filecat 6.65.1 → 6.67.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/build/dist/1384.3138b56fd880b4ef6b5a.js +1 -0
  2. package/build/dist/1458.4b7f874b4895f047f85d.js +1 -0
  3. package/build/dist/1472.26eae5dfbe640bd95007.js +1 -0
  4. package/build/dist/{5525.de31026d71adb2710e2d.js → 1911.5aa26af472734c5f1eeb.js} +1 -1
  5. package/build/dist/2091.5bc71c19b26140f00a48.js +1 -0
  6. package/build/dist/2851.6570385ed3b21d196648.js +1 -0
  7. package/build/dist/3659.f0dbf1eed0113cfeb0d2.js +1 -0
  8. package/build/dist/4273.136e9e07974f8cf908fb.js +1 -0
  9. package/build/dist/4903.462bc1f01c560e64bdf7.js +1 -0
  10. package/build/dist/5877.2a6d9ae0adf051f7629c.js +1 -0
  11. package/build/dist/5937.979de5c0672a08eb3b95.js +1 -0
  12. package/build/dist/6247.b49e239cf64a04aa3d19.js +1 -0
  13. package/build/dist/676.59a6aae24e044a731ead.js +1 -0
  14. package/build/dist/8302.e0f4d085e33b3b95b7a3.js +1 -0
  15. package/build/dist/8319.128f3b2f957ae19a6bf0.js +1 -0
  16. package/build/dist/9546.6347224c95e4ea71ca9e.js +1 -0
  17. package/build/dist/index.html +1 -1
  18. package/build/dist/main.0e7ed35ca4d77c86e560.js +2 -0
  19. package/build/main.js +1 -1
  20. package/package.json +13 -1
  21. package/build/dist/1472.7d429a0e8931548d4c65.js +0 -1
  22. package/build/dist/2851.c01bf2e1b109ff793f26.js +0 -1
  23. package/build/dist/3659.ff38a32734bc4b554f75.js +0 -1
  24. package/build/dist/4273.7a89027ccab7190e4bb3.js +0 -1
  25. package/build/dist/4903.5b155e7515c60da8e838.js +0 -1
  26. package/build/dist/5877.c3b8656d543de13651a0.js +0 -1
  27. package/build/dist/5937.cb255300ad4ecacbf26a.js +0 -1
  28. package/build/dist/6247.1924073703e9a1ac779e.js +0 -1
  29. package/build/dist/676.7db44f7b39bd0a3be5a6.js +0 -1
  30. package/build/dist/8302.905f1799092f205f27a6.js +0 -1
  31. package/build/dist/8319.bb6c2314a1e97312bfc4.js +0 -1
  32. package/build/dist/9546.44f31dcf58d9b3761677.js +0 -1
  33. package/build/dist/main.1af9587a0d6db4cebacf.js +0 -2
  34. /package/build/dist/{main.1af9587a0d6db4cebacf.js.LICENSE.txt → main.0e7ed35ca4d77c86e560.js.LICENSE.txt} +0 -0
