@okam/directus-flexible-content 1.0.2 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js CHANGED
@@ -1,18 +1,18 @@
1
1
  "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const ne=require("react/jsx-runtime"),ho=require("@tanstack/react-query"),Ki=require("radash"),ys=require("graphql-request"),ar=require("@okam/stack-ui"),Vi=require("react");function bs(n,e){return e}const qi=process.env.NEXT_PUBLIC_GRAPHQL_URL,Ji=process.env.NEXT_GRAPHQL_URL_ADMIN,Ui=process.env.NEXT_PUBLIC_API_TOKEN??"",_i=process.env.NEXT_PUBLIC_API_TOKEN,Gi=new ys.GraphQLClient(qi,{credentials:"include",mode:"cors",fetch,headers:{Authorization:`Bearer ${Ui}`}});new ys.GraphQLClient(Ji,{credentials:"include",mode:"cors",fetch,headers:{Authorization:`Bearer ${_i}`}});new ho.QueryClient({queryCache:new ho.QueryCache({onError:n=>{console.error(n)}}),defaultOptions:{queries:{staleTime:5*1e3}}});function ks(n,e,t=Gi){return t.request(n,{...e})}process.env.NEXT_PUBLIC_GRAPHQL_URL;process.env.NEXT_PUBLIC_API_TOKEN;function cr(n){return!!n}function Qi(n){return!Ki.isEmpty(n)&&Object.keys(n).length===1&&Object.keys(n)[0]==="id"&&!!n.id}async function Xi(n){const{document:e,blockKey:t,variables:r}=n;if(!e||!cr(r))return null;const o=await ks(e,r);return!o||typeof o!="object"||!t?null:o[t]}async function Yi(n){const{document:e,item:t,blockKey:r,variables:o}=n;if(t){if(!Qi(t))return t;const l={id:t.id,...o};return cr(l)?Xi({...n,variables:l}):null}if(!e||!cr(o))return null;const s=await ks(e,o);return!s||typeof s!="object"||!r?null:s[r]}function Zi(n,...e){return e.reduce((r,o)=>o?{components:{...r.components,...o.components}}:r,n)}const Ss={kind:"Document",definitions:[{kind:"FragmentDefinition",name:{kind:"Name",value:"BlockSettings"},typeCondition:{kind:"NamedType",name:{kind:"Name",value:"block_settings"}},selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"tokens"}},{kind:"Field",name:{kind:"Name",value:"variant"}}]}}]},el=n=>{var g,y,M;const{item:e,collection:t,config:r,variables:o,defaultVariant:s,...i}=n;if(!t||!r)return null;const l=(g=r==null?void 0:r.components)==null?void 0:g[t];if(!l)return null;const{settings:a}=e??{},c=(e==null?void 0:e.id)??(o==null?void 0:o.id);if(!c)return null;const{variant:u}=bs(Ss,a)??{},d=((y=l.getVariant)==null?void 0:y.call(l,n))??u??s,{default:f,document:h}=l,m=((M=l.variants)==null?void 0:M[d??""])??f;return m?ne.jsx(m,{document:h,config:r,collection:t,item:e,...c?{variables:{...o,id:c}}:{variables:o},...i},c):null},tl=async n=>{const{variables:e,themeName:t="wysiwyg",tokens:r,item:o,document:s}=n,i=await Yi({item:o,blockKey:"block_wysiwyg_by_id",document:s,variables:e});if(!i)return null;const{content:l,title:a,level:c,settings:u}=i,{tokens:d}=bs(Ss,u)??{};return!l&&!(a&&c)?null:ne.jsxs(ne.Fragment,{children:[a&&c&&ne.jsx(ar.Box,{as:"span",themeName:t,tokens:{...r,...d},children:Vi.createElement(c,{},a)}),l&&ne.jsx(ar.WysiwygBlock,{themeName:t,tokens:{...r,...d},content:l})]})},nl={block_wysiwyg:{default:n=>ne.jsx(tl,{...n})}},rl={components:{...nl}},po=n=>{const{children:e,config:t,...r}=n,o=Zi(rl,t),s=l=>e?e({...r,...l,config:o}):ne.jsx(el,{...r,...l,config:o});if("blocks"in n){const{blocks:l}=n;return l.map(s)}const{block:i}=n;return s(i)};function Cs(n,e,t){for(let r=0;;r++){if(r==n.childCount||r==e.childCount)return n.childCount==e.childCount?null:t;let o=n.child(r),s=e.child(r);if(o==s){t+=o.nodeSize;continue}if(!o.sameMarkup(s))return t;if(o.isText&&o.text!=s.text){for(let i=0;o.text[i]==s.text[i];i++)t++;return t}if(o.content.size||s.content.size){let i=Cs(o.content,s.content,t+1);if(i!=null)return i}t+=o.nodeSize}}function ws(n,e,t,r){for(let o=n.childCount,s=e.childCount;;){if(o==0||s==0)return o==s?null:{a:t,b:r};let i=n.child(--o),l=e.child(--s),a=i.nodeSize;if(i==l){t-=a,r-=a;continue}if(!i.sameMarkup(l))return{a:t,b:r};if(i.isText&&i.text!=l.text){let c=0,u=Math.min(i.text.length,l.text.length);for(;c<u&&i.text[i.text.length-c-1]==l.text[l.text.length-c-1];)c++,t--,r--;return{a:t,b:r}}if(i.content.size||l.content.size){let c=ws(i.content,l.content,t-1,r-1);if(c)return c}t-=a,r-=a}}class b{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,t,r,o=0,s){for(let i=0,l=0;l<t;i++){let a=this.content[i],c=l+a.nodeSize;if(c>e&&r(a,o+l,s||null,i)!==!1&&a.content.size){let u=l+1;a.nodesBetween(Math.max(0,e-u),Math.min(a.content.size,t-u),r,o+u)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,r,o){let s="",i=!0;return this.nodesBetween(e,t,(l,a)=>{let c=l.isText?l.text.slice(Math.max(e,a)-a,t-a):l.isLeaf?o?typeof o=="function"?o(l):o:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&c||l.isTextblock)&&r&&(i?i=!1:s+=r),s+=c},0),s}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,r=e.firstChild,o=this.content.slice(),s=0;for(t.isText&&t.sameMarkup(r)&&(o[o.length-1]=t.withText(t.text+r.text),s=1);s<e.content.length;s++)o.push(e.content[s]);return new b(o,this.size+e.size)}cut(e,t=this.size){if(e==0&&t==this.size)return this;let r=[],o=0;if(t>e)for(let s=0,i=0;i<t;s++){let l=this.content[s],a=i+l.nodeSize;a>e&&((i<e||a>t)&&(l.isText?l=l.cut(Math.max(0,e-i),Math.min(l.text.length,t-i)):l=l.cut(Math.max(0,e-i-1),Math.min(l.content.size,t-i-1))),r.push(l),o+=l.nodeSize),i=a}return new b(r,o)}cutByIndex(e,t){return e==t?b.empty:e==0&&t==this.content.length?this:new b(this.content.slice(e,t))}replaceChild(e,t){let r=this.content[e];if(r==t)return this;let o=this.content.slice(),s=this.size+t.nodeSize-r.nodeSize;return o[e]=t,new b(o,s)}addToStart(e){return new b([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new b(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,r=0;t<this.content.length;t++){let o=this.content[t];e(o,r,t),r+=o.nodeSize}}findDiffStart(e,t=0){return Cs(this,e,t)}findDiffEnd(e,t=this.size,r=e.size){return ws(this,e,t,r)}findIndex(e,t=-1){if(e==0)return At(0,e);if(e==this.size)return At(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let r=0,o=0;;r++){let s=this.child(r),i=o+s.nodeSize;if(i>=e)return i==e||t>0?At(r+1,i):At(r,o);o=i}}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 b.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new b(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return b.empty;let t,r=0;for(let o=0;o<e.length;o++){let s=e[o];r+=s.nodeSize,o&&s.isText&&e[o-1].sameMarkup(s)?(t||(t=e.slice(0,o)),t[t.length-1]=s.withText(t[t.length-1].text+s.text)):t&&t.push(s)}return new b(t||e,r)}static from(e){if(!e)return b.empty;if(e instanceof b)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new b([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}b.empty=new b([],0);const jn={index:0,offset:0};function At(n,e){return jn.index=n,jn.offset=e,jn}function ur(n,e){if(n===e)return!0;if(!(n&&typeof n=="object")||!(e&&typeof e=="object"))return!1;let t=Array.isArray(n);if(Array.isArray(e)!=t)return!1;if(t){if(n.length!=e.length)return!1;for(let r=0;r<n.length;r++)if(!ur(n[r],e[r]))return!1}else{for(let r in n)if(!(r in e)||!ur(n[r],e[r]))return!1;for(let r in e)if(!(r in n))return!1}return!0}let _=class dr{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,r=!1;for(let o=0;o<e.length;o++){let s=e[o];if(this.eq(s))return e;if(this.type.excludes(s.type))t||(t=e.slice(0,o));else{if(s.type.excludes(this.type))return e;!r&&s.type.rank>this.type.rank&&(t||(t=e.slice(0,o)),t.push(this),r=!0),t&&t.push(s)}}return t||(t=e.slice()),r||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&&ur(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 r=e.marks[t.type];if(!r)throw new RangeError(`There is no mark type ${t.type} in this schema`);return r.create(t.attrs)}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(t[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return dr.none;if(e instanceof dr)return[e];let t=e.slice();return t.sort((r,o)=>r.type.rank-o.type.rank),t}};_.none=[];class ol extends Error{}class S{constructor(e,t,r){this.content=e,this.openStart=t,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let r=Ts(this.content,e+this.openStart,t);return r&&new S(r,this.openStart,this.openEnd)}removeBetween(e,t){return new S(xs(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 S.empty;let r=t.openStart||0,o=t.openEnd||0;if(typeof r!="number"||typeof o!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new S(b.fromJSON(e,t.content),r,o)}static maxOpen(e,t=!0){let r=0,o=0;for(let s=e.firstChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.firstChild)r++;for(let s=e.lastChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.lastChild)o++;return new S(e,r,o)}}S.empty=new S(b.empty,0,0);function xs(n,e,t){let{index:r,offset:o}=n.findIndex(e),s=n.maybeChild(r),{index:i,offset:l}=n.findIndex(t);if(o==e||s.isText){if(l!=t&&!n.child(i).isText)throw new RangeError("Removing non-flat range");return n.cut(0,e).append(n.cut(t))}if(r!=i)throw new RangeError("Removing non-flat range");return n.replaceChild(r,s.copy(xs(s.content,e-o-1,t-o-1)))}function Ts(n,e,t,r){let{index:o,offset:s}=n.findIndex(e),i=n.maybeChild(o);if(s==e||i.isText)return n.cut(0,e).append(t).append(n.cut(e));let l=Ts(i.content,e-s-1,t);return l&&n.replaceChild(o,i.copy(l))}class fr{constructor(e,t,r){this.$from=e,this.$to=t,this.depth=r}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}function sl(n){let e=Object.create(null);for(let t in n){let r=n[t];if(!r.hasDefault)return null;e[t]=r.default}return e}function il(n,e){let t=Object.create(null);for(let r in n){let o=e&&e[r];if(o===void 0){let s=n[r];if(s.hasDefault)o=s.default;else throw new RangeError("No value supplied for attribute "+r)}t[r]=o}return t}function ll(n){let e=Object.create(null);if(n)for(let t in n)e[t]=new al(n[t]);return e}class al{constructor(e){this.hasDefault=Object.prototype.hasOwnProperty.call(e,"default"),this.default=e.default}get isRequired(){return!this.hasDefault}}class Dr{constructor(e,t,r,o){this.name=e,this.rank=t,this.schema=r,this.spec=o,this.attrs=ll(o.attrs),this.excluded=null;let s=sl(this.attrs);this.instance=s?new _(this,s):null}create(e=null){return!e&&this.instance?this.instance:new _(this,il(this.attrs,e))}static compile(e,t){let r=Object.create(null),o=0;return e.forEach((s,i)=>r[s]=new Dr(s,o++,t,i)),r}removeFromSet(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}excludes(e){return this.excluded.indexOf(e)>-1}}function cl(n){return n.tag!=null}function ul(n){return n.style!=null}class pt{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let r=this.matchedStyles=[];t.forEach(o=>{if(cl(o))this.tags.push(o);else if(ul(o)){let s=/[^=]*/.exec(o.style)[0];r.indexOf(s)<0&&r.push(s),this.styles.push(o)}}),this.normalizeLists=!this.tags.some(o=>{if(!/^(ul|ol)\b/.test(o.tag)||!o.node)return!1;let s=e.nodes[o.node];return s.contentMatch.matchType(s)})}parse(e,t={}){let r=new go(this,t,!1);return r.addAll(e,t.from,t.to),r.finish()}parseSlice(e,t={}){let r=new go(this,t,!0);return r.addAll(e,t.from,t.to),S.maxOpen(r.finish())}matchTag(e,t,r){for(let o=r?this.tags.indexOf(r)+1:0;o<this.tags.length;o++){let s=this.tags[o];if(hl(e,s.tag)&&(s.namespace===void 0||e.namespaceURI==s.namespace)&&(!s.context||t.matchesContext(s.context))){if(s.getAttrs){let i=s.getAttrs(e);if(i===!1)continue;s.attrs=i||void 0}return s}}}matchStyle(e,t,r,o){for(let s=o?this.styles.indexOf(o)+1:0;s<this.styles.length;s++){let i=this.styles[s],l=i.style;if(!(l.indexOf(e)!=0||i.context&&!r.matchesContext(i.context)||l.length>e.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=t))){if(i.getAttrs){let a=i.getAttrs(t);if(a===!1)continue;i.attrs=a||void 0}return i}}}static schemaRules(e){let t=[];function r(o){let s=o.priority==null?50:o.priority,i=0;for(;i<t.length;i++){let l=t[i];if((l.priority==null?50:l.priority)<s)break}t.splice(i,0,o)}for(let o in e.marks){let s=e.marks[o].spec.parseDOM;s&&s.forEach(i=>{r(i=yo(i)),i.mark||i.ignore||i.clearMark||(i.mark=o)})}for(let o in e.nodes){let s=e.nodes[o].spec.parseDOM;s&&s.forEach(i=>{r(i=yo(i)),i.node||i.ignore||i.mark||(i.node=o)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new pt(e,pt.schemaRules(e)))}}const As={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},dl={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Ms={ol:!0,ul:!0},Wt=1,Kt=2,at=4;function mo(n,e,t){return e!=null?(e?Wt:0)|(e==="full"?Kt:0):n&&n.whitespace=="pre"?Wt|Kt:t&~at}class Mt{constructor(e,t,r,o,s,i,l){this.type=e,this.attrs=t,this.marks=r,this.pendingMarks=o,this.solid=s,this.options=l,this.content=[],this.activeMarks=_.none,this.stashMarks=[],this.match=i||(l&at?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(b.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let r=this.type.contentMatch,o;return(o=r.findWrapping(e.type))?(this.match=r,o):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&Wt)){let r=this.content[this.content.length-1],o;if(r&&r.isText&&(o=/[ \t\r\n\u000c]+$/.exec(r.text))){let s=r;r.text.length==o[0].length?this.content.pop():this.content[this.content.length-1]=s.withText(s.text.slice(0,s.text.length-o[0].length))}}let t=b.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(b.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}popFromStashMark(e){for(let t=this.stashMarks.length-1;t>=0;t--)if(e.eq(this.stashMarks[t]))return this.stashMarks.splice(t,1)[0]}applyPending(e){for(let t=0,r=this.pendingMarks;t<r.length;t++){let o=r[t];(this.type?this.type.allowsMarkType(o.type):pl(o.type,e))&&!o.isInSet(this.activeMarks)&&(this.activeMarks=o.addToSet(this.activeMarks),this.pendingMarks=o.removeFromSet(this.pendingMarks))}}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!As.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class go{constructor(e,t,r){this.parser=e,this.options=t,this.isOpen=r,this.open=0;let o=t.topNode,s,i=mo(null,t.preserveWhitespace,0)|(r?at:0);o?s=new Mt(o.type,o.attrs,_.none,_.none,!0,t.topMatch||o.type.contentMatch,i):r?s=new Mt(null,null,_.none,_.none,!0,null,i):s=new Mt(e.schema.topNodeType,null,_.none,_.none,!0,null,i),this.nodes=[s],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e){e.nodeType==3?this.addTextNode(e):e.nodeType==1&&this.addElement(e)}withStyleRules(e,t){let r=e.style;if(!r||!r.length)return t();let o=this.readStyles(e.style);if(!o)return;let[s,i]=o,l=this.top;for(let a=0;a<i.length;a++)this.removePendingMark(i[a],l);for(let a=0;a<s.length;a++)this.addPendingMark(s[a]);t();for(let a=0;a<s.length;a++)this.removePendingMark(s[a],l);for(let a=0;a<i.length;a++)this.addPendingMark(i[a])}addTextNode(e){let t=e.nodeValue,r=this.top;if(r.options&Kt||r.inlineContext(e)||/[^ \t\r\n\u000c]/.test(t)){if(r.options&Wt)r.options&Kt?t=t.replace(/\r\n?/g,`
2
2
  `):t=t.replace(/\r?\n|\r/g," ");else if(t=t.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(t)&&this.open==this.nodes.length-1){let o=r.content[r.content.length-1],s=e.previousSibling;(!o||s&&s.nodeName=="BR"||o.isText&&/[ \t\r\n\u000c]$/.test(o.text))&&(t=t.slice(1))}t&&this.insertNode(this.parser.schema.text(t)),this.findInText(e)}else this.findInside(e)}addElement(e,t){let r=e.nodeName.toLowerCase(),o;Ms.hasOwnProperty(r)&&this.parser.normalizeLists&&fl(e);let s=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(o=this.parser.matchTag(e,this,t));if(s?s.ignore:dl.hasOwnProperty(r))this.findInside(e),this.ignoreFallback(e);else if(!s||s.skip||s.closeParent){s&&s.closeParent?this.open=Math.max(0,this.open-1):s&&s.skip.nodeType&&(e=s.skip);let i,l=this.top,a=this.needsBlock;if(As.hasOwnProperty(r))l.content.length&&l.content[0].isInline&&this.open&&(this.open--,l=this.top),i=!0,l.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e);return}s&&s.skip?this.addAll(e):this.withStyleRules(e,()=>this.addAll(e)),i&&this.sync(l),this.needsBlock=a}else this.withStyleRules(e,()=>{this.addElementByRule(e,s,s.consuming===!1?o:void 0)})}leafFallback(e){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
3
- `))}ignoreFallback(e){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"))}readStyles(e){let t=_.none,r=_.none;if(e.length)for(let o=0;o<this.parser.matchedStyles.length;o++){let s=this.parser.matchedStyles[o],i=e.getPropertyValue(s);if(i)for(let l=void 0;;){let a=this.parser.matchStyle(s,i,this,l);if(!a)break;if(a.ignore)return null;if(a.clearMark?this.top.pendingMarks.concat(this.top.activeMarks).forEach(c=>{a.clearMark(c)&&(r=c.addToSet(r))}):t=this.parser.schema.marks[a.mark].create(a.attrs).addToSet(t),a.consuming===!1)l=a;else break}}return[t,r]}addElementByRule(e,t,r){let o,s,i;t.node?(s=this.parser.schema.nodes[t.node],s.isLeaf?this.insertNode(s.create(t.attrs))||this.leafFallback(e):o=this.enter(s,t.attrs||null,t.preserveWhitespace)):(i=this.parser.schema.marks[t.mark].create(t.attrs),this.addPendingMark(i));let l=this.top;if(s&&s.isLeaf)this.findInside(e);else if(r)this.addElement(e,r);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a));else{let a=e;typeof t.contentElement=="string"?a=e.querySelector(t.contentElement):typeof t.contentElement=="function"?a=t.contentElement(e):t.contentElement&&(a=t.contentElement),this.findAround(e,a,!0),this.addAll(a)}o&&this.sync(l)&&this.open--,i&&this.removePendingMark(i,l)}addAll(e,t,r){let o=t||0;for(let s=t?e.childNodes[t]:e.firstChild,i=r==null?null:e.childNodes[r];s!=i;s=s.nextSibling,++o)this.findAtPoint(e,o),this.addDOM(s);this.findAtPoint(e,o)}findPlace(e){let t,r;for(let o=this.open;o>=0;o--){let s=this.nodes[o],i=s.findWrapping(e);if(i&&(!t||t.length>i.length)&&(t=i,r=s,!i.length)||s.solid)break}if(!t)return!1;this.sync(r);for(let o=0;o<t.length;o++)this.enterInner(t[o],null,!1);return!0}insertNode(e){if(e.isInline&&this.needsBlock&&!this.top.type){let t=this.textblockFromContext();t&&this.enterInner(t)}if(this.findPlace(e)){this.closeExtra();let t=this.top;t.applyPending(e.type),t.match&&(t.match=t.match.matchType(e.type));let r=t.activeMarks;for(let o=0;o<e.marks.length;o++)(!t.type||t.type.allowsMarkType(e.marks[o].type))&&(r=e.marks[o].addToSet(r));return t.content.push(e.mark(r)),!0}return!1}enter(e,t,r){let o=this.findPlace(e.create(t));return o&&this.enterInner(e,t,!0,r),o}enterInner(e,t=null,r=!1,o){this.closeExtra();let s=this.top;s.applyPending(e),s.match=s.match&&s.match.matchType(e);let i=mo(e,o,s.options);s.options&at&&s.content.length==0&&(i|=at),this.nodes.push(new Mt(e,t,s.activeMarks,s.pendingMarks,r,null,i)),this.open++}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;return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let r=this.nodes[t].content;for(let o=r.length-1;o>=0;o--)e+=r[o].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==t&&(this.find[r].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].pos==null&&e.nodeType==1&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,r){if(e!=t&&this.find)for(let o=0;o<this.find.length;o++)this.find[o].pos==null&&e.nodeType==1&&e.contains(this.find[o].node)&&t.compareDocumentPosition(this.find[o].node)&(r?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("/"),r=this.options.context,o=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),s=-(r?r.depth+1:0)+(o?0:1),i=(l,a)=>{for(;l>=0;l--){let c=t[l];if(c==""){if(l==t.length-1||l==0)continue;for(;a>=s;a--)if(i(l-1,a))return!0;return!1}else{let u=a>0||a==0&&o?this.nodes[a].type:r&&a>=s?r.node(a-s).type:null;if(!u||u.name!=c&&u.groups.indexOf(c)==-1)return!1;a--}}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 r=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let t in this.parser.schema.nodes){let r=this.parser.schema.nodes[t];if(r.isTextblock&&r.defaultAttrs)return r}}addPendingMark(e){let t=ml(e,this.top.pendingMarks);t&&this.top.stashMarks.push(t),this.top.pendingMarks=e.addToSet(this.top.pendingMarks)}removePendingMark(e,t){for(let r=this.open;r>=0;r--){let o=this.nodes[r];if(o.pendingMarks.lastIndexOf(e)>-1)o.pendingMarks=e.removeFromSet(o.pendingMarks);else{o.activeMarks=e.removeFromSet(o.activeMarks);let i=o.popFromStashMark(e);i&&o.type&&o.type.allowsMarkType(i.type)&&(o.activeMarks=i.addToSet(o.activeMarks))}if(o==t)break}}}function fl(n){for(let e=n.firstChild,t=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&Ms.hasOwnProperty(r)&&t?(t.appendChild(e),e=t):r=="li"?t=e:r&&(t=null)}}function hl(n,e){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,e)}function yo(n){let e={};for(let t in n)e[t]=n[t];return e}function pl(n,e){let t=e.schema.nodes;for(let r in t){let o=t[r];if(!o.allowsMarkType(n))continue;let s=[],i=l=>{s.push(l);for(let a=0;a<l.edgeCount;a++){let{type:c,next:u}=l.edge(a);if(c==e||s.indexOf(u)<0&&i(u))return!0}};if(i(o.contentMatch))return!0}}function ml(n,e){for(let t=0;t<e.length;t++)if(n.eq(e[t]))return e[t]}class ve{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},r){r||(r=Wn(t).createDocumentFragment());let o=r,s=[];return e.forEach(i=>{if(s.length||i.marks.length){let l=0,a=0;for(;l<s.length&&a<i.marks.length;){let c=i.marks[a];if(!this.marks[c.type.name]){a++;continue}if(!c.eq(s[l][0])||c.type.spec.spanning===!1)break;l++,a++}for(;l<s.length;)o=s.pop()[1];for(;a<i.marks.length;){let c=i.marks[a++],u=this.serializeMark(c,i.isInline,t);u&&(s.push([c,o]),o.appendChild(u.dom),o=u.contentDOM||u.dom)}}o.appendChild(this.serializeNodeInner(i,t))}),r}serializeNodeInner(e,t){let{dom:r,contentDOM:o}=ve.renderSpec(Wn(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 r}serializeNode(e,t={}){let r=this.serializeNodeInner(e,t);for(let o=e.marks.length-1;o>=0;o--){let s=this.serializeMark(e.marks[o],e.isInline,t);s&&((s.contentDOM||s.dom).appendChild(r),r=s.dom)}return r}serializeMark(e,t,r={}){let o=this.marks[e.type.name];return o&&ve.renderSpec(Wn(r),o(e,t))}static renderSpec(e,t,r=null){if(typeof t=="string")return{dom:e.createTextNode(t)};if(t.nodeType!=null)return{dom:t};if(t.dom&&t.dom.nodeType!=null)return t;let o=t[0],s=o.indexOf(" ");s>0&&(r=o.slice(0,s),o=o.slice(s+1));let i,l=r?e.createElementNS(r,o):e.createElement(o),a=t[1],c=1;if(a&&typeof a=="object"&&a.nodeType==null&&!Array.isArray(a)){c=2;for(let u in a)if(a[u]!=null){let d=u.indexOf(" ");d>0?l.setAttributeNS(u.slice(0,d),u.slice(d+1),a[u]):l.setAttribute(u,a[u])}}for(let u=c;u<t.length;u++){let d=t[u];if(d===0){if(u<t.length-1||u>c)throw new RangeError("Content hole must be the only child of its parent node");return{dom:l,contentDOM:l}}else{let{dom:f,contentDOM:h}=ve.renderSpec(e,d,r);if(l.appendChild(f),h){if(i)throw new RangeError("Multiple content holes");i=h}}}return{dom:l,contentDOM:i}}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new ve(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=bo(e.nodes);return t.text||(t.text=r=>r.text),t}static marksFromSchema(e){return bo(e.marks)}}function bo(n){let e={};for(let t in n){let r=n[t].spec.toDOM;r&&(e[t]=r)}return e}function Wn(n){return n.document||window.document}const Es=65535,Ns=Math.pow(2,16);function gl(n,e){return n+e*Ns}function ko(n){return n&Es}function yl(n){return(n-(n&Es))/Ns}const Rs=1,Os=2,Dt=4,Is=8;class hr{constructor(e,t,r){this.pos=e,this.delInfo=t,this.recover=r}get deleted(){return(this.delInfo&Is)>0}get deletedBefore(){return(this.delInfo&(Rs|Dt))>0}get deletedAfter(){return(this.delInfo&(Os|Dt))>0}get deletedAcross(){return(this.delInfo&Dt)>0}}class G{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&G.empty)return G.empty}recover(e){let t=0,r=ko(e);if(!this.inverted)for(let o=0;o<r;o++)t+=this.ranges[o*3+2]-this.ranges[o*3+1];return this.ranges[r*3]+t+yl(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,r){let o=0,s=this.inverted?2:1,i=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?o:0);if(a>e)break;let c=this.ranges[l+s],u=this.ranges[l+i],d=a+c;if(e<=d){let f=c?e==a?-1:e==d?1:t:t,h=a+o+(f<0?0:u);if(r)return h;let p=e==(t<0?a:d)?null:gl(l/3,e-a),m=e==a?Os:e==d?Rs:Dt;return(t<0?e!=a:e!=d)&&(m|=Is),new hr(h,m,p)}o+=u-c}return r?e+o:new hr(e+o,0,null)}touches(e,t){let r=0,o=ko(t),s=this.inverted?2:1,i=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?r:0);if(a>e)break;let c=this.ranges[l+s],u=a+c;if(e<=u&&l==o*3)return!0;r+=this.ranges[l+i]-c}return!1}forEach(e){let t=this.inverted?2:1,r=this.inverted?1:2;for(let o=0,s=0;o<this.ranges.length;o+=3){let i=this.ranges[o],l=i-(this.inverted?s:0),a=i+(this.inverted?0:s),c=this.ranges[o+t],u=this.ranges[o+r];e(l,l+c,a,a+u),s+=u-c}}invert(){return new G(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?G.empty:new G(e<0?[0,-e,0]:[0,0,e])}}G.empty=new G([]);class ct{constructor(e=[],t,r=0,o=e.length){this.maps=e,this.mirror=t,this.from=r,this.to=o}slice(e=0,t=this.maps.length){return new ct(this.maps,this.mirror,e,t)}copy(){return new ct(this.maps.slice(),this.mirror&&this.mirror.slice(),this.from,this.to)}appendMap(e,t){this.to=this.maps.push(e),t!=null&&this.setMirror(this.maps.length-1,t)}appendMapping(e){for(let t=0,r=this.maps.length;t<e.maps.length;t++){let o=e.getMirror(t);this.appendMap(e.maps[t],o!=null&&o<t?r+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,r=this.maps.length+e.maps.length;t>=0;t--){let o=e.getMirror(t);this.appendMap(e.maps[t].invert(),o!=null&&o>t?r-o-1:void 0)}}invert(){let e=new ct;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let r=this.from;r<this.to;r++)e=this.maps[r].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,r){let o=0;for(let s=this.from;s<this.to;s++){let i=this.maps[s],l=i.mapResult(e,t);if(l.recover!=null){let a=this.getMirror(s);if(a!=null&&a>s&&a<this.to){s=a,e=this.maps[a].recover(l.recover);continue}}o|=l.delInfo,e=l.pos}return r?e:new hr(e,o,null)}}const Kn=Object.create(null);class V{getMap(){return G.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=Kn[t.stepType];if(!r)throw new RangeError(`No step type ${t.stepType} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in Kn)throw new RangeError("Duplicate use of step JSON ID "+e);return Kn[e]=t,t.prototype.jsonID=e,t}}class B{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new B(e,null)}static fail(e){return new B(null,e)}static fromReplace(e,t,r,o){try{return B.ok(e.replace(t,r,o))}catch(s){if(s instanceof ol)return B.fail(s.message);throw s}}}function Br(n,e,t){let r=[];for(let o=0;o<n.childCount;o++){let s=n.child(o);s.content.size&&(s=s.copy(Br(s.content,e,s))),s.isInline&&(s=e(s,t,o)),r.push(s)}return b.fromArray(r)}class Te extends V{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=e.resolve(this.from),o=r.node(r.sharedDepth(this.to)),s=new S(Br(t.content,(i,l)=>!i.isAtom||!l.type.allowsMarkType(this.mark.type)?i:i.mark(this.mark.addToSet(i.marks)),o),t.openStart,t.openEnd);return B.fromReplace(e,this.from,this.to,s)}invert(){return new he(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new Te(t.pos,r.pos,this.mark)}merge(e){return e instanceof Te&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Te(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new Te(t.from,t.to,e.markFromJSON(t.mark))}}V.jsonID("addMark",Te);class he extends V{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=new S(Br(t.content,o=>o.mark(this.mark.removeFromSet(o.marks)),e),t.openStart,t.openEnd);return B.fromReplace(e,this.from,this.to,r)}invert(){return new Te(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new he(t.pos,r.pos,this.mark)}merge(e){return e instanceof he&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new he(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new he(t.from,t.to,e.markFromJSON(t.mark))}}V.jsonID("removeMark",he);class Ae extends V{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return B.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return B.fromReplace(e,this.pos,this.pos+1,new S(b.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let r=this.mark.addToSet(t.marks);if(r.length==t.marks.length){for(let o=0;o<t.marks.length;o++)if(!t.marks[o].isInSet(r))return new Ae(this.pos,t.marks[o]);return new Ae(this.pos,this.mark)}}return new Ye(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new Ae(t.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new Ae(t.pos,e.markFromJSON(t.mark))}}V.jsonID("addNodeMark",Ae);class Ye extends V{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return B.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return B.fromReplace(e,this.pos,this.pos+1,new S(b.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new Ae(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new Ye(t.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new Ye(t.pos,e.markFromJSON(t.mark))}}V.jsonID("removeNodeMark",Ye);class $ extends V{constructor(e,t,r,o=!1){super(),this.from=e,this.to=t,this.slice=r,this.structure=o}apply(e){return this.structure&&pr(e,this.from,this.to)?B.fail("Structure replace would overwrite content"):B.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new G([this.from,this.to-this.from,this.slice.size])}invert(e){return new $(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deletedAcross&&r.deletedAcross?null:new $(t.pos,Math.max(t.pos,r.pos),this.slice)}merge(e){if(!(e instanceof $)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let t=this.slice.size+e.slice.size==0?S.empty:new S(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new $(this.from,this.to+(e.to-e.from),t,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let t=this.slice.size+e.slice.size==0?S.empty:new S(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new $(e.from,this.to,t,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new $(t.from,t.to,S.fromJSON(e,t.slice),!!t.structure)}}V.jsonID("replace",$);class F extends V{constructor(e,t,r,o,s,i,l=!1){super(),this.from=e,this.to=t,this.gapFrom=r,this.gapTo=o,this.slice=s,this.insert=i,this.structure=l}apply(e){if(this.structure&&(pr(e,this.from,this.gapFrom)||pr(e,this.gapTo,this.to)))return B.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return B.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,t.content);return r?B.fromReplace(e,this.from,this.to,r):B.fail("Content does not fit in gap")}getMap(){return new G([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 F(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),r=e.mapResult(this.to,-1),o=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),s=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return t.deletedAcross&&r.deletedAcross||o<t.pos||s>r.pos?null:new F(t.pos,r.pos,o,s,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number"||typeof t.gapFrom!="number"||typeof t.gapTo!="number"||typeof t.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new F(t.from,t.to,t.gapFrom,t.gapTo,S.fromJSON(e,t.slice),t.insert,!!t.structure)}}V.jsonID("replaceAround",F);function pr(n,e,t){let r=n.resolve(e),o=t-e,s=r.depth;for(;o>0&&s>0&&r.indexAfter(s)==r.node(s).childCount;)s--,o--;if(o>0){let i=r.node(s).maybeChild(r.indexAfter(s));for(;o>0;){if(!i||i.isLeaf)return!0;i=i.firstChild,o--}}return!1}function bl(n,e,t,r){let o=[],s=[],i,l;n.doc.nodesBetween(e,t,(a,c,u)=>{if(!a.isInline)return;let d=a.marks;if(!r.isInSet(d)&&u.type.allowsMarkType(r.type)){let f=Math.max(c,e),h=Math.min(c+a.nodeSize,t),p=r.addToSet(d);for(let m=0;m<d.length;m++)d[m].isInSet(p)||(i&&i.to==f&&i.mark.eq(d[m])?i.to=h:o.push(i=new he(f,h,d[m])));l&&l.to==f?l.to=h:s.push(l=new Te(f,h,r))}}),o.forEach(a=>n.step(a)),s.forEach(a=>n.step(a))}function kl(n,e,t,r){let o=[],s=0;n.doc.nodesBetween(e,t,(i,l)=>{if(!i.isInline)return;s++;let a=null;if(r instanceof Dr){let c=i.marks,u;for(;u=r.isInSet(c);)(a||(a=[])).push(u),c=u.removeFromSet(c)}else r?r.isInSet(i.marks)&&(a=[r]):a=i.marks;if(a&&a.length){let c=Math.min(l+i.nodeSize,t);for(let u=0;u<a.length;u++){let d=a[u],f;for(let h=0;h<o.length;h++){let p=o[h];p.step==s-1&&d.eq(o[h].style)&&(f=p)}f?(f.to=c,f.step=s):o.push({style:d,from:Math.max(l,e),to:c,step:s})}}}),o.forEach(i=>n.step(new he(i.from,i.to,i.style)))}function Ls(n,e,t,r=t.contentMatch,o=!0){let s=n.doc.nodeAt(e),i=[],l=e+1;for(let a=0;a<s.childCount;a++){let c=s.child(a),u=l+c.nodeSize,d=r.matchType(c.type);if(!d)i.push(new $(l,u,S.empty));else{r=d;for(let f=0;f<c.marks.length;f++)t.allowsMarkType(c.marks[f].type)||n.step(new he(l,u,c.marks[f]));if(o&&c.isText&&t.whitespace!="pre"){let f,h=/\r?\n|\r/g,p;for(;f=h.exec(c.text);)p||(p=new S(b.from(t.schema.text(" ",t.allowedMarks(c.marks))),0,0)),i.push(new $(l+f.index,l+f.index+f[0].length,p))}}l=u}if(!r.validEnd){let a=r.fillBefore(b.empty,!0);n.replace(l,l,new S(a,0,0))}for(let a=i.length-1;a>=0;a--)n.step(i[a])}function Sl(n,e,t){return(e==0||n.canReplace(e,n.childCount))&&(t==n.childCount||n.canReplace(0,t))}function rt(n){let t=n.parent.content.cutByIndex(n.startIndex,n.endIndex);for(let r=n.depth;;--r){let o=n.$from.node(r),s=n.$from.index(r),i=n.$to.indexAfter(r);if(r<n.depth&&o.canReplace(s,i,t))return r;if(r==0||o.type.spec.isolating||!Sl(o,s,i))break}return null}function Cl(n,e,t){let{$from:r,$to:o,depth:s}=e,i=r.before(s+1),l=o.after(s+1),a=i,c=l,u=b.empty,d=0;for(let p=s,m=!1;p>t;p--)m||r.index(p)>0?(m=!0,u=b.from(r.node(p).copy(u)),d++):a--;let f=b.empty,h=0;for(let p=s,m=!1;p>t;p--)m||o.after(p+1)<o.end(p)?(m=!0,f=b.from(o.node(p).copy(f)),h++):c++;n.step(new F(a,c,i,l,new S(u.append(f),d,h),u.size-d,!0))}function Hr(n,e,t=null,r=n){let o=wl(n,e),s=o&&xl(r,e);return s?o.map(So).concat({type:e,attrs:t}).concat(s.map(So)):null}function So(n){return{type:n,attrs:null}}function wl(n,e){let{parent:t,startIndex:r,endIndex:o}=n,s=t.contentMatchAt(r).findWrapping(e);if(!s)return null;let i=s.length?s[0]:e;return t.canReplaceWith(r,o,i)?s:null}function xl(n,e){let{parent:t,startIndex:r,endIndex:o}=n,s=t.child(r),i=e.contentMatch.findWrapping(s.type);if(!i)return null;let a=(i.length?i[i.length-1]:e).contentMatch;for(let c=r;a&&c<o;c++)a=a.matchType(t.child(c).type);return!a||!a.validEnd?null:i}function Tl(n,e,t){let r=b.empty;for(let i=t.length-1;i>=0;i--){if(r.size){let l=t[i].type.contentMatch.matchFragment(r);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=b.from(t[i].type.create(t[i].attrs,r))}let o=e.start,s=e.end;n.step(new F(o,s,o,s,new S(r,0,0),t.length,!0))}function Al(n,e,t,r,o){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let s=n.steps.length;n.doc.nodesBetween(e,t,(i,l)=>{if(i.isTextblock&&!i.hasMarkup(r,o)&&Nl(n.doc,n.mapping.slice(s).map(l),r)){let a=null;if(r.schema.linebreakReplacement){let f=r.whitespace=="pre",h=!!r.contentMatch.matchType(r.schema.linebreakReplacement);f&&!h?a=!1:!f&&h&&(a=!0)}a===!1&&El(n,i,l,s),Ls(n,n.mapping.slice(s).map(l,1),r,void 0,a===null);let c=n.mapping.slice(s),u=c.map(l,1),d=c.map(l+i.nodeSize,1);return n.step(new F(u,d,u+1,d-1,new S(b.from(r.create(o,null,i.marks)),0,0),1,!0)),a===!0&&Ml(n,i,l,s),!1}})}function Ml(n,e,t,r){e.forEach((o,s)=>{if(o.isText){let i,l=/\r?\n|\r/g;for(;i=l.exec(o.text);){let a=n.mapping.slice(r).map(t+1+s+i.index);n.replaceWith(a,a+1,e.type.schema.linebreakReplacement.create())}}})}function El(n,e,t,r){e.forEach((o,s)=>{if(o.type==o.type.schema.linebreakReplacement){let i=n.mapping.slice(r).map(t+1+s);n.replaceWith(i,i+1,e.type.schema.text(`
4
- `))}})}function Nl(n,e,t){let r=n.resolve(e),o=r.index();return r.parent.canReplaceWith(o,o+1,t)}function Rl(n,e,t,r,o){let s=n.doc.nodeAt(e);if(!s)throw new RangeError("No node at given position");t||(t=s.type);let i=t.create(r,null,o||s.marks);if(s.isLeaf)return n.replaceWith(e,e+s.nodeSize,i);if(!t.validContent(s.content))throw new RangeError("Invalid content for node type "+t.name);n.step(new F(e,e+s.nodeSize,e+1,e+s.nodeSize-1,new S(b.from(i),0,0),1,!0))}function Ge(n,e,t=1,r){let o=n.resolve(e),s=o.depth-t,i=r&&r[r.length-1]||o.parent;if(s<0||o.parent.type.spec.isolating||!o.parent.canReplace(o.index(),o.parent.childCount)||!i.type.validContent(o.parent.content.cutByIndex(o.index(),o.parent.childCount)))return!1;for(let c=o.depth-1,u=t-2;c>s;c--,u--){let d=o.node(c),f=o.index(c);if(d.type.spec.isolating)return!1;let h=d.content.cutByIndex(f,d.childCount),p=r&&r[u+1];p&&(h=h.replaceChild(0,p.type.create(p.attrs)));let m=r&&r[u]||d;if(!d.canReplace(f+1,d.childCount)||!m.type.validContent(h))return!1}let l=o.indexAfter(s),a=r&&r[0];return o.node(s).canReplaceWith(l,l,a?a.type:o.node(s+1).type)}function Ol(n,e,t=1,r){let o=n.doc.resolve(e),s=b.empty,i=b.empty;for(let l=o.depth,a=o.depth-t,c=t-1;l>a;l--,c--){s=b.from(o.node(l).copy(s));let u=r&&r[c];i=b.from(u?u.type.create(u.attrs,i):o.node(l).copy(i))}n.step(new $(e,e,new S(s.append(i),t,t),!0))}function Re(n,e){let t=n.resolve(e),r=t.index();return vs(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(r,r+1)}function vs(n,e){return!!(n&&e&&!n.isLeaf&&n.canAppend(e))}function Nn(n,e,t=-1){let r=n.resolve(e);for(let o=r.depth;;o--){let s,i,l=r.index(o);if(o==r.depth?(s=r.nodeBefore,i=r.nodeAfter):t>0?(s=r.node(o+1),l++,i=r.node(o).maybeChild(l)):(s=r.node(o).maybeChild(l-1),i=r.node(o+1)),s&&!s.isTextblock&&vs(s,i)&&r.node(o).canReplace(l,l+1))return e;if(o==0)break;e=t<0?r.before(o):r.after(o)}}function Il(n,e,t){let r=new $(e-t,e+t,S.empty,!0);n.step(r)}function Ll(n,e,t){let r=n.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),t))return e;if(r.parentOffset==0)for(let o=r.depth-1;o>=0;o--){let s=r.index(o);if(r.node(o).canReplaceWith(s,s,t))return r.before(o+1);if(s>0)return null}if(r.parentOffset==r.parent.content.size)for(let o=r.depth-1;o>=0;o--){let s=r.indexAfter(o);if(r.node(o).canReplaceWith(s,s,t))return r.after(o+1);if(s<r.node(o).childCount)return null}return null}function vl(n,e,t){let r=n.resolve(e);if(!t.content.size)return e;let o=t.content;for(let s=0;s<t.openStart;s++)o=o.firstChild.content;for(let s=1;s<=(t.openStart==0&&t.size?2:1);s++)for(let i=r.depth;i>=0;i--){let l=i==r.depth?0:r.pos<=(r.start(i+1)+r.end(i+1))/2?-1:1,a=r.index(i)+(l>0?1:0),c=r.node(i),u=!1;if(s==1)u=c.canReplace(a,a,o);else{let d=c.contentMatchAt(a).findWrapping(o.firstChild.type);u=d&&c.canReplaceWith(a,a,d[0])}if(u)return l==0?r.pos:l<0?r.before(i+1):r.after(i+1)}return null}function Rn(n,e,t=e,r=S.empty){if(e==t&&!r.size)return null;let o=n.resolve(e),s=n.resolve(t);return Ps(o,s,r)?new $(e,t,r):new Pl(o,s,r).fit()}function Ps(n,e,t){return!t.openStart&&!t.openEnd&&n.start()==e.start()&&n.parent.canReplace(n.index(),e.index(),t.content)}class Pl{constructor(e,t,r){this.$from=e,this.$to=t,this.unplaced=r,this.frontier=[],this.placed=b.empty;for(let o=0;o<=e.depth;o++){let s=e.node(o);this.frontier.push({type:s.type,match:s.contentMatchAt(e.indexAfter(o))})}for(let o=e.depth;o>0;o--)this.placed=b.from(e.node(o).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let c=this.findFittable();c?this.placeNodes(c):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,r=this.$from,o=this.close(e<0?this.$to:r.doc.resolve(e));if(!o)return null;let s=this.placed,i=r.depth,l=o.depth;for(;i&&l&&s.childCount==1;)s=s.firstChild.content,i--,l--;let a=new S(s,i,l);return e>-1?new F(r.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||r.pos!=this.$to.pos?new $(r.pos,o.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,r=0,o=this.unplaced.openEnd;r<e;r++){let s=t.firstChild;if(t.childCount>1&&(o=0),s.type.spec.isolating&&o<=r){e=r;break}t=s.content}for(let t=1;t<=2;t++)for(let r=t==1?e:this.unplaced.openStart;r>=0;r--){let o,s=null;r?(s=Vn(this.unplaced.content,r-1).firstChild,o=s.content):o=this.unplaced.content;let i=o.firstChild;for(let l=this.depth;l>=0;l--){let{type:a,match:c}=this.frontier[l],u,d=null;if(t==1&&(i?c.matchType(i.type)||(d=c.fillBefore(b.from(i),!1)):s&&a.compatibleContent(s.type)))return{sliceDepth:r,frontierDepth:l,parent:s,inject:d};if(t==2&&i&&(u=c.findWrapping(i.type)))return{sliceDepth:r,frontierDepth:l,parent:s,wrap:u};if(s&&c.matchType(s.type))break}}}openMore(){let{content:e,openStart:t,openEnd:r}=this.unplaced,o=Vn(e,t);return!o.childCount||o.firstChild.isLeaf?!1:(this.unplaced=new S(e,t+1,Math.max(r,o.size+t>=e.size-r?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:r}=this.unplaced,o=Vn(e,t);if(o.childCount<=1&&t>0){let s=e.size-t<=t+o.size;this.unplaced=new S(it(e,t-1,1),t-1,s?t-1:r)}else this.unplaced=new S(it(e,t,1),t,r)}placeNodes({sliceDepth:e,frontierDepth:t,parent:r,inject:o,wrap:s}){for(;this.depth>t;)this.closeFrontierNode();if(s)for(let m=0;m<s.length;m++)this.openFrontierNode(s[m]);let i=this.unplaced,l=r?r.content:i.content,a=i.openStart-e,c=0,u=[],{match:d,type:f}=this.frontier[t];if(o){for(let m=0;m<o.childCount;m++)u.push(o.child(m));d=d.matchFragment(o)}let h=l.size+e-(i.content.size-i.openEnd);for(;c<l.childCount;){let m=l.child(c),g=d.matchType(m.type);if(!g)break;c++,(c>1||a==0||m.content.size)&&(d=g,u.push(zs(m.mark(f.allowedMarks(m.marks)),c==1?a:0,c==l.childCount?h:-1)))}let p=c==l.childCount;p||(h=-1),this.placed=lt(this.placed,t,b.from(u)),this.frontier[t].match=d,p&&h<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let m=0,g=l;m<h;m++){let y=g.lastChild;this.frontier.push({type:y.type,match:y.contentMatchAt(y.childCount)}),g=y.content}this.unplaced=p?e==0?S.empty:new S(it(i.content,e-1,1),e-1,h<0?i.openEnd:e-1):new S(it(i.content,e,c),i.openStart,i.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],t;if(!e.type.isTextblock||!qn(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(t=this.findCloseLevel(this.$to))&&t.depth==this.depth)return-1;let{depth:r}=this.$to,o=this.$to.after(r);for(;r>1&&o==this.$to.end(--r);)++o;return o}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:r,type:o}=this.frontier[t],s=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),i=qn(e,t,o,r,s);if(i){for(let l=t-1;l>=0;l--){let{match:a,type:c}=this.frontier[l],u=qn(e,l,c,a,!0);if(!u||u.childCount)continue e}return{depth:t,fit:i,move:s?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=lt(this.placed,t.depth,t.fit)),e=t.move;for(let r=t.depth+1;r<=e.depth;r++){let o=e.node(r),s=o.type.contentMatch.fillBefore(o.content,!0,e.index(r));this.openFrontierNode(o.type,o.attrs,s)}return e}openFrontierNode(e,t=null,r){let o=this.frontier[this.depth];o.match=o.match.matchType(e),this.placed=lt(this.placed,this.depth,b.from(e.create(t,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(b.empty,!0);t.childCount&&(this.placed=lt(this.placed,this.frontier.length,t))}}function it(n,e,t){return e==0?n.cutByIndex(t,n.childCount):n.replaceChild(0,n.firstChild.copy(it(n.firstChild.content,e-1,t)))}function lt(n,e,t){return e==0?n.append(t):n.replaceChild(n.childCount-1,n.lastChild.copy(lt(n.lastChild.content,e-1,t)))}function Vn(n,e){for(let t=0;t<e;t++)n=n.firstChild.content;return n}function zs(n,e,t){if(e<=0)return n;let r=n.content;return e>1&&(r=r.replaceChild(0,zs(r.firstChild,e-1,r.childCount==1?t-1:0))),e>0&&(r=n.type.contentMatch.fillBefore(r).append(r),t<=0&&(r=r.append(n.type.contentMatch.matchFragment(r).fillBefore(b.empty,!0)))),n.copy(r)}function qn(n,e,t,r,o){let s=n.node(e),i=o?n.indexAfter(e):n.index(e);if(i==s.childCount&&!t.compatibleContent(s.type))return null;let l=r.fillBefore(s.content,!0,i);return l&&!zl(t,s.content,i)?l:null}function zl(n,e,t){for(let r=t;r<e.childCount;r++)if(!n.allowsMarks(e.child(r).marks))return!0;return!1}function Dl(n){return n.spec.defining||n.spec.definingForContent}function Bl(n,e,t,r){if(!r.size)return n.deleteRange(e,t);let o=n.doc.resolve(e),s=n.doc.resolve(t);if(Ps(o,s,r))return n.step(new $(e,t,r));let i=Bs(o,n.doc.resolve(t));i[i.length-1]==0&&i.pop();let l=-(o.depth+1);i.unshift(l);for(let f=o.depth,h=o.pos-1;f>0;f--,h--){let p=o.node(f).type.spec;if(p.defining||p.definingAsContext||p.isolating)break;i.indexOf(f)>-1?l=f:o.before(f)==h&&i.splice(1,0,-f)}let a=i.indexOf(l),c=[],u=r.openStart;for(let f=r.content,h=0;;h++){let p=f.firstChild;if(c.push(p),h==r.openStart)break;f=p.content}for(let f=u-1;f>=0;f--){let h=c[f],p=Dl(h.type);if(p&&!h.sameMarkup(o.node(Math.abs(l)-1)))u=f;else if(p||!h.type.isTextblock)break}for(let f=r.openStart;f>=0;f--){let h=(f+u+1)%(r.openStart+1),p=c[h];if(p)for(let m=0;m<i.length;m++){let g=i[(m+a)%i.length],y=!0;g<0&&(y=!1,g=-g);let M=o.node(g-1),A=o.index(g-1);if(M.canReplaceWith(A,A,p.type,p.marks))return n.replace(o.before(g),y?s.after(g):t,new S(Ds(r.content,0,r.openStart,h),h,r.openEnd))}}let d=n.steps.length;for(let f=i.length-1;f>=0&&(n.replace(e,t,r),!(n.steps.length>d));f--){let h=i[f];h<0||(e=o.before(h),t=s.after(h))}}function Ds(n,e,t,r,o){if(e<t){let s=n.firstChild;n=n.replaceChild(0,s.copy(Ds(s.content,e+1,t,r,s)))}if(e>r){let s=o.contentMatchAt(0),i=s.fillBefore(n).append(n);n=i.append(s.matchFragment(i).fillBefore(b.empty,!0))}return n}function Hl(n,e,t,r){if(!r.isInline&&e==t&&n.doc.resolve(e).parent.content.size){let o=Ll(n.doc,e,r.type);o!=null&&(e=t=o)}n.replaceRange(e,t,new S(b.from(r),0,0))}function $l(n,e,t){let r=n.doc.resolve(e),o=n.doc.resolve(t),s=Bs(r,o);for(let i=0;i<s.length;i++){let l=s[i],a=i==s.length-1;if(a&&l==0||r.node(l).type.contentMatch.validEnd)return n.delete(r.start(l),o.end(l));if(l>0&&(a||r.node(l-1).canReplace(r.index(l-1),o.indexAfter(l-1))))return n.delete(r.before(l),o.after(l))}for(let i=1;i<=r.depth&&i<=o.depth;i++)if(e-r.start(i)==r.depth-i&&t>r.end(i)&&o.end(i)-t!=o.depth-i)return n.delete(r.before(i),t);n.delete(e,t)}function Bs(n,e){let t=[],r=Math.min(n.depth,e.depth);for(let o=r;o>=0;o--){let s=n.start(o);if(s<n.pos-(n.depth-o)||e.end(o)>e.pos+(e.depth-o)||n.node(o).type.spec.isolating||e.node(o).type.spec.isolating)break;(s==e.start(o)||o==n.depth&&o==e.depth&&n.parent.inlineContent&&e.parent.inlineContent&&o&&e.start(o-1)==s-1)&&t.push(o)}return t}class Qe extends V{constructor(e,t,r){super(),this.pos=e,this.attr=t,this.value=r}apply(e){let t=e.nodeAt(this.pos);if(!t)return B.fail("No node at attribute step's position");let r=Object.create(null);for(let s in t.attrs)r[s]=t.attrs[s];r[this.attr]=this.value;let o=t.type.create(r,null,t.marks);return B.fromReplace(e,this.pos,this.pos+1,new S(b.from(o),0,t.isLeaf?0:1))}getMap(){return G.empty}invert(e){return new Qe(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 Qe(t.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.pos!="number"||typeof t.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new Qe(t.pos,t.attr,t.value)}}V.jsonID("attr",Qe);class mt extends V{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let o in e.attrs)t[o]=e.attrs[o];t[this.attr]=this.value;let r=e.type.create(t,e.content,e.marks);return B.ok(r)}getMap(){return G.empty}invert(e){return new mt(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new mt(t.attr,t.value)}}V.jsonID("docAttr",mt);let Ze=class extends Error{};Ze=function n(e){let t=Error.call(this,e);return t.__proto__=n.prototype,t};Ze.prototype=Object.create(Error.prototype);Ze.prototype.constructor=Ze;Ze.prototype.name="TransformError";class Hs{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new ct}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,r=S.empty){let o=Rn(this.doc,e,t,r);return o&&this.step(o),this}replaceWith(e,t,r){return this.replace(e,t,new S(b.from(r),0,0))}delete(e,t){return this.replace(e,t,S.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,r){return Bl(this,e,t,r),this}replaceRangeWith(e,t,r){return Hl(this,e,t,r),this}deleteRange(e,t){return $l(this,e,t),this}lift(e,t){return Cl(this,e,t),this}join(e,t=1){return Il(this,e,t),this}wrap(e,t){return Tl(this,e,t),this}setBlockType(e,t=e,r,o=null){return Al(this,e,t,r,o),this}setNodeMarkup(e,t,r=null,o){return Rl(this,e,t,r,o),this}setNodeAttribute(e,t,r){return this.step(new Qe(e,t,r)),this}setDocAttribute(e,t){return this.step(new mt(e,t)),this}addNodeMark(e,t){return this.step(new Ae(e,t)),this}removeNodeMark(e,t){if(!(t instanceof _)){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(t=t.isInSet(r.marks),!t)return this}return this.step(new Ye(e,t)),this}split(e,t=1,r){return Ol(this,e,t,r),this}addMark(e,t,r){return bl(this,e,t,r),this}removeMark(e,t,r){return kl(this,e,t,r),this}clearIncompatible(e,t,r){return Ls(this,e,t,r),this}}const Jn=Object.create(null);class x{constructor(e,t,r){this.$anchor=e,this.$head=t,this.ranges=r||[new $s(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=S.empty){let r=t.content.lastChild,o=null;for(let l=0;l<t.openEnd;l++)o=r,r=r.lastChild;let s=e.steps.length,i=this.ranges;for(let l=0;l<i.length;l++){let{$from:a,$to:c}=i[l],u=e.mapping.slice(s);e.replaceRange(u.map(a.pos),u.map(c.pos),l?S.empty:t),l==0&&xo(e,s,(r?r.isInline:o&&o.isTextblock)?-1:1)}}replaceWith(e,t){let r=e.steps.length,o=this.ranges;for(let s=0;s<o.length;s++){let{$from:i,$to:l}=o[s],a=e.mapping.slice(r),c=a.map(i.pos),u=a.map(l.pos);s?e.deleteRange(c,u):(e.replaceRangeWith(c,u,t),xo(e,r,t.isInline?-1:1))}}static findFrom(e,t,r=!1){let o=e.parent.inlineContent?new w(e):Je(e.node(0),e.parent,e.pos,e.index(),t,r);if(o)return o;for(let s=e.depth-1;s>=0;s--){let i=t<0?Je(e.node(0),e.node(s),e.before(s+1),e.index(s),t,r):Je(e.node(0),e.node(s),e.after(s+1),e.index(s)+1,t,r);if(i)return i}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new oe(e.node(0))}static atStart(e){return Je(e,e,0,0,1)||new oe(e)}static atEnd(e){return Je(e,e,e.content.size,e.childCount,-1)||new oe(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=Jn[t.type];if(!r)throw new RangeError(`No selection type ${t.type} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in Jn)throw new RangeError("Duplicate use of selection JSON ID "+e);return Jn[e]=t,t.prototype.jsonID=e,t}getBookmark(){return w.between(this.$anchor,this.$head).getBookmark()}}x.prototype.visible=!0;class $s{constructor(e,t){this.$from=e,this.$to=t}}let Co=!1;function wo(n){!Co&&!n.parent.inlineContent&&(Co=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+n.parent.type.name+")"))}class w extends x{constructor(e,t=e){wo(e),wo(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let r=e.resolve(t.map(this.head));if(!r.parent.inlineContent)return x.near(r);let o=e.resolve(t.map(this.anchor));return new w(o.parent.inlineContent?o:r,r)}replace(e,t=S.empty){if(super.replace(e,t),t==S.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof w&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new On(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if(typeof t.anchor!="number"||typeof t.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new w(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,r=t){let o=e.resolve(t);return new this(o,r==t?o:e.resolve(r))}static between(e,t,r){let o=e.pos-t.pos;if((!r||o)&&(r=o>=0?1:-1),!t.parent.inlineContent){let s=x.findFrom(t,r,!0)||x.findFrom(t,-r,!0);if(s)t=s.$head;else return x.near(t,r)}return e.parent.inlineContent||(o==0?e=t:(e=(x.findFrom(e,-r,!0)||x.findFrom(e,r,!0)).$anchor,e.pos<t.pos!=o<0&&(e=t))),new w(e,t)}}x.jsonID("text",w);class On{constructor(e,t){this.anchor=e,this.head=t}map(e){return new On(e.map(this.anchor),e.map(this.head))}resolve(e){return w.between(e.resolve(this.anchor),e.resolve(this.head))}}class C extends x{constructor(e){let t=e.nodeAfter,r=e.node(0).resolve(e.pos+t.nodeSize);super(e,r),this.node=t}map(e,t){let{deleted:r,pos:o}=t.mapResult(this.anchor),s=e.resolve(o);return r?x.near(s):new C(s)}content(){return new S(b.from(this.node),0,0)}eq(e){return e instanceof C&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new $r(this.anchor)}static fromJSON(e,t){if(typeof t.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new C(e.resolve(t.anchor))}static create(e,t){return new C(e.resolve(t))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}C.prototype.visible=!1;x.jsonID("node",C);class $r{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:r}=e.mapResult(this.anchor);return t?new On(r,r):new $r(r)}resolve(e){let t=e.resolve(this.anchor),r=t.nodeAfter;return r&&C.isSelectable(r)?new C(t):x.near(t)}}class oe extends x{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=S.empty){if(t==S.empty){e.delete(0,e.doc.content.size);let r=x.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new oe(e)}map(e){return new oe(e)}eq(e){return e instanceof oe}getBookmark(){return Fl}}x.jsonID("all",oe);const Fl={map(){return this},resolve(n){return new oe(n)}};function Je(n,e,t,r,o,s=!1){if(e.inlineContent)return w.create(n,t);for(let i=r-(o>0?0:1);o>0?i<e.childCount:i>=0;i+=o){let l=e.child(i);if(l.isAtom){if(!s&&C.isSelectable(l))return C.create(n,t-(o<0?l.nodeSize:0))}else{let a=Je(n,l,t+o,o<0?l.childCount:0,o,s);if(a)return a}t+=l.nodeSize*o}return null}function xo(n,e,t){let r=n.steps.length-1;if(r<e)return;let o=n.steps[r];if(!(o instanceof $||o instanceof F))return;let s=n.mapping.maps[r],i;s.forEach((l,a,c,u)=>{i==null&&(i=u)}),n.setSelection(x.near(n.doc.resolve(i),t))}function To(n,e){return!e||!n?n:n.bind(e)}class Et{constructor(e,t,r){this.name=e,this.init=To(t.init,r),this.apply=To(t.apply,r)}}new Et("doc",{init(n){return n.doc||n.schema.topNodeType.createAndFill()},apply(n){return n.doc}}),new Et("selection",{init(n,e){return n.selection||x.atStart(e.doc)},apply(n){return n.selection}}),new Et("storedMarks",{init(n){return n.storedMarks||null},apply(n,e,t,r){return r.selection.$cursor?n.storedMarks:null}}),new Et("scrollToSelection",{init(){return 0},apply(n,e){return n.scrolledIntoView?e+1:e}});function Fs(n,e,t){for(let r in n){let o=n[r];o instanceof Function?o=o.bind(e):r=="handleDOMEvents"&&(o=Fs(o,e,{})),t[r]=o}return t}class ie{constructor(e){this.spec=e,this.props={},e.props&&Fs(e.props,this,this.props),this.key=e.key?e.key.key:js("plugin")}getState(e){return e[this.key]}}const Un=Object.create(null);function js(n){return n in Un?n+"$"+ ++Un[n]:(Un[n]=0,n+"$")}class te{constructor(e="key"){this.key=js(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const Fe=function(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e},Ws=function(n,e,t,r){return t&&(Ao(n,e,t,r,-1)||Ao(n,e,t,r,1))},jl=/^(img|br|input|textarea|hr)$/i;function Ao(n,e,t,r,o){for(;;){if(n==t&&e==r)return!0;if(e==(o<0?0:Vt(n))){let s=n.parentNode;if(!s||s.nodeType!=1||Fr(n)||jl.test(n.nodeName)||n.contentEditable=="false")return!1;e=Fe(n)+(o<0?0:1),n=s}else if(n.nodeType==1){if(n=n.childNodes[e+(o<0?-1:0)],n.contentEditable=="false")return!1;e=o<0?Vt(n):0}else return!1}}function Vt(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Wl(n,e,t){for(let r=e==0,o=e==Vt(n);r||o;){if(n==t)return!0;let s=Fe(n);if(n=n.parentNode,!n)return!1;r=r&&s==0,o=o&&s==Vt(n)}}function Fr(n){let e;for(let t=n;t&&!(e=t.pmViewDesc);t=t.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==n||e.contentDOM==n)}const Ks=function(n){return n.focusNode&&Ws(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)};function Vs(n,e){let t=document.createEvent("Event");return t.initEvent("keydown",!0,!0),t.keyCode=n,t.key=t.code=e,t}const pe=typeof navigator<"u"?navigator:null,Mo=typeof document<"u"?document:null,Oe=pe&&pe.userAgent||"",mr=/Edge\/(\d+)/.exec(Oe),qs=/MSIE \d/.exec(Oe),gr=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Oe),wt=!!(qs||gr||mr),Js=qs?document.documentMode:gr?+gr[1]:mr?+mr[1]:0,In=!wt&&/gecko\/(\d+)/i.test(Oe);In&&+(/Firefox\/(\d+)/.exec(Oe)||[0,0])[1];const yr=!wt&&/Chrome\/(\d+)/.exec(Oe),je=!!yr,Kl=yr?+yr[1]:0,We=!wt&&!!pe&&/Apple Computer/.test(pe.vendor),jr=We&&(/Mobile\/\w+/.test(Oe)||!!pe&&pe.maxTouchPoints>2),Z=jr||(pe?/Mac/.test(pe.platform):!1),Vl=pe?/Win/.test(pe.platform):!1,xt=/Android \d/.test(Oe),Wr=!!Mo&&"webkitFontSmoothing"in Mo.documentElement.style,ql=Wr?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Jl(n,e=null){let t=n.domSelectionRange(),r=n.state.doc;if(!t.focusNode)return null;let o=n.docView.nearestDesc(t.focusNode),s=o&&o.size==0,i=n.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(i<0)return null;let l=r.resolve(i),a,c;if(Ks(t)){for(a=l;o&&!o.node;)o=o.parent;let u=o.node;if(o&&u.isAtom&&C.isSelectable(u)&&o.parent&&!(u.isInline&&Wl(t.focusNode,t.focusOffset,o.dom))){let d=o.posBefore;c=new C(i==d?l:r.resolve(d))}}else{let u=n.docView.posFromDOM(t.anchorNode,t.anchorOffset,1);if(u<0)return null;a=r.resolve(u)}if(!c){let u=e=="pointer"||n.state.selection.head<l.pos&&!s?1:-1;c=_s(n,a,l,u)}return c}function Us(n){return n.editable?n.hasFocus():Ql(n)&&document.activeElement&&document.activeElement.contains(n.dom)}function Kr(n,e=!1){let t=n.state.selection;if(Gl(n,t),!!Us(n)){if(!e&&n.input.mouseDown&&n.input.mouseDown.allowDefault&&je){let r=n.domSelectionRange(),o=n.domObserver.currentSelection;if(r.anchorNode&&o.anchorNode&&Ws(r.anchorNode,r.anchorOffset,o.anchorNode,o.anchorOffset)){n.input.mouseDown.delayedSelectionSync=!0,n.domObserver.setCurSelection();return}}if(n.domObserver.disconnectSelection(),n.cursorWrapper)_l(n);else{let{anchor:r,head:o}=t,s,i;Eo&&!(t instanceof w)&&(t.$from.parent.inlineContent||(s=No(n,t.from)),!t.empty&&!t.$from.parent.inlineContent&&(i=No(n,t.to))),n.docView.setSelection(r,o,n.root,e),Eo&&(s&&Ro(s),i&&Ro(i)),t.visible?n.dom.classList.remove("ProseMirror-hideselection"):(n.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&Ul(n))}n.domObserver.setCurSelection(),n.domObserver.connectSelection()}}const Eo=We||je&&Kl<63;function No(n,e){let{node:t,offset:r}=n.docView.domFromPos(e,0),o=r<t.childNodes.length?t.childNodes[r]:null,s=r?t.childNodes[r-1]:null;if(We&&o&&o.contentEditable=="false")return _n(o);if((!o||o.contentEditable=="false")&&(!s||s.contentEditable=="false")){if(o)return _n(o);if(s)return _n(s)}}function _n(n){return n.contentEditable="true",We&&n.draggable&&(n.draggable=!1,n.wasDraggable=!0),n}function Ro(n){n.contentEditable="false",n.wasDraggable&&(n.draggable=!0,n.wasDraggable=null)}function Ul(n){let e=n.dom.ownerDocument;e.removeEventListener("selectionchange",n.input.hideSelectionGuard);let t=n.domSelectionRange(),r=t.anchorNode,o=t.anchorOffset;e.addEventListener("selectionchange",n.input.hideSelectionGuard=()=>{(t.anchorNode!=r||t.anchorOffset!=o)&&(e.removeEventListener("selectionchange",n.input.hideSelectionGuard),setTimeout(()=>{(!Us(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function _l(n){let e=n.domSelection(),t=document.createRange(),r=n.cursorWrapper.dom,o=r.nodeName=="IMG";o?t.setEnd(r.parentNode,Fe(r)+1):t.setEnd(r,0),t.collapse(!1),e.removeAllRanges(),e.addRange(t),!o&&!n.state.selection.visible&&wt&&Js<=11&&(r.disabled=!0,r.disabled=!1)}function Gl(n,e){if(e instanceof C){let t=n.docView.descAt(e.from);t!=n.lastSelectedViewDesc&&(Oo(n),t&&t.selectNode(),n.lastSelectedViewDesc=t)}else Oo(n)}function Oo(n){n.lastSelectedViewDesc&&(n.lastSelectedViewDesc.parent&&n.lastSelectedViewDesc.deselectNode(),n.lastSelectedViewDesc=void 0)}function _s(n,e,t,r){return n.someProp("createSelectionBetween",o=>o(n,e,t))||w.between(e,t,r)}function Ql(n){let e=n.domSelectionRange();if(!e.anchorNode)return!1;try{return n.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(n.editable||n.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function br(n,e){let{$anchor:t,$head:r}=n.selection,o=e>0?t.max(r):t.min(r),s=o.parent.inlineContent?o.depth?n.doc.resolve(e>0?o.after():o.before()):null:o;return s&&x.findFrom(s,e)}function Se(n,e){return n.dispatch(n.state.tr.setSelection(e).scrollIntoView()),!0}function Io(n,e,t){let r=n.state.selection;if(r instanceof w)if(t.indexOf("s")>-1){let{$head:o}=r,s=o.textOffset?null:e<0?o.nodeBefore:o.nodeAfter;if(!s||s.isText||!s.isLeaf)return!1;let i=n.state.doc.resolve(o.pos+s.nodeSize*(e<0?-1:1));return Se(n,new w(r.$anchor,i))}else if(r.empty){if(n.endOfTextblock(e>0?"forward":"backward")){let o=br(n.state,e);return o&&o instanceof C?Se(n,o):!1}else if(!(Z&&t.indexOf("m")>-1)){let o=r.$head,s=o.textOffset?null:e<0?o.nodeBefore:o.nodeAfter,i;if(!s||s.isText)return!1;let l=e<0?o.pos-s.nodeSize:o.pos;return s.isAtom||(i=n.docView.descAt(l))&&!i.contentDOM?C.isSelectable(s)?Se(n,new C(e<0?n.state.doc.resolve(o.pos-s.nodeSize):o)):Wr?Se(n,new w(n.state.doc.resolve(e<0?l:l+s.nodeSize))):!1:!1}}else return!1;else{if(r instanceof C&&r.node.isInline)return Se(n,new w(e>0?r.$to:r.$from));{let o=br(n.state,e);return o?Se(n,o):!1}}}function qt(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function ut(n,e){let t=n.pmViewDesc;return t&&t.size==0&&(e<0||n.nextSibling||n.nodeName!="BR")}function Ve(n,e){return e<0?Xl(n):Yl(n)}function Xl(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let o,s,i=!1;for(In&&t.nodeType==1&&r<qt(t)&&ut(t.childNodes[r],-1)&&(i=!0);;)if(r>0){if(t.nodeType!=1)break;{let l=t.childNodes[r-1];if(ut(l,-1))o=t,s=--r;else if(l.nodeType==3)t=l,r=t.nodeValue.length;else break}}else{if(Gs(t))break;{let l=t.previousSibling;for(;l&&ut(l,-1);)o=t.parentNode,s=Fe(l),l=l.previousSibling;if(l)t=l,r=qt(t);else{if(t=t.parentNode,t==n.dom)break;r=0}}}i?kr(n,t,r):o&&kr(n,o,s)}function Yl(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let o=qt(t),s,i;for(;;)if(r<o){if(t.nodeType!=1)break;let l=t.childNodes[r];if(ut(l,1))s=t,i=++r;else break}else{if(Gs(t))break;{let l=t.nextSibling;for(;l&&ut(l,1);)s=l.parentNode,i=Fe(l)+1,l=l.nextSibling;if(l)t=l,r=0,o=qt(t);else{if(t=t.parentNode,t==n.dom)break;r=o=0}}}s&&kr(n,s,i)}function Gs(n){let e=n.pmViewDesc;return e&&e.node&&e.node.isBlock}function Zl(n,e){for(;n&&e==n.childNodes.length&&!Fr(n);)e=Fe(n)+1,n=n.parentNode;for(;n&&e<n.childNodes.length;){let t=n.childNodes[e];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;n=t,e=0}}function ea(n,e){for(;n&&!e&&!Fr(n);)e=Fe(n),n=n.parentNode;for(;n&&e;){let t=n.childNodes[e-1];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;n=t,e=n.childNodes.length}}function kr(n,e,t){if(e.nodeType!=3){let s,i;(i=Zl(e,t))?(e=i,t=0):(s=ea(e,t))&&(e=s,t=s.nodeValue.length)}let r=n.domSelection();if(Ks(r)){let s=document.createRange();s.setEnd(e,t),s.setStart(e,t),r.removeAllRanges(),r.addRange(s)}else r.extend&&r.extend(e,t);n.domObserver.setCurSelection();let{state:o}=n;setTimeout(()=>{n.state==o&&Kr(n)},50)}function Lo(n,e){let t=n.state.doc.resolve(e);if(!(je||Vl)&&t.parent.inlineContent){let o=n.coordsAtPos(e);if(e>t.start()){let s=n.coordsAtPos(e-1),i=(s.top+s.bottom)/2;if(i>o.top&&i<o.bottom&&Math.abs(s.left-o.left)>1)return s.left<o.left?"ltr":"rtl"}if(e<t.end()){let s=n.coordsAtPos(e+1),i=(s.top+s.bottom)/2;if(i>o.top&&i<o.bottom&&Math.abs(s.left-o.left)>1)return s.left>o.left?"ltr":"rtl"}}return getComputedStyle(n.dom).direction=="rtl"?"rtl":"ltr"}function vo(n,e,t){let r=n.state.selection;if(r instanceof w&&!r.empty||t.indexOf("s")>-1||Z&&t.indexOf("m")>-1)return!1;let{$from:o,$to:s}=r;if(!o.parent.inlineContent||n.endOfTextblock(e<0?"up":"down")){let i=br(n.state,e);if(i&&i instanceof C)return Se(n,i)}if(!o.parent.inlineContent){let i=e<0?o:s,l=r instanceof oe?x.near(i,e):x.findFrom(i,e);return l?Se(n,l):!1}return!1}function Po(n,e){if(!(n.state.selection instanceof w))return!0;let{$head:t,$anchor:r,empty:o}=n.state.selection;if(!t.sameParent(r))return!0;if(!o)return!1;if(n.endOfTextblock(e>0?"forward":"backward"))return!0;let s=!t.textOffset&&(e<0?t.nodeBefore:t.nodeAfter);if(s&&!s.isText){let i=n.state.tr;return e<0?i.delete(t.pos-s.nodeSize,t.pos):i.delete(t.pos,t.pos+s.nodeSize),n.dispatch(i),!0}return!1}function zo(n,e,t){n.domObserver.stop(),e.contentEditable=t,n.domObserver.start()}function ta(n){if(!We||n.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:t}=n.domSelectionRange();if(e&&e.nodeType==1&&t==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let r=e.firstChild;zo(n,r,"true"),setTimeout(()=>zo(n,r,"false"),20)}return!1}function na(n){let e="";return n.ctrlKey&&(e+="c"),n.metaKey&&(e+="m"),n.altKey&&(e+="a"),n.shiftKey&&(e+="s"),e}function ra(n,e){let t=e.keyCode,r=na(e);if(t==8||Z&&t==72&&r=="c")return Po(n,-1)||Ve(n,-1);if(t==46&&!e.shiftKey||Z&&t==68&&r=="c")return Po(n,1)||Ve(n,1);if(t==13||t==27)return!0;if(t==37||Z&&t==66&&r=="c"){let o=t==37?Lo(n,n.state.selection.from)=="ltr"?-1:1:-1;return Io(n,o,r)||Ve(n,o)}else if(t==39||Z&&t==70&&r=="c"){let o=t==39?Lo(n,n.state.selection.from)=="ltr"?1:-1:1;return Io(n,o,r)||Ve(n,o)}else{if(t==38||Z&&t==80&&r=="c")return vo(n,-1,r)||Ve(n,-1);if(t==40||Z&&t==78&&r=="c")return ta(n)||vo(n,1,r)||Ve(n,1);if(r==(Z?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function Qs(n,e){n.someProp("transformCopied",h=>{e=h(e,n)});let t=[],{content:r,openStart:o,openEnd:s}=e;for(;o>1&&s>1&&r.childCount==1&&r.firstChild.childCount==1;){o--,s--;let h=r.firstChild;t.push(h.type.name,h.attrs!=h.type.defaultAttrs?h.attrs:null),r=h.content}let i=n.someProp("clipboardSerializer")||ve.fromSchema(n.state.schema),l=ni(),a=l.createElement("div");a.appendChild(i.serializeFragment(r,{document:l}));let c=a.firstChild,u,d=0;for(;c&&c.nodeType==1&&(u=ti[c.nodeName.toLowerCase()]);){for(let h=u.length-1;h>=0;h--){let p=l.createElement(u[h]);for(;a.firstChild;)p.appendChild(a.firstChild);a.appendChild(p),d++}c=a.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${o} ${s}${d?` -${d}`:""} ${JSON.stringify(t)}`);let f=n.someProp("clipboardTextSerializer",h=>h(e,n))||e.content.textBetween(0,e.content.size,`
3
+ `))}ignoreFallback(e){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"))}readStyles(e){let t=_.none,r=_.none;if(e.length)for(let o=0;o<this.parser.matchedStyles.length;o++){let s=this.parser.matchedStyles[o],i=e.getPropertyValue(s);if(i)for(let l=void 0;;){let a=this.parser.matchStyle(s,i,this,l);if(!a)break;if(a.ignore)return null;if(a.clearMark?this.top.pendingMarks.concat(this.top.activeMarks).forEach(c=>{a.clearMark(c)&&(r=c.addToSet(r))}):t=this.parser.schema.marks[a.mark].create(a.attrs).addToSet(t),a.consuming===!1)l=a;else break}}return[t,r]}addElementByRule(e,t,r){let o,s,i;t.node?(s=this.parser.schema.nodes[t.node],s.isLeaf?this.insertNode(s.create(t.attrs))||this.leafFallback(e):o=this.enter(s,t.attrs||null,t.preserveWhitespace)):(i=this.parser.schema.marks[t.mark].create(t.attrs),this.addPendingMark(i));let l=this.top;if(s&&s.isLeaf)this.findInside(e);else if(r)this.addElement(e,r);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a));else{let a=e;typeof t.contentElement=="string"?a=e.querySelector(t.contentElement):typeof t.contentElement=="function"?a=t.contentElement(e):t.contentElement&&(a=t.contentElement),this.findAround(e,a,!0),this.addAll(a)}o&&this.sync(l)&&this.open--,i&&this.removePendingMark(i,l)}addAll(e,t,r){let o=t||0;for(let s=t?e.childNodes[t]:e.firstChild,i=r==null?null:e.childNodes[r];s!=i;s=s.nextSibling,++o)this.findAtPoint(e,o),this.addDOM(s);this.findAtPoint(e,o)}findPlace(e){let t,r;for(let o=this.open;o>=0;o--){let s=this.nodes[o],i=s.findWrapping(e);if(i&&(!t||t.length>i.length)&&(t=i,r=s,!i.length)||s.solid)break}if(!t)return!1;this.sync(r);for(let o=0;o<t.length;o++)this.enterInner(t[o],null,!1);return!0}insertNode(e){if(e.isInline&&this.needsBlock&&!this.top.type){let t=this.textblockFromContext();t&&this.enterInner(t)}if(this.findPlace(e)){this.closeExtra();let t=this.top;t.applyPending(e.type),t.match&&(t.match=t.match.matchType(e.type));let r=t.activeMarks;for(let o=0;o<e.marks.length;o++)(!t.type||t.type.allowsMarkType(e.marks[o].type))&&(r=e.marks[o].addToSet(r));return t.content.push(e.mark(r)),!0}return!1}enter(e,t,r){let o=this.findPlace(e.create(t));return o&&this.enterInner(e,t,!0,r),o}enterInner(e,t=null,r=!1,o){this.closeExtra();let s=this.top;s.applyPending(e),s.match=s.match&&s.match.matchType(e);let i=mo(e,o,s.options);s.options&at&&s.content.length==0&&(i|=at),this.nodes.push(new Mt(e,t,s.activeMarks,s.pendingMarks,r,null,i)),this.open++}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;return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let r=this.nodes[t].content;for(let o=r.length-1;o>=0;o--)e+=r[o].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==t&&(this.find[r].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].pos==null&&e.nodeType==1&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,r){if(e!=t&&this.find)for(let o=0;o<this.find.length;o++)this.find[o].pos==null&&e.nodeType==1&&e.contains(this.find[o].node)&&t.compareDocumentPosition(this.find[o].node)&(r?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("/"),r=this.options.context,o=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),s=-(r?r.depth+1:0)+(o?0:1),i=(l,a)=>{for(;l>=0;l--){let c=t[l];if(c==""){if(l==t.length-1||l==0)continue;for(;a>=s;a--)if(i(l-1,a))return!0;return!1}else{let u=a>0||a==0&&o?this.nodes[a].type:r&&a>=s?r.node(a-s).type:null;if(!u||u.name!=c&&u.groups.indexOf(c)==-1)return!1;a--}}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 r=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let t in this.parser.schema.nodes){let r=this.parser.schema.nodes[t];if(r.isTextblock&&r.defaultAttrs)return r}}addPendingMark(e){let t=ml(e,this.top.pendingMarks);t&&this.top.stashMarks.push(t),this.top.pendingMarks=e.addToSet(this.top.pendingMarks)}removePendingMark(e,t){for(let r=this.open;r>=0;r--){let o=this.nodes[r];if(o.pendingMarks.lastIndexOf(e)>-1)o.pendingMarks=e.removeFromSet(o.pendingMarks);else{o.activeMarks=e.removeFromSet(o.activeMarks);let i=o.popFromStashMark(e);i&&o.type&&o.type.allowsMarkType(i.type)&&(o.activeMarks=i.addToSet(o.activeMarks))}if(o==t)break}}}function fl(n){for(let e=n.firstChild,t=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&Ms.hasOwnProperty(r)&&t?(t.appendChild(e),e=t):r=="li"?t=e:r&&(t=null)}}function hl(n,e){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,e)}function yo(n){let e={};for(let t in n)e[t]=n[t];return e}function pl(n,e){let t=e.schema.nodes;for(let r in t){let o=t[r];if(!o.allowsMarkType(n))continue;let s=[],i=l=>{s.push(l);for(let a=0;a<l.edgeCount;a++){let{type:c,next:u}=l.edge(a);if(c==e||s.indexOf(u)<0&&i(u))return!0}};if(i(o.contentMatch))return!0}}function ml(n,e){for(let t=0;t<e.length;t++)if(n.eq(e[t]))return e[t]}class ve{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},r){r||(r=Wn(t).createDocumentFragment());let o=r,s=[];return e.forEach(i=>{if(s.length||i.marks.length){let l=0,a=0;for(;l<s.length&&a<i.marks.length;){let c=i.marks[a];if(!this.marks[c.type.name]){a++;continue}if(!c.eq(s[l][0])||c.type.spec.spanning===!1)break;l++,a++}for(;l<s.length;)o=s.pop()[1];for(;a<i.marks.length;){let c=i.marks[a++],u=this.serializeMark(c,i.isInline,t);u&&(s.push([c,o]),o.appendChild(u.dom),o=u.contentDOM||u.dom)}}o.appendChild(this.serializeNodeInner(i,t))}),r}serializeNodeInner(e,t){let{dom:r,contentDOM:o}=ve.renderSpec(Wn(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 r}serializeNode(e,t={}){let r=this.serializeNodeInner(e,t);for(let o=e.marks.length-1;o>=0;o--){let s=this.serializeMark(e.marks[o],e.isInline,t);s&&((s.contentDOM||s.dom).appendChild(r),r=s.dom)}return r}serializeMark(e,t,r={}){let o=this.marks[e.type.name];return o&&ve.renderSpec(Wn(r),o(e,t))}static renderSpec(e,t,r=null){if(typeof t=="string")return{dom:e.createTextNode(t)};if(t.nodeType!=null)return{dom:t};if(t.dom&&t.dom.nodeType!=null)return t;let o=t[0],s=o.indexOf(" ");s>0&&(r=o.slice(0,s),o=o.slice(s+1));let i,l=r?e.createElementNS(r,o):e.createElement(o),a=t[1],c=1;if(a&&typeof a=="object"&&a.nodeType==null&&!Array.isArray(a)){c=2;for(let u in a)if(a[u]!=null){let d=u.indexOf(" ");d>0?l.setAttributeNS(u.slice(0,d),u.slice(d+1),a[u]):l.setAttribute(u,a[u])}}for(let u=c;u<t.length;u++){let d=t[u];if(d===0){if(u<t.length-1||u>c)throw new RangeError("Content hole must be the only child of its parent node");return{dom:l,contentDOM:l}}else{let{dom:f,contentDOM:h}=ve.renderSpec(e,d,r);if(l.appendChild(f),h){if(i)throw new RangeError("Multiple content holes");i=h}}}return{dom:l,contentDOM:i}}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new ve(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=bo(e.nodes);return t.text||(t.text=r=>r.text),t}static marksFromSchema(e){return bo(e.marks)}}function bo(n){let e={};for(let t in n){let r=n[t].spec.toDOM;r&&(e[t]=r)}return e}function Wn(n){return n.document||window.document}const Es=65535,Ns=Math.pow(2,16);function gl(n,e){return n+e*Ns}function ko(n){return n&Es}function yl(n){return(n-(n&Es))/Ns}const Rs=1,Os=2,Dt=4,Is=8;class hr{constructor(e,t,r){this.pos=e,this.delInfo=t,this.recover=r}get deleted(){return(this.delInfo&Is)>0}get deletedBefore(){return(this.delInfo&(Rs|Dt))>0}get deletedAfter(){return(this.delInfo&(Os|Dt))>0}get deletedAcross(){return(this.delInfo&Dt)>0}}class G{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&G.empty)return G.empty}recover(e){let t=0,r=ko(e);if(!this.inverted)for(let o=0;o<r;o++)t+=this.ranges[o*3+2]-this.ranges[o*3+1];return this.ranges[r*3]+t+yl(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,r){let o=0,s=this.inverted?2:1,i=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?o:0);if(a>e)break;let c=this.ranges[l+s],u=this.ranges[l+i],d=a+c;if(e<=d){let f=c?e==a?-1:e==d?1:t:t,h=a+o+(f<0?0:u);if(r)return h;let p=e==(t<0?a:d)?null:gl(l/3,e-a),m=e==a?Os:e==d?Rs:Dt;return(t<0?e!=a:e!=d)&&(m|=Is),new hr(h,m,p)}o+=u-c}return r?e+o:new hr(e+o,0,null)}touches(e,t){let r=0,o=ko(t),s=this.inverted?2:1,i=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?r:0);if(a>e)break;let c=this.ranges[l+s],u=a+c;if(e<=u&&l==o*3)return!0;r+=this.ranges[l+i]-c}return!1}forEach(e){let t=this.inverted?2:1,r=this.inverted?1:2;for(let o=0,s=0;o<this.ranges.length;o+=3){let i=this.ranges[o],l=i-(this.inverted?s:0),a=i+(this.inverted?0:s),c=this.ranges[o+t],u=this.ranges[o+r];e(l,l+c,a,a+u),s+=u-c}}invert(){return new G(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?G.empty:new G(e<0?[0,-e,0]:[0,0,e])}}G.empty=new G([]);class ct{constructor(e=[],t,r=0,o=e.length){this.maps=e,this.mirror=t,this.from=r,this.to=o}slice(e=0,t=this.maps.length){return new ct(this.maps,this.mirror,e,t)}copy(){return new ct(this.maps.slice(),this.mirror&&this.mirror.slice(),this.from,this.to)}appendMap(e,t){this.to=this.maps.push(e),t!=null&&this.setMirror(this.maps.length-1,t)}appendMapping(e){for(let t=0,r=this.maps.length;t<e.maps.length;t++){let o=e.getMirror(t);this.appendMap(e.maps[t],o!=null&&o<t?r+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,r=this.maps.length+e.maps.length;t>=0;t--){let o=e.getMirror(t);this.appendMap(e.maps[t].invert(),o!=null&&o>t?r-o-1:void 0)}}invert(){let e=new ct;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let r=this.from;r<this.to;r++)e=this.maps[r].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,r){let o=0;for(let s=this.from;s<this.to;s++){let i=this.maps[s],l=i.mapResult(e,t);if(l.recover!=null){let a=this.getMirror(s);if(a!=null&&a>s&&a<this.to){s=a,e=this.maps[a].recover(l.recover);continue}}o|=l.delInfo,e=l.pos}return r?e:new hr(e,o,null)}}const Kn=Object.create(null);class q{getMap(){return G.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=Kn[t.stepType];if(!r)throw new RangeError(`No step type ${t.stepType} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in Kn)throw new RangeError("Duplicate use of step JSON ID "+e);return Kn[e]=t,t.prototype.jsonID=e,t}}class B{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new B(e,null)}static fail(e){return new B(null,e)}static fromReplace(e,t,r,o){try{return B.ok(e.replace(t,r,o))}catch(s){if(s instanceof ol)return B.fail(s.message);throw s}}}function Br(n,e,t){let r=[];for(let o=0;o<n.childCount;o++){let s=n.child(o);s.content.size&&(s=s.copy(Br(s.content,e,s))),s.isInline&&(s=e(s,t,o)),r.push(s)}return b.fromArray(r)}class Te extends q{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=e.resolve(this.from),o=r.node(r.sharedDepth(this.to)),s=new S(Br(t.content,(i,l)=>!i.isAtom||!l.type.allowsMarkType(this.mark.type)?i:i.mark(this.mark.addToSet(i.marks)),o),t.openStart,t.openEnd);return B.fromReplace(e,this.from,this.to,s)}invert(){return new he(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new Te(t.pos,r.pos,this.mark)}merge(e){return e instanceof Te&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Te(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new Te(t.from,t.to,e.markFromJSON(t.mark))}}q.jsonID("addMark",Te);class he extends q{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=new S(Br(t.content,o=>o.mark(this.mark.removeFromSet(o.marks)),e),t.openStart,t.openEnd);return B.fromReplace(e,this.from,this.to,r)}invert(){return new Te(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new he(t.pos,r.pos,this.mark)}merge(e){return e instanceof he&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new he(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new he(t.from,t.to,e.markFromJSON(t.mark))}}q.jsonID("removeMark",he);class Ae extends q{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return B.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return B.fromReplace(e,this.pos,this.pos+1,new S(b.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let r=this.mark.addToSet(t.marks);if(r.length==t.marks.length){for(let o=0;o<t.marks.length;o++)if(!t.marks[o].isInSet(r))return new Ae(this.pos,t.marks[o]);return new Ae(this.pos,this.mark)}}return new Ye(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new Ae(t.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new Ae(t.pos,e.markFromJSON(t.mark))}}q.jsonID("addNodeMark",Ae);class Ye extends q{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return B.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return B.fromReplace(e,this.pos,this.pos+1,new S(b.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new Ae(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new Ye(t.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new Ye(t.pos,e.markFromJSON(t.mark))}}q.jsonID("removeNodeMark",Ye);class $ extends q{constructor(e,t,r,o=!1){super(),this.from=e,this.to=t,this.slice=r,this.structure=o}apply(e){return this.structure&&pr(e,this.from,this.to)?B.fail("Structure replace would overwrite content"):B.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new G([this.from,this.to-this.from,this.slice.size])}invert(e){return new $(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deletedAcross&&r.deletedAcross?null:new $(t.pos,Math.max(t.pos,r.pos),this.slice)}merge(e){if(!(e instanceof $)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let t=this.slice.size+e.slice.size==0?S.empty:new S(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new $(this.from,this.to+(e.to-e.from),t,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let t=this.slice.size+e.slice.size==0?S.empty:new S(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new $(e.from,this.to,t,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new $(t.from,t.to,S.fromJSON(e,t.slice),!!t.structure)}}q.jsonID("replace",$);class F extends q{constructor(e,t,r,o,s,i,l=!1){super(),this.from=e,this.to=t,this.gapFrom=r,this.gapTo=o,this.slice=s,this.insert=i,this.structure=l}apply(e){if(this.structure&&(pr(e,this.from,this.gapFrom)||pr(e,this.gapTo,this.to)))return B.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return B.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,t.content);return r?B.fromReplace(e,this.from,this.to,r):B.fail("Content does not fit in gap")}getMap(){return new G([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 F(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),r=e.mapResult(this.to,-1),o=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),s=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return t.deletedAcross&&r.deletedAcross||o<t.pos||s>r.pos?null:new F(t.pos,r.pos,o,s,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number"||typeof t.gapFrom!="number"||typeof t.gapTo!="number"||typeof t.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new F(t.from,t.to,t.gapFrom,t.gapTo,S.fromJSON(e,t.slice),t.insert,!!t.structure)}}q.jsonID("replaceAround",F);function pr(n,e,t){let r=n.resolve(e),o=t-e,s=r.depth;for(;o>0&&s>0&&r.indexAfter(s)==r.node(s).childCount;)s--,o--;if(o>0){let i=r.node(s).maybeChild(r.indexAfter(s));for(;o>0;){if(!i||i.isLeaf)return!0;i=i.firstChild,o--}}return!1}function bl(n,e,t,r){let o=[],s=[],i,l;n.doc.nodesBetween(e,t,(a,c,u)=>{if(!a.isInline)return;let d=a.marks;if(!r.isInSet(d)&&u.type.allowsMarkType(r.type)){let f=Math.max(c,e),h=Math.min(c+a.nodeSize,t),p=r.addToSet(d);for(let m=0;m<d.length;m++)d[m].isInSet(p)||(i&&i.to==f&&i.mark.eq(d[m])?i.to=h:o.push(i=new he(f,h,d[m])));l&&l.to==f?l.to=h:s.push(l=new Te(f,h,r))}}),o.forEach(a=>n.step(a)),s.forEach(a=>n.step(a))}function kl(n,e,t,r){let o=[],s=0;n.doc.nodesBetween(e,t,(i,l)=>{if(!i.isInline)return;s++;let a=null;if(r instanceof Dr){let c=i.marks,u;for(;u=r.isInSet(c);)(a||(a=[])).push(u),c=u.removeFromSet(c)}else r?r.isInSet(i.marks)&&(a=[r]):a=i.marks;if(a&&a.length){let c=Math.min(l+i.nodeSize,t);for(let u=0;u<a.length;u++){let d=a[u],f;for(let h=0;h<o.length;h++){let p=o[h];p.step==s-1&&d.eq(o[h].style)&&(f=p)}f?(f.to=c,f.step=s):o.push({style:d,from:Math.max(l,e),to:c,step:s})}}}),o.forEach(i=>n.step(new he(i.from,i.to,i.style)))}function Ls(n,e,t,r=t.contentMatch,o=!0){let s=n.doc.nodeAt(e),i=[],l=e+1;for(let a=0;a<s.childCount;a++){let c=s.child(a),u=l+c.nodeSize,d=r.matchType(c.type);if(!d)i.push(new $(l,u,S.empty));else{r=d;for(let f=0;f<c.marks.length;f++)t.allowsMarkType(c.marks[f].type)||n.step(new he(l,u,c.marks[f]));if(o&&c.isText&&t.whitespace!="pre"){let f,h=/\r?\n|\r/g,p;for(;f=h.exec(c.text);)p||(p=new S(b.from(t.schema.text(" ",t.allowedMarks(c.marks))),0,0)),i.push(new $(l+f.index,l+f.index+f[0].length,p))}}l=u}if(!r.validEnd){let a=r.fillBefore(b.empty,!0);n.replace(l,l,new S(a,0,0))}for(let a=i.length-1;a>=0;a--)n.step(i[a])}function Sl(n,e,t){return(e==0||n.canReplace(e,n.childCount))&&(t==n.childCount||n.canReplace(0,t))}function rt(n){let t=n.parent.content.cutByIndex(n.startIndex,n.endIndex);for(let r=n.depth;;--r){let o=n.$from.node(r),s=n.$from.index(r),i=n.$to.indexAfter(r);if(r<n.depth&&o.canReplace(s,i,t))return r;if(r==0||o.type.spec.isolating||!Sl(o,s,i))break}return null}function Cl(n,e,t){let{$from:r,$to:o,depth:s}=e,i=r.before(s+1),l=o.after(s+1),a=i,c=l,u=b.empty,d=0;for(let p=s,m=!1;p>t;p--)m||r.index(p)>0?(m=!0,u=b.from(r.node(p).copy(u)),d++):a--;let f=b.empty,h=0;for(let p=s,m=!1;p>t;p--)m||o.after(p+1)<o.end(p)?(m=!0,f=b.from(o.node(p).copy(f)),h++):c++;n.step(new F(a,c,i,l,new S(u.append(f),d,h),u.size-d,!0))}function Hr(n,e,t=null,r=n){let o=wl(n,e),s=o&&xl(r,e);return s?o.map(So).concat({type:e,attrs:t}).concat(s.map(So)):null}function So(n){return{type:n,attrs:null}}function wl(n,e){let{parent:t,startIndex:r,endIndex:o}=n,s=t.contentMatchAt(r).findWrapping(e);if(!s)return null;let i=s.length?s[0]:e;return t.canReplaceWith(r,o,i)?s:null}function xl(n,e){let{parent:t,startIndex:r,endIndex:o}=n,s=t.child(r),i=e.contentMatch.findWrapping(s.type);if(!i)return null;let a=(i.length?i[i.length-1]:e).contentMatch;for(let c=r;a&&c<o;c++)a=a.matchType(t.child(c).type);return!a||!a.validEnd?null:i}function Tl(n,e,t){let r=b.empty;for(let i=t.length-1;i>=0;i--){if(r.size){let l=t[i].type.contentMatch.matchFragment(r);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=b.from(t[i].type.create(t[i].attrs,r))}let o=e.start,s=e.end;n.step(new F(o,s,o,s,new S(r,0,0),t.length,!0))}function Al(n,e,t,r,o){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let s=n.steps.length;n.doc.nodesBetween(e,t,(i,l)=>{if(i.isTextblock&&!i.hasMarkup(r,o)&&Nl(n.doc,n.mapping.slice(s).map(l),r)){let a=null;if(r.schema.linebreakReplacement){let f=r.whitespace=="pre",h=!!r.contentMatch.matchType(r.schema.linebreakReplacement);f&&!h?a=!1:!f&&h&&(a=!0)}a===!1&&El(n,i,l,s),Ls(n,n.mapping.slice(s).map(l,1),r,void 0,a===null);let c=n.mapping.slice(s),u=c.map(l,1),d=c.map(l+i.nodeSize,1);return n.step(new F(u,d,u+1,d-1,new S(b.from(r.create(o,null,i.marks)),0,0),1,!0)),a===!0&&Ml(n,i,l,s),!1}})}function Ml(n,e,t,r){e.forEach((o,s)=>{if(o.isText){let i,l=/\r?\n|\r/g;for(;i=l.exec(o.text);){let a=n.mapping.slice(r).map(t+1+s+i.index);n.replaceWith(a,a+1,e.type.schema.linebreakReplacement.create())}}})}function El(n,e,t,r){e.forEach((o,s)=>{if(o.type==o.type.schema.linebreakReplacement){let i=n.mapping.slice(r).map(t+1+s);n.replaceWith(i,i+1,e.type.schema.text(`
4
+ `))}})}function Nl(n,e,t){let r=n.resolve(e),o=r.index();return r.parent.canReplaceWith(o,o+1,t)}function Rl(n,e,t,r,o){let s=n.doc.nodeAt(e);if(!s)throw new RangeError("No node at given position");t||(t=s.type);let i=t.create(r,null,o||s.marks);if(s.isLeaf)return n.replaceWith(e,e+s.nodeSize,i);if(!t.validContent(s.content))throw new RangeError("Invalid content for node type "+t.name);n.step(new F(e,e+s.nodeSize,e+1,e+s.nodeSize-1,new S(b.from(i),0,0),1,!0))}function Ge(n,e,t=1,r){let o=n.resolve(e),s=o.depth-t,i=r&&r[r.length-1]||o.parent;if(s<0||o.parent.type.spec.isolating||!o.parent.canReplace(o.index(),o.parent.childCount)||!i.type.validContent(o.parent.content.cutByIndex(o.index(),o.parent.childCount)))return!1;for(let c=o.depth-1,u=t-2;c>s;c--,u--){let d=o.node(c),f=o.index(c);if(d.type.spec.isolating)return!1;let h=d.content.cutByIndex(f,d.childCount),p=r&&r[u+1];p&&(h=h.replaceChild(0,p.type.create(p.attrs)));let m=r&&r[u]||d;if(!d.canReplace(f+1,d.childCount)||!m.type.validContent(h))return!1}let l=o.indexAfter(s),a=r&&r[0];return o.node(s).canReplaceWith(l,l,a?a.type:o.node(s+1).type)}function Ol(n,e,t=1,r){let o=n.doc.resolve(e),s=b.empty,i=b.empty;for(let l=o.depth,a=o.depth-t,c=t-1;l>a;l--,c--){s=b.from(o.node(l).copy(s));let u=r&&r[c];i=b.from(u?u.type.create(u.attrs,i):o.node(l).copy(i))}n.step(new $(e,e,new S(s.append(i),t,t),!0))}function Re(n,e){let t=n.resolve(e),r=t.index();return vs(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(r,r+1)}function vs(n,e){return!!(n&&e&&!n.isLeaf&&n.canAppend(e))}function Nn(n,e,t=-1){let r=n.resolve(e);for(let o=r.depth;;o--){let s,i,l=r.index(o);if(o==r.depth?(s=r.nodeBefore,i=r.nodeAfter):t>0?(s=r.node(o+1),l++,i=r.node(o).maybeChild(l)):(s=r.node(o).maybeChild(l-1),i=r.node(o+1)),s&&!s.isTextblock&&vs(s,i)&&r.node(o).canReplace(l,l+1))return e;if(o==0)break;e=t<0?r.before(o):r.after(o)}}function Il(n,e,t){let r=new $(e-t,e+t,S.empty,!0);n.step(r)}function Ll(n,e,t){let r=n.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),t))return e;if(r.parentOffset==0)for(let o=r.depth-1;o>=0;o--){let s=r.index(o);if(r.node(o).canReplaceWith(s,s,t))return r.before(o+1);if(s>0)return null}if(r.parentOffset==r.parent.content.size)for(let o=r.depth-1;o>=0;o--){let s=r.indexAfter(o);if(r.node(o).canReplaceWith(s,s,t))return r.after(o+1);if(s<r.node(o).childCount)return null}return null}function vl(n,e,t){let r=n.resolve(e);if(!t.content.size)return e;let o=t.content;for(let s=0;s<t.openStart;s++)o=o.firstChild.content;for(let s=1;s<=(t.openStart==0&&t.size?2:1);s++)for(let i=r.depth;i>=0;i--){let l=i==r.depth?0:r.pos<=(r.start(i+1)+r.end(i+1))/2?-1:1,a=r.index(i)+(l>0?1:0),c=r.node(i),u=!1;if(s==1)u=c.canReplace(a,a,o);else{let d=c.contentMatchAt(a).findWrapping(o.firstChild.type);u=d&&c.canReplaceWith(a,a,d[0])}if(u)return l==0?r.pos:l<0?r.before(i+1):r.after(i+1)}return null}function Rn(n,e,t=e,r=S.empty){if(e==t&&!r.size)return null;let o=n.resolve(e),s=n.resolve(t);return Ps(o,s,r)?new $(e,t,r):new Pl(o,s,r).fit()}function Ps(n,e,t){return!t.openStart&&!t.openEnd&&n.start()==e.start()&&n.parent.canReplace(n.index(),e.index(),t.content)}class Pl{constructor(e,t,r){this.$from=e,this.$to=t,this.unplaced=r,this.frontier=[],this.placed=b.empty;for(let o=0;o<=e.depth;o++){let s=e.node(o);this.frontier.push({type:s.type,match:s.contentMatchAt(e.indexAfter(o))})}for(let o=e.depth;o>0;o--)this.placed=b.from(e.node(o).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let c=this.findFittable();c?this.placeNodes(c):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,r=this.$from,o=this.close(e<0?this.$to:r.doc.resolve(e));if(!o)return null;let s=this.placed,i=r.depth,l=o.depth;for(;i&&l&&s.childCount==1;)s=s.firstChild.content,i--,l--;let a=new S(s,i,l);return e>-1?new F(r.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||r.pos!=this.$to.pos?new $(r.pos,o.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,r=0,o=this.unplaced.openEnd;r<e;r++){let s=t.firstChild;if(t.childCount>1&&(o=0),s.type.spec.isolating&&o<=r){e=r;break}t=s.content}for(let t=1;t<=2;t++)for(let r=t==1?e:this.unplaced.openStart;r>=0;r--){let o,s=null;r?(s=Vn(this.unplaced.content,r-1).firstChild,o=s.content):o=this.unplaced.content;let i=o.firstChild;for(let l=this.depth;l>=0;l--){let{type:a,match:c}=this.frontier[l],u,d=null;if(t==1&&(i?c.matchType(i.type)||(d=c.fillBefore(b.from(i),!1)):s&&a.compatibleContent(s.type)))return{sliceDepth:r,frontierDepth:l,parent:s,inject:d};if(t==2&&i&&(u=c.findWrapping(i.type)))return{sliceDepth:r,frontierDepth:l,parent:s,wrap:u};if(s&&c.matchType(s.type))break}}}openMore(){let{content:e,openStart:t,openEnd:r}=this.unplaced,o=Vn(e,t);return!o.childCount||o.firstChild.isLeaf?!1:(this.unplaced=new S(e,t+1,Math.max(r,o.size+t>=e.size-r?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:r}=this.unplaced,o=Vn(e,t);if(o.childCount<=1&&t>0){let s=e.size-t<=t+o.size;this.unplaced=new S(it(e,t-1,1),t-1,s?t-1:r)}else this.unplaced=new S(it(e,t,1),t,r)}placeNodes({sliceDepth:e,frontierDepth:t,parent:r,inject:o,wrap:s}){for(;this.depth>t;)this.closeFrontierNode();if(s)for(let m=0;m<s.length;m++)this.openFrontierNode(s[m]);let i=this.unplaced,l=r?r.content:i.content,a=i.openStart-e,c=0,u=[],{match:d,type:f}=this.frontier[t];if(o){for(let m=0;m<o.childCount;m++)u.push(o.child(m));d=d.matchFragment(o)}let h=l.size+e-(i.content.size-i.openEnd);for(;c<l.childCount;){let m=l.child(c),g=d.matchType(m.type);if(!g)break;c++,(c>1||a==0||m.content.size)&&(d=g,u.push(zs(m.mark(f.allowedMarks(m.marks)),c==1?a:0,c==l.childCount?h:-1)))}let p=c==l.childCount;p||(h=-1),this.placed=lt(this.placed,t,b.from(u)),this.frontier[t].match=d,p&&h<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let m=0,g=l;m<h;m++){let y=g.lastChild;this.frontier.push({type:y.type,match:y.contentMatchAt(y.childCount)}),g=y.content}this.unplaced=p?e==0?S.empty:new S(it(i.content,e-1,1),e-1,h<0?i.openEnd:e-1):new S(it(i.content,e,c),i.openStart,i.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],t;if(!e.type.isTextblock||!qn(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(t=this.findCloseLevel(this.$to))&&t.depth==this.depth)return-1;let{depth:r}=this.$to,o=this.$to.after(r);for(;r>1&&o==this.$to.end(--r);)++o;return o}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:r,type:o}=this.frontier[t],s=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),i=qn(e,t,o,r,s);if(i){for(let l=t-1;l>=0;l--){let{match:a,type:c}=this.frontier[l],u=qn(e,l,c,a,!0);if(!u||u.childCount)continue e}return{depth:t,fit:i,move:s?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=lt(this.placed,t.depth,t.fit)),e=t.move;for(let r=t.depth+1;r<=e.depth;r++){let o=e.node(r),s=o.type.contentMatch.fillBefore(o.content,!0,e.index(r));this.openFrontierNode(o.type,o.attrs,s)}return e}openFrontierNode(e,t=null,r){let o=this.frontier[this.depth];o.match=o.match.matchType(e),this.placed=lt(this.placed,this.depth,b.from(e.create(t,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(b.empty,!0);t.childCount&&(this.placed=lt(this.placed,this.frontier.length,t))}}function it(n,e,t){return e==0?n.cutByIndex(t,n.childCount):n.replaceChild(0,n.firstChild.copy(it(n.firstChild.content,e-1,t)))}function lt(n,e,t){return e==0?n.append(t):n.replaceChild(n.childCount-1,n.lastChild.copy(lt(n.lastChild.content,e-1,t)))}function Vn(n,e){for(let t=0;t<e;t++)n=n.firstChild.content;return n}function zs(n,e,t){if(e<=0)return n;let r=n.content;return e>1&&(r=r.replaceChild(0,zs(r.firstChild,e-1,r.childCount==1?t-1:0))),e>0&&(r=n.type.contentMatch.fillBefore(r).append(r),t<=0&&(r=r.append(n.type.contentMatch.matchFragment(r).fillBefore(b.empty,!0)))),n.copy(r)}function qn(n,e,t,r,o){let s=n.node(e),i=o?n.indexAfter(e):n.index(e);if(i==s.childCount&&!t.compatibleContent(s.type))return null;let l=r.fillBefore(s.content,!0,i);return l&&!zl(t,s.content,i)?l:null}function zl(n,e,t){for(let r=t;r<e.childCount;r++)if(!n.allowsMarks(e.child(r).marks))return!0;return!1}function Dl(n){return n.spec.defining||n.spec.definingForContent}function Bl(n,e,t,r){if(!r.size)return n.deleteRange(e,t);let o=n.doc.resolve(e),s=n.doc.resolve(t);if(Ps(o,s,r))return n.step(new $(e,t,r));let i=Bs(o,n.doc.resolve(t));i[i.length-1]==0&&i.pop();let l=-(o.depth+1);i.unshift(l);for(let f=o.depth,h=o.pos-1;f>0;f--,h--){let p=o.node(f).type.spec;if(p.defining||p.definingAsContext||p.isolating)break;i.indexOf(f)>-1?l=f:o.before(f)==h&&i.splice(1,0,-f)}let a=i.indexOf(l),c=[],u=r.openStart;for(let f=r.content,h=0;;h++){let p=f.firstChild;if(c.push(p),h==r.openStart)break;f=p.content}for(let f=u-1;f>=0;f--){let h=c[f],p=Dl(h.type);if(p&&!h.sameMarkup(o.node(Math.abs(l)-1)))u=f;else if(p||!h.type.isTextblock)break}for(let f=r.openStart;f>=0;f--){let h=(f+u+1)%(r.openStart+1),p=c[h];if(p)for(let m=0;m<i.length;m++){let g=i[(m+a)%i.length],y=!0;g<0&&(y=!1,g=-g);let M=o.node(g-1),A=o.index(g-1);if(M.canReplaceWith(A,A,p.type,p.marks))return n.replace(o.before(g),y?s.after(g):t,new S(Ds(r.content,0,r.openStart,h),h,r.openEnd))}}let d=n.steps.length;for(let f=i.length-1;f>=0&&(n.replace(e,t,r),!(n.steps.length>d));f--){let h=i[f];h<0||(e=o.before(h),t=s.after(h))}}function Ds(n,e,t,r,o){if(e<t){let s=n.firstChild;n=n.replaceChild(0,s.copy(Ds(s.content,e+1,t,r,s)))}if(e>r){let s=o.contentMatchAt(0),i=s.fillBefore(n).append(n);n=i.append(s.matchFragment(i).fillBefore(b.empty,!0))}return n}function Hl(n,e,t,r){if(!r.isInline&&e==t&&n.doc.resolve(e).parent.content.size){let o=Ll(n.doc,e,r.type);o!=null&&(e=t=o)}n.replaceRange(e,t,new S(b.from(r),0,0))}function $l(n,e,t){let r=n.doc.resolve(e),o=n.doc.resolve(t),s=Bs(r,o);for(let i=0;i<s.length;i++){let l=s[i],a=i==s.length-1;if(a&&l==0||r.node(l).type.contentMatch.validEnd)return n.delete(r.start(l),o.end(l));if(l>0&&(a||r.node(l-1).canReplace(r.index(l-1),o.indexAfter(l-1))))return n.delete(r.before(l),o.after(l))}for(let i=1;i<=r.depth&&i<=o.depth;i++)if(e-r.start(i)==r.depth-i&&t>r.end(i)&&o.end(i)-t!=o.depth-i)return n.delete(r.before(i),t);n.delete(e,t)}function Bs(n,e){let t=[],r=Math.min(n.depth,e.depth);for(let o=r;o>=0;o--){let s=n.start(o);if(s<n.pos-(n.depth-o)||e.end(o)>e.pos+(e.depth-o)||n.node(o).type.spec.isolating||e.node(o).type.spec.isolating)break;(s==e.start(o)||o==n.depth&&o==e.depth&&n.parent.inlineContent&&e.parent.inlineContent&&o&&e.start(o-1)==s-1)&&t.push(o)}return t}class Qe extends q{constructor(e,t,r){super(),this.pos=e,this.attr=t,this.value=r}apply(e){let t=e.nodeAt(this.pos);if(!t)return B.fail("No node at attribute step's position");let r=Object.create(null);for(let s in t.attrs)r[s]=t.attrs[s];r[this.attr]=this.value;let o=t.type.create(r,null,t.marks);return B.fromReplace(e,this.pos,this.pos+1,new S(b.from(o),0,t.isLeaf?0:1))}getMap(){return G.empty}invert(e){return new Qe(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 Qe(t.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.pos!="number"||typeof t.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new Qe(t.pos,t.attr,t.value)}}q.jsonID("attr",Qe);class mt extends q{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let o in e.attrs)t[o]=e.attrs[o];t[this.attr]=this.value;let r=e.type.create(t,e.content,e.marks);return B.ok(r)}getMap(){return G.empty}invert(e){return new mt(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new mt(t.attr,t.value)}}q.jsonID("docAttr",mt);let Ze=class extends Error{};Ze=function n(e){let t=Error.call(this,e);return t.__proto__=n.prototype,t};Ze.prototype=Object.create(Error.prototype);Ze.prototype.constructor=Ze;Ze.prototype.name="TransformError";class Hs{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new ct}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,r=S.empty){let o=Rn(this.doc,e,t,r);return o&&this.step(o),this}replaceWith(e,t,r){return this.replace(e,t,new S(b.from(r),0,0))}delete(e,t){return this.replace(e,t,S.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,r){return Bl(this,e,t,r),this}replaceRangeWith(e,t,r){return Hl(this,e,t,r),this}deleteRange(e,t){return $l(this,e,t),this}lift(e,t){return Cl(this,e,t),this}join(e,t=1){return Il(this,e,t),this}wrap(e,t){return Tl(this,e,t),this}setBlockType(e,t=e,r,o=null){return Al(this,e,t,r,o),this}setNodeMarkup(e,t,r=null,o){return Rl(this,e,t,r,o),this}setNodeAttribute(e,t,r){return this.step(new Qe(e,t,r)),this}setDocAttribute(e,t){return this.step(new mt(e,t)),this}addNodeMark(e,t){return this.step(new Ae(e,t)),this}removeNodeMark(e,t){if(!(t instanceof _)){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(t=t.isInSet(r.marks),!t)return this}return this.step(new Ye(e,t)),this}split(e,t=1,r){return Ol(this,e,t,r),this}addMark(e,t,r){return bl(this,e,t,r),this}removeMark(e,t,r){return kl(this,e,t,r),this}clearIncompatible(e,t,r){return Ls(this,e,t,r),this}}const Jn=Object.create(null);class x{constructor(e,t,r){this.$anchor=e,this.$head=t,this.ranges=r||[new $s(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=S.empty){let r=t.content.lastChild,o=null;for(let l=0;l<t.openEnd;l++)o=r,r=r.lastChild;let s=e.steps.length,i=this.ranges;for(let l=0;l<i.length;l++){let{$from:a,$to:c}=i[l],u=e.mapping.slice(s);e.replaceRange(u.map(a.pos),u.map(c.pos),l?S.empty:t),l==0&&xo(e,s,(r?r.isInline:o&&o.isTextblock)?-1:1)}}replaceWith(e,t){let r=e.steps.length,o=this.ranges;for(let s=0;s<o.length;s++){let{$from:i,$to:l}=o[s],a=e.mapping.slice(r),c=a.map(i.pos),u=a.map(l.pos);s?e.deleteRange(c,u):(e.replaceRangeWith(c,u,t),xo(e,r,t.isInline?-1:1))}}static findFrom(e,t,r=!1){let o=e.parent.inlineContent?new w(e):Je(e.node(0),e.parent,e.pos,e.index(),t,r);if(o)return o;for(let s=e.depth-1;s>=0;s--){let i=t<0?Je(e.node(0),e.node(s),e.before(s+1),e.index(s),t,r):Je(e.node(0),e.node(s),e.after(s+1),e.index(s)+1,t,r);if(i)return i}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new oe(e.node(0))}static atStart(e){return Je(e,e,0,0,1)||new oe(e)}static atEnd(e){return Je(e,e,e.content.size,e.childCount,-1)||new oe(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=Jn[t.type];if(!r)throw new RangeError(`No selection type ${t.type} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in Jn)throw new RangeError("Duplicate use of selection JSON ID "+e);return Jn[e]=t,t.prototype.jsonID=e,t}getBookmark(){return w.between(this.$anchor,this.$head).getBookmark()}}x.prototype.visible=!0;class $s{constructor(e,t){this.$from=e,this.$to=t}}let Co=!1;function wo(n){!Co&&!n.parent.inlineContent&&(Co=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+n.parent.type.name+")"))}class w extends x{constructor(e,t=e){wo(e),wo(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let r=e.resolve(t.map(this.head));if(!r.parent.inlineContent)return x.near(r);let o=e.resolve(t.map(this.anchor));return new w(o.parent.inlineContent?o:r,r)}replace(e,t=S.empty){if(super.replace(e,t),t==S.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof w&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new On(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if(typeof t.anchor!="number"||typeof t.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new w(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,r=t){let o=e.resolve(t);return new this(o,r==t?o:e.resolve(r))}static between(e,t,r){let o=e.pos-t.pos;if((!r||o)&&(r=o>=0?1:-1),!t.parent.inlineContent){let s=x.findFrom(t,r,!0)||x.findFrom(t,-r,!0);if(s)t=s.$head;else return x.near(t,r)}return e.parent.inlineContent||(o==0?e=t:(e=(x.findFrom(e,-r,!0)||x.findFrom(e,r,!0)).$anchor,e.pos<t.pos!=o<0&&(e=t))),new w(e,t)}}x.jsonID("text",w);class On{constructor(e,t){this.anchor=e,this.head=t}map(e){return new On(e.map(this.anchor),e.map(this.head))}resolve(e){return w.between(e.resolve(this.anchor),e.resolve(this.head))}}class C extends x{constructor(e){let t=e.nodeAfter,r=e.node(0).resolve(e.pos+t.nodeSize);super(e,r),this.node=t}map(e,t){let{deleted:r,pos:o}=t.mapResult(this.anchor),s=e.resolve(o);return r?x.near(s):new C(s)}content(){return new S(b.from(this.node),0,0)}eq(e){return e instanceof C&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new $r(this.anchor)}static fromJSON(e,t){if(typeof t.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new C(e.resolve(t.anchor))}static create(e,t){return new C(e.resolve(t))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}C.prototype.visible=!1;x.jsonID("node",C);class $r{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:r}=e.mapResult(this.anchor);return t?new On(r,r):new $r(r)}resolve(e){let t=e.resolve(this.anchor),r=t.nodeAfter;return r&&C.isSelectable(r)?new C(t):x.near(t)}}class oe extends x{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=S.empty){if(t==S.empty){e.delete(0,e.doc.content.size);let r=x.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new oe(e)}map(e){return new oe(e)}eq(e){return e instanceof oe}getBookmark(){return Fl}}x.jsonID("all",oe);const Fl={map(){return this},resolve(n){return new oe(n)}};function Je(n,e,t,r,o,s=!1){if(e.inlineContent)return w.create(n,t);for(let i=r-(o>0?0:1);o>0?i<e.childCount:i>=0;i+=o){let l=e.child(i);if(l.isAtom){if(!s&&C.isSelectable(l))return C.create(n,t-(o<0?l.nodeSize:0))}else{let a=Je(n,l,t+o,o<0?l.childCount:0,o,s);if(a)return a}t+=l.nodeSize*o}return null}function xo(n,e,t){let r=n.steps.length-1;if(r<e)return;let o=n.steps[r];if(!(o instanceof $||o instanceof F))return;let s=n.mapping.maps[r],i;s.forEach((l,a,c,u)=>{i==null&&(i=u)}),n.setSelection(x.near(n.doc.resolve(i),t))}function To(n,e){return!e||!n?n:n.bind(e)}class Et{constructor(e,t,r){this.name=e,this.init=To(t.init,r),this.apply=To(t.apply,r)}}new Et("doc",{init(n){return n.doc||n.schema.topNodeType.createAndFill()},apply(n){return n.doc}}),new Et("selection",{init(n,e){return n.selection||x.atStart(e.doc)},apply(n){return n.selection}}),new Et("storedMarks",{init(n){return n.storedMarks||null},apply(n,e,t,r){return r.selection.$cursor?n.storedMarks:null}}),new Et("scrollToSelection",{init(){return 0},apply(n,e){return n.scrolledIntoView?e+1:e}});function Fs(n,e,t){for(let r in n){let o=n[r];o instanceof Function?o=o.bind(e):r=="handleDOMEvents"&&(o=Fs(o,e,{})),t[r]=o}return t}class ie{constructor(e){this.spec=e,this.props={},e.props&&Fs(e.props,this,this.props),this.key=e.key?e.key.key:js("plugin")}getState(e){return e[this.key]}}const Un=Object.create(null);function js(n){return n in Un?n+"$"+ ++Un[n]:(Un[n]=0,n+"$")}class te{constructor(e="key"){this.key=js(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const Fe=function(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e},Ws=function(n,e,t,r){return t&&(Ao(n,e,t,r,-1)||Ao(n,e,t,r,1))},jl=/^(img|br|input|textarea|hr)$/i;function Ao(n,e,t,r,o){for(;;){if(n==t&&e==r)return!0;if(e==(o<0?0:Vt(n))){let s=n.parentNode;if(!s||s.nodeType!=1||Fr(n)||jl.test(n.nodeName)||n.contentEditable=="false")return!1;e=Fe(n)+(o<0?0:1),n=s}else if(n.nodeType==1){if(n=n.childNodes[e+(o<0?-1:0)],n.contentEditable=="false")return!1;e=o<0?Vt(n):0}else return!1}}function Vt(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Wl(n,e,t){for(let r=e==0,o=e==Vt(n);r||o;){if(n==t)return!0;let s=Fe(n);if(n=n.parentNode,!n)return!1;r=r&&s==0,o=o&&s==Vt(n)}}function Fr(n){let e;for(let t=n;t&&!(e=t.pmViewDesc);t=t.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==n||e.contentDOM==n)}const Ks=function(n){return n.focusNode&&Ws(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)};function Vs(n,e){let t=document.createEvent("Event");return t.initEvent("keydown",!0,!0),t.keyCode=n,t.key=t.code=e,t}const pe=typeof navigator<"u"?navigator:null,Mo=typeof document<"u"?document:null,Oe=pe&&pe.userAgent||"",mr=/Edge\/(\d+)/.exec(Oe),qs=/MSIE \d/.exec(Oe),gr=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Oe),wt=!!(qs||gr||mr),Js=qs?document.documentMode:gr?+gr[1]:mr?+mr[1]:0,In=!wt&&/gecko\/(\d+)/i.test(Oe);In&&+(/Firefox\/(\d+)/.exec(Oe)||[0,0])[1];const yr=!wt&&/Chrome\/(\d+)/.exec(Oe),je=!!yr,Kl=yr?+yr[1]:0,We=!wt&&!!pe&&/Apple Computer/.test(pe.vendor),jr=We&&(/Mobile\/\w+/.test(Oe)||!!pe&&pe.maxTouchPoints>2),Z=jr||(pe?/Mac/.test(pe.platform):!1),Vl=pe?/Win/.test(pe.platform):!1,xt=/Android \d/.test(Oe),Wr=!!Mo&&"webkitFontSmoothing"in Mo.documentElement.style,ql=Wr?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Jl(n,e=null){let t=n.domSelectionRange(),r=n.state.doc;if(!t.focusNode)return null;let o=n.docView.nearestDesc(t.focusNode),s=o&&o.size==0,i=n.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(i<0)return null;let l=r.resolve(i),a,c;if(Ks(t)){for(a=l;o&&!o.node;)o=o.parent;let u=o.node;if(o&&u.isAtom&&C.isSelectable(u)&&o.parent&&!(u.isInline&&Wl(t.focusNode,t.focusOffset,o.dom))){let d=o.posBefore;c=new C(i==d?l:r.resolve(d))}}else{let u=n.docView.posFromDOM(t.anchorNode,t.anchorOffset,1);if(u<0)return null;a=r.resolve(u)}if(!c){let u=e=="pointer"||n.state.selection.head<l.pos&&!s?1:-1;c=_s(n,a,l,u)}return c}function Us(n){return n.editable?n.hasFocus():Ql(n)&&document.activeElement&&document.activeElement.contains(n.dom)}function Kr(n,e=!1){let t=n.state.selection;if(Gl(n,t),!!Us(n)){if(!e&&n.input.mouseDown&&n.input.mouseDown.allowDefault&&je){let r=n.domSelectionRange(),o=n.domObserver.currentSelection;if(r.anchorNode&&o.anchorNode&&Ws(r.anchorNode,r.anchorOffset,o.anchorNode,o.anchorOffset)){n.input.mouseDown.delayedSelectionSync=!0,n.domObserver.setCurSelection();return}}if(n.domObserver.disconnectSelection(),n.cursorWrapper)_l(n);else{let{anchor:r,head:o}=t,s,i;Eo&&!(t instanceof w)&&(t.$from.parent.inlineContent||(s=No(n,t.from)),!t.empty&&!t.$from.parent.inlineContent&&(i=No(n,t.to))),n.docView.setSelection(r,o,n.root,e),Eo&&(s&&Ro(s),i&&Ro(i)),t.visible?n.dom.classList.remove("ProseMirror-hideselection"):(n.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&Ul(n))}n.domObserver.setCurSelection(),n.domObserver.connectSelection()}}const Eo=We||je&&Kl<63;function No(n,e){let{node:t,offset:r}=n.docView.domFromPos(e,0),o=r<t.childNodes.length?t.childNodes[r]:null,s=r?t.childNodes[r-1]:null;if(We&&o&&o.contentEditable=="false")return _n(o);if((!o||o.contentEditable=="false")&&(!s||s.contentEditable=="false")){if(o)return _n(o);if(s)return _n(s)}}function _n(n){return n.contentEditable="true",We&&n.draggable&&(n.draggable=!1,n.wasDraggable=!0),n}function Ro(n){n.contentEditable="false",n.wasDraggable&&(n.draggable=!0,n.wasDraggable=null)}function Ul(n){let e=n.dom.ownerDocument;e.removeEventListener("selectionchange",n.input.hideSelectionGuard);let t=n.domSelectionRange(),r=t.anchorNode,o=t.anchorOffset;e.addEventListener("selectionchange",n.input.hideSelectionGuard=()=>{(t.anchorNode!=r||t.anchorOffset!=o)&&(e.removeEventListener("selectionchange",n.input.hideSelectionGuard),setTimeout(()=>{(!Us(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function _l(n){let e=n.domSelection(),t=document.createRange(),r=n.cursorWrapper.dom,o=r.nodeName=="IMG";o?t.setEnd(r.parentNode,Fe(r)+1):t.setEnd(r,0),t.collapse(!1),e.removeAllRanges(),e.addRange(t),!o&&!n.state.selection.visible&&wt&&Js<=11&&(r.disabled=!0,r.disabled=!1)}function Gl(n,e){if(e instanceof C){let t=n.docView.descAt(e.from);t!=n.lastSelectedViewDesc&&(Oo(n),t&&t.selectNode(),n.lastSelectedViewDesc=t)}else Oo(n)}function Oo(n){n.lastSelectedViewDesc&&(n.lastSelectedViewDesc.parent&&n.lastSelectedViewDesc.deselectNode(),n.lastSelectedViewDesc=void 0)}function _s(n,e,t,r){return n.someProp("createSelectionBetween",o=>o(n,e,t))||w.between(e,t,r)}function Ql(n){let e=n.domSelectionRange();if(!e.anchorNode)return!1;try{return n.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(n.editable||n.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function br(n,e){let{$anchor:t,$head:r}=n.selection,o=e>0?t.max(r):t.min(r),s=o.parent.inlineContent?o.depth?n.doc.resolve(e>0?o.after():o.before()):null:o;return s&&x.findFrom(s,e)}function Se(n,e){return n.dispatch(n.state.tr.setSelection(e).scrollIntoView()),!0}function Io(n,e,t){let r=n.state.selection;if(r instanceof w)if(t.indexOf("s")>-1){let{$head:o}=r,s=o.textOffset?null:e<0?o.nodeBefore:o.nodeAfter;if(!s||s.isText||!s.isLeaf)return!1;let i=n.state.doc.resolve(o.pos+s.nodeSize*(e<0?-1:1));return Se(n,new w(r.$anchor,i))}else if(r.empty){if(n.endOfTextblock(e>0?"forward":"backward")){let o=br(n.state,e);return o&&o instanceof C?Se(n,o):!1}else if(!(Z&&t.indexOf("m")>-1)){let o=r.$head,s=o.textOffset?null:e<0?o.nodeBefore:o.nodeAfter,i;if(!s||s.isText)return!1;let l=e<0?o.pos-s.nodeSize:o.pos;return s.isAtom||(i=n.docView.descAt(l))&&!i.contentDOM?C.isSelectable(s)?Se(n,new C(e<0?n.state.doc.resolve(o.pos-s.nodeSize):o)):Wr?Se(n,new w(n.state.doc.resolve(e<0?l:l+s.nodeSize))):!1:!1}}else return!1;else{if(r instanceof C&&r.node.isInline)return Se(n,new w(e>0?r.$to:r.$from));{let o=br(n.state,e);return o?Se(n,o):!1}}}function qt(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function ut(n,e){let t=n.pmViewDesc;return t&&t.size==0&&(e<0||n.nextSibling||n.nodeName!="BR")}function Ve(n,e){return e<0?Xl(n):Yl(n)}function Xl(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let o,s,i=!1;for(In&&t.nodeType==1&&r<qt(t)&&ut(t.childNodes[r],-1)&&(i=!0);;)if(r>0){if(t.nodeType!=1)break;{let l=t.childNodes[r-1];if(ut(l,-1))o=t,s=--r;else if(l.nodeType==3)t=l,r=t.nodeValue.length;else break}}else{if(Gs(t))break;{let l=t.previousSibling;for(;l&&ut(l,-1);)o=t.parentNode,s=Fe(l),l=l.previousSibling;if(l)t=l,r=qt(t);else{if(t=t.parentNode,t==n.dom)break;r=0}}}i?kr(n,t,r):o&&kr(n,o,s)}function Yl(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let o=qt(t),s,i;for(;;)if(r<o){if(t.nodeType!=1)break;let l=t.childNodes[r];if(ut(l,1))s=t,i=++r;else break}else{if(Gs(t))break;{let l=t.nextSibling;for(;l&&ut(l,1);)s=l.parentNode,i=Fe(l)+1,l=l.nextSibling;if(l)t=l,r=0,o=qt(t);else{if(t=t.parentNode,t==n.dom)break;r=o=0}}}s&&kr(n,s,i)}function Gs(n){let e=n.pmViewDesc;return e&&e.node&&e.node.isBlock}function Zl(n,e){for(;n&&e==n.childNodes.length&&!Fr(n);)e=Fe(n)+1,n=n.parentNode;for(;n&&e<n.childNodes.length;){let t=n.childNodes[e];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;n=t,e=0}}function ea(n,e){for(;n&&!e&&!Fr(n);)e=Fe(n),n=n.parentNode;for(;n&&e;){let t=n.childNodes[e-1];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;n=t,e=n.childNodes.length}}function kr(n,e,t){if(e.nodeType!=3){let s,i;(i=Zl(e,t))?(e=i,t=0):(s=ea(e,t))&&(e=s,t=s.nodeValue.length)}let r=n.domSelection();if(Ks(r)){let s=document.createRange();s.setEnd(e,t),s.setStart(e,t),r.removeAllRanges(),r.addRange(s)}else r.extend&&r.extend(e,t);n.domObserver.setCurSelection();let{state:o}=n;setTimeout(()=>{n.state==o&&Kr(n)},50)}function Lo(n,e){let t=n.state.doc.resolve(e);if(!(je||Vl)&&t.parent.inlineContent){let o=n.coordsAtPos(e);if(e>t.start()){let s=n.coordsAtPos(e-1),i=(s.top+s.bottom)/2;if(i>o.top&&i<o.bottom&&Math.abs(s.left-o.left)>1)return s.left<o.left?"ltr":"rtl"}if(e<t.end()){let s=n.coordsAtPos(e+1),i=(s.top+s.bottom)/2;if(i>o.top&&i<o.bottom&&Math.abs(s.left-o.left)>1)return s.left>o.left?"ltr":"rtl"}}return getComputedStyle(n.dom).direction=="rtl"?"rtl":"ltr"}function vo(n,e,t){let r=n.state.selection;if(r instanceof w&&!r.empty||t.indexOf("s")>-1||Z&&t.indexOf("m")>-1)return!1;let{$from:o,$to:s}=r;if(!o.parent.inlineContent||n.endOfTextblock(e<0?"up":"down")){let i=br(n.state,e);if(i&&i instanceof C)return Se(n,i)}if(!o.parent.inlineContent){let i=e<0?o:s,l=r instanceof oe?x.near(i,e):x.findFrom(i,e);return l?Se(n,l):!1}return!1}function Po(n,e){if(!(n.state.selection instanceof w))return!0;let{$head:t,$anchor:r,empty:o}=n.state.selection;if(!t.sameParent(r))return!0;if(!o)return!1;if(n.endOfTextblock(e>0?"forward":"backward"))return!0;let s=!t.textOffset&&(e<0?t.nodeBefore:t.nodeAfter);if(s&&!s.isText){let i=n.state.tr;return e<0?i.delete(t.pos-s.nodeSize,t.pos):i.delete(t.pos,t.pos+s.nodeSize),n.dispatch(i),!0}return!1}function zo(n,e,t){n.domObserver.stop(),e.contentEditable=t,n.domObserver.start()}function ta(n){if(!We||n.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:t}=n.domSelectionRange();if(e&&e.nodeType==1&&t==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let r=e.firstChild;zo(n,r,"true"),setTimeout(()=>zo(n,r,"false"),20)}return!1}function na(n){let e="";return n.ctrlKey&&(e+="c"),n.metaKey&&(e+="m"),n.altKey&&(e+="a"),n.shiftKey&&(e+="s"),e}function ra(n,e){let t=e.keyCode,r=na(e);if(t==8||Z&&t==72&&r=="c")return Po(n,-1)||Ve(n,-1);if(t==46&&!e.shiftKey||Z&&t==68&&r=="c")return Po(n,1)||Ve(n,1);if(t==13||t==27)return!0;if(t==37||Z&&t==66&&r=="c"){let o=t==37?Lo(n,n.state.selection.from)=="ltr"?-1:1:-1;return Io(n,o,r)||Ve(n,o)}else if(t==39||Z&&t==70&&r=="c"){let o=t==39?Lo(n,n.state.selection.from)=="ltr"?1:-1:1;return Io(n,o,r)||Ve(n,o)}else{if(t==38||Z&&t==80&&r=="c")return vo(n,-1,r)||Ve(n,-1);if(t==40||Z&&t==78&&r=="c")return ta(n)||vo(n,1,r)||Ve(n,1);if(r==(Z?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function Qs(n,e){n.someProp("transformCopied",h=>{e=h(e,n)});let t=[],{content:r,openStart:o,openEnd:s}=e;for(;o>1&&s>1&&r.childCount==1&&r.firstChild.childCount==1;){o--,s--;let h=r.firstChild;t.push(h.type.name,h.attrs!=h.type.defaultAttrs?h.attrs:null),r=h.content}let i=n.someProp("clipboardSerializer")||ve.fromSchema(n.state.schema),l=ni(),a=l.createElement("div");a.appendChild(i.serializeFragment(r,{document:l}));let c=a.firstChild,u,d=0;for(;c&&c.nodeType==1&&(u=ti[c.nodeName.toLowerCase()]);){for(let h=u.length-1;h>=0;h--){let p=l.createElement(u[h]);for(;a.firstChild;)p.appendChild(a.firstChild);a.appendChild(p),d++}c=a.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${o} ${s}${d?` -${d}`:""} ${JSON.stringify(t)}`);let f=n.someProp("clipboardTextSerializer",h=>h(e,n))||e.content.textBetween(0,e.content.size,`
5
5
 
6
6
  `);return{dom:a,text:f,slice:e}}function Xs(n,e,t,r,o){let s=o.parent.type.spec.code,i,l;if(!t&&!e)return null;let a=e&&(r||s||!t);if(a){if(n.someProp("transformPastedText",f=>{e=f(e,s||r,n)}),s)return e?new S(b.from(n.state.schema.text(e.replace(/\r\n?/g,`
7
- `))),0,0):S.empty;let d=n.someProp("clipboardTextParser",f=>f(e,o,r,n));if(d)l=d;else{let f=o.marks(),{schema:h}=n.state,p=ve.fromSchema(h);i=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(m=>{let g=i.appendChild(document.createElement("p"));m&&g.appendChild(p.serializeNode(h.text(m,f)))})}}else n.someProp("transformPastedHTML",d=>{t=d(t,n)}),i=ia(t),Wr&&la(i);let c=i&&i.querySelector("[data-pm-slice]"),u=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(u&&u[3])for(let d=+u[3];d>0;d--){let f=i.firstChild;for(;f&&f.nodeType!=1;)f=f.nextSibling;if(!f)break;i=f}if(l||(l=(n.someProp("clipboardParser")||n.someProp("domParser")||pt.fromSchema(n.state.schema)).parseSlice(i,{preserveWhitespace:!!(a||u),context:o,ruleFromNode(f){return f.nodeName=="BR"&&!f.nextSibling&&f.parentNode&&!oa.test(f.parentNode.nodeName)?{ignore:!0}:null}})),u)l=aa(Do(l,+u[1],+u[2]),u[4]);else if(l=S.maxOpen(sa(l.content,o),!0),l.openStart||l.openEnd){let d=0,f=0;for(let h=l.content.firstChild;d<l.openStart&&!h.type.spec.isolating;d++,h=h.firstChild);for(let h=l.content.lastChild;f<l.openEnd&&!h.type.spec.isolating;f++,h=h.lastChild);l=Do(l,d,f)}return n.someProp("transformPasted",d=>{l=d(l,n)}),l}const oa=/^(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 sa(n,e){if(n.childCount<2)return n;for(let t=e.depth;t>=0;t--){let o=e.node(t).contentMatchAt(e.index(t)),s,i=[];if(n.forEach(l=>{if(!i)return;let a=o.findWrapping(l.type),c;if(!a)return i=null;if(c=i.length&&s.length&&Zs(a,s,l,i[i.length-1],0))i[i.length-1]=c;else{i.length&&(i[i.length-1]=ei(i[i.length-1],s.length));let u=Ys(l,a);i.push(u),o=o.matchType(u.type),s=a}}),i)return b.from(i)}return n}function Ys(n,e,t=0){for(let r=e.length-1;r>=t;r--)n=e[r].create(null,b.from(n));return n}function Zs(n,e,t,r,o){if(o<n.length&&o<e.length&&n[o]==e[o]){let s=Zs(n,e,t,r.lastChild,o+1);if(s)return r.copy(r.content.replaceChild(r.childCount-1,s));if(r.contentMatchAt(r.childCount).matchType(o==n.length-1?t.type:n[o+1]))return r.copy(r.content.append(b.from(Ys(t,n,o+1))))}}function ei(n,e){if(e==0)return n;let t=n.content.replaceChild(n.childCount-1,ei(n.lastChild,e-1)),r=n.contentMatchAt(n.childCount).fillBefore(b.empty,!0);return n.copy(t.append(r))}function Sr(n,e,t,r,o,s){let i=e<0?n.firstChild:n.lastChild,l=i.content;return n.childCount>1&&(s=0),o<r-1&&(l=Sr(l,e,t,r,o+1,s)),o>=t&&(l=e<0?i.contentMatchAt(0).fillBefore(l,s<=o).append(l):l.append(i.contentMatchAt(i.childCount).fillBefore(b.empty,!0))),n.replaceChild(e<0?0:n.childCount-1,i.copy(l))}function Do(n,e,t){return e<n.openStart&&(n=new S(Sr(n.content,-1,e,n.openStart,0,n.openEnd),e,n.openEnd)),t<n.openEnd&&(n=new S(Sr(n.content,1,t,n.openEnd,0,0),n.openStart,t)),n}const ti={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 Bo=null;function ni(){return Bo||(Bo=document.implementation.createHTMLDocument("title"))}function ia(n){let e=/^(\s*<meta [^>]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=ni().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(n),o;if((o=r&&ti[r[1].toLowerCase()])&&(n=o.map(s=>"<"+s+">").join("")+n+o.map(s=>"</"+s+">").reverse().join("")),t.innerHTML=n,o)for(let s=0;s<o.length;s++)t=t.querySelector(o[s])||t;return t}function la(n){let e=n.querySelectorAll(je?"span:not([class]):not([style])":"span.Apple-converted-space");for(let t=0;t<e.length;t++){let r=e[t];r.childNodes.length==1&&r.textContent==" "&&r.parentNode&&r.parentNode.replaceChild(n.ownerDocument.createTextNode(" "),r)}}function aa(n,e){if(!n.size)return n;let t=n.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return n}let{content:o,openStart:s,openEnd:i}=n;for(let l=r.length-2;l>=0;l-=2){let a=t.nodes[r[l]];if(!a||a.hasRequiredAttrs())break;o=b.from(a.create(r[l+1],o)),s++,i++}return new S(o,s,i)}const le={},Q={};function Me(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}Q.keydown=(n,e)=>{let t=e;if(n.input.shiftKey=t.keyCode==16||t.shiftKey,!oi(n,t)&&(n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),!(xt&&je&&t.keyCode==13)))if(t.keyCode!=229&&n.domObserver.forceFlush(),jr&&t.keyCode==13&&!t.ctrlKey&&!t.altKey&&!t.metaKey){let r=Date.now();n.input.lastIOSEnter=r,n.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{n.input.lastIOSEnter==r&&(n.someProp("handleKeyDown",o=>o(n,Vs(13,"Enter"))),n.input.lastIOSEnter=0)},200)}else n.someProp("handleKeyDown",r=>r(n,t))||ra(n,t)?t.preventDefault():Me(n,"key")};Q.keyup=(n,e)=>{e.keyCode==16&&(n.input.shiftKey=!1)};Q.keypress=(n,e)=>{let t=e;if(oi(n,t)||!t.charCode||t.ctrlKey&&!t.altKey||Z&&t.metaKey)return;if(n.someProp("handleKeyPress",o=>o(n,t))){t.preventDefault();return}let r=n.state.selection;if(!(r instanceof w)||!r.$from.sameParent(r.$to)){let o=String.fromCharCode(t.charCode);!/[\r\n]/.test(o)&&!n.someProp("handleTextInput",s=>s(n,r.$from.pos,r.$to.pos,o))&&n.dispatch(n.state.tr.insertText(o).scrollIntoView()),t.preventDefault()}};function Ln(n){return{left:n.clientX,top:n.clientY}}function ca(n,e){let t=e.x-n.clientX,r=e.y-n.clientY;return t*t+r*r<100}function Vr(n,e,t,r,o){if(r==-1)return!1;let s=n.state.doc.resolve(r);for(let i=s.depth+1;i>0;i--)if(n.someProp(e,l=>i>s.depth?l(n,t,s.nodeAfter,s.before(i),o,!0):l(n,t,s.node(i),s.before(i),o,!1)))return!0;return!1}function Xe(n,e,t){n.focused||n.focus();let r=n.state.tr.setSelection(e);r.setMeta("pointer",!0),n.dispatch(r)}function ua(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),r=t.nodeAfter;return r&&r.isAtom&&C.isSelectable(r)?(Xe(n,new C(t)),!0):!1}function da(n,e){if(e==-1)return!1;let t=n.state.selection,r,o;t instanceof C&&(r=t.node);let s=n.state.doc.resolve(e);for(let i=s.depth+1;i>0;i--){let l=i>s.depth?s.nodeAfter:s.node(i);if(C.isSelectable(l)){r&&t.$from.depth>0&&i>=t.$from.depth&&s.before(t.$from.depth+1)==t.$from.pos?o=s.before(t.$from.depth):o=s.before(i);break}}return o!=null?(Xe(n,C.create(n.state.doc,o)),!0):!1}function fa(n,e,t,r,o){return Vr(n,"handleClickOn",e,t,r)||n.someProp("handleClick",s=>s(n,e,r))||(o?da(n,t):ua(n,t))}function ha(n,e,t,r){return Vr(n,"handleDoubleClickOn",e,t,r)||n.someProp("handleDoubleClick",o=>o(n,e,r))}function pa(n,e,t,r){return Vr(n,"handleTripleClickOn",e,t,r)||n.someProp("handleTripleClick",o=>o(n,e,r))||ma(n,t,r)}function ma(n,e,t){if(t.button!=0)return!1;let r=n.state.doc;if(e==-1)return r.inlineContent?(Xe(n,w.create(r,0,r.content.size)),!0):!1;let o=r.resolve(e);for(let s=o.depth+1;s>0;s--){let i=s>o.depth?o.nodeAfter:o.node(s),l=o.before(s);if(i.inlineContent)Xe(n,w.create(r,l+1,l+1+i.content.size));else if(C.isSelectable(i))Xe(n,C.create(r,l));else continue;return!0}}function qr(n){return Jt(n)}const ri=Z?"metaKey":"ctrlKey";le.mousedown=(n,e)=>{let t=e;n.input.shiftKey=t.shiftKey;let r=qr(n),o=Date.now(),s="singleClick";o-n.input.lastClick.time<500&&ca(t,n.input.lastClick)&&!t[ri]&&(n.input.lastClick.type=="singleClick"?s="doubleClick":n.input.lastClick.type=="doubleClick"&&(s="tripleClick")),n.input.lastClick={time:o,x:t.clientX,y:t.clientY,type:s};let i=n.posAtCoords(Ln(t));i&&(s=="singleClick"?(n.input.mouseDown&&n.input.mouseDown.done(),n.input.mouseDown=new ga(n,i,t,!!r)):(s=="doubleClick"?ha:pa)(n,i.pos,i.inside,t)?t.preventDefault():Me(n,"pointer"))};class ga{constructor(e,t,r,o){this.view=e,this.pos=t,this.event=r,this.flushed=o,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!r[ri],this.allowDefault=r.shiftKey;let s,i;if(t.inside>-1)s=e.state.doc.nodeAt(t.inside),i=t.inside;else{let u=e.state.doc.resolve(t.pos);s=u.parent,i=u.depth?u.before():0}const l=o?null:r.target,a=l?e.docView.nearestDesc(l,!0):null;this.target=a&&a.dom.nodeType==1?a.dom:null;let{selection:c}=e.state;(r.button==0&&s.type.spec.draggable&&s.type.spec.selectable!==!1||c instanceof C&&c.from<=i&&c.to>i)&&(this.mightDrag={node:s,pos:i,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&In&&!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)),Me(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(()=>Kr(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(Ln(e))),this.updateAllowDefault(e),this.allowDefault||!t?Me(this.view,"pointer"):fa(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||We&&this.mightDrag&&!this.mightDrag.node.isAtom||je&&!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)?(Xe(this.view,x.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):Me(this.view,"pointer")}move(e){this.updateAllowDefault(e),Me(this.view,"pointer"),e.buttons==0&&this.done()}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}}le.touchstart=n=>{n.input.lastTouch=Date.now(),qr(n),Me(n,"pointer")};le.touchmove=n=>{n.input.lastTouch=Date.now(),Me(n,"pointer")};le.contextmenu=n=>qr(n);function oi(n,e){return n.composing?!0:We&&Math.abs(e.timeStamp-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}const ya=xt?5e3:-1;Q.compositionstart=Q.compositionupdate=n=>{if(!n.composing){n.domObserver.flush();let{state:e}=n,t=e.selection.$from;if(e.selection.empty&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)))n.markCursor=n.state.storedMarks||t.marks(),Jt(n,!0),n.markCursor=null;else if(Jt(n),In&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length){let r=n.domSelectionRange();for(let o=r.focusNode,s=r.focusOffset;o&&o.nodeType==1&&s!=0;){let i=s<0?o.lastChild:o.childNodes[s-1];if(!i)break;if(i.nodeType==3){n.domSelection().collapse(i,i.nodeValue.length);break}else o=i,s=-1}}n.input.composing=!0}si(n,ya)};Q.compositionend=(n,e)=>{n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=e.timeStamp,n.input.compositionPendingChanges=n.domObserver.pendingRecords().length?n.input.compositionID:0,n.input.compositionNode=null,n.input.compositionPendingChanges&&Promise.resolve().then(()=>n.domObserver.flush()),n.input.compositionID++,si(n,20))};function si(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>Jt(n),e))}function ba(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=ka());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function ka(){let n=document.createEvent("Event");return n.initEvent("event",!0,!0),n.timeStamp}function Jt(n,e=!1){if(!(xt&&n.domObserver.flushingSoon>=0)){if(n.domObserver.forceFlush(),ba(n),e||n.docView&&n.docView.dirty){let t=Jl(n);return t&&!t.eq(n.state.selection)?n.dispatch(n.state.tr.setSelection(t)):n.updateState(n.state),!0}return!1}}function Sa(n,e){if(!n.dom.parentNode)return;let t=n.dom.parentNode.appendChild(document.createElement("div"));t.appendChild(e),t.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),o=document.createRange();o.selectNodeContents(e),n.dom.blur(),r.removeAllRanges(),r.addRange(o),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t),n.focus()},50)}const gt=wt&&Js<15||jr&&ql<604;le.copy=Q.cut=(n,e)=>{let t=e,r=n.state.selection,o=t.type=="cut";if(r.empty)return;let s=gt?null:t.clipboardData,i=r.content(),{dom:l,text:a}=Qs(n,i);s?(t.preventDefault(),s.clearData(),s.setData("text/html",l.innerHTML),s.setData("text/plain",a)):Sa(n,l),o&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function Ca(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function wa(n,e){if(!n.dom.parentNode)return;let t=n.input.shiftKey||n.state.selection.$from.parent.type.spec.code,r=n.dom.parentNode.appendChild(document.createElement(t?"textarea":"div"));t||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let o=n.input.shiftKey&&n.input.lastKeyCode!=45;setTimeout(()=>{n.focus(),r.parentNode&&r.parentNode.removeChild(r),t?Cr(n,r.value,null,o,e):Cr(n,r.textContent,r.innerHTML,o,e)},50)}function Cr(n,e,t,r,o){let s=Xs(n,e,t,r,n.state.selection.$from);if(n.someProp("handlePaste",a=>a(n,o,s||S.empty)))return!0;if(!s)return!1;let i=Ca(s),l=i?n.state.tr.replaceSelectionWith(i,r):n.state.tr.replaceSelection(s);return n.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function ii(n){let e=n.getData("text/plain")||n.getData("Text");if(e)return e;let t=n.getData("text/uri-list");return t?t.replace(/\r?\n/g," "):""}Q.paste=(n,e)=>{let t=e;if(n.composing&&!xt)return;let r=gt?null:t.clipboardData,o=n.input.shiftKey&&n.input.lastKeyCode!=45;r&&Cr(n,ii(r),r.getData("text/html"),o,t)?t.preventDefault():wa(n,t)};class xa{constructor(e,t,r){this.slice=e,this.move=t,this.node=r}}const li=Z?"altKey":"ctrlKey";le.dragstart=(n,e)=>{let t=e,r=n.input.mouseDown;if(r&&r.done(),!t.dataTransfer)return;let o=n.state.selection,s=o.empty?null:n.posAtCoords(Ln(t)),i;if(!(s&&s.pos>=o.from&&s.pos<=(o instanceof C?o.to-1:o.to))){if(r&&r.mightDrag)i=C.create(n.state.doc,r.mightDrag.pos);else if(t.target&&t.target.nodeType==1){let d=n.docView.nearestDesc(t.target,!0);d&&d.node.type.spec.draggable&&d!=n.docView&&(i=C.create(n.state.doc,d.posBefore))}}let l=(i||n.state.selection).content(),{dom:a,text:c,slice:u}=Qs(n,l);t.dataTransfer.clearData(),t.dataTransfer.setData(gt?"Text":"text/html",a.innerHTML),t.dataTransfer.effectAllowed="copyMove",gt||t.dataTransfer.setData("text/plain",c),n.dragging=new xa(u,!t[li],i)};le.dragend=n=>{let e=n.dragging;window.setTimeout(()=>{n.dragging==e&&(n.dragging=null)},50)};Q.dragover=Q.dragenter=(n,e)=>e.preventDefault();Q.drop=(n,e)=>{let t=e,r=n.dragging;if(n.dragging=null,!t.dataTransfer)return;let o=n.posAtCoords(Ln(t));if(!o)return;let s=n.state.doc.resolve(o.pos),i=r&&r.slice;i?n.someProp("transformPasted",p=>{i=p(i,n)}):i=Xs(n,ii(t.dataTransfer),gt?null:t.dataTransfer.getData("text/html"),!1,s);let l=!!(r&&!t[li]);if(n.someProp("handleDrop",p=>p(n,t,i||S.empty,l))){t.preventDefault();return}if(!i)return;t.preventDefault();let a=i?vl(n.state.doc,s.pos,i):s.pos;a==null&&(a=s.pos);let c=n.state.tr;if(l){let{node:p}=r;p?p.replace(c):c.deleteSelection()}let u=c.mapping.map(a),d=i.openStart==0&&i.openEnd==0&&i.content.childCount==1,f=c.doc;if(d?c.replaceRangeWith(u,u,i.content.firstChild):c.replaceRange(u,u,i),c.doc.eq(f))return;let h=c.doc.resolve(u);if(d&&C.isSelectable(i.content.firstChild)&&h.nodeAfter&&h.nodeAfter.sameMarkup(i.content.firstChild))c.setSelection(new C(h));else{let p=c.mapping.map(a);c.mapping.maps[c.mapping.maps.length-1].forEach((m,g,y,M)=>p=M),c.setSelection(_s(n,h,c.doc.resolve(p)))}n.focus(),n.dispatch(c.setMeta("uiEvent","drop"))};le.focus=n=>{n.input.lastFocus=Date.now(),n.focused||(n.domObserver.stop(),n.dom.classList.add("ProseMirror-focused"),n.domObserver.start(),n.focused=!0,setTimeout(()=>{n.docView&&n.hasFocus()&&!n.domObserver.currentSelection.eq(n.domSelectionRange())&&Kr(n)},20))};le.blur=(n,e)=>{let t=e;n.focused&&(n.domObserver.stop(),n.dom.classList.remove("ProseMirror-focused"),n.domObserver.start(),t.relatedTarget&&n.dom.contains(t.relatedTarget)&&n.domObserver.currentSelection.clear(),n.focused=!1)};le.beforeinput=(n,e)=>{if(je&&xt&&e.inputType=="deleteContentBackward"){n.domObserver.flushSoon();let{domChangeCount:r}=n.input;setTimeout(()=>{if(n.input.domChangeCount!=r||(n.dom.blur(),n.focus(),n.someProp("handleKeyDown",s=>s(n,Vs(8,"Backspace")))))return;let{$cursor:o}=n.state.selection;o&&o.pos>0&&n.dispatch(n.state.tr.delete(o.pos-1,o.pos).scrollIntoView())},50)}};for(let n in Q)le[n]=Q[n];function yt(n,e){if(n==e)return!0;for(let t in n)if(n[t]!==e[t])return!1;for(let t in e)if(!(t in n))return!1;return!0}class Ut{constructor(e,t){this.toDOM=e,this.spec=t||De,this.side=this.spec.side||0}map(e,t,r,o){let{pos:s,deleted:i}=e.mapResult(t.from+o,this.side<0?-1:1);return i?null:new re(s-r,s-r,this)}valid(){return!0}eq(e){return this==e||e instanceof Ut&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&yt(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class Ee{constructor(e,t){this.attrs=e,this.spec=t||De}map(e,t,r,o){let s=e.map(t.from+o,this.spec.inclusiveStart?-1:1)-r,i=e.map(t.to+o,this.spec.inclusiveEnd?1:-1)-r;return s>=i?null:new re(s,i,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof Ee&&yt(this.attrs,e.attrs)&&yt(this.spec,e.spec)}static is(e){return e.type instanceof Ee}destroy(){}}class Jr{constructor(e,t){this.attrs=e,this.spec=t||De}map(e,t,r,o){let s=e.mapResult(t.from+o,1);if(s.deleted)return null;let i=e.mapResult(t.to+o,-1);return i.deleted||i.pos<=s.pos?null:new re(s.pos-r,i.pos-r,this)}valid(e,t){let{index:r,offset:o}=e.content.findIndex(t.from),s;return o==t.from&&!(s=e.child(r)).isText&&o+s.nodeSize==t.to}eq(e){return this==e||e instanceof Jr&&yt(this.attrs,e.attrs)&&yt(this.spec,e.spec)}destroy(){}}class re{constructor(e,t,r){this.from=e,this.to=t,this.type=r}copy(e,t){return new re(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,r){return this.type.map(e,this,t,r)}static widget(e,t,r){return new re(e,e,new Ut(t,r))}static inline(e,t,r,o){return new re(e,t,new Ee(r,o))}static node(e,t,r,o){return new re(e,t,new Jr(r,o))}get spec(){return this.type.spec}get inline(){return this.type instanceof Ee}get widget(){return this.type instanceof Ut}}const Ue=[],De={};class D{constructor(e,t){this.local=e.length?e:Ue,this.children=t.length?t:Ue}static create(e,t){return t.length?_t(t,e,0,De):q}find(e,t,r){let o=[];return this.findInner(e??0,t??1e9,o,0,r),o}findInner(e,t,r,o,s){for(let i=0;i<this.local.length;i++){let l=this.local[i];l.from<=t&&l.to>=e&&(!s||s(l.spec))&&r.push(l.copy(l.from+o,l.to+o))}for(let i=0;i<this.children.length;i+=3)if(this.children[i]<t&&this.children[i+1]>e){let l=this.children[i]+1;this.children[i+2].findInner(e-l,t-l,r,o+l,s)}}map(e,t,r){return this==q||e.maps.length==0?this:this.mapInner(e,t,0,0,r||De)}mapInner(e,t,r,o,s){let i;for(let l=0;l<this.local.length;l++){let a=this.local[l].map(e,r,o);a&&a.type.valid(t,a)?(i||(i=[])).push(a):s.onRemove&&s.onRemove(this.local[l].spec)}return this.children.length?Ta(this.children,i||[],e,t,r,o,s):i?new D(i.sort(Be),Ue):q}add(e,t){return t.length?this==q?D.create(e,t):this.addInner(e,t,0):this}addInner(e,t,r){let o,s=0;e.forEach((l,a)=>{let c=a+r,u;if(u=ci(t,l,c)){for(o||(o=this.children.slice());s<o.length&&o[s]<a;)s+=3;o[s]==a?o[s+2]=o[s+2].addInner(l,u,c+1):o.splice(s,0,a,a+l.nodeSize,_t(u,l,c+1,De)),s+=3}});let i=ai(s?ui(t):t,-r);for(let l=0;l<i.length;l++)i[l].type.valid(e,i[l])||i.splice(l--,1);return new D(i.length?this.local.concat(i).sort(Be):this.local,o||this.children)}remove(e){return e.length==0||this==q?this:this.removeInner(e,0)}removeInner(e,t){let r=this.children,o=this.local;for(let s=0;s<r.length;s+=3){let i,l=r[s]+t,a=r[s+1]+t;for(let u=0,d;u<e.length;u++)(d=e[u])&&d.from>l&&d.to<a&&(e[u]=null,(i||(i=[])).push(d));if(!i)continue;r==this.children&&(r=this.children.slice());let c=r[s+2].removeInner(i,l+1);c!=q?r[s+2]=c:(r.splice(s,3),s-=3)}if(o.length){for(let s=0,i;s<e.length;s++)if(i=e[s])for(let l=0;l<o.length;l++)o[l].eq(i,t)&&(o==this.local&&(o=this.local.slice()),o.splice(l--,1))}return r==this.children&&o==this.local?this:o.length||r.length?new D(o,r):q}forChild(e,t){if(this==q)return this;if(t.isLeaf)return D.empty;let r,o;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=e){this.children[l]==e&&(r=this.children[l+2]);break}let s=e+1,i=s+t.content.size;for(let l=0;l<this.local.length;l++){let a=this.local[l];if(a.from<i&&a.to>s&&a.type instanceof Ee){let c=Math.max(s,a.from)-s,u=Math.min(i,a.to)-s;c<u&&(o||(o=[])).push(a.copy(c,u))}}if(o){let l=new D(o.sort(Be),Ue);return r?new Le([l,r]):l}return r||q}eq(e){if(this==e)return!0;if(!(e instanceof D)||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 Ur(this.localsInner(e))}localsInner(e){if(this==q)return Ue;if(e.inlineContent||!this.local.some(Ee.is))return this.local;let t=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof Ee||t.push(this.local[r]);return t}}D.empty=new D([],[]);D.removeOverlap=Ur;const q=D.empty;class Le{constructor(e){this.members=e}map(e,t){const r=this.members.map(o=>o.map(e,t,De));return Le.from(r)}forChild(e,t){if(t.isLeaf)return D.empty;let r=[];for(let o=0;o<this.members.length;o++){let s=this.members[o].forChild(e,t);s!=q&&(s instanceof Le?r=r.concat(s.members):r.push(s))}return Le.from(r)}eq(e){if(!(e instanceof Le)||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,r=!0;for(let o=0;o<this.members.length;o++){let s=this.members[o].localsInner(e);if(s.length)if(!t)t=s;else{r&&(t=t.slice(),r=!1);for(let i=0;i<s.length;i++)t.push(s[i])}}return t?Ur(r?t:t.sort(Be)):Ue}static from(e){switch(e.length){case 0:return q;case 1:return e[0];default:return new Le(e.every(t=>t instanceof D)?e:e.reduce((t,r)=>t.concat(r instanceof D?r:r.members),[]))}}}function Ta(n,e,t,r,o,s,i){let l=n.slice();for(let c=0,u=s;c<t.maps.length;c++){let d=0;t.maps[c].forEach((f,h,p,m)=>{let g=m-p-(h-f);for(let y=0;y<l.length;y+=3){let M=l[y+1];if(M<0||f>M+u-d)continue;let A=l[y]+u-d;h>=A?l[y+1]=f<=A?-2:-1:f>=u&&g&&(l[y]+=g,l[y+1]+=g)}d+=g}),u=t.maps[c].map(u,-1)}let a=!1;for(let c=0;c<l.length;c+=3)if(l[c+1]<0){if(l[c+1]==-2){a=!0,l[c+1]=-1;continue}let u=t.map(n[c]+s),d=u-o;if(d<0||d>=r.content.size){a=!0;continue}let f=t.map(n[c+1]+s,-1),h=f-o,{index:p,offset:m}=r.content.findIndex(d),g=r.maybeChild(p);if(g&&m==d&&m+g.nodeSize==h){let y=l[c+2].mapInner(t,g,u+1,n[c]+s+1,i);y!=q?(l[c]=d,l[c+1]=h,l[c+2]=y):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=Aa(l,n,e,t,o,s,i),u=_t(c,r,0,i);e=u.local;for(let d=0;d<l.length;d+=3)l[d+1]<0&&(l.splice(d,3),d-=3);for(let d=0,f=0;d<u.children.length;d+=3){let h=u.children[d];for(;f<l.length&&l[f]<h;)f+=3;l.splice(f,0,u.children[d],u.children[d+1],u.children[d+2])}}return new D(e.sort(Be),l)}function ai(n,e){if(!e||!n.length)return n;let t=[];for(let r=0;r<n.length;r++){let o=n[r];t.push(new re(o.from+e,o.to+e,o.type))}return t}function Aa(n,e,t,r,o,s,i){function l(a,c){for(let u=0;u<a.local.length;u++){let d=a.local[u].map(r,o,c);d?t.push(d):i.onRemove&&i.onRemove(a.local[u].spec)}for(let u=0;u<a.children.length;u+=3)l(a.children[u+2],a.children[u]+c+1)}for(let a=0;a<n.length;a+=3)n[a+1]==-1&&l(n[a+2],e[a]+s+1);return t}function ci(n,e,t){if(e.isLeaf)return null;let r=t+e.nodeSize,o=null;for(let s=0,i;s<n.length;s++)(i=n[s])&&i.from>t&&i.to<r&&((o||(o=[])).push(i),n[s]=null);return o}function ui(n){let e=[];for(let t=0;t<n.length;t++)n[t]!=null&&e.push(n[t]);return e}function _t(n,e,t,r){let o=[],s=!1;e.forEach((l,a)=>{let c=ci(n,l,a+t);if(c){s=!0;let u=_t(c,l,t+a+1,r);u!=q&&o.push(a,a+l.nodeSize,u)}});let i=ai(s?ui(n):n,-t).sort(Be);for(let l=0;l<i.length;l++)i[l].type.valid(e,i[l])||(r.onRemove&&r.onRemove(i[l].spec),i.splice(l--,1));return i.length||o.length?new D(i,o):q}function Be(n,e){return n.from-e.from||n.to-e.to}function Ur(n){let e=n;for(let t=0;t<e.length-1;t++){let r=e[t];if(r.from!=r.to)for(let o=t+1;o<e.length;o++){let s=e[o];if(s.from==r.from){s.to!=r.to&&(e==n&&(e=n.slice()),e[o]=s.copy(s.from,r.to),Ho(e,o+1,s.copy(r.to,s.to)));continue}else{s.from<r.to&&(e==n&&(e=n.slice()),e[t]=r.copy(r.from,s.from),Ho(e,o,r.copy(s.from,r.to)));break}}}return e}function Ho(n,e,t){for(;e<n.length&&Be(t,n[e])>0;)e++;n.splice(e,0,t)}var Ne={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:"'"},Gt={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Ma=typeof navigator<"u"&&/Mac/.test(navigator.platform),Ea=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var j=0;j<10;j++)Ne[48+j]=Ne[96+j]=String(j);for(var j=1;j<=24;j++)Ne[j+111]="F"+j;for(var j=65;j<=90;j++)Ne[j]=String.fromCharCode(j+32),Gt[j]=String.fromCharCode(j);for(var Gn in Ne)Gt.hasOwnProperty(Gn)||(Gt[Gn]=Ne[Gn]);function Na(n){var e=Ma&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||Ea&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?Gt:Ne)[n.keyCode]||n.key||"Unidentified";return t=="Esc"&&(t="Escape"),t=="Del"&&(t="Delete"),t=="Left"&&(t="ArrowLeft"),t=="Up"&&(t="ArrowUp"),t=="Right"&&(t="ArrowRight"),t=="Down"&&(t="ArrowDown"),t}const Ra=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):!1;function Oa(n){let e=n.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");let r,o,s,i;for(let l=0;l<e.length-1;l++){let a=e[l];if(/^(cmd|meta|m)$/i.test(a))i=!0;else if(/^a(lt)?$/i.test(a))r=!0;else if(/^(c|ctrl|control)$/i.test(a))o=!0;else if(/^s(hift)?$/i.test(a))s=!0;else if(/^mod$/i.test(a))Ra?i=!0:o=!0;else throw new Error("Unrecognized modifier name: "+a)}return r&&(t="Alt-"+t),o&&(t="Ctrl-"+t),i&&(t="Meta-"+t),s&&(t="Shift-"+t),t}function Ia(n){let e=Object.create(null);for(let t in n)e[Oa(t)]=n[t];return e}function Qn(n,e,t=!0){return e.altKey&&(n="Alt-"+n),e.ctrlKey&&(n="Ctrl-"+n),e.metaKey&&(n="Meta-"+n),t&&e.shiftKey&&(n="Shift-"+n),n}function La(n){let e=Ia(n);return function(t,r){let o=Na(r),s,i=e[Qn(o,r)];if(i&&i(t.state,t.dispatch,t))return!0;if(o.length==1&&o!=" "){if(r.shiftKey){let l=e[Qn(o,r,!1)];if(l&&l(t.state,t.dispatch,t))return!0}if((r.shiftKey||r.altKey||r.metaKey||o.charCodeAt(0)>127)&&(s=Ne[r.keyCode])&&s!=o){let l=e[Qn(s,r)];if(l&&l(t.state,t.dispatch,t))return!0}}return!1}}const va=(n,e)=>n.selection.empty?!1:(e&&e(n.tr.deleteSelection().scrollIntoView()),!0);function di(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("backward",n):t.parentOffset>0)?null:t}const Pa=(n,e,t)=>{let r=di(n,t);if(!r)return!1;let o=_r(r);if(!o){let i=r.blockRange(),l=i&&rt(i);return l==null?!1:(e&&e(n.tr.lift(i,l).scrollIntoView()),!0)}let s=o.nodeBefore;if(!s.type.spec.isolating&&mi(n,o,e))return!0;if(r.parent.content.size==0&&(et(s,"end")||C.isSelectable(s))){let i=Rn(n.doc,r.before(),r.after(),S.empty);if(i&&i.slice.size<i.to-i.from){if(e){let l=n.tr.step(i);l.setSelection(et(s,"end")?x.findFrom(l.doc.resolve(l.mapping.map(o.pos,-1)),-1):C.create(l.doc,o.pos-s.nodeSize)),e(l.scrollIntoView())}return!0}}return s.isAtom&&o.depth==r.depth-1?(e&&e(n.tr.delete(o.pos-s.nodeSize,o.pos).scrollIntoView()),!0):!1},za=(n,e,t)=>{let r=di(n,t);if(!r)return!1;let o=_r(r);return o?fi(n,o,e):!1},Da=(n,e,t)=>{let r=hi(n,t);if(!r)return!1;let o=Gr(r);return o?fi(n,o,e):!1};function fi(n,e,t){let r=e.nodeBefore,o=r,s=e.pos-1;for(;!o.isTextblock;s--){if(o.type.spec.isolating)return!1;let u=o.lastChild;if(!u)return!1;o=u}let i=e.nodeAfter,l=i,a=e.pos+1;for(;!l.isTextblock;a++){if(l.type.spec.isolating)return!1;let u=l.firstChild;if(!u)return!1;l=u}let c=Rn(n.doc,s,a,S.empty);if(!c||c.from!=s||c instanceof $&&c.slice.size>=a-s)return!1;if(t){let u=n.tr.step(c);u.setSelection(w.create(u.doc,s)),t(u.scrollIntoView())}return!0}function et(n,e,t=!1){for(let r=n;r;r=e=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(t&&r.childCount!=1)return!1}return!1}const Ba=(n,e,t)=>{let{$head:r,empty:o}=n.selection,s=r;if(!o)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("backward",n):r.parentOffset>0)return!1;s=_r(r)}let i=s&&s.nodeBefore;return!i||!C.isSelectable(i)?!1:(e&&e(n.tr.setSelection(C.create(n.doc,s.pos-i.nodeSize)).scrollIntoView()),!0)};function _r(n){if(!n.parent.type.spec.isolating)for(let e=n.depth-1;e>=0;e--){if(n.index(e)>0)return n.doc.resolve(n.before(e+1));if(n.node(e).type.spec.isolating)break}return null}function hi(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("forward",n):t.parentOffset<t.parent.content.size)?null:t}const Ha=(n,e,t)=>{let r=hi(n,t);if(!r)return!1;let o=Gr(r);if(!o)return!1;let s=o.nodeAfter;if(mi(n,o,e))return!0;if(r.parent.content.size==0&&(et(s,"start")||C.isSelectable(s))){let i=Rn(n.doc,r.before(),r.after(),S.empty);if(i&&i.slice.size<i.to-i.from){if(e){let l=n.tr.step(i);l.setSelection(et(s,"start")?x.findFrom(l.doc.resolve(l.mapping.map(o.pos)),1):C.create(l.doc,l.mapping.map(o.pos))),e(l.scrollIntoView())}return!0}}return s.isAtom&&o.depth==r.depth-1?(e&&e(n.tr.delete(o.pos,o.pos+s.nodeSize).scrollIntoView()),!0):!1},$a=(n,e,t)=>{let{$head:r,empty:o}=n.selection,s=r;if(!o)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("forward",n):r.parentOffset<r.parent.content.size)return!1;s=Gr(r)}let i=s&&s.nodeAfter;return!i||!C.isSelectable(i)?!1:(e&&e(n.tr.setSelection(C.create(n.doc,s.pos)).scrollIntoView()),!0)};function Gr(n){if(!n.parent.type.spec.isolating)for(let e=n.depth-1;e>=0;e--){let t=n.node(e);if(n.index(e)+1<t.childCount)return n.doc.resolve(n.after(e+1));if(t.type.spec.isolating)break}return null}const Fa=(n,e)=>{let t=n.selection,r=t instanceof C,o;if(r){if(t.node.isTextblock||!Re(n.doc,t.from))return!1;o=t.from}else if(o=Nn(n.doc,t.from,-1),o==null)return!1;if(e){let s=n.tr.join(o);r&&s.setSelection(C.create(s.doc,o-n.doc.resolve(o).nodeBefore.nodeSize)),e(s.scrollIntoView())}return!0},ja=(n,e)=>{let t=n.selection,r;if(t instanceof C){if(t.node.isTextblock||!Re(n.doc,t.to))return!1;r=t.to}else if(r=Nn(n.doc,t.to,1),r==null)return!1;return e&&e(n.tr.join(r).scrollIntoView()),!0},Wa=(n,e)=>{let{$from:t,$to:r}=n.selection,o=t.blockRange(r),s=o&&rt(o);return s==null?!1:(e&&e(n.tr.lift(o,s).scrollIntoView()),!0)},Ka=(n,e)=>{let{$head:t,$anchor:r}=n.selection;return!t.parent.type.spec.code||!t.sameParent(r)?!1:(e&&e(n.tr.insertText(`
8
- `).scrollIntoView()),!0)};function pi(n){for(let e=0;e<n.edgeCount;e++){let{type:t}=n.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}const Va=(n,e)=>{let{$head:t,$anchor:r}=n.selection;if(!t.parent.type.spec.code||!t.sameParent(r))return!1;let o=t.node(-1),s=t.indexAfter(-1),i=pi(o.contentMatchAt(s));if(!i||!o.canReplaceWith(s,s,i))return!1;if(e){let l=t.after(),a=n.tr.replaceWith(l,l,i.createAndFill());a.setSelection(x.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},qa=(n,e)=>{let t=n.selection,{$from:r,$to:o}=t;if(t instanceof oe||r.parent.inlineContent||o.parent.inlineContent)return!1;let s=pi(o.parent.contentMatchAt(o.indexAfter()));if(!s||!s.isTextblock)return!1;if(e){let i=(!r.parentOffset&&o.index()<o.parent.childCount?r:o).pos,l=n.tr.insert(i,s.createAndFill());l.setSelection(w.create(l.doc,i+1)),e(l.scrollIntoView())}return!0},Ja=(n,e)=>{let{$cursor:t}=n.selection;if(!t||t.parent.content.size)return!1;if(t.depth>1&&t.after()!=t.end(-1)){let s=t.before();if(Ge(n.doc,s))return e&&e(n.tr.split(s).scrollIntoView()),!0}let r=t.blockRange(),o=r&&rt(r);return o==null?!1:(e&&e(n.tr.lift(r,o).scrollIntoView()),!0)},Ua=(n,e)=>{let{$from:t,to:r}=n.selection,o,s=t.sharedDepth(r);return s==0?!1:(o=t.before(s),e&&e(n.tr.setSelection(C.create(n.doc,o))),!0)};function _a(n,e,t){let r=e.nodeBefore,o=e.nodeAfter,s=e.index();return!r||!o||!r.type.compatibleContent(o.type)?!1:!r.content.size&&e.parent.canReplace(s-1,s)?(t&&t(n.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(s,s+1)||!(o.isTextblock||Re(n.doc,e.pos))?!1:(t&&t(n.tr.clearIncompatible(e.pos,r.type,r.contentMatchAt(r.childCount)).join(e.pos).scrollIntoView()),!0)}function mi(n,e,t){let r=e.nodeBefore,o=e.nodeAfter,s,i;if(r.type.spec.isolating||o.type.spec.isolating)return!1;if(_a(n,e,t))return!0;let l=e.parent.canReplace(e.index(),e.index()+1);if(l&&(s=(i=r.contentMatchAt(r.childCount)).findWrapping(o.type))&&i.matchType(s[0]||o.type).validEnd){if(t){let d=e.pos+o.nodeSize,f=b.empty;for(let m=s.length-1;m>=0;m--)f=b.from(s[m].create(null,f));f=b.from(r.copy(f));let h=n.tr.step(new F(e.pos-1,d,e.pos,d,new S(f,1,0),s.length,!0)),p=d+2*s.length;Re(h.doc,p)&&h.join(p),t(h.scrollIntoView())}return!0}let a=x.findFrom(e,1),c=a&&a.$from.blockRange(a.$to),u=c&&rt(c);if(u!=null&&u>=e.depth)return t&&t(n.tr.lift(c,u).scrollIntoView()),!0;if(l&&et(o,"start",!0)&&et(r,"end")){let d=r,f=[];for(;f.push(d),!d.isTextblock;)d=d.lastChild;let h=o,p=1;for(;!h.isTextblock;h=h.firstChild)p++;if(d.canReplace(d.childCount,d.childCount,h.content)){if(t){let m=b.empty;for(let y=f.length-1;y>=0;y--)m=b.from(f[y].copy(m));let g=n.tr.step(new F(e.pos-f.length,e.pos+o.nodeSize,e.pos+p,e.pos+o.nodeSize-p,new S(m,f.length,0),0,!0));t(g.scrollIntoView())}return!0}}return!1}function gi(n){return function(e,t){let r=e.selection,o=n<0?r.$from:r.$to,s=o.depth;for(;o.node(s).isInline;){if(!s)return!1;s--}return o.node(s).isTextblock?(t&&t(e.tr.setSelection(w.create(e.doc,n<0?o.start(s):o.end(s)))),!0):!1}}const Ga=gi(-1),Qa=gi(1);function Xa(n,e=null){return function(t,r){let{$from:o,$to:s}=t.selection,i=o.blockRange(s),l=i&&Hr(i,n,e);return l?(r&&r(t.tr.wrap(i,l).scrollIntoView()),!0):!1}}function $o(n,e=null){return function(t,r){let o=!1;for(let s=0;s<t.selection.ranges.length&&!o;s++){let{$from:{pos:i},$to:{pos:l}}=t.selection.ranges[s];t.doc.nodesBetween(i,l,(a,c)=>{if(o)return!1;if(!(!a.isTextblock||a.hasMarkup(n,e)))if(a.type==n)o=!0;else{let u=t.doc.resolve(c),d=u.index();o=u.parent.canReplaceWith(d,d+1,n)}})}if(!o)return!1;if(r){let s=t.tr;for(let i=0;i<t.selection.ranges.length;i++){let{$from:{pos:l},$to:{pos:a}}=t.selection.ranges[i];s.setBlockType(l,a,n,e)}r(s.scrollIntoView())}return!0}}typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function Ya(n,e=null){return function(t,r){let{$from:o,$to:s}=t.selection,i=o.blockRange(s),l=!1,a=i;if(!i)return!1;if(i.depth>=2&&o.node(i.depth-1).type.compatibleContent(n)&&i.startIndex==0){if(o.index(i.depth-1)==0)return!1;let u=t.doc.resolve(i.start-2);a=new fr(u,u,i.depth),i.endIndex<i.parent.childCount&&(i=new fr(o,t.doc.resolve(s.end(i.depth)),i.depth)),l=!0}let c=Hr(a,n,e,i);return c?(r&&r(Za(t.tr,i,c,l,n).scrollIntoView()),!0):!1}}function Za(n,e,t,r,o){let s=b.empty;for(let u=t.length-1;u>=0;u--)s=b.from(t[u].type.create(t[u].attrs,s));n.step(new F(e.start-(r?2:0),e.end,e.start,e.end,new S(s,0,0),t.length,!0));let i=0;for(let u=0;u<t.length;u++)t[u].type==o&&(i=u+1);let l=t.length-i,a=e.start+t.length-(r?2:0),c=e.parent;for(let u=e.startIndex,d=e.endIndex,f=!0;u<d;u++,f=!1)!f&&Ge(n.doc,a,l)&&(n.split(a,l),a+=2*l),a+=c.child(u).nodeSize;return n}function ec(n){return function(e,t){let{$from:r,$to:o}=e.selection,s=r.blockRange(o,i=>i.childCount>0&&i.firstChild.type==n);return s?t?r.node(s.depth-1).type==n?tc(e,t,n,s):nc(e,t,s):!0:!1}}function tc(n,e,t,r){let o=n.tr,s=r.end,i=r.$to.end(r.depth);s<i&&(o.step(new F(s-1,i,s,i,new S(b.from(t.create(null,r.parent.copy())),1,0),1,!0)),r=new fr(o.doc.resolve(r.$from.pos),o.doc.resolve(i),r.depth));const l=rt(r);if(l==null)return!1;o.lift(r,l);let a=o.mapping.map(s,-1)-1;return Re(o.doc,a)&&o.join(a),e(o.scrollIntoView()),!0}function nc(n,e,t){let r=n.tr,o=t.parent;for(let h=t.end,p=t.endIndex-1,m=t.startIndex;p>m;p--)h-=o.child(p).nodeSize,r.delete(h-1,h+1);let s=r.doc.resolve(t.start),i=s.nodeAfter;if(r.mapping.map(t.end)!=t.start+s.nodeAfter.nodeSize)return!1;let l=t.startIndex==0,a=t.endIndex==o.childCount,c=s.node(-1),u=s.index(-1);if(!c.canReplace(u+(l?0:1),u+1,i.content.append(a?b.empty:b.from(o))))return!1;let d=s.pos,f=d+i.nodeSize;return r.step(new F(d-(l?1:0),f+(a?1:0),d+1,f-1,new S((l?b.empty:b.from(o.copy(b.empty))).append(a?b.empty:b.from(o.copy(b.empty))),l?0:1,a?0:1),l?0:1)),e(r.scrollIntoView()),!0}function rc(n){return function(e,t){let{$from:r,$to:o}=e.selection,s=r.blockRange(o,c=>c.childCount>0&&c.firstChild.type==n);if(!s)return!1;let i=s.startIndex;if(i==0)return!1;let l=s.parent,a=l.child(i-1);if(a.type!=n)return!1;if(t){let c=a.lastChild&&a.lastChild.type==l.type,u=b.from(c?n.create():null),d=new S(b.from(n.create(null,b.from(l.type.create(null,u)))),c?3:1,0),f=s.start,h=s.end;t(e.tr.step(new F(f-(c?3:1),h,f,h,d,1,!0)).scrollIntoView())}return!0}}function yi(n){const{state:e,transaction:t}=n;let{selection:r}=t,{doc:o}=t,{storedMarks:s}=t;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return s},get selection(){return r},get doc(){return o},get tr(){return r=t.selection,o=t.doc,s=t.storedMarks,t}}}class oc{constructor(e){this.editor=e.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=e.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:e,editor:t,state:r}=this,{view:o}=t,{tr:s}=r,i=this.buildProps(s);return Object.fromEntries(Object.entries(e).map(([l,a])=>[l,(...u)=>{const d=a(...u)(i);return!s.getMeta("preventDispatch")&&!this.hasCustomState&&o.dispatch(s),d}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(e,t=!0){const{rawCommands:r,editor:o,state:s}=this,{view:i}=o,l=[],a=!!e,c=e||s.tr,u=()=>(!a&&t&&!c.getMeta("preventDispatch")&&!this.hasCustomState&&i.dispatch(c),l.every(f=>f===!0)),d={...Object.fromEntries(Object.entries(r).map(([f,h])=>[f,(...m)=>{const g=this.buildProps(c,t),y=h(...m)(g);return l.push(y),d}])),run:u};return d}createCan(e){const{rawCommands:t,state:r}=this,o=!1,s=e||r.tr,i=this.buildProps(s,o);return{...Object.fromEntries(Object.entries(t).map(([a,c])=>[a,(...u)=>c(...u)({...i,dispatch:void 0})])),chain:()=>this.createChain(s,o)}}buildProps(e,t=!0){const{rawCommands:r,editor:o,state:s}=this,{view:i}=o,l={tr:e,editor:o,view:i,state:yi({state:s,transaction:e}),dispatch:t?()=>{}:void 0,chain:()=>this.createChain(e,t),can:()=>this.createCan(e),get commands(){return Object.fromEntries(Object.entries(r).map(([a,c])=>[a,(...u)=>c(...u)(l)]))}};return l}}function H(n,e,t){return n.config[e]===void 0&&n.parent?H(n.parent,e,t):typeof n.config[e]=="function"?n.config[e].bind({...t,parent:n.parent?H(n.parent,e,t):null}):n.config[e]}function sc(n){const e=n.filter(o=>o.type==="extension"),t=n.filter(o=>o.type==="node"),r=n.filter(o=>o.type==="mark");return{baseExtensions:e,nodeExtensions:t,markExtensions:r}}function W(n,e){if(typeof n=="string"){if(!e.nodes[n])throw Error(`There is no node type named '${n}'. Maybe you forgot to add the extension?`);return e.nodes[n]}return n}function R(...n){return n.filter(e=>!!e).reduce((e,t)=>{const r={...e};return Object.entries(t).forEach(([o,s])=>{if(!r[o]){r[o]=s;return}if(o==="class"){const l=s?s.split(" "):[],a=r[o]?r[o].split(" "):[],c=l.filter(u=>!a.includes(u));r[o]=[...a,...c].join(" ")}else o==="style"?r[o]=[r[o],s].join("; "):r[o]=s}),r},{})}function ic(n){return typeof n=="function"}function v(n,e=void 0,...t){return ic(n)?e?n.bind(e)(...t):n(...t):n}function lc(n){return Object.prototype.toString.call(n)==="[object RegExp]"}class vn{constructor(e){this.find=e.find,this.handler=e.handler}}class ac{constructor(e){this.find=e.find,this.handler=e.handler}}function cc(n){return Object.prototype.toString.call(n).slice(8,-1)}function Xn(n){return cc(n)!=="Object"?!1:n.constructor===Object&&Object.getPrototypeOf(n)===Object.prototype}function Pn(n,e){const t={...n};return Xn(n)&&Xn(e)&&Object.keys(e).forEach(r=>{Xn(e[r])?r in n?t[r]=Pn(n[r],e[r]):Object.assign(t,{[r]:e[r]}):Object.assign(t,{[r]:e[r]})}),t}class me{constructor(e={}){this.type="extension",this.name="extension",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=v(H(this,"addOptions",{name:this.name}))),this.storage=v(H(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new me(e)}configure(e={}){const t=this.extend();return t.parent=this.parent,t.options=Pn(this.options,e),t.storage=v(H(t,"addStorage",{name:t.name,options:t.options})),t}extend(e={}){const t=new me({...this.config,...e});return t.parent=this,this.child=t,t.name=e.name?e.name:t.parent.name,e.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${t.name}".`),t.options=v(H(t,"addOptions",{name:t.name})),t.storage=v(H(t,"addStorage",{name:t.name,options:t.options})),t}}function uc(n,e,t){const{from:r,to:o}=e,{blockSeparator:s=`
7
+ `))),0,0):S.empty;let d=n.someProp("clipboardTextParser",f=>f(e,o,r,n));if(d)l=d;else{let f=o.marks(),{schema:h}=n.state,p=ve.fromSchema(h);i=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(m=>{let g=i.appendChild(document.createElement("p"));m&&g.appendChild(p.serializeNode(h.text(m,f)))})}}else n.someProp("transformPastedHTML",d=>{t=d(t,n)}),i=ia(t),Wr&&la(i);let c=i&&i.querySelector("[data-pm-slice]"),u=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(u&&u[3])for(let d=+u[3];d>0;d--){let f=i.firstChild;for(;f&&f.nodeType!=1;)f=f.nextSibling;if(!f)break;i=f}if(l||(l=(n.someProp("clipboardParser")||n.someProp("domParser")||pt.fromSchema(n.state.schema)).parseSlice(i,{preserveWhitespace:!!(a||u),context:o,ruleFromNode(f){return f.nodeName=="BR"&&!f.nextSibling&&f.parentNode&&!oa.test(f.parentNode.nodeName)?{ignore:!0}:null}})),u)l=aa(Do(l,+u[1],+u[2]),u[4]);else if(l=S.maxOpen(sa(l.content,o),!0),l.openStart||l.openEnd){let d=0,f=0;for(let h=l.content.firstChild;d<l.openStart&&!h.type.spec.isolating;d++,h=h.firstChild);for(let h=l.content.lastChild;f<l.openEnd&&!h.type.spec.isolating;f++,h=h.lastChild);l=Do(l,d,f)}return n.someProp("transformPasted",d=>{l=d(l,n)}),l}const oa=/^(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 sa(n,e){if(n.childCount<2)return n;for(let t=e.depth;t>=0;t--){let o=e.node(t).contentMatchAt(e.index(t)),s,i=[];if(n.forEach(l=>{if(!i)return;let a=o.findWrapping(l.type),c;if(!a)return i=null;if(c=i.length&&s.length&&Zs(a,s,l,i[i.length-1],0))i[i.length-1]=c;else{i.length&&(i[i.length-1]=ei(i[i.length-1],s.length));let u=Ys(l,a);i.push(u),o=o.matchType(u.type),s=a}}),i)return b.from(i)}return n}function Ys(n,e,t=0){for(let r=e.length-1;r>=t;r--)n=e[r].create(null,b.from(n));return n}function Zs(n,e,t,r,o){if(o<n.length&&o<e.length&&n[o]==e[o]){let s=Zs(n,e,t,r.lastChild,o+1);if(s)return r.copy(r.content.replaceChild(r.childCount-1,s));if(r.contentMatchAt(r.childCount).matchType(o==n.length-1?t.type:n[o+1]))return r.copy(r.content.append(b.from(Ys(t,n,o+1))))}}function ei(n,e){if(e==0)return n;let t=n.content.replaceChild(n.childCount-1,ei(n.lastChild,e-1)),r=n.contentMatchAt(n.childCount).fillBefore(b.empty,!0);return n.copy(t.append(r))}function Sr(n,e,t,r,o,s){let i=e<0?n.firstChild:n.lastChild,l=i.content;return n.childCount>1&&(s=0),o<r-1&&(l=Sr(l,e,t,r,o+1,s)),o>=t&&(l=e<0?i.contentMatchAt(0).fillBefore(l,s<=o).append(l):l.append(i.contentMatchAt(i.childCount).fillBefore(b.empty,!0))),n.replaceChild(e<0?0:n.childCount-1,i.copy(l))}function Do(n,e,t){return e<n.openStart&&(n=new S(Sr(n.content,-1,e,n.openStart,0,n.openEnd),e,n.openEnd)),t<n.openEnd&&(n=new S(Sr(n.content,1,t,n.openEnd,0,0),n.openStart,t)),n}const ti={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 Bo=null;function ni(){return Bo||(Bo=document.implementation.createHTMLDocument("title"))}function ia(n){let e=/^(\s*<meta [^>]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=ni().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(n),o;if((o=r&&ti[r[1].toLowerCase()])&&(n=o.map(s=>"<"+s+">").join("")+n+o.map(s=>"</"+s+">").reverse().join("")),t.innerHTML=n,o)for(let s=0;s<o.length;s++)t=t.querySelector(o[s])||t;return t}function la(n){let e=n.querySelectorAll(je?"span:not([class]):not([style])":"span.Apple-converted-space");for(let t=0;t<e.length;t++){let r=e[t];r.childNodes.length==1&&r.textContent==" "&&r.parentNode&&r.parentNode.replaceChild(n.ownerDocument.createTextNode(" "),r)}}function aa(n,e){if(!n.size)return n;let t=n.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return n}let{content:o,openStart:s,openEnd:i}=n;for(let l=r.length-2;l>=0;l-=2){let a=t.nodes[r[l]];if(!a||a.hasRequiredAttrs())break;o=b.from(a.create(r[l+1],o)),s++,i++}return new S(o,s,i)}const le={},Q={};function Me(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}Q.keydown=(n,e)=>{let t=e;if(n.input.shiftKey=t.keyCode==16||t.shiftKey,!oi(n,t)&&(n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),!(xt&&je&&t.keyCode==13)))if(t.keyCode!=229&&n.domObserver.forceFlush(),jr&&t.keyCode==13&&!t.ctrlKey&&!t.altKey&&!t.metaKey){let r=Date.now();n.input.lastIOSEnter=r,n.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{n.input.lastIOSEnter==r&&(n.someProp("handleKeyDown",o=>o(n,Vs(13,"Enter"))),n.input.lastIOSEnter=0)},200)}else n.someProp("handleKeyDown",r=>r(n,t))||ra(n,t)?t.preventDefault():Me(n,"key")};Q.keyup=(n,e)=>{e.keyCode==16&&(n.input.shiftKey=!1)};Q.keypress=(n,e)=>{let t=e;if(oi(n,t)||!t.charCode||t.ctrlKey&&!t.altKey||Z&&t.metaKey)return;if(n.someProp("handleKeyPress",o=>o(n,t))){t.preventDefault();return}let r=n.state.selection;if(!(r instanceof w)||!r.$from.sameParent(r.$to)){let o=String.fromCharCode(t.charCode);!/[\r\n]/.test(o)&&!n.someProp("handleTextInput",s=>s(n,r.$from.pos,r.$to.pos,o))&&n.dispatch(n.state.tr.insertText(o).scrollIntoView()),t.preventDefault()}};function Ln(n){return{left:n.clientX,top:n.clientY}}function ca(n,e){let t=e.x-n.clientX,r=e.y-n.clientY;return t*t+r*r<100}function Vr(n,e,t,r,o){if(r==-1)return!1;let s=n.state.doc.resolve(r);for(let i=s.depth+1;i>0;i--)if(n.someProp(e,l=>i>s.depth?l(n,t,s.nodeAfter,s.before(i),o,!0):l(n,t,s.node(i),s.before(i),o,!1)))return!0;return!1}function Xe(n,e,t){n.focused||n.focus();let r=n.state.tr.setSelection(e);r.setMeta("pointer",!0),n.dispatch(r)}function ua(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),r=t.nodeAfter;return r&&r.isAtom&&C.isSelectable(r)?(Xe(n,new C(t)),!0):!1}function da(n,e){if(e==-1)return!1;let t=n.state.selection,r,o;t instanceof C&&(r=t.node);let s=n.state.doc.resolve(e);for(let i=s.depth+1;i>0;i--){let l=i>s.depth?s.nodeAfter:s.node(i);if(C.isSelectable(l)){r&&t.$from.depth>0&&i>=t.$from.depth&&s.before(t.$from.depth+1)==t.$from.pos?o=s.before(t.$from.depth):o=s.before(i);break}}return o!=null?(Xe(n,C.create(n.state.doc,o)),!0):!1}function fa(n,e,t,r,o){return Vr(n,"handleClickOn",e,t,r)||n.someProp("handleClick",s=>s(n,e,r))||(o?da(n,t):ua(n,t))}function ha(n,e,t,r){return Vr(n,"handleDoubleClickOn",e,t,r)||n.someProp("handleDoubleClick",o=>o(n,e,r))}function pa(n,e,t,r){return Vr(n,"handleTripleClickOn",e,t,r)||n.someProp("handleTripleClick",o=>o(n,e,r))||ma(n,t,r)}function ma(n,e,t){if(t.button!=0)return!1;let r=n.state.doc;if(e==-1)return r.inlineContent?(Xe(n,w.create(r,0,r.content.size)),!0):!1;let o=r.resolve(e);for(let s=o.depth+1;s>0;s--){let i=s>o.depth?o.nodeAfter:o.node(s),l=o.before(s);if(i.inlineContent)Xe(n,w.create(r,l+1,l+1+i.content.size));else if(C.isSelectable(i))Xe(n,C.create(r,l));else continue;return!0}}function qr(n){return Jt(n)}const ri=Z?"metaKey":"ctrlKey";le.mousedown=(n,e)=>{let t=e;n.input.shiftKey=t.shiftKey;let r=qr(n),o=Date.now(),s="singleClick";o-n.input.lastClick.time<500&&ca(t,n.input.lastClick)&&!t[ri]&&(n.input.lastClick.type=="singleClick"?s="doubleClick":n.input.lastClick.type=="doubleClick"&&(s="tripleClick")),n.input.lastClick={time:o,x:t.clientX,y:t.clientY,type:s};let i=n.posAtCoords(Ln(t));i&&(s=="singleClick"?(n.input.mouseDown&&n.input.mouseDown.done(),n.input.mouseDown=new ga(n,i,t,!!r)):(s=="doubleClick"?ha:pa)(n,i.pos,i.inside,t)?t.preventDefault():Me(n,"pointer"))};class ga{constructor(e,t,r,o){this.view=e,this.pos=t,this.event=r,this.flushed=o,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!r[ri],this.allowDefault=r.shiftKey;let s,i;if(t.inside>-1)s=e.state.doc.nodeAt(t.inside),i=t.inside;else{let u=e.state.doc.resolve(t.pos);s=u.parent,i=u.depth?u.before():0}const l=o?null:r.target,a=l?e.docView.nearestDesc(l,!0):null;this.target=a&&a.dom.nodeType==1?a.dom:null;let{selection:c}=e.state;(r.button==0&&s.type.spec.draggable&&s.type.spec.selectable!==!1||c instanceof C&&c.from<=i&&c.to>i)&&(this.mightDrag={node:s,pos:i,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&In&&!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)),Me(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(()=>Kr(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(Ln(e))),this.updateAllowDefault(e),this.allowDefault||!t?Me(this.view,"pointer"):fa(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||We&&this.mightDrag&&!this.mightDrag.node.isAtom||je&&!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)?(Xe(this.view,x.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):Me(this.view,"pointer")}move(e){this.updateAllowDefault(e),Me(this.view,"pointer"),e.buttons==0&&this.done()}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}}le.touchstart=n=>{n.input.lastTouch=Date.now(),qr(n),Me(n,"pointer")};le.touchmove=n=>{n.input.lastTouch=Date.now(),Me(n,"pointer")};le.contextmenu=n=>qr(n);function oi(n,e){return n.composing?!0:We&&Math.abs(e.timeStamp-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}const ya=xt?5e3:-1;Q.compositionstart=Q.compositionupdate=n=>{if(!n.composing){n.domObserver.flush();let{state:e}=n,t=e.selection.$from;if(e.selection.empty&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)))n.markCursor=n.state.storedMarks||t.marks(),Jt(n,!0),n.markCursor=null;else if(Jt(n),In&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length){let r=n.domSelectionRange();for(let o=r.focusNode,s=r.focusOffset;o&&o.nodeType==1&&s!=0;){let i=s<0?o.lastChild:o.childNodes[s-1];if(!i)break;if(i.nodeType==3){n.domSelection().collapse(i,i.nodeValue.length);break}else o=i,s=-1}}n.input.composing=!0}si(n,ya)};Q.compositionend=(n,e)=>{n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=e.timeStamp,n.input.compositionPendingChanges=n.domObserver.pendingRecords().length?n.input.compositionID:0,n.input.compositionNode=null,n.input.compositionPendingChanges&&Promise.resolve().then(()=>n.domObserver.flush()),n.input.compositionID++,si(n,20))};function si(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>Jt(n),e))}function ba(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=ka());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function ka(){let n=document.createEvent("Event");return n.initEvent("event",!0,!0),n.timeStamp}function Jt(n,e=!1){if(!(xt&&n.domObserver.flushingSoon>=0)){if(n.domObserver.forceFlush(),ba(n),e||n.docView&&n.docView.dirty){let t=Jl(n);return t&&!t.eq(n.state.selection)?n.dispatch(n.state.tr.setSelection(t)):n.updateState(n.state),!0}return!1}}function Sa(n,e){if(!n.dom.parentNode)return;let t=n.dom.parentNode.appendChild(document.createElement("div"));t.appendChild(e),t.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),o=document.createRange();o.selectNodeContents(e),n.dom.blur(),r.removeAllRanges(),r.addRange(o),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t),n.focus()},50)}const gt=wt&&Js<15||jr&&ql<604;le.copy=Q.cut=(n,e)=>{let t=e,r=n.state.selection,o=t.type=="cut";if(r.empty)return;let s=gt?null:t.clipboardData,i=r.content(),{dom:l,text:a}=Qs(n,i);s?(t.preventDefault(),s.clearData(),s.setData("text/html",l.innerHTML),s.setData("text/plain",a)):Sa(n,l),o&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function Ca(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function wa(n,e){if(!n.dom.parentNode)return;let t=n.input.shiftKey||n.state.selection.$from.parent.type.spec.code,r=n.dom.parentNode.appendChild(document.createElement(t?"textarea":"div"));t||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let o=n.input.shiftKey&&n.input.lastKeyCode!=45;setTimeout(()=>{n.focus(),r.parentNode&&r.parentNode.removeChild(r),t?Cr(n,r.value,null,o,e):Cr(n,r.textContent,r.innerHTML,o,e)},50)}function Cr(n,e,t,r,o){let s=Xs(n,e,t,r,n.state.selection.$from);if(n.someProp("handlePaste",a=>a(n,o,s||S.empty)))return!0;if(!s)return!1;let i=Ca(s),l=i?n.state.tr.replaceSelectionWith(i,r):n.state.tr.replaceSelection(s);return n.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function ii(n){let e=n.getData("text/plain")||n.getData("Text");if(e)return e;let t=n.getData("text/uri-list");return t?t.replace(/\r?\n/g," "):""}Q.paste=(n,e)=>{let t=e;if(n.composing&&!xt)return;let r=gt?null:t.clipboardData,o=n.input.shiftKey&&n.input.lastKeyCode!=45;r&&Cr(n,ii(r),r.getData("text/html"),o,t)?t.preventDefault():wa(n,t)};class xa{constructor(e,t,r){this.slice=e,this.move=t,this.node=r}}const li=Z?"altKey":"ctrlKey";le.dragstart=(n,e)=>{let t=e,r=n.input.mouseDown;if(r&&r.done(),!t.dataTransfer)return;let o=n.state.selection,s=o.empty?null:n.posAtCoords(Ln(t)),i;if(!(s&&s.pos>=o.from&&s.pos<=(o instanceof C?o.to-1:o.to))){if(r&&r.mightDrag)i=C.create(n.state.doc,r.mightDrag.pos);else if(t.target&&t.target.nodeType==1){let d=n.docView.nearestDesc(t.target,!0);d&&d.node.type.spec.draggable&&d!=n.docView&&(i=C.create(n.state.doc,d.posBefore))}}let l=(i||n.state.selection).content(),{dom:a,text:c,slice:u}=Qs(n,l);t.dataTransfer.clearData(),t.dataTransfer.setData(gt?"Text":"text/html",a.innerHTML),t.dataTransfer.effectAllowed="copyMove",gt||t.dataTransfer.setData("text/plain",c),n.dragging=new xa(u,!t[li],i)};le.dragend=n=>{let e=n.dragging;window.setTimeout(()=>{n.dragging==e&&(n.dragging=null)},50)};Q.dragover=Q.dragenter=(n,e)=>e.preventDefault();Q.drop=(n,e)=>{let t=e,r=n.dragging;if(n.dragging=null,!t.dataTransfer)return;let o=n.posAtCoords(Ln(t));if(!o)return;let s=n.state.doc.resolve(o.pos),i=r&&r.slice;i?n.someProp("transformPasted",p=>{i=p(i,n)}):i=Xs(n,ii(t.dataTransfer),gt?null:t.dataTransfer.getData("text/html"),!1,s);let l=!!(r&&!t[li]);if(n.someProp("handleDrop",p=>p(n,t,i||S.empty,l))){t.preventDefault();return}if(!i)return;t.preventDefault();let a=i?vl(n.state.doc,s.pos,i):s.pos;a==null&&(a=s.pos);let c=n.state.tr;if(l){let{node:p}=r;p?p.replace(c):c.deleteSelection()}let u=c.mapping.map(a),d=i.openStart==0&&i.openEnd==0&&i.content.childCount==1,f=c.doc;if(d?c.replaceRangeWith(u,u,i.content.firstChild):c.replaceRange(u,u,i),c.doc.eq(f))return;let h=c.doc.resolve(u);if(d&&C.isSelectable(i.content.firstChild)&&h.nodeAfter&&h.nodeAfter.sameMarkup(i.content.firstChild))c.setSelection(new C(h));else{let p=c.mapping.map(a);c.mapping.maps[c.mapping.maps.length-1].forEach((m,g,y,M)=>p=M),c.setSelection(_s(n,h,c.doc.resolve(p)))}n.focus(),n.dispatch(c.setMeta("uiEvent","drop"))};le.focus=n=>{n.input.lastFocus=Date.now(),n.focused||(n.domObserver.stop(),n.dom.classList.add("ProseMirror-focused"),n.domObserver.start(),n.focused=!0,setTimeout(()=>{n.docView&&n.hasFocus()&&!n.domObserver.currentSelection.eq(n.domSelectionRange())&&Kr(n)},20))};le.blur=(n,e)=>{let t=e;n.focused&&(n.domObserver.stop(),n.dom.classList.remove("ProseMirror-focused"),n.domObserver.start(),t.relatedTarget&&n.dom.contains(t.relatedTarget)&&n.domObserver.currentSelection.clear(),n.focused=!1)};le.beforeinput=(n,e)=>{if(je&&xt&&e.inputType=="deleteContentBackward"){n.domObserver.flushSoon();let{domChangeCount:r}=n.input;setTimeout(()=>{if(n.input.domChangeCount!=r||(n.dom.blur(),n.focus(),n.someProp("handleKeyDown",s=>s(n,Vs(8,"Backspace")))))return;let{$cursor:o}=n.state.selection;o&&o.pos>0&&n.dispatch(n.state.tr.delete(o.pos-1,o.pos).scrollIntoView())},50)}};for(let n in Q)le[n]=Q[n];function yt(n,e){if(n==e)return!0;for(let t in n)if(n[t]!==e[t])return!1;for(let t in e)if(!(t in n))return!1;return!0}class Ut{constructor(e,t){this.toDOM=e,this.spec=t||De,this.side=this.spec.side||0}map(e,t,r,o){let{pos:s,deleted:i}=e.mapResult(t.from+o,this.side<0?-1:1);return i?null:new re(s-r,s-r,this)}valid(){return!0}eq(e){return this==e||e instanceof Ut&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&yt(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class Ee{constructor(e,t){this.attrs=e,this.spec=t||De}map(e,t,r,o){let s=e.map(t.from+o,this.spec.inclusiveStart?-1:1)-r,i=e.map(t.to+o,this.spec.inclusiveEnd?1:-1)-r;return s>=i?null:new re(s,i,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof Ee&&yt(this.attrs,e.attrs)&&yt(this.spec,e.spec)}static is(e){return e.type instanceof Ee}destroy(){}}class Jr{constructor(e,t){this.attrs=e,this.spec=t||De}map(e,t,r,o){let s=e.mapResult(t.from+o,1);if(s.deleted)return null;let i=e.mapResult(t.to+o,-1);return i.deleted||i.pos<=s.pos?null:new re(s.pos-r,i.pos-r,this)}valid(e,t){let{index:r,offset:o}=e.content.findIndex(t.from),s;return o==t.from&&!(s=e.child(r)).isText&&o+s.nodeSize==t.to}eq(e){return this==e||e instanceof Jr&&yt(this.attrs,e.attrs)&&yt(this.spec,e.spec)}destroy(){}}class re{constructor(e,t,r){this.from=e,this.to=t,this.type=r}copy(e,t){return new re(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,r){return this.type.map(e,this,t,r)}static widget(e,t,r){return new re(e,e,new Ut(t,r))}static inline(e,t,r,o){return new re(e,t,new Ee(r,o))}static node(e,t,r,o){return new re(e,t,new Jr(r,o))}get spec(){return this.type.spec}get inline(){return this.type instanceof Ee}get widget(){return this.type instanceof Ut}}const Ue=[],De={};class D{constructor(e,t){this.local=e.length?e:Ue,this.children=t.length?t:Ue}static create(e,t){return t.length?_t(t,e,0,De):J}find(e,t,r){let o=[];return this.findInner(e??0,t??1e9,o,0,r),o}findInner(e,t,r,o,s){for(let i=0;i<this.local.length;i++){let l=this.local[i];l.from<=t&&l.to>=e&&(!s||s(l.spec))&&r.push(l.copy(l.from+o,l.to+o))}for(let i=0;i<this.children.length;i+=3)if(this.children[i]<t&&this.children[i+1]>e){let l=this.children[i]+1;this.children[i+2].findInner(e-l,t-l,r,o+l,s)}}map(e,t,r){return this==J||e.maps.length==0?this:this.mapInner(e,t,0,0,r||De)}mapInner(e,t,r,o,s){let i;for(let l=0;l<this.local.length;l++){let a=this.local[l].map(e,r,o);a&&a.type.valid(t,a)?(i||(i=[])).push(a):s.onRemove&&s.onRemove(this.local[l].spec)}return this.children.length?Ta(this.children,i||[],e,t,r,o,s):i?new D(i.sort(Be),Ue):J}add(e,t){return t.length?this==J?D.create(e,t):this.addInner(e,t,0):this}addInner(e,t,r){let o,s=0;e.forEach((l,a)=>{let c=a+r,u;if(u=ci(t,l,c)){for(o||(o=this.children.slice());s<o.length&&o[s]<a;)s+=3;o[s]==a?o[s+2]=o[s+2].addInner(l,u,c+1):o.splice(s,0,a,a+l.nodeSize,_t(u,l,c+1,De)),s+=3}});let i=ai(s?ui(t):t,-r);for(let l=0;l<i.length;l++)i[l].type.valid(e,i[l])||i.splice(l--,1);return new D(i.length?this.local.concat(i).sort(Be):this.local,o||this.children)}remove(e){return e.length==0||this==J?this:this.removeInner(e,0)}removeInner(e,t){let r=this.children,o=this.local;for(let s=0;s<r.length;s+=3){let i,l=r[s]+t,a=r[s+1]+t;for(let u=0,d;u<e.length;u++)(d=e[u])&&d.from>l&&d.to<a&&(e[u]=null,(i||(i=[])).push(d));if(!i)continue;r==this.children&&(r=this.children.slice());let c=r[s+2].removeInner(i,l+1);c!=J?r[s+2]=c:(r.splice(s,3),s-=3)}if(o.length){for(let s=0,i;s<e.length;s++)if(i=e[s])for(let l=0;l<o.length;l++)o[l].eq(i,t)&&(o==this.local&&(o=this.local.slice()),o.splice(l--,1))}return r==this.children&&o==this.local?this:o.length||r.length?new D(o,r):J}forChild(e,t){if(this==J)return this;if(t.isLeaf)return D.empty;let r,o;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=e){this.children[l]==e&&(r=this.children[l+2]);break}let s=e+1,i=s+t.content.size;for(let l=0;l<this.local.length;l++){let a=this.local[l];if(a.from<i&&a.to>s&&a.type instanceof Ee){let c=Math.max(s,a.from)-s,u=Math.min(i,a.to)-s;c<u&&(o||(o=[])).push(a.copy(c,u))}}if(o){let l=new D(o.sort(Be),Ue);return r?new Le([l,r]):l}return r||J}eq(e){if(this==e)return!0;if(!(e instanceof D)||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 Ur(this.localsInner(e))}localsInner(e){if(this==J)return Ue;if(e.inlineContent||!this.local.some(Ee.is))return this.local;let t=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof Ee||t.push(this.local[r]);return t}}D.empty=new D([],[]);D.removeOverlap=Ur;const J=D.empty;class Le{constructor(e){this.members=e}map(e,t){const r=this.members.map(o=>o.map(e,t,De));return Le.from(r)}forChild(e,t){if(t.isLeaf)return D.empty;let r=[];for(let o=0;o<this.members.length;o++){let s=this.members[o].forChild(e,t);s!=J&&(s instanceof Le?r=r.concat(s.members):r.push(s))}return Le.from(r)}eq(e){if(!(e instanceof Le)||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,r=!0;for(let o=0;o<this.members.length;o++){let s=this.members[o].localsInner(e);if(s.length)if(!t)t=s;else{r&&(t=t.slice(),r=!1);for(let i=0;i<s.length;i++)t.push(s[i])}}return t?Ur(r?t:t.sort(Be)):Ue}static from(e){switch(e.length){case 0:return J;case 1:return e[0];default:return new Le(e.every(t=>t instanceof D)?e:e.reduce((t,r)=>t.concat(r instanceof D?r:r.members),[]))}}}function Ta(n,e,t,r,o,s,i){let l=n.slice();for(let c=0,u=s;c<t.maps.length;c++){let d=0;t.maps[c].forEach((f,h,p,m)=>{let g=m-p-(h-f);for(let y=0;y<l.length;y+=3){let M=l[y+1];if(M<0||f>M+u-d)continue;let A=l[y]+u-d;h>=A?l[y+1]=f<=A?-2:-1:f>=u&&g&&(l[y]+=g,l[y+1]+=g)}d+=g}),u=t.maps[c].map(u,-1)}let a=!1;for(let c=0;c<l.length;c+=3)if(l[c+1]<0){if(l[c+1]==-2){a=!0,l[c+1]=-1;continue}let u=t.map(n[c]+s),d=u-o;if(d<0||d>=r.content.size){a=!0;continue}let f=t.map(n[c+1]+s,-1),h=f-o,{index:p,offset:m}=r.content.findIndex(d),g=r.maybeChild(p);if(g&&m==d&&m+g.nodeSize==h){let y=l[c+2].mapInner(t,g,u+1,n[c]+s+1,i);y!=J?(l[c]=d,l[c+1]=h,l[c+2]=y):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=Aa(l,n,e,t,o,s,i),u=_t(c,r,0,i);e=u.local;for(let d=0;d<l.length;d+=3)l[d+1]<0&&(l.splice(d,3),d-=3);for(let d=0,f=0;d<u.children.length;d+=3){let h=u.children[d];for(;f<l.length&&l[f]<h;)f+=3;l.splice(f,0,u.children[d],u.children[d+1],u.children[d+2])}}return new D(e.sort(Be),l)}function ai(n,e){if(!e||!n.length)return n;let t=[];for(let r=0;r<n.length;r++){let o=n[r];t.push(new re(o.from+e,o.to+e,o.type))}return t}function Aa(n,e,t,r,o,s,i){function l(a,c){for(let u=0;u<a.local.length;u++){let d=a.local[u].map(r,o,c);d?t.push(d):i.onRemove&&i.onRemove(a.local[u].spec)}for(let u=0;u<a.children.length;u+=3)l(a.children[u+2],a.children[u]+c+1)}for(let a=0;a<n.length;a+=3)n[a+1]==-1&&l(n[a+2],e[a]+s+1);return t}function ci(n,e,t){if(e.isLeaf)return null;let r=t+e.nodeSize,o=null;for(let s=0,i;s<n.length;s++)(i=n[s])&&i.from>t&&i.to<r&&((o||(o=[])).push(i),n[s]=null);return o}function ui(n){let e=[];for(let t=0;t<n.length;t++)n[t]!=null&&e.push(n[t]);return e}function _t(n,e,t,r){let o=[],s=!1;e.forEach((l,a)=>{let c=ci(n,l,a+t);if(c){s=!0;let u=_t(c,l,t+a+1,r);u!=J&&o.push(a,a+l.nodeSize,u)}});let i=ai(s?ui(n):n,-t).sort(Be);for(let l=0;l<i.length;l++)i[l].type.valid(e,i[l])||(r.onRemove&&r.onRemove(i[l].spec),i.splice(l--,1));return i.length||o.length?new D(i,o):J}function Be(n,e){return n.from-e.from||n.to-e.to}function Ur(n){let e=n;for(let t=0;t<e.length-1;t++){let r=e[t];if(r.from!=r.to)for(let o=t+1;o<e.length;o++){let s=e[o];if(s.from==r.from){s.to!=r.to&&(e==n&&(e=n.slice()),e[o]=s.copy(s.from,r.to),Ho(e,o+1,s.copy(r.to,s.to)));continue}else{s.from<r.to&&(e==n&&(e=n.slice()),e[t]=r.copy(r.from,s.from),Ho(e,o,r.copy(s.from,r.to)));break}}}return e}function Ho(n,e,t){for(;e<n.length&&Be(t,n[e])>0;)e++;n.splice(e,0,t)}var Ne={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:"'"},Gt={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Ma=typeof navigator<"u"&&/Mac/.test(navigator.platform),Ea=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var j=0;j<10;j++)Ne[48+j]=Ne[96+j]=String(j);for(var j=1;j<=24;j++)Ne[j+111]="F"+j;for(var j=65;j<=90;j++)Ne[j]=String.fromCharCode(j+32),Gt[j]=String.fromCharCode(j);for(var Gn in Ne)Gt.hasOwnProperty(Gn)||(Gt[Gn]=Ne[Gn]);function Na(n){var e=Ma&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||Ea&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?Gt:Ne)[n.keyCode]||n.key||"Unidentified";return t=="Esc"&&(t="Escape"),t=="Del"&&(t="Delete"),t=="Left"&&(t="ArrowLeft"),t=="Up"&&(t="ArrowUp"),t=="Right"&&(t="ArrowRight"),t=="Down"&&(t="ArrowDown"),t}const Ra=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):!1;function Oa(n){let e=n.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");let r,o,s,i;for(let l=0;l<e.length-1;l++){let a=e[l];if(/^(cmd|meta|m)$/i.test(a))i=!0;else if(/^a(lt)?$/i.test(a))r=!0;else if(/^(c|ctrl|control)$/i.test(a))o=!0;else if(/^s(hift)?$/i.test(a))s=!0;else if(/^mod$/i.test(a))Ra?i=!0:o=!0;else throw new Error("Unrecognized modifier name: "+a)}return r&&(t="Alt-"+t),o&&(t="Ctrl-"+t),i&&(t="Meta-"+t),s&&(t="Shift-"+t),t}function Ia(n){let e=Object.create(null);for(let t in n)e[Oa(t)]=n[t];return e}function Qn(n,e,t=!0){return e.altKey&&(n="Alt-"+n),e.ctrlKey&&(n="Ctrl-"+n),e.metaKey&&(n="Meta-"+n),t&&e.shiftKey&&(n="Shift-"+n),n}function La(n){let e=Ia(n);return function(t,r){let o=Na(r),s,i=e[Qn(o,r)];if(i&&i(t.state,t.dispatch,t))return!0;if(o.length==1&&o!=" "){if(r.shiftKey){let l=e[Qn(o,r,!1)];if(l&&l(t.state,t.dispatch,t))return!0}if((r.shiftKey||r.altKey||r.metaKey||o.charCodeAt(0)>127)&&(s=Ne[r.keyCode])&&s!=o){let l=e[Qn(s,r)];if(l&&l(t.state,t.dispatch,t))return!0}}return!1}}const va=(n,e)=>n.selection.empty?!1:(e&&e(n.tr.deleteSelection().scrollIntoView()),!0);function di(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("backward",n):t.parentOffset>0)?null:t}const Pa=(n,e,t)=>{let r=di(n,t);if(!r)return!1;let o=_r(r);if(!o){let i=r.blockRange(),l=i&&rt(i);return l==null?!1:(e&&e(n.tr.lift(i,l).scrollIntoView()),!0)}let s=o.nodeBefore;if(!s.type.spec.isolating&&mi(n,o,e))return!0;if(r.parent.content.size==0&&(et(s,"end")||C.isSelectable(s))){let i=Rn(n.doc,r.before(),r.after(),S.empty);if(i&&i.slice.size<i.to-i.from){if(e){let l=n.tr.step(i);l.setSelection(et(s,"end")?x.findFrom(l.doc.resolve(l.mapping.map(o.pos,-1)),-1):C.create(l.doc,o.pos-s.nodeSize)),e(l.scrollIntoView())}return!0}}return s.isAtom&&o.depth==r.depth-1?(e&&e(n.tr.delete(o.pos-s.nodeSize,o.pos).scrollIntoView()),!0):!1},za=(n,e,t)=>{let r=di(n,t);if(!r)return!1;let o=_r(r);return o?fi(n,o,e):!1},Da=(n,e,t)=>{let r=hi(n,t);if(!r)return!1;let o=Gr(r);return o?fi(n,o,e):!1};function fi(n,e,t){let r=e.nodeBefore,o=r,s=e.pos-1;for(;!o.isTextblock;s--){if(o.type.spec.isolating)return!1;let u=o.lastChild;if(!u)return!1;o=u}let i=e.nodeAfter,l=i,a=e.pos+1;for(;!l.isTextblock;a++){if(l.type.spec.isolating)return!1;let u=l.firstChild;if(!u)return!1;l=u}let c=Rn(n.doc,s,a,S.empty);if(!c||c.from!=s||c instanceof $&&c.slice.size>=a-s)return!1;if(t){let u=n.tr.step(c);u.setSelection(w.create(u.doc,s)),t(u.scrollIntoView())}return!0}function et(n,e,t=!1){for(let r=n;r;r=e=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(t&&r.childCount!=1)return!1}return!1}const Ba=(n,e,t)=>{let{$head:r,empty:o}=n.selection,s=r;if(!o)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("backward",n):r.parentOffset>0)return!1;s=_r(r)}let i=s&&s.nodeBefore;return!i||!C.isSelectable(i)?!1:(e&&e(n.tr.setSelection(C.create(n.doc,s.pos-i.nodeSize)).scrollIntoView()),!0)};function _r(n){if(!n.parent.type.spec.isolating)for(let e=n.depth-1;e>=0;e--){if(n.index(e)>0)return n.doc.resolve(n.before(e+1));if(n.node(e).type.spec.isolating)break}return null}function hi(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("forward",n):t.parentOffset<t.parent.content.size)?null:t}const Ha=(n,e,t)=>{let r=hi(n,t);if(!r)return!1;let o=Gr(r);if(!o)return!1;let s=o.nodeAfter;if(mi(n,o,e))return!0;if(r.parent.content.size==0&&(et(s,"start")||C.isSelectable(s))){let i=Rn(n.doc,r.before(),r.after(),S.empty);if(i&&i.slice.size<i.to-i.from){if(e){let l=n.tr.step(i);l.setSelection(et(s,"start")?x.findFrom(l.doc.resolve(l.mapping.map(o.pos)),1):C.create(l.doc,l.mapping.map(o.pos))),e(l.scrollIntoView())}return!0}}return s.isAtom&&o.depth==r.depth-1?(e&&e(n.tr.delete(o.pos,o.pos+s.nodeSize).scrollIntoView()),!0):!1},$a=(n,e,t)=>{let{$head:r,empty:o}=n.selection,s=r;if(!o)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("forward",n):r.parentOffset<r.parent.content.size)return!1;s=Gr(r)}let i=s&&s.nodeAfter;return!i||!C.isSelectable(i)?!1:(e&&e(n.tr.setSelection(C.create(n.doc,s.pos)).scrollIntoView()),!0)};function Gr(n){if(!n.parent.type.spec.isolating)for(let e=n.depth-1;e>=0;e--){let t=n.node(e);if(n.index(e)+1<t.childCount)return n.doc.resolve(n.after(e+1));if(t.type.spec.isolating)break}return null}const Fa=(n,e)=>{let t=n.selection,r=t instanceof C,o;if(r){if(t.node.isTextblock||!Re(n.doc,t.from))return!1;o=t.from}else if(o=Nn(n.doc,t.from,-1),o==null)return!1;if(e){let s=n.tr.join(o);r&&s.setSelection(C.create(s.doc,o-n.doc.resolve(o).nodeBefore.nodeSize)),e(s.scrollIntoView())}return!0},ja=(n,e)=>{let t=n.selection,r;if(t instanceof C){if(t.node.isTextblock||!Re(n.doc,t.to))return!1;r=t.to}else if(r=Nn(n.doc,t.to,1),r==null)return!1;return e&&e(n.tr.join(r).scrollIntoView()),!0},Wa=(n,e)=>{let{$from:t,$to:r}=n.selection,o=t.blockRange(r),s=o&&rt(o);return s==null?!1:(e&&e(n.tr.lift(o,s).scrollIntoView()),!0)},Ka=(n,e)=>{let{$head:t,$anchor:r}=n.selection;return!t.parent.type.spec.code||!t.sameParent(r)?!1:(e&&e(n.tr.insertText(`
8
+ `).scrollIntoView()),!0)};function pi(n){for(let e=0;e<n.edgeCount;e++){let{type:t}=n.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}const Va=(n,e)=>{let{$head:t,$anchor:r}=n.selection;if(!t.parent.type.spec.code||!t.sameParent(r))return!1;let o=t.node(-1),s=t.indexAfter(-1),i=pi(o.contentMatchAt(s));if(!i||!o.canReplaceWith(s,s,i))return!1;if(e){let l=t.after(),a=n.tr.replaceWith(l,l,i.createAndFill());a.setSelection(x.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},qa=(n,e)=>{let t=n.selection,{$from:r,$to:o}=t;if(t instanceof oe||r.parent.inlineContent||o.parent.inlineContent)return!1;let s=pi(o.parent.contentMatchAt(o.indexAfter()));if(!s||!s.isTextblock)return!1;if(e){let i=(!r.parentOffset&&o.index()<o.parent.childCount?r:o).pos,l=n.tr.insert(i,s.createAndFill());l.setSelection(w.create(l.doc,i+1)),e(l.scrollIntoView())}return!0},Ja=(n,e)=>{let{$cursor:t}=n.selection;if(!t||t.parent.content.size)return!1;if(t.depth>1&&t.after()!=t.end(-1)){let s=t.before();if(Ge(n.doc,s))return e&&e(n.tr.split(s).scrollIntoView()),!0}let r=t.blockRange(),o=r&&rt(r);return o==null?!1:(e&&e(n.tr.lift(r,o).scrollIntoView()),!0)},Ua=(n,e)=>{let{$from:t,to:r}=n.selection,o,s=t.sharedDepth(r);return s==0?!1:(o=t.before(s),e&&e(n.tr.setSelection(C.create(n.doc,o))),!0)};function _a(n,e,t){let r=e.nodeBefore,o=e.nodeAfter,s=e.index();return!r||!o||!r.type.compatibleContent(o.type)?!1:!r.content.size&&e.parent.canReplace(s-1,s)?(t&&t(n.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(s,s+1)||!(o.isTextblock||Re(n.doc,e.pos))?!1:(t&&t(n.tr.clearIncompatible(e.pos,r.type,r.contentMatchAt(r.childCount)).join(e.pos).scrollIntoView()),!0)}function mi(n,e,t){let r=e.nodeBefore,o=e.nodeAfter,s,i;if(r.type.spec.isolating||o.type.spec.isolating)return!1;if(_a(n,e,t))return!0;let l=e.parent.canReplace(e.index(),e.index()+1);if(l&&(s=(i=r.contentMatchAt(r.childCount)).findWrapping(o.type))&&i.matchType(s[0]||o.type).validEnd){if(t){let d=e.pos+o.nodeSize,f=b.empty;for(let m=s.length-1;m>=0;m--)f=b.from(s[m].create(null,f));f=b.from(r.copy(f));let h=n.tr.step(new F(e.pos-1,d,e.pos,d,new S(f,1,0),s.length,!0)),p=d+2*s.length;Re(h.doc,p)&&h.join(p),t(h.scrollIntoView())}return!0}let a=x.findFrom(e,1),c=a&&a.$from.blockRange(a.$to),u=c&&rt(c);if(u!=null&&u>=e.depth)return t&&t(n.tr.lift(c,u).scrollIntoView()),!0;if(l&&et(o,"start",!0)&&et(r,"end")){let d=r,f=[];for(;f.push(d),!d.isTextblock;)d=d.lastChild;let h=o,p=1;for(;!h.isTextblock;h=h.firstChild)p++;if(d.canReplace(d.childCount,d.childCount,h.content)){if(t){let m=b.empty;for(let y=f.length-1;y>=0;y--)m=b.from(f[y].copy(m));let g=n.tr.step(new F(e.pos-f.length,e.pos+o.nodeSize,e.pos+p,e.pos+o.nodeSize-p,new S(m,f.length,0),0,!0));t(g.scrollIntoView())}return!0}}return!1}function gi(n){return function(e,t){let r=e.selection,o=n<0?r.$from:r.$to,s=o.depth;for(;o.node(s).isInline;){if(!s)return!1;s--}return o.node(s).isTextblock?(t&&t(e.tr.setSelection(w.create(e.doc,n<0?o.start(s):o.end(s)))),!0):!1}}const Ga=gi(-1),Qa=gi(1);function Xa(n,e=null){return function(t,r){let{$from:o,$to:s}=t.selection,i=o.blockRange(s),l=i&&Hr(i,n,e);return l?(r&&r(t.tr.wrap(i,l).scrollIntoView()),!0):!1}}function $o(n,e=null){return function(t,r){let o=!1;for(let s=0;s<t.selection.ranges.length&&!o;s++){let{$from:{pos:i},$to:{pos:l}}=t.selection.ranges[s];t.doc.nodesBetween(i,l,(a,c)=>{if(o)return!1;if(!(!a.isTextblock||a.hasMarkup(n,e)))if(a.type==n)o=!0;else{let u=t.doc.resolve(c),d=u.index();o=u.parent.canReplaceWith(d,d+1,n)}})}if(!o)return!1;if(r){let s=t.tr;for(let i=0;i<t.selection.ranges.length;i++){let{$from:{pos:l},$to:{pos:a}}=t.selection.ranges[i];s.setBlockType(l,a,n,e)}r(s.scrollIntoView())}return!0}}typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform()=="darwin";function Ya(n,e=null){return function(t,r){let{$from:o,$to:s}=t.selection,i=o.blockRange(s),l=!1,a=i;if(!i)return!1;if(i.depth>=2&&o.node(i.depth-1).type.compatibleContent(n)&&i.startIndex==0){if(o.index(i.depth-1)==0)return!1;let u=t.doc.resolve(i.start-2);a=new fr(u,u,i.depth),i.endIndex<i.parent.childCount&&(i=new fr(o,t.doc.resolve(s.end(i.depth)),i.depth)),l=!0}let c=Hr(a,n,e,i);return c?(r&&r(Za(t.tr,i,c,l,n).scrollIntoView()),!0):!1}}function Za(n,e,t,r,o){let s=b.empty;for(let u=t.length-1;u>=0;u--)s=b.from(t[u].type.create(t[u].attrs,s));n.step(new F(e.start-(r?2:0),e.end,e.start,e.end,new S(s,0,0),t.length,!0));let i=0;for(let u=0;u<t.length;u++)t[u].type==o&&(i=u+1);let l=t.length-i,a=e.start+t.length-(r?2:0),c=e.parent;for(let u=e.startIndex,d=e.endIndex,f=!0;u<d;u++,f=!1)!f&&Ge(n.doc,a,l)&&(n.split(a,l),a+=2*l),a+=c.child(u).nodeSize;return n}function ec(n){return function(e,t){let{$from:r,$to:o}=e.selection,s=r.blockRange(o,i=>i.childCount>0&&i.firstChild.type==n);return s?t?r.node(s.depth-1).type==n?tc(e,t,n,s):nc(e,t,s):!0:!1}}function tc(n,e,t,r){let o=n.tr,s=r.end,i=r.$to.end(r.depth);s<i&&(o.step(new F(s-1,i,s,i,new S(b.from(t.create(null,r.parent.copy())),1,0),1,!0)),r=new fr(o.doc.resolve(r.$from.pos),o.doc.resolve(i),r.depth));const l=rt(r);if(l==null)return!1;o.lift(r,l);let a=o.mapping.map(s,-1)-1;return Re(o.doc,a)&&o.join(a),e(o.scrollIntoView()),!0}function nc(n,e,t){let r=n.tr,o=t.parent;for(let h=t.end,p=t.endIndex-1,m=t.startIndex;p>m;p--)h-=o.child(p).nodeSize,r.delete(h-1,h+1);let s=r.doc.resolve(t.start),i=s.nodeAfter;if(r.mapping.map(t.end)!=t.start+s.nodeAfter.nodeSize)return!1;let l=t.startIndex==0,a=t.endIndex==o.childCount,c=s.node(-1),u=s.index(-1);if(!c.canReplace(u+(l?0:1),u+1,i.content.append(a?b.empty:b.from(o))))return!1;let d=s.pos,f=d+i.nodeSize;return r.step(new F(d-(l?1:0),f+(a?1:0),d+1,f-1,new S((l?b.empty:b.from(o.copy(b.empty))).append(a?b.empty:b.from(o.copy(b.empty))),l?0:1,a?0:1),l?0:1)),e(r.scrollIntoView()),!0}function rc(n){return function(e,t){let{$from:r,$to:o}=e.selection,s=r.blockRange(o,c=>c.childCount>0&&c.firstChild.type==n);if(!s)return!1;let i=s.startIndex;if(i==0)return!1;let l=s.parent,a=l.child(i-1);if(a.type!=n)return!1;if(t){let c=a.lastChild&&a.lastChild.type==l.type,u=b.from(c?n.create():null),d=new S(b.from(n.create(null,b.from(l.type.create(null,u)))),c?3:1,0),f=s.start,h=s.end;t(e.tr.step(new F(f-(c?3:1),h,f,h,d,1,!0)).scrollIntoView())}return!0}}function yi(n){const{state:e,transaction:t}=n;let{selection:r}=t,{doc:o}=t,{storedMarks:s}=t;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return s},get selection(){return r},get doc(){return o},get tr(){return r=t.selection,o=t.doc,s=t.storedMarks,t}}}class oc{constructor(e){this.editor=e.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=e.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:e,editor:t,state:r}=this,{view:o}=t,{tr:s}=r,i=this.buildProps(s);return Object.fromEntries(Object.entries(e).map(([l,a])=>[l,(...u)=>{const d=a(...u)(i);return!s.getMeta("preventDispatch")&&!this.hasCustomState&&o.dispatch(s),d}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(e,t=!0){const{rawCommands:r,editor:o,state:s}=this,{view:i}=o,l=[],a=!!e,c=e||s.tr,u=()=>(!a&&t&&!c.getMeta("preventDispatch")&&!this.hasCustomState&&i.dispatch(c),l.every(f=>f===!0)),d={...Object.fromEntries(Object.entries(r).map(([f,h])=>[f,(...m)=>{const g=this.buildProps(c,t),y=h(...m)(g);return l.push(y),d}])),run:u};return d}createCan(e){const{rawCommands:t,state:r}=this,o=!1,s=e||r.tr,i=this.buildProps(s,o);return{...Object.fromEntries(Object.entries(t).map(([a,c])=>[a,(...u)=>c(...u)({...i,dispatch:void 0})])),chain:()=>this.createChain(s,o)}}buildProps(e,t=!0){const{rawCommands:r,editor:o,state:s}=this,{view:i}=o,l={tr:e,editor:o,view:i,state:yi({state:s,transaction:e}),dispatch:t?()=>{}:void 0,chain:()=>this.createChain(e,t),can:()=>this.createCan(e),get commands(){return Object.fromEntries(Object.entries(r).map(([a,c])=>[a,(...u)=>c(...u)(l)]))}};return l}}function H(n,e,t){return n.config[e]===void 0&&n.parent?H(n.parent,e,t):typeof n.config[e]=="function"?n.config[e].bind({...t,parent:n.parent?H(n.parent,e,t):null}):n.config[e]}function sc(n){const e=n.filter(o=>o.type==="extension"),t=n.filter(o=>o.type==="node"),r=n.filter(o=>o.type==="mark");return{baseExtensions:e,nodeExtensions:t,markExtensions:r}}function W(n,e){if(typeof n=="string"){if(!e.nodes[n])throw Error(`There is no node type named '${n}'. Maybe you forgot to add the extension?`);return e.nodes[n]}return n}function O(...n){return n.filter(e=>!!e).reduce((e,t)=>{const r={...e};return Object.entries(t).forEach(([o,s])=>{if(!r[o]){r[o]=s;return}if(o==="class"){const l=s?s.split(" "):[],a=r[o]?r[o].split(" "):[],c=l.filter(u=>!a.includes(u));r[o]=[...a,...c].join(" ")}else o==="style"?r[o]=[r[o],s].join("; "):r[o]=s}),r},{})}function ic(n){return typeof n=="function"}function v(n,e=void 0,...t){return ic(n)?e?n.bind(e)(...t):n(...t):n}function lc(n){return Object.prototype.toString.call(n)==="[object RegExp]"}class vn{constructor(e){this.find=e.find,this.handler=e.handler}}class ac{constructor(e){this.find=e.find,this.handler=e.handler}}function cc(n){return Object.prototype.toString.call(n).slice(8,-1)}function Xn(n){return cc(n)!=="Object"?!1:n.constructor===Object&&Object.getPrototypeOf(n)===Object.prototype}function Pn(n,e){const t={...n};return Xn(n)&&Xn(e)&&Object.keys(e).forEach(r=>{Xn(e[r])?r in n?t[r]=Pn(n[r],e[r]):Object.assign(t,{[r]:e[r]}):Object.assign(t,{[r]:e[r]})}),t}class me{constructor(e={}){this.type="extension",this.name="extension",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=v(H(this,"addOptions",{name:this.name}))),this.storage=v(H(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new me(e)}configure(e={}){const t=this.extend();return t.parent=this.parent,t.options=Pn(this.options,e),t.storage=v(H(t,"addStorage",{name:t.name,options:t.options})),t}extend(e={}){const t=new me({...this.config,...e});return t.parent=this,this.child=t,t.name=e.name?e.name:t.parent.name,e.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${t.name}".`),t.options=v(H(t,"addOptions",{name:t.name})),t.storage=v(H(t,"addStorage",{name:t.name,options:t.options})),t}}function uc(n,e,t){const{from:r,to:o}=e,{blockSeparator:s=`
9
9
 
10
- `,textSerializers:i={}}=t||{};let l="";return n.nodesBetween(r,o,(a,c,u,d)=>{var f;a.isBlock&&c>r&&(l+=s);const h=i==null?void 0:i[a.type.name];if(h)return u&&(l+=h({node:a,pos:c,parent:u,index:d,range:e})),!1;a.isText&&(l+=(f=a==null?void 0:a.text)===null||f===void 0?void 0:f.slice(Math.max(r,c)-c,o-c))}),l}function dc(n){return Object.fromEntries(Object.entries(n.nodes).filter(([,e])=>e.spec.toText).map(([e,t])=>[e,t.spec.toText]))}me.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new ie({key:new te("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:n}=this,{state:e,schema:t}=n,{doc:r,selection:o}=e,{ranges:s}=o,i=Math.min(...s.map(u=>u.$from.pos)),l=Math.max(...s.map(u=>u.$to.pos)),a=dc(t);return uc(r,{from:i,to:l},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:a})}}})]}});const fc=()=>({editor:n,view:e})=>(requestAnimationFrame(()=>{var t;n.isDestroyed||(e.dom.blur(),(t=window==null?void 0:window.getSelection())===null||t===void 0||t.removeAllRanges())}),!0),hc=(n=!1)=>({commands:e})=>e.setContent("",n),pc=()=>({state:n,tr:e,dispatch:t})=>{const{selection:r}=e,{ranges:o}=r;return t&&o.forEach(({$from:s,$to:i})=>{n.doc.nodesBetween(s.pos,i.pos,(l,a)=>{if(l.type.isText)return;const{doc:c,mapping:u}=e,d=c.resolve(u.map(a)),f=c.resolve(u.map(a+l.nodeSize)),h=d.blockRange(f);if(!h)return;const p=rt(h);if(l.type.isTextblock){const{defaultType:m}=d.parent.contentMatchAt(d.index());e.setNodeMarkup(h.start,m)}(p||p===0)&&e.lift(h,p)})}),!0},mc=n=>e=>n(e),gc=()=>({state:n,dispatch:e})=>qa(n,e),yc=(n,e)=>({editor:t,tr:r})=>{const{state:o}=t,s=o.doc.slice(n.from,n.to);r.deleteRange(n.from,n.to);const i=r.mapping.map(e);return r.insert(i,s.content),r.setSelection(new w(r.doc.resolve(i-1))),!0},bc=()=>({tr:n,dispatch:e})=>{const{selection:t}=n,r=t.$anchor.node();if(r.content.size>0)return!1;const o=n.selection.$anchor;for(let s=o.depth;s>0;s-=1)if(o.node(s).type===r.type){if(e){const l=o.before(s),a=o.after(s);n.delete(l,a).scrollIntoView()}return!0}return!1},kc=n=>({tr:e,state:t,dispatch:r})=>{const o=W(n,t.schema),s=e.selection.$anchor;for(let i=s.depth;i>0;i-=1)if(s.node(i).type===o){if(r){const a=s.before(i),c=s.after(i);e.delete(a,c).scrollIntoView()}return!0}return!1},Sc=n=>({tr:e,dispatch:t})=>{const{from:r,to:o}=n;return t&&e.delete(r,o),!0},Cc=()=>({state:n,dispatch:e})=>va(n,e),wc=()=>({commands:n})=>n.keyboardShortcut("Enter"),xc=()=>({state:n,dispatch:e})=>Va(n,e);function Qt(n,e,t={strict:!0}){const r=Object.keys(e);return r.length?r.every(o=>t.strict?e[o]===n[o]:lc(e[o])?e[o].test(n[o]):e[o]===n[o]):!0}function wr(n,e,t={}){return n.find(r=>r.type===e&&Qt(r.attrs,t))}function Tc(n,e,t={}){return!!wr(n,e,t)}function Qr(n,e,t={}){if(!n||!e)return;let r=n.parent.childAfter(n.parentOffset);if(n.parentOffset===r.offset&&r.offset!==0&&(r=n.parent.childBefore(n.parentOffset)),!r.node)return;const o=wr([...r.node.marks],e,t);if(!o)return;let s=r.index,i=n.start()+r.offset,l=s+1,a=i+r.node.nodeSize;for(wr([...r.node.marks],e,t);s>0&&o.isInSet(n.parent.child(s-1).marks);)s-=1,i-=n.parent.child(s).nodeSize;for(;l<n.parent.childCount&&Tc([...n.parent.child(l).marks],e,t);)a+=n.parent.child(l).nodeSize,l+=1;return{from:i,to:a}}function Ie(n,e){if(typeof n=="string"){if(!e.marks[n])throw Error(`There is no mark type named '${n}'. Maybe you forgot to add the extension?`);return e.marks[n]}return n}const Ac=(n,e={})=>({tr:t,state:r,dispatch:o})=>{const s=Ie(n,r.schema),{doc:i,selection:l}=t,{$from:a,from:c,to:u}=l;if(o){const d=Qr(a,s,e);if(d&&d.from<=c&&d.to>=u){const f=w.create(i,d.from,d.to);t.setSelection(f)}}return!0},Mc=n=>e=>{const t=typeof n=="function"?n(e):n;for(let r=0;r<t.length;r+=1)if(t[r](e))return!0;return!1};function bi(n){return n instanceof w}function Pe(n=0,e=0,t=0){return Math.min(Math.max(n,e),t)}function Ec(n,e=null){if(!e)return null;const t=x.atStart(n),r=x.atEnd(n);if(e==="start"||e===!0)return t;if(e==="end")return r;const o=t.from,s=r.to;return e==="all"?w.create(n,Pe(0,o,s),Pe(n.content.size,o,s)):w.create(n,Pe(e,o,s),Pe(e,o,s))}function Xr(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}const Nc=(n=null,e={})=>({editor:t,view:r,tr:o,dispatch:s})=>{e={scrollIntoView:!0,...e};const i=()=>{Xr()&&r.dom.focus(),requestAnimationFrame(()=>{t.isDestroyed||(r.focus(),e!=null&&e.scrollIntoView&&t.commands.scrollIntoView())})};if(r.hasFocus()&&n===null||n===!1)return!0;if(s&&n===null&&!bi(t.state.selection))return i(),!0;const l=Ec(o.doc,n)||t.state.selection,a=t.state.selection.eq(l);return s&&(a||o.setSelection(l),a&&o.storedMarks&&o.setStoredMarks(o.storedMarks),i()),!0},Rc=(n,e)=>t=>n.every((r,o)=>e(r,{...t,index:o})),Oc=(n,e)=>({tr:t,commands:r})=>r.insertContentAt({from:t.selection.from,to:t.selection.to},n,e),ki=n=>{const e=n.childNodes;for(let t=e.length-1;t>=0;t-=1){const r=e[t];r.nodeType===3&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?n.removeChild(r):r.nodeType===1&&ki(r)}return n};function Fo(n){const e=`<body>${n}</body>`,t=new window.DOMParser().parseFromString(e,"text/html").body;return ki(t)}function Xt(n,e,t){t={slice:!0,parseOptions:{},...t};const r=typeof n=="object"&&n!==null,o=typeof n=="string";if(r)try{return Array.isArray(n)&&n.length>0?b.fromArray(n.map(i=>e.nodeFromJSON(i))):e.nodeFromJSON(n)}catch(s){return console.warn("[tiptap warn]: Invalid content.","Passed value:",n,"Error:",s),Xt("",e,t)}if(o){const s=pt.fromSchema(e);return t.slice?s.parseSlice(Fo(n),t.parseOptions).content:s.parse(Fo(n),t.parseOptions)}return Xt("",e,t)}function Ic(n,e,t){const r=n.steps.length-1;if(r<e)return;const o=n.steps[r];if(!(o instanceof $||o instanceof F))return;const s=n.mapping.maps[r];let i=0;s.forEach((l,a,c,u)=>{i===0&&(i=u)}),n.setSelection(x.near(n.doc.resolve(i),t))}const Lc=n=>n.toString().startsWith("<"),vc=(n,e,t)=>({tr:r,dispatch:o,editor:s})=>{if(o){t={parseOptions:{},updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...t};const i=Xt(e,s.schema,{parseOptions:{preserveWhitespace:"full",...t.parseOptions}});if(i.toString()==="<>")return!0;let{from:l,to:a}=typeof n=="number"?{from:n,to:n}:{from:n.from,to:n.to},c=!0,u=!0;if((Lc(i)?i:[i]).forEach(h=>{h.check(),c=c?h.isText&&h.marks.length===0:!1,u=u?h.isBlock:!1}),l===a&&u){const{parent:h}=r.doc.resolve(l);h.isTextblock&&!h.type.spec.code&&!h.childCount&&(l-=1,a+=1)}let f;c?(Array.isArray(e)?f=e.map(h=>h.text||"").join(""):typeof e=="object"&&e&&e.text?f=e.text:f=e,r.insertText(f,l,a)):(f=i,r.replaceWith(l,a,f)),t.updateSelection&&Ic(r,r.steps.length-1,-1),t.applyInputRules&&r.setMeta("applyInputRules",{from:l,text:f}),t.applyPasteRules&&r.setMeta("applyPasteRules",{from:l,text:f})}return!0},Pc=()=>({state:n,dispatch:e})=>Fa(n,e),zc=()=>({state:n,dispatch:e})=>ja(n,e),Dc=()=>({state:n,dispatch:e})=>Pa(n,e),Bc=()=>({state:n,dispatch:e})=>Ha(n,e),Hc=()=>({tr:n,state:e,dispatch:t})=>{try{const r=Nn(e.doc,e.selection.$from.pos,-1);return r==null?!1:(n.join(r,2),t&&t(n),!0)}catch{return!1}},$c=()=>({state:n,dispatch:e,tr:t})=>{try{const r=Nn(n.doc,n.selection.$from.pos,1);return r==null?!1:(t.join(r,2),e&&e(t),!0)}catch{return!1}},Fc=()=>({state:n,dispatch:e})=>za(n,e),jc=()=>({state:n,dispatch:e})=>Da(n,e);function Si(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function Wc(n){const e=n.split(/-(?!$)/);let t=e[e.length-1];t==="Space"&&(t=" ");let r,o,s,i;for(let l=0;l<e.length-1;l+=1){const a=e[l];if(/^(cmd|meta|m)$/i.test(a))i=!0;else if(/^a(lt)?$/i.test(a))r=!0;else if(/^(c|ctrl|control)$/i.test(a))o=!0;else if(/^s(hift)?$/i.test(a))s=!0;else if(/^mod$/i.test(a))Xr()||Si()?i=!0:o=!0;else throw new Error(`Unrecognized modifier name: ${a}`)}return r&&(t=`Alt-${t}`),o&&(t=`Ctrl-${t}`),i&&(t=`Meta-${t}`),s&&(t=`Shift-${t}`),t}const Kc=n=>({editor:e,view:t,tr:r,dispatch:o})=>{const s=Wc(n).split(/-(?!$)/),i=s.find(c=>!["Alt","Ctrl","Meta","Shift"].includes(c)),l=new KeyboardEvent("keydown",{key:i==="Space"?" ":i,altKey:s.includes("Alt"),ctrlKey:s.includes("Ctrl"),metaKey:s.includes("Meta"),shiftKey:s.includes("Shift"),bubbles:!0,cancelable:!0}),a=e.captureTransaction(()=>{t.someProp("handleKeyDown",c=>c(t,l))});return a==null||a.steps.forEach(c=>{const u=c.map(r.mapping);u&&o&&r.maybeStep(u)}),!0};function Yr(n,e,t={}){const{from:r,to:o,empty:s}=n.selection,i=e?W(e,n.schema):null,l=[];n.doc.nodesBetween(r,o,(d,f)=>{if(d.isText)return;const h=Math.max(r,f),p=Math.min(o,f+d.nodeSize);l.push({node:d,from:h,to:p})});const a=o-r,c=l.filter(d=>i?i.name===d.node.type.name:!0).filter(d=>Qt(d.node.attrs,t,{strict:!1}));return s?!!c.length:c.reduce((d,f)=>d+f.to-f.from,0)>=a}const Vc=(n,e={})=>({state:t,dispatch:r})=>{const o=W(n,t.schema);return Yr(t,o,e)?Wa(t,r):!1},qc=()=>({state:n,dispatch:e})=>Ja(n,e),Jc=n=>({state:e,dispatch:t})=>{const r=W(n,e.schema);return ec(r)(e,t)},Uc=()=>({state:n,dispatch:e})=>Ka(n,e);function Zr(n,e){return e.nodes[n]?"node":e.marks[n]?"mark":null}function jo(n,e){const t=typeof e=="string"?[e]:e;return Object.keys(n).reduce((r,o)=>(t.includes(o)||(r[o]=n[o]),r),{})}const _c=(n,e)=>({tr:t,state:r,dispatch:o})=>{let s=null,i=null;const l=Zr(typeof n=="string"?n:n.name,r.schema);return l?(l==="node"&&(s=W(n,r.schema)),l==="mark"&&(i=Ie(n,r.schema)),o&&t.selection.ranges.forEach(a=>{r.doc.nodesBetween(a.$from.pos,a.$to.pos,(c,u)=>{s&&s===c.type&&t.setNodeMarkup(u,void 0,jo(c.attrs,e)),i&&c.marks.length&&c.marks.forEach(d=>{i===d.type&&t.addMark(u,u+c.nodeSize,i.create(jo(d.attrs,e)))})})}),!0):!1},Gc=()=>({tr:n,dispatch:e})=>(e&&n.scrollIntoView(),!0),Qc=()=>({tr:n,commands:e})=>e.setTextSelection({from:0,to:n.doc.content.size}),Xc=()=>({state:n,dispatch:e})=>Ba(n,e),Yc=()=>({state:n,dispatch:e})=>$a(n,e),Zc=()=>({state:n,dispatch:e})=>Ua(n,e),eu=()=>({state:n,dispatch:e})=>Qa(n,e),tu=()=>({state:n,dispatch:e})=>Ga(n,e);function nu(n,e,t={}){return Xt(n,e,{slice:!1,parseOptions:t})}const ru=(n,e=!1,t={})=>({tr:r,editor:o,dispatch:s})=>{const{doc:i}=r,l=nu(n,o.schema,t);return s&&r.replaceWith(0,i.content.size,l).setMeta("preventUpdate",!e),!0};function zn(n,e){const t=Ie(e,n.schema),{from:r,to:o,empty:s}=n.selection,i=[];s?(n.storedMarks&&i.push(...n.storedMarks),i.push(...n.selection.$head.marks())):n.doc.nodesBetween(r,o,a=>{i.push(...a.marks)});const l=i.find(a=>a.type.name===t.name);return l?{...l.attrs}:{}}function ou(n,e){const t=new Hs(n);return e.forEach(r=>{r.steps.forEach(o=>{t.step(o)})}),t}function su(n){for(let e=0;e<n.edgeCount;e+=1){const{type:t}=n.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}function iu(n,e,t){const r=[];return n.nodesBetween(e.from,e.to,(o,s)=>{t(o)&&r.push({node:o,pos:s})}),r}function Ci(n,e){for(let t=n.depth;t>0;t-=1){const r=n.node(t);if(e(r))return{pos:t>0?n.before(t):0,start:n.start(t),depth:t,node:r}}}function eo(n){return e=>Ci(e.$from,n)}function lu(n,e){const t=W(e,n.schema),{from:r,to:o}=n.selection,s=[];n.doc.nodesBetween(r,o,l=>{s.push(l)});const i=s.reverse().find(l=>l.type.name===t.name);return i?{...i.attrs}:{}}function au(n,e){const t=Zr(typeof e=="string"?e:e.name,n.schema);return t==="node"?lu(n,e):t==="mark"?zn(n,e):{}}function cu(n,e=JSON.stringify){const t={};return n.filter(r=>{const o=e(r);return Object.prototype.hasOwnProperty.call(t,o)?!1:t[o]=!0})}function uu(n){const e=cu(n);return e.length===1?e:e.filter((t,r)=>!e.filter((s,i)=>i!==r).some(s=>t.oldRange.from>=s.oldRange.from&&t.oldRange.to<=s.oldRange.to&&t.newRange.from>=s.newRange.from&&t.newRange.to<=s.newRange.to))}function du(n){const{mapping:e,steps:t}=n,r=[];return e.maps.forEach((o,s)=>{const i=[];if(o.ranges.length)o.forEach((l,a)=>{i.push({from:l,to:a})});else{const{from:l,to:a}=t[s];if(l===void 0||a===void 0)return;i.push({from:l,to:a})}i.forEach(({from:l,to:a})=>{const c=e.slice(s).map(l,-1),u=e.slice(s).map(a),d=e.invert().map(c,-1),f=e.invert().map(u);r.push({oldRange:{from:d,to:f},newRange:{from:c,to:u}})})}),uu(r)}function to(n,e,t){const r=[];return n===e?t.resolve(n).marks().forEach(o=>{const s=t.resolve(n-1),i=Qr(s,o.type);i&&r.push({mark:o,...i})}):t.nodesBetween(n,e,(o,s)=>{!o||(o==null?void 0:o.nodeSize)===void 0||r.push(...o.marks.map(i=>({from:s,to:s+o.nodeSize,mark:i})))}),r}function Bt(n,e,t){return Object.fromEntries(Object.entries(t).filter(([r])=>{const o=n.find(s=>s.type===e&&s.name===r);return o?o.attribute.keepOnSplit:!1}))}function fu(n,e,t={}){const{empty:r,ranges:o}=n.selection,s=e?Ie(e,n.schema):null;if(r)return!!(n.storedMarks||n.selection.$from.marks()).filter(d=>s?s.name===d.type.name:!0).find(d=>Qt(d.attrs,t,{strict:!1}));let i=0;const l=[];if(o.forEach(({$from:d,$to:f})=>{const h=d.pos,p=f.pos;n.doc.nodesBetween(h,p,(m,g)=>{if(!m.isText&&!m.marks.length)return;const y=Math.max(h,g),M=Math.min(p,g+m.nodeSize),A=M-y;i+=A,l.push(...m.marks.map(J=>({mark:J,from:y,to:M})))})}),i===0)return!1;const a=l.filter(d=>s?s.name===d.mark.type.name:!0).filter(d=>Qt(d.mark.attrs,t,{strict:!1})).reduce((d,f)=>d+f.to-f.from,0),c=l.filter(d=>s?d.mark.type!==s&&d.mark.type.excludes(s):!0).reduce((d,f)=>d+f.to-f.from,0);return(a>0?a+c:a)>=i}function Wo(n,e){const{nodeExtensions:t}=sc(e),r=t.find(i=>i.name===n);if(!r)return!1;const o={name:r.name,options:r.options,storage:r.storage},s=v(H(r,"group",o));return typeof s!="string"?!1:s.split(" ").includes("list")}function hu(n,e,t){var r;const{selection:o}=e;let s=null;if(bi(o)&&(s=o.$cursor),s){const l=(r=n.storedMarks)!==null&&r!==void 0?r:s.marks();return!!t.isInSet(l)||!l.some(a=>a.type.excludes(t))}const{ranges:i}=o;return i.some(({$from:l,$to:a})=>{let c=l.depth===0?n.doc.inlineContent&&n.doc.type.allowsMarkType(t):!1;return n.doc.nodesBetween(l.pos,a.pos,(u,d,f)=>{if(c)return!1;if(u.isInline){const h=!f||f.type.allowsMarkType(t),p=!!t.isInSet(u.marks)||!u.marks.some(m=>m.type.excludes(t));c=h&&p}return!c}),c})}const pu=(n,e={})=>({tr:t,state:r,dispatch:o})=>{const{selection:s}=t,{empty:i,ranges:l}=s,a=Ie(n,r.schema);if(o)if(i){const c=zn(r,a);t.addStoredMark(a.create({...c,...e}))}else l.forEach(c=>{const u=c.$from.pos,d=c.$to.pos;r.doc.nodesBetween(u,d,(f,h)=>{const p=Math.max(h,u),m=Math.min(h+f.nodeSize,d);f.marks.find(y=>y.type===a)?f.marks.forEach(y=>{a===y.type&&t.addMark(p,m,a.create({...y.attrs,...e}))}):t.addMark(p,m,a.create(e))})});return hu(r,t,a)},mu=(n,e)=>({tr:t})=>(t.setMeta(n,e),!0),gu=(n,e={})=>({state:t,dispatch:r,chain:o})=>{const s=W(n,t.schema);return s.isTextblock?o().command(({commands:i})=>$o(s,e)(t)?!0:i.clearNodes()).command(({state:i})=>$o(s,e)(i,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},yu=n=>({tr:e,dispatch:t})=>{if(t){const{doc:r}=e,o=Pe(n,0,r.content.size),s=C.create(r,o);e.setSelection(s)}return!0},bu=n=>({tr:e,dispatch:t})=>{if(t){const{doc:r}=e,{from:o,to:s}=typeof n=="number"?{from:n,to:n}:n,i=w.atStart(r).from,l=w.atEnd(r).to,a=Pe(o,i,l),c=Pe(s,i,l),u=w.create(r,a,c);e.setSelection(u)}return!0},ku=n=>({state:e,dispatch:t})=>{const r=W(n,e.schema);return rc(r)(e,t)};function Ko(n,e){const t=n.storedMarks||n.selection.$to.parentOffset&&n.selection.$from.marks();if(t){const r=t.filter(o=>e==null?void 0:e.includes(o.type.name));n.tr.ensureMarks(r)}}const Su=({keepMarks:n=!0}={})=>({tr:e,state:t,dispatch:r,editor:o})=>{const{selection:s,doc:i}=e,{$from:l,$to:a}=s,c=o.extensionManager.attributes,u=Bt(c,l.node().type.name,l.node().attrs);if(s instanceof C&&s.node.isBlock)return!l.parentOffset||!Ge(i,l.pos)?!1:(r&&(n&&Ko(t,o.extensionManager.splittableMarks),e.split(l.pos).scrollIntoView()),!0);if(!l.parent.isBlock)return!1;if(r){const d=a.parentOffset===a.parent.content.size;s instanceof w&&e.deleteSelection();const f=l.depth===0?void 0:su(l.node(-1).contentMatchAt(l.indexAfter(-1)));let h=d&&f?[{type:f,attrs:u}]:void 0,p=Ge(e.doc,e.mapping.map(l.pos),1,h);if(!h&&!p&&Ge(e.doc,e.mapping.map(l.pos),1,f?[{type:f}]:void 0)&&(p=!0,h=f?[{type:f,attrs:u}]:void 0),p&&(e.split(e.mapping.map(l.pos),1,h),f&&!d&&!l.parentOffset&&l.parent.type!==f)){const m=e.mapping.map(l.before()),g=e.doc.resolve(m);l.node(-1).canReplaceWith(g.index(),g.index()+1,f)&&e.setNodeMarkup(e.mapping.map(l.before()),f)}n&&Ko(t,o.extensionManager.splittableMarks),e.scrollIntoView()}return!0},Cu=n=>({tr:e,state:t,dispatch:r,editor:o})=>{var s;const i=W(n,t.schema),{$from:l,$to:a}=t.selection,c=t.selection.node;if(c&&c.isBlock||l.depth<2||!l.sameParent(a))return!1;const u=l.node(-1);if(u.type!==i)return!1;const d=o.extensionManager.attributes;if(l.parent.content.size===0&&l.node(-1).childCount===l.indexAfter(-1)){if(l.depth===2||l.node(-3).type!==i||l.index(-2)!==l.node(-2).childCount-1)return!1;if(r){let g=b.empty;const y=l.index(-1)?1:l.index(-2)?2:3;for(let z=l.depth-y;z>=l.depth-3;z-=1)g=b.from(l.node(z).copy(g));const M=l.indexAfter(-1)<l.node(-2).childCount?1:l.indexAfter(-2)<l.node(-3).childCount?2:3,A=Bt(d,l.node().type.name,l.node().attrs),J=((s=i.contentMatch.defaultType)===null||s===void 0?void 0:s.createAndFill(A))||void 0;g=g.append(b.from(i.createAndFill(null,J)||void 0));const I=l.before(l.depth-(y-1));e.replace(I,l.after(-M),new S(g,4-y,0));let E=-1;e.doc.nodesBetween(I,e.doc.content.size,(z,ce)=>{if(E>-1)return!1;z.isTextblock&&z.content.size===0&&(E=ce+1)}),E>-1&&e.setSelection(w.near(e.doc.resolve(E))),e.scrollIntoView()}return!0}const f=a.pos===l.end()?u.contentMatchAt(0).defaultType:null,h=Bt(d,u.type.name,u.attrs),p=Bt(d,l.node().type.name,l.node().attrs);e.delete(l.pos,a.pos);const m=f?[{type:i,attrs:h},{type:f,attrs:p}]:[{type:i,attrs:h}];if(!Ge(e.doc,l.pos,2))return!1;if(r){const{selection:g,storedMarks:y}=t,{splittableMarks:M}=o.extensionManager,A=y||g.$to.parentOffset&&g.$from.marks();if(e.split(l.pos,2,m).scrollIntoView(),!A||!r)return!0;const J=A.filter(I=>M.includes(I.type.name));e.ensureMarks(J)}return!0},Yn=(n,e)=>{const t=eo(i=>i.type===e)(n.selection);if(!t)return!0;const r=n.doc.resolve(Math.max(0,t.pos-1)).before(t.depth);if(r===void 0)return!0;const o=n.doc.nodeAt(r);return t.node.type===(o==null?void 0:o.type)&&Re(n.doc,t.pos)&&n.join(t.pos),!0},Zn=(n,e)=>{const t=eo(i=>i.type===e)(n.selection);if(!t)return!0;const r=n.doc.resolve(t.start).after(t.depth);if(r===void 0)return!0;const o=n.doc.nodeAt(r);return t.node.type===(o==null?void 0:o.type)&&Re(n.doc,r)&&n.join(r),!0},wu=(n,e,t,r={})=>({editor:o,tr:s,state:i,dispatch:l,chain:a,commands:c,can:u})=>{const{extensions:d,splittableMarks:f}=o.extensionManager,h=W(n,i.schema),p=W(e,i.schema),{selection:m,storedMarks:g}=i,{$from:y,$to:M}=m,A=y.blockRange(M),J=g||m.$to.parentOffset&&m.$from.marks();if(!A)return!1;const I=eo(E=>Wo(E.type.name,d))(m);if(A.depth>=1&&I&&A.depth-I.depth<=1){if(I.node.type===h)return c.liftListItem(p);if(Wo(I.node.type.name,d)&&h.validContent(I.node.content)&&l)return a().command(()=>(s.setNodeMarkup(I.pos,h),!0)).command(()=>Yn(s,h)).command(()=>Zn(s,h)).run()}return!t||!J||!l?a().command(()=>u().wrapInList(h,r)?!0:c.clearNodes()).wrapInList(h,r).command(()=>Yn(s,h)).command(()=>Zn(s,h)).run():a().command(()=>{const E=u().wrapInList(h,r),z=J.filter(ce=>f.includes(ce.type.name));return s.ensureMarks(z),E?!0:c.clearNodes()}).wrapInList(h,r).command(()=>Yn(s,h)).command(()=>Zn(s,h)).run()},xu=(n,e={},t={})=>({state:r,commands:o})=>{const{extendEmptyMarkRange:s=!1}=t,i=Ie(n,r.schema);return fu(r,i,e)?o.unsetMark(i,{extendEmptyMarkRange:s}):o.setMark(i,e)},Tu=(n,e,t={})=>({state:r,commands:o})=>{const s=W(n,r.schema),i=W(e,r.schema);return Yr(r,s,t)?o.setNode(i):o.setNode(s,t)},Au=(n,e={})=>({state:t,commands:r})=>{const o=W(n,t.schema);return Yr(t,o,e)?r.lift(o):r.wrapIn(o,e)},Mu=()=>({state:n,dispatch:e})=>{const t=n.plugins;for(let r=0;r<t.length;r+=1){const o=t[r];let s;if(o.spec.isInputRules&&(s=o.getState(n))){if(e){const i=n.tr,l=s.transform;for(let a=l.steps.length-1;a>=0;a-=1)i.step(l.steps[a].invert(l.docs[a]));if(s.text){const a=i.doc.resolve(s.from).marks();i.replaceWith(s.from,s.to,n.schema.text(s.text,a))}else i.delete(s.from,s.to)}return!0}}return!1},Eu=()=>({tr:n,dispatch:e})=>{const{selection:t}=n,{empty:r,ranges:o}=t;return r||e&&o.forEach(s=>{n.removeMark(s.$from.pos,s.$to.pos)}),!0},Nu=(n,e={})=>({tr:t,state:r,dispatch:o})=>{var s;const{extendEmptyMarkRange:i=!1}=e,{selection:l}=t,a=Ie(n,r.schema),{$from:c,empty:u,ranges:d}=l;if(!o)return!0;if(u&&i){let{from:f,to:h}=l;const p=(s=c.marks().find(g=>g.type===a))===null||s===void 0?void 0:s.attrs,m=Qr(c,a,p);m&&(f=m.from,h=m.to),t.removeMark(f,h,a)}else d.forEach(f=>{t.removeMark(f.$from.pos,f.$to.pos,a)});return t.removeStoredMark(a),!0},Ru=(n,e={})=>({tr:t,state:r,dispatch:o})=>{let s=null,i=null;const l=Zr(typeof n=="string"?n:n.name,r.schema);return l?(l==="node"&&(s=W(n,r.schema)),l==="mark"&&(i=Ie(n,r.schema)),o&&t.selection.ranges.forEach(a=>{const c=a.$from.pos,u=a.$to.pos;r.doc.nodesBetween(c,u,(d,f)=>{s&&s===d.type&&t.setNodeMarkup(f,void 0,{...d.attrs,...e}),i&&d.marks.length&&d.marks.forEach(h=>{if(i===h.type){const p=Math.max(f,c),m=Math.min(f+d.nodeSize,u);t.addMark(p,m,i.create({...h.attrs,...e}))}})})}),!0):!1},Ou=(n,e={})=>({state:t,dispatch:r})=>{const o=W(n,t.schema);return Xa(o,e)(t,r)},Iu=(n,e={})=>({state:t,dispatch:r})=>{const o=W(n,t.schema);return Ya(o,e)(t,r)};var Lu=Object.freeze({__proto__:null,blur:fc,clearContent:hc,clearNodes:pc,command:mc,createParagraphNear:gc,cut:yc,deleteCurrentNode:bc,deleteNode:kc,deleteRange:Sc,deleteSelection:Cc,enter:wc,exitCode:xc,extendMarkRange:Ac,first:Mc,focus:Nc,forEach:Rc,insertContent:Oc,insertContentAt:vc,joinUp:Pc,joinDown:zc,joinBackward:Dc,joinForward:Bc,joinItemBackward:Hc,joinItemForward:$c,joinTextblockBackward:Fc,joinTextblockForward:jc,keyboardShortcut:Kc,lift:Vc,liftEmptyBlock:qc,liftListItem:Jc,newlineInCode:Uc,resetAttributes:_c,scrollIntoView:Gc,selectAll:Qc,selectNodeBackward:Xc,selectNodeForward:Yc,selectParentNode:Zc,selectTextblockEnd:eu,selectTextblockStart:tu,setContent:ru,setMark:pu,setMeta:mu,setNode:gu,setNodeSelection:yu,setTextSelection:bu,sinkListItem:ku,splitBlock:Su,splitListItem:Cu,toggleList:wu,toggleMark:xu,toggleNode:Tu,toggleWrap:Au,undoInputRule:Mu,unsetAllMarks:Eu,unsetMark:Nu,updateAttributes:Ru,wrapIn:Ou,wrapInList:Iu});me.create({name:"commands",addCommands(){return{...Lu}}});me.create({name:"editable",addProseMirrorPlugins(){return[new ie({key:new te("editable"),props:{editable:()=>this.editor.options.editable}})]}});me.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:n}=this;return[new ie({key:new te("focusEvents"),props:{handleDOMEvents:{focus:(e,t)=>{n.isFocused=!0;const r=n.state.tr.setMeta("focus",{event:t}).setMeta("addToHistory",!1);return e.dispatch(r),!1},blur:(e,t)=>{n.isFocused=!1;const r=n.state.tr.setMeta("blur",{event:t}).setMeta("addToHistory",!1);return e.dispatch(r),!1}}}})]}});me.create({name:"keymap",addKeyboardShortcuts(){const n=()=>this.editor.commands.first(({commands:i})=>[()=>i.undoInputRule(),()=>i.command(({tr:l})=>{const{selection:a,doc:c}=l,{empty:u,$anchor:d}=a,{pos:f,parent:h}=d,p=d.parent.isTextblock&&f>0?l.doc.resolve(f-1):d,m=p.parent.type.spec.isolating,g=d.pos-d.parentOffset,y=m&&p.parent.childCount===1?g===d.pos:x.atStart(c).from===f;return!u||!h.type.isTextblock||h.textContent.length||!y||y&&d.parent.type.name==="paragraph"?!1:i.clearNodes()}),()=>i.deleteSelection(),()=>i.joinBackward(),()=>i.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:i})=>[()=>i.deleteSelection(),()=>i.deleteCurrentNode(),()=>i.joinForward(),()=>i.selectNodeForward()]),r={Enter:()=>this.editor.commands.first(({commands:i})=>[()=>i.newlineInCode(),()=>i.createParagraphNear(),()=>i.liftEmptyBlock(),()=>i.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:n,"Mod-Backspace":n,"Shift-Backspace":n,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},o={...r},s={...r,"Ctrl-h":n,"Alt-Backspace":n,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return Xr()||Si()?s:o},addProseMirrorPlugins(){return[new ie({key:new te("clearDocument"),appendTransaction:(n,e,t)=>{if(!(n.some(p=>p.docChanged)&&!e.doc.eq(t.doc)))return;const{empty:o,from:s,to:i}=e.selection,l=x.atStart(e.doc).from,a=x.atEnd(e.doc).to;if(o||!(s===l&&i===a)||!(t.doc.textBetween(0,t.doc.content.size," "," ").length===0))return;const d=t.tr,f=yi({state:t,transaction:d}),{commands:h}=new oc({editor:this.editor,state:f});if(h.clearNodes(),!!d.steps.length)return d}})]}});me.create({name:"tabindex",addProseMirrorPlugins(){return[new ie({key:new te("tabindex"),props:{attributes:this.editor.isEditable?{tabindex:"0"}:{}}})]}});function tt(n){return new vn({find:n.find,handler:({state:e,range:t,match:r})=>{const o=v(n.getAttributes,void 0,r);if(o===!1||o===null)return null;const{tr:s}=e,i=r[r.length-1],l=r[0];if(i){const a=l.search(/\S/),c=t.from+l.indexOf(i),u=c+i.length;if(to(t.from,t.to,e.doc).filter(h=>h.mark.type.excluded.find(m=>m===n.type&&m!==h.mark.type)).filter(h=>h.to>c).length)return null;u<t.to&&s.delete(u,t.to),c>t.from&&s.delete(t.from+a,c);const f=t.from+a+i.length;s.addMark(t.from+a,f,n.type.create(o||{})),s.removeStoredMark(n.type)}}})}function vu(n){return new vn({find:n.find,handler:({state:e,range:t,match:r})=>{const o=v(n.getAttributes,void 0,r)||{},{tr:s}=e,i=t.from;let l=t.to;const a=n.type.create(o);if(r[1]){const c=r[0].lastIndexOf(r[1]);let u=i+c;u>l?u=l:l=u+r[1].length;const d=r[0][r[0].length-1];s.insertText(d,i+r[0].length-1),s.replaceWith(u,l,a)}else r[0]&&s.insert(i-1,n.type.create(o)).delete(s.mapping.map(i),s.mapping.map(l));s.scrollIntoView()}})}function xr(n){return new vn({find:n.find,handler:({state:e,range:t,match:r})=>{const o=e.doc.resolve(t.from),s=v(n.getAttributes,void 0,r)||{};if(!o.node(-1).canReplaceWith(o.index(-1),o.indexAfter(-1),n.type))return null;e.tr.delete(t.from,t.to).setBlockType(t.from,t.from,n.type,s)}})}function bt(n){return new vn({find:n.find,handler:({state:e,range:t,match:r,chain:o})=>{const s=v(n.getAttributes,void 0,r)||{},i=e.tr.delete(t.from,t.to),a=i.doc.resolve(t.from).blockRange(),c=a&&Hr(a,n.type,s);if(!c)return null;if(i.wrap(a,c),n.keepMarks&&n.editor){const{selection:d,storedMarks:f}=e,{splittableMarks:h}=n.editor.extensionManager,p=f||d.$to.parentOffset&&d.$from.marks();if(p){const m=p.filter(g=>h.includes(g.type.name));i.ensureMarks(m)}}if(n.keepAttributes){const d=n.type.name==="bulletList"||n.type.name==="orderedList"?"listItem":"taskList";o().updateAttributes(d,s).run()}const u=i.doc.resolve(t.from-1).nodeBefore;u&&u.type===n.type&&Re(i.doc,t.from-1)&&(!n.joinPredicate||n.joinPredicate(r,u))&&i.join(t.from-1)}})}class se{constructor(e={}){this.type="mark",this.name="mark",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=v(H(this,"addOptions",{name:this.name}))),this.storage=v(H(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new se(e)}configure(e={}){const t=this.extend();return t.options=Pn(this.options,e),t.storage=v(H(t,"addStorage",{name:t.name,options:t.options})),t}extend(e={}){const t=new se({...this.config,...e});return t.parent=this,this.child=t,t.name=e.name?e.name:t.parent.name,e.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${t.name}".`),t.options=v(H(t,"addOptions",{name:t.name})),t.storage=v(H(t,"addStorage",{name:t.name,options:t.options})),t}static handleExit({editor:e,mark:t}){const{tr:r}=e.state,o=e.state.selection.$from;if(o.pos===o.end()){const i=o.marks();if(!!!i.find(c=>(c==null?void 0:c.type.name)===t.name))return!1;const a=i.find(c=>(c==null?void 0:c.type.name)===t.name);return a&&r.removeStoredMark(a),r.insertText(" ",o.pos),e.view.dispatch(r),!0}return!1}}class P{constructor(e={}){this.type="node",this.name="node",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=v(H(this,"addOptions",{name:this.name}))),this.storage=v(H(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new P(e)}configure(e={}){const t=this.extend();return t.options=Pn(this.options,e),t.storage=v(H(t,"addStorage",{name:t.name,options:t.options})),t}extend(e={}){const t=new P({...this.config,...e});return t.parent=this,this.child=t,t.name=e.name?e.name:t.parent.name,e.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${t.name}".`),t.options=v(H(t,"addOptions",{name:t.name})),t.storage=v(H(t,"addStorage",{name:t.name,options:t.options})),t}}function He(n){return new ac({find:n.find,handler:({state:e,range:t,match:r,pasteEvent:o})=>{const s=v(n.getAttributes,void 0,r,o);if(s===!1||s===null)return null;const{tr:i}=e,l=r[r.length-1],a=r[0];let c=t.to;if(l){const u=a.search(/\S/),d=t.from+a.indexOf(l),f=d+l.length;if(to(t.from,t.to,e.doc).filter(p=>p.mark.type.excluded.find(g=>g===n.type&&g!==p.mark.type)).filter(p=>p.to>d).length)return null;f<t.to&&i.delete(f,t.to),d>t.from&&i.delete(t.from+u,d),c=t.from+u+l.length,i.addMark(t.from+u,c,n.type.create(s||{})),i.removeStoredMark(n.type)}}})}const Pu=(n,e,t="id",r="item")=>{const o=s=>{var i,l,a;if(!s||!n)return null;if(s.type==="relation-block"&&((i=s.attrs)!=null&&i.id)){const c=(l=n.find(u=>{var d;return(u==null?void 0:u[t])===((d=s.attrs)==null?void 0:d.id)}))==null?void 0:l[r];s.attrs.data=c}return(a=s.content)==null||a.map(o),s};return o(e)},zu=(n,e)=>{const t=e.map(s=>(s.type==="mark"?se:P).create({name:s.name,renderHTML({HTMLAttributes:l}){return s.render?[...s.render(l),0]:[s.component??(s.type==="mark"?"span":"div"),l,0]}})),r=t.map(({name:s})=>s);return[...n.filter(s=>r.indexOf(s.name)<0),...t]},wi=(n,e,t)=>{const r=t.find(o=>o.type===e&&o.name===n);if(r)return{...r.config,options:r.options}},Du=(n,e)=>{var r;const t=(r=e.addAttributes)==null?void 0:r.call(e);return!t||!n?n:Object.fromEntries(Object.entries(n).filter(([o])=>{var s;return((s=t[o])==null?void 0:s.rendered)!==!1}))},er=(n,e,t="node")=>{const r=wi(n.type,t,e);if(!(r!=null&&r.renderHTML))return[];const o=Du(n.attrs,r);return r.render?r.render(n):r.renderHTML({node:n,HTMLAttributes:o})},xi=(n,e,t)=>{if(n!=null&&n.content&&(n.content=n.content.map(i=>xi(i,e,t))),n.type==="text"){if(n.marks){let i;return n.marks.reverse().forEach(l=>{const[a="span",c=l.attrs]=er(l,e,"mark");i=t(a,c,i||n.text)}),i}return n.text??""}const r=wi(n.type,"node",e);if(r!=null&&r.render)return er(n,e);const[o="div",s=n.attrs]=er(n,e);return t(o,s,n.content)},Bu=(n,e,t)=>xi(n,e,t),tr={colspan:"colSpan",rowspan:"rowSpan",textAlign:"textalign"},Hu=(n,e)=>({...Object.fromEntries(Object.entries(e).map(([t,r])=>[(n==null?void 0:n[t])??(tr==null?void 0:tr[t])??t,r]))}),nr={},Ti=n=>{const{content:e,serializers:t=[],componentSerializers:r=[],renderingNodes:o,remappedAttributes:s,themeName:i,tokens:l,customTheme:a}=n,c=JSON.parse(JSON.stringify(e)),u=zu(t,r);return Bu(c,u,(d,f,h)=>{const p={...f,style:void 0},m=Hu(s,p),g=(o==null?void 0:o[d])??(nr==null?void 0:nr[d]);return g?g({children:h,attrs:m,themeName:i,tokens:l,customTheme:a}):ne.jsx(ar.Box,{as:d,...m,themeName:i,tokens:l,customTheme:a,children:h})})},$u=/^\s*>\s$/,Fu=P.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:n}){return["blockquote",R(this.options.HTMLAttributes,n),0]},addCommands(){return{setBlockquote:()=>({commands:n})=>n.wrapIn(this.name),toggleBlockquote:()=>({commands:n})=>n.toggleWrap(this.name),unsetBlockquote:()=>({commands:n})=>n.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[bt({find:$u,type:this.type})]}}),ju=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,Wu=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,Ku=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,Vu=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,qu=se.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:n=>n.style.fontWeight!=="normal"&&null},{style:"font-weight",getAttrs:n=>/^(bold(er)?|[5-9]\d{2,})$/.test(n)&&null}]},renderHTML({HTMLAttributes:n}){return["strong",R(this.options.HTMLAttributes,n),0]},addCommands(){return{setBold:()=>({commands:n})=>n.setMark(this.name),toggleBold:()=>({commands:n})=>n.toggleMark(this.name),unsetBold:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[tt({find:ju,type:this.type}),tt({find:Ku,type:this.type})]},addPasteRules(){return[He({find:Wu,type:this.type}),He({find:Vu,type:this.type})]}}),Ju=P.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:n}){return["li",R(this.options.HTMLAttributes,n),0]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),Vo=se.create({name:"textStyle",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"span",getAttrs:n=>n.hasAttribute("style")?{}:!1}]},renderHTML({HTMLAttributes:n}){return["span",R(this.options.HTMLAttributes,n),0]},addCommands(){return{removeEmptyTextStyle:()=>({state:n,commands:e})=>{const t=zn(n,this.type);return Object.entries(t).some(([,o])=>!!o)?!0:e.unsetMark(this.name)}}}}),qo=/^\s*([-+*])\s$/,Uu=P.create({name:"bulletList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:"ul"}]},renderHTML({HTMLAttributes:n}){return["ul",R(this.options.HTMLAttributes,n),0]},addCommands(){return{toggleBulletList:()=>({commands:n,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(Ju.name,this.editor.getAttributes(Vo.name)).run():n.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let n=bt({find:qo,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(n=bt({find:qo,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(Vo.name),editor:this.editor})),[n]}}),_u=/(?:^|\s)(`(?!\s+`)((?:[^`]+))`(?!\s+`))$/,Gu=/(?:^|\s)(`(?!\s+`)((?:[^`]+))`(?!\s+`))/g,Qu=se.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:n}){return["code",R(this.options.HTMLAttributes,n),0]},addCommands(){return{setCode:()=>({commands:n})=>n.setMark(this.name),toggleCode:()=>({commands:n})=>n.toggleMark(this.name),unsetCode:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[tt({find:_u,type:this.type})]},addPasteRules(){return[He({find:Gu,type:this.type})]}}),Xu=/^```([a-z]+)?[\s\n]$/,Yu=/^~~~([a-z]+)?[\s\n]$/,Zu=P.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:null,parseHTML:n=>{var e;const{languageClassPrefix:t}=this.options,s=[...((e=n.firstElementChild)===null||e===void 0?void 0:e.classList)||[]].filter(i=>i.startsWith(t)).map(i=>i.replace(t,""))[0];return s||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:n,HTMLAttributes:e}){return["pre",R(this.options.HTMLAttributes,e),["code",{class:n.attrs.language?this.options.languageClassPrefix+n.attrs.language:null},0]]},addCommands(){return{setCodeBlock:n=>({commands:e})=>e.setNode(this.name,n),toggleCodeBlock:n=>({commands:e})=>e.toggleNode(this.name,"paragraph",n)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:n,$anchor:e}=this.editor.state.selection,t=e.pos===1;return!n||e.parent.type.name!==this.name?!1:t||!e.parent.textContent.length?this.editor.commands.clearNodes():!1},Enter:({editor:n})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:e}=n,{selection:t}=e,{$from:r,empty:o}=t;if(!o||r.parent.type!==this.type)return!1;const s=r.parentOffset===r.parent.nodeSize-2,i=r.parent.textContent.endsWith(`
10
+ `,textSerializers:i={}}=t||{};let l="";return n.nodesBetween(r,o,(a,c,u,d)=>{var f;a.isBlock&&c>r&&(l+=s);const h=i==null?void 0:i[a.type.name];if(h)return u&&(l+=h({node:a,pos:c,parent:u,index:d,range:e})),!1;a.isText&&(l+=(f=a==null?void 0:a.text)===null||f===void 0?void 0:f.slice(Math.max(r,c)-c,o-c))}),l}function dc(n){return Object.fromEntries(Object.entries(n.nodes).filter(([,e])=>e.spec.toText).map(([e,t])=>[e,t.spec.toText]))}me.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new ie({key:new te("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:n}=this,{state:e,schema:t}=n,{doc:r,selection:o}=e,{ranges:s}=o,i=Math.min(...s.map(u=>u.$from.pos)),l=Math.max(...s.map(u=>u.$to.pos)),a=dc(t);return uc(r,{from:i,to:l},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:a})}}})]}});const fc=()=>({editor:n,view:e})=>(requestAnimationFrame(()=>{var t;n.isDestroyed||(e.dom.blur(),(t=window==null?void 0:window.getSelection())===null||t===void 0||t.removeAllRanges())}),!0),hc=(n=!1)=>({commands:e})=>e.setContent("",n),pc=()=>({state:n,tr:e,dispatch:t})=>{const{selection:r}=e,{ranges:o}=r;return t&&o.forEach(({$from:s,$to:i})=>{n.doc.nodesBetween(s.pos,i.pos,(l,a)=>{if(l.type.isText)return;const{doc:c,mapping:u}=e,d=c.resolve(u.map(a)),f=c.resolve(u.map(a+l.nodeSize)),h=d.blockRange(f);if(!h)return;const p=rt(h);if(l.type.isTextblock){const{defaultType:m}=d.parent.contentMatchAt(d.index());e.setNodeMarkup(h.start,m)}(p||p===0)&&e.lift(h,p)})}),!0},mc=n=>e=>n(e),gc=()=>({state:n,dispatch:e})=>qa(n,e),yc=(n,e)=>({editor:t,tr:r})=>{const{state:o}=t,s=o.doc.slice(n.from,n.to);r.deleteRange(n.from,n.to);const i=r.mapping.map(e);return r.insert(i,s.content),r.setSelection(new w(r.doc.resolve(i-1))),!0},bc=()=>({tr:n,dispatch:e})=>{const{selection:t}=n,r=t.$anchor.node();if(r.content.size>0)return!1;const o=n.selection.$anchor;for(let s=o.depth;s>0;s-=1)if(o.node(s).type===r.type){if(e){const l=o.before(s),a=o.after(s);n.delete(l,a).scrollIntoView()}return!0}return!1},kc=n=>({tr:e,state:t,dispatch:r})=>{const o=W(n,t.schema),s=e.selection.$anchor;for(let i=s.depth;i>0;i-=1)if(s.node(i).type===o){if(r){const a=s.before(i),c=s.after(i);e.delete(a,c).scrollIntoView()}return!0}return!1},Sc=n=>({tr:e,dispatch:t})=>{const{from:r,to:o}=n;return t&&e.delete(r,o),!0},Cc=()=>({state:n,dispatch:e})=>va(n,e),wc=()=>({commands:n})=>n.keyboardShortcut("Enter"),xc=()=>({state:n,dispatch:e})=>Va(n,e);function Qt(n,e,t={strict:!0}){const r=Object.keys(e);return r.length?r.every(o=>t.strict?e[o]===n[o]:lc(e[o])?e[o].test(n[o]):e[o]===n[o]):!0}function wr(n,e,t={}){return n.find(r=>r.type===e&&Qt(r.attrs,t))}function Tc(n,e,t={}){return!!wr(n,e,t)}function Qr(n,e,t={}){if(!n||!e)return;let r=n.parent.childAfter(n.parentOffset);if(n.parentOffset===r.offset&&r.offset!==0&&(r=n.parent.childBefore(n.parentOffset)),!r.node)return;const o=wr([...r.node.marks],e,t);if(!o)return;let s=r.index,i=n.start()+r.offset,l=s+1,a=i+r.node.nodeSize;for(wr([...r.node.marks],e,t);s>0&&o.isInSet(n.parent.child(s-1).marks);)s-=1,i-=n.parent.child(s).nodeSize;for(;l<n.parent.childCount&&Tc([...n.parent.child(l).marks],e,t);)a+=n.parent.child(l).nodeSize,l+=1;return{from:i,to:a}}function Ie(n,e){if(typeof n=="string"){if(!e.marks[n])throw Error(`There is no mark type named '${n}'. Maybe you forgot to add the extension?`);return e.marks[n]}return n}const Ac=(n,e={})=>({tr:t,state:r,dispatch:o})=>{const s=Ie(n,r.schema),{doc:i,selection:l}=t,{$from:a,from:c,to:u}=l;if(o){const d=Qr(a,s,e);if(d&&d.from<=c&&d.to>=u){const f=w.create(i,d.from,d.to);t.setSelection(f)}}return!0},Mc=n=>e=>{const t=typeof n=="function"?n(e):n;for(let r=0;r<t.length;r+=1)if(t[r](e))return!0;return!1};function bi(n){return n instanceof w}function Pe(n=0,e=0,t=0){return Math.min(Math.max(n,e),t)}function Ec(n,e=null){if(!e)return null;const t=x.atStart(n),r=x.atEnd(n);if(e==="start"||e===!0)return t;if(e==="end")return r;const o=t.from,s=r.to;return e==="all"?w.create(n,Pe(0,o,s),Pe(n.content.size,o,s)):w.create(n,Pe(e,o,s),Pe(e,o,s))}function Xr(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}const Nc=(n=null,e={})=>({editor:t,view:r,tr:o,dispatch:s})=>{e={scrollIntoView:!0,...e};const i=()=>{Xr()&&r.dom.focus(),requestAnimationFrame(()=>{t.isDestroyed||(r.focus(),e!=null&&e.scrollIntoView&&t.commands.scrollIntoView())})};if(r.hasFocus()&&n===null||n===!1)return!0;if(s&&n===null&&!bi(t.state.selection))return i(),!0;const l=Ec(o.doc,n)||t.state.selection,a=t.state.selection.eq(l);return s&&(a||o.setSelection(l),a&&o.storedMarks&&o.setStoredMarks(o.storedMarks),i()),!0},Rc=(n,e)=>t=>n.every((r,o)=>e(r,{...t,index:o})),Oc=(n,e)=>({tr:t,commands:r})=>r.insertContentAt({from:t.selection.from,to:t.selection.to},n,e),ki=n=>{const e=n.childNodes;for(let t=e.length-1;t>=0;t-=1){const r=e[t];r.nodeType===3&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?n.removeChild(r):r.nodeType===1&&ki(r)}return n};function Fo(n){const e=`<body>${n}</body>`,t=new window.DOMParser().parseFromString(e,"text/html").body;return ki(t)}function Xt(n,e,t){t={slice:!0,parseOptions:{},...t};const r=typeof n=="object"&&n!==null,o=typeof n=="string";if(r)try{return Array.isArray(n)&&n.length>0?b.fromArray(n.map(i=>e.nodeFromJSON(i))):e.nodeFromJSON(n)}catch(s){return console.warn("[tiptap warn]: Invalid content.","Passed value:",n,"Error:",s),Xt("",e,t)}if(o){const s=pt.fromSchema(e);return t.slice?s.parseSlice(Fo(n),t.parseOptions).content:s.parse(Fo(n),t.parseOptions)}return Xt("",e,t)}function Ic(n,e,t){const r=n.steps.length-1;if(r<e)return;const o=n.steps[r];if(!(o instanceof $||o instanceof F))return;const s=n.mapping.maps[r];let i=0;s.forEach((l,a,c,u)=>{i===0&&(i=u)}),n.setSelection(x.near(n.doc.resolve(i),t))}const Lc=n=>n.toString().startsWith("<"),vc=(n,e,t)=>({tr:r,dispatch:o,editor:s})=>{if(o){t={parseOptions:{},updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...t};const i=Xt(e,s.schema,{parseOptions:{preserveWhitespace:"full",...t.parseOptions}});if(i.toString()==="<>")return!0;let{from:l,to:a}=typeof n=="number"?{from:n,to:n}:{from:n.from,to:n.to},c=!0,u=!0;if((Lc(i)?i:[i]).forEach(h=>{h.check(),c=c?h.isText&&h.marks.length===0:!1,u=u?h.isBlock:!1}),l===a&&u){const{parent:h}=r.doc.resolve(l);h.isTextblock&&!h.type.spec.code&&!h.childCount&&(l-=1,a+=1)}let f;c?(Array.isArray(e)?f=e.map(h=>h.text||"").join(""):typeof e=="object"&&e&&e.text?f=e.text:f=e,r.insertText(f,l,a)):(f=i,r.replaceWith(l,a,f)),t.updateSelection&&Ic(r,r.steps.length-1,-1),t.applyInputRules&&r.setMeta("applyInputRules",{from:l,text:f}),t.applyPasteRules&&r.setMeta("applyPasteRules",{from:l,text:f})}return!0},Pc=()=>({state:n,dispatch:e})=>Fa(n,e),zc=()=>({state:n,dispatch:e})=>ja(n,e),Dc=()=>({state:n,dispatch:e})=>Pa(n,e),Bc=()=>({state:n,dispatch:e})=>Ha(n,e),Hc=()=>({tr:n,state:e,dispatch:t})=>{try{const r=Nn(e.doc,e.selection.$from.pos,-1);return r==null?!1:(n.join(r,2),t&&t(n),!0)}catch{return!1}},$c=()=>({state:n,dispatch:e,tr:t})=>{try{const r=Nn(n.doc,n.selection.$from.pos,1);return r==null?!1:(t.join(r,2),e&&e(t),!0)}catch{return!1}},Fc=()=>({state:n,dispatch:e})=>za(n,e),jc=()=>({state:n,dispatch:e})=>Da(n,e);function Si(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function Wc(n){const e=n.split(/-(?!$)/);let t=e[e.length-1];t==="Space"&&(t=" ");let r,o,s,i;for(let l=0;l<e.length-1;l+=1){const a=e[l];if(/^(cmd|meta|m)$/i.test(a))i=!0;else if(/^a(lt)?$/i.test(a))r=!0;else if(/^(c|ctrl|control)$/i.test(a))o=!0;else if(/^s(hift)?$/i.test(a))s=!0;else if(/^mod$/i.test(a))Xr()||Si()?i=!0:o=!0;else throw new Error(`Unrecognized modifier name: ${a}`)}return r&&(t=`Alt-${t}`),o&&(t=`Ctrl-${t}`),i&&(t=`Meta-${t}`),s&&(t=`Shift-${t}`),t}const Kc=n=>({editor:e,view:t,tr:r,dispatch:o})=>{const s=Wc(n).split(/-(?!$)/),i=s.find(c=>!["Alt","Ctrl","Meta","Shift"].includes(c)),l=new KeyboardEvent("keydown",{key:i==="Space"?" ":i,altKey:s.includes("Alt"),ctrlKey:s.includes("Ctrl"),metaKey:s.includes("Meta"),shiftKey:s.includes("Shift"),bubbles:!0,cancelable:!0}),a=e.captureTransaction(()=>{t.someProp("handleKeyDown",c=>c(t,l))});return a==null||a.steps.forEach(c=>{const u=c.map(r.mapping);u&&o&&r.maybeStep(u)}),!0};function Yr(n,e,t={}){const{from:r,to:o,empty:s}=n.selection,i=e?W(e,n.schema):null,l=[];n.doc.nodesBetween(r,o,(d,f)=>{if(d.isText)return;const h=Math.max(r,f),p=Math.min(o,f+d.nodeSize);l.push({node:d,from:h,to:p})});const a=o-r,c=l.filter(d=>i?i.name===d.node.type.name:!0).filter(d=>Qt(d.node.attrs,t,{strict:!1}));return s?!!c.length:c.reduce((d,f)=>d+f.to-f.from,0)>=a}const Vc=(n,e={})=>({state:t,dispatch:r})=>{const o=W(n,t.schema);return Yr(t,o,e)?Wa(t,r):!1},qc=()=>({state:n,dispatch:e})=>Ja(n,e),Jc=n=>({state:e,dispatch:t})=>{const r=W(n,e.schema);return ec(r)(e,t)},Uc=()=>({state:n,dispatch:e})=>Ka(n,e);function Zr(n,e){return e.nodes[n]?"node":e.marks[n]?"mark":null}function jo(n,e){const t=typeof e=="string"?[e]:e;return Object.keys(n).reduce((r,o)=>(t.includes(o)||(r[o]=n[o]),r),{})}const _c=(n,e)=>({tr:t,state:r,dispatch:o})=>{let s=null,i=null;const l=Zr(typeof n=="string"?n:n.name,r.schema);return l?(l==="node"&&(s=W(n,r.schema)),l==="mark"&&(i=Ie(n,r.schema)),o&&t.selection.ranges.forEach(a=>{r.doc.nodesBetween(a.$from.pos,a.$to.pos,(c,u)=>{s&&s===c.type&&t.setNodeMarkup(u,void 0,jo(c.attrs,e)),i&&c.marks.length&&c.marks.forEach(d=>{i===d.type&&t.addMark(u,u+c.nodeSize,i.create(jo(d.attrs,e)))})})}),!0):!1},Gc=()=>({tr:n,dispatch:e})=>(e&&n.scrollIntoView(),!0),Qc=()=>({tr:n,commands:e})=>e.setTextSelection({from:0,to:n.doc.content.size}),Xc=()=>({state:n,dispatch:e})=>Ba(n,e),Yc=()=>({state:n,dispatch:e})=>$a(n,e),Zc=()=>({state:n,dispatch:e})=>Ua(n,e),eu=()=>({state:n,dispatch:e})=>Qa(n,e),tu=()=>({state:n,dispatch:e})=>Ga(n,e);function nu(n,e,t={}){return Xt(n,e,{slice:!1,parseOptions:t})}const ru=(n,e=!1,t={})=>({tr:r,editor:o,dispatch:s})=>{const{doc:i}=r,l=nu(n,o.schema,t);return s&&r.replaceWith(0,i.content.size,l).setMeta("preventUpdate",!e),!0};function zn(n,e){const t=Ie(e,n.schema),{from:r,to:o,empty:s}=n.selection,i=[];s?(n.storedMarks&&i.push(...n.storedMarks),i.push(...n.selection.$head.marks())):n.doc.nodesBetween(r,o,a=>{i.push(...a.marks)});const l=i.find(a=>a.type.name===t.name);return l?{...l.attrs}:{}}function ou(n,e){const t=new Hs(n);return e.forEach(r=>{r.steps.forEach(o=>{t.step(o)})}),t}function su(n){for(let e=0;e<n.edgeCount;e+=1){const{type:t}=n.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}function iu(n,e,t){const r=[];return n.nodesBetween(e.from,e.to,(o,s)=>{t(o)&&r.push({node:o,pos:s})}),r}function Ci(n,e){for(let t=n.depth;t>0;t-=1){const r=n.node(t);if(e(r))return{pos:t>0?n.before(t):0,start:n.start(t),depth:t,node:r}}}function eo(n){return e=>Ci(e.$from,n)}function lu(n,e){const t=W(e,n.schema),{from:r,to:o}=n.selection,s=[];n.doc.nodesBetween(r,o,l=>{s.push(l)});const i=s.reverse().find(l=>l.type.name===t.name);return i?{...i.attrs}:{}}function au(n,e){const t=Zr(typeof e=="string"?e:e.name,n.schema);return t==="node"?lu(n,e):t==="mark"?zn(n,e):{}}function cu(n,e=JSON.stringify){const t={};return n.filter(r=>{const o=e(r);return Object.prototype.hasOwnProperty.call(t,o)?!1:t[o]=!0})}function uu(n){const e=cu(n);return e.length===1?e:e.filter((t,r)=>!e.filter((s,i)=>i!==r).some(s=>t.oldRange.from>=s.oldRange.from&&t.oldRange.to<=s.oldRange.to&&t.newRange.from>=s.newRange.from&&t.newRange.to<=s.newRange.to))}function du(n){const{mapping:e,steps:t}=n,r=[];return e.maps.forEach((o,s)=>{const i=[];if(o.ranges.length)o.forEach((l,a)=>{i.push({from:l,to:a})});else{const{from:l,to:a}=t[s];if(l===void 0||a===void 0)return;i.push({from:l,to:a})}i.forEach(({from:l,to:a})=>{const c=e.slice(s).map(l,-1),u=e.slice(s).map(a),d=e.invert().map(c,-1),f=e.invert().map(u);r.push({oldRange:{from:d,to:f},newRange:{from:c,to:u}})})}),uu(r)}function to(n,e,t){const r=[];return n===e?t.resolve(n).marks().forEach(o=>{const s=t.resolve(n-1),i=Qr(s,o.type);i&&r.push({mark:o,...i})}):t.nodesBetween(n,e,(o,s)=>{!o||(o==null?void 0:o.nodeSize)===void 0||r.push(...o.marks.map(i=>({from:s,to:s+o.nodeSize,mark:i})))}),r}function Bt(n,e,t){return Object.fromEntries(Object.entries(t).filter(([r])=>{const o=n.find(s=>s.type===e&&s.name===r);return o?o.attribute.keepOnSplit:!1}))}function fu(n,e,t={}){const{empty:r,ranges:o}=n.selection,s=e?Ie(e,n.schema):null;if(r)return!!(n.storedMarks||n.selection.$from.marks()).filter(d=>s?s.name===d.type.name:!0).find(d=>Qt(d.attrs,t,{strict:!1}));let i=0;const l=[];if(o.forEach(({$from:d,$to:f})=>{const h=d.pos,p=f.pos;n.doc.nodesBetween(h,p,(m,g)=>{if(!m.isText&&!m.marks.length)return;const y=Math.max(h,g),M=Math.min(p,g+m.nodeSize),A=M-y;i+=A,l.push(...m.marks.map(K=>({mark:K,from:y,to:M})))})}),i===0)return!1;const a=l.filter(d=>s?s.name===d.mark.type.name:!0).filter(d=>Qt(d.mark.attrs,t,{strict:!1})).reduce((d,f)=>d+f.to-f.from,0),c=l.filter(d=>s?d.mark.type!==s&&d.mark.type.excludes(s):!0).reduce((d,f)=>d+f.to-f.from,0);return(a>0?a+c:a)>=i}function Wo(n,e){const{nodeExtensions:t}=sc(e),r=t.find(i=>i.name===n);if(!r)return!1;const o={name:r.name,options:r.options,storage:r.storage},s=v(H(r,"group",o));return typeof s!="string"?!1:s.split(" ").includes("list")}function hu(n,e,t){var r;const{selection:o}=e;let s=null;if(bi(o)&&(s=o.$cursor),s){const l=(r=n.storedMarks)!==null&&r!==void 0?r:s.marks();return!!t.isInSet(l)||!l.some(a=>a.type.excludes(t))}const{ranges:i}=o;return i.some(({$from:l,$to:a})=>{let c=l.depth===0?n.doc.inlineContent&&n.doc.type.allowsMarkType(t):!1;return n.doc.nodesBetween(l.pos,a.pos,(u,d,f)=>{if(c)return!1;if(u.isInline){const h=!f||f.type.allowsMarkType(t),p=!!t.isInSet(u.marks)||!u.marks.some(m=>m.type.excludes(t));c=h&&p}return!c}),c})}const pu=(n,e={})=>({tr:t,state:r,dispatch:o})=>{const{selection:s}=t,{empty:i,ranges:l}=s,a=Ie(n,r.schema);if(o)if(i){const c=zn(r,a);t.addStoredMark(a.create({...c,...e}))}else l.forEach(c=>{const u=c.$from.pos,d=c.$to.pos;r.doc.nodesBetween(u,d,(f,h)=>{const p=Math.max(h,u),m=Math.min(h+f.nodeSize,d);f.marks.find(y=>y.type===a)?f.marks.forEach(y=>{a===y.type&&t.addMark(p,m,a.create({...y.attrs,...e}))}):t.addMark(p,m,a.create(e))})});return hu(r,t,a)},mu=(n,e)=>({tr:t})=>(t.setMeta(n,e),!0),gu=(n,e={})=>({state:t,dispatch:r,chain:o})=>{const s=W(n,t.schema);return s.isTextblock?o().command(({commands:i})=>$o(s,e)(t)?!0:i.clearNodes()).command(({state:i})=>$o(s,e)(i,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},yu=n=>({tr:e,dispatch:t})=>{if(t){const{doc:r}=e,o=Pe(n,0,r.content.size),s=C.create(r,o);e.setSelection(s)}return!0},bu=n=>({tr:e,dispatch:t})=>{if(t){const{doc:r}=e,{from:o,to:s}=typeof n=="number"?{from:n,to:n}:n,i=w.atStart(r).from,l=w.atEnd(r).to,a=Pe(o,i,l),c=Pe(s,i,l),u=w.create(r,a,c);e.setSelection(u)}return!0},ku=n=>({state:e,dispatch:t})=>{const r=W(n,e.schema);return rc(r)(e,t)};function Ko(n,e){const t=n.storedMarks||n.selection.$to.parentOffset&&n.selection.$from.marks();if(t){const r=t.filter(o=>e==null?void 0:e.includes(o.type.name));n.tr.ensureMarks(r)}}const Su=({keepMarks:n=!0}={})=>({tr:e,state:t,dispatch:r,editor:o})=>{const{selection:s,doc:i}=e,{$from:l,$to:a}=s,c=o.extensionManager.attributes,u=Bt(c,l.node().type.name,l.node().attrs);if(s instanceof C&&s.node.isBlock)return!l.parentOffset||!Ge(i,l.pos)?!1:(r&&(n&&Ko(t,o.extensionManager.splittableMarks),e.split(l.pos).scrollIntoView()),!0);if(!l.parent.isBlock)return!1;if(r){const d=a.parentOffset===a.parent.content.size;s instanceof w&&e.deleteSelection();const f=l.depth===0?void 0:su(l.node(-1).contentMatchAt(l.indexAfter(-1)));let h=d&&f?[{type:f,attrs:u}]:void 0,p=Ge(e.doc,e.mapping.map(l.pos),1,h);if(!h&&!p&&Ge(e.doc,e.mapping.map(l.pos),1,f?[{type:f}]:void 0)&&(p=!0,h=f?[{type:f,attrs:u}]:void 0),p&&(e.split(e.mapping.map(l.pos),1,h),f&&!d&&!l.parentOffset&&l.parent.type!==f)){const m=e.mapping.map(l.before()),g=e.doc.resolve(m);l.node(-1).canReplaceWith(g.index(),g.index()+1,f)&&e.setNodeMarkup(e.mapping.map(l.before()),f)}n&&Ko(t,o.extensionManager.splittableMarks),e.scrollIntoView()}return!0},Cu=n=>({tr:e,state:t,dispatch:r,editor:o})=>{var s;const i=W(n,t.schema),{$from:l,$to:a}=t.selection,c=t.selection.node;if(c&&c.isBlock||l.depth<2||!l.sameParent(a))return!1;const u=l.node(-1);if(u.type!==i)return!1;const d=o.extensionManager.attributes;if(l.parent.content.size===0&&l.node(-1).childCount===l.indexAfter(-1)){if(l.depth===2||l.node(-3).type!==i||l.index(-2)!==l.node(-2).childCount-1)return!1;if(r){let g=b.empty;const y=l.index(-1)?1:l.index(-2)?2:3;for(let z=l.depth-y;z>=l.depth-3;z-=1)g=b.from(l.node(z).copy(g));const M=l.indexAfter(-1)<l.node(-2).childCount?1:l.indexAfter(-2)<l.node(-3).childCount?2:3,A=Bt(d,l.node().type.name,l.node().attrs),K=((s=i.contentMatch.defaultType)===null||s===void 0?void 0:s.createAndFill(A))||void 0;g=g.append(b.from(i.createAndFill(null,K)||void 0));const N=l.before(l.depth-(y-1));e.replace(N,l.after(-M),new S(g,4-y,0));let E=-1;e.doc.nodesBetween(N,e.doc.content.size,(z,ce)=>{if(E>-1)return!1;z.isTextblock&&z.content.size===0&&(E=ce+1)}),E>-1&&e.setSelection(w.near(e.doc.resolve(E))),e.scrollIntoView()}return!0}const f=a.pos===l.end()?u.contentMatchAt(0).defaultType:null,h=Bt(d,u.type.name,u.attrs),p=Bt(d,l.node().type.name,l.node().attrs);e.delete(l.pos,a.pos);const m=f?[{type:i,attrs:h},{type:f,attrs:p}]:[{type:i,attrs:h}];if(!Ge(e.doc,l.pos,2))return!1;if(r){const{selection:g,storedMarks:y}=t,{splittableMarks:M}=o.extensionManager,A=y||g.$to.parentOffset&&g.$from.marks();if(e.split(l.pos,2,m).scrollIntoView(),!A||!r)return!0;const K=A.filter(N=>M.includes(N.type.name));e.ensureMarks(K)}return!0},Yn=(n,e)=>{const t=eo(i=>i.type===e)(n.selection);if(!t)return!0;const r=n.doc.resolve(Math.max(0,t.pos-1)).before(t.depth);if(r===void 0)return!0;const o=n.doc.nodeAt(r);return t.node.type===(o==null?void 0:o.type)&&Re(n.doc,t.pos)&&n.join(t.pos),!0},Zn=(n,e)=>{const t=eo(i=>i.type===e)(n.selection);if(!t)return!0;const r=n.doc.resolve(t.start).after(t.depth);if(r===void 0)return!0;const o=n.doc.nodeAt(r);return t.node.type===(o==null?void 0:o.type)&&Re(n.doc,r)&&n.join(r),!0},wu=(n,e,t,r={})=>({editor:o,tr:s,state:i,dispatch:l,chain:a,commands:c,can:u})=>{const{extensions:d,splittableMarks:f}=o.extensionManager,h=W(n,i.schema),p=W(e,i.schema),{selection:m,storedMarks:g}=i,{$from:y,$to:M}=m,A=y.blockRange(M),K=g||m.$to.parentOffset&&m.$from.marks();if(!A)return!1;const N=eo(E=>Wo(E.type.name,d))(m);if(A.depth>=1&&N&&A.depth-N.depth<=1){if(N.node.type===h)return c.liftListItem(p);if(Wo(N.node.type.name,d)&&h.validContent(N.node.content)&&l)return a().command(()=>(s.setNodeMarkup(N.pos,h),!0)).command(()=>Yn(s,h)).command(()=>Zn(s,h)).run()}return!t||!K||!l?a().command(()=>u().wrapInList(h,r)?!0:c.clearNodes()).wrapInList(h,r).command(()=>Yn(s,h)).command(()=>Zn(s,h)).run():a().command(()=>{const E=u().wrapInList(h,r),z=K.filter(ce=>f.includes(ce.type.name));return s.ensureMarks(z),E?!0:c.clearNodes()}).wrapInList(h,r).command(()=>Yn(s,h)).command(()=>Zn(s,h)).run()},xu=(n,e={},t={})=>({state:r,commands:o})=>{const{extendEmptyMarkRange:s=!1}=t,i=Ie(n,r.schema);return fu(r,i,e)?o.unsetMark(i,{extendEmptyMarkRange:s}):o.setMark(i,e)},Tu=(n,e,t={})=>({state:r,commands:o})=>{const s=W(n,r.schema),i=W(e,r.schema);return Yr(r,s,t)?o.setNode(i):o.setNode(s,t)},Au=(n,e={})=>({state:t,commands:r})=>{const o=W(n,t.schema);return Yr(t,o,e)?r.lift(o):r.wrapIn(o,e)},Mu=()=>({state:n,dispatch:e})=>{const t=n.plugins;for(let r=0;r<t.length;r+=1){const o=t[r];let s;if(o.spec.isInputRules&&(s=o.getState(n))){if(e){const i=n.tr,l=s.transform;for(let a=l.steps.length-1;a>=0;a-=1)i.step(l.steps[a].invert(l.docs[a]));if(s.text){const a=i.doc.resolve(s.from).marks();i.replaceWith(s.from,s.to,n.schema.text(s.text,a))}else i.delete(s.from,s.to)}return!0}}return!1},Eu=()=>({tr:n,dispatch:e})=>{const{selection:t}=n,{empty:r,ranges:o}=t;return r||e&&o.forEach(s=>{n.removeMark(s.$from.pos,s.$to.pos)}),!0},Nu=(n,e={})=>({tr:t,state:r,dispatch:o})=>{var s;const{extendEmptyMarkRange:i=!1}=e,{selection:l}=t,a=Ie(n,r.schema),{$from:c,empty:u,ranges:d}=l;if(!o)return!0;if(u&&i){let{from:f,to:h}=l;const p=(s=c.marks().find(g=>g.type===a))===null||s===void 0?void 0:s.attrs,m=Qr(c,a,p);m&&(f=m.from,h=m.to),t.removeMark(f,h,a)}else d.forEach(f=>{t.removeMark(f.$from.pos,f.$to.pos,a)});return t.removeStoredMark(a),!0},Ru=(n,e={})=>({tr:t,state:r,dispatch:o})=>{let s=null,i=null;const l=Zr(typeof n=="string"?n:n.name,r.schema);return l?(l==="node"&&(s=W(n,r.schema)),l==="mark"&&(i=Ie(n,r.schema)),o&&t.selection.ranges.forEach(a=>{const c=a.$from.pos,u=a.$to.pos;r.doc.nodesBetween(c,u,(d,f)=>{s&&s===d.type&&t.setNodeMarkup(f,void 0,{...d.attrs,...e}),i&&d.marks.length&&d.marks.forEach(h=>{if(i===h.type){const p=Math.max(f,c),m=Math.min(f+d.nodeSize,u);t.addMark(p,m,i.create({...h.attrs,...e}))}})})}),!0):!1},Ou=(n,e={})=>({state:t,dispatch:r})=>{const o=W(n,t.schema);return Xa(o,e)(t,r)},Iu=(n,e={})=>({state:t,dispatch:r})=>{const o=W(n,t.schema);return Ya(o,e)(t,r)};var Lu=Object.freeze({__proto__:null,blur:fc,clearContent:hc,clearNodes:pc,command:mc,createParagraphNear:gc,cut:yc,deleteCurrentNode:bc,deleteNode:kc,deleteRange:Sc,deleteSelection:Cc,enter:wc,exitCode:xc,extendMarkRange:Ac,first:Mc,focus:Nc,forEach:Rc,insertContent:Oc,insertContentAt:vc,joinUp:Pc,joinDown:zc,joinBackward:Dc,joinForward:Bc,joinItemBackward:Hc,joinItemForward:$c,joinTextblockBackward:Fc,joinTextblockForward:jc,keyboardShortcut:Kc,lift:Vc,liftEmptyBlock:qc,liftListItem:Jc,newlineInCode:Uc,resetAttributes:_c,scrollIntoView:Gc,selectAll:Qc,selectNodeBackward:Xc,selectNodeForward:Yc,selectParentNode:Zc,selectTextblockEnd:eu,selectTextblockStart:tu,setContent:ru,setMark:pu,setMeta:mu,setNode:gu,setNodeSelection:yu,setTextSelection:bu,sinkListItem:ku,splitBlock:Su,splitListItem:Cu,toggleList:wu,toggleMark:xu,toggleNode:Tu,toggleWrap:Au,undoInputRule:Mu,unsetAllMarks:Eu,unsetMark:Nu,updateAttributes:Ru,wrapIn:Ou,wrapInList:Iu});me.create({name:"commands",addCommands(){return{...Lu}}});me.create({name:"editable",addProseMirrorPlugins(){return[new ie({key:new te("editable"),props:{editable:()=>this.editor.options.editable}})]}});me.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:n}=this;return[new ie({key:new te("focusEvents"),props:{handleDOMEvents:{focus:(e,t)=>{n.isFocused=!0;const r=n.state.tr.setMeta("focus",{event:t}).setMeta("addToHistory",!1);return e.dispatch(r),!1},blur:(e,t)=>{n.isFocused=!1;const r=n.state.tr.setMeta("blur",{event:t}).setMeta("addToHistory",!1);return e.dispatch(r),!1}}}})]}});me.create({name:"keymap",addKeyboardShortcuts(){const n=()=>this.editor.commands.first(({commands:i})=>[()=>i.undoInputRule(),()=>i.command(({tr:l})=>{const{selection:a,doc:c}=l,{empty:u,$anchor:d}=a,{pos:f,parent:h}=d,p=d.parent.isTextblock&&f>0?l.doc.resolve(f-1):d,m=p.parent.type.spec.isolating,g=d.pos-d.parentOffset,y=m&&p.parent.childCount===1?g===d.pos:x.atStart(c).from===f;return!u||!h.type.isTextblock||h.textContent.length||!y||y&&d.parent.type.name==="paragraph"?!1:i.clearNodes()}),()=>i.deleteSelection(),()=>i.joinBackward(),()=>i.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:i})=>[()=>i.deleteSelection(),()=>i.deleteCurrentNode(),()=>i.joinForward(),()=>i.selectNodeForward()]),r={Enter:()=>this.editor.commands.first(({commands:i})=>[()=>i.newlineInCode(),()=>i.createParagraphNear(),()=>i.liftEmptyBlock(),()=>i.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:n,"Mod-Backspace":n,"Shift-Backspace":n,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},o={...r},s={...r,"Ctrl-h":n,"Alt-Backspace":n,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return Xr()||Si()?s:o},addProseMirrorPlugins(){return[new ie({key:new te("clearDocument"),appendTransaction:(n,e,t)=>{if(!(n.some(p=>p.docChanged)&&!e.doc.eq(t.doc)))return;const{empty:o,from:s,to:i}=e.selection,l=x.atStart(e.doc).from,a=x.atEnd(e.doc).to;if(o||!(s===l&&i===a)||!(t.doc.textBetween(0,t.doc.content.size," "," ").length===0))return;const d=t.tr,f=yi({state:t,transaction:d}),{commands:h}=new oc({editor:this.editor,state:f});if(h.clearNodes(),!!d.steps.length)return d}})]}});me.create({name:"tabindex",addProseMirrorPlugins(){return[new ie({key:new te("tabindex"),props:{attributes:this.editor.isEditable?{tabindex:"0"}:{}}})]}});function tt(n){return new vn({find:n.find,handler:({state:e,range:t,match:r})=>{const o=v(n.getAttributes,void 0,r);if(o===!1||o===null)return null;const{tr:s}=e,i=r[r.length-1],l=r[0];if(i){const a=l.search(/\S/),c=t.from+l.indexOf(i),u=c+i.length;if(to(t.from,t.to,e.doc).filter(h=>h.mark.type.excluded.find(m=>m===n.type&&m!==h.mark.type)).filter(h=>h.to>c).length)return null;u<t.to&&s.delete(u,t.to),c>t.from&&s.delete(t.from+a,c);const f=t.from+a+i.length;s.addMark(t.from+a,f,n.type.create(o||{})),s.removeStoredMark(n.type)}}})}function vu(n){return new vn({find:n.find,handler:({state:e,range:t,match:r})=>{const o=v(n.getAttributes,void 0,r)||{},{tr:s}=e,i=t.from;let l=t.to;const a=n.type.create(o);if(r[1]){const c=r[0].lastIndexOf(r[1]);let u=i+c;u>l?u=l:l=u+r[1].length;const d=r[0][r[0].length-1];s.insertText(d,i+r[0].length-1),s.replaceWith(u,l,a)}else r[0]&&s.insert(i-1,n.type.create(o)).delete(s.mapping.map(i),s.mapping.map(l));s.scrollIntoView()}})}function xr(n){return new vn({find:n.find,handler:({state:e,range:t,match:r})=>{const o=e.doc.resolve(t.from),s=v(n.getAttributes,void 0,r)||{};if(!o.node(-1).canReplaceWith(o.index(-1),o.indexAfter(-1),n.type))return null;e.tr.delete(t.from,t.to).setBlockType(t.from,t.from,n.type,s)}})}function bt(n){return new vn({find:n.find,handler:({state:e,range:t,match:r,chain:o})=>{const s=v(n.getAttributes,void 0,r)||{},i=e.tr.delete(t.from,t.to),a=i.doc.resolve(t.from).blockRange(),c=a&&Hr(a,n.type,s);if(!c)return null;if(i.wrap(a,c),n.keepMarks&&n.editor){const{selection:d,storedMarks:f}=e,{splittableMarks:h}=n.editor.extensionManager,p=f||d.$to.parentOffset&&d.$from.marks();if(p){const m=p.filter(g=>h.includes(g.type.name));i.ensureMarks(m)}}if(n.keepAttributes){const d=n.type.name==="bulletList"||n.type.name==="orderedList"?"listItem":"taskList";o().updateAttributes(d,s).run()}const u=i.doc.resolve(t.from-1).nodeBefore;u&&u.type===n.type&&Re(i.doc,t.from-1)&&(!n.joinPredicate||n.joinPredicate(r,u))&&i.join(t.from-1)}})}class se{constructor(e={}){this.type="mark",this.name="mark",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=v(H(this,"addOptions",{name:this.name}))),this.storage=v(H(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new se(e)}configure(e={}){const t=this.extend();return t.options=Pn(this.options,e),t.storage=v(H(t,"addStorage",{name:t.name,options:t.options})),t}extend(e={}){const t=new se({...this.config,...e});return t.parent=this,this.child=t,t.name=e.name?e.name:t.parent.name,e.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${t.name}".`),t.options=v(H(t,"addOptions",{name:t.name})),t.storage=v(H(t,"addStorage",{name:t.name,options:t.options})),t}static handleExit({editor:e,mark:t}){const{tr:r}=e.state,o=e.state.selection.$from;if(o.pos===o.end()){const i=o.marks();if(!!!i.find(c=>(c==null?void 0:c.type.name)===t.name))return!1;const a=i.find(c=>(c==null?void 0:c.type.name)===t.name);return a&&r.removeStoredMark(a),r.insertText(" ",o.pos),e.view.dispatch(r),!0}return!1}}class P{constructor(e={}){this.type="node",this.name="node",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=v(H(this,"addOptions",{name:this.name}))),this.storage=v(H(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new P(e)}configure(e={}){const t=this.extend();return t.options=Pn(this.options,e),t.storage=v(H(t,"addStorage",{name:t.name,options:t.options})),t}extend(e={}){const t=new P({...this.config,...e});return t.parent=this,this.child=t,t.name=e.name?e.name:t.parent.name,e.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${t.name}".`),t.options=v(H(t,"addOptions",{name:t.name})),t.storage=v(H(t,"addStorage",{name:t.name,options:t.options})),t}}function He(n){return new ac({find:n.find,handler:({state:e,range:t,match:r,pasteEvent:o})=>{const s=v(n.getAttributes,void 0,r,o);if(s===!1||s===null)return null;const{tr:i}=e,l=r[r.length-1],a=r[0];let c=t.to;if(l){const u=a.search(/\S/),d=t.from+a.indexOf(l),f=d+l.length;if(to(t.from,t.to,e.doc).filter(p=>p.mark.type.excluded.find(g=>g===n.type&&g!==p.mark.type)).filter(p=>p.to>d).length)return null;f<t.to&&i.delete(f,t.to),d>t.from&&i.delete(t.from+u,d),c=t.from+u+l.length,i.addMark(t.from+u,c,n.type.create(s||{})),i.removeStoredMark(n.type)}}})}const Pu=(n,e,t="id",r="item")=>{const o=s=>{var i,l,a;if(!n&&s)return s;if(!s||!n)return null;if(s.type==="relation-block"&&((i=s.attrs)!=null&&i.id)){const c=(l=n.find(u=>{var d;return(u==null?void 0:u[t])===((d=s.attrs)==null?void 0:d.id)}))==null?void 0:l[r];s.attrs.data=c}return(a=s.content)==null||a.map(o),s};return o(e)},zu=(n,e)=>{const t=e.map(s=>(s.type==="mark"?se:P).create({name:s.name,renderHTML({HTMLAttributes:l}){return s.render?[...s.render(l),0]:[s.component??(s.type==="mark"?"span":"div"),l,0]}})),r=t.map(({name:s})=>s);return[...n.filter(s=>r.indexOf(s.name)<0),...t]},wi=(n,e,t)=>{const r=t.find(o=>o.type===e&&o.name===n);if(r)return{...r.config,options:r.options}},Du=(n,e)=>{var r;const t=(r=e.addAttributes)==null?void 0:r.call(e);return!t||!n?n:Object.fromEntries(Object.entries(n).filter(([o])=>{var s;return((s=t[o])==null?void 0:s.rendered)!==!1}))},er=(n,e,t="node")=>{const r=wi(n.type,t,e);if(!(r!=null&&r.renderHTML))return[];const o=Du(n.attrs,r);return r.render?r.render(n):r.renderHTML({node:n,HTMLAttributes:o})},xi=(n,e,t)=>{if(n!=null&&n.content&&(n.content=n.content.map(i=>xi(i,e,t))),n.type==="text"){if(n.marks){let i;return n.marks.reverse().forEach(l=>{const[a="span",c=l.attrs]=er(l,e,"mark");i=t(a,c,i||n.text)}),i}return n.text??""}const r=wi(n.type,"node",e);if(r!=null&&r.render)return er(n,e);const[o="div",s=n.attrs]=er(n,e);return t(o,s,n.content)},Bu=(n,e,t)=>xi(n,e,t),tr={colspan:"colSpan",rowspan:"rowSpan",textAlign:"textalign"},Hu=(n,e)=>({...Object.fromEntries(Object.entries(e).map(([t,r])=>[(n==null?void 0:n[t])??(tr==null?void 0:tr[t])??t,r]))}),nr={},Ti=n=>{const{content:e,serializers:t=[],componentSerializers:r=[],renderingNodes:o,remappedAttributes:s,themeName:i,tokens:l,customTheme:a}=n,c=JSON.parse(JSON.stringify(e)),u=zu(t,r);return Bu(c,u,(d,f,h)=>{const p={...f,style:void 0},m=Hu(s,p),g=(o==null?void 0:o[d])??(nr==null?void 0:nr[d]);return g?g({children:h,attrs:m,themeName:i,tokens:l,customTheme:a}):ne.jsx(ar.Box,{as:d,...m,themeName:i,tokens:l,customTheme:a,children:h},JSON.stringify(h))})},$u=/^\s*>\s$/,Fu=P.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:n}){return["blockquote",O(this.options.HTMLAttributes,n),0]},addCommands(){return{setBlockquote:()=>({commands:n})=>n.wrapIn(this.name),toggleBlockquote:()=>({commands:n})=>n.toggleWrap(this.name),unsetBlockquote:()=>({commands:n})=>n.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[bt({find:$u,type:this.type})]}}),ju=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,Wu=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,Ku=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,Vu=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,qu=se.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:n=>n.style.fontWeight!=="normal"&&null},{style:"font-weight",getAttrs:n=>/^(bold(er)?|[5-9]\d{2,})$/.test(n)&&null}]},renderHTML({HTMLAttributes:n}){return["strong",O(this.options.HTMLAttributes,n),0]},addCommands(){return{setBold:()=>({commands:n})=>n.setMark(this.name),toggleBold:()=>({commands:n})=>n.toggleMark(this.name),unsetBold:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[tt({find:ju,type:this.type}),tt({find:Ku,type:this.type})]},addPasteRules(){return[He({find:Wu,type:this.type}),He({find:Vu,type:this.type})]}}),Ju=P.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:n}){return["li",O(this.options.HTMLAttributes,n),0]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),Vo=se.create({name:"textStyle",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"span",getAttrs:n=>n.hasAttribute("style")?{}:!1}]},renderHTML({HTMLAttributes:n}){return["span",O(this.options.HTMLAttributes,n),0]},addCommands(){return{removeEmptyTextStyle:()=>({state:n,commands:e})=>{const t=zn(n,this.type);return Object.entries(t).some(([,o])=>!!o)?!0:e.unsetMark(this.name)}}}}),qo=/^\s*([-+*])\s$/,Uu=P.create({name:"bulletList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:"ul"}]},renderHTML({HTMLAttributes:n}){return["ul",O(this.options.HTMLAttributes,n),0]},addCommands(){return{toggleBulletList:()=>({commands:n,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(Ju.name,this.editor.getAttributes(Vo.name)).run():n.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let n=bt({find:qo,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(n=bt({find:qo,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(Vo.name),editor:this.editor})),[n]}}),_u=/(?:^|\s)(`(?!\s+`)((?:[^`]+))`(?!\s+`))$/,Gu=/(?:^|\s)(`(?!\s+`)((?:[^`]+))`(?!\s+`))/g,Qu=se.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:n}){return["code",O(this.options.HTMLAttributes,n),0]},addCommands(){return{setCode:()=>({commands:n})=>n.setMark(this.name),toggleCode:()=>({commands:n})=>n.toggleMark(this.name),unsetCode:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[tt({find:_u,type:this.type})]},addPasteRules(){return[He({find:Gu,type:this.type})]}}),Xu=/^```([a-z]+)?[\s\n]$/,Yu=/^~~~([a-z]+)?[\s\n]$/,Zu=P.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:null,parseHTML:n=>{var e;const{languageClassPrefix:t}=this.options,s=[...((e=n.firstElementChild)===null||e===void 0?void 0:e.classList)||[]].filter(i=>i.startsWith(t)).map(i=>i.replace(t,""))[0];return s||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:n,HTMLAttributes:e}){return["pre",O(this.options.HTMLAttributes,e),["code",{class:n.attrs.language?this.options.languageClassPrefix+n.attrs.language:null},0]]},addCommands(){return{setCodeBlock:n=>({commands:e})=>e.setNode(this.name,n),toggleCodeBlock:n=>({commands:e})=>e.toggleNode(this.name,"paragraph",n)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:n,$anchor:e}=this.editor.state.selection,t=e.pos===1;return!n||e.parent.type.name!==this.name?!1:t||!e.parent.textContent.length?this.editor.commands.clearNodes():!1},Enter:({editor:n})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:e}=n,{selection:t}=e,{$from:r,empty:o}=t;if(!o||r.parent.type!==this.type)return!1;const s=r.parentOffset===r.parent.nodeSize-2,i=r.parent.textContent.endsWith(`
11
11
 
12
12
  `);return!s||!i?!1:n.chain().command(({tr:l})=>(l.delete(r.pos-2,r.pos),!0)).exitCode().run()},ArrowDown:({editor:n})=>{if(!this.options.exitOnArrowDown)return!1;const{state:e}=n,{selection:t,doc:r}=e,{$from:o,empty:s}=t;if(!s||o.parent.type!==this.type||!(o.parentOffset===o.parent.nodeSize-2))return!1;const l=o.after();return l===void 0||r.nodeAt(l)?!1:n.commands.exitCode()}}},addInputRules(){return[xr({find:Xu,type:this.type,getAttributes:n=>({language:n[1]})}),xr({find:Yu,type:this.type,getAttributes:n=>({language:n[1]})})]},addProseMirrorPlugins(){return[new ie({key:new te("codeBlockVSCodeHandler"),props:{handlePaste:(n,e)=>{if(!e.clipboardData||this.editor.isActive(this.type.name))return!1;const t=e.clipboardData.getData("text/plain"),r=e.clipboardData.getData("vscode-editor-data"),o=r?JSON.parse(r):void 0,s=o==null?void 0:o.mode;if(!t||!s)return!1;const{tr:i}=n.state;return n.state.selection.from===n.state.doc.nodeSize-(1+n.state.selection.$to.depth*2)?i.insert(n.state.selection.from-1,this.type.create({language:s})):i.replaceSelectionWith(this.type.create({language:s})),i.setSelection(w.near(i.doc.resolve(Math.max(0,i.selection.from-2)))),i.insertText(t.replace(/\r\n?/g,`
13
- `)),i.setMeta("paste",!0),n.dispatch(i),!0}}})]}}),ed=P.create({name:"doc",topNode:!0,content:"block+"}),td=P.create({name:"hardBreak",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:n}){return["br",R(this.options.HTMLAttributes,n)]},renderText(){return`
14
- `},addCommands(){return{setHardBreak:()=>({commands:n,chain:e,state:t,editor:r})=>n.first([()=>n.exitCode(),()=>n.command(()=>{const{selection:o,storedMarks:s}=t;if(o.$from.parent.type.spec.isolating)return!1;const{keepMarks:i}=this.options,{splittableMarks:l}=r.extensionManager,a=s||o.$to.parentOffset&&o.$from.marks();return e().insertContent({type:this.name}).command(({tr:c,dispatch:u})=>{if(u&&a&&i){const d=a.filter(f=>l.includes(f.type.name));c.ensureMarks(d)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),nd=P.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(n=>({tag:`h${n}`,attrs:{level:n}}))},renderHTML({node:n,HTMLAttributes:e}){return[`h${this.options.levels.includes(n.attrs.level)?n.attrs.level:this.options.levels[0]}`,R(this.options.HTMLAttributes,e),0]},addCommands(){return{setHeading:n=>({commands:e})=>this.options.levels.includes(n.level)?e.setNode(this.name,n):!1,toggleHeading:n=>({commands:e})=>this.options.levels.includes(n.level)?e.toggleNode(this.name,"paragraph",n):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((n,e)=>({...n,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}),{})},addInputRules(){return this.options.levels.map(n=>xr({find:new RegExp(`^(#{1,${n}})\\s$`),type:this.type,getAttributes:{level:n}}))}}),rd=P.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{}}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:n}){return["hr",R(this.options.HTMLAttributes,n)]},addCommands(){return{setHorizontalRule:()=>({chain:n,state:e})=>{const{$to:t}=e.selection,r=n();return t.parentOffset===0?r.insertContentAt(Math.max(t.pos-2,0),{type:this.name}):r.insertContent({type:this.name}),r.command(({tr:o,dispatch:s})=>{var i;if(s){const{$to:l}=o.selection,a=l.end();if(l.nodeAfter)l.nodeAfter.isTextblock?o.setSelection(w.create(o.doc,l.pos+1)):l.nodeAfter.isBlock?o.setSelection(C.create(o.doc,l.pos)):o.setSelection(w.create(o.doc,l.pos));else{const c=(i=l.parent.type.contentMatch.defaultType)===null||i===void 0?void 0:i.create();c&&(o.insert(a,c),o.setSelection(w.create(o.doc,a+1)))}o.scrollIntoView()}return!0}).run()}}},addInputRules(){return[vu({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),od=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,sd=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,id=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,ld=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,ad=se.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:n=>n.style.fontStyle!=="normal"&&null},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:n}){return["em",R(this.options.HTMLAttributes,n),0]},addCommands(){return{setItalic:()=>({commands:n})=>n.setMark(this.name),toggleItalic:()=>({commands:n})=>n.toggleMark(this.name),unsetItalic:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[tt({find:od,type:this.type}),tt({find:id,type:this.type})]},addPasteRules(){return[He({find:sd,type:this.type}),He({find:ld,type:this.type})]}}),cd="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4vianca6w0s2x0a2z0ure5ba0by2idu3namex3narepublic11d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2ntley5rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0cast4mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dabur3d1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0ardian6cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6logistics9properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3ncaster6d0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2psy3ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2tura4vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9dnavy5lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0america6xi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0a1b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp2w2ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4finity6ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",ud="ελ1υ2бг1ел3дети4ею2католик6ом3мкд2он1сква6онлайн5рг3рус2ф2сайт3рб3укр3қаз3հայ3ישראל5קום3ابوظبي5رامكو5لاردن4بحرين5جزائر5سعودية6عليان5مغرب5مارات5یران5بارت2زار4يتك3ھارت5تونس4سودان3رية5شبكة4عراق2ب2مان4فلسطين6قطر3كاثوليك6وم3مصر2ليسيا5وريتانيا7قع4همراه5پاکستان7ڀارت4कॉम3नेट3भारत0म्3ोत5संगठन5বাংলা5ভারত2ৰত4ਭਾਰਤ4ભારત4ଭାରତ4இந்தியா6லங்கை6சிங்கப்பூர்11భారత్5ಭಾರತ4ഭാരതം5ලංකා4คอม3ไทย3ລາວ3გე2みんな3アマゾン4クラウド4グーグル4コム2ストア3セール3ファッション6ポイント4世界2中信1国1國1文网3亚马逊3企业2佛山2信息2健康2八卦2公司1益2台湾1灣2商城1店1标2嘉里0大酒店5在线2大拿2天主教3娱乐2家電2广东2微博2慈善2我爱你3手机2招聘2政务1府2新加坡2闻2时尚2書籍2机构2淡马锡3游戏2澳門2点看2移动2组织机构4网址1店1站1络2联通2谷歌2购物2通販2集团2電訊盈科4飞利浦3食品2餐厅2香格里拉3港2닷넷1컴2삼성2한국2",nt=(n,e)=>{for(const t in e)n[t]=e[t];return n},Tr="numeric",Ar="ascii",Mr="alpha",Ht="asciinumeric",Nt="alphanumeric",Er="domain",Ai="emoji",dd="scheme",fd="slashscheme",Jo="whitespace";function hd(n,e){return n in e||(e[n]=[]),e[n]}function ze(n,e,t){e[Tr]&&(e[Ht]=!0,e[Nt]=!0),e[Ar]&&(e[Ht]=!0,e[Mr]=!0),e[Ht]&&(e[Nt]=!0),e[Mr]&&(e[Nt]=!0),e[Nt]&&(e[Er]=!0),e[Ai]&&(e[Er]=!0);for(const r in e){const o=hd(r,t);o.indexOf(n)<0&&o.push(n)}}function pd(n,e){const t={};for(const r in e)e[r].indexOf(n)>=0&&(t[r]=!0);return t}function U(n){n===void 0&&(n=null),this.j={},this.jr=[],this.jd=null,this.t=n}U.groups={};U.prototype={accepts(){return!!this.t},go(n){const e=this,t=e.j[n];if(t)return t;for(let r=0;r<e.jr.length;r++){const o=e.jr[r][0],s=e.jr[r][1];if(s&&o.test(n))return s}return e.jd},has(n,e){return e===void 0&&(e=!1),e?n in this.j:!!this.go(n)},ta(n,e,t,r){for(let o=0;o<n.length;o++)this.tt(n[o],e,t,r)},tr(n,e,t,r){r=r||U.groups;let o;return e&&e.j?o=e:(o=new U(e),t&&r&&ze(e,t,r)),this.jr.push([n,o]),o},ts(n,e,t,r){let o=this;const s=n.length;if(!s)return o;for(let i=0;i<s-1;i++)o=o.tt(n[i]);return o.tt(n[s-1],e,t,r)},tt(n,e,t,r){r=r||U.groups;const o=this;if(e&&e.j)return o.j[n]=e,e;const s=e;let i,l=o.go(n);if(l?(i=new U,nt(i.j,l.j),i.jr.push.apply(i.jr,l.jr),i.jd=l.jd,i.t=l.t):i=new U,s){if(r)if(i.t&&typeof i.t=="string"){const a=nt(pd(i.t,r),t);ze(s,a,r)}else t&&ze(s,t,r);i.t=s}return o.j[n]=i,i}};const T=(n,e,t,r,o)=>n.ta(e,t,r,o),X=(n,e,t,r,o)=>n.tr(e,t,r,o),Uo=(n,e,t,r,o)=>n.ts(e,t,r,o),k=(n,e,t,r,o)=>n.tt(e,t,r,o),ye="WORD",Nr="UWORD",kt="LOCALHOST",Rr="TLD",Or="UTLD",$t="SCHEME",_e="SLASH_SCHEME",no="NUM",Mi="WS",ro="NL",dt="OPENBRACE",ft="CLOSEBRACE",Yt="OPENBRACKET",Zt="CLOSEBRACKET",en="OPENPAREN",tn="CLOSEPAREN",nn="OPENANGLEBRACKET",rn="CLOSEANGLEBRACKET",on="FULLWIDTHLEFTPAREN",sn="FULLWIDTHRIGHTPAREN",ln="LEFTCORNERBRACKET",an="RIGHTCORNERBRACKET",cn="LEFTWHITECORNERBRACKET",un="RIGHTWHITECORNERBRACKET",dn="FULLWIDTHLESSTHAN",fn="FULLWIDTHGREATERTHAN",hn="AMPERSAND",pn="APOSTROPHE",mn="ASTERISK",Ce="AT",gn="BACKSLASH",yn="BACKTICK",bn="CARET",we="COLON",oo="COMMA",kn="DOLLAR",ue="DOT",Sn="EQUALS",so="EXCLAMATION",de="HYPHEN",Cn="PERCENT",wn="PIPE",xn="PLUS",Tn="POUND",An="QUERY",io="QUOTE",lo="SEMI",fe="SLASH",ht="TILDE",Mn="UNDERSCORE",Ei="EMOJI",En="SYM";var Ni=Object.freeze({__proto__:null,WORD:ye,UWORD:Nr,LOCALHOST:kt,TLD:Rr,UTLD:Or,SCHEME:$t,SLASH_SCHEME:_e,NUM:no,WS:Mi,NL:ro,OPENBRACE:dt,CLOSEBRACE:ft,OPENBRACKET:Yt,CLOSEBRACKET:Zt,OPENPAREN:en,CLOSEPAREN:tn,OPENANGLEBRACKET:nn,CLOSEANGLEBRACKET:rn,FULLWIDTHLEFTPAREN:on,FULLWIDTHRIGHTPAREN:sn,LEFTCORNERBRACKET:ln,RIGHTCORNERBRACKET:an,LEFTWHITECORNERBRACKET:cn,RIGHTWHITECORNERBRACKET:un,FULLWIDTHLESSTHAN:dn,FULLWIDTHGREATERTHAN:fn,AMPERSAND:hn,APOSTROPHE:pn,ASTERISK:mn,AT:Ce,BACKSLASH:gn,BACKTICK:yn,CARET:bn,COLON:we,COMMA:oo,DOLLAR:kn,DOT:ue,EQUALS:Sn,EXCLAMATION:so,HYPHEN:de,PERCENT:Cn,PIPE:wn,PLUS:xn,POUND:Tn,QUERY:An,QUOTE:io,SEMI:lo,SLASH:fe,TILDE:ht,UNDERSCORE:Mn,EMOJI:Ei,SYM:En});const qe=/[a-z]/,rr=new RegExp("\\p{L}","u"),or=new RegExp("\\p{Emoji}","u"),sr=/\d/,_o=/\s/,Go=`
15
- `,md="️",gd="‍";let Rt=null,Ot=null;function yd(n){n===void 0&&(n=[]);const e={};U.groups=e;const t=new U;Rt==null&&(Rt=Qo(cd)),Ot==null&&(Ot=Qo(ud)),k(t,"'",pn),k(t,"{",dt),k(t,"}",ft),k(t,"[",Yt),k(t,"]",Zt),k(t,"(",en),k(t,")",tn),k(t,"<",nn),k(t,">",rn),k(t,"(",on),k(t,")",sn),k(t,"「",ln),k(t,"」",an),k(t,"『",cn),k(t,"』",un),k(t,"<",dn),k(t,">",fn),k(t,"&",hn),k(t,"*",mn),k(t,"@",Ce),k(t,"`",yn),k(t,"^",bn),k(t,":",we),k(t,",",oo),k(t,"$",kn),k(t,".",ue),k(t,"=",Sn),k(t,"!",so),k(t,"-",de),k(t,"%",Cn),k(t,"|",wn),k(t,"+",xn),k(t,"#",Tn),k(t,"?",An),k(t,'"',io),k(t,"/",fe),k(t,";",lo),k(t,"~",ht),k(t,"_",Mn),k(t,"\\",gn);const r=X(t,sr,no,{[Tr]:!0});X(r,sr,r);const o=X(t,qe,ye,{[Ar]:!0});X(o,qe,o);const s=X(t,rr,Nr,{[Mr]:!0});X(s,qe),X(s,rr,s);const i=X(t,_o,Mi,{[Jo]:!0});k(t,Go,ro,{[Jo]:!0}),k(i,Go),X(i,_o,i);const l=X(t,or,Ei,{[Ai]:!0});X(l,or,l),k(l,md,l);const a=k(l,gd);X(a,or,l);const c=[[qe,o]],u=[[qe,null],[rr,s]];for(let d=0;d<Rt.length;d++)ke(t,Rt[d],Rr,ye,c);for(let d=0;d<Ot.length;d++)ke(t,Ot[d],Or,Nr,u);ze(Rr,{tld:!0,ascii:!0},e),ze(Or,{utld:!0,alpha:!0},e),ke(t,"file",$t,ye,c),ke(t,"mailto",$t,ye,c),ke(t,"http",_e,ye,c),ke(t,"https",_e,ye,c),ke(t,"ftp",_e,ye,c),ke(t,"ftps",_e,ye,c),ze($t,{scheme:!0,ascii:!0},e),ze(_e,{slashscheme:!0,ascii:!0},e),n=n.sort((d,f)=>d[0]>f[0]?1:-1);for(let d=0;d<n.length;d++){const f=n[d][0],p=n[d][1]?{[dd]:!0}:{[fd]:!0};f.indexOf("-")>=0?p[Er]=!0:qe.test(f)?sr.test(f)?p[Ht]=!0:p[Ar]=!0:p[Tr]=!0,Uo(t,f,f,p)}return Uo(t,"localhost",kt,{ascii:!0}),t.jd=new U(En),{start:t,tokens:nt({groups:e},Ni)}}function bd(n,e){const t=kd(e.replace(/[A-Z]/g,l=>l.toLowerCase())),r=t.length,o=[];let s=0,i=0;for(;i<r;){let l=n,a=null,c=0,u=null,d=-1,f=-1;for(;i<r&&(a=l.go(t[i]));)l=a,l.accepts()?(d=0,f=0,u=l):d>=0&&(d+=t[i].length,f++),c+=t[i].length,s+=t[i].length,i++;s-=d,i-=f,c-=d,o.push({t:u.t,v:e.slice(s-c,s),s:s-c,e:s})}return o}function kd(n){const e=[],t=n.length;let r=0;for(;r<t;){let o=n.charCodeAt(r),s,i=o<55296||o>56319||r+1===t||(s=n.charCodeAt(r+1))<56320||s>57343?n[r]:n.slice(r,r+2);e.push(i),r+=i.length}return e}function ke(n,e,t,r,o){let s;const i=e.length;for(let l=0;l<i-1;l++){const a=e[l];n.j[a]?s=n.j[a]:(s=new U(r),s.jr=o.slice(),n.j[a]=s),n=s}return s=new U(t),s.jr=o.slice(),n.j[e[i-1]]=s,s}function Qo(n){const e=[],t=[];let r=0,o="0123456789";for(;r<n.length;){let s=0;for(;o.indexOf(n[r+s])>=0;)s++;if(s>0){e.push(t.join(""));for(let i=parseInt(n.substring(r,r+s),10);i>0;i--)t.pop();r+=s}else t.push(n[r]),r++}return e}const St={defaultProtocol:"http",events:null,format:Xo,formatHref:Xo,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function ao(n,e){e===void 0&&(e=null);let t=nt({},St);n&&(t=nt(t,n instanceof ao?n.o:n));const r=t.ignoreTags,o=[];for(let s=0;s<r.length;s++)o.push(r[s].toUpperCase());this.o=t,e&&(this.defaultRender=e),this.ignoreTags=o}ao.prototype={o:St,ignoreTags:[],defaultRender(n){return n},check(n){return this.get("validate",n.toString(),n)},get(n,e,t){const r=e!=null;let o=this.o[n];return o&&(typeof o=="object"?(o=t.t in o?o[t.t]:St[n],typeof o=="function"&&r&&(o=o(e,t))):typeof o=="function"&&r&&(o=o(e,t.t,t)),o)},getObj(n,e,t){let r=this.o[n];return typeof r=="function"&&e!=null&&(r=r(e,t.t,t)),r},render(n){const e=n.render(this);return(this.get("render",null,n)||this.defaultRender)(e,n.t,n)}};function Xo(n){return n}function Ri(n,e){this.t="token",this.v=n,this.tk=e}Ri.prototype={isLink:!1,toString(){return this.v},toHref(n){return this.toString()},toFormattedString(n){const e=this.toString(),t=n.get("truncate",e,this),r=n.get("format",e,this);return t&&r.length>t?r.substring(0,t)+"…":r},toFormattedHref(n){return n.get("formatHref",this.toHref(n.get("defaultProtocol")),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(n){return n===void 0&&(n=St.defaultProtocol),{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(n),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(n){return{type:this.t,value:this.toFormattedString(n),isLink:this.isLink,href:this.toFormattedHref(n),start:this.startIndex(),end:this.endIndex()}},validate(n){return n.get("validate",this.toString(),this)},render(n){const e=this,t=this.toHref(n.get("defaultProtocol")),r=n.get("formatHref",t,this),o=n.get("tagName",t,e),s=this.toFormattedString(n),i={},l=n.get("className",t,e),a=n.get("target",t,e),c=n.get("rel",t,e),u=n.getObj("attributes",t,e),d=n.getObj("events",t,e);return i.href=r,l&&(i.class=l),a&&(i.target=a),c&&(i.rel=c),u&&nt(i,u),{tagName:o,attributes:i,content:s,eventListeners:d}}};function Dn(n,e){class t extends Ri{constructor(o,s){super(o,s),this.t=n}}for(const r in e)t.prototype[r]=e[r];return t.t=n,t}const Yo=Dn("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),Zo=Dn("text"),Sd=Dn("nl"),It=Dn("url",{isLink:!0,toHref(n){return n===void 0&&(n=St.defaultProtocol),this.hasProtocol()?this.v:`${n}://${this.v}`},hasProtocol(){const n=this.tk;return n.length>=2&&n[0].t!==kt&&n[1].t===we}}),Y=n=>new U(n);function Cd(n){let{groups:e}=n;const t=e.domain.concat([hn,mn,Ce,gn,yn,bn,kn,Sn,de,no,Cn,wn,xn,Tn,fe,En,ht,Mn]),r=[pn,we,oo,ue,so,An,io,lo,nn,rn,dt,ft,Zt,Yt,en,tn,on,sn,ln,an,cn,un,dn,fn],o=[hn,pn,mn,gn,yn,bn,kn,Sn,de,dt,ft,Cn,wn,xn,Tn,An,fe,En,ht,Mn],s=Y(),i=k(s,ht);T(i,o,i),T(i,e.domain,i);const l=Y(),a=Y(),c=Y();T(s,e.domain,l),T(s,e.scheme,a),T(s,e.slashscheme,c),T(l,o,i),T(l,e.domain,l);const u=k(l,Ce);k(i,Ce,u),k(a,Ce,u),k(c,Ce,u);const d=k(i,ue);T(d,o,i),T(d,e.domain,i);const f=Y();T(u,e.domain,f),T(f,e.domain,f);const h=k(f,ue);T(h,e.domain,f);const p=Y(Yo);T(h,e.tld,p),T(h,e.utld,p),k(u,kt,p);const m=k(f,de);T(m,e.domain,f),T(p,e.domain,f),k(p,ue,h),k(p,de,m);const g=k(p,we);T(g,e.numeric,Yo);const y=k(l,de),M=k(l,ue);T(y,e.domain,l),T(M,o,i),T(M,e.domain,l);const A=Y(It);T(M,e.tld,A),T(M,e.utld,A),T(A,e.domain,l),T(A,o,i),k(A,ue,M),k(A,de,y),k(A,Ce,u);const J=k(A,we),I=Y(It);T(J,e.numeric,I);const E=Y(It),z=Y();T(E,t,E),T(E,r,z),T(z,t,E),T(z,r,z),k(A,fe,E),k(I,fe,E);const ce=k(a,we),ji=k(c,we),Wi=k(ji,fe),Hn=k(Wi,fe);T(a,e.domain,l),k(a,ue,M),k(a,de,y),T(c,e.domain,l),k(c,ue,M),k(c,de,y),T(ce,e.domain,E),k(ce,fe,E),T(Hn,e.domain,E),T(Hn,t,E),k(Hn,fe,E);const uo=[[dt,ft],[Yt,Zt],[en,tn],[nn,rn],[on,sn],[ln,an],[cn,un],[dn,fn]];for(let $n=0;$n<uo.length;$n++){const[fo,Fn]=uo[$n],Tt=k(E,fo);k(z,fo,Tt),k(Tt,Fn,E);const Ke=Y(It);T(Tt,t,Ke);const st=Y();T(Tt,r),T(Ke,t,Ke),T(Ke,r,st),T(st,t,Ke),T(st,r,st),k(Ke,Fn,E),k(st,Fn,E)}return k(s,kt,A),k(s,ro,Sd),{start:s,tokens:Ni}}function wd(n,e,t){let r=t.length,o=0,s=[],i=[];for(;o<r;){let l=n,a=null,c=null,u=0,d=null,f=-1;for(;o<r&&!(a=l.go(t[o].t));)i.push(t[o++]);for(;o<r&&(c=a||l.go(t[o].t));)a=null,l=c,l.accepts()?(f=0,d=l):f>=0&&f++,o++,u++;if(f<0)o-=u,o<r&&(i.push(t[o]),o++);else{i.length>0&&(s.push(ir(Zo,e,i)),i=[]),o-=f,u-=f;const h=d.t,p=t.slice(o-u,o);s.push(ir(h,e,p))}}return i.length>0&&s.push(ir(Zo,e,i)),s}function ir(n,e,t){const r=t[0].s,o=t[t.length-1].e,s=e.slice(r,o);return new n(s,t)}const xd=typeof console<"u"&&console&&console.warn||(()=>{}),Td="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",O={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function Ad(){U.groups={},O.scanner=null,O.parser=null,O.tokenQueue=[],O.pluginQueue=[],O.customSchemes=[],O.initialized=!1}function es(n,e){if(e===void 0&&(e=!1),O.initialized&&xd(`linkifyjs: already initialized - will not register custom scheme "${n}" ${Td}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(n))throw new Error(`linkifyjs: incorrect scheme format.
13
+ `)),i.setMeta("paste",!0),n.dispatch(i),!0}}})]}}),ed=P.create({name:"doc",topNode:!0,content:"block+"}),td=P.create({name:"hardBreak",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:n}){return["br",O(this.options.HTMLAttributes,n)]},renderText(){return`
14
+ `},addCommands(){return{setHardBreak:()=>({commands:n,chain:e,state:t,editor:r})=>n.first([()=>n.exitCode(),()=>n.command(()=>{const{selection:o,storedMarks:s}=t;if(o.$from.parent.type.spec.isolating)return!1;const{keepMarks:i}=this.options,{splittableMarks:l}=r.extensionManager,a=s||o.$to.parentOffset&&o.$from.marks();return e().insertContent({type:this.name}).command(({tr:c,dispatch:u})=>{if(u&&a&&i){const d=a.filter(f=>l.includes(f.type.name));c.ensureMarks(d)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),nd=P.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(n=>({tag:`h${n}`,attrs:{level:n}}))},renderHTML({node:n,HTMLAttributes:e}){return[`h${this.options.levels.includes(n.attrs.level)?n.attrs.level:this.options.levels[0]}`,O(this.options.HTMLAttributes,e),0]},addCommands(){return{setHeading:n=>({commands:e})=>this.options.levels.includes(n.level)?e.setNode(this.name,n):!1,toggleHeading:n=>({commands:e})=>this.options.levels.includes(n.level)?e.toggleNode(this.name,"paragraph",n):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((n,e)=>({...n,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}),{})},addInputRules(){return this.options.levels.map(n=>xr({find:new RegExp(`^(#{1,${n}})\\s$`),type:this.type,getAttributes:{level:n}}))}}),rd=P.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{}}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:n}){return["hr",O(this.options.HTMLAttributes,n)]},addCommands(){return{setHorizontalRule:()=>({chain:n,state:e})=>{const{$to:t}=e.selection,r=n();return t.parentOffset===0?r.insertContentAt(Math.max(t.pos-2,0),{type:this.name}):r.insertContent({type:this.name}),r.command(({tr:o,dispatch:s})=>{var i;if(s){const{$to:l}=o.selection,a=l.end();if(l.nodeAfter)l.nodeAfter.isTextblock?o.setSelection(w.create(o.doc,l.pos+1)):l.nodeAfter.isBlock?o.setSelection(C.create(o.doc,l.pos)):o.setSelection(w.create(o.doc,l.pos));else{const c=(i=l.parent.type.contentMatch.defaultType)===null||i===void 0?void 0:i.create();c&&(o.insert(a,c),o.setSelection(w.create(o.doc,a+1)))}o.scrollIntoView()}return!0}).run()}}},addInputRules(){return[vu({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),od=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,sd=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,id=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,ld=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,ad=se.create({name:"italic",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"em"},{tag:"i",getAttrs:n=>n.style.fontStyle!=="normal"&&null},{style:"font-style=italic"}]},renderHTML({HTMLAttributes:n}){return["em",O(this.options.HTMLAttributes,n),0]},addCommands(){return{setItalic:()=>({commands:n})=>n.setMark(this.name),toggleItalic:()=>({commands:n})=>n.toggleMark(this.name),unsetItalic:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[tt({find:od,type:this.type}),tt({find:id,type:this.type})]},addPasteRules(){return[He({find:sd,type:this.type}),He({find:ld,type:this.type})]}}),cd="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4vianca6w0s2x0a2z0ure5ba0by2idu3namex3narepublic11d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2ntley5rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0cast4mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dabur3d1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0ardian6cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6logistics9properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3ncaster6d0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2psy3ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2tura4vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9dnavy5lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0america6xi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0a1b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp2w2ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4finity6ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",ud="ελ1υ2бг1ел3дети4ею2католик6ом3мкд2он1сква6онлайн5рг3рус2ф2сайт3рб3укр3қаз3հայ3ישראל5קום3ابوظبي5رامكو5لاردن4بحرين5جزائر5سعودية6عليان5مغرب5مارات5یران5بارت2زار4يتك3ھارت5تونس4سودان3رية5شبكة4عراق2ب2مان4فلسطين6قطر3كاثوليك6وم3مصر2ليسيا5وريتانيا7قع4همراه5پاکستان7ڀارت4कॉम3नेट3भारत0म्3ोत5संगठन5বাংলা5ভারত2ৰত4ਭਾਰਤ4ભારત4ଭାରତ4இந்தியா6லங்கை6சிங்கப்பூர்11భారత్5ಭಾರತ4ഭാരതം5ලංකා4คอม3ไทย3ລາວ3გე2みんな3アマゾン4クラウド4グーグル4コム2ストア3セール3ファッション6ポイント4世界2中信1国1國1文网3亚马逊3企业2佛山2信息2健康2八卦2公司1益2台湾1灣2商城1店1标2嘉里0大酒店5在线2大拿2天主教3娱乐2家電2广东2微博2慈善2我爱你3手机2招聘2政务1府2新加坡2闻2时尚2書籍2机构2淡马锡3游戏2澳門2点看2移动2组织机构4网址1店1站1络2联通2谷歌2购物2通販2集团2電訊盈科4飞利浦3食品2餐厅2香格里拉3港2닷넷1컴2삼성2한국2",nt=(n,e)=>{for(const t in e)n[t]=e[t];return n},Tr="numeric",Ar="ascii",Mr="alpha",Ht="asciinumeric",Nt="alphanumeric",Er="domain",Ai="emoji",dd="scheme",fd="slashscheme",Jo="whitespace";function hd(n,e){return n in e||(e[n]=[]),e[n]}function ze(n,e,t){e[Tr]&&(e[Ht]=!0,e[Nt]=!0),e[Ar]&&(e[Ht]=!0,e[Mr]=!0),e[Ht]&&(e[Nt]=!0),e[Mr]&&(e[Nt]=!0),e[Nt]&&(e[Er]=!0),e[Ai]&&(e[Er]=!0);for(const r in e){const o=hd(r,t);o.indexOf(n)<0&&o.push(n)}}function pd(n,e){const t={};for(const r in e)e[r].indexOf(n)>=0&&(t[r]=!0);return t}function U(n){n===void 0&&(n=null),this.j={},this.jr=[],this.jd=null,this.t=n}U.groups={};U.prototype={accepts(){return!!this.t},go(n){const e=this,t=e.j[n];if(t)return t;for(let r=0;r<e.jr.length;r++){const o=e.jr[r][0],s=e.jr[r][1];if(s&&o.test(n))return s}return e.jd},has(n,e){return e===void 0&&(e=!1),e?n in this.j:!!this.go(n)},ta(n,e,t,r){for(let o=0;o<n.length;o++)this.tt(n[o],e,t,r)},tr(n,e,t,r){r=r||U.groups;let o;return e&&e.j?o=e:(o=new U(e),t&&r&&ze(e,t,r)),this.jr.push([n,o]),o},ts(n,e,t,r){let o=this;const s=n.length;if(!s)return o;for(let i=0;i<s-1;i++)o=o.tt(n[i]);return o.tt(n[s-1],e,t,r)},tt(n,e,t,r){r=r||U.groups;const o=this;if(e&&e.j)return o.j[n]=e,e;const s=e;let i,l=o.go(n);if(l?(i=new U,nt(i.j,l.j),i.jr.push.apply(i.jr,l.jr),i.jd=l.jd,i.t=l.t):i=new U,s){if(r)if(i.t&&typeof i.t=="string"){const a=nt(pd(i.t,r),t);ze(s,a,r)}else t&&ze(s,t,r);i.t=s}return o.j[n]=i,i}};const T=(n,e,t,r,o)=>n.ta(e,t,r,o),X=(n,e,t,r,o)=>n.tr(e,t,r,o),Uo=(n,e,t,r,o)=>n.ts(e,t,r,o),k=(n,e,t,r,o)=>n.tt(e,t,r,o),ye="WORD",Nr="UWORD",kt="LOCALHOST",Rr="TLD",Or="UTLD",$t="SCHEME",_e="SLASH_SCHEME",no="NUM",Mi="WS",ro="NL",dt="OPENBRACE",ft="CLOSEBRACE",Yt="OPENBRACKET",Zt="CLOSEBRACKET",en="OPENPAREN",tn="CLOSEPAREN",nn="OPENANGLEBRACKET",rn="CLOSEANGLEBRACKET",on="FULLWIDTHLEFTPAREN",sn="FULLWIDTHRIGHTPAREN",ln="LEFTCORNERBRACKET",an="RIGHTCORNERBRACKET",cn="LEFTWHITECORNERBRACKET",un="RIGHTWHITECORNERBRACKET",dn="FULLWIDTHLESSTHAN",fn="FULLWIDTHGREATERTHAN",hn="AMPERSAND",pn="APOSTROPHE",mn="ASTERISK",Ce="AT",gn="BACKSLASH",yn="BACKTICK",bn="CARET",we="COLON",oo="COMMA",kn="DOLLAR",ue="DOT",Sn="EQUALS",so="EXCLAMATION",de="HYPHEN",Cn="PERCENT",wn="PIPE",xn="PLUS",Tn="POUND",An="QUERY",io="QUOTE",lo="SEMI",fe="SLASH",ht="TILDE",Mn="UNDERSCORE",Ei="EMOJI",En="SYM";var Ni=Object.freeze({__proto__:null,WORD:ye,UWORD:Nr,LOCALHOST:kt,TLD:Rr,UTLD:Or,SCHEME:$t,SLASH_SCHEME:_e,NUM:no,WS:Mi,NL:ro,OPENBRACE:dt,CLOSEBRACE:ft,OPENBRACKET:Yt,CLOSEBRACKET:Zt,OPENPAREN:en,CLOSEPAREN:tn,OPENANGLEBRACKET:nn,CLOSEANGLEBRACKET:rn,FULLWIDTHLEFTPAREN:on,FULLWIDTHRIGHTPAREN:sn,LEFTCORNERBRACKET:ln,RIGHTCORNERBRACKET:an,LEFTWHITECORNERBRACKET:cn,RIGHTWHITECORNERBRACKET:un,FULLWIDTHLESSTHAN:dn,FULLWIDTHGREATERTHAN:fn,AMPERSAND:hn,APOSTROPHE:pn,ASTERISK:mn,AT:Ce,BACKSLASH:gn,BACKTICK:yn,CARET:bn,COLON:we,COMMA:oo,DOLLAR:kn,DOT:ue,EQUALS:Sn,EXCLAMATION:so,HYPHEN:de,PERCENT:Cn,PIPE:wn,PLUS:xn,POUND:Tn,QUERY:An,QUOTE:io,SEMI:lo,SLASH:fe,TILDE:ht,UNDERSCORE:Mn,EMOJI:Ei,SYM:En});const qe=/[a-z]/,rr=new RegExp("\\p{L}","u"),or=new RegExp("\\p{Emoji}","u"),sr=/\d/,_o=/\s/,Go=`
15
+ `,md="️",gd="‍";let Rt=null,Ot=null;function yd(n){n===void 0&&(n=[]);const e={};U.groups=e;const t=new U;Rt==null&&(Rt=Qo(cd)),Ot==null&&(Ot=Qo(ud)),k(t,"'",pn),k(t,"{",dt),k(t,"}",ft),k(t,"[",Yt),k(t,"]",Zt),k(t,"(",en),k(t,")",tn),k(t,"<",nn),k(t,">",rn),k(t,"(",on),k(t,")",sn),k(t,"「",ln),k(t,"」",an),k(t,"『",cn),k(t,"』",un),k(t,"<",dn),k(t,">",fn),k(t,"&",hn),k(t,"*",mn),k(t,"@",Ce),k(t,"`",yn),k(t,"^",bn),k(t,":",we),k(t,",",oo),k(t,"$",kn),k(t,".",ue),k(t,"=",Sn),k(t,"!",so),k(t,"-",de),k(t,"%",Cn),k(t,"|",wn),k(t,"+",xn),k(t,"#",Tn),k(t,"?",An),k(t,'"',io),k(t,"/",fe),k(t,";",lo),k(t,"~",ht),k(t,"_",Mn),k(t,"\\",gn);const r=X(t,sr,no,{[Tr]:!0});X(r,sr,r);const o=X(t,qe,ye,{[Ar]:!0});X(o,qe,o);const s=X(t,rr,Nr,{[Mr]:!0});X(s,qe),X(s,rr,s);const i=X(t,_o,Mi,{[Jo]:!0});k(t,Go,ro,{[Jo]:!0}),k(i,Go),X(i,_o,i);const l=X(t,or,Ei,{[Ai]:!0});X(l,or,l),k(l,md,l);const a=k(l,gd);X(a,or,l);const c=[[qe,o]],u=[[qe,null],[rr,s]];for(let d=0;d<Rt.length;d++)ke(t,Rt[d],Rr,ye,c);for(let d=0;d<Ot.length;d++)ke(t,Ot[d],Or,Nr,u);ze(Rr,{tld:!0,ascii:!0},e),ze(Or,{utld:!0,alpha:!0},e),ke(t,"file",$t,ye,c),ke(t,"mailto",$t,ye,c),ke(t,"http",_e,ye,c),ke(t,"https",_e,ye,c),ke(t,"ftp",_e,ye,c),ke(t,"ftps",_e,ye,c),ze($t,{scheme:!0,ascii:!0},e),ze(_e,{slashscheme:!0,ascii:!0},e),n=n.sort((d,f)=>d[0]>f[0]?1:-1);for(let d=0;d<n.length;d++){const f=n[d][0],p=n[d][1]?{[dd]:!0}:{[fd]:!0};f.indexOf("-")>=0?p[Er]=!0:qe.test(f)?sr.test(f)?p[Ht]=!0:p[Ar]=!0:p[Tr]=!0,Uo(t,f,f,p)}return Uo(t,"localhost",kt,{ascii:!0}),t.jd=new U(En),{start:t,tokens:nt({groups:e},Ni)}}function bd(n,e){const t=kd(e.replace(/[A-Z]/g,l=>l.toLowerCase())),r=t.length,o=[];let s=0,i=0;for(;i<r;){let l=n,a=null,c=0,u=null,d=-1,f=-1;for(;i<r&&(a=l.go(t[i]));)l=a,l.accepts()?(d=0,f=0,u=l):d>=0&&(d+=t[i].length,f++),c+=t[i].length,s+=t[i].length,i++;s-=d,i-=f,c-=d,o.push({t:u.t,v:e.slice(s-c,s),s:s-c,e:s})}return o}function kd(n){const e=[],t=n.length;let r=0;for(;r<t;){let o=n.charCodeAt(r),s,i=o<55296||o>56319||r+1===t||(s=n.charCodeAt(r+1))<56320||s>57343?n[r]:n.slice(r,r+2);e.push(i),r+=i.length}return e}function ke(n,e,t,r,o){let s;const i=e.length;for(let l=0;l<i-1;l++){const a=e[l];n.j[a]?s=n.j[a]:(s=new U(r),s.jr=o.slice(),n.j[a]=s),n=s}return s=new U(t),s.jr=o.slice(),n.j[e[i-1]]=s,s}function Qo(n){const e=[],t=[];let r=0,o="0123456789";for(;r<n.length;){let s=0;for(;o.indexOf(n[r+s])>=0;)s++;if(s>0){e.push(t.join(""));for(let i=parseInt(n.substring(r,r+s),10);i>0;i--)t.pop();r+=s}else t.push(n[r]),r++}return e}const St={defaultProtocol:"http",events:null,format:Xo,formatHref:Xo,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function ao(n,e){e===void 0&&(e=null);let t=nt({},St);n&&(t=nt(t,n instanceof ao?n.o:n));const r=t.ignoreTags,o=[];for(let s=0;s<r.length;s++)o.push(r[s].toUpperCase());this.o=t,e&&(this.defaultRender=e),this.ignoreTags=o}ao.prototype={o:St,ignoreTags:[],defaultRender(n){return n},check(n){return this.get("validate",n.toString(),n)},get(n,e,t){const r=e!=null;let o=this.o[n];return o&&(typeof o=="object"?(o=t.t in o?o[t.t]:St[n],typeof o=="function"&&r&&(o=o(e,t))):typeof o=="function"&&r&&(o=o(e,t.t,t)),o)},getObj(n,e,t){let r=this.o[n];return typeof r=="function"&&e!=null&&(r=r(e,t.t,t)),r},render(n){const e=n.render(this);return(this.get("render",null,n)||this.defaultRender)(e,n.t,n)}};function Xo(n){return n}function Ri(n,e){this.t="token",this.v=n,this.tk=e}Ri.prototype={isLink:!1,toString(){return this.v},toHref(n){return this.toString()},toFormattedString(n){const e=this.toString(),t=n.get("truncate",e,this),r=n.get("format",e,this);return t&&r.length>t?r.substring(0,t)+"…":r},toFormattedHref(n){return n.get("formatHref",this.toHref(n.get("defaultProtocol")),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(n){return n===void 0&&(n=St.defaultProtocol),{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(n),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(n){return{type:this.t,value:this.toFormattedString(n),isLink:this.isLink,href:this.toFormattedHref(n),start:this.startIndex(),end:this.endIndex()}},validate(n){return n.get("validate",this.toString(),this)},render(n){const e=this,t=this.toHref(n.get("defaultProtocol")),r=n.get("formatHref",t,this),o=n.get("tagName",t,e),s=this.toFormattedString(n),i={},l=n.get("className",t,e),a=n.get("target",t,e),c=n.get("rel",t,e),u=n.getObj("attributes",t,e),d=n.getObj("events",t,e);return i.href=r,l&&(i.class=l),a&&(i.target=a),c&&(i.rel=c),u&&nt(i,u),{tagName:o,attributes:i,content:s,eventListeners:d}}};function Dn(n,e){class t extends Ri{constructor(o,s){super(o,s),this.t=n}}for(const r in e)t.prototype[r]=e[r];return t.t=n,t}const Yo=Dn("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),Zo=Dn("text"),Sd=Dn("nl"),It=Dn("url",{isLink:!0,toHref(n){return n===void 0&&(n=St.defaultProtocol),this.hasProtocol()?this.v:`${n}://${this.v}`},hasProtocol(){const n=this.tk;return n.length>=2&&n[0].t!==kt&&n[1].t===we}}),Y=n=>new U(n);function Cd(n){let{groups:e}=n;const t=e.domain.concat([hn,mn,Ce,gn,yn,bn,kn,Sn,de,no,Cn,wn,xn,Tn,fe,En,ht,Mn]),r=[pn,we,oo,ue,so,An,io,lo,nn,rn,dt,ft,Zt,Yt,en,tn,on,sn,ln,an,cn,un,dn,fn],o=[hn,pn,mn,gn,yn,bn,kn,Sn,de,dt,ft,Cn,wn,xn,Tn,An,fe,En,ht,Mn],s=Y(),i=k(s,ht);T(i,o,i),T(i,e.domain,i);const l=Y(),a=Y(),c=Y();T(s,e.domain,l),T(s,e.scheme,a),T(s,e.slashscheme,c),T(l,o,i),T(l,e.domain,l);const u=k(l,Ce);k(i,Ce,u),k(a,Ce,u),k(c,Ce,u);const d=k(i,ue);T(d,o,i),T(d,e.domain,i);const f=Y();T(u,e.domain,f),T(f,e.domain,f);const h=k(f,ue);T(h,e.domain,f);const p=Y(Yo);T(h,e.tld,p),T(h,e.utld,p),k(u,kt,p);const m=k(f,de);T(m,e.domain,f),T(p,e.domain,f),k(p,ue,h),k(p,de,m);const g=k(p,we);T(g,e.numeric,Yo);const y=k(l,de),M=k(l,ue);T(y,e.domain,l),T(M,o,i),T(M,e.domain,l);const A=Y(It);T(M,e.tld,A),T(M,e.utld,A),T(A,e.domain,l),T(A,o,i),k(A,ue,M),k(A,de,y),k(A,Ce,u);const K=k(A,we),N=Y(It);T(K,e.numeric,N);const E=Y(It),z=Y();T(E,t,E),T(E,r,z),T(z,t,E),T(z,r,z),k(A,fe,E),k(N,fe,E);const ce=k(a,we),ji=k(c,we),Wi=k(ji,fe),Hn=k(Wi,fe);T(a,e.domain,l),k(a,ue,M),k(a,de,y),T(c,e.domain,l),k(c,ue,M),k(c,de,y),T(ce,e.domain,E),k(ce,fe,E),T(Hn,e.domain,E),T(Hn,t,E),k(Hn,fe,E);const uo=[[dt,ft],[Yt,Zt],[en,tn],[nn,rn],[on,sn],[ln,an],[cn,un],[dn,fn]];for(let $n=0;$n<uo.length;$n++){const[fo,Fn]=uo[$n],Tt=k(E,fo);k(z,fo,Tt),k(Tt,Fn,E);const Ke=Y(It);T(Tt,t,Ke);const st=Y();T(Tt,r),T(Ke,t,Ke),T(Ke,r,st),T(st,t,Ke),T(st,r,st),k(Ke,Fn,E),k(st,Fn,E)}return k(s,kt,A),k(s,ro,Sd),{start:s,tokens:Ni}}function wd(n,e,t){let r=t.length,o=0,s=[],i=[];for(;o<r;){let l=n,a=null,c=null,u=0,d=null,f=-1;for(;o<r&&!(a=l.go(t[o].t));)i.push(t[o++]);for(;o<r&&(c=a||l.go(t[o].t));)a=null,l=c,l.accepts()?(f=0,d=l):f>=0&&f++,o++,u++;if(f<0)o-=u,o<r&&(i.push(t[o]),o++);else{i.length>0&&(s.push(ir(Zo,e,i)),i=[]),o-=f,u-=f;const h=d.t,p=t.slice(o-u,o);s.push(ir(h,e,p))}}return i.length>0&&s.push(ir(Zo,e,i)),s}function ir(n,e,t){const r=t[0].s,o=t[t.length-1].e,s=e.slice(r,o);return new n(s,t)}const xd=typeof console<"u"&&console&&console.warn||(()=>{}),Td="until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.",I={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function Ad(){U.groups={},I.scanner=null,I.parser=null,I.tokenQueue=[],I.pluginQueue=[],I.customSchemes=[],I.initialized=!1}function es(n,e){if(e===void 0&&(e=!1),I.initialized&&xd(`linkifyjs: already initialized - will not register custom scheme "${n}" ${Td}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(n))throw new Error(`linkifyjs: incorrect scheme format.
16
16
  1. Must only contain digits, lowercase ASCII letters or "-"
17
17
  2. Cannot start or end with "-"
18
- 3. "-" cannot repeat`);O.customSchemes.push([n,e])}function Md(){O.scanner=yd(O.customSchemes);for(let n=0;n<O.tokenQueue.length;n++)O.tokenQueue[n][1]({scanner:O.scanner});O.parser=Cd(O.scanner.tokens);for(let n=0;n<O.pluginQueue.length;n++)O.pluginQueue[n][1]({scanner:O.scanner,parser:O.parser});O.initialized=!0}function Oi(n){return O.initialized||Md(),wd(O.parser.start,n,bd(O.scanner.start,n))}function Ii(n,e,t){if(e===void 0&&(e=null),t===void 0&&(t=null),e&&typeof e=="object"){if(t)throw Error(`linkifyjs: Invalid link type ${e}; must be a string`);t=e,e=null}const r=new ao(t),o=Oi(n),s=[];for(let i=0;i<o.length;i++){const l=o[i];l.isLink&&(!e||l.t===e)&&r.check(l)&&s.push(l.toFormattedObject(r))}return s}function Ed(n){return n.length===1?n[0].isLink:n.length===3&&n[1].isLink?["()","[]"].includes(n[0].value+n[2].value):!1}function Nd(n){return new ie({key:new te("autolink"),appendTransaction:(e,t,r)=>{const o=e.some(c=>c.docChanged)&&!t.doc.eq(r.doc),s=e.some(c=>c.getMeta("preventAutolink"));if(!o||s)return;const{tr:i}=r,l=ou(t.doc,[...e]);if(du(l).forEach(({newRange:c})=>{const u=iu(r.doc,c,h=>h.isTextblock);let d,f;if(u.length>1?(d=u[0],f=r.doc.textBetween(d.pos,d.pos+d.node.nodeSize,void 0," ")):u.length&&r.doc.textBetween(c.from,c.to," "," ").endsWith(" ")&&(d=u[0],f=r.doc.textBetween(d.pos,c.to,void 0," ")),d&&f){const h=f.split(" ").filter(y=>y!=="");if(h.length<=0)return!1;const p=h[h.length-1],m=d.pos+f.lastIndexOf(p);if(!p)return!1;const g=Oi(p).map(y=>y.toObject());if(!Ed(g))return!1;g.filter(y=>y.isLink).map(y=>({...y,from:m+y.start+1,to:m+y.end+1})).filter(y=>r.schema.marks.code?!r.doc.rangeHasMark(y.from,y.to,r.schema.marks.code):!0).filter(y=>n.validate?n.validate(y.value):!0).forEach(y=>{to(y.from,y.to,r.doc).some(M=>M.mark.type===n.type)||i.addMark(y.from,y.to,n.type.create({href:y.href}))})}}),!!i.steps.length)return i}})}function Rd(n){return new ie({key:new te("handleClickLink"),props:{handleClick:(e,t,r)=>{var o,s;if(n.whenNotEditable&&e.editable||r.button!==0)return!1;let i=r.target;const l=[];for(;i.nodeName!=="DIV";)l.push(i),i=i.parentNode;if(!l.find(f=>f.nodeName==="A"))return!1;const a=au(e.state,n.type.name),c=r.target,u=(o=c==null?void 0:c.href)!==null&&o!==void 0?o:a.href,d=(s=c==null?void 0:c.target)!==null&&s!==void 0?s:a.target;return c&&u?(window.open(u,d),!0):!1}}})}function Od(n){return new ie({key:new te("handlePasteLink"),props:{handlePaste:(e,t,r)=>{const{state:o}=e,{selection:s}=o,{empty:i}=s;if(i)return!1;let l="";r.content.forEach(c=>{l+=c.textContent});const a=Ii(l).find(c=>c.isLink&&c.value===l);return!l||!a?!1:(n.editor.commands.setMark(n.type,{href:a.href}),!0)}}})}const Id=se.create({name:"link",priority:1e3,keepOnSplit:!1,onCreate(){this.options.protocols.forEach(n=>{if(typeof n=="string"){es(n);return}es(n.scheme,n.optionalSlashes)})},onDestroy(){Ad()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,linkOnPaste:!0,autolink:!0,protocols:[],HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},validate:void 0}},addAttributes(){return{href:{default:null},target:{default:this.options.HTMLAttributes.target},rel:{default:this.options.HTMLAttributes.rel},class:{default:this.options.HTMLAttributes.class}}},parseHTML(){return[{tag:'a[href]:not([href *= "javascript:" i])'}]},renderHTML({HTMLAttributes:n}){var e;return!((e=n.href)===null||e===void 0)&&e.startsWith("javascript:")?["a",R(this.options.HTMLAttributes,{...n,href:""}),0]:["a",R(this.options.HTMLAttributes,n),0]},addCommands(){return{setLink:n=>({chain:e})=>e().setMark(this.name,n).setMeta("preventAutolink",!0).run(),toggleLink:n=>({chain:e})=>e().toggleMark(this.name,n,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run(),unsetLink:()=>({chain:n})=>n().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addPasteRules(){return[He({find:n=>{const e=[];if(n){const t=Ii(n).filter(r=>r.isLink);t.length&&t.forEach(r=>e.push({text:r.value,data:{href:r.href},index:r.start}))}return e},type:this.type,getAttributes:n=>{var e;return{href:(e=n.data)===null||e===void 0?void 0:e.href}}})]},addProseMirrorPlugins(){const n=[];return this.options.autolink&&n.push(Nd({type:this.type,validate:this.options.validate})),this.options.openOnClick&&n.push(Rd({type:this.type,whenNotEditable:this.options.openOnClick==="whenNotEditable"})),this.options.linkOnPaste&&n.push(Od({editor:this.editor,type:this.type})),n}}),Ld=P.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:n}){return["li",R(this.options.HTMLAttributes,n),0]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),vd=P.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:n}){return["li",R(this.options.HTMLAttributes,n),0]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),ts=se.create({name:"textStyle",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"span",getAttrs:n=>n.hasAttribute("style")?{}:!1}]},renderHTML({HTMLAttributes:n}){return["span",R(this.options.HTMLAttributes,n),0]},addCommands(){return{removeEmptyTextStyle:()=>({state:n,commands:e})=>{const t=zn(n,this.type);return Object.entries(t).some(([,o])=>!!o)?!0:e.unsetMark(this.name)}}}}),ns=/^(\d+)\.\s$/,Pd=P.create({name:"orderedList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:n=>n.hasAttribute("start")?parseInt(n.getAttribute("start")||"",10):1}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:n}){const{start:e,...t}=n;return e===1?["ol",R(this.options.HTMLAttributes,t),0]:["ol",R(this.options.HTMLAttributes,n),0]},addCommands(){return{toggleOrderedList:()=>({commands:n,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(vd.name,this.editor.getAttributes(ts.name)).run():n.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let n=bt({find:ns,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(n=bt({find:ns,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(ts.name)}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1],editor:this.editor})),[n]}}),zd=P.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:n}){return["p",R(this.options.HTMLAttributes,n),0]},addCommands(){return{setParagraph:()=>({commands:n})=>n.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),Dd=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,Bd=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,Hd=se.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:n=>n.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:n}){return["s",R(this.options.HTMLAttributes,n),0]},addCommands(){return{setStrike:()=>({commands:n})=>n.setMark(this.name),toggleStrike:()=>({commands:n})=>n.toggleMark(this.name),unsetStrike:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[tt({find:Dd,type:this.type})]},addPasteRules(){return[He({find:Bd,type:this.type})]}});var Ir,Lr;if(typeof WeakMap<"u"){let n=new WeakMap;Ir=e=>n.get(e),Lr=(e,t)=>(n.set(e,t),t)}else{const n=[];let t=0;Ir=r=>{for(let o=0;o<n.length;o+=2)if(n[o]==r)return n[o+1]},Lr=(r,o)=>(t==10&&(t=0),n[t++]=r,n[t++]=o)}var L=class{constructor(n,e,t,r){this.width=n,this.height=e,this.map=t,this.problems=r}findCell(n){for(let e=0;e<this.map.length;e++){const t=this.map[e];if(t!=n)continue;const r=e%this.width,o=e/this.width|0;let s=r+1,i=o+1;for(let l=1;s<this.width&&this.map[e+l]==t;l++)s++;for(let l=1;i<this.height&&this.map[e+this.width*l]==t;l++)i++;return{left:r,top:o,right:s,bottom:i}}throw new RangeError(`No cell with offset ${n} found`)}colCount(n){for(let e=0;e<this.map.length;e++)if(this.map[e]==n)return e%this.width;throw new RangeError(`No cell with offset ${n} found`)}nextCell(n,e,t){const{left:r,right:o,top:s,bottom:i}=this.findCell(n);return e=="horiz"?(t<0?r==0:o==this.width)?null:this.map[s*this.width+(t<0?r-1:o)]:(t<0?s==0:i==this.height)?null:this.map[r+this.width*(t<0?s-1:i)]}rectBetween(n,e){const{left:t,right:r,top:o,bottom:s}=this.findCell(n),{left:i,right:l,top:a,bottom:c}=this.findCell(e);return{left:Math.min(t,i),top:Math.min(o,a),right:Math.max(r,l),bottom:Math.max(s,c)}}cellsInRect(n){const e=[],t={};for(let r=n.top;r<n.bottom;r++)for(let o=n.left;o<n.right;o++){const s=r*this.width+o,i=this.map[s];t[i]||(t[i]=!0,!(o==n.left&&o&&this.map[s-1]==i||r==n.top&&r&&this.map[s-this.width]==i)&&e.push(i))}return e}positionAt(n,e,t){for(let r=0,o=0;;r++){const s=o+t.child(r).nodeSize;if(r==n){let i=e+n*this.width;const l=(n+1)*this.width;for(;i<l&&this.map[i]<o;)i++;return i==l?s-1:this.map[i]}o=s}}static get(n){return Ir(n)||Lr(n,$d(n))}};function $d(n){if(n.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+n.type.name);const e=Fd(n),t=n.childCount,r=[];let o=0,s=null;const i=[];for(let c=0,u=e*t;c<u;c++)r[c]=0;for(let c=0,u=0;c<t;c++){const d=n.child(c);u++;for(let p=0;;p++){for(;o<r.length&&r[o]!=0;)o++;if(p==d.childCount)break;const m=d.child(p),{colspan:g,rowspan:y,colwidth:M}=m.attrs;for(let A=0;A<y;A++){if(A+c>=t){(s||(s=[])).push({type:"overlong_rowspan",pos:u,n:y-A});break}const J=o+A*e;for(let I=0;I<g;I++){r[J+I]==0?r[J+I]=u:(s||(s=[])).push({type:"collision",row:c,pos:u,n:g-I});const E=M&&M[I];if(E){const z=(J+I)%e*2,ce=i[z];ce==null||ce!=E&&i[z+1]==1?(i[z]=E,i[z+1]=1):ce==E&&i[z+1]++}}}o+=g,u+=m.nodeSize}const f=(c+1)*e;let h=0;for(;o<f;)r[o++]==0&&h++;h&&(s||(s=[])).push({type:"missing",row:c,n:h}),u++}const l=new L(e,t,r,s);let a=!1;for(let c=0;!a&&c<i.length;c+=2)i[c]!=null&&i[c+1]<t&&(a=!0);return a&&jd(l,i,n),l}function Fd(n){let e=-1,t=!1;for(let r=0;r<n.childCount;r++){const o=n.child(r);let s=0;if(t)for(let i=0;i<r;i++){const l=n.child(i);for(let a=0;a<l.childCount;a++){const c=l.child(a);i+c.attrs.rowspan>r&&(s+=c.attrs.colspan)}}for(let i=0;i<o.childCount;i++){const l=o.child(i);s+=l.attrs.colspan,l.attrs.rowspan>1&&(t=!0)}e==-1?e=s:e!=s&&(e=Math.max(e,s))}return e}function jd(n,e,t){n.problems||(n.problems=[]);const r={};for(let o=0;o<n.map.length;o++){const s=n.map[o];if(r[s])continue;r[s]=!0;const i=t.nodeAt(s);if(!i)throw new RangeError(`No cell with offset ${s} found`);let l=null;const a=i.attrs;for(let c=0;c<a.colspan;c++){const u=(o+c)%n.width,d=e[u*2];d!=null&&(!a.colwidth||a.colwidth[c]!=d)&&((l||(l=Wd(a)))[c]=d)}l&&n.problems.unshift({type:"colwidth mismatch",pos:s,colwidth:l})}}function Wd(n){if(n.colwidth)return n.colwidth.slice();const e=[];for(let t=0;t<n.colspan;t++)e.push(0);return e}function K(n){let e=n.cached.tableNodeTypes;if(!e){e=n.cached.tableNodeTypes={};for(const t in n.nodes){const r=n.nodes[t],o=r.spec.tableRole;o&&(e[o]=r)}}return e}var xe=new te("selectingCells");function ot(n){for(let e=n.depth-1;e>0;e--)if(n.node(e).type.spec.tableRole=="row")return n.node(0).resolve(n.before(e+1));return null}function Kd(n){for(let e=n.depth;e>0;e--){const t=n.node(e).type.spec.tableRole;if(t==="cell"||t==="header_cell")return n.node(e)}return null}function ae(n){const e=n.selection.$head;for(let t=e.depth;t>0;t--)if(e.node(t).type.spec.tableRole=="row")return!0;return!1}function Bn(n){const e=n.selection;if("$anchorCell"in e&&e.$anchorCell)return e.$anchorCell.pos>e.$headCell.pos?e.$anchorCell:e.$headCell;if("node"in e&&e.node&&e.node.type.spec.tableRole=="cell")return e.$anchor;const t=ot(e.$head)||Vd(e.$head);if(t)return t;throw new RangeError(`No cell found around position ${e.head}`)}function Vd(n){for(let e=n.nodeAfter,t=n.pos;e;e=e.firstChild,t++){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return n.doc.resolve(t)}for(let e=n.nodeBefore,t=n.pos;e;e=e.lastChild,t--){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return n.doc.resolve(t-e.nodeSize)}}function vr(n){return n.parent.type.spec.tableRole=="row"&&!!n.nodeAfter}function qd(n){return n.node(0).resolve(n.pos+n.nodeAfter.nodeSize)}function co(n,e){return n.depth==e.depth&&n.pos>=e.start(-1)&&n.pos<=e.end(-1)}function Li(n,e,t){const r=n.node(-1),o=L.get(r),s=n.start(-1),i=o.nextCell(n.pos-s,e,t);return i==null?null:n.node(0).resolve(s+i)}function $e(n,e,t=1){const r={...n,colspan:n.colspan-t};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(e,t),r.colwidth.some(o=>o>0)||(r.colwidth=null)),r}function vi(n,e,t=1){const r={...n,colspan:n.colspan+t};if(r.colwidth){r.colwidth=r.colwidth.slice();for(let o=0;o<t;o++)r.colwidth.splice(e,0,0)}return r}function Jd(n,e,t){const r=K(e.type.schema).header_cell;for(let o=0;o<n.height;o++)if(e.nodeAt(n.map[t+o*n.width]).type!=r)return!1;return!0}var N=class be extends x{constructor(e,t=e){const r=e.node(-1),o=L.get(r),s=e.start(-1),i=o.rectBetween(e.pos-s,t.pos-s),l=e.node(0),a=o.cellsInRect(i).filter(u=>u!=t.pos-s);a.unshift(t.pos-s);const c=a.map(u=>{const d=r.nodeAt(u);if(!d)throw RangeError(`No cell with offset ${u} found`);const f=s+u+1;return new $s(l.resolve(f),l.resolve(f+d.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=e,this.$headCell=t}map(e,t){const r=e.resolve(t.map(this.$anchorCell.pos)),o=e.resolve(t.map(this.$headCell.pos));if(vr(r)&&vr(o)&&co(r,o)){const s=this.$anchorCell.node(-1)!=r.node(-1);return s&&this.isRowSelection()?be.rowSelection(r,o):s&&this.isColSelection()?be.colSelection(r,o):new be(r,o)}return w.between(r,o)}content(){const e=this.$anchorCell.node(-1),t=L.get(e),r=this.$anchorCell.start(-1),o=t.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),s={},i=[];for(let a=o.top;a<o.bottom;a++){const c=[];for(let u=a*t.width+o.left,d=o.left;d<o.right;d++,u++){const f=t.map[u];if(s[f])continue;s[f]=!0;const h=t.findCell(f);let p=e.nodeAt(f);if(!p)throw RangeError(`No cell with offset ${f} found`);const m=o.left-h.left,g=h.right-o.right;if(m>0||g>0){let y=p.attrs;if(m>0&&(y=$e(y,0,m)),g>0&&(y=$e(y,y.colspan-g,g)),h.left<o.left){if(p=p.type.createAndFill(y),!p)throw RangeError(`Could not create cell with attrs ${JSON.stringify(y)}`)}else p=p.type.create(y,p.content)}if(h.top<o.top||h.bottom>o.bottom){const y={...p.attrs,rowspan:Math.min(h.bottom,o.bottom)-Math.max(h.top,o.top)};h.top<o.top?p=p.type.createAndFill(y):p=p.type.create(y,p.content)}c.push(p)}i.push(e.child(a).copy(b.from(c)))}const l=this.isColSelection()&&this.isRowSelection()?e:i;return new S(b.from(l),1,1)}replace(e,t=S.empty){const r=e.steps.length,o=this.ranges;for(let i=0;i<o.length;i++){const{$from:l,$to:a}=o[i],c=e.mapping.slice(r);e.replace(c.map(l.pos),c.map(a.pos),i?S.empty:t)}const s=x.findFrom(e.doc.resolve(e.mapping.slice(r).map(this.to)),-1);s&&e.setSelection(s)}replaceWith(e,t){this.replace(e,new S(b.from(t),0,0))}forEachCell(e){const t=this.$anchorCell.node(-1),r=L.get(t),o=this.$anchorCell.start(-1),s=r.cellsInRect(r.rectBetween(this.$anchorCell.pos-o,this.$headCell.pos-o));for(let i=0;i<s.length;i++)e(t.nodeAt(s[i]),o+s[i])}isColSelection(){const e=this.$anchorCell.index(-1),t=this.$headCell.index(-1);if(Math.min(e,t)>0)return!1;const r=e+this.$anchorCell.nodeAfter.attrs.rowspan,o=t+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(r,o)==this.$headCell.node(-1).childCount}static colSelection(e,t=e){const r=e.node(-1),o=L.get(r),s=e.start(-1),i=o.findCell(e.pos-s),l=o.findCell(t.pos-s),a=e.node(0);return i.top<=l.top?(i.top>0&&(e=a.resolve(s+o.map[i.left])),l.bottom<o.height&&(t=a.resolve(s+o.map[o.width*(o.height-1)+l.right-1]))):(l.top>0&&(t=a.resolve(s+o.map[l.left])),i.bottom<o.height&&(e=a.resolve(s+o.map[o.width*(o.height-1)+i.right-1]))),new be(e,t)}isRowSelection(){const e=this.$anchorCell.node(-1),t=L.get(e),r=this.$anchorCell.start(-1),o=t.colCount(this.$anchorCell.pos-r),s=t.colCount(this.$headCell.pos-r);if(Math.min(o,s)>0)return!1;const i=o+this.$anchorCell.nodeAfter.attrs.colspan,l=s+this.$headCell.nodeAfter.attrs.colspan;return Math.max(i,l)==t.width}eq(e){return e instanceof be&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,t=e){const r=e.node(-1),o=L.get(r),s=e.start(-1),i=o.findCell(e.pos-s),l=o.findCell(t.pos-s),a=e.node(0);return i.left<=l.left?(i.left>0&&(e=a.resolve(s+o.map[i.top*o.width])),l.right<o.width&&(t=a.resolve(s+o.map[o.width*(l.top+1)-1]))):(l.left>0&&(t=a.resolve(s+o.map[l.top*o.width])),i.right<o.width&&(e=a.resolve(s+o.map[o.width*(i.top+1)-1]))),new be(e,t)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,t){return new be(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,r=t){return new be(e.resolve(t),e.resolve(r))}getBookmark(){return new Ud(this.$anchorCell.pos,this.$headCell.pos)}};N.prototype.visible=!1;x.jsonID("cell",N);var Ud=class Pi{constructor(e,t){this.anchor=e,this.head=t}map(e){return new Pi(e.map(this.anchor),e.map(this.head))}resolve(e){const t=e.resolve(this.anchor),r=e.resolve(this.head);return t.parent.type.spec.tableRole=="row"&&r.parent.type.spec.tableRole=="row"&&t.index()<t.parent.childCount&&r.index()<r.parent.childCount&&co(t,r)?new N(t,r):x.near(r,1)}};function _d(n){if(!(n.selection instanceof N))return null;const e=[];return n.selection.forEachCell((t,r)=>{e.push(re.node(r,r+t.nodeSize,{class:"selectedCell"}))}),D.create(n.doc,e)}function Gd({$from:n,$to:e}){if(n.pos==e.pos||n.pos<n.pos-6)return!1;let t=n.pos,r=e.pos,o=n.depth;for(;o>=0&&!(n.after(o+1)<n.end(o));o--,t++);for(let s=e.depth;s>=0&&!(e.before(s+1)>e.start(s));s--,r--);return t==r&&/row|table/.test(n.node(o).type.spec.tableRole)}function Qd({$from:n,$to:e}){let t,r;for(let o=n.depth;o>0;o--){const s=n.node(o);if(s.type.spec.tableRole==="cell"||s.type.spec.tableRole==="header_cell"){t=s;break}}for(let o=e.depth;o>0;o--){const s=e.node(o);if(s.type.spec.tableRole==="cell"||s.type.spec.tableRole==="header_cell"){r=s;break}}return t!==r&&e.parentOffset===0}function Xd(n,e,t){const r=(e||n).selection,o=(e||n).doc;let s,i;if(r instanceof C&&(i=r.node.type.spec.tableRole)){if(i=="cell"||i=="header_cell")s=N.create(o,r.from);else if(i=="row"){const l=o.resolve(r.from+1);s=N.rowSelection(l,l)}else if(!t){const l=L.get(r.node),a=r.from+1,c=a+l.map[l.width*l.height-1];s=N.create(o,a+1,c)}}else r instanceof w&&Gd(r)?s=w.create(o,r.from):r instanceof w&&Qd(r)&&(s=w.create(o,r.$from.start(),r.$from.end()));return s&&(e||(e=n.tr)).setSelection(s),e}var Yd=new te("fix-tables");function zi(n,e,t,r){const o=n.childCount,s=e.childCount;e:for(let i=0,l=0;i<s;i++){const a=e.child(i);for(let c=l,u=Math.min(o,i+3);c<u;c++)if(n.child(c)==a){l=c+1,t+=a.nodeSize;continue e}r(a,t),l<o&&n.child(l).sameMarkup(a)?zi(n.child(l),a,t+1,r):a.nodesBetween(0,a.content.size,r,t+1),t+=a.nodeSize}}function Di(n,e){let t;const r=(o,s)=>{o.type.spec.tableRole=="table"&&(t=Zd(n,o,s,t))};return e?e.doc!=n.doc&&zi(e.doc,n.doc,0,r):n.doc.descendants(r),t}function Zd(n,e,t,r){const o=L.get(e);if(!o.problems)return r;r||(r=n.tr);const s=[];for(let a=0;a<o.height;a++)s.push(0);for(let a=0;a<o.problems.length;a++){const c=o.problems[a];if(c.type=="collision"){const u=e.nodeAt(c.pos);if(!u)continue;const d=u.attrs;for(let f=0;f<d.rowspan;f++)s[c.row+f]+=c.n;r.setNodeMarkup(r.mapping.map(t+1+c.pos),null,$e(d,d.colspan-c.n,c.n))}else if(c.type=="missing")s[c.row]+=c.n;else if(c.type=="overlong_rowspan"){const u=e.nodeAt(c.pos);if(!u)continue;r.setNodeMarkup(r.mapping.map(t+1+c.pos),null,{...u.attrs,rowspan:u.attrs.rowspan-c.n})}else if(c.type=="colwidth mismatch"){const u=e.nodeAt(c.pos);if(!u)continue;r.setNodeMarkup(r.mapping.map(t+1+c.pos),null,{...u.attrs,colwidth:c.colwidth})}}let i,l;for(let a=0;a<s.length;a++)s[a]&&(i==null&&(i=a),l=a);for(let a=0,c=t+1;a<o.height;a++){const u=e.child(a),d=c+u.nodeSize,f=s[a];if(f>0){let h="cell";u.firstChild&&(h=u.firstChild.type.spec.tableRole);const p=[];for(let g=0;g<f;g++){const y=K(n.schema)[h].createAndFill();y&&p.push(y)}const m=(a==0||i==a-1)&&l==a?c+1:d-1;r.insert(r.mapping.map(m),p)}c=d}return r.setMeta(Yd,{fixTables:!0})}function ef(n){if(!n.size)return null;let{content:e,openStart:t,openEnd:r}=n;for(;e.childCount==1&&(t>0&&r>0||e.child(0).type.spec.tableRole=="table");)t--,r--,e=e.child(0).content;const o=e.child(0),s=o.type.spec.tableRole,i=o.type.schema,l=[];if(s=="row")for(let a=0;a<e.childCount;a++){let c=e.child(a).content;const u=a?0:Math.max(0,t-1),d=a<e.childCount-1?0:Math.max(0,r-1);(u||d)&&(c=Pr(K(i).row,new S(c,u,d)).content),l.push(c)}else if(s=="cell"||s=="header_cell")l.push(t||r?Pr(K(i).row,new S(e,t,r)).content:e);else return null;return tf(i,l)}function tf(n,e){const t=[];for(let o=0;o<e.length;o++){const s=e[o];for(let i=s.childCount-1;i>=0;i--){const{rowspan:l,colspan:a}=s.child(i).attrs;for(let c=o;c<o+l;c++)t[c]=(t[c]||0)+a}}let r=0;for(let o=0;o<t.length;o++)r=Math.max(r,t[o]);for(let o=0;o<t.length;o++)if(o>=e.length&&e.push(b.empty),t[o]<r){const s=K(n).cell.createAndFill(),i=[];for(let l=t[o];l<r;l++)i.push(s);e[o]=e[o].append(b.from(i))}return{height:e.length,width:r,rows:e}}function Pr(n,e){const t=n.createAndFill();return new Hs(t).replace(0,t.content.size,e).doc}function nf({width:n,height:e,rows:t},r,o){if(n!=r){const s=[],i=[];for(let l=0;l<t.length;l++){const a=t[l],c=[];for(let u=s[l]||0,d=0;u<r;d++){let f=a.child(d%a.childCount);u+f.attrs.colspan>r&&(f=f.type.createChecked($e(f.attrs,f.attrs.colspan,u+f.attrs.colspan-r),f.content)),c.push(f),u+=f.attrs.colspan;for(let h=1;h<f.attrs.rowspan;h++)s[l+h]=(s[l+h]||0)+f.attrs.colspan}i.push(b.from(c))}t=i,n=r}if(e!=o){const s=[];for(let i=0,l=0;i<o;i++,l++){const a=[],c=t[l%e];for(let u=0;u<c.childCount;u++){let d=c.child(u);i+d.attrs.rowspan>o&&(d=d.type.create({...d.attrs,rowspan:Math.max(1,o-d.attrs.rowspan)},d.content)),a.push(d)}s.push(b.from(a))}t=s,e=o}return{width:n,height:e,rows:t}}function rf(n,e,t,r,o,s,i){const l=n.doc.type.schema,a=K(l);let c,u;if(o>e.width)for(let d=0,f=0;d<e.height;d++){const h=t.child(d);f+=h.nodeSize;const p=[];let m;h.lastChild==null||h.lastChild.type==a.cell?m=c||(c=a.cell.createAndFill()):m=u||(u=a.header_cell.createAndFill());for(let g=e.width;g<o;g++)p.push(m);n.insert(n.mapping.slice(i).map(f-1+r),p)}if(s>e.height){const d=[];for(let p=0,m=(e.height-1)*e.width;p<Math.max(e.width,o);p++){const g=p>=e.width?!1:t.nodeAt(e.map[m+p]).type==a.header_cell;d.push(g?u||(u=a.header_cell.createAndFill()):c||(c=a.cell.createAndFill()))}const f=a.row.create(null,b.from(d)),h=[];for(let p=e.height;p<s;p++)h.push(f);n.insert(n.mapping.slice(i).map(r+t.nodeSize-2),h)}return!!(c||u)}function rs(n,e,t,r,o,s,i,l){if(i==0||i==e.height)return!1;let a=!1;for(let c=o;c<s;c++){const u=i*e.width+c,d=e.map[u];if(e.map[u-e.width]==d){a=!0;const f=t.nodeAt(d),{top:h,left:p}=e.findCell(d);n.setNodeMarkup(n.mapping.slice(l).map(d+r),null,{...f.attrs,rowspan:i-h}),n.insert(n.mapping.slice(l).map(e.positionAt(i,p,t)),f.type.createAndFill({...f.attrs,rowspan:h+f.attrs.rowspan-i})),c+=f.attrs.colspan-1}}return a}function ss(n,e,t,r,o,s,i,l){if(i==0||i==e.width)return!1;let a=!1;for(let c=o;c<s;c++){const u=c*e.width+i,d=e.map[u];if(e.map[u-1]==d){a=!0;const f=t.nodeAt(d),h=e.colCount(d),p=n.mapping.slice(l).map(d+r);n.setNodeMarkup(p,null,$e(f.attrs,i-h,f.attrs.colspan-(i-h))),n.insert(p+f.nodeSize,f.type.createAndFill($e(f.attrs,0,i-h))),c+=f.attrs.rowspan-1}}return a}function is(n,e,t,r,o){let s=t?n.doc.nodeAt(t-1):n.doc;if(!s)throw new Error("No table found");let i=L.get(s);const{top:l,left:a}=r,c=a+o.width,u=l+o.height,d=n.tr;let f=0;function h(){if(s=t?d.doc.nodeAt(t-1):d.doc,!s)throw new Error("No table found");i=L.get(s),f=d.mapping.maps.length}rf(d,i,s,t,c,u,f)&&h(),rs(d,i,s,t,a,c,l,f)&&h(),rs(d,i,s,t,a,c,u,f)&&h(),ss(d,i,s,t,l,u,a,f)&&h(),ss(d,i,s,t,l,u,c,f)&&h();for(let p=l;p<u;p++){const m=i.positionAt(p,a,s),g=i.positionAt(p,c,s);d.replace(d.mapping.slice(f).map(m+t),d.mapping.slice(f).map(g+t),new S(o.rows[p-l],0,0))}h(),d.setSelection(new N(d.doc.resolve(t+i.positionAt(l,a,s)),d.doc.resolve(t+i.positionAt(u-1,c-1,s)))),e(d)}var of=La({ArrowLeft:Lt("horiz",-1),ArrowRight:Lt("horiz",1),ArrowUp:Lt("vert",-1),ArrowDown:Lt("vert",1),"Shift-ArrowLeft":vt("horiz",-1),"Shift-ArrowRight":vt("horiz",1),"Shift-ArrowUp":vt("vert",-1),"Shift-ArrowDown":vt("vert",1),Backspace:Pt,"Mod-Backspace":Pt,Delete:Pt,"Mod-Delete":Pt});function Ft(n,e,t){return t.eq(n.selection)?!1:(e&&e(n.tr.setSelection(t).scrollIntoView()),!0)}function Lt(n,e){return(t,r,o)=>{if(!o)return!1;const s=t.selection;if(s instanceof N)return Ft(t,r,x.near(s.$headCell,e));if(n!="horiz"&&!s.empty)return!1;const i=Bi(o,n,e);if(i==null)return!1;if(n=="horiz")return Ft(t,r,x.near(t.doc.resolve(s.head+e),e));{const l=t.doc.resolve(i),a=Li(l,n,e);let c;return a?c=x.near(a,1):e<0?c=x.near(t.doc.resolve(l.before(-1)),-1):c=x.near(t.doc.resolve(l.after(-1)),1),Ft(t,r,c)}}}function vt(n,e){return(t,r,o)=>{if(!o)return!1;const s=t.selection;let i;if(s instanceof N)i=s;else{const a=Bi(o,n,e);if(a==null)return!1;i=new N(t.doc.resolve(a))}const l=Li(i.$headCell,n,e);return l?Ft(t,r,new N(i.$anchorCell,l)):!1}}function Pt(n,e){const t=n.selection;if(!(t instanceof N))return!1;if(e){const r=n.tr,o=K(n.schema).cell.createAndFill().content;t.forEachCell((s,i)=>{s.content.eq(o)||r.replace(r.mapping.map(i+1),r.mapping.map(i+s.nodeSize-1),new S(o,0,0))}),r.docChanged&&e(r)}return!0}function sf(n,e){const t=n.state.doc,r=ot(t.resolve(e));return r?(n.dispatch(n.state.tr.setSelection(new N(r))),!0):!1}function lf(n,e,t){if(!ae(n.state))return!1;let r=ef(t);const o=n.state.selection;if(o instanceof N){r||(r={width:1,height:1,rows:[b.from(Pr(K(n.state.schema).cell,t))]});const s=o.$anchorCell.node(-1),i=o.$anchorCell.start(-1),l=L.get(s).rectBetween(o.$anchorCell.pos-i,o.$headCell.pos-i);return r=nf(r,l.right-l.left,l.bottom-l.top),is(n.state,n.dispatch,i,l,r),!0}else if(r){const s=Bn(n.state),i=s.start(-1);return is(n.state,n.dispatch,i,L.get(s.node(-1)).findCell(s.pos-i),r),!0}else return!1}function af(n,e){var t;if(e.ctrlKey||e.metaKey)return;const r=ls(n,e.target);let o;if(e.shiftKey&&n.state.selection instanceof N)s(n.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&r&&(o=ot(n.state.selection.$anchor))!=null&&((t=lr(n,e))==null?void 0:t.pos)!=o.pos)s(o,e),e.preventDefault();else if(!r)return;function s(a,c){let u=lr(n,c);const d=xe.getState(n.state)==null;if(!u||!co(a,u))if(d)u=a;else return;const f=new N(a,u);if(d||!n.state.selection.eq(f)){const h=n.state.tr.setSelection(f);d&&h.setMeta(xe,a.pos),n.dispatch(h)}}function i(){n.root.removeEventListener("mouseup",i),n.root.removeEventListener("dragstart",i),n.root.removeEventListener("mousemove",l),xe.getState(n.state)!=null&&n.dispatch(n.state.tr.setMeta(xe,-1))}function l(a){const c=a,u=xe.getState(n.state);let d;if(u!=null)d=n.state.doc.resolve(u);else if(ls(n,c.target)!=r&&(d=lr(n,e),!d))return i();d&&s(d,c)}n.root.addEventListener("mouseup",i),n.root.addEventListener("dragstart",i),n.root.addEventListener("mousemove",l)}function Bi(n,e,t){if(!(n.state.selection instanceof w))return null;const{$head:r}=n.state.selection;for(let o=r.depth-1;o>=0;o--){const s=r.node(o);if((t<0?r.index(o):r.indexAfter(o))!=(t<0?0:s.childCount))return null;if(s.type.spec.tableRole=="cell"||s.type.spec.tableRole=="header_cell"){const l=r.before(o),a=e=="vert"?t>0?"down":"up":t>0?"right":"left";return n.endOfTextblock(a)?l:null}}return null}function ls(n,e){for(;e&&e!=n.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function lr(n,e){const t=n.posAtCoords({left:e.clientX,top:e.clientY});return t&&t?ot(n.state.doc.resolve(t.pos)):null}var cf=class{constructor(e,t){this.node=e,this.cellMinWidth=t,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.colgroup=this.table.appendChild(document.createElement("colgroup")),zr(e,this.colgroup,this.table,t),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type!=this.node.type?!1:(this.node=e,zr(e,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(e){return e.type=="attributes"&&(e.target==this.table||this.colgroup.contains(e.target))}};function zr(n,e,t,r,o,s){var i;let l=0,a=!0,c=e.firstChild;const u=n.firstChild;if(u){for(let d=0,f=0;d<u.childCount;d++){const{colspan:h,colwidth:p}=u.child(d).attrs;for(let m=0;m<h;m++,f++){const g=o==f?s:p&&p[m],y=g?g+"px":"";l+=g||r,g||(a=!1),c?(c.style.width!=y&&(c.style.width=y),c=c.nextSibling):e.appendChild(document.createElement("col")).style.width=y}}for(;c;){const d=c.nextSibling;(i=c.parentNode)==null||i.removeChild(c),c=d}a?(t.style.width=l+"px",t.style.minWidth=""):(t.style.width="",t.style.minWidth=l+"px")}}var ee=new te("tableColumnResizing");function uf({handleWidth:n=5,cellMinWidth:e=25,View:t=cf,lastColumnResizable:r=!0}={}){const o=new ie({key:ee,state:{init(s,i){return o.spec.props.nodeViews[K(i.schema).table.name]=(l,a)=>new t(l,e,a),new df(-1,!1)},apply(s,i){return i.apply(s)}},props:{attributes:s=>{const i=ee.getState(s);return i&&i.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(s,i)=>{ff(s,i,n,e,r)},mouseleave:s=>{hf(s)},mousedown:(s,i)=>{pf(s,i,e)}},decorations:s=>{const i=ee.getState(s);if(i&&i.activeHandle>-1)return Sf(s,i.activeHandle)},nodeViews:{}}});return o}var df=class jt{constructor(e,t){this.activeHandle=e,this.dragging=t}apply(e){const t=this,r=e.getMeta(ee);if(r&&r.setHandle!=null)return new jt(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new jt(t.activeHandle,r.setDragging);if(t.activeHandle>-1&&e.docChanged){let o=e.mapping.map(t.activeHandle,-1);return vr(e.doc.resolve(o))||(o=-1),new jt(o,t.dragging)}return t}};function ff(n,e,t,r,o){const s=ee.getState(n.state);if(s&&!s.dragging){const i=gf(e.target);let l=-1;if(i){const{left:a,right:c}=i.getBoundingClientRect();e.clientX-a<=t?l=as(n,e,"left",t):c-e.clientX<=t&&(l=as(n,e,"right",t))}if(l!=s.activeHandle){if(!o&&l!==-1){const a=n.state.doc.resolve(l),c=a.node(-1),u=L.get(c),d=a.start(-1);if(u.colCount(a.pos-d)+a.nodeAfter.attrs.colspan-1==u.width-1)return}Hi(n,l)}}}function hf(n){const e=ee.getState(n.state);e&&e.activeHandle>-1&&!e.dragging&&Hi(n,-1)}function pf(n,e,t){var r;const o=(r=n.dom.ownerDocument.defaultView)!=null?r:window,s=ee.getState(n.state);if(!s||s.activeHandle==-1||s.dragging)return!1;const i=n.state.doc.nodeAt(s.activeHandle),l=mf(n,s.activeHandle,i.attrs);n.dispatch(n.state.tr.setMeta(ee,{setDragging:{startX:e.clientX,startWidth:l}}));function a(u){o.removeEventListener("mouseup",a),o.removeEventListener("mousemove",c);const d=ee.getState(n.state);d!=null&&d.dragging&&(yf(n,d.activeHandle,cs(d.dragging,u,t)),n.dispatch(n.state.tr.setMeta(ee,{setDragging:null})))}function c(u){if(!u.which)return a(u);const d=ee.getState(n.state);if(d&&d.dragging){const f=cs(d.dragging,u,t);bf(n,d.activeHandle,f,t)}}return o.addEventListener("mouseup",a),o.addEventListener("mousemove",c),e.preventDefault(),!0}function mf(n,e,{colspan:t,colwidth:r}){const o=r&&r[r.length-1];if(o)return o;const s=n.domAtPos(e);let l=s.node.childNodes[s.offset].offsetWidth,a=t;if(r)for(let c=0;c<t;c++)r[c]&&(l-=r[c],a--);return l/a}function gf(n){for(;n&&n.nodeName!="TD"&&n.nodeName!="TH";)n=n.classList&&n.classList.contains("ProseMirror")?null:n.parentNode;return n}function as(n,e,t,r){const o=t=="right"?-r:r,s=n.posAtCoords({left:e.clientX+o,top:e.clientY});if(!s)return-1;const{pos:i}=s,l=ot(n.state.doc.resolve(i));if(!l)return-1;if(t=="right")return l.pos;const a=L.get(l.node(-1)),c=l.start(-1),u=a.map.indexOf(l.pos-c);return u%a.width==0?-1:c+a.map[u-1]}function cs(n,e,t){const r=e.clientX-n.startX;return Math.max(t,n.startWidth+r)}function Hi(n,e){n.dispatch(n.state.tr.setMeta(ee,{setHandle:e}))}function yf(n,e,t){const r=n.state.doc.resolve(e),o=r.node(-1),s=L.get(o),i=r.start(-1),l=s.colCount(r.pos-i)+r.nodeAfter.attrs.colspan-1,a=n.state.tr;for(let c=0;c<s.height;c++){const u=c*s.width+l;if(c&&s.map[u]==s.map[u-s.width])continue;const d=s.map[u],f=o.nodeAt(d).attrs,h=f.colspan==1?0:l-s.colCount(d);if(f.colwidth&&f.colwidth[h]==t)continue;const p=f.colwidth?f.colwidth.slice():kf(f.colspan);p[h]=t,a.setNodeMarkup(i+d,null,{...f,colwidth:p})}a.docChanged&&n.dispatch(a)}function bf(n,e,t,r){const o=n.state.doc.resolve(e),s=o.node(-1),i=o.start(-1),l=L.get(s).colCount(o.pos-i)+o.nodeAfter.attrs.colspan-1;let a=n.domAtPos(o.start(-1)).node;for(;a&&a.nodeName!="TABLE";)a=a.parentNode;a&&zr(s,a.firstChild,a,r,l,t)}function kf(n){return Array(n).fill(0)}function Sf(n,e){const t=[],r=n.doc.resolve(e),o=r.node(-1);if(!o)return D.empty;const s=L.get(o),i=r.start(-1),l=s.colCount(r.pos-i)+r.nodeAfter.attrs.colspan;for(let a=0;a<s.height;a++){const c=l+a*s.width-1;if((l==s.width||s.map[c]!=s.map[c+1])&&(a==0||s.map[c]!=s.map[c-s.width])){const u=s.map[c],d=i+u+o.nodeAt(u).nodeSize-1,f=document.createElement("div");f.className="column-resize-handle",t.push(re.widget(d,f))}}return D.create(n.doc,t)}function ge(n){const e=n.selection,t=Bn(n),r=t.node(-1),o=t.start(-1),s=L.get(r);return{...e instanceof N?s.rectBetween(e.$anchorCell.pos-o,e.$headCell.pos-o):s.findCell(t.pos-o),tableStart:o,map:s,table:r}}function $i(n,{map:e,tableStart:t,table:r},o){let s=o>0?-1:0;Jd(e,r,o+s)&&(s=o==0||o==e.width?null:0);for(let i=0;i<e.height;i++){const l=i*e.width+o;if(o>0&&o<e.width&&e.map[l-1]==e.map[l]){const a=e.map[l],c=r.nodeAt(a);n.setNodeMarkup(n.mapping.map(t+a),null,vi(c.attrs,o-e.colCount(a))),i+=c.attrs.rowspan-1}else{const a=s==null?K(r.type.schema).cell:r.nodeAt(e.map[l+s]).type,c=e.positionAt(i,o,r);n.insert(n.mapping.map(t+c),a.createAndFill())}}return n}function Cf(n,e){if(!ae(n))return!1;if(e){const t=ge(n);e($i(n.tr,t,t.left))}return!0}function wf(n,e){if(!ae(n))return!1;if(e){const t=ge(n);e($i(n.tr,t,t.right))}return!0}function xf(n,{map:e,table:t,tableStart:r},o){const s=n.mapping.maps.length;for(let i=0;i<e.height;){const l=i*e.width+o,a=e.map[l],c=t.nodeAt(a),u=c.attrs;if(o>0&&e.map[l-1]==a||o<e.width-1&&e.map[l+1]==a)n.setNodeMarkup(n.mapping.slice(s).map(r+a),null,$e(u,o-e.colCount(a)));else{const d=n.mapping.slice(s).map(r+a);n.delete(d,d+c.nodeSize)}i+=u.rowspan}}function Tf(n,e){if(!ae(n))return!1;if(e){const t=ge(n),r=n.tr;if(t.left==0&&t.right==t.map.width)return!1;for(let o=t.right-1;xf(r,t,o),o!=t.left;o--){const s=t.tableStart?r.doc.nodeAt(t.tableStart-1):r.doc;if(!s)throw RangeError("No table found");t.table=s,t.map=L.get(s)}e(r)}return!0}function Af(n,e,t){var r;const o=K(e.type.schema).header_cell;for(let s=0;s<n.width;s++)if(((r=e.nodeAt(n.map[s+t*n.width]))==null?void 0:r.type)!=o)return!1;return!0}function Fi(n,{map:e,tableStart:t,table:r},o){var s;let i=t;for(let c=0;c<o;c++)i+=r.child(c).nodeSize;const l=[];let a=o>0?-1:0;Af(e,r,o+a)&&(a=o==0||o==e.height?null:0);for(let c=0,u=e.width*o;c<e.width;c++,u++)if(o>0&&o<e.height&&e.map[u]==e.map[u-e.width]){const d=e.map[u],f=r.nodeAt(d).attrs;n.setNodeMarkup(t+d,null,{...f,rowspan:f.rowspan+1}),c+=f.colspan-1}else{const d=a==null?K(r.type.schema).cell:(s=r.nodeAt(e.map[u+a*e.width]))==null?void 0:s.type,f=d==null?void 0:d.createAndFill();f&&l.push(f)}return n.insert(i,K(r.type.schema).row.create(null,l)),n}function Mf(n,e){if(!ae(n))return!1;if(e){const t=ge(n);e(Fi(n.tr,t,t.top))}return!0}function Ef(n,e){if(!ae(n))return!1;if(e){const t=ge(n);e(Fi(n.tr,t,t.bottom))}return!0}function Nf(n,{map:e,table:t,tableStart:r},o){let s=0;for(let c=0;c<o;c++)s+=t.child(c).nodeSize;const i=s+t.child(o).nodeSize,l=n.mapping.maps.length;n.delete(s+r,i+r);const a=new Set;for(let c=0,u=o*e.width;c<e.width;c++,u++){const d=e.map[u];if(!a.has(d)){if(a.add(d),o>0&&d==e.map[u-e.width]){const f=t.nodeAt(d).attrs;n.setNodeMarkup(n.mapping.slice(l).map(d+r),null,{...f,rowspan:f.rowspan-1}),c+=f.colspan-1}else if(o<e.height&&d==e.map[u+e.width]){const f=t.nodeAt(d),h=f.attrs,p=f.type.create({...h,rowspan:f.attrs.rowspan-1},f.content),m=e.positionAt(o+1,c,t);n.insert(n.mapping.slice(l).map(r+m),p),c+=h.colspan-1}}}}function Rf(n,e){if(!ae(n))return!1;if(e){const t=ge(n),r=n.tr;if(t.top==0&&t.bottom==t.map.height)return!1;for(let o=t.bottom-1;Nf(r,t,o),o!=t.top;o--){const s=t.tableStart?r.doc.nodeAt(t.tableStart-1):r.doc;if(!s)throw RangeError("No table found");t.table=s,t.map=L.get(t.table)}e(r)}return!0}function us(n){const e=n.content;return e.childCount==1&&e.child(0).isTextblock&&e.child(0).childCount==0}function Of({width:n,height:e,map:t},r){let o=r.top*n+r.left,s=o,i=(r.bottom-1)*n+r.left,l=o+(r.right-r.left-1);for(let a=r.top;a<r.bottom;a++){if(r.left>0&&t[s]==t[s-1]||r.right<n&&t[l]==t[l+1])return!0;s+=n,l+=n}for(let a=r.left;a<r.right;a++){if(r.top>0&&t[o]==t[o-n]||r.bottom<e&&t[i]==t[i+n])return!0;o++,i++}return!1}function ds(n,e){const t=n.selection;if(!(t instanceof N)||t.$anchorCell.pos==t.$headCell.pos)return!1;const r=ge(n),{map:o}=r;if(Of(o,r))return!1;if(e){const s=n.tr,i={};let l=b.empty,a,c;for(let u=r.top;u<r.bottom;u++)for(let d=r.left;d<r.right;d++){const f=o.map[u*o.width+d],h=r.table.nodeAt(f);if(!(i[f]||!h))if(i[f]=!0,a==null)a=f,c=h;else{us(h)||(l=l.append(h.content));const p=s.mapping.map(f+r.tableStart);s.delete(p,p+h.nodeSize)}}if(a==null||c==null)return!0;if(s.setNodeMarkup(a+r.tableStart,null,{...vi(c.attrs,c.attrs.colspan,r.right-r.left-c.attrs.colspan),rowspan:r.bottom-r.top}),l.size){const u=a+1+c.content.size,d=us(c)?a+1:u;s.replaceWith(d+r.tableStart,u+r.tableStart,l)}s.setSelection(new N(s.doc.resolve(a+r.tableStart))),e(s)}return!0}function fs(n,e){const t=K(n.schema);return If(({node:r})=>t[r.type.spec.tableRole])(n,e)}function If(n){return(e,t)=>{var r;const o=e.selection;let s,i;if(o instanceof N){if(o.$anchorCell.pos!=o.$headCell.pos)return!1;s=o.$anchorCell.nodeAfter,i=o.$anchorCell.pos}else{if(s=Kd(o.$from),!s)return!1;i=(r=ot(o.$from))==null?void 0:r.pos}if(s==null||i==null||s.attrs.colspan==1&&s.attrs.rowspan==1)return!1;if(t){let l=s.attrs;const a=[],c=l.colwidth;l.rowspan>1&&(l={...l,rowspan:1}),l.colspan>1&&(l={...l,colspan:1});const u=ge(e),d=e.tr;for(let h=0;h<u.right-u.left;h++)a.push(c?{...l,colwidth:c&&c[h]?[c[h]]:null}:l);let f;for(let h=u.top;h<u.bottom;h++){let p=u.map.positionAt(h,u.left,u.table);h==u.top&&(p+=s.nodeSize);for(let m=u.left,g=0;m<u.right;m++,g++)m==u.left&&h==u.top||d.insert(f=d.mapping.map(p+u.tableStart,1),n({node:s,row:h,col:m}).createAndFill(a[g]))}d.setNodeMarkup(i,n({node:s,row:u.top,col:u.left}),a[0]),o instanceof N&&d.setSelection(new N(d.doc.resolve(o.$anchorCell.pos),f?d.doc.resolve(f):void 0)),t(d)}return!0}}function Lf(n,e){return function(t,r){if(!ae(t))return!1;const o=Bn(t);if(o.nodeAfter.attrs[n]===e)return!1;if(r){const s=t.tr;t.selection instanceof N?t.selection.forEachCell((i,l)=>{i.attrs[n]!==e&&s.setNodeMarkup(l,null,{...i.attrs,[n]:e})}):s.setNodeMarkup(o.pos,null,{...o.nodeAfter.attrs,[n]:e}),r(s)}return!0}}function vf(n){return function(e,t){if(!ae(e))return!1;if(t){const r=K(e.schema),o=ge(e),s=e.tr,i=o.map.cellsInRect(n=="column"?{left:o.left,top:0,right:o.right,bottom:o.map.height}:n=="row"?{left:0,top:o.top,right:o.map.width,bottom:o.bottom}:o),l=i.map(a=>o.table.nodeAt(a));for(let a=0;a<i.length;a++)l[a].type==r.header_cell&&s.setNodeMarkup(o.tableStart+i[a],r.cell,l[a].attrs);if(s.steps.length==0)for(let a=0;a<i.length;a++)s.setNodeMarkup(o.tableStart+i[a],r.header_cell,l[a].attrs);t(s)}return!0}}function hs(n,e,t){const r=e.map.cellsInRect({left:0,top:0,right:n=="row"?e.map.width:1,bottom:n=="column"?e.map.height:1});for(let o=0;o<r.length;o++){const s=e.table.nodeAt(r[o]);if(s&&s.type!==t.header_cell)return!1}return!0}function Ct(n,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?vf(n):function(t,r){if(!ae(t))return!1;if(r){const o=K(t.schema),s=ge(t),i=t.tr,l=hs("row",s,o),a=hs("column",s,o),u=(n==="column"?l:n==="row"?a:!1)?1:0,d=n=="column"?{left:0,top:u,right:1,bottom:s.map.height}:n=="row"?{left:u,top:0,right:s.map.width,bottom:1}:s,f=n=="column"?a?o.cell:o.header_cell:n=="row"?l?o.cell:o.header_cell:o.cell;s.map.cellsInRect(d).forEach(h=>{const p=h+s.tableStart,m=i.doc.nodeAt(p);m&&i.setNodeMarkup(p,f,m.attrs)}),r(i)}return!0}}Ct("row",{useDeprecatedLogic:!0});Ct("column",{useDeprecatedLogic:!0});var Pf=Ct("cell",{useDeprecatedLogic:!0});function zf(n,e){if(e<0){const t=n.nodeBefore;if(t)return n.pos-t.nodeSize;for(let r=n.index(-1)-1,o=n.before();r>=0;r--){const s=n.node(-1).child(r),i=s.lastChild;if(i)return o-1-i.nodeSize;o-=s.nodeSize}}else{if(n.index()<n.parent.childCount-1)return n.pos+n.nodeAfter.nodeSize;const t=n.node(-1);for(let r=n.indexAfter(-1),o=n.after();r<t.childCount;r++){const s=t.child(r);if(s.childCount)return o+1;o+=s.nodeSize}}return null}function ps(n){return function(e,t){if(!ae(e))return!1;const r=zf(Bn(e),n);if(r==null)return!1;if(t){const o=e.doc.resolve(r);t(e.tr.setSelection(w.between(o,qd(o))).scrollIntoView())}return!0}}function Df(n,e){const t=n.selection.$anchor;for(let r=t.depth;r>0;r--)if(t.node(r).type.spec.tableRole=="table")return e&&e(n.tr.delete(t.before(r),t.after(r)).scrollIntoView()),!0;return!1}function Bf({allowTableNodeSelection:n=!1}={}){return new ie({key:xe,state:{init(){return null},apply(e,t){const r=e.getMeta(xe);if(r!=null)return r==-1?null:r;if(t==null||!e.docChanged)return t;const{deleted:o,pos:s}=e.mapping.mapResult(t);return o?null:s}},props:{decorations:_d,handleDOMEvents:{mousedown:af},createSelectionBetween(e){return xe.getState(e.state)!=null?e.state.selection:null},handleTripleClick:sf,handleKeyDown:of,handlePaste:lf},appendTransaction(e,t,r){return Xd(r,Di(r,t),n)}})}function ms(n,e,t,r,o,s){let i=0,l=!0,a=e.firstChild;const c=n.firstChild;for(let u=0,d=0;u<c.childCount;u+=1){const{colspan:f,colwidth:h}=c.child(u).attrs;for(let p=0;p<f;p+=1,d+=1){const m=o===d?s:h&&h[p],g=m?`${m}px`:"";i+=m||r,m||(l=!1),a?(a.style.width!==g&&(a.style.width=g),a=a.nextSibling):e.appendChild(document.createElement("col")).style.width=g}}for(;a;){const u=a.nextSibling;a.parentNode.removeChild(a),a=u}l?(t.style.width=`${i}px`,t.style.minWidth=""):(t.style.width="",t.style.minWidth=`${i}px`)}class Hf{constructor(e,t){this.node=e,this.cellMinWidth=t,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.colgroup=this.table.appendChild(document.createElement("colgroup")),ms(e,this.colgroup,this.table,t),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type!==this.node.type?!1:(this.node=e,ms(e,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(e){return e.type==="attributes"&&(e.target===this.table||this.colgroup.contains(e.target))}}function $f(n,e,t,r){let o=0,s=!0;const i=[],l=n.firstChild;if(!l)return{};for(let d=0,f=0;d<l.childCount;d+=1){const{colspan:h,colwidth:p}=l.child(d).attrs;for(let m=0;m<h;m+=1,f+=1){const g=t===f?r:p&&p[m],y=g?`${g}px`:"";o+=g||e,g||(s=!1),i.push(["col",y?{style:`width: ${y}`}:{}])}}const a=s?`${o}px`:"",c=s?"":`${o}px`;return{colgroup:["colgroup",{},...i],tableWidth:a,tableMinWidth:c}}function gs(n,e){return n.createAndFill()}function Ff(n){if(n.cached.tableNodeTypes)return n.cached.tableNodeTypes;const e={};return Object.keys(n.nodes).forEach(t=>{const r=n.nodes[t];r.spec.tableRole&&(e[r.spec.tableRole]=r)}),n.cached.tableNodeTypes=e,e}function jf(n,e,t,r,o){const s=Ff(n),i=[],l=[];for(let c=0;c<t;c+=1){const u=gs(s.cell);if(u&&l.push(u),r){const d=gs(s.header_cell);d&&i.push(d)}}const a=[];for(let c=0;c<e;c+=1)a.push(s.row.createChecked(null,r&&c===0?i:l));return s.table.createChecked(null,a)}function Wf(n){return n instanceof N}const zt=({editor:n})=>{const{selection:e}=n.state;if(!Wf(e))return!1;let t=0;const r=Ci(e.ranges[0].$from,s=>s.type.name==="table");return r==null||r.node.descendants(s=>{if(s.type.name==="table")return!1;["tableCell","tableHeader"].includes(s.type.name)&&(t+=1)}),t===e.ranges.length?(n.commands.deleteTable(),!0):!1},Kf=P.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,handleWidth:5,cellMinWidth:25,View:Hf,lastColumnResizable:!0,allowTableNodeSelection:!1}},content:"tableRow+",tableRole:"table",isolating:!0,group:"block",parseHTML(){return[{tag:"table"}]},renderHTML({node:n,HTMLAttributes:e}){const{colgroup:t,tableWidth:r,tableMinWidth:o}=$f(n,this.options.cellMinWidth);return["table",R(this.options.HTMLAttributes,e,{style:r?`width: ${r}`:`minWidth: ${o}`}),t,["tbody",0]]},addCommands(){return{insertTable:({rows:n=3,cols:e=3,withHeaderRow:t=!0}={})=>({tr:r,dispatch:o,editor:s})=>{const i=jf(s.schema,n,e,t);if(o){const l=r.selection.anchor+1;r.replaceSelectionWith(i).scrollIntoView().setSelection(w.near(r.doc.resolve(l)))}return!0},addColumnBefore:()=>({state:n,dispatch:e})=>Cf(n,e),addColumnAfter:()=>({state:n,dispatch:e})=>wf(n,e),deleteColumn:()=>({state:n,dispatch:e})=>Tf(n,e),addRowBefore:()=>({state:n,dispatch:e})=>Mf(n,e),addRowAfter:()=>({state:n,dispatch:e})=>Ef(n,e),deleteRow:()=>({state:n,dispatch:e})=>Rf(n,e),deleteTable:()=>({state:n,dispatch:e})=>Df(n,e),mergeCells:()=>({state:n,dispatch:e})=>ds(n,e),splitCell:()=>({state:n,dispatch:e})=>fs(n,e),toggleHeaderColumn:()=>({state:n,dispatch:e})=>Ct("column")(n,e),toggleHeaderRow:()=>({state:n,dispatch:e})=>Ct("row")(n,e),toggleHeaderCell:()=>({state:n,dispatch:e})=>Pf(n,e),mergeOrSplit:()=>({state:n,dispatch:e})=>ds(n,e)?!0:fs(n,e),setCellAttribute:(n,e)=>({state:t,dispatch:r})=>Lf(n,e)(t,r),goToNextCell:()=>({state:n,dispatch:e})=>ps(1)(n,e),goToPreviousCell:()=>({state:n,dispatch:e})=>ps(-1)(n,e),fixTables:()=>({state:n,dispatch:e})=>(e&&Di(n),!0),setCellSelection:n=>({tr:e,dispatch:t})=>{if(t){const r=N.create(e.doc,n.anchorCell,n.headCell);e.setSelection(r)}return!0}}},addKeyboardShortcuts(){return{Tab:()=>this.editor.commands.goToNextCell()?!0:this.editor.can().addRowAfter()?this.editor.chain().addRowAfter().goToNextCell().run():!1,"Shift-Tab":()=>this.editor.commands.goToPreviousCell(),Backspace:zt,"Mod-Backspace":zt,Delete:zt,"Mod-Delete":zt}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[uf({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],Bf({allowTableNodeSelection:this.options.allowTableNodeSelection})]},extendNodeSchema(n){const e={name:n.name,options:n.options,storage:n.storage};return{tableRole:v(H(n,"tableRole",e))}}}),Vf=P.create({name:"tableCell",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:n=>{const e=n.getAttribute("colwidth");return e?[parseInt(e,10)]:null}}}},tableRole:"cell",isolating:!0,parseHTML(){return[{tag:"td"}]},renderHTML({HTMLAttributes:n}){return["td",R(this.options.HTMLAttributes,n),0]}}),qf=P.create({name:"tableHeader",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:n=>{const e=n.getAttribute("colwidth");return e?[parseInt(e,10)]:null}}}},tableRole:"header_cell",isolating:!0,parseHTML(){return[{tag:"th"}]},renderHTML({HTMLAttributes:n}){return["th",R(this.options.HTMLAttributes,n),0]}}),Jf=P.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:n}){return["tr",R(this.options.HTMLAttributes,n),0]}}),Uf=P.create({name:"text",group:"inline"}),_f=me.create({name:"textAlign",addOptions(){return{types:[],alignments:["left","center","right","justify"],defaultAlignment:"left"}},addGlobalAttributes(){return[{types:this.options.types,attributes:{textAlign:{default:this.options.defaultAlignment,parseHTML:n=>n.style.textAlign||this.options.defaultAlignment,renderHTML:n=>n.textAlign===this.options.defaultAlignment?{}:{style:`text-align: ${n.textAlign}`}}}}]},addCommands(){return{setTextAlign:n=>({commands:e})=>this.options.alignments.includes(n)?this.options.types.map(t=>e.updateAttributes(t,{textAlign:n})).every(t=>t):!1,unsetTextAlign:()=>({commands:n})=>this.options.types.map(e=>n.resetAttributes(e,"textAlign")).every(e=>e)}},addKeyboardShortcuts(){return{"Mod-Shift-l":()=>this.editor.commands.setTextAlign("left"),"Mod-Shift-e":()=>this.editor.commands.setTextAlign("center"),"Mod-Shift-r":()=>this.editor.commands.setTextAlign("right"),"Mod-Shift-j":()=>this.editor.commands.setTextAlign("justify")}}}),Gf=[ed,Uf,zd,td,nd,Zu,Uu,Pd,Ld,Fu,rd,Id,qu,ad,Hd,Qu,Kf,qf,Jf,Vf,_f],Qf=n=>{const{flexibleEditor:e,editorNodes:t,serializers:r,nodes:o,config:s,themeName:i,tokens:l,customTheme:a,remappedAttributes:c}=n,u=Pu(t,e),d=r??[...Gf]??[],f=P.create({name:"relation-block",renderHTML:()=>["relation-block"],render:h=>{var m,g;const{attrs:p}=h;if(p!=null&&p.data){if(!((m=p==null?void 0:p.data)!=null&&m.blocks)){const A={collection:p.collection,item:{...h}};return ne.jsx(po,{block:A,config:s})}const y=(g=p==null?void 0:p.data)==null?void 0:g.blocks,M=y==null?void 0:y.map(A=>({...A,collection:p==null?void 0:p.collection}));return ne.jsx(po,{blocks:M,config:s})}return null}});return d.push(f),u?ne.jsx(Ti,{content:u,serializers:d,renderingNodes:o,themeName:i,tokens:l,customTheme:a,remappedAttributes:c}):null};exports.FlexibleEditorContent=Qf;exports.RenderNodes=Ti;
18
+ 3. "-" cannot repeat`);I.customSchemes.push([n,e])}function Md(){I.scanner=yd(I.customSchemes);for(let n=0;n<I.tokenQueue.length;n++)I.tokenQueue[n][1]({scanner:I.scanner});I.parser=Cd(I.scanner.tokens);for(let n=0;n<I.pluginQueue.length;n++)I.pluginQueue[n][1]({scanner:I.scanner,parser:I.parser});I.initialized=!0}function Oi(n){return I.initialized||Md(),wd(I.parser.start,n,bd(I.scanner.start,n))}function Ii(n,e,t){if(e===void 0&&(e=null),t===void 0&&(t=null),e&&typeof e=="object"){if(t)throw Error(`linkifyjs: Invalid link type ${e}; must be a string`);t=e,e=null}const r=new ao(t),o=Oi(n),s=[];for(let i=0;i<o.length;i++){const l=o[i];l.isLink&&(!e||l.t===e)&&r.check(l)&&s.push(l.toFormattedObject(r))}return s}function Ed(n){return n.length===1?n[0].isLink:n.length===3&&n[1].isLink?["()","[]"].includes(n[0].value+n[2].value):!1}function Nd(n){return new ie({key:new te("autolink"),appendTransaction:(e,t,r)=>{const o=e.some(c=>c.docChanged)&&!t.doc.eq(r.doc),s=e.some(c=>c.getMeta("preventAutolink"));if(!o||s)return;const{tr:i}=r,l=ou(t.doc,[...e]);if(du(l).forEach(({newRange:c})=>{const u=iu(r.doc,c,h=>h.isTextblock);let d,f;if(u.length>1?(d=u[0],f=r.doc.textBetween(d.pos,d.pos+d.node.nodeSize,void 0," ")):u.length&&r.doc.textBetween(c.from,c.to," "," ").endsWith(" ")&&(d=u[0],f=r.doc.textBetween(d.pos,c.to,void 0," ")),d&&f){const h=f.split(" ").filter(y=>y!=="");if(h.length<=0)return!1;const p=h[h.length-1],m=d.pos+f.lastIndexOf(p);if(!p)return!1;const g=Oi(p).map(y=>y.toObject());if(!Ed(g))return!1;g.filter(y=>y.isLink).map(y=>({...y,from:m+y.start+1,to:m+y.end+1})).filter(y=>r.schema.marks.code?!r.doc.rangeHasMark(y.from,y.to,r.schema.marks.code):!0).filter(y=>n.validate?n.validate(y.value):!0).forEach(y=>{to(y.from,y.to,r.doc).some(M=>M.mark.type===n.type)||i.addMark(y.from,y.to,n.type.create({href:y.href}))})}}),!!i.steps.length)return i}})}function Rd(n){return new ie({key:new te("handleClickLink"),props:{handleClick:(e,t,r)=>{var o,s;if(n.whenNotEditable&&e.editable||r.button!==0)return!1;let i=r.target;const l=[];for(;i.nodeName!=="DIV";)l.push(i),i=i.parentNode;if(!l.find(f=>f.nodeName==="A"))return!1;const a=au(e.state,n.type.name),c=r.target,u=(o=c==null?void 0:c.href)!==null&&o!==void 0?o:a.href,d=(s=c==null?void 0:c.target)!==null&&s!==void 0?s:a.target;return c&&u?(window.open(u,d),!0):!1}}})}function Od(n){return new ie({key:new te("handlePasteLink"),props:{handlePaste:(e,t,r)=>{const{state:o}=e,{selection:s}=o,{empty:i}=s;if(i)return!1;let l="";r.content.forEach(c=>{l+=c.textContent});const a=Ii(l).find(c=>c.isLink&&c.value===l);return!l||!a?!1:(n.editor.commands.setMark(n.type,{href:a.href}),!0)}}})}const Id=se.create({name:"link",priority:1e3,keepOnSplit:!1,onCreate(){this.options.protocols.forEach(n=>{if(typeof n=="string"){es(n);return}es(n.scheme,n.optionalSlashes)})},onDestroy(){Ad()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,linkOnPaste:!0,autolink:!0,protocols:[],HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},validate:void 0}},addAttributes(){return{href:{default:null},target:{default:this.options.HTMLAttributes.target},rel:{default:this.options.HTMLAttributes.rel},class:{default:this.options.HTMLAttributes.class}}},parseHTML(){return[{tag:'a[href]:not([href *= "javascript:" i])'}]},renderHTML({HTMLAttributes:n}){var e;return!((e=n.href)===null||e===void 0)&&e.startsWith("javascript:")?["a",O(this.options.HTMLAttributes,{...n,href:""}),0]:["a",O(this.options.HTMLAttributes,n),0]},addCommands(){return{setLink:n=>({chain:e})=>e().setMark(this.name,n).setMeta("preventAutolink",!0).run(),toggleLink:n=>({chain:e})=>e().toggleMark(this.name,n,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run(),unsetLink:()=>({chain:n})=>n().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addPasteRules(){return[He({find:n=>{const e=[];if(n){const t=Ii(n).filter(r=>r.isLink);t.length&&t.forEach(r=>e.push({text:r.value,data:{href:r.href},index:r.start}))}return e},type:this.type,getAttributes:n=>{var e;return{href:(e=n.data)===null||e===void 0?void 0:e.href}}})]},addProseMirrorPlugins(){const n=[];return this.options.autolink&&n.push(Nd({type:this.type,validate:this.options.validate})),this.options.openOnClick&&n.push(Rd({type:this.type,whenNotEditable:this.options.openOnClick==="whenNotEditable"})),this.options.linkOnPaste&&n.push(Od({editor:this.editor,type:this.type})),n}}),Ld=P.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:n}){return["li",O(this.options.HTMLAttributes,n),0]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),vd=P.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:n}){return["li",O(this.options.HTMLAttributes,n),0]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),ts=se.create({name:"textStyle",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"span",getAttrs:n=>n.hasAttribute("style")?{}:!1}]},renderHTML({HTMLAttributes:n}){return["span",O(this.options.HTMLAttributes,n),0]},addCommands(){return{removeEmptyTextStyle:()=>({state:n,commands:e})=>{const t=zn(n,this.type);return Object.entries(t).some(([,o])=>!!o)?!0:e.unsetMark(this.name)}}}}),ns=/^(\d+)\.\s$/,Pd=P.create({name:"orderedList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:n=>n.hasAttribute("start")?parseInt(n.getAttribute("start")||"",10):1}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:n}){const{start:e,...t}=n;return e===1?["ol",O(this.options.HTMLAttributes,t),0]:["ol",O(this.options.HTMLAttributes,n),0]},addCommands(){return{toggleOrderedList:()=>({commands:n,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(vd.name,this.editor.getAttributes(ts.name)).run():n.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let n=bt({find:ns,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(n=bt({find:ns,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(ts.name)}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1],editor:this.editor})),[n]}}),zd=P.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:n}){return["p",O(this.options.HTMLAttributes,n),0]},addCommands(){return{setParagraph:()=>({commands:n})=>n.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),Dd=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,Bd=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,Hd=se.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:n=>n.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:n}){return["s",O(this.options.HTMLAttributes,n),0]},addCommands(){return{setStrike:()=>({commands:n})=>n.setMark(this.name),toggleStrike:()=>({commands:n})=>n.toggleMark(this.name),unsetStrike:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[tt({find:Dd,type:this.type})]},addPasteRules(){return[He({find:Bd,type:this.type})]}});var Ir,Lr;if(typeof WeakMap<"u"){let n=new WeakMap;Ir=e=>n.get(e),Lr=(e,t)=>(n.set(e,t),t)}else{const n=[];let t=0;Ir=r=>{for(let o=0;o<n.length;o+=2)if(n[o]==r)return n[o+1]},Lr=(r,o)=>(t==10&&(t=0),n[t++]=r,n[t++]=o)}var L=class{constructor(n,e,t,r){this.width=n,this.height=e,this.map=t,this.problems=r}findCell(n){for(let e=0;e<this.map.length;e++){const t=this.map[e];if(t!=n)continue;const r=e%this.width,o=e/this.width|0;let s=r+1,i=o+1;for(let l=1;s<this.width&&this.map[e+l]==t;l++)s++;for(let l=1;i<this.height&&this.map[e+this.width*l]==t;l++)i++;return{left:r,top:o,right:s,bottom:i}}throw new RangeError(`No cell with offset ${n} found`)}colCount(n){for(let e=0;e<this.map.length;e++)if(this.map[e]==n)return e%this.width;throw new RangeError(`No cell with offset ${n} found`)}nextCell(n,e,t){const{left:r,right:o,top:s,bottom:i}=this.findCell(n);return e=="horiz"?(t<0?r==0:o==this.width)?null:this.map[s*this.width+(t<0?r-1:o)]:(t<0?s==0:i==this.height)?null:this.map[r+this.width*(t<0?s-1:i)]}rectBetween(n,e){const{left:t,right:r,top:o,bottom:s}=this.findCell(n),{left:i,right:l,top:a,bottom:c}=this.findCell(e);return{left:Math.min(t,i),top:Math.min(o,a),right:Math.max(r,l),bottom:Math.max(s,c)}}cellsInRect(n){const e=[],t={};for(let r=n.top;r<n.bottom;r++)for(let o=n.left;o<n.right;o++){const s=r*this.width+o,i=this.map[s];t[i]||(t[i]=!0,!(o==n.left&&o&&this.map[s-1]==i||r==n.top&&r&&this.map[s-this.width]==i)&&e.push(i))}return e}positionAt(n,e,t){for(let r=0,o=0;;r++){const s=o+t.child(r).nodeSize;if(r==n){let i=e+n*this.width;const l=(n+1)*this.width;for(;i<l&&this.map[i]<o;)i++;return i==l?s-1:this.map[i]}o=s}}static get(n){return Ir(n)||Lr(n,$d(n))}};function $d(n){if(n.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+n.type.name);const e=Fd(n),t=n.childCount,r=[];let o=0,s=null;const i=[];for(let c=0,u=e*t;c<u;c++)r[c]=0;for(let c=0,u=0;c<t;c++){const d=n.child(c);u++;for(let p=0;;p++){for(;o<r.length&&r[o]!=0;)o++;if(p==d.childCount)break;const m=d.child(p),{colspan:g,rowspan:y,colwidth:M}=m.attrs;for(let A=0;A<y;A++){if(A+c>=t){(s||(s=[])).push({type:"overlong_rowspan",pos:u,n:y-A});break}const K=o+A*e;for(let N=0;N<g;N++){r[K+N]==0?r[K+N]=u:(s||(s=[])).push({type:"collision",row:c,pos:u,n:g-N});const E=M&&M[N];if(E){const z=(K+N)%e*2,ce=i[z];ce==null||ce!=E&&i[z+1]==1?(i[z]=E,i[z+1]=1):ce==E&&i[z+1]++}}}o+=g,u+=m.nodeSize}const f=(c+1)*e;let h=0;for(;o<f;)r[o++]==0&&h++;h&&(s||(s=[])).push({type:"missing",row:c,n:h}),u++}const l=new L(e,t,r,s);let a=!1;for(let c=0;!a&&c<i.length;c+=2)i[c]!=null&&i[c+1]<t&&(a=!0);return a&&jd(l,i,n),l}function Fd(n){let e=-1,t=!1;for(let r=0;r<n.childCount;r++){const o=n.child(r);let s=0;if(t)for(let i=0;i<r;i++){const l=n.child(i);for(let a=0;a<l.childCount;a++){const c=l.child(a);i+c.attrs.rowspan>r&&(s+=c.attrs.colspan)}}for(let i=0;i<o.childCount;i++){const l=o.child(i);s+=l.attrs.colspan,l.attrs.rowspan>1&&(t=!0)}e==-1?e=s:e!=s&&(e=Math.max(e,s))}return e}function jd(n,e,t){n.problems||(n.problems=[]);const r={};for(let o=0;o<n.map.length;o++){const s=n.map[o];if(r[s])continue;r[s]=!0;const i=t.nodeAt(s);if(!i)throw new RangeError(`No cell with offset ${s} found`);let l=null;const a=i.attrs;for(let c=0;c<a.colspan;c++){const u=(o+c)%n.width,d=e[u*2];d!=null&&(!a.colwidth||a.colwidth[c]!=d)&&((l||(l=Wd(a)))[c]=d)}l&&n.problems.unshift({type:"colwidth mismatch",pos:s,colwidth:l})}}function Wd(n){if(n.colwidth)return n.colwidth.slice();const e=[];for(let t=0;t<n.colspan;t++)e.push(0);return e}function V(n){let e=n.cached.tableNodeTypes;if(!e){e=n.cached.tableNodeTypes={};for(const t in n.nodes){const r=n.nodes[t],o=r.spec.tableRole;o&&(e[o]=r)}}return e}var xe=new te("selectingCells");function ot(n){for(let e=n.depth-1;e>0;e--)if(n.node(e).type.spec.tableRole=="row")return n.node(0).resolve(n.before(e+1));return null}function Kd(n){for(let e=n.depth;e>0;e--){const t=n.node(e).type.spec.tableRole;if(t==="cell"||t==="header_cell")return n.node(e)}return null}function ae(n){const e=n.selection.$head;for(let t=e.depth;t>0;t--)if(e.node(t).type.spec.tableRole=="row")return!0;return!1}function Bn(n){const e=n.selection;if("$anchorCell"in e&&e.$anchorCell)return e.$anchorCell.pos>e.$headCell.pos?e.$anchorCell:e.$headCell;if("node"in e&&e.node&&e.node.type.spec.tableRole=="cell")return e.$anchor;const t=ot(e.$head)||Vd(e.$head);if(t)return t;throw new RangeError(`No cell found around position ${e.head}`)}function Vd(n){for(let e=n.nodeAfter,t=n.pos;e;e=e.firstChild,t++){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return n.doc.resolve(t)}for(let e=n.nodeBefore,t=n.pos;e;e=e.lastChild,t--){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return n.doc.resolve(t-e.nodeSize)}}function vr(n){return n.parent.type.spec.tableRole=="row"&&!!n.nodeAfter}function qd(n){return n.node(0).resolve(n.pos+n.nodeAfter.nodeSize)}function co(n,e){return n.depth==e.depth&&n.pos>=e.start(-1)&&n.pos<=e.end(-1)}function Li(n,e,t){const r=n.node(-1),o=L.get(r),s=n.start(-1),i=o.nextCell(n.pos-s,e,t);return i==null?null:n.node(0).resolve(s+i)}function $e(n,e,t=1){const r={...n,colspan:n.colspan-t};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(e,t),r.colwidth.some(o=>o>0)||(r.colwidth=null)),r}function vi(n,e,t=1){const r={...n,colspan:n.colspan+t};if(r.colwidth){r.colwidth=r.colwidth.slice();for(let o=0;o<t;o++)r.colwidth.splice(e,0,0)}return r}function Jd(n,e,t){const r=V(e.type.schema).header_cell;for(let o=0;o<n.height;o++)if(e.nodeAt(n.map[t+o*n.width]).type!=r)return!1;return!0}var R=class be extends x{constructor(e,t=e){const r=e.node(-1),o=L.get(r),s=e.start(-1),i=o.rectBetween(e.pos-s,t.pos-s),l=e.node(0),a=o.cellsInRect(i).filter(u=>u!=t.pos-s);a.unshift(t.pos-s);const c=a.map(u=>{const d=r.nodeAt(u);if(!d)throw RangeError(`No cell with offset ${u} found`);const f=s+u+1;return new $s(l.resolve(f),l.resolve(f+d.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=e,this.$headCell=t}map(e,t){const r=e.resolve(t.map(this.$anchorCell.pos)),o=e.resolve(t.map(this.$headCell.pos));if(vr(r)&&vr(o)&&co(r,o)){const s=this.$anchorCell.node(-1)!=r.node(-1);return s&&this.isRowSelection()?be.rowSelection(r,o):s&&this.isColSelection()?be.colSelection(r,o):new be(r,o)}return w.between(r,o)}content(){const e=this.$anchorCell.node(-1),t=L.get(e),r=this.$anchorCell.start(-1),o=t.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),s={},i=[];for(let a=o.top;a<o.bottom;a++){const c=[];for(let u=a*t.width+o.left,d=o.left;d<o.right;d++,u++){const f=t.map[u];if(s[f])continue;s[f]=!0;const h=t.findCell(f);let p=e.nodeAt(f);if(!p)throw RangeError(`No cell with offset ${f} found`);const m=o.left-h.left,g=h.right-o.right;if(m>0||g>0){let y=p.attrs;if(m>0&&(y=$e(y,0,m)),g>0&&(y=$e(y,y.colspan-g,g)),h.left<o.left){if(p=p.type.createAndFill(y),!p)throw RangeError(`Could not create cell with attrs ${JSON.stringify(y)}`)}else p=p.type.create(y,p.content)}if(h.top<o.top||h.bottom>o.bottom){const y={...p.attrs,rowspan:Math.min(h.bottom,o.bottom)-Math.max(h.top,o.top)};h.top<o.top?p=p.type.createAndFill(y):p=p.type.create(y,p.content)}c.push(p)}i.push(e.child(a).copy(b.from(c)))}const l=this.isColSelection()&&this.isRowSelection()?e:i;return new S(b.from(l),1,1)}replace(e,t=S.empty){const r=e.steps.length,o=this.ranges;for(let i=0;i<o.length;i++){const{$from:l,$to:a}=o[i],c=e.mapping.slice(r);e.replace(c.map(l.pos),c.map(a.pos),i?S.empty:t)}const s=x.findFrom(e.doc.resolve(e.mapping.slice(r).map(this.to)),-1);s&&e.setSelection(s)}replaceWith(e,t){this.replace(e,new S(b.from(t),0,0))}forEachCell(e){const t=this.$anchorCell.node(-1),r=L.get(t),o=this.$anchorCell.start(-1),s=r.cellsInRect(r.rectBetween(this.$anchorCell.pos-o,this.$headCell.pos-o));for(let i=0;i<s.length;i++)e(t.nodeAt(s[i]),o+s[i])}isColSelection(){const e=this.$anchorCell.index(-1),t=this.$headCell.index(-1);if(Math.min(e,t)>0)return!1;const r=e+this.$anchorCell.nodeAfter.attrs.rowspan,o=t+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(r,o)==this.$headCell.node(-1).childCount}static colSelection(e,t=e){const r=e.node(-1),o=L.get(r),s=e.start(-1),i=o.findCell(e.pos-s),l=o.findCell(t.pos-s),a=e.node(0);return i.top<=l.top?(i.top>0&&(e=a.resolve(s+o.map[i.left])),l.bottom<o.height&&(t=a.resolve(s+o.map[o.width*(o.height-1)+l.right-1]))):(l.top>0&&(t=a.resolve(s+o.map[l.left])),i.bottom<o.height&&(e=a.resolve(s+o.map[o.width*(o.height-1)+i.right-1]))),new be(e,t)}isRowSelection(){const e=this.$anchorCell.node(-1),t=L.get(e),r=this.$anchorCell.start(-1),o=t.colCount(this.$anchorCell.pos-r),s=t.colCount(this.$headCell.pos-r);if(Math.min(o,s)>0)return!1;const i=o+this.$anchorCell.nodeAfter.attrs.colspan,l=s+this.$headCell.nodeAfter.attrs.colspan;return Math.max(i,l)==t.width}eq(e){return e instanceof be&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,t=e){const r=e.node(-1),o=L.get(r),s=e.start(-1),i=o.findCell(e.pos-s),l=o.findCell(t.pos-s),a=e.node(0);return i.left<=l.left?(i.left>0&&(e=a.resolve(s+o.map[i.top*o.width])),l.right<o.width&&(t=a.resolve(s+o.map[o.width*(l.top+1)-1]))):(l.left>0&&(t=a.resolve(s+o.map[l.top*o.width])),i.right<o.width&&(e=a.resolve(s+o.map[o.width*(i.top+1)-1]))),new be(e,t)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,t){return new be(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,r=t){return new be(e.resolve(t),e.resolve(r))}getBookmark(){return new Ud(this.$anchorCell.pos,this.$headCell.pos)}};R.prototype.visible=!1;x.jsonID("cell",R);var Ud=class Pi{constructor(e,t){this.anchor=e,this.head=t}map(e){return new Pi(e.map(this.anchor),e.map(this.head))}resolve(e){const t=e.resolve(this.anchor),r=e.resolve(this.head);return t.parent.type.spec.tableRole=="row"&&r.parent.type.spec.tableRole=="row"&&t.index()<t.parent.childCount&&r.index()<r.parent.childCount&&co(t,r)?new R(t,r):x.near(r,1)}};function _d(n){if(!(n.selection instanceof R))return null;const e=[];return n.selection.forEachCell((t,r)=>{e.push(re.node(r,r+t.nodeSize,{class:"selectedCell"}))}),D.create(n.doc,e)}function Gd({$from:n,$to:e}){if(n.pos==e.pos||n.pos<n.pos-6)return!1;let t=n.pos,r=e.pos,o=n.depth;for(;o>=0&&!(n.after(o+1)<n.end(o));o--,t++);for(let s=e.depth;s>=0&&!(e.before(s+1)>e.start(s));s--,r--);return t==r&&/row|table/.test(n.node(o).type.spec.tableRole)}function Qd({$from:n,$to:e}){let t,r;for(let o=n.depth;o>0;o--){const s=n.node(o);if(s.type.spec.tableRole==="cell"||s.type.spec.tableRole==="header_cell"){t=s;break}}for(let o=e.depth;o>0;o--){const s=e.node(o);if(s.type.spec.tableRole==="cell"||s.type.spec.tableRole==="header_cell"){r=s;break}}return t!==r&&e.parentOffset===0}function Xd(n,e,t){const r=(e||n).selection,o=(e||n).doc;let s,i;if(r instanceof C&&(i=r.node.type.spec.tableRole)){if(i=="cell"||i=="header_cell")s=R.create(o,r.from);else if(i=="row"){const l=o.resolve(r.from+1);s=R.rowSelection(l,l)}else if(!t){const l=L.get(r.node),a=r.from+1,c=a+l.map[l.width*l.height-1];s=R.create(o,a+1,c)}}else r instanceof w&&Gd(r)?s=w.create(o,r.from):r instanceof w&&Qd(r)&&(s=w.create(o,r.$from.start(),r.$from.end()));return s&&(e||(e=n.tr)).setSelection(s),e}var Yd=new te("fix-tables");function zi(n,e,t,r){const o=n.childCount,s=e.childCount;e:for(let i=0,l=0;i<s;i++){const a=e.child(i);for(let c=l,u=Math.min(o,i+3);c<u;c++)if(n.child(c)==a){l=c+1,t+=a.nodeSize;continue e}r(a,t),l<o&&n.child(l).sameMarkup(a)?zi(n.child(l),a,t+1,r):a.nodesBetween(0,a.content.size,r,t+1),t+=a.nodeSize}}function Di(n,e){let t;const r=(o,s)=>{o.type.spec.tableRole=="table"&&(t=Zd(n,o,s,t))};return e?e.doc!=n.doc&&zi(e.doc,n.doc,0,r):n.doc.descendants(r),t}function Zd(n,e,t,r){const o=L.get(e);if(!o.problems)return r;r||(r=n.tr);const s=[];for(let a=0;a<o.height;a++)s.push(0);for(let a=0;a<o.problems.length;a++){const c=o.problems[a];if(c.type=="collision"){const u=e.nodeAt(c.pos);if(!u)continue;const d=u.attrs;for(let f=0;f<d.rowspan;f++)s[c.row+f]+=c.n;r.setNodeMarkup(r.mapping.map(t+1+c.pos),null,$e(d,d.colspan-c.n,c.n))}else if(c.type=="missing")s[c.row]+=c.n;else if(c.type=="overlong_rowspan"){const u=e.nodeAt(c.pos);if(!u)continue;r.setNodeMarkup(r.mapping.map(t+1+c.pos),null,{...u.attrs,rowspan:u.attrs.rowspan-c.n})}else if(c.type=="colwidth mismatch"){const u=e.nodeAt(c.pos);if(!u)continue;r.setNodeMarkup(r.mapping.map(t+1+c.pos),null,{...u.attrs,colwidth:c.colwidth})}}let i,l;for(let a=0;a<s.length;a++)s[a]&&(i==null&&(i=a),l=a);for(let a=0,c=t+1;a<o.height;a++){const u=e.child(a),d=c+u.nodeSize,f=s[a];if(f>0){let h="cell";u.firstChild&&(h=u.firstChild.type.spec.tableRole);const p=[];for(let g=0;g<f;g++){const y=V(n.schema)[h].createAndFill();y&&p.push(y)}const m=(a==0||i==a-1)&&l==a?c+1:d-1;r.insert(r.mapping.map(m),p)}c=d}return r.setMeta(Yd,{fixTables:!0})}function ef(n){if(!n.size)return null;let{content:e,openStart:t,openEnd:r}=n;for(;e.childCount==1&&(t>0&&r>0||e.child(0).type.spec.tableRole=="table");)t--,r--,e=e.child(0).content;const o=e.child(0),s=o.type.spec.tableRole,i=o.type.schema,l=[];if(s=="row")for(let a=0;a<e.childCount;a++){let c=e.child(a).content;const u=a?0:Math.max(0,t-1),d=a<e.childCount-1?0:Math.max(0,r-1);(u||d)&&(c=Pr(V(i).row,new S(c,u,d)).content),l.push(c)}else if(s=="cell"||s=="header_cell")l.push(t||r?Pr(V(i).row,new S(e,t,r)).content:e);else return null;return tf(i,l)}function tf(n,e){const t=[];for(let o=0;o<e.length;o++){const s=e[o];for(let i=s.childCount-1;i>=0;i--){const{rowspan:l,colspan:a}=s.child(i).attrs;for(let c=o;c<o+l;c++)t[c]=(t[c]||0)+a}}let r=0;for(let o=0;o<t.length;o++)r=Math.max(r,t[o]);for(let o=0;o<t.length;o++)if(o>=e.length&&e.push(b.empty),t[o]<r){const s=V(n).cell.createAndFill(),i=[];for(let l=t[o];l<r;l++)i.push(s);e[o]=e[o].append(b.from(i))}return{height:e.length,width:r,rows:e}}function Pr(n,e){const t=n.createAndFill();return new Hs(t).replace(0,t.content.size,e).doc}function nf({width:n,height:e,rows:t},r,o){if(n!=r){const s=[],i=[];for(let l=0;l<t.length;l++){const a=t[l],c=[];for(let u=s[l]||0,d=0;u<r;d++){let f=a.child(d%a.childCount);u+f.attrs.colspan>r&&(f=f.type.createChecked($e(f.attrs,f.attrs.colspan,u+f.attrs.colspan-r),f.content)),c.push(f),u+=f.attrs.colspan;for(let h=1;h<f.attrs.rowspan;h++)s[l+h]=(s[l+h]||0)+f.attrs.colspan}i.push(b.from(c))}t=i,n=r}if(e!=o){const s=[];for(let i=0,l=0;i<o;i++,l++){const a=[],c=t[l%e];for(let u=0;u<c.childCount;u++){let d=c.child(u);i+d.attrs.rowspan>o&&(d=d.type.create({...d.attrs,rowspan:Math.max(1,o-d.attrs.rowspan)},d.content)),a.push(d)}s.push(b.from(a))}t=s,e=o}return{width:n,height:e,rows:t}}function rf(n,e,t,r,o,s,i){const l=n.doc.type.schema,a=V(l);let c,u;if(o>e.width)for(let d=0,f=0;d<e.height;d++){const h=t.child(d);f+=h.nodeSize;const p=[];let m;h.lastChild==null||h.lastChild.type==a.cell?m=c||(c=a.cell.createAndFill()):m=u||(u=a.header_cell.createAndFill());for(let g=e.width;g<o;g++)p.push(m);n.insert(n.mapping.slice(i).map(f-1+r),p)}if(s>e.height){const d=[];for(let p=0,m=(e.height-1)*e.width;p<Math.max(e.width,o);p++){const g=p>=e.width?!1:t.nodeAt(e.map[m+p]).type==a.header_cell;d.push(g?u||(u=a.header_cell.createAndFill()):c||(c=a.cell.createAndFill()))}const f=a.row.create(null,b.from(d)),h=[];for(let p=e.height;p<s;p++)h.push(f);n.insert(n.mapping.slice(i).map(r+t.nodeSize-2),h)}return!!(c||u)}function rs(n,e,t,r,o,s,i,l){if(i==0||i==e.height)return!1;let a=!1;for(let c=o;c<s;c++){const u=i*e.width+c,d=e.map[u];if(e.map[u-e.width]==d){a=!0;const f=t.nodeAt(d),{top:h,left:p}=e.findCell(d);n.setNodeMarkup(n.mapping.slice(l).map(d+r),null,{...f.attrs,rowspan:i-h}),n.insert(n.mapping.slice(l).map(e.positionAt(i,p,t)),f.type.createAndFill({...f.attrs,rowspan:h+f.attrs.rowspan-i})),c+=f.attrs.colspan-1}}return a}function ss(n,e,t,r,o,s,i,l){if(i==0||i==e.width)return!1;let a=!1;for(let c=o;c<s;c++){const u=c*e.width+i,d=e.map[u];if(e.map[u-1]==d){a=!0;const f=t.nodeAt(d),h=e.colCount(d),p=n.mapping.slice(l).map(d+r);n.setNodeMarkup(p,null,$e(f.attrs,i-h,f.attrs.colspan-(i-h))),n.insert(p+f.nodeSize,f.type.createAndFill($e(f.attrs,0,i-h))),c+=f.attrs.rowspan-1}}return a}function is(n,e,t,r,o){let s=t?n.doc.nodeAt(t-1):n.doc;if(!s)throw new Error("No table found");let i=L.get(s);const{top:l,left:a}=r,c=a+o.width,u=l+o.height,d=n.tr;let f=0;function h(){if(s=t?d.doc.nodeAt(t-1):d.doc,!s)throw new Error("No table found");i=L.get(s),f=d.mapping.maps.length}rf(d,i,s,t,c,u,f)&&h(),rs(d,i,s,t,a,c,l,f)&&h(),rs(d,i,s,t,a,c,u,f)&&h(),ss(d,i,s,t,l,u,a,f)&&h(),ss(d,i,s,t,l,u,c,f)&&h();for(let p=l;p<u;p++){const m=i.positionAt(p,a,s),g=i.positionAt(p,c,s);d.replace(d.mapping.slice(f).map(m+t),d.mapping.slice(f).map(g+t),new S(o.rows[p-l],0,0))}h(),d.setSelection(new R(d.doc.resolve(t+i.positionAt(l,a,s)),d.doc.resolve(t+i.positionAt(u-1,c-1,s)))),e(d)}var of=La({ArrowLeft:Lt("horiz",-1),ArrowRight:Lt("horiz",1),ArrowUp:Lt("vert",-1),ArrowDown:Lt("vert",1),"Shift-ArrowLeft":vt("horiz",-1),"Shift-ArrowRight":vt("horiz",1),"Shift-ArrowUp":vt("vert",-1),"Shift-ArrowDown":vt("vert",1),Backspace:Pt,"Mod-Backspace":Pt,Delete:Pt,"Mod-Delete":Pt});function Ft(n,e,t){return t.eq(n.selection)?!1:(e&&e(n.tr.setSelection(t).scrollIntoView()),!0)}function Lt(n,e){return(t,r,o)=>{if(!o)return!1;const s=t.selection;if(s instanceof R)return Ft(t,r,x.near(s.$headCell,e));if(n!="horiz"&&!s.empty)return!1;const i=Bi(o,n,e);if(i==null)return!1;if(n=="horiz")return Ft(t,r,x.near(t.doc.resolve(s.head+e),e));{const l=t.doc.resolve(i),a=Li(l,n,e);let c;return a?c=x.near(a,1):e<0?c=x.near(t.doc.resolve(l.before(-1)),-1):c=x.near(t.doc.resolve(l.after(-1)),1),Ft(t,r,c)}}}function vt(n,e){return(t,r,o)=>{if(!o)return!1;const s=t.selection;let i;if(s instanceof R)i=s;else{const a=Bi(o,n,e);if(a==null)return!1;i=new R(t.doc.resolve(a))}const l=Li(i.$headCell,n,e);return l?Ft(t,r,new R(i.$anchorCell,l)):!1}}function Pt(n,e){const t=n.selection;if(!(t instanceof R))return!1;if(e){const r=n.tr,o=V(n.schema).cell.createAndFill().content;t.forEachCell((s,i)=>{s.content.eq(o)||r.replace(r.mapping.map(i+1),r.mapping.map(i+s.nodeSize-1),new S(o,0,0))}),r.docChanged&&e(r)}return!0}function sf(n,e){const t=n.state.doc,r=ot(t.resolve(e));return r?(n.dispatch(n.state.tr.setSelection(new R(r))),!0):!1}function lf(n,e,t){if(!ae(n.state))return!1;let r=ef(t);const o=n.state.selection;if(o instanceof R){r||(r={width:1,height:1,rows:[b.from(Pr(V(n.state.schema).cell,t))]});const s=o.$anchorCell.node(-1),i=o.$anchorCell.start(-1),l=L.get(s).rectBetween(o.$anchorCell.pos-i,o.$headCell.pos-i);return r=nf(r,l.right-l.left,l.bottom-l.top),is(n.state,n.dispatch,i,l,r),!0}else if(r){const s=Bn(n.state),i=s.start(-1);return is(n.state,n.dispatch,i,L.get(s.node(-1)).findCell(s.pos-i),r),!0}else return!1}function af(n,e){var t;if(e.ctrlKey||e.metaKey)return;const r=ls(n,e.target);let o;if(e.shiftKey&&n.state.selection instanceof R)s(n.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&r&&(o=ot(n.state.selection.$anchor))!=null&&((t=lr(n,e))==null?void 0:t.pos)!=o.pos)s(o,e),e.preventDefault();else if(!r)return;function s(a,c){let u=lr(n,c);const d=xe.getState(n.state)==null;if(!u||!co(a,u))if(d)u=a;else return;const f=new R(a,u);if(d||!n.state.selection.eq(f)){const h=n.state.tr.setSelection(f);d&&h.setMeta(xe,a.pos),n.dispatch(h)}}function i(){n.root.removeEventListener("mouseup",i),n.root.removeEventListener("dragstart",i),n.root.removeEventListener("mousemove",l),xe.getState(n.state)!=null&&n.dispatch(n.state.tr.setMeta(xe,-1))}function l(a){const c=a,u=xe.getState(n.state);let d;if(u!=null)d=n.state.doc.resolve(u);else if(ls(n,c.target)!=r&&(d=lr(n,e),!d))return i();d&&s(d,c)}n.root.addEventListener("mouseup",i),n.root.addEventListener("dragstart",i),n.root.addEventListener("mousemove",l)}function Bi(n,e,t){if(!(n.state.selection instanceof w))return null;const{$head:r}=n.state.selection;for(let o=r.depth-1;o>=0;o--){const s=r.node(o);if((t<0?r.index(o):r.indexAfter(o))!=(t<0?0:s.childCount))return null;if(s.type.spec.tableRole=="cell"||s.type.spec.tableRole=="header_cell"){const l=r.before(o),a=e=="vert"?t>0?"down":"up":t>0?"right":"left";return n.endOfTextblock(a)?l:null}}return null}function ls(n,e){for(;e&&e!=n.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function lr(n,e){const t=n.posAtCoords({left:e.clientX,top:e.clientY});return t&&t?ot(n.state.doc.resolve(t.pos)):null}var cf=class{constructor(e,t){this.node=e,this.cellMinWidth=t,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.colgroup=this.table.appendChild(document.createElement("colgroup")),zr(e,this.colgroup,this.table,t),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type!=this.node.type?!1:(this.node=e,zr(e,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(e){return e.type=="attributes"&&(e.target==this.table||this.colgroup.contains(e.target))}};function zr(n,e,t,r,o,s){var i;let l=0,a=!0,c=e.firstChild;const u=n.firstChild;if(u){for(let d=0,f=0;d<u.childCount;d++){const{colspan:h,colwidth:p}=u.child(d).attrs;for(let m=0;m<h;m++,f++){const g=o==f?s:p&&p[m],y=g?g+"px":"";l+=g||r,g||(a=!1),c?(c.style.width!=y&&(c.style.width=y),c=c.nextSibling):e.appendChild(document.createElement("col")).style.width=y}}for(;c;){const d=c.nextSibling;(i=c.parentNode)==null||i.removeChild(c),c=d}a?(t.style.width=l+"px",t.style.minWidth=""):(t.style.width="",t.style.minWidth=l+"px")}}var ee=new te("tableColumnResizing");function uf({handleWidth:n=5,cellMinWidth:e=25,View:t=cf,lastColumnResizable:r=!0}={}){const o=new ie({key:ee,state:{init(s,i){return o.spec.props.nodeViews[V(i.schema).table.name]=(l,a)=>new t(l,e,a),new df(-1,!1)},apply(s,i){return i.apply(s)}},props:{attributes:s=>{const i=ee.getState(s);return i&&i.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(s,i)=>{ff(s,i,n,e,r)},mouseleave:s=>{hf(s)},mousedown:(s,i)=>{pf(s,i,e)}},decorations:s=>{const i=ee.getState(s);if(i&&i.activeHandle>-1)return Sf(s,i.activeHandle)},nodeViews:{}}});return o}var df=class jt{constructor(e,t){this.activeHandle=e,this.dragging=t}apply(e){const t=this,r=e.getMeta(ee);if(r&&r.setHandle!=null)return new jt(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new jt(t.activeHandle,r.setDragging);if(t.activeHandle>-1&&e.docChanged){let o=e.mapping.map(t.activeHandle,-1);return vr(e.doc.resolve(o))||(o=-1),new jt(o,t.dragging)}return t}};function ff(n,e,t,r,o){const s=ee.getState(n.state);if(s&&!s.dragging){const i=gf(e.target);let l=-1;if(i){const{left:a,right:c}=i.getBoundingClientRect();e.clientX-a<=t?l=as(n,e,"left",t):c-e.clientX<=t&&(l=as(n,e,"right",t))}if(l!=s.activeHandle){if(!o&&l!==-1){const a=n.state.doc.resolve(l),c=a.node(-1),u=L.get(c),d=a.start(-1);if(u.colCount(a.pos-d)+a.nodeAfter.attrs.colspan-1==u.width-1)return}Hi(n,l)}}}function hf(n){const e=ee.getState(n.state);e&&e.activeHandle>-1&&!e.dragging&&Hi(n,-1)}function pf(n,e,t){var r;const o=(r=n.dom.ownerDocument.defaultView)!=null?r:window,s=ee.getState(n.state);if(!s||s.activeHandle==-1||s.dragging)return!1;const i=n.state.doc.nodeAt(s.activeHandle),l=mf(n,s.activeHandle,i.attrs);n.dispatch(n.state.tr.setMeta(ee,{setDragging:{startX:e.clientX,startWidth:l}}));function a(u){o.removeEventListener("mouseup",a),o.removeEventListener("mousemove",c);const d=ee.getState(n.state);d!=null&&d.dragging&&(yf(n,d.activeHandle,cs(d.dragging,u,t)),n.dispatch(n.state.tr.setMeta(ee,{setDragging:null})))}function c(u){if(!u.which)return a(u);const d=ee.getState(n.state);if(d&&d.dragging){const f=cs(d.dragging,u,t);bf(n,d.activeHandle,f,t)}}return o.addEventListener("mouseup",a),o.addEventListener("mousemove",c),e.preventDefault(),!0}function mf(n,e,{colspan:t,colwidth:r}){const o=r&&r[r.length-1];if(o)return o;const s=n.domAtPos(e);let l=s.node.childNodes[s.offset].offsetWidth,a=t;if(r)for(let c=0;c<t;c++)r[c]&&(l-=r[c],a--);return l/a}function gf(n){for(;n&&n.nodeName!="TD"&&n.nodeName!="TH";)n=n.classList&&n.classList.contains("ProseMirror")?null:n.parentNode;return n}function as(n,e,t,r){const o=t=="right"?-r:r,s=n.posAtCoords({left:e.clientX+o,top:e.clientY});if(!s)return-1;const{pos:i}=s,l=ot(n.state.doc.resolve(i));if(!l)return-1;if(t=="right")return l.pos;const a=L.get(l.node(-1)),c=l.start(-1),u=a.map.indexOf(l.pos-c);return u%a.width==0?-1:c+a.map[u-1]}function cs(n,e,t){const r=e.clientX-n.startX;return Math.max(t,n.startWidth+r)}function Hi(n,e){n.dispatch(n.state.tr.setMeta(ee,{setHandle:e}))}function yf(n,e,t){const r=n.state.doc.resolve(e),o=r.node(-1),s=L.get(o),i=r.start(-1),l=s.colCount(r.pos-i)+r.nodeAfter.attrs.colspan-1,a=n.state.tr;for(let c=0;c<s.height;c++){const u=c*s.width+l;if(c&&s.map[u]==s.map[u-s.width])continue;const d=s.map[u],f=o.nodeAt(d).attrs,h=f.colspan==1?0:l-s.colCount(d);if(f.colwidth&&f.colwidth[h]==t)continue;const p=f.colwidth?f.colwidth.slice():kf(f.colspan);p[h]=t,a.setNodeMarkup(i+d,null,{...f,colwidth:p})}a.docChanged&&n.dispatch(a)}function bf(n,e,t,r){const o=n.state.doc.resolve(e),s=o.node(-1),i=o.start(-1),l=L.get(s).colCount(o.pos-i)+o.nodeAfter.attrs.colspan-1;let a=n.domAtPos(o.start(-1)).node;for(;a&&a.nodeName!="TABLE";)a=a.parentNode;a&&zr(s,a.firstChild,a,r,l,t)}function kf(n){return Array(n).fill(0)}function Sf(n,e){const t=[],r=n.doc.resolve(e),o=r.node(-1);if(!o)return D.empty;const s=L.get(o),i=r.start(-1),l=s.colCount(r.pos-i)+r.nodeAfter.attrs.colspan;for(let a=0;a<s.height;a++){const c=l+a*s.width-1;if((l==s.width||s.map[c]!=s.map[c+1])&&(a==0||s.map[c]!=s.map[c-s.width])){const u=s.map[c],d=i+u+o.nodeAt(u).nodeSize-1,f=document.createElement("div");f.className="column-resize-handle",t.push(re.widget(d,f))}}return D.create(n.doc,t)}function ge(n){const e=n.selection,t=Bn(n),r=t.node(-1),o=t.start(-1),s=L.get(r);return{...e instanceof R?s.rectBetween(e.$anchorCell.pos-o,e.$headCell.pos-o):s.findCell(t.pos-o),tableStart:o,map:s,table:r}}function $i(n,{map:e,tableStart:t,table:r},o){let s=o>0?-1:0;Jd(e,r,o+s)&&(s=o==0||o==e.width?null:0);for(let i=0;i<e.height;i++){const l=i*e.width+o;if(o>0&&o<e.width&&e.map[l-1]==e.map[l]){const a=e.map[l],c=r.nodeAt(a);n.setNodeMarkup(n.mapping.map(t+a),null,vi(c.attrs,o-e.colCount(a))),i+=c.attrs.rowspan-1}else{const a=s==null?V(r.type.schema).cell:r.nodeAt(e.map[l+s]).type,c=e.positionAt(i,o,r);n.insert(n.mapping.map(t+c),a.createAndFill())}}return n}function Cf(n,e){if(!ae(n))return!1;if(e){const t=ge(n);e($i(n.tr,t,t.left))}return!0}function wf(n,e){if(!ae(n))return!1;if(e){const t=ge(n);e($i(n.tr,t,t.right))}return!0}function xf(n,{map:e,table:t,tableStart:r},o){const s=n.mapping.maps.length;for(let i=0;i<e.height;){const l=i*e.width+o,a=e.map[l],c=t.nodeAt(a),u=c.attrs;if(o>0&&e.map[l-1]==a||o<e.width-1&&e.map[l+1]==a)n.setNodeMarkup(n.mapping.slice(s).map(r+a),null,$e(u,o-e.colCount(a)));else{const d=n.mapping.slice(s).map(r+a);n.delete(d,d+c.nodeSize)}i+=u.rowspan}}function Tf(n,e){if(!ae(n))return!1;if(e){const t=ge(n),r=n.tr;if(t.left==0&&t.right==t.map.width)return!1;for(let o=t.right-1;xf(r,t,o),o!=t.left;o--){const s=t.tableStart?r.doc.nodeAt(t.tableStart-1):r.doc;if(!s)throw RangeError("No table found");t.table=s,t.map=L.get(s)}e(r)}return!0}function Af(n,e,t){var r;const o=V(e.type.schema).header_cell;for(let s=0;s<n.width;s++)if(((r=e.nodeAt(n.map[s+t*n.width]))==null?void 0:r.type)!=o)return!1;return!0}function Fi(n,{map:e,tableStart:t,table:r},o){var s;let i=t;for(let c=0;c<o;c++)i+=r.child(c).nodeSize;const l=[];let a=o>0?-1:0;Af(e,r,o+a)&&(a=o==0||o==e.height?null:0);for(let c=0,u=e.width*o;c<e.width;c++,u++)if(o>0&&o<e.height&&e.map[u]==e.map[u-e.width]){const d=e.map[u],f=r.nodeAt(d).attrs;n.setNodeMarkup(t+d,null,{...f,rowspan:f.rowspan+1}),c+=f.colspan-1}else{const d=a==null?V(r.type.schema).cell:(s=r.nodeAt(e.map[u+a*e.width]))==null?void 0:s.type,f=d==null?void 0:d.createAndFill();f&&l.push(f)}return n.insert(i,V(r.type.schema).row.create(null,l)),n}function Mf(n,e){if(!ae(n))return!1;if(e){const t=ge(n);e(Fi(n.tr,t,t.top))}return!0}function Ef(n,e){if(!ae(n))return!1;if(e){const t=ge(n);e(Fi(n.tr,t,t.bottom))}return!0}function Nf(n,{map:e,table:t,tableStart:r},o){let s=0;for(let c=0;c<o;c++)s+=t.child(c).nodeSize;const i=s+t.child(o).nodeSize,l=n.mapping.maps.length;n.delete(s+r,i+r);const a=new Set;for(let c=0,u=o*e.width;c<e.width;c++,u++){const d=e.map[u];if(!a.has(d)){if(a.add(d),o>0&&d==e.map[u-e.width]){const f=t.nodeAt(d).attrs;n.setNodeMarkup(n.mapping.slice(l).map(d+r),null,{...f,rowspan:f.rowspan-1}),c+=f.colspan-1}else if(o<e.height&&d==e.map[u+e.width]){const f=t.nodeAt(d),h=f.attrs,p=f.type.create({...h,rowspan:f.attrs.rowspan-1},f.content),m=e.positionAt(o+1,c,t);n.insert(n.mapping.slice(l).map(r+m),p),c+=h.colspan-1}}}}function Rf(n,e){if(!ae(n))return!1;if(e){const t=ge(n),r=n.tr;if(t.top==0&&t.bottom==t.map.height)return!1;for(let o=t.bottom-1;Nf(r,t,o),o!=t.top;o--){const s=t.tableStart?r.doc.nodeAt(t.tableStart-1):r.doc;if(!s)throw RangeError("No table found");t.table=s,t.map=L.get(t.table)}e(r)}return!0}function us(n){const e=n.content;return e.childCount==1&&e.child(0).isTextblock&&e.child(0).childCount==0}function Of({width:n,height:e,map:t},r){let o=r.top*n+r.left,s=o,i=(r.bottom-1)*n+r.left,l=o+(r.right-r.left-1);for(let a=r.top;a<r.bottom;a++){if(r.left>0&&t[s]==t[s-1]||r.right<n&&t[l]==t[l+1])return!0;s+=n,l+=n}for(let a=r.left;a<r.right;a++){if(r.top>0&&t[o]==t[o-n]||r.bottom<e&&t[i]==t[i+n])return!0;o++,i++}return!1}function ds(n,e){const t=n.selection;if(!(t instanceof R)||t.$anchorCell.pos==t.$headCell.pos)return!1;const r=ge(n),{map:o}=r;if(Of(o,r))return!1;if(e){const s=n.tr,i={};let l=b.empty,a,c;for(let u=r.top;u<r.bottom;u++)for(let d=r.left;d<r.right;d++){const f=o.map[u*o.width+d],h=r.table.nodeAt(f);if(!(i[f]||!h))if(i[f]=!0,a==null)a=f,c=h;else{us(h)||(l=l.append(h.content));const p=s.mapping.map(f+r.tableStart);s.delete(p,p+h.nodeSize)}}if(a==null||c==null)return!0;if(s.setNodeMarkup(a+r.tableStart,null,{...vi(c.attrs,c.attrs.colspan,r.right-r.left-c.attrs.colspan),rowspan:r.bottom-r.top}),l.size){const u=a+1+c.content.size,d=us(c)?a+1:u;s.replaceWith(d+r.tableStart,u+r.tableStart,l)}s.setSelection(new R(s.doc.resolve(a+r.tableStart))),e(s)}return!0}function fs(n,e){const t=V(n.schema);return If(({node:r})=>t[r.type.spec.tableRole])(n,e)}function If(n){return(e,t)=>{var r;const o=e.selection;let s,i;if(o instanceof R){if(o.$anchorCell.pos!=o.$headCell.pos)return!1;s=o.$anchorCell.nodeAfter,i=o.$anchorCell.pos}else{if(s=Kd(o.$from),!s)return!1;i=(r=ot(o.$from))==null?void 0:r.pos}if(s==null||i==null||s.attrs.colspan==1&&s.attrs.rowspan==1)return!1;if(t){let l=s.attrs;const a=[],c=l.colwidth;l.rowspan>1&&(l={...l,rowspan:1}),l.colspan>1&&(l={...l,colspan:1});const u=ge(e),d=e.tr;for(let h=0;h<u.right-u.left;h++)a.push(c?{...l,colwidth:c&&c[h]?[c[h]]:null}:l);let f;for(let h=u.top;h<u.bottom;h++){let p=u.map.positionAt(h,u.left,u.table);h==u.top&&(p+=s.nodeSize);for(let m=u.left,g=0;m<u.right;m++,g++)m==u.left&&h==u.top||d.insert(f=d.mapping.map(p+u.tableStart,1),n({node:s,row:h,col:m}).createAndFill(a[g]))}d.setNodeMarkup(i,n({node:s,row:u.top,col:u.left}),a[0]),o instanceof R&&d.setSelection(new R(d.doc.resolve(o.$anchorCell.pos),f?d.doc.resolve(f):void 0)),t(d)}return!0}}function Lf(n,e){return function(t,r){if(!ae(t))return!1;const o=Bn(t);if(o.nodeAfter.attrs[n]===e)return!1;if(r){const s=t.tr;t.selection instanceof R?t.selection.forEachCell((i,l)=>{i.attrs[n]!==e&&s.setNodeMarkup(l,null,{...i.attrs,[n]:e})}):s.setNodeMarkup(o.pos,null,{...o.nodeAfter.attrs,[n]:e}),r(s)}return!0}}function vf(n){return function(e,t){if(!ae(e))return!1;if(t){const r=V(e.schema),o=ge(e),s=e.tr,i=o.map.cellsInRect(n=="column"?{left:o.left,top:0,right:o.right,bottom:o.map.height}:n=="row"?{left:0,top:o.top,right:o.map.width,bottom:o.bottom}:o),l=i.map(a=>o.table.nodeAt(a));for(let a=0;a<i.length;a++)l[a].type==r.header_cell&&s.setNodeMarkup(o.tableStart+i[a],r.cell,l[a].attrs);if(s.steps.length==0)for(let a=0;a<i.length;a++)s.setNodeMarkup(o.tableStart+i[a],r.header_cell,l[a].attrs);t(s)}return!0}}function hs(n,e,t){const r=e.map.cellsInRect({left:0,top:0,right:n=="row"?e.map.width:1,bottom:n=="column"?e.map.height:1});for(let o=0;o<r.length;o++){const s=e.table.nodeAt(r[o]);if(s&&s.type!==t.header_cell)return!1}return!0}function Ct(n,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?vf(n):function(t,r){if(!ae(t))return!1;if(r){const o=V(t.schema),s=ge(t),i=t.tr,l=hs("row",s,o),a=hs("column",s,o),u=(n==="column"?l:n==="row"?a:!1)?1:0,d=n=="column"?{left:0,top:u,right:1,bottom:s.map.height}:n=="row"?{left:u,top:0,right:s.map.width,bottom:1}:s,f=n=="column"?a?o.cell:o.header_cell:n=="row"?l?o.cell:o.header_cell:o.cell;s.map.cellsInRect(d).forEach(h=>{const p=h+s.tableStart,m=i.doc.nodeAt(p);m&&i.setNodeMarkup(p,f,m.attrs)}),r(i)}return!0}}Ct("row",{useDeprecatedLogic:!0});Ct("column",{useDeprecatedLogic:!0});var Pf=Ct("cell",{useDeprecatedLogic:!0});function zf(n,e){if(e<0){const t=n.nodeBefore;if(t)return n.pos-t.nodeSize;for(let r=n.index(-1)-1,o=n.before();r>=0;r--){const s=n.node(-1).child(r),i=s.lastChild;if(i)return o-1-i.nodeSize;o-=s.nodeSize}}else{if(n.index()<n.parent.childCount-1)return n.pos+n.nodeAfter.nodeSize;const t=n.node(-1);for(let r=n.indexAfter(-1),o=n.after();r<t.childCount;r++){const s=t.child(r);if(s.childCount)return o+1;o+=s.nodeSize}}return null}function ps(n){return function(e,t){if(!ae(e))return!1;const r=zf(Bn(e),n);if(r==null)return!1;if(t){const o=e.doc.resolve(r);t(e.tr.setSelection(w.between(o,qd(o))).scrollIntoView())}return!0}}function Df(n,e){const t=n.selection.$anchor;for(let r=t.depth;r>0;r--)if(t.node(r).type.spec.tableRole=="table")return e&&e(n.tr.delete(t.before(r),t.after(r)).scrollIntoView()),!0;return!1}function Bf({allowTableNodeSelection:n=!1}={}){return new ie({key:xe,state:{init(){return null},apply(e,t){const r=e.getMeta(xe);if(r!=null)return r==-1?null:r;if(t==null||!e.docChanged)return t;const{deleted:o,pos:s}=e.mapping.mapResult(t);return o?null:s}},props:{decorations:_d,handleDOMEvents:{mousedown:af},createSelectionBetween(e){return xe.getState(e.state)!=null?e.state.selection:null},handleTripleClick:sf,handleKeyDown:of,handlePaste:lf},appendTransaction(e,t,r){return Xd(r,Di(r,t),n)}})}function ms(n,e,t,r,o,s){let i=0,l=!0,a=e.firstChild;const c=n.firstChild;for(let u=0,d=0;u<c.childCount;u+=1){const{colspan:f,colwidth:h}=c.child(u).attrs;for(let p=0;p<f;p+=1,d+=1){const m=o===d?s:h&&h[p],g=m?`${m}px`:"";i+=m||r,m||(l=!1),a?(a.style.width!==g&&(a.style.width=g),a=a.nextSibling):e.appendChild(document.createElement("col")).style.width=g}}for(;a;){const u=a.nextSibling;a.parentNode.removeChild(a),a=u}l?(t.style.width=`${i}px`,t.style.minWidth=""):(t.style.width="",t.style.minWidth=`${i}px`)}class Hf{constructor(e,t){this.node=e,this.cellMinWidth=t,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.colgroup=this.table.appendChild(document.createElement("colgroup")),ms(e,this.colgroup,this.table,t),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type!==this.node.type?!1:(this.node=e,ms(e,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(e){return e.type==="attributes"&&(e.target===this.table||this.colgroup.contains(e.target))}}function $f(n,e,t,r){let o=0,s=!0;const i=[],l=n.firstChild;if(!l)return{};for(let d=0,f=0;d<l.childCount;d+=1){const{colspan:h,colwidth:p}=l.child(d).attrs;for(let m=0;m<h;m+=1,f+=1){const g=t===f?r:p&&p[m],y=g?`${g}px`:"";o+=g||e,g||(s=!1),i.push(["col",y?{style:`width: ${y}`}:{}])}}const a=s?`${o}px`:"",c=s?"":`${o}px`;return{colgroup:["colgroup",{},...i],tableWidth:a,tableMinWidth:c}}function gs(n,e){return n.createAndFill()}function Ff(n){if(n.cached.tableNodeTypes)return n.cached.tableNodeTypes;const e={};return Object.keys(n.nodes).forEach(t=>{const r=n.nodes[t];r.spec.tableRole&&(e[r.spec.tableRole]=r)}),n.cached.tableNodeTypes=e,e}function jf(n,e,t,r,o){const s=Ff(n),i=[],l=[];for(let c=0;c<t;c+=1){const u=gs(s.cell);if(u&&l.push(u),r){const d=gs(s.header_cell);d&&i.push(d)}}const a=[];for(let c=0;c<e;c+=1)a.push(s.row.createChecked(null,r&&c===0?i:l));return s.table.createChecked(null,a)}function Wf(n){return n instanceof R}const zt=({editor:n})=>{const{selection:e}=n.state;if(!Wf(e))return!1;let t=0;const r=Ci(e.ranges[0].$from,s=>s.type.name==="table");return r==null||r.node.descendants(s=>{if(s.type.name==="table")return!1;["tableCell","tableHeader"].includes(s.type.name)&&(t+=1)}),t===e.ranges.length?(n.commands.deleteTable(),!0):!1},Kf=P.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,handleWidth:5,cellMinWidth:25,View:Hf,lastColumnResizable:!0,allowTableNodeSelection:!1}},content:"tableRow+",tableRole:"table",isolating:!0,group:"block",parseHTML(){return[{tag:"table"}]},renderHTML({node:n,HTMLAttributes:e}){const{colgroup:t,tableWidth:r,tableMinWidth:o}=$f(n,this.options.cellMinWidth);return["table",O(this.options.HTMLAttributes,e,{style:r?`width: ${r}`:`minWidth: ${o}`}),t,["tbody",0]]},addCommands(){return{insertTable:({rows:n=3,cols:e=3,withHeaderRow:t=!0}={})=>({tr:r,dispatch:o,editor:s})=>{const i=jf(s.schema,n,e,t);if(o){const l=r.selection.anchor+1;r.replaceSelectionWith(i).scrollIntoView().setSelection(w.near(r.doc.resolve(l)))}return!0},addColumnBefore:()=>({state:n,dispatch:e})=>Cf(n,e),addColumnAfter:()=>({state:n,dispatch:e})=>wf(n,e),deleteColumn:()=>({state:n,dispatch:e})=>Tf(n,e),addRowBefore:()=>({state:n,dispatch:e})=>Mf(n,e),addRowAfter:()=>({state:n,dispatch:e})=>Ef(n,e),deleteRow:()=>({state:n,dispatch:e})=>Rf(n,e),deleteTable:()=>({state:n,dispatch:e})=>Df(n,e),mergeCells:()=>({state:n,dispatch:e})=>ds(n,e),splitCell:()=>({state:n,dispatch:e})=>fs(n,e),toggleHeaderColumn:()=>({state:n,dispatch:e})=>Ct("column")(n,e),toggleHeaderRow:()=>({state:n,dispatch:e})=>Ct("row")(n,e),toggleHeaderCell:()=>({state:n,dispatch:e})=>Pf(n,e),mergeOrSplit:()=>({state:n,dispatch:e})=>ds(n,e)?!0:fs(n,e),setCellAttribute:(n,e)=>({state:t,dispatch:r})=>Lf(n,e)(t,r),goToNextCell:()=>({state:n,dispatch:e})=>ps(1)(n,e),goToPreviousCell:()=>({state:n,dispatch:e})=>ps(-1)(n,e),fixTables:()=>({state:n,dispatch:e})=>(e&&Di(n),!0),setCellSelection:n=>({tr:e,dispatch:t})=>{if(t){const r=R.create(e.doc,n.anchorCell,n.headCell);e.setSelection(r)}return!0}}},addKeyboardShortcuts(){return{Tab:()=>this.editor.commands.goToNextCell()?!0:this.editor.can().addRowAfter()?this.editor.chain().addRowAfter().goToNextCell().run():!1,"Shift-Tab":()=>this.editor.commands.goToPreviousCell(),Backspace:zt,"Mod-Backspace":zt,Delete:zt,"Mod-Delete":zt}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[uf({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],Bf({allowTableNodeSelection:this.options.allowTableNodeSelection})]},extendNodeSchema(n){const e={name:n.name,options:n.options,storage:n.storage};return{tableRole:v(H(n,"tableRole",e))}}}),Vf=P.create({name:"tableCell",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:n=>{const e=n.getAttribute("colwidth");return e?[parseInt(e,10)]:null}}}},tableRole:"cell",isolating:!0,parseHTML(){return[{tag:"td"}]},renderHTML({HTMLAttributes:n}){return["td",O(this.options.HTMLAttributes,n),0]}}),qf=P.create({name:"tableHeader",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:n=>{const e=n.getAttribute("colwidth");return e?[parseInt(e,10)]:null}}}},tableRole:"header_cell",isolating:!0,parseHTML(){return[{tag:"th"}]},renderHTML({HTMLAttributes:n}){return["th",O(this.options.HTMLAttributes,n),0]}}),Jf=P.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:n}){return["tr",O(this.options.HTMLAttributes,n),0]}}),Uf=P.create({name:"text",group:"inline"}),_f=me.create({name:"textAlign",addOptions(){return{types:[],alignments:["left","center","right","justify"],defaultAlignment:"left"}},addGlobalAttributes(){return[{types:this.options.types,attributes:{textAlign:{default:this.options.defaultAlignment,parseHTML:n=>n.style.textAlign||this.options.defaultAlignment,renderHTML:n=>n.textAlign===this.options.defaultAlignment?{}:{style:`text-align: ${n.textAlign}`}}}}]},addCommands(){return{setTextAlign:n=>({commands:e})=>this.options.alignments.includes(n)?this.options.types.map(t=>e.updateAttributes(t,{textAlign:n})).every(t=>t):!1,unsetTextAlign:()=>({commands:n})=>this.options.types.map(e=>n.resetAttributes(e,"textAlign")).every(e=>e)}},addKeyboardShortcuts(){return{"Mod-Shift-l":()=>this.editor.commands.setTextAlign("left"),"Mod-Shift-e":()=>this.editor.commands.setTextAlign("center"),"Mod-Shift-r":()=>this.editor.commands.setTextAlign("right"),"Mod-Shift-j":()=>this.editor.commands.setTextAlign("justify")}}}),Gf=[ed,Uf,zd,td,nd,Zu,Uu,Pd,Ld,Fu,rd,Id,qu,ad,Hd,Qu,Kf,qf,Jf,Vf,_f],Qf=n=>{const{jsonContent:e,editorNodes:t,serializers:r,nodes:o,config:s,themeName:i,tokens:l,customTheme:a,remappedAttributes:c}=n,u=Pu(t,e),d=r??[...Gf]??[],f=P.create({name:"relation-block",renderHTML:()=>["relation-block"],render:h=>{var g,y,M;const{attrs:p}=h,m=`${(g=p==null?void 0:p.collection)==null?void 0:g.replace("related_","")}_id`;if(p!=null&&p.data){if(!((y=p==null?void 0:p.data)!=null&&y.blocks)){const N={collection:p.collection,item:{...p==null?void 0:p.data}};return ne.jsx(po,{block:N,config:s},JSON.stringify(N))}const A=(M=p==null?void 0:p.data)==null?void 0:M.blocks,K=A==null?void 0:A.map(N=>({item:N==null?void 0:N[m],collection:p==null?void 0:p.collection}));return ne.jsx(po,{blocks:K,config:s},JSON.stringify(A))}return null}});return d.push(f),u?ne.jsx(Ti,{content:u,serializers:d,renderingNodes:o,themeName:i,tokens:l,customTheme:a,remappedAttributes:c}):null};exports.FlexibleEditorContent=Qf;exports.RenderNodes=Ti;