@okam/directus-flexible-content 1.0.5 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js CHANGED
@@ -1,18 +1,19 @@
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
- `):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 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,`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const le=require("react/jsx-runtime"),vo=require("@tanstack/react-query"),Ut=require("radash"),js=require("graphql-request"),Mr=require("@okam/stack-ui"),Tl=require("react");function Ws(n,e){return e}const Al=process.env.NEXT_PUBLIC_GRAPHQL_URL,Ml=process.env.NEXT_GRAPHQL_URL_ADMIN,El=process.env.NEXT_PUBLIC_API_TOKEN??"",Nl=process.env.NEXT_PUBLIC_API_TOKEN,Ol=new js.GraphQLClient(Al,{credentials:"include",mode:"cors",fetch,headers:{Authorization:`Bearer ${El}`}});new js.GraphQLClient(Ml,{credentials:"include",mode:"cors",fetch,headers:{Authorization:`Bearer ${Nl}`}});new vo.QueryClient({queryCache:new vo.QueryCache({onError:n=>{console.error(n)}}),defaultOptions:{queries:{staleTime:5*1e3}}});function Ks(n,e,t=Ol){return t.request(n,{...e})}process.env.NEXT_PUBLIC_GRAPHQL_URL;process.env.NEXT_PUBLIC_API_TOKEN;function Er(n){return!!n}function Rl(n){const{id:e,settings:t,...r}=n??{};return Ut.isEmpty(r)}async function Il(n){const{document:e,blockKey:t,variables:r}=n;if(!e||!Er(r))return null;const o=await Ks(e,r);return!o||typeof o!="object"||!t?null:o[t]}async function vl(n){const{document:e,item:t,blockKey:r,variables:o}=n;if(t){if(!Rl(t))return t;const l={id:t.id,...o};return Er(l)?Il({...n,variables:l}):null}if(!e||!Er(o))return null;const s=await Ks(e,o);return!s||typeof s!="object"||!r?null:s[r]}function Ll(n,...e){return e.reduce((r,o)=>o?{components:{...r.components,...o.components}}:r,n)}const Js={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"}}]}}]},zl=n=>{var y,g,M;const{item:e,collection:t,config:r,variables:o,defaultVariant:s,...i}=n;if(!t||!r)return null;const l=(y=r==null?void 0:r.components)==null?void 0:y[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}=Ws(Js,a)??{},f=((g=l.getVariant)==null?void 0:g.call(l,n))??u??s,{default:d,document:h}=l,m=((M=l.variants)==null?void 0:M[f??""])??d;return m?le.jsx(m,{document:h,config:r,collection:t,item:e,...c?{variables:{...o,id:c}}:{variables:o},...i},c):null};async function Dl(n,e,t){const r=Ut.get(n,"item"),o=Ut.get(n,"document"),s=Ut.get(n,"variables"),i=await vl({item:r,blockKey:e,document:o,variables:s}),{tokens:l}=Ws(Js,i==null?void 0:i.settings)??{};return{...i,cmsTokens:l}}const Bl=async n=>{const e="block_wysiwyg_by_id",{themeName:t="wysiwyg",tokens:r}=n,{content:o,title:s,level:i,cmsTokens:l}=await Dl(n,e);return!o&&!(s&&i)?null:le.jsxs(le.Fragment,{children:[s&&i&&le.jsx(Mr.Box,{as:"span",themeName:t,tokens:{...r,...l},children:Tl.createElement(i,{},s)}),o&&le.jsx(Mr.WysiwygBlock,{themeName:t,tokens:{...r,...l},content:o})]})},Pl={block_wysiwyg:{default:n=>le.jsx(Bl,{...n})}},Hl={components:{...Pl}},Lo=n=>{const{children:e,config:t,...r}=n,o=Ll(Hl,t),s=l=>e?e({...r,...l,config:o}):le.jsx(zl,{...r,...l,config:o});if("blocks"in n){const{blocks:l}=n;return l.map(s)}const{block:i}=n;return s(i)};function K(n){this.content=n}K.prototype={constructor:K,find:function(n){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===n)return e;return-1},get:function(n){var e=this.find(n);return e==-1?void 0:this.content[e+1]},update:function(n,e,t){var r=t&&t!=n?this.remove(t):this,o=r.find(n),s=r.content.slice();return o==-1?s.push(t||n,e):(s[o+1]=e,t&&(s[o]=t)),new K(s)},remove:function(n){var e=this.find(n);if(e==-1)return this;var t=this.content.slice();return t.splice(e,2),new K(t)},addToStart:function(n,e){return new K([n,e].concat(this.remove(n).content))},addToEnd:function(n,e){var t=this.remove(n).content.slice();return t.push(n,e),new K(t)},addBefore:function(n,e,t){var r=this.remove(e),o=r.content.slice(),s=r.find(n);return o.splice(s==-1?o.length:s,0,e,t),new K(o)},forEach:function(n){for(var e=0;e<this.content.length;e+=2)n(this.content[e],this.content[e+1])},prepend:function(n){return n=K.from(n),n.size?new K(n.content.concat(this.subtract(n).content)):this},append:function(n){return n=K.from(n),n.size?new K(this.subtract(n).content.concat(n.content)):this},subtract:function(n){var e=this;n=K.from(n);for(var t=0;t<n.content.length;t+=2)e=e.remove(n.content[t]);return e},toObject:function(){var n={};return this.forEach(function(e,t){n[e]=t}),n},get size(){return this.content.length>>1}};K.from=function(n){if(n instanceof K)return n;var e=[];if(n)for(var t in n)e.push(t,n[t]);return new K(e)};function Vs(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=Vs(o.content,s.content,t+1);if(i!=null)return i}t+=o.nodeSize}}function qs(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=qs(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 Vs(this,e,t)}findDiffEnd(e,t=this.size,r=e.size){return qs(this,e,t,r)}findIndex(e,t=-1){if(e==0)return zt(0,e);if(e==this.size)return zt(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?zt(r+1,i):zt(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 ir={index:0,offset:0};function zt(n,e){return ir.index=n,ir.offset=e,ir}function tn(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(!tn(n[r],e[r]))return!1}else{for(let r in n)if(!(r in e)||!tn(n[r],e[r]))return!1;for(let r in e)if(!(r in n))return!1}return!0}let R=class Nr{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&&tn(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`);let o=r.create(t.attrs);return r.checkAttrs(o.attrs),o}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 Nr.none;if(e instanceof Nr)return[e];let t=e.slice();return t.sort((r,o)=>r.type.rank-o.type.rank),t}};R.none=[];class nn extends Error{}class x{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=_s(this.content,e+this.openStart,t);return r&&new x(r,this.openStart,this.openEnd)}removeBetween(e,t){return new x(Us(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 x.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 x(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 x(e,r,o)}}x.empty=new x(b.empty,0,0);function Us(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(Us(s.content,e-o-1,t-o-1)))}function _s(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=_s(i.content,e-s-1,t);return l&&n.replaceChild(o,i.copy(l))}function Fl(n,e,t){if(t.openStart>n.depth)throw new nn("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new nn("Inconsistent open depths");return Gs(n,e,t,0)}function Gs(n,e,t,r){let o=n.index(r),s=n.node(r);if(o==e.index(r)&&r<n.depth-t.openStart){let i=Gs(n,e,t,r+1);return s.copy(s.content.replaceChild(o,i))}else if(t.content.size)if(!t.openStart&&!t.openEnd&&n.depth==r&&e.depth==r){let i=n.parent,l=i.content;return Fe(i,l.cut(0,n.parentOffset).append(t.content).append(l.cut(e.parentOffset)))}else{let{start:i,end:l}=$l(t,n);return Fe(s,Xs(n,i,l,e,r))}else return Fe(s,rn(n,e,r))}function Qs(n,e){if(!e.type.compatibleContent(n.type))throw new nn("Cannot join "+e.type.name+" onto "+n.type.name)}function Or(n,e,t){let r=n.node(t);return Qs(r,e.node(t)),r}function He(n,e){let t=e.length-1;t>=0&&n.isText&&n.sameMarkup(e[t])?e[t]=n.withText(e[t].text+n.text):e.push(n)}function mt(n,e,t,r){let o=(e||n).node(t),s=0,i=e?e.index(t):o.childCount;n&&(s=n.index(t),n.depth>t?s++:n.textOffset&&(He(n.nodeAfter,r),s++));for(let l=s;l<i;l++)He(o.child(l),r);e&&e.depth==t&&e.textOffset&&He(e.nodeBefore,r)}function Fe(n,e){return n.type.checkContent(e),n.copy(e)}function Xs(n,e,t,r,o){let s=n.depth>o&&Or(n,e,o+1),i=r.depth>o&&Or(t,r,o+1),l=[];return mt(null,n,o,l),s&&i&&e.index(o)==t.index(o)?(Qs(s,i),He(Fe(s,Xs(n,e,t,r,o+1)),l)):(s&&He(Fe(s,rn(n,e,o+1)),l),mt(e,t,o,l),i&&He(Fe(i,rn(t,r,o+1)),l)),mt(r,null,o,l),new b(l)}function rn(n,e,t){let r=[];if(mt(null,n,t,r),n.depth>t){let o=Or(n,e,t+1);He(Fe(o,rn(n,e,t+1)),r)}return mt(e,null,t,r),new b(r)}function $l(n,e){let t=e.depth-n.openStart,o=e.node(t).copy(n.content);for(let s=t-1;s>=0;s--)o=e.node(s).copy(b.from(o));return{start:o.resolveNoCache(n.openStart+t),end:o.resolveNoCache(o.content.size-n.openEnd-t)}}class wt{constructor(e,t,r){this.pos=e,this.path=t,this.parentOffset=r,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],o=e.child(t);return r?e.child(t).cut(r):o}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let r=this.path[t*3],o=t==0?0:this.path[t*3-1]+1;for(let s=0;s<e;s++)o+=r.child(s).nodeSize;return o}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return R.none;if(this.textOffset)return e.child(t).marks;let r=e.maybeChild(t-1),o=e.maybeChild(t);if(!r){let l=r;r=o,o=l}let s=r.marks;for(var i=0;i<s.length;i++)s[i].type.spec.inclusive===!1&&(!o||!s[i].isInSet(o.marks))&&(s=s[i--].removeFromSet(s));return s}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let r=t.marks,o=e.parent.maybeChild(e.index());for(var s=0;s<r.length;s++)r[s].type.spec.inclusive===!1&&(!o||!r[s].isInSet(o.marks))&&(r=r[s--].removeFromSet(r));return r}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let r=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);r>=0;r--)if(e.pos<=this.end(r)&&(!t||t(this.node(r))))return new on(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let t=1;t<=this.depth;t++)e+=(e?"/":"")+this.node(t).type.name+"_"+this.index(t-1);return e+":"+this.parentOffset}static resolve(e,t){if(!(t>=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let r=[],o=0,s=t;for(let i=e;;){let{index:l,offset:a}=i.content.findIndex(s),c=s-a;if(r.push(i,l,o+a),!c||(i=i.child(l),i.isText))break;s=c-1,o+=a+1}return new wt(t,r,s)}static resolveCached(e,t){let r=zo.get(e);if(r)for(let s=0;s<r.elts.length;s++){let i=r.elts[s];if(i.pos==t)return i}else zo.set(e,r=new jl);let o=r.elts[r.i]=wt.resolve(e,t);return r.i=(r.i+1)%Wl,o}}class jl{constructor(){this.elts=[],this.i=0}}const Wl=12,zo=new WeakMap;class on{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)}}const Kl=Object.create(null);let et=class Rr{constructor(e,t,r,o=R.none){this.type=e,this.attrs=t,this.marks=o,this.content=r||b.empty}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,r,o=0){this.content.nodesBetween(e,t,r,o,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,t,r,o){return this.content.textBetween(e,t,r,o)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,r){return this.type==e&&tn(this.attrs,t||e.defaultAttrs||Kl)&&R.sameSet(this.marks,r||R.none)}copy(e=null){return e==this.content?this:new Rr(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new Rr(this.type,this.attrs,this.content,e)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,r=!1){if(e==t)return x.empty;let o=this.resolve(e),s=this.resolve(t),i=r?0:o.sharedDepth(t),l=o.start(i),c=o.node(i).content.cut(o.pos-l,s.pos-l);return new x(c,o.depth-i,s.depth-i)}replace(e,t,r){return Fl(this.resolve(e),this.resolve(t),r)}nodeAt(e){for(let t=this;;){let{index:r,offset:o}=t.content.findIndex(e);if(t=t.maybeChild(r),!t)return null;if(o==e||t.isText)return t;e-=o+1}}childAfter(e){let{index:t,offset:r}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:r}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:r}=this.content.findIndex(e);if(r<e)return{node:this.content.child(t),index:t,offset:r};let o=this.content.child(t-1);return{node:o,index:t-1,offset:r-o.nodeSize}}resolve(e){return wt.resolveCached(this,e)}resolveNoCache(e){return wt.resolve(this,e)}rangeHasMark(e,t,r){let o=!1;return t>e&&this.nodesBetween(e,t,s=>(r.isInSet(s.marks)&&(o=!0),!o)),o}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),Ys(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw new Error("Called contentMatchAt on a node with invalid content");return t}canReplace(e,t,r=b.empty,o=0,s=r.childCount){let i=this.contentMatchAt(e).matchFragment(r,o,s),l=i&&i.matchFragment(this.content,t);if(!l||!l.validEnd)return!1;for(let a=o;a<s;a++)if(!this.type.allowsMarks(r.child(a).marks))return!1;return!0}canReplaceWith(e,t,r,o){if(o&&!this.type.allowsMarks(o))return!1;let s=this.contentMatchAt(e).matchType(r),i=s&&s.matchFragment(this.content,t);return i?i.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=R.none;for(let t=0;t<this.marks.length;t++){let r=this.marks[t];r.type.checkAttrs(r.attrs),e=r.addToSet(e)}if(!R.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(t=>t.type.name)}`);this.content.forEach(t=>t.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(t=>t.toJSON())),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let r;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=t.marks.map(e.markFromJSON)}if(t.type=="text"){if(typeof t.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(t.text,r)}let o=b.fromJSON(e,t.content),s=e.nodeType(t.type).create(t.attrs,o,r);return s.type.checkAttrs(s.attrs),s}};et.prototype.text=void 0;class sn extends et{constructor(e,t,r,o){if(super(e,t,null,o),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):Ys(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new sn(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new sn(this.type,this.attrs,e,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function Ys(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}class Ke{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let r=new Jl(e,t);if(r.next==null)return Ke.empty;let o=Zs(r);r.next&&r.err("Unexpected trailing text");let s=Xl(Ql(o));return Yl(s,r),s}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,r=e.childCount){let o=this;for(let s=t;o&&s<r;s++)o=o.matchType(e.child(s).type);return o}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let r=0;r<e.next.length;r++)if(this.next[t].type==e.next[r].type)return!0;return!1}fillBefore(e,t=!1,r=0){let o=[this];function s(i,l){let a=i.matchFragment(e,r);if(a&&(!t||a.validEnd))return b.from(l.map(c=>c.createAndFill()));for(let c=0;c<i.next.length;c++){let{type:u,next:f}=i.next[c];if(!(u.isText||u.hasRequiredAttrs())&&o.indexOf(f)==-1){o.push(f);let d=s(f,l.concat(u));if(d)return d}}return null}return s(this,[])}findWrapping(e){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==e)return this.wrapCache[r+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let o=r.shift(),s=o.match;if(s.matchType(e)){let i=[];for(let l=o;l.type;l=l.via)i.push(l.type);return i.reverse()}for(let i=0;i<s.next.length;i++){let{type:l,next:a}=s.next[i];!l.isLeaf&&!l.hasRequiredAttrs()&&!(l.name in t)&&(!o.type||a.validEnd)&&(r.push({match:l.contentMatch,type:l,via:o}),t[l.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(r){e.push(r);for(let o=0;o<r.next.length;o++)e.indexOf(r.next[o].next)==-1&&t(r.next[o].next)}return t(this),e.map((r,o)=>{let s=o+(r.validEnd?"*":" ")+" ";for(let i=0;i<r.next.length;i++)s+=(i?", ":"")+r.next[i].type.name+"->"+e.indexOf(r.next[i].next);return s}).join(`
2
+ `)}}Ke.empty=new Ke(!0);class Jl{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}}function Zs(n){let e=[];do e.push(Vl(n));while(n.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function Vl(n){let e=[];do e.push(ql(n));while(n.next&&n.next!=")"&&n.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function ql(n){let e=Gl(n);for(;;)if(n.eat("+"))e={type:"plus",expr:e};else if(n.eat("*"))e={type:"star",expr:e};else if(n.eat("?"))e={type:"opt",expr:e};else if(n.eat("{"))e=Ul(n,e);else break;return e}function Do(n){/\D/.test(n.next)&&n.err("Expected number, got '"+n.next+"'");let e=Number(n.next);return n.pos++,e}function Ul(n,e){let t=Do(n),r=t;return n.eat(",")&&(n.next!="}"?r=Do(n):r=-1),n.eat("}")||n.err("Unclosed braced range"),{type:"range",min:t,max:r,expr:e}}function _l(n,e){let t=n.nodeTypes,r=t[e];if(r)return[r];let o=[];for(let s in t){let i=t[s];i.groups.indexOf(e)>-1&&o.push(i)}return o.length==0&&n.err("No node type or group '"+e+"' found"),o}function Gl(n){if(n.eat("(")){let e=Zs(n);return n.eat(")")||n.err("Missing closing paren"),e}else if(/\W/.test(n.next))n.err("Unexpected token '"+n.next+"'");else{let e=_l(n,n.next).map(t=>(n.inline==null?n.inline=t.isInline:n.inline!=t.isInline&&n.err("Mixing inline and block content"),{type:"name",value:t}));return n.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function Ql(n){let e=[[]];return o(s(n,0),t()),e;function t(){return e.push([])-1}function r(i,l,a){let c={term:a,to:l};return e[i].push(c),c}function o(i,l){i.forEach(a=>a.to=l)}function s(i,l){if(i.type=="choice")return i.exprs.reduce((a,c)=>a.concat(s(c,l)),[]);if(i.type=="seq")for(let a=0;;a++){let c=s(i.exprs[a],l);if(a==i.exprs.length-1)return c;o(c,l=t())}else if(i.type=="star"){let a=t();return r(l,a),o(s(i.expr,a),a),[r(a)]}else if(i.type=="plus"){let a=t();return o(s(i.expr,l),a),o(s(i.expr,a),a),[r(a)]}else{if(i.type=="opt")return[r(l)].concat(s(i.expr,l));if(i.type=="range"){let a=l;for(let c=0;c<i.min;c++){let u=t();o(s(i.expr,a),u),a=u}if(i.max==-1)o(s(i.expr,a),a);else for(let c=i.min;c<i.max;c++){let u=t();r(a,u),o(s(i.expr,a),u),a=u}return[r(a)]}else{if(i.type=="name")return[r(l,void 0,i.value)];throw new Error("Unknown expr type")}}}}function ei(n,e){return e-n}function Bo(n,e){let t=[];return r(e),t.sort(ei);function r(o){let s=n[o];if(s.length==1&&!s[0].term)return r(s[0].to);t.push(o);for(let i=0;i<s.length;i++){let{term:l,to:a}=s[i];!l&&t.indexOf(a)==-1&&r(a)}}}function Xl(n){let e=Object.create(null);return t(Bo(n,0));function t(r){let o=[];r.forEach(i=>{n[i].forEach(({term:l,to:a})=>{if(!l)return;let c;for(let u=0;u<o.length;u++)o[u][0]==l&&(c=o[u][1]);Bo(n,a).forEach(u=>{c||o.push([l,c=[]]),c.indexOf(u)==-1&&c.push(u)})})});let s=e[r.join(",")]=new Ke(r.indexOf(n.length-1)>-1);for(let i=0;i<o.length;i++){let l=o[i][1].sort(ei);s.next.push({type:o[i][0],next:e[l.join(",")]||t(l)})}return s}}function Yl(n,e){for(let t=0,r=[n];t<r.length;t++){let o=r[t],s=!o.validEnd,i=[];for(let l=0;l<o.next.length;l++){let{type:a,next:c}=o.next[l];i.push(a.name),s&&!(a.isText||a.hasRequiredAttrs())&&(s=!1),r.indexOf(c)==-1&&r.push(c)}s&&e.err("Only non-generatable nodes ("+i.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function ti(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 ni(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 ri(n,e,t,r){for(let o in e)if(!(o in n))throw new RangeError(`Unsupported attribute ${o} for ${t} of type ${o}`);for(let o in n){let s=n[o];s.validate&&s.validate(e[o])}}function oi(n,e){let t=Object.create(null);if(e)for(let r in e)t[r]=new ea(n,r,e[r]);return t}let Po=class si{constructor(e,t,r){this.name=e,this.schema=t,this.spec=r,this.markSet=null,this.groups=r.group?r.group.split(" "):[],this.attrs=oi(e,r.attrs),this.defaultAttrs=ti(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(r.inline||e=="text"),this.isText=e=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==Ke.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:ni(this.attrs,e)}create(e=null,t,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new et(this,this.computeAttrs(e),b.from(t),R.setFrom(r))}createChecked(e=null,t,r){return t=b.from(t),this.checkContent(t),new et(this,this.computeAttrs(e),t,R.setFrom(r))}createAndFill(e=null,t,r){if(e=this.computeAttrs(e),t=b.from(t),t.size){let i=this.contentMatch.fillBefore(t);if(!i)return null;t=i.append(t)}let o=this.contentMatch.matchFragment(t),s=o&&o.fillBefore(b.empty,!0);return s?new et(this,e,t.append(s),R.setFrom(r)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let r=0;r<e.childCount;r++)if(!this.allowsMarks(e.child(r).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){ri(this.attrs,e,"node",this.name)}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let t;for(let r=0;r<e.length;r++)this.allowsMarkType(e[r].type)?t&&t.push(e[r]):t||(t=e.slice(0,r));return t?t.length?t:R.none:e}static compile(e,t){let r=Object.create(null);e.forEach((s,i)=>r[s]=new si(s,t,i));let o=t.spec.topNode||"doc";if(!r[o])throw new RangeError("Schema is missing its top node type ('"+o+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let s in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function Zl(n,e,t){let r=t.split("|");return o=>{let s=o===null?"null":typeof o;if(r.indexOf(s)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${n}, got ${s}`)}}class ea{constructor(e,t,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?Zl(e,t,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class Un{constructor(e,t,r,o){this.name=e,this.rank=t,this.schema=r,this.spec=o,this.attrs=oi(e,o.attrs),this.excluded=null;let s=ti(this.attrs);this.instance=s?new R(this,s):null}create(e=null){return!e&&this.instance?this.instance:new R(this,ni(this.attrs,e))}static compile(e,t){let r=Object.create(null),o=0;return e.forEach((s,i)=>r[s]=new Un(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]}checkAttrs(e){ri(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class ta{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let o in e)t[o]=e[o];t.nodes=K.from(e.nodes),t.marks=K.from(e.marks||{}),this.nodes=Po.compile(this.spec.nodes,this),this.marks=Un.compile(this.spec.marks,this);let r=Object.create(null);for(let o in this.nodes){if(o in this.marks)throw new RangeError(o+" can not be both a node and a mark");let s=this.nodes[o],i=s.spec.content||"",l=s.spec.marks;if(s.contentMatch=r[i]||(r[i]=Ke.parse(i,this.nodes)),s.inlineContent=s.contentMatch.inlineContent,s.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!s.isInline||!s.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=s}s.markSet=l=="_"?null:l?Ho(this,l.split(" ")):l==""||!s.inlineContent?[]:null}for(let o in this.marks){let s=this.marks[o],i=s.spec.excludes;s.excluded=i==null?[s]:i==""?[]:Ho(this,i.split(" "))}this.nodeFromJSON=this.nodeFromJSON.bind(this),this.markFromJSON=this.markFromJSON.bind(this),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,r,o){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof Po){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(t,r,o)}text(e,t){let r=this.nodes.text;return new sn(r,r.defaultAttrs,e,R.setFrom(t))}mark(e,t){return typeof e=="string"&&(e=this.marks[e]),e.create(t)}nodeFromJSON(e){return et.fromJSON(this,e)}markFromJSON(e){return R.fromJSON(this,e)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}}function Ho(n,e){let t=[];for(let r=0;r<e.length;r++){let o=e[r],s=n.marks[o],i=s;if(s)t.push(s);else for(let l in n.marks){let a=n.marks[l];(o=="_"||a.spec.group&&a.spec.group.split(" ").indexOf(o)>-1)&&t.push(i=a)}if(!i)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return t}function na(n){return n.tag!=null}function ra(n){return n.style!=null}class $e{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let r=this.matchedStyles=[];t.forEach(o=>{if(na(o))this.tags.push(o);else if(ra(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 $o(this,t,!1);return r.addAll(e,R.none,t.from,t.to),r.finish()}parseSlice(e,t={}){let r=new $o(this,t,!0);return r.addAll(e,R.none,t.from,t.to),x.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(ia(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=jo(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=jo(i)),i.node||i.ignore||i.mark||(i.node=o)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new $e(e,$e.schemaRules(e)))}}const ii={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},oa={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},li={ol:!0,ul:!0},ln=1,an=2,gt=4;function Fo(n,e,t){return e!=null?(e?ln:0)|(e==="full"?an:0):n&&n.whitespace=="pre"?ln|an:t&~gt}class Dt{constructor(e,t,r,o,s,i){this.type=e,this.attrs=t,this.marks=r,this.solid=o,this.options=i,this.content=[],this.activeMarks=R.none,this.match=s||(i&gt?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&ln)){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}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!ii.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class $o{constructor(e,t,r){this.parser=e,this.options=t,this.isOpen=r,this.open=0;let o=t.topNode,s,i=Fo(null,t.preserveWhitespace,0)|(r?gt:0);o?s=new Dt(o.type,o.attrs,R.none,!0,t.topMatch||o.type.contentMatch,i):r?s=new Dt(null,null,R.none,!0,null,i):s=new Dt(e.schema.topNodeType,null,R.none,!0,null,i),this.nodes=[s],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){e.nodeType==3?this.addTextNode(e,t):e.nodeType==1&&this.addElement(e,t)}addTextNode(e,t){let r=e.nodeValue,o=this.top;if(o.options&an||o.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(o.options&ln)o.options&an?r=r.replace(/\r\n?/g,`
3
+ `):r=r.replace(/\r?\n|\r/g," ");else if(r=r.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(r)&&this.open==this.nodes.length-1){let s=o.content[o.content.length-1],i=e.previousSibling;(!s||i&&i.nodeName=="BR"||s.isText&&/[ \t\r\n\u000c]$/.test(s.text))&&(r=r.slice(1))}r&&this.insertNode(this.parser.schema.text(r),t),this.findInText(e)}else this.findInside(e)}addElement(e,t,r){let o=e.nodeName.toLowerCase(),s;li.hasOwnProperty(o)&&this.parser.normalizeLists&&sa(e);let i=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(s=this.parser.matchTag(e,this,r));if(i?i.ignore:oa.hasOwnProperty(o))this.findInside(e),this.ignoreFallback(e,t);else if(!i||i.skip||i.closeParent){i&&i.closeParent?this.open=Math.max(0,this.open-1):i&&i.skip.nodeType&&(e=i.skip);let l,a=this.top,c=this.needsBlock;if(ii.hasOwnProperty(o))a.content.length&&a.content[0].isInline&&this.open&&(this.open--,a=this.top),l=!0,a.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);return}let u=i&&i.skip?t:this.readStyles(e,t);u&&this.addAll(e,u),l&&this.sync(a),this.needsBlock=c}else{let l=this.readStyles(e,t);l&&this.addElementByRule(e,i,l,i.consuming===!1?s:void 0)}}leafFallback(e,t){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
4
+ `),t)}ignoreFallback(e,t){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),t)}readStyles(e,t){let r=e.style;if(r&&r.length)for(let o=0;o<this.parser.matchedStyles.length;o++){let s=this.parser.matchedStyles[o],i=r.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?t=t.filter(c=>!a.clearMark(c)):t=t.concat(this.parser.schema.marks[a.mark].create(a.attrs)),a.consuming===!1)l=a;else break}}return t}addElementByRule(e,t,r,o){let s,i;if(t.node)if(i=this.parser.schema.nodes[t.node],i.isLeaf)this.insertNode(i.create(t.attrs),r)||this.leafFallback(e,r);else{let a=this.enter(i,t.attrs||null,r,t.preserveWhitespace);a&&(s=!0,r=a)}else{let a=this.parser.schema.marks[t.mark];r=r.concat(a.create(t.attrs))}let l=this.top;if(i&&i.isLeaf)this.findInside(e);else if(o)this.addElement(e,r,o);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a,r));else{let a=e;typeof t.contentElement=="string"?a=e.querySelector(t.contentElement):typeof t.contentElement=="function"?a=t.contentElement(e):t.contentElement&&(a=t.contentElement),this.findAround(e,a,!0),this.addAll(a,r)}s&&this.sync(l)&&this.open--}addAll(e,t,r,o){let s=r||0;for(let i=r?e.childNodes[r]:e.firstChild,l=o==null?null:e.childNodes[o];i!=l;i=i.nextSibling,++s)this.findAtPoint(e,s),this.addDOM(i,t);this.findAtPoint(e,s)}findPlace(e,t){let r,o;for(let s=this.open;s>=0;s--){let i=this.nodes[s],l=i.findWrapping(e);if(l&&(!r||r.length>l.length)&&(r=l,o=i,!l.length)||i.solid)break}if(!r)return null;this.sync(o);for(let s=0;s<r.length;s++)t=this.enterInner(r[s],null,t,!1);return t}insertNode(e,t){if(e.isInline&&this.needsBlock&&!this.top.type){let o=this.textblockFromContext();o&&(t=this.enterInner(o,null,t))}let r=this.findPlace(e,t);if(r){this.closeExtra();let o=this.top;o.match&&(o.match=o.match.matchType(e.type));let s=R.none;for(let i of r.concat(e.marks))(o.type?o.type.allowsMarkType(i.type):Wo(i.type,e.type))&&(s=i.addToSet(s));return o.content.push(e.mark(s)),!0}return!1}enter(e,t,r,o){let s=this.findPlace(e.create(t),r);return s&&(s=this.enterInner(e,t,r,!0,o)),s}enterInner(e,t,r,o=!1,s){this.closeExtra();let i=this.top;i.match=i.match&&i.match.matchType(e);let l=Fo(e,s,i.options);i.options&gt&&i.content.length==0&&(l|=gt);let a=R.none;return r=r.filter(c=>(i.type?i.type.allowsMarkType(c.type):Wo(c.type,e))?(a=c.addToSet(a),!1):!0),this.nodes.push(new Dt(e,t,a,o,null,l)),this.open++,r}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(this.isOpen||this.options.topOpen)}sync(e){for(let t=this.open;t>=0;t--)if(this.nodes[t]==e)return this.open=t,!0;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}}}function sa(n){for(let e=n.firstChild,t=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&li.hasOwnProperty(r)&&t?(t.appendChild(e),e=t):r=="li"?t=e:r&&(t=null)}}function ia(n,e){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,e)}function jo(n){let e={};for(let t in n)e[t]=n[t];return e}function Wo(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}}class _n{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},r){r||(r=lr(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}=_t(lr(t),this.nodes[e.type.name](e),null,e.attrs);if(o){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,o)}return 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&&_t(lr(r),o(e,t),null,e.attrs)}static renderSpec(e,t,r=null,o){return _t(e,t,r,o)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new _n(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=Ko(e.nodes);return t.text||(t.text=r=>r.text),t}static marksFromSchema(e){return Ko(e.marks)}}function Ko(n){let e={};for(let t in n){let r=n[t].spec.toDOM;r&&(e[t]=r)}return e}function lr(n){return n.document||window.document}const Jo=new WeakMap;function la(n){let e=Jo.get(n);return e===void 0&&Jo.set(n,e=aa(n)),e}function aa(n){let e=null;function t(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")e||(e=[]),e.push(r);else for(let o=0;o<r.length;o++)t(r[o]);else for(let o in r)t(r[o])}return t(n),e}function _t(n,e,t,r){if(typeof e=="string")return{dom:n.createTextNode(e)};if(e.nodeType!=null)return{dom:e};if(e.dom&&e.dom.nodeType!=null)return e;let o=e[0],s;if(typeof o!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(s=la(r))&&s.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let i=o.indexOf(" ");i>0&&(t=o.slice(0,i),o=o.slice(i+1));let l,a=t?n.createElementNS(t,o):n.createElement(o),c=e[1],u=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){u=2;for(let f in c)if(c[f]!=null){let d=f.indexOf(" ");d>0?a.setAttributeNS(f.slice(0,d),f.slice(d+1),c[f]):a.setAttribute(f,c[f])}}for(let f=u;f<e.length;f++){let d=e[f];if(d===0){if(f<e.length-1||f>u)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}else{let{dom:h,contentDOM:p}=_t(n,d,t,r);if(a.appendChild(h),p){if(l)throw new RangeError("Multiple content holes");l=p}}}return{dom:a,contentDOM:l}}const ai=65535,ci=Math.pow(2,16);function ca(n,e){return n+e*ci}function Vo(n){return n&ai}function ua(n){return(n-(n&ai))/ci}const ui=1,fi=2,Gt=4,di=8;class Ir{constructor(e,t,r){this.pos=e,this.delInfo=t,this.recover=r}get deleted(){return(this.delInfo&di)>0}get deletedBefore(){return(this.delInfo&(ui|Gt))>0}get deletedAfter(){return(this.delInfo&(fi|Gt))>0}get deletedAcross(){return(this.delInfo&Gt)>0}}class Y{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&Y.empty)return Y.empty}recover(e){let t=0,r=Vo(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+ua(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],f=a+c;if(e<=f){let d=c?e==a?-1:e==f?1:t:t,h=a+o+(d<0?0:u);if(r)return h;let p=e==(t<0?a:f)?null:ca(l/3,e-a),m=e==a?fi:e==f?ui:Gt;return(t<0?e!=a:e!=f)&&(m|=di),new Ir(h,m,p)}o+=u-c}return r?e+o:new Ir(e+o,0,null)}touches(e,t){let r=0,o=Vo(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 Y(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?Y.empty:new Y(e<0?[0,-e,0]:[0,0,e])}}Y.empty=new Y([]);class yt{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 yt(this.maps,this.mirror,e,t)}copy(){return new yt(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 yt;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 Ir(e,o,null)}}const ar=Object.create(null);class _{getMap(){return Y.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=ar[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 ar)throw new RangeError("Duplicate use of step JSON ID "+e);return ar[e]=t,t.prototype.jsonID=e,t}}class H{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new H(e,null)}static fail(e){return new H(null,e)}static fromReplace(e,t,r,o){try{return H.ok(e.replace(t,r,o))}catch(s){if(s instanceof nn)return H.fail(s.message);throw s}}}function eo(n,e,t){let r=[];for(let o=0;o<n.childCount;o++){let s=n.child(o);s.content.size&&(s=s.copy(eo(s.content,e,s))),s.isInline&&(s=e(s,t,o)),r.push(s)}return b.fromArray(r)}class Me extends _{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 x(eo(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 H.fromReplace(e,this.from,this.to,s)}invert(){return new me(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 Me(t.pos,r.pos,this.mark)}merge(e){return e instanceof Me&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Me(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 Me(t.from,t.to,e.markFromJSON(t.mark))}}_.jsonID("addMark",Me);class me extends _{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 x(eo(t.content,o=>o.mark(this.mark.removeFromSet(o.marks)),e),t.openStart,t.openEnd);return H.fromReplace(e,this.from,this.to,r)}invert(){return new Me(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 me(t.pos,r.pos,this.mark)}merge(e){return e instanceof me&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new me(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 me(t.from,t.to,e.markFromJSON(t.mark))}}_.jsonID("removeMark",me);class Ee extends _{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return H.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return H.fromReplace(e,this.pos,this.pos+1,new x(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 Ee(this.pos,t.marks[o]);return new Ee(this.pos,this.mark)}}return new ot(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new Ee(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 Ee(t.pos,e.markFromJSON(t.mark))}}_.jsonID("addNodeMark",Ee);class ot extends _{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return H.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return H.fromReplace(e,this.pos,this.pos+1,new x(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 Ee(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new ot(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 ot(t.pos,e.markFromJSON(t.mark))}}_.jsonID("removeNodeMark",ot);class $ extends _{constructor(e,t,r,o=!1){super(),this.from=e,this.to=t,this.slice=r,this.structure=o}apply(e){return this.structure&&vr(e,this.from,this.to)?H.fail("Structure replace would overwrite content"):H.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new Y([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?x.empty:new x(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?x.empty:new x(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,x.fromJSON(e,t.slice),!!t.structure)}}_.jsonID("replace",$);class j extends _{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&&(vr(e,this.from,this.gapFrom)||vr(e,this.gapTo,this.to)))return H.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return H.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,t.content);return r?H.fromReplace(e,this.from,this.to,r):H.fail("Content does not fit in gap")}getMap(){return new Y([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 j(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 j(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 j(t.from,t.to,t.gapFrom,t.gapTo,x.fromJSON(e,t.slice),t.insert,!!t.structure)}}_.jsonID("replaceAround",j);function vr(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 fa(n,e,t,r){let o=[],s=[],i,l;n.doc.nodesBetween(e,t,(a,c,u)=>{if(!a.isInline)return;let f=a.marks;if(!r.isInSet(f)&&u.type.allowsMarkType(r.type)){let d=Math.max(c,e),h=Math.min(c+a.nodeSize,t),p=r.addToSet(f);for(let m=0;m<f.length;m++)f[m].isInSet(p)||(i&&i.to==d&&i.mark.eq(f[m])?i.to=h:o.push(i=new me(d,h,f[m])));l&&l.to==d?l.to=h:s.push(l=new Me(d,h,r))}}),o.forEach(a=>n.step(a)),s.forEach(a=>n.step(a))}function da(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 Un){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 f=a[u],d;for(let h=0;h<o.length;h++){let p=o[h];p.step==s-1&&f.eq(o[h].style)&&(d=p)}d?(d.to=c,d.step=s):o.push({style:f,from:Math.max(l,e),to:c,step:s})}}}),o.forEach(i=>n.step(new me(i.from,i.to,i.style)))}function hi(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,f=r.matchType(c.type);if(!f)i.push(new $(l,u,x.empty));else{r=f;for(let d=0;d<c.marks.length;d++)t.allowsMarkType(c.marks[d].type)||n.step(new me(l,u,c.marks[d]));if(o&&c.isText&&t.whitespace!="pre"){let d,h=/\r?\n|\r/g,p;for(;d=h.exec(c.text);)p||(p=new x(b.from(t.schema.text(" ",t.allowedMarks(c.marks))),0,0)),i.push(new $(l+d.index,l+d.index+d[0].length,p))}}l=u}if(!r.validEnd){let a=r.fillBefore(b.empty,!0);n.replace(l,l,new x(a,0,0))}for(let a=i.length-1;a>=0;a--)n.step(i[a])}function ha(n,e,t){return(e==0||n.canReplace(e,n.childCount))&&(t==n.childCount||n.canReplace(0,t))}function ct(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||!ha(o,s,i))break}return null}function pa(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,f=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)),f++):a--;let d=b.empty,h=0;for(let p=s,m=!1;p>t;p--)m||o.after(p+1)<o.end(p)?(m=!0,d=b.from(o.node(p).copy(d)),h++):c++;n.step(new j(a,c,i,l,new x(u.append(d),f,h),u.size-f,!0))}function to(n,e,t=null,r=n){let o=ma(n,e),s=o&&ga(r,e);return s?o.map(qo).concat({type:e,attrs:t}).concat(s.map(qo)):null}function qo(n){return{type:n,attrs:null}}function ma(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 ga(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 ya(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 j(o,s,o,s,new x(r,0,0),t.length,!0))}function ba(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)=>{let a=typeof o=="function"?o(i):o;if(i.isTextblock&&!i.hasMarkup(r,a)&&Sa(n.doc,n.mapping.slice(s).map(l),r)){let c=null;if(r.schema.linebreakReplacement){let h=r.whitespace=="pre",p=!!r.contentMatch.matchType(r.schema.linebreakReplacement);h&&!p?c=!1:!h&&p&&(c=!0)}c===!1&&xa(n,i,l,s),hi(n,n.mapping.slice(s).map(l,1),r,void 0,c===null);let u=n.mapping.slice(s),f=u.map(l,1),d=u.map(l+i.nodeSize,1);return n.step(new j(f,d,f+1,d-1,new x(b.from(r.create(a,null,i.marks)),0,0),1,!0)),c===!0&&ka(n,i,l,s),!1}})}function ka(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 xa(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(`
5
+ `))}})}function Sa(n,e,t){let r=n.resolve(e),o=r.index();return r.parent.canReplaceWith(o,o+1,t)}function wa(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 j(e,e+s.nodeSize,e+1,e+s.nodeSize-1,new x(b.from(i),0,0),1,!0))}function tt(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 f=o.node(c),d=o.index(c);if(f.type.spec.isolating)return!1;let h=f.content.cutByIndex(d,f.childCount),p=r&&r[u+1];p&&(h=h.replaceChild(0,p.type.create(p.attrs)));let m=r&&r[u]||f;if(!f.canReplace(d+1,f.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 Ca(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 x(s.append(i),t,t),!0))}function Ie(n,e){let t=n.resolve(e),r=t.index();return pi(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(r,r+1)}function pi(n,e){return!!(n&&e&&!n.isLeaf&&n.canAppend(e))}function Gn(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&&pi(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 Ta(n,e,t){let r=new $(e-t,e+t,x.empty,!0);n.step(r)}function Aa(n,e,t){let r=n.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),t))return e;if(r.parentOffset==0)for(let o=r.depth-1;o>=0;o--){let 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 Ma(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 f=c.contentMatchAt(a).findWrapping(o.firstChild.type);u=f&&c.canReplaceWith(a,a,f[0])}if(u)return l==0?r.pos:l<0?r.before(i+1):r.after(i+1)}return null}function Qn(n,e,t=e,r=x.empty){if(e==t&&!r.size)return null;let o=n.resolve(e),s=n.resolve(t);return mi(o,s,r)?new $(e,t,r):new Ea(o,s,r).fit()}function mi(n,e,t){return!t.openStart&&!t.openEnd&&n.start()==e.start()&&n.parent.canReplace(n.index(),e.index(),t.content)}class Ea{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 x(s,i,l);return e>-1?new j(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=cr(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,f=null;if(t==1&&(i?c.matchType(i.type)||(f=c.fillBefore(b.from(i),!1)):s&&a.compatibleContent(s.type)))return{sliceDepth:r,frontierDepth:l,parent:s,inject:f};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=cr(e,t);return!o.childCount||o.firstChild.isLeaf?!1:(this.unplaced=new x(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=cr(e,t);if(o.childCount<=1&&t>0){let s=e.size-t<=t+o.size;this.unplaced=new x(ht(e,t-1,1),t-1,s?t-1:r)}else this.unplaced=new x(ht(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:f,type:d}=this.frontier[t];if(o){for(let m=0;m<o.childCount;m++)u.push(o.child(m));f=f.matchFragment(o)}let h=l.size+e-(i.content.size-i.openEnd);for(;c<l.childCount;){let m=l.child(c),y=f.matchType(m.type);if(!y)break;c++,(c>1||a==0||m.content.size)&&(f=y,u.push(gi(m.mark(d.allowedMarks(m.marks)),c==1?a:0,c==l.childCount?h:-1)))}let p=c==l.childCount;p||(h=-1),this.placed=pt(this.placed,t,b.from(u)),this.frontier[t].match=f,p&&h<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let m=0,y=l;m<h;m++){let g=y.lastChild;this.frontier.push({type:g.type,match:g.contentMatchAt(g.childCount)}),y=g.content}this.unplaced=p?e==0?x.empty:new x(ht(i.content,e-1,1),e-1,h<0?i.openEnd:e-1):new x(ht(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||!ur(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=ur(e,t,o,r,s);if(i){for(let l=t-1;l>=0;l--){let{match:a,type:c}=this.frontier[l],u=ur(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=pt(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=pt(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=pt(this.placed,this.frontier.length,t))}}function ht(n,e,t){return e==0?n.cutByIndex(t,n.childCount):n.replaceChild(0,n.firstChild.copy(ht(n.firstChild.content,e-1,t)))}function pt(n,e,t){return e==0?n.append(t):n.replaceChild(n.childCount-1,n.lastChild.copy(pt(n.lastChild.content,e-1,t)))}function cr(n,e){for(let t=0;t<e;t++)n=n.firstChild.content;return n}function gi(n,e,t){if(e<=0)return n;let r=n.content;return e>1&&(r=r.replaceChild(0,gi(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 ur(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&&!Na(t,s.content,i)?l:null}function Na(n,e,t){for(let r=t;r<e.childCount;r++)if(!n.allowsMarks(e.child(r).marks))return!0;return!1}function Oa(n){return n.spec.defining||n.spec.definingForContent}function Ra(n,e,t,r){if(!r.size)return n.deleteRange(e,t);let o=n.doc.resolve(e),s=n.doc.resolve(t);if(mi(o,s,r))return n.step(new $(e,t,r));let i=bi(o,n.doc.resolve(t));i[i.length-1]==0&&i.pop();let l=-(o.depth+1);i.unshift(l);for(let d=o.depth,h=o.pos-1;d>0;d--,h--){let p=o.node(d).type.spec;if(p.defining||p.definingAsContext||p.isolating)break;i.indexOf(d)>-1?l=d:o.before(d)==h&&i.splice(1,0,-d)}let a=i.indexOf(l),c=[],u=r.openStart;for(let d=r.content,h=0;;h++){let p=d.firstChild;if(c.push(p),h==r.openStart)break;d=p.content}for(let d=u-1;d>=0;d--){let h=c[d],p=Oa(h.type);if(p&&!h.sameMarkup(o.node(Math.abs(l)-1)))u=d;else if(p||!h.type.isTextblock)break}for(let d=r.openStart;d>=0;d--){let h=(d+u+1)%(r.openStart+1),p=c[h];if(p)for(let m=0;m<i.length;m++){let y=i[(m+a)%i.length],g=!0;y<0&&(g=!1,y=-y);let M=o.node(y-1),S=o.index(y-1);if(M.canReplaceWith(S,S,p.type,p.marks))return n.replace(o.before(y),g?s.after(y):t,new x(yi(r.content,0,r.openStart,h),h,r.openEnd))}}let f=n.steps.length;for(let d=i.length-1;d>=0&&(n.replace(e,t,r),!(n.steps.length>f));d--){let h=i[d];h<0||(e=o.before(h),t=s.after(h))}}function yi(n,e,t,r,o){if(e<t){let s=n.firstChild;n=n.replaceChild(0,s.copy(yi(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 Ia(n,e,t,r){if(!r.isInline&&e==t&&n.doc.resolve(e).parent.content.size){let o=Aa(n.doc,e,r.type);o!=null&&(e=t=o)}n.replaceRange(e,t,new x(b.from(r),0,0))}function va(n,e,t){let r=n.doc.resolve(e),o=n.doc.resolve(t),s=bi(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 bi(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 nt extends _{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 H.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 H.fromReplace(e,this.pos,this.pos+1,new x(b.from(o),0,t.isLeaf?0:1))}getMap(){return Y.empty}invert(e){return new nt(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 nt(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 nt(t.pos,t.attr,t.value)}}_.jsonID("attr",nt);class Ct extends _{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 H.ok(r)}getMap(){return Y.empty}invert(e){return new Ct(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 Ct(t.attr,t.value)}}_.jsonID("docAttr",Ct);let st=class extends Error{};st=function n(e){let t=Error.call(this,e);return t.__proto__=n.prototype,t};st.prototype=Object.create(Error.prototype);st.prototype.constructor=st;st.prototype.name="TransformError";class ki{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new yt}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new st(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=x.empty){let o=Qn(this.doc,e,t,r);return o&&this.step(o),this}replaceWith(e,t,r){return this.replace(e,t,new x(b.from(r),0,0))}delete(e,t){return this.replace(e,t,x.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,r){return Ra(this,e,t,r),this}replaceRangeWith(e,t,r){return Ia(this,e,t,r),this}deleteRange(e,t){return va(this,e,t),this}lift(e,t){return pa(this,e,t),this}join(e,t=1){return Ta(this,e,t),this}wrap(e,t){return ya(this,e,t),this}setBlockType(e,t=e,r,o=null){return ba(this,e,t,r,o),this}setNodeMarkup(e,t,r=null,o){return wa(this,e,t,r,o),this}setNodeAttribute(e,t,r){return this.step(new nt(e,t,r)),this}setDocAttribute(e,t){return this.step(new Ct(e,t)),this}addNodeMark(e,t){return this.step(new Ee(e,t)),this}removeNodeMark(e,t){if(!(t instanceof R)){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 ot(e,t)),this}split(e,t=1,r){return Ca(this,e,t,r),this}addMark(e,t,r){return fa(this,e,t,r),this}removeMark(e,t,r){return da(this,e,t,r),this}clearIncompatible(e,t,r){return hi(this,e,t,r),this}}const fr=Object.create(null);class T{constructor(e,t,r){this.$anchor=e,this.$head=t,this.ranges=r||[new xi(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=x.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?x.empty:t),l==0&&Go(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),Go(e,r,t.isInline?-1:1))}}static findFrom(e,t,r=!1){let o=e.parent.inlineContent?new C(e):Xe(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?Xe(e.node(0),e.node(s),e.before(s+1),e.index(s),t,r):Xe(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 ce(e.node(0))}static atStart(e){return Xe(e,e,0,0,1)||new ce(e)}static atEnd(e){return Xe(e,e,e.content.size,e.childCount,-1)||new ce(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=fr[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 fr)throw new RangeError("Duplicate use of selection JSON ID "+e);return fr[e]=t,t.prototype.jsonID=e,t}getBookmark(){return C.between(this.$anchor,this.$head).getBookmark()}}T.prototype.visible=!0;class xi{constructor(e,t){this.$from=e,this.$to=t}}let Uo=!1;function _o(n){!Uo&&!n.parent.inlineContent&&(Uo=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+n.parent.type.name+")"))}class C extends T{constructor(e,t=e){_o(e),_o(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 T.near(r);let o=e.resolve(t.map(this.anchor));return new C(o.parent.inlineContent?o:r,r)}replace(e,t=x.empty){if(super.replace(e,t),t==x.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof C&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Xn(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 C(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=T.findFrom(t,r,!0)||T.findFrom(t,-r,!0);if(s)t=s.$head;else return T.near(t,r)}return e.parent.inlineContent||(o==0?e=t:(e=(T.findFrom(e,-r,!0)||T.findFrom(e,r,!0)).$anchor,e.pos<t.pos!=o<0&&(e=t))),new C(e,t)}}T.jsonID("text",C);class Xn{constructor(e,t){this.anchor=e,this.head=t}map(e){return new Xn(e.map(this.anchor),e.map(this.head))}resolve(e){return C.between(e.resolve(this.anchor),e.resolve(this.head))}}class w extends T{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?T.near(s):new w(s)}content(){return new x(b.from(this.node),0,0)}eq(e){return e instanceof w&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new no(this.anchor)}static fromJSON(e,t){if(typeof t.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new w(e.resolve(t.anchor))}static create(e,t){return new w(e.resolve(t))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}w.prototype.visible=!1;T.jsonID("node",w);class no{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:r}=e.mapResult(this.anchor);return t?new Xn(r,r):new no(r)}resolve(e){let t=e.resolve(this.anchor),r=t.nodeAfter;return r&&w.isSelectable(r)?new w(t):T.near(t)}}class ce extends T{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=x.empty){if(t==x.empty){e.delete(0,e.doc.content.size);let r=T.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new ce(e)}map(e){return new ce(e)}eq(e){return e instanceof ce}getBookmark(){return La}}T.jsonID("all",ce);const La={map(){return this},resolve(n){return new ce(n)}};function Xe(n,e,t,r,o,s=!1){if(e.inlineContent)return C.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&&w.isSelectable(l))return w.create(n,t-(o<0?l.nodeSize:0))}else{let a=Xe(n,l,t+o,o<0?l.childCount:0,o,s);if(a)return a}t+=l.nodeSize*o}return null}function Go(n,e,t){let r=n.steps.length-1;if(r<e)return;let o=n.steps[r];if(!(o instanceof $||o instanceof j))return;let s=n.mapping.maps[r],i;s.forEach((l,a,c,u)=>{i==null&&(i=u)}),n.setSelection(T.near(n.doc.resolve(i),t))}function Qo(n,e){return!e||!n?n:n.bind(e)}class Bt{constructor(e,t,r){this.name=e,this.init=Qo(t.init,r),this.apply=Qo(t.apply,r)}}new Bt("doc",{init(n){return n.doc||n.schema.topNodeType.createAndFill()},apply(n){return n.doc}}),new Bt("selection",{init(n,e){return n.selection||T.atStart(e.doc)},apply(n){return n.selection}}),new Bt("storedMarks",{init(n){return n.storedMarks||null},apply(n,e,t,r){return r.selection.$cursor?n.storedMarks:null}}),new Bt("scrollToSelection",{init(){return 0},apply(n,e){return n.scrolledIntoView?e+1:e}});function Si(n,e,t){for(let r in n){let o=n[r];o instanceof Function?o=o.bind(e):r=="handleDOMEvents"&&(o=Si(o,e,{})),t[r]=o}return t}class te{constructor(e){this.spec=e,this.props={},e.props&&Si(e.props,this,this.props),this.key=e.key?e.key.key:wi("plugin")}getState(e){return e[this.key]}}const dr=Object.create(null);function wi(n){return n in dr?n+"$"+ ++dr[n]:(dr[n]=0,n+"$")}class X{constructor(e="key"){this.key=wi(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const qe=function(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e},Ci=function(n,e,t,r){return t&&(Xo(n,e,t,r,-1)||Xo(n,e,t,r,1))},za=/^(img|br|input|textarea|hr)$/i;function Xo(n,e,t,r,o){for(;;){if(n==t&&e==r)return!0;if(e==(o<0?0:cn(n))){let s=n.parentNode;if(!s||s.nodeType!=1||ro(n)||za.test(n.nodeName)||n.contentEditable=="false")return!1;e=qe(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?cn(n):0}else return!1}}function cn(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Da(n,e,t){for(let r=e==0,o=e==cn(n);r||o;){if(n==t)return!0;let s=qe(n);if(n=n.parentNode,!n)return!1;r=r&&s==0,o=o&&s==cn(n)}}function ro(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 Ti=function(n){return n.focusNode&&Ci(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)};function Ai(n,e){let t=document.createEvent("Event");return t.initEvent("keydown",!0,!0),t.keyCode=n,t.key=t.code=e,t}const ge=typeof navigator<"u"?navigator:null,Yo=typeof document<"u"?document:null,ve=ge&&ge.userAgent||"",Lr=/Edge\/(\d+)/.exec(ve),Mi=/MSIE \d/.exec(ve),zr=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(ve),Rt=!!(Mi||zr||Lr),Ei=Mi?document.documentMode:zr?+zr[1]:Lr?+Lr[1]:0,Yn=!Rt&&/gecko\/(\d+)/i.test(ve);Yn&&+(/Firefox\/(\d+)/.exec(ve)||[0,0])[1];const Dr=!Rt&&/Chrome\/(\d+)/.exec(ve),Le=!!Dr,Ni=Dr?+Dr[1]:0,Ue=!Rt&&!!ge&&/Apple Computer/.test(ge.vendor),oo=Ue&&(/Mobile\/\w+/.test(ve)||!!ge&&ge.maxTouchPoints>2),oe=oo||(ge?/Mac/.test(ge.platform):!1),Ba=ge?/Win/.test(ge.platform):!1,It=/Android \d/.test(ve),so=!!Yo&&"webkitFontSmoothing"in Yo.documentElement.style,Pa=so?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Ha(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(Ti(t)){for(a=i;o&&!o.node;)o=o.parent;let f=o.node;if(o&&f.isAtom&&w.isSelectable(f)&&o.parent&&!(f.isInline&&Da(t.focusNode,t.focusOffset,o.dom))){let d=o.posBefore;c=new w(i==d?l:r.resolve(d))}}else{if(t instanceof n.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let f=i,d=i;for(let h=0;h<t.rangeCount;h++){let p=t.getRangeAt(h);f=Math.min(f,n.docView.posFromDOM(p.startContainer,p.startOffset,1)),d=Math.max(d,n.docView.posFromDOM(p.endContainer,p.endOffset,-1))}if(f<0)return null;[a,i]=d==n.state.selection.anchor?[d,f]:[f,d],l=r.resolve(i)}else a=n.docView.posFromDOM(t.anchorNode,t.anchorOffset,1);if(a<0)return null}let u=r.resolve(a);if(!c){let f=e=="pointer"||n.state.selection.head<l.pos&&!s?1:-1;c=Ri(n,u,l,f)}return c}function Oi(n){return n.editable?n.hasFocus():Wa(n)&&document.activeElement&&document.activeElement.contains(n.dom)}function io(n,e=!1){let t=n.state.selection;if(ja(n,t),!!Oi(n)){if(!e&&n.input.mouseDown&&n.input.mouseDown.allowDefault&&Le){let r=n.domSelectionRange(),o=n.domObserver.currentSelection;if(r.anchorNode&&o.anchorNode&&Ci(r.anchorNode,r.anchorOffset,o.anchorNode,o.anchorOffset)){n.input.mouseDown.delayedSelectionSync=!0,n.domObserver.setCurSelection();return}}if(n.domObserver.disconnectSelection(),n.cursorWrapper)$a(n);else{let{anchor:r,head:o}=t,s,i;Zo&&!(t instanceof C)&&(t.$from.parent.inlineContent||(s=es(n,t.from)),!t.empty&&!t.$from.parent.inlineContent&&(i=es(n,t.to))),n.docView.setSelection(r,o,n.root,e),Zo&&(s&&ts(s),i&&ts(i)),t.visible?n.dom.classList.remove("ProseMirror-hideselection"):(n.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&Fa(n))}n.domObserver.setCurSelection(),n.domObserver.connectSelection()}}const Zo=Ue||Le&&Ni<63;function es(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(Ue&&o&&o.contentEditable=="false")return hr(o);if((!o||o.contentEditable=="false")&&(!s||s.contentEditable=="false")){if(o)return hr(o);if(s)return hr(s)}}function hr(n){return n.contentEditable="true",Ue&&n.draggable&&(n.draggable=!1,n.wasDraggable=!0),n}function ts(n){n.contentEditable="false",n.wasDraggable&&(n.draggable=!0,n.wasDraggable=null)}function Fa(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(()=>{(!Oi(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function $a(n){let e=n.domSelection(),t=document.createRange();if(!e)return;let r=n.cursorWrapper.dom,o=r.nodeName=="IMG";o?t.setStart(r.parentNode,qe(r)+1):t.setStart(r,0),t.collapse(!0),e.removeAllRanges(),e.addRange(t),!o&&!n.state.selection.visible&&Rt&&Ei<=11&&(r.disabled=!0,r.disabled=!1)}function ja(n,e){if(e instanceof w){let t=n.docView.descAt(e.from);t!=n.lastSelectedViewDesc&&(ns(n),t&&t.selectNode(),n.lastSelectedViewDesc=t)}else ns(n)}function ns(n){n.lastSelectedViewDesc&&(n.lastSelectedViewDesc.parent&&n.lastSelectedViewDesc.deselectNode(),n.lastSelectedViewDesc=void 0)}function Ri(n,e,t,r){return n.someProp("createSelectionBetween",o=>o(n,e,t))||C.between(e,t,r)}function Wa(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&&T.findFrom(s,e)}function we(n,e){return n.dispatch(n.state.tr.setSelection(e).scrollIntoView()),!0}function rs(n,e,t){let r=n.state.selection;if(r instanceof C)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 we(n,new C(r.$anchor,i))}else if(r.empty){if(n.endOfTextblock(e>0?"forward":"backward")){let o=Br(n.state,e);return o&&o instanceof w?we(n,o):!1}else if(!(oe&&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?w.isSelectable(s)?we(n,new w(e<0?n.state.doc.resolve(o.pos-s.nodeSize):o)):so?we(n,new C(n.state.doc.resolve(e<0?l:l+s.nodeSize))):!1:!1}}else return!1;else{if(r instanceof w&&r.node.isInline)return we(n,new C(e>0?r.$to:r.$from));{let o=Br(n.state,e);return o?we(n,o):!1}}}function un(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function bt(n,e){let t=n.pmViewDesc;return t&&t.size==0&&(e<0||n.nextSibling||n.nodeName!="BR")}function Ge(n,e){return e<0?Ka(n):Ja(n)}function Ka(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let o,s,i=!1;for(Yn&&t.nodeType==1&&r<un(t)&&bt(t.childNodes[r],-1)&&(i=!0);;)if(r>0){if(t.nodeType!=1)break;{let l=t.childNodes[r-1];if(bt(l,-1))o=t,s=--r;else if(l.nodeType==3)t=l,r=t.nodeValue.length;else break}}else{if(Ii(t))break;{let l=t.previousSibling;for(;l&&bt(l,-1);)o=t.parentNode,s=qe(l),l=l.previousSibling;if(l)t=l,r=un(t);else{if(t=t.parentNode,t==n.dom)break;r=0}}}i?Pr(n,t,r):o&&Pr(n,o,s)}function Ja(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let o=un(t),s,i;for(;;)if(r<o){if(t.nodeType!=1)break;let l=t.childNodes[r];if(bt(l,1))s=t,i=++r;else break}else{if(Ii(t))break;{let l=t.nextSibling;for(;l&&bt(l,1);)s=l.parentNode,i=qe(l)+1,l=l.nextSibling;if(l)t=l,r=0,o=un(t);else{if(t=t.parentNode,t==n.dom)break;r=o=0}}}s&&Pr(n,s,i)}function Ii(n){let e=n.pmViewDesc;return e&&e.node&&e.node.isBlock}function Va(n,e){for(;n&&e==n.childNodes.length&&!ro(n);)e=qe(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 qa(n,e){for(;n&&!e&&!ro(n);)e=qe(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 Pr(n,e,t){if(e.nodeType!=3){let s,i;(i=Va(e,t))?(e=i,t=0):(s=qa(e,t))&&(e=s,t=s.nodeValue.length)}let r=n.domSelection();if(!r)return;if(Ti(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&&io(n)},50)}function ss(n,e){let t=n.state.doc.resolve(e);if(!(Le||Ba)&&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 is(n,e,t){let r=n.state.selection;if(r instanceof C&&!r.empty||t.indexOf("s")>-1||oe&&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 w)return we(n,i)}if(!o.parent.inlineContent){let i=e<0?o:s,l=r instanceof ce?T.near(i,e):T.findFrom(i,e);return l?we(n,l):!1}return!1}function ls(n,e){if(!(n.state.selection instanceof C))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 as(n,e,t){n.domObserver.stop(),e.contentEditable=t,n.domObserver.start()}function Ua(n){if(!Ue||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;as(n,r,"true"),setTimeout(()=>as(n,r,"false"),20)}return!1}function _a(n){let e="";return n.ctrlKey&&(e+="c"),n.metaKey&&(e+="m"),n.altKey&&(e+="a"),n.shiftKey&&(e+="s"),e}function Ga(n,e){let t=e.keyCode,r=_a(e);if(t==8||oe&&t==72&&r=="c")return ls(n,-1)||Ge(n,-1);if(t==46&&!e.shiftKey||oe&&t==68&&r=="c")return ls(n,1)||Ge(n,1);if(t==13||t==27)return!0;if(t==37||oe&&t==66&&r=="c"){let o=t==37?ss(n,n.state.selection.from)=="ltr"?-1:1:-1;return rs(n,o,r)||Ge(n,o)}else if(t==39||oe&&t==70&&r=="c"){let o=t==39?ss(n,n.state.selection.from)=="ltr"?1:-1:1;return rs(n,o,r)||Ge(n,o)}else{if(t==38||oe&&t==80&&r=="c")return is(n,-1,r)||Ge(n,-1);if(t==40||oe&&t==78&&r=="c")return Ua(n)||is(n,1,r)||Ge(n,1);if(r==(oe?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function vi(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")||_n.fromSchema(n.state.schema),l=Hi(),a=l.createElement("div");a.appendChild(i.serializeFragment(r,{document:l}));let c=a.firstChild,u,f=0;for(;c&&c.nodeType==1&&(u=Pi[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),f++}c=a.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${o} ${s}${f?` -${f}`:""} ${JSON.stringify(t)}`);let d=n.someProp("clipboardTextSerializer",h=>h(e,n))||e.content.textBetween(0,e.content.size,`
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):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=`
7
+ `);return{dom:a,text:d,slice:e}}function Li(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",d=>{e=d(e,s||r,n)}),s)return e?new x(b.from(n.state.schema.text(e.replace(/\r\n?/g,`
8
+ `))),0,0):x.empty;let f=n.someProp("clipboardTextParser",d=>d(e,o,r,n));if(f)l=f;else{let d=o.marks(),{schema:h}=n.state,p=_n.fromSchema(h);i=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(m=>{let y=i.appendChild(document.createElement("p"));m&&y.appendChild(p.serializeNode(h.text(m,d)))})}}else n.someProp("transformPastedHTML",f=>{t=f(t,n)}),i=Za(t),so&&ec(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 f=+u[3];f>0;f--){let d=i.firstChild;for(;d&&d.nodeType!=1;)d=d.nextSibling;if(!d)break;i=d}if(l||(l=(n.someProp("clipboardParser")||n.someProp("domParser")||$e.fromSchema(n.state.schema)).parseSlice(i,{preserveWhitespace:!!(a||u),context:o,ruleFromNode(d){return d.nodeName=="BR"&&!d.nextSibling&&d.parentNode&&!Qa.test(d.parentNode.nodeName)?{ignore:!0}:null}})),u)l=tc(cs(l,+u[1],+u[2]),u[4]);else if(l=x.maxOpen(Xa(l.content,o),!0),l.openStart||l.openEnd){let f=0,d=0;for(let h=l.content.firstChild;f<l.openStart&&!h.type.spec.isolating;f++,h=h.firstChild);for(let h=l.content.lastChild;d<l.openEnd&&!h.type.spec.isolating;d++,h=h.lastChild);l=cs(l,f,d)}return n.someProp("transformPasted",f=>{l=f(l,n)}),l}const Qa=/^(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 Xa(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&&Di(a,s,l,i[i.length-1],0))i[i.length-1]=c;else{i.length&&(i[i.length-1]=Bi(i[i.length-1],s.length));let u=zi(l,a);i.push(u),o=o.matchType(u.type),s=a}}),i)return b.from(i)}return n}function zi(n,e,t=0){for(let r=e.length-1;r>=t;r--)n=e[r].create(null,b.from(n));return n}function Di(n,e,t,r,o){if(o<n.length&&o<e.length&&n[o]==e[o]){let s=Di(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(zi(t,n,o+1))))}}function Bi(n,e){if(e==0)return n;let t=n.content.replaceChild(n.childCount-1,Bi(n.lastChild,e-1)),r=n.contentMatchAt(n.childCount).fillBefore(b.empty,!0);return n.copy(t.append(r))}function Hr(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=Hr(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 cs(n,e,t){return e<n.openStart&&(n=new x(Hr(n.content,-1,e,n.openStart,0,n.openEnd),e,n.openEnd)),t<n.openEnd&&(n=new x(Hr(n.content,1,t,n.openEnd,0,0),n.openStart,t)),n}const Pi={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 us=null;function Hi(){return us||(us=document.implementation.createHTMLDocument("title"))}function Ya(n){let e=window.trustedTypes;return e?e.createPolicy("detachedDocument",{createHTML:t=>t}).createHTML(n):n}function Za(n){let e=/^(\s*<meta [^>]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=Hi().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(n),o;if((o=r&&Pi[r[1].toLowerCase()])&&(n=o.map(s=>"<"+s+">").join("")+n+o.map(s=>"</"+s+">").reverse().join("")),t.innerHTML=Ya(n),o)for(let s=0;s<o.length;s++)t=t.querySelector(o[s])||t;return t}function ec(n){let e=n.querySelectorAll(Le?"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 tc(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 x(o,s,i)}const ue={},Z={};function Ne(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}Z.keydown=(n,e)=>{let t=e;if(n.input.shiftKey=t.keyCode==16||t.shiftKey,!$i(n,t)&&(n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),!(It&&Le&&t.keyCode==13)))if(n.domObserver.selectionChanged(n.domSelectionRange())?n.domObserver.flush():t.keyCode!=229&&n.domObserver.forceFlush(),oo&&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,Ai(13,"Enter"))),n.input.lastIOSEnter=0)},200)}else n.someProp("handleKeyDown",r=>r(n,t))||Ga(n,t)?t.preventDefault():Ne(n,"key")};Z.keyup=(n,e)=>{e.keyCode==16&&(n.input.shiftKey=!1)};Z.keypress=(n,e)=>{let t=e;if($i(n,t)||!t.charCode||t.ctrlKey&&!t.altKey||oe&&t.metaKey)return;if(n.someProp("handleKeyPress",o=>o(n,t))){t.preventDefault();return}let r=n.state.selection;if(!(r instanceof C)||!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 Zn(n){return{left:n.clientX,top:n.clientY}}function nc(n,e){let t=e.x-n.clientX,r=e.y-n.clientY;return t*t+r*r<100}function lo(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 rt(n,e,t){if(n.focused||n.focus(),n.state.selection.eq(e))return;let r=n.state.tr.setSelection(e);r.setMeta("pointer",!0),n.dispatch(r)}function rc(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),r=t.nodeAfter;return r&&r.isAtom&&w.isSelectable(r)?(rt(n,new w(t)),!0):!1}function oc(n,e){if(e==-1)return!1;let t=n.state.selection,r,o;t instanceof w&&(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(w.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?(rt(n,w.create(n.state.doc,o)),!0):!1}function sc(n,e,t,r,o){return lo(n,"handleClickOn",e,t,r)||n.someProp("handleClick",s=>s(n,e,r))||(o?oc(n,t):rc(n,t))}function ic(n,e,t,r){return lo(n,"handleDoubleClickOn",e,t,r)||n.someProp("handleDoubleClick",o=>o(n,e,r))}function lc(n,e,t,r){return lo(n,"handleTripleClickOn",e,t,r)||n.someProp("handleTripleClick",o=>o(n,e,r))||ac(n,t,r)}function ac(n,e,t){if(t.button!=0)return!1;let r=n.state.doc;if(e==-1)return r.inlineContent?(rt(n,C.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)rt(n,C.create(r,l+1,l+1+i.content.size));else if(w.isSelectable(i))rt(n,w.create(r,l));else continue;return!0}}function ao(n){return fn(n)}const Fi=oe?"metaKey":"ctrlKey";ue.mousedown=(n,e)=>{let t=e;n.input.shiftKey=t.shiftKey;let r=ao(n),o=Date.now(),s="singleClick";o-n.input.lastClick.time<500&&nc(t,n.input.lastClick)&&!t[Fi]&&(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(Zn(t));i&&(s=="singleClick"?(n.input.mouseDown&&n.input.mouseDown.done(),n.input.mouseDown=new cc(n,i,t,!!r)):(s=="doubleClick"?ic:lc)(n,i.pos,i.inside,t)?t.preventDefault():Ne(n,"pointer"))};class cc{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[Fi],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 w&&c.from<=i&&c.to>i)&&(this.mightDrag={node:s,pos:i,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Yn&&!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)),Ne(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(()=>io(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(Zn(e))),this.updateAllowDefault(e),this.allowDefault||!t?Ne(this.view,"pointer"):sc(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||Ue&&this.mightDrag&&!this.mightDrag.node.isAtom||Le&&!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)?(rt(this.view,T.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):Ne(this.view,"pointer")}move(e){this.updateAllowDefault(e),Ne(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)}}ue.touchstart=n=>{n.input.lastTouch=Date.now(),ao(n),Ne(n,"pointer")};ue.touchmove=n=>{n.input.lastTouch=Date.now(),Ne(n,"pointer")};ue.contextmenu=n=>ao(n);function $i(n,e){return n.composing?!0:Ue&&Math.abs(e.timeStamp-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}const uc=It?5e3:-1;Z.compositionstart=Z.compositionupdate=n=>{if(!n.composing){n.domObserver.flush();let{state:e}=n,t=e.selection.$to;if(e.selection instanceof C&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)))n.markCursor=n.state.storedMarks||t.marks(),fn(n,!0),n.markCursor=null;else if(fn(n,!e.selection.empty),Yn&&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){let l=n.domSelection();l&&l.collapse(i,i.nodeValue.length);break}else o=i,s=-1}}n.input.composing=!0}ji(n,uc)};Z.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++,ji(n,20))};function ji(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>fn(n),e))}function fc(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=dc());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function dc(){let n=document.createEvent("Event");return n.initEvent("event",!0,!0),n.timeStamp}function fn(n,e=!1){if(!(It&&n.domObserver.flushingSoon>=0)){if(n.domObserver.forceFlush(),fc(n),e||n.docView&&n.docView.dirty){let t=Ha(n);return t&&!t.eq(n.state.selection)?n.dispatch(n.state.tr.setSelection(t)):(n.markCursor||e)&&!n.state.selection.empty?n.dispatch(n.state.tr.deleteSelection()):n.updateState(n.state),!0}return!1}}function hc(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 Tt=Rt&&Ei<15||oo&&Pa<604;ue.copy=Z.cut=(n,e)=>{let t=e,r=n.state.selection,o=t.type=="cut";if(r.empty)return;let s=Tt?null:t.clipboardData,i=r.content(),{dom:l,text:a}=vi(n,i);s?(t.preventDefault(),s.clearData(),s.setData("text/html",l.innerHTML),s.setData("text/plain",a)):hc(n,l),o&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function pc(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function mc(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?Fr(n,r.value,null,o,e):Fr(n,r.textContent,r.innerHTML,o,e)},50)}function Fr(n,e,t,r,o){let s=Li(n,e,t,r,n.state.selection.$from);if(n.someProp("handlePaste",a=>a(n,o,s||x.empty)))return!0;if(!s)return!1;let i=pc(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 Wi(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," "):""}Z.paste=(n,e)=>{let t=e;if(n.composing&&!It)return;let r=Tt?null:t.clipboardData,o=n.input.shiftKey&&n.input.lastKeyCode!=45;r&&Fr(n,Wi(r),r.getData("text/html"),o,t)?t.preventDefault():mc(n,t)};class gc{constructor(e,t,r){this.slice=e,this.move=t,this.node=r}}const Ki=oe?"altKey":"ctrlKey";ue.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(Zn(t)),i;if(!(s&&s.pos>=o.from&&s.pos<=(o instanceof w?o.to-1:o.to))){if(r&&r.mightDrag)i=w.create(n.state.doc,r.mightDrag.pos);else if(t.target&&t.target.nodeType==1){let f=n.docView.nearestDesc(t.target,!0);f&&f.node.type.spec.draggable&&f!=n.docView&&(i=w.create(n.state.doc,f.posBefore))}}let l=(i||n.state.selection).content(),{dom:a,text:c,slice:u}=vi(n,l);(!t.dataTransfer.files.length||!Le||Ni>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(Tt?"Text":"text/html",a.innerHTML),t.dataTransfer.effectAllowed="copyMove",Tt||t.dataTransfer.setData("text/plain",c),n.dragging=new gc(u,!t[Ki],i)};ue.dragend=n=>{let e=n.dragging;window.setTimeout(()=>{n.dragging==e&&(n.dragging=null)},50)};Z.dragover=Z.dragenter=(n,e)=>e.preventDefault();Z.drop=(n,e)=>{let t=e,r=n.dragging;if(n.dragging=null,!t.dataTransfer)return;let o=n.posAtCoords(Zn(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=Li(n,Wi(t.dataTransfer),Tt?null:t.dataTransfer.getData("text/html"),!1,s);let l=!!(r&&!t[Ki]);if(n.someProp("handleDrop",p=>p(n,t,i||x.empty,l))){t.preventDefault();return}if(!i)return;t.preventDefault();let a=i?Ma(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),f=i.openStart==0&&i.openEnd==0&&i.content.childCount==1,d=c.doc;if(f?c.replaceRangeWith(u,u,i.content.firstChild):c.replaceRange(u,u,i),c.doc.eq(d))return;let h=c.doc.resolve(u);if(f&&w.isSelectable(i.content.firstChild)&&h.nodeAfter&&h.nodeAfter.sameMarkup(i.content.firstChild))c.setSelection(new w(h));else{let p=c.mapping.map(a);c.mapping.maps[c.mapping.maps.length-1].forEach((m,y,g,M)=>p=M),c.setSelection(Ri(n,h,c.doc.resolve(p)))}n.focus(),n.dispatch(c.setMeta("uiEvent","drop"))};ue.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())&&io(n)},20))};ue.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)};ue.beforeinput=(n,e)=>{if(Le&&It&&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,Ai(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 Z)ue[n]=Z[n];function At(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 dn{constructor(e,t){this.toDOM=e,this.spec=t||je,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 ae(s-r,s-r,this)}valid(){return!0}eq(e){return this==e||e instanceof dn&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&At(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class Oe{constructor(e,t){this.attrs=e,this.spec=t||je}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 ae(s,i,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof Oe&&At(this.attrs,e.attrs)&&At(this.spec,e.spec)}static is(e){return e.type instanceof Oe}destroy(){}}class co{constructor(e,t){this.attrs=e,this.spec=t||je}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 ae(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 co&&At(this.attrs,e.attrs)&&At(this.spec,e.spec)}destroy(){}}class ae{constructor(e,t,r){this.from=e,this.to=t,this.type=r}copy(e,t){return new ae(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 ae(e,e,new dn(t,r))}static inline(e,t,r,o){return new ae(e,t,new Oe(r,o))}static node(e,t,r,o){return new ae(e,t,new co(r,o))}get spec(){return this.type.spec}get inline(){return this.type instanceof Oe}get widget(){return this.type instanceof dn}}const Ye=[],je={};class P{constructor(e,t){this.local=e.length?e:Ye,this.children=t.length?t:Ye}static create(e,t){return t.length?hn(t,e,0,je):G}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==G||e.maps.length==0?this:this.mapInner(e,t,0,0,r||je)}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?yc(this.children,i||[],e,t,r,o,s):i?new P(i.sort(We),Ye):G}add(e,t){return t.length?this==G?P.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=Vi(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,hn(u,l,c+1,je)),s+=3}});let i=Ji(s?qi(t):t,-r);for(let l=0;l<i.length;l++)i[l].type.valid(e,i[l])||i.splice(l--,1);return new P(i.length?this.local.concat(i).sort(We):this.local,o||this.children)}remove(e){return e.length==0||this==G?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,f;u<e.length;u++)(f=e[u])&&f.from>l&&f.to<a&&(e[u]=null,(i||(i=[])).push(f));if(!i)continue;r==this.children&&(r=this.children.slice());let c=r[s+2].removeInner(i,l+1);c!=G?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 P(o,r):G}forChild(e,t){if(this==G)return this;if(t.isLeaf)return P.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 Oe){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 P(o.sort(We),Ye);return r?new De([l,r]):l}return r||G}eq(e){if(this==e)return!0;if(!(e instanceof P)||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 uo(this.localsInner(e))}localsInner(e){if(this==G)return Ye;if(e.inlineContent||!this.local.some(Oe.is))return this.local;let t=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof Oe||t.push(this.local[r]);return t}forEachSet(e){e(this)}}P.empty=new P([],[]);P.removeOverlap=uo;const G=P.empty;class De{constructor(e){this.members=e}map(e,t){const r=this.members.map(o=>o.map(e,t,je));return De.from(r)}forChild(e,t){if(t.isLeaf)return P.empty;let r=[];for(let o=0;o<this.members.length;o++){let s=this.members[o].forChild(e,t);s!=G&&(s instanceof De?r=r.concat(s.members):r.push(s))}return De.from(r)}eq(e){if(!(e instanceof De)||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?uo(r?t:t.sort(We)):Ye}static from(e){switch(e.length){case 0:return G;case 1:return e[0];default:return new De(e.every(t=>t instanceof P)?e:e.reduce((t,r)=>t.concat(r instanceof P?r:r.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}}function yc(n,e,t,r,o,s,i){let l=n.slice();for(let c=0,u=s;c<t.maps.length;c++){let f=0;t.maps[c].forEach((d,h,p,m)=>{let y=m-p-(h-d);for(let g=0;g<l.length;g+=3){let M=l[g+1];if(M<0||d>M+u-f)continue;let S=l[g]+u-f;h>=S?l[g+1]=d<=S?-2:-1:d>=u&&y&&(l[g]+=y,l[g+1]+=y)}f+=y}),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),f=u-o;if(f<0||f>=r.content.size){a=!0;continue}let d=t.map(n[c+1]+s,-1),h=d-o,{index:p,offset:m}=r.content.findIndex(f),y=r.maybeChild(p);if(y&&m==f&&m+y.nodeSize==h){let g=l[c+2].mapInner(t,y,u+1,n[c]+s+1,i);g!=G?(l[c]=f,l[c+1]=h,l[c+2]=g):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=bc(l,n,e,t,o,s,i),u=hn(c,r,0,i);e=u.local;for(let f=0;f<l.length;f+=3)l[f+1]<0&&(l.splice(f,3),f-=3);for(let f=0,d=0;f<u.children.length;f+=3){let h=u.children[f];for(;d<l.length&&l[d]<h;)d+=3;l.splice(d,0,u.children[f],u.children[f+1],u.children[f+2])}}return new P(e.sort(We),l)}function Ji(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 ae(o.from+e,o.to+e,o.type))}return t}function bc(n,e,t,r,o,s,i){function l(a,c){for(let u=0;u<a.local.length;u++){let f=a.local[u].map(r,o,c);f?t.push(f):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 Vi(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 qi(n){let e=[];for(let t=0;t<n.length;t++)n[t]!=null&&e.push(n[t]);return e}function hn(n,e,t,r){let o=[],s=!1;e.forEach((l,a)=>{let c=Vi(n,l,a+t);if(c){s=!0;let u=hn(c,l,t+a+1,r);u!=G&&o.push(a,a+l.nodeSize,u)}});let i=Ji(s?qi(n):n,-t).sort(We);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 P(i,o):G}function We(n,e){return n.from-e.from||n.to-e.to}function uo(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),fs(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),fs(e,o,r.copy(s.from,r.to)));break}}}return e}function fs(n,e,t){for(;e<n.length&&We(t,n[e])>0;)e++;n.splice(e,0,t)}var Re={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:"'"},pn={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},kc=typeof navigator<"u"&&/Mac/.test(navigator.platform),xc=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var J=0;J<10;J++)Re[48+J]=Re[96+J]=String(J);for(var J=1;J<=24;J++)Re[J+111]="F"+J;for(var J=65;J<=90;J++)Re[J]=String.fromCharCode(J+32),pn[J]=String.fromCharCode(J);for(var pr in Re)pn.hasOwnProperty(pr)||(pn[pr]=Re[pr]);function Sc(n){var e=kc&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||xc&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?pn:Re)[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 wc=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):!1;function Cc(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))wc?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 Tc(n){let e=Object.create(null);for(let t in n)e[Cc(t)]=n[t];return e}function mr(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 Ac(n){let e=Tc(n);return function(t,r){let o=Sc(r),s,i=e[mr(o,r)];if(i&&i(t.state,t.dispatch,t))return!0;if(o.length==1&&o!=" "){if(r.shiftKey){let l=e[mr(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=Re[r.keyCode])&&s!=o){let l=e[mr(s,r)];if(l&&l(t.state,t.dispatch,t))return!0}}return!1}}const Mc=(n,e)=>n.selection.empty?!1:(e&&e(n.tr.deleteSelection().scrollIntoView()),!0);function Ui(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("backward",n):t.parentOffset>0)?null:t}const Ec=(n,e,t)=>{let r=Ui(n,t);if(!r)return!1;let o=fo(r);if(!o){let i=r.blockRange(),l=i&&ct(i);return l==null?!1:(e&&e(n.tr.lift(i,l).scrollIntoView()),!0)}let s=o.nodeBefore;if(Xi(n,o,e,-1))return!0;if(r.parent.content.size==0&&(it(s,"end")||w.isSelectable(s)))for(let i=r.depth;;i--){let l=Qn(n.doc,r.before(i),r.after(i),x.empty);if(l&&l.slice.size<l.to-l.from){if(e){let a=n.tr.step(l);a.setSelection(it(s,"end")?T.findFrom(a.doc.resolve(a.mapping.map(o.pos,-1)),-1):w.create(a.doc,o.pos-s.nodeSize)),e(a.scrollIntoView())}return!0}if(i==1||r.node(i-1).childCount>1)break}return s.isAtom&&o.depth==r.depth-1?(e&&e(n.tr.delete(o.pos-s.nodeSize,o.pos).scrollIntoView()),!0):!1},Nc=(n,e,t)=>{let r=Ui(n,t);if(!r)return!1;let o=fo(r);return o?_i(n,o,e):!1},Oc=(n,e,t)=>{let r=Gi(n,t);if(!r)return!1;let o=ho(r);return o?_i(n,o,e):!1};function _i(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=Qn(n.doc,s,a,x.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(C.create(u.doc,s)),t(u.scrollIntoView())}return!0}function it(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 Rc=(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=fo(r)}let i=s&&s.nodeBefore;return!i||!w.isSelectable(i)?!1:(e&&e(n.tr.setSelection(w.create(n.doc,s.pos-i.nodeSize)).scrollIntoView()),!0)};function fo(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 Gi(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("forward",n):t.parentOffset<t.parent.content.size)?null:t}const Ic=(n,e,t)=>{let r=Gi(n,t);if(!r)return!1;let o=ho(r);if(!o)return!1;let s=o.nodeAfter;if(Xi(n,o,e,1))return!0;if(r.parent.content.size==0&&(it(s,"start")||w.isSelectable(s))){let i=Qn(n.doc,r.before(),r.after(),x.empty);if(i&&i.slice.size<i.to-i.from){if(e){let l=n.tr.step(i);l.setSelection(it(s,"start")?T.findFrom(l.doc.resolve(l.mapping.map(o.pos)),1):w.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},vc=(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=ho(r)}let i=s&&s.nodeAfter;return!i||!w.isSelectable(i)?!1:(e&&e(n.tr.setSelection(w.create(n.doc,s.pos)).scrollIntoView()),!0)};function ho(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 Lc=(n,e)=>{let t=n.selection,r=t instanceof w,o;if(r){if(t.node.isTextblock||!Ie(n.doc,t.from))return!1;o=t.from}else if(o=Gn(n.doc,t.from,-1),o==null)return!1;if(e){let s=n.tr.join(o);r&&s.setSelection(w.create(s.doc,o-n.doc.resolve(o).nodeBefore.nodeSize)),e(s.scrollIntoView())}return!0},zc=(n,e)=>{let t=n.selection,r;if(t instanceof w){if(t.node.isTextblock||!Ie(n.doc,t.to))return!1;r=t.to}else if(r=Gn(n.doc,t.to,1),r==null)return!1;return e&&e(n.tr.join(r).scrollIntoView()),!0},Dc=(n,e)=>{let{$from:t,$to:r}=n.selection,o=t.blockRange(r),s=o&&ct(o);return s==null?!1:(e&&e(n.tr.lift(o,s).scrollIntoView()),!0)},Bc=(n,e)=>{let{$head:t,$anchor:r}=n.selection;return!t.parent.type.spec.code||!t.sameParent(r)?!1:(e&&e(n.tr.insertText(`
9
+ `).scrollIntoView()),!0)};function Qi(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 Pc=(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=Qi(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(T.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},Hc=(n,e)=>{let t=n.selection,{$from:r,$to:o}=t;if(t instanceof ce||r.parent.inlineContent||o.parent.inlineContent)return!1;let s=Qi(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(C.create(l.doc,i+1)),e(l.scrollIntoView())}return!0},Fc=(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(tt(n.doc,s))return e&&e(n.tr.split(s).scrollIntoView()),!0}let r=t.blockRange(),o=r&&ct(r);return o==null?!1:(e&&e(n.tr.lift(r,o).scrollIntoView()),!0)},$c=(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(w.create(n.doc,o))),!0)};function jc(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||Ie(n.doc,e.pos))?!1:(t&&t(n.tr.clearIncompatible(e.pos,r.type,r.contentMatchAt(r.childCount)).join(e.pos).scrollIntoView()),!0)}function Xi(n,e,t,r){let o=e.nodeBefore,s=e.nodeAfter,i,l,a=o.type.spec.isolating||s.type.spec.isolating;if(!a&&jc(n,e,t))return!0;let c=!a&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(i=(l=o.contentMatchAt(o.childCount)).findWrapping(s.type))&&l.matchType(i[0]||s.type).validEnd){if(t){let h=e.pos+s.nodeSize,p=b.empty;for(let g=i.length-1;g>=0;g--)p=b.from(i[g].create(null,p));p=b.from(o.copy(p));let m=n.tr.step(new j(e.pos-1,h,e.pos,h,new x(p,1,0),i.length,!0)),y=h+2*i.length;Ie(m.doc,y)&&m.join(y),t(m.scrollIntoView())}return!0}let u=s.type.spec.isolating||r>0&&a?null:T.findFrom(e,1),f=u&&u.$from.blockRange(u.$to),d=f&&ct(f);if(d!=null&&d>=e.depth)return t&&t(n.tr.lift(f,d).scrollIntoView()),!0;if(c&&it(s,"start",!0)&&it(o,"end")){let h=o,p=[];for(;p.push(h),!h.isTextblock;)h=h.lastChild;let m=s,y=1;for(;!m.isTextblock;m=m.firstChild)y++;if(h.canReplace(h.childCount,h.childCount,m.content)){if(t){let g=b.empty;for(let S=p.length-1;S>=0;S--)g=b.from(p[S].copy(g));let M=n.tr.step(new j(e.pos-p.length,e.pos+s.nodeSize,e.pos+y,e.pos+s.nodeSize-y,new x(g,p.length,0),0,!0));t(M.scrollIntoView())}return!0}}return!1}function Yi(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(C.create(e.doc,n<0?o.start(s):o.end(s)))),!0):!1}}const Wc=Yi(-1),Kc=Yi(1);function Jc(n,e=null){return function(t,r){let{$from:o,$to:s}=t.selection,i=o.blockRange(s),l=i&&to(i,n,e);return l?(r&&r(t.tr.wrap(i,l).scrollIntoView()),!0):!1}}function ds(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),f=u.index();o=u.parent.canReplaceWith(f,f+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 Vc(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 on(u,u,i.depth),i.endIndex<i.parent.childCount&&(i=new on(o,t.doc.resolve(s.end(i.depth)),i.depth)),l=!0}let c=to(a,n,e,i);return c?(r&&r(qc(t.tr,i,c,l,n).scrollIntoView()),!0):!1}}function qc(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 j(e.start-(r?2:0),e.end,e.start,e.end,new x(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,f=e.endIndex,d=!0;u<f;u++,d=!1)!d&&tt(n.doc,a,l)&&(n.split(a,l),a+=2*l),a+=c.child(u).nodeSize;return n}function Uc(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?_c(e,t,n,s):Gc(e,t,s):!0:!1}}function _c(n,e,t,r){let o=n.tr,s=r.end,i=r.$to.end(r.depth);s<i&&(o.step(new j(s-1,i,s,i,new x(b.from(t.create(null,r.parent.copy())),1,0),1,!0)),r=new on(o.doc.resolve(r.$from.pos),o.doc.resolve(i),r.depth));const l=ct(r);if(l==null)return!1;o.lift(r,l);let a=o.mapping.map(s,-1)-1;return Ie(o.doc,a)&&o.join(a),e(o.scrollIntoView()),!0}function Gc(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 f=s.pos,d=f+i.nodeSize;return r.step(new j(f-(l?1:0),d+(a?1:0),f+1,d-1,new x((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 Qc(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),f=new x(b.from(n.create(null,b.from(l.type.create(null,u)))),c?3:1,0),d=s.start,h=s.end;t(e.tr.step(new j(d-(c?3:1),h,d,h,f,1,!0)).scrollIntoView())}return!0}}function Zi(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 Xc{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 f=a(...u)(i);return!s.getMeta("preventDispatch")&&!this.hasCustomState&&o.dispatch(s),f}]))}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(d=>d===!0)),f={...Object.fromEntries(Object.entries(r).map(([d,h])=>[d,(...m)=>{const y=this.buildProps(c,t),g=h(...m)(y);return l.push(g),f}])),run:u};return f}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:Zi({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 q(n,e,t){return n.config[e]===void 0&&n.parent?q(n.parent,e,t):typeof n.config[e]=="function"?n.config[e].bind({...t,parent:n.parent?q(n.parent,e,t):null}):n.config[e]}function Yc(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 V(n,e){if(typeof n=="string"){if(!e.nodes[n])throw Error(`There is no node type named '${n}'. Maybe you forgot to add the extension?`);return e.nodes[n]}return n}function v(...n){return n.filter(e=>!!e).reduce((e,t)=>{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 if(o==="style"){const l=s?s.split(";").map(u=>u.trim()).filter(Boolean):[],a=r[o]?r[o].split(";").map(u=>u.trim()).filter(Boolean):[],c=new Map;a.forEach(u=>{const[f,d]=u.split(":").map(h=>h.trim());c.set(f,d)}),l.forEach(u=>{const[f,d]=u.split(":").map(h=>h.trim());c.set(f,d)}),r[o]=Array.from(c.entries()).map(([u,f])=>`${u}: ${f}`).join("; ")}else r[o]=s}),r},{})}function Zc(n){return typeof n=="function"}function F(n,e=void 0,...t){return Zc(n)?e?n.bind(e)(...t):n(...t):n}function eu(n){return Object.prototype.toString.call(n)==="[object RegExp]"}class er{constructor(e){this.find=e.find,this.handler=e.handler}}function tu(n){return Object.prototype.toString.call(n).slice(8,-1)}function Pt(n){return tu(n)!=="Object"?!1:n.constructor===Object&&Object.getPrototypeOf(n)===Object.prototype}function tr(n,e){const t={...n};return Pt(n)&&Pt(e)&&Object.keys(e).forEach(r=>{Pt(e[r])&&Pt(n[r])?t[r]=tr(n[r],e[r]):t[r]=e[r]}),t}class ee{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=F(q(this,"addOptions",{name:this.name}))),this.storage=F(q(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new ee(e)}configure(e={}){const t=this.extend({...this.config,addOptions:()=>tr(this.options,e)});return t.name=this.name,t.parent=this.parent,t}extend(e={}){const t=new ee(e);return t.parent=this,this.child=t,t.name=e.name?e.name:t.parent.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${t.name}".`),t.options=F(q(t,"addOptions",{name:t.name})),t.storage=F(q(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 nu{constructor(e){this.find=e.find,this.handler=e.handler}}class ie{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=F(q(this,"addOptions",{name:this.name}))),this.storage=F(q(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new ie(e)}configure(e={}){const t=this.extend({...this.config,addOptions:()=>tr(this.options,e)});return t.name=this.name,t.parent=this.parent,t}extend(e={}){const t=new ie({...this.config,...e});return t.parent=this,this.child=t,t.name=e.name?e.name:t.parent.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${t.name}".`),t.options=F(q(t,"addOptions",{name:t.name})),t.storage=F(q(t,"addStorage",{name:t.name,options:t.options})),t}}function ru(n,e,t){const{from:r,to:o}=e,{blockSeparator:s=`
9
10
 
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
+ `,textSerializers:i={}}=t||{};let l="";return n.nodesBetween(r,o,(a,c,u,f)=>{var d;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:f,range:e})),!1;a.isText&&(l+=(d=a==null?void 0:a.text)===null||d===void 0?void 0:d.slice(Math.max(r,c)-c,o-c))}),l}function ou(n){return Object.fromEntries(Object.entries(n.nodes).filter(([,e])=>e.spec.toText).map(([e,t])=>[e,t.spec.toText]))}ie.create({name:"clipboardTextSerializer",addOptions(){return{blockSeparator:void 0}},addProseMirrorPlugins(){return[new te({key:new X("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=ou(t);return ru(r,{from:i,to:l},{...this.options.blockSeparator!==void 0?{blockSeparator:this.options.blockSeparator}:{},textSerializers:a})}}})]}});const su=()=>({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),iu=(n=!1)=>({commands:e})=>e.setContent("",n),lu=()=>({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,f=c.resolve(u.map(a)),d=c.resolve(u.map(a+l.nodeSize)),h=f.blockRange(d);if(!h)return;const p=ct(h);if(l.type.isTextblock){const{defaultType:m}=f.parent.contentMatchAt(f.index());e.setNodeMarkup(h.start,m)}(p||p===0)&&e.lift(h,p)})}),!0},au=n=>e=>n(e),cu=()=>({state:n,dispatch:e})=>Hc(n,e),uu=(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 C(r.doc.resolve(i-1))),!0},fu=()=>({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},du=n=>({tr:e,state:t,dispatch:r})=>{const o=V(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},hu=n=>({tr:e,dispatch:t})=>{const{from:r,to:o}=n;return t&&e.delete(r,o),!0},pu=()=>({state:n,dispatch:e})=>Mc(n,e),mu=()=>({commands:n})=>n.keyboardShortcut("Enter"),gu=()=>({state:n,dispatch:e})=>Pc(n,e);function mn(n,e,t={strict:!0}){const r=Object.keys(e);return r.length?r.every(o=>t.strict?e[o]===n[o]:eu(e[o])?e[o].test(n[o]):e[o]===n[o]):!0}function $r(n,e,t={}){return n.find(r=>r.type===e&&mn(r.attrs,t))}function yu(n,e,t={}){return!!$r(n,e,t)}function po(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=$r([...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($r([...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&&yu([...n.parent.child(l).marks],e,t);)a+=n.parent.child(l).nodeSize,l+=1;return{from:i,to:a}}function ze(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 bu=(n,e={})=>({tr:t,state:r,dispatch:o})=>{const s=ze(n,r.schema),{doc:i,selection:l}=t,{$from:a,from:c,to:u}=l;if(o){const f=po(a,s,e);if(f&&f.from<=c&&f.to>=u){const d=C.create(i,f.from,f.to);t.setSelection(d)}}return!0},ku=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 el(n){return n instanceof C}function Be(n=0,e=0,t=0){return Math.min(Math.max(n,e),t)}function xu(n,e=null){if(!e)return null;const t=T.atStart(n),r=T.atEnd(n);if(e==="start"||e===!0)return t;if(e==="end")return r;const o=t.from,s=r.to;return e==="all"?C.create(n,Be(0,o,s),Be(n.content.size,o,s)):C.create(n,Be(e,o,s),Be(e,o,s))}function mo(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}const Su=(n=null,e={})=>({editor:t,view:r,tr:o,dispatch:s})=>{e={scrollIntoView:!0,...e};const i=()=>{mo()&&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&&!el(t.state.selection))return i(),!0;const l=xu(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},wu=(n,e)=>t=>n.every((r,o)=>e(r,{...t,index:o})),Cu=(n,e)=>({tr:t,commands:r})=>r.insertContentAt({from:t.selection.from,to:t.selection.to},n,e),tl=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&&tl(r)}return n};function Ht(n){const e=`<body>${n}</body>`,t=new window.DOMParser().parseFromString(e,"text/html").body;return tl(t)}function gn(n,e,t){t={slice:!0,parseOptions:{},...t};const r=typeof n=="object"&&n!==null,o=typeof n=="string";if(r)try{if(Array.isArray(n)&&n.length>0)return b.fromArray(n.map(l=>e.nodeFromJSON(l)));const i=e.nodeFromJSON(n);return t.errorOnInvalidContent&&i.check(),i}catch(s){if(t.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:s});return console.warn("[tiptap warn]: Invalid content.","Passed value:",n,"Error:",s),gn("",e,t)}if(o){if(t.errorOnInvalidContent){let i=!1,l="";const a=new ta({topNode:e.spec.topNode,marks:e.spec.marks,nodes:e.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:c=>(i=!0,l=typeof c=="string"?c:c.outerHTML,null)}]}})});if(t.slice?$e.fromSchema(a).parseSlice(Ht(n),t.parseOptions):$e.fromSchema(a).parse(Ht(n),t.parseOptions),t.errorOnInvalidContent&&i)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${l}`)})}const s=$e.fromSchema(e);return t.slice?s.parseSlice(Ht(n),t.parseOptions).content:s.parse(Ht(n),t.parseOptions)}return gn("",e,t)}function Tu(n,e,t){const r=n.steps.length-1;if(r<e)return;const o=n.steps[r];if(!(o instanceof $||o instanceof j))return;const s=n.mapping.maps[r];let i=0;s.forEach((l,a,c,u)=>{i===0&&(i=u)}),n.setSelection(T.near(n.doc.resolve(i),t))}const Au=n=>!("type"in n),Mu=(n,e,t)=>({tr:r,dispatch:o,editor:s})=>{var i;if(o){t={parseOptions:{},updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...t};let l;try{l=gn(e,s.schema,{parseOptions:{preserveWhitespace:"full",...t.parseOptions},errorOnInvalidContent:(i=t.errorOnInvalidContent)!==null&&i!==void 0?i:s.options.enableContentCheck})}catch(p){return s.emit("contentError",{editor:s,error:p,disableCollaboration:()=>{console.error("[tiptap error]: Unable to disable collaboration at this point in time")}}),!1}let{from:a,to:c}=typeof n=="number"?{from:n,to:n}:{from:n.from,to:n.to},u=!0,f=!0;if((Au(l)?l:[l]).forEach(p=>{p.check(),u=u?p.isText&&p.marks.length===0:!1,f=f?p.isBlock:!1}),a===c&&f){const{parent:p}=r.doc.resolve(a);p.isTextblock&&!p.type.spec.code&&!p.childCount&&(a-=1,c+=1)}let h;u?(Array.isArray(e)?h=e.map(p=>p.text||"").join(""):typeof e=="object"&&e&&e.text?h=e.text:h=e,r.insertText(h,a,c)):(h=l,r.replaceWith(a,c,h)),t.updateSelection&&Tu(r,r.steps.length-1,-1),t.applyInputRules&&r.setMeta("applyInputRules",{from:a,text:h}),t.applyPasteRules&&r.setMeta("applyPasteRules",{from:a,text:h})}return!0},Eu=()=>({state:n,dispatch:e})=>Lc(n,e),Nu=()=>({state:n,dispatch:e})=>zc(n,e),Ou=()=>({state:n,dispatch:e})=>Ec(n,e),Ru=()=>({state:n,dispatch:e})=>Ic(n,e),Iu=()=>({state:n,dispatch:e,tr:t})=>{try{const r=Gn(n.doc,n.selection.$from.pos,-1);return r==null?!1:(t.join(r,2),e&&e(t),!0)}catch{return!1}},vu=()=>({state:n,dispatch:e,tr:t})=>{try{const r=Gn(n.doc,n.selection.$from.pos,1);return r==null?!1:(t.join(r,2),e&&e(t),!0)}catch{return!1}},Lu=()=>({state:n,dispatch:e})=>Nc(n,e),zu=()=>({state:n,dispatch:e})=>Oc(n,e);function nl(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function Du(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))mo()||nl()?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 Bu=n=>({editor:e,view:t,tr:r,dispatch:o})=>{const s=Du(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 go(n,e,t={}){const{from:r,to:o,empty:s}=n.selection,i=e?V(e,n.schema):null,l=[];n.doc.nodesBetween(r,o,(f,d)=>{if(f.isText)return;const h=Math.max(r,d),p=Math.min(o,d+f.nodeSize);l.push({node:f,from:h,to:p})});const a=o-r,c=l.filter(f=>i?i.name===f.node.type.name:!0).filter(f=>mn(f.node.attrs,t,{strict:!1}));return s?!!c.length:c.reduce((f,d)=>f+d.to-d.from,0)>=a}const Pu=(n,e={})=>({state:t,dispatch:r})=>{const o=V(n,t.schema);return go(t,o,e)?Dc(t,r):!1},Hu=()=>({state:n,dispatch:e})=>Fc(n,e),Fu=n=>({state:e,dispatch:t})=>{const r=V(n,e.schema);return Uc(r)(e,t)},$u=()=>({state:n,dispatch:e})=>Bc(n,e);function yo(n,e){return e.nodes[n]?"node":e.marks[n]?"mark":null}function hs(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 ju=(n,e)=>({tr:t,state:r,dispatch:o})=>{let s=null,i=null;const l=yo(typeof n=="string"?n:n.name,r.schema);return l?(l==="node"&&(s=V(n,r.schema)),l==="mark"&&(i=ze(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,hs(c.attrs,e)),i&&c.marks.length&&c.marks.forEach(f=>{i===f.type&&t.addMark(u,u+c.nodeSize,i.create(hs(f.attrs,e)))})})}),!0):!1},Wu=()=>({tr:n,dispatch:e})=>(e&&n.scrollIntoView(),!0),Ku=()=>({tr:n,commands:e})=>e.setTextSelection({from:0,to:n.doc.content.size}),Ju=()=>({state:n,dispatch:e})=>Rc(n,e),Vu=()=>({state:n,dispatch:e})=>vc(n,e),qu=()=>({state:n,dispatch:e})=>$c(n,e),Uu=()=>({state:n,dispatch:e})=>Kc(n,e),_u=()=>({state:n,dispatch:e})=>Wc(n,e);function Gu(n,e,t={},r={}){return gn(n,e,{slice:!1,parseOptions:t,errorOnInvalidContent:r.errorOnInvalidContent})}const Qu=(n,e=!1,t={},r={})=>({editor:o,tr:s,dispatch:i,commands:l})=>{var a,c;const{doc:u}=s;if(t.preserveWhitespace!=="full"){const f=Gu(n,o.schema,t,{errorOnInvalidContent:(a=r.errorOnInvalidContent)!==null&&a!==void 0?a:o.options.enableContentCheck});return i&&s.replaceWith(0,u.content.size,f).setMeta("preventUpdate",!e),!0}return i&&s.setMeta("preventUpdate",!e),l.insertContentAt({from:0,to:u.content.size},n,{parseOptions:t,errorOnInvalidContent:(c=r.errorOnInvalidContent)!==null&&c!==void 0?c:o.options.enableContentCheck})};function bo(n,e){const t=ze(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 Xu(n,e){const t=new ki(n);return e.forEach(r=>{r.steps.forEach(o=>{t.step(o)})}),t}function Yu(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 Zu(n,e,t){const r=[];return n.nodesBetween(e.from,e.to,(o,s)=>{t(o)&&r.push({node:o,pos:s})}),r}function rl(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 ko(n){return e=>rl(e.$from,n)}function ef(n,e){const t=V(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 tf(n,e){const t=yo(typeof e=="string"?e:e.name,n.schema);return t==="node"?ef(n,e):t==="mark"?bo(n,e):{}}function nf(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 rf(n){const e=nf(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 of(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),f=e.invert().map(c,-1),d=e.invert().map(u);r.push({oldRange:{from:f,to:d},newRange:{from:c,to:u}})})}),rf(r)}function xo(n,e,t){const r=[];return n===e?t.resolve(n).marks().forEach(o=>{const s=t.resolve(n),i=po(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 Qt(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 sf(n,e,t={}){const{empty:r,ranges:o}=n.selection,s=e?ze(e,n.schema):null;if(r)return!!(n.storedMarks||n.selection.$from.marks()).filter(f=>s?s.name===f.type.name:!0).find(f=>mn(f.attrs,t,{strict:!1}));let i=0;const l=[];if(o.forEach(({$from:f,$to:d})=>{const h=f.pos,p=d.pos;n.doc.nodesBetween(h,p,(m,y)=>{if(!m.isText&&!m.marks.length)return;const g=Math.max(h,y),M=Math.min(p,y+m.nodeSize),S=M-g;i+=S,l.push(...m.marks.map(W=>({mark:W,from:g,to:M})))})}),i===0)return!1;const a=l.filter(f=>s?s.name===f.mark.type.name:!0).filter(f=>mn(f.mark.attrs,t,{strict:!1})).reduce((f,d)=>f+d.to-d.from,0),c=l.filter(f=>s?f.mark.type!==s&&f.mark.type.excludes(s):!0).reduce((f,d)=>f+d.to-d.from,0);return(a>0?a+c:a)>=i}function ps(n,e){const{nodeExtensions:t}=Yc(e),r=t.find(i=>i.name===n);if(!r)return!1;const o={name:r.name,options:r.options,storage:r.storage},s=F(q(r,"group",o));return typeof s!="string"?!1:s.split(" ").includes("list")}function ol(n,{checkChildren:e=!0,ignoreWhitespace:t=!1}={}){var r;if(t){if(n.type.name==="hardBreak")return!0;if(n.isText)return/^\s*$/m.test((r=n.text)!==null&&r!==void 0?r:"")}if(n.isText)return!n.text;if(n.isAtom||n.isLeaf)return!1;if(n.content.childCount===0)return!0;if(e){let o=!0;return n.content.forEach(s=>{o!==!1&&(ol(s,{ignoreWhitespace:t,checkChildren:e})||(o=!1))}),o}return!1}function lf(n){return n instanceof w}function af(n,e,t){var r;const{selection:o}=e;let s=null;if(el(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,f,d)=>{if(c)return!1;if(u.isInline){const h=!d||d.type.allowsMarkType(t),p=!!t.isInSet(u.marks)||!u.marks.some(m=>m.type.excludes(t));c=h&&p}return!c}),c})}const cf=(n,e={})=>({tr:t,state:r,dispatch:o})=>{const{selection:s}=t,{empty:i,ranges:l}=s,a=ze(n,r.schema);if(o)if(i){const c=bo(r,a);t.addStoredMark(a.create({...c,...e}))}else l.forEach(c=>{const u=c.$from.pos,f=c.$to.pos;r.doc.nodesBetween(u,f,(d,h)=>{const p=Math.max(h,u),m=Math.min(h+d.nodeSize,f);d.marks.find(g=>g.type===a)?d.marks.forEach(g=>{a===g.type&&t.addMark(p,m,a.create({...g.attrs,...e}))}):t.addMark(p,m,a.create(e))})});return af(r,t,a)},uf=(n,e)=>({tr:t})=>(t.setMeta(n,e),!0),ff=(n,e={})=>({state:t,dispatch:r,chain:o})=>{const s=V(n,t.schema);return s.isTextblock?o().command(({commands:i})=>ds(s,e)(t)?!0:i.clearNodes()).command(({state:i})=>ds(s,e)(i,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},df=n=>({tr:e,dispatch:t})=>{if(t){const{doc:r}=e,o=Be(n,0,r.content.size),s=w.create(r,o);e.setSelection(s)}return!0},hf=n=>({tr:e,dispatch:t})=>{if(t){const{doc:r}=e,{from:o,to:s}=typeof n=="number"?{from:n,to:n}:n,i=C.atStart(r).from,l=C.atEnd(r).to,a=Be(o,i,l),c=Be(s,i,l),u=C.create(r,a,c);e.setSelection(u)}return!0},pf=n=>({state:e,dispatch:t})=>{const r=V(n,e.schema);return Qc(r)(e,t)};function ms(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 mf=({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=Qt(c,l.node().type.name,l.node().attrs);if(s instanceof w&&s.node.isBlock)return!l.parentOffset||!tt(i,l.pos)?!1:(r&&(n&&ms(t,o.extensionManager.splittableMarks),e.split(l.pos).scrollIntoView()),!0);if(!l.parent.isBlock)return!1;const f=a.parentOffset===a.parent.content.size,d=l.depth===0?void 0:Yu(l.node(-1).contentMatchAt(l.indexAfter(-1)));let h=f&&d?[{type:d,attrs:u}]:void 0,p=tt(e.doc,e.mapping.map(l.pos),1,h);if(!h&&!p&&tt(e.doc,e.mapping.map(l.pos),1,d?[{type:d}]:void 0)&&(p=!0,h=d?[{type:d,attrs:u}]:void 0),r){if(p&&(s instanceof C&&e.deleteSelection(),e.split(e.mapping.map(l.pos),1,h),d&&!f&&!l.parentOffset&&l.parent.type!==d)){const m=e.mapping.map(l.before()),y=e.doc.resolve(m);l.node(-1).canReplaceWith(y.index(),y.index()+1,d)&&e.setNodeMarkup(e.mapping.map(l.before()),d)}n&&ms(t,o.extensionManager.splittableMarks),e.scrollIntoView()}return p},gf=(n,e={})=>({tr:t,state:r,dispatch:o,editor:s})=>{var i;const l=V(n,r.schema),{$from:a,$to:c}=r.selection,u=r.selection.node;if(u&&u.isBlock||a.depth<2||!a.sameParent(c))return!1;const f=a.node(-1);if(f.type!==l)return!1;const d=s.extensionManager.attributes;if(a.parent.content.size===0&&a.node(-1).childCount===a.indexAfter(-1)){if(a.depth===2||a.node(-3).type!==l||a.index(-2)!==a.node(-2).childCount-1)return!1;if(o){let g=b.empty;const M=a.index(-1)?1:a.index(-2)?2:3;for(let B=a.depth-M;B>=a.depth-3;B-=1)g=b.from(a.node(B).copy(g));const S=a.indexAfter(-1)<a.node(-2).childCount?1:a.indexAfter(-2)<a.node(-3).childCount?2:3,W={...Qt(d,a.node().type.name,a.node().attrs),...e},O=((i=l.contentMatch.defaultType)===null||i===void 0?void 0:i.createAndFill(W))||void 0;g=g.append(b.from(l.createAndFill(null,O)||void 0));const E=a.before(a.depth-(M-1));t.replace(E,a.after(-S),new x(g,4-M,0));let z=-1;t.doc.nodesBetween(E,t.doc.content.size,(B,ft)=>{if(z>-1)return!1;B.isTextblock&&B.content.size===0&&(z=ft+1)}),z>-1&&t.setSelection(C.near(t.doc.resolve(z))),t.scrollIntoView()}return!0}const h=c.pos===a.end()?f.contentMatchAt(0).defaultType:null,p={...Qt(d,f.type.name,f.attrs),...e},m={...Qt(d,a.node().type.name,a.node().attrs),...e};t.delete(a.pos,c.pos);const y=h?[{type:l,attrs:p},{type:h,attrs:m}]:[{type:l,attrs:p}];if(!tt(t.doc,a.pos,2))return!1;if(o){const{selection:g,storedMarks:M}=r,{splittableMarks:S}=s.extensionManager,W=M||g.$to.parentOffset&&g.$from.marks();if(t.split(a.pos,2,y).scrollIntoView(),!W||!o)return!0;const O=W.filter(E=>S.includes(E.type.name));t.ensureMarks(O)}return!0},gr=(n,e)=>{const t=ko(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)&&Ie(n.doc,t.pos)&&n.join(t.pos),!0},yr=(n,e)=>{const t=ko(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)&&Ie(n.doc,r)&&n.join(r),!0},yf=(n,e,t,r={})=>({editor:o,tr:s,state:i,dispatch:l,chain:a,commands:c,can:u})=>{const{extensions:f,splittableMarks:d}=o.extensionManager,h=V(n,i.schema),p=V(e,i.schema),{selection:m,storedMarks:y}=i,{$from:g,$to:M}=m,S=g.blockRange(M),W=y||m.$to.parentOffset&&m.$from.marks();if(!S)return!1;const O=ko(E=>ps(E.type.name,f))(m);if(S.depth>=1&&O&&S.depth-O.depth<=1){if(O.node.type===h)return c.liftListItem(p);if(ps(O.node.type.name,f)&&h.validContent(O.node.content)&&l)return a().command(()=>(s.setNodeMarkup(O.pos,h),!0)).command(()=>gr(s,h)).command(()=>yr(s,h)).run()}return!t||!W||!l?a().command(()=>u().wrapInList(h,r)?!0:c.clearNodes()).wrapInList(h,r).command(()=>gr(s,h)).command(()=>yr(s,h)).run():a().command(()=>{const E=u().wrapInList(h,r),z=W.filter(B=>d.includes(B.type.name));return s.ensureMarks(z),E?!0:c.clearNodes()}).wrapInList(h,r).command(()=>gr(s,h)).command(()=>yr(s,h)).run()},bf=(n,e={},t={})=>({state:r,commands:o})=>{const{extendEmptyMarkRange:s=!1}=t,i=ze(n,r.schema);return sf(r,i,e)?o.unsetMark(i,{extendEmptyMarkRange:s}):o.setMark(i,e)},kf=(n,e,t={})=>({state:r,commands:o})=>{const s=V(n,r.schema),i=V(e,r.schema),l=go(r,s,t);let a;return r.selection.$anchor.sameParent(r.selection.$head)&&(a=r.selection.$anchor.parent.attrs),l?o.setNode(i,a):o.setNode(s,{...a,...t})},xf=(n,e={})=>({state:t,commands:r})=>{const o=V(n,t.schema);return go(t,o,e)?r.lift(o):r.wrapIn(o,e)},Sf=()=>({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},wf=()=>({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},Cf=(n,e={})=>({tr:t,state:r,dispatch:o})=>{var s;const{extendEmptyMarkRange:i=!1}=e,{selection:l}=t,a=ze(n,r.schema),{$from:c,empty:u,ranges:f}=l;if(!o)return!0;if(u&&i){let{from:d,to:h}=l;const p=(s=c.marks().find(y=>y.type===a))===null||s===void 0?void 0:s.attrs,m=po(c,a,p);m&&(d=m.from,h=m.to),t.removeMark(d,h,a)}else f.forEach(d=>{t.removeMark(d.$from.pos,d.$to.pos,a)});return t.removeStoredMark(a),!0},Tf=(n,e={})=>({tr:t,state:r,dispatch:o})=>{let s=null,i=null;const l=yo(typeof n=="string"?n:n.name,r.schema);return l?(l==="node"&&(s=V(n,r.schema)),l==="mark"&&(i=ze(n,r.schema)),o&&t.selection.ranges.forEach(a=>{const c=a.$from.pos,u=a.$to.pos;r.doc.nodesBetween(c,u,(f,d)=>{s&&s===f.type&&t.setNodeMarkup(d,void 0,{...f.attrs,...e}),i&&f.marks.length&&f.marks.forEach(h=>{if(i===h.type){const p=Math.max(d,c),m=Math.min(d+f.nodeSize,u);t.addMark(p,m,i.create({...h.attrs,...e}))}})})}),!0):!1},Af=(n,e={})=>({state:t,dispatch:r})=>{const o=V(n,t.schema);return Jc(o,e)(t,r)},Mf=(n,e={})=>({state:t,dispatch:r})=>{const o=V(n,t.schema);return Vc(o,e)(t,r)};var Ef=Object.freeze({__proto__:null,blur:su,clearContent:iu,clearNodes:lu,command:au,createParagraphNear:cu,cut:uu,deleteCurrentNode:fu,deleteNode:du,deleteRange:hu,deleteSelection:pu,enter:mu,exitCode:gu,extendMarkRange:bu,first:ku,focus:Su,forEach:wu,insertContent:Cu,insertContentAt:Mu,joinBackward:Ou,joinDown:Nu,joinForward:Ru,joinItemBackward:Iu,joinItemForward:vu,joinTextblockBackward:Lu,joinTextblockForward:zu,joinUp:Eu,keyboardShortcut:Bu,lift:Pu,liftEmptyBlock:Hu,liftListItem:Fu,newlineInCode:$u,resetAttributes:ju,scrollIntoView:Wu,selectAll:Ku,selectNodeBackward:Ju,selectNodeForward:Vu,selectParentNode:qu,selectTextblockEnd:Uu,selectTextblockStart:_u,setContent:Qu,setMark:cf,setMeta:uf,setNode:ff,setNodeSelection:df,setTextSelection:hf,sinkListItem:pf,splitBlock:mf,splitListItem:gf,toggleList:yf,toggleMark:bf,toggleNode:kf,toggleWrap:xf,undoInputRule:Sf,unsetAllMarks:wf,unsetMark:Cf,updateAttributes:Tf,wrapIn:Af,wrapInList:Mf});ie.create({name:"commands",addCommands(){return{...Ef}}});ie.create({name:"drop",addProseMirrorPlugins(){return[new te({key:new X("tiptapDrop"),props:{handleDrop:(n,e,t,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:t,moved:r})}}})]}});ie.create({name:"editable",addProseMirrorPlugins(){return[new te({key:new X("editable"),props:{editable:()=>this.editor.options.editable}})]}});ie.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:n}=this;return[new te({key:new X("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}}}})]}});ie.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:f}=a,{pos:d,parent:h}=f,p=f.parent.isTextblock&&d>0?l.doc.resolve(d-1):f,m=p.parent.type.spec.isolating,y=f.pos-f.parentOffset,g=m&&p.parent.childCount===1?y===f.pos:T.atStart(c).from===d;return!u||!h.type.isTextblock||h.textContent.length||!g||g&&f.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 mo()||nl()?s:o},addProseMirrorPlugins(){return[new te({key:new X("clearDocument"),appendTransaction:(n,e,t)=>{const r=n.some(m=>m.docChanged)&&!e.doc.eq(t.doc),o=n.some(m=>m.getMeta("preventClearDocument"));if(!r||o)return;const{empty:s,from:i,to:l}=e.selection,a=T.atStart(e.doc).from,c=T.atEnd(e.doc).to;if(s||!(i===a&&l===c)||!ol(t.doc))return;const d=t.tr,h=Zi({state:t,transaction:d}),{commands:p}=new Xc({editor:this.editor,state:h});if(p.clearNodes(),!!d.steps.length)return d}})]}});ie.create({name:"paste",addProseMirrorPlugins(){return[new te({key:new X("tiptapPaste"),props:{handlePaste:(n,e,t)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:t})}}})]}});ie.create({name:"tabindex",addProseMirrorPlugins(){return[new te({key:new X("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}});function lt(n){return new er({find:n.find,handler:({state:e,range:t,match:r})=>{const o=F(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(xo(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 d=t.from+a+i.length;s.addMark(t.from+a,d,n.type.create(o||{})),s.removeStoredMark(n.type)}}})}function Nf(n){return new er({find:n.find,handler:({state:e,range:t,match:r})=>{const o=F(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 f=r[0][r[0].length-1];s.insertText(f,i+r[0].length-1),s.replaceWith(u,l,a)}else if(r[0]){const c=n.type.isInline?i:i-1;s.insert(c,n.type.create(o)).delete(s.mapping.map(i),s.mapping.map(l))}s.scrollIntoView()}})}function jr(n){return new er({find:n.find,handler:({state:e,range:t,match:r})=>{const o=e.doc.resolve(t.from),s=F(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 Mt(n){return new er({find:n.find,handler:({state:e,range:t,match:r,chain:o})=>{const s=F(n.getAttributes,void 0,r)||{},i=e.tr.delete(t.from,t.to),a=i.doc.resolve(t.from).blockRange(),c=a&&to(a,n.type,s);if(!c)return null;if(i.wrap(a,c),n.keepMarks&&n.editor){const{selection:f,storedMarks:d}=e,{splittableMarks:h}=n.editor.extensionManager,p=d||f.$to.parentOffset&&f.$from.marks();if(p){const m=p.filter(y=>h.includes(y.type.name));i.ensureMarks(m)}}if(n.keepAttributes){const f=n.type.name==="bulletList"||n.type.name==="orderedList"?"listItem":"taskList";o().updateAttributes(f,s).run()}const u=i.doc.resolve(t.from-1).nodeBefore;u&&u.type===n.type&&Ie(i.doc,t.from-1)&&(!n.joinPredicate||n.joinPredicate(r,u))&&i.join(t.from-1)}})}class D{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=F(q(this,"addOptions",{name:this.name}))),this.storage=F(q(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new D(e)}configure(e={}){const t=this.extend({...this.config,addOptions:()=>tr(this.options,e)});return t.name=this.name,t.parent=this.parent,t}extend(e={}){const t=new D(e);return t.parent=this,this.child=t,t.name=e.name?e.name:t.parent.name,e.defaultOptions&&Object.keys(e.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${t.name}".`),t.options=F(q(t,"addOptions",{name:t.name})),t.storage=F(q(t,"addStorage",{name:t.name,options:t.options})),t}}function Je(n){return new nu({find:n.find,handler:({state:e,range:t,match:r,pasteEvent:o})=>{const s=F(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/),f=t.from+a.indexOf(l),d=f+l.length;if(xo(t.from,t.to,e.doc).filter(p=>p.mark.type.excluded.find(y=>y===n.type&&y!==p.mark.type)).filter(p=>p.to>f).length)return null;d<t.to&&i.delete(d,t.to),f>t.from&&i.delete(t.from+u,f),c=t.from+u+l.length,i.addMark(t.from+u,c,n.type.create(s||{})),i.removeStoredMark(n.type)}}})}const Of=(n,e,t="id",r="item")=>{const o=s=>{var i,l,a,c,u,f;if(!n&&s)return s;if(!s||!n)return null;if(s.type==="relation-mark"&&((i=s.attrs)!=null&&i.id)||s.type==="relation-block"&&((l=s.attrs)!=null&&l.id)||s.type==="relation-inline-block"&&((a=s.attrs)!=null&&a.id)){const d=(c=n.find(h=>{var p;return(h==null?void 0:h[t])===((p=s.attrs)==null?void 0:p.id)}))==null?void 0:c[r];s.attrs.data=d}return(u=s.content)==null||u.map(o),(f=s.marks)==null||f.map(o),s};return o(e)},Rf=(n,e)=>{const t=e.map(s=>(s.type==="mark"?ee:D).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]},sl=(n,e,t)=>{const r=t.find(o=>o.type===e&&o.name===n);if(r)return{...r.config,options:r.options}},If=(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}))},br=(n,e,t="node")=>{const r=sl(n.type,t,e);if(!(r!=null&&r.renderHTML))return[];const o=If(n.attrs,r);return r.render?r.render(n):r.renderHTML({node:n,HTMLAttributes:o})},il=(n,e,t)=>{if(n!=null&&n.content&&(n.content=n.content.map(i=>il(i,e,t))),n.type==="text"){if(n.marks){let i;return n.marks.reverse().forEach(l=>{var c;const a=br({...l,attrs:{...l.attrs,data:{...(c=l==null?void 0:l.attrs)==null?void 0:c.data,markText:n.text}}},e,"mark");if(Array.isArray(a)){const[u="span",f=l.attrs]=a,d={...f,data:void 0};i=t(u,d,i||n.text)}else i={...a,text:n.text}}),i}return n.text??""}const r=sl(n.type,"node",e);if(r!=null&&r.render)return br(n,e);const[o="div",s=n.attrs]=br(n,e);return t(o,s,n.content)},vf=(n,e,t)=>il(n,e,t),kr={colspan:"colSpan",rowspan:"rowSpan",textAlign:"textalign"},Lf=(n,e)=>({...Object.fromEntries(Object.entries(e).map(([t,r])=>[(n==null?void 0:n[t])??(kr==null?void 0:kr[t])??t,r]))}),xr={},ll=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=Rf(t,r);return vf(c,u,(f,d,h)=>{const p={...d,style:void 0},m=Lf(s,p),y=(o==null?void 0:o[f])??(xr==null?void 0:xr[f]);return y?y({children:h,attrs:m,themeName:i,tokens:l,customTheme:a}):le.jsx(Mr.Box,{as:f,...m,themeName:i,tokens:l,customTheme:a,children:h},JSON.stringify(h))})},zf=/^\s*>\s$/,Df=D.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:n}){return["blockquote",v(this.options.HTMLAttributes,n),0]},addCommands(){return{setBlockquote:()=>({commands:n})=>n.wrapIn(this.name),toggleBlockquote:()=>({commands:n})=>n.toggleWrap(this.name),unsetBlockquote:()=>({commands:n})=>n.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[Mt({find:zf,type:this.type})]}}),Bf=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,Pf=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,Hf=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,Ff=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,$f=ee.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",v(this.options.HTMLAttributes,n),0]},addCommands(){return{setBold:()=>({commands:n})=>n.setMark(this.name),toggleBold:()=>({commands:n})=>n.toggleMark(this.name),unsetBold:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[lt({find:Bf,type:this.type}),lt({find:Hf,type:this.type})]},addPasteRules(){return[Je({find:Pf,type:this.type}),Je({find:Ff,type:this.type})]}}),So=D.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:n}){return["li",v(this.options.HTMLAttributes,n),0]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),yn=ee.create({name:"textStyle",priority:101,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"span",getAttrs:n=>n.hasAttribute("style")?{}:!1}]},renderHTML({HTMLAttributes:n}){return["span",v(this.options.HTMLAttributes,n),0]},addCommands(){return{removeEmptyTextStyle:()=>({state:n,commands:e})=>{const t=bo(n,this.type);return Object.entries(t).some(([,o])=>!!o)?!0:e.unsetMark(this.name)}}}}),gs=/^\s*([-+*])\s$/,jf=D.create({name:"bulletList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:"ul"}]},renderHTML({HTMLAttributes:n}){return["ul",v(this.options.HTMLAttributes,n),0]},addCommands(){return{toggleBulletList:()=>({commands:n,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(So.name,this.editor.getAttributes(yn.name)).run():n.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let n=Mt({find:gs,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(n=Mt({find:gs,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(yn.name),editor:this.editor})),[n]}}),Wf=/(?:^|\s)(`(?!\s+`)((?:[^`]+))`(?!\s+`))$/,Kf=/(?:^|\s)(`(?!\s+`)((?:[^`]+))`(?!\s+`))/g,Jf=ee.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:n}){return["code",v(this.options.HTMLAttributes,n),0]},addCommands(){return{setCode:()=>({commands:n})=>n.setMark(this.name),toggleCode:()=>({commands:n})=>n.toggleMark(this.name),unsetCode:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[lt({find:Wf,type:this.type})]},addPasteRules(){return[Je({find:Kf,type:this.type})]}}),Vf=/^```([a-z]+)?[\s\n]$/,qf=/^~~~([a-z]+)?[\s\n]$/,Uf=D.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,defaultLanguage:null,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:this.options.defaultLanguage,parseHTML:n=>{var e;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",v(this.options.HTMLAttributes,e),["code",{class:n.attrs.language?this.options.languageClassPrefix+n.attrs.language:null},0]]},addCommands(){return{setCodeBlock:n=>({commands:e})=>e.setNode(this.name,n),toggleCodeBlock:n=>({commands:e})=>e.toggleNode(this.name,"paragraph",n)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{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
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",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.
13
+ `);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?!1:r.nodeAt(l)?n.commands.command(({tr:c})=>(c.setSelection(T.near(r.resolve(l))),!0)):n.commands.exitCode()}}},addInputRules(){return[jr({find:Vf,type:this.type,getAttributes:n=>({language:n[1]})}),jr({find:qf,type:this.type,getAttributes:n=>({language:n[1]})})]},addProseMirrorPlugins(){return[new te({key:new X("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,schema:l}=n.state,a=l.text(t.replace(/\r\n?/g,`
14
+ `));return i.replaceSelectionWith(this.type.create({language:s},a)),i.selection.$from.parent.type!==this.type&&i.setSelection(C.near(i.doc.resolve(Math.max(0,i.selection.from-2)))),i.setMeta("paste",!0),n.dispatch(i),!0}}})]}}),_f=D.create({name:"doc",topNode:!0,content:"block+"}),Gf=D.create({name:"hardBreak",addOptions(){return{keepMarks:!0,HTMLAttributes:{}}},inline:!0,group:"inline",selectable:!1,parseHTML(){return[{tag:"br"}]},renderHTML({HTMLAttributes:n}){return["br",v(this.options.HTMLAttributes,n)]},renderText(){return`
15
+ `},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 f=a.filter(d=>l.includes(d.type.name));c.ensureMarks(f)}return!0}).run()})])}},addKeyboardShortcuts(){return{"Mod-Enter":()=>this.editor.commands.setHardBreak(),"Shift-Enter":()=>this.editor.commands.setHardBreak()}}}),Qf=D.create({name:"heading",addOptions(){return{levels:[1,2,3,4,5,6],HTMLAttributes:{}}},content:"inline*",group:"block",defining:!0,addAttributes(){return{level:{default:1,rendered:!1}}},parseHTML(){return this.options.levels.map(n=>({tag:`h${n}`,attrs:{level:n}}))},renderHTML({node:n,HTMLAttributes:e}){return[`h${this.options.levels.includes(n.attrs.level)?n.attrs.level:this.options.levels[0]}`,v(this.options.HTMLAttributes,e),0]},addCommands(){return{setHeading:n=>({commands:e})=>this.options.levels.includes(n.level)?e.setNode(this.name,n):!1,toggleHeading:n=>({commands:e})=>this.options.levels.includes(n.level)?e.toggleNode(this.name,"paragraph",n):!1}},addKeyboardShortcuts(){return this.options.levels.reduce((n,e)=>({...n,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})}),{})},addInputRules(){return this.options.levels.map(n=>jr({find:new RegExp(`^(#{1,${n}})\\s$`),type:this.type,getAttributes:{level:n}}))}}),Xf=D.create({name:"horizontalRule",addOptions(){return{HTMLAttributes:{}}},group:"block",parseHTML(){return[{tag:"hr"}]},renderHTML({HTMLAttributes:n}){return["hr",v(this.options.HTMLAttributes,n)]},addCommands(){return{setHorizontalRule:()=>({chain:n,state:e})=>{const{selection:t}=e,{$from:r,$to:o}=t,s=n();return r.parentOffset===0?s.insertContentAt({from:Math.max(r.pos-1,0),to:o.pos},{type:this.name}):lf(t)?s.insertContentAt(o.pos,{type:this.name}):s.insertContent({type:this.name}),s.command(({tr:i,dispatch:l})=>{var a;if(l){const{$to:c}=i.selection,u=c.end();if(c.nodeAfter)c.nodeAfter.isTextblock?i.setSelection(C.create(i.doc,c.pos+1)):c.nodeAfter.isBlock?i.setSelection(w.create(i.doc,c.pos)):i.setSelection(C.create(i.doc,c.pos));else{const f=(a=c.parent.type.contentMatch.defaultType)===null||a===void 0?void 0:a.create();f&&(i.insert(u,f),i.setSelection(C.create(i.doc,u+1)))}i.scrollIntoView()}return!0}).run()}}},addInputRules(){return[Nf({find:/^(?:---|—-|___\s|\*\*\*\s)$/,type:this.type})]}}),Yf=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,Zf=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,ed=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,td=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,nd=ee.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",v(this.options.HTMLAttributes,n),0]},addCommands(){return{setItalic:()=>({commands:n})=>n.setMark(this.name),toggleItalic:()=>({commands:n})=>n.toggleMark(this.name),unsetItalic:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[lt({find:Yf,type:this.type}),lt({find:ed,type:this.type})]},addPasteRules(){return[Je({find:Zf,type:this.type}),Je({find:td,type:this.type})]}}),rd="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4vianca6w0s2x0a2z0ure5ba0by2idu3namex3narepublic11d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2ntley5rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0cast4mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dabur3d1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0ardian6cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6logistics9properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3ncaster6d0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2psy3ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2tura4vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9dnavy5lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0america6xi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0a1b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp2w2ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4finity6ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",od="ελ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",at=(n,e)=>{for(const t in e)n[t]=e[t];return n},Wr="numeric",Kr="ascii",Jr="alpha",Xt="asciinumeric",Ft="alphanumeric",Vr="domain",al="emoji",sd="scheme",id="slashscheme",ys="whitespace";function ld(n,e){return n in e||(e[n]=[]),e[n]}function Pe(n,e,t){e[Wr]&&(e[Xt]=!0,e[Ft]=!0),e[Kr]&&(e[Xt]=!0,e[Jr]=!0),e[Xt]&&(e[Ft]=!0),e[Jr]&&(e[Ft]=!0),e[Ft]&&(e[Vr]=!0),e[al]&&(e[Vr]=!0);for(const r in e){const o=ld(r,t);o.indexOf(n)<0&&o.push(n)}}function ad(n,e){const t={};for(const r in e)e[r].indexOf(n)>=0&&(t[r]=!0);return t}function Q(n){n===void 0&&(n=null),this.j={},this.jr=[],this.jd=null,this.t=n}Q.groups={};Q.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||Q.groups;let o;return e&&e.j?o=e:(o=new Q(e),t&&r&&Pe(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||Q.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 Q,at(i.j,l.j),i.jr.push.apply(i.jr,l.jr),i.jd=l.jd,i.t=l.t):i=new Q,s){if(r)if(i.t&&typeof i.t=="string"){const a=at(ad(i.t,r),t);Pe(s,a,r)}else t&&Pe(s,t,r);i.t=s}return o.j[n]=i,i}};const A=(n,e,t,r,o)=>n.ta(e,t,r,o),ne=(n,e,t,r,o)=>n.tr(e,t,r,o),bs=(n,e,t,r,o)=>n.ts(e,t,r,o),k=(n,e,t,r,o)=>n.tt(e,t,r,o),be="WORD",qr="UWORD",Et="LOCALHOST",Ur="TLD",_r="UTLD",Yt="SCHEME",Ze="SLASH_SCHEME",wo="NUM",cl="WS",Co="NL",kt="OPENBRACE",xt="CLOSEBRACE",bn="OPENBRACKET",kn="CLOSEBRACKET",xn="OPENPAREN",Sn="CLOSEPAREN",wn="OPENANGLEBRACKET",Cn="CLOSEANGLEBRACKET",Tn="FULLWIDTHLEFTPAREN",An="FULLWIDTHRIGHTPAREN",Mn="LEFTCORNERBRACKET",En="RIGHTCORNERBRACKET",Nn="LEFTWHITECORNERBRACKET",On="RIGHTWHITECORNERBRACKET",Rn="FULLWIDTHLESSTHAN",In="FULLWIDTHGREATERTHAN",vn="AMPERSAND",Ln="APOSTROPHE",zn="ASTERISK",Ce="AT",Dn="BACKSLASH",Bn="BACKTICK",Pn="CARET",Te="COLON",To="COMMA",Hn="DOLLAR",de="DOT",Fn="EQUALS",Ao="EXCLAMATION",he="HYPHEN",$n="PERCENT",jn="PIPE",Wn="PLUS",Kn="POUND",Jn="QUERY",Mo="QUOTE",Eo="SEMI",pe="SLASH",St="TILDE",Vn="UNDERSCORE",ul="EMOJI",qn="SYM";var fl=Object.freeze({__proto__:null,WORD:be,UWORD:qr,LOCALHOST:Et,TLD:Ur,UTLD:_r,SCHEME:Yt,SLASH_SCHEME:Ze,NUM:wo,WS:cl,NL:Co,OPENBRACE:kt,CLOSEBRACE:xt,OPENBRACKET:bn,CLOSEBRACKET:kn,OPENPAREN:xn,CLOSEPAREN:Sn,OPENANGLEBRACKET:wn,CLOSEANGLEBRACKET:Cn,FULLWIDTHLEFTPAREN:Tn,FULLWIDTHRIGHTPAREN:An,LEFTCORNERBRACKET:Mn,RIGHTCORNERBRACKET:En,LEFTWHITECORNERBRACKET:Nn,RIGHTWHITECORNERBRACKET:On,FULLWIDTHLESSTHAN:Rn,FULLWIDTHGREATERTHAN:In,AMPERSAND:vn,APOSTROPHE:Ln,ASTERISK:zn,AT:Ce,BACKSLASH:Dn,BACKTICK:Bn,CARET:Pn,COLON:Te,COMMA:To,DOLLAR:Hn,DOT:de,EQUALS:Fn,EXCLAMATION:Ao,HYPHEN:he,PERCENT:$n,PIPE:jn,PLUS:Wn,POUND:Kn,QUERY:Jn,QUOTE:Mo,SEMI:Eo,SLASH:pe,TILDE:St,UNDERSCORE:Vn,EMOJI:ul,SYM:qn});const Qe=/[a-z]/,Sr=new RegExp("\\p{L}","u"),wr=new RegExp("\\p{Emoji}","u"),Cr=/\d/,ks=/\s/,xs=`
16
+ `,cd="️",ud="‍";let $t=null,jt=null;function fd(n){n===void 0&&(n=[]);const e={};Q.groups=e;const t=new Q;$t==null&&($t=Ss(rd)),jt==null&&(jt=Ss(od)),k(t,"'",Ln),k(t,"{",kt),k(t,"}",xt),k(t,"[",bn),k(t,"]",kn),k(t,"(",xn),k(t,")",Sn),k(t,"<",wn),k(t,">",Cn),k(t,"(",Tn),k(t,")",An),k(t,"「",Mn),k(t,"」",En),k(t,"『",Nn),k(t,"』",On),k(t,"<",Rn),k(t,">",In),k(t,"&",vn),k(t,"*",zn),k(t,"@",Ce),k(t,"`",Bn),k(t,"^",Pn),k(t,":",Te),k(t,",",To),k(t,"$",Hn),k(t,".",de),k(t,"=",Fn),k(t,"!",Ao),k(t,"-",he),k(t,"%",$n),k(t,"|",jn),k(t,"+",Wn),k(t,"#",Kn),k(t,"?",Jn),k(t,'"',Mo),k(t,"/",pe),k(t,";",Eo),k(t,"~",St),k(t,"_",Vn),k(t,"\\",Dn);const r=ne(t,Cr,wo,{[Wr]:!0});ne(r,Cr,r);const o=ne(t,Qe,be,{[Kr]:!0});ne(o,Qe,o);const s=ne(t,Sr,qr,{[Jr]:!0});ne(s,Qe),ne(s,Sr,s);const i=ne(t,ks,cl,{[ys]:!0});k(t,xs,Co,{[ys]:!0}),k(i,xs),ne(i,ks,i);const l=ne(t,wr,ul,{[al]:!0});ne(l,wr,l),k(l,cd,l);const a=k(l,ud);ne(a,wr,l);const c=[[Qe,o]],u=[[Qe,null],[Sr,s]];for(let f=0;f<$t.length;f++)Se(t,$t[f],Ur,be,c);for(let f=0;f<jt.length;f++)Se(t,jt[f],_r,qr,u);Pe(Ur,{tld:!0,ascii:!0},e),Pe(_r,{utld:!0,alpha:!0},e),Se(t,"file",Yt,be,c),Se(t,"mailto",Yt,be,c),Se(t,"http",Ze,be,c),Se(t,"https",Ze,be,c),Se(t,"ftp",Ze,be,c),Se(t,"ftps",Ze,be,c),Pe(Yt,{scheme:!0,ascii:!0},e),Pe(Ze,{slashscheme:!0,ascii:!0},e),n=n.sort((f,d)=>f[0]>d[0]?1:-1);for(let f=0;f<n.length;f++){const d=n[f][0],p=n[f][1]?{[sd]:!0}:{[id]:!0};d.indexOf("-")>=0?p[Vr]=!0:Qe.test(d)?Cr.test(d)?p[Xt]=!0:p[Kr]=!0:p[Wr]=!0,bs(t,d,d,p)}return bs(t,"localhost",Et,{ascii:!0}),t.jd=new Q(qn),{start:t,tokens:at({groups:e},fl)}}function dd(n,e){const t=hd(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,f=-1,d=-1;for(;i<r&&(a=l.go(t[i]));)l=a,l.accepts()?(f=0,d=0,u=l):f>=0&&(f+=t[i].length,d++),c+=t[i].length,s+=t[i].length,i++;s-=f,i-=d,c-=f,o.push({t:u.t,v:e.slice(s-c,s),s:s-c,e:s})}return o}function hd(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 Se(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 Q(r),s.jr=o.slice(),n.j[a]=s),n=s}return s=new Q(t),s.jr=o.slice(),n.j[e[i-1]]=s,s}function Ss(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 Nt={defaultProtocol:"http",events:null,format:ws,formatHref:ws,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function No(n,e){e===void 0&&(e=null);let t=at({},Nt);n&&(t=at(t,n instanceof No?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}No.prototype={o:Nt,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]:Nt[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 ws(n){return n}function dl(n,e){this.t="token",this.v=n,this.tk=e}dl.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=Nt.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),f=n.getObj("events",t,e);return i.href=r,l&&(i.class=l),a&&(i.target=a),c&&(i.rel=c),u&&at(i,u),{tagName:o,attributes:i,content:s,eventListeners:f}}};function nr(n,e){class t extends dl{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 Cs=nr("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),Ts=nr("text"),pd=nr("nl"),Wt=nr("url",{isLink:!0,toHref(n){return n===void 0&&(n=Nt.defaultProtocol),this.hasProtocol()?this.v:`${n}://${this.v}`},hasProtocol(){const n=this.tk;return n.length>=2&&n[0].t!==Et&&n[1].t===Te}}),re=n=>new Q(n);function md(n){let{groups:e}=n;const t=e.domain.concat([vn,zn,Ce,Dn,Bn,Pn,Hn,Fn,he,wo,$n,jn,Wn,Kn,pe,qn,St,Vn]),r=[Ln,Te,To,de,Ao,Jn,Mo,Eo,wn,Cn,kt,xt,kn,bn,xn,Sn,Tn,An,Mn,En,Nn,On,Rn,In],o=[vn,Ln,zn,Dn,Bn,Pn,Hn,Fn,he,kt,xt,$n,jn,Wn,Kn,Jn,pe,qn,St,Vn],s=re(),i=k(s,St);A(i,o,i),A(i,e.domain,i);const l=re(),a=re(),c=re();A(s,e.domain,l),A(s,e.scheme,a),A(s,e.slashscheme,c),A(l,o,i),A(l,e.domain,l);const u=k(l,Ce);k(i,Ce,u),k(a,Ce,u),k(c,Ce,u);const f=k(i,de);A(f,o,i),A(f,e.domain,i);const d=re();A(u,e.domain,d),A(d,e.domain,d);const h=k(d,de);A(h,e.domain,d);const p=re(Cs);A(h,e.tld,p),A(h,e.utld,p),k(u,Et,p);const m=k(d,he);A(m,e.domain,d),A(p,e.domain,d),k(p,de,h),k(p,he,m);const y=k(p,Te);A(y,e.numeric,Cs);const g=k(l,he),M=k(l,de);A(g,e.domain,l),A(M,o,i),A(M,e.domain,l);const S=re(Wt);A(M,e.tld,S),A(M,e.utld,S),A(S,e.domain,l),A(S,o,i),k(S,de,M),k(S,he,g),k(S,Ce,u);const W=k(S,Te),O=re(Wt);A(W,e.numeric,O);const E=re(Wt),z=re();A(E,t,E),A(E,r,z),A(z,t,E),A(z,r,z),k(S,pe,E),k(O,pe,E);const B=k(a,Te),ft=k(c,Te),xe=k(ft,pe),vt=k(xe,pe);A(a,e.domain,l),k(a,de,M),k(a,he,g),A(c,e.domain,l),k(c,de,M),k(c,he,g),A(B,e.domain,E),k(B,pe,E),A(vt,e.domain,E),A(vt,t,E),k(vt,pe,E);const Ro=[[kt,xt],[bn,kn],[xn,Sn],[wn,Cn],[Tn,An],[Mn,En],[Nn,On],[Rn,In]];for(let or=0;or<Ro.length;or++){const[Io,sr]=Ro[or],Lt=k(E,Io);k(z,Io,Lt),k(Lt,sr,E);const _e=re(Wt);A(Lt,t,_e);const dt=re();A(Lt,r),A(_e,t,_e),A(_e,r,dt),A(dt,t,_e),A(dt,r,dt),k(_e,sr,E),k(dt,sr,E)}return k(s,Et,S),k(s,Co,pd),{start:s,tokens:fl}}function gd(n,e,t){let r=t.length,o=0,s=[],i=[];for(;o<r;){let l=n,a=null,c=null,u=0,f=null,d=-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()?(d=0,f=l):d>=0&&d++,o++,u++;if(d<0)o-=u,o<r&&(i.push(t[o]),o++);else{i.length>0&&(s.push(Tr(Ts,e,i)),i=[]),o-=d,u-=d;const h=f.t,p=t.slice(o-u,o);s.push(Tr(h,e,p))}}return i.length>0&&s.push(Tr(Ts,e,i)),s}function Tr(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 yd=typeof console<"u"&&console&&console.warn||(()=>{}),bd="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 kd(){Q.groups={},I.scanner=null,I.parser=null,I.tokenQueue=[],I.pluginQueue=[],I.customSchemes=[],I.initialized=!1}function As(n,e){if(e===void 0&&(e=!1),I.initialized&&yd(`linkifyjs: already initialized - will not register custom scheme "${n}" ${bd}`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(n))throw new Error(`linkifyjs: incorrect scheme format.
16
17
  1. Must only contain digits, lowercase ASCII letters or "-"
17
18
  2. Cannot start or end with "-"
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;
19
+ 3. "-" cannot repeat`);I.customSchemes.push([n,e])}function xd(){I.scanner=fd(I.customSchemes);for(let n=0;n<I.tokenQueue.length;n++)I.tokenQueue[n][1]({scanner:I.scanner});I.parser=md(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 hl(n){return I.initialized||xd(),gd(I.parser.start,n,dd(I.scanner.start,n))}function pl(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 No(t),o=hl(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 Sd(n){return n.length===1?n[0].isLink:n.length===3&&n[1].isLink?["()","[]"].includes(n[0].value+n[2].value):!1}function wd(n){return new te({key:new X("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=Xu(t.doc,[...e]);if(of(l).forEach(({newRange:c})=>{const u=Zu(r.doc,c,h=>h.isTextblock);let f,d;if(u.length>1?(f=u[0],d=r.doc.textBetween(f.pos,f.pos+f.node.nodeSize,void 0," ")):u.length&&r.doc.textBetween(c.from,c.to," "," ").endsWith(" ")&&(f=u[0],d=r.doc.textBetween(f.pos,c.to,void 0," ")),f&&d){const h=d.split(" ").filter(g=>g!=="");if(h.length<=0)return!1;const p=h[h.length-1],m=f.pos+d.lastIndexOf(p);if(!p)return!1;const y=hl(p).map(g=>g.toObject(n.defaultProtocol));if(!Sd(y))return!1;y.filter(g=>g.isLink).map(g=>({...g,from:m+g.start+1,to:m+g.end+1})).filter(g=>r.schema.marks.code?!r.doc.rangeHasMark(g.from,g.to,r.schema.marks.code):!0).filter(g=>n.validate(g.value)).forEach(g=>{xo(g.from,g.to,r.doc).some(M=>M.mark.type===n.type)||i.addMark(g.from,g.to,n.type.create({href:g.href}))})}}),!!i.steps.length)return i}})}function Cd(n){return new te({key:new X("handleClickLink"),props:{handleClick:(e,t,r)=>{var o,s;if(r.button!==0||!e.editable)return!1;let i=r.target;const l=[];for(;i.nodeName!=="DIV";)l.push(i),i=i.parentNode;if(!l.find(d=>d.nodeName==="A"))return!1;const a=tf(e.state,n.type.name),c=r.target,u=(o=c==null?void 0:c.href)!==null&&o!==void 0?o:a.href,f=(s=c==null?void 0:c.target)!==null&&s!==void 0?s:a.target;return c&&u?(window.open(u,f),!0):!1}}})}function Td(n){return new te({key:new X("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=pl(l,{defaultProtocol:n.defaultProtocol}).find(c=>c.isLink&&c.value===l);return!l||!a?!1:(n.editor.commands.setMark(n.type,{href:a.href}),!0)}}})}const Ad=/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g;function Ms(n,e){const t=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return e&&e.forEach(r=>{const o=typeof r=="string"?r:r.scheme;o&&t.push(o)}),!n||n.replace(Ad,"").match(new RegExp(`^(?:(?:${t.join("|")}):|[^a-z]|[a-z+.-]+(?:[^a-z+.-:]|$))`,"i"))}const Md=ee.create({name:"link",priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.protocols.forEach(n=>{if(typeof n=="string"){As(n);return}As(n.scheme,n.optionalSlashes)})},onDestroy(){kd()},inclusive(){return this.options.autolink},addOptions(){return{openOnClick:!0,linkOnPaste:!0,autolink:!0,protocols:[],defaultProtocol:"http",HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},validate:n=>!!n}},addAttributes(){return{href:{default:null,parseHTML(n){return n.getAttribute("href")}},target:{default:this.options.HTMLAttributes.target},rel:{default:this.options.HTMLAttributes.rel},class:{default:this.options.HTMLAttributes.class}}},parseHTML(){return[{tag:"a[href]",getAttrs:n=>{const e=n.getAttribute("href");return!e||!Ms(e,this.options.protocols)?!1:null}}]},renderHTML({HTMLAttributes:n}){return Ms(n.href,this.options.protocols)?["a",v(this.options.HTMLAttributes,n),0]:["a",v(this.options.HTMLAttributes,{...n,href:""}),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[Je({find:n=>{const e=[];if(n){const{validate:t}=this.options,r=pl(n).filter(o=>o.isLink&&t(o.value));r.length&&r.forEach(o=>e.push({text:o.value,data:{href:o.href},index:o.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(wd({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:this.options.validate})),this.options.openOnClick===!0&&n.push(Cd({type:this.type})),this.options.linkOnPaste&&n.push(Td({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type})),n}}),Es=/^(\d+)\.\s$/,Ed=D.create({name:"orderedList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes(){return{start:{default:1,parseHTML:n=>n.hasAttribute("start")?parseInt(n.getAttribute("start")||"",10):1},type:{default:void 0,parseHTML:n=>n.getAttribute("type")}}},parseHTML(){return[{tag:"ol"}]},renderHTML({HTMLAttributes:n}){const{start:e,...t}=n;return e===1?["ol",v(this.options.HTMLAttributes,t),0]:["ol",v(this.options.HTMLAttributes,n),0]},addCommands(){return{toggleOrderedList:()=>({commands:n,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(So.name,this.editor.getAttributes(yn.name)).run():n.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let n=Mt({find:Es,type:this.type,getAttributes:e=>({start:+e[1]}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(n=Mt({find:Es,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:e=>({start:+e[1],...this.editor.getAttributes(yn.name)}),joinPredicate:(e,t)=>t.childCount+t.attrs.start===+e[1],editor:this.editor})),[n]}}),Nd=D.create({name:"paragraph",priority:1e3,addOptions(){return{HTMLAttributes:{}}},group:"block",content:"inline*",parseHTML(){return[{tag:"p"}]},renderHTML({HTMLAttributes:n}){return["p",v(this.options.HTMLAttributes,n),0]},addCommands(){return{setParagraph:()=>({commands:n})=>n.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),Od=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))$/,Rd=/(?:^|\s)(~~(?!\s+~~)((?:[^~]+))~~(?!\s+~~))/g,Id=ee.create({name:"strike",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"s"},{tag:"del"},{tag:"strike"},{style:"text-decoration",consuming:!1,getAttrs:n=>n.includes("line-through")?{}:!1}]},renderHTML({HTMLAttributes:n}){return["s",v(this.options.HTMLAttributes,n),0]},addCommands(){return{setStrike:()=>({commands:n})=>n.setMark(this.name),toggleStrike:()=>({commands:n})=>n.toggleMark(this.name),unsetStrike:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-s":()=>this.editor.commands.toggleStrike()}},addInputRules(){return[lt({find:Od,type:this.type})]},addPasteRules(){return[Je({find:Rd,type:this.type})]}}),vd=ee.create({name:"subscript",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"sub"},{style:"vertical-align",getAttrs(n){return n!=="sub"?!1:null}}]},renderHTML({HTMLAttributes:n}){return["sub",v(this.options.HTMLAttributes,n),0]},addCommands(){return{setSubscript:()=>({commands:n})=>n.setMark(this.name),toggleSubscript:()=>({commands:n})=>n.toggleMark(this.name),unsetSubscript:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-,":()=>this.editor.commands.toggleSubscript()}}}),Ld=ee.create({name:"superscript",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"sup"},{style:"vertical-align",getAttrs(n){return n!=="super"?!1:null}}]},renderHTML({HTMLAttributes:n}){return["sup",v(this.options.HTMLAttributes,n),0]},addCommands(){return{setSuperscript:()=>({commands:n})=>n.setMark(this.name),toggleSuperscript:()=>({commands:n})=>n.toggleMark(this.name),unsetSuperscript:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-.":()=>this.editor.commands.toggleSuperscript()}}});var Gr,Qr;if(typeof WeakMap<"u"){let n=new WeakMap;Gr=e=>n.get(e),Qr=(e,t)=>(n.set(e,t),t)}else{const n=[];let t=0;Gr=r=>{for(let o=0;o<n.length;o+=2)if(n[o]==r)return n[o+1]},Qr=(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 Gr(n)||Qr(n,zd(n))}};function zd(n){if(n.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+n.type.name);const e=Dd(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 f=n.child(c);u++;for(let p=0;;p++){for(;o<r.length&&r[o]!=0;)o++;if(p==f.childCount)break;const m=f.child(p),{colspan:y,rowspan:g,colwidth:M}=m.attrs;for(let S=0;S<g;S++){if(S+c>=t){(s||(s=[])).push({type:"overlong_rowspan",pos:u,n:g-S});break}const W=o+S*e;for(let O=0;O<y;O++){r[W+O]==0?r[W+O]=u:(s||(s=[])).push({type:"collision",row:c,pos:u,n:y-O});const E=M&&M[O];if(E){const z=(W+O)%e*2,B=i[z];B==null||B!=E&&i[z+1]==1?(i[z]=E,i[z+1]=1):B==E&&i[z+1]++}}}o+=y,u+=m.nodeSize}const d=(c+1)*e;let h=0;for(;o<d;)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&&Bd(l,i,n),l}function Dd(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 Bd(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,f=e[u*2];f!=null&&(!a.colwidth||a.colwidth[c]!=f)&&((l||(l=Pd(a)))[c]=f)}l&&n.problems.unshift({type:"colwidth mismatch",pos:s,colwidth:l})}}function Pd(n){if(n.colwidth)return n.colwidth.slice();const e=[];for(let t=0;t<n.colspan;t++)e.push(0);return e}function U(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 Ae=new X("selectingCells");function ut(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 Hd(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 fe(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 rr(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=ut(e.$head)||Fd(e.$head);if(t)return t;throw new RangeError(`No cell found around position ${e.head}`)}function Fd(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 Xr(n){return n.parent.type.spec.tableRole=="row"&&!!n.nodeAfter}function $d(n){return n.node(0).resolve(n.pos+n.nodeAfter.nodeSize)}function Oo(n,e){return n.depth==e.depth&&n.pos>=e.start(-1)&&n.pos<=e.end(-1)}function ml(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 Ve(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 gl(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=U(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 ke extends T{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 f=r.nodeAt(u);if(!f)throw RangeError(`No cell with offset ${u} found`);const d=s+u+1;return new xi(l.resolve(d),l.resolve(d+f.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(Xr(r)&&Xr(o)&&Oo(r,o)){const s=this.$anchorCell.node(-1)!=r.node(-1);return s&&this.isRowSelection()?ke.rowSelection(r,o):s&&this.isColSelection()?ke.colSelection(r,o):new ke(r,o)}return C.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,f=o.left;f<o.right;f++,u++){const d=t.map[u];if(s[d])continue;s[d]=!0;const h=t.findCell(d);let p=e.nodeAt(d);if(!p)throw RangeError(`No cell with offset ${d} found`);const m=o.left-h.left,y=h.right-o.right;if(m>0||y>0){let g=p.attrs;if(m>0&&(g=Ve(g,0,m)),y>0&&(g=Ve(g,g.colspan-y,y)),h.left<o.left){if(p=p.type.createAndFill(g),!p)throw RangeError(`Could not create cell with attrs ${JSON.stringify(g)}`)}else p=p.type.create(g,p.content)}if(h.top<o.top||h.bottom>o.bottom){const g={...p.attrs,rowspan:Math.min(h.bottom,o.bottom)-Math.max(h.top,o.top)};h.top<o.top?p=p.type.createAndFill(g):p=p.type.create(g,p.content)}c.push(p)}i.push(e.child(a).copy(b.from(c)))}const l=this.isColSelection()&&this.isRowSelection()?e:i;return new x(b.from(l),1,1)}replace(e,t=x.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?x.empty:t)}const s=T.findFrom(e.doc.resolve(e.mapping.slice(r).map(this.to)),-1);s&&e.setSelection(s)}replaceWith(e,t){this.replace(e,new x(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 ke(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 ke&&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 ke(e,t)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,t){return new ke(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,r=t){return new ke(e.resolve(t),e.resolve(r))}getBookmark(){return new Wd(this.$anchorCell.pos,this.$headCell.pos)}};N.prototype.visible=!1;T.jsonID("cell",N);var Wd=class yl{constructor(e,t){this.anchor=e,this.head=t}map(e){return new yl(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&&Oo(t,r)?new N(t,r):T.near(r,1)}};function Kd(n){if(!(n.selection instanceof N))return null;const e=[];return n.selection.forEachCell((t,r)=>{e.push(ae.node(r,r+t.nodeSize,{class:"selectedCell"}))}),P.create(n.doc,e)}function Jd({$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 Vd({$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 qd(n,e,t){const r=(e||n).selection,o=(e||n).doc;let s,i;if(r instanceof w&&(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 C&&Jd(r)?s=C.create(o,r.from):r instanceof C&&Vd(r)&&(s=C.create(o,r.$from.start(),r.$from.end()));return s&&(e||(e=n.tr)).setSelection(s),e}var Ud=new X("fix-tables");function bl(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)?bl(n.child(l),a,t+1,r):a.nodesBetween(0,a.content.size,r,t+1),t+=a.nodeSize}}function kl(n,e){let t;const r=(o,s)=>{o.type.spec.tableRole=="table"&&(t=_d(n,o,s,t))};return e?e.doc!=n.doc&&bl(e.doc,n.doc,0,r):n.doc.descendants(r),t}function _d(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 f=u.attrs;for(let d=0;d<f.rowspan;d++)s[c.row+d]+=c.n;r.setNodeMarkup(r.mapping.map(t+1+c.pos),null,Ve(f,f.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),f=c+u.nodeSize,d=s[a];if(d>0){let h="cell";u.firstChild&&(h=u.firstChild.type.spec.tableRole);const p=[];for(let y=0;y<d;y++){const g=U(n.schema)[h].createAndFill();g&&p.push(g)}const m=(a==0||i==a-1)&&l==a?c+1:f-1;r.insert(r.mapping.map(m),p)}c=f}return r.setMeta(Ud,{fixTables:!0})}function ye(n){const e=n.selection,t=rr(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 xl(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,gl(c.attrs,o-e.colCount(a))),i+=c.attrs.rowspan-1}else{const a=s==null?U(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 Gd(n,e){if(!fe(n))return!1;if(e){const t=ye(n);e(xl(n.tr,t,t.left))}return!0}function Qd(n,e){if(!fe(n))return!1;if(e){const t=ye(n);e(xl(n.tr,t,t.right))}return!0}function Xd(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,Ve(u,o-e.colCount(a)));else{const f=n.mapping.slice(s).map(r+a);n.delete(f,f+c.nodeSize)}i+=u.rowspan}}function Yd(n,e){if(!fe(n))return!1;if(e){const t=ye(n),r=n.tr;if(t.left==0&&t.right==t.map.width)return!1;for(let o=t.right-1;Xd(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 Zd(n,e,t){var r;const o=U(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 Sl(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;Zd(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 f=e.map[u],d=r.nodeAt(f).attrs;n.setNodeMarkup(t+f,null,{...d,rowspan:d.rowspan+1}),c+=d.colspan-1}else{const f=a==null?U(r.type.schema).cell:(s=r.nodeAt(e.map[u+a*e.width]))==null?void 0:s.type,d=f==null?void 0:f.createAndFill();d&&l.push(d)}return n.insert(i,U(r.type.schema).row.create(null,l)),n}function eh(n,e){if(!fe(n))return!1;if(e){const t=ye(n);e(Sl(n.tr,t,t.top))}return!0}function th(n,e){if(!fe(n))return!1;if(e){const t=ye(n);e(Sl(n.tr,t,t.bottom))}return!0}function nh(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 f=e.map[u];if(!a.has(f)){if(a.add(f),o>0&&f==e.map[u-e.width]){const d=t.nodeAt(f).attrs;n.setNodeMarkup(n.mapping.slice(l).map(f+r),null,{...d,rowspan:d.rowspan-1}),c+=d.colspan-1}else if(o<e.height&&f==e.map[u+e.width]){const d=t.nodeAt(f),h=d.attrs,p=d.type.create({...h,rowspan:d.attrs.rowspan-1},d.content),m=e.positionAt(o+1,c,t);n.insert(n.mapping.slice(l).map(r+m),p),c+=h.colspan-1}}}}function rh(n,e){if(!fe(n))return!1;if(e){const t=ye(n),r=n.tr;if(t.top==0&&t.bottom==t.map.height)return!1;for(let o=t.bottom-1;nh(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 Ns(n){const e=n.content;return e.childCount==1&&e.child(0).isTextblock&&e.child(0).childCount==0}function oh({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 Os(n,e){const t=n.selection;if(!(t instanceof N)||t.$anchorCell.pos==t.$headCell.pos)return!1;const r=ye(n),{map:o}=r;if(oh(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 f=r.left;f<r.right;f++){const d=o.map[u*o.width+f],h=r.table.nodeAt(d);if(!(i[d]||!h))if(i[d]=!0,a==null)a=d,c=h;else{Ns(h)||(l=l.append(h.content));const p=s.mapping.map(d+r.tableStart);s.delete(p,p+h.nodeSize)}}if(a==null||c==null)return!0;if(s.setNodeMarkup(a+r.tableStart,null,{...gl(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,f=Ns(c)?a+1:u;s.replaceWith(f+r.tableStart,u+r.tableStart,l)}s.setSelection(new N(s.doc.resolve(a+r.tableStart))),e(s)}return!0}function Rs(n,e){const t=U(n.schema);return sh(({node:r})=>t[r.type.spec.tableRole])(n,e)}function sh(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=Hd(o.$from),!s)return!1;i=(r=ut(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=ye(e),f=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 d;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,y=0;m<u.right;m++,y++)m==u.left&&h==u.top||f.insert(d=f.mapping.map(p+u.tableStart,1),n({node:s,row:h,col:m}).createAndFill(a[y]))}f.setNodeMarkup(i,n({node:s,row:u.top,col:u.left}),a[0]),o instanceof N&&f.setSelection(new N(f.doc.resolve(o.$anchorCell.pos),d?f.doc.resolve(d):void 0)),t(f)}return!0}}function ih(n,e){return function(t,r){if(!fe(t))return!1;const o=rr(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 lh(n){return function(e,t){if(!fe(e))return!1;if(t){const r=U(e.schema),o=ye(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 Is(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 Ot(n,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?lh(n):function(t,r){if(!fe(t))return!1;if(r){const o=U(t.schema),s=ye(t),i=t.tr,l=Is("row",s,o),a=Is("column",s,o),u=(n==="column"?l:n==="row"?a:!1)?1:0,f=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,d=n=="column"?a?o.cell:o.header_cell:n=="row"?l?o.cell:o.header_cell:o.cell;s.map.cellsInRect(f).forEach(h=>{const p=h+s.tableStart,m=i.doc.nodeAt(p);m&&i.setNodeMarkup(p,d,m.attrs)}),r(i)}return!0}}Ot("row",{useDeprecatedLogic:!0});Ot("column",{useDeprecatedLogic:!0});var ah=Ot("cell",{useDeprecatedLogic:!0});function ch(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 vs(n){return function(e,t){if(!fe(e))return!1;const r=ch(rr(e),n);if(r==null)return!1;if(t){const o=e.doc.resolve(r);t(e.tr.setSelection(C.between(o,$d(o))).scrollIntoView())}return!0}}function uh(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 Kt(n,e){const t=n.selection;if(!(t instanceof N))return!1;if(e){const r=n.tr,o=U(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 x(o,0,0))}),r.docChanged&&e(r)}return!0}function fh(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),f=a<e.childCount-1?0:Math.max(0,r-1);(u||f)&&(c=Yr(U(i).row,new x(c,u,f)).content),l.push(c)}else if(s=="cell"||s=="header_cell")l.push(t||r?Yr(U(i).row,new x(e,t,r)).content:e);else return null;return dh(i,l)}function dh(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=U(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 Yr(n,e){const t=n.createAndFill();return new ki(t).replace(0,t.content.size,e).doc}function hh({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,f=0;u<r;f++){let d=a.child(f%a.childCount);u+d.attrs.colspan>r&&(d=d.type.createChecked(Ve(d.attrs,d.attrs.colspan,u+d.attrs.colspan-r),d.content)),c.push(d),u+=d.attrs.colspan;for(let h=1;h<d.attrs.rowspan;h++)s[l+h]=(s[l+h]||0)+d.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 f=c.child(u);i+f.attrs.rowspan>o&&(f=f.type.create({...f.attrs,rowspan:Math.max(1,o-f.attrs.rowspan)},f.content)),a.push(f)}s.push(b.from(a))}t=s,e=o}return{width:n,height:e,rows:t}}function ph(n,e,t,r,o,s,i){const l=n.doc.type.schema,a=U(l);let c,u;if(o>e.width)for(let f=0,d=0;f<e.height;f++){const h=t.child(f);d+=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 y=e.width;y<o;y++)p.push(m);n.insert(n.mapping.slice(i).map(d-1+r),p)}if(s>e.height){const f=[];for(let p=0,m=(e.height-1)*e.width;p<Math.max(e.width,o);p++){const y=p>=e.width?!1:t.nodeAt(e.map[m+p]).type==a.header_cell;f.push(y?u||(u=a.header_cell.createAndFill()):c||(c=a.cell.createAndFill()))}const d=a.row.create(null,b.from(f)),h=[];for(let p=e.height;p<s;p++)h.push(d);n.insert(n.mapping.slice(i).map(r+t.nodeSize-2),h)}return!!(c||u)}function Ls(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,f=e.map[u];if(e.map[u-e.width]==f){a=!0;const d=t.nodeAt(f),{top:h,left:p}=e.findCell(f);n.setNodeMarkup(n.mapping.slice(l).map(f+r),null,{...d.attrs,rowspan:i-h}),n.insert(n.mapping.slice(l).map(e.positionAt(i,p,t)),d.type.createAndFill({...d.attrs,rowspan:h+d.attrs.rowspan-i})),c+=d.attrs.colspan-1}}return a}function zs(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,f=e.map[u];if(e.map[u-1]==f){a=!0;const d=t.nodeAt(f),h=e.colCount(f),p=n.mapping.slice(l).map(f+r);n.setNodeMarkup(p,null,Ve(d.attrs,i-h,d.attrs.colspan-(i-h))),n.insert(p+d.nodeSize,d.type.createAndFill(Ve(d.attrs,0,i-h))),c+=d.attrs.rowspan-1}}return a}function Ds(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,f=n.tr;let d=0;function h(){if(s=t?f.doc.nodeAt(t-1):f.doc,!s)throw new Error("No table found");i=L.get(s),d=f.mapping.maps.length}ph(f,i,s,t,c,u,d)&&h(),Ls(f,i,s,t,a,c,l,d)&&h(),Ls(f,i,s,t,a,c,u,d)&&h(),zs(f,i,s,t,l,u,a,d)&&h(),zs(f,i,s,t,l,u,c,d)&&h();for(let p=l;p<u;p++){const m=i.positionAt(p,a,s),y=i.positionAt(p,c,s);f.replace(f.mapping.slice(d).map(m+t),f.mapping.slice(d).map(y+t),new x(o.rows[p-l],0,0))}h(),f.setSelection(new N(f.doc.resolve(t+i.positionAt(l,a,s)),f.doc.resolve(t+i.positionAt(u-1,c-1,s)))),e(f)}var mh=Ac({ArrowLeft:Jt("horiz",-1),ArrowRight:Jt("horiz",1),ArrowUp:Jt("vert",-1),ArrowDown:Jt("vert",1),"Shift-ArrowLeft":Vt("horiz",-1),"Shift-ArrowRight":Vt("horiz",1),"Shift-ArrowUp":Vt("vert",-1),"Shift-ArrowDown":Vt("vert",1),Backspace:Kt,"Mod-Backspace":Kt,Delete:Kt,"Mod-Delete":Kt});function Zt(n,e,t){return t.eq(n.selection)?!1:(e&&e(n.tr.setSelection(t).scrollIntoView()),!0)}function Jt(n,e){return(t,r,o)=>{if(!o)return!1;const s=t.selection;if(s instanceof N)return Zt(t,r,T.near(s.$headCell,e));if(n!="horiz"&&!s.empty)return!1;const i=wl(o,n,e);if(i==null)return!1;if(n=="horiz")return Zt(t,r,T.near(t.doc.resolve(s.head+e),e));{const l=t.doc.resolve(i),a=ml(l,n,e);let c;return a?c=T.near(a,1):e<0?c=T.near(t.doc.resolve(l.before(-1)),-1):c=T.near(t.doc.resolve(l.after(-1)),1),Zt(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=wl(o,n,e);if(a==null)return!1;i=new N(t.doc.resolve(a))}const l=ml(i.$headCell,n,e);return l?Zt(t,r,new N(i.$anchorCell,l)):!1}}function gh(n,e){const t=n.state.doc,r=ut(t.resolve(e));return r?(n.dispatch(n.state.tr.setSelection(new N(r))),!0):!1}function yh(n,e,t){if(!fe(n.state))return!1;let r=fh(t);const o=n.state.selection;if(o instanceof N){r||(r={width:1,height:1,rows:[b.from(Yr(U(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=hh(r,l.right-l.left,l.bottom-l.top),Ds(n.state,n.dispatch,i,l,r),!0}else if(r){const s=rr(n.state),i=s.start(-1);return Ds(n.state,n.dispatch,i,L.get(s.node(-1)).findCell(s.pos-i),r),!0}else return!1}function bh(n,e){var t;if(e.ctrlKey||e.metaKey)return;const r=Bs(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=ut(n.state.selection.$anchor))!=null&&((t=Ar(n,e))==null?void 0:t.pos)!=o.pos)s(o,e),e.preventDefault();else if(!r)return;function s(a,c){let u=Ar(n,c);const f=Ae.getState(n.state)==null;if(!u||!Oo(a,u))if(f)u=a;else return;const d=new N(a,u);if(f||!n.state.selection.eq(d)){const h=n.state.tr.setSelection(d);f&&h.setMeta(Ae,a.pos),n.dispatch(h)}}function i(){n.root.removeEventListener("mouseup",i),n.root.removeEventListener("dragstart",i),n.root.removeEventListener("mousemove",l),Ae.getState(n.state)!=null&&n.dispatch(n.state.tr.setMeta(Ae,-1))}function l(a){const c=a,u=Ae.getState(n.state);let f;if(u!=null)f=n.state.doc.resolve(u);else if(Bs(n,c.target)!=r&&(f=Ar(n,e),!f))return i();f&&s(f,c)}n.root.addEventListener("mouseup",i),n.root.addEventListener("dragstart",i),n.root.addEventListener("mousemove",l)}function wl(n,e,t){if(!(n.state.selection instanceof C))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 Bs(n,e){for(;e&&e!=n.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function Ar(n,e){const t=n.posAtCoords({left:e.clientX,top:e.clientY});return t&&t?ut(n.state.doc.resolve(t.pos)):null}var kh=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 f=0,d=0;f<u.childCount;f++){const{colspan:h,colwidth:p}=u.child(f).attrs;for(let m=0;m<h;m++,d++){const y=o==d?s:p&&p[m],g=y?y+"px":"";l+=y||r,y||(a=!1),c?(c.style.width!=g&&(c.style.width=g),c=c.nextSibling):e.appendChild(document.createElement("col")).style.width=g}}for(;c;){const f=c.nextSibling;(i=c.parentNode)==null||i.removeChild(c),c=f}a?(t.style.width=l+"px",t.style.minWidth=""):(t.style.width="",t.style.minWidth=l+"px")}}var se=new X("tableColumnResizing");function xh({handleWidth:n=5,cellMinWidth:e=25,View:t=kh,lastColumnResizable:r=!0}={}){const o=new te({key:se,state:{init(s,i){var l,a;const c=(a=(l=o.spec)==null?void 0:l.props)==null?void 0:a.nodeViews,u=U(i.schema).table.name;return t&&c&&(c[u]=(f,d)=>new t(f,e,d)),new Sh(-1,!1)},apply(s,i){return i.apply(s)}},props:{attributes:s=>{const i=se.getState(s);return i&&i.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(s,i)=>{wh(s,i,n,e,r)},mouseleave:s=>{Ch(s)},mousedown:(s,i)=>{Th(s,i,e)}},decorations:s=>{const i=se.getState(s);if(i&&i.activeHandle>-1)return Rh(s,i.activeHandle)},nodeViews:{}}});return o}var Sh=class en{constructor(e,t){this.activeHandle=e,this.dragging=t}apply(e){const t=this,r=e.getMeta(se);if(r&&r.setHandle!=null)return new en(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new en(t.activeHandle,r.setDragging);if(t.activeHandle>-1&&e.docChanged){let o=e.mapping.map(t.activeHandle,-1);return Xr(e.doc.resolve(o))||(o=-1),new en(o,t.dragging)}return t}};function wh(n,e,t,r,o){const s=se.getState(n.state);if(s&&!s.dragging){const i=Mh(e.target);let l=-1;if(i){const{left:a,right:c}=i.getBoundingClientRect();e.clientX-a<=t?l=Ps(n,e,"left",t):c-e.clientX<=t&&(l=Ps(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),f=a.start(-1);if(u.colCount(a.pos-f)+a.nodeAfter.attrs.colspan-1==u.width-1)return}Cl(n,l)}}}function Ch(n){const e=se.getState(n.state);e&&e.activeHandle>-1&&!e.dragging&&Cl(n,-1)}function Th(n,e,t){var r;const o=(r=n.dom.ownerDocument.defaultView)!=null?r:window,s=se.getState(n.state);if(!s||s.activeHandle==-1||s.dragging)return!1;const i=n.state.doc.nodeAt(s.activeHandle),l=Ah(n,s.activeHandle,i.attrs);n.dispatch(n.state.tr.setMeta(se,{setDragging:{startX:e.clientX,startWidth:l}}));function a(u){o.removeEventListener("mouseup",a),o.removeEventListener("mousemove",c);const f=se.getState(n.state);f!=null&&f.dragging&&(Eh(n,f.activeHandle,Hs(f.dragging,u,t)),n.dispatch(n.state.tr.setMeta(se,{setDragging:null})))}function c(u){if(!u.which)return a(u);const f=se.getState(n.state);if(f&&f.dragging){const d=Hs(f.dragging,u,t);Nh(n,f.activeHandle,d,t)}}return o.addEventListener("mouseup",a),o.addEventListener("mousemove",c),e.preventDefault(),!0}function Ah(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 Mh(n){for(;n&&n.nodeName!="TD"&&n.nodeName!="TH";)n=n.classList&&n.classList.contains("ProseMirror")?null:n.parentNode;return n}function Ps(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=ut(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 Hs(n,e,t){const r=e.clientX-n.startX;return Math.max(t,n.startWidth+r)}function Cl(n,e){n.dispatch(n.state.tr.setMeta(se,{setHandle:e}))}function Eh(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 f=s.map[u],d=o.nodeAt(f).attrs,h=d.colspan==1?0:l-s.colCount(f);if(d.colwidth&&d.colwidth[h]==t)continue;const p=d.colwidth?d.colwidth.slice():Oh(d.colspan);p[h]=t,a.setNodeMarkup(i+f,null,{...d,colwidth:p})}a.docChanged&&n.dispatch(a)}function Nh(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 Oh(n){return Array(n).fill(0)}function Rh(n,e){const t=[],r=n.doc.resolve(e),o=r.node(-1);if(!o)return P.empty;const s=L.get(o),i=r.start(-1),l=s.colCount(r.pos-i)+r.nodeAfter.attrs.colspan-1;for(let a=0;a<s.height;a++){const c=l+a*s.width;if((l==s.width-1||s.map[c]!=s.map[c+1])&&(a==0||s.map[c]!=s.map[c-s.width])){const u=s.map[c],f=i+u+o.nodeAt(u).nodeSize-1,d=document.createElement("div");d.className="column-resize-handle",t.push(ae.widget(f,d))}}return P.create(n.doc,t)}function Ih({allowTableNodeSelection:n=!1}={}){return new te({key:Ae,state:{init(){return null},apply(e,t){const r=e.getMeta(Ae);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:Kd,handleDOMEvents:{mousedown:bh},createSelectionBetween(e){return Ae.getState(e.state)!=null?e.state.selection:null},handleTripleClick:gh,handleKeyDown:mh,handlePaste:yh},appendTransaction(e,t,r){return qd(r,kl(r,t),n)}})}function Fs(n,e,t,r,o,s){let i=0,l=!0,a=e.firstChild;const c=n.firstChild;for(let u=0,f=0;u<c.childCount;u+=1){const{colspan:d,colwidth:h}=c.child(u).attrs;for(let p=0;p<d;p+=1,f+=1){const m=o===f?s:h&&h[p],y=m?`${m}px`:"";i+=m||r,m||(l=!1),a?(a.style.width!==y&&(a.style.width=y),a=a.nextSibling):e.appendChild(document.createElement("col")).style.width=y}}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 vh{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")),Fs(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,Fs(e,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(e){return e.type==="attributes"&&(e.target===this.table||this.colgroup.contains(e.target))}}function Lh(n,e,t,r){let o=0,s=!0;const i=[],l=n.firstChild;if(!l)return{};for(let f=0,d=0;f<l.childCount;f+=1){const{colspan:h,colwidth:p}=l.child(f).attrs;for(let m=0;m<h;m+=1,d+=1){const y=t===d?r:p&&p[m],g=y?`${y}px`:"";o+=y||e,y||(s=!1),i.push(["col",g?{style:`width: ${g}`}:{}])}}const a=s?`${o}px`:"",c=s?"":`${o}px`;return{colgroup:["colgroup",{},...i],tableWidth:a,tableMinWidth:c}}function $s(n,e){return n.createAndFill()}function zh(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 Dh(n,e,t,r,o){const s=zh(n),i=[],l=[];for(let c=0;c<t;c+=1){const u=$s(s.cell);if(u&&l.push(u),r){const f=$s(s.header_cell);f&&i.push(f)}}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 Bh(n){return n instanceof N}const qt=({editor:n})=>{const{selection:e}=n.state;if(!Bh(e))return!1;let t=0;const r=rl(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},Ph=D.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,handleWidth:5,cellMinWidth:25,View:vh,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}=Lh(n,this.options.cellMinWidth);return["table",v(this.options.HTMLAttributes,e,{style:r?`width: ${r}`:`min-width: ${o}`}),t,["tbody",0]]},addCommands(){return{insertTable:({rows:n=3,cols:e=3,withHeaderRow:t=!0}={})=>({tr:r,dispatch:o,editor:s})=>{const i=Dh(s.schema,n,e,t);if(o){const l=r.selection.from+1;r.replaceSelectionWith(i).scrollIntoView().setSelection(C.near(r.doc.resolve(l)))}return!0},addColumnBefore:()=>({state:n,dispatch:e})=>Gd(n,e),addColumnAfter:()=>({state:n,dispatch:e})=>Qd(n,e),deleteColumn:()=>({state:n,dispatch:e})=>Yd(n,e),addRowBefore:()=>({state:n,dispatch:e})=>eh(n,e),addRowAfter:()=>({state:n,dispatch:e})=>th(n,e),deleteRow:()=>({state:n,dispatch:e})=>rh(n,e),deleteTable:()=>({state:n,dispatch:e})=>uh(n,e),mergeCells:()=>({state:n,dispatch:e})=>Os(n,e),splitCell:()=>({state:n,dispatch:e})=>Rs(n,e),toggleHeaderColumn:()=>({state:n,dispatch:e})=>Ot("column")(n,e),toggleHeaderRow:()=>({state:n,dispatch:e})=>Ot("row")(n,e),toggleHeaderCell:()=>({state:n,dispatch:e})=>ah(n,e),mergeOrSplit:()=>({state:n,dispatch:e})=>Os(n,e)?!0:Rs(n,e),setCellAttribute:(n,e)=>({state:t,dispatch:r})=>ih(n,e)(t,r),goToNextCell:()=>({state:n,dispatch:e})=>vs(1)(n,e),goToPreviousCell:()=>({state:n,dispatch:e})=>vs(-1)(n,e),fixTables:()=>({state:n,dispatch:e})=>(e&&kl(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:qt,"Mod-Backspace":qt,Delete:qt,"Mod-Delete":qt}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[xh({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],Ih({allowTableNodeSelection:this.options.allowTableNodeSelection})]},extendNodeSchema(n){const e={name:n.name,options:n.options,storage:n.storage};return{tableRole:F(q(n,"tableRole",e))}}}),Hh=D.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",v(this.options.HTMLAttributes,n),0]}}),Fh=D.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",v(this.options.HTMLAttributes,n),0]}}),$h=D.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:n}){return["tr",v(this.options.HTMLAttributes,n),0]}}),jh=D.create({name:"text",group:"inline"}),Wh=ie.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=>{const e=n.style.textAlign||this.options.defaultAlignment;return this.options.alignments.includes(e)?e: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")}}}),Kh=[_f,jh,Nd,Gf,Qf,Uf,jf,Ed,So,Df,Xf,Md,$f,nd,Id,Jf,Ph,Fh,$h,Hh,Wh,vd,Ld],Jh=n=>{const{jsonContent:e,editorNodes:t,serializers:r,nodes:o,config:s,relationMarksConfig:i,themeName:l,tokens:a,customTheme:c,remappedAttributes:u}=n,f=Of(t,e),d=r??[...Kh]??[],h=(g,M)=>{var O,E,z;const{attrs:S}=g,W=`${(O=S==null?void 0:S.collection)==null?void 0:O.replace("related_","")}_id`;if(S!=null&&S.data){if(!((E=S==null?void 0:S.data)!=null&&E.blocks)){const xe={collection:S.collection,item:{...S==null?void 0:S.data}};return le.jsx(Lo,{block:xe,config:M},JSON.stringify(xe))}const B=(z=S==null?void 0:S.data)==null?void 0:z.blocks,ft=B==null?void 0:B.map(xe=>({item:xe==null?void 0:xe[W],collection:S==null?void 0:S.collection}));return le.jsx(Lo,{blocks:ft,config:M},JSON.stringify(B))}return null},p=D.create({name:"relation-block",renderHTML:()=>["relation-block"],render:g=>h(g,s)}),m=D.create({name:"relation-inline-block",renderHTML:()=>["relation-inline-block"],render:g=>h(g,s)}),y=ee.create({name:"relation-mark",type:"relation-mark",renderHTML:()=>["relation-mark"],render:g=>h(g,i)});return d.push(p,m,y),f?le.jsx(ll,{content:f,serializers:d,renderingNodes:o,themeName:l,tokens:a,customTheme:c,remappedAttributes:u}):null};exports.FlexibleEditorContent=Jh;exports.RenderNodes=ll;