diff --git a/django_prose_editor/static/django_prose_editor/editor.css b/django_prose_editor/static/django_prose_editor/editor.css index 2fe5429..2eeb272 100644 --- a/django_prose_editor/static/django_prose_editor/editor.css +++ b/django_prose_editor/static/django_prose_editor/editor.css @@ -1 +1 @@ -.prose-editor *,.prose-editor *:before,.prose-editor *:after{box-sizing:inherit}.prose-editor{box-sizing:border-box;position:relative;max-width:120ch;min-width:40ch;flex-grow:1}.prose-editor,.prose-editor-dialog{--_b: var(--prose-editor-background, var(--body-bg, #fff));--_f: var(--prose-editor-foreground, var(--body-fg, #333));--_r: var(--prose-editor-border-color, var(--border-color, #ccc));--_a: var(--prose-editor-active-color, var(--primary, #79aec8));--_d: var(--prose-editor-disabled-color, var(--border-color, #ccc));--_t: var(--prose-editor-typographic, #ccc)}[data-django-prose-editor]{opacity:0}.prose-editor+textarea{display:none!important}.prose-menubar{font-size:14px;display:inline-flex;align-items:center;gap:8px;flex-wrap:wrap;margin-bottom:2px;background:var(--_b);padding:4px;width:100%;box-shadow:0 1px 2px #0000001a;border-bottom:1px solid var(--_r);box-sizing:border-box;z-index:10}.prose-menubar--floating{position:fixed;margin:0;border-radius:0}.prose-menubar-placeholder{display:none;height:0;width:100%;box-sizing:border-box}.prose-menubar-placeholder--active{display:block;height:var(--menubar-height, 45px)}.prose-menubar__group{display:flex}.prose-menubar__button{cursor:pointer;padding:0 .25em;min-width:2em;transition:all .25s;background:var(--_b);color:var(--_f);border:1px solid var(--_r);text-align:center;display:inline-flex;align-items:center;position:relative}.prose-menubar__button.hidden{display:none!important}.prose-menubar__button--heading .level{position:absolute;right:3px;bottom:2px;font-size:80%}.prose-menubar__button:not(.hidden){border-top-left-radius:4px;border-bottom-left-radius:4px}.prose-menubar__button:not(.hidden)~.prose-menubar__button:not(.hidden){border-top-left-radius:0;border-bottom-left-radius:0}.prose-menubar__button:not(.hidden):not(:has(~.prose-menubar__button:not(.hidden))){border-top-right-radius:4px;border-bottom-right-radius:4px}.prose-menubar__button+.prose-menubar__button{border-left:none}.prose-menubar__button.material-icons{padding:0 .125em;min-width:auto}.prose-menubar__button:hover{filter:brightness(110%)}.prose-menubar__button.active{background-color:var(--_a)}.prose-menubar__button.disabled:not(.active){background:var(--_d);filter:brightness(100%);cursor:not-allowed;opacity:.3}.prose-editor .ProseMirror{padding:0 6px;background:var(--_b);color:var(--_f);border:1px solid var(--_r);border-radius:4px}.prose-editor-dialog{background:var(--_b);color:var(--_f);border:1px solid var(--_r);border-radius:4px;padding:1em;min-width:300px}.prose-editor-dialog-title{font-size:1.25em;font-weight:700;margin:0!important;padding:0 0 .5em!important;border-bottom:1px solid var(--_r)}.prose-editor-dialog input[type=checkbox],.prose-editor-dialog input[type=radio]{margin-right:4px}.prose-editor-dialog p{padding:0;margin:0}.prose-editor-dialog label{display:block;margin-bottom:.5em;font-weight:700;width:auto;min-width:0}.prose-editor-dialog input:not([type=checkbox],[type=radio]),.prose-editor-dialog select,.prose-editor-dialog textarea{width:100%;padding:.5em;border:1px solid var(--_r);border-radius:4px;margin-bottom:1em;transition:border-color .2s,box-shadow .2s}.prose-editor-dialog input:focus,.prose-editor-dialog select:focus,.prose-editor-dialog textarea:focus{outline:none;border-color:var(--_a);box-shadow:0 0 0 2px #79aec840}.prose-editor-dialog input[type=number]{width:5em}.prose-editor-dialog button{all:unset;cursor:pointer;padding:.5em 1em;transition:all .25s;background:var(--_b);color:var(--_f);border:1px solid var(--_r);border-radius:4px;text-align:center;display:inline-flex;position:relative;margin-right:.5em;margin-top:.5em}.prose-editor-dialog button:hover{filter:brightness(1.1);background-color:#0000000d}.prose-editor-dialog button:active{filter:brightness(.95)}.prose-editor-dialog button:focus{outline:2px solid var(--_a);outline-offset:2px;position:relative;z-index:1}label:empty:has(+.prose-editor){display:none}.prose-editor-nbsp{background:var(--_t);box-shadow:0 2px 0 0 var(--_t),0 -2px 0 0 var(--_t)}.prose-editor-shy{background:var(--_t);box-shadow:0 2px 0 1px var(--_t),0 -2px 0 1px var(--_t)}.prose-editor-fullscreen{position:fixed!important;top:0!important;left:0!important;width:100vw!important;height:100vh!important;max-width:none!important;max-height:none!important;z-index:9999!important;margin:0!important;padding:20px!important;background:var(--_b)!important;overflow-y:auto!important;display:flex!important;flex-direction:column!important}.prose-editor-fullscreen .prose-menubar{padding:8px 20px!important;border-radius:0!important;width:100%!important}.prose-editor-fullscreen .prose-menubar--floating{position:fixed!important;top:0!important;left:0!important;right:0!important;z-index:10000!important}.prose-editor-fullscreen .ProseMirror{flex:1!important;max-height:none!important;overflow-y:auto!important;padding:1em!important;box-shadow:none!important;border:1px solid var(--_r)!important;border-radius:4px!important}.prose-menubar__button svg{display:inline-block;vertical-align:middle;width:20px;height:20px}.prose-menubar__button svg *{color:inherit}.ProseMirror .figure{display:flex;flex-direction:column;margin:1.5rem 0;max-width:100%;position:relative}.ProseMirror .figure figcaption.figure-caption{padding:.5rem 0;color:#555;font-style:italic;font-size:.9rem;text-align:center;margin-top:.5rem}.ProseMirror .figure img{max-width:100%;height:auto} +.prose-editor *,.prose-editor *:before,.prose-editor *:after{box-sizing:inherit}.prose-editor{box-sizing:border-box;position:relative;max-width:120ch;min-width:40ch;flex-grow:1}.prose-editor,.prose-editor-dialog{--_b: var(--prose-editor-background, var(--body-bg, #fff));--_f: var(--prose-editor-foreground, var(--body-fg, #333));--_r: var(--prose-editor-border-color, var(--border-color, #ccc));--_a: var(--prose-editor-active-color, var(--primary, #79aec8));--_d: var(--prose-editor-disabled-color, var(--border-color, #ccc));--_t: var(--prose-editor-typographic, #ccc)}[data-django-prose-editor]{opacity:0}.prose-editor+textarea{display:none!important}.prose-menubar{font-size:14px;display:inline-flex;align-items:center;gap:8px;flex-wrap:wrap;margin-bottom:2px;background:var(--_b);padding:4px;width:100%;box-shadow:0 1px 2px #0000001a;border-bottom:1px solid var(--_r);box-sizing:border-box;z-index:10}.prose-menubar--floating{position:fixed;margin:0;border-radius:0}.prose-menubar-placeholder{display:none;height:0;width:100%;box-sizing:border-box}.prose-menubar-placeholder--active{display:block;height:var(--menubar-height, 45px)}.prose-menubar__group{display:flex}.prose-menubar__button{cursor:pointer;padding:0 .25em;min-width:2em;transition:all .25s;background:var(--_b);color:var(--_f);border:1px solid var(--_r);text-align:center;display:inline-flex;align-items:center;position:relative}.prose-menubar__button.hidden{display:none!important}.prose-menubar__button--heading .level{position:absolute;right:3px;bottom:2px;font-size:80%}.prose-menubar__button:not(.hidden){border-top-left-radius:4px;border-bottom-left-radius:4px}.prose-menubar__button:not(.hidden)~.prose-menubar__button:not(.hidden){border-top-left-radius:0;border-bottom-left-radius:0}.prose-menubar__button:not(.hidden):not(:has(~.prose-menubar__button:not(.hidden))){border-top-right-radius:4px;border-bottom-right-radius:4px}.prose-menubar__button+.prose-menubar__button{border-left:none}.prose-menubar__button.material-icons{padding:0 .125em;min-width:auto}.prose-menubar__button:hover{filter:brightness(110%)}.prose-menubar__button.active{background-color:var(--_a)}.prose-menubar__button.disabled:not(.active){background:var(--_d);filter:brightness(100%);cursor:not-allowed;opacity:.3}.prose-editor .ProseMirror{padding:0 6px;background:var(--_b);color:var(--_f);border:1px solid var(--_r);border-radius:4px}.prose-editor-dialog{background:var(--_b);color:var(--_f);border:1px solid var(--_r);border-radius:4px;padding:1em;min-width:300px}.prose-editor-dialog-title{font-size:1.25em;font-weight:700;margin:0!important;padding:0 0 .5em!important;border-bottom:1px solid var(--_r)}.prose-editor-dialog input[type=checkbox],.prose-editor-dialog input[type=radio]{margin-right:4px}.prose-editor-dialog p{padding:0;margin:0}.prose-editor-dialog label{display:block;margin-bottom:.5em;font-weight:700;width:auto;min-width:0}.prose-editor-dialog input:not([type=checkbox],[type=radio]),.prose-editor-dialog select,.prose-editor-dialog textarea{width:100%;padding:.5em;border:1px solid var(--_r);border-radius:4px;margin-bottom:1em;transition:border-color .2s,box-shadow .2s}.prose-editor-dialog input:focus,.prose-editor-dialog select:focus,.prose-editor-dialog textarea:focus{outline:none;border-color:var(--_a);box-shadow:0 0 0 2px #79aec840}.prose-editor-dialog input[type=number]{width:5em}.prose-editor-dialog button{all:unset;cursor:pointer;padding:.5em 1em;transition:all .25s;background:var(--_b);color:var(--_f);border:1px solid var(--_r);border-radius:4px;text-align:center;display:inline-flex;position:relative;margin-right:.5em;margin-top:.5em}.prose-editor-dialog button:hover{filter:brightness(1.1);background-color:#0000000d}.prose-editor-dialog button:active{filter:brightness(.95)}.prose-editor-dialog button:focus{outline:2px solid var(--_a);outline-offset:2px;position:relative;z-index:1}label:empty:has(+.prose-editor){display:none}.prose-editor-nbsp{background:var(--_t);box-shadow:0 2px 0 0 var(--_t),0 -2px 0 0 var(--_t)}.prose-editor-shy{background:var(--_t);box-shadow:0 2px 0 1px var(--_t),0 -2px 0 1px var(--_t)}.prose-editor-zwsp{position:relative}.prose-editor-zwsp:after{content:"\b7";position:absolute;color:var(--_t);font-weight:700;top:50%;left:50%;transform:translate(-50%,-50%);font-size:.8em}.prose-editor-zwnj{position:relative}.prose-editor-zwnj:after{content:"\2298";position:absolute;color:var(--_t);top:50%;left:50%;transform:translate(-50%,-50%);font-size:.8em}.prose-editor-zwj{position:relative}.prose-editor-zwj:after{content:"\2299";position:absolute;color:var(--_t);top:50%;left:50%;transform:translate(-50%,-50%);font-size:.8em}.prose-editor-wj{position:relative}.prose-editor-wj:after{content:"\2194";position:absolute;color:var(--_t);top:50%;left:50%;transform:translate(-50%,-50%);font-size:.8em}.prose-editor-ls{position:relative}.prose-editor-ls:after{content:"\21b2";position:absolute;color:var(--_t);top:50%;left:50%;transform:translate(-50%,-50%);font-size:.8em}.prose-editor-ps{position:relative}.prose-editor-ps:after{content:"\204b";position:absolute;color:var(--_t);top:50%;left:50%;transform:translate(-50%,-50%);font-size:.8em}.prose-editor-br-marker{display:inline-block;color:var(--_t);font-size:1em;margin-right:.2em;-webkit-user-select:none;-moz-user-select:none;user-select:none;pointer-events:none;vertical-align:middle}.prose-editor-emsp{background:var(--_t);box-shadow:0 2px 0 0 var(--_t),0 -2px 0 0 var(--_t);position:relative}.prose-editor-emsp:after{content:"em";position:absolute;color:#fff;top:50%;left:50%;transform:translate(-50%,-50%);font-size:.5em;font-weight:700}.prose-editor-thinsp{background:var(--_t);box-shadow:0 2px 0 0 var(--_t),0 -2px 0 0 var(--_t);position:relative}.prose-editor-thinsp:after{content:"thin";position:absolute;color:#fff;top:50%;left:50%;transform:translate(-50%,-50%);font-size:.4em;font-weight:700}.prose-editor-nnbsp{background:var(--_t);box-shadow:0 2px 0 0 var(--_t),0 -2px 0 0 var(--_t);position:relative}.prose-editor-nnbsp:after{content:"nnbsp";position:absolute;color:#fff;top:50%;left:50%;transform:translate(-50%,-50%);font-size:.4em;font-weight:700}.prose-editor-ensp{background:var(--_t);box-shadow:0 2px 0 0 var(--_t),0 -2px 0 0 var(--_t);position:relative}.prose-editor-ensp:after{content:"en";position:absolute;color:#fff;top:50%;left:50%;transform:translate(-50%,-50%);font-size:.5em;font-weight:700}.prose-editor-3persp{background:var(--_t);box-shadow:0 2px 0 0 var(--_t),0 -2px 0 0 var(--_t);position:relative}.prose-editor-3persp:after{content:"3/em";position:absolute;color:#fff;top:50%;left:50%;transform:translate(-50%,-50%);font-size:.4em;font-weight:700}.prose-editor-4persp{background:var(--_t);box-shadow:0 2px 0 0 var(--_t),0 -2px 0 0 var(--_t);position:relative}.prose-editor-4persp:after{content:"4/em";position:absolute;color:#fff;top:50%;left:50%;transform:translate(-50%,-50%);font-size:.4em;font-weight:700}.prose-editor-6persp{background:var(--_t);box-shadow:0 2px 0 0 var(--_t),0 -2px 0 0 var(--_t);position:relative}.prose-editor-6persp:after{content:"6/em";position:absolute;color:#fff;top:50%;left:50%;transform:translate(-50%,-50%);font-size:.4em;font-weight:700}.prose-editor-figsp{background:var(--_t);box-shadow:0 2px 0 0 var(--_t),0 -2px 0 0 var(--_t);position:relative}.prose-editor-figsp:after{content:"fig";position:absolute;color:#fff;top:50%;left:50%;transform:translate(-50%,-50%);font-size:.4em;font-weight:700}.prose-editor-psp{background:var(--_t);box-shadow:0 2px 0 0 var(--_t),0 -2px 0 0 var(--_t);position:relative}.prose-editor-psp:after{content:"punct";position:absolute;color:#fff;top:50%;left:50%;transform:translate(-50%,-50%);font-size:.4em;font-weight:700}.prose-editor-mmsp{background:var(--_t);box-shadow:0 2px 0 0 var(--_t),0 -2px 0 0 var(--_t);position:relative}.prose-editor-mmsp:after{content:"math";position:absolute;color:#fff;top:50%;left:50%;transform:translate(-50%,-50%);font-size:.4em;font-weight:700}.prose-editor-mvs{position:relative}.prose-editor-mvs:after{content:"mvs";position:absolute;color:var(--_t);top:50%;left:50%;transform:translate(-50%,-50%);font-size:.5em;font-weight:700}.prose-editor-bom{position:relative}.prose-editor-bom:after{content:"BOM";position:absolute;color:var(--_t);top:50%;left:50%;transform:translate(-50%,-50%);font-size:.5em;font-weight:700}.prose-editor-fullscreen{position:fixed!important;top:0!important;left:0!important;width:100vw!important;height:100vh!important;max-width:none!important;max-height:none!important;z-index:9999!important;margin:0!important;padding:20px!important;background:var(--_b)!important;overflow-y:auto!important;display:flex!important;flex-direction:column!important}.prose-editor-fullscreen .prose-menubar{padding:8px 20px!important;border-radius:0!important;width:100%!important}.prose-editor-fullscreen .prose-menubar--floating{position:fixed!important;top:0!important;left:0!important;right:0!important;z-index:10000!important}.prose-editor-fullscreen .ProseMirror{flex:1!important;max-height:none!important;overflow-y:auto!important;padding:1em!important;box-shadow:none!important;border:1px solid var(--_r)!important;border-radius:4px!important}.prose-menubar__button svg{display:inline-block;vertical-align:middle;width:20px;height:20px}.prose-menubar__button svg *{color:inherit}.ProseMirror .figure{display:flex;flex-direction:column;margin:1.5rem 0;max-width:100%;position:relative}.ProseMirror .figure figcaption.figure-caption{padding:.5rem 0;color:#555;font-style:italic;font-size:.9rem;text-align:center;margin-top:.5rem}.ProseMirror .figure img{max-width:100%;height:auto} diff --git a/django_prose_editor/static/django_prose_editor/editor.js b/django_prose_editor/static/django_prose_editor/editor.js index 8ad559f..f4c74a2 100644 --- a/django_prose_editor/static/django_prose_editor/editor.js +++ b/django_prose_editor/static/django_prose_editor/editor.js @@ -1,18 +1,18 @@ -var wl=Object.defineProperty,Eu=Object.defineProperties;var Ou=Object.getOwnPropertyDescriptors;var tr=Object.getOwnPropertySymbols;var Cl=Object.prototype.hasOwnProperty,Ml=Object.prototype.propertyIsEnumerable;var Sl=(n,e,t)=>e in n?wl(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,b=(n,e)=>{for(var t in e||(e={}))Cl.call(e,t)&&Sl(n,t,e[t]);if(tr)for(var t of tr(e))Ml.call(e,t)&&Sl(n,t,e[t]);return n},N=(n,e)=>Eu(n,Ou(e));var Al=(n,e)=>{var t={};for(var r in n)Cl.call(n,r)&&e.indexOf(r)<0&&(t[r]=n[r]);if(n!=null&&tr)for(var r of tr(n))e.indexOf(r)<0&&Ml.call(n,r)&&(t[r]=n[r]);return t};var rt=(n,e)=>{for(var t in e)wl(n,t,{get:e[t],enumerable:!0})};var Tl=(n,e,t)=>new Promise((r,o)=>{var i=a=>{try{l(t.next(a))}catch(c){o(c)}},s=a=>{try{l(t.throw(a))}catch(c){o(c)}},l=a=>a.done?r(a.value):Promise.resolve(a.value).then(i,s);l((t=t.apply(n,e)).next())});var ur={};rt(ur,{AllSelection:()=>ae,EditorState:()=>En,NodeSelection:()=>O,Plugin:()=>L,PluginKey:()=>j,Selection:()=>E,SelectionRange:()=>Ke,TextSelection:()=>T,Transaction:()=>dr});function le(n){this.content=n}le.prototype={constructor:le,find:function(n){for(var e=0;e>1}};le.from=function(n){if(n instanceof le)return n;var e=[];if(n)for(var t in n)e.push(t,n[t]);return new le(e)};var ei=le;function Bl(n,e,t){for(let r=0;;r++){if(r==n.childCount||r==e.childCount)return n.childCount==e.childCount?null:t;let o=n.child(r),i=e.child(r);if(o==i){t+=o.nodeSize;continue}if(!o.sameMarkup(i))return t;if(o.isText&&o.text!=i.text){for(let s=0;o.text[s]==i.text[s];s++)t++;return t}if(o.content.size||i.content.size){let s=Bl(o.content,i.content,t+1);if(s!=null)return s}t+=o.nodeSize}}function zl(n,e,t,r){for(let o=n.childCount,i=e.childCount;;){if(o==0||i==0)return o==i?null:{a:t,b:r};let s=n.child(--o),l=e.child(--i),a=s.nodeSize;if(s==l){t-=a,r-=a;continue}if(!s.sameMarkup(l))return{a:t,b:r};if(s.isText&&s.text!=l.text){let c=0,d=Math.min(s.text.length,l.text.length);for(;ce&&r(a,o+l,i||null,s)!==!1&&a.content.size){let d=l+1;a.nodesBetween(Math.max(0,e-d),Math.min(a.content.size,t-d),r,o+d)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,r,o){let i="",s=!0;return this.nodesBetween(e,t,(l,a)=>{let c=l.isText?l.text.slice(Math.max(e,a)-a,t-a):l.isLeaf?o?typeof o=="function"?o(l):o:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&c||l.isTextblock)&&r&&(s?s=!1:i+=r),i+=c},0),i}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,r=e.firstChild,o=this.content.slice(),i=0;for(t.isText&&t.sameMarkup(r)&&(o[o.length-1]=t.withText(t.text+r.text),i=1);ie)for(let i=0,s=0;se&&((st)&&(l.isText?l=l.cut(Math.max(0,e-s),Math.min(l.text.length,t-s)):l=l.cut(Math.max(0,e-s-1),Math.min(l.content.size,t-s-1))),r.push(l),o+=l.nodeSize),s=a}return new n(r,o)}cutByIndex(e,t){return e==t?n.empty:e==0&&t==this.content.length?this:new n(this.content.slice(e,t))}replaceChild(e,t){let r=this.content[e];if(r==t)return this;let o=this.content.slice(),i=this.size+t.nodeSize-r.nodeSize;return o[e]=t,new n(o,i)}addToStart(e){return new n([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new n(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;tthis.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let r=0,o=0;;r++){let i=this.child(r),s=o+i.nodeSize;if(s>=e)return s==e||t>0?nr(r+1,s):nr(r,o);o=s}}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 n.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new n(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return n.empty;let t,r=0;for(let o=0;othis.type.rank&&(t||(t=e.slice(0,o)),t.push(this),r=!0),t&&t.push(i)}}return t||(t=e.slice()),r||t.push(this),t}removeFromSet(e){for(let t=0;tr.type.rank-o.type.rank),t}};F.none=[];var ot=class extends Error{},w=class n{constructor(e,t,r){this.content=e,this.openStart=t,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let r=Hl(this.content,e+this.openStart,t);return r&&new n(r,this.openStart,this.openEnd)}removeBetween(e,t){return new n(Fl(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 n.empty;let r=t.openStart||0,o=t.openEnd||0;if(typeof r!="number"||typeof o!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new n(x.fromJSON(e,t.content),r,o)}static maxOpen(e,t=!0){let r=0,o=0;for(let i=e.firstChild;i&&!i.isLeaf&&(t||!i.type.spec.isolating);i=i.firstChild)r++;for(let i=e.lastChild;i&&!i.isLeaf&&(t||!i.type.spec.isolating);i=i.lastChild)o++;return new n(e,r,o)}};w.empty=new w(x.empty,0,0);function Fl(n,e,t){let{index:r,offset:o}=n.findIndex(e),i=n.maybeChild(r),{index:s,offset:l}=n.findIndex(t);if(o==e||i.isText){if(l!=t&&!n.child(s).isText)throw new RangeError("Removing non-flat range");return n.cut(0,e).append(n.cut(t))}if(r!=s)throw new RangeError("Removing non-flat range");return n.replaceChild(r,i.copy(Fl(i.content,e-o-1,t-o-1)))}function Hl(n,e,t,r){let{index:o,offset:i}=n.findIndex(e),s=n.maybeChild(o);if(i==e||s.isText)return r&&!r.canReplace(o,o,t)?null:n.cut(0,e).append(t).append(n.cut(e));let l=Hl(s.content,e-i-1,t);return l&&n.replaceChild(o,s.copy(l))}function vu(n,e,t){if(t.openStart>n.depth)throw new ot("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new ot("Inconsistent open depths");return $l(n,e,t,0)}function $l(n,e,t,r){let o=n.index(r),i=n.node(r);if(o==e.index(r)&&r=0&&n.isText&&n.sameMarkup(e[t])?e[t]=n.withText(e[t].text+n.text):e.push(n)}function gn(n,e,t,r){let o=(e||n).node(t),i=0,s=e?e.index(t):o.childCount;n&&(i=n.index(t),n.depth>t?i++:n.textOffset&&(wt(n.nodeAfter,r),i++));for(let l=i;lo&&ri(n,e,o+1),s=r.depth>o&&ri(t,r,o+1),l=[];return gn(null,n,o,l),i&&s&&e.index(o)==t.index(o)?(_l(i,s),wt(Ct(i,Vl(n,e,t,r,o+1)),l)):(i&&wt(Ct(i,ir(n,e,o+1)),l),gn(e,t,o,l),s&&wt(Ct(s,ir(t,r,o+1)),l)),gn(r,null,o,l),new x(l)}function ir(n,e,t){let r=[];if(gn(null,n,t,r),n.depth>t){let o=ri(n,e,t+1);wt(Ct(o,ir(n,e,t+1)),r)}return gn(e,null,t,r),new x(r)}function Nu(n,e){let t=e.depth-n.openStart,o=e.node(t).copy(n.content);for(let i=t-1;i>=0;i--)o=e.node(i).copy(x.from(o));return{start:o.resolveNoCache(n.openStart+t),end:o.resolveNoCache(o.content.size-n.openEnd-t)}}var bn=class n{constructor(e,t,r){this.pos=e,this.path=t,this.parentOffset=r,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],o=e.child(t);return r?e.child(t).cut(r):o}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let r=this.path[t*3],o=t==0?0:this.path[t*3-1]+1;for(let i=0;i0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos=0;r--)if(e.pos<=this.end(r)&&(!t||t(this.node(r))))return new it(this,e,r);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=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let r=[],o=0,i=t;for(let s=e;;){let{index:l,offset:a}=s.content.findIndex(i),c=i-a;if(r.push(s,l,o+a),!c||(s=s.child(l),s.isText))break;i=c-1,o+=a+1}return new n(t,r,i)}static resolveCached(e,t){let r=El.get(e);if(r)for(let i=0;ie&&this.nodesBetween(e,t,i=>(r.isInSet(i.marks)&&(o=!0),!o)),o}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()+")"),jl(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,r=x.empty,o=0,i=r.childCount){let s=this.contentMatchAt(e).matchFragment(r,o,i),l=s&&s.matchFragment(this.content,t);if(!l||!l.validEnd)return!1;for(let a=o;at.type.name)}`);this.content.forEach(t=>t.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(t=>t.toJSON())),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let r;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=t.marks.map(e.markFromJSON)}if(t.type=="text"){if(typeof t.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(t.text,r)}let o=x.fromJSON(e,t.content),i=e.nodeType(t.type).create(t.attrs,o,r);return i.type.checkAttrs(i.attrs),i}};he.prototype.text=void 0;var ii=class n extends he{constructor(e,t,r,o){if(super(e,t,null,o),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):jl(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 n(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new n(this.type,this.attrs,e,this.marks)}cut(e=0,t=this.text.length){return e==0&&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 jl(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}var st=class n{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let r=new si(e,t);if(r.next==null)return n.empty;let o=Wl(r);r.next&&r.err("Unexpected trailing text");let i=Hu(Fu(o));return $u(i,r),i}matchType(e){for(let t=0;tc.createAndFill()));for(let c=0;c=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(r){e.push(r);for(let o=0;o{let i=o+(r.validEnd?"*":" ")+" ";for(let s=0;s"+e.indexOf(r.next[s].next);return i}).join(` -`)}};st.empty=new st(!0);var si=class{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}};function Wl(n){let e=[];do e.push(Iu(n));while(n.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function Iu(n){let e=[];do e.push(Pu(n));while(n.next&&n.next!=")"&&n.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function Pu(n){let e=zu(n);for(;;)if(n.eat("+"))e={type:"plus",expr:e};else if(n.eat("*"))e={type:"star",expr:e};else if(n.eat("?"))e={type:"opt",expr:e};else if(n.eat("{"))e=Lu(n,e);else break;return e}function Ol(n){/\D/.test(n.next)&&n.err("Expected number, got '"+n.next+"'");let e=Number(n.next);return n.pos++,e}function Lu(n,e){let t=Ol(n),r=t;return n.eat(",")&&(n.next!="}"?r=Ol(n):r=-1),n.eat("}")||n.err("Unclosed braced range"),{type:"range",min:t,max:r,expr:e}}function Bu(n,e){let t=n.nodeTypes,r=t[e];if(r)return[r];let o=[];for(let i in t){let s=t[i];s.isInGroup(e)&&o.push(s)}return o.length==0&&n.err("No node type or group '"+e+"' found"),o}function zu(n){if(n.eat("(")){let e=Wl(n);return n.eat(")")||n.err("Missing closing paren"),e}else if(/\W/.test(n.next))n.err("Unexpected token '"+n.next+"'");else{let e=Bu(n,n.next).map(t=>(n.inline==null?n.inline=t.isInline:n.inline!=t.isInline&&n.err("Mixing inline and block content"),{type:"name",value:t}));return n.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function Fu(n){let e=[[]];return o(i(n,0),t()),e;function t(){return e.push([])-1}function r(s,l,a){let c={term:a,to:l};return e[s].push(c),c}function o(s,l){s.forEach(a=>a.to=l)}function i(s,l){if(s.type=="choice")return s.exprs.reduce((a,c)=>a.concat(i(c,l)),[]);if(s.type=="seq")for(let a=0;;a++){let c=i(s.exprs[a],l);if(a==s.exprs.length-1)return c;o(c,l=t())}else if(s.type=="star"){let a=t();return r(l,a),o(i(s.expr,a),a),[r(a)]}else if(s.type=="plus"){let a=t();return o(i(s.expr,l),a),o(i(s.expr,a),a),[r(a)]}else{if(s.type=="opt")return[r(l)].concat(i(s.expr,l));if(s.type=="range"){let a=l;for(let c=0;c{n[s].forEach(({term:l,to:a})=>{if(!l)return;let c;for(let d=0;d{c||o.push([l,c=[]]),c.indexOf(d)==-1&&c.push(d)})})});let i=e[r.join(",")]=new st(r.indexOf(n.length-1)>-1);for(let s=0;s-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:Ul(this.attrs,e)}create(e=null,t,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new he(this,this.computeAttrs(e),x.from(t),F.setFrom(r))}createChecked(e=null,t,r){return t=x.from(t),this.checkContent(t),new he(this,this.computeAttrs(e),t,F.setFrom(r))}createAndFill(e=null,t,r){if(e=this.computeAttrs(e),t=x.from(t),t.size){let s=this.contentMatch.fillBefore(t);if(!s)return null;t=s.append(t)}let o=this.contentMatch.matchFragment(t),i=o&&o.fillBefore(x.empty,!0);return i?new he(this,e,t.append(i),F.setFrom(r)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let r=0;r-1}allowsMarks(e){if(this.markSet==null)return!0;for(let t=0;tr[i]=new n(i,t,s));let o=t.spec.topNode||"doc";if(!r[o])throw new RangeError("Schema is missing its top node type ('"+o+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let i in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function _u(n,e,t){let r=t.split("|");return o=>{let i=o===null?"null":typeof o;if(r.indexOf(i)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${n}, got ${i}`)}}var li=class{constructor(e,t,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?_u(e,t,r.validate):r.validate}get isRequired(){return!this.hasDefault}},jt=class n{constructor(e,t,r,o){this.name=e,this.rank=t,this.schema=r,this.spec=o,this.attrs=Gl(e,o.attrs),this.excluded=null;let i=Jl(this.attrs);this.instance=i?new F(this,i):null}create(e=null){return!e&&this.instance?this.instance:new F(this,Ul(this.attrs,e))}static compile(e,t){let r=Object.create(null),o=0;return e.forEach((i,s)=>r[i]=new n(i,o++,t,s)),r}removeFromSet(e){for(var t=0;t-1}},Wt=class{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let o in e)t[o]=e[o];t.nodes=ei.from(e.nodes),t.marks=ei.from(e.marks||{}),this.nodes=xn.compile(this.spec.nodes,this),this.marks=jt.compile(this.spec.marks,this);let r=Object.create(null);for(let o in this.nodes){if(o in this.marks)throw new RangeError(o+" can not be both a node and a mark");let i=this.nodes[o],s=i.spec.content||"",l=i.spec.marks;if(i.contentMatch=r[s]||(r[s]=st.parse(s,this.nodes)),i.inlineContent=i.contentMatch.inlineContent,i.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!i.isInline||!i.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=i}i.markSet=l=="_"?null:l?Nl(this,l.split(" ")):l==""||!i.inlineContent?[]:null}for(let o in this.marks){let i=this.marks[o],s=i.spec.excludes;i.excluded=s==null?[i]:s==""?[]:Nl(this,s.split(" "))}this.nodeFromJSON=this.nodeFromJSON.bind(this),this.markFromJSON=this.markFromJSON.bind(this),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,r,o){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof xn){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(t,r,o)}text(e,t){let r=this.nodes.text;return new ii(r,r.defaultAttrs,e,F.setFrom(t))}mark(e,t){return typeof e=="string"&&(e=this.marks[e]),e.create(t)}nodeFromJSON(e){return he.fromJSON(this,e)}markFromJSON(e){return F.fromJSON(this,e)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}};function Nl(n,e){let t=[];for(let r=0;r-1)&&t.push(s=a)}if(!s)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return t}function Vu(n){return n.tag!=null}function ju(n){return n.style!=null}var Ne=class n{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let r=this.matchedStyles=[];t.forEach(o=>{if(Vu(o))this.tags.push(o);else if(ju(o)){let i=/[^=]*/.exec(o.style)[0];r.indexOf(i)<0&&r.push(i),this.styles.push(o)}}),this.normalizeLists=!this.tags.some(o=>{if(!/^(ul|ol)\b/.test(o.tag)||!o.node)return!1;let i=e.nodes[o.node];return i.contentMatch.matchType(i)})}parse(e,t={}){let r=new sr(this,t,!1);return r.addAll(e,F.none,t.from,t.to),r.finish()}parseSlice(e,t={}){let r=new sr(this,t,!0);return r.addAll(e,F.none,t.from,t.to),w.maxOpen(r.finish())}matchTag(e,t,r){for(let o=r?this.tags.indexOf(r)+1:0;oe.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=t))){if(s.getAttrs){let a=s.getAttrs(t);if(a===!1)continue;s.attrs=a||void 0}return s}}}static schemaRules(e){let t=[];function r(o){let i=o.priority==null?50:o.priority,s=0;for(;s{r(s=Dl(s)),s.mark||s.ignore||s.clearMark||(s.mark=o)})}for(let o in e.nodes){let i=e.nodes[o].spec.parseDOM;i&&i.forEach(s=>{r(s=Dl(s)),s.node||s.ignore||s.mark||(s.node=o)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new n(e,n.schemaRules(e)))}},Yl={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},Wu={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Ql={ol:!0,ul:!0},kn=1,ai=2,yn=4;function Rl(n,e,t){return e!=null?(e?kn:0)|(e==="full"?ai:0):n&&n.whitespace=="pre"?kn|ai:t&~yn}var Vt=class{constructor(e,t,r,o,i,s){this.type=e,this.attrs=t,this.marks=r,this.solid=o,this.options=s,this.content=[],this.activeMarks=F.none,this.match=i||(s&yn?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(x.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let r=this.type.contentMatch,o;return(o=r.findWrapping(e.type))?(this.match=r,o):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&kn)){let r=this.content[this.content.length-1],o;if(r&&r.isText&&(o=/[ \t\r\n\u000c]+$/.exec(r.text))){let i=r;r.text.length==o[0].length?this.content.pop():this.content[this.content.length-1]=i.withText(i.text.slice(0,i.text.length-o[0].length))}}let t=x.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(x.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&&!Yl.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}},sr=class{constructor(e,t,r){this.parser=e,this.options=t,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let o=t.topNode,i,s=Rl(null,t.preserveWhitespace,0)|(r?yn:0);o?i=new Vt(o.type,o.attrs,F.none,!0,t.topMatch||o.type.contentMatch,s):r?i=new Vt(null,null,F.none,!0,null,s):i=new Vt(e.schema.topNodeType,null,F.none,!0,null,s),this.nodes=[i],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){e.nodeType==3?this.addTextNode(e,t):e.nodeType==1&&this.addElement(e,t)}addTextNode(e,t){let r=e.nodeValue,o=this.top,i=o.options&ai?"full":this.localPreserveWS||(o.options&kn)>0;if(i==="full"||o.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(i)i!=="full"?r=r.replace(/\r?\n|\r/g," "):r=r.replace(/\r\n?/g,` -`);else if(r=r.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(r)&&this.open==this.nodes.length-1){let s=o.content[o.content.length-1],l=e.previousSibling;(!s||l&&l.nodeName=="BR"||s.isText&&/[ \t\r\n\u000c]$/.test(s.text))&&(r=r.slice(1))}r&&this.insertNode(this.parser.schema.text(r),t),this.findInText(e)}else this.findInside(e)}addElement(e,t,r){let o=this.localPreserveWS,i=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let s=e.nodeName.toLowerCase(),l;Ql.hasOwnProperty(s)&&this.parser.normalizeLists&&Ku(e);let a=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(l=this.parser.matchTag(e,this,r));e:if(a?a.ignore:Wu.hasOwnProperty(s))this.findInside(e),this.ignoreFallback(e,t);else if(!a||a.skip||a.closeParent){a&&a.closeParent?this.open=Math.max(0,this.open-1):a&&a.skip.nodeType&&(e=a.skip);let c,d=this.needsBlock;if(Yl.hasOwnProperty(s))i.content.length&&i.content[0].isInline&&this.open&&(this.open--,i=this.top),c=!0,i.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break e}let u=a&&a.skip?t:this.readStyles(e,t);u&&this.addAll(e,u),c&&this.sync(i),this.needsBlock=d}else{let c=this.readStyles(e,t);c&&this.addElementByRule(e,a,c,a.consuming===!1?l:void 0)}this.localPreserveWS=o}leafFallback(e,t){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(` -`),t)}ignoreFallback(e,t){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),t)}readStyles(e,t){let r=e.style;if(r&&r.length)for(let o=0;o!a.clearMark(c)):t=t.concat(this.parser.schema.marks[a.mark].create(a.attrs)),a.consuming===!1)l=a;else break}}return t}addElementByRule(e,t,r,o){let i,s;if(t.node)if(s=this.parser.schema.nodes[t.node],s.isLeaf)this.insertNode(s.create(t.attrs),r)||this.leafFallback(e,r);else{let a=this.enter(s,t.attrs||null,r,t.preserveWhitespace);a&&(i=!0,r=a)}else{let a=this.parser.schema.marks[t.mark];r=r.concat(a.create(t.attrs))}let l=this.top;if(s&&s.isLeaf)this.findInside(e);else if(o)this.addElement(e,r,o);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a,r));else{let a=e;typeof t.contentElement=="string"?a=e.querySelector(t.contentElement):typeof t.contentElement=="function"?a=t.contentElement(e):t.contentElement&&(a=t.contentElement),this.findAround(e,a,!0),this.addAll(a,r),this.findAround(e,a,!1)}i&&this.sync(l)&&this.open--}addAll(e,t,r,o){let i=r||0;for(let s=r?e.childNodes[r]:e.firstChild,l=o==null?null:e.childNodes[o];s!=l;s=s.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(s,t);this.findAtPoint(e,i)}findPlace(e,t){let r,o;for(let i=this.open;i>=0;i--){let s=this.nodes[i],l=s.findWrapping(e);if(l&&(!r||r.length>l.length)&&(r=l,o=s,!l.length)||s.solid)break}if(!r)return null;this.sync(o);for(let i=0;i(s.type?s.type.allowsMarkType(c.type):Il(c.type,e))?(a=c.addToSet(a),!1):!0),this.nodes.push(new Vt(e,t,a,o,null,l)),this.open++,r}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|=kn)}return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let r=this.nodes[t].content;for(let o=r.length-1;o>=0;o--)e+=r[o].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let r=0;r-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split("/"),r=this.options.context,o=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),i=-(r?r.depth+1:0)+(o?0:1),s=(l,a)=>{for(;l>=0;l--){let c=t[l];if(c==""){if(l==t.length-1||l==0)continue;for(;a>=i;a--)if(s(l-1,a))return!0;return!1}else{let d=a>0||a==0&&o?this.nodes[a].type:r&&a>=i?r.node(a-i).type:null;if(!d||d.name!=c&&!d.isInGroup(c))return!1;a--}}return!0};return s(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let r=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let t in this.parser.schema.nodes){let r=this.parser.schema.nodes[t];if(r.isTextblock&&r.defaultAttrs)return r}}};function Ku(n){for(let e=n.firstChild,t=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&Ql.hasOwnProperty(r)&&t?(t.appendChild(e),e=t):r=="li"?t=e:r&&(t=null)}}function Ju(n,e){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,e)}function Dl(n){let e={};for(let t in n)e[t]=n[t];return e}function Il(n,e){let t=e.schema.nodes;for(let r in t){let o=t[r];if(!o.allowsMarkType(n))continue;let i=[],s=l=>{i.push(l);for(let a=0;a{if(i.length||s.marks.length){let l=0,a=0;for(;l=0;o--){let i=this.serializeMark(e.marks[o],e.isInline,t);i&&((i.contentDOM||i.dom).appendChild(r),r=i.dom)}return r}serializeMark(e,t,r={}){let o=this.marks[e.type.name];return o&&rr(ni(r),o(e,t),null,e.attrs)}static renderSpec(e,t,r=null,o){return rr(e,t,r,o)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new n(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=Pl(e.nodes);return t.text||(t.text=r=>r.text),t}static marksFromSchema(e){return Pl(e.marks)}};function Pl(n){let e={};for(let t in n){let r=n[t].spec.toDOM;r&&(e[t]=r)}return e}function ni(n){return n.document||window.document}var Ll=new WeakMap;function Uu(n){let e=Ll.get(n);return e===void 0&&Ll.set(n,e=qu(n)),e}function qu(n){let e=null;function t(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")e||(e=[]),e.push(r);else for(let o=0;o-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=o.indexOf(" ");s>0&&(t=o.slice(0,s),o=o.slice(s+1));let l,a=t?n.createElementNS(t,o):n.createElement(o),c=e[1],d=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){d=2;for(let u in c)if(c[u]!=null){let f=u.indexOf(" ");f>0?a.setAttributeNS(u.slice(0,f),u.slice(f+1),c[u]):a.setAttribute(u,c[u])}}for(let u=d;ud)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}else{let{dom:h,contentDOM:p}=rr(n,f,t,r);if(a.appendChild(h),p){if(l)throw new RangeError("Multiple content holes");l=p}}}return{dom:a,contentDOM:l}}var ea=65535,ta=Math.pow(2,16);function Gu(n,e){return n+e*ta}function Xl(n){return n&ea}function Yu(n){return(n-(n&ea))/ta}var na=1,ra=2,lr=4,oa=8,Kt=class{constructor(e,t,r){this.pos=e,this.delInfo=t,this.recover=r}get deleted(){return(this.delInfo&oa)>0}get deletedBefore(){return(this.delInfo&(na|lr))>0}get deletedAfter(){return(this.delInfo&(ra|lr))>0}get deletedAcross(){return(this.delInfo&lr)>0}},Pe=class n{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&n.empty)return n.empty}recover(e){let t=0,r=Xl(e);if(!this.inverted)for(let o=0;oe)break;let c=this.ranges[l+i],d=this.ranges[l+s],u=a+c;if(e<=u){let f=c?e==a?-1:e==u?1:t:t,h=a+o+(f<0?0:d);if(r)return h;let p=e==(t<0?a:u)?null:Gu(l/3,e-a),m=e==a?ra:e==u?na:lr;return(t<0?e!=a:e!=u)&&(m|=oa),new Kt(h,m,p)}o+=d-c}return r?e+o:new Kt(e+o,0,null)}touches(e,t){let r=0,o=Xl(t),i=this.inverted?2:1,s=this.inverted?1:2;for(let l=0;le)break;let c=this.ranges[l+i],d=a+c;if(e<=d&&l==o*3)return!0;r+=this.ranges[l+s]-c}return!1}forEach(e){let t=this.inverted?2:1,r=this.inverted?1:2;for(let o=0,i=0;o=0;t--){let o=e.getMirror(t);this.appendMap(e._maps[t].invert(),o!=null&&o>t?r-o-1:void 0)}}invert(){let e=new n;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let r=this.from;ri&&a!s.isAtom||!l.type.allowsMarkType(this.mark.type)?s:s.mark(this.mark.addToSet(s.marks)),o),t.openStart,t.openEnd);return te.fromReplace(e,this.from,this.to,i)}invert(){return new lt(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new n(t.pos,r.pos,this.mark)}merge(e){return e instanceof n&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new n(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new n(t.from,t.to,e.markFromJSON(t.mark))}};ee.jsonID("addMark",Ut);var lt=class n extends ee{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=new w(pi(t.content,o=>o.mark(this.mark.removeFromSet(o.marks)),e),t.openStart,t.openEnd);return te.fromReplace(e,this.from,this.to,r)}invert(){return new Ut(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new n(t.pos,r.pos,this.mark)}merge(e){return e instanceof n&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new n(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new n(t.from,t.to,e.markFromJSON(t.mark))}};ee.jsonID("removeMark",lt);var qt=class n extends ee{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return te.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return te.fromReplace(e,this.pos,this.pos+1,new w(x.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let r=this.mark.addToSet(t.marks);if(r.length==t.marks.length){for(let o=0;or.pos?null:new n(t.pos,r.pos,o,i,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number"||typeof t.gapFrom!="number"||typeof t.gapTo!="number"||typeof t.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new n(t.from,t.to,t.gapFrom,t.gapTo,w.fromJSON(e,t.slice),t.insert,!!t.structure)}};ee.jsonID("replaceAround",X);function fi(n,e,t){let r=n.resolve(e),o=t-e,i=r.depth;for(;o>0&&i>0&&r.indexAfter(i)==r.node(i).childCount;)i--,o--;if(o>0){let s=r.node(i).maybeChild(r.indexAfter(i));for(;o>0;){if(!s||s.isLeaf)return!0;s=s.firstChild,o--}}return!1}function Qu(n,e,t,r){let o=[],i=[],s,l;n.doc.nodesBetween(e,t,(a,c,d)=>{if(!a.isInline)return;let u=a.marks;if(!r.isInSet(u)&&d.type.allowsMarkType(r.type)){let f=Math.max(c,e),h=Math.min(c+a.nodeSize,t),p=r.addToSet(u);for(let m=0;mn.step(a)),i.forEach(a=>n.step(a))}function Xu(n,e,t,r){let o=[],i=0;n.doc.nodesBetween(e,t,(s,l)=>{if(!s.isInline)return;i++;let a=null;if(r instanceof jt){let c=s.marks,d;for(;d=r.isInSet(c);)(a||(a=[])).push(d),c=d.removeFromSet(c)}else r?r.isInSet(s.marks)&&(a=[r]):a=s.marks;if(a&&a.length){let c=Math.min(l+s.nodeSize,t);for(let d=0;dn.step(new lt(s.from,s.to,s.style)))}function mi(n,e,t,r=t.contentMatch,o=!0){let i=n.doc.nodeAt(e),s=[],l=e+1;for(let a=0;a=0;a--)n.step(s[a])}function Zu(n,e,t){return(e==0||n.canReplace(e,n.childCount))&&(t==n.childCount||n.canReplace(0,t))}function Le(n){let t=n.parent.content.cutByIndex(n.startIndex,n.endIndex);for(let r=n.depth;;--r){let o=n.$from.node(r),i=n.$from.index(r),s=n.$to.indexAfter(r);if(rt;p--)m||r.index(p)>0?(m=!0,d=x.from(r.node(p).copy(d)),u++):a--;let f=x.empty,h=0;for(let p=i,m=!1;p>t;p--)m||o.after(p+1)=0;s--){if(r.size){let l=t[s].type.contentMatch.matchFragment(r);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=x.from(t[s].type.create(t[s].attrs,r))}let o=e.start,i=e.end;n.step(new X(o,i,o,i,new w(r,0,0),t.length,!0))}function of(n,e,t,r,o){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let i=n.steps.length;n.doc.nodesBetween(e,t,(s,l)=>{let a=typeof o=="function"?o(s):o;if(s.isTextblock&&!s.hasMarkup(r,a)&&sf(n.doc,n.mapping.slice(i).map(l),r)){let c=null;if(r.schema.linebreakReplacement){let h=r.whitespace=="pre",p=!!r.contentMatch.matchType(r.schema.linebreakReplacement);h&&!p?c=!1:!h&&p&&(c=!0)}c===!1&&sa(n,s,l,i),mi(n,n.mapping.slice(i).map(l,1),r,void 0,c===null);let d=n.mapping.slice(i),u=d.map(l,1),f=d.map(l+s.nodeSize,1);return n.step(new X(u,f,u+1,f-1,new w(x.from(r.create(a,null,s.marks)),0,0),1,!0)),c===!0&&ia(n,s,l,i),!1}})}function ia(n,e,t,r){e.forEach((o,i)=>{if(o.isText){let s,l=/\r?\n|\r/g;for(;s=l.exec(o.text);){let a=n.mapping.slice(r).map(t+1+i+s.index);n.replaceWith(a,a+1,e.type.schema.linebreakReplacement.create())}}})}function sa(n,e,t,r){e.forEach((o,i)=>{if(o.type==o.type.schema.linebreakReplacement){let s=n.mapping.slice(r).map(t+1+i);n.replaceWith(s,s+1,e.type.schema.text(` -`))}})}function sf(n,e,t){let r=n.resolve(e),o=r.index();return r.parent.canReplaceWith(o,o+1,t)}function lf(n,e,t,r,o){let i=n.doc.nodeAt(e);if(!i)throw new RangeError("No node at given position");t||(t=i.type);let s=t.create(r,null,o||i.marks);if(i.isLeaf)return n.replaceWith(e,e+i.nodeSize,s);if(!t.validContent(i.content))throw new RangeError("Invalid content for node type "+t.name);n.step(new X(e,e+i.nodeSize,e+1,e+i.nodeSize-1,new w(x.from(s),0,0),1,!0))}function ke(n,e,t=1,r){let o=n.resolve(e),i=o.depth-t,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 c=o.depth-1,d=t-2;c>i;c--,d--){let u=o.node(c),f=o.index(c);if(u.type.spec.isolating)return!1;let h=u.content.cutByIndex(f,u.childCount),p=r&&r[d+1];p&&(h=h.replaceChild(0,p.type.create(p.attrs)));let m=r&&r[d]||u;if(!u.canReplace(f+1,u.childCount)||!m.type.validContent(h))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 af(n,e,t=1,r){let o=n.doc.resolve(e),i=x.empty,s=x.empty;for(let l=o.depth,a=o.depth-t,c=t-1;l>a;l--,c--){i=x.from(o.node(l).copy(i));let d=r&&r[c];s=x.from(d?d.type.create(d.attrs,s):o.node(l).copy(s))}n.step(new oe(e,e,new w(i.append(s),t,t),!0))}function Se(n,e){let t=n.resolve(e),r=t.index();return la(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(r,r+1)}function cf(n,e){e.content.size||n.type.compatibleContent(e.type);let t=n.contentMatchAt(n.childCount),{linebreakReplacement:r}=n.type.schema;for(let o=0;o0?(i=r.node(o+1),l++,s=r.node(o).maybeChild(l)):(i=r.node(o).maybeChild(l-1),s=r.node(o+1)),i&&!i.isTextblock&&la(i,s)&&r.node(o).canReplace(l,l+1))return e;if(o==0)break;e=t<0?r.before(o):r.after(o)}}function df(n,e,t){let r=null,{linebreakReplacement:o}=n.doc.type.schema,i=n.doc.resolve(e-t),s=i.node().type;if(o&&s.inlineContent){let d=s.whitespace=="pre",u=!!s.contentMatch.matchType(o);d&&!u?r=!1:!d&&u&&(r=!0)}let l=n.steps.length;if(r===!1){let d=n.doc.resolve(e+t);sa(n,d.node(),d.before(),l)}s.inlineContent&&mi(n,e+t-1,s,i.node().contentMatchAt(i.index()),r==null);let a=n.mapping.slice(l),c=a.map(e-t);if(n.step(new oe(c,a.map(e+t,-1),w.empty,!0)),r===!0){let d=n.doc.resolve(c);ia(n,d.node(),d.before(),n.steps.length)}return n}function aa(n,e,t){let r=n.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),t))return e;if(r.parentOffset==0)for(let o=r.depth-1;o>=0;o--){let i=r.index(o);if(r.node(o).canReplaceWith(i,i,t))return r.before(o+1);if(i>0)return null}if(r.parentOffset==r.parent.content.size)for(let o=r.depth-1;o>=0;o--){let i=r.indexAfter(o);if(r.node(o).canReplaceWith(i,i,t))return r.after(o+1);if(i=0;s--){let l=s==r.depth?0:r.pos<=(r.start(s+1)+r.end(s+1))/2?-1:1,a=r.index(s)+(l>0?1:0),c=r.node(s),d=!1;if(i==1)d=c.canReplace(a,a,o);else{let u=c.contentMatchAt(a).findWrapping(o.firstChild.type);d=u&&c.canReplaceWith(a,a,u[0])}if(d)return l==0?r.pos:l<0?r.before(s+1):r.after(s+1)}return null}function Yt(n,e,t=e,r=w.empty){if(e==t&&!r.size)return null;let o=n.resolve(e),i=n.resolve(t);return ca(o,i,r)?new oe(e,t,r):new hi(o,i,r).fit()}function ca(n,e,t){return!t.openStart&&!t.openEnd&&n.start()==e.start()&&n.parent.canReplace(n.index(),e.index(),t.content)}var hi=class{constructor(e,t,r){this.$from=e,this.$to=t,this.unplaced=r,this.frontier=[],this.placed=x.empty;for(let o=0;o<=e.depth;o++){let i=e.node(o);this.frontier.push({type:i.type,match:i.contentMatchAt(e.indexAfter(o))})}for(let o=e.depth;o>0;o--)this.placed=x.from(e.node(o).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let c=this.findFittable();c?this.placeNodes(c):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,r=this.$from,o=this.close(e<0?this.$to:r.doc.resolve(e));if(!o)return null;let i=this.placed,s=r.depth,l=o.depth;for(;s&&l&&i.childCount==1;)i=i.firstChild.content,s--,l--;let a=new w(i,s,l);return e>-1?new X(r.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||r.pos!=this.$to.pos?new oe(r.pos,o.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,r=0,o=this.unplaced.openEnd;r1&&(o=0),i.type.spec.isolating&&o<=r){e=r;break}t=i.content}for(let t=1;t<=2;t++)for(let r=t==1?e:this.unplaced.openStart;r>=0;r--){let o,i=null;r?(i=di(this.unplaced.content,r-1).firstChild,o=i.content):o=this.unplaced.content;let s=o.firstChild;for(let l=this.depth;l>=0;l--){let{type:a,match:c}=this.frontier[l],d,u=null;if(t==1&&(s?c.matchType(s.type)||(u=c.fillBefore(x.from(s),!1)):i&&a.compatibleContent(i.type)))return{sliceDepth:r,frontierDepth:l,parent:i,inject:u};if(t==2&&s&&(d=c.findWrapping(s.type)))return{sliceDepth:r,frontierDepth:l,parent:i,wrap:d};if(i&&c.matchType(i.type))break}}}openMore(){let{content:e,openStart:t,openEnd:r}=this.unplaced,o=di(e,t);return!o.childCount||o.firstChild.isLeaf?!1:(this.unplaced=new w(e,t+1,Math.max(r,o.size+t>=e.size-r?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:r}=this.unplaced,o=di(e,t);if(o.childCount<=1&&t>0){let i=e.size-t<=t+o.size;this.unplaced=new w(Sn(e,t-1,1),t-1,i?t-1:r)}else this.unplaced=new w(Sn(e,t,1),t,r)}placeNodes({sliceDepth:e,frontierDepth:t,parent:r,inject:o,wrap:i}){for(;this.depth>t;)this.closeFrontierNode();if(i)for(let m=0;m1||a==0||m.content.size)&&(u=g,d.push(da(m.mark(f.allowedMarks(m.marks)),c==1?a:0,c==l.childCount?h:-1)))}let p=c==l.childCount;p||(h=-1),this.placed=wn(this.placed,t,x.from(d)),this.frontier[t].match=u,p&&h<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let m=0,g=l;m1&&o==this.$to.end(--r);)++o;return o}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:r,type:o}=this.frontier[t],i=t=0;l--){let{match:a,type:c}=this.frontier[l],d=ui(e,l,c,a,!0);if(!d||d.childCount)continue e}return{depth:t,fit:s,move:i?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=wn(this.placed,t.depth,t.fit)),e=t.move;for(let r=t.depth+1;r<=e.depth;r++){let o=e.node(r),i=o.type.contentMatch.fillBefore(o.content,!0,e.index(r));this.openFrontierNode(o.type,o.attrs,i)}return e}openFrontierNode(e,t=null,r){let o=this.frontier[this.depth];o.match=o.match.matchType(e),this.placed=wn(this.placed,this.depth,x.from(e.create(t,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(x.empty,!0);t.childCount&&(this.placed=wn(this.placed,this.frontier.length,t))}};function Sn(n,e,t){return e==0?n.cutByIndex(t,n.childCount):n.replaceChild(0,n.firstChild.copy(Sn(n.firstChild.content,e-1,t)))}function wn(n,e,t){return e==0?n.append(t):n.replaceChild(n.childCount-1,n.lastChild.copy(wn(n.lastChild.content,e-1,t)))}function di(n,e){for(let t=0;t1&&(r=r.replaceChild(0,da(r.firstChild,e-1,r.childCount==1?t-1:0))),e>0&&(r=n.type.contentMatch.fillBefore(r).append(r),t<=0&&(r=r.append(n.type.contentMatch.matchFragment(r).fillBefore(x.empty,!0)))),n.copy(r)}function ui(n,e,t,r,o){let i=n.node(e),s=o?n.indexAfter(e):n.index(e);if(s==i.childCount&&!t.compatibleContent(i.type))return null;let l=r.fillBefore(i.content,!0,s);return l&&!uf(t,i.content,s)?l:null}function uf(n,e,t){for(let r=t;r0;f--,h--){let p=o.node(f).type.spec;if(p.defining||p.definingAsContext||p.isolating)break;s.indexOf(f)>-1?l=f:o.before(f)==h&&s.splice(1,0,-f)}let a=s.indexOf(l),c=[],d=r.openStart;for(let f=r.content,h=0;;h++){let p=f.firstChild;if(c.push(p),h==r.openStart)break;f=p.content}for(let f=d-1;f>=0;f--){let h=c[f],p=ff(h.type);if(p&&!h.sameMarkup(o.node(Math.abs(l)-1)))d=f;else if(p||!h.type.isTextblock)break}for(let f=r.openStart;f>=0;f--){let h=(f+d+1)%(r.openStart+1),p=c[h];if(p)for(let m=0;m=0&&(n.replace(e,t,r),!(n.steps.length>u));f--){let h=s[f];h<0||(e=o.before(h),t=i.after(h))}}function ua(n,e,t,r,o){if(er){let i=o.contentMatchAt(0),s=i.fillBefore(n).append(n);n=s.append(i.matchFragment(s).fillBefore(x.empty,!0))}return n}function pf(n,e,t,r){if(!r.isInline&&e==t&&n.doc.resolve(e).parent.content.size){let o=aa(n.doc,e,r.type);o!=null&&(e=t=o)}n.replaceRange(e,t,new w(x.from(r),0,0))}function mf(n,e,t){let r=n.doc.resolve(e),o=n.doc.resolve(t),i=fa(r,o);for(let s=0;s0&&(a||r.node(l-1).canReplace(r.index(l-1),o.indexAfter(l-1))))return n.delete(r.before(l),o.after(l))}for(let s=1;s<=r.depth&&s<=o.depth;s++)if(e-r.start(s)==r.depth-s&&t>r.end(s)&&o.end(s)-t!=o.depth-s&&r.start(s-1)==o.start(s-1)&&r.node(s-1).canReplace(r.index(s-1),o.index(s-1)))return n.delete(r.before(s),t);n.delete(e,t)}function fa(n,e){let t=[],r=Math.min(n.depth,e.depth);for(let o=r;o>=0;o--){let i=n.start(o);if(ie.pos+(e.depth-o)||n.node(o).type.spec.isolating||e.node(o).type.spec.isolating)break;(i==e.start(o)||o==n.depth&&o==e.depth&&n.parent.inlineContent&&e.parent.inlineContent&&o&&e.start(o-1)==i-1)&&t.push(o)}return t}var Cn=class n extends ee{constructor(e,t,r){super(),this.pos=e,this.attr=t,this.value=r}apply(e){let t=e.nodeAt(this.pos);if(!t)return te.fail("No node at attribute step's position");let r=Object.create(null);for(let i in t.attrs)r[i]=t.attrs[i];r[this.attr]=this.value;let o=t.type.create(r,null,t.marks);return te.fromReplace(e,this.pos,this.pos+1,new w(x.from(o),0,t.isLeaf?0:1))}getMap(){return Pe.empty}invert(e){return new n(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 n(t.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.pos!="number"||typeof t.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new n(t.pos,t.attr,t.value)}};ee.jsonID("attr",Cn);var Mn=class n extends ee{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let o in e.attrs)t[o]=e.attrs[o];t[this.attr]=this.value;let r=e.type.create(t,e.content,e.marks);return te.ok(r)}getMap(){return Pe.empty}invert(e){return new n(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new n(t.attr,t.value)}};ee.jsonID("docAttr",Mn);var Mt=class extends Error{};Mt=function n(e){let t=Error.call(this,e);return t.__proto__=n.prototype,t};Mt.prototype=Object.create(Error.prototype);Mt.prototype.constructor=Mt;Mt.prototype.name="TransformError";var We=class{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Jt}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new Mt(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}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,r=w.empty){let o=Yt(this.doc,e,t,r);return o&&this.step(o),this}replaceWith(e,t,r){return this.replace(e,t,new w(x.from(r),0,0))}delete(e,t){return this.replace(e,t,w.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,r){return hf(this,e,t,r),this}replaceRangeWith(e,t,r){return pf(this,e,t,r),this}deleteRange(e,t){return mf(this,e,t),this}lift(e,t){return ef(this,e,t),this}join(e,t=1){return df(this,e,t),this}wrap(e,t){return rf(this,e,t),this}setBlockType(e,t=e,r,o=null){return of(this,e,t,r,o),this}setNodeMarkup(e,t,r=null,o){return lf(this,e,t,r,o),this}setNodeAttribute(e,t,r){return this.step(new Cn(e,t,r)),this}setDocAttribute(e,t){return this.step(new Mn(e,t)),this}addNodeMark(e,t){return this.step(new qt(e,t)),this}removeNodeMark(e,t){if(!(t instanceof F)){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(t=t.isInSet(r.marks),!t)return this}return this.step(new Gt(e,t)),this}split(e,t=1,r){return af(this,e,t,r),this}addMark(e,t,r){return Qu(this,e,t,r),this}removeMark(e,t,r){return Xu(this,e,t,r),this}clearIncompatible(e,t,r){return mi(this,e,t,r),this}};var gi=Object.create(null),E=class{constructor(e,t,r){this.$anchor=e,this.$head=t,this.ranges=r||[new Ke(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=0;i--){let s=t<0?Qt(e.node(0),e.node(i),e.before(i+1),e.index(i),t,r):Qt(e.node(0),e.node(i),e.after(i+1),e.index(i)+1,t,r);if(s)return s}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new ae(e.node(0))}static atStart(e){return Qt(e,e,0,0,1)||new ae(e)}static atEnd(e){return Qt(e,e,e.content.size,e.childCount,-1)||new ae(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=gi[t.type];if(!r)throw new RangeError(`No selection type ${t.type} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in gi)throw new RangeError("Duplicate use of selection JSON ID "+e);return gi[e]=t,t.prototype.jsonID=e,t}getBookmark(){return T.between(this.$anchor,this.$head).getBookmark()}};E.prototype.visible=!0;var Ke=class{constructor(e,t){this.$from=e,this.$to=t}},ha=!1;function pa(n){!ha&&!n.parent.inlineContent&&(ha=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+n.parent.type.name+")"))}var T=class n extends E{constructor(e,t=e){pa(e),pa(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let r=e.resolve(t.map(this.head));if(!r.parent.inlineContent)return E.near(r);let o=e.resolve(t.map(this.anchor));return new n(o.parent.inlineContent?o:r,r)}replace(e,t=w.empty){if(super.replace(e,t),t==w.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof n&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new cr(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if(typeof t.anchor!="number"||typeof t.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new n(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,r=t){let o=e.resolve(t);return new this(o,r==t?o:e.resolve(r))}static between(e,t,r){let o=e.pos-t.pos;if((!r||o)&&(r=o>=0?1:-1),!t.parent.inlineContent){let i=E.findFrom(t,r,!0)||E.findFrom(t,-r,!0);if(i)t=i.$head;else return E.near(t,r)}return e.parent.inlineContent||(o==0?e=t:(e=(E.findFrom(e,-r,!0)||E.findFrom(e,r,!0)).$anchor,e.pos0?0:1);o>0?s=0;s+=o){let l=e.child(s);if(l.isAtom){if(!i&&O.isSelectable(l))return O.create(n,t-(o<0?l.nodeSize:0))}else{let a=Qt(n,l,t+o,o<0?l.childCount:0,o,i);if(a)return a}t+=l.nodeSize*o}return null}function ma(n,e,t){let r=n.steps.length-1;if(r{s==null&&(s=d)}),n.setSelection(E.near(n.doc.resolve(s),t))}var ga=1,ar=2,ya=4,dr=class extends We{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.curSelectionFor0}setStoredMarks(e){return this.storedMarks=e,this.updated|=ar,this}ensureMarks(e){return F.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&ar)>0}addStep(e,t){super.addStep(e,t),this.updated=this.updated&~ar,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let r=this.selection;return t&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||F.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,r){let o=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(o.text(e),!0):this.deleteSelection();{if(r==null&&(r=t),r=r==null?t:r,!e)return this.deleteRange(t,r);let i=this.storedMarks;if(!i){let s=this.doc.resolve(t);i=r==t?s.marks():s.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(t,r,o.text(e,i)),this.selection.empty||this.setSelection(E.near(this.selection.$to)),this}}setMeta(e,t){return this.meta[typeof e=="string"?e:e.key]=t,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=ya,this}get scrolledIntoView(){return(this.updated&ya)>0}};function ba(n,e){return!e||!n?n:n.bind(e)}var Et=class{constructor(e,t,r){this.name=e,this.init=ba(t.init,r),this.apply=ba(t.apply,r)}},yf=[new Et("doc",{init(n){return n.doc||n.schema.topNodeType.createAndFill()},apply(n){return n.doc}}),new Et("selection",{init(n,e){return n.selection||E.atStart(e.doc)},apply(n){return n.selection}}),new Et("storedMarks",{init(n){return n.storedMarks||null},apply(n,e,t,r){return r.selection.$cursor?n.storedMarks:null}}),new Et("scrollToSelection",{init(){return 0},apply(n,e){return n.scrolledIntoView?e+1:e}})],Tn=class{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=yf.slice(),t&&t.forEach(r=>{if(this.pluginsByKey[r.key])throw new RangeError("Adding different instances of a keyed plugin ("+r.key+")");this.plugins.push(r),this.pluginsByKey[r.key]=r,r.spec.state&&this.fields.push(new Et(r.key,r.spec.state,r))})}},En=class n{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 r=0;rr.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let o=e[r],i=o.spec.state;i&&i.toJSON&&(t[r]=i.toJSON.call(o,this[o.key]))}return t}static fromJSON(e,t,r){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let o=new Tn(e.schema,e.plugins),i=new n(o);return o.fields.forEach(s=>{if(s.name=="doc")i.doc=he.fromJSON(e.schema,t.doc);else if(s.name=="selection")i.selection=E.fromJSON(i.doc,t.selection);else if(s.name=="storedMarks")t.storedMarks&&(i.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let l in r){let a=r[l],c=a.spec.state;if(a.key==s.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(t,l)){i[s.name]=c.fromJSON.call(a,e,t[l],i);return}}i[s.name]=s.init(e,i)}}),i}};function xa(n,e,t){for(let r in n){let o=n[r];o instanceof Function?o=o.bind(e):r=="handleDOMEvents"&&(o=xa(o,e,{})),t[r]=o}return t}var L=class{constructor(e){this.spec=e,this.props={},e.props&&xa(e.props,this,this.props),this.key=e.key?e.key.key:ka("plugin")}getState(e){return e[this.key]}},yi=Object.create(null);function ka(n){return n in yi?n+"$"+ ++yi[n]:(yi[n]=0,n+"$")}var j=class{constructor(e="key"){this.key=ka(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}};var Cr={};rt(Cr,{Decoration:()=>ne,DecorationSet:()=>q,EditorView:()=>Ln,__endComposition:()=>jh,__parseFromClipboard:()=>Vh});var ie=function(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e},nn=function(n){let e=n.assignedSlot||n.parentNode;return e&&e.nodeType==11?e.host:e},Mi=null,Ue=function(n,e,t){let r=Mi||(Mi=document.createRange());return r.setEnd(n,t==null?n.nodeValue.length:t),r.setStart(n,e||0),r},bf=function(){Mi=null},Pt=function(n,e,t,r){return t&&(Sa(n,e,t,r,-1)||Sa(n,e,t,r,1))},xf=/^(img|br|input|textarea|hr)$/i;function Sa(n,e,t,r,o){for(;;){if(n==t&&e==r)return!0;if(e==(o<0?0:Ae(n))){let i=n.parentNode;if(!i||i.nodeType!=1||Bn(n)||xf.test(n.nodeName)||n.contentEditable=="false")return!1;e=ie(n)+(o<0?0:1),n=i}else if(n.nodeType==1){if(n=n.childNodes[e+(o<0?-1:0)],n.contentEditable=="false")return!1;e=o<0?Ae(n):0}else return!1}}function Ae(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function kf(n,e){for(;;){if(n.nodeType==3&&e)return n;if(n.nodeType==1&&e>0){if(n.contentEditable=="false")return null;n=n.childNodes[e-1],e=Ae(n)}else if(n.parentNode&&!Bn(n))e=ie(n),n=n.parentNode;else return null}}function Sf(n,e){for(;;){if(n.nodeType==3&&e2),Me=rn||(Be?/Mac/.test(Be.platform):!1),Af=Be?/Win/.test(Be.platform):!1,qe=/Android \d/.test(ht),zn=!!wa&&"webkitFontSmoothing"in wa.documentElement.style,Tf=zn?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Ef(n){let e=n.defaultView&&n.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:n.documentElement.clientWidth,top:0,bottom:n.documentElement.clientHeight}}function Je(n,e){return typeof n=="number"?n:n[e]}function Of(n){let e=n.getBoundingClientRect(),t=e.width/n.offsetWidth||1,r=e.height/n.offsetHeight||1;return{left:e.left,right:e.left+n.clientWidth*t,top:e.top,bottom:e.top+n.clientHeight*r}}function Ca(n,e,t){let r=n.someProp("scrollThreshold")||0,o=n.someProp("scrollMargin")||5,i=n.dom.ownerDocument;for(let s=t||n.dom;s;){if(s.nodeType!=1){s=nn(s);continue}let l=s,a=l==i.body,c=a?Ef(i):Of(l),d=0,u=0;if(e.topc.bottom-Je(r,"bottom")&&(u=e.bottom-e.top>c.bottom-c.top?e.top+Je(o,"top")-c.top:e.bottom-c.bottom+Je(o,"bottom")),e.leftc.right-Je(r,"right")&&(d=e.right-c.right+Je(o,"right")),d||u)if(a)i.defaultView.scrollBy(d,u);else{let h=l.scrollLeft,p=l.scrollTop;u&&(l.scrollTop+=u),d&&(l.scrollLeft+=d);let m=l.scrollLeft-h,g=l.scrollTop-p;e={left:e.left-m,top:e.top-g,right:e.right-m,bottom:e.bottom-g}}let f=a?"fixed":getComputedStyle(s).position;if(/^(fixed|sticky)$/.test(f))break;s=f=="absolute"?s.offsetParent:nn(s)}}function vf(n){let e=n.dom.getBoundingClientRect(),t=Math.max(0,e.top),r,o;for(let i=(e.left+e.right)/2,s=t+1;s=t-20){r=l,o=a.top;break}}return{refDOM:r,refTop:o,stack:nc(n.dom)}}function nc(n){let e=[],t=n.ownerDocument;for(let r=n;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),n!=t);r=nn(r));return e}function Nf({refDOM:n,refTop:e,stack:t}){let r=n?n.getBoundingClientRect().top:0;rc(t,r==0?0:r-e)}function rc(n,e){for(let t=0;t=l){s=Math.max(p.bottom,s),l=Math.min(p.top,l);let m=p.left>e.left?p.left-e.left:p.right=(p.left+p.right)/2?1:0));continue}}else p.top>e.top&&!a&&p.left<=e.left&&p.right>=e.left&&(a=d,c={left:Math.max(p.left,Math.min(p.right,e.left)),top:p.top});!t&&(e.left>=p.right&&e.top>=p.top||e.left>=p.left&&e.top>=p.bottom)&&(i=u+1)}}return!t&&a&&(t=a,o=c,r=0),t&&t.nodeType==3?Df(t,o):!t||r&&t.nodeType==1?{node:n,offset:i}:oc(t,o)}function Df(n,e){let t=n.nodeValue.length,r=document.createRange();for(let o=0;o=(i.left+i.right)/2?1:0)}}return{node:n,offset:0}}function Vi(n,e){return n.left>=e.left-1&&n.left<=e.right+1&&n.top>=e.top-1&&n.top<=e.bottom+1}function If(n,e){let t=n.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left(s.left+s.right)/2?1:-1}return n.docView.posFromDOM(r,o,i)}function Lf(n,e,t,r){let o=-1;for(let i=e,s=!1;i!=n.dom;){let l=n.docView.nearestDesc(i,!0),a;if(!l)return null;if(l.dom.nodeType==1&&(l.node.isBlock&&l.parent||!l.contentDOM)&&((a=l.dom.getBoundingClientRect()).width||a.height)&&(l.node.isBlock&&l.parent&&(!s&&a.left>r.left||a.top>r.top?o=l.posBefore:(!s&&a.right-1?o:n.docView.posFromDOM(e,t,-1)}function ic(n,e,t){let r=n.childNodes.length;if(r&&t.tope.top&&o++}let c;zn&&o&&r.nodeType==1&&(c=r.childNodes[o-1]).nodeType==1&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=e.top&&o--,r==n.dom&&o==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?l=n.state.doc.content.size:(o==0||r.nodeType!=1||r.childNodes[o-1].nodeName!="BR")&&(l=Lf(n,r,o,e))}l==null&&(l=Pf(n,s,e));let a=n.docView.nearestDesc(s,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function Ma(n){return n.top=0&&o==r.nodeValue.length?(a--,d=1):t<0?a--:c++,On(at(Ue(r,a,c),d),d<0)}if(!n.state.doc.resolve(e-(i||0)).parent.inlineContent){if(i==null&&o&&(t<0||o==Ae(r))){let a=r.childNodes[o-1];if(a.nodeType==1)return xi(a.getBoundingClientRect(),!1)}if(i==null&&o=0)}if(i==null&&o&&(t<0||o==Ae(r))){let a=r.childNodes[o-1],c=a.nodeType==3?Ue(a,Ae(a)-(s?0:1)):a.nodeType==1&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(c)return On(at(c,1),!1)}if(i==null&&o=0)}function On(n,e){if(n.width==0)return n;let t=e?n.left:n.right;return{top:n.top,bottom:n.bottom,left:t,right:t}}function xi(n,e){if(n.height==0)return n;let t=e?n.top:n.bottom;return{top:t,bottom:t,left:n.left,right:n.right}}function lc(n,e,t){let r=n.state,o=n.root.activeElement;r!=e&&n.updateState(e),o!=n.dom&&n.focus();try{return t()}finally{r!=e&&n.updateState(r),o!=n.dom&&o&&o.focus()}}function Ff(n,e,t){let r=e.selection,o=t=="up"?r.$from:r.$to;return lc(n,e,()=>{let{node:i}=n.docView.domFromPos(o.pos,t=="up"?-1:1);for(;;){let l=n.docView.nearestDesc(i,!0);if(!l)break;if(l.node.isBlock){i=l.contentDOM||l.dom;break}i=l.dom.parentNode}let s=sc(n,o.pos,1);for(let l=i.firstChild;l;l=l.nextSibling){let a;if(l.nodeType==1)a=l.getClientRects();else if(l.nodeType==3)a=Ue(l,0,l.nodeValue.length).getClientRects();else continue;for(let c=0;cd.top+1&&(t=="up"?s.top-d.top>(d.bottom-s.top)*2:d.bottom-s.bottom>(s.bottom-d.top)*2))return!1}}return!0})}var Hf=/[\u0590-\u08ac]/;function $f(n,e,t){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let o=r.parentOffset,i=!o,s=o==r.parent.content.size,l=n.domSelection();return l?!Hf.test(r.parent.textContent)||!l.modify?t=="left"||t=="backward"?i:s:lc(n,e,()=>{let{focusNode:a,focusOffset:c,anchorNode:d,anchorOffset:u}=n.domSelectionRange(),f=l.caretBidiLevel;l.modify("move",t,"character");let h=r.depth?n.docView.domAfterPos(r.before()):n.dom,{focusNode:p,focusOffset:m}=n.domSelectionRange(),g=p&&!h.contains(p.nodeType==1?p:p.parentNode)||a==p&&c==m;try{l.collapse(d,u),a&&(a!=d||c!=u)&&l.extend&&l.extend(a,c)}catch(y){}return f!=null&&(l.caretBidiLevel=f),g}):r.pos==r.start()||r.pos==r.end()}var Aa=null,Ta=null,Ea=!1;function _f(n,e,t){return Aa==e&&Ta==t?Ea:(Aa=e,Ta=t,Ea=t=="up"||t=="down"?Ff(n,e,t):$f(n,e,t))}var Te=0,Oa=1,vt=2,ze=3,Lt=class{constructor(e,t,r,o){this.parent=e,this.children=t,this.dom=r,this.contentDOM=o,this.dirty=Te,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,r){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;tie(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))o=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(t==0)for(let i=e;;i=i.parentNode){if(i==this.dom){o=!1;break}if(i.previousSibling)break}if(o==null&&t==e.childNodes.length)for(let i=e;;i=i.parentNode){if(i==this.dom){o=!0;break}if(i.nextSibling)break}}return(o==null?r>0:o)?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let r=!0,o=e;o;o=o.parentNode){let i=this.getDesc(o),s;if(i&&(!t||i.node))if(r&&(s=i.nodeDOM)&&!(s.nodeType==1?s.contains(e.nodeType==1?e:e.parentNode):s==e))r=!1;else return i}}getDesc(e){let t=e.pmViewDesc;for(let r=t;r;r=r.parent)if(r==this)return t}posFromDOM(e,t,r){for(let o=e;o;o=o.parentNode){let i=this.getDesc(o);if(i)return i.localPosFromDOM(e,t,r)}return-1}descAt(e){for(let t=0,r=0;te||s instanceof pr){o=e-i;break}i=l}if(o)return this.children[r].domFromPos(o-this.children[r].border,t);for(let i;r&&!(i=this.children[r-1]).size&&i instanceof fr&&i.side>=0;r--);if(t<=0){let i,s=!0;for(;i=r?this.children[r-1]:null,!(!i||i.dom.parentNode==this.contentDOM);r--,s=!1);return i&&t&&s&&!i.border&&!i.domAtom?i.domFromPos(i.size,t):{node:this.contentDOM,offset:i?ie(i.dom)+1:0}}else{let i,s=!0;for(;i=r=d&&t<=c-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,t,d);e=s;for(let u=l;u>0;u--){let f=this.children[u-1];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(1)){o=ie(f.dom)+1;break}e-=f.size}o==-1&&(o=0)}if(o>-1&&(c>t||l==this.children.length-1)){t=c;for(let d=l+1;dp&&st){let p=l;l=a,a=p}let h=document.createRange();h.setEnd(a.node,a.offset),h.setStart(l.node,l.offset),c.removeAllRanges(),c.addRange(h)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let r=0,o=0;o=r:er){let l=r+i.border,a=s-i.border;if(e>=l&&t<=a){this.dirty=e==r||t==s?vt:Oa,e==l&&t==a&&(i.contentLost||i.dom.parentNode!=this.contentDOM)?i.dirty=ze:i.markDirty(e-l,t-l);return}else i.dirty=i.dom==i.contentDOM&&i.dom.parentNode==this.contentDOM&&!i.children.length?vt:ze}r=s}this.dirty=vt}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let r=e==1?vt:Oa;t.dirty{if(!i)return o;if(i.parent)return i.parent.posBeforeChild(i)})),!t.type.spec.raw){if(s.nodeType!=1){let l=document.createElement("span");l.appendChild(s),s=l}s.contentEditable="false",s.classList.add("ProseMirror-widget")}super(e,[],s,null),this.widget=t,this.widget=t,i=this}matchesWidget(e){return this.dirty==Te&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return t?t(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get side(){return this.widget.type.side}},Oi=class extends Lt{constructor(e,t,r,o){super(e,[],t,null),this.textDOM=r,this.text=o}get size(){return this.text.length}localPosFromDOM(e,t){return e!=this.textDOM?this.posAtStart+(t?this.size:0):this.posAtStart+t}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}},on=class n extends Lt{constructor(e,t,r,o,i){super(e,[],r,o),this.mark=t,this.spec=i}static create(e,t,r,o){let i=o.nodeViews[t.type.name],s=i&&i(t,o,r);return(!s||!s.dom)&&(s=Ie.renderSpec(document,t.type.spec.toDOM(t,r),null,t.attrs)),new n(e,t,s.dom,s.contentDOM||s.dom,s)}parseRule(){return this.dirty&ze||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=ze&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=Te){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty0&&(i=Di(i,0,e,r));for(let l=0;l{if(!a)return s;if(a.parent)return a.parent.posBeforeChild(a)},r,o),d=c&&c.dom,u=c&&c.contentDOM;if(t.isText){if(!d)d=document.createTextNode(t.text);else if(d.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else d||({dom:d,contentDOM:u}=Ie.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs));!u&&!t.isText&&d.nodeName!="BR"&&(d.hasAttribute("contenteditable")||(d.contentEditable="false"),t.type.spec.draggable&&(d.draggable=!0));let f=d;return d=dc(d,r,t),c?a=new vi(e,t,r,o,d,u||null,f,c,i,s+1):t.isText?new hr(e,t,r,o,d,f,i):new n(e,t,r,o,d,u||null,f,i,s+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(e.preserveWhitespace="full"),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let t=this.children.length-1;t>=0;t--){let r=this.children[t];if(this.dom.contains(r.dom.parentNode)){e.contentElement=r.dom.parentNode;break}}e.contentElement||(e.getContent=()=>x.empty)}return e}matchesNode(e,t,r){return this.dirty==Te&&e.eq(this.node)&&mr(t,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let r=this.node.inlineContent,o=t,i=e.composing?this.localCompositionInfo(e,t):null,s=i&&i.pos>-1?i:null,l=i&&i.pos<0,a=new Ri(this,s&&s.node,e);Kf(this.node,this.innerDeco,(c,d,u)=>{c.spec.marks?a.syncToMarks(c.spec.marks,r,e):c.type.side>=0&&!u&&a.syncToMarks(d==this.node.childCount?F.none:this.node.child(d).marks,r,e),a.placeWidget(c,e,o)},(c,d,u,f)=>{a.syncToMarks(c.marks,r,e);let h;a.findNodeMatch(c,d,u,f)||l&&e.state.selection.from>o&&e.state.selection.to-1&&a.updateNodeAt(c,d,u,h,e)||a.updateNextNode(c,d,u,e,f,o)||a.addNode(c,d,u,e,o),o+=c.nodeSize}),a.syncToMarks([],r,e),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==vt)&&(s&&this.protectLocalComposition(e,s),ac(this.contentDOM,this.children,e),rn&&Jf(this.dom))}localCompositionInfo(e,t){let{from:r,to:o}=e.state.selection;if(!(e.state.selection instanceof T)||rt+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 s=i.nodeValue,l=Uf(this.node.content,s,r-t,o-t);return l<0?null:{node:i,pos:l,text:s}}else return{node:i,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:r,text:o}){if(this.getDesc(t))return;let i=t;for(;i.parentNode!=this.contentDOM;i=i.parentNode){for(;i.previousSibling;)i.parentNode.removeChild(i.previousSibling);for(;i.nextSibling;)i.parentNode.removeChild(i.nextSibling);i.pmViewDesc&&(i.pmViewDesc=void 0)}let s=new Oi(this,i,t,o);e.input.compositionNodes.push(s),this.children=Di(this.children,r,r+o.length,e,s)}update(e,t,r,o){return this.dirty==ze||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,r,o),!0)}updateInner(e,t,r,o){this.updateOuterDeco(t),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(o,this.posAtStart),this.dirty=Te}updateOuterDeco(e){if(mr(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=cc(this.dom,this.nodeDOM,Ni(this.outerDeco,this.node,t),Ni(e,this.node,t)),this.dom!=r&&(r.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.dom.draggable=!0)}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.dom.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}};function va(n,e,t,r,o){dc(r,e,n);let i=new ft(void 0,n,e,t,r,r,r,o,0);return i.contentDOM&&i.updateChildren(o,0),i}var hr=class n extends ft{constructor(e,t,r,o,i,s,l){super(e,t,r,o,i,null,s,l,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,r,o){return this.dirty==ze||this.dirty!=Te&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=Te||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,o.trackWrites==this.nodeDOM&&(o.trackWrites=null)),this.node=e,this.dirty=Te,!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,r){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,t,r){let o=this.node.cut(e,t),i=document.createTextNode(o.text);return new n(this.parent,o,this.outerDeco,this.innerDeco,i,i,r)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=ze)}get domAtom(){return!1}isText(e){return this.node.text==e}},pr=class extends Lt{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==Te&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}},vi=class extends ft{constructor(e,t,r,o,i,s,l,a,c,d){super(e,t,r,o,i,s,l,c,d),this.spec=a}update(e,t,r,o){if(this.dirty==ze)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let i=this.spec.update(e,t,r);return i&&this.updateInner(e,t,r,o),i}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,t,r,o)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,r,o){this.spec.setSelection?this.spec.setSelection(e,t,r.root):super.setSelection(e,t,r,o)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}};function ac(n,e,t){let r=n.firstChild,o=!1;for(let i=0;i>1,s=Math.min(i,e.length);for(;o-1)l>this.index&&(this.changed=!0,this.destroyBetween(this.index,l)),this.top=this.top.children[this.index];else{let a=on.create(this.top,e[i],t,r);this.top.children.splice(this.index,0,a),this.top=a,this.changed=!0}this.index=0,i++}}findNodeMatch(e,t,r,o){let i=-1,s;if(o>=this.preMatch.index&&(s=this.preMatch.matches[o-this.preMatch.index]).parent==this.top&&s.matchesNode(e,t,r))i=this.top.children.indexOf(s,this.index);else for(let l=this.index,a=Math.min(this.top.children.length,l+5);l0;){let l;for(;;)if(r){let c=t.children[r-1];if(c instanceof on)t=c,r=c.children.length;else{l=c,r--;break}}else{if(t==e)break e;r=t.parent.children.indexOf(t),t=t.parent}let a=l.node;if(a){if(a!=n.child(o-1))break;--o,i.set(l,o),s.push(l)}}return{index:o,matched:i,matches:s.reverse()}}function Wf(n,e){return n.type.side-e.type.side}function Kf(n,e,t,r){let o=e.locals(n),i=0;if(o.length==0){for(let c=0;ci;)l.push(o[s++]);let p=i+f.nodeSize;if(f.isText){let g=p;s!g.inline):l.slice();r(f,m,e.forChild(i,f),h),i=p}}function Jf(n){if(n.nodeName=="UL"||n.nodeName=="OL"){let e=n.style.cssText;n.style.cssText=e+"; list-style: square !important",window.getComputedStyle(n).listStyle,n.style.cssText=e}}function Uf(n,e,t,r){for(let o=0,i=0;o=t){if(i>=r&&a.slice(r-e.length-l,r-l)==e)return r-e.length;let c=l=0&&c+e.length+l>=t)return l+c;if(t==r&&a.length>=r+e.length-l&&a.slice(r-l,r-l+e.length)==e)return r}}return-1}function Di(n,e,t,r,o){let i=[];for(let s=0,l=0;s=t||d<=e?i.push(a):(ct&&i.push(a.slice(t-c,a.size,r)))}return i}function ji(n,e=null){let t=n.domSelectionRange(),r=n.state.doc;if(!t.focusNode)return null;let o=n.docView.nearestDesc(t.focusNode),i=o&&o.size==0,s=n.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(s<0)return null;let l=r.resolve(s),a,c;if(Sr(t)){for(a=s;o&&!o.node;)o=o.parent;let u=o.node;if(o&&u.isAtom&&O.isSelectable(u)&&o.parent&&!(u.isInline&&wf(t.focusNode,t.focusOffset,o.dom))){let f=o.posBefore;c=new O(s==f?l:r.resolve(f))}}else{if(t instanceof n.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let u=s,f=s;for(let h=0;h{(t.anchorNode!=r||t.anchorOffset!=o)&&(e.removeEventListener("selectionchange",n.input.hideSelectionGuard),setTimeout(()=>{(!uc(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function Gf(n){let e=n.domSelection(),t=document.createRange();if(!e)return;let r=n.cursorWrapper.dom,o=r.nodeName=="IMG";o?t.setStart(r.parentNode,ie(r)+1):t.setStart(r,0),t.collapse(!0),e.removeAllRanges(),e.addRange(t),!o&&!n.state.selection.visible&&ye&&ut<=11&&(r.disabled=!0,r.disabled=!1)}function fc(n,e){if(e instanceof O){let t=n.docView.descAt(e.from);t!=n.lastSelectedViewDesc&&(Pa(n),t&&t.selectNode(),n.lastSelectedViewDesc=t)}else Pa(n)}function Pa(n){n.lastSelectedViewDesc&&(n.lastSelectedViewDesc.parent&&n.lastSelectedViewDesc.deselectNode(),n.lastSelectedViewDesc=void 0)}function Wi(n,e,t,r){return n.someProp("createSelectionBetween",o=>o(n,e,t))||T.between(e,t,r)}function La(n){return n.editable&&!n.hasFocus()?!1:hc(n)}function hc(n){let e=n.domSelectionRange();if(!e.anchorNode)return!1;try{return n.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(n.editable||n.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch(t){return!1}}function Yf(n){let e=n.docView.domFromPos(n.state.selection.anchor,0),t=n.domSelectionRange();return Pt(e.node,e.offset,t.anchorNode,t.anchorOffset)}function Ii(n,e){let{$anchor:t,$head:r}=n.selection,o=e>0?t.max(r):t.min(r),i=o.parent.inlineContent?o.depth?n.doc.resolve(e>0?o.after():o.before()):null:o;return i&&E.findFrom(i,e)}function ct(n,e){return n.dispatch(n.state.tr.setSelection(e).scrollIntoView()),!0}function Ba(n,e,t){let r=n.state.selection;if(r instanceof T)if(t.indexOf("s")>-1){let{$head:o}=r,i=o.textOffset?null:e<0?o.nodeBefore:o.nodeAfter;if(!i||i.isText||!i.isLeaf)return!1;let s=n.state.doc.resolve(o.pos+i.nodeSize*(e<0?-1:1));return ct(n,new T(r.$anchor,s))}else if(r.empty){if(n.endOfTextblock(e>0?"forward":"backward")){let o=Ii(n.state,e);return o&&o instanceof O?ct(n,o):!1}else if(!(Me&&t.indexOf("m")>-1)){let o=r.$head,i=o.textOffset?null:e<0?o.nodeBefore:o.nodeAfter,s;if(!i||i.isText)return!1;let l=e<0?o.pos-i.nodeSize:o.pos;return i.isAtom||(s=n.docView.descAt(l))&&!s.contentDOM?O.isSelectable(i)?ct(n,new O(e<0?n.state.doc.resolve(o.pos-i.nodeSize):o)):zn?ct(n,new T(n.state.doc.resolve(e<0?l:l+i.nodeSize))):!1:!1}}else return!1;else{if(r instanceof O&&r.node.isInline)return ct(n,new T(e>0?r.$to:r.$from));{let o=Ii(n.state,e);return o?ct(n,o):!1}}}function gr(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Nn(n,e){let t=n.pmViewDesc;return t&&t.size==0&&(e<0||n.nextSibling||n.nodeName!="BR")}function Zt(n,e){return e<0?Qf(n):Xf(n)}function Qf(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let o,i,s=!1;for(Re&&t.nodeType==1&&r0){if(t.nodeType!=1)break;{let l=t.childNodes[r-1];if(Nn(l,-1))o=t,i=--r;else if(l.nodeType==3)t=l,r=t.nodeValue.length;else break}}else{if(pc(t))break;{let l=t.previousSibling;for(;l&&Nn(l,-1);)o=t.parentNode,i=ie(l),l=l.previousSibling;if(l)t=l,r=gr(t);else{if(t=t.parentNode,t==n.dom)break;r=0}}}s?Pi(n,t,r):o&&Pi(n,o,i)}function Xf(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let o=gr(t),i,s;for(;;)if(r{n.state==o&&Ge(n)},50)}function za(n,e){let t=n.state.doc.resolve(e);if(!(de||Af)&&t.parent.inlineContent){let o=n.coordsAtPos(e);if(e>t.start()){let i=n.coordsAtPos(e-1),s=(i.top+i.bottom)/2;if(s>o.top&&s1)return i.lefto.top&&s1)return i.left>o.left?"ltr":"rtl"}}return getComputedStyle(n.dom).direction=="rtl"?"rtl":"ltr"}function Fa(n,e,t){let r=n.state.selection;if(r instanceof T&&!r.empty||t.indexOf("s")>-1||Me&&t.indexOf("m")>-1)return!1;let{$from:o,$to:i}=r;if(!o.parent.inlineContent||n.endOfTextblock(e<0?"up":"down")){let s=Ii(n.state,e);if(s&&s instanceof O)return ct(n,s)}if(!o.parent.inlineContent){let s=e<0?o:i,l=r instanceof ae?E.near(s,e):E.findFrom(s,e);return l?ct(n,l):!1}return!1}function Ha(n,e){if(!(n.state.selection instanceof T))return!0;let{$head:t,$anchor:r,empty:o}=n.state.selection;if(!t.sameParent(r))return!0;if(!o)return!1;if(n.endOfTextblock(e>0?"forward":"backward"))return!0;let i=!t.textOffset&&(e<0?t.nodeBefore:t.nodeAfter);if(i&&!i.isText){let s=n.state.tr;return e<0?s.delete(t.pos-i.nodeSize,t.pos):s.delete(t.pos,t.pos+i.nodeSize),n.dispatch(s),!0}return!1}function $a(n,e,t){n.domObserver.stop(),e.contentEditable=t,n.domObserver.start()}function th(n){if(!pe||n.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:t}=n.domSelectionRange();if(e&&e.nodeType==1&&t==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let r=e.firstChild;$a(n,r,"true"),setTimeout(()=>$a(n,r,"false"),20)}return!1}function nh(n){let e="";return n.ctrlKey&&(e+="c"),n.metaKey&&(e+="m"),n.altKey&&(e+="a"),n.shiftKey&&(e+="s"),e}function rh(n,e){let t=e.keyCode,r=nh(e);if(t==8||Me&&t==72&&r=="c")return Ha(n,-1)||Zt(n,-1);if(t==46&&!e.shiftKey||Me&&t==68&&r=="c")return Ha(n,1)||Zt(n,1);if(t==13||t==27)return!0;if(t==37||Me&&t==66&&r=="c"){let o=t==37?za(n,n.state.selection.from)=="ltr"?-1:1:-1;return Ba(n,o,r)||Zt(n,o)}else if(t==39||Me&&t==70&&r=="c"){let o=t==39?za(n,n.state.selection.from)=="ltr"?1:-1:1;return Ba(n,o,r)||Zt(n,o)}else{if(t==38||Me&&t==80&&r=="c")return Fa(n,-1,r)||Zt(n,-1);if(t==40||Me&&t==78&&r=="c")return th(n)||Fa(n,1,r)||Zt(n,1);if(r==(Me?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function Ki(n,e){n.someProp("transformCopied",h=>{e=h(e,n)});let t=[],{content:r,openStart:o,openEnd:i}=e;for(;o>1&&i>1&&r.childCount==1&&r.firstChild.childCount==1;){o--,i--;let h=r.firstChild;t.push(h.type.name,h.attrs!=h.type.defaultAttrs?h.attrs:null),r=h.content}let s=n.someProp("clipboardSerializer")||Ie.fromSchema(n.state.schema),l=xc(),a=l.createElement("div");a.appendChild(s.serializeFragment(r,{document:l}));let c=a.firstChild,d,u=0;for(;c&&c.nodeType==1&&(d=bc[c.nodeName.toLowerCase()]);){for(let h=d.length-1;h>=0;h--){let p=l.createElement(d[h]);for(;a.firstChild;)p.appendChild(a.firstChild);a.appendChild(p),u++}c=a.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${o} ${i}${u?` -${u}`:""} ${JSON.stringify(t)}`);let f=n.someProp("clipboardTextSerializer",h=>h(e,n))||e.content.textBetween(0,e.content.size,` +var Cl=Object.defineProperty,vu=Object.defineProperties;var Ou=Object.getOwnPropertyDescriptors;var tr=Object.getOwnPropertySymbols;var Ml=Object.prototype.hasOwnProperty,Tl=Object.prototype.propertyIsEnumerable;var Sl=(n,e,t)=>e in n?Cl(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,b=(n,e)=>{for(var t in e||(e={}))Ml.call(e,t)&&Sl(n,t,e[t]);if(tr)for(var t of tr(e))Tl.call(e,t)&&Sl(n,t,e[t]);return n},N=(n,e)=>vu(n,Ou(e));var Al=(n,e)=>{var t={};for(var r in n)Ml.call(n,r)&&e.indexOf(r)<0&&(t[r]=n[r]);if(n!=null&&tr)for(var r of tr(n))e.indexOf(r)<0&&Tl.call(n,r)&&(t[r]=n[r]);return t};var rt=(n,e)=>{for(var t in e)Cl(n,t,{get:e[t],enumerable:!0})};var El=(n,e,t)=>new Promise((r,o)=>{var i=a=>{try{l(t.next(a))}catch(c){o(c)}},s=a=>{try{l(t.throw(a))}catch(c){o(c)}},l=a=>a.done?r(a.value):Promise.resolve(a.value).then(i,s);l((t=t.apply(n,e)).next())});var ur={};rt(ur,{AllSelection:()=>ae,EditorState:()=>En,NodeSelection:()=>v,Plugin:()=>L,PluginKey:()=>j,Selection:()=>E,SelectionRange:()=>Ke,TextSelection:()=>A,Transaction:()=>dr});function le(n){this.content=n}le.prototype={constructor:le,find:function(n){for(var e=0;e>1}};le.from=function(n){if(n instanceof le)return n;var e=[];if(n)for(var t in n)e.push(t,n[t]);return new le(e)};var ei=le;function Bl(n,e,t){for(let r=0;;r++){if(r==n.childCount||r==e.childCount)return n.childCount==e.childCount?null:t;let o=n.child(r),i=e.child(r);if(o==i){t+=o.nodeSize;continue}if(!o.sameMarkup(i))return t;if(o.isText&&o.text!=i.text){for(let s=0;o.text[s]==i.text[s];s++)t++;return t}if(o.content.size||i.content.size){let s=Bl(o.content,i.content,t+1);if(s!=null)return s}t+=o.nodeSize}}function Fl(n,e,t,r){for(let o=n.childCount,i=e.childCount;;){if(o==0||i==0)return o==i?null:{a:t,b:r};let s=n.child(--o),l=e.child(--i),a=s.nodeSize;if(s==l){t-=a,r-=a;continue}if(!s.sameMarkup(l))return{a:t,b:r};if(s.isText&&s.text!=l.text){let c=0,d=Math.min(s.text.length,l.text.length);for(;ce&&r(a,o+l,i||null,s)!==!1&&a.content.size){let d=l+1;a.nodesBetween(Math.max(0,e-d),Math.min(a.content.size,t-d),r,o+d)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,r,o){let i="",s=!0;return this.nodesBetween(e,t,(l,a)=>{let c=l.isText?l.text.slice(Math.max(e,a)-a,t-a):l.isLeaf?o?typeof o=="function"?o(l):o:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&c||l.isTextblock)&&r&&(s?s=!1:i+=r),i+=c},0),i}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,r=e.firstChild,o=this.content.slice(),i=0;for(t.isText&&t.sameMarkup(r)&&(o[o.length-1]=t.withText(t.text+r.text),i=1);ie)for(let i=0,s=0;se&&((st)&&(l.isText?l=l.cut(Math.max(0,e-s),Math.min(l.text.length,t-s)):l=l.cut(Math.max(0,e-s-1),Math.min(l.content.size,t-s-1))),r.push(l),o+=l.nodeSize),s=a}return new n(r,o)}cutByIndex(e,t){return e==t?n.empty:e==0&&t==this.content.length?this:new n(this.content.slice(e,t))}replaceChild(e,t){let r=this.content[e];if(r==t)return this;let o=this.content.slice(),i=this.size+t.nodeSize-r.nodeSize;return o[e]=t,new n(o,i)}addToStart(e){return new n([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new n(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;tthis.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let r=0,o=0;;r++){let i=this.child(r),s=o+i.nodeSize;if(s>=e)return s==e||t>0?nr(r+1,s):nr(r,o);o=s}}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 n.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new n(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return n.empty;let t,r=0;for(let o=0;othis.type.rank&&(t||(t=e.slice(0,o)),t.push(this),r=!0),t&&t.push(i)}}return t||(t=e.slice()),r||t.push(this),t}removeFromSet(e){for(let t=0;tr.type.rank-o.type.rank),t}};F.none=[];var ot=class extends Error{},S=class n{constructor(e,t,r){this.content=e,this.openStart=t,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let r=$l(this.content,e+this.openStart,t);return r&&new n(r,this.openStart,this.openEnd)}removeBetween(e,t){return new n(Hl(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 n.empty;let r=t.openStart||0,o=t.openEnd||0;if(typeof r!="number"||typeof o!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new n(x.fromJSON(e,t.content),r,o)}static maxOpen(e,t=!0){let r=0,o=0;for(let i=e.firstChild;i&&!i.isLeaf&&(t||!i.type.spec.isolating);i=i.firstChild)r++;for(let i=e.lastChild;i&&!i.isLeaf&&(t||!i.type.spec.isolating);i=i.lastChild)o++;return new n(e,r,o)}};S.empty=new S(x.empty,0,0);function Hl(n,e,t){let{index:r,offset:o}=n.findIndex(e),i=n.maybeChild(r),{index:s,offset:l}=n.findIndex(t);if(o==e||i.isText){if(l!=t&&!n.child(s).isText)throw new RangeError("Removing non-flat range");return n.cut(0,e).append(n.cut(t))}if(r!=s)throw new RangeError("Removing non-flat range");return n.replaceChild(r,i.copy(Hl(i.content,e-o-1,t-o-1)))}function $l(n,e,t,r){let{index:o,offset:i}=n.findIndex(e),s=n.maybeChild(o);if(i==e||s.isText)return r&&!r.canReplace(o,o,t)?null:n.cut(0,e).append(t).append(n.cut(e));let l=$l(s.content,e-i-1,t);return l&&n.replaceChild(o,s.copy(l))}function Nu(n,e,t){if(t.openStart>n.depth)throw new ot("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new ot("Inconsistent open depths");return _l(n,e,t,0)}function _l(n,e,t,r){let o=n.index(r),i=n.node(r);if(o==e.index(r)&&r=0&&n.isText&&n.sameMarkup(e[t])?e[t]=n.withText(e[t].text+n.text):e.push(n)}function gn(n,e,t,r){let o=(e||n).node(t),i=0,s=e?e.index(t):o.childCount;n&&(i=n.index(t),n.depth>t?i++:n.textOffset&&(St(n.nodeAfter,r),i++));for(let l=i;lo&&ri(n,e,o+1),s=r.depth>o&&ri(t,r,o+1),l=[];return gn(null,n,o,l),i&&s&&e.index(o)==t.index(o)?(Vl(i,s),St(Ct(i,jl(n,e,t,r,o+1)),l)):(i&&St(Ct(i,ir(n,e,o+1)),l),gn(e,t,o,l),s&&St(Ct(s,ir(t,r,o+1)),l)),gn(r,null,o,l),new x(l)}function ir(n,e,t){let r=[];if(gn(null,n,t,r),n.depth>t){let o=ri(n,e,t+1);St(Ct(o,ir(n,e,t+1)),r)}return gn(e,null,t,r),new x(r)}function Ru(n,e){let t=e.depth-n.openStart,o=e.node(t).copy(n.content);for(let i=t-1;i>=0;i--)o=e.node(i).copy(x.from(o));return{start:o.resolveNoCache(n.openStart+t),end:o.resolveNoCache(o.content.size-n.openEnd-t)}}var bn=class n{constructor(e,t,r){this.pos=e,this.path=t,this.parentOffset=r,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],o=e.child(t);return r?e.child(t).cut(r):o}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let r=this.path[t*3],o=t==0?0:this.path[t*3-1]+1;for(let i=0;i0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos=0;r--)if(e.pos<=this.end(r)&&(!t||t(this.node(r))))return new it(this,e,r);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=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let r=[],o=0,i=t;for(let s=e;;){let{index:l,offset:a}=s.content.findIndex(i),c=i-a;if(r.push(s,l,o+a),!c||(s=s.child(l),s.isText))break;i=c-1,o+=a+1}return new n(t,r,i)}static resolveCached(e,t){let r=vl.get(e);if(r)for(let i=0;ie&&this.nodesBetween(e,t,i=>(r.isInSet(i.marks)&&(o=!0),!o)),o}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()+")"),Wl(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,r=x.empty,o=0,i=r.childCount){let s=this.contentMatchAt(e).matchFragment(r,o,i),l=s&&s.matchFragment(this.content,t);if(!l||!l.validEnd)return!1;for(let a=o;at.type.name)}`);this.content.forEach(t=>t.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(t=>t.toJSON())),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let r;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=t.marks.map(e.markFromJSON)}if(t.type=="text"){if(typeof t.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(t.text,r)}let o=x.fromJSON(e,t.content),i=e.nodeType(t.type).create(t.attrs,o,r);return i.type.checkAttrs(i.attrs),i}};pe.prototype.text=void 0;var ii=class n extends pe{constructor(e,t,r,o){if(super(e,t,null,o),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):Wl(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 n(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new n(this.type,this.attrs,e,this.marks)}cut(e=0,t=this.text.length){return e==0&&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 Wl(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}var st=class n{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let r=new si(e,t);if(r.next==null)return n.empty;let o=Kl(r);r.next&&r.err("Unexpected trailing text");let i=$u(Hu(o));return _u(i,r),i}matchType(e){for(let t=0;tc.createAndFill()));for(let c=0;c=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(r){e.push(r);for(let o=0;o{let i=o+(r.validEnd?"*":" ")+" ";for(let s=0;s"+e.indexOf(r.next[s].next);return i}).join(` +`)}};st.empty=new st(!0);var si=class{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}};function Kl(n){let e=[];do e.push(Pu(n));while(n.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function Pu(n){let e=[];do e.push(Lu(n));while(n.next&&n.next!=")"&&n.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function Lu(n){let e=Fu(n);for(;;)if(n.eat("+"))e={type:"plus",expr:e};else if(n.eat("*"))e={type:"star",expr:e};else if(n.eat("?"))e={type:"opt",expr:e};else if(n.eat("{"))e=zu(n,e);else break;return e}function Ol(n){/\D/.test(n.next)&&n.err("Expected number, got '"+n.next+"'");let e=Number(n.next);return n.pos++,e}function zu(n,e){let t=Ol(n),r=t;return n.eat(",")&&(n.next!="}"?r=Ol(n):r=-1),n.eat("}")||n.err("Unclosed braced range"),{type:"range",min:t,max:r,expr:e}}function Bu(n,e){let t=n.nodeTypes,r=t[e];if(r)return[r];let o=[];for(let i in t){let s=t[i];s.isInGroup(e)&&o.push(s)}return o.length==0&&n.err("No node type or group '"+e+"' found"),o}function Fu(n){if(n.eat("(")){let e=Kl(n);return n.eat(")")||n.err("Missing closing paren"),e}else if(/\W/.test(n.next))n.err("Unexpected token '"+n.next+"'");else{let e=Bu(n,n.next).map(t=>(n.inline==null?n.inline=t.isInline:n.inline!=t.isInline&&n.err("Mixing inline and block content"),{type:"name",value:t}));return n.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function Hu(n){let e=[[]];return o(i(n,0),t()),e;function t(){return e.push([])-1}function r(s,l,a){let c={term:a,to:l};return e[s].push(c),c}function o(s,l){s.forEach(a=>a.to=l)}function i(s,l){if(s.type=="choice")return s.exprs.reduce((a,c)=>a.concat(i(c,l)),[]);if(s.type=="seq")for(let a=0;;a++){let c=i(s.exprs[a],l);if(a==s.exprs.length-1)return c;o(c,l=t())}else if(s.type=="star"){let a=t();return r(l,a),o(i(s.expr,a),a),[r(a)]}else if(s.type=="plus"){let a=t();return o(i(s.expr,l),a),o(i(s.expr,a),a),[r(a)]}else{if(s.type=="opt")return[r(l)].concat(i(s.expr,l));if(s.type=="range"){let a=l;for(let c=0;c{n[s].forEach(({term:l,to:a})=>{if(!l)return;let c;for(let d=0;d{c||o.push([l,c=[]]),c.indexOf(d)==-1&&c.push(d)})})});let i=e[r.join(",")]=new st(r.indexOf(n.length-1)>-1);for(let s=0;s-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:ql(this.attrs,e)}create(e=null,t,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new pe(this,this.computeAttrs(e),x.from(t),F.setFrom(r))}createChecked(e=null,t,r){return t=x.from(t),this.checkContent(t),new pe(this,this.computeAttrs(e),t,F.setFrom(r))}createAndFill(e=null,t,r){if(e=this.computeAttrs(e),t=x.from(t),t.size){let s=this.contentMatch.fillBefore(t);if(!s)return null;t=s.append(t)}let o=this.contentMatch.matchFragment(t),i=o&&o.fillBefore(x.empty,!0);return i?new pe(this,e,t.append(i),F.setFrom(r)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let r=0;r-1}allowsMarks(e){if(this.markSet==null)return!0;for(let t=0;tr[i]=new n(i,t,s));let o=t.spec.topNode||"doc";if(!r[o])throw new RangeError("Schema is missing its top node type ('"+o+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let i in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function Vu(n,e,t){let r=t.split("|");return o=>{let i=o===null?"null":typeof o;if(r.indexOf(i)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${n}, got ${i}`)}}var li=class{constructor(e,t,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?Vu(e,t,r.validate):r.validate}get isRequired(){return!this.hasDefault}},jt=class n{constructor(e,t,r,o){this.name=e,this.rank=t,this.schema=r,this.spec=o,this.attrs=Yl(e,o.attrs),this.excluded=null;let i=Ul(this.attrs);this.instance=i?new F(this,i):null}create(e=null){return!e&&this.instance?this.instance:new F(this,ql(this.attrs,e))}static compile(e,t){let r=Object.create(null),o=0;return e.forEach((i,s)=>r[i]=new n(i,o++,t,s)),r}removeFromSet(e){for(var t=0;t-1}},Wt=class{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let o in e)t[o]=e[o];t.nodes=ei.from(e.nodes),t.marks=ei.from(e.marks||{}),this.nodes=xn.compile(this.spec.nodes,this),this.marks=jt.compile(this.spec.marks,this);let r=Object.create(null);for(let o in this.nodes){if(o in this.marks)throw new RangeError(o+" can not be both a node and a mark");let i=this.nodes[o],s=i.spec.content||"",l=i.spec.marks;if(i.contentMatch=r[s]||(r[s]=st.parse(s,this.nodes)),i.inlineContent=i.contentMatch.inlineContent,i.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!i.isInline||!i.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=i}i.markSet=l=="_"?null:l?Rl(this,l.split(" ")):l==""||!i.inlineContent?[]:null}for(let o in this.marks){let i=this.marks[o],s=i.spec.excludes;i.excluded=s==null?[i]:s==""?[]:Rl(this,s.split(" "))}this.nodeFromJSON=this.nodeFromJSON.bind(this),this.markFromJSON=this.markFromJSON.bind(this),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,r,o){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof xn){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(t,r,o)}text(e,t){let r=this.nodes.text;return new ii(r,r.defaultAttrs,e,F.setFrom(t))}mark(e,t){return typeof e=="string"&&(e=this.marks[e]),e.create(t)}nodeFromJSON(e){return pe.fromJSON(this,e)}markFromJSON(e){return F.fromJSON(this,e)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}};function Rl(n,e){let t=[];for(let r=0;r-1)&&t.push(s=a)}if(!s)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return t}function ju(n){return n.tag!=null}function Wu(n){return n.style!=null}var Ne=class n{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let r=this.matchedStyles=[];t.forEach(o=>{if(ju(o))this.tags.push(o);else if(Wu(o)){let i=/[^=]*/.exec(o.style)[0];r.indexOf(i)<0&&r.push(i),this.styles.push(o)}}),this.normalizeLists=!this.tags.some(o=>{if(!/^(ul|ol)\b/.test(o.tag)||!o.node)return!1;let i=e.nodes[o.node];return i.contentMatch.matchType(i)})}parse(e,t={}){let r=new sr(this,t,!1);return r.addAll(e,F.none,t.from,t.to),r.finish()}parseSlice(e,t={}){let r=new sr(this,t,!0);return r.addAll(e,F.none,t.from,t.to),S.maxOpen(r.finish())}matchTag(e,t,r){for(let o=r?this.tags.indexOf(r)+1:0;oe.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=t))){if(s.getAttrs){let a=s.getAttrs(t);if(a===!1)continue;s.attrs=a||void 0}return s}}}static schemaRules(e){let t=[];function r(o){let i=o.priority==null?50:o.priority,s=0;for(;s{r(s=Il(s)),s.mark||s.ignore||s.clearMark||(s.mark=o)})}for(let o in e.nodes){let i=e.nodes[o].spec.parseDOM;i&&i.forEach(s=>{r(s=Il(s)),s.node||s.ignore||s.mark||(s.node=o)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new n(e,n.schemaRules(e)))}},Ql={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},Ku={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Xl={ol:!0,ul:!0},kn=1,ai=2,yn=4;function Dl(n,e,t){return e!=null?(e?kn:0)|(e==="full"?ai:0):n&&n.whitespace=="pre"?kn|ai:t&~yn}var Vt=class{constructor(e,t,r,o,i,s){this.type=e,this.attrs=t,this.marks=r,this.solid=o,this.options=s,this.content=[],this.activeMarks=F.none,this.match=i||(s&yn?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(x.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let r=this.type.contentMatch,o;return(o=r.findWrapping(e.type))?(this.match=r,o):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&kn)){let r=this.content[this.content.length-1],o;if(r&&r.isText&&(o=/[ \t\r\n\u000c]+$/.exec(r.text))){let i=r;r.text.length==o[0].length?this.content.pop():this.content[this.content.length-1]=i.withText(i.text.slice(0,i.text.length-o[0].length))}}let t=x.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(x.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&&!Ql.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}},sr=class{constructor(e,t,r){this.parser=e,this.options=t,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let o=t.topNode,i,s=Dl(null,t.preserveWhitespace,0)|(r?yn:0);o?i=new Vt(o.type,o.attrs,F.none,!0,t.topMatch||o.type.contentMatch,s):r?i=new Vt(null,null,F.none,!0,null,s):i=new Vt(e.schema.topNodeType,null,F.none,!0,null,s),this.nodes=[i],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){e.nodeType==3?this.addTextNode(e,t):e.nodeType==1&&this.addElement(e,t)}addTextNode(e,t){let r=e.nodeValue,o=this.top,i=o.options&ai?"full":this.localPreserveWS||(o.options&kn)>0;if(i==="full"||o.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(i)i!=="full"?r=r.replace(/\r?\n|\r/g," "):r=r.replace(/\r\n?/g,` +`);else if(r=r.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(r)&&this.open==this.nodes.length-1){let s=o.content[o.content.length-1],l=e.previousSibling;(!s||l&&l.nodeName=="BR"||s.isText&&/[ \t\r\n\u000c]$/.test(s.text))&&(r=r.slice(1))}r&&this.insertNode(this.parser.schema.text(r),t),this.findInText(e)}else this.findInside(e)}addElement(e,t,r){let o=this.localPreserveWS,i=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let s=e.nodeName.toLowerCase(),l;Xl.hasOwnProperty(s)&&this.parser.normalizeLists&&Ju(e);let a=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(l=this.parser.matchTag(e,this,r));e:if(a?a.ignore:Ku.hasOwnProperty(s))this.findInside(e),this.ignoreFallback(e,t);else if(!a||a.skip||a.closeParent){a&&a.closeParent?this.open=Math.max(0,this.open-1):a&&a.skip.nodeType&&(e=a.skip);let c,d=this.needsBlock;if(Ql.hasOwnProperty(s))i.content.length&&i.content[0].isInline&&this.open&&(this.open--,i=this.top),c=!0,i.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break e}let u=a&&a.skip?t:this.readStyles(e,t);u&&this.addAll(e,u),c&&this.sync(i),this.needsBlock=d}else{let c=this.readStyles(e,t);c&&this.addElementByRule(e,a,c,a.consuming===!1?l:void 0)}this.localPreserveWS=o}leafFallback(e,t){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(` +`),t)}ignoreFallback(e,t){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),t)}readStyles(e,t){let r=e.style;if(r&&r.length)for(let o=0;o!a.clearMark(c)):t=t.concat(this.parser.schema.marks[a.mark].create(a.attrs)),a.consuming===!1)l=a;else break}}return t}addElementByRule(e,t,r,o){let i,s;if(t.node)if(s=this.parser.schema.nodes[t.node],s.isLeaf)this.insertNode(s.create(t.attrs),r)||this.leafFallback(e,r);else{let a=this.enter(s,t.attrs||null,r,t.preserveWhitespace);a&&(i=!0,r=a)}else{let a=this.parser.schema.marks[t.mark];r=r.concat(a.create(t.attrs))}let l=this.top;if(s&&s.isLeaf)this.findInside(e);else if(o)this.addElement(e,r,o);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a,r));else{let a=e;typeof t.contentElement=="string"?a=e.querySelector(t.contentElement):typeof t.contentElement=="function"?a=t.contentElement(e):t.contentElement&&(a=t.contentElement),this.findAround(e,a,!0),this.addAll(a,r),this.findAround(e,a,!1)}i&&this.sync(l)&&this.open--}addAll(e,t,r,o){let i=r||0;for(let s=r?e.childNodes[r]:e.firstChild,l=o==null?null:e.childNodes[o];s!=l;s=s.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(s,t);this.findAtPoint(e,i)}findPlace(e,t){let r,o;for(let i=this.open;i>=0;i--){let s=this.nodes[i],l=s.findWrapping(e);if(l&&(!r||r.length>l.length)&&(r=l,o=s,!l.length)||s.solid)break}if(!r)return null;this.sync(o);for(let i=0;i(s.type?s.type.allowsMarkType(c.type):Pl(c.type,e))?(a=c.addToSet(a),!1):!0),this.nodes.push(new Vt(e,t,a,o,null,l)),this.open++,r}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|=kn)}return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let r=this.nodes[t].content;for(let o=r.length-1;o>=0;o--)e+=r[o].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let r=0;r-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split("/"),r=this.options.context,o=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),i=-(r?r.depth+1:0)+(o?0:1),s=(l,a)=>{for(;l>=0;l--){let c=t[l];if(c==""){if(l==t.length-1||l==0)continue;for(;a>=i;a--)if(s(l-1,a))return!0;return!1}else{let d=a>0||a==0&&o?this.nodes[a].type:r&&a>=i?r.node(a-i).type:null;if(!d||d.name!=c&&!d.isInGroup(c))return!1;a--}}return!0};return s(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let r=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let t in this.parser.schema.nodes){let r=this.parser.schema.nodes[t];if(r.isTextblock&&r.defaultAttrs)return r}}};function Ju(n){for(let e=n.firstChild,t=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&Xl.hasOwnProperty(r)&&t?(t.appendChild(e),e=t):r=="li"?t=e:r&&(t=null)}}function Uu(n,e){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,e)}function Il(n){let e={};for(let t in n)e[t]=n[t];return e}function Pl(n,e){let t=e.schema.nodes;for(let r in t){let o=t[r];if(!o.allowsMarkType(n))continue;let i=[],s=l=>{i.push(l);for(let a=0;a{if(i.length||s.marks.length){let l=0,a=0;for(;l=0;o--){let i=this.serializeMark(e.marks[o],e.isInline,t);i&&((i.contentDOM||i.dom).appendChild(r),r=i.dom)}return r}serializeMark(e,t,r={}){let o=this.marks[e.type.name];return o&&rr(ni(r),o(e,t),null,e.attrs)}static renderSpec(e,t,r=null,o){return rr(e,t,r,o)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new n(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=Ll(e.nodes);return t.text||(t.text=r=>r.text),t}static marksFromSchema(e){return Ll(e.marks)}};function Ll(n){let e={};for(let t in n){let r=n[t].spec.toDOM;r&&(e[t]=r)}return e}function ni(n){return n.document||window.document}var zl=new WeakMap;function qu(n){let e=zl.get(n);return e===void 0&&zl.set(n,e=Gu(n)),e}function Gu(n){let e=null;function t(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")e||(e=[]),e.push(r);else for(let o=0;o-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=o.indexOf(" ");s>0&&(t=o.slice(0,s),o=o.slice(s+1));let l,a=t?n.createElementNS(t,o):n.createElement(o),c=e[1],d=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){d=2;for(let u in c)if(c[u]!=null){let f=u.indexOf(" ");f>0?a.setAttributeNS(u.slice(0,f),u.slice(f+1),c[u]):a.setAttribute(u,c[u])}}for(let u=d;ud)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}else{let{dom:p,contentDOM:h}=rr(n,f,t,r);if(a.appendChild(p),h){if(l)throw new RangeError("Multiple content holes");l=h}}}return{dom:a,contentDOM:l}}var ta=65535,na=Math.pow(2,16);function Yu(n,e){return n+e*na}function Zl(n){return n&ta}function Qu(n){return(n-(n&ta))/na}var ra=1,oa=2,lr=4,ia=8,Kt=class{constructor(e,t,r){this.pos=e,this.delInfo=t,this.recover=r}get deleted(){return(this.delInfo&ia)>0}get deletedBefore(){return(this.delInfo&(ra|lr))>0}get deletedAfter(){return(this.delInfo&(oa|lr))>0}get deletedAcross(){return(this.delInfo&lr)>0}},Pe=class n{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&n.empty)return n.empty}recover(e){let t=0,r=Zl(e);if(!this.inverted)for(let o=0;oe)break;let c=this.ranges[l+i],d=this.ranges[l+s],u=a+c;if(e<=u){let f=c?e==a?-1:e==u?1:t:t,p=a+o+(f<0?0:d);if(r)return p;let h=e==(t<0?a:u)?null:Yu(l/3,e-a),m=e==a?oa:e==u?ra:lr;return(t<0?e!=a:e!=u)&&(m|=ia),new Kt(p,m,h)}o+=d-c}return r?e+o:new Kt(e+o,0,null)}touches(e,t){let r=0,o=Zl(t),i=this.inverted?2:1,s=this.inverted?1:2;for(let l=0;le)break;let c=this.ranges[l+i],d=a+c;if(e<=d&&l==o*3)return!0;r+=this.ranges[l+s]-c}return!1}forEach(e){let t=this.inverted?2:1,r=this.inverted?1:2;for(let o=0,i=0;o=0;t--){let o=e.getMirror(t);this.appendMap(e._maps[t].invert(),o!=null&&o>t?r-o-1:void 0)}}invert(){let e=new n;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let r=this.from;ri&&a!s.isAtom||!l.type.allowsMarkType(this.mark.type)?s:s.mark(this.mark.addToSet(s.marks)),o),t.openStart,t.openEnd);return te.fromReplace(e,this.from,this.to,i)}invert(){return new lt(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new n(t.pos,r.pos,this.mark)}merge(e){return e instanceof n&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new n(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new n(t.from,t.to,e.markFromJSON(t.mark))}};ee.jsonID("addMark",Ut);var lt=class n extends ee{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=new S(hi(t.content,o=>o.mark(this.mark.removeFromSet(o.marks)),e),t.openStart,t.openEnd);return te.fromReplace(e,this.from,this.to,r)}invert(){return new Ut(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new n(t.pos,r.pos,this.mark)}merge(e){return e instanceof n&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new n(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new n(t.from,t.to,e.markFromJSON(t.mark))}};ee.jsonID("removeMark",lt);var qt=class n extends ee{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return te.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return te.fromReplace(e,this.pos,this.pos+1,new S(x.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let r=this.mark.addToSet(t.marks);if(r.length==t.marks.length){for(let o=0;or.pos?null:new n(t.pos,r.pos,o,i,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number"||typeof t.gapFrom!="number"||typeof t.gapTo!="number"||typeof t.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new n(t.from,t.to,t.gapFrom,t.gapTo,S.fromJSON(e,t.slice),t.insert,!!t.structure)}};ee.jsonID("replaceAround",X);function fi(n,e,t){let r=n.resolve(e),o=t-e,i=r.depth;for(;o>0&&i>0&&r.indexAfter(i)==r.node(i).childCount;)i--,o--;if(o>0){let s=r.node(i).maybeChild(r.indexAfter(i));for(;o>0;){if(!s||s.isLeaf)return!0;s=s.firstChild,o--}}return!1}function Xu(n,e,t,r){let o=[],i=[],s,l;n.doc.nodesBetween(e,t,(a,c,d)=>{if(!a.isInline)return;let u=a.marks;if(!r.isInSet(u)&&d.type.allowsMarkType(r.type)){let f=Math.max(c,e),p=Math.min(c+a.nodeSize,t),h=r.addToSet(u);for(let m=0;mn.step(a)),i.forEach(a=>n.step(a))}function Zu(n,e,t,r){let o=[],i=0;n.doc.nodesBetween(e,t,(s,l)=>{if(!s.isInline)return;i++;let a=null;if(r instanceof jt){let c=s.marks,d;for(;d=r.isInSet(c);)(a||(a=[])).push(d),c=d.removeFromSet(c)}else r?r.isInSet(s.marks)&&(a=[r]):a=s.marks;if(a&&a.length){let c=Math.min(l+s.nodeSize,t);for(let d=0;dn.step(new lt(s.from,s.to,s.style)))}function mi(n,e,t,r=t.contentMatch,o=!0){let i=n.doc.nodeAt(e),s=[],l=e+1;for(let a=0;a=0;a--)n.step(s[a])}function ef(n,e,t){return(e==0||n.canReplace(e,n.childCount))&&(t==n.childCount||n.canReplace(0,t))}function Le(n){let t=n.parent.content.cutByIndex(n.startIndex,n.endIndex);for(let r=n.depth;;--r){let o=n.$from.node(r),i=n.$from.index(r),s=n.$to.indexAfter(r);if(rt;h--)m||r.index(h)>0?(m=!0,d=x.from(r.node(h).copy(d)),u++):a--;let f=x.empty,p=0;for(let h=i,m=!1;h>t;h--)m||o.after(h+1)=0;s--){if(r.size){let l=t[s].type.contentMatch.matchFragment(r);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=x.from(t[s].type.create(t[s].attrs,r))}let o=e.start,i=e.end;n.step(new X(o,i,o,i,new S(r,0,0),t.length,!0))}function sf(n,e,t,r,o){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let i=n.steps.length;n.doc.nodesBetween(e,t,(s,l)=>{let a=typeof o=="function"?o(s):o;if(s.isTextblock&&!s.hasMarkup(r,a)&&lf(n.doc,n.mapping.slice(i).map(l),r)){let c=null;if(r.schema.linebreakReplacement){let p=r.whitespace=="pre",h=!!r.contentMatch.matchType(r.schema.linebreakReplacement);p&&!h?c=!1:!p&&h&&(c=!0)}c===!1&&la(n,s,l,i),mi(n,n.mapping.slice(i).map(l,1),r,void 0,c===null);let d=n.mapping.slice(i),u=d.map(l,1),f=d.map(l+s.nodeSize,1);return n.step(new X(u,f,u+1,f-1,new S(x.from(r.create(a,null,s.marks)),0,0),1,!0)),c===!0&&sa(n,s,l,i),!1}})}function sa(n,e,t,r){e.forEach((o,i)=>{if(o.isText){let s,l=/\r?\n|\r/g;for(;s=l.exec(o.text);){let a=n.mapping.slice(r).map(t+1+i+s.index);n.replaceWith(a,a+1,e.type.schema.linebreakReplacement.create())}}})}function la(n,e,t,r){e.forEach((o,i)=>{if(o.type==o.type.schema.linebreakReplacement){let s=n.mapping.slice(r).map(t+1+i);n.replaceWith(s,s+1,e.type.schema.text(` +`))}})}function lf(n,e,t){let r=n.resolve(e),o=r.index();return r.parent.canReplaceWith(o,o+1,t)}function af(n,e,t,r,o){let i=n.doc.nodeAt(e);if(!i)throw new RangeError("No node at given position");t||(t=i.type);let s=t.create(r,null,o||i.marks);if(i.isLeaf)return n.replaceWith(e,e+i.nodeSize,s);if(!t.validContent(i.content))throw new RangeError("Invalid content for node type "+t.name);n.step(new X(e,e+i.nodeSize,e+1,e+i.nodeSize-1,new S(x.from(s),0,0),1,!0))}function ke(n,e,t=1,r){let o=n.resolve(e),i=o.depth-t,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 c=o.depth-1,d=t-2;c>i;c--,d--){let u=o.node(c),f=o.index(c);if(u.type.spec.isolating)return!1;let p=u.content.cutByIndex(f,u.childCount),h=r&&r[d+1];h&&(p=p.replaceChild(0,h.type.create(h.attrs)));let m=r&&r[d]||u;if(!u.canReplace(f+1,u.childCount)||!m.type.validContent(p))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 cf(n,e,t=1,r){let o=n.doc.resolve(e),i=x.empty,s=x.empty;for(let l=o.depth,a=o.depth-t,c=t-1;l>a;l--,c--){i=x.from(o.node(l).copy(i));let d=r&&r[c];s=x.from(d?d.type.create(d.attrs,s):o.node(l).copy(s))}n.step(new oe(e,e,new S(i.append(s),t,t),!0))}function we(n,e){let t=n.resolve(e),r=t.index();return aa(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(r,r+1)}function df(n,e){e.content.size||n.type.compatibleContent(e.type);let t=n.contentMatchAt(n.childCount),{linebreakReplacement:r}=n.type.schema;for(let o=0;o0?(i=r.node(o+1),l++,s=r.node(o).maybeChild(l)):(i=r.node(o).maybeChild(l-1),s=r.node(o+1)),i&&!i.isTextblock&&aa(i,s)&&r.node(o).canReplace(l,l+1))return e;if(o==0)break;e=t<0?r.before(o):r.after(o)}}function uf(n,e,t){let r=null,{linebreakReplacement:o}=n.doc.type.schema,i=n.doc.resolve(e-t),s=i.node().type;if(o&&s.inlineContent){let d=s.whitespace=="pre",u=!!s.contentMatch.matchType(o);d&&!u?r=!1:!d&&u&&(r=!0)}let l=n.steps.length;if(r===!1){let d=n.doc.resolve(e+t);la(n,d.node(),d.before(),l)}s.inlineContent&&mi(n,e+t-1,s,i.node().contentMatchAt(i.index()),r==null);let a=n.mapping.slice(l),c=a.map(e-t);if(n.step(new oe(c,a.map(e+t,-1),S.empty,!0)),r===!0){let d=n.doc.resolve(c);sa(n,d.node(),d.before(),n.steps.length)}return n}function ca(n,e,t){let r=n.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),t))return e;if(r.parentOffset==0)for(let o=r.depth-1;o>=0;o--){let i=r.index(o);if(r.node(o).canReplaceWith(i,i,t))return r.before(o+1);if(i>0)return null}if(r.parentOffset==r.parent.content.size)for(let o=r.depth-1;o>=0;o--){let i=r.indexAfter(o);if(r.node(o).canReplaceWith(i,i,t))return r.after(o+1);if(i=0;s--){let l=s==r.depth?0:r.pos<=(r.start(s+1)+r.end(s+1))/2?-1:1,a=r.index(s)+(l>0?1:0),c=r.node(s),d=!1;if(i==1)d=c.canReplace(a,a,o);else{let u=c.contentMatchAt(a).findWrapping(o.firstChild.type);d=u&&c.canReplaceWith(a,a,u[0])}if(d)return l==0?r.pos:l<0?r.before(s+1):r.after(s+1)}return null}function Yt(n,e,t=e,r=S.empty){if(e==t&&!r.size)return null;let o=n.resolve(e),i=n.resolve(t);return da(o,i,r)?new oe(e,t,r):new pi(o,i,r).fit()}function da(n,e,t){return!t.openStart&&!t.openEnd&&n.start()==e.start()&&n.parent.canReplace(n.index(),e.index(),t.content)}var pi=class{constructor(e,t,r){this.$from=e,this.$to=t,this.unplaced=r,this.frontier=[],this.placed=x.empty;for(let o=0;o<=e.depth;o++){let i=e.node(o);this.frontier.push({type:i.type,match:i.contentMatchAt(e.indexAfter(o))})}for(let o=e.depth;o>0;o--)this.placed=x.from(e.node(o).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let c=this.findFittable();c?this.placeNodes(c):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,r=this.$from,o=this.close(e<0?this.$to:r.doc.resolve(e));if(!o)return null;let i=this.placed,s=r.depth,l=o.depth;for(;s&&l&&i.childCount==1;)i=i.firstChild.content,s--,l--;let a=new S(i,s,l);return e>-1?new X(r.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||r.pos!=this.$to.pos?new oe(r.pos,o.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,r=0,o=this.unplaced.openEnd;r1&&(o=0),i.type.spec.isolating&&o<=r){e=r;break}t=i.content}for(let t=1;t<=2;t++)for(let r=t==1?e:this.unplaced.openStart;r>=0;r--){let o,i=null;r?(i=di(this.unplaced.content,r-1).firstChild,o=i.content):o=this.unplaced.content;let s=o.firstChild;for(let l=this.depth;l>=0;l--){let{type:a,match:c}=this.frontier[l],d,u=null;if(t==1&&(s?c.matchType(s.type)||(u=c.fillBefore(x.from(s),!1)):i&&a.compatibleContent(i.type)))return{sliceDepth:r,frontierDepth:l,parent:i,inject:u};if(t==2&&s&&(d=c.findWrapping(s.type)))return{sliceDepth:r,frontierDepth:l,parent:i,wrap:d};if(i&&c.matchType(i.type))break}}}openMore(){let{content:e,openStart:t,openEnd:r}=this.unplaced,o=di(e,t);return!o.childCount||o.firstChild.isLeaf?!1:(this.unplaced=new S(e,t+1,Math.max(r,o.size+t>=e.size-r?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:r}=this.unplaced,o=di(e,t);if(o.childCount<=1&&t>0){let i=e.size-t<=t+o.size;this.unplaced=new S(wn(e,t-1,1),t-1,i?t-1:r)}else this.unplaced=new S(wn(e,t,1),t,r)}placeNodes({sliceDepth:e,frontierDepth:t,parent:r,inject:o,wrap:i}){for(;this.depth>t;)this.closeFrontierNode();if(i)for(let m=0;m1||a==0||m.content.size)&&(u=g,d.push(ua(m.mark(f.allowedMarks(m.marks)),c==1?a:0,c==l.childCount?p:-1)))}let h=c==l.childCount;h||(p=-1),this.placed=Sn(this.placed,t,x.from(d)),this.frontier[t].match=u,h&&p<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let m=0,g=l;m1&&o==this.$to.end(--r);)++o;return o}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:r,type:o}=this.frontier[t],i=t=0;l--){let{match:a,type:c}=this.frontier[l],d=ui(e,l,c,a,!0);if(!d||d.childCount)continue e}return{depth:t,fit:s,move:i?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=Sn(this.placed,t.depth,t.fit)),e=t.move;for(let r=t.depth+1;r<=e.depth;r++){let o=e.node(r),i=o.type.contentMatch.fillBefore(o.content,!0,e.index(r));this.openFrontierNode(o.type,o.attrs,i)}return e}openFrontierNode(e,t=null,r){let o=this.frontier[this.depth];o.match=o.match.matchType(e),this.placed=Sn(this.placed,this.depth,x.from(e.create(t,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(x.empty,!0);t.childCount&&(this.placed=Sn(this.placed,this.frontier.length,t))}};function wn(n,e,t){return e==0?n.cutByIndex(t,n.childCount):n.replaceChild(0,n.firstChild.copy(wn(n.firstChild.content,e-1,t)))}function Sn(n,e,t){return e==0?n.append(t):n.replaceChild(n.childCount-1,n.lastChild.copy(Sn(n.lastChild.content,e-1,t)))}function di(n,e){for(let t=0;t1&&(r=r.replaceChild(0,ua(r.firstChild,e-1,r.childCount==1?t-1:0))),e>0&&(r=n.type.contentMatch.fillBefore(r).append(r),t<=0&&(r=r.append(n.type.contentMatch.matchFragment(r).fillBefore(x.empty,!0)))),n.copy(r)}function ui(n,e,t,r,o){let i=n.node(e),s=o?n.indexAfter(e):n.index(e);if(s==i.childCount&&!t.compatibleContent(i.type))return null;let l=r.fillBefore(i.content,!0,s);return l&&!ff(t,i.content,s)?l:null}function ff(n,e,t){for(let r=t;r0;f--,p--){let h=o.node(f).type.spec;if(h.defining||h.definingAsContext||h.isolating)break;s.indexOf(f)>-1?l=f:o.before(f)==p&&s.splice(1,0,-f)}let a=s.indexOf(l),c=[],d=r.openStart;for(let f=r.content,p=0;;p++){let h=f.firstChild;if(c.push(h),p==r.openStart)break;f=h.content}for(let f=d-1;f>=0;f--){let p=c[f],h=pf(p.type);if(h&&!p.sameMarkup(o.node(Math.abs(l)-1)))d=f;else if(h||!p.type.isTextblock)break}for(let f=r.openStart;f>=0;f--){let p=(f+d+1)%(r.openStart+1),h=c[p];if(h)for(let m=0;m=0&&(n.replace(e,t,r),!(n.steps.length>u));f--){let p=s[f];p<0||(e=o.before(p),t=i.after(p))}}function fa(n,e,t,r,o){if(er){let i=o.contentMatchAt(0),s=i.fillBefore(n).append(n);n=s.append(i.matchFragment(s).fillBefore(x.empty,!0))}return n}function mf(n,e,t,r){if(!r.isInline&&e==t&&n.doc.resolve(e).parent.content.size){let o=ca(n.doc,e,r.type);o!=null&&(e=t=o)}n.replaceRange(e,t,new S(x.from(r),0,0))}function gf(n,e,t){let r=n.doc.resolve(e),o=n.doc.resolve(t),i=pa(r,o);for(let s=0;s0&&(a||r.node(l-1).canReplace(r.index(l-1),o.indexAfter(l-1))))return n.delete(r.before(l),o.after(l))}for(let s=1;s<=r.depth&&s<=o.depth;s++)if(e-r.start(s)==r.depth-s&&t>r.end(s)&&o.end(s)-t!=o.depth-s&&r.start(s-1)==o.start(s-1)&&r.node(s-1).canReplace(r.index(s-1),o.index(s-1)))return n.delete(r.before(s),t);n.delete(e,t)}function pa(n,e){let t=[],r=Math.min(n.depth,e.depth);for(let o=r;o>=0;o--){let i=n.start(o);if(ie.pos+(e.depth-o)||n.node(o).type.spec.isolating||e.node(o).type.spec.isolating)break;(i==e.start(o)||o==n.depth&&o==e.depth&&n.parent.inlineContent&&e.parent.inlineContent&&o&&e.start(o-1)==i-1)&&t.push(o)}return t}var Cn=class n extends ee{constructor(e,t,r){super(),this.pos=e,this.attr=t,this.value=r}apply(e){let t=e.nodeAt(this.pos);if(!t)return te.fail("No node at attribute step's position");let r=Object.create(null);for(let i in t.attrs)r[i]=t.attrs[i];r[this.attr]=this.value;let o=t.type.create(r,null,t.marks);return te.fromReplace(e,this.pos,this.pos+1,new S(x.from(o),0,t.isLeaf?0:1))}getMap(){return Pe.empty}invert(e){return new n(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 n(t.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.pos!="number"||typeof t.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new n(t.pos,t.attr,t.value)}};ee.jsonID("attr",Cn);var Mn=class n extends ee{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let o in e.attrs)t[o]=e.attrs[o];t[this.attr]=this.value;let r=e.type.create(t,e.content,e.marks);return te.ok(r)}getMap(){return Pe.empty}invert(e){return new n(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new n(t.attr,t.value)}};ee.jsonID("docAttr",Mn);var Mt=class extends Error{};Mt=function n(e){let t=Error.call(this,e);return t.__proto__=n.prototype,t};Mt.prototype=Object.create(Error.prototype);Mt.prototype.constructor=Mt;Mt.prototype.name="TransformError";var We=class{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Jt}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new Mt(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}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,r=S.empty){let o=Yt(this.doc,e,t,r);return o&&this.step(o),this}replaceWith(e,t,r){return this.replace(e,t,new S(x.from(r),0,0))}delete(e,t){return this.replace(e,t,S.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,r){return hf(this,e,t,r),this}replaceRangeWith(e,t,r){return mf(this,e,t,r),this}deleteRange(e,t){return gf(this,e,t),this}lift(e,t){return tf(this,e,t),this}join(e,t=1){return uf(this,e,t),this}wrap(e,t){return of(this,e,t),this}setBlockType(e,t=e,r,o=null){return sf(this,e,t,r,o),this}setNodeMarkup(e,t,r=null,o){return af(this,e,t,r,o),this}setNodeAttribute(e,t,r){return this.step(new Cn(e,t,r)),this}setDocAttribute(e,t){return this.step(new Mn(e,t)),this}addNodeMark(e,t){return this.step(new qt(e,t)),this}removeNodeMark(e,t){if(!(t instanceof F)){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(t=t.isInSet(r.marks),!t)return this}return this.step(new Gt(e,t)),this}split(e,t=1,r){return cf(this,e,t,r),this}addMark(e,t,r){return Xu(this,e,t,r),this}removeMark(e,t,r){return Zu(this,e,t,r),this}clearIncompatible(e,t,r){return mi(this,e,t,r),this}};var gi=Object.create(null),E=class{constructor(e,t,r){this.$anchor=e,this.$head=t,this.ranges=r||[new Ke(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=0;i--){let s=t<0?Qt(e.node(0),e.node(i),e.before(i+1),e.index(i),t,r):Qt(e.node(0),e.node(i),e.after(i+1),e.index(i)+1,t,r);if(s)return s}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new ae(e.node(0))}static atStart(e){return Qt(e,e,0,0,1)||new ae(e)}static atEnd(e){return Qt(e,e,e.content.size,e.childCount,-1)||new ae(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=gi[t.type];if(!r)throw new RangeError(`No selection type ${t.type} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in gi)throw new RangeError("Duplicate use of selection JSON ID "+e);return gi[e]=t,t.prototype.jsonID=e,t}getBookmark(){return A.between(this.$anchor,this.$head).getBookmark()}};E.prototype.visible=!0;var Ke=class{constructor(e,t){this.$from=e,this.$to=t}},ha=!1;function ma(n){!ha&&!n.parent.inlineContent&&(ha=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+n.parent.type.name+")"))}var A=class n extends E{constructor(e,t=e){ma(e),ma(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let r=e.resolve(t.map(this.head));if(!r.parent.inlineContent)return E.near(r);let o=e.resolve(t.map(this.anchor));return new n(o.parent.inlineContent?o:r,r)}replace(e,t=S.empty){if(super.replace(e,t),t==S.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof n&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new cr(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if(typeof t.anchor!="number"||typeof t.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new n(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,r=t){let o=e.resolve(t);return new this(o,r==t?o:e.resolve(r))}static between(e,t,r){let o=e.pos-t.pos;if((!r||o)&&(r=o>=0?1:-1),!t.parent.inlineContent){let i=E.findFrom(t,r,!0)||E.findFrom(t,-r,!0);if(i)t=i.$head;else return E.near(t,r)}return e.parent.inlineContent||(o==0?e=t:(e=(E.findFrom(e,-r,!0)||E.findFrom(e,r,!0)).$anchor,e.pos0?0:1);o>0?s=0;s+=o){let l=e.child(s);if(l.isAtom){if(!i&&v.isSelectable(l))return v.create(n,t-(o<0?l.nodeSize:0))}else{let a=Qt(n,l,t+o,o<0?l.childCount:0,o,i);if(a)return a}t+=l.nodeSize*o}return null}function ga(n,e,t){let r=n.steps.length-1;if(r{s==null&&(s=d)}),n.setSelection(E.near(n.doc.resolve(s),t))}var ya=1,ar=2,ba=4,dr=class extends We{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.curSelectionFor0}setStoredMarks(e){return this.storedMarks=e,this.updated|=ar,this}ensureMarks(e){return F.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&ar)>0}addStep(e,t){super.addStep(e,t),this.updated=this.updated&~ar,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let r=this.selection;return t&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||F.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,r){let o=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(o.text(e),!0):this.deleteSelection();{if(r==null&&(r=t),r=r==null?t:r,!e)return this.deleteRange(t,r);let i=this.storedMarks;if(!i){let s=this.doc.resolve(t);i=r==t?s.marks():s.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(t,r,o.text(e,i)),this.selection.empty||this.setSelection(E.near(this.selection.$to)),this}}setMeta(e,t){return this.meta[typeof e=="string"?e:e.key]=t,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=ba,this}get scrolledIntoView(){return(this.updated&ba)>0}};function xa(n,e){return!e||!n?n:n.bind(e)}var Et=class{constructor(e,t,r){this.name=e,this.init=xa(t.init,r),this.apply=xa(t.apply,r)}},bf=[new Et("doc",{init(n){return n.doc||n.schema.topNodeType.createAndFill()},apply(n){return n.doc}}),new Et("selection",{init(n,e){return n.selection||E.atStart(e.doc)},apply(n){return n.selection}}),new Et("storedMarks",{init(n){return n.storedMarks||null},apply(n,e,t,r){return r.selection.$cursor?n.storedMarks:null}}),new Et("scrollToSelection",{init(){return 0},apply(n,e){return n.scrolledIntoView?e+1:e}})],An=class{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=bf.slice(),t&&t.forEach(r=>{if(this.pluginsByKey[r.key])throw new RangeError("Adding different instances of a keyed plugin ("+r.key+")");this.plugins.push(r),this.pluginsByKey[r.key]=r,r.spec.state&&this.fields.push(new Et(r.key,r.spec.state,r))})}},En=class n{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 r=0;rr.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let o=e[r],i=o.spec.state;i&&i.toJSON&&(t[r]=i.toJSON.call(o,this[o.key]))}return t}static fromJSON(e,t,r){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let o=new An(e.schema,e.plugins),i=new n(o);return o.fields.forEach(s=>{if(s.name=="doc")i.doc=pe.fromJSON(e.schema,t.doc);else if(s.name=="selection")i.selection=E.fromJSON(i.doc,t.selection);else if(s.name=="storedMarks")t.storedMarks&&(i.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let l in r){let a=r[l],c=a.spec.state;if(a.key==s.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(t,l)){i[s.name]=c.fromJSON.call(a,e,t[l],i);return}}i[s.name]=s.init(e,i)}}),i}};function ka(n,e,t){for(let r in n){let o=n[r];o instanceof Function?o=o.bind(e):r=="handleDOMEvents"&&(o=ka(o,e,{})),t[r]=o}return t}var L=class{constructor(e){this.spec=e,this.props={},e.props&&ka(e.props,this,this.props),this.key=e.key?e.key.key:wa("plugin")}getState(e){return e[this.key]}},yi=Object.create(null);function wa(n){return n in yi?n+"$"+ ++yi[n]:(yi[n]=0,n+"$")}var j=class{constructor(e="key"){this.key=wa(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}};var Cr={};rt(Cr,{Decoration:()=>ne,DecorationSet:()=>q,EditorView:()=>Ln,__endComposition:()=>Wp,__parseFromClipboard:()=>jp});var ie=function(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e},nn=function(n){let e=n.assignedSlot||n.parentNode;return e&&e.nodeType==11?e.host:e},Mi=null,Ue=function(n,e,t){let r=Mi||(Mi=document.createRange());return r.setEnd(n,t==null?n.nodeValue.length:t),r.setStart(n,e||0),r},xf=function(){Mi=null},Pt=function(n,e,t,r){return t&&(Sa(n,e,t,r,-1)||Sa(n,e,t,r,1))},kf=/^(img|br|input|textarea|hr)$/i;function Sa(n,e,t,r,o){for(;;){if(n==t&&e==r)return!0;if(e==(o<0?0:Te(n))){let i=n.parentNode;if(!i||i.nodeType!=1||zn(n)||kf.test(n.nodeName)||n.contentEditable=="false")return!1;e=ie(n)+(o<0?0:1),n=i}else if(n.nodeType==1){if(n=n.childNodes[e+(o<0?-1:0)],n.contentEditable=="false")return!1;e=o<0?Te(n):0}else return!1}}function Te(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function wf(n,e){for(;;){if(n.nodeType==3&&e)return n;if(n.nodeType==1&&e>0){if(n.contentEditable=="false")return null;n=n.childNodes[e-1],e=Te(n)}else if(n.parentNode&&!zn(n))e=ie(n),n=n.parentNode;else return null}}function Sf(n,e){for(;;){if(n.nodeType==3&&e2),Me=rn||(ze?/Mac/.test(ze.platform):!1),Af=ze?/Win/.test(ze.platform):!1,qe=/Android \d/.test(pt),Bn=!!Ca&&"webkitFontSmoothing"in Ca.documentElement.style,Ef=Bn?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function vf(n){let e=n.defaultView&&n.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:n.documentElement.clientWidth,top:0,bottom:n.documentElement.clientHeight}}function Je(n,e){return typeof n=="number"?n:n[e]}function Of(n){let e=n.getBoundingClientRect(),t=e.width/n.offsetWidth||1,r=e.height/n.offsetHeight||1;return{left:e.left,right:e.left+n.clientWidth*t,top:e.top,bottom:e.top+n.clientHeight*r}}function Ma(n,e,t){let r=n.someProp("scrollThreshold")||0,o=n.someProp("scrollMargin")||5,i=n.dom.ownerDocument;for(let s=t||n.dom;s;){if(s.nodeType!=1){s=nn(s);continue}let l=s,a=l==i.body,c=a?vf(i):Of(l),d=0,u=0;if(e.topc.bottom-Je(r,"bottom")&&(u=e.bottom-e.top>c.bottom-c.top?e.top+Je(o,"top")-c.top:e.bottom-c.bottom+Je(o,"bottom")),e.leftc.right-Je(r,"right")&&(d=e.right-c.right+Je(o,"right")),d||u)if(a)i.defaultView.scrollBy(d,u);else{let p=l.scrollLeft,h=l.scrollTop;u&&(l.scrollTop+=u),d&&(l.scrollLeft+=d);let m=l.scrollLeft-p,g=l.scrollTop-h;e={left:e.left-m,top:e.top-g,right:e.right-m,bottom:e.bottom-g}}let f=a?"fixed":getComputedStyle(s).position;if(/^(fixed|sticky)$/.test(f))break;s=f=="absolute"?s.offsetParent:nn(s)}}function Nf(n){let e=n.dom.getBoundingClientRect(),t=Math.max(0,e.top),r,o;for(let i=(e.left+e.right)/2,s=t+1;s=t-20){r=l,o=a.top;break}}return{refDOM:r,refTop:o,stack:rc(n.dom)}}function rc(n){let e=[],t=n.ownerDocument;for(let r=n;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),n!=t);r=nn(r));return e}function Rf({refDOM:n,refTop:e,stack:t}){let r=n?n.getBoundingClientRect().top:0;oc(t,r==0?0:r-e)}function oc(n,e){for(let t=0;t=l){s=Math.max(h.bottom,s),l=Math.min(h.top,l);let m=h.left>e.left?h.left-e.left:h.right=(h.left+h.right)/2?1:0));continue}}else h.top>e.top&&!a&&h.left<=e.left&&h.right>=e.left&&(a=d,c={left:Math.max(h.left,Math.min(h.right,e.left)),top:h.top});!t&&(e.left>=h.right&&e.top>=h.top||e.left>=h.left&&e.top>=h.bottom)&&(i=u+1)}}return!t&&a&&(t=a,o=c,r=0),t&&t.nodeType==3?If(t,o):!t||r&&t.nodeType==1?{node:n,offset:i}:ic(t,o)}function If(n,e){let t=n.nodeValue.length,r=document.createRange();for(let o=0;o=(i.left+i.right)/2?1:0)}}return{node:n,offset:0}}function Vi(n,e){return n.left>=e.left-1&&n.left<=e.right+1&&n.top>=e.top-1&&n.top<=e.bottom+1}function Pf(n,e){let t=n.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left(s.left+s.right)/2?1:-1}return n.docView.posFromDOM(r,o,i)}function zf(n,e,t,r){let o=-1;for(let i=e,s=!1;i!=n.dom;){let l=n.docView.nearestDesc(i,!0),a;if(!l)return null;if(l.dom.nodeType==1&&(l.node.isBlock&&l.parent||!l.contentDOM)&&((a=l.dom.getBoundingClientRect()).width||a.height)&&(l.node.isBlock&&l.parent&&(!s&&a.left>r.left||a.top>r.top?o=l.posBefore:(!s&&a.right-1?o:n.docView.posFromDOM(e,t,-1)}function sc(n,e,t){let r=n.childNodes.length;if(r&&t.tope.top&&o++}let c;Bn&&o&&r.nodeType==1&&(c=r.childNodes[o-1]).nodeType==1&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=e.top&&o--,r==n.dom&&o==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?l=n.state.doc.content.size:(o==0||r.nodeType!=1||r.childNodes[o-1].nodeName!="BR")&&(l=zf(n,r,o,e))}l==null&&(l=Lf(n,s,e));let a=n.docView.nearestDesc(s,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function Ta(n){return n.top=0&&o==r.nodeValue.length?(a--,d=1):t<0?a--:c++,vn(at(Ue(r,a,c),d),d<0)}if(!n.state.doc.resolve(e-(i||0)).parent.inlineContent){if(i==null&&o&&(t<0||o==Te(r))){let a=r.childNodes[o-1];if(a.nodeType==1)return xi(a.getBoundingClientRect(),!1)}if(i==null&&o=0)}if(i==null&&o&&(t<0||o==Te(r))){let a=r.childNodes[o-1],c=a.nodeType==3?Ue(a,Te(a)-(s?0:1)):a.nodeType==1&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(c)return vn(at(c,1),!1)}if(i==null&&o=0)}function vn(n,e){if(n.width==0)return n;let t=e?n.left:n.right;return{top:n.top,bottom:n.bottom,left:t,right:t}}function xi(n,e){if(n.height==0)return n;let t=e?n.top:n.bottom;return{top:t,bottom:t,left:n.left,right:n.right}}function ac(n,e,t){let r=n.state,o=n.root.activeElement;r!=e&&n.updateState(e),o!=n.dom&&n.focus();try{return t()}finally{r!=e&&n.updateState(r),o!=n.dom&&o&&o.focus()}}function Hf(n,e,t){let r=e.selection,o=t=="up"?r.$from:r.$to;return ac(n,e,()=>{let{node:i}=n.docView.domFromPos(o.pos,t=="up"?-1:1);for(;;){let l=n.docView.nearestDesc(i,!0);if(!l)break;if(l.node.isBlock){i=l.contentDOM||l.dom;break}i=l.dom.parentNode}let s=lc(n,o.pos,1);for(let l=i.firstChild;l;l=l.nextSibling){let a;if(l.nodeType==1)a=l.getClientRects();else if(l.nodeType==3)a=Ue(l,0,l.nodeValue.length).getClientRects();else continue;for(let c=0;cd.top+1&&(t=="up"?s.top-d.top>(d.bottom-s.top)*2:d.bottom-s.bottom>(s.bottom-d.top)*2))return!1}}return!0})}var $f=/[\u0590-\u08ac]/;function _f(n,e,t){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let o=r.parentOffset,i=!o,s=o==r.parent.content.size,l=n.domSelection();return l?!$f.test(r.parent.textContent)||!l.modify?t=="left"||t=="backward"?i:s:ac(n,e,()=>{let{focusNode:a,focusOffset:c,anchorNode:d,anchorOffset:u}=n.domSelectionRange(),f=l.caretBidiLevel;l.modify("move",t,"character");let p=r.depth?n.docView.domAfterPos(r.before()):n.dom,{focusNode:h,focusOffset:m}=n.domSelectionRange(),g=h&&!p.contains(h.nodeType==1?h:h.parentNode)||a==h&&c==m;try{l.collapse(d,u),a&&(a!=d||c!=u)&&l.extend&&l.extend(a,c)}catch(y){}return f!=null&&(l.caretBidiLevel=f),g}):r.pos==r.start()||r.pos==r.end()}var Aa=null,Ea=null,va=!1;function Vf(n,e,t){return Aa==e&&Ea==t?va:(Aa=e,Ea=t,va=t=="up"||t=="down"?Hf(n,e,t):_f(n,e,t))}var Ae=0,Oa=1,Ot=2,Be=3,Lt=class{constructor(e,t,r,o){this.parent=e,this.children=t,this.dom=r,this.contentDOM=o,this.dirty=Ae,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,r){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;tie(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))o=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(t==0)for(let i=e;;i=i.parentNode){if(i==this.dom){o=!1;break}if(i.previousSibling)break}if(o==null&&t==e.childNodes.length)for(let i=e;;i=i.parentNode){if(i==this.dom){o=!0;break}if(i.nextSibling)break}}return(o==null?r>0:o)?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let r=!0,o=e;o;o=o.parentNode){let i=this.getDesc(o),s;if(i&&(!t||i.node))if(r&&(s=i.nodeDOM)&&!(s.nodeType==1?s.contains(e.nodeType==1?e:e.parentNode):s==e))r=!1;else return i}}getDesc(e){let t=e.pmViewDesc;for(let r=t;r;r=r.parent)if(r==this)return t}posFromDOM(e,t,r){for(let o=e;o;o=o.parentNode){let i=this.getDesc(o);if(i)return i.localPosFromDOM(e,t,r)}return-1}descAt(e){for(let t=0,r=0;te||s instanceof hr){o=e-i;break}i=l}if(o)return this.children[r].domFromPos(o-this.children[r].border,t);for(let i;r&&!(i=this.children[r-1]).size&&i instanceof fr&&i.side>=0;r--);if(t<=0){let i,s=!0;for(;i=r?this.children[r-1]:null,!(!i||i.dom.parentNode==this.contentDOM);r--,s=!1);return i&&t&&s&&!i.border&&!i.domAtom?i.domFromPos(i.size,t):{node:this.contentDOM,offset:i?ie(i.dom)+1:0}}else{let i,s=!0;for(;i=r=d&&t<=c-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,t,d);e=s;for(let u=l;u>0;u--){let f=this.children[u-1];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(1)){o=ie(f.dom)+1;break}e-=f.size}o==-1&&(o=0)}if(o>-1&&(c>t||l==this.children.length-1)){t=c;for(let d=l+1;dh&&st){let h=l;l=a,a=h}let p=document.createRange();p.setEnd(a.node,a.offset),p.setStart(l.node,l.offset),c.removeAllRanges(),c.addRange(p)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let r=0,o=0;o=r:er){let l=r+i.border,a=s-i.border;if(e>=l&&t<=a){this.dirty=e==r||t==s?Ot:Oa,e==l&&t==a&&(i.contentLost||i.dom.parentNode!=this.contentDOM)?i.dirty=Be:i.markDirty(e-l,t-l);return}else i.dirty=i.dom==i.contentDOM&&i.dom.parentNode==this.contentDOM&&!i.children.length?Ot:Be}r=s}this.dirty=Ot}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let r=e==1?Ot:Oa;t.dirty{if(!i)return o;if(i.parent)return i.parent.posBeforeChild(i)})),!t.type.spec.raw){if(s.nodeType!=1){let l=document.createElement("span");l.appendChild(s),s=l}s.contentEditable="false",s.classList.add("ProseMirror-widget")}super(e,[],s,null),this.widget=t,this.widget=t,i=this}matchesWidget(e){return this.dirty==Ae&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return t?t(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get side(){return this.widget.type.side}},vi=class extends Lt{constructor(e,t,r,o){super(e,[],t,null),this.textDOM=r,this.text=o}get size(){return this.text.length}localPosFromDOM(e,t){return e!=this.textDOM?this.posAtStart+(t?this.size:0):this.posAtStart+t}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}},on=class n extends Lt{constructor(e,t,r,o,i){super(e,[],r,o),this.mark=t,this.spec=i}static create(e,t,r,o){let i=o.nodeViews[t.type.name],s=i&&i(t,o,r);return(!s||!s.dom)&&(s=Ie.renderSpec(document,t.type.spec.toDOM(t,r),null,t.attrs)),new n(e,t,s.dom,s.contentDOM||s.dom,s)}parseRule(){return this.dirty&Be||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=Be&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=Ae){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty0&&(i=Di(i,0,e,r));for(let l=0;l{if(!a)return s;if(a.parent)return a.parent.posBeforeChild(a)},r,o),d=c&&c.dom,u=c&&c.contentDOM;if(t.isText){if(!d)d=document.createTextNode(t.text);else if(d.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else d||({dom:d,contentDOM:u}=Ie.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs));!u&&!t.isText&&d.nodeName!="BR"&&(d.hasAttribute("contenteditable")||(d.contentEditable="false"),t.type.spec.draggable&&(d.draggable=!0));let f=d;return d=uc(d,r,t),c?a=new Oi(e,t,r,o,d,u||null,f,c,i,s+1):t.isText?new pr(e,t,r,o,d,f,i):new n(e,t,r,o,d,u||null,f,i,s+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(e.preserveWhitespace="full"),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let t=this.children.length-1;t>=0;t--){let r=this.children[t];if(this.dom.contains(r.dom.parentNode)){e.contentElement=r.dom.parentNode;break}}e.contentElement||(e.getContent=()=>x.empty)}return e}matchesNode(e,t,r){return this.dirty==Ae&&e.eq(this.node)&&mr(t,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let r=this.node.inlineContent,o=t,i=e.composing?this.localCompositionInfo(e,t):null,s=i&&i.pos>-1?i:null,l=i&&i.pos<0,a=new Ri(this,s&&s.node,e);Jf(this.node,this.innerDeco,(c,d,u)=>{c.spec.marks?a.syncToMarks(c.spec.marks,r,e):c.type.side>=0&&!u&&a.syncToMarks(d==this.node.childCount?F.none:this.node.child(d).marks,r,e),a.placeWidget(c,e,o)},(c,d,u,f)=>{a.syncToMarks(c.marks,r,e);let p;a.findNodeMatch(c,d,u,f)||l&&e.state.selection.from>o&&e.state.selection.to-1&&a.updateNodeAt(c,d,u,p,e)||a.updateNextNode(c,d,u,e,f,o)||a.addNode(c,d,u,e,o),o+=c.nodeSize}),a.syncToMarks([],r,e),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==Ot)&&(s&&this.protectLocalComposition(e,s),cc(this.contentDOM,this.children,e),rn&&Uf(this.dom))}localCompositionInfo(e,t){let{from:r,to:o}=e.state.selection;if(!(e.state.selection instanceof A)||rt+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 s=i.nodeValue,l=qf(this.node.content,s,r-t,o-t);return l<0?null:{node:i,pos:l,text:s}}else return{node:i,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:r,text:o}){if(this.getDesc(t))return;let i=t;for(;i.parentNode!=this.contentDOM;i=i.parentNode){for(;i.previousSibling;)i.parentNode.removeChild(i.previousSibling);for(;i.nextSibling;)i.parentNode.removeChild(i.nextSibling);i.pmViewDesc&&(i.pmViewDesc=void 0)}let s=new vi(this,i,t,o);e.input.compositionNodes.push(s),this.children=Di(this.children,r,r+o.length,e,s)}update(e,t,r,o){return this.dirty==Be||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,r,o),!0)}updateInner(e,t,r,o){this.updateOuterDeco(t),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(o,this.posAtStart),this.dirty=Ae}updateOuterDeco(e){if(mr(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=dc(this.dom,this.nodeDOM,Ni(this.outerDeco,this.node,t),Ni(e,this.node,t)),this.dom!=r&&(r.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.dom.draggable=!0)}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.dom.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}};function Na(n,e,t,r,o){uc(r,e,n);let i=new ft(void 0,n,e,t,r,r,r,o,0);return i.contentDOM&&i.updateChildren(o,0),i}var pr=class n extends ft{constructor(e,t,r,o,i,s,l){super(e,t,r,o,i,null,s,l,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,r,o){return this.dirty==Be||this.dirty!=Ae&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=Ae||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,o.trackWrites==this.nodeDOM&&(o.trackWrites=null)),this.node=e,this.dirty=Ae,!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,r){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,t,r){let o=this.node.cut(e,t),i=document.createTextNode(o.text);return new n(this.parent,o,this.outerDeco,this.innerDeco,i,i,r)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=Be)}get domAtom(){return!1}isText(e){return this.node.text==e}},hr=class extends Lt{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==Ae&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}},Oi=class extends ft{constructor(e,t,r,o,i,s,l,a,c,d){super(e,t,r,o,i,s,l,c,d),this.spec=a}update(e,t,r,o){if(this.dirty==Be)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let i=this.spec.update(e,t,r);return i&&this.updateInner(e,t,r,o),i}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,t,r,o)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,r,o){this.spec.setSelection?this.spec.setSelection(e,t,r.root):super.setSelection(e,t,r,o)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}};function cc(n,e,t){let r=n.firstChild,o=!1;for(let i=0;i>1,s=Math.min(i,e.length);for(;o-1)l>this.index&&(this.changed=!0,this.destroyBetween(this.index,l)),this.top=this.top.children[this.index];else{let a=on.create(this.top,e[i],t,r);this.top.children.splice(this.index,0,a),this.top=a,this.changed=!0}this.index=0,i++}}findNodeMatch(e,t,r,o){let i=-1,s;if(o>=this.preMatch.index&&(s=this.preMatch.matches[o-this.preMatch.index]).parent==this.top&&s.matchesNode(e,t,r))i=this.top.children.indexOf(s,this.index);else for(let l=this.index,a=Math.min(this.top.children.length,l+5);l0;){let l;for(;;)if(r){let c=t.children[r-1];if(c instanceof on)t=c,r=c.children.length;else{l=c,r--;break}}else{if(t==e)break e;r=t.parent.children.indexOf(t),t=t.parent}let a=l.node;if(a){if(a!=n.child(o-1))break;--o,i.set(l,o),s.push(l)}}return{index:o,matched:i,matches:s.reverse()}}function Kf(n,e){return n.type.side-e.type.side}function Jf(n,e,t,r){let o=e.locals(n),i=0;if(o.length==0){for(let c=0;ci;)l.push(o[s++]);let h=i+f.nodeSize;if(f.isText){let g=h;s!g.inline):l.slice();r(f,m,e.forChild(i,f),p),i=h}}function Uf(n){if(n.nodeName=="UL"||n.nodeName=="OL"){let e=n.style.cssText;n.style.cssText=e+"; list-style: square !important",window.getComputedStyle(n).listStyle,n.style.cssText=e}}function qf(n,e,t,r){for(let o=0,i=0;o=t){if(i>=r&&a.slice(r-e.length-l,r-l)==e)return r-e.length;let c=l=0&&c+e.length+l>=t)return l+c;if(t==r&&a.length>=r+e.length-l&&a.slice(r-l,r-l+e.length)==e)return r}}return-1}function Di(n,e,t,r,o){let i=[];for(let s=0,l=0;s=t||d<=e?i.push(a):(ct&&i.push(a.slice(t-c,a.size,r)))}return i}function ji(n,e=null){let t=n.domSelectionRange(),r=n.state.doc;if(!t.focusNode)return null;let o=n.docView.nearestDesc(t.focusNode),i=o&&o.size==0,s=n.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(s<0)return null;let l=r.resolve(s),a,c;if(wr(t)){for(a=s;o&&!o.node;)o=o.parent;let u=o.node;if(o&&u.isAtom&&v.isSelectable(u)&&o.parent&&!(u.isInline&&Cf(t.focusNode,t.focusOffset,o.dom))){let f=o.posBefore;c=new v(s==f?l:r.resolve(f))}}else{if(t instanceof n.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let u=s,f=s;for(let p=0;p{(t.anchorNode!=r||t.anchorOffset!=o)&&(e.removeEventListener("selectionchange",n.input.hideSelectionGuard),setTimeout(()=>{(!fc(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function Yf(n){let e=n.domSelection(),t=document.createRange();if(!e)return;let r=n.cursorWrapper.dom,o=r.nodeName=="IMG";o?t.setStart(r.parentNode,ie(r)+1):t.setStart(r,0),t.collapse(!0),e.removeAllRanges(),e.addRange(t),!o&&!n.state.selection.visible&&ye&&ut<=11&&(r.disabled=!0,r.disabled=!1)}function pc(n,e){if(e instanceof v){let t=n.docView.descAt(e.from);t!=n.lastSelectedViewDesc&&(La(n),t&&t.selectNode(),n.lastSelectedViewDesc=t)}else La(n)}function La(n){n.lastSelectedViewDesc&&(n.lastSelectedViewDesc.parent&&n.lastSelectedViewDesc.deselectNode(),n.lastSelectedViewDesc=void 0)}function Wi(n,e,t,r){return n.someProp("createSelectionBetween",o=>o(n,e,t))||A.between(e,t,r)}function za(n){return n.editable&&!n.hasFocus()?!1:hc(n)}function hc(n){let e=n.domSelectionRange();if(!e.anchorNode)return!1;try{return n.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(n.editable||n.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch(t){return!1}}function Qf(n){let e=n.docView.domFromPos(n.state.selection.anchor,0),t=n.domSelectionRange();return Pt(e.node,e.offset,t.anchorNode,t.anchorOffset)}function Ii(n,e){let{$anchor:t,$head:r}=n.selection,o=e>0?t.max(r):t.min(r),i=o.parent.inlineContent?o.depth?n.doc.resolve(e>0?o.after():o.before()):null:o;return i&&E.findFrom(i,e)}function ct(n,e){return n.dispatch(n.state.tr.setSelection(e).scrollIntoView()),!0}function Ba(n,e,t){let r=n.state.selection;if(r instanceof A)if(t.indexOf("s")>-1){let{$head:o}=r,i=o.textOffset?null:e<0?o.nodeBefore:o.nodeAfter;if(!i||i.isText||!i.isLeaf)return!1;let s=n.state.doc.resolve(o.pos+i.nodeSize*(e<0?-1:1));return ct(n,new A(r.$anchor,s))}else if(r.empty){if(n.endOfTextblock(e>0?"forward":"backward")){let o=Ii(n.state,e);return o&&o instanceof v?ct(n,o):!1}else if(!(Me&&t.indexOf("m")>-1)){let o=r.$head,i=o.textOffset?null:e<0?o.nodeBefore:o.nodeAfter,s;if(!i||i.isText)return!1;let l=e<0?o.pos-i.nodeSize:o.pos;return i.isAtom||(s=n.docView.descAt(l))&&!s.contentDOM?v.isSelectable(i)?ct(n,new v(e<0?n.state.doc.resolve(o.pos-i.nodeSize):o)):Bn?ct(n,new A(n.state.doc.resolve(e<0?l:l+i.nodeSize))):!1:!1}}else return!1;else{if(r instanceof v&&r.node.isInline)return ct(n,new A(e>0?r.$to:r.$from));{let o=Ii(n.state,e);return o?ct(n,o):!1}}}function gr(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Nn(n,e){let t=n.pmViewDesc;return t&&t.size==0&&(e<0||n.nextSibling||n.nodeName!="BR")}function Zt(n,e){return e<0?Xf(n):Zf(n)}function Xf(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let o,i,s=!1;for(Re&&t.nodeType==1&&r0){if(t.nodeType!=1)break;{let l=t.childNodes[r-1];if(Nn(l,-1))o=t,i=--r;else if(l.nodeType==3)t=l,r=t.nodeValue.length;else break}}else{if(mc(t))break;{let l=t.previousSibling;for(;l&&Nn(l,-1);)o=t.parentNode,i=ie(l),l=l.previousSibling;if(l)t=l,r=gr(t);else{if(t=t.parentNode,t==n.dom)break;r=0}}}s?Pi(n,t,r):o&&Pi(n,o,i)}function Zf(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let o=gr(t),i,s;for(;;)if(r{n.state==o&&Ge(n)},50)}function Fa(n,e){let t=n.state.doc.resolve(e);if(!(de||Af)&&t.parent.inlineContent){let o=n.coordsAtPos(e);if(e>t.start()){let i=n.coordsAtPos(e-1),s=(i.top+i.bottom)/2;if(s>o.top&&s1)return i.lefto.top&&s1)return i.left>o.left?"ltr":"rtl"}}return getComputedStyle(n.dom).direction=="rtl"?"rtl":"ltr"}function Ha(n,e,t){let r=n.state.selection;if(r instanceof A&&!r.empty||t.indexOf("s")>-1||Me&&t.indexOf("m")>-1)return!1;let{$from:o,$to:i}=r;if(!o.parent.inlineContent||n.endOfTextblock(e<0?"up":"down")){let s=Ii(n.state,e);if(s&&s instanceof v)return ct(n,s)}if(!o.parent.inlineContent){let s=e<0?o:i,l=r instanceof ae?E.near(s,e):E.findFrom(s,e);return l?ct(n,l):!1}return!1}function $a(n,e){if(!(n.state.selection instanceof A))return!0;let{$head:t,$anchor:r,empty:o}=n.state.selection;if(!t.sameParent(r))return!0;if(!o)return!1;if(n.endOfTextblock(e>0?"forward":"backward"))return!0;let i=!t.textOffset&&(e<0?t.nodeBefore:t.nodeAfter);if(i&&!i.isText){let s=n.state.tr;return e<0?s.delete(t.pos-i.nodeSize,t.pos):s.delete(t.pos,t.pos+i.nodeSize),n.dispatch(s),!0}return!1}function _a(n,e,t){n.domObserver.stop(),e.contentEditable=t,n.domObserver.start()}function np(n){if(!he||n.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:t}=n.domSelectionRange();if(e&&e.nodeType==1&&t==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let r=e.firstChild;_a(n,r,"true"),setTimeout(()=>_a(n,r,"false"),20)}return!1}function rp(n){let e="";return n.ctrlKey&&(e+="c"),n.metaKey&&(e+="m"),n.altKey&&(e+="a"),n.shiftKey&&(e+="s"),e}function op(n,e){let t=e.keyCode,r=rp(e);if(t==8||Me&&t==72&&r=="c")return $a(n,-1)||Zt(n,-1);if(t==46&&!e.shiftKey||Me&&t==68&&r=="c")return $a(n,1)||Zt(n,1);if(t==13||t==27)return!0;if(t==37||Me&&t==66&&r=="c"){let o=t==37?Fa(n,n.state.selection.from)=="ltr"?-1:1:-1;return Ba(n,o,r)||Zt(n,o)}else if(t==39||Me&&t==70&&r=="c"){let o=t==39?Fa(n,n.state.selection.from)=="ltr"?1:-1:1;return Ba(n,o,r)||Zt(n,o)}else{if(t==38||Me&&t==80&&r=="c")return Ha(n,-1,r)||Zt(n,-1);if(t==40||Me&&t==78&&r=="c")return np(n)||Ha(n,1,r)||Zt(n,1);if(r==(Me?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function Ki(n,e){n.someProp("transformCopied",p=>{e=p(e,n)});let t=[],{content:r,openStart:o,openEnd:i}=e;for(;o>1&&i>1&&r.childCount==1&&r.firstChild.childCount==1;){o--,i--;let p=r.firstChild;t.push(p.type.name,p.attrs!=p.type.defaultAttrs?p.attrs:null),r=p.content}let s=n.someProp("clipboardSerializer")||Ie.fromSchema(n.state.schema),l=kc(),a=l.createElement("div");a.appendChild(s.serializeFragment(r,{document:l}));let c=a.firstChild,d,u=0;for(;c&&c.nodeType==1&&(d=xc[c.nodeName.toLowerCase()]);){for(let p=d.length-1;p>=0;p--){let h=l.createElement(d[p]);for(;a.firstChild;)h.appendChild(a.firstChild);a.appendChild(h),u++}c=a.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${o} ${i}${u?` -${u}`:""} ${JSON.stringify(t)}`);let f=n.someProp("clipboardTextSerializer",p=>p(e,n))||e.content.textBetween(0,e.content.size,` -`);return{dom:a,text:f,slice:e}}function Ji(n,e,t,r,o){let i=o.parent.type.spec.code,s,l;if(!t&&!e)return null;let a=e&&(r||i||!t);if(a){if(n.someProp("transformPastedText",f=>{e=f(e,i||r,n)}),i)return e?new w(x.from(n.state.schema.text(e.replace(/\r\n?/g,` -`))),0,0):w.empty;let u=n.someProp("clipboardTextParser",f=>f(e,o,r,n));if(u)l=u;else{let f=o.marks(),{schema:h}=n.state,p=Ie.fromSchema(h);s=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(m=>{let g=s.appendChild(document.createElement("p"));m&&g.appendChild(p.serializeNode(h.text(m,f)))})}}else n.someProp("transformPastedHTML",u=>{t=u(t,n)}),s=lh(t),zn&&ah(s);let c=s&&s.querySelector("[data-pm-slice]"),d=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(d&&d[3])for(let u=+d[3];u>0;u--){let f=s.firstChild;for(;f&&f.nodeType!=1;)f=f.nextSibling;if(!f)break;s=f}if(l||(l=(n.someProp("clipboardParser")||n.someProp("domParser")||Ne.fromSchema(n.state.schema)).parseSlice(s,{preserveWhitespace:!!(a||d),context:o,ruleFromNode(f){return f.nodeName=="BR"&&!f.nextSibling&&f.parentNode&&!oh.test(f.parentNode.nodeName)?{ignore:!0}:null}})),d)l=ch(_a(l,+d[1],+d[2]),d[4]);else if(l=w.maxOpen(ih(l.content,o),!0),l.openStart||l.openEnd){let u=0,f=0;for(let h=l.content.firstChild;u{l=u(l,n)}),l}var oh=/^(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 ih(n,e){if(n.childCount<2)return n;for(let t=e.depth;t>=0;t--){let o=e.node(t).contentMatchAt(e.index(t)),i,s=[];if(n.forEach(l=>{if(!s)return;let a=o.findWrapping(l.type),c;if(!a)return s=null;if(c=s.length&&i.length&&gc(a,i,l,s[s.length-1],0))s[s.length-1]=c;else{s.length&&(s[s.length-1]=yc(s[s.length-1],i.length));let d=mc(l,a);s.push(d),o=o.matchType(d.type),i=a}}),s)return x.from(s)}return n}function mc(n,e,t=0){for(let r=e.length-1;r>=t;r--)n=e[r].create(null,x.from(n));return n}function gc(n,e,t,r,o){if(o1&&(i=0),o=t&&(l=e<0?s.contentMatchAt(0).fillBefore(l,i<=o).append(l):l.append(s.contentMatchAt(s.childCount).fillBefore(x.empty,!0))),n.replaceChild(e<0?0:n.childCount-1,s.copy(l))}function _a(n,e,t){return et})),Si.createHTML(n)):n}function lh(n){let e=/^(\s*]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=xc().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(n),o;if((o=r&&bc[r[1].toLowerCase()])&&(n=o.map(i=>"<"+i+">").join("")+n+o.map(i=>"").reverse().join("")),t.innerHTML=sh(n),o)for(let i=0;i=0;l-=2){let a=t.nodes[r[l]];if(!a||a.hasRequiredAttrs())break;o=x.from(a.create(r[l+1],o)),i++,s++}return new w(o,i,s)}var me={},ge={},dh={touchstart:!0,touchmove:!0},Bi=class{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:""},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}};function uh(n){for(let e in me){let t=me[e];n.dom.addEventListener(e,n.input.eventHandlers[e]=r=>{hh(n,r)&&!Ui(n,r)&&(n.editable||!(r.type in ge))&&t(n,r)},dh[e]?{passive:!0}:void 0)}pe&&n.dom.addEventListener("input",()=>null),zi(n)}function dt(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}function fh(n){n.domObserver.stop();for(let e in n.input.eventHandlers)n.dom.removeEventListener(e,n.input.eventHandlers[e]);clearTimeout(n.input.composingTimeout),clearTimeout(n.input.lastIOSEnterFallbackTimeout)}function zi(n){n.someProp("handleDOMEvents",e=>{for(let t in e)n.input.eventHandlers[t]||n.dom.addEventListener(t,n.input.eventHandlers[t]=r=>Ui(n,r))})}function Ui(n,e){return n.someProp("handleDOMEvents",t=>{let r=t[e.type];return r?r(n,e)||e.defaultPrevented:!1})}function hh(n,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target;t!=n.dom;t=t.parentNode)if(!t||t.nodeType==11||t.pmViewDesc&&t.pmViewDesc.stopEvent(e))return!1;return!0}function ph(n,e){!Ui(n,e)&&me[e.type]&&(n.editable||!(e.type in ge))&&me[e.type](n,e)}ge.keydown=(n,e)=>{let t=e;if(n.input.shiftKey=t.keyCode==16||t.shiftKey,!Sc(n,t)&&(n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),!(qe&&de&&t.keyCode==13)))if(t.keyCode!=229&&n.domObserver.forceFlush(),rn&&t.keyCode==13&&!t.ctrlKey&&!t.altKey&&!t.metaKey){let r=Date.now();n.input.lastIOSEnter=r,n.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{n.input.lastIOSEnter==r&&(n.someProp("handleKeyDown",o=>o(n,Ot(13,"Enter"))),n.input.lastIOSEnter=0)},200)}else n.someProp("handleKeyDown",r=>r(n,t))||rh(n,t)?t.preventDefault():dt(n,"key")};ge.keyup=(n,e)=>{e.keyCode==16&&(n.input.shiftKey=!1)};ge.keypress=(n,e)=>{let t=e;if(Sc(n,t)||!t.charCode||t.ctrlKey&&!t.altKey||Me&&t.metaKey)return;if(n.someProp("handleKeyPress",o=>o(n,t))){t.preventDefault();return}let r=n.state.selection;if(!(r instanceof T)||!r.$from.sameParent(r.$to)){let o=String.fromCharCode(t.charCode);!/[\r\n]/.test(o)&&!n.someProp("handleTextInput",i=>i(n,r.$from.pos,r.$to.pos,o))&&n.dispatch(n.state.tr.insertText(o).scrollIntoView()),t.preventDefault()}};function wr(n){return{left:n.clientX,top:n.clientY}}function mh(n,e){let t=e.x-n.clientX,r=e.y-n.clientY;return t*t+r*r<100}function qi(n,e,t,r,o){if(r==-1)return!1;let i=n.state.doc.resolve(r);for(let s=i.depth+1;s>0;s--)if(n.someProp(e,l=>s>i.depth?l(n,t,i.nodeAfter,i.before(s),o,!0):l(n,t,i.node(s),i.before(s),o,!1)))return!0;return!1}function tn(n,e,t){if(n.focused||n.focus(),n.state.selection.eq(e))return;let r=n.state.tr.setSelection(e);t=="pointer"&&r.setMeta("pointer",!0),n.dispatch(r)}function gh(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),r=t.nodeAfter;return r&&r.isAtom&&O.isSelectable(r)?(tn(n,new O(t),"pointer"),!0):!1}function yh(n,e){if(e==-1)return!1;let t=n.state.selection,r,o;t instanceof O&&(r=t.node);let i=n.state.doc.resolve(e);for(let s=i.depth+1;s>0;s--){let l=s>i.depth?i.nodeAfter:i.node(s);if(O.isSelectable(l)){r&&t.$from.depth>0&&s>=t.$from.depth&&i.before(t.$from.depth+1)==t.$from.pos?o=i.before(t.$from.depth):o=i.before(s);break}}return o!=null?(tn(n,O.create(n.state.doc,o),"pointer"),!0):!1}function bh(n,e,t,r,o){return qi(n,"handleClickOn",e,t,r)||n.someProp("handleClick",i=>i(n,e,r))||(o?yh(n,t):gh(n,t))}function xh(n,e,t,r){return qi(n,"handleDoubleClickOn",e,t,r)||n.someProp("handleDoubleClick",o=>o(n,e,r))}function kh(n,e,t,r){return qi(n,"handleTripleClickOn",e,t,r)||n.someProp("handleTripleClick",o=>o(n,e,r))||Sh(n,t,r)}function Sh(n,e,t){if(t.button!=0)return!1;let r=n.state.doc;if(e==-1)return r.inlineContent?(tn(n,T.create(r,0,r.content.size),"pointer"),!0):!1;let o=r.resolve(e);for(let i=o.depth+1;i>0;i--){let s=i>o.depth?o.nodeAfter:o.node(i),l=o.before(i);if(s.inlineContent)tn(n,T.create(r,l+1,l+1+s.content.size),"pointer");else if(O.isSelectable(s))tn(n,O.create(r,l),"pointer");else continue;return!0}}function Gi(n){return Rn(n)}var kc=Me?"metaKey":"ctrlKey";me.mousedown=(n,e)=>{let t=e;n.input.shiftKey=t.shiftKey;let r=Gi(n),o=Date.now(),i="singleClick";o-n.input.lastClick.time<500&&mh(t,n.input.lastClick)&&!t[kc]&&(n.input.lastClick.type=="singleClick"?i="doubleClick":n.input.lastClick.type=="doubleClick"&&(i="tripleClick")),n.input.lastClick={time:o,x:t.clientX,y:t.clientY,type:i};let s=n.posAtCoords(wr(t));s&&(i=="singleClick"?(n.input.mouseDown&&n.input.mouseDown.done(),n.input.mouseDown=new Fi(n,s,t,!!r)):(i=="doubleClick"?xh:kh)(n,s.pos,s.inside,t)?t.preventDefault():dt(n,"pointer"))};var Fi=class{constructor(e,t,r,o){this.view=e,this.pos=t,this.event=r,this.flushed=o,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!r[kc],this.allowDefault=r.shiftKey;let i,s;if(t.inside>-1)i=e.state.doc.nodeAt(t.inside),s=t.inside;else{let d=e.state.doc.resolve(t.pos);i=d.parent,s=d.depth?d.before():0}let l=o?null:r.target,a=l?e.docView.nearestDesc(l,!0):null;this.target=a&&a.dom.nodeType==1?a.dom:null;let{selection:c}=e.state;(r.button==0&&i.type.spec.draggable&&i.type.spec.selectable!==!1||c instanceof O&&c.from<=s&&c.to>s)&&(this.mightDrag={node:i,pos:s,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Re&&!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()),e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this)),dt(e,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>Ge(this.view)),this.view.input.mouseDown=null}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(wr(e))),this.updateAllowDefault(e),this.allowDefault||!t?dt(this.view,"pointer"):bh(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||pe&&this.mightDrag&&!this.mightDrag.node.isAtom||de&&!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)?(tn(this.view,E.near(this.view.state.doc.resolve(t.pos)),"pointer"),e.preventDefault()):dt(this.view,"pointer")}move(e){this.updateAllowDefault(e),dt(this.view,"pointer"),e.buttons==0&&this.done()}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}};me.touchstart=n=>{n.input.lastTouch=Date.now(),Gi(n),dt(n,"pointer")};me.touchmove=n=>{n.input.lastTouch=Date.now(),dt(n,"pointer")};me.contextmenu=n=>Gi(n);function Sc(n,e){return n.composing?!0:pe&&Math.abs(e.timeStamp-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}var wh=qe?5e3:-1;ge.compositionstart=ge.compositionupdate=n=>{if(!n.composing){n.domObserver.flush();let{state:e}=n,t=e.selection.$to;if(e.selection instanceof T&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)))n.markCursor=n.state.storedMarks||t.marks(),Rn(n,!0),n.markCursor=null;else if(Rn(n,!e.selection.empty),Re&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length){let r=n.domSelectionRange();for(let o=r.focusNode,i=r.focusOffset;o&&o.nodeType==1&&i!=0;){let s=i<0?o.lastChild:o.childNodes[i-1];if(!s)break;if(s.nodeType==3){let l=n.domSelection();l&&l.collapse(s,s.nodeValue.length);break}else o=s,i=-1}}n.input.composing=!0}wc(n,wh)};ge.compositionend=(n,e)=>{n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=e.timeStamp,n.input.compositionPendingChanges=n.domObserver.pendingRecords().length?n.input.compositionID:0,n.input.compositionNode=null,n.input.compositionPendingChanges&&Promise.resolve().then(()=>n.domObserver.flush()),n.input.compositionID++,wc(n,20))};function wc(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>Rn(n),e))}function Cc(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=Mh());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function Ch(n){let e=n.domSelectionRange();if(!e.focusNode)return null;let t=kf(e.focusNode,e.focusOffset),r=Sf(e.focusNode,e.focusOffset);if(t&&r&&t!=r){let o=r.pmViewDesc,i=n.domObserver.lastChangedTextNode;if(t==i||r==i)return i;if(!o||!o.isText(r.nodeValue))return r;if(n.input.compositionNode==r){let s=t.pmViewDesc;if(!(!s||!s.isText(t.nodeValue)))return r}}return t||r}function Mh(){let n=document.createEvent("Event");return n.initEvent("event",!0,!0),n.timeStamp}function Rn(n,e=!1){if(!(qe&&n.domObserver.flushingSoon>=0)){if(n.domObserver.forceFlush(),Cc(n),e||n.docView&&n.docView.dirty){let t=ji(n);return t&&!t.eq(n.state.selection)?n.dispatch(n.state.tr.setSelection(t)):(n.markCursor||e)&&!n.state.selection.empty?n.dispatch(n.state.tr.deleteSelection()):n.updateState(n.state),!0}return!1}}function Ah(n,e){if(!n.dom.parentNode)return;let t=n.dom.parentNode.appendChild(document.createElement("div"));t.appendChild(e),t.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),o=document.createRange();o.selectNodeContents(e),n.dom.blur(),r.removeAllRanges(),r.addRange(o),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t),n.focus()},50)}var Dn=ye&&ut<15||rn&&Tf<604;me.copy=ge.cut=(n,e)=>{let t=e,r=n.state.selection,o=t.type=="cut";if(r.empty)return;let i=Dn?null:t.clipboardData,s=r.content(),{dom:l,text:a}=Ki(n,s);i?(t.preventDefault(),i.clearData(),i.setData("text/html",l.innerHTML),i.setData("text/plain",a)):Ah(n,l),o&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function Th(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function Eh(n,e){if(!n.dom.parentNode)return;let t=n.input.shiftKey||n.state.selection.$from.parent.type.spec.code,r=n.dom.parentNode.appendChild(document.createElement(t?"textarea":"div"));t||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let o=n.input.shiftKey&&n.input.lastKeyCode!=45;setTimeout(()=>{n.focus(),r.parentNode&&r.parentNode.removeChild(r),t?In(n,r.value,null,o,e):In(n,r.textContent,r.innerHTML,o,e)},50)}function In(n,e,t,r,o){let i=Ji(n,e,t,r,n.state.selection.$from);if(n.someProp("handlePaste",a=>a(n,o,i||w.empty)))return!0;if(!i)return!1;let s=Th(i),l=s?n.state.tr.replaceSelectionWith(s,r):n.state.tr.replaceSelection(i);return n.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Mc(n){let e=n.getData("text/plain")||n.getData("Text");if(e)return e;let t=n.getData("text/uri-list");return t?t.replace(/\r?\n/g," "):""}ge.paste=(n,e)=>{let t=e;if(n.composing&&!qe)return;let r=Dn?null:t.clipboardData,o=n.input.shiftKey&&n.input.lastKeyCode!=45;r&&In(n,Mc(r),r.getData("text/html"),o,t)?t.preventDefault():Eh(n,t)};var yr=class{constructor(e,t,r){this.slice=e,this.move=t,this.node=r}},Ac=Me?"altKey":"ctrlKey";me.dragstart=(n,e)=>{let t=e,r=n.input.mouseDown;if(r&&r.done(),!t.dataTransfer)return;let o=n.state.selection,i=o.empty?null:n.posAtCoords(wr(t)),s;if(!(i&&i.pos>=o.from&&i.pos<=(o instanceof O?o.to-1:o.to))){if(r&&r.mightDrag)s=O.create(n.state.doc,r.mightDrag.pos);else if(t.target&&t.target.nodeType==1){let u=n.docView.nearestDesc(t.target,!0);u&&u.node.type.spec.draggable&&u!=n.docView&&(s=O.create(n.state.doc,u.posBefore))}}let l=(s||n.state.selection).content(),{dom:a,text:c,slice:d}=Ki(n,l);(!t.dataTransfer.files.length||!de||tc>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(Dn?"Text":"text/html",a.innerHTML),t.dataTransfer.effectAllowed="copyMove",Dn||t.dataTransfer.setData("text/plain",c),n.dragging=new yr(d,!t[Ac],s)};me.dragend=n=>{let e=n.dragging;window.setTimeout(()=>{n.dragging==e&&(n.dragging=null)},50)};ge.dragover=ge.dragenter=(n,e)=>e.preventDefault();ge.drop=(n,e)=>{let t=e,r=n.dragging;if(n.dragging=null,!t.dataTransfer)return;let o=n.posAtCoords(wr(t));if(!o)return;let i=n.state.doc.resolve(o.pos),s=r&&r.slice;s?n.someProp("transformPasted",p=>{s=p(s,n)}):s=Ji(n,Mc(t.dataTransfer),Dn?null:t.dataTransfer.getData("text/html"),!1,i);let l=!!(r&&!t[Ac]);if(n.someProp("handleDrop",p=>p(n,t,s||w.empty,l))){t.preventDefault();return}if(!s)return;t.preventDefault();let a=s?An(n.state.doc,i.pos,s):i.pos;a==null&&(a=i.pos);let c=n.state.tr;if(l){let{node:p}=r;p?p.replace(c):c.deleteSelection()}let d=c.mapping.map(a),u=s.openStart==0&&s.openEnd==0&&s.content.childCount==1,f=c.doc;if(u?c.replaceRangeWith(d,d,s.content.firstChild):c.replaceRange(d,d,s),c.doc.eq(f))return;let h=c.doc.resolve(d);if(u&&O.isSelectable(s.content.firstChild)&&h.nodeAfter&&h.nodeAfter.sameMarkup(s.content.firstChild))c.setSelection(new O(h));else{let p=c.mapping.map(a);c.mapping.maps[c.mapping.maps.length-1].forEach((m,g,y,S)=>p=S),c.setSelection(Wi(n,h,c.doc.resolve(p)))}n.focus(),n.dispatch(c.setMeta("uiEvent","drop"))};me.focus=n=>{n.input.lastFocus=Date.now(),n.focused||(n.domObserver.stop(),n.dom.classList.add("ProseMirror-focused"),n.domObserver.start(),n.focused=!0,setTimeout(()=>{n.docView&&n.hasFocus()&&!n.domObserver.currentSelection.eq(n.domSelectionRange())&&Ge(n)},20))};me.blur=(n,e)=>{let t=e;n.focused&&(n.domObserver.stop(),n.dom.classList.remove("ProseMirror-focused"),n.domObserver.start(),t.relatedTarget&&n.dom.contains(t.relatedTarget)&&n.domObserver.currentSelection.clear(),n.focused=!1)};me.beforeinput=(n,e)=>{if(de&&qe&&e.inputType=="deleteContentBackward"){n.domObserver.flushSoon();let{domChangeCount:r}=n.input;setTimeout(()=>{if(n.input.domChangeCount!=r||(n.dom.blur(),n.focus(),n.someProp("handleKeyDown",i=>i(n,Ot(8,"Backspace")))))return;let{$cursor:o}=n.state.selection;o&&o.pos>0&&n.dispatch(n.state.tr.delete(o.pos-1,o.pos).scrollIntoView())},50)}};for(let n in ge)me[n]=ge[n];function Pn(n,e){if(n==e)return!0;for(let t in n)if(n[t]!==e[t])return!1;for(let t in e)if(!(t in n))return!1;return!0}var br=class n{constructor(e,t){this.toDOM=e,this.spec=t||Dt,this.side=this.spec.side||0}map(e,t,r,o){let{pos:i,deleted:s}=e.mapResult(t.from+o,this.side<0?-1:1);return s?null:new ne(i-r,i-r,this)}valid(){return!0}eq(e){return this==e||e instanceof n&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Pn(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}},Rt=class n{constructor(e,t){this.attrs=e,this.spec=t||Dt}map(e,t,r,o){let i=e.map(t.from+o,this.spec.inclusiveStart?-1:1)-r,s=e.map(t.to+o,this.spec.inclusiveEnd?1:-1)-r;return i>=s?null:new ne(i,s,this)}valid(e,t){return t.from=e&&(!i||i(l.spec))&&r.push(l.copy(l.from+o,l.to+o))}for(let s=0;se){let l=this.children[s]+1;this.children[s+2].findInner(e-l,t-l,r,o+l,i)}}map(e,t,r){return this==ce||e.maps.length==0?this:this.mapInner(e,t,0,0,r||Dt)}mapInner(e,t,r,o,i){let s;for(let l=0;l{let c=a+r,d;if(d=Ec(t,l,c)){for(o||(o=this.children.slice());il&&u.to=e){this.children[l]==e&&(r=this.children[l+2]);break}let i=e+1,s=i+t.content.size;for(let l=0;li&&a.type instanceof Rt){let c=Math.max(i,a.from)-i,d=Math.min(s,a.to)-i;co.map(e,t,Dt));return n.from(r)}forChild(e,t){if(t.isLeaf)return q.empty;let r=[];for(let o=0;ot instanceof q)?e:e.reduce((t,r)=>t.concat(r instanceof q?r:r.members),[]))}}forEachSet(e){for(let t=0;t{let g=m-p-(h-f);for(let y=0;yS+d-u)continue;let A=l[y]+d-u;h>=A?l[y+1]=f<=A?-2:-1:f>=d&&g&&(l[y]+=g,l[y+1]+=g)}u+=g}),d=t.maps[c].map(d,-1)}let a=!1;for(let c=0;c=r.content.size){a=!0;continue}let f=t.map(n[c+1]+i,-1),h=f-o,{index:p,offset:m}=r.content.findIndex(u),g=r.maybeChild(p);if(g&&m==u&&m+g.nodeSize==h){let y=l[c+2].mapInner(t,g,d+1,n[c]+i+1,s);y!=ce?(l[c]=u,l[c+1]=h,l[c+2]=y):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=vh(l,n,e,t,o,i,s),d=kr(c,r,0,s);e=d.local;for(let u=0;ut&&s.to{let c=Ec(n,l,a+t);if(c){i=!0;let d=kr(c,l,t+a+1,r);d!=ce&&o.push(a,a+l.nodeSize,d)}});let s=Tc(i?Oc(n):n,-t).sort(It);for(let l=0;l0;)e++;n.splice(e,0,t)}function wi(n){let e=[];return n.someProp("decorations",t=>{let r=t(n.state);r&&r!=ce&&e.push(r)}),n.cursorWrapper&&e.push(q.create(n.state.doc,[n.cursorWrapper.deco])),xr.from(e)}var Nh={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},Rh=ye&&ut<=11,$i=class{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}},_i=class{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new $i,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let o=0;oo.type=="childList"&&o.removedNodes.length||o.type=="characterData"&&o.oldValue.length>o.target.nodeValue.length)?this.flushSoon():this.flush()}),Rh&&(this.onCharData=r=>{this.queue.push({target:r.target,type:"characterData",oldValue:r.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,Nh)),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;tthis.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(La(this.view)){if(this.suppressingSelectionUpdates)return Ge(this.view);if(ye&&ut<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Pt(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t=new Set,r;for(let i=e.focusNode;i;i=nn(i))t.add(i);for(let i=e.anchorNode;i;i=nn(i))if(t.has(i)){r=i;break}let o=r&&this.view.docView.nearestDesc(r);if(o&&o.ignoreMutation({type:"selection",target:r.nodeType==3?r.parentNode:r}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.pendingRecords();t.length&&(this.queue=[]);let r=e.domSelectionRange(),o=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&La(e)&&!this.ignoreSelectionChange(r),i=-1,s=-1,l=!1,a=[];if(e.editable)for(let d=0;du.nodeName=="BR");if(d.length==2){let[u,f]=d;u.parentNode&&u.parentNode.parentNode==f.parentNode?f.remove():u.remove()}else{let{focusNode:u}=this.currentSelection;for(let f of d){let h=f.parentNode;h&&h.nodeName=="LI"&&(!u||Ph(e,u)!=h)&&f.remove()}}}let c=null;i<0&&o&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)-1||o)&&(i>-1&&(e.docView.markDirty(i,s),Dh(e)),this.handleDOMChange(i,s,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||Ge(e),this.currentSelection.set(r))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let r=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(r==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!r||r.ignoreMutation(e))return null;if(e.type=="childList"){for(let d=0;do;g--){let y=r.childNodes[g-1],S=y.pmViewDesc;if(y.nodeName=="BR"&&!S){i=g;break}if(!S||S.size)break}let u=n.state.doc,f=n.someProp("domParser")||Ne.fromSchema(n.state.schema),h=u.resolve(s),p=null,m=f.parse(r,{topNode:h.parent,topMatch:h.parent.contentMatchAt(h.index()),topOpen:!0,from:o,to:i,preserveWhitespace:h.parent.type.whitespace=="pre"?"full":!0,findPositions:c,ruleFromNode:Bh,context:h});if(c&&c[0].pos!=null){let g=c[0].pos,y=c[1]&&c[1].pos;y==null&&(y=g),p={anchor:g+s,head:y+s}}return{doc:m,sel:p,from:s,to:l}}function Bh(n){let e=n.pmViewDesc;if(e)return e.parseRule();if(n.nodeName=="BR"&&n.parentNode){if(pe&&/^(ul|ol)$/i.test(n.parentNode.nodeName)){let t=document.createElement("div");return t.appendChild(document.createElement("li")),{skip:t}}else if(n.parentNode.lastChild==n||pe&&/^(tr|table)$/i.test(n.parentNode.nodeName))return{ignore:!0}}else if(n.nodeName=="IMG"&&n.getAttribute("mark-placeholder"))return{ignore:!0};return null}var zh=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function Fh(n,e,t,r,o){let i=n.input.compositionPendingChanges||(n.composing?n.input.compositionID:0);if(n.input.compositionPendingChanges=0,e<0){let z=n.input.lastSelectionTime>Date.now()-50?n.input.lastSelectionOrigin:null,Ce=ji(n,z);if(Ce&&!n.state.selection.eq(Ce)){if(de&&qe&&n.input.lastKeyCode===13&&Date.now()-100pn(n,Ot(13,"Enter"))))return;let St=n.state.tr.setSelection(Ce);z=="pointer"?St.setMeta("pointer",!0):z=="key"&&St.scrollIntoView(),i&&St.setMeta("composition",i),n.dispatch(St)}return}let s=n.state.doc.resolve(e),l=s.sharedDepth(t);e=s.before(l+1),t=n.state.doc.resolve(t).after(l+1);let a=n.state.selection,c=Lh(n,e,t),d=n.state.doc,u=d.slice(c.from,c.to),f,h;n.input.lastKeyCode===8&&Date.now()-100Date.now()-225||qe)&&o.some(z=>z.nodeType==1&&!zh.test(z.nodeName))&&(!p||p.endA>=p.endB)&&n.someProp("handleKeyDown",z=>z(n,Ot(13,"Enter")))){n.input.lastIOSEnter=0;return}if(!p)if(r&&a instanceof T&&!a.empty&&a.$head.sameParent(a.$anchor)&&!n.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))p={start:a.from,endA:a.to,endB:a.to};else{if(c.sel){let z=Ua(n,n.state.doc,c.sel);if(z&&!z.eq(n.state.selection)){let Ce=n.state.tr.setSelection(z);i&&Ce.setMeta("composition",i),n.dispatch(Ce)}}return}n.state.selection.fromn.state.selection.from&&p.start<=n.state.selection.from+2&&n.state.selection.from>=c.from?p.start=n.state.selection.from:p.endA=n.state.selection.to-2&&n.state.selection.to<=c.to&&(p.endB+=n.state.selection.to-p.endA,p.endA=n.state.selection.to)),ye&&ut<=11&&p.endB==p.start+1&&p.endA==p.start&&p.start>c.from&&c.doc.textBetween(p.start-c.from-1,p.start-c.from+1)==" \xA0"&&(p.start--,p.endA--,p.endB--);let m=c.doc.resolveNoCache(p.start-c.from),g=c.doc.resolveNoCache(p.endB-c.from),y=d.resolve(p.start),S=m.sameParent(g)&&m.parent.inlineContent&&y.end()>=p.endA,A;if((rn&&n.input.lastIOSEnter>Date.now()-225&&(!S||o.some(z=>z.nodeName=="DIV"||z.nodeName=="P"))||!S&&m.posz(n,Ot(13,"Enter")))){n.input.lastIOSEnter=0;return}if(n.state.selection.anchor>p.start&&$h(d,p.start,p.endA,m,g)&&n.someProp("handleKeyDown",z=>z(n,Ot(8,"Backspace")))){qe&&de&&n.domObserver.suppressSelectionUpdates();return}de&&p.endB==p.start&&(n.input.lastChromeDelete=Date.now()),qe&&!S&&m.start()!=g.start()&&g.parentOffset==0&&m.depth==g.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==p.endA&&(p.endB-=2,g=c.doc.resolveNoCache(p.endB-c.from),setTimeout(()=>{n.someProp("handleKeyDown",function(z){return z(n,Ot(13,"Enter"))})},20));let I=p.start,M=p.endA,R,_,Q;if(S){if(m.pos==g.pos)ye&&ut<=11&&m.parentOffset==0&&(n.domObserver.suppressSelectionUpdates(),setTimeout(()=>Ge(n),20)),R=n.state.tr.delete(I,M),_=d.resolve(p.start).marksAcross(d.resolve(p.endA));else if(p.endA==p.endB&&(Q=Hh(m.parent.content.cut(m.parentOffset,g.parentOffset),y.parent.content.cut(y.parentOffset,p.endA-y.start()))))R=n.state.tr,Q.type=="add"?R.addMark(I,M,Q.mark):R.removeMark(I,M,Q.mark);else if(m.parent.child(m.index()).isText&&m.index()==g.index()-(g.textOffset?0:1)){let z=m.parent.textBetween(m.parentOffset,g.parentOffset);if(n.someProp("handleTextInput",Ce=>Ce(n,I,M,z)))return;R=n.state.tr.insertText(z,I,M)}}if(R||(R=n.state.tr.replace(I,M,c.doc.slice(p.start-c.from,p.endB-c.from))),c.sel){let z=Ua(n,R.doc,c.sel);z&&!(de&&n.composing&&z.empty&&(p.start!=p.endB||n.input.lastChromeDeletee.content.size?null:Wi(n,e.resolve(t.anchor),e.resolve(t.head))}function Hh(n,e){let t=n.firstChild.marks,r=e.firstChild.marks,o=t,i=r,s,l,a;for(let d=0;dd.mark(l.addToSet(d.marks));else if(o.length==0&&i.length==1)l=i[0],s="remove",a=d=>d.mark(l.removeFromSet(d.marks));else return null;let c=[];for(let d=0;dt||Ci(s,!0,!1)0&&(e||n.indexAfter(r)==n.node(r).childCount);)r--,o++,e=!1;if(t){let i=n.node(r).maybeChild(n.indexAfter(r));for(;i&&!i.isLeaf;)i=i.firstChild,o++}return o}function _h(n,e,t,r,o){let i=n.findDiffStart(e,t);if(i==null)return null;let{a:s,b:l}=n.findDiffEnd(e,t+n.size,t+e.size);if(o=="end"){let a=Math.max(0,i-Math.min(s,l));r-=s+a-i}if(s=s?i-r:0;i-=a,i&&i=l?i-r:0;i-=a,i&&i=56320&&e<=57343&&t>=55296&&t<=56319}var Vh=Ji,jh=Rn,Ln=class{constructor(e,t){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new Bi,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(Za),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):typeof e=="function"?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=Qa(this),Ya(this),this.nodeViews=Xa(this),this.docView=va(this.state.doc,Ga(this),wi(this),this.dom,this),this.domObserver=new _i(this,(r,o,i,s)=>Fh(this,r,o,i,s)),this.domObserver.start(),uh(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&&zi(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Za),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let r in this._props)t[r]=this._props[r];t.state=this.state;for(let r in e)t[r]=e[r];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var r;let o=this.state,i=!1,s=!1;e.storedMarks&&this.composing&&(Cc(this),s=!0),this.state=e;let l=o.plugins!=e.plugins||this._props.plugins!=t.plugins;if(l||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let h=Xa(this);Kh(h,this.nodeViews)&&(this.nodeViews=h,i=!0)}(l||t.handleDOMEvents!=this._props.handleDOMEvents)&&zi(this),this.editable=Qa(this),Ya(this);let a=wi(this),c=Ga(this),d=o.plugins!=e.plugins&&!o.doc.eq(e.doc)?"reset":e.scrollToSelection>o.scrollToSelection?"to selection":"preserve",u=i||!this.docView.matchesNode(e.doc,c,a);(u||!e.selection.eq(o.selection))&&(s=!0);let f=d=="preserve"&&s&&this.dom.style.overflowAnchor==null&&vf(this);if(s){this.domObserver.stop();let h=u&&(ye||de)&&!this.composing&&!o.selection.empty&&!e.selection.empty&&Wh(o.selection,e.selection);if(u){let p=de?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=Ch(this)),(i||!this.docView.update(e.doc,c,a,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=va(e.doc,c,a,this.dom,this)),p&&!this.trackWrites&&(h=!0)}h||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&Yf(this))?Ge(this,h):(fc(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(o),!((r=this.dragging)===null||r===void 0)&&r.node&&!o.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,o),d=="reset"?this.dom.scrollTop=0:d=="to selection"?this.scrollToSelection():f&&Nf(f)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))){if(!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof O){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&Ca(this,t.getBoundingClientRect(),e)}else Ca(this,this.coordsAtPos(this.state.selection.head,1),e)}}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let t=0;t0&&this.state.doc.nodeAt(i))==r.node&&(o=i)}this.dragging=new yr(e.slice,e.move,o<0?void 0:O.create(this.state.doc,o))}someProp(e,t){let r=this._props&&this._props[e],o;if(r!=null&&(o=t?t(r):r))return o;for(let s=0;st.ownerDocument.getSelection()),this._root=t}return e||document}updateRoot(){this._root=null}posAtCoords(e){return Bf(this,e)}coordsAtPos(e,t=1){return sc(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,r=-1){let o=this.docView.posFromDOM(e,t,r);if(o==null)throw new RangeError("DOM position not inside the editor");return o}endOfTextblock(e,t){return _f(this,t||this.state,e)}pasteHTML(e,t){return In(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return In(this,e,null,!0,t||new ClipboardEvent("paste"))}serializeForClipboard(e){return Ki(this,e)}destroy(){this.docView&&(fh(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],wi(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,bf())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return ph(this,e)}dispatch(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))}domSelectionRange(){let e=this.domSelection();return e?pe&&this.root.nodeType===11&&Cf(this.dom.ownerDocument)==this.dom&&Ih(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}};function Ga(n){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(n.editable),n.someProp("attributes",t=>{if(typeof t=="function"&&(t=t(n.state)),t)for(let r in t)r=="class"?e.class+=" "+t[r]:r=="style"?e.style=(e.style?e.style+";":"")+t[r]:!e[r]&&r!="contenteditable"&&r!="nodeName"&&(e[r]=String(t[r]))}),e.translate||(e.translate="no"),[ne.node(0,n.state.doc.content.size,e)]}function Ya(n){if(n.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),n.cursorWrapper={dom:e,deco:ne.widget(n.state.selection.from,e,{raw:!0,marks:n.markCursor})}}else n.cursorWrapper=null}function Qa(n){return!n.someProp("editable",e=>e(n.state)===!1)}function Wh(n,e){let t=Math.min(n.$anchor.sharedDepth(n.head),e.$anchor.sharedDepth(e.head));return n.$anchor.start(t)!=e.$anchor.start(t)}function Xa(n){let e=Object.create(null);function t(r){for(let o in r)Object.prototype.hasOwnProperty.call(e,o)||(e[o]=r[o])}return n.someProp("nodeViews",t),n.someProp("markViews",t),e}function Kh(n,e){let t=0,r=0;for(let o in n){if(n[o]!=e[o])return!0;t++}for(let o in e)r++;return t!=r}function Za(n){if(n.spec.state||n.spec.filterTransaction||n.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var Tr={};rt(Tr,{keydownHandler:()=>sn,keymap:()=>Xi});var Ye={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:"'"},Ar={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Jh=typeof navigator!="undefined"&&/Mac/.test(navigator.platform),Uh=typeof navigator!="undefined"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(Z=0;Z<10;Z++)Ye[48+Z]=Ye[96+Z]=String(Z);var Z;for(Z=1;Z<=24;Z++)Ye[Z+111]="F"+Z;var Z;for(Z=65;Z<=90;Z++)Ye[Z]=String.fromCharCode(Z+32),Ar[Z]=String.fromCharCode(Z);var Z;for(Mr in Ye)Ar.hasOwnProperty(Mr)||(Ar[Mr]=Ye[Mr]);var Mr;function vc(n){var e=Jh&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||Uh&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?Ar:Ye)[n.keyCode]||n.key||"Unidentified";return t=="Esc"&&(t="Escape"),t=="Del"&&(t="Delete"),t=="Left"&&(t="ArrowLeft"),t=="Up"&&(t="ArrowUp"),t=="Right"&&(t="ArrowRight"),t=="Down"&&(t="ArrowDown"),t}var qh=typeof navigator!="undefined"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):!1;function Gh(n){let e=n.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");let r,o,i,s;for(let l=0;l127)&&(i=Ye[r.keyCode])&&i!=o){let l=e[Qi(i,r)];if(l&&l(t.state,t.dispatch,t))return!0}}return!1}}var Er={};rt(Er,{ContentMatch:()=>st,DOMParser:()=>Ne,DOMSerializer:()=>Ie,Fragment:()=>x,Mark:()=>F,MarkType:()=>jt,Node:()=>he,NodeRange:()=>it,NodeType:()=>xn,ReplaceError:()=>ot,ResolvedPos:()=>bn,Schema:()=>Wt,Slice:()=>w});var Or={};rt(Or,{AddMarkStep:()=>Ut,AddNodeMarkStep:()=>qt,AttrStep:()=>Cn,DocAttrStep:()=>Mn,MapResult:()=>Kt,Mapping:()=>Jt,RemoveMarkStep:()=>lt,RemoveNodeMarkStep:()=>Gt,ReplaceAroundStep:()=>X,ReplaceStep:()=>oe,Step:()=>ee,StepMap:()=>Pe,StepResult:()=>te,Transform:()=>We,TransformError:()=>Mt,canJoin:()=>Se,canSplit:()=>ke,dropPoint:()=>An,findWrapping:()=>At,insertPoint:()=>aa,joinPoint:()=>Tt,liftTarget:()=>Le,replaceStep:()=>Yt});var _r={};rt(_r,{autoJoin:()=>rp,baseKeymap:()=>ip,chainCommands:()=>$r,createParagraphNear:()=>Lr,deleteSelection:()=>Fn,exitCode:()=>Pr,joinBackward:()=>vr,joinDown:()=>ss,joinForward:()=>Rr,joinTextblockBackward:()=>es,joinTextblockForward:()=>ts,joinUp:()=>is,lift:()=>ls,liftEmptyBlock:()=>Br,macBaseKeymap:()=>fs,newlineInCode:()=>Ir,pcBaseKeymap:()=>Fe,selectAll:()=>Lc,selectNodeBackward:()=>Nr,selectNodeForward:()=>Dr,selectParentNode:()=>ds,selectTextblockEnd:()=>Fr,selectTextblockStart:()=>zr,setBlockType:()=>Hr,splitBlock:()=>cs,splitBlockAs:()=>Pc,splitBlockKeepMarks:()=>Qh,toggleMark:()=>tp,wrapIn:()=>us});var Fn=(n,e)=>n.selection.empty?!1:(e&&e(n.tr.deleteSelection().scrollIntoView()),!0);function Rc(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("backward",n):t.parentOffset>0)?null:t}var vr=(n,e,t)=>{let r=Rc(n,t);if(!r)return!1;let o=ns(r);if(!o){let s=r.blockRange(),l=s&&Le(s);return l==null?!1:(e&&e(n.tr.lift(s,l).scrollIntoView()),!0)}let i=o.nodeBefore;if(Bc(n,o,e,-1))return!0;if(r.parent.content.size==0&&(ln(i,"end")||O.isSelectable(i)))for(let s=r.depth;;s--){let l=Yt(n.doc,r.before(s),r.after(s),w.empty);if(l&&l.slice.size1)break}return i.isAtom&&o.depth==r.depth-1?(e&&e(n.tr.delete(o.pos-i.nodeSize,o.pos).scrollIntoView()),!0):!1},es=(n,e,t)=>{let r=Rc(n,t);if(!r)return!1;let o=ns(r);return o?Dc(n,o,e):!1},ts=(n,e,t)=>{let r=Ic(n,t);if(!r)return!1;let o=rs(r);return o?Dc(n,o,e):!1};function Dc(n,e,t){let r=e.nodeBefore,o=r,i=e.pos-1;for(;!o.isTextblock;i--){if(o.type.spec.isolating)return!1;let d=o.lastChild;if(!d)return!1;o=d}let s=e.nodeAfter,l=s,a=e.pos+1;for(;!l.isTextblock;a++){if(l.type.spec.isolating)return!1;let d=l.firstChild;if(!d)return!1;l=d}let c=Yt(n.doc,i,a,w.empty);if(!c||c.from!=i||c instanceof oe&&c.slice.size>=a-i)return!1;if(t){let d=n.tr.step(c);d.setSelection(T.create(d.doc,i)),t(d.scrollIntoView())}return!0}function ln(n,e,t=!1){for(let r=n;r;r=e=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(t&&r.childCount!=1)return!1}return!1}var Nr=(n,e,t)=>{let{$head:r,empty:o}=n.selection,i=r;if(!o)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("backward",n):r.parentOffset>0)return!1;i=ns(r)}let s=i&&i.nodeBefore;return!s||!O.isSelectable(s)?!1:(e&&e(n.tr.setSelection(O.create(n.doc,i.pos-s.nodeSize)).scrollIntoView()),!0)};function ns(n){if(!n.parent.type.spec.isolating)for(let e=n.depth-1;e>=0;e--){if(n.index(e)>0)return n.doc.resolve(n.before(e+1));if(n.node(e).type.spec.isolating)break}return null}function Ic(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("forward",n):t.parentOffset{let r=Ic(n,t);if(!r)return!1;let o=rs(r);if(!o)return!1;let i=o.nodeAfter;if(Bc(n,o,e,1))return!0;if(r.parent.content.size==0&&(ln(i,"start")||O.isSelectable(i))){let s=Yt(n.doc,r.before(),r.after(),w.empty);if(s&&s.slice.size{let{$head:r,empty:o}=n.selection,i=r;if(!o)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("forward",n):r.parentOffset=0;e--){let t=n.node(e);if(n.index(e)+1{let t=n.selection,r=t instanceof O,o;if(r){if(t.node.isTextblock||!Se(n.doc,t.from))return!1;o=t.from}else if(o=Tt(n.doc,t.from,-1),o==null)return!1;if(e){let i=n.tr.join(o);r&&i.setSelection(O.create(i.doc,o-n.doc.resolve(o).nodeBefore.nodeSize)),e(i.scrollIntoView())}return!0},ss=(n,e)=>{let t=n.selection,r;if(t instanceof O){if(t.node.isTextblock||!Se(n.doc,t.to))return!1;r=t.to}else if(r=Tt(n.doc,t.to,1),r==null)return!1;return e&&e(n.tr.join(r).scrollIntoView()),!0},ls=(n,e)=>{let{$from:t,$to:r}=n.selection,o=t.blockRange(r),i=o&&Le(o);return i==null?!1:(e&&e(n.tr.lift(o,i).scrollIntoView()),!0)},Ir=(n,e)=>{let{$head:t,$anchor:r}=n.selection;return!t.parent.type.spec.code||!t.sameParent(r)?!1:(e&&e(n.tr.insertText(` -`).scrollIntoView()),!0)};function as(n){for(let e=0;e{let{$head:t,$anchor:r}=n.selection;if(!t.parent.type.spec.code||!t.sameParent(r))return!1;let o=t.node(-1),i=t.indexAfter(-1),s=as(o.contentMatchAt(i));if(!s||!o.canReplaceWith(i,i,s))return!1;if(e){let l=t.after(),a=n.tr.replaceWith(l,l,s.createAndFill());a.setSelection(E.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},Lr=(n,e)=>{let t=n.selection,{$from:r,$to:o}=t;if(t instanceof ae||r.parent.inlineContent||o.parent.inlineContent)return!1;let i=as(o.parent.contentMatchAt(o.indexAfter()));if(!i||!i.isTextblock)return!1;if(e){let s=(!r.parentOffset&&o.index(){let{$cursor:t}=n.selection;if(!t||t.parent.content.size)return!1;if(t.depth>1&&t.after()!=t.end(-1)){let i=t.before();if(ke(n.doc,i))return e&&e(n.tr.split(i).scrollIntoView()),!0}let r=t.blockRange(),o=r&&Le(r);return o==null?!1:(e&&e(n.tr.lift(r,o).scrollIntoView()),!0)};function Pc(n){return(e,t)=>{let{$from:r,$to:o}=e.selection;if(e.selection instanceof O&&e.selection.node.isBlock)return!r.parentOffset||!ke(e.doc,r.pos)?!1:(t&&t(e.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let i=[],s,l,a=!1,c=!1;for(let h=r.depth;;h--)if(r.node(h).isBlock){a=r.end(h)==r.pos+(r.depth-h),c=r.start(h)==r.pos-(r.depth-h),l=as(r.node(h-1).contentMatchAt(r.indexAfter(h-1)));let m=n&&n(o.parent,a,r);i.unshift(m||(a&&l?{type:l}:null)),s=h;break}else{if(h==1)return!1;i.unshift(null)}let d=e.tr;(e.selection instanceof T||e.selection instanceof ae)&&d.deleteSelection();let u=d.mapping.map(r.pos),f=ke(d.doc,u,i.length,i);if(f||(i[0]=l?{type:l}:null,f=ke(d.doc,u,i.length,i)),d.split(u,i.length,i),!a&&c&&r.node(s).type!=l){let h=d.mapping.map(r.before(s)),p=d.doc.resolve(h);l&&r.node(s-1).canReplaceWith(p.index(),p.index()+1,l)&&d.setNodeMarkup(d.mapping.map(r.before(s)),l)}return t&&t(d.scrollIntoView()),!0}}var cs=Pc(),Qh=(n,e)=>cs(n,e&&(t=>{let r=n.storedMarks||n.selection.$to.parentOffset&&n.selection.$from.marks();r&&t.ensureMarks(r),e(t)})),ds=(n,e)=>{let{$from:t,to:r}=n.selection,o,i=t.sharedDepth(r);return i==0?!1:(o=t.before(i),e&&e(n.tr.setSelection(O.create(n.doc,o))),!0)},Lc=(n,e)=>(e&&e(n.tr.setSelection(new ae(n.doc))),!0);function Xh(n,e,t){let r=e.nodeBefore,o=e.nodeAfter,i=e.index();return!r||!o||!r.type.compatibleContent(o.type)?!1:!r.content.size&&e.parent.canReplace(i-1,i)?(t&&t(n.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(i,i+1)||!(o.isTextblock||Se(n.doc,e.pos))?!1:(t&&t(n.tr.join(e.pos).scrollIntoView()),!0)}function Bc(n,e,t,r){let o=e.nodeBefore,i=e.nodeAfter,s,l,a=o.type.spec.isolating||i.type.spec.isolating;if(!a&&Xh(n,e,t))return!0;let c=!a&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(s=(l=o.contentMatchAt(o.childCount)).findWrapping(i.type))&&l.matchType(s[0]||i.type).validEnd){if(t){let h=e.pos+i.nodeSize,p=x.empty;for(let y=s.length-1;y>=0;y--)p=x.from(s[y].create(null,p));p=x.from(o.copy(p));let m=n.tr.step(new X(e.pos-1,h,e.pos,h,new w(p,1,0),s.length,!0)),g=m.doc.resolve(h+2*s.length);g.nodeAfter&&g.nodeAfter.type==o.type&&Se(m.doc,g.pos)&&m.join(g.pos),t(m.scrollIntoView())}return!0}let d=i.type.spec.isolating||r>0&&a?null:E.findFrom(e,1),u=d&&d.$from.blockRange(d.$to),f=u&&Le(u);if(f!=null&&f>=e.depth)return t&&t(n.tr.lift(u,f).scrollIntoView()),!0;if(c&&ln(i,"start",!0)&&ln(o,"end")){let h=o,p=[];for(;p.push(h),!h.isTextblock;)h=h.lastChild;let m=i,g=1;for(;!m.isTextblock;m=m.firstChild)g++;if(h.canReplace(h.childCount,h.childCount,m.content)){if(t){let y=x.empty;for(let A=p.length-1;A>=0;A--)y=x.from(p[A].copy(y));let S=n.tr.step(new X(e.pos-p.length,e.pos+i.nodeSize,e.pos+g,e.pos+i.nodeSize-g,new w(y,p.length,0),0,!0));t(S.scrollIntoView())}return!0}}return!1}function zc(n){return function(e,t){let r=e.selection,o=n<0?r.$from:r.$to,i=o.depth;for(;o.node(i).isInline;){if(!i)return!1;i--}return o.node(i).isTextblock?(t&&t(e.tr.setSelection(T.create(e.doc,n<0?o.start(i):o.end(i)))),!0):!1}}var zr=zc(-1),Fr=zc(1);function us(n,e=null){return function(t,r){let{$from:o,$to:i}=t.selection,s=o.blockRange(i),l=s&&At(s,n,e);return l?(r&&r(t.tr.wrap(s,l).scrollIntoView()),!0):!1}}function Hr(n,e=null){return function(t,r){let o=!1;for(let i=0;i{if(o)return!1;if(!(!a.isTextblock||a.hasMarkup(n,e)))if(a.type==n)o=!0;else{let d=t.doc.resolve(c),u=d.index();o=d.parent.canReplaceWith(u,u+1,n)}})}if(!o)return!1;if(r){let i=t.tr;for(let s=0;s{if(l||!r&&a.isAtom&&a.isInline&&c>=i.pos&&c+a.nodeSize<=s.pos)return!1;l=a.inlineContent&&a.type.allowsMarkType(t)}),l)return!0}return!1}function ep(n){let e=[];for(let t=0;t{if(i.isAtom&&i.content.size&&i.isInline&&s>=r.pos&&s+i.nodeSize<=o.pos)return s+1>r.pos&&e.push(new Ke(r,r.doc.resolve(s+1))),r=r.doc.resolve(s+1+i.content.size),!1}),r.poss.doc.rangeHasMark(h.$from.pos,h.$to.pos,n)):u=!d.every(h=>{let p=!1;return f.doc.nodesBetween(h.$from.pos,h.$to.pos,(m,g,y)=>{if(p)return!1;p=!n.isInSet(m.marks)&&!!y&&y.type.allowsMarkType(n)&&!(m.isText&&/^\s*$/.test(m.textBetween(Math.max(0,h.$from.pos-g),Math.min(m.nodeSize,h.$to.pos-g))))}),!p});for(let h=0;h{if(!t.isGeneric)return n(t);let r=[];for(let i=0;ir.push(c,d))}let o=[];for(let i=0;ii-s);for(let i=o.length-1;i>=0;i--)Se(t.doc,o[i])&&t.join(o[i]);n(t)}}function rp(n,e){let t=Array.isArray(e)?r=>e.indexOf(r.type.name)>-1:e;return(r,o,i)=>n(r,o&&np(o,t),i)}function $r(...n){return function(e,t,r){for(let o=0;o=2&&e.$from.node(e.depth-1).type.compatibleContent(t)&&e.startIndex==0){if(e.$from.index(e.depth-1)==0)return!1;let a=s.resolve(e.start-2);i=new it(a,a,e.depth),e.endIndex=0;d--)i=x.from(t[d].type.create(t[d].attrs,i));n.step(new X(e.start-(r?2:0),e.end,e.start,e.end,new w(i,0,0),t.length,!0));let s=0;for(let d=0;ds.childCount>0&&s.firstChild.type==n);return i?t?r.node(i.depth-1).type==n?ap(e,t,n,i):cp(e,t,i):!0:!1}}function ap(n,e,t,r){let o=n.tr,i=r.end,s=r.$to.end(r.depth);im;p--)h-=o.child(p).nodeSize,r.delete(h-1,h+1);let i=r.doc.resolve(t.start),s=i.nodeAfter;if(r.mapping.map(t.end)!=t.start+i.nodeAfter.nodeSize)return!1;let l=t.startIndex==0,a=t.endIndex==o.childCount,c=i.node(-1),d=i.index(-1);if(!c.canReplace(d+(l?0:1),d+1,s.content.append(a?x.empty:x.from(o))))return!1;let u=i.pos,f=u+s.nodeSize;return r.step(new X(u-(l?1:0),f+(a?1:0),u+1,f-1,new w((l?x.empty:x.from(o.copy(x.empty))).append(a?x.empty:x.from(o.copy(x.empty))),l?0:1,a?0:1),l?0:1)),e(r.scrollIntoView()),!0}function $c(n){return function(e,t){let{$from:r,$to:o}=e.selection,i=r.blockRange(o,c=>c.childCount>0&&c.firstChild.type==n);if(!i)return!1;let s=i.startIndex;if(s==0)return!1;let l=i.parent,a=l.child(s-1);if(a.type!=n)return!1;if(t){let c=a.lastChild&&a.lastChild.type==l.type,d=x.from(c?n.create():null),u=new w(x.from(n.create(null,x.from(l.type.create(null,d)))),c?3:1,0),f=i.start,h=i.end;t(e.tr.step(new X(f-(c?3:1),h,f,h,u,1,!0)).scrollIntoView())}return!0}}function Yr(n){let{state:e,transaction:t}=n,{selection:r}=t,{doc:o}=t,{storedMarks:i}=t;return N(b({},e),{apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return i},get selection(){return r},get doc(){return o},get tr(){return r=t.selection,o=t.doc,i=t.storedMarks,t}})}var an=class{constructor(e){this.editor=e.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=e.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){let{rawCommands:e,editor:t,state:r}=this,{view:o}=t,{tr:i}=r,s=this.buildProps(i);return Object.fromEntries(Object.entries(e).map(([l,a])=>[l,(...d)=>{let u=a(...d)(s);return!i.getMeta("preventDispatch")&&!this.hasCustomState&&o.dispatch(i),u}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(e,t=!0){let{rawCommands:r,editor:o,state:i}=this,{view:s}=o,l=[],a=!!e,c=e||i.tr,d=()=>(!a&&t&&!c.getMeta("preventDispatch")&&!this.hasCustomState&&s.dispatch(c),l.every(f=>f===!0)),u=N(b({},Object.fromEntries(Object.entries(r).map(([f,h])=>[f,(...m)=>{let g=this.buildProps(c,t),y=h(...m)(g);return l.push(y),u}]))),{run:d});return u}createCan(e){let{rawCommands:t,state:r}=this,o=!1,i=e||r.tr,s=this.buildProps(i,o),l=Object.fromEntries(Object.entries(t).map(([a,c])=>[a,(...d)=>c(...d)(N(b({},s),{dispatch:void 0}))]));return N(b({},l),{chain:()=>this.createChain(i,o)})}buildProps(e,t=!0){let{rawCommands:r,editor:o,state:i}=this,{view:s}=o,l={tr:e,editor:o,view:s,state:Yr({state:i,transaction:e}),dispatch:t?()=>{}:void 0,chain:()=>this.createChain(e,t),can:()=>this.createCan(e),get commands(){return Object.fromEntries(Object.entries(r).map(([a,c])=>[a,(...d)=>c(...d)(l)]))}};return l}},gs=class{constructor(){this.callbacks={}}on(e,t){return this.callbacks[e]||(this.callbacks[e]=[]),this.callbacks[e].push(t),this}emit(e,...t){let r=this.callbacks[e];return r&&r.forEach(o=>o.apply(this,t)),this}off(e,t){let r=this.callbacks[e];return r&&(t?this.callbacks[e]=r.filter(o=>o!==t):delete this.callbacks[e]),this}once(e,t){let r=(...o)=>{this.off(e,r),t.apply(this,o)};return this.on(e,r)}removeAllListeners(){this.callbacks={}}};function C(n,e,t){return n.config[e]===void 0&&n.parent?C(n.parent,e,t):typeof n.config[e]=="function"?n.config[e].bind(N(b({},t),{parent:n.parent?C(n.parent,e,t):null})):n.config[e]}function Qr(n){let e=n.filter(o=>o.type==="extension"),t=n.filter(o=>o.type==="node"),r=n.filter(o=>o.type==="mark");return{baseExtensions:e,nodeExtensions:t,markExtensions:r}}function Yc(n){let e=[],{nodeExtensions:t,markExtensions:r}=Qr(n),o=[...t,...r],i={default:null,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return n.forEach(s=>{let l={name:s.name,options:s.options,storage:s.storage,extensions:o},a=C(s,"addGlobalAttributes",l);if(!a)return;a().forEach(d=>{d.types.forEach(u=>{Object.entries(d.attributes).forEach(([f,h])=>{e.push({type:u,name:f,attribute:b(b({},i),h)})})})})}),o.forEach(s=>{let l={name:s.name,options:s.options,storage:s.storage},a=C(s,"addAttributes",l);if(!a)return;let c=a();Object.entries(c).forEach(([d,u])=>{let f=b(b({},i),u);typeof(f==null?void 0:f.default)=="function"&&(f.default=f.default()),f!=null&&f.isRequired&&(f==null?void 0:f.default)===void 0&&delete f.default,e.push({type:s.name,name:d,attribute:f})})}),e}function re(n,e){if(typeof n=="string"){if(!e.nodes[n])throw Error(`There is no node type named '${n}'. Maybe you forgot to add the extension?`);return e.nodes[n]}return n}function v(...n){return n.filter(e=>!!e).reduce((e,t)=>{let r=b({},e);return Object.entries(t).forEach(([o,i])=>{if(!r[o]){r[o]=i;return}if(o==="class"){let l=i?String(i).split(" "):[],a=r[o]?r[o].split(" "):[],c=l.filter(d=>!a.includes(d));r[o]=[...a,...c].join(" ")}else if(o==="style"){let l=i?i.split(";").map(d=>d.trim()).filter(Boolean):[],a=r[o]?r[o].split(";").map(d=>d.trim()).filter(Boolean):[],c=new Map;a.forEach(d=>{let[u,f]=d.split(":").map(h=>h.trim());c.set(u,f)}),l.forEach(d=>{let[u,f]=d.split(":").map(h=>h.trim());c.set(u,f)}),r[o]=Array.from(c.entries()).map(([d,u])=>`${d}: ${u}`).join("; ")}else r[o]=i}),r},{})}function ys(n,e){return e.filter(t=>t.type===n.type.name).filter(t=>t.attribute.rendered).map(t=>t.attribute.renderHTML?t.attribute.renderHTML(n.attrs)||{}:{[t.name]:n.attrs[t.name]}).reduce((t,r)=>v(t,r),{})}function Qc(n){return typeof n=="function"}function D(n,e=void 0,...t){return Qc(n)?e?n.bind(e)(...t):n(...t):n}function dp(n={}){return Object.keys(n).length===0&&n.constructor===Object}function up(n){return typeof n!="string"?n:n.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(n):n==="true"?!0:n==="false"?!1:n}function _c(n,e){return"style"in n?n:N(b({},n),{getAttrs:t=>{let r=n.getAttrs?n.getAttrs(t):n.attrs;if(r===!1)return!1;let o=e.reduce((i,s)=>{let l=s.attribute.parseHTML?s.attribute.parseHTML(t):up(t.getAttribute(s.name));return l==null?i:N(b({},i),{[s.name]:l})},{});return b(b({},r),o)}})}function Vc(n){return Object.fromEntries(Object.entries(n).filter(([e,t])=>e==="attrs"&&dp(t)?!1:t!=null))}function Xc(n,e){var t;let r=Yc(n),{nodeExtensions:o,markExtensions:i}=Qr(n),s=(t=o.find(c=>C(c,"topNode")))===null||t===void 0?void 0:t.name,l=Object.fromEntries(o.map(c=>{let d=r.filter(y=>y.type===c.name),u={name:c.name,options:c.options,storage:c.storage,editor:e},f=n.reduce((y,S)=>{let A=C(S,"extendNodeSchema",u);return b(b({},y),A?A(c):{})},{}),h=Vc(N(b({},f),{content:D(C(c,"content",u)),marks:D(C(c,"marks",u)),group:D(C(c,"group",u)),inline:D(C(c,"inline",u)),atom:D(C(c,"atom",u)),selectable:D(C(c,"selectable",u)),draggable:D(C(c,"draggable",u)),code:D(C(c,"code",u)),whitespace:D(C(c,"whitespace",u)),linebreakReplacement:D(C(c,"linebreakReplacement",u)),defining:D(C(c,"defining",u)),isolating:D(C(c,"isolating",u)),attrs:Object.fromEntries(d.map(y=>{var S;return[y.name,{default:(S=y==null?void 0:y.attribute)===null||S===void 0?void 0:S.default}]}))})),p=D(C(c,"parseHTML",u));p&&(h.parseDOM=p.map(y=>_c(y,d)));let m=C(c,"renderHTML",u);m&&(h.toDOM=y=>m({node:y,HTMLAttributes:ys(y,d)}));let g=C(c,"renderText",u);return g&&(h.toText=g),[c.name,h]})),a=Object.fromEntries(i.map(c=>{let d=r.filter(g=>g.type===c.name),u={name:c.name,options:c.options,storage:c.storage,editor:e},f=n.reduce((g,y)=>{let S=C(y,"extendMarkSchema",u);return b(b({},g),S?S(c):{})},{}),h=Vc(N(b({},f),{inclusive:D(C(c,"inclusive",u)),excludes:D(C(c,"excludes",u)),group:D(C(c,"group",u)),spanning:D(C(c,"spanning",u)),code:D(C(c,"code",u)),attrs:Object.fromEntries(d.map(g=>{var y;return[g.name,{default:(y=g==null?void 0:g.attribute)===null||y===void 0?void 0:y.default}]}))})),p=D(C(c,"parseHTML",u));p&&(h.parseDOM=p.map(g=>_c(g,d)));let m=C(c,"renderHTML",u);return m&&(h.toDOM=g=>m({mark:g,HTMLAttributes:ys(g,d)})),[c.name,h]}));return new Wt({topNode:s,nodes:l,marks:a})}function hs(n,e){return e.nodes[n]||e.marks[n]||null}function jc(n,e){return Array.isArray(e)?e.some(t=>(typeof t=="string"?t:t.name)===n.name):e}function Xr(n,e){let t=Ie.fromSchema(e).serializeFragment(n),o=document.implementation.createHTMLDocument().createElement("div");return o.appendChild(t),o.innerHTML}var fp=(n,e=500)=>{let t="",r=n.parentOffset;return n.parent.nodesBetween(Math.max(0,r-e),r,(o,i,s,l)=>{var a,c;let d=((c=(a=o.type.spec).toText)===null||c===void 0?void 0:c.call(a,{node:o,pos:i,parent:s,index:l}))||o.textContent||"%leaf%";t+=o.isAtom&&!o.isText?d:d.slice(0,Math.max(0,r-i))}),t};function Ss(n){return Object.prototype.toString.call(n)==="[object RegExp]"}var Bt=class{constructor(e){this.find=e.find,this.handler=e.handler}},hp=(n,e)=>{if(Ss(e))return e.exec(n);let t=e(n);if(!t)return null;let r=[t.text];return r.index=t.index,r.input=n,r.data=t.data,t.replaceWith&&(t.text.includes(t.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),r.push(t.replaceWith)),r};function Vr(n){var e;let{editor:t,from:r,to:o,text:i,rules:s,plugin:l}=n,{view:a}=t;if(a.composing)return!1;let c=a.state.doc.resolve(r);if(c.parent.type.spec.code||!((e=c.nodeBefore||c.nodeAfter)===null||e===void 0)&&e.marks.find(f=>f.type.spec.code))return!1;let d=!1,u=fp(c)+i;return s.forEach(f=>{if(d)return;let h=hp(u,f.find);if(!h)return;let p=a.state.tr,m=Yr({state:a.state,transaction:p}),g={from:r-(h[0].length-i.length),to:o},{commands:y,chain:S,can:A}=new an({editor:t,state:m});f.handler({state:m,range:g,match:h,commands:y,chain:S,can:A})===null||!p.steps.length||(p.setMeta(l,{transform:p,from:r,to:o,text:i}),a.dispatch(p),d=!0)}),d}function pp(n){let{editor:e,rules:t}=n,r=new L({state:{init(){return null},apply(o,i,s){let l=o.getMeta(r);if(l)return l;let a=o.getMeta("applyInputRules");return!!a&&setTimeout(()=>{let{text:d}=a;typeof d=="string"?d=d:d=Xr(x.from(d),s.schema);let{from:u}=a,f=u+d.length;Vr({editor:e,from:u,to:f,text:d,rules:t,plugin:r})}),o.selectionSet||o.docChanged?null:i}},props:{handleTextInput(o,i,s,l){return Vr({editor:e,from:i,to:s,text:l,rules:t,plugin:r})},handleDOMEvents:{compositionend:o=>(setTimeout(()=>{let{$cursor:i}=o.state.selection;i&&Vr({editor:e,from:i.pos,to:i.pos,text:"",rules:t,plugin:r})}),!1)},handleKeyDown(o,i){if(i.key!=="Enter")return!1;let{$cursor:s}=o.state.selection;return s?Vr({editor:e,from:s.pos,to:s.pos,text:` -`,rules:t,plugin:r}):!1}},isInputRules:!0});return r}function mp(n){return Object.prototype.toString.call(n).slice(8,-1)}function jr(n){return mp(n)!=="Object"?!1:n.constructor===Object&&Object.getPrototypeOf(n)===Object.prototype}function Zr(n,e){let t=b({},n);return jr(n)&&jr(e)&&Object.keys(e).forEach(r=>{jr(e[r])&&jr(n[r])?t[r]=Zr(n[r],e[r]):t[r]=e[r]}),t}var J=class n{constructor(e={}){this.type="mark",this.name="mark",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config=b(b({},this.config),e),this.name=this.config.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=D(C(this,"addOptions",{name:this.name}))),this.storage=D(C(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new n(e)}configure(e={}){let t=this.extend(N(b({},this.config),{addOptions:()=>Zr(this.options,e)}));return t.name=this.name,t.parent=this.parent,t}extend(e={}){let t=new n(e);return t.parent=this,this.child=t,t.name=e.name?e.name:t.parent.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${t.name}".`),t.options=D(C(t,"addOptions",{name:t.name})),t.storage=D(C(t,"addStorage",{name:t.name,options:t.options})),t}static handleExit({editor:e,mark:t}){let{tr:r}=e.state,o=e.state.selection.$from;if(o.pos===o.end()){let s=o.marks();if(!!!s.find(c=>(c==null?void 0:c.type.name)===t.name))return!1;let a=s.find(c=>(c==null?void 0:c.type.name)===t.name);return a&&r.removeStoredMark(a),r.insertText(" ",o.pos),e.view.dispatch(r),!0}return!1}};function gp(n){return typeof n=="number"}var $n=class{constructor(e){this.find=e.find,this.handler=e.handler}},yp=(n,e,t)=>{if(Ss(e))return[...n.matchAll(e)];let r=e(n,t);return r?r.map(o=>{let i=[o.text];return i.index=o.index,i.input=n,i.data=o.data,o.replaceWith&&(o.text.includes(o.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),i.push(o.replaceWith)),i}):[]};function bp(n){let{editor:e,state:t,from:r,to:o,rule:i,pasteEvent:s,dropEvent:l}=n,{commands:a,chain:c,can:d}=new an({editor:e,state:t}),u=[];return t.doc.nodesBetween(r,o,(h,p)=>{if(!h.isTextblock||h.type.spec.code)return;let m=Math.max(r,p),g=Math.min(o,p+h.content.size),y=h.textBetween(m-p,g-p,void 0,"\uFFFC");yp(y,i.find,s).forEach(A=>{if(A.index===void 0)return;let I=m+A.index+1,M=I+A[0].length,R={from:t.tr.mapping.map(I),to:t.tr.mapping.map(M)},_=i.handler({state:t,range:R,match:A,commands:a,chain:c,can:d,pasteEvent:s,dropEvent:l});u.push(_)})}),u.every(h=>h!==null)}var Wr=null,xp=n=>{var e;let t=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=t.clipboardData)===null||e===void 0||e.setData("text/html",n),t};function kp(n){let{editor:e,rules:t}=n,r=null,o=!1,i=!1,s=typeof ClipboardEvent!="undefined"?new ClipboardEvent("paste"):null,l;try{l=typeof DragEvent!="undefined"?new DragEvent("drop"):null}catch(d){l=null}let a=({state:d,from:u,to:f,rule:h,pasteEvt:p})=>{let m=d.tr,g=Yr({state:d,transaction:m});if(!(!bp({editor:e,state:g,from:Math.max(u-1,0),to:f.b-1,rule:h,pasteEvent:p,dropEvent:l})||!m.steps.length)){try{l=typeof DragEvent!="undefined"?new DragEvent("drop"):null}catch(S){l=null}return s=typeof ClipboardEvent!="undefined"?new ClipboardEvent("paste"):null,m}};return t.map(d=>new L({view(u){let f=p=>{var m;r=!((m=u.dom.parentElement)===null||m===void 0)&&m.contains(p.target)?u.dom.parentElement:null,r&&(Wr=e)},h=()=>{Wr&&(Wr=null)};return window.addEventListener("dragstart",f),window.addEventListener("dragend",h),{destroy(){window.removeEventListener("dragstart",f),window.removeEventListener("dragend",h)}}},props:{handleDOMEvents:{drop:(u,f)=>{if(i=r===u.dom.parentElement,l=f,!i){let h=Wr;h&&setTimeout(()=>{let p=h.state.selection;p&&h.commands.deleteRange({from:p.from,to:p.to})},10)}return!1},paste:(u,f)=>{var h;let p=(h=f.clipboardData)===null||h===void 0?void 0:h.getData("text/html");return s=f,o=!!(p!=null&&p.includes("data-pm-slice")),!1}}},appendTransaction:(u,f,h)=>{let p=u[0],m=p.getMeta("uiEvent")==="paste"&&!o,g=p.getMeta("uiEvent")==="drop"&&!i,y=p.getMeta("applyPasteRules"),S=!!y;if(!m&&!g&&!S)return;if(S){let{text:M}=y;typeof M=="string"?M=M:M=Xr(x.from(M),h.schema);let{from:R}=y,_=R+M.length,Q=xp(M);return a({rule:d,state:h,from:R,to:{b:_},pasteEvt:Q})}let A=f.doc.content.findDiffStart(h.doc.content),I=f.doc.content.findDiffEnd(h.doc.content);if(!(!gp(A)||!I||A===I.b))return a({rule:d,state:h,from:A,to:I,pasteEvt:s})}}))}function Sp(n){let e=n.filter((t,r)=>n.indexOf(t)!==r);return Array.from(new Set(e))}var Jr=class n{constructor(e,t){this.splittableMarks=[],this.editor=t,this.extensions=n.resolve(e),this.schema=Xc(this.extensions,t),this.setupExtensions()}static resolve(e){let t=n.sort(n.flatten(e)),r=Sp(t.map(o=>o.name));return r.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${r.map(o=>`'${o}'`).join(", ")}]. This can lead to issues.`),t}static flatten(e){return e.map(t=>{let r={name:t.name,options:t.options,storage:t.storage},o=C(t,"addExtensions",r);return o?[t,...this.flatten(o())]:t}).flat(10)}static sort(e){return e.sort((r,o)=>{let i=C(r,"priority")||100,s=C(o,"priority")||100;return i>s?-1:i{let r={name:t.name,options:t.options,storage:t.storage,editor:this.editor,type:hs(t.name,this.schema)},o=C(t,"addCommands",r);return o?b(b({},e),o()):e},{})}get plugins(){let{editor:e}=this,t=n.sort([...this.extensions].reverse()),r=[],o=[],i=t.map(s=>{let l={name:s.name,options:s.options,storage:s.storage,editor:e,type:hs(s.name,this.schema)},a=[],c=C(s,"addKeyboardShortcuts",l),d={};if(s.type==="mark"&&C(s,"exitable",l)&&(d.ArrowRight=()=>J.handleExit({editor:e,mark:s})),c){let m=Object.fromEntries(Object.entries(c()).map(([g,y])=>[g,()=>y({editor:e})]));d=b(b({},d),m)}let u=Xi(d);a.push(u);let f=C(s,"addInputRules",l);jc(s,e.options.enableInputRules)&&f&&r.push(...f());let h=C(s,"addPasteRules",l);jc(s,e.options.enablePasteRules)&&h&&o.push(...h());let p=C(s,"addProseMirrorPlugins",l);if(p){let m=p();a.push(...m)}return a}).flat();return[pp({editor:e,rules:r}),...kp({editor:e,rules:o}),...i]}get attributes(){return Yc(this.extensions)}get nodeViews(){let{editor:e}=this,{nodeExtensions:t}=Qr(this.extensions);return Object.fromEntries(t.filter(r=>!!C(r,"addNodeView")).map(r=>{let o=this.attributes.filter(a=>a.type===r.name),i={name:r.name,options:r.options,storage:r.storage,editor:e,type:re(r.name,this.schema)},s=C(r,"addNodeView",i);if(!s)return[];let l=(a,c,d,u,f)=>{let h=ys(a,o);return s()({node:a,view:c,getPos:d,decorations:u,innerDecorations:f,editor:e,extension:r,HTMLAttributes:h})};return[r.name,l]}))}setupExtensions(){this.extensions.forEach(e=>{var t;this.editor.extensionStorage[e.name]=e.storage;let r={name:e.name,options:e.options,storage:e.storage,editor:this.editor,type:hs(e.name,this.schema)};e.type==="mark"&&(!((t=D(C(e,"keepOnSplit",r)))!==null&&t!==void 0)||t)&&this.splittableMarks.push(e.name);let o=C(e,"onBeforeCreate",r),i=C(e,"onCreate",r),s=C(e,"onUpdate",r),l=C(e,"onSelectionUpdate",r),a=C(e,"onTransaction",r),c=C(e,"onFocus",r),d=C(e,"onBlur",r),u=C(e,"onDestroy",r);o&&this.editor.on("beforeCreate",o),i&&this.editor.on("create",i),s&&this.editor.on("update",s),l&&this.editor.on("selectionUpdate",l),a&&this.editor.on("transaction",a),c&&this.editor.on("focus",c),d&&this.editor.on("blur",d),u&&this.editor.on("destroy",u)})}},H=class n{constructor(e={}){this.type="extension",this.name="extension",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config=b(b({},this.config),e),this.name=this.config.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=D(C(this,"addOptions",{name:this.name}))),this.storage=D(C(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new n(e)}configure(e={}){let t=this.extend(N(b({},this.config),{addOptions:()=>Zr(this.options,e)}));return t.name=this.name,t.parent=this.parent,t}extend(e={}){let t=new n(b(b({},this.config),e));return t.parent=this,this.child=t,t.name=e.name?e.name:t.parent.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${t.name}".`),t.options=D(C(t,"addOptions",{name:t.name})),t.storage=D(C(t,"addStorage",{name:t.name,options:t.options})),t}};function Zc(n,e,t){let{from:r,to:o}=e,{blockSeparator:i=` +`);return{dom:a,text:f,slice:e}}function Ji(n,e,t,r,o){let i=o.parent.type.spec.code,s,l;if(!t&&!e)return null;let a=e&&(r||i||!t);if(a){if(n.someProp("transformPastedText",f=>{e=f(e,i||r,n)}),i)return e?new S(x.from(n.state.schema.text(e.replace(/\r\n?/g,` +`))),0,0):S.empty;let u=n.someProp("clipboardTextParser",f=>f(e,o,r,n));if(u)l=u;else{let f=o.marks(),{schema:p}=n.state,h=Ie.fromSchema(p);s=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(m=>{let g=s.appendChild(document.createElement("p"));m&&g.appendChild(h.serializeNode(p.text(m,f)))})}}else n.someProp("transformPastedHTML",u=>{t=u(t,n)}),s=ap(t),Bn&&cp(s);let c=s&&s.querySelector("[data-pm-slice]"),d=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(d&&d[3])for(let u=+d[3];u>0;u--){let f=s.firstChild;for(;f&&f.nodeType!=1;)f=f.nextSibling;if(!f)break;s=f}if(l||(l=(n.someProp("clipboardParser")||n.someProp("domParser")||Ne.fromSchema(n.state.schema)).parseSlice(s,{preserveWhitespace:!!(a||d),context:o,ruleFromNode(f){return f.nodeName=="BR"&&!f.nextSibling&&f.parentNode&&!ip.test(f.parentNode.nodeName)?{ignore:!0}:null}})),d)l=dp(Va(l,+d[1],+d[2]),d[4]);else if(l=S.maxOpen(sp(l.content,o),!0),l.openStart||l.openEnd){let u=0,f=0;for(let p=l.content.firstChild;u{l=u(l,n)}),l}var ip=/^(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 sp(n,e){if(n.childCount<2)return n;for(let t=e.depth;t>=0;t--){let o=e.node(t).contentMatchAt(e.index(t)),i,s=[];if(n.forEach(l=>{if(!s)return;let a=o.findWrapping(l.type),c;if(!a)return s=null;if(c=s.length&&i.length&&yc(a,i,l,s[s.length-1],0))s[s.length-1]=c;else{s.length&&(s[s.length-1]=bc(s[s.length-1],i.length));let d=gc(l,a);s.push(d),o=o.matchType(d.type),i=a}}),s)return x.from(s)}return n}function gc(n,e,t=0){for(let r=e.length-1;r>=t;r--)n=e[r].create(null,x.from(n));return n}function yc(n,e,t,r,o){if(o1&&(i=0),o=t&&(l=e<0?s.contentMatchAt(0).fillBefore(l,i<=o).append(l):l.append(s.contentMatchAt(s.childCount).fillBefore(x.empty,!0))),n.replaceChild(e<0?0:n.childCount-1,s.copy(l))}function Va(n,e,t){return et})),wi.createHTML(n)):n}function ap(n){let e=/^(\s*]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=kc().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(n),o;if((o=r&&xc[r[1].toLowerCase()])&&(n=o.map(i=>"<"+i+">").join("")+n+o.map(i=>"").reverse().join("")),t.innerHTML=lp(n),o)for(let i=0;i=0;l-=2){let a=t.nodes[r[l]];if(!a||a.hasRequiredAttrs())break;o=x.from(a.create(r[l+1],o)),i++,s++}return new S(o,i,s)}var me={},ge={},up={touchstart:!0,touchmove:!0},zi=class{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:""},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}};function fp(n){for(let e in me){let t=me[e];n.dom.addEventListener(e,n.input.eventHandlers[e]=r=>{hp(n,r)&&!Ui(n,r)&&(n.editable||!(r.type in ge))&&t(n,r)},up[e]?{passive:!0}:void 0)}he&&n.dom.addEventListener("input",()=>null),Bi(n)}function dt(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}function pp(n){n.domObserver.stop();for(let e in n.input.eventHandlers)n.dom.removeEventListener(e,n.input.eventHandlers[e]);clearTimeout(n.input.composingTimeout),clearTimeout(n.input.lastIOSEnterFallbackTimeout)}function Bi(n){n.someProp("handleDOMEvents",e=>{for(let t in e)n.input.eventHandlers[t]||n.dom.addEventListener(t,n.input.eventHandlers[t]=r=>Ui(n,r))})}function Ui(n,e){return n.someProp("handleDOMEvents",t=>{let r=t[e.type];return r?r(n,e)||e.defaultPrevented:!1})}function hp(n,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target;t!=n.dom;t=t.parentNode)if(!t||t.nodeType==11||t.pmViewDesc&&t.pmViewDesc.stopEvent(e))return!1;return!0}function mp(n,e){!Ui(n,e)&&me[e.type]&&(n.editable||!(e.type in ge))&&me[e.type](n,e)}ge.keydown=(n,e)=>{let t=e;if(n.input.shiftKey=t.keyCode==16||t.shiftKey,!Sc(n,t)&&(n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),!(qe&&de&&t.keyCode==13)))if(t.keyCode!=229&&n.domObserver.forceFlush(),rn&&t.keyCode==13&&!t.ctrlKey&&!t.altKey&&!t.metaKey){let r=Date.now();n.input.lastIOSEnter=r,n.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{n.input.lastIOSEnter==r&&(n.someProp("handleKeyDown",o=>o(n,vt(13,"Enter"))),n.input.lastIOSEnter=0)},200)}else n.someProp("handleKeyDown",r=>r(n,t))||op(n,t)?t.preventDefault():dt(n,"key")};ge.keyup=(n,e)=>{e.keyCode==16&&(n.input.shiftKey=!1)};ge.keypress=(n,e)=>{let t=e;if(Sc(n,t)||!t.charCode||t.ctrlKey&&!t.altKey||Me&&t.metaKey)return;if(n.someProp("handleKeyPress",o=>o(n,t))){t.preventDefault();return}let r=n.state.selection;if(!(r instanceof A)||!r.$from.sameParent(r.$to)){let o=String.fromCharCode(t.charCode);!/[\r\n]/.test(o)&&!n.someProp("handleTextInput",i=>i(n,r.$from.pos,r.$to.pos,o))&&n.dispatch(n.state.tr.insertText(o).scrollIntoView()),t.preventDefault()}};function Sr(n){return{left:n.clientX,top:n.clientY}}function gp(n,e){let t=e.x-n.clientX,r=e.y-n.clientY;return t*t+r*r<100}function qi(n,e,t,r,o){if(r==-1)return!1;let i=n.state.doc.resolve(r);for(let s=i.depth+1;s>0;s--)if(n.someProp(e,l=>s>i.depth?l(n,t,i.nodeAfter,i.before(s),o,!0):l(n,t,i.node(s),i.before(s),o,!1)))return!0;return!1}function tn(n,e,t){if(n.focused||n.focus(),n.state.selection.eq(e))return;let r=n.state.tr.setSelection(e);t=="pointer"&&r.setMeta("pointer",!0),n.dispatch(r)}function yp(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),r=t.nodeAfter;return r&&r.isAtom&&v.isSelectable(r)?(tn(n,new v(t),"pointer"),!0):!1}function bp(n,e){if(e==-1)return!1;let t=n.state.selection,r,o;t instanceof v&&(r=t.node);let i=n.state.doc.resolve(e);for(let s=i.depth+1;s>0;s--){let l=s>i.depth?i.nodeAfter:i.node(s);if(v.isSelectable(l)){r&&t.$from.depth>0&&s>=t.$from.depth&&i.before(t.$from.depth+1)==t.$from.pos?o=i.before(t.$from.depth):o=i.before(s);break}}return o!=null?(tn(n,v.create(n.state.doc,o),"pointer"),!0):!1}function xp(n,e,t,r,o){return qi(n,"handleClickOn",e,t,r)||n.someProp("handleClick",i=>i(n,e,r))||(o?bp(n,t):yp(n,t))}function kp(n,e,t,r){return qi(n,"handleDoubleClickOn",e,t,r)||n.someProp("handleDoubleClick",o=>o(n,e,r))}function wp(n,e,t,r){return qi(n,"handleTripleClickOn",e,t,r)||n.someProp("handleTripleClick",o=>o(n,e,r))||Sp(n,t,r)}function Sp(n,e,t){if(t.button!=0)return!1;let r=n.state.doc;if(e==-1)return r.inlineContent?(tn(n,A.create(r,0,r.content.size),"pointer"),!0):!1;let o=r.resolve(e);for(let i=o.depth+1;i>0;i--){let s=i>o.depth?o.nodeAfter:o.node(i),l=o.before(i);if(s.inlineContent)tn(n,A.create(r,l+1,l+1+s.content.size),"pointer");else if(v.isSelectable(s))tn(n,v.create(r,l),"pointer");else continue;return!0}}function Gi(n){return Rn(n)}var wc=Me?"metaKey":"ctrlKey";me.mousedown=(n,e)=>{let t=e;n.input.shiftKey=t.shiftKey;let r=Gi(n),o=Date.now(),i="singleClick";o-n.input.lastClick.time<500&&gp(t,n.input.lastClick)&&!t[wc]&&(n.input.lastClick.type=="singleClick"?i="doubleClick":n.input.lastClick.type=="doubleClick"&&(i="tripleClick")),n.input.lastClick={time:o,x:t.clientX,y:t.clientY,type:i};let s=n.posAtCoords(Sr(t));s&&(i=="singleClick"?(n.input.mouseDown&&n.input.mouseDown.done(),n.input.mouseDown=new Fi(n,s,t,!!r)):(i=="doubleClick"?kp:wp)(n,s.pos,s.inside,t)?t.preventDefault():dt(n,"pointer"))};var Fi=class{constructor(e,t,r,o){this.view=e,this.pos=t,this.event=r,this.flushed=o,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!r[wc],this.allowDefault=r.shiftKey;let i,s;if(t.inside>-1)i=e.state.doc.nodeAt(t.inside),s=t.inside;else{let d=e.state.doc.resolve(t.pos);i=d.parent,s=d.depth?d.before():0}let l=o?null:r.target,a=l?e.docView.nearestDesc(l,!0):null;this.target=a&&a.dom.nodeType==1?a.dom:null;let{selection:c}=e.state;(r.button==0&&i.type.spec.draggable&&i.type.spec.selectable!==!1||c instanceof v&&c.from<=s&&c.to>s)&&(this.mightDrag={node:i,pos:s,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Re&&!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()),e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this)),dt(e,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>Ge(this.view)),this.view.input.mouseDown=null}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(Sr(e))),this.updateAllowDefault(e),this.allowDefault||!t?dt(this.view,"pointer"):xp(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||he&&this.mightDrag&&!this.mightDrag.node.isAtom||de&&!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)?(tn(this.view,E.near(this.view.state.doc.resolve(t.pos)),"pointer"),e.preventDefault()):dt(this.view,"pointer")}move(e){this.updateAllowDefault(e),dt(this.view,"pointer"),e.buttons==0&&this.done()}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}};me.touchstart=n=>{n.input.lastTouch=Date.now(),Gi(n),dt(n,"pointer")};me.touchmove=n=>{n.input.lastTouch=Date.now(),dt(n,"pointer")};me.contextmenu=n=>Gi(n);function Sc(n,e){return n.composing?!0:he&&Math.abs(e.timeStamp-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}var Cp=qe?5e3:-1;ge.compositionstart=ge.compositionupdate=n=>{if(!n.composing){n.domObserver.flush();let{state:e}=n,t=e.selection.$to;if(e.selection instanceof A&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)))n.markCursor=n.state.storedMarks||t.marks(),Rn(n,!0),n.markCursor=null;else if(Rn(n,!e.selection.empty),Re&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length){let r=n.domSelectionRange();for(let o=r.focusNode,i=r.focusOffset;o&&o.nodeType==1&&i!=0;){let s=i<0?o.lastChild:o.childNodes[i-1];if(!s)break;if(s.nodeType==3){let l=n.domSelection();l&&l.collapse(s,s.nodeValue.length);break}else o=s,i=-1}}n.input.composing=!0}Cc(n,Cp)};ge.compositionend=(n,e)=>{n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=e.timeStamp,n.input.compositionPendingChanges=n.domObserver.pendingRecords().length?n.input.compositionID:0,n.input.compositionNode=null,n.input.compositionPendingChanges&&Promise.resolve().then(()=>n.domObserver.flush()),n.input.compositionID++,Cc(n,20))};function Cc(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>Rn(n),e))}function Mc(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=Tp());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function Mp(n){let e=n.domSelectionRange();if(!e.focusNode)return null;let t=wf(e.focusNode,e.focusOffset),r=Sf(e.focusNode,e.focusOffset);if(t&&r&&t!=r){let o=r.pmViewDesc,i=n.domObserver.lastChangedTextNode;if(t==i||r==i)return i;if(!o||!o.isText(r.nodeValue))return r;if(n.input.compositionNode==r){let s=t.pmViewDesc;if(!(!s||!s.isText(t.nodeValue)))return r}}return t||r}function Tp(){let n=document.createEvent("Event");return n.initEvent("event",!0,!0),n.timeStamp}function Rn(n,e=!1){if(!(qe&&n.domObserver.flushingSoon>=0)){if(n.domObserver.forceFlush(),Mc(n),e||n.docView&&n.docView.dirty){let t=ji(n);return t&&!t.eq(n.state.selection)?n.dispatch(n.state.tr.setSelection(t)):(n.markCursor||e)&&!n.state.selection.empty?n.dispatch(n.state.tr.deleteSelection()):n.updateState(n.state),!0}return!1}}function Ap(n,e){if(!n.dom.parentNode)return;let t=n.dom.parentNode.appendChild(document.createElement("div"));t.appendChild(e),t.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),o=document.createRange();o.selectNodeContents(e),n.dom.blur(),r.removeAllRanges(),r.addRange(o),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t),n.focus()},50)}var Dn=ye&&ut<15||rn&&Ef<604;me.copy=ge.cut=(n,e)=>{let t=e,r=n.state.selection,o=t.type=="cut";if(r.empty)return;let i=Dn?null:t.clipboardData,s=r.content(),{dom:l,text:a}=Ki(n,s);i?(t.preventDefault(),i.clearData(),i.setData("text/html",l.innerHTML),i.setData("text/plain",a)):Ap(n,l),o&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function Ep(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function vp(n,e){if(!n.dom.parentNode)return;let t=n.input.shiftKey||n.state.selection.$from.parent.type.spec.code,r=n.dom.parentNode.appendChild(document.createElement(t?"textarea":"div"));t||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let o=n.input.shiftKey&&n.input.lastKeyCode!=45;setTimeout(()=>{n.focus(),r.parentNode&&r.parentNode.removeChild(r),t?In(n,r.value,null,o,e):In(n,r.textContent,r.innerHTML,o,e)},50)}function In(n,e,t,r,o){let i=Ji(n,e,t,r,n.state.selection.$from);if(n.someProp("handlePaste",a=>a(n,o,i||S.empty)))return!0;if(!i)return!1;let s=Ep(i),l=s?n.state.tr.replaceSelectionWith(s,r):n.state.tr.replaceSelection(i);return n.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Tc(n){let e=n.getData("text/plain")||n.getData("Text");if(e)return e;let t=n.getData("text/uri-list");return t?t.replace(/\r?\n/g," "):""}ge.paste=(n,e)=>{let t=e;if(n.composing&&!qe)return;let r=Dn?null:t.clipboardData,o=n.input.shiftKey&&n.input.lastKeyCode!=45;r&&In(n,Tc(r),r.getData("text/html"),o,t)?t.preventDefault():vp(n,t)};var yr=class{constructor(e,t,r){this.slice=e,this.move=t,this.node=r}},Ac=Me?"altKey":"ctrlKey";me.dragstart=(n,e)=>{let t=e,r=n.input.mouseDown;if(r&&r.done(),!t.dataTransfer)return;let o=n.state.selection,i=o.empty?null:n.posAtCoords(Sr(t)),s;if(!(i&&i.pos>=o.from&&i.pos<=(o instanceof v?o.to-1:o.to))){if(r&&r.mightDrag)s=v.create(n.state.doc,r.mightDrag.pos);else if(t.target&&t.target.nodeType==1){let u=n.docView.nearestDesc(t.target,!0);u&&u.node.type.spec.draggable&&u!=n.docView&&(s=v.create(n.state.doc,u.posBefore))}}let l=(s||n.state.selection).content(),{dom:a,text:c,slice:d}=Ki(n,l);(!t.dataTransfer.files.length||!de||nc>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(Dn?"Text":"text/html",a.innerHTML),t.dataTransfer.effectAllowed="copyMove",Dn||t.dataTransfer.setData("text/plain",c),n.dragging=new yr(d,!t[Ac],s)};me.dragend=n=>{let e=n.dragging;window.setTimeout(()=>{n.dragging==e&&(n.dragging=null)},50)};ge.dragover=ge.dragenter=(n,e)=>e.preventDefault();ge.drop=(n,e)=>{let t=e,r=n.dragging;if(n.dragging=null,!t.dataTransfer)return;let o=n.posAtCoords(Sr(t));if(!o)return;let i=n.state.doc.resolve(o.pos),s=r&&r.slice;s?n.someProp("transformPasted",h=>{s=h(s,n)}):s=Ji(n,Tc(t.dataTransfer),Dn?null:t.dataTransfer.getData("text/html"),!1,i);let l=!!(r&&!t[Ac]);if(n.someProp("handleDrop",h=>h(n,t,s||S.empty,l))){t.preventDefault();return}if(!s)return;t.preventDefault();let a=s?Tn(n.state.doc,i.pos,s):i.pos;a==null&&(a=i.pos);let c=n.state.tr;if(l){let{node:h}=r;h?h.replace(c):c.deleteSelection()}let d=c.mapping.map(a),u=s.openStart==0&&s.openEnd==0&&s.content.childCount==1,f=c.doc;if(u?c.replaceRangeWith(d,d,s.content.firstChild):c.replaceRange(d,d,s),c.doc.eq(f))return;let p=c.doc.resolve(d);if(u&&v.isSelectable(s.content.firstChild)&&p.nodeAfter&&p.nodeAfter.sameMarkup(s.content.firstChild))c.setSelection(new v(p));else{let h=c.mapping.map(a);c.mapping.maps[c.mapping.maps.length-1].forEach((m,g,y,w)=>h=w),c.setSelection(Wi(n,p,c.doc.resolve(h)))}n.focus(),n.dispatch(c.setMeta("uiEvent","drop"))};me.focus=n=>{n.input.lastFocus=Date.now(),n.focused||(n.domObserver.stop(),n.dom.classList.add("ProseMirror-focused"),n.domObserver.start(),n.focused=!0,setTimeout(()=>{n.docView&&n.hasFocus()&&!n.domObserver.currentSelection.eq(n.domSelectionRange())&&Ge(n)},20))};me.blur=(n,e)=>{let t=e;n.focused&&(n.domObserver.stop(),n.dom.classList.remove("ProseMirror-focused"),n.domObserver.start(),t.relatedTarget&&n.dom.contains(t.relatedTarget)&&n.domObserver.currentSelection.clear(),n.focused=!1)};me.beforeinput=(n,e)=>{if(de&&qe&&e.inputType=="deleteContentBackward"){n.domObserver.flushSoon();let{domChangeCount:r}=n.input;setTimeout(()=>{if(n.input.domChangeCount!=r||(n.dom.blur(),n.focus(),n.someProp("handleKeyDown",i=>i(n,vt(8,"Backspace")))))return;let{$cursor:o}=n.state.selection;o&&o.pos>0&&n.dispatch(n.state.tr.delete(o.pos-1,o.pos).scrollIntoView())},50)}};for(let n in ge)me[n]=ge[n];function Pn(n,e){if(n==e)return!0;for(let t in n)if(n[t]!==e[t])return!1;for(let t in e)if(!(t in n))return!1;return!0}var br=class n{constructor(e,t){this.toDOM=e,this.spec=t||Dt,this.side=this.spec.side||0}map(e,t,r,o){let{pos:i,deleted:s}=e.mapResult(t.from+o,this.side<0?-1:1);return s?null:new ne(i-r,i-r,this)}valid(){return!0}eq(e){return this==e||e instanceof n&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Pn(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}},Rt=class n{constructor(e,t){this.attrs=e,this.spec=t||Dt}map(e,t,r,o){let i=e.map(t.from+o,this.spec.inclusiveStart?-1:1)-r,s=e.map(t.to+o,this.spec.inclusiveEnd?1:-1)-r;return i>=s?null:new ne(i,s,this)}valid(e,t){return t.from=e&&(!i||i(l.spec))&&r.push(l.copy(l.from+o,l.to+o))}for(let s=0;se){let l=this.children[s]+1;this.children[s+2].findInner(e-l,t-l,r,o+l,i)}}map(e,t,r){return this==ce||e.maps.length==0?this:this.mapInner(e,t,0,0,r||Dt)}mapInner(e,t,r,o,i){let s;for(let l=0;l{let c=a+r,d;if(d=vc(t,l,c)){for(o||(o=this.children.slice());il&&u.to=e){this.children[l]==e&&(r=this.children[l+2]);break}let i=e+1,s=i+t.content.size;for(let l=0;li&&a.type instanceof Rt){let c=Math.max(i,a.from)-i,d=Math.min(s,a.to)-i;co.map(e,t,Dt));return n.from(r)}forChild(e,t){if(t.isLeaf)return q.empty;let r=[];for(let o=0;ot instanceof q)?e:e.reduce((t,r)=>t.concat(r instanceof q?r:r.members),[]))}}forEachSet(e){for(let t=0;t{let g=m-h-(p-f);for(let y=0;yw+d-u)continue;let T=l[y]+d-u;p>=T?l[y+1]=f<=T?-2:-1:f>=d&&g&&(l[y]+=g,l[y+1]+=g)}u+=g}),d=t.maps[c].map(d,-1)}let a=!1;for(let c=0;c=r.content.size){a=!0;continue}let f=t.map(n[c+1]+i,-1),p=f-o,{index:h,offset:m}=r.content.findIndex(u),g=r.maybeChild(h);if(g&&m==u&&m+g.nodeSize==p){let y=l[c+2].mapInner(t,g,d+1,n[c]+i+1,s);y!=ce?(l[c]=u,l[c+1]=p,l[c+2]=y):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=Np(l,n,e,t,o,i,s),d=kr(c,r,0,s);e=d.local;for(let u=0;ut&&s.to{let c=vc(n,l,a+t);if(c){i=!0;let d=kr(c,l,t+a+1,r);d!=ce&&o.push(a,a+l.nodeSize,d)}});let s=Ec(i?Oc(n):n,-t).sort(It);for(let l=0;l0;)e++;n.splice(e,0,t)}function Si(n){let e=[];return n.someProp("decorations",t=>{let r=t(n.state);r&&r!=ce&&e.push(r)}),n.cursorWrapper&&e.push(q.create(n.state.doc,[n.cursorWrapper.deco])),xr.from(e)}var Rp={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},Dp=ye&&ut<=11,$i=class{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}},_i=class{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new $i,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let o=0;oo.type=="childList"&&o.removedNodes.length||o.type=="characterData"&&o.oldValue.length>o.target.nodeValue.length)?this.flushSoon():this.flush()}),Dp&&(this.onCharData=r=>{this.queue.push({target:r.target,type:"characterData",oldValue:r.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,Rp)),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;tthis.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(za(this.view)){if(this.suppressingSelectionUpdates)return Ge(this.view);if(ye&&ut<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Pt(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t=new Set,r;for(let i=e.focusNode;i;i=nn(i))t.add(i);for(let i=e.anchorNode;i;i=nn(i))if(t.has(i)){r=i;break}let o=r&&this.view.docView.nearestDesc(r);if(o&&o.ignoreMutation({type:"selection",target:r.nodeType==3?r.parentNode:r}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.pendingRecords();t.length&&(this.queue=[]);let r=e.domSelectionRange(),o=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&za(e)&&!this.ignoreSelectionChange(r),i=-1,s=-1,l=!1,a=[];if(e.editable)for(let d=0;du.nodeName=="BR");if(d.length==2){let[u,f]=d;u.parentNode&&u.parentNode.parentNode==f.parentNode?f.remove():u.remove()}else{let{focusNode:u}=this.currentSelection;for(let f of d){let p=f.parentNode;p&&p.nodeName=="LI"&&(!u||Lp(e,u)!=p)&&f.remove()}}}let c=null;i<0&&o&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)-1||o)&&(i>-1&&(e.docView.markDirty(i,s),Ip(e)),this.handleDOMChange(i,s,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||Ge(e),this.currentSelection.set(r))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let r=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(r==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!r||r.ignoreMutation(e))return null;if(e.type=="childList"){for(let d=0;do;g--){let y=r.childNodes[g-1],w=y.pmViewDesc;if(y.nodeName=="BR"&&!w){i=g;break}if(!w||w.size)break}let u=n.state.doc,f=n.someProp("domParser")||Ne.fromSchema(n.state.schema),p=u.resolve(s),h=null,m=f.parse(r,{topNode:p.parent,topMatch:p.parent.contentMatchAt(p.index()),topOpen:!0,from:o,to:i,preserveWhitespace:p.parent.type.whitespace=="pre"?"full":!0,findPositions:c,ruleFromNode:Bp,context:p});if(c&&c[0].pos!=null){let g=c[0].pos,y=c[1]&&c[1].pos;y==null&&(y=g),h={anchor:g+s,head:y+s}}return{doc:m,sel:h,from:s,to:l}}function Bp(n){let e=n.pmViewDesc;if(e)return e.parseRule();if(n.nodeName=="BR"&&n.parentNode){if(he&&/^(ul|ol)$/i.test(n.parentNode.nodeName)){let t=document.createElement("div");return t.appendChild(document.createElement("li")),{skip:t}}else if(n.parentNode.lastChild==n||he&&/^(tr|table)$/i.test(n.parentNode.nodeName))return{ignore:!0}}else if(n.nodeName=="IMG"&&n.getAttribute("mark-placeholder"))return{ignore:!0};return null}var Fp=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function Hp(n,e,t,r,o){let i=n.input.compositionPendingChanges||(n.composing?n.input.compositionID:0);if(n.input.compositionPendingChanges=0,e<0){let B=n.input.lastSelectionTime>Date.now()-50?n.input.lastSelectionOrigin:null,Ce=ji(n,B);if(Ce&&!n.state.selection.eq(Ce)){if(de&&qe&&n.input.lastKeyCode===13&&Date.now()-100hn(n,vt(13,"Enter"))))return;let wt=n.state.tr.setSelection(Ce);B=="pointer"?wt.setMeta("pointer",!0):B=="key"&&wt.scrollIntoView(),i&&wt.setMeta("composition",i),n.dispatch(wt)}return}let s=n.state.doc.resolve(e),l=s.sharedDepth(t);e=s.before(l+1),t=n.state.doc.resolve(t).after(l+1);let a=n.state.selection,c=zp(n,e,t),d=n.state.doc,u=d.slice(c.from,c.to),f,p;n.input.lastKeyCode===8&&Date.now()-100Date.now()-225||qe)&&o.some(B=>B.nodeType==1&&!Fp.test(B.nodeName))&&(!h||h.endA>=h.endB)&&n.someProp("handleKeyDown",B=>B(n,vt(13,"Enter")))){n.input.lastIOSEnter=0;return}if(!h)if(r&&a instanceof A&&!a.empty&&a.$head.sameParent(a.$anchor)&&!n.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))h={start:a.from,endA:a.to,endB:a.to};else{if(c.sel){let B=qa(n,n.state.doc,c.sel);if(B&&!B.eq(n.state.selection)){let Ce=n.state.tr.setSelection(B);i&&Ce.setMeta("composition",i),n.dispatch(Ce)}}return}n.state.selection.fromn.state.selection.from&&h.start<=n.state.selection.from+2&&n.state.selection.from>=c.from?h.start=n.state.selection.from:h.endA=n.state.selection.to-2&&n.state.selection.to<=c.to&&(h.endB+=n.state.selection.to-h.endA,h.endA=n.state.selection.to)),ye&&ut<=11&&h.endB==h.start+1&&h.endA==h.start&&h.start>c.from&&c.doc.textBetween(h.start-c.from-1,h.start-c.from+1)==" \xA0"&&(h.start--,h.endA--,h.endB--);let m=c.doc.resolveNoCache(h.start-c.from),g=c.doc.resolveNoCache(h.endB-c.from),y=d.resolve(h.start),w=m.sameParent(g)&&m.parent.inlineContent&&y.end()>=h.endA,T;if((rn&&n.input.lastIOSEnter>Date.now()-225&&(!w||o.some(B=>B.nodeName=="DIV"||B.nodeName=="P"))||!w&&m.posB(n,vt(13,"Enter")))){n.input.lastIOSEnter=0;return}if(n.state.selection.anchor>h.start&&_p(d,h.start,h.endA,m,g)&&n.someProp("handleKeyDown",B=>B(n,vt(8,"Backspace")))){qe&&de&&n.domObserver.suppressSelectionUpdates();return}de&&h.endB==h.start&&(n.input.lastChromeDelete=Date.now()),qe&&!w&&m.start()!=g.start()&&g.parentOffset==0&&m.depth==g.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==h.endA&&(h.endB-=2,g=c.doc.resolveNoCache(h.endB-c.from),setTimeout(()=>{n.someProp("handleKeyDown",function(B){return B(n,vt(13,"Enter"))})},20));let I=h.start,M=h.endA,R,_,Q;if(w){if(m.pos==g.pos)ye&&ut<=11&&m.parentOffset==0&&(n.domObserver.suppressSelectionUpdates(),setTimeout(()=>Ge(n),20)),R=n.state.tr.delete(I,M),_=d.resolve(h.start).marksAcross(d.resolve(h.endA));else if(h.endA==h.endB&&(Q=$p(m.parent.content.cut(m.parentOffset,g.parentOffset),y.parent.content.cut(y.parentOffset,h.endA-y.start()))))R=n.state.tr,Q.type=="add"?R.addMark(I,M,Q.mark):R.removeMark(I,M,Q.mark);else if(m.parent.child(m.index()).isText&&m.index()==g.index()-(g.textOffset?0:1)){let B=m.parent.textBetween(m.parentOffset,g.parentOffset);if(n.someProp("handleTextInput",Ce=>Ce(n,I,M,B)))return;R=n.state.tr.insertText(B,I,M)}}if(R||(R=n.state.tr.replace(I,M,c.doc.slice(h.start-c.from,h.endB-c.from))),c.sel){let B=qa(n,R.doc,c.sel);B&&!(de&&n.composing&&B.empty&&(h.start!=h.endB||n.input.lastChromeDeletee.content.size?null:Wi(n,e.resolve(t.anchor),e.resolve(t.head))}function $p(n,e){let t=n.firstChild.marks,r=e.firstChild.marks,o=t,i=r,s,l,a;for(let d=0;dd.mark(l.addToSet(d.marks));else if(o.length==0&&i.length==1)l=i[0],s="remove",a=d=>d.mark(l.removeFromSet(d.marks));else return null;let c=[];for(let d=0;dt||Ci(s,!0,!1)0&&(e||n.indexAfter(r)==n.node(r).childCount);)r--,o++,e=!1;if(t){let i=n.node(r).maybeChild(n.indexAfter(r));for(;i&&!i.isLeaf;)i=i.firstChild,o++}return o}function Vp(n,e,t,r,o){let i=n.findDiffStart(e,t);if(i==null)return null;let{a:s,b:l}=n.findDiffEnd(e,t+n.size,t+e.size);if(o=="end"){let a=Math.max(0,i-Math.min(s,l));r-=s+a-i}if(s=s?i-r:0;i-=a,i&&i=l?i-r:0;i-=a,i&&i=56320&&e<=57343&&t>=55296&&t<=56319}var jp=Ji,Wp=Rn,Ln=class{constructor(e,t){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new zi,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(ec),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):typeof e=="function"?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=Xa(this),Qa(this),this.nodeViews=Za(this),this.docView=Na(this.state.doc,Ya(this),Si(this),this.dom,this),this.domObserver=new _i(this,(r,o,i,s)=>Hp(this,r,o,i,s)),this.domObserver.start(),fp(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&&Bi(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(ec),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let r in this._props)t[r]=this._props[r];t.state=this.state;for(let r in e)t[r]=e[r];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var r;let o=this.state,i=!1,s=!1;e.storedMarks&&this.composing&&(Mc(this),s=!0),this.state=e;let l=o.plugins!=e.plugins||this._props.plugins!=t.plugins;if(l||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let p=Za(this);Jp(p,this.nodeViews)&&(this.nodeViews=p,i=!0)}(l||t.handleDOMEvents!=this._props.handleDOMEvents)&&Bi(this),this.editable=Xa(this),Qa(this);let a=Si(this),c=Ya(this),d=o.plugins!=e.plugins&&!o.doc.eq(e.doc)?"reset":e.scrollToSelection>o.scrollToSelection?"to selection":"preserve",u=i||!this.docView.matchesNode(e.doc,c,a);(u||!e.selection.eq(o.selection))&&(s=!0);let f=d=="preserve"&&s&&this.dom.style.overflowAnchor==null&&Nf(this);if(s){this.domObserver.stop();let p=u&&(ye||de)&&!this.composing&&!o.selection.empty&&!e.selection.empty&&Kp(o.selection,e.selection);if(u){let h=de?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=Mp(this)),(i||!this.docView.update(e.doc,c,a,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=Na(e.doc,c,a,this.dom,this)),h&&!this.trackWrites&&(p=!0)}p||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&Qf(this))?Ge(this,p):(pc(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(o),!((r=this.dragging)===null||r===void 0)&&r.node&&!o.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,o),d=="reset"?this.dom.scrollTop=0:d=="to selection"?this.scrollToSelection():f&&Rf(f)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))){if(!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof v){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&Ma(this,t.getBoundingClientRect(),e)}else Ma(this,this.coordsAtPos(this.state.selection.head,1),e)}}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let t=0;t0&&this.state.doc.nodeAt(i))==r.node&&(o=i)}this.dragging=new yr(e.slice,e.move,o<0?void 0:v.create(this.state.doc,o))}someProp(e,t){let r=this._props&&this._props[e],o;if(r!=null&&(o=t?t(r):r))return o;for(let s=0;st.ownerDocument.getSelection()),this._root=t}return e||document}updateRoot(){this._root=null}posAtCoords(e){return Bf(this,e)}coordsAtPos(e,t=1){return lc(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,r=-1){let o=this.docView.posFromDOM(e,t,r);if(o==null)throw new RangeError("DOM position not inside the editor");return o}endOfTextblock(e,t){return Vf(this,t||this.state,e)}pasteHTML(e,t){return In(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return In(this,e,null,!0,t||new ClipboardEvent("paste"))}serializeForClipboard(e){return Ki(this,e)}destroy(){this.docView&&(pp(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Si(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,xf())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return mp(this,e)}dispatch(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))}domSelectionRange(){let e=this.domSelection();return e?he&&this.root.nodeType===11&&Mf(this.dom.ownerDocument)==this.dom&&Pp(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}};function Ya(n){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(n.editable),n.someProp("attributes",t=>{if(typeof t=="function"&&(t=t(n.state)),t)for(let r in t)r=="class"?e.class+=" "+t[r]:r=="style"?e.style=(e.style?e.style+";":"")+t[r]:!e[r]&&r!="contenteditable"&&r!="nodeName"&&(e[r]=String(t[r]))}),e.translate||(e.translate="no"),[ne.node(0,n.state.doc.content.size,e)]}function Qa(n){if(n.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),n.cursorWrapper={dom:e,deco:ne.widget(n.state.selection.from,e,{raw:!0,marks:n.markCursor})}}else n.cursorWrapper=null}function Xa(n){return!n.someProp("editable",e=>e(n.state)===!1)}function Kp(n,e){let t=Math.min(n.$anchor.sharedDepth(n.head),e.$anchor.sharedDepth(e.head));return n.$anchor.start(t)!=e.$anchor.start(t)}function Za(n){let e=Object.create(null);function t(r){for(let o in r)Object.prototype.hasOwnProperty.call(e,o)||(e[o]=r[o])}return n.someProp("nodeViews",t),n.someProp("markViews",t),e}function Jp(n,e){let t=0,r=0;for(let o in n){if(n[o]!=e[o])return!0;t++}for(let o in e)r++;return t!=r}function ec(n){if(n.spec.state||n.spec.filterTransaction||n.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}var Ar={};rt(Ar,{keydownHandler:()=>sn,keymap:()=>Xi});var Ye={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:"'"},Tr={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Up=typeof navigator!="undefined"&&/Mac/.test(navigator.platform),qp=typeof navigator!="undefined"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(Z=0;Z<10;Z++)Ye[48+Z]=Ye[96+Z]=String(Z);var Z;for(Z=1;Z<=24;Z++)Ye[Z+111]="F"+Z;var Z;for(Z=65;Z<=90;Z++)Ye[Z]=String.fromCharCode(Z+32),Tr[Z]=String.fromCharCode(Z);var Z;for(Mr in Ye)Tr.hasOwnProperty(Mr)||(Tr[Mr]=Ye[Mr]);var Mr;function Nc(n){var e=Up&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||qp&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?Tr:Ye)[n.keyCode]||n.key||"Unidentified";return t=="Esc"&&(t="Escape"),t=="Del"&&(t="Delete"),t=="Left"&&(t="ArrowLeft"),t=="Up"&&(t="ArrowUp"),t=="Right"&&(t="ArrowRight"),t=="Down"&&(t="ArrowDown"),t}var Gp=typeof navigator!="undefined"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):!1;function Yp(n){let e=n.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");let r,o,i,s;for(let l=0;l127)&&(i=Ye[r.keyCode])&&i!=o){let l=e[Qi(i,r)];if(l&&l(t.state,t.dispatch,t))return!0}}return!1}}var Er={};rt(Er,{ContentMatch:()=>st,DOMParser:()=>Ne,DOMSerializer:()=>Ie,Fragment:()=>x,Mark:()=>F,MarkType:()=>jt,Node:()=>pe,NodeRange:()=>it,NodeType:()=>xn,ReplaceError:()=>ot,ResolvedPos:()=>bn,Schema:()=>Wt,Slice:()=>S});var vr={};rt(vr,{AddMarkStep:()=>Ut,AddNodeMarkStep:()=>qt,AttrStep:()=>Cn,DocAttrStep:()=>Mn,MapResult:()=>Kt,Mapping:()=>Jt,RemoveMarkStep:()=>lt,RemoveNodeMarkStep:()=>Gt,ReplaceAroundStep:()=>X,ReplaceStep:()=>oe,Step:()=>ee,StepMap:()=>Pe,StepResult:()=>te,Transform:()=>We,TransformError:()=>Mt,canJoin:()=>we,canSplit:()=>ke,dropPoint:()=>Tn,findWrapping:()=>Tt,insertPoint:()=>ca,joinPoint:()=>At,liftTarget:()=>Le,replaceStep:()=>Yt});var _r={};rt(_r,{autoJoin:()=>oh,baseKeymap:()=>sh,chainCommands:()=>$r,createParagraphNear:()=>Lr,deleteSelection:()=>Fn,exitCode:()=>Pr,joinBackward:()=>Or,joinDown:()=>ss,joinForward:()=>Rr,joinTextblockBackward:()=>es,joinTextblockForward:()=>ts,joinUp:()=>is,lift:()=>ls,liftEmptyBlock:()=>zr,macBaseKeymap:()=>fs,newlineInCode:()=>Ir,pcBaseKeymap:()=>Fe,selectAll:()=>zc,selectNodeBackward:()=>Nr,selectNodeForward:()=>Dr,selectParentNode:()=>ds,selectTextblockEnd:()=>Fr,selectTextblockStart:()=>Br,setBlockType:()=>Hr,splitBlock:()=>cs,splitBlockAs:()=>Lc,splitBlockKeepMarks:()=>Xp,toggleMark:()=>nh,wrapIn:()=>us});var Fn=(n,e)=>n.selection.empty?!1:(e&&e(n.tr.deleteSelection().scrollIntoView()),!0);function Dc(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("backward",n):t.parentOffset>0)?null:t}var Or=(n,e,t)=>{let r=Dc(n,t);if(!r)return!1;let o=ns(r);if(!o){let s=r.blockRange(),l=s&&Le(s);return l==null?!1:(e&&e(n.tr.lift(s,l).scrollIntoView()),!0)}let i=o.nodeBefore;if(Bc(n,o,e,-1))return!0;if(r.parent.content.size==0&&(ln(i,"end")||v.isSelectable(i)))for(let s=r.depth;;s--){let l=Yt(n.doc,r.before(s),r.after(s),S.empty);if(l&&l.slice.size1)break}return i.isAtom&&o.depth==r.depth-1?(e&&e(n.tr.delete(o.pos-i.nodeSize,o.pos).scrollIntoView()),!0):!1},es=(n,e,t)=>{let r=Dc(n,t);if(!r)return!1;let o=ns(r);return o?Ic(n,o,e):!1},ts=(n,e,t)=>{let r=Pc(n,t);if(!r)return!1;let o=rs(r);return o?Ic(n,o,e):!1};function Ic(n,e,t){let r=e.nodeBefore,o=r,i=e.pos-1;for(;!o.isTextblock;i--){if(o.type.spec.isolating)return!1;let d=o.lastChild;if(!d)return!1;o=d}let s=e.nodeAfter,l=s,a=e.pos+1;for(;!l.isTextblock;a++){if(l.type.spec.isolating)return!1;let d=l.firstChild;if(!d)return!1;l=d}let c=Yt(n.doc,i,a,S.empty);if(!c||c.from!=i||c instanceof oe&&c.slice.size>=a-i)return!1;if(t){let d=n.tr.step(c);d.setSelection(A.create(d.doc,i)),t(d.scrollIntoView())}return!0}function ln(n,e,t=!1){for(let r=n;r;r=e=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(t&&r.childCount!=1)return!1}return!1}var Nr=(n,e,t)=>{let{$head:r,empty:o}=n.selection,i=r;if(!o)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("backward",n):r.parentOffset>0)return!1;i=ns(r)}let s=i&&i.nodeBefore;return!s||!v.isSelectable(s)?!1:(e&&e(n.tr.setSelection(v.create(n.doc,i.pos-s.nodeSize)).scrollIntoView()),!0)};function ns(n){if(!n.parent.type.spec.isolating)for(let e=n.depth-1;e>=0;e--){if(n.index(e)>0)return n.doc.resolve(n.before(e+1));if(n.node(e).type.spec.isolating)break}return null}function Pc(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("forward",n):t.parentOffset{let r=Pc(n,t);if(!r)return!1;let o=rs(r);if(!o)return!1;let i=o.nodeAfter;if(Bc(n,o,e,1))return!0;if(r.parent.content.size==0&&(ln(i,"start")||v.isSelectable(i))){let s=Yt(n.doc,r.before(),r.after(),S.empty);if(s&&s.slice.size{let{$head:r,empty:o}=n.selection,i=r;if(!o)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("forward",n):r.parentOffset=0;e--){let t=n.node(e);if(n.index(e)+1{let t=n.selection,r=t instanceof v,o;if(r){if(t.node.isTextblock||!we(n.doc,t.from))return!1;o=t.from}else if(o=At(n.doc,t.from,-1),o==null)return!1;if(e){let i=n.tr.join(o);r&&i.setSelection(v.create(i.doc,o-n.doc.resolve(o).nodeBefore.nodeSize)),e(i.scrollIntoView())}return!0},ss=(n,e)=>{let t=n.selection,r;if(t instanceof v){if(t.node.isTextblock||!we(n.doc,t.to))return!1;r=t.to}else if(r=At(n.doc,t.to,1),r==null)return!1;return e&&e(n.tr.join(r).scrollIntoView()),!0},ls=(n,e)=>{let{$from:t,$to:r}=n.selection,o=t.blockRange(r),i=o&&Le(o);return i==null?!1:(e&&e(n.tr.lift(o,i).scrollIntoView()),!0)},Ir=(n,e)=>{let{$head:t,$anchor:r}=n.selection;return!t.parent.type.spec.code||!t.sameParent(r)?!1:(e&&e(n.tr.insertText(` +`).scrollIntoView()),!0)};function as(n){for(let e=0;e{let{$head:t,$anchor:r}=n.selection;if(!t.parent.type.spec.code||!t.sameParent(r))return!1;let o=t.node(-1),i=t.indexAfter(-1),s=as(o.contentMatchAt(i));if(!s||!o.canReplaceWith(i,i,s))return!1;if(e){let l=t.after(),a=n.tr.replaceWith(l,l,s.createAndFill());a.setSelection(E.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},Lr=(n,e)=>{let t=n.selection,{$from:r,$to:o}=t;if(t instanceof ae||r.parent.inlineContent||o.parent.inlineContent)return!1;let i=as(o.parent.contentMatchAt(o.indexAfter()));if(!i||!i.isTextblock)return!1;if(e){let s=(!r.parentOffset&&o.index(){let{$cursor:t}=n.selection;if(!t||t.parent.content.size)return!1;if(t.depth>1&&t.after()!=t.end(-1)){let i=t.before();if(ke(n.doc,i))return e&&e(n.tr.split(i).scrollIntoView()),!0}let r=t.blockRange(),o=r&&Le(r);return o==null?!1:(e&&e(n.tr.lift(r,o).scrollIntoView()),!0)};function Lc(n){return(e,t)=>{let{$from:r,$to:o}=e.selection;if(e.selection instanceof v&&e.selection.node.isBlock)return!r.parentOffset||!ke(e.doc,r.pos)?!1:(t&&t(e.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let i=[],s,l,a=!1,c=!1;for(let p=r.depth;;p--)if(r.node(p).isBlock){a=r.end(p)==r.pos+(r.depth-p),c=r.start(p)==r.pos-(r.depth-p),l=as(r.node(p-1).contentMatchAt(r.indexAfter(p-1)));let m=n&&n(o.parent,a,r);i.unshift(m||(a&&l?{type:l}:null)),s=p;break}else{if(p==1)return!1;i.unshift(null)}let d=e.tr;(e.selection instanceof A||e.selection instanceof ae)&&d.deleteSelection();let u=d.mapping.map(r.pos),f=ke(d.doc,u,i.length,i);if(f||(i[0]=l?{type:l}:null,f=ke(d.doc,u,i.length,i)),d.split(u,i.length,i),!a&&c&&r.node(s).type!=l){let p=d.mapping.map(r.before(s)),h=d.doc.resolve(p);l&&r.node(s-1).canReplaceWith(h.index(),h.index()+1,l)&&d.setNodeMarkup(d.mapping.map(r.before(s)),l)}return t&&t(d.scrollIntoView()),!0}}var cs=Lc(),Xp=(n,e)=>cs(n,e&&(t=>{let r=n.storedMarks||n.selection.$to.parentOffset&&n.selection.$from.marks();r&&t.ensureMarks(r),e(t)})),ds=(n,e)=>{let{$from:t,to:r}=n.selection,o,i=t.sharedDepth(r);return i==0?!1:(o=t.before(i),e&&e(n.tr.setSelection(v.create(n.doc,o))),!0)},zc=(n,e)=>(e&&e(n.tr.setSelection(new ae(n.doc))),!0);function Zp(n,e,t){let r=e.nodeBefore,o=e.nodeAfter,i=e.index();return!r||!o||!r.type.compatibleContent(o.type)?!1:!r.content.size&&e.parent.canReplace(i-1,i)?(t&&t(n.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(i,i+1)||!(o.isTextblock||we(n.doc,e.pos))?!1:(t&&t(n.tr.join(e.pos).scrollIntoView()),!0)}function Bc(n,e,t,r){let o=e.nodeBefore,i=e.nodeAfter,s,l,a=o.type.spec.isolating||i.type.spec.isolating;if(!a&&Zp(n,e,t))return!0;let c=!a&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(s=(l=o.contentMatchAt(o.childCount)).findWrapping(i.type))&&l.matchType(s[0]||i.type).validEnd){if(t){let p=e.pos+i.nodeSize,h=x.empty;for(let y=s.length-1;y>=0;y--)h=x.from(s[y].create(null,h));h=x.from(o.copy(h));let m=n.tr.step(new X(e.pos-1,p,e.pos,p,new S(h,1,0),s.length,!0)),g=m.doc.resolve(p+2*s.length);g.nodeAfter&&g.nodeAfter.type==o.type&&we(m.doc,g.pos)&&m.join(g.pos),t(m.scrollIntoView())}return!0}let d=i.type.spec.isolating||r>0&&a?null:E.findFrom(e,1),u=d&&d.$from.blockRange(d.$to),f=u&&Le(u);if(f!=null&&f>=e.depth)return t&&t(n.tr.lift(u,f).scrollIntoView()),!0;if(c&&ln(i,"start",!0)&&ln(o,"end")){let p=o,h=[];for(;h.push(p),!p.isTextblock;)p=p.lastChild;let m=i,g=1;for(;!m.isTextblock;m=m.firstChild)g++;if(p.canReplace(p.childCount,p.childCount,m.content)){if(t){let y=x.empty;for(let T=h.length-1;T>=0;T--)y=x.from(h[T].copy(y));let w=n.tr.step(new X(e.pos-h.length,e.pos+i.nodeSize,e.pos+g,e.pos+i.nodeSize-g,new S(y,h.length,0),0,!0));t(w.scrollIntoView())}return!0}}return!1}function Fc(n){return function(e,t){let r=e.selection,o=n<0?r.$from:r.$to,i=o.depth;for(;o.node(i).isInline;){if(!i)return!1;i--}return o.node(i).isTextblock?(t&&t(e.tr.setSelection(A.create(e.doc,n<0?o.start(i):o.end(i)))),!0):!1}}var Br=Fc(-1),Fr=Fc(1);function us(n,e=null){return function(t,r){let{$from:o,$to:i}=t.selection,s=o.blockRange(i),l=s&&Tt(s,n,e);return l?(r&&r(t.tr.wrap(s,l).scrollIntoView()),!0):!1}}function Hr(n,e=null){return function(t,r){let o=!1;for(let i=0;i{if(o)return!1;if(!(!a.isTextblock||a.hasMarkup(n,e)))if(a.type==n)o=!0;else{let d=t.doc.resolve(c),u=d.index();o=d.parent.canReplaceWith(u,u+1,n)}})}if(!o)return!1;if(r){let i=t.tr;for(let s=0;s{if(l||!r&&a.isAtom&&a.isInline&&c>=i.pos&&c+a.nodeSize<=s.pos)return!1;l=a.inlineContent&&a.type.allowsMarkType(t)}),l)return!0}return!1}function th(n){let e=[];for(let t=0;t{if(i.isAtom&&i.content.size&&i.isInline&&s>=r.pos&&s+i.nodeSize<=o.pos)return s+1>r.pos&&e.push(new Ke(r,r.doc.resolve(s+1))),r=r.doc.resolve(s+1+i.content.size),!1}),r.poss.doc.rangeHasMark(p.$from.pos,p.$to.pos,n)):u=!d.every(p=>{let h=!1;return f.doc.nodesBetween(p.$from.pos,p.$to.pos,(m,g,y)=>{if(h)return!1;h=!n.isInSet(m.marks)&&!!y&&y.type.allowsMarkType(n)&&!(m.isText&&/^\s*$/.test(m.textBetween(Math.max(0,p.$from.pos-g),Math.min(m.nodeSize,p.$to.pos-g))))}),!h});for(let p=0;p{if(!t.isGeneric)return n(t);let r=[];for(let i=0;ir.push(c,d))}let o=[];for(let i=0;ii-s);for(let i=o.length-1;i>=0;i--)we(t.doc,o[i])&&t.join(o[i]);n(t)}}function oh(n,e){let t=Array.isArray(e)?r=>e.indexOf(r.type.name)>-1:e;return(r,o,i)=>n(r,o&&rh(o,t),i)}function $r(...n){return function(e,t,r){for(let o=0;o=2&&e.$from.node(e.depth-1).type.compatibleContent(t)&&e.startIndex==0){if(e.$from.index(e.depth-1)==0)return!1;let a=s.resolve(e.start-2);i=new it(a,a,e.depth),e.endIndex=0;d--)i=x.from(t[d].type.create(t[d].attrs,i));n.step(new X(e.start-(r?2:0),e.end,e.start,e.end,new S(i,0,0),t.length,!0));let s=0;for(let d=0;ds.childCount>0&&s.firstChild.type==n);return i?t?r.node(i.depth-1).type==n?ch(e,t,n,i):dh(e,t,i):!0:!1}}function ch(n,e,t,r){let o=n.tr,i=r.end,s=r.$to.end(r.depth);im;h--)p-=o.child(h).nodeSize,r.delete(p-1,p+1);let i=r.doc.resolve(t.start),s=i.nodeAfter;if(r.mapping.map(t.end)!=t.start+i.nodeAfter.nodeSize)return!1;let l=t.startIndex==0,a=t.endIndex==o.childCount,c=i.node(-1),d=i.index(-1);if(!c.canReplace(d+(l?0:1),d+1,s.content.append(a?x.empty:x.from(o))))return!1;let u=i.pos,f=u+s.nodeSize;return r.step(new X(u-(l?1:0),f+(a?1:0),u+1,f-1,new S((l?x.empty:x.from(o.copy(x.empty))).append(a?x.empty:x.from(o.copy(x.empty))),l?0:1,a?0:1),l?0:1)),e(r.scrollIntoView()),!0}function _c(n){return function(e,t){let{$from:r,$to:o}=e.selection,i=r.blockRange(o,c=>c.childCount>0&&c.firstChild.type==n);if(!i)return!1;let s=i.startIndex;if(s==0)return!1;let l=i.parent,a=l.child(s-1);if(a.type!=n)return!1;if(t){let c=a.lastChild&&a.lastChild.type==l.type,d=x.from(c?n.create():null),u=new S(x.from(n.create(null,x.from(l.type.create(null,d)))),c?3:1,0),f=i.start,p=i.end;t(e.tr.step(new X(f-(c?3:1),p,f,p,u,1,!0)).scrollIntoView())}return!0}}function Yr(n){let{state:e,transaction:t}=n,{selection:r}=t,{doc:o}=t,{storedMarks:i}=t;return N(b({},e),{apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return i},get selection(){return r},get doc(){return o},get tr(){return r=t.selection,o=t.doc,i=t.storedMarks,t}})}var an=class{constructor(e){this.editor=e.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=e.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){let{rawCommands:e,editor:t,state:r}=this,{view:o}=t,{tr:i}=r,s=this.buildProps(i);return Object.fromEntries(Object.entries(e).map(([l,a])=>[l,(...d)=>{let u=a(...d)(s);return!i.getMeta("preventDispatch")&&!this.hasCustomState&&o.dispatch(i),u}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(e,t=!0){let{rawCommands:r,editor:o,state:i}=this,{view:s}=o,l=[],a=!!e,c=e||i.tr,d=()=>(!a&&t&&!c.getMeta("preventDispatch")&&!this.hasCustomState&&s.dispatch(c),l.every(f=>f===!0)),u=N(b({},Object.fromEntries(Object.entries(r).map(([f,p])=>[f,(...m)=>{let g=this.buildProps(c,t),y=p(...m)(g);return l.push(y),u}]))),{run:d});return u}createCan(e){let{rawCommands:t,state:r}=this,o=!1,i=e||r.tr,s=this.buildProps(i,o),l=Object.fromEntries(Object.entries(t).map(([a,c])=>[a,(...d)=>c(...d)(N(b({},s),{dispatch:void 0}))]));return N(b({},l),{chain:()=>this.createChain(i,o)})}buildProps(e,t=!0){let{rawCommands:r,editor:o,state:i}=this,{view:s}=o,l={tr:e,editor:o,view:s,state:Yr({state:i,transaction:e}),dispatch:t?()=>{}:void 0,chain:()=>this.createChain(e,t),can:()=>this.createCan(e),get commands(){return Object.fromEntries(Object.entries(r).map(([a,c])=>[a,(...d)=>c(...d)(l)]))}};return l}},gs=class{constructor(){this.callbacks={}}on(e,t){return this.callbacks[e]||(this.callbacks[e]=[]),this.callbacks[e].push(t),this}emit(e,...t){let r=this.callbacks[e];return r&&r.forEach(o=>o.apply(this,t)),this}off(e,t){let r=this.callbacks[e];return r&&(t?this.callbacks[e]=r.filter(o=>o!==t):delete this.callbacks[e]),this}once(e,t){let r=(...o)=>{this.off(e,r),t.apply(this,o)};return this.on(e,r)}removeAllListeners(){this.callbacks={}}};function C(n,e,t){return n.config[e]===void 0&&n.parent?C(n.parent,e,t):typeof n.config[e]=="function"?n.config[e].bind(N(b({},t),{parent:n.parent?C(n.parent,e,t):null})):n.config[e]}function Qr(n){let e=n.filter(o=>o.type==="extension"),t=n.filter(o=>o.type==="node"),r=n.filter(o=>o.type==="mark");return{baseExtensions:e,nodeExtensions:t,markExtensions:r}}function Qc(n){let e=[],{nodeExtensions:t,markExtensions:r}=Qr(n),o=[...t,...r],i={default:null,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return n.forEach(s=>{let l={name:s.name,options:s.options,storage:s.storage,extensions:o},a=C(s,"addGlobalAttributes",l);if(!a)return;a().forEach(d=>{d.types.forEach(u=>{Object.entries(d.attributes).forEach(([f,p])=>{e.push({type:u,name:f,attribute:b(b({},i),p)})})})})}),o.forEach(s=>{let l={name:s.name,options:s.options,storage:s.storage},a=C(s,"addAttributes",l);if(!a)return;let c=a();Object.entries(c).forEach(([d,u])=>{let f=b(b({},i),u);typeof(f==null?void 0:f.default)=="function"&&(f.default=f.default()),f!=null&&f.isRequired&&(f==null?void 0:f.default)===void 0&&delete f.default,e.push({type:s.name,name:d,attribute:f})})}),e}function re(n,e){if(typeof n=="string"){if(!e.nodes[n])throw Error(`There is no node type named '${n}'. Maybe you forgot to add the extension?`);return e.nodes[n]}return n}function O(...n){return n.filter(e=>!!e).reduce((e,t)=>{let r=b({},e);return Object.entries(t).forEach(([o,i])=>{if(!r[o]){r[o]=i;return}if(o==="class"){let l=i?String(i).split(" "):[],a=r[o]?r[o].split(" "):[],c=l.filter(d=>!a.includes(d));r[o]=[...a,...c].join(" ")}else if(o==="style"){let l=i?i.split(";").map(d=>d.trim()).filter(Boolean):[],a=r[o]?r[o].split(";").map(d=>d.trim()).filter(Boolean):[],c=new Map;a.forEach(d=>{let[u,f]=d.split(":").map(p=>p.trim());c.set(u,f)}),l.forEach(d=>{let[u,f]=d.split(":").map(p=>p.trim());c.set(u,f)}),r[o]=Array.from(c.entries()).map(([d,u])=>`${d}: ${u}`).join("; ")}else r[o]=i}),r},{})}function ys(n,e){return e.filter(t=>t.type===n.type.name).filter(t=>t.attribute.rendered).map(t=>t.attribute.renderHTML?t.attribute.renderHTML(n.attrs)||{}:{[t.name]:n.attrs[t.name]}).reduce((t,r)=>O(t,r),{})}function Xc(n){return typeof n=="function"}function D(n,e=void 0,...t){return Xc(n)?e?n.bind(e)(...t):n(...t):n}function uh(n={}){return Object.keys(n).length===0&&n.constructor===Object}function fh(n){return typeof n!="string"?n:n.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(n):n==="true"?!0:n==="false"?!1:n}function Vc(n,e){return"style"in n?n:N(b({},n),{getAttrs:t=>{let r=n.getAttrs?n.getAttrs(t):n.attrs;if(r===!1)return!1;let o=e.reduce((i,s)=>{let l=s.attribute.parseHTML?s.attribute.parseHTML(t):fh(t.getAttribute(s.name));return l==null?i:N(b({},i),{[s.name]:l})},{});return b(b({},r),o)}})}function jc(n){return Object.fromEntries(Object.entries(n).filter(([e,t])=>e==="attrs"&&uh(t)?!1:t!=null))}function Zc(n,e){var t;let r=Qc(n),{nodeExtensions:o,markExtensions:i}=Qr(n),s=(t=o.find(c=>C(c,"topNode")))===null||t===void 0?void 0:t.name,l=Object.fromEntries(o.map(c=>{let d=r.filter(y=>y.type===c.name),u={name:c.name,options:c.options,storage:c.storage,editor:e},f=n.reduce((y,w)=>{let T=C(w,"extendNodeSchema",u);return b(b({},y),T?T(c):{})},{}),p=jc(N(b({},f),{content:D(C(c,"content",u)),marks:D(C(c,"marks",u)),group:D(C(c,"group",u)),inline:D(C(c,"inline",u)),atom:D(C(c,"atom",u)),selectable:D(C(c,"selectable",u)),draggable:D(C(c,"draggable",u)),code:D(C(c,"code",u)),whitespace:D(C(c,"whitespace",u)),linebreakReplacement:D(C(c,"linebreakReplacement",u)),defining:D(C(c,"defining",u)),isolating:D(C(c,"isolating",u)),attrs:Object.fromEntries(d.map(y=>{var w;return[y.name,{default:(w=y==null?void 0:y.attribute)===null||w===void 0?void 0:w.default}]}))})),h=D(C(c,"parseHTML",u));h&&(p.parseDOM=h.map(y=>Vc(y,d)));let m=C(c,"renderHTML",u);m&&(p.toDOM=y=>m({node:y,HTMLAttributes:ys(y,d)}));let g=C(c,"renderText",u);return g&&(p.toText=g),[c.name,p]})),a=Object.fromEntries(i.map(c=>{let d=r.filter(g=>g.type===c.name),u={name:c.name,options:c.options,storage:c.storage,editor:e},f=n.reduce((g,y)=>{let w=C(y,"extendMarkSchema",u);return b(b({},g),w?w(c):{})},{}),p=jc(N(b({},f),{inclusive:D(C(c,"inclusive",u)),excludes:D(C(c,"excludes",u)),group:D(C(c,"group",u)),spanning:D(C(c,"spanning",u)),code:D(C(c,"code",u)),attrs:Object.fromEntries(d.map(g=>{var y;return[g.name,{default:(y=g==null?void 0:g.attribute)===null||y===void 0?void 0:y.default}]}))})),h=D(C(c,"parseHTML",u));h&&(p.parseDOM=h.map(g=>Vc(g,d)));let m=C(c,"renderHTML",u);return m&&(p.toDOM=g=>m({mark:g,HTMLAttributes:ys(g,d)})),[c.name,p]}));return new Wt({topNode:s,nodes:l,marks:a})}function ps(n,e){return e.nodes[n]||e.marks[n]||null}function Wc(n,e){return Array.isArray(e)?e.some(t=>(typeof t=="string"?t:t.name)===n.name):e}function Xr(n,e){let t=Ie.fromSchema(e).serializeFragment(n),o=document.implementation.createHTMLDocument().createElement("div");return o.appendChild(t),o.innerHTML}var ph=(n,e=500)=>{let t="",r=n.parentOffset;return n.parent.nodesBetween(Math.max(0,r-e),r,(o,i,s,l)=>{var a,c;let d=((c=(a=o.type.spec).toText)===null||c===void 0?void 0:c.call(a,{node:o,pos:i,parent:s,index:l}))||o.textContent||"%leaf%";t+=o.isAtom&&!o.isText?d:d.slice(0,Math.max(0,r-i))}),t};function ws(n){return Object.prototype.toString.call(n)==="[object RegExp]"}var zt=class{constructor(e){this.find=e.find,this.handler=e.handler}},hh=(n,e)=>{if(ws(e))return e.exec(n);let t=e(n);if(!t)return null;let r=[t.text];return r.index=t.index,r.input=n,r.data=t.data,t.replaceWith&&(t.text.includes(t.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),r.push(t.replaceWith)),r};function Vr(n){var e;let{editor:t,from:r,to:o,text:i,rules:s,plugin:l}=n,{view:a}=t;if(a.composing)return!1;let c=a.state.doc.resolve(r);if(c.parent.type.spec.code||!((e=c.nodeBefore||c.nodeAfter)===null||e===void 0)&&e.marks.find(f=>f.type.spec.code))return!1;let d=!1,u=ph(c)+i;return s.forEach(f=>{if(d)return;let p=hh(u,f.find);if(!p)return;let h=a.state.tr,m=Yr({state:a.state,transaction:h}),g={from:r-(p[0].length-i.length),to:o},{commands:y,chain:w,can:T}=new an({editor:t,state:m});f.handler({state:m,range:g,match:p,commands:y,chain:w,can:T})===null||!h.steps.length||(h.setMeta(l,{transform:h,from:r,to:o,text:i}),a.dispatch(h),d=!0)}),d}function mh(n){let{editor:e,rules:t}=n,r=new L({state:{init(){return null},apply(o,i,s){let l=o.getMeta(r);if(l)return l;let a=o.getMeta("applyInputRules");return!!a&&setTimeout(()=>{let{text:d}=a;typeof d=="string"?d=d:d=Xr(x.from(d),s.schema);let{from:u}=a,f=u+d.length;Vr({editor:e,from:u,to:f,text:d,rules:t,plugin:r})}),o.selectionSet||o.docChanged?null:i}},props:{handleTextInput(o,i,s,l){return Vr({editor:e,from:i,to:s,text:l,rules:t,plugin:r})},handleDOMEvents:{compositionend:o=>(setTimeout(()=>{let{$cursor:i}=o.state.selection;i&&Vr({editor:e,from:i.pos,to:i.pos,text:"",rules:t,plugin:r})}),!1)},handleKeyDown(o,i){if(i.key!=="Enter")return!1;let{$cursor:s}=o.state.selection;return s?Vr({editor:e,from:s.pos,to:s.pos,text:` +`,rules:t,plugin:r}):!1}},isInputRules:!0});return r}function gh(n){return Object.prototype.toString.call(n).slice(8,-1)}function jr(n){return gh(n)!=="Object"?!1:n.constructor===Object&&Object.getPrototypeOf(n)===Object.prototype}function Zr(n,e){let t=b({},n);return jr(n)&&jr(e)&&Object.keys(e).forEach(r=>{jr(e[r])&&jr(n[r])?t[r]=Zr(n[r],e[r]):t[r]=e[r]}),t}var J=class n{constructor(e={}){this.type="mark",this.name="mark",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config=b(b({},this.config),e),this.name=this.config.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=D(C(this,"addOptions",{name:this.name}))),this.storage=D(C(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new n(e)}configure(e={}){let t=this.extend(N(b({},this.config),{addOptions:()=>Zr(this.options,e)}));return t.name=this.name,t.parent=this.parent,t}extend(e={}){let t=new n(e);return t.parent=this,this.child=t,t.name=e.name?e.name:t.parent.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${t.name}".`),t.options=D(C(t,"addOptions",{name:t.name})),t.storage=D(C(t,"addStorage",{name:t.name,options:t.options})),t}static handleExit({editor:e,mark:t}){let{tr:r}=e.state,o=e.state.selection.$from;if(o.pos===o.end()){let s=o.marks();if(!!!s.find(c=>(c==null?void 0:c.type.name)===t.name))return!1;let a=s.find(c=>(c==null?void 0:c.type.name)===t.name);return a&&r.removeStoredMark(a),r.insertText(" ",o.pos),e.view.dispatch(r),!0}return!1}};function yh(n){return typeof n=="number"}var $n=class{constructor(e){this.find=e.find,this.handler=e.handler}},bh=(n,e,t)=>{if(ws(e))return[...n.matchAll(e)];let r=e(n,t);return r?r.map(o=>{let i=[o.text];return i.index=o.index,i.input=n,i.data=o.data,o.replaceWith&&(o.text.includes(o.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),i.push(o.replaceWith)),i}):[]};function xh(n){let{editor:e,state:t,from:r,to:o,rule:i,pasteEvent:s,dropEvent:l}=n,{commands:a,chain:c,can:d}=new an({editor:e,state:t}),u=[];return t.doc.nodesBetween(r,o,(p,h)=>{if(!p.isTextblock||p.type.spec.code)return;let m=Math.max(r,h),g=Math.min(o,h+p.content.size),y=p.textBetween(m-h,g-h,void 0,"\uFFFC");bh(y,i.find,s).forEach(T=>{if(T.index===void 0)return;let I=m+T.index+1,M=I+T[0].length,R={from:t.tr.mapping.map(I),to:t.tr.mapping.map(M)},_=i.handler({state:t,range:R,match:T,commands:a,chain:c,can:d,pasteEvent:s,dropEvent:l});u.push(_)})}),u.every(p=>p!==null)}var Wr=null,kh=n=>{var e;let t=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return(e=t.clipboardData)===null||e===void 0||e.setData("text/html",n),t};function wh(n){let{editor:e,rules:t}=n,r=null,o=!1,i=!1,s=typeof ClipboardEvent!="undefined"?new ClipboardEvent("paste"):null,l;try{l=typeof DragEvent!="undefined"?new DragEvent("drop"):null}catch(d){l=null}let a=({state:d,from:u,to:f,rule:p,pasteEvt:h})=>{let m=d.tr,g=Yr({state:d,transaction:m});if(!(!xh({editor:e,state:g,from:Math.max(u-1,0),to:f.b-1,rule:p,pasteEvent:h,dropEvent:l})||!m.steps.length)){try{l=typeof DragEvent!="undefined"?new DragEvent("drop"):null}catch(w){l=null}return s=typeof ClipboardEvent!="undefined"?new ClipboardEvent("paste"):null,m}};return t.map(d=>new L({view(u){let f=h=>{var m;r=!((m=u.dom.parentElement)===null||m===void 0)&&m.contains(h.target)?u.dom.parentElement:null,r&&(Wr=e)},p=()=>{Wr&&(Wr=null)};return window.addEventListener("dragstart",f),window.addEventListener("dragend",p),{destroy(){window.removeEventListener("dragstart",f),window.removeEventListener("dragend",p)}}},props:{handleDOMEvents:{drop:(u,f)=>{if(i=r===u.dom.parentElement,l=f,!i){let p=Wr;p&&setTimeout(()=>{let h=p.state.selection;h&&p.commands.deleteRange({from:h.from,to:h.to})},10)}return!1},paste:(u,f)=>{var p;let h=(p=f.clipboardData)===null||p===void 0?void 0:p.getData("text/html");return s=f,o=!!(h!=null&&h.includes("data-pm-slice")),!1}}},appendTransaction:(u,f,p)=>{let h=u[0],m=h.getMeta("uiEvent")==="paste"&&!o,g=h.getMeta("uiEvent")==="drop"&&!i,y=h.getMeta("applyPasteRules"),w=!!y;if(!m&&!g&&!w)return;if(w){let{text:M}=y;typeof M=="string"?M=M:M=Xr(x.from(M),p.schema);let{from:R}=y,_=R+M.length,Q=kh(M);return a({rule:d,state:p,from:R,to:{b:_},pasteEvt:Q})}let T=f.doc.content.findDiffStart(p.doc.content),I=f.doc.content.findDiffEnd(p.doc.content);if(!(!yh(T)||!I||T===I.b))return a({rule:d,state:p,from:T,to:I,pasteEvt:s})}}))}function Sh(n){let e=n.filter((t,r)=>n.indexOf(t)!==r);return Array.from(new Set(e))}var Jr=class n{constructor(e,t){this.splittableMarks=[],this.editor=t,this.extensions=n.resolve(e),this.schema=Zc(this.extensions,t),this.setupExtensions()}static resolve(e){let t=n.sort(n.flatten(e)),r=Sh(t.map(o=>o.name));return r.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${r.map(o=>`'${o}'`).join(", ")}]. This can lead to issues.`),t}static flatten(e){return e.map(t=>{let r={name:t.name,options:t.options,storage:t.storage},o=C(t,"addExtensions",r);return o?[t,...this.flatten(o())]:t}).flat(10)}static sort(e){return e.sort((r,o)=>{let i=C(r,"priority")||100,s=C(o,"priority")||100;return i>s?-1:i{let r={name:t.name,options:t.options,storage:t.storage,editor:this.editor,type:ps(t.name,this.schema)},o=C(t,"addCommands",r);return o?b(b({},e),o()):e},{})}get plugins(){let{editor:e}=this,t=n.sort([...this.extensions].reverse()),r=[],o=[],i=t.map(s=>{let l={name:s.name,options:s.options,storage:s.storage,editor:e,type:ps(s.name,this.schema)},a=[],c=C(s,"addKeyboardShortcuts",l),d={};if(s.type==="mark"&&C(s,"exitable",l)&&(d.ArrowRight=()=>J.handleExit({editor:e,mark:s})),c){let m=Object.fromEntries(Object.entries(c()).map(([g,y])=>[g,()=>y({editor:e})]));d=b(b({},d),m)}let u=Xi(d);a.push(u);let f=C(s,"addInputRules",l);Wc(s,e.options.enableInputRules)&&f&&r.push(...f());let p=C(s,"addPasteRules",l);Wc(s,e.options.enablePasteRules)&&p&&o.push(...p());let h=C(s,"addProseMirrorPlugins",l);if(h){let m=h();a.push(...m)}return a}).flat();return[mh({editor:e,rules:r}),...wh({editor:e,rules:o}),...i]}get attributes(){return Qc(this.extensions)}get nodeViews(){let{editor:e}=this,{nodeExtensions:t}=Qr(this.extensions);return Object.fromEntries(t.filter(r=>!!C(r,"addNodeView")).map(r=>{let o=this.attributes.filter(a=>a.type===r.name),i={name:r.name,options:r.options,storage:r.storage,editor:e,type:re(r.name,this.schema)},s=C(r,"addNodeView",i);if(!s)return[];let l=(a,c,d,u,f)=>{let p=ys(a,o);return s()({node:a,view:c,getPos:d,decorations:u,innerDecorations:f,editor:e,extension:r,HTMLAttributes:p})};return[r.name,l]}))}setupExtensions(){this.extensions.forEach(e=>{var t;this.editor.extensionStorage[e.name]=e.storage;let r={name:e.name,options:e.options,storage:e.storage,editor:this.editor,type:ps(e.name,this.schema)};e.type==="mark"&&(!((t=D(C(e,"keepOnSplit",r)))!==null&&t!==void 0)||t)&&this.splittableMarks.push(e.name);let o=C(e,"onBeforeCreate",r),i=C(e,"onCreate",r),s=C(e,"onUpdate",r),l=C(e,"onSelectionUpdate",r),a=C(e,"onTransaction",r),c=C(e,"onFocus",r),d=C(e,"onBlur",r),u=C(e,"onDestroy",r);o&&this.editor.on("beforeCreate",o),i&&this.editor.on("create",i),s&&this.editor.on("update",s),l&&this.editor.on("selectionUpdate",l),a&&this.editor.on("transaction",a),c&&this.editor.on("focus",c),d&&this.editor.on("blur",d),u&&this.editor.on("destroy",u)})}},H=class n{constructor(e={}){this.type="extension",this.name="extension",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config=b(b({},this.config),e),this.name=this.config.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=D(C(this,"addOptions",{name:this.name}))),this.storage=D(C(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new n(e)}configure(e={}){let t=this.extend(N(b({},this.config),{addOptions:()=>Zr(this.options,e)}));return t.name=this.name,t.parent=this.parent,t}extend(e={}){let t=new n(b(b({},this.config),e));return t.parent=this,this.child=t,t.name=e.name?e.name:t.parent.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${t.name}".`),t.options=D(C(t,"addOptions",{name:t.name})),t.storage=D(C(t,"addStorage",{name:t.name,options:t.options})),t}};function ed(n,e,t){let{from:r,to:o}=e,{blockSeparator:i=` -`,textSerializers:s={}}=t||{},l="";return n.nodesBetween(r,o,(a,c,d,u)=>{var f;a.isBlock&&c>r&&(l+=i);let h=s==null?void 0:s[a.type.name];if(h)return d&&(l+=h({node:a,pos:c,parent:d,index:u,range:e})),!1;a.isText&&(l+=(f=a==null?void 0:a.text)===null||f===void 0?void 0:f.slice(Math.max(r,c)-c,o-c))}),l}function ws(n){return Object.fromEntries(Object.entries(n.nodes).filter(([,e])=>e.spec.toText).map(([e,t])=>[e,t.spec.toText]))}var ed=H.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new L({key:new j("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{let{editor:n}=this,{state:e,schema:t}=n,{doc:r,selection:o}=e,{ranges:i}=o,s=Math.min(...i.map(d=>d.$from.pos)),l=Math.max(...i.map(d=>d.$to.pos)),a=ws(t);return Zc(r,{from:s,to:l},N(b({},this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{}),{textSerializers:a}))}}})]}}),wp=()=>({editor:n,view:e})=>(requestAnimationFrame(()=>{var t;n.isDestroyed||(e.dom.blur(),(t=window==null?void 0:window.getSelection())===null||t===void 0||t.removeAllRanges())}),!0),Cp=(n=!1)=>({commands:e})=>e.setContent("",n),Mp=()=>({state:n,tr:e,dispatch:t})=>{let{selection:r}=e,{ranges:o}=r;return t&&o.forEach(({$from:i,$to:s})=>{n.doc.nodesBetween(i.pos,s.pos,(l,a)=>{if(l.type.isText)return;let{doc:c,mapping:d}=e,u=c.resolve(d.map(a)),f=c.resolve(d.map(a+l.nodeSize)),h=u.blockRange(f);if(!h)return;let p=Le(h);if(l.type.isTextblock){let{defaultType:m}=u.parent.contentMatchAt(u.index());e.setNodeMarkup(h.start,m)}(p||p===0)&&e.lift(h,p)})}),!0},Ap=n=>e=>n(e),Tp=()=>({state:n,dispatch:e})=>Lr(n,e),Ep=(n,e)=>({editor:t,tr:r})=>{let{state:o}=t,i=o.doc.slice(n.from,n.to);r.deleteRange(n.from,n.to);let s=r.mapping.map(e);return r.insert(s,i.content),r.setSelection(new T(r.doc.resolve(s-1))),!0},Op=()=>({tr:n,dispatch:e})=>{let{selection:t}=n,r=t.$anchor.node();if(r.content.size>0)return!1;let o=n.selection.$anchor;for(let i=o.depth;i>0;i-=1)if(o.node(i).type===r.type){if(e){let l=o.before(i),a=o.after(i);n.delete(l,a).scrollIntoView()}return!0}return!1},vp=n=>({tr:e,state:t,dispatch:r})=>{let o=re(n,t.schema),i=e.selection.$anchor;for(let s=i.depth;s>0;s-=1)if(i.node(s).type===o){if(r){let a=i.before(s),c=i.after(s);e.delete(a,c).scrollIntoView()}return!0}return!1},Np=n=>({tr:e,dispatch:t})=>{let{from:r,to:o}=n;return t&&e.delete(r,o),!0},Rp=()=>({state:n,dispatch:e})=>Fn(n,e),Dp=()=>({commands:n})=>n.keyboardShortcut("Enter"),Ip=()=>({state:n,dispatch:e})=>Pr(n,e);function Ur(n,e,t={strict:!0}){let r=Object.keys(e);return r.length?r.every(o=>t.strict?e[o]===n[o]:Ss(e[o])?e[o].test(n[o]):e[o]===n[o]):!0}function td(n,e,t={}){return n.find(r=>r.type===e&&Ur(Object.fromEntries(Object.keys(t).map(o=>[o,r.attrs[o]])),t))}function Wc(n,e,t={}){return!!td(n,e,t)}function Cs(n,e,t){var r;if(!n||!e)return;let o=n.parent.childAfter(n.parentOffset);if((!o.node||!o.node.marks.some(d=>d.type===e))&&(o=n.parent.childBefore(n.parentOffset)),!o.node||!o.node.marks.some(d=>d.type===e)||(t=t||((r=o.node.marks[0])===null||r===void 0?void 0:r.attrs),!td([...o.node.marks],e,t)))return;let s=o.index,l=n.start()+o.offset,a=s+1,c=l+o.node.nodeSize;for(;s>0&&Wc([...n.parent.child(s-1).marks],e,t);)s-=1,l-=n.parent.child(s).nodeSize;for(;a({tr:t,state:r,dispatch:o})=>{let i=pt(n,r.schema),{doc:s,selection:l}=t,{$from:a,from:c,to:d}=l;if(o){let u=Cs(a,i,e);if(u&&u.from<=c&&u.to>=d){let f=T.create(s,u.from,u.to);t.setSelection(f)}}return!0},Lp=n=>e=>{let t=typeof n=="function"?n(e):n;for(let r=0;r({editor:t,view:r,tr:o,dispatch:i})=>{e=b({scrollIntoView:!0},e);let s=()=>{(eo()||od())&&r.dom.focus(),requestAnimationFrame(()=>{t.isDestroyed||(r.focus(),e!=null&&e.scrollIntoView&&t.commands.scrollIntoView())})};if(r.hasFocus()&&n===null||n===!1)return!0;if(i&&n===null&&!nd(t.state.selection))return s(),!0;let l=rd(o.doc,n)||t.state.selection,a=t.state.selection.eq(l);return i&&(a||o.setSelection(l),a&&o.storedMarks&&o.setStoredMarks(o.storedMarks),s()),!0},zp=(n,e)=>t=>n.every((r,o)=>e(r,N(b({},t),{index:o}))),Fp=(n,e)=>({tr:t,commands:r})=>r.insertContentAt({from:t.selection.from,to:t.selection.to},n,e),id=n=>{let e=n.childNodes;for(let t=e.length-1;t>=0;t-=1){let r=e[t];r.nodeType===3&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?n.removeChild(r):r.nodeType===1&&id(r)}return n};function Hn(n){let e=`${n}`,t=new window.DOMParser().parseFromString(e,"text/html").body;return id(t)}function qr(n,e,t){if(n instanceof he||n instanceof x)return n;t=b({slice:!0,parseOptions:{}},t);let r=typeof n=="object"&&n!==null,o=typeof n=="string";if(r)try{if(Array.isArray(n)&&n.length>0)return x.fromArray(n.map(l=>e.nodeFromJSON(l)));let s=e.nodeFromJSON(n);return t.errorOnInvalidContent&&s.check(),s}catch(i){if(t.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:i});return console.warn("[tiptap warn]: Invalid content.","Passed value:",n,"Error:",i),qr("",e,t)}if(o){if(t.errorOnInvalidContent){let s=!1,l="",a=new Wt({topNode:e.spec.topNode,marks:e.spec.marks,nodes:e.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:c=>(s=!0,l=typeof c=="string"?c:c.outerHTML,null)}]}})});if(t.slice?Ne.fromSchema(a).parseSlice(Hn(n),t.parseOptions):Ne.fromSchema(a).parse(Hn(n),t.parseOptions),t.errorOnInvalidContent&&s)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${l}`)})}let i=Ne.fromSchema(e);return t.slice?i.parseSlice(Hn(n),t.parseOptions).content:i.parse(Hn(n),t.parseOptions)}return qr("",e,t)}function Hp(n,e,t){let r=n.steps.length-1;if(r{s===0&&(s=d)}),n.setSelection(E.near(n.doc.resolve(s),t))}var $p=n=>!("type"in n),_p=(n,e,t)=>({tr:r,dispatch:o,editor:i})=>{var s;if(o){t=b({parseOptions:i.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1},t);let l;try{l=qr(e,i.schema,{parseOptions:b({preserveWhitespace:"full"},t.parseOptions),errorOnInvalidContent:(s=t.errorOnInvalidContent)!==null&&s!==void 0?s:i.options.enableContentCheck})}catch(p){return i.emit("contentError",{editor:i,error:p,disableCollaboration:()=>{i.storage.collaboration&&(i.storage.collaboration.isDisabled=!0)}}),!1}let{from:a,to:c}=typeof n=="number"?{from:n,to:n}:{from:n.from,to:n.to},d=!0,u=!0;if(($p(l)?l:[l]).forEach(p=>{p.check(),d=d?p.isText&&p.marks.length===0:!1,u=u?p.isBlock:!1}),a===c&&u){let{parent:p}=r.doc.resolve(a);p.isTextblock&&!p.type.spec.code&&!p.childCount&&(a-=1,c+=1)}let h;if(d){if(Array.isArray(e))h=e.map(p=>p.text||"").join("");else if(e instanceof x){let p="";e.forEach(m=>{m.text&&(p+=m.text)}),h=p}else typeof e=="object"&&e&&e.text?h=e.text:h=e;r.insertText(h,a,c)}else h=l,r.replaceWith(a,c,h);t.updateSelection&&Hp(r,r.steps.length-1,-1),t.applyInputRules&&r.setMeta("applyInputRules",{from:a,text:h}),t.applyPasteRules&&r.setMeta("applyPasteRules",{from:a,text:h})}return!0},Vp=()=>({state:n,dispatch:e})=>is(n,e),jp=()=>({state:n,dispatch:e})=>ss(n,e),Wp=()=>({state:n,dispatch:e})=>vr(n,e),Kp=()=>({state:n,dispatch:e})=>Rr(n,e),Jp=()=>({state:n,dispatch:e,tr:t})=>{try{let r=Tt(n.doc,n.selection.$from.pos,-1);return r==null?!1:(t.join(r,2),e&&e(t),!0)}catch(r){return!1}},Up=()=>({state:n,dispatch:e,tr:t})=>{try{let r=Tt(n.doc,n.selection.$from.pos,1);return r==null?!1:(t.join(r,2),e&&e(t),!0)}catch(r){return!1}},qp=()=>({state:n,dispatch:e})=>es(n,e),Gp=()=>({state:n,dispatch:e})=>ts(n,e);function sd(){return typeof navigator!="undefined"?/Mac/.test(navigator.platform):!1}function Yp(n){let e=n.split(/-(?!$)/),t=e[e.length-1];t==="Space"&&(t=" ");let r,o,i,s;for(let l=0;l({editor:e,view:t,tr:r,dispatch:o})=>{let i=Yp(n).split(/-(?!$)/),s=i.find(c=>!["Alt","Ctrl","Meta","Shift"].includes(c)),l=new KeyboardEvent("keydown",{key:s==="Space"?" ":s,altKey:i.includes("Alt"),ctrlKey:i.includes("Ctrl"),metaKey:i.includes("Meta"),shiftKey:i.includes("Shift"),bubbles:!0,cancelable:!0}),a=e.captureTransaction(()=>{t.someProp("handleKeyDown",c=>c(t,l))});return a==null||a.steps.forEach(c=>{let d=c.map(r.mapping);d&&o&&r.maybeStep(d)}),!0};function _n(n,e,t={}){let{from:r,to:o,empty:i}=n.selection,s=e?re(e,n.schema):null,l=[];n.doc.nodesBetween(r,o,(u,f)=>{if(u.isText)return;let h=Math.max(r,f),p=Math.min(o,f+u.nodeSize);l.push({node:u,from:h,to:p})});let a=o-r,c=l.filter(u=>s?s.name===u.node.type.name:!0).filter(u=>Ur(u.node.attrs,t,{strict:!1}));return i?!!c.length:c.reduce((u,f)=>u+f.to-f.from,0)>=a}var Xp=(n,e={})=>({state:t,dispatch:r})=>{let o=re(n,t.schema);return _n(t,o,e)?ls(t,r):!1},Zp=()=>({state:n,dispatch:e})=>Br(n,e),em=n=>({state:e,dispatch:t})=>{let r=re(n,e.schema);return Hc(r)(e,t)},tm=()=>({state:n,dispatch:e})=>Ir(n,e);function to(n,e){return e.nodes[n]?"node":e.marks[n]?"mark":null}function Kc(n,e){let t=typeof e=="string"?[e]:e;return Object.keys(n).reduce((r,o)=>(t.includes(o)||(r[o]=n[o]),r),{})}var nm=(n,e)=>({tr:t,state:r,dispatch:o})=>{let i=null,s=null,l=to(typeof n=="string"?n:n.name,r.schema);return l?(l==="node"&&(i=re(n,r.schema)),l==="mark"&&(s=pt(n,r.schema)),o&&t.selection.ranges.forEach(a=>{r.doc.nodesBetween(a.$from.pos,a.$to.pos,(c,d)=>{i&&i===c.type&&t.setNodeMarkup(d,void 0,Kc(c.attrs,e)),s&&c.marks.length&&c.marks.forEach(u=>{s===u.type&&t.addMark(d,d+c.nodeSize,s.create(Kc(u.attrs,e)))})})}),!0):!1},rm=()=>({tr:n,dispatch:e})=>(e&&n.scrollIntoView(),!0),om=()=>({tr:n,dispatch:e})=>{if(e){let t=new ae(n.doc);n.setSelection(t)}return!0},im=()=>({state:n,dispatch:e})=>Nr(n,e),sm=()=>({state:n,dispatch:e})=>Dr(n,e),lm=()=>({state:n,dispatch:e})=>ds(n,e),am=()=>({state:n,dispatch:e})=>Fr(n,e),cm=()=>({state:n,dispatch:e})=>zr(n,e);function bs(n,e,t={},r={}){return qr(n,e,{slice:!1,parseOptions:t,errorOnInvalidContent:r.errorOnInvalidContent})}var dm=(n,e=!1,t={},r={})=>({editor:o,tr:i,dispatch:s,commands:l})=>{var a,c;let{doc:d}=i;if(t.preserveWhitespace!=="full"){let u=bs(n,o.schema,t,{errorOnInvalidContent:(a=r.errorOnInvalidContent)!==null&&a!==void 0?a:o.options.enableContentCheck});return s&&i.replaceWith(0,d.content.size,u).setMeta("preventUpdate",!e),!0}return s&&i.setMeta("preventUpdate",!e),l.insertContentAt({from:0,to:d.content.size},n,{parseOptions:t,errorOnInvalidContent:(c=r.errorOnInvalidContent)!==null&&c!==void 0?c:o.options.enableContentCheck})};function ld(n,e){let t=pt(e,n.schema),{from:r,to:o,empty:i}=n.selection,s=[];i?(n.storedMarks&&s.push(...n.storedMarks),s.push(...n.selection.$head.marks())):n.doc.nodesBetween(r,o,a=>{s.push(...a.marks)});let l=s.find(a=>a.type.name===t.name);return l?b({},l.attrs):{}}function ad(n,e){let t=new We(n);return e.forEach(r=>{r.steps.forEach(o=>{t.step(o)})}),t}function um(n){for(let e=0;e{e(r)&&t.push({node:r,pos:o})}),t}function cd(n,e,t){let r=[];return n.nodesBetween(e.from,e.to,(o,i)=>{t(o)&&r.push({node:o,pos:i})}),r}function Ms(n,e){for(let t=n.depth;t>0;t-=1){let r=n.node(t);if(e(r))return{pos:t>0?n.before(t):0,start:n.start(t),depth:t,node:r}}}function no(n){return e=>Ms(e.$from,n)}function As(n,e){let t=Jr.resolve(n);return Xc(t,e)}function vb(n,e){let t=As(e),r=he.fromJSON(t,n);return Xr(r.content,t)}function Nb(n,e){let t=As(e),r=Hn(n);return Ne.fromSchema(t).parse(r).toJSON()}function dd(n,e){let t={from:0,to:n.content.size};return Zc(n,t,e)}function Rb(n,e,t){let{blockSeparator:r=` +`,textSerializers:s={}}=t||{},l="";return n.nodesBetween(r,o,(a,c,d,u)=>{var f;a.isBlock&&c>r&&(l+=i);let p=s==null?void 0:s[a.type.name];if(p)return d&&(l+=p({node:a,pos:c,parent:d,index:u,range:e})),!1;a.isText&&(l+=(f=a==null?void 0:a.text)===null||f===void 0?void 0:f.slice(Math.max(r,c)-c,o-c))}),l}function Ss(n){return Object.fromEntries(Object.entries(n.nodes).filter(([,e])=>e.spec.toText).map(([e,t])=>[e,t.spec.toText]))}var td=H.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new L({key:new j("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{let{editor:n}=this,{state:e,schema:t}=n,{doc:r,selection:o}=e,{ranges:i}=o,s=Math.min(...i.map(d=>d.$from.pos)),l=Math.max(...i.map(d=>d.$to.pos)),a=Ss(t);return ed(r,{from:s,to:l},N(b({},this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{}),{textSerializers:a}))}}})]}}),Ch=()=>({editor:n,view:e})=>(requestAnimationFrame(()=>{var t;n.isDestroyed||(e.dom.blur(),(t=window==null?void 0:window.getSelection())===null||t===void 0||t.removeAllRanges())}),!0),Mh=(n=!1)=>({commands:e})=>e.setContent("",n),Th=()=>({state:n,tr:e,dispatch:t})=>{let{selection:r}=e,{ranges:o}=r;return t&&o.forEach(({$from:i,$to:s})=>{n.doc.nodesBetween(i.pos,s.pos,(l,a)=>{if(l.type.isText)return;let{doc:c,mapping:d}=e,u=c.resolve(d.map(a)),f=c.resolve(d.map(a+l.nodeSize)),p=u.blockRange(f);if(!p)return;let h=Le(p);if(l.type.isTextblock){let{defaultType:m}=u.parent.contentMatchAt(u.index());e.setNodeMarkup(p.start,m)}(h||h===0)&&e.lift(p,h)})}),!0},Ah=n=>e=>n(e),Eh=()=>({state:n,dispatch:e})=>Lr(n,e),vh=(n,e)=>({editor:t,tr:r})=>{let{state:o}=t,i=o.doc.slice(n.from,n.to);r.deleteRange(n.from,n.to);let s=r.mapping.map(e);return r.insert(s,i.content),r.setSelection(new A(r.doc.resolve(s-1))),!0},Oh=()=>({tr:n,dispatch:e})=>{let{selection:t}=n,r=t.$anchor.node();if(r.content.size>0)return!1;let o=n.selection.$anchor;for(let i=o.depth;i>0;i-=1)if(o.node(i).type===r.type){if(e){let l=o.before(i),a=o.after(i);n.delete(l,a).scrollIntoView()}return!0}return!1},Nh=n=>({tr:e,state:t,dispatch:r})=>{let o=re(n,t.schema),i=e.selection.$anchor;for(let s=i.depth;s>0;s-=1)if(i.node(s).type===o){if(r){let a=i.before(s),c=i.after(s);e.delete(a,c).scrollIntoView()}return!0}return!1},Rh=n=>({tr:e,dispatch:t})=>{let{from:r,to:o}=n;return t&&e.delete(r,o),!0},Dh=()=>({state:n,dispatch:e})=>Fn(n,e),Ih=()=>({commands:n})=>n.keyboardShortcut("Enter"),Ph=()=>({state:n,dispatch:e})=>Pr(n,e);function Ur(n,e,t={strict:!0}){let r=Object.keys(e);return r.length?r.every(o=>t.strict?e[o]===n[o]:ws(e[o])?e[o].test(n[o]):e[o]===n[o]):!0}function nd(n,e,t={}){return n.find(r=>r.type===e&&Ur(Object.fromEntries(Object.keys(t).map(o=>[o,r.attrs[o]])),t))}function Kc(n,e,t={}){return!!nd(n,e,t)}function Cs(n,e,t){var r;if(!n||!e)return;let o=n.parent.childAfter(n.parentOffset);if((!o.node||!o.node.marks.some(d=>d.type===e))&&(o=n.parent.childBefore(n.parentOffset)),!o.node||!o.node.marks.some(d=>d.type===e)||(t=t||((r=o.node.marks[0])===null||r===void 0?void 0:r.attrs),!nd([...o.node.marks],e,t)))return;let s=o.index,l=n.start()+o.offset,a=s+1,c=l+o.node.nodeSize;for(;s>0&&Kc([...n.parent.child(s-1).marks],e,t);)s-=1,l-=n.parent.child(s).nodeSize;for(;a({tr:t,state:r,dispatch:o})=>{let i=ht(n,r.schema),{doc:s,selection:l}=t,{$from:a,from:c,to:d}=l;if(o){let u=Cs(a,i,e);if(u&&u.from<=c&&u.to>=d){let f=A.create(s,u.from,u.to);t.setSelection(f)}}return!0},zh=n=>e=>{let t=typeof n=="function"?n(e):n;for(let r=0;r({editor:t,view:r,tr:o,dispatch:i})=>{e=b({scrollIntoView:!0},e);let s=()=>{(eo()||id())&&r.dom.focus(),requestAnimationFrame(()=>{t.isDestroyed||(r.focus(),e!=null&&e.scrollIntoView&&t.commands.scrollIntoView())})};if(r.hasFocus()&&n===null||n===!1)return!0;if(i&&n===null&&!rd(t.state.selection))return s(),!0;let l=od(o.doc,n)||t.state.selection,a=t.state.selection.eq(l);return i&&(a||o.setSelection(l),a&&o.storedMarks&&o.setStoredMarks(o.storedMarks),s()),!0},Fh=(n,e)=>t=>n.every((r,o)=>e(r,N(b({},t),{index:o}))),Hh=(n,e)=>({tr:t,commands:r})=>r.insertContentAt({from:t.selection.from,to:t.selection.to},n,e),sd=n=>{let e=n.childNodes;for(let t=e.length-1;t>=0;t-=1){let r=e[t];r.nodeType===3&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?n.removeChild(r):r.nodeType===1&&sd(r)}return n};function Hn(n){let e=`${n}`,t=new window.DOMParser().parseFromString(e,"text/html").body;return sd(t)}function qr(n,e,t){if(n instanceof pe||n instanceof x)return n;t=b({slice:!0,parseOptions:{}},t);let r=typeof n=="object"&&n!==null,o=typeof n=="string";if(r)try{if(Array.isArray(n)&&n.length>0)return x.fromArray(n.map(l=>e.nodeFromJSON(l)));let s=e.nodeFromJSON(n);return t.errorOnInvalidContent&&s.check(),s}catch(i){if(t.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:i});return console.warn("[tiptap warn]: Invalid content.","Passed value:",n,"Error:",i),qr("",e,t)}if(o){if(t.errorOnInvalidContent){let s=!1,l="",a=new Wt({topNode:e.spec.topNode,marks:e.spec.marks,nodes:e.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:c=>(s=!0,l=typeof c=="string"?c:c.outerHTML,null)}]}})});if(t.slice?Ne.fromSchema(a).parseSlice(Hn(n),t.parseOptions):Ne.fromSchema(a).parse(Hn(n),t.parseOptions),t.errorOnInvalidContent&&s)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${l}`)})}let i=Ne.fromSchema(e);return t.slice?i.parseSlice(Hn(n),t.parseOptions).content:i.parse(Hn(n),t.parseOptions)}return qr("",e,t)}function $h(n,e,t){let r=n.steps.length-1;if(r{s===0&&(s=d)}),n.setSelection(E.near(n.doc.resolve(s),t))}var _h=n=>!("type"in n),Vh=(n,e,t)=>({tr:r,dispatch:o,editor:i})=>{var s;if(o){t=b({parseOptions:i.options.parseOptions,updateSelection:!0,applyInputRules:!1,applyPasteRules:!1},t);let l;try{l=qr(e,i.schema,{parseOptions:b({preserveWhitespace:"full"},t.parseOptions),errorOnInvalidContent:(s=t.errorOnInvalidContent)!==null&&s!==void 0?s:i.options.enableContentCheck})}catch(h){return i.emit("contentError",{editor:i,error:h,disableCollaboration:()=>{i.storage.collaboration&&(i.storage.collaboration.isDisabled=!0)}}),!1}let{from:a,to:c}=typeof n=="number"?{from:n,to:n}:{from:n.from,to:n.to},d=!0,u=!0;if((_h(l)?l:[l]).forEach(h=>{h.check(),d=d?h.isText&&h.marks.length===0:!1,u=u?h.isBlock:!1}),a===c&&u){let{parent:h}=r.doc.resolve(a);h.isTextblock&&!h.type.spec.code&&!h.childCount&&(a-=1,c+=1)}let p;if(d){if(Array.isArray(e))p=e.map(h=>h.text||"").join("");else if(e instanceof x){let h="";e.forEach(m=>{m.text&&(h+=m.text)}),p=h}else typeof e=="object"&&e&&e.text?p=e.text:p=e;r.insertText(p,a,c)}else p=l,r.replaceWith(a,c,p);t.updateSelection&&$h(r,r.steps.length-1,-1),t.applyInputRules&&r.setMeta("applyInputRules",{from:a,text:p}),t.applyPasteRules&&r.setMeta("applyPasteRules",{from:a,text:p})}return!0},jh=()=>({state:n,dispatch:e})=>is(n,e),Wh=()=>({state:n,dispatch:e})=>ss(n,e),Kh=()=>({state:n,dispatch:e})=>Or(n,e),Jh=()=>({state:n,dispatch:e})=>Rr(n,e),Uh=()=>({state:n,dispatch:e,tr:t})=>{try{let r=At(n.doc,n.selection.$from.pos,-1);return r==null?!1:(t.join(r,2),e&&e(t),!0)}catch(r){return!1}},qh=()=>({state:n,dispatch:e,tr:t})=>{try{let r=At(n.doc,n.selection.$from.pos,1);return r==null?!1:(t.join(r,2),e&&e(t),!0)}catch(r){return!1}},Gh=()=>({state:n,dispatch:e})=>es(n,e),Yh=()=>({state:n,dispatch:e})=>ts(n,e);function ld(){return typeof navigator!="undefined"?/Mac/.test(navigator.platform):!1}function Qh(n){let e=n.split(/-(?!$)/),t=e[e.length-1];t==="Space"&&(t=" ");let r,o,i,s;for(let l=0;l({editor:e,view:t,tr:r,dispatch:o})=>{let i=Qh(n).split(/-(?!$)/),s=i.find(c=>!["Alt","Ctrl","Meta","Shift"].includes(c)),l=new KeyboardEvent("keydown",{key:s==="Space"?" ":s,altKey:i.includes("Alt"),ctrlKey:i.includes("Ctrl"),metaKey:i.includes("Meta"),shiftKey:i.includes("Shift"),bubbles:!0,cancelable:!0}),a=e.captureTransaction(()=>{t.someProp("handleKeyDown",c=>c(t,l))});return a==null||a.steps.forEach(c=>{let d=c.map(r.mapping);d&&o&&r.maybeStep(d)}),!0};function _n(n,e,t={}){let{from:r,to:o,empty:i}=n.selection,s=e?re(e,n.schema):null,l=[];n.doc.nodesBetween(r,o,(u,f)=>{if(u.isText)return;let p=Math.max(r,f),h=Math.min(o,f+u.nodeSize);l.push({node:u,from:p,to:h})});let a=o-r,c=l.filter(u=>s?s.name===u.node.type.name:!0).filter(u=>Ur(u.node.attrs,t,{strict:!1}));return i?!!c.length:c.reduce((u,f)=>u+f.to-f.from,0)>=a}var Zh=(n,e={})=>({state:t,dispatch:r})=>{let o=re(n,t.schema);return _n(t,o,e)?ls(t,r):!1},em=()=>({state:n,dispatch:e})=>zr(n,e),tm=n=>({state:e,dispatch:t})=>{let r=re(n,e.schema);return $c(r)(e,t)},nm=()=>({state:n,dispatch:e})=>Ir(n,e);function to(n,e){return e.nodes[n]?"node":e.marks[n]?"mark":null}function Jc(n,e){let t=typeof e=="string"?[e]:e;return Object.keys(n).reduce((r,o)=>(t.includes(o)||(r[o]=n[o]),r),{})}var rm=(n,e)=>({tr:t,state:r,dispatch:o})=>{let i=null,s=null,l=to(typeof n=="string"?n:n.name,r.schema);return l?(l==="node"&&(i=re(n,r.schema)),l==="mark"&&(s=ht(n,r.schema)),o&&t.selection.ranges.forEach(a=>{r.doc.nodesBetween(a.$from.pos,a.$to.pos,(c,d)=>{i&&i===c.type&&t.setNodeMarkup(d,void 0,Jc(c.attrs,e)),s&&c.marks.length&&c.marks.forEach(u=>{s===u.type&&t.addMark(d,d+c.nodeSize,s.create(Jc(u.attrs,e)))})})}),!0):!1},om=()=>({tr:n,dispatch:e})=>(e&&n.scrollIntoView(),!0),im=()=>({tr:n,dispatch:e})=>{if(e){let t=new ae(n.doc);n.setSelection(t)}return!0},sm=()=>({state:n,dispatch:e})=>Nr(n,e),lm=()=>({state:n,dispatch:e})=>Dr(n,e),am=()=>({state:n,dispatch:e})=>ds(n,e),cm=()=>({state:n,dispatch:e})=>Fr(n,e),dm=()=>({state:n,dispatch:e})=>Br(n,e);function bs(n,e,t={},r={}){return qr(n,e,{slice:!1,parseOptions:t,errorOnInvalidContent:r.errorOnInvalidContent})}var um=(n,e=!1,t={},r={})=>({editor:o,tr:i,dispatch:s,commands:l})=>{var a,c;let{doc:d}=i;if(t.preserveWhitespace!=="full"){let u=bs(n,o.schema,t,{errorOnInvalidContent:(a=r.errorOnInvalidContent)!==null&&a!==void 0?a:o.options.enableContentCheck});return s&&i.replaceWith(0,d.content.size,u).setMeta("preventUpdate",!e),!0}return s&&i.setMeta("preventUpdate",!e),l.insertContentAt({from:0,to:d.content.size},n,{parseOptions:t,errorOnInvalidContent:(c=r.errorOnInvalidContent)!==null&&c!==void 0?c:o.options.enableContentCheck})};function ad(n,e){let t=ht(e,n.schema),{from:r,to:o,empty:i}=n.selection,s=[];i?(n.storedMarks&&s.push(...n.storedMarks),s.push(...n.selection.$head.marks())):n.doc.nodesBetween(r,o,a=>{s.push(...a.marks)});let l=s.find(a=>a.type.name===t.name);return l?b({},l.attrs):{}}function cd(n,e){let t=new We(n);return e.forEach(r=>{r.steps.forEach(o=>{t.step(o)})}),t}function fm(n){for(let e=0;e{e(r)&&t.push({node:r,pos:o})}),t}function dd(n,e,t){let r=[];return n.nodesBetween(e.from,e.to,(o,i)=>{t(o)&&r.push({node:o,pos:i})}),r}function Ms(n,e){for(let t=n.depth;t>0;t-=1){let r=n.node(t);if(e(r))return{pos:t>0?n.before(t):0,start:n.start(t),depth:t,node:r}}}function no(n){return e=>Ms(e.$from,n)}function Ts(n,e){let t=Jr.resolve(n);return Zc(t,e)}function Nb(n,e){let t=Ts(e),r=pe.fromJSON(t,n);return Xr(r.content,t)}function Rb(n,e){let t=Ts(e),r=Hn(n);return Ne.fromSchema(t).parse(r).toJSON()}function ud(n,e){let t={from:0,to:n.content.size};return ed(n,t,e)}function Db(n,e,t){let{blockSeparator:r=` -`,textSerializers:o={}}=t||{},i=As(e),s=he.fromJSON(i,n);return dd(s,{blockSeparator:r,textSerializers:b(b({},ws(i)),o)})}function fm(n,e){let t=re(e,n.schema),{from:r,to:o}=n.selection,i=[];n.doc.nodesBetween(r,o,l=>{i.push(l)});let s=i.reverse().find(l=>l.type.name===t.name);return s?b({},s.attrs):{}}function Ts(n,e){let t=to(typeof e=="string"?e:e.name,n.schema);return t==="node"?fm(n,e):t==="mark"?ld(n,e):{}}function hm(n,e=JSON.stringify){let t={};return n.filter(r=>{let o=e(r);return Object.prototype.hasOwnProperty.call(t,o)?!1:t[o]=!0})}function pm(n){let e=hm(n);return e.length===1?e:e.filter((t,r)=>!e.filter((i,s)=>s!==r).some(i=>t.oldRange.from>=i.oldRange.from&&t.oldRange.to<=i.oldRange.to&&t.newRange.from>=i.newRange.from&&t.newRange.to<=i.newRange.to))}function ud(n){let{mapping:e,steps:t}=n,r=[];return e.maps.forEach((o,i)=>{let s=[];if(o.ranges.length)o.forEach((l,a)=>{s.push({from:l,to:a})});else{let{from:l,to:a}=t[i];if(l===void 0||a===void 0)return;s.push({from:l,to:a})}s.forEach(({from:l,to:a})=>{let c=e.slice(i).map(l,-1),d=e.slice(i).map(a),u=e.invert().map(c,-1),f=e.invert().map(d);r.push({oldRange:{from:u,to:f},newRange:{from:c,to:d}})})}),pm(r)}function mm(n,e=0){let r=n.type===n.type.schema.topNodeType?0:1,o=e,i=o+n.nodeSize,s=n.marks.map(c=>{let d={type:c.type.name};return Object.keys(c.attrs).length&&(d.attrs=b({},c.attrs)),d}),l=b({},n.attrs),a={type:n.type.name,from:o,to:i};return Object.keys(l).length&&(a.attrs=l),s.length&&(a.marks=s),n.content.childCount&&(a.content=[],n.forEach((c,d)=>{var u;(u=a.content)===null||u===void 0||u.push(mm(c,e+d+r))})),n.text&&(a.text=n.text),a}function ro(n,e,t){let r=[];return n===e?t.resolve(n).marks().forEach(o=>{let i=t.resolve(n),s=Cs(i,o.type);s&&r.push(b({mark:o},s))}):t.nodesBetween(n,e,(o,i)=>{!o||(o==null?void 0:o.nodeSize)===void 0||r.push(...o.marks.map(s=>({from:i,to:i+o.nodeSize,mark:s})))}),r}var Db=(n,e,t,r=20)=>{let o=n.doc.resolve(t),i=r,s=null;for(;i>0&&s===null;){let l=o.node(i);(l==null?void 0:l.type.name)===e?s=l:i-=1}return[s,i]};function Kr(n,e,t){return Object.fromEntries(Object.entries(t).filter(([r])=>{let o=n.find(i=>i.type===e&&i.name===r);return o?o.attribute.keepOnSplit:!1}))}function xs(n,e,t={}){let{empty:r,ranges:o}=n.selection,i=e?pt(e,n.schema):null;if(r)return!!(n.storedMarks||n.selection.$from.marks()).filter(u=>i?i.name===u.type.name:!0).find(u=>Ur(u.attrs,t,{strict:!1}));let s=0,l=[];if(o.forEach(({$from:u,$to:f})=>{let h=u.pos,p=f.pos;n.doc.nodesBetween(h,p,(m,g)=>{if(!m.isText&&!m.marks.length)return;let y=Math.max(h,g),S=Math.min(p,g+m.nodeSize),A=S-y;s+=A,l.push(...m.marks.map(I=>({mark:I,from:y,to:S})))})}),s===0)return!1;let a=l.filter(u=>i?i.name===u.mark.type.name:!0).filter(u=>Ur(u.mark.attrs,t,{strict:!1})).reduce((u,f)=>u+f.to-f.from,0),c=l.filter(u=>i?u.mark.type!==i&&u.mark.type.excludes(i):!0).reduce((u,f)=>u+f.to-f.from,0);return(a>0?a+c:a)>=s}function gm(n,e,t={}){if(!e)return _n(n,null,t)||xs(n,null,t);let r=to(e,n.schema);return r==="node"?_n(n,e,t):r==="mark"?xs(n,e,t):!1}var Ib=(n,e)=>{let{$from:t,$to:r,$anchor:o}=n.selection;if(e){let i=no(l=>l.type.name===e)(n.selection);if(!i)return!1;let s=n.doc.resolve(i.pos+1);return o.pos+1===s.end()}return!(r.parentOffset{let{$from:e,$to:t}=n.selection;return!(e.parentOffset>0||e.pos!==t.pos)};function Jc(n,e){let{nodeExtensions:t}=Qr(e),r=t.find(s=>s.name===n);if(!r)return!1;let o={name:r.name,options:r.options,storage:r.storage},i=D(C(r,"group",o));return typeof i!="string"?!1:i.split(" ").includes("list")}function Es(n,{checkChildren:e=!0,ignoreWhitespace:t=!1}={}){var r;if(t){if(n.type.name==="hardBreak")return!0;if(n.isText)return/^\s*$/m.test((r=n.text)!==null&&r!==void 0?r:"")}if(n.isText)return!n.text;if(n.isAtom||n.isLeaf)return!1;if(n.content.childCount===0)return!0;if(e){let o=!0;return n.content.forEach(i=>{o!==!1&&(Es(i,{ignoreWhitespace:t,checkChildren:e})||(o=!1))}),o}return!1}function fd(n){return n instanceof O}function Lb(n,e,t){let o=n.state.doc.content.size,i=Qe(e,0,o),s=Qe(t,0,o),l=n.coordsAtPos(i),a=n.coordsAtPos(s,-1),c=Math.min(l.top,a.top),d=Math.max(l.bottom,a.bottom),u=Math.min(l.left,a.left),f=Math.max(l.right,a.right),h=f-u,p=d-c,y={top:c,bottom:d,left:u,right:f,width:h,height:p,x:u,y:c};return N(b({},y),{toJSON:()=>y})}function hd({json:n,validMarks:e,validNodes:t,options:r,rewrittenContent:o=[]}){return n.marks&&Array.isArray(n.marks)&&(n.marks=n.marks.filter(i=>{let s=typeof i=="string"?i:i.type;return e.has(s)?!0:(o.push({original:JSON.parse(JSON.stringify(i)),unsupported:s}),!1)})),n.content&&Array.isArray(n.content)&&(n.content=n.content.map(i=>hd({json:i,validMarks:e,validNodes:t,options:r,rewrittenContent:o}).json).filter(i=>i!=null)),n.type&&!t.has(n.type)?(o.push({original:JSON.parse(JSON.stringify(n)),unsupported:n.type}),n.content&&Array.isArray(n.content)&&(r==null?void 0:r.fallbackToParagraph)!==!1?(n.type="paragraph",{json:n,rewrittenContent:o}):{json:null,rewrittenContent:o}):{json:n,rewrittenContent:o}}function Bb(n,e,t){return hd({json:n,validNodes:new Set(Object.keys(e.nodes)),validMarks:new Set(Object.keys(e.marks)),options:t})}function ym(n,e,t){var r;let{selection:o}=e,i=null;if(nd(o)&&(i=o.$cursor),i){let l=(r=n.storedMarks)!==null&&r!==void 0?r:i.marks();return!!t.isInSet(l)||!l.some(a=>a.type.excludes(t))}let{ranges:s}=o;return s.some(({$from:l,$to:a})=>{let c=l.depth===0?n.doc.inlineContent&&n.doc.type.allowsMarkType(t):!1;return n.doc.nodesBetween(l.pos,a.pos,(d,u,f)=>{if(c)return!1;if(d.isInline){let h=!f||f.type.allowsMarkType(t),p=!!t.isInSet(d.marks)||!d.marks.some(m=>m.type.excludes(t));c=h&&p}return!c}),c})}var bm=(n,e={})=>({tr:t,state:r,dispatch:o})=>{let{selection:i}=t,{empty:s,ranges:l}=i,a=pt(n,r.schema);if(o)if(s){let c=ld(r,a);t.addStoredMark(a.create(b(b({},c),e)))}else l.forEach(c=>{let d=c.$from.pos,u=c.$to.pos;r.doc.nodesBetween(d,u,(f,h)=>{let p=Math.max(h,d),m=Math.min(h+f.nodeSize,u);f.marks.find(y=>y.type===a)?f.marks.forEach(y=>{a===y.type&&t.addMark(p,m,a.create(b(b({},y.attrs),e)))}):t.addMark(p,m,a.create(e))})});return ym(r,t,a)},xm=(n,e)=>({tr:t})=>(t.setMeta(n,e),!0),km=(n,e={})=>({state:t,dispatch:r,chain:o})=>{let i=re(n,t.schema),s;return t.selection.$anchor.sameParent(t.selection.$head)&&(s=t.selection.$anchor.parent.attrs),i.isTextblock?o().command(({commands:l})=>Hr(i,b(b({},s),e))(t)?!0:l.clearNodes()).command(({state:l})=>Hr(i,b(b({},s),e))(l,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},Sm=n=>({tr:e,dispatch:t})=>{if(t){let{doc:r}=e,o=Qe(n,0,r.content.size),i=O.create(r,o);e.setSelection(i)}return!0},wm=n=>({tr:e,dispatch:t})=>{if(t){let{doc:r}=e,{from:o,to:i}=typeof n=="number"?{from:n,to:n}:n,s=T.atStart(r).from,l=T.atEnd(r).to,a=Qe(o,s,l),c=Qe(i,s,l),d=T.create(r,a,c);e.setSelection(d)}return!0},Cm=n=>({state:e,dispatch:t})=>{let r=re(n,e.schema);return $c(r)(e,t)};function Uc(n,e){let t=n.storedMarks||n.selection.$to.parentOffset&&n.selection.$from.marks();if(t){let r=t.filter(o=>e==null?void 0:e.includes(o.type.name));n.tr.ensureMarks(r)}}var Mm=({keepMarks:n=!0}={})=>({tr:e,state:t,dispatch:r,editor:o})=>{let{selection:i,doc:s}=e,{$from:l,$to:a}=i,c=o.extensionManager.attributes,d=Kr(c,l.node().type.name,l.node().attrs);if(i instanceof O&&i.node.isBlock)return!l.parentOffset||!ke(s,l.pos)?!1:(r&&(n&&Uc(t,o.extensionManager.splittableMarks),e.split(l.pos).scrollIntoView()),!0);if(!l.parent.isBlock)return!1;let u=a.parentOffset===a.parent.content.size,f=l.depth===0?void 0:um(l.node(-1).contentMatchAt(l.indexAfter(-1))),h=u&&f?[{type:f,attrs:d}]:void 0,p=ke(e.doc,e.mapping.map(l.pos),1,h);if(!h&&!p&&ke(e.doc,e.mapping.map(l.pos),1,f?[{type:f}]:void 0)&&(p=!0,h=f?[{type:f,attrs:d}]:void 0),r){if(p&&(i instanceof T&&e.deleteSelection(),e.split(e.mapping.map(l.pos),1,h),f&&!u&&!l.parentOffset&&l.parent.type!==f)){let m=e.mapping.map(l.before()),g=e.doc.resolve(m);l.node(-1).canReplaceWith(g.index(),g.index()+1,f)&&e.setNodeMarkup(e.mapping.map(l.before()),f)}n&&Uc(t,o.extensionManager.splittableMarks),e.scrollIntoView()}return p},Am=(n,e={})=>({tr:t,state:r,dispatch:o,editor:i})=>{var s;let l=re(n,r.schema),{$from:a,$to:c}=r.selection,d=r.selection.node;if(d&&d.isBlock||a.depth<2||!a.sameParent(c))return!1;let u=a.node(-1);if(u.type!==l)return!1;let f=i.extensionManager.attributes;if(a.parent.content.size===0&&a.node(-1).childCount===a.indexAfter(-1)){if(a.depth===2||a.node(-3).type!==l||a.index(-2)!==a.node(-2).childCount-1)return!1;if(o){let y=x.empty,S=a.index(-1)?1:a.index(-2)?2:3;for(let Q=a.depth-S;Q>=a.depth-3;Q-=1)y=x.from(a.node(Q).copy(y));let A=a.indexAfter(-1){if(_>-1)return!1;Q.isTextblock&&Q.content.size===0&&(_=z+1)}),_>-1&&t.setSelection(T.near(t.doc.resolve(_))),t.scrollIntoView()}return!0}let h=c.pos===a.end()?u.contentMatchAt(0).defaultType:null,p=b(b({},Kr(f,u.type.name,u.attrs)),e),m=b(b({},Kr(f,a.node().type.name,a.node().attrs)),e);t.delete(a.pos,c.pos);let g=h?[{type:l,attrs:p},{type:h,attrs:m}]:[{type:l,attrs:p}];if(!ke(t.doc,a.pos,2))return!1;if(o){let{selection:y,storedMarks:S}=r,{splittableMarks:A}=i.extensionManager,I=S||y.$to.parentOffset&&y.$from.marks();if(t.split(a.pos,2,g).scrollIntoView(),!I||!o)return!0;let M=I.filter(R=>A.includes(R.type.name));t.ensureMarks(M)}return!0},ps=(n,e)=>{let t=no(s=>s.type===e)(n.selection);if(!t)return!0;let r=n.doc.resolve(Math.max(0,t.pos-1)).before(t.depth);if(r===void 0)return!0;let o=n.doc.nodeAt(r);return t.node.type===(o==null?void 0:o.type)&&Se(n.doc,t.pos)&&n.join(t.pos),!0},ms=(n,e)=>{let t=no(s=>s.type===e)(n.selection);if(!t)return!0;let r=n.doc.resolve(t.start).after(t.depth);if(r===void 0)return!0;let o=n.doc.nodeAt(r);return t.node.type===(o==null?void 0:o.type)&&Se(n.doc,r)&&n.join(r),!0},Tm=(n,e,t,r={})=>({editor:o,tr:i,state:s,dispatch:l,chain:a,commands:c,can:d})=>{let{extensions:u,splittableMarks:f}=o.extensionManager,h=re(n,s.schema),p=re(e,s.schema),{selection:m,storedMarks:g}=s,{$from:y,$to:S}=m,A=y.blockRange(S),I=g||m.$to.parentOffset&&m.$from.marks();if(!A)return!1;let M=no(R=>Jc(R.type.name,u))(m);if(A.depth>=1&&M&&A.depth-M.depth<=1){if(M.node.type===h)return c.liftListItem(p);if(Jc(M.node.type.name,u)&&h.validContent(M.node.content)&&l)return a().command(()=>(i.setNodeMarkup(M.pos,h),!0)).command(()=>ps(i,h)).command(()=>ms(i,h)).run()}return!t||!I||!l?a().command(()=>d().wrapInList(h,r)?!0:c.clearNodes()).wrapInList(h,r).command(()=>ps(i,h)).command(()=>ms(i,h)).run():a().command(()=>{let R=d().wrapInList(h,r),_=I.filter(Q=>f.includes(Q.type.name));return i.ensureMarks(_),R?!0:c.clearNodes()}).wrapInList(h,r).command(()=>ps(i,h)).command(()=>ms(i,h)).run()},Em=(n,e={},t={})=>({state:r,commands:o})=>{let{extendEmptyMarkRange:i=!1}=t,s=pt(n,r.schema);return xs(r,s,e)?o.unsetMark(s,{extendEmptyMarkRange:i}):o.setMark(s,e)},Om=(n,e,t={})=>({state:r,commands:o})=>{let i=re(n,r.schema),s=re(e,r.schema),l=_n(r,i,t),a;return r.selection.$anchor.sameParent(r.selection.$head)&&(a=r.selection.$anchor.parent.attrs),l?o.setNode(s,a):o.setNode(i,b(b({},a),t))},vm=(n,e={})=>({state:t,commands:r})=>{let o=re(n,t.schema);return _n(t,o,e)?r.lift(o):r.wrapIn(o,e)},Nm=()=>({state:n,dispatch:e})=>{let t=n.plugins;for(let r=0;r=0;a-=1)s.step(l.steps[a].invert(l.docs[a]));if(i.text){let a=s.doc.resolve(i.from).marks();s.replaceWith(i.from,i.to,n.schema.text(i.text,a))}else s.delete(i.from,i.to)}return!0}}return!1},Rm=()=>({tr:n,dispatch:e})=>{let{selection:t}=n,{empty:r,ranges:o}=t;return r||e&&o.forEach(i=>{n.removeMark(i.$from.pos,i.$to.pos)}),!0},Dm=(n,e={})=>({tr:t,state:r,dispatch:o})=>{var i;let{extendEmptyMarkRange:s=!1}=e,{selection:l}=t,a=pt(n,r.schema),{$from:c,empty:d,ranges:u}=l;if(!o)return!0;if(d&&s){let{from:f,to:h}=l,p=(i=c.marks().find(g=>g.type===a))===null||i===void 0?void 0:i.attrs,m=Cs(c,a,p);m&&(f=m.from,h=m.to),t.removeMark(f,h,a)}else u.forEach(f=>{t.removeMark(f.$from.pos,f.$to.pos,a)});return t.removeStoredMark(a),!0},Im=(n,e={})=>({tr:t,state:r,dispatch:o})=>{let i=null,s=null,l=to(typeof n=="string"?n:n.name,r.schema);return l?(l==="node"&&(i=re(n,r.schema)),l==="mark"&&(s=pt(n,r.schema)),o&&t.selection.ranges.forEach(a=>{let c=a.$from.pos,d=a.$to.pos,u,f,h,p;t.selection.empty?r.doc.nodesBetween(c,d,(m,g)=>{i&&i===m.type&&(h=Math.max(g,c),p=Math.min(g+m.nodeSize,d),u=g,f=m)}):r.doc.nodesBetween(c,d,(m,g)=>{g=c&&g<=d&&(i&&i===m.type&&t.setNodeMarkup(g,void 0,b(b({},m.attrs),e)),s&&m.marks.length&&m.marks.forEach(y=>{if(s===y.type){let S=Math.max(g,c),A=Math.min(g+m.nodeSize,d);t.addMark(S,A,s.create(b(b({},y.attrs),e)))}}))}),f&&(u!==void 0&&t.setNodeMarkup(u,void 0,b(b({},f.attrs),e)),s&&f.marks.length&&f.marks.forEach(m=>{s===m.type&&t.addMark(h,p,s.create(b(b({},m.attrs),e)))}))}),!0):!1},Pm=(n,e={})=>({state:t,dispatch:r})=>{let o=re(n,t.schema);return us(o,e)(t,r)},Lm=(n,e={})=>({state:t,dispatch:r})=>{let o=re(n,t.schema);return Fc(o,e)(t,r)},Bm=Object.freeze({__proto__:null,blur:wp,clearContent:Cp,clearNodes:Mp,command:Ap,createParagraphNear:Tp,cut:Ep,deleteCurrentNode:Op,deleteNode:vp,deleteRange:Np,deleteSelection:Rp,enter:Dp,exitCode:Ip,extendMarkRange:Pp,first:Lp,focus:Bp,forEach:zp,insertContent:Fp,insertContentAt:_p,joinBackward:Wp,joinDown:jp,joinForward:Kp,joinItemBackward:Jp,joinItemForward:Up,joinTextblockBackward:qp,joinTextblockForward:Gp,joinUp:Vp,keyboardShortcut:Qp,lift:Xp,liftEmptyBlock:Zp,liftListItem:em,newlineInCode:tm,resetAttributes:nm,scrollIntoView:rm,selectAll:om,selectNodeBackward:im,selectNodeForward:sm,selectParentNode:lm,selectTextblockEnd:am,selectTextblockStart:cm,setContent:dm,setMark:bm,setMeta:xm,setNode:km,setNodeSelection:Sm,setTextSelection:wm,sinkListItem:Cm,splitBlock:Mm,splitListItem:Am,toggleList:Tm,toggleMark:Em,toggleNode:Om,toggleWrap:vm,undoInputRule:Nm,unsetAllMarks:Rm,unsetMark:Dm,updateAttributes:Im,wrapIn:Pm,wrapInList:Lm}),pd=H.create({name:"commands",addCommands(){return b({},Bm)}}),md=H.create({name:"drop",addProseMirrorPlugins(){return[new L({key:new j("tiptapDrop"),props:{handleDrop:(n,e,t,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:t,moved:r})}}})]}}),gd=H.create({name:"editable",addProseMirrorPlugins(){return[new L({key:new j("editable"),props:{editable:()=>this.editor.options.editable}})]}}),yd=H.create({name:"focusEvents",addProseMirrorPlugins(){let{editor:n}=this;return[new L({key:new j("focusEvents"),props:{handleDOMEvents:{focus:(e,t)=>{n.isFocused=!0;let r=n.state.tr.setMeta("focus",{event:t}).setMeta("addToHistory",!1);return e.dispatch(r),!1},blur:(e,t)=>{n.isFocused=!1;let r=n.state.tr.setMeta("blur",{event:t}).setMeta("addToHistory",!1);return e.dispatch(r),!1}}}})]}}),bd=H.create({name:"keymap",addKeyboardShortcuts(){let n=()=>this.editor.commands.first(({commands:s})=>[()=>s.undoInputRule(),()=>s.command(({tr:l})=>{let{selection:a,doc:c}=l,{empty:d,$anchor:u}=a,{pos:f,parent:h}=u,p=u.parent.isTextblock&&f>0?l.doc.resolve(f-1):u,m=p.parent.type.spec.isolating,g=u.pos-u.parentOffset,y=m&&p.parent.childCount===1?g===u.pos:E.atStart(c).from===f;return!d||!h.type.isTextblock||h.textContent.length||!y||y&&u.parent.type.name==="paragraph"?!1:s.clearNodes()}),()=>s.deleteSelection(),()=>s.joinBackward(),()=>s.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:s})=>[()=>s.deleteSelection(),()=>s.deleteCurrentNode(),()=>s.joinForward(),()=>s.selectNodeForward()]),r={Enter:()=>this.editor.commands.first(({commands:s})=>[()=>s.newlineInCode(),()=>s.createParagraphNear(),()=>s.liftEmptyBlock(),()=>s.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:n,"Mod-Backspace":n,"Shift-Backspace":n,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},o=b({},r),i=N(b({},r),{"Ctrl-h":n,"Alt-Backspace":n,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()});return eo()||sd()?i:o},addProseMirrorPlugins(){return[new L({key:new j("clearDocument"),appendTransaction:(n,e,t)=>{if(n.some(m=>m.getMeta("composition")))return;let r=n.some(m=>m.docChanged)&&!e.doc.eq(t.doc),o=n.some(m=>m.getMeta("preventClearDocument"));if(!r||o)return;let{empty:i,from:s,to:l}=e.selection,a=E.atStart(e.doc).from,c=E.atEnd(e.doc).to;if(i||!(s===a&&l===c)||!Es(t.doc))return;let f=t.tr,h=Yr({state:t,transaction:f}),{commands:p}=new an({editor:this.editor,state:h});if(p.clearNodes(),!!f.steps.length)return f}})]}}),xd=H.create({name:"paste",addProseMirrorPlugins(){return[new L({key:new j("tiptapPaste"),props:{handlePaste:(n,e,t)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:t})}}})]}}),kd=H.create({name:"tabindex",addProseMirrorPlugins(){return[new L({key:new j("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}}),zb=Object.freeze({__proto__:null,ClipboardTextSerializer:ed,Commands:pd,Drop:md,Editable:gd,FocusEvents:yd,Keymap:bd,Paste:xd,Tabindex:kd}),ks=class n{get name(){return this.node.type.name}constructor(e,t,r=!1,o=null){this.currentNode=null,this.actualDepth=null,this.isBlock=r,this.resolvedPos=e,this.editor=t,this.currentNode=o}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var e;return(e=this.actualDepth)!==null&&e!==void 0?e:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(e){let t=this.from,r=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You can\u2019t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}t=this.from+1,r=this.to-1}this.editor.commands.insertContentAt({from:t,to:r},e)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+(this.node.isText?0:1)}get parent(){if(this.depth===0)return null;let e=this.resolvedPos.start(this.resolvedPos.depth-1),t=this.resolvedPos.doc.resolve(e);return new n(t,this.editor)}get before(){let e=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.from-3)),new n(e,this.editor)}get after(){let e=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.to+3)),new n(e,this.editor)}get children(){let e=[];return this.node.content.forEach((t,r)=>{let o=t.isBlock&&!t.isTextblock,i=t.isAtom&&!t.isText,s=this.pos+r+(i?0:1),l=this.resolvedPos.doc.resolve(s);if(!o&&l.depth<=this.depth)return;let a=new n(l,this.editor,o,o?t:null);o&&(a.actualDepth=this.depth+1),e.push(new n(l,this.editor,o,o?t:null))}),e}get firstChild(){return this.children[0]||null}get lastChild(){let e=this.children;return e[e.length-1]||null}closest(e,t={}){let r=null,o=this.parent;for(;o&&!r;){if(o.node.type.name===e)if(Object.keys(t).length>0){let i=o.node.attrs,s=Object.keys(t);for(let l=0;l{r&&o.length>0||(s.node.type.name===e&&i.every(a=>t[a]===s.node.attrs[a])&&o.push(s),!(r&&o.length>0)&&(o=o.concat(s.querySelectorAll(e,t,r))))}),o}setAttribute(e){let{tr:t}=this.editor.state;t.setNodeMarkup(this.from,void 0,b(b({},this.node.attrs),e)),this.editor.view.dispatch(t)}},zm=`.ProseMirror { +`,textSerializers:o={}}=t||{},i=Ts(e),s=pe.fromJSON(i,n);return ud(s,{blockSeparator:r,textSerializers:b(b({},Ss(i)),o)})}function pm(n,e){let t=re(e,n.schema),{from:r,to:o}=n.selection,i=[];n.doc.nodesBetween(r,o,l=>{i.push(l)});let s=i.reverse().find(l=>l.type.name===t.name);return s?b({},s.attrs):{}}function As(n,e){let t=to(typeof e=="string"?e:e.name,n.schema);return t==="node"?pm(n,e):t==="mark"?ad(n,e):{}}function hm(n,e=JSON.stringify){let t={};return n.filter(r=>{let o=e(r);return Object.prototype.hasOwnProperty.call(t,o)?!1:t[o]=!0})}function mm(n){let e=hm(n);return e.length===1?e:e.filter((t,r)=>!e.filter((i,s)=>s!==r).some(i=>t.oldRange.from>=i.oldRange.from&&t.oldRange.to<=i.oldRange.to&&t.newRange.from>=i.newRange.from&&t.newRange.to<=i.newRange.to))}function fd(n){let{mapping:e,steps:t}=n,r=[];return e.maps.forEach((o,i)=>{let s=[];if(o.ranges.length)o.forEach((l,a)=>{s.push({from:l,to:a})});else{let{from:l,to:a}=t[i];if(l===void 0||a===void 0)return;s.push({from:l,to:a})}s.forEach(({from:l,to:a})=>{let c=e.slice(i).map(l,-1),d=e.slice(i).map(a),u=e.invert().map(c,-1),f=e.invert().map(d);r.push({oldRange:{from:u,to:f},newRange:{from:c,to:d}})})}),mm(r)}function gm(n,e=0){let r=n.type===n.type.schema.topNodeType?0:1,o=e,i=o+n.nodeSize,s=n.marks.map(c=>{let d={type:c.type.name};return Object.keys(c.attrs).length&&(d.attrs=b({},c.attrs)),d}),l=b({},n.attrs),a={type:n.type.name,from:o,to:i};return Object.keys(l).length&&(a.attrs=l),s.length&&(a.marks=s),n.content.childCount&&(a.content=[],n.forEach((c,d)=>{var u;(u=a.content)===null||u===void 0||u.push(gm(c,e+d+r))})),n.text&&(a.text=n.text),a}function ro(n,e,t){let r=[];return n===e?t.resolve(n).marks().forEach(o=>{let i=t.resolve(n),s=Cs(i,o.type);s&&r.push(b({mark:o},s))}):t.nodesBetween(n,e,(o,i)=>{!o||(o==null?void 0:o.nodeSize)===void 0||r.push(...o.marks.map(s=>({from:i,to:i+o.nodeSize,mark:s})))}),r}var Ib=(n,e,t,r=20)=>{let o=n.doc.resolve(t),i=r,s=null;for(;i>0&&s===null;){let l=o.node(i);(l==null?void 0:l.type.name)===e?s=l:i-=1}return[s,i]};function Kr(n,e,t){return Object.fromEntries(Object.entries(t).filter(([r])=>{let o=n.find(i=>i.type===e&&i.name===r);return o?o.attribute.keepOnSplit:!1}))}function xs(n,e,t={}){let{empty:r,ranges:o}=n.selection,i=e?ht(e,n.schema):null;if(r)return!!(n.storedMarks||n.selection.$from.marks()).filter(u=>i?i.name===u.type.name:!0).find(u=>Ur(u.attrs,t,{strict:!1}));let s=0,l=[];if(o.forEach(({$from:u,$to:f})=>{let p=u.pos,h=f.pos;n.doc.nodesBetween(p,h,(m,g)=>{if(!m.isText&&!m.marks.length)return;let y=Math.max(p,g),w=Math.min(h,g+m.nodeSize),T=w-y;s+=T,l.push(...m.marks.map(I=>({mark:I,from:y,to:w})))})}),s===0)return!1;let a=l.filter(u=>i?i.name===u.mark.type.name:!0).filter(u=>Ur(u.mark.attrs,t,{strict:!1})).reduce((u,f)=>u+f.to-f.from,0),c=l.filter(u=>i?u.mark.type!==i&&u.mark.type.excludes(i):!0).reduce((u,f)=>u+f.to-f.from,0);return(a>0?a+c:a)>=s}function ym(n,e,t={}){if(!e)return _n(n,null,t)||xs(n,null,t);let r=to(e,n.schema);return r==="node"?_n(n,e,t):r==="mark"?xs(n,e,t):!1}var Pb=(n,e)=>{let{$from:t,$to:r,$anchor:o}=n.selection;if(e){let i=no(l=>l.type.name===e)(n.selection);if(!i)return!1;let s=n.doc.resolve(i.pos+1);return o.pos+1===s.end()}return!(r.parentOffset{let{$from:e,$to:t}=n.selection;return!(e.parentOffset>0||e.pos!==t.pos)};function Uc(n,e){let{nodeExtensions:t}=Qr(e),r=t.find(s=>s.name===n);if(!r)return!1;let o={name:r.name,options:r.options,storage:r.storage},i=D(C(r,"group",o));return typeof i!="string"?!1:i.split(" ").includes("list")}function Es(n,{checkChildren:e=!0,ignoreWhitespace:t=!1}={}){var r;if(t){if(n.type.name==="hardBreak")return!0;if(n.isText)return/^\s*$/m.test((r=n.text)!==null&&r!==void 0?r:"")}if(n.isText)return!n.text;if(n.isAtom||n.isLeaf)return!1;if(n.content.childCount===0)return!0;if(e){let o=!0;return n.content.forEach(i=>{o!==!1&&(Es(i,{ignoreWhitespace:t,checkChildren:e})||(o=!1))}),o}return!1}function pd(n){return n instanceof v}function zb(n,e,t){let o=n.state.doc.content.size,i=Qe(e,0,o),s=Qe(t,0,o),l=n.coordsAtPos(i),a=n.coordsAtPos(s,-1),c=Math.min(l.top,a.top),d=Math.max(l.bottom,a.bottom),u=Math.min(l.left,a.left),f=Math.max(l.right,a.right),p=f-u,h=d-c,y={top:c,bottom:d,left:u,right:f,width:p,height:h,x:u,y:c};return N(b({},y),{toJSON:()=>y})}function hd({json:n,validMarks:e,validNodes:t,options:r,rewrittenContent:o=[]}){return n.marks&&Array.isArray(n.marks)&&(n.marks=n.marks.filter(i=>{let s=typeof i=="string"?i:i.type;return e.has(s)?!0:(o.push({original:JSON.parse(JSON.stringify(i)),unsupported:s}),!1)})),n.content&&Array.isArray(n.content)&&(n.content=n.content.map(i=>hd({json:i,validMarks:e,validNodes:t,options:r,rewrittenContent:o}).json).filter(i=>i!=null)),n.type&&!t.has(n.type)?(o.push({original:JSON.parse(JSON.stringify(n)),unsupported:n.type}),n.content&&Array.isArray(n.content)&&(r==null?void 0:r.fallbackToParagraph)!==!1?(n.type="paragraph",{json:n,rewrittenContent:o}):{json:null,rewrittenContent:o}):{json:n,rewrittenContent:o}}function Bb(n,e,t){return hd({json:n,validNodes:new Set(Object.keys(e.nodes)),validMarks:new Set(Object.keys(e.marks)),options:t})}function bm(n,e,t){var r;let{selection:o}=e,i=null;if(rd(o)&&(i=o.$cursor),i){let l=(r=n.storedMarks)!==null&&r!==void 0?r:i.marks();return!!t.isInSet(l)||!l.some(a=>a.type.excludes(t))}let{ranges:s}=o;return s.some(({$from:l,$to:a})=>{let c=l.depth===0?n.doc.inlineContent&&n.doc.type.allowsMarkType(t):!1;return n.doc.nodesBetween(l.pos,a.pos,(d,u,f)=>{if(c)return!1;if(d.isInline){let p=!f||f.type.allowsMarkType(t),h=!!t.isInSet(d.marks)||!d.marks.some(m=>m.type.excludes(t));c=p&&h}return!c}),c})}var xm=(n,e={})=>({tr:t,state:r,dispatch:o})=>{let{selection:i}=t,{empty:s,ranges:l}=i,a=ht(n,r.schema);if(o)if(s){let c=ad(r,a);t.addStoredMark(a.create(b(b({},c),e)))}else l.forEach(c=>{let d=c.$from.pos,u=c.$to.pos;r.doc.nodesBetween(d,u,(f,p)=>{let h=Math.max(p,d),m=Math.min(p+f.nodeSize,u);f.marks.find(y=>y.type===a)?f.marks.forEach(y=>{a===y.type&&t.addMark(h,m,a.create(b(b({},y.attrs),e)))}):t.addMark(h,m,a.create(e))})});return bm(r,t,a)},km=(n,e)=>({tr:t})=>(t.setMeta(n,e),!0),wm=(n,e={})=>({state:t,dispatch:r,chain:o})=>{let i=re(n,t.schema),s;return t.selection.$anchor.sameParent(t.selection.$head)&&(s=t.selection.$anchor.parent.attrs),i.isTextblock?o().command(({commands:l})=>Hr(i,b(b({},s),e))(t)?!0:l.clearNodes()).command(({state:l})=>Hr(i,b(b({},s),e))(l,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},Sm=n=>({tr:e,dispatch:t})=>{if(t){let{doc:r}=e,o=Qe(n,0,r.content.size),i=v.create(r,o);e.setSelection(i)}return!0},Cm=n=>({tr:e,dispatch:t})=>{if(t){let{doc:r}=e,{from:o,to:i}=typeof n=="number"?{from:n,to:n}:n,s=A.atStart(r).from,l=A.atEnd(r).to,a=Qe(o,s,l),c=Qe(i,s,l),d=A.create(r,a,c);e.setSelection(d)}return!0},Mm=n=>({state:e,dispatch:t})=>{let r=re(n,e.schema);return _c(r)(e,t)};function qc(n,e){let t=n.storedMarks||n.selection.$to.parentOffset&&n.selection.$from.marks();if(t){let r=t.filter(o=>e==null?void 0:e.includes(o.type.name));n.tr.ensureMarks(r)}}var Tm=({keepMarks:n=!0}={})=>({tr:e,state:t,dispatch:r,editor:o})=>{let{selection:i,doc:s}=e,{$from:l,$to:a}=i,c=o.extensionManager.attributes,d=Kr(c,l.node().type.name,l.node().attrs);if(i instanceof v&&i.node.isBlock)return!l.parentOffset||!ke(s,l.pos)?!1:(r&&(n&&qc(t,o.extensionManager.splittableMarks),e.split(l.pos).scrollIntoView()),!0);if(!l.parent.isBlock)return!1;let u=a.parentOffset===a.parent.content.size,f=l.depth===0?void 0:fm(l.node(-1).contentMatchAt(l.indexAfter(-1))),p=u&&f?[{type:f,attrs:d}]:void 0,h=ke(e.doc,e.mapping.map(l.pos),1,p);if(!p&&!h&&ke(e.doc,e.mapping.map(l.pos),1,f?[{type:f}]:void 0)&&(h=!0,p=f?[{type:f,attrs:d}]:void 0),r){if(h&&(i instanceof A&&e.deleteSelection(),e.split(e.mapping.map(l.pos),1,p),f&&!u&&!l.parentOffset&&l.parent.type!==f)){let m=e.mapping.map(l.before()),g=e.doc.resolve(m);l.node(-1).canReplaceWith(g.index(),g.index()+1,f)&&e.setNodeMarkup(e.mapping.map(l.before()),f)}n&&qc(t,o.extensionManager.splittableMarks),e.scrollIntoView()}return h},Am=(n,e={})=>({tr:t,state:r,dispatch:o,editor:i})=>{var s;let l=re(n,r.schema),{$from:a,$to:c}=r.selection,d=r.selection.node;if(d&&d.isBlock||a.depth<2||!a.sameParent(c))return!1;let u=a.node(-1);if(u.type!==l)return!1;let f=i.extensionManager.attributes;if(a.parent.content.size===0&&a.node(-1).childCount===a.indexAfter(-1)){if(a.depth===2||a.node(-3).type!==l||a.index(-2)!==a.node(-2).childCount-1)return!1;if(o){let y=x.empty,w=a.index(-1)?1:a.index(-2)?2:3;for(let Q=a.depth-w;Q>=a.depth-3;Q-=1)y=x.from(a.node(Q).copy(y));let T=a.indexAfter(-1){if(_>-1)return!1;Q.isTextblock&&Q.content.size===0&&(_=B+1)}),_>-1&&t.setSelection(A.near(t.doc.resolve(_))),t.scrollIntoView()}return!0}let p=c.pos===a.end()?u.contentMatchAt(0).defaultType:null,h=b(b({},Kr(f,u.type.name,u.attrs)),e),m=b(b({},Kr(f,a.node().type.name,a.node().attrs)),e);t.delete(a.pos,c.pos);let g=p?[{type:l,attrs:h},{type:p,attrs:m}]:[{type:l,attrs:h}];if(!ke(t.doc,a.pos,2))return!1;if(o){let{selection:y,storedMarks:w}=r,{splittableMarks:T}=i.extensionManager,I=w||y.$to.parentOffset&&y.$from.marks();if(t.split(a.pos,2,g).scrollIntoView(),!I||!o)return!0;let M=I.filter(R=>T.includes(R.type.name));t.ensureMarks(M)}return!0},hs=(n,e)=>{let t=no(s=>s.type===e)(n.selection);if(!t)return!0;let r=n.doc.resolve(Math.max(0,t.pos-1)).before(t.depth);if(r===void 0)return!0;let o=n.doc.nodeAt(r);return t.node.type===(o==null?void 0:o.type)&&we(n.doc,t.pos)&&n.join(t.pos),!0},ms=(n,e)=>{let t=no(s=>s.type===e)(n.selection);if(!t)return!0;let r=n.doc.resolve(t.start).after(t.depth);if(r===void 0)return!0;let o=n.doc.nodeAt(r);return t.node.type===(o==null?void 0:o.type)&&we(n.doc,r)&&n.join(r),!0},Em=(n,e,t,r={})=>({editor:o,tr:i,state:s,dispatch:l,chain:a,commands:c,can:d})=>{let{extensions:u,splittableMarks:f}=o.extensionManager,p=re(n,s.schema),h=re(e,s.schema),{selection:m,storedMarks:g}=s,{$from:y,$to:w}=m,T=y.blockRange(w),I=g||m.$to.parentOffset&&m.$from.marks();if(!T)return!1;let M=no(R=>Uc(R.type.name,u))(m);if(T.depth>=1&&M&&T.depth-M.depth<=1){if(M.node.type===p)return c.liftListItem(h);if(Uc(M.node.type.name,u)&&p.validContent(M.node.content)&&l)return a().command(()=>(i.setNodeMarkup(M.pos,p),!0)).command(()=>hs(i,p)).command(()=>ms(i,p)).run()}return!t||!I||!l?a().command(()=>d().wrapInList(p,r)?!0:c.clearNodes()).wrapInList(p,r).command(()=>hs(i,p)).command(()=>ms(i,p)).run():a().command(()=>{let R=d().wrapInList(p,r),_=I.filter(Q=>f.includes(Q.type.name));return i.ensureMarks(_),R?!0:c.clearNodes()}).wrapInList(p,r).command(()=>hs(i,p)).command(()=>ms(i,p)).run()},vm=(n,e={},t={})=>({state:r,commands:o})=>{let{extendEmptyMarkRange:i=!1}=t,s=ht(n,r.schema);return xs(r,s,e)?o.unsetMark(s,{extendEmptyMarkRange:i}):o.setMark(s,e)},Om=(n,e,t={})=>({state:r,commands:o})=>{let i=re(n,r.schema),s=re(e,r.schema),l=_n(r,i,t),a;return r.selection.$anchor.sameParent(r.selection.$head)&&(a=r.selection.$anchor.parent.attrs),l?o.setNode(s,a):o.setNode(i,b(b({},a),t))},Nm=(n,e={})=>({state:t,commands:r})=>{let o=re(n,t.schema);return _n(t,o,e)?r.lift(o):r.wrapIn(o,e)},Rm=()=>({state:n,dispatch:e})=>{let t=n.plugins;for(let r=0;r=0;a-=1)s.step(l.steps[a].invert(l.docs[a]));if(i.text){let a=s.doc.resolve(i.from).marks();s.replaceWith(i.from,i.to,n.schema.text(i.text,a))}else s.delete(i.from,i.to)}return!0}}return!1},Dm=()=>({tr:n,dispatch:e})=>{let{selection:t}=n,{empty:r,ranges:o}=t;return r||e&&o.forEach(i=>{n.removeMark(i.$from.pos,i.$to.pos)}),!0},Im=(n,e={})=>({tr:t,state:r,dispatch:o})=>{var i;let{extendEmptyMarkRange:s=!1}=e,{selection:l}=t,a=ht(n,r.schema),{$from:c,empty:d,ranges:u}=l;if(!o)return!0;if(d&&s){let{from:f,to:p}=l,h=(i=c.marks().find(g=>g.type===a))===null||i===void 0?void 0:i.attrs,m=Cs(c,a,h);m&&(f=m.from,p=m.to),t.removeMark(f,p,a)}else u.forEach(f=>{t.removeMark(f.$from.pos,f.$to.pos,a)});return t.removeStoredMark(a),!0},Pm=(n,e={})=>({tr:t,state:r,dispatch:o})=>{let i=null,s=null,l=to(typeof n=="string"?n:n.name,r.schema);return l?(l==="node"&&(i=re(n,r.schema)),l==="mark"&&(s=ht(n,r.schema)),o&&t.selection.ranges.forEach(a=>{let c=a.$from.pos,d=a.$to.pos,u,f,p,h;t.selection.empty?r.doc.nodesBetween(c,d,(m,g)=>{i&&i===m.type&&(p=Math.max(g,c),h=Math.min(g+m.nodeSize,d),u=g,f=m)}):r.doc.nodesBetween(c,d,(m,g)=>{g=c&&g<=d&&(i&&i===m.type&&t.setNodeMarkup(g,void 0,b(b({},m.attrs),e)),s&&m.marks.length&&m.marks.forEach(y=>{if(s===y.type){let w=Math.max(g,c),T=Math.min(g+m.nodeSize,d);t.addMark(w,T,s.create(b(b({},y.attrs),e)))}}))}),f&&(u!==void 0&&t.setNodeMarkup(u,void 0,b(b({},f.attrs),e)),s&&f.marks.length&&f.marks.forEach(m=>{s===m.type&&t.addMark(p,h,s.create(b(b({},m.attrs),e)))}))}),!0):!1},Lm=(n,e={})=>({state:t,dispatch:r})=>{let o=re(n,t.schema);return us(o,e)(t,r)},zm=(n,e={})=>({state:t,dispatch:r})=>{let o=re(n,t.schema);return Hc(o,e)(t,r)},Bm=Object.freeze({__proto__:null,blur:Ch,clearContent:Mh,clearNodes:Th,command:Ah,createParagraphNear:Eh,cut:vh,deleteCurrentNode:Oh,deleteNode:Nh,deleteRange:Rh,deleteSelection:Dh,enter:Ih,exitCode:Ph,extendMarkRange:Lh,first:zh,focus:Bh,forEach:Fh,insertContent:Hh,insertContentAt:Vh,joinBackward:Kh,joinDown:Wh,joinForward:Jh,joinItemBackward:Uh,joinItemForward:qh,joinTextblockBackward:Gh,joinTextblockForward:Yh,joinUp:jh,keyboardShortcut:Xh,lift:Zh,liftEmptyBlock:em,liftListItem:tm,newlineInCode:nm,resetAttributes:rm,scrollIntoView:om,selectAll:im,selectNodeBackward:sm,selectNodeForward:lm,selectParentNode:am,selectTextblockEnd:cm,selectTextblockStart:dm,setContent:um,setMark:xm,setMeta:km,setNode:wm,setNodeSelection:Sm,setTextSelection:Cm,sinkListItem:Mm,splitBlock:Tm,splitListItem:Am,toggleList:Em,toggleMark:vm,toggleNode:Om,toggleWrap:Nm,undoInputRule:Rm,unsetAllMarks:Dm,unsetMark:Im,updateAttributes:Pm,wrapIn:Lm,wrapInList:zm}),md=H.create({name:"commands",addCommands(){return b({},Bm)}}),gd=H.create({name:"drop",addProseMirrorPlugins(){return[new L({key:new j("tiptapDrop"),props:{handleDrop:(n,e,t,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:t,moved:r})}}})]}}),yd=H.create({name:"editable",addProseMirrorPlugins(){return[new L({key:new j("editable"),props:{editable:()=>this.editor.options.editable}})]}}),bd=H.create({name:"focusEvents",addProseMirrorPlugins(){let{editor:n}=this;return[new L({key:new j("focusEvents"),props:{handleDOMEvents:{focus:(e,t)=>{n.isFocused=!0;let r=n.state.tr.setMeta("focus",{event:t}).setMeta("addToHistory",!1);return e.dispatch(r),!1},blur:(e,t)=>{n.isFocused=!1;let r=n.state.tr.setMeta("blur",{event:t}).setMeta("addToHistory",!1);return e.dispatch(r),!1}}}})]}}),xd=H.create({name:"keymap",addKeyboardShortcuts(){let n=()=>this.editor.commands.first(({commands:s})=>[()=>s.undoInputRule(),()=>s.command(({tr:l})=>{let{selection:a,doc:c}=l,{empty:d,$anchor:u}=a,{pos:f,parent:p}=u,h=u.parent.isTextblock&&f>0?l.doc.resolve(f-1):u,m=h.parent.type.spec.isolating,g=u.pos-u.parentOffset,y=m&&h.parent.childCount===1?g===u.pos:E.atStart(c).from===f;return!d||!p.type.isTextblock||p.textContent.length||!y||y&&u.parent.type.name==="paragraph"?!1:s.clearNodes()}),()=>s.deleteSelection(),()=>s.joinBackward(),()=>s.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:s})=>[()=>s.deleteSelection(),()=>s.deleteCurrentNode(),()=>s.joinForward(),()=>s.selectNodeForward()]),r={Enter:()=>this.editor.commands.first(({commands:s})=>[()=>s.newlineInCode(),()=>s.createParagraphNear(),()=>s.liftEmptyBlock(),()=>s.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:n,"Mod-Backspace":n,"Shift-Backspace":n,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},o=b({},r),i=N(b({},r),{"Ctrl-h":n,"Alt-Backspace":n,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()});return eo()||ld()?i:o},addProseMirrorPlugins(){return[new L({key:new j("clearDocument"),appendTransaction:(n,e,t)=>{if(n.some(m=>m.getMeta("composition")))return;let r=n.some(m=>m.docChanged)&&!e.doc.eq(t.doc),o=n.some(m=>m.getMeta("preventClearDocument"));if(!r||o)return;let{empty:i,from:s,to:l}=e.selection,a=E.atStart(e.doc).from,c=E.atEnd(e.doc).to;if(i||!(s===a&&l===c)||!Es(t.doc))return;let f=t.tr,p=Yr({state:t,transaction:f}),{commands:h}=new an({editor:this.editor,state:p});if(h.clearNodes(),!!f.steps.length)return f}})]}}),kd=H.create({name:"paste",addProseMirrorPlugins(){return[new L({key:new j("tiptapPaste"),props:{handlePaste:(n,e,t)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:t})}}})]}}),wd=H.create({name:"tabindex",addProseMirrorPlugins(){return[new L({key:new j("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}}),Fb=Object.freeze({__proto__:null,ClipboardTextSerializer:td,Commands:md,Drop:gd,Editable:yd,FocusEvents:bd,Keymap:xd,Paste:kd,Tabindex:wd}),ks=class n{get name(){return this.node.type.name}constructor(e,t,r=!1,o=null){this.currentNode=null,this.actualDepth=null,this.isBlock=r,this.resolvedPos=e,this.editor=t,this.currentNode=o}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var e;return(e=this.actualDepth)!==null&&e!==void 0?e:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(e){let t=this.from,r=this.to;if(this.isBlock){if(this.content.size===0){console.error(`You can\u2019t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);return}t=this.from+1,r=this.to-1}this.editor.commands.insertContentAt({from:t,to:r},e)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+(this.node.isText?0:1)}get parent(){if(this.depth===0)return null;let e=this.resolvedPos.start(this.resolvedPos.depth-1),t=this.resolvedPos.doc.resolve(e);return new n(t,this.editor)}get before(){let e=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.from-3)),new n(e,this.editor)}get after(){let e=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return e.depth!==this.depth&&(e=this.resolvedPos.doc.resolve(this.to+3)),new n(e,this.editor)}get children(){let e=[];return this.node.content.forEach((t,r)=>{let o=t.isBlock&&!t.isTextblock,i=t.isAtom&&!t.isText,s=this.pos+r+(i?0:1),l=this.resolvedPos.doc.resolve(s);if(!o&&l.depth<=this.depth)return;let a=new n(l,this.editor,o,o?t:null);o&&(a.actualDepth=this.depth+1),e.push(new n(l,this.editor,o,o?t:null))}),e}get firstChild(){return this.children[0]||null}get lastChild(){let e=this.children;return e[e.length-1]||null}closest(e,t={}){let r=null,o=this.parent;for(;o&&!r;){if(o.node.type.name===e)if(Object.keys(t).length>0){let i=o.node.attrs,s=Object.keys(t);for(let l=0;l{r&&o.length>0||(s.node.type.name===e&&i.every(a=>t[a]===s.node.attrs[a])&&o.push(s),!(r&&o.length>0)&&(o=o.concat(s.querySelectorAll(e,t,r))))}),o}setAttribute(e){let{tr:t}=this.editor.state;t.setNodeMarkup(this.from,void 0,b(b({},this.node.attrs),e)),this.editor.view.dispatch(t)}},Fm=`.ProseMirror { position: relative; } @@ -86,21 +86,21 @@ img.ProseMirror-separator { .tippy-box[data-animation=fade][data-state=hidden] { opacity: 0 -}`;function Fm(n,e,t){let r=document.querySelector(`style[data-tiptap-style${t?`-${t}`:""}]`);if(r!==null)return r;let o=document.createElement("style");return e&&o.setAttribute("nonce",e),o.setAttribute(`data-tiptap-style${t?`-${t}`:""}`,""),o.innerHTML=n,document.getElementsByTagName("head")[0].appendChild(o),o}var Gr=class extends gs{constructor(e={}){super(),this.isFocused=!1,this.isInitialized=!1,this.extensionStorage={},this.options={element:document.createElement("div"),content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,onBeforeCreate:()=>null,onCreate:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:t})=>{throw t},onPaste:()=>null,onDrop:()=>null},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.setOptions(e),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.on("contentError",this.options.onContentError),this.createView(),this.injectCSS(),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.options.onFocus),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),this.on("drop",({event:t,slice:r,moved:o})=>this.options.onDrop(t,r,o)),this.on("paste",({event:t,slice:r})=>this.options.onPaste(t,r)),window.setTimeout(()=>{this.isDestroyed||(this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}),this.isInitialized=!0)},0)}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager.chain()}can(){return this.commandManager.can()}injectCSS(){this.options.injectCSS&&document&&(this.css=Fm(zm,this.options.injectNonce))}setOptions(e={}){this.options=b(b({},this.options),e),!(!this.view||!this.state||this.isDestroyed)&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}setEditable(e,t=!0){this.setOptions({editable:e}),t&&this.emit("update",{editor:this,transaction:this.state.tr})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get state(){return this.view.state}registerPlugin(e,t){let r=Qc(t)?t(e,[...this.state.plugins]):[...this.state.plugins,e],o=this.state.reconfigure({plugins:r});return this.view.updateState(o),o}unregisterPlugin(e){if(this.isDestroyed)return;let t=this.state.plugins,r=t;if([].concat(e).forEach(i=>{let s=typeof i=="string"?`${i}$`:i.key;r=t.filter(l=>!l.key.startsWith(s))}),t.length===r.length)return;let o=this.state.reconfigure({plugins:r});return this.view.updateState(o),o}createExtensionManager(){var e,t;let o=[...this.options.enableCoreExtensions?[gd,ed.configure({blockSeparator:(t=(e=this.options.coreExtensionOptions)===null||e===void 0?void 0:e.clipboardTextSerializer)===null||t===void 0?void 0:t.blockSeparator}),pd,yd,bd,kd,md,xd].filter(i=>typeof this.options.enableCoreExtensions=="object"?this.options.enableCoreExtensions[i.name]!==!1:!0):[],...this.options.extensions].filter(i=>["extension","node","mark"].includes(i==null?void 0:i.type));this.extensionManager=new Jr(o,this)}createCommandManager(){this.commandManager=new an({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createView(){var e;let t;try{t=bs(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(s){if(!(s instanceof Error)||!["[tiptap error]: Invalid JSON content","[tiptap error]: Invalid HTML content"].includes(s.message))throw s;this.emit("contentError",{editor:this,error:s,disableCollaboration:()=>{this.storage.collaboration&&(this.storage.collaboration.isDisabled=!0),this.options.extensions=this.options.extensions.filter(l=>l.name!=="collaboration"),this.createExtensionManager()}}),t=bs(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}let r=rd(t,this.options.autofocus);this.view=new Ln(this.options.element,N(b({},this.options.editorProps),{attributes:b({role:"textbox"},(e=this.options.editorProps)===null||e===void 0?void 0:e.attributes),dispatchTransaction:this.dispatchTransaction.bind(this),state:En.create({doc:t,selection:r||void 0})}));let o=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(o),this.createNodeViews(),this.prependClass();let i=this.view.dom;i.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`tiptap ${this.view.dom.className}`}captureTransaction(e){this.isCapturingTransaction=!0,e(),this.isCapturingTransaction=!1;let t=this.capturedTransaction;return this.capturedTransaction=null,t}dispatchTransaction(e){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=e;return}e.steps.forEach(s=>{var l;return(l=this.capturedTransaction)===null||l===void 0?void 0:l.step(s)});return}let t=this.state.apply(e),r=!this.state.selection.eq(t.selection);this.emit("beforeTransaction",{editor:this,transaction:e,nextState:t}),this.view.updateState(t),this.emit("transaction",{editor:this,transaction:e}),r&&this.emit("selectionUpdate",{editor:this,transaction:e});let o=e.getMeta("focus"),i=e.getMeta("blur");o&&this.emit("focus",{editor:this,event:o.event,transaction:e}),i&&this.emit("blur",{editor:this,event:i.event,transaction:e}),!(!e.docChanged||e.getMeta("preventUpdate"))&&this.emit("update",{editor:this,transaction:e})}getAttributes(e){return Ts(this.state,e)}isActive(e,t){let r=typeof e=="string"?e:null,o=typeof e=="string"?t:e;return gm(this.state,r,o)}getJSON(){return this.state.doc.toJSON()}getHTML(){return Xr(this.state.doc.content,this.schema)}getText(e){let{blockSeparator:t=` +}`;function Hm(n,e,t){let r=document.querySelector(`style[data-tiptap-style${t?`-${t}`:""}]`);if(r!==null)return r;let o=document.createElement("style");return e&&o.setAttribute("nonce",e),o.setAttribute(`data-tiptap-style${t?`-${t}`:""}`,""),o.innerHTML=n,document.getElementsByTagName("head")[0].appendChild(o),o}var Gr=class extends gs{constructor(e={}){super(),this.isFocused=!1,this.isInitialized=!1,this.extensionStorage={},this.options={element:document.createElement("div"),content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,onBeforeCreate:()=>null,onCreate:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:t})=>{throw t},onPaste:()=>null,onDrop:()=>null},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.setOptions(e),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.on("contentError",this.options.onContentError),this.createView(),this.injectCSS(),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.options.onFocus),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),this.on("drop",({event:t,slice:r,moved:o})=>this.options.onDrop(t,r,o)),this.on("paste",({event:t,slice:r})=>this.options.onPaste(t,r)),window.setTimeout(()=>{this.isDestroyed||(this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}),this.isInitialized=!0)},0)}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager.chain()}can(){return this.commandManager.can()}injectCSS(){this.options.injectCSS&&document&&(this.css=Hm(Fm,this.options.injectNonce))}setOptions(e={}){this.options=b(b({},this.options),e),!(!this.view||!this.state||this.isDestroyed)&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}setEditable(e,t=!0){this.setOptions({editable:e}),t&&this.emit("update",{editor:this,transaction:this.state.tr})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get state(){return this.view.state}registerPlugin(e,t){let r=Xc(t)?t(e,[...this.state.plugins]):[...this.state.plugins,e],o=this.state.reconfigure({plugins:r});return this.view.updateState(o),o}unregisterPlugin(e){if(this.isDestroyed)return;let t=this.state.plugins,r=t;if([].concat(e).forEach(i=>{let s=typeof i=="string"?`${i}$`:i.key;r=t.filter(l=>!l.key.startsWith(s))}),t.length===r.length)return;let o=this.state.reconfigure({plugins:r});return this.view.updateState(o),o}createExtensionManager(){var e,t;let o=[...this.options.enableCoreExtensions?[yd,td.configure({blockSeparator:(t=(e=this.options.coreExtensionOptions)===null||e===void 0?void 0:e.clipboardTextSerializer)===null||t===void 0?void 0:t.blockSeparator}),md,bd,xd,wd,gd,kd].filter(i=>typeof this.options.enableCoreExtensions=="object"?this.options.enableCoreExtensions[i.name]!==!1:!0):[],...this.options.extensions].filter(i=>["extension","node","mark"].includes(i==null?void 0:i.type));this.extensionManager=new Jr(o,this)}createCommandManager(){this.commandManager=new an({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createView(){var e;let t;try{t=bs(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(s){if(!(s instanceof Error)||!["[tiptap error]: Invalid JSON content","[tiptap error]: Invalid HTML content"].includes(s.message))throw s;this.emit("contentError",{editor:this,error:s,disableCollaboration:()=>{this.storage.collaboration&&(this.storage.collaboration.isDisabled=!0),this.options.extensions=this.options.extensions.filter(l=>l.name!=="collaboration"),this.createExtensionManager()}}),t=bs(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}let r=od(t,this.options.autofocus);this.view=new Ln(this.options.element,N(b({},this.options.editorProps),{attributes:b({role:"textbox"},(e=this.options.editorProps)===null||e===void 0?void 0:e.attributes),dispatchTransaction:this.dispatchTransaction.bind(this),state:En.create({doc:t,selection:r||void 0})}));let o=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(o),this.createNodeViews(),this.prependClass();let i=this.view.dom;i.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`tiptap ${this.view.dom.className}`}captureTransaction(e){this.isCapturingTransaction=!0,e(),this.isCapturingTransaction=!1;let t=this.capturedTransaction;return this.capturedTransaction=null,t}dispatchTransaction(e){if(this.view.isDestroyed)return;if(this.isCapturingTransaction){if(!this.capturedTransaction){this.capturedTransaction=e;return}e.steps.forEach(s=>{var l;return(l=this.capturedTransaction)===null||l===void 0?void 0:l.step(s)});return}let t=this.state.apply(e),r=!this.state.selection.eq(t.selection);this.emit("beforeTransaction",{editor:this,transaction:e,nextState:t}),this.view.updateState(t),this.emit("transaction",{editor:this,transaction:e}),r&&this.emit("selectionUpdate",{editor:this,transaction:e});let o=e.getMeta("focus"),i=e.getMeta("blur");o&&this.emit("focus",{editor:this,event:o.event,transaction:e}),i&&this.emit("blur",{editor:this,event:i.event,transaction:e}),!(!e.docChanged||e.getMeta("preventUpdate"))&&this.emit("update",{editor:this,transaction:e})}getAttributes(e){return As(this.state,e)}isActive(e,t){let r=typeof e=="string"?e:null,o=typeof e=="string"?t:e;return ym(this.state,r,o)}getJSON(){return this.state.doc.toJSON()}getHTML(){return Xr(this.state.doc.content,this.schema)}getText(e){let{blockSeparator:t=` -`,textSerializers:r={}}=e||{};return dd(this.state.doc,{blockSeparator:t,textSerializers:b(b({},ws(this.schema)),r)})}get isEmpty(){return Es(this.state.doc)}getCharacterCount(){return console.warn('[tiptap warn]: "editor.getCharacterCount()" is deprecated. Please use "editor.storage.characterCount.characters()" instead.'),this.state.doc.content.size-2}destroy(){if(this.emit("destroy"),this.view){let e=this.view.dom;e&&e.editor&&delete e.editor,this.view.destroy()}this.removeAllListeners()}get isDestroyed(){var e;return!(!((e=this.view)===null||e===void 0)&&e.docView)}$node(e,t){var r;return((r=this.$doc)===null||r===void 0?void 0:r.querySelector(e,t))||null}$nodes(e,t){var r;return((r=this.$doc)===null||r===void 0?void 0:r.querySelectorAll(e,t))||null}$pos(e){let t=this.state.doc.resolve(e);return new ks(t,this)}get $doc(){return this.$pos(0)}};function Ee(n){return new Bt({find:n.find,handler:({state:e,range:t,match:r})=>{let o=D(n.getAttributes,void 0,r);if(o===!1||o===null)return null;let{tr:i}=e,s=r[r.length-1],l=r[0];if(s){let a=l.search(/\S/),c=t.from+l.indexOf(s),d=c+s.length;if(ro(t.from,t.to,e.doc).filter(h=>h.mark.type.excluded.find(m=>m===n.type&&m!==h.mark.type)).filter(h=>h.to>c).length)return null;dt.from&&i.delete(t.from+a,c);let f=t.from+a+s.length;i.addMark(t.from+a,f,n.type.create(o||{})),i.removeStoredMark(n.type)}}})}function oo(n){return new Bt({find:n.find,handler:({state:e,range:t,match:r})=>{let o=D(n.getAttributes,void 0,r)||{},{tr:i}=e,s=t.from,l=t.to,a=n.type.create(o);if(r[1]){let c=r[0].lastIndexOf(r[1]),d=s+c;d>l?d=l:l=d+r[1].length;let u=r[0][r[0].length-1];i.insertText(u,s+r[0].length-1),i.replaceWith(d,l,a)}else if(r[0]){let c=n.type.isInline?s:s-1;i.insert(c,n.type.create(o)).delete(i.mapping.map(s),i.mapping.map(l))}i.scrollIntoView()}})}function Vn(n){return new Bt({find:n.find,handler:({state:e,range:t,match:r})=>{let o=e.doc.resolve(t.from),i=D(n.getAttributes,void 0,r)||{};if(!o.node(-1).canReplaceWith(o.index(-1),o.indexAfter(-1),n.type))return null;e.tr.delete(t.from,t.to).setBlockType(t.from,t.from,n.type,i)}})}function Fb(n){return new Bt({find:n.find,handler:({state:e,range:t,match:r})=>{let o=n.replace,i=t.from,s=t.to;if(r[1]){let l=r[0].lastIndexOf(r[1]);o+=r[0].slice(l+r[1].length),i+=l;let a=i-s;a>0&&(o=r[0].slice(l-a,l)+o,i=s)}e.tr.insertText(o,i,s)}})}function mt(n){return new Bt({find:n.find,handler:({state:e,range:t,match:r,chain:o})=>{let i=D(n.getAttributes,void 0,r)||{},s=e.tr.delete(t.from,t.to),a=s.doc.resolve(t.from).blockRange(),c=a&&At(a,n.type,i);if(!c)return null;if(s.wrap(a,c),n.keepMarks&&n.editor){let{selection:u,storedMarks:f}=e,{splittableMarks:h}=n.editor.extensionManager,p=f||u.$to.parentOffset&&u.$from.marks();if(p){let m=p.filter(g=>h.includes(g.type.name));s.ensureMarks(m)}}if(n.keepAttributes){let u=n.type.name==="bulletList"||n.type.name==="orderedList"?"listItem":"taskList";o().updateAttributes(u,i).run()}let d=s.doc.resolve(t.from-1).nodeBefore;d&&d.type===n.type&&Se(s.doc,t.from-1)&&(!n.joinPredicate||n.joinPredicate(r,d))&&s.join(t.from-1)}})}var B=class n{constructor(e={}){this.type="node",this.name="node",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config=b(b({},this.config),e),this.name=this.config.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=D(C(this,"addOptions",{name:this.name}))),this.storage=D(C(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new n(e)}configure(e={}){let t=this.extend(N(b({},this.config),{addOptions:()=>Zr(this.options,e)}));return t.name=this.name,t.parent=this.parent,t}extend(e={}){let t=new n(e);return t.parent=this,this.child=t,t.name=e.name?e.name:t.parent.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${t.name}".`),t.options=D(C(t,"addOptions",{name:t.name})),t.storage=D(C(t,"addStorage",{name:t.name,options:t.options})),t}},qc=class{constructor(e,t,r){this.isDragging=!1,this.component=e,this.editor=t.editor,this.options=b({stopEvent:null,ignoreMutation:null},r),this.extension=t.extension,this.node=t.node,this.decorations=t.decorations,this.innerDecorations=t.innerDecorations,this.view=t.view,this.HTMLAttributes=t.HTMLAttributes,this.getPos=t.getPos,this.mount()}mount(){}get dom(){return this.editor.view.dom}get contentDOM(){return null}onDragStart(e){var t,r,o,i,s,l,a;let{view:c}=this.editor,d=e.target,u=d.nodeType===3?(t=d.parentElement)===null||t===void 0?void 0:t.closest("[data-drag-handle]"):d.closest("[data-drag-handle]");if(!this.dom||!((r=this.contentDOM)===null||r===void 0)&&r.contains(d)||!u)return;let f=0,h=0;if(this.dom!==u){let y=this.dom.getBoundingClientRect(),S=u.getBoundingClientRect(),A=(o=e.offsetX)!==null&&o!==void 0?o:(i=e.nativeEvent)===null||i===void 0?void 0:i.offsetX,I=(s=e.offsetY)!==null&&s!==void 0?s:(l=e.nativeEvent)===null||l===void 0?void 0:l.offsetY;f=S.x-y.x+A,h=S.y-y.y+I}(a=e.dataTransfer)===null||a===void 0||a.setDragImage(this.dom,f,h);let p=this.getPos();if(typeof p!="number")return;let m=O.create(c.state.doc,p),g=c.state.tr.setSelection(m);c.dispatch(g)}stopEvent(e){var t;if(!this.dom)return!1;if(typeof this.options.stopEvent=="function")return this.options.stopEvent({event:e});let r=e.target;if(!(this.dom.contains(r)&&!(!((t=this.contentDOM)===null||t===void 0)&&t.contains(r))))return!1;let i=e.type.startsWith("drag"),s=e.type==="drop";if((["INPUT","BUTTON","SELECT","TEXTAREA"].includes(r.tagName)||r.isContentEditable)&&!s&&!i)return!0;let{isEditable:a}=this.editor,{isDragging:c}=this,d=!!this.node.type.spec.draggable,u=O.isSelectable(this.node),f=e.type==="copy",h=e.type==="paste",p=e.type==="cut",m=e.type==="mousedown";if(!d&&u&&i&&e.target===this.dom&&e.preventDefault(),d&&i&&!c&&e.target===this.dom)return e.preventDefault(),!1;if(d&&a&&!c&&m){let g=r.closest("[data-drag-handle]");g&&(this.dom===g||this.dom.contains(g))&&(this.isDragging=!0,document.addEventListener("dragend",()=>{this.isDragging=!1},{once:!0}),document.addEventListener("drop",()=>{this.isDragging=!1},{once:!0}),document.addEventListener("mouseup",()=>{this.isDragging=!1},{once:!0}))}return!(c||s||f||h||p||m&&u)}ignoreMutation(e){return!this.dom||!this.contentDOM?!0:typeof this.options.ignoreMutation=="function"?this.options.ignoreMutation({mutation:e}):this.node.isLeaf||this.node.isAtom?!0:e.type==="selection"||this.dom.contains(e.target)&&e.type==="childList"&&(eo()||od())&&this.editor.isFocused&&[...Array.from(e.addedNodes),...Array.from(e.removedNodes)].every(r=>r.isContentEditable)?!1:this.contentDOM===e.target&&e.type==="attributes"?!0:!this.contentDOM.contains(e.target)}updateAttributes(e){this.editor.commands.command(({tr:t})=>{let r=this.getPos();return typeof r!="number"?!1:(t.setNodeMarkup(r,void 0,b(b({},this.node.attrs),e)),!0)})}deleteNode(){let e=this.getPos();if(typeof e!="number")return;let t=e+this.node.nodeSize;this.editor.commands.deleteRange({from:e,to:t})}};function be(n){return new $n({find:n.find,handler:({state:e,range:t,match:r,pasteEvent:o})=>{let i=D(n.getAttributes,void 0,r,o);if(i===!1||i===null)return null;let{tr:s}=e,l=r[r.length-1],a=r[0],c=t.to;if(l){let d=a.search(/\S/),u=t.from+a.indexOf(l),f=u+l.length;if(ro(t.from,t.to,e.doc).filter(p=>p.mark.type.excluded.find(g=>g===n.type&&g!==p.mark.type)).filter(p=>p.to>u).length)return null;ft.from&&s.delete(t.from+d,u),c=t.from+d+l.length,s.addMark(t.from+d,c,n.type.create(i||{})),s.removeStoredMark(n.type)}}})}function Hb(n){return n.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}function $b(n){return typeof n=="string"}function _b(n){return new $n({find:n.find,handler({match:e,chain:t,range:r,pasteEvent:o}){let i=D(n.getAttributes,void 0,e,o),s=D(n.getContent,void 0,i);if(i===!1||i===null)return null;let l={type:n.type.name,attrs:i};s&&(l.content=s),e.input&&t().deleteRange(r).insertContentAt(r.from,l)}})}function Vb(n){return new $n({find:n.find,handler:({state:e,range:t,match:r})=>{let o=n.replace,i=t.from,s=t.to;if(r[1]){let l=r[0].lastIndexOf(r[1]);o+=r[0].slice(l+r[1].length),i+=l;let a=i-s;a>0&&(o=r[0].slice(l-a,l)+o,i=s)}e.tr.insertText(o,i,s)}})}var Gc=class{constructor(e){this.transaction=e,this.currentStep=this.transaction.steps.length}map(e){let t=!1;return{position:this.transaction.steps.slice(this.currentStep).reduce((o,i)=>{let s=i.getMap().mapResult(o);return s.deleted&&(t=!0),s.pos},e),deleted:t}}};var Hm=B.create({name:"doc",topNode:!0,content:"block+"});function Sd(n={}){return new L({view(e){return new Os(e,n)}})}var Os=class{constructor(e,t){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=t.width)!==null&&r!==void 0?r:1,this.color=t.color===!1?void 0:t.color||"black",this.class=t.class,this.handlers=["dragover","dragend","drop","dragleave"].map(o=>{let i=s=>{this[o](s)};return e.dom.addEventListener(o,i),{name:o,handler:i}})}destroy(){this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){this.cursorPos!=null&&t.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),t=!e.parent.inlineContent,r;if(t){let l=e.nodeBefore,a=e.nodeAfter;if(l||a){let c=this.editorView.nodeDOM(this.cursorPos-(l?l.nodeSize:0));if(c){let d=c.getBoundingClientRect(),u=l?d.bottom:d.top;l&&a&&(u=(u+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2),r={left:d.left,right:d.right,top:u-this.width/2,bottom:u+this.width/2}}}}if(!r){let l=this.editorView.coordsAtPos(this.cursorPos);r={left:l.left-this.width/2,right:l.left+this.width/2,top:l.top,bottom:l.bottom}}let o=this.editorView.dom.offsetParent;this.element||(this.element=o.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",t),this.element.classList.toggle("prosemirror-dropcursor-inline",!t);let i,s;if(!o||o==document.body&&getComputedStyle(o).position=="static")i=-pageXOffset,s=-pageYOffset;else{let l=o.getBoundingClientRect();i=l.left-o.scrollLeft,s=l.top-o.scrollTop}this.element.style.left=r.left-i+"px",this.element.style.top=r.top-s+"px",this.element.style.width=r.right-r.left+"px",this.element.style.height=r.bottom-r.top+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),o=r&&r.type.spec.disableDropCursor,i=typeof o=="function"?o(this.editorView,t,e):o;if(t&&!i){let s=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=An(this.editorView.state.doc,s,this.editorView.dragging.slice);l!=null&&(s=l)}this.setCursor(s),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){(e.target==this.editorView.dom||!this.editorView.dom.contains(e.relatedTarget))&&this.setCursor(null)}};var $m=H.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[Sd(this.options)]}});var ue=class n extends E{constructor(e){super(e,e)}map(e,t){let r=e.resolve(t.map(this.head));return n.valid(r)?new n(r):E.near(r)}content(){return w.empty}eq(e){return e instanceof n&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new n(e.resolve(t.pos))}getBookmark(){return new vs(this.anchor)}static valid(e){let t=e.parent;if(t.isTextblock||!_m(e)||!Vm(e))return!1;let r=t.type.spec.allowGapCursor;if(r!=null)return r;let o=t.contentMatchAt(e.index()).defaultType;return o&&o.isTextblock}static findGapCursorFrom(e,t,r=!1){e:for(;;){if(!r&&n.valid(e))return e;let o=e.pos,i=null;for(let s=e.depth;;s--){let l=e.node(s);if(t>0?e.indexAfter(s)0){i=l.child(t>0?e.indexAfter(s):e.index(s)-1);break}else if(s==0)return null;o+=t;let a=e.doc.resolve(o);if(n.valid(a))return a}for(;;){let s=t>0?i.firstChild:i.lastChild;if(!s){if(i.isAtom&&!i.isText&&!O.isSelectable(i)){e=e.doc.resolve(o+i.nodeSize*t),r=!1;continue e}break}i=s,o+=t;let l=e.doc.resolve(o);if(n.valid(l))return l}return null}}};ue.prototype.visible=!1;ue.findFrom=ue.findGapCursorFrom;E.jsonID("gapcursor",ue);var vs=class n{constructor(e){this.pos=e}map(e){return new n(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return ue.valid(t)?new ue(t):E.near(t)}};function _m(n){for(let e=n.depth;e>=0;e--){let t=n.index(e),r=n.node(e);if(t==0){if(r.type.spec.isolating)return!0;continue}for(let o=r.child(t-1);;o=o.lastChild){if(o.childCount==0&&!o.inlineContent||o.isAtom||o.type.spec.isolating)return!0;if(o.inlineContent)return!1}}return!0}function Vm(n){for(let e=n.depth;e>=0;e--){let t=n.indexAfter(e),r=n.node(e);if(t==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let o=r.child(t);;o=o.firstChild){if(o.childCount==0&&!o.inlineContent||o.isAtom||o.type.spec.isolating)return!0;if(o.inlineContent)return!1}}return!0}function wd(){return new L({props:{decorations:Jm,createSelectionBetween(n,e,t){return e.pos==t.pos&&ue.valid(t)?new ue(t):null},handleClick:Wm,handleKeyDown:jm,handleDOMEvents:{beforeinput:Km}}})}var jm=sn({ArrowLeft:io("horiz",-1),ArrowRight:io("horiz",1),ArrowUp:io("vert",-1),ArrowDown:io("vert",1)});function io(n,e){let t=n=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,o,i){let s=r.selection,l=e>0?s.$to:s.$from,a=s.empty;if(s instanceof T){if(!i.endOfTextblock(t)||l.depth==0)return!1;a=!1,l=r.doc.resolve(e>0?l.after():l.before())}let c=ue.findGapCursorFrom(l,e,a);return c?(o&&o(r.tr.setSelection(new ue(c))),!0):!1}}function Wm(n,e,t){if(!n||!n.editable)return!1;let r=n.state.doc.resolve(e);if(!ue.valid(r))return!1;let o=n.posAtCoords({left:t.clientX,top:t.clientY});return o&&o.inside>-1&&O.isSelectable(n.state.doc.nodeAt(o.inside))?!1:(n.dispatch(n.state.tr.setSelection(new ue(r))),!0)}function Km(n,e){if(e.inputType!="insertCompositionText"||!(n.state.selection instanceof ue))return!1;let{$from:t}=n.state.selection,r=t.parent.contentMatchAt(t.index()).findWrapping(n.state.schema.nodes.text);if(!r)return!1;let o=x.empty;for(let s=r.length-1;s>=0;s--)o=x.from(r[s].createAndFill(null,o));let i=n.state.tr.replace(t.pos,t.pos,new w(o,0,0));return i.setSelection(T.near(i.doc.resolve(t.pos+1))),n.dispatch(i),!1}function Jm(n){if(!(n.selection instanceof ue))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",q.create(n.doc,[ne.widget(n.selection.head,e,{key:"gapcursor"})])}var Um=H.create({name:"gapCursor",addProseMirrorPlugins(){return[wd()]},extendNodeSchema(n){var e;let t={name:n.name,options:n.options,storage:n.storage};return{allowGapCursor:(e=D(C(n,"allowGapCursor",t)))!==null&&e!==void 0?e:null}}});var fo={};rt(fo,{closeHistory:()=>tg,history:()=>Is,redo:()=>uo,redoDepth:()=>ig,redoNoScroll:()=>rg,undo:()=>co,undoDepth:()=>og,undoNoScroll:()=>ng});var so=200,se=function(){};se.prototype.append=function(e){return e.length?(e=se.from(e),!this.length&&e||e.length=t?se.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))};se.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};se.prototype.forEach=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length),t<=r?this.forEachInner(e,t,r,0):this.forEachInvertedInner(e,t,r,0)};se.prototype.map=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length);var o=[];return this.forEach(function(i,s){return o.push(e(i,s))},t,r),o};se.from=function(e){return e instanceof se?e:e&&e.length?new Cd(e):se.empty};var Cd=function(n){function e(r){n.call(this),this.values=r}n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e;var t={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(o,i){return o==0&&i==this.length?this:new e(this.values.slice(o,i))},e.prototype.getInner=function(o){return this.values[o]},e.prototype.forEachInner=function(o,i,s,l){for(var a=i;a=s;a--)if(o(this.values[a],l+a)===!1)return!1},e.prototype.leafAppend=function(o){if(this.length+o.length<=so)return new e(this.values.concat(o.flatten()))},e.prototype.leafPrepend=function(o){if(this.length+o.length<=so)return new e(o.flatten().concat(this.values))},t.length.get=function(){return this.values.length},t.depth.get=function(){return 0},Object.defineProperties(e.prototype,t),e}(se);se.empty=new Cd([]);var qm=function(n){function e(t,r){n.call(this),this.left=t,this.right=r,this.length=t.length+r.length,this.depth=Math.max(t.depth,r.depth)+1}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(r){return rl&&this.right.forEachInner(r,Math.max(o-l,0),Math.min(this.length,i)-l,s+l)===!1)return!1},e.prototype.forEachInvertedInner=function(r,o,i,s){var l=this.left.length;if(o>l&&this.right.forEachInvertedInner(r,o-l,Math.max(i,l)-l,s+l)===!1||i=i?this.right.slice(r-i,o-i):this.left.slice(r,i).append(this.right.slice(0,o-i))},e.prototype.leafAppend=function(r){var o=this.right.leafAppend(r);if(o)return new e(this.left,o)},e.prototype.leafPrepend=function(r){var o=this.left.leafPrepend(r);if(o)return new e(o,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e}(se),Ns=se;var Gm=500,zt=class n{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let o,i;t&&(o=this.remapping(r,this.items.length),i=o.maps.length);let s=e.tr,l,a,c=[],d=[];return this.items.forEach((u,f)=>{if(!u.step){o||(o=this.remapping(r,f+1),i=o.maps.length),i--,d.push(u);return}if(o){d.push(new He(u.map));let h=u.step.map(o.slice(i)),p;h&&s.maybeStep(h).doc&&(p=s.mapping.maps[s.mapping.maps.length-1],c.push(new He(p,void 0,void 0,c.length+d.length))),i--,p&&o.appendMap(p,i)}else s.maybeStep(u.step);if(u.selection)return l=o?u.selection.map(o.slice(i)):u.selection,a=new n(this.items.slice(0,r).append(d.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:s,selection:l}}addTransform(e,t,r,o){let i=[],s=this.eventCount,l=this.items,a=!o&&l.length?l.get(l.length-1):null;for(let d=0;dQm&&(l=Ym(l,c),s-=c),new n(l.append(i),s)}remapping(e,t){let r=new Jt;return this.items.forEach((o,i)=>{let s=o.mirrorOffset!=null&&i-o.mirrorOffset>=e?r.maps.length-o.mirrorOffset:void 0;r.appendMap(o.map,s)},e,t),r}addMaps(e){return this.eventCount==0?this:new n(this.items.append(e.map(t=>new He(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let r=[],o=Math.max(0,this.items.length-t),i=e.mapping,s=e.steps.length,l=this.eventCount;this.items.forEach(f=>{f.selection&&l--},o);let a=t;this.items.forEach(f=>{let h=i.getMirror(--a);if(h==null)return;s=Math.min(s,h);let p=i.maps[h];if(f.step){let m=e.steps[h].invert(e.docs[h]),g=f.selection&&f.selection.map(i.slice(a+1,h));g&&l++,r.push(new He(p,m,g))}else r.push(new He(p))},o);let c=[];for(let f=t;fGm&&(u=u.compress(this.items.length-r.length)),u}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),r=t.maps.length,o=[],i=0;return this.items.forEach((s,l)=>{if(l>=e)o.push(s),s.selection&&i++;else if(s.step){let a=s.step.map(t.slice(r)),c=a&&a.getMap();if(r--,c&&t.appendMap(c,r),a){let d=s.selection&&s.selection.map(t.slice(r));d&&i++;let u=new He(c.invert(),a,d),f,h=o.length-1;(f=o.length&&o[h].merge(u))?o[h]=f:o.push(u)}}else s.map&&r--},this.items.length,0),new n(Ns.from(o.reverse()),i)}};zt.empty=new zt(Ns.empty,0);function Ym(n,e){let t;return n.forEach((r,o)=>{if(r.selection&&e--==0)return t=o,!1}),n.slice(t)}var He=class n{constructor(e,t,r,o){this.map=e,this.step=t,this.selection=r,this.mirrorOffset=o}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new n(t.getMap().invert(),t,this.selection)}}},$e=class{constructor(e,t,r,o,i){this.done=e,this.undone=t,this.prevRanges=r,this.prevTime=o,this.prevComposition=i}},Qm=20;function Xm(n,e,t,r){let o=t.getMeta(Xe),i;if(o)return o.historyState;t.getMeta(Td)&&(n=new $e(n.done,n.undone,null,0,-1));let s=t.getMeta("appendedTransaction");if(t.steps.length==0)return n;if(s&&s.getMeta(Xe))return s.getMeta(Xe).redo?new $e(n.done.addTransform(t,void 0,r,lo(e)),n.undone,Md(t.mapping.maps),n.prevTime,n.prevComposition):new $e(n.done,n.undone.addTransform(t,void 0,r,lo(e)),null,n.prevTime,n.prevComposition);if(t.getMeta("addToHistory")!==!1&&!(s&&s.getMeta("addToHistory")===!1)){let l=t.getMeta("composition"),a=n.prevTime==0||!s&&n.prevComposition!=l&&(n.prevTime<(t.time||0)-r.newGroupDelay||!Zm(t,n.prevRanges)),c=s?Rs(n.prevRanges,t.mapping):Md(t.mapping.maps);return new $e(n.done.addTransform(t,a?e.selection.getBookmark():void 0,r,lo(e)),zt.empty,c,t.time,l==null?n.prevComposition:l)}else return(i=t.getMeta("rebased"))?new $e(n.done.rebased(t,i),n.undone.rebased(t,i),Rs(n.prevRanges,t.mapping),n.prevTime,n.prevComposition):new $e(n.done.addMaps(t.mapping.maps),n.undone.addMaps(t.mapping.maps),Rs(n.prevRanges,t.mapping),n.prevTime,n.prevComposition)}function Zm(n,e){if(!e)return!1;if(!n.docChanged)return!0;let t=!1;return n.mapping.maps[0].forEach((r,o)=>{for(let i=0;i=e[i]&&(t=!0)}),t}function Md(n){let e=[];for(let t=n.length-1;t>=0&&e.length==0;t--)n[t].forEach((r,o,i,s)=>e.push(i,s));return e}function Rs(n,e){if(!n)return null;let t=[];for(let r=0;r{let o=Xe.getState(t);if(!o||(n?o.undone:o.done).eventCount==0)return!1;if(r){let i=eg(o,t,n);i&&r(e?i.scrollIntoView():i)}return!0}}var co=ao(!1,!0),uo=ao(!0,!0),ng=ao(!1,!1),rg=ao(!0,!1);function og(n){let e=Xe.getState(n);return e?e.done.eventCount:0}function ig(n){let e=Xe.getState(n);return e?e.undone.eventCount:0}var sg=H.create({name:"history",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:n,dispatch:e})=>co(n,e),redo:()=>({state:n,dispatch:e})=>uo(n,e)}},addProseMirrorPlugins(){return[Is(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-\u044F":()=>this.editor.commands.undo(),"Shift-Mod-\u044F":()=>this.editor.commands.redo()}}});var lg=B.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:n}){return["p",v(this.options.HTMLAttributes,n),0]},addCommands(){return{setParagraph:()=>({commands:n})=>n.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}});var ag=B.create({name:"hardBreak",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:n}){return["br",v(this.options.HTMLAttributes,n)]},renderText(){return` -`},addCommands(){return{setHardBreak:()=>({commands:n,chain:e,state:t,editor:r})=>n.first([()=>n.exitCode(),()=>n.command(()=>{let{selection:o,storedMarks:i}=t;if(o.$from.parent.type.spec.isolating)return!1;let{keepMarks:s}=this.options,{splittableMarks:l}=r.extensionManager,a=i||o.$to.parentOffset&&o.$from.marks();return e().insertContent({type:this.name}).command(({tr:c,dispatch:d})=>{if(d&&a&&s){let u=a.filter(f=>l.includes(f.type.name));c.ensureMarks(u)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}});var cg=B.create({name:"text",group:"inline"});var dg=/^\s*>\s$/,ug=B.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:n}){return["blockquote",v(this.options.HTMLAttributes,n),0]},addCommands(){return{setBlockquote:()=>({commands:n})=>n.wrapIn(this.name),toggleBlockquote:()=>({commands:n})=>n.toggleWrap(this.name),unsetBlockquote:()=>({commands:n})=>n.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[mt({find:dg,type:this.type})]}});var fg=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,hg=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,pg=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,mg=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,gg=J.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:n=>n.style.fontWeight!=="normal"&&null},{style:"font-weight=400",clearMark:n=>n.type.name===this.name},{style:"font-weight",getAttrs:n=>/^(bold(er)?|[5-9]\d{2,})$/.test(n)&&null}]},renderHTML({HTMLAttributes:n}){return["strong",v(this.options.HTMLAttributes,n),0]},addCommands(){return{setBold:()=>({commands:n})=>n.setMark(this.name),toggleBold:()=>({commands:n})=>n.toggleMark(this.name),unsetBold:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[Ee({find:fg,type:this.type}),Ee({find:pg,type:this.type})]},addPasteRules(){return[be({find:hg,type:this.type}),be({find:mg,type:this.type})]}});var yg="listItem",Ed="textStyle",Od=/^\s*([-+*])\s$/,bg=B.create({name:"bulletList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:"ul"}]},renderHTML({HTMLAttributes:n}){return["ul",v(this.options.HTMLAttributes,n),0]},addCommands(){return{toggleBulletList:()=>({commands:n,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(yg,this.editor.getAttributes(Ed)).run():n.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let n=mt({find:Od,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(n=mt({find:Od,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(Ed),editor:this.editor})),[n]}});var xg=B.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(n=>({tag:`h${n}`,attrs:{level:n}}))},renderHTML({node:n,HTMLAttributes:e}){return[`h${this.options.levels.includes(n.attrs.level)?n.attrs.level:this.options.levels[0]}`,v(this.options.HTMLAttributes,e),0]},addCommands(){return{setHeading:n=>({commands:e})=>this.options.levels.includes(n.level)?e.setNode(this.name,n):!1,toggleHeading:n=>({commands:e})=>this.options.levels.includes(n.level)?e.toggleNode(this.name,"paragraph",n):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((n,e)=>N(b({},n),{[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}),{})},addInputRules(){return this.options.levels.map(n=>Vn({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${n}})\\s$`),type:this.type,getAttributes:{level:n}}))}});var kg=B.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{}}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:n}){return["hr",v(this.options.HTMLAttributes,n)]},addCommands(){return{setHorizontalRule:()=>({chain:n,state:e})=>{let{selection:t}=e,{$from:r,$to:o}=t,i=n();return r.parentOffset===0?i.insertContentAt({from:Math.max(r.pos-1,0),to:o.pos},{type:this.name}):fd(t)?i.insertContentAt(o.pos,{type:this.name}):i.insertContent({type:this.name}),i.command(({tr:s,dispatch:l})=>{var a;if(l){let{$to:c}=s.selection,d=c.end();if(c.nodeAfter)c.nodeAfter.isTextblock?s.setSelection(T.create(s.doc,c.pos+1)):c.nodeAfter.isBlock?s.setSelection(O.create(s.doc,c.pos)):s.setSelection(T.create(s.doc,c.pos));else{let u=(a=c.parent.type.contentMatch.defaultType)===null||a===void 0?void 0:a.create();u&&(s.insert(d,u),s.setSelection(T.create(s.doc,d+1)))}s.scrollIntoView()}return!0}).run()}}},addInputRules(){return[oo({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}});var Sg=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,wg=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,Cg=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,Mg=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,Ag=J.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:n=>n.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:n=>n.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:n}){return["em",v(this.options.HTMLAttributes,n),0]},addCommands(){return{setItalic:()=>({commands:n})=>n.setMark(this.name),toggleItalic:()=>({commands:n})=>n.toggleMark(this.name),unsetItalic:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[Ee({find:Sg,type:this.type}),Ee({find:Cg,type:this.type})]},addPasteRules(){return[be({find:wg,type:this.type}),be({find:Mg,type:this.type})]}});var Tg=B.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:n}){return["li",v(this.options.HTMLAttributes,n),0]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}});var Eg=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,Og=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,vg=J.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:n=>n.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:n}){return["s",v(this.options.HTMLAttributes,n),0]},addCommands(){return{setStrike:()=>({commands:n})=>n.setMark(this.name),toggleStrike:()=>({commands:n})=>n.toggleMark(this.name),unsetStrike:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[Ee({find:Eg,type:this.type})]},addPasteRules(){return[be({find:Og,type:this.type})]}});var Ng=J.create({name:"subscript",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"sub"},{style:"vertical-align",getAttrs(n){return n!=="sub"?!1:null}}]},renderHTML({HTMLAttributes:n}){return["sub",v(this.options.HTMLAttributes,n),0]},addCommands(){return{setSubscript:()=>({commands:n})=>n.setMark(this.name),toggleSubscript:()=>({commands:n})=>n.toggleMark(this.name),unsetSubscript:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-,":()=>this.editor.commands.toggleSubscript()}}});var Rg=J.create({name:"superscript",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"sup"},{style:"vertical-align",getAttrs(n){return n!=="super"?!1:null}}]},renderHTML({HTMLAttributes:n}){return["sup",v(this.options.HTMLAttributes,n),0]},addCommands(){return{setSuperscript:()=>({commands:n})=>n.setMark(this.name),toggleSuperscript:()=>({commands:n})=>n.toggleMark(this.name),unsetSuperscript:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-.":()=>this.editor.commands.toggleSuperscript()}}});var Dg=J.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:n=>n.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:n}){return["u",v(this.options.HTMLAttributes,n),0]},addCommands(){return{setUnderline:()=>({commands:n})=>n.setMark(this.name),toggleUnderline:()=>({commands:n})=>n.toggleMark(this.name),unsetUnderline:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}});var Ig=/(^|[^`])`([^`]+)`(?!`)/,Pg=/(^|[^`])`([^`]+)`(?!`)/g,Lg=J.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:n}){return["code",v(this.options.HTMLAttributes,n),0]},addCommands(){return{setCode:()=>({commands:n})=>n.setMark(this.name),toggleCode:()=>({commands:n})=>n.toggleMark(this.name),unsetCode:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[Ee({find:Ig,type:this.type})]},addPasteRules(){return[be({find:Pg,type:this.type})]}});var Bg=/^```([a-z]+)?[\s\n]$/,zg=/^~~~([a-z]+)?[\s\n]$/,Fg=B.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:n=>{var e;let{languageClassPrefix:t}=this.options,i=[...((e=n.firstElementChild)===null||e===void 0?void 0:e.classList)||[]].filter(s=>s.startsWith(t)).map(s=>s.replace(t,""))[0];return i||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:n,HTMLAttributes:e}){return["pre",v(this.options.HTMLAttributes,e),["code",{class:n.attrs.language?this.options.languageClassPrefix+n.attrs.language:null},0]]},addCommands(){return{setCodeBlock:n=>({commands:e})=>e.setNode(this.name,n),toggleCodeBlock:n=>({commands:e})=>e.toggleNode(this.name,"paragraph",n)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{let{empty:n,$anchor:e}=this.editor.state.selection,t=e.pos===1;return!n||e.parent.type.name!==this.name?!1:t||!e.parent.textContent.length?this.editor.commands.clearNodes():!1},Enter:({editor:n})=>{if(!this.options.exitOnTripleEnter)return!1;let{state:e}=n,{selection:t}=e,{$from:r,empty:o}=t;if(!o||r.parent.type!==this.type)return!1;let i=r.parentOffset===r.parent.nodeSize-2,s=r.parent.textContent.endsWith(` +`,textSerializers:r={}}=e||{};return ud(this.state.doc,{blockSeparator:t,textSerializers:b(b({},Ss(this.schema)),r)})}get isEmpty(){return Es(this.state.doc)}getCharacterCount(){return console.warn('[tiptap warn]: "editor.getCharacterCount()" is deprecated. Please use "editor.storage.characterCount.characters()" instead.'),this.state.doc.content.size-2}destroy(){if(this.emit("destroy"),this.view){let e=this.view.dom;e&&e.editor&&delete e.editor,this.view.destroy()}this.removeAllListeners()}get isDestroyed(){var e;return!(!((e=this.view)===null||e===void 0)&&e.docView)}$node(e,t){var r;return((r=this.$doc)===null||r===void 0?void 0:r.querySelector(e,t))||null}$nodes(e,t){var r;return((r=this.$doc)===null||r===void 0?void 0:r.querySelectorAll(e,t))||null}$pos(e){let t=this.state.doc.resolve(e);return new ks(t,this)}get $doc(){return this.$pos(0)}};function Ee(n){return new zt({find:n.find,handler:({state:e,range:t,match:r})=>{let o=D(n.getAttributes,void 0,r);if(o===!1||o===null)return null;let{tr:i}=e,s=r[r.length-1],l=r[0];if(s){let a=l.search(/\S/),c=t.from+l.indexOf(s),d=c+s.length;if(ro(t.from,t.to,e.doc).filter(p=>p.mark.type.excluded.find(m=>m===n.type&&m!==p.mark.type)).filter(p=>p.to>c).length)return null;dt.from&&i.delete(t.from+a,c);let f=t.from+a+s.length;i.addMark(t.from+a,f,n.type.create(o||{})),i.removeStoredMark(n.type)}}})}function oo(n){return new zt({find:n.find,handler:({state:e,range:t,match:r})=>{let o=D(n.getAttributes,void 0,r)||{},{tr:i}=e,s=t.from,l=t.to,a=n.type.create(o);if(r[1]){let c=r[0].lastIndexOf(r[1]),d=s+c;d>l?d=l:l=d+r[1].length;let u=r[0][r[0].length-1];i.insertText(u,s+r[0].length-1),i.replaceWith(d,l,a)}else if(r[0]){let c=n.type.isInline?s:s-1;i.insert(c,n.type.create(o)).delete(i.mapping.map(s),i.mapping.map(l))}i.scrollIntoView()}})}function Vn(n){return new zt({find:n.find,handler:({state:e,range:t,match:r})=>{let o=e.doc.resolve(t.from),i=D(n.getAttributes,void 0,r)||{};if(!o.node(-1).canReplaceWith(o.index(-1),o.indexAfter(-1),n.type))return null;e.tr.delete(t.from,t.to).setBlockType(t.from,t.from,n.type,i)}})}function Hb(n){return new zt({find:n.find,handler:({state:e,range:t,match:r})=>{let o=n.replace,i=t.from,s=t.to;if(r[1]){let l=r[0].lastIndexOf(r[1]);o+=r[0].slice(l+r[1].length),i+=l;let a=i-s;a>0&&(o=r[0].slice(l-a,l)+o,i=s)}e.tr.insertText(o,i,s)}})}function mt(n){return new zt({find:n.find,handler:({state:e,range:t,match:r,chain:o})=>{let i=D(n.getAttributes,void 0,r)||{},s=e.tr.delete(t.from,t.to),a=s.doc.resolve(t.from).blockRange(),c=a&&Tt(a,n.type,i);if(!c)return null;if(s.wrap(a,c),n.keepMarks&&n.editor){let{selection:u,storedMarks:f}=e,{splittableMarks:p}=n.editor.extensionManager,h=f||u.$to.parentOffset&&u.$from.marks();if(h){let m=h.filter(g=>p.includes(g.type.name));s.ensureMarks(m)}}if(n.keepAttributes){let u=n.type.name==="bulletList"||n.type.name==="orderedList"?"listItem":"taskList";o().updateAttributes(u,i).run()}let d=s.doc.resolve(t.from-1).nodeBefore;d&&d.type===n.type&&we(s.doc,t.from-1)&&(!n.joinPredicate||n.joinPredicate(r,d))&&s.join(t.from-1)}})}var z=class n{constructor(e={}){this.type="node",this.name="node",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config=b(b({},this.config),e),this.name=this.config.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=D(C(this,"addOptions",{name:this.name}))),this.storage=D(C(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new n(e)}configure(e={}){let t=this.extend(N(b({},this.config),{addOptions:()=>Zr(this.options,e)}));return t.name=this.name,t.parent=this.parent,t}extend(e={}){let t=new n(e);return t.parent=this,this.child=t,t.name=e.name?e.name:t.parent.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${t.name}".`),t.options=D(C(t,"addOptions",{name:t.name})),t.storage=D(C(t,"addStorage",{name:t.name,options:t.options})),t}},Gc=class{constructor(e,t,r){this.isDragging=!1,this.component=e,this.editor=t.editor,this.options=b({stopEvent:null,ignoreMutation:null},r),this.extension=t.extension,this.node=t.node,this.decorations=t.decorations,this.innerDecorations=t.innerDecorations,this.view=t.view,this.HTMLAttributes=t.HTMLAttributes,this.getPos=t.getPos,this.mount()}mount(){}get dom(){return this.editor.view.dom}get contentDOM(){return null}onDragStart(e){var t,r,o,i,s,l,a;let{view:c}=this.editor,d=e.target,u=d.nodeType===3?(t=d.parentElement)===null||t===void 0?void 0:t.closest("[data-drag-handle]"):d.closest("[data-drag-handle]");if(!this.dom||!((r=this.contentDOM)===null||r===void 0)&&r.contains(d)||!u)return;let f=0,p=0;if(this.dom!==u){let y=this.dom.getBoundingClientRect(),w=u.getBoundingClientRect(),T=(o=e.offsetX)!==null&&o!==void 0?o:(i=e.nativeEvent)===null||i===void 0?void 0:i.offsetX,I=(s=e.offsetY)!==null&&s!==void 0?s:(l=e.nativeEvent)===null||l===void 0?void 0:l.offsetY;f=w.x-y.x+T,p=w.y-y.y+I}(a=e.dataTransfer)===null||a===void 0||a.setDragImage(this.dom,f,p);let h=this.getPos();if(typeof h!="number")return;let m=v.create(c.state.doc,h),g=c.state.tr.setSelection(m);c.dispatch(g)}stopEvent(e){var t;if(!this.dom)return!1;if(typeof this.options.stopEvent=="function")return this.options.stopEvent({event:e});let r=e.target;if(!(this.dom.contains(r)&&!(!((t=this.contentDOM)===null||t===void 0)&&t.contains(r))))return!1;let i=e.type.startsWith("drag"),s=e.type==="drop";if((["INPUT","BUTTON","SELECT","TEXTAREA"].includes(r.tagName)||r.isContentEditable)&&!s&&!i)return!0;let{isEditable:a}=this.editor,{isDragging:c}=this,d=!!this.node.type.spec.draggable,u=v.isSelectable(this.node),f=e.type==="copy",p=e.type==="paste",h=e.type==="cut",m=e.type==="mousedown";if(!d&&u&&i&&e.target===this.dom&&e.preventDefault(),d&&i&&!c&&e.target===this.dom)return e.preventDefault(),!1;if(d&&a&&!c&&m){let g=r.closest("[data-drag-handle]");g&&(this.dom===g||this.dom.contains(g))&&(this.isDragging=!0,document.addEventListener("dragend",()=>{this.isDragging=!1},{once:!0}),document.addEventListener("drop",()=>{this.isDragging=!1},{once:!0}),document.addEventListener("mouseup",()=>{this.isDragging=!1},{once:!0}))}return!(c||s||f||p||h||m&&u)}ignoreMutation(e){return!this.dom||!this.contentDOM?!0:typeof this.options.ignoreMutation=="function"?this.options.ignoreMutation({mutation:e}):this.node.isLeaf||this.node.isAtom?!0:e.type==="selection"||this.dom.contains(e.target)&&e.type==="childList"&&(eo()||id())&&this.editor.isFocused&&[...Array.from(e.addedNodes),...Array.from(e.removedNodes)].every(r=>r.isContentEditable)?!1:this.contentDOM===e.target&&e.type==="attributes"?!0:!this.contentDOM.contains(e.target)}updateAttributes(e){this.editor.commands.command(({tr:t})=>{let r=this.getPos();return typeof r!="number"?!1:(t.setNodeMarkup(r,void 0,b(b({},this.node.attrs),e)),!0)})}deleteNode(){let e=this.getPos();if(typeof e!="number")return;let t=e+this.node.nodeSize;this.editor.commands.deleteRange({from:e,to:t})}};function be(n){return new $n({find:n.find,handler:({state:e,range:t,match:r,pasteEvent:o})=>{let i=D(n.getAttributes,void 0,r,o);if(i===!1||i===null)return null;let{tr:s}=e,l=r[r.length-1],a=r[0],c=t.to;if(l){let d=a.search(/\S/),u=t.from+a.indexOf(l),f=u+l.length;if(ro(t.from,t.to,e.doc).filter(h=>h.mark.type.excluded.find(g=>g===n.type&&g!==h.mark.type)).filter(h=>h.to>u).length)return null;ft.from&&s.delete(t.from+d,u),c=t.from+d+l.length,s.addMark(t.from+d,c,n.type.create(i||{})),s.removeStoredMark(n.type)}}})}function $b(n){return n.replace(/[-/\\^$*+?.()|[\]{}]/g,"\\$&")}function _b(n){return typeof n=="string"}function Vb(n){return new $n({find:n.find,handler({match:e,chain:t,range:r,pasteEvent:o}){let i=D(n.getAttributes,void 0,e,o),s=D(n.getContent,void 0,i);if(i===!1||i===null)return null;let l={type:n.type.name,attrs:i};s&&(l.content=s),e.input&&t().deleteRange(r).insertContentAt(r.from,l)}})}function jb(n){return new $n({find:n.find,handler:({state:e,range:t,match:r})=>{let o=n.replace,i=t.from,s=t.to;if(r[1]){let l=r[0].lastIndexOf(r[1]);o+=r[0].slice(l+r[1].length),i+=l;let a=i-s;a>0&&(o=r[0].slice(l-a,l)+o,i=s)}e.tr.insertText(o,i,s)}})}var Yc=class{constructor(e){this.transaction=e,this.currentStep=this.transaction.steps.length}map(e){let t=!1;return{position:this.transaction.steps.slice(this.currentStep).reduce((o,i)=>{let s=i.getMap().mapResult(o);return s.deleted&&(t=!0),s.pos},e),deleted:t}}};var $m=z.create({name:"doc",topNode:!0,content:"block+"});function Sd(n={}){return new L({view(e){return new vs(e,n)}})}var vs=class{constructor(e,t){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=t.width)!==null&&r!==void 0?r:1,this.color=t.color===!1?void 0:t.color||"black",this.class=t.class,this.handlers=["dragover","dragend","drop","dragleave"].map(o=>{let i=s=>{this[o](s)};return e.dom.addEventListener(o,i),{name:o,handler:i}})}destroy(){this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){this.cursorPos!=null&&t.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),t=!e.parent.inlineContent,r;if(t){let l=e.nodeBefore,a=e.nodeAfter;if(l||a){let c=this.editorView.nodeDOM(this.cursorPos-(l?l.nodeSize:0));if(c){let d=c.getBoundingClientRect(),u=l?d.bottom:d.top;l&&a&&(u=(u+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2),r={left:d.left,right:d.right,top:u-this.width/2,bottom:u+this.width/2}}}}if(!r){let l=this.editorView.coordsAtPos(this.cursorPos);r={left:l.left-this.width/2,right:l.left+this.width/2,top:l.top,bottom:l.bottom}}let o=this.editorView.dom.offsetParent;this.element||(this.element=o.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",t),this.element.classList.toggle("prosemirror-dropcursor-inline",!t);let i,s;if(!o||o==document.body&&getComputedStyle(o).position=="static")i=-pageXOffset,s=-pageYOffset;else{let l=o.getBoundingClientRect();i=l.left-o.scrollLeft,s=l.top-o.scrollTop}this.element.style.left=r.left-i+"px",this.element.style.top=r.top-s+"px",this.element.style.width=r.right-r.left+"px",this.element.style.height=r.bottom-r.top+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),o=r&&r.type.spec.disableDropCursor,i=typeof o=="function"?o(this.editorView,t,e):o;if(t&&!i){let s=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=Tn(this.editorView.state.doc,s,this.editorView.dragging.slice);l!=null&&(s=l)}this.setCursor(s),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){(e.target==this.editorView.dom||!this.editorView.dom.contains(e.relatedTarget))&&this.setCursor(null)}};var _m=H.create({name:"dropCursor",addOptions(){return{color:"currentColor",width:1,class:void 0}},addProseMirrorPlugins(){return[Sd(this.options)]}});var ue=class n extends E{constructor(e){super(e,e)}map(e,t){let r=e.resolve(t.map(this.head));return n.valid(r)?new n(r):E.near(r)}content(){return S.empty}eq(e){return e instanceof n&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new n(e.resolve(t.pos))}getBookmark(){return new Os(this.anchor)}static valid(e){let t=e.parent;if(t.isTextblock||!Vm(e)||!jm(e))return!1;let r=t.type.spec.allowGapCursor;if(r!=null)return r;let o=t.contentMatchAt(e.index()).defaultType;return o&&o.isTextblock}static findGapCursorFrom(e,t,r=!1){e:for(;;){if(!r&&n.valid(e))return e;let o=e.pos,i=null;for(let s=e.depth;;s--){let l=e.node(s);if(t>0?e.indexAfter(s)0){i=l.child(t>0?e.indexAfter(s):e.index(s)-1);break}else if(s==0)return null;o+=t;let a=e.doc.resolve(o);if(n.valid(a))return a}for(;;){let s=t>0?i.firstChild:i.lastChild;if(!s){if(i.isAtom&&!i.isText&&!v.isSelectable(i)){e=e.doc.resolve(o+i.nodeSize*t),r=!1;continue e}break}i=s,o+=t;let l=e.doc.resolve(o);if(n.valid(l))return l}return null}}};ue.prototype.visible=!1;ue.findFrom=ue.findGapCursorFrom;E.jsonID("gapcursor",ue);var Os=class n{constructor(e){this.pos=e}map(e){return new n(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return ue.valid(t)?new ue(t):E.near(t)}};function Vm(n){for(let e=n.depth;e>=0;e--){let t=n.index(e),r=n.node(e);if(t==0){if(r.type.spec.isolating)return!0;continue}for(let o=r.child(t-1);;o=o.lastChild){if(o.childCount==0&&!o.inlineContent||o.isAtom||o.type.spec.isolating)return!0;if(o.inlineContent)return!1}}return!0}function jm(n){for(let e=n.depth;e>=0;e--){let t=n.indexAfter(e),r=n.node(e);if(t==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let o=r.child(t);;o=o.firstChild){if(o.childCount==0&&!o.inlineContent||o.isAtom||o.type.spec.isolating)return!0;if(o.inlineContent)return!1}}return!0}function Cd(){return new L({props:{decorations:Um,createSelectionBetween(n,e,t){return e.pos==t.pos&&ue.valid(t)?new ue(t):null},handleClick:Km,handleKeyDown:Wm,handleDOMEvents:{beforeinput:Jm}}})}var Wm=sn({ArrowLeft:io("horiz",-1),ArrowRight:io("horiz",1),ArrowUp:io("vert",-1),ArrowDown:io("vert",1)});function io(n,e){let t=n=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,o,i){let s=r.selection,l=e>0?s.$to:s.$from,a=s.empty;if(s instanceof A){if(!i.endOfTextblock(t)||l.depth==0)return!1;a=!1,l=r.doc.resolve(e>0?l.after():l.before())}let c=ue.findGapCursorFrom(l,e,a);return c?(o&&o(r.tr.setSelection(new ue(c))),!0):!1}}function Km(n,e,t){if(!n||!n.editable)return!1;let r=n.state.doc.resolve(e);if(!ue.valid(r))return!1;let o=n.posAtCoords({left:t.clientX,top:t.clientY});return o&&o.inside>-1&&v.isSelectable(n.state.doc.nodeAt(o.inside))?!1:(n.dispatch(n.state.tr.setSelection(new ue(r))),!0)}function Jm(n,e){if(e.inputType!="insertCompositionText"||!(n.state.selection instanceof ue))return!1;let{$from:t}=n.state.selection,r=t.parent.contentMatchAt(t.index()).findWrapping(n.state.schema.nodes.text);if(!r)return!1;let o=x.empty;for(let s=r.length-1;s>=0;s--)o=x.from(r[s].createAndFill(null,o));let i=n.state.tr.replace(t.pos,t.pos,new S(o,0,0));return i.setSelection(A.near(i.doc.resolve(t.pos+1))),n.dispatch(i),!1}function Um(n){if(!(n.selection instanceof ue))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",q.create(n.doc,[ne.widget(n.selection.head,e,{key:"gapcursor"})])}var qm=H.create({name:"gapCursor",addProseMirrorPlugins(){return[Cd()]},extendNodeSchema(n){var e;let t={name:n.name,options:n.options,storage:n.storage};return{allowGapCursor:(e=D(C(n,"allowGapCursor",t)))!==null&&e!==void 0?e:null}}});var fo={};rt(fo,{closeHistory:()=>ng,history:()=>Is,redo:()=>uo,redoDepth:()=>sg,redoNoScroll:()=>og,undo:()=>co,undoDepth:()=>ig,undoNoScroll:()=>rg});var so=200,se=function(){};se.prototype.append=function(e){return e.length?(e=se.from(e),!this.length&&e||e.length=t?se.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))};se.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};se.prototype.forEach=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length),t<=r?this.forEachInner(e,t,r,0):this.forEachInvertedInner(e,t,r,0)};se.prototype.map=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length);var o=[];return this.forEach(function(i,s){return o.push(e(i,s))},t,r),o};se.from=function(e){return e instanceof se?e:e&&e.length?new Md(e):se.empty};var Md=function(n){function e(r){n.call(this),this.values=r}n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e;var t={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(o,i){return o==0&&i==this.length?this:new e(this.values.slice(o,i))},e.prototype.getInner=function(o){return this.values[o]},e.prototype.forEachInner=function(o,i,s,l){for(var a=i;a=s;a--)if(o(this.values[a],l+a)===!1)return!1},e.prototype.leafAppend=function(o){if(this.length+o.length<=so)return new e(this.values.concat(o.flatten()))},e.prototype.leafPrepend=function(o){if(this.length+o.length<=so)return new e(o.flatten().concat(this.values))},t.length.get=function(){return this.values.length},t.depth.get=function(){return 0},Object.defineProperties(e.prototype,t),e}(se);se.empty=new Md([]);var Gm=function(n){function e(t,r){n.call(this),this.left=t,this.right=r,this.length=t.length+r.length,this.depth=Math.max(t.depth,r.depth)+1}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(r){return rl&&this.right.forEachInner(r,Math.max(o-l,0),Math.min(this.length,i)-l,s+l)===!1)return!1},e.prototype.forEachInvertedInner=function(r,o,i,s){var l=this.left.length;if(o>l&&this.right.forEachInvertedInner(r,o-l,Math.max(i,l)-l,s+l)===!1||i=i?this.right.slice(r-i,o-i):this.left.slice(r,i).append(this.right.slice(0,o-i))},e.prototype.leafAppend=function(r){var o=this.right.leafAppend(r);if(o)return new e(this.left,o)},e.prototype.leafPrepend=function(r){var o=this.left.leafPrepend(r);if(o)return new e(o,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e}(se),Ns=se;var Ym=500,Bt=class n{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let o,i;t&&(o=this.remapping(r,this.items.length),i=o.maps.length);let s=e.tr,l,a,c=[],d=[];return this.items.forEach((u,f)=>{if(!u.step){o||(o=this.remapping(r,f+1),i=o.maps.length),i--,d.push(u);return}if(o){d.push(new He(u.map));let p=u.step.map(o.slice(i)),h;p&&s.maybeStep(p).doc&&(h=s.mapping.maps[s.mapping.maps.length-1],c.push(new He(h,void 0,void 0,c.length+d.length))),i--,h&&o.appendMap(h,i)}else s.maybeStep(u.step);if(u.selection)return l=o?u.selection.map(o.slice(i)):u.selection,a=new n(this.items.slice(0,r).append(d.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:s,selection:l}}addTransform(e,t,r,o){let i=[],s=this.eventCount,l=this.items,a=!o&&l.length?l.get(l.length-1):null;for(let d=0;dXm&&(l=Qm(l,c),s-=c),new n(l.append(i),s)}remapping(e,t){let r=new Jt;return this.items.forEach((o,i)=>{let s=o.mirrorOffset!=null&&i-o.mirrorOffset>=e?r.maps.length-o.mirrorOffset:void 0;r.appendMap(o.map,s)},e,t),r}addMaps(e){return this.eventCount==0?this:new n(this.items.append(e.map(t=>new He(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let r=[],o=Math.max(0,this.items.length-t),i=e.mapping,s=e.steps.length,l=this.eventCount;this.items.forEach(f=>{f.selection&&l--},o);let a=t;this.items.forEach(f=>{let p=i.getMirror(--a);if(p==null)return;s=Math.min(s,p);let h=i.maps[p];if(f.step){let m=e.steps[p].invert(e.docs[p]),g=f.selection&&f.selection.map(i.slice(a+1,p));g&&l++,r.push(new He(h,m,g))}else r.push(new He(h))},o);let c=[];for(let f=t;fYm&&(u=u.compress(this.items.length-r.length)),u}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),r=t.maps.length,o=[],i=0;return this.items.forEach((s,l)=>{if(l>=e)o.push(s),s.selection&&i++;else if(s.step){let a=s.step.map(t.slice(r)),c=a&&a.getMap();if(r--,c&&t.appendMap(c,r),a){let d=s.selection&&s.selection.map(t.slice(r));d&&i++;let u=new He(c.invert(),a,d),f,p=o.length-1;(f=o.length&&o[p].merge(u))?o[p]=f:o.push(u)}}else s.map&&r--},this.items.length,0),new n(Ns.from(o.reverse()),i)}};Bt.empty=new Bt(Ns.empty,0);function Qm(n,e){let t;return n.forEach((r,o)=>{if(r.selection&&e--==0)return t=o,!1}),n.slice(t)}var He=class n{constructor(e,t,r,o){this.map=e,this.step=t,this.selection=r,this.mirrorOffset=o}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new n(t.getMap().invert(),t,this.selection)}}},$e=class{constructor(e,t,r,o,i){this.done=e,this.undone=t,this.prevRanges=r,this.prevTime=o,this.prevComposition=i}},Xm=20;function Zm(n,e,t,r){let o=t.getMeta(Xe),i;if(o)return o.historyState;t.getMeta(Ed)&&(n=new $e(n.done,n.undone,null,0,-1));let s=t.getMeta("appendedTransaction");if(t.steps.length==0)return n;if(s&&s.getMeta(Xe))return s.getMeta(Xe).redo?new $e(n.done.addTransform(t,void 0,r,lo(e)),n.undone,Td(t.mapping.maps),n.prevTime,n.prevComposition):new $e(n.done,n.undone.addTransform(t,void 0,r,lo(e)),null,n.prevTime,n.prevComposition);if(t.getMeta("addToHistory")!==!1&&!(s&&s.getMeta("addToHistory")===!1)){let l=t.getMeta("composition"),a=n.prevTime==0||!s&&n.prevComposition!=l&&(n.prevTime<(t.time||0)-r.newGroupDelay||!eg(t,n.prevRanges)),c=s?Rs(n.prevRanges,t.mapping):Td(t.mapping.maps);return new $e(n.done.addTransform(t,a?e.selection.getBookmark():void 0,r,lo(e)),Bt.empty,c,t.time,l==null?n.prevComposition:l)}else return(i=t.getMeta("rebased"))?new $e(n.done.rebased(t,i),n.undone.rebased(t,i),Rs(n.prevRanges,t.mapping),n.prevTime,n.prevComposition):new $e(n.done.addMaps(t.mapping.maps),n.undone.addMaps(t.mapping.maps),Rs(n.prevRanges,t.mapping),n.prevTime,n.prevComposition)}function eg(n,e){if(!e)return!1;if(!n.docChanged)return!0;let t=!1;return n.mapping.maps[0].forEach((r,o)=>{for(let i=0;i=e[i]&&(t=!0)}),t}function Td(n){let e=[];for(let t=n.length-1;t>=0&&e.length==0;t--)n[t].forEach((r,o,i,s)=>e.push(i,s));return e}function Rs(n,e){if(!n)return null;let t=[];for(let r=0;r{let o=Xe.getState(t);if(!o||(n?o.undone:o.done).eventCount==0)return!1;if(r){let i=tg(o,t,n);i&&r(e?i.scrollIntoView():i)}return!0}}var co=ao(!1,!0),uo=ao(!0,!0),rg=ao(!1,!1),og=ao(!0,!1);function ig(n){let e=Xe.getState(n);return e?e.done.eventCount:0}function sg(n){let e=Xe.getState(n);return e?e.undone.eventCount:0}var lg=H.create({name:"history",addOptions(){return{depth:100,newGroupDelay:500}},addCommands(){return{undo:()=>({state:n,dispatch:e})=>co(n,e),redo:()=>({state:n,dispatch:e})=>uo(n,e)}},addProseMirrorPlugins(){return[Is(this.options)]},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Shift-Mod-z":()=>this.editor.commands.redo(),"Mod-y":()=>this.editor.commands.redo(),"Mod-\u044F":()=>this.editor.commands.undo(),"Shift-Mod-\u044F":()=>this.editor.commands.redo()}}});var ag=z.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:n}){return["p",O(this.options.HTMLAttributes,n),0]},addCommands(){return{setParagraph:()=>({commands:n})=>n.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}});var cg=z.create({name:"hardBreak",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,linebreakReplacement:!0,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:n}){return["br",O(this.options.HTMLAttributes,n)]},renderText(){return` +`},addCommands(){return{setHardBreak:()=>({commands:n,chain:e,state:t,editor:r})=>n.first([()=>n.exitCode(),()=>n.command(()=>{let{selection:o,storedMarks:i}=t;if(o.$from.parent.type.spec.isolating)return!1;let{keepMarks:s}=this.options,{splittableMarks:l}=r.extensionManager,a=i||o.$to.parentOffset&&o.$from.marks();return e().insertContent({type:this.name}).command(({tr:c,dispatch:d})=>{if(d&&a&&s){let u=a.filter(f=>l.includes(f.type.name));c.ensureMarks(u)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}});var dg=z.create({name:"text",group:"inline"});var ug=/^\s*>\s$/,fg=z.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:n}){return["blockquote",O(this.options.HTMLAttributes,n),0]},addCommands(){return{setBlockquote:()=>({commands:n})=>n.wrapIn(this.name),toggleBlockquote:()=>({commands:n})=>n.toggleWrap(this.name),unsetBlockquote:()=>({commands:n})=>n.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[mt({find:ug,type:this.type})]}});var pg=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,hg=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,mg=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,gg=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,yg=J.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:n=>n.style.fontWeight!=="normal"&&null},{style:"font-weight=400",clearMark:n=>n.type.name===this.name},{style:"font-weight",getAttrs:n=>/^(bold(er)?|[5-9]\d{2,})$/.test(n)&&null}]},renderHTML({HTMLAttributes:n}){return["strong",O(this.options.HTMLAttributes,n),0]},addCommands(){return{setBold:()=>({commands:n})=>n.setMark(this.name),toggleBold:()=>({commands:n})=>n.toggleMark(this.name),unsetBold:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[Ee({find:pg,type:this.type}),Ee({find:mg,type:this.type})]},addPasteRules(){return[be({find:hg,type:this.type}),be({find:gg,type:this.type})]}});var bg="listItem",vd="textStyle",Od=/^\s*([-+*])\s$/,xg=z.create({name:"bulletList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:"ul"}]},renderHTML({HTMLAttributes:n}){return["ul",O(this.options.HTMLAttributes,n),0]},addCommands(){return{toggleBulletList:()=>({commands:n,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(bg,this.editor.getAttributes(vd)).run():n.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let n=mt({find:Od,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(n=mt({find:Od,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(vd),editor:this.editor})),[n]}});var kg=z.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(n=>({tag:`h${n}`,attrs:{level:n}}))},renderHTML({node:n,HTMLAttributes:e}){return[`h${this.options.levels.includes(n.attrs.level)?n.attrs.level:this.options.levels[0]}`,O(this.options.HTMLAttributes,e),0]},addCommands(){return{setHeading:n=>({commands:e})=>this.options.levels.includes(n.level)?e.setNode(this.name,n):!1,toggleHeading:n=>({commands:e})=>this.options.levels.includes(n.level)?e.toggleNode(this.name,"paragraph",n):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((n,e)=>N(b({},n),{[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}),{})},addInputRules(){return this.options.levels.map(n=>Vn({find:new RegExp(`^(#{${Math.min(...this.options.levels)},${n}})\\s$`),type:this.type,getAttributes:{level:n}}))}});var wg=z.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{}}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:n}){return["hr",O(this.options.HTMLAttributes,n)]},addCommands(){return{setHorizontalRule:()=>({chain:n,state:e})=>{let{selection:t}=e,{$from:r,$to:o}=t,i=n();return r.parentOffset===0?i.insertContentAt({from:Math.max(r.pos-1,0),to:o.pos},{type:this.name}):pd(t)?i.insertContentAt(o.pos,{type:this.name}):i.insertContent({type:this.name}),i.command(({tr:s,dispatch:l})=>{var a;if(l){let{$to:c}=s.selection,d=c.end();if(c.nodeAfter)c.nodeAfter.isTextblock?s.setSelection(A.create(s.doc,c.pos+1)):c.nodeAfter.isBlock?s.setSelection(v.create(s.doc,c.pos)):s.setSelection(A.create(s.doc,c.pos));else{let u=(a=c.parent.type.contentMatch.defaultType)===null||a===void 0?void 0:a.create();u&&(s.insert(d,u),s.setSelection(A.create(s.doc,d+1)))}s.scrollIntoView()}return!0}).run()}}},addInputRules(){return[oo({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}});var Sg=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,Cg=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,Mg=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,Tg=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,Ag=J.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:n=>n.style.fontStyle!=="normal"&&null},{style:"font-style=normal",clearMark:n=>n.type.name===this.name},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:n}){return["em",O(this.options.HTMLAttributes,n),0]},addCommands(){return{setItalic:()=>({commands:n})=>n.setMark(this.name),toggleItalic:()=>({commands:n})=>n.toggleMark(this.name),unsetItalic:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[Ee({find:Sg,type:this.type}),Ee({find:Mg,type:this.type})]},addPasteRules(){return[be({find:Cg,type:this.type}),be({find:Tg,type:this.type})]}});var Eg=z.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:n}){return["li",O(this.options.HTMLAttributes,n),0]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}});var vg=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,Og=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,Ng=J.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:n=>n.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:n}){return["s",O(this.options.HTMLAttributes,n),0]},addCommands(){return{setStrike:()=>({commands:n})=>n.setMark(this.name),toggleStrike:()=>({commands:n})=>n.toggleMark(this.name),unsetStrike:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[Ee({find:vg,type:this.type})]},addPasteRules(){return[be({find:Og,type:this.type})]}});var Rg=J.create({name:"subscript",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"sub"},{style:"vertical-align",getAttrs(n){return n!=="sub"?!1:null}}]},renderHTML({HTMLAttributes:n}){return["sub",O(this.options.HTMLAttributes,n),0]},addCommands(){return{setSubscript:()=>({commands:n})=>n.setMark(this.name),toggleSubscript:()=>({commands:n})=>n.toggleMark(this.name),unsetSubscript:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-,":()=>this.editor.commands.toggleSubscript()}}});var Dg=J.create({name:"superscript",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"sup"},{style:"vertical-align",getAttrs(n){return n!=="super"?!1:null}}]},renderHTML({HTMLAttributes:n}){return["sup",O(this.options.HTMLAttributes,n),0]},addCommands(){return{setSuperscript:()=>({commands:n})=>n.setMark(this.name),toggleSuperscript:()=>({commands:n})=>n.toggleMark(this.name),unsetSuperscript:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-.":()=>this.editor.commands.toggleSuperscript()}}});var Ig=J.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:n=>n.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:n}){return["u",O(this.options.HTMLAttributes,n),0]},addCommands(){return{setUnderline:()=>({commands:n})=>n.setMark(this.name),toggleUnderline:()=>({commands:n})=>n.toggleMark(this.name),unsetUnderline:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}});var Pg=/(^|[^`])`([^`]+)`(?!`)/,Lg=/(^|[^`])`([^`]+)`(?!`)/g,zg=J.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:n}){return["code",O(this.options.HTMLAttributes,n),0]},addCommands(){return{setCode:()=>({commands:n})=>n.setMark(this.name),toggleCode:()=>({commands:n})=>n.toggleMark(this.name),unsetCode:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[Ee({find:Pg,type:this.type})]},addPasteRules(){return[be({find:Lg,type:this.type})]}});var Bg=/^```([a-z]+)?[\s\n]$/,Fg=/^~~~([a-z]+)?[\s\n]$/,Hg=z.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:n=>{var e;let{languageClassPrefix:t}=this.options,i=[...((e=n.firstElementChild)===null||e===void 0?void 0:e.classList)||[]].filter(s=>s.startsWith(t)).map(s=>s.replace(t,""))[0];return i||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:n,HTMLAttributes:e}){return["pre",O(this.options.HTMLAttributes,e),["code",{class:n.attrs.language?this.options.languageClassPrefix+n.attrs.language:null},0]]},addCommands(){return{setCodeBlock:n=>({commands:e})=>e.setNode(this.name,n),toggleCodeBlock:n=>({commands:e})=>e.toggleNode(this.name,"paragraph",n)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{let{empty:n,$anchor:e}=this.editor.state.selection,t=e.pos===1;return!n||e.parent.type.name!==this.name?!1:t||!e.parent.textContent.length?this.editor.commands.clearNodes():!1},Enter:({editor:n})=>{if(!this.options.exitOnTripleEnter)return!1;let{state:e}=n,{selection:t}=e,{$from:r,empty:o}=t;if(!o||r.parent.type!==this.type)return!1;let i=r.parentOffset===r.parent.nodeSize-2,s=r.parent.textContent.endsWith(` -`);return!i||!s?!1:n.chain().command(({tr:l})=>(l.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowDown:({editor:n})=>{if(!this.options.exitOnArrowDown)return!1;let{state:e}=n,{selection:t,doc:r}=e,{$from:o,empty:i}=t;if(!i||o.parent.type!==this.type||!(o.parentOffset===o.parent.nodeSize-2))return!1;let l=o.after();return l===void 0?!1:r.nodeAt(l)?n.commands.command(({tr:c})=>(c.setSelection(E.near(r.resolve(l))),!0)):n.commands.exitCode()}}},addInputRules(){return[Vn({find:Bg,type:this.type,getAttributes:n=>({language:n[1]})}),Vn({find:zg,type:this.type,getAttributes:n=>({language:n[1]})})]},addProseMirrorPlugins(){return[new L({key:new j("codeBlockVSCodeHandler"),props:{handlePaste:(n,e)=>{if(!e.clipboardData||this.editor.isActive(this.type.name))return!1;let t=e.clipboardData.getData("text/plain"),r=e.clipboardData.getData("vscode-editor-data"),o=r?JSON.parse(r):void 0,i=o==null?void 0:o.mode;if(!t||!i)return!1;let{tr:s,schema:l}=n.state,a=l.text(t.replace(/\r\n?/g,` -`));return s.replaceSelectionWith(this.type.create({language:i},a)),s.selection.$from.parent.type!==this.type&&s.setSelection(T.near(s.doc.resolve(Math.max(0,s.selection.from-2)))),s.setMeta("paste",!0),n.dispatch(s),!0}}})]}});var Hg=n=>{if(!n.children.length)return;let e=n.querySelectorAll("span");e&&e.forEach(t=>{var r,o;let i=t.getAttribute("style"),s=(o=(r=t.parentElement)===null||r===void 0?void 0:r.closest("span"))===null||o===void 0?void 0:o.getAttribute("style");t.setAttribute("style",`${s};${i}`)})},$g=J.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!1}},parseHTML(){return[{tag:"span",getAttrs:n=>n.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&Hg(n),{}):!1}]},renderHTML({HTMLAttributes:n}){return["span",v(this.options.HTMLAttributes,n),0]},addCommands(){return{removeEmptyTextStyle:()=>({tr:n})=>{let{selection:e}=n;return n.doc.nodesBetween(e.from,e.to,(t,r)=>{if(t.isTextblock)return!0;t.marks.filter(o=>o.type===this.type).some(o=>Object.values(o.attrs).some(i=>!!i))||n.removeMark(r,r+t.nodeSize,this.type)}),!0}}}});var _g=H.create({name:"color",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{color:{default:null,parseHTML:n=>{var e;return(e=n.style.color)===null||e===void 0?void 0:e.replace(/['"]+/g,"")},renderHTML:n=>n.color?{style:`color: ${n.color}`}:{}}}}]},addCommands(){return{setColor:n=>({chain:e})=>e().setMark("textStyle",{color:n}).run(),unsetColor:()=>({chain:n})=>n().setMark("textStyle",{color:null}).removeEmptyTextStyle().run()}}});var Vg=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/,jg=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g,Wg=J.create({name:"highlight",addOptions(){return{multicolor:!1,HTMLAttributes:{}}},addAttributes(){return this.options.multicolor?{color:{default:null,parseHTML:n=>n.getAttribute("data-color")||n.style.backgroundColor,renderHTML:n=>n.color?{"data-color":n.color,style:`background-color: ${n.color}; color: inherit`}:{}}}:{}},parseHTML(){return[{tag:"mark"}]},renderHTML({HTMLAttributes:n}){return["mark",v(this.options.HTMLAttributes,n),0]},addCommands(){return{setHighlight:n=>({commands:e})=>e.setMark(this.name,n),toggleHighlight:n=>({commands:e})=>e.toggleMark(this.name,n),unsetHighlight:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-h":()=>this.editor.commands.toggleHighlight()}},addInputRules(){return[Ee({find:Vg,type:this.type})]},addPasteRules(){return[be({find:jg,type:this.type})]}});var Kg=H.create({name:"textAlign",addOptions(){return{types:[],alignments:["left","center","right","justify"],defaultAlignment:null}},addGlobalAttributes(){return[{types:this.options.types,attributes:{textAlign:{default:this.options.defaultAlignment,parseHTML:n=>{let e=n.style.textAlign;return this.options.alignments.includes(e)?e:this.options.defaultAlignment},renderHTML:n=>n.textAlign?{style:`text-align: ${n.textAlign}`}:{}}}}]},addCommands(){return{setTextAlign:n=>({commands:e})=>this.options.alignments.includes(n)?this.options.types.map(t=>e.updateAttributes(t,{textAlign:n})).every(t=>t):!1,unsetTextAlign:()=>({commands:n})=>this.options.types.map(e=>n.resetAttributes(e,"textAlign")).every(e=>e)}},addKeyboardShortcuts(){return{"Mod-Shift-l":()=>this.editor.commands.setTextAlign("left"),"Mod-Shift-e":()=>this.editor.commands.setTextAlign("center"),"Mod-Shift-r":()=>this.editor.commands.setTextAlign("right"),"Mod-Shift-j":()=>this.editor.commands.setTextAlign("justify")}}});var Ls,Bs;if(typeof WeakMap!="undefined"){let n=new WeakMap;Ls=e=>n.get(e),Bs=(e,t)=>(n.set(e,t),t)}else{let n=[],t=0;Ls=r=>{for(let o=0;o(t==10&&(t=0),n[t++]=r,n[t++]=o)}var G=class{constructor(n,e,t,r){this.width=n,this.height=e,this.map=t,this.problems=r}findCell(n){for(let e=0;e=t){(i||(i=[])).push({type:"overlong_rowspan",pos:d,n:y-A});break}let I=o+A*e;for(let M=0;Mr&&(i+=c.attrs.colspan)}}for(let s=0;s1&&(t=!0)}e==-1?e=i:e!=i&&(e=Math.max(e,i))}return e}function qg(n,e,t){n.problems||(n.problems=[]);let r={};for(let o=0;o0;e--)if(n.node(e).type.spec.tableRole=="row")return n.node(0).resolve(n.before(e+1));return null}function Yg(n){for(let e=n.depth;e>0;e--){let t=n.node(e).type.spec.tableRole;if(t==="cell"||t==="header_cell")return n.node(e)}return null}function De(n){let e=n.selection.$head;for(let t=e.depth;t>0;t--)if(e.node(t).type.spec.tableRole=="row")return!0;return!1}function bo(n){let e=n.selection;if("$anchorCell"in e&&e.$anchorCell)return e.$anchorCell.pos>e.$headCell.pos?e.$anchorCell:e.$headCell;if("node"in e&&e.node&&e.node.type.spec.tableRole=="cell")return e.$anchor;let t=cn(e.$head)||Qg(e.$head);if(t)return t;throw new RangeError(`No cell found around position ${e.head}`)}function Qg(n){for(let e=n.nodeAfter,t=n.pos;e;e=e.firstChild,t++){let r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return n.doc.resolve(t)}for(let e=n.nodeBefore,t=n.pos;e;e=e.lastChild,t--){let r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return n.doc.resolve(t-e.nodeSize)}}function zs(n){return n.parent.type.spec.tableRole=="row"&&!!n.nodeAfter}function Xg(n){return n.node(0).resolve(n.pos+n.nodeAfter.nodeSize)}function $s(n,e){return n.depth==e.depth&&n.pos>=e.start(-1)&&n.pos<=e.end(-1)}function Fd(n,e,t){let r=n.node(-1),o=G.get(r),i=n.start(-1),s=o.nextCell(n.pos-i,e,t);return s==null?null:n.node(0).resolve(i+s)}function Ft(n,e,t=1){let r=N(b({},n),{colspan:n.colspan-t});return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(e,t),r.colwidth.some(o=>o>0)||(r.colwidth=null)),r}function Hd(n,e,t=1){let r=N(b({},n),{colspan:n.colspan+t});if(r.colwidth){r.colwidth=r.colwidth.slice();for(let o=0;od!=t.pos-i);a.unshift(t.pos-i);let c=a.map(d=>{let u=r.nodeAt(d);if(!u)throw RangeError(`No cell with offset ${d} found`);let f=i+d+1;return new Ke(l.resolve(f),l.resolve(f+u.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=e,this.$headCell=t}map(e,t){let r=e.resolve(t.map(this.$anchorCell.pos)),o=e.resolve(t.map(this.$headCell.pos));if(zs(r)&&zs(o)&&$s(r,o)){let i=this.$anchorCell.node(-1)!=r.node(-1);return i&&this.isRowSelection()?Ze.rowSelection(r,o):i&&this.isColSelection()?Ze.colSelection(r,o):new Ze(r,o)}return T.between(r,o)}content(){let e=this.$anchorCell.node(-1),t=G.get(e),r=this.$anchorCell.start(-1),o=t.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),i={},s=[];for(let a=o.top;a0||g>0){let y=p.attrs;if(m>0&&(y=Ft(y,0,m)),g>0&&(y=Ft(y,y.colspan-g,g)),h.lefto.bottom){let y=N(b({},p.attrs),{rowspan:Math.min(h.bottom,o.bottom)-Math.max(h.top,o.top)});h.top0)return!1;let r=e+this.$anchorCell.nodeAfter.attrs.rowspan,o=t+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(r,o)==this.$headCell.node(-1).childCount}static colSelection(e,t=e){let r=e.node(-1),o=G.get(r),i=e.start(-1),s=o.findCell(e.pos-i),l=o.findCell(t.pos-i),a=e.node(0);return s.top<=l.top?(s.top>0&&(e=a.resolve(i+o.map[s.left])),l.bottom0&&(t=a.resolve(i+o.map[l.left])),s.bottom0)return!1;let s=o+this.$anchorCell.nodeAfter.attrs.colspan,l=i+this.$headCell.nodeAfter.attrs.colspan;return Math.max(s,l)==t.width}eq(e){return e instanceof Ze&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,t=e){let r=e.node(-1),o=G.get(r),i=e.start(-1),s=o.findCell(e.pos-i),l=o.findCell(t.pos-i),a=e.node(0);return s.left<=l.left?(s.left>0&&(e=a.resolve(i+o.map[s.top*o.width])),l.right0&&(t=a.resolve(i+o.map[l.top*o.width])),s.right{e.push(ne.node(r,r+t.nodeSize,{class:"selectedCell"}))}),q.create(n.doc,e)}function ny({$from:n,$to:e}){if(n.pos==e.pos||n.pos=0&&!(n.after(o+1)=0&&!(e.before(i+1)>e.start(i));i--,r--);return t==r&&/row|table/.test(n.node(o).type.spec.tableRole)}function ry({$from:n,$to:e}){let t,r;for(let o=n.depth;o>0;o--){let i=n.node(o);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){t=i;break}}for(let o=e.depth;o>0;o--){let i=e.node(o);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){r=i;break}}return t!==r&&e.parentOffset===0}function oy(n,e,t){let r=(e||n).selection,o=(e||n).doc,i,s;if(r instanceof O&&(s=r.node.type.spec.tableRole)){if(s=="cell"||s=="header_cell")i=V.create(o,r.from);else if(s=="row"){let l=o.resolve(r.from+1);i=V.rowSelection(l,l)}else if(!t){let l=G.get(r.node),a=r.from+1,c=a+l.map[l.width*l.height-1];i=V.create(o,a+1,c)}}else r instanceof T&&ny(r)?i=T.create(o,r.from):r instanceof T&&ry(r)&&(i=T.create(o,r.$from.start(),r.$from.end()));return i&&(e||(e=n.tr)).setSelection(i),e}var iy=new j("fix-tables");function _d(n,e,t,r){let o=n.childCount,i=e.childCount;e:for(let s=0,l=0;s{o.type.spec.tableRole=="table"&&(t=sy(n,o,i,t))};return e?e.doc!=n.doc&&_d(e.doc,n.doc,0,r):n.doc.descendants(r),t}function sy(n,e,t,r){let o=G.get(e);if(!o.problems)return r;r||(r=n.tr);let i=[];for(let a=0;a0){let h="cell";d.firstChild&&(h=d.firstChild.type.spec.tableRole);let p=[];for(let g=0;g0?-1:0;Zg(e,r,o+i)&&(i=o==0||o==e.width?null:0);for(let s=0;s0&&o0&&e.map[l-1]==a||o0?-1:0;ay(e,r,o+a)&&(a=o==0||o==e.height?null:0);for(let c=0,d=e.width*o;c0&&o0&&u==e.map[d-e.width]){let f=t.nodeAt(u).attrs;n.setNodeMarkup(n.mapping.slice(l).map(u+r),null,N(b({},f),{rowspan:f.rowspan-1})),c+=f.colspan-1}else if(o0&&t[i]==t[i-1]||r.right0&&t[o]==t[o-n]||r.bottomt[r.type.spec.tableRole])(n,e)}function uy(n){return(e,t)=>{var r;let o=e.selection,i,s;if(o instanceof V){if(o.$anchorCell.pos!=o.$headCell.pos)return!1;i=o.$anchorCell.nodeAfter,s=o.$anchorCell.pos}else{if(i=Yg(o.$from),!i)return!1;s=(r=cn(o.$from))==null?void 0:r.pos}if(i==null||s==null||i.attrs.colspan==1&&i.attrs.rowspan==1)return!1;if(t){let l=i.attrs,a=[],c=l.colwidth;l.rowspan>1&&(l=N(b({},l),{rowspan:1})),l.colspan>1&&(l=N(b({},l),{colspan:1}));let d=_e(e),u=e.tr;for(let h=0;h{s.attrs[n]!==e&&i.setNodeMarkup(l,null,N(b({},s.attrs),{[n]:e}))}):i.setNodeMarkup(o.pos,null,N(b({},o.nodeAfter.attrs),{[n]:e})),r(i)}return!0}}function fy(n){return function(e,t){if(!De(e))return!1;if(t){let r=fe(e.schema),o=_e(e),i=e.tr,s=o.map.cellsInRect(n=="column"?{left:o.left,top:0,right:o.right,bottom:o.map.height}:n=="row"?{left:0,top:o.top,right:o.map.width,bottom:o.bottom}:o),l=s.map(a=>o.table.nodeAt(a));for(let a=0;a{let p=h+i.tableStart,m=s.doc.nodeAt(p);m&&s.setNodeMarkup(p,f,m.attrs)}),r(s)}return!0}}var Sx=dn("row",{useDeprecatedLogic:!0}),wx=dn("column",{useDeprecatedLogic:!0}),Qd=dn("cell",{useDeprecatedLogic:!0});function hy(n,e){if(e<0){let t=n.nodeBefore;if(t)return n.pos-t.nodeSize;for(let r=n.index(-1)-1,o=n.before();r>=0;r--){let i=n.node(-1).child(r),s=i.lastChild;if(s)return o-1-s.nodeSize;o-=i.nodeSize}}else{if(n.index()0;r--)if(t.node(r).type.spec.tableRole=="table")return e&&e(n.tr.delete(t.before(r),t.after(r)).scrollIntoView()),!0;return!1}function ho(n,e){let t=n.selection;if(!(t instanceof V))return!1;if(e){let r=n.tr,o=fe(n.schema).cell.createAndFill().content;t.forEachCell((i,s)=>{i.content.eq(o)||r.replace(r.mapping.map(s+1),r.mapping.map(s+i.nodeSize-1),new w(o,0,0))}),r.docChanged&&e(r)}return!0}function py(n){if(!n.size)return null;let{content:e,openStart:t,openEnd:r}=n;for(;e.childCount==1&&(t>0&&r>0||e.child(0).type.spec.tableRole=="table");)t--,r--,e=e.child(0).content;let o=e.child(0),i=o.type.spec.tableRole,s=o.type.schema,l=[];if(i=="row")for(let a=0;a=0;s--){let{rowspan:l,colspan:a}=i.child(s).attrs;for(let c=o;c=e.length&&e.push(x.empty),t[o]r&&(f=f.type.createChecked(Ft(f.attrs,f.attrs.colspan,d+f.attrs.colspan-r),f.content)),c.push(f),d+=f.attrs.colspan;for(let h=1;ho&&(u=u.type.create(N(b({},u.attrs),{rowspan:Math.max(1,o-u.attrs.rowspan)}),u.content)),a.push(u)}i.push(x.from(a))}t=i,e=o}return{width:n,height:e,rows:t}}function yy(n,e,t,r,o,i,s){let l=n.doc.type.schema,a=fe(l),c,d;if(o>e.width)for(let u=0,f=0;ue.height){let u=[];for(let p=0,m=(e.height-1)*e.width;p=e.width?!1:t.nodeAt(e.map[m+p]).type==a.header_cell;u.push(g?d||(d=a.header_cell.createAndFill()):c||(c=a.cell.createAndFill()))}let f=a.row.create(null,x.from(u)),h=[];for(let p=e.height;p{if(!o)return!1;let i=t.selection;if(i instanceof V)return go(t,r,E.near(i.$headCell,e));if(n!="horiz"&&!i.empty)return!1;let s=Zd(o,n,e);if(s==null)return!1;if(n=="horiz")return go(t,r,E.near(t.doc.resolve(i.head+e),e));{let l=t.doc.resolve(s),a=Fd(l,n,e),c;return a?c=E.near(a,1):e<0?c=E.near(t.doc.resolve(l.before(-1)),-1):c=E.near(t.doc.resolve(l.after(-1)),1),go(t,r,c)}}}function mo(n,e){return(t,r,o)=>{if(!o)return!1;let i=t.selection,s;if(i instanceof V)s=i;else{let a=Zd(o,n,e);if(a==null)return!1;s=new V(t.doc.resolve(a))}let l=Fd(s.$headCell,n,e);return l?go(t,r,new V(s.$anchorCell,l)):!1}}function xy(n,e){let t=n.state.doc,r=cn(t.resolve(e));return r?(n.dispatch(n.state.tr.setSelection(new V(r))),!0):!1}function ky(n,e,t){if(!De(n.state))return!1;let r=py(t),o=n.state.selection;if(o instanceof V){r||(r={width:1,height:1,rows:[x.from(Fs(fe(n.state.schema).cell,t))]});let i=o.$anchorCell.node(-1),s=o.$anchorCell.start(-1),l=G.get(i).rectBetween(o.$anchorCell.pos-s,o.$headCell.pos-s);return r=gy(r,l.right-l.left,l.bottom-l.top),Id(n.state,n.dispatch,s,l,r),!0}else if(r){let i=bo(n.state),s=i.start(-1);return Id(n.state,n.dispatch,s,G.get(i.node(-1)).findCell(i.pos-s),r),!0}else return!1}function Sy(n,e){var t;if(e.ctrlKey||e.metaKey)return;let r=Pd(n,e.target),o;if(e.shiftKey&&n.state.selection instanceof V)i(n.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&r&&(o=cn(n.state.selection.$anchor))!=null&&((t=Ps(n,e))==null?void 0:t.pos)!=o.pos)i(o,e),e.preventDefault();else if(!r)return;function i(a,c){let d=Ps(n,c),u=gt.getState(n.state)==null;if(!d||!$s(a,d))if(u)d=a;else return;let f=new V(a,d);if(u||!n.state.selection.eq(f)){let h=n.state.tr.setSelection(f);u&&h.setMeta(gt,a.pos),n.dispatch(h)}}function s(){n.root.removeEventListener("mouseup",s),n.root.removeEventListener("dragstart",s),n.root.removeEventListener("mousemove",l),gt.getState(n.state)!=null&&n.dispatch(n.state.tr.setMeta(gt,-1))}function l(a){let c=a,d=gt.getState(n.state),u;if(d!=null)u=n.state.doc.resolve(d);else if(Pd(n,c.target)!=r&&(u=Ps(n,e),!u))return s();u&&i(u,c)}n.root.addEventListener("mouseup",s),n.root.addEventListener("dragstart",s),n.root.addEventListener("mousemove",l)}function Zd(n,e,t){if(!(n.state.selection instanceof T))return null;let{$head:r}=n.state.selection;for(let o=r.depth-1;o>=0;o--){let i=r.node(o);if((t<0?r.index(o):r.indexAfter(o))!=(t<0?0:i.childCount))return null;if(i.type.spec.tableRole=="cell"||i.type.spec.tableRole=="header_cell"){let l=r.before(o),a=e=="vert"?t>0?"down":"up":t>0?"right":"left";return n.endOfTextblock(a)?l:null}}return null}function Pd(n,e){for(;e&&e!=n.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function Ps(n,e){let t=n.posAtCoords({left:e.clientX,top:e.clientY});return t&&t?cn(n.state.doc.resolve(t.pos)):null}var wy=class{constructor(n,e){this.node=n,this.defaultCellMinWidth=e,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",`${e}px`),this.colgroup=this.table.appendChild(document.createElement("colgroup")),Hs(n,this.colgroup,this.table,e),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(n){return n.type!=this.node.type?!1:(this.node=n,Hs(n,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(n){return n.type=="attributes"&&(n.target==this.table||this.colgroup.contains(n.target))}};function Hs(n,e,t,r,o,i){var s;let l=0,a=!0,c=e.firstChild,d=n.firstChild;if(d){for(let u=0,f=0;unew r(f,t,h)),new Cy(-1,!1)},apply(s,l){return l.apply(s)}},props:{attributes:s=>{let l=we.getState(s);return l&&l.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(s,l)=>{My(s,l,n,o)},mouseleave:s=>{Ay(s)},mousedown:(s,l)=>{Ty(s,l,e,t)}},decorations:s=>{let l=we.getState(s);if(l&&l.activeHandle>-1)return Ry(s,l.activeHandle)},nodeViews:{}}});return i}var Cy=class yo{constructor(e,t){this.activeHandle=e,this.dragging=t}apply(e){let t=this,r=e.getMeta(we);if(r&&r.setHandle!=null)return new yo(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new yo(t.activeHandle,r.setDragging);if(t.activeHandle>-1&&e.docChanged){let o=e.mapping.map(t.activeHandle,-1);return zs(e.doc.resolve(o))||(o=-1),new yo(o,t.dragging)}return t}};function My(n,e,t,r){if(!n.editable)return;let o=we.getState(n.state);if(o&&!o.dragging){let i=Oy(e.target),s=-1;if(i){let{left:l,right:a}=i.getBoundingClientRect();e.clientX-l<=t?s=Ld(n,e,"left",t):a-e.clientX<=t&&(s=Ld(n,e,"right",t))}if(s!=o.activeHandle){if(!r&&s!==-1){let l=n.state.doc.resolve(s),a=l.node(-1),c=G.get(a),d=l.start(-1);if(c.colCount(l.pos-d)+l.nodeAfter.attrs.colspan-1==c.width-1)return}tu(n,s)}}}function Ay(n){if(!n.editable)return;let e=we.getState(n.state);e&&e.activeHandle>-1&&!e.dragging&&tu(n,-1)}function Ty(n,e,t,r){var o;if(!n.editable)return!1;let i=(o=n.dom.ownerDocument.defaultView)!=null?o:window,s=we.getState(n.state);if(!s||s.activeHandle==-1||s.dragging)return!1;let l=n.state.doc.nodeAt(s.activeHandle),a=Ey(n,s.activeHandle,l.attrs);n.dispatch(n.state.tr.setMeta(we,{setDragging:{startX:e.clientX,startWidth:a}}));function c(u){i.removeEventListener("mouseup",c),i.removeEventListener("mousemove",d);let f=we.getState(n.state);f!=null&&f.dragging&&(vy(n,f.activeHandle,Bd(f.dragging,u,t)),n.dispatch(n.state.tr.setMeta(we,{setDragging:null})))}function d(u){if(!u.which)return c(u);let f=we.getState(n.state);if(f&&f.dragging){let h=Bd(f.dragging,u,t);zd(n,f.activeHandle,h,r)}}return zd(n,s.activeHandle,a,r),i.addEventListener("mouseup",c),i.addEventListener("mousemove",d),e.preventDefault(),!0}function Ey(n,e,{colspan:t,colwidth:r}){let o=r&&r[r.length-1];if(o)return o;let i=n.domAtPos(e),l=i.node.childNodes[i.offset].offsetWidth,a=t;if(r)for(let c=0;c{let r=n.nodes[t];r.spec.tableRole&&(e[r.spec.tableRole]=r)}),n.cached.tableNodeTypes=e,e}function Py(n,e,t,r,o){let i=Iy(n),s=[],l=[];for(let c=0;c{let{selection:e}=n.state;if(!Ly(e))return!1;let t=0,r=Ms(e.ranges[0].$from,i=>i.type.name==="table");return r==null||r.node.descendants(i=>{if(i.type.name==="table")return!1;["tableCell","tableHeader"].includes(i.type.name)&&(t+=1)}),t===e.ranges.length?(n.commands.deleteTable(),!0):!1},By=B.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,handleWidth:5,cellMinWidth:25,View:Js,lastColumnResizable:!0,allowTableNodeSelection:!1}},content:"tableRow+",tableRole:"table",isolating:!0,group:"block",parseHTML(){return[{tag:"table"}]},renderHTML({node:n,HTMLAttributes:e}){let{colgroup:t,tableWidth:r,tableMinWidth:o}=Dy(n,this.options.cellMinWidth);return["table",v(this.options.HTMLAttributes,e,{style:r?`width: ${r}`:`min-width: ${o}`}),t,["tbody",0]]},addCommands(){return{insertTable:({rows:n=3,cols:e=3,withHeaderRow:t=!0}={})=>({tr:r,dispatch:o,editor:i})=>{let s=Py(i.schema,n,e,t);if(o){let l=r.selection.from+1;r.replaceSelectionWith(s).scrollIntoView().setSelection(T.near(r.doc.resolve(l)))}return!0},addColumnBefore:()=>({state:n,dispatch:e})=>jd(n,e),addColumnAfter:()=>({state:n,dispatch:e})=>Wd(n,e),deleteColumn:()=>({state:n,dispatch:e})=>Kd(n,e),addRowBefore:()=>({state:n,dispatch:e})=>Ud(n,e),addRowAfter:()=>({state:n,dispatch:e})=>qd(n,e),deleteRow:()=>({state:n,dispatch:e})=>Gd(n,e),deleteTable:()=>({state:n,dispatch:e})=>Xd(n,e),mergeCells:()=>({state:n,dispatch:e})=>Vs(n,e),splitCell:()=>({state:n,dispatch:e})=>js(n,e),toggleHeaderColumn:()=>({state:n,dispatch:e})=>dn("column")(n,e),toggleHeaderRow:()=>({state:n,dispatch:e})=>dn("row")(n,e),toggleHeaderCell:()=>({state:n,dispatch:e})=>Qd(n,e),mergeOrSplit:()=>({state:n,dispatch:e})=>Vs(n,e)?!0:js(n,e),setCellAttribute:(n,e)=>({state:t,dispatch:r})=>Yd(n,e)(t,r),goToNextCell:()=>({state:n,dispatch:e})=>Ws(1)(n,e),goToPreviousCell:()=>({state:n,dispatch:e})=>Ws(-1)(n,e),fixTables:()=>({state:n,dispatch:e})=>(e&&_s(n),!0),setCellSelection:n=>({tr:e,dispatch:t})=>{if(t){let r=V.create(e.doc,n.anchorCell,n.headCell);e.setSelection(r)}return!0}}},addKeyboardShortcuts(){return{Tab:()=>this.editor.commands.goToNextCell()?!0:this.editor.can().addRowAfter()?this.editor.chain().addRowAfter().goToNextCell().run():!1,"Shift-Tab":()=>this.editor.commands.goToPreviousCell(),Backspace:xo,"Mod-Backspace":xo,Delete:xo,"Mod-Delete":xo}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[eu({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],nu({allowTableNodeSelection:this.options.allowTableNodeSelection})]},extendNodeSchema(n){let e={name:n.name,options:n.options,storage:n.storage};return{tableRole:D(C(n,"tableRole",e))}}});var zy=B.create({name:"tableCell",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:n=>{let e=n.getAttribute("colwidth");return e?e.split(",").map(r=>parseInt(r,10)):null}}}},tableRole:"cell",isolating:!0,parseHTML(){return[{tag:"td"}]},renderHTML({HTMLAttributes:n}){return["td",v(this.options.HTMLAttributes,n),0]}});var Fy=B.create({name:"tableHeader",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:n=>{let e=n.getAttribute("colwidth");return e?e.split(",").map(r=>parseInt(r,10)):null}}}},tableRole:"header_cell",isolating:!0,parseHTML(){return[{tag:"th"}]},renderHTML({HTMLAttributes:n}){return["th",v(this.options.HTMLAttributes,n),0]}});var Hy=B.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:n}){return["tr",v(this.options.HTMLAttributes,n),0]}});var W=(n,e=null,t=[])=>{let r=document.createElement(n);if(r.append(...t),e)for(let[o,i]of Object.entries(e))/^data-|^aria-|^role/.test(o)?r.setAttribute(o,i):r[o]=i;return r},$=window.gettext||(n=>n),$y=(n,e,t)=>{let r=W("label",{textContent:e.title||n}),o=t||e.default||"",i;if(e.type==="boolean")return W("label",{},[W("input",{name:n,type:"checkbox",checked:!!o}),e.title||n]);if(e.format==="textarea")i=W("textarea",{name:n,value:o,cols:80,rows:30});else if(e.enum)i=W("select",{name:n,value:o},e.enum.map(s=>W("option",{textContent:s})));else{let s={name:n,value:o,type:e.format||"text",size:50};e.min!==void 0&&(s.min=e.min),e.max!==void 0&&(s.max=e.max),e.required&&(s.required="required"),i=W("input",s)}return W("p",{},[r,i])},_y=(n,e,t)=>e.type==="boolean"?!!t[n].checked:t[n].value,yt=(n,e={})=>(t,r)=>new Promise(o=>{let i=W("button",{type:"submit",textContent:e.submitText||$("Update")}),s=W("button",{type:"button",value:"cancel",textContent:$("Cancel")}),l=[];e.title&&l.push(W("h3",{className:"prose-editor-dialog-title",textContent:e.title})),l.push(...Object.entries(n).map(([u,f])=>$y(u,f,r[u]))),l.push(i,s);let a=W("div",{},[W("dialog",{className:"prose-editor-dialog"},[W("form",{},l)])]);t.view.dom.parentElement.append(a);let c=a.querySelector("dialog"),d=a.querySelector("form");s.addEventListener("click",()=>{c.close()}),c.addEventListener("close",()=>{a.remove(),o(null)}),i.addEventListener("click",u=>{u.preventDefault(),d.reportValidity()&&(a.remove(),o(Object.fromEntries(Object.entries(n).map(([f,h])=>[f,_y(f,h,d)]))))}),c.showModal()});var Vy=yt({html:{type:"string",title:"HTML",format:"textarea"}},{title:$("Edit HTML")}),jy=(n,e)=>Array.isArray(n)&&Array.isArray(e)&&n.length===e.length&&n.every((t,r)=>Object.is(t,e[r])),Wy=n=>{if(!n)return n;let e=["div","p","h1","h2","h3","h4","h5","h6","ul","ol","li","table","tr","td","th","thead","tbody","tfoot","section","article","header","footer","aside","nav","blockquote","figure","figcaption","form","fieldset"],t=n,r=new RegExp(``,"gi"),o=new RegExp(`<(${e.join("|")})(?:\\s+[^>]*)?>`,"gi");t=t.replace(r,` +`);return!i||!s?!1:n.chain().command(({tr:l})=>(l.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowDown:({editor:n})=>{if(!this.options.exitOnArrowDown)return!1;let{state:e}=n,{selection:t,doc:r}=e,{$from:o,empty:i}=t;if(!i||o.parent.type!==this.type||!(o.parentOffset===o.parent.nodeSize-2))return!1;let l=o.after();return l===void 0?!1:r.nodeAt(l)?n.commands.command(({tr:c})=>(c.setSelection(E.near(r.resolve(l))),!0)):n.commands.exitCode()}}},addInputRules(){return[Vn({find:Bg,type:this.type,getAttributes:n=>({language:n[1]})}),Vn({find:Fg,type:this.type,getAttributes:n=>({language:n[1]})})]},addProseMirrorPlugins(){return[new L({key:new j("codeBlockVSCodeHandler"),props:{handlePaste:(n,e)=>{if(!e.clipboardData||this.editor.isActive(this.type.name))return!1;let t=e.clipboardData.getData("text/plain"),r=e.clipboardData.getData("vscode-editor-data"),o=r?JSON.parse(r):void 0,i=o==null?void 0:o.mode;if(!t||!i)return!1;let{tr:s,schema:l}=n.state,a=l.text(t.replace(/\r\n?/g,` +`));return s.replaceSelectionWith(this.type.create({language:i},a)),s.selection.$from.parent.type!==this.type&&s.setSelection(A.near(s.doc.resolve(Math.max(0,s.selection.from-2)))),s.setMeta("paste",!0),n.dispatch(s),!0}}})]}});var $g=n=>{if(!n.children.length)return;let e=n.querySelectorAll("span");e&&e.forEach(t=>{var r,o;let i=t.getAttribute("style"),s=(o=(r=t.parentElement)===null||r===void 0?void 0:r.closest("span"))===null||o===void 0?void 0:o.getAttribute("style");t.setAttribute("style",`${s};${i}`)})},_g=J.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{},mergeNestedSpanStyles:!1}},parseHTML(){return[{tag:"span",getAttrs:n=>n.hasAttribute("style")?(this.options.mergeNestedSpanStyles&&$g(n),{}):!1}]},renderHTML({HTMLAttributes:n}){return["span",O(this.options.HTMLAttributes,n),0]},addCommands(){return{removeEmptyTextStyle:()=>({tr:n})=>{let{selection:e}=n;return n.doc.nodesBetween(e.from,e.to,(t,r)=>{if(t.isTextblock)return!0;t.marks.filter(o=>o.type===this.type).some(o=>Object.values(o.attrs).some(i=>!!i))||n.removeMark(r,r+t.nodeSize,this.type)}),!0}}}});var Vg=H.create({name:"color",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{color:{default:null,parseHTML:n=>{var e;return(e=n.style.color)===null||e===void 0?void 0:e.replace(/['"]+/g,"")},renderHTML:n=>n.color?{style:`color: ${n.color}`}:{}}}}]},addCommands(){return{setColor:n=>({chain:e})=>e().setMark("textStyle",{color:n}).run(),unsetColor:()=>({chain:n})=>n().setMark("textStyle",{color:null}).removeEmptyTextStyle().run()}}});var jg=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/,Wg=/(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g,Kg=J.create({name:"highlight",addOptions(){return{multicolor:!1,HTMLAttributes:{}}},addAttributes(){return this.options.multicolor?{color:{default:null,parseHTML:n=>n.getAttribute("data-color")||n.style.backgroundColor,renderHTML:n=>n.color?{"data-color":n.color,style:`background-color: ${n.color}; color: inherit`}:{}}}:{}},parseHTML(){return[{tag:"mark"}]},renderHTML({HTMLAttributes:n}){return["mark",O(this.options.HTMLAttributes,n),0]},addCommands(){return{setHighlight:n=>({commands:e})=>e.setMark(this.name,n),toggleHighlight:n=>({commands:e})=>e.toggleMark(this.name,n),unsetHighlight:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-h":()=>this.editor.commands.toggleHighlight()}},addInputRules(){return[Ee({find:jg,type:this.type})]},addPasteRules(){return[be({find:Wg,type:this.type})]}});var Jg=H.create({name:"textAlign",addOptions(){return{types:[],alignments:["left","center","right","justify"],defaultAlignment:null}},addGlobalAttributes(){return[{types:this.options.types,attributes:{textAlign:{default:this.options.defaultAlignment,parseHTML:n=>{let e=n.style.textAlign;return this.options.alignments.includes(e)?e:this.options.defaultAlignment},renderHTML:n=>n.textAlign?{style:`text-align: ${n.textAlign}`}:{}}}}]},addCommands(){return{setTextAlign:n=>({commands:e})=>this.options.alignments.includes(n)?this.options.types.map(t=>e.updateAttributes(t,{textAlign:n})).every(t=>t):!1,unsetTextAlign:()=>({commands:n})=>this.options.types.map(e=>n.resetAttributes(e,"textAlign")).every(e=>e)}},addKeyboardShortcuts(){return{"Mod-Shift-l":()=>this.editor.commands.setTextAlign("left"),"Mod-Shift-e":()=>this.editor.commands.setTextAlign("center"),"Mod-Shift-r":()=>this.editor.commands.setTextAlign("right"),"Mod-Shift-j":()=>this.editor.commands.setTextAlign("justify")}}});var Ls,zs;if(typeof WeakMap!="undefined"){let n=new WeakMap;Ls=e=>n.get(e),zs=(e,t)=>(n.set(e,t),t)}else{let n=[],t=0;Ls=r=>{for(let o=0;o(t==10&&(t=0),n[t++]=r,n[t++]=o)}var G=class{constructor(n,e,t,r){this.width=n,this.height=e,this.map=t,this.problems=r}findCell(n){for(let e=0;e=t){(i||(i=[])).push({type:"overlong_rowspan",pos:d,n:y-T});break}let I=o+T*e;for(let M=0;Mr&&(i+=c.attrs.colspan)}}for(let s=0;s1&&(t=!0)}e==-1?e=i:e!=i&&(e=Math.max(e,i))}return e}function Gg(n,e,t){n.problems||(n.problems=[]);let r={};for(let o=0;o0;e--)if(n.node(e).type.spec.tableRole=="row")return n.node(0).resolve(n.before(e+1));return null}function Qg(n){for(let e=n.depth;e>0;e--){let t=n.node(e).type.spec.tableRole;if(t==="cell"||t==="header_cell")return n.node(e)}return null}function De(n){let e=n.selection.$head;for(let t=e.depth;t>0;t--)if(e.node(t).type.spec.tableRole=="row")return!0;return!1}function bo(n){let e=n.selection;if("$anchorCell"in e&&e.$anchorCell)return e.$anchorCell.pos>e.$headCell.pos?e.$anchorCell:e.$headCell;if("node"in e&&e.node&&e.node.type.spec.tableRole=="cell")return e.$anchor;let t=cn(e.$head)||Xg(e.$head);if(t)return t;throw new RangeError(`No cell found around position ${e.head}`)}function Xg(n){for(let e=n.nodeAfter,t=n.pos;e;e=e.firstChild,t++){let r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return n.doc.resolve(t)}for(let e=n.nodeBefore,t=n.pos;e;e=e.lastChild,t--){let r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return n.doc.resolve(t-e.nodeSize)}}function Bs(n){return n.parent.type.spec.tableRole=="row"&&!!n.nodeAfter}function Zg(n){return n.node(0).resolve(n.pos+n.nodeAfter.nodeSize)}function $s(n,e){return n.depth==e.depth&&n.pos>=e.start(-1)&&n.pos<=e.end(-1)}function Hd(n,e,t){let r=n.node(-1),o=G.get(r),i=n.start(-1),s=o.nextCell(n.pos-i,e,t);return s==null?null:n.node(0).resolve(i+s)}function Ft(n,e,t=1){let r=N(b({},n),{colspan:n.colspan-t});return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(e,t),r.colwidth.some(o=>o>0)||(r.colwidth=null)),r}function $d(n,e,t=1){let r=N(b({},n),{colspan:n.colspan+t});if(r.colwidth){r.colwidth=r.colwidth.slice();for(let o=0;od!=t.pos-i);a.unshift(t.pos-i);let c=a.map(d=>{let u=r.nodeAt(d);if(!u)throw RangeError(`No cell with offset ${d} found`);let f=i+d+1;return new Ke(l.resolve(f),l.resolve(f+u.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=e,this.$headCell=t}map(e,t){let r=e.resolve(t.map(this.$anchorCell.pos)),o=e.resolve(t.map(this.$headCell.pos));if(Bs(r)&&Bs(o)&&$s(r,o)){let i=this.$anchorCell.node(-1)!=r.node(-1);return i&&this.isRowSelection()?Ze.rowSelection(r,o):i&&this.isColSelection()?Ze.colSelection(r,o):new Ze(r,o)}return A.between(r,o)}content(){let e=this.$anchorCell.node(-1),t=G.get(e),r=this.$anchorCell.start(-1),o=t.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),i={},s=[];for(let a=o.top;a0||g>0){let y=h.attrs;if(m>0&&(y=Ft(y,0,m)),g>0&&(y=Ft(y,y.colspan-g,g)),p.lefto.bottom){let y=N(b({},h.attrs),{rowspan:Math.min(p.bottom,o.bottom)-Math.max(p.top,o.top)});p.top0)return!1;let r=e+this.$anchorCell.nodeAfter.attrs.rowspan,o=t+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(r,o)==this.$headCell.node(-1).childCount}static colSelection(e,t=e){let r=e.node(-1),o=G.get(r),i=e.start(-1),s=o.findCell(e.pos-i),l=o.findCell(t.pos-i),a=e.node(0);return s.top<=l.top?(s.top>0&&(e=a.resolve(i+o.map[s.left])),l.bottom0&&(t=a.resolve(i+o.map[l.left])),s.bottom0)return!1;let s=o+this.$anchorCell.nodeAfter.attrs.colspan,l=i+this.$headCell.nodeAfter.attrs.colspan;return Math.max(s,l)==t.width}eq(e){return e instanceof Ze&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,t=e){let r=e.node(-1),o=G.get(r),i=e.start(-1),s=o.findCell(e.pos-i),l=o.findCell(t.pos-i),a=e.node(0);return s.left<=l.left?(s.left>0&&(e=a.resolve(i+o.map[s.top*o.width])),l.right0&&(t=a.resolve(i+o.map[l.top*o.width])),s.right{e.push(ne.node(r,r+t.nodeSize,{class:"selectedCell"}))}),q.create(n.doc,e)}function ry({$from:n,$to:e}){if(n.pos==e.pos||n.pos=0&&!(n.after(o+1)=0&&!(e.before(i+1)>e.start(i));i--,r--);return t==r&&/row|table/.test(n.node(o).type.spec.tableRole)}function oy({$from:n,$to:e}){let t,r;for(let o=n.depth;o>0;o--){let i=n.node(o);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){t=i;break}}for(let o=e.depth;o>0;o--){let i=e.node(o);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){r=i;break}}return t!==r&&e.parentOffset===0}function iy(n,e,t){let r=(e||n).selection,o=(e||n).doc,i,s;if(r instanceof v&&(s=r.node.type.spec.tableRole)){if(s=="cell"||s=="header_cell")i=V.create(o,r.from);else if(s=="row"){let l=o.resolve(r.from+1);i=V.rowSelection(l,l)}else if(!t){let l=G.get(r.node),a=r.from+1,c=a+l.map[l.width*l.height-1];i=V.create(o,a+1,c)}}else r instanceof A&&ry(r)?i=A.create(o,r.from):r instanceof A&&oy(r)&&(i=A.create(o,r.$from.start(),r.$from.end()));return i&&(e||(e=n.tr)).setSelection(i),e}var sy=new j("fix-tables");function Vd(n,e,t,r){let o=n.childCount,i=e.childCount;e:for(let s=0,l=0;s{o.type.spec.tableRole=="table"&&(t=ly(n,o,i,t))};return e?e.doc!=n.doc&&Vd(e.doc,n.doc,0,r):n.doc.descendants(r),t}function ly(n,e,t,r){let o=G.get(e);if(!o.problems)return r;r||(r=n.tr);let i=[];for(let a=0;a0){let p="cell";d.firstChild&&(p=d.firstChild.type.spec.tableRole);let h=[];for(let g=0;g0?-1:0;ey(e,r,o+i)&&(i=o==0||o==e.width?null:0);for(let s=0;s0&&o0&&e.map[l-1]==a||o0?-1:0;cy(e,r,o+a)&&(a=o==0||o==e.height?null:0);for(let c=0,d=e.width*o;c0&&o0&&u==e.map[d-e.width]){let f=t.nodeAt(u).attrs;n.setNodeMarkup(n.mapping.slice(l).map(u+r),null,N(b({},f),{rowspan:f.rowspan-1})),c+=f.colspan-1}else if(o0&&t[i]==t[i-1]||r.right0&&t[o]==t[o-n]||r.bottomt[r.type.spec.tableRole])(n,e)}function fy(n){return(e,t)=>{var r;let o=e.selection,i,s;if(o instanceof V){if(o.$anchorCell.pos!=o.$headCell.pos)return!1;i=o.$anchorCell.nodeAfter,s=o.$anchorCell.pos}else{if(i=Qg(o.$from),!i)return!1;s=(r=cn(o.$from))==null?void 0:r.pos}if(i==null||s==null||i.attrs.colspan==1&&i.attrs.rowspan==1)return!1;if(t){let l=i.attrs,a=[],c=l.colwidth;l.rowspan>1&&(l=N(b({},l),{rowspan:1})),l.colspan>1&&(l=N(b({},l),{colspan:1}));let d=_e(e),u=e.tr;for(let p=0;p{s.attrs[n]!==e&&i.setNodeMarkup(l,null,N(b({},s.attrs),{[n]:e}))}):i.setNodeMarkup(o.pos,null,N(b({},o.nodeAfter.attrs),{[n]:e})),r(i)}return!0}}function py(n){return function(e,t){if(!De(e))return!1;if(t){let r=fe(e.schema),o=_e(e),i=e.tr,s=o.map.cellsInRect(n=="column"?{left:o.left,top:0,right:o.right,bottom:o.map.height}:n=="row"?{left:0,top:o.top,right:o.map.width,bottom:o.bottom}:o),l=s.map(a=>o.table.nodeAt(a));for(let a=0;a{let h=p+i.tableStart,m=s.doc.nodeAt(h);m&&s.setNodeMarkup(h,f,m.attrs)}),r(s)}return!0}}var Sx=dn("row",{useDeprecatedLogic:!0}),Cx=dn("column",{useDeprecatedLogic:!0}),Xd=dn("cell",{useDeprecatedLogic:!0});function hy(n,e){if(e<0){let t=n.nodeBefore;if(t)return n.pos-t.nodeSize;for(let r=n.index(-1)-1,o=n.before();r>=0;r--){let i=n.node(-1).child(r),s=i.lastChild;if(s)return o-1-s.nodeSize;o-=i.nodeSize}}else{if(n.index()0;r--)if(t.node(r).type.spec.tableRole=="table")return e&&e(n.tr.delete(t.before(r),t.after(r)).scrollIntoView()),!0;return!1}function po(n,e){let t=n.selection;if(!(t instanceof V))return!1;if(e){let r=n.tr,o=fe(n.schema).cell.createAndFill().content;t.forEachCell((i,s)=>{i.content.eq(o)||r.replace(r.mapping.map(s+1),r.mapping.map(s+i.nodeSize-1),new S(o,0,0))}),r.docChanged&&e(r)}return!0}function my(n){if(!n.size)return null;let{content:e,openStart:t,openEnd:r}=n;for(;e.childCount==1&&(t>0&&r>0||e.child(0).type.spec.tableRole=="table");)t--,r--,e=e.child(0).content;let o=e.child(0),i=o.type.spec.tableRole,s=o.type.schema,l=[];if(i=="row")for(let a=0;a=0;s--){let{rowspan:l,colspan:a}=i.child(s).attrs;for(let c=o;c=e.length&&e.push(x.empty),t[o]r&&(f=f.type.createChecked(Ft(f.attrs,f.attrs.colspan,d+f.attrs.colspan-r),f.content)),c.push(f),d+=f.attrs.colspan;for(let p=1;po&&(u=u.type.create(N(b({},u.attrs),{rowspan:Math.max(1,o-u.attrs.rowspan)}),u.content)),a.push(u)}i.push(x.from(a))}t=i,e=o}return{width:n,height:e,rows:t}}function by(n,e,t,r,o,i,s){let l=n.doc.type.schema,a=fe(l),c,d;if(o>e.width)for(let u=0,f=0;ue.height){let u=[];for(let h=0,m=(e.height-1)*e.width;h=e.width?!1:t.nodeAt(e.map[m+h]).type==a.header_cell;u.push(g?d||(d=a.header_cell.createAndFill()):c||(c=a.cell.createAndFill()))}let f=a.row.create(null,x.from(u)),p=[];for(let h=e.height;h{if(!o)return!1;let i=t.selection;if(i instanceof V)return go(t,r,E.near(i.$headCell,e));if(n!="horiz"&&!i.empty)return!1;let s=eu(o,n,e);if(s==null)return!1;if(n=="horiz")return go(t,r,E.near(t.doc.resolve(i.head+e),e));{let l=t.doc.resolve(s),a=Hd(l,n,e),c;return a?c=E.near(a,1):e<0?c=E.near(t.doc.resolve(l.before(-1)),-1):c=E.near(t.doc.resolve(l.after(-1)),1),go(t,r,c)}}}function mo(n,e){return(t,r,o)=>{if(!o)return!1;let i=t.selection,s;if(i instanceof V)s=i;else{let a=eu(o,n,e);if(a==null)return!1;s=new V(t.doc.resolve(a))}let l=Hd(s.$headCell,n,e);return l?go(t,r,new V(s.$anchorCell,l)):!1}}function ky(n,e){let t=n.state.doc,r=cn(t.resolve(e));return r?(n.dispatch(n.state.tr.setSelection(new V(r))),!0):!1}function wy(n,e,t){if(!De(n.state))return!1;let r=my(t),o=n.state.selection;if(o instanceof V){r||(r={width:1,height:1,rows:[x.from(Fs(fe(n.state.schema).cell,t))]});let i=o.$anchorCell.node(-1),s=o.$anchorCell.start(-1),l=G.get(i).rectBetween(o.$anchorCell.pos-s,o.$headCell.pos-s);return r=yy(r,l.right-l.left,l.bottom-l.top),Pd(n.state,n.dispatch,s,l,r),!0}else if(r){let i=bo(n.state),s=i.start(-1);return Pd(n.state,n.dispatch,s,G.get(i.node(-1)).findCell(i.pos-s),r),!0}else return!1}function Sy(n,e){var t;if(e.ctrlKey||e.metaKey)return;let r=Ld(n,e.target),o;if(e.shiftKey&&n.state.selection instanceof V)i(n.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&r&&(o=cn(n.state.selection.$anchor))!=null&&((t=Ps(n,e))==null?void 0:t.pos)!=o.pos)i(o,e),e.preventDefault();else if(!r)return;function i(a,c){let d=Ps(n,c),u=gt.getState(n.state)==null;if(!d||!$s(a,d))if(u)d=a;else return;let f=new V(a,d);if(u||!n.state.selection.eq(f)){let p=n.state.tr.setSelection(f);u&&p.setMeta(gt,a.pos),n.dispatch(p)}}function s(){n.root.removeEventListener("mouseup",s),n.root.removeEventListener("dragstart",s),n.root.removeEventListener("mousemove",l),gt.getState(n.state)!=null&&n.dispatch(n.state.tr.setMeta(gt,-1))}function l(a){let c=a,d=gt.getState(n.state),u;if(d!=null)u=n.state.doc.resolve(d);else if(Ld(n,c.target)!=r&&(u=Ps(n,e),!u))return s();u&&i(u,c)}n.root.addEventListener("mouseup",s),n.root.addEventListener("dragstart",s),n.root.addEventListener("mousemove",l)}function eu(n,e,t){if(!(n.state.selection instanceof A))return null;let{$head:r}=n.state.selection;for(let o=r.depth-1;o>=0;o--){let i=r.node(o);if((t<0?r.index(o):r.indexAfter(o))!=(t<0?0:i.childCount))return null;if(i.type.spec.tableRole=="cell"||i.type.spec.tableRole=="header_cell"){let l=r.before(o),a=e=="vert"?t>0?"down":"up":t>0?"right":"left";return n.endOfTextblock(a)?l:null}}return null}function Ld(n,e){for(;e&&e!=n.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function Ps(n,e){let t=n.posAtCoords({left:e.clientX,top:e.clientY});return t&&t?cn(n.state.doc.resolve(t.pos)):null}var Cy=class{constructor(n,e){this.node=n,this.defaultCellMinWidth=e,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",`${e}px`),this.colgroup=this.table.appendChild(document.createElement("colgroup")),Hs(n,this.colgroup,this.table,e),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(n){return n.type!=this.node.type?!1:(this.node=n,Hs(n,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(n){return n.type=="attributes"&&(n.target==this.table||this.colgroup.contains(n.target))}};function Hs(n,e,t,r,o,i){var s;let l=0,a=!0,c=e.firstChild,d=n.firstChild;if(d){for(let u=0,f=0;unew r(f,t,p)),new My(-1,!1)},apply(s,l){return l.apply(s)}},props:{attributes:s=>{let l=Se.getState(s);return l&&l.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(s,l)=>{Ty(s,l,n,o)},mouseleave:s=>{Ay(s)},mousedown:(s,l)=>{Ey(s,l,e,t)}},decorations:s=>{let l=Se.getState(s);if(l&&l.activeHandle>-1)return Dy(s,l.activeHandle)},nodeViews:{}}});return i}var My=class yo{constructor(e,t){this.activeHandle=e,this.dragging=t}apply(e){let t=this,r=e.getMeta(Se);if(r&&r.setHandle!=null)return new yo(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new yo(t.activeHandle,r.setDragging);if(t.activeHandle>-1&&e.docChanged){let o=e.mapping.map(t.activeHandle,-1);return Bs(e.doc.resolve(o))||(o=-1),new yo(o,t.dragging)}return t}};function Ty(n,e,t,r){if(!n.editable)return;let o=Se.getState(n.state);if(o&&!o.dragging){let i=Oy(e.target),s=-1;if(i){let{left:l,right:a}=i.getBoundingClientRect();e.clientX-l<=t?s=zd(n,e,"left",t):a-e.clientX<=t&&(s=zd(n,e,"right",t))}if(s!=o.activeHandle){if(!r&&s!==-1){let l=n.state.doc.resolve(s),a=l.node(-1),c=G.get(a),d=l.start(-1);if(c.colCount(l.pos-d)+l.nodeAfter.attrs.colspan-1==c.width-1)return}nu(n,s)}}}function Ay(n){if(!n.editable)return;let e=Se.getState(n.state);e&&e.activeHandle>-1&&!e.dragging&&nu(n,-1)}function Ey(n,e,t,r){var o;if(!n.editable)return!1;let i=(o=n.dom.ownerDocument.defaultView)!=null?o:window,s=Se.getState(n.state);if(!s||s.activeHandle==-1||s.dragging)return!1;let l=n.state.doc.nodeAt(s.activeHandle),a=vy(n,s.activeHandle,l.attrs);n.dispatch(n.state.tr.setMeta(Se,{setDragging:{startX:e.clientX,startWidth:a}}));function c(u){i.removeEventListener("mouseup",c),i.removeEventListener("mousemove",d);let f=Se.getState(n.state);f!=null&&f.dragging&&(Ny(n,f.activeHandle,Bd(f.dragging,u,t)),n.dispatch(n.state.tr.setMeta(Se,{setDragging:null})))}function d(u){if(!u.which)return c(u);let f=Se.getState(n.state);if(f&&f.dragging){let p=Bd(f.dragging,u,t);Fd(n,f.activeHandle,p,r)}}return Fd(n,s.activeHandle,a,r),i.addEventListener("mouseup",c),i.addEventListener("mousemove",d),e.preventDefault(),!0}function vy(n,e,{colspan:t,colwidth:r}){let o=r&&r[r.length-1];if(o)return o;let i=n.domAtPos(e),l=i.node.childNodes[i.offset].offsetWidth,a=t;if(r)for(let c=0;c{let r=n.nodes[t];r.spec.tableRole&&(e[r.spec.tableRole]=r)}),n.cached.tableNodeTypes=e,e}function Ly(n,e,t,r,o){let i=Py(n),s=[],l=[];for(let c=0;c{let{selection:e}=n.state;if(!zy(e))return!1;let t=0,r=Ms(e.ranges[0].$from,i=>i.type.name==="table");return r==null||r.node.descendants(i=>{if(i.type.name==="table")return!1;["tableCell","tableHeader"].includes(i.type.name)&&(t+=1)}),t===e.ranges.length?(n.commands.deleteTable(),!0):!1},By=z.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,handleWidth:5,cellMinWidth:25,View:Js,lastColumnResizable:!0,allowTableNodeSelection:!1}},content:"tableRow+",tableRole:"table",isolating:!0,group:"block",parseHTML(){return[{tag:"table"}]},renderHTML({node:n,HTMLAttributes:e}){let{colgroup:t,tableWidth:r,tableMinWidth:o}=Iy(n,this.options.cellMinWidth);return["table",O(this.options.HTMLAttributes,e,{style:r?`width: ${r}`:`min-width: ${o}`}),t,["tbody",0]]},addCommands(){return{insertTable:({rows:n=3,cols:e=3,withHeaderRow:t=!0}={})=>({tr:r,dispatch:o,editor:i})=>{let s=Ly(i.schema,n,e,t);if(o){let l=r.selection.from+1;r.replaceSelectionWith(s).scrollIntoView().setSelection(A.near(r.doc.resolve(l)))}return!0},addColumnBefore:()=>({state:n,dispatch:e})=>Wd(n,e),addColumnAfter:()=>({state:n,dispatch:e})=>Kd(n,e),deleteColumn:()=>({state:n,dispatch:e})=>Jd(n,e),addRowBefore:()=>({state:n,dispatch:e})=>qd(n,e),addRowAfter:()=>({state:n,dispatch:e})=>Gd(n,e),deleteRow:()=>({state:n,dispatch:e})=>Yd(n,e),deleteTable:()=>({state:n,dispatch:e})=>Zd(n,e),mergeCells:()=>({state:n,dispatch:e})=>Vs(n,e),splitCell:()=>({state:n,dispatch:e})=>js(n,e),toggleHeaderColumn:()=>({state:n,dispatch:e})=>dn("column")(n,e),toggleHeaderRow:()=>({state:n,dispatch:e})=>dn("row")(n,e),toggleHeaderCell:()=>({state:n,dispatch:e})=>Xd(n,e),mergeOrSplit:()=>({state:n,dispatch:e})=>Vs(n,e)?!0:js(n,e),setCellAttribute:(n,e)=>({state:t,dispatch:r})=>Qd(n,e)(t,r),goToNextCell:()=>({state:n,dispatch:e})=>Ws(1)(n,e),goToPreviousCell:()=>({state:n,dispatch:e})=>Ws(-1)(n,e),fixTables:()=>({state:n,dispatch:e})=>(e&&_s(n),!0),setCellSelection:n=>({tr:e,dispatch:t})=>{if(t){let r=V.create(e.doc,n.anchorCell,n.headCell);e.setSelection(r)}return!0}}},addKeyboardShortcuts(){return{Tab:()=>this.editor.commands.goToNextCell()?!0:this.editor.can().addRowAfter()?this.editor.chain().addRowAfter().goToNextCell().run():!1,"Shift-Tab":()=>this.editor.commands.goToPreviousCell(),Backspace:xo,"Mod-Backspace":xo,Delete:xo,"Mod-Delete":xo}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[tu({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,defaultCellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],ru({allowTableNodeSelection:this.options.allowTableNodeSelection})]},extendNodeSchema(n){let e={name:n.name,options:n.options,storage:n.storage};return{tableRole:D(C(n,"tableRole",e))}}});var Fy=z.create({name:"tableCell",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:n=>{let e=n.getAttribute("colwidth");return e?e.split(",").map(r=>parseInt(r,10)):null}}}},tableRole:"cell",isolating:!0,parseHTML(){return[{tag:"td"}]},renderHTML({HTMLAttributes:n}){return["td",O(this.options.HTMLAttributes,n),0]}});var Hy=z.create({name:"tableHeader",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:n=>{let e=n.getAttribute("colwidth");return e?e.split(",").map(r=>parseInt(r,10)):null}}}},tableRole:"header_cell",isolating:!0,parseHTML(){return[{tag:"th"}]},renderHTML({HTMLAttributes:n}){return["th",O(this.options.HTMLAttributes,n),0]}});var $y=z.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:n}){return["tr",O(this.options.HTMLAttributes,n),0]}});var W=(n,e=null,t=[])=>{let r=document.createElement(n);if(r.append(...t),e)for(let[o,i]of Object.entries(e))/^data-|^aria-|^role/.test(o)?r.setAttribute(o,i):r[o]=i;return r},$=window.gettext||(n=>n),_y=(n,e,t)=>{let r=W("label",{textContent:e.title||n}),o=t||e.default||"",i;if(e.type==="boolean")return W("label",{},[W("input",{name:n,type:"checkbox",checked:!!o}),e.title||n]);if(e.format==="textarea")i=W("textarea",{name:n,value:o,cols:80,rows:30});else if(e.enum)i=W("select",{name:n,value:o},e.enum.map(s=>W("option",{textContent:s})));else{let s={name:n,value:o,type:e.format||"text",size:50};e.min!==void 0&&(s.min=e.min),e.max!==void 0&&(s.max=e.max),e.required&&(s.required="required"),i=W("input",s)}return W("p",{},[r,i])},Vy=(n,e,t)=>e.type==="boolean"?!!t[n].checked:t[n].value,yt=(n,e={})=>(t,r)=>new Promise(o=>{let i=W("button",{type:"submit",textContent:e.submitText||$("Update")}),s=W("button",{type:"button",value:"cancel",textContent:$("Cancel")}),l=[];e.title&&l.push(W("h3",{className:"prose-editor-dialog-title",textContent:e.title})),l.push(...Object.entries(n).map(([u,f])=>_y(u,f,r[u]))),l.push(i,s);let a=W("div",{},[W("dialog",{className:"prose-editor-dialog"},[W("form",{},l)])]);t.view.dom.parentElement.append(a);let c=a.querySelector("dialog"),d=a.querySelector("form");s.addEventListener("click",()=>{c.close()}),c.addEventListener("close",()=>{a.remove(),o(null)}),i.addEventListener("click",u=>{u.preventDefault(),d.reportValidity()&&(a.remove(),o(Object.fromEntries(Object.entries(n).map(([f,p])=>[f,Vy(f,p,d)]))))}),c.showModal()});var jy=yt({html:{type:"string",title:"HTML",format:"textarea"}},{title:$("Edit HTML")}),Wy=(n,e)=>Array.isArray(n)&&Array.isArray(e)&&n.length===e.length&&n.every((t,r)=>Object.is(t,e[r])),Ky=n=>{if(!n)return n;let e=["div","p","h1","h2","h3","h4","h5","h6","ul","ol","li","table","tr","td","th","thead","tbody","tfoot","section","article","header","footer","aside","nav","blockquote","figure","figcaption","form","fieldset"],t=n,r=new RegExp(``,"gi"),o=new RegExp(`<(${e.join("|")})(?:\\s+[^>]*)?>`,"gi");t=t.replace(r,` `).replace(o,` $&`);let i=t.split(` -`).filter(l=>l.trim()),s=0;for(let l=0;l({editor:n})=>{let e=Wy(n.getHTML());Vy(n,{html:e}).then(t=>{t&&n.chain().focus().setContent(t.html,!0).run()})}}}});var Jy="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2ntley5rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6logistics9properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3ncaster6d0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2psy3ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0america6xi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5m\xF6gensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",Uy="\u03B5\u03BB1\u03C52\u0431\u04331\u0435\u043B3\u0434\u0435\u0442\u04384\u0435\u044E2\u043A\u0430\u0442\u043E\u043B\u0438\u043A6\u043E\u043C3\u043C\u043A\u04342\u043E\u043D1\u0441\u043A\u0432\u04306\u043E\u043D\u043B\u0430\u0439\u043D5\u0440\u04333\u0440\u0443\u04412\u04442\u0441\u0430\u0439\u04423\u0440\u04313\u0443\u043A\u04403\u049B\u0430\u04373\u0570\u0561\u05753\u05D9\u05E9\u05E8\u05D0\u05DC5\u05E7\u05D5\u05DD3\u0627\u0628\u0648\u0638\u0628\u064A5\u0631\u0627\u0645\u0643\u06485\u0644\u0627\u0631\u062F\u06464\u0628\u062D\u0631\u064A\u06465\u062C\u0632\u0627\u0626\u06315\u0633\u0639\u0648\u062F\u064A\u06296\u0639\u0644\u064A\u0627\u06465\u0645\u063A\u0631\u06285\u0645\u0627\u0631\u0627\u062A5\u06CC\u0631\u0627\u06465\u0628\u0627\u0631\u062A2\u0632\u0627\u06314\u064A\u062A\u06433\u06BE\u0627\u0631\u062A5\u062A\u0648\u0646\u06334\u0633\u0648\u062F\u0627\u06463\u0631\u064A\u06295\u0634\u0628\u0643\u06294\u0639\u0631\u0627\u06422\u06282\u0645\u0627\u06464\u0641\u0644\u0633\u0637\u064A\u06466\u0642\u0637\u06313\u0643\u0627\u062B\u0648\u0644\u064A\u06436\u0648\u06453\u0645\u0635\u06312\u0644\u064A\u0633\u064A\u06275\u0648\u0631\u064A\u062A\u0627\u0646\u064A\u06277\u0642\u06394\u0647\u0645\u0631\u0627\u06475\u067E\u0627\u06A9\u0633\u062A\u0627\u06467\u0680\u0627\u0631\u062A4\u0915\u0949\u092E3\u0928\u0947\u091F3\u092D\u093E\u0930\u09240\u092E\u094D3\u094B\u09245\u0938\u0902\u0917\u0920\u09285\u09AC\u09BE\u0982\u09B2\u09BE5\u09AD\u09BE\u09B0\u09A42\u09F0\u09A44\u0A2D\u0A3E\u0A30\u0A244\u0AAD\u0ABE\u0AB0\u0AA44\u0B2D\u0B3E\u0B30\u0B244\u0B87\u0BA8\u0BCD\u0BA4\u0BBF\u0BAF\u0BBE6\u0BB2\u0B99\u0BCD\u0B95\u0BC86\u0B9A\u0BBF\u0B99\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0BC2\u0BB0\u0BCD11\u0C2D\u0C3E\u0C30\u0C24\u0C4D5\u0CAD\u0CBE\u0CB0\u0CA44\u0D2D\u0D3E\u0D30\u0D24\u0D025\u0DBD\u0D82\u0D9A\u0DCF4\u0E04\u0E2D\u0E213\u0E44\u0E17\u0E223\u0EA5\u0EB2\u0EA73\u10D2\u10D42\u307F\u3093\u306A3\u30A2\u30DE\u30BE\u30F34\u30AF\u30E9\u30A6\u30C94\u30B0\u30FC\u30B0\u30EB4\u30B3\u30E02\u30B9\u30C8\u30A23\u30BB\u30FC\u30EB3\u30D5\u30A1\u30C3\u30B7\u30E7\u30F36\u30DD\u30A4\u30F3\u30C84\u4E16\u754C2\u4E2D\u4FE11\u56FD1\u570B1\u6587\u7F513\u4E9A\u9A6C\u900A3\u4F01\u4E1A2\u4F5B\u5C712\u4FE1\u606F2\u5065\u5EB72\u516B\u53662\u516C\u53F81\u76CA2\u53F0\u6E7E1\u70632\u5546\u57CE1\u5E971\u68072\u5609\u91CC0\u5927\u9152\u5E975\u5728\u7EBF2\u5927\u62FF2\u5929\u4E3B\u65593\u5A31\u4E502\u5BB6\u96FB2\u5E7F\u4E1C2\u5FAE\u535A2\u6148\u55842\u6211\u7231\u4F603\u624B\u673A2\u62DB\u80582\u653F\u52A11\u5E9C2\u65B0\u52A0\u57612\u95FB2\u65F6\u5C1A2\u66F8\u7C4D2\u673A\u67842\u6DE1\u9A6C\u95213\u6E38\u620F2\u6FB3\u95802\u70B9\u770B2\u79FB\u52A82\u7EC4\u7EC7\u673A\u67844\u7F51\u57401\u5E971\u7AD91\u7EDC2\u8054\u901A2\u8C37\u6B4C2\u8D2D\u72692\u901A\u8CA92\u96C6\u56E22\u96FB\u8A0A\u76C8\u79D14\u98DE\u5229\u6D663\u98DF\u54C12\u9910\u53852\u9999\u683C\u91CC\u62C93\u6E2F2\uB2F7\uB1371\uCEF42\uC0BC\uC1312\uD55C\uAD6D2",fn=(n,e)=>{for(let t in e)n[t]=e[t];return n},Zs="numeric",el="ascii",tl="alpha",Kn="asciinumeric",Wn="alphanumeric",nl="domain",uu="emoji",qy="scheme",Gy="slashscheme",Us="whitespace";function Yy(n,e){return n in e||(e[n]=[]),e[n]}function Ht(n,e,t){e[Zs]&&(e[Kn]=!0,e[Wn]=!0),e[el]&&(e[Kn]=!0,e[tl]=!0),e[Kn]&&(e[Wn]=!0),e[tl]&&(e[Wn]=!0),e[Wn]&&(e[nl]=!0),e[uu]&&(e[nl]=!0);for(let r in e){let o=Yy(r,t);o.indexOf(n)<0&&o.push(n)}}function Qy(n,e){let t={};for(let r in e)e[r].indexOf(n)>=0&&(t[r]=!0);return t}function xe(n=null){this.j={},this.jr=[],this.jd=null,this.t=n}xe.groups={};xe.prototype={accepts(){return!!this.t},go(n){let e=this,t=e.j[n];if(t)return t;for(let r=0;rn.ta(e,t,r,o),Y=(n,e,t,r,o)=>n.tr(e,t,r,o),iu=(n,e,t,r,o)=>n.ts(e,t,r,o),k=(n,e,t,r,o)=>n.tt(e,t,r,o),nt="WORD",rl="UWORD",fu="ASCIINUMERICAL",hu="ALPHANUMERICAL",Qn="LOCALHOST",ol="TLD",il="UTLD",Co="SCHEME",un="SLASH_SCHEME",ll="NUM",sl="WS",al="NL",Jn="OPENBRACE",Un="CLOSEBRACE",Mo="OPENBRACKET",Ao="CLOSEBRACKET",To="OPENPAREN",Eo="CLOSEPAREN",Oo="OPENANGLEBRACKET",vo="CLOSEANGLEBRACKET",No="FULLWIDTHLEFTPAREN",Ro="FULLWIDTHRIGHTPAREN",Do="LEFTCORNERBRACKET",Io="RIGHTCORNERBRACKET",Po="LEFTWHITECORNERBRACKET",Lo="RIGHTWHITECORNERBRACKET",Bo="FULLWIDTHLESSTHAN",zo="FULLWIDTHGREATERTHAN",Fo="AMPERSAND",cl="APOSTROPHE",Ho="ASTERISK",xt="AT",$o="BACKSLASH",_o="BACKTICK",Vo="CARET",kt="COLON",dl="COMMA",jo="DOLLAR",Ve="DOT",Wo="EQUALS",ul="EXCLAMATION",ve="HYPHEN",qn="PERCENT",Ko="PIPE",Jo="PLUS",Uo="POUND",Gn="QUERY",fl="QUOTE",pu="FULLWIDTHMIDDLEDOT",hl="SEMI",je="SLASH",Yn="TILDE",qo="UNDERSCORE",mu="EMOJI",Go="SYM",gu=Object.freeze({__proto__:null,WORD:nt,UWORD:rl,ASCIINUMERICAL:fu,ALPHANUMERICAL:hu,LOCALHOST:Qn,TLD:ol,UTLD:il,SCHEME:Co,SLASH_SCHEME:un,NUM:ll,WS:sl,NL:al,OPENBRACE:Jn,CLOSEBRACE:Un,OPENBRACKET:Mo,CLOSEBRACKET:Ao,OPENPAREN:To,CLOSEPAREN:Eo,OPENANGLEBRACKET:Oo,CLOSEANGLEBRACKET:vo,FULLWIDTHLEFTPAREN:No,FULLWIDTHRIGHTPAREN:Ro,LEFTCORNERBRACKET:Do,RIGHTCORNERBRACKET:Io,LEFTWHITECORNERBRACKET:Po,RIGHTWHITECORNERBRACKET:Lo,FULLWIDTHLESSTHAN:Bo,FULLWIDTHGREATERTHAN:zo,AMPERSAND:Fo,APOSTROPHE:cl,ASTERISK:Ho,AT:xt,BACKSLASH:$o,BACKTICK:_o,CARET:Vo,COLON:kt,COMMA:dl,DOLLAR:jo,DOT:Ve,EQUALS:Wo,EXCLAMATION:ul,HYPHEN:ve,PERCENT:qn,PIPE:Ko,PLUS:Jo,POUND:Uo,QUERY:Gn,QUOTE:fl,FULLWIDTHMIDDLEDOT:pu,SEMI:hl,SLASH:je,TILDE:Yn,UNDERSCORE:qo,EMOJI:mu,SYM:Go}),et=/[a-z]/,jn=new RegExp("\\p{L}","u"),qs=new RegExp("\\p{Emoji}","u");var tt=/\d/,Gs=/\s/;var su="\r",Ys=` -`,Xy="\uFE0F",Zy="\u200D",Qs="\uFFFC",ko=null,So=null;function e0(n=[]){let e={};xe.groups=e;let t=new xe;ko==null&&(ko=lu(Jy)),So==null&&(So=lu(Uy)),k(t,"'",cl),k(t,"{",Jn),k(t,"}",Un),k(t,"[",Mo),k(t,"]",Ao),k(t,"(",To),k(t,")",Eo),k(t,"<",Oo),k(t,">",vo),k(t,"\uFF08",No),k(t,"\uFF09",Ro),k(t,"\u300C",Do),k(t,"\u300D",Io),k(t,"\u300E",Po),k(t,"\u300F",Lo),k(t,"\uFF1C",Bo),k(t,"\uFF1E",zo),k(t,"&",Fo),k(t,"*",Ho),k(t,"@",xt),k(t,"`",_o),k(t,"^",Vo),k(t,":",kt),k(t,",",dl),k(t,"$",jo),k(t,".",Ve),k(t,"=",Wo),k(t,"!",ul),k(t,"-",ve),k(t,"%",qn),k(t,"|",Ko),k(t,"+",Jo),k(t,"#",Uo),k(t,"?",Gn),k(t,'"',fl),k(t,"/",je),k(t,";",hl),k(t,"~",Yn),k(t,"_",qo),k(t,"\\",$o),k(t,"\u30FB",pu);let r=Y(t,tt,ll,{[Zs]:!0});Y(r,tt,r);let o=Y(r,et,fu,{[Kn]:!0}),i=Y(r,jn,hu,{[Wn]:!0}),s=Y(t,et,nt,{[el]:!0});Y(s,tt,o),Y(s,et,s),Y(o,tt,o),Y(o,et,o);let l=Y(t,jn,rl,{[tl]:!0});Y(l,et),Y(l,tt,i),Y(l,jn,l),Y(i,tt,i),Y(i,et),Y(i,jn,i);let a=k(t,Ys,al,{[Us]:!0}),c=k(t,su,sl,{[Us]:!0}),d=Y(t,Gs,sl,{[Us]:!0});k(t,Qs,d),k(c,Ys,a),k(c,Qs,d),Y(c,Gs,d),k(d,su),k(d,Ys),Y(d,Gs,d),k(d,Qs,d);let u=Y(t,qs,mu,{[uu]:!0});k(u,"#"),Y(u,qs,u),k(u,Xy,u);let f=k(u,Zy);k(f,"#"),Y(f,qs,u);let h=[[et,s],[tt,o]],p=[[et,null],[jn,l],[tt,i]];for(let m=0;mm[0]>g[0]?1:-1);for(let m=0;m=0?S[nl]=!0:et.test(g)?tt.test(g)?S[Kn]=!0:S[el]=!0:S[Zs]=!0,iu(t,g,g,S)}return iu(t,"localhost",Qn,{ascii:!0}),t.jd=new xe(Go),{start:t,tokens:fn({groups:e},gu)}}function yu(n,e){let t=t0(e.replace(/[A-Z]/g,l=>l.toLowerCase())),r=t.length,o=[],i=0,s=0;for(;s=0&&(u+=t[s].length,f++),c+=t[s].length,i+=t[s].length,s++;i-=u,s-=f,c-=u,o.push({t:d.t,v:e.slice(i-c,i),s:i-c,e:i})}return o}function t0(n){let e=[],t=n.length,r=0;for(;r56319||r+1===t||(i=n.charCodeAt(r+1))<56320||i>57343?n[r]:n.slice(r,r+2);e.push(s),r+=s.length}return e}function bt(n,e,t,r,o){let i,s=e.length;for(let l=0;l=0;)i++;if(i>0){e.push(t.join(""));for(let s=parseInt(n.substring(r,r+i),10);s>0;s--)t.pop();r+=i}else t.push(n[r]),r++}return e}var Xn={defaultProtocol:"http",events:null,format:au,formatHref:au,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function pl(n,e=null){let t=fn({},Xn);n&&(t=fn(t,n instanceof pl?n.o:n));let r=t.ignoreTags,o=[];for(let i=0;it?r.substring(0,t)+"\u2026":r},toFormattedHref(n){return n.get("formatHref",this.toHref(n.get("defaultProtocol")),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(n=Xn.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(n),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(n){return{type:this.t,value:this.toFormattedString(n),isLink:this.isLink,href:this.toFormattedHref(n),start:this.startIndex(),end:this.endIndex()}},validate(n){return n.get("validate",this.toString(),this)},render(n){let e=this,t=this.toHref(n.get("defaultProtocol")),r=n.get("formatHref",t,this),o=n.get("tagName",t,e),i=this.toFormattedString(n),s={},l=n.get("className",t,e),a=n.get("target",t,e),c=n.get("rel",t,e),d=n.getObj("attributes",t,e),u=n.getObj("events",t,e);return s.href=r,l&&(s.class=l),a&&(s.target=a),c&&(s.rel=c),d&&fn(s,d),{tagName:o,attributes:s,content:i,eventListeners:u}}};function Yo(n,e){class t extends bu{constructor(o,i){super(o,i),this.t=n}}for(let r in e)t.prototype[r]=e[r];return t.t=n,t}var cu=Yo("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),du=Yo("text"),n0=Yo("nl"),wo=Yo("url",{isLink:!0,toHref(n=Xn.defaultProtocol){return this.hasProtocol()?this.v:`${n}://${this.v}`},hasProtocol(){let n=this.tk;return n.length>=2&&n[0].t!==Qn&&n[1].t===kt}});var Oe=n=>new xe(n);function r0({groups:n}){let e=n.domain.concat([Fo,Ho,xt,$o,_o,Vo,jo,Wo,ve,ll,qn,Ko,Jo,Uo,je,Go,Yn,qo]),t=[kt,dl,Ve,ul,qn,Gn,fl,hl,Oo,vo,Jn,Un,Ao,Mo,To,Eo,No,Ro,Do,Io,Po,Lo,Bo,zo],r=[Fo,cl,Ho,$o,_o,Vo,jo,Wo,ve,Jn,Un,qn,Ko,Jo,Uo,Gn,je,Go,Yn,qo],o=Oe(),i=k(o,Yn);P(i,r,i),P(i,n.domain,i);let s=Oe(),l=Oe(),a=Oe();P(o,n.domain,s),P(o,n.scheme,l),P(o,n.slashscheme,a),P(s,r,i),P(s,n.domain,s);let c=k(s,xt);k(i,xt,c),k(l,xt,c),k(a,xt,c);let d=k(i,Ve);P(d,r,i),P(d,n.domain,i);let u=Oe();P(c,n.domain,u),P(u,n.domain,u);let f=k(u,Ve);P(f,n.domain,u);let h=Oe(cu);P(f,n.tld,h),P(f,n.utld,h),k(c,Qn,h);let p=k(u,ve);k(p,ve,p),P(p,n.domain,u),P(h,n.domain,u),k(h,Ve,f),k(h,ve,p);let m=k(h,kt);P(m,n.numeric,cu);let g=k(s,ve),y=k(s,Ve);k(g,ve,g),P(g,n.domain,s),P(y,r,i),P(y,n.domain,s);let S=Oe(wo);P(y,n.tld,S),P(y,n.utld,S),P(S,n.domain,s),P(S,r,i),k(S,Ve,y),k(S,ve,g),k(S,xt,c);let A=k(S,kt),I=Oe(wo);P(A,n.numeric,I);let M=Oe(wo),R=Oe();P(M,e,M),P(M,t,R),P(R,e,M),P(R,t,R),k(S,je,M),k(I,je,M);let _=k(l,kt),Q=k(a,kt),z=k(Q,je),Ce=k(z,je);P(l,n.domain,s),k(l,Ve,y),k(l,ve,g),P(a,n.domain,s),k(a,Ve,y),k(a,ve,g),P(_,n.domain,M),k(_,je,M),k(_,Gn,M),P(Ce,n.domain,M),P(Ce,e,M),k(Ce,je,M);let St=[[Jn,Un],[Mo,Ao],[To,Eo],[Oo,vo],[No,Ro],[Do,Io],[Po,Lo],[Bo,zo]];for(let pn=0;pn=0&&f++,o++,d++;if(f<0)o-=d,o0&&(i.push(Xs(du,e,s)),s=[]),o-=f,d-=f;let h=u.t,p=t.slice(o-d,o);i.push(Xs(h,e,p))}}return s.length>0&&i.push(Xs(du,e,s)),i}function Xs(n,e,t){let r=t[0].s,o=t[t.length-1].e,i=e.slice(r,o);return new n(i,t)}var i0=typeof console!="undefined"&&console&&console.warn||(()=>{}),s0="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",K={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function xu(){return xe.groups={},K.scanner=null,K.parser=null,K.tokenQueue=[],K.pluginQueue=[],K.customSchemes=[],K.initialized=!1,K}function ml(n,e=!1){if(K.initialized&&i0(`linkifyjs: already initialized - will not register custom scheme "${n}" ${s0}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(n))throw new Error(`linkifyjs: incorrect scheme format. +`).filter(l=>l.trim()),s=0;for(let l=0;l({editor:n})=>{let e=Ky(n.getHTML());jy(n,{html:e}).then(t=>{t&&n.chain().focus().setContent(t.html,!0).run()})}}}});var Uy="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2ntley5rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6logistics9properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3ncaster6d0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2psy3ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0america6xi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5m\xF6gensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",qy="\u03B5\u03BB1\u03C52\u0431\u04331\u0435\u043B3\u0434\u0435\u0442\u04384\u0435\u044E2\u043A\u0430\u0442\u043E\u043B\u0438\u043A6\u043E\u043C3\u043C\u043A\u04342\u043E\u043D1\u0441\u043A\u0432\u04306\u043E\u043D\u043B\u0430\u0439\u043D5\u0440\u04333\u0440\u0443\u04412\u04442\u0441\u0430\u0439\u04423\u0440\u04313\u0443\u043A\u04403\u049B\u0430\u04373\u0570\u0561\u05753\u05D9\u05E9\u05E8\u05D0\u05DC5\u05E7\u05D5\u05DD3\u0627\u0628\u0648\u0638\u0628\u064A5\u0631\u0627\u0645\u0643\u06485\u0644\u0627\u0631\u062F\u06464\u0628\u062D\u0631\u064A\u06465\u062C\u0632\u0627\u0626\u06315\u0633\u0639\u0648\u062F\u064A\u06296\u0639\u0644\u064A\u0627\u06465\u0645\u063A\u0631\u06285\u0645\u0627\u0631\u0627\u062A5\u06CC\u0631\u0627\u06465\u0628\u0627\u0631\u062A2\u0632\u0627\u06314\u064A\u062A\u06433\u06BE\u0627\u0631\u062A5\u062A\u0648\u0646\u06334\u0633\u0648\u062F\u0627\u06463\u0631\u064A\u06295\u0634\u0628\u0643\u06294\u0639\u0631\u0627\u06422\u06282\u0645\u0627\u06464\u0641\u0644\u0633\u0637\u064A\u06466\u0642\u0637\u06313\u0643\u0627\u062B\u0648\u0644\u064A\u06436\u0648\u06453\u0645\u0635\u06312\u0644\u064A\u0633\u064A\u06275\u0648\u0631\u064A\u062A\u0627\u0646\u064A\u06277\u0642\u06394\u0647\u0645\u0631\u0627\u06475\u067E\u0627\u06A9\u0633\u062A\u0627\u06467\u0680\u0627\u0631\u062A4\u0915\u0949\u092E3\u0928\u0947\u091F3\u092D\u093E\u0930\u09240\u092E\u094D3\u094B\u09245\u0938\u0902\u0917\u0920\u09285\u09AC\u09BE\u0982\u09B2\u09BE5\u09AD\u09BE\u09B0\u09A42\u09F0\u09A44\u0A2D\u0A3E\u0A30\u0A244\u0AAD\u0ABE\u0AB0\u0AA44\u0B2D\u0B3E\u0B30\u0B244\u0B87\u0BA8\u0BCD\u0BA4\u0BBF\u0BAF\u0BBE6\u0BB2\u0B99\u0BCD\u0B95\u0BC86\u0B9A\u0BBF\u0B99\u0BCD\u0B95\u0BAA\u0BCD\u0BAA\u0BC2\u0BB0\u0BCD11\u0C2D\u0C3E\u0C30\u0C24\u0C4D5\u0CAD\u0CBE\u0CB0\u0CA44\u0D2D\u0D3E\u0D30\u0D24\u0D025\u0DBD\u0D82\u0D9A\u0DCF4\u0E04\u0E2D\u0E213\u0E44\u0E17\u0E223\u0EA5\u0EB2\u0EA73\u10D2\u10D42\u307F\u3093\u306A3\u30A2\u30DE\u30BE\u30F34\u30AF\u30E9\u30A6\u30C94\u30B0\u30FC\u30B0\u30EB4\u30B3\u30E02\u30B9\u30C8\u30A23\u30BB\u30FC\u30EB3\u30D5\u30A1\u30C3\u30B7\u30E7\u30F36\u30DD\u30A4\u30F3\u30C84\u4E16\u754C2\u4E2D\u4FE11\u56FD1\u570B1\u6587\u7F513\u4E9A\u9A6C\u900A3\u4F01\u4E1A2\u4F5B\u5C712\u4FE1\u606F2\u5065\u5EB72\u516B\u53662\u516C\u53F81\u76CA2\u53F0\u6E7E1\u70632\u5546\u57CE1\u5E971\u68072\u5609\u91CC0\u5927\u9152\u5E975\u5728\u7EBF2\u5927\u62FF2\u5929\u4E3B\u65593\u5A31\u4E502\u5BB6\u96FB2\u5E7F\u4E1C2\u5FAE\u535A2\u6148\u55842\u6211\u7231\u4F603\u624B\u673A2\u62DB\u80582\u653F\u52A11\u5E9C2\u65B0\u52A0\u57612\u95FB2\u65F6\u5C1A2\u66F8\u7C4D2\u673A\u67842\u6DE1\u9A6C\u95213\u6E38\u620F2\u6FB3\u95802\u70B9\u770B2\u79FB\u52A82\u7EC4\u7EC7\u673A\u67844\u7F51\u57401\u5E971\u7AD91\u7EDC2\u8054\u901A2\u8C37\u6B4C2\u8D2D\u72692\u901A\u8CA92\u96C6\u56E22\u96FB\u8A0A\u76C8\u79D14\u98DE\u5229\u6D663\u98DF\u54C12\u9910\u53852\u9999\u683C\u91CC\u62C93\u6E2F2\uB2F7\uB1371\uCEF42\uC0BC\uC1312\uD55C\uAD6D2",fn=(n,e)=>{for(let t in e)n[t]=e[t];return n},Zs="numeric",el="ascii",tl="alpha",Kn="asciinumeric",Wn="alphanumeric",nl="domain",fu="emoji",Gy="scheme",Yy="slashscheme",Us="whitespace";function Qy(n,e){return n in e||(e[n]=[]),e[n]}function Ht(n,e,t){e[Zs]&&(e[Kn]=!0,e[Wn]=!0),e[el]&&(e[Kn]=!0,e[tl]=!0),e[Kn]&&(e[Wn]=!0),e[tl]&&(e[Wn]=!0),e[Wn]&&(e[nl]=!0),e[fu]&&(e[nl]=!0);for(let r in e){let o=Qy(r,t);o.indexOf(n)<0&&o.push(n)}}function Xy(n,e){let t={};for(let r in e)e[r].indexOf(n)>=0&&(t[r]=!0);return t}function xe(n=null){this.j={},this.jr=[],this.jd=null,this.t=n}xe.groups={};xe.prototype={accepts(){return!!this.t},go(n){let e=this,t=e.j[n];if(t)return t;for(let r=0;rn.ta(e,t,r,o),Y=(n,e,t,r,o)=>n.tr(e,t,r,o),su=(n,e,t,r,o)=>n.ts(e,t,r,o),k=(n,e,t,r,o)=>n.tt(e,t,r,o),nt="WORD",rl="UWORD",pu="ASCIINUMERICAL",hu="ALPHANUMERICAL",Qn="LOCALHOST",ol="TLD",il="UTLD",Co="SCHEME",un="SLASH_SCHEME",ll="NUM",sl="WS",al="NL",Jn="OPENBRACE",Un="CLOSEBRACE",Mo="OPENBRACKET",To="CLOSEBRACKET",Ao="OPENPAREN",Eo="CLOSEPAREN",vo="OPENANGLEBRACKET",Oo="CLOSEANGLEBRACKET",No="FULLWIDTHLEFTPAREN",Ro="FULLWIDTHRIGHTPAREN",Do="LEFTCORNERBRACKET",Io="RIGHTCORNERBRACKET",Po="LEFTWHITECORNERBRACKET",Lo="RIGHTWHITECORNERBRACKET",zo="FULLWIDTHLESSTHAN",Bo="FULLWIDTHGREATERTHAN",Fo="AMPERSAND",cl="APOSTROPHE",Ho="ASTERISK",xt="AT",$o="BACKSLASH",_o="BACKTICK",Vo="CARET",kt="COLON",dl="COMMA",jo="DOLLAR",Ve="DOT",Wo="EQUALS",ul="EXCLAMATION",Oe="HYPHEN",qn="PERCENT",Ko="PIPE",Jo="PLUS",Uo="POUND",Gn="QUERY",fl="QUOTE",mu="FULLWIDTHMIDDLEDOT",pl="SEMI",je="SLASH",Yn="TILDE",qo="UNDERSCORE",gu="EMOJI",Go="SYM",yu=Object.freeze({__proto__:null,WORD:nt,UWORD:rl,ASCIINUMERICAL:pu,ALPHANUMERICAL:hu,LOCALHOST:Qn,TLD:ol,UTLD:il,SCHEME:Co,SLASH_SCHEME:un,NUM:ll,WS:sl,NL:al,OPENBRACE:Jn,CLOSEBRACE:Un,OPENBRACKET:Mo,CLOSEBRACKET:To,OPENPAREN:Ao,CLOSEPAREN:Eo,OPENANGLEBRACKET:vo,CLOSEANGLEBRACKET:Oo,FULLWIDTHLEFTPAREN:No,FULLWIDTHRIGHTPAREN:Ro,LEFTCORNERBRACKET:Do,RIGHTCORNERBRACKET:Io,LEFTWHITECORNERBRACKET:Po,RIGHTWHITECORNERBRACKET:Lo,FULLWIDTHLESSTHAN:zo,FULLWIDTHGREATERTHAN:Bo,AMPERSAND:Fo,APOSTROPHE:cl,ASTERISK:Ho,AT:xt,BACKSLASH:$o,BACKTICK:_o,CARET:Vo,COLON:kt,COMMA:dl,DOLLAR:jo,DOT:Ve,EQUALS:Wo,EXCLAMATION:ul,HYPHEN:Oe,PERCENT:qn,PIPE:Ko,PLUS:Jo,POUND:Uo,QUERY:Gn,QUOTE:fl,FULLWIDTHMIDDLEDOT:mu,SEMI:pl,SLASH:je,TILDE:Yn,UNDERSCORE:qo,EMOJI:gu,SYM:Go}),et=/[a-z]/,jn=new RegExp("\\p{L}","u"),qs=new RegExp("\\p{Emoji}","u");var tt=/\d/,Gs=/\s/;var lu="\r",Ys=` +`,Zy="\uFE0F",e0="\u200D",Qs="\uFFFC",ko=null,wo=null;function t0(n=[]){let e={};xe.groups=e;let t=new xe;ko==null&&(ko=au(Uy)),wo==null&&(wo=au(qy)),k(t,"'",cl),k(t,"{",Jn),k(t,"}",Un),k(t,"[",Mo),k(t,"]",To),k(t,"(",Ao),k(t,")",Eo),k(t,"<",vo),k(t,">",Oo),k(t,"\uFF08",No),k(t,"\uFF09",Ro),k(t,"\u300C",Do),k(t,"\u300D",Io),k(t,"\u300E",Po),k(t,"\u300F",Lo),k(t,"\uFF1C",zo),k(t,"\uFF1E",Bo),k(t,"&",Fo),k(t,"*",Ho),k(t,"@",xt),k(t,"`",_o),k(t,"^",Vo),k(t,":",kt),k(t,",",dl),k(t,"$",jo),k(t,".",Ve),k(t,"=",Wo),k(t,"!",ul),k(t,"-",Oe),k(t,"%",qn),k(t,"|",Ko),k(t,"+",Jo),k(t,"#",Uo),k(t,"?",Gn),k(t,'"',fl),k(t,"/",je),k(t,";",pl),k(t,"~",Yn),k(t,"_",qo),k(t,"\\",$o),k(t,"\u30FB",mu);let r=Y(t,tt,ll,{[Zs]:!0});Y(r,tt,r);let o=Y(r,et,pu,{[Kn]:!0}),i=Y(r,jn,hu,{[Wn]:!0}),s=Y(t,et,nt,{[el]:!0});Y(s,tt,o),Y(s,et,s),Y(o,tt,o),Y(o,et,o);let l=Y(t,jn,rl,{[tl]:!0});Y(l,et),Y(l,tt,i),Y(l,jn,l),Y(i,tt,i),Y(i,et),Y(i,jn,i);let a=k(t,Ys,al,{[Us]:!0}),c=k(t,lu,sl,{[Us]:!0}),d=Y(t,Gs,sl,{[Us]:!0});k(t,Qs,d),k(c,Ys,a),k(c,Qs,d),Y(c,Gs,d),k(d,lu),k(d,Ys),Y(d,Gs,d),k(d,Qs,d);let u=Y(t,qs,gu,{[fu]:!0});k(u,"#"),Y(u,qs,u),k(u,Zy,u);let f=k(u,e0);k(f,"#"),Y(f,qs,u);let p=[[et,s],[tt,o]],h=[[et,null],[jn,l],[tt,i]];for(let m=0;mm[0]>g[0]?1:-1);for(let m=0;m=0?w[nl]=!0:et.test(g)?tt.test(g)?w[Kn]=!0:w[el]=!0:w[Zs]=!0,su(t,g,g,w)}return su(t,"localhost",Qn,{ascii:!0}),t.jd=new xe(Go),{start:t,tokens:fn({groups:e},yu)}}function bu(n,e){let t=n0(e.replace(/[A-Z]/g,l=>l.toLowerCase())),r=t.length,o=[],i=0,s=0;for(;s=0&&(u+=t[s].length,f++),c+=t[s].length,i+=t[s].length,s++;i-=u,s-=f,c-=u,o.push({t:d.t,v:e.slice(i-c,i),s:i-c,e:i})}return o}function n0(n){let e=[],t=n.length,r=0;for(;r56319||r+1===t||(i=n.charCodeAt(r+1))<56320||i>57343?n[r]:n.slice(r,r+2);e.push(s),r+=s.length}return e}function bt(n,e,t,r,o){let i,s=e.length;for(let l=0;l=0;)i++;if(i>0){e.push(t.join(""));for(let s=parseInt(n.substring(r,r+i),10);s>0;s--)t.pop();r+=i}else t.push(n[r]),r++}return e}var Xn={defaultProtocol:"http",events:null,format:cu,formatHref:cu,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function hl(n,e=null){let t=fn({},Xn);n&&(t=fn(t,n instanceof hl?n.o:n));let r=t.ignoreTags,o=[];for(let i=0;it?r.substring(0,t)+"\u2026":r},toFormattedHref(n){return n.get("formatHref",this.toHref(n.get("defaultProtocol")),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(n=Xn.defaultProtocol){return{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(n),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(n){return{type:this.t,value:this.toFormattedString(n),isLink:this.isLink,href:this.toFormattedHref(n),start:this.startIndex(),end:this.endIndex()}},validate(n){return n.get("validate",this.toString(),this)},render(n){let e=this,t=this.toHref(n.get("defaultProtocol")),r=n.get("formatHref",t,this),o=n.get("tagName",t,e),i=this.toFormattedString(n),s={},l=n.get("className",t,e),a=n.get("target",t,e),c=n.get("rel",t,e),d=n.getObj("attributes",t,e),u=n.getObj("events",t,e);return s.href=r,l&&(s.class=l),a&&(s.target=a),c&&(s.rel=c),d&&fn(s,d),{tagName:o,attributes:s,content:i,eventListeners:u}}};function Yo(n,e){class t extends xu{constructor(o,i){super(o,i),this.t=n}}for(let r in e)t.prototype[r]=e[r];return t.t=n,t}var du=Yo("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),uu=Yo("text"),r0=Yo("nl"),So=Yo("url",{isLink:!0,toHref(n=Xn.defaultProtocol){return this.hasProtocol()?this.v:`${n}://${this.v}`},hasProtocol(){let n=this.tk;return n.length>=2&&n[0].t!==Qn&&n[1].t===kt}});var ve=n=>new xe(n);function o0({groups:n}){let e=n.domain.concat([Fo,Ho,xt,$o,_o,Vo,jo,Wo,Oe,ll,qn,Ko,Jo,Uo,je,Go,Yn,qo]),t=[kt,dl,Ve,ul,qn,Gn,fl,pl,vo,Oo,Jn,Un,To,Mo,Ao,Eo,No,Ro,Do,Io,Po,Lo,zo,Bo],r=[Fo,cl,Ho,$o,_o,Vo,jo,Wo,Oe,Jn,Un,qn,Ko,Jo,Uo,Gn,je,Go,Yn,qo],o=ve(),i=k(o,Yn);P(i,r,i),P(i,n.domain,i);let s=ve(),l=ve(),a=ve();P(o,n.domain,s),P(o,n.scheme,l),P(o,n.slashscheme,a),P(s,r,i),P(s,n.domain,s);let c=k(s,xt);k(i,xt,c),k(l,xt,c),k(a,xt,c);let d=k(i,Ve);P(d,r,i),P(d,n.domain,i);let u=ve();P(c,n.domain,u),P(u,n.domain,u);let f=k(u,Ve);P(f,n.domain,u);let p=ve(du);P(f,n.tld,p),P(f,n.utld,p),k(c,Qn,p);let h=k(u,Oe);k(h,Oe,h),P(h,n.domain,u),P(p,n.domain,u),k(p,Ve,f),k(p,Oe,h);let m=k(p,kt);P(m,n.numeric,du);let g=k(s,Oe),y=k(s,Ve);k(g,Oe,g),P(g,n.domain,s),P(y,r,i),P(y,n.domain,s);let w=ve(So);P(y,n.tld,w),P(y,n.utld,w),P(w,n.domain,s),P(w,r,i),k(w,Ve,y),k(w,Oe,g),k(w,xt,c);let T=k(w,kt),I=ve(So);P(T,n.numeric,I);let M=ve(So),R=ve();P(M,e,M),P(M,t,R),P(R,e,M),P(R,t,R),k(w,je,M),k(I,je,M);let _=k(l,kt),Q=k(a,kt),B=k(Q,je),Ce=k(B,je);P(l,n.domain,s),k(l,Ve,y),k(l,Oe,g),P(a,n.domain,s),k(a,Ve,y),k(a,Oe,g),P(_,n.domain,M),k(_,je,M),k(_,Gn,M),P(Ce,n.domain,M),P(Ce,e,M),k(Ce,je,M);let wt=[[Jn,Un],[Mo,To],[Ao,Eo],[vo,Oo],[No,Ro],[Do,Io],[Po,Lo],[zo,Bo]];for(let hn=0;hn=0&&f++,o++,d++;if(f<0)o-=d,o0&&(i.push(Xs(uu,e,s)),s=[]),o-=f,d-=f;let p=u.t,h=t.slice(o-d,o);i.push(Xs(p,e,h))}}return s.length>0&&i.push(Xs(uu,e,s)),i}function Xs(n,e,t){let r=t[0].s,o=t[t.length-1].e,i=e.slice(r,o);return new n(i,t)}var s0=typeof console!="undefined"&&console&&console.warn||(()=>{}),l0="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",K={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function ku(){return xe.groups={},K.scanner=null,K.parser=null,K.tokenQueue=[],K.pluginQueue=[],K.customSchemes=[],K.initialized=!1,K}function ml(n,e=!1){if(K.initialized&&s0(`linkifyjs: already initialized - will not register custom scheme "${n}" ${l0}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(n))throw new Error(`linkifyjs: incorrect scheme format. 1. Must only contain digits, lowercase ASCII letters or "-" 2. Cannot start or end with "-" -3. "-" cannot repeat`);K.customSchemes.push([n,e])}function l0(){K.scanner=e0(K.customSchemes);for(let n=0;n{let o=e.some(c=>c.docChanged)&&!t.doc.eq(r.doc),i=e.some(c=>c.getMeta("preventAutolink"));if(!o||i)return;let{tr:s}=r,l=ad(t.doc,[...e]);if(ud(l).forEach(({newRange:c})=>{let d=cd(r.doc,c,h=>h.isTextblock),u,f;if(d.length>1?(u=d[0],f=r.doc.textBetween(u.pos,u.pos+u.node.nodeSize,void 0," ")):d.length&&r.doc.textBetween(c.from,c.to," "," ").endsWith(" ")&&(u=d[0],f=r.doc.textBetween(u.pos,c.to,void 0," ")),u&&f){let h=f.split(" ").filter(y=>y!=="");if(h.length<=0)return!1;let p=h[h.length-1],m=u.pos+f.lastIndexOf(p);if(!p)return!1;let g=Qo(p).map(y=>y.toObject(n.defaultProtocol));if(!a0(g))return!1;g.filter(y=>y.isLink).map(y=>N(b({},y),{from:m+y.start+1,to:m+y.end+1})).filter(y=>r.schema.marks.code?!r.doc.rangeHasMark(y.from,y.to,r.schema.marks.code):!0).filter(y=>n.validate(y.value)).filter(y=>n.shouldAutoLink(y.value)).forEach(y=>{ro(y.from,y.to,r.doc).some(S=>S.mark.type===n.type)||s.addMark(y.from,y.to,n.type.create({href:y.href}))})}}),!!s.steps.length)return s}})}function d0(n){return new L({key:new j("handleClickLink"),props:{handleClick:(e,t,r)=>{var o,i;if(r.button!==0||!e.editable)return!1;let s=r.target,l=[];for(;s.nodeName!=="DIV";)l.push(s),s=s.parentNode;if(!l.find(f=>f.nodeName==="A"))return!1;let a=Ts(e.state,n.type.name),c=r.target,d=(o=c==null?void 0:c.href)!==null&&o!==void 0?o:a.href,u=(i=c==null?void 0:c.target)!==null&&i!==void 0?i:a.target;return c&&d?(window.open(d,u),!0):!1}}})}function u0(n){return new L({key:new j("handlePasteLink"),props:{handlePaste:(e,t,r)=>{let{state:o}=e,{selection:i}=o,{empty:s}=i;if(s)return!1;let l="";r.content.forEach(c=>{l+=c.textContent});let a=gl(l,{defaultProtocol:n.defaultProtocol}).find(c=>c.isLink&&c.value===l);return!l||!a?!1:n.editor.commands.setMark(n.type,{href:a.href})}}})}var f0=/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g;function $t(n,e){let t=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return e&&e.forEach(r=>{let o=typeof r=="string"?r:r.scheme;o&&t.push(o)}),!n||n.replace(f0,"").match(new RegExp(`^(?:(?:${t.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}var ku=J.create({name:"link",priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.validate&&!this.options.shouldAutoLink&&(this.options.shouldAutoLink=this.options.validate,console.warn("The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.")),this.options.protocols.forEach(n=>{if(typeof n=="string"){ml(n);return}ml(n.scheme,n.optionalSlashes)})},onDestroy(){xu()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,linkOnPaste:!0,autolink:!0,protocols:[],defaultProtocol:"http",HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},isAllowedUri:(n,e)=>!!$t(n,e.protocols),validate:n=>!!n,shouldAutoLink:n=>!!n}},addAttributes(){return{href:{default:null,parseHTML(n){return n.getAttribute("href")}},target:{default:this.options.HTMLAttributes.target},rel:{default:this.options.HTMLAttributes.rel},class:{default:this.options.HTMLAttributes.class}}},parseHTML(){return[{tag:"a[href]",getAttrs:n=>{let e=n.getAttribute("href");return!e||!this.options.isAllowedUri(e,{defaultValidate:t=>!!$t(t,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:n}){return this.options.isAllowedUri(n.href,{defaultValidate:e=>!!$t(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",v(this.options.HTMLAttributes,n),0]:["a",v(this.options.HTMLAttributes,N(b({},n),{href:""})),0]},addCommands(){return{setLink:n=>({chain:e})=>{let{href:t}=n;return this.options.isAllowedUri(t,{defaultValidate:r=>!!$t(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?e().setMark(this.name,n).setMeta("preventAutolink",!0).run():!1},toggleLink:n=>({chain:e})=>{let{href:t}=n;return this.options.isAllowedUri(t,{defaultValidate:r=>!!$t(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?e().toggleMark(this.name,n,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run():!1},unsetLink:()=>({chain:n})=>n().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addPasteRules(){return[be({find:n=>{let e=[];if(n){let{protocols:t,defaultProtocol:r}=this.options,o=gl(n).filter(i=>i.isLink&&this.options.isAllowedUri(i.value,{defaultValidate:s=>!!$t(s,t),protocols:t,defaultProtocol:r}));o.length&&o.forEach(i=>e.push({text:i.value,data:{href:i.href},index:i.start}))}return e},type:this.type,getAttributes:n=>{var e;return{href:(e=n.data)===null||e===void 0?void 0:e.href}}})]},addProseMirrorPlugins(){let n=[],{protocols:e,defaultProtocol:t}=this.options;return this.options.autolink&&n.push(c0({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:o=>!!$t(o,e),protocols:e,defaultProtocol:t}),shouldAutoLink:this.options.shouldAutoLink})),this.options.openOnClick===!0&&n.push(d0({type:this.type})),this.options.linkOnPaste&&n.push(u0({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type})),n}});var h0=yt({href:{type:"string",title:$("URL")},title:{type:"string",title:$("Title")},openInNewWindow:{type:"boolean",title:$("Open in new window")}},{title:$("Edit Link")}),p0=(n,e)=>Tl(void 0,null,function*(){if(e=e||{},e.openInNewWindow=e.target==="_blank",e=yield h0(n,e),e)return e.openInNewWindow&&(e.target="_blank"),e}),m0=ku.extend({addOptions(){var n;return N(b({},(n=this.parent)==null?void 0:n.call(this)),{openOnClick:!1,HTMLAttributes:{target:null,rel:"noopener noreferrer nofollow",class:null}})},addCommands(){var n;return N(b({},(n=this.parent)==null?void 0:n.call(this)),{addLink:()=>({editor:e})=>{let t=e.getAttributes(this.name);p0(e,t).then(r=>{if(r){let o=e.chain().focus().extendMarkRange(this.name).unsetMark(this.name);o.setMark(this.name,r),o.run()}})}})},addKeyboardShortcuts(){return{"Mod-k":({editor:n})=>{let e;(e=window.event)&&e.preventDefault(),n.commands.addLink()}}}});var g0=H.create({name:"noSpellCheck",addProseMirrorPlugins(){return[new L({view(n){return new yl(n)}})]}}),yl=class{constructor(e){this.editorView=e,this.editorView.dom.setAttribute("spellcheck","false")}update(){}destroy(){this.editorView.dom.removeAttribute("spellcheck")}};var y0=H.create({name:"typographic",addProseMirrorPlugins(){return[Cu]}});function Su(n,e,t,r){let o=n.childCount,i=e.childCount;e:for(let s=0,l=0;s{let t=[];if(n.text)for(let r of n.text.matchAll(/(\u00A0|\u00AD)/g)){let o=e+(r.index||0);t.push(ne.inline(o,o+1,{class:b0[r[1]]}))}return t},x0=n=>{let e=[];return n.descendants((t,r)=>{e.push(wu(t,r))}),q.create(n,e.flat())},Cu=new L({state:{init(n,{doc:e}){return x0(e)},apply(n,e,t){let r=e.map(n.mapping,n.doc);return Su(t.doc,n.doc,0,(o,i)=>{r=r.remove(r.find(i,i+o.content.size)),r=r.add(n.doc,wu(o,i))}),r}},props:{decorations(n){return Cu.getState(n)}}});var k0=H.create({name:"fullscreen",addOptions(){return{fullscreenClass:"prose-editor-fullscreen"}},addCommands(){return{toggleFullscreen:()=>({editor:n})=>{let e=n.storage.fullscreen.fullscreen;n.storage.fullscreen.fullscreen=!e;let t=n.options.element.closest(".prose-editor");if(setTimeout(()=>{n.view.update([])},0),n.storage.fullscreen.fullscreen){t.classList.add(this.options.fullscreenClass),n.storage.fullscreen.scrollPosition=window.scrollY,document.body.style.overflow="hidden",n.commands.focus();let r=t.querySelector(".prose-menubar");r&&(r.classList.remove("prose-menubar--floating"),r.style.width="",r.style.left="",r.style.top="");let o=t.querySelector(".prose-menubar-placeholder");o&&o.classList.remove("prose-menubar-placeholder--active")}else t.classList.remove(this.options.fullscreenClass),document.body.style.overflow="",window.scrollTo(0,n.storage.fullscreen.scrollPosition||0);return!0}}},addStorage(){return{fullscreen:!1,scrollPosition:0}},addKeyboardShortcuts(){return{Escape:()=>this.editor.storage.fullscreen.fullscreen?this.editor.commands.toggleFullscreen():!1,F11:()=>this.editor.commands.toggleFullscreen()}}});var hn=(n,e)=>n.extensionManager.extensions.find(t=>t.name===e),S0=n=>[C0(n),M0(n),T0(n),A0(n),O0(n),v0(n),E0(n),N0(n)].filter(Boolean),mk=H.create({name:"menu",addOptions(){return{menuItems:S0}},addProseMirrorPlugins(){let n=this.editor,e=this.options.menuItems(n);return[new L({view(){let t=new bl(n,e),r=n.view.dom.parentNode;return r.insertBefore(t.placeholder,n.view.dom),r.insertBefore(t.dom,n.view.dom),t}})]}}),bl=class{constructor(e,t){this.items=t.flat(),this.editor=e,this.isFloating=!1,this.dom=W("div",{className:"prose-menubar"}),this.placeholder=W("div",{className:"prose-menubar-placeholder"}),t.filter(o=>o.length).forEach(o=>{let i=W("div",{className:"prose-menubar__group"});this.dom.append(i),o.forEach(({dom:s})=>i.append(s))}),this.update(),this.dom.addEventListener("mousedown",o=>{o.preventDefault(),e.view.focus(),this.items.forEach(({command:i,dom:s})=>{s.contains(o.target)&&i(e)})}),this.handleScroll=this.handleScroll.bind(this),window.addEventListener("scroll",this.handleScroll,{passive:!0}),window.addEventListener("resize",this.handleScroll,{passive:!0});let r=()=>{this.menubarHeight=this.dom.offsetHeight,this.placeholder.style.setProperty("--menubar-height",`${this.menubarHeight}px`),this.handleScroll()};r(),setTimeout(r,100)}handleScroll(){if(this.editor.options.element.closest(".prose-editor-fullscreen"))return;let e=this.editor.options.element.getBoundingClientRect(),t=this.dom.getBoundingClientRect();e.top<0&&e.bottom>t.height?this.isFloating||(this.dom.classList.add("prose-menubar--floating"),this.placeholder.classList.add("prose-menubar-placeholder--active"),this.dom.style.width=`${e.width}px`,this.dom.style.left=`${e.left}px`,this.dom.style.top="0px",this.isFloating=!0):this.isFloating&&(this.dom.classList.remove("prose-menubar--floating"),this.placeholder.classList.remove("prose-menubar-placeholder--active"),this.dom.style.width="",this.dom.style.left="",this.dom.style.top="",this.isFloating=!1)}update(){this.items.forEach(({dom:e,enabled:t=()=>!0,active:r=()=>!1,hidden:o=()=>!1,update:i=null})=>{e.classList.toggle("disabled",!t(this.editor)),e.classList.toggle("active",!!r(this.editor)),e.classList.toggle("hidden",!!o(this.editor)),i&&i(this.editor)})}destroy(){window.removeEventListener("scroll",this.handleScroll),window.removeEventListener("resize",this.handleScroll),this.dom.remove(),this.placeholder.remove()}};function U(n,e){return W("span",{className:"prose-menubar__button material-icons",textContent:n,title:e})}function Zn(n,e=""){return W("span",{className:"prose-menubar__button",innerHTML:n,title:e})}var w0=n=>{let e=W("span",{className:"prose-menubar__button prose-menubar__button--heading",title:`heading ${n}`});return e.append(W("span",{className:"material-icons",textContent:"title"}),W("span",{className:"level",textContent:`${n}`})),{command:t=>{t.chain().focus().toggleHeading({level:n}).run()},dom:e,active(t){return t.isActive("heading",{level:n})}}};function C0(n){let e=n.schema,t=hn(n,"heading"),o=(t?t.options.levels:[]).map(s=>w0(s)),i;return(i=e.nodes.bulletList)&&o.push({command(s){s.chain().focus().toggleBulletList().run()},dom:U("format_list_bulleted","unordered list"),active(s){return!1}}),(i=e.nodes.orderedList)&&(o.push({command(s){s.chain().focus().toggleOrderedList().run()},dom:U("format_list_numbered","ordered list"),active(s){return s.isActive("orderedList")}}),o.push({command(s){s.chain().focus().updateListAttributes().run()},dom:U("tune",$("List properties")),hidden(s){return!s.isActive("orderedList")}})),o.length?[...o,{command(s){s.chain().focus().setParagraph().run()},dom:U("notes","paragraph"),active(s){return!1}}]:null}function M0(n){let e=n.schema,t=[],r;return(r=e.nodes.blockquote)&&t.push({command(o){o.chain().focus().toggleBlockquote().run()},dom:U("format_quote","blockquote"),active(o){return o.isActive("blockquote")}}),(r=e.nodes.horizontalRule)&&t.push({command(o){o.chain().focus().setHorizontalRule().run()},dom:U("horizontal_rule","horizontal rule"),active(o){return!1}}),(r=e.nodes.figure)&&t.push({command(o){o.chain().focus().insertFigure().run()},dom:U("image","figure"),active(o){return o.isActive("figure")}}),t}function A0(n){let e=(t,r)=>t in n.schema.marks?{command(o){o.chain().focus().toggleMark(t).run()},dom:r,active:o=>o.isActive(t)}:null;return[e("bold",U("format_bold","bold")),e("italic",U("format_italic","italic")),e("underline",U("format_underline","underline")),e("strike",U("format_strikethrough","strike")),e("subscript",U("subscript","subscript")),e("superscript",U("superscript","superscript"))].filter(Boolean)}function T0(n){let e=n.schema.marks.link;return e?[{command(t){t.chain().addLink().focus().run()},enabled(t){return!t.state.selection.empty||t.isActive("link")},dom:U("insert_link","insert link"),active(t){return t.isActive(e)}},{command(t){t.chain().focus().unsetLink().run()},dom:U("link_off","remove link"),hidden(t){return!t.isActive("link")}}]:null}function E0(n){return hn(n,"history")?[{command(e){e.commands.undo()},enabled(e){return e.can().undo()},dom:U("undo","undo"),active(){return!1}},{command(e){e.commands.redo()},enabled(e){return e.can().redo()},dom:U("redo","redo"),active(){return!1}}]:null}function O0(n){let e=t=>({command(r){r.chain().focus().setTextAlign(t).run()},dom:U(`format_align_${t}`,t),active(){return n.isActive({textAlign:t})}});return hn(n,"textAlign")?[e("left"),e("center"),e("right"),e("justify")]:null}function v0(n){if(!hn(n,"table"))return null;let e=(t,r)=>({command:t,dom:r,hidden(){return!n.isActive("table")}});return[{command(t){t.chain().focus().insertTableWithOptions().run()},dom:U("grid_on","Insert table")},e(t=>{t.chain().focus().addColumnAfter().run()},Zn(` +3. "-" cannot repeat`);K.customSchemes.push([n,e])}function a0(){K.scanner=t0(K.customSchemes);for(let n=0;n{let o=e.some(c=>c.docChanged)&&!t.doc.eq(r.doc),i=e.some(c=>c.getMeta("preventAutolink"));if(!o||i)return;let{tr:s}=r,l=cd(t.doc,[...e]);if(fd(l).forEach(({newRange:c})=>{let d=dd(r.doc,c,p=>p.isTextblock),u,f;if(d.length>1?(u=d[0],f=r.doc.textBetween(u.pos,u.pos+u.node.nodeSize,void 0," ")):d.length&&r.doc.textBetween(c.from,c.to," "," ").endsWith(" ")&&(u=d[0],f=r.doc.textBetween(u.pos,c.to,void 0," ")),u&&f){let p=f.split(" ").filter(y=>y!=="");if(p.length<=0)return!1;let h=p[p.length-1],m=u.pos+f.lastIndexOf(h);if(!h)return!1;let g=Qo(h).map(y=>y.toObject(n.defaultProtocol));if(!c0(g))return!1;g.filter(y=>y.isLink).map(y=>N(b({},y),{from:m+y.start+1,to:m+y.end+1})).filter(y=>r.schema.marks.code?!r.doc.rangeHasMark(y.from,y.to,r.schema.marks.code):!0).filter(y=>n.validate(y.value)).filter(y=>n.shouldAutoLink(y.value)).forEach(y=>{ro(y.from,y.to,r.doc).some(w=>w.mark.type===n.type)||s.addMark(y.from,y.to,n.type.create({href:y.href}))})}}),!!s.steps.length)return s}})}function u0(n){return new L({key:new j("handleClickLink"),props:{handleClick:(e,t,r)=>{var o,i;if(r.button!==0||!e.editable)return!1;let s=r.target,l=[];for(;s.nodeName!=="DIV";)l.push(s),s=s.parentNode;if(!l.find(f=>f.nodeName==="A"))return!1;let a=As(e.state,n.type.name),c=r.target,d=(o=c==null?void 0:c.href)!==null&&o!==void 0?o:a.href,u=(i=c==null?void 0:c.target)!==null&&i!==void 0?i:a.target;return c&&d?(window.open(d,u),!0):!1}}})}function f0(n){return new L({key:new j("handlePasteLink"),props:{handlePaste:(e,t,r)=>{let{state:o}=e,{selection:i}=o,{empty:s}=i;if(s)return!1;let l="";r.content.forEach(c=>{l+=c.textContent});let a=gl(l,{defaultProtocol:n.defaultProtocol}).find(c=>c.isLink&&c.value===l);return!l||!a?!1:n.editor.commands.setMark(n.type,{href:a.href})}}})}var p0=/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g;function $t(n,e){let t=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return e&&e.forEach(r=>{let o=typeof r=="string"?r:r.scheme;o&&t.push(o)}),!n||n.replace(p0,"").match(new RegExp(`^(?:(?:${t.join("|")}):|[^a-z]|[a-z0-9+.-]+(?:[^a-z+.-:]|$))`,"i"))}var wu=J.create({name:"link",priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.validate&&!this.options.shouldAutoLink&&(this.options.shouldAutoLink=this.options.validate,console.warn("The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.")),this.options.protocols.forEach(n=>{if(typeof n=="string"){ml(n);return}ml(n.scheme,n.optionalSlashes)})},onDestroy(){ku()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,linkOnPaste:!0,autolink:!0,protocols:[],defaultProtocol:"http",HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},isAllowedUri:(n,e)=>!!$t(n,e.protocols),validate:n=>!!n,shouldAutoLink:n=>!!n}},addAttributes(){return{href:{default:null,parseHTML(n){return n.getAttribute("href")}},target:{default:this.options.HTMLAttributes.target},rel:{default:this.options.HTMLAttributes.rel},class:{default:this.options.HTMLAttributes.class}}},parseHTML(){return[{tag:"a[href]",getAttrs:n=>{let e=n.getAttribute("href");return!e||!this.options.isAllowedUri(e,{defaultValidate:t=>!!$t(t,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?!1:null}}]},renderHTML({HTMLAttributes:n}){return this.options.isAllowedUri(n.href,{defaultValidate:e=>!!$t(e,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?["a",O(this.options.HTMLAttributes,n),0]:["a",O(this.options.HTMLAttributes,N(b({},n),{href:""})),0]},addCommands(){return{setLink:n=>({chain:e})=>{let{href:t}=n;return this.options.isAllowedUri(t,{defaultValidate:r=>!!$t(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?e().setMark(this.name,n).setMeta("preventAutolink",!0).run():!1},toggleLink:n=>({chain:e})=>{let{href:t}=n;return this.options.isAllowedUri(t,{defaultValidate:r=>!!$t(r,this.options.protocols),protocols:this.options.protocols,defaultProtocol:this.options.defaultProtocol})?e().toggleMark(this.name,n,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run():!1},unsetLink:()=>({chain:n})=>n().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addPasteRules(){return[be({find:n=>{let e=[];if(n){let{protocols:t,defaultProtocol:r}=this.options,o=gl(n).filter(i=>i.isLink&&this.options.isAllowedUri(i.value,{defaultValidate:s=>!!$t(s,t),protocols:t,defaultProtocol:r}));o.length&&o.forEach(i=>e.push({text:i.value,data:{href:i.href},index:i.start}))}return e},type:this.type,getAttributes:n=>{var e;return{href:(e=n.data)===null||e===void 0?void 0:e.href}}})]},addProseMirrorPlugins(){let n=[],{protocols:e,defaultProtocol:t}=this.options;return this.options.autolink&&n.push(d0({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:r=>this.options.isAllowedUri(r,{defaultValidate:o=>!!$t(o,e),protocols:e,defaultProtocol:t}),shouldAutoLink:this.options.shouldAutoLink})),this.options.openOnClick===!0&&n.push(u0({type:this.type})),this.options.linkOnPaste&&n.push(f0({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type})),n}});var h0=yt({href:{type:"string",title:$("URL")},title:{type:"string",title:$("Title")},openInNewWindow:{type:"boolean",title:$("Open in new window")}},{title:$("Edit Link")}),m0=(n,e)=>El(void 0,null,function*(){if(e=e||{},e.openInNewWindow=e.target==="_blank",e=yield h0(n,e),e)return e.openInNewWindow&&(e.target="_blank"),e}),g0=wu.extend({addOptions(){var n;return N(b({},(n=this.parent)==null?void 0:n.call(this)),{openOnClick:!1,HTMLAttributes:{target:null,rel:"noopener noreferrer nofollow",class:null}})},addCommands(){var n;return N(b({},(n=this.parent)==null?void 0:n.call(this)),{addLink:()=>({editor:e})=>{let t=e.getAttributes(this.name);m0(e,t).then(r=>{if(r){let o=e.chain().focus().extendMarkRange(this.name).unsetMark(this.name);o.setMark(this.name,r),o.run()}})}})},addKeyboardShortcuts(){return{"Mod-k":({editor:n})=>{let e;(e=window.event)&&e.preventDefault(),n.commands.addLink()}}}});var y0=H.create({name:"noSpellCheck",addProseMirrorPlugins(){return[new L({view(n){return new yl(n)}})]}}),yl=class{constructor(e){this.editorView=e,this.editorView.dom.setAttribute("spellcheck","false")}update(){}destroy(){this.editorView.dom.removeAttribute("spellcheck")}};var b0=H.create({name:"typographic",addProseMirrorPlugins(){return[Mu,x0]}}),Su={"\xA0":"prose-editor-nbsp","\xAD":"prose-editor-shy","\u200B":"prose-editor-zwsp","\u200C":"prose-editor-zwnj","\u200D":"prose-editor-zwj","\u2060":"prose-editor-wj","\u2028":"prose-editor-ls","\u2029":"prose-editor-ps","\u2003":"prose-editor-emsp","\u2009":"prose-editor-thinsp","\u202F":"prose-editor-nnbsp","\u2002":"prose-editor-ensp","\u2004":"prose-editor-3persp","\u2005":"prose-editor-4persp","\u2006":"prose-editor-6persp","\u2007":"prose-editor-figsp","\u2008":"prose-editor-psp","\u205F":"prose-editor-mmsp","\u180E":"prose-editor-mvs","\uFEFF":"prose-editor-bom"},bl=class{constructor(e){this.dom=document.createElement("span"),this.dom.className="prose-editor-br-container";let t=document.createElement("span");t.className="prose-editor-br-marker",t.textContent="\u21B5",this.dom.appendChild(t);let r=document.createElement("br");this.dom.appendChild(r),this.contentDOM=null}update(e){return e.type.name==="hardBreak"}stopEvent(){return!1}ignoreMutation(){return!0}},x0=new L({props:{nodeViews:{hardBreak:(n,e,t)=>new bl(n)}}}),k0=(n,e)=>{let t=[];if(n.text){let r=new RegExp(`([${Object.keys(Su).join("")}])`,"g");for(let o of n.text.matchAll(r)){let i=e+(o.index||0);t.push(ne.inline(i,i+1,{class:Su[o[1]]}))}}return t},Cu=n=>{let e=[];return n.descendants((t,r)=>{e.push(k0(t,r))}),q.create(n,e.flat())},Mu=new L({state:{init(n,{doc:e}){return Cu(e)},apply(n,e,t){return n.docChanged?Cu(n.doc):e.map(n.mapping,n.doc)}},props:{decorations(n){return Mu.getState(n)}}});var w0=H.create({name:"fullscreen",addOptions(){return{fullscreenClass:"prose-editor-fullscreen"}},addCommands(){return{toggleFullscreen:()=>({editor:n})=>{let e=n.storage.fullscreen.fullscreen;n.storage.fullscreen.fullscreen=!e;let t=n.options.element.closest(".prose-editor");if(setTimeout(()=>{n.view.update([])},0),n.storage.fullscreen.fullscreen){t.classList.add(this.options.fullscreenClass),n.storage.fullscreen.scrollPosition=window.scrollY,document.body.style.overflow="hidden",n.commands.focus();let r=t.querySelector(".prose-menubar");r&&(r.classList.remove("prose-menubar--floating"),r.style.width="",r.style.left="",r.style.top="");let o=t.querySelector(".prose-menubar-placeholder");o&&o.classList.remove("prose-menubar-placeholder--active")}else t.classList.remove(this.options.fullscreenClass),document.body.style.overflow="",window.scrollTo(0,n.storage.fullscreen.scrollPosition||0);return!0}}},addStorage(){return{fullscreen:!1,scrollPosition:0}},addKeyboardShortcuts(){return{Escape:()=>this.editor.storage.fullscreen.fullscreen?this.editor.commands.toggleFullscreen():!1,F11:()=>this.editor.commands.toggleFullscreen()}}});var pn=(n,e)=>n.extensionManager.extensions.find(t=>t.name===e),S0=n=>[M0(n),T0(n),E0(n),A0(n),O0(n),N0(n),v0(n),R0(n)].filter(Boolean),gk=H.create({name:"menu",addOptions(){return{menuItems:S0}},addProseMirrorPlugins(){let n=this.editor,e=this.options.menuItems(n);return[new L({view(){let t=new xl(n,e),r=n.view.dom.parentNode;return r.insertBefore(t.placeholder,n.view.dom),r.insertBefore(t.dom,n.view.dom),t}})]}}),xl=class{constructor(e,t){this.items=t.flat(),this.editor=e,this.isFloating=!1,this.dom=W("div",{className:"prose-menubar"}),this.placeholder=W("div",{className:"prose-menubar-placeholder"}),t.filter(o=>o.length).forEach(o=>{let i=W("div",{className:"prose-menubar__group"});this.dom.append(i),o.forEach(({dom:s})=>i.append(s))}),this.update(),this.dom.addEventListener("mousedown",o=>{o.preventDefault(),e.view.focus(),this.items.forEach(({command:i,dom:s})=>{s.contains(o.target)&&i(e)})}),this.handleScroll=this.handleScroll.bind(this),window.addEventListener("scroll",this.handleScroll,{passive:!0}),window.addEventListener("resize",this.handleScroll,{passive:!0});let r=()=>{this.menubarHeight=this.dom.offsetHeight,this.placeholder.style.setProperty("--menubar-height",`${this.menubarHeight}px`),this.handleScroll()};r(),setTimeout(r,100)}handleScroll(){if(this.editor.options.element.closest(".prose-editor-fullscreen"))return;let e=this.editor.options.element.getBoundingClientRect(),t=this.dom.getBoundingClientRect();e.top<0&&e.bottom>t.height?this.isFloating||(this.dom.classList.add("prose-menubar--floating"),this.placeholder.classList.add("prose-menubar-placeholder--active"),this.dom.style.width=`${e.width}px`,this.dom.style.left=`${e.left}px`,this.dom.style.top="0px",this.isFloating=!0):this.isFloating&&(this.dom.classList.remove("prose-menubar--floating"),this.placeholder.classList.remove("prose-menubar-placeholder--active"),this.dom.style.width="",this.dom.style.left="",this.dom.style.top="",this.isFloating=!1)}update(){this.items.forEach(({dom:e,enabled:t=()=>!0,active:r=()=>!1,hidden:o=()=>!1,update:i=null})=>{e.classList.toggle("disabled",!t(this.editor)),e.classList.toggle("active",!!r(this.editor)),e.classList.toggle("hidden",!!o(this.editor)),i&&i(this.editor)})}destroy(){window.removeEventListener("scroll",this.handleScroll),window.removeEventListener("resize",this.handleScroll),this.dom.remove(),this.placeholder.remove()}};function U(n,e){return W("span",{className:"prose-menubar__button material-icons",textContent:n,title:e})}function Zn(n,e=""){return W("span",{className:"prose-menubar__button",innerHTML:n,title:e})}var C0=n=>{let e=W("span",{className:"prose-menubar__button prose-menubar__button--heading",title:`heading ${n}`});return e.append(W("span",{className:"material-icons",textContent:"title"}),W("span",{className:"level",textContent:`${n}`})),{command:t=>{t.chain().focus().toggleHeading({level:n}).run()},dom:e,active(t){return t.isActive("heading",{level:n})}}};function M0(n){let e=n.schema,t=pn(n,"heading"),o=(t?t.options.levels:[]).map(s=>C0(s)),i;return(i=e.nodes.bulletList)&&o.push({command(s){s.chain().focus().toggleBulletList().run()},dom:U("format_list_bulleted","unordered list"),active(s){return!1}}),(i=e.nodes.orderedList)&&(o.push({command(s){s.chain().focus().toggleOrderedList().run()},dom:U("format_list_numbered","ordered list"),active(s){return s.isActive("orderedList")}}),o.push({command(s){s.chain().focus().updateListAttributes().run()},dom:U("tune",$("List properties")),hidden(s){return!s.isActive("orderedList")}})),o.length?[...o,{command(s){s.chain().focus().setParagraph().run()},dom:U("notes","paragraph"),active(s){return!1}}]:null}function T0(n){let e=n.schema,t=[],r;return(r=e.nodes.blockquote)&&t.push({command(o){o.chain().focus().toggleBlockquote().run()},dom:U("format_quote","blockquote"),active(o){return o.isActive("blockquote")}}),(r=e.nodes.horizontalRule)&&t.push({command(o){o.chain().focus().setHorizontalRule().run()},dom:U("horizontal_rule","horizontal rule"),active(o){return!1}}),(r=e.nodes.figure)&&t.push({command(o){o.chain().focus().insertFigure().run()},dom:U("image","figure"),active(o){return o.isActive("figure")}}),t}function A0(n){let e=(t,r)=>t in n.schema.marks?{command(o){o.chain().focus().toggleMark(t).run()},dom:r,active:o=>o.isActive(t)}:null;return[e("bold",U("format_bold","bold")),e("italic",U("format_italic","italic")),e("underline",U("format_underline","underline")),e("strike",U("format_strikethrough","strike")),e("subscript",U("subscript","subscript")),e("superscript",U("superscript","superscript"))].filter(Boolean)}function E0(n){let e=n.schema.marks.link;return e?[{command(t){t.chain().addLink().focus().run()},enabled(t){return!t.state.selection.empty||t.isActive("link")},dom:U("insert_link","insert link"),active(t){return t.isActive(e)}},{command(t){t.chain().focus().unsetLink().run()},dom:U("link_off","remove link"),hidden(t){return!t.isActive("link")}}]:null}function v0(n){return pn(n,"history")?[{command(e){e.commands.undo()},enabled(e){return e.can().undo()},dom:U("undo","undo"),active(){return!1}},{command(e){e.commands.redo()},enabled(e){return e.can().redo()},dom:U("redo","redo"),active(){return!1}}]:null}function O0(n){let e=t=>({command(r){r.chain().focus().setTextAlign(t).run()},dom:U(`format_align_${t}`,t),active(){return n.isActive({textAlign:t})}});return pn(n,"textAlign")?[e("left"),e("center"),e("right"),e("justify")]:null}function N0(n){if(!pn(n,"table"))return null;let e=(t,r)=>({command:t,dom:r,hidden(){return!n.isActive("table")}});return[{command(t){t.chain().focus().insertTableWithOptions().run()},dom:U("grid_on","Insert table")},e(t=>{t.chain().focus().addColumnAfter().run()},Zn(` @@ -128,4 +128,4 @@ $&`);let i=t.split(` - `,"Toggle header cell"))]}function N0(n){let e=[];if(hn(n,"html")&&e.push({command(t){t.commands.editHTML()},dom:U("code","edit HTML")}),hn(n,"fullscreen")){let t=U("",$("Toggle fullscreen"));e.push({command(r){r.commands.toggleFullscreen()},dom:t,update:r=>{var o;t.textContent=(o=r.storage.fullscreen)!=null&&o.fullscreen?"fullscreen_exit":"fullscreen"},active(r){var o;return(o=r.storage.fullscreen)==null?void 0:o.fullscreen}})}return e}var xl={};rt(xl,{commands:()=>_r,history:()=>fo,keymap:()=>Tr,model:()=>Er,state:()=>ur,transform:()=>Or,view:()=>Cr});var R0="listItem",Mu="textStyle",Au=/^(\d+)\.\s$/,Tu=B.create({name:"orderedList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:n=>n.hasAttribute("start")?parseInt(n.getAttribute("start")||"",10):1},type:{default:void 0,parseHTML:n=>n.getAttribute("type")}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:n}){let r=n,{start:e}=r,t=Al(r,["start"]);return e===1?["ol",v(this.options.HTMLAttributes,t),0]:["ol",v(this.options.HTMLAttributes,n),0]},addCommands(){return{toggleOrderedList:()=>({commands:n,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(R0,this.editor.getAttributes(Mu)).run():n.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let n=mt({find:Au,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(n=mt({find:Au,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>b({start:+e[1]},this.editor.getAttributes(Mu)),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1],editor:this.editor})),[n]}});var Xo=[{label:"1, 2, 3, ...",htmlType:"1",description:$("Decimal numbers")},{label:"a, b, c, ...",htmlType:"a",description:$("Lowercase letters")},{label:"A, B, C, ...",htmlType:"A",description:$("Uppercase letters")},{label:"i, ii, iii, ...",htmlType:"i",description:$("Lowercase Roman numerals")},{label:"I, II, III, ...",htmlType:"I",description:$("Uppercase Roman numerals")}],D0=n=>{let e=Xo.find(t=>t.label===n);return e?e.htmlType:"1"},I0=n=>{let e=Xo.find(t=>t.htmlType===n);return e?e.label:Xo[0].label},P0=yt({start:{type:"number",title:$("Start at"),format:"number",default:"1",min:"1"},listType:{title:$("List type"),enum:Xo.map(n=>n.label),default:""}},{title:$("List properties"),submitText:$("Update")}),L0=Tu.configure({keepMarks:!1,keepAttributes:!1,HTMLAttributes:{}}).extend({addInputRules(){return[]},addCommands(){var n;return N(b({},(n=this.parent)==null?void 0:n.call(this)),{updateListAttributes:()=>({editor:e})=>{var l,a;let{state:t}=e,{selection:r}=t,o;for(let c=1;c<=3;c++)try{let d=r.$anchor.node(-c);if(d&&d.type.name==="orderedList"){o=d;break}}catch(d){}o||(o={attrs:{start:1,type:"1"}});let i=((l=o==null?void 0:o.attrs)==null?void 0:l.start)||1,s=((a=o==null?void 0:o.attrs)==null?void 0:a.type)||"1";P0(e,{start:String(i),listType:I0(s)}).then(c=>{if(c){let d=D0(c.listType),u=Number.parseInt(c.start,10)||1;e.chain().focus().updateAttributes("orderedList",{start:u,type:d}).run()}})}})}});var B0=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,z0=B.create({name:"image",addOptions(){return{inline:!1,allowBase64:!1,HTMLAttributes:{}}},inline(){return this.options.inline},group(){return this.options.inline?"inline":"block"},draggable:!0,addAttributes(){return{src:{default:null},alt:{default:null},title:{default:null}}},parseHTML(){return[{tag:this.options.allowBase64?"img[src]":'img[src]:not([src^="data:"])'}]},renderHTML({HTMLAttributes:n}){return["img",v(this.options.HTMLAttributes,n)]},addCommands(){return{setImage:n=>({commands:e})=>e.insertContent({type:this.name,attrs:n})}},addInputRules(){return[oo({find:B0,type:this.type,getAttributes:n=>{let[,,e,t,r]=n;return{src:t,alt:e,title:r}}})]}});var F0=B.create({name:"figure",group:"block",content:"image caption?",draggable:!0,isolating:!0,addAttributes(){return{class:{default:"figure"}}},parseHTML(){return[{tag:"figure"}]},renderHTML({HTMLAttributes:n}){return["figure",v(n),0]},addNodeView(){return({node:n})=>{let e=document.createElement("figure");return Object.entries(n.attrs).forEach(([t,r])=>{t==="class"?e.className=r:e.setAttribute(t,r)}),{dom:e,contentDOM:e,update:t=>t.type.name==="figure"}}},addCommands(){return{insertFigure:()=>({editor:n})=>{let e=n.isActive("figure"),t="",r="",o="";if(e){let{state:c}=n,{selection:d}=c,{$from:u}=d,f=null,h=null,p=null;for(let m=u.depth;m>0;m--){let g=u.node(m);if(g.type.name==="figure"){f=g,g.forEach((y,S,A)=>{y.type.name==="image"?p=y:y.type.name==="caption"&&(h=y)});break}}if(f&&p&&(t=p.attrs.src||"",r=p.attrs.alt||"",h)){let m=[];h.descendants(g=>(g.isText&&m.push(g.text),!0)),o=m.join("")}}let i={imageUrl:{type:"string",title:$("Image URL"),format:"url",required:!0},altText:{type:"string",title:$("Alternative Text")},caption:{type:"string",title:$("Caption")}},s={title:e?$("Edit Figure"):$("Insert Figure"),submitText:e?$("Update"):$("Insert")},l={imageUrl:t,altText:r,caption:o};yt(i,s)(n,l).then(c=>{if(!c)return;let d=c.imageUrl.trim(),u=c.altText.trim(),f=c.caption.trim();if(d)if(e){let{state:h}=n,{selection:p}=h,{$from:m}=p;for(let g=m.depth;g>0;g--){let y=m.node(g);if(y.type.name==="figure"){let S=null,A=null,I=m.start(g);y.forEach((R,_)=>{R.type.name==="image"?S=I+_:R.type.name==="caption"&&(A=I+_)});let M=n.chain();if(S!==null&&(M=M.setNodeSelection(S).updateAttributes("image",{src:d,alt:u})),f){let R={type:"caption",content:[{type:"text",text:f}]};A?M=M.setNodeSelection(A).insertContent(R):M=M.insertContentAt(S+1,R)}else A&&(M=M.setNodeSelection(A).deleteSelection());M.run();break}}}else{let h=[{type:"image",attrs:{src:d,alt:u}}];f&&h.push({type:"caption",content:[{type:"text",text:f}]}),n.chain().focus().insertContent({type:"figure",content:h}).run()}})}}}}),H0=B.create({name:"caption",content:"inline*",group:"block",isolating:!0,addAttributes(){return{class:{default:"figure-caption"}}},parseHTML(){return[{tag:"figcaption"}]},renderHTML({HTMLAttributes:n}){return["figcaption",v(n),0]}});function Dk(n,e){let t=n.hasAttribute("disabled"),r=W("div",{className:`prose-editor ${t?"disabled":""}`});return n.before(r),new Gr({element:r,editable:!t,extensions:e,content:n.value,onUpdate({editor:i}){n.value=i.getHTML(),n.dispatchEvent(new Event("input",{bubbles:!0}))},onDestroy(){r.remove()}})}function Ik(n,e){function t(o){for(let i of o.querySelectorAll(e))i.id.includes("__prefix__")||n(i)}function r(){let o;(o=window.django)&&(o=o.jQuery)&&o(document).on("formset:added",i=>{t(i.target)})}t(document),r()}export{ug as Blockquote,gg as Bold,bg as BulletList,H0 as Caption,Lg as Code,Fg as CodeBlock,_g as Color,an as CommandManager,Hm as Document,$m as Dropcursor,Gr as Editor,H as Extension,F0 as Figure,k0 as Fullscreen,Um as Gapcursor,Ky as HTML,ag as HardBreak,xg as Heading,Wg as Highlight,sg as History,kg as HorizontalRule,z0 as Image,Bt as InputRule,Ag as Italic,m0 as Link,Tg as ListItem,J as Mark,mk as Menu,g0 as NoSpellCheck,B as Node,ks as NodePos,qc as NodeView,L0 as OrderedList,lg as Paragraph,$n as PasteRule,L as Plugin,vg as Strike,Ng as Subscript,Rg as Superscript,By as Table,zy as TableCell,Fy as TableHeader,Hy as TableRow,cg as Text,Kg as TextAlign,$g as TextStyle,Gc as Tracker,y0 as Typographic,Dg as Underline,D as callOrReturn,ad as combineTransactionSteps,Yr as createChainableState,bs as createDocument,qr as createNodeFromContent,Fm as createStyleTag,Dk as createTextareaEditor,W as crel,um as defaultBlockAt,Kc as deleteProps,Hn as elementFromString,Hb as escapeForRegEx,zb as extensions,Ob as findChildren,cd as findChildrenInRange,Sp as findDuplicates,no as findParentNode,Ms as findParentNodeClosestToPos,up as fromString,vb as generateHTML,Nb as generateJSON,Rb as generateText,Ts as getAttributes,Yc as getAttributesFromExtensions,ud as getChangedRanges,mm as getDebugJSON,C as getExtensionField,Xr as getHTMLFromFragment,ld as getMarkAttributes,Cs as getMarkRange,pt as getMarkType,ro as getMarksBetween,Db as getNodeAtPosition,fm as getNodeAttributes,re as getNodeType,ys as getRenderedAttributes,As as getSchema,Xc as getSchemaByResolvedExtensions,hs as getSchemaTypeByName,to as getSchemaTypeNameByName,Kr as getSplittedAttributes,dd as getText,Zc as getTextBetween,fp as getTextContentFromNodes,ws as getTextSerializersFromSchema,$ as gettext,Ik as initializeEditors,_c as injectExtensionAttributesToParseRule,pp as inputRulesPlugin,gm as isActive,Ib as isAtEndOfNode,Pb as isAtStartOfNode,dp as isEmptyObject,jc as isExtensionRulesEnabled,Qc as isFunction,Jc as isList,sd as isMacOS,xs as isMarkActive,_n as isNodeActive,Es as isNodeEmpty,fd as isNodeSelection,gp as isNumber,jr as isPlainObject,Ss as isRegExp,$b as isString,nd as isTextSelection,eo as isiOS,Ee as markInputRule,be as markPasteRule,S0 as menuItemsFromEditor,v as mergeAttributes,Zr as mergeDeep,Qe as minMax,oo as nodeInputRule,_b as nodePasteRule,Ur as objectIncludes,kp as pasteRulesPlugin,xl as pm,Lb as posToDOMRect,hm as removeDuplicates,rd as resolveFocusPosition,Bb as rewriteUnknownContent,Hp as selectionToInsertionEnd,Qr as splitExtensions,Fb as textInputRule,Vb as textPasteRule,Vn as textblockTypeInputRule,yt as updateAttrsDialog,mt as wrappingInputRule}; + `,"Toggle header cell"))]}function R0(n){let e=[];if(pn(n,"html")&&e.push({command(t){t.commands.editHTML()},dom:U("code","edit HTML")}),pn(n,"fullscreen")){let t=U("",$("Toggle fullscreen"));e.push({command(r){r.commands.toggleFullscreen()},dom:t,update:r=>{var o;t.textContent=(o=r.storage.fullscreen)!=null&&o.fullscreen?"fullscreen_exit":"fullscreen"},active(r){var o;return(o=r.storage.fullscreen)==null?void 0:o.fullscreen}})}return e}var kl={};rt(kl,{commands:()=>_r,history:()=>fo,keymap:()=>Ar,model:()=>Er,state:()=>ur,transform:()=>vr,view:()=>Cr});var D0="listItem",Tu="textStyle",Au=/^(\d+)\.\s$/,Eu=z.create({name:"orderedList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:n=>n.hasAttribute("start")?parseInt(n.getAttribute("start")||"",10):1},type:{default:void 0,parseHTML:n=>n.getAttribute("type")}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:n}){let r=n,{start:e}=r,t=Al(r,["start"]);return e===1?["ol",O(this.options.HTMLAttributes,t),0]:["ol",O(this.options.HTMLAttributes,n),0]},addCommands(){return{toggleOrderedList:()=>({commands:n,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(D0,this.editor.getAttributes(Tu)).run():n.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let n=mt({find:Au,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(n=mt({find:Au,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>b({start:+e[1]},this.editor.getAttributes(Tu)),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1],editor:this.editor})),[n]}});var Xo=[{label:"1, 2, 3, ...",htmlType:"1",description:$("Decimal numbers")},{label:"a, b, c, ...",htmlType:"a",description:$("Lowercase letters")},{label:"A, B, C, ...",htmlType:"A",description:$("Uppercase letters")},{label:"i, ii, iii, ...",htmlType:"i",description:$("Lowercase Roman numerals")},{label:"I, II, III, ...",htmlType:"I",description:$("Uppercase Roman numerals")}],I0=n=>{let e=Xo.find(t=>t.label===n);return e?e.htmlType:"1"},P0=n=>{let e=Xo.find(t=>t.htmlType===n);return e?e.label:Xo[0].label},L0=yt({start:{type:"number",title:$("Start at"),format:"number",default:"1",min:"1"},listType:{title:$("List type"),enum:Xo.map(n=>n.label),default:""}},{title:$("List properties"),submitText:$("Update")}),z0=Eu.configure({keepMarks:!1,keepAttributes:!1,HTMLAttributes:{}}).extend({addInputRules(){return[]},addCommands(){var n;return N(b({},(n=this.parent)==null?void 0:n.call(this)),{updateListAttributes:()=>({editor:e})=>{var l,a;let{state:t}=e,{selection:r}=t,o;for(let c=1;c<=3;c++)try{let d=r.$anchor.node(-c);if(d&&d.type.name==="orderedList"){o=d;break}}catch(d){}o||(o={attrs:{start:1,type:"1"}});let i=((l=o==null?void 0:o.attrs)==null?void 0:l.start)||1,s=((a=o==null?void 0:o.attrs)==null?void 0:a.type)||"1";L0(e,{start:String(i),listType:P0(s)}).then(c=>{if(c){let d=I0(c.listType),u=Number.parseInt(c.start,10)||1;e.chain().focus().updateAttributes("orderedList",{start:u,type:d}).run()}})}})}});var B0=/(?:^|\s)(!\[(.+|:?)]\((\S+)(?:(?:\s+)["'](\S+)["'])?\))$/,F0=z.create({name:"image",addOptions(){return{inline:!1,allowBase64:!1,HTMLAttributes:{}}},inline(){return this.options.inline},group(){return this.options.inline?"inline":"block"},draggable:!0,addAttributes(){return{src:{default:null},alt:{default:null},title:{default:null}}},parseHTML(){return[{tag:this.options.allowBase64?"img[src]":'img[src]:not([src^="data:"])'}]},renderHTML({HTMLAttributes:n}){return["img",O(this.options.HTMLAttributes,n)]},addCommands(){return{setImage:n=>({commands:e})=>e.insertContent({type:this.name,attrs:n})}},addInputRules(){return[oo({find:B0,type:this.type,getAttributes:n=>{let[,,e,t,r]=n;return{src:t,alt:e,title:r}}})]}});var H0=z.create({name:"figure",group:"block",content:"image caption?",draggable:!0,isolating:!0,addAttributes(){return{class:{default:"figure"}}},parseHTML(){return[{tag:"figure"}]},renderHTML({HTMLAttributes:n}){return["figure",O(n),0]},addNodeView(){return({node:n})=>{let e=document.createElement("figure");return Object.entries(n.attrs).forEach(([t,r])=>{t==="class"?e.className=r:e.setAttribute(t,r)}),{dom:e,contentDOM:e,update:t=>t.type.name==="figure"}}},addCommands(){return{insertFigure:()=>({editor:n})=>{let e=n.isActive("figure"),t="",r="",o="";if(e){let{state:c}=n,{selection:d}=c,{$from:u}=d,f=null,p=null,h=null;for(let m=u.depth;m>0;m--){let g=u.node(m);if(g.type.name==="figure"){f=g,g.forEach((y,w,T)=>{y.type.name==="image"?h=y:y.type.name==="caption"&&(p=y)});break}}if(f&&h&&(t=h.attrs.src||"",r=h.attrs.alt||"",p)){let m=[];p.descendants(g=>(g.isText&&m.push(g.text),!0)),o=m.join("")}}let i={imageUrl:{type:"string",title:$("Image URL"),format:"url",required:!0},altText:{type:"string",title:$("Alternative Text")},caption:{type:"string",title:$("Caption")}},s={title:e?$("Edit Figure"):$("Insert Figure"),submitText:e?$("Update"):$("Insert")},l={imageUrl:t,altText:r,caption:o};yt(i,s)(n,l).then(c=>{if(!c)return;let d=c.imageUrl.trim(),u=c.altText.trim(),f=c.caption.trim();if(d)if(e){let{state:p}=n,{selection:h}=p,{$from:m}=h;for(let g=m.depth;g>0;g--){let y=m.node(g);if(y.type.name==="figure"){let w=null,T=null,I=m.start(g);y.forEach((R,_)=>{R.type.name==="image"?w=I+_:R.type.name==="caption"&&(T=I+_)});let M=n.chain();if(w!==null&&(M=M.setNodeSelection(w).updateAttributes("image",{src:d,alt:u})),f){let R={type:"caption",content:[{type:"text",text:f}]};T?M=M.setNodeSelection(T).insertContent(R):M=M.insertContentAt(w+1,R)}else T&&(M=M.setNodeSelection(T).deleteSelection());M.run();break}}}else{let p=[{type:"image",attrs:{src:d,alt:u}}];f&&p.push({type:"caption",content:[{type:"text",text:f}]}),n.chain().focus().insertContent({type:"figure",content:p}).run()}})}}}}),$0=z.create({name:"caption",content:"inline*",group:"block",isolating:!0,addAttributes(){return{class:{default:"figure-caption"}}},parseHTML(){return[{tag:"figcaption"}]},renderHTML({HTMLAttributes:n}){return["figcaption",O(n),0]}});function Ik(n,e){let t=n.hasAttribute("disabled"),r=W("div",{className:`prose-editor ${t?"disabled":""}`});return n.before(r),new Gr({element:r,editable:!t,extensions:e,content:n.value,onUpdate({editor:i}){n.value=i.getHTML(),n.dispatchEvent(new Event("input",{bubbles:!0}))},onDestroy(){r.remove()}})}function Pk(n,e){function t(o){for(let i of o.querySelectorAll(e))i.id.includes("__prefix__")||n(i)}function r(){let o;(o=window.django)&&(o=o.jQuery)&&o(document).on("formset:added",i=>{t(i.target)})}t(document),r()}export{fg as Blockquote,yg as Bold,xg as BulletList,$0 as Caption,zg as Code,Hg as CodeBlock,Vg as Color,an as CommandManager,$m as Document,_m as Dropcursor,Gr as Editor,H as Extension,H0 as Figure,w0 as Fullscreen,qm as Gapcursor,Jy as HTML,cg as HardBreak,kg as Heading,Kg as Highlight,lg as History,wg as HorizontalRule,F0 as Image,zt as InputRule,Ag as Italic,g0 as Link,Eg as ListItem,J as Mark,gk as Menu,y0 as NoSpellCheck,z as Node,ks as NodePos,Gc as NodeView,z0 as OrderedList,ag as Paragraph,$n as PasteRule,L as Plugin,Ng as Strike,Rg as Subscript,Dg as Superscript,By as Table,Fy as TableCell,Hy as TableHeader,$y as TableRow,dg as Text,Jg as TextAlign,_g as TextStyle,Yc as Tracker,b0 as Typographic,Ig as Underline,D as callOrReturn,cd as combineTransactionSteps,Yr as createChainableState,bs as createDocument,qr as createNodeFromContent,Hm as createStyleTag,Ik as createTextareaEditor,W as crel,fm as defaultBlockAt,Jc as deleteProps,Hn as elementFromString,$b as escapeForRegEx,Fb as extensions,Ob as findChildren,dd as findChildrenInRange,Sh as findDuplicates,no as findParentNode,Ms as findParentNodeClosestToPos,fh as fromString,Nb as generateHTML,Rb as generateJSON,Db as generateText,As as getAttributes,Qc as getAttributesFromExtensions,fd as getChangedRanges,gm as getDebugJSON,C as getExtensionField,Xr as getHTMLFromFragment,ad as getMarkAttributes,Cs as getMarkRange,ht as getMarkType,ro as getMarksBetween,Ib as getNodeAtPosition,pm as getNodeAttributes,re as getNodeType,ys as getRenderedAttributes,Ts as getSchema,Zc as getSchemaByResolvedExtensions,ps as getSchemaTypeByName,to as getSchemaTypeNameByName,Kr as getSplittedAttributes,ud as getText,ed as getTextBetween,ph as getTextContentFromNodes,Ss as getTextSerializersFromSchema,$ as gettext,Pk as initializeEditors,Vc as injectExtensionAttributesToParseRule,mh as inputRulesPlugin,ym as isActive,Pb as isAtEndOfNode,Lb as isAtStartOfNode,uh as isEmptyObject,Wc as isExtensionRulesEnabled,Xc as isFunction,Uc as isList,ld as isMacOS,xs as isMarkActive,_n as isNodeActive,Es as isNodeEmpty,pd as isNodeSelection,yh as isNumber,jr as isPlainObject,ws as isRegExp,_b as isString,rd as isTextSelection,eo as isiOS,Ee as markInputRule,be as markPasteRule,S0 as menuItemsFromEditor,O as mergeAttributes,Zr as mergeDeep,Qe as minMax,oo as nodeInputRule,Vb as nodePasteRule,Ur as objectIncludes,wh as pasteRulesPlugin,kl as pm,zb as posToDOMRect,hm as removeDuplicates,od as resolveFocusPosition,Bb as rewriteUnknownContent,$h as selectionToInsertionEnd,Qr as splitExtensions,Hb as textInputRule,jb as textPasteRule,Vn as textblockTypeInputRule,yt as updateAttrsDialog,mt as wrappingInputRule}; diff --git a/src/editor.css b/src/editor.css index 80f9c76..c4d6f5a 100644 --- a/src/editor.css +++ b/src/editor.css @@ -254,6 +254,302 @@ label:empty:has(+ .prose-editor) { box-shadow: 0 2px 0 1px var(--_t), 0 -2px 0 1px var(--_t); } +/* Zero-width space - dot in the middle */ +.prose-editor-zwsp { + position: relative; +} +.prose-editor-zwsp::after { + content: "·"; + position: absolute; + color: var(--_t); + font-weight: bold; + top: 50%; + left: 50%; + transform: translate(-50%, -50%); + font-size: 0.8em; +} + +/* Zero-width non-joiner - circle with slash */ +.prose-editor-zwnj { + position: relative; +} +.prose-editor-zwnj::after { + content: "⊘"; + position: absolute; + color: var(--_t); + top: 50%; + left: 50%; + transform: translate(-50%, -50%); + font-size: 0.8em; +} + +/* Zero-width joiner - circle with link */ +.prose-editor-zwj { + position: relative; +} +.prose-editor-zwj::after { + content: "⊙"; + position: absolute; + color: var(--_t); + top: 50%; + left: 50%; + transform: translate(-50%, -50%); + font-size: 0.8em; +} + +/* Word joiner - double arrow */ +.prose-editor-wj { + position: relative; +} +.prose-editor-wj::after { + content: "↔"; + position: absolute; + color: var(--_t); + top: 50%; + left: 50%; + transform: translate(-50%, -50%); + font-size: 0.8em; +} + +/* Line separator - slash + nl */ +.prose-editor-ls { + position: relative; +} +.prose-editor-ls::after { + content: "↲"; + position: absolute; + color: var(--_t); + top: 50%; + left: 50%; + transform: translate(-50%, -50%); + font-size: 0.8em; +} + +/* Paragraph separator - double slash + nl */ +.prose-editor-ps { + position: relative; +} +.prose-editor-ps::after { + content: "⁋"; + position: absolute; + color: var(--_t); + top: 50%; + left: 50%; + transform: translate(-50%, -50%); + font-size: 0.8em; +} + +/* Visualization for HTML line breaks (
elements) */ +.prose-editor-br-marker { + display: inline-block; + color: var(--_t); + font-size: 1em; + margin-right: 0.2em; + user-select: none; + pointer-events: none; + vertical-align: middle; +} + +/* Em space */ +.prose-editor-emsp { + background: var(--_t); + box-shadow: 0 2px 0 0 var(--_t), 0 -2px 0 0 var(--_t); + position: relative; +} +.prose-editor-emsp::after { + content: "em"; + position: absolute; + color: #fff; + top: 50%; + left: 50%; + transform: translate(-50%, -50%); + font-size: 0.5em; + font-weight: bold; +} + +/* Thin space */ +.prose-editor-thinsp { + background: var(--_t); + box-shadow: 0 2px 0 0 var(--_t), 0 -2px 0 0 var(--_t); + position: relative; +} +.prose-editor-thinsp::after { + content: "thin"; + position: absolute; + color: #fff; + top: 50%; + left: 50%; + transform: translate(-50%, -50%); + font-size: 0.4em; + font-weight: bold; +} + +/* Narrow no-break space */ +.prose-editor-nnbsp { + background: var(--_t); + box-shadow: 0 2px 0 0 var(--_t), 0 -2px 0 0 var(--_t); + position: relative; +} +.prose-editor-nnbsp::after { + content: "nnbsp"; + position: absolute; + color: #fff; + top: 50%; + left: 50%; + transform: translate(-50%, -50%); + font-size: 0.4em; + font-weight: bold; +} + +/* En space */ +.prose-editor-ensp { + background: var(--_t); + box-shadow: 0 2px 0 0 var(--_t), 0 -2px 0 0 var(--_t); + position: relative; +} +.prose-editor-ensp::after { + content: "en"; + position: absolute; + color: #fff; + top: 50%; + left: 50%; + transform: translate(-50%, -50%); + font-size: 0.5em; + font-weight: bold; +} + +/* Three-per-em space */ +.prose-editor-3persp { + background: var(--_t); + box-shadow: 0 2px 0 0 var(--_t), 0 -2px 0 0 var(--_t); + position: relative; +} +.prose-editor-3persp::after { + content: "3/em"; + position: absolute; + color: #fff; + top: 50%; + left: 50%; + transform: translate(-50%, -50%); + font-size: 0.4em; + font-weight: bold; +} + +/* Four-per-em space */ +.prose-editor-4persp { + background: var(--_t); + box-shadow: 0 2px 0 0 var(--_t), 0 -2px 0 0 var(--_t); + position: relative; +} +.prose-editor-4persp::after { + content: "4/em"; + position: absolute; + color: #fff; + top: 50%; + left: 50%; + transform: translate(-50%, -50%); + font-size: 0.4em; + font-weight: bold; +} + +/* Six-per-em space */ +.prose-editor-6persp { + background: var(--_t); + box-shadow: 0 2px 0 0 var(--_t), 0 -2px 0 0 var(--_t); + position: relative; +} +.prose-editor-6persp::after { + content: "6/em"; + position: absolute; + color: #fff; + top: 50%; + left: 50%; + transform: translate(-50%, -50%); + font-size: 0.4em; + font-weight: bold; +} + +/* Figure space */ +.prose-editor-figsp { + background: var(--_t); + box-shadow: 0 2px 0 0 var(--_t), 0 -2px 0 0 var(--_t); + position: relative; +} +.prose-editor-figsp::after { + content: "fig"; + position: absolute; + color: #fff; + top: 50%; + left: 50%; + transform: translate(-50%, -50%); + font-size: 0.4em; + font-weight: bold; +} + +/* Punctuation space */ +.prose-editor-psp { + background: var(--_t); + box-shadow: 0 2px 0 0 var(--_t), 0 -2px 0 0 var(--_t); + position: relative; +} +.prose-editor-psp::after { + content: "punct"; + position: absolute; + color: #fff; + top: 50%; + left: 50%; + transform: translate(-50%, -50%); + font-size: 0.4em; + font-weight: bold; +} + +/* Medium mathematical space */ +.prose-editor-mmsp { + background: var(--_t); + box-shadow: 0 2px 0 0 var(--_t), 0 -2px 0 0 var(--_t); + position: relative; +} +.prose-editor-mmsp::after { + content: "math"; + position: absolute; + color: #fff; + top: 50%; + left: 50%; + transform: translate(-50%, -50%); + font-size: 0.4em; + font-weight: bold; +} + +/* Mongolian vowel separator */ +.prose-editor-mvs { + position: relative; +} +.prose-editor-mvs::after { + content: "mvs"; + position: absolute; + color: var(--_t); + top: 50%; + left: 50%; + transform: translate(-50%, -50%); + font-size: 0.5em; + font-weight: bold; +} + +/* Byte order mark */ +.prose-editor-bom { + position: relative; +} +.prose-editor-bom::after { + content: "BOM"; + position: absolute; + color: var(--_t); + top: 50%; + left: 50%; + transform: translate(-50%, -50%); + font-size: 0.5em; + font-weight: bold; +} + /* Fullscreen mode styles */ .prose-editor-fullscreen { position: fixed !important; diff --git a/src/typographic.js b/src/typographic.js index a80a6d3..c2128bc 100644 --- a/src/typographic.js +++ b/src/typographic.js @@ -1,4 +1,4 @@ -// Plugin which shows typographic characters (currently only non-breaking spaces) +// Plugin which shows typographic and invisible characters import { Extension } from "@tiptap/core" @@ -9,43 +9,84 @@ export const Typographic = Extension.create({ name: "typographic", addProseMirrorPlugins() { - return [typographicPlugin] + return [typographicPlugin, hardBreakPlugin] }, }) -// https://discuss.prosemirror.net/t/efficiently-finding-changed-nodes/4280/5 -// Helper for iterating through the nodes in a document that changed -// compared to the given previous document. Useful for avoiding -// duplicate work on each transaction. -function changedDescendants(old, cur, offset, f) { - const oldSize = old.childCount - const curSize = cur.childCount - outer: for (let i = 0, j = 0; i < curSize; i++) { - const child = cur.child(i) - for (let scan = j, e = Math.min(oldSize, i + 3); scan < e; scan++) { - if (old.child(scan) === child) { - j = scan + 1 - offset += child.nodeSize - continue outer - } - } - f(child, offset) - if (j < oldSize && old.child(j).sameMarkup(child)) - changedDescendants(old.child(j), child, offset + 1, f) - else child.nodesBetween(0, child.content.size, f, offset + 1) - offset += child.nodeSize - } +const classes = { + "\u00A0": "prose-editor-nbsp", // Non-breaking space + "\u00AD": "prose-editor-shy", // Soft hyphen + "\u200B": "prose-editor-zwsp", // Zero-width space + "\u200C": "prose-editor-zwnj", // Zero-width non-joiner + "\u200D": "prose-editor-zwj", // Zero-width joiner + "\u2060": "prose-editor-wj", // Word joiner + "\u2028": "prose-editor-ls", // Line separator + "\u2029": "prose-editor-ps", // Paragraph separator + "\u2003": "prose-editor-emsp", // Em space + "\u2009": "prose-editor-thinsp", // Thin space + "\u202F": "prose-editor-nnbsp", // Narrow no-break space + "\u2002": "prose-editor-ensp", // En space + "\u2004": "prose-editor-3persp", // Three-per-em space + "\u2005": "prose-editor-4persp", // Four-per-em space + "\u2006": "prose-editor-6persp", // Six-per-em space + "\u2007": "prose-editor-figsp", // Figure space + "\u2008": "prose-editor-psp", // Punctuation space + "\u205F": "prose-editor-mmsp", // Medium mathematical space + "\u180E": "prose-editor-mvs", // Mongolian vowel separator + "\uFEFF": "prose-editor-bom", // Byte order mark } -const classes = { - "\u00A0": "prose-editor-nbsp", - "\u00AD": "prose-editor-shy", +// Custom NodeView for hard breaks +class HardBreakView { + constructor(_node) { + // Create a container for both the BR and our custom marker + this.dom = document.createElement("span") + this.dom.className = "prose-editor-br-container" + + // Add the marker span + const marker = document.createElement("span") + marker.className = "prose-editor-br-marker" + marker.textContent = "↵" + this.dom.appendChild(marker) + + // Add the actual BR element + const br = document.createElement("br") + this.dom.appendChild(br) + + // No content DOM since this is a leaf node + this.contentDOM = null + } + + update(node) { + return node.type.name === "hardBreak" + } + + stopEvent() { + return false + } + + ignoreMutation() { + return true + } } +// Separate plugin for handling hard breaks with NodeViews +const hardBreakPlugin = new Plugin({ + props: { + nodeViews: { + hardBreak: (node, _view, _getPos) => new HardBreakView(node), + }, + }, +}) + const typographicDecorationsForNode = (node, position) => { const decorations = [] + + // For text nodes, look for special characters if (node.text) { - for (const match of node.text.matchAll(/(\u00A0|\u00AD)/g)) { + // Create a regex pattern from all character keys in the classes object + const pattern = new RegExp(`([${Object.keys(classes).join("")}])`, "g") + for (const match of node.text.matchAll(pattern)) { const from = position + (match.index || 0) decorations.push( Decoration.inline(from, from + 1, { @@ -54,6 +95,7 @@ const typographicDecorationsForNode = (node, position) => { ) } } + return decorations } @@ -70,19 +112,15 @@ const typographicPlugin = new Plugin({ init(_, { doc }) { return typographicDecorations(doc) }, - apply(tr, set, oldState) { - // I fear that's not very performant. Maybe improve this "later". - // return tr.docChanged ? typographicDecorations(tr.doc) : set - - let newSet = set.map(tr.mapping, tr.doc) - changedDescendants(oldState.doc, tr.doc, 0, (node, offset) => { - // First, remove our inline decorations for the current node - newSet = newSet.remove(newSet.find(offset, offset + node.content.size)) - // Then, add decorations (including the new content) - newSet = newSet.add(tr.doc, typographicDecorationsForNode(node, offset)) - }) - - return newSet + apply(tr, set, _oldState) { + // Simplest solution: Rebuild all decorations on doc changes + // This ensures we catch all special characters, even those in adjacent nodes + if (tr.docChanged) { + return typographicDecorations(tr.doc) + } + + // If the document hasn't changed, just map the existing decorations + return set.map(tr.mapping, tr.doc) }, }, props: {