@progress/kendo-editor-common 1.12.4-develop.8 → 1.12.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.KendoEditorCommon=t():e.KendoEditorCommon=t()}(self,(()=>(()=>{"use strict";var e={d:(t,n)=>{for(var o in n)e.o(n,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:n[o]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};function n(e){this.content=e}e.r(t),e.d(t,{AddMarkStep:()=>ke,AddNodeMarkStep:()=>Se,AllSelection:()=>dt,AttrStep:()=>Ge,CellSelection:()=>Fa,ContentMatch:()=>$,DOMParser:()=>G,DOMSerializer:()=>le,Decoration:()=>Cl,DecorationSet:()=>Ol,DocAttrStep:()=>Qe,EditorState:()=>vt,EditorView:()=>Zl,Fragment:()=>s,GapCursor:()=>$p,InputRule:()=>Ed,MapResult:()=>fe,Mapping:()=>ge,Mark:()=>d,MarkType:()=>X,Node:()=>D,NodeRange:()=>A,NodeSelection:()=>at,NodeType:()=>J,Plugin:()=>kt,PluginKey:()=>Ct,RemoveMarkStep:()=>xe,RemoveNodeMarkStep:()=>Ce,ReplaceAroundStep:()=>Ne,ReplaceError:()=>h,ReplaceStep:()=>Me,ResolvedPos:()=>C,Schema:()=>U,Selection:()=>nt,SelectionRange:()=>ot,Slice:()=>p,Step:()=>we,StepMap:()=>me,StepResult:()=>ve,TableMap:()=>va,TextSelection:()=>st,Transaction:()=>ft,Transform:()=>et,TransformError:()=>Ze,__endComposition:()=>Ql,__parseFromClipboard:()=>Gl,activeNode:()=>po,addColSpan:()=>Pa,addColumn:()=>Ja,addColumnAfter:()=>Gp,addColumnBefore:()=>Yp,addListNodes:()=>So,addRow:()=>Qa,addRowAfter:()=>Kp,addRowBefore:()=>Jp,alignBlocks:()=>uo,alignCenterRules:()=>_r,alignJustifyRules:()=>Wr,alignLeftRules:()=>Lr,alignRemoveRules:()=>qr,alignRightRules:()=>Hr,applyInlineStyle:()=>Qn,applyLink:()=>eo,autoJoin:()=>mr,baseKeymap:()=>kr,blockNodes:()=>ro,blockquote:()=>xr,bold:()=>jd,buildKeymap:()=>Zd,buildListKeymap:()=>eh,bulletList:()=>bo,canBeIndented:()=>Ar,canIndentAsListItem:()=>Nr,canInsert:()=>Kt,canJoin:()=>Be,canOutdentAsListItem:()=>Or,canSplit:()=>ze,caretColor:()=>Qh,caretColorKey:()=>Gh,cellAround:()=>Oa,chainCommands:()=>gr,changeTextBlock:()=>oo,cleanFormatting:()=>mo,cleanMarks:()=>Hn,cleanTextBlockFormatting:()=>so,closeDoubleQuote:()=>Fd,closeHistory:()=>bd,closeSingleQuote:()=>Hd,colCount:()=>Ia,columnIsHeader:()=>Va,columnResizing:()=>$c,columnResizingPluginKey:()=>Rc,convertMsLists:()=>ch,createParagraphNear:()=>er,createTable:()=>Hp,cspFix:()=>Lh,deleteColumn:()=>Qp,deleteRow:()=>nc,deleteSelection:()=>zo,deleteTable:()=>fc,domToPmDoc:()=>Nn,dropCursor:()=>Ep,dropPoint:()=>Le,ellipsis:()=>Pd,emDash:()=>Bd,exitCode:()=>Zo,expandSelection:()=>rn,expandToWordWrap:()=>sn,find:()=>Nh,findAll:()=>Oh,findAt:()=>Mh,findCell:()=>$a,findWrapping:()=>Ee,fixTables:()=>qa,fixTablesKey:()=>_a,flattenNestedSpans:()=>Bn,formatBlockElements:()=>io,fragmentToHtml:()=>Cn,gapCursor:()=>zp,getActiveMarks:()=>Jn,getBlockFormats:()=>lo,getHtml:()=>An,getInlineStyles:()=>Un,getMark:()=>jn,getNodeFromSelection:()=>en,getSelectionText:()=>Zt,goToNextCell:()=>uc,hasMark:()=>_n,hasNode:()=>co,hasSameMarkup:()=>Dn,history:()=>Sd,htmlToFragment:()=>Sn,imageResizeKey:()=>jh,imageResizing:()=>Yh,inSameTable:()=>Ra,indent:()=>Tr,indentBlocks:()=>Cr,indentHtml:()=>nn,indentRules:()=>$o,inputRules:()=>$d,insertImage:()=>no,insertNode:()=>Qt,insertPoint:()=>Fe,insertText:()=>to,isAligned:()=>fo,isInTable:()=>Aa,isIndented:()=>Mr,italic:()=>Jd,joinBackward:()=>Po,joinDown:()=>Uo,joinForward:()=>jo,joinPoint:()=>Ve,joinTextblockBackward:()=>Vo,joinTextblockForward:()=>Fo,joinUp:()=>Xo,keydownHandler:()=>ga,keymap:()=>ma,lift:()=>Yo,liftBlockquote:()=>Sr,liftEmptyBlock:()=>tr,liftListItem:()=>Ao,liftTarget:()=>De,link:()=>Gd,listItem:()=>ko,listMarkersStyles:()=>Dp,listStyle:()=>zr,macBaseKeymap:()=>br,marks:()=>Qc,mergeCells:()=>rc,moveCellForward:()=>Ea,newlineInCode:()=>Go,nextCell:()=>za,nodes:()=>id,openDoubleQuote:()=>Vd,openSingleQuote:()=>Ld,orderedList:()=>vo,outdent:()=>Dr,outdentRules:()=>Io,parentBlockFormat:()=>ho,parentNode:()=>Yt,parseContent:()=>On,pasteCleanup:()=>mh,pcBaseKeymap:()=>vr,placeholder:()=>$h,pmAddColumnAfter:()=>Xa,pmAddColumnBefore:()=>Ka,pmAddRowAfter:()=>ec,pmAddRowBefore:()=>Za,pmDeleteColumn:()=>Ya,pmDocToFragment:()=>Mn,redo:()=>Nd,redoDepth:()=>Dd,redoNoScroll:()=>Ad,removeAllMarks:()=>Ln,removeAttribute:()=>ph,removeColSpan:()=>Ba,removeComments:()=>En,removeLink:()=>Zn,removeTag:()=>hh,replace:()=>Ah,replaceAll:()=>Th,replaceImageSourcesFromRtf:()=>Ch,replaceStep:()=>He,rowIsHeader:()=>Ga,sanitize:()=>dh,sanitizeClassAttr:()=>uh,sanitizeStyleAttr:()=>fh,selectAll:()=>sr,selectNodeBackward:()=>_o,selectNodeForward:()=>Jo,selectParentNode:()=>ir,selectTextblockEnd:()=>dr,selectTextblockStart:()=>cr,selectedLineTextOnly:()=>tn,selectedRect:()=>ja,selectionCell:()=>Ta,selectionMarks:()=>qn,setBlockType:()=>pr,setCellAttr:()=>lc,setHtml:()=>Tn,sinkListItem:()=>To,smartQuotes:()=>_d,spacesFix:()=>Bh,splitBlock:()=>or,splitBlockAs:()=>nr,splitBlockKeepMarks:()=>rr,splitCell:()=>ic,splitCellWithType:()=>sc,splitListItem:()=>No,splitListItemKeepMarks:()=>Oo,strikethrough:()=>Xd,subscript:()=>Ud,superscript:()=>Yd,tableColumnResizeKey:()=>np,tableEditing:()=>Fc,tableEditingKey:()=>Na,tableNodeTypes:()=>Ma,tableNodes:()=>Ca,tableResizeKey:()=>tp,tableResizing:()=>Mp,tableRowResizeKey:()=>op,textHighlight:()=>_h,textHighlightKey:()=>Hh,textblockTypeInputRule:()=>qd,toggleHeader:()=>cc,toggleHeaderCell:()=>pc,toggleHeaderColumn:()=>hc,toggleHeaderRow:()=>dc,toggleInlineFormat:()=>Gn,toggleList:()=>Br,toggleMark:()=>ur,toggleOrderedList:()=>Vr,toggleUnorderedList:()=>Pr,trimWhitespace:()=>yn,underline:()=>Kd,undo:()=>Md,undoDepth:()=>Td,undoInputRule:()=>zd,undoNoScroll:()=>Od,updateColumnsOnResize:()=>Ec,wrapIn:()=>hr,wrapInList:()=>Co,wrapRangeInList:()=>Mo,wrappingInputRule:()=>Wd}),n.prototype={constructor:n,find:function(e){for(var t=0;t<this.content.length;t+=2)if(this.content[t]===e)return t;return-1},get:function(e){var t=this.find(e);return-1==t?void 0:this.content[t+1]},update:function(e,t,o){var r=o&&o!=e?this.remove(o):this,i=r.find(e),s=r.content.slice();return-1==i?s.push(o||e,t):(s[i+1]=t,o&&(s[i]=o)),new n(s)},remove:function(e){var t=this.find(e);if(-1==t)return this;var o=this.content.slice();return o.splice(t,2),new n(o)},addToStart:function(e,t){return new n([e,t].concat(this.remove(e).content))},addToEnd:function(e,t){var o=this.remove(e).content.slice();return o.push(e,t),new n(o)},addBefore:function(e,t,o){var r=this.remove(t),i=r.content.slice(),s=r.find(e);return i.splice(-1==s?i.length:s,0,t,o),new n(i)},forEach:function(e){for(var t=0;t<this.content.length;t+=2)e(this.content[t],this.content[t+1])},prepend:function(e){return(e=n.from(e)).size?new n(e.content.concat(this.subtract(e).content)):this},append:function(e){return(e=n.from(e)).size?new n(this.subtract(e).content.concat(e.content)):this},subtract:function(e){var t=this;e=n.from(e);for(var o=0;o<e.content.length;o+=2)t=t.remove(e.content[o]);return t},toObject:function(){var e={};return this.forEach((function(t,n){e[t]=n})),e},get size(){return this.content.length>>1}},n.from=function(e){if(e instanceof n)return e;var t=[];if(e)for(var o in e)t.push(o,e[o]);return new n(t)};const o=n;function r(e,t,n){for(let o=0;;o++){if(o==e.childCount||o==t.childCount)return e.childCount==t.childCount?null:n;let i=e.child(o),s=t.child(o);if(i!=s){if(!i.sameMarkup(s))return n;if(i.isText&&i.text!=s.text){for(let e=0;i.text[e]==s.text[e];e++)n++;return n}if(i.content.size||s.content.size){let e=r(i.content,s.content,n+1);if(null!=e)return e}n+=i.nodeSize}else n+=i.nodeSize}}function i(e,t,n,o){for(let r=e.childCount,s=t.childCount;;){if(0==r||0==s)return r==s?null:{a:n,b:o};let l=e.child(--r),a=t.child(--s),c=l.nodeSize;if(l!=a){if(!l.sameMarkup(a))return{a:n,b:o};if(l.isText&&l.text!=a.text){let e=0,t=Math.min(l.text.length,a.text.length);for(;e<t&&l.text[l.text.length-e-1]==a.text[a.text.length-e-1];)e++,n--,o--;return{a:n,b:o}}if(l.content.size||a.content.size){let e=i(l.content,a.content,n-1,o-1);if(e)return e}n-=c,o-=c}else n-=c,o-=c}}class s{constructor(e,t){if(this.content=e,this.size=t||0,null==t)for(let t=0;t<e.length;t++)this.size+=e[t].nodeSize}nodesBetween(e,t,n,o=0,r){for(let i=0,s=0;s<t;i++){let l=this.content[i],a=s+l.nodeSize;if(a>e&&!1!==n(l,o+s,r||null,i)&&l.content.size){let r=s+1;l.nodesBetween(Math.max(0,e-r),Math.min(l.content.size,t-r),n,o+r)}s=a}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,n,o){let r="",i=!0;return this.nodesBetween(e,t,((s,l)=>{let a=s.isText?s.text.slice(Math.max(e,l)-l,t-l):s.isLeaf?o?"function"==typeof o?o(s):o:s.type.spec.leafText?s.type.spec.leafText(s):"":"";s.isBlock&&(s.isLeaf&&a||s.isTextblock)&&n&&(i?i=!1:r+=n),r+=a}),0),r}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,n=e.firstChild,o=this.content.slice(),r=0;for(t.isText&&t.sameMarkup(n)&&(o[o.length-1]=t.withText(t.text+n.text),r=1);r<e.content.length;r++)o.push(e.content[r]);return new s(o,this.size+e.size)}cut(e,t=this.size){if(0==e&&t==this.size)return this;let n=[],o=0;if(t>e)for(let r=0,i=0;i<t;r++){let s=this.content[r],l=i+s.nodeSize;l>e&&((i<e||l>t)&&(s=s.isText?s.cut(Math.max(0,e-i),Math.min(s.text.length,t-i)):s.cut(Math.max(0,e-i-1),Math.min(s.content.size,t-i-1))),n.push(s),o+=s.nodeSize),i=l}return new s(n,o)}cutByIndex(e,t){return e==t?s.empty:0==e&&t==this.content.length?this:new s(this.content.slice(e,t))}replaceChild(e,t){let n=this.content[e];if(n==t)return this;let o=this.content.slice(),r=this.size+t.nodeSize-n.nodeSize;return o[e]=t,new s(o,r)}addToStart(e){return new s([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new s(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw new RangeError("Index "+e+" out of range for "+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,n=0;t<this.content.length;t++){let o=this.content[t];e(o,n,t),n+=o.nodeSize}}findDiffStart(e,t=0){return r(this,e,t)}findDiffEnd(e,t=this.size,n=e.size){return i(this,e,t,n)}findIndex(e){if(0==e)return a(0,e);if(e==this.size)return a(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,n=0;;t++){let o=n+this.child(t).nodeSize;if(o>=e)return o==e?a(t+1,o):a(t,n);n=o}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map((e=>e.toJSON())):null}static fromJSON(e,t){if(!t)return s.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new s(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return s.empty;let t,n=0;for(let o=0;o<e.length;o++){let r=e[o];n+=r.nodeSize,o&&r.isText&&e[o-1].sameMarkup(r)?(t||(t=e.slice(0,o)),t[t.length-1]=r.withText(t[t.length-1].text+r.text)):t&&t.push(r)}return new s(t||e,n)}static from(e){if(!e)return s.empty;if(e instanceof s)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new s([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}s.empty=new s([],0);const l={index:0,offset:0};function a(e,t){return l.index=e,l.offset=t,l}function c(e,t){if(e===t)return!0;if(!e||"object"!=typeof e||!t||"object"!=typeof t)return!1;let n=Array.isArray(e);if(Array.isArray(t)!=n)return!1;if(n){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!c(e[n],t[n]))return!1}else{for(let n in e)if(!(n in t)||!c(e[n],t[n]))return!1;for(let n in t)if(!(n in e))return!1}return!0}class d{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,n=!1;for(let o=0;o<e.length;o++){let r=e[o];if(this.eq(r))return e;if(this.type.excludes(r.type))t||(t=e.slice(0,o));else{if(r.type.excludes(this.type))return e;!n&&r.type.rank>this.type.rank&&(t||(t=e.slice(0,o)),t.push(this),n=!0),t&&t.push(r)}}return t||(t=e.slice()),n||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&c(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Mark.fromJSON");let n=e.marks[t.type];if(!n)throw new RangeError(`There is no mark type ${t.type} in this schema`);let o=n.create(t.attrs);return n.checkAttrs(o.attrs),o}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].eq(t[n]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&0==e.length)return d.none;if(e instanceof d)return[e];let t=e.slice();return t.sort(((e,t)=>e.type.rank-t.type.rank)),t}}d.none=[];class h extends Error{}class p{constructor(e,t,n){this.content=e,this.openStart=t,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let n=f(this.content,e+this.openStart,t);return n&&new p(n,this.openStart,this.openEnd)}removeBetween(e,t){return new p(u(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 p.empty;let n=t.openStart||0,o=t.openEnd||0;if("number"!=typeof n||"number"!=typeof o)throw new RangeError("Invalid input for Slice.fromJSON");return new p(s.fromJSON(e,t.content),n,o)}static maxOpen(e,t=!0){let n=0,o=0;for(let o=e.firstChild;o&&!o.isLeaf&&(t||!o.type.spec.isolating);o=o.firstChild)n++;for(let n=e.lastChild;n&&!n.isLeaf&&(t||!n.type.spec.isolating);n=n.lastChild)o++;return new p(e,n,o)}}function u(e,t,n){let{index:o,offset:r}=e.findIndex(t),i=e.maybeChild(o),{index:s,offset:l}=e.findIndex(n);if(r==t||i.isText){if(l!=n&&!e.child(s).isText)throw new RangeError("Removing non-flat range");return e.cut(0,t).append(e.cut(n))}if(o!=s)throw new RangeError("Removing non-flat range");return e.replaceChild(o,i.copy(u(i.content,t-r-1,n-r-1)))}function f(e,t,n,o){let{index:r,offset:i}=e.findIndex(t),s=e.maybeChild(r);if(i==t||s.isText)return o&&!o.canReplace(r,r,n)?null:e.cut(0,t).append(n).append(e.cut(t));let l=f(s.content,t-i-1,n,s);return l&&e.replaceChild(r,s.copy(l))}function m(e,t,n){if(n.openStart>e.depth)throw new h("Inserted content deeper than insertion position");if(e.depth-n.openStart!=t.depth-n.openEnd)throw new h("Inconsistent open depths");return g(e,t,n,0)}function g(e,t,n,o){let r=e.index(o),i=e.node(o);if(r==t.index(o)&&o<e.depth-n.openStart){let s=g(e,t,n,o+1);return i.copy(i.content.replaceChild(r,s))}if(n.content.size){if(n.openStart||n.openEnd||e.depth!=o||t.depth!=o){let{start:r,end:l}=function(e,t){let n=t.depth-e.openStart,o=t.node(n).copy(e.content);for(let e=n-1;e>=0;e--)o=t.node(e).copy(s.from(o));return{start:o.resolveNoCache(e.openStart+n),end:o.resolveNoCache(o.content.size-e.openEnd-n)}}(n,e);return k(i,x(e,r,l,t,o))}{let o=e.parent,r=o.content;return k(o,r.cut(0,e.parentOffset).append(n.content).append(r.cut(t.parentOffset)))}}return k(i,S(e,t,o))}function y(e,t){if(!t.type.compatibleContent(e.type))throw new h("Cannot join "+t.type.name+" onto "+e.type.name)}function w(e,t,n){let o=e.node(n);return y(o,t.node(n)),o}function v(e,t){let n=t.length-1;n>=0&&e.isText&&e.sameMarkup(t[n])?t[n]=e.withText(t[n].text+e.text):t.push(e)}function b(e,t,n,o){let r=(t||e).node(n),i=0,s=t?t.index(n):r.childCount;e&&(i=e.index(n),e.depth>n?i++:e.textOffset&&(v(e.nodeAfter,o),i++));for(let e=i;e<s;e++)v(r.child(e),o);t&&t.depth==n&&t.textOffset&&v(t.nodeBefore,o)}function k(e,t){return e.type.checkContent(t),e.copy(t)}function x(e,t,n,o,r){let i=e.depth>r&&w(e,t,r+1),l=o.depth>r&&w(n,o,r+1),a=[];return b(null,e,r,a),i&&l&&t.index(r)==n.index(r)?(y(i,l),v(k(i,x(e,t,n,o,r+1)),a)):(i&&v(k(i,S(e,t,r+1)),a),b(t,n,r,a),l&&v(k(l,S(n,o,r+1)),a)),b(o,null,r,a),new s(a)}function S(e,t,n){let o=[];return b(null,e,n,o),e.depth>n&&v(k(w(e,t,n+1),S(e,t,n+1)),o),b(t,null,n,o),new s(o)}p.empty=new p(s.empty,0,0);class C{constructor(e,t,n){this.pos=e,this.path=t,this.parentOffset=n,this.depth=t.length/3-1}resolveDepth(e){return null==e?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[3*this.resolveDepth(e)]}index(e){return this.path[3*this.resolveDepth(e)+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e!=this.depth||this.textOffset?1:0)}start(e){return 0==(e=this.resolveDepth(e))?0:this.path[3*e-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(!(e=this.resolveDepth(e)))throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[3*e-1]}after(e){if(!(e=this.resolveDepth(e)))throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[3*e-1]+this.path[3*e].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let n=this.pos-this.path[this.path.length-1],o=e.child(t);return n?e.child(t).cut(n):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):0==e?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let n=this.path[3*t],o=0==t?0:this.path[3*t-1]+1;for(let t=0;t<e;t++)o+=n.child(t).nodeSize;return o}marks(){let e=this.parent,t=this.index();if(0==e.content.size)return d.none;if(this.textOffset)return e.child(t).marks;let n=e.maybeChild(t-1),o=e.maybeChild(t);if(!n){let e=n;n=o,o=e}let r=n.marks;for(var i=0;i<r.length;i++)!1!==r[i].type.spec.inclusive||o&&r[i].isInSet(o.marks)||(r=r[i--].removeFromSet(r));return r}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let n=t.marks,o=e.parent.maybeChild(e.index());for(var r=0;r<n.length;r++)!1!==n[r].type.spec.inclusive||o&&n[r].isInSet(o.marks)||(n=n[r--].removeFromSet(n));return n}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let n=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);n>=0;n--)if(e.pos<=this.end(n)&&(!t||t(this.node(n))))return new A(this,e,n);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let t=1;t<=this.depth;t++)e+=(e?"/":"")+this.node(t).type.name+"_"+this.index(t-1);return e+":"+this.parentOffset}static resolve(e,t){if(!(t>=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let n=[],o=0,r=t;for(let t=e;;){let{index:e,offset:i}=t.content.findIndex(r),s=r-i;if(n.push(t,e,o+i),!s)break;if(t=t.child(e),t.isText)break;r=s-1,o+=i+1}return new C(t,n,r)}static resolveCached(e,t){let n=O.get(e);if(n)for(let e=0;e<n.elts.length;e++){let o=n.elts[e];if(o.pos==t)return o}else O.set(e,n=new M);let o=n.elts[n.i]=C.resolve(e,t);return n.i=(n.i+1)%N,o}}class M{constructor(){this.elts=[],this.i=0}}const N=12,O=new WeakMap;class A{constructor(e,t,n){this.$from=e,this.$to=t,this.depth=n}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const T=Object.create(null);class D{constructor(e,t,n,o=d.none){this.type=e,this.attrs=t,this.marks=o,this.content=n||s.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,n,o=0){this.content.nodesBetween(e,t,n,o,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,t,n,o){return this.content.textBetween(e,t,n,o)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,n){return this.type==e&&c(this.attrs,t||e.defaultAttrs||T)&&d.sameSet(this.marks,n||d.none)}copy(e=null){return e==this.content?this:new D(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new D(this.type,this.attrs,this.content,e)}cut(e,t=this.content.size){return 0==e&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,n=!1){if(e==t)return p.empty;let o=this.resolve(e),r=this.resolve(t),i=n?0:o.sharedDepth(t),s=o.start(i),l=o.node(i).content.cut(o.pos-s,r.pos-s);return new p(l,o.depth-i,r.depth-i)}replace(e,t,n){return m(this.resolve(e),this.resolve(t),n)}nodeAt(e){for(let t=this;;){let{index:n,offset:o}=t.content.findIndex(e);if(t=t.maybeChild(n),!t)return null;if(o==e||t.isText)return t;e-=o+1}}childAfter(e){let{index:t,offset:n}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:n}}childBefore(e){if(0==e)return{node:null,index:0,offset:0};let{index:t,offset:n}=this.content.findIndex(e);if(n<e)return{node:this.content.child(t),index:t,offset:n};let o=this.content.child(t-1);return{node:o,index:t-1,offset:n-o.nodeSize}}resolve(e){return C.resolveCached(this,e)}resolveNoCache(e){return C.resolve(this,e)}rangeHasMark(e,t,n){let o=!1;return t>e&&this.nodesBetween(e,t,(e=>(n.isInSet(e.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()+")"),R(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw new Error("Called contentMatchAt on a node with invalid content");return t}canReplace(e,t,n=s.empty,o=0,r=n.childCount){let i=this.contentMatchAt(e).matchFragment(n,o,r),l=i&&i.matchFragment(this.content,t);if(!l||!l.validEnd)return!1;for(let e=o;e<r;e++)if(!this.type.allowsMarks(n.child(e).marks))return!1;return!0}canReplaceWith(e,t,n,o){if(o&&!this.type.allowsMarks(o))return!1;let r=this.contentMatchAt(e).matchType(n),i=r&&r.matchFragment(this.content,t);return!!i&&i.validEnd}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=d.none;for(let t=0;t<this.marks.length;t++){let n=this.marks[t];n.type.checkAttrs(n.attrs),e=n.addToSet(e)}if(!d.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map((e=>e.type.name))}`);this.content.forEach((e=>e.check()))}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map((e=>e.toJSON()))),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let n;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");n=t.marks.map(e.markFromJSON)}if("text"==t.type){if("string"!=typeof t.text)throw new RangeError("Invalid text node in JSON");return e.text(t.text,n)}let o=s.fromJSON(e,t.content),r=e.nodeType(t.type).create(t.attrs,o,n);return r.type.checkAttrs(r.attrs),r}}D.prototype.text=void 0;class E extends D{constructor(e,t,n,o){if(super(e,t,null,o),!n)throw new RangeError("Empty text nodes are not allowed");this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):R(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 E(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new E(this.type,this.attrs,e,this.marks)}cut(e=0,t=this.text.length){return 0==e&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function R(e,t){for(let n=e.length-1;n>=0;n--)t=e[n].type.name+"("+t+")";return t}class ${constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let n=new I(e,t);if(null==n.next)return $.empty;let o=z(n);n.next&&n.err("Unexpected trailing text");let r=function(e){let t=Object.create(null);return function n(o){let r=[];o.forEach((t=>{e[t].forEach((({term:t,to:n})=>{if(!t)return;let o;for(let e=0;e<r.length;e++)r[e][0]==t&&(o=r[e][1]);H(e,n).forEach((e=>{o||r.push([t,o=[]]),-1==o.indexOf(e)&&o.push(e)}))}))}));let i=t[o.join(",")]=new $(o.indexOf(e.length-1)>-1);for(let e=0;e<r.length;e++){let o=r[e][1].sort(L);i.next.push({type:r[e][0],next:t[o.join(",")]||n(o)})}return i}(H(e,0))}(function(e){let t=[[]];return r(function e(t,i){if("choice"==t.type)return t.exprs.reduce(((t,n)=>t.concat(e(n,i))),[]);if("seq"!=t.type){if("star"==t.type){let s=n();return o(i,s),r(e(t.expr,s),s),[o(s)]}if("plus"==t.type){let s=n();return r(e(t.expr,i),s),r(e(t.expr,s),s),[o(s)]}if("opt"==t.type)return[o(i)].concat(e(t.expr,i));if("range"==t.type){let s=i;for(let o=0;o<t.min;o++){let o=n();r(e(t.expr,s),o),s=o}if(-1==t.max)r(e(t.expr,s),s);else for(let i=t.min;i<t.max;i++){let i=n();o(s,i),r(e(t.expr,s),i),s=i}return[o(s)]}if("name"==t.type)return[o(i,void 0,t.value)];throw new Error("Unknown expr type")}for(let o=0;;o++){let s=e(t.exprs[o],i);if(o==t.exprs.length-1)return s;r(s,i=n())}}(e,0),n()),t;function n(){return t.push([])-1}function o(e,n,o){let r={term:o,to:n};return t[e].push(r),r}function r(e,t){e.forEach((e=>e.to=t))}}(o));return function(e,t){for(let n=0,o=[e];n<o.length;n++){let e=o[n],r=!e.validEnd,i=[];for(let t=0;t<e.next.length;t++){let{type:n,next:s}=e.next[t];i.push(n.name),!r||n.isText||n.hasRequiredAttrs()||(r=!1),-1==o.indexOf(s)&&o.push(s)}r&&t.err("Only non-generatable nodes ("+i.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}(r,n),r}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,n=e.childCount){let o=this;for(let r=t;o&&r<n;r++)o=o.matchType(e.child(r).type);return o}get inlineContent(){return 0!=this.next.length&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!t.isText&&!t.hasRequiredAttrs())return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let n=0;n<e.next.length;n++)if(this.next[t].type==e.next[n].type)return!0;return!1}fillBefore(e,t=!1,n=0){let o=[this];return function r(i,l){let a=i.matchFragment(e,n);if(a&&(!t||a.validEnd))return s.from(l.map((e=>e.createAndFill())));for(let e=0;e<i.next.length;e++){let{type:t,next:n}=i.next[e];if(!t.isText&&!t.hasRequiredAttrs()&&-1==o.indexOf(n)){o.push(n);let e=r(n,l.concat(t));if(e)return e}}return null}(this,[])}findWrapping(e){for(let t=0;t<this.wrapCache.length;t+=2)if(this.wrapCache[t]==e)return this.wrapCache[t+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),n=[{match:this,type:null,via:null}];for(;n.length;){let o=n.shift(),r=o.match;if(r.matchType(e)){let e=[];for(let t=o;t.type;t=t.via)e.push(t.type);return e.reverse()}for(let e=0;e<r.next.length;e++){let{type:i,next:s}=r.next[e];i.isLeaf||i.hasRequiredAttrs()||i.name in t||o.type&&!s.validEnd||(n.push({match:i.contentMatch,type:i,via:o}),t[i.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];return function t(n){e.push(n);for(let o=0;o<n.next.length;o++)-1==e.indexOf(n.next[o].next)&&t(n.next[o].next)}(this),e.map(((t,n)=>{let o=n+(t.validEnd?"*":" ")+" ";for(let n=0;n<t.next.length;n++)o+=(n?", ":"")+t.next[n].type.name+"->"+e.indexOf(t.next[n].next);return o})).join("\n")}}$.empty=new $(!0);class I{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 z(e){let t=[];do{t.push(B(e))}while(e.eat("|"));return 1==t.length?t[0]:{type:"choice",exprs:t}}function B(e){let t=[];do{t.push(P(e))}while(e.next&&")"!=e.next&&"|"!=e.next);return 1==t.length?t[0]:{type:"seq",exprs:t}}function P(e){let t=function(e){if(e.eat("(")){let t=z(e);return e.eat(")")||e.err("Missing closing paren"),t}if(!/\W/.test(e.next)){let t=function(e,t){let n=e.nodeTypes,o=n[t];if(o)return[o];let r=[];for(let e in n){let o=n[e];o.isInGroup(t)&&r.push(o)}return 0==r.length&&e.err("No node type or group '"+t+"' found"),r}(e,e.next).map((t=>(null==e.inline?e.inline=t.isInline:e.inline!=t.isInline&&e.err("Mixing inline and block content"),{type:"name",value:t})));return e.pos++,1==t.length?t[0]:{type:"choice",exprs:t}}e.err("Unexpected token '"+e.next+"'")}(e);for(;;)if(e.eat("+"))t={type:"plus",expr:t};else if(e.eat("*"))t={type:"star",expr:t};else if(e.eat("?"))t={type:"opt",expr:t};else{if(!e.eat("{"))break;t=F(e,t)}return t}function V(e){/\D/.test(e.next)&&e.err("Expected number, got '"+e.next+"'");let t=Number(e.next);return e.pos++,t}function F(e,t){let n=V(e),o=n;return e.eat(",")&&(o="}"!=e.next?V(e):-1),e.eat("}")||e.err("Unclosed braced range"),{type:"range",min:n,max:o,expr:t}}function L(e,t){return t-e}function H(e,t){let n=[];return function t(o){let r=e[o];if(1==r.length&&!r[0].term)return t(r[0].to);n.push(o);for(let e=0;e<r.length;e++){let{term:o,to:i}=r[e];o||-1!=n.indexOf(i)||t(i)}}(t),n.sort(L)}function _(e){let t=Object.create(null);for(let n in e){let o=e[n];if(!o.hasDefault)return null;t[n]=o.default}return t}function W(e,t){let n=Object.create(null);for(let o in e){let r=t&&t[o];if(void 0===r){let t=e[o];if(!t.hasDefault)throw new RangeError("No value supplied for attribute "+o);r=t.default}n[o]=r}return n}function q(e,t,n,o){for(let o in t)if(!(o in e))throw new RangeError(`Unsupported attribute ${o} for ${n} of type ${o}`);for(let n in e){let o=e[n];o.validate&&o.validate(t[n])}}function j(e,t){let n=Object.create(null);if(t)for(let o in t)n[o]=new K(e,o,t[o]);return n}class J{constructor(e,t,n){this.name=e,this.schema=t,this.spec=n,this.markSet=null,this.groups=n.group?n.group.split(" "):[],this.attrs=j(e,n.attrs),this.defaultAttrs=_(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(n.inline||"text"==e),this.isText="text"==e}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==$.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(e){return this.groups.indexOf(e)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:W(this.attrs,e)}create(e=null,t,n){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new D(this,this.computeAttrs(e),s.from(t),d.setFrom(n))}createChecked(e=null,t,n){return t=s.from(t),this.checkContent(t),new D(this,this.computeAttrs(e),t,d.setFrom(n))}createAndFill(e=null,t,n){if(e=this.computeAttrs(e),(t=s.from(t)).size){let e=this.contentMatch.fillBefore(t);if(!e)return null;t=e.append(t)}let o=this.contentMatch.matchFragment(t),r=o&&o.fillBefore(s.empty,!0);return r?new D(this,e,t.append(r),d.setFrom(n)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let t=0;t<e.childCount;t++)if(!this.allowsMarks(e.child(t).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){q(this.attrs,e,"node",this.name)}allowsMarkType(e){return null==this.markSet||this.markSet.indexOf(e)>-1}allowsMarks(e){if(null==this.markSet)return!0;for(let t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){if(null==this.markSet)return e;let t;for(let n=0;n<e.length;n++)this.allowsMarkType(e[n].type)?t&&t.push(e[n]):t||(t=e.slice(0,n));return t?t.length?t:d.none:e}static compile(e,t){let n=Object.create(null);e.forEach(((e,o)=>n[e]=new J(e,t,o)));let o=t.spec.topNode||"doc";if(!n[o])throw new RangeError("Schema is missing its top node type ('"+o+"')");if(!n.text)throw new RangeError("Every schema needs a 'text' type");for(let e in n.text.attrs)throw new RangeError("The text node type should not have attributes");return n}}class K{constructor(e,t,n){this.hasDefault=Object.prototype.hasOwnProperty.call(n,"default"),this.default=n.default,this.validate="string"==typeof n.validate?function(e,t,n){let o=n.split("|");return n=>{let r=null===n?"null":typeof n;if(o.indexOf(r)<0)throw new RangeError(`Expected value of type ${o} for attribute ${t} on type ${e}, got ${r}`)}}(e,t,n.validate):n.validate}get isRequired(){return!this.hasDefault}}class X{constructor(e,t,n,o){this.name=e,this.rank=t,this.schema=n,this.spec=o,this.attrs=j(e,o.attrs),this.excluded=null;let r=_(this.attrs);this.instance=r?new d(this,r):null}create(e=null){return!e&&this.instance?this.instance:new d(this,W(this.attrs,e))}static compile(e,t){let n=Object.create(null),o=0;return e.forEach(((e,r)=>n[e]=new X(e,o++,t,r))),n}removeFromSet(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}checkAttrs(e){q(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class U{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let n in e)t[n]=e[n];t.nodes=o.from(e.nodes),t.marks=o.from(e.marks||{}),this.nodes=J.compile(this.spec.nodes,this),this.marks=X.compile(this.spec.marks,this);let n=Object.create(null);for(let e in this.nodes){if(e in this.marks)throw new RangeError(e+" can not be both a node and a mark");let t=this.nodes[e],o=t.spec.content||"",r=t.spec.marks;if(t.contentMatch=n[o]||(n[o]=$.parse(o,this.nodes)),t.inlineContent=t.contentMatch.inlineContent,t.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!t.isInline||!t.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=t}t.markSet="_"==r?null:r?Y(this,r.split(" ")):""!=r&&t.inlineContent?null:[]}for(let e in this.marks){let t=this.marks[e],n=t.spec.excludes;t.excluded=null==n?[t]:""==n?[]:Y(this,n.split(" "))}this.nodeFromJSON=e=>D.fromJSON(this,e),this.markFromJSON=e=>d.fromJSON(this,e),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,n,o){if("string"==typeof e)e=this.nodeType(e);else{if(!(e instanceof J))throw new RangeError("Invalid node type: "+e);if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}return e.createChecked(t,n,o)}text(e,t){let n=this.nodes.text;return new E(n,n.defaultAttrs,e,d.setFrom(t))}mark(e,t){return"string"==typeof e&&(e=this.marks[e]),e.create(t)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}}function Y(e,t){let n=[];for(let o=0;o<t.length;o++){let r=t[o],i=e.marks[r],s=i;if(i)n.push(i);else for(let t in e.marks){let o=e.marks[t];("_"==r||o.spec.group&&o.spec.group.split(" ").indexOf(r)>-1)&&n.push(s=o)}if(!s)throw new SyntaxError("Unknown mark type: '"+t[o]+"'")}return n}class G{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let n=this.matchedStyles=[];t.forEach((e=>{if(function(e){return null!=e.tag}(e))this.tags.push(e);else if(function(e){return null!=e.style}(e)){let t=/[^=]*/.exec(e.style)[0];n.indexOf(t)<0&&n.push(t),this.styles.push(e)}})),this.normalizeLists=!this.tags.some((t=>{if(!/^(ul|ol)\b/.test(t.tag)||!t.node)return!1;let n=e.nodes[t.node];return n.contentMatch.matchType(n)}))}parse(e,t={}){let n=new oe(this,t,!1);return n.addAll(e,d.none,t.from,t.to),n.finish()}parseSlice(e,t={}){let n=new oe(this,t,!0);return n.addAll(e,d.none,t.from,t.to),p.maxOpen(n.finish())}matchTag(e,t,n){for(let o=n?this.tags.indexOf(n)+1:0;o<this.tags.length;o++){let n=this.tags[o];if(re(e,n.tag)&&(void 0===n.namespace||e.namespaceURI==n.namespace)&&(!n.context||t.matchesContext(n.context))){if(n.getAttrs){let t=n.getAttrs(e);if(!1===t)continue;n.attrs=t||void 0}return n}}}matchStyle(e,t,n,o){for(let r=o?this.styles.indexOf(o)+1:0;r<this.styles.length;r++){let o=this.styles[r],i=o.style;if(!(0!=i.indexOf(e)||o.context&&!n.matchesContext(o.context)||i.length>e.length&&(61!=i.charCodeAt(e.length)||i.slice(e.length+1)!=t))){if(o.getAttrs){let e=o.getAttrs(t);if(!1===e)continue;o.attrs=e||void 0}return o}}}static schemaRules(e){let t=[];function n(e){let n=null==e.priority?50:e.priority,o=0;for(;o<t.length;o++){let e=t[o];if((null==e.priority?50:e.priority)<n)break}t.splice(o,0,e)}for(let t in e.marks){let o=e.marks[t].spec.parseDOM;o&&o.forEach((e=>{n(e=ie(e)),e.mark||e.ignore||e.clearMark||(e.mark=t)}))}for(let t in e.nodes){let o=e.nodes[t].spec.parseDOM;o&&o.forEach((e=>{n(e=ie(e)),e.node||e.ignore||e.mark||(e.node=t)}))}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new G(e,G.schemaRules(e)))}}const Q={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},Z={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},ee={ol:!0,ul:!0};function te(e,t,n){return null!=t?(t?1:0)|("full"===t?2:0):e&&"pre"==e.whitespace?3:-5&n}class ne{constructor(e,t,n,o,r,i){this.type=e,this.attrs=t,this.marks=n,this.solid=o,this.options=i,this.content=[],this.activeMarks=d.none,this.match=r||(4&i?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(s.from(e));if(!t){let t,n=this.type.contentMatch;return(t=n.findWrapping(e.type))?(this.match=n,t):null}this.match=this.type.contentMatch.matchFragment(t)}return this.match.findWrapping(e.type)}finish(e){if(!(1&this.options)){let e,t=this.content[this.content.length-1];if(t&&t.isText&&(e=/[ \t\r\n\u000c]+$/.exec(t.text))){let n=t;t.text.length==e[0].length?this.content.pop():this.content[this.content.length-1]=n.withText(n.text.slice(0,n.text.length-e[0].length))}}let t=s.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(s.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!Q.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class oe{constructor(e,t,n){this.parser=e,this.options=t,this.isOpen=n,this.open=0,this.localPreserveWS=!1;let o,r=t.topNode,i=te(null,t.preserveWhitespace,0)|(n?4:0);o=r?new ne(r.type,r.attrs,d.none,!0,t.topMatch||r.type.contentMatch,i):new ne(n?null:e.schema.topNodeType,null,d.none,!0,null,i),this.nodes=[o],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){3==e.nodeType?this.addTextNode(e,t):1==e.nodeType&&this.addElement(e,t)}addTextNode(e,t){let n=e.nodeValue,o=this.top,r=2&o.options?"full":this.localPreserveWS||(1&o.options)>0;if("full"===r||o.inlineContext(e)||/[^ \t\r\n\u000c]/.test(n)){if(r)n="full"!==r?n.replace(/\r?\n|\r/g," "):n.replace(/\r\n?/g,"\n");else if(n=n.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(n)&&this.open==this.nodes.length-1){let t=o.content[o.content.length-1],r=e.previousSibling;(!t||r&&"BR"==r.nodeName||t.isText&&/[ \t\r\n\u000c]$/.test(t.text))&&(n=n.slice(1))}n&&this.insertNode(this.parser.schema.text(n),t,!/\S/.test(n)),this.findInText(e)}else this.findInside(e)}addElement(e,t,n){let o=this.localPreserveWS,r=this.top;("PRE"==e.tagName||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let i,s=e.nodeName.toLowerCase();ee.hasOwnProperty(s)&&this.parser.normalizeLists&&function(e){for(let t=e.firstChild,n=null;t;t=t.nextSibling){let e=1==t.nodeType?t.nodeName.toLowerCase():null;e&&ee.hasOwnProperty(e)&&n?(n.appendChild(t),t=n):"li"==e?n=t:e&&(n=null)}}(e);let l=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(i=this.parser.matchTag(e,this,n));e:if(l?l.ignore:Z.hasOwnProperty(s))this.findInside(e),this.ignoreFallback(e,t);else if(!l||l.skip||l.closeParent){l&&l.closeParent?this.open=Math.max(0,this.open-1):l&&l.skip.nodeType&&(e=l.skip);let n,o=this.needsBlock;if(Q.hasOwnProperty(s))r.content.length&&r.content[0].isInline&&this.open&&(this.open--,r=this.top),n=!0,r.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break e}let i=l&&l.skip?t:this.readStyles(e,t);i&&this.addAll(e,i),n&&this.sync(r),this.needsBlock=o}else{let n=this.readStyles(e,t);n&&this.addElementByRule(e,l,n,!1===l.consuming?i:void 0)}this.localPreserveWS=o}leafFallback(e,t){"BR"==e.nodeName&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode("\n"),t)}ignoreFallback(e,t){"BR"!=e.nodeName||this.top.type&&this.top.type.inlineContent||this.findPlace(this.parser.schema.text("-"),t,!0)}readStyles(e,t){let n=e.style;if(n&&n.length)for(let e=0;e<this.parser.matchedStyles.length;e++){let o=this.parser.matchedStyles[e],r=n.getPropertyValue(o);if(r)for(let e;;){let n=this.parser.matchStyle(o,r,this,e);if(!n)break;if(n.ignore)return null;if(t=n.clearMark?t.filter((e=>!n.clearMark(e))):t.concat(this.parser.schema.marks[n.mark].create(n.attrs)),!1!==n.consuming)break;e=n}}return t}addElementByRule(e,t,n,o){let r,i;if(t.node)if(i=this.parser.schema.nodes[t.node],i.isLeaf)this.insertNode(i.create(t.attrs),n,"BR"==e.nodeName)||this.leafFallback(e,n);else{let e=this.enter(i,t.attrs||null,n,t.preserveWhitespace);e&&(r=!0,n=e)}else{let e=this.parser.schema.marks[t.mark];n=n.concat(e.create(t.attrs))}let s=this.top;if(i&&i.isLeaf)this.findInside(e);else if(o)this.addElement(e,n,o);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach((e=>this.insertNode(e,n,!1)));else{let o=e;"string"==typeof t.contentElement?o=e.querySelector(t.contentElement):"function"==typeof t.contentElement?o=t.contentElement(e):t.contentElement&&(o=t.contentElement),this.findAround(e,o,!0),this.addAll(o,n),this.findAround(e,o,!1)}r&&this.sync(s)&&this.open--}addAll(e,t,n,o){let r=n||0;for(let i=n?e.childNodes[n]:e.firstChild,s=null==o?null:e.childNodes[o];i!=s;i=i.nextSibling,++r)this.findAtPoint(e,r),this.addDOM(i,t);this.findAtPoint(e,r)}findPlace(e,t,n){let o,r;for(let t=this.open,i=0;t>=0;t--){let s=this.nodes[t],l=s.findWrapping(e);if(l&&(!o||o.length>l.length+i)&&(o=l,r=s,!l.length))break;if(s.solid){if(n)break;i+=2}}if(!o)return null;this.sync(r);for(let e=0;e<o.length;e++)t=this.enterInner(o[e],null,t,!1);return t}insertNode(e,t,n){if(e.isInline&&this.needsBlock&&!this.top.type){let e=this.textblockFromContext();e&&(t=this.enterInner(e,null,t))}let o=this.findPlace(e,t,n);if(o){this.closeExtra();let t=this.top;t.match&&(t.match=t.match.matchType(e.type));let n=d.none;for(let r of o.concat(e.marks))(t.type?t.type.allowsMarkType(r.type):se(r.type,e.type))&&(n=r.addToSet(n));return t.content.push(e.mark(n)),!0}return!1}enter(e,t,n,o){let r=this.findPlace(e.create(t),n,!1);return r&&(r=this.enterInner(e,t,n,!0,o)),r}enterInner(e,t,n,o=!1,r){this.closeExtra();let i=this.top;i.match=i.match&&i.match.matchType(e);let s=te(e,r,i.options);4&i.options&&0==i.content.length&&(s|=4);let l=d.none;return n=n.filter((t=>!(i.type?i.type.allowsMarkType(t.type):se(t.type,e))||(l=t.addToSet(l),!1))),this.nodes.push(new ne(e,t,l,o,null,s)),this.open++,n}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!(!this.isOpen&&!this.options.topOpen))}sync(e){for(let t=this.open;t>=0;t--){if(this.nodes[t]==e)return this.open=t,!0;this.localPreserveWS&&(this.nodes[t].options|=1)}return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let n=this.nodes[t].content;for(let t=n.length-1;t>=0;t--)e+=n[t].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&this.find[n].offset==t&&(this.find[n].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)null==this.find[t].pos&&1==e.nodeType&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,n){if(e!=t&&this.find)for(let o=0;o<this.find.length;o++)null==this.find[o].pos&&1==e.nodeType&&e.contains(this.find[o].node)&&t.compareDocumentPosition(this.find[o].node)&(n?2:4)&&(this.find[o].pos=this.currentPos)}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split("/"),n=this.options.context,o=!(this.isOpen||n&&n.parent.type!=this.nodes[0].type),r=-(n?n.depth+1:0)+(o?0:1),i=(e,s)=>{for(;e>=0;e--){let l=t[e];if(""==l){if(e==t.length-1||0==e)continue;for(;s>=r;s--)if(i(e-1,s))return!0;return!1}{let e=s>0||0==s&&o?this.nodes[s].type:n&&s>=r?n.node(s-r).type:null;if(!e||e.name!=l&&!e.isInGroup(l))return!1;s--}}return!0};return i(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let n=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(let e in this.parser.schema.nodes){let t=this.parser.schema.nodes[e];if(t.isTextblock&&t.defaultAttrs)return t}}}function re(e,t){return(e.matches||e.msMatchesSelector||e.webkitMatchesSelector||e.mozMatchesSelector).call(e,t)}function ie(e){let t={};for(let n in e)t[n]=e[n];return t}function se(e,t){let n=t.schema.nodes;for(let o in n){let r=n[o];if(!r.allowsMarkType(e))continue;let i=[],s=e=>{i.push(e);for(let n=0;n<e.edgeCount;n++){let{type:o,next:r}=e.edge(n);if(o==t)return!0;if(i.indexOf(r)<0&&s(r))return!0}};if(s(r.contentMatch))return!0}}class le{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},n){n||(n=ce(t).createDocumentFragment());let o=n,r=[];return e.forEach((e=>{if(r.length||e.marks.length){let n=0,i=0;for(;n<r.length&&i<e.marks.length;){let t=e.marks[i];if(this.marks[t.type.name]){if(!t.eq(r[n][0])||!1===t.type.spec.spanning)break;n++,i++}else i++}for(;n<r.length;)o=r.pop()[1];for(;i<e.marks.length;){let n=e.marks[i++],s=this.serializeMark(n,e.isInline,t);s&&(r.push([n,o]),o.appendChild(s.dom),o=s.contentDOM||s.dom)}}o.appendChild(this.serializeNodeInner(e,t))})),n}serializeNodeInner(e,t){let{dom:n,contentDOM:o}=he(ce(t),this.nodes[e.type.name](e),null,e.attrs);if(o){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,o)}return n}serializeNode(e,t={}){let n=this.serializeNodeInner(e,t);for(let o=e.marks.length-1;o>=0;o--){let r=this.serializeMark(e.marks[o],e.isInline,t);r&&((r.contentDOM||r.dom).appendChild(n),n=r.dom)}return n}serializeMark(e,t,n={}){let o=this.marks[e.type.name];return o&&he(ce(n),o(e,t),null,e.attrs)}static renderSpec(e,t,n=null,o){return he(e,t,n,o)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new le(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=ae(e.nodes);return t.text||(t.text=e=>e.text),t}static marksFromSchema(e){return ae(e.marks)}}function ae(e){let t={};for(let n in e){let o=e[n].spec.toDOM;o&&(t[n]=o)}return t}function ce(e){return e.document||window.document}const de=new WeakMap;function he(e,t,n,o){if("string"==typeof t)return{dom:e.createTextNode(t)};if(null!=t.nodeType)return{dom:t};if(t.dom&&null!=t.dom.nodeType)return t;let r,i=t[0];if("string"!=typeof i)throw new RangeError("Invalid array passed to renderSpec");if(o&&(r=function(e){let t=de.get(e);return void 0===t&&de.set(e,t=function(e){let t=null;return function e(n){if(n&&"object"==typeof n)if(Array.isArray(n))if("string"==typeof n[0])t||(t=[]),t.push(n);else for(let t=0;t<n.length;t++)e(n[t]);else for(let t in n)e(n[t])}(e),t}(e)),t}(o))&&r.indexOf(t)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let s,l=i.indexOf(" ");l>0&&(n=i.slice(0,l),i=i.slice(l+1));let a=n?e.createElementNS(n,i):e.createElement(i),c=t[1],d=1;if(c&&"object"==typeof c&&null==c.nodeType&&!Array.isArray(c)){d=2;for(let e in c)if(null!=c[e]){let t=e.indexOf(" ");t>0?a.setAttributeNS(e.slice(0,t),e.slice(t+1),c[e]):"style"==e&&a.style?a.style.cssText=c[e]:a.setAttribute(e,c[e])}}for(let r=d;r<t.length;r++){let i=t[r];if(0===i){if(r<t.length-1||r>d)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}{let{dom:t,contentDOM:r}=he(e,i,n,o);if(a.appendChild(t),r){if(s)throw new RangeError("Multiple content holes");s=r}}}return{dom:a,contentDOM:s}}const pe=Math.pow(2,16);function ue(e){return 65535&e}class fe{constructor(e,t,n){this.pos=e,this.delInfo=t,this.recover=n}get deleted(){return(8&this.delInfo)>0}get deletedBefore(){return(5&this.delInfo)>0}get deletedAfter(){return(6&this.delInfo)>0}get deletedAcross(){return(4&this.delInfo)>0}}class me{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&me.empty)return me.empty}recover(e){let t=0,n=ue(e);if(!this.inverted)for(let e=0;e<n;e++)t+=this.ranges[3*e+2]-this.ranges[3*e+1];return this.ranges[3*n]+t+function(e){return(e-(65535&e))/pe}(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,n){let o=0,r=this.inverted?2:1,i=this.inverted?1:2;for(let s=0;s<this.ranges.length;s+=3){let l=this.ranges[s]-(this.inverted?o:0);if(l>e)break;let a=this.ranges[s+r],c=this.ranges[s+i],d=l+a;if(e<=d){let r=l+o+((a?e==l?-1:e==d?1:t:t)<0?0:c);if(n)return r;let i=e==l?2:e==d?1:4;return(t<0?e!=l:e!=d)&&(i|=8),new fe(r,i,e==(t<0?l:d)?null:s/3+(e-l)*pe)}o+=c-a}return n?e+o:new fe(e+o,0,null)}touches(e,t){let n=0,o=ue(t),r=this.inverted?2:1,i=this.inverted?1:2;for(let t=0;t<this.ranges.length;t+=3){let s=this.ranges[t]-(this.inverted?n:0);if(s>e)break;let l=this.ranges[t+r];if(e<=s+l&&t==3*o)return!0;n+=this.ranges[t+i]-l}return!1}forEach(e){let t=this.inverted?2:1,n=this.inverted?1:2;for(let o=0,r=0;o<this.ranges.length;o+=3){let i=this.ranges[o],s=i-(this.inverted?r:0),l=i+(this.inverted?0:r),a=this.ranges[o+t],c=this.ranges[o+n];e(s,s+a,l,l+c),r+=c-a}}invert(){return new me(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return 0==e?me.empty:new me(e<0?[0,-e,0]:[0,0,e])}}me.empty=new me([]);class ge{constructor(e,t,n=0,o=(e?e.length:0)){this.mirror=t,this.from=n,this.to=o,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(e=0,t=this.maps.length){return new ge(this._maps,this.mirror,e,t)}appendMap(e,t){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),null!=t&&this.setMirror(this._maps.length-1,t)}appendMapping(e){for(let t=0,n=this._maps.length;t<e._maps.length;t++){let o=e.getMirror(t);this.appendMap(e._maps[t],null!=o&&o<t?n+o:void 0)}}getMirror(e){if(this.mirror)for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}setMirror(e,t){this.mirror||(this.mirror=[]),this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,n=this._maps.length+e._maps.length;t>=0;t--){let o=e.getMirror(t);this.appendMap(e._maps[t].invert(),null!=o&&o>t?n-o-1:void 0)}}invert(){let e=new ge;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let n=this.from;n<this.to;n++)e=this._maps[n].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,n){let o=0;for(let n=this.from;n<this.to;n++){let r=this._maps[n].mapResult(e,t);if(null!=r.recover){let t=this.getMirror(n);if(null!=t&&t>n&&t<this.to){n=t,e=this._maps[t].recover(r.recover);continue}}o|=r.delInfo,e=r.pos}return n?e:new fe(e,o,null)}}const ye=Object.create(null);class we{getMap(){return me.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let n=ye[t.stepType];if(!n)throw new RangeError(`No step type ${t.stepType} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in ye)throw new RangeError("Duplicate use of step JSON ID "+e);return ye[e]=t,t.prototype.jsonID=e,t}}class ve{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new ve(e,null)}static fail(e){return new ve(null,e)}static fromReplace(e,t,n,o){try{return ve.ok(e.replace(t,n,o))}catch(e){if(e instanceof h)return ve.fail(e.message);throw e}}}function be(e,t,n){let o=[];for(let r=0;r<e.childCount;r++){let i=e.child(r);i.content.size&&(i=i.copy(be(i.content,t,i))),i.isInline&&(i=t(i,n,r)),o.push(i)}return s.fromArray(o)}class ke extends we{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=e.resolve(this.from),o=n.node(n.sharedDepth(this.to)),r=new p(be(t.content,((e,t)=>e.isAtom&&t.type.allowsMarkType(this.mark.type)?e.mark(this.mark.addToSet(e.marks)):e),o),t.openStart,t.openEnd);return ve.fromReplace(e,this.from,this.to,r)}invert(){return new xe(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return t.deleted&&n.deleted||t.pos>=n.pos?null:new ke(t.pos,n.pos,this.mark)}merge(e){return e instanceof ke&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new ke(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if("number"!=typeof t.from||"number"!=typeof t.to)throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new ke(t.from,t.to,e.markFromJSON(t.mark))}}we.jsonID("addMark",ke);class xe extends we{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=new p(be(t.content,(e=>e.mark(this.mark.removeFromSet(e.marks))),e),t.openStart,t.openEnd);return ve.fromReplace(e,this.from,this.to,n)}invert(){return new ke(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return t.deleted&&n.deleted||t.pos>=n.pos?null:new xe(t.pos,n.pos,this.mark)}merge(e){return e instanceof xe&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new xe(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if("number"!=typeof t.from||"number"!=typeof t.to)throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new xe(t.from,t.to,e.markFromJSON(t.mark))}}we.jsonID("removeMark",xe);class Se extends we{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return ve.fail("No node at mark step's position");let n=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return ve.fromReplace(e,this.pos,this.pos+1,new p(s.from(n),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let e=this.mark.addToSet(t.marks);if(e.length==t.marks.length){for(let n=0;n<t.marks.length;n++)if(!t.marks[n].isInSet(e))return new Se(this.pos,t.marks[n]);return new Se(this.pos,this.mark)}}return new Ce(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new Se(t.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if("number"!=typeof t.pos)throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new Se(t.pos,e.markFromJSON(t.mark))}}we.jsonID("addNodeMark",Se);class Ce extends we{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return ve.fail("No node at mark step's position");let n=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return ve.fromReplace(e,this.pos,this.pos+1,new p(s.from(n),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return t&&this.mark.isInSet(t.marks)?new Se(this.pos,this.mark):this}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new Ce(t.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if("number"!=typeof t.pos)throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new Ce(t.pos,e.markFromJSON(t.mark))}}we.jsonID("removeNodeMark",Ce);class Me extends we{constructor(e,t,n,o=!1){super(),this.from=e,this.to=t,this.slice=n,this.structure=o}apply(e){return this.structure&&Oe(e,this.from,this.to)?ve.fail("Structure replace would overwrite content"):ve.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new me([this.from,this.to-this.from,this.slice.size])}invert(e){return new Me(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return t.deletedAcross&&n.deletedAcross?null:new Me(t.pos,Math.max(t.pos,n.pos),this.slice,this.structure)}merge(e){if(!(e instanceof Me)||e.structure||this.structure)return null;if(this.from+this.slice.size!=e.from||this.slice.openEnd||e.slice.openStart){if(e.to!=this.from||this.slice.openStart||e.slice.openEnd)return null;{let t=this.slice.size+e.slice.size==0?p.empty:new p(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new Me(e.from,this.to,t,this.structure)}}{let t=this.slice.size+e.slice.size==0?p.empty:new p(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new Me(this.from,this.to+(e.to-e.from),t,this.structure)}}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if("number"!=typeof t.from||"number"!=typeof t.to)throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new Me(t.from,t.to,p.fromJSON(e,t.slice),!!t.structure)}}we.jsonID("replace",Me);class Ne extends we{constructor(e,t,n,o,r,i,s=!1){super(),this.from=e,this.to=t,this.gapFrom=n,this.gapTo=o,this.slice=r,this.insert=i,this.structure=s}apply(e){if(this.structure&&(Oe(e,this.from,this.gapFrom)||Oe(e,this.gapTo,this.to)))return ve.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return ve.fail("Gap is not a flat range");let n=this.slice.insertAt(this.insert,t.content);return n?ve.fromReplace(e,this.from,this.to,n):ve.fail("Content does not fit in gap")}getMap(){return new me([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let t=this.gapTo-this.gapFrom;return new Ne(this.from,this.from+this.slice.size+t,this.from+this.insert,this.from+this.insert+t,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1),o=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),r=this.to==this.gapTo?n.pos:e.map(this.gapTo,1);return t.deletedAcross&&n.deletedAcross||o<t.pos||r>n.pos?null:new Ne(t.pos,n.pos,o,r,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if("number"!=typeof t.from||"number"!=typeof t.to||"number"!=typeof t.gapFrom||"number"!=typeof t.gapTo||"number"!=typeof t.insert)throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new Ne(t.from,t.to,t.gapFrom,t.gapTo,p.fromJSON(e,t.slice),t.insert,!!t.structure)}}function Oe(e,t,n){let o=e.resolve(t),r=n-t,i=o.depth;for(;r>0&&i>0&&o.indexAfter(i)==o.node(i).childCount;)i--,r--;if(r>0){let e=o.node(i).maybeChild(o.indexAfter(i));for(;r>0;){if(!e||e.isLeaf)return!0;e=e.firstChild,r--}}return!1}function Ae(e,t,n,o=n.contentMatch,r=!0){let i=e.doc.nodeAt(t),l=[],a=t+1;for(let t=0;t<i.childCount;t++){let c=i.child(t),d=a+c.nodeSize,h=o.matchType(c.type);if(h){o=h;for(let t=0;t<c.marks.length;t++)n.allowsMarkType(c.marks[t].type)||e.step(new xe(a,d,c.marks[t]));if(r&&c.isText&&"pre"!=n.whitespace){let e,t,o=/\r?\n|\r/g;for(;e=o.exec(c.text);)t||(t=new p(s.from(n.schema.text(" ",n.allowedMarks(c.marks))),0,0)),l.push(new Me(a+e.index,a+e.index+e[0].length,t))}}else l.push(new Me(a,d,p.empty));a=d}if(!o.validEnd){let t=o.fillBefore(s.empty,!0);e.replace(a,a,new p(t,0,0))}for(let t=l.length-1;t>=0;t--)e.step(l[t])}function Te(e,t,n){return(0==t||e.canReplace(t,e.childCount))&&(n==e.childCount||e.canReplace(0,n))}function De(e){let t=e.parent.content.cutByIndex(e.startIndex,e.endIndex);for(let n=e.depth;;--n){let o=e.$from.node(n),r=e.$from.index(n),i=e.$to.indexAfter(n);if(n<e.depth&&o.canReplace(r,i,t))return n;if(0==n||o.type.spec.isolating||!Te(o,r,i))break}return null}function Ee(e,t,n=null,o=e){let r=function(e,t){let{parent:n,startIndex:o,endIndex:r}=e,i=n.contentMatchAt(o).findWrapping(t);if(!i)return null;let s=i.length?i[0]:t;return n.canReplaceWith(o,r,s)?i:null}(e,t),i=r&&function(e,t){let{parent:n,startIndex:o,endIndex:r}=e,i=n.child(o),s=t.contentMatch.findWrapping(i.type);if(!s)return null;let l=(s.length?s[s.length-1]:t).contentMatch;for(let e=o;l&&e<r;e++)l=l.matchType(n.child(e).type);return l&&l.validEnd?s:null}(o,t);return i?r.map(Re).concat({type:t,attrs:n}).concat(i.map(Re)):null}function Re(e){return{type:e,attrs:null}}function $e(e,t,n,o){t.forEach(((r,i)=>{if(r.isText){let s,l=/\r?\n|\r/g;for(;s=l.exec(r.text);){let r=e.mapping.slice(o).map(n+1+i+s.index);e.replaceWith(r,r+1,t.type.schema.linebreakReplacement.create())}}}))}function Ie(e,t,n,o){t.forEach(((r,i)=>{if(r.type==r.type.schema.linebreakReplacement){let r=e.mapping.slice(o).map(n+1+i);e.replaceWith(r,r+1,t.type.schema.text("\n"))}}))}function ze(e,t,n=1,o){let r=e.resolve(t),i=r.depth-n,s=o&&o[o.length-1]||r.parent;if(i<0||r.parent.type.spec.isolating||!r.parent.canReplace(r.index(),r.parent.childCount)||!s.type.validContent(r.parent.content.cutByIndex(r.index(),r.parent.childCount)))return!1;for(let e=r.depth-1,t=n-2;e>i;e--,t--){let n=r.node(e),i=r.index(e);if(n.type.spec.isolating)return!1;let s=n.content.cutByIndex(i,n.childCount),l=o&&o[t+1];l&&(s=s.replaceChild(0,l.type.create(l.attrs)));let a=o&&o[t]||n;if(!n.canReplace(i+1,n.childCount)||!a.type.validContent(s))return!1}let l=r.indexAfter(i),a=o&&o[0];return r.node(i).canReplaceWith(l,l,a?a.type:r.node(i+1).type)}function Be(e,t){let n=e.resolve(t),o=n.index();return Pe(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(o,o+1)}function Pe(e,t){return!(!e||!t||e.isLeaf||!function(e,t){t.content.size||e.type.compatibleContent(t.type);let n=e.contentMatchAt(e.childCount),{linebreakReplacement:o}=e.type.schema;for(let r=0;r<t.childCount;r++){let i=t.child(r),s=i.type==o?e.type.schema.nodes.text:i.type;if(n=n.matchType(s),!n)return!1;if(!e.type.allowsMarks(i.marks))return!1}return n.validEnd}(e,t))}function Ve(e,t,n=-1){let o=e.resolve(t);for(let e=o.depth;;e--){let r,i,s=o.index(e);if(e==o.depth?(r=o.nodeBefore,i=o.nodeAfter):n>0?(r=o.node(e+1),s++,i=o.node(e).maybeChild(s)):(r=o.node(e).maybeChild(s-1),i=o.node(e+1)),r&&!r.isTextblock&&Pe(r,i)&&o.node(e).canReplace(s,s+1))return t;if(0==e)break;t=n<0?o.before(e):o.after(e)}}function Fe(e,t,n){let o=e.resolve(t);if(o.parent.canReplaceWith(o.index(),o.index(),n))return t;if(0==o.parentOffset)for(let e=o.depth-1;e>=0;e--){let t=o.index(e);if(o.node(e).canReplaceWith(t,t,n))return o.before(e+1);if(t>0)return null}if(o.parentOffset==o.parent.content.size)for(let e=o.depth-1;e>=0;e--){let t=o.indexAfter(e);if(o.node(e).canReplaceWith(t,t,n))return o.after(e+1);if(t<o.node(e).childCount)return null}return null}function Le(e,t,n){let o=e.resolve(t);if(!n.content.size)return t;let r=n.content;for(let e=0;e<n.openStart;e++)r=r.firstChild.content;for(let e=1;e<=(0==n.openStart&&n.size?2:1);e++)for(let t=o.depth;t>=0;t--){let n=t==o.depth?0:o.pos<=(o.start(t+1)+o.end(t+1))/2?-1:1,i=o.index(t)+(n>0?1:0),s=o.node(t),l=!1;if(1==e)l=s.canReplace(i,i,r);else{let e=s.contentMatchAt(i).findWrapping(r.firstChild.type);l=e&&s.canReplaceWith(i,i,e[0])}if(l)return 0==n?o.pos:n<0?o.before(t+1):o.after(t+1)}return null}function He(e,t,n=t,o=p.empty){if(t==n&&!o.size)return null;let r=e.resolve(t),i=e.resolve(n);return _e(r,i,o)?new Me(t,n,o):new We(r,i,o).fit()}function _e(e,t,n){return!n.openStart&&!n.openEnd&&e.start()==t.start()&&e.parent.canReplace(e.index(),t.index(),n.content)}we.jsonID("replaceAround",Ne);class We{constructor(e,t,n){this.$from=e,this.$to=t,this.unplaced=n,this.frontier=[],this.placed=s.empty;for(let t=0;t<=e.depth;t++){let n=e.node(t);this.frontier.push({type:n.type,match:n.contentMatchAt(e.indexAfter(t))})}for(let t=e.depth;t>0;t--)this.placed=s.from(e.node(t).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let e=this.findFittable();e?this.placeNodes(e):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,n=this.$from,o=this.close(e<0?this.$to:n.doc.resolve(e));if(!o)return null;let r=this.placed,i=n.depth,s=o.depth;for(;i&&s&&1==r.childCount;)r=r.firstChild.content,i--,s--;let l=new p(r,i,s);return e>-1?new Ne(n.pos,e,this.$to.pos,this.$to.end(),l,t):l.size||n.pos!=this.$to.pos?new Me(n.pos,o.pos,l):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,n=0,o=this.unplaced.openEnd;n<e;n++){let r=t.firstChild;if(t.childCount>1&&(o=0),r.type.spec.isolating&&o<=n){e=n;break}t=r.content}for(let t=1;t<=2;t++)for(let n=1==t?e:this.unplaced.openStart;n>=0;n--){let e,o=null;n?(o=Je(this.unplaced.content,n-1).firstChild,e=o.content):e=this.unplaced.content;let r=e.firstChild;for(let e=this.depth;e>=0;e--){let i,{type:l,match:a}=this.frontier[e],c=null;if(1==t&&(r?a.matchType(r.type)||(c=a.fillBefore(s.from(r),!1)):o&&l.compatibleContent(o.type)))return{sliceDepth:n,frontierDepth:e,parent:o,inject:c};if(2==t&&r&&(i=a.findWrapping(r.type)))return{sliceDepth:n,frontierDepth:e,parent:o,wrap:i};if(o&&a.matchType(o.type))break}}}openMore(){let{content:e,openStart:t,openEnd:n}=this.unplaced,o=Je(e,t);return!(!o.childCount||o.firstChild.isLeaf||(this.unplaced=new p(e,t+1,Math.max(n,o.size+t>=e.size-n?t+1:0)),0))}dropNode(){let{content:e,openStart:t,openEnd:n}=this.unplaced,o=Je(e,t);if(o.childCount<=1&&t>0){let r=e.size-t<=t+o.size;this.unplaced=new p(qe(e,t-1,1),t-1,r?t-1:n)}else this.unplaced=new p(qe(e,t,1),t,n)}placeNodes({sliceDepth:e,frontierDepth:t,parent:n,inject:o,wrap:r}){for(;this.depth>t;)this.closeFrontierNode();if(r)for(let e=0;e<r.length;e++)this.openFrontierNode(r[e]);let i=this.unplaced,l=n?n.content:i.content,a=i.openStart-e,c=0,d=[],{match:h,type:u}=this.frontier[t];if(o){for(let e=0;e<o.childCount;e++)d.push(o.child(e));h=h.matchFragment(o)}let f=l.size+e-(i.content.size-i.openEnd);for(;c<l.childCount;){let e=l.child(c),t=h.matchType(e.type);if(!t)break;c++,(c>1||0==a||e.content.size)&&(h=t,d.push(Ke(e.mark(u.allowedMarks(e.marks)),1==c?a:0,c==l.childCount?f:-1)))}let m=c==l.childCount;m||(f=-1),this.placed=je(this.placed,t,s.from(d)),this.frontier[t].match=h,m&&f<0&&n&&n.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let e=0,t=l;e<f;e++){let e=t.lastChild;this.frontier.push({type:e.type,match:e.contentMatchAt(e.childCount)}),t=e.content}this.unplaced=m?0==e?p.empty:new p(qe(i.content,e-1,1),e-1,f<0?i.openEnd:e-1):new p(qe(i.content,e,c),i.openStart,i.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e,t=this.frontier[this.depth];if(!t.type.isTextblock||!Xe(this.$to,this.$to.depth,t.type,t.match,!1)||this.$to.depth==this.depth&&(e=this.findCloseLevel(this.$to))&&e.depth==this.depth)return-1;let{depth:n}=this.$to,o=this.$to.after(n);for(;n>1&&o==this.$to.end(--n);)++o;return o}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:n,type:o}=this.frontier[t],r=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),i=Xe(e,t,o,n,r);if(i){for(let n=t-1;n>=0;n--){let{match:t,type:o}=this.frontier[n],r=Xe(e,n,o,t,!0);if(!r||r.childCount)continue e}return{depth:t,fit:i,move:r?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=je(this.placed,t.depth,t.fit)),e=t.move;for(let n=t.depth+1;n<=e.depth;n++){let t=e.node(n),o=t.type.contentMatch.fillBefore(t.content,!0,e.index(n));this.openFrontierNode(t.type,t.attrs,o)}return e}openFrontierNode(e,t=null,n){let o=this.frontier[this.depth];o.match=o.match.matchType(e),this.placed=je(this.placed,this.depth,s.from(e.create(t,n))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let e=this.frontier.pop().match.fillBefore(s.empty,!0);e.childCount&&(this.placed=je(this.placed,this.frontier.length,e))}}function qe(e,t,n){return 0==t?e.cutByIndex(n,e.childCount):e.replaceChild(0,e.firstChild.copy(qe(e.firstChild.content,t-1,n)))}function je(e,t,n){return 0==t?e.append(n):e.replaceChild(e.childCount-1,e.lastChild.copy(je(e.lastChild.content,t-1,n)))}function Je(e,t){for(let n=0;n<t;n++)e=e.firstChild.content;return e}function Ke(e,t,n){if(t<=0)return e;let o=e.content;return t>1&&(o=o.replaceChild(0,Ke(o.firstChild,t-1,1==o.childCount?n-1:0))),t>0&&(o=e.type.contentMatch.fillBefore(o).append(o),n<=0&&(o=o.append(e.type.contentMatch.matchFragment(o).fillBefore(s.empty,!0)))),e.copy(o)}function Xe(e,t,n,o,r){let i=e.node(t),s=r?e.indexAfter(t):e.index(t);if(s==i.childCount&&!n.compatibleContent(i.type))return null;let l=o.fillBefore(i.content,!0,s);return l&&!function(e,t,n){for(let o=n;o<t.childCount;o++)if(!e.allowsMarks(t.child(o).marks))return!0;return!1}(n,i.content,s)?l:null}function Ue(e,t,n,o,r){if(t<n){let r=e.firstChild;e=e.replaceChild(0,r.copy(Ue(r.content,t+1,n,o,r)))}if(t>o){let t=r.contentMatchAt(0),n=t.fillBefore(e).append(e);e=n.append(t.matchFragment(n).fillBefore(s.empty,!0))}return e}function Ye(e,t){let n=[];for(let o=Math.min(e.depth,t.depth);o>=0;o--){let r=e.start(o);if(r<e.pos-(e.depth-o)||t.end(o)>t.pos+(t.depth-o)||e.node(o).type.spec.isolating||t.node(o).type.spec.isolating)break;(r==t.start(o)||o==e.depth&&o==t.depth&&e.parent.inlineContent&&t.parent.inlineContent&&o&&t.start(o-1)==r-1)&&n.push(o)}return n}class Ge extends we{constructor(e,t,n){super(),this.pos=e,this.attr=t,this.value=n}apply(e){let t=e.nodeAt(this.pos);if(!t)return ve.fail("No node at attribute step's position");let n=Object.create(null);for(let e in t.attrs)n[e]=t.attrs[e];n[this.attr]=this.value;let o=t.type.create(n,null,t.marks);return ve.fromReplace(e,this.pos,this.pos+1,new p(s.from(o),0,t.isLeaf?0:1))}getMap(){return me.empty}invert(e){return new Ge(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 Ge(t.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,t){if("number"!=typeof t.pos||"string"!=typeof t.attr)throw new RangeError("Invalid input for AttrStep.fromJSON");return new Ge(t.pos,t.attr,t.value)}}we.jsonID("attr",Ge);class Qe extends we{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let n in e.attrs)t[n]=e.attrs[n];t[this.attr]=this.value;let n=e.type.create(t,e.content,e.marks);return ve.ok(n)}getMap(){return me.empty}invert(e){return new Qe(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,t){if("string"!=typeof t.attr)throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new Qe(t.attr,t.value)}}we.jsonID("docAttr",Qe);let Ze=class extends Error{};Ze=function e(t){let n=Error.call(this,t);return n.__proto__=e.prototype,n},Ze.prototype=Object.create(Error.prototype),Ze.prototype.constructor=Ze,Ze.prototype.name="TransformError";class et{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new ge}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new Ze(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,n=p.empty){let o=He(this.doc,e,t,n);return o&&this.step(o),this}replaceWith(e,t,n){return this.replace(e,t,new p(s.from(n),0,0))}delete(e,t){return this.replace(e,t,p.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,n){return function(e,t,n,o){if(!o.size)return e.deleteRange(t,n);let r=e.doc.resolve(t),i=e.doc.resolve(n);if(_e(r,i,o))return e.step(new Me(t,n,o));let s=Ye(r,e.doc.resolve(n));0==s[s.length-1]&&s.pop();let l=-(r.depth+1);s.unshift(l);for(let e=r.depth,t=r.pos-1;e>0;e--,t--){let n=r.node(e).type.spec;if(n.defining||n.definingAsContext||n.isolating)break;s.indexOf(e)>-1?l=e:r.before(e)==t&&s.splice(1,0,-e)}let a=s.indexOf(l),c=[],d=o.openStart;for(let e=o.content,t=0;;t++){let n=e.firstChild;if(c.push(n),t==o.openStart)break;e=n.content}for(let e=d-1;e>=0;e--){let t=c[e],n=(h=t.type).spec.defining||h.spec.definingForContent;if(n&&!t.sameMarkup(r.node(Math.abs(l)-1)))d=e;else if(n||!t.type.isTextblock)break}var h;for(let t=o.openStart;t>=0;t--){let l=(t+d+1)%(o.openStart+1),h=c[l];if(h)for(let t=0;t<s.length;t++){let c=s[(t+a)%s.length],d=!0;c<0&&(d=!1,c=-c);let u=r.node(c-1),f=r.index(c-1);if(u.canReplaceWith(f,f,h.type,h.marks))return e.replace(r.before(c),d?i.after(c):n,new p(Ue(o.content,0,o.openStart,l),l,o.openEnd))}}let u=e.steps.length;for(let l=s.length-1;l>=0&&(e.replace(t,n,o),!(e.steps.length>u));l--){let e=s[l];e<0||(t=r.before(e),n=i.after(e))}}(this,e,t,n),this}replaceRangeWith(e,t,n){return function(e,t,n,o){if(!o.isInline&&t==n&&e.doc.resolve(t).parent.content.size){let r=Fe(e.doc,t,o.type);null!=r&&(t=n=r)}e.replaceRange(t,n,new p(s.from(o),0,0))}(this,e,t,n),this}deleteRange(e,t){return function(e,t,n){let o=e.doc.resolve(t),r=e.doc.resolve(n),i=Ye(o,r);for(let t=0;t<i.length;t++){let n=i[t],s=t==i.length-1;if(s&&0==n||o.node(n).type.contentMatch.validEnd)return e.delete(o.start(n),r.end(n));if(n>0&&(s||o.node(n-1).canReplace(o.index(n-1),r.indexAfter(n-1))))return e.delete(o.before(n),r.after(n))}for(let i=1;i<=o.depth&&i<=r.depth;i++)if(t-o.start(i)==o.depth-i&&n>o.end(i)&&r.end(i)-n!=r.depth-i&&o.start(i-1)==r.start(i-1)&&o.node(i-1).canReplace(o.index(i-1),r.index(i-1)))return e.delete(o.before(i),n);e.delete(t,n)}(this,e,t),this}lift(e,t){return function(e,t,n){let{$from:o,$to:r,depth:i}=t,l=o.before(i+1),a=r.after(i+1),c=l,d=a,h=s.empty,u=0;for(let e=i,t=!1;e>n;e--)t||o.index(e)>0?(t=!0,h=s.from(o.node(e).copy(h)),u++):c--;let f=s.empty,m=0;for(let e=i,t=!1;e>n;e--)t||r.after(e+1)<r.end(e)?(t=!0,f=s.from(r.node(e).copy(f)),m++):d++;e.step(new Ne(c,d,l,a,new p(h.append(f),u,m),h.size-u,!0))}(this,e,t),this}join(e,t=1){return function(e,t,n){let o=null,{linebreakReplacement:r}=e.doc.type.schema,i=e.doc.resolve(t-n),s=i.node().type;if(r&&s.inlineContent){let e="pre"==s.whitespace,t=!!s.contentMatch.matchType(r);e&&!t?o=!1:!e&&t&&(o=!0)}let l=e.steps.length;if(!1===o){let o=e.doc.resolve(t+n);Ie(e,o.node(),o.before(),l)}s.inlineContent&&Ae(e,t+n-1,s,i.node().contentMatchAt(i.index()),null==o);let a=e.mapping.slice(l),c=a.map(t-n);if(e.step(new Me(c,a.map(t+n,-1),p.empty,!0)),!0===o){let t=e.doc.resolve(c);$e(e,t.node(),t.before(),e.steps.length)}}(this,e,t),this}wrap(e,t){return function(e,t,n){let o=s.empty;for(let e=n.length-1;e>=0;e--){if(o.size){let t=n[e].type.contentMatch.matchFragment(o);if(!t||!t.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}o=s.from(n[e].type.create(n[e].attrs,o))}let r=t.start,i=t.end;e.step(new Ne(r,i,r,i,new p(o,0,0),n.length,!0))}(this,e,t),this}setBlockType(e,t=e,n,o=null){return function(e,t,n,o,r){if(!o.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let i=e.steps.length;e.doc.nodesBetween(t,n,((t,n)=>{let l="function"==typeof r?r(t):r;if(t.isTextblock&&!t.hasMarkup(o,l)&&function(e,t,n){let o=e.resolve(t),r=o.index();return o.parent.canReplaceWith(r,r+1,n)}(e.doc,e.mapping.slice(i).map(n),o)){let r=null;if(o.schema.linebreakReplacement){let e="pre"==o.whitespace,t=!!o.contentMatch.matchType(o.schema.linebreakReplacement);e&&!t?r=!1:!e&&t&&(r=!0)}!1===r&&Ie(e,t,n,i),Ae(e,e.mapping.slice(i).map(n,1),o,void 0,null===r);let a=e.mapping.slice(i),c=a.map(n,1),d=a.map(n+t.nodeSize,1);return e.step(new Ne(c,d,c+1,d-1,new p(s.from(o.create(l,null,t.marks)),0,0),1,!0)),!0===r&&$e(e,t,n,i),!1}}))}(this,e,t,n,o),this}setNodeMarkup(e,t,n=null,o){return function(e,t,n,o,r){let i=e.doc.nodeAt(t);if(!i)throw new RangeError("No node at given position");n||(n=i.type);let l=n.create(o,null,r||i.marks);if(i.isLeaf)return e.replaceWith(t,t+i.nodeSize,l);if(!n.validContent(i.content))throw new RangeError("Invalid content for node type "+n.name);e.step(new Ne(t,t+i.nodeSize,t+1,t+i.nodeSize-1,new p(s.from(l),0,0),1,!0))}(this,e,t,n,o),this}setNodeAttribute(e,t,n){return this.step(new Ge(e,t,n)),this}setDocAttribute(e,t){return this.step(new Qe(e,t)),this}addNodeMark(e,t){return this.step(new Se(e,t)),this}removeNodeMark(e,t){let n=this.doc.nodeAt(e);if(!n)throw new RangeError("No node at position "+e);if(t instanceof d)t.isInSet(n.marks)&&this.step(new Ce(e,t));else{let o,r=n.marks,i=[];for(;o=t.isInSet(r);)i.push(new Ce(e,o)),r=o.removeFromSet(r);for(let e=i.length-1;e>=0;e--)this.step(i[e])}return this}split(e,t=1,n){return function(e,t,n=1,o){let r=e.doc.resolve(t),i=s.empty,l=s.empty;for(let e=r.depth,t=r.depth-n,a=n-1;e>t;e--,a--){i=s.from(r.node(e).copy(i));let t=o&&o[a];l=s.from(t?t.type.create(t.attrs,l):r.node(e).copy(l))}e.step(new Me(t,t,new p(i.append(l),n,n),!0))}(this,e,t,n),this}addMark(e,t,n){return function(e,t,n,o){let r,i,s=[],l=[];e.doc.nodesBetween(t,n,((e,a,c)=>{if(!e.isInline)return;let d=e.marks;if(!o.isInSet(d)&&c.type.allowsMarkType(o.type)){let c=Math.max(a,t),h=Math.min(a+e.nodeSize,n),p=o.addToSet(d);for(let e=0;e<d.length;e++)d[e].isInSet(p)||(r&&r.to==c&&r.mark.eq(d[e])?r.to=h:s.push(r=new xe(c,h,d[e])));i&&i.to==c?i.to=h:l.push(i=new ke(c,h,o))}})),s.forEach((t=>e.step(t))),l.forEach((t=>e.step(t)))}(this,e,t,n),this}removeMark(e,t,n){return function(e,t,n,o){let r=[],i=0;e.doc.nodesBetween(t,n,((e,s)=>{if(!e.isInline)return;i++;let l=null;if(o instanceof X){let t,n=e.marks;for(;t=o.isInSet(n);)(l||(l=[])).push(t),n=t.removeFromSet(n)}else o?o.isInSet(e.marks)&&(l=[o]):l=e.marks;if(l&&l.length){let o=Math.min(s+e.nodeSize,n);for(let e=0;e<l.length;e++){let n,a=l[e];for(let e=0;e<r.length;e++){let t=r[e];t.step==i-1&&a.eq(r[e].style)&&(n=t)}n?(n.to=o,n.step=i):r.push({style:a,from:Math.max(s,t),to:o,step:i})}}})),r.forEach((t=>e.step(new xe(t.from,t.to,t.style))))}(this,e,t,n),this}clearIncompatible(e,t,n){return Ae(this,e,t,n),this}}const tt=Object.create(null);class nt{constructor(e,t,n){this.$anchor=e,this.$head=t,this.ranges=n||[new ot(e.min(t),e.max(t))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let t=0;t<e.length;t++)if(e[t].$from.pos!=e[t].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,t=p.empty){let n=t.content.lastChild,o=null;for(let e=0;e<t.openEnd;e++)o=n,n=n.lastChild;let r=e.steps.length,i=this.ranges;for(let s=0;s<i.length;s++){let{$from:l,$to:a}=i[s],c=e.mapping.slice(r);e.replaceRange(c.map(l.pos),c.map(a.pos),s?p.empty:t),0==s&&ut(e,r,(n?n.isInline:o&&o.isTextblock)?-1:1)}}replaceWith(e,t){let n=e.steps.length,o=this.ranges;for(let r=0;r<o.length;r++){let{$from:i,$to:s}=o[r],l=e.mapping.slice(n),a=l.map(i.pos),c=l.map(s.pos);r?e.deleteRange(a,c):(e.replaceRangeWith(a,c,t),ut(e,n,t.isInline?-1:1))}}static findFrom(e,t,n=!1){let o=e.parent.inlineContent?new st(e):pt(e.node(0),e.parent,e.pos,e.index(),t,n);if(o)return o;for(let o=e.depth-1;o>=0;o--){let r=t<0?pt(e.node(0),e.node(o),e.before(o+1),e.index(o),t,n):pt(e.node(0),e.node(o),e.after(o+1),e.index(o)+1,t,n);if(r)return r}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new dt(e.node(0))}static atStart(e){return pt(e,e,0,0,1)||new dt(e)}static atEnd(e){return pt(e,e,e.content.size,e.childCount,-1)||new dt(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let n=tt[t.type];if(!n)throw new RangeError(`No selection type ${t.type} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in tt)throw new RangeError("Duplicate use of selection JSON ID "+e);return tt[e]=t,t.prototype.jsonID=e,t}getBookmark(){return st.between(this.$anchor,this.$head).getBookmark()}}nt.prototype.visible=!0;class ot{constructor(e,t){this.$from=e,this.$to=t}}let rt=!1;function it(e){rt||e.parent.inlineContent||(rt=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+e.parent.type.name+")"))}class st extends nt{constructor(e,t=e){it(e),it(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let n=e.resolve(t.map(this.head));if(!n.parent.inlineContent)return nt.near(n);let o=e.resolve(t.map(this.anchor));return new st(o.parent.inlineContent?o:n,n)}replace(e,t=p.empty){if(super.replace(e,t),t==p.empty){let t=this.$from.marksAcross(this.$to);t&&e.ensureMarks(t)}}eq(e){return e instanceof st&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new lt(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if("number"!=typeof t.anchor||"number"!=typeof t.head)throw new RangeError("Invalid input for TextSelection.fromJSON");return new st(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,n=t){let o=e.resolve(t);return new this(o,n==t?o:e.resolve(n))}static between(e,t,n){let o=e.pos-t.pos;if(n&&!o||(n=o>=0?1:-1),!t.parent.inlineContent){let e=nt.findFrom(t,n,!0)||nt.findFrom(t,-n,!0);if(!e)return nt.near(t,n);t=e.$head}return e.parent.inlineContent||(0==o||(e=(nt.findFrom(e,-n,!0)||nt.findFrom(e,n,!0)).$anchor).pos<t.pos!=o<0)&&(e=t),new st(e,t)}}nt.jsonID("text",st);class lt{constructor(e,t){this.anchor=e,this.head=t}map(e){return new lt(e.map(this.anchor),e.map(this.head))}resolve(e){return st.between(e.resolve(this.anchor),e.resolve(this.head))}}class at extends nt{constructor(e){let t=e.nodeAfter,n=e.node(0).resolve(e.pos+t.nodeSize);super(e,n),this.node=t}map(e,t){let{deleted:n,pos:o}=t.mapResult(this.anchor),r=e.resolve(o);return n?nt.near(r):new at(r)}content(){return new p(s.from(this.node),0,0)}eq(e){return e instanceof at&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new ct(this.anchor)}static fromJSON(e,t){if("number"!=typeof t.anchor)throw new RangeError("Invalid input for NodeSelection.fromJSON");return new at(e.resolve(t.anchor))}static create(e,t){return new at(e.resolve(t))}static isSelectable(e){return!e.isText&&!1!==e.type.spec.selectable}}at.prototype.visible=!1,nt.jsonID("node",at);class ct{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:n}=e.mapResult(this.anchor);return t?new lt(n,n):new ct(n)}resolve(e){let t=e.resolve(this.anchor),n=t.nodeAfter;return n&&at.isSelectable(n)?new at(t):nt.near(t)}}class dt extends nt{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=p.empty){if(t==p.empty){e.delete(0,e.doc.content.size);let t=nt.atStart(e.doc);t.eq(e.selection)||e.setSelection(t)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new dt(e)}map(e){return new dt(e)}eq(e){return e instanceof dt}getBookmark(){return ht}}nt.jsonID("all",dt);const ht={map(){return this},resolve:e=>new dt(e)};function pt(e,t,n,o,r,i=!1){if(t.inlineContent)return st.create(e,n);for(let s=o-(r>0?0:1);r>0?s<t.childCount:s>=0;s+=r){let o=t.child(s);if(o.isAtom){if(!i&&at.isSelectable(o))return at.create(e,n-(r<0?o.nodeSize:0))}else{let t=pt(e,o,n+r,r<0?o.childCount:0,r,i);if(t)return t}n+=o.nodeSize*r}return null}function ut(e,t,n){let o=e.steps.length-1;if(o<t)return;let r,i=e.steps[o];(i instanceof Me||i instanceof Ne)&&(e.mapping.maps[o].forEach(((e,t,n,o)=>{null==r&&(r=o)})),e.setSelection(nt.near(e.doc.resolve(r),n)))}class ft extends et{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(e){if(e.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=-3&this.updated|1,this.storedMarks=null,this}get selectionSet(){return(1&this.updated)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=2,this}ensureMarks(e){return d.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(2&this.updated)>0}addStep(e,t){super.addStep(e,t),this.updated=-3&this.updated,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let n=this.selection;return t&&(e=e.mark(this.storedMarks||(n.empty?n.$from.marks():n.$from.marksAcross(n.$to)||d.none))),n.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,n){let o=this.doc.type.schema;if(null==t)return e?this.replaceSelectionWith(o.text(e),!0):this.deleteSelection();{if(null==n&&(n=t),n=null==n?t:n,!e)return this.deleteRange(t,n);let r=this.storedMarks;if(!r){let e=this.doc.resolve(t);r=n==t?e.marks():e.marksAcross(this.doc.resolve(n))}return this.replaceRangeWith(t,n,o.text(e,r)),this.selection.empty||this.setSelection(nt.near(this.selection.$to)),this}}setMeta(e,t){return this.meta["string"==typeof e?e:e.key]=t,this}getMeta(e){return this.meta["string"==typeof e?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=4,this}get scrolledIntoView(){return(4&this.updated)>0}}function mt(e,t){return t&&e?e.bind(t):e}class gt{constructor(e,t,n){this.name=e,this.init=mt(t.init,n),this.apply=mt(t.apply,n)}}const yt=[new gt("doc",{init:e=>e.doc||e.schema.topNodeType.createAndFill(),apply:e=>e.doc}),new gt("selection",{init:(e,t)=>e.selection||nt.atStart(t.doc),apply:e=>e.selection}),new gt("storedMarks",{init:e=>e.storedMarks||null,apply:(e,t,n,o)=>o.selection.$cursor?e.storedMarks:null}),new gt("scrollToSelection",{init:()=>0,apply:(e,t)=>e.scrolledIntoView?t+1:t})];class wt{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=yt.slice(),t&&t.forEach((e=>{if(this.pluginsByKey[e.key])throw new RangeError("Adding different instances of a keyed plugin ("+e.key+")");this.plugins.push(e),this.pluginsByKey[e.key]=e,e.spec.state&&this.fields.push(new gt(e.key,e.spec.state,e))}))}}class vt{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,t=-1){for(let n=0;n<this.config.plugins.length;n++)if(n!=t){let t=this.config.plugins[n];if(t.spec.filterTransaction&&!t.spec.filterTransaction.call(t,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let t=[e],n=this.applyInner(e),o=null;for(;;){let r=!1;for(let i=0;i<this.config.plugins.length;i++){let s=this.config.plugins[i];if(s.spec.appendTransaction){let l=o?o[i].n:0,a=o?o[i].state:this,c=l<t.length&&s.spec.appendTransaction.call(s,l?t.slice(l):t,a,n);if(c&&n.filterTransaction(c,i)){if(c.setMeta("appendedTransaction",e),!o){o=[];for(let e=0;e<this.config.plugins.length;e++)o.push(e<i?{state:n,n:t.length}:{state:this,n:0})}t.push(c),n=n.applyInner(c),r=!0}o&&(o[i]={state:n,n:t.length})}}if(!r)return{state:n,transactions:t}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let t=new vt(this.config),n=this.config.fields;for(let o=0;o<n.length;o++){let r=n[o];t[r.name]=r.apply(e,this[r.name],this,t)}return t}get tr(){return new ft(this)}static create(e){let t=new wt(e.doc?e.doc.type.schema:e.schema,e.plugins),n=new vt(t);for(let o=0;o<t.fields.length;o++)n[t.fields[o].name]=t.fields[o].init(e,n);return n}reconfigure(e){let t=new wt(this.schema,e.plugins),n=t.fields,o=new vt(t);for(let t=0;t<n.length;t++){let r=n[t].name;o[r]=this.hasOwnProperty(r)?this[r]:n[t].init(e,o)}return o}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map((e=>e.toJSON()))),e&&"object"==typeof e)for(let n in e){if("doc"==n||"selection"==n)throw new RangeError("The JSON fields `doc` and `selection` are reserved");let o=e[n],r=o.spec.state;r&&r.toJSON&&(t[n]=r.toJSON.call(o,this[o.key]))}return t}static fromJSON(e,t,n){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let o=new wt(e.schema,e.plugins),r=new vt(o);return o.fields.forEach((o=>{if("doc"==o.name)r.doc=D.fromJSON(e.schema,t.doc);else if("selection"==o.name)r.selection=nt.fromJSON(r.doc,t.selection);else if("storedMarks"==o.name)t.storedMarks&&(r.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(n)for(let i in n){let s=n[i],l=s.spec.state;if(s.key==o.name&&l&&l.fromJSON&&Object.prototype.hasOwnProperty.call(t,i))return void(r[o.name]=l.fromJSON.call(s,e,t[i],r))}r[o.name]=o.init(e,r)}})),r}}function bt(e,t,n){for(let o in e){let r=e[o];r instanceof Function?r=r.bind(t):"handleDOMEvents"==o&&(r=bt(r,t,{})),n[o]=r}return n}class kt{constructor(e){this.spec=e,this.props={},e.props&&bt(e.props,this,this.props),this.key=e.key?e.key.key:St("plugin")}getState(e){return e[this.key]}}const xt=Object.create(null);function St(e){return e in xt?e+"$"+ ++xt[e]:(xt[e]=0,e+"$")}class Ct{constructor(e="key"){this.key=St(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const Mt="k-parent-node",Nt="k-colgroup-data",Ot="k-resizable-node",At="k-editor-resize-handle",Tt="data-dir-table-resize",Dt="data-dir-image-resize";var Et=function(){return"undefined"!=typeof window},Rt={wp:/(Windows Phone(?: OS)?)\s(\d+)\.(\d+(\.\d+)?)/,fire:/(Silk)\/(\d+)\.(\d+(\.\d+)?)/,android:/(Android|Android.*(?:Opera|Firefox).*?\/)\s*(\d+)(\.(\d+(\.\d+)?))?/,iphone:/(iPhone|iPod).*OS\s+(\d+)[\._]([\d\._]+)/,ipad:/(iPad).*OS\s+(\d+)[\._]([\d_]+)/,meego:/(MeeGo).+NokiaBrowser\/(\d+)\.([\d\._]+)/,webos:/(webOS)\/(\d+)\.(\d+(\.\d+)?)/,blackberry:/(BlackBerry|BB10).*?Version\/(\d+)\.(\d+(\.\d+)?)/,playbook:/(PlayBook).*?Tablet\s*OS\s*(\d+)\.(\d+(\.\d+)?)/,windows:/(MSIE)\s+(\d+)\.(\d+(\.\d+)?)/,tizen:/(tizen).*?Version\/(\d+)\.(\d+(\.\d+)?)/i,sailfish:/(sailfish).*rv:(\d+)\.(\d+(\.\d+)?).*firefox/i,ffos:/(Mobile).*rv:(\d+)\.(\d+(\.\d+)?).*Firefox/},$t={ios:/^i(phone|pad|pod)$/i,android:/^android|fire$/i,blackberry:/^blackberry|playbook/i,windows:/windows/,wp:/wp/,flat:/sailfish|ffos|tizen/i,meego:/meego/},It={edge:/(edge)[ \/]([\w.]+)/i,webkit:/(chrome)[ \/]([\w.]+)/i,safari:/(webkit)[ \/]([\w.]+)/i,opera:/(opera)(?:.*version|)[ \/]([\w.]+)/i,msie:/(msie\s|trident.*? rv:)([\w.]+)/i,mozilla:/(mozilla)(?:.*? rv:([\w.]+)|)/i},zt={omini:/Opera\sMini/i,omobile:/Opera\sMobi/i,firefox:/Firefox|Fennec/i,mobilesafari:/version\/.*safari/i,ie:/MSIE|Windows\sPhone/i,chrome:/chrome|crios/i,webkit:/webkit/i},Bt=function(e,t,n){for(var o in t)if(t.hasOwnProperty(o)&&t[o].test(e))return o;return void 0!==n?n:e},Pt=Et()&&window.navigator?window.navigator.userAgent:null,Vt=Pt?function(e){var t=null,n=[];for(var o in It)if(It.hasOwnProperty(o)&&(n=e.match(It[o]))){(t={})[o]=!0,t[n[1].toLowerCase().split(" ")[0].split("/")[0]]=!0,t.version=parseInt(document.documentMode||n[2],10);break}return t}(Pt):null,Ft=(Pt&&function(e){var t,n=[];for(var o in Rt)if(Rt.hasOwnProperty(o)){if(!(n=e.match(Rt[o])))continue;if("windows"===o&&"plugins"in window.navigator)return null;var r={};return r.device=o,r.browser=Bt(e,zt,"default"),r.name=Bt(o,$t),r[r.name]=!0,r.majorVersion=n[2],r.minorVersion=n[3]?n[3].replace("_","."):".0",t=r.minorVersion.replace(".","").substr(0,2),r.flatVersion=r.majorVersion+t+new Array(3-(t.length<3?t.length:2)).join("0"),r.cordova=void 0!==typeof window.PhoneGap||void 0!==typeof window.cordova,r.appMode=window.navigator.standalone||/file|local|wmapp/.test(window.location.protocol)||r.cordova,r}}(Pt),Et()&&window,Vt&&!Vt.chrome&&window.MSPointerEvent,Vt&&!Vt.chrome&&window.PointerEvent,{});Ft[void 0]=function(e){return e};var Lt=/\/\*[\s\S]*?\*\//g,Ht=/([^\s:;]+?)\s*:\s*((?:(?:url\(\s*(?:(?:[^"')\\]|\\.)*|"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*')\s*\)|"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'|[^;"'])*?)\s*)(?=;|$)/gi,_t=/&quot;|&#34;|&#x22;/gi,Wt=/&apos;|&#39;|&#x27;/gi;const qt=(e,t)=>{const n=t.style,o=t.value,r=t.newValue;if(!e)return{changed:!1,style:null};const i=ln(e),s=Object.keys(i),l=[];for(let e=0;e<s.length;e++){const t=s[e];t.toLowerCase()===n&&o.test(i[t])||l.push(`${t}: ${i[t]}`)}return r&&l.push(`${n}: ${r}`),{style:l.join("; ")+(l.length?";":""),changed:Boolean(r)||l.length!==s.length}},jt=/^.+$/;function Jt(e,t,n){let o;if(new RegExp("[^-]?"+t+":").test(e.style||"")){const{style:r}=qt(e.style||"",{style:t,value:jt,newValue:n});o={...e,style:r}}else o=e.style?{...e,style:e.style.replace(/;$/,"")+"; "+t+": "+n+";"}:{...e,style:t+": "+n+";"};return o}const Kt=(e,t)=>{const n=e.selection.$from;for(let e=n.depth;e>=0;e--){const o=n.index(e);if(n.node(e).canReplaceWith(o,o,t))return!0}return!1},Xt=e=>e instanceof D?e.type.name:e.name,Ut=(e,t=1)=>n=>((e,t=1)=>n=>{const{$from:o}=n;for(let n=o.depth;n>0;n--){const r=o.node(n);if(e(r)&&0==(t-=1))return{depth:n,node:r}}})((t=>Xt(t)===Xt(e)),t)(n);function Yt(e,t){for(let n=e.depth;n>0;n--){const o=e.node(n);if(t(o))return{node:o,depth:n}}return null}const Gt=e=>{const t={};for(const n in e)n&&(e[n]||0===e[n])&&(t[n]=e[n]);return t},Qt=(e,t)=>(n,o)=>{const{selection:r,tr:i}=n;r instanceof at&&r.node.type.name===e.type.name&&e.isLeaf&&!e.isText&&1===e.nodeSize?(i.setNodeMarkup(r.from,null,{...Gt(r.node.attrs),...Gt(e.attrs)}),i.setSelection(at.create(i.doc,r.from))):i.replaceSelectionWith(e),t&&i.scrollIntoView(),o(i)},Zt=e=>{const t=e.selection;if(t instanceof st||t instanceof dt){const e=t.content().content;return e.textBetween(0,e.size)}return""},en=e=>{if(e.selection instanceof at)return e.selection.node},tn=e=>{let t="",n=!1;const{selection:o,doc:r}=e,{$from:i,$to:s,from:l,to:a}=o;return i.sameParent(s)&&(r.nodesBetween(l,a,(e=>{n=n||e.isLeaf&&!e.isText})),n||(t=Zt(e))),t},nn=e=>e.replace(/<\/(p|li|ul|ol|h[1-6]|table|tr|td|th)>/gi,"</$1>\n").replace(/<(ul|ol)([^>]*)><li/gi,"<$1$2>\n<li").replace(/<br \/>/gi,"<br />\n").replace(/\n$/,""),on={before:/[^ !,?.[\]{}()]+$/i,after:/^[^ !,?.[\]{}()]+/i},rn=(e,t,n)=>{if(!n.applyToWord||!e.selection.empty)return{state:e,dispatch:t};const o=!0===n.applyToWord?on:n.applyToWord;let r=null;const i=e.tr,s=e.selection,l=s.$head.nodeBefore,a=s.$head.nodeAfter;if(l&&"text"===l.type.name&&l.text&&a&&"text"===a.type.name&&a.text){const n=[];s.$head.parent.descendants(((e,t)=>(n.push({node:e,pos:t}),!1)));let l=s.$head.parentOffset;const a=n.findIndex((({node:e,pos:t})=>t<=l&&t+e.nodeSize>=l));let c=n[a].node.text,d=!1;for(let e=a-1;e>=0;e--){const t=n[e];!d&&t&&"text"===t.node.type.name?c=t.node.text+c:(d=!0,l-=t.node.nodeSize)}for(let e=a+1;e<n.length;e++){const t=n[e];if(!t||"text"!==t.node.type.name)break;c+=t.node.text}const h=c.substring(0,l),p=c.substring(l),u=o.before.exec(h),f=o.after.exec(p);if(u&&f){const n=u[0].length,o=f[0].length,l=r=s.from;return i.setSelection(st.create(e.doc,l-n,l+o)),{state:{tr:i,selection:i.selection,doc:i.doc,storedMarks:null,schema:i.doc.type.schema},dispatch:e=>{e.setSelection(st.create(e.doc,r)),t(e)}}}}return{state:e,dispatch:t}},sn=(e,t)=>(n,o)=>{const{state:r,dispatch:i}=rn(n,o,t);return e(t)(r,i)},ln=e=>function(e){for(var t,n,o={},r=(e||"").replace(Lt,"").replace(_t,'"').replace(Wt,"'"),i=Ht.exec(r);null!==i;)t=i[1].trim(),n=i[2].trim(),o[t]=n,i=Ht.exec(r);return o}(e),an=(e,t,n)=>{const o=ln(e);o[t]=n;const r=Object.keys(o).map((e=>o[e]?`${e}: ${o[e]}`:null)).filter(Boolean).join("; ");return r?r+";":null},cn=(e,t)=>{const n=ln(t);for(const t in n)t&&void 0!==e.style[t]&&(e.style[t]=n[t])},dn=(e,t,n)=>{const o=e.getAttribute(t);void 0!==n&&n!==o?"style"===t?(e.removeAttribute(t),cn(e,n)):e.setAttribute(t,n):void 0===n&&e.removeAttribute(t)};class hn{static renderSpec(e,t,n=null){if("string"==typeof t)return{dom:e.createTextNode(t)};if(null!=t.nodeType)return{dom:t};if(t.dom&&null!=t.dom.nodeType)return t;let o,r=t[0],i=r.indexOf(" ");i>0&&(n=r.slice(0,i),r=r.slice(i+1));const s=n?e.createElementNS(n,r):e.createElement(r),l=t[1];let a=1;if(l&&"object"==typeof l&&null==l.nodeType&&!Array.isArray(l)){a=2;for(const e in l)null!=l[e]&&(i=e.indexOf(" "),i>0?s.setAttributeNS(e.slice(0,i),e.slice(i+1),l[e]):dn(s,e,l[e]))}for(let r=a;r<t.length;r++){const i=t[r];if(0===i){if(r<t.length-1||r>a)throw new RangeError("Content hole must be the only child of its parent node");return{dom:s,contentDOM:s}}{const{dom:t,contentDOM:r}=hn.renderSpec(e,i,n);if(s.appendChild(t),r){if(o)throw new RangeError("Multiple content holes");o=r}}}return{dom:s,contentDOM:o}}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new hn(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){const t=pn(e.nodes);return t.text||(t.text=e=>e.text),t}static marksFromSchema(e){return pn(e.marks)}constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},n){n||(n=un(t).createDocumentFragment());let o=n;const r=[];return e.forEach((e=>{if(r.length||e.marks.length){let n=0,i=0;for(;n<r.length&&i<e.marks.length;){const t=e.marks[i];if(this.marks[t.type.name]){if(!t.eq(r[n][0])||!1===t.type.spec.spanning)break;n++,i++}else i++}for(;n<r.length;)o=r.pop()[1];for(;i<e.marks.length;){const n=e.marks[i++],s=this.serializeMark(n,e.isInline,t);s&&(r.push([n,o]),o.appendChild(s.dom),o=s.contentDOM||s.dom)}}o.appendChild(this.serializeNodeInner(e,t))})),n}serializeNode(e,t={}){let n=this.serializeNodeInner(e,t);for(let o=e.marks.length-1;o>=0;o--){const r=this.serializeMark(e.marks[o],e.isInline,t);r&&((r.contentDOM||r.dom).appendChild(n),n=r.dom)}return n}serializeMark(e,t,n={}){const o=this.marks[e.type.name];return o&&hn.renderSpec(un(n),o(e,t))}serializeNodeInner(e,t){const{dom:n,contentDOM:o}=hn.renderSpec(un(t),this.nodes[e.type.name](e));if(o){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,o)}return n}}function pn(e){const t={};for(const n in e)if(e[n]){const o=e[n].spec.toDOM;o&&(t[n]=o)}return t}function un(e){return e.document||window.document}const fn=["div","ol","ul","li","table","tbody","thead","tfoot","caption","td","th","p","tr","col","colgroup","article","main","nav","header","footer","aside","section"],mn=(e,t)=>{const n=(e.ownerDocument||document).createElement(t);Array.from(e.rows).filter((e=>e.getAttribute(Mt)===t)).forEach((e=>{e.removeAttribute(Mt),n.appendChild(e)})),n.children.length&&e.appendChild(n)},gn=(e,t)=>{const n=t.toUpperCase();e.filter((e=>e.nodeName===n)).forEach((e=>{Array.from(e.children).forEach((n=>{n.setAttribute(Mt,t),e.parentNode&&e.parentNode.insertBefore(n,e)})),e.remove()}))},yn=(e,t=fn)=>{const n=t.join("|");return e.replace(new RegExp("\\s*(<(?:"+n+")(?:\\s[^>]*?)?>)","g"),"$1").replace(new RegExp("(<\\/(?:"+n+")(?:\\s[^>]*?)?>)\\s*","g"),"$1")},wn="data-style",vn=" "+wn+"=",bn=/<[^>]+>/gm,kn=/\sstyle=/gm,xn=e=>e.replace(kn,vn),Sn=e=>{const t=document.createElement("template");var n;return t.innerHTML=(e=>e.replace(bn,xn))(e),n=t.content,Array.from(n.querySelectorAll("["+wn+"]")).forEach((e=>{const t=e.getAttribute(wn);e.removeAttribute(wn),cn(e,t)})),t.content.cloneNode(!0)},Cn=e=>Array.from(e.childNodes).reduce(((e,t)=>e+(t.outerHTML||t.textContent||"")),""),Mn=e=>{const t=hn.fromSchema(e.type.schema).serializeFragment(e.content);return(e=>{Array.from(e.querySelectorAll("table")).forEach((e=>{mn(e,"thead"),mn(e,"tbody"),mn(e,"tfoot");const t=Array.from(e.children).find((e=>0===e.children.length));t&&t.remove();const n=e.parentNode instanceof HTMLDivElement?e.parentNode:null;if(n&&n.matches("div[table]")){e.style.marginLeft=n.style.marginLeft,e.style.marginRight=n.style.marginRight;const t=Array.from(n.children).find((e=>e.matches("div[caption]")));if(t&&"<img>"!==t.innerHTML){const n=e.createCaption();for(t.id&&(n.id=t.id),t.className&&(n.className=t.className),Array.from(t.style).forEach((e=>{n.style[e]=t.style[e]}));t.firstChild;)n.appendChild(t.firstChild)}n.style.width&&!e.style.width&&(e.style.width=n.style.width),n.parentNode.insertBefore(e,n),n.parentNode.removeChild(n)}}))})(t),t},Nn=(e,t,n)=>G.fromSchema(t).parse(e,n),On=(e,t,n)=>{const o=Sn(e);var r;return r=o,Array.from(r.querySelectorAll("table")).forEach((e=>{const t=Array.from(e.children);t.some((e=>"THEAD"===e.nodeName||"TFOOT"===e.nodeName))&&(gn(t,"thead"),gn(t,"tbody"),gn(t,"tfoot"));const n=t.find((e=>"COLGROUP"===e.nodeName));if(n&&(e.setAttribute(Nt,n.outerHTML),n.remove()),e.caption||e.style.marginLeft||e.style.marginRight){const t=document.createElement("div");if(t.setAttribute("table",""),t.style.display="table",t.style.marginLeft=e.style.marginLeft,t.style.marginRight=e.style.marginRight,e.caption){const n=document.createElement("div");for(n.setAttribute("caption",""),e.caption.id&&(n.id=e.caption.id),e.caption.className&&(n.className=e.caption.className),Array.from(e.caption.style).forEach((t=>{n.style[t]=e.caption.style[t]}));e.caption.firstChild;)n.appendChild(e.caption.firstChild);e.removeChild(e.caption),t.appendChild(n)}e.parentNode.insertBefore(t,e),t.appendChild(e),/%/.test(e.style.width)&&(t.style.width=e.style.width,e.style.width="")}})),Nn(o,t,n)},An=e=>{const t=Mn(e.doc);return Cn(t)},Tn=(e,t="setHTML",n={preserveWhitespace:"full"})=>(o,r)=>r(o.tr.setSelection(new dt(o.doc)).replaceSelectionWith(On(e,o.schema,n)).setMeta("commandName",t)),Dn=(e,t,n,o)=>{const r=s.from(On(e,n,o)),i=s.from(On(t,n,o));return r.eq(i)},En=e=>{const t=Sn(e);return Rn(t),Cn(t)},Rn=e=>{var t;const n=e.ownerDocument.createNodeIterator(e,NodeFilter.SHOW_COMMENT);let o=n.nextNode();for(;o;)null===(t=o.parentNode)||void 0===t||t.removeChild(o),o=n.nextNode()};class $n{constructor(e){this.extractBefore=e=>this._traverseSide({edge:e,next:function(e){return e.previousSibling},insert:function(e,t){e.insertBefore(t,e.firstChild)}}),this.extractAfter=e=>this._traverseSide({edge:e,next:function(e){return e.nextSibling},insert:function(e,t){e.appendChild(t)}}),this._traverseSide=e=>{const t=this.top,n=t.ownerDocument.createDocumentFragment();let o=e.edge;do{const r=o.parentNode;for(o=e.next(o);o;){const t=e.next(o);e.insert(n,o),o=t}if(t===r||t.contains(r)){const t=r.cloneNode(!1);t.innerHTML="",t.appendChild(n),e.insert(n,t)}o=r}while(o&&o!==t);return n},this.top=e}}const In=e=>e.querySelector("span span"),zn=e=>1===e.childNodes.length&&"SPAN"===e.firstChild.nodeName&&0===e.firstChild.childNodes.length,Bn=e=>{const t=Sn(e);let n=In(t);for(;n;){const e=n.parentNode.closest("span");if(e){const t=new $n(e),o=t.extractAfter(n),r=t.extractBefore(n);for(let t=0;t<n.style.length;t++){const o=n.style.item(t);e.style[o]=n.style.getPropertyValue(o)}n.removeAttribute("style"),n.classList.length&&Array.from(n.classList).forEach((t=>{e.classList.contains(t)||e.classList.add(t)})),n.removeAttribute("class");for(let t=0;t<n.attributes.length;t++){const o=n.attributes.item(t);o&&null!==o.nodeValue&&e.setAttribute(o.nodeName,o.nodeValue)}for(;n.firstChild&&n.parentNode;)n.parentNode.insertBefore(n.firstChild,n);n.parentNode&&n.parentNode.removeChild(n),e.parentNode&&(zn(r)||e.parentNode.insertBefore(r,e),zn(o)||e.parentNode.insertBefore(o,e.nextSibling))}n=In(t)}return Cn(t)},Pn=(e,t,n)=>{const o=o=>{const r=t[o],i=r.$from,s=r.$to;let l=0===i.depth&&e.type.allowsMarkType(n);if(e.nodesBetween(i.pos,s.pos,(e=>{if(l)return!1;l=e.inlineContent&&e.type.allowsMarkType(n)})),l)return{v:!0}};for(let e=0;e<t.length;e++){const t=o(e);if(t)return t.v}return!1},Vn=(e,t,n)=>(o,r)=>{const{empty:i,$cursor:s,ranges:l}=o.selection;if(i&&!s||!Pn(o.doc,l,e))return!1;if(r)if(s)e.isInSet(o.storedMarks||s.marks())?r(n.removeStoredMark(e)):r(n.addStoredMark(e.create(t)));else{let i=!1;for(let t=0;!i&&t<l.length;t++){const{$from:n,$to:r}=l[t];i=o.doc.rangeHasMark(n.pos,r.pos,e)}for(let o=0;o<l.length;o++){const{$from:r,$to:s}=l[o];i?n.removeMark(r.pos,s.pos,e):n.addMark(r.pos,s.pos,e.create(t))}r(n.scrollIntoView())}return!0},Fn=(e,t,n,o)=>{void 0===o&&(o=null);const r=[];let i=0;return e.doc.nodesBetween(t,n,((e,s)=>{if(!e.isInline)return;i++;let l=null;if(o instanceof X){const t=o.isInSet(e.marks);t&&(l=[t])}else o?o.isInSet(e.marks)&&(l=[o]):l=e.marks;if(l&&l.length){const o=Math.min(s+e.nodeSize,n);for(let e=0;e<l.length;e++){const n=l[e];let a;for(let e=0;e<r.length;e++){const t=r[e];t.step===i-1&&n.eq(t.style)&&(a=t)}a?(a.to=o,a.step=i):r.push({style:n,from:Math.max(s,t),to:o,step:i})}}})),r.forEach((t=>e.step(new xe(t.from,t.to,t.style)))),e},Ln=({except:e=[]}={})=>(t,n)=>{const o=t.tr;var r;Hn(o,{except:(r=e,r instanceof Array?r:[r])}),o.docChanged&&n(o)},Hn=(e,{except:t})=>{const{doc:n,selection:o}=e,r=n.type.schema,{empty:i,ranges:s}=o,l=(t||[]).map((e=>e.name));if(!i){const t=Object.keys(r.marks).map((e=>r.marks[e])).filter((e=>-1===l.indexOf(e.name)));s.forEach((({$from:n,$to:o})=>{t.forEach((t=>e.removeMark(n.pos,o.pos,t)))}))}},_n=(e,t)=>{const n=e.schema.marks,o=(t.altMarks||[]).filter((e=>n[e])),r=t.altStyle,{from:i,$from:s,to:l,empty:a}=e.selection,c=n[t.mark],d=e.doc;let h,p=!1;return a?(h=e.storedMarks||s.marks(),p=c&&c.isInSet(h)||o.some((e=>n[e].isInSet(h)))):p=c&&d.rangeHasMark(i,l,c)||o.some((e=>d.rangeHasMark(i,l,n[e]))),!p&&r&&n.style?qn(e,n.style).some((e=>null!==Wn(e,r))):Boolean(p)},Wn=(e,t)=>{const n=e&&e.attrs.style||"",o=ln(n),r=Object.keys(o);for(let e=0;e<r.length;e++){const n=r[e];if(n.toLowerCase()===t.name&&t.value.test(o[n]))return o[n]}return null},qn=(e,t)=>{const{from:n,$from:o,to:r,empty:i}=e.selection,s=[];return i?s.push(t.isInSet(e.storedMarks||o.marks())):e.doc.nodesBetween(n,r,(e=>{e.isInline&&s.push(t.isInSet(e.marks))})),s},jn=(e,t)=>{const n=qn(e,t),o=n.filter((e=>Boolean(e)));return n.length===o.length?n[0]:void 0},Jn=(e,t)=>{const n=qn(e,t),o=n.filter((e=>Boolean(e)));return{hasNodesWithoutMarks:n.length!==o.length,marks:o}},Kn=(e,t)=>{const n=e.find((e=>"style"===e.type.name)),o=n&&n.attrs.style;return qt(o,t)},Xn=(e,t,n,o,r)=>{const i=r.create({style:o.style}),s=[],l=[];let a=null,c=null;return e.doc.nodesBetween(t,n,((e,d,h)=>{if(!e.isInline)return;const p=e.marks;if(!i.isInSet(p)&&h.type.allowsMarkType(i.type)){const i=Math.max(d,t),h=Math.min(d+e.nodeSize,n),u=Kn(p,o);if(u.changed||o.newValue){const e=u.changed?{style:u.style||null}:{style:`${o.style}: ${o.newValue};`},t=r.isInSet(p)?p.find((e=>"style"===e.type.name)):null,n=t?{...t.attrs,...e}:e,d=r.create(n),f=d.addToSet(p);for(let e=0;e<p.length;e++)p[e].isInSet(f)||(a&&a.to===i&&a.mark.eq(p[e])?a.to=h:(a=new xe(i,h,p[e]),s.push(a)));const m=c&&c.to===i,g=m&&d.attrs.style===c.mark.attrs.style;m&&g?c.to=h:Object.keys(n).some((e=>null!==n[e]))&&(c=new ke(i,h,d),l.push(c))}}})),s.forEach((t=>e.step(t))),l.forEach((t=>e.step(t))),s.length+l.length>0},Un=(e,t)=>{const n=e.schema.marks.style;return(n?qn(e,n):[]).map((e=>Wn(e,t))).filter((e=>null!==e))},Yn=(e,t)=>function(n,o,r){const{empty:i,ranges:s}=n.selection,l=n.selection instanceof st&&n.selection.$cursor;if(i&&!l||!Pn(n.doc,s,e))return!1;let a=!1;if(o){const i=r||n.tr;if(l){const r=n.storedMarks||l.marks();if(e.isInSet(r)){const n=Kn(r,t),s=r.find((e=>"style"===e.type.name)),l={...s?s.attrs:{},style:n.style||null};if(((e,t)=>{const n=Object.keys(e),o=Object.keys(t);return n.length===o.length&&n.every((n=>e[n]===t[n]))})(s.attrs,l))return!1;o(i.removeStoredMark(e)),Object.keys(l).some((e=>null!==l[e]))&&o(i.addStoredMark(e.create(l))),a=!0}}else{for(let n=0;n<s.length;n++){const{$from:o,$to:r}=s[n];a=Xn(i,o.pos,r.pos,t,e)||a}a&&(i.scrollIntoView(),o(i))}}return a},Gn=(e,t,n)=>(o,r)=>{const i=o.schema.marks,{altStyle:s,altMarks:l=[],mark:a}=e,c=t||o.tr;let d=!1,h=!1;const p=()=>h=!0;s&&i.style&&(d=Yn(i.style,{style:s.name,value:s.value})(o,p,c));const u=[a,...l].filter((e=>i[e])).map((e=>_n(o,{mark:e})&&i[e])).filter((e=>e));return u.length?((e,t,n,o)=>{const{$cursor:r,ranges:i}=t.selection;if(o=o||t.tr,r)e.forEach((e=>{e.isInSet(t.storedMarks||r.marks())&&n(o.removeStoredMark(e))}));else{for(let t=0;t<i.length;t++){const{$from:n,$to:r}=i[t];e.forEach((e=>{Fn(o,n.pos,r.pos,e)}))}n(o.scrollIntoView())}})(u,o,p,c):d||Vn(i[a],n,c)(o,p),h&&r(c),h},Qn=(e,t)=>(n,o)=>{const r=n.schema.marks.style,i={style:e.style,value:/^.+$/,newValue:e.value},s=n.tr;t&&s.setMeta("commandName",t),s.setMeta("args",e);const{empty:l,$cursor:a,ranges:c}=n.selection;if(l&&!a||!r||!Pn(n.doc,c,r))return!1;if(a){const e=n.storedMarks||a.marks(),t=r.isInSet(e)?e.find((e=>"style"===e.type.name)):null,l={style:null};if(t&&t.attrs.style){const e=qt(t.attrs.style,i);e.changed&&e.style&&(l.style=e.style)}else i.newValue&&(l.style=`${i.style}: ${i.newValue};`);const c=t?{...t.attrs,...l}:l;return Object.keys(c).some((e=>null!==c[e]))?o(s.addStoredMark(r.create(c))):o(s.removeStoredMark(r)),!0}return Yn(r,i)(n,o,s)},Zn=(e,t)=>(n,o)=>{const{$cursor:r}=n.selection;if(r){const i=r.parent,s=r.index(),l=n.schema.marks[e.mark],a=i.child(s).marks.find((e=>e.type===l)),c=i.childCount;let d,h,p=r.pos-r.textOffset,u=i.child(s).nodeSize;for(d=s-1;d>=0&&a.isInSet(i.child(d).marks);)h=i.child(d).nodeSize,u+=h,p-=h,d-=1;for(d=s+1;d<c&&a.isInSet(i.child(d).marks);)u+=i.child(d).nodeSize,d+=1;o(Fn(t||n.tr,p,p+u,a))}else Gn(e,t)(n,o)},eo=({mark:e,attrs:t},n="link")=>(o,r)=>{const i=o.schema.marks,s=o.tr;n&&(s.setMeta("commandName",n),s.setMeta("args",t));let l=!1;const a=()=>l=!0;if(((e,t)=>{const n=qn(e,t);return 1===n.length&&n[0]?n[0]:null})(o,i[e]))((e,t)=>(n,o)=>{const{$cursor:r,from:i,to:s}=n.selection,l=n.schema.marks[e.mark];if(r){const n=r.parent,i=r.index(),s=n.child(i).marks.find((e=>e.type===l)),a=n.childCount;let c,d,h=r.pos-r.textOffset,p=n.child(i).nodeSize;for(c=i-1;c>=0&&s.isInSet(n.child(c).marks);)d=n.child(c).nodeSize,p+=d,h-=d,c-=1;for(c=i+1;c<a&&s.isInSet(n.child(c).marks);)p+=n.child(c).nodeSize,c+=1;t.removeMark(h,h+p,l),t.addMark(h,h+p,l.create(e.attrs)),o(t)}else t.doc.nodesBetween(i,s,((n,r)=>{n.isInline&&l.isInSet(n.marks)&&(t.removeMark(r,r+n.nodeSize,l),t.addMark(r,r+n.nodeSize,l.create(e.attrs)),o(t))}))})({mark:e,attrs:t},s)(o,a);else{let n=o;_n(o,{mark:e})&&(Zn({mark:e,attrs:t},s)(o,a),n=vt.create({doc:s.doc,selection:s.selection})),l?Vn(i[e],t,s)(n,a):Gn({mark:e},s,t)(n,a)}return l&&r(s),l},to=e=>(t,n)=>{n(t.tr.insertText(e.text,e.from,e.to))},no=e=>(t,n)=>{const{image:o}=t.schema.nodes,r=o.createAndFill(e);Qt(r)(t,(t=>n(t.setMeta("commandName","insertImage").setMeta("args",e))))},oo=(e,t,n,o)=>{if(!n.isTextblock)return!1;const{ranges:r}=e.selection;r.forEach((r=>{const i=e.steps.length,l=r.$from.pos,a=r.$to.pos;e.doc.nodesBetween(l,a,((r,l)=>{if(r.eq(t)&&r.isTextblock&&!r.hasMarkup(n,o)&&((e,t,n)=>{const o=e.resolve(t),r=o.index();return o.parent.canReplaceWith(r,r+1,n)})(e.doc,e.mapping.slice(i).map(l),n)){e.clearIncompatible(e.mapping.slice(i).map(l,1),n);const t=e.mapping.slice(i),a=t.map(l,1),c=t.map(l+r.nodeSize,1),d=new p(s.from(n.create(o,null,r.marks)),0,0);return e.step(new Ne(a,c,a+1,c-1,d,1,!0)),!1}}))}))},ro=(e,t={blocksInSelection:!1})=>{const{doc:n,selection:o}=e,{$from:r,ranges:i}=o,{blocksInSelection:s}=t,l=[],a=o instanceof at?o.node:void 0;return a?a.isBlock?(l.push(a),a.nodesBetween(0,a.content.size,(e=>{e.isBlock&&l.push(e)}))):!s&&r.parent&&r.parent.isBlock&&l.push(r.parent):i.forEach((e=>{const t=e.$from.pos,o=e.$to.pos;n.nodesBetween(t,o,((e,n)=>{e.isBlock&&(!s||n>=t&&n+e.content.size+2<=o)&&l.push(e)}))})),l},io=(e,t)=>(n,o)=>{const r=ro(n),i=n.schema.nodes,s=n.tr;s.setMeta("commandName",t),s.setMeta("args",{value:e}),r.forEach((t=>{if(t.type.isTextblock)if("p"===e)oo(s,t,i.paragraph,t.attrs);else if(/^h[1-6]$/i.test(e)){const n=parseInt(e.substr(1),10);oo(s,t,i.heading,{...t.attrs,level:n})}else"blockquote"===e&&oo(s,t,i.blockquote,t.attrs)}));const l=s.docChanged;return l&&o(s.scrollIntoView()),l},so=(e,t={blocksInSelection:!0})=>{const{doc:n,selection:o}=e,{blocksInSelection:r,blockNodeType:i}=t;ro({doc:n,selection:o},{blocksInSelection:r}).filter((e=>e.isTextblock)).forEach((t=>{const{style:n="",class:o="",...r}=t.attrs||{},s=i||t.type;(n||o||s!==t.type)&&oo(e,t,s,r)}))},lo=e=>{const t=ro(e),n=e.schema.nodes,o=[];return t.forEach((e=>{e.type===n.paragraph?o.push("p"):e.type===n.heading?o.push(`h${e.attrs.level}`):e.type===n.blockquote&&n.blockquote.isTextblock&&o.push("blockquote")})),o},ao=(e,t)=>{let n,o,r=e.attrs.style;return r&&t.forEach((e=>{o={style:e.name,value:/^.+$/,newValue:e.value},n=qt(r,o),r=n.changed?n.style:r})),r=r||t.reduce(((e,t)=>(e&&t.value?e+" ":"")+t.value?`${t.name}: ${t.value};`:""),""),Object.assign({},e.attrs,{style:r||null})},co=(e,t)=>{const{from:n,to:o}=e.selection;let r=!1;return e.doc.nodesBetween(n,o,(e=>(r=r||e.type===t,!r))),r},ho=e=>{const t=lo(e);return 1===new Set(t).size?t[0]:null},po=e=>({tag:ho(e)||""}),uo=(e,t)=>(n,o)=>{const r=ro(n),i=n.tr;i.setMeta("commandName",t),r.forEach((t=>{if(t.type.isTextblock){const n=e.find((e=>e.node===t.type.name));if(n){const e=ao(t,n.style);oo(i,t,t.type,e)}}}));const s=i.docChanged;return s&&o(i.scrollIntoView()),s},fo=(e,t)=>{const n=ro(e);let o=!1;return n.forEach((e=>{if(!o&&e.type.isTextblock&&e.attrs.style){const n=t.find((t=>t.node===e.type.name));n&&(o=n.style.every((t=>!!t.value&&new RegExp(`${t.name}:\\s?${t.value}`,"i").test(e.attrs.style))))}})),o},mo=(e={blocksInSelection:!0})=>(t,n)=>{const o=t.tr,{blocksInSelection:r,blockNodeType:i,exceptMarks:s}=e,l=(s||[t.schema.marks.link]).filter(Boolean);Hn(o,{except:l}),so(o,{blocksInSelection:r,blockNodeType:i});const a=o.docChanged;return a&&n&&n(o),a},go=["ol",0],yo=["ul",0],wo=["li",0],vo={attrs:{order:{default:1,validate:"number"}},parseDOM:[{tag:"ol",getAttrs:e=>({order:e.hasAttribute("start")?+e.getAttribute("start"):1})}],toDOM:e=>1==e.attrs.order?go:["ol",{start:e.attrs.order},0]},bo={parseDOM:[{tag:"ul"}],toDOM:()=>yo},ko={parseDOM:[{tag:"li"}],toDOM:()=>wo,defining:!0};function xo(e,t){let n={};for(let t in e)n[t]=e[t];for(let e in t)n[e]=t[e];return n}function So(e,t,n){return e.append({ordered_list:xo(vo,{content:"list_item+",group:n}),bullet_list:xo(bo,{content:"list_item+",group:n}),list_item:xo(ko,{content:t})})}function Co(e,t=null){return function(n,o){let{$from:r,$to:i}=n.selection,s=r.blockRange(i);if(!s)return!1;let l=o?n.tr:null;return!!Mo(l,s,e,t)&&(o&&o(l.scrollIntoView()),!0)}}function Mo(e,t,n,o=null){let r=!1,i=t,l=t.$from.doc;if(t.depth>=2&&t.$from.node(t.depth-1).type.compatibleContent(n)&&0==t.startIndex){if(0==t.$from.index(t.depth-1))return!1;let e=l.resolve(t.start-2);i=new A(e,e,t.depth),t.endIndex<t.parent.childCount&&(t=new A(t.$from,l.resolve(t.$to.end(t.depth)),t.depth)),r=!0}let a=Ee(i,n,o,t);return!!a&&(e&&function(e,t,n,o,r){let i=s.empty;for(let e=n.length-1;e>=0;e--)i=s.from(n[e].type.create(n[e].attrs,i));e.step(new Ne(t.start-(o?2:0),t.end,t.start,t.end,new p(i,0,0),n.length,!0));let l=0;for(let e=0;e<n.length;e++)n[e].type==r&&(l=e+1);let a=n.length-l,c=t.start+n.length-(o?2:0),d=t.parent;for(let n=t.startIndex,o=t.endIndex,r=!0;n<o;n++,r=!1)!r&&ze(e.doc,c,a)&&(e.split(c,a),c+=2*a),c+=d.child(n).nodeSize}(e,t,a,r,n),!0)}function No(e,t){return function(n,o){let{$from:r,$to:i,node:l}=n.selection;if(l&&l.isBlock||r.depth<2||!r.sameParent(i))return!1;let a=r.node(-1);if(a.type!=e)return!1;if(0==r.parent.content.size&&r.node(-1).childCount==r.indexAfter(-1)){if(3==r.depth||r.node(-3).type!=e||r.index(-2)!=r.node(-2).childCount-1)return!1;if(o){let t=s.empty,i=r.index(-1)?1:r.index(-2)?2:3;for(let e=r.depth-i;e>=r.depth-3;e--)t=s.from(r.node(e).copy(t));let l=r.indexAfter(-1)<r.node(-2).childCount?1:r.indexAfter(-2)<r.node(-3).childCount?2:3;t=t.append(s.from(e.createAndFill()));let a=r.before(r.depth-(i-1)),c=n.tr.replace(a,r.after(-l),new p(t,4-i,0)),d=-1;c.doc.nodesBetween(a,c.doc.content.size,((e,t)=>{if(d>-1)return!1;e.isTextblock&&0==e.content.size&&(d=t+1)})),d>-1&&c.setSelection(nt.near(c.doc.resolve(d))),o(c.scrollIntoView())}return!0}let c=i.pos==r.end()?a.contentMatchAt(0).defaultType:null,d=n.tr.delete(r.pos,i.pos),h=c?[t?{type:e,attrs:t}:null,{type:c}]:void 0;return!!ze(d.doc,r.pos,2,h)&&(o&&o(d.split(r.pos,2,h).scrollIntoView()),!0)}}function Oo(e,t){let n=No(e,t);return(e,t)=>n(e,t&&(n=>{let o=e.storedMarks||e.selection.$to.parentOffset&&e.selection.$from.marks();o&&n.ensureMarks(o),t(n)}))}function Ao(e){return function(t,n){let{$from:o,$to:r}=t.selection,i=o.blockRange(r,(t=>t.childCount>0&&t.firstChild.type==e));return!!i&&(!n||(o.node(i.depth-1).type==e?function(e,t,n,o){let r=e.tr,i=o.end,l=o.$to.end(o.depth);i<l&&(r.step(new Ne(i-1,l,i,l,new p(s.from(n.create(null,o.parent.copy())),1,0),1,!0)),o=new A(r.doc.resolve(o.$from.pos),r.doc.resolve(l),o.depth));const a=De(o);if(null==a)return!1;r.lift(o,a);let c=r.doc.resolve(r.mapping.map(i,-1)-1);return Be(r.doc,c.pos)&&c.nodeBefore.type==c.nodeAfter.type&&r.join(c.pos),t(r.scrollIntoView()),!0}(t,n,e,i):function(e,t,n){let o=e.tr,r=n.parent;for(let e=n.end,t=n.endIndex-1,i=n.startIndex;t>i;t--)e-=r.child(t).nodeSize,o.delete(e-1,e+1);let i=o.doc.resolve(n.start),l=i.nodeAfter;if(o.mapping.map(n.end)!=n.start+i.nodeAfter.nodeSize)return!1;let a=0==n.startIndex,c=n.endIndex==r.childCount,d=i.node(-1),h=i.index(-1);if(!d.canReplace(h+(a?0:1),h+1,l.content.append(c?s.empty:s.from(r))))return!1;let u=i.pos,f=u+l.nodeSize;return o.step(new Ne(u-(a?1:0),f+(c?1:0),u+1,f-1,new p((a?s.empty:s.from(r.copy(s.empty))).append(c?s.empty:s.from(r.copy(s.empty))),a?0:1,c?0:1),a?0:1)),t(o.scrollIntoView()),!0}(t,n,i)))}}function To(e){return function(t,n){let{$from:o,$to:r}=t.selection,i=o.blockRange(r,(t=>t.childCount>0&&t.firstChild.type==e));if(!i)return!1;let l=i.startIndex;if(0==l)return!1;let a=i.parent,c=a.child(l-1);if(c.type!=e)return!1;if(n){let o=c.lastChild&&c.lastChild.type==a.type,r=s.from(o?e.create():null),l=new p(s.from(e.create(null,s.from(a.type.create(null,r)))),o?3:1,0),d=i.start,h=i.end;n(t.tr.step(new Ne(d-(o?3:1),h,d,h,l,1,!0)).scrollIntoView())}return!0}}const Do={orderedList:"ordered_list",bulletList:"bullet_list",listItem:"list_item"},Eo={listType:Do.orderedList,types:{...Do}},Ro={listType:Do.bulletList,types:{...Do}},$o={nodes:[{node:"paragraph",style:"margin-left",rtlStyle:"margin-right",step:30,unit:"px"},{node:"heading",style:"margin-left",rtlStyle:"margin-right",step:30,unit:"px"}],listsTypes:{...Do}},Io={nodes:[{node:"paragraph",style:"margin-left",rtlStyle:"margin-right",step:-30,unit:"px"},{node:"heading",style:"margin-left",rtlStyle:"margin-right",step:-30,unit:"px"}],listsTypes:{...Do}},zo=(e,t)=>!e.selection.empty&&(t&&t(e.tr.deleteSelection().scrollIntoView()),!0);function Bo(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock("backward",e):n.parentOffset>0)?null:n}const Po=(e,t,n)=>{let o=Bo(e,n);if(!o)return!1;let r=Wo(o);if(!r){let n=o.blockRange(),r=n&&De(n);return null!=r&&(t&&t(e.tr.lift(n,r).scrollIntoView()),!0)}let i=r.nodeBefore;if(lr(e,r,t,-1))return!0;if(0==o.parent.content.size&&(Ho(i,"end")||at.isSelectable(i)))for(let n=o.depth;;n--){let s=He(e.doc,o.before(n),o.after(n),p.empty);if(s&&s.slice.size<s.to-s.from){if(t){let n=e.tr.step(s);n.setSelection(Ho(i,"end")?nt.findFrom(n.doc.resolve(n.mapping.map(r.pos,-1)),-1):at.create(n.doc,r.pos-i.nodeSize)),t(n.scrollIntoView())}return!0}if(1==n||o.node(n-1).childCount>1)break}return!(!i.isAtom||r.depth!=o.depth-1||(t&&t(e.tr.delete(r.pos-i.nodeSize,r.pos).scrollIntoView()),0))},Vo=(e,t,n)=>{let o=Bo(e,n);if(!o)return!1;let r=Wo(o);return!!r&&Lo(e,r,t)},Fo=(e,t,n)=>{let o=qo(e,n);if(!o)return!1;let r=Ko(o);return!!r&&Lo(e,r,t)};function Lo(e,t,n){let o=t.nodeBefore,r=t.pos-1;for(;!o.isTextblock;r--){if(o.type.spec.isolating)return!1;let e=o.lastChild;if(!e)return!1;o=e}let i=t.nodeAfter,s=t.pos+1;for(;!i.isTextblock;s++){if(i.type.spec.isolating)return!1;let e=i.firstChild;if(!e)return!1;i=e}let l=He(e.doc,r,s,p.empty);if(!l||l.from!=r||l instanceof Me&&l.slice.size>=s-r)return!1;if(n){let t=e.tr.step(l);t.setSelection(st.create(t.doc,r)),n(t.scrollIntoView())}return!0}function Ho(e,t,n=!1){for(let o=e;o;o="start"==t?o.firstChild:o.lastChild){if(o.isTextblock)return!0;if(n&&1!=o.childCount)return!1}return!1}const _o=(e,t,n)=>{let{$head:o,empty:r}=e.selection,i=o;if(!r)return!1;if(o.parent.isTextblock){if(n?!n.endOfTextblock("backward",e):o.parentOffset>0)return!1;i=Wo(o)}let s=i&&i.nodeBefore;return!(!s||!at.isSelectable(s)||(t&&t(e.tr.setSelection(at.create(e.doc,i.pos-s.nodeSize)).scrollIntoView()),0))};function Wo(e){if(!e.parent.type.spec.isolating)for(let t=e.depth-1;t>=0;t--){if(e.index(t)>0)return e.doc.resolve(e.before(t+1));if(e.node(t).type.spec.isolating)break}return null}function qo(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock("forward",e):n.parentOffset<n.parent.content.size)?null:n}const jo=(e,t,n)=>{let o=qo(e,n);if(!o)return!1;let r=Ko(o);if(!r)return!1;let i=r.nodeAfter;if(lr(e,r,t,1))return!0;if(0==o.parent.content.size&&(Ho(i,"start")||at.isSelectable(i))){let n=He(e.doc,o.before(),o.after(),p.empty);if(n&&n.slice.size<n.to-n.from){if(t){let o=e.tr.step(n);o.setSelection(Ho(i,"start")?nt.findFrom(o.doc.resolve(o.mapping.map(r.pos)),1):at.create(o.doc,o.mapping.map(r.pos))),t(o.scrollIntoView())}return!0}}return!(!i.isAtom||r.depth!=o.depth-1||(t&&t(e.tr.delete(r.pos,r.pos+i.nodeSize).scrollIntoView()),0))},Jo=(e,t,n)=>{let{$head:o,empty:r}=e.selection,i=o;if(!r)return!1;if(o.parent.isTextblock){if(n?!n.endOfTextblock("forward",e):o.parentOffset<o.parent.content.size)return!1;i=Ko(o)}let s=i&&i.nodeAfter;return!(!s||!at.isSelectable(s)||(t&&t(e.tr.setSelection(at.create(e.doc,i.pos)).scrollIntoView()),0))};function Ko(e){if(!e.parent.type.spec.isolating)for(let t=e.depth-1;t>=0;t--){let n=e.node(t);if(e.index(t)+1<n.childCount)return e.doc.resolve(e.after(t+1));if(n.type.spec.isolating)break}return null}const Xo=(e,t)=>{let n,o=e.selection,r=o instanceof at;if(r){if(o.node.isTextblock||!Be(e.doc,o.from))return!1;n=o.from}else if(n=Ve(e.doc,o.from,-1),null==n)return!1;if(t){let o=e.tr.join(n);r&&o.setSelection(at.create(o.doc,n-e.doc.resolve(n).nodeBefore.nodeSize)),t(o.scrollIntoView())}return!0},Uo=(e,t)=>{let n,o=e.selection;if(o instanceof at){if(o.node.isTextblock||!Be(e.doc,o.to))return!1;n=o.to}else if(n=Ve(e.doc,o.to,1),null==n)return!1;return t&&t(e.tr.join(n).scrollIntoView()),!0},Yo=(e,t)=>{let{$from:n,$to:o}=e.selection,r=n.blockRange(o),i=r&&De(r);return null!=i&&(t&&t(e.tr.lift(r,i).scrollIntoView()),!0)},Go=(e,t)=>{let{$head:n,$anchor:o}=e.selection;return!(!n.parent.type.spec.code||!n.sameParent(o)||(t&&t(e.tr.insertText("\n").scrollIntoView()),0))};function Qo(e){for(let t=0;t<e.edgeCount;t++){let{type:n}=e.edge(t);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}const Zo=(e,t)=>{let{$head:n,$anchor:o}=e.selection;if(!n.parent.type.spec.code||!n.sameParent(o))return!1;let r=n.node(-1),i=n.indexAfter(-1),s=Qo(r.contentMatchAt(i));if(!s||!r.canReplaceWith(i,i,s))return!1;if(t){let o=n.after(),r=e.tr.replaceWith(o,o,s.createAndFill());r.setSelection(nt.near(r.doc.resolve(o),1)),t(r.scrollIntoView())}return!0},er=(e,t)=>{let n=e.selection,{$from:o,$to:r}=n;if(n instanceof dt||o.parent.inlineContent||r.parent.inlineContent)return!1;let i=Qo(r.parent.contentMatchAt(r.indexAfter()));if(!i||!i.isTextblock)return!1;if(t){let n=(!o.parentOffset&&r.index()<r.parent.childCount?o:r).pos,s=e.tr.insert(n,i.createAndFill());s.setSelection(st.create(s.doc,n+1)),t(s.scrollIntoView())}return!0},tr=(e,t)=>{let{$cursor:n}=e.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let o=n.before();if(ze(e.doc,o))return t&&t(e.tr.split(o).scrollIntoView()),!0}let o=n.blockRange(),r=o&&De(o);return null!=r&&(t&&t(e.tr.lift(o,r).scrollIntoView()),!0)};function nr(e){return(t,n)=>{let{$from:o,$to:r}=t.selection;if(t.selection instanceof at&&t.selection.node.isBlock)return!(!o.parentOffset||!ze(t.doc,o.pos)||(n&&n(t.tr.split(o.pos).scrollIntoView()),0));if(!o.depth)return!1;let i,s,l=[],a=!1,c=!1;for(let t=o.depth;;t--){if(o.node(t).isBlock){a=o.end(t)==o.pos+(o.depth-t),c=o.start(t)==o.pos-(o.depth-t),s=Qo(o.node(t-1).contentMatchAt(o.indexAfter(t-1)));let n=e&&e(r.parent,a,o);l.unshift(n||(a&&s?{type:s}:null)),i=t;break}if(1==t)return!1;l.unshift(null)}let d=t.tr;(t.selection instanceof st||t.selection instanceof dt)&&d.deleteSelection();let h=d.mapping.map(o.pos),p=ze(d.doc,h,l.length,l);if(p||(l[0]=s?{type:s}:null,p=ze(d.doc,h,l.length,l)),!p)return!1;if(d.split(h,l.length,l),!a&&c&&o.node(i).type!=s){let e=d.mapping.map(o.before(i)),t=d.doc.resolve(e);s&&o.node(i-1).canReplaceWith(t.index(),t.index()+1,s)&&d.setNodeMarkup(d.mapping.map(o.before(i)),s)}return n&&n(d.scrollIntoView()),!0}}const or=nr(),rr=(e,t)=>or(e,t&&(n=>{let o=e.storedMarks||e.selection.$to.parentOffset&&e.selection.$from.marks();o&&n.ensureMarks(o),t(n)})),ir=(e,t)=>{let n,{$from:o,to:r}=e.selection,i=o.sharedDepth(r);return 0!=i&&(n=o.before(i),t&&t(e.tr.setSelection(at.create(e.doc,n))),!0)},sr=(e,t)=>(t&&t(e.tr.setSelection(new dt(e.doc))),!0);function lr(e,t,n,o){let r,i,l=t.nodeBefore,a=t.nodeAfter,c=l.type.spec.isolating||a.type.spec.isolating;if(!c&&function(e,t,n){let o=t.nodeBefore,r=t.nodeAfter,i=t.index();return!(!(o&&r&&o.type.compatibleContent(r.type))||(!o.content.size&&t.parent.canReplace(i-1,i)?(n&&n(e.tr.delete(t.pos-o.nodeSize,t.pos).scrollIntoView()),0):!t.parent.canReplace(i,i+1)||!r.isTextblock&&!Be(e.doc,t.pos)||(n&&n(e.tr.join(t.pos).scrollIntoView()),0)))}(e,t,n))return!0;let d=!c&&t.parent.canReplace(t.index(),t.index()+1);if(d&&(r=(i=l.contentMatchAt(l.childCount)).findWrapping(a.type))&&i.matchType(r[0]||a.type).validEnd){if(n){let o=t.pos+a.nodeSize,i=s.empty;for(let e=r.length-1;e>=0;e--)i=s.from(r[e].create(null,i));i=s.from(l.copy(i));let c=e.tr.step(new Ne(t.pos-1,o,t.pos,o,new p(i,1,0),r.length,!0)),d=c.doc.resolve(o+2*r.length);d.nodeAfter&&d.nodeAfter.type==l.type&&Be(c.doc,d.pos)&&c.join(d.pos),n(c.scrollIntoView())}return!0}let h=a.type.spec.isolating||o>0&&c?null:nt.findFrom(t,1),u=h&&h.$from.blockRange(h.$to),f=u&&De(u);if(null!=f&&f>=t.depth)return n&&n(e.tr.lift(u,f).scrollIntoView()),!0;if(d&&Ho(a,"start",!0)&&Ho(l,"end")){let o=l,r=[];for(;r.push(o),!o.isTextblock;)o=o.lastChild;let i=a,c=1;for(;!i.isTextblock;i=i.firstChild)c++;if(o.canReplace(o.childCount,o.childCount,i.content)){if(n){let o=s.empty;for(let e=r.length-1;e>=0;e--)o=s.from(r[e].copy(o));n(e.tr.step(new Ne(t.pos-r.length,t.pos+a.nodeSize,t.pos+c,t.pos+a.nodeSize-c,new p(o,r.length,0),0,!0)).scrollIntoView())}return!0}}return!1}function ar(e){return function(t,n){let o=t.selection,r=e<0?o.$from:o.$to,i=r.depth;for(;r.node(i).isInline;){if(!i)return!1;i--}return!!r.node(i).isTextblock&&(n&&n(t.tr.setSelection(st.create(t.doc,e<0?r.start(i):r.end(i)))),!0)}}const cr=ar(-1),dr=ar(1);function hr(e,t=null){return function(n,o){let{$from:r,$to:i}=n.selection,s=r.blockRange(i),l=s&&Ee(s,e,t);return!!l&&(o&&o(n.tr.wrap(s,l).scrollIntoView()),!0)}}function pr(e,t=null){return function(n,o){let r=!1;for(let o=0;o<n.selection.ranges.length&&!r;o++){let{$from:{pos:i},$to:{pos:s}}=n.selection.ranges[o];n.doc.nodesBetween(i,s,((o,i)=>{if(r)return!1;if(o.isTextblock&&!o.hasMarkup(e,t))if(o.type==e)r=!0;else{let t=n.doc.resolve(i),o=t.index();r=t.parent.canReplaceWith(o,o+1,e)}}))}if(!r)return!1;if(o){let r=n.tr;for(let o=0;o<n.selection.ranges.length;o++){let{$from:{pos:i},$to:{pos:s}}=n.selection.ranges[o];r.setBlockType(i,s,e,t)}o(r.scrollIntoView())}return!0}}function ur(e,t=null,n){let o=!1!==(n&&n.removeWhenPresent),r=!1!==(n&&n.enterInlineAtoms),i=!(n&&n.includeWhitespace);return function(n,s){let{empty:l,$cursor:a,ranges:c}=n.selection;if(l&&!a||!function(e,t,n,o){for(let r=0;r<t.length;r++){let{$from:i,$to:s}=t[r],l=0==i.depth&&e.inlineContent&&e.type.allowsMarkType(n);if(e.nodesBetween(i.pos,s.pos,((e,t)=>{if(l||!o&&e.isAtom&&e.isInline&&t>=i.pos&&t+e.nodeSize<=s.pos)return!1;l=e.inlineContent&&e.type.allowsMarkType(n)})),l)return!0}return!1}(n.doc,c,e,r))return!1;if(s)if(a)e.isInSet(n.storedMarks||a.marks())?s(n.tr.removeStoredMark(e)):s(n.tr.addStoredMark(e.create(t)));else{let l,a=n.tr;r||(c=function(e){let t=[];for(let n=0;n<e.length;n++){let{$from:o,$to:r}=e[n];o.doc.nodesBetween(o.pos,r.pos,((e,n)=>{if(e.isAtom&&e.content.size&&e.isInline&&n>=o.pos&&n+e.nodeSize<=r.pos)return n+1>o.pos&&t.push(new ot(o,o.doc.resolve(n+1))),o=o.doc.resolve(n+1+e.content.size),!1})),o.pos<r.pos&&t.push(new ot(o,r))}return t}(c)),l=o?!c.some((t=>n.doc.rangeHasMark(t.$from.pos,t.$to.pos,e))):!c.every((t=>{let n=!1;return a.doc.nodesBetween(t.$from.pos,t.$to.pos,((o,r,i)=>{if(n)return!1;n=!e.isInSet(o.marks)&&!!i&&i.type.allowsMarkType(e)&&!(o.isText&&/^\s*$/.test(o.textBetween(Math.max(0,t.$from.pos-r),Math.min(o.nodeSize,t.$to.pos-r))))})),!n}));for(let n=0;n<c.length;n++){let{$from:o,$to:r}=c[n];if(l){let n=o.pos,s=r.pos,l=o.nodeAfter,c=r.nodeBefore,d=i&&l&&l.isText?/^\s*/.exec(l.text)[0].length:0,h=i&&c&&c.isText?/\s*$/.exec(c.text)[0].length:0;n+d<s&&(n+=d,s-=h),a.addMark(n,s,e.create(t))}else a.removeMark(o.pos,r.pos,e)}s(a.scrollIntoView())}return!0}}function fr(e,t){return n=>{if(!n.isGeneric)return e(n);let o=[];for(let e=0;e<n.mapping.maps.length;e++){let t=n.mapping.maps[e];for(let e=0;e<o.length;e++)o[e]=t.map(o[e]);t.forEach(((e,t,n,r)=>o.push(n,r)))}let r=[];for(let e=0;e<o.length;e+=2){let i=o[e],s=o[e+1],l=n.doc.resolve(i),a=l.sharedDepth(s),c=l.node(a);for(let e=l.indexAfter(a),n=l.after(a+1);n<=s;++e){let o=c.maybeChild(e);if(!o)break;if(e&&-1==r.indexOf(n)){let i=c.child(e-1);i.type==o.type&&t(i,o)&&r.push(n)}n+=o.nodeSize}}r.sort(((e,t)=>e-t));for(let e=r.length-1;e>=0;e--)Be(n.doc,r[e])&&n.join(r[e]);e(n)}}function mr(e,t){let n=Array.isArray(t)?e=>t.indexOf(e.type.name)>-1:t;return(t,o,r)=>e(t,o&&fr(o,n),r)}function gr(...e){return function(t,n,o){for(let r=0;r<e.length;r++)if(e[r](t,n,o))return!0;return!1}}let yr=gr(zo,Po,_o),wr=gr(zo,jo,Jo);const vr={Enter:gr(Go,er,tr,or),"Mod-Enter":Zo,Backspace:yr,"Mod-Backspace":yr,"Shift-Backspace":yr,Delete:wr,"Mod-Delete":wr,"Mod-a":sr},br={"Ctrl-h":vr.Backspace,"Alt-Backspace":vr["Mod-Backspace"],"Ctrl-d":vr.Delete,"Ctrl-Alt-Backspace":vr["Mod-Delete"],"Alt-Delete":vr["Mod-Delete"],"Alt-d":vr["Mod-Delete"],"Ctrl-a":cr,"Ctrl-e":dr};for(let e in vr)br[e]=vr[e];const kr=("undefined"!=typeof navigator?/Mac|iP(hone|[oa]d)/.test(navigator.platform):"undefined"!=typeof os&&os.platform&&"darwin"==os.platform())?br:vr,xr=(e,t)=>hr(e.schema.nodes.blockquote)(e,t),Sr=(e,t)=>{const{$from:n,$to:o}=e.selection,r=e.schema.nodes.blockquote,i=e.doc;let s=-1;const l=n.blockRange(o);l&&i.nodesBetween(l.start,l.end,((e,t)=>{e.type===r&&(s=t)}));const a=-1!==s;return t&&a&&t(e.tr.lift(l,i.resolve(s).depth)),a},Cr=(e,t,n)=>(o,r)=>{const i=ro(o),s=o.tr;s.setMeta("commandName",t),i.forEach((t=>{if(t.type.isTextblock){let o;const r=e.find((e=>e.node===t.type.name));if(r){const e="rtl"===n?r.rtlStyle:r.style,i={name:e,value:r.step>0?`${r.step}${r.unit}`:""};if(t.attrs.style){const n=new RegExp(`${e}:\\s?(\\d+)${r.unit}`,"i"),o=t.attrs.style.match(n);if(o){let e=parseFloat(o[1])+r.step;e=e<=0?"":e,i.value=`${e}${e?r.unit:""}`}}o=ao(t,[i])}o&&oo(s,t,t.type,o)}}));const l=s.docChanged;return l&&r(s.scrollIntoView()),l},Mr=(e,t,n)=>{const o=ro(e);let r=!1;return o.forEach((e=>{if(!r&&e.type.isTextblock&&e.attrs.style){const o=t.find((t=>t.node===e.type.name));if(o){const t="rtl"===n?o.rtlStyle:o.style,i=new RegExp(`${t}:\\s?\\d+${o.unit}`,"i");r=i.test(e.attrs.style)}}})),r},Nr=(e,t)=>To(t)(e),Or=(e,t)=>{const n=e.schema.nodes[t.listsTypes.listItem],o=e.schema.nodes[t.listsTypes.orderedList],r=e.schema.nodes[t.listsTypes.bulletList],i=!!Ut(o,2)(e.selection),s=!!Ut(r,2)(e.selection);return(i||s)&&Ao(n)(e)},Ar=(e,t)=>{const n=e.schema.nodes,o=n[$o.listsTypes.listItem];return(Mr(e,t.nodes)||$o.nodes.some((t=>n[t.node]&&co(e,n[t.node]))))&&!co(e,o)},Tr=(e,t)=>{const n=e.schema.nodes[$o.listsTypes.listItem],o=Ar(e,$o);Nr(e,n)?To(n)(e,t):o&&Cr($o.nodes)(e,t)},Dr=(e,t)=>{const n=e.schema.nodes,o=n[Io.listsTypes.listItem],r=Ar(e,Io);co(e,n.blockquote)?Sr(e,t):Or(e,Io)?Ao(o)(e,t):r&&Cr(Io.nodes)(e,t)},Er=(e,t,n)=>{let o=t.depth;const r=e.nodes[n.bulletList],i=e.nodes[n.orderedList],s=e.nodes[n.listItem];for(let e=t.depth;e>0;e--){const n=t.node(e);if(n.type!==r&&n.type!==i||(o=e),n.type!==r&&n.type!==i&&n.type!==s)break}return o-1};function Rr(e,t,n,o){const r=o||e.schema.nodes.listItem,{$from:i,$to:l}=t;let a=i.blockRange(l,(e=>e.childCount&&e.firstChild.type===r));if(!a||a.depth<2||i.node(a.depth-1).type!==r)return n;const c=a.end,d=l.end(a.depth);return c<d&&(n.step(new Ne(c-1,d,c,d,new p(s.from(r.create(void 0,a.parent.copy())),1,0),1,!0)),a=new A(n.doc.resolve(i.pos),n.doc.resolve(d),a.depth)),n.lift(a,De(a)).scrollIntoView()}function $r(e){return function(t,n){const{tr:o}=t,{$from:r,$to:i}=t.selection;return o.doc.nodesBetween(r.pos,i.pos,((n,r)=>{if(n.isTextblock||"blockquote"===n.type.name||"div"===n.type.name){const n=new at(o.doc.resolve(o.mapping.map(r))),i=n.$from.blockRange(n.$to);if(!i||n.$from.parent.type!==t.schema.nodes[e.listItem])return;const s=i&&De(i);if(null==s)return!1;o.lift(i,s)}})),n&&n(o),!0}}const Ir=/list-style-type:\s?([\w-]+)/,zr=e=>{const t=e.style||"",n=Ir.exec(t);return n&&n[1]||""},Br=(e,t,n,o,r)=>{const{listType:i,listAttrs:s={style:null}}=o,{selection:l}=e,a=l.$from.node(l.$from.depth-2),c=l.$to.node(l.$to.depth-2);if(a&&a.type.name===i&&zr(a.attrs)===zr(s)&&c&&c.type.name===i&&zr(c.attrs)===zr(s)){const i=n.state.schema.nodes,s={bulletList:i[o.bulletList],orderedList:i[o.orderedList],listItem:i[o.listItem]},a=((e,t)=>{const{bulletList:n,orderedList:o,listItem:r}=t;let i;for(let t=e.depth-1;t>0;t--){const s=e.node(t);if(s.type!==n&&s.type!==o||(i=t),s.type!==n&&s.type!==o&&s.type!==r)break}return i})(l.$to,s);let c=function(e,t,n,o,r,i){i||(i=e.schema.nodes.listItem);let s=!1;return r.doc.nodesBetween(t,n,((n,l)=>{if(!s&&n.type===i&&l>t){s=!0;let t=o+3;for(;t>o+2;){const o=r.doc.resolve(r.mapping.map(l));t=o.depth;const s=r.doc.resolve(r.mapping.map(l+n.textContent.length)),a=new st(o,s);r=Rr(e,a,r,i)}}})),r}(e,l.$to.pos,l.$to.end(a),a,n.state.tr,s.listItem);return c=function(e,t,n){const{from:o,to:r}=e.selection,{paragraph:i,heading:s}=e.schema.nodes,l=[];t.doc.nodesBetween(o,r,((e,t)=>{e.type!==i&&e.type!==s||l.push({node:e,pos:t})}));for(let o=l.length-1;o>=0;o--){const r=l[o],i=t.doc.resolve(t.mapping.map(r.pos));if(i.depth>0){let o;o=r.node.textContent&&r.node.textContent.length>0?t.doc.resolve(t.mapping.map(r.pos+r.node.textContent.length)):t.doc.resolve(t.mapping.map(r.pos+1));const s=i.blockRange(o);s&&t.lift(s,Er(e.schema,i,n))}}return t}(e,c,o),c.setMeta("commandName",r),t(c),!0}return function(e){return function(t,n,o){if(!o)return!1;const r=(t=o.state).schema.nodes[e.listType],{$from:i,$to:s}=t.selection,l=i.node(-2),a=i.node(-3),c=function(e,t,n,o){return 0===function(e,t,n){const o=[],r=function(e,t){const n=["blockquote","bulletList","orderedList"];if(1===t.depth)return t;let o=t.node(t.depth),r=t;for(;t.depth>=1;)o=(t=e.resolve(t.before(t.depth))).node(t.depth),o&&-1!==n.indexOf(o.type.name)&&(r=t);return r}(e,t).depth;let i=e.resolve(t.start(r));for(;i.pos<=n.start(n.depth);){const t=Math.min(i.depth,r),n=i.node(t);if(n&&o.push(n),0===t)break;let s=e.resolve(i.after(t));if(s.start(t)>=e.nodeSize-2)break;s.depth!==i.depth&&(s=e.resolve(s.pos+2)),i=s.depth?e.resolve(s.start(s.depth)):e.resolve(s.end(s.depth))}return o}(e,t,n).filter((e=>e.type!==o)).length}(t.doc,i,s,r);return(l&&l.type===r||a&&a.type===r)&&c?$r(e)(t,n):(c||($r(e)(t,n),t=o.state),function(e,t={}){return mr(Co(e,t),((t,n)=>t.type===n.type&&t.type===e))}(r,e.listAttrs)(t,n))}}(o)(e,t,n)};function Pr(e,t,n){return Br(e,t,n,{listType:Ro.listType,...Ro.types})}function Vr(e,t,n){return Br(e,t,n,{listType:Eo.listType,...Eo.types})}const Fr=(e,t)=>({name:e,value:t}),Lr=[{node:"paragraph",style:[Fr("text-align","left")]},{node:"heading",style:[Fr("text-align","left")]},{node:"table_caption_external",style:[Fr("text-align","left")]}],Hr=[{node:"paragraph",style:[Fr("text-align","right")]},{node:"heading",style:[Fr("text-align","right")]},{node:"table_caption_external",style:[Fr("text-align","right")]}],_r=[{node:"paragraph",style:[Fr("text-align","center")]},{node:"heading",style:[Fr("text-align","center")]},{node:"table_caption_external",style:[Fr("text-align","center")]}],Wr=[{node:"paragraph",style:[Fr("text-align","justify")]},{node:"heading",style:[Fr("text-align","justify")]},{node:"table_caption_external",style:[Fr("text-align","justify")]}],qr=[{node:"paragraph",style:[Fr("text-align","")]},{node:"heading",style:[Fr("text-align","")]},{node:"table_caption_external",style:[Fr("text-align","")]}],jr=function(e){for(var t=0;;t++)if(!(e=e.previousSibling))return t},Jr=function(e){let t=e.assignedSlot||e.parentNode;return t&&11==t.nodeType?t.host:t};let Kr=null;const Xr=function(e,t,n){let o=Kr||(Kr=document.createRange());return o.setEnd(e,null==n?e.nodeValue.length:n),o.setStart(e,t||0),o},Ur=function(e,t,n,o){return n&&(Gr(e,t,n,o,-1)||Gr(e,t,n,o,1))},Yr=/^(img|br|input|textarea|hr)$/i;function Gr(e,t,n,o,r){for(var i;;){if(e==n&&t==o)return!0;if(t==(r<0?0:Qr(e))){let n=e.parentNode;if(!n||1!=n.nodeType||Zr(e)||Yr.test(e.nodeName)||"false"==e.contentEditable)return!1;t=jr(e)+(r<0?0:1),e=n}else{if(1!=e.nodeType)return!1;{let n=e.childNodes[t+(r<0?-1:0)];if(1==n.nodeType&&"false"==n.contentEditable){if(!(null===(i=n.pmViewDesc)||void 0===i?void 0:i.ignoreForSelection))return!1;t+=r}else e=n,t=r<0?Qr(e):0}}}}function Qr(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function Zr(e){let t;for(let n=e;n&&!(t=n.pmViewDesc);n=n.parentNode);return t&&t.node&&t.node.isBlock&&(t.dom==e||t.contentDOM==e)}const ei=function(e){return e.focusNode&&Ur(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)};function ti(e,t){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=e,n.key=n.code=t,n}const ni="undefined"!=typeof navigator?navigator:null,oi="undefined"!=typeof document?document:null,ri=ni&&ni.userAgent||"",ii=/Edge\/(\d+)/.exec(ri),si=/MSIE \d/.exec(ri),li=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(ri),ai=!!(si||li||ii),ci=si?document.documentMode:li?+li[1]:ii?+ii[1]:0,di=!ai&&/gecko\/(\d+)/i.test(ri);di&&(/Firefox\/(\d+)/.exec(ri)||[0,0])[1];const hi=!ai&&/Chrome\/(\d+)/.exec(ri),pi=!!hi,ui=hi?+hi[1]:0,fi=!ai&&!!ni&&/Apple Computer/.test(ni.vendor),mi=fi&&(/Mobile\/\w+/.test(ri)||!!ni&&ni.maxTouchPoints>2),gi=mi||!!ni&&/Mac/.test(ni.platform),yi=!!ni&&/Win/.test(ni.platform),wi=/Android \d/.test(ri),vi=!!oi&&"webkitFontSmoothing"in oi.documentElement.style,bi=vi?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function ki(e){let t=e.defaultView&&e.defaultView.visualViewport;return t?{left:0,right:t.width,top:0,bottom:t.height}:{left:0,right:e.documentElement.clientWidth,top:0,bottom:e.documentElement.clientHeight}}function xi(e,t){return"number"==typeof e?e:e[t]}function Si(e){let t=e.getBoundingClientRect(),n=t.width/e.offsetWidth||1,o=t.height/e.offsetHeight||1;return{left:t.left,right:t.left+e.clientWidth*n,top:t.top,bottom:t.top+e.clientHeight*o}}function Ci(e,t,n){let o=e.someProp("scrollThreshold")||0,r=e.someProp("scrollMargin")||5,i=e.dom.ownerDocument;for(let s=n||e.dom;s;){if(1!=s.nodeType){s=Jr(s);continue}let e=s,n=e==i.body,l=n?ki(i):Si(e),a=0,c=0;if(t.top<l.top+xi(o,"top")?c=-(l.top-t.top+xi(r,"top")):t.bottom>l.bottom-xi(o,"bottom")&&(c=t.bottom-t.top>l.bottom-l.top?t.top+xi(r,"top")-l.top:t.bottom-l.bottom+xi(r,"bottom")),t.left<l.left+xi(o,"left")?a=-(l.left-t.left+xi(r,"left")):t.right>l.right-xi(o,"right")&&(a=t.right-l.right+xi(r,"right")),a||c)if(n)i.defaultView.scrollBy(a,c);else{let n=e.scrollLeft,o=e.scrollTop;c&&(e.scrollTop+=c),a&&(e.scrollLeft+=a);let r=e.scrollLeft-n,i=e.scrollTop-o;t={left:t.left-r,top:t.top-i,right:t.right-r,bottom:t.bottom-i}}let d=n?"fixed":getComputedStyle(s).position;if(/^(fixed|sticky)$/.test(d))break;s="absolute"==d?s.offsetParent:Jr(s)}}function Mi(e){let t=[],n=e.ownerDocument;for(let o=e;o&&(t.push({dom:o,top:o.scrollTop,left:o.scrollLeft}),e!=n);o=Jr(o));return t}function Ni(e,t){for(let n=0;n<e.length;n++){let{dom:o,top:r,left:i}=e[n];o.scrollTop!=r+t&&(o.scrollTop=r+t),o.scrollLeft!=i&&(o.scrollLeft=i)}}let Oi=null;function Ai(e,t){let n,o,r,i,s=2e8,l=0,a=t.top,c=t.top;for(let d=e.firstChild,h=0;d;d=d.nextSibling,h++){let e;if(1==d.nodeType)e=d.getClientRects();else{if(3!=d.nodeType)continue;e=Xr(d).getClientRects()}for(let p=0;p<e.length;p++){let u=e[p];if(u.top<=a&&u.bottom>=c){a=Math.max(u.bottom,a),c=Math.min(u.top,c);let e=u.left>t.left?u.left-t.left:u.right<t.left?t.left-u.right:0;if(e<s){n=d,s=e,o=e&&3==n.nodeType?{left:u.right<t.left?u.right:u.left,top:t.top}:t,1==d.nodeType&&e&&(l=h+(t.left>=(u.left+u.right)/2?1:0));continue}}else u.top>t.top&&!r&&u.left<=t.left&&u.right>=t.left&&(r=d,i={left:Math.max(u.left,Math.min(u.right,t.left)),top:u.top});!n&&(t.left>=u.right&&t.top>=u.top||t.left>=u.left&&t.top>=u.bottom)&&(l=h+1)}}return!n&&r&&(n=r,o=i,s=0),n&&3==n.nodeType?function(e,t){let n=e.nodeValue.length,o=document.createRange();for(let r=0;r<n;r++){o.setEnd(e,r+1),o.setStart(e,r);let n=$i(o,1);if(n.top!=n.bottom&&Ti(t,n))return{node:e,offset:r+(t.left>=(n.left+n.right)/2?1:0)}}return{node:e,offset:0}}(n,o):!n||s&&1==n.nodeType?{node:e,offset:l}:Ai(n,o)}function Ti(e,t){return e.left>=t.left-1&&e.left<=t.right+1&&e.top>=t.top-1&&e.top<=t.bottom+1}function Di(e,t,n){let o=e.childNodes.length;if(o&&n.top<n.bottom)for(let r=Math.max(0,Math.min(o-1,Math.floor(o*(t.top-n.top)/(n.bottom-n.top))-2)),i=r;;){let n=e.childNodes[i];if(1==n.nodeType){let e=n.getClientRects();for(let o=0;o<e.length;o++){let r=e[o];if(Ti(t,r))return Di(n,t,r)}}if((i=(i+1)%o)==r)break}return e}function Ei(e,t){let n,o=e.dom.ownerDocument,r=0,i=function(e,t,n){if(e.caretPositionFromPoint)try{let o=e.caretPositionFromPoint(t,n);if(o)return{node:o.offsetNode,offset:Math.min(Qr(o.offsetNode),o.offset)}}catch(e){}if(e.caretRangeFromPoint){let o=e.caretRangeFromPoint(t,n);if(o)return{node:o.startContainer,offset:Math.min(Qr(o.startContainer),o.startOffset)}}}(o,t.left,t.top);i&&({node:n,offset:r}=i);let s,l=(e.root.elementFromPoint?e.root:o).elementFromPoint(t.left,t.top);if(!l||!e.dom.contains(1!=l.nodeType?l.parentNode:l)){let n=e.dom.getBoundingClientRect();if(!Ti(t,n))return null;if(l=Di(e.dom,t,n),!l)return null}if(fi)for(let e=l;n&&e;e=Jr(e))e.draggable&&(n=void 0);if(l=function(e,t){let n=e.parentNode;return n&&/^li$/i.test(n.nodeName)&&t.left<e.getBoundingClientRect().left?n:e}(l,t),n){if(di&&1==n.nodeType&&(r=Math.min(r,n.childNodes.length),r<n.childNodes.length)){let e,o=n.childNodes[r];"IMG"==o.nodeName&&(e=o.getBoundingClientRect()).right<=t.left&&e.bottom>t.top&&r++}let o;vi&&r&&1==n.nodeType&&1==(o=n.childNodes[r-1]).nodeType&&"false"==o.contentEditable&&o.getBoundingClientRect().top>=t.top&&r--,n==e.dom&&r==n.childNodes.length-1&&1==n.lastChild.nodeType&&t.top>n.lastChild.getBoundingClientRect().bottom?s=e.state.doc.content.size:0!=r&&1==n.nodeType&&"BR"==n.childNodes[r-1].nodeName||(s=function(e,t,n,o){let r=-1;for(let n=t,i=!1;n!=e.dom;){let t,s=e.docView.nearestDesc(n,!0);if(!s)return null;if(1==s.dom.nodeType&&(s.node.isBlock&&s.parent||!s.contentDOM)&&((t=s.dom.getBoundingClientRect()).width||t.height)&&(s.node.isBlock&&s.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(s.dom.nodeName)&&(!i&&t.left>o.left||t.top>o.top?r=s.posBefore:(!i&&t.right<o.left||t.bottom<o.top)&&(r=s.posAfter),i=!0),!s.contentDOM&&r<0&&!s.node.isText))return(s.node.isBlock?o.top<(t.top+t.bottom)/2:o.left<(t.left+t.right)/2)?s.posBefore:s.posAfter;n=s.dom.parentNode}return r>-1?r:e.docView.posFromDOM(t,n,-1)}(e,n,r,t))}null==s&&(s=function(e,t,n){let{node:o,offset:r}=Ai(t,n),i=-1;if(1==o.nodeType&&!o.firstChild){let e=o.getBoundingClientRect();i=e.left!=e.right&&n.left>(e.left+e.right)/2?1:-1}return e.docView.posFromDOM(o,r,i)}(e,l,t));let a=e.docView.nearestDesc(l,!0);return{pos:s,inside:a?a.posAtStart-a.border:-1}}function Ri(e){return e.top<e.bottom||e.left<e.right}function $i(e,t){let n=e.getClientRects();if(n.length){let e=n[t<0?0:n.length-1];if(Ri(e))return e}return Array.prototype.find.call(n,Ri)||e.getBoundingClientRect()}const Ii=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function zi(e,t,n){let{node:o,offset:r,atom:i}=e.docView.domFromPos(t,n<0?-1:1),s=vi||di;if(3==o.nodeType){if(!s||!Ii.test(o.nodeValue)&&(n<0?r:r!=o.nodeValue.length)){let e=r,t=r,i=n<0?1:-1;return n<0&&!r?(t++,i=-1):n>=0&&r==o.nodeValue.length?(e--,i=1):n<0?e--:t++,Bi($i(Xr(o,e,t),i),i<0)}{let e=$i(Xr(o,r,r),n);if(di&&r&&/\s/.test(o.nodeValue[r-1])&&r<o.nodeValue.length){let t=$i(Xr(o,r-1,r-1),-1);if(t.top==e.top){let n=$i(Xr(o,r,r+1),-1);if(n.top!=e.top)return Bi(n,n.left<t.left)}}return e}}if(!e.state.doc.resolve(t-(i||0)).parent.inlineContent){if(null==i&&r&&(n<0||r==Qr(o))){let e=o.childNodes[r-1];if(1==e.nodeType)return Pi(e.getBoundingClientRect(),!1)}if(null==i&&r<Qr(o)){let e=o.childNodes[r];if(1==e.nodeType)return Pi(e.getBoundingClientRect(),!0)}return Pi(o.getBoundingClientRect(),n>=0)}if(null==i&&r&&(n<0||r==Qr(o))){let e=o.childNodes[r-1],t=3==e.nodeType?Xr(e,Qr(e)-(s?0:1)):1!=e.nodeType||"BR"==e.nodeName&&e.nextSibling?null:e;if(t)return Bi($i(t,1),!1)}if(null==i&&r<Qr(o)){let e=o.childNodes[r];for(;e.pmViewDesc&&e.pmViewDesc.ignoreForCoords;)e=e.nextSibling;let t=e?3==e.nodeType?Xr(e,0,s?0:1):1==e.nodeType?e:null:null;if(t)return Bi($i(t,-1),!0)}return Bi($i(3==o.nodeType?Xr(o):o,-n),n>=0)}function Bi(e,t){if(0==e.width)return e;let n=t?e.left:e.right;return{top:e.top,bottom:e.bottom,left:n,right:n}}function Pi(e,t){if(0==e.height)return e;let n=t?e.top:e.bottom;return{top:n,bottom:n,left:e.left,right:e.right}}function Vi(e,t,n){let o=e.state,r=e.root.activeElement;o!=t&&e.updateState(t),r!=e.dom&&e.focus();try{return n()}finally{o!=t&&e.updateState(o),r!=e.dom&&r&&r.focus()}}const Fi=/[\u0590-\u08ac]/;let Li=null,Hi=null,_i=!1;class Wi{constructor(e,t,n,o){this.parent=e,this.children=t,this.dom=n,this.contentDOM=o,this.dirty=0,n.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,n){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;t<this.children.length;t++)e+=this.children[t].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let t=0,n=this.posAtStart;;t++){let o=this.children[t];if(o==e)return n;n+=o.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,t,n){if(this.contentDOM&&this.contentDOM.contains(1==e.nodeType?e:e.parentNode)){if(n<0){let n,o;if(e==this.contentDOM)n=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;n=e.previousSibling}for(;n&&(!(o=n.pmViewDesc)||o.parent!=this);)n=n.previousSibling;return n?this.posBeforeChild(o)+o.size:this.posAtStart}{let n,o;if(e==this.contentDOM)n=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;n=e.nextSibling}for(;n&&(!(o=n.pmViewDesc)||o.parent!=this);)n=n.nextSibling;return n?this.posBeforeChild(o):this.posAtEnd}}let o;if(e==this.dom&&this.contentDOM)o=t>jr(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))o=2&e.compareDocumentPosition(this.contentDOM);else if(this.dom.firstChild){if(0==t)for(let t=e;;t=t.parentNode){if(t==this.dom){o=!1;break}if(t.previousSibling)break}if(null==o&&t==e.childNodes.length)for(let t=e;;t=t.parentNode){if(t==this.dom){o=!0;break}if(t.nextSibling)break}}return(null==o?n>0:o)?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let n=!0,o=e;o;o=o.parentNode){let r,i=this.getDesc(o);if(i&&(!t||i.node)){if(!n||!(r=i.nodeDOM)||(1==r.nodeType?r.contains(1==e.nodeType?e:e.parentNode):r==e))return i;n=!1}}}getDesc(e){let t=e.pmViewDesc;for(let e=t;e;e=e.parent)if(e==this)return t}posFromDOM(e,t,n){for(let o=e;o;o=o.parentNode){let r=this.getDesc(o);if(r)return r.localPosFromDOM(e,t,n)}return-1}descAt(e){for(let t=0,n=0;t<this.children.length;t++){let o=this.children[t],r=n+o.size;if(n==e&&r!=n){for(;!o.border&&o.children.length;)for(let e=0;e<o.children.length;e++){let t=o.children[e];if(t.size){o=t;break}}return o}if(e<r)return o.descAt(e-n-o.border);n=r}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let n=0,o=0;for(let t=0;n<this.children.length;n++){let r=this.children[n],i=t+r.size;if(i>e||r instanceof Yi){o=e-t;break}t=i}if(o)return this.children[n].domFromPos(o-this.children[n].border,t);for(let e;n&&!(e=this.children[n-1]).size&&e instanceof qi&&e.side>=0;n--);if(t<=0){let e,o=!0;for(;e=n?this.children[n-1]:null,e&&e.dom.parentNode!=this.contentDOM;n--,o=!1);return e&&t&&o&&!e.border&&!e.domAtom?e.domFromPos(e.size,t):{node:this.contentDOM,offset:e?jr(e.dom)+1:0}}{let e,o=!0;for(;e=n<this.children.length?this.children[n]:null,e&&e.dom.parentNode!=this.contentDOM;n++,o=!1);return e&&o&&!e.border&&!e.domAtom?e.domFromPos(0,t):{node:this.contentDOM,offset:e?jr(e.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,n=0){if(0==this.children.length)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let o=-1,r=-1;for(let i=n,s=0;;s++){let n=this.children[s],l=i+n.size;if(-1==o&&e<=l){let r=i+n.border;if(e>=r&&t<=l-n.border&&n.node&&n.contentDOM&&this.contentDOM.contains(n.contentDOM))return n.parseRange(e,t,r);e=i;for(let t=s;t>0;t--){let n=this.children[t-1];if(n.size&&n.dom.parentNode==this.contentDOM&&!n.emptyChildAt(1)){o=jr(n.dom)+1;break}e-=n.size}-1==o&&(o=0)}if(o>-1&&(l>t||s==this.children.length-1)){t=l;for(let e=s+1;e<this.children.length;e++){let n=this.children[e];if(n.size&&n.dom.parentNode==this.contentDOM&&!n.emptyChildAt(-1)){r=jr(n.dom);break}t+=n.size}-1==r&&(r=this.contentDOM.childNodes.length);break}i=l}return{node:this.contentDOM,from:e,to:t,fromOffset:o,toOffset:r}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let t=this.children[e<0?0:this.children.length-1];return 0==t.size||t.emptyChildAt(e)}domAfterPos(e){let{node:t,offset:n}=this.domFromPos(e,0);if(1!=t.nodeType||n==t.childNodes.length)throw new RangeError("No node after pos "+e);return t.childNodes[n]}setSelection(e,t,n,o=!1){let r=Math.min(e,t),i=Math.max(e,t);for(let s=0,l=0;s<this.children.length;s++){let a=this.children[s],c=l+a.size;if(r>l&&i<c)return a.setSelection(e-l-a.border,t-l-a.border,n,o);l=c}let s=this.domFromPos(e,e?-1:1),l=t==e?s:this.domFromPos(t,t?-1:1),a=n.root.getSelection(),c=n.domSelectionRange(),d=!1;if((di||fi)&&e==t){let{node:e,offset:t}=s;if(3==e.nodeType){if(d=!(!t||"\n"!=e.nodeValue[t-1]),d&&t==e.nodeValue.length)for(let t,n=e;n;n=n.parentNode){if(t=n.nextSibling){"BR"==t.nodeName&&(s=l={node:t.parentNode,offset:jr(t)+1});break}let e=n.pmViewDesc;if(e&&e.node&&e.node.isBlock)break}}else{let n=e.childNodes[t-1];d=n&&("BR"==n.nodeName||"false"==n.contentEditable)}}if(di&&c.focusNode&&c.focusNode!=l.node&&1==c.focusNode.nodeType){let e=c.focusNode.childNodes[c.focusOffset];e&&"false"==e.contentEditable&&(o=!0)}if(!(o||d&&fi)&&Ur(s.node,s.offset,c.anchorNode,c.anchorOffset)&&Ur(l.node,l.offset,c.focusNode,c.focusOffset))return;let h=!1;if((a.extend||e==t)&&(!d||!di)){a.collapse(s.node,s.offset);try{e!=t&&a.extend(l.node,l.offset),h=!0}catch(e){}}if(!h){if(e>t){let e=s;s=l,l=e}let n=document.createRange();n.setEnd(l.node,l.offset),n.setStart(s.node,s.offset),a.removeAllRanges(),a.addRange(n)}}ignoreMutation(e){return!this.contentDOM&&"selection"!=e.type}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let n=0,o=0;o<this.children.length;o++){let r=this.children[o],i=n+r.size;if(n==i?e<=i&&t>=n:e<i&&t>n){let o=n+r.border,s=i-r.border;if(e>=o&&t<=s)return this.dirty=e==n||t==i?2:1,void(e!=o||t!=s||!r.contentLost&&r.dom.parentNode==this.contentDOM?r.markDirty(e-o,t-o):r.dirty=3);r.dirty=r.dom!=r.contentDOM||r.dom.parentNode!=this.contentDOM||r.children.length?3:2}n=i}this.dirty=2}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let n=1==e?2:1;t.dirty<n&&(t.dirty=n)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class qi extends Wi{constructor(e,t,n,o){let r,i=t.type.toDOM;if("function"==typeof i&&(i=i(n,(()=>r?r.parent?r.parent.posBeforeChild(r):void 0:o))),!t.type.spec.raw){if(1!=i.nodeType){let e=document.createElement("span");e.appendChild(i),i=e}i.contentEditable="false",i.classList.add("ProseMirror-widget")}super(e,[],i,null),this.widget=t,this.widget=t,r=this}matchesWidget(e){return 0==this.dirty&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return!!t&&t(e)}ignoreMutation(e){return"selection"!=e.type||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}}class ji extends Wi{constructor(e,t,n,o){super(e,[],t,null),this.textDOM=n,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"characterData"===e.type&&e.target.nodeValue==e.oldValue}}class Ji extends Wi{constructor(e,t,n,o,r){super(e,[],n,o),this.mark=t,this.spec=r}static create(e,t,n,o){let r=o.nodeViews[t.type.name],i=r&&r(t,o,n);return i&&i.dom||(i=le.renderSpec(document,t.type.spec.toDOM(t,n),null,t.attrs)),new Ji(e,t,i.dom,i.contentDOM||i.dom,i)}parseRule(){return 3&this.dirty||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return 3!=this.dirty&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),0!=this.dirty){let e=this.parent;for(;!e.node;)e=e.parent;e.dirty<this.dirty&&(e.dirty=this.dirty),this.dirty=0}}slice(e,t,n){let o=Ji.create(this.parent,this.mark,!0,n),r=this.children,i=this.size;t<i&&(r=ds(r,t,i,n)),e>0&&(r=ds(r,0,e,n));for(let e=0;e<r.length;e++)r[e].parent=o;return o.children=r,o}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class Ki extends Wi{constructor(e,t,n,o,r,i,s,l,a){super(e,[],r,i),this.node=t,this.outerDeco=n,this.innerDeco=o,this.nodeDOM=s}static create(e,t,n,o,r,i){let s,l=r.nodeViews[t.type.name],a=l&&l(t,r,(()=>s?s.parent?s.parent.posBeforeChild(s):void 0:i),n,o),c=a&&a.dom,d=a&&a.contentDOM;if(t.isText)if(c){if(3!=c.nodeType)throw new RangeError("Text must be rendered as a DOM text node")}else c=document.createTextNode(t.text);else if(!c){let e=le.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs);({dom:c,contentDOM:d}=e)}d||t.isText||"BR"==c.nodeName||(c.hasAttribute("contenteditable")||(c.contentEditable="false"),t.type.spec.draggable&&(c.draggable=!0));let h=c;return c=is(c,n,t),a?s=new Gi(e,t,n,o,c,d||null,h,a,r,i+1):t.isText?new Ui(e,t,n,o,c,h,r):new Ki(e,t,n,o,c,d||null,h,r,i+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if("pre"==this.node.type.whitespace&&(e.preserveWhitespace="full"),this.contentDOM)if(this.contentLost){for(let t=this.children.length-1;t>=0;t--){let n=this.children[t];if(this.dom.contains(n.dom.parentNode)){e.contentElement=n.dom.parentNode;break}}e.contentElement||(e.getContent=()=>s.empty)}else e.contentElement=this.contentDOM;else e.getContent=()=>this.node.content;return e}matchesNode(e,t,n){return 0==this.dirty&&e.eq(this.node)&&ss(t,this.outerDeco)&&n.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let n=this.node.inlineContent,o=t,r=e.composing?this.localCompositionInfo(e,t):null,i=r&&r.pos>-1?r:null,s=r&&r.pos<0,l=new as(this,i&&i.node,e);!function(e,t,n,o){let r=t.locals(e),i=0;if(0==r.length){for(let n=0;n<e.childCount;n++){let s=e.child(n);o(s,r,t.forChild(i,s),n),i+=s.nodeSize}return}let s=0,l=[],a=null;for(let c=0;;){let d,h,p,u;for(;s<r.length&&r[s].to==i;){let e=r[s++];e.widget&&(d?(h||(h=[d])).push(e):d=e)}if(d)if(h){h.sort(cs);for(let e=0;e<h.length;e++)n(h[e],c,!!a)}else n(d,c,!!a);if(a)u=-1,p=a,a=null;else{if(!(c<e.childCount))break;u=c,p=e.child(c++)}for(let e=0;e<l.length;e++)l[e].to<=i&&l.splice(e--,1);for(;s<r.length&&r[s].from<=i&&r[s].to>i;)l.push(r[s++]);let f=i+p.nodeSize;if(p.isText){let e=f;s<r.length&&r[s].from<e&&(e=r[s].from);for(let t=0;t<l.length;t++)l[t].to<e&&(e=l[t].to);e<f&&(a=p.cut(e-i),p=p.cut(0,e-i),f=e,u=-1)}else for(;s<r.length&&r[s].to<f;)s++;o(p,p.isInline&&!p.isLeaf?l.filter((e=>!e.inline)):l.slice(),t.forChild(i,p),u),i=f}}(this.node,this.innerDeco,((t,r,i)=>{t.spec.marks?l.syncToMarks(t.spec.marks,n,e):t.type.side>=0&&!i&&l.syncToMarks(r==this.node.childCount?d.none:this.node.child(r).marks,n,e),l.placeWidget(t,e,o)}),((t,i,a,c)=>{let d;l.syncToMarks(t.marks,n,e),l.findNodeMatch(t,i,a,c)||s&&e.state.selection.from>o&&e.state.selection.to<o+t.nodeSize&&(d=l.findIndexWithChild(r.node))>-1&&l.updateNodeAt(t,i,a,d,e)||l.updateNextNode(t,i,a,e,c,o)||l.addNode(t,i,a,e,o),o+=t.nodeSize})),l.syncToMarks([],n,e),this.node.isTextblock&&l.addTextblockHacks(),l.destroyRest(),(l.changed||2==this.dirty)&&(i&&this.protectLocalComposition(e,i),Qi(this.contentDOM,this.children,e),mi&&function(e){if("UL"==e.nodeName||"OL"==e.nodeName){let t=e.style.cssText;e.style.cssText=t+"; list-style: square !important",window.getComputedStyle(e).listStyle,e.style.cssText=t}}(this.dom))}localCompositionInfo(e,t){let{from:n,to:o}=e.state.selection;if(!(e.state.selection instanceof st)||n<t||o>t+this.node.content.size)return null;let r=e.input.compositionNode;if(!r||!this.dom.contains(r.parentNode))return null;if(this.node.inlineContent){let e=r.nodeValue,i=function(e,t,n,o){for(let r=0,i=0;r<e.childCount&&i<=o;){let s=e.child(r++),l=i;if(i+=s.nodeSize,!s.isText)continue;let a=s.text;for(;r<e.childCount;){let t=e.child(r++);if(i+=t.nodeSize,!t.isText)break;a+=t.text}if(i>=n){if(i>=o&&a.slice(o-t.length-l,o-l)==t)return o-t.length;let e=l<o?a.lastIndexOf(t,o-l-1):-1;if(e>=0&&e+t.length+l>=n)return l+e;if(n==o&&a.length>=o+t.length-l&&a.slice(o-l,o-l+t.length)==t)return o}}return-1}(this.node.content,e,n-t,o-t);return i<0?null:{node:r,pos:i,text:e}}return{node:r,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:n,text:o}){if(this.getDesc(t))return;let r=t;for(;r.parentNode!=this.contentDOM;r=r.parentNode){for(;r.previousSibling;)r.parentNode.removeChild(r.previousSibling);for(;r.nextSibling;)r.parentNode.removeChild(r.nextSibling);r.pmViewDesc&&(r.pmViewDesc=void 0)}let i=new ji(this,r,t,o);e.input.compositionNodes.push(i),this.children=ds(this.children,n,n+o.length,e,i)}update(e,t,n,o){return!(3==this.dirty||!e.sameMarkup(this.node)||(this.updateInner(e,t,n,o),0))}updateInner(e,t,n,o){this.updateOuterDeco(t),this.node=e,this.innerDeco=n,this.contentDOM&&this.updateChildren(o,this.posAtStart),this.dirty=0}updateOuterDeco(e){if(ss(e,this.outerDeco))return;let t=1!=this.nodeDOM.nodeType,n=this.dom;this.dom=ns(this.dom,this.nodeDOM,ts(this.outerDeco,this.node,t),ts(e,this.node,t)),this.dom!=n&&(n.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){1==this.nodeDOM.nodeType&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),!this.contentDOM&&this.node.type.spec.draggable||(this.nodeDOM.draggable=!0))}deselectNode(){1==this.nodeDOM.nodeType&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),!this.contentDOM&&this.node.type.spec.draggable||this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function Xi(e,t,n,o,r){is(o,t,e);let i=new Ki(void 0,e,t,n,o,o,o,r,0);return i.contentDOM&&i.updateChildren(r,0),i}class Ui extends Ki{constructor(e,t,n,o,r,i,s){super(e,t,n,o,r,null,i,s,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,n,o){return!(3==this.dirty||0!=this.dirty&&!this.inParent()||!e.sameMarkup(this.node)||(this.updateOuterDeco(t),0==this.dirty&&e.text==this.node.text||e.text==this.nodeDOM.nodeValue||(this.nodeDOM.nodeValue=e.text,o.trackWrites==this.nodeDOM&&(o.trackWrites=null)),this.node=e,this.dirty=0,0))}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,n){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,n)}ignoreMutation(e){return"characterData"!=e.type&&"selection"!=e.type}slice(e,t,n){let o=this.node.cut(e,t),r=document.createTextNode(o.text);return new Ui(this.parent,o,this.outerDeco,this.innerDeco,r,r,n)}markDirty(e,t){super.markDirty(e,t),this.dom==this.nodeDOM||0!=e&&t!=this.nodeDOM.nodeValue.length||(this.dirty=3)}get domAtom(){return!1}isText(e){return this.node.text==e}}class Yi extends Wi{parseRule(){return{ignore:!0}}matchesHack(e){return 0==this.dirty&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return"IMG"==this.dom.nodeName}}class Gi extends Ki{constructor(e,t,n,o,r,i,s,l,a,c){super(e,t,n,o,r,i,s,a,c),this.spec=l}update(e,t,n,o){if(3==this.dirty)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let r=this.spec.update(e,t,n);return r&&this.updateInner(e,t,n,o),r}return!(!this.contentDOM&&!e.isLeaf)&&super.update(e,t,n,o)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,n,o){this.spec.setSelection?this.spec.setSelection(e,t,n.root):super.setSelection(e,t,n,o)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return!!this.spec.stopEvent&&this.spec.stopEvent(e)}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function Qi(e,t,n){let o=e.firstChild,r=!1;for(let i=0;i<t.length;i++){let s=t[i],l=s.dom;if(l.parentNode==e){for(;l!=o;)o=ls(o),r=!0;o=o.nextSibling}else r=!0,e.insertBefore(l,o);if(s instanceof Ji){let t=o?o.previousSibling:e.lastChild;Qi(s.contentDOM,s.children,n),o=t?t.nextSibling:e.firstChild}}for(;o;)o=ls(o),r=!0;r&&n.trackWrites==e&&(n.trackWrites=null)}const Zi=function(e){e&&(this.nodeName=e)};Zi.prototype=Object.create(null);const es=[new Zi];function ts(e,t,n){if(0==e.length)return es;let o=n?es[0]:new Zi,r=[o];for(let i=0;i<e.length;i++){let s=e[i].type.attrs;if(s){s.nodeName&&r.push(o=new Zi(s.nodeName));for(let e in s){let i=s[e];null!=i&&(n&&1==r.length&&r.push(o=new Zi(t.isInline?"span":"div")),"class"==e?o.class=(o.class?o.class+" ":"")+i:"style"==e?o.style=(o.style?o.style+";":"")+i:"nodeName"!=e&&(o[e]=i))}}}return r}function ns(e,t,n,o){if(n==es&&o==es)return t;let r=t;for(let t=0;t<o.length;t++){let i=o[t],s=n[t];if(t){let t;s&&s.nodeName==i.nodeName&&r!=e&&(t=r.parentNode)&&t.nodeName.toLowerCase()==i.nodeName||(t=document.createElement(i.nodeName),t.pmIsDeco=!0,t.appendChild(r),s=es[0]),r=t}rs(r,s||es[0],i)}return r}function rs(e,t,n){for(let o in t)"class"==o||"style"==o||"nodeName"==o||o in n||e.removeAttribute(o);for(let o in n)"class"!=o&&"style"!=o&&"nodeName"!=o&&n[o]!=t[o]&&e.setAttribute(o,n[o]);if(t.class!=n.class){let o=t.class?t.class.split(" ").filter(Boolean):[],r=n.class?n.class.split(" ").filter(Boolean):[];for(let t=0;t<o.length;t++)-1==r.indexOf(o[t])&&e.classList.remove(o[t]);for(let t=0;t<r.length;t++)-1==o.indexOf(r[t])&&e.classList.add(r[t]);0==e.classList.length&&e.removeAttribute("class")}if(t.style!=n.style){if(t.style){let n,o=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g;for(;n=o.exec(t.style);)e.style.removeProperty(n[1])}n.style&&(e.style.cssText+=n.style)}}function is(e,t,n){return ns(e,e,es,ts(t,n,1!=e.nodeType))}function ss(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].type.eq(t[n].type))return!1;return!0}function ls(e){let t=e.nextSibling;return e.parentNode.removeChild(e),t}class as{constructor(e,t,n){this.lock=t,this.view=n,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=function(e,t){let n=t,o=n.children.length,r=e.childCount,i=new Map,s=[];e:for(;r>0;){let l;for(;;)if(o){let e=n.children[o-1];if(!(e instanceof Ji)){l=e,o--;break}n=e,o=e.children.length}else{if(n==t)break e;o=n.parent.children.indexOf(n),n=n.parent}let a=l.node;if(a){if(a!=e.child(r-1))break;--r,i.set(l,r),s.push(l)}}return{index:r,matched:i,matches:s.reverse()}}(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let n=e;n<t;n++)this.top.children[n].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,n){let o=0,r=this.stack.length>>1,i=Math.min(r,e.length);for(;o<i&&(o==r-1?this.top:this.stack[o+1<<1]).matchesMark(e[o])&&!1!==e[o].type.spec.spanning;)o++;for(;o<r;)this.destroyRest(),this.top.dirty=0,this.index=this.stack.pop(),this.top=this.stack.pop(),r--;for(;r<e.length;){this.stack.push(this.top,this.index+1);let o=-1;for(let t=this.index;t<Math.min(this.index+3,this.top.children.length);t++){let n=this.top.children[t];if(n.matchesMark(e[r])&&!this.isLocked(n.dom)){o=t;break}}if(o>-1)o>this.index&&(this.changed=!0,this.destroyBetween(this.index,o)),this.top=this.top.children[this.index];else{let o=Ji.create(this.top,e[r],t,n);this.top.children.splice(this.index,0,o),this.top=o,this.changed=!0}this.index=0,r++}}findNodeMatch(e,t,n,o){let r,i=-1;if(o>=this.preMatch.index&&(r=this.preMatch.matches[o-this.preMatch.index]).parent==this.top&&r.matchesNode(e,t,n))i=this.top.children.indexOf(r,this.index);else for(let o=this.index,r=Math.min(this.top.children.length,o+5);o<r;o++){let r=this.top.children[o];if(r.matchesNode(e,t,n)&&!this.preMatch.matched.has(r)){i=o;break}}return!(i<0||(this.destroyBetween(this.index,i),this.index++,0))}updateNodeAt(e,t,n,o,r){let i=this.top.children[o];return 3==i.dirty&&i.dom==i.contentDOM&&(i.dirty=2),!!i.update(e,t,n,r)&&(this.destroyBetween(this.index,o),this.index++,!0)}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){let t=e.pmViewDesc;if(t)for(let e=this.index;e<this.top.children.length;e++)if(this.top.children[e]==t)return e;return-1}e=t}}updateNextNode(e,t,n,o,r,i){for(let s=this.index;s<this.top.children.length;s++){let l=this.top.children[s];if(l instanceof Ki){let a=this.preMatch.matched.get(l);if(null!=a&&a!=r)return!1;let c,d=l.dom,h=this.isLocked(d)&&!(e.isText&&l.node&&l.node.isText&&l.nodeDOM.nodeValue==e.text&&3!=l.dirty&&ss(t,l.outerDeco));if(!h&&l.update(e,t,n,o))return this.destroyBetween(this.index,s),l.dom!=d&&(this.changed=!0),this.index++,!0;if(!h&&(c=this.recreateWrapper(l,e,t,n,o,i)))return this.destroyBetween(this.index,s),this.top.children[this.index]=c,c.contentDOM&&(c.dirty=2,c.updateChildren(o,i+1),c.dirty=0),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,n,o,r,i){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!ss(n,e.outerDeco)||!o.eq(e.innerDeco))return null;let s=Ki.create(this.top,t,n,o,r,i);if(s.contentDOM){s.children=e.children,e.children=[];for(let e of s.children)e.parent=s}return e.destroy(),s}addNode(e,t,n,o,r){let i=Ki.create(this.top,e,t,n,o,r);i.contentDOM&&i.updateChildren(o,r+1),this.top.children.splice(this.index++,0,i),this.changed=!0}placeWidget(e,t,n){let o=this.index<this.top.children.length?this.top.children[this.index]:null;if(!o||!o.matchesWidget(e)||e!=o.widget&&o.widget.type.toDOM.parentNode){let o=new qi(this.top,e,t,n);this.top.children.splice(this.index++,0,o),this.changed=!0}else this.index++}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof Ji;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof Ui)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((fi||pi)&&e&&"false"==e.dom.contentEditable&&this.addHackNode("IMG",t),this.addHackNode("BR",this.top))}addHackNode(e,t){if(t==this.top&&this.index<t.children.length&&t.children[this.index].matchesHack(e))this.index++;else{let n=document.createElement(e);"IMG"==e&&(n.className="ProseMirror-separator",n.alt=""),"BR"==e&&(n.className="ProseMirror-trailingBreak");let o=new Yi(this.top,[],n,null);t!=this.top?t.children.push(o):t.children.splice(this.index++,0,o),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||1==e.nodeType&&e.contains(this.lock.parentNode))}}function cs(e,t){return e.type.side-t.type.side}function ds(e,t,n,o,r){let i=[];for(let s=0,l=0;s<e.length;s++){let a=e[s],c=l,d=l+=a.size;c>=n||d<=t?i.push(a):(c<t&&i.push(a.slice(0,t-c,o)),r&&(i.push(r),r=void 0),d>n&&i.push(a.slice(n-c,a.size,o)))}return i}function hs(e,t=null){let n=e.domSelectionRange(),o=e.state.doc;if(!n.focusNode)return null;let r=e.docView.nearestDesc(n.focusNode),i=r&&0==r.size,s=e.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(s<0)return null;let l,a,c=o.resolve(s);if(ei(n)){for(l=s;r&&!r.node;)r=r.parent;let e=r.node;if(r&&e.isAtom&&at.isSelectable(e)&&r.parent&&(!e.isInline||!function(e,t,n){for(let o=0==t,r=t==Qr(e);o||r;){if(e==n)return!0;let t=jr(e);if(!(e=e.parentNode))return!1;o=o&&0==t,r=r&&t==Qr(e)}}(n.focusNode,n.focusOffset,r.dom))){let e=r.posBefore;a=new at(s==e?c:o.resolve(e))}}else{if(n instanceof e.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let t=s,r=s;for(let o=0;o<n.rangeCount;o++){let i=n.getRangeAt(o);t=Math.min(t,e.docView.posFromDOM(i.startContainer,i.startOffset,1)),r=Math.max(r,e.docView.posFromDOM(i.endContainer,i.endOffset,-1))}if(t<0)return null;[l,s]=r==e.state.selection.anchor?[r,t]:[t,r],c=o.resolve(s)}else l=e.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(l<0)return null}let d=o.resolve(l);return a||(a=bs(e,d,c,"pointer"==t||e.state.selection.head<c.pos&&!i?1:-1)),a}function ps(e){return e.editable?e.hasFocus():xs(e)&&document.activeElement&&document.activeElement.contains(e.dom)}function us(e,t=!1){let n=e.state.selection;if(ws(e,n),ps(e)){if(!t&&e.input.mouseDown&&e.input.mouseDown.allowDefault&&pi){let t=e.domSelectionRange(),n=e.domObserver.currentSelection;if(t.anchorNode&&n.anchorNode&&Ur(t.anchorNode,t.anchorOffset,n.anchorNode,n.anchorOffset))return e.input.mouseDown.delayedSelectionSync=!0,void e.domObserver.setCurSelection()}if(e.domObserver.disconnectSelection(),e.cursorWrapper)!function(e){let t=e.domSelection();if(!t)return;let n=e.cursorWrapper.dom,o="IMG"==n.nodeName;o?t.collapse(n.parentNode,jr(n)+1):t.collapse(n,0),!o&&!e.state.selection.visible&&ai&&ci<=11&&(n.disabled=!0,n.disabled=!1)}(e);else{let o,r,{anchor:i,head:s}=n;!fs||n instanceof st||(n.$from.parent.inlineContent||(o=ms(e,n.from)),n.empty||n.$from.parent.inlineContent||(r=ms(e,n.to))),e.docView.setSelection(i,s,e,t),fs&&(o&&ys(o),r&&ys(r)),n.visible?e.dom.classList.remove("ProseMirror-hideselection"):(e.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&function(e){let t=e.dom.ownerDocument;t.removeEventListener("selectionchange",e.input.hideSelectionGuard);let n=e.domSelectionRange(),o=n.anchorNode,r=n.anchorOffset;t.addEventListener("selectionchange",e.input.hideSelectionGuard=()=>{n.anchorNode==o&&n.anchorOffset==r||(t.removeEventListener("selectionchange",e.input.hideSelectionGuard),setTimeout((()=>{ps(e)&&!e.state.selection.visible||e.dom.classList.remove("ProseMirror-hideselection")}),20))})}(e))}e.domObserver.setCurSelection(),e.domObserver.connectSelection()}}const fs=fi||pi&&ui<63;function ms(e,t){let{node:n,offset:o}=e.docView.domFromPos(t,0),r=o<n.childNodes.length?n.childNodes[o]:null,i=o?n.childNodes[o-1]:null;if(fi&&r&&"false"==r.contentEditable)return gs(r);if(!(r&&"false"!=r.contentEditable||i&&"false"!=i.contentEditable)){if(r)return gs(r);if(i)return gs(i)}}function gs(e){return e.contentEditable="true",fi&&e.draggable&&(e.draggable=!1,e.wasDraggable=!0),e}function ys(e){e.contentEditable="false",e.wasDraggable&&(e.draggable=!0,e.wasDraggable=null)}function ws(e,t){if(t instanceof at){let n=e.docView.descAt(t.from);n!=e.lastSelectedViewDesc&&(vs(e),n&&n.selectNode(),e.lastSelectedViewDesc=n)}else vs(e)}function vs(e){e.lastSelectedViewDesc&&(e.lastSelectedViewDesc.parent&&e.lastSelectedViewDesc.deselectNode(),e.lastSelectedViewDesc=void 0)}function bs(e,t,n,o){return e.someProp("createSelectionBetween",(o=>o(e,t,n)))||st.between(t,n,o)}function ks(e){return!(e.editable&&!e.hasFocus())&&xs(e)}function xs(e){let t=e.domSelectionRange();if(!t.anchorNode)return!1;try{return e.dom.contains(3==t.anchorNode.nodeType?t.anchorNode.parentNode:t.anchorNode)&&(e.editable||e.dom.contains(3==t.focusNode.nodeType?t.focusNode.parentNode:t.focusNode))}catch(e){return!1}}function Ss(e,t){let{$anchor:n,$head:o}=e.selection,r=t>0?n.max(o):n.min(o),i=r.parent.inlineContent?r.depth?e.doc.resolve(t>0?r.after():r.before()):null:r;return i&&nt.findFrom(i,t)}function Cs(e,t){return e.dispatch(e.state.tr.setSelection(t).scrollIntoView()),!0}function Ms(e,t,n){let o=e.state.selection;if(!(o instanceof st)){if(o instanceof at&&o.node.isInline)return Cs(e,new st(t>0?o.$to:o.$from));{let n=Ss(e.state,t);return!!n&&Cs(e,n)}}if(n.indexOf("s")>-1){let{$head:n}=o,r=n.textOffset?null:t<0?n.nodeBefore:n.nodeAfter;if(!r||r.isText||!r.isLeaf)return!1;let i=e.state.doc.resolve(n.pos+r.nodeSize*(t<0?-1:1));return Cs(e,new st(o.$anchor,i))}if(!o.empty)return!1;if(e.endOfTextblock(t>0?"forward":"backward")){let n=Ss(e.state,t);return!!(n&&n instanceof at)&&Cs(e,n)}if(!(gi&&n.indexOf("m")>-1)){let n,r=o.$head,i=r.textOffset?null:t<0?r.nodeBefore:r.nodeAfter;if(!i||i.isText)return!1;let s=t<0?r.pos-i.nodeSize:r.pos;return!!(i.isAtom||(n=e.docView.descAt(s))&&!n.contentDOM)&&(at.isSelectable(i)?Cs(e,new at(t<0?e.state.doc.resolve(r.pos-i.nodeSize):r)):!!vi&&Cs(e,new st(e.state.doc.resolve(t<0?s:s+i.nodeSize))))}}function Ns(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function Os(e,t){let n=e.pmViewDesc;return n&&0==n.size&&(t<0||e.nextSibling||"BR"!=e.nodeName)}function As(e,t){return t<0?function(e){let t=e.domSelectionRange(),n=t.focusNode,o=t.focusOffset;if(!n)return;let r,i,s=!1;for(di&&1==n.nodeType&&o<Ns(n)&&Os(n.childNodes[o],-1)&&(s=!0);;)if(o>0){if(1!=n.nodeType)break;{let e=n.childNodes[o-1];if(Os(e,-1))r=n,i=--o;else{if(3!=e.nodeType)break;n=e,o=n.nodeValue.length}}}else{if(Ts(n))break;{let t=n.previousSibling;for(;t&&Os(t,-1);)r=n.parentNode,i=jr(t),t=t.previousSibling;if(t)n=t,o=Ns(n);else{if(n=n.parentNode,n==e.dom)break;o=0}}}s?Ds(e,n,o):r&&Ds(e,r,i)}(e):function(e){let t=e.domSelectionRange(),n=t.focusNode,o=t.focusOffset;if(!n)return;let r,i,s=Ns(n);for(;;)if(o<s){if(1!=n.nodeType)break;if(!Os(n.childNodes[o],1))break;r=n,i=++o}else{if(Ts(n))break;{let t=n.nextSibling;for(;t&&Os(t,1);)r=t.parentNode,i=jr(t)+1,t=t.nextSibling;if(t)n=t,o=0,s=Ns(n);else{if(n=n.parentNode,n==e.dom)break;o=s=0}}}r&&Ds(e,r,i)}(e)}function Ts(e){let t=e.pmViewDesc;return t&&t.node&&t.node.isBlock}function Ds(e,t,n){if(3!=t.nodeType){let e,o;(o=function(e,t){for(;e&&t==e.childNodes.length&&!Zr(e);)t=jr(e)+1,e=e.parentNode;for(;e&&t<e.childNodes.length;){let n=e.childNodes[t];if(3==n.nodeType)return n;if(1==n.nodeType&&"false"==n.contentEditable)break;e=n,t=0}}(t,n))?(t=o,n=0):(e=function(e,t){for(;e&&!t&&!Zr(e);)t=jr(e),e=e.parentNode;for(;e&&t;){let n=e.childNodes[t-1];if(3==n.nodeType)return n;if(1==n.nodeType&&"false"==n.contentEditable)break;t=(e=n).childNodes.length}}(t,n))&&(t=e,n=e.nodeValue.length)}let o=e.domSelection();if(!o)return;if(ei(o)){let e=document.createRange();e.setEnd(t,n),e.setStart(t,n),o.removeAllRanges(),o.addRange(e)}else o.extend&&o.extend(t,n);e.domObserver.setCurSelection();let{state:r}=e;setTimeout((()=>{e.state==r&&us(e)}),50)}function Es(e,t){let n=e.state.doc.resolve(t);if(!pi&&!yi&&n.parent.inlineContent){let o=e.coordsAtPos(t);if(t>n.start()){let n=e.coordsAtPos(t-1),r=(n.top+n.bottom)/2;if(r>o.top&&r<o.bottom&&Math.abs(n.left-o.left)>1)return n.left<o.left?"ltr":"rtl"}if(t<n.end()){let n=e.coordsAtPos(t+1),r=(n.top+n.bottom)/2;if(r>o.top&&r<o.bottom&&Math.abs(n.left-o.left)>1)return n.left>o.left?"ltr":"rtl"}}return"rtl"==getComputedStyle(e.dom).direction?"rtl":"ltr"}function Rs(e,t,n){let o=e.state.selection;if(o instanceof st&&!o.empty||n.indexOf("s")>-1)return!1;if(gi&&n.indexOf("m")>-1)return!1;let{$from:r,$to:i}=o;if(!r.parent.inlineContent||e.endOfTextblock(t<0?"up":"down")){let n=Ss(e.state,t);if(n&&n instanceof at)return Cs(e,n)}if(!r.parent.inlineContent){let n=t<0?r:i,s=o instanceof dt?nt.near(n,t):nt.findFrom(n,t);return!!s&&Cs(e,s)}return!1}function $s(e,t){if(!(e.state.selection instanceof st))return!0;let{$head:n,$anchor:o,empty:r}=e.state.selection;if(!n.sameParent(o))return!0;if(!r)return!1;if(e.endOfTextblock(t>0?"forward":"backward"))return!0;let i=!n.textOffset&&(t<0?n.nodeBefore:n.nodeAfter);if(i&&!i.isText){let o=e.state.tr;return t<0?o.delete(n.pos-i.nodeSize,n.pos):o.delete(n.pos,n.pos+i.nodeSize),e.dispatch(o),!0}return!1}function Is(e,t,n){e.domObserver.stop(),t.contentEditable=n,e.domObserver.start()}function zs(e,t){e.someProp("transformCopied",(n=>{t=n(t,e)}));let n=[],{content:o,openStart:r,openEnd:i}=t;for(;r>1&&i>1&&1==o.childCount&&1==o.firstChild.childCount;){r--,i--;let e=o.firstChild;n.push(e.type.name,e.attrs!=e.type.defaultAttrs?e.attrs:null),o=e.content}let s=e.someProp("clipboardSerializer")||le.fromSchema(e.state.schema),l=js(),a=l.createElement("div");a.appendChild(s.serializeFragment(o,{document:l}));let c,d=a.firstChild,h=0;for(;d&&1==d.nodeType&&(c=Ws[d.nodeName.toLowerCase()]);){for(let e=c.length-1;e>=0;e--){let t=l.createElement(c[e]);for(;a.firstChild;)t.appendChild(a.firstChild);a.appendChild(t),h++}d=a.firstChild}return d&&1==d.nodeType&&d.setAttribute("data-pm-slice",`${r} ${i}${h?` -${h}`:""} ${JSON.stringify(n)}`),{dom:a,text:e.someProp("clipboardTextSerializer",(n=>n(t,e)))||t.content.textBetween(0,t.content.size,"\n\n"),slice:t}}function Bs(e,t,n,o,r){let i,l,a=r.parent.type.spec.code;if(!n&&!t)return null;let c=!!t&&(o||a||!n);if(c){if(e.someProp("transformPastedText",(n=>{t=n(t,a||o,e)})),a)return l=new p(s.from(e.state.schema.text(t.replace(/\r\n?/g,"\n"))),0,0),e.someProp("transformPasted",(t=>{l=t(l,e,!0)})),l;let n=e.someProp("clipboardTextParser",(n=>n(t,r,o,e)));if(n)l=n;else{let n=r.marks(),{schema:o}=e.state,s=le.fromSchema(o);i=document.createElement("div"),t.split(/(?:\r\n?|\n)+/).forEach((e=>{let t=i.appendChild(document.createElement("p"));e&&t.appendChild(s.serializeNode(o.text(e,n)))}))}}else e.someProp("transformPastedHTML",(t=>{n=t(n,e)})),i=function(e){let t=/^(\s*<meta [^>]*>)*/.exec(e);t&&(e=e.slice(t[0].length));let n,o=js().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(e);if((n=r&&Ws[r[1].toLowerCase()])&&(e=n.map((e=>"<"+e+">")).join("")+e+n.map((e=>"</"+e+">")).reverse().join("")),o.innerHTML=function(e){let t=window.trustedTypes;return t?(Js||(Js=t.defaultPolicy||t.createPolicy("ProseMirrorClipboard",{createHTML:e=>e})),Js.createHTML(e)):e}(e),n)for(let e=0;e<n.length;e++)o=o.querySelector(n[e])||o;return o}(n),vi&&function(e){let t=e.querySelectorAll(pi?"span:not([class]):not([style])":"span.Apple-converted-space");for(let n=0;n<t.length;n++){let o=t[n];1==o.childNodes.length&&" "==o.textContent&&o.parentNode&&o.parentNode.replaceChild(e.ownerDocument.createTextNode(" "),o)}}(i);let d=i&&i.querySelector("[data-pm-slice]"),h=d&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(d.getAttribute("data-pm-slice")||"");if(h&&h[3])for(let e=+h[3];e>0;e--){let e=i.firstChild;for(;e&&1!=e.nodeType;)e=e.nextSibling;if(!e)break;i=e}if(!l){let t=e.someProp("clipboardParser")||e.someProp("domParser")||G.fromSchema(e.state.schema);l=t.parseSlice(i,{preserveWhitespace:!(!c&&!h),context:r,ruleFromNode:e=>"BR"!=e.nodeName||e.nextSibling||!e.parentNode||Ps.test(e.parentNode.nodeName)?null:{ignore:!0}})}if(h)l=function(e,t){if(!e.size)return e;let n,o=e.content.firstChild.type.schema;try{n=JSON.parse(t)}catch(t){return e}let{content:r,openStart:i,openEnd:l}=e;for(let e=n.length-2;e>=0;e-=2){let t=o.nodes[n[e]];if(!t||t.hasRequiredAttrs())break;r=s.from(t.create(n[e+1],r)),i++,l++}return new p(r,i,l)}(_s(l,+h[1],+h[2]),h[4]);else if(l=p.maxOpen(function(e,t){if(e.childCount<2)return e;for(let n=t.depth;n>=0;n--){let o,r=t.node(n).contentMatchAt(t.index(n)),i=[];if(e.forEach((e=>{if(!i)return;let t,n=r.findWrapping(e.type);if(!n)return i=null;if(t=i.length&&o.length&&Fs(n,o,e,i[i.length-1],0))i[i.length-1]=t;else{i.length&&(i[i.length-1]=Ls(i[i.length-1],o.length));let t=Vs(e,n);i.push(t),r=r.matchType(t.type),o=n}})),i)return s.from(i)}return e}(l.content,r),!0),l.openStart||l.openEnd){let e=0,t=0;for(let t=l.content.firstChild;e<l.openStart&&!t.type.spec.isolating;e++,t=t.firstChild);for(let e=l.content.lastChild;t<l.openEnd&&!e.type.spec.isolating;t++,e=e.lastChild);l=_s(l,e,t)}return e.someProp("transformPasted",(t=>{l=t(l,e,c)})),l}const Ps=/^(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 Vs(e,t,n=0){for(let o=t.length-1;o>=n;o--)e=t[o].create(null,s.from(e));return e}function Fs(e,t,n,o,r){if(r<e.length&&r<t.length&&e[r]==t[r]){let i=Fs(e,t,n,o.lastChild,r+1);if(i)return o.copy(o.content.replaceChild(o.childCount-1,i));if(o.contentMatchAt(o.childCount).matchType(r==e.length-1?n.type:e[r+1]))return o.copy(o.content.append(s.from(Vs(n,e,r+1))))}}function Ls(e,t){if(0==t)return e;let n=e.content.replaceChild(e.childCount-1,Ls(e.lastChild,t-1)),o=e.contentMatchAt(e.childCount).fillBefore(s.empty,!0);return e.copy(n.append(o))}function Hs(e,t,n,o,r,i){let l=t<0?e.firstChild:e.lastChild,a=l.content;return e.childCount>1&&(i=0),r<o-1&&(a=Hs(a,t,n,o,r+1,i)),r>=n&&(a=t<0?l.contentMatchAt(0).fillBefore(a,i<=r).append(a):a.append(l.contentMatchAt(l.childCount).fillBefore(s.empty,!0))),e.replaceChild(t<0?0:e.childCount-1,l.copy(a))}function _s(e,t,n){return t<e.openStart&&(e=new p(Hs(e.content,-1,t,e.openStart,0,e.openEnd),t,e.openEnd)),n<e.openEnd&&(e=new p(Hs(e.content,1,n,e.openEnd,0,0),e.openStart,n)),e}const Ws={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};let qs=null;function js(){return qs||(qs=document.implementation.createHTMLDocument("title"))}let Js=null;const Ks={},Xs={},Us={touchstart:!0,touchmove:!0};class Ys{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:"",button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function Gs(e,t){e.input.lastSelectionOrigin=t,e.input.lastSelectionTime=Date.now()}function Qs(e){e.someProp("handleDOMEvents",(t=>{for(let n in t)e.input.eventHandlers[n]||e.dom.addEventListener(n,e.input.eventHandlers[n]=t=>Zs(e,t))}))}function Zs(e,t){return e.someProp("handleDOMEvents",(n=>{let o=n[t.type];return!!o&&(o(e,t)||t.defaultPrevented)}))}function el(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let n=t.target;n!=e.dom;n=n.parentNode)if(!n||11==n.nodeType||n.pmViewDesc&&n.pmViewDesc.stopEvent(t))return!1;return!0}function tl(e){return{left:e.clientX,top:e.clientY}}function nl(e,t,n,o,r){if(-1==o)return!1;let i=e.state.doc.resolve(o);for(let o=i.depth+1;o>0;o--)if(e.someProp(t,(t=>o>i.depth?t(e,n,i.nodeAfter,i.before(o),r,!0):t(e,n,i.node(o),i.before(o),r,!1))))return!0;return!1}function ol(e,t,n){if(e.focused||e.focus(),e.state.selection.eq(t))return;let o=e.state.tr.setSelection(t);"pointer"==n&&o.setMeta("pointer",!0),e.dispatch(o)}function rl(e,t,n,o){return nl(e,"handleDoubleClickOn",t,n,o)||e.someProp("handleDoubleClick",(n=>n(e,t,o)))}function il(e,t,n,o){return nl(e,"handleTripleClickOn",t,n,o)||e.someProp("handleTripleClick",(n=>n(e,t,o)))||function(e,t,n){if(0!=n.button)return!1;let o=e.state.doc;if(-1==t)return!!o.inlineContent&&(ol(e,st.create(o,0,o.content.size),"pointer"),!0);let r=o.resolve(t);for(let t=r.depth+1;t>0;t--){let n=t>r.depth?r.nodeAfter:r.node(t),i=r.before(t);if(n.inlineContent)ol(e,st.create(o,i+1,i+1+n.content.size),"pointer");else{if(!at.isSelectable(n))continue;ol(e,at.create(o,i),"pointer")}return!0}}(e,n,o)}function sl(e){return ul(e)}Xs.keydown=(e,t)=>{let n=t;if(e.input.shiftKey=16==n.keyCode||n.shiftKey,!cl(e,n)&&(e.input.lastKeyCode=n.keyCode,e.input.lastKeyCodeTime=Date.now(),!wi||!pi||13!=n.keyCode))if(229!=n.keyCode&&e.domObserver.forceFlush(),!mi||13!=n.keyCode||n.ctrlKey||n.altKey||n.metaKey)e.someProp("handleKeyDown",(t=>t(e,n)))||function(e,t){let n=t.keyCode,o=function(e){let t="";return e.ctrlKey&&(t+="c"),e.metaKey&&(t+="m"),e.altKey&&(t+="a"),e.shiftKey&&(t+="s"),t}(t);if(8==n||gi&&72==n&&"c"==o)return $s(e,-1)||As(e,-1);if(46==n&&!t.shiftKey||gi&&68==n&&"c"==o)return $s(e,1)||As(e,1);if(13==n||27==n)return!0;if(37==n||gi&&66==n&&"c"==o){let t=37==n?"ltr"==Es(e,e.state.selection.from)?-1:1:-1;return Ms(e,t,o)||As(e,t)}if(39==n||gi&&70==n&&"c"==o){let t=39==n?"ltr"==Es(e,e.state.selection.from)?1:-1:1;return Ms(e,t,o)||As(e,t)}return 38==n||gi&&80==n&&"c"==o?Rs(e,-1,o)||As(e,-1):40==n||gi&&78==n&&"c"==o?function(e){if(!fi||e.state.selection.$head.parentOffset>0)return!1;let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(t&&1==t.nodeType&&0==n&&t.firstChild&&"false"==t.firstChild.contentEditable){let n=t.firstChild;Is(e,n,"true"),setTimeout((()=>Is(e,n,"false")),20)}return!1}(e)||Rs(e,1,o)||As(e,1):o==(gi?"m":"c")&&(66==n||73==n||89==n||90==n)}(e,n)?n.preventDefault():Gs(e,"key");else{let t=Date.now();e.input.lastIOSEnter=t,e.input.lastIOSEnterFallbackTimeout=setTimeout((()=>{e.input.lastIOSEnter==t&&(e.someProp("handleKeyDown",(t=>t(e,ti(13,"Enter")))),e.input.lastIOSEnter=0)}),200)}},Xs.keyup=(e,t)=>{16==t.keyCode&&(e.input.shiftKey=!1)},Xs.keypress=(e,t)=>{let n=t;if(cl(e,n)||!n.charCode||n.ctrlKey&&!n.altKey||gi&&n.metaKey)return;if(e.someProp("handleKeyPress",(t=>t(e,n))))return void n.preventDefault();let o=e.state.selection;if(!(o instanceof st&&o.$from.sameParent(o.$to))){let t=String.fromCharCode(n.charCode),r=()=>e.state.tr.insertText(t).scrollIntoView();/[\r\n]/.test(t)||e.someProp("handleTextInput",(n=>n(e,o.$from.pos,o.$to.pos,t,r)))||e.dispatch(r()),n.preventDefault()}};const ll=gi?"metaKey":"ctrlKey";Ks.mousedown=(e,t)=>{let n=t;e.input.shiftKey=n.shiftKey;let o=sl(e),r=Date.now(),i="singleClick";r-e.input.lastClick.time<500&&function(e,t){let n=t.x-e.clientX,o=t.y-e.clientY;return n*n+o*o<100}(n,e.input.lastClick)&&!n[ll]&&e.input.lastClick.button==n.button&&("singleClick"==e.input.lastClick.type?i="doubleClick":"doubleClick"==e.input.lastClick.type&&(i="tripleClick")),e.input.lastClick={time:r,x:n.clientX,y:n.clientY,type:i,button:n.button};let s=e.posAtCoords(tl(n));s&&("singleClick"==i?(e.input.mouseDown&&e.input.mouseDown.done(),e.input.mouseDown=new al(e,s,n,!!o)):("doubleClick"==i?rl:il)(e,s.pos,s.inside,n)?n.preventDefault():Gs(e,"pointer"))};class al{constructor(e,t,n,o){let r,i;if(this.view=e,this.pos=t,this.event=n,this.flushed=o,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!n[ll],this.allowDefault=n.shiftKey,t.inside>-1)r=e.state.doc.nodeAt(t.inside),i=t.inside;else{let n=e.state.doc.resolve(t.pos);r=n.parent,i=n.depth?n.before():0}const s=o?null:n.target,l=s?e.docView.nearestDesc(s,!0):null;this.target=l&&1==l.nodeDOM.nodeType?l.nodeDOM:null;let{selection:a}=e.state;(0==n.button&&r.type.spec.draggable&&!1!==r.type.spec.selectable||a instanceof at&&a.from<=i&&a.to>i)&&(this.mightDrag={node:r,pos:i,addAttr:!(!this.target||this.target.draggable),setUneditable:!(!this.target||!di||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)),Gs(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((()=>us(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(tl(e))),this.updateAllowDefault(e),this.allowDefault||!t?Gs(this.view,"pointer"):function(e,t,n,o,r){return nl(e,"handleClickOn",t,n,o)||e.someProp("handleClick",(n=>n(e,t,o)))||(r?function(e,t){if(-1==t)return!1;let n,o,r=e.state.selection;r instanceof at&&(n=r.node);let i=e.state.doc.resolve(t);for(let e=i.depth+1;e>0;e--){let t=e>i.depth?i.nodeAfter:i.node(e);if(at.isSelectable(t)){o=n&&r.$from.depth>0&&e>=r.$from.depth&&i.before(r.$from.depth+1)==r.$from.pos?i.before(r.$from.depth):i.before(e);break}}return null!=o&&(ol(e,at.create(e.state.doc,o),"pointer"),!0)}(e,n):function(e,t){if(-1==t)return!1;let n=e.state.doc.resolve(t),o=n.nodeAfter;return!!(o&&o.isAtom&&at.isSelectable(o))&&(ol(e,new at(n),"pointer"),!0)}(e,n))}(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():0==e.button&&(this.flushed||fi&&this.mightDrag&&!this.mightDrag.node.isAtom||pi&&!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)?(ol(this.view,nt.near(this.view.state.doc.resolve(t.pos)),"pointer"),e.preventDefault()):Gs(this.view,"pointer")}move(e){this.updateAllowDefault(e),Gs(this.view,"pointer"),0==e.buttons&&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)}}function cl(e,t){return!!e.composing||!!(fi&&Math.abs(t.timeStamp-e.input.compositionEndedAt)<500)&&(e.input.compositionEndedAt=-2e8,!0)}Ks.touchstart=e=>{e.input.lastTouch=Date.now(),sl(e),Gs(e,"pointer")},Ks.touchmove=e=>{e.input.lastTouch=Date.now(),Gs(e,"pointer")},Ks.contextmenu=e=>sl(e);const dl=wi?5e3:-1;function hl(e,t){clearTimeout(e.input.composingTimeout),t>-1&&(e.input.composingTimeout=setTimeout((()=>ul(e)),t))}function pl(e){for(e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=function(){let e=document.createEvent("Event");return e.initEvent("event",!0,!0),e.timeStamp}());e.input.compositionNodes.length>0;)e.input.compositionNodes.pop().markParentsDirty()}function ul(e,t=!1){if(!(wi&&e.domObserver.flushingSoon>=0)){if(e.domObserver.forceFlush(),pl(e),t||e.docView&&e.docView.dirty){let n=hs(e),o=e.state.selection;return n&&!n.eq(o)?e.dispatch(e.state.tr.setSelection(n)):!e.markCursor&&!t||o.$from.node(o.$from.sharedDepth(o.to)).inlineContent?e.updateState(e.state):e.dispatch(e.state.tr.deleteSelection()),!0}return!1}}Xs.compositionstart=Xs.compositionupdate=e=>{if(!e.composing){e.domObserver.flush();let{state:t}=e,n=t.selection.$to;if(t.selection instanceof st&&(t.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some((e=>!1===e.type.spec.inclusive))))e.markCursor=e.state.storedMarks||n.marks(),ul(e,!0),e.markCursor=null;else if(ul(e,!t.selection.empty),di&&t.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let t=e.domSelectionRange();for(let n=t.focusNode,o=t.focusOffset;n&&1==n.nodeType&&0!=o;){let t=o<0?n.lastChild:n.childNodes[o-1];if(!t)break;if(3==t.nodeType){let n=e.domSelection();n&&n.collapse(t,t.nodeValue.length);break}n=t,o=-1}}e.input.composing=!0}hl(e,dl)},Xs.compositionend=(e,t)=>{e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=t.timeStamp,e.input.compositionPendingChanges=e.domObserver.pendingRecords().length?e.input.compositionID:0,e.input.compositionNode=null,e.input.compositionPendingChanges&&Promise.resolve().then((()=>e.domObserver.flush())),e.input.compositionID++,hl(e,20))};const fl=ai&&ci<15||mi&&bi<604;function ml(e,t,n,o,r){let i=Bs(e,t,n,o,e.state.selection.$from);if(e.someProp("handlePaste",(t=>t(e,r,i||p.empty))))return!0;if(!i)return!1;let s=function(e){return 0==e.openStart&&0==e.openEnd&&1==e.content.childCount?e.content.firstChild:null}(i),l=s?e.state.tr.replaceSelectionWith(s,o):e.state.tr.replaceSelection(i);return e.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function gl(e){let t=e.getData("text/plain")||e.getData("Text");if(t)return t;let n=e.getData("text/uri-list");return n?n.replace(/\r?\n/g," "):""}Ks.copy=Xs.cut=(e,t)=>{let n=t,o=e.state.selection,r="cut"==n.type;if(o.empty)return;let i=fl?null:n.clipboardData,s=o.content(),{dom:l,text:a}=zs(e,s);i?(n.preventDefault(),i.clearData(),i.setData("text/html",l.innerHTML),i.setData("text/plain",a)):function(e,t){if(!e.dom.parentNode)return;let n=e.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(t),n.style.cssText="position: fixed; left: -10000px; top: 10px";let o=getSelection(),r=document.createRange();r.selectNodeContents(t),e.dom.blur(),o.removeAllRanges(),o.addRange(r),setTimeout((()=>{n.parentNode&&n.parentNode.removeChild(n),e.focus()}),50)}(e,l),r&&e.dispatch(e.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))},Xs.paste=(e,t)=>{let n=t;if(e.composing&&!wi)return;let o=fl?null:n.clipboardData,r=e.input.shiftKey&&45!=e.input.lastKeyCode;o&&ml(e,gl(o),o.getData("text/html"),r,n)?n.preventDefault():function(e,t){if(!e.dom.parentNode)return;let n=e.input.shiftKey||e.state.selection.$from.parent.type.spec.code,o=e.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(o.contentEditable="true"),o.style.cssText="position: fixed; left: -10000px; top: 10px",o.focus();let r=e.input.shiftKey&&45!=e.input.lastKeyCode;setTimeout((()=>{e.focus(),o.parentNode&&o.parentNode.removeChild(o),n?ml(e,o.value,null,r,t):ml(e,o.textContent,o.innerHTML,r,t)}),50)}(e,n)};class yl{constructor(e,t,n){this.slice=e,this.move=t,this.node=n}}const wl=gi?"altKey":"ctrlKey";function vl(e,t){let n=e.someProp("dragCopies",(e=>!e(t)));return null!=n?n:!t[wl]}Ks.dragstart=(e,t)=>{let n=t,o=e.input.mouseDown;if(o&&o.done(),!n.dataTransfer)return;let r,i=e.state.selection,s=i.empty?null:e.posAtCoords(tl(n));if(s&&s.pos>=i.from&&s.pos<=(i instanceof at?i.to-1:i.to));else if(o&&o.mightDrag)r=at.create(e.state.doc,o.mightDrag.pos);else if(n.target&&1==n.target.nodeType){let t=e.docView.nearestDesc(n.target,!0);t&&t.node.type.spec.draggable&&t!=e.docView&&(r=at.create(e.state.doc,t.posBefore))}let l=(r||e.state.selection).content(),{dom:a,text:c,slice:d}=zs(e,l);(!n.dataTransfer.files.length||!pi||ui>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(fl?"Text":"text/html",a.innerHTML),n.dataTransfer.effectAllowed="copyMove",fl||n.dataTransfer.setData("text/plain",c),e.dragging=new yl(d,vl(e,n),r)},Ks.dragend=e=>{let t=e.dragging;window.setTimeout((()=>{e.dragging==t&&(e.dragging=null)}),50)},Xs.dragover=Xs.dragenter=(e,t)=>t.preventDefault(),Xs.drop=(e,t)=>{let n=t,o=e.dragging;if(e.dragging=null,!n.dataTransfer)return;let r=e.posAtCoords(tl(n));if(!r)return;let i=e.state.doc.resolve(r.pos),s=o&&o.slice;s?e.someProp("transformPasted",(t=>{s=t(s,e,!1)})):s=Bs(e,gl(n.dataTransfer),fl?null:n.dataTransfer.getData("text/html"),!1,i);let l=!(!o||!vl(e,n));if(e.someProp("handleDrop",(t=>t(e,n,s||p.empty,l))))return void n.preventDefault();if(!s)return;n.preventDefault();let a=s?Le(e.state.doc,i.pos,s):i.pos;null==a&&(a=i.pos);let c=e.state.tr;if(l){let{node:e}=o;e?e.replace(c):c.deleteSelection()}let d=c.mapping.map(a),h=0==s.openStart&&0==s.openEnd&&1==s.content.childCount,u=c.doc;if(h?c.replaceRangeWith(d,d,s.content.firstChild):c.replaceRange(d,d,s),c.doc.eq(u))return;let f=c.doc.resolve(d);if(h&&at.isSelectable(s.content.firstChild)&&f.nodeAfter&&f.nodeAfter.sameMarkup(s.content.firstChild))c.setSelection(new at(f));else{let t=c.mapping.map(a);c.mapping.maps[c.mapping.maps.length-1].forEach(((e,n,o,r)=>t=r)),c.setSelection(bs(e,f,c.doc.resolve(t)))}e.focus(),e.dispatch(c.setMeta("uiEvent","drop"))},Ks.focus=e=>{e.input.lastFocus=Date.now(),e.focused||(e.domObserver.stop(),e.dom.classList.add("ProseMirror-focused"),e.domObserver.start(),e.focused=!0,setTimeout((()=>{e.docView&&e.hasFocus()&&!e.domObserver.currentSelection.eq(e.domSelectionRange())&&us(e)}),20))},Ks.blur=(e,t)=>{let n=t;e.focused&&(e.domObserver.stop(),e.dom.classList.remove("ProseMirror-focused"),e.domObserver.start(),n.relatedTarget&&e.dom.contains(n.relatedTarget)&&e.domObserver.currentSelection.clear(),e.focused=!1)},Ks.beforeinput=(e,t)=>{if(pi&&wi&&"deleteContentBackward"==t.inputType){e.domObserver.flushSoon();let{domChangeCount:t}=e.input;setTimeout((()=>{if(e.input.domChangeCount!=t)return;if(e.dom.blur(),e.focus(),e.someProp("handleKeyDown",(t=>t(e,ti(8,"Backspace")))))return;let{$cursor:n}=e.state.selection;n&&n.pos>0&&e.dispatch(e.state.tr.delete(n.pos-1,n.pos).scrollIntoView())}),50)}};for(let e in Xs)Ks[e]=Xs[e];function bl(e,t){if(e==t)return!0;for(let n in e)if(e[n]!==t[n])return!1;for(let n in t)if(!(n in e))return!1;return!0}class kl{constructor(e,t){this.toDOM=e,this.spec=t||Nl,this.side=this.spec.side||0}map(e,t,n,o){let{pos:r,deleted:i}=e.mapResult(t.from+o,this.side<0?-1:1);return i?null:new Cl(r-n,r-n,this)}valid(){return!0}eq(e){return this==e||e instanceof kl&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&bl(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class xl{constructor(e,t){this.attrs=e,this.spec=t||Nl}map(e,t,n,o){let r=e.map(t.from+o,this.spec.inclusiveStart?-1:1)-n,i=e.map(t.to+o,this.spec.inclusiveEnd?1:-1)-n;return r>=i?null:new Cl(r,i,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof xl&&bl(this.attrs,e.attrs)&&bl(this.spec,e.spec)}static is(e){return e.type instanceof xl}destroy(){}}class Sl{constructor(e,t){this.attrs=e,this.spec=t||Nl}map(e,t,n,o){let r=e.mapResult(t.from+o,1);if(r.deleted)return null;let i=e.mapResult(t.to+o,-1);return i.deleted||i.pos<=r.pos?null:new Cl(r.pos-n,i.pos-n,this)}valid(e,t){let n,{index:o,offset:r}=e.content.findIndex(t.from);return r==t.from&&!(n=e.child(o)).isText&&r+n.nodeSize==t.to}eq(e){return this==e||e instanceof Sl&&bl(this.attrs,e.attrs)&&bl(this.spec,e.spec)}destroy(){}}class Cl{constructor(e,t,n){this.from=e,this.to=t,this.type=n}copy(e,t){return new Cl(e,t,this.type)}eq(e,t=0){return this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to}map(e,t,n){return this.type.map(e,this,t,n)}static widget(e,t,n){return new Cl(e,e,new kl(t,n))}static inline(e,t,n,o){return new Cl(e,t,new xl(n,o))}static node(e,t,n,o){return new Cl(e,t,new Sl(n,o))}get spec(){return this.type.spec}get inline(){return this.type instanceof xl}get widget(){return this.type instanceof kl}}const Ml=[],Nl={};class Ol{constructor(e,t){this.local=e.length?e:Ml,this.children=t.length?t:Ml}static create(e,t){return t.length?$l(t,e,0,Nl):Al}find(e,t,n){let o=[];return this.findInner(null==e?0:e,null==t?1e9:t,o,0,n),o}findInner(e,t,n,o,r){for(let i=0;i<this.local.length;i++){let s=this.local[i];s.from<=t&&s.to>=e&&(!r||r(s.spec))&&n.push(s.copy(s.from+o,s.to+o))}for(let i=0;i<this.children.length;i+=3)if(this.children[i]<t&&this.children[i+1]>e){let s=this.children[i]+1;this.children[i+2].findInner(e-s,t-s,n,o+s,r)}}map(e,t,n){return this==Al||0==e.maps.length?this:this.mapInner(e,t,0,0,n||Nl)}mapInner(e,t,n,o,r){let i;for(let s=0;s<this.local.length;s++){let l=this.local[s].map(e,n,o);l&&l.type.valid(t,l)?(i||(i=[])).push(l):r.onRemove&&r.onRemove(this.local[s].spec)}return this.children.length?function(e,t,n,o,r,i,s){let l=e.slice();for(let e=0,t=i;e<n.maps.length;e++){let o=0;n.maps[e].forEach(((e,n,r,i)=>{let s=i-r-(n-e);for(let r=0;r<l.length;r+=3){let i=l[r+1];if(i<0||e>i+t-o)continue;let a=l[r]+t-o;n>=a?l[r+1]=e<=a?-2:-1:e>=t&&s&&(l[r]+=s,l[r+1]+=s)}o+=s})),t=n.maps[e].map(t,-1)}let a=!1;for(let t=0;t<l.length;t+=3)if(l[t+1]<0){if(-2==l[t+1]){a=!0,l[t+1]=-1;continue}let c=n.map(e[t]+i),d=c-r;if(d<0||d>=o.content.size){a=!0;continue}let h=n.map(e[t+1]+i,-1)-r,{index:p,offset:u}=o.content.findIndex(d),f=o.maybeChild(p);if(f&&u==d&&u+f.nodeSize==h){let o=l[t+2].mapInner(n,f,c+1,e[t]+i+1,s);o!=Al?(l[t]=d,l[t+1]=h,l[t+2]=o):(l[t+1]=-2,a=!0)}else a=!0}if(a){let a=function(e,t,n,o,r,i,s){function l(e,t){for(let i=0;i<e.local.length;i++){let l=e.local[i].map(o,r,t);l?n.push(l):s.onRemove&&s.onRemove(e.local[i].spec)}for(let n=0;n<e.children.length;n+=3)l(e.children[n+2],e.children[n]+t+1)}for(let n=0;n<e.length;n+=3)-1==e[n+1]&&l(e[n+2],t[n]+i+1);return n}(l,e,t,n,r,i,s),c=$l(a,o,0,s);t=c.local;for(let e=0;e<l.length;e+=3)l[e+1]<0&&(l.splice(e,3),e-=3);for(let e=0,t=0;e<c.children.length;e+=3){let n=c.children[e];for(;t<l.length&&l[t]<n;)t+=3;l.splice(t,0,c.children[e],c.children[e+1],c.children[e+2])}}return new Ol(t.sort(Il),l)}(this.children,i||[],e,t,n,o,r):i?new Ol(i.sort(Il),Ml):Al}add(e,t){return t.length?this==Al?Ol.create(e,t):this.addInner(e,t,0):this}addInner(e,t,n){let o,r=0;e.forEach(((e,i)=>{let s,l=i+n;if(s=El(t,e,l)){for(o||(o=this.children.slice());r<o.length&&o[r]<i;)r+=3;o[r]==i?o[r+2]=o[r+2].addInner(e,s,l+1):o.splice(r,0,i,i+e.nodeSize,$l(s,e,l+1,Nl)),r+=3}}));let i=Dl(r?Rl(t):t,-n);for(let t=0;t<i.length;t++)i[t].type.valid(e,i[t])||i.splice(t--,1);return new Ol(i.length?this.local.concat(i).sort(Il):this.local,o||this.children)}remove(e){return 0==e.length||this==Al?this:this.removeInner(e,0)}removeInner(e,t){let n=this.children,o=this.local;for(let o=0;o<n.length;o+=3){let r,i=n[o]+t,s=n[o+1]+t;for(let t,n=0;n<e.length;n++)(t=e[n])&&t.from>i&&t.to<s&&(e[n]=null,(r||(r=[])).push(t));if(!r)continue;n==this.children&&(n=this.children.slice());let l=n[o+2].removeInner(r,i+1);l!=Al?n[o+2]=l:(n.splice(o,3),o-=3)}if(o.length)for(let n,r=0;r<e.length;r++)if(n=e[r])for(let e=0;e<o.length;e++)o[e].eq(n,t)&&(o==this.local&&(o=this.local.slice()),o.splice(e--,1));return n==this.children&&o==this.local?this:o.length||n.length?new Ol(o,n):Al}forChild(e,t){if(this==Al)return this;if(t.isLeaf)return Ol.empty;let n,o;for(let t=0;t<this.children.length;t+=3)if(this.children[t]>=e){this.children[t]==e&&(n=this.children[t+2]);break}let r=e+1,i=r+t.content.size;for(let e=0;e<this.local.length;e++){let t=this.local[e];if(t.from<i&&t.to>r&&t.type instanceof xl){let e=Math.max(r,t.from)-r,n=Math.min(i,t.to)-r;e<n&&(o||(o=[])).push(t.copy(e,n))}}if(o){let e=new Ol(o.sort(Il),Ml);return n?new Tl([e,n]):e}return n||Al}eq(e){if(this==e)return!0;if(!(e instanceof Ol)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let t=0;t<this.local.length;t++)if(!this.local[t].eq(e.local[t]))return!1;for(let t=0;t<this.children.length;t+=3)if(this.children[t]!=e.children[t]||this.children[t+1]!=e.children[t+1]||!this.children[t+2].eq(e.children[t+2]))return!1;return!0}locals(e){return zl(this.localsInner(e))}localsInner(e){if(this==Al)return Ml;if(e.inlineContent||!this.local.some(xl.is))return this.local;let t=[];for(let e=0;e<this.local.length;e++)this.local[e].type instanceof xl||t.push(this.local[e]);return t}forEachSet(e){e(this)}}Ol.empty=new Ol([],[]),Ol.removeOverlap=zl;const Al=Ol.empty;class Tl{constructor(e){this.members=e}map(e,t){const n=this.members.map((n=>n.map(e,t,Nl)));return Tl.from(n)}forChild(e,t){if(t.isLeaf)return Ol.empty;let n=[];for(let o=0;o<this.members.length;o++){let r=this.members[o].forChild(e,t);r!=Al&&(r instanceof Tl?n=n.concat(r.members):n.push(r))}return Tl.from(n)}eq(e){if(!(e instanceof Tl)||e.members.length!=this.members.length)return!1;for(let t=0;t<this.members.length;t++)if(!this.members[t].eq(e.members[t]))return!1;return!0}locals(e){let t,n=!0;for(let o=0;o<this.members.length;o++){let r=this.members[o].localsInner(e);if(r.length)if(t){n&&(t=t.slice(),n=!1);for(let e=0;e<r.length;e++)t.push(r[e])}else t=r}return t?zl(n?t:t.sort(Il)):Ml}static from(e){switch(e.length){case 0:return Al;case 1:return e[0];default:return new Tl(e.every((e=>e instanceof Ol))?e:e.reduce(((e,t)=>e.concat(t instanceof Ol?t:t.members)),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}}function Dl(e,t){if(!t||!e.length)return e;let n=[];for(let o=0;o<e.length;o++){let r=e[o];n.push(new Cl(r.from+t,r.to+t,r.type))}return n}function El(e,t,n){if(t.isLeaf)return null;let o=n+t.nodeSize,r=null;for(let t,i=0;i<e.length;i++)(t=e[i])&&t.from>n&&t.to<o&&((r||(r=[])).push(t),e[i]=null);return r}function Rl(e){let t=[];for(let n=0;n<e.length;n++)null!=e[n]&&t.push(e[n]);return t}function $l(e,t,n,o){let r=[],i=!1;t.forEach(((t,s)=>{let l=El(e,t,s+n);if(l){i=!0;let e=$l(l,t,n+s+1,o);e!=Al&&r.push(s,s+t.nodeSize,e)}}));let s=Dl(i?Rl(e):e,-n).sort(Il);for(let e=0;e<s.length;e++)s[e].type.valid(t,s[e])||(o.onRemove&&o.onRemove(s[e].spec),s.splice(e--,1));return s.length||r.length?new Ol(s,r):Al}function Il(e,t){return e.from-t.from||e.to-t.to}function zl(e){let t=e;for(let n=0;n<t.length-1;n++){let o=t[n];if(o.from!=o.to)for(let r=n+1;r<t.length;r++){let i=t[r];if(i.from!=o.from){i.from<o.to&&(t==e&&(t=e.slice()),t[n]=o.copy(o.from,i.from),Bl(t,r,o.copy(i.from,o.to)));break}i.to!=o.to&&(t==e&&(t=e.slice()),t[r]=i.copy(i.from,o.to),Bl(t,r+1,i.copy(o.to,i.to)))}}return t}function Bl(e,t,n){for(;t<e.length&&Il(n,e[t])>0;)t++;e.splice(t,0,n)}function Pl(e){let t=[];return e.someProp("decorations",(n=>{let o=n(e.state);o&&o!=Al&&t.push(o)})),e.cursorWrapper&&t.push(Ol.create(e.state.doc,[e.cursorWrapper.deco])),Tl.from(t)}const Vl={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},Fl=ai&&ci<=11;class Ll{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}}class Hl{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new Ll,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver((e=>{for(let t=0;t<e.length;t++)this.queue.push(e[t]);ai&&ci<=11&&e.some((e=>"childList"==e.type&&e.removedNodes.length||"characterData"==e.type&&e.oldValue.length>e.target.nodeValue.length))?this.flushSoon():this.flush()})),Fl&&(this.onCharData=e=>{this.queue.push({target:e.target,type:"characterData",oldValue:e.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout((()=>{this.flushingSoon=-1,this.flush()}),20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,Vl)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let t=0;t<e.length;t++)this.queue.push(e[t]);window.setTimeout((()=>this.flush()),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout((()=>this.suppressingSelectionUpdates=!1),50)}onSelectionChange(){if(ks(this.view)){if(this.suppressingSelectionUpdates)return us(this.view);if(ai&&ci<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Ur(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t,n=new Set;for(let t=e.focusNode;t;t=Jr(t))n.add(t);for(let o=e.anchorNode;o;o=Jr(o))if(n.has(o)){t=o;break}let o=t&&this.view.docView.nearestDesc(t);return o&&o.ignoreMutation({type:"selection",target:3==t.nodeType?t.parentNode:t})?(this.setCurSelection(),!0):void 0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.pendingRecords();t.length&&(this.queue=[]);let n=e.domSelectionRange(),o=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(n)&&ks(e)&&!this.ignoreSelectionChange(n),r=-1,i=-1,s=!1,l=[];if(e.editable)for(let e=0;e<t.length;e++){let n=this.registerMutation(t[e],l);n&&(r=r<0?n.from:Math.min(n.from,r),i=i<0?n.to:Math.max(n.to,i),n.typeOver&&(s=!0))}if(di&&l.length){let t=l.filter((e=>"BR"==e.nodeName));if(2==t.length){let[e,n]=t;e.parentNode&&e.parentNode.parentNode==n.parentNode?n.remove():e.remove()}else{let{focusNode:n}=this.currentSelection;for(let o of t){let t=o.parentNode;!t||"LI"!=t.nodeName||n&&jl(e,n)==t||o.remove()}}}let a=null;r<0&&o&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&ei(n)&&(a=hs(e))&&a.eq(nt.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,us(e),this.currentSelection.set(n),e.scrollToSelection()):(r>-1||o)&&(r>-1&&(e.docView.markDirty(r,i),function(e){if(!_l.has(e)&&(_l.set(e,null),-1!==["normal","nowrap","pre-line"].indexOf(getComputedStyle(e.dom).whiteSpace))){if(e.requiresGeckoHackNode=di,Wl)return;console.warn("ProseMirror expects the CSS white-space property to be set, preferably to 'pre-wrap'. It is recommended to load style/prosemirror.css from the prosemirror-view package."),Wl=!0}}(e)),this.handleDOMChange(r,i,s,l),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(n)||us(e),this.currentSelection.set(n))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let n=this.view.docView.nearestDesc(e.target);if("attributes"==e.type&&(n==this.view.docView||"contenteditable"==e.attributeName||"style"==e.attributeName&&!e.oldValue&&!e.target.getAttribute("style")))return null;if(!n||n.ignoreMutation(e))return null;if("childList"==e.type){for(let n=0;n<e.addedNodes.length;n++){let o=e.addedNodes[n];t.push(o),3==o.nodeType&&(this.lastChangedTextNode=o)}if(n.contentDOM&&n.contentDOM!=n.dom&&!n.contentDOM.contains(e.target))return{from:n.posBefore,to:n.posAfter};let o=e.previousSibling,r=e.nextSibling;if(ai&&ci<=11&&e.addedNodes.length)for(let t=0;t<e.addedNodes.length;t++){let{previousSibling:n,nextSibling:i}=e.addedNodes[t];(!n||Array.prototype.indexOf.call(e.addedNodes,n)<0)&&(o=n),(!i||Array.prototype.indexOf.call(e.addedNodes,i)<0)&&(r=i)}let i=o&&o.parentNode==e.target?jr(o)+1:0,s=n.localPosFromDOM(e.target,i,-1),l=r&&r.parentNode==e.target?jr(r):e.target.childNodes.length;return{from:s,to:n.localPosFromDOM(e.target,l,1)}}return"attributes"==e.type?{from:n.posAtStart-n.border,to:n.posAtEnd+n.border}:(this.lastChangedTextNode=e.target,{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let _l=new WeakMap,Wl=!1;function ql(e,t){let n=t.startContainer,o=t.startOffset,r=t.endContainer,i=t.endOffset,s=e.domAtPos(e.state.selection.anchor);return Ur(s.node,s.offset,r,i)&&([n,o,r,i]=[r,i,n,o]),{anchorNode:n,anchorOffset:o,focusNode:r,focusOffset:i}}function jl(e,t){for(let n=t.parentNode;n&&n!=e.dom;n=n.parentNode){let t=e.docView.nearestDesc(n,!0);if(t&&t.node.isBlock)return n}return null}function Jl(e){let t=e.pmViewDesc;if(t)return t.parseRule();if("BR"==e.nodeName&&e.parentNode){if(fi&&/^(ul|ol)$/i.test(e.parentNode.nodeName)){let e=document.createElement("div");return e.appendChild(document.createElement("li")),{skip:e}}if(e.parentNode.lastChild==e||fi&&/^(tr|table)$/i.test(e.parentNode.nodeName))return{ignore:!0}}else if("IMG"==e.nodeName&&e.getAttribute("mark-placeholder"))return{ignore:!0};return null}const Kl=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function Xl(e,t,n){return Math.max(n.anchor,n.head)>t.content.size?null:bs(e,t.resolve(n.anchor),t.resolve(n.head))}function Ul(e,t,n){let o=e.depth,r=t?e.end():e.pos;for(;o>0&&(t||e.indexAfter(o)==e.node(o).childCount);)o--,r++,t=!1;if(n){let t=e.node(o).maybeChild(e.indexAfter(o));for(;t&&!t.isLeaf;)t=t.firstChild,r++}return r}function Yl(e){if(2!=e.length)return!1;let t=e.charCodeAt(0),n=e.charCodeAt(1);return t>=56320&&t<=57343&&n>=55296&&n<=56319}const Gl=Bs,Ql=ul;class Zl{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 Ys,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(ra),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):"function"==typeof e?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=na(this),ta(this),this.nodeViews=oa(this),this.docView=Xi(this.state.doc,ea(this),Pl(this),this.dom,this),this.domObserver=new Hl(this,((e,t,n,o)=>function(e,t,n,o,r){let i=e.input.compositionPendingChanges||(e.composing?e.input.compositionID:0);if(e.input.compositionPendingChanges=0,t<0){let t=e.input.lastSelectionTime>Date.now()-50?e.input.lastSelectionOrigin:null,n=hs(e,t);if(n&&!e.state.selection.eq(n)){if(pi&&wi&&13===e.input.lastKeyCode&&Date.now()-100<e.input.lastKeyCodeTime&&e.someProp("handleKeyDown",(t=>t(e,ti(13,"Enter")))))return;let o=e.state.tr.setSelection(n);"pointer"==t?o.setMeta("pointer",!0):"key"==t&&o.scrollIntoView(),i&&o.setMeta("composition",i),e.dispatch(o)}return}let l=e.state.doc.resolve(t),a=l.sharedDepth(n);t=l.before(a+1),n=e.state.doc.resolve(n).after(a+1);let c,d,h=e.state.selection,p=function(e,t,n){let o,{node:r,fromOffset:i,toOffset:s,from:l,to:a}=e.docView.parseRange(t,n),c=e.domSelectionRange(),d=c.anchorNode;if(d&&e.dom.contains(1==d.nodeType?d:d.parentNode)&&(o=[{node:d,offset:c.anchorOffset}],ei(c)||o.push({node:c.focusNode,offset:c.focusOffset})),pi&&8===e.input.lastKeyCode)for(let e=s;e>i;e--){let t=r.childNodes[e-1],n=t.pmViewDesc;if("BR"==t.nodeName&&!n){s=e;break}if(!n||n.size)break}let h=e.state.doc,p=e.someProp("domParser")||G.fromSchema(e.state.schema),u=h.resolve(l),f=null,m=p.parse(r,{topNode:u.parent,topMatch:u.parent.contentMatchAt(u.index()),topOpen:!0,from:i,to:s,preserveWhitespace:"pre"!=u.parent.type.whitespace||"full",findPositions:o,ruleFromNode:Jl,context:u});if(o&&null!=o[0].pos){let e=o[0].pos,t=o[1]&&o[1].pos;null==t&&(t=e),f={anchor:e+l,head:t+l}}return{doc:m,sel:f,from:l,to:a}}(e,t,n),u=e.state.doc,f=u.slice(p.from,p.to);8===e.input.lastKeyCode&&Date.now()-100<e.input.lastKeyCodeTime?(c=e.state.selection.to,d="end"):(c=e.state.selection.from,d="start"),e.input.lastKeyCode=null;let m=function(e,t,n,o,r){let i=e.findDiffStart(t,n);if(null==i)return null;let{a:s,b:l}=e.findDiffEnd(t,n+e.size,n+t.size);if("end"==r&&(o-=s+Math.max(0,i-Math.min(s,l))-i),s<i&&e.size<t.size){let e=o<=i&&o>=s?i-o:0;i-=e,i&&i<t.size&&Yl(t.textBetween(i-1,i+1))&&(i+=e?1:-1),l=i+(l-s),s=i}else if(l<i){let t=o<=i&&o>=l?i-o:0;i-=t,i&&i<e.size&&Yl(e.textBetween(i-1,i+1))&&(i+=t?1:-1),s=i+(s-l),l=i}return{start:i,endA:s,endB:l}}(f.content,p.doc.content,p.from,c,d);if(m&&e.input.domChangeCount++,(mi&&e.input.lastIOSEnter>Date.now()-225||wi)&&r.some((e=>1==e.nodeType&&!Kl.test(e.nodeName)))&&(!m||m.endA>=m.endB)&&e.someProp("handleKeyDown",(t=>t(e,ti(13,"Enter")))))return void(e.input.lastIOSEnter=0);if(!m){if(!(o&&h instanceof st&&!h.empty&&h.$head.sameParent(h.$anchor))||e.composing||p.sel&&p.sel.anchor!=p.sel.head){if(p.sel){let t=Xl(e,e.state.doc,p.sel);if(t&&!t.eq(e.state.selection)){let n=e.state.tr.setSelection(t);i&&n.setMeta("composition",i),e.dispatch(n)}}return}m={start:h.from,endA:h.to,endB:h.to}}e.state.selection.from<e.state.selection.to&&m.start==m.endB&&e.state.selection instanceof st&&(m.start>e.state.selection.from&&m.start<=e.state.selection.from+2&&e.state.selection.from>=p.from?m.start=e.state.selection.from:m.endA<e.state.selection.to&&m.endA>=e.state.selection.to-2&&e.state.selection.to<=p.to&&(m.endB+=e.state.selection.to-m.endA,m.endA=e.state.selection.to)),ai&&ci<=11&&m.endB==m.start+1&&m.endA==m.start&&m.start>p.from&&"  "==p.doc.textBetween(m.start-p.from-1,m.start-p.from+1)&&(m.start--,m.endA--,m.endB--);let g=p.doc.resolveNoCache(m.start-p.from),y=p.doc.resolveNoCache(m.endB-p.from),w=u.resolve(m.start),v=g.sameParent(y)&&g.parent.inlineContent&&w.end()>=m.endA;if((mi&&e.input.lastIOSEnter>Date.now()-225&&(!v||r.some((e=>"DIV"==e.nodeName||"P"==e.nodeName)))||!v&&g.pos<p.doc.content.size&&(!g.sameParent(y)||!g.parent.inlineContent)&&g.pos<y.pos&&!/\S/.test(p.doc.textBetween(g.pos,y.pos,"","")))&&e.someProp("handleKeyDown",(t=>t(e,ti(13,"Enter")))))return void(e.input.lastIOSEnter=0);if(e.state.selection.anchor>m.start&&function(e,t,n,o,r){if(n-t<=r.pos-o.pos||Ul(o,!0,!1)<r.pos)return!1;let i=e.resolve(t);if(!o.parent.isTextblock){let e=i.nodeAfter;return null!=e&&n==t+e.nodeSize}if(i.parentOffset<i.parent.content.size||!i.parent.isTextblock)return!1;let s=e.resolve(Ul(i,!0,!0));return!(!s.parent.isTextblock||s.pos>n||Ul(s,!0,!1)<n)&&o.parent.content.cut(o.parentOffset).eq(s.parent.content)}(u,m.start,m.endA,g,y)&&e.someProp("handleKeyDown",(t=>t(e,ti(8,"Backspace")))))return void(wi&&pi&&e.domObserver.suppressSelectionUpdates());pi&&m.endB==m.start&&(e.input.lastChromeDelete=Date.now()),wi&&!v&&g.start()!=y.start()&&0==y.parentOffset&&g.depth==y.depth&&p.sel&&p.sel.anchor==p.sel.head&&p.sel.head==m.endA&&(m.endB-=2,y=p.doc.resolveNoCache(m.endB-p.from),setTimeout((()=>{e.someProp("handleKeyDown",(function(t){return t(e,ti(13,"Enter"))}))}),20));let b,k=m.start,x=m.endA,S=t=>{let n=t||e.state.tr.replace(k,x,p.doc.slice(m.start-p.from,m.endB-p.from));if(p.sel){let t=Xl(e,n.doc,p.sel);t&&!(pi&&e.composing&&t.empty&&(m.start!=m.endB||e.input.lastChromeDelete<Date.now()-100)&&(t.head==k||t.head==n.mapping.map(x)-1)||ai&&t.empty&&t.head==k)&&n.setSelection(t)}return i&&n.setMeta("composition",i),n.scrollIntoView()};if(v)if(g.pos==y.pos){ai&&ci<=11&&0==g.parentOffset&&(e.domObserver.suppressSelectionUpdates(),setTimeout((()=>us(e)),20));let t=S(e.state.tr.delete(k,x)),n=u.resolve(m.start).marksAcross(u.resolve(m.endA));n&&t.ensureMarks(n),e.dispatch(t)}else if(m.endA==m.endB&&(b=function(e,t){let n,o,r,i=e.firstChild.marks,l=t.firstChild.marks,a=i,c=l;for(let e=0;e<l.length;e++)a=l[e].removeFromSet(a);for(let e=0;e<i.length;e++)c=i[e].removeFromSet(c);if(1==a.length&&0==c.length)o=a[0],n="add",r=e=>e.mark(o.addToSet(e.marks));else{if(0!=a.length||1!=c.length)return null;o=c[0],n="remove",r=e=>e.mark(o.removeFromSet(e.marks))}let d=[];for(let e=0;e<t.childCount;e++)d.push(r(t.child(e)));if(s.from(d).eq(e))return{mark:o,type:n}}(g.parent.content.cut(g.parentOffset,y.parentOffset),w.parent.content.cut(w.parentOffset,m.endA-w.start())))){let t=S(e.state.tr);"add"==b.type?t.addMark(k,x,b.mark):t.removeMark(k,x,b.mark),e.dispatch(t)}else if(g.parent.child(g.index()).isText&&g.index()==y.index()-(y.textOffset?0:1)){let t=g.parent.textBetween(g.parentOffset,y.parentOffset),n=()=>S(e.state.tr.insertText(t,k,x));e.someProp("handleTextInput",(o=>o(e,k,x,t,n)))||e.dispatch(n())}else e.dispatch(S());else e.dispatch(S())}(this,e,t,n,o))),this.domObserver.start(),function(e){for(let t in Ks){let n=Ks[t];e.dom.addEventListener(t,e.input.eventHandlers[t]=t=>{!el(e,t)||Zs(e,t)||!e.editable&&t.type in Xs||n(e,t)},Us[t]?{passive:!0}:void 0)}fi&&e.dom.addEventListener("input",(()=>null)),Qs(e)}(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let t in e)this._props[t]=e[t];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&Qs(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(ra),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let e in this._props)t[e]=this._props[e];t.state=this.state;for(let n in e)t[n]=e[n];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var n;let o=this.state,r=!1,i=!1;e.storedMarks&&this.composing&&(pl(this),i=!0),this.state=e;let s=o.plugins!=e.plugins||this._props.plugins!=t.plugins;if(s||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let e=oa(this);(function(e,t){let n=0,o=0;for(let o in e){if(e[o]!=t[o])return!0;n++}for(let e in t)o++;return n!=o})(e,this.nodeViews)&&(this.nodeViews=e,r=!0)}(s||t.handleDOMEvents!=this._props.handleDOMEvents)&&Qs(this),this.editable=na(this),ta(this);let l=Pl(this),a=ea(this),c=o.plugins==e.plugins||o.doc.eq(e.doc)?e.scrollToSelection>o.scrollToSelection?"to selection":"preserve":"reset",d=r||!this.docView.matchesNode(e.doc,a,l);!d&&e.selection.eq(o.selection)||(i=!0);let h="preserve"==c&&i&&null==this.dom.style.overflowAnchor&&function(e){let t,n,o=e.dom.getBoundingClientRect(),r=Math.max(0,o.top);for(let i=(o.left+o.right)/2,s=r+1;s<Math.min(innerHeight,o.bottom);s+=5){let o=e.root.elementFromPoint(i,s);if(!o||o==e.dom||!e.dom.contains(o))continue;let l=o.getBoundingClientRect();if(l.top>=r-20){t=o,n=l.top;break}}return{refDOM:t,refTop:n,stack:Mi(e.dom)}}(this);if(i){this.domObserver.stop();let t=d&&(ai||pi)&&!this.composing&&!o.selection.empty&&!e.selection.empty&&function(e,t){let n=Math.min(e.$anchor.sharedDepth(e.head),t.$anchor.sharedDepth(t.head));return e.$anchor.start(n)!=t.$anchor.start(n)}(o.selection,e.selection);if(d){let n=pi?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=function(e){let t=e.domSelectionRange();if(!t.focusNode)return null;let n=function(e,t){for(;;){if(3==e.nodeType&&t)return e;if(1==e.nodeType&&t>0){if("false"==e.contentEditable)return null;t=Qr(e=e.childNodes[t-1])}else{if(!e.parentNode||Zr(e))return null;t=jr(e),e=e.parentNode}}}(t.focusNode,t.focusOffset),o=function(e,t){for(;;){if(3==e.nodeType&&t<e.nodeValue.length)return e;if(1==e.nodeType&&t<e.childNodes.length){if("false"==e.contentEditable)return null;e=e.childNodes[t],t=0}else{if(!e.parentNode||Zr(e))return null;t=jr(e)+1,e=e.parentNode}}}(t.focusNode,t.focusOffset);if(n&&o&&n!=o){let t=o.pmViewDesc,r=e.domObserver.lastChangedTextNode;if(n==r||o==r)return r;if(!t||!t.isText(o.nodeValue))return o;if(e.input.compositionNode==o){let e=n.pmViewDesc;if(e&&e.isText(n.nodeValue))return o}}return n||o}(this)),!r&&this.docView.update(e.doc,a,l,this)||(this.docView.updateOuterDeco(a),this.docView.destroy(),this.docView=Xi(e.doc,a,l,this.dom,this)),n&&!this.trackWrites&&(t=!0)}t||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&function(e){let t=e.docView.domFromPos(e.state.selection.anchor,0),n=e.domSelectionRange();return Ur(t.node,t.offset,n.anchorNode,n.anchorOffset)}(this))?us(this,t):(ws(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(o),(null===(n=this.dragging)||void 0===n?void 0:n.node)&&!o.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,o),"reset"==c?this.dom.scrollTop=0:"to selection"==c?this.scrollToSelection():h&&function({refDOM:e,refTop:t,stack:n}){let o=e?e.getBoundingClientRect().top:0;Ni(n,0==o?0:o-t)}(h)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(e&&this.dom.contains(1==e.nodeType?e:e.parentNode))if(this.someProp("handleScrollToSelection",(e=>e(this))));else if(this.state.selection instanceof at){let t=this.docView.domAfterPos(this.state.selection.from);1==t.nodeType&&Ci(this,t.getBoundingClientRect(),e)}else Ci(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)for(let t=0;t<this.pluginViews.length;t++){let n=this.pluginViews[t];n.update&&n.update(this,e)}else{this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let e=0;e<this.directPlugins.length;e++){let t=this.directPlugins[e];t.spec.view&&this.pluginViews.push(t.spec.view(this))}for(let e=0;e<this.state.plugins.length;e++){let t=this.state.plugins[e];t.spec.view&&this.pluginViews.push(t.spec.view(this))}}}updateDraggedNode(e,t){let n=e.node,o=-1;if(this.state.doc.nodeAt(n.from)==n.node)o=n.from;else{let e=n.from+(this.state.doc.content.size-t.doc.content.size);(e>0&&this.state.doc.nodeAt(e))==n.node&&(o=e)}this.dragging=new yl(e.slice,e.move,o<0?void 0:at.create(this.state.doc,o))}someProp(e,t){let n,o=this._props&&this._props[e];if(null!=o&&(n=t?t(o):o))return n;for(let o=0;o<this.directPlugins.length;o++){let r=this.directPlugins[o].props[e];if(null!=r&&(n=t?t(r):r))return n}let r=this.state.plugins;if(r)for(let o=0;o<r.length;o++){let i=r[o].props[e];if(null!=i&&(n=t?t(i):i))return n}}hasFocus(){if(ai){let e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if("false"==e.contentEditable)return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&function(e){if(e.setActive)return e.setActive();if(Oi)return e.focus(Oi);let t=Mi(e);e.focus(null==Oi?{get preventScroll(){return Oi={preventScroll:!0},!0}}:void 0),Oi||(Oi=!1,Ni(t,0))}(this.dom),us(this),this.domObserver.start()}get root(){let e=this._root;if(null==e)for(let e=this.dom.parentNode;e;e=e.parentNode)if(9==e.nodeType||11==e.nodeType&&e.host)return e.getSelection||(Object.getPrototypeOf(e).getSelection=()=>e.ownerDocument.getSelection()),this._root=e;return e||document}updateRoot(){this._root=null}posAtCoords(e){return Ei(this,e)}coordsAtPos(e,t=1){return zi(this,e,t)}domAtPos(e,t=0){return this.docView.domFromPos(e,t)}nodeDOM(e){let t=this.docView.descAt(e);return t?t.nodeDOM:null}posAtDOM(e,t,n=-1){let o=this.docView.posFromDOM(e,t,n);if(null==o)throw new RangeError("DOM position not inside the editor");return o}endOfTextblock(e,t){return function(e,t,n){return Li==t&&Hi==n?_i:(Li=t,Hi=n,_i="up"==n||"down"==n?function(e,t,n){let o=t.selection,r="up"==n?o.$from:o.$to;return Vi(e,t,(()=>{let{node:t}=e.docView.domFromPos(r.pos,"up"==n?-1:1);for(;;){let n=e.docView.nearestDesc(t,!0);if(!n)break;if(n.node.isBlock){t=n.contentDOM||n.dom;break}t=n.dom.parentNode}let o=zi(e,r.pos,1);for(let e=t.firstChild;e;e=e.nextSibling){let t;if(1==e.nodeType)t=e.getClientRects();else{if(3!=e.nodeType)continue;t=Xr(e,0,e.nodeValue.length).getClientRects()}for(let e=0;e<t.length;e++){let r=t[e];if(r.bottom>r.top+1&&("up"==n?o.top-r.top>2*(r.bottom-o.top):r.bottom-o.bottom>2*(o.bottom-r.top)))return!1}}return!0}))}(e,t,n):function(e,t,n){let{$head:o}=t.selection;if(!o.parent.isTextblock)return!1;let r=o.parentOffset,i=!r,s=r==o.parent.content.size,l=e.domSelection();return l?Fi.test(o.parent.textContent)&&l.modify?Vi(e,t,(()=>{let{focusNode:t,focusOffset:r,anchorNode:i,anchorOffset:s}=e.domSelectionRange(),a=l.caretBidiLevel;l.modify("move",n,"character");let c=o.depth?e.docView.domAfterPos(o.before()):e.dom,{focusNode:d,focusOffset:h}=e.domSelectionRange(),p=d&&!c.contains(1==d.nodeType?d:d.parentNode)||t==d&&r==h;try{l.collapse(i,s),t&&(t!=i||r!=s)&&l.extend&&l.extend(t,r)}catch(e){}return null!=a&&(l.caretBidiLevel=a),p})):"left"==n||"backward"==n?i:s:o.pos==o.start()||o.pos==o.end()}(e,t,n))}(this,t||this.state,e)}pasteHTML(e,t){return ml(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return ml(this,e,null,!0,t||new ClipboardEvent("paste"))}serializeForClipboard(e){return zs(this,e)}destroy(){this.docView&&(function(e){e.domObserver.stop();for(let t in e.input.eventHandlers)e.dom.removeEventListener(t,e.input.eventHandlers[t]);clearTimeout(e.input.composingTimeout),clearTimeout(e.input.lastIOSEnterFallbackTimeout)}(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Pl(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Kr=null)}get isDestroyed(){return null==this.docView}dispatchEvent(e){return function(e,t){Zs(e,t)||!Ks[t.type]||!e.editable&&t.type in Xs||Ks[t.type](e,t)}(this,e)}domSelectionRange(){let e=this.domSelection();return e?fi&&11===this.root.nodeType&&function(e){let t=e.activeElement;for(;t&&t.shadowRoot;)t=t.shadowRoot.activeElement;return t}(this.dom.ownerDocument)==this.dom&&function(e,t){if(t.getComposedRanges){let n=t.getComposedRanges(e.root)[0];if(n)return ql(e,n)}let n;function o(e){e.preventDefault(),e.stopImmediatePropagation(),n=e.getTargetRanges()[0]}return e.dom.addEventListener("beforeinput",o,!0),document.execCommand("indent"),e.dom.removeEventListener("beforeinput",o,!0),n?ql(e,n):null}(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}function ea(e){let t=Object.create(null);return t.class="ProseMirror",t.contenteditable=String(e.editable),e.someProp("attributes",(n=>{if("function"==typeof n&&(n=n(e.state)),n)for(let e in n)"class"==e?t.class+=" "+n[e]:"style"==e?t.style=(t.style?t.style+";":"")+n[e]:t[e]||"contenteditable"==e||"nodeName"==e||(t[e]=String(n[e]))})),t.translate||(t.translate="no"),[Cl.node(0,e.state.doc.content.size,t)]}function ta(e){if(e.markCursor){let t=document.createElement("img");t.className="ProseMirror-separator",t.setAttribute("mark-placeholder","true"),t.setAttribute("alt",""),e.cursorWrapper={dom:t,deco:Cl.widget(e.state.selection.from,t,{raw:!0,marks:e.markCursor})}}else e.cursorWrapper=null}function na(e){return!e.someProp("editable",(t=>!1===t(e.state)))}function oa(e){let t=Object.create(null);function n(e){for(let n in e)Object.prototype.hasOwnProperty.call(t,n)||(t[n]=e[n])}return e.someProp("nodeViews",n),e.someProp("markViews",n),t}function ra(e){if(e.spec.state||e.spec.filterTransaction||e.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}Zl.prototype.dispatch=function(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))};for(var ia={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:"'"},sa={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},la="undefined"!=typeof navigator&&/Mac/.test(navigator.platform),aa="undefined"!=typeof navigator&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),ca=0;ca<10;ca++)ia[48+ca]=ia[96+ca]=String(ca);for(ca=1;ca<=24;ca++)ia[ca+111]="F"+ca;for(ca=65;ca<=90;ca++)ia[ca]=String.fromCharCode(ca+32),sa[ca]=String.fromCharCode(ca);for(var da in ia)sa.hasOwnProperty(da)||(sa[da]=ia[da]);const ha="undefined"!=typeof navigator&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),pa="undefined"!=typeof navigator&&/Win/.test(navigator.platform);function ua(e){let t,n,o,r,i=e.split(/-(?!$)/),s=i[i.length-1];"Space"==s&&(s=" ");for(let e=0;e<i.length-1;e++){let s=i[e];if(/^(cmd|meta|m)$/i.test(s))r=!0;else if(/^a(lt)?$/i.test(s))t=!0;else if(/^(c|ctrl|control)$/i.test(s))n=!0;else if(/^s(hift)?$/i.test(s))o=!0;else{if(!/^mod$/i.test(s))throw new Error("Unrecognized modifier name: "+s);ha?r=!0:n=!0}}return t&&(s="Alt-"+s),n&&(s="Ctrl-"+s),r&&(s="Meta-"+s),o&&(s="Shift-"+s),s}function fa(e,t,n=!0){return t.altKey&&(e="Alt-"+e),t.ctrlKey&&(e="Ctrl-"+e),t.metaKey&&(e="Meta-"+e),n&&t.shiftKey&&(e="Shift-"+e),e}function ma(e){return new kt({props:{handleKeyDown:ga(e)}})}function ga(e){let t=function(e){let t=Object.create(null);for(let n in e)t[ua(n)]=e[n];return t}(e);return function(e,n){let o,r=function(e){var t=!(la&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||aa&&e.shiftKey&&e.key&&1==e.key.length||"Unidentified"==e.key)&&e.key||(e.shiftKey?sa:ia)[e.keyCode]||e.key||"Unidentified";return"Esc"==t&&(t="Escape"),"Del"==t&&(t="Delete"),"Left"==t&&(t="ArrowLeft"),"Up"==t&&(t="ArrowUp"),"Right"==t&&(t="ArrowRight"),"Down"==t&&(t="ArrowDown"),t}(n),i=t[fa(r,n)];if(i&&i(e.state,e.dispatch,e))return!0;if(1==r.length&&" "!=r){if(n.shiftKey){let o=t[fa(r,n,!1)];if(o&&o(e.state,e.dispatch,e))return!0}if((n.altKey||n.metaKey||n.ctrlKey)&&!(pa&&n.ctrlKey&&n.altKey)&&(o=ia[n.keyCode])&&o!=r){let r=t[fa(o,n)];if(r&&r(e.state,e.dispatch,e))return!0}}return!1}}var ya,wa;if("undefined"!=typeof WeakMap){let e=new WeakMap;ya=t=>e.get(t),wa=(t,n)=>(e.set(t,n),n)}else{const e=[],t=10;let n=0;ya=t=>{for(let n=0;n<e.length;n+=2)if(e[n]==t)return e[n+1]},wa=(o,r)=>(n==t&&(n=0),e[n++]=o,e[n++]=r)}var va=class{constructor(e,t,n,o){this.width=e,this.height=t,this.map=n,this.problems=o}findCell(e){for(let t=0;t<this.map.length;t++){const n=this.map[t];if(n!=e)continue;const o=t%this.width,r=t/this.width|0;let i=o+1,s=r+1;for(let e=1;i<this.width&&this.map[t+e]==n;e++)i++;for(let e=1;s<this.height&&this.map[t+this.width*e]==n;e++)s++;return{left:o,top:r,right:i,bottom:s}}throw new RangeError(`No cell with offset ${e} found`)}colCount(e){for(let t=0;t<this.map.length;t++)if(this.map[t]==e)return t%this.width;throw new RangeError(`No cell with offset ${e} found`)}nextCell(e,t,n){const{left:o,right:r,top:i,bottom:s}=this.findCell(e);return"horiz"==t?(n<0?0==o:r==this.width)?null:this.map[i*this.width+(n<0?o-1:r)]:(n<0?0==i:s==this.height)?null:this.map[o+this.width*(n<0?i-1:s)]}rectBetween(e,t){const{left:n,right:o,top:r,bottom:i}=this.findCell(e),{left:s,right:l,top:a,bottom:c}=this.findCell(t);return{left:Math.min(n,s),top:Math.min(r,a),right:Math.max(o,l),bottom:Math.max(i,c)}}cellsInRect(e){const t=[],n={};for(let o=e.top;o<e.bottom;o++)for(let r=e.left;r<e.right;r++){const i=o*this.width+r,s=this.map[i];n[s]||(n[s]=!0,r==e.left&&r&&this.map[i-1]==s||o==e.top&&o&&this.map[i-this.width]==s||t.push(s))}return t}positionAt(e,t,n){for(let o=0,r=0;;o++){const i=r+n.child(o).nodeSize;if(o==e){let n=t+e*this.width;const o=(e+1)*this.width;for(;n<o&&this.map[n]<r;)n++;return n==o?i-1:this.map[n]}r=i}}static get(e){return ya(e)||wa(e,function(e){if("table"!=e.type.spec.tableRole)throw new RangeError("Not a table node: "+e.type.name);const t=function(e){let t=-1,n=!1;for(let o=0;o<e.childCount;o++){const r=e.child(o);let i=0;if(n)for(let t=0;t<o;t++){const n=e.child(t);for(let e=0;e<n.childCount;e++){const r=n.child(e);t+r.attrs.rowspan>o&&(i+=r.attrs.colspan)}}for(let e=0;e<r.childCount;e++){const t=r.child(e);i+=t.attrs.colspan,t.attrs.rowspan>1&&(n=!0)}-1==t?t=i:t!=i&&(t=Math.max(t,i))}return t}(e),n=e.childCount,o=[];let r=0,i=null;const s=[];for(let e=0,r=t*n;e<r;e++)o[e]=0;for(let l=0,a=0;l<n;l++){const c=e.child(l);a++;for(let e=0;;e++){for(;r<o.length&&0!=o[r];)r++;if(e==c.childCount)break;const d=c.child(e),{colspan:h,rowspan:p,colwidth:u}=d.attrs;for(let e=0;e<p;e++){if(e+l>=n){(i||(i=[])).push({type:"overlong_rowspan",pos:a,n:p-e});break}const c=r+e*t;for(let e=0;e<h;e++){0==o[c+e]?o[c+e]=a:(i||(i=[])).push({type:"collision",row:l,pos:a,n:h-e});const n=u&&u[e];if(n){const o=(c+e)%t*2,r=s[o];null==r||r!=n&&1==s[o+1]?(s[o]=n,s[o+1]=1):r==n&&s[o+1]++}}}r+=h,a+=d.nodeSize}const d=(l+1)*t;let h=0;for(;r<d;)0==o[r++]&&h++;h&&(i||(i=[])).push({type:"missing",row:l,n:h}),a++}0!==t&&0!==n||(i||(i=[])).push({type:"zero_sized"});const l=new va(t,n,o,i);let a=!1;for(let e=0;!a&&e<s.length;e+=2)null!=s[e]&&s[e+1]<n&&(a=!0);return a&&function(e,t,n){e.problems||(e.problems=[]);const o={};for(let r=0;r<e.map.length;r++){const i=e.map[r];if(o[i])continue;o[i]=!0;const s=n.nodeAt(i);if(!s)throw new RangeError(`No cell with offset ${i} found`);let l=null;const a=s.attrs;for(let n=0;n<a.colspan;n++){const o=t[(r+n)%e.width*2];null==o||a.colwidth&&a.colwidth[n]==o||((l||(l=ba(a)))[n]=o)}l&&e.problems.unshift({type:"colwidth mismatch",pos:i,colwidth:l})}}(l,s,e),l}(e))}};function ba(e){if(e.colwidth)return e.colwidth.slice();const t=[];for(let n=0;n<e.colspan;n++)t.push(0);return t}function ka(e,t){if("string"==typeof e)return{};const n=e.getAttribute("data-colwidth"),o=n&&/^\d+(,\d+)*$/.test(n)?n.split(",").map((e=>Number(e))):null,r=Number(e.getAttribute("colspan")||1),i={colspan:r,rowspan:Number(e.getAttribute("rowspan")||1),colwidth:o&&o.length==r?o:null};for(const n in t){const o=t[n].getFromDOM,r=o&&o(e);null!=r&&(i[n]=r)}return i}function xa(e,t){const n={};1!=e.attrs.colspan&&(n.colspan=e.attrs.colspan),1!=e.attrs.rowspan&&(n.rowspan=e.attrs.rowspan),e.attrs.colwidth&&(n["data-colwidth"]=e.attrs.colwidth.join(","));for(const o in t){const r=t[o].setDOMAttr;r&&r(e.attrs[o],n)}return n}function Sa(e){if(null!==e){if(!Array.isArray(e))throw new TypeError("colwidth must be null or an array");for(const t of e)if("number"!=typeof t)throw new TypeError("colwidth must be null or an array of numbers")}}function Ca(e){const t=e.cellAttributes||{},n={colspan:{default:1,validate:"number"},rowspan:{default:1,validate:"number"},colwidth:{default:null,validate:Sa}};for(const e in t)n[e]={default:t[e].default,validate:t[e].validate};return{table:{content:"table_row+",tableRole:"table",isolating:!0,group:e.tableGroup,parseDOM:[{tag:"table"}],toDOM:()=>["table",["tbody",0]]},table_row:{content:"(table_cell | table_header)*",tableRole:"row",parseDOM:[{tag:"tr"}],toDOM:()=>["tr",0]},table_cell:{content:e.cellContent,attrs:n,tableRole:"cell",isolating:!0,parseDOM:[{tag:"td",getAttrs:e=>ka(e,t)}],toDOM:e=>["td",xa(e,t),0]},table_header:{content:e.cellContent,attrs:n,tableRole:"header_cell",isolating:!0,parseDOM:[{tag:"th",getAttrs:e=>ka(e,t)}],toDOM:e=>["th",xa(e,t),0]}}}function Ma(e){let t=e.cached.tableNodeTypes;if(!t){t=e.cached.tableNodeTypes={};for(const n in e.nodes){const o=e.nodes[n],r=o.spec.tableRole;r&&(t[r]=o)}}return t}var Na=new Ct("selectingCells");function Oa(e){for(let t=e.depth-1;t>0;t--)if("row"==e.node(t).type.spec.tableRole)return e.node(0).resolve(e.before(t+1));return null}function Aa(e){const t=e.selection.$head;for(let e=t.depth;e>0;e--)if("row"==t.node(e).type.spec.tableRole)return!0;return!1}function Ta(e){const t=e.selection;if("$anchorCell"in t&&t.$anchorCell)return t.$anchorCell.pos>t.$headCell.pos?t.$anchorCell:t.$headCell;if("node"in t&&t.node&&"cell"==t.node.type.spec.tableRole)return t.$anchor;const n=Oa(t.$head)||function(e){for(let t=e.nodeAfter,n=e.pos;t;t=t.firstChild,n++){const o=t.type.spec.tableRole;if("cell"==o||"header_cell"==o)return e.doc.resolve(n)}for(let t=e.nodeBefore,n=e.pos;t;t=t.lastChild,n--){const o=t.type.spec.tableRole;if("cell"==o||"header_cell"==o)return e.doc.resolve(n-t.nodeSize)}}(t.$head);if(n)return n;throw new RangeError(`No cell found around position ${t.head}`)}function Da(e){return"row"==e.parent.type.spec.tableRole&&!!e.nodeAfter}function Ea(e){return e.node(0).resolve(e.pos+e.nodeAfter.nodeSize)}function Ra(e,t){return e.depth==t.depth&&e.pos>=t.start(-1)&&e.pos<=t.end(-1)}function $a(e){return va.get(e.node(-1)).findCell(e.pos-e.start(-1))}function Ia(e){return va.get(e.node(-1)).colCount(e.pos-e.start(-1))}function za(e,t,n){const o=e.node(-1),r=va.get(o),i=e.start(-1),s=r.nextCell(e.pos-i,t,n);return null==s?null:e.node(0).resolve(i+s)}function Ba(e,t,n=1){const o={...e,colspan:e.colspan-n};return o.colwidth&&(o.colwidth=o.colwidth.slice(),o.colwidth.splice(t,n),o.colwidth.some((e=>e>0))||(o.colwidth=null)),o}function Pa(e,t,n=1){const o={...e,colspan:e.colspan+n};if(o.colwidth){o.colwidth=o.colwidth.slice();for(let e=0;e<n;e++)o.colwidth.splice(t,0,0)}return o}function Va(e,t,n){const o=Ma(t.type.schema).header_cell;for(let r=0;r<e.height;r++)if(t.nodeAt(e.map[n+r*e.width]).type!=o)return!1;return!0}var Fa=class e extends nt{constructor(e,t=e){const n=e.node(-1),o=va.get(n),r=e.start(-1),i=o.rectBetween(e.pos-r,t.pos-r),s=e.node(0),l=o.cellsInRect(i).filter((e=>e!=t.pos-r));l.unshift(t.pos-r);const a=l.map((e=>{const t=n.nodeAt(e);if(!t)throw RangeError(`No cell with offset ${e} found`);const o=r+e+1;return new ot(s.resolve(o),s.resolve(o+t.content.size))}));super(a[0].$from,a[0].$to,a),this.$anchorCell=e,this.$headCell=t}map(t,n){const o=t.resolve(n.map(this.$anchorCell.pos)),r=t.resolve(n.map(this.$headCell.pos));if(Da(o)&&Da(r)&&Ra(o,r)){const t=this.$anchorCell.node(-1)!=o.node(-1);return t&&this.isRowSelection()?e.rowSelection(o,r):t&&this.isColSelection()?e.colSelection(o,r):new e(o,r)}return st.between(o,r)}content(){const e=this.$anchorCell.node(-1),t=va.get(e),n=this.$anchorCell.start(-1),o=t.rectBetween(this.$anchorCell.pos-n,this.$headCell.pos-n),r={},i=[];for(let n=o.top;n<o.bottom;n++){const l=[];for(let i=n*t.width+o.left,s=o.left;s<o.right;s++,i++){const n=t.map[i];if(r[n])continue;r[n]=!0;const s=t.findCell(n);let a=e.nodeAt(n);if(!a)throw RangeError(`No cell with offset ${n} found`);const c=o.left-s.left,d=s.right-o.right;if(c>0||d>0){let e=a.attrs;if(c>0&&(e=Ba(e,0,c)),d>0&&(e=Ba(e,e.colspan-d,d)),s.left<o.left){if(a=a.type.createAndFill(e),!a)throw RangeError(`Could not create cell with attrs ${JSON.stringify(e)}`)}else a=a.type.create(e,a.content)}if(s.top<o.top||s.bottom>o.bottom){const e={...a.attrs,rowspan:Math.min(s.bottom,o.bottom)-Math.max(s.top,o.top)};a=s.top<o.top?a.type.createAndFill(e):a.type.create(e,a.content)}l.push(a)}i.push(e.child(n).copy(s.from(l)))}const l=this.isColSelection()&&this.isRowSelection()?e:i;return new p(s.from(l),1,1)}replace(e,t=p.empty){const n=e.steps.length,o=this.ranges;for(let r=0;r<o.length;r++){const{$from:i,$to:s}=o[r],l=e.mapping.slice(n);e.replace(l.map(i.pos),l.map(s.pos),r?p.empty:t)}const r=nt.findFrom(e.doc.resolve(e.mapping.slice(n).map(this.to)),-1);r&&e.setSelection(r)}replaceWith(e,t){this.replace(e,new p(s.from(t),0,0))}forEachCell(e){const t=this.$anchorCell.node(-1),n=va.get(t),o=this.$anchorCell.start(-1),r=n.cellsInRect(n.rectBetween(this.$anchorCell.pos-o,this.$headCell.pos-o));for(let n=0;n<r.length;n++)e(t.nodeAt(r[n]),o+r[n])}isColSelection(){const e=this.$anchorCell.index(-1),t=this.$headCell.index(-1);if(Math.min(e,t)>0)return!1;const n=e+this.$anchorCell.nodeAfter.attrs.rowspan,o=t+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(n,o)==this.$headCell.node(-1).childCount}static colSelection(t,n=t){const o=t.node(-1),r=va.get(o),i=t.start(-1),s=r.findCell(t.pos-i),l=r.findCell(n.pos-i),a=t.node(0);return s.top<=l.top?(s.top>0&&(t=a.resolve(i+r.map[s.left])),l.bottom<r.height&&(n=a.resolve(i+r.map[r.width*(r.height-1)+l.right-1]))):(l.top>0&&(n=a.resolve(i+r.map[l.left])),s.bottom<r.height&&(t=a.resolve(i+r.map[r.width*(r.height-1)+s.right-1]))),new e(t,n)}isRowSelection(){const e=this.$anchorCell.node(-1),t=va.get(e),n=this.$anchorCell.start(-1),o=t.colCount(this.$anchorCell.pos-n),r=t.colCount(this.$headCell.pos-n);if(Math.min(o,r)>0)return!1;const i=o+this.$anchorCell.nodeAfter.attrs.colspan,s=r+this.$headCell.nodeAfter.attrs.colspan;return Math.max(i,s)==t.width}eq(t){return t instanceof e&&t.$anchorCell.pos==this.$anchorCell.pos&&t.$headCell.pos==this.$headCell.pos}static rowSelection(t,n=t){const o=t.node(-1),r=va.get(o),i=t.start(-1),s=r.findCell(t.pos-i),l=r.findCell(n.pos-i),a=t.node(0);return s.left<=l.left?(s.left>0&&(t=a.resolve(i+r.map[s.top*r.width])),l.right<r.width&&(n=a.resolve(i+r.map[r.width*(l.top+1)-1]))):(l.left>0&&(n=a.resolve(i+r.map[l.top*r.width])),s.right<r.width&&(t=a.resolve(i+r.map[r.width*(s.top+1)-1]))),new e(t,n)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(t,n){return new e(t.resolve(n.anchor),t.resolve(n.head))}static create(t,n,o=n){return new e(t.resolve(n),t.resolve(o))}getBookmark(){return new La(this.$anchorCell.pos,this.$headCell.pos)}};Fa.prototype.visible=!1,nt.jsonID("cell",Fa);var La=class e{constructor(e,t){this.anchor=e,this.head=t}map(t){return new e(t.map(this.anchor),t.map(this.head))}resolve(e){const t=e.resolve(this.anchor),n=e.resolve(this.head);return"row"==t.parent.type.spec.tableRole&&"row"==n.parent.type.spec.tableRole&&t.index()<t.parent.childCount&&n.index()<n.parent.childCount&&Ra(t,n)?new Fa(t,n):nt.near(n,1)}};function Ha(e){if(!(e.selection instanceof Fa))return null;const t=[];return e.selection.forEachCell(((e,n)=>{t.push(Cl.node(n,n+e.nodeSize,{class:"selectedCell"}))})),Ol.create(e.doc,t)}var _a=new Ct("fix-tables");function Wa(e,t,n,o){const r=e.childCount,i=t.childCount;e:for(let s=0,l=0;s<i;s++){const i=t.child(s);for(let t=l,o=Math.min(r,s+3);t<o;t++)if(e.child(t)==i){l=t+1,n+=i.nodeSize;continue e}o(i,n),l<r&&e.child(l).sameMarkup(i)?Wa(e.child(l),i,n+1,o):i.nodesBetween(0,i.content.size,o,n+1),n+=i.nodeSize}}function qa(e,t){let n;const o=(t,o)=>{"table"==t.type.spec.tableRole&&(n=function(e,t,n,o){const r=va.get(t);if(!r.problems)return o;o||(o=e.tr);const i=[];for(let e=0;e<r.height;e++)i.push(0);for(let e=0;e<r.problems.length;e++){const s=r.problems[e];if("collision"==s.type){const e=t.nodeAt(s.pos);if(!e)continue;const r=e.attrs;for(let e=0;e<r.rowspan;e++)i[s.row+e]+=s.n;o.setNodeMarkup(o.mapping.map(n+1+s.pos),null,Ba(r,r.colspan-s.n,s.n))}else if("missing"==s.type)i[s.row]+=s.n;else if("overlong_rowspan"==s.type){const e=t.nodeAt(s.pos);if(!e)continue;o.setNodeMarkup(o.mapping.map(n+1+s.pos),null,{...e.attrs,rowspan:e.attrs.rowspan-s.n})}else if("colwidth mismatch"==s.type){const e=t.nodeAt(s.pos);if(!e)continue;o.setNodeMarkup(o.mapping.map(n+1+s.pos),null,{...e.attrs,colwidth:s.colwidth})}else if("zero_sized"==s.type){const e=o.mapping.map(n);o.delete(e,e+t.nodeSize)}}let s,l;for(let e=0;e<i.length;e++)i[e]&&(null==s&&(s=e),l=e);for(let a=0,c=n+1;a<r.height;a++){const n=t.child(a),r=c+n.nodeSize,d=i[a];if(d>0){let t="cell";n.firstChild&&(t=n.firstChild.type.spec.tableRole);const i=[];for(let n=0;n<d;n++){const n=Ma(e.schema)[t].createAndFill();n&&i.push(n)}const h=0!=a&&s!=a-1||l!=a?r-1:c+1;o.insert(o.mapping.map(h),i)}c=r}return o.setMeta(_a,{fixTables:!0})}(e,t,o,n))};return t?t.doc!=e.doc&&Wa(t.doc,e.doc,0,o):e.doc.descendants(o),n}function ja(e){const t=e.selection,n=Ta(e),o=n.node(-1),r=n.start(-1),i=va.get(o);return{...t instanceof Fa?i.rectBetween(t.$anchorCell.pos-r,t.$headCell.pos-r):i.findCell(n.pos-r),tableStart:r,map:i,table:o}}function Ja(e,{map:t,tableStart:n,table:o},r){let i=r>0?-1:0;Va(t,o,r+i)&&(i=0==r||r==t.width?null:0);for(let s=0;s<t.height;s++){const l=s*t.width+r;if(r>0&&r<t.width&&t.map[l-1]==t.map[l]){const i=t.map[l],a=o.nodeAt(i);e.setNodeMarkup(e.mapping.map(n+i),null,Pa(a.attrs,r-t.colCount(i))),s+=a.attrs.rowspan-1}else{const a=null==i?Ma(o.type.schema).cell:o.nodeAt(t.map[l+i]).type,c=t.positionAt(s,r,o);e.insert(e.mapping.map(n+c),a.createAndFill())}}return e}function Ka(e,t){if(!Aa(e))return!1;if(t){const n=ja(e);t(Ja(e.tr,n,n.left))}return!0}function Xa(e,t){if(!Aa(e))return!1;if(t){const n=ja(e);t(Ja(e.tr,n,n.right))}return!0}function Ua(e,{map:t,table:n,tableStart:o},r){const i=e.mapping.maps.length;for(let s=0;s<t.height;){const l=s*t.width+r,a=t.map[l],c=n.nodeAt(a),d=c.attrs;if(r>0&&t.map[l-1]==a||r<t.width-1&&t.map[l+1]==a)e.setNodeMarkup(e.mapping.slice(i).map(o+a),null,Ba(d,r-t.colCount(a)));else{const t=e.mapping.slice(i).map(o+a);e.delete(t,t+c.nodeSize)}s+=d.rowspan}}function Ya(e,t){if(!Aa(e))return!1;if(t){const n=ja(e),o=e.tr;if(0==n.left&&n.right==n.map.width)return!1;for(let e=n.right-1;Ua(o,n,e),e!=n.left;e--){const e=n.tableStart?o.doc.nodeAt(n.tableStart-1):o.doc;if(!e)throw RangeError("No table found");n.table=e,n.map=va.get(e)}t(o)}return!0}function Ga(e,t,n){var o;const r=Ma(t.type.schema).header_cell;for(let i=0;i<e.width;i++)if((null==(o=t.nodeAt(e.map[i+n*e.width]))?void 0:o.type)!=r)return!1;return!0}function Qa(e,{map:t,tableStart:n,table:o},r){var i;let s=n;for(let e=0;e<r;e++)s+=o.child(e).nodeSize;const l=[];let a=r>0?-1:0;Ga(t,o,r+a)&&(a=0==r||r==t.height?null:0);for(let s=0,c=t.width*r;s<t.width;s++,c++)if(r>0&&r<t.height&&t.map[c]==t.map[c-t.width]){const r=t.map[c],i=o.nodeAt(r).attrs;e.setNodeMarkup(n+r,null,{...i,rowspan:i.rowspan+1}),s+=i.colspan-1}else{const e=null==a?Ma(o.type.schema).cell:null==(i=o.nodeAt(t.map[c+a*t.width]))?void 0:i.type,n=null==e?void 0:e.createAndFill();n&&l.push(n)}return e.insert(s,Ma(o.type.schema).row.create(null,l)),e}function Za(e,t){if(!Aa(e))return!1;if(t){const n=ja(e);t(Qa(e.tr,n,n.top))}return!0}function ec(e,t){if(!Aa(e))return!1;if(t){const n=ja(e);t(Qa(e.tr,n,n.bottom))}return!0}function tc(e,{map:t,table:n,tableStart:o},r){let i=0;for(let e=0;e<r;e++)i+=n.child(e).nodeSize;const s=i+n.child(r).nodeSize,l=e.mapping.maps.length;e.delete(i+o,s+o);const a=new Set;for(let i=0,s=r*t.width;i<t.width;i++,s++){const c=t.map[s];if(!a.has(c))if(a.add(c),r>0&&c==t.map[s-t.width]){const t=n.nodeAt(c).attrs;e.setNodeMarkup(e.mapping.slice(l).map(c+o),null,{...t,rowspan:t.rowspan-1}),i+=t.colspan-1}else if(r<t.height&&c==t.map[s+t.width]){const s=n.nodeAt(c),a=s.attrs,d=s.type.create({...a,rowspan:s.attrs.rowspan-1},s.content),h=t.positionAt(r+1,i,n);e.insert(e.mapping.slice(l).map(o+h),d),i+=a.colspan-1}}}function nc(e,t){if(!Aa(e))return!1;if(t){const n=ja(e),o=e.tr;if(0==n.top&&n.bottom==n.map.height)return!1;for(let e=n.bottom-1;tc(o,n,e),e!=n.top;e--){const e=n.tableStart?o.doc.nodeAt(n.tableStart-1):o.doc;if(!e)throw RangeError("No table found");n.table=e,n.map=va.get(n.table)}t(o)}return!0}function oc(e){const t=e.content;return 1==t.childCount&&t.child(0).isTextblock&&0==t.child(0).childCount}function rc(e,t){const n=e.selection;if(!(n instanceof Fa)||n.$anchorCell.pos==n.$headCell.pos)return!1;const o=ja(e),{map:r}=o;if(function({width:e,height:t,map:n},o){let r=o.top*e+o.left,i=r,s=(o.bottom-1)*e+o.left,l=r+(o.right-o.left-1);for(let t=o.top;t<o.bottom;t++){if(o.left>0&&n[i]==n[i-1]||o.right<e&&n[l]==n[l+1])return!0;i+=e,l+=e}for(let i=o.left;i<o.right;i++){if(o.top>0&&n[r]==n[r-e]||o.bottom<t&&n[s]==n[s+e])return!0;r++,s++}return!1}(r,o))return!1;if(t){const n=e.tr,i={};let l,a,c=s.empty;for(let e=o.top;e<o.bottom;e++)for(let t=o.left;t<o.right;t++){const s=r.map[e*r.width+t],d=o.table.nodeAt(s);if(!i[s]&&d)if(i[s]=!0,null==l)l=s,a=d;else{oc(d)||(c=c.append(d.content));const e=n.mapping.map(s+o.tableStart);n.delete(e,e+d.nodeSize)}}if(null==l||null==a)return!0;if(n.setNodeMarkup(l+o.tableStart,null,{...Pa(a.attrs,a.attrs.colspan,o.right-o.left-a.attrs.colspan),rowspan:o.bottom-o.top}),c.size){const e=l+1+a.content.size,t=oc(a)?l+1:e;n.replaceWith(t+o.tableStart,e+o.tableStart,c)}n.setSelection(new Fa(n.doc.resolve(l+o.tableStart))),t(n)}return!0}function ic(e,t){const n=Ma(e.schema);return sc((({node:e})=>n[e.type.spec.tableRole]))(e,t)}function sc(e){return(t,n)=>{var o;const r=t.selection;let i,s;if(r instanceof Fa){if(r.$anchorCell.pos!=r.$headCell.pos)return!1;i=r.$anchorCell.nodeAfter,s=r.$anchorCell.pos}else{if(i=function(e){for(let t=e.depth;t>0;t--){const n=e.node(t).type.spec.tableRole;if("cell"===n||"header_cell"===n)return e.node(t)}return null}(r.$from),!i)return!1;s=null==(o=Oa(r.$from))?void 0:o.pos}if(null==i||null==s)return!1;if(1==i.attrs.colspan&&1==i.attrs.rowspan)return!1;if(n){let o=i.attrs;const l=[],a=o.colwidth;o.rowspan>1&&(o={...o,rowspan:1}),o.colspan>1&&(o={...o,colspan:1});const c=ja(t),d=t.tr;for(let e=0;e<c.right-c.left;e++)l.push(a?{...o,colwidth:a&&a[e]?[a[e]]:null}:o);let h;for(let t=c.top;t<c.bottom;t++){let n=c.map.positionAt(t,c.left,c.table);t==c.top&&(n+=i.nodeSize);for(let o=c.left,r=0;o<c.right;o++,r++)o==c.left&&t==c.top||d.insert(h=d.mapping.map(n+c.tableStart,1),e({node:i,row:t,col:o}).createAndFill(l[r]))}d.setNodeMarkup(s,e({node:i,row:c.top,col:c.left}),l[0]),r instanceof Fa&&d.setSelection(new Fa(d.doc.resolve(r.$anchorCell.pos),h?d.doc.resolve(h):void 0)),n(d)}return!0}}function lc(e,t){return function(n,o){if(!Aa(n))return!1;const r=Ta(n);if(r.nodeAfter.attrs[e]===t)return!1;if(o){const i=n.tr;n.selection instanceof Fa?n.selection.forEachCell(((n,o)=>{n.attrs[e]!==t&&i.setNodeMarkup(o,null,{...n.attrs,[e]:t})})):i.setNodeMarkup(r.pos,null,{...r.nodeAfter.attrs,[e]:t}),o(i)}return!0}}function ac(e,t,n){const o=t.map.cellsInRect({left:0,top:0,right:"row"==e?t.map.width:1,bottom:"column"==e?t.map.height:1});for(let e=0;e<o.length;e++){const r=t.table.nodeAt(o[e]);if(r&&r.type!==n.header_cell)return!1}return!0}function cc(e,t){return(t=t||{useDeprecatedLogic:!1}).useDeprecatedLogic?function(e){return function(t,n){if(!Aa(t))return!1;if(n){const o=Ma(t.schema),r=ja(t),i=t.tr,s=r.map.cellsInRect("column"==e?{left:r.left,top:0,right:r.right,bottom:r.map.height}:"row"==e?{left:0,top:r.top,right:r.map.width,bottom:r.bottom}:r),l=s.map((e=>r.table.nodeAt(e)));for(let e=0;e<s.length;e++)l[e].type==o.header_cell&&i.setNodeMarkup(r.tableStart+s[e],o.cell,l[e].attrs);if(0==i.steps.length)for(let e=0;e<s.length;e++)i.setNodeMarkup(r.tableStart+s[e],o.header_cell,l[e].attrs);n(i)}return!0}}(e):function(t,n){if(!Aa(t))return!1;if(n){const o=Ma(t.schema),r=ja(t),i=t.tr,s=ac("row",r,o),l=ac("column",r,o),a=("column"===e?s:"row"===e&&l)?1:0,c="column"==e?{left:0,top:a,right:1,bottom:r.map.height}:"row"==e?{left:a,top:0,right:r.map.width,bottom:1}:r,d="column"==e?l?o.cell:o.header_cell:"row"==e?s?o.cell:o.header_cell:o.cell;r.map.cellsInRect(c).forEach((e=>{const t=e+r.tableStart,n=i.doc.nodeAt(t);n&&i.setNodeMarkup(t,d,n.attrs)})),n(i)}return!0}}var dc=cc("row",{useDeprecatedLogic:!0}),hc=cc("column",{useDeprecatedLogic:!0}),pc=cc("cell",{useDeprecatedLogic:!0});function uc(e){return function(t,n){if(!Aa(t))return!1;const o=function(e,t){if(t<0){const t=e.nodeBefore;if(t)return e.pos-t.nodeSize;for(let t=e.index(-1)-1,n=e.before();t>=0;t--){const o=e.node(-1).child(t),r=o.lastChild;if(r)return n-1-r.nodeSize;n-=o.nodeSize}}else{if(e.index()<e.parent.childCount-1)return e.pos+e.nodeAfter.nodeSize;const t=e.node(-1);for(let n=e.indexAfter(-1),o=e.after();n<t.childCount;n++){const e=t.child(n);if(e.childCount)return o+1;o+=e.nodeSize}}return null}(Ta(t),e);if(null==o)return!1;if(n){const e=t.doc.resolve(o);n(t.tr.setSelection(st.between(e,Ea(e))).scrollIntoView())}return!0}}function fc(e,t){const n=e.selection.$anchor;for(let o=n.depth;o>0;o--)if("table"==n.node(o).type.spec.tableRole)return t&&t(e.tr.delete(n.before(o),n.after(o)).scrollIntoView()),!0;return!1}function mc(e,t){const n=e.selection;if(!(n instanceof Fa))return!1;if(t){const o=e.tr,r=Ma(e.schema).cell.createAndFill().content;n.forEachCell(((e,t)=>{e.content.eq(r)||o.replace(o.mapping.map(t+1),o.mapping.map(t+e.nodeSize-1),new p(r,0,0))})),o.docChanged&&t(o)}return!0}function gc(e,t){const n=e.createAndFill();return new et(n).replace(0,n.content.size,t).doc}function yc(e,t,n,o,r,i,s,l){if(0==s||s==t.height)return!1;let a=!1;for(let c=r;c<i;c++){const r=s*t.width+c,i=t.map[r];if(t.map[r-t.width]==i){a=!0;const r=n.nodeAt(i),{top:d,left:h}=t.findCell(i);e.setNodeMarkup(e.mapping.slice(l).map(i+o),null,{...r.attrs,rowspan:s-d}),e.insert(e.mapping.slice(l).map(t.positionAt(s,h,n)),r.type.createAndFill({...r.attrs,rowspan:d+r.attrs.rowspan-s})),c+=r.attrs.colspan-1}}return a}function wc(e,t,n,o,r,i,s,l){if(0==s||s==t.width)return!1;let a=!1;for(let c=r;c<i;c++){const r=c*t.width+s,i=t.map[r];if(t.map[r-1]==i){a=!0;const r=n.nodeAt(i),d=t.colCount(i),h=e.mapping.slice(l).map(i+o);e.setNodeMarkup(h,null,Ba(r.attrs,s-d,r.attrs.colspan-(s-d))),e.insert(h+r.nodeSize,r.type.createAndFill(Ba(r.attrs,0,s-d))),c+=r.attrs.rowspan-1}}return a}function vc(e,t,n,o,r){let i=n?e.doc.nodeAt(n-1):e.doc;if(!i)throw new Error("No table found");let l=va.get(i);const{top:a,left:c}=o,d=c+r.width,h=a+r.height,u=e.tr;let f=0;function m(){if(i=n?u.doc.nodeAt(n-1):u.doc,!i)throw new Error("No table found");l=va.get(i),f=u.mapping.maps.length}(function(e,t,n,o,r,i,l){const a=Ma(e.doc.type.schema);let c,d;if(r>t.width)for(let i=0,s=0;i<t.height;i++){const h=n.child(i);s+=h.nodeSize;const p=[];let u;u=null==h.lastChild||h.lastChild.type==a.cell?c||(c=a.cell.createAndFill()):d||(d=a.header_cell.createAndFill());for(let e=t.width;e<r;e++)p.push(u);e.insert(e.mapping.slice(l).map(s-1+o),p)}if(i>t.height){const h=[];for(let e=0,o=(t.height-1)*t.width;e<Math.max(t.width,r);e++){const r=!(e>=t.width)&&n.nodeAt(t.map[o+e]).type==a.header_cell;h.push(r?d||(d=a.header_cell.createAndFill()):c||(c=a.cell.createAndFill()))}const p=a.row.create(null,s.from(h)),u=[];for(let e=t.height;e<i;e++)u.push(p);e.insert(e.mapping.slice(l).map(o+n.nodeSize-2),u)}return!(!c&&!d)})(u,l,i,n,d,h,f)&&m(),yc(u,l,i,n,c,d,a,f)&&m(),yc(u,l,i,n,c,d,h,f)&&m(),wc(u,l,i,n,a,h,c,f)&&m(),wc(u,l,i,n,a,h,d,f)&&m();for(let e=a;e<h;e++){const t=l.positionAt(e,c,i),o=l.positionAt(e,d,i);u.replace(u.mapping.slice(f).map(t+n),u.mapping.slice(f).map(o+n),new p(r.rows[e-a],0,0))}m(),u.setSelection(new Fa(u.doc.resolve(n+l.positionAt(a,c,i)),u.doc.resolve(n+l.positionAt(h-1,d-1,i)))),t(u)}var bc=ga({ArrowLeft:xc("horiz",-1),ArrowRight:xc("horiz",1),ArrowUp:xc("vert",-1),ArrowDown:xc("vert",1),"Shift-ArrowLeft":Sc("horiz",-1),"Shift-ArrowRight":Sc("horiz",1),"Shift-ArrowUp":Sc("vert",-1),"Shift-ArrowDown":Sc("vert",1),Backspace:mc,"Mod-Backspace":mc,Delete:mc,"Mod-Delete":mc});function kc(e,t,n){return!n.eq(e.selection)&&(t&&t(e.tr.setSelection(n).scrollIntoView()),!0)}function xc(e,t){return(n,o,r)=>{if(!r)return!1;const i=n.selection;if(i instanceof Fa)return kc(n,o,nt.near(i.$headCell,t));if("horiz"!=e&&!i.empty)return!1;const s=Oc(r,e,t);if(null==s)return!1;if("horiz"==e)return kc(n,o,nt.near(n.doc.resolve(i.head+t),t));{const r=n.doc.resolve(s),i=za(r,e,t);let l;return l=i?nt.near(i,1):t<0?nt.near(n.doc.resolve(r.before(-1)),-1):nt.near(n.doc.resolve(r.after(-1)),1),kc(n,o,l)}}}function Sc(e,t){return(n,o,r)=>{if(!r)return!1;const i=n.selection;let s;if(i instanceof Fa)s=i;else{const o=Oc(r,e,t);if(null==o)return!1;s=new Fa(n.doc.resolve(o))}const l=za(s.$headCell,e,t);return!!l&&kc(n,o,new Fa(s.$anchorCell,l))}}function Cc(e,t){const n=Oa(e.state.doc.resolve(t));return!!n&&(e.dispatch(e.state.tr.setSelection(new Fa(n))),!0)}function Mc(e,t,n){if(!Aa(e.state))return!1;let o=function(e){if(!e.size)return null;let{content:t,openStart:n,openEnd:o}=e;for(;1==t.childCount&&(n>0&&o>0||"table"==t.child(0).type.spec.tableRole);)n--,o--,t=t.child(0).content;const r=t.child(0),i=r.type.spec.tableRole,l=r.type.schema,a=[];if("row"==i)for(let e=0;e<t.childCount;e++){let r=t.child(e).content;const i=e?0:Math.max(0,n-1),s=e<t.childCount-1?0:Math.max(0,o-1);(i||s)&&(r=gc(Ma(l).row,new p(r,i,s)).content),a.push(r)}else{if("cell"!=i&&"header_cell"!=i)return null;a.push(n||o?gc(Ma(l).row,new p(t,n,o)).content:t)}return function(e,t){const n=[];for(let e=0;e<t.length;e++){const o=t[e];for(let t=o.childCount-1;t>=0;t--){const{rowspan:r,colspan:i}=o.child(t).attrs;for(let t=e;t<e+r;t++)n[t]=(n[t]||0)+i}}let o=0;for(let e=0;e<n.length;e++)o=Math.max(o,n[e]);for(let r=0;r<n.length;r++)if(r>=t.length&&t.push(s.empty),n[r]<o){const i=Ma(e).cell.createAndFill(),l=[];for(let e=n[r];e<o;e++)l.push(i);t[r]=t[r].append(s.from(l))}return{height:t.length,width:o,rows:t}}(l,a)}(n);const r=e.state.selection;if(r instanceof Fa){o||(o={width:1,height:1,rows:[s.from(gc(Ma(e.state.schema).cell,n))]});const t=r.$anchorCell.node(-1),i=r.$anchorCell.start(-1),l=va.get(t).rectBetween(r.$anchorCell.pos-i,r.$headCell.pos-i);return o=function({width:e,height:t,rows:n},o,r){if(e!=o){const t=[],r=[];for(let e=0;e<n.length;e++){const i=n[e],l=[];for(let n=t[e]||0,r=0;n<o;r++){let s=i.child(r%i.childCount);n+s.attrs.colspan>o&&(s=s.type.createChecked(Ba(s.attrs,s.attrs.colspan,n+s.attrs.colspan-o),s.content)),l.push(s),n+=s.attrs.colspan;for(let n=1;n<s.attrs.rowspan;n++)t[e+n]=(t[e+n]||0)+s.attrs.colspan}r.push(s.from(l))}n=r,e=o}if(t!=r){const e=[];for(let o=0,i=0;o<r;o++,i++){const l=[],a=n[i%t];for(let e=0;e<a.childCount;e++){let t=a.child(e);o+t.attrs.rowspan>r&&(t=t.type.create({...t.attrs,rowspan:Math.max(1,r-t.attrs.rowspan)},t.content)),l.push(t)}e.push(s.from(l))}n=e,t=r}return{width:e,height:t,rows:n}}(o,l.right-l.left,l.bottom-l.top),vc(e.state,e.dispatch,i,l,o),!0}if(o){const t=Ta(e.state),n=t.start(-1);return vc(e.state,e.dispatch,n,va.get(t.node(-1)).findCell(t.pos-n),o),!0}return!1}function Nc(e,t){var n;if(t.ctrlKey||t.metaKey)return;const o=Ac(e,t.target);let r;if(t.shiftKey&&e.state.selection instanceof Fa)i(e.state.selection.$anchorCell,t),t.preventDefault();else if(t.shiftKey&&o&&null!=(r=Oa(e.state.selection.$anchor))&&(null==(n=Tc(e,t))?void 0:n.pos)!=r.pos)i(r,t),t.preventDefault();else if(!o)return;function i(t,n){let o=Tc(e,n);const r=null==Na.getState(e.state);if(!o||!Ra(t,o)){if(!r)return;o=t}const i=new Fa(t,o);if(r||!e.state.selection.eq(i)){const n=e.state.tr.setSelection(i);r&&n.setMeta(Na,t.pos),e.dispatch(n)}}function s(){e.root.removeEventListener("mouseup",s),e.root.removeEventListener("dragstart",s),e.root.removeEventListener("mousemove",l),null!=Na.getState(e.state)&&e.dispatch(e.state.tr.setMeta(Na,-1))}function l(n){const r=n,l=Na.getState(e.state);let a;if(null!=l)a=e.state.doc.resolve(l);else if(Ac(e,r.target)!=o&&(a=Tc(e,t),!a))return s();a&&i(a,r)}e.root.addEventListener("mouseup",s),e.root.addEventListener("dragstart",s),e.root.addEventListener("mousemove",l)}function Oc(e,t,n){if(!(e.state.selection instanceof st))return null;const{$head:o}=e.state.selection;for(let r=o.depth-1;r>=0;r--){const i=o.node(r);if((n<0?o.index(r):o.indexAfter(r))!=(n<0?0:i.childCount))return null;if("cell"==i.type.spec.tableRole||"header_cell"==i.type.spec.tableRole){const i=o.before(r),s="vert"==t?n>0?"down":"up":n>0?"right":"left";return e.endOfTextblock(s)?i:null}}return null}function Ac(e,t){for(;t&&t!=e.dom;t=t.parentNode)if("TD"==t.nodeName||"TH"==t.nodeName)return t;return null}function Tc(e,t){const n=e.posAtCoords({left:t.clientX,top:t.clientY});return n&&n?Oa(e.state.doc.resolve(n.pos)):null}var Dc=class{constructor(e,t){this.node=e,this.defaultCellMinWidth=t,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.table.style.setProperty("--default-cell-min-width",`${t}px`),this.colgroup=this.table.appendChild(document.createElement("colgroup")),Ec(e,this.colgroup,this.table,t),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type==this.node.type&&(this.node=e,Ec(e,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(e){return"attributes"==e.type&&(e.target==this.table||this.colgroup.contains(e.target))}};function Ec(e,t,n,o,r,i){var s;let l=0,a=!0,c=t.firstChild;const d=e.firstChild;if(d){for(let e=0,n=0;e<d.childCount;e++){const{colspan:s,colwidth:h}=d.child(e).attrs;for(let e=0;e<s;e++,n++){const s=r==n?i:h&&h[e],d=s?s+"px":"";if(l+=s||o,s||(a=!1),c)c.style.width!=d&&(c.style.width=d),c=c.nextSibling;else{const e=document.createElement("col");e.style.width=d,t.appendChild(e)}}}for(;c;){const e=c.nextSibling;null==(s=c.parentNode)||s.removeChild(c),c=e}a?(n.style.width=l+"px",n.style.minWidth=""):(n.style.width="",n.style.minWidth=l+"px")}}var Rc=new Ct("tableColumnResizing");function $c({handleWidth:e=5,cellMinWidth:t=25,defaultCellMinWidth:n=100,View:o=Dc,lastColumnResizable:r=!0}={}){const i=new kt({key:Rc,state:{init(e,t){var r,s;const l=null==(s=null==(r=i.spec)?void 0:r.props)?void 0:s.nodeViews,a=Ma(t.schema).table.name;return o&&l&&(l[a]=(e,t)=>new o(e,n,t)),new Ic(-1,!1)},apply:(e,t)=>t.apply(e)},props:{attributes:e=>{const t=Rc.getState(e);return t&&t.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(t,n)=>{!function(e,t,n,o){if(!e.editable)return;const r=Rc.getState(e.state);if(r&&!r.dragging){const i=function(e){for(;e&&"TD"!=e.nodeName&&"TH"!=e.nodeName;)e=e.classList&&e.classList.contains("ProseMirror")?null:e.parentNode;return e}(t.target);let s=-1;if(i){const{left:o,right:r}=i.getBoundingClientRect();t.clientX-o<=n?s=zc(e,t,"left",n):r-t.clientX<=n&&(s=zc(e,t,"right",n))}if(s!=r.activeHandle){if(!o&&-1!==s){const t=e.state.doc.resolve(s),n=t.node(-1),o=va.get(n),r=t.start(-1);if(o.colCount(t.pos-r)+t.nodeAfter.attrs.colspan-1==o.width-1)return}Pc(e,s)}}}(t,n,e,r)},mouseleave:e=>{!function(e){if(!e.editable)return;const t=Rc.getState(e.state);t&&t.activeHandle>-1&&!t.dragging&&Pc(e,-1)}(e)},mousedown:(e,o)=>{!function(e,t,n,o){var r;if(!e.editable)return!1;const i=null!=(r=e.dom.ownerDocument.defaultView)?r:window,s=Rc.getState(e.state);if(!s||-1==s.activeHandle||s.dragging)return!1;const l=e.state.doc.nodeAt(s.activeHandle),a=function(e,t,{colspan:n,colwidth:o}){const r=o&&o[o.length-1];if(r)return r;const i=e.domAtPos(t);let s=i.node.childNodes[i.offset].offsetWidth,l=n;if(o)for(let e=0;e<n;e++)o[e]&&(s-=o[e],l--);return s/l}(e,s.activeHandle,l.attrs);function c(t){i.removeEventListener("mouseup",c),i.removeEventListener("mousemove",d);const o=Rc.getState(e.state);(null==o?void 0:o.dragging)&&(function(e,t,n){const o=e.state.doc.resolve(t),r=o.node(-1),i=va.get(r),s=o.start(-1),l=i.colCount(o.pos-s)+o.nodeAfter.attrs.colspan-1,a=e.state.tr;for(let e=0;e<i.height;e++){const t=e*i.width+l;if(e&&i.map[t]==i.map[t-i.width])continue;const o=i.map[t],d=r.nodeAt(o).attrs,h=1==d.colspan?0:l-i.colCount(o);if(d.colwidth&&d.colwidth[h]==n)continue;const p=d.colwidth?d.colwidth.slice():(c=d.colspan,Array(c).fill(0));p[h]=n,a.setNodeMarkup(s+o,null,{...d,colwidth:p})}var c;a.docChanged&&e.dispatch(a)}(e,o.activeHandle,Bc(o.dragging,t,n)),e.dispatch(e.state.tr.setMeta(Rc,{setDragging:null})))}function d(t){if(!t.which)return c(t);const r=Rc.getState(e.state);if(r&&r.dragging){const i=Bc(r.dragging,t,n);Vc(e,r.activeHandle,i,o)}}e.dispatch(e.state.tr.setMeta(Rc,{setDragging:{startX:t.clientX,startWidth:a}})),Vc(e,s.activeHandle,a,o),i.addEventListener("mouseup",c),i.addEventListener("mousemove",d),t.preventDefault()}(e,o,t,n)}},decorations:e=>{const t=Rc.getState(e);if(t&&t.activeHandle>-1)return function(e,t){var n;const o=[],r=e.doc.resolve(t),i=r.node(-1);if(!i)return Ol.empty;const s=va.get(i),l=r.start(-1),a=s.colCount(r.pos-l)+r.nodeAfter.attrs.colspan-1;for(let t=0;t<s.height;t++){const r=a+t*s.width;if(!(a!=s.width-1&&s.map[r]==s.map[r+1]||0!=t&&s.map[r]==s.map[r-s.width])){const t=s.map[r],a=l+t+i.nodeAt(t).nodeSize-1,c=document.createElement("div");c.className="column-resize-handle",(null==(n=Rc.getState(e))?void 0:n.dragging)&&o.push(Cl.node(l+t,l+t+i.nodeAt(t).nodeSize,{class:"column-resize-dragging"})),o.push(Cl.widget(a,c))}}return Ol.create(e.doc,o)}(e,t.activeHandle)},nodeViews:{}}});return i}var Ic=class e{constructor(e,t){this.activeHandle=e,this.dragging=t}apply(t){const n=this,o=t.getMeta(Rc);if(o&&null!=o.setHandle)return new e(o.setHandle,!1);if(o&&void 0!==o.setDragging)return new e(n.activeHandle,o.setDragging);if(n.activeHandle>-1&&t.docChanged){let o=t.mapping.map(n.activeHandle,-1);return Da(t.doc.resolve(o))||(o=-1),new e(o,n.dragging)}return n}};function zc(e,t,n,o){const r="right"==n?-o:o,i=e.posAtCoords({left:t.clientX+r,top:t.clientY});if(!i)return-1;const{pos:s}=i,l=Oa(e.state.doc.resolve(s));if(!l)return-1;if("right"==n)return l.pos;const a=va.get(l.node(-1)),c=l.start(-1),d=a.map.indexOf(l.pos-c);return d%a.width==0?-1:c+a.map[d-1]}function Bc(e,t,n){const o=t.clientX-e.startX;return Math.max(n,e.startWidth+o)}function Pc(e,t){e.dispatch(e.state.tr.setMeta(Rc,{setHandle:t}))}function Vc(e,t,n,o){const r=e.state.doc.resolve(t),i=r.node(-1),s=r.start(-1),l=va.get(i).colCount(r.pos-s)+r.nodeAfter.attrs.colspan-1;let a=e.domAtPos(r.start(-1)).node;for(;a&&"TABLE"!=a.nodeName;)a=a.parentNode;a&&Ec(i,a.firstChild,a,o,l,n)}function Fc({allowTableNodeSelection:e=!1}={}){return new kt({key:Na,state:{init:()=>null,apply(e,t){const n=e.getMeta(Na);if(null!=n)return-1==n?null:n;if(null==t||!e.docChanged)return t;const{deleted:o,pos:r}=e.mapping.mapResult(t);return o?null:r}},props:{decorations:Ha,handleDOMEvents:{mousedown:Nc},createSelectionBetween:e=>null!=Na.getState(e.state)?e.state.selection:null,handleTripleClick:Cc,handleKeyDown:bc,handlePaste:Mc},appendTransaction:(t,n,o)=>function(e,t,n){const o=(t||e).selection,r=(t||e).doc;let i,s;if(o instanceof at&&(s=o.node.type.spec.tableRole)){if("cell"==s||"header_cell"==s)i=Fa.create(r,o.from);else if("row"==s){const e=r.resolve(o.from+1);i=Fa.rowSelection(e,e)}else if(!n){const e=va.get(o.node),t=o.from+1,n=t+e.map[e.width*e.height-1];i=Fa.create(r,t+1,n)}}else o instanceof st&&function({$from:e,$to:t}){if(e.pos==t.pos||e.pos<t.pos-6)return!1;let n=e.pos,o=t.pos,r=e.depth;for(;r>=0&&!(e.after(r+1)<e.end(r));r--,n++);for(let e=t.depth;e>=0&&!(t.before(e+1)>t.start(e));e--,o--);return n==o&&/row|table/.test(e.node(r).type.spec.tableRole)}(o)?i=st.create(r,o.from):o instanceof st&&function({$from:e,$to:t}){let n,o;for(let t=e.depth;t>0;t--){const o=e.node(t);if("cell"===o.type.spec.tableRole||"header_cell"===o.type.spec.tableRole){n=o;break}}for(let e=t.depth;e>0;e--){const n=t.node(e);if("cell"===n.type.spec.tableRole||"header_cell"===n.type.spec.tableRole){o=n;break}}return n!==o&&0===t.parentOffset}(o)&&(i=st.create(r,o.$from.start(),o.$from.end()));return i&&(t||(t=e.tr)).setSelection(i),t}(o,qa(o,n),e)})}const Lc=["blockquote",0],Hc=["hr"],_c=["pre",["code",0]],Wc=["ol",0],qc=["ul",0],jc=["li",0],Jc=e=>{const t={},n=e.attributes;let o;for(let e=0;e<n.length;e++)o=n[e],t[o.name]=o.value;return t},Kc=e=>{const t={};return e.forEach((e=>{t[e]={default:null}})),t},Xc=()=>Kc(["style","class","id"]),Uc=(e,t)=>{for(const n in e)if(n&&null!==e[n]&&n!==t)return!0;return!1},Yc=(e,t=[])=>{const n={};for(const o in e)o&&null!==e[o]&&!t.find((e=>e===o))&&(n[o]=e[o]);return n},Gc=e=>({[e]:{name:e,inclusive:!0,parseDOM:[{tag:e}],toDOM:()=>[e,0]}}),Qc={link:{attrs:{...Xc(),href:{default:null},target:{default:null},title:{default:null}},inclusive:!1,parseDOM:[{tag:"a",getAttrs:Jc}],toDOM:e=>["a",Yc(e.attrs),0]},...Gc("strong"),...Gc("b"),...Gc("em"),...Gc("i"),...Gc("del"),...Gc("sub"),...Gc("sup"),...Gc("code"),style:{attrs:{...Xc()},parseDOM:[{tag:"span",getAttrs:Jc}],toDOM:e=>Uc(e.attrs)?["span",Yc(e.attrs),0]:["span",0]},...Gc("u")},Zc=e=>({[e]:{default:null,getFromDOM:t=>t.getAttribute(e),setDOMAttr:(t,n)=>{n[e]=t}}}),ed={...Zc("style"),...Zc("class"),...Zc("id"),...Zc("headers"),...Zc("scope")},td={doc:{content:"colgroup*"},col:{attrs:Kc(["id","class","style","span"]),parseDOM:[{getAttrs:Jc,tag:"col"}],toDOM:e=>["col",e.attrs]},colgroup:{attrs:Kc(["id","class","style","span"]),content:"col*",parseDOM:[{getAttrs:Jc,tag:"colgroup"}],toDOM:e=>["colgroup",e.attrs,0]},text:{inline:!0,group:"inline"}},nd=new U({nodes:td,marks:{}}),od=e=>{const t=Nn(Sn(e),nd,{preserveWhitespace:!1});return Mn(t).firstChild},rd=Ca({tableGroup:"block",cellContent:"block+",cellAttributes:ed});rd.table_row.attrs={...rd.table_row.attrs,...Kc([Mt,"style","class","id"])},rd.table_row.toDOM=e=>["tr",Yc(e.attrs),0],rd.table_row.parseDOM=[{tag:"tr",getAttrs:Jc}],rd.table.attrs={...rd.table.attrs,...Kc(["style","class","id",Nt,Ot])},rd.table.toDOM=e=>{const t=Uc(e.attrs)?Yc(e.attrs,[Nt,Ot]):{};let n=null;if(e.attrs[Nt]&&!(e=>{let t=!1;const n=e.child(0);for(let e=0;e<n.childCount;e++)if(n.child(e).attrs.colwidth){t=!0;break}return t})(e)){const t=od(e.attrs[Nt]);if(t){const e=Array.from(t.children).map((e=>["col",Jc(e)]));n=["colgroup",Jc(t)].concat(e)}}return n?["table",t,n,["tbody",0]]:["table",t,["tbody",0]]},rd.table.parseDOM=[{tag:"table",getAttrs:e=>{const t=Jc(e),n=Array.from(e.childNodes).find((e=>"COLGROUP"===e.nodeName));return n&&(t[Nt]=n.outerHTML),t}}];const id={doc:{content:"block+"},paragraph:{content:"inline*",group:"block",attrs:{...Xc()},parseDOM:[{tag:"p",getAttrs:Jc}],toDOM:e=>Uc(e.attrs)?["p",Yc(e.attrs),0]:["p",0]},table_wrapper:{content:"(table_caption_external | table)+",group:"block",defining:!0,attrs:{table:{default:null},style:{default:null}},parseDOM:[{tag:"div[table]",getAttrs:Jc}],toDOM:e=>Uc(e.attrs)?["div",Yc(e.attrs),0]:["div",0]},table_caption_external:{content:"inline+",group:"block",attrs:{caption:{default:null},...Xc()},parseDOM:[{tag:"div[caption]",getAttrs:Jc}],toDOM:e=>Uc(e.attrs)?["div",Yc(e.attrs),0]:["div",0]},div:{content:"block*",group:"block",attrs:{...Xc()},parseDOM:[{tag:"div",getAttrs:Jc}],toDOM:e=>Uc(e.attrs)?["div",Yc(e.attrs),0]:["div",0]},blockquote:{attrs:{...Xc()},content:"block+",group:"block",defining:!0,parseDOM:[{tag:"blockquote",getAttrs:Jc}],toDOM:e=>Uc(e.attrs)?["blockquote",Yc(e.attrs),0]:Lc},horizontal_rule:{group:"block",parseDOM:[{tag:"hr"}],toDOM:()=>Hc},heading:{attrs:{...Xc(),level:{default:1}},content:"inline*",group:"block",defining:!0,parseDOM:[{tag:"h1",getAttrs:e=>({...Jc(e),level:1})},{tag:"h2",getAttrs:e=>({...Jc(e),level:2})},{tag:"h3",getAttrs:e=>({...Jc(e),level:3})},{tag:"h4",getAttrs:e=>({...Jc(e),level:4})},{tag:"h5",getAttrs:e=>({...Jc(e),level:5})},{tag:"h6",getAttrs:e=>({...Jc(e),level:6})}],toDOM:e=>Uc(e.attrs,"level")?["h"+e.attrs.level,Yc(e.attrs,["level"]),0]:["h"+e.attrs.level,0]},code_block:{content:"text*",marks:"",group:"block",code:!0,defining:!0,parseDOM:[{tag:"pre",preserveWhitespace:"full"}],toDOM:()=>_c},text:{inline:!0,group:"inline"},image:{inline:!0,attrs:{src:{default:null},alt:{default:null},title:{default:null},width:{default:null},height:{default:null},...Xc()},group:"inline",draggable:!0,parseDOM:[{tag:"img",getAttrs:Jc}],toDOM:e=>Uc(e.attrs)?["img",Yc(e.attrs)]:["img"]},hard_break:{inline:!0,attrs:{...Xc()},group:"inline",selectable:!1,parseDOM:[{tag:"br",getAttrs:Jc}],toDOM:e=>Uc(e.attrs)?["br",Yc(e.attrs)]:["br"]},ordered_list:{content:"list_item+",group:"block",attrs:{...Xc(),type:{default:null},order:{default:1}},parseDOM:[{tag:"ol",getAttrs:e=>({...Jc(e),order:e.hasAttribute("start")?parseInt(e.getAttribute("start")||"1",10):1})}],toDOM:e=>1===e.attrs.order?Uc(e.attrs,"order")?["ol",Yc(e.attrs,["order"]),0]:Wc:["ol",{...Yc(e.attrs,["order"]),start:e.attrs.order},0]},bullet_list:{content:"list_item+",group:"block",attrs:{...Xc()},parseDOM:[{tag:"ul",getAttrs:Jc}],toDOM:e=>Uc(e.attrs)?["ul",Yc(e.attrs),0]:qc},list_item:{content:"(paragraph | heading) block*",attrs:{...Xc()},parseDOM:[{tag:"li",getAttrs:Jc}],toDOM:e=>Uc(e.attrs)?["li",Yc(e.attrs),0]:jc,defining:!0},...rd};var sd=200,ld=function(){};ld.prototype.append=function(e){return e.length?(e=ld.from(e),!this.length&&e||e.length<sd&&this.leafAppend(e)||this.length<sd&&e.leafPrepend(this)||this.appendInner(e)):this},ld.prototype.prepend=function(e){return e.length?ld.from(e).append(this):this},ld.prototype.appendInner=function(e){return new cd(this,e)},ld.prototype.slice=function(e,t){return void 0===e&&(e=0),void 0===t&&(t=this.length),e>=t?ld.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},ld.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},ld.prototype.forEach=function(e,t,n){void 0===t&&(t=0),void 0===n&&(n=this.length),t<=n?this.forEachInner(e,t,n,0):this.forEachInvertedInner(e,t,n,0)},ld.prototype.map=function(e,t,n){void 0===t&&(t=0),void 0===n&&(n=this.length);var o=[];return this.forEach((function(t,n){return o.push(e(t,n))}),t,n),o},ld.from=function(e){return e instanceof ld?e:e&&e.length?new ad(e):ld.empty};var ad=function(e){function t(t){e.call(this),this.values=t}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var n={length:{configurable:!0},depth:{configurable:!0}};return t.prototype.flatten=function(){return this.values},t.prototype.sliceInner=function(e,n){return 0==e&&n==this.length?this:new t(this.values.slice(e,n))},t.prototype.getInner=function(e){return this.values[e]},t.prototype.forEachInner=function(e,t,n,o){for(var r=t;r<n;r++)if(!1===e(this.values[r],o+r))return!1},t.prototype.forEachInvertedInner=function(e,t,n,o){for(var r=t-1;r>=n;r--)if(!1===e(this.values[r],o+r))return!1},t.prototype.leafAppend=function(e){if(this.length+e.length<=sd)return new t(this.values.concat(e.flatten()))},t.prototype.leafPrepend=function(e){if(this.length+e.length<=sd)return new t(e.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(t.prototype,n),t}(ld);ld.empty=new ad([]);var cd=function(e){function t(t,n){e.call(this),this.left=t,this.right=n,this.length=t.length+n.length,this.depth=Math.max(t.depth,n.depth)+1}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},t.prototype.getInner=function(e){return e<this.left.length?this.left.get(e):this.right.get(e-this.left.length)},t.prototype.forEachInner=function(e,t,n,o){var r=this.left.length;return!(t<r&&!1===this.left.forEachInner(e,t,Math.min(n,r),o))&&!(n>r&&!1===this.right.forEachInner(e,Math.max(t-r,0),Math.min(this.length,n)-r,o+r))&&void 0},t.prototype.forEachInvertedInner=function(e,t,n,o){var r=this.left.length;return!(t>r&&!1===this.right.forEachInvertedInner(e,t-r,Math.max(n,r)-r,o+r))&&!(n<r&&!1===this.left.forEachInvertedInner(e,Math.min(t,r),n,o))&&void 0},t.prototype.sliceInner=function(e,t){if(0==e&&t==this.length)return this;var n=this.left.length;return t<=n?this.left.slice(e,t):e>=n?this.right.slice(e-n,t-n):this.left.slice(e,n).append(this.right.slice(0,t-n))},t.prototype.leafAppend=function(e){var n=this.right.leafAppend(e);if(n)return new t(this.left,n)},t.prototype.leafPrepend=function(e){var n=this.left.leafPrepend(e);if(n)return new t(n,this.right)},t.prototype.appendInner=function(e){return this.left.depth>=Math.max(this.right.depth,e.depth)+1?new t(this.left,new t(this.right,e)):new t(this,e)},t}(ld);const dd=ld;class hd{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(0==this.eventCount)return null;let n,o,r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}t&&(n=this.remapping(r,this.items.length),o=n.maps.length);let i,s,l=e.tr,a=[],c=[];return this.items.forEach(((e,t)=>{if(!e.step)return n||(n=this.remapping(r,t+1),o=n.maps.length),o--,void c.push(e);if(n){c.push(new pd(e.map));let t,r=e.step.map(n.slice(o));r&&l.maybeStep(r).doc&&(t=l.mapping.maps[l.mapping.maps.length-1],a.push(new pd(t,void 0,void 0,a.length+c.length))),o--,t&&n.appendMap(t,o)}else l.maybeStep(e.step);return e.selection?(i=n?e.selection.map(n.slice(o)):e.selection,s=new hd(this.items.slice(0,r).append(c.reverse().concat(a)),this.eventCount-1),!1):void 0}),this.items.length,0),{remaining:s,transform:l,selection:i}}addTransform(e,t,n,o){let r=[],i=this.eventCount,s=this.items,l=!o&&s.length?s.get(s.length-1):null;for(let n=0;n<e.steps.length;n++){let a,c=e.steps[n].invert(e.docs[n]),d=new pd(e.mapping.maps[n],c,t);(a=l&&l.merge(d))&&(d=a,n?r.pop():s=s.slice(0,s.length-1)),r.push(d),t&&(i++,t=void 0),o||(l=d)}let a=i-n.depth;return a>fd&&(s=function(e,t){let n;return e.forEach(((e,o)=>{if(e.selection&&0==t--)return n=o,!1})),e.slice(n)}(s,a),i-=a),new hd(s.append(r),i)}remapping(e,t){let n=new ge;return this.items.forEach(((t,o)=>{let r=null!=t.mirrorOffset&&o-t.mirrorOffset>=e?n.maps.length-t.mirrorOffset:void 0;n.appendMap(t.map,r)}),e,t),n}addMaps(e){return 0==this.eventCount?this:new hd(this.items.append(e.map((e=>new pd(e)))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let n=[],o=Math.max(0,this.items.length-t),r=e.mapping,i=e.steps.length,s=this.eventCount;this.items.forEach((e=>{e.selection&&s--}),o);let l=t;this.items.forEach((t=>{let o=r.getMirror(--l);if(null==o)return;i=Math.min(i,o);let a=r.maps[o];if(t.step){let i=e.steps[o].invert(e.docs[o]),c=t.selection&&t.selection.map(r.slice(l+1,o));c&&s++,n.push(new pd(a,i,c))}else n.push(new pd(a))}),o);let a=[];for(let e=t;e<i;e++)a.push(new pd(r.maps[e]));let c=this.items.slice(0,o).append(a).append(n),d=new hd(c,s);return d.emptyItemCount()>500&&(d=d.compress(this.items.length-n.length)),d}emptyItemCount(){let e=0;return this.items.forEach((t=>{t.step||e++})),e}compress(e=this.items.length){let t=this.remapping(0,e),n=t.maps.length,o=[],r=0;return this.items.forEach(((i,s)=>{if(s>=e)o.push(i),i.selection&&r++;else if(i.step){let e=i.step.map(t.slice(n)),s=e&&e.getMap();if(n--,s&&t.appendMap(s,n),e){let l=i.selection&&i.selection.map(t.slice(n));l&&r++;let a,c=new pd(s.invert(),e,l),d=o.length-1;(a=o.length&&o[d].merge(c))?o[d]=a:o.push(c)}}else i.map&&n--}),this.items.length,0),new hd(dd.from(o.reverse()),r)}}hd.empty=new hd(dd.empty,0);class pd{constructor(e,t,n,o){this.map=e,this.step=t,this.selection=n,this.mirrorOffset=o}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new pd(t.getMap().invert(),t,this.selection)}}}class ud{constructor(e,t,n,o,r){this.done=e,this.undone=t,this.prevRanges=n,this.prevTime=o,this.prevComposition=r}}const fd=20;function md(e){let t=[];for(let n=e.length-1;n>=0&&0==t.length;n--)e[n].forEach(((e,n,o,r)=>t.push(o,r)));return t}function gd(e,t){if(!e)return null;let n=[];for(let o=0;o<e.length;o+=2){let r=t.map(e[o],1),i=t.map(e[o+1],-1);r<=i&&n.push(r,i)}return n}let yd=!1,wd=null;function vd(e){let t=e.plugins;if(wd!=t){yd=!1,wd=t;for(let e=0;e<t.length;e++)if(t[e].spec.historyPreserveItems){yd=!0;break}}return yd}function bd(e){return e.setMeta(xd,!0)}const kd=new Ct("history"),xd=new Ct("closeHistory");function Sd(e={}){return e={depth:e.depth||100,newGroupDelay:e.newGroupDelay||500},new kt({key:kd,state:{init:()=>new ud(hd.empty,hd.empty,null,0,-1),apply:(t,n,o)=>function(e,t,n,o){let r,i=n.getMeta(kd);if(i)return i.historyState;n.getMeta(xd)&&(e=new ud(e.done,e.undone,null,0,-1));let s=n.getMeta("appendedTransaction");if(0==n.steps.length)return e;if(s&&s.getMeta(kd))return s.getMeta(kd).redo?new ud(e.done.addTransform(n,void 0,o,vd(t)),e.undone,md(n.mapping.maps),e.prevTime,e.prevComposition):new ud(e.done,e.undone.addTransform(n,void 0,o,vd(t)),null,e.prevTime,e.prevComposition);if(!1===n.getMeta("addToHistory")||s&&!1===s.getMeta("addToHistory"))return(r=n.getMeta("rebased"))?new ud(e.done.rebased(n,r),e.undone.rebased(n,r),gd(e.prevRanges,n.mapping),e.prevTime,e.prevComposition):new ud(e.done.addMaps(n.mapping.maps),e.undone.addMaps(n.mapping.maps),gd(e.prevRanges,n.mapping),e.prevTime,e.prevComposition);{let r=n.getMeta("composition"),i=0==e.prevTime||!s&&e.prevComposition!=r&&(e.prevTime<(n.time||0)-o.newGroupDelay||!function(e,t){if(!t)return!1;if(!e.docChanged)return!0;let n=!1;return e.mapping.maps[0].forEach(((e,o)=>{for(let r=0;r<t.length;r+=2)e<=t[r+1]&&o>=t[r]&&(n=!0)})),n}(n,e.prevRanges)),l=s?gd(e.prevRanges,n.mapping):md(n.mapping.maps);return new ud(e.done.addTransform(n,i?t.selection.getBookmark():void 0,o,vd(t)),hd.empty,l,n.time,null==r?e.prevComposition:r)}}(n,o,t,e)},config:e,props:{handleDOMEvents:{beforeinput(e,t){let n=t.inputType,o="historyUndo"==n?Md:"historyRedo"==n?Nd:null;return!!o&&(t.preventDefault(),o(e.state,e.dispatch))}}}})}function Cd(e,t){return(n,o)=>{let r=kd.getState(n);if(!r||0==(e?r.undone:r.done).eventCount)return!1;if(o){let i=function(e,t,n){let o=vd(t),r=kd.get(t).spec.config,i=(n?e.undone:e.done).popEvent(t,o);if(!i)return null;let s=i.selection.resolve(i.transform.doc),l=(n?e.done:e.undone).addTransform(i.transform,t.selection.getBookmark(),r,o),a=new ud(n?l:i.remaining,n?i.remaining:l,null,0,-1);return i.transform.setSelection(s).setMeta(kd,{redo:n,historyState:a})}(r,n,e);i&&o(t?i.scrollIntoView():i)}return!0}}const Md=Cd(!1,!0),Nd=Cd(!0,!0),Od=Cd(!1,!1),Ad=Cd(!0,!1);function Td(e){let t=kd.getState(e);return t?t.done.eventCount:0}function Dd(e){let t=kd.getState(e);return t?t.undone.eventCount:0}class Ed{constructor(e,t,n={}){var o;this.match=e,this.match=e,this.handler="string"==typeof t?(o=t,function(e,t,n,r){let i=o;if(t[1]){let e=t[0].lastIndexOf(t[1]);i+=t[0].slice(e+t[1].length);let o=(n+=e)-r;o>0&&(i=t[0].slice(e-o,e)+i,n=r)}return e.tr.insertText(i,n,r)}):t,this.undoable=!1!==n.undoable,this.inCode=n.inCode||!1,this.inCodeMark=!1!==n.inCodeMark}}const Rd=500;function $d({rules:e}){let t=new kt({state:{init:()=>null,apply(e,t){return e.getMeta(this)||(e.selectionSet||e.docChanged?null:t)}},props:{handleTextInput:(n,o,r,i)=>Id(n,o,r,i,e,t),handleDOMEvents:{compositionend:n=>{setTimeout((()=>{let{$cursor:o}=n.state.selection;o&&Id(n,o.pos,o.pos,"",e,t)}))}}},isInputRules:!0});return t}function Id(e,t,n,o,r,i){if(e.composing)return!1;let s=e.state,l=s.doc.resolve(t),a=l.parent.textBetween(Math.max(0,l.parentOffset-Rd),l.parentOffset,null,"")+o;for(let c=0;c<r.length;c++){let d=r[c];if(!d.inCodeMark&&l.marks().some((e=>e.type.spec.code)))continue;if(l.parent.type.spec.code){if(!d.inCode)continue}else if("only"===d.inCode)continue;let h=d.match.exec(a),p=h&&h[0].length>=o.length&&d.handler(s,h,t-(h[0].length-o.length),n);if(p)return d.undoable&&p.setMeta(i,{transform:p,from:t,to:n,text:o}),e.dispatch(p),!0}return!1}const zd=(e,t)=>{let n=e.plugins;for(let o=0;o<n.length;o++){let r,i=n[o];if(i.spec.isInputRules&&(r=i.getState(e))){if(t){let n=e.tr,o=r.transform;for(let e=o.steps.length-1;e>=0;e--)n.step(o.steps[e].invert(o.docs[e]));if(r.text){let t=n.doc.resolve(r.from).marks();n.replaceWith(r.from,r.to,e.schema.text(r.text,t))}else n.delete(r.from,r.to);t(n)}return!0}}return!1},Bd=new Ed(/--$/,"—",{inCodeMark:!1}),Pd=new Ed(/\.\.\.$/,"…",{inCodeMark:!1}),Vd=new Ed(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,"“",{inCodeMark:!1}),Fd=new Ed(/"$/,"”",{inCodeMark:!1}),Ld=new Ed(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,"‘",{inCodeMark:!1}),Hd=new Ed(/'$/,"’",{inCodeMark:!1}),_d=[Vd,Fd,Ld,Hd];function Wd(e,t,n=null,o){return new Ed(e,((e,r,i,s)=>{let l=n instanceof Function?n(r):n,a=e.tr.delete(i,s),c=a.doc.resolve(i).blockRange(),d=c&&Ee(c,t,l);if(!d)return null;a.wrap(c,d);let h=a.doc.resolve(i-1).nodeBefore;return h&&h.type==t&&Be(a.doc,i-1)&&(!o||o(r,h))&&a.join(i-1),a}))}function qd(e,t,n=null){return new Ed(e,((e,o,r,i)=>{let s=e.doc.resolve(r),l=n instanceof Function?n(o):n;return s.node(-1).canReplaceWith(s.index(-1),s.indexAfter(-1),t)?e.tr.delete(r,i).setBlockType(r,r,t,l):null}))}const jd={mark:"strong",altMarks:["b"],altStyle:{name:"font-weight",value:/^(bold(er)?|[5-9]\d{2,})$/}},Jd={mark:"em",altMarks:["i"],altStyle:{name:"font-style",value:/^italic$/i}},Kd={mark:"u",altStyle:{name:"text-decoration",value:/^underline$/i}},Xd={mark:"del",altStyle:{name:"text-decoration",value:/^line-through$/i}},Ud={mark:"sub"},Yd={mark:"sup"},Gd={mark:"link"},Qd="undefined"!=typeof navigator&&/Mac/.test(navigator.platform),Zd=(e,t)=>{const n={},o=t&&t.applyToWord||!1;if(n["Mod-z"]=Md,n["Shift-Mod-z"]=Nd,n.Backspace=gr(zd,zo,Po,_o),n.Enter=gr(Go,er,tr,rr),Qd||(n["Mod-y"]=Nd),e.marks.strong&&(n["Mod-b"]=sn(Gn,{...jd,applyToWord:o})),e.marks.em&&(n["Mod-i"]=sn(Gn,{...Jd,applyToWord:o})),e.marks.u&&(n["Mod-u"]=sn(Gn,{...Kd,applyToWord:o})),e.nodes.hard_break){const t=e.nodes.hard_break,o=gr(Zo,((e,n)=>(n(e.tr.replaceSelectionWith(t.create()).scrollIntoView()),!0)));n["Shift-Enter"]=o}return n},eh=e=>{const t={};var n;return e.nodes.list_item&&(t.Enter=(n=e.nodes.list_item,(e,t)=>No(n)(e,(n=>{const o=e.storedMarks||e.selection.$to.parentOffset&&e.selection.$from.marks();o&&n.ensureMarks(o),t(n)})))),t},th=/style=['"]?[^'"]*?mso-list:\s*[a-zA-Z]+(\d+)\s[a-zA-Z]+(\d+)\s(\w+)/gi,nh=e=>/^MsoListParagraph/.test(e.className),oh=e=>e.textContent,rh=(e,t)=>{const n=document.createElement(e);return n.style.listStyleType=t,n},ih=e=>{let t=null;return/^\d/.test(e)||(t=(/^[a-z]/.test(e)?"lower-":"upper-")+(/^[ivxlcdm]/i.test(e)?"roman":"alpha")),t},sh=(e,t)=>{let n=[];Array.from(e).forEach((e=>{if(e.nodeType!==Node.ELEMENT_NODE)return;const o=e;o.getAttribute("datalist")?(n.push(e),t.add(n)):nh(o)&&n.length?n.push(e):(n=[],"DIV"===o.nodeName?sh(o.children,t):"TABLE"===o.nodeName&&Array.from(o.querySelectorAll("td,th")).forEach((e=>{sh(e.children,t)})))}))},lh=e=>{const t=e.textContent,n=e=>e.replace(/^(?:&nbsp;|[\u00a0\n\r\s])+/,"");return/^[\u2022\u00b7\u00a7\u00d8oØüvn][\u00a0 ]+/.test(t)?{tag:"ul",style:(o=n(oh(e)),/^[\u2022\u00b7\u00FC\u00D8\u002dv-]/.test(o)?null:/^o/.test(o)?"circle":"square")}:/^\s*\w+[.)][\u00a0 ]{2,}/.test(t)?{tag:"ol",style:ih(n(oh(e)))}:void 0;var o},ah=e=>{const t=e.nodeName.toLowerCase();let n;e.firstChild&&e.firstChild.nodeType===Node.COMMENT_NODE&&e.removeChild(e.firstChild),1===e.childNodes.length?n=e.firstChild.nodeType===Node.TEXT_NODE?oh(e):e.firstChild.innerHTML.replace(/^\w+[.)](&nbsp;)+ /,""):(e.removeChild(e.firstChild),3===e.firstChild.nodeType&&/^[ivxlcdm]+\.$/i.test(e.firstChild.nodeValue)&&e.removeChild(e.firstChild),/^(&nbsp;|\s)+$/i.test(e.firstChild.innerHTML)&&e.removeChild(e.firstChild),n="p"!==t?"<"+t+">"+e.innerHTML+"</"+t+">":e.innerHTML),e.parentNode.removeChild(e);const o=document.createElement("li");return o.appendChild(Sn(n)),o},ch=e=>{const t=Sn((e=>e.replace(th,((e,t,n)=>`datalist="${t}" datalevel="${n}" ${e}`)))(e)),n=new Set;return sh(t.children,n),n.forEach((e=>(e=>{const t={};let n,o,r,i,s,l,a,c,d,h,p,u,f,m=-1;for(c=0;c<e.length;c++){d=e[c],f={datalist:d.getAttribute("datalist"),datalevel:d.getAttribute("datalevel")};const g=f.datalist,y=lh(d);if(h=y&&y.tag,!h){!n||s&&!nh(d)||(d.style.marginLeft&&(d.style.marginLeft=""),d.style.marginLeft&&(d.style.margin=""),n.appendChild(d));continue}if(p=f.datalevel||parseFloat(d.style.marginLeft||0),!f.datalevel&&!d.style.marginLeft)continue;const w=h+g;t[p]||(t[p]={}),(!o||o<0)&&(o=p,r=g,a=e.filter((e=>e.getAttribute("datalist")===String(r))),i=a[a.length-1],l=rh(h,y&&y.style),d.parentNode.insertBefore(l,d),m=p,t[p][w]=l),s=i===d,u=t[p][w],(p>m||!u)&&(u=rh(h,y&&y.style),t[p][w]=u,n.appendChild(u)),n=ah(d),u.appendChild(n),s?o=m=-1:m=p}})(e))),Cn(t)},dh=e=>{let t;e=(e=(e=(e=e.replace(/^[\s\S]+?<!--StartFragment-->\s*([\s\S]*?)\s*<!--EndFragment-->[\s\S]+$/,"$1")).replace(/<\/?[ovw]:[^>]*?>/gi,"")).replace(/<\\?\??xml[^>]*>/gi,"")).replace(/<(?:link|meta) [^>]+?>/gi,"");do{t=e,e=e.replace(/<style[^>]*?>\s*<\/style>/gi,"")}while(e!==t);return(e=(e=(e=(e=e.replace(/<\/?st1:.*?>/gi,"")).replace(/<a name="[a-zA-Z0-9_]+">/gim,"")).replace(/v:shapes?="[^"]+"/gi,"")).replace(/<!\[if !supportLists\]>/gi,"")).replace(/<!\[endif\]>/gi,"")},hh=(e,t)=>e.replace(new RegExp("<\\/?("+t+")(?:\\s[^>]*?)?>","gi"),""),ph=e=>{e.ownerElement&&e.ownerElement.removeAttribute(e.name)},uh=e=>{/^Mso/.test(e.value)&&ph(e)},fh=e=>{const t=ln(e.value),n=e.ownerElement.style;let o="";Object.keys(t).forEach((e=>{void 0!==n[e]&&(o+=`${e}: ${t[e]}; `)})),o=o.trim(),o?e.value=o:ph(e)},mh=(e,t)=>{let n=e;if(t.convertMsLists&&(n=ch(n)),t.stripTags&&(n=hh(n,t.stripTags)),t.attributes){const e=Sn(n);Array.from(e.querySelectorAll("*")).forEach((e=>((e,t)=>{if(e.nodeType===Node.ELEMENT_NODE){for(let n=e.attributes.length-1;n>=0;n--){const o=e.attributes[n];t[o.name]?t[o.name](o):t["*"]&&t["*"](o)}"SPAN"===e.nodeName&&0===e.attributes.length&&(e=>{const t=e.parentNode;if(t){for(;e.firstChild;)t.insertBefore(e.firstChild,e);t.removeChild(e)}})(e)}})(e,t.attributes))),n=Cn(e)}return n};function gh(e){const t=e.length,n=new Array(t/2);for(let o=0;o<t;o+=2)n[o]=String.fromCharCode(parseInt(e.substring(o,o+2),16));return btoa(n.join(""))}const yh=/<img\s[^>]*?src=(?:'|")file:\/[^'"]+(?:'|")[^>]*>/gi,wh=/{\\pict[\s\S]+?\\bliptag-?\d+(\\blipupi-?\d+)?({\\\*\\blipuid\s?[\da-fA-F]+)?[\s}]*?/,vh=new RegExp("(?:("+wh.source+"))([\\da-fA-F\\s]+)\\}","g"),bh=/[^\da-fA-F]/g,kh=/file:\/[^'"]+\.(jpg|png|gif)/i,xh=/\\(png|jpeg)blip\\/,Sh="text/rtf",Ch=(e,t)=>{const n=e.match(yh);if(!n||-1===t.types.indexOf(Sh))return e;const o=t.getData(Sh),r=[],i=o.match(vh);if(!o||!i)return e;for(const e of i){const t=xh.exec(e);if(t){const n=e.replace(wh,"").replace(bh,"");r.push(`data:image/${t[1]};base64,${gh(n)}`)}}return n.length!==r.length?e:e.replace(yh,(e=>{const t=r.shift()||"";return e.replace(kh,t)}))},Mh=(e,t,n,o,r)=>{const i=[];let s,l,a,c,d,h;const p=[],{matchCase:u,matchWord:f,useRegExp:m}=t,g=t.text;if(!g)return i;const y=u?"g":"gi",w=m?new RegExp(g,y):new RegExp(Rh(g),y);return e.nodesBetween(n,o,((t,u)=>{if(r(i))return!1;t.inlineContent&&u+t.content.size>=n&&(p.length=0,t.nodesBetween(0,t.content.size,((t,m,g,y)=>{if(r(i))return!1;const v=1+u+m;if(t.isText&&v+t.nodeSize>=n){if(d=t.text||"",h=g.childCount-1>=y+1&&g.child(y+1),p.push(n<=v?{text:d,start:v}:{text:d.slice(n-v),start:n}),h&&h.isText)return;for(l=p.map((e=>e.text)).join(""),s=w.exec(l);null!==s;){if(s[0].length>0){if(a=p[0].start+s.index,c=a+s[0].length,n<=a&&o>=c&&Eh(s,f)&&i.push(st.create(e,a,c)),r(i))break}else w.lastIndex++;s=w.exec(l)}}else p.length=0})))})),i},Nh=(e,t)=>{const{backward:n,matchCyclic:o,...r}=t,i=n?()=>!1:e=>e.length>0,{doc:s,selection:l}=e;let a=[];return n?(a=Mh(s,r,0,l.from,i),!a.length&&o&&(a=Mh(s,r,l.from,s.content.size,i))):(a=Mh(s,r,l.to,s.content.size,i),!a.length&&o&&(a=Mh(s,r,0,l.to,i))),a.length?a[a.length-1]:null},Oh=(e,t)=>Mh(e,t,0,e.content.size,(()=>!1)),Ah=(e,t,n)=>{const{from:o,to:r}=e;return n.insertText(t,o,r).setSelection(st.create(n.doc,o,o+t.length)),n},Th=(e,t,n)=>{const o=Oh(e.doc,n);if(0===o.length)return null;const r=e.tr;for(let e=o.length-1;e>=0;e--)r.insertText(t,o[e].from,o[e].to);return r},Dh=/^[\s0-9~`!@#$%^&*()_\-=+\\|[\]{};:'"?/.,<>]?$/,Eh=(e,t)=>{if(t){if(!0===t){const t=e.input,n=t.charAt(e.index-1),o=t.charAt(e.index+e[0].length);return Dh.test(n)&&Dh.test(o)}return t(e)}return!0},Rh=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");function $h(e){const t={class:"k-placeholder","data-placeholder":e};return new kt({key:new Ct("placeholder"),props:{decorations:e=>{const{doc:n}=e,o=n.content.firstChild;if(!(0===n.childCount||1===n.childCount&&o.inlineContent&&0===o.childCount))return Ol.empty;const r=[];return n.descendants(((e,n)=>{r.push(Cl.node(n,n+e.nodeSize,t))})),Ol.create(n,r)}}})}const Ih=/\s+/g,zh=/text-align/,Bh=()=>new kt({key:new Ct("spaces-fix"),props:{decorations:e=>{const t=[],n=e.doc;let o,r,i,s;return n.nodesBetween(0,n.content.size,((e,n,l)=>{if(e.type.isText&&(e=>zh.test(e&&e.attrs&&e.attrs.style||""))(l))for(r=Ih.exec(e.text||"");null!==r;){if(o=n+r.index,i=r[0].length,r.index+i<r.input.length)for(s=0;s<=i-1;s+=2)t.push(Cl.inline(o+s,o+s+1,{style:"white-space: normal"}));r=Ih.exec(e.text||"")}})),Ol.create(n,t)}}}),Ph=(e,t)=>{for(const n in t)n&&dn(e,n,t[n])};class Vh{constructor(e,t,n,o=!1){this.node=e,this.view=t,this.dom=document.createElement(n),Ph(this.dom,e.attrs),this.contentDOM=o?void 0:this.dom}}class Fh{constructor(e,t){this.mark=e,this.view=t,this.dom=document.createElement("span"),Ph(this.dom,e.attrs),this.contentDOM=this.dom}}const Lh=()=>new kt({key:new Ct("csp-fix"),props:{nodeViews:{paragraph:(e,t)=>new Vh(e,t,"p"),div:(e,t)=>new Vh(e,t,"div"),table_wrapper:(e,t)=>new Vh(e,t,"div"),table_caption_external:(e,t)=>new Vh(e,t,"div"),table:(e,t)=>new Vh(e,t,"table"),table_row:(e,t)=>new Vh(e,t,"tr"),table_cell:(e,t)=>new Vh(e,t,"td"),table_header:(e,t)=>new Vh(e,t,"th"),image:(e,t)=>new Vh(e,t,"img",!0)},markViews:{style:(e,t)=>new Fh(e,t)}}}),Hh=new Ct("highlight");function _h(e=Hh){return new kt({key:e,state:{init:()=>null,apply(e){return e.getMeta(this.spec.key)}},props:{decorations(e){const t=(this.spec.key.getState(e)||[]).map((e=>Cl.inline(e.from,e.to,e.attrs)));return Ol.create(e.doc,t)}}})}const Wh={southeast:{x:1,y:1},east:{x:1,y:0},south:{x:0,y:1},north:{x:0,y:-1},west:{x:-1,y:0},southwest:{x:-1,y:1},northwest:{x:-1,y:-1},northeast:{x:1,y:-1}},qh=Object.keys(Wh),jh=new Ct("image-resize"),Jh=(e,t,n)=>{e.style[t]=n+"px"},Kh=/[^-]width:|[^-]height:/,Xh=/^.+$/;class Uh{constructor(e,t,n,o){this.activeHandle=e,this.dragging=t,this.rect=n,this.nodePosition=o}apply(e){const t=e.getMeta(jh);return t?new Uh(t.activeHandle,t.setDragging,t.rect,t.nodePosition):this}}const Yh=(e={node:"image",lockRatio:!0})=>new kt({key:jh,view:t=>({resize(){jh.getState(t.state).rect&&t.dispatch(t.state.tr.setMeta("resize",!0))},get window(){return t.dom.ownerDocument&&t.dom.ownerDocument.defaultView},attachResize(){const e=this.window;e&&(e.removeEventListener("resize",this.resize),e.addEventListener("resize",this.resize))},removeResize(){const e=this.window;e&&e.removeEventListener("resize",this.resize)},update(t,n){const o=t.state,r=o.selection,i=o.schema.nodes[e.node],s=jh.getState(o),l=s.rect;if(r instanceof at&&i===r.node.type){const e=t.nodeDOM(r.from),i={top:e.offsetTop,left:e.offsetLeft,width:e.offsetWidth,height:e.offsetHeight};if(!n.selection.eq(r)||l&&(l.width!==i.width||l.height!==i.height||l.top!==i.top||l.left!==i.left)){const e=o.tr;e.setMeta(jh,{rect:i,nodePosition:r.from}),t.dispatch(e),this.attachResize()}}else l&&(s.rect=null,s.nodePosition=-1)},destroy(){this.removeResize()}}),state:{init:()=>new Uh("",null,null,-1),apply:(e,t)=>t.apply(e)},props:{handleDOMEvents:{mousedown:(t,n)=>((e,t,n)=>{const o=t.target.getAttribute(Dt);if(!o)return!1;const r=jh.getState(e.state);t.preventDefault();const i=e.state.tr;function s(t){((e,t,n)=>{const o=jh.getState(e.state),{rect:r,dragging:i,nodePosition:s,activeHandle:l}=o;if(!i||!r)return;const a=e.nodeDOM(s),c=Wh[l],d=(t.clientX-i.startX)*c.x,h=(t.clientY-i.startY)*c.y;let p=c.x?d+a.width:r.width,u=c.y?h+a.height:r.height;if(n.lockRatio&&c.x&&c.y){const e=Math.min(p/a.width,u/a.height),n=a.width*e,o=a.height*e;i.startX=t.clientX-(p-n)*c.x,i.startY=t.clientY-(u-o)*c.y,p=n,u=o}else i.startX=c.x?t.clientX:i.startX,i.startY=c.y?t.clientY:i.startY;Jh(a,"width",p),Jh(a,"height",u),r.top=a.offsetTop,r.left=a.offsetLeft,r.width=a.offsetWidth,r.height=a.offsetHeight;const f=a.nextElementSibling;f.style.width=r.width+"px",f.style.height=r.height+"px",f.style.top=r.top+"px",f.style.left=r.left+"px"})(e,t,n)}return i.setMeta(jh,{setDragging:{startX:t.clientX,startY:t.clientY},activeHandle:o,rect:r.rect,nodePosition:r.nodePosition}),i.setMeta("addToHistory",!1),e.dispatch(i),t.view.addEventListener("mouseup",(function t(n){n.view.removeEventListener("mouseup",t),n.view.removeEventListener("mousemove",s),(e=>{const{rect:t,dragging:n,nodePosition:o}=jh.getState(e.state);if(n&&t){const n=e.state.selection;if(n instanceof at){const r=n.node.attrs,i=t.width,s=t.height;let l;if(Kh.test(r.style||"")){const e=qt(r.style,{style:"width",value:Xh,newValue:i+"px"}),{style:t}=qt(e.style||"",{style:"height",value:Xh,newValue:s+"px"});l={...r,style:t}}else l={...r,width:i,height:s};const a=n.node.type.createAndFill(l);if(a){const n=e.state.tr;n.replaceWith(o,o+1,a),n.setSelection(at.create(n.doc,o)),n.setMeta("commandName","image-resize"),n.setMeta("args",l),n.setMeta(jh,{setDragging:null,activeHandle:null,rect:t,nodePosition:o}),e.dispatch(n)}}}})(e)})),t.view.addEventListener("mousemove",s),!0})(t,n,e)},decorations(t){const n=t.selection,o=t.schema.nodes[e.node],r=jh.getState(t).rect;if(r&&n instanceof at&&o===n.node.type){const e=document.createElement("div");e.className="k-editor-resize-handles-wrapper",e.style.width=r.width+"px",e.style.height=r.height+"px",e.style.top=r.top+"px",e.style.left=r.left+"px";for(let t=0;t<qh.length;t++){const n=document.createElement("div");n.className=At+" "+qh[t],n.setAttribute(Dt,qh[t]),e.appendChild(n)}return Ol.create(t.doc,[Cl.widget(t.selection.from+1,e)])}return Ol.empty}}}),Gh=new Ct("caret-color");function Qh(){return new kt({key:Gh,props:{decorations:e=>{const{doc:t,selection:n,storedMarks:o}=e;if(!n.empty||!o)return Ol.empty;const r=Wn((o||[]).find((e=>"style"===e.type.name)),{name:"color",value:/^.+$/});if(!r)return Ol.empty;const i=n.$anchor.parent,s=[];return t.descendants(((e,t)=>{e.eq(i)&&s.push(Cl.node(t,t+e.nodeSize,{style:"caret-color: "+r}))})),Ol.create(t,s)}}})}class Zh{constructor(e,t){this.node=e,this.view=t,this.dom=document.createElement("div"),this.dom.className="k-editor-resize-wrap-element",this.table=this.dom.appendChild(document.createElement("table")),e.attrs[Nt]&&this.renderColgroup(e.attrs[Nt]);const n=this.table.appendChild(document.createElement("tbody"));this.setAttributes(this.table,e.attrs),this.resizeHandles=qh.map((e=>{const t=document.createElement("span");return t.className=At+" "+e,t.setAttribute(Tt,e),t})),this.contentDOM=n}update(e){if(e.type!==this.node.type)return!1;const t=this.node;return this.node=e,e.attrs[Ot]?this.resizeHandles.forEach((e=>{this.dom.appendChild(e)})):Array.from(this.dom.children).filter((e=>e.classList.contains(At))).forEach((e=>e.remove())),this.setAttributes(this.table,e.attrs),t.attrs[Nt]!==e.attrs[Nt]&&this.renderColgroup(e.attrs[Nt]),!0}ignoreMutation(e){return"attributes"===e.type&&(e.target===this.table||e.target.firstChild===this.table||this.colgroup&&this.colgroup.contains(e.target))}destroy(){this.node=void 0,this.view=void 0,this.table=void 0,this.colgroup=void 0,this.resizeHandles=void 0}renderColgroup(e){this.table&&this.table.firstChild&&"COLGROUP"===this.table.firstChild.nodeName&&this.table.removeChild(this.table.firstChild),e&&(this.colgroup=od(e),this.table.insertBefore(this.colgroup,this.table.firstChild))}setAttributes(e,t){const n=[Nt,Ot];for(const o in t)o&&-1===n.indexOf(o)&&dn(e,o,t[o]);/%$/.test(e.style.width)?(this.dom.style.width=e.style.width,e.style.width=""):this.dom.style.width=""}}class ep{constructor(e,t){this.node=e,this.view=t,this.dom=document.createElement("div"),this.setAttributes(this.dom,e.attrs),this.contentDOM=this.dom}update(e){return e.type===this.node.type&&(this.node=e,this.setAttributes(this.dom,e.attrs),!0)}ignoreMutation(e){return"attributes"===e.type&&"style"===e.attributeName}destroy(){this.node=void 0,this.view=void 0}setAttributes(e,t){for(const n in t)n&&dn(e,n,t[n]);if(e.setAttribute("table",""),/%/.test(e.style.width)){const t=this.node&&this.node.lastChild,n=(t?ln(t.attrs.style):{}).width||"";n&&!/%/.test(n)&&(e.style.width="")}}}const tp=new Ct("table-resize"),np=new Ct("table-column-resizing"),op=new Ct("table-row-resizing");function rp(e,t){let n=!1;return n=n||e!==tp&&Boolean(tp.get(t))&&tp.getState(t).dragging,n=n||e!==np&&Boolean(np.get(t))&&np.getState(t).dragging,n=n||e!==op&&Boolean(op.get(t))&&op.getState(t).dragging,n}function ip(e,t){let n=!1;return n=n||e!==np&&Boolean(np.get(t))&&np.getState(t).activeHandle>-1,n=n||e!==op&&Boolean(op.get(t))&&op.getState(t).activeHandle>-1,n}function sp(e){return e&&e.firstChild&&"TABLE"===e.firstChild.nodeName?e.firstChild:e}function lp(e){for(;e&&"TD"!==e.nodeName&&"TH"!==e.nodeName;)e=e.classList.contains("ProseMirror")?null:e.parentNode;return e}function ap(e){const t=function(e){const t=Array.from(e&&e.rows||[]),n=Array.from(t&&t[0]&&t[0].cells||[]).map((e=>e.colSpan)).reduce(((e,t)=>e+t),0),o=t.map((()=>new Array(n)));return t.forEach(((e,t)=>{let n=0;Array.from(e.cells).forEach((e=>{for(let r=0;r<e.colSpan;r++){for(let r=0;r<e.rowSpan;r++){const i=o[t+r].findIndex(((e,t)=>t>=n&&!e));o[t+r][i]=e}n++}}))})),o}(e.closest("table"));let n=null;for(let o=0;o<t.length&&(t[o].forEach(((t,r)=>{e===t&&(n={rowIndex:o,cellIndex:r})})),!n);o++);return n||{rowIndex:-1,cellIndex:-1}}function cp(e,t,n){const o=e.posAtCoords({left:t.clientX,top:t.clientY});if(!o)return-1;const r=e.state.doc.resolve(o.pos),i=Yt(r,(e=>"table"===e.type.spec.tableRole));if(null===i)return-1;const s=r.start(i.depth),l=i.node,a=va.get(l);return s+a.map[a.width*n.rowIndex+n.cellIndex]}function dp(e){const t=Array.from(e&&e.children||[]);let n=!1;return t.forEach((t=>{for(;t.span>1;){const o=t.cloneNode();o.span=1,e.insertBefore(o,t),t.span-=1,n=!0}})),n}function hp(){const e=new kt({key:np,state:{init:()=>new pp(-1,null),apply:(e,t)=>t.apply(e)},props:{attributes:e=>ip(np,e)?null:np.getState(e).activeHandle>-1?{class:"resize-cursor"}:null,handleDOMEvents:{mousemove:(e,t)=>(rp(np,e.state)||function(e,t){const n=np.getState(e.state);if(!n.dragging){const o=lp(t.target);let r=-1;if(o){const n=ap(o),{left:i,right:s}=o.getBoundingClientRect();Math.abs(t.clientX-i)<=5&&n.cellIndex>0?(n.cellIndex-=o.colSpan,r=cp(e,t,n)):s-t.clientX>0&&s-t.clientX<=5&&(r=cp(e,t,n))}r!==n.activeHandle&&up(e,r)}}(e,t),!1),mouseleave:e=>(function(e){const t=np.getState(e.state);t.activeHandle>-1&&!t.dragging&&up(e,-1)}(e),!1),mousedown:(e,t)=>function(e,t){const n=np.getState(e.state);if(-1===n.activeHandle||n.dragging)return!1;const o=e.state.doc.resolve(n.activeHandle),r=o.parent,i=o.index();let s=0;for(let e=0;e<=i;e++)s+=r.child(e).attrs.colspan;const l=o.node(o.depth-1),a=e.domAtPos(n.activeHandle),c=a.node.childNodes[a.offset].closest("table");let d,h;if(l.attrs[Nt]){const e=c.firstChild;dp(e)&&(h={...l.attrs,[Nt]:e.outerHTML}),d=e.children[s-1],d.style.width||(d.style.width=d.offsetWidth+"px")}else{let e=0;for(let t=0;t<r.childCount;t++)e+=r.child(t).attrs.colspan;const t=document.createElement("colgroup"),n=new Array(e);for(let o=0;o<e;o++)n[o]=document.createElement("col"),t.appendChild(n[o]);c.insertBefore(t,c.firstChild),d=n[i],d.style.width=d.offsetWidth+"px",h={...l.attrs,[Nt]:"<colgroup>"+n.reduce(((e,t)=>e+t.outerHTML),"")+"</colgroup>"}}const p=parseFloat(d.style.width),u=e.state.tr.setMeta(np,{setDragging:{startX:t.clientX,startWidth:p}});if(!c.style.width){const e=Array.from(d.parentNode.children).map((e=>e.style.width));if(e.every(Boolean)){const t=e.reduce(((e,t)=>e+parseFloat(t)),0);h=Jt(h||l.attrs,"width",t+"px")}}if(h){const e=o.posAtIndex(0,o.depth-1)-1;u.setNodeMarkup(e,null,h)}function f(t){t.view.removeEventListener("mouseup",f),t.view.removeEventListener("mousemove",m);const n=np.getState(e.state);if(n.dragging){const t=e.state.tr;!function(e,t,n){const o=e.state.doc.resolve(n),r=o.node(-1),i=o.start(-1),s=o.posAtIndex(0,o.depth-1)-1,l=e.nodeDOM(i).closest("table");let a=r.attrs;if(r&&a[Nt]){const e=l.firstChild;a={...a,[Nt]:e.outerHTML}}const c=l.style.width;l&&c&&ln(a.style).width!==c&&(a=Jt(a,"width",c)),t.setNodeMarkup(s,null,a)}(e,t,n.activeHandle),e.dispatch(t.setMeta(np,{setDragging:null}))}}function m(t){if(!t.which)return f(t);const n=np.getState(e.state),o=function(e,t){const n=t.clientX-e.startX;return Math.max(25,e.startWidth+n)}(n.dragging,t);!function(e,t,n){const o=e.state.doc.resolve(t),r=o.node(-1),i=o.start(-1),s=va.get(r).colCount(o.pos-i)+o.nodeAfter.attrs.colspan-1;let l=e.domAtPos(o.start(-1)).node;"TABLE"!==l.nodeName&&(l=l.closest("table"));const a=l,c=a.firstChild,d=Array.from(c.children);if(d[s].style.width=n+"px",a.style.width){const e=d.map((e=>e.style.width));if(e.every(Boolean)){const t=e.reduce(((e,t)=>e+parseFloat(t)),0);a.style.width=t+"px"}}}(e,n.activeHandle,o)}return e.dispatch(u),t.view.addEventListener("mouseup",f),t.view.addEventListener("mousemove",m),t.preventDefault(),!0}(e,t)},decorations(e){if(!rp(np,e)){const t=np.getState(e);if(t.activeHandle>-1)return function(e,t){const n=[],o=e.doc.resolve(t),r=o.node(-1),i=va.get(r),s=o.start(-1),l=[],a=t-s;let c=-1;for(let e=0;e<i.height;e++)l.push(i.map.slice(e*i.width,e*i.width+i.width)),-1===c&&(c=l[e].lastIndexOf(a));const d=[];return l.forEach((e=>{const t=e[c];e[c]!==e[c+1]&&d.push(t)})),d.forEach((e=>{const t=s+e+r.nodeAt(e).nodeSize-1,o=document.createElement("div");o.className="column-resize-handle",n.push(Cl.widget(t,o))})),Ol.create(e.doc,n)}(e,t.activeHandle)}return Ol.empty},nodeViews:{table_wrapper:(e,t)=>new ep(e,t),table:(e,t)=>new Zh(e,t)}}});return e}class pp{constructor(e,t){this.activeHandle=e,this.dragging=t}apply(e){let t;const n=e.getMeta(np);if(n&&null!=n.setHandle)return new pp(n.setHandle,null);if(n&&void 0!==n.setDragging)return new pp(this.activeHandle,n.setDragging);if(this.activeHandle>-1&&e.docChanged){let n=e.mapping.map(this.activeHandle,-1);o=e.doc.resolve(n),Boolean("row"===o.parent.type.spec.tableRole&&o.nodeAfter)||(n=-1),t=new pp(n,this.dragging)}var o;return t||this}}function up(e,t){const n=e.state.tr;n.setMeta("addToHistory",!1),n.setMeta(np,{setHandle:t}),e.dispatch(n)}const fp={southeast:!0,southwest:!0,northwest:!0,northeast:!0},mp={east:!0,west:!0,...fp},gp={south:!0,north:!0,...fp};class yp{constructor(e,t,n){this.activeHandle=e,this.dragging=t,this.nodePosition=n}apply(e){const t=e.getMeta(tp);return t?new yp(t.activeHandle,t.setDragging,t.nodePosition):this}}const wp=e=>{const t=Array.from(e.firstChild.children).map((e=>e.offsetWidth)),n=Array.from(e.rows).map((e=>e.offsetHeight)),o=t.reduce(((e,t)=>e+t),0),r=n.reduce(((e,t)=>e+t),0),i=e.offsetHeight;return{width:o,height:r,colsWidth:t,rowsHeight:n,offsetWidth:e.offsetWidth,offsetHeight:i}},vp=(e,t)=>{const n=t.target.getAttribute(Tt);if(!n)return!1;const o=tp.getState(e.state);t.preventDefault();const r=e.state.tr;r.setMeta(tp,{setDragging:{startX:t.clientX,startY:t.clientY},activeHandle:n,nodePosition:o.nodePosition}),r.setMeta("addToHistory",!1),((e,t,n)=>{const o=e.state.doc.nodeAt(n),r=sp(e.nodeDOM(n)),i=r.firstChild;let s=dp(i);const{width:l,height:a,colsWidth:c,rowsHeight:d,offsetWidth:h,offsetHeight:p}=wp(r);Array.from(i&&i.children||[]).forEach(((e,t)=>{e.style.width&&!/%$/.test(e.style.width)&&(e.style.width=100*c[t]/l+"%",s=!0)}));let u=!1;o.forEach(((e,o,r)=>{const i=ln(e.attrs.style).height;i&&!/%$/.test(i)&&(t.setNodeMarkup(n+o+1,null,Jt(e.attrs,"height",100*d[r]/a+"%")),u=!0)}));let f=o.attrs;ln(f.style).width!==h+"px"&&(f=Jt(f,"width",h+"px")),s&&(f[Nt]=i.outerHTML),u&&(f=Jt(f,"height",p+"px")),(s||u)&&t.setNodeMarkup(n,null,f)})(e,r,o.nodePosition),e.dispatch(r);const i=t.view||window;function s(t){((e,t)=>{var n;const o=tp.getState(e.state),{dragging:r,nodePosition:i,activeHandle:s}=o;if(i<0||!r)return;const l=sp(e.nodeDOM(i)),a=l.getBoundingClientRect(),c=Wh[s],d=(t.clientX-r.startX)*c.x,h=(t.clientY-r.startY)*c.y,p=(l.ownerDocument&&l.ownerDocument.defaultView||window).getComputedStyle(l),u=/px/.test(p.width)?parseFloat(p.width):l.offsetWidth,f=/px/.test(p.height)?parseFloat(p.height):l.offsetHeight,m=c.x?d+u:a.width,g=c.y?h+f:a.height;if(r.startX=c.x?t.clientX:r.startX,r.startY=c.y?t.clientY:r.startY,mp[s]&&(l.style.width=m+"px"),gp[s]&&(l.style.height=g+"px"),/px/.test(l.style.width)){const e=null===(n=l.parentNode)||void 0===n?void 0:n.parentNode;e instanceof HTMLDivElement&&e.matches("div[table]")&&/%/.test(e.style.width)&&(e.style.width="")}})(e,t)}return i.addEventListener("mouseup",(function t(){i.removeEventListener("mouseup",t),i.removeEventListener("mousemove",s),(e=>{const{dragging:t,nodePosition:n,activeHandle:o}=tp.getState(e.state);if(t){const t=e.state.doc.nodeAt(n),r=sp(e.nodeDOM(n)),i=wp(r);if(t){const s=i.offsetWidth+"px",l=i.offsetHeight+"px",a=e.state.tr;let c=t.attrs;const d=ln(c.style);if(mp[o]&&r.style.width&&d.width!==s&&(c=Jt(c,"width",s)),gp[o]&&r.style.height&&d.height!==l&&(c=Jt(c,"height",l)),c=((e,t,n,o)=>{const r=e.state.doc.nodeAt(n),i=sp(e.nodeDOM(n)),s=(i.ownerDocument&&i.ownerDocument.defaultView||window).getComputedStyle,l=Array.from(i.rows);r.forEach(((e,o,r)=>{const i=ln(e.attrs.style).height;i&&!/px$/.test(i)&&t.setNodeMarkup(n+o+1,null,Jt(e.attrs,"height",s(l[r]).height))}));const a=i.firstChild,c=Array.from(a&&a.children||[]);let d=!1;c.forEach(((e,t)=>{e.style.width&&!/px$/.test(e.style.width)&&(e.style.width=s(c[t]).width,d=!0)}));const h={...o};return d&&(h[Nt]=a.outerHTML),h})(e,a,n,c),a.setNodeMarkup(n,null,c),a.setMeta("commandName","node-resize"),a.setMeta("args",c),a.setMeta(tp,{setDragging:null,activeHandle:null,nodePosition:n}),!/%/.test(ln(c.style).width||"")){const e=a.doc.resolve(n),t=Yt(e,(e=>"table_wrapper"===e.type.name));if(t&&/%/.test(ln(t.node.attrs.style).width||"")){const n=Jt(t.node.attrs,"width",""),o=e.start(t.depth)-1;a.setNodeMarkup(o,null,n)}}e.dispatch(a)}}})(e)})),i.addEventListener("mousemove",s),!0},bp=(e={node:"table"})=>new kt({key:tp,view:()=>({selectedNode(e,t){const n=e.selection;if(n instanceof at&&t===n.node.type&&n instanceof at)return{node:n.node,pos:n.from};const o=Yt(n.$from,(e=>e.type===t)),r=o&&o.node;return r?{node:r,pos:n.$from.start(o.depth)-1}:null},update(t,n){const o=t.state,r=o.schema.nodes[e.node],i=this.selectedNode(o,r),s=this.selectedNode(n,r);if((i||!s||n.doc.eq(t.state.doc))&&(i||s)){const e=o.tr;if(e.setMeta("addToHistory",!1),i&&s&&i.pos!==s.pos){e.setMeta(tp,{nodePosition:i.pos});const n=e.doc.nodeAt(s.pos);n&&n.type.name===r.name&&e.setNodeMarkup(s.pos,r,{...s.node.attrs,[Ot]:!1}),e.setNodeMarkup(i.pos,r,{...i.node.attrs,[Ot]:!0}),t.dispatch(e)}else i&&s&&i.pos===s.pos&&!i.node.attrs[Ot]&&!o.selection.eq(n.selection)?(e.setMeta(tp,{nodePosition:i.pos}),t.dispatch(e.setNodeMarkup(i.pos,r,{...i.node.attrs,[Ot]:!0}))):i&&!s?(e.setMeta(tp,{nodePosition:i.pos}),t.dispatch(e.setNodeMarkup(i.pos,r,{...i.node.attrs,[Ot]:!0}))):!i&&s&&(e.setMeta(tp,{nodePosition:-1}),t.dispatch(e.setNodeMarkup(s.pos,r,{...s.node.attrs,[Ot]:!1})))}}}),state:{init:()=>new yp("",null,-1),apply:(e,t)=>t.apply(e)},props:{handleDOMEvents:{mousedown:(e,t)=>vp(e,t)}}});class kp{ignoreMutation(e){return"attributes"===e.type&&"style"===e.attributeName&&"TR"===e.target.nodeName}}function xp(){const e=new kt({key:op,state:{init(e,t){return this.spec.props.nodeViews[Ma(t.schema).row.name]=()=>new kp,new Sp(-1,null)},apply:(e,t)=>t.apply(e)},props:{attributes:e=>ip(op,e)?null:op.getState(e).activeHandle>-1?{class:"resize-cursor-vertical"}:null,handleDOMEvents:{mousemove:(e,t)=>(rp(op,e.state)||function(e,t){const n=op.getState(e.state);if(!n.dragging){const o=lp(t.target);let r=-1;if(o){const n=ap(o),{top:i,bottom:s}=o.getBoundingClientRect();Math.abs(t.clientY-i)<=5&&n.rowIndex>0?(n.rowIndex-=o.rowSpan,r=cp(e,t,n)):s-t.clientY>0&&s-t.clientY<=5&&(r=cp(e,t,n))}r!==n.activeHandle&&Cp(e,r)}}(e,t),!1),mouseleave:e=>(function(e){const t=op.getState(e.state);t.activeHandle>-1&&!t.dragging&&Cp(e,-1)}(e),!1),mousedown:(e,t)=>function(e,t){const n=op.getState(e.state);if(-1===n.activeHandle||n.dragging)return!1;const o=e.state.doc.resolve(n.activeHandle),r=o.parent,i=o.node(-1),s=ln(r.attrs.style).height,l=ln(i.attrs.style).height;let a=s?parseFloat(s):0;function c(t){t.view.removeEventListener("mouseup",c),t.view.removeEventListener("mousemove",d);const n=op.getState(e.state);if(n.dragging){const t=e.state.tr.setMeta(op,{setDragging:null});!function(e,t,n){const o=e.state.doc,r=o.resolve(n),i=r.parent,s=r.posAtIndex(0)-1,l=e.nodeDOM(s),a=l.ownerDocument&&l.ownerDocument.defaultView||window;l.style.height=a.getComputedStyle(l).height,t.setNodeMarkup(s,null,Jt(i.attrs,"height",l.style.height));const c=l&&l.closest("table"),d=c&&c.style.height;if(d){const e=o.resolve(s),n=e.start(e.depth)-1;t.setNodeMarkup(n,null,Jt(e.parent.attrs,"height",d))}}(e,t,n.activeHandle),e.dispatch(t)}}function d(t){if(!t.which)return c(t);const n=op.getState(e.state),o=function(e,t){const n=t.clientY-e.startY;return e.startHeight.rowHeight+n}(n.dragging,t),r=t.clientY-n.dragging.startY;!function(e,t,n,o,r){const i=e.nodeDOM(t),s=i&&i.parentNode;if(s){s.style.height=n+"px";const e=s.ownerDocument&&s.ownerDocument.defaultView||window;s.style.height=e.getComputedStyle(s).height;const t=s.closest("table"),i=parseFloat(r)+o+"px",l=t&&t.style.height;l&&l!==i&&(t.style.height=parseFloat(r)+o+"px",t.style.height=e.getComputedStyle(t).height)}}(e,n.activeHandle,o,r,l)}return s||(a=e.nodeDOM(n.activeHandle).offsetHeight),e.dispatch(e.state.tr.setMeta(op,{setDragging:{startY:t.clientY,startHeight:{rowHeight:a,tableHeight:l}}})),t.view.addEventListener("mouseup",c),t.view.addEventListener("mousemove",d),t.preventDefault(),!0}(e,t)},decorations(e){if(rp(op,e))return Ol.empty;const t=op.getState(e);return t.activeHandle>-1?function(e,t){const n=[];if("number"!=typeof t)return Ol.empty;const o=e.doc.resolve(t),r=o.node(-1),i=va.get(r),s=o.start(-1),l=[],a=t-s;let c=-1;for(let e=0;e<i.height;e++)l.push(i.map.slice(e*i.width,e*i.width+i.width)),-1!==l[e].indexOf(a)&&(c=e);const d=[];return l[c].forEach(((e,t)=>{l[c+1]&&e===l[c+1][t]||d.push(e)})),d.forEach((e=>{const t=r.nodeAt(e),o=s+e+(t?t.nodeSize:0)-1,i=document.createElement("div");i.className="row-resize-handle",n.push(Cl.widget(o,i))})),Ol.create(e.doc,n)}(e,t.activeHandle):void 0},nodeViews:{}}});return e}class Sp{constructor(e,t){this.activeHandle=e,this.dragging=t}apply(e){let t;const n=e.getMeta(op);if(n&&null!=n.setHandle)return new Sp(n.setHandle,null);if(n&&void 0!==n.setDragging)return new Sp(this.activeHandle,n.setDragging);if(this.activeHandle>-1){let n=e.mapping.map(this.activeHandle,-1);"row"===(o=e.doc.resolve(n)).parent.type.spec.tableRole&&o.nodeAfter||(n=null),t=new Sp(n,this.dragging)}var o;return t||this}}function Cp(e,t){const n=e.state.tr;n.setMeta("addToHistory",!1),n.setMeta(op,{setHandle:t}),e.dispatch(n)}const Mp=()=>[bp(),hp(),xp()],Np=(e,t,n,o,r)=>{const i=r.resolve(e),s=r.resolve(t),l=o.type.name;let a,c;return!i.nodeBefore&&(a=i.node(i.depth),c=i.node(i.depth-1),a&&c&&c.firstChild===a&&c.type.name===l)?n+o.content.size<=t:!s.nodeAfter&&(a=s.node(s.depth),c=s.node(s.depth-1),a&&c&&c.lastChild===a&&c.type.name===l)?e<=n:e<=n&&n+o.content.size<=t},Op=(e,t,n)=>{const{tr:o,doc:r,selection:{from:i,to:s}}=t,l=e.getMeta("args");return r.nodesBetween(i,s,((e,t)=>{e.type.name===n.listItem&&Np(i,s,t,e,r)&&o.setNodeMarkup(t,null,{...e.attrs,style:an(e.attrs.style,l.style,l.value)})})),o.docChanged?o:void 0},Ap=(e,t,n)=>{const o=Object.keys(n.resetValues),{tr:r,doc:i,selection:{from:s,to:l}}=t;return i.nodesBetween(s,l,((e,t)=>{if(e.type.name===n.listItem&&Np(s,l,t,e,i)){let n=e.attrs;const i=ln(e.attrs.style);o.forEach((e=>{i[e]&&(n={...n,style:an(n.style,e,"")})})),n!==e.attrs&&r.setNodeMarkup(t,null,n)}})),e.steps.forEach((e=>{if(e instanceof xe){const t=e.mark;if("style"===t.type.name&&t.attrs.style){const[o]=t.attrs.style.split(/\s*:\s*/),i=Yt(r.doc.resolve(e.from),(e=>e.type.name===n.listItem));if(i&&ln(i.node.attrs.style)[o]&&n.resetValues[o]){const i=t.type.create({style:`${o}: ${n.resetValues[o]};`});r.addMark(e.from,e.to,i)}}}})),r.docChanged?r:void 0},Tp={listItem:"list_item",resetValues:{"font-size":"","font-family":"",color:""}};function Dp(e=Tp){return new kt({key:new Ct("list-markers-styles"),appendTransaction:(t,n,o)=>{const r=t.slice().pop(),i=r.getMeta("commandName");let s;return"FontSize"===i||"FontName"===i||"ForeColor"===i?s=Op(r,o,e):"CleanFormatting"===i&&(s=Ap(r,o,e)),s&&s.setMeta("addToHistory",!0),s}})}function Ep(e={}){return new kt({view:t=>new Rp(t,e)})}class Rp{constructor(e,t){var n;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=null!==(n=t.width)&&void 0!==n?n:1,this.color=!1===t.color?void 0:t.color||"black",this.class=t.class,this.handlers=["dragover","dragend","drop","dragleave"].map((t=>{let n=e=>{this[t](e)};return e.dom.addEventListener(t,n),{name:t,handler:n}}))}destroy(){this.handlers.forEach((({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t)))}update(e,t){null!=this.cursorPos&&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,null==e?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e,t=this.editorView.state.doc.resolve(this.cursorPos),n=!t.parent.inlineContent,o=this.editorView.dom,r=o.getBoundingClientRect(),i=r.width/o.offsetWidth,s=r.height/o.offsetHeight;if(n){let n=t.nodeBefore,o=t.nodeAfter;if(n||o){let t=this.editorView.nodeDOM(this.cursorPos-(n?n.nodeSize:0));if(t){let r=t.getBoundingClientRect(),i=n?r.bottom:r.top;n&&o&&(i=(i+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let l=this.width/2*s;e={left:r.left,right:r.right,top:i-l,bottom:i+l}}}}if(!e){let t=this.editorView.coordsAtPos(this.cursorPos),n=this.width/2*i;e={left:t.left-n,right:t.left+n,top:t.top,bottom:t.bottom}}let l,a,c=this.editorView.dom.offsetParent;if(this.element||(this.element=c.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",n),this.element.classList.toggle("prosemirror-dropcursor-inline",!n),!c||c==document.body&&"static"==getComputedStyle(c).position)l=-pageXOffset,a=-pageYOffset;else{let e=c.getBoundingClientRect(),t=e.width/c.offsetWidth,n=e.height/c.offsetHeight;l=e.left-c.scrollLeft*t,a=e.top-c.scrollTop*n}this.element.style.left=(e.left-l)/i+"px",this.element.style.top=(e.top-a)/s+"px",this.element.style.width=(e.right-e.left)/i+"px",this.element.style.height=(e.bottom-e.top)/s+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout((()=>this.setCursor(null)),e)}dragover(e){if(!this.editorView.editable)return;let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),n=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),o=n&&n.type.spec.disableDropCursor,r="function"==typeof o?o(this.editorView,t,e):o;if(t&&!r){let e=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let t=Le(this.editorView.state.doc,e,this.editorView.dragging.slice);null!=t&&(e=t)}this.setCursor(e),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}class $p extends nt{constructor(e){super(e,e)}map(e,t){let n=e.resolve(t.map(this.head));return $p.valid(n)?new $p(n):nt.near(n)}content(){return p.empty}eq(e){return e instanceof $p&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,t){if("number"!=typeof t.pos)throw new RangeError("Invalid input for GapCursor.fromJSON");return new $p(e.resolve(t.pos))}getBookmark(){return new Ip(this.anchor)}static valid(e){let t=e.parent;if(t.isTextblock||!function(e){for(let t=e.depth;t>=0;t--){let n=e.index(t),o=e.node(t);if(0!=n)for(let e=o.child(n-1);;e=e.lastChild){if(0==e.childCount&&!e.inlineContent||e.isAtom||e.type.spec.isolating)return!0;if(e.inlineContent)return!1}else if(o.type.spec.isolating)return!0}return!0}(e)||!function(e){for(let t=e.depth;t>=0;t--){let n=e.indexAfter(t),o=e.node(t);if(n!=o.childCount)for(let e=o.child(n);;e=e.firstChild){if(0==e.childCount&&!e.inlineContent||e.isAtom||e.type.spec.isolating)return!0;if(e.inlineContent)return!1}else if(o.type.spec.isolating)return!0}return!0}(e))return!1;let n=t.type.spec.allowGapCursor;if(null!=n)return n;let o=t.contentMatchAt(e.index()).defaultType;return o&&o.isTextblock}static findGapCursorFrom(e,t,n=!1){e:for(;;){if(!n&&$p.valid(e))return e;let o=e.pos,r=null;for(let n=e.depth;;n--){let i=e.node(n);if(t>0?e.indexAfter(n)<i.childCount:e.index(n)>0){r=i.child(t>0?e.indexAfter(n):e.index(n)-1);break}if(0==n)return null;o+=t;let s=e.doc.resolve(o);if($p.valid(s))return s}for(;;){let i=t>0?r.firstChild:r.lastChild;if(!i){if(r.isAtom&&!r.isText&&!at.isSelectable(r)){e=e.doc.resolve(o+r.nodeSize*t),n=!1;continue e}break}r=i,o+=t;let s=e.doc.resolve(o);if($p.valid(s))return s}return null}}}$p.prototype.visible=!1,$p.findFrom=$p.findGapCursorFrom,nt.jsonID("gapcursor",$p);class Ip{constructor(e){this.pos=e}map(e){return new Ip(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return $p.valid(t)?new $p(t):nt.near(t)}}function zp(){return new kt({props:{decorations:Lp,createSelectionBetween:(e,t,n)=>t.pos==n.pos&&$p.valid(n)?new $p(n):null,handleClick:Vp,handleKeyDown:Bp,handleDOMEvents:{beforeinput:Fp}}})}const Bp=ga({ArrowLeft:Pp("horiz",-1),ArrowRight:Pp("horiz",1),ArrowUp:Pp("vert",-1),ArrowDown:Pp("vert",1)});function Pp(e,t){const n="vert"==e?t>0?"down":"up":t>0?"right":"left";return function(e,o,r){let i=e.selection,s=t>0?i.$to:i.$from,l=i.empty;if(i instanceof st){if(!r.endOfTextblock(n)||0==s.depth)return!1;l=!1,s=e.doc.resolve(t>0?s.after():s.before())}let a=$p.findGapCursorFrom(s,t,l);return!!a&&(o&&o(e.tr.setSelection(new $p(a))),!0)}}function Vp(e,t,n){if(!e||!e.editable)return!1;let o=e.state.doc.resolve(t);if(!$p.valid(o))return!1;let r=e.posAtCoords({left:n.clientX,top:n.clientY});return!(r&&r.inside>-1&&at.isSelectable(e.state.doc.nodeAt(r.inside))||(e.dispatch(e.state.tr.setSelection(new $p(o))),0))}function Fp(e,t){if("insertCompositionText"!=t.inputType||!(e.state.selection instanceof $p))return!1;let{$from:n}=e.state.selection,o=n.parent.contentMatchAt(n.index()).findWrapping(e.state.schema.nodes.text);if(!o)return!1;let r=s.empty;for(let e=o.length-1;e>=0;e--)r=s.from(o[e].createAndFill(null,r));let i=e.state.tr.replace(n.pos,n.pos,new p(r,0,0));return i.setSelection(st.near(i.doc.resolve(n.pos+1))),e.dispatch(i),!1}function Lp(e){if(!(e.selection instanceof $p))return null;let t=document.createElement("div");return t.className="ProseMirror-gapcursor",Ol.create(e.doc,[Cl.widget(e.selection.head,t,{key:"gapcursor"})])}const Hp=(e,t,n)=>{const{table:o,table_row:r,table_cell:i}=e,s=[];let l;for(let e=0;e<t+1;e++){l=[];for(let e=0;e<n+1;e++)l.push(i.createAndFill());s.push(r.createAndFill(void 0,l))}return o.createAndFill(void 0,s)},_p=/^table$/,Wp=/^table_row$/,qp=/^table_cell|table_header$/,jp=(e,t)=>{const n=e.$head;for(let e=n.depth;e>0;e--){const o=n.node(e);if(t.test(o.type.name))return{pos:n.before(e),node:o}}return null},Jp=(e,t)=>{const n=t&&(e=>{const n=jp(e.selection,Wp),o=jp(e.selection,_p);if(n&&o&&n.node.attrs[Mt]){let t=0;for(let e=0;e<o.node.nodeSize;e++)if(o.node.child(e).eq(n.node)){t=e;break}const r=o.node.child(t-1),i=n.pos-r.nodeSize;e.setNodeMarkup(i,void 0,{[Mt]:n.node.attrs[Mt]})}return t(e)});return Za(e,n)},Kp=(e,t)=>ec(e,t&&(e=>{const n=jp(e.selection,Wp);if(n&&n.node.attrs[Mt]){const t=n.pos+n.node.nodeSize;e.setNodeMarkup(t,void 0,{[Mt]:n.node.attrs[Mt]})}return t(e)})),Xp=(e,t)=>{if(!e)return-1;const n=va.get(e.node),o=jp(t,qp),r=n.map.indexOf(o.pos-e.pos-1);let i=-1;return-1!==r&&(i=r%n.width),i},Up=(e,t,n)=>{const o=Xp(t,e.selection),r=od(t.node.attrs[Nt]);r.insertBefore(r.ownerDocument.createElement("col"),r.children[o+n]),e.setNodeMarkup(t.pos,null,{...t.node.attrs,[Nt]:r.outerHTML})},Yp=(e,t)=>Ka(e,t&&(e=>{const n=jp(e.selection,_p);return n.node.attrs[Nt]?(Up(e,n,-1),t(e)):t(e)})),Gp=(e,t)=>Xa(e,t&&(e=>{const n=jp(e.selection,_p);return n.node.attrs[Nt]?(Up(e,n,1),t(e)):t(e)})),Qp=(e,t)=>{const n=jp(e.selection,_p),o=n&&n.node.attrs[Nt],r=Xp(n,e.selection),i=t&&(e=>{if(!o)return t(e);const i=e.doc.nodeAt(n.pos);return((e,t,n)=>{const o=od(t.node.attrs[Nt]);o.removeChild(o.children[n]),e.setNodeMarkup(t.pos,null,{...t.node.attrs,[Nt]:o.outerHTML})})(e,{node:i,pos:n.pos},r),t(e)});return Ya(e,i)};return t})()));
1
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.KendoEditorCommon=t():e.KendoEditorCommon=t()}(self,(()=>(()=>{"use strict";var e={d:(t,n)=>{for(var o in n)e.o(n,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:n[o]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};function n(e){this.content=e}e.r(t),e.d(t,{AddMarkStep:()=>ke,AddNodeMarkStep:()=>Se,AllSelection:()=>dt,AttrStep:()=>Ye,CellSelection:()=>Fa,ContentMatch:()=>$,DOMParser:()=>Y,DOMSerializer:()=>le,Decoration:()=>Cl,DecorationSet:()=>Ol,DocAttrStep:()=>Qe,EditorState:()=>vt,EditorView:()=>Zl,Fragment:()=>s,GapCursor:()=>$p,InputRule:()=>Ed,MapResult:()=>fe,Mapping:()=>ge,Mark:()=>d,MarkType:()=>X,Node:()=>D,NodeRange:()=>A,NodeSelection:()=>at,NodeType:()=>J,Plugin:()=>kt,PluginKey:()=>Ct,RemoveMarkStep:()=>xe,RemoveNodeMarkStep:()=>Ce,ReplaceAroundStep:()=>Ne,ReplaceError:()=>h,ReplaceStep:()=>Me,ResolvedPos:()=>C,Schema:()=>U,Selection:()=>nt,SelectionRange:()=>ot,Slice:()=>p,Step:()=>we,StepMap:()=>me,StepResult:()=>ve,TableMap:()=>va,TextSelection:()=>st,Transaction:()=>ft,Transform:()=>et,TransformError:()=>Ze,__endComposition:()=>Ql,__parseFromClipboard:()=>Yl,activeNode:()=>po,addColSpan:()=>Pa,addColumn:()=>Ja,addColumnAfter:()=>Qp,addColumnBefore:()=>Yp,addListNodes:()=>So,addRow:()=>Qa,addRowAfter:()=>Xp,addRowBefore:()=>Kp,alignBlocks:()=>uo,alignCenterRules:()=>_r,alignJustifyRules:()=>Wr,alignLeftRules:()=>Lr,alignRemoveRules:()=>qr,alignRightRules:()=>Hr,applyInlineStyle:()=>Qn,applyLink:()=>eo,autoJoin:()=>mr,baseKeymap:()=>kr,blockNodes:()=>ro,blockquote:()=>xr,bold:()=>jd,buildKeymap:()=>Zd,buildListKeymap:()=>eh,bulletList:()=>bo,canBeIndented:()=>Ar,canIndentAsListItem:()=>Nr,canInsert:()=>Kt,canJoin:()=>Be,canOutdentAsListItem:()=>Or,canSplit:()=>ze,caretColor:()=>Qh,caretColorKey:()=>Yh,cellAround:()=>Oa,chainCommands:()=>gr,changeTextBlock:()=>oo,cleanFormatting:()=>mo,cleanMarks:()=>Hn,cleanTextBlockFormatting:()=>so,closeDoubleQuote:()=>Fd,closeHistory:()=>bd,closeSingleQuote:()=>Hd,colCount:()=>Ia,columnIsHeader:()=>Va,columnResizing:()=>$c,columnResizingPluginKey:()=>Rc,convertMsLists:()=>ch,createParagraphNear:()=>er,createTable:()=>_p,cspFix:()=>Lh,deleteColumn:()=>Zp,deleteRow:()=>nc,deleteSelection:()=>zo,deleteTable:()=>fc,domToPmDoc:()=>Nn,dropCursor:()=>Ep,dropPoint:()=>Le,ellipsis:()=>Pd,emDash:()=>Bd,exitCode:()=>Zo,expandSelection:()=>rn,expandToWordWrap:()=>sn,find:()=>Nh,findAll:()=>Oh,findAt:()=>Mh,findCell:()=>$a,findWrapping:()=>Ee,fixTables:()=>qa,fixTablesKey:()=>_a,flattenNestedSpans:()=>Bn,formatBlockElements:()=>io,fragmentToHtml:()=>Cn,gapCursor:()=>Bp,getActiveMarks:()=>Jn,getBlockFormats:()=>lo,getHtml:()=>An,getInlineStyles:()=>Un,getMark:()=>jn,getNodeFromSelection:()=>en,getSelectionText:()=>Zt,goToNextCell:()=>uc,hasMark:()=>_n,hasNode:()=>co,hasSameMarkup:()=>Dn,history:()=>Sd,htmlToFragment:()=>Sn,imageResizeKey:()=>jh,imageResizing:()=>Gh,inSameTable:()=>Ra,indent:()=>Tr,indentBlocks:()=>Cr,indentHtml:()=>nn,indentRules:()=>$o,inputRules:()=>$d,insertImage:()=>no,insertNode:()=>Qt,insertPoint:()=>Fe,insertText:()=>to,isAligned:()=>fo,isInTable:()=>Aa,isIndented:()=>Mr,italic:()=>Jd,joinBackward:()=>Po,joinDown:()=>Uo,joinForward:()=>jo,joinPoint:()=>Ve,joinTextblockBackward:()=>Vo,joinTextblockForward:()=>Fo,joinUp:()=>Xo,keydownHandler:()=>ga,keymap:()=>ma,lift:()=>Go,liftBlockquote:()=>Sr,liftEmptyBlock:()=>tr,liftListItem:()=>Ao,liftTarget:()=>De,link:()=>Yd,listItem:()=>ko,listMarkersStyles:()=>Dp,listStyle:()=>zr,macBaseKeymap:()=>br,marks:()=>Qc,mergeCells:()=>rc,moveCellForward:()=>Ea,newlineInCode:()=>Yo,nextCell:()=>za,nodes:()=>id,openDoubleQuote:()=>Vd,openSingleQuote:()=>Ld,orderedList:()=>vo,outdent:()=>Dr,outdentRules:()=>Io,parentBlockFormat:()=>ho,parentNode:()=>Gt,parseContent:()=>On,pasteCleanup:()=>mh,pcBaseKeymap:()=>vr,placeholder:()=>$h,pmAddColumnAfter:()=>Xa,pmAddColumnBefore:()=>Ka,pmAddRowAfter:()=>ec,pmAddRowBefore:()=>Za,pmDeleteColumn:()=>Ga,pmDocToFragment:()=>Mn,redo:()=>Nd,redoDepth:()=>Dd,redoNoScroll:()=>Ad,removeAllMarks:()=>Ln,removeAttribute:()=>ph,removeColSpan:()=>Ba,removeComments:()=>En,removeLink:()=>Zn,removeTag:()=>hh,replace:()=>Ah,replaceAll:()=>Th,replaceImageSourcesFromRtf:()=>Ch,replaceStep:()=>He,rowIsHeader:()=>Ya,sanitize:()=>dh,sanitizeClassAttr:()=>uh,sanitizeStyleAttr:()=>fh,selectAll:()=>sr,selectNodeBackward:()=>_o,selectNodeForward:()=>Jo,selectParentNode:()=>ir,selectTextblockEnd:()=>dr,selectTextblockStart:()=>cr,selectedLineTextOnly:()=>tn,selectedRect:()=>ja,selectionCell:()=>Ta,selectionMarks:()=>qn,setBlockType:()=>pr,setCellAttr:()=>lc,setHtml:()=>Tn,sinkListItem:()=>To,smartQuotes:()=>_d,spacesFix:()=>Bh,splitBlock:()=>or,splitBlockAs:()=>nr,splitBlockKeepMarks:()=>rr,splitCell:()=>ic,splitCellWithType:()=>sc,splitListItem:()=>No,splitListItemKeepMarks:()=>Oo,strikethrough:()=>Xd,subscript:()=>Ud,superscript:()=>Gd,tableColumnResizeKey:()=>np,tableEditing:()=>Fc,tableEditingKey:()=>Na,tableNodeTypes:()=>Ma,tableNodes:()=>Ca,tableResizeKey:()=>tp,tableResizing:()=>Mp,tableRowResizeKey:()=>op,textHighlight:()=>_h,textHighlightKey:()=>Hh,textblockTypeInputRule:()=>qd,toggleHeader:()=>cc,toggleHeaderCell:()=>pc,toggleHeaderColumn:()=>hc,toggleHeaderRow:()=>dc,toggleInlineFormat:()=>Yn,toggleList:()=>Br,toggleMark:()=>ur,toggleOrderedList:()=>Vr,toggleUnorderedList:()=>Pr,trimWhitespace:()=>yn,underline:()=>Kd,undo:()=>Md,undoDepth:()=>Td,undoInputRule:()=>zd,undoNoScroll:()=>Od,updateColumnsOnResize:()=>Ec,wrapIn:()=>hr,wrapInList:()=>Co,wrapRangeInList:()=>Mo,wrappingInputRule:()=>Wd}),n.prototype={constructor:n,find:function(e){for(var t=0;t<this.content.length;t+=2)if(this.content[t]===e)return t;return-1},get:function(e){var t=this.find(e);return-1==t?void 0:this.content[t+1]},update:function(e,t,o){var r=o&&o!=e?this.remove(o):this,i=r.find(e),s=r.content.slice();return-1==i?s.push(o||e,t):(s[i+1]=t,o&&(s[i]=o)),new n(s)},remove:function(e){var t=this.find(e);if(-1==t)return this;var o=this.content.slice();return o.splice(t,2),new n(o)},addToStart:function(e,t){return new n([e,t].concat(this.remove(e).content))},addToEnd:function(e,t){var o=this.remove(e).content.slice();return o.push(e,t),new n(o)},addBefore:function(e,t,o){var r=this.remove(t),i=r.content.slice(),s=r.find(e);return i.splice(-1==s?i.length:s,0,t,o),new n(i)},forEach:function(e){for(var t=0;t<this.content.length;t+=2)e(this.content[t],this.content[t+1])},prepend:function(e){return(e=n.from(e)).size?new n(e.content.concat(this.subtract(e).content)):this},append:function(e){return(e=n.from(e)).size?new n(this.subtract(e).content.concat(e.content)):this},subtract:function(e){var t=this;e=n.from(e);for(var o=0;o<e.content.length;o+=2)t=t.remove(e.content[o]);return t},toObject:function(){var e={};return this.forEach((function(t,n){e[t]=n})),e},get size(){return this.content.length>>1}},n.from=function(e){if(e instanceof n)return e;var t=[];if(e)for(var o in e)t.push(o,e[o]);return new n(t)};const o=n;function r(e,t,n){for(let o=0;;o++){if(o==e.childCount||o==t.childCount)return e.childCount==t.childCount?null:n;let i=e.child(o),s=t.child(o);if(i!=s){if(!i.sameMarkup(s))return n;if(i.isText&&i.text!=s.text){for(let e=0;i.text[e]==s.text[e];e++)n++;return n}if(i.content.size||s.content.size){let e=r(i.content,s.content,n+1);if(null!=e)return e}n+=i.nodeSize}else n+=i.nodeSize}}function i(e,t,n,o){for(let r=e.childCount,s=t.childCount;;){if(0==r||0==s)return r==s?null:{a:n,b:o};let l=e.child(--r),a=t.child(--s),c=l.nodeSize;if(l!=a){if(!l.sameMarkup(a))return{a:n,b:o};if(l.isText&&l.text!=a.text){let e=0,t=Math.min(l.text.length,a.text.length);for(;e<t&&l.text[l.text.length-e-1]==a.text[a.text.length-e-1];)e++,n--,o--;return{a:n,b:o}}if(l.content.size||a.content.size){let e=i(l.content,a.content,n-1,o-1);if(e)return e}n-=c,o-=c}else n-=c,o-=c}}class s{constructor(e,t){if(this.content=e,this.size=t||0,null==t)for(let t=0;t<e.length;t++)this.size+=e[t].nodeSize}nodesBetween(e,t,n,o=0,r){for(let i=0,s=0;s<t;i++){let l=this.content[i],a=s+l.nodeSize;if(a>e&&!1!==n(l,o+s,r||null,i)&&l.content.size){let r=s+1;l.nodesBetween(Math.max(0,e-r),Math.min(l.content.size,t-r),n,o+r)}s=a}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,n,o){let r="",i=!0;return this.nodesBetween(e,t,((s,l)=>{let a=s.isText?s.text.slice(Math.max(e,l)-l,t-l):s.isLeaf?o?"function"==typeof o?o(s):o:s.type.spec.leafText?s.type.spec.leafText(s):"":"";s.isBlock&&(s.isLeaf&&a||s.isTextblock)&&n&&(i?i=!1:r+=n),r+=a}),0),r}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,n=e.firstChild,o=this.content.slice(),r=0;for(t.isText&&t.sameMarkup(n)&&(o[o.length-1]=t.withText(t.text+n.text),r=1);r<e.content.length;r++)o.push(e.content[r]);return new s(o,this.size+e.size)}cut(e,t=this.size){if(0==e&&t==this.size)return this;let n=[],o=0;if(t>e)for(let r=0,i=0;i<t;r++){let s=this.content[r],l=i+s.nodeSize;l>e&&((i<e||l>t)&&(s=s.isText?s.cut(Math.max(0,e-i),Math.min(s.text.length,t-i)):s.cut(Math.max(0,e-i-1),Math.min(s.content.size,t-i-1))),n.push(s),o+=s.nodeSize),i=l}return new s(n,o)}cutByIndex(e,t){return e==t?s.empty:0==e&&t==this.content.length?this:new s(this.content.slice(e,t))}replaceChild(e,t){let n=this.content[e];if(n==t)return this;let o=this.content.slice(),r=this.size+t.nodeSize-n.nodeSize;return o[e]=t,new s(o,r)}addToStart(e){return new s([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new s(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw new RangeError("Index "+e+" out of range for "+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,n=0;t<this.content.length;t++){let o=this.content[t];e(o,n,t),n+=o.nodeSize}}findDiffStart(e,t=0){return r(this,e,t)}findDiffEnd(e,t=this.size,n=e.size){return i(this,e,t,n)}findIndex(e){if(0==e)return a(0,e);if(e==this.size)return a(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,n=0;;t++){let o=n+this.child(t).nodeSize;if(o>=e)return o==e?a(t+1,o):a(t,n);n=o}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map((e=>e.toJSON())):null}static fromJSON(e,t){if(!t)return s.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new s(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return s.empty;let t,n=0;for(let o=0;o<e.length;o++){let r=e[o];n+=r.nodeSize,o&&r.isText&&e[o-1].sameMarkup(r)?(t||(t=e.slice(0,o)),t[t.length-1]=r.withText(t[t.length-1].text+r.text)):t&&t.push(r)}return new s(t||e,n)}static from(e){if(!e)return s.empty;if(e instanceof s)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new s([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}s.empty=new s([],0);const l={index:0,offset:0};function a(e,t){return l.index=e,l.offset=t,l}function c(e,t){if(e===t)return!0;if(!e||"object"!=typeof e||!t||"object"!=typeof t)return!1;let n=Array.isArray(e);if(Array.isArray(t)!=n)return!1;if(n){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!c(e[n],t[n]))return!1}else{for(let n in e)if(!(n in t)||!c(e[n],t[n]))return!1;for(let n in t)if(!(n in e))return!1}return!0}class d{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,n=!1;for(let o=0;o<e.length;o++){let r=e[o];if(this.eq(r))return e;if(this.type.excludes(r.type))t||(t=e.slice(0,o));else{if(r.type.excludes(this.type))return e;!n&&r.type.rank>this.type.rank&&(t||(t=e.slice(0,o)),t.push(this),n=!0),t&&t.push(r)}}return t||(t=e.slice()),n||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&c(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Mark.fromJSON");let n=e.marks[t.type];if(!n)throw new RangeError(`There is no mark type ${t.type} in this schema`);let o=n.create(t.attrs);return n.checkAttrs(o.attrs),o}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].eq(t[n]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&0==e.length)return d.none;if(e instanceof d)return[e];let t=e.slice();return t.sort(((e,t)=>e.type.rank-t.type.rank)),t}}d.none=[];class h extends Error{}class p{constructor(e,t,n){this.content=e,this.openStart=t,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let n=f(this.content,e+this.openStart,t);return n&&new p(n,this.openStart,this.openEnd)}removeBetween(e,t){return new p(u(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 p.empty;let n=t.openStart||0,o=t.openEnd||0;if("number"!=typeof n||"number"!=typeof o)throw new RangeError("Invalid input for Slice.fromJSON");return new p(s.fromJSON(e,t.content),n,o)}static maxOpen(e,t=!0){let n=0,o=0;for(let o=e.firstChild;o&&!o.isLeaf&&(t||!o.type.spec.isolating);o=o.firstChild)n++;for(let n=e.lastChild;n&&!n.isLeaf&&(t||!n.type.spec.isolating);n=n.lastChild)o++;return new p(e,n,o)}}function u(e,t,n){let{index:o,offset:r}=e.findIndex(t),i=e.maybeChild(o),{index:s,offset:l}=e.findIndex(n);if(r==t||i.isText){if(l!=n&&!e.child(s).isText)throw new RangeError("Removing non-flat range");return e.cut(0,t).append(e.cut(n))}if(o!=s)throw new RangeError("Removing non-flat range");return e.replaceChild(o,i.copy(u(i.content,t-r-1,n-r-1)))}function f(e,t,n,o){let{index:r,offset:i}=e.findIndex(t),s=e.maybeChild(r);if(i==t||s.isText)return o&&!o.canReplace(r,r,n)?null:e.cut(0,t).append(n).append(e.cut(t));let l=f(s.content,t-i-1,n,s);return l&&e.replaceChild(r,s.copy(l))}function m(e,t,n){if(n.openStart>e.depth)throw new h("Inserted content deeper than insertion position");if(e.depth-n.openStart!=t.depth-n.openEnd)throw new h("Inconsistent open depths");return g(e,t,n,0)}function g(e,t,n,o){let r=e.index(o),i=e.node(o);if(r==t.index(o)&&o<e.depth-n.openStart){let s=g(e,t,n,o+1);return i.copy(i.content.replaceChild(r,s))}if(n.content.size){if(n.openStart||n.openEnd||e.depth!=o||t.depth!=o){let{start:r,end:l}=function(e,t){let n=t.depth-e.openStart,o=t.node(n).copy(e.content);for(let e=n-1;e>=0;e--)o=t.node(e).copy(s.from(o));return{start:o.resolveNoCache(e.openStart+n),end:o.resolveNoCache(o.content.size-e.openEnd-n)}}(n,e);return k(i,x(e,r,l,t,o))}{let o=e.parent,r=o.content;return k(o,r.cut(0,e.parentOffset).append(n.content).append(r.cut(t.parentOffset)))}}return k(i,S(e,t,o))}function y(e,t){if(!t.type.compatibleContent(e.type))throw new h("Cannot join "+t.type.name+" onto "+e.type.name)}function w(e,t,n){let o=e.node(n);return y(o,t.node(n)),o}function v(e,t){let n=t.length-1;n>=0&&e.isText&&e.sameMarkup(t[n])?t[n]=e.withText(t[n].text+e.text):t.push(e)}function b(e,t,n,o){let r=(t||e).node(n),i=0,s=t?t.index(n):r.childCount;e&&(i=e.index(n),e.depth>n?i++:e.textOffset&&(v(e.nodeAfter,o),i++));for(let e=i;e<s;e++)v(r.child(e),o);t&&t.depth==n&&t.textOffset&&v(t.nodeBefore,o)}function k(e,t){return e.type.checkContent(t),e.copy(t)}function x(e,t,n,o,r){let i=e.depth>r&&w(e,t,r+1),l=o.depth>r&&w(n,o,r+1),a=[];return b(null,e,r,a),i&&l&&t.index(r)==n.index(r)?(y(i,l),v(k(i,x(e,t,n,o,r+1)),a)):(i&&v(k(i,S(e,t,r+1)),a),b(t,n,r,a),l&&v(k(l,S(n,o,r+1)),a)),b(o,null,r,a),new s(a)}function S(e,t,n){let o=[];return b(null,e,n,o),e.depth>n&&v(k(w(e,t,n+1),S(e,t,n+1)),o),b(t,null,n,o),new s(o)}p.empty=new p(s.empty,0,0);class C{constructor(e,t,n){this.pos=e,this.path=t,this.parentOffset=n,this.depth=t.length/3-1}resolveDepth(e){return null==e?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[3*this.resolveDepth(e)]}index(e){return this.path[3*this.resolveDepth(e)+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e!=this.depth||this.textOffset?1:0)}start(e){return 0==(e=this.resolveDepth(e))?0:this.path[3*e-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(!(e=this.resolveDepth(e)))throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[3*e-1]}after(e){if(!(e=this.resolveDepth(e)))throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[3*e-1]+this.path[3*e].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let n=this.pos-this.path[this.path.length-1],o=e.child(t);return n?e.child(t).cut(n):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):0==e?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let n=this.path[3*t],o=0==t?0:this.path[3*t-1]+1;for(let t=0;t<e;t++)o+=n.child(t).nodeSize;return o}marks(){let e=this.parent,t=this.index();if(0==e.content.size)return d.none;if(this.textOffset)return e.child(t).marks;let n=e.maybeChild(t-1),o=e.maybeChild(t);if(!n){let e=n;n=o,o=e}let r=n.marks;for(var i=0;i<r.length;i++)!1!==r[i].type.spec.inclusive||o&&r[i].isInSet(o.marks)||(r=r[i--].removeFromSet(r));return r}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let n=t.marks,o=e.parent.maybeChild(e.index());for(var r=0;r<n.length;r++)!1!==n[r].type.spec.inclusive||o&&n[r].isInSet(o.marks)||(n=n[r--].removeFromSet(n));return n}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let n=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);n>=0;n--)if(e.pos<=this.end(n)&&(!t||t(this.node(n))))return new A(this,e,n);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let t=1;t<=this.depth;t++)e+=(e?"/":"")+this.node(t).type.name+"_"+this.index(t-1);return e+":"+this.parentOffset}static resolve(e,t){if(!(t>=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let n=[],o=0,r=t;for(let t=e;;){let{index:e,offset:i}=t.content.findIndex(r),s=r-i;if(n.push(t,e,o+i),!s)break;if(t=t.child(e),t.isText)break;r=s-1,o+=i+1}return new C(t,n,r)}static resolveCached(e,t){let n=O.get(e);if(n)for(let e=0;e<n.elts.length;e++){let o=n.elts[e];if(o.pos==t)return o}else O.set(e,n=new M);let o=n.elts[n.i]=C.resolve(e,t);return n.i=(n.i+1)%N,o}}class M{constructor(){this.elts=[],this.i=0}}const N=12,O=new WeakMap;class A{constructor(e,t,n){this.$from=e,this.$to=t,this.depth=n}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const T=Object.create(null);class D{constructor(e,t,n,o=d.none){this.type=e,this.attrs=t,this.marks=o,this.content=n||s.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,n,o=0){this.content.nodesBetween(e,t,n,o,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,t,n,o){return this.content.textBetween(e,t,n,o)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,n){return this.type==e&&c(this.attrs,t||e.defaultAttrs||T)&&d.sameSet(this.marks,n||d.none)}copy(e=null){return e==this.content?this:new D(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new D(this.type,this.attrs,this.content,e)}cut(e,t=this.content.size){return 0==e&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,n=!1){if(e==t)return p.empty;let o=this.resolve(e),r=this.resolve(t),i=n?0:o.sharedDepth(t),s=o.start(i),l=o.node(i).content.cut(o.pos-s,r.pos-s);return new p(l,o.depth-i,r.depth-i)}replace(e,t,n){return m(this.resolve(e),this.resolve(t),n)}nodeAt(e){for(let t=this;;){let{index:n,offset:o}=t.content.findIndex(e);if(t=t.maybeChild(n),!t)return null;if(o==e||t.isText)return t;e-=o+1}}childAfter(e){let{index:t,offset:n}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:n}}childBefore(e){if(0==e)return{node:null,index:0,offset:0};let{index:t,offset:n}=this.content.findIndex(e);if(n<e)return{node:this.content.child(t),index:t,offset:n};let o=this.content.child(t-1);return{node:o,index:t-1,offset:n-o.nodeSize}}resolve(e){return C.resolveCached(this,e)}resolveNoCache(e){return C.resolve(this,e)}rangeHasMark(e,t,n){let o=!1;return t>e&&this.nodesBetween(e,t,(e=>(n.isInSet(e.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()+")"),R(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw new Error("Called contentMatchAt on a node with invalid content");return t}canReplace(e,t,n=s.empty,o=0,r=n.childCount){let i=this.contentMatchAt(e).matchFragment(n,o,r),l=i&&i.matchFragment(this.content,t);if(!l||!l.validEnd)return!1;for(let e=o;e<r;e++)if(!this.type.allowsMarks(n.child(e).marks))return!1;return!0}canReplaceWith(e,t,n,o){if(o&&!this.type.allowsMarks(o))return!1;let r=this.contentMatchAt(e).matchType(n),i=r&&r.matchFragment(this.content,t);return!!i&&i.validEnd}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=d.none;for(let t=0;t<this.marks.length;t++){let n=this.marks[t];n.type.checkAttrs(n.attrs),e=n.addToSet(e)}if(!d.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map((e=>e.type.name))}`);this.content.forEach((e=>e.check()))}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map((e=>e.toJSON()))),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let n;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");n=t.marks.map(e.markFromJSON)}if("text"==t.type){if("string"!=typeof t.text)throw new RangeError("Invalid text node in JSON");return e.text(t.text,n)}let o=s.fromJSON(e,t.content),r=e.nodeType(t.type).create(t.attrs,o,n);return r.type.checkAttrs(r.attrs),r}}D.prototype.text=void 0;class E extends D{constructor(e,t,n,o){if(super(e,t,null,o),!n)throw new RangeError("Empty text nodes are not allowed");this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):R(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 E(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new E(this.type,this.attrs,e,this.marks)}cut(e=0,t=this.text.length){return 0==e&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function R(e,t){for(let n=e.length-1;n>=0;n--)t=e[n].type.name+"("+t+")";return t}class ${constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let n=new I(e,t);if(null==n.next)return $.empty;let o=z(n);n.next&&n.err("Unexpected trailing text");let r=function(e){let t=Object.create(null);return function n(o){let r=[];o.forEach((t=>{e[t].forEach((({term:t,to:n})=>{if(!t)return;let o;for(let e=0;e<r.length;e++)r[e][0]==t&&(o=r[e][1]);H(e,n).forEach((e=>{o||r.push([t,o=[]]),-1==o.indexOf(e)&&o.push(e)}))}))}));let i=t[o.join(",")]=new $(o.indexOf(e.length-1)>-1);for(let e=0;e<r.length;e++){let o=r[e][1].sort(L);i.next.push({type:r[e][0],next:t[o.join(",")]||n(o)})}return i}(H(e,0))}(function(e){let t=[[]];return r(function e(t,i){if("choice"==t.type)return t.exprs.reduce(((t,n)=>t.concat(e(n,i))),[]);if("seq"!=t.type){if("star"==t.type){let s=n();return o(i,s),r(e(t.expr,s),s),[o(s)]}if("plus"==t.type){let s=n();return r(e(t.expr,i),s),r(e(t.expr,s),s),[o(s)]}if("opt"==t.type)return[o(i)].concat(e(t.expr,i));if("range"==t.type){let s=i;for(let o=0;o<t.min;o++){let o=n();r(e(t.expr,s),o),s=o}if(-1==t.max)r(e(t.expr,s),s);else for(let i=t.min;i<t.max;i++){let i=n();o(s,i),r(e(t.expr,s),i),s=i}return[o(s)]}if("name"==t.type)return[o(i,void 0,t.value)];throw new Error("Unknown expr type")}for(let o=0;;o++){let s=e(t.exprs[o],i);if(o==t.exprs.length-1)return s;r(s,i=n())}}(e,0),n()),t;function n(){return t.push([])-1}function o(e,n,o){let r={term:o,to:n};return t[e].push(r),r}function r(e,t){e.forEach((e=>e.to=t))}}(o));return function(e,t){for(let n=0,o=[e];n<o.length;n++){let e=o[n],r=!e.validEnd,i=[];for(let t=0;t<e.next.length;t++){let{type:n,next:s}=e.next[t];i.push(n.name),!r||n.isText||n.hasRequiredAttrs()||(r=!1),-1==o.indexOf(s)&&o.push(s)}r&&t.err("Only non-generatable nodes ("+i.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}(r,n),r}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,n=e.childCount){let o=this;for(let r=t;o&&r<n;r++)o=o.matchType(e.child(r).type);return o}get inlineContent(){return 0!=this.next.length&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!t.isText&&!t.hasRequiredAttrs())return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let n=0;n<e.next.length;n++)if(this.next[t].type==e.next[n].type)return!0;return!1}fillBefore(e,t=!1,n=0){let o=[this];return function r(i,l){let a=i.matchFragment(e,n);if(a&&(!t||a.validEnd))return s.from(l.map((e=>e.createAndFill())));for(let e=0;e<i.next.length;e++){let{type:t,next:n}=i.next[e];if(!t.isText&&!t.hasRequiredAttrs()&&-1==o.indexOf(n)){o.push(n);let e=r(n,l.concat(t));if(e)return e}}return null}(this,[])}findWrapping(e){for(let t=0;t<this.wrapCache.length;t+=2)if(this.wrapCache[t]==e)return this.wrapCache[t+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),n=[{match:this,type:null,via:null}];for(;n.length;){let o=n.shift(),r=o.match;if(r.matchType(e)){let e=[];for(let t=o;t.type;t=t.via)e.push(t.type);return e.reverse()}for(let e=0;e<r.next.length;e++){let{type:i,next:s}=r.next[e];i.isLeaf||i.hasRequiredAttrs()||i.name in t||o.type&&!s.validEnd||(n.push({match:i.contentMatch,type:i,via:o}),t[i.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];return function t(n){e.push(n);for(let o=0;o<n.next.length;o++)-1==e.indexOf(n.next[o].next)&&t(n.next[o].next)}(this),e.map(((t,n)=>{let o=n+(t.validEnd?"*":" ")+" ";for(let n=0;n<t.next.length;n++)o+=(n?", ":"")+t.next[n].type.name+"->"+e.indexOf(t.next[n].next);return o})).join("\n")}}$.empty=new $(!0);class I{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 z(e){let t=[];do{t.push(B(e))}while(e.eat("|"));return 1==t.length?t[0]:{type:"choice",exprs:t}}function B(e){let t=[];do{t.push(P(e))}while(e.next&&")"!=e.next&&"|"!=e.next);return 1==t.length?t[0]:{type:"seq",exprs:t}}function P(e){let t=function(e){if(e.eat("(")){let t=z(e);return e.eat(")")||e.err("Missing closing paren"),t}if(!/\W/.test(e.next)){let t=function(e,t){let n=e.nodeTypes,o=n[t];if(o)return[o];let r=[];for(let e in n){let o=n[e];o.isInGroup(t)&&r.push(o)}return 0==r.length&&e.err("No node type or group '"+t+"' found"),r}(e,e.next).map((t=>(null==e.inline?e.inline=t.isInline:e.inline!=t.isInline&&e.err("Mixing inline and block content"),{type:"name",value:t})));return e.pos++,1==t.length?t[0]:{type:"choice",exprs:t}}e.err("Unexpected token '"+e.next+"'")}(e);for(;;)if(e.eat("+"))t={type:"plus",expr:t};else if(e.eat("*"))t={type:"star",expr:t};else if(e.eat("?"))t={type:"opt",expr:t};else{if(!e.eat("{"))break;t=F(e,t)}return t}function V(e){/\D/.test(e.next)&&e.err("Expected number, got '"+e.next+"'");let t=Number(e.next);return e.pos++,t}function F(e,t){let n=V(e),o=n;return e.eat(",")&&(o="}"!=e.next?V(e):-1),e.eat("}")||e.err("Unclosed braced range"),{type:"range",min:n,max:o,expr:t}}function L(e,t){return t-e}function H(e,t){let n=[];return function t(o){let r=e[o];if(1==r.length&&!r[0].term)return t(r[0].to);n.push(o);for(let e=0;e<r.length;e++){let{term:o,to:i}=r[e];o||-1!=n.indexOf(i)||t(i)}}(t),n.sort(L)}function _(e){let t=Object.create(null);for(let n in e){let o=e[n];if(!o.hasDefault)return null;t[n]=o.default}return t}function W(e,t){let n=Object.create(null);for(let o in e){let r=t&&t[o];if(void 0===r){let t=e[o];if(!t.hasDefault)throw new RangeError("No value supplied for attribute "+o);r=t.default}n[o]=r}return n}function q(e,t,n,o){for(let o in t)if(!(o in e))throw new RangeError(`Unsupported attribute ${o} for ${n} of type ${o}`);for(let n in e){let o=e[n];o.validate&&o.validate(t[n])}}function j(e,t){let n=Object.create(null);if(t)for(let o in t)n[o]=new K(e,o,t[o]);return n}class J{constructor(e,t,n){this.name=e,this.schema=t,this.spec=n,this.markSet=null,this.groups=n.group?n.group.split(" "):[],this.attrs=j(e,n.attrs),this.defaultAttrs=_(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(n.inline||"text"==e),this.isText="text"==e}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==$.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(e){return this.groups.indexOf(e)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:W(this.attrs,e)}create(e=null,t,n){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new D(this,this.computeAttrs(e),s.from(t),d.setFrom(n))}createChecked(e=null,t,n){return t=s.from(t),this.checkContent(t),new D(this,this.computeAttrs(e),t,d.setFrom(n))}createAndFill(e=null,t,n){if(e=this.computeAttrs(e),(t=s.from(t)).size){let e=this.contentMatch.fillBefore(t);if(!e)return null;t=e.append(t)}let o=this.contentMatch.matchFragment(t),r=o&&o.fillBefore(s.empty,!0);return r?new D(this,e,t.append(r),d.setFrom(n)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let t=0;t<e.childCount;t++)if(!this.allowsMarks(e.child(t).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){q(this.attrs,e,"node",this.name)}allowsMarkType(e){return null==this.markSet||this.markSet.indexOf(e)>-1}allowsMarks(e){if(null==this.markSet)return!0;for(let t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){if(null==this.markSet)return e;let t;for(let n=0;n<e.length;n++)this.allowsMarkType(e[n].type)?t&&t.push(e[n]):t||(t=e.slice(0,n));return t?t.length?t:d.none:e}static compile(e,t){let n=Object.create(null);e.forEach(((e,o)=>n[e]=new J(e,t,o)));let o=t.spec.topNode||"doc";if(!n[o])throw new RangeError("Schema is missing its top node type ('"+o+"')");if(!n.text)throw new RangeError("Every schema needs a 'text' type");for(let e in n.text.attrs)throw new RangeError("The text node type should not have attributes");return n}}class K{constructor(e,t,n){this.hasDefault=Object.prototype.hasOwnProperty.call(n,"default"),this.default=n.default,this.validate="string"==typeof n.validate?function(e,t,n){let o=n.split("|");return n=>{let r=null===n?"null":typeof n;if(o.indexOf(r)<0)throw new RangeError(`Expected value of type ${o} for attribute ${t} on type ${e}, got ${r}`)}}(e,t,n.validate):n.validate}get isRequired(){return!this.hasDefault}}class X{constructor(e,t,n,o){this.name=e,this.rank=t,this.schema=n,this.spec=o,this.attrs=j(e,o.attrs),this.excluded=null;let r=_(this.attrs);this.instance=r?new d(this,r):null}create(e=null){return!e&&this.instance?this.instance:new d(this,W(this.attrs,e))}static compile(e,t){let n=Object.create(null),o=0;return e.forEach(((e,r)=>n[e]=new X(e,o++,t,r))),n}removeFromSet(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}checkAttrs(e){q(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class U{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let n in e)t[n]=e[n];t.nodes=o.from(e.nodes),t.marks=o.from(e.marks||{}),this.nodes=J.compile(this.spec.nodes,this),this.marks=X.compile(this.spec.marks,this);let n=Object.create(null);for(let e in this.nodes){if(e in this.marks)throw new RangeError(e+" can not be both a node and a mark");let t=this.nodes[e],o=t.spec.content||"",r=t.spec.marks;if(t.contentMatch=n[o]||(n[o]=$.parse(o,this.nodes)),t.inlineContent=t.contentMatch.inlineContent,t.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!t.isInline||!t.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=t}t.markSet="_"==r?null:r?G(this,r.split(" ")):""!=r&&t.inlineContent?null:[]}for(let e in this.marks){let t=this.marks[e],n=t.spec.excludes;t.excluded=null==n?[t]:""==n?[]:G(this,n.split(" "))}this.nodeFromJSON=e=>D.fromJSON(this,e),this.markFromJSON=e=>d.fromJSON(this,e),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,n,o){if("string"==typeof e)e=this.nodeType(e);else{if(!(e instanceof J))throw new RangeError("Invalid node type: "+e);if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}return e.createChecked(t,n,o)}text(e,t){let n=this.nodes.text;return new E(n,n.defaultAttrs,e,d.setFrom(t))}mark(e,t){return"string"==typeof e&&(e=this.marks[e]),e.create(t)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}}function G(e,t){let n=[];for(let o=0;o<t.length;o++){let r=t[o],i=e.marks[r],s=i;if(i)n.push(i);else for(let t in e.marks){let o=e.marks[t];("_"==r||o.spec.group&&o.spec.group.split(" ").indexOf(r)>-1)&&n.push(s=o)}if(!s)throw new SyntaxError("Unknown mark type: '"+t[o]+"'")}return n}class Y{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let n=this.matchedStyles=[];t.forEach((e=>{if(function(e){return null!=e.tag}(e))this.tags.push(e);else if(function(e){return null!=e.style}(e)){let t=/[^=]*/.exec(e.style)[0];n.indexOf(t)<0&&n.push(t),this.styles.push(e)}})),this.normalizeLists=!this.tags.some((t=>{if(!/^(ul|ol)\b/.test(t.tag)||!t.node)return!1;let n=e.nodes[t.node];return n.contentMatch.matchType(n)}))}parse(e,t={}){let n=new oe(this,t,!1);return n.addAll(e,d.none,t.from,t.to),n.finish()}parseSlice(e,t={}){let n=new oe(this,t,!0);return n.addAll(e,d.none,t.from,t.to),p.maxOpen(n.finish())}matchTag(e,t,n){for(let o=n?this.tags.indexOf(n)+1:0;o<this.tags.length;o++){let n=this.tags[o];if(re(e,n.tag)&&(void 0===n.namespace||e.namespaceURI==n.namespace)&&(!n.context||t.matchesContext(n.context))){if(n.getAttrs){let t=n.getAttrs(e);if(!1===t)continue;n.attrs=t||void 0}return n}}}matchStyle(e,t,n,o){for(let r=o?this.styles.indexOf(o)+1:0;r<this.styles.length;r++){let o=this.styles[r],i=o.style;if(!(0!=i.indexOf(e)||o.context&&!n.matchesContext(o.context)||i.length>e.length&&(61!=i.charCodeAt(e.length)||i.slice(e.length+1)!=t))){if(o.getAttrs){let e=o.getAttrs(t);if(!1===e)continue;o.attrs=e||void 0}return o}}}static schemaRules(e){let t=[];function n(e){let n=null==e.priority?50:e.priority,o=0;for(;o<t.length;o++){let e=t[o];if((null==e.priority?50:e.priority)<n)break}t.splice(o,0,e)}for(let t in e.marks){let o=e.marks[t].spec.parseDOM;o&&o.forEach((e=>{n(e=ie(e)),e.mark||e.ignore||e.clearMark||(e.mark=t)}))}for(let t in e.nodes){let o=e.nodes[t].spec.parseDOM;o&&o.forEach((e=>{n(e=ie(e)),e.node||e.ignore||e.mark||(e.node=t)}))}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Y(e,Y.schemaRules(e)))}}const Q={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},Z={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},ee={ol:!0,ul:!0};function te(e,t,n){return null!=t?(t?1:0)|("full"===t?2:0):e&&"pre"==e.whitespace?3:-5&n}class ne{constructor(e,t,n,o,r,i){this.type=e,this.attrs=t,this.marks=n,this.solid=o,this.options=i,this.content=[],this.activeMarks=d.none,this.match=r||(4&i?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(s.from(e));if(!t){let t,n=this.type.contentMatch;return(t=n.findWrapping(e.type))?(this.match=n,t):null}this.match=this.type.contentMatch.matchFragment(t)}return this.match.findWrapping(e.type)}finish(e){if(!(1&this.options)){let e,t=this.content[this.content.length-1];if(t&&t.isText&&(e=/[ \t\r\n\u000c]+$/.exec(t.text))){let n=t;t.text.length==e[0].length?this.content.pop():this.content[this.content.length-1]=n.withText(n.text.slice(0,n.text.length-e[0].length))}}let t=s.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(s.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!Q.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class oe{constructor(e,t,n){this.parser=e,this.options=t,this.isOpen=n,this.open=0,this.localPreserveWS=!1;let o,r=t.topNode,i=te(null,t.preserveWhitespace,0)|(n?4:0);o=r?new ne(r.type,r.attrs,d.none,!0,t.topMatch||r.type.contentMatch,i):new ne(n?null:e.schema.topNodeType,null,d.none,!0,null,i),this.nodes=[o],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){3==e.nodeType?this.addTextNode(e,t):1==e.nodeType&&this.addElement(e,t)}addTextNode(e,t){let n=e.nodeValue,o=this.top,r=2&o.options?"full":this.localPreserveWS||(1&o.options)>0,{schema:i}=this.parser;if("full"===r||o.inlineContext(e)||/[^ \t\r\n\u000c]/.test(n)){if(r)if("full"===r)n=n.replace(/\r\n?/g,"\n");else if(i.linebreakReplacement&&/[\r\n]/.test(n)&&this.top.findWrapping(i.linebreakReplacement.create())){let e=n.split(/\r?\n|\r/);for(let n=0;n<e.length;n++)n&&this.insertNode(i.linebreakReplacement.create(),t,!0),e[n]&&this.insertNode(i.text(e[n]),t,!/\S/.test(e[n]));n=""}else n=n.replace(/\r?\n|\r/g," ");else if(n=n.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(n)&&this.open==this.nodes.length-1){let t=o.content[o.content.length-1],r=e.previousSibling;(!t||r&&"BR"==r.nodeName||t.isText&&/[ \t\r\n\u000c]$/.test(t.text))&&(n=n.slice(1))}n&&this.insertNode(i.text(n),t,!/\S/.test(n)),this.findInText(e)}else this.findInside(e)}addElement(e,t,n){let o=this.localPreserveWS,r=this.top;("PRE"==e.tagName||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let i,s=e.nodeName.toLowerCase();ee.hasOwnProperty(s)&&this.parser.normalizeLists&&function(e){for(let t=e.firstChild,n=null;t;t=t.nextSibling){let e=1==t.nodeType?t.nodeName.toLowerCase():null;e&&ee.hasOwnProperty(e)&&n?(n.appendChild(t),t=n):"li"==e?n=t:e&&(n=null)}}(e);let l=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(i=this.parser.matchTag(e,this,n));e:if(l?l.ignore:Z.hasOwnProperty(s))this.findInside(e),this.ignoreFallback(e,t);else if(!l||l.skip||l.closeParent){l&&l.closeParent?this.open=Math.max(0,this.open-1):l&&l.skip.nodeType&&(e=l.skip);let n,o=this.needsBlock;if(Q.hasOwnProperty(s))r.content.length&&r.content[0].isInline&&this.open&&(this.open--,r=this.top),n=!0,r.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break e}let i=l&&l.skip?t:this.readStyles(e,t);i&&this.addAll(e,i),n&&this.sync(r),this.needsBlock=o}else{let n=this.readStyles(e,t);n&&this.addElementByRule(e,l,n,!1===l.consuming?i:void 0)}this.localPreserveWS=o}leafFallback(e,t){"BR"==e.nodeName&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode("\n"),t)}ignoreFallback(e,t){"BR"!=e.nodeName||this.top.type&&this.top.type.inlineContent||this.findPlace(this.parser.schema.text("-"),t,!0)}readStyles(e,t){let n=e.style;if(n&&n.length)for(let e=0;e<this.parser.matchedStyles.length;e++){let o=this.parser.matchedStyles[e],r=n.getPropertyValue(o);if(r)for(let e;;){let n=this.parser.matchStyle(o,r,this,e);if(!n)break;if(n.ignore)return null;if(t=n.clearMark?t.filter((e=>!n.clearMark(e))):t.concat(this.parser.schema.marks[n.mark].create(n.attrs)),!1!==n.consuming)break;e=n}}return t}addElementByRule(e,t,n,o){let r,i;if(t.node)if(i=this.parser.schema.nodes[t.node],i.isLeaf)this.insertNode(i.create(t.attrs),n,"BR"==e.nodeName)||this.leafFallback(e,n);else{let e=this.enter(i,t.attrs||null,n,t.preserveWhitespace);e&&(r=!0,n=e)}else{let e=this.parser.schema.marks[t.mark];n=n.concat(e.create(t.attrs))}let s=this.top;if(i&&i.isLeaf)this.findInside(e);else if(o)this.addElement(e,n,o);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach((e=>this.insertNode(e,n,!1)));else{let o=e;"string"==typeof t.contentElement?o=e.querySelector(t.contentElement):"function"==typeof t.contentElement?o=t.contentElement(e):t.contentElement&&(o=t.contentElement),this.findAround(e,o,!0),this.addAll(o,n),this.findAround(e,o,!1)}r&&this.sync(s)&&this.open--}addAll(e,t,n,o){let r=n||0;for(let i=n?e.childNodes[n]:e.firstChild,s=null==o?null:e.childNodes[o];i!=s;i=i.nextSibling,++r)this.findAtPoint(e,r),this.addDOM(i,t);this.findAtPoint(e,r)}findPlace(e,t,n){let o,r;for(let t=this.open,i=0;t>=0;t--){let s=this.nodes[t],l=s.findWrapping(e);if(l&&(!o||o.length>l.length+i)&&(o=l,r=s,!l.length))break;if(s.solid){if(n)break;i+=2}}if(!o)return null;this.sync(r);for(let e=0;e<o.length;e++)t=this.enterInner(o[e],null,t,!1);return t}insertNode(e,t,n){if(e.isInline&&this.needsBlock&&!this.top.type){let e=this.textblockFromContext();e&&(t=this.enterInner(e,null,t))}let o=this.findPlace(e,t,n);if(o){this.closeExtra();let t=this.top;t.match&&(t.match=t.match.matchType(e.type));let n=d.none;for(let r of o.concat(e.marks))(t.type?t.type.allowsMarkType(r.type):se(r.type,e.type))&&(n=r.addToSet(n));return t.content.push(e.mark(n)),!0}return!1}enter(e,t,n,o){let r=this.findPlace(e.create(t),n,!1);return r&&(r=this.enterInner(e,t,n,!0,o)),r}enterInner(e,t,n,o=!1,r){this.closeExtra();let i=this.top;i.match=i.match&&i.match.matchType(e);let s=te(e,r,i.options);4&i.options&&0==i.content.length&&(s|=4);let l=d.none;return n=n.filter((t=>!(i.type?i.type.allowsMarkType(t.type):se(t.type,e))||(l=t.addToSet(l),!1))),this.nodes.push(new ne(e,t,l,o,null,s)),this.open++,n}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!(!this.isOpen&&!this.options.topOpen))}sync(e){for(let t=this.open;t>=0;t--){if(this.nodes[t]==e)return this.open=t,!0;this.localPreserveWS&&(this.nodes[t].options|=1)}return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let n=this.nodes[t].content;for(let t=n.length-1;t>=0;t--)e+=n[t].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&this.find[n].offset==t&&(this.find[n].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)null==this.find[t].pos&&1==e.nodeType&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,n){if(e!=t&&this.find)for(let o=0;o<this.find.length;o++)null==this.find[o].pos&&1==e.nodeType&&e.contains(this.find[o].node)&&t.compareDocumentPosition(this.find[o].node)&(n?2:4)&&(this.find[o].pos=this.currentPos)}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split("/"),n=this.options.context,o=!(this.isOpen||n&&n.parent.type!=this.nodes[0].type),r=-(n?n.depth+1:0)+(o?0:1),i=(e,s)=>{for(;e>=0;e--){let l=t[e];if(""==l){if(e==t.length-1||0==e)continue;for(;s>=r;s--)if(i(e-1,s))return!0;return!1}{let e=s>0||0==s&&o?this.nodes[s].type:n&&s>=r?n.node(s-r).type:null;if(!e||e.name!=l&&!e.isInGroup(l))return!1;s--}}return!0};return i(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let n=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(let e in this.parser.schema.nodes){let t=this.parser.schema.nodes[e];if(t.isTextblock&&t.defaultAttrs)return t}}}function re(e,t){return(e.matches||e.msMatchesSelector||e.webkitMatchesSelector||e.mozMatchesSelector).call(e,t)}function ie(e){let t={};for(let n in e)t[n]=e[n];return t}function se(e,t){let n=t.schema.nodes;for(let o in n){let r=n[o];if(!r.allowsMarkType(e))continue;let i=[],s=e=>{i.push(e);for(let n=0;n<e.edgeCount;n++){let{type:o,next:r}=e.edge(n);if(o==t)return!0;if(i.indexOf(r)<0&&s(r))return!0}};if(s(r.contentMatch))return!0}}class le{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},n){n||(n=ce(t).createDocumentFragment());let o=n,r=[];return e.forEach((e=>{if(r.length||e.marks.length){let n=0,i=0;for(;n<r.length&&i<e.marks.length;){let t=e.marks[i];if(this.marks[t.type.name]){if(!t.eq(r[n][0])||!1===t.type.spec.spanning)break;n++,i++}else i++}for(;n<r.length;)o=r.pop()[1];for(;i<e.marks.length;){let n=e.marks[i++],s=this.serializeMark(n,e.isInline,t);s&&(r.push([n,o]),o.appendChild(s.dom),o=s.contentDOM||s.dom)}}o.appendChild(this.serializeNodeInner(e,t))})),n}serializeNodeInner(e,t){let{dom:n,contentDOM:o}=he(ce(t),this.nodes[e.type.name](e),null,e.attrs);if(o){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,o)}return n}serializeNode(e,t={}){let n=this.serializeNodeInner(e,t);for(let o=e.marks.length-1;o>=0;o--){let r=this.serializeMark(e.marks[o],e.isInline,t);r&&((r.contentDOM||r.dom).appendChild(n),n=r.dom)}return n}serializeMark(e,t,n={}){let o=this.marks[e.type.name];return o&&he(ce(n),o(e,t),null,e.attrs)}static renderSpec(e,t,n=null,o){return he(e,t,n,o)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new le(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=ae(e.nodes);return t.text||(t.text=e=>e.text),t}static marksFromSchema(e){return ae(e.marks)}}function ae(e){let t={};for(let n in e){let o=e[n].spec.toDOM;o&&(t[n]=o)}return t}function ce(e){return e.document||window.document}const de=new WeakMap;function he(e,t,n,o){if("string"==typeof t)return{dom:e.createTextNode(t)};if(null!=t.nodeType)return{dom:t};if(t.dom&&null!=t.dom.nodeType)return t;let r,i=t[0];if("string"!=typeof i)throw new RangeError("Invalid array passed to renderSpec");if(o&&(r=function(e){let t=de.get(e);return void 0===t&&de.set(e,t=function(e){let t=null;return function e(n){if(n&&"object"==typeof n)if(Array.isArray(n))if("string"==typeof n[0])t||(t=[]),t.push(n);else for(let t=0;t<n.length;t++)e(n[t]);else for(let t in n)e(n[t])}(e),t}(e)),t}(o))&&r.indexOf(t)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let s,l=i.indexOf(" ");l>0&&(n=i.slice(0,l),i=i.slice(l+1));let a=n?e.createElementNS(n,i):e.createElement(i),c=t[1],d=1;if(c&&"object"==typeof c&&null==c.nodeType&&!Array.isArray(c)){d=2;for(let e in c)if(null!=c[e]){let t=e.indexOf(" ");t>0?a.setAttributeNS(e.slice(0,t),e.slice(t+1),c[e]):"style"==e&&a.style?a.style.cssText=c[e]:a.setAttribute(e,c[e])}}for(let r=d;r<t.length;r++){let i=t[r];if(0===i){if(r<t.length-1||r>d)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}{let{dom:t,contentDOM:r}=he(e,i,n,o);if(a.appendChild(t),r){if(s)throw new RangeError("Multiple content holes");s=r}}}return{dom:a,contentDOM:s}}const pe=Math.pow(2,16);function ue(e){return 65535&e}class fe{constructor(e,t,n){this.pos=e,this.delInfo=t,this.recover=n}get deleted(){return(8&this.delInfo)>0}get deletedBefore(){return(5&this.delInfo)>0}get deletedAfter(){return(6&this.delInfo)>0}get deletedAcross(){return(4&this.delInfo)>0}}class me{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&me.empty)return me.empty}recover(e){let t=0,n=ue(e);if(!this.inverted)for(let e=0;e<n;e++)t+=this.ranges[3*e+2]-this.ranges[3*e+1];return this.ranges[3*n]+t+function(e){return(e-(65535&e))/pe}(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,n){let o=0,r=this.inverted?2:1,i=this.inverted?1:2;for(let s=0;s<this.ranges.length;s+=3){let l=this.ranges[s]-(this.inverted?o:0);if(l>e)break;let a=this.ranges[s+r],c=this.ranges[s+i],d=l+a;if(e<=d){let r=l+o+((a?e==l?-1:e==d?1:t:t)<0?0:c);if(n)return r;let i=e==l?2:e==d?1:4;return(t<0?e!=l:e!=d)&&(i|=8),new fe(r,i,e==(t<0?l:d)?null:s/3+(e-l)*pe)}o+=c-a}return n?e+o:new fe(e+o,0,null)}touches(e,t){let n=0,o=ue(t),r=this.inverted?2:1,i=this.inverted?1:2;for(let t=0;t<this.ranges.length;t+=3){let s=this.ranges[t]-(this.inverted?n:0);if(s>e)break;let l=this.ranges[t+r];if(e<=s+l&&t==3*o)return!0;n+=this.ranges[t+i]-l}return!1}forEach(e){let t=this.inverted?2:1,n=this.inverted?1:2;for(let o=0,r=0;o<this.ranges.length;o+=3){let i=this.ranges[o],s=i-(this.inverted?r:0),l=i+(this.inverted?0:r),a=this.ranges[o+t],c=this.ranges[o+n];e(s,s+a,l,l+c),r+=c-a}}invert(){return new me(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return 0==e?me.empty:new me(e<0?[0,-e,0]:[0,0,e])}}me.empty=new me([]);class ge{constructor(e,t,n=0,o=(e?e.length:0)){this.mirror=t,this.from=n,this.to=o,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(e=0,t=this.maps.length){return new ge(this._maps,this.mirror,e,t)}appendMap(e,t){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),null!=t&&this.setMirror(this._maps.length-1,t)}appendMapping(e){for(let t=0,n=this._maps.length;t<e._maps.length;t++){let o=e.getMirror(t);this.appendMap(e._maps[t],null!=o&&o<t?n+o:void 0)}}getMirror(e){if(this.mirror)for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}setMirror(e,t){this.mirror||(this.mirror=[]),this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,n=this._maps.length+e._maps.length;t>=0;t--){let o=e.getMirror(t);this.appendMap(e._maps[t].invert(),null!=o&&o>t?n-o-1:void 0)}}invert(){let e=new ge;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let n=this.from;n<this.to;n++)e=this._maps[n].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,n){let o=0;for(let n=this.from;n<this.to;n++){let r=this._maps[n].mapResult(e,t);if(null!=r.recover){let t=this.getMirror(n);if(null!=t&&t>n&&t<this.to){n=t,e=this._maps[t].recover(r.recover);continue}}o|=r.delInfo,e=r.pos}return n?e:new fe(e,o,null)}}const ye=Object.create(null);class we{getMap(){return me.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let n=ye[t.stepType];if(!n)throw new RangeError(`No step type ${t.stepType} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in ye)throw new RangeError("Duplicate use of step JSON ID "+e);return ye[e]=t,t.prototype.jsonID=e,t}}class ve{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new ve(e,null)}static fail(e){return new ve(null,e)}static fromReplace(e,t,n,o){try{return ve.ok(e.replace(t,n,o))}catch(e){if(e instanceof h)return ve.fail(e.message);throw e}}}function be(e,t,n){let o=[];for(let r=0;r<e.childCount;r++){let i=e.child(r);i.content.size&&(i=i.copy(be(i.content,t,i))),i.isInline&&(i=t(i,n,r)),o.push(i)}return s.fromArray(o)}class ke extends we{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=e.resolve(this.from),o=n.node(n.sharedDepth(this.to)),r=new p(be(t.content,((e,t)=>e.isAtom&&t.type.allowsMarkType(this.mark.type)?e.mark(this.mark.addToSet(e.marks)):e),o),t.openStart,t.openEnd);return ve.fromReplace(e,this.from,this.to,r)}invert(){return new xe(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return t.deleted&&n.deleted||t.pos>=n.pos?null:new ke(t.pos,n.pos,this.mark)}merge(e){return e instanceof ke&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new ke(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if("number"!=typeof t.from||"number"!=typeof t.to)throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new ke(t.from,t.to,e.markFromJSON(t.mark))}}we.jsonID("addMark",ke);class xe extends we{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=new p(be(t.content,(e=>e.mark(this.mark.removeFromSet(e.marks))),e),t.openStart,t.openEnd);return ve.fromReplace(e,this.from,this.to,n)}invert(){return new ke(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return t.deleted&&n.deleted||t.pos>=n.pos?null:new xe(t.pos,n.pos,this.mark)}merge(e){return e instanceof xe&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new xe(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if("number"!=typeof t.from||"number"!=typeof t.to)throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new xe(t.from,t.to,e.markFromJSON(t.mark))}}we.jsonID("removeMark",xe);class Se extends we{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return ve.fail("No node at mark step's position");let n=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return ve.fromReplace(e,this.pos,this.pos+1,new p(s.from(n),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let e=this.mark.addToSet(t.marks);if(e.length==t.marks.length){for(let n=0;n<t.marks.length;n++)if(!t.marks[n].isInSet(e))return new Se(this.pos,t.marks[n]);return new Se(this.pos,this.mark)}}return new Ce(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new Se(t.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if("number"!=typeof t.pos)throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new Se(t.pos,e.markFromJSON(t.mark))}}we.jsonID("addNodeMark",Se);class Ce extends we{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return ve.fail("No node at mark step's position");let n=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return ve.fromReplace(e,this.pos,this.pos+1,new p(s.from(n),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return t&&this.mark.isInSet(t.marks)?new Se(this.pos,this.mark):this}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new Ce(t.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if("number"!=typeof t.pos)throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new Ce(t.pos,e.markFromJSON(t.mark))}}we.jsonID("removeNodeMark",Ce);class Me extends we{constructor(e,t,n,o=!1){super(),this.from=e,this.to=t,this.slice=n,this.structure=o}apply(e){return this.structure&&Oe(e,this.from,this.to)?ve.fail("Structure replace would overwrite content"):ve.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new me([this.from,this.to-this.from,this.slice.size])}invert(e){return new Me(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return t.deletedAcross&&n.deletedAcross?null:new Me(t.pos,Math.max(t.pos,n.pos),this.slice,this.structure)}merge(e){if(!(e instanceof Me)||e.structure||this.structure)return null;if(this.from+this.slice.size!=e.from||this.slice.openEnd||e.slice.openStart){if(e.to!=this.from||this.slice.openStart||e.slice.openEnd)return null;{let t=this.slice.size+e.slice.size==0?p.empty:new p(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new Me(e.from,this.to,t,this.structure)}}{let t=this.slice.size+e.slice.size==0?p.empty:new p(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new Me(this.from,this.to+(e.to-e.from),t,this.structure)}}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if("number"!=typeof t.from||"number"!=typeof t.to)throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new Me(t.from,t.to,p.fromJSON(e,t.slice),!!t.structure)}}we.jsonID("replace",Me);class Ne extends we{constructor(e,t,n,o,r,i,s=!1){super(),this.from=e,this.to=t,this.gapFrom=n,this.gapTo=o,this.slice=r,this.insert=i,this.structure=s}apply(e){if(this.structure&&(Oe(e,this.from,this.gapFrom)||Oe(e,this.gapTo,this.to)))return ve.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return ve.fail("Gap is not a flat range");let n=this.slice.insertAt(this.insert,t.content);return n?ve.fromReplace(e,this.from,this.to,n):ve.fail("Content does not fit in gap")}getMap(){return new me([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let t=this.gapTo-this.gapFrom;return new Ne(this.from,this.from+this.slice.size+t,this.from+this.insert,this.from+this.insert+t,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1),o=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),r=this.to==this.gapTo?n.pos:e.map(this.gapTo,1);return t.deletedAcross&&n.deletedAcross||o<t.pos||r>n.pos?null:new Ne(t.pos,n.pos,o,r,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if("number"!=typeof t.from||"number"!=typeof t.to||"number"!=typeof t.gapFrom||"number"!=typeof t.gapTo||"number"!=typeof t.insert)throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new Ne(t.from,t.to,t.gapFrom,t.gapTo,p.fromJSON(e,t.slice),t.insert,!!t.structure)}}function Oe(e,t,n){let o=e.resolve(t),r=n-t,i=o.depth;for(;r>0&&i>0&&o.indexAfter(i)==o.node(i).childCount;)i--,r--;if(r>0){let e=o.node(i).maybeChild(o.indexAfter(i));for(;r>0;){if(!e||e.isLeaf)return!0;e=e.firstChild,r--}}return!1}function Ae(e,t,n,o=n.contentMatch,r=!0){let i=e.doc.nodeAt(t),l=[],a=t+1;for(let t=0;t<i.childCount;t++){let c=i.child(t),d=a+c.nodeSize,h=o.matchType(c.type);if(h){o=h;for(let t=0;t<c.marks.length;t++)n.allowsMarkType(c.marks[t].type)||e.step(new xe(a,d,c.marks[t]));if(r&&c.isText&&"pre"!=n.whitespace){let e,t,o=/\r?\n|\r/g;for(;e=o.exec(c.text);)t||(t=new p(s.from(n.schema.text(" ",n.allowedMarks(c.marks))),0,0)),l.push(new Me(a+e.index,a+e.index+e[0].length,t))}}else l.push(new Me(a,d,p.empty));a=d}if(!o.validEnd){let t=o.fillBefore(s.empty,!0);e.replace(a,a,new p(t,0,0))}for(let t=l.length-1;t>=0;t--)e.step(l[t])}function Te(e,t,n){return(0==t||e.canReplace(t,e.childCount))&&(n==e.childCount||e.canReplace(0,n))}function De(e){let t=e.parent.content.cutByIndex(e.startIndex,e.endIndex);for(let n=e.depth;;--n){let o=e.$from.node(n),r=e.$from.index(n),i=e.$to.indexAfter(n);if(n<e.depth&&o.canReplace(r,i,t))return n;if(0==n||o.type.spec.isolating||!Te(o,r,i))break}return null}function Ee(e,t,n=null,o=e){let r=function(e,t){let{parent:n,startIndex:o,endIndex:r}=e,i=n.contentMatchAt(o).findWrapping(t);if(!i)return null;let s=i.length?i[0]:t;return n.canReplaceWith(o,r,s)?i:null}(e,t),i=r&&function(e,t){let{parent:n,startIndex:o,endIndex:r}=e,i=n.child(o),s=t.contentMatch.findWrapping(i.type);if(!s)return null;let l=(s.length?s[s.length-1]:t).contentMatch;for(let e=o;l&&e<r;e++)l=l.matchType(n.child(e).type);return l&&l.validEnd?s:null}(o,t);return i?r.map(Re).concat({type:t,attrs:n}).concat(i.map(Re)):null}function Re(e){return{type:e,attrs:null}}function $e(e,t,n,o){t.forEach(((r,i)=>{if(r.isText){let s,l=/\r?\n|\r/g;for(;s=l.exec(r.text);){let r=e.mapping.slice(o).map(n+1+i+s.index);e.replaceWith(r,r+1,t.type.schema.linebreakReplacement.create())}}}))}function Ie(e,t,n,o){t.forEach(((r,i)=>{if(r.type==r.type.schema.linebreakReplacement){let r=e.mapping.slice(o).map(n+1+i);e.replaceWith(r,r+1,t.type.schema.text("\n"))}}))}function ze(e,t,n=1,o){let r=e.resolve(t),i=r.depth-n,s=o&&o[o.length-1]||r.parent;if(i<0||r.parent.type.spec.isolating||!r.parent.canReplace(r.index(),r.parent.childCount)||!s.type.validContent(r.parent.content.cutByIndex(r.index(),r.parent.childCount)))return!1;for(let e=r.depth-1,t=n-2;e>i;e--,t--){let n=r.node(e),i=r.index(e);if(n.type.spec.isolating)return!1;let s=n.content.cutByIndex(i,n.childCount),l=o&&o[t+1];l&&(s=s.replaceChild(0,l.type.create(l.attrs)));let a=o&&o[t]||n;if(!n.canReplace(i+1,n.childCount)||!a.type.validContent(s))return!1}let l=r.indexAfter(i),a=o&&o[0];return r.node(i).canReplaceWith(l,l,a?a.type:r.node(i+1).type)}function Be(e,t){let n=e.resolve(t),o=n.index();return Pe(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(o,o+1)}function Pe(e,t){return!(!e||!t||e.isLeaf||!function(e,t){t.content.size||e.type.compatibleContent(t.type);let n=e.contentMatchAt(e.childCount),{linebreakReplacement:o}=e.type.schema;for(let r=0;r<t.childCount;r++){let i=t.child(r),s=i.type==o?e.type.schema.nodes.text:i.type;if(n=n.matchType(s),!n)return!1;if(!e.type.allowsMarks(i.marks))return!1}return n.validEnd}(e,t))}function Ve(e,t,n=-1){let o=e.resolve(t);for(let e=o.depth;;e--){let r,i,s=o.index(e);if(e==o.depth?(r=o.nodeBefore,i=o.nodeAfter):n>0?(r=o.node(e+1),s++,i=o.node(e).maybeChild(s)):(r=o.node(e).maybeChild(s-1),i=o.node(e+1)),r&&!r.isTextblock&&Pe(r,i)&&o.node(e).canReplace(s,s+1))return t;if(0==e)break;t=n<0?o.before(e):o.after(e)}}function Fe(e,t,n){let o=e.resolve(t);if(o.parent.canReplaceWith(o.index(),o.index(),n))return t;if(0==o.parentOffset)for(let e=o.depth-1;e>=0;e--){let t=o.index(e);if(o.node(e).canReplaceWith(t,t,n))return o.before(e+1);if(t>0)return null}if(o.parentOffset==o.parent.content.size)for(let e=o.depth-1;e>=0;e--){let t=o.indexAfter(e);if(o.node(e).canReplaceWith(t,t,n))return o.after(e+1);if(t<o.node(e).childCount)return null}return null}function Le(e,t,n){let o=e.resolve(t);if(!n.content.size)return t;let r=n.content;for(let e=0;e<n.openStart;e++)r=r.firstChild.content;for(let e=1;e<=(0==n.openStart&&n.size?2:1);e++)for(let t=o.depth;t>=0;t--){let n=t==o.depth?0:o.pos<=(o.start(t+1)+o.end(t+1))/2?-1:1,i=o.index(t)+(n>0?1:0),s=o.node(t),l=!1;if(1==e)l=s.canReplace(i,i,r);else{let e=s.contentMatchAt(i).findWrapping(r.firstChild.type);l=e&&s.canReplaceWith(i,i,e[0])}if(l)return 0==n?o.pos:n<0?o.before(t+1):o.after(t+1)}return null}function He(e,t,n=t,o=p.empty){if(t==n&&!o.size)return null;let r=e.resolve(t),i=e.resolve(n);return _e(r,i,o)?new Me(t,n,o):new We(r,i,o).fit()}function _e(e,t,n){return!n.openStart&&!n.openEnd&&e.start()==t.start()&&e.parent.canReplace(e.index(),t.index(),n.content)}we.jsonID("replaceAround",Ne);class We{constructor(e,t,n){this.$from=e,this.$to=t,this.unplaced=n,this.frontier=[],this.placed=s.empty;for(let t=0;t<=e.depth;t++){let n=e.node(t);this.frontier.push({type:n.type,match:n.contentMatchAt(e.indexAfter(t))})}for(let t=e.depth;t>0;t--)this.placed=s.from(e.node(t).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let e=this.findFittable();e?this.placeNodes(e):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,n=this.$from,o=this.close(e<0?this.$to:n.doc.resolve(e));if(!o)return null;let r=this.placed,i=n.depth,s=o.depth;for(;i&&s&&1==r.childCount;)r=r.firstChild.content,i--,s--;let l=new p(r,i,s);return e>-1?new Ne(n.pos,e,this.$to.pos,this.$to.end(),l,t):l.size||n.pos!=this.$to.pos?new Me(n.pos,o.pos,l):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,n=0,o=this.unplaced.openEnd;n<e;n++){let r=t.firstChild;if(t.childCount>1&&(o=0),r.type.spec.isolating&&o<=n){e=n;break}t=r.content}for(let t=1;t<=2;t++)for(let n=1==t?e:this.unplaced.openStart;n>=0;n--){let e,o=null;n?(o=Je(this.unplaced.content,n-1).firstChild,e=o.content):e=this.unplaced.content;let r=e.firstChild;for(let e=this.depth;e>=0;e--){let i,{type:l,match:a}=this.frontier[e],c=null;if(1==t&&(r?a.matchType(r.type)||(c=a.fillBefore(s.from(r),!1)):o&&l.compatibleContent(o.type)))return{sliceDepth:n,frontierDepth:e,parent:o,inject:c};if(2==t&&r&&(i=a.findWrapping(r.type)))return{sliceDepth:n,frontierDepth:e,parent:o,wrap:i};if(o&&a.matchType(o.type))break}}}openMore(){let{content:e,openStart:t,openEnd:n}=this.unplaced,o=Je(e,t);return!(!o.childCount||o.firstChild.isLeaf||(this.unplaced=new p(e,t+1,Math.max(n,o.size+t>=e.size-n?t+1:0)),0))}dropNode(){let{content:e,openStart:t,openEnd:n}=this.unplaced,o=Je(e,t);if(o.childCount<=1&&t>0){let r=e.size-t<=t+o.size;this.unplaced=new p(qe(e,t-1,1),t-1,r?t-1:n)}else this.unplaced=new p(qe(e,t,1),t,n)}placeNodes({sliceDepth:e,frontierDepth:t,parent:n,inject:o,wrap:r}){for(;this.depth>t;)this.closeFrontierNode();if(r)for(let e=0;e<r.length;e++)this.openFrontierNode(r[e]);let i=this.unplaced,l=n?n.content:i.content,a=i.openStart-e,c=0,d=[],{match:h,type:u}=this.frontier[t];if(o){for(let e=0;e<o.childCount;e++)d.push(o.child(e));h=h.matchFragment(o)}let f=l.size+e-(i.content.size-i.openEnd);for(;c<l.childCount;){let e=l.child(c),t=h.matchType(e.type);if(!t)break;c++,(c>1||0==a||e.content.size)&&(h=t,d.push(Ke(e.mark(u.allowedMarks(e.marks)),1==c?a:0,c==l.childCount?f:-1)))}let m=c==l.childCount;m||(f=-1),this.placed=je(this.placed,t,s.from(d)),this.frontier[t].match=h,m&&f<0&&n&&n.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let e=0,t=l;e<f;e++){let e=t.lastChild;this.frontier.push({type:e.type,match:e.contentMatchAt(e.childCount)}),t=e.content}this.unplaced=m?0==e?p.empty:new p(qe(i.content,e-1,1),e-1,f<0?i.openEnd:e-1):new p(qe(i.content,e,c),i.openStart,i.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e,t=this.frontier[this.depth];if(!t.type.isTextblock||!Xe(this.$to,this.$to.depth,t.type,t.match,!1)||this.$to.depth==this.depth&&(e=this.findCloseLevel(this.$to))&&e.depth==this.depth)return-1;let{depth:n}=this.$to,o=this.$to.after(n);for(;n>1&&o==this.$to.end(--n);)++o;return o}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:n,type:o}=this.frontier[t],r=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),i=Xe(e,t,o,n,r);if(i){for(let n=t-1;n>=0;n--){let{match:t,type:o}=this.frontier[n],r=Xe(e,n,o,t,!0);if(!r||r.childCount)continue e}return{depth:t,fit:i,move:r?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=je(this.placed,t.depth,t.fit)),e=t.move;for(let n=t.depth+1;n<=e.depth;n++){let t=e.node(n),o=t.type.contentMatch.fillBefore(t.content,!0,e.index(n));this.openFrontierNode(t.type,t.attrs,o)}return e}openFrontierNode(e,t=null,n){let o=this.frontier[this.depth];o.match=o.match.matchType(e),this.placed=je(this.placed,this.depth,s.from(e.create(t,n))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let e=this.frontier.pop().match.fillBefore(s.empty,!0);e.childCount&&(this.placed=je(this.placed,this.frontier.length,e))}}function qe(e,t,n){return 0==t?e.cutByIndex(n,e.childCount):e.replaceChild(0,e.firstChild.copy(qe(e.firstChild.content,t-1,n)))}function je(e,t,n){return 0==t?e.append(n):e.replaceChild(e.childCount-1,e.lastChild.copy(je(e.lastChild.content,t-1,n)))}function Je(e,t){for(let n=0;n<t;n++)e=e.firstChild.content;return e}function Ke(e,t,n){if(t<=0)return e;let o=e.content;return t>1&&(o=o.replaceChild(0,Ke(o.firstChild,t-1,1==o.childCount?n-1:0))),t>0&&(o=e.type.contentMatch.fillBefore(o).append(o),n<=0&&(o=o.append(e.type.contentMatch.matchFragment(o).fillBefore(s.empty,!0)))),e.copy(o)}function Xe(e,t,n,o,r){let i=e.node(t),s=r?e.indexAfter(t):e.index(t);if(s==i.childCount&&!n.compatibleContent(i.type))return null;let l=o.fillBefore(i.content,!0,s);return l&&!function(e,t,n){for(let o=n;o<t.childCount;o++)if(!e.allowsMarks(t.child(o).marks))return!0;return!1}(n,i.content,s)?l:null}function Ue(e,t,n,o,r){if(t<n){let r=e.firstChild;e=e.replaceChild(0,r.copy(Ue(r.content,t+1,n,o,r)))}if(t>o){let t=r.contentMatchAt(0),n=t.fillBefore(e).append(e);e=n.append(t.matchFragment(n).fillBefore(s.empty,!0))}return e}function Ge(e,t){let n=[];for(let o=Math.min(e.depth,t.depth);o>=0;o--){let r=e.start(o);if(r<e.pos-(e.depth-o)||t.end(o)>t.pos+(t.depth-o)||e.node(o).type.spec.isolating||t.node(o).type.spec.isolating)break;(r==t.start(o)||o==e.depth&&o==t.depth&&e.parent.inlineContent&&t.parent.inlineContent&&o&&t.start(o-1)==r-1)&&n.push(o)}return n}class Ye extends we{constructor(e,t,n){super(),this.pos=e,this.attr=t,this.value=n}apply(e){let t=e.nodeAt(this.pos);if(!t)return ve.fail("No node at attribute step's position");let n=Object.create(null);for(let e in t.attrs)n[e]=t.attrs[e];n[this.attr]=this.value;let o=t.type.create(n,null,t.marks);return ve.fromReplace(e,this.pos,this.pos+1,new p(s.from(o),0,t.isLeaf?0:1))}getMap(){return me.empty}invert(e){return new Ye(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 Ye(t.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,t){if("number"!=typeof t.pos||"string"!=typeof t.attr)throw new RangeError("Invalid input for AttrStep.fromJSON");return new Ye(t.pos,t.attr,t.value)}}we.jsonID("attr",Ye);class Qe extends we{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let n in e.attrs)t[n]=e.attrs[n];t[this.attr]=this.value;let n=e.type.create(t,e.content,e.marks);return ve.ok(n)}getMap(){return me.empty}invert(e){return new Qe(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,t){if("string"!=typeof t.attr)throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new Qe(t.attr,t.value)}}we.jsonID("docAttr",Qe);let Ze=class extends Error{};Ze=function e(t){let n=Error.call(this,t);return n.__proto__=e.prototype,n},Ze.prototype=Object.create(Error.prototype),Ze.prototype.constructor=Ze,Ze.prototype.name="TransformError";class et{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new ge}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new Ze(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,n=p.empty){let o=He(this.doc,e,t,n);return o&&this.step(o),this}replaceWith(e,t,n){return this.replace(e,t,new p(s.from(n),0,0))}delete(e,t){return this.replace(e,t,p.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,n){return function(e,t,n,o){if(!o.size)return e.deleteRange(t,n);let r=e.doc.resolve(t),i=e.doc.resolve(n);if(_e(r,i,o))return e.step(new Me(t,n,o));let s=Ge(r,e.doc.resolve(n));0==s[s.length-1]&&s.pop();let l=-(r.depth+1);s.unshift(l);for(let e=r.depth,t=r.pos-1;e>0;e--,t--){let n=r.node(e).type.spec;if(n.defining||n.definingAsContext||n.isolating)break;s.indexOf(e)>-1?l=e:r.before(e)==t&&s.splice(1,0,-e)}let a=s.indexOf(l),c=[],d=o.openStart;for(let e=o.content,t=0;;t++){let n=e.firstChild;if(c.push(n),t==o.openStart)break;e=n.content}for(let e=d-1;e>=0;e--){let t=c[e],n=(h=t.type).spec.defining||h.spec.definingForContent;if(n&&!t.sameMarkup(r.node(Math.abs(l)-1)))d=e;else if(n||!t.type.isTextblock)break}var h;for(let t=o.openStart;t>=0;t--){let l=(t+d+1)%(o.openStart+1),h=c[l];if(h)for(let t=0;t<s.length;t++){let c=s[(t+a)%s.length],d=!0;c<0&&(d=!1,c=-c);let u=r.node(c-1),f=r.index(c-1);if(u.canReplaceWith(f,f,h.type,h.marks))return e.replace(r.before(c),d?i.after(c):n,new p(Ue(o.content,0,o.openStart,l),l,o.openEnd))}}let u=e.steps.length;for(let l=s.length-1;l>=0&&(e.replace(t,n,o),!(e.steps.length>u));l--){let e=s[l];e<0||(t=r.before(e),n=i.after(e))}}(this,e,t,n),this}replaceRangeWith(e,t,n){return function(e,t,n,o){if(!o.isInline&&t==n&&e.doc.resolve(t).parent.content.size){let r=Fe(e.doc,t,o.type);null!=r&&(t=n=r)}e.replaceRange(t,n,new p(s.from(o),0,0))}(this,e,t,n),this}deleteRange(e,t){return function(e,t,n){let o=e.doc.resolve(t),r=e.doc.resolve(n),i=Ge(o,r);for(let t=0;t<i.length;t++){let n=i[t],s=t==i.length-1;if(s&&0==n||o.node(n).type.contentMatch.validEnd)return e.delete(o.start(n),r.end(n));if(n>0&&(s||o.node(n-1).canReplace(o.index(n-1),r.indexAfter(n-1))))return e.delete(o.before(n),r.after(n))}for(let i=1;i<=o.depth&&i<=r.depth;i++)if(t-o.start(i)==o.depth-i&&n>o.end(i)&&r.end(i)-n!=r.depth-i&&o.start(i-1)==r.start(i-1)&&o.node(i-1).canReplace(o.index(i-1),r.index(i-1)))return e.delete(o.before(i),n);e.delete(t,n)}(this,e,t),this}lift(e,t){return function(e,t,n){let{$from:o,$to:r,depth:i}=t,l=o.before(i+1),a=r.after(i+1),c=l,d=a,h=s.empty,u=0;for(let e=i,t=!1;e>n;e--)t||o.index(e)>0?(t=!0,h=s.from(o.node(e).copy(h)),u++):c--;let f=s.empty,m=0;for(let e=i,t=!1;e>n;e--)t||r.after(e+1)<r.end(e)?(t=!0,f=s.from(r.node(e).copy(f)),m++):d++;e.step(new Ne(c,d,l,a,new p(h.append(f),u,m),h.size-u,!0))}(this,e,t),this}join(e,t=1){return function(e,t,n){let o=null,{linebreakReplacement:r}=e.doc.type.schema,i=e.doc.resolve(t-n),s=i.node().type;if(r&&s.inlineContent){let e="pre"==s.whitespace,t=!!s.contentMatch.matchType(r);e&&!t?o=!1:!e&&t&&(o=!0)}let l=e.steps.length;if(!1===o){let o=e.doc.resolve(t+n);Ie(e,o.node(),o.before(),l)}s.inlineContent&&Ae(e,t+n-1,s,i.node().contentMatchAt(i.index()),null==o);let a=e.mapping.slice(l),c=a.map(t-n);if(e.step(new Me(c,a.map(t+n,-1),p.empty,!0)),!0===o){let t=e.doc.resolve(c);$e(e,t.node(),t.before(),e.steps.length)}}(this,e,t),this}wrap(e,t){return function(e,t,n){let o=s.empty;for(let e=n.length-1;e>=0;e--){if(o.size){let t=n[e].type.contentMatch.matchFragment(o);if(!t||!t.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}o=s.from(n[e].type.create(n[e].attrs,o))}let r=t.start,i=t.end;e.step(new Ne(r,i,r,i,new p(o,0,0),n.length,!0))}(this,e,t),this}setBlockType(e,t=e,n,o=null){return function(e,t,n,o,r){if(!o.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let i=e.steps.length;e.doc.nodesBetween(t,n,((t,n)=>{let l="function"==typeof r?r(t):r;if(t.isTextblock&&!t.hasMarkup(o,l)&&function(e,t,n){let o=e.resolve(t),r=o.index();return o.parent.canReplaceWith(r,r+1,n)}(e.doc,e.mapping.slice(i).map(n),o)){let r=null;if(o.schema.linebreakReplacement){let e="pre"==o.whitespace,t=!!o.contentMatch.matchType(o.schema.linebreakReplacement);e&&!t?r=!1:!e&&t&&(r=!0)}!1===r&&Ie(e,t,n,i),Ae(e,e.mapping.slice(i).map(n,1),o,void 0,null===r);let a=e.mapping.slice(i),c=a.map(n,1),d=a.map(n+t.nodeSize,1);return e.step(new Ne(c,d,c+1,d-1,new p(s.from(o.create(l,null,t.marks)),0,0),1,!0)),!0===r&&$e(e,t,n,i),!1}}))}(this,e,t,n,o),this}setNodeMarkup(e,t,n=null,o){return function(e,t,n,o,r){let i=e.doc.nodeAt(t);if(!i)throw new RangeError("No node at given position");n||(n=i.type);let l=n.create(o,null,r||i.marks);if(i.isLeaf)return e.replaceWith(t,t+i.nodeSize,l);if(!n.validContent(i.content))throw new RangeError("Invalid content for node type "+n.name);e.step(new Ne(t,t+i.nodeSize,t+1,t+i.nodeSize-1,new p(s.from(l),0,0),1,!0))}(this,e,t,n,o),this}setNodeAttribute(e,t,n){return this.step(new Ye(e,t,n)),this}setDocAttribute(e,t){return this.step(new Qe(e,t)),this}addNodeMark(e,t){return this.step(new Se(e,t)),this}removeNodeMark(e,t){let n=this.doc.nodeAt(e);if(!n)throw new RangeError("No node at position "+e);if(t instanceof d)t.isInSet(n.marks)&&this.step(new Ce(e,t));else{let o,r=n.marks,i=[];for(;o=t.isInSet(r);)i.push(new Ce(e,o)),r=o.removeFromSet(r);for(let e=i.length-1;e>=0;e--)this.step(i[e])}return this}split(e,t=1,n){return function(e,t,n=1,o){let r=e.doc.resolve(t),i=s.empty,l=s.empty;for(let e=r.depth,t=r.depth-n,a=n-1;e>t;e--,a--){i=s.from(r.node(e).copy(i));let t=o&&o[a];l=s.from(t?t.type.create(t.attrs,l):r.node(e).copy(l))}e.step(new Me(t,t,new p(i.append(l),n,n),!0))}(this,e,t,n),this}addMark(e,t,n){return function(e,t,n,o){let r,i,s=[],l=[];e.doc.nodesBetween(t,n,((e,a,c)=>{if(!e.isInline)return;let d=e.marks;if(!o.isInSet(d)&&c.type.allowsMarkType(o.type)){let c=Math.max(a,t),h=Math.min(a+e.nodeSize,n),p=o.addToSet(d);for(let e=0;e<d.length;e++)d[e].isInSet(p)||(r&&r.to==c&&r.mark.eq(d[e])?r.to=h:s.push(r=new xe(c,h,d[e])));i&&i.to==c?i.to=h:l.push(i=new ke(c,h,o))}})),s.forEach((t=>e.step(t))),l.forEach((t=>e.step(t)))}(this,e,t,n),this}removeMark(e,t,n){return function(e,t,n,o){let r=[],i=0;e.doc.nodesBetween(t,n,((e,s)=>{if(!e.isInline)return;i++;let l=null;if(o instanceof X){let t,n=e.marks;for(;t=o.isInSet(n);)(l||(l=[])).push(t),n=t.removeFromSet(n)}else o?o.isInSet(e.marks)&&(l=[o]):l=e.marks;if(l&&l.length){let o=Math.min(s+e.nodeSize,n);for(let e=0;e<l.length;e++){let n,a=l[e];for(let e=0;e<r.length;e++){let t=r[e];t.step==i-1&&a.eq(r[e].style)&&(n=t)}n?(n.to=o,n.step=i):r.push({style:a,from:Math.max(s,t),to:o,step:i})}}})),r.forEach((t=>e.step(new xe(t.from,t.to,t.style))))}(this,e,t,n),this}clearIncompatible(e,t,n){return Ae(this,e,t,n),this}}const tt=Object.create(null);class nt{constructor(e,t,n){this.$anchor=e,this.$head=t,this.ranges=n||[new ot(e.min(t),e.max(t))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let t=0;t<e.length;t++)if(e[t].$from.pos!=e[t].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,t=p.empty){let n=t.content.lastChild,o=null;for(let e=0;e<t.openEnd;e++)o=n,n=n.lastChild;let r=e.steps.length,i=this.ranges;for(let s=0;s<i.length;s++){let{$from:l,$to:a}=i[s],c=e.mapping.slice(r);e.replaceRange(c.map(l.pos),c.map(a.pos),s?p.empty:t),0==s&&ut(e,r,(n?n.isInline:o&&o.isTextblock)?-1:1)}}replaceWith(e,t){let n=e.steps.length,o=this.ranges;for(let r=0;r<o.length;r++){let{$from:i,$to:s}=o[r],l=e.mapping.slice(n),a=l.map(i.pos),c=l.map(s.pos);r?e.deleteRange(a,c):(e.replaceRangeWith(a,c,t),ut(e,n,t.isInline?-1:1))}}static findFrom(e,t,n=!1){let o=e.parent.inlineContent?new st(e):pt(e.node(0),e.parent,e.pos,e.index(),t,n);if(o)return o;for(let o=e.depth-1;o>=0;o--){let r=t<0?pt(e.node(0),e.node(o),e.before(o+1),e.index(o),t,n):pt(e.node(0),e.node(o),e.after(o+1),e.index(o)+1,t,n);if(r)return r}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new dt(e.node(0))}static atStart(e){return pt(e,e,0,0,1)||new dt(e)}static atEnd(e){return pt(e,e,e.content.size,e.childCount,-1)||new dt(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let n=tt[t.type];if(!n)throw new RangeError(`No selection type ${t.type} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in tt)throw new RangeError("Duplicate use of selection JSON ID "+e);return tt[e]=t,t.prototype.jsonID=e,t}getBookmark(){return st.between(this.$anchor,this.$head).getBookmark()}}nt.prototype.visible=!0;class ot{constructor(e,t){this.$from=e,this.$to=t}}let rt=!1;function it(e){rt||e.parent.inlineContent||(rt=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+e.parent.type.name+")"))}class st extends nt{constructor(e,t=e){it(e),it(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let n=e.resolve(t.map(this.head));if(!n.parent.inlineContent)return nt.near(n);let o=e.resolve(t.map(this.anchor));return new st(o.parent.inlineContent?o:n,n)}replace(e,t=p.empty){if(super.replace(e,t),t==p.empty){let t=this.$from.marksAcross(this.$to);t&&e.ensureMarks(t)}}eq(e){return e instanceof st&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new lt(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if("number"!=typeof t.anchor||"number"!=typeof t.head)throw new RangeError("Invalid input for TextSelection.fromJSON");return new st(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,n=t){let o=e.resolve(t);return new this(o,n==t?o:e.resolve(n))}static between(e,t,n){let o=e.pos-t.pos;if(n&&!o||(n=o>=0?1:-1),!t.parent.inlineContent){let e=nt.findFrom(t,n,!0)||nt.findFrom(t,-n,!0);if(!e)return nt.near(t,n);t=e.$head}return e.parent.inlineContent||(0==o||(e=(nt.findFrom(e,-n,!0)||nt.findFrom(e,n,!0)).$anchor).pos<t.pos!=o<0)&&(e=t),new st(e,t)}}nt.jsonID("text",st);class lt{constructor(e,t){this.anchor=e,this.head=t}map(e){return new lt(e.map(this.anchor),e.map(this.head))}resolve(e){return st.between(e.resolve(this.anchor),e.resolve(this.head))}}class at extends nt{constructor(e){let t=e.nodeAfter,n=e.node(0).resolve(e.pos+t.nodeSize);super(e,n),this.node=t}map(e,t){let{deleted:n,pos:o}=t.mapResult(this.anchor),r=e.resolve(o);return n?nt.near(r):new at(r)}content(){return new p(s.from(this.node),0,0)}eq(e){return e instanceof at&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new ct(this.anchor)}static fromJSON(e,t){if("number"!=typeof t.anchor)throw new RangeError("Invalid input for NodeSelection.fromJSON");return new at(e.resolve(t.anchor))}static create(e,t){return new at(e.resolve(t))}static isSelectable(e){return!e.isText&&!1!==e.type.spec.selectable}}at.prototype.visible=!1,nt.jsonID("node",at);class ct{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:n}=e.mapResult(this.anchor);return t?new lt(n,n):new ct(n)}resolve(e){let t=e.resolve(this.anchor),n=t.nodeAfter;return n&&at.isSelectable(n)?new at(t):nt.near(t)}}class dt extends nt{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=p.empty){if(t==p.empty){e.delete(0,e.doc.content.size);let t=nt.atStart(e.doc);t.eq(e.selection)||e.setSelection(t)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new dt(e)}map(e){return new dt(e)}eq(e){return e instanceof dt}getBookmark(){return ht}}nt.jsonID("all",dt);const ht={map(){return this},resolve:e=>new dt(e)};function pt(e,t,n,o,r,i=!1){if(t.inlineContent)return st.create(e,n);for(let s=o-(r>0?0:1);r>0?s<t.childCount:s>=0;s+=r){let o=t.child(s);if(o.isAtom){if(!i&&at.isSelectable(o))return at.create(e,n-(r<0?o.nodeSize:0))}else{let t=pt(e,o,n+r,r<0?o.childCount:0,r,i);if(t)return t}n+=o.nodeSize*r}return null}function ut(e,t,n){let o=e.steps.length-1;if(o<t)return;let r,i=e.steps[o];(i instanceof Me||i instanceof Ne)&&(e.mapping.maps[o].forEach(((e,t,n,o)=>{null==r&&(r=o)})),e.setSelection(nt.near(e.doc.resolve(r),n)))}class ft extends et{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(e){if(e.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=-3&this.updated|1,this.storedMarks=null,this}get selectionSet(){return(1&this.updated)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=2,this}ensureMarks(e){return d.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(2&this.updated)>0}addStep(e,t){super.addStep(e,t),this.updated=-3&this.updated,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let n=this.selection;return t&&(e=e.mark(this.storedMarks||(n.empty?n.$from.marks():n.$from.marksAcross(n.$to)||d.none))),n.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,n){let o=this.doc.type.schema;if(null==t)return e?this.replaceSelectionWith(o.text(e),!0):this.deleteSelection();{if(null==n&&(n=t),!e)return this.deleteRange(t,n);let r=this.storedMarks;if(!r){let e=this.doc.resolve(t);r=n==t?e.marks():e.marksAcross(this.doc.resolve(n))}return this.replaceRangeWith(t,n,o.text(e,r)),this.selection.empty||this.selection.to!=t+e.length||this.setSelection(nt.near(this.selection.$to)),this}}setMeta(e,t){return this.meta["string"==typeof e?e:e.key]=t,this}getMeta(e){return this.meta["string"==typeof e?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=4,this}get scrolledIntoView(){return(4&this.updated)>0}}function mt(e,t){return t&&e?e.bind(t):e}class gt{constructor(e,t,n){this.name=e,this.init=mt(t.init,n),this.apply=mt(t.apply,n)}}const yt=[new gt("doc",{init:e=>e.doc||e.schema.topNodeType.createAndFill(),apply:e=>e.doc}),new gt("selection",{init:(e,t)=>e.selection||nt.atStart(t.doc),apply:e=>e.selection}),new gt("storedMarks",{init:e=>e.storedMarks||null,apply:(e,t,n,o)=>o.selection.$cursor?e.storedMarks:null}),new gt("scrollToSelection",{init:()=>0,apply:(e,t)=>e.scrolledIntoView?t+1:t})];class wt{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=yt.slice(),t&&t.forEach((e=>{if(this.pluginsByKey[e.key])throw new RangeError("Adding different instances of a keyed plugin ("+e.key+")");this.plugins.push(e),this.pluginsByKey[e.key]=e,e.spec.state&&this.fields.push(new gt(e.key,e.spec.state,e))}))}}class vt{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,t=-1){for(let n=0;n<this.config.plugins.length;n++)if(n!=t){let t=this.config.plugins[n];if(t.spec.filterTransaction&&!t.spec.filterTransaction.call(t,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let t=[e],n=this.applyInner(e),o=null;for(;;){let r=!1;for(let i=0;i<this.config.plugins.length;i++){let s=this.config.plugins[i];if(s.spec.appendTransaction){let l=o?o[i].n:0,a=o?o[i].state:this,c=l<t.length&&s.spec.appendTransaction.call(s,l?t.slice(l):t,a,n);if(c&&n.filterTransaction(c,i)){if(c.setMeta("appendedTransaction",e),!o){o=[];for(let e=0;e<this.config.plugins.length;e++)o.push(e<i?{state:n,n:t.length}:{state:this,n:0})}t.push(c),n=n.applyInner(c),r=!0}o&&(o[i]={state:n,n:t.length})}}if(!r)return{state:n,transactions:t}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let t=new vt(this.config),n=this.config.fields;for(let o=0;o<n.length;o++){let r=n[o];t[r.name]=r.apply(e,this[r.name],this,t)}return t}get tr(){return new ft(this)}static create(e){let t=new wt(e.doc?e.doc.type.schema:e.schema,e.plugins),n=new vt(t);for(let o=0;o<t.fields.length;o++)n[t.fields[o].name]=t.fields[o].init(e,n);return n}reconfigure(e){let t=new wt(this.schema,e.plugins),n=t.fields,o=new vt(t);for(let t=0;t<n.length;t++){let r=n[t].name;o[r]=this.hasOwnProperty(r)?this[r]:n[t].init(e,o)}return o}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map((e=>e.toJSON()))),e&&"object"==typeof e)for(let n in e){if("doc"==n||"selection"==n)throw new RangeError("The JSON fields `doc` and `selection` are reserved");let o=e[n],r=o.spec.state;r&&r.toJSON&&(t[n]=r.toJSON.call(o,this[o.key]))}return t}static fromJSON(e,t,n){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let o=new wt(e.schema,e.plugins),r=new vt(o);return o.fields.forEach((o=>{if("doc"==o.name)r.doc=D.fromJSON(e.schema,t.doc);else if("selection"==o.name)r.selection=nt.fromJSON(r.doc,t.selection);else if("storedMarks"==o.name)t.storedMarks&&(r.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(n)for(let i in n){let s=n[i],l=s.spec.state;if(s.key==o.name&&l&&l.fromJSON&&Object.prototype.hasOwnProperty.call(t,i))return void(r[o.name]=l.fromJSON.call(s,e,t[i],r))}r[o.name]=o.init(e,r)}})),r}}function bt(e,t,n){for(let o in e){let r=e[o];r instanceof Function?r=r.bind(t):"handleDOMEvents"==o&&(r=bt(r,t,{})),n[o]=r}return n}class kt{constructor(e){this.spec=e,this.props={},e.props&&bt(e.props,this,this.props),this.key=e.key?e.key.key:St("plugin")}getState(e){return e[this.key]}}const xt=Object.create(null);function St(e){return e in xt?e+"$"+ ++xt[e]:(xt[e]=0,e+"$")}class Ct{constructor(e="key"){this.key=St(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const Mt="k-parent-node",Nt="k-colgroup-data",Ot="k-resizable-node",At="k-editor-resize-handle",Tt="data-dir-table-resize",Dt="data-dir-image-resize";var Et=function(){return"undefined"!=typeof window},Rt={wp:/(Windows Phone(?: OS)?)\s(\d+)\.(\d+(\.\d+)?)/,fire:/(Silk)\/(\d+)\.(\d+(\.\d+)?)/,android:/(Android|Android.*(?:Opera|Firefox).*?\/)\s*(\d+)(\.(\d+(\.\d+)?))?/,iphone:/(iPhone|iPod).*OS\s+(\d+)[\._]([\d\._]+)/,ipad:/(iPad).*OS\s+(\d+)[\._]([\d_]+)/,meego:/(MeeGo).+NokiaBrowser\/(\d+)\.([\d\._]+)/,webos:/(webOS)\/(\d+)\.(\d+(\.\d+)?)/,blackberry:/(BlackBerry|BB10).*?Version\/(\d+)\.(\d+(\.\d+)?)/,playbook:/(PlayBook).*?Tablet\s*OS\s*(\d+)\.(\d+(\.\d+)?)/,windows:/(MSIE)\s+(\d+)\.(\d+(\.\d+)?)/,tizen:/(tizen).*?Version\/(\d+)\.(\d+(\.\d+)?)/i,sailfish:/(sailfish).*rv:(\d+)\.(\d+(\.\d+)?).*firefox/i,ffos:/(Mobile).*rv:(\d+)\.(\d+(\.\d+)?).*Firefox/},$t={ios:/^i(phone|pad|pod)$/i,android:/^android|fire$/i,blackberry:/^blackberry|playbook/i,windows:/windows/,wp:/wp/,flat:/sailfish|ffos|tizen/i,meego:/meego/},It={edge:/(edge)[ \/]([\w.]+)/i,webkit:/(chrome)[ \/]([\w.]+)/i,safari:/(webkit)[ \/]([\w.]+)/i,opera:/(opera)(?:.*version|)[ \/]([\w.]+)/i,msie:/(msie\s|trident.*? rv:)([\w.]+)/i,mozilla:/(mozilla)(?:.*? rv:([\w.]+)|)/i},zt={omini:/Opera\sMini/i,omobile:/Opera\sMobi/i,firefox:/Firefox|Fennec/i,mobilesafari:/version\/.*safari/i,ie:/MSIE|Windows\sPhone/i,chrome:/chrome|crios/i,webkit:/webkit/i},Bt=function(e,t,n){for(var o in t)if(t.hasOwnProperty(o)&&t[o].test(e))return o;return void 0!==n?n:e},Pt=Et()&&window.navigator?window.navigator.userAgent:null,Vt=Pt?function(e){var t=null,n=[];for(var o in It)if(It.hasOwnProperty(o)&&(n=e.match(It[o]))){(t={})[o]=!0,t[n[1].toLowerCase().split(" ")[0].split("/")[0]]=!0,t.version=parseInt(document.documentMode||n[2],10);break}return t}(Pt):null,Ft=(Pt&&function(e){var t,n=[];for(var o in Rt)if(Rt.hasOwnProperty(o)){if(!(n=e.match(Rt[o])))continue;if("windows"===o&&"plugins"in window.navigator)return null;var r={};return r.device=o,r.browser=Bt(e,zt,"default"),r.name=Bt(o,$t),r[r.name]=!0,r.majorVersion=n[2],r.minorVersion=n[3]?n[3].replace("_","."):".0",t=r.minorVersion.replace(".","").substr(0,2),r.flatVersion=r.majorVersion+t+new Array(3-(t.length<3?t.length:2)).join("0"),r.cordova=void 0!==typeof window.PhoneGap||void 0!==typeof window.cordova,r.appMode=window.navigator.standalone||/file|local|wmapp/.test(window.location.protocol)||r.cordova,r}}(Pt),Et()&&window,Vt&&!Vt.chrome&&window.MSPointerEvent,Vt&&!Vt.chrome&&window.PointerEvent,{});Ft[void 0]=function(e){return e};var Lt=/\/\*[\s\S]*?\*\//g,Ht=/([^\s:;]+?)\s*:\s*((?:(?:url\(\s*(?:(?:[^"')\\]|\\.)*|"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*')\s*\)|"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'|[^;"'])*?)\s*)(?=;|$)/gi,_t=/&quot;|&#34;|&#x22;/gi,Wt=/&apos;|&#39;|&#x27;/gi;const qt=(e,t)=>{const n=t.style,o=t.value,r=t.newValue;if(!e)return{changed:!1,style:null};const i=ln(e),s=Object.keys(i),l=[];for(let e=0;e<s.length;e++){const t=s[e];t.toLowerCase()===n&&o.test(i[t])||l.push(`${t}: ${i[t]}`)}return r&&l.push(`${n}: ${r}`),{style:l.join("; ")+(l.length?";":""),changed:Boolean(r)||l.length!==s.length}},jt=/^.+$/;function Jt(e,t,n){let o;if(new RegExp("[^-]?"+t+":").test(e.style||"")){const{style:r}=qt(e.style||"",{style:t,value:jt,newValue:n});o={...e,style:r}}else o=e.style?{...e,style:e.style.replace(/;$/,"")+"; "+t+": "+n+";"}:{...e,style:t+": "+n+";"};return o}const Kt=(e,t)=>{const n=e.selection.$from;for(let e=n.depth;e>=0;e--){const o=n.index(e);if(n.node(e).canReplaceWith(o,o,t))return!0}return!1},Xt=e=>e instanceof D?e.type.name:e.name,Ut=(e,t=1)=>n=>((e,t=1)=>n=>{const{$from:o}=n;for(let n=o.depth;n>0;n--){const r=o.node(n);if(e(r)&&0==(t-=1))return{depth:n,node:r}}})((t=>Xt(t)===Xt(e)),t)(n);function Gt(e,t){for(let n=e.depth;n>0;n--){const o=e.node(n);if(t(o))return{node:o,depth:n}}return null}const Yt=e=>{const t={};for(const n in e)n&&(e[n]||0===e[n])&&(t[n]=e[n]);return t},Qt=(e,t)=>(n,o)=>{const{selection:r,tr:i}=n;r instanceof at&&r.node.type.name===e.type.name&&e.isLeaf&&!e.isText&&1===e.nodeSize?(i.setNodeMarkup(r.from,null,{...Yt(r.node.attrs),...Yt(e.attrs)}),i.setSelection(at.create(i.doc,r.from))):i.replaceSelectionWith(e),t&&i.scrollIntoView(),o(i)},Zt=e=>{const t=e.selection;if(t instanceof st||t instanceof dt){const e=t.content().content;return e.textBetween(0,e.size)}return""},en=e=>{if(e.selection instanceof at)return e.selection.node},tn=e=>{let t="",n=!1;const{selection:o,doc:r}=e,{$from:i,$to:s,from:l,to:a}=o;return i.sameParent(s)&&(r.nodesBetween(l,a,(e=>{n=n||e.isLeaf&&!e.isText})),n||(t=Zt(e))),t},nn=e=>e.replace(/<\/(p|li|ul|ol|h[1-6]|table|tr|td|th)>/gi,"</$1>\n").replace(/<(ul|ol)([^>]*)><li/gi,"<$1$2>\n<li").replace(/<br \/>/gi,"<br />\n").replace(/\n$/,""),on={before:/[^ !,?.[\]{}()]+$/i,after:/^[^ !,?.[\]{}()]+/i},rn=(e,t,n)=>{if(!n.applyToWord||!e.selection.empty)return{state:e,dispatch:t};const o=!0===n.applyToWord?on:n.applyToWord;let r=null;const i=e.tr,s=e.selection,l=s.$head.nodeBefore,a=s.$head.nodeAfter;if(l&&"text"===l.type.name&&l.text&&a&&"text"===a.type.name&&a.text){const n=[];s.$head.parent.descendants(((e,t)=>(n.push({node:e,pos:t}),!1)));let l=s.$head.parentOffset;const a=n.findIndex((({node:e,pos:t})=>t<=l&&t+e.nodeSize>=l));let c=n[a].node.text,d=!1;for(let e=a-1;e>=0;e--){const t=n[e];!d&&t&&"text"===t.node.type.name?c=t.node.text+c:(d=!0,l-=t.node.nodeSize)}for(let e=a+1;e<n.length;e++){const t=n[e];if(!t||"text"!==t.node.type.name)break;c+=t.node.text}const h=c.substring(0,l),p=c.substring(l),u=o.before.exec(h),f=o.after.exec(p);if(u&&f){const n=u[0].length,o=f[0].length,l=r=s.from;return i.setSelection(st.create(e.doc,l-n,l+o)),{state:{tr:i,selection:i.selection,doc:i.doc,storedMarks:null,schema:i.doc.type.schema},dispatch:e=>{e.setSelection(st.create(e.doc,r)),t(e)}}}}return{state:e,dispatch:t}},sn=(e,t)=>(n,o)=>{const{state:r,dispatch:i}=rn(n,o,t);return e(t)(r,i)},ln=e=>function(e){for(var t,n,o={},r=(e||"").replace(Lt,"").replace(_t,'"').replace(Wt,"'"),i=Ht.exec(r);null!==i;)t=i[1].trim(),n=i[2].trim(),o[t]=n,i=Ht.exec(r);return o}(e),an=(e,t,n)=>{const o=ln(e);o[t]=n;const r=Object.keys(o).map((e=>o[e]?`${e}: ${o[e]}`:null)).filter(Boolean).join("; ");return r?r+";":null},cn=(e,t)=>{const n=ln(t);for(const t in n)t&&void 0!==e.style[t]&&(e.style[t]=n[t])},dn=(e,t,n)=>{const o=e.getAttribute(t);void 0!==n&&n!==o?"style"===t?(e.removeAttribute(t),cn(e,n)):e.setAttribute(t,n):void 0===n&&e.removeAttribute(t)};class hn{static renderSpec(e,t,n=null){if("string"==typeof t)return{dom:e.createTextNode(t)};if(null!=t.nodeType)return{dom:t};if(t.dom&&null!=t.dom.nodeType)return t;let o,r=t[0],i=r.indexOf(" ");i>0&&(n=r.slice(0,i),r=r.slice(i+1));const s=n?e.createElementNS(n,r):e.createElement(r),l=t[1];let a=1;if(l&&"object"==typeof l&&null==l.nodeType&&!Array.isArray(l)){a=2;for(const e in l)null!=l[e]&&(i=e.indexOf(" "),i>0?s.setAttributeNS(e.slice(0,i),e.slice(i+1),l[e]):dn(s,e,l[e]))}for(let r=a;r<t.length;r++){const i=t[r];if(0===i){if(r<t.length-1||r>a)throw new RangeError("Content hole must be the only child of its parent node");return{dom:s,contentDOM:s}}{const{dom:t,contentDOM:r}=hn.renderSpec(e,i,n);if(s.appendChild(t),r){if(o)throw new RangeError("Multiple content holes");o=r}}}return{dom:s,contentDOM:o}}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new hn(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){const t=pn(e.nodes);return t.text||(t.text=e=>e.text),t}static marksFromSchema(e){return pn(e.marks)}constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},n){n||(n=un(t).createDocumentFragment());let o=n;const r=[];return e.forEach((e=>{if(r.length||e.marks.length){let n=0,i=0;for(;n<r.length&&i<e.marks.length;){const t=e.marks[i];if(this.marks[t.type.name]){if(!t.eq(r[n][0])||!1===t.type.spec.spanning)break;n++,i++}else i++}for(;n<r.length;)o=r.pop()[1];for(;i<e.marks.length;){const n=e.marks[i++],s=this.serializeMark(n,e.isInline,t);s&&(r.push([n,o]),o.appendChild(s.dom),o=s.contentDOM||s.dom)}}o.appendChild(this.serializeNodeInner(e,t))})),n}serializeNode(e,t={}){let n=this.serializeNodeInner(e,t);for(let o=e.marks.length-1;o>=0;o--){const r=this.serializeMark(e.marks[o],e.isInline,t);r&&((r.contentDOM||r.dom).appendChild(n),n=r.dom)}return n}serializeMark(e,t,n={}){const o=this.marks[e.type.name];return o&&hn.renderSpec(un(n),o(e,t))}serializeNodeInner(e,t){const{dom:n,contentDOM:o}=hn.renderSpec(un(t),this.nodes[e.type.name](e));if(o){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,o)}return n}}function pn(e){const t={};for(const n in e)if(e[n]){const o=e[n].spec.toDOM;o&&(t[n]=o)}return t}function un(e){return e.document||window.document}const fn=["div","ol","ul","li","table","tbody","thead","tfoot","caption","td","th","p","tr","col","colgroup","article","main","nav","header","footer","aside","section"],mn=(e,t)=>{const n=(e.ownerDocument||document).createElement(t);Array.from(e.rows).filter((e=>e.getAttribute(Mt)===t)).forEach((e=>{e.removeAttribute(Mt),n.appendChild(e)})),n.children.length&&e.appendChild(n)},gn=(e,t)=>{const n=t.toUpperCase();e.filter((e=>e.nodeName===n)).forEach((e=>{Array.from(e.children).forEach((n=>{n.setAttribute(Mt,t),e.parentNode&&e.parentNode.insertBefore(n,e)})),e.remove()}))},yn=(e,t=fn)=>{const n=t.join("|");return e.replace(new RegExp("\\s*(<(?:"+n+")(?:\\s[^>]*?)?>)","g"),"$1").replace(new RegExp("(<\\/(?:"+n+")(?:\\s[^>]*?)?>)\\s*","g"),"$1")},wn="data-style",vn=" "+wn+"=",bn=/<[^>]+>/gm,kn=/\sstyle=/gm,xn=e=>e.replace(kn,vn),Sn=e=>{const t=document.createElement("template");var n;return t.innerHTML=(e=>e.replace(bn,xn))(e),n=t.content,Array.from(n.querySelectorAll("["+wn+"]")).forEach((e=>{const t=e.getAttribute(wn);e.removeAttribute(wn),cn(e,t)})),t.content.cloneNode(!0)},Cn=e=>Array.from(e.childNodes).reduce(((e,t)=>e+(t.outerHTML||t.textContent||"")),""),Mn=e=>{const t=hn.fromSchema(e.type.schema).serializeFragment(e.content);return(e=>{Array.from(e.querySelectorAll("table")).forEach((e=>{mn(e,"thead"),mn(e,"tbody"),mn(e,"tfoot");const t=Array.from(e.children).find((e=>0===e.children.length));t&&t.remove();const n=e.parentNode instanceof HTMLDivElement?e.parentNode:null;if(n&&n.matches("div[table]")){e.style.marginLeft=n.style.marginLeft,e.style.marginRight=n.style.marginRight;const t=Array.from(n.children).find((e=>e.matches("div[caption]")));if(t&&"<img>"!==t.innerHTML){const n=e.createCaption();for(t.id&&(n.id=t.id),t.className&&(n.className=t.className),Array.from(t.style).forEach((e=>{n.style[e]=t.style[e]}));t.firstChild;)n.appendChild(t.firstChild)}n.style.width&&!e.style.width&&(e.style.width=n.style.width),n.parentNode.insertBefore(e,n),n.parentNode.removeChild(n)}}))})(t),t},Nn=(e,t,n)=>Y.fromSchema(t).parse(e,n),On=(e,t,n)=>{const o=Sn(e);var r;return r=o,Array.from(r.querySelectorAll("table")).forEach((e=>{const t=Array.from(e.children);t.some((e=>"THEAD"===e.nodeName||"TFOOT"===e.nodeName))&&(gn(t,"thead"),gn(t,"tbody"),gn(t,"tfoot"));const n=t.find((e=>"COLGROUP"===e.nodeName));if(n&&(e.setAttribute(Nt,n.outerHTML),n.remove()),e.caption||e.style.marginLeft||e.style.marginRight){const t=document.createElement("div");if(t.setAttribute("table",""),t.style.display="table",t.style.marginLeft=e.style.marginLeft,t.style.marginRight=e.style.marginRight,e.caption){const n=document.createElement("div");for(n.setAttribute("caption",""),e.caption.id&&(n.id=e.caption.id),e.caption.className&&(n.className=e.caption.className),Array.from(e.caption.style).forEach((t=>{n.style[t]=e.caption.style[t]}));e.caption.firstChild;)n.appendChild(e.caption.firstChild);e.removeChild(e.caption),t.appendChild(n)}e.parentNode.insertBefore(t,e),t.appendChild(e),/%/.test(e.style.width)&&(t.style.width=e.style.width,e.style.width="")}})),Nn(o,t,n)},An=e=>{const t=Mn(e.doc);return Cn(t)},Tn=(e,t="setHTML",n={preserveWhitespace:"full"})=>(o,r)=>r(o.tr.setSelection(new dt(o.doc)).replaceSelectionWith(On(e,o.schema,n)).setMeta("commandName",t)),Dn=(e,t,n,o)=>{const r=s.from(On(e,n,o)),i=s.from(On(t,n,o));return r.eq(i)},En=e=>{const t=Sn(e);return Rn(t),Cn(t)},Rn=e=>{var t;const n=e.ownerDocument.createNodeIterator(e,NodeFilter.SHOW_COMMENT);let o=n.nextNode();for(;o;)null===(t=o.parentNode)||void 0===t||t.removeChild(o),o=n.nextNode()};class $n{constructor(e){this.extractBefore=e=>this._traverseSide({edge:e,next:function(e){return e.previousSibling},insert:function(e,t){e.insertBefore(t,e.firstChild)}}),this.extractAfter=e=>this._traverseSide({edge:e,next:function(e){return e.nextSibling},insert:function(e,t){e.appendChild(t)}}),this._traverseSide=e=>{const t=this.top,n=t.ownerDocument.createDocumentFragment();let o=e.edge;do{const r=o.parentNode;for(o=e.next(o);o;){const t=e.next(o);e.insert(n,o),o=t}if(t===r||t.contains(r)){const t=r.cloneNode(!1);t.innerHTML="",t.appendChild(n),e.insert(n,t)}o=r}while(o&&o!==t);return n},this.top=e}}const In=e=>e.querySelector("span span"),zn=e=>1===e.childNodes.length&&"SPAN"===e.firstChild.nodeName&&0===e.firstChild.childNodes.length,Bn=e=>{const t=Sn(e);let n=In(t);for(;n;){const e=n.parentNode.closest("span");if(e){const t=new $n(e),o=t.extractAfter(n),r=t.extractBefore(n);for(let t=0;t<n.style.length;t++){const o=n.style.item(t);e.style[o]=n.style.getPropertyValue(o)}n.removeAttribute("style"),n.classList.length&&Array.from(n.classList).forEach((t=>{e.classList.contains(t)||e.classList.add(t)})),n.removeAttribute("class");for(let t=0;t<n.attributes.length;t++){const o=n.attributes.item(t);o&&null!==o.nodeValue&&e.setAttribute(o.nodeName,o.nodeValue)}for(;n.firstChild&&n.parentNode;)n.parentNode.insertBefore(n.firstChild,n);n.parentNode&&n.parentNode.removeChild(n),e.parentNode&&(zn(r)||e.parentNode.insertBefore(r,e),zn(o)||e.parentNode.insertBefore(o,e.nextSibling))}n=In(t)}return Cn(t)},Pn=(e,t,n)=>{const o=o=>{const r=t[o],i=r.$from,s=r.$to;let l=0===i.depth&&e.type.allowsMarkType(n);if(e.nodesBetween(i.pos,s.pos,(e=>{if(l)return!1;l=e.inlineContent&&e.type.allowsMarkType(n)})),l)return{v:!0}};for(let e=0;e<t.length;e++){const t=o(e);if(t)return t.v}return!1},Vn=(e,t,n)=>(o,r)=>{const{empty:i,$cursor:s,ranges:l}=o.selection;if(i&&!s||!Pn(o.doc,l,e))return!1;if(r)if(s)e.isInSet(o.storedMarks||s.marks())?r(n.removeStoredMark(e)):r(n.addStoredMark(e.create(t)));else{let i=!1;for(let t=0;!i&&t<l.length;t++){const{$from:n,$to:r}=l[t];i=o.doc.rangeHasMark(n.pos,r.pos,e)}for(let o=0;o<l.length;o++){const{$from:r,$to:s}=l[o];i?n.removeMark(r.pos,s.pos,e):n.addMark(r.pos,s.pos,e.create(t))}r(n.scrollIntoView())}return!0},Fn=(e,t,n,o)=>{void 0===o&&(o=null);const r=[];let i=0;return e.doc.nodesBetween(t,n,((e,s)=>{if(!e.isInline)return;i++;let l=null;if(o instanceof X){const t=o.isInSet(e.marks);t&&(l=[t])}else o?o.isInSet(e.marks)&&(l=[o]):l=e.marks;if(l&&l.length){const o=Math.min(s+e.nodeSize,n);for(let e=0;e<l.length;e++){const n=l[e];let a;for(let e=0;e<r.length;e++){const t=r[e];t.step===i-1&&n.eq(t.style)&&(a=t)}a?(a.to=o,a.step=i):r.push({style:n,from:Math.max(s,t),to:o,step:i})}}})),r.forEach((t=>e.step(new xe(t.from,t.to,t.style)))),e},Ln=({except:e=[]}={})=>(t,n)=>{const o=t.tr;var r;Hn(o,{except:(r=e,r instanceof Array?r:[r])}),o.docChanged&&n(o)},Hn=(e,{except:t})=>{const{doc:n,selection:o}=e,r=n.type.schema,{empty:i,ranges:s}=o,l=(t||[]).map((e=>e.name));if(!i){const t=Object.keys(r.marks).map((e=>r.marks[e])).filter((e=>-1===l.indexOf(e.name)));s.forEach((({$from:n,$to:o})=>{t.forEach((t=>e.removeMark(n.pos,o.pos,t)))}))}},_n=(e,t)=>{const n=e.schema.marks,o=(t.altMarks||[]).filter((e=>n[e])),r=t.altStyle,{from:i,$from:s,to:l,empty:a}=e.selection,c=n[t.mark],d=e.doc;let h,p=!1;return a?(h=e.storedMarks||s.marks(),p=c&&c.isInSet(h)||o.some((e=>n[e].isInSet(h)))):p=c&&d.rangeHasMark(i,l,c)||o.some((e=>d.rangeHasMark(i,l,n[e]))),!p&&r&&n.style?qn(e,n.style).some((e=>null!==Wn(e,r))):Boolean(p)},Wn=(e,t)=>{const n=e&&e.attrs.style||"",o=ln(n),r=Object.keys(o);for(let e=0;e<r.length;e++){const n=r[e];if(n.toLowerCase()===t.name&&t.value.test(o[n]))return o[n]}return null},qn=(e,t)=>{const{from:n,$from:o,to:r,empty:i}=e.selection,s=[];return i?s.push(t.isInSet(e.storedMarks||o.marks())):e.doc.nodesBetween(n,r,(e=>{e.isInline&&s.push(t.isInSet(e.marks))})),s},jn=(e,t)=>{const n=qn(e,t),o=n.filter((e=>Boolean(e)));return n.length===o.length?n[0]:void 0},Jn=(e,t)=>{const n=qn(e,t),o=n.filter((e=>Boolean(e)));return{hasNodesWithoutMarks:n.length!==o.length,marks:o}},Kn=(e,t)=>{const n=e.find((e=>"style"===e.type.name)),o=n&&n.attrs.style;return qt(o,t)},Xn=(e,t,n,o,r)=>{const i=r.create({style:o.style}),s=[],l=[];let a=null,c=null;return e.doc.nodesBetween(t,n,((e,d,h)=>{if(!e.isInline)return;const p=e.marks;if(!i.isInSet(p)&&h.type.allowsMarkType(i.type)){const i=Math.max(d,t),h=Math.min(d+e.nodeSize,n),u=Kn(p,o);if(u.changed||o.newValue){const e=u.changed?{style:u.style||null}:{style:`${o.style}: ${o.newValue};`},t=r.isInSet(p)?p.find((e=>"style"===e.type.name)):null,n=t?{...t.attrs,...e}:e,d=r.create(n),f=d.addToSet(p);for(let e=0;e<p.length;e++)p[e].isInSet(f)||(a&&a.to===i&&a.mark.eq(p[e])?a.to=h:(a=new xe(i,h,p[e]),s.push(a)));const m=c&&c.to===i,g=m&&d.attrs.style===c.mark.attrs.style;m&&g?c.to=h:Object.keys(n).some((e=>null!==n[e]))&&(c=new ke(i,h,d),l.push(c))}}})),s.forEach((t=>e.step(t))),l.forEach((t=>e.step(t))),s.length+l.length>0},Un=(e,t)=>{const n=e.schema.marks.style;return(n?qn(e,n):[]).map((e=>Wn(e,t))).filter((e=>null!==e))},Gn=(e,t)=>function(n,o,r){const{empty:i,ranges:s}=n.selection,l=n.selection instanceof st&&n.selection.$cursor;if(i&&!l||!Pn(n.doc,s,e))return!1;let a=!1;if(o){const i=r||n.tr;if(l){const r=n.storedMarks||l.marks();if(e.isInSet(r)){const n=Kn(r,t),s=r.find((e=>"style"===e.type.name)),l={...s?s.attrs:{},style:n.style||null};if(((e,t)=>{const n=Object.keys(e),o=Object.keys(t);return n.length===o.length&&n.every((n=>e[n]===t[n]))})(s.attrs,l))return!1;o(i.removeStoredMark(e)),Object.keys(l).some((e=>null!==l[e]))&&o(i.addStoredMark(e.create(l))),a=!0}}else{for(let n=0;n<s.length;n++){const{$from:o,$to:r}=s[n];a=Xn(i,o.pos,r.pos,t,e)||a}a&&(i.scrollIntoView(),o(i))}}return a},Yn=(e,t,n)=>(o,r)=>{const i=o.schema.marks,{altStyle:s,altMarks:l=[],mark:a}=e,c=t||o.tr;let d=!1,h=!1;const p=()=>h=!0;s&&i.style&&(d=Gn(i.style,{style:s.name,value:s.value})(o,p,c));const u=[a,...l].filter((e=>i[e])).map((e=>_n(o,{mark:e})&&i[e])).filter((e=>e));return u.length?((e,t,n,o)=>{const{$cursor:r,ranges:i}=t.selection;if(o=o||t.tr,r)e.forEach((e=>{e.isInSet(t.storedMarks||r.marks())&&n(o.removeStoredMark(e))}));else{for(let t=0;t<i.length;t++){const{$from:n,$to:r}=i[t];e.forEach((e=>{Fn(o,n.pos,r.pos,e)}))}n(o.scrollIntoView())}})(u,o,p,c):d||Vn(i[a],n,c)(o,p),h&&r(c),h},Qn=(e,t)=>(n,o)=>{const r=n.schema.marks.style,i={style:e.style,value:/^.+$/,newValue:e.value},s=n.tr;t&&s.setMeta("commandName",t),s.setMeta("args",e);const{empty:l,$cursor:a,ranges:c}=n.selection;if(l&&!a||!r||!Pn(n.doc,c,r))return!1;if(a){const e=n.storedMarks||a.marks(),t=r.isInSet(e)?e.find((e=>"style"===e.type.name)):null,l={style:null};if(t&&t.attrs.style){const e=qt(t.attrs.style,i);e.changed&&e.style&&(l.style=e.style)}else i.newValue&&(l.style=`${i.style}: ${i.newValue};`);const c=t?{...t.attrs,...l}:l;return Object.keys(c).some((e=>null!==c[e]))?o(s.addStoredMark(r.create(c))):o(s.removeStoredMark(r)),!0}return Gn(r,i)(n,o,s)},Zn=(e,t)=>(n,o)=>{const{$cursor:r}=n.selection;if(r){const i=r.parent,s=r.index(),l=n.schema.marks[e.mark],a=i.child(s).marks.find((e=>e.type===l)),c=i.childCount;let d,h,p=r.pos-r.textOffset,u=i.child(s).nodeSize;for(d=s-1;d>=0&&a.isInSet(i.child(d).marks);)h=i.child(d).nodeSize,u+=h,p-=h,d-=1;for(d=s+1;d<c&&a.isInSet(i.child(d).marks);)u+=i.child(d).nodeSize,d+=1;o(Fn(t||n.tr,p,p+u,a))}else Yn(e,t)(n,o)},eo=({mark:e,attrs:t},n="link")=>(o,r)=>{const i=o.schema.marks,s=o.tr;n&&(s.setMeta("commandName",n),s.setMeta("args",t));let l=!1;const a=()=>l=!0;if(((e,t)=>{const n=qn(e,t);return 1===n.length&&n[0]?n[0]:null})(o,i[e]))((e,t)=>(n,o)=>{const{$cursor:r,from:i,to:s}=n.selection,l=n.schema.marks[e.mark];if(r){const n=r.parent,i=r.index(),s=n.child(i).marks.find((e=>e.type===l)),a=n.childCount;let c,d,h=r.pos-r.textOffset,p=n.child(i).nodeSize;for(c=i-1;c>=0&&s.isInSet(n.child(c).marks);)d=n.child(c).nodeSize,p+=d,h-=d,c-=1;for(c=i+1;c<a&&s.isInSet(n.child(c).marks);)p+=n.child(c).nodeSize,c+=1;t.removeMark(h,h+p,l),t.addMark(h,h+p,l.create(e.attrs)),o(t)}else t.doc.nodesBetween(i,s,((n,r)=>{n.isInline&&l.isInSet(n.marks)&&(t.removeMark(r,r+n.nodeSize,l),t.addMark(r,r+n.nodeSize,l.create(e.attrs)),o(t))}))})({mark:e,attrs:t},s)(o,a);else{let n=o;_n(o,{mark:e})&&(Zn({mark:e,attrs:t},s)(o,a),n=vt.create({doc:s.doc,selection:s.selection})),l?Vn(i[e],t,s)(n,a):Yn({mark:e},s,t)(n,a)}return l&&r(s),l},to=e=>(t,n)=>{n(t.tr.insertText(e.text,e.from,e.to))},no=e=>(t,n)=>{const{image:o}=t.schema.nodes,r=o.createAndFill(e);Qt(r)(t,(t=>n(t.setMeta("commandName","insertImage").setMeta("args",e))))},oo=(e,t,n,o)=>{if(!n.isTextblock)return!1;const{ranges:r}=e.selection;r.forEach((r=>{const i=e.steps.length,l=r.$from.pos,a=r.$to.pos;e.doc.nodesBetween(l,a,((r,l)=>{if(r.eq(t)&&r.isTextblock&&!r.hasMarkup(n,o)&&((e,t,n)=>{const o=e.resolve(t),r=o.index();return o.parent.canReplaceWith(r,r+1,n)})(e.doc,e.mapping.slice(i).map(l),n)){e.clearIncompatible(e.mapping.slice(i).map(l,1),n);const t=e.mapping.slice(i),a=t.map(l,1),c=t.map(l+r.nodeSize,1),d=new p(s.from(n.create(o,null,r.marks)),0,0);return e.step(new Ne(a,c,a+1,c-1,d,1,!0)),!1}}))}))},ro=(e,t={blocksInSelection:!1})=>{const{doc:n,selection:o}=e,{$from:r,ranges:i}=o,{blocksInSelection:s}=t,l=[],a=o instanceof at?o.node:void 0;return a?a.isBlock?(l.push(a),a.nodesBetween(0,a.content.size,(e=>{e.isBlock&&l.push(e)}))):!s&&r.parent&&r.parent.isBlock&&l.push(r.parent):i.forEach((e=>{const t=e.$from.pos,o=e.$to.pos;n.nodesBetween(t,o,((e,n)=>{e.isBlock&&(!s||n>=t&&n+e.content.size+2<=o)&&l.push(e)}))})),l},io=(e,t)=>(n,o)=>{const r=ro(n),i=n.schema.nodes,s=n.tr;s.setMeta("commandName",t),s.setMeta("args",{value:e}),r.forEach((t=>{if(t.type.isTextblock)if("p"===e)oo(s,t,i.paragraph,t.attrs);else if(/^h[1-6]$/i.test(e)){const n=parseInt(e.substr(1),10);oo(s,t,i.heading,{...t.attrs,level:n})}else"blockquote"===e&&oo(s,t,i.blockquote,t.attrs)}));const l=s.docChanged;return l&&o(s.scrollIntoView()),l},so=(e,t={blocksInSelection:!0})=>{const{doc:n,selection:o}=e,{blocksInSelection:r,blockNodeType:i}=t;ro({doc:n,selection:o},{blocksInSelection:r}).filter((e=>e.isTextblock)).forEach((t=>{const{style:n="",class:o="",...r}=t.attrs||{},s=i||t.type;(n||o||s!==t.type)&&oo(e,t,s,r)}))},lo=e=>{const t=ro(e),n=e.schema.nodes,o=[];return t.forEach((e=>{e.type===n.paragraph?o.push("p"):e.type===n.heading?o.push(`h${e.attrs.level}`):e.type===n.blockquote&&n.blockquote.isTextblock&&o.push("blockquote")})),o},ao=(e,t)=>{let n,o,r=e.attrs.style;return r&&t.forEach((e=>{o={style:e.name,value:/^.+$/,newValue:e.value},n=qt(r,o),r=n.changed?n.style:r})),r=r||t.reduce(((e,t)=>(e&&t.value?e+" ":"")+t.value?`${t.name}: ${t.value};`:""),""),Object.assign({},e.attrs,{style:r||null})},co=(e,t)=>{const{from:n,to:o}=e.selection;let r=!1;return e.doc.nodesBetween(n,o,(e=>(r=r||e.type===t,!r))),r},ho=e=>{const t=lo(e);return 1===new Set(t).size?t[0]:null},po=e=>({tag:ho(e)||""}),uo=(e,t)=>(n,o)=>{const r=ro(n),i=n.tr;i.setMeta("commandName",t),r.forEach((t=>{if(t.type.isTextblock){const n=e.find((e=>e.node===t.type.name));if(n){const e=ao(t,n.style);oo(i,t,t.type,e)}}}));const s=i.docChanged;return s&&o(i.scrollIntoView()),s},fo=(e,t)=>{const n=ro(e);let o=!1;return n.forEach((e=>{if(!o&&e.type.isTextblock&&e.attrs.style){const n=t.find((t=>t.node===e.type.name));n&&(o=n.style.every((t=>!!t.value&&new RegExp(`${t.name}:\\s?${t.value}`,"i").test(e.attrs.style))))}})),o},mo=(e={blocksInSelection:!0})=>(t,n)=>{const o=t.tr,{blocksInSelection:r,blockNodeType:i,exceptMarks:s}=e,l=(s||[t.schema.marks.link]).filter(Boolean);Hn(o,{except:l}),so(o,{blocksInSelection:r,blockNodeType:i});const a=o.docChanged;return a&&n&&n(o),a},go=["ol",0],yo=["ul",0],wo=["li",0],vo={attrs:{order:{default:1,validate:"number"}},parseDOM:[{tag:"ol",getAttrs:e=>({order:e.hasAttribute("start")?+e.getAttribute("start"):1})}],toDOM:e=>1==e.attrs.order?go:["ol",{start:e.attrs.order},0]},bo={parseDOM:[{tag:"ul"}],toDOM:()=>yo},ko={parseDOM:[{tag:"li"}],toDOM:()=>wo,defining:!0};function xo(e,t){let n={};for(let t in e)n[t]=e[t];for(let e in t)n[e]=t[e];return n}function So(e,t,n){return e.append({ordered_list:xo(vo,{content:"list_item+",group:n}),bullet_list:xo(bo,{content:"list_item+",group:n}),list_item:xo(ko,{content:t})})}function Co(e,t=null){return function(n,o){let{$from:r,$to:i}=n.selection,s=r.blockRange(i);if(!s)return!1;let l=o?n.tr:null;return!!Mo(l,s,e,t)&&(o&&o(l.scrollIntoView()),!0)}}function Mo(e,t,n,o=null){let r=!1,i=t,l=t.$from.doc;if(t.depth>=2&&t.$from.node(t.depth-1).type.compatibleContent(n)&&0==t.startIndex){if(0==t.$from.index(t.depth-1))return!1;let e=l.resolve(t.start-2);i=new A(e,e,t.depth),t.endIndex<t.parent.childCount&&(t=new A(t.$from,l.resolve(t.$to.end(t.depth)),t.depth)),r=!0}let a=Ee(i,n,o,t);return!!a&&(e&&function(e,t,n,o,r){let i=s.empty;for(let e=n.length-1;e>=0;e--)i=s.from(n[e].type.create(n[e].attrs,i));e.step(new Ne(t.start-(o?2:0),t.end,t.start,t.end,new p(i,0,0),n.length,!0));let l=0;for(let e=0;e<n.length;e++)n[e].type==r&&(l=e+1);let a=n.length-l,c=t.start+n.length-(o?2:0),d=t.parent;for(let n=t.startIndex,o=t.endIndex,r=!0;n<o;n++,r=!1)!r&&ze(e.doc,c,a)&&(e.split(c,a),c+=2*a),c+=d.child(n).nodeSize}(e,t,a,r,n),!0)}function No(e,t){return function(n,o){let{$from:r,$to:i,node:l}=n.selection;if(l&&l.isBlock||r.depth<2||!r.sameParent(i))return!1;let a=r.node(-1);if(a.type!=e)return!1;if(0==r.parent.content.size&&r.node(-1).childCount==r.indexAfter(-1)){if(3==r.depth||r.node(-3).type!=e||r.index(-2)!=r.node(-2).childCount-1)return!1;if(o){let t=s.empty,i=r.index(-1)?1:r.index(-2)?2:3;for(let e=r.depth-i;e>=r.depth-3;e--)t=s.from(r.node(e).copy(t));let l=r.indexAfter(-1)<r.node(-2).childCount?1:r.indexAfter(-2)<r.node(-3).childCount?2:3;t=t.append(s.from(e.createAndFill()));let a=r.before(r.depth-(i-1)),c=n.tr.replace(a,r.after(-l),new p(t,4-i,0)),d=-1;c.doc.nodesBetween(a,c.doc.content.size,((e,t)=>{if(d>-1)return!1;e.isTextblock&&0==e.content.size&&(d=t+1)})),d>-1&&c.setSelection(nt.near(c.doc.resolve(d))),o(c.scrollIntoView())}return!0}let c=i.pos==r.end()?a.contentMatchAt(0).defaultType:null,d=n.tr.delete(r.pos,i.pos),h=c?[t?{type:e,attrs:t}:null,{type:c}]:void 0;return!!ze(d.doc,r.pos,2,h)&&(o&&o(d.split(r.pos,2,h).scrollIntoView()),!0)}}function Oo(e,t){let n=No(e,t);return(e,t)=>n(e,t&&(n=>{let o=e.storedMarks||e.selection.$to.parentOffset&&e.selection.$from.marks();o&&n.ensureMarks(o),t(n)}))}function Ao(e){return function(t,n){let{$from:o,$to:r}=t.selection,i=o.blockRange(r,(t=>t.childCount>0&&t.firstChild.type==e));return!!i&&(!n||(o.node(i.depth-1).type==e?function(e,t,n,o){let r=e.tr,i=o.end,l=o.$to.end(o.depth);i<l&&(r.step(new Ne(i-1,l,i,l,new p(s.from(n.create(null,o.parent.copy())),1,0),1,!0)),o=new A(r.doc.resolve(o.$from.pos),r.doc.resolve(l),o.depth));const a=De(o);if(null==a)return!1;r.lift(o,a);let c=r.doc.resolve(r.mapping.map(i,-1)-1);return Be(r.doc,c.pos)&&c.nodeBefore.type==c.nodeAfter.type&&r.join(c.pos),t(r.scrollIntoView()),!0}(t,n,e,i):function(e,t,n){let o=e.tr,r=n.parent;for(let e=n.end,t=n.endIndex-1,i=n.startIndex;t>i;t--)e-=r.child(t).nodeSize,o.delete(e-1,e+1);let i=o.doc.resolve(n.start),l=i.nodeAfter;if(o.mapping.map(n.end)!=n.start+i.nodeAfter.nodeSize)return!1;let a=0==n.startIndex,c=n.endIndex==r.childCount,d=i.node(-1),h=i.index(-1);if(!d.canReplace(h+(a?0:1),h+1,l.content.append(c?s.empty:s.from(r))))return!1;let u=i.pos,f=u+l.nodeSize;return o.step(new Ne(u-(a?1:0),f+(c?1:0),u+1,f-1,new p((a?s.empty:s.from(r.copy(s.empty))).append(c?s.empty:s.from(r.copy(s.empty))),a?0:1,c?0:1),a?0:1)),t(o.scrollIntoView()),!0}(t,n,i)))}}function To(e){return function(t,n){let{$from:o,$to:r}=t.selection,i=o.blockRange(r,(t=>t.childCount>0&&t.firstChild.type==e));if(!i)return!1;let l=i.startIndex;if(0==l)return!1;let a=i.parent,c=a.child(l-1);if(c.type!=e)return!1;if(n){let o=c.lastChild&&c.lastChild.type==a.type,r=s.from(o?e.create():null),l=new p(s.from(e.create(null,s.from(a.type.create(null,r)))),o?3:1,0),d=i.start,h=i.end;n(t.tr.step(new Ne(d-(o?3:1),h,d,h,l,1,!0)).scrollIntoView())}return!0}}const Do={orderedList:"ordered_list",bulletList:"bullet_list",listItem:"list_item"},Eo={listType:Do.orderedList,types:{...Do}},Ro={listType:Do.bulletList,types:{...Do}},$o={nodes:[{node:"paragraph",style:"margin-left",rtlStyle:"margin-right",step:30,unit:"px"},{node:"heading",style:"margin-left",rtlStyle:"margin-right",step:30,unit:"px"}],listsTypes:{...Do}},Io={nodes:[{node:"paragraph",style:"margin-left",rtlStyle:"margin-right",step:-30,unit:"px"},{node:"heading",style:"margin-left",rtlStyle:"margin-right",step:-30,unit:"px"}],listsTypes:{...Do}},zo=(e,t)=>!e.selection.empty&&(t&&t(e.tr.deleteSelection().scrollIntoView()),!0);function Bo(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock("backward",e):n.parentOffset>0)?null:n}const Po=(e,t,n)=>{let o=Bo(e,n);if(!o)return!1;let r=Wo(o);if(!r){let n=o.blockRange(),r=n&&De(n);return null!=r&&(t&&t(e.tr.lift(n,r).scrollIntoView()),!0)}let i=r.nodeBefore;if(lr(e,r,t,-1))return!0;if(0==o.parent.content.size&&(Ho(i,"end")||at.isSelectable(i)))for(let n=o.depth;;n--){let s=He(e.doc,o.before(n),o.after(n),p.empty);if(s&&s.slice.size<s.to-s.from){if(t){let n=e.tr.step(s);n.setSelection(Ho(i,"end")?nt.findFrom(n.doc.resolve(n.mapping.map(r.pos,-1)),-1):at.create(n.doc,r.pos-i.nodeSize)),t(n.scrollIntoView())}return!0}if(1==n||o.node(n-1).childCount>1)break}return!(!i.isAtom||r.depth!=o.depth-1||(t&&t(e.tr.delete(r.pos-i.nodeSize,r.pos).scrollIntoView()),0))},Vo=(e,t,n)=>{let o=Bo(e,n);if(!o)return!1;let r=Wo(o);return!!r&&Lo(e,r,t)},Fo=(e,t,n)=>{let o=qo(e,n);if(!o)return!1;let r=Ko(o);return!!r&&Lo(e,r,t)};function Lo(e,t,n){let o=t.nodeBefore,r=t.pos-1;for(;!o.isTextblock;r--){if(o.type.spec.isolating)return!1;let e=o.lastChild;if(!e)return!1;o=e}let i=t.nodeAfter,s=t.pos+1;for(;!i.isTextblock;s++){if(i.type.spec.isolating)return!1;let e=i.firstChild;if(!e)return!1;i=e}let l=He(e.doc,r,s,p.empty);if(!l||l.from!=r||l instanceof Me&&l.slice.size>=s-r)return!1;if(n){let t=e.tr.step(l);t.setSelection(st.create(t.doc,r)),n(t.scrollIntoView())}return!0}function Ho(e,t,n=!1){for(let o=e;o;o="start"==t?o.firstChild:o.lastChild){if(o.isTextblock)return!0;if(n&&1!=o.childCount)return!1}return!1}const _o=(e,t,n)=>{let{$head:o,empty:r}=e.selection,i=o;if(!r)return!1;if(o.parent.isTextblock){if(n?!n.endOfTextblock("backward",e):o.parentOffset>0)return!1;i=Wo(o)}let s=i&&i.nodeBefore;return!(!s||!at.isSelectable(s)||(t&&t(e.tr.setSelection(at.create(e.doc,i.pos-s.nodeSize)).scrollIntoView()),0))};function Wo(e){if(!e.parent.type.spec.isolating)for(let t=e.depth-1;t>=0;t--){if(e.index(t)>0)return e.doc.resolve(e.before(t+1));if(e.node(t).type.spec.isolating)break}return null}function qo(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock("forward",e):n.parentOffset<n.parent.content.size)?null:n}const jo=(e,t,n)=>{let o=qo(e,n);if(!o)return!1;let r=Ko(o);if(!r)return!1;let i=r.nodeAfter;if(lr(e,r,t,1))return!0;if(0==o.parent.content.size&&(Ho(i,"start")||at.isSelectable(i))){let n=He(e.doc,o.before(),o.after(),p.empty);if(n&&n.slice.size<n.to-n.from){if(t){let o=e.tr.step(n);o.setSelection(Ho(i,"start")?nt.findFrom(o.doc.resolve(o.mapping.map(r.pos)),1):at.create(o.doc,o.mapping.map(r.pos))),t(o.scrollIntoView())}return!0}}return!(!i.isAtom||r.depth!=o.depth-1||(t&&t(e.tr.delete(r.pos,r.pos+i.nodeSize).scrollIntoView()),0))},Jo=(e,t,n)=>{let{$head:o,empty:r}=e.selection,i=o;if(!r)return!1;if(o.parent.isTextblock){if(n?!n.endOfTextblock("forward",e):o.parentOffset<o.parent.content.size)return!1;i=Ko(o)}let s=i&&i.nodeAfter;return!(!s||!at.isSelectable(s)||(t&&t(e.tr.setSelection(at.create(e.doc,i.pos)).scrollIntoView()),0))};function Ko(e){if(!e.parent.type.spec.isolating)for(let t=e.depth-1;t>=0;t--){let n=e.node(t);if(e.index(t)+1<n.childCount)return e.doc.resolve(e.after(t+1));if(n.type.spec.isolating)break}return null}const Xo=(e,t)=>{let n,o=e.selection,r=o instanceof at;if(r){if(o.node.isTextblock||!Be(e.doc,o.from))return!1;n=o.from}else if(n=Ve(e.doc,o.from,-1),null==n)return!1;if(t){let o=e.tr.join(n);r&&o.setSelection(at.create(o.doc,n-e.doc.resolve(n).nodeBefore.nodeSize)),t(o.scrollIntoView())}return!0},Uo=(e,t)=>{let n,o=e.selection;if(o instanceof at){if(o.node.isTextblock||!Be(e.doc,o.to))return!1;n=o.to}else if(n=Ve(e.doc,o.to,1),null==n)return!1;return t&&t(e.tr.join(n).scrollIntoView()),!0},Go=(e,t)=>{let{$from:n,$to:o}=e.selection,r=n.blockRange(o),i=r&&De(r);return null!=i&&(t&&t(e.tr.lift(r,i).scrollIntoView()),!0)},Yo=(e,t)=>{let{$head:n,$anchor:o}=e.selection;return!(!n.parent.type.spec.code||!n.sameParent(o)||(t&&t(e.tr.insertText("\n").scrollIntoView()),0))};function Qo(e){for(let t=0;t<e.edgeCount;t++){let{type:n}=e.edge(t);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}const Zo=(e,t)=>{let{$head:n,$anchor:o}=e.selection;if(!n.parent.type.spec.code||!n.sameParent(o))return!1;let r=n.node(-1),i=n.indexAfter(-1),s=Qo(r.contentMatchAt(i));if(!s||!r.canReplaceWith(i,i,s))return!1;if(t){let o=n.after(),r=e.tr.replaceWith(o,o,s.createAndFill());r.setSelection(nt.near(r.doc.resolve(o),1)),t(r.scrollIntoView())}return!0},er=(e,t)=>{let n=e.selection,{$from:o,$to:r}=n;if(n instanceof dt||o.parent.inlineContent||r.parent.inlineContent)return!1;let i=Qo(r.parent.contentMatchAt(r.indexAfter()));if(!i||!i.isTextblock)return!1;if(t){let n=(!o.parentOffset&&r.index()<r.parent.childCount?o:r).pos,s=e.tr.insert(n,i.createAndFill());s.setSelection(st.create(s.doc,n+1)),t(s.scrollIntoView())}return!0},tr=(e,t)=>{let{$cursor:n}=e.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let o=n.before();if(ze(e.doc,o))return t&&t(e.tr.split(o).scrollIntoView()),!0}let o=n.blockRange(),r=o&&De(o);return null!=r&&(t&&t(e.tr.lift(o,r).scrollIntoView()),!0)};function nr(e){return(t,n)=>{let{$from:o,$to:r}=t.selection;if(t.selection instanceof at&&t.selection.node.isBlock)return!(!o.parentOffset||!ze(t.doc,o.pos)||(n&&n(t.tr.split(o.pos).scrollIntoView()),0));if(!o.depth)return!1;let i,s,l=[],a=!1,c=!1;for(let t=o.depth;;t--){if(o.node(t).isBlock){a=o.end(t)==o.pos+(o.depth-t),c=o.start(t)==o.pos-(o.depth-t),s=Qo(o.node(t-1).contentMatchAt(o.indexAfter(t-1)));let n=e&&e(r.parent,a,o);l.unshift(n||(a&&s?{type:s}:null)),i=t;break}if(1==t)return!1;l.unshift(null)}let d=t.tr;(t.selection instanceof st||t.selection instanceof dt)&&d.deleteSelection();let h=d.mapping.map(o.pos),p=ze(d.doc,h,l.length,l);if(p||(l[0]=s?{type:s}:null,p=ze(d.doc,h,l.length,l)),!p)return!1;if(d.split(h,l.length,l),!a&&c&&o.node(i).type!=s){let e=d.mapping.map(o.before(i)),t=d.doc.resolve(e);s&&o.node(i-1).canReplaceWith(t.index(),t.index()+1,s)&&d.setNodeMarkup(d.mapping.map(o.before(i)),s)}return n&&n(d.scrollIntoView()),!0}}const or=nr(),rr=(e,t)=>or(e,t&&(n=>{let o=e.storedMarks||e.selection.$to.parentOffset&&e.selection.$from.marks();o&&n.ensureMarks(o),t(n)})),ir=(e,t)=>{let n,{$from:o,to:r}=e.selection,i=o.sharedDepth(r);return 0!=i&&(n=o.before(i),t&&t(e.tr.setSelection(at.create(e.doc,n))),!0)},sr=(e,t)=>(t&&t(e.tr.setSelection(new dt(e.doc))),!0);function lr(e,t,n,o){let r,i,l=t.nodeBefore,a=t.nodeAfter,c=l.type.spec.isolating||a.type.spec.isolating;if(!c&&function(e,t,n){let o=t.nodeBefore,r=t.nodeAfter,i=t.index();return!(!(o&&r&&o.type.compatibleContent(r.type))||(!o.content.size&&t.parent.canReplace(i-1,i)?(n&&n(e.tr.delete(t.pos-o.nodeSize,t.pos).scrollIntoView()),0):!t.parent.canReplace(i,i+1)||!r.isTextblock&&!Be(e.doc,t.pos)||(n&&n(e.tr.join(t.pos).scrollIntoView()),0)))}(e,t,n))return!0;let d=!c&&t.parent.canReplace(t.index(),t.index()+1);if(d&&(r=(i=l.contentMatchAt(l.childCount)).findWrapping(a.type))&&i.matchType(r[0]||a.type).validEnd){if(n){let o=t.pos+a.nodeSize,i=s.empty;for(let e=r.length-1;e>=0;e--)i=s.from(r[e].create(null,i));i=s.from(l.copy(i));let c=e.tr.step(new Ne(t.pos-1,o,t.pos,o,new p(i,1,0),r.length,!0)),d=c.doc.resolve(o+2*r.length);d.nodeAfter&&d.nodeAfter.type==l.type&&Be(c.doc,d.pos)&&c.join(d.pos),n(c.scrollIntoView())}return!0}let h=a.type.spec.isolating||o>0&&c?null:nt.findFrom(t,1),u=h&&h.$from.blockRange(h.$to),f=u&&De(u);if(null!=f&&f>=t.depth)return n&&n(e.tr.lift(u,f).scrollIntoView()),!0;if(d&&Ho(a,"start",!0)&&Ho(l,"end")){let o=l,r=[];for(;r.push(o),!o.isTextblock;)o=o.lastChild;let i=a,c=1;for(;!i.isTextblock;i=i.firstChild)c++;if(o.canReplace(o.childCount,o.childCount,i.content)){if(n){let o=s.empty;for(let e=r.length-1;e>=0;e--)o=s.from(r[e].copy(o));n(e.tr.step(new Ne(t.pos-r.length,t.pos+a.nodeSize,t.pos+c,t.pos+a.nodeSize-c,new p(o,r.length,0),0,!0)).scrollIntoView())}return!0}}return!1}function ar(e){return function(t,n){let o=t.selection,r=e<0?o.$from:o.$to,i=r.depth;for(;r.node(i).isInline;){if(!i)return!1;i--}return!!r.node(i).isTextblock&&(n&&n(t.tr.setSelection(st.create(t.doc,e<0?r.start(i):r.end(i)))),!0)}}const cr=ar(-1),dr=ar(1);function hr(e,t=null){return function(n,o){let{$from:r,$to:i}=n.selection,s=r.blockRange(i),l=s&&Ee(s,e,t);return!!l&&(o&&o(n.tr.wrap(s,l).scrollIntoView()),!0)}}function pr(e,t=null){return function(n,o){let r=!1;for(let o=0;o<n.selection.ranges.length&&!r;o++){let{$from:{pos:i},$to:{pos:s}}=n.selection.ranges[o];n.doc.nodesBetween(i,s,((o,i)=>{if(r)return!1;if(o.isTextblock&&!o.hasMarkup(e,t))if(o.type==e)r=!0;else{let t=n.doc.resolve(i),o=t.index();r=t.parent.canReplaceWith(o,o+1,e)}}))}if(!r)return!1;if(o){let r=n.tr;for(let o=0;o<n.selection.ranges.length;o++){let{$from:{pos:i},$to:{pos:s}}=n.selection.ranges[o];r.setBlockType(i,s,e,t)}o(r.scrollIntoView())}return!0}}function ur(e,t=null,n){let o=!1!==(n&&n.removeWhenPresent),r=!1!==(n&&n.enterInlineAtoms),i=!(n&&n.includeWhitespace);return function(n,s){let{empty:l,$cursor:a,ranges:c}=n.selection;if(l&&!a||!function(e,t,n,o){for(let r=0;r<t.length;r++){let{$from:i,$to:s}=t[r],l=0==i.depth&&e.inlineContent&&e.type.allowsMarkType(n);if(e.nodesBetween(i.pos,s.pos,((e,t)=>{if(l||!o&&e.isAtom&&e.isInline&&t>=i.pos&&t+e.nodeSize<=s.pos)return!1;l=e.inlineContent&&e.type.allowsMarkType(n)})),l)return!0}return!1}(n.doc,c,e,r))return!1;if(s)if(a)e.isInSet(n.storedMarks||a.marks())?s(n.tr.removeStoredMark(e)):s(n.tr.addStoredMark(e.create(t)));else{let l,a=n.tr;r||(c=function(e){let t=[];for(let n=0;n<e.length;n++){let{$from:o,$to:r}=e[n];o.doc.nodesBetween(o.pos,r.pos,((e,n)=>{if(e.isAtom&&e.content.size&&e.isInline&&n>=o.pos&&n+e.nodeSize<=r.pos)return n+1>o.pos&&t.push(new ot(o,o.doc.resolve(n+1))),o=o.doc.resolve(n+1+e.content.size),!1})),o.pos<r.pos&&t.push(new ot(o,r))}return t}(c)),l=o?!c.some((t=>n.doc.rangeHasMark(t.$from.pos,t.$to.pos,e))):!c.every((t=>{let n=!1;return a.doc.nodesBetween(t.$from.pos,t.$to.pos,((o,r,i)=>{if(n)return!1;n=!e.isInSet(o.marks)&&!!i&&i.type.allowsMarkType(e)&&!(o.isText&&/^\s*$/.test(o.textBetween(Math.max(0,t.$from.pos-r),Math.min(o.nodeSize,t.$to.pos-r))))})),!n}));for(let n=0;n<c.length;n++){let{$from:o,$to:r}=c[n];if(l){let n=o.pos,s=r.pos,l=o.nodeAfter,c=r.nodeBefore,d=i&&l&&l.isText?/^\s*/.exec(l.text)[0].length:0,h=i&&c&&c.isText?/\s*$/.exec(c.text)[0].length:0;n+d<s&&(n+=d,s-=h),a.addMark(n,s,e.create(t))}else a.removeMark(o.pos,r.pos,e)}s(a.scrollIntoView())}return!0}}function fr(e,t){return n=>{if(!n.isGeneric)return e(n);let o=[];for(let e=0;e<n.mapping.maps.length;e++){let t=n.mapping.maps[e];for(let e=0;e<o.length;e++)o[e]=t.map(o[e]);t.forEach(((e,t,n,r)=>o.push(n,r)))}let r=[];for(let e=0;e<o.length;e+=2){let i=o[e],s=o[e+1],l=n.doc.resolve(i),a=l.sharedDepth(s),c=l.node(a);for(let e=l.indexAfter(a),n=l.after(a+1);n<=s;++e){let o=c.maybeChild(e);if(!o)break;if(e&&-1==r.indexOf(n)){let i=c.child(e-1);i.type==o.type&&t(i,o)&&r.push(n)}n+=o.nodeSize}}r.sort(((e,t)=>e-t));for(let e=r.length-1;e>=0;e--)Be(n.doc,r[e])&&n.join(r[e]);e(n)}}function mr(e,t){let n=Array.isArray(t)?e=>t.indexOf(e.type.name)>-1:t;return(t,o,r)=>e(t,o&&fr(o,n),r)}function gr(...e){return function(t,n,o){for(let r=0;r<e.length;r++)if(e[r](t,n,o))return!0;return!1}}let yr=gr(zo,Po,_o),wr=gr(zo,jo,Jo);const vr={Enter:gr(Yo,er,tr,or),"Mod-Enter":Zo,Backspace:yr,"Mod-Backspace":yr,"Shift-Backspace":yr,Delete:wr,"Mod-Delete":wr,"Mod-a":sr},br={"Ctrl-h":vr.Backspace,"Alt-Backspace":vr["Mod-Backspace"],"Ctrl-d":vr.Delete,"Ctrl-Alt-Backspace":vr["Mod-Delete"],"Alt-Delete":vr["Mod-Delete"],"Alt-d":vr["Mod-Delete"],"Ctrl-a":cr,"Ctrl-e":dr};for(let e in vr)br[e]=vr[e];const kr=("undefined"!=typeof navigator?/Mac|iP(hone|[oa]d)/.test(navigator.platform):"undefined"!=typeof os&&os.platform&&"darwin"==os.platform())?br:vr,xr=(e,t)=>hr(e.schema.nodes.blockquote)(e,t),Sr=(e,t)=>{const{$from:n,$to:o}=e.selection,r=e.schema.nodes.blockquote,i=e.doc;let s=-1;const l=n.blockRange(o);l&&i.nodesBetween(l.start,l.end,((e,t)=>{e.type===r&&(s=t)}));const a=-1!==s;return t&&a&&t(e.tr.lift(l,i.resolve(s).depth)),a},Cr=(e,t,n)=>(o,r)=>{const i=ro(o),s=o.tr;s.setMeta("commandName",t),i.forEach((t=>{if(t.type.isTextblock){let o;const r=e.find((e=>e.node===t.type.name));if(r){const e="rtl"===n?r.rtlStyle:r.style,i={name:e,value:r.step>0?`${r.step}${r.unit}`:""};if(t.attrs.style){const n=new RegExp(`${e}:\\s?(\\d+)${r.unit}`,"i"),o=t.attrs.style.match(n);if(o){let e=parseFloat(o[1])+r.step;e=e<=0?"":e,i.value=`${e}${e?r.unit:""}`}}o=ao(t,[i])}o&&oo(s,t,t.type,o)}}));const l=s.docChanged;return l&&r(s.scrollIntoView()),l},Mr=(e,t,n)=>{const o=ro(e);let r=!1;return o.forEach((e=>{if(!r&&e.type.isTextblock&&e.attrs.style){const o=t.find((t=>t.node===e.type.name));if(o){const t="rtl"===n?o.rtlStyle:o.style,i=new RegExp(`${t}:\\s?\\d+${o.unit}`,"i");r=i.test(e.attrs.style)}}})),r},Nr=(e,t)=>To(t)(e),Or=(e,t)=>{const n=e.schema.nodes[t.listsTypes.listItem],o=e.schema.nodes[t.listsTypes.orderedList],r=e.schema.nodes[t.listsTypes.bulletList],i=!!Ut(o,2)(e.selection),s=!!Ut(r,2)(e.selection);return(i||s)&&Ao(n)(e)},Ar=(e,t)=>{const n=e.schema.nodes,o=n[$o.listsTypes.listItem];return(Mr(e,t.nodes)||$o.nodes.some((t=>n[t.node]&&co(e,n[t.node]))))&&!co(e,o)},Tr=(e,t)=>{const n=e.schema.nodes[$o.listsTypes.listItem],o=Ar(e,$o);Nr(e,n)?To(n)(e,t):o&&Cr($o.nodes)(e,t)},Dr=(e,t)=>{const n=e.schema.nodes,o=n[Io.listsTypes.listItem],r=Ar(e,Io);co(e,n.blockquote)?Sr(e,t):Or(e,Io)?Ao(o)(e,t):r&&Cr(Io.nodes)(e,t)},Er=(e,t,n)=>{let o=t.depth;const r=e.nodes[n.bulletList],i=e.nodes[n.orderedList],s=e.nodes[n.listItem];for(let e=t.depth;e>0;e--){const n=t.node(e);if(n.type!==r&&n.type!==i||(o=e),n.type!==r&&n.type!==i&&n.type!==s)break}return o-1};function Rr(e,t,n,o){const r=o||e.schema.nodes.listItem,{$from:i,$to:l}=t;let a=i.blockRange(l,(e=>e.childCount&&e.firstChild.type===r));if(!a||a.depth<2||i.node(a.depth-1).type!==r)return n;const c=a.end,d=l.end(a.depth);return c<d&&(n.step(new Ne(c-1,d,c,d,new p(s.from(r.create(void 0,a.parent.copy())),1,0),1,!0)),a=new A(n.doc.resolve(i.pos),n.doc.resolve(d),a.depth)),n.lift(a,De(a)).scrollIntoView()}function $r(e){return function(t,n){const{tr:o}=t,{$from:r,$to:i}=t.selection;return o.doc.nodesBetween(r.pos,i.pos,((n,r)=>{if(n.isTextblock||"blockquote"===n.type.name||"div"===n.type.name){const n=new at(o.doc.resolve(o.mapping.map(r))),i=n.$from.blockRange(n.$to);if(!i||n.$from.parent.type!==t.schema.nodes[e.listItem])return;const s=i&&De(i);if(null==s)return!1;o.lift(i,s)}})),n&&n(o),!0}}const Ir=/list-style-type:\s?([\w-]+)/,zr=e=>{const t=e.style||"",n=Ir.exec(t);return n&&n[1]||""},Br=(e,t,n,o,r)=>{const{listType:i,listAttrs:s={style:null}}=o,{selection:l}=e,a=l.$from.node(l.$from.depth-2),c=l.$to.node(l.$to.depth-2);if(a&&a.type.name===i&&zr(a.attrs)===zr(s)&&c&&c.type.name===i&&zr(c.attrs)===zr(s)){const i=n.state.schema.nodes,s={bulletList:i[o.bulletList],orderedList:i[o.orderedList],listItem:i[o.listItem]},a=((e,t)=>{const{bulletList:n,orderedList:o,listItem:r}=t;let i;for(let t=e.depth-1;t>0;t--){const s=e.node(t);if(s.type!==n&&s.type!==o||(i=t),s.type!==n&&s.type!==o&&s.type!==r)break}return i})(l.$to,s);let c=function(e,t,n,o,r,i){i||(i=e.schema.nodes.listItem);let s=!1;return r.doc.nodesBetween(t,n,((n,l)=>{if(!s&&n.type===i&&l>t){s=!0;let t=o+3;for(;t>o+2;){const o=r.doc.resolve(r.mapping.map(l));t=o.depth;const s=r.doc.resolve(r.mapping.map(l+n.textContent.length)),a=new st(o,s);r=Rr(e,a,r,i)}}})),r}(e,l.$to.pos,l.$to.end(a),a,n.state.tr,s.listItem);return c=function(e,t,n){const{from:o,to:r}=e.selection,{paragraph:i,heading:s}=e.schema.nodes,l=[];t.doc.nodesBetween(o,r,((e,t)=>{e.type!==i&&e.type!==s||l.push({node:e,pos:t})}));for(let o=l.length-1;o>=0;o--){const r=l[o],i=t.doc.resolve(t.mapping.map(r.pos));if(i.depth>0){let o;o=r.node.textContent&&r.node.textContent.length>0?t.doc.resolve(t.mapping.map(r.pos+r.node.textContent.length)):t.doc.resolve(t.mapping.map(r.pos+1));const s=i.blockRange(o);s&&t.lift(s,Er(e.schema,i,n))}}return t}(e,c,o),c.setMeta("commandName",r),t(c),!0}return function(e){return function(t,n,o){if(!o)return!1;const r=(t=o.state).schema.nodes[e.listType],{$from:i,$to:s}=t.selection,l=i.node(-2),a=i.node(-3),c=function(e,t,n,o){return 0===function(e,t,n){const o=[],r=function(e,t){const n=["blockquote","bulletList","orderedList"];if(1===t.depth)return t;let o=t.node(t.depth),r=t;for(;t.depth>=1;)o=(t=e.resolve(t.before(t.depth))).node(t.depth),o&&-1!==n.indexOf(o.type.name)&&(r=t);return r}(e,t).depth;let i=e.resolve(t.start(r));for(;i.pos<=n.start(n.depth);){const t=Math.min(i.depth,r),n=i.node(t);if(n&&o.push(n),0===t)break;let s=e.resolve(i.after(t));if(s.start(t)>=e.nodeSize-2)break;s.depth!==i.depth&&(s=e.resolve(s.pos+2)),i=s.depth?e.resolve(s.start(s.depth)):e.resolve(s.end(s.depth))}return o}(e,t,n).filter((e=>e.type!==o)).length}(t.doc,i,s,r);return(l&&l.type===r||a&&a.type===r)&&c?$r(e)(t,n):(c||($r(e)(t,n),t=o.state),function(e,t={}){return mr(Co(e,t),((t,n)=>t.type===n.type&&t.type===e))}(r,e.listAttrs)(t,n))}}(o)(e,t,n)};function Pr(e,t,n){return Br(e,t,n,{listType:Ro.listType,...Ro.types})}function Vr(e,t,n){return Br(e,t,n,{listType:Eo.listType,...Eo.types})}const Fr=(e,t)=>({name:e,value:t}),Lr=[{node:"paragraph",style:[Fr("text-align","left")]},{node:"heading",style:[Fr("text-align","left")]},{node:"table_caption_external",style:[Fr("text-align","left")]}],Hr=[{node:"paragraph",style:[Fr("text-align","right")]},{node:"heading",style:[Fr("text-align","right")]},{node:"table_caption_external",style:[Fr("text-align","right")]}],_r=[{node:"paragraph",style:[Fr("text-align","center")]},{node:"heading",style:[Fr("text-align","center")]},{node:"table_caption_external",style:[Fr("text-align","center")]}],Wr=[{node:"paragraph",style:[Fr("text-align","justify")]},{node:"heading",style:[Fr("text-align","justify")]},{node:"table_caption_external",style:[Fr("text-align","justify")]}],qr=[{node:"paragraph",style:[Fr("text-align","")]},{node:"heading",style:[Fr("text-align","")]},{node:"table_caption_external",style:[Fr("text-align","")]}],jr=function(e){for(var t=0;;t++)if(!(e=e.previousSibling))return t},Jr=function(e){let t=e.assignedSlot||e.parentNode;return t&&11==t.nodeType?t.host:t};let Kr=null;const Xr=function(e,t,n){let o=Kr||(Kr=document.createRange());return o.setEnd(e,null==n?e.nodeValue.length:n),o.setStart(e,t||0),o},Ur=function(e,t,n,o){return n&&(Yr(e,t,n,o,-1)||Yr(e,t,n,o,1))},Gr=/^(img|br|input|textarea|hr)$/i;function Yr(e,t,n,o,r){for(var i;;){if(e==n&&t==o)return!0;if(t==(r<0?0:Qr(e))){let n=e.parentNode;if(!n||1!=n.nodeType||Zr(e)||Gr.test(e.nodeName)||"false"==e.contentEditable)return!1;t=jr(e)+(r<0?0:1),e=n}else{if(1!=e.nodeType)return!1;{let n=e.childNodes[t+(r<0?-1:0)];if(1==n.nodeType&&"false"==n.contentEditable){if(!(null===(i=n.pmViewDesc)||void 0===i?void 0:i.ignoreForSelection))return!1;t+=r}else e=n,t=r<0?Qr(e):0}}}}function Qr(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function Zr(e){let t;for(let n=e;n&&!(t=n.pmViewDesc);n=n.parentNode);return t&&t.node&&t.node.isBlock&&(t.dom==e||t.contentDOM==e)}const ei=function(e){return e.focusNode&&Ur(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)};function ti(e,t){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=e,n.key=n.code=t,n}const ni="undefined"!=typeof navigator?navigator:null,oi="undefined"!=typeof document?document:null,ri=ni&&ni.userAgent||"",ii=/Edge\/(\d+)/.exec(ri),si=/MSIE \d/.exec(ri),li=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(ri),ai=!!(si||li||ii),ci=si?document.documentMode:li?+li[1]:ii?+ii[1]:0,di=!ai&&/gecko\/(\d+)/i.test(ri);di&&(/Firefox\/(\d+)/.exec(ri)||[0,0])[1];const hi=!ai&&/Chrome\/(\d+)/.exec(ri),pi=!!hi,ui=hi?+hi[1]:0,fi=!ai&&!!ni&&/Apple Computer/.test(ni.vendor),mi=fi&&(/Mobile\/\w+/.test(ri)||!!ni&&ni.maxTouchPoints>2),gi=mi||!!ni&&/Mac/.test(ni.platform),yi=!!ni&&/Win/.test(ni.platform),wi=/Android \d/.test(ri),vi=!!oi&&"webkitFontSmoothing"in oi.documentElement.style,bi=vi?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function ki(e){let t=e.defaultView&&e.defaultView.visualViewport;return t?{left:0,right:t.width,top:0,bottom:t.height}:{left:0,right:e.documentElement.clientWidth,top:0,bottom:e.documentElement.clientHeight}}function xi(e,t){return"number"==typeof e?e:e[t]}function Si(e){let t=e.getBoundingClientRect(),n=t.width/e.offsetWidth||1,o=t.height/e.offsetHeight||1;return{left:t.left,right:t.left+e.clientWidth*n,top:t.top,bottom:t.top+e.clientHeight*o}}function Ci(e,t,n){let o=e.someProp("scrollThreshold")||0,r=e.someProp("scrollMargin")||5,i=e.dom.ownerDocument;for(let s=n||e.dom;s;){if(1!=s.nodeType){s=Jr(s);continue}let e=s,n=e==i.body,l=n?ki(i):Si(e),a=0,c=0;if(t.top<l.top+xi(o,"top")?c=-(l.top-t.top+xi(r,"top")):t.bottom>l.bottom-xi(o,"bottom")&&(c=t.bottom-t.top>l.bottom-l.top?t.top+xi(r,"top")-l.top:t.bottom-l.bottom+xi(r,"bottom")),t.left<l.left+xi(o,"left")?a=-(l.left-t.left+xi(r,"left")):t.right>l.right-xi(o,"right")&&(a=t.right-l.right+xi(r,"right")),a||c)if(n)i.defaultView.scrollBy(a,c);else{let n=e.scrollLeft,o=e.scrollTop;c&&(e.scrollTop+=c),a&&(e.scrollLeft+=a);let r=e.scrollLeft-n,i=e.scrollTop-o;t={left:t.left-r,top:t.top-i,right:t.right-r,bottom:t.bottom-i}}let d=n?"fixed":getComputedStyle(s).position;if(/^(fixed|sticky)$/.test(d))break;s="absolute"==d?s.offsetParent:Jr(s)}}function Mi(e){let t=[],n=e.ownerDocument;for(let o=e;o&&(t.push({dom:o,top:o.scrollTop,left:o.scrollLeft}),e!=n);o=Jr(o));return t}function Ni(e,t){for(let n=0;n<e.length;n++){let{dom:o,top:r,left:i}=e[n];o.scrollTop!=r+t&&(o.scrollTop=r+t),o.scrollLeft!=i&&(o.scrollLeft=i)}}let Oi=null;function Ai(e,t){let n,o,r,i,s=2e8,l=0,a=t.top,c=t.top;for(let d=e.firstChild,h=0;d;d=d.nextSibling,h++){let e;if(1==d.nodeType)e=d.getClientRects();else{if(3!=d.nodeType)continue;e=Xr(d).getClientRects()}for(let p=0;p<e.length;p++){let u=e[p];if(u.top<=a&&u.bottom>=c){a=Math.max(u.bottom,a),c=Math.min(u.top,c);let e=u.left>t.left?u.left-t.left:u.right<t.left?t.left-u.right:0;if(e<s){n=d,s=e,o=e&&3==n.nodeType?{left:u.right<t.left?u.right:u.left,top:t.top}:t,1==d.nodeType&&e&&(l=h+(t.left>=(u.left+u.right)/2?1:0));continue}}else u.top>t.top&&!r&&u.left<=t.left&&u.right>=t.left&&(r=d,i={left:Math.max(u.left,Math.min(u.right,t.left)),top:u.top});!n&&(t.left>=u.right&&t.top>=u.top||t.left>=u.left&&t.top>=u.bottom)&&(l=h+1)}}return!n&&r&&(n=r,o=i,s=0),n&&3==n.nodeType?function(e,t){let n=e.nodeValue.length,o=document.createRange();for(let r=0;r<n;r++){o.setEnd(e,r+1),o.setStart(e,r);let n=$i(o,1);if(n.top!=n.bottom&&Ti(t,n))return{node:e,offset:r+(t.left>=(n.left+n.right)/2?1:0)}}return{node:e,offset:0}}(n,o):!n||s&&1==n.nodeType?{node:e,offset:l}:Ai(n,o)}function Ti(e,t){return e.left>=t.left-1&&e.left<=t.right+1&&e.top>=t.top-1&&e.top<=t.bottom+1}function Di(e,t,n){let o=e.childNodes.length;if(o&&n.top<n.bottom)for(let r=Math.max(0,Math.min(o-1,Math.floor(o*(t.top-n.top)/(n.bottom-n.top))-2)),i=r;;){let n=e.childNodes[i];if(1==n.nodeType){let e=n.getClientRects();for(let o=0;o<e.length;o++){let r=e[o];if(Ti(t,r))return Di(n,t,r)}}if((i=(i+1)%o)==r)break}return e}function Ei(e,t){let n,o=e.dom.ownerDocument,r=0,i=function(e,t,n){if(e.caretPositionFromPoint)try{let o=e.caretPositionFromPoint(t,n);if(o)return{node:o.offsetNode,offset:Math.min(Qr(o.offsetNode),o.offset)}}catch(e){}if(e.caretRangeFromPoint){let o=e.caretRangeFromPoint(t,n);if(o)return{node:o.startContainer,offset:Math.min(Qr(o.startContainer),o.startOffset)}}}(o,t.left,t.top);i&&({node:n,offset:r}=i);let s,l=(e.root.elementFromPoint?e.root:o).elementFromPoint(t.left,t.top);if(!l||!e.dom.contains(1!=l.nodeType?l.parentNode:l)){let n=e.dom.getBoundingClientRect();if(!Ti(t,n))return null;if(l=Di(e.dom,t,n),!l)return null}if(fi)for(let e=l;n&&e;e=Jr(e))e.draggable&&(n=void 0);if(l=function(e,t){let n=e.parentNode;return n&&/^li$/i.test(n.nodeName)&&t.left<e.getBoundingClientRect().left?n:e}(l,t),n){if(di&&1==n.nodeType&&(r=Math.min(r,n.childNodes.length),r<n.childNodes.length)){let e,o=n.childNodes[r];"IMG"==o.nodeName&&(e=o.getBoundingClientRect()).right<=t.left&&e.bottom>t.top&&r++}let o;vi&&r&&1==n.nodeType&&1==(o=n.childNodes[r-1]).nodeType&&"false"==o.contentEditable&&o.getBoundingClientRect().top>=t.top&&r--,n==e.dom&&r==n.childNodes.length-1&&1==n.lastChild.nodeType&&t.top>n.lastChild.getBoundingClientRect().bottom?s=e.state.doc.content.size:0!=r&&1==n.nodeType&&"BR"==n.childNodes[r-1].nodeName||(s=function(e,t,n,o){let r=-1;for(let n=t,i=!1;n!=e.dom;){let t,s=e.docView.nearestDesc(n,!0);if(!s)return null;if(1==s.dom.nodeType&&(s.node.isBlock&&s.parent||!s.contentDOM)&&((t=s.dom.getBoundingClientRect()).width||t.height)&&(s.node.isBlock&&s.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(s.dom.nodeName)&&(!i&&t.left>o.left||t.top>o.top?r=s.posBefore:(!i&&t.right<o.left||t.bottom<o.top)&&(r=s.posAfter),i=!0),!s.contentDOM&&r<0&&!s.node.isText))return(s.node.isBlock?o.top<(t.top+t.bottom)/2:o.left<(t.left+t.right)/2)?s.posBefore:s.posAfter;n=s.dom.parentNode}return r>-1?r:e.docView.posFromDOM(t,n,-1)}(e,n,r,t))}null==s&&(s=function(e,t,n){let{node:o,offset:r}=Ai(t,n),i=-1;if(1==o.nodeType&&!o.firstChild){let e=o.getBoundingClientRect();i=e.left!=e.right&&n.left>(e.left+e.right)/2?1:-1}return e.docView.posFromDOM(o,r,i)}(e,l,t));let a=e.docView.nearestDesc(l,!0);return{pos:s,inside:a?a.posAtStart-a.border:-1}}function Ri(e){return e.top<e.bottom||e.left<e.right}function $i(e,t){let n=e.getClientRects();if(n.length){let e=n[t<0?0:n.length-1];if(Ri(e))return e}return Array.prototype.find.call(n,Ri)||e.getBoundingClientRect()}const Ii=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function zi(e,t,n){let{node:o,offset:r,atom:i}=e.docView.domFromPos(t,n<0?-1:1),s=vi||di;if(3==o.nodeType){if(!s||!Ii.test(o.nodeValue)&&(n<0?r:r!=o.nodeValue.length)){let e=r,t=r,i=n<0?1:-1;return n<0&&!r?(t++,i=-1):n>=0&&r==o.nodeValue.length?(e--,i=1):n<0?e--:t++,Bi($i(Xr(o,e,t),i),i<0)}{let e=$i(Xr(o,r,r),n);if(di&&r&&/\s/.test(o.nodeValue[r-1])&&r<o.nodeValue.length){let t=$i(Xr(o,r-1,r-1),-1);if(t.top==e.top){let n=$i(Xr(o,r,r+1),-1);if(n.top!=e.top)return Bi(n,n.left<t.left)}}return e}}if(!e.state.doc.resolve(t-(i||0)).parent.inlineContent){if(null==i&&r&&(n<0||r==Qr(o))){let e=o.childNodes[r-1];if(1==e.nodeType)return Pi(e.getBoundingClientRect(),!1)}if(null==i&&r<Qr(o)){let e=o.childNodes[r];if(1==e.nodeType)return Pi(e.getBoundingClientRect(),!0)}return Pi(o.getBoundingClientRect(),n>=0)}if(null==i&&r&&(n<0||r==Qr(o))){let e=o.childNodes[r-1],t=3==e.nodeType?Xr(e,Qr(e)-(s?0:1)):1!=e.nodeType||"BR"==e.nodeName&&e.nextSibling?null:e;if(t)return Bi($i(t,1),!1)}if(null==i&&r<Qr(o)){let e=o.childNodes[r];for(;e.pmViewDesc&&e.pmViewDesc.ignoreForCoords;)e=e.nextSibling;let t=e?3==e.nodeType?Xr(e,0,s?0:1):1==e.nodeType?e:null:null;if(t)return Bi($i(t,-1),!0)}return Bi($i(3==o.nodeType?Xr(o):o,-n),n>=0)}function Bi(e,t){if(0==e.width)return e;let n=t?e.left:e.right;return{top:e.top,bottom:e.bottom,left:n,right:n}}function Pi(e,t){if(0==e.height)return e;let n=t?e.top:e.bottom;return{top:n,bottom:n,left:e.left,right:e.right}}function Vi(e,t,n){let o=e.state,r=e.root.activeElement;o!=t&&e.updateState(t),r!=e.dom&&e.focus();try{return n()}finally{o!=t&&e.updateState(o),r!=e.dom&&r&&r.focus()}}const Fi=/[\u0590-\u08ac]/;let Li=null,Hi=null,_i=!1;class Wi{constructor(e,t,n,o){this.parent=e,this.children=t,this.dom=n,this.contentDOM=o,this.dirty=0,n.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,n){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;t<this.children.length;t++)e+=this.children[t].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let t=0,n=this.posAtStart;;t++){let o=this.children[t];if(o==e)return n;n+=o.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,t,n){if(this.contentDOM&&this.contentDOM.contains(1==e.nodeType?e:e.parentNode)){if(n<0){let n,o;if(e==this.contentDOM)n=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;n=e.previousSibling}for(;n&&(!(o=n.pmViewDesc)||o.parent!=this);)n=n.previousSibling;return n?this.posBeforeChild(o)+o.size:this.posAtStart}{let n,o;if(e==this.contentDOM)n=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;n=e.nextSibling}for(;n&&(!(o=n.pmViewDesc)||o.parent!=this);)n=n.nextSibling;return n?this.posBeforeChild(o):this.posAtEnd}}let o;if(e==this.dom&&this.contentDOM)o=t>jr(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))o=2&e.compareDocumentPosition(this.contentDOM);else if(this.dom.firstChild){if(0==t)for(let t=e;;t=t.parentNode){if(t==this.dom){o=!1;break}if(t.previousSibling)break}if(null==o&&t==e.childNodes.length)for(let t=e;;t=t.parentNode){if(t==this.dom){o=!0;break}if(t.nextSibling)break}}return(null==o?n>0:o)?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let n=!0,o=e;o;o=o.parentNode){let r,i=this.getDesc(o);if(i&&(!t||i.node)){if(!n||!(r=i.nodeDOM)||(1==r.nodeType?r.contains(1==e.nodeType?e:e.parentNode):r==e))return i;n=!1}}}getDesc(e){let t=e.pmViewDesc;for(let e=t;e;e=e.parent)if(e==this)return t}posFromDOM(e,t,n){for(let o=e;o;o=o.parentNode){let r=this.getDesc(o);if(r)return r.localPosFromDOM(e,t,n)}return-1}descAt(e){for(let t=0,n=0;t<this.children.length;t++){let o=this.children[t],r=n+o.size;if(n==e&&r!=n){for(;!o.border&&o.children.length;)for(let e=0;e<o.children.length;e++){let t=o.children[e];if(t.size){o=t;break}}return o}if(e<r)return o.descAt(e-n-o.border);n=r}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let n=0,o=0;for(let t=0;n<this.children.length;n++){let r=this.children[n],i=t+r.size;if(i>e||r instanceof Gi){o=e-t;break}t=i}if(o)return this.children[n].domFromPos(o-this.children[n].border,t);for(let e;n&&!(e=this.children[n-1]).size&&e instanceof qi&&e.side>=0;n--);if(t<=0){let e,o=!0;for(;e=n?this.children[n-1]:null,e&&e.dom.parentNode!=this.contentDOM;n--,o=!1);return e&&t&&o&&!e.border&&!e.domAtom?e.domFromPos(e.size,t):{node:this.contentDOM,offset:e?jr(e.dom)+1:0}}{let e,o=!0;for(;e=n<this.children.length?this.children[n]:null,e&&e.dom.parentNode!=this.contentDOM;n++,o=!1);return e&&o&&!e.border&&!e.domAtom?e.domFromPos(0,t):{node:this.contentDOM,offset:e?jr(e.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,n=0){if(0==this.children.length)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let o=-1,r=-1;for(let i=n,s=0;;s++){let n=this.children[s],l=i+n.size;if(-1==o&&e<=l){let r=i+n.border;if(e>=r&&t<=l-n.border&&n.node&&n.contentDOM&&this.contentDOM.contains(n.contentDOM))return n.parseRange(e,t,r);e=i;for(let t=s;t>0;t--){let n=this.children[t-1];if(n.size&&n.dom.parentNode==this.contentDOM&&!n.emptyChildAt(1)){o=jr(n.dom)+1;break}e-=n.size}-1==o&&(o=0)}if(o>-1&&(l>t||s==this.children.length-1)){t=l;for(let e=s+1;e<this.children.length;e++){let n=this.children[e];if(n.size&&n.dom.parentNode==this.contentDOM&&!n.emptyChildAt(-1)){r=jr(n.dom);break}t+=n.size}-1==r&&(r=this.contentDOM.childNodes.length);break}i=l}return{node:this.contentDOM,from:e,to:t,fromOffset:o,toOffset:r}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let t=this.children[e<0?0:this.children.length-1];return 0==t.size||t.emptyChildAt(e)}domAfterPos(e){let{node:t,offset:n}=this.domFromPos(e,0);if(1!=t.nodeType||n==t.childNodes.length)throw new RangeError("No node after pos "+e);return t.childNodes[n]}setSelection(e,t,n,o=!1){let r=Math.min(e,t),i=Math.max(e,t);for(let s=0,l=0;s<this.children.length;s++){let a=this.children[s],c=l+a.size;if(r>l&&i<c)return a.setSelection(e-l-a.border,t-l-a.border,n,o);l=c}let s=this.domFromPos(e,e?-1:1),l=t==e?s:this.domFromPos(t,t?-1:1),a=n.root.getSelection(),c=n.domSelectionRange(),d=!1;if((di||fi)&&e==t){let{node:e,offset:t}=s;if(3==e.nodeType){if(d=!(!t||"\n"!=e.nodeValue[t-1]),d&&t==e.nodeValue.length)for(let t,n=e;n;n=n.parentNode){if(t=n.nextSibling){"BR"==t.nodeName&&(s=l={node:t.parentNode,offset:jr(t)+1});break}let e=n.pmViewDesc;if(e&&e.node&&e.node.isBlock)break}}else{let n=e.childNodes[t-1];d=n&&("BR"==n.nodeName||"false"==n.contentEditable)}}if(di&&c.focusNode&&c.focusNode!=l.node&&1==c.focusNode.nodeType){let e=c.focusNode.childNodes[c.focusOffset];e&&"false"==e.contentEditable&&(o=!0)}if(!(o||d&&fi)&&Ur(s.node,s.offset,c.anchorNode,c.anchorOffset)&&Ur(l.node,l.offset,c.focusNode,c.focusOffset))return;let h=!1;if((a.extend||e==t)&&(!d||!di)){a.collapse(s.node,s.offset);try{e!=t&&a.extend(l.node,l.offset),h=!0}catch(e){}}if(!h){if(e>t){let e=s;s=l,l=e}let n=document.createRange();n.setEnd(l.node,l.offset),n.setStart(s.node,s.offset),a.removeAllRanges(),a.addRange(n)}}ignoreMutation(e){return!this.contentDOM&&"selection"!=e.type}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let n=0,o=0;o<this.children.length;o++){let r=this.children[o],i=n+r.size;if(n==i?e<=i&&t>=n:e<i&&t>n){let o=n+r.border,s=i-r.border;if(e>=o&&t<=s)return this.dirty=e==n||t==i?2:1,void(e!=o||t!=s||!r.contentLost&&r.dom.parentNode==this.contentDOM?r.markDirty(e-o,t-o):r.dirty=3);r.dirty=r.dom!=r.contentDOM||r.dom.parentNode!=this.contentDOM||r.children.length?3:2}n=i}this.dirty=2}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let n=1==e?2:1;t.dirty<n&&(t.dirty=n)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class qi extends Wi{constructor(e,t,n,o){let r,i=t.type.toDOM;if("function"==typeof i&&(i=i(n,(()=>r?r.parent?r.parent.posBeforeChild(r):void 0:o))),!t.type.spec.raw){if(1!=i.nodeType){let e=document.createElement("span");e.appendChild(i),i=e}i.contentEditable="false",i.classList.add("ProseMirror-widget")}super(e,[],i,null),this.widget=t,this.widget=t,r=this}matchesWidget(e){return 0==this.dirty&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return!!t&&t(e)}ignoreMutation(e){return"selection"!=e.type||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}}class ji extends Wi{constructor(e,t,n,o){super(e,[],t,null),this.textDOM=n,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"characterData"===e.type&&e.target.nodeValue==e.oldValue}}class Ji extends Wi{constructor(e,t,n,o,r){super(e,[],n,o),this.mark=t,this.spec=r}static create(e,t,n,o){let r=o.nodeViews[t.type.name],i=r&&r(t,o,n);return i&&i.dom||(i=le.renderSpec(document,t.type.spec.toDOM(t,n),null,t.attrs)),new Ji(e,t,i.dom,i.contentDOM||i.dom,i)}parseRule(){return 3&this.dirty||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return 3!=this.dirty&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),0!=this.dirty){let e=this.parent;for(;!e.node;)e=e.parent;e.dirty<this.dirty&&(e.dirty=this.dirty),this.dirty=0}}slice(e,t,n){let o=Ji.create(this.parent,this.mark,!0,n),r=this.children,i=this.size;t<i&&(r=ds(r,t,i,n)),e>0&&(r=ds(r,0,e,n));for(let e=0;e<r.length;e++)r[e].parent=o;return o.children=r,o}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class Ki extends Wi{constructor(e,t,n,o,r,i,s,l,a){super(e,[],r,i),this.node=t,this.outerDeco=n,this.innerDeco=o,this.nodeDOM=s}static create(e,t,n,o,r,i){let s,l=r.nodeViews[t.type.name],a=l&&l(t,r,(()=>s?s.parent?s.parent.posBeforeChild(s):void 0:i),n,o),c=a&&a.dom,d=a&&a.contentDOM;if(t.isText)if(c){if(3!=c.nodeType)throw new RangeError("Text must be rendered as a DOM text node")}else c=document.createTextNode(t.text);else if(!c){let e=le.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs);({dom:c,contentDOM:d}=e)}d||t.isText||"BR"==c.nodeName||(c.hasAttribute("contenteditable")||(c.contentEditable="false"),t.type.spec.draggable&&(c.draggable=!0));let h=c;return c=is(c,n,t),a?s=new Yi(e,t,n,o,c,d||null,h,a,r,i+1):t.isText?new Ui(e,t,n,o,c,h,r):new Ki(e,t,n,o,c,d||null,h,r,i+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if("pre"==this.node.type.whitespace&&(e.preserveWhitespace="full"),this.contentDOM)if(this.contentLost){for(let t=this.children.length-1;t>=0;t--){let n=this.children[t];if(this.dom.contains(n.dom.parentNode)){e.contentElement=n.dom.parentNode;break}}e.contentElement||(e.getContent=()=>s.empty)}else e.contentElement=this.contentDOM;else e.getContent=()=>this.node.content;return e}matchesNode(e,t,n){return 0==this.dirty&&e.eq(this.node)&&ss(t,this.outerDeco)&&n.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let n=this.node.inlineContent,o=t,r=e.composing?this.localCompositionInfo(e,t):null,i=r&&r.pos>-1?r:null,s=r&&r.pos<0,l=new as(this,i&&i.node,e);!function(e,t,n,o){let r=t.locals(e),i=0;if(0==r.length){for(let n=0;n<e.childCount;n++){let s=e.child(n);o(s,r,t.forChild(i,s),n),i+=s.nodeSize}return}let s=0,l=[],a=null;for(let c=0;;){let d,h,p,u;for(;s<r.length&&r[s].to==i;){let e=r[s++];e.widget&&(d?(h||(h=[d])).push(e):d=e)}if(d)if(h){h.sort(cs);for(let e=0;e<h.length;e++)n(h[e],c,!!a)}else n(d,c,!!a);if(a)u=-1,p=a,a=null;else{if(!(c<e.childCount))break;u=c,p=e.child(c++)}for(let e=0;e<l.length;e++)l[e].to<=i&&l.splice(e--,1);for(;s<r.length&&r[s].from<=i&&r[s].to>i;)l.push(r[s++]);let f=i+p.nodeSize;if(p.isText){let e=f;s<r.length&&r[s].from<e&&(e=r[s].from);for(let t=0;t<l.length;t++)l[t].to<e&&(e=l[t].to);e<f&&(a=p.cut(e-i),p=p.cut(0,e-i),f=e,u=-1)}else for(;s<r.length&&r[s].to<f;)s++;o(p,p.isInline&&!p.isLeaf?l.filter((e=>!e.inline)):l.slice(),t.forChild(i,p),u),i=f}}(this.node,this.innerDeco,((t,r,i)=>{t.spec.marks?l.syncToMarks(t.spec.marks,n,e):t.type.side>=0&&!i&&l.syncToMarks(r==this.node.childCount?d.none:this.node.child(r).marks,n,e),l.placeWidget(t,e,o)}),((t,i,a,c)=>{let d;l.syncToMarks(t.marks,n,e),l.findNodeMatch(t,i,a,c)||s&&e.state.selection.from>o&&e.state.selection.to<o+t.nodeSize&&(d=l.findIndexWithChild(r.node))>-1&&l.updateNodeAt(t,i,a,d,e)||l.updateNextNode(t,i,a,e,c,o)||l.addNode(t,i,a,e,o),o+=t.nodeSize})),l.syncToMarks([],n,e),this.node.isTextblock&&l.addTextblockHacks(),l.destroyRest(),(l.changed||2==this.dirty)&&(i&&this.protectLocalComposition(e,i),Qi(this.contentDOM,this.children,e),mi&&function(e){if("UL"==e.nodeName||"OL"==e.nodeName){let t=e.style.cssText;e.style.cssText=t+"; list-style: square !important",window.getComputedStyle(e).listStyle,e.style.cssText=t}}(this.dom))}localCompositionInfo(e,t){let{from:n,to:o}=e.state.selection;if(!(e.state.selection instanceof st)||n<t||o>t+this.node.content.size)return null;let r=e.input.compositionNode;if(!r||!this.dom.contains(r.parentNode))return null;if(this.node.inlineContent){let e=r.nodeValue,i=function(e,t,n,o){for(let r=0,i=0;r<e.childCount&&i<=o;){let s=e.child(r++),l=i;if(i+=s.nodeSize,!s.isText)continue;let a=s.text;for(;r<e.childCount;){let t=e.child(r++);if(i+=t.nodeSize,!t.isText)break;a+=t.text}if(i>=n){if(i>=o&&a.slice(o-t.length-l,o-l)==t)return o-t.length;let e=l<o?a.lastIndexOf(t,o-l-1):-1;if(e>=0&&e+t.length+l>=n)return l+e;if(n==o&&a.length>=o+t.length-l&&a.slice(o-l,o-l+t.length)==t)return o}}return-1}(this.node.content,e,n-t,o-t);return i<0?null:{node:r,pos:i,text:e}}return{node:r,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:n,text:o}){if(this.getDesc(t))return;let r=t;for(;r.parentNode!=this.contentDOM;r=r.parentNode){for(;r.previousSibling;)r.parentNode.removeChild(r.previousSibling);for(;r.nextSibling;)r.parentNode.removeChild(r.nextSibling);r.pmViewDesc&&(r.pmViewDesc=void 0)}let i=new ji(this,r,t,o);e.input.compositionNodes.push(i),this.children=ds(this.children,n,n+o.length,e,i)}update(e,t,n,o){return!(3==this.dirty||!e.sameMarkup(this.node)||(this.updateInner(e,t,n,o),0))}updateInner(e,t,n,o){this.updateOuterDeco(t),this.node=e,this.innerDeco=n,this.contentDOM&&this.updateChildren(o,this.posAtStart),this.dirty=0}updateOuterDeco(e){if(ss(e,this.outerDeco))return;let t=1!=this.nodeDOM.nodeType,n=this.dom;this.dom=ns(this.dom,this.nodeDOM,ts(this.outerDeco,this.node,t),ts(e,this.node,t)),this.dom!=n&&(n.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){1==this.nodeDOM.nodeType&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),!this.contentDOM&&this.node.type.spec.draggable||(this.nodeDOM.draggable=!0))}deselectNode(){1==this.nodeDOM.nodeType&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),!this.contentDOM&&this.node.type.spec.draggable||this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function Xi(e,t,n,o,r){is(o,t,e);let i=new Ki(void 0,e,t,n,o,o,o,r,0);return i.contentDOM&&i.updateChildren(r,0),i}class Ui extends Ki{constructor(e,t,n,o,r,i,s){super(e,t,n,o,r,null,i,s,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,n,o){return!(3==this.dirty||0!=this.dirty&&!this.inParent()||!e.sameMarkup(this.node)||(this.updateOuterDeco(t),0==this.dirty&&e.text==this.node.text||e.text==this.nodeDOM.nodeValue||(this.nodeDOM.nodeValue=e.text,o.trackWrites==this.nodeDOM&&(o.trackWrites=null)),this.node=e,this.dirty=0,0))}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,n){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,n)}ignoreMutation(e){return"characterData"!=e.type&&"selection"!=e.type}slice(e,t,n){let o=this.node.cut(e,t),r=document.createTextNode(o.text);return new Ui(this.parent,o,this.outerDeco,this.innerDeco,r,r,n)}markDirty(e,t){super.markDirty(e,t),this.dom==this.nodeDOM||0!=e&&t!=this.nodeDOM.nodeValue.length||(this.dirty=3)}get domAtom(){return!1}isText(e){return this.node.text==e}}class Gi extends Wi{parseRule(){return{ignore:!0}}matchesHack(e){return 0==this.dirty&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return"IMG"==this.dom.nodeName}}class Yi extends Ki{constructor(e,t,n,o,r,i,s,l,a,c){super(e,t,n,o,r,i,s,a,c),this.spec=l}update(e,t,n,o){if(3==this.dirty)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let r=this.spec.update(e,t,n);return r&&this.updateInner(e,t,n,o),r}return!(!this.contentDOM&&!e.isLeaf)&&super.update(e,t,n,o)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,n,o){this.spec.setSelection?this.spec.setSelection(e,t,n.root):super.setSelection(e,t,n,o)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return!!this.spec.stopEvent&&this.spec.stopEvent(e)}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function Qi(e,t,n){let o=e.firstChild,r=!1;for(let i=0;i<t.length;i++){let s=t[i],l=s.dom;if(l.parentNode==e){for(;l!=o;)o=ls(o),r=!0;o=o.nextSibling}else r=!0,e.insertBefore(l,o);if(s instanceof Ji){let t=o?o.previousSibling:e.lastChild;Qi(s.contentDOM,s.children,n),o=t?t.nextSibling:e.firstChild}}for(;o;)o=ls(o),r=!0;r&&n.trackWrites==e&&(n.trackWrites=null)}const Zi=function(e){e&&(this.nodeName=e)};Zi.prototype=Object.create(null);const es=[new Zi];function ts(e,t,n){if(0==e.length)return es;let o=n?es[0]:new Zi,r=[o];for(let i=0;i<e.length;i++){let s=e[i].type.attrs;if(s){s.nodeName&&r.push(o=new Zi(s.nodeName));for(let e in s){let i=s[e];null!=i&&(n&&1==r.length&&r.push(o=new Zi(t.isInline?"span":"div")),"class"==e?o.class=(o.class?o.class+" ":"")+i:"style"==e?o.style=(o.style?o.style+";":"")+i:"nodeName"!=e&&(o[e]=i))}}}return r}function ns(e,t,n,o){if(n==es&&o==es)return t;let r=t;for(let t=0;t<o.length;t++){let i=o[t],s=n[t];if(t){let t;s&&s.nodeName==i.nodeName&&r!=e&&(t=r.parentNode)&&t.nodeName.toLowerCase()==i.nodeName||(t=document.createElement(i.nodeName),t.pmIsDeco=!0,t.appendChild(r),s=es[0]),r=t}rs(r,s||es[0],i)}return r}function rs(e,t,n){for(let o in t)"class"==o||"style"==o||"nodeName"==o||o in n||e.removeAttribute(o);for(let o in n)"class"!=o&&"style"!=o&&"nodeName"!=o&&n[o]!=t[o]&&e.setAttribute(o,n[o]);if(t.class!=n.class){let o=t.class?t.class.split(" ").filter(Boolean):[],r=n.class?n.class.split(" ").filter(Boolean):[];for(let t=0;t<o.length;t++)-1==r.indexOf(o[t])&&e.classList.remove(o[t]);for(let t=0;t<r.length;t++)-1==o.indexOf(r[t])&&e.classList.add(r[t]);0==e.classList.length&&e.removeAttribute("class")}if(t.style!=n.style){if(t.style){let n,o=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g;for(;n=o.exec(t.style);)e.style.removeProperty(n[1])}n.style&&(e.style.cssText+=n.style)}}function is(e,t,n){return ns(e,e,es,ts(t,n,1!=e.nodeType))}function ss(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].type.eq(t[n].type))return!1;return!0}function ls(e){let t=e.nextSibling;return e.parentNode.removeChild(e),t}class as{constructor(e,t,n){this.lock=t,this.view=n,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=function(e,t){let n=t,o=n.children.length,r=e.childCount,i=new Map,s=[];e:for(;r>0;){let l;for(;;)if(o){let e=n.children[o-1];if(!(e instanceof Ji)){l=e,o--;break}n=e,o=e.children.length}else{if(n==t)break e;o=n.parent.children.indexOf(n),n=n.parent}let a=l.node;if(a){if(a!=e.child(r-1))break;--r,i.set(l,r),s.push(l)}}return{index:r,matched:i,matches:s.reverse()}}(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let n=e;n<t;n++)this.top.children[n].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,n){let o=0,r=this.stack.length>>1,i=Math.min(r,e.length);for(;o<i&&(o==r-1?this.top:this.stack[o+1<<1]).matchesMark(e[o])&&!1!==e[o].type.spec.spanning;)o++;for(;o<r;)this.destroyRest(),this.top.dirty=0,this.index=this.stack.pop(),this.top=this.stack.pop(),r--;for(;r<e.length;){this.stack.push(this.top,this.index+1);let o=-1;for(let t=this.index;t<Math.min(this.index+3,this.top.children.length);t++){let n=this.top.children[t];if(n.matchesMark(e[r])&&!this.isLocked(n.dom)){o=t;break}}if(o>-1)o>this.index&&(this.changed=!0,this.destroyBetween(this.index,o)),this.top=this.top.children[this.index];else{let o=Ji.create(this.top,e[r],t,n);this.top.children.splice(this.index,0,o),this.top=o,this.changed=!0}this.index=0,r++}}findNodeMatch(e,t,n,o){let r,i=-1;if(o>=this.preMatch.index&&(r=this.preMatch.matches[o-this.preMatch.index]).parent==this.top&&r.matchesNode(e,t,n))i=this.top.children.indexOf(r,this.index);else for(let o=this.index,r=Math.min(this.top.children.length,o+5);o<r;o++){let r=this.top.children[o];if(r.matchesNode(e,t,n)&&!this.preMatch.matched.has(r)){i=o;break}}return!(i<0||(this.destroyBetween(this.index,i),this.index++,0))}updateNodeAt(e,t,n,o,r){let i=this.top.children[o];return 3==i.dirty&&i.dom==i.contentDOM&&(i.dirty=2),!!i.update(e,t,n,r)&&(this.destroyBetween(this.index,o),this.index++,!0)}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){let t=e.pmViewDesc;if(t)for(let e=this.index;e<this.top.children.length;e++)if(this.top.children[e]==t)return e;return-1}e=t}}updateNextNode(e,t,n,o,r,i){for(let s=this.index;s<this.top.children.length;s++){let l=this.top.children[s];if(l instanceof Ki){let a=this.preMatch.matched.get(l);if(null!=a&&a!=r)return!1;let c,d=l.dom,h=this.isLocked(d)&&!(e.isText&&l.node&&l.node.isText&&l.nodeDOM.nodeValue==e.text&&3!=l.dirty&&ss(t,l.outerDeco));if(!h&&l.update(e,t,n,o))return this.destroyBetween(this.index,s),l.dom!=d&&(this.changed=!0),this.index++,!0;if(!h&&(c=this.recreateWrapper(l,e,t,n,o,i)))return this.destroyBetween(this.index,s),this.top.children[this.index]=c,c.contentDOM&&(c.dirty=2,c.updateChildren(o,i+1),c.dirty=0),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,n,o,r,i){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!ss(n,e.outerDeco)||!o.eq(e.innerDeco))return null;let s=Ki.create(this.top,t,n,o,r,i);if(s.contentDOM){s.children=e.children,e.children=[];for(let e of s.children)e.parent=s}return e.destroy(),s}addNode(e,t,n,o,r){let i=Ki.create(this.top,e,t,n,o,r);i.contentDOM&&i.updateChildren(o,r+1),this.top.children.splice(this.index++,0,i),this.changed=!0}placeWidget(e,t,n){let o=this.index<this.top.children.length?this.top.children[this.index]:null;if(!o||!o.matchesWidget(e)||e!=o.widget&&o.widget.type.toDOM.parentNode){let o=new qi(this.top,e,t,n);this.top.children.splice(this.index++,0,o),this.changed=!0}else this.index++}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof Ji;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof Ui)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((fi||pi)&&e&&"false"==e.dom.contentEditable&&this.addHackNode("IMG",t),this.addHackNode("BR",this.top))}addHackNode(e,t){if(t==this.top&&this.index<t.children.length&&t.children[this.index].matchesHack(e))this.index++;else{let n=document.createElement(e);"IMG"==e&&(n.className="ProseMirror-separator",n.alt=""),"BR"==e&&(n.className="ProseMirror-trailingBreak");let o=new Gi(this.top,[],n,null);t!=this.top?t.children.push(o):t.children.splice(this.index++,0,o),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||1==e.nodeType&&e.contains(this.lock.parentNode))}}function cs(e,t){return e.type.side-t.type.side}function ds(e,t,n,o,r){let i=[];for(let s=0,l=0;s<e.length;s++){let a=e[s],c=l,d=l+=a.size;c>=n||d<=t?i.push(a):(c<t&&i.push(a.slice(0,t-c,o)),r&&(i.push(r),r=void 0),d>n&&i.push(a.slice(n-c,a.size,o)))}return i}function hs(e,t=null){let n=e.domSelectionRange(),o=e.state.doc;if(!n.focusNode)return null;let r=e.docView.nearestDesc(n.focusNode),i=r&&0==r.size,s=e.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(s<0)return null;let l,a,c=o.resolve(s);if(ei(n)){for(l=s;r&&!r.node;)r=r.parent;let e=r.node;if(r&&e.isAtom&&at.isSelectable(e)&&r.parent&&(!e.isInline||!function(e,t,n){for(let o=0==t,r=t==Qr(e);o||r;){if(e==n)return!0;let t=jr(e);if(!(e=e.parentNode))return!1;o=o&&0==t,r=r&&t==Qr(e)}}(n.focusNode,n.focusOffset,r.dom))){let e=r.posBefore;a=new at(s==e?c:o.resolve(e))}}else{if(n instanceof e.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let t=s,r=s;for(let o=0;o<n.rangeCount;o++){let i=n.getRangeAt(o);t=Math.min(t,e.docView.posFromDOM(i.startContainer,i.startOffset,1)),r=Math.max(r,e.docView.posFromDOM(i.endContainer,i.endOffset,-1))}if(t<0)return null;[l,s]=r==e.state.selection.anchor?[r,t]:[t,r],c=o.resolve(s)}else l=e.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(l<0)return null}let d=o.resolve(l);return a||(a=bs(e,d,c,"pointer"==t||e.state.selection.head<c.pos&&!i?1:-1)),a}function ps(e){return e.editable?e.hasFocus():xs(e)&&document.activeElement&&document.activeElement.contains(e.dom)}function us(e,t=!1){let n=e.state.selection;if(ws(e,n),ps(e)){if(!t&&e.input.mouseDown&&e.input.mouseDown.allowDefault&&pi){let t=e.domSelectionRange(),n=e.domObserver.currentSelection;if(t.anchorNode&&n.anchorNode&&Ur(t.anchorNode,t.anchorOffset,n.anchorNode,n.anchorOffset))return e.input.mouseDown.delayedSelectionSync=!0,void e.domObserver.setCurSelection()}if(e.domObserver.disconnectSelection(),e.cursorWrapper)!function(e){let t=e.domSelection();if(!t)return;let n=e.cursorWrapper.dom,o="IMG"==n.nodeName;o?t.collapse(n.parentNode,jr(n)+1):t.collapse(n,0),!o&&!e.state.selection.visible&&ai&&ci<=11&&(n.disabled=!0,n.disabled=!1)}(e);else{let o,r,{anchor:i,head:s}=n;!fs||n instanceof st||(n.$from.parent.inlineContent||(o=ms(e,n.from)),n.empty||n.$from.parent.inlineContent||(r=ms(e,n.to))),e.docView.setSelection(i,s,e,t),fs&&(o&&ys(o),r&&ys(r)),n.visible?e.dom.classList.remove("ProseMirror-hideselection"):(e.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&function(e){let t=e.dom.ownerDocument;t.removeEventListener("selectionchange",e.input.hideSelectionGuard);let n=e.domSelectionRange(),o=n.anchorNode,r=n.anchorOffset;t.addEventListener("selectionchange",e.input.hideSelectionGuard=()=>{n.anchorNode==o&&n.anchorOffset==r||(t.removeEventListener("selectionchange",e.input.hideSelectionGuard),setTimeout((()=>{ps(e)&&!e.state.selection.visible||e.dom.classList.remove("ProseMirror-hideselection")}),20))})}(e))}e.domObserver.setCurSelection(),e.domObserver.connectSelection()}}const fs=fi||pi&&ui<63;function ms(e,t){let{node:n,offset:o}=e.docView.domFromPos(t,0),r=o<n.childNodes.length?n.childNodes[o]:null,i=o?n.childNodes[o-1]:null;if(fi&&r&&"false"==r.contentEditable)return gs(r);if(!(r&&"false"!=r.contentEditable||i&&"false"!=i.contentEditable)){if(r)return gs(r);if(i)return gs(i)}}function gs(e){return e.contentEditable="true",fi&&e.draggable&&(e.draggable=!1,e.wasDraggable=!0),e}function ys(e){e.contentEditable="false",e.wasDraggable&&(e.draggable=!0,e.wasDraggable=null)}function ws(e,t){if(t instanceof at){let n=e.docView.descAt(t.from);n!=e.lastSelectedViewDesc&&(vs(e),n&&n.selectNode(),e.lastSelectedViewDesc=n)}else vs(e)}function vs(e){e.lastSelectedViewDesc&&(e.lastSelectedViewDesc.parent&&e.lastSelectedViewDesc.deselectNode(),e.lastSelectedViewDesc=void 0)}function bs(e,t,n,o){return e.someProp("createSelectionBetween",(o=>o(e,t,n)))||st.between(t,n,o)}function ks(e){return!(e.editable&&!e.hasFocus())&&xs(e)}function xs(e){let t=e.domSelectionRange();if(!t.anchorNode)return!1;try{return e.dom.contains(3==t.anchorNode.nodeType?t.anchorNode.parentNode:t.anchorNode)&&(e.editable||e.dom.contains(3==t.focusNode.nodeType?t.focusNode.parentNode:t.focusNode))}catch(e){return!1}}function Ss(e,t){let{$anchor:n,$head:o}=e.selection,r=t>0?n.max(o):n.min(o),i=r.parent.inlineContent?r.depth?e.doc.resolve(t>0?r.after():r.before()):null:r;return i&&nt.findFrom(i,t)}function Cs(e,t){return e.dispatch(e.state.tr.setSelection(t).scrollIntoView()),!0}function Ms(e,t,n){let o=e.state.selection;if(!(o instanceof st)){if(o instanceof at&&o.node.isInline)return Cs(e,new st(t>0?o.$to:o.$from));{let n=Ss(e.state,t);return!!n&&Cs(e,n)}}if(n.indexOf("s")>-1){let{$head:n}=o,r=n.textOffset?null:t<0?n.nodeBefore:n.nodeAfter;if(!r||r.isText||!r.isLeaf)return!1;let i=e.state.doc.resolve(n.pos+r.nodeSize*(t<0?-1:1));return Cs(e,new st(o.$anchor,i))}if(!o.empty)return!1;if(e.endOfTextblock(t>0?"forward":"backward")){let n=Ss(e.state,t);return!!(n&&n instanceof at)&&Cs(e,n)}if(!(gi&&n.indexOf("m")>-1)){let n,r=o.$head,i=r.textOffset?null:t<0?r.nodeBefore:r.nodeAfter;if(!i||i.isText)return!1;let s=t<0?r.pos-i.nodeSize:r.pos;return!!(i.isAtom||(n=e.docView.descAt(s))&&!n.contentDOM)&&(at.isSelectable(i)?Cs(e,new at(t<0?e.state.doc.resolve(r.pos-i.nodeSize):r)):!!vi&&Cs(e,new st(e.state.doc.resolve(t<0?s:s+i.nodeSize))))}}function Ns(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function Os(e,t){let n=e.pmViewDesc;return n&&0==n.size&&(t<0||e.nextSibling||"BR"!=e.nodeName)}function As(e,t){return t<0?function(e){let t=e.domSelectionRange(),n=t.focusNode,o=t.focusOffset;if(!n)return;let r,i,s=!1;for(di&&1==n.nodeType&&o<Ns(n)&&Os(n.childNodes[o],-1)&&(s=!0);;)if(o>0){if(1!=n.nodeType)break;{let e=n.childNodes[o-1];if(Os(e,-1))r=n,i=--o;else{if(3!=e.nodeType)break;n=e,o=n.nodeValue.length}}}else{if(Ts(n))break;{let t=n.previousSibling;for(;t&&Os(t,-1);)r=n.parentNode,i=jr(t),t=t.previousSibling;if(t)n=t,o=Ns(n);else{if(n=n.parentNode,n==e.dom)break;o=0}}}s?Ds(e,n,o):r&&Ds(e,r,i)}(e):function(e){let t=e.domSelectionRange(),n=t.focusNode,o=t.focusOffset;if(!n)return;let r,i,s=Ns(n);for(;;)if(o<s){if(1!=n.nodeType)break;if(!Os(n.childNodes[o],1))break;r=n,i=++o}else{if(Ts(n))break;{let t=n.nextSibling;for(;t&&Os(t,1);)r=t.parentNode,i=jr(t)+1,t=t.nextSibling;if(t)n=t,o=0,s=Ns(n);else{if(n=n.parentNode,n==e.dom)break;o=s=0}}}r&&Ds(e,r,i)}(e)}function Ts(e){let t=e.pmViewDesc;return t&&t.node&&t.node.isBlock}function Ds(e,t,n){if(3!=t.nodeType){let e,o;(o=function(e,t){for(;e&&t==e.childNodes.length&&!Zr(e);)t=jr(e)+1,e=e.parentNode;for(;e&&t<e.childNodes.length;){let n=e.childNodes[t];if(3==n.nodeType)return n;if(1==n.nodeType&&"false"==n.contentEditable)break;e=n,t=0}}(t,n))?(t=o,n=0):(e=function(e,t){for(;e&&!t&&!Zr(e);)t=jr(e),e=e.parentNode;for(;e&&t;){let n=e.childNodes[t-1];if(3==n.nodeType)return n;if(1==n.nodeType&&"false"==n.contentEditable)break;t=(e=n).childNodes.length}}(t,n))&&(t=e,n=e.nodeValue.length)}let o=e.domSelection();if(!o)return;if(ei(o)){let e=document.createRange();e.setEnd(t,n),e.setStart(t,n),o.removeAllRanges(),o.addRange(e)}else o.extend&&o.extend(t,n);e.domObserver.setCurSelection();let{state:r}=e;setTimeout((()=>{e.state==r&&us(e)}),50)}function Es(e,t){let n=e.state.doc.resolve(t);if(!pi&&!yi&&n.parent.inlineContent){let o=e.coordsAtPos(t);if(t>n.start()){let n=e.coordsAtPos(t-1),r=(n.top+n.bottom)/2;if(r>o.top&&r<o.bottom&&Math.abs(n.left-o.left)>1)return n.left<o.left?"ltr":"rtl"}if(t<n.end()){let n=e.coordsAtPos(t+1),r=(n.top+n.bottom)/2;if(r>o.top&&r<o.bottom&&Math.abs(n.left-o.left)>1)return n.left>o.left?"ltr":"rtl"}}return"rtl"==getComputedStyle(e.dom).direction?"rtl":"ltr"}function Rs(e,t,n){let o=e.state.selection;if(o instanceof st&&!o.empty||n.indexOf("s")>-1)return!1;if(gi&&n.indexOf("m")>-1)return!1;let{$from:r,$to:i}=o;if(!r.parent.inlineContent||e.endOfTextblock(t<0?"up":"down")){let n=Ss(e.state,t);if(n&&n instanceof at)return Cs(e,n)}if(!r.parent.inlineContent){let n=t<0?r:i,s=o instanceof dt?nt.near(n,t):nt.findFrom(n,t);return!!s&&Cs(e,s)}return!1}function $s(e,t){if(!(e.state.selection instanceof st))return!0;let{$head:n,$anchor:o,empty:r}=e.state.selection;if(!n.sameParent(o))return!0;if(!r)return!1;if(e.endOfTextblock(t>0?"forward":"backward"))return!0;let i=!n.textOffset&&(t<0?n.nodeBefore:n.nodeAfter);if(i&&!i.isText){let o=e.state.tr;return t<0?o.delete(n.pos-i.nodeSize,n.pos):o.delete(n.pos,n.pos+i.nodeSize),e.dispatch(o),!0}return!1}function Is(e,t,n){e.domObserver.stop(),t.contentEditable=n,e.domObserver.start()}function zs(e,t){e.someProp("transformCopied",(n=>{t=n(t,e)}));let n=[],{content:o,openStart:r,openEnd:i}=t;for(;r>1&&i>1&&1==o.childCount&&1==o.firstChild.childCount;){r--,i--;let e=o.firstChild;n.push(e.type.name,e.attrs!=e.type.defaultAttrs?e.attrs:null),o=e.content}let s=e.someProp("clipboardSerializer")||le.fromSchema(e.state.schema),l=js(),a=l.createElement("div");a.appendChild(s.serializeFragment(o,{document:l}));let c,d=a.firstChild,h=0;for(;d&&1==d.nodeType&&(c=Ws[d.nodeName.toLowerCase()]);){for(let e=c.length-1;e>=0;e--){let t=l.createElement(c[e]);for(;a.firstChild;)t.appendChild(a.firstChild);a.appendChild(t),h++}d=a.firstChild}return d&&1==d.nodeType&&d.setAttribute("data-pm-slice",`${r} ${i}${h?` -${h}`:""} ${JSON.stringify(n)}`),{dom:a,text:e.someProp("clipboardTextSerializer",(n=>n(t,e)))||t.content.textBetween(0,t.content.size,"\n\n"),slice:t}}function Bs(e,t,n,o,r){let i,l,a=r.parent.type.spec.code;if(!n&&!t)return null;let c=!!t&&(o||a||!n);if(c){if(e.someProp("transformPastedText",(n=>{t=n(t,a||o,e)})),a)return l=new p(s.from(e.state.schema.text(t.replace(/\r\n?/g,"\n"))),0,0),e.someProp("transformPasted",(t=>{l=t(l,e,!0)})),l;let n=e.someProp("clipboardTextParser",(n=>n(t,r,o,e)));if(n)l=n;else{let n=r.marks(),{schema:o}=e.state,s=le.fromSchema(o);i=document.createElement("div"),t.split(/(?:\r\n?|\n)+/).forEach((e=>{let t=i.appendChild(document.createElement("p"));e&&t.appendChild(s.serializeNode(o.text(e,n)))}))}}else e.someProp("transformPastedHTML",(t=>{n=t(n,e)})),i=function(e){let t=/^(\s*<meta [^>]*>)*/.exec(e);t&&(e=e.slice(t[0].length));let n,o=js().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(e);if((n=r&&Ws[r[1].toLowerCase()])&&(e=n.map((e=>"<"+e+">")).join("")+e+n.map((e=>"</"+e+">")).reverse().join("")),o.innerHTML=function(e){let t=window.trustedTypes;return t?(Js||(Js=t.defaultPolicy||t.createPolicy("ProseMirrorClipboard",{createHTML:e=>e})),Js.createHTML(e)):e}(e),n)for(let e=0;e<n.length;e++)o=o.querySelector(n[e])||o;return o}(n),vi&&function(e){let t=e.querySelectorAll(pi?"span:not([class]):not([style])":"span.Apple-converted-space");for(let n=0;n<t.length;n++){let o=t[n];1==o.childNodes.length&&" "==o.textContent&&o.parentNode&&o.parentNode.replaceChild(e.ownerDocument.createTextNode(" "),o)}}(i);let d=i&&i.querySelector("[data-pm-slice]"),h=d&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(d.getAttribute("data-pm-slice")||"");if(h&&h[3])for(let e=+h[3];e>0;e--){let e=i.firstChild;for(;e&&1!=e.nodeType;)e=e.nextSibling;if(!e)break;i=e}if(!l){let t=e.someProp("clipboardParser")||e.someProp("domParser")||Y.fromSchema(e.state.schema);l=t.parseSlice(i,{preserveWhitespace:!(!c&&!h),context:r,ruleFromNode:e=>"BR"!=e.nodeName||e.nextSibling||!e.parentNode||Ps.test(e.parentNode.nodeName)?null:{ignore:!0}})}if(h)l=function(e,t){if(!e.size)return e;let n,o=e.content.firstChild.type.schema;try{n=JSON.parse(t)}catch(t){return e}let{content:r,openStart:i,openEnd:l}=e;for(let e=n.length-2;e>=0;e-=2){let t=o.nodes[n[e]];if(!t||t.hasRequiredAttrs())break;r=s.from(t.create(n[e+1],r)),i++,l++}return new p(r,i,l)}(_s(l,+h[1],+h[2]),h[4]);else if(l=p.maxOpen(function(e,t){if(e.childCount<2)return e;for(let n=t.depth;n>=0;n--){let o,r=t.node(n).contentMatchAt(t.index(n)),i=[];if(e.forEach((e=>{if(!i)return;let t,n=r.findWrapping(e.type);if(!n)return i=null;if(t=i.length&&o.length&&Fs(n,o,e,i[i.length-1],0))i[i.length-1]=t;else{i.length&&(i[i.length-1]=Ls(i[i.length-1],o.length));let t=Vs(e,n);i.push(t),r=r.matchType(t.type),o=n}})),i)return s.from(i)}return e}(l.content,r),!0),l.openStart||l.openEnd){let e=0,t=0;for(let t=l.content.firstChild;e<l.openStart&&!t.type.spec.isolating;e++,t=t.firstChild);for(let e=l.content.lastChild;t<l.openEnd&&!e.type.spec.isolating;t++,e=e.lastChild);l=_s(l,e,t)}return e.someProp("transformPasted",(t=>{l=t(l,e,c)})),l}const Ps=/^(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 Vs(e,t,n=0){for(let o=t.length-1;o>=n;o--)e=t[o].create(null,s.from(e));return e}function Fs(e,t,n,o,r){if(r<e.length&&r<t.length&&e[r]==t[r]){let i=Fs(e,t,n,o.lastChild,r+1);if(i)return o.copy(o.content.replaceChild(o.childCount-1,i));if(o.contentMatchAt(o.childCount).matchType(r==e.length-1?n.type:e[r+1]))return o.copy(o.content.append(s.from(Vs(n,e,r+1))))}}function Ls(e,t){if(0==t)return e;let n=e.content.replaceChild(e.childCount-1,Ls(e.lastChild,t-1)),o=e.contentMatchAt(e.childCount).fillBefore(s.empty,!0);return e.copy(n.append(o))}function Hs(e,t,n,o,r,i){let l=t<0?e.firstChild:e.lastChild,a=l.content;return e.childCount>1&&(i=0),r<o-1&&(a=Hs(a,t,n,o,r+1,i)),r>=n&&(a=t<0?l.contentMatchAt(0).fillBefore(a,i<=r).append(a):a.append(l.contentMatchAt(l.childCount).fillBefore(s.empty,!0))),e.replaceChild(t<0?0:e.childCount-1,l.copy(a))}function _s(e,t,n){return t<e.openStart&&(e=new p(Hs(e.content,-1,t,e.openStart,0,e.openEnd),t,e.openEnd)),n<e.openEnd&&(e=new p(Hs(e.content,1,n,e.openEnd,0,0),e.openStart,n)),e}const Ws={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};let qs=null;function js(){return qs||(qs=document.implementation.createHTMLDocument("title"))}let Js=null;const Ks={},Xs={},Us={touchstart:!0,touchmove:!0};class Gs{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:"",button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function Ys(e,t){e.input.lastSelectionOrigin=t,e.input.lastSelectionTime=Date.now()}function Qs(e){e.someProp("handleDOMEvents",(t=>{for(let n in t)e.input.eventHandlers[n]||e.dom.addEventListener(n,e.input.eventHandlers[n]=t=>Zs(e,t))}))}function Zs(e,t){return e.someProp("handleDOMEvents",(n=>{let o=n[t.type];return!!o&&(o(e,t)||t.defaultPrevented)}))}function el(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let n=t.target;n!=e.dom;n=n.parentNode)if(!n||11==n.nodeType||n.pmViewDesc&&n.pmViewDesc.stopEvent(t))return!1;return!0}function tl(e){return{left:e.clientX,top:e.clientY}}function nl(e,t,n,o,r){if(-1==o)return!1;let i=e.state.doc.resolve(o);for(let o=i.depth+1;o>0;o--)if(e.someProp(t,(t=>o>i.depth?t(e,n,i.nodeAfter,i.before(o),r,!0):t(e,n,i.node(o),i.before(o),r,!1))))return!0;return!1}function ol(e,t,n){if(e.focused||e.focus(),e.state.selection.eq(t))return;let o=e.state.tr.setSelection(t);"pointer"==n&&o.setMeta("pointer",!0),e.dispatch(o)}function rl(e,t,n,o){return nl(e,"handleDoubleClickOn",t,n,o)||e.someProp("handleDoubleClick",(n=>n(e,t,o)))}function il(e,t,n,o){return nl(e,"handleTripleClickOn",t,n,o)||e.someProp("handleTripleClick",(n=>n(e,t,o)))||function(e,t,n){if(0!=n.button)return!1;let o=e.state.doc;if(-1==t)return!!o.inlineContent&&(ol(e,st.create(o,0,o.content.size),"pointer"),!0);let r=o.resolve(t);for(let t=r.depth+1;t>0;t--){let n=t>r.depth?r.nodeAfter:r.node(t),i=r.before(t);if(n.inlineContent)ol(e,st.create(o,i+1,i+1+n.content.size),"pointer");else{if(!at.isSelectable(n))continue;ol(e,at.create(o,i),"pointer")}return!0}}(e,n,o)}function sl(e){return ul(e)}Xs.keydown=(e,t)=>{let n=t;if(e.input.shiftKey=16==n.keyCode||n.shiftKey,!cl(e,n)&&(e.input.lastKeyCode=n.keyCode,e.input.lastKeyCodeTime=Date.now(),!wi||!pi||13!=n.keyCode))if(229!=n.keyCode&&e.domObserver.forceFlush(),!mi||13!=n.keyCode||n.ctrlKey||n.altKey||n.metaKey)e.someProp("handleKeyDown",(t=>t(e,n)))||function(e,t){let n=t.keyCode,o=function(e){let t="";return e.ctrlKey&&(t+="c"),e.metaKey&&(t+="m"),e.altKey&&(t+="a"),e.shiftKey&&(t+="s"),t}(t);if(8==n||gi&&72==n&&"c"==o)return $s(e,-1)||As(e,-1);if(46==n&&!t.shiftKey||gi&&68==n&&"c"==o)return $s(e,1)||As(e,1);if(13==n||27==n)return!0;if(37==n||gi&&66==n&&"c"==o){let t=37==n?"ltr"==Es(e,e.state.selection.from)?-1:1:-1;return Ms(e,t,o)||As(e,t)}if(39==n||gi&&70==n&&"c"==o){let t=39==n?"ltr"==Es(e,e.state.selection.from)?1:-1:1;return Ms(e,t,o)||As(e,t)}return 38==n||gi&&80==n&&"c"==o?Rs(e,-1,o)||As(e,-1):40==n||gi&&78==n&&"c"==o?function(e){if(!fi||e.state.selection.$head.parentOffset>0)return!1;let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(t&&1==t.nodeType&&0==n&&t.firstChild&&"false"==t.firstChild.contentEditable){let n=t.firstChild;Is(e,n,"true"),setTimeout((()=>Is(e,n,"false")),20)}return!1}(e)||Rs(e,1,o)||As(e,1):o==(gi?"m":"c")&&(66==n||73==n||89==n||90==n)}(e,n)?n.preventDefault():Ys(e,"key");else{let t=Date.now();e.input.lastIOSEnter=t,e.input.lastIOSEnterFallbackTimeout=setTimeout((()=>{e.input.lastIOSEnter==t&&(e.someProp("handleKeyDown",(t=>t(e,ti(13,"Enter")))),e.input.lastIOSEnter=0)}),200)}},Xs.keyup=(e,t)=>{16==t.keyCode&&(e.input.shiftKey=!1)},Xs.keypress=(e,t)=>{let n=t;if(cl(e,n)||!n.charCode||n.ctrlKey&&!n.altKey||gi&&n.metaKey)return;if(e.someProp("handleKeyPress",(t=>t(e,n))))return void n.preventDefault();let o=e.state.selection;if(!(o instanceof st&&o.$from.sameParent(o.$to))){let t=String.fromCharCode(n.charCode),r=()=>e.state.tr.insertText(t).scrollIntoView();/[\r\n]/.test(t)||e.someProp("handleTextInput",(n=>n(e,o.$from.pos,o.$to.pos,t,r)))||e.dispatch(r()),n.preventDefault()}};const ll=gi?"metaKey":"ctrlKey";Ks.mousedown=(e,t)=>{let n=t;e.input.shiftKey=n.shiftKey;let o=sl(e),r=Date.now(),i="singleClick";r-e.input.lastClick.time<500&&function(e,t){let n=t.x-e.clientX,o=t.y-e.clientY;return n*n+o*o<100}(n,e.input.lastClick)&&!n[ll]&&e.input.lastClick.button==n.button&&("singleClick"==e.input.lastClick.type?i="doubleClick":"doubleClick"==e.input.lastClick.type&&(i="tripleClick")),e.input.lastClick={time:r,x:n.clientX,y:n.clientY,type:i,button:n.button};let s=e.posAtCoords(tl(n));s&&("singleClick"==i?(e.input.mouseDown&&e.input.mouseDown.done(),e.input.mouseDown=new al(e,s,n,!!o)):("doubleClick"==i?rl:il)(e,s.pos,s.inside,n)?n.preventDefault():Ys(e,"pointer"))};class al{constructor(e,t,n,o){let r,i;if(this.view=e,this.pos=t,this.event=n,this.flushed=o,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!n[ll],this.allowDefault=n.shiftKey,t.inside>-1)r=e.state.doc.nodeAt(t.inside),i=t.inside;else{let n=e.state.doc.resolve(t.pos);r=n.parent,i=n.depth?n.before():0}const s=o?null:n.target,l=s?e.docView.nearestDesc(s,!0):null;this.target=l&&1==l.nodeDOM.nodeType?l.nodeDOM:null;let{selection:a}=e.state;(0==n.button&&r.type.spec.draggable&&!1!==r.type.spec.selectable||a instanceof at&&a.from<=i&&a.to>i)&&(this.mightDrag={node:r,pos:i,addAttr:!(!this.target||this.target.draggable),setUneditable:!(!this.target||!di||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)),Ys(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((()=>us(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(tl(e))),this.updateAllowDefault(e),this.allowDefault||!t?Ys(this.view,"pointer"):function(e,t,n,o,r){return nl(e,"handleClickOn",t,n,o)||e.someProp("handleClick",(n=>n(e,t,o)))||(r?function(e,t){if(-1==t)return!1;let n,o,r=e.state.selection;r instanceof at&&(n=r.node);let i=e.state.doc.resolve(t);for(let e=i.depth+1;e>0;e--){let t=e>i.depth?i.nodeAfter:i.node(e);if(at.isSelectable(t)){o=n&&r.$from.depth>0&&e>=r.$from.depth&&i.before(r.$from.depth+1)==r.$from.pos?i.before(r.$from.depth):i.before(e);break}}return null!=o&&(ol(e,at.create(e.state.doc,o),"pointer"),!0)}(e,n):function(e,t){if(-1==t)return!1;let n=e.state.doc.resolve(t),o=n.nodeAfter;return!!(o&&o.isAtom&&at.isSelectable(o))&&(ol(e,new at(n),"pointer"),!0)}(e,n))}(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():0==e.button&&(this.flushed||fi&&this.mightDrag&&!this.mightDrag.node.isAtom||pi&&!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)?(ol(this.view,nt.near(this.view.state.doc.resolve(t.pos)),"pointer"),e.preventDefault()):Ys(this.view,"pointer")}move(e){this.updateAllowDefault(e),Ys(this.view,"pointer"),0==e.buttons&&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)}}function cl(e,t){return!!e.composing||!!(fi&&Math.abs(t.timeStamp-e.input.compositionEndedAt)<500)&&(e.input.compositionEndedAt=-2e8,!0)}Ks.touchstart=e=>{e.input.lastTouch=Date.now(),sl(e),Ys(e,"pointer")},Ks.touchmove=e=>{e.input.lastTouch=Date.now(),Ys(e,"pointer")},Ks.contextmenu=e=>sl(e);const dl=wi?5e3:-1;function hl(e,t){clearTimeout(e.input.composingTimeout),t>-1&&(e.input.composingTimeout=setTimeout((()=>ul(e)),t))}function pl(e){for(e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=function(){let e=document.createEvent("Event");return e.initEvent("event",!0,!0),e.timeStamp}());e.input.compositionNodes.length>0;)e.input.compositionNodes.pop().markParentsDirty()}function ul(e,t=!1){if(!(wi&&e.domObserver.flushingSoon>=0)){if(e.domObserver.forceFlush(),pl(e),t||e.docView&&e.docView.dirty){let n=hs(e),o=e.state.selection;return n&&!n.eq(o)?e.dispatch(e.state.tr.setSelection(n)):!e.markCursor&&!t||o.$from.node(o.$from.sharedDepth(o.to)).inlineContent?e.updateState(e.state):e.dispatch(e.state.tr.deleteSelection()),!0}return!1}}Xs.compositionstart=Xs.compositionupdate=e=>{if(!e.composing){e.domObserver.flush();let{state:t}=e,n=t.selection.$to;if(t.selection instanceof st&&(t.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some((e=>!1===e.type.spec.inclusive))))e.markCursor=e.state.storedMarks||n.marks(),ul(e,!0),e.markCursor=null;else if(ul(e,!t.selection.empty),di&&t.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let t=e.domSelectionRange();for(let n=t.focusNode,o=t.focusOffset;n&&1==n.nodeType&&0!=o;){let t=o<0?n.lastChild:n.childNodes[o-1];if(!t)break;if(3==t.nodeType){let n=e.domSelection();n&&n.collapse(t,t.nodeValue.length);break}n=t,o=-1}}e.input.composing=!0}hl(e,dl)},Xs.compositionend=(e,t)=>{e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=t.timeStamp,e.input.compositionPendingChanges=e.domObserver.pendingRecords().length?e.input.compositionID:0,e.input.compositionNode=null,e.input.compositionPendingChanges&&Promise.resolve().then((()=>e.domObserver.flush())),e.input.compositionID++,hl(e,20))};const fl=ai&&ci<15||mi&&bi<604;function ml(e,t,n,o,r){let i=Bs(e,t,n,o,e.state.selection.$from);if(e.someProp("handlePaste",(t=>t(e,r,i||p.empty))))return!0;if(!i)return!1;let s=function(e){return 0==e.openStart&&0==e.openEnd&&1==e.content.childCount?e.content.firstChild:null}(i),l=s?e.state.tr.replaceSelectionWith(s,o):e.state.tr.replaceSelection(i);return e.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function gl(e){let t=e.getData("text/plain")||e.getData("Text");if(t)return t;let n=e.getData("text/uri-list");return n?n.replace(/\r?\n/g," "):""}Ks.copy=Xs.cut=(e,t)=>{let n=t,o=e.state.selection,r="cut"==n.type;if(o.empty)return;let i=fl?null:n.clipboardData,s=o.content(),{dom:l,text:a}=zs(e,s);i?(n.preventDefault(),i.clearData(),i.setData("text/html",l.innerHTML),i.setData("text/plain",a)):function(e,t){if(!e.dom.parentNode)return;let n=e.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(t),n.style.cssText="position: fixed; left: -10000px; top: 10px";let o=getSelection(),r=document.createRange();r.selectNodeContents(t),e.dom.blur(),o.removeAllRanges(),o.addRange(r),setTimeout((()=>{n.parentNode&&n.parentNode.removeChild(n),e.focus()}),50)}(e,l),r&&e.dispatch(e.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))},Xs.paste=(e,t)=>{let n=t;if(e.composing&&!wi)return;let o=fl?null:n.clipboardData,r=e.input.shiftKey&&45!=e.input.lastKeyCode;o&&ml(e,gl(o),o.getData("text/html"),r,n)?n.preventDefault():function(e,t){if(!e.dom.parentNode)return;let n=e.input.shiftKey||e.state.selection.$from.parent.type.spec.code,o=e.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(o.contentEditable="true"),o.style.cssText="position: fixed; left: -10000px; top: 10px",o.focus();let r=e.input.shiftKey&&45!=e.input.lastKeyCode;setTimeout((()=>{e.focus(),o.parentNode&&o.parentNode.removeChild(o),n?ml(e,o.value,null,r,t):ml(e,o.textContent,o.innerHTML,r,t)}),50)}(e,n)};class yl{constructor(e,t,n){this.slice=e,this.move=t,this.node=n}}const wl=gi?"altKey":"ctrlKey";function vl(e,t){let n=e.someProp("dragCopies",(e=>!e(t)));return null!=n?n:!t[wl]}Ks.dragstart=(e,t)=>{let n=t,o=e.input.mouseDown;if(o&&o.done(),!n.dataTransfer)return;let r,i=e.state.selection,s=i.empty?null:e.posAtCoords(tl(n));if(s&&s.pos>=i.from&&s.pos<=(i instanceof at?i.to-1:i.to));else if(o&&o.mightDrag)r=at.create(e.state.doc,o.mightDrag.pos);else if(n.target&&1==n.target.nodeType){let t=e.docView.nearestDesc(n.target,!0);t&&t.node.type.spec.draggable&&t!=e.docView&&(r=at.create(e.state.doc,t.posBefore))}let l=(r||e.state.selection).content(),{dom:a,text:c,slice:d}=zs(e,l);(!n.dataTransfer.files.length||!pi||ui>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(fl?"Text":"text/html",a.innerHTML),n.dataTransfer.effectAllowed="copyMove",fl||n.dataTransfer.setData("text/plain",c),e.dragging=new yl(d,vl(e,n),r)},Ks.dragend=e=>{let t=e.dragging;window.setTimeout((()=>{e.dragging==t&&(e.dragging=null)}),50)},Xs.dragover=Xs.dragenter=(e,t)=>t.preventDefault(),Xs.drop=(e,t)=>{let n=t,o=e.dragging;if(e.dragging=null,!n.dataTransfer)return;let r=e.posAtCoords(tl(n));if(!r)return;let i=e.state.doc.resolve(r.pos),s=o&&o.slice;s?e.someProp("transformPasted",(t=>{s=t(s,e,!1)})):s=Bs(e,gl(n.dataTransfer),fl?null:n.dataTransfer.getData("text/html"),!1,i);let l=!(!o||!vl(e,n));if(e.someProp("handleDrop",(t=>t(e,n,s||p.empty,l))))return void n.preventDefault();if(!s)return;n.preventDefault();let a=s?Le(e.state.doc,i.pos,s):i.pos;null==a&&(a=i.pos);let c=e.state.tr;if(l){let{node:e}=o;e?e.replace(c):c.deleteSelection()}let d=c.mapping.map(a),h=0==s.openStart&&0==s.openEnd&&1==s.content.childCount,u=c.doc;if(h?c.replaceRangeWith(d,d,s.content.firstChild):c.replaceRange(d,d,s),c.doc.eq(u))return;let f=c.doc.resolve(d);if(h&&at.isSelectable(s.content.firstChild)&&f.nodeAfter&&f.nodeAfter.sameMarkup(s.content.firstChild))c.setSelection(new at(f));else{let t=c.mapping.map(a);c.mapping.maps[c.mapping.maps.length-1].forEach(((e,n,o,r)=>t=r)),c.setSelection(bs(e,f,c.doc.resolve(t)))}e.focus(),e.dispatch(c.setMeta("uiEvent","drop"))},Ks.focus=e=>{e.input.lastFocus=Date.now(),e.focused||(e.domObserver.stop(),e.dom.classList.add("ProseMirror-focused"),e.domObserver.start(),e.focused=!0,setTimeout((()=>{e.docView&&e.hasFocus()&&!e.domObserver.currentSelection.eq(e.domSelectionRange())&&us(e)}),20))},Ks.blur=(e,t)=>{let n=t;e.focused&&(e.domObserver.stop(),e.dom.classList.remove("ProseMirror-focused"),e.domObserver.start(),n.relatedTarget&&e.dom.contains(n.relatedTarget)&&e.domObserver.currentSelection.clear(),e.focused=!1)},Ks.beforeinput=(e,t)=>{if(pi&&wi&&"deleteContentBackward"==t.inputType){e.domObserver.flushSoon();let{domChangeCount:t}=e.input;setTimeout((()=>{if(e.input.domChangeCount!=t)return;if(e.dom.blur(),e.focus(),e.someProp("handleKeyDown",(t=>t(e,ti(8,"Backspace")))))return;let{$cursor:n}=e.state.selection;n&&n.pos>0&&e.dispatch(e.state.tr.delete(n.pos-1,n.pos).scrollIntoView())}),50)}};for(let e in Xs)Ks[e]=Xs[e];function bl(e,t){if(e==t)return!0;for(let n in e)if(e[n]!==t[n])return!1;for(let n in t)if(!(n in e))return!1;return!0}class kl{constructor(e,t){this.toDOM=e,this.spec=t||Nl,this.side=this.spec.side||0}map(e,t,n,o){let{pos:r,deleted:i}=e.mapResult(t.from+o,this.side<0?-1:1);return i?null:new Cl(r-n,r-n,this)}valid(){return!0}eq(e){return this==e||e instanceof kl&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&bl(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class xl{constructor(e,t){this.attrs=e,this.spec=t||Nl}map(e,t,n,o){let r=e.map(t.from+o,this.spec.inclusiveStart?-1:1)-n,i=e.map(t.to+o,this.spec.inclusiveEnd?1:-1)-n;return r>=i?null:new Cl(r,i,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof xl&&bl(this.attrs,e.attrs)&&bl(this.spec,e.spec)}static is(e){return e.type instanceof xl}destroy(){}}class Sl{constructor(e,t){this.attrs=e,this.spec=t||Nl}map(e,t,n,o){let r=e.mapResult(t.from+o,1);if(r.deleted)return null;let i=e.mapResult(t.to+o,-1);return i.deleted||i.pos<=r.pos?null:new Cl(r.pos-n,i.pos-n,this)}valid(e,t){let n,{index:o,offset:r}=e.content.findIndex(t.from);return r==t.from&&!(n=e.child(o)).isText&&r+n.nodeSize==t.to}eq(e){return this==e||e instanceof Sl&&bl(this.attrs,e.attrs)&&bl(this.spec,e.spec)}destroy(){}}class Cl{constructor(e,t,n){this.from=e,this.to=t,this.type=n}copy(e,t){return new Cl(e,t,this.type)}eq(e,t=0){return this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to}map(e,t,n){return this.type.map(e,this,t,n)}static widget(e,t,n){return new Cl(e,e,new kl(t,n))}static inline(e,t,n,o){return new Cl(e,t,new xl(n,o))}static node(e,t,n,o){return new Cl(e,t,new Sl(n,o))}get spec(){return this.type.spec}get inline(){return this.type instanceof xl}get widget(){return this.type instanceof kl}}const Ml=[],Nl={};class Ol{constructor(e,t){this.local=e.length?e:Ml,this.children=t.length?t:Ml}static create(e,t){return t.length?$l(t,e,0,Nl):Al}find(e,t,n){let o=[];return this.findInner(null==e?0:e,null==t?1e9:t,o,0,n),o}findInner(e,t,n,o,r){for(let i=0;i<this.local.length;i++){let s=this.local[i];s.from<=t&&s.to>=e&&(!r||r(s.spec))&&n.push(s.copy(s.from+o,s.to+o))}for(let i=0;i<this.children.length;i+=3)if(this.children[i]<t&&this.children[i+1]>e){let s=this.children[i]+1;this.children[i+2].findInner(e-s,t-s,n,o+s,r)}}map(e,t,n){return this==Al||0==e.maps.length?this:this.mapInner(e,t,0,0,n||Nl)}mapInner(e,t,n,o,r){let i;for(let s=0;s<this.local.length;s++){let l=this.local[s].map(e,n,o);l&&l.type.valid(t,l)?(i||(i=[])).push(l):r.onRemove&&r.onRemove(this.local[s].spec)}return this.children.length?function(e,t,n,o,r,i,s){let l=e.slice();for(let e=0,t=i;e<n.maps.length;e++){let o=0;n.maps[e].forEach(((e,n,r,i)=>{let s=i-r-(n-e);for(let r=0;r<l.length;r+=3){let i=l[r+1];if(i<0||e>i+t-o)continue;let a=l[r]+t-o;n>=a?l[r+1]=e<=a?-2:-1:e>=t&&s&&(l[r]+=s,l[r+1]+=s)}o+=s})),t=n.maps[e].map(t,-1)}let a=!1;for(let t=0;t<l.length;t+=3)if(l[t+1]<0){if(-2==l[t+1]){a=!0,l[t+1]=-1;continue}let c=n.map(e[t]+i),d=c-r;if(d<0||d>=o.content.size){a=!0;continue}let h=n.map(e[t+1]+i,-1)-r,{index:p,offset:u}=o.content.findIndex(d),f=o.maybeChild(p);if(f&&u==d&&u+f.nodeSize==h){let o=l[t+2].mapInner(n,f,c+1,e[t]+i+1,s);o!=Al?(l[t]=d,l[t+1]=h,l[t+2]=o):(l[t+1]=-2,a=!0)}else a=!0}if(a){let a=function(e,t,n,o,r,i,s){function l(e,t){for(let i=0;i<e.local.length;i++){let l=e.local[i].map(o,r,t);l?n.push(l):s.onRemove&&s.onRemove(e.local[i].spec)}for(let n=0;n<e.children.length;n+=3)l(e.children[n+2],e.children[n]+t+1)}for(let n=0;n<e.length;n+=3)-1==e[n+1]&&l(e[n+2],t[n]+i+1);return n}(l,e,t,n,r,i,s),c=$l(a,o,0,s);t=c.local;for(let e=0;e<l.length;e+=3)l[e+1]<0&&(l.splice(e,3),e-=3);for(let e=0,t=0;e<c.children.length;e+=3){let n=c.children[e];for(;t<l.length&&l[t]<n;)t+=3;l.splice(t,0,c.children[e],c.children[e+1],c.children[e+2])}}return new Ol(t.sort(Il),l)}(this.children,i||[],e,t,n,o,r):i?new Ol(i.sort(Il),Ml):Al}add(e,t){return t.length?this==Al?Ol.create(e,t):this.addInner(e,t,0):this}addInner(e,t,n){let o,r=0;e.forEach(((e,i)=>{let s,l=i+n;if(s=El(t,e,l)){for(o||(o=this.children.slice());r<o.length&&o[r]<i;)r+=3;o[r]==i?o[r+2]=o[r+2].addInner(e,s,l+1):o.splice(r,0,i,i+e.nodeSize,$l(s,e,l+1,Nl)),r+=3}}));let i=Dl(r?Rl(t):t,-n);for(let t=0;t<i.length;t++)i[t].type.valid(e,i[t])||i.splice(t--,1);return new Ol(i.length?this.local.concat(i).sort(Il):this.local,o||this.children)}remove(e){return 0==e.length||this==Al?this:this.removeInner(e,0)}removeInner(e,t){let n=this.children,o=this.local;for(let o=0;o<n.length;o+=3){let r,i=n[o]+t,s=n[o+1]+t;for(let t,n=0;n<e.length;n++)(t=e[n])&&t.from>i&&t.to<s&&(e[n]=null,(r||(r=[])).push(t));if(!r)continue;n==this.children&&(n=this.children.slice());let l=n[o+2].removeInner(r,i+1);l!=Al?n[o+2]=l:(n.splice(o,3),o-=3)}if(o.length)for(let n,r=0;r<e.length;r++)if(n=e[r])for(let e=0;e<o.length;e++)o[e].eq(n,t)&&(o==this.local&&(o=this.local.slice()),o.splice(e--,1));return n==this.children&&o==this.local?this:o.length||n.length?new Ol(o,n):Al}forChild(e,t){if(this==Al)return this;if(t.isLeaf)return Ol.empty;let n,o;for(let t=0;t<this.children.length;t+=3)if(this.children[t]>=e){this.children[t]==e&&(n=this.children[t+2]);break}let r=e+1,i=r+t.content.size;for(let e=0;e<this.local.length;e++){let t=this.local[e];if(t.from<i&&t.to>r&&t.type instanceof xl){let e=Math.max(r,t.from)-r,n=Math.min(i,t.to)-r;e<n&&(o||(o=[])).push(t.copy(e,n))}}if(o){let e=new Ol(o.sort(Il),Ml);return n?new Tl([e,n]):e}return n||Al}eq(e){if(this==e)return!0;if(!(e instanceof Ol)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let t=0;t<this.local.length;t++)if(!this.local[t].eq(e.local[t]))return!1;for(let t=0;t<this.children.length;t+=3)if(this.children[t]!=e.children[t]||this.children[t+1]!=e.children[t+1]||!this.children[t+2].eq(e.children[t+2]))return!1;return!0}locals(e){return zl(this.localsInner(e))}localsInner(e){if(this==Al)return Ml;if(e.inlineContent||!this.local.some(xl.is))return this.local;let t=[];for(let e=0;e<this.local.length;e++)this.local[e].type instanceof xl||t.push(this.local[e]);return t}forEachSet(e){e(this)}}Ol.empty=new Ol([],[]),Ol.removeOverlap=zl;const Al=Ol.empty;class Tl{constructor(e){this.members=e}map(e,t){const n=this.members.map((n=>n.map(e,t,Nl)));return Tl.from(n)}forChild(e,t){if(t.isLeaf)return Ol.empty;let n=[];for(let o=0;o<this.members.length;o++){let r=this.members[o].forChild(e,t);r!=Al&&(r instanceof Tl?n=n.concat(r.members):n.push(r))}return Tl.from(n)}eq(e){if(!(e instanceof Tl)||e.members.length!=this.members.length)return!1;for(let t=0;t<this.members.length;t++)if(!this.members[t].eq(e.members[t]))return!1;return!0}locals(e){let t,n=!0;for(let o=0;o<this.members.length;o++){let r=this.members[o].localsInner(e);if(r.length)if(t){n&&(t=t.slice(),n=!1);for(let e=0;e<r.length;e++)t.push(r[e])}else t=r}return t?zl(n?t:t.sort(Il)):Ml}static from(e){switch(e.length){case 0:return Al;case 1:return e[0];default:return new Tl(e.every((e=>e instanceof Ol))?e:e.reduce(((e,t)=>e.concat(t instanceof Ol?t:t.members)),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}}function Dl(e,t){if(!t||!e.length)return e;let n=[];for(let o=0;o<e.length;o++){let r=e[o];n.push(new Cl(r.from+t,r.to+t,r.type))}return n}function El(e,t,n){if(t.isLeaf)return null;let o=n+t.nodeSize,r=null;for(let t,i=0;i<e.length;i++)(t=e[i])&&t.from>n&&t.to<o&&((r||(r=[])).push(t),e[i]=null);return r}function Rl(e){let t=[];for(let n=0;n<e.length;n++)null!=e[n]&&t.push(e[n]);return t}function $l(e,t,n,o){let r=[],i=!1;t.forEach(((t,s)=>{let l=El(e,t,s+n);if(l){i=!0;let e=$l(l,t,n+s+1,o);e!=Al&&r.push(s,s+t.nodeSize,e)}}));let s=Dl(i?Rl(e):e,-n).sort(Il);for(let e=0;e<s.length;e++)s[e].type.valid(t,s[e])||(o.onRemove&&o.onRemove(s[e].spec),s.splice(e--,1));return s.length||r.length?new Ol(s,r):Al}function Il(e,t){return e.from-t.from||e.to-t.to}function zl(e){let t=e;for(let n=0;n<t.length-1;n++){let o=t[n];if(o.from!=o.to)for(let r=n+1;r<t.length;r++){let i=t[r];if(i.from!=o.from){i.from<o.to&&(t==e&&(t=e.slice()),t[n]=o.copy(o.from,i.from),Bl(t,r,o.copy(i.from,o.to)));break}i.to!=o.to&&(t==e&&(t=e.slice()),t[r]=i.copy(i.from,o.to),Bl(t,r+1,i.copy(o.to,i.to)))}}return t}function Bl(e,t,n){for(;t<e.length&&Il(n,e[t])>0;)t++;e.splice(t,0,n)}function Pl(e){let t=[];return e.someProp("decorations",(n=>{let o=n(e.state);o&&o!=Al&&t.push(o)})),e.cursorWrapper&&t.push(Ol.create(e.state.doc,[e.cursorWrapper.deco])),Tl.from(t)}const Vl={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},Fl=ai&&ci<=11;class Ll{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}}class Hl{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new Ll,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver((e=>{for(let t=0;t<e.length;t++)this.queue.push(e[t]);ai&&ci<=11&&e.some((e=>"childList"==e.type&&e.removedNodes.length||"characterData"==e.type&&e.oldValue.length>e.target.nodeValue.length))?this.flushSoon():this.flush()})),Fl&&(this.onCharData=e=>{this.queue.push({target:e.target,type:"characterData",oldValue:e.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout((()=>{this.flushingSoon=-1,this.flush()}),20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,Vl)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let t=0;t<e.length;t++)this.queue.push(e[t]);window.setTimeout((()=>this.flush()),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout((()=>this.suppressingSelectionUpdates=!1),50)}onSelectionChange(){if(ks(this.view)){if(this.suppressingSelectionUpdates)return us(this.view);if(ai&&ci<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Ur(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t,n=new Set;for(let t=e.focusNode;t;t=Jr(t))n.add(t);for(let o=e.anchorNode;o;o=Jr(o))if(n.has(o)){t=o;break}let o=t&&this.view.docView.nearestDesc(t);return o&&o.ignoreMutation({type:"selection",target:3==t.nodeType?t.parentNode:t})?(this.setCurSelection(),!0):void 0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.pendingRecords();t.length&&(this.queue=[]);let n=e.domSelectionRange(),o=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(n)&&ks(e)&&!this.ignoreSelectionChange(n),r=-1,i=-1,s=!1,l=[];if(e.editable)for(let e=0;e<t.length;e++){let n=this.registerMutation(t[e],l);n&&(r=r<0?n.from:Math.min(n.from,r),i=i<0?n.to:Math.max(n.to,i),n.typeOver&&(s=!0))}if(di&&l.length){let t=l.filter((e=>"BR"==e.nodeName));if(2==t.length){let[e,n]=t;e.parentNode&&e.parentNode.parentNode==n.parentNode?n.remove():e.remove()}else{let{focusNode:n}=this.currentSelection;for(let o of t){let t=o.parentNode;!t||"LI"!=t.nodeName||n&&jl(e,n)==t||o.remove()}}}let a=null;r<0&&o&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&ei(n)&&(a=hs(e))&&a.eq(nt.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,us(e),this.currentSelection.set(n),e.scrollToSelection()):(r>-1||o)&&(r>-1&&(e.docView.markDirty(r,i),function(e){if(!_l.has(e)&&(_l.set(e,null),-1!==["normal","nowrap","pre-line"].indexOf(getComputedStyle(e.dom).whiteSpace))){if(e.requiresGeckoHackNode=di,Wl)return;console.warn("ProseMirror expects the CSS white-space property to be set, preferably to 'pre-wrap'. It is recommended to load style/prosemirror.css from the prosemirror-view package."),Wl=!0}}(e)),this.handleDOMChange(r,i,s,l),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(n)||us(e),this.currentSelection.set(n))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let n=this.view.docView.nearestDesc(e.target);if("attributes"==e.type&&(n==this.view.docView||"contenteditable"==e.attributeName||"style"==e.attributeName&&!e.oldValue&&!e.target.getAttribute("style")))return null;if(!n||n.ignoreMutation(e))return null;if("childList"==e.type){for(let n=0;n<e.addedNodes.length;n++){let o=e.addedNodes[n];t.push(o),3==o.nodeType&&(this.lastChangedTextNode=o)}if(n.contentDOM&&n.contentDOM!=n.dom&&!n.contentDOM.contains(e.target))return{from:n.posBefore,to:n.posAfter};let o=e.previousSibling,r=e.nextSibling;if(ai&&ci<=11&&e.addedNodes.length)for(let t=0;t<e.addedNodes.length;t++){let{previousSibling:n,nextSibling:i}=e.addedNodes[t];(!n||Array.prototype.indexOf.call(e.addedNodes,n)<0)&&(o=n),(!i||Array.prototype.indexOf.call(e.addedNodes,i)<0)&&(r=i)}let i=o&&o.parentNode==e.target?jr(o)+1:0,s=n.localPosFromDOM(e.target,i,-1),l=r&&r.parentNode==e.target?jr(r):e.target.childNodes.length;return{from:s,to:n.localPosFromDOM(e.target,l,1)}}return"attributes"==e.type?{from:n.posAtStart-n.border,to:n.posAtEnd+n.border}:(this.lastChangedTextNode=e.target,{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let _l=new WeakMap,Wl=!1;function ql(e,t){let n=t.startContainer,o=t.startOffset,r=t.endContainer,i=t.endOffset,s=e.domAtPos(e.state.selection.anchor);return Ur(s.node,s.offset,r,i)&&([n,o,r,i]=[r,i,n,o]),{anchorNode:n,anchorOffset:o,focusNode:r,focusOffset:i}}function jl(e,t){for(let n=t.parentNode;n&&n!=e.dom;n=n.parentNode){let t=e.docView.nearestDesc(n,!0);if(t&&t.node.isBlock)return n}return null}function Jl(e){let t=e.pmViewDesc;if(t)return t.parseRule();if("BR"==e.nodeName&&e.parentNode){if(fi&&/^(ul|ol)$/i.test(e.parentNode.nodeName)){let e=document.createElement("div");return e.appendChild(document.createElement("li")),{skip:e}}if(e.parentNode.lastChild==e||fi&&/^(tr|table)$/i.test(e.parentNode.nodeName))return{ignore:!0}}else if("IMG"==e.nodeName&&e.getAttribute("mark-placeholder"))return{ignore:!0};return null}const Kl=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function Xl(e,t,n){return Math.max(n.anchor,n.head)>t.content.size?null:bs(e,t.resolve(n.anchor),t.resolve(n.head))}function Ul(e,t,n){let o=e.depth,r=t?e.end():e.pos;for(;o>0&&(t||e.indexAfter(o)==e.node(o).childCount);)o--,r++,t=!1;if(n){let t=e.node(o).maybeChild(e.indexAfter(o));for(;t&&!t.isLeaf;)t=t.firstChild,r++}return r}function Gl(e){if(2!=e.length)return!1;let t=e.charCodeAt(0),n=e.charCodeAt(1);return t>=56320&&t<=57343&&n>=55296&&n<=56319}const Yl=Bs,Ql=ul;class Zl{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 Gs,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(ra),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):"function"==typeof e?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=na(this),ta(this),this.nodeViews=oa(this),this.docView=Xi(this.state.doc,ea(this),Pl(this),this.dom,this),this.domObserver=new Hl(this,((e,t,n,o)=>function(e,t,n,o,r){let i=e.input.compositionPendingChanges||(e.composing?e.input.compositionID:0);if(e.input.compositionPendingChanges=0,t<0){let t=e.input.lastSelectionTime>Date.now()-50?e.input.lastSelectionOrigin:null,n=hs(e,t);if(n&&!e.state.selection.eq(n)){if(pi&&wi&&13===e.input.lastKeyCode&&Date.now()-100<e.input.lastKeyCodeTime&&e.someProp("handleKeyDown",(t=>t(e,ti(13,"Enter")))))return;let o=e.state.tr.setSelection(n);"pointer"==t?o.setMeta("pointer",!0):"key"==t&&o.scrollIntoView(),i&&o.setMeta("composition",i),e.dispatch(o)}return}let l=e.state.doc.resolve(t),a=l.sharedDepth(n);t=l.before(a+1),n=e.state.doc.resolve(n).after(a+1);let c,d,h=e.state.selection,p=function(e,t,n){let o,{node:r,fromOffset:i,toOffset:s,from:l,to:a}=e.docView.parseRange(t,n),c=e.domSelectionRange(),d=c.anchorNode;if(d&&e.dom.contains(1==d.nodeType?d:d.parentNode)&&(o=[{node:d,offset:c.anchorOffset}],ei(c)||o.push({node:c.focusNode,offset:c.focusOffset})),pi&&8===e.input.lastKeyCode)for(let e=s;e>i;e--){let t=r.childNodes[e-1],n=t.pmViewDesc;if("BR"==t.nodeName&&!n){s=e;break}if(!n||n.size)break}let h=e.state.doc,p=e.someProp("domParser")||Y.fromSchema(e.state.schema),u=h.resolve(l),f=null,m=p.parse(r,{topNode:u.parent,topMatch:u.parent.contentMatchAt(u.index()),topOpen:!0,from:i,to:s,preserveWhitespace:"pre"!=u.parent.type.whitespace||"full",findPositions:o,ruleFromNode:Jl,context:u});if(o&&null!=o[0].pos){let e=o[0].pos,t=o[1]&&o[1].pos;null==t&&(t=e),f={anchor:e+l,head:t+l}}return{doc:m,sel:f,from:l,to:a}}(e,t,n),u=e.state.doc,f=u.slice(p.from,p.to);8===e.input.lastKeyCode&&Date.now()-100<e.input.lastKeyCodeTime?(c=e.state.selection.to,d="end"):(c=e.state.selection.from,d="start"),e.input.lastKeyCode=null;let m=function(e,t,n,o,r){let i=e.findDiffStart(t,n);if(null==i)return null;let{a:s,b:l}=e.findDiffEnd(t,n+e.size,n+t.size);if("end"==r&&(o-=s+Math.max(0,i-Math.min(s,l))-i),s<i&&e.size<t.size){let e=o<=i&&o>=s?i-o:0;i-=e,i&&i<t.size&&Gl(t.textBetween(i-1,i+1))&&(i+=e?1:-1),l=i+(l-s),s=i}else if(l<i){let t=o<=i&&o>=l?i-o:0;i-=t,i&&i<e.size&&Gl(e.textBetween(i-1,i+1))&&(i+=t?1:-1),s=i+(s-l),l=i}return{start:i,endA:s,endB:l}}(f.content,p.doc.content,p.from,c,d);if(m&&e.input.domChangeCount++,(mi&&e.input.lastIOSEnter>Date.now()-225||wi)&&r.some((e=>1==e.nodeType&&!Kl.test(e.nodeName)))&&(!m||m.endA>=m.endB)&&e.someProp("handleKeyDown",(t=>t(e,ti(13,"Enter")))))return void(e.input.lastIOSEnter=0);if(!m){if(!(o&&h instanceof st&&!h.empty&&h.$head.sameParent(h.$anchor))||e.composing||p.sel&&p.sel.anchor!=p.sel.head){if(p.sel){let t=Xl(e,e.state.doc,p.sel);if(t&&!t.eq(e.state.selection)){let n=e.state.tr.setSelection(t);i&&n.setMeta("composition",i),e.dispatch(n)}}return}m={start:h.from,endA:h.to,endB:h.to}}e.state.selection.from<e.state.selection.to&&m.start==m.endB&&e.state.selection instanceof st&&(m.start>e.state.selection.from&&m.start<=e.state.selection.from+2&&e.state.selection.from>=p.from?m.start=e.state.selection.from:m.endA<e.state.selection.to&&m.endA>=e.state.selection.to-2&&e.state.selection.to<=p.to&&(m.endB+=e.state.selection.to-m.endA,m.endA=e.state.selection.to)),ai&&ci<=11&&m.endB==m.start+1&&m.endA==m.start&&m.start>p.from&&"  "==p.doc.textBetween(m.start-p.from-1,m.start-p.from+1)&&(m.start--,m.endA--,m.endB--);let g=p.doc.resolveNoCache(m.start-p.from),y=p.doc.resolveNoCache(m.endB-p.from),w=u.resolve(m.start),v=g.sameParent(y)&&g.parent.inlineContent&&w.end()>=m.endA;if((mi&&e.input.lastIOSEnter>Date.now()-225&&(!v||r.some((e=>"DIV"==e.nodeName||"P"==e.nodeName)))||!v&&g.pos<p.doc.content.size&&(!g.sameParent(y)||!g.parent.inlineContent)&&g.pos<y.pos&&!/\S/.test(p.doc.textBetween(g.pos,y.pos,"","")))&&e.someProp("handleKeyDown",(t=>t(e,ti(13,"Enter")))))return void(e.input.lastIOSEnter=0);if(e.state.selection.anchor>m.start&&function(e,t,n,o,r){if(n-t<=r.pos-o.pos||Ul(o,!0,!1)<r.pos)return!1;let i=e.resolve(t);if(!o.parent.isTextblock){let e=i.nodeAfter;return null!=e&&n==t+e.nodeSize}if(i.parentOffset<i.parent.content.size||!i.parent.isTextblock)return!1;let s=e.resolve(Ul(i,!0,!0));return!(!s.parent.isTextblock||s.pos>n||Ul(s,!0,!1)<n)&&o.parent.content.cut(o.parentOffset).eq(s.parent.content)}(u,m.start,m.endA,g,y)&&e.someProp("handleKeyDown",(t=>t(e,ti(8,"Backspace")))))return void(wi&&pi&&e.domObserver.suppressSelectionUpdates());pi&&m.endB==m.start&&(e.input.lastChromeDelete=Date.now()),wi&&!v&&g.start()!=y.start()&&0==y.parentOffset&&g.depth==y.depth&&p.sel&&p.sel.anchor==p.sel.head&&p.sel.head==m.endA&&(m.endB-=2,y=p.doc.resolveNoCache(m.endB-p.from),setTimeout((()=>{e.someProp("handleKeyDown",(function(t){return t(e,ti(13,"Enter"))}))}),20));let b,k=m.start,x=m.endA,S=t=>{let n=t||e.state.tr.replace(k,x,p.doc.slice(m.start-p.from,m.endB-p.from));if(p.sel){let t=Xl(e,n.doc,p.sel);t&&!(pi&&e.composing&&t.empty&&(m.start!=m.endB||e.input.lastChromeDelete<Date.now()-100)&&(t.head==k||t.head==n.mapping.map(x)-1)||ai&&t.empty&&t.head==k)&&n.setSelection(t)}return i&&n.setMeta("composition",i),n.scrollIntoView()};if(v)if(g.pos==y.pos){ai&&ci<=11&&0==g.parentOffset&&(e.domObserver.suppressSelectionUpdates(),setTimeout((()=>us(e)),20));let t=S(e.state.tr.delete(k,x)),n=u.resolve(m.start).marksAcross(u.resolve(m.endA));n&&t.ensureMarks(n),e.dispatch(t)}else if(m.endA==m.endB&&(b=function(e,t){let n,o,r,i=e.firstChild.marks,l=t.firstChild.marks,a=i,c=l;for(let e=0;e<l.length;e++)a=l[e].removeFromSet(a);for(let e=0;e<i.length;e++)c=i[e].removeFromSet(c);if(1==a.length&&0==c.length)o=a[0],n="add",r=e=>e.mark(o.addToSet(e.marks));else{if(0!=a.length||1!=c.length)return null;o=c[0],n="remove",r=e=>e.mark(o.removeFromSet(e.marks))}let d=[];for(let e=0;e<t.childCount;e++)d.push(r(t.child(e)));if(s.from(d).eq(e))return{mark:o,type:n}}(g.parent.content.cut(g.parentOffset,y.parentOffset),w.parent.content.cut(w.parentOffset,m.endA-w.start())))){let t=S(e.state.tr);"add"==b.type?t.addMark(k,x,b.mark):t.removeMark(k,x,b.mark),e.dispatch(t)}else if(g.parent.child(g.index()).isText&&g.index()==y.index()-(y.textOffset?0:1)){let t=g.parent.textBetween(g.parentOffset,y.parentOffset),n=()=>S(e.state.tr.insertText(t,k,x));e.someProp("handleTextInput",(o=>o(e,k,x,t,n)))||e.dispatch(n())}else e.dispatch(S());else e.dispatch(S())}(this,e,t,n,o))),this.domObserver.start(),function(e){for(let t in Ks){let n=Ks[t];e.dom.addEventListener(t,e.input.eventHandlers[t]=t=>{!el(e,t)||Zs(e,t)||!e.editable&&t.type in Xs||n(e,t)},Us[t]?{passive:!0}:void 0)}fi&&e.dom.addEventListener("input",(()=>null)),Qs(e)}(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let t in e)this._props[t]=e[t];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&Qs(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(ra),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let e in this._props)t[e]=this._props[e];t.state=this.state;for(let n in e)t[n]=e[n];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var n;let o=this.state,r=!1,i=!1;e.storedMarks&&this.composing&&(pl(this),i=!0),this.state=e;let s=o.plugins!=e.plugins||this._props.plugins!=t.plugins;if(s||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let e=oa(this);(function(e,t){let n=0,o=0;for(let o in e){if(e[o]!=t[o])return!0;n++}for(let e in t)o++;return n!=o})(e,this.nodeViews)&&(this.nodeViews=e,r=!0)}(s||t.handleDOMEvents!=this._props.handleDOMEvents)&&Qs(this),this.editable=na(this),ta(this);let l=Pl(this),a=ea(this),c=o.plugins==e.plugins||o.doc.eq(e.doc)?e.scrollToSelection>o.scrollToSelection?"to selection":"preserve":"reset",d=r||!this.docView.matchesNode(e.doc,a,l);!d&&e.selection.eq(o.selection)||(i=!0);let h="preserve"==c&&i&&null==this.dom.style.overflowAnchor&&function(e){let t,n,o=e.dom.getBoundingClientRect(),r=Math.max(0,o.top);for(let i=(o.left+o.right)/2,s=r+1;s<Math.min(innerHeight,o.bottom);s+=5){let o=e.root.elementFromPoint(i,s);if(!o||o==e.dom||!e.dom.contains(o))continue;let l=o.getBoundingClientRect();if(l.top>=r-20){t=o,n=l.top;break}}return{refDOM:t,refTop:n,stack:Mi(e.dom)}}(this);if(i){this.domObserver.stop();let t=d&&(ai||pi)&&!this.composing&&!o.selection.empty&&!e.selection.empty&&function(e,t){let n=Math.min(e.$anchor.sharedDepth(e.head),t.$anchor.sharedDepth(t.head));return e.$anchor.start(n)!=t.$anchor.start(n)}(o.selection,e.selection);if(d){let n=pi?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=function(e){let t=e.domSelectionRange();if(!t.focusNode)return null;let n=function(e,t){for(;;){if(3==e.nodeType&&t)return e;if(1==e.nodeType&&t>0){if("false"==e.contentEditable)return null;t=Qr(e=e.childNodes[t-1])}else{if(!e.parentNode||Zr(e))return null;t=jr(e),e=e.parentNode}}}(t.focusNode,t.focusOffset),o=function(e,t){for(;;){if(3==e.nodeType&&t<e.nodeValue.length)return e;if(1==e.nodeType&&t<e.childNodes.length){if("false"==e.contentEditable)return null;e=e.childNodes[t],t=0}else{if(!e.parentNode||Zr(e))return null;t=jr(e)+1,e=e.parentNode}}}(t.focusNode,t.focusOffset);if(n&&o&&n!=o){let t=o.pmViewDesc,r=e.domObserver.lastChangedTextNode;if(n==r||o==r)return r;if(!t||!t.isText(o.nodeValue))return o;if(e.input.compositionNode==o){let e=n.pmViewDesc;if(e&&e.isText(n.nodeValue))return o}}return n||o}(this)),!r&&this.docView.update(e.doc,a,l,this)||(this.docView.updateOuterDeco(a),this.docView.destroy(),this.docView=Xi(e.doc,a,l,this.dom,this)),n&&!this.trackWrites&&(t=!0)}t||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&function(e){let t=e.docView.domFromPos(e.state.selection.anchor,0),n=e.domSelectionRange();return Ur(t.node,t.offset,n.anchorNode,n.anchorOffset)}(this))?us(this,t):(ws(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(o),(null===(n=this.dragging)||void 0===n?void 0:n.node)&&!o.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,o),"reset"==c?this.dom.scrollTop=0:"to selection"==c?this.scrollToSelection():h&&function({refDOM:e,refTop:t,stack:n}){let o=e?e.getBoundingClientRect().top:0;Ni(n,0==o?0:o-t)}(h)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(e&&this.dom.contains(1==e.nodeType?e:e.parentNode))if(this.someProp("handleScrollToSelection",(e=>e(this))));else if(this.state.selection instanceof at){let t=this.docView.domAfterPos(this.state.selection.from);1==t.nodeType&&Ci(this,t.getBoundingClientRect(),e)}else Ci(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)for(let t=0;t<this.pluginViews.length;t++){let n=this.pluginViews[t];n.update&&n.update(this,e)}else{this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let e=0;e<this.directPlugins.length;e++){let t=this.directPlugins[e];t.spec.view&&this.pluginViews.push(t.spec.view(this))}for(let e=0;e<this.state.plugins.length;e++){let t=this.state.plugins[e];t.spec.view&&this.pluginViews.push(t.spec.view(this))}}}updateDraggedNode(e,t){let n=e.node,o=-1;if(this.state.doc.nodeAt(n.from)==n.node)o=n.from;else{let e=n.from+(this.state.doc.content.size-t.doc.content.size);(e>0&&this.state.doc.nodeAt(e))==n.node&&(o=e)}this.dragging=new yl(e.slice,e.move,o<0?void 0:at.create(this.state.doc,o))}someProp(e,t){let n,o=this._props&&this._props[e];if(null!=o&&(n=t?t(o):o))return n;for(let o=0;o<this.directPlugins.length;o++){let r=this.directPlugins[o].props[e];if(null!=r&&(n=t?t(r):r))return n}let r=this.state.plugins;if(r)for(let o=0;o<r.length;o++){let i=r[o].props[e];if(null!=i&&(n=t?t(i):i))return n}}hasFocus(){if(ai){let e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if("false"==e.contentEditable)return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&function(e){if(e.setActive)return e.setActive();if(Oi)return e.focus(Oi);let t=Mi(e);e.focus(null==Oi?{get preventScroll(){return Oi={preventScroll:!0},!0}}:void 0),Oi||(Oi=!1,Ni(t,0))}(this.dom),us(this),this.domObserver.start()}get root(){let e=this._root;if(null==e)for(let e=this.dom.parentNode;e;e=e.parentNode)if(9==e.nodeType||11==e.nodeType&&e.host)return e.getSelection||(Object.getPrototypeOf(e).getSelection=()=>e.ownerDocument.getSelection()),this._root=e;return e||document}updateRoot(){this._root=null}posAtCoords(e){return Ei(this,e)}coordsAtPos(e,t=1){return zi(this,e,t)}domAtPos(e,t=0){return this.docView.domFromPos(e,t)}nodeDOM(e){let t=this.docView.descAt(e);return t?t.nodeDOM:null}posAtDOM(e,t,n=-1){let o=this.docView.posFromDOM(e,t,n);if(null==o)throw new RangeError("DOM position not inside the editor");return o}endOfTextblock(e,t){return function(e,t,n){return Li==t&&Hi==n?_i:(Li=t,Hi=n,_i="up"==n||"down"==n?function(e,t,n){let o=t.selection,r="up"==n?o.$from:o.$to;return Vi(e,t,(()=>{let{node:t}=e.docView.domFromPos(r.pos,"up"==n?-1:1);for(;;){let n=e.docView.nearestDesc(t,!0);if(!n)break;if(n.node.isBlock){t=n.contentDOM||n.dom;break}t=n.dom.parentNode}let o=zi(e,r.pos,1);for(let e=t.firstChild;e;e=e.nextSibling){let t;if(1==e.nodeType)t=e.getClientRects();else{if(3!=e.nodeType)continue;t=Xr(e,0,e.nodeValue.length).getClientRects()}for(let e=0;e<t.length;e++){let r=t[e];if(r.bottom>r.top+1&&("up"==n?o.top-r.top>2*(r.bottom-o.top):r.bottom-o.bottom>2*(o.bottom-r.top)))return!1}}return!0}))}(e,t,n):function(e,t,n){let{$head:o}=t.selection;if(!o.parent.isTextblock)return!1;let r=o.parentOffset,i=!r,s=r==o.parent.content.size,l=e.domSelection();return l?Fi.test(o.parent.textContent)&&l.modify?Vi(e,t,(()=>{let{focusNode:t,focusOffset:r,anchorNode:i,anchorOffset:s}=e.domSelectionRange(),a=l.caretBidiLevel;l.modify("move",n,"character");let c=o.depth?e.docView.domAfterPos(o.before()):e.dom,{focusNode:d,focusOffset:h}=e.domSelectionRange(),p=d&&!c.contains(1==d.nodeType?d:d.parentNode)||t==d&&r==h;try{l.collapse(i,s),t&&(t!=i||r!=s)&&l.extend&&l.extend(t,r)}catch(e){}return null!=a&&(l.caretBidiLevel=a),p})):"left"==n||"backward"==n?i:s:o.pos==o.start()||o.pos==o.end()}(e,t,n))}(this,t||this.state,e)}pasteHTML(e,t){return ml(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return ml(this,e,null,!0,t||new ClipboardEvent("paste"))}serializeForClipboard(e){return zs(this,e)}destroy(){this.docView&&(function(e){e.domObserver.stop();for(let t in e.input.eventHandlers)e.dom.removeEventListener(t,e.input.eventHandlers[t]);clearTimeout(e.input.composingTimeout),clearTimeout(e.input.lastIOSEnterFallbackTimeout)}(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Pl(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Kr=null)}get isDestroyed(){return null==this.docView}dispatchEvent(e){return function(e,t){Zs(e,t)||!Ks[t.type]||!e.editable&&t.type in Xs||Ks[t.type](e,t)}(this,e)}domSelectionRange(){let e=this.domSelection();return e?fi&&11===this.root.nodeType&&function(e){let t=e.activeElement;for(;t&&t.shadowRoot;)t=t.shadowRoot.activeElement;return t}(this.dom.ownerDocument)==this.dom&&function(e,t){if(t.getComposedRanges){let n=t.getComposedRanges(e.root)[0];if(n)return ql(e,n)}let n;function o(e){e.preventDefault(),e.stopImmediatePropagation(),n=e.getTargetRanges()[0]}return e.dom.addEventListener("beforeinput",o,!0),document.execCommand("indent"),e.dom.removeEventListener("beforeinput",o,!0),n?ql(e,n):null}(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}function ea(e){let t=Object.create(null);return t.class="ProseMirror",t.contenteditable=String(e.editable),e.someProp("attributes",(n=>{if("function"==typeof n&&(n=n(e.state)),n)for(let e in n)"class"==e?t.class+=" "+n[e]:"style"==e?t.style=(t.style?t.style+";":"")+n[e]:t[e]||"contenteditable"==e||"nodeName"==e||(t[e]=String(n[e]))})),t.translate||(t.translate="no"),[Cl.node(0,e.state.doc.content.size,t)]}function ta(e){if(e.markCursor){let t=document.createElement("img");t.className="ProseMirror-separator",t.setAttribute("mark-placeholder","true"),t.setAttribute("alt",""),e.cursorWrapper={dom:t,deco:Cl.widget(e.state.selection.from,t,{raw:!0,marks:e.markCursor})}}else e.cursorWrapper=null}function na(e){return!e.someProp("editable",(t=>!1===t(e.state)))}function oa(e){let t=Object.create(null);function n(e){for(let n in e)Object.prototype.hasOwnProperty.call(t,n)||(t[n]=e[n])}return e.someProp("nodeViews",n),e.someProp("markViews",n),t}function ra(e){if(e.spec.state||e.spec.filterTransaction||e.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}Zl.prototype.dispatch=function(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))};for(var ia={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:"'"},sa={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},la="undefined"!=typeof navigator&&/Mac/.test(navigator.platform),aa="undefined"!=typeof navigator&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),ca=0;ca<10;ca++)ia[48+ca]=ia[96+ca]=String(ca);for(ca=1;ca<=24;ca++)ia[ca+111]="F"+ca;for(ca=65;ca<=90;ca++)ia[ca]=String.fromCharCode(ca+32),sa[ca]=String.fromCharCode(ca);for(var da in ia)sa.hasOwnProperty(da)||(sa[da]=ia[da]);const ha="undefined"!=typeof navigator&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),pa="undefined"!=typeof navigator&&/Win/.test(navigator.platform);function ua(e){let t,n,o,r,i=e.split(/-(?!$)/),s=i[i.length-1];"Space"==s&&(s=" ");for(let e=0;e<i.length-1;e++){let s=i[e];if(/^(cmd|meta|m)$/i.test(s))r=!0;else if(/^a(lt)?$/i.test(s))t=!0;else if(/^(c|ctrl|control)$/i.test(s))n=!0;else if(/^s(hift)?$/i.test(s))o=!0;else{if(!/^mod$/i.test(s))throw new Error("Unrecognized modifier name: "+s);ha?r=!0:n=!0}}return t&&(s="Alt-"+s),n&&(s="Ctrl-"+s),r&&(s="Meta-"+s),o&&(s="Shift-"+s),s}function fa(e,t,n=!0){return t.altKey&&(e="Alt-"+e),t.ctrlKey&&(e="Ctrl-"+e),t.metaKey&&(e="Meta-"+e),n&&t.shiftKey&&(e="Shift-"+e),e}function ma(e){return new kt({props:{handleKeyDown:ga(e)}})}function ga(e){let t=function(e){let t=Object.create(null);for(let n in e)t[ua(n)]=e[n];return t}(e);return function(e,n){let o,r=function(e){var t=!(la&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||aa&&e.shiftKey&&e.key&&1==e.key.length||"Unidentified"==e.key)&&e.key||(e.shiftKey?sa:ia)[e.keyCode]||e.key||"Unidentified";return"Esc"==t&&(t="Escape"),"Del"==t&&(t="Delete"),"Left"==t&&(t="ArrowLeft"),"Up"==t&&(t="ArrowUp"),"Right"==t&&(t="ArrowRight"),"Down"==t&&(t="ArrowDown"),t}(n),i=t[fa(r,n)];if(i&&i(e.state,e.dispatch,e))return!0;if(1==r.length&&" "!=r){if(n.shiftKey){let o=t[fa(r,n,!1)];if(o&&o(e.state,e.dispatch,e))return!0}if((n.altKey||n.metaKey||n.ctrlKey)&&!(pa&&n.ctrlKey&&n.altKey)&&(o=ia[n.keyCode])&&o!=r){let r=t[fa(o,n)];if(r&&r(e.state,e.dispatch,e))return!0}}return!1}}var ya,wa;if("undefined"!=typeof WeakMap){let e=new WeakMap;ya=t=>e.get(t),wa=(t,n)=>(e.set(t,n),n)}else{const e=[],t=10;let n=0;ya=t=>{for(let n=0;n<e.length;n+=2)if(e[n]==t)return e[n+1]},wa=(o,r)=>(n==t&&(n=0),e[n++]=o,e[n++]=r)}var va=class{constructor(e,t,n,o){this.width=e,this.height=t,this.map=n,this.problems=o}findCell(e){for(let t=0;t<this.map.length;t++){const n=this.map[t];if(n!=e)continue;const o=t%this.width,r=t/this.width|0;let i=o+1,s=r+1;for(let e=1;i<this.width&&this.map[t+e]==n;e++)i++;for(let e=1;s<this.height&&this.map[t+this.width*e]==n;e++)s++;return{left:o,top:r,right:i,bottom:s}}throw new RangeError(`No cell with offset ${e} found`)}colCount(e){for(let t=0;t<this.map.length;t++)if(this.map[t]==e)return t%this.width;throw new RangeError(`No cell with offset ${e} found`)}nextCell(e,t,n){const{left:o,right:r,top:i,bottom:s}=this.findCell(e);return"horiz"==t?(n<0?0==o:r==this.width)?null:this.map[i*this.width+(n<0?o-1:r)]:(n<0?0==i:s==this.height)?null:this.map[o+this.width*(n<0?i-1:s)]}rectBetween(e,t){const{left:n,right:o,top:r,bottom:i}=this.findCell(e),{left:s,right:l,top:a,bottom:c}=this.findCell(t);return{left:Math.min(n,s),top:Math.min(r,a),right:Math.max(o,l),bottom:Math.max(i,c)}}cellsInRect(e){const t=[],n={};for(let o=e.top;o<e.bottom;o++)for(let r=e.left;r<e.right;r++){const i=o*this.width+r,s=this.map[i];n[s]||(n[s]=!0,r==e.left&&r&&this.map[i-1]==s||o==e.top&&o&&this.map[i-this.width]==s||t.push(s))}return t}positionAt(e,t,n){for(let o=0,r=0;;o++){const i=r+n.child(o).nodeSize;if(o==e){let n=t+e*this.width;const o=(e+1)*this.width;for(;n<o&&this.map[n]<r;)n++;return n==o?i-1:this.map[n]}r=i}}static get(e){return ya(e)||wa(e,function(e){if("table"!=e.type.spec.tableRole)throw new RangeError("Not a table node: "+e.type.name);const t=function(e){let t=-1,n=!1;for(let o=0;o<e.childCount;o++){const r=e.child(o);let i=0;if(n)for(let t=0;t<o;t++){const n=e.child(t);for(let e=0;e<n.childCount;e++){const r=n.child(e);t+r.attrs.rowspan>o&&(i+=r.attrs.colspan)}}for(let e=0;e<r.childCount;e++){const t=r.child(e);i+=t.attrs.colspan,t.attrs.rowspan>1&&(n=!0)}-1==t?t=i:t!=i&&(t=Math.max(t,i))}return t}(e),n=e.childCount,o=[];let r=0,i=null;const s=[];for(let e=0,r=t*n;e<r;e++)o[e]=0;for(let l=0,a=0;l<n;l++){const c=e.child(l);a++;for(let e=0;;e++){for(;r<o.length&&0!=o[r];)r++;if(e==c.childCount)break;const d=c.child(e),{colspan:h,rowspan:p,colwidth:u}=d.attrs;for(let e=0;e<p;e++){if(e+l>=n){(i||(i=[])).push({type:"overlong_rowspan",pos:a,n:p-e});break}const c=r+e*t;for(let e=0;e<h;e++){0==o[c+e]?o[c+e]=a:(i||(i=[])).push({type:"collision",row:l,pos:a,n:h-e});const n=u&&u[e];if(n){const o=(c+e)%t*2,r=s[o];null==r||r!=n&&1==s[o+1]?(s[o]=n,s[o+1]=1):r==n&&s[o+1]++}}}r+=h,a+=d.nodeSize}const d=(l+1)*t;let h=0;for(;r<d;)0==o[r++]&&h++;h&&(i||(i=[])).push({type:"missing",row:l,n:h}),a++}0!==t&&0!==n||(i||(i=[])).push({type:"zero_sized"});const l=new va(t,n,o,i);let a=!1;for(let e=0;!a&&e<s.length;e+=2)null!=s[e]&&s[e+1]<n&&(a=!0);return a&&function(e,t,n){e.problems||(e.problems=[]);const o={};for(let r=0;r<e.map.length;r++){const i=e.map[r];if(o[i])continue;o[i]=!0;const s=n.nodeAt(i);if(!s)throw new RangeError(`No cell with offset ${i} found`);let l=null;const a=s.attrs;for(let n=0;n<a.colspan;n++){const o=t[(r+n)%e.width*2];null==o||a.colwidth&&a.colwidth[n]==o||((l||(l=ba(a)))[n]=o)}l&&e.problems.unshift({type:"colwidth mismatch",pos:i,colwidth:l})}}(l,s,e),l}(e))}};function ba(e){if(e.colwidth)return e.colwidth.slice();const t=[];for(let n=0;n<e.colspan;n++)t.push(0);return t}function ka(e,t){if("string"==typeof e)return{};const n=e.getAttribute("data-colwidth"),o=n&&/^\d+(,\d+)*$/.test(n)?n.split(",").map((e=>Number(e))):null,r=Number(e.getAttribute("colspan")||1),i={colspan:r,rowspan:Number(e.getAttribute("rowspan")||1),colwidth:o&&o.length==r?o:null};for(const n in t){const o=t[n].getFromDOM,r=o&&o(e);null!=r&&(i[n]=r)}return i}function xa(e,t){const n={};1!=e.attrs.colspan&&(n.colspan=e.attrs.colspan),1!=e.attrs.rowspan&&(n.rowspan=e.attrs.rowspan),e.attrs.colwidth&&(n["data-colwidth"]=e.attrs.colwidth.join(","));for(const o in t){const r=t[o].setDOMAttr;r&&r(e.attrs[o],n)}return n}function Sa(e){if(null!==e){if(!Array.isArray(e))throw new TypeError("colwidth must be null or an array");for(const t of e)if("number"!=typeof t)throw new TypeError("colwidth must be null or an array of numbers")}}function Ca(e){const t=e.cellAttributes||{},n={colspan:{default:1,validate:"number"},rowspan:{default:1,validate:"number"},colwidth:{default:null,validate:Sa}};for(const e in t)n[e]={default:t[e].default,validate:t[e].validate};return{table:{content:"table_row+",tableRole:"table",isolating:!0,group:e.tableGroup,parseDOM:[{tag:"table"}],toDOM:()=>["table",["tbody",0]]},table_row:{content:"(table_cell | table_header)*",tableRole:"row",parseDOM:[{tag:"tr"}],toDOM:()=>["tr",0]},table_cell:{content:e.cellContent,attrs:n,tableRole:"cell",isolating:!0,parseDOM:[{tag:"td",getAttrs:e=>ka(e,t)}],toDOM:e=>["td",xa(e,t),0]},table_header:{content:e.cellContent,attrs:n,tableRole:"header_cell",isolating:!0,parseDOM:[{tag:"th",getAttrs:e=>ka(e,t)}],toDOM:e=>["th",xa(e,t),0]}}}function Ma(e){let t=e.cached.tableNodeTypes;if(!t){t=e.cached.tableNodeTypes={};for(const n in e.nodes){const o=e.nodes[n],r=o.spec.tableRole;r&&(t[r]=o)}}return t}var Na=new Ct("selectingCells");function Oa(e){for(let t=e.depth-1;t>0;t--)if("row"==e.node(t).type.spec.tableRole)return e.node(0).resolve(e.before(t+1));return null}function Aa(e){const t=e.selection.$head;for(let e=t.depth;e>0;e--)if("row"==t.node(e).type.spec.tableRole)return!0;return!1}function Ta(e){const t=e.selection;if("$anchorCell"in t&&t.$anchorCell)return t.$anchorCell.pos>t.$headCell.pos?t.$anchorCell:t.$headCell;if("node"in t&&t.node&&"cell"==t.node.type.spec.tableRole)return t.$anchor;const n=Oa(t.$head)||function(e){for(let t=e.nodeAfter,n=e.pos;t;t=t.firstChild,n++){const o=t.type.spec.tableRole;if("cell"==o||"header_cell"==o)return e.doc.resolve(n)}for(let t=e.nodeBefore,n=e.pos;t;t=t.lastChild,n--){const o=t.type.spec.tableRole;if("cell"==o||"header_cell"==o)return e.doc.resolve(n-t.nodeSize)}}(t.$head);if(n)return n;throw new RangeError(`No cell found around position ${t.head}`)}function Da(e){return"row"==e.parent.type.spec.tableRole&&!!e.nodeAfter}function Ea(e){return e.node(0).resolve(e.pos+e.nodeAfter.nodeSize)}function Ra(e,t){return e.depth==t.depth&&e.pos>=t.start(-1)&&e.pos<=t.end(-1)}function $a(e){return va.get(e.node(-1)).findCell(e.pos-e.start(-1))}function Ia(e){return va.get(e.node(-1)).colCount(e.pos-e.start(-1))}function za(e,t,n){const o=e.node(-1),r=va.get(o),i=e.start(-1),s=r.nextCell(e.pos-i,t,n);return null==s?null:e.node(0).resolve(i+s)}function Ba(e,t,n=1){const o={...e,colspan:e.colspan-n};return o.colwidth&&(o.colwidth=o.colwidth.slice(),o.colwidth.splice(t,n),o.colwidth.some((e=>e>0))||(o.colwidth=null)),o}function Pa(e,t,n=1){const o={...e,colspan:e.colspan+n};if(o.colwidth){o.colwidth=o.colwidth.slice();for(let e=0;e<n;e++)o.colwidth.splice(t,0,0)}return o}function Va(e,t,n){const o=Ma(t.type.schema).header_cell;for(let r=0;r<e.height;r++)if(t.nodeAt(e.map[n+r*e.width]).type!=o)return!1;return!0}var Fa=class e extends nt{constructor(e,t=e){const n=e.node(-1),o=va.get(n),r=e.start(-1),i=o.rectBetween(e.pos-r,t.pos-r),s=e.node(0),l=o.cellsInRect(i).filter((e=>e!=t.pos-r));l.unshift(t.pos-r);const a=l.map((e=>{const t=n.nodeAt(e);if(!t)throw RangeError(`No cell with offset ${e} found`);const o=r+e+1;return new ot(s.resolve(o),s.resolve(o+t.content.size))}));super(a[0].$from,a[0].$to,a),this.$anchorCell=e,this.$headCell=t}map(t,n){const o=t.resolve(n.map(this.$anchorCell.pos)),r=t.resolve(n.map(this.$headCell.pos));if(Da(o)&&Da(r)&&Ra(o,r)){const t=this.$anchorCell.node(-1)!=o.node(-1);return t&&this.isRowSelection()?e.rowSelection(o,r):t&&this.isColSelection()?e.colSelection(o,r):new e(o,r)}return st.between(o,r)}content(){const e=this.$anchorCell.node(-1),t=va.get(e),n=this.$anchorCell.start(-1),o=t.rectBetween(this.$anchorCell.pos-n,this.$headCell.pos-n),r={},i=[];for(let n=o.top;n<o.bottom;n++){const l=[];for(let i=n*t.width+o.left,s=o.left;s<o.right;s++,i++){const n=t.map[i];if(r[n])continue;r[n]=!0;const s=t.findCell(n);let a=e.nodeAt(n);if(!a)throw RangeError(`No cell with offset ${n} found`);const c=o.left-s.left,d=s.right-o.right;if(c>0||d>0){let e=a.attrs;if(c>0&&(e=Ba(e,0,c)),d>0&&(e=Ba(e,e.colspan-d,d)),s.left<o.left){if(a=a.type.createAndFill(e),!a)throw RangeError(`Could not create cell with attrs ${JSON.stringify(e)}`)}else a=a.type.create(e,a.content)}if(s.top<o.top||s.bottom>o.bottom){const e={...a.attrs,rowspan:Math.min(s.bottom,o.bottom)-Math.max(s.top,o.top)};a=s.top<o.top?a.type.createAndFill(e):a.type.create(e,a.content)}l.push(a)}i.push(e.child(n).copy(s.from(l)))}const l=this.isColSelection()&&this.isRowSelection()?e:i;return new p(s.from(l),1,1)}replace(e,t=p.empty){const n=e.steps.length,o=this.ranges;for(let r=0;r<o.length;r++){const{$from:i,$to:s}=o[r],l=e.mapping.slice(n);e.replace(l.map(i.pos),l.map(s.pos),r?p.empty:t)}const r=nt.findFrom(e.doc.resolve(e.mapping.slice(n).map(this.to)),-1);r&&e.setSelection(r)}replaceWith(e,t){this.replace(e,new p(s.from(t),0,0))}forEachCell(e){const t=this.$anchorCell.node(-1),n=va.get(t),o=this.$anchorCell.start(-1),r=n.cellsInRect(n.rectBetween(this.$anchorCell.pos-o,this.$headCell.pos-o));for(let n=0;n<r.length;n++)e(t.nodeAt(r[n]),o+r[n])}isColSelection(){const e=this.$anchorCell.index(-1),t=this.$headCell.index(-1);if(Math.min(e,t)>0)return!1;const n=e+this.$anchorCell.nodeAfter.attrs.rowspan,o=t+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(n,o)==this.$headCell.node(-1).childCount}static colSelection(t,n=t){const o=t.node(-1),r=va.get(o),i=t.start(-1),s=r.findCell(t.pos-i),l=r.findCell(n.pos-i),a=t.node(0);return s.top<=l.top?(s.top>0&&(t=a.resolve(i+r.map[s.left])),l.bottom<r.height&&(n=a.resolve(i+r.map[r.width*(r.height-1)+l.right-1]))):(l.top>0&&(n=a.resolve(i+r.map[l.left])),s.bottom<r.height&&(t=a.resolve(i+r.map[r.width*(r.height-1)+s.right-1]))),new e(t,n)}isRowSelection(){const e=this.$anchorCell.node(-1),t=va.get(e),n=this.$anchorCell.start(-1),o=t.colCount(this.$anchorCell.pos-n),r=t.colCount(this.$headCell.pos-n);if(Math.min(o,r)>0)return!1;const i=o+this.$anchorCell.nodeAfter.attrs.colspan,s=r+this.$headCell.nodeAfter.attrs.colspan;return Math.max(i,s)==t.width}eq(t){return t instanceof e&&t.$anchorCell.pos==this.$anchorCell.pos&&t.$headCell.pos==this.$headCell.pos}static rowSelection(t,n=t){const o=t.node(-1),r=va.get(o),i=t.start(-1),s=r.findCell(t.pos-i),l=r.findCell(n.pos-i),a=t.node(0);return s.left<=l.left?(s.left>0&&(t=a.resolve(i+r.map[s.top*r.width])),l.right<r.width&&(n=a.resolve(i+r.map[r.width*(l.top+1)-1]))):(l.left>0&&(n=a.resolve(i+r.map[l.top*r.width])),s.right<r.width&&(t=a.resolve(i+r.map[r.width*(s.top+1)-1]))),new e(t,n)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(t,n){return new e(t.resolve(n.anchor),t.resolve(n.head))}static create(t,n,o=n){return new e(t.resolve(n),t.resolve(o))}getBookmark(){return new La(this.$anchorCell.pos,this.$headCell.pos)}};Fa.prototype.visible=!1,nt.jsonID("cell",Fa);var La=class e{constructor(e,t){this.anchor=e,this.head=t}map(t){return new e(t.map(this.anchor),t.map(this.head))}resolve(e){const t=e.resolve(this.anchor),n=e.resolve(this.head);return"row"==t.parent.type.spec.tableRole&&"row"==n.parent.type.spec.tableRole&&t.index()<t.parent.childCount&&n.index()<n.parent.childCount&&Ra(t,n)?new Fa(t,n):nt.near(n,1)}};function Ha(e){if(!(e.selection instanceof Fa))return null;const t=[];return e.selection.forEachCell(((e,n)=>{t.push(Cl.node(n,n+e.nodeSize,{class:"selectedCell"}))})),Ol.create(e.doc,t)}var _a=new Ct("fix-tables");function Wa(e,t,n,o){const r=e.childCount,i=t.childCount;e:for(let s=0,l=0;s<i;s++){const i=t.child(s);for(let t=l,o=Math.min(r,s+3);t<o;t++)if(e.child(t)==i){l=t+1,n+=i.nodeSize;continue e}o(i,n),l<r&&e.child(l).sameMarkup(i)?Wa(e.child(l),i,n+1,o):i.nodesBetween(0,i.content.size,o,n+1),n+=i.nodeSize}}function qa(e,t){let n;const o=(t,o)=>{"table"==t.type.spec.tableRole&&(n=function(e,t,n,o){const r=va.get(t);if(!r.problems)return o;o||(o=e.tr);const i=[];for(let e=0;e<r.height;e++)i.push(0);for(let e=0;e<r.problems.length;e++){const s=r.problems[e];if("collision"==s.type){const e=t.nodeAt(s.pos);if(!e)continue;const r=e.attrs;for(let e=0;e<r.rowspan;e++)i[s.row+e]+=s.n;o.setNodeMarkup(o.mapping.map(n+1+s.pos),null,Ba(r,r.colspan-s.n,s.n))}else if("missing"==s.type)i[s.row]+=s.n;else if("overlong_rowspan"==s.type){const e=t.nodeAt(s.pos);if(!e)continue;o.setNodeMarkup(o.mapping.map(n+1+s.pos),null,{...e.attrs,rowspan:e.attrs.rowspan-s.n})}else if("colwidth mismatch"==s.type){const e=t.nodeAt(s.pos);if(!e)continue;o.setNodeMarkup(o.mapping.map(n+1+s.pos),null,{...e.attrs,colwidth:s.colwidth})}else if("zero_sized"==s.type){const e=o.mapping.map(n);o.delete(e,e+t.nodeSize)}}let s,l;for(let e=0;e<i.length;e++)i[e]&&(null==s&&(s=e),l=e);for(let a=0,c=n+1;a<r.height;a++){const n=t.child(a),r=c+n.nodeSize,d=i[a];if(d>0){let t="cell";n.firstChild&&(t=n.firstChild.type.spec.tableRole);const i=[];for(let n=0;n<d;n++){const n=Ma(e.schema)[t].createAndFill();n&&i.push(n)}const h=0!=a&&s!=a-1||l!=a?r-1:c+1;o.insert(o.mapping.map(h),i)}c=r}return o.setMeta(_a,{fixTables:!0})}(e,t,o,n))};return t?t.doc!=e.doc&&Wa(t.doc,e.doc,0,o):e.doc.descendants(o),n}function ja(e){const t=e.selection,n=Ta(e),o=n.node(-1),r=n.start(-1),i=va.get(o);return{...t instanceof Fa?i.rectBetween(t.$anchorCell.pos-r,t.$headCell.pos-r):i.findCell(n.pos-r),tableStart:r,map:i,table:o}}function Ja(e,{map:t,tableStart:n,table:o},r){let i=r>0?-1:0;Va(t,o,r+i)&&(i=0==r||r==t.width?null:0);for(let s=0;s<t.height;s++){const l=s*t.width+r;if(r>0&&r<t.width&&t.map[l-1]==t.map[l]){const i=t.map[l],a=o.nodeAt(i);e.setNodeMarkup(e.mapping.map(n+i),null,Pa(a.attrs,r-t.colCount(i))),s+=a.attrs.rowspan-1}else{const a=null==i?Ma(o.type.schema).cell:o.nodeAt(t.map[l+i]).type,c=t.positionAt(s,r,o);e.insert(e.mapping.map(n+c),a.createAndFill())}}return e}function Ka(e,t){if(!Aa(e))return!1;if(t){const n=ja(e);t(Ja(e.tr,n,n.left))}return!0}function Xa(e,t){if(!Aa(e))return!1;if(t){const n=ja(e);t(Ja(e.tr,n,n.right))}return!0}function Ua(e,{map:t,table:n,tableStart:o},r){const i=e.mapping.maps.length;for(let s=0;s<t.height;){const l=s*t.width+r,a=t.map[l],c=n.nodeAt(a),d=c.attrs;if(r>0&&t.map[l-1]==a||r<t.width-1&&t.map[l+1]==a)e.setNodeMarkup(e.mapping.slice(i).map(o+a),null,Ba(d,r-t.colCount(a)));else{const t=e.mapping.slice(i).map(o+a);e.delete(t,t+c.nodeSize)}s+=d.rowspan}}function Ga(e,t){if(!Aa(e))return!1;if(t){const n=ja(e),o=e.tr;if(0==n.left&&n.right==n.map.width)return!1;for(let e=n.right-1;Ua(o,n,e),e!=n.left;e--){const e=n.tableStart?o.doc.nodeAt(n.tableStart-1):o.doc;if(!e)throw RangeError("No table found");n.table=e,n.map=va.get(e)}t(o)}return!0}function Ya(e,t,n){var o;const r=Ma(t.type.schema).header_cell;for(let i=0;i<e.width;i++)if((null==(o=t.nodeAt(e.map[i+n*e.width]))?void 0:o.type)!=r)return!1;return!0}function Qa(e,{map:t,tableStart:n,table:o},r){var i;let s=n;for(let e=0;e<r;e++)s+=o.child(e).nodeSize;const l=[];let a=r>0?-1:0;Ya(t,o,r+a)&&(a=0==r||r==t.height?null:0);for(let s=0,c=t.width*r;s<t.width;s++,c++)if(r>0&&r<t.height&&t.map[c]==t.map[c-t.width]){const r=t.map[c],i=o.nodeAt(r).attrs;e.setNodeMarkup(n+r,null,{...i,rowspan:i.rowspan+1}),s+=i.colspan-1}else{const e=null==a?Ma(o.type.schema).cell:null==(i=o.nodeAt(t.map[c+a*t.width]))?void 0:i.type,n=null==e?void 0:e.createAndFill();n&&l.push(n)}return e.insert(s,Ma(o.type.schema).row.create(null,l)),e}function Za(e,t){if(!Aa(e))return!1;if(t){const n=ja(e);t(Qa(e.tr,n,n.top))}return!0}function ec(e,t){if(!Aa(e))return!1;if(t){const n=ja(e);t(Qa(e.tr,n,n.bottom))}return!0}function tc(e,{map:t,table:n,tableStart:o},r){let i=0;for(let e=0;e<r;e++)i+=n.child(e).nodeSize;const s=i+n.child(r).nodeSize,l=e.mapping.maps.length;e.delete(i+o,s+o);const a=new Set;for(let i=0,s=r*t.width;i<t.width;i++,s++){const c=t.map[s];if(!a.has(c))if(a.add(c),r>0&&c==t.map[s-t.width]){const t=n.nodeAt(c).attrs;e.setNodeMarkup(e.mapping.slice(l).map(c+o),null,{...t,rowspan:t.rowspan-1}),i+=t.colspan-1}else if(r<t.height&&c==t.map[s+t.width]){const s=n.nodeAt(c),a=s.attrs,d=s.type.create({...a,rowspan:s.attrs.rowspan-1},s.content),h=t.positionAt(r+1,i,n);e.insert(e.mapping.slice(l).map(o+h),d),i+=a.colspan-1}}}function nc(e,t){if(!Aa(e))return!1;if(t){const n=ja(e),o=e.tr;if(0==n.top&&n.bottom==n.map.height)return!1;for(let e=n.bottom-1;tc(o,n,e),e!=n.top;e--){const e=n.tableStart?o.doc.nodeAt(n.tableStart-1):o.doc;if(!e)throw RangeError("No table found");n.table=e,n.map=va.get(n.table)}t(o)}return!0}function oc(e){const t=e.content;return 1==t.childCount&&t.child(0).isTextblock&&0==t.child(0).childCount}function rc(e,t){const n=e.selection;if(!(n instanceof Fa)||n.$anchorCell.pos==n.$headCell.pos)return!1;const o=ja(e),{map:r}=o;if(function({width:e,height:t,map:n},o){let r=o.top*e+o.left,i=r,s=(o.bottom-1)*e+o.left,l=r+(o.right-o.left-1);for(let t=o.top;t<o.bottom;t++){if(o.left>0&&n[i]==n[i-1]||o.right<e&&n[l]==n[l+1])return!0;i+=e,l+=e}for(let i=o.left;i<o.right;i++){if(o.top>0&&n[r]==n[r-e]||o.bottom<t&&n[s]==n[s+e])return!0;r++,s++}return!1}(r,o))return!1;if(t){const n=e.tr,i={};let l,a,c=s.empty;for(let e=o.top;e<o.bottom;e++)for(let t=o.left;t<o.right;t++){const s=r.map[e*r.width+t],d=o.table.nodeAt(s);if(!i[s]&&d)if(i[s]=!0,null==l)l=s,a=d;else{oc(d)||(c=c.append(d.content));const e=n.mapping.map(s+o.tableStart);n.delete(e,e+d.nodeSize)}}if(null==l||null==a)return!0;if(n.setNodeMarkup(l+o.tableStart,null,{...Pa(a.attrs,a.attrs.colspan,o.right-o.left-a.attrs.colspan),rowspan:o.bottom-o.top}),c.size){const e=l+1+a.content.size,t=oc(a)?l+1:e;n.replaceWith(t+o.tableStart,e+o.tableStart,c)}n.setSelection(new Fa(n.doc.resolve(l+o.tableStart))),t(n)}return!0}function ic(e,t){const n=Ma(e.schema);return sc((({node:e})=>n[e.type.spec.tableRole]))(e,t)}function sc(e){return(t,n)=>{var o;const r=t.selection;let i,s;if(r instanceof Fa){if(r.$anchorCell.pos!=r.$headCell.pos)return!1;i=r.$anchorCell.nodeAfter,s=r.$anchorCell.pos}else{if(i=function(e){for(let t=e.depth;t>0;t--){const n=e.node(t).type.spec.tableRole;if("cell"===n||"header_cell"===n)return e.node(t)}return null}(r.$from),!i)return!1;s=null==(o=Oa(r.$from))?void 0:o.pos}if(null==i||null==s)return!1;if(1==i.attrs.colspan&&1==i.attrs.rowspan)return!1;if(n){let o=i.attrs;const l=[],a=o.colwidth;o.rowspan>1&&(o={...o,rowspan:1}),o.colspan>1&&(o={...o,colspan:1});const c=ja(t),d=t.tr;for(let e=0;e<c.right-c.left;e++)l.push(a?{...o,colwidth:a&&a[e]?[a[e]]:null}:o);let h;for(let t=c.top;t<c.bottom;t++){let n=c.map.positionAt(t,c.left,c.table);t==c.top&&(n+=i.nodeSize);for(let o=c.left,r=0;o<c.right;o++,r++)o==c.left&&t==c.top||d.insert(h=d.mapping.map(n+c.tableStart,1),e({node:i,row:t,col:o}).createAndFill(l[r]))}d.setNodeMarkup(s,e({node:i,row:c.top,col:c.left}),l[0]),r instanceof Fa&&d.setSelection(new Fa(d.doc.resolve(r.$anchorCell.pos),h?d.doc.resolve(h):void 0)),n(d)}return!0}}function lc(e,t){return function(n,o){if(!Aa(n))return!1;const r=Ta(n);if(r.nodeAfter.attrs[e]===t)return!1;if(o){const i=n.tr;n.selection instanceof Fa?n.selection.forEachCell(((n,o)=>{n.attrs[e]!==t&&i.setNodeMarkup(o,null,{...n.attrs,[e]:t})})):i.setNodeMarkup(r.pos,null,{...r.nodeAfter.attrs,[e]:t}),o(i)}return!0}}function ac(e,t,n){const o=t.map.cellsInRect({left:0,top:0,right:"row"==e?t.map.width:1,bottom:"column"==e?t.map.height:1});for(let e=0;e<o.length;e++){const r=t.table.nodeAt(o[e]);if(r&&r.type!==n.header_cell)return!1}return!0}function cc(e,t){return(t=t||{useDeprecatedLogic:!1}).useDeprecatedLogic?function(e){return function(t,n){if(!Aa(t))return!1;if(n){const o=Ma(t.schema),r=ja(t),i=t.tr,s=r.map.cellsInRect("column"==e?{left:r.left,top:0,right:r.right,bottom:r.map.height}:"row"==e?{left:0,top:r.top,right:r.map.width,bottom:r.bottom}:r),l=s.map((e=>r.table.nodeAt(e)));for(let e=0;e<s.length;e++)l[e].type==o.header_cell&&i.setNodeMarkup(r.tableStart+s[e],o.cell,l[e].attrs);if(0==i.steps.length)for(let e=0;e<s.length;e++)i.setNodeMarkup(r.tableStart+s[e],o.header_cell,l[e].attrs);n(i)}return!0}}(e):function(t,n){if(!Aa(t))return!1;if(n){const o=Ma(t.schema),r=ja(t),i=t.tr,s=ac("row",r,o),l=ac("column",r,o),a=("column"===e?s:"row"===e&&l)?1:0,c="column"==e?{left:0,top:a,right:1,bottom:r.map.height}:"row"==e?{left:a,top:0,right:r.map.width,bottom:1}:r,d="column"==e?l?o.cell:o.header_cell:"row"==e?s?o.cell:o.header_cell:o.cell;r.map.cellsInRect(c).forEach((e=>{const t=e+r.tableStart,n=i.doc.nodeAt(t);n&&i.setNodeMarkup(t,d,n.attrs)})),n(i)}return!0}}var dc=cc("row",{useDeprecatedLogic:!0}),hc=cc("column",{useDeprecatedLogic:!0}),pc=cc("cell",{useDeprecatedLogic:!0});function uc(e){return function(t,n){if(!Aa(t))return!1;const o=function(e,t){if(t<0){const t=e.nodeBefore;if(t)return e.pos-t.nodeSize;for(let t=e.index(-1)-1,n=e.before();t>=0;t--){const o=e.node(-1).child(t),r=o.lastChild;if(r)return n-1-r.nodeSize;n-=o.nodeSize}}else{if(e.index()<e.parent.childCount-1)return e.pos+e.nodeAfter.nodeSize;const t=e.node(-1);for(let n=e.indexAfter(-1),o=e.after();n<t.childCount;n++){const e=t.child(n);if(e.childCount)return o+1;o+=e.nodeSize}}return null}(Ta(t),e);if(null==o)return!1;if(n){const e=t.doc.resolve(o);n(t.tr.setSelection(st.between(e,Ea(e))).scrollIntoView())}return!0}}function fc(e,t){const n=e.selection.$anchor;for(let o=n.depth;o>0;o--)if("table"==n.node(o).type.spec.tableRole)return t&&t(e.tr.delete(n.before(o),n.after(o)).scrollIntoView()),!0;return!1}function mc(e,t){const n=e.selection;if(!(n instanceof Fa))return!1;if(t){const o=e.tr,r=Ma(e.schema).cell.createAndFill().content;n.forEachCell(((e,t)=>{e.content.eq(r)||o.replace(o.mapping.map(t+1),o.mapping.map(t+e.nodeSize-1),new p(r,0,0))})),o.docChanged&&t(o)}return!0}function gc(e,t){const n=e.createAndFill();return new et(n).replace(0,n.content.size,t).doc}function yc(e,t,n,o,r,i,s,l){if(0==s||s==t.height)return!1;let a=!1;for(let c=r;c<i;c++){const r=s*t.width+c,i=t.map[r];if(t.map[r-t.width]==i){a=!0;const r=n.nodeAt(i),{top:d,left:h}=t.findCell(i);e.setNodeMarkup(e.mapping.slice(l).map(i+o),null,{...r.attrs,rowspan:s-d}),e.insert(e.mapping.slice(l).map(t.positionAt(s,h,n)),r.type.createAndFill({...r.attrs,rowspan:d+r.attrs.rowspan-s})),c+=r.attrs.colspan-1}}return a}function wc(e,t,n,o,r,i,s,l){if(0==s||s==t.width)return!1;let a=!1;for(let c=r;c<i;c++){const r=c*t.width+s,i=t.map[r];if(t.map[r-1]==i){a=!0;const r=n.nodeAt(i),d=t.colCount(i),h=e.mapping.slice(l).map(i+o);e.setNodeMarkup(h,null,Ba(r.attrs,s-d,r.attrs.colspan-(s-d))),e.insert(h+r.nodeSize,r.type.createAndFill(Ba(r.attrs,0,s-d))),c+=r.attrs.rowspan-1}}return a}function vc(e,t,n,o,r){let i=n?e.doc.nodeAt(n-1):e.doc;if(!i)throw new Error("No table found");let l=va.get(i);const{top:a,left:c}=o,d=c+r.width,h=a+r.height,u=e.tr;let f=0;function m(){if(i=n?u.doc.nodeAt(n-1):u.doc,!i)throw new Error("No table found");l=va.get(i),f=u.mapping.maps.length}(function(e,t,n,o,r,i,l){const a=Ma(e.doc.type.schema);let c,d;if(r>t.width)for(let i=0,s=0;i<t.height;i++){const h=n.child(i);s+=h.nodeSize;const p=[];let u;u=null==h.lastChild||h.lastChild.type==a.cell?c||(c=a.cell.createAndFill()):d||(d=a.header_cell.createAndFill());for(let e=t.width;e<r;e++)p.push(u);e.insert(e.mapping.slice(l).map(s-1+o),p)}if(i>t.height){const h=[];for(let e=0,o=(t.height-1)*t.width;e<Math.max(t.width,r);e++){const r=!(e>=t.width)&&n.nodeAt(t.map[o+e]).type==a.header_cell;h.push(r?d||(d=a.header_cell.createAndFill()):c||(c=a.cell.createAndFill()))}const p=a.row.create(null,s.from(h)),u=[];for(let e=t.height;e<i;e++)u.push(p);e.insert(e.mapping.slice(l).map(o+n.nodeSize-2),u)}return!(!c&&!d)})(u,l,i,n,d,h,f)&&m(),yc(u,l,i,n,c,d,a,f)&&m(),yc(u,l,i,n,c,d,h,f)&&m(),wc(u,l,i,n,a,h,c,f)&&m(),wc(u,l,i,n,a,h,d,f)&&m();for(let e=a;e<h;e++){const t=l.positionAt(e,c,i),o=l.positionAt(e,d,i);u.replace(u.mapping.slice(f).map(t+n),u.mapping.slice(f).map(o+n),new p(r.rows[e-a],0,0))}m(),u.setSelection(new Fa(u.doc.resolve(n+l.positionAt(a,c,i)),u.doc.resolve(n+l.positionAt(h-1,d-1,i)))),t(u)}var bc=ga({ArrowLeft:xc("horiz",-1),ArrowRight:xc("horiz",1),ArrowUp:xc("vert",-1),ArrowDown:xc("vert",1),"Shift-ArrowLeft":Sc("horiz",-1),"Shift-ArrowRight":Sc("horiz",1),"Shift-ArrowUp":Sc("vert",-1),"Shift-ArrowDown":Sc("vert",1),Backspace:mc,"Mod-Backspace":mc,Delete:mc,"Mod-Delete":mc});function kc(e,t,n){return!n.eq(e.selection)&&(t&&t(e.tr.setSelection(n).scrollIntoView()),!0)}function xc(e,t){return(n,o,r)=>{if(!r)return!1;const i=n.selection;if(i instanceof Fa)return kc(n,o,nt.near(i.$headCell,t));if("horiz"!=e&&!i.empty)return!1;const s=Oc(r,e,t);if(null==s)return!1;if("horiz"==e)return kc(n,o,nt.near(n.doc.resolve(i.head+t),t));{const r=n.doc.resolve(s),i=za(r,e,t);let l;return l=i?nt.near(i,1):t<0?nt.near(n.doc.resolve(r.before(-1)),-1):nt.near(n.doc.resolve(r.after(-1)),1),kc(n,o,l)}}}function Sc(e,t){return(n,o,r)=>{if(!r)return!1;const i=n.selection;let s;if(i instanceof Fa)s=i;else{const o=Oc(r,e,t);if(null==o)return!1;s=new Fa(n.doc.resolve(o))}const l=za(s.$headCell,e,t);return!!l&&kc(n,o,new Fa(s.$anchorCell,l))}}function Cc(e,t){const n=Oa(e.state.doc.resolve(t));return!!n&&(e.dispatch(e.state.tr.setSelection(new Fa(n))),!0)}function Mc(e,t,n){if(!Aa(e.state))return!1;let o=function(e){if(!e.size)return null;let{content:t,openStart:n,openEnd:o}=e;for(;1==t.childCount&&(n>0&&o>0||"table"==t.child(0).type.spec.tableRole);)n--,o--,t=t.child(0).content;const r=t.child(0),i=r.type.spec.tableRole,l=r.type.schema,a=[];if("row"==i)for(let e=0;e<t.childCount;e++){let r=t.child(e).content;const i=e?0:Math.max(0,n-1),s=e<t.childCount-1?0:Math.max(0,o-1);(i||s)&&(r=gc(Ma(l).row,new p(r,i,s)).content),a.push(r)}else{if("cell"!=i&&"header_cell"!=i)return null;a.push(n||o?gc(Ma(l).row,new p(t,n,o)).content:t)}return function(e,t){const n=[];for(let e=0;e<t.length;e++){const o=t[e];for(let t=o.childCount-1;t>=0;t--){const{rowspan:r,colspan:i}=o.child(t).attrs;for(let t=e;t<e+r;t++)n[t]=(n[t]||0)+i}}let o=0;for(let e=0;e<n.length;e++)o=Math.max(o,n[e]);for(let r=0;r<n.length;r++)if(r>=t.length&&t.push(s.empty),n[r]<o){const i=Ma(e).cell.createAndFill(),l=[];for(let e=n[r];e<o;e++)l.push(i);t[r]=t[r].append(s.from(l))}return{height:t.length,width:o,rows:t}}(l,a)}(n);const r=e.state.selection;if(r instanceof Fa){o||(o={width:1,height:1,rows:[s.from(gc(Ma(e.state.schema).cell,n))]});const t=r.$anchorCell.node(-1),i=r.$anchorCell.start(-1),l=va.get(t).rectBetween(r.$anchorCell.pos-i,r.$headCell.pos-i);return o=function({width:e,height:t,rows:n},o,r){if(e!=o){const t=[],r=[];for(let e=0;e<n.length;e++){const i=n[e],l=[];for(let n=t[e]||0,r=0;n<o;r++){let s=i.child(r%i.childCount);n+s.attrs.colspan>o&&(s=s.type.createChecked(Ba(s.attrs,s.attrs.colspan,n+s.attrs.colspan-o),s.content)),l.push(s),n+=s.attrs.colspan;for(let n=1;n<s.attrs.rowspan;n++)t[e+n]=(t[e+n]||0)+s.attrs.colspan}r.push(s.from(l))}n=r,e=o}if(t!=r){const e=[];for(let o=0,i=0;o<r;o++,i++){const l=[],a=n[i%t];for(let e=0;e<a.childCount;e++){let t=a.child(e);o+t.attrs.rowspan>r&&(t=t.type.create({...t.attrs,rowspan:Math.max(1,r-t.attrs.rowspan)},t.content)),l.push(t)}e.push(s.from(l))}n=e,t=r}return{width:e,height:t,rows:n}}(o,l.right-l.left,l.bottom-l.top),vc(e.state,e.dispatch,i,l,o),!0}if(o){const t=Ta(e.state),n=t.start(-1);return vc(e.state,e.dispatch,n,va.get(t.node(-1)).findCell(t.pos-n),o),!0}return!1}function Nc(e,t){var n;if(t.ctrlKey||t.metaKey)return;const o=Ac(e,t.target);let r;if(t.shiftKey&&e.state.selection instanceof Fa)i(e.state.selection.$anchorCell,t),t.preventDefault();else if(t.shiftKey&&o&&null!=(r=Oa(e.state.selection.$anchor))&&(null==(n=Tc(e,t))?void 0:n.pos)!=r.pos)i(r,t),t.preventDefault();else if(!o)return;function i(t,n){let o=Tc(e,n);const r=null==Na.getState(e.state);if(!o||!Ra(t,o)){if(!r)return;o=t}const i=new Fa(t,o);if(r||!e.state.selection.eq(i)){const n=e.state.tr.setSelection(i);r&&n.setMeta(Na,t.pos),e.dispatch(n)}}function s(){e.root.removeEventListener("mouseup",s),e.root.removeEventListener("dragstart",s),e.root.removeEventListener("mousemove",l),null!=Na.getState(e.state)&&e.dispatch(e.state.tr.setMeta(Na,-1))}function l(n){const r=n,l=Na.getState(e.state);let a;if(null!=l)a=e.state.doc.resolve(l);else if(Ac(e,r.target)!=o&&(a=Tc(e,t),!a))return s();a&&i(a,r)}e.root.addEventListener("mouseup",s),e.root.addEventListener("dragstart",s),e.root.addEventListener("mousemove",l)}function Oc(e,t,n){if(!(e.state.selection instanceof st))return null;const{$head:o}=e.state.selection;for(let r=o.depth-1;r>=0;r--){const i=o.node(r);if((n<0?o.index(r):o.indexAfter(r))!=(n<0?0:i.childCount))return null;if("cell"==i.type.spec.tableRole||"header_cell"==i.type.spec.tableRole){const i=o.before(r),s="vert"==t?n>0?"down":"up":n>0?"right":"left";return e.endOfTextblock(s)?i:null}}return null}function Ac(e,t){for(;t&&t!=e.dom;t=t.parentNode)if("TD"==t.nodeName||"TH"==t.nodeName)return t;return null}function Tc(e,t){const n=e.posAtCoords({left:t.clientX,top:t.clientY});return n&&n?Oa(e.state.doc.resolve(n.pos)):null}var Dc=class{constructor(e,t){this.node=e,this.defaultCellMinWidth=t,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.table.style.setProperty("--default-cell-min-width",`${t}px`),this.colgroup=this.table.appendChild(document.createElement("colgroup")),Ec(e,this.colgroup,this.table,t),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type==this.node.type&&(this.node=e,Ec(e,this.colgroup,this.table,this.defaultCellMinWidth),!0)}ignoreMutation(e){return"attributes"==e.type&&(e.target==this.table||this.colgroup.contains(e.target))}};function Ec(e,t,n,o,r,i){var s;let l=0,a=!0,c=t.firstChild;const d=e.firstChild;if(d){for(let e=0,n=0;e<d.childCount;e++){const{colspan:s,colwidth:h}=d.child(e).attrs;for(let e=0;e<s;e++,n++){const s=r==n?i:h&&h[e],d=s?s+"px":"";if(l+=s||o,s||(a=!1),c)c.style.width!=d&&(c.style.width=d),c=c.nextSibling;else{const e=document.createElement("col");e.style.width=d,t.appendChild(e)}}}for(;c;){const e=c.nextSibling;null==(s=c.parentNode)||s.removeChild(c),c=e}a?(n.style.width=l+"px",n.style.minWidth=""):(n.style.width="",n.style.minWidth=l+"px")}}var Rc=new Ct("tableColumnResizing");function $c({handleWidth:e=5,cellMinWidth:t=25,defaultCellMinWidth:n=100,View:o=Dc,lastColumnResizable:r=!0}={}){const i=new kt({key:Rc,state:{init(e,t){var r,s;const l=null==(s=null==(r=i.spec)?void 0:r.props)?void 0:s.nodeViews,a=Ma(t.schema).table.name;return o&&l&&(l[a]=(e,t)=>new o(e,n,t)),new Ic(-1,!1)},apply:(e,t)=>t.apply(e)},props:{attributes:e=>{const t=Rc.getState(e);return t&&t.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(t,n)=>{!function(e,t,n,o){if(!e.editable)return;const r=Rc.getState(e.state);if(r&&!r.dragging){const i=function(e){for(;e&&"TD"!=e.nodeName&&"TH"!=e.nodeName;)e=e.classList&&e.classList.contains("ProseMirror")?null:e.parentNode;return e}(t.target);let s=-1;if(i){const{left:o,right:r}=i.getBoundingClientRect();t.clientX-o<=n?s=zc(e,t,"left",n):r-t.clientX<=n&&(s=zc(e,t,"right",n))}if(s!=r.activeHandle){if(!o&&-1!==s){const t=e.state.doc.resolve(s),n=t.node(-1),o=va.get(n),r=t.start(-1);if(o.colCount(t.pos-r)+t.nodeAfter.attrs.colspan-1==o.width-1)return}Pc(e,s)}}}(t,n,e,r)},mouseleave:e=>{!function(e){if(!e.editable)return;const t=Rc.getState(e.state);t&&t.activeHandle>-1&&!t.dragging&&Pc(e,-1)}(e)},mousedown:(e,o)=>{!function(e,t,n,o){var r;if(!e.editable)return!1;const i=null!=(r=e.dom.ownerDocument.defaultView)?r:window,s=Rc.getState(e.state);if(!s||-1==s.activeHandle||s.dragging)return!1;const l=e.state.doc.nodeAt(s.activeHandle),a=function(e,t,{colspan:n,colwidth:o}){const r=o&&o[o.length-1];if(r)return r;const i=e.domAtPos(t);let s=i.node.childNodes[i.offset].offsetWidth,l=n;if(o)for(let e=0;e<n;e++)o[e]&&(s-=o[e],l--);return s/l}(e,s.activeHandle,l.attrs);function c(t){i.removeEventListener("mouseup",c),i.removeEventListener("mousemove",d);const o=Rc.getState(e.state);(null==o?void 0:o.dragging)&&(function(e,t,n){const o=e.state.doc.resolve(t),r=o.node(-1),i=va.get(r),s=o.start(-1),l=i.colCount(o.pos-s)+o.nodeAfter.attrs.colspan-1,a=e.state.tr;for(let e=0;e<i.height;e++){const t=e*i.width+l;if(e&&i.map[t]==i.map[t-i.width])continue;const o=i.map[t],d=r.nodeAt(o).attrs,h=1==d.colspan?0:l-i.colCount(o);if(d.colwidth&&d.colwidth[h]==n)continue;const p=d.colwidth?d.colwidth.slice():(c=d.colspan,Array(c).fill(0));p[h]=n,a.setNodeMarkup(s+o,null,{...d,colwidth:p})}var c;a.docChanged&&e.dispatch(a)}(e,o.activeHandle,Bc(o.dragging,t,n)),e.dispatch(e.state.tr.setMeta(Rc,{setDragging:null})))}function d(t){if(!t.which)return c(t);const r=Rc.getState(e.state);if(r&&r.dragging){const i=Bc(r.dragging,t,n);Vc(e,r.activeHandle,i,o)}}e.dispatch(e.state.tr.setMeta(Rc,{setDragging:{startX:t.clientX,startWidth:a}})),Vc(e,s.activeHandle,a,o),i.addEventListener("mouseup",c),i.addEventListener("mousemove",d),t.preventDefault()}(e,o,t,n)}},decorations:e=>{const t=Rc.getState(e);if(t&&t.activeHandle>-1)return function(e,t){var n;const o=[],r=e.doc.resolve(t),i=r.node(-1);if(!i)return Ol.empty;const s=va.get(i),l=r.start(-1),a=s.colCount(r.pos-l)+r.nodeAfter.attrs.colspan-1;for(let t=0;t<s.height;t++){const r=a+t*s.width;if(!(a!=s.width-1&&s.map[r]==s.map[r+1]||0!=t&&s.map[r]==s.map[r-s.width])){const t=s.map[r],a=l+t+i.nodeAt(t).nodeSize-1,c=document.createElement("div");c.className="column-resize-handle",(null==(n=Rc.getState(e))?void 0:n.dragging)&&o.push(Cl.node(l+t,l+t+i.nodeAt(t).nodeSize,{class:"column-resize-dragging"})),o.push(Cl.widget(a,c))}}return Ol.create(e.doc,o)}(e,t.activeHandle)},nodeViews:{}}});return i}var Ic=class e{constructor(e,t){this.activeHandle=e,this.dragging=t}apply(t){const n=this,o=t.getMeta(Rc);if(o&&null!=o.setHandle)return new e(o.setHandle,!1);if(o&&void 0!==o.setDragging)return new e(n.activeHandle,o.setDragging);if(n.activeHandle>-1&&t.docChanged){let o=t.mapping.map(n.activeHandle,-1);return Da(t.doc.resolve(o))||(o=-1),new e(o,n.dragging)}return n}};function zc(e,t,n,o){const r="right"==n?-o:o,i=e.posAtCoords({left:t.clientX+r,top:t.clientY});if(!i)return-1;const{pos:s}=i,l=Oa(e.state.doc.resolve(s));if(!l)return-1;if("right"==n)return l.pos;const a=va.get(l.node(-1)),c=l.start(-1),d=a.map.indexOf(l.pos-c);return d%a.width==0?-1:c+a.map[d-1]}function Bc(e,t,n){const o=t.clientX-e.startX;return Math.max(n,e.startWidth+o)}function Pc(e,t){e.dispatch(e.state.tr.setMeta(Rc,{setHandle:t}))}function Vc(e,t,n,o){const r=e.state.doc.resolve(t),i=r.node(-1),s=r.start(-1),l=va.get(i).colCount(r.pos-s)+r.nodeAfter.attrs.colspan-1;let a=e.domAtPos(r.start(-1)).node;for(;a&&"TABLE"!=a.nodeName;)a=a.parentNode;a&&Ec(i,a.firstChild,a,o,l,n)}function Fc({allowTableNodeSelection:e=!1}={}){return new kt({key:Na,state:{init:()=>null,apply(e,t){const n=e.getMeta(Na);if(null!=n)return-1==n?null:n;if(null==t||!e.docChanged)return t;const{deleted:o,pos:r}=e.mapping.mapResult(t);return o?null:r}},props:{decorations:Ha,handleDOMEvents:{mousedown:Nc},createSelectionBetween:e=>null!=Na.getState(e.state)?e.state.selection:null,handleTripleClick:Cc,handleKeyDown:bc,handlePaste:Mc},appendTransaction:(t,n,o)=>function(e,t,n){const o=(t||e).selection,r=(t||e).doc;let i,s;if(o instanceof at&&(s=o.node.type.spec.tableRole)){if("cell"==s||"header_cell"==s)i=Fa.create(r,o.from);else if("row"==s){const e=r.resolve(o.from+1);i=Fa.rowSelection(e,e)}else if(!n){const e=va.get(o.node),t=o.from+1,n=t+e.map[e.width*e.height-1];i=Fa.create(r,t+1,n)}}else o instanceof st&&function({$from:e,$to:t}){if(e.pos==t.pos||e.pos<t.pos-6)return!1;let n=e.pos,o=t.pos,r=e.depth;for(;r>=0&&!(e.after(r+1)<e.end(r));r--,n++);for(let e=t.depth;e>=0&&!(t.before(e+1)>t.start(e));e--,o--);return n==o&&/row|table/.test(e.node(r).type.spec.tableRole)}(o)?i=st.create(r,o.from):o instanceof st&&function({$from:e,$to:t}){let n,o;for(let t=e.depth;t>0;t--){const o=e.node(t);if("cell"===o.type.spec.tableRole||"header_cell"===o.type.spec.tableRole){n=o;break}}for(let e=t.depth;e>0;e--){const n=t.node(e);if("cell"===n.type.spec.tableRole||"header_cell"===n.type.spec.tableRole){o=n;break}}return n!==o&&0===t.parentOffset}(o)&&(i=st.create(r,o.$from.start(),o.$from.end()));return i&&(t||(t=e.tr)).setSelection(i),t}(o,qa(o,n),e)})}const Lc=["blockquote",0],Hc=["hr"],_c=["pre",["code",0]],Wc=["ol",0],qc=["ul",0],jc=["li",0],Jc=e=>{const t={},n=e.attributes;let o;for(let e=0;e<n.length;e++)o=n[e],t[o.name]=o.value;return t},Kc=e=>{const t={};return e.forEach((e=>{t[e]={default:null}})),t},Xc=()=>Kc(["style","class","id"]),Uc=(e,t)=>{for(const n in e)if(n&&null!==e[n]&&n!==t)return!0;return!1},Gc=(e,t=[])=>{const n={};for(const o in e)o&&null!==e[o]&&!t.find((e=>e===o))&&(n[o]=e[o]);return n},Yc=e=>({[e]:{name:e,inclusive:!0,parseDOM:[{tag:e}],toDOM:()=>[e,0]}}),Qc={link:{attrs:{...Xc(),href:{default:null},target:{default:null},title:{default:null}},inclusive:!1,parseDOM:[{tag:"a",getAttrs:Jc}],toDOM:e=>["a",Gc(e.attrs),0]},...Yc("strong"),...Yc("b"),...Yc("em"),...Yc("i"),...Yc("del"),...Yc("sub"),...Yc("sup"),...Yc("code"),style:{attrs:{...Xc()},parseDOM:[{tag:"span",getAttrs:Jc}],toDOM:e=>Uc(e.attrs)?["span",Gc(e.attrs),0]:["span",0]},...Yc("u")},Zc=e=>({[e]:{default:null,getFromDOM:t=>t.getAttribute(e),setDOMAttr:(t,n)=>{n[e]=t}}}),ed={...Zc("style"),...Zc("class"),...Zc("id"),...Zc("headers"),...Zc("scope")},td={doc:{content:"colgroup*"},col:{attrs:Kc(["id","class","style","span"]),parseDOM:[{getAttrs:Jc,tag:"col"}],toDOM:e=>["col",e.attrs]},colgroup:{attrs:Kc(["id","class","style","span"]),content:"col*",parseDOM:[{getAttrs:Jc,tag:"colgroup"}],toDOM:e=>["colgroup",e.attrs,0]},text:{inline:!0,group:"inline"}},nd=new U({nodes:td,marks:{}}),od=e=>{const t=Nn(Sn(e),nd,{preserveWhitespace:!1});return Mn(t).firstChild},rd=Ca({tableGroup:"block",cellContent:"block+",cellAttributes:ed});rd.table_row.attrs={...rd.table_row.attrs,...Kc([Mt,"style","class","id"])},rd.table_row.toDOM=e=>["tr",Gc(e.attrs),0],rd.table_row.parseDOM=[{tag:"tr",getAttrs:Jc}],rd.table.attrs={...rd.table.attrs,...Kc(["style","class","id",Nt,Ot])},rd.table.toDOM=e=>{const t=Uc(e.attrs)?Gc(e.attrs,[Nt,Ot]):{};let n=null;if(e.attrs[Nt]&&!(e=>{let t=!1;const n=e.child(0);for(let e=0;e<n.childCount;e++)if(n.child(e).attrs.colwidth){t=!0;break}return t})(e)){const t=od(e.attrs[Nt]);if(t){const e=Array.from(t.children).map((e=>["col",Jc(e)]));n=["colgroup",Jc(t)].concat(e)}}return n?["table",t,n,["tbody",0]]:["table",t,["tbody",0]]},rd.table.parseDOM=[{tag:"table",getAttrs:e=>{const t=Jc(e),n=Array.from(e.childNodes).find((e=>"COLGROUP"===e.nodeName));return n&&(t[Nt]=n.outerHTML),t}}];const id={doc:{content:"block+"},paragraph:{content:"inline*",group:"block",attrs:{...Xc()},parseDOM:[{tag:"p",getAttrs:Jc}],toDOM:e=>Uc(e.attrs)?["p",Gc(e.attrs),0]:["p",0]},table_wrapper:{content:"(table_caption_external | table)+",group:"block",defining:!0,attrs:{table:{default:null},style:{default:null}},parseDOM:[{tag:"div[table]",getAttrs:Jc}],toDOM:e=>Uc(e.attrs)?["div",Gc(e.attrs),0]:["div",0]},table_caption_external:{content:"inline+",group:"block",attrs:{caption:{default:null},...Xc()},parseDOM:[{tag:"div[caption]",getAttrs:Jc}],toDOM:e=>Uc(e.attrs)?["div",Gc(e.attrs),0]:["div",0]},div:{content:"block*",group:"block",attrs:{...Xc()},parseDOM:[{tag:"div",getAttrs:Jc}],toDOM:e=>Uc(e.attrs)?["div",Gc(e.attrs),0]:["div",0]},blockquote:{attrs:{...Xc()},content:"block+",group:"block",defining:!0,parseDOM:[{tag:"blockquote",getAttrs:Jc}],toDOM:e=>Uc(e.attrs)?["blockquote",Gc(e.attrs),0]:Lc},horizontal_rule:{group:"block",parseDOM:[{tag:"hr"}],toDOM:()=>Hc},heading:{attrs:{...Xc(),level:{default:1}},content:"inline*",group:"block",defining:!0,parseDOM:[{tag:"h1",getAttrs:e=>({...Jc(e),level:1})},{tag:"h2",getAttrs:e=>({...Jc(e),level:2})},{tag:"h3",getAttrs:e=>({...Jc(e),level:3})},{tag:"h4",getAttrs:e=>({...Jc(e),level:4})},{tag:"h5",getAttrs:e=>({...Jc(e),level:5})},{tag:"h6",getAttrs:e=>({...Jc(e),level:6})}],toDOM:e=>Uc(e.attrs,"level")?["h"+e.attrs.level,Gc(e.attrs,["level"]),0]:["h"+e.attrs.level,0]},code_block:{content:"text*",marks:"",group:"block",code:!0,defining:!0,parseDOM:[{tag:"pre",preserveWhitespace:"full"}],toDOM:()=>_c},text:{inline:!0,group:"inline"},image:{inline:!0,attrs:{src:{default:null},alt:{default:null},title:{default:null},width:{default:null},height:{default:null},...Xc()},group:"inline",draggable:!0,parseDOM:[{tag:"img",getAttrs:Jc}],toDOM:e=>Uc(e.attrs)?["img",Gc(e.attrs)]:["img"]},hard_break:{inline:!0,attrs:{...Xc()},group:"inline",selectable:!1,parseDOM:[{tag:"br",getAttrs:Jc}],toDOM:e=>Uc(e.attrs)?["br",Gc(e.attrs)]:["br"]},ordered_list:{content:"list_item+",group:"block",attrs:{...Xc(),type:{default:null},order:{default:1}},parseDOM:[{tag:"ol",getAttrs:e=>({...Jc(e),order:e.hasAttribute("start")?parseInt(e.getAttribute("start")||"1",10):1})}],toDOM:e=>1===e.attrs.order?Uc(e.attrs,"order")?["ol",Gc(e.attrs,["order"]),0]:Wc:["ol",{...Gc(e.attrs,["order"]),start:e.attrs.order},0]},bullet_list:{content:"list_item+",group:"block",attrs:{...Xc()},parseDOM:[{tag:"ul",getAttrs:Jc}],toDOM:e=>Uc(e.attrs)?["ul",Gc(e.attrs),0]:qc},list_item:{content:"(paragraph | heading) block*",attrs:{...Xc()},parseDOM:[{tag:"li",getAttrs:Jc}],toDOM:e=>Uc(e.attrs)?["li",Gc(e.attrs),0]:jc,defining:!0},...rd};var sd=200,ld=function(){};ld.prototype.append=function(e){return e.length?(e=ld.from(e),!this.length&&e||e.length<sd&&this.leafAppend(e)||this.length<sd&&e.leafPrepend(this)||this.appendInner(e)):this},ld.prototype.prepend=function(e){return e.length?ld.from(e).append(this):this},ld.prototype.appendInner=function(e){return new cd(this,e)},ld.prototype.slice=function(e,t){return void 0===e&&(e=0),void 0===t&&(t=this.length),e>=t?ld.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},ld.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},ld.prototype.forEach=function(e,t,n){void 0===t&&(t=0),void 0===n&&(n=this.length),t<=n?this.forEachInner(e,t,n,0):this.forEachInvertedInner(e,t,n,0)},ld.prototype.map=function(e,t,n){void 0===t&&(t=0),void 0===n&&(n=this.length);var o=[];return this.forEach((function(t,n){return o.push(e(t,n))}),t,n),o},ld.from=function(e){return e instanceof ld?e:e&&e.length?new ad(e):ld.empty};var ad=function(e){function t(t){e.call(this),this.values=t}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var n={length:{configurable:!0},depth:{configurable:!0}};return t.prototype.flatten=function(){return this.values},t.prototype.sliceInner=function(e,n){return 0==e&&n==this.length?this:new t(this.values.slice(e,n))},t.prototype.getInner=function(e){return this.values[e]},t.prototype.forEachInner=function(e,t,n,o){for(var r=t;r<n;r++)if(!1===e(this.values[r],o+r))return!1},t.prototype.forEachInvertedInner=function(e,t,n,o){for(var r=t-1;r>=n;r--)if(!1===e(this.values[r],o+r))return!1},t.prototype.leafAppend=function(e){if(this.length+e.length<=sd)return new t(this.values.concat(e.flatten()))},t.prototype.leafPrepend=function(e){if(this.length+e.length<=sd)return new t(e.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(t.prototype,n),t}(ld);ld.empty=new ad([]);var cd=function(e){function t(t,n){e.call(this),this.left=t,this.right=n,this.length=t.length+n.length,this.depth=Math.max(t.depth,n.depth)+1}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},t.prototype.getInner=function(e){return e<this.left.length?this.left.get(e):this.right.get(e-this.left.length)},t.prototype.forEachInner=function(e,t,n,o){var r=this.left.length;return!(t<r&&!1===this.left.forEachInner(e,t,Math.min(n,r),o))&&!(n>r&&!1===this.right.forEachInner(e,Math.max(t-r,0),Math.min(this.length,n)-r,o+r))&&void 0},t.prototype.forEachInvertedInner=function(e,t,n,o){var r=this.left.length;return!(t>r&&!1===this.right.forEachInvertedInner(e,t-r,Math.max(n,r)-r,o+r))&&!(n<r&&!1===this.left.forEachInvertedInner(e,Math.min(t,r),n,o))&&void 0},t.prototype.sliceInner=function(e,t){if(0==e&&t==this.length)return this;var n=this.left.length;return t<=n?this.left.slice(e,t):e>=n?this.right.slice(e-n,t-n):this.left.slice(e,n).append(this.right.slice(0,t-n))},t.prototype.leafAppend=function(e){var n=this.right.leafAppend(e);if(n)return new t(this.left,n)},t.prototype.leafPrepend=function(e){var n=this.left.leafPrepend(e);if(n)return new t(n,this.right)},t.prototype.appendInner=function(e){return this.left.depth>=Math.max(this.right.depth,e.depth)+1?new t(this.left,new t(this.right,e)):new t(this,e)},t}(ld);const dd=ld;class hd{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(0==this.eventCount)return null;let n,o,r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}t&&(n=this.remapping(r,this.items.length),o=n.maps.length);let i,s,l=e.tr,a=[],c=[];return this.items.forEach(((e,t)=>{if(!e.step)return n||(n=this.remapping(r,t+1),o=n.maps.length),o--,void c.push(e);if(n){c.push(new pd(e.map));let t,r=e.step.map(n.slice(o));r&&l.maybeStep(r).doc&&(t=l.mapping.maps[l.mapping.maps.length-1],a.push(new pd(t,void 0,void 0,a.length+c.length))),o--,t&&n.appendMap(t,o)}else l.maybeStep(e.step);return e.selection?(i=n?e.selection.map(n.slice(o)):e.selection,s=new hd(this.items.slice(0,r).append(c.reverse().concat(a)),this.eventCount-1),!1):void 0}),this.items.length,0),{remaining:s,transform:l,selection:i}}addTransform(e,t,n,o){let r=[],i=this.eventCount,s=this.items,l=!o&&s.length?s.get(s.length-1):null;for(let n=0;n<e.steps.length;n++){let a,c=e.steps[n].invert(e.docs[n]),d=new pd(e.mapping.maps[n],c,t);(a=l&&l.merge(d))&&(d=a,n?r.pop():s=s.slice(0,s.length-1)),r.push(d),t&&(i++,t=void 0),o||(l=d)}let a=i-n.depth;return a>fd&&(s=function(e,t){let n;return e.forEach(((e,o)=>{if(e.selection&&0==t--)return n=o,!1})),e.slice(n)}(s,a),i-=a),new hd(s.append(r),i)}remapping(e,t){let n=new ge;return this.items.forEach(((t,o)=>{let r=null!=t.mirrorOffset&&o-t.mirrorOffset>=e?n.maps.length-t.mirrorOffset:void 0;n.appendMap(t.map,r)}),e,t),n}addMaps(e){return 0==this.eventCount?this:new hd(this.items.append(e.map((e=>new pd(e)))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let n=[],o=Math.max(0,this.items.length-t),r=e.mapping,i=e.steps.length,s=this.eventCount;this.items.forEach((e=>{e.selection&&s--}),o);let l=t;this.items.forEach((t=>{let o=r.getMirror(--l);if(null==o)return;i=Math.min(i,o);let a=r.maps[o];if(t.step){let i=e.steps[o].invert(e.docs[o]),c=t.selection&&t.selection.map(r.slice(l+1,o));c&&s++,n.push(new pd(a,i,c))}else n.push(new pd(a))}),o);let a=[];for(let e=t;e<i;e++)a.push(new pd(r.maps[e]));let c=this.items.slice(0,o).append(a).append(n),d=new hd(c,s);return d.emptyItemCount()>500&&(d=d.compress(this.items.length-n.length)),d}emptyItemCount(){let e=0;return this.items.forEach((t=>{t.step||e++})),e}compress(e=this.items.length){let t=this.remapping(0,e),n=t.maps.length,o=[],r=0;return this.items.forEach(((i,s)=>{if(s>=e)o.push(i),i.selection&&r++;else if(i.step){let e=i.step.map(t.slice(n)),s=e&&e.getMap();if(n--,s&&t.appendMap(s,n),e){let l=i.selection&&i.selection.map(t.slice(n));l&&r++;let a,c=new pd(s.invert(),e,l),d=o.length-1;(a=o.length&&o[d].merge(c))?o[d]=a:o.push(c)}}else i.map&&n--}),this.items.length,0),new hd(dd.from(o.reverse()),r)}}hd.empty=new hd(dd.empty,0);class pd{constructor(e,t,n,o){this.map=e,this.step=t,this.selection=n,this.mirrorOffset=o}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new pd(t.getMap().invert(),t,this.selection)}}}class ud{constructor(e,t,n,o,r){this.done=e,this.undone=t,this.prevRanges=n,this.prevTime=o,this.prevComposition=r}}const fd=20;function md(e){let t=[];for(let n=e.length-1;n>=0&&0==t.length;n--)e[n].forEach(((e,n,o,r)=>t.push(o,r)));return t}function gd(e,t){if(!e)return null;let n=[];for(let o=0;o<e.length;o+=2){let r=t.map(e[o],1),i=t.map(e[o+1],-1);r<=i&&n.push(r,i)}return n}let yd=!1,wd=null;function vd(e){let t=e.plugins;if(wd!=t){yd=!1,wd=t;for(let e=0;e<t.length;e++)if(t[e].spec.historyPreserveItems){yd=!0;break}}return yd}function bd(e){return e.setMeta(xd,!0)}const kd=new Ct("history"),xd=new Ct("closeHistory");function Sd(e={}){return e={depth:e.depth||100,newGroupDelay:e.newGroupDelay||500},new kt({key:kd,state:{init:()=>new ud(hd.empty,hd.empty,null,0,-1),apply:(t,n,o)=>function(e,t,n,o){let r,i=n.getMeta(kd);if(i)return i.historyState;n.getMeta(xd)&&(e=new ud(e.done,e.undone,null,0,-1));let s=n.getMeta("appendedTransaction");if(0==n.steps.length)return e;if(s&&s.getMeta(kd))return s.getMeta(kd).redo?new ud(e.done.addTransform(n,void 0,o,vd(t)),e.undone,md(n.mapping.maps),e.prevTime,e.prevComposition):new ud(e.done,e.undone.addTransform(n,void 0,o,vd(t)),null,e.prevTime,e.prevComposition);if(!1===n.getMeta("addToHistory")||s&&!1===s.getMeta("addToHistory"))return(r=n.getMeta("rebased"))?new ud(e.done.rebased(n,r),e.undone.rebased(n,r),gd(e.prevRanges,n.mapping),e.prevTime,e.prevComposition):new ud(e.done.addMaps(n.mapping.maps),e.undone.addMaps(n.mapping.maps),gd(e.prevRanges,n.mapping),e.prevTime,e.prevComposition);{let r=n.getMeta("composition"),i=0==e.prevTime||!s&&e.prevComposition!=r&&(e.prevTime<(n.time||0)-o.newGroupDelay||!function(e,t){if(!t)return!1;if(!e.docChanged)return!0;let n=!1;return e.mapping.maps[0].forEach(((e,o)=>{for(let r=0;r<t.length;r+=2)e<=t[r+1]&&o>=t[r]&&(n=!0)})),n}(n,e.prevRanges)),l=s?gd(e.prevRanges,n.mapping):md(n.mapping.maps);return new ud(e.done.addTransform(n,i?t.selection.getBookmark():void 0,o,vd(t)),hd.empty,l,n.time,null==r?e.prevComposition:r)}}(n,o,t,e)},config:e,props:{handleDOMEvents:{beforeinput(e,t){let n=t.inputType,o="historyUndo"==n?Md:"historyRedo"==n?Nd:null;return!!o&&(t.preventDefault(),o(e.state,e.dispatch))}}}})}function Cd(e,t){return(n,o)=>{let r=kd.getState(n);if(!r||0==(e?r.undone:r.done).eventCount)return!1;if(o){let i=function(e,t,n){let o=vd(t),r=kd.get(t).spec.config,i=(n?e.undone:e.done).popEvent(t,o);if(!i)return null;let s=i.selection.resolve(i.transform.doc),l=(n?e.done:e.undone).addTransform(i.transform,t.selection.getBookmark(),r,o),a=new ud(n?l:i.remaining,n?i.remaining:l,null,0,-1);return i.transform.setSelection(s).setMeta(kd,{redo:n,historyState:a})}(r,n,e);i&&o(t?i.scrollIntoView():i)}return!0}}const Md=Cd(!1,!0),Nd=Cd(!0,!0),Od=Cd(!1,!1),Ad=Cd(!0,!1);function Td(e){let t=kd.getState(e);return t?t.done.eventCount:0}function Dd(e){let t=kd.getState(e);return t?t.undone.eventCount:0}class Ed{constructor(e,t,n={}){var o;this.match=e,this.match=e,this.handler="string"==typeof t?(o=t,function(e,t,n,r){let i=o;if(t[1]){let e=t[0].lastIndexOf(t[1]);i+=t[0].slice(e+t[1].length);let o=(n+=e)-r;o>0&&(i=t[0].slice(e-o,e)+i,n=r)}return e.tr.insertText(i,n,r)}):t,this.undoable=!1!==n.undoable,this.inCode=n.inCode||!1,this.inCodeMark=!1!==n.inCodeMark}}const Rd=500;function $d({rules:e}){let t=new kt({state:{init:()=>null,apply(e,t){return e.getMeta(this)||(e.selectionSet||e.docChanged?null:t)}},props:{handleTextInput:(n,o,r,i)=>Id(n,o,r,i,e,t),handleDOMEvents:{compositionend:n=>{setTimeout((()=>{let{$cursor:o}=n.state.selection;o&&Id(n,o.pos,o.pos,"",e,t)}))}}},isInputRules:!0});return t}function Id(e,t,n,o,r,i){if(e.composing)return!1;let s=e.state,l=s.doc.resolve(t),a=l.parent.textBetween(Math.max(0,l.parentOffset-Rd),l.parentOffset,null,"")+o;for(let c=0;c<r.length;c++){let d=r[c];if(!d.inCodeMark&&l.marks().some((e=>e.type.spec.code)))continue;if(l.parent.type.spec.code){if(!d.inCode)continue}else if("only"===d.inCode)continue;let h=d.match.exec(a);if(!h||h[0].length<o.length)continue;let p=t-(h[0].length-o.length);if(!d.inCodeMark){let e=!1;if(s.doc.nodesBetween(p,l.pos,(t=>{t.isInline&&t.marks.some((e=>e.type.spec.code))&&(e=!0)})),e)continue}let u=d.handler(s,h,p,n);if(u)return d.undoable&&u.setMeta(i,{transform:u,from:t,to:n,text:o}),e.dispatch(u),!0}return!1}const zd=(e,t)=>{let n=e.plugins;for(let o=0;o<n.length;o++){let r,i=n[o];if(i.spec.isInputRules&&(r=i.getState(e))){if(t){let n=e.tr,o=r.transform;for(let e=o.steps.length-1;e>=0;e--)n.step(o.steps[e].invert(o.docs[e]));if(r.text){let t=n.doc.resolve(r.from).marks();n.replaceWith(r.from,r.to,e.schema.text(r.text,t))}else n.delete(r.from,r.to);t(n)}return!0}}return!1},Bd=new Ed(/--$/,"—",{inCodeMark:!1}),Pd=new Ed(/\.\.\.$/,"…",{inCodeMark:!1}),Vd=new Ed(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,"“",{inCodeMark:!1}),Fd=new Ed(/"$/,"”",{inCodeMark:!1}),Ld=new Ed(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,"‘",{inCodeMark:!1}),Hd=new Ed(/'$/,"’",{inCodeMark:!1}),_d=[Vd,Fd,Ld,Hd];function Wd(e,t,n=null,o){return new Ed(e,((e,r,i,s)=>{let l=n instanceof Function?n(r):n,a=e.tr.delete(i,s),c=a.doc.resolve(i).blockRange(),d=c&&Ee(c,t,l);if(!d)return null;a.wrap(c,d);let h=a.doc.resolve(i-1).nodeBefore;return h&&h.type==t&&Be(a.doc,i-1)&&(!o||o(r,h))&&a.join(i-1),a}))}function qd(e,t,n=null){return new Ed(e,((e,o,r,i)=>{let s=e.doc.resolve(r),l=n instanceof Function?n(o):n;return s.node(-1).canReplaceWith(s.index(-1),s.indexAfter(-1),t)?e.tr.delete(r,i).setBlockType(r,r,t,l):null}))}const jd={mark:"strong",altMarks:["b"],altStyle:{name:"font-weight",value:/^(bold(er)?|[5-9]\d{2,})$/}},Jd={mark:"em",altMarks:["i"],altStyle:{name:"font-style",value:/^italic$/i}},Kd={mark:"u",altStyle:{name:"text-decoration",value:/^underline$/i}},Xd={mark:"del",altStyle:{name:"text-decoration",value:/^line-through$/i}},Ud={mark:"sub"},Gd={mark:"sup"},Yd={mark:"link"},Qd="undefined"!=typeof navigator&&/Mac/.test(navigator.platform),Zd=(e,t)=>{const n={},o=t&&t.applyToWord||!1;if(n["Mod-z"]=Md,n["Shift-Mod-z"]=Nd,n.Backspace=gr(zd,zo,Po,_o),n.Enter=gr(Yo,er,tr,rr),Qd||(n["Mod-y"]=Nd),e.marks.strong&&(n["Mod-b"]=sn(Yn,{...jd,applyToWord:o})),e.marks.em&&(n["Mod-i"]=sn(Yn,{...Jd,applyToWord:o})),e.marks.u&&(n["Mod-u"]=sn(Yn,{...Kd,applyToWord:o})),e.nodes.hard_break){const t=e.nodes.hard_break,o=gr(Zo,((e,n)=>(n(e.tr.replaceSelectionWith(t.create()).scrollIntoView()),!0)));n["Shift-Enter"]=o}return n},eh=e=>{const t={};var n;return e.nodes.list_item&&(t.Enter=(n=e.nodes.list_item,(e,t)=>No(n)(e,(n=>{const o=e.storedMarks||e.selection.$to.parentOffset&&e.selection.$from.marks();o&&n.ensureMarks(o),t(n)})))),t},th=/style=['"]?[^'"]*?mso-list:\s*[a-zA-Z]+(\d+)\s[a-zA-Z]+(\d+)\s(\w+)/gi,nh=e=>/^MsoListParagraph/.test(e.className),oh=e=>e.textContent,rh=(e,t)=>{const n=document.createElement(e);return n.style.listStyleType=t,n},ih=e=>{let t=null;return/^\d/.test(e)||(t=(/^[a-z]/.test(e)?"lower-":"upper-")+(/^[ivxlcdm]/i.test(e)?"roman":"alpha")),t},sh=(e,t)=>{let n=[];Array.from(e).forEach((e=>{if(e.nodeType!==Node.ELEMENT_NODE)return;const o=e;o.getAttribute("datalist")?(n.push(e),t.add(n)):nh(o)&&n.length?n.push(e):(n=[],"DIV"===o.nodeName?sh(o.children,t):"TABLE"===o.nodeName&&Array.from(o.querySelectorAll("td,th")).forEach((e=>{sh(e.children,t)})))}))},lh=e=>{const t=e.textContent,n=e=>e.replace(/^(?:&nbsp;|[\u00a0\n\r\s])+/,"");return/^[\u2022\u00b7\u00a7\u00d8oØüvn][\u00a0 ]+/.test(t)?{tag:"ul",style:(o=n(oh(e)),/^[\u2022\u00b7\u00FC\u00D8\u002dv-]/.test(o)?null:/^o/.test(o)?"circle":"square")}:/^\s*\w+[.)][\u00a0 ]{2,}/.test(t)?{tag:"ol",style:ih(n(oh(e)))}:void 0;var o},ah=e=>{const t=e.nodeName.toLowerCase();let n;e.firstChild&&e.firstChild.nodeType===Node.COMMENT_NODE&&e.removeChild(e.firstChild),1===e.childNodes.length?n=e.firstChild.nodeType===Node.TEXT_NODE?oh(e):e.firstChild.innerHTML.replace(/^\w+[.)](&nbsp;)+ /,""):(e.removeChild(e.firstChild),3===e.firstChild.nodeType&&/^[ivxlcdm]+\.$/i.test(e.firstChild.nodeValue)&&e.removeChild(e.firstChild),/^(&nbsp;|\s)+$/i.test(e.firstChild.innerHTML)&&e.removeChild(e.firstChild),n="p"!==t?"<"+t+">"+e.innerHTML+"</"+t+">":e.innerHTML),e.parentNode.removeChild(e);const o=document.createElement("li");return o.appendChild(Sn(n)),o},ch=e=>{const t=Sn((e=>e.replace(th,((e,t,n)=>`datalist="${t}" datalevel="${n}" ${e}`)))(e)),n=new Set;return sh(t.children,n),n.forEach((e=>(e=>{const t={};let n,o,r,i,s,l,a,c,d,h,p,u,f,m=-1;for(c=0;c<e.length;c++){d=e[c],f={datalist:d.getAttribute("datalist"),datalevel:d.getAttribute("datalevel")};const g=f.datalist,y=lh(d);if(h=y&&y.tag,!h){!n||s&&!nh(d)||(d.style.marginLeft&&(d.style.marginLeft=""),d.style.marginLeft&&(d.style.margin=""),n.appendChild(d));continue}if(p=f.datalevel||parseFloat(d.style.marginLeft||0),!f.datalevel&&!d.style.marginLeft)continue;const w=h+g;t[p]||(t[p]={}),(!o||o<0)&&(o=p,r=g,a=e.filter((e=>e.getAttribute("datalist")===String(r))),i=a[a.length-1],l=rh(h,y&&y.style),d.parentNode.insertBefore(l,d),m=p,t[p][w]=l),s=i===d,u=t[p][w],(p>m||!u)&&(u=rh(h,y&&y.style),t[p][w]=u,n.appendChild(u)),n=ah(d),u.appendChild(n),s?o=m=-1:m=p}})(e))),Cn(t)},dh=e=>{let t;e=(e=(e=(e=e.replace(/^[\s\S]+?<!--StartFragment-->\s*([\s\S]*?)\s*<!--EndFragment-->[\s\S]+$/,"$1")).replace(/<\/?[ovw]:[^>]*?>/gi,"")).replace(/<\\?\??xml[^>]*>/gi,"")).replace(/<(?:link|meta) [^>]+?>/gi,"");do{t=e,e=e.replace(/<style[^>]*?>\s*<\/style>/gi,"")}while(e!==t);return(e=(e=(e=(e=e.replace(/<\/?st1:.*?>/gi,"")).replace(/<a name="[a-zA-Z0-9_]+">/gim,"")).replace(/v:shapes?="[^"]+"/gi,"")).replace(/<!\[if !supportLists\]>/gi,"")).replace(/<!\[endif\]>/gi,"")},hh=(e,t)=>e.replace(new RegExp("<\\/?("+t+")(?:\\s[^>]*?)?>","gi"),""),ph=e=>{e.ownerElement&&e.ownerElement.removeAttribute(e.name)},uh=e=>{/^Mso/.test(e.value)&&ph(e)},fh=e=>{const t=ln(e.value),n=e.ownerElement.style;let o="";Object.keys(t).forEach((e=>{void 0!==n[e]&&(o+=`${e}: ${t[e]}; `)})),o=o.trim(),o?e.value=o:ph(e)},mh=(e,t)=>{let n=e;if(t.convertMsLists&&(n=ch(n)),t.stripTags&&(n=hh(n,t.stripTags)),t.attributes){const e=Sn(n);Array.from(e.querySelectorAll("*")).forEach((e=>((e,t)=>{if(e.nodeType===Node.ELEMENT_NODE){for(let n=e.attributes.length-1;n>=0;n--){const o=e.attributes[n];t[o.name]?t[o.name](o):t["*"]&&t["*"](o)}"SPAN"===e.nodeName&&0===e.attributes.length&&(e=>{const t=e.parentNode;if(t){for(;e.firstChild;)t.insertBefore(e.firstChild,e);t.removeChild(e)}})(e)}})(e,t.attributes))),n=Cn(e)}return n};function gh(e){const t=e.length,n=new Array(t/2);for(let o=0;o<t;o+=2)n[o]=String.fromCharCode(parseInt(e.substring(o,o+2),16));return btoa(n.join(""))}const yh=/<img\s[^>]*?src=(?:'|")file:\/[^'"]+(?:'|")[^>]*>/gi,wh=/{\\pict[\s\S]+?\\bliptag-?\d+(\\blipupi-?\d+)?({\\\*\\blipuid\s?[\da-fA-F]+)?[\s}]*?/,vh=new RegExp("(?:("+wh.source+"))([\\da-fA-F\\s]+)\\}","g"),bh=/[^\da-fA-F]/g,kh=/file:\/[^'"]+\.(jpg|png|gif)/i,xh=/\\(png|jpeg)blip\\/,Sh="text/rtf",Ch=(e,t)=>{const n=e.match(yh);if(!n||-1===t.types.indexOf(Sh))return e;const o=t.getData(Sh),r=[],i=o.match(vh);if(!o||!i)return e;for(const e of i){const t=xh.exec(e);if(t){const n=e.replace(wh,"").replace(bh,"");r.push(`data:image/${t[1]};base64,${gh(n)}`)}}return n.length!==r.length?e:e.replace(yh,(e=>{const t=r.shift()||"";return e.replace(kh,t)}))},Mh=(e,t,n,o,r)=>{const i=[];let s,l,a,c,d,h;const p=[],{matchCase:u,matchWord:f,useRegExp:m}=t,g=t.text;if(!g)return i;const y=u?"g":"gi",w=m?new RegExp(g,y):new RegExp(Rh(g),y);return e.nodesBetween(n,o,((t,u)=>{if(r(i))return!1;t.inlineContent&&u+t.content.size>=n&&(p.length=0,t.nodesBetween(0,t.content.size,((t,m,g,y)=>{if(r(i))return!1;const v=1+u+m;if(t.isText&&v+t.nodeSize>=n){if(d=t.text||"",h=g.childCount-1>=y+1&&g.child(y+1),p.push(n<=v?{text:d,start:v}:{text:d.slice(n-v),start:n}),h&&h.isText)return;for(l=p.map((e=>e.text)).join(""),s=w.exec(l);null!==s;){if(s[0].length>0){if(a=p[0].start+s.index,c=a+s[0].length,n<=a&&o>=c&&Eh(s,f)&&i.push(st.create(e,a,c)),r(i))break}else w.lastIndex++;s=w.exec(l)}}else p.length=0})))})),i},Nh=(e,t)=>{const{backward:n,matchCyclic:o,...r}=t,i=n?()=>!1:e=>e.length>0,{doc:s,selection:l}=e;let a=[];return n?(a=Mh(s,r,0,l.from,i),!a.length&&o&&(a=Mh(s,r,l.from,s.content.size,i))):(a=Mh(s,r,l.to,s.content.size,i),!a.length&&o&&(a=Mh(s,r,0,l.to,i))),a.length?a[a.length-1]:null},Oh=(e,t)=>Mh(e,t,0,e.content.size,(()=>!1)),Ah=(e,t,n)=>{const{from:o,to:r}=e;return n.insertText(t,o,r).setSelection(st.create(n.doc,o,o+t.length)),n},Th=(e,t,n)=>{const o=Oh(e.doc,n);if(0===o.length)return null;const r=e.tr;for(let e=o.length-1;e>=0;e--)r.insertText(t,o[e].from,o[e].to);return r},Dh=/^[\s0-9~`!@#$%^&*()_\-=+\\|[\]{};:'"?/.,<>]?$/,Eh=(e,t)=>{if(t){if(!0===t){const t=e.input,n=t.charAt(e.index-1),o=t.charAt(e.index+e[0].length);return Dh.test(n)&&Dh.test(o)}return t(e)}return!0},Rh=e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");function $h(e){const t={class:"k-placeholder","data-placeholder":e};return new kt({key:new Ct("placeholder"),props:{decorations:e=>{const{doc:n}=e,o=n.content.firstChild;if(!(0===n.childCount||1===n.childCount&&o.inlineContent&&0===o.childCount))return Ol.empty;const r=[];return n.descendants(((e,n)=>{r.push(Cl.node(n,n+e.nodeSize,t))})),Ol.create(n,r)}}})}const Ih=/\s+/g,zh=/text-align/,Bh=()=>new kt({key:new Ct("spaces-fix"),props:{decorations:e=>{const t=[],n=e.doc;let o,r,i,s;return n.nodesBetween(0,n.content.size,((e,n,l)=>{if(e.type.isText&&(e=>zh.test(e&&e.attrs&&e.attrs.style||""))(l))for(r=Ih.exec(e.text||"");null!==r;){if(o=n+r.index,i=r[0].length,r.index+i<r.input.length)for(s=0;s<=i-1;s+=2)t.push(Cl.inline(o+s,o+s+1,{style:"white-space: normal"}));r=Ih.exec(e.text||"")}})),Ol.create(n,t)}}}),Ph=(e,t)=>{for(const n in t)n&&dn(e,n,t[n])};class Vh{constructor(e,t,n,o=!1){this.node=e,this.view=t,this.dom=document.createElement(n),Ph(this.dom,e.attrs),this.contentDOM=o?void 0:this.dom}}class Fh{constructor(e,t){this.mark=e,this.view=t,this.dom=document.createElement("span"),Ph(this.dom,e.attrs),this.contentDOM=this.dom}}const Lh=()=>new kt({key:new Ct("csp-fix"),props:{nodeViews:{paragraph:(e,t)=>new Vh(e,t,"p"),div:(e,t)=>new Vh(e,t,"div"),table_wrapper:(e,t)=>new Vh(e,t,"div"),table_caption_external:(e,t)=>new Vh(e,t,"div"),table:(e,t)=>new Vh(e,t,"table"),table_row:(e,t)=>new Vh(e,t,"tr"),table_cell:(e,t)=>new Vh(e,t,"td"),table_header:(e,t)=>new Vh(e,t,"th"),image:(e,t)=>new Vh(e,t,"img",!0)},markViews:{style:(e,t)=>new Fh(e,t)}}}),Hh=new Ct("highlight");function _h(e=Hh){return new kt({key:e,state:{init:()=>null,apply(e){return e.getMeta(this.spec.key)}},props:{decorations(e){const t=(this.spec.key.getState(e)||[]).map((e=>Cl.inline(e.from,e.to,e.attrs)));return Ol.create(e.doc,t)}}})}const Wh={southeast:{x:1,y:1},east:{x:1,y:0},south:{x:0,y:1},north:{x:0,y:-1},west:{x:-1,y:0},southwest:{x:-1,y:1},northwest:{x:-1,y:-1},northeast:{x:1,y:-1}},qh=Object.keys(Wh),jh=new Ct("image-resize"),Jh=(e,t,n)=>{e.style[t]=n+"px"},Kh=/[^-]width:|[^-]height:/,Xh=/^.+$/;class Uh{constructor(e,t,n,o){this.activeHandle=e,this.dragging=t,this.rect=n,this.nodePosition=o}apply(e){const t=e.getMeta(jh);return t?new Uh(t.activeHandle,t.setDragging,t.rect,t.nodePosition):this}}const Gh=(e={node:"image",lockRatio:!0})=>new kt({key:jh,view:t=>({resize(){jh.getState(t.state).rect&&t.dispatch(t.state.tr.setMeta("resize",!0))},get window(){return t.dom.ownerDocument&&t.dom.ownerDocument.defaultView},attachResize(){const e=this.window;e&&(e.removeEventListener("resize",this.resize),e.addEventListener("resize",this.resize))},removeResize(){const e=this.window;e&&e.removeEventListener("resize",this.resize)},update(t,n){const o=t.state,r=o.selection,i=o.schema.nodes[e.node],s=jh.getState(o),l=s.rect;if(r instanceof at&&i===r.node.type){const e=t.nodeDOM(r.from),i={top:e.offsetTop,left:e.offsetLeft,width:e.offsetWidth,height:e.offsetHeight};if(!n.selection.eq(r)||l&&(l.width!==i.width||l.height!==i.height||l.top!==i.top||l.left!==i.left)){const e=o.tr;e.setMeta(jh,{rect:i,nodePosition:r.from}),t.dispatch(e),this.attachResize()}}else l&&(s.rect=null,s.nodePosition=-1)},destroy(){this.removeResize()}}),state:{init:()=>new Uh("",null,null,-1),apply:(e,t)=>t.apply(e)},props:{handleDOMEvents:{mousedown:(t,n)=>((e,t,n)=>{const o=t.target.getAttribute(Dt);if(!o)return!1;const r=jh.getState(e.state);t.preventDefault();const i=e.state.tr;function s(t){((e,t,n)=>{const o=jh.getState(e.state),{rect:r,dragging:i,nodePosition:s,activeHandle:l}=o;if(!i||!r)return;const a=e.nodeDOM(s),c=Wh[l],d=(t.clientX-i.startX)*c.x,h=(t.clientY-i.startY)*c.y;let p=c.x?d+a.width:r.width,u=c.y?h+a.height:r.height;if(n.lockRatio&&c.x&&c.y){const e=Math.min(p/a.width,u/a.height),n=a.width*e,o=a.height*e;i.startX=t.clientX-(p-n)*c.x,i.startY=t.clientY-(u-o)*c.y,p=n,u=o}else i.startX=c.x?t.clientX:i.startX,i.startY=c.y?t.clientY:i.startY;Jh(a,"width",p),Jh(a,"height",u),r.top=a.offsetTop,r.left=a.offsetLeft,r.width=a.offsetWidth,r.height=a.offsetHeight;const f=a.nextElementSibling;f.style.width=r.width+"px",f.style.height=r.height+"px",f.style.top=r.top+"px",f.style.left=r.left+"px"})(e,t,n)}return i.setMeta(jh,{setDragging:{startX:t.clientX,startY:t.clientY},activeHandle:o,rect:r.rect,nodePosition:r.nodePosition}),i.setMeta("addToHistory",!1),e.dispatch(i),t.view.addEventListener("mouseup",(function t(n){n.view.removeEventListener("mouseup",t),n.view.removeEventListener("mousemove",s),(e=>{const{rect:t,dragging:n,nodePosition:o}=jh.getState(e.state);if(n&&t){const n=e.state.selection;if(n instanceof at){const r=n.node.attrs,i=t.width,s=t.height;let l;if(Kh.test(r.style||"")){const e=qt(r.style,{style:"width",value:Xh,newValue:i+"px"}),{style:t}=qt(e.style||"",{style:"height",value:Xh,newValue:s+"px"});l={...r,style:t}}else l={...r,width:i,height:s};const a=n.node.type.createAndFill(l);if(a){const n=e.state.tr;n.replaceWith(o,o+1,a),n.setSelection(at.create(n.doc,o)),n.setMeta("commandName","image-resize"),n.setMeta("args",l),n.setMeta(jh,{setDragging:null,activeHandle:null,rect:t,nodePosition:o}),e.dispatch(n)}}}})(e)})),t.view.addEventListener("mousemove",s),!0})(t,n,e)},decorations(t){const n=t.selection,o=t.schema.nodes[e.node],r=jh.getState(t).rect;if(r&&n instanceof at&&o===n.node.type){const e=document.createElement("div");e.className="k-editor-resize-handles-wrapper",e.style.width=r.width+"px",e.style.height=r.height+"px",e.style.top=r.top+"px",e.style.left=r.left+"px";for(let t=0;t<qh.length;t++){const n=document.createElement("div");n.className=At+" "+qh[t],n.setAttribute(Dt,qh[t]),e.appendChild(n)}return Ol.create(t.doc,[Cl.widget(t.selection.from+1,e)])}return Ol.empty}}}),Yh=new Ct("caret-color");function Qh(){return new kt({key:Yh,props:{decorations:e=>{const{doc:t,selection:n,storedMarks:o}=e;if(!n.empty||!o)return Ol.empty;const r=Wn((o||[]).find((e=>"style"===e.type.name)),{name:"color",value:/^.+$/});if(!r)return Ol.empty;const i=n.$anchor.parent,s=[];return t.descendants(((e,t)=>{e.eq(i)&&s.push(Cl.node(t,t+e.nodeSize,{style:"caret-color: "+r}))})),Ol.create(t,s)}}})}class Zh{constructor(e,t){this.node=e,this.view=t,this.dom=document.createElement("div"),this.dom.className="k-editor-resize-wrap-element",this.table=this.dom.appendChild(document.createElement("table")),e.attrs[Nt]&&this.renderColgroup(e.attrs[Nt]);const n=this.table.appendChild(document.createElement("tbody"));this.setAttributes(this.table,e.attrs),this.resizeHandles=qh.map((e=>{const t=document.createElement("span");return t.className=At+" "+e,t.setAttribute(Tt,e),t})),this.contentDOM=n}update(e){if(e.type!==this.node.type)return!1;const t=this.node;return this.node=e,e.attrs[Ot]?this.resizeHandles.forEach((e=>{this.dom.appendChild(e)})):Array.from(this.dom.children).filter((e=>e.classList.contains(At))).forEach((e=>e.remove())),this.setAttributes(this.table,e.attrs),t.attrs[Nt]!==e.attrs[Nt]&&this.renderColgroup(e.attrs[Nt]),!0}ignoreMutation(e){return"attributes"===e.type&&(e.target===this.table||e.target.firstChild===this.table||this.colgroup&&this.colgroup.contains(e.target))}destroy(){this.node=void 0,this.view=void 0,this.table=void 0,this.colgroup=void 0,this.resizeHandles=void 0}renderColgroup(e){this.table&&this.table.firstChild&&"COLGROUP"===this.table.firstChild.nodeName&&this.table.removeChild(this.table.firstChild),e&&(this.colgroup=od(e),this.table.insertBefore(this.colgroup,this.table.firstChild))}setAttributes(e,t){const n=[Nt,Ot];for(const o in t)o&&-1===n.indexOf(o)&&dn(e,o,t[o]);/%$/.test(e.style.width)?(this.dom.style.width=e.style.width,e.style.width=""):this.dom.style.width=""}}class ep{constructor(e,t){this.node=e,this.view=t,this.dom=document.createElement("div"),this.setAttributes(this.dom,e.attrs),this.contentDOM=this.dom}update(e){return e.type===this.node.type&&(this.node=e,this.setAttributes(this.dom,e.attrs),!0)}ignoreMutation(e){return"attributes"===e.type&&"style"===e.attributeName}destroy(){this.node=void 0,this.view=void 0}setAttributes(e,t){for(const n in t)n&&dn(e,n,t[n]);if(e.setAttribute("table",""),/%/.test(e.style.width)){const t=this.node&&this.node.lastChild,n=(t?ln(t.attrs.style):{}).width||"";n&&!/%/.test(n)&&(e.style.width="")}}}const tp=new Ct("table-resize"),np=new Ct("table-column-resizing"),op=new Ct("table-row-resizing");function rp(e,t){let n=!1;return n=n||e!==tp&&Boolean(tp.get(t))&&tp.getState(t).dragging,n=n||e!==np&&Boolean(np.get(t))&&np.getState(t).dragging,n=n||e!==op&&Boolean(op.get(t))&&op.getState(t).dragging,n}function ip(e,t){let n=!1;return n=n||e!==np&&Boolean(np.get(t))&&np.getState(t).activeHandle>-1,n=n||e!==op&&Boolean(op.get(t))&&op.getState(t).activeHandle>-1,n}function sp(e){return e&&e.firstChild&&"TABLE"===e.firstChild.nodeName?e.firstChild:e}function lp(e){for(;e&&"TD"!==e.nodeName&&"TH"!==e.nodeName;)e=e.classList.contains("ProseMirror")?null:e.parentNode;return e}function ap(e){const t=function(e){const t=Array.from(e&&e.rows||[]),n=Array.from(t&&t[0]&&t[0].cells||[]).map((e=>e.colSpan)).reduce(((e,t)=>e+t),0),o=t.map((()=>new Array(n)));return t.forEach(((e,t)=>{let n=0;Array.from(e.cells).forEach((e=>{for(let r=0;r<e.colSpan;r++){for(let r=0;r<e.rowSpan;r++){const i=o[t+r].findIndex(((e,t)=>t>=n&&!e));o[t+r][i]=e}n++}}))})),o}(e.closest("table"));let n=null;for(let o=0;o<t.length&&(t[o].forEach(((t,r)=>{e===t&&(n={rowIndex:o,cellIndex:r})})),!n);o++);return n||{rowIndex:-1,cellIndex:-1}}function cp(e,t,n){const o=e.posAtCoords({left:t.clientX,top:t.clientY});if(!o)return-1;const r=e.state.doc.resolve(o.pos),i=Gt(r,(e=>"table"===e.type.spec.tableRole));if(null===i)return-1;const s=r.start(i.depth),l=i.node,a=va.get(l);return s+a.map[a.width*n.rowIndex+n.cellIndex]}function dp(e){const t=Array.from(e&&e.children||[]);let n=!1;return t.forEach((t=>{for(;t.span>1;){const o=t.cloneNode();o.span=1,e.insertBefore(o,t),t.span-=1,n=!0}})),n}function hp(){const e=new kt({key:np,state:{init:()=>new pp(-1,null),apply:(e,t)=>t.apply(e)},props:{attributes:e=>ip(np,e)?null:np.getState(e).activeHandle>-1?{class:"resize-cursor"}:null,handleDOMEvents:{mousemove:(e,t)=>(rp(np,e.state)||function(e,t){const n=np.getState(e.state);if(!n.dragging){const o=lp(t.target);let r=-1;if(o){const n=ap(o),{left:i,right:s}=o.getBoundingClientRect();Math.abs(t.clientX-i)<=5&&n.cellIndex>0?(n.cellIndex-=o.colSpan,r=cp(e,t,n)):s-t.clientX>0&&s-t.clientX<=5&&(r=cp(e,t,n))}r!==n.activeHandle&&up(e,r)}}(e,t),!1),mouseleave:e=>(function(e){const t=np.getState(e.state);t.activeHandle>-1&&!t.dragging&&up(e,-1)}(e),!1),mousedown:(e,t)=>function(e,t){const n=np.getState(e.state);if(-1===n.activeHandle||n.dragging)return!1;const o=e.state.doc.resolve(n.activeHandle),r=o.parent,i=o.index();let s=0;for(let e=0;e<=i;e++)s+=r.child(e).attrs.colspan;const l=o.node(o.depth-1),a=e.domAtPos(n.activeHandle),c=a.node.childNodes[a.offset].closest("table");let d,h;if(l.attrs[Nt]){const e=c.firstChild;dp(e)&&(h={...l.attrs,[Nt]:e.outerHTML}),d=e.children[s-1],d.style.width||(d.style.width=d.offsetWidth+"px")}else{let e=0;for(let t=0;t<r.childCount;t++)e+=r.child(t).attrs.colspan;const t=document.createElement("colgroup"),n=new Array(e);for(let o=0;o<e;o++)n[o]=document.createElement("col"),t.appendChild(n[o]);c.insertBefore(t,c.firstChild),d=n[i],d.style.width=d.offsetWidth+"px",h={...l.attrs,[Nt]:"<colgroup>"+n.reduce(((e,t)=>e+t.outerHTML),"")+"</colgroup>"}}const p=parseFloat(d.style.width),u=e.state.tr.setMeta(np,{setDragging:{startX:t.clientX,startWidth:p}});if(!c.style.width){const e=Array.from(d.parentNode.children).map((e=>e.style.width));if(e.every(Boolean)){const t=e.reduce(((e,t)=>e+parseFloat(t)),0);h=Jt(h||l.attrs,"width",t+"px")}}if(h){const e=o.posAtIndex(0,o.depth-1)-1;u.setNodeMarkup(e,null,h)}function f(t){t.view.removeEventListener("mouseup",f),t.view.removeEventListener("mousemove",m);const n=np.getState(e.state);if(n.dragging){const t=e.state.tr;!function(e,t,n){const o=e.state.doc.resolve(n),r=o.node(-1),i=o.start(-1),s=o.posAtIndex(0,o.depth-1)-1,l=e.nodeDOM(i).closest("table");let a=r.attrs;if(r&&a[Nt]){const e=l.firstChild;a={...a,[Nt]:e.outerHTML}}const c=l.style.width;l&&c&&ln(a.style).width!==c&&(a=Jt(a,"width",c)),t.setNodeMarkup(s,null,a)}(e,t,n.activeHandle),e.dispatch(t.setMeta(np,{setDragging:null}))}}function m(t){if(!t.which)return f(t);const n=np.getState(e.state),o=function(e,t){const n=t.clientX-e.startX;return Math.max(25,e.startWidth+n)}(n.dragging,t);!function(e,t,n){const o=e.state.doc.resolve(t),r=o.node(-1),i=o.start(-1),s=va.get(r).colCount(o.pos-i)+o.nodeAfter.attrs.colspan-1;let l=e.domAtPos(o.start(-1)).node;"TABLE"!==l.nodeName&&(l=l.closest("table"));const a=l,c=a.firstChild,d=Array.from(c.children);if(d[s].style.width=n+"px",a.style.width){const e=d.map((e=>e.style.width));if(e.every(Boolean)){const t=e.reduce(((e,t)=>e+parseFloat(t)),0);a.style.width=t+"px"}}}(e,n.activeHandle,o)}return e.dispatch(u),t.view.addEventListener("mouseup",f),t.view.addEventListener("mousemove",m),t.preventDefault(),!0}(e,t)},decorations(e){if(!rp(np,e)){const t=np.getState(e);if(t.activeHandle>-1)return function(e,t){const n=[],o=e.doc.resolve(t),r=o.node(-1),i=va.get(r),s=o.start(-1),l=[],a=t-s;let c=-1;for(let e=0;e<i.height;e++)l.push(i.map.slice(e*i.width,e*i.width+i.width)),-1===c&&(c=l[e].lastIndexOf(a));const d=[];return l.forEach((e=>{const t=e[c];e[c]!==e[c+1]&&d.push(t)})),d.forEach((e=>{const t=s+e+r.nodeAt(e).nodeSize-1,o=document.createElement("div");o.className="column-resize-handle",n.push(Cl.widget(t,o))})),Ol.create(e.doc,n)}(e,t.activeHandle)}return Ol.empty},nodeViews:{table_wrapper:(e,t)=>new ep(e,t),table:(e,t)=>new Zh(e,t)}}});return e}class pp{constructor(e,t){this.activeHandle=e,this.dragging=t}apply(e){let t;const n=e.getMeta(np);if(n&&null!=n.setHandle)return new pp(n.setHandle,null);if(n&&void 0!==n.setDragging)return new pp(this.activeHandle,n.setDragging);if(this.activeHandle>-1&&e.docChanged){let n=e.mapping.map(this.activeHandle,-1);o=e.doc.resolve(n),Boolean("row"===o.parent.type.spec.tableRole&&o.nodeAfter)||(n=-1),t=new pp(n,this.dragging)}var o;return t||this}}function up(e,t){const n=e.state.tr;n.setMeta("addToHistory",!1),n.setMeta(np,{setHandle:t}),e.dispatch(n)}const fp={southeast:!0,southwest:!0,northwest:!0,northeast:!0},mp={east:!0,west:!0,...fp},gp={south:!0,north:!0,...fp};class yp{constructor(e,t,n){this.activeHandle=e,this.dragging=t,this.nodePosition=n}apply(e){const t=e.getMeta(tp);return t?new yp(t.activeHandle,t.setDragging,t.nodePosition):this}}const wp=e=>{const t=Array.from(e.firstChild.children).map((e=>e.offsetWidth)),n=Array.from(e.rows).map((e=>e.offsetHeight)),o=t.reduce(((e,t)=>e+t),0),r=n.reduce(((e,t)=>e+t),0),i=e.offsetHeight;return{width:o,height:r,colsWidth:t,rowsHeight:n,offsetWidth:e.offsetWidth,offsetHeight:i}},vp=(e,t)=>{const n=t.target.getAttribute(Tt);if(!n)return!1;const o=tp.getState(e.state);t.preventDefault();const r=e.state.tr;r.setMeta(tp,{setDragging:{startX:t.clientX,startY:t.clientY},activeHandle:n,nodePosition:o.nodePosition}),r.setMeta("addToHistory",!1),((e,t,n)=>{const o=e.state.doc.nodeAt(n),r=sp(e.nodeDOM(n)),i=r.firstChild;let s=dp(i);const{width:l,height:a,colsWidth:c,rowsHeight:d,offsetWidth:h,offsetHeight:p}=wp(r);Array.from(i&&i.children||[]).forEach(((e,t)=>{e.style.width&&!/%$/.test(e.style.width)&&(e.style.width=100*c[t]/l+"%",s=!0)}));let u=!1;o.forEach(((e,o,r)=>{const i=ln(e.attrs.style).height;i&&!/%$/.test(i)&&(t.setNodeMarkup(n+o+1,null,Jt(e.attrs,"height",100*d[r]/a+"%")),u=!0)}));let f=o.attrs;ln(f.style).width!==h+"px"&&(f=Jt(f,"width",h+"px")),s&&(f[Nt]=i.outerHTML),u&&(f=Jt(f,"height",p+"px")),(s||u)&&t.setNodeMarkup(n,null,f)})(e,r,o.nodePosition),e.dispatch(r);const i=t.view||window;function s(t){((e,t)=>{var n;const o=tp.getState(e.state),{dragging:r,nodePosition:i,activeHandle:s}=o;if(i<0||!r)return;const l=sp(e.nodeDOM(i)),a=l.getBoundingClientRect(),c=Wh[s],d=(t.clientX-r.startX)*c.x,h=(t.clientY-r.startY)*c.y,p=(l.ownerDocument&&l.ownerDocument.defaultView||window).getComputedStyle(l),u=/px/.test(p.width)?parseFloat(p.width):l.offsetWidth,f=/px/.test(p.height)?parseFloat(p.height):l.offsetHeight,m=c.x?d+u:a.width,g=c.y?h+f:a.height;if(r.startX=c.x?t.clientX:r.startX,r.startY=c.y?t.clientY:r.startY,mp[s]&&(l.style.width=m+"px"),gp[s]&&(l.style.height=g+"px"),/px/.test(l.style.width)){const e=null===(n=l.parentNode)||void 0===n?void 0:n.parentNode;e instanceof HTMLDivElement&&e.matches("div[table]")&&/%/.test(e.style.width)&&(e.style.width="")}})(e,t)}return i.addEventListener("mouseup",(function t(){i.removeEventListener("mouseup",t),i.removeEventListener("mousemove",s),(e=>{const{dragging:t,nodePosition:n,activeHandle:o}=tp.getState(e.state);if(t){const t=e.state.doc.nodeAt(n),r=sp(e.nodeDOM(n)),i=wp(r);if(t){const s=i.offsetWidth+"px",l=i.offsetHeight+"px",a=e.state.tr;let c=t.attrs;const d=ln(c.style);if(mp[o]&&r.style.width&&d.width!==s&&(c=Jt(c,"width",s)),gp[o]&&r.style.height&&d.height!==l&&(c=Jt(c,"height",l)),c=((e,t,n,o)=>{const r=e.state.doc.nodeAt(n),i=sp(e.nodeDOM(n)),s=(i.ownerDocument&&i.ownerDocument.defaultView||window).getComputedStyle,l=Array.from(i.rows);r.forEach(((e,o,r)=>{const i=ln(e.attrs.style).height;i&&!/px$/.test(i)&&t.setNodeMarkup(n+o+1,null,Jt(e.attrs,"height",s(l[r]).height))}));const a=i.firstChild,c=Array.from(a&&a.children||[]);let d=!1;c.forEach(((e,t)=>{e.style.width&&!/px$/.test(e.style.width)&&(e.style.width=s(c[t]).width,d=!0)}));const h={...o};return d&&(h[Nt]=a.outerHTML),h})(e,a,n,c),a.setNodeMarkup(n,null,c),a.setMeta("commandName","node-resize"),a.setMeta("args",c),a.setMeta(tp,{setDragging:null,activeHandle:null,nodePosition:n}),!/%/.test(ln(c.style).width||"")){const e=a.doc.resolve(n),t=Gt(e,(e=>"table_wrapper"===e.type.name));if(t&&/%/.test(ln(t.node.attrs.style).width||"")){const n=Jt(t.node.attrs,"width",""),o=e.start(t.depth)-1;a.setNodeMarkup(o,null,n)}}e.dispatch(a)}}})(e)})),i.addEventListener("mousemove",s),!0},bp=(e={node:"table"})=>new kt({key:tp,view:()=>({selectedNode(e,t){const n=e.selection;if(n instanceof at&&t===n.node.type&&n instanceof at)return{node:n.node,pos:n.from};const o=Gt(n.$from,(e=>e.type===t)),r=o&&o.node;return r?{node:r,pos:n.$from.start(o.depth)-1}:null},update(t,n){const o=t.state,r=o.schema.nodes[e.node],i=this.selectedNode(o,r),s=this.selectedNode(n,r);if((i||!s||n.doc.eq(t.state.doc))&&(i||s)){const e=o.tr;if(e.setMeta("addToHistory",!1),i&&s&&i.pos!==s.pos){e.setMeta(tp,{nodePosition:i.pos});const n=e.doc.nodeAt(s.pos);n&&n.type.name===r.name&&e.setNodeMarkup(s.pos,r,{...s.node.attrs,[Ot]:!1}),e.setNodeMarkup(i.pos,r,{...i.node.attrs,[Ot]:!0}),t.dispatch(e)}else i&&s&&i.pos===s.pos&&!i.node.attrs[Ot]&&!o.selection.eq(n.selection)?(e.setMeta(tp,{nodePosition:i.pos}),t.dispatch(e.setNodeMarkup(i.pos,r,{...i.node.attrs,[Ot]:!0}))):i&&!s?(e.setMeta(tp,{nodePosition:i.pos}),t.dispatch(e.setNodeMarkup(i.pos,r,{...i.node.attrs,[Ot]:!0}))):!i&&s&&(e.setMeta(tp,{nodePosition:-1}),t.dispatch(e.setNodeMarkup(s.pos,r,{...s.node.attrs,[Ot]:!1})))}}}),state:{init:()=>new yp("",null,-1),apply:(e,t)=>t.apply(e)},props:{handleDOMEvents:{mousedown:(e,t)=>vp(e,t)}}});class kp{ignoreMutation(e){return"attributes"===e.type&&"style"===e.attributeName&&"TR"===e.target.nodeName}}function xp(){const e=new kt({key:op,state:{init(e,t){return this.spec.props.nodeViews[Ma(t.schema).row.name]=()=>new kp,new Sp(-1,null)},apply:(e,t)=>t.apply(e)},props:{attributes:e=>ip(op,e)?null:op.getState(e).activeHandle>-1?{class:"resize-cursor-vertical"}:null,handleDOMEvents:{mousemove:(e,t)=>(rp(op,e.state)||function(e,t){const n=op.getState(e.state);if(!n.dragging){const o=lp(t.target);let r=-1;if(o){const n=ap(o),{top:i,bottom:s}=o.getBoundingClientRect();Math.abs(t.clientY-i)<=5&&n.rowIndex>0?(n.rowIndex-=o.rowSpan,r=cp(e,t,n)):s-t.clientY>0&&s-t.clientY<=5&&(r=cp(e,t,n))}r!==n.activeHandle&&Cp(e,r)}}(e,t),!1),mouseleave:e=>(function(e){const t=op.getState(e.state);t.activeHandle>-1&&!t.dragging&&Cp(e,-1)}(e),!1),mousedown:(e,t)=>function(e,t){const n=op.getState(e.state);if(-1===n.activeHandle||n.dragging)return!1;const o=e.state.doc.resolve(n.activeHandle),r=o.parent,i=o.node(-1),s=ln(r.attrs.style).height,l=ln(i.attrs.style).height;let a=s?parseFloat(s):0;function c(t){t.view.removeEventListener("mouseup",c),t.view.removeEventListener("mousemove",d);const n=op.getState(e.state);if(n.dragging){const t=e.state.tr.setMeta(op,{setDragging:null});!function(e,t,n){const o=e.state.doc,r=o.resolve(n),i=r.parent,s=r.posAtIndex(0)-1,l=e.nodeDOM(s),a=l.ownerDocument&&l.ownerDocument.defaultView||window;l.style.height=a.getComputedStyle(l).height,t.setNodeMarkup(s,null,Jt(i.attrs,"height",l.style.height));const c=l&&l.closest("table"),d=c&&c.style.height;if(d){const e=o.resolve(s),n=e.start(e.depth)-1;t.setNodeMarkup(n,null,Jt(e.parent.attrs,"height",d))}}(e,t,n.activeHandle),e.dispatch(t)}}function d(t){if(!t.which)return c(t);const n=op.getState(e.state),o=function(e,t){const n=t.clientY-e.startY;return e.startHeight.rowHeight+n}(n.dragging,t),r=t.clientY-n.dragging.startY;!function(e,t,n,o,r){const i=e.nodeDOM(t),s=i&&i.parentNode;if(s){s.style.height=n+"px";const e=s.ownerDocument&&s.ownerDocument.defaultView||window;s.style.height=e.getComputedStyle(s).height;const t=s.closest("table"),i=parseFloat(r)+o+"px",l=t&&t.style.height;l&&l!==i&&(t.style.height=parseFloat(r)+o+"px",t.style.height=e.getComputedStyle(t).height)}}(e,n.activeHandle,o,r,l)}return s||(a=e.nodeDOM(n.activeHandle).offsetHeight),e.dispatch(e.state.tr.setMeta(op,{setDragging:{startY:t.clientY,startHeight:{rowHeight:a,tableHeight:l}}})),t.view.addEventListener("mouseup",c),t.view.addEventListener("mousemove",d),t.preventDefault(),!0}(e,t)},decorations(e){if(rp(op,e))return Ol.empty;const t=op.getState(e);return t.activeHandle>-1?function(e,t){const n=[];if("number"!=typeof t)return Ol.empty;const o=e.doc.resolve(t),r=o.node(-1),i=va.get(r),s=o.start(-1),l=[],a=t-s;let c=-1;for(let e=0;e<i.height;e++)l.push(i.map.slice(e*i.width,e*i.width+i.width)),-1!==l[e].indexOf(a)&&(c=e);const d=[];return l[c].forEach(((e,t)=>{l[c+1]&&e===l[c+1][t]||d.push(e)})),d.forEach((e=>{const t=r.nodeAt(e),o=s+e+(t?t.nodeSize:0)-1,i=document.createElement("div");i.className="row-resize-handle",n.push(Cl.widget(o,i))})),Ol.create(e.doc,n)}(e,t.activeHandle):void 0},nodeViews:{}}});return e}class Sp{constructor(e,t){this.activeHandle=e,this.dragging=t}apply(e){let t;const n=e.getMeta(op);if(n&&null!=n.setHandle)return new Sp(n.setHandle,null);if(n&&void 0!==n.setDragging)return new Sp(this.activeHandle,n.setDragging);if(this.activeHandle>-1){let n=e.mapping.map(this.activeHandle,-1);"row"===(o=e.doc.resolve(n)).parent.type.spec.tableRole&&o.nodeAfter||(n=null),t=new Sp(n,this.dragging)}var o;return t||this}}function Cp(e,t){const n=e.state.tr;n.setMeta("addToHistory",!1),n.setMeta(op,{setHandle:t}),e.dispatch(n)}const Mp=()=>[bp(),hp(),xp()],Np=(e,t,n,o,r)=>{const i=r.resolve(e),s=r.resolve(t),l=o.type.name;let a,c;return!i.nodeBefore&&(a=i.node(i.depth),c=i.node(i.depth-1),a&&c&&c.firstChild===a&&c.type.name===l)?n+o.content.size<=t:!s.nodeAfter&&(a=s.node(s.depth),c=s.node(s.depth-1),a&&c&&c.lastChild===a&&c.type.name===l)?e<=n:e<=n&&n+o.content.size<=t},Op=(e,t,n)=>{const{tr:o,doc:r,selection:{from:i,to:s}}=t,l=e.getMeta("args");return r.nodesBetween(i,s,((e,t)=>{e.type.name===n.listItem&&Np(i,s,t,e,r)&&o.setNodeMarkup(t,null,{...e.attrs,style:an(e.attrs.style,l.style,l.value)})})),o.docChanged?o:void 0},Ap=(e,t,n)=>{const o=Object.keys(n.resetValues),{tr:r,doc:i,selection:{from:s,to:l}}=t;return i.nodesBetween(s,l,((e,t)=>{if(e.type.name===n.listItem&&Np(s,l,t,e,i)){let n=e.attrs;const i=ln(e.attrs.style);o.forEach((e=>{i[e]&&(n={...n,style:an(n.style,e,"")})})),n!==e.attrs&&r.setNodeMarkup(t,null,n)}})),e.steps.forEach((e=>{if(e instanceof xe){const t=e.mark;if("style"===t.type.name&&t.attrs.style){const[o]=t.attrs.style.split(/\s*:\s*/),i=Gt(r.doc.resolve(e.from),(e=>e.type.name===n.listItem));if(i&&ln(i.node.attrs.style)[o]&&n.resetValues[o]){const i=t.type.create({style:`${o}: ${n.resetValues[o]};`});r.addMark(e.from,e.to,i)}}}})),r.docChanged?r:void 0},Tp={listItem:"list_item",resetValues:{"font-size":"","font-family":"",color:""}};function Dp(e=Tp){return new kt({key:new Ct("list-markers-styles"),appendTransaction:(t,n,o)=>{const r=t.slice().pop(),i=r.getMeta("commandName");let s;return"FontSize"===i||"FontName"===i||"ForeColor"===i?s=Op(r,o,e):"CleanFormatting"===i&&(s=Ap(r,o,e)),s&&s.setMeta("addToHistory",!0),s}})}function Ep(e={}){return new kt({view:t=>new Rp(t,e)})}class Rp{constructor(e,t){var n;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=null!==(n=t.width)&&void 0!==n?n:1,this.color=!1===t.color?void 0:t.color||"black",this.class=t.class,this.handlers=["dragover","dragend","drop","dragleave"].map((t=>{let n=e=>{this[t](e)};return e.dom.addEventListener(t,n),{name:t,handler:n}}))}destroy(){this.handlers.forEach((({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t)))}update(e,t){null!=this.cursorPos&&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,null==e?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e,t=this.editorView.state.doc.resolve(this.cursorPos),n=!t.parent.inlineContent,o=this.editorView.dom,r=o.getBoundingClientRect(),i=r.width/o.offsetWidth,s=r.height/o.offsetHeight;if(n){let n=t.nodeBefore,o=t.nodeAfter;if(n||o){let t=this.editorView.nodeDOM(this.cursorPos-(n?n.nodeSize:0));if(t){let r=t.getBoundingClientRect(),i=n?r.bottom:r.top;n&&o&&(i=(i+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let l=this.width/2*s;e={left:r.left,right:r.right,top:i-l,bottom:i+l}}}}if(!e){let t=this.editorView.coordsAtPos(this.cursorPos),n=this.width/2*i;e={left:t.left-n,right:t.left+n,top:t.top,bottom:t.bottom}}let l,a,c=this.editorView.dom.offsetParent;if(this.element||(this.element=c.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",n),this.element.classList.toggle("prosemirror-dropcursor-inline",!n),!c||c==document.body&&"static"==getComputedStyle(c).position)l=-pageXOffset,a=-pageYOffset;else{let e=c.getBoundingClientRect(),t=e.width/c.offsetWidth,n=e.height/c.offsetHeight;l=e.left-c.scrollLeft*t,a=e.top-c.scrollTop*n}this.element.style.left=(e.left-l)/i+"px",this.element.style.top=(e.top-a)/s+"px",this.element.style.width=(e.right-e.left)/i+"px",this.element.style.height=(e.bottom-e.top)/s+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout((()=>this.setCursor(null)),e)}dragover(e){if(!this.editorView.editable)return;let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),n=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),o=n&&n.type.spec.disableDropCursor,r="function"==typeof o?o(this.editorView,t,e):o;if(t&&!r){let e=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let t=Le(this.editorView.state.doc,e,this.editorView.dragging.slice);null!=t&&(e=t)}this.setCursor(e),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}class $p extends nt{constructor(e){super(e,e)}map(e,t){let n=e.resolve(t.map(this.head));return $p.valid(n)?new $p(n):nt.near(n)}content(){return p.empty}eq(e){return e instanceof $p&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,t){if("number"!=typeof t.pos)throw new RangeError("Invalid input for GapCursor.fromJSON");return new $p(e.resolve(t.pos))}getBookmark(){return new Ip(this.anchor)}static valid(e){let t=e.parent;if(t.isTextblock||!function(e){for(let t=e.depth;t>=0;t--){let n=e.index(t),o=e.node(t);if(0!=n)for(let e=o.child(n-1);;e=e.lastChild){if(0==e.childCount&&!e.inlineContent||zp(e.type))return!0;if(e.inlineContent)return!1}else if(o.type.spec.isolating)return!0}return!0}(e)||!function(e){for(let t=e.depth;t>=0;t--){let n=e.indexAfter(t),o=e.node(t);if(n!=o.childCount)for(let e=o.child(n);;e=e.firstChild){if(0==e.childCount&&!e.inlineContent||zp(e.type))return!0;if(e.inlineContent)return!1}else if(o.type.spec.isolating)return!0}return!0}(e))return!1;let n=t.type.spec.allowGapCursor;if(null!=n)return n;let o=t.contentMatchAt(e.index()).defaultType;return o&&o.isTextblock}static findGapCursorFrom(e,t,n=!1){e:for(;;){if(!n&&$p.valid(e))return e;let o=e.pos,r=null;for(let n=e.depth;;n--){let i=e.node(n);if(t>0?e.indexAfter(n)<i.childCount:e.index(n)>0){r=i.child(t>0?e.indexAfter(n):e.index(n)-1);break}if(0==n)return null;o+=t;let s=e.doc.resolve(o);if($p.valid(s))return s}for(;;){let i=t>0?r.firstChild:r.lastChild;if(!i){if(r.isAtom&&!r.isText&&!at.isSelectable(r)){e=e.doc.resolve(o+r.nodeSize*t),n=!1;continue e}break}r=i,o+=t;let s=e.doc.resolve(o);if($p.valid(s))return s}return null}}}$p.prototype.visible=!1,$p.findFrom=$p.findGapCursorFrom,nt.jsonID("gapcursor",$p);class Ip{constructor(e){this.pos=e}map(e){return new Ip(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return $p.valid(t)?new $p(t):nt.near(t)}}function zp(e){return e.isAtom||e.spec.isolating||e.spec.createGapCursor}function Bp(){return new kt({props:{decorations:Hp,createSelectionBetween:(e,t,n)=>t.pos==n.pos&&$p.valid(n)?new $p(n):null,handleClick:Fp,handleKeyDown:Pp,handleDOMEvents:{beforeinput:Lp}}})}const Pp=ga({ArrowLeft:Vp("horiz",-1),ArrowRight:Vp("horiz",1),ArrowUp:Vp("vert",-1),ArrowDown:Vp("vert",1)});function Vp(e,t){const n="vert"==e?t>0?"down":"up":t>0?"right":"left";return function(e,o,r){let i=e.selection,s=t>0?i.$to:i.$from,l=i.empty;if(i instanceof st){if(!r.endOfTextblock(n)||0==s.depth)return!1;l=!1,s=e.doc.resolve(t>0?s.after():s.before())}let a=$p.findGapCursorFrom(s,t,l);return!!a&&(o&&o(e.tr.setSelection(new $p(a))),!0)}}function Fp(e,t,n){if(!e||!e.editable)return!1;let o=e.state.doc.resolve(t);if(!$p.valid(o))return!1;let r=e.posAtCoords({left:n.clientX,top:n.clientY});return!(r&&r.inside>-1&&at.isSelectable(e.state.doc.nodeAt(r.inside))||(e.dispatch(e.state.tr.setSelection(new $p(o))),0))}function Lp(e,t){if("insertCompositionText"!=t.inputType||!(e.state.selection instanceof $p))return!1;let{$from:n}=e.state.selection,o=n.parent.contentMatchAt(n.index()).findWrapping(e.state.schema.nodes.text);if(!o)return!1;let r=s.empty;for(let e=o.length-1;e>=0;e--)r=s.from(o[e].createAndFill(null,r));let i=e.state.tr.replace(n.pos,n.pos,new p(r,0,0));return i.setSelection(st.near(i.doc.resolve(n.pos+1))),e.dispatch(i),!1}function Hp(e){if(!(e.selection instanceof $p))return null;let t=document.createElement("div");return t.className="ProseMirror-gapcursor",Ol.create(e.doc,[Cl.widget(e.selection.head,t,{key:"gapcursor"})])}const _p=(e,t,n)=>{const{table:o,table_row:r,table_cell:i}=e,s=[];let l;for(let e=0;e<t+1;e++){l=[];for(let e=0;e<n+1;e++)l.push(i.createAndFill());s.push(r.createAndFill(void 0,l))}return o.createAndFill(void 0,s)},Wp=/^table$/,qp=/^table_row$/,jp=/^table_cell|table_header$/,Jp=(e,t)=>{const n=e.$head;for(let e=n.depth;e>0;e--){const o=n.node(e);if(t.test(o.type.name))return{pos:n.before(e),node:o}}return null},Kp=(e,t)=>{const n=t&&(e=>{const n=Jp(e.selection,qp),o=Jp(e.selection,Wp);if(n&&o&&n.node.attrs[Mt]){let t=0;for(let e=0;e<o.node.nodeSize;e++)if(o.node.child(e).eq(n.node)){t=e;break}const r=o.node.child(t-1),i=n.pos-r.nodeSize;e.setNodeMarkup(i,void 0,{[Mt]:n.node.attrs[Mt]})}return t(e)});return Za(e,n)},Xp=(e,t)=>ec(e,t&&(e=>{const n=Jp(e.selection,qp);if(n&&n.node.attrs[Mt]){const t=n.pos+n.node.nodeSize;e.setNodeMarkup(t,void 0,{[Mt]:n.node.attrs[Mt]})}return t(e)})),Up=(e,t)=>{if(!e)return-1;const n=va.get(e.node),o=Jp(t,jp),r=n.map.indexOf(o.pos-e.pos-1);let i=-1;return-1!==r&&(i=r%n.width),i},Gp=(e,t,n)=>{const o=Up(t,e.selection),r=od(t.node.attrs[Nt]);r.insertBefore(r.ownerDocument.createElement("col"),r.children[o+n]),e.setNodeMarkup(t.pos,null,{...t.node.attrs,[Nt]:r.outerHTML})},Yp=(e,t)=>Ka(e,t&&(e=>{const n=Jp(e.selection,Wp);return n.node.attrs[Nt]?(Gp(e,n,-1),t(e)):t(e)})),Qp=(e,t)=>Xa(e,t&&(e=>{const n=Jp(e.selection,Wp);return n.node.attrs[Nt]?(Gp(e,n,1),t(e)):t(e)})),Zp=(e,t)=>{const n=Jp(e.selection,Wp),o=n&&n.node.attrs[Nt],r=Up(n,e.selection),i=t&&(e=>{if(!o)return t(e);const i=e.doc.nodeAt(n.pos);return((e,t,n)=>{const o=od(t.node.attrs[Nt]);o.removeChild(o.children[n]),e.setNodeMarkup(t.pos,null,{...t.node.attrs,[Nt]:o.outerHTML})})(e,{node:i,pos:n.pos},r),t(e)});return Ga(e,i)};return t})()));