@@ -0,0 +1 @@
1
+ "use strict";(self.webpackChunkfilecat=self.webpackChunkfilecat||[]).push([[1384],{18445(e,t,n){var r=n(31601),o=n.n(r),i=n(76314),s=n.n(i)()(o());s.push([e.id,'.ProseMirror-gapcursor {\n display: none;\n pointer-events: none;\n position: absolute;\n}\n\n.ProseMirror-gapcursor:after {\n content: "";\n display: block;\n position: absolute;\n top: -2px;\n width: 20px;\n border-top: 1px solid black;\n animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;\n}\n\n@keyframes ProseMirror-cursor-blink {\n to {\n visibility: hidden;\n }\n}\n\n.ProseMirror-focused .ProseMirror-gapcursor {\n display: block;\n}\n',""]);const l=s;n.d(t,["A",0,l])},93417(e,t,n){var r=n(31601),o=n.n(r),i=n(76314),s=n.n(i)()(o());s.push([e.id,".ProseMirror .tableWrapper {\n overflow-x: auto;\n}\n.ProseMirror table {\n border-collapse: collapse;\n table-layout: fixed;\n width: 100%;\n overflow: hidden;\n}\n.ProseMirror td,\n.ProseMirror th {\n vertical-align: top;\n box-sizing: border-box;\n position: relative;\n}\n\n.ProseMirror td:not([data-colwidth]):not(.column-resize-dragging),\n.ProseMirror th:not([data-colwidth]):not(.column-resize-dragging) {\n /* if there's no explicit width set and the column is not being resized, set a default width */\n min-width: var(--default-cell-min-width);\n}\n\n.ProseMirror .column-resize-handle {\n position: absolute;\n right: -2px;\n top: 0;\n bottom: 0;\n width: 4px;\n z-index: 20;\n background-color: #adf;\n pointer-events: none;\n}\n.ProseMirror.resize-cursor {\n cursor: ew-resize;\n cursor: col-resize;\n}\n/* Give selected cells a blue overlay */\n.ProseMirror .selectedCell:after {\n z-index: 2;\n position: absolute;\n content: '';\n left: 0;\n right: 0;\n top: 0;\n bottom: 0;\n background: rgba(200, 200, 255, 0.4);\n pointer-events: none;\n}\n",""]);const l=s;n.d(t,["A",0,l])},76800(e,t,n){var r=n(31601),o=n.n(r),i=n(76314),s=n.n(i)()(o());s.push([e.id,'.ProseMirror {\n position: relative;\n}\n\n.ProseMirror {\n word-wrap: break-word;\n white-space: pre-wrap;\n white-space: break-spaces;\n -webkit-font-variant-ligatures: none;\n font-variant-ligatures: none;\n font-feature-settings: "liga" 0; /* the above doesn\'t seem to work in Edge */\n}\n\n.ProseMirror pre {\n white-space: pre-wrap;\n}\n\n.ProseMirror li {\n position: relative;\n}\n\n.ProseMirror-hideselection *::selection { background: transparent; }\n.ProseMirror-hideselection *::-moz-selection { background: transparent; }\n.ProseMirror-hideselection { caret-color: transparent; }\n\n/* See https://code.haverbeke.berlin/prosemirror/prosemirror/issues/1421#issuecomment-1759320191 */\n.ProseMirror [draggable][contenteditable=false] { user-select: text }\n\n.ProseMirror-selectednode {\n outline: 2px solid #8cf;\n}\n\n/* Make sure li selections wrap around markers */\n\nli.ProseMirror-selectednode {\n outline: none;\n}\n\nli.ProseMirror-selectednode:after {\n content: "";\n position: absolute;\n left: -32px;\n right: -2px; top: -2px; bottom: -2px;\n border: 2px solid #8cf;\n pointer-events: none;\n}\n\n/* Protect against generic img rules */\n\nimg.ProseMirror-separator {\n display: inline !important;\n border: none !important;\n margin: 0 !important;\n}\n',""]);const l=s;n.d(t,["A",0,l])},50576(e,t,n){var r=n(85072),o=n.n(r),i=n(97825),s=n.n(i),l=n(77659),a=n.n(l),c=n(55056),h=n.n(c),d=n(10540),p=n.n(d),f=n(41113),u=n.n(f),m=n(18445),g={};g.styleTagTransform=u(),g.setAttributes=h(),g.insert=a().bind(null,"head"),g.domAPI=s(),g.insertStyleElement=p();o()(m.A,g),m.A&&m.A.locals&&m.A.locals},70432(e,t,n){var r=n(85072),o=n.n(r),i=n(97825),s=n.n(i),l=n(77659),a=n.n(l),c=n(55056),h=n.n(c),d=n(10540),p=n.n(d),f=n(41113),u=n.n(f),m=n(93417),g={};g.styleTagTransform=u(),g.setAttributes=h(),g.insert=a().bind(null,"head"),g.domAPI=s(),g.insertStyleElement=p();o()(m.A,g),m.A&&m.A.locals&&m.A.locals},41631(e,t,n){var r=n(85072),o=n.n(r),i=n(97825),s=n.n(i),l=n(77659),a=n.n(l),c=n(55056),h=n.n(c),d=n(10540),p=n.n(d),f=n(41113),u=n.n(f),m=n(76800),g={};g.styleTagTransform=u(),g.setAttributes=h(),g.insert=a().bind(null,"head"),g.domAPI=s(),g.insertStyleElement=p();o()(m.A,g),m.A&&m.A.locals&&m.A.locals},46762(e,t,n){n.d(t,{st:()=>C,wh:()=>k});var r=n(38262),o=n(58903),i=n(42845);const s=(e,t)=>!e.selection.empty&&(t&&t(e.tr.deleteSelection().scrollIntoView()),!0);function l(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock("backward",e):n.parentOffset>0)?null:n}function a(e,t,n=!1){for(let r=e;r;r="start"==t?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(n&&1!=r.childCount)return!1}return!1}function c(e){if(!e.parent.type.spec.isolating)for(let t=e.depth-1;t>=0;t--){if(e.index(t)>0)return e.doc.resolve(e.before(t+1));if(e.node(t).type.spec.isolating)break}return null}function h(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock("forward",e):n.parentOffset<n.parent.content.size)?null:n}function d(e){if(!e.parent.type.spec.isolating)for(let t=e.depth-1;t>=0;t--){let n=e.node(t);if(e.index(t)+1<n.childCount)return e.doc.resolve(e.after(t+1));if(n.type.spec.isolating)break}return null}const p=(e,t)=>{let{$head:n,$anchor:r}=e.selection;return!(!n.parent.type.spec.code||!n.sameParent(r))&&(t&&t(e.tr.insertText("\n").scrollIntoView()),!0)};function f(e){for(let t=0;t<e.edgeCount;t++){let{type:n}=e.edge(t);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}const u=(e,t)=>{let{$head:n,$anchor:r}=e.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let o=n.node(-1),s=n.indexAfter(-1),l=f(o.contentMatchAt(s));if(!l||!o.canReplaceWith(s,s,l))return!1;if(t){let r=n.after(),o=e.tr.replaceWith(r,r,l.createAndFill());o.setSelection(i.LN.near(o.doc.resolve(r),1)),t(o.scrollIntoView())}return!0},m=(e,t)=>{let n=e.selection,{$from:r,$to:o}=n;if(n instanceof i.i5||r.parent.inlineContent||o.parent.inlineContent)return!1;let s=f(o.parent.contentMatchAt(o.indexAfter()));if(!s||!s.isTextblock)return!1;if(t){let n=(!r.parentOffset&&o.index()<o.parent.childCount?r:o).pos,l=e.tr.insert(n,s.createAndFill());l.setSelection(i.U3.create(l.doc,n+1)),t(l.scrollIntoView())}return!0},g=(e,t)=>{let{$cursor:n}=e.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let o=n.before();if((0,r.zy)(e.doc,o))return t&&t(e.tr.split(o).scrollIntoView()),!0}let o=n.blockRange(),i=o&&(0,r.jP)(o);return null!=i&&(t&&t(e.tr.lift(o,i).scrollIntoView()),!0)};const w=(e,t)=>{if(e.selection instanceof i.nh&&e.selection.node.isBlock){let{$from:n}=e.selection;return!(!n.parentOffset||!(0,r.zy)(e.doc,n.pos)||(t&&t(e.tr.split(n.pos).scrollIntoView()),0))}if(!e.selection.$from.depth)return!1;let n=e.tr;!e.selection.empty&&(e.selection instanceof i.U3||e.selection instanceof i.i5)&&n.deleteSelection();let o,s,{$from:l}=n.selection,a=n.steps.length,c=[],h=!1,d=!1;for(let e=l.depth;;e--){if(l.node(e).isBlock){h=l.end(e)==l.pos+(l.depth-e),d=l.start(e)==l.pos-(l.depth-e),s=f(l.node(e-1).contentMatchAt(l.indexAfter(e-1)));let t=y&&y(l.parent,h,l);c.unshift(t||(h&&s?{type:s}:null)),o=e;break}if(1==e)return!1;c.unshift(null)}let p=l.pos,u=(0,r.zy)(n.doc,p,c.length,c);if(u||(c[0]=s?{type:s}:null,u=(0,r.zy)(n.doc,p,c.length,c)),!u)return!1;if(n.split(p,c.length,c),!h&&d&&l.node(o).type!=s){let e=n.mapping.slice(a),t=e.map(l.before(o)),r=n.doc.resolve(t);s&&l.node(o-1).canReplaceWith(r.index(),r.index()+1,s)&&n.setNodeMarkup(e.map(l.before(o)),s)}return t&&t(n.scrollIntoView()),!0};var y;function v(e,t,n,s){let l,c,h=t.nodeBefore,d=t.nodeAfter,p=h.type.spec.isolating||d.type.spec.isolating;if(!p&&function(e,t,n){let o=t.nodeBefore,i=t.nodeAfter,s=t.index();return!(!(o&&i&&o.type.compatibleContent(i.type))||(!o.content.size&&t.parent.canReplace(s-1,s)?(n&&n(e.tr.delete(t.pos-o.nodeSize,t.pos).scrollIntoView()),0):!t.parent.canReplace(s,s+1)||!i.isTextblock&&!(0,r.n9)(e.doc,t.pos)||(n&&n(e.tr.join(t.pos).scrollIntoView()),0)))}(e,t,n))return!0;let f=!p&&t.parent.canReplace(t.index(),t.index()+1);if(f&&(l=(c=h.contentMatchAt(h.childCount)).findWrapping(d.type))&&c.matchType(l[0]||d.type).validEnd){if(n){let i=t.pos+d.nodeSize,s=o.FK.empty;for(let e=l.length-1;e>=0;e--)s=o.FK.from(l[e].create(null,s));s=o.FK.from(h.copy(s));let a=e.tr.step(new r.Wg(t.pos-1,i,t.pos,i,new o.Ji(s,1,0),l.length,!0)),c=a.doc.resolve(i+2*l.length);c.nodeAfter&&c.nodeAfter.type==h.type&&(0,r.n9)(a.doc,c.pos)&&a.join(c.pos),n(a.scrollIntoView())}return!0}let u=d.type.spec.isolating||s>0&&p?null:i.LN.findFrom(t,1),m=u&&u.$from.blockRange(u.$to),g=m&&(0,r.jP)(m);if(null!=g&&g>=t.depth)return n&&n(e.tr.lift(m,g).scrollIntoView()),!0;if(f&&a(d,"start",!0)&&a(h,"end")){let i=h,s=[];for(;s.push(i),!i.isTextblock;)i=i.lastChild;let l=d,a=1;for(;!l.isTextblock;l=l.firstChild)a++;if(i.canReplace(i.childCount,i.childCount,l.content)){if(n){let i=o.FK.empty;for(let e=s.length-1;e>=0;e--)i=o.FK.from(s[e].copy(i));n(e.tr.step(new r.Wg(t.pos-s.length,t.pos+d.nodeSize,t.pos+a,t.pos+d.nodeSize-a,new o.Ji(i,s.length,0),0,!0)).scrollIntoView())}return!0}}return!1}function b(e){return function(t,n){let r=t.selection,o=e<0?r.$from:r.$to,s=o.depth;for(;o.node(s).isInline;){if(!s)return!1;s--}return!!o.node(s).isTextblock&&(n&&n(t.tr.setSelection(i.U3.create(t.doc,e<0?o.start(s):o.end(s)))),!0)}}const S=b(-1),x=b(1);function k(e,t=null,n){let r=!1!==(n&&n.removeWhenPresent),o=!1!==(n&&n.enterInlineAtoms),s=!(n&&n.includeWhitespace);return function(n,l){let{empty:a,$cursor:c,ranges:h}=n.selection;if(a&&!c||!function(e,t,n,r){for(let o=0;o<t.length;o++){let{$from:i,$to:s}=t[o],l=0==i.depth&&e.inlineContent&&e.type.allowsMarkType(n);if(e.nodesBetween(i.pos,s.pos,(e,t)=>{if(l||!r&&e.isAtom&&e.isInline&&t>=i.pos&&t+e.nodeSize<=s.pos)return!1;l=e.inlineContent&&e.type.allowsMarkType(n)}),l)return!0}return!1}(n.doc,h,e,o))return!1;if(l)if(c)e.isInSet(n.storedMarks||c.marks())?l(n.tr.removeStoredMark(e)):l(n.tr.addStoredMark(e.create(t)));else{let a,c=n.tr;o||(h=function(e){let t=[];for(let n=0;n<e.length;n++){let{$from:r,$to:o}=e[n];r.doc.nodesBetween(r.pos,o.pos,(e,n)=>{if(e.isAtom&&e.content.size&&e.isInline&&n>=r.pos&&n+e.nodeSize<=o.pos)return n+1>r.pos&&t.push(new i.yn(r,r.doc.resolve(n+1))),r=r.doc.resolve(n+1+e.content.size),!1}),r.pos<o.pos&&t.push(new i.yn(r,o))}return t}(h)),a=r?!h.some(t=>n.doc.rangeHasMark(t.$from.pos,t.$to.pos,e)):!h.every(t=>{let n=!1;return c.doc.nodesBetween(t.$from.pos,t.$to.pos,(r,o,i)=>{if(n)return!1;n=!e.isInSet(r.marks)&&!!i&&i.type.allowsMarkType(e)&&!(r.isText&&/^\s*$/.test(r.textBetween(Math.max(0,t.$from.pos-o),Math.min(r.nodeSize,t.$to.pos-o))))}),!n});for(let n=0;n<h.length;n++){let{$from:r,$to:o}=h[n];if(a){let n=r.pos,i=o.pos,l=r.nodeAfter,a=o.nodeBefore,h=s&&l&&l.isText?/^\s*/.exec(l.text)[0].length:0,d=s&&a&&a.isText?/\s*$/.exec(a.text)[0].length:0;n+h<i&&(n+=h,i-=d),c.addMark(n,i,e.create(t))}else c.removeMark(r.pos,o.pos,e)}l(c.scrollIntoView())}return!0}}function C(...e){return function(t,n,r){for(let o=0;o<e.length;o++)if(e[o](t,n,r))return!0;return!1}}let M=C(s,(e,t,n)=>{let s=l(e,n);if(!s)return!1;let h=c(s);if(!h){let n=s.blockRange(),o=n&&(0,r.jP)(n);return null!=o&&(t&&t(e.tr.lift(n,o).scrollIntoView()),!0)}let d=h.nodeBefore;if(v(e,h,t,-1))return!0;if(0==s.parent.content.size&&(a(d,"end")||i.nh.isSelectable(d)))for(let n=s.depth;;n--){let l=(0,r.$L)(e.doc,s.before(n),s.after(n),o.Ji.empty);if(l&&l.slice.size<l.to-l.from){if(t){let n=e.tr.step(l);n.setSelection(a(d,"end")?i.LN.findFrom(n.doc.resolve(n.mapping.map(h.pos,-1)),-1):i.nh.create(n.doc,h.pos-d.nodeSize)),t(n.scrollIntoView())}return!0}if(1==n||s.node(n-1).childCount>1)break}return!(!d.isAtom||h.depth!=s.depth-1)&&(t&&t(e.tr.delete(h.pos-d.nodeSize,h.pos).scrollIntoView()),!0)},(e,t,n)=>{let{$head:r,empty:o}=e.selection,s=r;if(!o)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("backward",e):r.parentOffset>0)return!1;s=c(r)}let l=s&&s.nodeBefore;return!(!l||!i.nh.isSelectable(l))&&(t&&t(e.tr.setSelection(i.nh.create(e.doc,s.pos-l.nodeSize)).scrollIntoView()),!0)}),N=C(s,(e,t,n)=>{let s=h(e,n);if(!s)return!1;let l=d(s);if(!l)return!1;let c=l.nodeAfter;if(v(e,l,t,1))return!0;if(0==s.parent.content.size&&(a(c,"start")||i.nh.isSelectable(c))){let n=(0,r.$L)(e.doc,s.before(),s.after(),o.Ji.empty);if(n&&n.slice.size<n.to-n.from){if(t){let r=e.tr.step(n);r.setSelection(a(c,"start")?i.LN.findFrom(r.doc.resolve(r.mapping.map(l.pos)),1):i.nh.create(r.doc,r.mapping.map(l.pos))),t(r.scrollIntoView())}return!0}}return!(!c.isAtom||l.depth!=s.depth-1)&&(t&&t(e.tr.delete(l.pos,l.pos+c.nodeSize).scrollIntoView()),!0)},(e,t,n)=>{let{$head:r,empty:o}=e.selection,s=r;if(!o)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("forward",e):r.parentOffset<r.parent.content.size)return!1;s=d(r)}let l=s&&s.nodeAfter;return!(!l||!i.nh.isSelectable(l))&&(t&&t(e.tr.setSelection(i.nh.create(e.doc,s.pos)).scrollIntoView()),!0)});const O={Enter:C(p,m,g,w),"Mod-Enter":u,Backspace:M,"Mod-Backspace":M,"Shift-Backspace":M,Delete:N,"Mod-Delete":N,"Mod-a":(e,t)=>(t&&t(e.tr.setSelection(new i.i5(e.doc))),!0)},D={"Ctrl-h":O.Backspace,"Alt-Backspace":O["Mod-Backspace"],"Ctrl-d":O.Delete,"Ctrl-Alt-Backspace":O["Mod-Delete"],"Alt-Delete":O["Mod-Delete"],"Alt-d":O["Mod-Delete"],"Ctrl-a":S,"Ctrl-e":x};for(let e in O)D[e]=O[e];const A=("undefined"!=typeof navigator?/Mac|iP(hone|[oa]d)/.test(navigator.platform):!("undefined"==typeof os||!os.platform)&&"darwin"==os.platform())?D:O;n.d(t,["I$",0,u,"RV",0,A,"Z1",0,m,"aw",0,w,"iz",0,g,"pC",0,p])},73337(e,t,n){n.d(t,{A:()=>i});var r=n(42845),o=n(38262);function i(e={}){return new r.k_({view:t=>new s(t,e)})}class s{constructor(e,t){var n;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.lastDragEvent=null,this.width=null!==(n=t.width)&&void 0!==n?n:1,this.color=!1===t.color?void 0:t.color||"black",this.class=t.class,this.handlers=["dragover","dragend","drop","dragleave"].map(t=>{let n=e=>{this[t](e)};return e.dom.addEventListener(t,n),{name:t,handler:n}})}destroy(){this.setCursor(null),this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){if(null!=this.cursorPos&&t.doc!=e.state.doc)if(this.lastDragEvent){let e=this.computeTarget(this.lastDragEvent);e==this.cursorPos?this.updateOverlay():this.setCursor(e)}else this.updateOverlay()}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,null==e?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e,t=this.editorView.state.doc.resolve(this.cursorPos),n=!t.parent.inlineContent,r=this.editorView.dom,o=r.getBoundingClientRect(),i=o.width/r.offsetWidth,s=o.height/r.offsetHeight;if(n){let n=t.nodeBefore,r=t.nodeAfter;if(n||r){let t=this.editorView.nodeDOM(this.cursorPos-(n?n.nodeSize:0));if(t){let o=t.getBoundingClientRect(),i=n?o.bottom:o.top;n&&r&&(i=(i+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let l=this.width/2*s;e={left:o.left,right:o.right,top:i-l,bottom:i+l}}}}if(!e){let t=this.editorView.coordsAtPos(this.cursorPos),n=this.width/2*i;e={left:t.left-n,right:t.left+n,top:t.top,bottom:t.bottom}}let l,a,c=this.editorView.dom.offsetParent;if(this.element||(this.element=c.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",n),this.element.classList.toggle("prosemirror-dropcursor-inline",!n),!c||c==document.body&&"static"==getComputedStyle(c).position)l=-pageXOffset,a=-pageYOffset;else{let e=c.getBoundingClientRect(),t=e.width/c.offsetWidth,n=e.height/c.offsetHeight;l=e.left-c.scrollLeft*t,a=e.top-c.scrollTop*n}this.element.style.left=(e.left-l)/i+"px",this.element.style.top=(e.top-a)/s+"px",this.element.style.width=(e.right-e.left)/i+"px",this.element.style.height=(e.bottom-e.top)/s+"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),r=n&&n.type.spec.disableDropCursor,i="function"==typeof r?r(this.editorView,t,e):r;if(!t||i)return null;let s=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let e=(0,o.Um)(this.editorView.state.doc,s,this.editorView.dragging.slice);null!=e&&(s=e)}return s}dragover(e){if(!this.editorView.editable)return;this.lastDragEvent=e;let t=this.computeTarget(e);null!=t&&(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)}}},89552(e,t,n){n.d(t,{z:()=>h});var r=n(61396),o=n(42845),i=n(58903),s=n(1575);class l extends o.LN{constructor(e){super(e,e)}map(e,t){let n=e.resolve(t.map(this.head));return l.valid(n)?new l(n):o.LN.near(n)}content(){return i.Ji.empty}eq(e){return e instanceof l&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,t){if("number"!=typeof t.pos)throw new RangeError("Invalid input for GapCursor.fromJSON");return new l(e.resolve(t.pos))}getBookmark(){return new a(this.anchor)}static valid(e){let t=e.parent;if(t.inlineContent||!function(e){for(let t=e.depth;t>=0;t--){let n=e.index(t),r=e.node(t);if(0!=n)for(let e=r.child(n-1);;e=e.lastChild){if(0==e.childCount&&!e.inlineContent||c(e.type))return!0;if(e.inlineContent)return!1}else if(r.type.spec.isolating)return!0}return!0}(e)||!function(e){for(let t=e.depth;t>=0;t--){let n=e.indexAfter(t),r=e.node(t);if(n!=r.childCount)for(let e=r.child(n);;e=e.firstChild){if(0==e.childCount&&!e.inlineContent||c(e.type))return!0;if(e.inlineContent)return!1}else if(r.type.spec.isolating)return!0}return!0}(e))return!1;let n=t.type.spec.allowGapCursor;if(null!=n)return n;let r=t.contentMatchAt(e.index()).defaultType;return r&&r.isTextblock}static findGapCursorFrom(e,t,n=!1){e:for(;;){if(!n&&l.valid(e))return e;let r=e.pos,i=null;for(let n=e.depth;;n--){let o=e.node(n);if(t>0?e.indexAfter(n)<o.childCount:e.index(n)>0){i=o.child(t>0?e.indexAfter(n):e.index(n)-1);break}if(0==n)return null;r+=t;let s=e.doc.resolve(r);if(l.valid(s))return s}for(;;){let s=t>0?i.firstChild:i.lastChild;if(!s){if(i.isAtom&&!i.isText&&!o.nh.isSelectable(i)){e=e.doc.resolve(r+i.nodeSize*t),n=!1;continue e}break}i=s,r+=t;let a=e.doc.resolve(r);if(l.valid(a))return a}return null}}}l.prototype.visible=!1,l.findFrom=l.findGapCursorFrom,o.LN.jsonID("gapcursor",l);class a{constructor(e){this.pos=e}map(e){return new a(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return l.valid(t)?new l(t):o.LN.near(t)}}function c(e){return e.isAtom||e.spec.isolating||e.spec.createGapCursor}function h(){return new o.k_({props:{decorations:m,createSelectionBetween:(e,t,n)=>t.pos==n.pos&&l.valid(n)?new l(n):null,handleClick:f,handleKeyDown:d,handleDOMEvents:{beforeinput:u}}})}const d=(0,r.K)({ArrowLeft:p("horiz",-1),ArrowRight:p("horiz",1),ArrowUp:p("vert",-1),ArrowDown:p("vert",1)});function p(e,t){const n="vert"==e?t>0?"down":"up":t>0?"right":"left";return function(e,r,i){let s=e.selection,a=t>0?s.$to:s.$from,c=s.empty;if(s instanceof o.U3){if(!i.endOfTextblock(n)||0==a.depth)return!1;c=!1,a=e.doc.resolve(t>0?a.after():a.before())}let h=l.findGapCursorFrom(a,t,c);return!!h&&(r&&r(e.tr.setSelection(new l(h))),!0)}}function f(e,t,n){if(!e||!e.editable)return!1;let r=e.state.doc.resolve(t);if(!l.valid(r))return!1;let i=e.posAtCoords({left:n.clientX,top:n.clientY});return!(i&&i.inside>-1&&o.nh.isSelectable(e.state.doc.nodeAt(i.inside)))&&(e.dispatch(e.state.tr.setSelection(new l(r))),!0)}function u(e,t){if("insertCompositionText"!=t.inputType||!(e.state.selection instanceof l))return!1;let{$from:n}=e.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(e.state.schema.nodes.text);if(!r)return!1;let s=i.FK.empty;for(let e=r.length-1;e>=0;e--)s=i.FK.from(r[e].createAndFill(null,s));let a=e.state.tr.replace(n.pos,n.pos,new i.Ji(s,0,0));return a.setSelection(o.U3.near(a.doc.resolve(n.pos+1))),e.dispatch(a),!1}function m(e){if(!(e.selection instanceof l))return null;let t=document.createElement("div");return t.className="ProseMirror-gapcursor",s.zF.create(e.doc,[s.NZ.widget(e.selection.head,t,{key:"gapcursor"})])}},89781(e,t,n){n.d(t,{b6:()=>S});var r=200,o=function(){};o.prototype.append=function(e){return e.length?(e=o.from(e),!this.length&&e||e.length<r&&this.leafAppend(e)||this.length<r&&e.leafPrepend(this)||this.appendInner(e)):this},o.prototype.prepend=function(e){return e.length?o.from(e).append(this):this},o.prototype.appendInner=function(e){return new s(this,e)},o.prototype.slice=function(e,t){return void 0===e&&(e=0),void 0===t&&(t=this.length),e>=t?o.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},o.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},o.prototype.forEach=function(e,t,n){void 0===t&&(t=0),void 0===n&&(n=this.length),t<=n?this.forEachInner(e,t,n,0):this.forEachInvertedInner(e,t,n,0)},o.prototype.map=function(e,t,n){void 0===t&&(t=0),void 0===n&&(n=this.length);var r=[];return this.forEach(function(t,n){return r.push(e(t,n))},t,n),r},o.from=function(e){return e instanceof o?e:e&&e.length?new i(e):o.empty};var i=function(e){function t(t){e.call(this),this.values=t}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var n={length:{configurable:!0},depth:{configurable:!0}};return t.prototype.flatten=function(){return this.values},t.prototype.sliceInner=function(e,n){return 0==e&&n==this.length?this:new t(this.values.slice(e,n))},t.prototype.getInner=function(e){return this.values[e]},t.prototype.forEachInner=function(e,t,n,r){for(var o=t;o<n;o++)if(!1===e(this.values[o],r+o))return!1},t.prototype.forEachInvertedInner=function(e,t,n,r){for(var o=t-1;o>=n;o--)if(!1===e(this.values[o],r+o))return!1},t.prototype.leafAppend=function(e){if(this.length+e.length<=r)return new t(this.values.concat(e.flatten()))},t.prototype.leafPrepend=function(e){if(this.length+e.length<=r)return new t(e.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(t.prototype,n),t}(o);o.empty=new i([]);var s=function(e){function t(t,n){e.call(this),this.left=t,this.right=n,this.length=t.length+n.length,this.depth=Math.max(t.depth,n.depth)+1}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},t.prototype.getInner=function(e){return e<this.left.length?this.left.get(e):this.right.get(e-this.left.length)},t.prototype.forEachInner=function(e,t,n,r){var o=this.left.length;return!(t<o&&!1===this.left.forEachInner(e,t,Math.min(n,o),r))&&(!(n>o&&!1===this.right.forEachInner(e,Math.max(t-o,0),Math.min(this.length,n)-o,r+o))&&void 0)},t.prototype.forEachInvertedInner=function(e,t,n,r){var o=this.left.length;return!(t>o&&!1===this.right.forEachInvertedInner(e,t-o,Math.max(n,o)-o,r+o))&&(!(n<o&&!1===this.left.forEachInvertedInner(e,Math.min(t,o),n,r))&&void 0)},t.prototype.sliceInner=function(e,t){if(0==e&&t==this.length)return this;var n=this.left.length;return t<=n?this.left.slice(e,t):e>=n?this.right.slice(e-n,t-n):this.left.slice(e,n).append(this.right.slice(0,t-n))},t.prototype.leafAppend=function(e){var n=this.right.leafAppend(e);if(n)return new t(this.left,n)},t.prototype.leafPrepend=function(e){var n=this.left.leafPrepend(e);if(n)return new t(n,this.right)},t.prototype.appendInner=function(e){return this.left.depth>=Math.max(this.right.depth,e.depth)+1?new t(this.left,new t(this.right,e)):new t(this,e)},t}(o);const l=o;var a=n(38262),c=n(42845);class h{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(0==this.eventCount)return null;let n,r,o=this.items.length;for(;;o--){if(this.items.get(o-1).selection){--o;break}}t&&(n=this.remapping(o,this.items.length),r=n.maps.length);let i,s,l=e.tr,a=[],c=[];return this.items.forEach((e,t)=>{if(!e.step)return n||(n=this.remapping(o,t+1),r=n.maps.length),r--,void c.push(e);if(n){c.push(new d(e.map));let t,o=e.step.map(n.slice(r));o&&l.maybeStep(o).doc&&(t=l.mapping.maps[l.mapping.maps.length-1],a.push(new d(t,void 0,void 0,a.length+c.length))),r--,t&&n.appendMap(t,r)}else l.maybeStep(e.step);return e.selection?(i=n?e.selection.map(n.slice(r)):e.selection,s=new h(this.items.slice(0,o).append(c.reverse().concat(a)),this.eventCount-1),!1):void 0},this.items.length,0),{remaining:s,transform:l,selection:i}}addTransform(e,t,n,r){let o=[],i=this.eventCount,s=this.items,l=!r&&s.length?s.get(s.length-1):null;for(let n=0;n<e.steps.length;n++){let a,c=e.steps[n].invert(e.docs[n]),h=new d(e.mapping.maps[n],c,t);(a=l&&l.merge(h))&&(h=a,n?o.pop():s=s.slice(0,s.length-1)),o.push(h),t&&(i++,t=void 0),r||(l=h)}let a=i-n.depth;return a>f&&(s=function(e,t){let n;return e.forEach((e,r)=>{if(e.selection&&0==t--)return n=r,!1}),e.slice(n)}(s,a),i-=a),new h(s.append(o),i)}remapping(e,t){let n=new a.X9;return this.items.forEach((t,r)=>{let o=null!=t.mirrorOffset&&r-t.mirrorOffset>=e?n.maps.length-t.mirrorOffset:void 0;n.appendMap(t.map,o)},e,t),n}addMaps(e){return 0==this.eventCount?this:new h(this.items.append(e.map(e=>new d(e))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let n=[],r=Math.max(0,this.items.length-t),o=e.mapping,i=e.steps.length,s=this.eventCount;this.items.forEach(e=>{e.selection&&s--},r);let l=t;this.items.forEach(t=>{let r=o.getMirror(--l);if(null==r)return;i=Math.min(i,r);let a=o.maps[r];if(t.step){let i=e.steps[r].invert(e.docs[r]),c=t.selection&&t.selection.map(o.slice(l+1,r));c&&s++,n.push(new d(a,i,c))}else n.push(new d(a))},r);let a=[];for(let e=t;e<i;e++)a.push(new d(o.maps[e]));let c=this.items.slice(0,r).append(a).append(n),p=new h(c,s);return p.emptyItemCount()>500&&(p=p.compress(this.items.length-n.length)),p}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,r=[],o=0;return this.items.forEach((i,s)=>{if(s>=e)r.push(i),i.selection&&o++;else if(i.step){let e=i.step.map(t.slice(n)),s=e&&e.getMap();if(n--,s&&t.appendMap(s,n),e){let l=i.selection&&i.selection.map(t.slice(n));l&&o++;let a,c=new d(s.invert(),e,l),h=r.length-1;(a=r.length&&r[h].merge(c))?r[h]=a:r.push(c)}}else i.map&&n--},this.items.length,0),new h(l.from(r.reverse()),o)}}h.empty=new h(l.empty,0);class d{constructor(e,t,n,r){this.map=e,this.step=t,this.selection=n,this.mirrorOffset=r}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new d(t.getMap().invert(),t,this.selection)}}}class p{constructor(e,t,n,r,o){this.done=e,this.undone=t,this.prevRanges=n,this.prevTime=r,this.prevComposition=o}}const f=20;function u(e){let t=[];for(let n=e.length-1;n>=0&&0==t.length;n--)e[n].forEach((e,n,r,o)=>t.push(r,o));return t}function m(e,t){if(!e)return null;let n=[];for(let r=0;r<e.length;r+=2){let o=t.map(e[r],1),i=t.map(e[r+1],-1);o<=i&&n.push(o,i)}return n}let g=!1,w=null;function y(e){let t=e.plugins;if(w!=t){g=!1,w=t;for(let e=0;e<t.length;e++)if(t[e].spec.historyPreserveItems){g=!0;break}}return g}const v=new c.hs("history"),b=new c.hs("closeHistory");function S(e={}){return e={depth:e.depth||100,newGroupDelay:e.newGroupDelay||500},new c.k_({key:v,state:{init:()=>new p(h.empty,h.empty,null,0,-1),apply:(t,n,r)=>function(e,t,n,r){let o,i=n.getMeta(v);if(i)return i.historyState;n.getMeta(b)&&(e=new p(e.done,e.undone,null,0,-1));let s=n.getMeta("appendedTransaction");if(0==n.steps.length)return e;if(s&&s.getMeta(v))return s.getMeta(v).redo?new p(e.done.addTransform(n,void 0,r,y(t)),e.undone,u(n.mapping.maps),e.prevTime,e.prevComposition):new p(e.done,e.undone.addTransform(n,void 0,r,y(t)),null,e.prevTime,e.prevComposition);if(!1===n.getMeta("addToHistory")||s&&!1===s.getMeta("addToHistory"))return(o=n.getMeta("rebased"))?new p(e.done.rebased(n,o),e.undone.rebased(n,o),m(e.prevRanges,n.mapping),e.prevTime,e.prevComposition):new p(e.done.addMaps(n.mapping.maps),e.undone.addMaps(n.mapping.maps),m(e.prevRanges,n.mapping),e.prevTime,e.prevComposition);{let o=n.getMeta("composition"),i=0==e.prevTime||!s&&e.prevComposition!=o&&(e.prevTime<(n.time||0)-r.newGroupDelay||!function(e,t){if(!t)return!1;if(!e.docChanged)return!0;let n=!1;return e.mapping.maps[0].forEach((e,r)=>{for(let o=0;o<t.length;o+=2)e<=t[o+1]&&r>=t[o]&&(n=!0)}),n}(n,e.prevRanges)),l=s?m(e.prevRanges,n.mapping):u(n.mapping.maps);return new p(e.done.addTransform(n,i?t.selection.getBookmark():void 0,r,y(t)),h.empty,l,n.time,o??e.prevComposition)}}(n,r,t,e)},config:e,props:{handleDOMEvents:{beforeinput(e,t){let n=t.inputType,r="historyUndo"==n?k:"historyRedo"==n?C:null;return!(!r||!e.editable)&&(t.preventDefault(),r(e.state,e.dispatch))}}}})}function x(e,t){return(n,r)=>{let o=v.getState(n);if(!o||0==(e?o.undone:o.done).eventCount)return!1;if(r){let i=function(e,t,n){let r=y(t),o=v.get(t).spec.config,i=(n?e.undone:e.done).popEvent(t,r);if(!i)return null;let s=i.selection.resolve(i.transform.doc),l=(n?e.done:e.undone).addTransform(i.transform,t.selection.getBookmark(),o,r),a=new p(n?l:i.remaining,n?i.remaining:l,null,0,-1);return i.transform.setSelection(s).setMeta(v,{redo:n,historyState:a})}(o,n,e);i&&r(t?i.scrollIntoView():i)}return!0}}const k=x(!1,!0),C=x(!0,!0);x(!1,!1),x(!0,!1)},38341(e,t,n){n.d(t,{JJ:()=>d,sM:()=>s,tG:()=>h});var r=n(42845),o=n(38262);class i{constructor(e,t,n={}){var r;this.match=e,this.match=e,this.handler="string"==typeof t?(r=t,function(e,t,n,o){let i=r;if(t[1]){let e=t[0].lastIndexOf(t[1]);i+=t[0].slice(e+t[1].length);let r=(n+=e)-o;r>0&&(i=t[0].slice(e-r,e)+i,n=o)}return e.tr.insertText(i,n,o)}):t,this.undoable=!1!==n.undoable,this.inCode=n.inCode||!1,this.inCodeMark=!1!==n.inCodeMark}}function s({rules:e}){let t=new r.k_({state:{init:()=>null,apply(e,t){let n=e.getMeta(this);return n||(e.selectionSet||e.docChanged?null:t)}},props:{handleTextInput:(n,r,o,i)=>l(n,r,o,i,e,t),handleDOMEvents:{compositionend:n=>{setTimeout(()=>{let{$cursor:r}=n.state.selection;r&&l(n,r.pos,r.pos,"",e,t)})}}},isInputRules:!0});return t}function l(e,t,n,r,o,i){if(e.composing)return!1;let s=e.state,l=s.doc.resolve(t),a=l.parent.textBetween(Math.max(0,l.parentOffset-500),l.parentOffset,null,"")+r;for(let c=0;c<o.length;c++){let h=o[c];if(!h.inCodeMark&&l.marks().some(e=>e.type.spec.code))continue;if(l.parent.type.spec.code){if(!h.inCode)continue}else if("only"===h.inCode)continue;let d=h.match.exec(a);if(!d||d[0].length<r.length)continue;let p=t-(d[0].length-r.length);if(!h.inCodeMark){let e=!1;if(s.doc.nodesBetween(p,l.pos,t=>{t.isInline&&t.marks.some(e=>e.type.spec.code)&&(e=!0)}),e)continue}let f=h.handler(s,d,p,n);if(f)return h.undoable&&f.setMeta(i,{transform:f,from:t,to:n,text:r}),e.dispatch(f),!0}return!1}new i(/--$/,"—",{inCodeMark:!1});const a=new i(/\.\.\.$/,"…",{inCodeMark:!1}),c=[new i(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,"“",{inCodeMark:!1}),new i(/"$/,"”",{inCodeMark:!1}),new i(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,"‘",{inCodeMark:!1}),new i(/'$/,"’",{inCodeMark:!1})];function h(e,t,n=null,r){return new i(e,(e,i,s,l)=>{let a=n instanceof Function?n(i):n,c=e.tr.delete(s,l),h=c.doc.resolve(s).blockRange(),d=h&&(0,o.oM)(h,t,a);if(!d)return null;c.wrap(h,d);let p=c.doc.resolve(s-1).nodeBefore;return p&&p.type==t&&(0,o.n9)(c.doc,s-1)&&(!r||r(i,p))&&c.join(s-1),c})}function d(e,t,n=null){return new i(e,(e,r,o,i)=>{let s=e.doc.resolve(o),l=n instanceof Function?n(r):n;return s.node(-1).canReplaceWith(s.index(-1),s.indexAfter(-1),t)?e.tr.delete(o,i).setBlockType(o,o,t,l):null})}n.d(t,["Fr",0,c,"gO",0,a])},61396(e,t,n){n.d(t,{K:()=>m,w:()=>u});for(var r={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:"'"},o={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},i="undefined"!=typeof navigator&&/Mac/.test(navigator.platform),s="undefined"!=typeof navigator&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),l=0;l<10;l++)r[48+l]=r[96+l]=String(l);for(l=1;l<=24;l++)r[l+111]="F"+l;for(l=65;l<=90;l++)r[l]=String.fromCharCode(l+32),o[l]=String.fromCharCode(l);for(var a in r)o.hasOwnProperty(a)||(o[a]=r[a]);var c=n(42845);const h="undefined"!=typeof navigator&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),d="undefined"!=typeof navigator&&/Win/.test(navigator.platform);function p(e){let t,n,r,o,i=e.split(/-(?!$)/),s=i[i.length-1];"Space"==s&&(s=" ");for(let e=0;e<i.length-1;e++){let s=i[e];if(/^(cmd|meta|m)$/i.test(s))o=!0;else if(/^a(lt)?$/i.test(s))t=!0;else if(/^(c|ctrl|control)$/i.test(s))n=!0;else if(/^s(hift)?$/i.test(s))r=!0;else{if(!/^mod$/i.test(s))throw new Error("Unrecognized modifier name: "+s);h?o=!0:n=!0}}return t&&(s="Alt-"+s),n&&(s="Ctrl-"+s),o&&(s="Meta-"+s),r&&(s="Shift-"+s),s}function f(e,t,n=!0){return t.altKey&&(e="Alt-"+e),t.ctrlKey&&(e="Ctrl-"+e),t.metaKey&&(e="Meta-"+e),n&&t.shiftKey&&(e="Shift-"+e),e}function u(e){return new c.k_({props:{handleKeyDown:m(e)}})}function m(e){let t=function(e){let t=Object.create(null);for(let n in e)t[p(n)]=e[n];return t}(e);return function(e,n){let l,a=function(e){var t=!(i&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||s&&e.shiftKey&&e.key&&1==e.key.length||"Unidentified"==e.key)&&e.key||(e.shiftKey?o:r)[e.keyCode]||e.key||"Unidentified";return"Esc"==t&&(t="Escape"),"Del"==t&&(t="Delete"),"Left"==t&&(t="ArrowLeft"),"Up"==t&&(t="ArrowUp"),"Right"==t&&(t="ArrowRight"),"Down"==t&&(t="ArrowDown"),t}(n),c=t[f(a,n)];if(c&&c(e.state,e.dispatch,e))return!0;if(1==a.length&&" "!=a){if(n.shiftKey){let r=t[f(a,n,!1)];if(r&&r(e.state,e.dispatch,e))return!0}if((n.altKey||n.metaKey||n.ctrlKey)&&!(d&&n.ctrlKey&&n.altKey)&&(l=r[n.keyCode])&&l!=a){let r=t[f(l,n)];if(r&&r(e.state,e.dispatch,e))return!0}}return!1}}},58903(e,t,n){function r(e){this.content=e}n.d(t,{S4:()=>ee,ZF:()=>he,FK:()=>c,CU:()=>f,sX:()=>Z,bP:()=>I,u$:()=>E,vI:()=>u,Sj:()=>Y,Ji:()=>m}),r.prototype={constructor:r,find:function(e){for(var t=0;t<this.content.length;t+=2)if(this.content[t]===e)return t;return-1},get:function(e){var t=this.find(e);return-1==t?void 0:this.content[t+1]},update:function(e,t,n){var o=n&&n!=e?this.remove(n):this,i=o.find(e),s=o.content.slice();return-1==i?s.push(n||e,t):(s[i+1]=t,n&&(s[i]=n)),new r(s)},remove:function(e){var t=this.find(e);if(-1==t)return this;var n=this.content.slice();return n.splice(t,2),new r(n)},addToStart:function(e,t){return new r([e,t].concat(this.remove(e).content))},addToEnd:function(e,t){var n=this.remove(e).content.slice();return n.push(e,t),new r(n)},addBefore:function(e,t,n){var o=this.remove(t),i=o.content.slice(),s=o.find(e);return i.splice(-1==s?i.length:s,0,t,n),new r(i)},forEach:function(e){for(var t=0;t<this.content.length;t+=2)e(this.content[t],this.content[t+1])},prepend:function(e){return(e=r.from(e)).size?new r(e.content.concat(this.subtract(e).content)):this},append:function(e){return(e=r.from(e)).size?new r(this.subtract(e).content.concat(e.content)):this},subtract:function(e){var t=this;e=r.from(e);for(var n=0;n<e.content.length;n+=2)t=t.remove(e.content[n]);return t},toObject:function(){var e={};return this.forEach(function(t,n){e[t]=n}),e},get size(){return this.content.length>>1}},r.from=function(e){if(e instanceof r)return e;var t=[];if(e)for(var n in e)t.push(n,e[n]);return new r(t)};const o=r;function i(e,t,n){for(let r=0;;r++){if(r==e.childCount||r==t.childCount)return e.childCount==t.childCount?null:n;let o=e.child(r),s=t.child(r);if(o!=s){if(!o.sameMarkup(s))return n;if(o.isText&&o.text!=s.text){let e=o.text,t=s.text,r=0;for(;e[r]==t[r];r++)n++;return r&&r<e.length&&r<t.length&&a(e.charCodeAt(r-1))&&l(e.charCodeAt(r))&&n--,n}if(o.content.size||s.content.size){let e=i(o.content,s.content,n+1);if(null!=e)return e}n+=o.nodeSize}else n+=o.nodeSize}}function s(e,t,n,r){for(let o=e.childCount,i=t.childCount;;){if(0==o||0==i)return o==i?null:{a:n,b:r};let c=e.child(--o),h=t.child(--i),d=c.nodeSize;if(c!=h){if(!c.sameMarkup(h))return{a:n,b:r};if(c.isText&&c.text!=h.text){let e=c.text,t=h.text,o=e.length,i=t.length;for(;o>0&&i>0&&e[o-1]==t[i-1];)o--,i--,n--,r--;return o&&i&&o<e.length&&a(e.charCodeAt(o-1))&&l(e.charCodeAt(o))&&(n++,r++),{a:n,b:r}}if(c.content.size||h.content.size){let e=s(c.content,h.content,n-1,r-1);if(e)return e}n-=d,r-=d}else n-=d,r-=d}}function l(e){return e>=56320&&e<57344}function a(e){return e>=55296&&e<56320}class c{constructor(e,t){if(this.content=e,this.size=t||0,null==t)for(let t=0;t<e.length;t++)this.size+=e[t].nodeSize}nodesBetween(e,t,n,r=0,o){for(let i=0,s=0;s<t;i++){let l=this.content[i],a=s+l.nodeSize;if(a>e&&!1!==n(l,r+s,o||null,i)&&l.content.size){let o=s+1;l.nodesBetween(Math.max(0,e-o),Math.min(l.content.size,t-o),n,r+o)}s=a}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,n,r){let o="",i=!0;return this.nodesBetween(e,t,(s,l)=>{let a=s.isText?s.text.slice(Math.max(e,l)-l,t-l):s.isLeaf?r?"function"==typeof r?r(s):r:s.type.spec.leafText?s.type.spec.leafText(s):"":"";s.isBlock&&(s.isLeaf&&a||s.isTextblock)&&n&&(i?i=!1:o+=n),o+=a},0),o}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,n=e.firstChild,r=this.content.slice(),o=0;for(t.isText&&t.sameMarkup(n)&&(r[r.length-1]=t.withText(t.text+n.text),o=1);o<e.content.length;o++)r.push(e.content[o]);return new c(r,this.size+e.size)}cut(e,t=this.size){if(0==e&&t==this.size)return this;let n=[],r=0;if(t>e)for(let o=0,i=0;i<t;o++){let s=this.content[o],l=i+s.nodeSize;l>e&&((i<e||l>t)&&(s=s.isText?s.cut(Math.max(0,e-i),Math.min(s.text.length,t-i)):s.cut(Math.max(0,e-i-1),Math.min(s.content.size,t-i-1))),n.push(s),r+=s.nodeSize),i=l}return new c(n,r)}cutByIndex(e,t){return e==t?c.empty:0==e&&t==this.content.length?this:new c(this.content.slice(e,t))}replaceChild(e,t){let n=this.content[e];if(n==t)return this;let r=this.content.slice(),o=this.size+t.nodeSize-n.nodeSize;return r[e]=t,new c(r,o)}addToStart(e){return new c([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new c(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 r=this.content[t];e(r,n,t),n+=r.nodeSize}}findDiffStart(e,t=0){return i(this,e,t)}findDiffEnd(e,t=this.size,n=e.size){return s(this,e,t,n)}findIndex(e){if(0==e)return d(0,e);if(e==this.size)return d(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 r=n+this.child(t).nodeSize;if(r>=e)return r==e?d(t+1,r):d(t,n);n=r}}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 c.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return c.fromArray(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return c.empty;let t,n=0;for(let r=0;r<e.length;r++){let o=e[r];n+=o.nodeSize,r&&o.isText&&e[r-1].sameMarkup(o)?(t||(t=e.slice(0,r)),t[t.length-1]=o.withText(t[t.length-1].text+o.text)):t&&t.push(o)}return new c(t||e,n)}static from(e){if(!e)return c.empty;if(e instanceof c)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new c([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}c.empty=new c([],0);const h={index:0,offset:0};function d(e,t){return h.index=e,h.offset=t,h}function p(e,t){if(e===t)return!0;if(!e||"object"!=typeof e||!t||"object"!=typeof t)return!1;let n=Array.isArray(e);if(Array.isArray(t)!=n)return!1;if(n){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!p(e[n],t[n]))return!1}else{for(let n in e)if(!(n in t)||!p(e[n],t[n]))return!1;for(let n in t)if(!(n in e))return!1}return!0}class f{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,n=!1;for(let r=0;r<e.length;r++){let o=e[r];if(this.eq(o))return e;if(this.type.excludes(o.type))t||(t=e.slice(0,r));else{if(o.type.excludes(this.type))return e;!n&&o.type.rank>this.type.rank&&(t||(t=e.slice(0,r)),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&&p(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)&&0==e.length)return f.none;if(e instanceof f)return[e];let t=e.slice();return t.sort((e,t)=>e.type.rank-t.type.rank),t}}f.none=[];class u extends Error{}class m{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=w(this.content,e+this.openStart,t,this.openStart+1,this.openEnd+1);return n&&new m(n,this.openStart,this.openEnd)}removeBetween(e,t){return new m(g(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 m.empty;let n=t.openStart||0,r=t.openEnd||0;if("number"!=typeof n||"number"!=typeof r)throw new RangeError("Invalid input for Slice.fromJSON");return new m(c.fromJSON(e,t.content),n,r)}static maxOpen(e,t=!0){let n=0,r=0;for(let r=e.firstChild;r&&!r.isLeaf&&(t||!r.type.spec.isolating);r=r.firstChild)n++;for(let n=e.lastChild;n&&!n.isLeaf&&(t||!n.type.spec.isolating);n=n.lastChild)r++;return new m(e,n,r)}}function g(e,t,n){let{index:r,offset:o}=e.findIndex(t),i=e.maybeChild(r),{index:s,offset:l}=e.findIndex(n);if(o==t||i.isText){if(l!=n&&!e.child(s).isText)throw new RangeError("Removing non-flat range");return e.cut(0,t).append(e.cut(n))}if(r!=s)throw new RangeError("Removing non-flat range");return e.replaceChild(r,i.copy(g(i.content,t-o-1,n-o-1)))}function w(e,t,n,r,o,i){let{index:s,offset:l}=e.findIndex(t),a=e.maybeChild(s);if(l==t||a.isText)return i&&r<=0&&o<=0&&!i.canReplace(s,s,n)?null:e.cut(0,t).append(n).append(e.cut(t));let c=w(a.content,t-l-1,n,0==s?r-1:0,s==e.childCount-1?o-1:0,a);return c&&e.replaceChild(s,a.copy(c))}function y(e,t,n){if(n.openStart>e.depth)throw new u("Inserted content deeper than insertion position");if(e.depth-n.openStart!=t.depth-n.openEnd)throw new u("Inconsistent open depths");return v(e,t,n,0)}function v(e,t,n,r){let o=e.index(r),i=e.node(r);if(o==t.index(r)&&r<e.depth-n.openStart){let s=v(e,t,n,r+1);return i.copy(i.content.replaceChild(o,s))}if(n.content.size){if(n.openStart||n.openEnd||e.depth!=r||t.depth!=r){let{start:o,end:s}=function(e,t){let n=t.depth-e.openStart,r=t.node(n).copy(e.content);for(let e=n-1;e>=0;e--)r=t.node(e).copy(c.from(r));return{start:r.resolveNoCache(e.openStart+n),end:r.resolveNoCache(r.content.size-e.openEnd-n)}}(n,e);return C(i,M(e,o,s,t,r))}{let r=e.parent,o=r.content;return C(r,o.cut(0,e.parentOffset).append(n.content).append(o.cut(t.parentOffset)))}}return C(i,N(e,t,r))}function b(e,t){if(!t.type.compatibleContent(e.type))throw new u("Cannot join "+t.type.name+" onto "+e.type.name)}function S(e,t,n){let r=e.node(n);return b(r,t.node(n)),r}function x(e,t){let n=t.length-1;n>=0&&e.isText&&e.sameMarkup(t[n])?t[n]=e.withText(t[n].text+e.text):t.push(e)}function k(e,t,n,r){let o=(t||e).node(n),i=0,s=t?t.index(n):o.childCount;e&&(i=e.index(n),e.depth>n?i++:e.textOffset&&(x(e.nodeAfter,r),i++));for(let e=i;e<s;e++)x(o.child(e),r);t&&t.depth==n&&t.textOffset&&x(t.nodeBefore,r)}function C(e,t){if(!e.type.validContent(t))throw new u("Invalid content for node "+e.type.name);return e.copy(t)}function M(e,t,n,r,o){let i=e.depth>o&&S(e,t,o+1),s=r.depth>o&&S(n,r,o+1),l=[];return k(null,e,o,l),i&&s&&t.index(o)==n.index(o)?(b(i,s),x(C(i,M(e,t,n,r,o+1)),l)):(i&&x(C(i,N(e,t,o+1)),l),k(t,n,o,l),s&&x(C(s,N(n,r,o+1)),l)),k(r,null,o,l),new c(l)}function N(e,t,n){let r=[];if(k(null,e,n,r),e.depth>n){x(C(S(e,t,n+1),N(e,t,n+1)),r)}return k(t,null,n,r),new c(r)}m.empty=new m(c.empty,0,0);class O{constructor(e,t,n){this.pos=e,this.path=t,this.parentOffset=n,this.depth=t.length/3-1}resolveDepth(e){return null==e?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[3*this.resolveDepth(e)]}index(e){return this.path[3*this.resolveDepth(e)+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e!=this.depth||this.textOffset?1:0)}start(e){return 0==(e=this.resolveDepth(e))?0:this.path[3*e-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(!(e=this.resolveDepth(e)))throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[3*e-1]}after(e){if(!(e=this.resolveDepth(e)))throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[3*e-1]+this.path[3*e].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],r=e.child(t);return n?e.child(t).cut(n):r}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):0==e?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let n=this.path[3*t],r=0==t?0:this.path[3*t-1]+1;for(let t=0;t<e;t++)r+=n.child(t).nodeSize;return r}marks(){let e=this.parent,t=this.index();if(0==e.content.size)return f.none;if(this.textOffset)return e.child(t).marks;let n=e.maybeChild(t-1),r=e.maybeChild(t);if(!n){let e=n;n=r,r=e}let o=n.marks;for(var i=0;i<o.length;i++)!1!==o[i].type.spec.inclusive||r&&o[i].isInSet(r.marks)||(o=o[i--].removeFromSet(o));return o}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let n=t.marks,r=e.parent.maybeChild(e.index());for(var o=0;o<n.length;o++)!1!==n[o].type.spec.inclusive||r&&n[o].isInSet(r.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 E(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=[],r=0,o=t;for(let t=e;;){let{index:e,offset:i}=t.content.findIndex(o),s=o-i;if(n.push(t,e,r+i),!s)break;if(t=t.child(e),t.isText)break;o=s-1,r+=i+1}return new O(t,n,o)}static resolveCached(e,t){let n=T.get(e);if(n)for(let e=0;e<n.elts.length;e++){let r=n.elts[e];if(r.pos==t)return r}else T.set(e,n=new D);let r=n.elts[n.i]=O.resolve(e,t);return n.i=(n.i+1)%A,r}}class D{constructor(){this.elts=[],this.i=0}}const A=12,T=new WeakMap;class E{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)}}const R=Object.create(null);class I{constructor(e,t,n,r=f.none){this.type=e,this.attrs=t,this.marks=r,this.content=n||c.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,r=0){this.content.nodesBetween(e,t,n,r,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,r){return this.content.textBetween(e,t,n,r)}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&&p(this.attrs,t||e.defaultAttrs||R)&&f.sameSet(this.marks,n||f.none)}copy(e=null){return e==this.content?this:new I(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new I(this.type,this.attrs,this.content,e)}cut(e,t=this.content.size){return 0==e&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,n=!1){if(e==t)return m.empty;let r=this.resolve(e),o=this.resolve(t),i=n?0:r.sharedDepth(t),s=r.start(i),l=r.node(i).content.cut(r.pos-s,o.pos-s);return new m(l,r.depth-i,o.depth-i)}replace(e,t,n){return y(this.resolve(e),this.resolve(t),n)}nodeAt(e){for(let t=this;;){let{index:n,offset:r}=t.content.findIndex(e);if(t=t.maybeChild(n),!t)return null;if(r==e||t.isText)return t;e-=r+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(0==e)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 r=this.content.child(t-1);return{node:r,index:t-1,offset:n-r.nodeSize}}resolve(e){return O.resolveCached(this,e)}resolveNoCache(e){return O.resolve(this,e)}rangeHasMark(e,t,n){let r=!1;return t>e&&this.nodesBetween(e,t,e=>(n.isInSet(e.marks)&&(r=!0),!r)),r}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()+")"),$(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=c.empty,r=0,o=n.childCount){let i=this.contentMatchAt(e).matchFragment(n,r,o),s=i&&i.matchFragment(this.content,t);if(!s||!s.validEnd)return!1;for(let e=r;e<o;e++)if(!this.type.allowsMarks(n.child(e).marks))return!1;return!0}canReplaceWith(e,t,n,r){if(r&&!this.type.allowsMarks(r))return!1;let o=this.contentMatchAt(e).matchType(n),i=o&&o.matchFragment(this.content,t);return!!i&&i.validEnd}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),F(this.type.attrs,this.attrs,"node",this.type.name);let e=f.none;for(let t=0;t<this.marks.length;t++){let n=this.marks[t];F(n.type.attrs,n.attrs,"mark",n.type.name),e=n.addToSet(e)}if(!f.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(e=>e.type.name)}`);this.content.forEach(e=>e.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(e=>e.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("text"==t.type){if("string"!=typeof t.text)throw new RangeError("Invalid text node in JSON");return e.text(t.text,n)}let r=c.fromJSON(e,t.content);return e.nodeType(t.type).create(t.attrs,r,n)}}I.prototype.text=void 0;class z extends I{constructor(e,t,n,r){if(super(e,t,null,r),!n)throw new RangeError("Empty text nodes are not allowed");this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):$(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new z(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new z(this.type,this.attrs,e,this.marks)}cut(e=0,t=this.text.length){return 0==e&&t==this.text.length?this:this.withText(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 $(e,t){for(let n=e.length-1;n>=0;n--)t=e[n].type.name+"("+t+")";return t}function F(e,t,n,r){for(let o in t)if(!(o in e))throw new RangeError(`Unsupported attribute ${o} for ${n} of type ${r}`);for(let n in e)e[n].validate&&e[n].validate(t[n])}class P{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let n=new B(e,t);if(null==n.next)return P.empty;let r=V(n);n.next&&n.err("Unexpected trailing text");let o=function(e){let t=Object.create(null);return n(q(e,0));function n(r){let o=[];r.forEach(t=>{e[t].forEach(({term:t,to:n})=>{if(!t)return;let r;for(let e=0;e<o.length;e++)o[e][0]==t&&(r=o[e][1]);q(e,n).forEach(e=>{r||o.push([t,r=[]]),-1==r.indexOf(e)&&r.push(e)})})});let i=t[r.join(",")]=new P(r.indexOf(e.length-1)>-1);for(let e=0;e<o.length;e++){let r=o[e][1].sort(_);i.next.push({type:o[e][0],next:t[r.join(",")]||n(r)})}return i}}(function(e){let t=[[]];return o(i(e,0),n()),t;function n(){return t.push([])-1}function r(e,n,r){let o={term:r,to:n};return t[e].push(o),o}function o(e,t){e.forEach(e=>e.to=t)}function i(e,t){if("choice"==e.type)return e.exprs.reduce((e,n)=>e.concat(i(n,t)),[]);if("seq"!=e.type){if("star"==e.type){let s=n();return r(t,s),o(i(e.expr,s),s),[r(s)]}if("plus"==e.type){let s=n();return o(i(e.expr,t),s),o(i(e.expr,s),s),[r(s)]}if("opt"==e.type)return[r(t)].concat(i(e.expr,t));if("range"==e.type){let s=t;for(let t=0;t<e.min;t++){let t=n();o(i(e.expr,s),t),s=t}if(-1==e.max)o(i(e.expr,s),s);else for(let t=e.min;t<e.max;t++){let t=n();r(s,t),o(i(e.expr,s),t),s=t}return[r(s)]}if("name"==e.type)return[r(t,void 0,e.value)];throw new Error("Unknown expr type")}for(let r=0;;r++){let s=i(e.exprs[r],t);if(r==e.exprs.length-1)return s;o(s,t=n())}}}(r));return function(e,t){for(let n=0,r=[e];n<r.length;n++){let e=r[n],o=!e.validEnd,i=[];for(let t=0;t<e.next.length;t++){let{type:n,next:s}=e.next[t];i.push(n.name),!o||n.isText||n.hasRequiredAttrs()||(o=!1),-1==r.indexOf(s)&&r.push(s)}o&&t.err("Only non-generatable nodes ("+i.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}(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 r=this;for(let o=t;r&&o<n;o++)r=r.matchType(e.child(o).type);return r}get inlineContent(){return 0!=this.next.length&&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 r=[this];return function o(i,s){let l=i.matchFragment(e,n);if(l&&(!t||l.validEnd))return c.from(s.map(e=>e.createAndFill()));for(let e=0;e<i.next.length;e++){let{type:t,next:n}=i.next[e];if(!t.isText&&!t.hasRequiredAttrs()&&-1==r.indexOf(n)){r.push(n);let e=o(n,s.concat(t));if(e)return e}}return null}(this,[])}findWrapping(e){for(let t=0;t<this.wrapCache.length;t+=2)if(this.wrapCache[t]==e)return this.wrapCache[t+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 r=n.shift(),o=r.match;if(o.matchType(e)){let e=[];for(let t=r;t.type;t=t.via)e.push(t.type);return e.reverse()}for(let e=0;e<o.next.length;e++){let{type:i,next:s}=o.next[e];i.isLeaf||i.hasRequiredAttrs()||i.name in t||r.type&&!s.validEnd||(n.push({match:i.contentMatch,type:i,via:r}),t[i.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=[];return function t(n){e.push(n);for(let r=0;r<n.next.length;r++)-1==e.indexOf(n.next[r].next)&&t(n.next[r].next)}(this),e.map((t,n)=>{let r=n+(t.validEnd?"*":" ")+" ";for(let n=0;n<t.next.length;n++)r+=(n?", ":"")+t.next[n].type.name+"->"+e.indexOf(t.next[n].next);return r}).join("\n")}}P.empty=new P(!0);class B{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 V(e){let t=[];do{t.push(L(e))}while(e.eat("|"));return 1==t.length?t[0]:{type:"choice",exprs:t}}function L(e){let t=[];do{t.push(J(e))}while(e.next&&")"!=e.next&&"|"!=e.next);return 1==t.length?t[0]:{type:"seq",exprs:t}}function J(e){let t=function(e){if(e.eat("(")){let t=V(e);return e.eat(")")||e.err("Missing closing paren"),t}if(!/\W/.test(e.next)){let t=function(e,t){let n=e.nodeTypes,r=n[t];if(r)return[r];let o=[];for(let e in n){let r=n[e];r.isInGroup(t)&&o.push(r)}0==o.length&&e.err("No node type or group '"+t+"' found");return o}(e,e.next).map(t=>(null==e.inline?e.inline=t.isInline:e.inline!=t.isInline&&e.err("Mixing inline and block content"),{type:"name",value:t}));return e.pos++,1==t.length?t[0]:{type:"choice",exprs:t}}e.err("Unexpected token '"+e.next+"'")}(e);for(;;)if(e.eat("+"))t={type:"plus",expr:t};else if(e.eat("*"))t={type:"star",expr:t};else if(e.eat("?"))t={type:"opt",expr:t};else{if(!e.eat("{"))break;t=W(e,t)}return t}function K(e){/\D/.test(e.next)&&e.err("Expected number, got '"+e.next+"'");let t=Number(e.next);return e.pos++,t}function W(e,t){let n=K(e),r=n;return e.eat(",")&&(r="}"!=e.next?K(e):-1),e.eat("}")||e.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:t}}function _(e,t){return t-e}function q(e,t){let n=[];return function t(r){let o=e[r];if(1==o.length&&!o[0].term)return t(o[0].to);n.push(r);for(let e=0;e<o.length;e++){let{term:r,to:i}=o[e];r||-1!=n.indexOf(i)||t(i)}}(t),n.sort(_)}function j(e){let t=Object.create(null);for(let n in e){let r=e[n];if(!r.hasDefault)return null;t[n]=r.default}return t}function U(e,t){let n=Object.create(null);for(let r in e){let o=e[r],i=t&&t[r];if(void 0===i){if(!o.hasDefault)throw new RangeError("No value supplied for attribute "+r);i=o.default}else o.validate&&o.validate(i);n[r]=i}return n}function H(e,t){let n=Object.create(null);if(t)for(let r in t)n[r]=new X(e,r,t[r]);return n}class G{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=H(e,n.attrs),this.defaultAttrs=j(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(n.inline||"text"==e),this.isText="text"==e}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==P.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:U(this.attrs,e)}create(e=null,t,n){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new I(this,this.computeAttrs(e),c.from(t),f.setFrom(n))}createChecked(e=null,t,n){return t=c.from(t),this.checkContent(t),new I(this,this.computeAttrs(e),t,f.setFrom(n))}createAndFill(e=null,t,n){if(e=this.computeAttrs(e),(t=c.from(t)).size){let e=this.contentMatch.fillBefore(t);if(!e)return null;t=e.append(t)}let r=this.contentMatch.matchFragment(t),o=r&&r.fillBefore(c.empty,!0);return o?new I(this,e,t.append(o),f.setFrom(n)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let t=0;t<e.childCount;t++)if(!this.allowsMarks(e.child(t).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 null==this.markSet||this.markSet.indexOf(e)>-1}allowsMarks(e){if(null==this.markSet)return!0;for(let t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){if(null==this.markSet)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:f.none:e}static compile(e,t){let n=Object.create(null);e.forEach((e,r)=>n[e]=new G(e,t,r));let r=t.spec.topNode||"doc";if(!n[r])throw new RangeError("Schema is missing its top node type ('"+r+"')");if(!n.text)throw new RangeError("Every schema needs a 'text' type");for(let e in n.text.attrs)throw new RangeError("The text node type should not have attributes");return n}}class X{constructor(e,t,n){this.hasDefault=Object.prototype.hasOwnProperty.call(n,"default"),this.default=n.default,this.validate="string"==typeof n.validate?function(e,t,n){let r=n.split("|");return n=>{let o=null===n?"null":typeof n;if(r.indexOf(o)<0)throw new RangeError(`Expected value of type ${r} for attribute ${t} on type ${e}, got ${o}`)}}(e,t,n.validate):n.validate}get isRequired(){return!this.hasDefault}}class Z{constructor(e,t,n,r){this.name=e,this.rank=t,this.schema=n,this.spec=r,this.attrs=H(e,r.attrs),this.excluded=null;let o=j(this.attrs);this.instance=o?new f(this,o):null}create(e=null){return!e&&this.instance?this.instance:new f(this,U(this.attrs,e))}static compile(e,t){let n=Object.create(null),r=0;return e.forEach((e,o)=>n[e]=new Z(e,r++,t,o)),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}}class Y{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let n in e)t[n]=e[n];t.nodes=o.from(e.nodes),t.marks=o.from(e.marks||{}),this.nodes=G.compile(this.spec.nodes,this),this.marks=Z.compile(this.spec.marks,this);let n=Object.create(null);for(let e in this.nodes){if(e in this.marks)throw new RangeError(e+" can not be both a node and a mark");let t=this.nodes[e],r=t.spec.content||"",o=t.spec.marks;if(t.contentMatch=n[r]||(n[r]=P.parse(r,this.nodes)),t.inlineContent=t.contentMatch.inlineContent,t.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!t.isInline||!t.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=t}t.markSet="_"==o?null:o?Q(this,o.split(" ")):""!=o&&t.inlineContent?null:[]}for(let e in this.marks){let t=this.marks[e],n=t.spec.excludes;t.excluded=null==n?[t]:""==n?[]:Q(this,n.split(" "))}this.nodeFromJSON=e=>I.fromJSON(this,e),this.markFromJSON=e=>f.fromJSON(this,e),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,n,r){if("string"==typeof e)e=this.nodeType(e);else{if(!(e instanceof G))throw new RangeError("Invalid node type: "+e);if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}return e.createChecked(t,n,r)}text(e,t){let n=this.nodes.text;return new z(n,n.defaultAttrs,e,f.setFrom(t))}mark(e,t){return"string"==typeof e&&(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 Q(e,t){let n=[];for(let r=0;r<t.length;r++){let o=t[r],i=e.marks[o],s=i;if(i)n.push(i);else for(let t in e.marks){let r=e.marks[t];("_"==o||r.spec.group&&r.spec.group.split(" ").indexOf(o)>-1)&&n.push(s=r)}if(!s)throw new SyntaxError("Unknown mark type: '"+t[r]+"'")}return n}class ee{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let n=this.matchedStyles=[];t.forEach(e=>{if(function(e){return null!=e.tag}(e))this.tags.push(e);else if(function(e){return null!=e.style}(e)){let t=/[^=]*/.exec(e.style)[0];n.indexOf(t)<0&&n.push(t),this.styles.push(e)}}),this.normalizeLists=!this.tags.some(t=>{if(!/^(ul|ol)\b/.test(t.tag)||!t.node)return!1;let n=e.nodes[t.node];return n.contentMatch.matchType(n)})}parse(e,t={}){let n=new se(this,t,!1);return n.addAll(e,f.none,t.from,t.to),n.finish()}parseSlice(e,t={}){let n=new se(this,t,!0);return n.addAll(e,f.none,t.from,t.to),m.maxOpen(n.finish())}matchTag(e,t,n){for(let r=n?this.tags.indexOf(n)+1:0;r<this.tags.length;r++){let n=this.tags[r];if(le(e,n.tag)&&(void 0===n.namespace||e.namespaceURI==n.namespace)&&(!n.context||t.matchesContext(n.context))){if(n.getAttrs){let t=n.getAttrs(e);if(!1===t)continue;n.attrs=t||void 0}return n}}}matchStyle(e,t,n,r){for(let o=r?this.styles.indexOf(r)+1:0;o<this.styles.length;o++){let r=this.styles[o],i=r.style;if(!(0!=i.indexOf(e)||r.context&&!n.matchesContext(r.context)||i.length>e.length&&(61!=i.charCodeAt(e.length)||i.slice(e.length+1)!=t))){if(r.getAttrs){let e=r.getAttrs(t);if(!1===e)continue;r.attrs=e||void 0}return r}}}static schemaRules(e){let t=[];function n(e){let n=null==e.priority?50:e.priority,r=0;for(;r<t.length;r++){let e=t[r];if((null==e.priority?50:e.priority)<n)break}t.splice(r,0,e)}for(let t in e.marks){let r=e.marks[t].spec.parseDOM;r&&r.forEach(e=>{n(e=ae(e)),e.mark||e.ignore||e.clearMark||(e.mark=t)})}for(let t in e.nodes){let r=e.nodes[t].spec.parseDOM;r&&r.forEach(e=>{n(e=ae(e)),e.node||e.ignore||e.mark||(e.node=t)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new ee(e,ee.schemaRules(e)))}}const te={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},ne={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},re={ol:!0,ul:!0};function oe(e,t,n){return null!=t?(t?1:0)|("full"===t?2:0):e&&"pre"==e.whitespace?3:-5&n}class ie{constructor(e,t,n,r,o,i){this.type=e,this.attrs=t,this.marks=n,this.solid=r,this.options=i,this.content=[],this.activeMarks=f.none,this.match=o||(4&i?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(c.from(e));if(!t){let t,n=this.type.contentMatch;return(t=n.findWrapping(e.type))?(this.match=n,t):null}this.match=this.type.contentMatch.matchFragment(t)}return this.match.findWrapping(e.type)}finish(e){if(!(1&this.options)){let e,t=this.content[this.content.length-1];if(t&&t.isText&&(e=/[ \t\r\n\u000c]+$/.exec(t.text))){let n=t;t.text.length==e[0].length?this.content.pop():this.content[this.content.length-1]=n.withText(n.text.slice(0,n.text.length-e[0].length))}}let t=c.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(c.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&&!te.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class se{constructor(e,t,n){this.parser=e,this.options=t,this.isOpen=n,this.open=0,this.localPreserveWS=!1;let r,o=t.topNode,i=oe(null,t.preserveWhitespace,0)|(n?4:0);r=o?new ie(o.type,o.attrs,f.none,!0,t.topMatch||o.type.contentMatch,i):new ie(n?null:e.schema.topNodeType,null,f.none,!0,null,i),this.nodes=[r],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){3==e.nodeType?this.addTextNode(e,t):1==e.nodeType&&this.addElement(e,t)}addTextNode(e,t){let n=e.nodeValue,r=this.top,o=2&r.options?"full":this.localPreserveWS||(1&r.options)>0,{schema:i}=this.parser;if("full"===o||r.inlineContext(e)||/[^ \t\r\n\u000c]/.test(n)){if(o)if("full"===o)n=n.replace(/\r\n?/g,"\n");else if(i.linebreakReplacement&&/[\r\n]/.test(n)&&this.top.findWrapping(i.linebreakReplacement.create())){let e=n.split(/\r?\n|\r/);for(let n=0;n<e.length;n++)n&&this.insertNode(i.linebreakReplacement.create(),t,!0),e[n]&&this.insertNode(i.text(e[n]),t,!/\S/.test(e[n]));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 t=r.content[r.content.length-1],o=e.previousSibling;(!t||o&&"BR"==o.nodeName||t.isText&&/[ \t\r\n\u000c]$/.test(t.text))&&(n=n.slice(1))}n&&this.insertNode(i.text(n),t,!/\S/.test(n)),this.findInText(e)}else this.findInside(e)}addElement(e,t,n){let r=this.localPreserveWS,o=this.top;("PRE"==e.tagName||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let i,s=e.nodeName.toLowerCase();re.hasOwnProperty(s)&&this.parser.normalizeLists&&function(e){for(let t=e.firstChild,n=null;t;t=t.nextSibling){let e=1==t.nodeType?t.nodeName.toLowerCase():null;e&&re.hasOwnProperty(e)&&n?(n.appendChild(t),t=n):"li"==e?n=t:e&&(n=null)}}(e);let l=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(i=this.parser.matchTag(e,this,n));e:if(l?l.ignore:ne.hasOwnProperty(s))this.findInside(e),this.ignoreFallback(e,t);else if(!l||l.skip||l.closeParent){l&&l.closeParent?this.open=Math.max(0,this.open-1):l&&l.skip.nodeType&&(e=l.skip);let n,r=this.needsBlock;if(te.hasOwnProperty(s))o.content.length&&o.content[0].isInline&&this.open&&(this.open--,o=this.top),n=!0,o.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break e}let i=l&&l.skip?t:this.readStyles(e,t);i&&this.addAll(e,i),n&&this.sync(o),this.needsBlock=r}else{let n=this.readStyles(e,t);n&&this.addElementByRule(e,l,n,!1===l.consuming?i:void 0)}this.localPreserveWS=r}leafFallback(e,t){"BR"==e.nodeName&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode("\n"),t)}ignoreFallback(e,t){"BR"!=e.nodeName||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 e=0;e<this.parser.matchedStyles.length;e++){let r=this.parser.matchedStyles[e],o=n.getPropertyValue(r);if(o)for(let e;;){let n=this.parser.matchStyle(r,o,this,e);if(!n)break;if(n.ignore)return null;if(t=n.clearMark?t.filter(e=>!n.clearMark(e)):t.concat(this.parser.schema.marks[n.mark].create(n.attrs)),!1!==n.consuming)break;e=n}}return t}addElementByRule(e,t,n,r){let o,i;if(t.node)if(i=this.parser.schema.nodes[t.node],i.isLeaf)this.insertNode(i.create(t.attrs),n,"BR"==e.nodeName)||this.leafFallback(e,n);else{let e=this.enter(i,t.attrs||null,n,t.preserveWhitespace);e&&(o=!0,n=e)}else{let e=this.parser.schema.marks[t.mark];n=n.concat(e.create(t.attrs))}let s=this.top;if(i&&i.isLeaf)this.findInside(e);else if(r)this.addElement(e,n,r);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(e=>this.insertNode(e,n,!1));else{let r=e;"string"==typeof t.contentElement?r=e.querySelector(t.contentElement):"function"==typeof t.contentElement?r=t.contentElement(e):t.contentElement&&(r=t.contentElement),this.findAround(e,r,!0),this.addAll(r,n),this.findAround(e,r,!1)}o&&this.sync(s)&&this.open--}addAll(e,t,n,r){let o=n||0;for(let i=n?e.childNodes[n]:e.firstChild,s=null==r?null:e.childNodes[r];i!=s;i=i.nextSibling,++o)this.findAtPoint(e,o),this.addDOM(i,t);this.findAtPoint(e,o)}findPlace(e,t,n){let r,o;for(let t=this.open,i=0;t>=0;t--){let s=this.nodes[t],l=s.findWrapping(e);if(l&&(!r||r.length>l.length+i)&&(r=l,o=s,!l.length))break;if(s.solid){if(n)break;i+=2}}if(!r)return null;this.sync(o);for(let e=0;e<r.length;e++)t=this.enterInner(r[e],null,t,!1);return t}insertNode(e,t,n){if(e.isInline&&this.needsBlock&&!this.top.type){let e=this.textblockFromContext();e&&(t=this.enterInner(e,null,t))}let r=this.findPlace(e,t,n);if(r){this.closeExtra();let t=this.top;t.match&&(t.match=t.match.matchType(e.type));let n=f.none;for(let o of r.concat(e.marks))(t.type?t.type.allowsMarkType(o.type):ce(o.type,e.type))&&(n=o.addToSet(n));return t.content.push(e.mark(n)),!0}return!1}enter(e,t,n,r){let o=this.findPlace(e.create(t),n,!1);return o&&(o=this.enterInner(e,t,n,!0,r)),o}enterInner(e,t,n,r=!1,o){this.closeExtra();let i=this.top;i.match=i.match&&i.match.matchType(e);let s=oe(e,o,i.options);4&i.options&&0==i.content.length&&(s|=4);let l=f.none;return n=n.filter(t=>!(i.type?i.type.allowsMarkType(t.type):ce(t.type,e))||(l=t.addToSet(l),!1)),this.nodes.push(new ie(e,t,l,r,null,s)),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|=1)}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 t=n.length-1;t>=0;t--)e+=n[t].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++)null==this.find[t].pos&&1==e.nodeType&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,n){if(e!=t&&this.find)for(let r=0;r<this.find.length;r++)if(null==this.find[r].pos&&1==e.nodeType&&e.contains(this.find[r].node)){t.compareDocumentPosition(this.find[r].node)&(n?2:4)&&(this.find[r].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,r=!(this.isOpen||n&&n.parent.type!=this.nodes[0].type),o=-(n?n.depth+1:0)+(r?0:1),i=(e,s)=>{for(;e>=0;e--){let l=t[e];if(""==l){if(e==t.length-1||0==e)continue;for(;s>=o;s--)if(i(e-1,s))return!0;return!1}{let e=s>0||0==s&&r?this.nodes[s].type:n&&s>=o?n.node(s-o).type:null;if(!e||e.name!=l&&!e.isInGroup(l))return!1;s--}}return!0};return i(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 e in this.parser.schema.nodes){let t=this.parser.schema.nodes[e];if(t.isTextblock&&t.defaultAttrs)return t}}}function le(e,t){return(e.matches||e.msMatchesSelector||e.webkitMatchesSelector||e.mozMatchesSelector).call(e,t)}function ae(e){let t={};for(let n in e)t[n]=e[n];return t}function ce(e,t){let n=t.schema.nodes;for(let r in n){let o=n[r];if(!o.allowsMarkType(e))continue;let i=[],s=e=>{i.push(e);for(let n=0;n<e.edgeCount;n++){let{type:r,next:o}=e.edge(n);if(r==t)return!0;if(i.indexOf(o)<0&&s(o))return!0}};if(s(o.contentMatch))return!0}}class he{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},n){n||(n=pe(t).createDocumentFragment());let r=n,o=[];return e.forEach(e=>{if(o.length||e.marks.length){let n=0,i=0;for(;n<o.length&&i<e.marks.length;){let t=e.marks[i];if(this.marks[t.type.name]){if(!t.eq(o[n][0])||!1===t.type.spec.spanning)break;n++,i++}else i++}for(;n<o.length;)r=o.pop()[1];for(;i<e.marks.length;){let n=e.marks[i++],s=this.serializeMark(n,e.isInline,t);s&&(o.push([n,r]),r.appendChild(s.dom),r=s.contentDOM||s.dom)}}r.appendChild(this.serializeNodeInner(e,t))}),n}serializeNodeInner(e,t){if(e.isText)return pe(t).createTextNode(e.text);let{dom:n,contentDOM:r}=me(pe(t),this.nodes[e.type.name](e),null,e.attrs);if(r){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,r)}return n}serializeNode(e,t={}){let n=this.serializeNodeInner(e,t);for(let r=e.marks.length-1;r>=0;r--){let o=this.serializeMark(e.marks[r],e.isInline,t);o&&((o.contentDOM||o.dom).appendChild(n),n=o.dom)}return n}serializeMark(e,t,n={}){let r=this.marks[e.type.name];return r&&me(pe(n),r(e,t),null,e.attrs)}static renderSpec(e,t,n=null,r){return"string"==typeof t?{dom:e.createTextNode(t)}:me(e,t,n,r)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new he(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=de(e.nodes);return t.text||(t.text=e=>e.text),t}static marksFromSchema(e){return de(e.marks)}}function de(e){let t={};for(let n in e){let r=e[n].spec.toDOM;r&&(t[n]=r)}return t}function pe(e){return e.document||window.document}const fe=new WeakMap;function ue(e){let t=fe.get(e);return void 0===t&&fe.set(e,t=function(e){let t=null;function n(e){if(e&&"object"==typeof e)if(Array.isArray(e))if("string"==typeof e[0])t||(t=[]),t.push(e);else for(let t=0;t<e.length;t++)n(e[t]);else for(let t in e)n(e[t])}return n(e),t}(e)),t}function me(e,t,n,r){if(1==t.nodeType)return{dom:t};if(t.dom&&1==t.dom.nodeType)return t;let o,i=t[0];if("string"!=typeof i)throw new RangeError("Invalid array passed to renderSpec");if(r&&(o=ue(r))&&o.indexOf(t)>-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,l=i.indexOf(" ");l>0&&(n=i.slice(0,l),i=i.slice(l+1));let a=n?e.createElementNS(n,i):e.createElement(i),c=t[1],h=1;if(c&&"object"==typeof c&&null==c.nodeType&&!Array.isArray(c)){h=2;for(let e in c)if(null!=c[e]){let t=e.indexOf(" ");t>0?a.setAttributeNS(e.slice(0,t),e.slice(t+1),c[e]):"style"==e&&a.style?a.style.cssText=c[e]:a.setAttribute(e,c[e])}}for(let o=h;o<t.length;o++){let i=t[o];if(0===i){if(o<t.length-1||o>h)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}if("string"==typeof i)a.appendChild(e.createTextNode(i));else{let{dom:t,contentDOM:o}=me(e,i,n,r);if(a.appendChild(t),o){if(s)throw new RangeError("Multiple content holes");s=o}}}return{dom:a,contentDOM:s}}},3772(e,t,n){n.d(t,{$B:()=>c,Sd:()=>s,T2:()=>a,wn:()=>l});var r=n(38262),o=n(58903),i=n(42845);function s(e,t=null){return function(n,i){let{$from:s,$to:l}=n.selection,a=s.blockRange(l);if(!a)return!1;let c=i?n.tr:null;return!!function(e,t,n,i=null){let s=!1,l=t,a=t.$from.doc;if(t.depth>=2&&t.$from.node(t.depth-1).type.compatibleContent(n)&&0==t.startIndex){if(0==t.$from.index(t.depth-1))return!1;let e=a.resolve(t.start-2);l=new o.u$(e,e,t.depth),t.endIndex<t.parent.childCount&&(t=new o.u$(t.$from,a.resolve(t.$to.end(t.depth)),t.depth)),s=!0}let c=(0,r.oM)(l,n,i,t);if(!c)return!1;e&&function(e,t,n,i,s){let l=o.FK.empty;for(let e=n.length-1;e>=0;e--)l=o.FK.from(n[e].type.create(n[e].attrs,l));e.step(new r.Wg(t.start-(i?2:0),t.end,t.start,t.end,new o.Ji(l,0,0),n.length,!0));let a=0;for(let e=0;e<n.length;e++)n[e].type==s&&(a=e+1);let c=n.length-a,h=t.start+n.length-(i?2:0),d=t.parent;for(let n=t.startIndex,o=t.endIndex,i=!0;n<o;n++,i=!1)!i&&(0,r.zy)(e.doc,h,c)&&(e.split(h,c),h+=2*c),h+=d.child(n).nodeSize}(e,t,c,s,n);return!0}(c,a,e,t)&&(i&&i(c.scrollIntoView()),!0)}}function l(e,t){return function(n,s){let{$from:l,$to:a,node:c}=n.selection;if(c&&c.isBlock||l.depth<2||!l.sameParent(a))return!1;let h=l.node(-1);if(h.type!=e)return!1;if(0==l.parent.content.size&&l.node(-1).childCount==l.indexAfter(-1)){if(3==l.depth||l.node(-3).type!=e||l.index(-2)!=l.node(-2).childCount-1)return!1;if(s){let t=o.FK.empty,r=l.index(-1)?1:l.index(-2)?2:3;for(let e=l.depth-r;e>=l.depth-3;e--)t=o.FK.from(l.node(e).copy(t));let a=l.indexAfter(-1)<l.node(-2).childCount?1:l.indexAfter(-2)<l.node(-3).childCount?2:3;t=t.append(o.FK.from(e.createAndFill()));let c=l.before(l.depth-(r-1)),h=n.tr.replace(c,l.after(-a),new o.Ji(t,4-r,0)),d=-1;h.doc.nodesBetween(c,h.doc.content.size,(e,t)=>{if(d>-1)return!1;e.isTextblock&&0==e.content.size&&(d=t+1)}),d>-1&&h.setSelection(i.LN.near(h.doc.resolve(d))),s(h.scrollIntoView())}return!0}let d=a.pos==l.end()?h.contentMatchAt(0).defaultType:null,p=n.tr.delete(l.pos,a.pos),f=d?[t?{type:e,attrs:t}:null,{type:d}]:void 0;return!!(0,r.zy)(p.doc,l.pos,2,f)&&(s&&s(p.split(l.pos,2,f).scrollIntoView()),!0)}}function a(e){return function(t,n){let{$from:i,$to:s}=t.selection,l=i.blockRange(s,t=>t.childCount>0&&t.firstChild.type==e);return!!l&&(!n||(i.node(l.depth-1).type==e?function(e,t,n,i){let s=e.tr,l=i.end,a=i.$to.end(i.depth);l<a&&(s.step(new r.Wg(l-1,a,l,a,new o.Ji(o.FK.from(n.create(null,i.parent.copy())),1,0),1,!0)),i=new o.u$(s.doc.resolve(i.$from.pos),s.doc.resolve(a),i.depth));const c=(0,r.jP)(i);if(null==c)return!1;s.lift(i,c);let h=s.doc.resolve(s.mapping.map(l,-1)-1);(0,r.n9)(s.doc,h.pos)&&h.nodeBefore.type==h.nodeAfter.type&&s.join(h.pos);return t(s.scrollIntoView()),!0}(t,n,e,l):function(e,t,n){let i=e.tr,s=n.parent;for(let e=n.end,t=n.endIndex-1,r=n.startIndex;t>r;t--)e-=s.child(t).nodeSize,i.delete(e-1,e+1);let l=i.doc.resolve(n.start),a=l.nodeAfter;if(i.mapping.map(n.end)!=n.start+l.nodeAfter.nodeSize)return!1;let c=0==n.startIndex,h=n.endIndex==s.childCount,d=l.node(-1),p=l.index(-1);if(!d.canReplace(p+(c?0:1),p+1,a.content.append(h?o.FK.empty:o.FK.from(s))))return!1;let f=l.pos,u=f+a.nodeSize;return i.step(new r.Wg(f-(c?1:0),u+(h?1:0),f+1,u-1,new o.Ji((c?o.FK.empty:o.FK.from(s.copy(o.FK.empty))).append(h?o.FK.empty:o.FK.from(s.copy(o.FK.empty))),c?0:1,h?0:1),c?0:1)),t(i.scrollIntoView()),!0}(t,n,l)))}}function c(e){return function(t,n){let{$from:i,$to:s}=t.selection,l=i.blockRange(s,t=>t.childCount>0&&t.firstChild.type==e);if(!l)return!1;let a=l.startIndex;if(0==a)return!1;let c=l.parent,h=c.child(a-1);if(h.type!=e)return!1;if(n){let i=h.lastChild&&h.lastChild.type==c.type,s=o.FK.from(i?e.create():null),a=new o.Ji(o.FK.from(e.create(null,o.FK.from(c.type.create(null,s)))),i?3:1,0),d=l.start,p=l.end;n(t.tr.step(new r.Wg(d-(i?3:1),p,d,p,a,1,!0)).scrollIntoView())}return!0}}},42845(e,t,n){n.d(t,{$t:()=>k,LN:()=>s,U3:()=>h,hs:()=>D,i5:()=>u,k_:()=>M,nh:()=>p,yn:()=>l});var r=n(58903),o=n(38262);const i=Object.create(null);class s{constructor(e,t,n){this.$anchor=e,this.$head=t,this.ranges=n||[new l(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=r.Ji.empty){let n=t.content.lastChild,o=null;for(let e=0;e<t.openEnd;e++)o=n,n=n.lastChild;let i=e.steps.length,s=this.ranges;for(let l=0;l<s.length;l++){let{$from:a,$to:c}=s[l],h=e.mapping.slice(i);e.replaceRange(h.map(a.pos),h.map(c.pos),l?r.Ji.empty:t),0==l&&w(e,i,(n?n.isInline:o&&o.isTextblock)?-1:1)}}replaceWith(e,t){let n=e.steps.length,r=this.ranges;for(let o=0;o<r.length;o++){let{$from:i,$to:s}=r[o],l=e.mapping.slice(n),a=l.map(i.pos),c=l.map(s.pos);o?e.deleteRange(a,c):(e.replaceRangeWith(a,c,t),w(e,n,t.isInline?-1:1))}}static findFrom(e,t,n=!1){let r=e.parent.inlineContent?new h(e):g(e.node(0),e.parent,e.pos,e.index(),t,n);if(r)return r;for(let r=e.depth-1;r>=0;r--){let o=t<0?g(e.node(0),e.node(r),e.before(r+1),e.index(r),t,n):g(e.node(0),e.node(r),e.after(r+1),e.index(r)+1,t,n);if(o)return o}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new u(e.node(0))}static atStart(e){return g(e,e,0,0,1)||new u(e)}static atEnd(e){return g(e,e,e.content.size,e.childCount,-1)||new u(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let n=i[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 i)throw new RangeError("Duplicate use of selection JSON ID "+e);return i[e]=t,t.prototype.jsonID=e,t}getBookmark(){return h.between(this.$anchor,this.$head).getBookmark()}}s.prototype.visible=!0;class l{constructor(e,t){this.$from=e,this.$to=t}}let a=!1;function c(e){a||e.parent.inlineContent||(a=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+e.parent.type.name+")"))}class h extends s{constructor(e,t=e){c(e),c(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 s.near(n);let r=e.resolve(t.map(this.anchor));return new h(r.parent.inlineContent?r:n,n)}replace(e,t=r.Ji.empty){if(super.replace(e,t),t==r.Ji.empty){let t=this.$from.marksAcross(this.$to);t&&e.ensureMarks(t)}}eq(e){return e instanceof h&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new d(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if("number"!=typeof t.anchor||"number"!=typeof t.head)throw new RangeError("Invalid input for TextSelection.fromJSON");return new h(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,n=t){let r=e.resolve(t);return new this(r,n==t?r:e.resolve(n))}static between(e,t,n){let r=e.pos-t.pos;if(n&&!r||(n=r>=0?1:-1),!t.parent.inlineContent){let e=s.findFrom(t,n,!0)||s.findFrom(t,-n,!0);if(!e)return s.near(t,n);t=e.$head}return e.parent.inlineContent||(0==r||(e=(s.findFrom(e,-n,!0)||s.findFrom(e,n,!0)).$anchor).pos<t.pos!=r<0)&&(e=t),new h(e,t)}}s.jsonID("text",h);class d{constructor(e,t){this.anchor=e,this.head=t}map(e){return new d(e.map(this.anchor),e.map(this.head))}resolve(e){return h.between(e.resolve(this.anchor),e.resolve(this.head))}}class p extends s{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:r}=t.mapResult(this.anchor),o=e.resolve(r);return n?s.near(o):new p(o)}content(){return new r.Ji(r.FK.from(this.node),0,0)}eq(e){return e instanceof p&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new f(this.anchor)}static fromJSON(e,t){if("number"!=typeof t.anchor)throw new RangeError("Invalid input for NodeSelection.fromJSON");return new p(e.resolve(t.anchor))}static create(e,t){return new p(e.resolve(t))}static isSelectable(e){return!e.isText&&!1!==e.type.spec.selectable}}p.prototype.visible=!1,s.jsonID("node",p);class f{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:n}=e.mapResult(this.anchor);return t?new d(n,n):new f(n)}resolve(e){let t=e.resolve(this.anchor),n=t.nodeAfter;return n&&p.isSelectable(n)?new p(t):s.near(t)}}class u extends s{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=r.Ji.empty){if(t==r.Ji.empty){e.delete(0,e.doc.content.size);let t=s.atStart(e.doc);t.eq(e.selection)||e.setSelection(t)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new u(e)}map(e){return new u(e)}eq(e){return e instanceof u}getBookmark(){return m}}s.jsonID("all",u);const m={map(){return this},resolve:e=>new u(e)};function g(e,t,n,r,o,i=!1){if(t.inlineContent)return h.create(e,n);for(let s=r-(o>0?0:1);o>0?s<t.childCount:s>=0;s+=o){let r=t.child(s);if(r.isAtom){if(!i&&p.isSelectable(r))return p.create(e,n-(o<0?r.nodeSize:0))}else{let t=g(e,r,n+o,o<0?r.childCount:0,o,i);if(t)return t}n+=r.nodeSize*o}return null}function w(e,t,n){let r=e.steps.length-1;if(r<t)return;let i,l=e.steps[r];(l instanceof o.Ln||l instanceof o.Wg)&&(e.mapping.maps[r].forEach((e,t,n,r)=>{null==i&&(i=r)}),e.setSelection(s.near(e.doc.resolve(i),n)))}class y extends o.dL{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=-3&this.updated|1,this.storedMarks=null,this}get selectionSet(){return(1&this.updated)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=2,this}ensureMarks(e){return r.CU.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(2&this.updated)>0}addStep(e,t){super.addStep(e,t),this.updated=-3&this.updated,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)||r.CU.none))),n.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,n){let r=this.doc.type.schema;if(null==t)return e?this.replaceSelectionWith(r.text(e),!0):this.deleteSelection();{if(null==n&&(n=t),!e)return this.deleteRange(t,n);let o=this.storedMarks;if(!o){let e=this.doc.resolve(t);o=n==t?e.marks():e.marksAcross(this.doc.resolve(n))}return this.replaceRangeWith(t,n,r.text(e,o)),this.selection.empty||this.selection.to!=t+e.length||this.setSelection(s.near(this.selection.$to)),this}}setMeta(e,t){return this.meta["string"==typeof e?e:e.key]=t,this}getMeta(e){return this.meta["string"==typeof e?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=4,this}get scrolledIntoView(){return(4&this.updated)>0}}function v(e,t){return t&&e?e.bind(t):e}class b{constructor(e,t,n){this.name=e,this.init=v(t.init,n),this.apply=v(t.apply,n)}}const S=[new b("doc",{init:e=>e.doc||e.schema.topNodeType.createAndFill(),apply:e=>e.doc}),new b("selection",{init:(e,t)=>e.selection||s.atStart(t.doc),apply:e=>e.selection}),new b("storedMarks",{init:e=>e.storedMarks||null,apply:(e,t,n,r)=>r.selection.$cursor?e.storedMarks:null}),new b("scrollToSelection",{init:()=>0,apply:(e,t)=>e.scrolledIntoView?t+1:t})];class x{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=S.slice(),t&&t.forEach(e=>{if(this.pluginsByKey[e.key])throw new RangeError("Adding different instances of a keyed plugin ("+e.key+")");this.plugins.push(e),this.pluginsByKey[e.key]=e,e.spec.state&&this.fields.push(new b(e.key,e.spec.state,e))})}}class k{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 t=this.config.plugins[n];if(t.spec.filterTransaction&&!t.spec.filterTransaction.call(t,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let t=[e],n=this.applyInner(e),r=null;for(;;){let o=!1;for(let i=0;i<this.config.plugins.length;i++){let s=this.config.plugins[i];if(s.spec.appendTransaction){let l=r?r[i].n:0,a=r?r[i].state:this,c=l<t.length&&s.spec.appendTransaction.call(s,l?t.slice(l):t,a,n);if(c&&n.filterTransaction(c,i)){if(c.setMeta("appendedTransaction",e),!r){r=[];for(let e=0;e<this.config.plugins.length;e++)r.push(e<i?{state:n,n:t.length}:{state:this,n:0})}t.push(c),n=n.applyInner(c),o=!0}r&&(r[i]={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 k(this.config),n=this.config.fields;for(let r=0;r<n.length;r++){let o=n[r];t[o.name]=o.apply(e,this[o.name],this,t)}return t}get tr(){return new y(this)}static create(e){let t=new x(e.doc?e.doc.type.schema:e.schema,e.plugins),n=new k(t);for(let r=0;r<t.fields.length;r++)n[t.fields[r].name]=t.fields[r].init(e,n);return n}reconfigure(e){let t=new x(this.schema,e.plugins),n=t.fields,r=new k(t);for(let t=0;t<n.length;t++){let o=n[t].name;r[o]=this.hasOwnProperty(o)?this[o]:n[t].init(e,r)}return r}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map(e=>e.toJSON())),e&&"object"==typeof e)for(let n in e){if("doc"==n||"selection"==n)throw new RangeError("The JSON fields `doc` and `selection` are reserved");let r=e[n],o=r.spec.state;o&&o.toJSON&&(t[n]=o.toJSON.call(r,this[r.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 o=new x(e.schema,e.plugins),i=new k(o);return o.fields.forEach(o=>{if("doc"==o.name)i.doc=r.bP.fromJSON(e.schema,t.doc);else if("selection"==o.name)i.selection=s.fromJSON(i.doc,t.selection);else if("storedMarks"==o.name)t.storedMarks&&(i.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(n)for(let r in n){let s=n[r],l=s.spec.state;if(s.key==o.name&&l&&l.fromJSON&&Object.prototype.hasOwnProperty.call(t,r))return void(i[o.name]=l.fromJSON.call(s,e,t[r],i))}i[o.name]=o.init(e,i)}}),i}}function C(e,t,n){for(let r in e){let o=e[r];o instanceof Function?o=o.bind(t):"handleDOMEvents"==r&&(o=C(o,t,{})),n[r]=o}return n}class M{constructor(e){this.spec=e,this.props={},e.props&&C(e.props,this,this.props),this.key=e.key?e.key.key:O("plugin")}getState(e){return e[this.key]}}const N=Object.create(null);function O(e){return e in N?e+"$"+ ++N[e]:(N[e]=0,e+"$")}class D{constructor(e="key"){this.key=O(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}},86059(e,t,n){n.d(t,{AL:()=>we,D8:()=>X,GU:()=>F,JD:()=>L,L0:()=>j,LF:()=>Ce,RC:()=>$,aH:()=>v,aR:()=>W,e:()=>g,gC:()=>J,gR:()=>B,kG:()=>Z,of:()=>m,w7:()=>q});var r=n(42845),o=n(58903),i=n(1575),s=n(61396),l=n(38262);let a,c;if("undefined"!=typeof WeakMap){let e=new WeakMap;a=t=>e.get(t),c=(t,n)=>(e.set(t,n),n)}else{const e=[],t=10;let n=0;a=t=>{for(let n=0;n<e.length;n+=2)if(e[n]==t)return e[n+1]},c=(r,o)=>(n==t&&(n=0),e[n++]=r,e[n++]=o)}var h=class{constructor(e,t,n,r){this.width=e,this.height=t,this.map=n,this.problems=r}findCell(e){for(let t=0;t<this.map.length;t++){const n=this.map[t];if(n!=e)continue;const r=t%this.width,o=t/this.width|0;let i=r+1,s=o+1;for(let e=1;i<this.width&&this.map[t+e]==n;e++)i++;for(let e=1;s<this.height&&this.map[t+this.width*e]==n;e++)s++;return{left:r,top:o,right:i,bottom:s}}throw new RangeError(`No cell with offset ${e} found`)}colCount(e){for(let t=0;t<this.map.length;t++)if(this.map[t]==e)return t%this.width;throw new RangeError(`No cell with offset ${e} found`)}nextCell(e,t,n){const{left:r,right:o,top:i,bottom:s}=this.findCell(e);return"horiz"==t?(n<0?0==r:o==this.width)?null:this.map[i*this.width+(n<0?r-1:o)]:(n<0?0==i:s==this.height)?null:this.map[r+this.width*(n<0?i-1:s)]}rectBetween(e,t){const{left:n,right:r,top:o,bottom:i}=this.findCell(e),{left:s,right:l,top:a,bottom:c}=this.findCell(t);return{left:Math.min(n,s),top:Math.min(o,a),right:Math.max(r,l),bottom:Math.max(i,c)}}cellsInRect(e){const t=[],n={};for(let r=e.top;r<e.bottom;r++)for(let o=e.left;o<e.right;o++){const i=r*this.width+o,s=this.map[i];n[s]||(n[s]=!0,o==e.left&&o&&this.map[i-1]==s||r==e.top&&r&&this.map[i-this.width]==s||t.push(s))}return t}positionAt(e,t,n){for(let r=0,o=0;;r++){const i=o+n.child(r).nodeSize;if(r==e){let n=t+e*this.width;const r=(e+1)*this.width;for(;n<r&&this.map[n]<o;)n++;return n==r?i-1:this.map[n]}o=i}}static get(e){return a(e)||c(e,function(e){if("table"!=e.type.spec.tableRole)throw new RangeError("Not a table node: "+e.type.name);const t=function(e){let t=-1,n=!1;for(let r=0;r<e.childCount;r++){const o=e.child(r);let i=0;if(n)for(let t=0;t<r;t++){const n=e.child(t);for(let e=0;e<n.childCount;e++){const o=n.child(e);t+o.attrs.rowspan>r&&(i+=o.attrs.colspan)}}for(let e=0;e<o.childCount;e++){const t=o.child(e);i+=t.attrs.colspan,t.attrs.rowspan>1&&(n=!0)}-1==t?t=i:t!=i&&(t=Math.max(t,i))}return t}(e),n=e.childCount,r=[];let o=0,i=null;const s=[];for(let e=0,o=t*n;e<o;e++)r[e]=0;for(let l=0,a=0;l<n;l++){const c=e.child(l);a++;for(let e=0;;e++){for(;o<r.length&&0!=r[o];)o++;if(e==c.childCount)break;const h=c.child(e),{colspan:d,rowspan:p,colwidth:f}=h.attrs;for(let e=0;e<p;e++){if(e+l>=n){(i||(i=[])).push({type:"overlong_rowspan",pos:a,n:p-e});break}const c=o+e*t;for(let e=0;e<d;e++){0==r[c+e]?r[c+e]=a:(i||(i=[])).push({type:"collision",row:l,pos:a,n:d-e});const n=f&&f[e];if(n){const r=(c+e)%t*2,o=s[r];null==o||o!=n&&1==s[r+1]?(s[r]=n,s[r+1]=1):o==n&&s[r+1]++}}}o+=d,a+=h.nodeSize}const h=(l+1)*t;let d=0;for(;o<h;)0==r[o++]&&d++;d&&(i||(i=[])).push({type:"missing",row:l,n:d}),a++}0!==t&&0!==n||(i||(i=[])).push({type:"zero_sized"});const l=new h(t,n,r,i);let a=!1;for(let e=0;!a&&e<s.length;e+=2)null!=s[e]&&s[e+1]<n&&(a=!0);a&&function(e,t,n){e.problems||(e.problems=[]);const r={};for(let o=0;o<e.map.length;o++){const i=e.map[o];if(r[i])continue;r[i]=!0;const s=n.nodeAt(i);if(!s)throw new RangeError(`No cell with offset ${i} found`);let l=null;const a=s.attrs;for(let n=0;n<a.colspan;n++){const r=t[(o+n)%e.width*2];null==r||a.colwidth&&a.colwidth[n]==r||((l||(l=d(a)))[n]=r)}l&&e.problems.unshift({type:"colwidth mismatch",pos:i,colwidth:l})}}(l,s,e);return l}(e))}};function d(e){if(e.colwidth)return e.colwidth.slice();const t=[];for(let n=0;n<e.colspan;n++)t.push(0);return t}function p(e,t){if("string"==typeof e)return{};const n=e.getAttribute("data-colwidth"),r=n&&/^\d+(,\d+)*$/.test(n)?n.split(",").map(e=>Number(e)):null,o=Number(e.getAttribute("colspan")||1),i={colspan:o,rowspan:Number(e.getAttribute("rowspan")||1),colwidth:r&&r.length==o?r:null};for(const n in t){const r=t[n].getFromDOM,o=r&&r(e);null!=o&&(i[n]=o)}return i}function f(e,t){const n={};1!=e.attrs.colspan&&(n.colspan=e.attrs.colspan),1!=e.attrs.rowspan&&(n.rowspan=e.attrs.rowspan),e.attrs.colwidth&&(n["data-colwidth"]=e.attrs.colwidth.join(","));for(const r in t){const o=t[r].setDOMAttr;o&&o(e.attrs[r],n)}return n}function u(e){if(null!==e){if(!Array.isArray(e))throw new TypeError("colwidth must be null or an array");for(const t of e)if("number"!=typeof t)throw new TypeError("colwidth must be null or an array of numbers")}}function m(e){const t=e.cellAttributes||{},n={colspan:{default:1,validate:"number"},rowspan:{default:1,validate:"number"},colwidth:{default:null,validate:u}};for(const e in t)n[e]={default:t[e].default,validate:t[e].validate};return{table:{content:"table_row+",tableRole:"table",isolating:!0,group:e.tableGroup,parseDOM:[{tag:"table"}],toDOM:()=>["table",["tbody",0]]},table_row:{content:"(table_cell | table_header)*",tableRole:"row",parseDOM:[{tag:"tr"}],toDOM:()=>["tr",0]},table_cell:{content:e.cellContent,attrs:n,tableRole:"cell",isolating:!0,parseDOM:[{tag:"td",getAttrs:e=>p(e,t)}],toDOM:e=>["td",f(e,t),0]},table_header:{content:e.cellContent,attrs:n,tableRole:"header_cell",isolating:!0,parseDOM:[{tag:"th",getAttrs:e=>p(e,t)}],toDOM:e=>["th",f(e,t),0]}}}function g(e){let t=e.cached.tableNodeTypes;if(!t){t=e.cached.tableNodeTypes={};for(const n in e.nodes){const r=e.nodes[n],o=r.spec.tableRole;o&&(t[o]=r)}}return t}const w=new r.hs("selectingCells");function y(e){for(let t=e.depth-1;t>0;t--)if("row"==e.node(t).type.spec.tableRole)return e.node(0).resolve(e.before(t+1));return null}function v(e){const t=e.selection.$head;for(let e=t.depth;e>0;e--)if("row"==t.node(e).type.spec.tableRole)return!0;return!1}function b(e){const t=e.selection;if("$anchorCell"in t&&t.$anchorCell)return t.$anchorCell.pos>t.$headCell.pos?t.$anchorCell:t.$headCell;if("node"in t&&t.node&&"cell"==t.node.type.spec.tableRole)return t.$anchor;const n=y(t.$head)||S(t.$head);if(n)return n;throw new RangeError(`No cell found around position ${t.head}`)}function S(e){for(let t=e.nodeAfter,n=e.pos;t;t=t.firstChild,n++){const r=t.type.spec.tableRole;if("cell"==r||"header_cell"==r)return e.doc.resolve(n)}for(let t=e.nodeBefore,n=e.pos;t;t=t.lastChild,n--){const r=t.type.spec.tableRole;if("cell"==r||"header_cell"==r)return e.doc.resolve(n-t.nodeSize)}}function x(e){return"row"==e.parent.type.spec.tableRole&&!!e.nodeAfter}function k(e,t){return e.depth==t.depth&&e.pos>=t.start(-1)&&e.pos<=t.end(-1)}function C(e,t,n){const r=e.node(-1),o=h.get(r),i=e.start(-1),s=o.nextCell(e.pos-i,t,n);return null==s?null:e.node(0).resolve(i+s)}function M(e,t,n=1){const r={...e,colspan:e.colspan-n};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(t,n),r.colwidth.some(e=>e>0)||(r.colwidth=null)),r}function N(e,t,n=1){const r={...e,colspan:e.colspan+n};if(r.colwidth){r.colwidth=r.colwidth.slice();for(let e=0;e<n;e++)r.colwidth.splice(t,0,0)}return r}var O=class e extends r.LN{constructor(e,t=e){const n=e.node(-1),o=h.get(n),i=e.start(-1),s=o.rectBetween(e.pos-i,t.pos-i),l=e.node(0),a=o.cellsInRect(s).filter(e=>e!=t.pos-i);a.unshift(t.pos-i);const c=a.map(e=>{const t=n.nodeAt(e);if(!t)throw new RangeError(`No cell with offset ${e} found`);const o=i+e+1;return new r.yn(l.resolve(o),l.resolve(o+t.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=e,this.$headCell=t}map(t,n){const o=t.resolve(n.map(this.$anchorCell.pos)),i=t.resolve(n.map(this.$headCell.pos));if(x(o)&&x(i)&&k(o,i)){const t=this.$anchorCell.node(-1)!=o.node(-1);return t&&this.isRowSelection()?e.rowSelection(o,i):t&&this.isColSelection()?e.colSelection(o,i):new e(o,i)}return r.U3.between(o,i)}content(){const e=this.$anchorCell.node(-1),t=h.get(e),n=this.$anchorCell.start(-1),r=t.rectBetween(this.$anchorCell.pos-n,this.$headCell.pos-n),i={},s=[];for(let n=r.top;n<r.bottom;n++){const l=[];for(let o=n*t.width+r.left,s=r.left;s<r.right;s++,o++){const n=t.map[o];if(i[n])continue;i[n]=!0;const s=t.findCell(n);let a=e.nodeAt(n);if(!a)throw new RangeError(`No cell with offset ${n} found`);const c=r.left-s.left,h=s.right-r.right;if(c>0||h>0){let e=a.attrs;if(c>0&&(e=M(e,0,c)),h>0&&(e=M(e,e.colspan-h,h)),s.left<r.left){if(a=a.type.createAndFill(e),!a)throw new RangeError(`Could not create cell with attrs ${JSON.stringify(e)}`)}else a=a.type.create(e,a.content)}if(s.top<r.top||s.bottom>r.bottom){const e={...a.attrs,rowspan:Math.min(s.bottom,r.bottom)-Math.max(s.top,r.top)};a=s.top<r.top?a.type.createAndFill(e):a.type.create(e,a.content)}l.push(a)}s.push(e.child(n).copy(o.FK.from(l)))}const l=this.isColSelection()&&this.isRowSelection()?e:s;return new o.Ji(o.FK.from(l),1,1)}replace(e,t=o.Ji.empty){const n=e.steps.length,i=this.ranges;for(let r=0;r<i.length;r++){const{$from:s,$to:l}=i[r],a=e.mapping.slice(n);e.replace(a.map(s.pos),a.map(l.pos),r?o.Ji.empty:t)}const s=r.LN.findFrom(e.doc.resolve(e.mapping.slice(n).map(this.to)),-1);s&&e.setSelection(s)}replaceWith(e,t){this.replace(e,new o.Ji(o.FK.from(t),0,0))}forEachCell(e){const t=this.$anchorCell.node(-1),n=h.get(t),r=this.$anchorCell.start(-1),o=n.cellsInRect(n.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r));for(let n=0;n<o.length;n++)e(t.nodeAt(o[n]),r+o[n])}isColSelection(){const e=this.$anchorCell.index(-1),t=this.$headCell.index(-1);if(Math.min(e,t)>0)return!1;const n=e+this.$anchorCell.nodeAfter.attrs.rowspan,r=t+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(n,r)==this.$headCell.node(-1).childCount}static colSelection(t,n=t){const r=t.node(-1),o=h.get(r),i=t.start(-1),s=o.findCell(t.pos-i),l=o.findCell(n.pos-i),a=t.node(0);return s.top<=l.top?(s.top>0&&(t=a.resolve(i+o.map[s.left])),l.bottom<o.height&&(n=a.resolve(i+o.map[o.width*(o.height-1)+l.right-1]))):(l.top>0&&(n=a.resolve(i+o.map[l.left])),s.bottom<o.height&&(t=a.resolve(i+o.map[o.width*(o.height-1)+s.right-1]))),new e(t,n)}isRowSelection(){const e=this.$anchorCell.node(-1),t=h.get(e),n=this.$anchorCell.start(-1),r=t.colCount(this.$anchorCell.pos-n),o=t.colCount(this.$headCell.pos-n);if(Math.min(r,o)>0)return!1;const i=r+this.$anchorCell.nodeAfter.attrs.colspan,s=o+this.$headCell.nodeAfter.attrs.colspan;return Math.max(i,s)==t.width}eq(t){return t instanceof e&&t.$anchorCell.pos==this.$anchorCell.pos&&t.$headCell.pos==this.$headCell.pos}static rowSelection(t,n=t){const r=t.node(-1),o=h.get(r),i=t.start(-1),s=o.findCell(t.pos-i),l=o.findCell(n.pos-i),a=t.node(0);return s.left<=l.left?(s.left>0&&(t=a.resolve(i+o.map[s.top*o.width])),l.right<o.width&&(n=a.resolve(i+o.map[o.width*(l.top+1)-1]))):(l.left>0&&(n=a.resolve(i+o.map[l.top*o.width])),s.right<o.width&&(t=a.resolve(i+o.map[o.width*(s.top+1)-1]))),new e(t,n)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(t,n){return new e(t.resolve(n.anchor),t.resolve(n.head))}static create(t,n,r=n){return new e(t.resolve(n),t.resolve(r))}getBookmark(){return new D(this.$anchorCell.pos,this.$headCell.pos)}};O.prototype.visible=!1,r.LN.jsonID("cell",O);var D=class e{constructor(e,t){this.anchor=e,this.head=t}map(t){return new e(t.map(this.anchor),t.map(this.head))}resolve(e){const t=e.resolve(this.anchor),n=e.resolve(this.head);return"row"==t.parent.type.spec.tableRole&&"row"==n.parent.type.spec.tableRole&&t.index()<t.parent.childCount&&n.index()<n.parent.childCount&&k(t,n)?new O(t,n):r.LN.near(n,1)}};function A(e){if(!(e.selection instanceof O))return null;const t=[];return e.selection.forEachCell((e,n)=>{t.push(i.NZ.node(n,n+e.nodeSize,{class:"selectedCell"}))}),i.zF.create(e.doc,t)}const T=new r.hs("fix-tables");function E(e,t,n,r){const o=e.childCount,i=t.childCount;e:for(let s=0,l=0;s<i;s++){const i=t.child(s);for(let t=l,r=Math.min(o,s+3);t<r;t++)if(e.child(t)==i){l=t+1,n+=i.nodeSize;continue e}r(i,n),l<o&&e.child(l).sameMarkup(i)?E(e.child(l),i,n+1,r):i.nodesBetween(0,i.content.size,r,n+1),n+=i.nodeSize}}function R(e,t){let n;const r=(t,r)=>{"table"==t.type.spec.tableRole&&(n=function(e,t,n,r){const o=h.get(t);if(!o.problems)return r;r||(r=e.tr);const i=[];for(let e=0;e<o.height;e++)i.push(0);for(let e=0;e<o.problems.length;e++){const s=o.problems[e];if("collision"==s.type){const e=t.nodeAt(s.pos);if(!e)continue;const o=e.attrs;for(let e=0;e<o.rowspan;e++)i[s.row+e]+=s.n;r.setNodeMarkup(r.mapping.map(n+1+s.pos),null,M(o,o.colspan-s.n,s.n))}else if("missing"==s.type)i[s.row]+=s.n;else if("overlong_rowspan"==s.type){const e=t.nodeAt(s.pos);if(!e)continue;r.setNodeMarkup(r.mapping.map(n+1+s.pos),null,{...e.attrs,rowspan:e.attrs.rowspan-s.n})}else if("colwidth mismatch"==s.type){const e=t.nodeAt(s.pos);if(!e)continue;r.setNodeMarkup(r.mapping.map(n+1+s.pos),null,{...e.attrs,colwidth:s.colwidth})}else if("zero_sized"==s.type){const e=r.mapping.map(n);r.delete(e,e+t.nodeSize)}}let s,l;for(let e=0;e<i.length;e++)i[e]&&(null==s&&(s=e),l=e);for(let a=0,c=n+1;a<o.height;a++){const n=t.child(a),o=c+n.nodeSize,h=i[a];if(h>0){let t="cell";n.firstChild&&(t=n.firstChild.type.spec.tableRole);const i=[];for(let n=0;n<h;n++){const n=g(e.schema)[t].createAndFill();n&&i.push(n)}const d=0!=a&&s!=a-1||l!=a?o-1:c+1;r.insert(r.mapping.map(d),i)}c=o}return r.setMeta(T,{fixTables:!0})}(e,t,r,n))};return t?t.doc!=e.doc&&E(t.doc,e.doc,0,r):e.doc.descendants(r),n}function I(e){const t=e.selection,n=b(e),r=n.node(-1),o=n.start(-1),i=h.get(r);return{...t instanceof O?i.rectBetween(t.$anchorCell.pos-o,t.$headCell.pos-o):i.findCell(n.pos-o),tableStart:o,map:i,table:r}}function z(e,{map:t,tableStart:n,table:r},o){let i=o>0?-1:0;(function(e,t,n){const r=g(t.type.schema).header_cell;for(let o=0;o<e.height;o++)if(t.nodeAt(e.map[n+o*e.width]).type!=r)return!1;return!0})(t,r,o+i)&&(i=0==o||o==t.width?null:0);for(let s=0;s<t.height;s++){const l=s*t.width+o;if(o>0&&o<t.width&&t.map[l-1]==t.map[l]){const i=t.map[l],a=r.nodeAt(i);e.setNodeMarkup(e.mapping.map(n+i),null,N(a.attrs,o-t.colCount(i))),s+=a.attrs.rowspan-1}else{const a=null==i?g(r.type.schema).cell:r.nodeAt(t.map[l+i]).type,c=t.positionAt(s,o,r);e.insert(e.mapping.map(n+c),a.createAndFill())}}return e}function $(e,t){if(!v(e))return!1;if(t){const n=I(e);t(z(e.tr,n,n.left))}return!0}function F(e,t){if(!v(e))return!1;if(t){const n=I(e);t(z(e.tr,n,n.right))}return!0}function P(e,{map:t,table:n,tableStart:r},o){const i=e.mapping.maps.length;for(let s=0;s<t.height;){const l=s*t.width+o,a=t.map[l],c=n.nodeAt(a),h=c.attrs;if(o>0&&t.map[l-1]==a||o<t.width-1&&t.map[l+1]==a)e.setNodeMarkup(e.mapping.slice(i).map(r+a),null,M(h,o-t.colCount(a)));else{const t=e.mapping.slice(i).map(r+a);e.delete(t,t+c.nodeSize)}s+=h.rowspan}}function B(e,t){if(!v(e))return!1;if(t){const n=I(e),r=e.tr;if(0==n.left&&n.right==n.map.width)return!1;for(let e=n.right-1;P(r,n,e),e!=n.left;e--){const e=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!e)throw new RangeError("No table found");n.table=e,n.map=h.get(e)}t(r)}return!0}function V(e,{map:t,tableStart:n,table:r},o){let i=n;for(let e=0;e<o;e++)i+=r.child(e).nodeSize;const s=[];let l=o>0?-1:0;(function(e,t,n){var r;const o=g(t.type.schema).header_cell;for(let i=0;i<e.width;i++)if((null===(r=t.nodeAt(e.map[i+n*e.width]))||void 0===r?void 0:r.type)!=o)return!1;return!0})(t,r,o+l)&&(l=0==o||o==t.height?null:0);for(let i=0,c=t.width*o;i<t.width;i++,c++)if(o>0&&o<t.height&&t.map[c]==t.map[c-t.width]){const o=t.map[c],s=r.nodeAt(o).attrs;e.setNodeMarkup(n+o,null,{...s,rowspan:s.rowspan+1}),i+=s.colspan-1}else{var a;const e=null==l?g(r.type.schema).cell:null===(a=r.nodeAt(t.map[c+l*t.width]))||void 0===a?void 0:a.type,n=null==e?void 0:e.createAndFill();n&&s.push(n)}return e.insert(i,g(r.type.schema).row.create(null,s)),e}function L(e,t){if(!v(e))return!1;if(t){const n=I(e);t(V(e.tr,n,n.top))}return!0}function J(e,t){if(!v(e))return!1;if(t){const n=I(e);t(V(e.tr,n,n.bottom))}return!0}function K(e,{map:t,table:n,tableStart:r},o){let i=0;for(let e=0;e<o;e++)i+=n.child(e).nodeSize;const s=i+n.child(o).nodeSize,l=e.mapping.maps.length;e.delete(i+r,s+r);const a=new Set;for(let i=0,s=o*t.width;i<t.width;i++,s++){const c=t.map[s];if(!a.has(c))if(a.add(c),o>0&&c==t.map[s-t.width]){const t=n.nodeAt(c).attrs;e.setNodeMarkup(e.mapping.slice(l).map(c+r),null,{...t,rowspan:t.rowspan-1}),i+=t.colspan-1}else if(o<t.height&&c==t.map[s+t.width]){const s=n.nodeAt(c),a=s.attrs,h=s.type.create({...a,rowspan:s.attrs.rowspan-1},s.content),d=t.positionAt(o+1,i,n);e.insert(e.mapping.slice(l).map(r+d),h),i+=a.colspan-1}}}function W(e,t){if(!v(e))return!1;if(t){const n=I(e),r=e.tr;if(0==n.top&&n.bottom==n.map.height)return!1;for(let e=n.bottom-1;K(r,n,e),e!=n.top;e--){const e=n.tableStart?r.doc.nodeAt(n.tableStart-1):r.doc;if(!e)throw new RangeError("No table found");n.table=e,n.map=h.get(n.table)}t(r)}return!0}function _(e){const t=e.content;return 1==t.childCount&&t.child(0).isTextblock&&0==t.child(0).childCount}function q(e,t){const n=e.selection;if(!(n instanceof O)||n.$anchorCell.pos==n.$headCell.pos)return!1;const r=I(e),{map:i}=r;if(function({width:e,height:t,map:n},r){let o=r.top*e+r.left,i=o,s=(r.bottom-1)*e+r.left,l=o+(r.right-r.left-1);for(let t=r.top;t<r.bottom;t++){if(r.left>0&&n[i]==n[i-1]||r.right<e&&n[l]==n[l+1])return!0;i+=e,l+=e}for(let i=r.left;i<r.right;i++){if(r.top>0&&n[o]==n[o-e]||r.bottom<t&&n[s]==n[s+e])return!0;o++,s++}return!1}(i,r))return!1;if(t){const n=e.tr,s={};let l,a,c=o.FK.empty;for(let e=r.top;e<r.bottom;e++)for(let t=r.left;t<r.right;t++){const o=i.map[e*i.width+t],h=r.table.nodeAt(o);if(!s[o]&&h)if(s[o]=!0,null==l)l=o,a=h;else{_(h)||(c=c.append(h.content));const e=n.mapping.map(o+r.tableStart);n.delete(e,e+h.nodeSize)}}if(null==l||null==a)return!0;if(n.setNodeMarkup(l+r.tableStart,null,{...N(a.attrs,a.attrs.colspan,r.right-r.left-a.attrs.colspan),rowspan:r.bottom-r.top}),c.size>0){const e=l+1+a.content.size,t=_(a)?l+1:e;n.replaceWith(t+r.tableStart,e+r.tableStart,c)}n.setSelection(new O(n.doc.resolve(l+r.tableStart))),t(n)}return!0}function j(e,t){const n=g(e.schema);return(r=({node:e})=>n[e.type.spec.tableRole],(e,t)=>{const n=e.selection;let o,i;if(n instanceof O){if(n.$anchorCell.pos!=n.$headCell.pos)return!1;o=n.$anchorCell.nodeAfter,i=n.$anchorCell.pos}else{var s;if(o=function(e){for(let t=e.depth;t>0;t--){const n=e.node(t).type.spec.tableRole;if("cell"===n||"header_cell"===n)return e.node(t)}return null}(n.$from),!o)return!1;i=null===(s=y(n.$from))||void 0===s?void 0:s.pos}if(null==o||null==i)return!1;if(1==o.attrs.colspan&&1==o.attrs.rowspan)return!1;if(t){let s=o.attrs;const l=[],a=s.colwidth;s.rowspan>1&&(s={...s,rowspan:1}),s.colspan>1&&(s={...s,colspan:1});const c=I(e),h=e.tr;for(let e=0;e<c.right-c.left;e++)l.push(a?{...s,colwidth:a&&a[e]?[a[e]]:null}:s);let d;for(let e=c.top;e<c.bottom;e++){let t=c.map.positionAt(e,c.left,c.table);e==c.top&&(t+=o.nodeSize);for(let n=c.left,i=0;n<c.right;n++,i++)n==c.left&&e==c.top||h.insert(d=h.mapping.map(t+c.tableStart,1),r({node:o,row:e,col:n}).createAndFill(l[i]))}h.setNodeMarkup(i,r({node:o,row:c.top,col:c.left}),l[0]),n instanceof O&&h.setSelection(new O(h.doc.resolve(n.$anchorCell.pos),d?h.doc.resolve(d):void 0)),t(h)}return!0})(e,t);var r}function U(e,t,n){const r=t.map.cellsInRect({left:0,top:0,right:"row"==e?t.map.width:1,bottom:"column"==e?t.map.height:1});for(let e=0;e<r.length;e++){const o=t.table.nodeAt(r[e]);if(o&&o.type!==n.header_cell)return!1}return!0}function H(e,t){return(t=t||{useDeprecatedLogic:!1}).useDeprecatedLogic?function(e){return function(t,n){if(!v(t))return!1;if(n){const r=g(t.schema),o=I(t),i=t.tr,s=o.map.cellsInRect("column"==e?{left:o.left,top:0,right:o.right,bottom:o.map.height}:"row"==e?{left:0,top:o.top,right:o.map.width,bottom:o.bottom}:o),l=s.map(e=>o.table.nodeAt(e));for(let e=0;e<s.length;e++)l[e].type==r.header_cell&&i.setNodeMarkup(o.tableStart+s[e],r.cell,l[e].attrs);if(0===i.steps.length)for(let e=0;e<s.length;e++)i.setNodeMarkup(o.tableStart+s[e],r.header_cell,l[e].attrs);n(i)}return!0}}(e):function(t,n){if(!v(t))return!1;if(n){const r=g(t.schema),o=I(t),i=t.tr,s=U("row",o,r),l=U("column",o,r),a=("column"===e?s:"row"===e&&l)?1:0,c="column"==e?{left:0,top:a,right:1,bottom:o.map.height}:"row"==e?{left:a,top:0,right:o.map.width,bottom:1}:o,h="column"==e?l?r.cell:r.header_cell:"row"==e?s?r.cell:r.header_cell:r.cell;o.map.cellsInRect(c).forEach(e=>{const t=e+o.tableStart,n=i.doc.nodeAt(t);n&&i.setNodeMarkup(t,h,n.attrs)}),n(i)}return!0}}const G=H("row",{useDeprecatedLogic:!0});H("column",{useDeprecatedLogic:!0}),H("cell",{useDeprecatedLogic:!0});function X(e){return function(t,n){if(!v(t))return!1;const o=function(e,t){if(t<0){const t=e.nodeBefore;if(t)return e.pos-t.nodeSize;for(let t=e.index(-1)-1,n=e.before();t>=0;t--){const r=e.node(-1).child(t),o=r.lastChild;if(o)return n-1-o.nodeSize;n-=r.nodeSize}}else{if(e.index()<e.parent.childCount-1)return e.pos+e.nodeAfter.nodeSize;const t=e.node(-1);for(let n=e.indexAfter(-1),r=e.after();n<t.childCount;n++){const e=t.child(n);if(e.childCount)return r+1;r+=e.nodeSize}}return null}(b(t),e);if(null==o)return!1;if(n){const e=t.doc.resolve(o);n(t.tr.setSelection(r.U3.between(e,(i=e,i.node(0).resolve(i.pos+i.nodeAfter.nodeSize)))).scrollIntoView())}var i;return!0}}function Z(e,t){const n=e.selection.$anchor;for(let r=n.depth;r>0;r--)if("table"==n.node(r).type.spec.tableRole)return t&&t(e.tr.delete(n.before(r),n.after(r)).scrollIntoView()),!0;return!1}function Y(e,t){const n=e.selection;if(!(n instanceof O))return!1;if(t){const r=e.tr,i=g(e.schema).cell.createAndFill().content;n.forEachCell((e,t)=>{e.content.eq(i)||r.replace(r.mapping.map(t+1),r.mapping.map(t+e.nodeSize-1),new o.Ji(i,0,0))}),r.docChanged&&t(r)}return!0}function Q(e){if(0===e.size)return null;let{content:t,openStart:n,openEnd:r}=e;for(;1==t.childCount&&(n>0&&r>0||"table"==t.child(0).type.spec.tableRole);)n--,r--,t=t.child(0).content;const i=t.child(0),s=i.type.spec.tableRole,l=i.type.schema,a=[];if("row"==s)for(let e=0;e<t.childCount;e++){let i=t.child(e).content;const s=e?0:Math.max(0,n-1),c=e<t.childCount-1?0:Math.max(0,r-1);(s||c)&&(i=ee(g(l).row,new o.Ji(i,s,c)).content),a.push(i)}else{if("cell"!=s&&"header_cell"!=s)return null;a.push(n||r?ee(g(l).row,new o.Ji(t,n,r)).content:t)}return function(e,t){const n=[];for(let e=0;e<t.length;e++){const r=t[e];for(let t=r.childCount-1;t>=0;t--){const{rowspan:o,colspan:i}=r.child(t).attrs;for(let t=e;t<e+o;t++)n[t]=(n[t]||0)+i}}let r=0;for(let e=0;e<n.length;e++)r=Math.max(r,n[e]);for(let i=0;i<n.length;i++)if(i>=t.length&&t.push(o.FK.empty),n[i]<r){const s=g(e).cell.createAndFill(),l=[];for(let e=n[i];e<r;e++)l.push(s);t[i]=t[i].append(o.FK.from(l))}return{height:t.length,width:r,rows:t}}(l,a)}function ee(e,t){const n=e.createAndFill();return new l.dL(n).replace(0,n.content.size,t).doc}function te(e,t,n,r,o,i,s,l){if(0==s||s==t.height)return!1;let a=!1;for(let c=o;c<i;c++){const o=s*t.width+c,i=t.map[o];if(t.map[o-t.width]==i){a=!0;const o=n.nodeAt(i),{top:h,left:d}=t.findCell(i);e.setNodeMarkup(e.mapping.slice(l).map(i+r),null,{...o.attrs,rowspan:s-h}),e.insert(e.mapping.slice(l).map(t.positionAt(s,d,n)),o.type.createAndFill({...o.attrs,rowspan:h+o.attrs.rowspan-s})),c+=o.attrs.colspan-1}}return a}function ne(e,t,n,r,o,i,s,l){if(0==s||s==t.width)return!1;let a=!1;for(let c=o;c<i;c++){const o=c*t.width+s,i=t.map[o];if(t.map[o-1]==i){a=!0;const o=n.nodeAt(i),h=t.colCount(i),d=e.mapping.slice(l).map(i+r);e.setNodeMarkup(d,null,M(o.attrs,s-h,o.attrs.colspan-(s-h))),e.insert(d+o.nodeSize,o.type.createAndFill(M(o.attrs,0,s-h))),c+=o.attrs.rowspan-1}}return a}function re(e,t,n,r,i){let s=n?e.doc.nodeAt(n-1):e.doc;if(!s)throw new Error("No table found");let l=h.get(s);const{top:a,left:c}=r,d=c+i.width,p=a+i.height,f=e.tr;let u=0;function m(){if(s=n?f.doc.nodeAt(n-1):f.doc,!s)throw new Error("No table found");l=h.get(s),u=f.mapping.maps.length}(function(e,t,n,r,i,s,l){const a=g(e.doc.type.schema);let c,h;if(i>t.width)for(let o=0,s=0;o<t.height;o++){const d=n.child(o);s+=d.nodeSize;const p=[];let f;f=null==d.lastChild||d.lastChild.type==a.cell?c||(c=a.cell.createAndFill()):h||(h=a.header_cell.createAndFill());for(let e=t.width;e<i;e++)p.push(f);e.insert(e.mapping.slice(l).map(s-1+r),p)}if(s>t.height){const d=[];for(let e=0,r=(t.height-1)*t.width;e<Math.max(t.width,i);e++){const o=!(e>=t.width)&&n.nodeAt(t.map[r+e]).type==a.header_cell;d.push(o?h||(h=a.header_cell.createAndFill()):c||(c=a.cell.createAndFill()))}const p=a.row.create(null,o.FK.from(d)),f=[];for(let e=t.height;e<s;e++)f.push(p);e.insert(e.mapping.slice(l).map(r+n.nodeSize-2),f)}return!(!c&&!h)})(f,l,s,n,d,p,u)&&m(),te(f,l,s,n,c,d,a,u)&&m(),te(f,l,s,n,c,d,p,u)&&m(),ne(f,l,s,n,a,p,c,u)&&m(),ne(f,l,s,n,a,p,d,u)&&m();for(let e=a;e<p;e++){const t=l.positionAt(e,c,s),r=l.positionAt(e,d,s);f.replace(f.mapping.slice(u).map(t+n),f.mapping.slice(u).map(r+n),new o.Ji(i.rows[e-a],0,0))}m(),f.setSelection(new O(f.doc.resolve(n+l.positionAt(a,c,s)),f.doc.resolve(n+l.positionAt(p-1,d-1,s)))),t(f)}const oe=(0,s.K)({ArrowLeft:se("horiz",-1),ArrowRight:se("horiz",1),ArrowUp:se("vert",-1),ArrowDown:se("vert",1),"Shift-ArrowLeft":le("horiz",-1),"Shift-ArrowRight":le("horiz",1),"Shift-ArrowUp":le("vert",-1),"Shift-ArrowDown":le("vert",1),Backspace:Y,"Mod-Backspace":Y,Delete:Y,"Mod-Delete":Y});function ie(e,t,n){return!n.eq(e.selection)&&(t&&t(e.tr.setSelection(n).scrollIntoView()),!0)}function se(e,t){return(n,o,i)=>{if(!i)return!1;const s=n.selection;if(s instanceof O)return ie(n,o,r.LN.near(s.$headCell,t));if("horiz"!=e&&!s.empty)return!1;const l=de(i,e,t);if(null==l)return!1;if("horiz"==e)return ie(n,o,r.LN.near(n.doc.resolve(s.head+t),t));{const i=n.doc.resolve(l),s=C(i,e,t);let a;return a=s?r.LN.near(s,1):t<0?r.LN.near(n.doc.resolve(i.before(-1)),-1):r.LN.near(n.doc.resolve(i.after(-1)),1),ie(n,o,a)}}}function le(e,t){return(n,r,o)=>{if(!o)return!1;const i=n.selection;let s;if(i instanceof O)s=i;else{const r=de(o,e,t);if(null==r)return!1;s=new O(n.doc.resolve(r))}const l=C(s.$headCell,e,t);return!!l&&ie(n,r,new O(s.$anchorCell,l))}}function ae(e,t){const n=y(e.state.doc.resolve(t));return!!n&&(e.dispatch(e.state.tr.setSelection(new O(n))),!0)}function ce(e,t,n){if(!v(e.state))return!1;let r=Q(n);const i=e.state.selection;if(i instanceof O){r||(r={width:1,height:1,rows:[o.FK.from(ee(g(e.state.schema).cell,n))]});const t=i.$anchorCell.node(-1),s=i.$anchorCell.start(-1),l=h.get(t).rectBetween(i.$anchorCell.pos-s,i.$headCell.pos-s);return r=function({width:e,height:t,rows:n},r,i){if(e!=r){const t=[],i=[];for(let e=0;e<n.length;e++){const s=n[e],l=[];for(let n=t[e]||0,o=0;n<r;o++){let i=s.child(o%s.childCount);n+i.attrs.colspan>r&&(i=i.type.createChecked(M(i.attrs,i.attrs.colspan,n+i.attrs.colspan-r),i.content)),l.push(i),n+=i.attrs.colspan;for(let n=1;n<i.attrs.rowspan;n++)t[e+n]=(t[e+n]||0)+i.attrs.colspan}i.push(o.FK.from(l))}n=i,e=r}if(t!=i){const e=[];for(let r=0,s=0;r<i;r++,s++){const l=[],a=n[s%t];for(let e=0;e<a.childCount;e++){let t=a.child(e);r+t.attrs.rowspan>i&&(t=t.type.create({...t.attrs,rowspan:Math.max(1,i-t.attrs.rowspan)},t.content)),l.push(t)}e.push(o.FK.from(l))}n=e,t=i}return{width:e,height:t,rows:n}}(r,l.right-l.left,l.bottom-l.top),re(e.state,e.dispatch,s,l,r),!0}if(r){const t=b(e.state),n=t.start(-1);return re(e.state,e.dispatch,n,h.get(t.node(-1)).findCell(t.pos-n),r),!0}return!1}function he(e,t){var n;if(0!=t.button)return;if(t.ctrlKey||t.metaKey)return;const r=pe(e,t.target);let o;if(t.shiftKey&&e.state.selection instanceof O)i(e.state.selection.$anchorCell,t),t.preventDefault();else if(t.shiftKey&&r&&null!=(o=y(e.state.selection.$anchor))&&(null===(n=fe(e,t))||void 0===n?void 0:n.pos)!=o.pos)i(o,t),t.preventDefault();else if(!r)return;function i(t,n){let r=fe(e,n);const o=null==w.getState(e.state);if(!r||!k(t,r)){if(!o)return;r=t}const i=new O(t,r);if(o||!e.state.selection.eq(i)){const n=e.state.tr.setSelection(i);o&&n.setMeta(w,t.pos),e.dispatch(n)}}function s(){e.root.removeEventListener("mouseup",s),e.root.removeEventListener("dragstart",s),e.root.removeEventListener("mousemove",l),null!=w.getState(e.state)&&e.dispatch(e.state.tr.setMeta(w,-1))}function l(n){const o=n,l=w.getState(e.state);let a;if(null!=l)a=e.state.doc.resolve(l);else if(pe(e,o.target)!=r&&(a=fe(e,t),!a))return s();a&&i(a,o)}e.root.addEventListener("mouseup",s),e.root.addEventListener("dragstart",s),e.root.addEventListener("mousemove",l)}function de(e,t,n){if(!(e.state.selection instanceof r.U3))return null;const{$head:o}=e.state.selection;for(let r=o.depth-1;r>=0;r--){const i=o.node(r);if((n<0?o.index(r):o.indexAfter(r))!=(n<0?0:i.childCount))return null;if("cell"==i.type.spec.tableRole||"header_cell"==i.type.spec.tableRole){const i=o.before(r),s="vert"==t?n>0?"down":"up":n>0?"right":"left";return e.endOfTextblock(s)?i:null}}return null}function pe(e,t){for(;t&&t!=e.dom;t=t.parentNode)if("TD"==t.nodeName||"TH"==t.nodeName)return t;return null}function fe(e,t){const n=e.posAtCoords({left:t.clientX,top:t.clientY});if(!n)return null;let{inside:r,pos:o}=n;return r>=0&&y(e.state.doc.resolve(r))||y(e.state.doc.resolve(o))}var ue=class{constructor(e,t){this.node=e,this.defaultCellMinWidth=t,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.table.style.setProperty("--default-cell-min-width",`${t}px`),this.colgroup=this.table.appendChild(document.createElement("colgroup")),me(e,this.colgroup,this.table,t),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type==this.node.type&&(this.node=e,me(e,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(e){return"attributes"==e.type&&(e.target==this.table||this.colgroup.contains(e.target))}};function me(e,t,n,r,o,i){let s=0,l=!0,a=t.firstChild;const c=e.firstChild;if(c){for(let e=0,n=0;e<c.childCount;e++){const{colspan:h,colwidth:d}=c.child(e).attrs;for(let e=0;e<h;e++,n++){const c=o==n?i:d&&d[e],h=c?c+"px":"";if(s+=c||r,c||(l=!1),a)a.style.width!=h&&(a.style.width=h),a=a.nextSibling;else{const e=document.createElement("col");e.style.width=h,t.appendChild(e)}}}for(;a;){var h;const e=a.nextSibling;null===(h=a.parentNode)||void 0===h||h.removeChild(a),a=e}l?(n.style.width=s+"px",n.style.minWidth=""):(n.style.width="",n.style.minWidth=s+"px")}}const ge=new r.hs("tableColumnResizing");function we({handleWidth:e=5,cellMinWidth:t=25,defaultCellMinWidth:n=100,View:o=ue,lastColumnResizable:s=!0}={}){const l=new r.k_({key:ge,state:{init(e,t){var r;const i=null===(r=l.spec)||void 0===r||null===(r=r.props)||void 0===r?void 0:r.nodeViews,s=g(t.schema).table.name;return o&&i&&(i[s]=(e,t)=>new o(e,n,t)),new ye(-1,!1)},apply:(e,t)=>t.apply(e)},props:{attributes:e=>{const t=ge.getState(e);return t&&t.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(t,n)=>{!function(e,t,n,r){if(!e.editable)return;const o=ge.getState(e.state);if(!o)return;if(!o.dragging){const i=function(e){for(;e&&"TD"!=e.nodeName&&"TH"!=e.nodeName;)e=e.classList&&e.classList.contains("ProseMirror")?null:e.parentNode;return e}(t.target);let s=-1;if(i){const{left:r,right:o}=i.getBoundingClientRect();t.clientX-r<=n?s=ve(e,t,"left",n):o-t.clientX<=n&&(s=ve(e,t,"right",n))}if(s!=o.activeHandle){if(!r&&-1!==s){const t=e.state.doc.resolve(s),n=t.node(-1),r=h.get(n),o=t.start(-1);if(r.colCount(t.pos-o)+t.nodeAfter.attrs.colspan-1==r.width-1)return}Se(e,s)}}}(t,n,e,s)},mouseleave:e=>{!function(e){if(!e.editable)return;const t=ge.getState(e.state);t&&t.activeHandle>-1&&!t.dragging&&Se(e,-1)}(e)},mousedown:(e,r)=>{!function(e,t,n,r){var o;if(!e.editable)return!1;const i=null!==(o=e.dom.ownerDocument.defaultView)&&void 0!==o?o:window,s=ge.getState(e.state);if(!s||-1==s.activeHandle||s.dragging)return!1;const l=e.state.doc.nodeAt(s.activeHandle),a=function(e,t,{colspan:n,colwidth:r}){const o=r&&r[r.length-1];if(o)return o;const i=e.domAtPos(t);let s=i.node.childNodes[i.offset].offsetWidth,l=n;if(r)for(let e=0;e<n;e++)r[e]&&(s-=r[e],l--);return s/l}(e,s.activeHandle,l.attrs);function c(t){i.removeEventListener("mouseup",c),i.removeEventListener("mousemove",d);const r=ge.getState(e.state);(null==r?void 0:r.dragging)&&(!function(e,t,n){const r=e.state.doc.resolve(t),o=r.node(-1),i=h.get(o),s=r.start(-1),l=i.colCount(r.pos-s)+r.nodeAfter.attrs.colspan-1,a=e.state.tr;for(let e=0;e<i.height;e++){const t=e*i.width+l;if(e&&i.map[t]==i.map[t-i.width])continue;const r=i.map[t],c=o.nodeAt(r).attrs,h=1==c.colspan?0:l-i.colCount(r);if(c.colwidth&&c.colwidth[h]==n)continue;const d=c.colwidth?c.colwidth.slice():ke(c.colspan);d[h]=n,a.setNodeMarkup(s+r,null,{...c,colwidth:d})}a.docChanged&&e.dispatch(a)}(e,r.activeHandle,be(r.dragging,t,n)),e.dispatch(e.state.tr.setMeta(ge,{setDragging:null})))}function d(t){if(!t.which)return c(t);const o=ge.getState(e.state);if(o&&o.dragging){const i=be(o.dragging,t,n);xe(e,o.activeHandle,i,r)}}e.dispatch(e.state.tr.setMeta(ge,{setDragging:{startX:t.clientX,startWidth:a}})),xe(e,s.activeHandle,a,r),i.addEventListener("mouseup",c),i.addEventListener("mousemove",d),t.preventDefault()}(e,r,t,n)}},decorations:e=>{const t=ge.getState(e);if(t&&t.activeHandle>-1)return function(e,t){const n=[],r=e.doc.resolve(t),o=r.node(-1);if(!o)return i.zF.empty;const s=h.get(o),l=r.start(-1),a=s.colCount(r.pos-l)+r.nodeAfter.attrs.colspan-1;for(let t=0;t<s.height;t++){const r=a+t*s.width;if(!(a!=s.width-1&&s.map[r]==s.map[r+1]||0!=t&&s.map[r]==s.map[r-s.width])){var c;const t=s.map[r],a=l+t+o.nodeAt(t).nodeSize-1,h=document.createElement("div");h.className="column-resize-handle",(null===(c=ge.getState(e))||void 0===c?void 0:c.dragging)&&n.push(i.NZ.node(l+t,l+t+o.nodeAt(t).nodeSize,{class:"column-resize-dragging"})),n.push(i.NZ.widget(a,h))}}return i.zF.create(e.doc,n)}(e,t.activeHandle)},nodeViews:{}}});return l}var ye=class e{constructor(e,t){this.activeHandle=e,this.dragging=t}apply(t){const n=this,r=t.getMeta(ge);if(r&&null!=r.setHandle)return new e(r.setHandle,!1);if(r&&void 0!==r.setDragging)return new e(n.activeHandle,r.setDragging);if(n.activeHandle>-1&&t.docChanged){let r=t.mapping.map(n.activeHandle,-1);return x(t.doc.resolve(r))||(r=-1),new e(r,n.dragging)}return n}};function ve(e,t,n,r){const o="right"==n?-r:r,i=e.posAtCoords({left:t.clientX+o,top:t.clientY});if(!i)return-1;const{pos:s}=i,l=y(e.state.doc.resolve(s));if(!l)return-1;if("right"==n)return l.pos;const a=h.get(l.node(-1)),c=l.start(-1),d=a.map.indexOf(l.pos-c);return d%a.width==0?-1:c+a.map[d-1]}function be(e,t,n){const r=t.clientX-e.startX;return Math.max(n,e.startWidth+r)}function Se(e,t){e.dispatch(e.state.tr.setMeta(ge,{setHandle:t}))}function xe(e,t,n,r){const o=e.state.doc.resolve(t),i=o.node(-1),s=o.start(-1),l=h.get(i).colCount(o.pos-s)+o.nodeAfter.attrs.colspan-1;let a=e.domAtPos(o.start(-1)).node;for(;a&&"TABLE"!=a.nodeName;)a=a.parentNode;a&&me(i,a.firstChild,a,r,l,n)}function ke(e){return Array(e).fill(0)}function Ce({allowTableNodeSelection:e=!1}={}){return new r.k_({key:w,state:{init:()=>null,apply(e,t){const n=e.getMeta(w);if(null!=n)return-1==n?null:n;if(null==t||!e.docChanged)return t;const{deleted:r,pos:o}=e.mapping.mapResult(t);return r?null:o}},props:{decorations:A,handleDOMEvents:{mousedown:he},createSelectionBetween:e=>null!=w.getState(e.state)?e.state.selection:null,handleTripleClick:ae,handleKeyDown:oe,handlePaste:ce},appendTransaction:(t,n,o)=>function(e,t,n){const o=(t||e).selection,i=(t||e).doc;let s,l;if(o instanceof r.nh&&(l=o.node.type.spec.tableRole)){if("cell"==l||"header_cell"==l)s=O.create(i,o.from);else if("row"==l){const e=i.resolve(o.from+1);s=O.rowSelection(e,e)}else if(!n){const e=h.get(o.node),t=o.from+1,n=t+e.map[e.width*e.height-1];s=O.create(i,t+1,n)}}else o instanceof r.U3&&function({$from:e,$to:t}){if(e.pos==t.pos||e.pos<t.pos-6)return!1;let n=e.pos,r=t.pos,o=e.depth;for(;o>=0&&!(e.after(o+1)<e.end(o));o--,n++);for(let e=t.depth;e>=0&&!(t.before(e+1)>t.start(e));e--,r--);return n==r&&/row|table/.test(e.node(o).type.spec.tableRole)}(o)?s=r.U3.create(i,o.from):o instanceof r.U3&&function({$from:e,$to:t}){let n,r;for(let t=e.depth;t>0;t--){const r=e.node(t);if("cell"===r.type.spec.tableRole||"header_cell"===r.type.spec.tableRole){n=r;break}}for(let e=t.depth;e>0;e--){const n=t.node(e);if("cell"===n.type.spec.tableRole||"header_cell"===n.type.spec.tableRole){r=n;break}}return n!==r&&0===t.parentOffset}(o)&&(s=r.U3.create(i,o.$from.start(),o.$from.end()));return s&&(t||(t=e.tr)).setSelection(s),t}(o,R(o,n),e)})}n.d(t,["uC",0,G])},38262(e,t,n){n.d(t,{$L:()=>R,Ln:()=>y,Um:()=>E,Wg:()=>v,X9:()=>c,dL:()=>U,jP:()=>k,n9:()=>A,oM:()=>C,zy:()=>D});var r=n(58903);const o=Math.pow(2,16);function i(e,t){return e+t*o}function s(e){return 65535&e}class l{constructor(e,t,n){this.pos=e,this.delInfo=t,this.recover=n}get deleted(){return(8&this.delInfo)>0}get deletedBefore(){return(5&this.delInfo)>0}get deletedAfter(){return(6&this.delInfo)>0}get deletedAcross(){return(4&this.delInfo)>0}}class a{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&a.empty)return a.empty}recover(e){let t=0,n=s(e);if(!this.inverted)for(let e=0;e<n;e++)t+=this.ranges[3*e+2]-this.ranges[3*e+1];return this.ranges[3*n]+t+function(e){return(e-(65535&e))/o}(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 r=0,o=this.inverted?2:1,s=this.inverted?1:2;for(let a=0;a<this.ranges.length;a+=3){let c=this.ranges[a]-(this.inverted?r:0);if(c>e)break;let h=this.ranges[a+o],d=this.ranges[a+s],p=c+h;if(e<=p){let o=c+r+((h?e==c?-1:e==p?1:t:t)<0?0:d);if(n)return o;let s=e==(t<0?c:p)?null:i(a/3,e-c),f=0;return h&&(f|=e==c?2:e==p?1:4,(t<0?e!=c:e!=p)&&(f|=8)),new l(o,f,s)}r+=d-h}return n?e+r:new l(e+r,0,null)}touches(e,t){let n=0,r=s(t),o=this.inverted?2:1,i=this.inverted?1:2;for(let t=0;t<this.ranges.length;t+=3){let s=this.ranges[t]-(this.inverted?n:0);if(s>e)break;let l=this.ranges[t+o];if(e<=s+l&&t==3*r)return!0;n+=this.ranges[t+i]-l}return!1}forEach(e){let t=this.inverted?2:1,n=this.inverted?1:2;for(let r=0,o=0;r<this.ranges.length;r+=3){let i=this.ranges[r],s=i-(this.inverted?o:0),l=i+(this.inverted?0:o),a=this.ranges[r+t],c=this.ranges[r+n];e(s,s+a,l,l+c),o+=c-a}}invert(){return new a(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return 0==e?a.empty:new a(e<0?[0,-e,0]:[0,0,e])}}a.empty=new a([]);class c{constructor(e,t,n=0,r=(e?e.length:0)){this.mirror=t,this.from=n,this.to=r,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(e=0,t=this.maps.length){return new c(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),null!=t&&this.setMirror(this._maps.length-1,t)}appendMapping(e){for(let t=0,n=this._maps.length;t<e._maps.length;t++){let r=e.getMirror(t);this.appendMap(e._maps[t],null!=r&&r<t?n+r: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 r=e.getMirror(t);this.appendMap(e._maps[t].invert(),null!=r&&r>t?n-r-1:void 0)}}invert(){let e=new c;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 r=0;for(let n=this.from;n<this.to;n++){let o=this._maps[n].mapResult(e,t);if(null!=o.recover){let t=this.getMirror(n);if(null!=t&&t>n&&t<this.to){n=t,e=this._maps[t].recover(o.recover);continue}}r|=o.delInfo,e=o.pos}return n?e:new l(e,r,null)}}const h=Object.create(null);class d{getMap(){return a.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let n=h[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 h)throw new RangeError("Duplicate use of step JSON ID "+e);return h[e]=t,t.prototype.jsonID=e,t}}class p{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new p(e,null)}static fail(e){return new p(null,e)}static fromReplace(e,t,n,o){try{return p.ok(e.replace(t,n,o))}catch(e){if(e instanceof r.vI)return p.fail(e.message);throw e}}}function f(e,t,n){let o=[];for(let r=0;r<e.childCount;r++){let i=e.child(r);i.content.size&&(i=i.copy(f(i.content,t,i))),i.isInline&&(i=t(i,n,r)),o.push(i)}return r.FK.fromArray(o)}class u extends d{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),o=n.node(n.sharedDepth(this.to)),i=new r.Ji(f(t.content,(e,t)=>e.isAtom&&t.type.allowsMarkType(this.mark.type)?e.mark(this.mark.addToSet(e.marks)):e,o),t.openStart,t.openEnd);return p.fromReplace(e,this.from,this.to,i)}invert(){return new m(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return t.deleted&&n.deleted||t.pos>=n.pos?null:new u(t.pos,n.pos,this.mark)}merge(e){return e instanceof u&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new u(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("number"!=typeof t.from||"number"!=typeof t.to)throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new u(t.from,t.to,e.markFromJSON(t.mark))}}d.jsonID("addMark",u);class m extends d{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 r.Ji(f(t.content,e=>e.mark(this.mark.removeFromSet(e.marks)),e),t.openStart,t.openEnd);return p.fromReplace(e,this.from,this.to,n)}invert(){return new u(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return t.deleted&&n.deleted||t.pos>=n.pos?null:new m(t.pos,n.pos,this.mark)}merge(e){return e instanceof m&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new m(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("number"!=typeof t.from||"number"!=typeof t.to)throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new m(t.from,t.to,e.markFromJSON(t.mark))}}d.jsonID("removeMark",m);class g extends d{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return p.fail("No node at mark step's position");let n=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return p.fromReplace(e,this.pos,this.pos+1,new r.Ji(r.FK.from(n),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let e=this.mark.addToSet(t.marks);if(e.length==t.marks.length){for(let n=0;n<t.marks.length;n++)if(!t.marks[n].isInSet(e))return new g(this.pos,t.marks[n]);return new g(this.pos,this.mark)}}return new w(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new g(t.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if("number"!=typeof t.pos)throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new g(t.pos,e.markFromJSON(t.mark))}}d.jsonID("addNodeMark",g);class w extends d{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return p.fail("No node at mark step's position");let n=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return p.fromReplace(e,this.pos,this.pos+1,new r.Ji(r.FK.from(n),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return t&&this.mark.isInSet(t.marks)?new g(this.pos,this.mark):this}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new w(t.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if("number"!=typeof t.pos)throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new w(t.pos,e.markFromJSON(t.mark))}}d.jsonID("removeNodeMark",w);class y extends d{constructor(e,t,n,r=!1){super(),this.from=e,this.to=t,this.slice=n,this.structure=r}apply(e){return this.structure&&b(e,this.from,this.to)?p.fail("Structure replace would overwrite content"):p.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new a([this.from,this.to-this.from,this.slice.size])}invert(e){return new y(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&&y.MAP_BIAS<0?t:e.mapResult(this.from,1);return n.deletedAcross&&t.deletedAcross?null:new y(n.pos,Math.max(n.pos,t.pos),this.slice,this.structure)}merge(e){if(!(e instanceof y)||e.structure||this.structure)return null;if(this.from+this.slice.size!=e.from||this.slice.openEnd||e.slice.openStart){if(e.to!=this.from||this.slice.openStart||e.slice.openEnd)return null;{let t=this.slice.size+e.slice.size==0?r.Ji.empty:new r.Ji(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new y(e.from,this.to,t,this.structure)}}{let t=this.slice.size+e.slice.size==0?r.Ji.empty:new r.Ji(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new y(this.from,this.to+(e.to-e.from),t,this.structure)}}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("number"!=typeof t.from||"number"!=typeof t.to)throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new y(t.from,t.to,r.Ji.fromJSON(e,t.slice),!!t.structure)}}y.MAP_BIAS=1,d.jsonID("replace",y);class v extends d{constructor(e,t,n,r,o,i,s=!1){super(),this.from=e,this.to=t,this.gapFrom=n,this.gapTo=r,this.slice=o,this.insert=i,this.structure=s}apply(e){if(this.structure&&(b(e,this.from,this.gapFrom)||b(e,this.gapTo,this.to)))return p.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return p.fail("Gap is not a flat range");let n=this.slice.insertAt(this.insert,t.content);return n?p.fromReplace(e,this.from,this.to,n):p.fail("Content does not fit in gap")}getMap(){return new a([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 v(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),r=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||r<t.pos||o>n.pos?null:new v(t.pos,n.pos,r,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("number"!=typeof t.from||"number"!=typeof t.to||"number"!=typeof t.gapFrom||"number"!=typeof t.gapTo||"number"!=typeof t.insert)throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new v(t.from,t.to,t.gapFrom,t.gapTo,r.Ji.fromJSON(e,t.slice),t.insert,!!t.structure)}}function b(e,t,n){let r=e.resolve(t),o=n-t,i=r.depth;for(;o>0&&i>0&&r.indexAfter(i)==r.node(i).childCount;)i--,o--;if(o>0){let e=r.node(i).maybeChild(r.indexAfter(i));for(;o>0;){if(!e||e.isLeaf)return!0;e=e.firstChild,o--}}return!1}function S(e,t,n,o=n.contentMatch,i=!0){let s=e.doc.nodeAt(t),l=[],a=t+1;for(let t=0;t<s.childCount;t++){let c=s.child(t),h=a+c.nodeSize,d=o.matchType(c.type);if(d){o=d;for(let t=0;t<c.marks.length;t++)n.allowsMarkType(c.marks[t].type)||e.step(new m(a,h,c.marks[t]));if(i&&c.isText&&"pre"!=n.whitespace){let e,t,o=/\r?\n|\r/g;for(;e=o.exec(c.text);)t||(t=new r.Ji(r.FK.from(n.schema.text(" ",n.allowedMarks(c.marks))),0,0)),l.push(new y(a+e.index,a+e.index+e[0].length,t))}}else l.push(new y(a,h,r.Ji.empty));a=h}if(!o.validEnd){let t=o.fillBefore(r.FK.empty,!0);e.replace(a,a,new r.Ji(t,0,0))}for(let t=l.length-1;t>=0;t--)e.step(l[t])}function x(e,t,n){return(0==t||e.canReplace(t,e.childCount))&&(n==e.childCount||e.canReplace(0,n))}function k(e){let t=e.parent.content.cutByIndex(e.startIndex,e.endIndex);for(let n=e.depth,r=0,o=0;;--n){let i=e.$from.node(n),s=e.$from.index(n)+r,l=e.$to.indexAfter(n)-o;if(n<e.depth&&i.canReplace(s,l,t))return n;if(0==n||i.type.spec.isolating||!x(i,s,l))break;s&&(r=1),l<i.childCount&&(o=1)}return null}function C(e,t,n=null,r=e){let o=function(e,t){let{parent:n,startIndex:r,endIndex:o}=e,i=n.contentMatchAt(r).findWrapping(t);if(!i)return null;let s=i.length?i[0]:t;return n.canReplaceWith(r,o,s)?i:null}(e,t),i=o&&function(e,t){let{parent:n,startIndex:r,endIndex:o}=e,i=n.child(r),s=t.contentMatch.findWrapping(i.type);if(!s)return null;let l=(s.length?s[s.length-1]:t).contentMatch;for(let e=r;l&&e<o;e++)l=l.matchType(n.child(e).type);return l&&l.validEnd?s:null}(r,t);return i?o.map(M).concat({type:t,attrs:n}).concat(i.map(M)):null}function M(e){return{type:e,attrs:null}}function N(e,t,n,r){t.forEach((o,i)=>{if(o.isText){let s,l=/\r?\n|\r/g;for(;s=l.exec(o.text);){let o=e.mapping.slice(r).map(n+1+i+s.index);e.replaceWith(o,o+1,t.type.schema.linebreakReplacement.create())}}})}function O(e,t,n,r){t.forEach((o,i)=>{if(o.type==o.type.schema.linebreakReplacement){let o=e.mapping.slice(r).map(n+1+i);e.replaceWith(o,o+1,t.type.schema.text("\n"))}})}function D(e,t,n=1,r){let o=e.resolve(t),i=o.depth-n,s=r&&r[r.length-1]||o.parent;if(i<0||o.parent.type.spec.isolating||!o.parent.canReplace(o.index(),o.parent.childCount)||!s.type.validContent(o.parent.content.cutByIndex(o.index(),o.parent.childCount)))return!1;for(let e=o.depth-1,t=n-2;e>i;e--,t--){let n=o.node(e),i=o.index(e);if(n.type.spec.isolating)return!1;let s=n.content.cutByIndex(i,n.childCount),l=r&&r[t+1];l&&(s=s.replaceChild(0,l.type.create(l.attrs)));let a=r&&r[t]||n;if(!n.canReplace(i+1,n.childCount)||!a.type.validContent(s))return!1}let l=o.indexAfter(i),a=r&&r[0];return o.node(i).canReplaceWith(l,l,a?a.type:o.node(i+1).type)}function A(e,t){let n=e.resolve(t),r=n.index();return T(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function T(e,t){return!(!e||!t||e.isLeaf||!function(e,t){t.content.size||e.type.compatibleContent(t.type);let n=e.contentMatchAt(e.childCount),{linebreakReplacement:r}=e.type.schema;for(let o=0;o<t.childCount;o++){let i=t.child(o),s=i.type==r?e.type.schema.nodes.text:i.type;if(n=n.matchType(s),!n)return!1;if(!e.type.allowsMarks(i.marks))return!1}return n.validEnd}(e,t))}function E(e,t,n){let r=e.resolve(t);if(!n.content.size)return t;let o=n.content;for(let e=0;e<n.openStart;e++)o=o.firstChild.content;for(let e=1;e<=(0==n.openStart&&n.size?2:1);e++)for(let t=r.depth;t>=0;t--){let n=t==r.depth?0:r.pos<=(r.start(t+1)+r.end(t+1))/2?-1:1,i=r.index(t)+(n>0?1:0),s=r.node(t),l=!1;if(1==e)l=s.canReplace(i,i,o);else{let e=s.contentMatchAt(i).findWrapping(o.firstChild.type);l=e&&s.canReplaceWith(i,i,e[0])}if(l)return 0==n?r.pos:n<0?r.before(t+1):r.after(t+1)}return null}function R(e,t,n=t,o=r.Ji.empty){if(t==n&&!o.size)return null;let i=e.resolve(t),s=e.resolve(n);return I(i,s,o)?new y(t,n,o):new z(i,s,o).fit()}function I(e,t,n){return!n.openStart&&!n.openEnd&&e.start()==t.start()&&e.parent.canReplace(e.index(),t.index(),n.content)}d.jsonID("replaceAround",v);class z{constructor(e,t,n){this.$from=e,this.$to=t,this.unplaced=n,this.frontier=[],this.placed=r.FK.empty;for(let t=0;t<=e.depth;t++){let n=e.node(t);this.frontier.push({type:n.type,match:n.contentMatchAt(e.indexAfter(t))})}for(let t=e.depth;t>0;t--)this.placed=r.FK.from(e.node(t).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let e=this.findFittable();e?this.placeNodes(e):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,n=this.$from,o=this.close(e<0?this.$to:n.doc.resolve(e));if(!o)return null;let i=this.placed,s=n.depth,l=o.depth;for(;s&&l&&1==i.childCount;)i=i.firstChild.content,s--,l--;let a=new r.Ji(i,s,l);return e>-1?new v(n.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||n.pos!=this.$to.pos?new y(n.pos,o.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,n=0,r=this.unplaced.openEnd;n<e;n++){let o=t.firstChild;if(t.childCount>1&&(r=0),o.type.spec.isolating&&r<=n){e=n;break}t=o.content}for(let t=1;t<=2;t++)for(let n=1==t?e:this.unplaced.openStart;n>=0;n--){let e,o=null;n?(o=P(this.unplaced.content,n-1).firstChild,e=o.content):e=this.unplaced.content;let i=e.firstChild;for(let e=this.depth;e>=0;e--){let s,{type:l,match:a}=this.frontier[e],c=null;if(1==t&&(i?a.matchType(i.type)||(c=a.fillBefore(r.FK.from(i),!1)):o&&l.compatibleContent(o.type)))return{sliceDepth:n,frontierDepth:e,parent:o,inject:c};if(2==t&&i&&(s=a.findWrapping(i.type)))return{sliceDepth:n,frontierDepth:e,parent:o,wrap:s};if(o&&a.matchType(o.type))break}}}openMore(){let{content:e,openStart:t,openEnd:n}=this.unplaced;return!(J(e,-1)<=t)&&(this.unplaced.size>1&&J(e,1)>n&&n++,this.unplaced=new r.Ji(e,t+1,n),!0)}dropNode(){let{content:e,openStart:t,openEnd:n}=this.unplaced,o=P(e,t);if(o.childCount<=1&&t>0){let i=e.size-t<=t+o.size;this.unplaced=new r.Ji($(e,t-1,1),t-1,i?t-1:n)}else this.unplaced=new r.Ji($(e,t,1),t,n)}placeNodes({sliceDepth:e,frontierDepth:t,parent:n,inject:o,wrap:i}){for(;this.depth>t;)this.closeFrontierNode();if(i)for(let e=0;e<i.length;e++)this.openFrontierNode(i[e]);let s=this.unplaced,l=n?n.content:s.content,a=s.openStart-e,c=0,h=[],{match:d,type:p}=this.frontier[t];if(o){for(let e=0;e<o.childCount;e++)h.push(o.child(e));d=d.matchFragment(o)}let f=l.size+e-(s.content.size-s.openEnd);for(;c<l.childCount;){let e=l.child(c),t=d.matchType(e.type);if(!t)break;c++,(c>1||0==a||e.content.size)&&(d=t,h.push(B(e.mark(p.allowedMarks(e.marks)),1==c?a:0,c==l.childCount?f:-1)))}let u=c==l.childCount;u||(f=-1),this.placed=F(this.placed,t,r.FK.from(h)),this.frontier[t].match=d,u&&f<0&&n&&n.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let e=0,t=l;e<f;e++){let e=t.lastChild;this.frontier.push({type:e.type,match:e.contentMatchAt(e.childCount)}),t=e.content}this.unplaced=u?0==e?r.Ji.empty:new r.Ji($(s.content,e-1,1),e-1,f<0?s.openEnd:e-1):new r.Ji($(s.content,e,c),s.openStart,s.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e,t=this.frontier[this.depth];if(!t.type.isTextblock||!V(this.$to,this.$to.depth,t.type,t.match,!1)||this.$to.depth==this.depth&&(e=this.findCloseLevel(this.$to))&&e.depth==this.depth)return-1;let{depth:n}=this.$to,r=this.$to.after(n);for(;n>1&&r==this.$to.end(--n);)++r;return r}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:n,type:r}=this.frontier[t],o=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),i=V(e,t,r,n,o);if(i){for(let n=t-1;n>=0;n--){let{match:t,type:r}=this.frontier[n],o=V(e,n,r,t,!0);if(!o||o.childCount)continue e}return{depth:t,fit:i,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=F(this.placed,t.depth,t.fit)),e=t.move;for(let n=t.depth+1;n<=e.depth;n++){let t=e.node(n),r=t.type.contentMatch.fillBefore(t.content,!0,e.index(n));this.openFrontierNode(t.type,t.attrs,r)}return e}openFrontierNode(e,t=null,n){let o=this.frontier[this.depth];o.match=o.match.matchType(e),this.placed=F(this.placed,this.depth,r.FK.from(e.create(t,n))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let e=this.frontier.pop().match.fillBefore(r.FK.empty,!0);e.childCount&&(this.placed=F(this.placed,this.frontier.length,e))}}function $(e,t,n){return 0==t?e.cutByIndex(n,e.childCount):e.replaceChild(0,e.firstChild.copy($(e.firstChild.content,t-1,n)))}function F(e,t,n){return 0==t?e.append(n):e.replaceChild(e.childCount-1,e.lastChild.copy(F(e.lastChild.content,t-1,n)))}function P(e,t){for(let n=0;n<t;n++)e=e.firstChild.content;return e}function B(e,t,n){if(t<=0)return e;let o=e.content;return t>1&&(o=o.replaceChild(0,B(o.firstChild,t-1,1==o.childCount?n-1:0))),t>0&&(o=e.type.contentMatch.fillBefore(o).append(o),n<=0&&(o=o.append(e.type.contentMatch.matchFragment(o).fillBefore(r.FK.empty,!0)))),e.copy(o)}function V(e,t,n,r,o){let i=e.node(t),s=o?e.indexAfter(t):e.index(t);if(s==i.childCount&&!n.compatibleContent(i.type))return null;let l=r.fillBefore(i.content,!0,s);return l&&!function(e,t,n){for(let r=n;r<t.childCount;r++)if(!e.allowsMarks(t.child(r).marks))return!0;return!1}(n,i.content,s)?l:null}function L(e){return e.spec.defining||e.spec.definingForContent}function J(e,t){for(let n=0;;n++){let r=t<0?e.firstChild:e.lastChild;if(!r||r.isAtom)return n;e=r.content}}function K(e,t,n,o,i){if(t<n){let r=e.firstChild;e=e.replaceChild(0,r.copy(K(r.content,t+1,n,o,r)))}if(t>o){let t=i.contentMatchAt(0),n=t.fillBefore(e).append(e);e=n.append(t.matchFragment(n).fillBefore(r.FK.empty,!0))}return e}function W(e,t){let n=[];for(let r=Math.min(e.depth,t.depth);r>=0;r--){let o=e.start(r);if(o<e.pos-(e.depth-r)||t.end(r)>t.pos+(t.depth-r)||e.node(r).type.spec.isolating||t.node(r).type.spec.isolating)break;(o==t.start(r)||r==e.depth&&r==t.depth&&e.parent.inlineContent&&t.parent.inlineContent&&r&&t.start(r-1)==o-1)&&n.push(r)}return n}class _ extends d{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 p.fail("No node at attribute step's position");let n=Object.create(null);for(let e in t.attrs)n[e]=t.attrs[e];n[this.attr]=this.value;let o=t.type.create(n,null,t.marks);return p.fromReplace(e,this.pos,this.pos+1,new r.Ji(r.FK.from(o),0,t.isLeaf?0:1))}getMap(){return a.empty}invert(e){return new _(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 _(t.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,t){if("number"!=typeof t.pos||"string"!=typeof t.attr)throw new RangeError("Invalid input for AttrStep.fromJSON");return new _(t.pos,t.attr,t.value)}}d.jsonID("attr",_);class q extends d{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let n in e.attrs)t[n]=e.attrs[n];t[this.attr]=this.value;let n=e.type.create(t,e.content,e.marks);return p.ok(n)}getMap(){return a.empty}invert(e){return new q(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("string"!=typeof t.attr)throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new q(t.attr,t.value)}}d.jsonID("docAttr",q);let j=class extends Error{};j=function e(t){let n=Error.call(this,t);return n.__proto__=e.prototype,n},(j.prototype=Object.create(Error.prototype)).constructor=j,j.prototype.name="TransformError";class U{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new c}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new j(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 r=this.mapping.maps[n];n&&(e=r.map(e,1),t=r.map(t,-1)),r.forEach((n,r,o,i)=>{e=Math.min(e,o),t=Math.max(t,i)})}return 1e9==e?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=r.Ji.empty){let o=R(this.doc,e,t,n);return o&&this.step(o),this}replaceWith(e,t,n){return this.replace(e,t,new r.Ji(r.FK.from(n),0,0))}delete(e,t){return this.replace(e,t,r.Ji.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,n){return function(e,t,n,o){if(!o.size)return e.deleteRange(t,n);let i=e.doc.resolve(t),s=e.doc.resolve(n);if(I(i,s,o))return e.step(new y(t,n,o));let l=W(i,s);0==l[l.length-1]&&l.pop();let a=-(i.depth+1);l.unshift(a);for(let e=i.depth,t=i.pos-1;e>0;e--,t--){let n=i.node(e).type.spec;if(n.defining||n.definingAsContext||n.isolating)break;l.indexOf(e)>-1?a=e:i.before(e)==t&&l.splice(1,0,-e)}let c=l.indexOf(a),h=[],d=o.openStart;for(let e=o.content,t=0;;t++){let n=e.firstChild;if(h.push(n),t==o.openStart)break;e=n.content}for(let e=d-1;e>=0;e--){let t=h[e],n=L(t.type);if(n&&!t.sameMarkup(i.node(Math.abs(a)-1)))d=e;else if(n||!t.type.isTextblock)break}for(let t=o.openStart;t>=0;t--){let a=(t+d+1)%(o.openStart+1),p=h[a];if(p)for(let t=0;t<l.length;t++){let h=l[(t+c)%l.length],d=!0;h<0&&(d=!1,h=-h);let f=i.node(h-1),u=i.index(h-1);if(f.canReplaceWith(u,u,p.type,p.marks))return e.replace(i.before(h),d?s.after(h):n,new r.Ji(K(o.content,0,o.openStart,a),a,o.openEnd))}}let p=e.steps.length;for(let r=l.length-1;r>=0&&(e.replace(t,n,o),!(e.steps.length>p));r--){let e=l[r];e<0||(t=i.before(e),n=s.after(e))}}(this,e,t,n),this}replaceRangeWith(e,t,n){return function(e,t,n,o){if(!o.isInline&&t==n&&e.doc.resolve(t).parent.content.size){let r=function(e,t,n){let r=e.resolve(t);if(r.parent.canReplaceWith(r.index(),r.index(),n))return t;if(0==r.parentOffset)for(let e=r.depth-1;e>=0;e--){let t=r.index(e);if(r.node(e).canReplaceWith(t,t,n))return r.before(e+1);if(t>0)return null}if(r.parentOffset==r.parent.content.size)for(let e=r.depth-1;e>=0;e--){let t=r.indexAfter(e);if(r.node(e).canReplaceWith(t,t,n))return r.after(e+1);if(t<r.node(e).childCount)return null}return null}(e.doc,t,o.type);null!=r&&(t=n=r)}e.replaceRange(t,n,new r.Ji(r.FK.from(o),0,0))}(this,e,t,n),this}deleteRange(e,t){return function(e,t,n){let r=e.doc.resolve(t),o=e.doc.resolve(n);if(r.parent.isTextblock&&o.parent.isTextblock&&r.start()!=o.start()&&0==r.parentOffset&&0==o.parentOffset){let i=r.sharedDepth(n),s=!1;for(let e=r.depth;e>i;e--)r.node(e).type.spec.isolating&&(s=!0);for(let e=o.depth;e>i;e--)o.node(e).type.spec.isolating&&(s=!0);if(!s){for(let e=r.depth;e>0&&t==r.start(e);e--)t=r.before(e);for(let e=o.depth;e>0&&n==o.start(e);e--)n=o.before(e);r=e.doc.resolve(t),o=e.doc.resolve(n)}}let i=W(r,o);for(let t=0;t<i.length;t++){let n=i[t],s=t==i.length-1;if(s&&0==n||r.node(n).type.contentMatch.validEnd)return e.delete(r.start(n),o.end(n));if(n>0&&(s||r.node(n-1).canReplace(r.index(n-1),o.indexAfter(n-1))))return e.delete(r.before(n),o.after(n))}for(let i=1;i<=r.depth&&i<=o.depth;i++)if(t-r.start(i)==r.depth-i&&n>r.end(i)&&o.end(i)-n!=o.depth-i&&r.start(i-1)==o.start(i-1)&&r.node(i-1).canReplace(r.index(i-1),o.index(i-1)))return e.delete(r.before(i),n);e.delete(t,n)}(this,e,t),this}lift(e,t){return function(e,t,n){let{$from:o,$to:i,depth:s}=t,l=o.before(s+1),a=i.after(s+1),c=l,h=a,d=r.FK.empty,p=0;for(let e=s,t=!1;e>n;e--)t||o.index(e)>0?(t=!0,d=r.FK.from(o.node(e).copy(d)),p++):c--;let f=r.FK.empty,u=0;for(let e=s,t=!1;e>n;e--)t||i.after(e+1)<i.end(e)?(t=!0,f=r.FK.from(i.node(e).copy(f)),u++):h++;e.step(new v(c,h,l,a,new r.Ji(d.append(f),p,u),d.size-p,!0))}(this,e,t),this}join(e,t=1){return function(e,t,n){let o=null,{linebreakReplacement:i}=e.doc.type.schema,s=e.doc.resolve(t-n),l=s.node().type;if(i&&l.inlineContent){let e="pre"==l.whitespace,t=!!l.contentMatch.matchType(i);e&&!t?o=!1:!e&&t&&(o=!0)}let a=e.steps.length;if(!1===o){let r=e.doc.resolve(t+n);O(e,r.node(),r.before(),a)}l.inlineContent&&S(e,t+n-1,l,s.node().contentMatchAt(s.index()),null==o);let c=e.mapping.slice(a),h=c.map(t-n);if(e.step(new y(h,c.map(t+n,-1),r.Ji.empty,!0)),!0===o){let t=e.doc.resolve(h);N(e,t.node(),t.before(),e.steps.length)}}(this,e,t),this}wrap(e,t){return function(e,t,n){let o=r.FK.empty;for(let e=n.length-1;e>=0;e--){if(o.size){let t=n[e].type.contentMatch.matchFragment(o);if(!t||!t.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}o=r.FK.from(n[e].type.create(n[e].attrs,o))}let i=t.start,s=t.end;e.step(new v(i,s,i,s,new r.Ji(o,0,0),n.length,!0))}(this,e,t),this}setBlockType(e,t=e,n,o=null){return function(e,t,n,o,i){if(!o.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let s=e.steps.length;e.doc.nodesBetween(t,n,(t,n)=>{let l="function"==typeof i?i(t):i;if(t.isTextblock&&!t.hasMarkup(o,l)&&function(e,t,n){let r=e.resolve(t),o=r.index();return r.parent.canReplaceWith(o,o+1,n)}(e.doc,e.mapping.slice(s).map(n),o)){let i=null;if(o.schema.linebreakReplacement){let e="pre"==o.whitespace,t=!!o.contentMatch.matchType(o.schema.linebreakReplacement);e&&!t?i=!1:!e&&t&&(i=!0)}!1===i&&O(e,t,n,s),S(e,e.mapping.slice(s).map(n,1),o,void 0,null===i);let a=e.mapping.slice(s),c=a.map(n,1),h=a.map(n+t.nodeSize,1);return e.step(new v(c,h,c+1,h-1,new r.Ji(r.FK.from(o.create(l,null,t.marks)),0,0),1,!0)),!0===i&&N(e,t,n,s),!1}})}(this,e,t,n,o),this}setNodeMarkup(e,t,n=null,o){return function(e,t,n,o,i){let s=e.doc.nodeAt(t);if(!s)throw new RangeError("No node at given position");n||(n=s.type);let l=n.create(o,null,i||s.marks);if(s.isLeaf)return e.replaceWith(t,t+s.nodeSize,l);if(!n.validContent(s.content))throw new RangeError("Invalid content for node type "+n.name);e.step(new v(t,t+s.nodeSize,t+1,t+s.nodeSize-1,new r.Ji(r.FK.from(l),0,0),1,!0))}(this,e,t,n,o),this}setNodeAttribute(e,t,n){return this.step(new _(e,t,n)),this}setDocAttribute(e,t){return this.step(new q(e,t)),this}addNodeMark(e,t){return this.step(new g(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 r.CU)t.isInSet(n.marks)&&this.step(new w(e,t));else{let r,o=n.marks,i=[];for(;r=t.isInSet(o);)i.push(new w(e,r)),o=r.removeFromSet(o);for(let e=i.length-1;e>=0;e--)this.step(i[e])}return this}split(e,t=1,n){return function(e,t,n=1,o){let i=e.doc.resolve(t),s=r.FK.empty,l=r.FK.empty;for(let e=i.depth,t=i.depth-n,a=n-1;e>t;e--,a--){s=r.FK.from(i.node(e).copy(s));let t=o&&o[a];l=r.FK.from(t?t.type.create(t.attrs,l):i.node(e).copy(l))}e.step(new y(t,t,new r.Ji(s.append(l),n,n),!0))}(this,e,t,n),this}addMark(e,t,n){return function(e,t,n,r){let o,i,s=[],l=[];e.doc.nodesBetween(t,n,(e,a,c)=>{if(!e.isInline)return;let h=e.marks;if(!r.isInSet(h)&&c.type.allowsMarkType(r.type)){let c=Math.max(a,t),d=Math.min(a+e.nodeSize,n),p=r.addToSet(h);for(let e=0;e<h.length;e++)h[e].isInSet(p)||(o&&o.to==c&&o.mark.eq(h[e])?o.to=d:s.push(o=new m(c,d,h[e])));i&&i.to==c?i.to=d:l.push(i=new u(c,d,r))}}),s.forEach(t=>e.step(t)),l.forEach(t=>e.step(t))}(this,e,t,n),this}removeMark(e,t,n){return function(e,t,n,o){let i=[],s=0;e.doc.nodesBetween(t,n,(e,l)=>{if(!e.isInline)return;s++;let a=null;if(o instanceof r.sX){let t,n=e.marks;for(;t=o.isInSet(n);)(a||(a=[])).push(t),n=t.removeFromSet(n)}else o?o.isInSet(e.marks)&&(a=[o]):a=e.marks;if(a&&a.length){let r=Math.min(l+e.nodeSize,n);for(let e=0;e<a.length;e++){let n,o=a[e];for(let e=0;e<i.length;e++){let t=i[e];t.step==s-1&&o.eq(i[e].style)&&(n=t)}n?(n.to=r,n.step=s):i.push({style:o,from:Math.max(l,t),to:r,step:s})}}}),i.forEach(t=>e.step(new m(t.from,t.to,t.style)))}(this,e,t,n),this}clearIncompatible(e,t,n){return S(this,e,t,n),this}}},1575(e,t,n){n.d(t,{Lz:()=>bn,NZ:()=>jt,zF:()=>Gt});var r=n(42845),o=n(58903),i=n(38262);const s=function(e){for(var t=0;;t++)if(!(e=e.previousSibling))return t},l=function(e){let t=e.assignedSlot||e.parentNode;return t&&11==t.nodeType?t.host:t};let a=null;const c=function(e,t,n){let r=a||(a=document.createRange());return r.setEnd(e,n??e.nodeValue.length),r.setStart(e,t||0),r},h=function(e,t,n,r){return n&&(p(e,t,n,r,-1)||p(e,t,n,r,1))},d=/^(img|br|input|textarea|hr)$/i;function p(e,t,n,r,o){for(var i;;){if(e==n&&t==r)return!0;if(t==(o<0?0:f(e))){let n=e.parentNode;if(!n||!u(n)||w(e)||d.test(e.nodeName)||"false"==e.contentEditable)return!1;t=s(e)+(o<0?0:1),e=n}else{if(!u(e))return!1;{let n=e.childNodes[t+(o<0?-1:0)];if(u(n)&&"false"==n.contentEditable){if(!(null===(i=n.pmViewDesc)||void 0===i?void 0:i.ignoreForSelection))return!1;t+=o}else e=n,t=o<0?f(e):0}}}}function f(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function u(e){return 1==e.nodeType}function m(e){return 3==e.nodeType}function g(e,t){return!!t&&e.contains(u(t)?t:t.parentNode)}function w(e){let t;for(let n=e;n&&!(t=n.pmViewDesc);n=n.parentNode);return t&&t.node&&t.node.isBlock&&(t.dom==e||t.contentDOM==e)}const y=function(e){return e.focusNode&&h(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)};function v(e,t){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=e,n.key=n.code=t,n}const b="undefined"!=typeof navigator?navigator:null,S="undefined"!=typeof document?document:null,x=b&&b.userAgent||"",k=/Edge\/(\d+)/.exec(x),C=/MSIE \d/.exec(x),M=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(x),N=!!(C||M||k),O=C?document.documentMode:M?+M[1]:k?+k[1]:0,D=!N&&/gecko\/(\d+)/i.test(x);D&&(/Firefox\/(\d+)/.exec(x)||[0,0])[1];const A=!N&&/Chrome\/(\d+)/.exec(x),T=!!A,E=A?+A[1]:0,R=!N&&!!b&&/Apple Computer/.test(b.vendor),I=R&&(/Mobile\/\w+/.test(x)||!!b&&b.maxTouchPoints>2),z=I||!!b&&/Mac/.test(b.platform),$=!!b&&/Win/.test(b.platform),F=/Android \d/.test(x),P=!!S&&"webkitFontSmoothing"in S.documentElement.style,B=P?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function V(e){let t=e.defaultView&&e.defaultView.visualViewport;return t?{left:0,right:t.width,top:0,bottom:t.height}:{left:0,right:e.documentElement.clientWidth,top:0,bottom:e.documentElement.clientHeight}}function L(e,t){return"number"==typeof e?e:e[t]}function J(e){let t=e.getBoundingClientRect(),n=t.width/e.offsetWidth||1,r=t.height/e.offsetHeight||1;return{left:t.left,right:t.left+e.clientWidth*n,top:t.top,bottom:t.top+e.clientHeight*r}}function K(e,t,n){if(!X(t)&&0==t.left)return;let r=e.someProp("scrollThreshold")||0,o=e.someProp("scrollMargin")||5,i=e.dom.ownerDocument;for(let s=n||e.dom;s;){if(!u(s)){s=l(s);continue}let e=s==i.body,n=e?V(i):J(s),a=0,c=0;if(t.top<n.top+L(r,"top")?c=-(n.top-t.top+L(o,"top")):t.bottom>n.bottom-L(r,"bottom")&&(c=t.bottom-t.top>n.bottom-n.top?t.top+L(o,"top")-n.top:t.bottom-n.bottom+L(o,"bottom")),t.left<n.left+L(r,"left")?a=-(n.left-t.left+L(o,"left")):t.right>n.right-L(r,"right")&&(a=t.right-n.right+L(o,"right")),a||c)if(e)i.defaultView.scrollBy(a,c);else{let e=s.scrollLeft,n=s.scrollTop;c&&(s.scrollTop+=c),a&&(s.scrollLeft+=a);let r=s.scrollLeft-e,o=s.scrollTop-n;t={left:t.left-r,top:t.top-o,right:t.right-r,bottom:t.bottom-o}}let h=e?"fixed":getComputedStyle(s).position;if(/^(fixed|sticky)$/.test(h))break;s="absolute"==h?s.offsetParent:l(s)}}function W(e){let t=[],n=e.ownerDocument;for(let r=e;r&&(t.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),e!=n);r=l(r));return t}function _(e,t){for(let n=0;n<e.length;n++){let{dom:r,top:o,left:i}=e[n];r.scrollTop!=o+t&&(r.scrollTop=o+t),r.scrollLeft!=i&&(r.scrollLeft=i)}}let q=null;function j(e,t){let n,r,o,i,s=2e8,l=0,a=t.top,h=t.top;for(let d=e.firstChild,p=0;d;d=d.nextSibling,p++){let e;if(u(d))e=d.getClientRects();else{if(!m(d))continue;e=c(d).getClientRects()}for(let c=0;c<e.length;c++){let f=e[c];if(f.top<=a&&f.bottom>=h){a=Math.max(f.bottom,a),h=Math.min(f.top,h);let e=f.left>t.left?f.left-t.left:f.right<t.left?t.left-f.right:0;if(e<s){n=d,s=e,r=e&&m(n)?{left:f.right<t.left?f.right:f.left,top:t.top}:t,u(d)&&e&&(l=p+(t.left>=(f.left+f.right)/2?1:0));continue}}else f.top>t.top&&!o&&f.left<=t.left&&f.right>=t.left&&(o=d,i={left:Math.max(f.left,Math.min(f.right,t.left)),top:f.top});!n&&(t.left>=f.right&&t.top>=f.top||t.left>=f.left&&t.top>=f.bottom)&&(l=p+1)}}return!n&&o&&(n=o,r=i,s=0),n&&m(n)?function(e,t){let n,r=e.nodeValue.length,o=document.createRange();for(let i=0;i<r;i++){o.setEnd(e,i+1),o.setStart(e,i);let r=Z(o,1);if(r.top!=r.bottom&&U(t,r)){n={node:e,offset:i+(t.left>=(r.left+r.right)/2?1:0)};break}}return o.detach(),n||{node:e,offset:0}}(n,r):!n||s?{node:e,offset:l}:j(n,r)}function U(e,t){return e.left>=t.left-1&&e.left<=t.right+1&&e.top>=t.top-1&&e.top<=t.bottom+1}function H(e,t,n){let r=e.childNodes.length;if(r&&n.top<n.bottom)for(let o=Math.max(0,Math.min(r-1,Math.floor(r*(t.top-n.top)/(n.bottom-n.top))-2)),i=o;;){let n=e.childNodes[i];if(u(n)){let e=n.getClientRects();for(let r=0;r<e.length;r++){let o=e[r];if(U(t,o))return H(n,t,o)}}if((i=(i+1)%r)==o)break}return e}function G(e,t){let n,r=e.dom.ownerDocument,o=0,i=function(e,t,n){if(e.caretPositionFromPoint)try{let r=e.caretPositionFromPoint(t,n);if(r)return{node:r.offsetNode,offset:Math.min(f(r.offsetNode),r.offset)}}catch(e){}if(e.caretRangeFromPoint){let r=e.caretRangeFromPoint(t,n);if(r)return{node:r.startContainer,offset:Math.min(f(r.startContainer),r.startOffset)}}}(r,t.left,t.top);i&&({node:n,offset:o}=i);let s,a=(e.root.elementFromPoint?e.root:r).elementFromPoint(t.left,t.top);if(!a||!e.dom.contains(a)){let n=e.dom.getBoundingClientRect();if(!U(t,n))return null;if(a=H(e.dom,t,n),!a)return null}if(R)for(let e=a;n&&e;e=l(e))e.draggable&&(n=void 0);if(a=function(e,t){let n=e.parentNode;return n&&/^li$/i.test(n.nodeName)&&t.left<e.getBoundingClientRect().left?n:e}(a,t),n){if(D&&u(n)&&(o=Math.min(o,n.childNodes.length),o<n.childNodes.length)){let e,r=n.childNodes[o];"IMG"==r.nodeName&&(e=r.getBoundingClientRect()).right<=t.left&&e.bottom>t.top&&o++}let r;P&&o&&u(n)&&u(r=n.childNodes[o-1])&&"false"==r.contentEditable&&r.getBoundingClientRect().top>=t.top&&o--,n==e.dom&&o==n.childNodes.length-1&&u(n.lastChild)&&t.top>n.lastChild.getBoundingClientRect().bottom?s=e.state.doc.content.size:0!=o&&u(n)&&"BR"==n.childNodes[o-1].nodeName||(s=function(e,t,n,r){let o=-1;for(let n=t,i=!1;n!=e.dom;){let t,s=e.docView.nearestDesc(n,!0);if(!s)return null;if(u(s.dom)&&(s.node.isBlock&&s.parent||!s.contentDOM)&&((t=s.dom.getBoundingClientRect()).width||t.height)&&(s.node.isBlock&&s.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(s.dom.nodeName)&&(!i&&t.left>r.left||t.top>r.top?o=s.posBefore:(!i&&t.right<r.left||t.bottom<r.top)&&(o=s.posAfter),i=!0),!s.contentDOM&&o<0&&!s.node.isText))return(s.node.isBlock?r.top<(t.top+t.bottom)/2:r.left<(t.left+t.right)/2)?s.posBefore:s.posAfter;n=s.dom.parentNode}return o>-1?o:e.docView.posFromDOM(t,n,-1)}(e,n,o,t))}null==s&&(s=function(e,t,n){let{node:r,offset:o}=j(t,n),i=-1;if(u(r)&&!r.firstChild){let e=r.getBoundingClientRect();i=e.left!=e.right&&n.left>(e.left+e.right)/2?1:-1}return e.docView.posFromDOM(r,o,i)}(e,a,t));let c=e.docView.nearestDesc(a,!0);return{pos:s,inside:c?c.posAtStart-c.border:-1}}function X(e){return e.top<e.bottom||e.left<e.right}function Z(e,t){let n=e.getClientRects();if(n.length){let e=n[t<0?0:n.length-1];if(X(e))return e}return Array.prototype.find.call(n,X)||e.getBoundingClientRect()}const Y=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function Q(e,t,n){let{node:r,offset:o,atom:i}=e.docView.domFromPos(t,n<0?-1:1),s=P||D;if(m(r)){if(!s||!Y.test(r.nodeValue)&&(n<0?o:o!=r.nodeValue.length)){let e=o,t=o,i=n<0?1:-1;return n<0&&!o?(t++,i=-1):n>=0&&o==r.nodeValue.length?(e--,i=1):n<0?e--:t++,ee(Z(c(r,e,t),i),i<0)}{let e=Z(c(r,o,o),n);if(D&&o&&/\s/.test(r.nodeValue[o-1])&&o<r.nodeValue.length){let t=Z(c(r,o-1,o-1),-1);if(t.top==e.top){let n=Z(c(r,o,o+1),-1);if(n.top!=e.top)return ee(n,n.left<t.left)}}return e}}if(!e.state.doc.resolve(t-(i||0)).parent.inlineContent){if(null==i&&o&&(n<0||o==f(r))){let e=r.childNodes[o-1];if(u(e))return te(e.getBoundingClientRect(),!1)}if(null==i&&o<f(r)){let e=r.childNodes[o];if(u(e))return te(e.getBoundingClientRect(),!0)}return te(r.getBoundingClientRect(),n>=0)}if(null==i&&o&&(n<0||o==f(r))){let e=r.childNodes[o-1],t=m(e)?c(e,f(e)-(s?0:1)):!u(e)||"BR"==e.nodeName&&e.nextSibling?null:e;if(t)return ee(Z(t,1),!1)}if(null==i&&o<f(r)){let e=r.childNodes[o];for(;e.pmViewDesc&&e.pmViewDesc.ignoreForCoords;)e=e.nextSibling;let t=e?m(e)?c(e,0,s?0:1):u(e)?e:null:null;if(t)return ee(Z(t,-1),!0)}return ee(Z(m(r)?c(r):r,-n),n>=0)}function ee(e,t){if(0==e.width)return e;let n=t?e.left:e.right;return{top:e.top,bottom:e.bottom,left:n,right:n}}function te(e,t){if(0==e.height)return e;let n=t?e.top:e.bottom;return{top:n,bottom:n,left:e.left,right:e.right}}function ne(e,t,n){let r=e.state,o=e.root.activeElement;r!=t&&e.updateState(t),o!=e.dom&&e.focus();try{return n()}finally{r!=t&&e.updateState(r),o!=e.dom&&o&&o.focus()}}const re=/[\u0590-\u08ac]/;let oe=null,ie=null,se=!1;function le(e,t,n){return oe==t&&ie==n?se:(oe=t,ie=n,se="up"==n||"down"==n?function(e,t,n){let r=t.selection,o="up"==n?r.$from:r.$to;return ne(e,t,()=>{let{node:t}=e.docView.domFromPos(o.pos,"up"==n?-1:1);for(;;){let n=e.docView.nearestDesc(t,!0);if(!n)break;if(n.node.isBlock){t=n.contentDOM||n.dom;break}t=n.dom.parentNode}let r=Q(e,o.pos,1);for(let e=t.firstChild;e;e=e.nextSibling){let t;if(u(e))t=e.getClientRects();else{if(!m(e))continue;t=c(e,0,e.nodeValue.length).getClientRects()}for(let e=0;e<t.length;e++){let o=t[e];if(o.bottom>o.top+1&&("up"==n?r.top-o.top>2*(o.bottom-r.top):o.bottom-r.bottom>2*(r.bottom-o.top)))return!1}}return!0})}(e,t,n):function(e,t,n){let{$head:r}=t.selection;if(!r.parent.isTextblock)return!1;let o=r.parentOffset,i=!o,s=o==r.parent.content.size,l=e.domSelection();return l?re.test(r.parent.textContent)&&l.modify?ne(e,t,()=>{let{focusNode:t,focusOffset:o,anchorNode:i,anchorOffset:s}=e.domSelectionRange(),a=l.caretBidiLevel;l.modify("move",n,"character");let c=r.depth?e.docView.domAfterPos(r.before()):e.dom,{focusNode:h,focusOffset:d}=e.domSelectionRange(),p=h&&!g(c,h)||t==h&&o==d;try{l.collapse(i,s),t&&(t!=i||o!=s)&&l.extend&&l.extend(t,o)}catch(e){}return null!=a&&(l.caretBidiLevel=a),p}):"left"==n||"backward"==n?i:s:r.pos==r.start()||r.pos==r.end()}(e,t,n))}class ae{constructor(e,t,n,r){this.parent=e,this.children=t,this.dom=n,this.contentDOM=r,this.dirty=0,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 r=this.children[t];if(r==e)return n;n+=r.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&&g(this.contentDOM,e)){if(n<0){let n,r;if(e==this.contentDOM)n=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;n=e.previousSibling}for(;n&&(!(r=n.pmViewDesc)||r.parent!=this);)n=n.previousSibling;return n?this.posBeforeChild(r)+r.size:this.posAtStart}{let n,r;if(e==this.contentDOM)n=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;n=e.nextSibling}for(;n&&(!(r=n.pmViewDesc)||r.parent!=this);)n=n.nextSibling;return n?this.posBeforeChild(r):this.posAtEnd}}let r;if(e==this.dom&&this.contentDOM)r=t>s(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))r=!!(4&e.compareDocumentPosition(this.contentDOM));else if(this.dom.firstChild){if(0==t)for(let t=e;;t=t.parentNode){if(t==this.dom){r=!1;break}if(t.previousSibling)break}if(null==r&&t==e.childNodes.length)for(let t=e;;t=t.parentNode){if(t==this.dom){r=!0;break}if(t.nextSibling)break}}return r??n>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let n=!0,r=e;r;r=r.parentNode){let o,i=this.getDesc(r);if(i&&(!t||i.node)){if(!n||!(o=i.nodeDOM)||(u(o)?g(o,e):o==e))return i;n=!1}}}getDesc(e){let t=e.pmViewDesc;for(let e=t;e;e=e.parent)if(e==this)return t}posFromDOM(e,t,n){for(let r=e;r;r=r.parentNode){let o=this.getDesc(r);if(o)return o.localPosFromDOM(e,t,n)}return-1}descAt(e){for(let t=0,n=0;t<this.children.length;t++){let r=this.children[t],o=n+r.size;if(n==e&&o!=n){for(;!r.border&&r.children.length;)for(let e=0;e<r.children.length;e++){let t=r.children[e];if(t.size){r=t;break}}return r}if(e<o)return r.descAt(e-n-r.border);n=o}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let n=0,r=0;for(let t=0;n<this.children.length;n++){let o=t+this.children[n].size;if(o>e){r=e-t;break}t=o}if(r)return this.children[n].domFromPos(r-this.children[n].border,t);for(;n>0;n--){let e=this.children[n-1];if(e.size||!(e instanceof me||e instanceof ce&&e.side>=0))break}if(t<=0){let e,r=!0;for(;e=n?this.children[n-1]:null,e&&e.dom.parentNode!=this.contentDOM;n--,r=!1);return e&&t&&r&&!e.border&&!e.domAtom?e.domFromPos(e.size,t):{node:this.contentDOM,offset:e?s(e.dom)+1:0}}{let e,r=!0;for(;e=n<this.children.length?this.children[n]:null,e&&e.dom.parentNode!=this.contentDOM;n++,r=!1);return e&&r&&!e.border&&!e.domAtom?e.domFromPos(0,t):{node:this.contentDOM,offset:e?s(e.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,n=0){if(0==this.children.length)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let r=-1,o=-1;for(let i=n,l=0;;l++){let n=this.children[l],a=i+n.size;if(-1==r&&e<=a){let o=i+n.border;if(e>=o&&t<=a-n.border&&n.node&&n.contentDOM&&this.contentDOM.contains(n.contentDOM))return n.parseRange(e,t,o);e=i;for(let t=l;t>0;t--){let n=this.children[t-1];if(n.size&&n.dom.parentNode==this.contentDOM&&!n.emptyChildAt(1)){r=s(n.dom)+1;break}e-=n.size}-1==r&&(r=0)}if(r>-1&&(a>t||l==this.children.length-1)){t=a;for(let e=l+1;e<this.children.length;e++){let n=this.children[e];if(n.size&&n.dom.parentNode==this.contentDOM&&!n.emptyChildAt(-1)){o=s(n.dom);break}t+=n.size}-1==o&&(o=this.contentDOM.childNodes.length);break}i=a}return{node:this.contentDOM,from:e,to:t,fromOffset:r,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 0==t.size||t.emptyChildAt(e)}domAfterPos(e){let{node:t,offset:n}=this.domFromPos(e,0);if(!u(t)||n==t.childNodes.length)throw new RangeError("No node after pos "+e);return t.childNodes[n]}setSelection(e,t,n,r=!1){let o=Math.min(e,t),i=Math.max(e,t);for(let s=0,l=0;s<this.children.length;s++){let a=this.children[s],c=l+a.size;if(o>l&&i<c)return a.setSelection(e-l-a.border,t-l-a.border,n,r);l=c}let l=this.domFromPos(e,e?-1:1),a=t==e?l:this.domFromPos(t,t?-1:1),c=n.root.getSelection(),d=n.domSelectionRange(),p=!1;if((D||R)&&e==t){let{node:e,offset:t}=l;if(m(e)){if(p=!(!t||"\n"!=e.nodeValue[t-1]),p&&t==e.nodeValue.length)for(let t,n=e;n;n=n.parentNode){if(t=n.nextSibling){"BR"==t.nodeName&&(l=a={node:t.parentNode,offset:s(t)+1});break}let e=n.pmViewDesc;if(e&&e.node&&e.node.isBlock)break}}else{let n=e.childNodes[t-1];p=n&&("BR"==n.nodeName||"false"==n.contentEditable)}}if(D&&d.focusNode&&d.focusNode!=a.node&&u(d.focusNode)){let e=d.focusNode.childNodes[d.focusOffset];e&&"false"==e.contentEditable&&(r=!0)}if(!(r||p&&R)&&h(l.node,l.offset,d.anchorNode,d.anchorOffset)&&h(a.node,a.offset,d.focusNode,d.focusOffset))return;let f=!1;if((c.extend||e==t)&&(!p||!D)){c.collapse(l.node,l.offset);try{e!=t&&c.extend(a.node,a.offset),f=!0}catch(e){}}if(!f){if(e>t){let e=l;l=a,a=e}let n=document.createRange();n.setEnd(a.node,a.offset),n.setStart(l.node,l.offset),c.removeAllRanges(),c.addRange(n)}}ignoreMutation(e){return!this.contentDOM&&"selection"!=e.type}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let n=0,r=0;r<this.children.length;r++){let o=this.children[r],i=n+o.size;if(n==i?e<=i&&t>=n:e<i&&t>n){let r=n+o.border,s=i-o.border;if(e>=r&&t<=s)return this.dirty=e==n||t==i?2:1,void(e!=r||t!=s||!o.contentLost&&o.dom.parentNode==this.contentDOM?o.markDirty(e-r,t-r):o.dirty=3);o.dirty=o.dom!=o.contentDOM||o.dom.parentNode!=this.contentDOM||o.children.length?3:2}n=i}this.dirty=2}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let n=1==e?2:1;t.dirty<n&&(t.dirty=n)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class ce extends ae{constructor(e,t,n,r){let o,i=t.type.toDOM;if("function"==typeof i&&(i=i(n,()=>o?o.parent?o.parent.posBeforeChild(o):void 0:r)),!t.type.spec.raw){let e=u(i)?i:document.createElement("span");e!=i&&e.appendChild(i),e.hasAttribute("contenteditable")||(e.contentEditable="false"),e.classList.add("ProseMirror-widget")}super(e,[],i,null),this.widget=t,this.widget=t,o=this}matchesWidget(e){return 0==this.dirty&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return!!t&&t(e)}ignoreMutation(e){return"selection"!=e.type||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}}class he extends ae{constructor(e,t,n,r){super(e,[],t,null),this.textDOM=n,this.text=r}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"characterData"===e.type&&e.target.nodeValue==e.oldValue}}class de extends ae{constructor(e,t,n,r,o){super(e,[],n,r),this.mark=t,this.spec=o}static create(e,t,n,r){let i=r.nodeViews[t.type.name],s=i&&i(t,r,n);return s&&s.dom||(s=o.ZF.renderSpec(document,t.type.spec.toDOM(t,n),null,t.attrs)),new de(e,t,s.dom,s.contentDOM||s.dom,s)}parseRule(){return 3&this.dirty||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return 3!=this.dirty&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),0!=this.dirty){let e=this.parent;for(;!e.node;)e=e.parent;e.dirty<this.dirty&&(e.dirty=this.dirty),this.dirty=0}}slice(e,t,n){let r=de.create(this.parent,this.mark,!0,n),o=this.children,i=this.size;t<i&&(o=De(o,t,i,n)),e>0&&(o=De(o,0,e,n));for(let e=0;e<o.length;e++)o[e].parent=r;return r.children=o,r}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class pe extends ae{constructor(e,t,n,r,o,i,s){super(e,[],o,i),this.node=t,this.outerDeco=n,this.innerDeco=r,this.nodeDOM=s}static create(e,t,n,r,i,s){let l,a=i.nodeViews[t.type.name],c=a&&a(t,i,()=>l?l.parent?l.parent.posBeforeChild(l):void 0:s,n,r),h=c&&c.dom,d=c&&c.contentDOM;if(t.isText)if(h){if(!m(h))throw new RangeError("Text must be rendered as a DOM text node")}else h=document.createTextNode(t.text);else if(!h){let e=o.ZF.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs);({dom:h,contentDOM:d}=e)}d||t.isText||"BR"==h.nodeName||(h.hasAttribute("contenteditable")||(h.contentEditable="false"),t.type.spec.draggable&&(h.draggable=!0));let p=h;return h=ke(h,n,t),c?l=new ge(e,t,n,r,h,d||null,p,c):t.isText?new ue(e,t,n,r,h,p):new pe(e,t,n,r,h,d||null,p)}parseRule(e){if(this.node.type.spec.reparseInView)return null;let t={node:this.node.type.name,attrs:this.node.attrs};if("pre"==this.node.type.whitespace&&(t.preserveWhitespace="full"),this.contentDOM)if(this.contentLost){for(let e=this.children.length-1;e>=0;e--){let n=this.children[e];if(this.dom.contains(n.dom.parentNode)){t.contentElement=n.dom.parentNode;break}}if(!t.contentElement){let n=e&&e.find(t=>u(t)&&e.indexOf(t.parentNode)<0&&this.dom.contains(t));n?t.contentElement=n:t.getContent=()=>o.FK.empty}}else t.contentElement=this.contentDOM;else t.getContent=()=>this.node.content;return t}matchesNode(e,t,n){return 0==this.dirty&&e.eq(this.node)&&Ce(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,r=t,i=e.composing?this.localCompositionInfo(e,t):null,s=i&&i.pos>-1?i:null,l=i&&i.pos<0,a=new Ne(this,s&&s.node,e),c=this.node.inlineContent,h=c&&this.node.isBlock;!function(e,t,n,r){let o=t.locals(e),i=0;if(0==o.length){for(let n=0;n<e.childCount;n++){let s=e.child(n);r(s,o,t.forChild(i,s),n),i+=s.nodeSize}return}let s=0,l=[],a=null;for(let c=0;;){let h,d,p,f;for(;s<o.length&&o[s].to==i;){let e=o[s++];e.widget&&(h?(d||(d=[h])).push(e):h=e)}if(h)if(d){d.sort(Oe);for(let e=0;e<d.length;e++)n(d[e],c,!!a)}else n(h,c,!!a);if(a)f=-1,p=a,a=null;else{if(!(c<e.childCount))break;f=c,p=e.child(c++)}for(let e=0;e<l.length;e++)l[e].to<=i&&l.splice(e--,1);for(;s<o.length&&o[s].from<=i&&o[s].to>i;)l.push(o[s++]);let u=i+p.nodeSize;if(p.isText){let e=u;s<o.length&&o[s].from<e&&(e=o[s].from);for(let t=0;t<l.length;t++)l[t].to<e&&(e=l[t].to);e<u&&(a=p.cut(e-i),p=p.cut(0,e-i),u=e,f=-1)}else for(;s<o.length&&o[s].to<u;)s++;r(p,p.isInline&&!p.isLeaf?l.filter(e=>!e.inline):l.slice(),t.forChild(i,p),f),i=u}}(this.node,this.innerDeco,(t,i,s)=>{t.spec.marks?a.syncToMarks(t.spec.marks,n,e,i):t.type.side>=0&&!s&&a.syncToMarks(i==this.node.childCount?o.CU.none:this.node.child(i).marks,n,e,i),a.placeWidget(t,e,r)},(t,o,s,d)=>{let p;a.syncToMarks(t.marks,n,e,d),h&&t.isAtom&&!t.isText&&a.addHackNode("IMG",a.top),a.findNodeMatch(t,o,s,d)||l&&e.state.selection.from>r&&e.state.selection.to<r+t.nodeSize&&(p=a.findIndexWithChild(i.node))>-1&&a.updateNodeAt(t,o,s,p,e)||a.updateNextNode(t,o,s,e,d,r)||a.addNode(t,o,s,e,r),r+=t.nodeSize,c&&(h=t.isAtom&&!t.isText)}),a.syncToMarks([],n,e,0),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||2==this.dirty)&&(s&&this.protectLocalComposition(e,s),we(this.contentDOM,this.children,e),I&&function(e){if("UL"==e.nodeName||"OL"==e.nodeName){let t=e.style.cssText;e.style.cssText=t+"; list-style: square !important",window.getComputedStyle(e).listStyle,e.style.cssText=t}}(this.dom))}localCompositionInfo(e,t){let{from:n,to:o}=e.state.selection;if(!(e.state.selection instanceof r.U3)||n<t||o>t+this.node.content.size)return null;let i=e.input.compositionNode;if(!i||!this.dom.contains(i.parentNode))return null;if(this.node.inlineContent){let e=i.nodeValue,r=function(e,t,n,r){for(let o=0,i=0;o<e.childCount&&i<=r;){let s=e.child(o++),l=i;if(i+=s.nodeSize,!s.isText)continue;let a=s.text;for(;o<e.childCount;){let t=e.child(o++);if(i+=t.nodeSize,!t.isText)break;a+=t.text}if(i>=n){if(i>=r&&a.slice(r-t.length-l,r-l)==t)return r-t.length;let e=l<r?a.lastIndexOf(t,r-l-1):-1;if(e>=0&&e+t.length+l>=n)return l+e;if(n==r&&a.length>=r+t.length-l&&a.slice(r-l,r-l+t.length)==t)return r}}return-1}(this.node.content,e,n-t,o-t);return r<0?null:{node:i,pos:r,text:e}}return{node:i,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:n,text:r}){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 i=new he(this,o,t,r);e.input.compositionNodes.push(i),this.children=De(this.children,n,n+r.length,e,i)}update(e,t,n,r){return!(3==this.dirty||!e.sameMarkup(this.node))&&(this.updateInner(e,t,n,r),!0)}updateInner(e,t,n,r){this.updateOuterDeco(t),this.node=e,this.innerDeco=n,this.contentDOM&&this.updateChildren(r,this.posAtStart),this.dirty=0}updateOuterDeco(e){if(Ce(e,this.outerDeco))return;let t=!u(this.nodeDOM),n=this.dom;this.dom=Se(this.dom,this.nodeDOM,be(this.outerDeco,this.node,t),be(e,this.node,t)),this.dom!=n&&(n.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){u(this.nodeDOM)&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),!this.contentDOM&&this.node.type.spec.draggable||(this.nodeDOM.draggable=!0))}deselectNode(){u(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 fe(e,t,n,r,o){ke(r,t,e);let i=new pe(void 0,e,t,n,r,r,r);return i.contentDOM&&i.updateChildren(o,0),i}class ue extends pe{constructor(e,t,n,r,o,i){super(e,t,n,r,o,null,i)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,n,r){return!(3==this.dirty||0!=this.dirty&&!this.inParent()||!e.sameMarkup(this.node))&&(this.updateOuterDeco(t),0==this.dirty&&e.text==this.node.text||e.text==this.nodeDOM.nodeValue||(this.nodeDOM.nodeValue=e.text,r.trackWrites==this.nodeDOM&&(r.trackWrites=null)),this.node=e,this.dirty=0,!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"characterData"!=e.type&&"selection"!=e.type}slice(e,t,n){let r=this.node.cut(e,t),o=document.createTextNode(r.text);return new ue(this.parent,r,this.outerDeco,this.innerDeco,o,o)}markDirty(e,t){super.markDirty(e,t),this.dom==this.nodeDOM||0!=e&&t!=this.nodeDOM.nodeValue.length||(this.dirty=3)}get domAtom(){return!1}isText(e){return this.node.text==e}}class me extends ae{parseRule(){return{ignore:!0}}matchesHack(e){return 0==this.dirty&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return"IMG"==this.dom.nodeName}}class ge extends pe{constructor(e,t,n,r,o,i,s,l){super(e,t,n,r,o,i,s),this.spec=l}update(e,t,n,r){if(3==this.dirty)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,r),o}return!(!this.contentDOM&&!e.isLeaf)&&super.update(e,t,n,r)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,n,r){this.spec.setSelection?this.spec.setSelection(e,t,n.root):super.setSelection(e,t,n,r)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return!!this.spec.stopEvent&&this.spec.stopEvent(e)}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function we(e,t,n){let r=e.firstChild,o=!1;for(let i=0;i<t.length;i++){let s=t[i],l=s.dom;if(l.parentNode==e){for(;l!=r;)r=Me(r),o=!0;r=r.nextSibling}else o=!0,e.insertBefore(l,r);if(s instanceof de){let t=r?r.previousSibling:e.lastChild;we(s.contentDOM,s.children,n),r=t?t.nextSibling:e.firstChild}}for(;r;)r=Me(r),o=!0;o&&n.trackWrites==e&&(n.trackWrites=null)}const ye=function(e){e&&(this.nodeName=e)};ye.prototype=Object.create(null);const ve=[new ye];function be(e,t,n){if(0==e.length)return ve;let r=n?ve[0]:new ye,o=[r];for(let i=0;i<e.length;i++){let s=e[i].type.attrs;if(s){s.nodeName&&o.push(r=new ye(s.nodeName));for(let e in s){let i=s[e];null!=i&&(n&&1==o.length&&o.push(r=new ye(t.isInline?"span":"div")),"class"==e?r.class=(r.class?r.class+" ":"")+i:"style"==e?r.style=(r.style?r.style+";":"")+i:"nodeName"!=e&&(r[e]=i))}}}return o}function Se(e,t,n,r){if(n==ve&&r==ve)return t;let o=t;for(let t=0;t<r.length;t++){let i=r[t],s=n[t];if(t){let t;s&&s.nodeName==i.nodeName&&o!=e&&(t=o.parentNode)&&t.nodeName.toLowerCase()==i.nodeName||(t=document.createElement(i.nodeName),t.pmIsDeco=!0,t.appendChild(o),s=ve[0]),o=t}xe(o,s||ve[0],i)}return o}function xe(e,t,n){for(let r in t)"class"==r||"style"==r||"nodeName"==r||r in n||e.removeAttribute(r);for(let r in n)"class"!=r&&"style"!=r&&"nodeName"!=r&&n[r]!=t[r]&&e.setAttribute(r,n[r]);if(t.class!=n.class){let r=t.class?t.class.split(" ").filter(Boolean):[],o=n.class?n.class.split(" ").filter(Boolean):[];for(let t=0;t<r.length;t++)-1==o.indexOf(r[t])&&e.classList.remove(r[t]);for(let t=0;t<o.length;t++)-1==r.indexOf(o[t])&&e.classList.add(o[t]);0==e.classList.length&&e.removeAttribute("class")}if(t.style!=n.style){if(t.style){let n,r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g;for(;n=r.exec(t.style);)e.style.removeProperty(n[1])}n.style&&(e.style.cssText+=n.style)}}function ke(e,t,n){return Se(e,e,ve,be(t,n,!u(e)))}function Ce(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].type.eq(t[n].type))return!1;return!0}function Me(e){let t=e.nextSibling;return e.parentNode.removeChild(e),t}class Ne{constructor(e,t,n){this.lock=t,this.view=n,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=function(e,t){let n=t,r=n.children.length,o=e.childCount,i=new Map,s=[];e:for(;o>0;){let l;for(;;)if(r){let e=n.children[r-1];if(!(e instanceof de)){l=e,r--;break}n=e,r=e.children.length}else{if(n==t)break e;r=n.parent.children.indexOf(n),n=n.parent}let a=l.node;if(a){if(a!=e.child(o-1))break;--o,i.set(l,o),s.push(l)}}return{index:o,matched:i,matches:s.reverse()}}(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,r){let o=0,i=this.stack.length>>1,s=Math.min(i,e.length);for(;o<s&&(o==i-1?this.top:this.stack[o+1<<1]).matchesMark(e[o])&&!1!==e[o].type.spec.spanning;)o++;for(;o<i;)this.destroyRest(),this.top.dirty=0,this.index=this.stack.pop(),this.top=this.stack.pop(),i--;for(;i<e.length;){this.stack.push(this.top,this.index+1);let o=-1,s=this.top.children.length;r<this.preMatch.index&&(s=Math.min(this.index+3,s));for(let t=this.index;t<s;t++){let n=this.top.children[t];if(n.matchesMark(e[i])&&!this.isLocked(n.dom)){o=t;break}}if(o<0&&this.index<this.top.children.length){let t=this.top.children[this.index];t instanceof de&&3!=t.dirty&&t.mark.type==e[i].type&&t.spec.update&&!this.isLocked(t.dom)&&t.spec.update(e[i])&&(t.mark=e[i],o=this.index,this.changed=!0)}if(o>-1)o>this.index&&(this.changed=!0,this.destroyBetween(this.index,o)),this.top=this.top.children[this.index];else{let r=de.create(this.top,e[i],t,n);this.top.children.splice(this.index,0,r),this.top=r,this.changed=!0}this.index=0,i++}}findNodeMatch(e,t,n,r){let o,i=-1;if(r>=this.preMatch.index&&(o=this.preMatch.matches[r-this.preMatch.index]).parent==this.top&&o.matchesNode(e,t,n))i=this.top.children.indexOf(o,this.index);else for(let r=this.index,o=Math.min(this.top.children.length,r+5);r<o;r++){let o=this.top.children[r];if(o.matchesNode(e,t,n)&&!this.preMatch.matched.has(o)){i=r;break}}return!(i<0)&&(this.destroyBetween(this.index,i),this.index++,!0)}updateNodeAt(e,t,n,r,o){let i=this.top.children[r];return 3==i.dirty&&i.dom==i.contentDOM&&(i.dirty=2),!!i.update(e,t,n,o)&&(this.destroyBetween(this.index,r),this.index++,!0)}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){let t=e.pmViewDesc;if(t)for(let e=this.index;e<this.top.children.length;e++)if(this.top.children[e]==t)return e;return-1}e=t}}updateNextNode(e,t,n,r,o,i){for(let s=this.index;s<this.top.children.length;s++){let l=this.top.children[s];if(l instanceof pe){let a=this.preMatch.matched.get(l);if(null!=a&&a!=o)return!1;let c,h=l.dom,d=this.isLocked(h)&&!(e.isText&&l.node&&l.node.isText&&l.nodeDOM.nodeValue==e.text&&3!=l.dirty&&Ce(t,l.outerDeco));if(!d&&l.update(e,t,n,r))return this.destroyBetween(this.index,s),l.dom!=h&&(this.changed=!0),this.index++,!0;if(!d&&(c=this.recreateWrapper(l,e,t,n,r,i)))return this.destroyBetween(this.index,s),this.top.children[this.index]=c,c.contentDOM&&(c.dirty=2,c.updateChildren(r,i+1),c.dirty=0),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,n,r,o,i){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!Ce(n,e.outerDeco)||!r.eq(e.innerDeco))return null;let s=pe.create(this.top,t,n,r,o,i);if(s.contentDOM){s.children=e.children,e.children=[];for(let e of s.children)e.parent=s}return e.destroy(),s}addNode(e,t,n,r,o){let i=pe.create(this.top,e,t,n,r,o);i.contentDOM&&i.updateChildren(r,o+1),this.top.children.splice(this.index++,0,i),this.changed=!0}placeWidget(e,t,n){let r=this.index<this.top.children.length?this.top.children[this.index]:null;if(!r||!r.matchesWidget(e)||e!=r.widget&&r.widget.type.toDOM.parentNode){let r=new ce(this.top,e,t,n);this.top.children.splice(this.index++,0,r),this.changed=!0}else this.index++}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof de;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof ue)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((R||T)&&e&&"false"==e.dom.contentEditable&&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);"IMG"==e&&(n.className="ProseMirror-separator",n.alt=""),"BR"==e&&(n.className="ProseMirror-trailingBreak");let r=new me(this.top,[],n,null);t!=this.top?t.children.push(r):t.children.splice(this.index++,0,r),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||u(e)&&e.contains(this.lock.parentNode))}}function Oe(e,t){return e.type.side-t.type.side}function De(e,t,n,r,o){let i=[];for(let s=0,l=0;s<e.length;s++){let a=e[s],c=l,h=l+=a.size;c>=n||h<=t?i.push(a):(c<t&&i.push(a.slice(0,t-c,r)),o&&(i.push(o),o=void 0),h>n&&i.push(a.slice(n-c,a.size,r)))}return i}function Ae(e,t=null){let n=e.domSelectionRange(),o=e.state.doc;if(!n.focusNode)return null;let i=e.docView.nearestDesc(n.focusNode),l=i&&0==i.size,a=e.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(a<0)return null;let c,h,d=o.resolve(a);if(y(n)){for(c=a;i&&!i.node;)i=i.parent;if(!(i&&i.node.isAtom&&r.nh.isSelectable(i.node)&&i.parent)||i.node.isInline&&function(e,t,n){for(let r=0==t,o=t==f(e);r||o;){if(e==n)return!0;let t=s(e);if(!(e=e.parentNode))return!1;r=r&&0==t,o=o&&t==f(e)}}(n.focusNode,n.focusOffset,i.dom)){if(D&&"key"==t&&a>e.state.selection.to&&u(n.focusNode)&&n.focusOffset==n.focusNode.childNodes.length&&i&&i.posAtStart>e.state.selection.to)for(let e=n.focusNode;;e=e.parentNode){if("visible"!=getComputedStyle(e).overflow){h=r.LN.findFrom(o.resolve(i.posAtStart),1);break}if(e==i.dom||e.nextSibling||!e.parentNode||!u(e.parentNode))break}}else{let e=i.posBefore;h=new r.nh(a==e?d:o.resolve(e))}}else{if(n instanceof e.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let t=a,r=a;for(let o=0;o<n.rangeCount;o++){let i=n.getRangeAt(o);t=Math.min(t,e.docView.posFromDOM(i.startContainer,i.startOffset,1)),r=Math.max(r,e.docView.posFromDOM(i.endContainer,i.endOffset,-1))}if(t<0)return null;[c,a]=r==e.state.selection.anchor?[r,t]:[t,r],d=o.resolve(a)}else c=e.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(c<0)return null}let p=o.resolve(c);if(!h){h=Be(e,p,d,"pointer"==t||e.state.selection.head<d.pos&&!l?1:-1)}return h}function Te(e){return e.editable?e.hasFocus():Le(e)&&document.activeElement&&document.activeElement.contains(e.dom)}function Ee(e,t=!1){let n=e.state.selection;if(Fe(e,n),!Te(e))return;let o=e.input.mouseDown;if(!t&&T&&o){let t=e.domSelectionRange(),n=e.domObserver.currentSelection;if(t.anchorNode&&n.anchorNode&&h(t.anchorNode,t.anchorOffset,n.anchorNode,n.anchorOffset)&&o.delaySelUpdate())return void e.domObserver.setCurSelection()}if(e.domObserver.disconnectSelection(),e.cursorWrapper)!function(e){let t=e.domSelection();if(!t)return;let n=e.cursorWrapper.dom,r="IMG"==n.nodeName;r?t.collapse(n.parentNode,s(n)+1):t.collapse(n,0);!r&&!e.state.selection.visible&&N&&O<=11&&(n.disabled=!0,n.disabled=!1)}(e);else{let o,i,{anchor:s,head:l}=n;!Re||n instanceof r.U3||(n.$from.parent.inlineContent||(o=Ie(e,n.from)),n.empty||n.$from.parent.inlineContent||(i=Ie(e,n.to))),e.docView.setSelection(s,l,e,t),Re&&(o&&$e(o),i&&$e(i)),n.visible?e.dom.classList.remove("ProseMirror-hideselection"):(e.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&function(e){let t=e.dom.ownerDocument;t.removeEventListener("selectionchange",e.input.hideSelectionGuard);let n=e.domSelectionRange(),r=n.anchorNode,o=n.anchorOffset;t.addEventListener("selectionchange",e.input.hideSelectionGuard=()=>{n.anchorNode==r&&n.anchorOffset==o||(t.removeEventListener("selectionchange",e.input.hideSelectionGuard),setTimeout(()=>{Te(e)&&!e.state.selection.visible||e.dom.classList.remove("ProseMirror-hideselection")},20))})}(e))}e.domObserver.setCurSelection(),e.domObserver.connectSelection()}const Re=R||T&&E<63;function Ie(e,t){let{node:n,offset:r}=e.docView.domFromPos(t,0),o=r<n.childNodes.length?n.childNodes[r]:null,i=r?n.childNodes[r-1]:null;if(R&&o&&"false"==o.contentEditable)return ze(o);if(!(o&&"false"!=o.contentEditable||i&&"false"!=i.contentEditable)){if(o)return ze(o);if(i)return ze(i)}}function ze(e){return e.contentEditable="true",R&&e.draggable&&(e.draggable=!1,e.wasDraggable=!0),e}function $e(e){e.contentEditable="false",e.wasDraggable&&(e.draggable=!0,e.wasDraggable=null)}function Fe(e,t){if(t instanceof r.nh){let n=e.docView.descAt(t.from);n!=e.lastSelectedViewDesc&&(Pe(e),n&&n.selectNode(),e.lastSelectedViewDesc=n)}else Pe(e)}function Pe(e){e.lastSelectedViewDesc&&(e.lastSelectedViewDesc.parent&&e.lastSelectedViewDesc.deselectNode(),e.lastSelectedViewDesc=void 0)}function Be(e,t,n,o){return e.someProp("createSelectionBetween",r=>r(e,t,n))||r.U3.between(t,n,o)}function Ve(e){return!(e.editable&&!e.hasFocus())&&Le(e)}function Le(e){let t=e.domSelectionRange();if(!t.anchorNode)return!1;try{return g(e.dom,t.anchorNode)&&(e.editable||g(e.dom,t.focusNode))}catch(e){return!1}}function Je(e,t){let{$anchor:n,$head:o}=e.selection,i=t>0?n.max(o):n.min(o),s=i.parent.inlineContent?i.depth?e.doc.resolve(t>0?i.after():i.before()):null:i;return s&&r.LN.findFrom(s,t)}function Ke(e,t){return e.dispatch(e.state.tr.setSelection(t).scrollIntoView()),!0}function We(e,t,n){let o=e.state.selection;if(!(o instanceof r.U3)){if(o instanceof r.nh&&o.node.isInline)return Ke(e,new r.U3(t>0?o.$to:o.$from));{let n=Je(e.state,t);return!!n&&Ke(e,n)}}if(n.indexOf("s")>-1){let{$head:n}=o,i=n.textOffset?null:t<0?n.nodeBefore:n.nodeAfter;if(!i||i.isText||!i.isLeaf)return!1;let s=e.state.doc.resolve(n.pos+i.nodeSize*(t<0?-1:1));return Ke(e,new r.U3(o.$anchor,s))}if(!o.empty)return!1;if(e.endOfTextblock(t>0?"forward":"backward")){let n=Je(e.state,t);return!!(n&&n instanceof r.nh)&&Ke(e,n)}if(!(z&&n.indexOf("m")>-1)){let n,i=o.$head,s=i.textOffset?null:t<0?i.nodeBefore:i.nodeAfter;if(!s||s.isText)return!1;let l=t<0?i.pos-s.nodeSize:i.pos;return!!(s.isAtom||(n=e.docView.descAt(l))&&!n.contentDOM)&&(r.nh.isSelectable(s)?Ke(e,new r.nh(t<0?e.state.doc.resolve(i.pos-s.nodeSize):i)):Ke(e,new r.U3(e.state.doc.resolve(t<0?l:l+s.nodeSize))))}}function _e(e,t){let n=e.pmViewDesc;return n?0==n.size&&(t<0||e.nextSibling||"BR"!=e.nodeName):u(e)&&"false"==e.contentEditable}function qe(e,t){return t<0?function(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let o,i,l=!1;D&&u(n)&&r<f(n)&&_e(n.childNodes[r],-1)&&(l=!0);for(;;)if(r>0){if(!u(n))break;let e=n.childNodes[r-1];if(_e(e,-1))o=n,i=--r;else{if(!m(e))break;n=e,r=n.nodeValue.length}}else{if(je(n))break;{let t=n.previousSibling;for(;t&&_e(t,-1);)o=n.parentNode,i=s(t),t=t.previousSibling;if(t)n=t,r=f(n);else{if(n=n.parentNode,n==e.dom)break;r=0}}}l?Ue(e,n,r):o&&Ue(e,o,i)}(e):function(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let o,i,l=f(n);for(;;)if(r<l){if(!u(n))break;if(!_e(n.childNodes[r],1))break;o=n,i=++r}else{if(je(n))break;{let t=n.nextSibling;for(;t&&_e(t,1);)o=t.parentNode,i=s(t)+1,t=t.nextSibling;if(t)n=t,r=0,l=f(n);else{if(n=n.parentNode,n==e.dom)break;r=l=0}}}o&&Ue(e,o,i)}(e)}function je(e){let t=e.pmViewDesc;return t&&t.node&&t.node.isBlock}function Ue(e,t,n){if(!m(t)){let e,r;(r=function(e,t){for(;e&&t==e.childNodes.length&&!w(e);)t=s(e)+1,e=e.parentNode;for(;e&&t<e.childNodes.length;){let n=e.childNodes[t];if(m(n))return n;if(u(n)&&"false"==n.contentEditable)break;e=n,t=0}}(t,n))?(t=r,n=0):(e=function(e,t){for(;e&&!t&&!w(e);)t=s(e),e=e.parentNode;for(;e&&t;){let n=e.childNodes[t-1];if(m(n))return n;if(u(n)&&"false"==n.contentEditable)break;t=(e=n).childNodes.length}}(t,n))&&(t=e,n=e.nodeValue.length)}let r=e.domSelection();if(!r)return;if(y(r)){let e=document.createRange();e.setEnd(t,n),e.setStart(t,n),r.removeAllRanges(),r.addRange(e)}else r.extend&&r.extend(t,n);e.domObserver.setCurSelection();let{state:o}=e;setTimeout(()=>{e.state==o&&Ee(e)},50)}function He(e,t){let n=e.state.doc.resolve(t);if(!T&&!$&&n.parent.inlineContent){let r=e.coordsAtPos(t);if(t>n.start()){let n=e.coordsAtPos(t-1),o=(n.top+n.bottom)/2;if(o>r.top&&o<r.bottom&&Math.abs(n.left-r.left)>1)return n.left<r.left?"ltr":"rtl"}if(t<n.end()){let n=e.coordsAtPos(t+1),o=(n.top+n.bottom)/2;if(o>r.top&&o<r.bottom&&Math.abs(n.left-r.left)>1)return n.left>r.left?"ltr":"rtl"}}return"rtl"==getComputedStyle(e.dom).direction?"rtl":"ltr"}function Ge(e,t,n){let o=e.state.selection;if(o instanceof r.U3&&!o.empty||n.indexOf("s")>-1)return!1;if(z&&n.indexOf("m")>-1)return!1;let{$from:i,$to:s}=o;if(!i.parent.inlineContent||e.endOfTextblock(t<0?"up":"down")){let n=Je(e.state,t);if(n&&n instanceof r.nh)return Ke(e,n)}if(!i.parent.inlineContent){let n=t<0?i:s,l=o instanceof r.i5?r.LN.near(n,t):r.LN.findFrom(n,t);return!!l&&Ke(e,l)}return!1}function Xe(e,t){if(!(e.state.selection instanceof r.U3))return!0;let{$head:n,$anchor:o,empty:i}=e.state.selection;if(!n.sameParent(o))return!0;if(!i)return!1;if(e.endOfTextblock(t>0?"forward":"backward"))return!0;let s=!n.textOffset&&(t<0?n.nodeBefore:n.nodeAfter);if(s&&!s.isText){let r=e.state.tr;return t<0?r.delete(n.pos-s.nodeSize,n.pos):r.delete(n.pos,n.pos+s.nodeSize),e.dispatch(r),!0}return!1}function Ze(e,t,n){e.domObserver.stop(),t.contentEditable=n,e.domObserver.start()}function Ye(e,t){let n=t.keyCode,r=function(e){let t="";return e.ctrlKey&&(t+="c"),e.metaKey&&(t+="m"),e.altKey&&(t+="a"),e.shiftKey&&(t+="s"),t}(t);if(8==n||z&&72==n&&"c"==r)return Xe(e,-1)||qe(e,-1);if(46==n&&!t.shiftKey||z&&68==n&&"c"==r)return Xe(e,1)||qe(e,1);if(13==n||27==n)return!0;if(37==n||z&&66==n&&"c"==r){let t=37==n?"ltr"==He(e,e.state.selection.from)?-1:1:-1;return We(e,t,r)||qe(e,t)}if(39==n||z&&70==n&&"c"==r){let t=39==n?"ltr"==He(e,e.state.selection.from)?1:-1:1;return We(e,t,r)||qe(e,t)}return 38==n||z&&80==n&&"c"==r?Ge(e,-1,r)||qe(e,-1):40==n||z&&78==n&&"c"==r?function(e){if(!R||e.state.selection.$head.parentOffset>0)return!1;let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(t&&u(t)&&0==n&&t.firstChild&&u(t.firstChild)&&"false"==t.firstChild.contentEditable){let n=t.firstChild;Ze(e,n,"true"),setTimeout(()=>Ze(e,n,"false"),20)}return!1}(e)||Ge(e,1,r)||qe(e,1):r==(z?"m":"c")&&(66==n||73==n||89==n||90==n)}function Qe(e,t){e.someProp("transformCopied",n=>{t=n(t,e)});let n=[],{content:r,openStart:i,openEnd:s}=t;for(;i>1&&s>1&&1==r.childCount&&1==r.firstChild.childCount;){i--,s--;let e=r.firstChild;n.push(e.type.name,e.attrs!=e.type.defaultAttrs?e.attrs:null),r=e.content}let l=e.someProp("clipboardSerializer")||o.ZF.fromSchema(e.state.schema),a=at(),c=a.createElement("div");c.appendChild(l.serializeFragment(r,{document:a}));let h,d=c.firstChild,p=0;for(;d&&u(d)&&(h=lt[d.nodeName.toLowerCase()]);){for(let e=h.length-1;e>=0;e--){let t=a.createElement(h[e]);for(;c.firstChild;)t.appendChild(c.firstChild);c.appendChild(t),p++}d=c.firstChild}return d&&u(d)&&d.setAttribute("data-pm-slice",`${i} ${s}${p?` -${p}`:""} ${JSON.stringify(n)}`),{dom:c,text:e.someProp("clipboardTextSerializer",n=>n(t,e))||t.content.textBetween(0,t.content.size,"\n\n"),slice:t}}function et(e,t,n,r,i){let s,l,a=i.parent.type.spec.code;if(!n&&!t)return null;let c=!!t&&(r||a||!n);if(c){if(e.someProp("transformPastedText",n=>{t=n(t,a||r,e)}),a)return l=new o.Ji(o.FK.from(e.state.schema.text(t.replace(/\r\n?/g,"\n"))),0,0),e.someProp("transformPasted",t=>{l=t(l,e,!0)}),l;let n=e.someProp("clipboardTextParser",n=>n(t,i,r,e));if(n)l=n;else{let n=i.marks(),{schema:r}=e.state,l=o.ZF.fromSchema(r);s=document.createElement("div"),t.split(/(?:\r\n?|\n)+/).forEach(e=>{let t=s.appendChild(document.createElement("p"));e&&t.appendChild(l.serializeNode(r.text(e,n)))})}}else e.someProp("transformPastedHTML",t=>{n=t(n,e)}),s=function(e){let t=/^(\s*<meta [^>]*>)*/.exec(e);t&&(e=e.slice(t[0].length));let n,r=at(),o=r.body,i=/<([a-z][^>\s]+)/i.exec(e);(n=i&&lt[i[1].toLowerCase()])&&(e=n.map(e=>"<"+e+">").join("")+e+n.map(e=>"</"+e+">").reverse().join(""));if(o.innerHTML=function(e){let t=window.trustedTypes;if(!t)return e;if(!ct){if(ct=t.defaultPolicy)try{return ct.createHTML(e)}catch(e){}ct=t.createPolicy("ProseMirrorClipboard",{createHTML:e=>e})}return ct.createHTML(e)}(e),n)for(let e=0;e<n.length;e++)o=o.querySelector(n[e])||o;for(let e=0;e<r.styleSheets.length;e++){let t=r.styleSheets[e];for(let e=0;e<t.rules.length;e++){let n=t.rules[e];if(n instanceof CSSStyleRule){let e=o.querySelectorAll(n.selectorText);for(let t=0;t<e.length;t++)e[t].style.cssText+=n.style.cssText}}}return o}(n),P&&function(e){let t=e.querySelectorAll(T?"span:not([class]):not([style])":"span.Apple-converted-space");for(let n=0;n<t.length;n++){let r=t[n];1==r.childNodes.length&&" "==r.textContent&&r.parentNode&&r.parentNode.replaceChild(e.ownerDocument.createTextNode(" "),r)}}(s);let h=s&&s.querySelector("[data-pm-slice]"),d=h&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(h.getAttribute("data-pm-slice")||"");if(d&&d[3])for(let e=+d[3];e>0;e--){let e=s.firstChild;for(;e&&!u(e);)e=e.nextSibling;if(!e)break;s=e}if(!l){let t=e.someProp("clipboardParser")||e.someProp("domParser")||o.S4.fromSchema(e.state.schema);l=t.parseSlice(s,{preserveWhitespace:!(!c&&!d),context:i,ruleFromNode:e=>"BR"!=e.nodeName||e.nextSibling||!e.parentNode||tt.test(e.parentNode.nodeName)?null:{ignore:!0}})}if(d)l=function(e,t){if(!e.size)return e;let n,r=e.content.firstChild.type.schema;try{n=JSON.parse(t)}catch(t){return e}let{content:i,openStart:s,openEnd:l}=e;for(let e=n.length-2;e>=0;e-=2){let t=r.nodes[n[e]];if(!t||t.hasRequiredAttrs())break;try{i=o.FK.from(t.create(n[e+1],i))}catch(e){break}s++,l++}return new o.Ji(i,s,l)}(st(l,+d[1],+d[2]),d[4]);else if(l=o.Ji.maxOpen(function(e,t){if(e.childCount<2)return e;for(let n=t.depth;n>=0;n--){let r,i=t.node(n).contentMatchAt(t.index(n)),s=[];if(e.forEach(e=>{if(!s)return;let t,n=i.findWrapping(e.type);if(!n)return s=null;if(t=s.length&&r.length&&rt(n,r,e,s[s.length-1],0))s[s.length-1]=t;else{s.length&&(s[s.length-1]=ot(s[s.length-1],r.length));let t=nt(e,n);s.push(t),i=i.matchType(t.type),r=n}}),s)return o.FK.from(s)}return e}(l.content,i),!0),l.openStart||l.openEnd){let e=0,t=0;for(let t=l.content.firstChild;e<l.openStart&&!t.type.spec.isolating;e++,t=t.firstChild);for(let e=l.content.lastChild;t<l.openEnd&&!e.type.spec.isolating;t++,e=e.lastChild);l=st(l,e,t)}return e.someProp("transformPasted",t=>{l=t(l,e,c)}),l}const tt=/^(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 nt(e,t,n=0){for(let r=t.length-1;r>=n;r--)e=t[r].create(null,o.FK.from(e));return e}function rt(e,t,n,r,i){if(i<e.length&&i<t.length&&e[i]==t[i]){let s=rt(e,t,n,r.lastChild,i+1);if(s)return r.copy(r.content.replaceChild(r.childCount-1,s));if(r.contentMatchAt(r.childCount).matchType(i==e.length-1?n.type:e[i+1]))return r.copy(r.content.append(o.FK.from(nt(n,e,i+1))))}}function ot(e,t){if(0==t)return e;let n=e.content.replaceChild(e.childCount-1,ot(e.lastChild,t-1)),r=e.contentMatchAt(e.childCount).fillBefore(o.FK.empty,!0);return e.copy(n.append(r))}function it(e,t,n,r,i,s){let l=t<0?e.firstChild:e.lastChild,a=l.content;return e.childCount>1&&(s=0),i<r-1&&(a=it(a,t,n,r,i+1,s)),i>=n&&(a=t<0?l.contentMatchAt(0).fillBefore(a,s<=i).append(a):a.append(l.contentMatchAt(l.childCount).fillBefore(o.FK.empty,!0))),e.replaceChild(t<0?0:e.childCount-1,l.copy(a))}function st(e,t,n){return t<e.openStart&&(e=new o.Ji(it(e.content,-1,t,e.openStart,0,e.openEnd),t,e.openEnd)),n<e.openEnd&&(e=new o.Ji(it(e.content,1,n,e.openEnd,0,0),e.openStart,n)),e}const lt={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 at(){return document.implementation.createHTMLDocument("title")}let ct=null;const ht={},dt={},pt={touchstart:!0,touchmove:!0};class ft{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:"",button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!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 ut(e,t){e.input.lastSelectionOrigin=t,e.input.lastSelectionTime=Date.now()}function mt(e){e.someProp("handleDOMEvents",t=>{for(let n in t)e.input.eventHandlers[n]||e.dom.addEventListener(n,e.input.eventHandlers[n]=t=>gt(e,t))})}function gt(e,t){return e.someProp("handleDOMEvents",n=>{let r=n[t.type];return!!r&&(r(e,t)||t.defaultPrevented)})}function wt(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let n=t.target;n!=e.dom;n=n.parentNode)if(!n||11==n.nodeType||n.pmViewDesc&&n.pmViewDesc.stopEvent(t))return!1;return!0}function yt(e){return{left:e.clientX,top:e.clientY}}function vt(e,t,n,r,o){if(-1==r)return!1;let i=e.state.doc.resolve(r);for(let r=i.depth+1;r>0;r--)if(e.someProp(t,t=>r>i.depth?t(e,n,i.nodeAfter,i.before(r),o,!0):t(e,n,i.node(r),i.before(r),o,!1)))return!0;return!1}function bt(e,t,n){if(e.focused||e.focus(),e.state.selection.eq(t))return;let r=e.state.tr.setSelection(t);r.setMeta("pointer",!0),e.dispatch(r)}function St(e,t,n,o,i){return vt(e,"handleClickOn",t,n,o)||e.someProp("handleClick",n=>n(e,t,o))||(i?function(e,t){if(-1==t)return!1;let n,o,i=e.state.selection;i instanceof r.nh&&(n=i.node);let s=e.state.doc.resolve(t);for(let e=s.depth+1;e>0;e--){let t=e>s.depth?s.nodeAfter:s.node(e);if(r.nh.isSelectable(t)){o=n&&i.$from.depth>0&&e>=i.$from.depth&&s.before(i.$from.depth+1)==i.$from.pos?s.before(i.$from.depth):s.before(e);break}}return null!=o&&(bt(e,r.nh.create(e.state.doc,o)),!0)}(e,n):function(e,t){if(-1==t)return!1;let n=e.state.doc.resolve(t),o=n.nodeAfter;return!!(o&&o.isAtom&&r.nh.isSelectable(o))&&(bt(e,new r.nh(n)),!0)}(e,n))}function xt(e,t,n,r){return vt(e,"handleDoubleClickOn",t,n,r)||e.someProp("handleDoubleClick",n=>n(e,t,r))}function kt(e,t,n,o){return vt(e,"handleTripleClickOn",t,n,o)||e.someProp("handleTripleClick",n=>n(e,t,o))||function(e,t,n){if(0!=n.button)return!1;let o=Ct(e,t,!0),i=e.state.doc;if(!o)return!1;bt(e,o),o instanceof r.U3&&i.eq(e.state.doc)&&(e.input.mouseDown=new At(e,o));return!0}(e,n,o)}function Ct(e,t,n){let o=e.state.doc;if(-1==t)return o.inlineContent?r.U3.create(o,0,o.content.size):null;let i=o.resolve(t);for(let e=i.depth+1;e>0;e--){let t=e>i.depth?i.nodeAfter:i.node(e),s=i.before(e);if(t.inlineContent)return r.U3.create(o,s+1,s+1+t.content.size);if(n&&r.nh.isSelectable(t))return r.nh.create(o,s)}return null}function Mt(e){return $t(e)}dt.keydown=(e,t)=>{let n=t;if(e.input.shiftKey=16==n.keyCode||n.shiftKey,!Tt(e)&&(e.input.lastKeyCode=n.keyCode,e.input.lastKeyCodeTime=Date.now(),!F||!T||13!=n.keyCode))if(229!=n.keyCode&&e.domObserver.forceFlush(),!I||13!=n.keyCode||n.ctrlKey||n.altKey||n.metaKey)e.someProp("handleKeyDown",t=>t(e,n))||Ye(e,n)?n.preventDefault():ut(e,"key");else{let t=Date.now();e.input.lastIOSEnter=t,e.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{e.input.lastIOSEnter==t&&(e.someProp("handleKeyDown",t=>t(e,v(13,"Enter"))),e.input.lastIOSEnter=0)},200)}},dt.keyup=(e,t)=>{16==t.keyCode&&(e.input.shiftKey=!1)},dt.keypress=(e,t)=>{let n=t;if(Tt(e)||!n.charCode||n.ctrlKey&&!n.altKey||z&&n.metaKey)return;if(e.someProp("handleKeyPress",t=>t(e,n)))return void n.preventDefault();let o=e.state.selection;if(!(o instanceof r.U3&&o.$from.sameParent(o.$to))){let t=String.fromCharCode(n.charCode),r=()=>e.state.tr.insertText(t).scrollIntoView();/[\r\n]/.test(t)||e.someProp("handleTextInput",n=>n(e,o.$from.pos,o.$to.pos,t,r))||e.dispatch(r()),n.preventDefault()}};const Nt=z?"metaKey":"ctrlKey";ht.mousedown=(e,t)=>{let n=t;e.input.shiftKey=n.shiftKey;let r=Mt(e),o=Date.now(),i="singleClick";o-e.input.lastClick.time<500&&function(e,t){let n=t.x-e.clientX,r=t.y-e.clientY;return n*n+r*r<100}(n,e.input.lastClick)&&!n[Nt]&&e.input.lastClick.button==n.button&&("singleClick"==e.input.lastClick.type?i="doubleClick":"doubleClick"==e.input.lastClick.type&&(i="tripleClick")),e.input.lastClick={time:o,x:n.clientX,y:n.clientY,type:i,button:n.button},e.input.mouseDown&&e.input.mouseDown.done();let s=e.posAtCoords(yt(n));s&&("singleClick"==i?e.input.mouseDown=new Dt(e,s,n,!!r):("doubleClick"==i?xt:kt)(e,s.pos,s.inside,n)?n.preventDefault():ut(e,"pointer"))};class Ot{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){0==e.buttons&&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}}class Dt extends Ot{constructor(e,t,n,o){let i,s;if(super(e),this.pos=t,this.event=n,this.flushed=o,this.delayedSelectionSync=!1,this.startDoc=e.state.doc,this.selectNode=!!n[Nt],this.allowDefault=n.shiftKey,t.inside>-1)i=e.state.doc.nodeAt(t.inside),s=t.inside;else{let n=e.state.doc.resolve(t.pos);i=n.parent,s=n.depth?n.before():0}const l=o?null:n.target,a=l?e.docView.nearestDesc(l,!0):null;this.target=a&&u(a.nodeDOM)?a.nodeDOM:null;let{selection:c}=e.state;0==n.button&&(i.type.spec.draggable&&!1!==i.type.spec.selectable||c instanceof r.nh&&c.from<=s&&c.to>s)&&(this.mightDrag={node:i,pos:s,addAttr:!(!this.target||this.target.draggable),setUneditable:!(!this.target||!D||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()),ut(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?ut(this.view,"pointer"):St(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():0==e.button&&(this.flushed||R&&this.mightDrag&&!this.mightDrag.node.isAtom||T&&!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)?(bt(this.view,r.LN.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):ut(this.view,"pointer")}move(e){this.updateAllowDefault(e),ut(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)}}class At extends Ot{constructor(e,t){super(e),this.startSelection=t,this.startDoc=e.state.doc}move(e){if(0==e.buttons||this.view.isDestroyed||!this.view.state.doc.eq(this.startDoc))return void this.done();e.preventDefault(),ut(this.view,"pointer");let t=this.view.posAtCoords(yt(e)),n=t&&Ct(this.view,t.inside,!1);if(!n)return;let{doc:o}=this.view.state,i=this.startSelection,[s,l]=n.from<i.from?[i.to,n.from]:[i.from,n.to];bt(this.view,r.U3.create(o,s,l))}}function Tt(e,t){return!!e.composing||!!(R&&Math.abs(Date.now()-e.input.compositionEndedAt)<500)&&(e.input.compositionEndedAt=-2e8,!0)}ht.touchstart=e=>{e.input.lastTouch=Date.now(),Mt(e),ut(e,"pointer")},ht.touchmove=e=>{e.input.lastTouch=Date.now(),ut(e,"pointer")},ht.contextmenu=e=>Mt(e);const Et=F?5e3:-1;function Rt(e,t){clearTimeout(e.input.composingTimeout),t>-1&&(e.input.composingTimeout=setTimeout(()=>$t(e),t))}function It(e){for(e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=Date.now());e.input.compositionNodes.length>0;)e.input.compositionNodes.pop().markParentsDirty()}function zt(e){let t=e.domSelectionRange();if(!t.focusNode)return null;let n=function(e,t){for(;;){if(m(e)&&t)return e;if(u(e)&&t>0){if("false"==e.contentEditable)return null;t=f(e=e.childNodes[t-1])}else{if(!e.parentNode||w(e))return null;t=s(e),e=e.parentNode}}}(t.focusNode,t.focusOffset),r=function(e,t){for(;;){if(m(e)&&t<e.nodeValue.length)return e;if(u(e)&&t<e.childNodes.length){if("false"==e.contentEditable)return null;e=e.childNodes[t],t=0}else{if(!e.parentNode||w(e))return null;t=s(e)+1,e=e.parentNode}}}(t.focusNode,t.focusOffset);if(n&&r&&n!=r){let t=r.pmViewDesc,o=e.domObserver.lastChangedTextNode;if(n==o||r==o)return o;if(!t||!t.isText(r.nodeValue))return r;if(e.input.compositionNode==r){let e=n.pmViewDesc;if(e&&e.isText(n.nodeValue))return r}}return n||r}function $t(e,t=!1){if(!(F&&e.domObserver.flushingSoon>=0)){if(e.domObserver.forceFlush(),It(e),t||e.docView&&e.docView.dirty){let n=Ae(e),r=e.state.selection;return n&&!n.eq(r)?e.dispatch(e.state.tr.setSelection(n)):!e.markCursor&&!t||r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?e.updateState(e.state):e.dispatch(e.state.tr.deleteSelection()),!0}return!1}}dt.compositionstart=dt.compositionupdate=e=>{if(!e.composing){e.domObserver.flush();let{state:t}=e,n=t.selection.$to;if(t.selection instanceof r.U3&&t.selection.empty&&(t.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(e=>!1===e.type.spec.inclusive)||T&&$&&function(e){let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(!t||!u(t)||n>=t.childNodes.length)return!1;let r=t.childNodes[n];return u(r)&&"false"==r.contentEditable}(e)))e.markCursor=e.state.storedMarks||n.marks(),$t(e,!0),e.markCursor=null;else if($t(e,!t.selection.empty),D&&t.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let t=e.domSelectionRange();for(let n=t.focusNode,r=t.focusOffset;n&&u(n)&&0!=r;){let t=r<0?n.lastChild:n.childNodes[r-1];if(!t)break;if(m(t)){let n=e.domSelection();n&&n.collapse(t,t.nodeValue.length);break}n=t,r=-1}}e.input.composing=!0}Rt(e,Et)},dt.compositionend=(e,t)=>{e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=Date.now(),e.input.compositionPendingChanges=e.domObserver.pendingRecords().length?e.input.compositionID:0,e.input.compositionNode=null,e.input.badSafariComposition?e.domObserver.forceFlush():e.input.compositionPendingChanges&&Promise.resolve().then(()=>e.domObserver.flush()),e.input.compositionID++,Rt(e,20))};const Ft=N&&O<15||I&&B<604;function Pt(e,t,n,r,i){let s=et(e,t,n,r,e.state.selection.$from);if(e.someProp("handlePaste",t=>t(e,i,s||o.Ji.empty)))return!0;if(!s)return!1;let l=function(e){return 0==e.openStart&&0==e.openEnd&&1==e.content.childCount?e.content.firstChild:null}(s),a=l?e.state.tr.replaceSelectionWith(l,r):e.state.tr.replaceSelection(s);return e.dispatch(a.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Bt(e){let t=e.getData("text/plain")||e.getData("Text");if(t)return t;let n=e.getData("text/uri-list");return n?n.replace(/\r?\n/g," "):""}ht.copy=dt.cut=(e,t)=>{let n=t,r=e.state.selection,o="cut"==n.type;if(r.empty)return;let i=Ft?null:n.clipboardData,s=r.content(),{dom:l,text:a}=Qe(e,s);i?(n.preventDefault(),i.clearData(),i.setData("text/html",l.innerHTML),i.setData("text/plain",a)):function(e,t){if(!e.dom.parentNode)return;let n=e.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(t),n.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),o=document.createRange();o.selectNodeContents(t),e.dom.blur(),r.removeAllRanges(),r.addRange(o),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),e.focus()},50)}(e,l),o&&e.dispatch(e.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))},dt.paste=(e,t)=>{let n=t;if(e.composing&&!F)return;let r=Ft?null:n.clipboardData,o=e.input.shiftKey&&45!=e.input.lastKeyCode;r&&Pt(e,Bt(r),r.getData("text/html"),o,n)?n.preventDefault():function(e,t){if(!e.dom.parentNode)return;let n=e.input.shiftKey||e.state.selection.$from.parent.type.spec.code,r=e.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let o=e.input.shiftKey&&45!=e.input.lastKeyCode;setTimeout(()=>{e.focus(),r.parentNode&&r.parentNode.removeChild(r),n?Pt(e,r.value,null,o,t):Pt(e,r.textContent,r.innerHTML,o,t)},50)}(e,n)};class Vt{constructor(e,t,n){this.slice=e,this.move=t,this.node=n}}const Lt=z?"altKey":"ctrlKey";function Jt(e,t){let n;return e.someProp("dragCopies",e=>{n=n||e(t)}),null!=n?!n:!t[Lt]}ht.dragstart=(e,t)=>{let n=t,o=e.input.mouseDown;if(o&&o.done(),!n.dataTransfer)return;let i,s=e.state.selection,l=s.empty?null:e.posAtCoords(yt(n));if(l&&l.pos>=s.from&&l.pos<=(s instanceof r.nh?s.to-1:s.to));else if(o&&o.mightDrag)i=r.nh.create(e.state.doc,o.mightDrag.pos);else if(n.target&&u(n.target)){let t=e.docView.nearestDesc(n.target,!0);t&&t.node.type.spec.draggable&&t!=e.docView&&(i=r.nh.create(e.state.doc,t.posBefore))}let a=(i||e.state.selection).content(),{dom:c,text:h,slice:d}=Qe(e,a);(!n.dataTransfer.files.length||!T||E>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(Ft?"Text":"text/html",c.innerHTML),n.dataTransfer.effectAllowed="copyMove",Ft||n.dataTransfer.setData("text/plain",h),e.dragging=new Vt(d,Jt(e,n),i)},ht.dragend=e=>{let t=e.dragging;window.setTimeout(()=>{e.dragging==t&&(e.dragging=null)},50)},dt.dragover=dt.dragenter=(e,t)=>t.preventDefault(),dt.drop=(e,t)=>{try{!function(e,t,n){if(!t.dataTransfer)return;let s=e.posAtCoords(yt(t));if(!s)return;let l=e.state.doc.resolve(s.pos),a=n&&n.slice;a?e.someProp("transformPasted",t=>{a=t(a,e,!1)}):a=et(e,Bt(t.dataTransfer),Ft?null:t.dataTransfer.getData("text/html"),!1,l);let c=!(!n||!Jt(e,t));if(e.someProp("handleDrop",n=>n(e,t,a||o.Ji.empty,c)))return void t.preventDefault();if(!a)return;t.preventDefault();let h=a?(0,i.Um)(e.state.doc,l.pos,a):l.pos;null==h&&(h=l.pos);let d=e.state.tr;if(c){let{node:e}=n;e?e.replace(d):d.deleteSelection()}let p=d.mapping.map(h),f=0==a.openStart&&0==a.openEnd&&1==a.content.childCount,u=d.doc;f?d.replaceRangeWith(p,p,a.content.firstChild):d.replaceRange(p,p,a);if(d.doc.eq(u))return;let m=d.doc.resolve(p);if(f&&r.nh.isSelectable(a.content.firstChild)&&m.nodeAfter&&m.nodeAfter.sameMarkup(a.content.firstChild))d.setSelection(new r.nh(m));else{let t=d.mapping.map(h);d.mapping.maps[d.mapping.maps.length-1].forEach((e,n,r,o)=>t=o),d.setSelection(Be(e,m,d.doc.resolve(t)))}e.focus(),e.dispatch(d.setMeta("uiEvent","drop"))}(e,t,e.dragging)}finally{e.dragging=null}},ht.focus=e=>{e.input.lastFocus=Date.now(),e.focused||(e.domObserver.stop(),e.dom.classList.add("ProseMirror-focused"),e.domObserver.start(),e.focused=!0,setTimeout(()=>{e.docView&&e.hasFocus()&&!e.domObserver.currentSelection.eq(e.domSelectionRange())&&Ee(e)},20))},ht.blur=(e,t)=>{let n=t;e.focused&&(e.domObserver.stop(),e.dom.classList.remove("ProseMirror-focused"),e.domObserver.start(),n.relatedTarget&&e.dom.contains(n.relatedTarget)&&e.domObserver.currentSelection.clear(),e.focused=!1)},ht.beforeinput=(e,t)=>{if(F&&"deleteContentBackward"==t.inputType){e.domObserver.flushSoon();let{domChangeCount:t}=e.input;setTimeout(()=>{if(e.input.domChangeCount!=t)return;if(e.dom.blur(),e.focus(),e.someProp("handleKeyDown",t=>t(e,v(8,"Backspace"))))return;let{$cursor:n}=e.state.selection;n&&n.pos>0&&e.dispatch(e.state.tr.delete(n.pos-1,n.pos).scrollIntoView())},50)}};for(let e in dt)ht[e]=dt[e];function Kt(e,t){if(e==t)return!0;for(let n in e)if(e[n]!==t[n])return!1;for(let n in t)if(!(n in e))return!1;return!0}class Wt{constructor(e,t){this.toDOM=e,this.spec=t||Ht,this.side=this.spec.side||0}map(e,t,n,r){let{pos:o,deleted:i}=e.mapResult(t.from+r,this.side<0?-1:1);return i?null:new jt(o-n,o-n,this)}valid(){return!0}eq(e){return this==e||e instanceof Wt&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Kt(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class _t{constructor(e,t){this.attrs=e,this.spec=t||Ht}map(e,t,n,r){let o=e.map(t.from+r,this.spec.inclusiveStart?-1:1)-n,i=e.map(t.to+r,this.spec.inclusiveEnd?1:-1)-n;return o>=i?null:new jt(o,i,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof _t&&Kt(this.attrs,e.attrs)&&Kt(this.spec,e.spec)}static is(e){return e.type instanceof _t}destroy(){}}class qt{constructor(e,t){this.attrs=e,this.spec=t||Ht}map(e,t,n,r){let o=e.mapResult(t.from+r,1);if(o.deleted)return null;let i=e.mapResult(t.to+r,-1);return i.deleted||i.pos<=o.pos?null:new jt(o.pos-n,i.pos-n,this)}valid(e,t){let n,{index:r,offset:o}=e.content.findIndex(t.from);return o==t.from&&!(n=e.child(r)).isText&&o+n.nodeSize==t.to}eq(e){return this==e||e instanceof qt&&Kt(this.attrs,e.attrs)&&Kt(this.spec,e.spec)}destroy(){}}class jt{constructor(e,t,n){this.from=e,this.to=t,this.type=n}copy(e,t){return new jt(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 jt(e,e,new Wt(t,n))}static inline(e,t,n,r){return new jt(e,t,new _t(n,r))}static node(e,t,n,r){return new jt(e,t,new qt(n,r))}get spec(){return this.type.spec}get inline(){return this.type instanceof _t}get widget(){return this.type instanceof Wt}}const Ut=[],Ht={};class Gt{constructor(e,t){this.local=e.length?e:Ut,this.children=t.length?t:Ut}static create(e,t){return t.length?tn(t,e,0,Ht):Xt}find(e,t,n){let r=[];return this.findInner(e??0,t??1e9,r,0,n),r}findInner(e,t,n,r,o){for(let i=0;i<this.local.length;i++){let s=this.local[i];s.from<=t&&s.to>=e&&(!o||o(s.spec))&&n.push(s.copy(s.from+r,s.to+r))}for(let i=0;i<this.children.length;i+=3)if(this.children[i]<t&&this.children[i+1]>e){let s=this.children[i]+1;this.children[i+2].findInner(e-s,t-s,n,r+s,o)}}map(e,t,n){return this==Xt||0==e.maps.length?this:this.mapInner(e,t,0,0,n||Ht)}mapInner(e,t,n,r,o){let i;for(let s=0;s<this.local.length;s++){let l=this.local[s].map(e,n,r);l&&l.type.valid(t,l)?(i||(i=[])).push(l):o.onRemove&&o.onRemove(this.local[s].spec)}return this.children.length?function(e,t,n,r,o,i,s){let l=e.slice();for(let e=0,t=i;e<n.maps.length;e++){let r=0;n.maps[e].forEach((e,n,o,i)=>{let s=i-o-(n-e);for(let o=0;o<l.length;o+=3){let i=l[o+1];if(i<0||e>i+t-r)continue;let a=l[o]+t-r;n>=a?l[o+1]=e<=a?-2:-1:e>=t&&s&&(l[o]+=s,l[o+1]+=s)}r+=s}),t=n.maps[e].map(t,-1)}let a=!1;for(let t=0;t<l.length;t+=3)if(l[t+1]<0){if(-2==l[t+1]){a=!0,l[t+1]=-1;continue}let c=n.map(e[t]+i),h=c-o;if(h<0||h>=r.content.size){a=!0;continue}let d=n.map(e[t+1]+i,-1)-o,{index:p,offset:f}=r.content.findIndex(h),u=r.maybeChild(p);if(u&&f==h&&f+u.nodeSize==d){let r=l[t+2].mapInner(n,u,c+1,e[t]+i+1,s);r!=Xt?(l[t]=h,l[t+1]=d,l[t+2]=r):(l[t+1]=-2,a=!0)}else a=!0}if(a){let a=function(e,t,n,r,o,i,s){function l(e,t){for(let i=0;i<e.local.length;i++){let l=e.local[i].map(r,o,t);l?n.push(l):s.onRemove&&s.onRemove(e.local[i].spec)}for(let n=0;n<e.children.length;n+=3)l(e.children[n+2],e.children[n]+t+1)}for(let n=0;n<e.length;n+=3)-1==e[n+1]&&l(e[n+2],t[n]+i+1);return n}(l,e,t,n,o,i,s),c=tn(a,r,0,s);t=c.local;for(let e=0;e<l.length;e+=3)l[e+1]<0&&(l.splice(e,3),e-=3);for(let e=0,t=0;e<c.children.length;e+=3){let n=c.children[e];for(;t<l.length&&l[t]<n;)t+=3;l.splice(t,0,c.children[e],c.children[e+1],c.children[e+2])}}return new Gt(t.sort(nn),l)}(this.children,i||[],e,t,n,r,o):i?new Gt(i.sort(nn),Ut):Xt}add(e,t){return t.length?this==Xt?Gt.create(e,t):this.addInner(e,t,0):this}addInner(e,t,n){let r,o=0;e.forEach((e,i)=>{let s,l=i+n;if(s=Qt(t,e,l)){for(r||(r=this.children.slice());o<r.length&&r[o]<i;)o+=3;r[o]==i?r[o+2]=r[o+2].addInner(e,s,l+1):r.splice(o,0,i,i+e.nodeSize,tn(s,e,l+1,Ht)),o+=3}});let i=Yt(o?en(t):t,-n);for(let t=0;t<i.length;t++)i[t].type.valid(e,i[t])||i.splice(t--,1);return new Gt(i.length?this.local.concat(i).sort(nn):this.local,r||this.children)}remove(e){return 0==e.length||this==Xt?this:this.removeInner(e,0)}removeInner(e,t){let n=this.children,r=this.local;for(let r=0;r<n.length;r+=3){let o,i=n[r]+t,s=n[r+1]+t;for(let t,n=0;n<e.length;n++)(t=e[n])&&t.from>i&&t.to<s&&(e[n]=null,(o||(o=[])).push(t));if(!o)continue;n==this.children&&(n=this.children.slice());let l=n[r+2].removeInner(o,i+1);l!=Xt?n[r+2]=l:(n.splice(r,3),r-=3)}if(r.length)for(let n,o=0;o<e.length;o++)if(n=e[o])for(let e=0;e<r.length;e++)r[e].eq(n,t)&&(r==this.local&&(r=this.local.slice()),r.splice(e--,1));return n==this.children&&r==this.local?this:r.length||n.length?new Gt(r,n):Xt}forChild(e,t){if(this==Xt)return this;if(t.isLeaf)return Gt.empty;let n,r;for(let t=0;t<this.children.length;t+=3)if(this.children[t]>=e){this.children[t]==e&&(n=this.children[t+2]);break}let o=e+1,i=o+t.content.size;for(let e=0;e<this.local.length;e++){let t=this.local[e];if(t.from<i&&t.to>o&&t.type instanceof _t){let e=Math.max(o,t.from)-o,n=Math.min(i,t.to)-o;e<n&&(r||(r=[])).push(t.copy(e,n))}}if(r){let e=new Gt(r.sort(nn),Ut);return n?new Zt([e,n]):e}return n||Xt}eq(e){if(this==e)return!0;if(!(e instanceof Gt)||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 rn(this.localsInner(e))}localsInner(e){if(this==Xt)return Ut;if(e.inlineContent||!this.local.some(_t.is))return this.local;let t=[];for(let e=0;e<this.local.length;e++)this.local[e].type instanceof _t||t.push(this.local[e]);return t}forEachSet(e){e(this)}}Gt.empty=new Gt([],[]),Gt.removeOverlap=rn;const Xt=Gt.empty;class Zt{constructor(e){this.members=e}map(e,t){const n=this.members.map(n=>n.map(e,t,Ht));return Zt.from(n)}forChild(e,t){if(t.isLeaf)return Gt.empty;let n=[];for(let r=0;r<this.members.length;r++){let o=this.members[r].forChild(e,t);o!=Xt&&(o instanceof Zt?n=n.concat(o.members):n.push(o))}return Zt.from(n)}eq(e){if(!(e instanceof Zt)||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 r=0;r<this.members.length;r++){let o=this.members[r].localsInner(e);if(o.length)if(t){n&&(t=t.slice(),n=!1);for(let e=0;e<o.length;e++)t.push(o[e])}else t=o}return t?rn(n?t:t.sort(nn)):Ut}static from(e){switch(e.length){case 0:return Xt;case 1:return e[0];default:return new Zt(e.every(e=>e instanceof Gt)?e:e.reduce((e,t)=>e.concat(t instanceof Gt?t:t.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}}function Yt(e,t){if(!t||!e.length)return e;let n=[];for(let r=0;r<e.length;r++){let o=e[r];n.push(new jt(o.from+t,o.to+t,o.type))}return n}function Qt(e,t,n){if(t.isLeaf)return null;let r=n+t.nodeSize,o=null;for(let t,i=0;i<e.length;i++)(t=e[i])&&t.from>n&&t.to<r&&((o||(o=[])).push(t),e[i]=null);return o}function en(e){let t=[];for(let n=0;n<e.length;n++)null!=e[n]&&t.push(e[n]);return t}function tn(e,t,n,r){let o=[],i=!1;t.forEach((t,s)=>{let l=Qt(e,t,s+n);if(l){i=!0;let e=tn(l,t,n+s+1,r);e!=Xt&&o.push(s,s+t.nodeSize,e)}});let s=Yt(i?en(e):e,-n).sort(nn);for(let e=0;e<s.length;e++)s[e].type.valid(t,s[e])||(r.onRemove&&r.onRemove(s[e].spec),s.splice(e--,1));return s.length||o.length?new Gt(s,o):Xt}function nn(e,t){return e.from-t.from||e.to-t.to}function rn(e){let t=e;for(let n=0;n<t.length-1;n++){let r=t[n];if(r.from!=r.to)for(let o=n+1;o<t.length;o++){let i=t[o];if(i.from!=r.from){i.from<r.to&&(t==e&&(t=e.slice()),t[n]=r.copy(r.from,i.from),on(t,o,r.copy(i.from,r.to)));break}i.to!=r.to&&(t==e&&(t=e.slice()),t[o]=i.copy(i.from,r.to),on(t,o+1,i.copy(r.to,i.to)))}}return t}function on(e,t,n){for(;t<e.length&&nn(n,e[t])>0;)t++;e.splice(t,0,n)}function sn(e){let t=[];return e.someProp("decorations",n=>{let r=n(e.state);r&&r!=Xt&&t.push(r)}),e.cursorWrapper&&t.push(Gt.create(e.state.doc,[e.cursorWrapper.deco])),Zt.from(t)}const ln={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},an=N&&O<=11;class cn{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}}class hn{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new cn,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(t=>{for(let e=0;e<t.length;e++)this.queue.push(t[e]);N&&O<=11&&t.some(e=>"childList"==e.type&&e.removedNodes.length||"characterData"==e.type&&e.oldValue.length>e.target.nodeValue.length)?this.flushSoon():R&&e.composing&&t.some(e=>"childList"==e.type&&"TR"==e.target.nodeName)?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),an&&(this.onCharData=e=>{this.queue.push({target:e.target,type:"characterData",oldValue:e.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,ln)),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(Ve(this.view)){if(this.suppressingSelectionUpdates)return Ee(this.view);if(N&&O<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&h(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,n=new Set;for(let t=e.focusNode;t;t=l(t))n.add(t);for(let r=e.anchorNode;r;r=l(r))if(n.has(r)){t=r;break}let r=t&&this.view.docView.nearestDesc(t);return r&&r.ignoreMutation({type:"selection",target:m(t)?t.parentNode:t})?(this.setCurSelection(),!0):void 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=e.domSelectionRange(),o=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(n)&&Ve(e)&&!this.ignoreSelectionChange(n),i=-1,s=-1,l=!1,a=[];if(e.editable)for(let e=0;e<t.length;e++){let n=this.registerMutation(t[e],a);n&&(i=i<0?n.from:Math.min(n.from,i),s=s<0?n.to:Math.max(n.to,s),n.typeOver&&(l=!0))}if(a.some(e=>"BR"==e.nodeName)&&(8==e.input.lastKeyCode||46==e.input.lastKeyCode||T&&(e.composing||e.input.compositionEndedAt>Date.now()-50)&&t.some(e=>"childList"==e.type&&e.removedNodes.length))){for(let e of a)if("BR"==e.nodeName&&e.parentNode){let t=e.nextSibling;for(;t&&u(t);){if("false"==t.contentEditable){e.parentNode.removeChild(e);break}t=t.firstChild}}}else if(D&&a.length){let t=a.filter(e=>"BR"==e.nodeName);if(2==t.length){let[e,n]=t;e.parentNode&&e.parentNode.parentNode==n.parentNode?n.remove():e.remove()}else{let{focusNode:n}=this.currentSelection;for(let r of t){let t=r.parentNode;!t||"LI"!=t.nodeName||n&&un(e,n)==t||r.remove()}}}let c=null;i<0&&o&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&y(n)&&(c=Ae(e))&&c.eq(r.LN.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,Ee(e),this.currentSelection.set(n),e.scrollToSelection()):(i>-1||o)&&(i>-1&&(e.docView.markDirty(i,s),function(e){if(dn.has(e))return;if(dn.set(e,null),-1!==["normal","nowrap","pre-line"].indexOf(getComputedStyle(e.dom).whiteSpace)){if(e.requiresGeckoHackNode=D,pn)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."),pn=!0}}(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,function(e,t){var n;let{focusNode:r,focusOffset:o}=e.domSelectionRange();for(let i of t)if("TR"==(null===(n=i.parentNode)||void 0===n?void 0:n.nodeName)){let t=i.nextSibling;for(;t&&"TD"!=t.nodeName&&"TH"!=t.nodeName;)t=t.nextSibling;if(t){let n=t;for(;;){let e=n.firstChild;if(!e||!u(e)||"false"==e.contentEditable||/^(BR|IMG)$/.test(e.nodeName))break;n=e}n.insertBefore(i,n.firstChild),r==i&&e.domSelection().collapse(i,o)}else i.parentNode.removeChild(i)}}(e,a)),this.handleDOMChange(i,s,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(n)||Ee(e),this.currentSelection.set(n))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let n=this.view.docView.nearestDesc(e.target);if("attributes"==e.type&&(n==this.view.docView||"contenteditable"==e.attributeName||"style"==e.attributeName&&!e.oldValue&&!e.target.getAttribute("style")))return null;if(!n||n.ignoreMutation(e))return null;if("childList"==e.type){for(let n=0;n<e.addedNodes.length;n++){let r=e.addedNodes[n];t.push(r),m(r)&&(this.lastChangedTextNode=r)}if(n.contentDOM&&n.contentDOM!=n.dom&&!n.contentDOM.contains(e.target))return{from:n.posBefore,to:n.posAfter};let r=e.previousSibling,o=e.nextSibling;if(N&&O<=11&&e.addedNodes.length)for(let t=0;t<e.addedNodes.length;t++){let{previousSibling:n,nextSibling:i}=e.addedNodes[t];(!n||Array.prototype.indexOf.call(e.addedNodes,n)<0)&&(r=n),(!i||Array.prototype.indexOf.call(e.addedNodes,i)<0)&&(o=i)}let i=r&&r.parentNode==e.target?s(r)+1:0,l=n.localPosFromDOM(e.target,i,-1),a=o&&o.parentNode==e.target?s(o):e.target.childNodes.length;return{from:l,to:n.localPosFromDOM(e.target,a,1)}}return"attributes"==e.type?{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})}}let dn=new WeakMap,pn=!1;function fn(e,t){let n=t.startContainer,r=t.startOffset,o=t.endContainer,i=t.endOffset,s=e.domAtPos(e.state.selection.anchor);return h(s.node,s.offset,o,i)&&([n,r,o,i]=[o,i,n,r]),{anchorNode:n,anchorOffset:r,focusNode:o,focusOffset:i}}function un(e,t){for(let n=t.parentNode;n&&n!=e.dom;n=n.parentNode){let t=e.docView.nearestDesc(n,!0);if(t&&t.node.isBlock)return n}return null}const mn=e=>t=>{let n=t.pmViewDesc;if(n)return n.parseRule(e);if("BR"==t.nodeName&&t.parentNode){if(R&&/^(ul|ol)$/i.test(t.parentNode.nodeName)){let e=document.createElement("div");return e.appendChild(document.createElement("li")),{skip:e}}if(t.parentNode.lastChild==t||R&&/^(tr|table)$/i.test(t.parentNode.nodeName))return{ignore:!0}}else if("IMG"==t.nodeName&&t.getAttribute("mark-placeholder"))return{ignore:!0};return null},gn=/^(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 wn(e,t,n,i,s){let l=e.input.compositionPendingChanges||(e.composing?e.input.compositionID:0);if(e.input.compositionPendingChanges=0,t<0){let t=e.input.lastSelectionTime>Date.now()-50?e.input.lastSelectionOrigin:null,n=Ae(e,t);if(n&&!e.state.selection.eq(n)){if(T&&F&&13===e.input.lastKeyCode&&Date.now()-100<e.input.lastKeyCodeTime&&e.someProp("handleKeyDown",t=>t(e,v(13,"Enter"))))return;let r=e.state.tr.setSelection(n);"pointer"==t?r.setMeta("pointer",!0):"key"==t&&r.scrollIntoView(),l&&r.setMeta("composition",l),e.dispatch(r)}return}let a=e.state.doc.resolve(t),c=a.sharedDepth(n);t=a.before(c+1),n=e.state.doc.resolve(n).after(c+1);let h,d,p=e.state.selection,f=function(e,t,n,r){let i,{node:s,fromOffset:l,toOffset:a,from:c,to:h}=e.docView.parseRange(t,n),d=e.domSelectionRange(),p=d.anchorNode;if(p&&g(e.dom,p)&&(i=[{node:p,offset:d.anchorOffset}],y(d)||i.push({node:d.focusNode,offset:d.focusOffset})),T&&8===e.input.lastKeyCode)for(let e=a;e>l;e--){let t=s.childNodes[e-1],n=t.pmViewDesc;if("BR"==t.nodeName&&!n){a=e;break}if(!n||n.size)break}let f=e.state.doc,u=e.someProp("domParser")||o.S4.fromSchema(e.state.schema),m=f.resolve(c),w=null,v=u.parse(s,{topNode:m.parent,topMatch:m.parent.contentMatchAt(m.index()),topOpen:!0,from:l,to:a,preserveWhitespace:"pre"!=m.parent.type.whitespace||"full",findPositions:i,ruleFromNode:mn(r),context:m});if(i&&null!=i[0].pos){let e=i[0].pos,t=i[1]&&i[1].pos;null==t&&(t=e),w={anchor:e+c,head:t+c}}return{doc:v,sel:w,from:c,to:h}}(e,t,n,s),m=e.state.doc,w=m.slice(f.from,f.to);8===e.input.lastKeyCode&&Date.now()-100<e.input.lastKeyCodeTime?(h=e.state.selection.to,d="end"):(h=e.state.selection.from,d="start"),e.input.lastKeyCode=null;let b=function(e,t,n,r,o){let i=e.findDiffStart(t,n),s=n+e.size,l=n+t.size;if(null==i)return null;let{a,b:c}=e.findDiffEnd(t,s,l);if("end"==o){r-=a+Math.max(0,i-Math.min(a,c))-i}if(a<i&&s<l){i-=r<=i&&r>=a?i-r:0,c=i+(c-a),a=i}else if(c<i){i-=r<=i&&r>=c?i-r:0,a=i+(a-c),c=i}return{start:i,endA:a,endB:c}}(w.content,f.doc.content,f.from,h,d);if(b&&e.input.domChangeCount++,(I&&e.input.lastIOSEnter>Date.now()-225||F)&&s.some(e=>u(e)&&!gn.test(e.nodeName))&&(!b||b.endA>=b.endB)&&e.someProp("handleKeyDown",t=>t(e,v(13,"Enter"))))return void(e.input.lastIOSEnter=0);if(!b){if(!(i&&p instanceof r.U3&&!p.empty&&p.$head.sameParent(p.$anchor))||e.composing||f.sel&&f.sel.anchor!=f.sel.head){if(f.sel){let t=yn(e,e.state.doc,f.sel);if(t&&!t.eq(e.state.selection)){let n=e.state.tr.setSelection(t);l&&n.setMeta("composition",l),e.dispatch(n)}}return}b={start:p.from,endA:p.to,endB:p.to}}e.state.selection.from<e.state.selection.to&&b.start==b.endB&&e.state.selection instanceof r.U3&&(b.start>e.state.selection.from&&b.start<=e.state.selection.from+2&&e.state.selection.from>=f.from?b.start=e.state.selection.from:b.endA<e.state.selection.to&&b.endA>=e.state.selection.to-2&&e.state.selection.to<=f.to&&(b.endB+=e.state.selection.to-b.endA,b.endA=e.state.selection.to)),N&&O<=11&&b.endB==b.start+1&&b.endA==b.start&&b.start>f.from&&"  "==f.doc.textBetween(b.start-f.from-1,b.start-f.from+1)&&(b.start--,b.endA--,b.endB--);let S=f.doc.resolveNoCache(b.start-f.from),x=f.doc.resolveNoCache(b.endB-f.from),k=m.resolve(b.start),C=S.sameParent(x)&&S.parent.inlineContent&&k.end()>=b.endA;if((I&&e.input.lastIOSEnter>Date.now()-225&&(!C||s.some(e=>"DIV"==e.nodeName||"P"==e.nodeName))||!C&&function(e,t,n){let r=0,o=0;return e.nodesBetween(t,n,(e,i)=>{e.isTextblock&&i>=t&&i<n?r++:(e.isText?/\S/.test(e.text.slice(Math.max(0,t-i),Math.min(e.nodeSize,n-i))):e.isLeaf)&&o++}),0==o&&1==r}(f.doc,S.pos,x.pos))&&e.someProp("handleKeyDown",t=>t(e,v(13,"Enter"))))return void(e.input.lastIOSEnter=0);if(e.state.selection.anchor>b.start&&function(e,t,n,r,o){if(n-t<=o.pos-r.pos||vn(r,!0,!1)<o.pos)return!1;let i=e.resolve(t);if(!r.parent.isTextblock){let e=i.nodeAfter;return null!=e&&n==t+e.nodeSize}if(i.parentOffset<i.parent.content.size||!i.parent.isTextblock)return!1;let s=e.resolve(vn(i,!0,!0));return!(!s.parent.isTextblock||s.pos>n||vn(s,!0,!1)<n)&&r.parent.content.cut(r.parentOffset).eq(s.parent.content)}(m,b.start,b.endA,S,x)&&e.someProp("handleKeyDown",t=>t(e,v(8,"Backspace"))))return void(F&&T&&e.domObserver.suppressSelectionUpdates());T&&b.endB==b.start&&(e.input.lastChromeDelete=Date.now()),F&&!C&&S.start()!=x.start()&&0==x.parentOffset&&S.depth==x.depth&&f.sel&&f.sel.anchor==f.sel.head&&f.sel.head==b.endA&&(b.endB-=2,x=f.doc.resolveNoCache(b.endB-f.from),setTimeout(()=>{e.someProp("handleKeyDown",function(t){return t(e,v(13,"Enter"))})},20));let M,D=b.start,A=b.endA,E=t=>{let n=t||e.state.tr.replace(D,A,f.doc.slice(b.start-f.from,b.endB-f.from));if(f.sel){let t=yn(e,n.doc,f.sel);t&&!(T&&e.composing&&t.empty&&(b.start!=b.endB||e.input.lastChromeDelete<Date.now()-100)&&(t.head==D||t.head==n.mapping.map(A)-1)||N&&t.empty&&t.head==D)&&n.setSelection(t)}return l&&n.setMeta("composition",l),n.scrollIntoView()};if(C)if(S.pos==x.pos){N&&O<=11&&0==S.parentOffset&&(e.domObserver.suppressSelectionUpdates(),setTimeout(()=>Ee(e),20));let t=E(e.state.tr.delete(D,A)),n=m.resolve(b.start).marksAcross(m.resolve(b.endA));n&&t.ensureMarks(n),e.dispatch(t)}else if(b.endA==b.endB&&(M=function(e,t){let n,r,i,s=e.firstChild.marks,l=t.firstChild.marks,a=s,c=l;for(let e=0;e<l.length;e++)a=l[e].removeFromSet(a);for(let e=0;e<s.length;e++)c=s[e].removeFromSet(c);if(1==a.length&&0==c.length)r=a[0],n="add",i=e=>e.mark(r.addToSet(e.marks));else{if(0!=a.length||1!=c.length)return null;r=c[0],n="remove",i=e=>e.mark(r.removeFromSet(e.marks))}let h=[];for(let e=0;e<t.childCount;e++)h.push(i(t.child(e)));if(o.FK.from(h).eq(e))return{mark:r,type:n}}(S.parent.content.cut(S.parentOffset,x.parentOffset),k.parent.content.cut(k.parentOffset,b.endA-k.start())))){let t=E(e.state.tr);"add"==M.type?t.addMark(D,A,M.mark):t.removeMark(D,A,M.mark),e.dispatch(t)}else if(S.parent.child(S.index()).isText&&S.index()==x.index()-(x.textOffset?0:1)){let t=S.parent.textBetween(S.parentOffset,x.parentOffset),n=()=>E(e.state.tr.insertText(t,D,A));e.someProp("handleTextInput",r=>r(e,D,A,t,n))||e.dispatch(n())}else e.dispatch(E());else e.dispatch(E())}function yn(e,t,n){return Math.max(n.anchor,n.head)>t.content.size?null:Be(e,t.resolve(n.anchor),t.resolve(n.head))}function vn(e,t,n){let r=e.depth,o=t?e.end():e.pos;for(;r>0&&(t||e.indexAfter(r)==e.node(r).childCount);)r--,o++,t=!1;if(n){let t=e.node(r).maybeChild(e.indexAfter(r));for(;t&&!t.isLeaf;)t=t.firstChild,o++}return o}class bn{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 ft,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(Mn),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):"function"==typeof e?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=kn(this),xn(this),this.nodeViews=Cn(this),this.docView=fe(this.state.doc,Sn(this),sn(this),this.dom,this),this.domObserver=new hn(this,(e,t,n,r)=>wn(this,e,t,n,r)),this.domObserver.start(),function(e){for(let t in ht){let n=ht[t];e.dom.addEventListener(t,e.input.eventHandlers[t]=t=>{!wt(e,t)||gt(e,t)||!e.editable&&t.type in dt||n(e,t)},pt[t]?{passive:!0}:void 0)}R&&e.dom.addEventListener("input",()=>null),mt(e)}(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&&mt(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Mn),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let e in this._props)t[e]=this._props[e];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 r=this.state,o=!1,i=!1;e.storedMarks&&this.composing&&(It(this),i=!0),this.state=e;let s=r.plugins!=e.plugins||this._props.plugins!=t.plugins;if(s||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let e=Cn(this);(function(e,t){let n=0,r=0;for(let r in e){if(e[r]!=t[r])return!0;n++}for(let e in t)r++;return n!=r})(e,this.nodeViews)&&(this.nodeViews=e,o=!0)}(s||t.handleDOMEvents!=this._props.handleDOMEvents)&&mt(this),this.editable=kn(this),xn(this);let l=sn(this),a=Sn(this),c=r.plugins==e.plugins||r.doc.eq(e.doc)?e.scrollToSelection>r.scrollToSelection?"to selection":"preserve":"reset",d=o||!this.docView.matchesNode(e.doc,a,l);!d&&e.selection.eq(r.selection)||(i=!0);let p="preserve"==c&&i&&null==this.dom.style.overflowAnchor&&function(e){let t,n,r=e.dom.getBoundingClientRect(),o=Math.max(0,r.top);for(let i=(r.left+r.right)/2,s=o+1;s<Math.min(innerHeight,r.bottom);s+=5){let r=e.root.elementFromPoint(i,s);if(!r||r==e.dom||!e.dom.contains(r))continue;let l=r.getBoundingClientRect();if(l.top>=o-20){t=r,n=l.top;break}}return{refDOM:t,refTop:n,stack:W(e.dom)}}(this);if(i){this.domObserver.stop();let t=d&&(N||T)&&!this.composing&&!r.selection.empty&&!e.selection.empty&&function(e,t){let n=Math.min(e.$anchor.sharedDepth(e.head),t.$anchor.sharedDepth(t.head));return e.$anchor.start(n)!=t.$anchor.start(n)}(r.selection,e.selection);if(d){let n=T?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=zt(this)),!o&&this.docView.update(e.doc,a,l,this)||(this.docView.updateOuterDeco(a),this.docView.destroy(),this.docView=fe(e.doc,a,l,this.dom,this)),!n||this.trackWrites&&this.dom.contains(this.trackWrites)||(t=!0)}let n=this.input.mouseDown;t||!(n&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&function(e){let t=e.docView.domFromPos(e.state.selection.anchor,0),n=e.domSelectionRange();return h(t.node,t.offset,n.anchorNode,n.anchorOffset)}(this)&&n.delaySelUpdate())?Ee(this,t):(Fe(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(r),(null===(n=this.dragging)||void 0===n?void 0:n.node)&&!r.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,r),"reset"==c?this.dom.scrollTop=0:"to selection"==c?this.scrollToSelection():p&&function({refDOM:e,refTop:t,stack:n}){let r=e?e.getBoundingClientRect().top:0;_(n,0==r?0:r-t)}(p)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(e&&g(this.dom,e))if(this.someProp("handleScrollToSelection",e=>e(this)));else if(this.state.selection instanceof r.nh){let t=this.docView.domAfterPos(this.state.selection.from);u(t)&&K(this,t.getBoundingClientRect(),e)}else K(this,this.coordsAtPos(this.state.selection.head,1),e);else;}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)for(let t=0;t<this.pluginViews.length;t++){let n=this.pluginViews[t];n.update&&n.update(this,e)}else{this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let e=0;e<this.directPlugins.length;e++){let t=this.directPlugins[e];t.spec.view&&this.pluginViews.push(t.spec.view(this))}for(let e=0;e<this.state.plugins.length;e++){let t=this.state.plugins[e];t.spec.view&&this.pluginViews.push(t.spec.view(this))}}}updateDraggedNode(e,t){let n=e.node,o=-1;if(n.from<this.state.doc.content.size&&this.state.doc.nodeAt(n.from)==n.node)o=n.from;else{let e=n.from+(this.state.doc.content.size-t.doc.content.size);(e>0&&e<this.state.doc.content.size&&this.state.doc.nodeAt(e))==n.node&&(o=e)}this.dragging=new Vt(e.slice,e.move,o<0?void 0:r.nh.create(this.state.doc,o))}someProp(e,t){let n,r=this._props&&this._props[e];if(null!=r&&(n=t?t(r):r))return n;for(let r=0;r<this.directPlugins.length;r++){let o=this.directPlugins[r].props[e];if(null!=o&&(n=t?t(o):o))return n}let o=this.state.plugins;if(o)for(let r=0;r<o.length;r++){let i=o[r].props[e];if(null!=i&&(n=t?t(i):i))return n}}hasFocus(){if(N){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("false"==e.contentEditable)return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&function(e){if(e.setActive)return e.setActive();if(q)return e.focus(q);let t=W(e);e.focus(null==q?{get preventScroll(){return q={preventScroll:!0},!0}}:void 0),q||(q=!1,_(t,0))}(this.dom),Ee(this),this.domObserver.start()}get root(){let e=this._root;if(null==e)for(let e=this.dom.parentNode;e;e=e.parentNode)if(9==e.nodeType||11==e.nodeType&&e.host)return e.getSelection||(Object.getPrototypeOf(e).getSelection=()=>e.ownerDocument.getSelection()),this._root=e;return e||document}updateRoot(){this._root=null}posAtCoords(e){return G(this,e)}coordsAtPos(e,t=1){return Q(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 r=this.docView.posFromDOM(e,t,n);if(null==r)throw new RangeError("DOM position not inside the editor");return r}endOfTextblock(e,t){return le(this,t||this.state,e)}pasteHTML(e,t){return Pt(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return Pt(this,e,null,!0,t||new ClipboardEvent("paste"))}serializeForClipboard(e){return Qe(this,e)}destroy(){this.docView&&(!function(e){e.input.mouseDown&&e.input.mouseDown.done(),e.domObserver.stop();for(let t in e.input.eventHandlers)e.dom.removeEventListener(t,e.input.eventHandlers[t]);clearTimeout(e.input.composingTimeout),clearTimeout(e.input.lastIOSEnterFallbackTimeout)}(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],sn(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,a=null)}get isDestroyed(){return null==this.docView}dispatchEvent(e){return function(e,t){gt(e,t)||!ht[t.type]||!e.editable&&t.type in dt||ht[t.type](e,t)}(this,e)}domSelectionRange(){let e=!1!==this.dom.isConnected&&this.domSelection();return e?R&&11===this.root.nodeType&&function(e){let t=e.activeElement;for(;t&&t.shadowRoot;)t=t.shadowRoot.activeElement;return t}(this.dom.ownerDocument)==this.dom&&function(e,t){if(t.getComposedRanges){let n=t.getComposedRanges(e.root)[0];if(n)return fn(e,n)}let n;function r(e){e.preventDefault(),e.stopImmediatePropagation(),n=e.getTargetRanges()[0]}return e.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),e.dom.removeEventListener("beforeinput",r,!0),n?fn(e,n):null}(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}function Sn(e){let t=Object.create(null);return t.class="ProseMirror",t.contenteditable=String(e.editable),e.someProp("attributes",n=>{if("function"==typeof n&&(n=n(e.state)),n)for(let e in n)"class"==e?t.class+=" "+n[e]:"style"==e?t.style=(t.style?t.style+";":"")+n[e]:t[e]||"contenteditable"==e||"nodeName"==e||(t[e]=String(n[e]))}),t.translate||(t.translate="no"),[jt.node(0,e.state.doc.content.size,t)]}function xn(e){if(e.markCursor){let t=document.createElement("img");t.className="ProseMirror-separator",t.setAttribute("mark-placeholder","true"),t.setAttribute("alt",""),e.cursorWrapper={dom:t,deco:jt.widget(e.state.selection.from,t,{raw:!0,marks:e.markCursor})}}else e.cursorWrapper=null}function kn(e){return!e.someProp("editable",t=>!1===t(e.state))}function Cn(e){let t=Object.create(null);function n(e){for(let n in e)Object.prototype.hasOwnProperty.call(t,n)||(t[n]=e[n])}return e.someProp("nodeViews",n),e.someProp("markViews",n),t}function Mn(e){if(e.spec.state||e.spec.filterTransaction||e.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}bn.prototype.dispatch=function(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))}}}]);