From 964fc45e3438532a857c539ca356d9a507d57e3d Mon Sep 17 00:00:00 2001 From: Shane Friedman Date: Thu, 7 Mar 2024 15:14:47 -0500 Subject: [PATCH] Wrap the DocNodeView in a ChildDescriptorContext. (#116) When rendering nested ProseMirror editors, e.g. when taking control over an atom node's content, the nested DocNodeView would register itself as the child of the atom node in the view descriptor tree. This could cause subtle issues when, e.g., ProseMirror attempts to determine whether the content is ltr or rtl, because it would treat the nested editor as the contentDOM of the atom, even if it was rendered in a portal into a non- contiguous part of the page. Presumably other issues could also arise from the fact that ProseMirror thought this node had a contentDOM when it actually does not. This change resolves this by simply providing a top- level ChildDescriptorContext, so that nested editors never accidentally cross the boundary up into their parents' view descriptor tree. --- .../{index-2d0cb2b2.js => index-4fa89cf5.js} | 22 +++++++++---------- docs/index.html | 2 +- src/components/ProseMirrorDoc.tsx | 20 ++++++++++------- 3 files changed, 24 insertions(+), 20 deletions(-) rename docs/assets/{index-2d0cb2b2.js => index-4fa89cf5.js} (97%) diff --git a/docs/assets/index-2d0cb2b2.js b/docs/assets/index-4fa89cf5.js similarity index 97% rename from docs/assets/index-2d0cb2b2.js rename to docs/assets/index-4fa89cf5.js index 3c0c5137..5646bb4d 100644 --- a/docs/assets/index-2d0cb2b2.js +++ b/docs/assets/index-4fa89cf5.js @@ -14,15 +14,15 @@ * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var Dy=C,Ty=Symbol.for("react.element"),Ay=Symbol.for("react.fragment"),Ry=Object.prototype.hasOwnProperty,Py=Dy.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,zy={key:!0,ref:!0,__self:!0,__source:!0};function rp(t,e,n){var r,i={},o=null,s=null;n!==void 0&&(o=""+n),e.key!==void 0&&(o=""+e.key),e.ref!==void 0&&(s=e.ref);for(r in e)Ry.call(e,r)&&!zy.hasOwnProperty(r)&&(i[r]=e[r]);if(t&&t.defaultProps)for(r in e=t.defaultProps,e)i[r]===void 0&&(i[r]=e[r]);return{$$typeof:Ty,type:t,key:o,ref:s,props:i,_owner:Py.current}}nl.Fragment=Ay;nl.jsx=rp;nl.jsxs=rp;qh.exports=nl;var Ju=qh.exports;const Ku=Ju.Fragment,F=Ju.jsx,Sf=Ju.jsxs;function de(t){this.content=t}de.prototype={constructor:de,find:function(t){for(var e=0;e>1}};de.from=function(t){if(t instanceof de)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new de(e)};function ip(t,e,n){for(let r=0;;r++){if(r==t.childCount||r==e.childCount)return t.childCount==e.childCount?null:n;let i=t.child(r),o=e.child(r);if(i==o){n+=i.nodeSize;continue}if(!i.sameMarkup(o))return n;if(i.isText&&i.text!=o.text){for(let s=0;i.text[s]==o.text[s];s++)n++;return n}if(i.content.size||o.content.size){let s=ip(i.content,o.content,n+1);if(s!=null)return s}n+=i.nodeSize}}function op(t,e,n,r){for(let i=t.childCount,o=e.childCount;;){if(i==0||o==0)return i==o?null:{a:n,b:r};let s=t.child(--i),l=e.child(--o),a=s.nodeSize;if(s==l){n-=a,r-=a;continue}if(!s.sameMarkup(l))return{a:n,b:r};if(s.isText&&s.text!=l.text){let u=0,c=Math.min(s.text.length,l.text.length);for(;ue&&r(a,i+l,o||null,s)!==!1&&a.content.size){let c=l+1;a.nodesBetween(Math.max(0,e-c),Math.min(a.content.size,n-c),r,i+c)}l=u}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,r,i){let o="",s=!0;return this.nodesBetween(e,n,(l,a)=>{let u=l.isText?l.text.slice(Math.max(e,a)-a,n-a):l.isLeaf?i?typeof i=="function"?i(l):i:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&u||l.isTextblock)&&r&&(s?s=!1:o+=r),o+=u},0),o}append(e){if(!e.size)return this;if(!this.size)return e;let n=this.lastChild,r=e.firstChild,i=this.content.slice(),o=0;for(n.isText&&n.sameMarkup(r)&&(i[i.length-1]=n.withText(n.text+r.text),o=1);oe)for(let o=0,s=0;se&&((sn)&&(l.isText?l=l.cut(Math.max(0,e-s),Math.min(l.text.length,n-s)):l=l.cut(Math.max(0,e-s-1),Math.min(l.content.size,n-s-1))),r.push(l),i+=l.nodeSize),s=a}return new v(r,i)}cutByIndex(e,n){return e==n?v.empty:e==0&&n==this.content.length?this:new v(this.content.slice(e,n))}replaceChild(e,n){let r=this.content[e];if(r==n)return this;let i=this.content.slice(),o=this.size+n.nodeSize-r.nodeSize;return i[e]=n,new v(i,o)}addToStart(e){return new v([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new v(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let n=0;nthis.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let r=0,i=0;;r++){let o=this.child(r),s=i+o.nodeSize;if(s>=e)return s==e||n>0?Oo(r+1,s):Oo(r,i);i=s}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,n){if(!n)return v.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new v(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return v.empty;let n,r=0;for(let i=0;ithis.type.rank&&(n||(n=e.slice(0,i)),n.push(this),r=!0),n&&n.push(o)}}return n||(n=e.slice()),r||n.push(this),n}removeFromSet(e){for(let n=0;nr.type.rank-i.type.rank),n}}_.none=[];class Ii extends Error{}class x{constructor(e,n,r){this.content=e,this.openStart=n,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,n){let r=lp(this.content,e+this.openStart,n);return r&&new x(r,this.openStart,this.openEnd)}removeBetween(e,n){return new x(sp(this.content,e+this.openStart,n+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,n){if(!n)return x.empty;let r=n.openStart||0,i=n.openEnd||0;if(typeof r!="number"||typeof i!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new x(v.fromJSON(e,n.content),r,i)}static maxOpen(e,n=!0){let r=0,i=0;for(let o=e.firstChild;o&&!o.isLeaf&&(n||!o.type.spec.isolating);o=o.firstChild)r++;for(let o=e.lastChild;o&&!o.isLeaf&&(n||!o.type.spec.isolating);o=o.lastChild)i++;return new x(e,r,i)}}x.empty=new x(v.empty,0,0);function sp(t,e,n){let{index:r,offset:i}=t.findIndex(e),o=t.maybeChild(r),{index:s,offset:l}=t.findIndex(n);if(i==e||o.isText){if(l!=n&&!t.child(s).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(r!=s)throw new RangeError("Removing non-flat range");return t.replaceChild(r,o.copy(sp(o.content,e-i-1,n-i-1)))}function lp(t,e,n,r){let{index:i,offset:o}=t.findIndex(e),s=t.maybeChild(i);if(o==e||s.isText)return r&&!r.canReplace(i,i,n)?null:t.cut(0,e).append(n).append(t.cut(e));let l=lp(s.content,e-o-1,n);return l&&t.replaceChild(i,s.copy(l))}function Fy(t,e,n){if(n.openStart>t.depth)throw new Ii("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new Ii("Inconsistent open depths");return ap(t,e,n,0)}function ap(t,e,n,r){let i=t.index(r),o=t.node(r);if(i==e.index(r)&&r=0&&t.isText&&t.sameMarkup(e[n])?e[n]=t.withText(e[n].text+t.text):e.push(t)}function wi(t,e,n,r){let i=(e||t).node(n),o=0,s=e?e.index(n):i.childCount;t&&(o=t.index(n),t.depth>n?o++:t.textOffset&&(Wn(t.nodeAfter,r),o++));for(let l=o;li&&Ca(t,e,i+1),s=r.depth>i&&Ca(n,r,i+1),l=[];return wi(null,t,i,l),o&&s&&e.index(i)==n.index(i)?(up(o,s),Wn(Un(o,cp(t,e,n,r,i+1)),l)):(o&&Wn(Un(o,ws(t,e,i+1)),l),wi(e,n,i,l),s&&Wn(Un(s,ws(n,r,i+1)),l)),wi(r,null,i,l),new v(l)}function ws(t,e,n){let r=[];if(wi(null,t,n,r),t.depth>n){let i=Ca(t,e,n+1);Wn(Un(i,ws(t,e,n+1)),r)}return wi(e,null,n,r),new v(r)}function Iy(t,e){let n=e.depth-t.openStart,i=e.node(n).copy(t.content);for(let o=n-1;o>=0;o--)i=e.node(o).copy(v.from(i));return{start:i.resolveNoCache(t.openStart+n),end:i.resolveNoCache(i.content.size-t.openEnd-n)}}class bi{constructor(e,n,r){this.pos=e,this.path=n,this.parentOffset=r,this.depth=n.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,n=this.index(this.depth);if(n==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],i=e.child(n);return r?e.child(n).cut(r):i}get nodeBefore(){let e=this.index(this.depth),n=this.pos-this.path[this.path.length-1];return n?this.parent.child(e).cut(0,n):e==0?null:this.parent.child(e-1)}posAtIndex(e,n){n=this.resolveDepth(n);let r=this.path[n*3],i=n==0?0:this.path[n*3-1]+1;for(let o=0;o0;n--)if(this.start(n)<=e&&this.end(n)>=e)return n;return 0}blockRange(e=this,n){if(e.pos=0;r--)if(e.pos<=this.end(r)&&(!n||n(this.node(r))))return new Ly(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos=0&&n<=e.content.size))throw new RangeError("Position "+n+" out of range");let r=[],i=0,o=n;for(let s=e;;){let{index:l,offset:a}=s.content.findIndex(o),u=o-a;if(r.push(s,l,i+a),!u||(s=s.child(l),s.isText))break;o=u-1,i+=a+1}return new bi(n,r,o)}static resolveCached(e,n){for(let i=0;ie&&this.nodesBetween(e,n,o=>(r.isInSet(o.marks)&&(i=!0),!i)),i}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()+")"),fp(this.marks,e)}contentMatchAt(e){let n=this.type.contentMatch.matchFragment(this.content,0,e);if(!n)throw new Error("Called contentMatchAt on a node with invalid content");return n}canReplace(e,n,r=v.empty,i=0,o=r.childCount){let s=this.contentMatchAt(e).matchFragment(r,i,o),l=s&&s.matchFragment(this.content,n);if(!l||!l.validEnd)return!1;for(let a=i;an.type.name)}`);this.content.forEach(n=>n.check())}toJSON(){let e={type:this.type.name};for(let n 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(n=>n.toJSON())),e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Node.fromJSON");let r=null;if(n.marks){if(!Array.isArray(n.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=n.marks.map(e.markFromJSON)}if(n.type=="text"){if(typeof n.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(n.text,r)}let i=v.fromJSON(e,n.content);return e.nodeType(n.type).create(n.attrs,i,r)}}vt.prototype.text=void 0;class vs extends vt{constructor(e,n,r,i){if(super(e,n,null,i),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):fp(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,n){return this.text.slice(e,n)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new vs(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new vs(this.type,this.attrs,e,this.marks)}cut(e=0,n=this.text.length){return e==0&&n==this.text.length?this:this.withText(this.text.slice(e,n))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function fp(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class qn{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new Vy(e,n);if(r.next==null)return qn.empty;let i=dp(r);r.next&&r.err("Unexpected trailing text");let o=Jy(Hy(i));return Ky(o,r),o}matchType(e){for(let n=0;nu.createAndFill()));for(let u=0;u=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function n(r){e.push(r);for(let i=0;i{let o=i+(r.validEnd?"*":" ")+" ";for(let s=0;s"+e.indexOf(r.next[s].next);return o}).join(` -`)}}qn.empty=new qn(!0);class Vy{constructor(e,n){this.string=e,this.nodeTypes=n,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 dp(t){let e=[];do e.push($y(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function $y(t){let e=[];do e.push(_y(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function _y(t){let e=jy(t);for(;;)if(t.eat("+"))e={type:"plus",expr:e};else if(t.eat("*"))e={type:"star",expr:e};else if(t.eat("?"))e={type:"opt",expr:e};else if(t.eat("{"))e=Wy(t,e);else break;return e}function kf(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function Wy(t,e){let n=kf(t),r=n;return t.eat(",")&&(t.next!="}"?r=kf(t):r=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function Uy(t,e){let n=t.nodeTypes,r=n[e];if(r)return[r];let i=[];for(let o in n){let s=n[o];s.groups.indexOf(e)>-1&&i.push(s)}return i.length==0&&t.err("No node type or group '"+e+"' found"),i}function jy(t){if(t.eat("(")){let e=dp(t);return t.eat(")")||t.err("Missing closing paren"),e}else if(/\W/.test(t.next))t.err("Unexpected token '"+t.next+"'");else{let e=Uy(t,t.next).map(n=>(t.inline==null?t.inline=n.isInline:t.inline!=n.isInline&&t.err("Mixing inline and block content"),{type:"name",value:n}));return t.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function Hy(t){let e=[[]];return i(o(t,0),n()),e;function n(){return e.push([])-1}function r(s,l,a){let u={term:a,to:l};return e[s].push(u),u}function i(s,l){s.forEach(a=>a.to=l)}function o(s,l){if(s.type=="choice")return s.exprs.reduce((a,u)=>a.concat(o(u,l)),[]);if(s.type=="seq")for(let a=0;;a++){let u=o(s.exprs[a],l);if(a==s.exprs.length-1)return u;i(u,l=n())}else if(s.type=="star"){let a=n();return r(l,a),i(o(s.expr,a),a),[r(a)]}else if(s.type=="plus"){let a=n();return i(o(s.expr,l),a),i(o(s.expr,a),a),[r(a)]}else{if(s.type=="opt")return[r(l)].concat(o(s.expr,l));if(s.type=="range"){let a=l;for(let u=0;u{t[s].forEach(({term:l,to:a})=>{if(!l)return;let u;for(let c=0;c{u||i.push([l,u=[]]),u.indexOf(c)==-1&&u.push(c)})})});let o=e[r.join(",")]=new qn(r.indexOf(t.length-1)>-1);for(let s=0;s-1}allowsMarks(e){if(this.markSet==null)return!0;for(let n=0;nr[o]=new yp(o,n,s));let i=n.spec.topNode||"doc";if(!r[i])throw new RangeError("Schema is missing its top node type ('"+i+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let o in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};class qy{constructor(e){this.hasDefault=Object.prototype.hasOwnProperty.call(e,"default"),this.default=e.default}get isRequired(){return!this.hasDefault}}class fo{constructor(e,n,r,i){this.name=e,this.rank=n,this.schema=r,this.spec=i,this.attrs=gp(i.attrs),this.excluded=null;let o=pp(this.attrs);this.instance=o?new _(this,o):null}create(e=null){return!e&&this.instance?this.instance:new _(this,mp(this.attrs,e))}static compile(e,n){let r=Object.create(null),i=0;return e.forEach((o,s)=>r[o]=new fo(o,i++,n,s)),r}removeFromSet(e){for(var n=0;n-1}}class Sp{constructor(e){this.cached=Object.create(null);let n=this.spec={};for(let i in e)n[i]=e[i];n.nodes=de.from(e.nodes),n.marks=de.from(e.marks||{}),this.nodes=vf.compile(this.spec.nodes,this),this.marks=fo.compile(this.spec.marks,this);let r=Object.create(null);for(let i in this.nodes){if(i in this.marks)throw new RangeError(i+" can not be both a node and a mark");let o=this.nodes[i],s=o.spec.content||"",l=o.spec.marks;o.contentMatch=r[s]||(r[s]=qn.parse(s,this.nodes)),o.inlineContent=o.contentMatch.inlineContent,o.markSet=l=="_"?null:l?xf(this,l.split(" ")):l==""||!o.inlineContent?[]:null}for(let i in this.marks){let o=this.marks[i],s=o.spec.excludes;o.excluded=s==null?[o]:s==""?[]:xf(this,s.split(" "))}this.nodeFromJSON=this.nodeFromJSON.bind(this),this.markFromJSON=this.markFromJSON.bind(this),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,n=null,r,i){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof vf){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(n,r,i)}text(e,n){let r=this.nodes.text;return new vs(r,r.defaultAttrs,e,_.setFrom(n))}mark(e,n){return typeof e=="string"&&(e=this.marks[e]),e.create(n)}nodeFromJSON(e){return vt.fromJSON(this,e)}markFromJSON(e){return _.fromJSON(this,e)}nodeType(e){let n=this.nodes[e];if(!n)throw new RangeError("Unknown node type: "+e);return n}}function xf(t,e){let n=[];for(let r=0;r-1)&&n.push(s=a)}if(!s)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return n}class Li{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[],n.forEach(r=>{r.tag?this.tags.push(r):r.style&&this.styles.push(r)}),this.normalizeLists=!this.tags.some(r=>{if(!/^(ul|ol)\b/.test(r.tag)||!r.node)return!1;let i=e.nodes[r.node];return i.contentMatch.matchType(i)})}parse(e,n={}){let r=new Nf(this,n,!1);return r.addAll(e,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new Nf(this,n,!0);return r.addAll(e,n.from,n.to),x.maxOpen(r.finish())}matchTag(e,n,r){for(let i=r?this.tags.indexOf(r)+1:0;ie.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=n))){if(s.getAttrs){let a=s.getAttrs(n);if(a===!1)continue;s.attrs=a||void 0}return s}}}static schemaRules(e){let n=[];function r(i){let o=i.priority==null?50:i.priority,s=0;for(;s{r(s=Mf(s)),s.mark||s.ignore||s.clearMark||(s.mark=i)})}for(let i in e.nodes){let o=e.nodes[i].spec.parseDOM;o&&o.forEach(s=>{r(s=Mf(s)),s.node||s.ignore||s.mark||(s.node=i)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Li(e,Li.schemaRules(e)))}}const kp={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},Qy={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},wp={ol:!0,ul:!0},xs=1,Cs=2,vi=4;function Cf(t,e,n){return e!=null?(e?xs:0)|(e==="full"?Cs:0):t&&t.whitespace=="pre"?xs|Cs:n&~vi}class Do{constructor(e,n,r,i,o,s,l){this.type=e,this.attrs=n,this.marks=r,this.pendingMarks=i,this.solid=o,this.options=l,this.content=[],this.activeMarks=_.none,this.stashMarks=[],this.match=s||(l&vi?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(v.from(e));if(n)this.match=this.type.contentMatch.matchFragment(n);else{let r=this.type.contentMatch,i;return(i=r.findWrapping(e.type))?(this.match=r,i):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&xs)){let r=this.content[this.content.length-1],i;if(r&&r.isText&&(i=/[ \t\r\n\u000c]+$/.exec(r.text))){let o=r;r.text.length==i[0].length?this.content.pop():this.content[this.content.length-1]=o.withText(o.text.slice(0,o.text.length-i[0].length))}}let n=v.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(v.empty,!0))),this.type?this.type.create(this.attrs,n,this.marks):n}popFromStashMark(e){for(let n=this.stashMarks.length-1;n>=0;n--)if(e.eq(this.stashMarks[n]))return this.stashMarks.splice(n,1)[0]}applyPending(e){for(let n=0,r=this.pendingMarks;n>1}};de.from=function(t){if(t instanceof de)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new de(e)};function ip(t,e,n){for(let r=0;;r++){if(r==t.childCount||r==e.childCount)return t.childCount==e.childCount?null:n;let i=t.child(r),o=e.child(r);if(i==o){n+=i.nodeSize;continue}if(!i.sameMarkup(o))return n;if(i.isText&&i.text!=o.text){for(let s=0;i.text[s]==o.text[s];s++)n++;return n}if(i.content.size||o.content.size){let s=ip(i.content,o.content,n+1);if(s!=null)return s}n+=i.nodeSize}}function op(t,e,n,r){for(let i=t.childCount,o=e.childCount;;){if(i==0||o==0)return i==o?null:{a:n,b:r};let s=t.child(--i),l=e.child(--o),a=s.nodeSize;if(s==l){n-=a,r-=a;continue}if(!s.sameMarkup(l))return{a:n,b:r};if(s.isText&&s.text!=l.text){let u=0,c=Math.min(s.text.length,l.text.length);for(;ue&&r(a,i+l,o||null,s)!==!1&&a.content.size){let c=l+1;a.nodesBetween(Math.max(0,e-c),Math.min(a.content.size,n-c),r,i+c)}l=u}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,r,i){let o="",s=!0;return this.nodesBetween(e,n,(l,a)=>{let u=l.isText?l.text.slice(Math.max(e,a)-a,n-a):l.isLeaf?i?typeof i=="function"?i(l):i:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&u||l.isTextblock)&&r&&(s?s=!1:o+=r),o+=u},0),o}append(e){if(!e.size)return this;if(!this.size)return e;let n=this.lastChild,r=e.firstChild,i=this.content.slice(),o=0;for(n.isText&&n.sameMarkup(r)&&(i[i.length-1]=n.withText(n.text+r.text),o=1);oe)for(let o=0,s=0;se&&((sn)&&(l.isText?l=l.cut(Math.max(0,e-s),Math.min(l.text.length,n-s)):l=l.cut(Math.max(0,e-s-1),Math.min(l.content.size,n-s-1))),r.push(l),i+=l.nodeSize),s=a}return new v(r,i)}cutByIndex(e,n){return e==n?v.empty:e==0&&n==this.content.length?this:new v(this.content.slice(e,n))}replaceChild(e,n){let r=this.content[e];if(r==n)return this;let i=this.content.slice(),o=this.size+n.nodeSize-r.nodeSize;return i[e]=n,new v(i,o)}addToStart(e){return new v([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new v(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let n=0;nthis.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let r=0,i=0;;r++){let o=this.child(r),s=i+o.nodeSize;if(s>=e)return s==e||n>0?Oo(r+1,s):Oo(r,i);i=s}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,n){if(!n)return v.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new v(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return v.empty;let n,r=0;for(let i=0;ithis.type.rank&&(n||(n=e.slice(0,i)),n.push(this),r=!0),n&&n.push(o)}}return n||(n=e.slice()),r||n.push(this),n}removeFromSet(e){for(let n=0;nr.type.rank-i.type.rank),n}}_.none=[];class Ii extends Error{}class x{constructor(e,n,r){this.content=e,this.openStart=n,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,n){let r=lp(this.content,e+this.openStart,n);return r&&new x(r,this.openStart,this.openEnd)}removeBetween(e,n){return new x(sp(this.content,e+this.openStart,n+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,n){if(!n)return x.empty;let r=n.openStart||0,i=n.openEnd||0;if(typeof r!="number"||typeof i!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new x(v.fromJSON(e,n.content),r,i)}static maxOpen(e,n=!0){let r=0,i=0;for(let o=e.firstChild;o&&!o.isLeaf&&(n||!o.type.spec.isolating);o=o.firstChild)r++;for(let o=e.lastChild;o&&!o.isLeaf&&(n||!o.type.spec.isolating);o=o.lastChild)i++;return new x(e,r,i)}}x.empty=new x(v.empty,0,0);function sp(t,e,n){let{index:r,offset:i}=t.findIndex(e),o=t.maybeChild(r),{index:s,offset:l}=t.findIndex(n);if(i==e||o.isText){if(l!=n&&!t.child(s).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(r!=s)throw new RangeError("Removing non-flat range");return t.replaceChild(r,o.copy(sp(o.content,e-i-1,n-i-1)))}function lp(t,e,n,r){let{index:i,offset:o}=t.findIndex(e),s=t.maybeChild(i);if(o==e||s.isText)return r&&!r.canReplace(i,i,n)?null:t.cut(0,e).append(n).append(t.cut(e));let l=lp(s.content,e-o-1,n);return l&&t.replaceChild(i,s.copy(l))}function Fy(t,e,n){if(n.openStart>t.depth)throw new Ii("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new Ii("Inconsistent open depths");return ap(t,e,n,0)}function ap(t,e,n,r){let i=t.index(r),o=t.node(r);if(i==e.index(r)&&r=0&&t.isText&&t.sameMarkup(e[n])?e[n]=t.withText(e[n].text+t.text):e.push(t)}function wi(t,e,n,r){let i=(e||t).node(n),o=0,s=e?e.index(n):i.childCount;t&&(o=t.index(n),t.depth>n?o++:t.textOffset&&(Wn(t.nodeAfter,r),o++));for(let l=o;li&&Ca(t,e,i+1),s=r.depth>i&&Ca(n,r,i+1),l=[];return wi(null,t,i,l),o&&s&&e.index(i)==n.index(i)?(up(o,s),Wn(Un(o,cp(t,e,n,r,i+1)),l)):(o&&Wn(Un(o,ws(t,e,i+1)),l),wi(e,n,i,l),s&&Wn(Un(s,ws(n,r,i+1)),l)),wi(r,null,i,l),new v(l)}function ws(t,e,n){let r=[];if(wi(null,t,n,r),t.depth>n){let i=Ca(t,e,n+1);Wn(Un(i,ws(t,e,n+1)),r)}return wi(e,null,n,r),new v(r)}function Iy(t,e){let n=e.depth-t.openStart,i=e.node(n).copy(t.content);for(let o=n-1;o>=0;o--)i=e.node(o).copy(v.from(i));return{start:i.resolveNoCache(t.openStart+n),end:i.resolveNoCache(i.content.size-t.openEnd-n)}}class bi{constructor(e,n,r){this.pos=e,this.path=n,this.parentOffset=r,this.depth=n.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,n=this.index(this.depth);if(n==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],i=e.child(n);return r?e.child(n).cut(r):i}get nodeBefore(){let e=this.index(this.depth),n=this.pos-this.path[this.path.length-1];return n?this.parent.child(e).cut(0,n):e==0?null:this.parent.child(e-1)}posAtIndex(e,n){n=this.resolveDepth(n);let r=this.path[n*3],i=n==0?0:this.path[n*3-1]+1;for(let o=0;o0;n--)if(this.start(n)<=e&&this.end(n)>=e)return n;return 0}blockRange(e=this,n){if(e.pos=0;r--)if(e.pos<=this.end(r)&&(!n||n(this.node(r))))return new Ly(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos=0&&n<=e.content.size))throw new RangeError("Position "+n+" out of range");let r=[],i=0,o=n;for(let s=e;;){let{index:l,offset:a}=s.content.findIndex(o),u=o-a;if(r.push(s,l,i+a),!u||(s=s.child(l),s.isText))break;o=u-1,i+=a+1}return new bi(n,r,o)}static resolveCached(e,n){for(let i=0;ie&&this.nodesBetween(e,n,o=>(r.isInSet(o.marks)&&(i=!0),!i)),i}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()+")"),fp(this.marks,e)}contentMatchAt(e){let n=this.type.contentMatch.matchFragment(this.content,0,e);if(!n)throw new Error("Called contentMatchAt on a node with invalid content");return n}canReplace(e,n,r=v.empty,i=0,o=r.childCount){let s=this.contentMatchAt(e).matchFragment(r,i,o),l=s&&s.matchFragment(this.content,n);if(!l||!l.validEnd)return!1;for(let a=i;an.type.name)}`);this.content.forEach(n=>n.check())}toJSON(){let e={type:this.type.name};for(let n 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(n=>n.toJSON())),e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Node.fromJSON");let r=null;if(n.marks){if(!Array.isArray(n.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=n.marks.map(e.markFromJSON)}if(n.type=="text"){if(typeof n.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(n.text,r)}let i=v.fromJSON(e,n.content);return e.nodeType(n.type).create(n.attrs,i,r)}}xt.prototype.text=void 0;class vs extends xt{constructor(e,n,r,i){if(super(e,n,null,i),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):fp(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,n){return this.text.slice(e,n)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new vs(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new vs(this.type,this.attrs,e,this.marks)}cut(e=0,n=this.text.length){return e==0&&n==this.text.length?this:this.withText(this.text.slice(e,n))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function fp(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class qn{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new Vy(e,n);if(r.next==null)return qn.empty;let i=dp(r);r.next&&r.err("Unexpected trailing text");let o=Jy(Hy(i));return Ky(o,r),o}matchType(e){for(let n=0;nu.createAndFill()));for(let u=0;u=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function n(r){e.push(r);for(let i=0;i{let o=i+(r.validEnd?"*":" ")+" ";for(let s=0;s"+e.indexOf(r.next[s].next);return o}).join(` +`)}}qn.empty=new qn(!0);class Vy{constructor(e,n){this.string=e,this.nodeTypes=n,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 dp(t){let e=[];do e.push($y(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function $y(t){let e=[];do e.push(_y(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function _y(t){let e=jy(t);for(;;)if(t.eat("+"))e={type:"plus",expr:e};else if(t.eat("*"))e={type:"star",expr:e};else if(t.eat("?"))e={type:"opt",expr:e};else if(t.eat("{"))e=Wy(t,e);else break;return e}function kf(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function Wy(t,e){let n=kf(t),r=n;return t.eat(",")&&(t.next!="}"?r=kf(t):r=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function Uy(t,e){let n=t.nodeTypes,r=n[e];if(r)return[r];let i=[];for(let o in n){let s=n[o];s.groups.indexOf(e)>-1&&i.push(s)}return i.length==0&&t.err("No node type or group '"+e+"' found"),i}function jy(t){if(t.eat("(")){let e=dp(t);return t.eat(")")||t.err("Missing closing paren"),e}else if(/\W/.test(t.next))t.err("Unexpected token '"+t.next+"'");else{let e=Uy(t,t.next).map(n=>(t.inline==null?t.inline=n.isInline:t.inline!=n.isInline&&t.err("Mixing inline and block content"),{type:"name",value:n}));return t.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function Hy(t){let e=[[]];return i(o(t,0),n()),e;function n(){return e.push([])-1}function r(s,l,a){let u={term:a,to:l};return e[s].push(u),u}function i(s,l){s.forEach(a=>a.to=l)}function o(s,l){if(s.type=="choice")return s.exprs.reduce((a,u)=>a.concat(o(u,l)),[]);if(s.type=="seq")for(let a=0;;a++){let u=o(s.exprs[a],l);if(a==s.exprs.length-1)return u;i(u,l=n())}else if(s.type=="star"){let a=n();return r(l,a),i(o(s.expr,a),a),[r(a)]}else if(s.type=="plus"){let a=n();return i(o(s.expr,l),a),i(o(s.expr,a),a),[r(a)]}else{if(s.type=="opt")return[r(l)].concat(o(s.expr,l));if(s.type=="range"){let a=l;for(let u=0;u{t[s].forEach(({term:l,to:a})=>{if(!l)return;let u;for(let c=0;c{u||i.push([l,u=[]]),u.indexOf(c)==-1&&u.push(c)})})});let o=e[r.join(",")]=new qn(r.indexOf(t.length-1)>-1);for(let s=0;s-1}allowsMarks(e){if(this.markSet==null)return!0;for(let n=0;nr[o]=new yp(o,n,s));let i=n.spec.topNode||"doc";if(!r[i])throw new RangeError("Schema is missing its top node type ('"+i+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let o in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};class qy{constructor(e){this.hasDefault=Object.prototype.hasOwnProperty.call(e,"default"),this.default=e.default}get isRequired(){return!this.hasDefault}}class fo{constructor(e,n,r,i){this.name=e,this.rank=n,this.schema=r,this.spec=i,this.attrs=gp(i.attrs),this.excluded=null;let o=pp(this.attrs);this.instance=o?new _(this,o):null}create(e=null){return!e&&this.instance?this.instance:new _(this,mp(this.attrs,e))}static compile(e,n){let r=Object.create(null),i=0;return e.forEach((o,s)=>r[o]=new fo(o,i++,n,s)),r}removeFromSet(e){for(var n=0;n-1}}class Sp{constructor(e){this.cached=Object.create(null);let n=this.spec={};for(let i in e)n[i]=e[i];n.nodes=de.from(e.nodes),n.marks=de.from(e.marks||{}),this.nodes=vf.compile(this.spec.nodes,this),this.marks=fo.compile(this.spec.marks,this);let r=Object.create(null);for(let i in this.nodes){if(i in this.marks)throw new RangeError(i+" can not be both a node and a mark");let o=this.nodes[i],s=o.spec.content||"",l=o.spec.marks;o.contentMatch=r[s]||(r[s]=qn.parse(s,this.nodes)),o.inlineContent=o.contentMatch.inlineContent,o.markSet=l=="_"?null:l?xf(this,l.split(" ")):l==""||!o.inlineContent?[]:null}for(let i in this.marks){let o=this.marks[i],s=o.spec.excludes;o.excluded=s==null?[o]:s==""?[]:xf(this,s.split(" "))}this.nodeFromJSON=this.nodeFromJSON.bind(this),this.markFromJSON=this.markFromJSON.bind(this),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,n=null,r,i){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof vf){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(n,r,i)}text(e,n){let r=this.nodes.text;return new vs(r,r.defaultAttrs,e,_.setFrom(n))}mark(e,n){return typeof e=="string"&&(e=this.marks[e]),e.create(n)}nodeFromJSON(e){return xt.fromJSON(this,e)}markFromJSON(e){return _.fromJSON(this,e)}nodeType(e){let n=this.nodes[e];if(!n)throw new RangeError("Unknown node type: "+e);return n}}function xf(t,e){let n=[];for(let r=0;r-1)&&n.push(s=a)}if(!s)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return n}class Li{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[],n.forEach(r=>{r.tag?this.tags.push(r):r.style&&this.styles.push(r)}),this.normalizeLists=!this.tags.some(r=>{if(!/^(ul|ol)\b/.test(r.tag)||!r.node)return!1;let i=e.nodes[r.node];return i.contentMatch.matchType(i)})}parse(e,n={}){let r=new Nf(this,n,!1);return r.addAll(e,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new Nf(this,n,!0);return r.addAll(e,n.from,n.to),x.maxOpen(r.finish())}matchTag(e,n,r){for(let i=r?this.tags.indexOf(r)+1:0;ie.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=n))){if(s.getAttrs){let a=s.getAttrs(n);if(a===!1)continue;s.attrs=a||void 0}return s}}}static schemaRules(e){let n=[];function r(i){let o=i.priority==null?50:i.priority,s=0;for(;s{r(s=Mf(s)),s.mark||s.ignore||s.clearMark||(s.mark=i)})}for(let i in e.nodes){let o=e.nodes[i].spec.parseDOM;o&&o.forEach(s=>{r(s=Mf(s)),s.node||s.ignore||s.mark||(s.node=i)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Li(e,Li.schemaRules(e)))}}const kp={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},Qy={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},wp={ol:!0,ul:!0},xs=1,Cs=2,vi=4;function Cf(t,e,n){return e!=null?(e?xs:0)|(e==="full"?Cs:0):t&&t.whitespace=="pre"?xs|Cs:n&~vi}class Do{constructor(e,n,r,i,o,s,l){this.type=e,this.attrs=n,this.marks=r,this.pendingMarks=i,this.solid=o,this.options=l,this.content=[],this.activeMarks=_.none,this.stashMarks=[],this.match=s||(l&vi?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(v.from(e));if(n)this.match=this.type.contentMatch.matchFragment(n);else{let r=this.type.contentMatch,i;return(i=r.findWrapping(e.type))?(this.match=r,i):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&xs)){let r=this.content[this.content.length-1],i;if(r&&r.isText&&(i=/[ \t\r\n\u000c]+$/.exec(r.text))){let o=r;r.text.length==i[0].length?this.content.pop():this.content[this.content.length-1]=o.withText(o.text.slice(0,o.text.length-i[0].length))}}let n=v.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(v.empty,!0))),this.type?this.type.create(this.attrs,n,this.marks):n}popFromStashMark(e){for(let n=this.stashMarks.length-1;n>=0;n--)if(e.eq(this.stashMarks[n]))return this.stashMarks.splice(n,1)[0]}applyPending(e){for(let n=0,r=this.pendingMarks;nthis.addAll(e)),s&&this.sync(l),this.needsBlock=a}else this.withStyleRules(e,()=>{this.addElementByRule(e,o,o.consuming===!1?i:void 0)})}leafFallback(e){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(` -`))}ignoreFallback(e){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"))}readStyles(e){let n=_.none,r=_.none;for(let i=0;i{s.clearMark(l)&&(r=l.addToSet(r))}):n=this.parser.schema.marks[s.mark].create(s.attrs).addToSet(n),s.consuming===!1)o=s;else break}return[n,r]}addElementByRule(e,n,r){let i,o,s;n.node?(o=this.parser.schema.nodes[n.node],o.isLeaf?this.insertNode(o.create(n.attrs))||this.leafFallback(e):i=this.enter(o,n.attrs||null,n.preserveWhitespace)):(s=this.parser.schema.marks[n.mark].create(n.attrs),this.addPendingMark(s));let l=this.top;if(o&&o.isLeaf)this.findInside(e);else if(r)this.addElement(e,r);else if(n.getContent)this.findInside(e),n.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a));else{let a=e;typeof n.contentElement=="string"?a=e.querySelector(n.contentElement):typeof n.contentElement=="function"?a=n.contentElement(e):n.contentElement&&(a=n.contentElement),this.findAround(e,a,!0),this.addAll(a)}i&&this.sync(l)&&this.open--,s&&this.removePendingMark(s,l)}addAll(e,n,r){let i=n||0;for(let o=n?e.childNodes[n]:e.firstChild,s=r==null?null:e.childNodes[r];o!=s;o=o.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(o);this.findAtPoint(e,i)}findPlace(e){let n,r;for(let i=this.open;i>=0;i--){let o=this.nodes[i],s=o.findWrapping(e);if(s&&(!n||n.length>s.length)&&(n=s,r=o,!s.length)||o.solid)break}if(!n)return!1;this.sync(r);for(let i=0;ithis.open){for(;n>this.open;n--)this.nodes[n-1].content.push(this.nodes[n].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 n=this.open;n>=0;n--)if(this.nodes[n]==e)return this.open=n,!0;return!1}get currentPos(){this.closeExtra();let e=0;for(let n=this.open;n>=0;n--){let r=this.nodes[n].content;for(let i=r.length-1;i>=0;i--)e+=r[i].nodeSize;n&&e++}return e}findAtPoint(e,n){if(this.find)for(let r=0;r-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let n=e.split("/"),r=this.options.context,i=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),o=-(r?r.depth+1:0)+(i?0:1),s=(l,a)=>{for(;l>=0;l--){let u=n[l];if(u==""){if(l==n.length-1||l==0)continue;for(;a>=o;a--)if(s(l-1,a))return!0;return!1}else{let c=a>0||a==0&&i?this.nodes[a].type:r&&a>=o?r.node(a-o).type:null;if(!c||c.name!=u&&c.groups.indexOf(u)==-1)return!1;a--}}return!0};return s(n.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let n=e.depth;n>=0;n--){let r=e.node(n).contentMatchAt(e.indexAfter(n)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let n in this.parser.schema.nodes){let r=this.parser.schema.nodes[n];if(r.isTextblock&&r.defaultAttrs)return r}}addPendingMark(e){let n=e1(e,this.top.pendingMarks);n&&this.top.stashMarks.push(n),this.top.pendingMarks=e.addToSet(this.top.pendingMarks)}removePendingMark(e,n){for(let r=this.open;r>=0;r--){let i=this.nodes[r];if(i.pendingMarks.lastIndexOf(e)>-1)i.pendingMarks=e.removeFromSet(i.pendingMarks);else{i.activeMarks=e.removeFromSet(i.activeMarks);let s=i.popFromStashMark(e);s&&i.type&&i.type.allowsMarkType(s.type)&&(i.activeMarks=s.addToSet(i.activeMarks))}if(i==n)break}}}function Yy(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&wp.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function Gy(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function Xy(t){let e=/\s*([\w-]+)\s*:\s*([^;]+)/g,n,r=[];for(;n=e.exec(t);)r.push(n[1],n[2].trim());return r}function Mf(t){let e={};for(let n in t)e[n]=t[n];return e}function Zy(t,e){let n=e.schema.nodes;for(let r in n){let i=n[r];if(!i.allowsMarkType(t))continue;let o=[],s=l=>{o.push(l);for(let a=0;a{if(o.length||s.marks.length){let l=0,a=0;for(;l=0;i--){let o=this.serializeMark(e.marks[i],e.isInline,n);o&&((o.contentDOM||o.dom).appendChild(r),r=o.dom)}return r}serializeMark(e,n,r={}){let i=this.marks[e.type.name];return i&&Lt.renderSpec(Al(r),i(e,n))}static renderSpec(e,n,r=null){if(typeof n=="string")return{dom:e.createTextNode(n)};if(n.nodeType!=null)return{dom:n};if(n.dom&&n.dom.nodeType!=null)return n;let i=n[0],o=i.indexOf(" ");o>0&&(r=i.slice(0,o),i=i.slice(o+1));let s,l=r?e.createElementNS(r,i):e.createElement(i),a=n[1],u=1;if(a&&typeof a=="object"&&a.nodeType==null&&!Array.isArray(a)){u=2;for(let c in a)if(a[c]!=null){let f=c.indexOf(" ");f>0?l.setAttributeNS(c.slice(0,f),c.slice(f+1),a[c]):l.setAttribute(c,a[c])}}for(let c=u;cu)throw new RangeError("Content hole must be the only child of its parent node");return{dom:l,contentDOM:l}}else{let{dom:d,contentDOM:p}=Lt.renderSpec(e,f,r);if(l.appendChild(d),p){if(s)throw new RangeError("Multiple content holes");s=p}}}return{dom:l,contentDOM:s}}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new Lt(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=Ef(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return Ef(e.marks)}}function Ef(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function Al(t){return t.document||window.document}const vp=65535,xp=Math.pow(2,16);function t1(t,e){return t+e*xp}function Of(t){return t&vp}function n1(t){return(t-(t&vp))/xp}const Cp=1,Np=2,es=4,Mp=8;let Na=class{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&Mp)>0}get deletedBefore(){return(this.delInfo&(Cp|es))>0}get deletedAfter(){return(this.delInfo&(Np|es))>0}get deletedAcross(){return(this.delInfo&es)>0}},zr=class lr{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&lr.empty)return lr.empty}recover(e){let n=0,r=Of(e);if(!this.inverted)for(let i=0;ie)break;let u=this.ranges[l+o],c=this.ranges[l+s],f=a+u;if(e<=f){let d=u?e==a?-1:e==f?1:n:n,p=a+i+(d<0?0:c);if(r)return p;let h=e==(n<0?a:f)?null:t1(l/3,e-a),m=e==a?Np:e==f?Cp:es;return(n<0?e!=a:e!=f)&&(m|=Mp),new Na(p,m,h)}i+=c-u}return r?e+i:new Na(e+i,0,null)}touches(e,n){let r=0,i=Of(n),o=this.inverted?2:1,s=this.inverted?1:2;for(let l=0;le)break;let u=this.ranges[l+o],c=a+u;if(e<=c&&l==i*3)return!0;r+=this.ranges[l+s]-u}return!1}forEach(e){let n=this.inverted?2:1,r=this.inverted?1:2;for(let i=0,o=0;i=0;n--){let i=e.getMirror(n);this.appendMap(e.maps[n].invert(),i!=null&&i>n?r-i-1:void 0)}}invert(){let e=new ts;return e.appendMappingInverted(this),e}map(e,n=1){if(this.mirror)return this._map(e,n,!0);for(let r=this.from;ro&&a!s.isAtom||!l.type.allowsMarkType(this.mark.type)?s:s.mark(this.mark.addToSet(s.marks)),i),n.openStart,n.openEnd);return Ie.fromReplace(e,this.from,this.to,o)}invert(){return new ho(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new ai(n.pos,r.pos,this.mark)}merge(e){return e instanceof ai&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new ai(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,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new ai(n.from,n.to,e.markFromJSON(n.mark))}};We.jsonID("addMark",Qu);let ho=class ui extends We{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=new x(qu(n.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),n.openStart,n.openEnd);return Ie.fromReplace(e,this.from,this.to,r)}invert(){return new Qu(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new ui(n.pos,r.pos,this.mark)}merge(e){return e instanceof ui&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new ui(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,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new ui(n.from,n.to,e.markFromJSON(n.mark))}};We.jsonID("removeMark",ho);let Yu=class ci extends We{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return Ie.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return Ie.fromReplace(e,this.pos,this.pos+1,new x(v.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);if(n){let r=this.mark.addToSet(n.marks);if(r.length==n.marks.length){for(let i=0;ir.pos?null:new ns(n.pos,r.pos,i,o,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number"||typeof n.gapFrom!="number"||typeof n.gapTo!="number"||typeof n.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new ns(n.from,n.to,n.gapFrom,n.gapTo,x.fromJSON(e,n.slice),n.insert,!!n.structure)}};We.jsonID("replaceAround",Wt);function Ea(t,e,n){let r=t.resolve(e),i=n-e,o=r.depth;for(;i>0&&o>0&&r.indexAfter(o)==r.node(o).childCount;)o--,i--;if(i>0){let s=r.node(o).maybeChild(r.indexAfter(o));for(;i>0;){if(!s||s.isLeaf)return!0;s=s.firstChild,i--}}return!1}function i1(t,e,n,r){let i=[],o=[],s,l;t.doc.nodesBetween(e,n,(a,u,c)=>{if(!a.isInline)return;let f=a.marks;if(!r.isInSet(f)&&c.type.allowsMarkType(r.type)){let d=Math.max(u,e),p=Math.min(u+a.nodeSize,n),h=r.addToSet(f);for(let m=0;mt.step(a)),o.forEach(a=>t.step(a))}function o1(t,e,n,r){let i=[],o=0;t.doc.nodesBetween(e,n,(s,l)=>{if(!s.isInline)return;o++;let a=null;if(r instanceof fo){let u=s.marks,c;for(;c=r.isInSet(u);)(a||(a=[])).push(c),u=c.removeFromSet(u)}else r?r.isInSet(s.marks)&&(a=[r]):a=s.marks;if(a&&a.length){let u=Math.min(l+s.nodeSize,n);for(let c=0;ct.step(new ho(s.from,s.to,s.style)))}function s1(t,e,n,r=n.contentMatch){let i=t.doc.nodeAt(e),o=[],s=e+1;for(let l=0;l=0;l--)t.step(o[l])}function l1(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function Xu(t){let n=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let r=t.depth;;--r){let i=t.$from.node(r),o=t.$from.index(r),s=t.$to.indexAfter(r);if(rn;h--)m||r.index(h)>0?(m=!0,c=v.from(r.node(h).copy(c)),f++):a--;let d=v.empty,p=0;for(let h=o,m=!1;h>n;h--)m||i.after(h+1)=0;s--){if(r.size){let l=n[s].type.contentMatch.matchFragment(r);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=v.from(n[s].type.create(n[s].attrs,r))}let i=e.start,o=e.end;t.step(new Wt(i,o,i,o,new x(r,0,0),n.length,!0))}function h1(t,e,n,r,i){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let o=t.steps.length;t.doc.nodesBetween(e,n,(s,l)=>{if(s.isTextblock&&!s.hasMarkup(r,i)&&p1(t.doc,t.mapping.slice(o).map(l),r)){t.clearIncompatible(t.mapping.slice(o).map(l,1),r);let a=t.mapping.slice(o),u=a.map(l,1),c=a.map(l+s.nodeSize,1);return t.step(new Wt(u,c,u+1,c-1,new x(v.from(r.create(i,null,s.marks)),0,0),1,!0)),!1}})}function p1(t,e,n){let r=t.resolve(e),i=r.index();return r.parent.canReplaceWith(i,i+1,n)}function m1(t,e,n,r,i){let o=t.doc.nodeAt(e);if(!o)throw new RangeError("No node at given position");n||(n=o.type);let s=n.create(r,null,i||o.marks);if(o.isLeaf)return t.replaceWith(e,e+o.nodeSize,s);if(!n.validContent(o.content))throw new RangeError("Invalid content for node type "+n.name);t.step(new Wt(e,e+o.nodeSize,e+1,e+o.nodeSize-1,new x(v.from(s),0,0),1,!0))}function rs(t,e,n=1,r){let i=t.resolve(e),o=i.depth-n,s=r&&r[r.length-1]||i.parent;if(o<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!s.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let u=i.depth-1,c=n-2;u>o;u--,c--){let f=i.node(u),d=i.index(u);if(f.type.spec.isolating)return!1;let p=f.content.cutByIndex(d,f.childCount),h=r&&r[c]||f;if(h!=f&&(p=p.replaceChild(0,h.type.create(h.attrs))),!f.canReplace(d+1,f.childCount)||!h.type.validContent(p))return!1}let l=i.indexAfter(o),a=r&&r[0];return i.node(o).canReplaceWith(l,l,a?a.type:i.node(o+1).type)}function g1(t,e,n=1,r){let i=t.doc.resolve(e),o=v.empty,s=v.empty;for(let l=i.depth,a=i.depth-n,u=n-1;l>a;l--,u--){o=v.from(i.node(l).copy(o));let c=r&&r[u];s=v.from(c?c.type.create(c.attrs,s):i.node(l).copy(s))}t.step(new Cn(e,e,new x(o.append(s),n,n),!0))}function Zu(t,e){let n=t.resolve(e),r=n.index();return y1(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function y1(t,e){return!!(t&&e&&!t.isLeaf&&t.canAppend(e))}function S1(t,e,n){let r=new Cn(e-n,e+n,x.empty,!0);t.step(r)}function k1(t,e,n){let r=t.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),n))return e;if(r.parentOffset==0)for(let i=r.depth-1;i>=0;i--){let o=r.index(i);if(r.node(i).canReplaceWith(o,o,n))return r.before(i+1);if(o>0)return null}if(r.parentOffset==r.parent.content.size)for(let i=r.depth-1;i>=0;i--){let o=r.indexAfter(i);if(r.node(i).canReplaceWith(o,o,n))return r.after(i+1);if(o=0;s--){let l=s==r.depth?0:r.pos<=(r.start(s+1)+r.end(s+1))/2?-1:1,a=r.index(s)+(l>0?1:0),u=r.node(s),c=!1;if(o==1)c=u.canReplace(a,a,i);else{let f=u.contentMatchAt(a).findWrapping(i.firstChild.type);c=f&&u.canReplaceWith(a,a,f[0])}if(c)return l==0?r.pos:l<0?r.before(s+1):r.after(s+1)}return null}function ec(t,e,n=e,r=x.empty){if(e==n&&!r.size)return null;let i=t.resolve(e),o=t.resolve(n);return Ep(i,o,r)?new Cn(e,n,r):new v1(i,o,r).fit()}function Ep(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}let v1=class{constructor(e,n,r){this.$from=e,this.$to=n,this.unplaced=r,this.frontier=[],this.placed=v.empty;for(let i=0;i<=e.depth;i++){let o=e.node(i);this.frontier.push({type:o.type,match:o.contentMatchAt(e.indexAfter(i))})}for(let i=e.depth;i>0;i--)this.placed=v.from(e.node(i).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let u=this.findFittable();u?this.placeNodes(u):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),n=this.placed.size-this.depth-this.$from.depth,r=this.$from,i=this.close(e<0?this.$to:r.doc.resolve(e));if(!i)return null;let o=this.placed,s=r.depth,l=i.depth;for(;s&&l&&o.childCount==1;)o=o.firstChild.content,s--,l--;let a=new x(o,s,l);return e>-1?new Wt(r.pos,e,this.$to.pos,this.$to.end(),a,n):a.size||r.pos!=this.$to.pos?new Cn(r.pos,i.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let n=this.unplaced.content,r=0,i=this.unplaced.openEnd;r1&&(i=0),o.type.spec.isolating&&i<=r){e=r;break}n=o.content}for(let n=1;n<=2;n++)for(let r=n==1?e:this.unplaced.openStart;r>=0;r--){let i,o=null;r?(o=Pl(this.unplaced.content,r-1).firstChild,i=o.content):i=this.unplaced.content;let s=i.firstChild;for(let l=this.depth;l>=0;l--){let{type:a,match:u}=this.frontier[l],c,f=null;if(n==1&&(s?u.matchType(s.type)||(f=u.fillBefore(v.from(s),!1)):o&&a.compatibleContent(o.type)))return{sliceDepth:r,frontierDepth:l,parent:o,inject:f};if(n==2&&s&&(c=u.findWrapping(s.type)))return{sliceDepth:r,frontierDepth:l,parent:o,wrap:c};if(o&&u.matchType(o.type))break}}}openMore(){let{content:e,openStart:n,openEnd:r}=this.unplaced,i=Pl(e,n);return!i.childCount||i.firstChild.isLeaf?!1:(this.unplaced=new x(e,n+1,Math.max(r,i.size+n>=e.size-r?n+1:0)),!0)}dropNode(){let{content:e,openStart:n,openEnd:r}=this.unplaced,i=Pl(e,n);if(i.childCount<=1&&n>0){let o=e.size-n<=n+i.size;this.unplaced=new x(fi(e,n-1,1),n-1,o?n-1:r)}else this.unplaced=new x(fi(e,n,1),n,r)}placeNodes({sliceDepth:e,frontierDepth:n,parent:r,inject:i,wrap:o}){for(;this.depth>n;)this.closeFrontierNode();if(o)for(let m=0;m1||a==0||m.content.size)&&(f=k,c.push(Op(m.mark(d.allowedMarks(m.marks)),u==1?a:0,u==l.childCount?p:-1)))}let h=u==l.childCount;h||(p=-1),this.placed=di(this.placed,n,v.from(c)),this.frontier[n].match=f,h&&p<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let m=0,k=l;m1&&i==this.$to.end(--r);)++i;return i}findCloseLevel(e){e:for(let n=Math.min(this.depth,e.depth);n>=0;n--){let{match:r,type:i}=this.frontier[n],o=n=0;l--){let{match:a,type:u}=this.frontier[l],c=zl(e,l,u,a,!0);if(!c||c.childCount)continue e}return{depth:n,fit:s,move:o?e.doc.resolve(e.after(n+1)):e}}}}close(e){let n=this.findCloseLevel(e);if(!n)return null;for(;this.depth>n.depth;)this.closeFrontierNode();n.fit.childCount&&(this.placed=di(this.placed,n.depth,n.fit)),e=n.move;for(let r=n.depth+1;r<=e.depth;r++){let i=e.node(r),o=i.type.contentMatch.fillBefore(i.content,!0,e.index(r));this.openFrontierNode(i.type,i.attrs,o)}return e}openFrontierNode(e,n=null,r){let i=this.frontier[this.depth];i.match=i.match.matchType(e),this.placed=di(this.placed,this.depth,v.from(e.create(n,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(v.empty,!0);n.childCount&&(this.placed=di(this.placed,this.frontier.length,n))}};function fi(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(fi(t.firstChild.content,e-1,n)))}function di(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(di(t.lastChild.content,e-1,n)))}function Pl(t,e){for(let n=0;n1&&(r=r.replaceChild(0,Op(r.firstChild,e-1,r.childCount==1?n-1:0))),e>0&&(r=t.type.contentMatch.fillBefore(r).append(r),n<=0&&(r=r.append(t.type.contentMatch.matchFragment(r).fillBefore(v.empty,!0)))),t.copy(r)}function zl(t,e,n,r,i){let o=t.node(e),s=i?t.indexAfter(e):t.index(e);if(s==o.childCount&&!n.compatibleContent(o.type))return null;let l=r.fillBefore(o.content,!0,s);return l&&!x1(n,o.content,s)?l:null}function x1(t,e,n){for(let r=n;r0;d--,p--){let h=i.node(d).type.spec;if(h.defining||h.definingAsContext||h.isolating)break;s.indexOf(d)>-1?l=d:i.before(d)==p&&s.splice(1,0,-d)}let a=s.indexOf(l),u=[],c=r.openStart;for(let d=r.content,p=0;;p++){let h=d.firstChild;if(u.push(h),p==r.openStart)break;d=h.content}for(let d=c-1;d>=0;d--){let p=u[d].type,h=C1(p);if(h&&i.node(a).type!=p)c=d;else if(h||!p.isTextblock)break}for(let d=r.openStart;d>=0;d--){let p=(d+c+1)%(r.openStart+1),h=u[p];if(h)for(let m=0;m=0&&(t.replace(e,n,r),!(t.steps.length>f));d--){let p=s[d];p<0||(e=i.before(p),n=o.after(p))}}function Dp(t,e,n,r,i){if(er){let o=i.contentMatchAt(0),s=o.fillBefore(t).append(t);t=s.append(o.matchFragment(s).fillBefore(v.empty,!0))}return t}function M1(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let i=k1(t.doc,e,r.type);i!=null&&(e=n=i)}t.replaceRange(e,n,new x(v.from(r),0,0))}function E1(t,e,n){let r=t.doc.resolve(e),i=t.doc.resolve(n),o=Tp(r,i);for(let s=0;s0&&(a||r.node(l-1).canReplace(r.index(l-1),i.indexAfter(l-1))))return t.delete(r.before(l),i.after(l))}for(let s=1;s<=r.depth&&s<=i.depth;s++)if(e-r.start(s)==r.depth-s&&n>r.end(s)&&i.end(s)-n!=i.depth-s)return t.delete(r.before(s),n);t.delete(e,n)}function Tp(t,e){let n=[],r=Math.min(t.depth,e.depth);for(let i=r;i>=0;i--){let o=t.start(i);if(oe.pos+(e.depth-i)||t.node(i).type.spec.isolating||e.node(i).type.spec.isolating)break;(o==e.start(i)||i==t.depth&&i==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&i&&e.start(i-1)==o-1)&&n.push(i)}return n}let Ap=class is extends We{constructor(e,n,r){super(),this.pos=e,this.attr=n,this.value=r}apply(e){let n=e.nodeAt(this.pos);if(!n)return Ie.fail("No node at attribute step's position");let r=Object.create(null);for(let o in n.attrs)r[o]=n.attrs[o];r[this.attr]=this.value;let i=n.type.create(r,null,n.marks);return Ie.fromReplace(e,this.pos,this.pos+1,new x(v.from(i),0,n.isLeaf?0:1))}getMap(){return zr.empty}invert(e){return new is(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new is(n.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.pos!="number"||typeof n.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new is(n.pos,n.attr,n.value)}};We.jsonID("attr",Ap);let Fr=class extends Error{};Fr=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};Fr.prototype=Object.create(Error.prototype);Fr.prototype.constructor=Fr;Fr.prototype.name="TransformError";let O1=class{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new r1}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new Fr(n.failed);return this}maybeStep(e){let n=e.apply(this.doc);return n.failed||this.addStep(e,n.doc),n}get docChanged(){return this.steps.length>0}addStep(e,n){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=n}replace(e,n=e,r=x.empty){let i=ec(this.doc,e,n,r);return i&&this.step(i),this}replaceWith(e,n,r){return this.replace(e,n,new x(v.from(r),0,0))}delete(e,n){return this.replace(e,n,x.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,r){return N1(this,e,n,r),this}replaceRangeWith(e,n,r){return M1(this,e,n,r),this}deleteRange(e,n){return E1(this,e,n),this}lift(e,n){return a1(this,e,n),this}join(e,n=1){return S1(this,e,n),this}wrap(e,n){return d1(this,e,n),this}setBlockType(e,n=e,r,i=null){return h1(this,e,n,r,i),this}setNodeMarkup(e,n,r=null,i){return m1(this,e,n,r,i),this}setNodeAttribute(e,n,r){return this.step(new Ap(e,n,r)),this}addNodeMark(e,n){return this.step(new Yu(e,n)),this}removeNodeMark(e,n){if(!(n instanceof _)){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(n=n.isInSet(r.marks),!n)return this}return this.step(new Gu(e,n)),this}split(e,n=1,r){return g1(this,e,n,r),this}addMark(e,n,r){return i1(this,e,n,r),this}removeMark(e,n,r){return o1(this,e,n,r),this}clearIncompatible(e,n,r){return s1(this,e,n,r),this}};const Fl=Object.create(null);class I{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new Rp(e.min(n),e.max(n))]}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 n=0;n=0;o--){let s=n<0?ar(e.node(0),e.node(o),e.before(o+1),e.index(o),n,r):ar(e.node(0),e.node(o),e.after(o+1),e.index(o)+1,n,r);if(s)return s}return null}static near(e,n=1){return this.findFrom(e,n)||this.findFrom(e,-n)||new Je(e.node(0))}static atStart(e){return ar(e,e,0,0,1)||new Je(e)}static atEnd(e){return ar(e,e,e.content.size,e.childCount,-1)||new Je(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=Fl[n.type];if(!r)throw new RangeError(`No selection type ${n.type} defined`);return r.fromJSON(e,n)}static jsonID(e,n){if(e in Fl)throw new RangeError("Duplicate use of selection JSON ID "+e);return Fl[e]=n,n.prototype.jsonID=e,n}getBookmark(){return B.between(this.$anchor,this.$head).getBookmark()}}I.prototype.visible=!0;class Rp{constructor(e,n){this.$from=e,this.$to=n}}let Tf=!1;function Af(t){!Tf&&!t.parent.inlineContent&&(Tf=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class B extends I{constructor(e,n=e){Af(e),Af(n),super(e,n)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,n){let r=e.resolve(n.map(this.head));if(!r.parent.inlineContent)return I.near(r);let i=e.resolve(n.map(this.anchor));return new B(i.parent.inlineContent?i:r,r)}replace(e,n=x.empty){if(super.replace(e,n),n==x.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof B&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new rl(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,n){if(typeof n.anchor!="number"||typeof n.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new B(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){let i=e.resolve(n);return new this(i,r==n?i:e.resolve(r))}static between(e,n,r){let i=e.pos-n.pos;if((!r||i)&&(r=i>=0?1:-1),!n.parent.inlineContent){let o=I.findFrom(n,r,!0)||I.findFrom(n,-r,!0);if(o)n=o.$head;else return I.near(n,r)}return e.parent.inlineContent||(i==0?e=n:(e=(I.findFrom(e,-r,!0)||I.findFrom(e,r,!0)).$anchor,e.pos0?0:1);i>0?s=0;s+=i){let l=e.child(s);if(l.isAtom){if(!o&&z.isSelectable(l))return z.create(t,n-(i<0?l.nodeSize:0))}else{let a=ar(t,l,n+i,i<0?l.childCount:0,i,o);if(a)return a}n+=l.nodeSize*i}return null}function Rf(t,e,n){let r=t.steps.length-1;if(r{s==null&&(s=c)}),t.setSelection(I.near(t.doc.resolve(s),n))}const Pf=1,To=2,zf=4;class T1 extends O1{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor0}setStoredMarks(e){return this.storedMarks=e,this.updated|=To,this}ensureMarks(e){return _.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&To)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~To,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,n=!0){let r=this.selection;return n&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||_.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,n,r){let i=this.doc.type.schema;if(n==null)return e?this.replaceSelectionWith(i.text(e),!0):this.deleteSelection();{if(r==null&&(r=n),r=r??n,!e)return this.deleteRange(n,r);let o=this.storedMarks;if(!o){let s=this.doc.resolve(n);o=r==n?s.marks():s.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(n,r,i.text(e,o)),this.selection.empty||this.setSelection(I.near(this.selection.$to)),this}}setMeta(e,n){return this.meta[typeof e=="string"?e:e.key]=n,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=zf,this}get scrolledIntoView(){return(this.updated&zf)>0}}function Ff(t,e){return!e||!t?t:t.bind(e)}class hi{constructor(e,n,r){this.name=e,this.init=Ff(n.init,r),this.apply=Ff(n.apply,r)}}const A1=[new hi("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new hi("selection",{init(t,e){return t.selection||I.atStart(e.doc)},apply(t){return t.selection}}),new hi("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new hi("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class Il{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=A1.slice(),n&&n.forEach(r=>{if(this.pluginsByKey[r.key])throw new RangeError("Adding different instances of a keyed plugin ("+r.key+")");this.plugins.push(r),this.pluginsByKey[r.key]=r,r.spec.state&&this.fields.push(new hi(r.key,r.spec.state,r))})}}class on{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,n=-1){for(let r=0;rr.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let i=e[r],o=i.spec.state;o&&o.toJSON&&(n[r]=o.toJSON.call(i,this[i.key]))}return n}static fromJSON(e,n,r){if(!n)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let i=new Il(e.schema,e.plugins),o=new on(i);return i.fields.forEach(s=>{if(s.name=="doc")o.doc=vt.fromJSON(e.schema,n.doc);else if(s.name=="selection")o.selection=I.fromJSON(o.doc,n.selection);else if(s.name=="storedMarks")n.storedMarks&&(o.storedMarks=n.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let l in r){let a=r[l],u=a.spec.state;if(a.key==s.name&&u&&u.fromJSON&&Object.prototype.hasOwnProperty.call(n,l)){o[s.name]=u.fromJSON.call(a,e,n[l],o);return}}o[s.name]=s.init(e,o)}}),o}}function Pp(t,e,n){for(let r in t){let i=t[r];i instanceof Function?i=i.bind(e):r=="handleDOMEvents"&&(i=Pp(i,e,{})),n[r]=i}return n}class At{constructor(e){this.spec=e,this.props={},e.props&&Pp(e.props,this,this.props),this.key=e.key?e.key.key:zp("plugin")}getState(e){return e[this.key]}}const bl=Object.create(null);function zp(t){return t in bl?t+"$"+ ++bl[t]:(bl[t]=0,t+"$")}class po{constructor(e="key"){this.key=zp(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const Fp=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function R1(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}const P1=(t,e,n)=>{let r=R1(t,n);if(!r)return!1;let i=Ip(r);if(!i){let s=r.blockRange(),l=s&&Xu(s);return l==null?!1:(e&&e(t.tr.lift(s,l).scrollIntoView()),!0)}let o=i.nodeBefore;if(!o.type.spec.isolating&&Lp(t,i,e))return!0;if(r.parent.content.size==0&&(Ir(o,"end")||z.isSelectable(o))){let s=ec(t.doc,r.before(),r.after(),x.empty);if(s&&s.slice.size{let{$head:r,empty:i}=t.selection,o=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("backward",t):r.parentOffset>0)return!1;o=Ip(r)}let s=o&&o.nodeBefore;return!s||!z.isSelectable(s)?!1:(e&&e(t.tr.setSelection(z.create(t.doc,o.pos-s.nodeSize)).scrollIntoView()),!0)};function Ip(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){if(t.index(e)>0)return t.doc.resolve(t.before(e+1));if(t.node(e).type.spec.isolating)break}return null}function F1(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset{let r=F1(t,n);if(!r)return!1;let i=bp(r);if(!i)return!1;let o=i.nodeAfter;if(Lp(t,i,e))return!0;if(r.parent.content.size==0&&(Ir(o,"start")||z.isSelectable(o))){let s=ec(t.doc,r.before(),r.after(),x.empty);if(s&&s.slice.size{let{$head:r,empty:i}=t.selection,o=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("forward",t):r.parentOffset=0;e--){let n=t.node(e);if(t.index(e)+1{let{$head:n,$anchor:r}=t.selection;return!n.parent.type.spec.code||!n.sameParent(r)?!1:(e&&e(t.tr.insertText(` -`).scrollIntoView()),!0)};function nc(t){for(let e=0;e{let{$head:n,$anchor:r}=t.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let i=n.node(-1),o=n.indexAfter(-1),s=nc(i.contentMatchAt(o));if(!s||!i.canReplaceWith(o,o,s))return!1;if(e){let l=n.after(),a=t.tr.replaceWith(l,l,s.createAndFill());a.setSelection(I.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},V1=(t,e)=>{let n=t.selection,{$from:r,$to:i}=n;if(n instanceof Je||r.parent.inlineContent||i.parent.inlineContent)return!1;let o=nc(i.parent.contentMatchAt(i.indexAfter()));if(!o||!o.isTextblock)return!1;if(e){let s=(!r.parentOffset&&i.index(){let{$cursor:n}=t.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let o=n.before();if(rs(t.doc,o))return e&&e(t.tr.split(o).scrollIntoView()),!0}let r=n.blockRange(),i=r&&Xu(r);return i==null?!1:(e&&e(t.tr.lift(r,i).scrollIntoView()),!0)};function _1(t){return(e,n)=>{let{$from:r,$to:i}=e.selection;if(e.selection instanceof z&&e.selection.node.isBlock)return!r.parentOffset||!rs(e.doc,r.pos)?!1:(n&&n(e.tr.split(r.pos).scrollIntoView()),!0);if(!r.parent.isBlock)return!1;if(n){let o=i.parentOffset==i.parent.content.size,s=e.tr;(e.selection instanceof B||e.selection instanceof Je)&&s.deleteSelection();let l=r.depth==0?null:nc(r.node(-1).contentMatchAt(r.indexAfter(-1))),a=t&&t(i.parent,o),u=a?[a]:o&&l?[{type:l}]:void 0,c=rs(s.doc,s.mapping.map(r.pos),1,u);if(!u&&!c&&rs(s.doc,s.mapping.map(r.pos),1,l?[{type:l}]:void 0)&&(l&&(u=[{type:l}]),c=!0),c&&(s.split(s.mapping.map(r.pos),1,u),!o&&!r.parentOffset&&r.parent.type!=l)){let f=s.mapping.map(r.before()),d=s.doc.resolve(f);l&&r.node(-1).canReplaceWith(d.index(),d.index()+1,l)&&s.setNodeMarkup(s.mapping.map(r.before()),l)}n(s.scrollIntoView())}return!0}}const W1=_1(),U1=(t,e)=>(e&&e(t.tr.setSelection(new Je(t.doc))),!0);function j1(t,e,n){let r=e.nodeBefore,i=e.nodeAfter,o=e.index();return!r||!i||!r.type.compatibleContent(i.type)?!1:!r.content.size&&e.parent.canReplace(o-1,o)?(n&&n(t.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(o,o+1)||!(i.isTextblock||Zu(t.doc,e.pos))?!1:(n&&n(t.tr.clearIncompatible(e.pos,r.type,r.contentMatchAt(r.childCount)).join(e.pos).scrollIntoView()),!0)}function Lp(t,e,n){let r=e.nodeBefore,i=e.nodeAfter,o,s;if(r.type.spec.isolating||i.type.spec.isolating)return!1;if(j1(t,e,n))return!0;let l=e.parent.canReplace(e.index(),e.index()+1);if(l&&(o=(s=r.contentMatchAt(r.childCount)).findWrapping(i.type))&&s.matchType(o[0]||i.type).validEnd){if(n){let f=e.pos+i.nodeSize,d=v.empty;for(let m=o.length-1;m>=0;m--)d=v.from(o[m].create(null,d));d=v.from(r.copy(d));let p=t.tr.step(new Wt(e.pos-1,f,e.pos,f,new x(d,1,0),o.length,!0)),h=f+2*o.length;Zu(p.doc,h)&&p.join(h),n(p.scrollIntoView())}return!0}let a=I.findFrom(e,1),u=a&&a.$from.blockRange(a.$to),c=u&&Xu(u);if(c!=null&&c>=e.depth)return n&&n(t.tr.lift(u,c).scrollIntoView()),!0;if(l&&Ir(i,"start",!0)&&Ir(r,"end")){let f=r,d=[];for(;d.push(f),!f.isTextblock;)f=f.lastChild;let p=i,h=1;for(;!p.isTextblock;p=p.firstChild)h++;if(f.canReplace(f.childCount,f.childCount,p.content)){if(n){let m=v.empty;for(let g=d.length-1;g>=0;g--)m=v.from(d[g].copy(m));let k=t.tr.step(new Wt(e.pos-d.length,e.pos+i.nodeSize,e.pos+h,e.pos+i.nodeSize-h,new x(m,d.length,0),0,!0));n(k.scrollIntoView())}return!0}}return!1}function Bp(t){return function(e,n){let r=e.selection,i=t<0?r.$from:r.$to,o=i.depth;for(;i.node(o).isInline;){if(!o)return!1;o--}return i.node(o).isTextblock?(n&&n(e.tr.setSelection(B.create(e.doc,t<0?i.start(o):i.end(o)))),!0):!1}}const H1=Bp(-1),J1=Bp(1);function K1(t,e,n){for(let r=0;r{if(s)return!1;s=l.inlineContent&&l.type.allowsMarkType(n)}),s)return!0}return!1}function If(t,e=null){return function(n,r){let{empty:i,$cursor:o,ranges:s}=n.selection;if(i&&!o||!K1(n.doc,s,t))return!1;if(r)if(o)t.isInSet(n.storedMarks||o.marks())?r(n.tr.removeStoredMark(t)):r(n.tr.addStoredMark(t.create(e)));else{let l=!1,a=n.tr;for(let u=0;!l&&u",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Lf=typeof navigator<"u"&&/Chrome\/(\d+)/.exec(navigator.userAgent),Y1=typeof navigator<"u"&&/Mac/.test(navigator.platform),G1=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),X1=Y1||Lf&&+Lf[1]<57;for(var pe=0;pe<10;pe++)Ut[48+pe]=Ut[96+pe]=String(pe);for(var pe=1;pe<=24;pe++)Ut[pe+111]="F"+pe;for(var pe=65;pe<=90;pe++)Ut[pe]=String.fromCharCode(pe+32),Ns[pe]=String.fromCharCode(pe);for(var Bl in Ut)Ns.hasOwnProperty(Bl)||(Ns[Bl]=Ut[Bl]);function $p(t){var e=X1&&(t.ctrlKey||t.altKey||t.metaKey)||G1&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?Ns:Ut)[t.keyCode]||t.key||"Unidentified";return n=="Esc"&&(n="Escape"),n=="Del"&&(n="Delete"),n=="Left"&&(n="ArrowLeft"),n=="Up"&&(n="ArrowUp"),n=="Right"&&(n="ArrowRight"),n=="Down"&&(n="ArrowDown"),n}const Z1=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):!1;function eS(t){let e=t.split(/-(?!$)/),n=e[e.length-1];n=="Space"&&(n=" ");let r,i,o,s;for(let l=0;l127)&&(o=Ut[r.keyCode])&&o!=i){let l=e[Vl(o,r)];if(l&&l(n.state,n.dispatch,n))return!0}}return!1}}const Ee=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},Bi=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let Bf=null;const zt=function(t,e,n){let r=Bf||(Bf=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r},Qn=function(t,e,n,r){return n&&(Vf(t,e,n,r,-1)||Vf(t,e,n,r,1))},nS=/^(img|br|input|textarea|hr)$/i;function Vf(t,e,n,r,i){for(;;){if(t==n&&e==r)return!0;if(e==(i<0?0:St(t))){let o=t.parentNode;if(!o||o.nodeType!=1||ic(t)||nS.test(t.nodeName)||t.contentEditable=="false")return!1;e=Ee(t)+(i<0?0:1),t=o}else if(t.nodeType==1){if(t=t.childNodes[e+(i<0?-1:0)],t.contentEditable=="false")return!1;e=i<0?St(t):0}else return!1}}function St(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function rS(t,e,n){for(let r=e==0,i=e==St(t);r||i;){if(t==n)return!0;let o=Ee(t);if(t=t.parentNode,!t)return!1;r=r&&o==0,i=i&&o==St(t)}}function ic(t){let e;for(let n=t;n&&!(e=n.pmViewDesc);n=n.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==t||e.contentDOM==t)}const il=function(t){return t.focusNode&&Qn(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function In(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}function iS(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function oS(t,e,n){if(t.caretPositionFromPoint)try{let r=t.caretPositionFromPoint(e,n);if(r)return{node:r.offsetNode,offset:r.offset}}catch{}if(t.caretRangeFromPoint){let r=t.caretRangeFromPoint(e,n);if(r)return{node:r.startContainer,offset:r.startOffset}}}const Mt=typeof navigator<"u"?navigator:null,$f=typeof document<"u"?document:null,Nn=Mt&&Mt.userAgent||"",Oa=/Edge\/(\d+)/.exec(Nn),Wp=/MSIE \d/.exec(Nn),Da=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Nn),Be=!!(Wp||Da||Oa),fn=Wp?document.documentMode:Da?+Da[1]:Oa?+Oa[1]:0,pt=!Be&&/gecko\/(\d+)/i.test(Nn);pt&&+(/Firefox\/(\d+)/.exec(Nn)||[0,0])[1];const Ta=!Be&&/Chrome\/(\d+)/.exec(Nn),xe=!!Ta,sS=Ta?+Ta[1]:0,Te=!Be&&!!Mt&&/Apple Computer/.test(Mt.vendor),br=Te&&(/Mobile\/\w+/.test(Nn)||!!Mt&&Mt.maxTouchPoints>2),Ge=br||(Mt?/Mac/.test(Mt.platform):!1),lS=Mt?/Win/.test(Mt.platform):!1,ct=/Android \d/.test(Nn),mo=!!$f&&"webkitFontSmoothing"in $f.documentElement.style,aS=mo?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function uS(t){return{left:0,right:t.documentElement.clientWidth,top:0,bottom:t.documentElement.clientHeight}}function Rt(t,e){return typeof t=="number"?t:t[e]}function cS(t){let e=t.getBoundingClientRect(),n=e.width/t.offsetWidth||1,r=e.height/t.offsetHeight||1;return{left:e.left,right:e.left+t.clientWidth*n,top:e.top,bottom:e.top+t.clientHeight*r}}function _f(t,e,n){let r=t.someProp("scrollThreshold")||0,i=t.someProp("scrollMargin")||5,o=t.dom.ownerDocument;for(let s=n||t.dom;s;s=Bi(s)){if(s.nodeType!=1)continue;let l=s,a=l==o.body,u=a?uS(o):cS(l),c=0,f=0;if(e.topu.bottom-Rt(r,"bottom")&&(f=e.bottom-e.top>u.bottom-u.top?e.top+Rt(i,"top")-u.top:e.bottom-u.bottom+Rt(i,"bottom")),e.leftu.right-Rt(r,"right")&&(c=e.right-u.right+Rt(i,"right")),c||f)if(a)o.defaultView.scrollBy(c,f);else{let d=l.scrollLeft,p=l.scrollTop;f&&(l.scrollTop+=f),c&&(l.scrollLeft+=c);let h=l.scrollLeft-d,m=l.scrollTop-p;e={left:e.left-h,top:e.top-m,right:e.right-h,bottom:e.bottom-m}}if(a||/^(fixed|sticky)$/.test(getComputedStyle(s).position))break}}function fS(t){let e=t.dom.getBoundingClientRect(),n=Math.max(0,e.top),r,i;for(let o=(e.left+e.right)/2,s=n+1;s=n-20){r=l,i=a.top;break}}return{refDOM:r,refTop:i,stack:Up(t.dom)}}function Up(t){let e=[],n=t.ownerDocument;for(let r=t;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t!=n);r=Bi(r));return e}function dS({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;jp(n,r==0?0:r-e)}function jp(t,e){for(let n=0;n=l){s=Math.max(h.bottom,s),l=Math.min(h.top,l);let m=h.left>e.left?h.left-e.left:h.right=(h.left+h.right)/2?1:0));continue}}else h.top>e.top&&!a&&h.left<=e.left&&h.right>=e.left&&(a=c,u={left:Math.max(h.left,Math.min(h.right,e.left)),top:h.top});!n&&(e.left>=h.right&&e.top>=h.top||e.left>=h.left&&e.top>=h.bottom)&&(o=f+1)}}return!n&&a&&(n=a,i=u,r=0),n&&n.nodeType==3?pS(n,i):!n||r&&n.nodeType==1?{node:t,offset:o}:Hp(n,i)}function pS(t,e){let n=t.nodeValue.length,r=document.createRange();for(let i=0;i=(o.left+o.right)/2?1:0)}}return{node:t,offset:0}}function oc(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function mS(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left(s.left+s.right)/2?1:-1}return t.docView.posFromDOM(r,i,o)}function yS(t,e,n,r){let i=-1;for(let o=e,s=!1;o!=t.dom;){let l=t.docView.nearestDesc(o,!0);if(!l)return null;if(l.dom.nodeType==1&&(l.node.isBlock&&l.parent&&!s||!l.contentDOM)){let a=l.dom.getBoundingClientRect();if(l.node.isBlock&&l.parent&&!s&&(s=!0,a.left>r.left||a.top>r.top?i=l.posBefore:(a.right-1?i:t.docView.posFromDOM(e,n,-1)}function Jp(t,e,n){let r=t.childNodes.length;if(r&&n.tope.top&&i++}let u;mo&&i&&r.nodeType==1&&(u=r.childNodes[i-1]).nodeType==1&&u.contentEditable=="false"&&u.getBoundingClientRect().top>=e.top&&i--,r==t.dom&&i==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?l=t.state.doc.content.size:(i==0||r.nodeType!=1||r.childNodes[i-1].nodeName!="BR")&&(l=yS(t,r,i,e))}l==null&&(l=gS(t,s,e));let a=t.docView.nearestDesc(s,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function Wf(t){return t.top=0&&i==r.nodeValue.length?(a--,c=1):n<0?a--:u++,Xr(Yt(zt(r,a,u),c),c<0)}if(!t.state.doc.resolve(e-(o||0)).parent.inlineContent){if(o==null&&i&&(n<0||i==St(r))){let a=r.childNodes[i-1];if(a.nodeType==1)return $l(a.getBoundingClientRect(),!1)}if(o==null&&i=0)}if(o==null&&i&&(n<0||i==St(r))){let a=r.childNodes[i-1],u=a.nodeType==3?zt(a,St(a)-(s?0:1)):a.nodeType==1&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(u)return Xr(Yt(u,1),!1)}if(o==null&&i=0)}function Xr(t,e){if(t.width==0)return t;let n=e?t.left:t.right;return{top:t.top,bottom:t.bottom,left:n,right:n}}function $l(t,e){if(t.height==0)return t;let n=e?t.top:t.bottom;return{top:n,bottom:n,left:t.left,right:t.right}}function qp(t,e,n){let r=t.state,i=t.root.activeElement;r!=e&&t.updateState(e),i!=t.dom&&t.focus();try{return n()}finally{r!=e&&t.updateState(r),i!=t.dom&&i&&i.focus()}}function wS(t,e,n){let r=e.selection,i=n=="up"?r.$from:r.$to;return qp(t,e,()=>{let{node:o}=t.docView.domFromPos(i.pos,n=="up"?-1:1);for(;;){let l=t.docView.nearestDesc(o,!0);if(!l)break;if(l.node.isBlock){o=l.contentDOM||l.dom;break}o=l.dom.parentNode}let s=Kp(t,i.pos,1);for(let l=o.firstChild;l;l=l.nextSibling){let a;if(l.nodeType==1)a=l.getClientRects();else if(l.nodeType==3)a=zt(l,0,l.nodeValue.length).getClientRects();else continue;for(let u=0;uc.top+1&&(n=="up"?s.top-c.top>(c.bottom-s.top)*2:c.bottom-s.bottom>(s.bottom-c.top)*2))return!1}}return!0})}const vS=/[\u0590-\u08ac]/;function xS(t,e,n){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let i=r.parentOffset,o=!i,s=i==r.parent.content.size,l=t.domSelection();return!vS.test(r.parent.textContent)||!l.modify?n=="left"||n=="backward"?o:s:qp(t,e,()=>{let{focusNode:a,focusOffset:u,anchorNode:c,anchorOffset:f}=t.domSelectionRange(),d=l.caretBidiLevel;l.modify("move",n,"character");let p=r.depth?t.docView.domAfterPos(r.before()):t.dom,{focusNode:h,focusOffset:m}=t.domSelectionRange(),k=h&&!p.contains(h.nodeType==1?h:h.parentNode)||a==h&&u==m;try{l.collapse(c,f),a&&(a!=c||u!=f)&&l.extend&&l.extend(a,u)}catch{}return d!=null&&(l.caretBidiLevel=d),k})}let Uf=null,jf=null,Hf=!1;function CS(t,e,n){return Uf==e&&jf==n?Hf:(Uf=e,jf=n,Hf=n=="up"||n=="down"?wS(t,e,n):xS(t,e,n))}const nt=0,Jf=1,Ln=2,Et=3;let go=class{constructor(e,n,r,i){this.parent=e,this.children=n,this.dom=r,this.contentDOM=i,this.dirty=nt,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,n,r){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let n=0;nEe(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))i=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(n==0)for(let o=e;;o=o.parentNode){if(o==this.dom){i=!1;break}if(o.previousSibling)break}if(i==null&&n==e.childNodes.length)for(let o=e;;o=o.parentNode){if(o==this.dom){i=!0;break}if(o.nextSibling)break}}return i??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,n=!1){for(let r=!0,i=e;i;i=i.parentNode){let o=this.getDesc(i),s;if(o&&(!n||o.node))if(r&&(s=o.nodeDOM)&&!(s.nodeType==1?s.contains(e.nodeType==1?e:e.parentNode):s==e))r=!1;else return o}}getDesc(e){let n=e.pmViewDesc;for(let r=n;r;r=r.parent)if(r==this)return n}posFromDOM(e,n,r){for(let i=e;i;i=i.parentNode){let o=this.getDesc(i);if(o)return o.localPosFromDOM(e,n,r)}return-1}descAt(e){for(let n=0,r=0;ne||s instanceof Zp){i=e-o;break}o=l}if(i)return this.children[r].domFromPos(i-this.children[r].border,n);for(let o;r&&!(o=this.children[r-1]).size&&o instanceof Qp&&o.side>=0;r--);if(n<=0){let o,s=!0;for(;o=r?this.children[r-1]:null,!(!o||o.dom.parentNode==this.contentDOM);r--,s=!1);return o&&n&&s&&!o.border&&!o.domAtom?o.domFromPos(o.size,n):{node:this.contentDOM,offset:o?Ee(o.dom)+1:0}}else{let o,s=!0;for(;o=r=c&&n<=u-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,n,c);e=s;for(let f=l;f>0;f--){let d=this.children[f-1];if(d.size&&d.dom.parentNode==this.contentDOM&&!d.emptyChildAt(1)){i=Ee(d.dom)+1;break}e-=d.size}i==-1&&(i=0)}if(i>-1&&(u>n||l==this.children.length-1)){n=u;for(let c=l+1;cp&&sn){let p=l;l=a,a=p}let d=document.createRange();d.setEnd(a.node,a.offset),d.setStart(l.node,l.offset),u.removeAllRanges(),u.addRange(d)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,n){for(let r=0,i=0;i=r:er){let l=r+o.border,a=s-o.border;if(e>=l&&n<=a){this.dirty=e==r||n==s?Ln:Jf,e==l&&n==a&&(o.contentLost||o.dom.parentNode!=this.contentDOM)?o.dirty=Et:o.markDirty(e-l,n-l);return}else o.dirty=o.dom==o.contentDOM&&o.dom.parentNode==this.contentDOM&&!o.children.length?Ln:Et}r=s}this.dirty=Ln}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let r=e==1?Ln:Jf;n.dirty{if(!o)return i;if(o.parent)return o.parent.posBeforeChild(o)})),!n.type.spec.raw){if(s.nodeType!=1){let l=document.createElement("span");l.appendChild(s),s=l}s.contentEditable="false",s.classList.add("ProseMirror-widget")}super(e,[],s,null),this.widget=n,this.widget=n,o=this}matchesWidget(e){return this.dirty==nt&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let n=this.widget.spec.stopEvent;return n?n(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get side(){return this.widget.type.side}},NS=class extends go{constructor(e,n,r,i){super(e,[],n,null),this.textDOM=r,this.text=i}get size(){return this.text.length}localPosFromDOM(e,n){return e!=this.textDOM?this.posAtStart+(n?this.size:0):this.posAtStart+n}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}},Ms=class Aa extends go{constructor(e,n,r,i){super(e,[],r,i),this.mark=n}static create(e,n,r,i){let o=i.nodeViews[n.type.name],s=o&&o(n,i,r);return(!s||!s.dom)&&(s=Lt.renderSpec(document,n.type.spec.toDOM(n,r))),new Aa(e,n,s.dom,s.contentDOM||s.dom)}parseRule(){return this.dirty&Et||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=Et&&this.mark.eq(e)}markDirty(e,n){if(super.markDirty(e,n),this.dirty!=nt){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty0&&(o=za(o,0,e,r));for(let l=0;l{if(!a)return s;if(a.parent)return a.parent.posBeforeChild(a)},r,i),c=u&&u.dom,f=u&&u.contentDOM;if(n.isText){if(!c)c=document.createTextNode(n.text);else if(c.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else c||({dom:c,contentDOM:f}=Lt.renderSpec(document,n.type.spec.toDOM(n)));!f&&!n.isText&&c.nodeName!="BR"&&(c.hasAttribute("contenteditable")||(c.contentEditable="false"),n.type.spec.draggable&&(c.draggable=!0));let d=c;return c=nm(c,r,n),u?a=new MS(e,n,r,i,c,f||null,d,u,o,s+1):n.isText?new Gp(e,n,r,i,c,d,o):new Yp(e,n,r,i,c,f||null,d,o,s+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(e.preserveWhitespace="full"),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let n=this.children.length-1;n>=0;n--){let r=this.children[n];if(this.dom.contains(r.dom.parentNode)){e.contentElement=r.dom.parentNode;break}}e.contentElement||(e.getContent=()=>v.empty)}return e}matchesNode(e,n,r){return this.dirty==nt&&e.eq(this.node)&&Pa(n,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,n){let r=this.node.inlineContent,i=n,o=e.composing?this.localCompositionInfo(e,n):null,s=o&&o.pos>-1?o:null,l=o&&o.pos<0,a=new OS(this,s&&s.node,e);AS(this.node,this.innerDeco,(u,c,f)=>{u.spec.marks?a.syncToMarks(u.spec.marks,r,e):u.type.side>=0&&!f&&a.syncToMarks(c==this.node.childCount?_.none:this.node.child(c).marks,r,e),a.placeWidget(u,e,i)},(u,c,f,d)=>{a.syncToMarks(u.marks,r,e);let p;a.findNodeMatch(u,c,f,d)||l&&e.state.selection.from>i&&e.state.selection.to-1&&a.updateNodeAt(u,c,f,p,e)||a.updateNextNode(u,c,f,e,d,i)||a.addNode(u,c,f,e,i),i+=u.nodeSize}),a.syncToMarks([],r,e),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==Ln)&&(s&&this.protectLocalComposition(e,s),em(this.contentDOM,this.children,e),br&&RS(this.dom))}localCompositionInfo(e,n){let{from:r,to:i}=e.state.selection;if(!(e.state.selection instanceof B)||rn+this.node.content.size)return null;let o=e.domSelectionRange(),s=PS(o.focusNode,o.focusOffset);if(!s||!this.dom.contains(s.parentNode))return null;if(this.node.inlineContent){let l=s.nodeValue,a=zS(this.node.content,l,r-n,i-n);return a<0?null:{node:s,pos:a,text:l}}else return{node:s,pos:-1,text:""}}protectLocalComposition(e,{node:n,pos:r,text:i}){if(this.getDesc(n))return;let o=n;for(;o.parentNode!=this.contentDOM;o=o.parentNode){for(;o.previousSibling;)o.parentNode.removeChild(o.previousSibling);for(;o.nextSibling;)o.parentNode.removeChild(o.nextSibling);o.pmViewDesc&&(o.pmViewDesc=void 0)}let s=new NS(this,o,n,i);e.input.compositionNodes.push(s),this.children=za(this.children,r,r+i.length,e,s)}update(e,n,r,i){return this.dirty==Et||!e.sameMarkup(this.node)?!1:(this.updateInner(e,n,r,i),!0)}updateInner(e,n,r,i){this.updateOuterDeco(n),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(i,this.posAtStart),this.dirty=nt}updateOuterDeco(e){if(Pa(e,this.outerDeco))return;let n=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=tm(this.dom,this.nodeDOM,Ra(this.outerDeco,this.node,n),Ra(e,this.node,n)),this.dom!=r&&(r.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.dom.draggable=!0)}deselectNode(){this.nodeDOM.nodeType==1&&this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.dom.removeAttribute("draggable")}get domAtom(){return this.node.isAtom}};function Kf(t,e,n,r,i){nm(r,e,t);let o=new Cr(void 0,t,e,n,r,r,r,i,0);return o.contentDOM&&o.updateChildren(i,0),o}let Gp=class Xp extends Cr{constructor(e,n,r,i,o,s,l){super(e,n,r,i,o,null,s,l,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,n,r,i){return this.dirty==Et||this.dirty!=nt&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=nt||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,i.trackWrites==this.nodeDOM&&(i.trackWrites=null)),this.node=e,this.dirty=nt,!0)}inParent(){let e=this.parent.contentDOM;for(let n=this.nodeDOM;n;n=n.parentNode)if(n==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,n,r){return e==this.nodeDOM?this.posAtStart+Math.min(n,this.node.text.length):super.localPosFromDOM(e,n,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,n,r){let i=this.node.cut(e,n),o=document.createTextNode(i.text);return new Xp(this.parent,i,this.outerDeco,this.innerDeco,o,o,r)}markDirty(e,n){super.markDirty(e,n),this.dom!=this.nodeDOM&&(e==0||n==this.nodeDOM.nodeValue.length)&&(this.dirty=Et)}get domAtom(){return!1}},Zp=class extends go{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==nt&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}};class MS extends Cr{constructor(e,n,r,i,o,s,l,a,u,c){super(e,n,r,i,o,s,l,u,c),this.spec=a}update(e,n,r,i){if(this.dirty==Et)return!1;if(this.spec.update){let o=this.spec.update(e,n,r);return o&&this.updateInner(e,n,r,i),o}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,n,r,i)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,n,r,i){this.spec.setSelection?this.spec.setSelection(e,n,r):super.setSelection(e,n,r,i)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function em(t,e,n){let r=t.firstChild,i=!1;for(let o=0;o>1,s=Math.min(o,e.length);for(;i-1)l>this.index&&(this.changed=!0,this.destroyBetween(this.index,l)),this.top=this.top.children[this.index];else{let a=Ms.create(this.top,e[o],n,r);this.top.children.splice(this.index,0,a),this.top=a,this.changed=!0}this.index=0,o++}}findNodeMatch(e,n,r,i){let o=-1,s;if(i>=this.preMatch.index&&(s=this.preMatch.matches[i-this.preMatch.index]).parent==this.top&&s.matchesNode(e,n,r))o=this.top.children.indexOf(s,this.index);else for(let l=this.index,a=Math.min(this.top.children.length,l+5);l0;){let l;for(;;)if(r){let u=n.children[r-1];if(u instanceof Ms)n=u,r=u.children.length;else{l=u,r--;break}}else{if(n==e)break e;r=n.parent.children.indexOf(n),n=n.parent}let a=l.node;if(a){if(a!=t.child(i-1))break;--i,o.set(l,i),s.push(l)}}return{index:i,matched:o,matches:s.reverse()}}function TS(t,e){return t.type.side-e.type.side}function AS(t,e,n,r){let i=e.locals(t),o=0;if(i.length==0){for(let u=0;uo;)l.push(i[s++]);let h=o+d.nodeSize;if(d.isText){let k=h;s!k.inline):l.slice();r(d,m,e.forChild(o,d),p),o=h}}function RS(t){if(t.nodeName=="UL"||t.nodeName=="OL"){let e=t.style.cssText;t.style.cssText=e+"; list-style: square !important",window.getComputedStyle(t).listStyle,t.style.cssText=e}}function PS(t,e){for(;;){if(t.nodeType==3)return t;if(t.nodeType==1&&e>0){if(t.childNodes.length>e&&t.childNodes[e].nodeType==3)return t.childNodes[e];t=t.childNodes[e-1],e=St(t)}else if(t.nodeType==1&&e=n){if(o>=r&&a.slice(r-e.length-l,r-l)==e)return r-e.length;let u=l=0&&u+e.length+l>=n)return l+u;if(n==r&&a.length>=r+e.length-l&&a.slice(r-l,r-l+e.length)==e)return r}}return-1}function za(t,e,n,r,i){let o=[];for(let s=0,l=0;s=n||c<=e?o.push(a):(un&&o.push(a.slice(n-u,a.size,r)))}return o}function sc(t,e=null){let n=t.domSelectionRange(),r=t.state.doc;if(!n.focusNode)return null;let i=t.docView.nearestDesc(n.focusNode),o=i&&i.size==0,s=t.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(s<0)return null;let l=r.resolve(s),a,u;if(il(n)){for(a=l;i&&!i.node;)i=i.parent;let c=i.node;if(i&&c.isAtom&&z.isSelectable(c)&&i.parent&&!(c.isInline&&rS(n.focusNode,n.focusOffset,i.dom))){let f=i.posBefore;u=new z(s==f?l:r.resolve(f))}}else{let c=t.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(c<0)return null;a=r.resolve(c)}if(!u){let c=e=="pointer"||t.state.selection.head{(n.anchorNode!=r||n.anchorOffset!=i)&&(e.removeEventListener("selectionchange",t.input.hideSelectionGuard),setTimeout(()=>{(!rm(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function IS(t){let e=t.domSelection(),n=document.createRange(),r=t.cursorWrapper.dom,i=r.nodeName=="IMG";i?n.setEnd(r.parentNode,Ee(r)+1):n.setEnd(r,0),n.collapse(!1),e.removeAllRanges(),e.addRange(n),!i&&!t.state.selection.visible&&Be&&fn<=11&&(r.disabled=!0,r.disabled=!1)}function im(t,e){if(e instanceof z){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(Xf(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else Xf(t)}function Xf(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function lc(t,e,n,r){return t.someProp("createSelectionBetween",i=>i(t,e,n))||B.between(e,n,r)}function Zf(t){return t.editable&&!t.hasFocus()?!1:om(t)}function om(t){let e=t.domSelectionRange();if(!e.anchorNode)return!1;try{return t.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(t.editable||t.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function bS(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return Qn(e.node,e.offset,n.anchorNode,n.anchorOffset)}function Fa(t,e){let{$anchor:n,$head:r}=t.selection,i=e>0?n.max(r):n.min(r),o=i.parent.inlineContent?i.depth?t.doc.resolve(e>0?i.after():i.before()):null:i;return o&&I.findFrom(o,e)}function Gt(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function ed(t,e,n){let r=t.state.selection;if(r instanceof B)if(n.indexOf("s")>-1){let{$head:i}=r,o=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter;if(!o||o.isText||!o.isLeaf)return!1;let s=t.state.doc.resolve(i.pos+o.nodeSize*(e<0?-1:1));return Gt(t,new B(r.$anchor,s))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let i=Fa(t.state,e);return i&&i instanceof z?Gt(t,i):!1}else if(!(Ge&&n.indexOf("m")>-1)){let i=r.$head,o=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter,s;if(!o||o.isText)return!1;let l=e<0?i.pos-o.nodeSize:i.pos;return o.isAtom||(s=t.docView.descAt(l))&&!s.contentDOM?z.isSelectable(o)?Gt(t,new z(e<0?t.state.doc.resolve(i.pos-o.nodeSize):i)):mo?Gt(t,new B(t.state.doc.resolve(e<0?l:l+o.nodeSize))):!1:!1}}else return!1;else{if(r instanceof z&&r.node.isInline)return Gt(t,new B(e>0?r.$to:r.$from));{let i=Fa(t.state,e);return i?Gt(t,i):!1}}}function Es(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function Ci(t,e){let n=t.pmViewDesc;return n&&n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function or(t,e){return e<0?LS(t):BS(t)}function LS(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i,o,s=!1;for(pt&&n.nodeType==1&&r0){if(n.nodeType!=1)break;{let l=n.childNodes[r-1];if(Ci(l,-1))i=n,o=--r;else if(l.nodeType==3)n=l,r=n.nodeValue.length;else break}}else{if(sm(n))break;{let l=n.previousSibling;for(;l&&Ci(l,-1);)i=n.parentNode,o=Ee(l),l=l.previousSibling;if(l)n=l,r=Es(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}s?Ia(t,n,r):i&&Ia(t,i,o)}function BS(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i=Es(n),o,s;for(;;)if(r{t.state==i&&$t(t)},50)}function td(t,e){let n=t.state.doc.resolve(e);if(!(xe||lS)&&n.parent.inlineContent){let i=t.coordsAtPos(e);if(e>n.start()){let o=t.coordsAtPos(e-1),s=(o.top+o.bottom)/2;if(s>i.top&&s1)return o.lefti.top&&s1)return o.left>i.left?"ltr":"rtl"}}return getComputedStyle(t.dom).direction=="rtl"?"rtl":"ltr"}function nd(t,e,n){let r=t.state.selection;if(r instanceof B&&!r.empty||n.indexOf("s")>-1||Ge&&n.indexOf("m")>-1)return!1;let{$from:i,$to:o}=r;if(!i.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let s=Fa(t.state,e);if(s&&s instanceof z)return Gt(t,s)}if(!i.parent.inlineContent){let s=e<0?i:o,l=r instanceof Je?I.near(s,e):I.findFrom(s,e);return l?Gt(t,l):!1}return!1}function rd(t,e){if(!(t.state.selection instanceof B))return!0;let{$head:n,$anchor:r,empty:i}=t.state.selection;if(!n.sameParent(r))return!0;if(!i)return!1;if(t.endOfTextblock(e>0?"forward":"backward"))return!0;let o=!n.textOffset&&(e<0?n.nodeBefore:n.nodeAfter);if(o&&!o.isText){let s=t.state.tr;return e<0?s.delete(n.pos-o.nodeSize,n.pos):s.delete(n.pos,n.pos+o.nodeSize),t.dispatch(s),!0}return!1}function id(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function _S(t){if(!Te||t.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(e&&e.nodeType==1&&n==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let r=e.firstChild;id(t,r,"true"),setTimeout(()=>id(t,r,"false"),20)}return!1}function WS(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function US(t,e){let n=e.keyCode,r=WS(e);if(n==8||Ge&&n==72&&r=="c")return rd(t,-1)||or(t,-1);if(n==46&&!e.shiftKey||Ge&&n==68&&r=="c")return rd(t,1)||or(t,1);if(n==13||n==27)return!0;if(n==37||Ge&&n==66&&r=="c"){let i=n==37?td(t,t.state.selection.from)=="ltr"?-1:1:-1;return ed(t,i,r)||or(t,i)}else if(n==39||Ge&&n==70&&r=="c"){let i=n==39?td(t,t.state.selection.from)=="ltr"?1:-1:1;return ed(t,i,r)||or(t,i)}else{if(n==38||Ge&&n==80&&r=="c")return nd(t,-1,r)||or(t,-1);if(n==40||Ge&&n==78&&r=="c")return _S(t)||nd(t,1,r)||or(t,1);if(r==(Ge?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function lm(t,e){t.someProp("transformCopied",p=>{e=p(e,t)});let n=[],{content:r,openStart:i,openEnd:o}=e;for(;i>1&&o>1&&r.childCount==1&&r.firstChild.childCount==1;){i--,o--;let p=r.firstChild;n.push(p.type.name,p.attrs!=p.type.defaultAttrs?p.attrs:null),r=p.content}let s=t.someProp("clipboardSerializer")||Lt.fromSchema(t.state.schema),l=hm(),a=l.createElement("div");a.appendChild(s.serializeFragment(r,{document:l}));let u=a.firstChild,c,f=0;for(;u&&u.nodeType==1&&(c=dm[u.nodeName.toLowerCase()]);){for(let p=c.length-1;p>=0;p--){let h=l.createElement(c[p]);for(;a.firstChild;)h.appendChild(a.firstChild);a.appendChild(h),f++}u=a.firstChild}u&&u.nodeType==1&&u.setAttribute("data-pm-slice",`${i} ${o}${f?` -${f}`:""} ${JSON.stringify(n)}`);let d=t.someProp("clipboardTextSerializer",p=>p(e,t))||e.content.textBetween(0,e.content.size,` +`))}ignoreFallback(e){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"))}readStyles(e){let n=_.none,r=_.none;for(let i=0;i{s.clearMark(l)&&(r=l.addToSet(r))}):n=this.parser.schema.marks[s.mark].create(s.attrs).addToSet(n),s.consuming===!1)o=s;else break}return[n,r]}addElementByRule(e,n,r){let i,o,s;n.node?(o=this.parser.schema.nodes[n.node],o.isLeaf?this.insertNode(o.create(n.attrs))||this.leafFallback(e):i=this.enter(o,n.attrs||null,n.preserveWhitespace)):(s=this.parser.schema.marks[n.mark].create(n.attrs),this.addPendingMark(s));let l=this.top;if(o&&o.isLeaf)this.findInside(e);else if(r)this.addElement(e,r);else if(n.getContent)this.findInside(e),n.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a));else{let a=e;typeof n.contentElement=="string"?a=e.querySelector(n.contentElement):typeof n.contentElement=="function"?a=n.contentElement(e):n.contentElement&&(a=n.contentElement),this.findAround(e,a,!0),this.addAll(a)}i&&this.sync(l)&&this.open--,s&&this.removePendingMark(s,l)}addAll(e,n,r){let i=n||0;for(let o=n?e.childNodes[n]:e.firstChild,s=r==null?null:e.childNodes[r];o!=s;o=o.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(o);this.findAtPoint(e,i)}findPlace(e){let n,r;for(let i=this.open;i>=0;i--){let o=this.nodes[i],s=o.findWrapping(e);if(s&&(!n||n.length>s.length)&&(n=s,r=o,!s.length)||o.solid)break}if(!n)return!1;this.sync(r);for(let i=0;ithis.open){for(;n>this.open;n--)this.nodes[n-1].content.push(this.nodes[n].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 n=this.open;n>=0;n--)if(this.nodes[n]==e)return this.open=n,!0;return!1}get currentPos(){this.closeExtra();let e=0;for(let n=this.open;n>=0;n--){let r=this.nodes[n].content;for(let i=r.length-1;i>=0;i--)e+=r[i].nodeSize;n&&e++}return e}findAtPoint(e,n){if(this.find)for(let r=0;r-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let n=e.split("/"),r=this.options.context,i=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),o=-(r?r.depth+1:0)+(i?0:1),s=(l,a)=>{for(;l>=0;l--){let u=n[l];if(u==""){if(l==n.length-1||l==0)continue;for(;a>=o;a--)if(s(l-1,a))return!0;return!1}else{let c=a>0||a==0&&i?this.nodes[a].type:r&&a>=o?r.node(a-o).type:null;if(!c||c.name!=u&&c.groups.indexOf(u)==-1)return!1;a--}}return!0};return s(n.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let n=e.depth;n>=0;n--){let r=e.node(n).contentMatchAt(e.indexAfter(n)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let n in this.parser.schema.nodes){let r=this.parser.schema.nodes[n];if(r.isTextblock&&r.defaultAttrs)return r}}addPendingMark(e){let n=e1(e,this.top.pendingMarks);n&&this.top.stashMarks.push(n),this.top.pendingMarks=e.addToSet(this.top.pendingMarks)}removePendingMark(e,n){for(let r=this.open;r>=0;r--){let i=this.nodes[r];if(i.pendingMarks.lastIndexOf(e)>-1)i.pendingMarks=e.removeFromSet(i.pendingMarks);else{i.activeMarks=e.removeFromSet(i.activeMarks);let s=i.popFromStashMark(e);s&&i.type&&i.type.allowsMarkType(s.type)&&(i.activeMarks=s.addToSet(i.activeMarks))}if(i==n)break}}}function Yy(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&wp.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function Gy(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function Xy(t){let e=/\s*([\w-]+)\s*:\s*([^;]+)/g,n,r=[];for(;n=e.exec(t);)r.push(n[1],n[2].trim());return r}function Mf(t){let e={};for(let n in t)e[n]=t[n];return e}function Zy(t,e){let n=e.schema.nodes;for(let r in n){let i=n[r];if(!i.allowsMarkType(t))continue;let o=[],s=l=>{o.push(l);for(let a=0;a{if(o.length||s.marks.length){let l=0,a=0;for(;l=0;i--){let o=this.serializeMark(e.marks[i],e.isInline,n);o&&((o.contentDOM||o.dom).appendChild(r),r=o.dom)}return r}serializeMark(e,n,r={}){let i=this.marks[e.type.name];return i&&Lt.renderSpec(Al(r),i(e,n))}static renderSpec(e,n,r=null){if(typeof n=="string")return{dom:e.createTextNode(n)};if(n.nodeType!=null)return{dom:n};if(n.dom&&n.dom.nodeType!=null)return n;let i=n[0],o=i.indexOf(" ");o>0&&(r=i.slice(0,o),i=i.slice(o+1));let s,l=r?e.createElementNS(r,i):e.createElement(i),a=n[1],u=1;if(a&&typeof a=="object"&&a.nodeType==null&&!Array.isArray(a)){u=2;for(let c in a)if(a[c]!=null){let f=c.indexOf(" ");f>0?l.setAttributeNS(c.slice(0,f),c.slice(f+1),a[c]):l.setAttribute(c,a[c])}}for(let c=u;cu)throw new RangeError("Content hole must be the only child of its parent node");return{dom:l,contentDOM:l}}else{let{dom:d,contentDOM:p}=Lt.renderSpec(e,f,r);if(l.appendChild(d),p){if(s)throw new RangeError("Multiple content holes");s=p}}}return{dom:l,contentDOM:s}}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new Lt(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=Ef(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return Ef(e.marks)}}function Ef(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function Al(t){return t.document||window.document}const vp=65535,xp=Math.pow(2,16);function t1(t,e){return t+e*xp}function Of(t){return t&vp}function n1(t){return(t-(t&vp))/xp}const Cp=1,Np=2,es=4,Mp=8;let Na=class{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&Mp)>0}get deletedBefore(){return(this.delInfo&(Cp|es))>0}get deletedAfter(){return(this.delInfo&(Np|es))>0}get deletedAcross(){return(this.delInfo&es)>0}},zr=class lr{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&lr.empty)return lr.empty}recover(e){let n=0,r=Of(e);if(!this.inverted)for(let i=0;ie)break;let u=this.ranges[l+o],c=this.ranges[l+s],f=a+u;if(e<=f){let d=u?e==a?-1:e==f?1:n:n,p=a+i+(d<0?0:c);if(r)return p;let h=e==(n<0?a:f)?null:t1(l/3,e-a),m=e==a?Np:e==f?Cp:es;return(n<0?e!=a:e!=f)&&(m|=Mp),new Na(p,m,h)}i+=c-u}return r?e+i:new Na(e+i,0,null)}touches(e,n){let r=0,i=Of(n),o=this.inverted?2:1,s=this.inverted?1:2;for(let l=0;le)break;let u=this.ranges[l+o],c=a+u;if(e<=c&&l==i*3)return!0;r+=this.ranges[l+s]-u}return!1}forEach(e){let n=this.inverted?2:1,r=this.inverted?1:2;for(let i=0,o=0;i=0;n--){let i=e.getMirror(n);this.appendMap(e.maps[n].invert(),i!=null&&i>n?r-i-1:void 0)}}invert(){let e=new ts;return e.appendMappingInverted(this),e}map(e,n=1){if(this.mirror)return this._map(e,n,!0);for(let r=this.from;ro&&a!s.isAtom||!l.type.allowsMarkType(this.mark.type)?s:s.mark(this.mark.addToSet(s.marks)),i),n.openStart,n.openEnd);return Ie.fromReplace(e,this.from,this.to,o)}invert(){return new ho(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new ai(n.pos,r.pos,this.mark)}merge(e){return e instanceof ai&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new ai(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,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new ai(n.from,n.to,e.markFromJSON(n.mark))}};We.jsonID("addMark",Qu);let ho=class ui extends We{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=new x(qu(n.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),n.openStart,n.openEnd);return Ie.fromReplace(e,this.from,this.to,r)}invert(){return new Qu(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new ui(n.pos,r.pos,this.mark)}merge(e){return e instanceof ui&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new ui(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,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new ui(n.from,n.to,e.markFromJSON(n.mark))}};We.jsonID("removeMark",ho);let Yu=class ci extends We{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return Ie.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return Ie.fromReplace(e,this.pos,this.pos+1,new x(v.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);if(n){let r=this.mark.addToSet(n.marks);if(r.length==n.marks.length){for(let i=0;ir.pos?null:new ns(n.pos,r.pos,i,o,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number"||typeof n.gapFrom!="number"||typeof n.gapTo!="number"||typeof n.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new ns(n.from,n.to,n.gapFrom,n.gapTo,x.fromJSON(e,n.slice),n.insert,!!n.structure)}};We.jsonID("replaceAround",Wt);function Ea(t,e,n){let r=t.resolve(e),i=n-e,o=r.depth;for(;i>0&&o>0&&r.indexAfter(o)==r.node(o).childCount;)o--,i--;if(i>0){let s=r.node(o).maybeChild(r.indexAfter(o));for(;i>0;){if(!s||s.isLeaf)return!0;s=s.firstChild,i--}}return!1}function i1(t,e,n,r){let i=[],o=[],s,l;t.doc.nodesBetween(e,n,(a,u,c)=>{if(!a.isInline)return;let f=a.marks;if(!r.isInSet(f)&&c.type.allowsMarkType(r.type)){let d=Math.max(u,e),p=Math.min(u+a.nodeSize,n),h=r.addToSet(f);for(let m=0;mt.step(a)),o.forEach(a=>t.step(a))}function o1(t,e,n,r){let i=[],o=0;t.doc.nodesBetween(e,n,(s,l)=>{if(!s.isInline)return;o++;let a=null;if(r instanceof fo){let u=s.marks,c;for(;c=r.isInSet(u);)(a||(a=[])).push(c),u=c.removeFromSet(u)}else r?r.isInSet(s.marks)&&(a=[r]):a=s.marks;if(a&&a.length){let u=Math.min(l+s.nodeSize,n);for(let c=0;ct.step(new ho(s.from,s.to,s.style)))}function s1(t,e,n,r=n.contentMatch){let i=t.doc.nodeAt(e),o=[],s=e+1;for(let l=0;l=0;l--)t.step(o[l])}function l1(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function Xu(t){let n=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let r=t.depth;;--r){let i=t.$from.node(r),o=t.$from.index(r),s=t.$to.indexAfter(r);if(rn;h--)m||r.index(h)>0?(m=!0,c=v.from(r.node(h).copy(c)),f++):a--;let d=v.empty,p=0;for(let h=o,m=!1;h>n;h--)m||i.after(h+1)=0;s--){if(r.size){let l=n[s].type.contentMatch.matchFragment(r);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=v.from(n[s].type.create(n[s].attrs,r))}let i=e.start,o=e.end;t.step(new Wt(i,o,i,o,new x(r,0,0),n.length,!0))}function h1(t,e,n,r,i){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let o=t.steps.length;t.doc.nodesBetween(e,n,(s,l)=>{if(s.isTextblock&&!s.hasMarkup(r,i)&&p1(t.doc,t.mapping.slice(o).map(l),r)){t.clearIncompatible(t.mapping.slice(o).map(l,1),r);let a=t.mapping.slice(o),u=a.map(l,1),c=a.map(l+s.nodeSize,1);return t.step(new Wt(u,c,u+1,c-1,new x(v.from(r.create(i,null,s.marks)),0,0),1,!0)),!1}})}function p1(t,e,n){let r=t.resolve(e),i=r.index();return r.parent.canReplaceWith(i,i+1,n)}function m1(t,e,n,r,i){let o=t.doc.nodeAt(e);if(!o)throw new RangeError("No node at given position");n||(n=o.type);let s=n.create(r,null,i||o.marks);if(o.isLeaf)return t.replaceWith(e,e+o.nodeSize,s);if(!n.validContent(o.content))throw new RangeError("Invalid content for node type "+n.name);t.step(new Wt(e,e+o.nodeSize,e+1,e+o.nodeSize-1,new x(v.from(s),0,0),1,!0))}function rs(t,e,n=1,r){let i=t.resolve(e),o=i.depth-n,s=r&&r[r.length-1]||i.parent;if(o<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!s.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let u=i.depth-1,c=n-2;u>o;u--,c--){let f=i.node(u),d=i.index(u);if(f.type.spec.isolating)return!1;let p=f.content.cutByIndex(d,f.childCount),h=r&&r[c]||f;if(h!=f&&(p=p.replaceChild(0,h.type.create(h.attrs))),!f.canReplace(d+1,f.childCount)||!h.type.validContent(p))return!1}let l=i.indexAfter(o),a=r&&r[0];return i.node(o).canReplaceWith(l,l,a?a.type:i.node(o+1).type)}function g1(t,e,n=1,r){let i=t.doc.resolve(e),o=v.empty,s=v.empty;for(let l=i.depth,a=i.depth-n,u=n-1;l>a;l--,u--){o=v.from(i.node(l).copy(o));let c=r&&r[u];s=v.from(c?c.type.create(c.attrs,s):i.node(l).copy(s))}t.step(new Cn(e,e,new x(o.append(s),n,n),!0))}function Zu(t,e){let n=t.resolve(e),r=n.index();return y1(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function y1(t,e){return!!(t&&e&&!t.isLeaf&&t.canAppend(e))}function S1(t,e,n){let r=new Cn(e-n,e+n,x.empty,!0);t.step(r)}function k1(t,e,n){let r=t.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),n))return e;if(r.parentOffset==0)for(let i=r.depth-1;i>=0;i--){let o=r.index(i);if(r.node(i).canReplaceWith(o,o,n))return r.before(i+1);if(o>0)return null}if(r.parentOffset==r.parent.content.size)for(let i=r.depth-1;i>=0;i--){let o=r.indexAfter(i);if(r.node(i).canReplaceWith(o,o,n))return r.after(i+1);if(o=0;s--){let l=s==r.depth?0:r.pos<=(r.start(s+1)+r.end(s+1))/2?-1:1,a=r.index(s)+(l>0?1:0),u=r.node(s),c=!1;if(o==1)c=u.canReplace(a,a,i);else{let f=u.contentMatchAt(a).findWrapping(i.firstChild.type);c=f&&u.canReplaceWith(a,a,f[0])}if(c)return l==0?r.pos:l<0?r.before(s+1):r.after(s+1)}return null}function ec(t,e,n=e,r=x.empty){if(e==n&&!r.size)return null;let i=t.resolve(e),o=t.resolve(n);return Ep(i,o,r)?new Cn(e,n,r):new v1(i,o,r).fit()}function Ep(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}let v1=class{constructor(e,n,r){this.$from=e,this.$to=n,this.unplaced=r,this.frontier=[],this.placed=v.empty;for(let i=0;i<=e.depth;i++){let o=e.node(i);this.frontier.push({type:o.type,match:o.contentMatchAt(e.indexAfter(i))})}for(let i=e.depth;i>0;i--)this.placed=v.from(e.node(i).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let u=this.findFittable();u?this.placeNodes(u):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),n=this.placed.size-this.depth-this.$from.depth,r=this.$from,i=this.close(e<0?this.$to:r.doc.resolve(e));if(!i)return null;let o=this.placed,s=r.depth,l=i.depth;for(;s&&l&&o.childCount==1;)o=o.firstChild.content,s--,l--;let a=new x(o,s,l);return e>-1?new Wt(r.pos,e,this.$to.pos,this.$to.end(),a,n):a.size||r.pos!=this.$to.pos?new Cn(r.pos,i.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let n=this.unplaced.content,r=0,i=this.unplaced.openEnd;r1&&(i=0),o.type.spec.isolating&&i<=r){e=r;break}n=o.content}for(let n=1;n<=2;n++)for(let r=n==1?e:this.unplaced.openStart;r>=0;r--){let i,o=null;r?(o=Pl(this.unplaced.content,r-1).firstChild,i=o.content):i=this.unplaced.content;let s=i.firstChild;for(let l=this.depth;l>=0;l--){let{type:a,match:u}=this.frontier[l],c,f=null;if(n==1&&(s?u.matchType(s.type)||(f=u.fillBefore(v.from(s),!1)):o&&a.compatibleContent(o.type)))return{sliceDepth:r,frontierDepth:l,parent:o,inject:f};if(n==2&&s&&(c=u.findWrapping(s.type)))return{sliceDepth:r,frontierDepth:l,parent:o,wrap:c};if(o&&u.matchType(o.type))break}}}openMore(){let{content:e,openStart:n,openEnd:r}=this.unplaced,i=Pl(e,n);return!i.childCount||i.firstChild.isLeaf?!1:(this.unplaced=new x(e,n+1,Math.max(r,i.size+n>=e.size-r?n+1:0)),!0)}dropNode(){let{content:e,openStart:n,openEnd:r}=this.unplaced,i=Pl(e,n);if(i.childCount<=1&&n>0){let o=e.size-n<=n+i.size;this.unplaced=new x(fi(e,n-1,1),n-1,o?n-1:r)}else this.unplaced=new x(fi(e,n,1),n,r)}placeNodes({sliceDepth:e,frontierDepth:n,parent:r,inject:i,wrap:o}){for(;this.depth>n;)this.closeFrontierNode();if(o)for(let m=0;m1||a==0||m.content.size)&&(f=k,c.push(Op(m.mark(d.allowedMarks(m.marks)),u==1?a:0,u==l.childCount?p:-1)))}let h=u==l.childCount;h||(p=-1),this.placed=di(this.placed,n,v.from(c)),this.frontier[n].match=f,h&&p<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let m=0,k=l;m1&&i==this.$to.end(--r);)++i;return i}findCloseLevel(e){e:for(let n=Math.min(this.depth,e.depth);n>=0;n--){let{match:r,type:i}=this.frontier[n],o=n=0;l--){let{match:a,type:u}=this.frontier[l],c=zl(e,l,u,a,!0);if(!c||c.childCount)continue e}return{depth:n,fit:s,move:o?e.doc.resolve(e.after(n+1)):e}}}}close(e){let n=this.findCloseLevel(e);if(!n)return null;for(;this.depth>n.depth;)this.closeFrontierNode();n.fit.childCount&&(this.placed=di(this.placed,n.depth,n.fit)),e=n.move;for(let r=n.depth+1;r<=e.depth;r++){let i=e.node(r),o=i.type.contentMatch.fillBefore(i.content,!0,e.index(r));this.openFrontierNode(i.type,i.attrs,o)}return e}openFrontierNode(e,n=null,r){let i=this.frontier[this.depth];i.match=i.match.matchType(e),this.placed=di(this.placed,this.depth,v.from(e.create(n,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(v.empty,!0);n.childCount&&(this.placed=di(this.placed,this.frontier.length,n))}};function fi(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(fi(t.firstChild.content,e-1,n)))}function di(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(di(t.lastChild.content,e-1,n)))}function Pl(t,e){for(let n=0;n1&&(r=r.replaceChild(0,Op(r.firstChild,e-1,r.childCount==1?n-1:0))),e>0&&(r=t.type.contentMatch.fillBefore(r).append(r),n<=0&&(r=r.append(t.type.contentMatch.matchFragment(r).fillBefore(v.empty,!0)))),t.copy(r)}function zl(t,e,n,r,i){let o=t.node(e),s=i?t.indexAfter(e):t.index(e);if(s==o.childCount&&!n.compatibleContent(o.type))return null;let l=r.fillBefore(o.content,!0,s);return l&&!x1(n,o.content,s)?l:null}function x1(t,e,n){for(let r=n;r0;d--,p--){let h=i.node(d).type.spec;if(h.defining||h.definingAsContext||h.isolating)break;s.indexOf(d)>-1?l=d:i.before(d)==p&&s.splice(1,0,-d)}let a=s.indexOf(l),u=[],c=r.openStart;for(let d=r.content,p=0;;p++){let h=d.firstChild;if(u.push(h),p==r.openStart)break;d=h.content}for(let d=c-1;d>=0;d--){let p=u[d].type,h=C1(p);if(h&&i.node(a).type!=p)c=d;else if(h||!p.isTextblock)break}for(let d=r.openStart;d>=0;d--){let p=(d+c+1)%(r.openStart+1),h=u[p];if(h)for(let m=0;m=0&&(t.replace(e,n,r),!(t.steps.length>f));d--){let p=s[d];p<0||(e=i.before(p),n=o.after(p))}}function Dp(t,e,n,r,i){if(er){let o=i.contentMatchAt(0),s=o.fillBefore(t).append(t);t=s.append(o.matchFragment(s).fillBefore(v.empty,!0))}return t}function M1(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let i=k1(t.doc,e,r.type);i!=null&&(e=n=i)}t.replaceRange(e,n,new x(v.from(r),0,0))}function E1(t,e,n){let r=t.doc.resolve(e),i=t.doc.resolve(n),o=Tp(r,i);for(let s=0;s0&&(a||r.node(l-1).canReplace(r.index(l-1),i.indexAfter(l-1))))return t.delete(r.before(l),i.after(l))}for(let s=1;s<=r.depth&&s<=i.depth;s++)if(e-r.start(s)==r.depth-s&&n>r.end(s)&&i.end(s)-n!=i.depth-s)return t.delete(r.before(s),n);t.delete(e,n)}function Tp(t,e){let n=[],r=Math.min(t.depth,e.depth);for(let i=r;i>=0;i--){let o=t.start(i);if(oe.pos+(e.depth-i)||t.node(i).type.spec.isolating||e.node(i).type.spec.isolating)break;(o==e.start(i)||i==t.depth&&i==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&i&&e.start(i-1)==o-1)&&n.push(i)}return n}let Ap=class is extends We{constructor(e,n,r){super(),this.pos=e,this.attr=n,this.value=r}apply(e){let n=e.nodeAt(this.pos);if(!n)return Ie.fail("No node at attribute step's position");let r=Object.create(null);for(let o in n.attrs)r[o]=n.attrs[o];r[this.attr]=this.value;let i=n.type.create(r,null,n.marks);return Ie.fromReplace(e,this.pos,this.pos+1,new x(v.from(i),0,n.isLeaf?0:1))}getMap(){return zr.empty}invert(e){return new is(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new is(n.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.pos!="number"||typeof n.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new is(n.pos,n.attr,n.value)}};We.jsonID("attr",Ap);let Fr=class extends Error{};Fr=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};Fr.prototype=Object.create(Error.prototype);Fr.prototype.constructor=Fr;Fr.prototype.name="TransformError";let O1=class{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new r1}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new Fr(n.failed);return this}maybeStep(e){let n=e.apply(this.doc);return n.failed||this.addStep(e,n.doc),n}get docChanged(){return this.steps.length>0}addStep(e,n){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=n}replace(e,n=e,r=x.empty){let i=ec(this.doc,e,n,r);return i&&this.step(i),this}replaceWith(e,n,r){return this.replace(e,n,new x(v.from(r),0,0))}delete(e,n){return this.replace(e,n,x.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,r){return N1(this,e,n,r),this}replaceRangeWith(e,n,r){return M1(this,e,n,r),this}deleteRange(e,n){return E1(this,e,n),this}lift(e,n){return a1(this,e,n),this}join(e,n=1){return S1(this,e,n),this}wrap(e,n){return d1(this,e,n),this}setBlockType(e,n=e,r,i=null){return h1(this,e,n,r,i),this}setNodeMarkup(e,n,r=null,i){return m1(this,e,n,r,i),this}setNodeAttribute(e,n,r){return this.step(new Ap(e,n,r)),this}addNodeMark(e,n){return this.step(new Yu(e,n)),this}removeNodeMark(e,n){if(!(n instanceof _)){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(n=n.isInSet(r.marks),!n)return this}return this.step(new Gu(e,n)),this}split(e,n=1,r){return g1(this,e,n,r),this}addMark(e,n,r){return i1(this,e,n,r),this}removeMark(e,n,r){return o1(this,e,n,r),this}clearIncompatible(e,n,r){return s1(this,e,n,r),this}};const Fl=Object.create(null);class I{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new Rp(e.min(n),e.max(n))]}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 n=0;n=0;o--){let s=n<0?ar(e.node(0),e.node(o),e.before(o+1),e.index(o),n,r):ar(e.node(0),e.node(o),e.after(o+1),e.index(o)+1,n,r);if(s)return s}return null}static near(e,n=1){return this.findFrom(e,n)||this.findFrom(e,-n)||new Je(e.node(0))}static atStart(e){return ar(e,e,0,0,1)||new Je(e)}static atEnd(e){return ar(e,e,e.content.size,e.childCount,-1)||new Je(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=Fl[n.type];if(!r)throw new RangeError(`No selection type ${n.type} defined`);return r.fromJSON(e,n)}static jsonID(e,n){if(e in Fl)throw new RangeError("Duplicate use of selection JSON ID "+e);return Fl[e]=n,n.prototype.jsonID=e,n}getBookmark(){return B.between(this.$anchor,this.$head).getBookmark()}}I.prototype.visible=!0;class Rp{constructor(e,n){this.$from=e,this.$to=n}}let Tf=!1;function Af(t){!Tf&&!t.parent.inlineContent&&(Tf=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class B extends I{constructor(e,n=e){Af(e),Af(n),super(e,n)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,n){let r=e.resolve(n.map(this.head));if(!r.parent.inlineContent)return I.near(r);let i=e.resolve(n.map(this.anchor));return new B(i.parent.inlineContent?i:r,r)}replace(e,n=x.empty){if(super.replace(e,n),n==x.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof B&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new rl(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,n){if(typeof n.anchor!="number"||typeof n.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new B(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){let i=e.resolve(n);return new this(i,r==n?i:e.resolve(r))}static between(e,n,r){let i=e.pos-n.pos;if((!r||i)&&(r=i>=0?1:-1),!n.parent.inlineContent){let o=I.findFrom(n,r,!0)||I.findFrom(n,-r,!0);if(o)n=o.$head;else return I.near(n,r)}return e.parent.inlineContent||(i==0?e=n:(e=(I.findFrom(e,-r,!0)||I.findFrom(e,r,!0)).$anchor,e.pos0?0:1);i>0?s=0;s+=i){let l=e.child(s);if(l.isAtom){if(!o&&z.isSelectable(l))return z.create(t,n-(i<0?l.nodeSize:0))}else{let a=ar(t,l,n+i,i<0?l.childCount:0,i,o);if(a)return a}n+=l.nodeSize*i}return null}function Rf(t,e,n){let r=t.steps.length-1;if(r{s==null&&(s=c)}),t.setSelection(I.near(t.doc.resolve(s),n))}const Pf=1,To=2,zf=4;class T1 extends O1{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor0}setStoredMarks(e){return this.storedMarks=e,this.updated|=To,this}ensureMarks(e){return _.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&To)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~To,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,n=!0){let r=this.selection;return n&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||_.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,n,r){let i=this.doc.type.schema;if(n==null)return e?this.replaceSelectionWith(i.text(e),!0):this.deleteSelection();{if(r==null&&(r=n),r=r??n,!e)return this.deleteRange(n,r);let o=this.storedMarks;if(!o){let s=this.doc.resolve(n);o=r==n?s.marks():s.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(n,r,i.text(e,o)),this.selection.empty||this.setSelection(I.near(this.selection.$to)),this}}setMeta(e,n){return this.meta[typeof e=="string"?e:e.key]=n,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=zf,this}get scrolledIntoView(){return(this.updated&zf)>0}}function Ff(t,e){return!e||!t?t:t.bind(e)}class hi{constructor(e,n,r){this.name=e,this.init=Ff(n.init,r),this.apply=Ff(n.apply,r)}}const A1=[new hi("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new hi("selection",{init(t,e){return t.selection||I.atStart(e.doc)},apply(t){return t.selection}}),new hi("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new hi("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class Il{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=A1.slice(),n&&n.forEach(r=>{if(this.pluginsByKey[r.key])throw new RangeError("Adding different instances of a keyed plugin ("+r.key+")");this.plugins.push(r),this.pluginsByKey[r.key]=r,r.spec.state&&this.fields.push(new hi(r.key,r.spec.state,r))})}}class on{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,n=-1){for(let r=0;rr.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let i=e[r],o=i.spec.state;o&&o.toJSON&&(n[r]=o.toJSON.call(i,this[i.key]))}return n}static fromJSON(e,n,r){if(!n)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let i=new Il(e.schema,e.plugins),o=new on(i);return i.fields.forEach(s=>{if(s.name=="doc")o.doc=xt.fromJSON(e.schema,n.doc);else if(s.name=="selection")o.selection=I.fromJSON(o.doc,n.selection);else if(s.name=="storedMarks")n.storedMarks&&(o.storedMarks=n.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let l in r){let a=r[l],u=a.spec.state;if(a.key==s.name&&u&&u.fromJSON&&Object.prototype.hasOwnProperty.call(n,l)){o[s.name]=u.fromJSON.call(a,e,n[l],o);return}}o[s.name]=s.init(e,o)}}),o}}function Pp(t,e,n){for(let r in t){let i=t[r];i instanceof Function?i=i.bind(e):r=="handleDOMEvents"&&(i=Pp(i,e,{})),n[r]=i}return n}class At{constructor(e){this.spec=e,this.props={},e.props&&Pp(e.props,this,this.props),this.key=e.key?e.key.key:zp("plugin")}getState(e){return e[this.key]}}const bl=Object.create(null);function zp(t){return t in bl?t+"$"+ ++bl[t]:(bl[t]=0,t+"$")}class po{constructor(e="key"){this.key=zp(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const Fp=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function R1(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}const P1=(t,e,n)=>{let r=R1(t,n);if(!r)return!1;let i=Ip(r);if(!i){let s=r.blockRange(),l=s&&Xu(s);return l==null?!1:(e&&e(t.tr.lift(s,l).scrollIntoView()),!0)}let o=i.nodeBefore;if(!o.type.spec.isolating&&Lp(t,i,e))return!0;if(r.parent.content.size==0&&(Ir(o,"end")||z.isSelectable(o))){let s=ec(t.doc,r.before(),r.after(),x.empty);if(s&&s.slice.size{let{$head:r,empty:i}=t.selection,o=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("backward",t):r.parentOffset>0)return!1;o=Ip(r)}let s=o&&o.nodeBefore;return!s||!z.isSelectable(s)?!1:(e&&e(t.tr.setSelection(z.create(t.doc,o.pos-s.nodeSize)).scrollIntoView()),!0)};function Ip(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){if(t.index(e)>0)return t.doc.resolve(t.before(e+1));if(t.node(e).type.spec.isolating)break}return null}function F1(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset{let r=F1(t,n);if(!r)return!1;let i=bp(r);if(!i)return!1;let o=i.nodeAfter;if(Lp(t,i,e))return!0;if(r.parent.content.size==0&&(Ir(o,"start")||z.isSelectable(o))){let s=ec(t.doc,r.before(),r.after(),x.empty);if(s&&s.slice.size{let{$head:r,empty:i}=t.selection,o=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("forward",t):r.parentOffset=0;e--){let n=t.node(e);if(t.index(e)+1{let{$head:n,$anchor:r}=t.selection;return!n.parent.type.spec.code||!n.sameParent(r)?!1:(e&&e(t.tr.insertText(` +`).scrollIntoView()),!0)};function nc(t){for(let e=0;e{let{$head:n,$anchor:r}=t.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let i=n.node(-1),o=n.indexAfter(-1),s=nc(i.contentMatchAt(o));if(!s||!i.canReplaceWith(o,o,s))return!1;if(e){let l=n.after(),a=t.tr.replaceWith(l,l,s.createAndFill());a.setSelection(I.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},V1=(t,e)=>{let n=t.selection,{$from:r,$to:i}=n;if(n instanceof Je||r.parent.inlineContent||i.parent.inlineContent)return!1;let o=nc(i.parent.contentMatchAt(i.indexAfter()));if(!o||!o.isTextblock)return!1;if(e){let s=(!r.parentOffset&&i.index(){let{$cursor:n}=t.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let o=n.before();if(rs(t.doc,o))return e&&e(t.tr.split(o).scrollIntoView()),!0}let r=n.blockRange(),i=r&&Xu(r);return i==null?!1:(e&&e(t.tr.lift(r,i).scrollIntoView()),!0)};function _1(t){return(e,n)=>{let{$from:r,$to:i}=e.selection;if(e.selection instanceof z&&e.selection.node.isBlock)return!r.parentOffset||!rs(e.doc,r.pos)?!1:(n&&n(e.tr.split(r.pos).scrollIntoView()),!0);if(!r.parent.isBlock)return!1;if(n){let o=i.parentOffset==i.parent.content.size,s=e.tr;(e.selection instanceof B||e.selection instanceof Je)&&s.deleteSelection();let l=r.depth==0?null:nc(r.node(-1).contentMatchAt(r.indexAfter(-1))),a=t&&t(i.parent,o),u=a?[a]:o&&l?[{type:l}]:void 0,c=rs(s.doc,s.mapping.map(r.pos),1,u);if(!u&&!c&&rs(s.doc,s.mapping.map(r.pos),1,l?[{type:l}]:void 0)&&(l&&(u=[{type:l}]),c=!0),c&&(s.split(s.mapping.map(r.pos),1,u),!o&&!r.parentOffset&&r.parent.type!=l)){let f=s.mapping.map(r.before()),d=s.doc.resolve(f);l&&r.node(-1).canReplaceWith(d.index(),d.index()+1,l)&&s.setNodeMarkup(s.mapping.map(r.before()),l)}n(s.scrollIntoView())}return!0}}const W1=_1(),U1=(t,e)=>(e&&e(t.tr.setSelection(new Je(t.doc))),!0);function j1(t,e,n){let r=e.nodeBefore,i=e.nodeAfter,o=e.index();return!r||!i||!r.type.compatibleContent(i.type)?!1:!r.content.size&&e.parent.canReplace(o-1,o)?(n&&n(t.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(o,o+1)||!(i.isTextblock||Zu(t.doc,e.pos))?!1:(n&&n(t.tr.clearIncompatible(e.pos,r.type,r.contentMatchAt(r.childCount)).join(e.pos).scrollIntoView()),!0)}function Lp(t,e,n){let r=e.nodeBefore,i=e.nodeAfter,o,s;if(r.type.spec.isolating||i.type.spec.isolating)return!1;if(j1(t,e,n))return!0;let l=e.parent.canReplace(e.index(),e.index()+1);if(l&&(o=(s=r.contentMatchAt(r.childCount)).findWrapping(i.type))&&s.matchType(o[0]||i.type).validEnd){if(n){let f=e.pos+i.nodeSize,d=v.empty;for(let m=o.length-1;m>=0;m--)d=v.from(o[m].create(null,d));d=v.from(r.copy(d));let p=t.tr.step(new Wt(e.pos-1,f,e.pos,f,new x(d,1,0),o.length,!0)),h=f+2*o.length;Zu(p.doc,h)&&p.join(h),n(p.scrollIntoView())}return!0}let a=I.findFrom(e,1),u=a&&a.$from.blockRange(a.$to),c=u&&Xu(u);if(c!=null&&c>=e.depth)return n&&n(t.tr.lift(u,c).scrollIntoView()),!0;if(l&&Ir(i,"start",!0)&&Ir(r,"end")){let f=r,d=[];for(;d.push(f),!f.isTextblock;)f=f.lastChild;let p=i,h=1;for(;!p.isTextblock;p=p.firstChild)h++;if(f.canReplace(f.childCount,f.childCount,p.content)){if(n){let m=v.empty;for(let g=d.length-1;g>=0;g--)m=v.from(d[g].copy(m));let k=t.tr.step(new Wt(e.pos-d.length,e.pos+i.nodeSize,e.pos+h,e.pos+i.nodeSize-h,new x(m,d.length,0),0,!0));n(k.scrollIntoView())}return!0}}return!1}function Bp(t){return function(e,n){let r=e.selection,i=t<0?r.$from:r.$to,o=i.depth;for(;i.node(o).isInline;){if(!o)return!1;o--}return i.node(o).isTextblock?(n&&n(e.tr.setSelection(B.create(e.doc,t<0?i.start(o):i.end(o)))),!0):!1}}const H1=Bp(-1),J1=Bp(1);function K1(t,e,n){for(let r=0;r{if(s)return!1;s=l.inlineContent&&l.type.allowsMarkType(n)}),s)return!0}return!1}function If(t,e=null){return function(n,r){let{empty:i,$cursor:o,ranges:s}=n.selection;if(i&&!o||!K1(n.doc,s,t))return!1;if(r)if(o)t.isInSet(n.storedMarks||o.marks())?r(n.tr.removeStoredMark(t)):r(n.tr.addStoredMark(t.create(e)));else{let l=!1,a=n.tr;for(let u=0;!l&&u",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Lf=typeof navigator<"u"&&/Chrome\/(\d+)/.exec(navigator.userAgent),Y1=typeof navigator<"u"&&/Mac/.test(navigator.platform),G1=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),X1=Y1||Lf&&+Lf[1]<57;for(var pe=0;pe<10;pe++)Ut[48+pe]=Ut[96+pe]=String(pe);for(var pe=1;pe<=24;pe++)Ut[pe+111]="F"+pe;for(var pe=65;pe<=90;pe++)Ut[pe]=String.fromCharCode(pe+32),Ns[pe]=String.fromCharCode(pe);for(var Bl in Ut)Ns.hasOwnProperty(Bl)||(Ns[Bl]=Ut[Bl]);function $p(t){var e=X1&&(t.ctrlKey||t.altKey||t.metaKey)||G1&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?Ns:Ut)[t.keyCode]||t.key||"Unidentified";return n=="Esc"&&(n="Escape"),n=="Del"&&(n="Delete"),n=="Left"&&(n="ArrowLeft"),n=="Up"&&(n="ArrowUp"),n=="Right"&&(n="ArrowRight"),n=="Down"&&(n="ArrowDown"),n}const Z1=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):!1;function eS(t){let e=t.split(/-(?!$)/),n=e[e.length-1];n=="Space"&&(n=" ");let r,i,o,s;for(let l=0;l127)&&(o=Ut[r.keyCode])&&o!=i){let l=e[Vl(o,r)];if(l&&l(n.state,n.dispatch,n))return!0}}return!1}}const Ee=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},Bi=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let Bf=null;const zt=function(t,e,n){let r=Bf||(Bf=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r},Qn=function(t,e,n,r){return n&&(Vf(t,e,n,r,-1)||Vf(t,e,n,r,1))},nS=/^(img|br|input|textarea|hr)$/i;function Vf(t,e,n,r,i){for(;;){if(t==n&&e==r)return!0;if(e==(i<0?0:kt(t))){let o=t.parentNode;if(!o||o.nodeType!=1||ic(t)||nS.test(t.nodeName)||t.contentEditable=="false")return!1;e=Ee(t)+(i<0?0:1),t=o}else if(t.nodeType==1){if(t=t.childNodes[e+(i<0?-1:0)],t.contentEditable=="false")return!1;e=i<0?kt(t):0}else return!1}}function kt(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function rS(t,e,n){for(let r=e==0,i=e==kt(t);r||i;){if(t==n)return!0;let o=Ee(t);if(t=t.parentNode,!t)return!1;r=r&&o==0,i=i&&o==kt(t)}}function ic(t){let e;for(let n=t;n&&!(e=n.pmViewDesc);n=n.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==t||e.contentDOM==t)}const il=function(t){return t.focusNode&&Qn(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function In(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}function iS(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function oS(t,e,n){if(t.caretPositionFromPoint)try{let r=t.caretPositionFromPoint(e,n);if(r)return{node:r.offsetNode,offset:r.offset}}catch{}if(t.caretRangeFromPoint){let r=t.caretRangeFromPoint(e,n);if(r)return{node:r.startContainer,offset:r.startOffset}}}const Et=typeof navigator<"u"?navigator:null,$f=typeof document<"u"?document:null,Nn=Et&&Et.userAgent||"",Oa=/Edge\/(\d+)/.exec(Nn),Wp=/MSIE \d/.exec(Nn),Da=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Nn),Be=!!(Wp||Da||Oa),fn=Wp?document.documentMode:Da?+Da[1]:Oa?+Oa[1]:0,pt=!Be&&/gecko\/(\d+)/i.test(Nn);pt&&+(/Firefox\/(\d+)/.exec(Nn)||[0,0])[1];const Ta=!Be&&/Chrome\/(\d+)/.exec(Nn),xe=!!Ta,sS=Ta?+Ta[1]:0,Te=!Be&&!!Et&&/Apple Computer/.test(Et.vendor),br=Te&&(/Mobile\/\w+/.test(Nn)||!!Et&&Et.maxTouchPoints>2),Ge=br||(Et?/Mac/.test(Et.platform):!1),lS=Et?/Win/.test(Et.platform):!1,ct=/Android \d/.test(Nn),mo=!!$f&&"webkitFontSmoothing"in $f.documentElement.style,aS=mo?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function uS(t){return{left:0,right:t.documentElement.clientWidth,top:0,bottom:t.documentElement.clientHeight}}function Rt(t,e){return typeof t=="number"?t:t[e]}function cS(t){let e=t.getBoundingClientRect(),n=e.width/t.offsetWidth||1,r=e.height/t.offsetHeight||1;return{left:e.left,right:e.left+t.clientWidth*n,top:e.top,bottom:e.top+t.clientHeight*r}}function _f(t,e,n){let r=t.someProp("scrollThreshold")||0,i=t.someProp("scrollMargin")||5,o=t.dom.ownerDocument;for(let s=n||t.dom;s;s=Bi(s)){if(s.nodeType!=1)continue;let l=s,a=l==o.body,u=a?uS(o):cS(l),c=0,f=0;if(e.topu.bottom-Rt(r,"bottom")&&(f=e.bottom-e.top>u.bottom-u.top?e.top+Rt(i,"top")-u.top:e.bottom-u.bottom+Rt(i,"bottom")),e.leftu.right-Rt(r,"right")&&(c=e.right-u.right+Rt(i,"right")),c||f)if(a)o.defaultView.scrollBy(c,f);else{let d=l.scrollLeft,p=l.scrollTop;f&&(l.scrollTop+=f),c&&(l.scrollLeft+=c);let h=l.scrollLeft-d,m=l.scrollTop-p;e={left:e.left-h,top:e.top-m,right:e.right-h,bottom:e.bottom-m}}if(a||/^(fixed|sticky)$/.test(getComputedStyle(s).position))break}}function fS(t){let e=t.dom.getBoundingClientRect(),n=Math.max(0,e.top),r,i;for(let o=(e.left+e.right)/2,s=n+1;s=n-20){r=l,i=a.top;break}}return{refDOM:r,refTop:i,stack:Up(t.dom)}}function Up(t){let e=[],n=t.ownerDocument;for(let r=t;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t!=n);r=Bi(r));return e}function dS({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;jp(n,r==0?0:r-e)}function jp(t,e){for(let n=0;n=l){s=Math.max(h.bottom,s),l=Math.min(h.top,l);let m=h.left>e.left?h.left-e.left:h.right=(h.left+h.right)/2?1:0));continue}}else h.top>e.top&&!a&&h.left<=e.left&&h.right>=e.left&&(a=c,u={left:Math.max(h.left,Math.min(h.right,e.left)),top:h.top});!n&&(e.left>=h.right&&e.top>=h.top||e.left>=h.left&&e.top>=h.bottom)&&(o=f+1)}}return!n&&a&&(n=a,i=u,r=0),n&&n.nodeType==3?pS(n,i):!n||r&&n.nodeType==1?{node:t,offset:o}:Hp(n,i)}function pS(t,e){let n=t.nodeValue.length,r=document.createRange();for(let i=0;i=(o.left+o.right)/2?1:0)}}return{node:t,offset:0}}function oc(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function mS(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left(s.left+s.right)/2?1:-1}return t.docView.posFromDOM(r,i,o)}function yS(t,e,n,r){let i=-1;for(let o=e,s=!1;o!=t.dom;){let l=t.docView.nearestDesc(o,!0);if(!l)return null;if(l.dom.nodeType==1&&(l.node.isBlock&&l.parent&&!s||!l.contentDOM)){let a=l.dom.getBoundingClientRect();if(l.node.isBlock&&l.parent&&!s&&(s=!0,a.left>r.left||a.top>r.top?i=l.posBefore:(a.right-1?i:t.docView.posFromDOM(e,n,-1)}function Jp(t,e,n){let r=t.childNodes.length;if(r&&n.tope.top&&i++}let u;mo&&i&&r.nodeType==1&&(u=r.childNodes[i-1]).nodeType==1&&u.contentEditable=="false"&&u.getBoundingClientRect().top>=e.top&&i--,r==t.dom&&i==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?l=t.state.doc.content.size:(i==0||r.nodeType!=1||r.childNodes[i-1].nodeName!="BR")&&(l=yS(t,r,i,e))}l==null&&(l=gS(t,s,e));let a=t.docView.nearestDesc(s,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function Wf(t){return t.top=0&&i==r.nodeValue.length?(a--,c=1):n<0?a--:u++,Xr(Yt(zt(r,a,u),c),c<0)}if(!t.state.doc.resolve(e-(o||0)).parent.inlineContent){if(o==null&&i&&(n<0||i==kt(r))){let a=r.childNodes[i-1];if(a.nodeType==1)return $l(a.getBoundingClientRect(),!1)}if(o==null&&i=0)}if(o==null&&i&&(n<0||i==kt(r))){let a=r.childNodes[i-1],u=a.nodeType==3?zt(a,kt(a)-(s?0:1)):a.nodeType==1&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(u)return Xr(Yt(u,1),!1)}if(o==null&&i=0)}function Xr(t,e){if(t.width==0)return t;let n=e?t.left:t.right;return{top:t.top,bottom:t.bottom,left:n,right:n}}function $l(t,e){if(t.height==0)return t;let n=e?t.top:t.bottom;return{top:n,bottom:n,left:t.left,right:t.right}}function qp(t,e,n){let r=t.state,i=t.root.activeElement;r!=e&&t.updateState(e),i!=t.dom&&t.focus();try{return n()}finally{r!=e&&t.updateState(r),i!=t.dom&&i&&i.focus()}}function wS(t,e,n){let r=e.selection,i=n=="up"?r.$from:r.$to;return qp(t,e,()=>{let{node:o}=t.docView.domFromPos(i.pos,n=="up"?-1:1);for(;;){let l=t.docView.nearestDesc(o,!0);if(!l)break;if(l.node.isBlock){o=l.contentDOM||l.dom;break}o=l.dom.parentNode}let s=Kp(t,i.pos,1);for(let l=o.firstChild;l;l=l.nextSibling){let a;if(l.nodeType==1)a=l.getClientRects();else if(l.nodeType==3)a=zt(l,0,l.nodeValue.length).getClientRects();else continue;for(let u=0;uc.top+1&&(n=="up"?s.top-c.top>(c.bottom-s.top)*2:c.bottom-s.bottom>(s.bottom-c.top)*2))return!1}}return!0})}const vS=/[\u0590-\u08ac]/;function xS(t,e,n){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let i=r.parentOffset,o=!i,s=i==r.parent.content.size,l=t.domSelection();return!vS.test(r.parent.textContent)||!l.modify?n=="left"||n=="backward"?o:s:qp(t,e,()=>{let{focusNode:a,focusOffset:u,anchorNode:c,anchorOffset:f}=t.domSelectionRange(),d=l.caretBidiLevel;l.modify("move",n,"character");let p=r.depth?t.docView.domAfterPos(r.before()):t.dom,{focusNode:h,focusOffset:m}=t.domSelectionRange(),k=h&&!p.contains(h.nodeType==1?h:h.parentNode)||a==h&&u==m;try{l.collapse(c,f),a&&(a!=c||u!=f)&&l.extend&&l.extend(a,u)}catch{}return d!=null&&(l.caretBidiLevel=d),k})}let Uf=null,jf=null,Hf=!1;function CS(t,e,n){return Uf==e&&jf==n?Hf:(Uf=e,jf=n,Hf=n=="up"||n=="down"?wS(t,e,n):xS(t,e,n))}const nt=0,Jf=1,Ln=2,Ot=3;let go=class{constructor(e,n,r,i){this.parent=e,this.children=n,this.dom=r,this.contentDOM=i,this.dirty=nt,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,n,r){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let n=0;nEe(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))i=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(n==0)for(let o=e;;o=o.parentNode){if(o==this.dom){i=!1;break}if(o.previousSibling)break}if(i==null&&n==e.childNodes.length)for(let o=e;;o=o.parentNode){if(o==this.dom){i=!0;break}if(o.nextSibling)break}}return i??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,n=!1){for(let r=!0,i=e;i;i=i.parentNode){let o=this.getDesc(i),s;if(o&&(!n||o.node))if(r&&(s=o.nodeDOM)&&!(s.nodeType==1?s.contains(e.nodeType==1?e:e.parentNode):s==e))r=!1;else return o}}getDesc(e){let n=e.pmViewDesc;for(let r=n;r;r=r.parent)if(r==this)return n}posFromDOM(e,n,r){for(let i=e;i;i=i.parentNode){let o=this.getDesc(i);if(o)return o.localPosFromDOM(e,n,r)}return-1}descAt(e){for(let n=0,r=0;ne||s instanceof Zp){i=e-o;break}o=l}if(i)return this.children[r].domFromPos(i-this.children[r].border,n);for(let o;r&&!(o=this.children[r-1]).size&&o instanceof Qp&&o.side>=0;r--);if(n<=0){let o,s=!0;for(;o=r?this.children[r-1]:null,!(!o||o.dom.parentNode==this.contentDOM);r--,s=!1);return o&&n&&s&&!o.border&&!o.domAtom?o.domFromPos(o.size,n):{node:this.contentDOM,offset:o?Ee(o.dom)+1:0}}else{let o,s=!0;for(;o=r=c&&n<=u-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,n,c);e=s;for(let f=l;f>0;f--){let d=this.children[f-1];if(d.size&&d.dom.parentNode==this.contentDOM&&!d.emptyChildAt(1)){i=Ee(d.dom)+1;break}e-=d.size}i==-1&&(i=0)}if(i>-1&&(u>n||l==this.children.length-1)){n=u;for(let c=l+1;cp&&sn){let p=l;l=a,a=p}let d=document.createRange();d.setEnd(a.node,a.offset),d.setStart(l.node,l.offset),u.removeAllRanges(),u.addRange(d)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,n){for(let r=0,i=0;i=r:er){let l=r+o.border,a=s-o.border;if(e>=l&&n<=a){this.dirty=e==r||n==s?Ln:Jf,e==l&&n==a&&(o.contentLost||o.dom.parentNode!=this.contentDOM)?o.dirty=Ot:o.markDirty(e-l,n-l);return}else o.dirty=o.dom==o.contentDOM&&o.dom.parentNode==this.contentDOM&&!o.children.length?Ln:Ot}r=s}this.dirty=Ln}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let r=e==1?Ln:Jf;n.dirty{if(!o)return i;if(o.parent)return o.parent.posBeforeChild(o)})),!n.type.spec.raw){if(s.nodeType!=1){let l=document.createElement("span");l.appendChild(s),s=l}s.contentEditable="false",s.classList.add("ProseMirror-widget")}super(e,[],s,null),this.widget=n,this.widget=n,o=this}matchesWidget(e){return this.dirty==nt&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let n=this.widget.spec.stopEvent;return n?n(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get side(){return this.widget.type.side}},NS=class extends go{constructor(e,n,r,i){super(e,[],n,null),this.textDOM=r,this.text=i}get size(){return this.text.length}localPosFromDOM(e,n){return e!=this.textDOM?this.posAtStart+(n?this.size:0):this.posAtStart+n}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}},Ms=class Aa extends go{constructor(e,n,r,i){super(e,[],r,i),this.mark=n}static create(e,n,r,i){let o=i.nodeViews[n.type.name],s=o&&o(n,i,r);return(!s||!s.dom)&&(s=Lt.renderSpec(document,n.type.spec.toDOM(n,r))),new Aa(e,n,s.dom,s.contentDOM||s.dom)}parseRule(){return this.dirty&Ot||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=Ot&&this.mark.eq(e)}markDirty(e,n){if(super.markDirty(e,n),this.dirty!=nt){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty0&&(o=za(o,0,e,r));for(let l=0;l{if(!a)return s;if(a.parent)return a.parent.posBeforeChild(a)},r,i),c=u&&u.dom,f=u&&u.contentDOM;if(n.isText){if(!c)c=document.createTextNode(n.text);else if(c.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else c||({dom:c,contentDOM:f}=Lt.renderSpec(document,n.type.spec.toDOM(n)));!f&&!n.isText&&c.nodeName!="BR"&&(c.hasAttribute("contenteditable")||(c.contentEditable="false"),n.type.spec.draggable&&(c.draggable=!0));let d=c;return c=nm(c,r,n),u?a=new MS(e,n,r,i,c,f||null,d,u,o,s+1):n.isText?new Gp(e,n,r,i,c,d,o):new Yp(e,n,r,i,c,f||null,d,o,s+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(e.preserveWhitespace="full"),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let n=this.children.length-1;n>=0;n--){let r=this.children[n];if(this.dom.contains(r.dom.parentNode)){e.contentElement=r.dom.parentNode;break}}e.contentElement||(e.getContent=()=>v.empty)}return e}matchesNode(e,n,r){return this.dirty==nt&&e.eq(this.node)&&Pa(n,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,n){let r=this.node.inlineContent,i=n,o=e.composing?this.localCompositionInfo(e,n):null,s=o&&o.pos>-1?o:null,l=o&&o.pos<0,a=new OS(this,s&&s.node,e);AS(this.node,this.innerDeco,(u,c,f)=>{u.spec.marks?a.syncToMarks(u.spec.marks,r,e):u.type.side>=0&&!f&&a.syncToMarks(c==this.node.childCount?_.none:this.node.child(c).marks,r,e),a.placeWidget(u,e,i)},(u,c,f,d)=>{a.syncToMarks(u.marks,r,e);let p;a.findNodeMatch(u,c,f,d)||l&&e.state.selection.from>i&&e.state.selection.to-1&&a.updateNodeAt(u,c,f,p,e)||a.updateNextNode(u,c,f,e,d,i)||a.addNode(u,c,f,e,i),i+=u.nodeSize}),a.syncToMarks([],r,e),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==Ln)&&(s&&this.protectLocalComposition(e,s),em(this.contentDOM,this.children,e),br&&RS(this.dom))}localCompositionInfo(e,n){let{from:r,to:i}=e.state.selection;if(!(e.state.selection instanceof B)||rn+this.node.content.size)return null;let o=e.domSelectionRange(),s=PS(o.focusNode,o.focusOffset);if(!s||!this.dom.contains(s.parentNode))return null;if(this.node.inlineContent){let l=s.nodeValue,a=zS(this.node.content,l,r-n,i-n);return a<0?null:{node:s,pos:a,text:l}}else return{node:s,pos:-1,text:""}}protectLocalComposition(e,{node:n,pos:r,text:i}){if(this.getDesc(n))return;let o=n;for(;o.parentNode!=this.contentDOM;o=o.parentNode){for(;o.previousSibling;)o.parentNode.removeChild(o.previousSibling);for(;o.nextSibling;)o.parentNode.removeChild(o.nextSibling);o.pmViewDesc&&(o.pmViewDesc=void 0)}let s=new NS(this,o,n,i);e.input.compositionNodes.push(s),this.children=za(this.children,r,r+i.length,e,s)}update(e,n,r,i){return this.dirty==Ot||!e.sameMarkup(this.node)?!1:(this.updateInner(e,n,r,i),!0)}updateInner(e,n,r,i){this.updateOuterDeco(n),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(i,this.posAtStart),this.dirty=nt}updateOuterDeco(e){if(Pa(e,this.outerDeco))return;let n=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=tm(this.dom,this.nodeDOM,Ra(this.outerDeco,this.node,n),Ra(e,this.node,n)),this.dom!=r&&(r.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.dom.draggable=!0)}deselectNode(){this.nodeDOM.nodeType==1&&this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.dom.removeAttribute("draggable")}get domAtom(){return this.node.isAtom}};function Kf(t,e,n,r,i){nm(r,e,t);let o=new Cr(void 0,t,e,n,r,r,r,i,0);return o.contentDOM&&o.updateChildren(i,0),o}let Gp=class Xp extends Cr{constructor(e,n,r,i,o,s,l){super(e,n,r,i,o,null,s,l,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,n,r,i){return this.dirty==Ot||this.dirty!=nt&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=nt||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,i.trackWrites==this.nodeDOM&&(i.trackWrites=null)),this.node=e,this.dirty=nt,!0)}inParent(){let e=this.parent.contentDOM;for(let n=this.nodeDOM;n;n=n.parentNode)if(n==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,n,r){return e==this.nodeDOM?this.posAtStart+Math.min(n,this.node.text.length):super.localPosFromDOM(e,n,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,n,r){let i=this.node.cut(e,n),o=document.createTextNode(i.text);return new Xp(this.parent,i,this.outerDeco,this.innerDeco,o,o,r)}markDirty(e,n){super.markDirty(e,n),this.dom!=this.nodeDOM&&(e==0||n==this.nodeDOM.nodeValue.length)&&(this.dirty=Ot)}get domAtom(){return!1}},Zp=class extends go{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==nt&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}};class MS extends Cr{constructor(e,n,r,i,o,s,l,a,u,c){super(e,n,r,i,o,s,l,u,c),this.spec=a}update(e,n,r,i){if(this.dirty==Ot)return!1;if(this.spec.update){let o=this.spec.update(e,n,r);return o&&this.updateInner(e,n,r,i),o}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,n,r,i)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,n,r,i){this.spec.setSelection?this.spec.setSelection(e,n,r):super.setSelection(e,n,r,i)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function em(t,e,n){let r=t.firstChild,i=!1;for(let o=0;o>1,s=Math.min(o,e.length);for(;i-1)l>this.index&&(this.changed=!0,this.destroyBetween(this.index,l)),this.top=this.top.children[this.index];else{let a=Ms.create(this.top,e[o],n,r);this.top.children.splice(this.index,0,a),this.top=a,this.changed=!0}this.index=0,o++}}findNodeMatch(e,n,r,i){let o=-1,s;if(i>=this.preMatch.index&&(s=this.preMatch.matches[i-this.preMatch.index]).parent==this.top&&s.matchesNode(e,n,r))o=this.top.children.indexOf(s,this.index);else for(let l=this.index,a=Math.min(this.top.children.length,l+5);l0;){let l;for(;;)if(r){let u=n.children[r-1];if(u instanceof Ms)n=u,r=u.children.length;else{l=u,r--;break}}else{if(n==e)break e;r=n.parent.children.indexOf(n),n=n.parent}let a=l.node;if(a){if(a!=t.child(i-1))break;--i,o.set(l,i),s.push(l)}}return{index:i,matched:o,matches:s.reverse()}}function TS(t,e){return t.type.side-e.type.side}function AS(t,e,n,r){let i=e.locals(t),o=0;if(i.length==0){for(let u=0;uo;)l.push(i[s++]);let h=o+d.nodeSize;if(d.isText){let k=h;s!k.inline):l.slice();r(d,m,e.forChild(o,d),p),o=h}}function RS(t){if(t.nodeName=="UL"||t.nodeName=="OL"){let e=t.style.cssText;t.style.cssText=e+"; list-style: square !important",window.getComputedStyle(t).listStyle,t.style.cssText=e}}function PS(t,e){for(;;){if(t.nodeType==3)return t;if(t.nodeType==1&&e>0){if(t.childNodes.length>e&&t.childNodes[e].nodeType==3)return t.childNodes[e];t=t.childNodes[e-1],e=kt(t)}else if(t.nodeType==1&&e=n){if(o>=r&&a.slice(r-e.length-l,r-l)==e)return r-e.length;let u=l=0&&u+e.length+l>=n)return l+u;if(n==r&&a.length>=r+e.length-l&&a.slice(r-l,r-l+e.length)==e)return r}}return-1}function za(t,e,n,r,i){let o=[];for(let s=0,l=0;s=n||c<=e?o.push(a):(un&&o.push(a.slice(n-u,a.size,r)))}return o}function sc(t,e=null){let n=t.domSelectionRange(),r=t.state.doc;if(!n.focusNode)return null;let i=t.docView.nearestDesc(n.focusNode),o=i&&i.size==0,s=t.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(s<0)return null;let l=r.resolve(s),a,u;if(il(n)){for(a=l;i&&!i.node;)i=i.parent;let c=i.node;if(i&&c.isAtom&&z.isSelectable(c)&&i.parent&&!(c.isInline&&rS(n.focusNode,n.focusOffset,i.dom))){let f=i.posBefore;u=new z(s==f?l:r.resolve(f))}}else{let c=t.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(c<0)return null;a=r.resolve(c)}if(!u){let c=e=="pointer"||t.state.selection.head{(n.anchorNode!=r||n.anchorOffset!=i)&&(e.removeEventListener("selectionchange",t.input.hideSelectionGuard),setTimeout(()=>{(!rm(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function IS(t){let e=t.domSelection(),n=document.createRange(),r=t.cursorWrapper.dom,i=r.nodeName=="IMG";i?n.setEnd(r.parentNode,Ee(r)+1):n.setEnd(r,0),n.collapse(!1),e.removeAllRanges(),e.addRange(n),!i&&!t.state.selection.visible&&Be&&fn<=11&&(r.disabled=!0,r.disabled=!1)}function im(t,e){if(e instanceof z){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(Xf(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else Xf(t)}function Xf(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function lc(t,e,n,r){return t.someProp("createSelectionBetween",i=>i(t,e,n))||B.between(e,n,r)}function Zf(t){return t.editable&&!t.hasFocus()?!1:om(t)}function om(t){let e=t.domSelectionRange();if(!e.anchorNode)return!1;try{return t.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(t.editable||t.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function bS(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return Qn(e.node,e.offset,n.anchorNode,n.anchorOffset)}function Fa(t,e){let{$anchor:n,$head:r}=t.selection,i=e>0?n.max(r):n.min(r),o=i.parent.inlineContent?i.depth?t.doc.resolve(e>0?i.after():i.before()):null:i;return o&&I.findFrom(o,e)}function Gt(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function ed(t,e,n){let r=t.state.selection;if(r instanceof B)if(n.indexOf("s")>-1){let{$head:i}=r,o=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter;if(!o||o.isText||!o.isLeaf)return!1;let s=t.state.doc.resolve(i.pos+o.nodeSize*(e<0?-1:1));return Gt(t,new B(r.$anchor,s))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let i=Fa(t.state,e);return i&&i instanceof z?Gt(t,i):!1}else if(!(Ge&&n.indexOf("m")>-1)){let i=r.$head,o=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter,s;if(!o||o.isText)return!1;let l=e<0?i.pos-o.nodeSize:i.pos;return o.isAtom||(s=t.docView.descAt(l))&&!s.contentDOM?z.isSelectable(o)?Gt(t,new z(e<0?t.state.doc.resolve(i.pos-o.nodeSize):i)):mo?Gt(t,new B(t.state.doc.resolve(e<0?l:l+o.nodeSize))):!1:!1}}else return!1;else{if(r instanceof z&&r.node.isInline)return Gt(t,new B(e>0?r.$to:r.$from));{let i=Fa(t.state,e);return i?Gt(t,i):!1}}}function Es(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function Ci(t,e){let n=t.pmViewDesc;return n&&n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function or(t,e){return e<0?LS(t):BS(t)}function LS(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i,o,s=!1;for(pt&&n.nodeType==1&&r0){if(n.nodeType!=1)break;{let l=n.childNodes[r-1];if(Ci(l,-1))i=n,o=--r;else if(l.nodeType==3)n=l,r=n.nodeValue.length;else break}}else{if(sm(n))break;{let l=n.previousSibling;for(;l&&Ci(l,-1);)i=n.parentNode,o=Ee(l),l=l.previousSibling;if(l)n=l,r=Es(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}s?Ia(t,n,r):i&&Ia(t,i,o)}function BS(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i=Es(n),o,s;for(;;)if(r{t.state==i&&$t(t)},50)}function td(t,e){let n=t.state.doc.resolve(e);if(!(xe||lS)&&n.parent.inlineContent){let i=t.coordsAtPos(e);if(e>n.start()){let o=t.coordsAtPos(e-1),s=(o.top+o.bottom)/2;if(s>i.top&&s1)return o.lefti.top&&s1)return o.left>i.left?"ltr":"rtl"}}return getComputedStyle(t.dom).direction=="rtl"?"rtl":"ltr"}function nd(t,e,n){let r=t.state.selection;if(r instanceof B&&!r.empty||n.indexOf("s")>-1||Ge&&n.indexOf("m")>-1)return!1;let{$from:i,$to:o}=r;if(!i.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let s=Fa(t.state,e);if(s&&s instanceof z)return Gt(t,s)}if(!i.parent.inlineContent){let s=e<0?i:o,l=r instanceof Je?I.near(s,e):I.findFrom(s,e);return l?Gt(t,l):!1}return!1}function rd(t,e){if(!(t.state.selection instanceof B))return!0;let{$head:n,$anchor:r,empty:i}=t.state.selection;if(!n.sameParent(r))return!0;if(!i)return!1;if(t.endOfTextblock(e>0?"forward":"backward"))return!0;let o=!n.textOffset&&(e<0?n.nodeBefore:n.nodeAfter);if(o&&!o.isText){let s=t.state.tr;return e<0?s.delete(n.pos-o.nodeSize,n.pos):s.delete(n.pos,n.pos+o.nodeSize),t.dispatch(s),!0}return!1}function id(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function _S(t){if(!Te||t.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(e&&e.nodeType==1&&n==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let r=e.firstChild;id(t,r,"true"),setTimeout(()=>id(t,r,"false"),20)}return!1}function WS(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function US(t,e){let n=e.keyCode,r=WS(e);if(n==8||Ge&&n==72&&r=="c")return rd(t,-1)||or(t,-1);if(n==46&&!e.shiftKey||Ge&&n==68&&r=="c")return rd(t,1)||or(t,1);if(n==13||n==27)return!0;if(n==37||Ge&&n==66&&r=="c"){let i=n==37?td(t,t.state.selection.from)=="ltr"?-1:1:-1;return ed(t,i,r)||or(t,i)}else if(n==39||Ge&&n==70&&r=="c"){let i=n==39?td(t,t.state.selection.from)=="ltr"?1:-1:1;return ed(t,i,r)||or(t,i)}else{if(n==38||Ge&&n==80&&r=="c")return nd(t,-1,r)||or(t,-1);if(n==40||Ge&&n==78&&r=="c")return _S(t)||nd(t,1,r)||or(t,1);if(r==(Ge?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function lm(t,e){t.someProp("transformCopied",p=>{e=p(e,t)});let n=[],{content:r,openStart:i,openEnd:o}=e;for(;i>1&&o>1&&r.childCount==1&&r.firstChild.childCount==1;){i--,o--;let p=r.firstChild;n.push(p.type.name,p.attrs!=p.type.defaultAttrs?p.attrs:null),r=p.content}let s=t.someProp("clipboardSerializer")||Lt.fromSchema(t.state.schema),l=hm(),a=l.createElement("div");a.appendChild(s.serializeFragment(r,{document:l}));let u=a.firstChild,c,f=0;for(;u&&u.nodeType==1&&(c=dm[u.nodeName.toLowerCase()]);){for(let p=c.length-1;p>=0;p--){let h=l.createElement(c[p]);for(;a.firstChild;)h.appendChild(a.firstChild);a.appendChild(h),f++}u=a.firstChild}u&&u.nodeType==1&&u.setAttribute("data-pm-slice",`${i} ${o}${f?` -${f}`:""} ${JSON.stringify(n)}`);let d=t.someProp("clipboardTextSerializer",p=>p(e,t))||e.content.textBetween(0,e.content.size,` `);return{dom:a,text:d}}function am(t,e,n,r,i){let o=i.parent.type.spec.code,s,l;if(!n&&!e)return null;let a=e&&(r||o||!n);if(a){if(t.someProp("transformPastedText",d=>{e=d(e,o||r,t)}),o)return e?new x(v.from(t.state.schema.text(e.replace(/\r\n?/g,` -`))),0,0):x.empty;let f=t.someProp("clipboardTextParser",d=>d(e,i,r,t));if(f)l=f;else{let d=i.marks(),{schema:p}=t.state,h=Lt.fromSchema(p);s=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(m=>{let k=s.appendChild(document.createElement("p"));m&&k.appendChild(h.serializeNode(p.text(m,d)))})}}else t.someProp("transformPastedHTML",f=>{n=f(n,t)}),s=JS(n),mo&&KS(s);let u=s&&s.querySelector("[data-pm-slice]"),c=u&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(u.getAttribute("data-pm-slice")||"");if(c&&c[3])for(let f=+c[3];f>0;f--){let d=s.firstChild;for(;d&&d.nodeType!=1;)d=d.nextSibling;if(!d)break;s=d}if(l||(l=(t.someProp("clipboardParser")||t.someProp("domParser")||Li.fromSchema(t.state.schema)).parseSlice(s,{preserveWhitespace:!!(a||c),context:i,ruleFromNode(d){return d.nodeName=="BR"&&!d.nextSibling&&d.parentNode&&!jS.test(d.parentNode.nodeName)?{ignore:!0}:null}})),c)l=qS(od(l,+c[1],+c[2]),c[4]);else if(l=x.maxOpen(HS(l.content,i),!0),l.openStart||l.openEnd){let f=0,d=0;for(let p=l.content.firstChild;f{l=f(l,t)}),l}const jS=/^(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 HS(t,e){if(t.childCount<2)return t;for(let n=e.depth;n>=0;n--){let i=e.node(n).contentMatchAt(e.index(n)),o,s=[];if(t.forEach(l=>{if(!s)return;let a=i.findWrapping(l.type),u;if(!a)return s=null;if(u=s.length&&o.length&&cm(a,o,l,s[s.length-1],0))s[s.length-1]=u;else{s.length&&(s[s.length-1]=fm(s[s.length-1],o.length));let c=um(l,a);s.push(c),i=i.matchType(c.type),o=a}}),s)return v.from(s)}return t}function um(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,v.from(t));return t}function cm(t,e,n,r,i){if(i1&&(o=0),i=n&&(l=e<0?s.contentMatchAt(0).fillBefore(l,o<=i).append(l):l.append(s.contentMatchAt(s.childCount).fillBefore(v.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,s.copy(l))}function od(t,e,n){return e]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=hm().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(t),i;if((i=r&&dm[r[1].toLowerCase()])&&(t=i.map(o=>"<"+o+">").join("")+t+i.map(o=>"").reverse().join("")),n.innerHTML=t,i)for(let o=0;o=0;l-=2){let a=n.nodes[r[l]];if(!a||a.hasRequiredAttrs())break;i=v.from(a.create(r[l+1],i)),o++,s++}return new x(i,o,s)}const Ae={},Re={},QS={touchstart:!0,touchmove:!0};class YS{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:""},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastAndroidDelete=0,this.composing=!1,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function GS(t){for(let e in Ae){let n=Ae[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=r=>{ZS(t,r)&&!ac(t,r)&&(t.editable||!(r.type in Re))&&n(t,r)},QS[e]?{passive:!0}:void 0)}Te&&t.dom.addEventListener("input",()=>null),La(t)}function sn(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function XS(t){t.domObserver.stop();for(let e in t.input.eventHandlers)t.dom.removeEventListener(e,t.input.eventHandlers[e]);clearTimeout(t.input.composingTimeout),clearTimeout(t.input.lastIOSEnterFallbackTimeout)}function La(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=r=>ac(t,r))})}function ac(t,e){return t.someProp("handleDOMEvents",n=>{let r=n[e.type];return r?r(t,e)||e.defaultPrevented:!1})}function ZS(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let n=e.target;n!=t.dom;n=n.parentNode)if(!n||n.nodeType==11||n.pmViewDesc&&n.pmViewDesc.stopEvent(e))return!1;return!0}function ek(t,e){!ac(t,e)&&Ae[e.type]&&(t.editable||!(e.type in Re))&&Ae[e.type](t,e)}Re.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!mm(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(ct&&xe&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),br&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let r=Date.now();t.input.lastIOSEnter=r,t.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{t.input.lastIOSEnter==r&&(t.someProp("handleKeyDown",i=>i(t,In(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",r=>r(t,n))||US(t,n)?n.preventDefault():sn(t,"key")};Re.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};Re.keypress=(t,e)=>{let n=e;if(mm(t,n)||!n.charCode||n.ctrlKey&&!n.altKey||Ge&&n.metaKey)return;if(t.someProp("handleKeyPress",i=>i(t,n))){n.preventDefault();return}let r=t.state.selection;if(!(r instanceof B)||!r.$from.sameParent(r.$to)){let i=String.fromCharCode(n.charCode);!/[\r\n]/.test(i)&&!t.someProp("handleTextInput",o=>o(t,r.$from.pos,r.$to.pos,i))&&t.dispatch(t.state.tr.insertText(i).scrollIntoView()),n.preventDefault()}};function ol(t){return{left:t.clientX,top:t.clientY}}function tk(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function uc(t,e,n,r,i){if(r==-1)return!1;let o=t.state.doc.resolve(r);for(let s=o.depth+1;s>0;s--)if(t.someProp(e,l=>s>o.depth?l(t,n,o.nodeAfter,o.before(s),i,!0):l(t,n,o.node(s),o.before(s),i,!1)))return!0;return!1}function Nr(t,e,n){t.focused||t.focus();let r=t.state.tr.setSelection(e);n=="pointer"&&r.setMeta("pointer",!0),t.dispatch(r)}function nk(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&z.isSelectable(r)?(Nr(t,new z(n),"pointer"),!0):!1}function rk(t,e){if(e==-1)return!1;let n=t.state.selection,r,i;n instanceof z&&(r=n.node);let o=t.state.doc.resolve(e);for(let s=o.depth+1;s>0;s--){let l=s>o.depth?o.nodeAfter:o.node(s);if(z.isSelectable(l)){r&&n.$from.depth>0&&s>=n.$from.depth&&o.before(n.$from.depth+1)==n.$from.pos?i=o.before(n.$from.depth):i=o.before(s);break}}return i!=null?(Nr(t,z.create(t.state.doc,i),"pointer"),!0):!1}function ik(t,e,n,r,i){return uc(t,"handleClickOn",e,n,r)||t.someProp("handleClick",o=>o(t,e,r))||(i?rk(t,n):nk(t,n))}function ok(t,e,n,r){return uc(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",i=>i(t,e,r))}function sk(t,e,n,r){return uc(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",i=>i(t,e,r))||lk(t,n,r)}function lk(t,e,n){if(n.button!=0)return!1;let r=t.state.doc;if(e==-1)return r.inlineContent?(Nr(t,B.create(r,0,r.content.size),"pointer"),!0):!1;let i=r.resolve(e);for(let o=i.depth+1;o>0;o--){let s=o>i.depth?i.nodeAfter:i.node(o),l=i.before(o);if(s.inlineContent)Nr(t,B.create(r,l+1,l+1+s.content.size),"pointer");else if(z.isSelectable(s))Nr(t,z.create(r,l),"pointer");else continue;return!0}}function cc(t){return Os(t)}const pm=Ge?"metaKey":"ctrlKey";Ae.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=cc(t),i=Date.now(),o="singleClick";i-t.input.lastClick.time<500&&tk(n,t.input.lastClick)&&!n[pm]&&(t.input.lastClick.type=="singleClick"?o="doubleClick":t.input.lastClick.type=="doubleClick"&&(o="tripleClick")),t.input.lastClick={time:i,x:n.clientX,y:n.clientY,type:o};let s=t.posAtCoords(ol(n));s&&(o=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new ak(t,s,n,!!r)):(o=="doubleClick"?ok:sk)(t,s.pos,s.inside,n)?n.preventDefault():sn(t,"pointer"))};class ak{constructor(e,n,r,i){this.view=e,this.pos=n,this.event=r,this.flushed=i,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!r[pm],this.allowDefault=r.shiftKey;let o,s;if(n.inside>-1)o=e.state.doc.nodeAt(n.inside),s=n.inside;else{let c=e.state.doc.resolve(n.pos);o=c.parent,s=c.depth?c.before():0}const l=i?null:r.target,a=l?e.docView.nearestDesc(l,!0):null;this.target=a?a.dom:null;let{selection:u}=e.state;(r.button==0&&o.type.spec.draggable&&o.type.spec.selectable!==!1||u instanceof z&&u.from<=s&&u.to>s)&&(this.mightDrag={node:o,pos:s,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&pt&&!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)),sn(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(()=>$t(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let n=this.pos;this.view.state.doc!=this.startDoc&&(n=this.view.posAtCoords(ol(e))),this.updateAllowDefault(e),this.allowDefault||!n?sn(this.view,"pointer"):ik(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||Te&&this.mightDrag&&!this.mightDrag.node.isAtom||xe&&!this.view.state.selection.visible&&Math.min(Math.abs(n.pos-this.view.state.selection.from),Math.abs(n.pos-this.view.state.selection.to))<=2)?(Nr(this.view,I.near(this.view.state.doc.resolve(n.pos)),"pointer"),e.preventDefault()):sn(this.view,"pointer")}move(e){this.updateAllowDefault(e),sn(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)}}Ae.touchstart=t=>{t.input.lastTouch=Date.now(),cc(t),sn(t,"pointer")};Ae.touchmove=t=>{t.input.lastTouch=Date.now(),sn(t,"pointer")};Ae.contextmenu=t=>cc(t);function mm(t,e){return t.composing?!0:Te&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const uk=ct?5e3:-1;Re.compositionstart=Re.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$from;if(e.selection.empty&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)))t.markCursor=t.state.storedMarks||n.marks(),Os(t,!0),t.markCursor=null;else if(Os(t),pt&&e.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let r=t.domSelectionRange();for(let i=r.focusNode,o=r.focusOffset;i&&i.nodeType==1&&o!=0;){let s=o<0?i.lastChild:i.childNodes[o-1];if(!s)break;if(s.nodeType==3){t.domSelection().collapse(s,s.nodeValue.length);break}else i=s,o=-1}}t.input.composing=!0}gm(t,uk)};Re.compositionend=(t,e)=>{t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=e.timeStamp,t.input.compositionPendingChanges=t.domObserver.pendingRecords().length?t.input.compositionID:0,t.input.compositionPendingChanges&&Promise.resolve().then(()=>t.domObserver.flush()),t.input.compositionID++,gm(t,20))};function gm(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>Os(t),e))}function ym(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=ck());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function ck(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function Os(t,e=!1){if(!(ct&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),ym(t),e||t.docView&&t.docView.dirty){let n=sc(t);return n&&!n.eq(t.state.selection)?t.dispatch(t.state.tr.setSelection(n)):t.updateState(t.state),!0}return!1}}function fk(t,e){if(!t.dom.parentNode)return;let n=t.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(e),n.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),i=document.createRange();i.selectNodeContents(e),t.dom.blur(),r.removeAllRanges(),r.addRange(i),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),t.focus()},50)}const Vi=Be&&fn<15||br&&aS<604;Ae.copy=Re.cut=(t,e)=>{let n=e,r=t.state.selection,i=n.type=="cut";if(r.empty)return;let o=Vi?null:n.clipboardData,s=r.content(),{dom:l,text:a}=lm(t,s);o?(n.preventDefault(),o.clearData(),o.setData("text/html",l.innerHTML),o.setData("text/plain",a)):fk(t,l),i&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function dk(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function hk(t,e){if(!t.dom.parentNode)return;let n=t.input.shiftKey||t.state.selection.$from.parent.type.spec.code,r=t.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let i=t.input.shiftKey&&t.input.lastKeyCode!=45;setTimeout(()=>{t.focus(),r.parentNode&&r.parentNode.removeChild(r),n?$i(t,r.value,null,i,e):$i(t,r.textContent,r.innerHTML,i,e)},50)}function $i(t,e,n,r,i){let o=am(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",a=>a(t,i,o||x.empty)))return!0;if(!o)return!1;let s=dk(o),l=s?t.state.tr.replaceSelectionWith(s,r):t.state.tr.replaceSelection(o);return t.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Sm(t){let e=t.getData("text/plain")||t.getData("Text");if(e)return e;let n=t.getData("text/uri-list");return n?n.replace(/\r?\n/g," "):""}Re.paste=(t,e)=>{let n=e;if(t.composing&&!ct)return;let r=Vi?null:n.clipboardData,i=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&$i(t,Sm(r),r.getData("text/html"),i,n)?n.preventDefault():hk(t,n)};class km{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}}const wm=Ge?"altKey":"ctrlKey";Ae.dragstart=(t,e)=>{let n=e,r=t.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let i=t.state.selection,o=i.empty?null:t.posAtCoords(ol(n)),s;if(!(o&&o.pos>=i.from&&o.pos<=(i instanceof z?i.to-1:i.to))){if(r&&r.mightDrag)s=z.create(t.state.doc,r.mightDrag.pos);else if(n.target&&n.target.nodeType==1){let c=t.docView.nearestDesc(n.target,!0);c&&c.node.type.spec.draggable&&c!=t.docView&&(s=z.create(t.state.doc,c.posBefore))}}let l=(s||t.state.selection).content(),{dom:a,text:u}=lm(t,l);n.dataTransfer.clearData(),n.dataTransfer.setData(Vi?"Text":"text/html",a.innerHTML),n.dataTransfer.effectAllowed="copyMove",Vi||n.dataTransfer.setData("text/plain",u),t.dragging=new km(l,!n[wm],s)};Ae.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};Re.dragover=Re.dragenter=(t,e)=>e.preventDefault();Re.drop=(t,e)=>{let n=e,r=t.dragging;if(t.dragging=null,!n.dataTransfer)return;let i=t.posAtCoords(ol(n));if(!i)return;let o=t.state.doc.resolve(i.pos),s=r&&r.slice;s?t.someProp("transformPasted",h=>{s=h(s,t)}):s=am(t,Sm(n.dataTransfer),Vi?null:n.dataTransfer.getData("text/html"),!1,o);let l=!!(r&&!n[wm]);if(t.someProp("handleDrop",h=>h(t,n,s||x.empty,l))){n.preventDefault();return}if(!s)return;n.preventDefault();let a=s?w1(t.state.doc,o.pos,s):o.pos;a==null&&(a=o.pos);let u=t.state.tr;if(l){let{node:h}=r;h?h.replace(u):u.deleteSelection()}let c=u.mapping.map(a),f=s.openStart==0&&s.openEnd==0&&s.content.childCount==1,d=u.doc;if(f?u.replaceRangeWith(c,c,s.content.firstChild):u.replaceRange(c,c,s),u.doc.eq(d))return;let p=u.doc.resolve(c);if(f&&z.isSelectable(s.content.firstChild)&&p.nodeAfter&&p.nodeAfter.sameMarkup(s.content.firstChild))u.setSelection(new z(p));else{let h=u.mapping.map(a);u.mapping.maps[u.mapping.maps.length-1].forEach((m,k,g,y)=>h=y),u.setSelection(lc(t,p,u.doc.resolve(h)))}t.focus(),t.dispatch(u.setMeta("uiEvent","drop"))};Ae.focus=t=>{t.input.lastFocus=Date.now(),t.focused||(t.domObserver.stop(),t.dom.classList.add("ProseMirror-focused"),t.domObserver.start(),t.focused=!0,setTimeout(()=>{t.docView&&t.hasFocus()&&!t.domObserver.currentSelection.eq(t.domSelectionRange())&&$t(t)},20))};Ae.blur=(t,e)=>{let n=e;t.focused&&(t.domObserver.stop(),t.dom.classList.remove("ProseMirror-focused"),t.domObserver.start(),n.relatedTarget&&t.dom.contains(n.relatedTarget)&&t.domObserver.currentSelection.clear(),t.focused=!1)};Ae.beforeinput=(t,e)=>{if(xe&&ct&&e.inputType=="deleteContentBackward"){t.domObserver.flushSoon();let{domChangeCount:r}=t.input;setTimeout(()=>{if(t.input.domChangeCount!=r||(t.dom.blur(),t.focus(),t.someProp("handleKeyDown",o=>o(t,In(8,"Backspace")))))return;let{$cursor:i}=t.state.selection;i&&i.pos>0&&t.dispatch(t.state.tr.delete(i.pos-1,i.pos).scrollIntoView())},50)}};for(let t in Re)Ae[t]=Re[t];function _i(t,e){if(t==e)return!0;for(let n in t)if(t[n]!==e[n])return!1;for(let n in e)if(!(n in t))return!1;return!0}class Ds{constructor(e,n){this.toDOM=e,this.spec=n||jn,this.side=this.spec.side||0}map(e,n,r,i){let{pos:o,deleted:s}=e.mapResult(n.from+i,this.side<0?-1:1);return s?null:new me(o-r,o-r,this)}valid(){return!0}eq(e){return this==e||e instanceof Ds&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&_i(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class dn{constructor(e,n){this.attrs=e,this.spec=n||jn}map(e,n,r,i){let o=e.map(n.from+i,this.spec.inclusiveStart?-1:1)-r,s=e.map(n.to+i,this.spec.inclusiveEnd?1:-1)-r;return o>=s?null:new me(o,s,this)}valid(e,n){return n.from=e&&(!o||o(l.spec))&&r.push(l.copy(l.from+i,l.to+i))}for(let s=0;se){let l=this.children[s]+1;this.children[s+2].findInner(e-l,n-l,r,i+l,o)}}map(e,n,r){return this==we||e.maps.length==0?this:this.mapInner(e,n,0,0,r||jn)}mapInner(e,n,r,i,o){let s;for(let l=0;l{let u=a+r,c;if(c=Cm(n,l,u)){for(i||(i=this.children.slice());ol&&f.to=e){this.children[l]==e&&(r=this.children[l+2]);break}let o=e+1,s=o+n.content.size;for(let l=0;lo&&a.type instanceof dn){let u=Math.max(o,a.from)-o,c=Math.min(s,a.to)-o;ui.map(e,n,jn));return cr.from(r)}forChild(e,n){if(n.isLeaf)return W.empty;let r=[];for(let i=0;in instanceof W)?e:e.reduce((n,r)=>n.concat(r instanceof W?r:r.members),[]))}}};function pk(t,e,n,r,i,o,s){let l=t.slice();for(let u=0,c=o;u{let k=m-h-(p-d);for(let g=0;gy+c-f)continue;let S=l[g]+c-f;p>=S?l[g+1]=d<=S?-2:-1:d>=c&&k&&(l[g]+=k,l[g+1]+=k)}f+=k}),c=n.maps[u].map(c,-1)}let a=!1;for(let u=0;u=r.content.size){a=!0;continue}let d=n.map(t[u+1]+o,-1),p=d-i,{index:h,offset:m}=r.content.findIndex(f),k=r.maybeChild(h);if(k&&m==f&&m+k.nodeSize==p){let g=l[u+2].mapInner(n,k,c+1,t[u]+o+1,s);g!=we?(l[u]=f,l[u+1]=p,l[u+2]=g):(l[u+1]=-2,a=!0)}else a=!0}if(a){let u=mk(l,t,e,n,i,o,s),c=Ts(u,r,0,s);e=c.local;for(let f=0;fn&&s.to{let u=Cm(t,l,a+n);if(u){o=!0;let c=Ts(u,l,n+a+1,r);c!=we&&i.push(a,a+l.nodeSize,c)}});let s=xm(o?Nm(t):t,-n).sort(Hn);for(let l=0;l0;)e++;t.splice(e,0,n)}function Wl(t){let e=[];return t.someProp("decorations",n=>{let r=n(t.state);r&&r!=we&&e.push(r)}),t.cursorWrapper&&e.push(W.create(t.state.doc,[t.cursorWrapper.deco])),vm.from(e)}const gk={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},yk=Be&&fn<=11;let Sk=class{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}};class kk{constructor(e,n){this.view=e,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new Sk,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let i=0;ii.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():this.flush()}),yk&&(this.onCharData=r=>{this.queue.push({target:r.target,type:"characterData",oldValue:r.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,gk)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let n=0;nthis.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(Zf(this.view)){if(this.suppressingSelectionUpdates)return $t(this.view);if(Be&&fn<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Qn(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let n=new Set,r;for(let o=e.focusNode;o;o=Bi(o))n.add(o);for(let o=e.anchorNode;o;o=Bi(o))if(n.has(o)){r=o;break}let i=r&&this.view.docView.nearestDesc(r);if(i&&i.ignoreMutation({type:"selection",target:r.nodeType==3?r.parentNode:r}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let n=this.pendingRecords();n.length&&(this.queue=[]);let r=e.domSelectionRange(),i=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&Zf(e)&&!this.ignoreSelectionChange(r),o=-1,s=-1,l=!1,a=[];if(e.editable)for(let c=0;c1){let c=a.filter(f=>f.nodeName=="BR");if(c.length==2){let f=c[0],d=c[1];f.parentNode&&f.parentNode.parentNode==d.parentNode?d.remove():f.remove()}}let u=null;o<0&&i&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)-1||i)&&(o>-1&&(e.docView.markDirty(o,s),wk(e)),this.handleDOMChange(o,s,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||$t(e),this.currentSelection.set(r))}registerMutation(e,n){if(n.indexOf(e.target)>-1)return null;let r=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(r==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!r||r.ignoreMutation(e))return null;if(e.type=="childList"){for(let c=0;ci;k--){let g=r.childNodes[k-1],y=g.pmViewDesc;if(g.nodeName=="BR"&&!y){o=k;break}if(!y||y.size)break}let f=t.state.doc,d=t.someProp("domParser")||Li.fromSchema(t.state.schema),p=f.resolve(s),h=null,m=d.parse(r,{topNode:p.parent,topMatch:p.parent.contentMatchAt(p.index()),topOpen:!0,from:i,to:o,preserveWhitespace:p.parent.type.whitespace=="pre"?"full":!0,findPositions:u,ruleFromNode:Ck,context:p});if(u&&u[0].pos!=null){let k=u[0].pos,g=u[1]&&u[1].pos;g==null&&(g=k),h={anchor:k+s,head:g+s}}return{doc:m,sel:h,from:s,to:l}}function Ck(t){let e=t.pmViewDesc;if(e)return e.parseRule();if(t.nodeName=="BR"&&t.parentNode){if(Te&&/^(ul|ol)$/i.test(t.parentNode.nodeName)){let n=document.createElement("div");return n.appendChild(document.createElement("li")),{skip:n}}else if(t.parentNode.lastChild==t||Te&&/^(tr|table)$/i.test(t.parentNode.nodeName))return{ignore:!0}}else if(t.nodeName=="IMG"&&t.getAttribute("mark-placeholder"))return{ignore:!0};return null}const Nk=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function Mk(t,e,n,r,i){let o=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,e<0){let P=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,A=sc(t,P);if(A&&!t.state.selection.eq(A)){if(xe&&ct&&t.input.lastKeyCode===13&&Date.now()-100st(t,In(13,"Enter"))))return;let H=t.state.tr.setSelection(A);P=="pointer"?H.setMeta("pointer",!0):P=="key"&&H.scrollIntoView(),o&&H.setMeta("composition",o),t.dispatch(H)}return}let s=t.state.doc.resolve(e),l=s.sharedDepth(n);e=s.before(l+1),n=t.state.doc.resolve(n).after(l+1);let a=t.state.selection,u=xk(t,e,n),c=t.state.doc,f=c.slice(u.from,u.to),d,p;t.input.lastKeyCode===8&&Date.now()-100Date.now()-225||ct)&&i.some(P=>P.nodeType==1&&!Nk.test(P.nodeName))&&(!h||h.endA>=h.endB)&&t.someProp("handleKeyDown",P=>P(t,In(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!h)if(r&&a instanceof B&&!a.empty&&a.$head.sameParent(a.$anchor)&&!t.composing&&!(u.sel&&u.sel.anchor!=u.sel.head))h={start:a.from,endA:a.to,endB:a.to};else{if(u.sel){let P=cd(t,t.state.doc,u.sel);if(P&&!P.eq(t.state.selection)){let A=t.state.tr.setSelection(P);o&&A.setMeta("composition",o),t.dispatch(A)}}return}if(xe&&t.cursorWrapper&&u.sel&&u.sel.anchor==t.cursorWrapper.deco.from&&u.sel.head==u.sel.anchor){let P=h.endB-h.start;u.sel={anchor:u.sel.anchor+P,head:u.sel.anchor+P}}t.input.domChangeCount++,t.state.selection.fromt.state.selection.from&&h.start<=t.state.selection.from+2&&t.state.selection.from>=u.from?h.start=t.state.selection.from:h.endA=t.state.selection.to-2&&t.state.selection.to<=u.to&&(h.endB+=t.state.selection.to-h.endA,h.endA=t.state.selection.to)),Be&&fn<=11&&h.endB==h.start+1&&h.endA==h.start&&h.start>u.from&&u.doc.textBetween(h.start-u.from-1,h.start-u.from+1)=="  "&&(h.start--,h.endA--,h.endB--);let m=u.doc.resolveNoCache(h.start-u.from),k=u.doc.resolveNoCache(h.endB-u.from),g=c.resolve(h.start),y=m.sameParent(k)&&m.parent.inlineContent&&g.end()>=h.endA,S;if((br&&t.input.lastIOSEnter>Date.now()-225&&(!y||i.some(P=>P.nodeName=="DIV"||P.nodeName=="P"))||!y&&m.posP(t,In(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>h.start&&Ok(c,h.start,h.endA,m,k)&&t.someProp("handleKeyDown",P=>P(t,In(8,"Backspace")))){ct&&xe&&t.domObserver.suppressSelectionUpdates();return}xe&&ct&&h.endB==h.start&&(t.input.lastAndroidDelete=Date.now()),ct&&!y&&m.start()!=k.start()&&k.parentOffset==0&&m.depth==k.depth&&u.sel&&u.sel.anchor==u.sel.head&&u.sel.head==h.endA&&(h.endB-=2,k=u.doc.resolveNoCache(h.endB-u.from),setTimeout(()=>{t.someProp("handleKeyDown",function(P){return P(t,In(13,"Enter"))})},20));let w=h.start,M=h.endA,E,O,T;if(y){if(m.pos==k.pos)Be&&fn<=11&&m.parentOffset==0&&(t.domObserver.suppressSelectionUpdates(),setTimeout(()=>$t(t),20)),E=t.state.tr.delete(w,M),O=c.resolve(h.start).marksAcross(c.resolve(h.endA));else if(h.endA==h.endB&&(T=Ek(m.parent.content.cut(m.parentOffset,k.parentOffset),g.parent.content.cut(g.parentOffset,h.endA-g.start()))))E=t.state.tr,T.type=="add"?E.addMark(w,M,T.mark):E.removeMark(w,M,T.mark);else if(m.parent.child(m.index()).isText&&m.index()==k.index()-(k.textOffset?0:1)){let P=m.parent.textBetween(m.parentOffset,k.parentOffset);if(t.someProp("handleTextInput",A=>A(t,w,M,P)))return;E=t.state.tr.insertText(P,w,M)}}if(E||(E=t.state.tr.replace(w,M,u.doc.slice(h.start-u.from,h.endB-u.from))),u.sel){let P=cd(t,E.doc,u.sel);P&&!(xe&&ct&&t.composing&&P.empty&&(h.start!=h.endB||t.input.lastAndroidDeletee.content.size?null:lc(t,e.resolve(n.anchor),e.resolve(n.head))}function Ek(t,e){let n=t.firstChild.marks,r=e.firstChild.marks,i=n,o=r,s,l,a;for(let c=0;cc.mark(l.addToSet(c.marks));else if(i.length==0&&o.length==1)l=o[0],s="remove",a=c=>c.mark(l.removeFromSet(c.marks));else return null;let u=[];for(let c=0;cn||Ul(s,!0,!1)0&&(e||t.indexAfter(r)==t.node(r).childCount);)r--,i++,e=!1;if(n){let o=t.node(r).maybeChild(t.indexAfter(r));for(;o&&!o.isLeaf;)o=o.firstChild,i++}return i}function Dk(t,e,n,r,i){let o=t.findDiffStart(e,n);if(o==null)return null;let{a:s,b:l}=t.findDiffEnd(e,n+t.size,n+e.size);if(i=="end"){let a=Math.max(0,o-Math.min(s,l));r-=s+a-o}if(s=s?o-r:0;o-=a,o&&o=l?o-r:0;o-=a,o&&o=56320&&e<=57343&&n>=55296&&n<=56319}class Tk{constructor(e,n){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new YS,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(gd),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):typeof e=="function"?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=pd(this),hd(this),this.nodeViews=md(this),this.docView=Kf(this.state.doc,dd(this),Wl(this),this.dom,this),this.domObserver=new kk(this,(r,i,o,s)=>Mk(this,r,i,o,s)),this.domObserver.start(),GS(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let n in e)this._props[n]=e[n];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&La(this);let n=this._props;this._props=e,e.plugins&&(e.plugins.forEach(gd),this.directPlugins=e.plugins),this.updateStateInner(e.state,n)}setProps(e){let n={};for(let r in this._props)n[r]=this._props[r];n.state=this.state;for(let r in e)n[r]=e[r];this.update(n)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,n){var r;let i=this.state,o=!1,s=!1;e.storedMarks&&this.composing&&(ym(this),s=!0),this.state=e;let l=i.plugins!=e.plugins||this._props.plugins!=n.plugins;if(l||this._props.plugins!=n.plugins||this._props.nodeViews!=n.nodeViews){let p=md(this);Rk(p,this.nodeViews)&&(this.nodeViews=p,o=!0)}(l||n.handleDOMEvents!=this._props.handleDOMEvents)&&La(this),this.editable=pd(this),hd(this);let a=Wl(this),u=dd(this),c=i.plugins!=e.plugins&&!i.doc.eq(e.doc)?"reset":e.scrollToSelection>i.scrollToSelection?"to selection":"preserve",f=o||!this.docView.matchesNode(e.doc,u,a);(f||!e.selection.eq(i.selection))&&(s=!0);let d=c=="preserve"&&s&&this.dom.style.overflowAnchor==null&&fS(this);if(s){this.domObserver.stop();let p=f&&(Be||xe)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&Ak(i.selection,e.selection);if(f){let h=xe?this.trackWrites=this.domSelectionRange().focusNode:null;(o||!this.docView.update(e.doc,u,a,this))&&(this.docView.updateOuterDeco([]),this.docView.destroy(),this.docView=Kf(e.doc,u,a,this.dom,this)),h&&!this.trackWrites&&(p=!0)}p||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&bS(this))?$t(this,p):(im(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(i),!((r=this.dragging)===null||r===void 0)&&r.node&&!i.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,i),c=="reset"?this.dom.scrollTop=0:c=="to selection"?this.scrollToSelection():d&&dS(d)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!this.someProp("handleScrollToSelection",n=>n(this)))if(this.state.selection instanceof z){let n=this.docView.domAfterPos(this.state.selection.from);n.nodeType==1&&_f(this,n.getBoundingClientRect(),e)}else _f(this,this.coordsAtPos(this.state.selection.head,1),e)}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let n=0;n0&&this.state.doc.nodeAt(o))==r.node&&(i=o)}this.dragging=new km(e.slice,e.move,i<0?void 0:z.create(this.state.doc,i))}someProp(e,n){let r=this._props&&this._props[e],i;if(r!=null&&(i=n?n(r):r))return i;for(let s=0;sn.ownerDocument.getSelection()),this._root=n}return e||document}updateRoot(){this._root=null}posAtCoords(e){return SS(this,e)}coordsAtPos(e,n=1){return Kp(this,e,n)}domAtPos(e,n=0){return this.docView.domFromPos(e,n)}nodeDOM(e){let n=this.docView.descAt(e);return n?n.nodeDOM:null}posAtDOM(e,n,r=-1){let i=this.docView.posFromDOM(e,n,r);if(i==null)throw new RangeError("DOM position not inside the editor");return i}endOfTextblock(e,n){return CS(this,n||this.state,e)}pasteHTML(e,n){return $i(this,"",e,!1,n||new ClipboardEvent("paste"))}pasteText(e,n){return $i(this,e,null,!0,n||new ClipboardEvent("paste"))}destroy(){this.docView&&(XS(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Wl(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null)}get isDestroyed(){return this.docView==null}dispatchEvent(e){return ek(this,e)}dispatch(e){let n=this._props.dispatchTransaction;n?n.call(this,e):this.updateState(this.state.apply(e))}domSelectionRange(){return Te&&this.root.nodeType===11&&iS(this.dom.ownerDocument)==this.dom?vk(this):this.domSelection()}domSelection(){return this.root.getSelection()}}function dd(t){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(t.editable),t.someProp("attributes",n=>{if(typeof n=="function"&&(n=n(t.state)),n)for(let r in n)r=="class"?e.class+=" "+n[r]:r=="style"?e.style=(e.style?e.style+";":"")+n[r]:!e[r]&&r!="contenteditable"&&r!="nodeName"&&(e[r]=String(n[r]))}),e.translate||(e.translate="no"),[me.node(0,t.state.doc.content.size,e)]}function hd(t){if(t.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),t.cursorWrapper={dom:e,deco:me.widget(t.state.selection.head,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function pd(t){return!t.someProp("editable",e=>e(t.state)===!1)}function Ak(t,e){let n=Math.min(t.$anchor.sharedDepth(t.head),e.$anchor.sharedDepth(e.head));return t.$anchor.start(n)!=e.$anchor.start(n)}function md(t){let e=Object.create(null);function n(r){for(let i in r)Object.prototype.hasOwnProperty.call(e,i)||(e[i]=r[i])}return t.someProp("nodeViews",n),t.someProp("markViews",n),e}function Rk(t,e){let n=0,r=0;for(let i in t){if(t[i]!=e[i])return!0;n++}for(let i in e)r++;return n!=r}function gd(t){if(t.spec.state||t.spec.filterTransaction||t.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}class ee extends I{constructor(e){super(e,e)}map(e,n){let r=e.resolve(n.map(this.head));return ee.valid(r)?new ee(r):I.near(r)}content(){return x.empty}eq(e){return e instanceof ee&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new ee(e.resolve(n.pos))}getBookmark(){return new hc(this.anchor)}static valid(e){let n=e.parent;if(n.isTextblock||!Pk(e)||!zk(e))return!1;let r=n.type.spec.allowGapCursor;if(r!=null)return r;let i=n.contentMatchAt(e.index()).defaultType;return i&&i.isTextblock}static findGapCursorFrom(e,n,r=!1){e:for(;;){if(!r&&ee.valid(e))return e;let i=e.pos,o=null;for(let s=e.depth;;s--){let l=e.node(s);if(n>0?e.indexAfter(s)0){o=l.child(n>0?e.indexAfter(s):e.index(s)-1);break}else if(s==0)return null;i+=n;let a=e.doc.resolve(i);if(ee.valid(a))return a}for(;;){let s=n>0?o.firstChild:o.lastChild;if(!s){if(o.isAtom&&!o.isText&&!z.isSelectable(o)){e=e.doc.resolve(i+o.nodeSize*n),r=!1;continue e}break}o=s,i+=n;let l=e.doc.resolve(i);if(ee.valid(l))return l}return null}}}ee.prototype.visible=!1;ee.findFrom=ee.findGapCursorFrom;I.jsonID("gapcursor",ee);class hc{constructor(e){this.pos=e}map(e){return new hc(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return ee.valid(n)?new ee(n):I.near(n)}}function Pk(t){for(let e=t.depth;e>=0;e--){let n=t.index(e),r=t.node(e);if(n==0){if(r.type.spec.isolating)return!0;continue}for(let i=r.child(n-1);;i=i.lastChild){if(i.childCount==0&&!i.inlineContent||i.isAtom||i.type.spec.isolating)return!0;if(i.inlineContent)return!1}}return!0}function zk(t){for(let e=t.depth;e>=0;e--){let n=t.indexAfter(e),r=t.node(e);if(n==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let i=r.child(n);;i=i.firstChild){if(i.childCount==0&&!i.inlineContent||i.isAtom||i.type.spec.isolating)return!0;if(i.inlineContent)return!1}}return!0}function Fk(){return new At({props:{decorations:Bk,createSelectionBetween(t,e,n){return e.pos==n.pos&&ee.valid(n)?new ee(n):null},handleClick:bk,handleKeyDown:Ik,handleDOMEvents:{beforeinput:Lk}}})}const Ik=_p({ArrowLeft:Ao("horiz",-1),ArrowRight:Ao("horiz",1),ArrowUp:Ao("vert",-1),ArrowDown:Ao("vert",1)});function Ao(t,e){const n=t=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,i,o){let s=r.selection,l=e>0?s.$to:s.$from,a=s.empty;if(s instanceof B){if(!o.endOfTextblock(n)||l.depth==0)return!1;a=!1,l=r.doc.resolve(e>0?l.after():l.before())}let u=ee.findGapCursorFrom(l,e,a);return u?(i&&i(r.tr.setSelection(new ee(u))),!0):!1}}function bk(t,e,n){if(!t||!t.editable)return!1;let r=t.state.doc.resolve(e);if(!ee.valid(r))return!1;let i=t.posAtCoords({left:n.clientX,top:n.clientY});return i&&i.inside>-1&&z.isSelectable(t.state.doc.nodeAt(i.inside))?!1:(t.dispatch(t.state.tr.setSelection(new ee(r))),!0)}function Lk(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof ee))return!1;let{$from:n}=t.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(t.state.schema.nodes.text);if(!r)return!1;let i=v.empty;for(let s=r.length-1;s>=0;s--)i=v.from(r[s].createAndFill(null,i));let o=t.state.tr.replace(n.pos,n.pos,new x(i,0,0));return o.setSelection(B.near(o.doc.resolve(n.pos+1))),t.dispatch(o),!1}function Bk(t){if(!(t.selection instanceof ee))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",W.create(t.doc,[me.widget(t.selection.head,e,{key:"gapcursor"})])}class tr{constructor(e,n,r={}){this.match=e,this.match=e,this.handler=typeof n=="string"?Vk(n):n,this.undoable=r.undoable!==!1,this.inCode=r.inCode||!1}}function Vk(t){return function(e,n,r,i){let o=t;if(n[1]){let s=n[0].lastIndexOf(n[1]);o+=n[0].slice(s+n[1].length),r+=s;let l=r-i;l>0&&(o=n[0].slice(s-l,s)+o,r=i)}return e.tr.insertText(o,r,i)}}const $k=500;function _k({rules:t}){let e=new At({state:{init(){return null},apply(n,r){let i=n.getMeta(this);return i||(n.selectionSet||n.docChanged?null:r)}},props:{handleTextInput(n,r,i,o){return yd(n,r,i,o,t,e)},handleDOMEvents:{compositionend:n=>{setTimeout(()=>{let{$cursor:r}=n.state.selection;r&&yd(n,r.pos,r.pos,"",t,e)})}}},isInputRules:!0});return e}function yd(t,e,n,r,i,o){if(t.composing)return!1;let s=t.state,l=s.doc.resolve(e),a=l.parent.textBetween(Math.max(0,l.parentOffset-$k),l.parentOffset,null,"")+r;for(let u=0;u{let a=n instanceof Function?n(o):n,u=i.tr.delete(s,l),c=u.doc.resolve(s),f=c.blockRange(),d=f&&u1(f,e,a);if(!d)return null;u.wrap(f,d);let p=u.doc.resolve(s-1).nodeBefore;return p&&p.type==e&&Zu(u.doc,s-1)&&(!r||r(o,p))&&u.join(s-1),u})}const Uk=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):!1;function jk(t){let e=t.split(/-(?!$)/),n=e[e.length-1];n=="Space"&&(n=" ");let r,i,o,s;for(let l=0;l127)&&(o=Ut[r.keyCode])&&o!=i){let l=e[jl(o,r)];if(l&&l(n.state,n.dispatch,n))return!0}}return!1}}const Mm=65535,Em=Math.pow(2,16);function qk(t,e){return t+e*Em}function Sd(t){return t&Mm}function Qk(t){return(t-(t&Mm))/Em}const Om=1,Dm=2,ss=4,Tm=8;class Ba{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&Tm)>0}get deletedBefore(){return(this.delInfo&(Om|ss))>0}get deletedAfter(){return(this.delInfo&(Dm|ss))>0}get deletedAcross(){return(this.delInfo&ss)>0}}class je{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&je.empty)return je.empty}recover(e){let n=0,r=Sd(e);if(!this.inverted)for(let i=0;ie)break;let u=this.ranges[l+o],c=this.ranges[l+s],f=a+u;if(e<=f){let d=u?e==a?-1:e==f?1:n:n,p=a+i+(d<0?0:c);if(r)return p;let h=e==(n<0?a:f)?null:qk(l/3,e-a),m=e==a?Dm:e==f?Om:ss;return(n<0?e!=a:e!=f)&&(m|=Tm),new Ba(p,m,h)}i+=c-u}return r?e+i:new Ba(e+i,0,null)}touches(e,n){let r=0,i=Sd(n),o=this.inverted?2:1,s=this.inverted?1:2;for(let l=0;le)break;let u=this.ranges[l+o],c=a+u;if(e<=c&&l==i*3)return!0;r+=this.ranges[l+s]-u}return!1}forEach(e){let n=this.inverted?2:1,r=this.inverted?1:2;for(let i=0,o=0;i=0;n--){let i=e.getMirror(n);this.appendMap(e.maps[n].invert(),i!=null&&i>n?r-i-1:void 0)}}invert(){let e=new Ni;return e.appendMappingInverted(this),e}map(e,n=1){if(this.mirror)return this._map(e,n,!0);for(let r=this.from;ro&&a!s.isAtom||!l.type.allowsMarkType(this.mark.type)?s:s.mark(this.mark.addToSet(s.marks)),i),n.openStart,n.openEnd);return oe.fromReplace(e,this.from,this.to,o)}invert(){return new wt(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new ln(n.pos,r.pos,this.mark)}merge(e){return e instanceof ln&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new ln(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,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new ln(n.from,n.to,e.markFromJSON(n.mark))}}Ne.jsonID("addMark",ln);class wt extends Ne{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=new x(pc(n.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),n.openStart,n.openEnd);return oe.fromReplace(e,this.from,this.to,r)}invert(){return new ln(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new wt(n.pos,r.pos,this.mark)}merge(e){return e instanceof wt&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new wt(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,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new wt(n.from,n.to,e.markFromJSON(n.mark))}}Ne.jsonID("removeMark",wt);class an extends Ne{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return oe.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return oe.fromReplace(e,this.pos,this.pos+1,new x(v.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);if(n){let r=this.mark.addToSet(n.marks);if(r.length==n.marks.length){for(let i=0;ir.pos?null:new xt(n.pos,r.pos,i,o,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number"||typeof n.gapFrom!="number"||typeof n.gapTo!="number"||typeof n.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new xt(n.from,n.to,n.gapFrom,n.gapTo,x.fromJSON(e,n.slice),n.insert,!!n.structure)}}Ne.jsonID("replaceAround",xt);function Va(t,e,n){let r=t.resolve(e),i=n-e,o=r.depth;for(;i>0&&o>0&&r.indexAfter(o)==r.node(o).childCount;)o--,i--;if(i>0){let s=r.node(o).maybeChild(r.indexAfter(o));for(;i>0;){if(!s||s.isLeaf)return!0;s=s.firstChild,i--}}return!1}function Yk(t,e,n,r){let i=[],o=[],s,l;t.doc.nodesBetween(e,n,(a,u,c)=>{if(!a.isInline)return;let f=a.marks;if(!r.isInSet(f)&&c.type.allowsMarkType(r.type)){let d=Math.max(u,e),p=Math.min(u+a.nodeSize,n),h=r.addToSet(f);for(let m=0;mt.step(a)),o.forEach(a=>t.step(a))}function Gk(t,e,n,r){let i=[],o=0;t.doc.nodesBetween(e,n,(s,l)=>{if(!s.isInline)return;o++;let a=null;if(r instanceof fo){let u=s.marks,c;for(;c=r.isInSet(u);)(a||(a=[])).push(c),u=c.removeFromSet(u)}else r?r.isInSet(s.marks)&&(a=[r]):a=s.marks;if(a&&a.length){let u=Math.min(l+s.nodeSize,n);for(let c=0;ct.step(new wt(s.from,s.to,s.style)))}function Xk(t,e,n,r=n.contentMatch){let i=t.doc.nodeAt(e),o=[],s=e+1;for(let l=0;l=0;l--)t.step(o[l])}function Zk(t,e,n){let{$from:r,$to:i,depth:o}=e,s=r.before(o+1),l=i.after(o+1),a=s,u=l,c=v.empty,f=0;for(let h=o,m=!1;h>n;h--)m||r.index(h)>0?(m=!0,c=v.from(r.node(h).copy(c)),f++):a--;let d=v.empty,p=0;for(let h=o,m=!1;h>n;h--)m||i.after(h+1)=0;s--){if(r.size){let l=n[s].type.contentMatch.matchFragment(r);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=v.from(n[s].type.create(n[s].attrs,r))}let i=e.start,o=e.end;t.step(new xt(i,o,i,o,new x(r,0,0),n.length,!0))}function tw(t,e,n,r,i){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let o=t.steps.length;t.doc.nodesBetween(e,n,(s,l)=>{if(s.isTextblock&&!s.hasMarkup(r,i)&&nw(t.doc,t.mapping.slice(o).map(l),r)){t.clearIncompatible(t.mapping.slice(o).map(l,1),r);let a=t.mapping.slice(o),u=a.map(l,1),c=a.map(l+s.nodeSize,1);return t.step(new xt(u,c,u+1,c-1,new x(v.from(r.create(i,null,s.marks)),0,0),1,!0)),!1}})}function nw(t,e,n){let r=t.resolve(e),i=r.index();return r.parent.canReplaceWith(i,i+1,n)}function rw(t,e,n,r,i){let o=t.doc.nodeAt(e);if(!o)throw new RangeError("No node at given position");n||(n=o.type);let s=n.create(r,null,i||o.marks);if(o.isLeaf)return t.replaceWith(e,e+o.nodeSize,s);if(!n.validContent(o.content))throw new RangeError("Invalid content for node type "+n.name);t.step(new xt(e,e+o.nodeSize,e+1,e+o.nodeSize-1,new x(v.from(s),0,0),1,!0))}function iw(t,e,n=1,r){let i=t.doc.resolve(e),o=v.empty,s=v.empty;for(let l=i.depth,a=i.depth-n,u=n-1;l>a;l--,u--){o=v.from(i.node(l).copy(o));let c=r&&r[u];s=v.from(c?c.type.create(c.attrs,s):i.node(l).copy(s))}t.step(new Oe(e,e,new x(o.append(s),n,n),!0))}function ow(t,e,n){let r=new Oe(e-n,e+n,x.empty,!0);t.step(r)}function sw(t,e,n){let r=t.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),n))return e;if(r.parentOffset==0)for(let i=r.depth-1;i>=0;i--){let o=r.index(i);if(r.node(i).canReplaceWith(o,o,n))return r.before(i+1);if(o>0)return null}if(r.parentOffset==r.parent.content.size)for(let i=r.depth-1;i>=0;i--){let o=r.indexAfter(i);if(r.node(i).canReplaceWith(o,o,n))return r.after(i+1);if(o0;i--)this.placed=v.from(e.node(i).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let u=this.findFittable();u?this.placeNodes(u):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),n=this.placed.size-this.depth-this.$from.depth,r=this.$from,i=this.close(e<0?this.$to:r.doc.resolve(e));if(!i)return null;let o=this.placed,s=r.depth,l=i.depth;for(;s&&l&&o.childCount==1;)o=o.firstChild.content,s--,l--;let a=new x(o,s,l);return e>-1?new xt(r.pos,e,this.$to.pos,this.$to.end(),a,n):a.size||r.pos!=this.$to.pos?new Oe(r.pos,i.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let n=this.unplaced.content,r=0,i=this.unplaced.openEnd;r1&&(i=0),o.type.spec.isolating&&i<=r){e=r;break}n=o.content}for(let n=1;n<=2;n++)for(let r=n==1?e:this.unplaced.openStart;r>=0;r--){let i,o=null;r?(o=Jl(this.unplaced.content,r-1).firstChild,i=o.content):i=this.unplaced.content;let s=i.firstChild;for(let l=this.depth;l>=0;l--){let{type:a,match:u}=this.frontier[l],c,f=null;if(n==1&&(s?u.matchType(s.type)||(f=u.fillBefore(v.from(s),!1)):o&&a.compatibleContent(o.type)))return{sliceDepth:r,frontierDepth:l,parent:o,inject:f};if(n==2&&s&&(c=u.findWrapping(s.type)))return{sliceDepth:r,frontierDepth:l,parent:o,wrap:c};if(o&&u.matchType(o.type))break}}}openMore(){let{content:e,openStart:n,openEnd:r}=this.unplaced,i=Jl(e,n);return!i.childCount||i.firstChild.isLeaf?!1:(this.unplaced=new x(e,n+1,Math.max(r,i.size+n>=e.size-r?n+1:0)),!0)}dropNode(){let{content:e,openStart:n,openEnd:r}=this.unplaced,i=Jl(e,n);if(i.childCount<=1&&n>0){let o=e.size-n<=n+i.size;this.unplaced=new x(pi(e,n-1,1),n-1,o?n-1:r)}else this.unplaced=new x(pi(e,n,1),n,r)}placeNodes({sliceDepth:e,frontierDepth:n,parent:r,inject:i,wrap:o}){for(;this.depth>n;)this.closeFrontierNode();if(o)for(let m=0;m1||a==0||m.content.size)&&(f=k,c.push(Rm(m.mark(d.allowedMarks(m.marks)),u==1?a:0,u==l.childCount?p:-1)))}let h=u==l.childCount;h||(p=-1),this.placed=mi(this.placed,n,v.from(c)),this.frontier[n].match=f,h&&p<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let m=0,k=l;m1&&i==this.$to.end(--r);)++i;return i}findCloseLevel(e){e:for(let n=Math.min(this.depth,e.depth);n>=0;n--){let{match:r,type:i}=this.frontier[n],o=n=0;l--){let{match:a,type:u}=this.frontier[l],c=Kl(e,l,u,a,!0);if(!c||c.childCount)continue e}return{depth:n,fit:s,move:o?e.doc.resolve(e.after(n+1)):e}}}}close(e){let n=this.findCloseLevel(e);if(!n)return null;for(;this.depth>n.depth;)this.closeFrontierNode();n.fit.childCount&&(this.placed=mi(this.placed,n.depth,n.fit)),e=n.move;for(let r=n.depth+1;r<=e.depth;r++){let i=e.node(r),o=i.type.contentMatch.fillBefore(i.content,!0,e.index(r));this.openFrontierNode(i.type,i.attrs,o)}return e}openFrontierNode(e,n=null,r){let i=this.frontier[this.depth];i.match=i.match.matchType(e),this.placed=mi(this.placed,this.depth,v.from(e.create(n,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(v.empty,!0);n.childCount&&(this.placed=mi(this.placed,this.frontier.length,n))}}function pi(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(pi(t.firstChild.content,e-1,n)))}function mi(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(mi(t.lastChild.content,e-1,n)))}function Jl(t,e){for(let n=0;n1&&(r=r.replaceChild(0,Rm(r.firstChild,e-1,r.childCount==1?n-1:0))),e>0&&(r=t.type.contentMatch.fillBefore(r).append(r),n<=0&&(r=r.append(t.type.contentMatch.matchFragment(r).fillBefore(v.empty,!0)))),t.copy(r)}function Kl(t,e,n,r,i){let o=t.node(e),s=i?t.indexAfter(e):t.index(e);if(s==o.childCount&&!n.compatibleContent(o.type))return null;let l=r.fillBefore(o.content,!0,s);return l&&!uw(n,o.content,s)?l:null}function uw(t,e,n){for(let r=n;r0;d--,p--){let h=i.node(d).type.spec;if(h.defining||h.definingAsContext||h.isolating)break;s.indexOf(d)>-1?l=d:i.before(d)==p&&s.splice(1,0,-d)}let a=s.indexOf(l),u=[],c=r.openStart;for(let d=r.content,p=0;;p++){let h=d.firstChild;if(u.push(h),p==r.openStart)break;d=h.content}for(let d=c-1;d>=0;d--){let p=u[d],h=cw(p.type);if(h&&!p.sameMarkup(i.node(Math.abs(l)-1)))c=d;else if(h||!p.type.isTextblock)break}for(let d=r.openStart;d>=0;d--){let p=(d+c+1)%(r.openStart+1),h=u[p];if(h)for(let m=0;m=0&&(t.replace(e,n,r),!(t.steps.length>f));d--){let p=s[d];p<0||(e=i.before(p),n=o.after(p))}}function Pm(t,e,n,r,i){if(er){let o=i.contentMatchAt(0),s=o.fillBefore(t).append(t);t=s.append(o.matchFragment(s).fillBefore(v.empty,!0))}return t}function dw(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let i=sw(t.doc,e,r.type);i!=null&&(e=n=i)}t.replaceRange(e,n,new x(v.from(r),0,0))}function hw(t,e,n){let r=t.doc.resolve(e),i=t.doc.resolve(n),o=zm(r,i);for(let s=0;s0&&(a||r.node(l-1).canReplace(r.index(l-1),i.indexAfter(l-1))))return t.delete(r.before(l),i.after(l))}for(let s=1;s<=r.depth&&s<=i.depth;s++)if(e-r.start(s)==r.depth-s&&n>r.end(s)&&i.end(s)-n!=i.depth-s)return t.delete(r.before(s),n);t.delete(e,n)}function zm(t,e){let n=[],r=Math.min(t.depth,e.depth);for(let i=r;i>=0;i--){let o=t.start(i);if(oe.pos+(e.depth-i)||t.node(i).type.spec.isolating||e.node(i).type.spec.isolating)break;(o==e.start(i)||i==t.depth&&i==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&i&&e.start(i-1)==o-1)&&n.push(i)}return n}class Mr extends Ne{constructor(e,n,r){super(),this.pos=e,this.attr=n,this.value=r}apply(e){let n=e.nodeAt(this.pos);if(!n)return oe.fail("No node at attribute step's position");let r=Object.create(null);for(let o in n.attrs)r[o]=n.attrs[o];r[this.attr]=this.value;let i=n.type.create(r,null,n.marks);return oe.fromReplace(e,this.pos,this.pos+1,new x(v.from(i),0,n.isLeaf?0:1))}getMap(){return je.empty}invert(e){return new Mr(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Mr(n.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.pos!="number"||typeof n.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new Mr(n.pos,n.attr,n.value)}}Ne.jsonID("attr",Mr);class Wi extends Ne{constructor(e,n){super(),this.attr=e,this.value=n}apply(e){let n=Object.create(null);for(let i in e.attrs)n[i]=e.attrs[i];n[this.attr]=this.value;let r=e.type.create(n,e.content,e.marks);return oe.ok(r)}getMap(){return je.empty}invert(e){return new Wi(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new Wi(n.attr,n.value)}}Ne.jsonID("docAttr",Wi);let Br=class extends Error{};Br=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};Br.prototype=Object.create(Error.prototype);Br.prototype.constructor=Br;Br.prototype.name="TransformError";class pw{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Ni}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new Br(n.failed);return this}maybeStep(e){let n=e.apply(this.doc);return n.failed||this.addStep(e,n.doc),n}get docChanged(){return this.steps.length>0}addStep(e,n){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=n}replace(e,n=e,r=x.empty){let i=lw(this.doc,e,n,r);return i&&this.step(i),this}replaceWith(e,n,r){return this.replace(e,n,new x(v.from(r),0,0))}delete(e,n){return this.replace(e,n,x.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,r){return fw(this,e,n,r),this}replaceRangeWith(e,n,r){return dw(this,e,n,r),this}deleteRange(e,n){return hw(this,e,n),this}lift(e,n){return Zk(this,e,n),this}join(e,n=1){return ow(this,e,n),this}wrap(e,n){return ew(this,e,n),this}setBlockType(e,n=e,r,i=null){return tw(this,e,n,r,i),this}setNodeMarkup(e,n,r=null,i){return rw(this,e,n,r,i),this}setNodeAttribute(e,n,r){return this.step(new Mr(e,n,r)),this}setDocAttribute(e,n){return this.step(new Wi(e,n)),this}addNodeMark(e,n){return this.step(new an(e,n)),this}removeNodeMark(e,n){if(!(n instanceof _)){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(n=n.isInSet(r.marks),!n)return this}return this.step(new Lr(e,n)),this}split(e,n=1,r){return iw(this,e,n,r),this}addMark(e,n,r){return Yk(this,e,n,r),this}removeMark(e,n,r){return Gk(this,e,n,r),this}clearIncompatible(e,n,r){return Xk(this,e,n,r),this}}var $a,_a;if(typeof WeakMap<"u"){let t=new WeakMap;$a=e=>t.get(e),_a=(e,n)=>(t.set(e,n),n)}else{const t=[];let n=0;$a=r=>{for(let i=0;i(n==10&&(n=0),t[n++]=r,t[n++]=i)}var re=class{constructor(t,e,n,r){this.width=t,this.height=e,this.map=n,this.problems=r}findCell(t){for(let e=0;e=n){(o||(o=[])).push({type:"overlong_rowspan",pos:c,n:g-S});break}const w=i+S*e;for(let M=0;Mr&&(o+=u.attrs.colspan)}}for(let s=0;s1&&(n=!0)}e==-1?e=o:e!=o&&(e=Math.max(e,o))}return e}function yw(t,e,n){t.problems||(t.problems=[]);const r={};for(let i=0;iNumber(s)):null,i=Number(t.getAttribute("colspan")||1),o={colspan:i,rowspan:Number(t.getAttribute("rowspan")||1),colwidth:r&&r.length==i?r:null};for(const s in e){const l=e[s].getFromDOM,a=l&&l(t);a!=null&&(o[s]=a)}return o}function wd(t,e){const n={};t.attrs.colspan!=1&&(n.colspan=t.attrs.colspan),t.attrs.rowspan!=1&&(n.rowspan=t.attrs.rowspan),t.attrs.colwidth&&(n["data-colwidth"]=t.attrs.colwidth.join(","));for(const r in e){const i=e[r].setDOMAttr;i&&i(t.attrs[r],n)}return n}function kw(t){const e=t.cellAttributes||{},n={colspan:{default:1},rowspan:{default:1},colwidth:{default:null}};for(const r in e)n[r]={default:e[r].default};return{table:{content:"table_row+",tableRole:"table",isolating:!0,group:t.tableGroup,parseDOM:[{tag:"table"}],toDOM(){return["table",["tbody",0]]}},table_row:{content:"(table_cell | table_header)*",tableRole:"row",parseDOM:[{tag:"tr"}],toDOM(){return["tr",0]}},table_cell:{content:t.cellContent,attrs:n,tableRole:"cell",isolating:!0,parseDOM:[{tag:"td",getAttrs:r=>kd(r,e)}],toDOM(r){return["td",wd(r,e),0]}},table_header:{content:t.cellContent,attrs:n,tableRole:"header_cell",isolating:!0,parseDOM:[{tag:"th",getAttrs:r=>kd(r,e)}],toDOM(r){return["th",wd(r,e),0]}}}}function Ot(t){let e=t.cached.tableNodeTypes;if(!e){e=t.cached.tableNodeTypes={};for(const n in t.nodes){const r=t.nodes[n],i=r.spec.tableRole;i&&(e[i]=r)}}return e}var tn=new po("selectingCells");function yo(t){for(let e=t.depth-1;e>0;e--)if(t.node(e).type.spec.tableRole=="row")return t.node(0).resolve(t.before(e+1));return null}function mc(t){const e=t.selection.$head;for(let n=e.depth;n>0;n--)if(e.node(n).type.spec.tableRole=="row")return!0;return!1}function Fm(t){const e=t.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 n=yo(e.$head)||ww(e.$head);if(n)return n;throw new RangeError(`No cell found around position ${e.head}`)}function ww(t){for(let e=t.nodeAfter,n=t.pos;e;e=e.firstChild,n++){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return t.doc.resolve(n)}for(let e=t.nodeBefore,n=t.pos;e;e=e.lastChild,n--){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return t.doc.resolve(n-e.nodeSize)}}function Wa(t){return t.parent.type.spec.tableRole=="row"&&!!t.nodeAfter}function gc(t,e){return t.depth==e.depth&&t.pos>=e.start(-1)&&t.pos<=e.end(-1)}function Im(t,e,n){const r=t.node(-1),i=re.get(r),o=t.start(-1),s=i.nextCell(t.pos-o,e,n);return s==null?null:t.node(0).resolve(o+s)}function Vr(t,e,n=1){const r={...t,colspan:t.colspan-n};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(e,n),r.colwidth.some(i=>i>0)||(r.colwidth=null)),r}var ce=class Pt extends I{constructor(e,n=e){const r=e.node(-1),i=re.get(r),o=e.start(-1),s=i.rectBetween(e.pos-o,n.pos-o),l=e.node(0),a=i.cellsInRect(s).filter(c=>c!=n.pos-o);a.unshift(n.pos-o);const u=a.map(c=>{const f=r.nodeAt(c);if(!f)throw RangeError(`No cell with offset ${c} found`);const d=o+c+1;return new Rp(l.resolve(d),l.resolve(d+f.content.size))});super(u[0].$from,u[0].$to,u),this.$anchorCell=e,this.$headCell=n}map(e,n){const r=e.resolve(n.map(this.$anchorCell.pos)),i=e.resolve(n.map(this.$headCell.pos));if(Wa(r)&&Wa(i)&&gc(r,i)){const o=this.$anchorCell.node(-1)!=r.node(-1);return o&&this.isRowSelection()?Pt.rowSelection(r,i):o&&this.isColSelection()?Pt.colSelection(r,i):new Pt(r,i)}return B.between(r,i)}content(){const e=this.$anchorCell.node(-1),n=re.get(e),r=this.$anchorCell.start(-1),i=n.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),o={},s=[];for(let a=i.top;a0||k>0){let g=h.attrs;if(m>0&&(g=Vr(g,0,m)),k>0&&(g=Vr(g,g.colspan-k,k)),p.lefti.bottom){const g={...h.attrs,rowspan:Math.min(p.bottom,i.bottom)-Math.max(p.top,i.top)};p.top0)return!1;const r=e+this.$anchorCell.nodeAfter.attrs.rowspan,i=n+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(r,i)==this.$headCell.node(-1).childCount}static colSelection(e,n=e){const r=e.node(-1),i=re.get(r),o=e.start(-1),s=i.findCell(e.pos-o),l=i.findCell(n.pos-o),a=e.node(0);return s.top<=l.top?(s.top>0&&(e=a.resolve(o+i.map[s.left])),l.bottom0&&(n=a.resolve(o+i.map[l.left])),s.bottom0)return!1;const s=i+this.$anchorCell.nodeAfter.attrs.colspan,l=o+this.$headCell.nodeAfter.attrs.colspan;return Math.max(s,l)==n.width}eq(e){return e instanceof Pt&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,n=e){const r=e.node(-1),i=re.get(r),o=e.start(-1),s=i.findCell(e.pos-o),l=i.findCell(n.pos-o),a=e.node(0);return s.left<=l.left?(s.left>0&&(e=a.resolve(o+i.map[s.top*i.width])),l.right0&&(n=a.resolve(o+i.map[l.top*i.width])),s.right{e.push(me.node(r,r+n.nodeSize,{class:"selectedCell"}))}),W.create(t.doc,e)}function Cw({$from:t,$to:e}){if(t.pos==e.pos||t.pos=0&&!(t.after(i+1)=0&&!(e.before(o+1)>e.start(o));o--,r--);return n==r&&/row|table/.test(t.node(i).type.spec.tableRole)}function Nw({$from:t,$to:e}){let n,r;for(let i=t.depth;i>0;i--){const o=t.node(i);if(o.type.spec.tableRole==="cell"||o.type.spec.tableRole==="header_cell"){n=o;break}}for(let i=e.depth;i>0;i--){const o=e.node(i);if(o.type.spec.tableRole==="cell"||o.type.spec.tableRole==="header_cell"){r=o;break}}return n!==r&&e.parentOffset===0}function Mw(t,e,n){const r=(e||t).selection,i=(e||t).doc;let o,s;if(r instanceof z&&(s=r.node.type.spec.tableRole)){if(s=="cell"||s=="header_cell")o=ce.create(i,r.from);else if(s=="row"){const l=i.resolve(r.from+1);o=ce.rowSelection(l,l)}else if(!n){const l=re.get(r.node),a=r.from+1,u=a+l.map[l.width*l.height-1];o=ce.create(i,a+1,u)}}else r instanceof B&&Cw(r)?o=B.create(i,r.from):r instanceof B&&Nw(r)&&(o=B.create(i,r.$from.start(),r.$from.end()));return o&&(e||(e=t.tr)).setSelection(o),e}var Ew=new po("fix-tables");function Lm(t,e,n,r){const i=t.childCount,o=e.childCount;e:for(let s=0,l=0;s{i.type.spec.tableRole=="table"&&(n=Dw(t,i,o,n))};return e?e.doc!=t.doc&&Lm(e.doc,t.doc,0,r):t.doc.descendants(r),n}function Dw(t,e,n,r){const i=re.get(e);if(!i.problems)return r;r||(r=t.tr);const o=[];for(let a=0;a0){let p="cell";c.firstChild&&(p=c.firstChild.type.spec.tableRole);const h=[];for(let k=0;k0&&r>0||e.child(0).type.spec.tableRole=="table");)n--,r--,e=e.child(0).content;const i=e.child(0),o=i.type.spec.tableRole,s=i.type.schema,l=[];if(o=="row")for(let a=0;a=0;s--){const{rowspan:l,colspan:a}=o.child(s).attrs;for(let u=i;u=e.length&&e.push(v.empty),n[i]r&&(d=d.type.createChecked(Vr(d.attrs,d.attrs.colspan,c+d.attrs.colspan-r),d.content)),u.push(d),c+=d.attrs.colspan;for(let p=1;pi&&(f=f.type.create({...f.attrs,rowspan:Math.max(1,i-f.attrs.rowspan)},f.content)),a.push(f)}o.push(v.from(a))}n=o,e=i}return{width:t,height:e,rows:n}}function Pw(t,e,n,r,i,o,s){const l=t.doc.type.schema,a=Ot(l);let u,c;if(i>e.width)for(let f=0,d=0;fe.height){const f=[];for(let h=0,m=(e.height-1)*e.width;h=e.width?!1:n.nodeAt(e.map[m+h]).type==a.header_cell;f.push(k?c||(c=a.header_cell.createAndFill()):u||(u=a.cell.createAndFill()))}const d=a.row.create(null,v.from(f)),p=[];for(let h=e.height;h{if(!i)return!1;const o=n.selection;if(o instanceof ce)return ls(n,r,I.near(o.$headCell,e));if(t!="horiz"&&!o.empty)return!1;const s=Bm(i,t,e);if(s==null)return!1;if(t=="horiz")return ls(n,r,I.near(n.doc.resolve(o.head+e),e));{const l=n.doc.resolve(s),a=Im(l,t,e);let u;return a?u=I.near(a,1):e<0?u=I.near(n.doc.resolve(l.before(-1)),-1):u=I.near(n.doc.resolve(l.after(-1)),1),ls(n,r,u)}}}function Po(t,e){return(n,r,i)=>{if(!i)return!1;const o=n.selection;let s;if(o instanceof ce)s=o;else{const a=Bm(i,t,e);if(a==null)return!1;s=new ce(n.doc.resolve(a))}const l=Im(s.$headCell,t,e);return l?ls(n,r,new ce(s.$anchorCell,l)):!1}}function zo(t,e){const n=t.selection;if(!(n instanceof ce))return!1;if(e){const r=t.tr,i=Ot(t.schema).cell.createAndFill().content;n.forEachCell((o,s)=>{o.content.eq(i)||r.replace(r.mapping.map(s+1),r.mapping.map(s+o.nodeSize-1),new x(i,0,0))}),r.docChanged&&e(r)}return!0}function Fw(t,e){const n=t.state.doc,r=yo(n.resolve(e));return r?(t.dispatch(t.state.tr.setSelection(new ce(r))),!0):!1}function Iw(t,e,n){if(!mc(t.state))return!1;let r=Tw(n);const i=t.state.selection;if(i instanceof ce){r||(r={width:1,height:1,rows:[v.from(Ua(Ot(t.state.schema).cell,n))]});const o=i.$anchorCell.node(-1),s=i.$anchorCell.start(-1),l=re.get(o).rectBetween(i.$anchorCell.pos-s,i.$headCell.pos-s);return r=Rw(r,l.right-l.left,l.bottom-l.top),Cd(t.state,t.dispatch,s,l,r),!0}else if(r){const o=Fm(t.state),s=o.start(-1);return Cd(t.state,t.dispatch,s,re.get(o.node(-1)).findCell(o.pos-s),r),!0}else return!1}function bw(t,e){var n;if(e.ctrlKey||e.metaKey)return;const r=Nd(t,e.target);let i;if(e.shiftKey&&t.state.selection instanceof ce)o(t.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&r&&(i=yo(t.state.selection.$anchor))!=null&&((n=ql(t,e))==null?void 0:n.pos)!=i.pos)o(i,e),e.preventDefault();else if(!r)return;function o(a,u){let c=ql(t,u);const f=tn.getState(t.state)==null;if(!c||!gc(a,c))if(f)c=a;else return;const d=new ce(a,c);if(f||!t.state.selection.eq(d)){const p=t.state.tr.setSelection(d);f&&p.setMeta(tn,a.pos),t.dispatch(p)}}function s(){t.root.removeEventListener("mouseup",s),t.root.removeEventListener("dragstart",s),t.root.removeEventListener("mousemove",l),tn.getState(t.state)!=null&&t.dispatch(t.state.tr.setMeta(tn,-1))}function l(a){const u=a,c=tn.getState(t.state);let f;if(c!=null)f=t.state.doc.resolve(c);else if(Nd(t,u.target)!=r&&(f=ql(t,e),!f))return s();f&&o(f,u)}t.root.addEventListener("mouseup",s),t.root.addEventListener("dragstart",s),t.root.addEventListener("mousemove",l)}function Bm(t,e,n){if(!(t.state.selection instanceof B))return null;const{$head:r}=t.state.selection;for(let i=r.depth-1;i>=0;i--){const o=r.node(i);if((n<0?r.index(i):r.indexAfter(i))!=(n<0?0:o.childCount))return null;if(o.type.spec.tableRole=="cell"||o.type.spec.tableRole=="header_cell"){const l=r.before(i),a=e=="vert"?n>0?"down":"up":n>0?"right":"left";return t.endOfTextblock(a)?l:null}}return null}function Nd(t,e){for(;e&&e!=t.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function ql(t,e){const n=t.posAtCoords({left:e.clientX,top:e.clientY});return n&&n?yo(t.state.doc.resolve(n.pos)):null}var Lw=class{constructor(t,e){this.node=t,this.cellMinWidth=e,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")),ja(t,this.colgroup,this.table,e),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(t){return t.type!=this.node.type?!1:(this.node=t,ja(t,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(t){return t.type=="attributes"&&(t.target==this.table||this.colgroup.contains(t.target))}};function ja(t,e,n,r,i,o){var s;let l=0,a=!0,u=e.firstChild;const c=t.firstChild;if(c){for(let f=0,d=0;fnew n(l,e,a),new Vw(-1,!1)},apply(o,s){return s.apply(o)}},props:{attributes:o=>{const s=et.getState(o);return s&&s.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(o,s)=>{$w(o,s,t,e,r)},mouseleave:o=>{_w(o)},mousedown:(o,s)=>{Ww(o,s,e)}},decorations:o=>{const s=et.getState(o);if(s&&s.activeHandle>-1)return qw(o,s.activeHandle)},nodeViews:{}}});return i}var Vw=class as{constructor(e,n){this.activeHandle=e,this.dragging=n}apply(e){const n=this,r=e.getMeta(et);if(r&&r.setHandle!=null)return new as(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new as(n.activeHandle,r.setDragging);if(n.activeHandle>-1&&e.docChanged){let i=e.mapping.map(n.activeHandle,-1);return Wa(e.doc.resolve(i))||(i=-1),new as(i,n.dragging)}return n}};function $w(t,e,n,r,i){const o=et.getState(t.state);if(o&&!o.dragging){const s=jw(e.target);let l=-1;if(s){const{left:a,right:u}=s.getBoundingClientRect();e.clientX-a<=n?l=Md(t,e,"left",n):u-e.clientX<=n&&(l=Md(t,e,"right",n))}if(l!=o.activeHandle){if(!i&&l!==-1){const a=t.state.doc.resolve(l),u=a.node(-1),c=re.get(u),f=a.start(-1);if(c.colCount(a.pos-f)+a.nodeAfter.attrs.colspan-1==c.width-1)return}Vm(t,l)}}}function _w(t){const e=et.getState(t.state);e&&e.activeHandle>-1&&!e.dragging&&Vm(t,-1)}function Ww(t,e,n){var r;const i=(r=t.dom.ownerDocument.defaultView)!=null?r:window,o=et.getState(t.state);if(!o||o.activeHandle==-1||o.dragging)return!1;const s=t.state.doc.nodeAt(o.activeHandle),l=Uw(t,o.activeHandle,s.attrs);t.dispatch(t.state.tr.setMeta(et,{setDragging:{startX:e.clientX,startWidth:l}}));function a(c){i.removeEventListener("mouseup",a),i.removeEventListener("mousemove",u);const f=et.getState(t.state);f!=null&&f.dragging&&(Hw(t,f.activeHandle,Ed(f.dragging,c,n)),t.dispatch(t.state.tr.setMeta(et,{setDragging:null})))}function u(c){if(!c.which)return a(c);const f=et.getState(t.state);if(f&&f.dragging){const d=Ed(f.dragging,c,n);Jw(t,f.activeHandle,d,n)}}return i.addEventListener("mouseup",a),i.addEventListener("mousemove",u),e.preventDefault(),!0}function Uw(t,e,{colspan:n,colwidth:r}){const i=r&&r[r.length-1];if(i)return i;const o=t.domAtPos(e);let l=o.node.childNodes[o.offset].offsetWidth,a=n;if(r)for(let u=0;ui.table.nodeAt(a));for(let a=0;a{const h=p+o.tableStart,m=s.doc.nodeAt(h);m&&s.setNodeMarkup(h,d,m.attrs)}),r(s)}return!0}}yc("row",{useDeprecatedLogic:!0});yc("column",{useDeprecatedLogic:!0});yc("cell",{useDeprecatedLogic:!0});function Yw({allowTableNodeSelection:t=!1}={}){return new At({key:tn,state:{init(){return null},apply(e,n){const r=e.getMeta(tn);if(r!=null)return r==-1?null:r;if(n==null||!e.docChanged)return n;const{deleted:i,pos:o}=e.mapping.mapResult(n);return i?null:o}},props:{decorations:xw,handleDOMEvents:{mousedown:bw},createSelectionBetween(e){return tn.getState(e.state)!=null?e.state.selection:null},handleTripleClick:Fw,handleKeyDown:zw,handlePaste:Iw},appendTransaction(e,n,r){return Mw(r,Ow(r,n),t)}})}var _m={exports:{}},Qe={},Wm={exports:{}},Um={};/** +`))),0,0):x.empty;let f=t.someProp("clipboardTextParser",d=>d(e,i,r,t));if(f)l=f;else{let d=i.marks(),{schema:p}=t.state,h=Lt.fromSchema(p);s=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(m=>{let k=s.appendChild(document.createElement("p"));m&&k.appendChild(h.serializeNode(p.text(m,d)))})}}else t.someProp("transformPastedHTML",f=>{n=f(n,t)}),s=JS(n),mo&&KS(s);let u=s&&s.querySelector("[data-pm-slice]"),c=u&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(u.getAttribute("data-pm-slice")||"");if(c&&c[3])for(let f=+c[3];f>0;f--){let d=s.firstChild;for(;d&&d.nodeType!=1;)d=d.nextSibling;if(!d)break;s=d}if(l||(l=(t.someProp("clipboardParser")||t.someProp("domParser")||Li.fromSchema(t.state.schema)).parseSlice(s,{preserveWhitespace:!!(a||c),context:i,ruleFromNode(d){return d.nodeName=="BR"&&!d.nextSibling&&d.parentNode&&!jS.test(d.parentNode.nodeName)?{ignore:!0}:null}})),c)l=qS(od(l,+c[1],+c[2]),c[4]);else if(l=x.maxOpen(HS(l.content,i),!0),l.openStart||l.openEnd){let f=0,d=0;for(let p=l.content.firstChild;f{l=f(l,t)}),l}const jS=/^(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 HS(t,e){if(t.childCount<2)return t;for(let n=e.depth;n>=0;n--){let i=e.node(n).contentMatchAt(e.index(n)),o,s=[];if(t.forEach(l=>{if(!s)return;let a=i.findWrapping(l.type),u;if(!a)return s=null;if(u=s.length&&o.length&&cm(a,o,l,s[s.length-1],0))s[s.length-1]=u;else{s.length&&(s[s.length-1]=fm(s[s.length-1],o.length));let c=um(l,a);s.push(c),i=i.matchType(c.type),o=a}}),s)return v.from(s)}return t}function um(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,v.from(t));return t}function cm(t,e,n,r,i){if(i1&&(o=0),i=n&&(l=e<0?s.contentMatchAt(0).fillBefore(l,o<=i).append(l):l.append(s.contentMatchAt(s.childCount).fillBefore(v.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,s.copy(l))}function od(t,e,n){return e]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=hm().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(t),i;if((i=r&&dm[r[1].toLowerCase()])&&(t=i.map(o=>"<"+o+">").join("")+t+i.map(o=>"").reverse().join("")),n.innerHTML=t,i)for(let o=0;o=0;l-=2){let a=n.nodes[r[l]];if(!a||a.hasRequiredAttrs())break;i=v.from(a.create(r[l+1],i)),o++,s++}return new x(i,o,s)}const Ae={},Re={},QS={touchstart:!0,touchmove:!0};class YS{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:""},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastAndroidDelete=0,this.composing=!1,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function GS(t){for(let e in Ae){let n=Ae[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=r=>{ZS(t,r)&&!ac(t,r)&&(t.editable||!(r.type in Re))&&n(t,r)},QS[e]?{passive:!0}:void 0)}Te&&t.dom.addEventListener("input",()=>null),La(t)}function sn(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function XS(t){t.domObserver.stop();for(let e in t.input.eventHandlers)t.dom.removeEventListener(e,t.input.eventHandlers[e]);clearTimeout(t.input.composingTimeout),clearTimeout(t.input.lastIOSEnterFallbackTimeout)}function La(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=r=>ac(t,r))})}function ac(t,e){return t.someProp("handleDOMEvents",n=>{let r=n[e.type];return r?r(t,e)||e.defaultPrevented:!1})}function ZS(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let n=e.target;n!=t.dom;n=n.parentNode)if(!n||n.nodeType==11||n.pmViewDesc&&n.pmViewDesc.stopEvent(e))return!1;return!0}function ek(t,e){!ac(t,e)&&Ae[e.type]&&(t.editable||!(e.type in Re))&&Ae[e.type](t,e)}Re.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!mm(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(ct&&xe&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),br&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let r=Date.now();t.input.lastIOSEnter=r,t.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{t.input.lastIOSEnter==r&&(t.someProp("handleKeyDown",i=>i(t,In(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",r=>r(t,n))||US(t,n)?n.preventDefault():sn(t,"key")};Re.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};Re.keypress=(t,e)=>{let n=e;if(mm(t,n)||!n.charCode||n.ctrlKey&&!n.altKey||Ge&&n.metaKey)return;if(t.someProp("handleKeyPress",i=>i(t,n))){n.preventDefault();return}let r=t.state.selection;if(!(r instanceof B)||!r.$from.sameParent(r.$to)){let i=String.fromCharCode(n.charCode);!/[\r\n]/.test(i)&&!t.someProp("handleTextInput",o=>o(t,r.$from.pos,r.$to.pos,i))&&t.dispatch(t.state.tr.insertText(i).scrollIntoView()),n.preventDefault()}};function ol(t){return{left:t.clientX,top:t.clientY}}function tk(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function uc(t,e,n,r,i){if(r==-1)return!1;let o=t.state.doc.resolve(r);for(let s=o.depth+1;s>0;s--)if(t.someProp(e,l=>s>o.depth?l(t,n,o.nodeAfter,o.before(s),i,!0):l(t,n,o.node(s),o.before(s),i,!1)))return!0;return!1}function Nr(t,e,n){t.focused||t.focus();let r=t.state.tr.setSelection(e);n=="pointer"&&r.setMeta("pointer",!0),t.dispatch(r)}function nk(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&z.isSelectable(r)?(Nr(t,new z(n),"pointer"),!0):!1}function rk(t,e){if(e==-1)return!1;let n=t.state.selection,r,i;n instanceof z&&(r=n.node);let o=t.state.doc.resolve(e);for(let s=o.depth+1;s>0;s--){let l=s>o.depth?o.nodeAfter:o.node(s);if(z.isSelectable(l)){r&&n.$from.depth>0&&s>=n.$from.depth&&o.before(n.$from.depth+1)==n.$from.pos?i=o.before(n.$from.depth):i=o.before(s);break}}return i!=null?(Nr(t,z.create(t.state.doc,i),"pointer"),!0):!1}function ik(t,e,n,r,i){return uc(t,"handleClickOn",e,n,r)||t.someProp("handleClick",o=>o(t,e,r))||(i?rk(t,n):nk(t,n))}function ok(t,e,n,r){return uc(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",i=>i(t,e,r))}function sk(t,e,n,r){return uc(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",i=>i(t,e,r))||lk(t,n,r)}function lk(t,e,n){if(n.button!=0)return!1;let r=t.state.doc;if(e==-1)return r.inlineContent?(Nr(t,B.create(r,0,r.content.size),"pointer"),!0):!1;let i=r.resolve(e);for(let o=i.depth+1;o>0;o--){let s=o>i.depth?i.nodeAfter:i.node(o),l=i.before(o);if(s.inlineContent)Nr(t,B.create(r,l+1,l+1+s.content.size),"pointer");else if(z.isSelectable(s))Nr(t,z.create(r,l),"pointer");else continue;return!0}}function cc(t){return Os(t)}const pm=Ge?"metaKey":"ctrlKey";Ae.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=cc(t),i=Date.now(),o="singleClick";i-t.input.lastClick.time<500&&tk(n,t.input.lastClick)&&!n[pm]&&(t.input.lastClick.type=="singleClick"?o="doubleClick":t.input.lastClick.type=="doubleClick"&&(o="tripleClick")),t.input.lastClick={time:i,x:n.clientX,y:n.clientY,type:o};let s=t.posAtCoords(ol(n));s&&(o=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new ak(t,s,n,!!r)):(o=="doubleClick"?ok:sk)(t,s.pos,s.inside,n)?n.preventDefault():sn(t,"pointer"))};class ak{constructor(e,n,r,i){this.view=e,this.pos=n,this.event=r,this.flushed=i,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!r[pm],this.allowDefault=r.shiftKey;let o,s;if(n.inside>-1)o=e.state.doc.nodeAt(n.inside),s=n.inside;else{let c=e.state.doc.resolve(n.pos);o=c.parent,s=c.depth?c.before():0}const l=i?null:r.target,a=l?e.docView.nearestDesc(l,!0):null;this.target=a?a.dom:null;let{selection:u}=e.state;(r.button==0&&o.type.spec.draggable&&o.type.spec.selectable!==!1||u instanceof z&&u.from<=s&&u.to>s)&&(this.mightDrag={node:o,pos:s,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&pt&&!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)),sn(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(()=>$t(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let n=this.pos;this.view.state.doc!=this.startDoc&&(n=this.view.posAtCoords(ol(e))),this.updateAllowDefault(e),this.allowDefault||!n?sn(this.view,"pointer"):ik(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||Te&&this.mightDrag&&!this.mightDrag.node.isAtom||xe&&!this.view.state.selection.visible&&Math.min(Math.abs(n.pos-this.view.state.selection.from),Math.abs(n.pos-this.view.state.selection.to))<=2)?(Nr(this.view,I.near(this.view.state.doc.resolve(n.pos)),"pointer"),e.preventDefault()):sn(this.view,"pointer")}move(e){this.updateAllowDefault(e),sn(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)}}Ae.touchstart=t=>{t.input.lastTouch=Date.now(),cc(t),sn(t,"pointer")};Ae.touchmove=t=>{t.input.lastTouch=Date.now(),sn(t,"pointer")};Ae.contextmenu=t=>cc(t);function mm(t,e){return t.composing?!0:Te&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const uk=ct?5e3:-1;Re.compositionstart=Re.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$from;if(e.selection.empty&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)))t.markCursor=t.state.storedMarks||n.marks(),Os(t,!0),t.markCursor=null;else if(Os(t),pt&&e.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let r=t.domSelectionRange();for(let i=r.focusNode,o=r.focusOffset;i&&i.nodeType==1&&o!=0;){let s=o<0?i.lastChild:i.childNodes[o-1];if(!s)break;if(s.nodeType==3){t.domSelection().collapse(s,s.nodeValue.length);break}else i=s,o=-1}}t.input.composing=!0}gm(t,uk)};Re.compositionend=(t,e)=>{t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=e.timeStamp,t.input.compositionPendingChanges=t.domObserver.pendingRecords().length?t.input.compositionID:0,t.input.compositionPendingChanges&&Promise.resolve().then(()=>t.domObserver.flush()),t.input.compositionID++,gm(t,20))};function gm(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>Os(t),e))}function ym(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=ck());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function ck(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function Os(t,e=!1){if(!(ct&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),ym(t),e||t.docView&&t.docView.dirty){let n=sc(t);return n&&!n.eq(t.state.selection)?t.dispatch(t.state.tr.setSelection(n)):t.updateState(t.state),!0}return!1}}function fk(t,e){if(!t.dom.parentNode)return;let n=t.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(e),n.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),i=document.createRange();i.selectNodeContents(e),t.dom.blur(),r.removeAllRanges(),r.addRange(i),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),t.focus()},50)}const Vi=Be&&fn<15||br&&aS<604;Ae.copy=Re.cut=(t,e)=>{let n=e,r=t.state.selection,i=n.type=="cut";if(r.empty)return;let o=Vi?null:n.clipboardData,s=r.content(),{dom:l,text:a}=lm(t,s);o?(n.preventDefault(),o.clearData(),o.setData("text/html",l.innerHTML),o.setData("text/plain",a)):fk(t,l),i&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function dk(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function hk(t,e){if(!t.dom.parentNode)return;let n=t.input.shiftKey||t.state.selection.$from.parent.type.spec.code,r=t.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let i=t.input.shiftKey&&t.input.lastKeyCode!=45;setTimeout(()=>{t.focus(),r.parentNode&&r.parentNode.removeChild(r),n?$i(t,r.value,null,i,e):$i(t,r.textContent,r.innerHTML,i,e)},50)}function $i(t,e,n,r,i){let o=am(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",a=>a(t,i,o||x.empty)))return!0;if(!o)return!1;let s=dk(o),l=s?t.state.tr.replaceSelectionWith(s,r):t.state.tr.replaceSelection(o);return t.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Sm(t){let e=t.getData("text/plain")||t.getData("Text");if(e)return e;let n=t.getData("text/uri-list");return n?n.replace(/\r?\n/g," "):""}Re.paste=(t,e)=>{let n=e;if(t.composing&&!ct)return;let r=Vi?null:n.clipboardData,i=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&$i(t,Sm(r),r.getData("text/html"),i,n)?n.preventDefault():hk(t,n)};class km{constructor(e,n,r){this.slice=e,this.move=n,this.node=r}}const wm=Ge?"altKey":"ctrlKey";Ae.dragstart=(t,e)=>{let n=e,r=t.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let i=t.state.selection,o=i.empty?null:t.posAtCoords(ol(n)),s;if(!(o&&o.pos>=i.from&&o.pos<=(i instanceof z?i.to-1:i.to))){if(r&&r.mightDrag)s=z.create(t.state.doc,r.mightDrag.pos);else if(n.target&&n.target.nodeType==1){let c=t.docView.nearestDesc(n.target,!0);c&&c.node.type.spec.draggable&&c!=t.docView&&(s=z.create(t.state.doc,c.posBefore))}}let l=(s||t.state.selection).content(),{dom:a,text:u}=lm(t,l);n.dataTransfer.clearData(),n.dataTransfer.setData(Vi?"Text":"text/html",a.innerHTML),n.dataTransfer.effectAllowed="copyMove",Vi||n.dataTransfer.setData("text/plain",u),t.dragging=new km(l,!n[wm],s)};Ae.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};Re.dragover=Re.dragenter=(t,e)=>e.preventDefault();Re.drop=(t,e)=>{let n=e,r=t.dragging;if(t.dragging=null,!n.dataTransfer)return;let i=t.posAtCoords(ol(n));if(!i)return;let o=t.state.doc.resolve(i.pos),s=r&&r.slice;s?t.someProp("transformPasted",h=>{s=h(s,t)}):s=am(t,Sm(n.dataTransfer),Vi?null:n.dataTransfer.getData("text/html"),!1,o);let l=!!(r&&!n[wm]);if(t.someProp("handleDrop",h=>h(t,n,s||x.empty,l))){n.preventDefault();return}if(!s)return;n.preventDefault();let a=s?w1(t.state.doc,o.pos,s):o.pos;a==null&&(a=o.pos);let u=t.state.tr;if(l){let{node:h}=r;h?h.replace(u):u.deleteSelection()}let c=u.mapping.map(a),f=s.openStart==0&&s.openEnd==0&&s.content.childCount==1,d=u.doc;if(f?u.replaceRangeWith(c,c,s.content.firstChild):u.replaceRange(c,c,s),u.doc.eq(d))return;let p=u.doc.resolve(c);if(f&&z.isSelectable(s.content.firstChild)&&p.nodeAfter&&p.nodeAfter.sameMarkup(s.content.firstChild))u.setSelection(new z(p));else{let h=u.mapping.map(a);u.mapping.maps[u.mapping.maps.length-1].forEach((m,k,g,y)=>h=y),u.setSelection(lc(t,p,u.doc.resolve(h)))}t.focus(),t.dispatch(u.setMeta("uiEvent","drop"))};Ae.focus=t=>{t.input.lastFocus=Date.now(),t.focused||(t.domObserver.stop(),t.dom.classList.add("ProseMirror-focused"),t.domObserver.start(),t.focused=!0,setTimeout(()=>{t.docView&&t.hasFocus()&&!t.domObserver.currentSelection.eq(t.domSelectionRange())&&$t(t)},20))};Ae.blur=(t,e)=>{let n=e;t.focused&&(t.domObserver.stop(),t.dom.classList.remove("ProseMirror-focused"),t.domObserver.start(),n.relatedTarget&&t.dom.contains(n.relatedTarget)&&t.domObserver.currentSelection.clear(),t.focused=!1)};Ae.beforeinput=(t,e)=>{if(xe&&ct&&e.inputType=="deleteContentBackward"){t.domObserver.flushSoon();let{domChangeCount:r}=t.input;setTimeout(()=>{if(t.input.domChangeCount!=r||(t.dom.blur(),t.focus(),t.someProp("handleKeyDown",o=>o(t,In(8,"Backspace")))))return;let{$cursor:i}=t.state.selection;i&&i.pos>0&&t.dispatch(t.state.tr.delete(i.pos-1,i.pos).scrollIntoView())},50)}};for(let t in Re)Ae[t]=Re[t];function _i(t,e){if(t==e)return!0;for(let n in t)if(t[n]!==e[n])return!1;for(let n in e)if(!(n in t))return!1;return!0}class Ds{constructor(e,n){this.toDOM=e,this.spec=n||jn,this.side=this.spec.side||0}map(e,n,r,i){let{pos:o,deleted:s}=e.mapResult(n.from+i,this.side<0?-1:1);return s?null:new me(o-r,o-r,this)}valid(){return!0}eq(e){return this==e||e instanceof Ds&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&_i(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class dn{constructor(e,n){this.attrs=e,this.spec=n||jn}map(e,n,r,i){let o=e.map(n.from+i,this.spec.inclusiveStart?-1:1)-r,s=e.map(n.to+i,this.spec.inclusiveEnd?1:-1)-r;return o>=s?null:new me(o,s,this)}valid(e,n){return n.from=e&&(!o||o(l.spec))&&r.push(l.copy(l.from+i,l.to+i))}for(let s=0;se){let l=this.children[s]+1;this.children[s+2].findInner(e-l,n-l,r,i+l,o)}}map(e,n,r){return this==we||e.maps.length==0?this:this.mapInner(e,n,0,0,r||jn)}mapInner(e,n,r,i,o){let s;for(let l=0;l{let u=a+r,c;if(c=Cm(n,l,u)){for(i||(i=this.children.slice());ol&&f.to=e){this.children[l]==e&&(r=this.children[l+2]);break}let o=e+1,s=o+n.content.size;for(let l=0;lo&&a.type instanceof dn){let u=Math.max(o,a.from)-o,c=Math.min(s,a.to)-o;ui.map(e,n,jn));return cr.from(r)}forChild(e,n){if(n.isLeaf)return W.empty;let r=[];for(let i=0;in instanceof W)?e:e.reduce((n,r)=>n.concat(r instanceof W?r:r.members),[]))}}};function pk(t,e,n,r,i,o,s){let l=t.slice();for(let u=0,c=o;u{let k=m-h-(p-d);for(let g=0;gy+c-f)continue;let S=l[g]+c-f;p>=S?l[g+1]=d<=S?-2:-1:d>=c&&k&&(l[g]+=k,l[g+1]+=k)}f+=k}),c=n.maps[u].map(c,-1)}let a=!1;for(let u=0;u=r.content.size){a=!0;continue}let d=n.map(t[u+1]+o,-1),p=d-i,{index:h,offset:m}=r.content.findIndex(f),k=r.maybeChild(h);if(k&&m==f&&m+k.nodeSize==p){let g=l[u+2].mapInner(n,k,c+1,t[u]+o+1,s);g!=we?(l[u]=f,l[u+1]=p,l[u+2]=g):(l[u+1]=-2,a=!0)}else a=!0}if(a){let u=mk(l,t,e,n,i,o,s),c=Ts(u,r,0,s);e=c.local;for(let f=0;fn&&s.to{let u=Cm(t,l,a+n);if(u){o=!0;let c=Ts(u,l,n+a+1,r);c!=we&&i.push(a,a+l.nodeSize,c)}});let s=xm(o?Nm(t):t,-n).sort(Hn);for(let l=0;l0;)e++;t.splice(e,0,n)}function Wl(t){let e=[];return t.someProp("decorations",n=>{let r=n(t.state);r&&r!=we&&e.push(r)}),t.cursorWrapper&&e.push(W.create(t.state.doc,[t.cursorWrapper.deco])),vm.from(e)}const gk={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},yk=Be&&fn<=11;let Sk=class{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}};class kk{constructor(e,n){this.view=e,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new Sk,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let i=0;ii.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():this.flush()}),yk&&(this.onCharData=r=>{this.queue.push({target:r.target,type:"characterData",oldValue:r.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,gk)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let n=0;nthis.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(Zf(this.view)){if(this.suppressingSelectionUpdates)return $t(this.view);if(Be&&fn<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Qn(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let n=new Set,r;for(let o=e.focusNode;o;o=Bi(o))n.add(o);for(let o=e.anchorNode;o;o=Bi(o))if(n.has(o)){r=o;break}let i=r&&this.view.docView.nearestDesc(r);if(i&&i.ignoreMutation({type:"selection",target:r.nodeType==3?r.parentNode:r}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let n=this.pendingRecords();n.length&&(this.queue=[]);let r=e.domSelectionRange(),i=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&Zf(e)&&!this.ignoreSelectionChange(r),o=-1,s=-1,l=!1,a=[];if(e.editable)for(let c=0;c1){let c=a.filter(f=>f.nodeName=="BR");if(c.length==2){let f=c[0],d=c[1];f.parentNode&&f.parentNode.parentNode==d.parentNode?d.remove():f.remove()}}let u=null;o<0&&i&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)-1||i)&&(o>-1&&(e.docView.markDirty(o,s),wk(e)),this.handleDOMChange(o,s,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||$t(e),this.currentSelection.set(r))}registerMutation(e,n){if(n.indexOf(e.target)>-1)return null;let r=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(r==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!r||r.ignoreMutation(e))return null;if(e.type=="childList"){for(let c=0;ci;k--){let g=r.childNodes[k-1],y=g.pmViewDesc;if(g.nodeName=="BR"&&!y){o=k;break}if(!y||y.size)break}let f=t.state.doc,d=t.someProp("domParser")||Li.fromSchema(t.state.schema),p=f.resolve(s),h=null,m=d.parse(r,{topNode:p.parent,topMatch:p.parent.contentMatchAt(p.index()),topOpen:!0,from:i,to:o,preserveWhitespace:p.parent.type.whitespace=="pre"?"full":!0,findPositions:u,ruleFromNode:Ck,context:p});if(u&&u[0].pos!=null){let k=u[0].pos,g=u[1]&&u[1].pos;g==null&&(g=k),h={anchor:k+s,head:g+s}}return{doc:m,sel:h,from:s,to:l}}function Ck(t){let e=t.pmViewDesc;if(e)return e.parseRule();if(t.nodeName=="BR"&&t.parentNode){if(Te&&/^(ul|ol)$/i.test(t.parentNode.nodeName)){let n=document.createElement("div");return n.appendChild(document.createElement("li")),{skip:n}}else if(t.parentNode.lastChild==t||Te&&/^(tr|table)$/i.test(t.parentNode.nodeName))return{ignore:!0}}else if(t.nodeName=="IMG"&&t.getAttribute("mark-placeholder"))return{ignore:!0};return null}const Nk=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function Mk(t,e,n,r,i){let o=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,e<0){let P=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,A=sc(t,P);if(A&&!t.state.selection.eq(A)){if(xe&&ct&&t.input.lastKeyCode===13&&Date.now()-100st(t,In(13,"Enter"))))return;let H=t.state.tr.setSelection(A);P=="pointer"?H.setMeta("pointer",!0):P=="key"&&H.scrollIntoView(),o&&H.setMeta("composition",o),t.dispatch(H)}return}let s=t.state.doc.resolve(e),l=s.sharedDepth(n);e=s.before(l+1),n=t.state.doc.resolve(n).after(l+1);let a=t.state.selection,u=xk(t,e,n),c=t.state.doc,f=c.slice(u.from,u.to),d,p;t.input.lastKeyCode===8&&Date.now()-100Date.now()-225||ct)&&i.some(P=>P.nodeType==1&&!Nk.test(P.nodeName))&&(!h||h.endA>=h.endB)&&t.someProp("handleKeyDown",P=>P(t,In(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!h)if(r&&a instanceof B&&!a.empty&&a.$head.sameParent(a.$anchor)&&!t.composing&&!(u.sel&&u.sel.anchor!=u.sel.head))h={start:a.from,endA:a.to,endB:a.to};else{if(u.sel){let P=cd(t,t.state.doc,u.sel);if(P&&!P.eq(t.state.selection)){let A=t.state.tr.setSelection(P);o&&A.setMeta("composition",o),t.dispatch(A)}}return}if(xe&&t.cursorWrapper&&u.sel&&u.sel.anchor==t.cursorWrapper.deco.from&&u.sel.head==u.sel.anchor){let P=h.endB-h.start;u.sel={anchor:u.sel.anchor+P,head:u.sel.anchor+P}}t.input.domChangeCount++,t.state.selection.fromt.state.selection.from&&h.start<=t.state.selection.from+2&&t.state.selection.from>=u.from?h.start=t.state.selection.from:h.endA=t.state.selection.to-2&&t.state.selection.to<=u.to&&(h.endB+=t.state.selection.to-h.endA,h.endA=t.state.selection.to)),Be&&fn<=11&&h.endB==h.start+1&&h.endA==h.start&&h.start>u.from&&u.doc.textBetween(h.start-u.from-1,h.start-u.from+1)=="  "&&(h.start--,h.endA--,h.endB--);let m=u.doc.resolveNoCache(h.start-u.from),k=u.doc.resolveNoCache(h.endB-u.from),g=c.resolve(h.start),y=m.sameParent(k)&&m.parent.inlineContent&&g.end()>=h.endA,S;if((br&&t.input.lastIOSEnter>Date.now()-225&&(!y||i.some(P=>P.nodeName=="DIV"||P.nodeName=="P"))||!y&&m.posP(t,In(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>h.start&&Ok(c,h.start,h.endA,m,k)&&t.someProp("handleKeyDown",P=>P(t,In(8,"Backspace")))){ct&&xe&&t.domObserver.suppressSelectionUpdates();return}xe&&ct&&h.endB==h.start&&(t.input.lastAndroidDelete=Date.now()),ct&&!y&&m.start()!=k.start()&&k.parentOffset==0&&m.depth==k.depth&&u.sel&&u.sel.anchor==u.sel.head&&u.sel.head==h.endA&&(h.endB-=2,k=u.doc.resolveNoCache(h.endB-u.from),setTimeout(()=>{t.someProp("handleKeyDown",function(P){return P(t,In(13,"Enter"))})},20));let w=h.start,M=h.endA,E,O,T;if(y){if(m.pos==k.pos)Be&&fn<=11&&m.parentOffset==0&&(t.domObserver.suppressSelectionUpdates(),setTimeout(()=>$t(t),20)),E=t.state.tr.delete(w,M),O=c.resolve(h.start).marksAcross(c.resolve(h.endA));else if(h.endA==h.endB&&(T=Ek(m.parent.content.cut(m.parentOffset,k.parentOffset),g.parent.content.cut(g.parentOffset,h.endA-g.start()))))E=t.state.tr,T.type=="add"?E.addMark(w,M,T.mark):E.removeMark(w,M,T.mark);else if(m.parent.child(m.index()).isText&&m.index()==k.index()-(k.textOffset?0:1)){let P=m.parent.textBetween(m.parentOffset,k.parentOffset);if(t.someProp("handleTextInput",A=>A(t,w,M,P)))return;E=t.state.tr.insertText(P,w,M)}}if(E||(E=t.state.tr.replace(w,M,u.doc.slice(h.start-u.from,h.endB-u.from))),u.sel){let P=cd(t,E.doc,u.sel);P&&!(xe&&ct&&t.composing&&P.empty&&(h.start!=h.endB||t.input.lastAndroidDeletee.content.size?null:lc(t,e.resolve(n.anchor),e.resolve(n.head))}function Ek(t,e){let n=t.firstChild.marks,r=e.firstChild.marks,i=n,o=r,s,l,a;for(let c=0;cc.mark(l.addToSet(c.marks));else if(i.length==0&&o.length==1)l=o[0],s="remove",a=c=>c.mark(l.removeFromSet(c.marks));else return null;let u=[];for(let c=0;cn||Ul(s,!0,!1)0&&(e||t.indexAfter(r)==t.node(r).childCount);)r--,i++,e=!1;if(n){let o=t.node(r).maybeChild(t.indexAfter(r));for(;o&&!o.isLeaf;)o=o.firstChild,i++}return i}function Dk(t,e,n,r,i){let o=t.findDiffStart(e,n);if(o==null)return null;let{a:s,b:l}=t.findDiffEnd(e,n+t.size,n+e.size);if(i=="end"){let a=Math.max(0,o-Math.min(s,l));r-=s+a-o}if(s=s?o-r:0;o-=a,o&&o=l?o-r:0;o-=a,o&&o=56320&&e<=57343&&n>=55296&&n<=56319}class Tk{constructor(e,n){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new YS,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(gd),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):typeof e=="function"?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=pd(this),hd(this),this.nodeViews=md(this),this.docView=Kf(this.state.doc,dd(this),Wl(this),this.dom,this),this.domObserver=new kk(this,(r,i,o,s)=>Mk(this,r,i,o,s)),this.domObserver.start(),GS(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let n in e)this._props[n]=e[n];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&La(this);let n=this._props;this._props=e,e.plugins&&(e.plugins.forEach(gd),this.directPlugins=e.plugins),this.updateStateInner(e.state,n)}setProps(e){let n={};for(let r in this._props)n[r]=this._props[r];n.state=this.state;for(let r in e)n[r]=e[r];this.update(n)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,n){var r;let i=this.state,o=!1,s=!1;e.storedMarks&&this.composing&&(ym(this),s=!0),this.state=e;let l=i.plugins!=e.plugins||this._props.plugins!=n.plugins;if(l||this._props.plugins!=n.plugins||this._props.nodeViews!=n.nodeViews){let p=md(this);Rk(p,this.nodeViews)&&(this.nodeViews=p,o=!0)}(l||n.handleDOMEvents!=this._props.handleDOMEvents)&&La(this),this.editable=pd(this),hd(this);let a=Wl(this),u=dd(this),c=i.plugins!=e.plugins&&!i.doc.eq(e.doc)?"reset":e.scrollToSelection>i.scrollToSelection?"to selection":"preserve",f=o||!this.docView.matchesNode(e.doc,u,a);(f||!e.selection.eq(i.selection))&&(s=!0);let d=c=="preserve"&&s&&this.dom.style.overflowAnchor==null&&fS(this);if(s){this.domObserver.stop();let p=f&&(Be||xe)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&Ak(i.selection,e.selection);if(f){let h=xe?this.trackWrites=this.domSelectionRange().focusNode:null;(o||!this.docView.update(e.doc,u,a,this))&&(this.docView.updateOuterDeco([]),this.docView.destroy(),this.docView=Kf(e.doc,u,a,this.dom,this)),h&&!this.trackWrites&&(p=!0)}p||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&bS(this))?$t(this,p):(im(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(i),!((r=this.dragging)===null||r===void 0)&&r.node&&!i.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,i),c=="reset"?this.dom.scrollTop=0:c=="to selection"?this.scrollToSelection():d&&dS(d)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!this.someProp("handleScrollToSelection",n=>n(this)))if(this.state.selection instanceof z){let n=this.docView.domAfterPos(this.state.selection.from);n.nodeType==1&&_f(this,n.getBoundingClientRect(),e)}else _f(this,this.coordsAtPos(this.state.selection.head,1),e)}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let n=0;n0&&this.state.doc.nodeAt(o))==r.node&&(i=o)}this.dragging=new km(e.slice,e.move,i<0?void 0:z.create(this.state.doc,i))}someProp(e,n){let r=this._props&&this._props[e],i;if(r!=null&&(i=n?n(r):r))return i;for(let s=0;sn.ownerDocument.getSelection()),this._root=n}return e||document}updateRoot(){this._root=null}posAtCoords(e){return SS(this,e)}coordsAtPos(e,n=1){return Kp(this,e,n)}domAtPos(e,n=0){return this.docView.domFromPos(e,n)}nodeDOM(e){let n=this.docView.descAt(e);return n?n.nodeDOM:null}posAtDOM(e,n,r=-1){let i=this.docView.posFromDOM(e,n,r);if(i==null)throw new RangeError("DOM position not inside the editor");return i}endOfTextblock(e,n){return CS(this,n||this.state,e)}pasteHTML(e,n){return $i(this,"",e,!1,n||new ClipboardEvent("paste"))}pasteText(e,n){return $i(this,e,null,!0,n||new ClipboardEvent("paste"))}destroy(){this.docView&&(XS(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Wl(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null)}get isDestroyed(){return this.docView==null}dispatchEvent(e){return ek(this,e)}dispatch(e){let n=this._props.dispatchTransaction;n?n.call(this,e):this.updateState(this.state.apply(e))}domSelectionRange(){return Te&&this.root.nodeType===11&&iS(this.dom.ownerDocument)==this.dom?vk(this):this.domSelection()}domSelection(){return this.root.getSelection()}}function dd(t){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(t.editable),t.someProp("attributes",n=>{if(typeof n=="function"&&(n=n(t.state)),n)for(let r in n)r=="class"?e.class+=" "+n[r]:r=="style"?e.style=(e.style?e.style+";":"")+n[r]:!e[r]&&r!="contenteditable"&&r!="nodeName"&&(e[r]=String(n[r]))}),e.translate||(e.translate="no"),[me.node(0,t.state.doc.content.size,e)]}function hd(t){if(t.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),t.cursorWrapper={dom:e,deco:me.widget(t.state.selection.head,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function pd(t){return!t.someProp("editable",e=>e(t.state)===!1)}function Ak(t,e){let n=Math.min(t.$anchor.sharedDepth(t.head),e.$anchor.sharedDepth(e.head));return t.$anchor.start(n)!=e.$anchor.start(n)}function md(t){let e=Object.create(null);function n(r){for(let i in r)Object.prototype.hasOwnProperty.call(e,i)||(e[i]=r[i])}return t.someProp("nodeViews",n),t.someProp("markViews",n),e}function Rk(t,e){let n=0,r=0;for(let i in t){if(t[i]!=e[i])return!0;n++}for(let i in e)r++;return n!=r}function gd(t){if(t.spec.state||t.spec.filterTransaction||t.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}class ee extends I{constructor(e){super(e,e)}map(e,n){let r=e.resolve(n.map(this.head));return ee.valid(r)?new ee(r):I.near(r)}content(){return x.empty}eq(e){return e instanceof ee&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new ee(e.resolve(n.pos))}getBookmark(){return new hc(this.anchor)}static valid(e){let n=e.parent;if(n.isTextblock||!Pk(e)||!zk(e))return!1;let r=n.type.spec.allowGapCursor;if(r!=null)return r;let i=n.contentMatchAt(e.index()).defaultType;return i&&i.isTextblock}static findGapCursorFrom(e,n,r=!1){e:for(;;){if(!r&&ee.valid(e))return e;let i=e.pos,o=null;for(let s=e.depth;;s--){let l=e.node(s);if(n>0?e.indexAfter(s)0){o=l.child(n>0?e.indexAfter(s):e.index(s)-1);break}else if(s==0)return null;i+=n;let a=e.doc.resolve(i);if(ee.valid(a))return a}for(;;){let s=n>0?o.firstChild:o.lastChild;if(!s){if(o.isAtom&&!o.isText&&!z.isSelectable(o)){e=e.doc.resolve(i+o.nodeSize*n),r=!1;continue e}break}o=s,i+=n;let l=e.doc.resolve(i);if(ee.valid(l))return l}return null}}}ee.prototype.visible=!1;ee.findFrom=ee.findGapCursorFrom;I.jsonID("gapcursor",ee);class hc{constructor(e){this.pos=e}map(e){return new hc(e.map(this.pos))}resolve(e){let n=e.resolve(this.pos);return ee.valid(n)?new ee(n):I.near(n)}}function Pk(t){for(let e=t.depth;e>=0;e--){let n=t.index(e),r=t.node(e);if(n==0){if(r.type.spec.isolating)return!0;continue}for(let i=r.child(n-1);;i=i.lastChild){if(i.childCount==0&&!i.inlineContent||i.isAtom||i.type.spec.isolating)return!0;if(i.inlineContent)return!1}}return!0}function zk(t){for(let e=t.depth;e>=0;e--){let n=t.indexAfter(e),r=t.node(e);if(n==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let i=r.child(n);;i=i.firstChild){if(i.childCount==0&&!i.inlineContent||i.isAtom||i.type.spec.isolating)return!0;if(i.inlineContent)return!1}}return!0}function Fk(){return new At({props:{decorations:Bk,createSelectionBetween(t,e,n){return e.pos==n.pos&&ee.valid(n)?new ee(n):null},handleClick:bk,handleKeyDown:Ik,handleDOMEvents:{beforeinput:Lk}}})}const Ik=_p({ArrowLeft:Ao("horiz",-1),ArrowRight:Ao("horiz",1),ArrowUp:Ao("vert",-1),ArrowDown:Ao("vert",1)});function Ao(t,e){const n=t=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,i,o){let s=r.selection,l=e>0?s.$to:s.$from,a=s.empty;if(s instanceof B){if(!o.endOfTextblock(n)||l.depth==0)return!1;a=!1,l=r.doc.resolve(e>0?l.after():l.before())}let u=ee.findGapCursorFrom(l,e,a);return u?(i&&i(r.tr.setSelection(new ee(u))),!0):!1}}function bk(t,e,n){if(!t||!t.editable)return!1;let r=t.state.doc.resolve(e);if(!ee.valid(r))return!1;let i=t.posAtCoords({left:n.clientX,top:n.clientY});return i&&i.inside>-1&&z.isSelectable(t.state.doc.nodeAt(i.inside))?!1:(t.dispatch(t.state.tr.setSelection(new ee(r))),!0)}function Lk(t,e){if(e.inputType!="insertCompositionText"||!(t.state.selection instanceof ee))return!1;let{$from:n}=t.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(t.state.schema.nodes.text);if(!r)return!1;let i=v.empty;for(let s=r.length-1;s>=0;s--)i=v.from(r[s].createAndFill(null,i));let o=t.state.tr.replace(n.pos,n.pos,new x(i,0,0));return o.setSelection(B.near(o.doc.resolve(n.pos+1))),t.dispatch(o),!1}function Bk(t){if(!(t.selection instanceof ee))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",W.create(t.doc,[me.widget(t.selection.head,e,{key:"gapcursor"})])}class tr{constructor(e,n,r={}){this.match=e,this.match=e,this.handler=typeof n=="string"?Vk(n):n,this.undoable=r.undoable!==!1,this.inCode=r.inCode||!1}}function Vk(t){return function(e,n,r,i){let o=t;if(n[1]){let s=n[0].lastIndexOf(n[1]);o+=n[0].slice(s+n[1].length),r+=s;let l=r-i;l>0&&(o=n[0].slice(s-l,s)+o,r=i)}return e.tr.insertText(o,r,i)}}const $k=500;function _k({rules:t}){let e=new At({state:{init(){return null},apply(n,r){let i=n.getMeta(this);return i||(n.selectionSet||n.docChanged?null:r)}},props:{handleTextInput(n,r,i,o){return yd(n,r,i,o,t,e)},handleDOMEvents:{compositionend:n=>{setTimeout(()=>{let{$cursor:r}=n.state.selection;r&&yd(n,r.pos,r.pos,"",t,e)})}}},isInputRules:!0});return e}function yd(t,e,n,r,i,o){if(t.composing)return!1;let s=t.state,l=s.doc.resolve(e),a=l.parent.textBetween(Math.max(0,l.parentOffset-$k),l.parentOffset,null,"")+r;for(let u=0;u{let a=n instanceof Function?n(o):n,u=i.tr.delete(s,l),c=u.doc.resolve(s),f=c.blockRange(),d=f&&u1(f,e,a);if(!d)return null;u.wrap(f,d);let p=u.doc.resolve(s-1).nodeBefore;return p&&p.type==e&&Zu(u.doc,s-1)&&(!r||r(o,p))&&u.join(s-1),u})}const Uk=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):!1;function jk(t){let e=t.split(/-(?!$)/),n=e[e.length-1];n=="Space"&&(n=" ");let r,i,o,s;for(let l=0;l127)&&(o=Ut[r.keyCode])&&o!=i){let l=e[jl(o,r)];if(l&&l(n.state,n.dispatch,n))return!0}}return!1}}const Mm=65535,Em=Math.pow(2,16);function qk(t,e){return t+e*Em}function Sd(t){return t&Mm}function Qk(t){return(t-(t&Mm))/Em}const Om=1,Dm=2,ss=4,Tm=8;class Ba{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&Tm)>0}get deletedBefore(){return(this.delInfo&(Om|ss))>0}get deletedAfter(){return(this.delInfo&(Dm|ss))>0}get deletedAcross(){return(this.delInfo&ss)>0}}class je{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&je.empty)return je.empty}recover(e){let n=0,r=Sd(e);if(!this.inverted)for(let i=0;ie)break;let u=this.ranges[l+o],c=this.ranges[l+s],f=a+u;if(e<=f){let d=u?e==a?-1:e==f?1:n:n,p=a+i+(d<0?0:c);if(r)return p;let h=e==(n<0?a:f)?null:qk(l/3,e-a),m=e==a?Dm:e==f?Om:ss;return(n<0?e!=a:e!=f)&&(m|=Tm),new Ba(p,m,h)}i+=c-u}return r?e+i:new Ba(e+i,0,null)}touches(e,n){let r=0,i=Sd(n),o=this.inverted?2:1,s=this.inverted?1:2;for(let l=0;le)break;let u=this.ranges[l+o],c=a+u;if(e<=c&&l==i*3)return!0;r+=this.ranges[l+s]-u}return!1}forEach(e){let n=this.inverted?2:1,r=this.inverted?1:2;for(let i=0,o=0;i=0;n--){let i=e.getMirror(n);this.appendMap(e.maps[n].invert(),i!=null&&i>n?r-i-1:void 0)}}invert(){let e=new Ni;return e.appendMappingInverted(this),e}map(e,n=1){if(this.mirror)return this._map(e,n,!0);for(let r=this.from;ro&&a!s.isAtom||!l.type.allowsMarkType(this.mark.type)?s:s.mark(this.mark.addToSet(s.marks)),i),n.openStart,n.openEnd);return oe.fromReplace(e,this.from,this.to,o)}invert(){return new vt(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new ln(n.pos,r.pos,this.mark)}merge(e){return e instanceof ln&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new ln(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,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new ln(n.from,n.to,e.markFromJSON(n.mark))}}Ne.jsonID("addMark",ln);class vt extends Ne{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=new x(pc(n.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),n.openStart,n.openEnd);return oe.fromReplace(e,this.from,this.to,r)}invert(){return new ln(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new vt(n.pos,r.pos,this.mark)}merge(e){return e instanceof vt&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new vt(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,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new vt(n.from,n.to,e.markFromJSON(n.mark))}}Ne.jsonID("removeMark",vt);class an extends Ne{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return oe.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return oe.fromReplace(e,this.pos,this.pos+1,new x(v.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);if(n){let r=this.mark.addToSet(n.marks);if(r.length==n.marks.length){for(let i=0;ir.pos?null:new Ct(n.pos,r.pos,i,o,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number"||typeof n.gapFrom!="number"||typeof n.gapTo!="number"||typeof n.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new Ct(n.from,n.to,n.gapFrom,n.gapTo,x.fromJSON(e,n.slice),n.insert,!!n.structure)}}Ne.jsonID("replaceAround",Ct);function Va(t,e,n){let r=t.resolve(e),i=n-e,o=r.depth;for(;i>0&&o>0&&r.indexAfter(o)==r.node(o).childCount;)o--,i--;if(i>0){let s=r.node(o).maybeChild(r.indexAfter(o));for(;i>0;){if(!s||s.isLeaf)return!0;s=s.firstChild,i--}}return!1}function Yk(t,e,n,r){let i=[],o=[],s,l;t.doc.nodesBetween(e,n,(a,u,c)=>{if(!a.isInline)return;let f=a.marks;if(!r.isInSet(f)&&c.type.allowsMarkType(r.type)){let d=Math.max(u,e),p=Math.min(u+a.nodeSize,n),h=r.addToSet(f);for(let m=0;mt.step(a)),o.forEach(a=>t.step(a))}function Gk(t,e,n,r){let i=[],o=0;t.doc.nodesBetween(e,n,(s,l)=>{if(!s.isInline)return;o++;let a=null;if(r instanceof fo){let u=s.marks,c;for(;c=r.isInSet(u);)(a||(a=[])).push(c),u=c.removeFromSet(u)}else r?r.isInSet(s.marks)&&(a=[r]):a=s.marks;if(a&&a.length){let u=Math.min(l+s.nodeSize,n);for(let c=0;ct.step(new vt(s.from,s.to,s.style)))}function Xk(t,e,n,r=n.contentMatch){let i=t.doc.nodeAt(e),o=[],s=e+1;for(let l=0;l=0;l--)t.step(o[l])}function Zk(t,e,n){let{$from:r,$to:i,depth:o}=e,s=r.before(o+1),l=i.after(o+1),a=s,u=l,c=v.empty,f=0;for(let h=o,m=!1;h>n;h--)m||r.index(h)>0?(m=!0,c=v.from(r.node(h).copy(c)),f++):a--;let d=v.empty,p=0;for(let h=o,m=!1;h>n;h--)m||i.after(h+1)=0;s--){if(r.size){let l=n[s].type.contentMatch.matchFragment(r);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=v.from(n[s].type.create(n[s].attrs,r))}let i=e.start,o=e.end;t.step(new Ct(i,o,i,o,new x(r,0,0),n.length,!0))}function tw(t,e,n,r,i){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let o=t.steps.length;t.doc.nodesBetween(e,n,(s,l)=>{if(s.isTextblock&&!s.hasMarkup(r,i)&&nw(t.doc,t.mapping.slice(o).map(l),r)){t.clearIncompatible(t.mapping.slice(o).map(l,1),r);let a=t.mapping.slice(o),u=a.map(l,1),c=a.map(l+s.nodeSize,1);return t.step(new Ct(u,c,u+1,c-1,new x(v.from(r.create(i,null,s.marks)),0,0),1,!0)),!1}})}function nw(t,e,n){let r=t.resolve(e),i=r.index();return r.parent.canReplaceWith(i,i+1,n)}function rw(t,e,n,r,i){let o=t.doc.nodeAt(e);if(!o)throw new RangeError("No node at given position");n||(n=o.type);let s=n.create(r,null,i||o.marks);if(o.isLeaf)return t.replaceWith(e,e+o.nodeSize,s);if(!n.validContent(o.content))throw new RangeError("Invalid content for node type "+n.name);t.step(new Ct(e,e+o.nodeSize,e+1,e+o.nodeSize-1,new x(v.from(s),0,0),1,!0))}function iw(t,e,n=1,r){let i=t.doc.resolve(e),o=v.empty,s=v.empty;for(let l=i.depth,a=i.depth-n,u=n-1;l>a;l--,u--){o=v.from(i.node(l).copy(o));let c=r&&r[u];s=v.from(c?c.type.create(c.attrs,s):i.node(l).copy(s))}t.step(new Oe(e,e,new x(o.append(s),n,n),!0))}function ow(t,e,n){let r=new Oe(e-n,e+n,x.empty,!0);t.step(r)}function sw(t,e,n){let r=t.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),n))return e;if(r.parentOffset==0)for(let i=r.depth-1;i>=0;i--){let o=r.index(i);if(r.node(i).canReplaceWith(o,o,n))return r.before(i+1);if(o>0)return null}if(r.parentOffset==r.parent.content.size)for(let i=r.depth-1;i>=0;i--){let o=r.indexAfter(i);if(r.node(i).canReplaceWith(o,o,n))return r.after(i+1);if(o0;i--)this.placed=v.from(e.node(i).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let u=this.findFittable();u?this.placeNodes(u):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),n=this.placed.size-this.depth-this.$from.depth,r=this.$from,i=this.close(e<0?this.$to:r.doc.resolve(e));if(!i)return null;let o=this.placed,s=r.depth,l=i.depth;for(;s&&l&&o.childCount==1;)o=o.firstChild.content,s--,l--;let a=new x(o,s,l);return e>-1?new Ct(r.pos,e,this.$to.pos,this.$to.end(),a,n):a.size||r.pos!=this.$to.pos?new Oe(r.pos,i.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let n=this.unplaced.content,r=0,i=this.unplaced.openEnd;r1&&(i=0),o.type.spec.isolating&&i<=r){e=r;break}n=o.content}for(let n=1;n<=2;n++)for(let r=n==1?e:this.unplaced.openStart;r>=0;r--){let i,o=null;r?(o=Jl(this.unplaced.content,r-1).firstChild,i=o.content):i=this.unplaced.content;let s=i.firstChild;for(let l=this.depth;l>=0;l--){let{type:a,match:u}=this.frontier[l],c,f=null;if(n==1&&(s?u.matchType(s.type)||(f=u.fillBefore(v.from(s),!1)):o&&a.compatibleContent(o.type)))return{sliceDepth:r,frontierDepth:l,parent:o,inject:f};if(n==2&&s&&(c=u.findWrapping(s.type)))return{sliceDepth:r,frontierDepth:l,parent:o,wrap:c};if(o&&u.matchType(o.type))break}}}openMore(){let{content:e,openStart:n,openEnd:r}=this.unplaced,i=Jl(e,n);return!i.childCount||i.firstChild.isLeaf?!1:(this.unplaced=new x(e,n+1,Math.max(r,i.size+n>=e.size-r?n+1:0)),!0)}dropNode(){let{content:e,openStart:n,openEnd:r}=this.unplaced,i=Jl(e,n);if(i.childCount<=1&&n>0){let o=e.size-n<=n+i.size;this.unplaced=new x(pi(e,n-1,1),n-1,o?n-1:r)}else this.unplaced=new x(pi(e,n,1),n,r)}placeNodes({sliceDepth:e,frontierDepth:n,parent:r,inject:i,wrap:o}){for(;this.depth>n;)this.closeFrontierNode();if(o)for(let m=0;m1||a==0||m.content.size)&&(f=k,c.push(Rm(m.mark(d.allowedMarks(m.marks)),u==1?a:0,u==l.childCount?p:-1)))}let h=u==l.childCount;h||(p=-1),this.placed=mi(this.placed,n,v.from(c)),this.frontier[n].match=f,h&&p<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let m=0,k=l;m1&&i==this.$to.end(--r);)++i;return i}findCloseLevel(e){e:for(let n=Math.min(this.depth,e.depth);n>=0;n--){let{match:r,type:i}=this.frontier[n],o=n=0;l--){let{match:a,type:u}=this.frontier[l],c=Kl(e,l,u,a,!0);if(!c||c.childCount)continue e}return{depth:n,fit:s,move:o?e.doc.resolve(e.after(n+1)):e}}}}close(e){let n=this.findCloseLevel(e);if(!n)return null;for(;this.depth>n.depth;)this.closeFrontierNode();n.fit.childCount&&(this.placed=mi(this.placed,n.depth,n.fit)),e=n.move;for(let r=n.depth+1;r<=e.depth;r++){let i=e.node(r),o=i.type.contentMatch.fillBefore(i.content,!0,e.index(r));this.openFrontierNode(i.type,i.attrs,o)}return e}openFrontierNode(e,n=null,r){let i=this.frontier[this.depth];i.match=i.match.matchType(e),this.placed=mi(this.placed,this.depth,v.from(e.create(n,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(v.empty,!0);n.childCount&&(this.placed=mi(this.placed,this.frontier.length,n))}}function pi(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(pi(t.firstChild.content,e-1,n)))}function mi(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(mi(t.lastChild.content,e-1,n)))}function Jl(t,e){for(let n=0;n1&&(r=r.replaceChild(0,Rm(r.firstChild,e-1,r.childCount==1?n-1:0))),e>0&&(r=t.type.contentMatch.fillBefore(r).append(r),n<=0&&(r=r.append(t.type.contentMatch.matchFragment(r).fillBefore(v.empty,!0)))),t.copy(r)}function Kl(t,e,n,r,i){let o=t.node(e),s=i?t.indexAfter(e):t.index(e);if(s==o.childCount&&!n.compatibleContent(o.type))return null;let l=r.fillBefore(o.content,!0,s);return l&&!uw(n,o.content,s)?l:null}function uw(t,e,n){for(let r=n;r0;d--,p--){let h=i.node(d).type.spec;if(h.defining||h.definingAsContext||h.isolating)break;s.indexOf(d)>-1?l=d:i.before(d)==p&&s.splice(1,0,-d)}let a=s.indexOf(l),u=[],c=r.openStart;for(let d=r.content,p=0;;p++){let h=d.firstChild;if(u.push(h),p==r.openStart)break;d=h.content}for(let d=c-1;d>=0;d--){let p=u[d],h=cw(p.type);if(h&&!p.sameMarkup(i.node(Math.abs(l)-1)))c=d;else if(h||!p.type.isTextblock)break}for(let d=r.openStart;d>=0;d--){let p=(d+c+1)%(r.openStart+1),h=u[p];if(h)for(let m=0;m=0&&(t.replace(e,n,r),!(t.steps.length>f));d--){let p=s[d];p<0||(e=i.before(p),n=o.after(p))}}function Pm(t,e,n,r,i){if(er){let o=i.contentMatchAt(0),s=o.fillBefore(t).append(t);t=s.append(o.matchFragment(s).fillBefore(v.empty,!0))}return t}function dw(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let i=sw(t.doc,e,r.type);i!=null&&(e=n=i)}t.replaceRange(e,n,new x(v.from(r),0,0))}function hw(t,e,n){let r=t.doc.resolve(e),i=t.doc.resolve(n),o=zm(r,i);for(let s=0;s0&&(a||r.node(l-1).canReplace(r.index(l-1),i.indexAfter(l-1))))return t.delete(r.before(l),i.after(l))}for(let s=1;s<=r.depth&&s<=i.depth;s++)if(e-r.start(s)==r.depth-s&&n>r.end(s)&&i.end(s)-n!=i.depth-s)return t.delete(r.before(s),n);t.delete(e,n)}function zm(t,e){let n=[],r=Math.min(t.depth,e.depth);for(let i=r;i>=0;i--){let o=t.start(i);if(oe.pos+(e.depth-i)||t.node(i).type.spec.isolating||e.node(i).type.spec.isolating)break;(o==e.start(i)||i==t.depth&&i==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&i&&e.start(i-1)==o-1)&&n.push(i)}return n}class Mr extends Ne{constructor(e,n,r){super(),this.pos=e,this.attr=n,this.value=r}apply(e){let n=e.nodeAt(this.pos);if(!n)return oe.fail("No node at attribute step's position");let r=Object.create(null);for(let o in n.attrs)r[o]=n.attrs[o];r[this.attr]=this.value;let i=n.type.create(r,null,n.marks);return oe.fromReplace(e,this.pos,this.pos+1,new x(v.from(i),0,n.isLeaf?0:1))}getMap(){return je.empty}invert(e){return new Mr(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Mr(n.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.pos!="number"||typeof n.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new Mr(n.pos,n.attr,n.value)}}Ne.jsonID("attr",Mr);class Wi extends Ne{constructor(e,n){super(),this.attr=e,this.value=n}apply(e){let n=Object.create(null);for(let i in e.attrs)n[i]=e.attrs[i];n[this.attr]=this.value;let r=e.type.create(n,e.content,e.marks);return oe.ok(r)}getMap(){return je.empty}invert(e){return new Wi(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new Wi(n.attr,n.value)}}Ne.jsonID("docAttr",Wi);let Br=class extends Error{};Br=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};Br.prototype=Object.create(Error.prototype);Br.prototype.constructor=Br;Br.prototype.name="TransformError";class pw{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Ni}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new Br(n.failed);return this}maybeStep(e){let n=e.apply(this.doc);return n.failed||this.addStep(e,n.doc),n}get docChanged(){return this.steps.length>0}addStep(e,n){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=n}replace(e,n=e,r=x.empty){let i=lw(this.doc,e,n,r);return i&&this.step(i),this}replaceWith(e,n,r){return this.replace(e,n,new x(v.from(r),0,0))}delete(e,n){return this.replace(e,n,x.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,r){return fw(this,e,n,r),this}replaceRangeWith(e,n,r){return dw(this,e,n,r),this}deleteRange(e,n){return hw(this,e,n),this}lift(e,n){return Zk(this,e,n),this}join(e,n=1){return ow(this,e,n),this}wrap(e,n){return ew(this,e,n),this}setBlockType(e,n=e,r,i=null){return tw(this,e,n,r,i),this}setNodeMarkup(e,n,r=null,i){return rw(this,e,n,r,i),this}setNodeAttribute(e,n,r){return this.step(new Mr(e,n,r)),this}setDocAttribute(e,n){return this.step(new Wi(e,n)),this}addNodeMark(e,n){return this.step(new an(e,n)),this}removeNodeMark(e,n){if(!(n instanceof _)){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(n=n.isInSet(r.marks),!n)return this}return this.step(new Lr(e,n)),this}split(e,n=1,r){return iw(this,e,n,r),this}addMark(e,n,r){return Yk(this,e,n,r),this}removeMark(e,n,r){return Gk(this,e,n,r),this}clearIncompatible(e,n,r){return Xk(this,e,n,r),this}}var $a,_a;if(typeof WeakMap<"u"){let t=new WeakMap;$a=e=>t.get(e),_a=(e,n)=>(t.set(e,n),n)}else{const t=[];let n=0;$a=r=>{for(let i=0;i(n==10&&(n=0),t[n++]=r,t[n++]=i)}var re=class{constructor(t,e,n,r){this.width=t,this.height=e,this.map=n,this.problems=r}findCell(t){for(let e=0;e=n){(o||(o=[])).push({type:"overlong_rowspan",pos:c,n:g-S});break}const w=i+S*e;for(let M=0;Mr&&(o+=u.attrs.colspan)}}for(let s=0;s1&&(n=!0)}e==-1?e=o:e!=o&&(e=Math.max(e,o))}return e}function yw(t,e,n){t.problems||(t.problems=[]);const r={};for(let i=0;iNumber(s)):null,i=Number(t.getAttribute("colspan")||1),o={colspan:i,rowspan:Number(t.getAttribute("rowspan")||1),colwidth:r&&r.length==i?r:null};for(const s in e){const l=e[s].getFromDOM,a=l&&l(t);a!=null&&(o[s]=a)}return o}function wd(t,e){const n={};t.attrs.colspan!=1&&(n.colspan=t.attrs.colspan),t.attrs.rowspan!=1&&(n.rowspan=t.attrs.rowspan),t.attrs.colwidth&&(n["data-colwidth"]=t.attrs.colwidth.join(","));for(const r in e){const i=e[r].setDOMAttr;i&&i(t.attrs[r],n)}return n}function kw(t){const e=t.cellAttributes||{},n={colspan:{default:1},rowspan:{default:1},colwidth:{default:null}};for(const r in e)n[r]={default:e[r].default};return{table:{content:"table_row+",tableRole:"table",isolating:!0,group:t.tableGroup,parseDOM:[{tag:"table"}],toDOM(){return["table",["tbody",0]]}},table_row:{content:"(table_cell | table_header)*",tableRole:"row",parseDOM:[{tag:"tr"}],toDOM(){return["tr",0]}},table_cell:{content:t.cellContent,attrs:n,tableRole:"cell",isolating:!0,parseDOM:[{tag:"td",getAttrs:r=>kd(r,e)}],toDOM(r){return["td",wd(r,e),0]}},table_header:{content:t.cellContent,attrs:n,tableRole:"header_cell",isolating:!0,parseDOM:[{tag:"th",getAttrs:r=>kd(r,e)}],toDOM(r){return["th",wd(r,e),0]}}}}function Dt(t){let e=t.cached.tableNodeTypes;if(!e){e=t.cached.tableNodeTypes={};for(const n in t.nodes){const r=t.nodes[n],i=r.spec.tableRole;i&&(e[i]=r)}}return e}var tn=new po("selectingCells");function yo(t){for(let e=t.depth-1;e>0;e--)if(t.node(e).type.spec.tableRole=="row")return t.node(0).resolve(t.before(e+1));return null}function mc(t){const e=t.selection.$head;for(let n=e.depth;n>0;n--)if(e.node(n).type.spec.tableRole=="row")return!0;return!1}function Fm(t){const e=t.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 n=yo(e.$head)||ww(e.$head);if(n)return n;throw new RangeError(`No cell found around position ${e.head}`)}function ww(t){for(let e=t.nodeAfter,n=t.pos;e;e=e.firstChild,n++){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return t.doc.resolve(n)}for(let e=t.nodeBefore,n=t.pos;e;e=e.lastChild,n--){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return t.doc.resolve(n-e.nodeSize)}}function Wa(t){return t.parent.type.spec.tableRole=="row"&&!!t.nodeAfter}function gc(t,e){return t.depth==e.depth&&t.pos>=e.start(-1)&&t.pos<=e.end(-1)}function Im(t,e,n){const r=t.node(-1),i=re.get(r),o=t.start(-1),s=i.nextCell(t.pos-o,e,n);return s==null?null:t.node(0).resolve(o+s)}function Vr(t,e,n=1){const r={...t,colspan:t.colspan-n};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(e,n),r.colwidth.some(i=>i>0)||(r.colwidth=null)),r}var ce=class Pt extends I{constructor(e,n=e){const r=e.node(-1),i=re.get(r),o=e.start(-1),s=i.rectBetween(e.pos-o,n.pos-o),l=e.node(0),a=i.cellsInRect(s).filter(c=>c!=n.pos-o);a.unshift(n.pos-o);const u=a.map(c=>{const f=r.nodeAt(c);if(!f)throw RangeError(`No cell with offset ${c} found`);const d=o+c+1;return new Rp(l.resolve(d),l.resolve(d+f.content.size))});super(u[0].$from,u[0].$to,u),this.$anchorCell=e,this.$headCell=n}map(e,n){const r=e.resolve(n.map(this.$anchorCell.pos)),i=e.resolve(n.map(this.$headCell.pos));if(Wa(r)&&Wa(i)&&gc(r,i)){const o=this.$anchorCell.node(-1)!=r.node(-1);return o&&this.isRowSelection()?Pt.rowSelection(r,i):o&&this.isColSelection()?Pt.colSelection(r,i):new Pt(r,i)}return B.between(r,i)}content(){const e=this.$anchorCell.node(-1),n=re.get(e),r=this.$anchorCell.start(-1),i=n.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),o={},s=[];for(let a=i.top;a0||k>0){let g=h.attrs;if(m>0&&(g=Vr(g,0,m)),k>0&&(g=Vr(g,g.colspan-k,k)),p.lefti.bottom){const g={...h.attrs,rowspan:Math.min(p.bottom,i.bottom)-Math.max(p.top,i.top)};p.top0)return!1;const r=e+this.$anchorCell.nodeAfter.attrs.rowspan,i=n+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(r,i)==this.$headCell.node(-1).childCount}static colSelection(e,n=e){const r=e.node(-1),i=re.get(r),o=e.start(-1),s=i.findCell(e.pos-o),l=i.findCell(n.pos-o),a=e.node(0);return s.top<=l.top?(s.top>0&&(e=a.resolve(o+i.map[s.left])),l.bottom0&&(n=a.resolve(o+i.map[l.left])),s.bottom0)return!1;const s=i+this.$anchorCell.nodeAfter.attrs.colspan,l=o+this.$headCell.nodeAfter.attrs.colspan;return Math.max(s,l)==n.width}eq(e){return e instanceof Pt&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,n=e){const r=e.node(-1),i=re.get(r),o=e.start(-1),s=i.findCell(e.pos-o),l=i.findCell(n.pos-o),a=e.node(0);return s.left<=l.left?(s.left>0&&(e=a.resolve(o+i.map[s.top*i.width])),l.right0&&(n=a.resolve(o+i.map[l.top*i.width])),s.right{e.push(me.node(r,r+n.nodeSize,{class:"selectedCell"}))}),W.create(t.doc,e)}function Cw({$from:t,$to:e}){if(t.pos==e.pos||t.pos=0&&!(t.after(i+1)=0&&!(e.before(o+1)>e.start(o));o--,r--);return n==r&&/row|table/.test(t.node(i).type.spec.tableRole)}function Nw({$from:t,$to:e}){let n,r;for(let i=t.depth;i>0;i--){const o=t.node(i);if(o.type.spec.tableRole==="cell"||o.type.spec.tableRole==="header_cell"){n=o;break}}for(let i=e.depth;i>0;i--){const o=e.node(i);if(o.type.spec.tableRole==="cell"||o.type.spec.tableRole==="header_cell"){r=o;break}}return n!==r&&e.parentOffset===0}function Mw(t,e,n){const r=(e||t).selection,i=(e||t).doc;let o,s;if(r instanceof z&&(s=r.node.type.spec.tableRole)){if(s=="cell"||s=="header_cell")o=ce.create(i,r.from);else if(s=="row"){const l=i.resolve(r.from+1);o=ce.rowSelection(l,l)}else if(!n){const l=re.get(r.node),a=r.from+1,u=a+l.map[l.width*l.height-1];o=ce.create(i,a+1,u)}}else r instanceof B&&Cw(r)?o=B.create(i,r.from):r instanceof B&&Nw(r)&&(o=B.create(i,r.$from.start(),r.$from.end()));return o&&(e||(e=t.tr)).setSelection(o),e}var Ew=new po("fix-tables");function Lm(t,e,n,r){const i=t.childCount,o=e.childCount;e:for(let s=0,l=0;s{i.type.spec.tableRole=="table"&&(n=Dw(t,i,o,n))};return e?e.doc!=t.doc&&Lm(e.doc,t.doc,0,r):t.doc.descendants(r),n}function Dw(t,e,n,r){const i=re.get(e);if(!i.problems)return r;r||(r=t.tr);const o=[];for(let a=0;a0){let p="cell";c.firstChild&&(p=c.firstChild.type.spec.tableRole);const h=[];for(let k=0;k0&&r>0||e.child(0).type.spec.tableRole=="table");)n--,r--,e=e.child(0).content;const i=e.child(0),o=i.type.spec.tableRole,s=i.type.schema,l=[];if(o=="row")for(let a=0;a=0;s--){const{rowspan:l,colspan:a}=o.child(s).attrs;for(let u=i;u=e.length&&e.push(v.empty),n[i]r&&(d=d.type.createChecked(Vr(d.attrs,d.attrs.colspan,c+d.attrs.colspan-r),d.content)),u.push(d),c+=d.attrs.colspan;for(let p=1;pi&&(f=f.type.create({...f.attrs,rowspan:Math.max(1,i-f.attrs.rowspan)},f.content)),a.push(f)}o.push(v.from(a))}n=o,e=i}return{width:t,height:e,rows:n}}function Pw(t,e,n,r,i,o,s){const l=t.doc.type.schema,a=Dt(l);let u,c;if(i>e.width)for(let f=0,d=0;fe.height){const f=[];for(let h=0,m=(e.height-1)*e.width;h=e.width?!1:n.nodeAt(e.map[m+h]).type==a.header_cell;f.push(k?c||(c=a.header_cell.createAndFill()):u||(u=a.cell.createAndFill()))}const d=a.row.create(null,v.from(f)),p=[];for(let h=e.height;h{if(!i)return!1;const o=n.selection;if(o instanceof ce)return ls(n,r,I.near(o.$headCell,e));if(t!="horiz"&&!o.empty)return!1;const s=Bm(i,t,e);if(s==null)return!1;if(t=="horiz")return ls(n,r,I.near(n.doc.resolve(o.head+e),e));{const l=n.doc.resolve(s),a=Im(l,t,e);let u;return a?u=I.near(a,1):e<0?u=I.near(n.doc.resolve(l.before(-1)),-1):u=I.near(n.doc.resolve(l.after(-1)),1),ls(n,r,u)}}}function Po(t,e){return(n,r,i)=>{if(!i)return!1;const o=n.selection;let s;if(o instanceof ce)s=o;else{const a=Bm(i,t,e);if(a==null)return!1;s=new ce(n.doc.resolve(a))}const l=Im(s.$headCell,t,e);return l?ls(n,r,new ce(s.$anchorCell,l)):!1}}function zo(t,e){const n=t.selection;if(!(n instanceof ce))return!1;if(e){const r=t.tr,i=Dt(t.schema).cell.createAndFill().content;n.forEachCell((o,s)=>{o.content.eq(i)||r.replace(r.mapping.map(s+1),r.mapping.map(s+o.nodeSize-1),new x(i,0,0))}),r.docChanged&&e(r)}return!0}function Fw(t,e){const n=t.state.doc,r=yo(n.resolve(e));return r?(t.dispatch(t.state.tr.setSelection(new ce(r))),!0):!1}function Iw(t,e,n){if(!mc(t.state))return!1;let r=Tw(n);const i=t.state.selection;if(i instanceof ce){r||(r={width:1,height:1,rows:[v.from(Ua(Dt(t.state.schema).cell,n))]});const o=i.$anchorCell.node(-1),s=i.$anchorCell.start(-1),l=re.get(o).rectBetween(i.$anchorCell.pos-s,i.$headCell.pos-s);return r=Rw(r,l.right-l.left,l.bottom-l.top),Cd(t.state,t.dispatch,s,l,r),!0}else if(r){const o=Fm(t.state),s=o.start(-1);return Cd(t.state,t.dispatch,s,re.get(o.node(-1)).findCell(o.pos-s),r),!0}else return!1}function bw(t,e){var n;if(e.ctrlKey||e.metaKey)return;const r=Nd(t,e.target);let i;if(e.shiftKey&&t.state.selection instanceof ce)o(t.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&r&&(i=yo(t.state.selection.$anchor))!=null&&((n=ql(t,e))==null?void 0:n.pos)!=i.pos)o(i,e),e.preventDefault();else if(!r)return;function o(a,u){let c=ql(t,u);const f=tn.getState(t.state)==null;if(!c||!gc(a,c))if(f)c=a;else return;const d=new ce(a,c);if(f||!t.state.selection.eq(d)){const p=t.state.tr.setSelection(d);f&&p.setMeta(tn,a.pos),t.dispatch(p)}}function s(){t.root.removeEventListener("mouseup",s),t.root.removeEventListener("dragstart",s),t.root.removeEventListener("mousemove",l),tn.getState(t.state)!=null&&t.dispatch(t.state.tr.setMeta(tn,-1))}function l(a){const u=a,c=tn.getState(t.state);let f;if(c!=null)f=t.state.doc.resolve(c);else if(Nd(t,u.target)!=r&&(f=ql(t,e),!f))return s();f&&o(f,u)}t.root.addEventListener("mouseup",s),t.root.addEventListener("dragstart",s),t.root.addEventListener("mousemove",l)}function Bm(t,e,n){if(!(t.state.selection instanceof B))return null;const{$head:r}=t.state.selection;for(let i=r.depth-1;i>=0;i--){const o=r.node(i);if((n<0?r.index(i):r.indexAfter(i))!=(n<0?0:o.childCount))return null;if(o.type.spec.tableRole=="cell"||o.type.spec.tableRole=="header_cell"){const l=r.before(i),a=e=="vert"?n>0?"down":"up":n>0?"right":"left";return t.endOfTextblock(a)?l:null}}return null}function Nd(t,e){for(;e&&e!=t.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function ql(t,e){const n=t.posAtCoords({left:e.clientX,top:e.clientY});return n&&n?yo(t.state.doc.resolve(n.pos)):null}var Lw=class{constructor(t,e){this.node=t,this.cellMinWidth=e,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")),ja(t,this.colgroup,this.table,e),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(t){return t.type!=this.node.type?!1:(this.node=t,ja(t,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(t){return t.type=="attributes"&&(t.target==this.table||this.colgroup.contains(t.target))}};function ja(t,e,n,r,i,o){var s;let l=0,a=!0,u=e.firstChild;const c=t.firstChild;if(c){for(let f=0,d=0;fnew n(l,e,a),new Vw(-1,!1)},apply(o,s){return s.apply(o)}},props:{attributes:o=>{const s=et.getState(o);return s&&s.activeHandle>-1?{class:"resize-cursor"}:{}},handleDOMEvents:{mousemove:(o,s)=>{$w(o,s,t,e,r)},mouseleave:o=>{_w(o)},mousedown:(o,s)=>{Ww(o,s,e)}},decorations:o=>{const s=et.getState(o);if(s&&s.activeHandle>-1)return qw(o,s.activeHandle)},nodeViews:{}}});return i}var Vw=class as{constructor(e,n){this.activeHandle=e,this.dragging=n}apply(e){const n=this,r=e.getMeta(et);if(r&&r.setHandle!=null)return new as(r.setHandle,!1);if(r&&r.setDragging!==void 0)return new as(n.activeHandle,r.setDragging);if(n.activeHandle>-1&&e.docChanged){let i=e.mapping.map(n.activeHandle,-1);return Wa(e.doc.resolve(i))||(i=-1),new as(i,n.dragging)}return n}};function $w(t,e,n,r,i){const o=et.getState(t.state);if(o&&!o.dragging){const s=jw(e.target);let l=-1;if(s){const{left:a,right:u}=s.getBoundingClientRect();e.clientX-a<=n?l=Md(t,e,"left",n):u-e.clientX<=n&&(l=Md(t,e,"right",n))}if(l!=o.activeHandle){if(!i&&l!==-1){const a=t.state.doc.resolve(l),u=a.node(-1),c=re.get(u),f=a.start(-1);if(c.colCount(a.pos-f)+a.nodeAfter.attrs.colspan-1==c.width-1)return}Vm(t,l)}}}function _w(t){const e=et.getState(t.state);e&&e.activeHandle>-1&&!e.dragging&&Vm(t,-1)}function Ww(t,e,n){var r;const i=(r=t.dom.ownerDocument.defaultView)!=null?r:window,o=et.getState(t.state);if(!o||o.activeHandle==-1||o.dragging)return!1;const s=t.state.doc.nodeAt(o.activeHandle),l=Uw(t,o.activeHandle,s.attrs);t.dispatch(t.state.tr.setMeta(et,{setDragging:{startX:e.clientX,startWidth:l}}));function a(c){i.removeEventListener("mouseup",a),i.removeEventListener("mousemove",u);const f=et.getState(t.state);f!=null&&f.dragging&&(Hw(t,f.activeHandle,Ed(f.dragging,c,n)),t.dispatch(t.state.tr.setMeta(et,{setDragging:null})))}function u(c){if(!c.which)return a(c);const f=et.getState(t.state);if(f&&f.dragging){const d=Ed(f.dragging,c,n);Jw(t,f.activeHandle,d,n)}}return i.addEventListener("mouseup",a),i.addEventListener("mousemove",u),e.preventDefault(),!0}function Uw(t,e,{colspan:n,colwidth:r}){const i=r&&r[r.length-1];if(i)return i;const o=t.domAtPos(e);let l=o.node.childNodes[o.offset].offsetWidth,a=n;if(r)for(let u=0;ui.table.nodeAt(a));for(let a=0;a{const h=p+o.tableStart,m=s.doc.nodeAt(h);m&&s.setNodeMarkup(h,d,m.attrs)}),r(s)}return!0}}yc("row",{useDeprecatedLogic:!0});yc("column",{useDeprecatedLogic:!0});yc("cell",{useDeprecatedLogic:!0});function Yw({allowTableNodeSelection:t=!1}={}){return new At({key:tn,state:{init(){return null},apply(e,n){const r=e.getMeta(tn);if(r!=null)return r==-1?null:r;if(n==null||!e.docChanged)return n;const{deleted:i,pos:o}=e.mapping.mapResult(n);return i?null:o}},props:{decorations:xw,handleDOMEvents:{mousedown:bw},createSelectionBetween(e){return tn.getState(e.state)!=null?e.state.selection:null},handleTripleClick:Fw,handleKeyDown:zw,handlePaste:Iw},appendTransaction(e,n,r){return Mw(r,Ow(r,n),t)}})}var _m={exports:{}},Qe={},Wm={exports:{}},Um={};/** * @license React * scheduler.production.min.js * @@ -42,12 +42,12 @@ `+Ql+t}var Yl=!1;function Gl(t,e){if(!t||Yl)return"";Yl=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(e)if(e=function(){throw Error()},Object.defineProperty(e.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(e,[])}catch(u){var r=u}Reflect.construct(t,[],e)}else{try{e.call()}catch(u){r=u}t.call(e.prototype)}else{try{throw Error()}catch(u){r=u}t()}}catch(u){if(u&&r&&typeof u.stack=="string"){for(var i=u.stack.split(` `),o=r.stack.split(` `),s=i.length-1,l=o.length-1;1<=s&&0<=l&&i[s]!==o[l];)l--;for(;1<=s&&0<=l;s--,l--)if(i[s]!==o[l]){if(s!==1||l!==1)do if(s--,l--,0>l||i[s]!==o[l]){var a=` -`+i[s].replace(" at new "," at ");return t.displayName&&a.includes("")&&(a=a.replace("",t.displayName)),a}while(1<=s&&0<=l);break}}}finally{Yl=!1,Error.prepareStackTrace=n}return(t=t?t.displayName||t.name:"")?gi(t):""}function nv(t){switch(t.tag){case 5:return gi(t.type);case 16:return gi("Lazy");case 13:return gi("Suspense");case 19:return gi("SuspenseList");case 0:case 2:case 15:return t=Gl(t.type,!1),t;case 11:return t=Gl(t.type.render,!1),t;case 1:return t=Gl(t.type,!0),t;default:return""}}function Qa(t){if(t==null)return null;if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case dr:return"Fragment";case fr:return"Portal";case Ja:return"Profiler";case vc:return"StrictMode";case Ka:return"Suspense";case qa:return"SuspenseList"}if(typeof t=="object")switch(t.$$typeof){case Km:return(t.displayName||"Context")+".Consumer";case Jm:return(t._context.displayName||"Context")+".Provider";case xc:var e=t.render;return t=t.displayName,t||(t=e.displayName||e.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case Cc:return e=t.displayName||null,e!==null?e:Qa(t.type)||"Memo";case Xt:e=t._payload,t=t._init;try{return Qa(t(e))}catch{}}return null}function rv(t){var e=t.type;switch(t.tag){case 24:return"Cache";case 9:return(e.displayName||"Context")+".Consumer";case 10:return(e._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return t=e.render,t=t.displayName||t.name||"",e.displayName||(t!==""?"ForwardRef("+t+")":"ForwardRef");case 7:return"Fragment";case 5:return e;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return Qa(e);case 8:return e===vc?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e}return null}function vn(t){switch(typeof t){case"boolean":case"number":case"string":case"undefined":return t;case"object":return t;default:return""}}function Qm(t){var e=t.type;return(t=t.nodeName)&&t.toLowerCase()==="input"&&(e==="checkbox"||e==="radio")}function iv(t){var e=Qm(t)?"checked":"value",n=Object.getOwnPropertyDescriptor(t.constructor.prototype,e),r=""+t[e];if(!t.hasOwnProperty(e)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var i=n.get,o=n.set;return Object.defineProperty(t,e,{configurable:!0,get:function(){return i.call(this)},set:function(s){r=""+s,o.call(this,s)}}),Object.defineProperty(t,e,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(s){r=""+s},stopTracking:function(){t._valueTracker=null,delete t[e]}}}}function Io(t){t._valueTracker||(t._valueTracker=iv(t))}function Ym(t){if(!t)return!1;var e=t._valueTracker;if(!e)return!0;var n=e.getValue(),r="";return t&&(r=Qm(t)?t.checked?"true":"false":t.value),t=r,t!==n?(e.setValue(t),!0):!1}function As(t){if(t=t||(typeof document<"u"?document:void 0),typeof t>"u")return null;try{return t.activeElement||t.body}catch{return t.body}}function Ya(t,e){var n=e.checked;return X({},e,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??t._wrapperState.initialChecked})}function Rd(t,e){var n=e.defaultValue==null?"":e.defaultValue,r=e.checked!=null?e.checked:e.defaultChecked;n=vn(e.value!=null?e.value:n),t._wrapperState={initialChecked:r,initialValue:n,controlled:e.type==="checkbox"||e.type==="radio"?e.checked!=null:e.value!=null}}function Gm(t,e){e=e.checked,e!=null&&wc(t,"checked",e,!1)}function Ga(t,e){Gm(t,e);var n=vn(e.value),r=e.type;if(n!=null)r==="number"?(n===0&&t.value===""||t.value!=n)&&(t.value=""+n):t.value!==""+n&&(t.value=""+n);else if(r==="submit"||r==="reset"){t.removeAttribute("value");return}e.hasOwnProperty("value")?Xa(t,e.type,n):e.hasOwnProperty("defaultValue")&&Xa(t,e.type,vn(e.defaultValue)),e.checked==null&&e.defaultChecked!=null&&(t.defaultChecked=!!e.defaultChecked)}function Pd(t,e,n){if(e.hasOwnProperty("value")||e.hasOwnProperty("defaultValue")){var r=e.type;if(!(r!=="submit"&&r!=="reset"||e.value!==void 0&&e.value!==null))return;e=""+t._wrapperState.initialValue,n||e===t.value||(t.value=e),t.defaultValue=e}n=t.name,n!==""&&(t.name=""),t.defaultChecked=!!t._wrapperState.initialChecked,n!==""&&(t.name=n)}function Xa(t,e,n){(e!=="number"||As(t.ownerDocument)!==t)&&(n==null?t.defaultValue=""+t._wrapperState.initialValue:t.defaultValue!==""+n&&(t.defaultValue=""+n))}var yi=Array.isArray;function Er(t,e,n,r){if(t=t.options,e){e={};for(var i=0;i"+e.valueOf().toString()+"",e=bo.firstChild;t.firstChild;)t.removeChild(t.firstChild);for(;e.firstChild;)t.appendChild(e.firstChild)}});function ji(t,e){if(e){var n=t.firstChild;if(n&&n===t.lastChild&&n.nodeType===3){n.nodeValue=e;return}}t.textContent=e}var Mi={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},ov=["Webkit","ms","Moz","O"];Object.keys(Mi).forEach(function(t){ov.forEach(function(e){e=e+t.charAt(0).toUpperCase()+t.substring(1),Mi[e]=Mi[t]})});function tg(t,e,n){return e==null||typeof e=="boolean"||e===""?"":n||typeof e!="number"||e===0||Mi.hasOwnProperty(t)&&Mi[t]?(""+e).trim():e+"px"}function ng(t,e){t=t.style;for(var n in e)if(e.hasOwnProperty(n)){var r=n.indexOf("--")===0,i=tg(n,e[n],r);n==="float"&&(n="cssFloat"),r?t.setProperty(n,i):t[n]=i}}var sv=X({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function tu(t,e){if(e){if(sv[t]&&(e.children!=null||e.dangerouslySetInnerHTML!=null))throw Error(N(137,t));if(e.dangerouslySetInnerHTML!=null){if(e.children!=null)throw Error(N(60));if(typeof e.dangerouslySetInnerHTML!="object"||!("__html"in e.dangerouslySetInnerHTML))throw Error(N(61))}if(e.style!=null&&typeof e.style!="object")throw Error(N(62))}}function nu(t,e){if(t.indexOf("-")===-1)return typeof e.is=="string";switch(t){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var ru=null;function Nc(t){return t=t.target||t.srcElement||window,t.correspondingUseElement&&(t=t.correspondingUseElement),t.nodeType===3?t.parentNode:t}var iu=null,Or=null,Dr=null;function Id(t){if(t=wo(t)){if(typeof iu!="function")throw Error(N(280));var e=t.stateNode;e&&(e=cl(e),iu(t.stateNode,t.type,e))}}function rg(t){Or?Dr?Dr.push(t):Dr=[t]:Or=t}function ig(){if(Or){var t=Or,e=Dr;if(Dr=Or=null,Id(t),e)for(t=0;t>>=0,t===0?32:31-(yv(t)/Sv|0)|0}var Lo=64,Bo=4194304;function Si(t){switch(t&-t){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return t&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return t}}function Fs(t,e){var n=t.pendingLanes;if(n===0)return 0;var r=0,i=t.suspendedLanes,o=t.pingedLanes,s=n&268435455;if(s!==0){var l=s&~i;l!==0?r=Si(l):(o&=s,o!==0&&(r=Si(o)))}else s=n&~i,s!==0?r=Si(s):o!==0&&(r=Si(o));if(r===0)return 0;if(e!==0&&e!==r&&!(e&i)&&(i=r&-r,o=e&-e,i>=o||i===16&&(o&4194240)!==0))return e;if(r&4&&(r|=n&16),e=t.entangledLanes,e!==0)for(t=t.entanglements,e&=r;0n;n++)e.push(t);return e}function So(t,e,n){t.pendingLanes|=e,e!==536870912&&(t.suspendedLanes=0,t.pingedLanes=0),t=t.eventTimes,e=31-dt(e),t[e]=n}function xv(t,e){var n=t.pendingLanes&~e;t.pendingLanes=e,t.suspendedLanes=0,t.pingedLanes=0,t.expiredLanes&=e,t.mutableReadLanes&=e,t.entangledLanes&=e,e=t.entanglements;var r=t.eventTimes;for(t=t.expirationTimes;0=Oi),jd=String.fromCharCode(32),Hd=!1;function Ng(t,e){switch(t){case"keyup":return Yv.indexOf(e.keyCode)!==-1;case"keydown":return e.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Mg(t){return t=t.detail,typeof t=="object"&&"data"in t?t.data:null}var hr=!1;function Xv(t,e){switch(t){case"compositionend":return Mg(e);case"keypress":return e.which!==32?null:(Hd=!0,jd);case"textInput":return t=e.data,t===jd&&Hd?null:t;default:return null}}function Zv(t,e){if(hr)return t==="compositionend"||!Pc&&Ng(t,e)?(t=xg(),cs=Tc=un=null,hr=!1,t):null;switch(t){case"paste":return null;case"keypress":if(!(e.ctrlKey||e.altKey||e.metaKey)||e.ctrlKey&&e.altKey){if(e.char&&1=e)return{node:n,offset:e-t};t=r}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=Qd(n)}}function Tg(t,e){return t&&e?t===e?!0:t&&t.nodeType===3?!1:e&&e.nodeType===3?Tg(t,e.parentNode):"contains"in t?t.contains(e):t.compareDocumentPosition?!!(t.compareDocumentPosition(e)&16):!1:!1}function Ag(){for(var t=window,e=As();e instanceof t.HTMLIFrameElement;){try{var n=typeof e.contentWindow.location.href=="string"}catch{n=!1}if(n)t=e.contentWindow;else break;e=As(t.document)}return e}function zc(t){var e=t&&t.nodeName&&t.nodeName.toLowerCase();return e&&(e==="input"&&(t.type==="text"||t.type==="search"||t.type==="tel"||t.type==="url"||t.type==="password")||e==="textarea"||t.contentEditable==="true")}function ax(t){var e=Ag(),n=t.focusedElem,r=t.selectionRange;if(e!==n&&n&&n.ownerDocument&&Tg(n.ownerDocument.documentElement,n)){if(r!==null&&zc(n)){if(e=r.start,t=r.end,t===void 0&&(t=e),"selectionStart"in n)n.selectionStart=e,n.selectionEnd=Math.min(t,n.value.length);else if(t=(e=n.ownerDocument||document)&&e.defaultView||window,t.getSelection){t=t.getSelection();var i=n.textContent.length,o=Math.min(r.start,i);r=r.end===void 0?o:Math.min(r.end,i),!t.extend&&o>r&&(i=r,r=o,o=i),i=Yd(n,o);var s=Yd(n,r);i&&s&&(t.rangeCount!==1||t.anchorNode!==i.node||t.anchorOffset!==i.offset||t.focusNode!==s.node||t.focusOffset!==s.offset)&&(e=e.createRange(),e.setStart(i.node,i.offset),t.removeAllRanges(),o>r?(t.addRange(e),t.extend(s.node,s.offset)):(e.setEnd(s.node,s.offset),t.addRange(e)))}}for(e=[],t=n;t=t.parentNode;)t.nodeType===1&&e.push({element:t,left:t.scrollLeft,top:t.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n=document.documentMode,pr=null,cu=null,Ti=null,fu=!1;function Gd(t,e,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;fu||pr==null||pr!==As(r)||(r=pr,"selectionStart"in r&&zc(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),Ti&&Yi(Ti,r)||(Ti=r,r=Ls(cu,"onSelect"),0yr||(t.current=yu[yr],yu[yr]=null,yr--)}function J(t,e){yr++,yu[yr]=t.current,t.current=e}var xn={},Ce=En(xn),Ve=En(!1),Yn=xn;function _r(t,e){var n=t.type.contextTypes;if(!n)return xn;var r=t.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===e)return r.__reactInternalMemoizedMaskedChildContext;var i={},o;for(o in n)i[o]=e[o];return r&&(t=t.stateNode,t.__reactInternalMemoizedUnmaskedChildContext=e,t.__reactInternalMemoizedMaskedChildContext=i),i}function $e(t){return t=t.childContextTypes,t!=null}function Vs(){q(Ve),q(Ce)}function ih(t,e,n){if(Ce.current!==xn)throw Error(N(168));J(Ce,e),J(Ve,n)}function Vg(t,e,n){var r=t.stateNode;if(e=e.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var i in r)if(!(i in e))throw Error(N(108,rv(t)||"Unknown",i));return X({},n,r)}function $s(t){return t=(t=t.stateNode)&&t.__reactInternalMemoizedMergedChildContext||xn,Yn=Ce.current,J(Ce,t),J(Ve,Ve.current),!0}function oh(t,e,n){var r=t.stateNode;if(!r)throw Error(N(169));n?(t=Vg(t,e,Yn),r.__reactInternalMemoizedMergedChildContext=t,q(Ve),q(Ce),J(Ce,t)):q(Ve),J(Ve,n)}var bt=null,fl=!1,fa=!1;function $g(t){bt===null?bt=[t]:bt.push(t)}function wx(t){fl=!0,$g(t)}function On(){if(!fa&&bt!==null){fa=!0;var t=0,e=j;try{var n=bt;for(j=1;t>=s,i-=s,Bt=1<<32-dt(e)+i|n<T?(P=O,O=null):P=O.sibling;var A=d(g,O,S[T],w);if(A===null){O===null&&(O=P);break}t&&O&&A.alternate===null&&e(g,O),y=o(A,y,T),E===null?M=A:E.sibling=A,E=A,O=P}if(T===S.length)return n(g,O),Q&&zn(g,T),M;if(O===null){for(;TT?(P=O,O=null):P=O.sibling;var H=d(g,O,A.value,w);if(H===null){O===null&&(O=P);break}t&&O&&H.alternate===null&&e(g,O),y=o(H,y,T),E===null?M=H:E.sibling=H,E=H,O=P}if(A.done)return n(g,O),Q&&zn(g,T),M;if(O===null){for(;!A.done;T++,A=S.next())A=f(g,A.value,w),A!==null&&(y=o(A,y,T),E===null?M=A:E.sibling=A,E=A);return Q&&zn(g,T),M}for(O=r(g,O);!A.done;T++,A=S.next())A=p(O,g,T,A.value,w),A!==null&&(t&&A.alternate!==null&&O.delete(A.key===null?T:A.key),y=o(A,y,T),E===null?M=A:E.sibling=A,E=A);return t&&O.forEach(function(st){return e(g,st)}),Q&&zn(g,T),M}function k(g,y,S,w){if(typeof S=="object"&&S!==null&&S.type===dr&&S.key===null&&(S=S.props.children),typeof S=="object"&&S!==null){switch(S.$$typeof){case Fo:e:{for(var M=S.key,E=y;E!==null;){if(E.key===M){if(M=S.type,M===dr){if(E.tag===7){n(g,E.sibling),y=i(E,S.props.children),y.return=g,g=y;break e}}else if(E.elementType===M||typeof M=="object"&&M!==null&&M.$$typeof===Xt&&dh(M)===E.type){n(g,E.sibling),y=i(E,S.props),y.ref=ii(g,E,S),y.return=g,g=y;break e}n(g,E);break}else e(g,E);E=E.sibling}S.type===dr?(y=Kn(S.props.children,g.mode,w,S.key),y.return=g,g=y):(w=Ss(S.type,S.key,S.props,null,g.mode,w),w.ref=ii(g,y,S),w.return=g,g=w)}return s(g);case fr:e:{for(E=S.key;y!==null;){if(y.key===E)if(y.tag===4&&y.stateNode.containerInfo===S.containerInfo&&y.stateNode.implementation===S.implementation){n(g,y.sibling),y=i(y,S.children||[]),y.return=g,g=y;break e}else{n(g,y);break}else e(g,y);y=y.sibling}y=ka(S,g.mode,w),y.return=g,g=y}return s(g);case Xt:return E=S._init,k(g,y,E(S._payload),w)}if(yi(S))return h(g,y,S,w);if(Zr(S))return m(g,y,S,w);Ho(g,S)}return typeof S=="string"&&S!==""||typeof S=="number"?(S=""+S,y!==null&&y.tag===6?(n(g,y.sibling),y=i(y,S),y.return=g,g=y):(n(g,y),y=Sa(S,g.mode,w),y.return=g,g=y),s(g)):n(g,y)}return k}var Ur=qg(!0),Qg=qg(!1),vo={},Nt=En(vo),eo=En(vo),to=En(vo);function _n(t){if(t===vo)throw Error(N(174));return t}function Wc(t,e){switch(J(to,e),J(eo,t),J(Nt,vo),t=e.nodeType,t){case 9:case 11:e=(e=e.documentElement)?e.namespaceURI:eu(null,"");break;default:t=t===8?e.parentNode:e,e=t.namespaceURI||null,t=t.tagName,e=eu(e,t)}q(Nt),J(Nt,e)}function jr(){q(Nt),q(eo),q(to)}function Yg(t){_n(to.current);var e=_n(Nt.current),n=eu(e,t.type);e!==n&&(J(eo,t),J(Nt,n))}function Uc(t){eo.current===t&&(q(Nt),q(eo))}var Y=En(0);function Js(t){for(var e=t;e!==null;){if(e.tag===13){var n=e.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||n.data==="$?"||n.data==="$!"))return e}else if(e.tag===19&&e.memoizedProps.revealOrder!==void 0){if(e.flags&128)return e}else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break;for(;e.sibling===null;){if(e.return===null||e.return===t)return null;e=e.return}e.sibling.return=e.return,e=e.sibling}return null}var da=[];function jc(){for(var t=0;tn?n:4,t(!0);var r=ha.transition;ha.transition={};try{t(!1),e()}finally{j=n,ha.transition=r}}function d0(){return ot().memoizedState}function Nx(t,e,n){var r=kn(t);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},h0(t))p0(e,n);else if(n=jg(t,e,n,r),n!==null){var i=De();ht(n,t,r,i),m0(n,e,r)}}function Mx(t,e,n){var r=kn(t),i={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(h0(t))p0(e,i);else{var o=t.alternate;if(t.lanes===0&&(o===null||o.lanes===0)&&(o=e.lastRenderedReducer,o!==null))try{var s=e.lastRenderedState,l=o(s,n);if(i.hasEagerState=!0,i.eagerState=l,mt(l,s)){var a=e.interleaved;a===null?(i.next=i,$c(e)):(i.next=a.next,a.next=i),e.interleaved=i;return}}catch{}finally{}n=jg(t,e,i,r),n!==null&&(i=De(),ht(n,t,r,i),m0(n,e,r))}}function h0(t){var e=t.alternate;return t===G||e!==null&&e===G}function p0(t,e){Ai=Ks=!0;var n=t.pending;n===null?e.next=e:(e.next=n.next,n.next=e),t.pending=e}function m0(t,e,n){if(n&4194240){var r=e.lanes;r&=t.pendingLanes,n|=r,e.lanes=n,Ec(t,n)}}var qs={readContext:it,useCallback:Se,useContext:Se,useEffect:Se,useImperativeHandle:Se,useInsertionEffect:Se,useLayoutEffect:Se,useMemo:Se,useReducer:Se,useRef:Se,useState:Se,useDebugValue:Se,useDeferredValue:Se,useTransition:Se,useMutableSource:Se,useSyncExternalStore:Se,useId:Se,unstable_isNewReconciler:!1},Ex={readContext:it,useCallback:function(t,e){return yt().memoizedState=[t,e===void 0?null:e],t},useContext:it,useEffect:ph,useImperativeHandle:function(t,e,n){return n=n!=null?n.concat([t]):null,ps(4194308,4,l0.bind(null,e,t),n)},useLayoutEffect:function(t,e){return ps(4194308,4,t,e)},useInsertionEffect:function(t,e){return ps(4,2,t,e)},useMemo:function(t,e){var n=yt();return e=e===void 0?null:e,t=t(),n.memoizedState=[t,e],t},useReducer:function(t,e,n){var r=yt();return e=n!==void 0?n(e):e,r.memoizedState=r.baseState=e,t={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:t,lastRenderedState:e},r.queue=t,t=t.dispatch=Nx.bind(null,G,t),[r.memoizedState,t]},useRef:function(t){var e=yt();return t={current:t},e.memoizedState=t},useState:hh,useDebugValue:Qc,useDeferredValue:function(t){return yt().memoizedState=t},useTransition:function(){var t=hh(!1),e=t[0];return t=Cx.bind(null,t[1]),yt().memoizedState=t,[e,t]},useMutableSource:function(){},useSyncExternalStore:function(t,e,n){var r=G,i=yt();if(Q){if(n===void 0)throw Error(N(407));n=n()}else{if(n=e(),fe===null)throw Error(N(349));Xn&30||Zg(r,e,n)}i.memoizedState=n;var o={value:n,getSnapshot:e};return i.queue=o,ph(t0.bind(null,r,o,t),[t]),r.flags|=2048,io(9,e0.bind(null,r,o,n,e),void 0,null),n},useId:function(){var t=yt(),e=fe.identifierPrefix;if(Q){var n=Vt,r=Bt;n=(r&~(1<<32-dt(r)-1)).toString(32)+n,e=":"+e+"R"+n,n=no++,0")&&(a=a.replace("",t.displayName)),a}while(1<=s&&0<=l);break}}}finally{Yl=!1,Error.prepareStackTrace=n}return(t=t?t.displayName||t.name:"")?gi(t):""}function nv(t){switch(t.tag){case 5:return gi(t.type);case 16:return gi("Lazy");case 13:return gi("Suspense");case 19:return gi("SuspenseList");case 0:case 2:case 15:return t=Gl(t.type,!1),t;case 11:return t=Gl(t.type.render,!1),t;case 1:return t=Gl(t.type,!0),t;default:return""}}function Qa(t){if(t==null)return null;if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case dr:return"Fragment";case fr:return"Portal";case Ja:return"Profiler";case vc:return"StrictMode";case Ka:return"Suspense";case qa:return"SuspenseList"}if(typeof t=="object")switch(t.$$typeof){case Km:return(t.displayName||"Context")+".Consumer";case Jm:return(t._context.displayName||"Context")+".Provider";case xc:var e=t.render;return t=t.displayName,t||(t=e.displayName||e.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case Cc:return e=t.displayName||null,e!==null?e:Qa(t.type)||"Memo";case Xt:e=t._payload,t=t._init;try{return Qa(t(e))}catch{}}return null}function rv(t){var e=t.type;switch(t.tag){case 24:return"Cache";case 9:return(e.displayName||"Context")+".Consumer";case 10:return(e._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return t=e.render,t=t.displayName||t.name||"",e.displayName||(t!==""?"ForwardRef("+t+")":"ForwardRef");case 7:return"Fragment";case 5:return e;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return Qa(e);case 8:return e===vc?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e}return null}function vn(t){switch(typeof t){case"boolean":case"number":case"string":case"undefined":return t;case"object":return t;default:return""}}function Qm(t){var e=t.type;return(t=t.nodeName)&&t.toLowerCase()==="input"&&(e==="checkbox"||e==="radio")}function iv(t){var e=Qm(t)?"checked":"value",n=Object.getOwnPropertyDescriptor(t.constructor.prototype,e),r=""+t[e];if(!t.hasOwnProperty(e)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var i=n.get,o=n.set;return Object.defineProperty(t,e,{configurable:!0,get:function(){return i.call(this)},set:function(s){r=""+s,o.call(this,s)}}),Object.defineProperty(t,e,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(s){r=""+s},stopTracking:function(){t._valueTracker=null,delete t[e]}}}}function Io(t){t._valueTracker||(t._valueTracker=iv(t))}function Ym(t){if(!t)return!1;var e=t._valueTracker;if(!e)return!0;var n=e.getValue(),r="";return t&&(r=Qm(t)?t.checked?"true":"false":t.value),t=r,t!==n?(e.setValue(t),!0):!1}function As(t){if(t=t||(typeof document<"u"?document:void 0),typeof t>"u")return null;try{return t.activeElement||t.body}catch{return t.body}}function Ya(t,e){var n=e.checked;return X({},e,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??t._wrapperState.initialChecked})}function Rd(t,e){var n=e.defaultValue==null?"":e.defaultValue,r=e.checked!=null?e.checked:e.defaultChecked;n=vn(e.value!=null?e.value:n),t._wrapperState={initialChecked:r,initialValue:n,controlled:e.type==="checkbox"||e.type==="radio"?e.checked!=null:e.value!=null}}function Gm(t,e){e=e.checked,e!=null&&wc(t,"checked",e,!1)}function Ga(t,e){Gm(t,e);var n=vn(e.value),r=e.type;if(n!=null)r==="number"?(n===0&&t.value===""||t.value!=n)&&(t.value=""+n):t.value!==""+n&&(t.value=""+n);else if(r==="submit"||r==="reset"){t.removeAttribute("value");return}e.hasOwnProperty("value")?Xa(t,e.type,n):e.hasOwnProperty("defaultValue")&&Xa(t,e.type,vn(e.defaultValue)),e.checked==null&&e.defaultChecked!=null&&(t.defaultChecked=!!e.defaultChecked)}function Pd(t,e,n){if(e.hasOwnProperty("value")||e.hasOwnProperty("defaultValue")){var r=e.type;if(!(r!=="submit"&&r!=="reset"||e.value!==void 0&&e.value!==null))return;e=""+t._wrapperState.initialValue,n||e===t.value||(t.value=e),t.defaultValue=e}n=t.name,n!==""&&(t.name=""),t.defaultChecked=!!t._wrapperState.initialChecked,n!==""&&(t.name=n)}function Xa(t,e,n){(e!=="number"||As(t.ownerDocument)!==t)&&(n==null?t.defaultValue=""+t._wrapperState.initialValue:t.defaultValue!==""+n&&(t.defaultValue=""+n))}var yi=Array.isArray;function Er(t,e,n,r){if(t=t.options,e){e={};for(var i=0;i"+e.valueOf().toString()+"",e=bo.firstChild;t.firstChild;)t.removeChild(t.firstChild);for(;e.firstChild;)t.appendChild(e.firstChild)}});function ji(t,e){if(e){var n=t.firstChild;if(n&&n===t.lastChild&&n.nodeType===3){n.nodeValue=e;return}}t.textContent=e}var Mi={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},ov=["Webkit","ms","Moz","O"];Object.keys(Mi).forEach(function(t){ov.forEach(function(e){e=e+t.charAt(0).toUpperCase()+t.substring(1),Mi[e]=Mi[t]})});function tg(t,e,n){return e==null||typeof e=="boolean"||e===""?"":n||typeof e!="number"||e===0||Mi.hasOwnProperty(t)&&Mi[t]?(""+e).trim():e+"px"}function ng(t,e){t=t.style;for(var n in e)if(e.hasOwnProperty(n)){var r=n.indexOf("--")===0,i=tg(n,e[n],r);n==="float"&&(n="cssFloat"),r?t.setProperty(n,i):t[n]=i}}var sv=X({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function tu(t,e){if(e){if(sv[t]&&(e.children!=null||e.dangerouslySetInnerHTML!=null))throw Error(N(137,t));if(e.dangerouslySetInnerHTML!=null){if(e.children!=null)throw Error(N(60));if(typeof e.dangerouslySetInnerHTML!="object"||!("__html"in e.dangerouslySetInnerHTML))throw Error(N(61))}if(e.style!=null&&typeof e.style!="object")throw Error(N(62))}}function nu(t,e){if(t.indexOf("-")===-1)return typeof e.is=="string";switch(t){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var ru=null;function Nc(t){return t=t.target||t.srcElement||window,t.correspondingUseElement&&(t=t.correspondingUseElement),t.nodeType===3?t.parentNode:t}var iu=null,Or=null,Dr=null;function Id(t){if(t=wo(t)){if(typeof iu!="function")throw Error(N(280));var e=t.stateNode;e&&(e=cl(e),iu(t.stateNode,t.type,e))}}function rg(t){Or?Dr?Dr.push(t):Dr=[t]:Or=t}function ig(){if(Or){var t=Or,e=Dr;if(Dr=Or=null,Id(t),e)for(t=0;t>>=0,t===0?32:31-(yv(t)/Sv|0)|0}var Lo=64,Bo=4194304;function Si(t){switch(t&-t){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return t&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return t}}function Fs(t,e){var n=t.pendingLanes;if(n===0)return 0;var r=0,i=t.suspendedLanes,o=t.pingedLanes,s=n&268435455;if(s!==0){var l=s&~i;l!==0?r=Si(l):(o&=s,o!==0&&(r=Si(o)))}else s=n&~i,s!==0?r=Si(s):o!==0&&(r=Si(o));if(r===0)return 0;if(e!==0&&e!==r&&!(e&i)&&(i=r&-r,o=e&-e,i>=o||i===16&&(o&4194240)!==0))return e;if(r&4&&(r|=n&16),e=t.entangledLanes,e!==0)for(t=t.entanglements,e&=r;0n;n++)e.push(t);return e}function So(t,e,n){t.pendingLanes|=e,e!==536870912&&(t.suspendedLanes=0,t.pingedLanes=0),t=t.eventTimes,e=31-dt(e),t[e]=n}function xv(t,e){var n=t.pendingLanes&~e;t.pendingLanes=e,t.suspendedLanes=0,t.pingedLanes=0,t.expiredLanes&=e,t.mutableReadLanes&=e,t.entangledLanes&=e,e=t.entanglements;var r=t.eventTimes;for(t=t.expirationTimes;0=Oi),jd=String.fromCharCode(32),Hd=!1;function Ng(t,e){switch(t){case"keyup":return Yv.indexOf(e.keyCode)!==-1;case"keydown":return e.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Mg(t){return t=t.detail,typeof t=="object"&&"data"in t?t.data:null}var hr=!1;function Xv(t,e){switch(t){case"compositionend":return Mg(e);case"keypress":return e.which!==32?null:(Hd=!0,jd);case"textInput":return t=e.data,t===jd&&Hd?null:t;default:return null}}function Zv(t,e){if(hr)return t==="compositionend"||!Pc&&Ng(t,e)?(t=xg(),cs=Tc=un=null,hr=!1,t):null;switch(t){case"paste":return null;case"keypress":if(!(e.ctrlKey||e.altKey||e.metaKey)||e.ctrlKey&&e.altKey){if(e.char&&1=e)return{node:n,offset:e-t};t=r}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=Qd(n)}}function Tg(t,e){return t&&e?t===e?!0:t&&t.nodeType===3?!1:e&&e.nodeType===3?Tg(t,e.parentNode):"contains"in t?t.contains(e):t.compareDocumentPosition?!!(t.compareDocumentPosition(e)&16):!1:!1}function Ag(){for(var t=window,e=As();e instanceof t.HTMLIFrameElement;){try{var n=typeof e.contentWindow.location.href=="string"}catch{n=!1}if(n)t=e.contentWindow;else break;e=As(t.document)}return e}function zc(t){var e=t&&t.nodeName&&t.nodeName.toLowerCase();return e&&(e==="input"&&(t.type==="text"||t.type==="search"||t.type==="tel"||t.type==="url"||t.type==="password")||e==="textarea"||t.contentEditable==="true")}function ax(t){var e=Ag(),n=t.focusedElem,r=t.selectionRange;if(e!==n&&n&&n.ownerDocument&&Tg(n.ownerDocument.documentElement,n)){if(r!==null&&zc(n)){if(e=r.start,t=r.end,t===void 0&&(t=e),"selectionStart"in n)n.selectionStart=e,n.selectionEnd=Math.min(t,n.value.length);else if(t=(e=n.ownerDocument||document)&&e.defaultView||window,t.getSelection){t=t.getSelection();var i=n.textContent.length,o=Math.min(r.start,i);r=r.end===void 0?o:Math.min(r.end,i),!t.extend&&o>r&&(i=r,r=o,o=i),i=Yd(n,o);var s=Yd(n,r);i&&s&&(t.rangeCount!==1||t.anchorNode!==i.node||t.anchorOffset!==i.offset||t.focusNode!==s.node||t.focusOffset!==s.offset)&&(e=e.createRange(),e.setStart(i.node,i.offset),t.removeAllRanges(),o>r?(t.addRange(e),t.extend(s.node,s.offset)):(e.setEnd(s.node,s.offset),t.addRange(e)))}}for(e=[],t=n;t=t.parentNode;)t.nodeType===1&&e.push({element:t,left:t.scrollLeft,top:t.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n=document.documentMode,pr=null,cu=null,Ti=null,fu=!1;function Gd(t,e,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;fu||pr==null||pr!==As(r)||(r=pr,"selectionStart"in r&&zc(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),Ti&&Yi(Ti,r)||(Ti=r,r=Ls(cu,"onSelect"),0yr||(t.current=yu[yr],yu[yr]=null,yr--)}function J(t,e){yr++,yu[yr]=t.current,t.current=e}var xn={},Ce=En(xn),Ve=En(!1),Yn=xn;function _r(t,e){var n=t.type.contextTypes;if(!n)return xn;var r=t.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===e)return r.__reactInternalMemoizedMaskedChildContext;var i={},o;for(o in n)i[o]=e[o];return r&&(t=t.stateNode,t.__reactInternalMemoizedUnmaskedChildContext=e,t.__reactInternalMemoizedMaskedChildContext=i),i}function $e(t){return t=t.childContextTypes,t!=null}function Vs(){q(Ve),q(Ce)}function ih(t,e,n){if(Ce.current!==xn)throw Error(N(168));J(Ce,e),J(Ve,n)}function Vg(t,e,n){var r=t.stateNode;if(e=e.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var i in r)if(!(i in e))throw Error(N(108,rv(t)||"Unknown",i));return X({},n,r)}function $s(t){return t=(t=t.stateNode)&&t.__reactInternalMemoizedMergedChildContext||xn,Yn=Ce.current,J(Ce,t),J(Ve,Ve.current),!0}function oh(t,e,n){var r=t.stateNode;if(!r)throw Error(N(169));n?(t=Vg(t,e,Yn),r.__reactInternalMemoizedMergedChildContext=t,q(Ve),q(Ce),J(Ce,t)):q(Ve),J(Ve,n)}var bt=null,fl=!1,fa=!1;function $g(t){bt===null?bt=[t]:bt.push(t)}function wx(t){fl=!0,$g(t)}function On(){if(!fa&&bt!==null){fa=!0;var t=0,e=j;try{var n=bt;for(j=1;t>=s,i-=s,Bt=1<<32-dt(e)+i|n<T?(P=O,O=null):P=O.sibling;var A=d(g,O,S[T],w);if(A===null){O===null&&(O=P);break}t&&O&&A.alternate===null&&e(g,O),y=o(A,y,T),E===null?M=A:E.sibling=A,E=A,O=P}if(T===S.length)return n(g,O),Q&&zn(g,T),M;if(O===null){for(;TT?(P=O,O=null):P=O.sibling;var H=d(g,O,A.value,w);if(H===null){O===null&&(O=P);break}t&&O&&H.alternate===null&&e(g,O),y=o(H,y,T),E===null?M=H:E.sibling=H,E=H,O=P}if(A.done)return n(g,O),Q&&zn(g,T),M;if(O===null){for(;!A.done;T++,A=S.next())A=f(g,A.value,w),A!==null&&(y=o(A,y,T),E===null?M=A:E.sibling=A,E=A);return Q&&zn(g,T),M}for(O=r(g,O);!A.done;T++,A=S.next())A=p(O,g,T,A.value,w),A!==null&&(t&&A.alternate!==null&&O.delete(A.key===null?T:A.key),y=o(A,y,T),E===null?M=A:E.sibling=A,E=A);return t&&O.forEach(function(st){return e(g,st)}),Q&&zn(g,T),M}function k(g,y,S,w){if(typeof S=="object"&&S!==null&&S.type===dr&&S.key===null&&(S=S.props.children),typeof S=="object"&&S!==null){switch(S.$$typeof){case Fo:e:{for(var M=S.key,E=y;E!==null;){if(E.key===M){if(M=S.type,M===dr){if(E.tag===7){n(g,E.sibling),y=i(E,S.props.children),y.return=g,g=y;break e}}else if(E.elementType===M||typeof M=="object"&&M!==null&&M.$$typeof===Xt&&dh(M)===E.type){n(g,E.sibling),y=i(E,S.props),y.ref=ii(g,E,S),y.return=g,g=y;break e}n(g,E);break}else e(g,E);E=E.sibling}S.type===dr?(y=Kn(S.props.children,g.mode,w,S.key),y.return=g,g=y):(w=Ss(S.type,S.key,S.props,null,g.mode,w),w.ref=ii(g,y,S),w.return=g,g=w)}return s(g);case fr:e:{for(E=S.key;y!==null;){if(y.key===E)if(y.tag===4&&y.stateNode.containerInfo===S.containerInfo&&y.stateNode.implementation===S.implementation){n(g,y.sibling),y=i(y,S.children||[]),y.return=g,g=y;break e}else{n(g,y);break}else e(g,y);y=y.sibling}y=ka(S,g.mode,w),y.return=g,g=y}return s(g);case Xt:return E=S._init,k(g,y,E(S._payload),w)}if(yi(S))return h(g,y,S,w);if(Zr(S))return m(g,y,S,w);Ho(g,S)}return typeof S=="string"&&S!==""||typeof S=="number"?(S=""+S,y!==null&&y.tag===6?(n(g,y.sibling),y=i(y,S),y.return=g,g=y):(n(g,y),y=Sa(S,g.mode,w),y.return=g,g=y),s(g)):n(g,y)}return k}var Ur=qg(!0),Qg=qg(!1),vo={},Mt=En(vo),eo=En(vo),to=En(vo);function _n(t){if(t===vo)throw Error(N(174));return t}function Wc(t,e){switch(J(to,e),J(eo,t),J(Mt,vo),t=e.nodeType,t){case 9:case 11:e=(e=e.documentElement)?e.namespaceURI:eu(null,"");break;default:t=t===8?e.parentNode:e,e=t.namespaceURI||null,t=t.tagName,e=eu(e,t)}q(Mt),J(Mt,e)}function jr(){q(Mt),q(eo),q(to)}function Yg(t){_n(to.current);var e=_n(Mt.current),n=eu(e,t.type);e!==n&&(J(eo,t),J(Mt,n))}function Uc(t){eo.current===t&&(q(Mt),q(eo))}var Y=En(0);function Js(t){for(var e=t;e!==null;){if(e.tag===13){var n=e.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||n.data==="$?"||n.data==="$!"))return e}else if(e.tag===19&&e.memoizedProps.revealOrder!==void 0){if(e.flags&128)return e}else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break;for(;e.sibling===null;){if(e.return===null||e.return===t)return null;e=e.return}e.sibling.return=e.return,e=e.sibling}return null}var da=[];function jc(){for(var t=0;tn?n:4,t(!0);var r=ha.transition;ha.transition={};try{t(!1),e()}finally{j=n,ha.transition=r}}function d0(){return ot().memoizedState}function Nx(t,e,n){var r=kn(t);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},h0(t))p0(e,n);else if(n=jg(t,e,n,r),n!==null){var i=De();ht(n,t,r,i),m0(n,e,r)}}function Mx(t,e,n){var r=kn(t),i={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(h0(t))p0(e,i);else{var o=t.alternate;if(t.lanes===0&&(o===null||o.lanes===0)&&(o=e.lastRenderedReducer,o!==null))try{var s=e.lastRenderedState,l=o(s,n);if(i.hasEagerState=!0,i.eagerState=l,mt(l,s)){var a=e.interleaved;a===null?(i.next=i,$c(e)):(i.next=a.next,a.next=i),e.interleaved=i;return}}catch{}finally{}n=jg(t,e,i,r),n!==null&&(i=De(),ht(n,t,r,i),m0(n,e,r))}}function h0(t){var e=t.alternate;return t===G||e!==null&&e===G}function p0(t,e){Ai=Ks=!0;var n=t.pending;n===null?e.next=e:(e.next=n.next,n.next=e),t.pending=e}function m0(t,e,n){if(n&4194240){var r=e.lanes;r&=t.pendingLanes,n|=r,e.lanes=n,Ec(t,n)}}var qs={readContext:it,useCallback:Se,useContext:Se,useEffect:Se,useImperativeHandle:Se,useInsertionEffect:Se,useLayoutEffect:Se,useMemo:Se,useReducer:Se,useRef:Se,useState:Se,useDebugValue:Se,useDeferredValue:Se,useTransition:Se,useMutableSource:Se,useSyncExternalStore:Se,useId:Se,unstable_isNewReconciler:!1},Ex={readContext:it,useCallback:function(t,e){return St().memoizedState=[t,e===void 0?null:e],t},useContext:it,useEffect:ph,useImperativeHandle:function(t,e,n){return n=n!=null?n.concat([t]):null,ps(4194308,4,l0.bind(null,e,t),n)},useLayoutEffect:function(t,e){return ps(4194308,4,t,e)},useInsertionEffect:function(t,e){return ps(4,2,t,e)},useMemo:function(t,e){var n=St();return e=e===void 0?null:e,t=t(),n.memoizedState=[t,e],t},useReducer:function(t,e,n){var r=St();return e=n!==void 0?n(e):e,r.memoizedState=r.baseState=e,t={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:t,lastRenderedState:e},r.queue=t,t=t.dispatch=Nx.bind(null,G,t),[r.memoizedState,t]},useRef:function(t){var e=St();return t={current:t},e.memoizedState=t},useState:hh,useDebugValue:Qc,useDeferredValue:function(t){return St().memoizedState=t},useTransition:function(){var t=hh(!1),e=t[0];return t=Cx.bind(null,t[1]),St().memoizedState=t,[e,t]},useMutableSource:function(){},useSyncExternalStore:function(t,e,n){var r=G,i=St();if(Q){if(n===void 0)throw Error(N(407));n=n()}else{if(n=e(),fe===null)throw Error(N(349));Xn&30||Zg(r,e,n)}i.memoizedState=n;var o={value:n,getSnapshot:e};return i.queue=o,ph(t0.bind(null,r,o,t),[t]),r.flags|=2048,io(9,e0.bind(null,r,o,n,e),void 0,null),n},useId:function(){var t=St(),e=fe.identifierPrefix;if(Q){var n=Vt,r=Bt;n=(r&~(1<<32-dt(r)-1)).toString(32)+n,e=":"+e+"R"+n,n=no++,0<\/script>",t=t.removeChild(t.firstChild)):typeof r.is=="string"?t=s.createElement(n,{is:r.is}):(t=s.createElement(n),n==="select"&&(s=t,r.multiple?s.multiple=!0:r.size&&(s.size=r.size))):t=s.createElementNS(t,n),t[kt]=e,t[Zi]=r,N0(t,e,!1,!1),e.stateNode=t;e:{switch(s=nu(n,r),n){case"dialog":K("cancel",t),K("close",t),i=r;break;case"iframe":case"object":case"embed":K("load",t),i=r;break;case"video":case"audio":for(i=0;iJr&&(e.flags|=128,r=!0,oi(o,!1),e.lanes=4194304)}else{if(!r)if(t=Js(s),t!==null){if(e.flags|=128,r=!0,n=t.updateQueue,n!==null&&(e.updateQueue=n,e.flags|=4),oi(o,!0),o.tail===null&&o.tailMode==="hidden"&&!s.alternate&&!Q)return ke(e),null}else 2*ne()-o.renderingStartTime>Jr&&n!==1073741824&&(e.flags|=128,r=!0,oi(o,!1),e.lanes=4194304);o.isBackwards?(s.sibling=e.child,e.child=s):(n=o.last,n!==null?n.sibling=s:e.child=s,o.last=s)}return o.tail!==null?(e=o.tail,o.rendering=e,o.tail=e.sibling,o.renderingStartTime=ne(),e.sibling=null,n=Y.current,J(Y,r?n&1|2:n&1),e):(ke(e),null);case 22:case 23:return tf(),r=e.memoizedState!==null,t!==null&&t.memoizedState!==null!==r&&(e.flags|=8192),r&&e.mode&1?Ue&1073741824&&(ke(e),e.subtreeFlags&6&&(e.flags|=8192)):ke(e),null;case 24:return null;case 25:return null}throw Error(N(156,e.tag))}function Fx(t,e){switch(Ic(e),e.tag){case 1:return $e(e.type)&&Vs(),t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 3:return jr(),q(Ve),q(Ce),jc(),t=e.flags,t&65536&&!(t&128)?(e.flags=t&-65537|128,e):null;case 5:return Uc(e),null;case 13:if(q(Y),t=e.memoizedState,t!==null&&t.dehydrated!==null){if(e.alternate===null)throw Error(N(340));Wr()}return t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 19:return q(Y),null;case 4:return jr(),null;case 10:return Vc(e.type._context),null;case 22:case 23:return tf(),null;case 24:return null;default:return null}}var Ko=!1,ve=!1,Ix=typeof WeakSet=="function"?WeakSet:Set,D=null;function vr(t,e){var n=t.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){Z(t,e,r)}else n.current=null}function Tu(t,e,n){try{n()}catch(r){Z(t,e,r)}}var Ch=!1;function bx(t,e){if(du=Is,t=Ag(),zc(t)){if("selectionStart"in t)var n={start:t.selectionStart,end:t.selectionEnd};else e:{n=(n=t.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var i=r.anchorOffset,o=r.focusNode;r=r.focusOffset;try{n.nodeType,o.nodeType}catch{n=null;break e}var s=0,l=-1,a=-1,u=0,c=0,f=t,d=null;t:for(;;){for(var p;f!==n||i!==0&&f.nodeType!==3||(l=s+i),f!==o||r!==0&&f.nodeType!==3||(a=s+r),f.nodeType===3&&(s+=f.nodeValue.length),(p=f.firstChild)!==null;)d=f,f=p;for(;;){if(f===t)break t;if(d===n&&++u===i&&(l=s),d===o&&++c===r&&(a=s),(p=f.nextSibling)!==null)break;f=d,d=f.parentNode}f=p}n=l===-1||a===-1?null:{start:l,end:a}}else n=null}n=n||{start:0,end:0}}else n=null;for(hu={focusedElem:t,selectionRange:n},Is=!1,D=e;D!==null;)if(e=D,t=e.child,(e.subtreeFlags&1028)!==0&&t!==null)t.return=e,D=t;else for(;D!==null;){e=D;try{var h=e.alternate;if(e.flags&1024)switch(e.tag){case 0:case 11:case 15:break;case 1:if(h!==null){var m=h.memoizedProps,k=h.memoizedState,g=e.stateNode,y=g.getSnapshotBeforeUpdate(e.elementType===e.type?m:at(e.type,m),k);g.__reactInternalSnapshotBeforeUpdate=y}break;case 3:var S=e.stateNode.containerInfo;S.nodeType===1?S.textContent="":S.nodeType===9&&S.documentElement&&S.removeChild(S.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(N(163))}}catch(w){Z(e,e.return,w)}if(t=e.sibling,t!==null){t.return=e.return,D=t;break}D=e.return}return h=Ch,Ch=!1,h}function Ri(t,e,n){var r=e.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var i=r=r.next;do{if((i.tag&t)===t){var o=i.destroy;i.destroy=void 0,o!==void 0&&Tu(e,n,o)}i=i.next}while(i!==r)}}function pl(t,e){if(e=e.updateQueue,e=e!==null?e.lastEffect:null,e!==null){var n=e=e.next;do{if((n.tag&t)===t){var r=n.create;n.destroy=r()}n=n.next}while(n!==e)}}function Au(t){var e=t.ref;if(e!==null){var n=t.stateNode;switch(t.tag){case 5:t=n;break;default:t=n}typeof e=="function"?e(t):e.current=t}}function O0(t){var e=t.alternate;e!==null&&(t.alternate=null,O0(e)),t.child=null,t.deletions=null,t.sibling=null,t.tag===5&&(e=t.stateNode,e!==null&&(delete e[kt],delete e[Zi],delete e[gu],delete e[Sx],delete e[kx])),t.stateNode=null,t.return=null,t.dependencies=null,t.memoizedProps=null,t.memoizedState=null,t.pendingProps=null,t.stateNode=null,t.updateQueue=null}function D0(t){return t.tag===5||t.tag===3||t.tag===4}function Nh(t){e:for(;;){for(;t.sibling===null;){if(t.return===null||D0(t.return))return null;t=t.return}for(t.sibling.return=t.return,t=t.sibling;t.tag!==5&&t.tag!==6&&t.tag!==18;){if(t.flags&2||t.child===null||t.tag===4)continue e;t.child.return=t,t=t.child}if(!(t.flags&2))return t.stateNode}}function Ru(t,e,n){var r=t.tag;if(r===5||r===6)t=t.stateNode,e?n.nodeType===8?n.parentNode.insertBefore(t,e):n.insertBefore(t,e):(n.nodeType===8?(e=n.parentNode,e.insertBefore(t,n)):(e=n,e.appendChild(t)),n=n._reactRootContainer,n!=null||e.onclick!==null||(e.onclick=Bs));else if(r!==4&&(t=t.child,t!==null))for(Ru(t,e,n),t=t.sibling;t!==null;)Ru(t,e,n),t=t.sibling}function Pu(t,e,n){var r=t.tag;if(r===5||r===6)t=t.stateNode,e?n.insertBefore(t,e):n.appendChild(t);else if(r!==4&&(t=t.child,t!==null))for(Pu(t,e,n),t=t.sibling;t!==null;)Pu(t,e,n),t=t.sibling}var he=null,ut=!1;function Qt(t,e,n){for(n=n.child;n!==null;)T0(t,e,n),n=n.sibling}function T0(t,e,n){if(Ct&&typeof Ct.onCommitFiberUnmount=="function")try{Ct.onCommitFiberUnmount(sl,n)}catch{}switch(n.tag){case 5:ve||vr(n,e);case 6:var r=he,i=ut;he=null,Qt(t,e,n),he=r,ut=i,he!==null&&(ut?(t=he,n=n.stateNode,t.nodeType===8?t.parentNode.removeChild(n):t.removeChild(n)):he.removeChild(n.stateNode));break;case 18:he!==null&&(ut?(t=he,n=n.stateNode,t.nodeType===8?ca(t.parentNode,n):t.nodeType===1&&ca(t,n),qi(t)):ca(he,n.stateNode));break;case 4:r=he,i=ut,he=n.stateNode.containerInfo,ut=!0,Qt(t,e,n),he=r,ut=i;break;case 0:case 11:case 14:case 15:if(!ve&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){i=r=r.next;do{var o=i,s=o.destroy;o=o.tag,s!==void 0&&(o&2||o&4)&&Tu(n,e,s),i=i.next}while(i!==r)}Qt(t,e,n);break;case 1:if(!ve&&(vr(n,e),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(l){Z(n,e,l)}Qt(t,e,n);break;case 21:Qt(t,e,n);break;case 22:n.mode&1?(ve=(r=ve)||n.memoizedState!==null,Qt(t,e,n),ve=r):Qt(t,e,n);break;default:Qt(t,e,n)}}function Mh(t){var e=t.updateQueue;if(e!==null){t.updateQueue=null;var n=t.stateNode;n===null&&(n=t.stateNode=new Ix),e.forEach(function(r){var i=Hx.bind(null,t,r);n.has(r)||(n.add(r),r.then(i,i))})}}function lt(t,e){var n=e.deletions;if(n!==null)for(var r=0;ri&&(i=s),r&=~o}if(r=i,r=ne()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*Bx(r/1960))-r,10t?16:t,cn===null)var r=!1;else{if(t=cn,cn=null,Gs=0,$&6)throw Error(N(331));var i=$;for($|=4,D=t.current;D!==null;){var o=D,s=o.child;if(D.flags&16){var l=o.deletions;if(l!==null){for(var a=0;ane()-Zc?Jn(t,0):Xc|=n),_e(t,e)}function L0(t,e){e===0&&(t.mode&1?(e=Bo,Bo<<=1,!(Bo&130023424)&&(Bo=4194304)):e=1);var n=De();t=Jt(t,e),t!==null&&(So(t,e,n),_e(t,n))}function jx(t){var e=t.memoizedState,n=0;e!==null&&(n=e.retryLane),L0(t,n)}function Hx(t,e){var n=0;switch(t.tag){case 13:var r=t.stateNode,i=t.memoizedState;i!==null&&(n=i.retryLane);break;case 19:r=t.stateNode;break;default:throw Error(N(314))}r!==null&&r.delete(e),L0(t,n)}var B0;B0=function(t,e,n){if(t!==null)if(t.memoizedProps!==e.pendingProps||Ve.current)be=!0;else{if(!(t.lanes&n)&&!(e.flags&128))return be=!1,Px(t,e,n);be=!!(t.flags&131072)}else be=!1,Q&&e.flags&1048576&&_g(e,Ws,e.index);switch(e.lanes=0,e.tag){case 2:var r=e.type;ms(t,e),t=e.pendingProps;var i=_r(e,Ce.current);Ar(e,n),i=Jc(null,e,r,t,i,n);var o=Kc();return e.flags|=1,typeof i=="object"&&i!==null&&typeof i.render=="function"&&i.$$typeof===void 0?(e.tag=1,e.memoizedState=null,e.updateQueue=null,$e(r)?(o=!0,$s(e)):o=!1,e.memoizedState=i.state!==null&&i.state!==void 0?i.state:null,_c(e),i.updater=dl,e.stateNode=i,i._reactInternals=e,xu(e,r,t,n),e=Mu(null,e,r,!0,o,n)):(e.tag=0,Q&&o&&Fc(e),Me(null,e,i,n),e=e.child),e;case 16:r=e.elementType;e:{switch(ms(t,e),t=e.pendingProps,i=r._init,r=i(r._payload),e.type=r,i=e.tag=Kx(r),t=at(r,t),i){case 0:e=Nu(null,e,r,t,n);break e;case 1:e=wh(null,e,r,t,n);break e;case 11:e=Sh(null,e,r,t,n);break e;case 14:e=kh(null,e,r,at(r.type,t),n);break e}throw Error(N(306,r,""))}return e;case 0:return r=e.type,i=e.pendingProps,i=e.elementType===r?i:at(r,i),Nu(t,e,r,i,n);case 1:return r=e.type,i=e.pendingProps,i=e.elementType===r?i:at(r,i),wh(t,e,r,i,n);case 3:e:{if(v0(e),t===null)throw Error(N(387));r=e.pendingProps,o=e.memoizedState,i=o.element,Hg(t,e),Hs(e,r,null,n);var s=e.memoizedState;if(r=s.element,o.isDehydrated)if(o={element:r,isDehydrated:!1,cache:s.cache,pendingSuspenseBoundaries:s.pendingSuspenseBoundaries,transitions:s.transitions},e.updateQueue.baseState=o,e.memoizedState=o,e.flags&256){i=Hr(Error(N(423)),e),e=vh(t,e,r,n,i);break e}else if(r!==i){i=Hr(Error(N(424)),e),e=vh(t,e,r,n,i);break e}else for(He=gn(e.stateNode.containerInfo.firstChild),Ke=e,Q=!0,ft=null,n=Qg(e,null,r,n),e.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(Wr(),r===i){e=Kt(t,e,n);break e}Me(t,e,r,n)}e=e.child}return e;case 5:return Yg(e),t===null&&ku(e),r=e.type,i=e.pendingProps,o=t!==null?t.memoizedProps:null,s=i.children,pu(r,i)?s=null:o!==null&&pu(r,o)&&(e.flags|=32),w0(t,e),Me(t,e,s,n),e.child;case 6:return t===null&&ku(e),null;case 13:return x0(t,e,n);case 4:return Wc(e,e.stateNode.containerInfo),r=e.pendingProps,t===null?e.child=Ur(e,null,r,n):Me(t,e,r,n),e.child;case 11:return r=e.type,i=e.pendingProps,i=e.elementType===r?i:at(r,i),Sh(t,e,r,i,n);case 7:return Me(t,e,e.pendingProps,n),e.child;case 8:return Me(t,e,e.pendingProps.children,n),e.child;case 12:return Me(t,e,e.pendingProps.children,n),e.child;case 10:e:{if(r=e.type._context,i=e.pendingProps,o=e.memoizedProps,s=i.value,J(Us,r._currentValue),r._currentValue=s,o!==null)if(mt(o.value,s)){if(o.children===i.children&&!Ve.current){e=Kt(t,e,n);break e}}else for(o=e.child,o!==null&&(o.return=e);o!==null;){var l=o.dependencies;if(l!==null){s=o.child;for(var a=l.firstContext;a!==null;){if(a.context===r){if(o.tag===1){a=_t(-1,n&-n),a.tag=2;var u=o.updateQueue;if(u!==null){u=u.shared;var c=u.pending;c===null?a.next=a:(a.next=c.next,c.next=a),u.pending=a}}o.lanes|=n,a=o.alternate,a!==null&&(a.lanes|=n),wu(o.return,n,e),l.lanes|=n;break}a=a.next}}else if(o.tag===10)s=o.type===e.type?null:o.child;else if(o.tag===18){if(s=o.return,s===null)throw Error(N(341));s.lanes|=n,l=s.alternate,l!==null&&(l.lanes|=n),wu(s,n,e),s=o.sibling}else s=o.child;if(s!==null)s.return=o;else for(s=o;s!==null;){if(s===e){s=null;break}if(o=s.sibling,o!==null){o.return=s.return,s=o;break}s=s.return}o=s}Me(t,e,i.children,n),e=e.child}return e;case 9:return i=e.type,r=e.pendingProps.children,Ar(e,n),i=it(i),r=r(i),e.flags|=1,Me(t,e,r,n),e.child;case 14:return r=e.type,i=at(r,e.pendingProps),i=at(r.type,i),kh(t,e,r,i,n);case 15:return S0(t,e,e.type,e.pendingProps,n);case 17:return r=e.type,i=e.pendingProps,i=e.elementType===r?i:at(r,i),ms(t,e),e.tag=1,$e(r)?(t=!0,$s(e)):t=!1,Ar(e,n),Kg(e,r,i),xu(e,r,i,n),Mu(null,e,r,!0,t,n);case 19:return C0(t,e,n);case 22:return k0(t,e,n)}throw Error(N(156,e.tag))};function V0(t,e){return fg(t,e)}function Jx(t,e,n,r){this.tag=t,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=e,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function tt(t,e,n,r){return new Jx(t,e,n,r)}function rf(t){return t=t.prototype,!(!t||!t.isReactComponent)}function Kx(t){if(typeof t=="function")return rf(t)?1:0;if(t!=null){if(t=t.$$typeof,t===xc)return 11;if(t===Cc)return 14}return 2}function wn(t,e){var n=t.alternate;return n===null?(n=tt(t.tag,e,t.key,t.mode),n.elementType=t.elementType,n.type=t.type,n.stateNode=t.stateNode,n.alternate=t,t.alternate=n):(n.pendingProps=e,n.type=t.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=t.flags&14680064,n.childLanes=t.childLanes,n.lanes=t.lanes,n.child=t.child,n.memoizedProps=t.memoizedProps,n.memoizedState=t.memoizedState,n.updateQueue=t.updateQueue,e=t.dependencies,n.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext},n.sibling=t.sibling,n.index=t.index,n.ref=t.ref,n}function Ss(t,e,n,r,i,o){var s=2;if(r=t,typeof t=="function")rf(t)&&(s=1);else if(typeof t=="string")s=5;else e:switch(t){case dr:return Kn(n.children,i,o,e);case vc:s=8,i|=8;break;case Ja:return t=tt(12,n,e,i|2),t.elementType=Ja,t.lanes=o,t;case Ka:return t=tt(13,n,e,i),t.elementType=Ka,t.lanes=o,t;case qa:return t=tt(19,n,e,i),t.elementType=qa,t.lanes=o,t;case qm:return gl(n,i,o,e);default:if(typeof t=="object"&&t!==null)switch(t.$$typeof){case Jm:s=10;break e;case Km:s=9;break e;case xc:s=11;break e;case Cc:s=14;break e;case Xt:s=16,r=null;break e}throw Error(N(130,t==null?t:typeof t,""))}return e=tt(s,n,e,i),e.elementType=t,e.type=r,e.lanes=o,e}function Kn(t,e,n,r){return t=tt(7,t,r,e),t.lanes=n,t}function gl(t,e,n,r){return t=tt(22,t,r,e),t.elementType=qm,t.lanes=n,t.stateNode={isHidden:!1},t}function Sa(t,e,n){return t=tt(6,t,null,e),t.lanes=n,t}function ka(t,e,n){return e=tt(4,t.children!==null?t.children:[],t.key,e),e.lanes=n,e.stateNode={containerInfo:t.containerInfo,pendingChildren:null,implementation:t.implementation},e}function qx(t,e,n,r,i){this.tag=e,this.containerInfo=t,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Zl(0),this.expirationTimes=Zl(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Zl(0),this.identifierPrefix=r,this.onRecoverableError=i,this.mutableSourceEagerHydrationData=null}function of(t,e,n,r,i,o,s,l,a){return t=new qx(t,e,n,l,a),e===1?(e=1,o===!0&&(e|=8)):e=0,o=tt(3,null,null,e),t.current=o,o.stateNode=t,o.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},_c(o),t}function Qx(t,e,n){var r=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(U0)}catch(t){console.error(t)}}U0(),_m.exports=Qe;var Kr=_m.exports,j0,zh=Kr;j0=zh.createRoot,zh.hydrateRoot;const xo=C.createContext(null),H0=C.createContext(null);function eC(t){const e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(t.editable),t.someProp("attributes",n=>{if(typeof n=="function"&&(n=n(t.state)),n)for(const r in n)r=="class"?e.class+=" "+n[r]:r=="style"?e.style=(e.style?e.style+";":"")+n[r]:!e[r]&&r!="contenteditable"&&r!="nodeName"&&(e[r]=String(n[r]))}),e.translate||(e.translate="no"),[me.node(0,t.state.doc.content.size,e)]}const tC=[],nC={},Lu=W.empty;class bn{constructor(e){this.members=e}map(e,n){const r=this.members.map(i=>i.map(e,n,nC));return bn.from(r)}forChild(e,n){if(n.isLeaf)return W.empty;let r=[];for(let i=0;in instanceof W)?e:e.reduce((n,r)=>n.concat(r instanceof W?r:r.members),[]))}}}function J0(t,e){return t.from-e.from||t.to-e.to}function rC(t){let e=t;for(let n=0;n0;)e++;t.splice(e,0,n)}function iC(t,e){const n=[];return t.someProp("decorations",r=>{const i=r(t.state);i&&i!=Lu&&n.push(i)}),e&&n.push(W.create(t.state.doc,[e])),bn.from(n)}const uf=function(t){for(let e=0;;e++)if(t=t.previousSibling,!t)return e},Ih=function(t){const e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e},oC=function(t,e,n,r){return n&&(bh(t,e,n,r,-1)||bh(t,e,n,r,1))},sC=/^(img|br|input|textarea|hr)$/i;function bh(t,e,n,r,i){for(;;){if(t==n&&e==r)return!0;if(e==(i<0?0:el(t))){const o=t.parentNode;if(!o||o.nodeType!=1||aC(t)||sC.test(t.nodeName)||t.contentEditable=="false")return!1;e=uf(t)+(i<0?0:1),t=o}else if(t.nodeType==1){if(t=t.childNodes[e+(i<0?-1:0)],t.contentEditable=="false")return!1;e=i<0?el(t):0}else return!1}}function el(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function lC(t,e,n){for(let r=e==0,i=e==el(t);r||i;){if(t==n)return!0;const o=uf(t);if(t=t.parentNode,!t)return!1;r=r&&o==0,i=i&&o==el(t)}return!1}function aC(t){let e;for(let n=t;n&&!(e=n.pmViewDesc);n=n.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==t||e.contentDOM==t)}const K0=function(t){return t.focusNode&&oC(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)},q0=C.createContext(null);function uC(t,e){const n=C.useContext(q0);C.useLayoutEffect(()=>n(t),e)}function Q0(t,e){const{view:n}=C.useContext(xo);uC(()=>{if(n)return t(n)},e&&[n,...e])}const cC=C.forwardRef(function({widget:e,pos:n,...r},i){const[o,s]=C.useState(!0),l=C.useRef(null);return C.useImperativeHandle(i,()=>l.current,[]),Q0(a=>{if(!a||!l.current)return;a.domObserver.disconnectSelection();const u=a.domSelection(),c=document.createRange(),f=l.current;f.nodeName=="IMG"&&f.parentNode?c.setEnd(f.parentNode,uf(f)+1):c.setEnd(f,0),c.collapse(!1),u.removeAllRanges(),u.addRange(c),s(!1),a.domObserver.connectSelection()},[]),o?F("img",{ref:l,className:"ProseMirror-separator","mark-placeholder":"true",alt:"",...r}):null});function fC(t,e){if(t==e)return!0;for(const n in t)if(t[n]!==e[n])return!1;for(const n in e)if(!(n in t))return!1;return!0}const dC={side:0};class so{constructor(e,n){this.Component=e,this.spec=n??dC,this.side=this.spec.side??0}map(e,n,r,i){const{pos:o,deleted:s}=e.mapResult(n.from+i,this.side<0?-1:1);return s?null:new me(o-r,o-r,this)}valid(){return!0}eq(e){return this==e||e instanceof so&&(this.spec.key&&this.spec.key==e.spec.key||this.Component==e.Component&&fC(this.spec,e.spec))}destroy(){}}function Y0(t,e,n){return new me(t,t,new so(e,n))}function wa(){return Math.floor(Math.random()*16777215).toString(16)}const lo=new po("@nytimes/react-prosemirror/reactKeys");function hC(){let t=!1;return new At({key:lo,state:{init(e,n){const r={posToKey:new Map,keyToPos:new Map};return n.doc.descendants((i,o)=>{const s=wa();return r.posToKey.set(o,s),r.keyToPos.set(s,o),!0}),r},apply(e,n,r,i){if(!e.docChanged||t)return n;const o=e.getMeta(lo),s=(o==null?void 0:o.type)==="bustKey"&&o.payload.key,l={posToKey:new Map,keyToPos:new Map},a=Array.from(n.posToKey.entries()).sort(([u],[c])=>u-c);for(const[u,c]of a){const{pos:f,deleted:d}=e.mapping.mapResult(u);if(d)continue;let p=c;s===c&&(p=wa()),l.posToKey.set(f,p),l.keyToPos.set(p,f)}return i.doc.descendants((u,c)=>{if(l.posToKey.has(c))return!0;const f=wa();return l.posToKey.set(c,f),l.keyToPos.set(f,c),!0}),l}},props:{handleDOMEvents:{compositionstart:()=>{t=!0},compositionend:()=>{t=!1}}}})}const pC=/\s/,mC=/[\u0021-\u0023\u0025-\u002A\u002C-\u002F\u003A\u003B\u003F\u0040\u005B-\u005D\u005F\u007B\u007D\u00A1\u00A7\u00AB\u00B6\u00B7\u00BB\u00BF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061E\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u0AF0\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166D\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E3B\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]/,gC=/['\u2018\u2019]/,ao=(t,e,n=-1)=>{if(t.resolve(e).parentOffset===0)return!1;const i=t.textBetween(e+n,e,null," ");return pC.test(i)?!1:gC.test(i)&&ao(t,e-1)?!0:!mC.test(i)};function va(t,e,n={}){var s,l;if(e===null)return!1;const r=n.from??t.state.selection.from,i=n.to??t.state.selection.to;if((s=t.someProp("handleTextInput"))!=null&&s(t,r,i,e))return!0;const{tr:o}=t.state;if(n.marks&&o.ensureMarks(n.marks),o.insertText(e,r,i),n.bust){const a=t.state.doc.resolve(r),u=a.sharedDepth(i),c=a.start(u),f=(l=lo.getState(t.state))==null?void 0:l.posToKey.get(c-1);o.setMeta(lo,{type:"bustKey",payload:{key:f}})}return t.dispatch(o),!0}function yC(t,e){let n=e;for(;!ao(t,n);)n--;for(;ao(t,n);)n--;return n}function SC(t,e){let n=e;for(;!ao(t,n,1);)n++;for(;ao(t,n,1);)n++;return n}function kC(t){let e=null,n=null;return new At({props:{handleDOMEvents:{compositionstart(r){var s;const{state:i}=r;r.dispatch(i.tr.deleteSelection());const o=i.selection.$from;return i.selection.empty&&(i.storedMarks||!o.textOffset&&o.parentOffset&&((s=o.nodeBefore)!=null&&s.marks.some(l=>l.type.spec.inclusive===!1)))&&t(Y0(i.selection.from,cC,{key:"cursor-wrapper",marks:i.storedMarks??o.marks()})),n=i.storedMarks??o.marks(),r.input.composing=!0,!0},compositionupdate(){return!0},compositionend(r){if(r.input.composing=!1,e!==null)return va(r,e,{bust:!0,marks:n}),e=null,n=null,t(null),!0},beforeinput(r,i){var o,s;switch(i.preventDefault(),i.inputType){case"insertCompositionText":{if(i.data===null)break;e=i.data;break}case"insertReplacementText":{const l=i.getTargetRanges();(s=(o=i.dataTransfer)==null?void 0:o.items[0])==null||s.getAsString(a=>{for(const u of l){const c=r.docView.posFromDOM(u.startContainer,u.startOffset,1),f=r.docView.posFromDOM(u.endContainer,u.endOffset,1);va(r,a,{from:c,to:f})}});break}case"insertText":{va(r,i.data);break}case"deleteWordBackward":{const{tr:l,doc:a,selection:u}=r.state,c=u.empty?yC(r.state.doc,u.from):u.from,f=u.to,d=a.resolve(c).marksAcross(a.resolve(f));l.delete(c,f).setStoredMarks(d),r.dispatch(l);break}case"deleteWordForward":{const{tr:l,doc:a,selection:u}=r.state,c=u.empty?SC(r.state.doc,u.from):u.from,f=u.to,d=a.resolve(c).marksAcross(a.resolve(f));l.delete(c,f).setStoredMarks(d),r.dispatch(l);break}case"deleteContentBackward":{const{tr:l,doc:a,selection:u}=r.state,c=u.empty?u.from-1:u.from,f=u.to,d=a.resolve(c).marksAcross(a.resolve(f));l.delete(c,f).setStoredMarks(d),r.dispatch(l);break}case"deleteContentForward":{const{tr:l,doc:a,selection:u}=r.state,c=u.from,f=u.empty?u.to+1:u.to,d=a.resolve(c).marksAcross(a.resolve(f));l.delete(c,f).setStoredMarks(d);break}case"deleteContent":{const{tr:l,doc:a,selection:u}=r.state,c=a.resolve(u.from).marksAcross(a.resolve(u.to));l.delete(u.from,u.to).setStoredMarks(c),r.dispatch(l);break}}return!0}}}})}const Dt=typeof navigator<"u"?navigator:null,Lh=typeof document<"u"?document:null,Dn=Dt&&Dt.userAgent||"",Bu=/Edge\/(\d+)/.exec(Dn),G0=/MSIE \d/.exec(Dn),Vu=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Dn),vl=!!(G0||Vu||Bu),wC=G0?document.documentMode:Vu?+Vu[1]:Bu?+Bu[1]:0,X0=!vl&&/gecko\/(\d+)/i.test(Dn),vC=X0&&+(/Firefox\/(\d+)/.exec(Dn)||[0,0])[1],$u=!vl&&/Chrome\/(\d+)/.exec(Dn),xC=!!$u,CC=$u?+$u[1]:0,Z0=!vl&&!!Dt&&/Apple Computer/.test(Dt.vendor),ey=Z0&&(/Mobile\/\w+/.test(Dn)||!!Dt&&Dt.maxTouchPoints>2),NC=ey||(Dt?/Mac/.test(Dt.platform):!1),MC=Dt?/Win/.test(Dt.platform):!1,EC=/Android \d/.test(Dn),ty=!!Lh&&"webkitFontSmoothing"in Lh.documentElement.style,OC=ty?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0,Le={ie:vl,ie_version:wC,gecko:X0,gecko_version:vC,chrome:xC,chrome_version:CC,safari:Z0,ios:ey,mac:NC,windows:MC,android:EC,webkit:ty,webkit_version:OC};function Bh(t){return t.editable&&!t.hasFocus()?!1:DC(t)}function DC(t){var n,r;const e=t.domSelectionRange();if(!e.anchorNode)return!1;try{return t.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(t.editable||t.dom.contains(((n=e.focusNode)==null?void 0:n.nodeType)==3?(r=e.focusNode)==null?void 0:r.parentNode:e.focusNode))}catch{return!1}}function TC(t,e,n,r){return t.someProp("createSelectionBetween",i=>i(t,e,n))||B.between(e,n,r)}function Vh(t,e=null){const n=t.domSelectionRange(),r=t.state.doc;if(!n.focusNode)return null;let i=t.docView.nearestDesc(n.focusNode);const o=i&&i.size==0,s=t.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(s<0)return null;const l=r.resolve(s);let a,u;if(K0(n)){for(a=l;i&&!i.node;)i=i.parent;const c=i.node;if(i&&c.isAtom&&z.isSelectable(c)&&i.parent&&!(c.isInline&&lC(n.focusNode,n.focusOffset,i.dom))){const f=i.posBefore;u=new z(s==f?l:r.resolve(f))}}else{const c=t.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(c<0)return null;a=r.resolve(c)}if(!u){const c=e=="pointer"||t.state.selection.head{(r.anchorNode!=i||r.anchorOffset!=o)&&(n.removeEventListener("selectionchange",e.input.hideSelectionGuard),setTimeout(()=>{(!ny(e)||e.state.selection.visible)&&e.dom.classList.remove("ProseMirror-hideselection")},20))})}const Hh=Le.safari||Le.chrome&&Le.chrome_version<63;function Yo(t,e=!1){const n=t,r=n.state.selection;if(PC(n,r),!!ny(n)){if(!e&&n.input.mouseDown&&n.input.mouseDown.allowDefault&&Le.chrome){const i=n.domSelectionRange(),o=n.domObserver.currentSelection;if(i.anchorNode&&o.anchorNode&&tl(i.anchorNode,i.anchorOffset,o.anchorNode,o.anchorOffset)){n.input.mouseDown.delayedSelectionSync=!0,n.domObserver.setCurSelection();return}}if(n.domObserver.disconnectSelection(),n.cursorWrapper)FC(n);else{const{anchor:i,head:o}=r;let s,l;Hh&&!(r instanceof B)&&(r.$from.parent.inlineContent||(s=Uh(n,r.from)),!r.empty&&!r.$from.parent.inlineContent&&(l=Uh(n,r.to))),n.docView.setSelection(i,o,n.root,e),Hh&&(s&&jh(s),l&&jh(l)),r.visible?n.dom.classList.remove("ProseMirror-hideselection"):(n.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&IC(n))}n.domObserver.setCurSelection(),n.domObserver.connectSelection()}}class bC{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}}class LC{constructor(e){this.view=e,this.flushingSoon=-1,this.currentSelection=new bC,this.suppressingSelectionUpdates=!1,this.view=e,this.onSelectionChange=this.onSelectionChange.bind(this)}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}stop(){this.disconnectSelection()}start(){this.connectSelection()}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;const n=new Set;let r;for(let o=e.focusNode;o;o=Ih(o))n.add(o);for(let o=e.anchorNode;o;o=Ih(o))if(n.has(o)){r=o;break}const i=r&&this.view.docView.nearestDesc(r);if(i&&i.ignoreMutation({type:"selection",target:(r==null?void 0:r.nodeType)==3?r==null?void 0:r.parentNode:r}))return this.setCurSelection(),!0}registerMutation(){}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}updateSelection(){const{view:e}=this,n=e.input.compositionPendingChanges||(e.composing?e.input.compositionID:0);e.input.compositionPendingChanges=0;const r=e.input.lastSelectionTime>Date.now()-50?e.input.lastSelectionOrigin:null,i=Vh(e,r);if(i&&!e.state.selection.eq(i)){const o=e.state.tr.setSelection(i);r=="pointer"?o.setMeta("pointer",!0):r=="key"&&o.scrollIntoView(),n&&o.setMeta("composition",n),e.dispatch(o)}}selectionToDOM(){const{view:e}=this;Yo(e);const n=e.domSelectionRange();this.currentSelection.set(n)}flush(){const{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;const n=e.domSelectionRange(),r=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(n)&&Bh(e)&&!this.ignoreSelectionChange(n);let i=null;r&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}onSelectionChange(){if(Bh(this.view)&&!this.view.composing){if(this.suppressingSelectionUpdates)return Yo(this.view);if(Le.ie&&Le.ie_version<=11&&!this.view.state.selection.empty){const e=this.view.domSelectionRange();if(e.focusNode&&tl(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}}const qr=0,Jh=1,Go=2,uo=3;class Co{constructor(e,n,r,i){this.parent=e,this.children=n,this.dom=r,this.contentDOM=i,this.dirty=qr,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,n,r){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let n=0;nen(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))i=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(n==0)for(let o=e;;o=o.parentNode){if(o==this.dom){i=!1;break}if(o.previousSibling)break}if(i==null&&n==e.childNodes.length)for(let o=e;;o=o.parentNode){if(o==this.dom){i=!0;break}if(o.nextSibling)break}}return i??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,n=!1){for(let r=!0,i=e;i;i=i.parentNode){const o=this.getDesc(i);let s;if(o&&(!n||o.node))if(r&&(s=o.nodeDOM)&&!(s.nodeType==1?s.contains(e.nodeType==1?e:e.parentNode):s==e))r=!1;else return o}}getDesc(e){const n=e.pmViewDesc;for(let r=n;r;r=r.parent)if(r==this)return n}posFromDOM(e,n,r){for(let i=e;i;i=i.parentNode){const o=this.getDesc(i);if(o)return o.localPosFromDOM(e,n,r)}return-1}descAt(e){for(let n=0,r=0;ne||s instanceof ry){i=e-o;break}o=l}if(i)return this.children[r].domFromPos(i-this.children[r].border,n);for(let o;r&&!(o=this.children[r-1]).size&&o instanceof cf&&o.side>=0;r--);if(n<=0){let o,s=!0;for(;o=r?this.children[r-1]:null,!(!o||o.dom.parentNode==this.contentDOM);r--,s=!1);return o&&n&&s&&!o.border&&!o.domAtom?o.domFromPos(o.size,n):{node:this.contentDOM,offset:o?en(o.dom)+1:0}}else{let o,s=!0;for(;o=r=c&&n<=u-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,n,c);e=s;for(let f=l;f>0;f--){const d=this.children[f-1];if(d.size&&d.dom.parentNode==this.contentDOM&&!d.emptyChildAt(1)){i=en(d.dom)+1;break}e-=d.size}i==-1&&(i=0)}if(i>-1&&(u>n||l==this.children.length-1)){n=u;for(let c=l+1;ch&&sn){const h=l;l=a,a=h}const p=document.createRange();p.setEnd(a.node,a.offset),p.setStart(l.node,l.offset),u.removeAllRanges(),u.addRange(p)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,n){for(let r=0,i=0;i=r:er){const l=r+o.border,a=s-o.border;if(e>=l&&n<=a){this.dirty=e==r||n==s?Go:Jh,e==l&&n==a&&(o.contentLost||o.dom.parentNode!=this.contentDOM)?o.dirty=uo:o.markDirty(e-l,n-l);return}else o.dirty=o.dom==o.contentDOM&&o.dom.parentNode==this.contentDOM&&!o.children.length?Go:uo}r=s}this.dirty=Go}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){const r=e==1?Go:Jh;n.dirtythis.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let n=this.children.length-1;n>=0;n--){const r=this.children[n];if(this.dom.contains(r.dom.parentNode)){e.contentElement=r.dom.parentNode;break}}e.contentElement||(e.getContent=()=>v.empty)}return e}matchesNode(e,n,r){return this.dirty==qr&&e.eq(this.node)&&_C(n,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}update(e,n,r,i){return!0}selectNode(){this.nodeDOM.nodeType==1&&this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.dom.draggable=!0)}deselectNode(){this.nodeDOM.nodeType==1&&this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.dom.removeAttribute("draggable")}get domAtom(){return this.node.isAtom}}class $C extends ff{constructor(e,n,r,i,o,s,l){super(e,n,r,i,o,s,null,l)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,n,r,i){return!0}inParent(){const e=this.parent.contentDOM;for(let n=this.nodeDOM;n;n=n.parentNode)if(n==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,n,r){return e==this.nodeDOM?this.posAtStart+Math.min(n,this.node.text.length):super.localPosFromDOM(e,n,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}markDirty(e,n){super.markDirty(e,n),this.dom!=this.nodeDOM&&(e==0||n==this.nodeDOM.nodeValue.length)&&(this.dirty=uo)}get domAtom(){return!1}}class ry extends Co{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==qr&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}function _C(t,e){if(t.length!=e.length)return!1;for(let n=0;n{u=!!a.call(this,s,l)}),u||l.defaultPrevented)return!0}return!1};e[r]=o}return new At({key:new po("@nytimes/react-prosemirror/componentEventListeners"),props:{handleDOMEvents:e}})}function UC(){const[t,e]=C.useState(new Map),n=C.useCallback((o,s)=>{const l=t.get(o)??[];l.unshift(s),t.has(o)||(t.set(o,l),e(new Map(t)))},[t]),r=C.useCallback((o,s)=>{const l=t.get(o);l==null||l.splice(l.indexOf(s),1)},[t]),i=C.useMemo(()=>WC(t),[t]);return{registerEventListener:n,unregisterEventListener:r,componentEventListenersPlugin:i}}function iy(){const[,t]=C.useReducer(e=>e+1,0);return t}class jC extends Tk{constructor(e,n){super(e,{state:on.create({schema:n.state.schema,plugins:n.state.plugins}),plugins:n.plugins}),this.shouldUpdatePluginViews=!1,this.shouldUpdatePluginViews=!0,this._props=n,this.oldProps={state:n.state},this.state=n.state,this.domObserver.stop(),this.domObserver=new LC(this),this.domObserver.start(),this.docView.dom.replaceChildren(),this.docView=n.docView}pureSetProps(e){this._props={...this._props,...e},this.state=this._props.state}runPendingEffects(){const e=this.props;this._props=this.oldProps,this.state=this._props.state,this.update(e)}update(e){super.update(e),this.oldProps=e}updatePluginViews(){this.shouldUpdatePluginViews&&super.updatePluginViews()}}const HC=new Sp({nodes:{doc:{content:"text*"},text:{inline:!0}}}),JC=on.create({schema:HC});function KC(t,e){const[n,r]=C.useState(null),[i,o]=C.useState(null),s=iy(),l=e.defaultState??JC,[a,u]=C.useState(l),c=e.state??a,{componentEventListenersPlugin:f,registerEventListener:d,unregisterEventListener:p}=UC(),h=C.useCallback(w=>{Kr.flushSync(()=>{o(w)})},[]),m=C.useMemo(()=>[...e.plugins??[],f,kC(h)],[e.plugins,f,h]);function k(w){Kr.flushSync(()=>{e.state||u(M=>M.apply(w)),e.dispatchTransaction&&e.dispatchTransaction.call(this,w)})}const g=document.createElement("div"),y=C.useRef(new ff(void 0,[],c.doc,[],W.empty,g,null,g)),S={...e,state:c,plugins:m,dispatchTransaction:k,docView:y.current};return C.useLayoutEffect(()=>{if(n&&n.dom!==t&&r(null),!!t&&!n){const w=new jC({mount:t},S);r(w),w.dom.addEventListener("compositionend",s);return}}),n==null||n.pureSetProps(S),C.useMemo(()=>({view:n,state:c,registerEventListener:d,unregisterEventListener:p,cursorWrapper:i,docViewDescRef:y}),[n,c,d,p,i])}function qC(t){C.useLayoutEffect(()=>{t==null||t.domObserver.selectionToDOM(),t==null||t.runPendingEffects()},[t,t==null?void 0:t.props])}function QC({children:t}){const e=C.useRef(new Set).current,n=C.useRef(new Set).current,r=C.useRef(!1),i=iy(),o=C.useRef(!0),s=C.useCallback(()=>{o.current||(i(),o.current=!0)},[i]),l=C.useCallback(a=>{let u;const c=()=>{u=a()};return e.add(c),s(),()=>{e.delete(c),u&&(r.current?(n.add(u),s()):u())}},[e,n,s]);return C.useLayoutEffect(()=>(o.current=!1,e.forEach(a=>a()),e.clear(),()=>{n.forEach(a=>a()),n.clear()})),C.useLayoutEffect(()=>(r.current=!0,()=>{r.current=!1}),[]),F(q0.Provider,{value:l,children:t})}const Tt=C.createContext([]);function oy(t,e,n,r,i,o,s){const l=C.useRef(o),a=C.useContext(Tt),u=[];return C.useLayoutEffect(()=>{if(!t||!n.current)return;const c=u[0];l.current?(l.current.parent=void 0,l.current.children=u,l.current.node=t,l.current.outerDeco=i,l.current.innerDeco=r,l.current.dom=(e==null?void 0:e.current)??n.current,l.current.dom.pmViewDesc=l.current,l.current.contentDOM=(s==null?void 0:s.current)??l.current.contentDOM??(c==null?void 0:c.dom.parentElement)??null,l.current.nodeDOM=n.current):l.current=new ff(void 0,u,t,i,r,(e==null?void 0:e.current)??n.current,(c==null?void 0:c.dom.parentElement)??null,n.current),a.push(l.current);for(const f of u)f.parent=l.current}),u}var sy={exports:{}};/*! +`+o.stack}return{value:t,source:e,stack:i,digest:null}}function ga(t,e,n){return{value:t,source:null,stack:n??null,digest:e??null}}function Cu(t,e){try{console.error(e.value)}catch(n){setTimeout(function(){throw n})}}var Tx=typeof WeakMap=="function"?WeakMap:Map;function g0(t,e,n){n=_t(-1,n),n.tag=3,n.payload={element:null};var r=e.value;return n.callback=function(){Ys||(Ys=!0,zu=r),Cu(t,e)},n}function y0(t,e,n){n=_t(-1,n),n.tag=3;var r=t.type.getDerivedStateFromError;if(typeof r=="function"){var i=e.value;n.payload=function(){return r(i)},n.callback=function(){Cu(t,e)}}var o=t.stateNode;return o!==null&&typeof o.componentDidCatch=="function"&&(n.callback=function(){Cu(t,e),typeof r!="function"&&(Sn===null?Sn=new Set([this]):Sn.add(this));var s=e.stack;this.componentDidCatch(e.value,{componentStack:s!==null?s:""})}),n}function mh(t,e,n){var r=t.pingCache;if(r===null){r=t.pingCache=new Tx;var i=new Set;r.set(e,i)}else i=r.get(e),i===void 0&&(i=new Set,r.set(e,i));i.has(n)||(i.add(n),t=Ux.bind(null,t,e,n),e.then(t,t))}function gh(t){do{var e;if((e=t.tag===13)&&(e=t.memoizedState,e=e!==null?e.dehydrated!==null:!0),e)return t;t=t.return}while(t!==null);return null}function yh(t,e,n,r,i){return t.mode&1?(t.flags|=65536,t.lanes=i,t):(t===e?t.flags|=65536:(t.flags|=128,n.flags|=131072,n.flags&=-52805,n.tag===1&&(n.alternate===null?n.tag=17:(e=_t(-1,1),e.tag=2,yn(n,e,1))),n.lanes|=1),t)}var Ax=qt.ReactCurrentOwner,be=!1;function Me(t,e,n,r){e.child=t===null?Qg(e,null,n,r):Ur(e,t.child,n,r)}function Sh(t,e,n,r,i){n=n.render;var o=e.ref;return Ar(e,i),r=Jc(t,e,n,r,o,i),n=Kc(),t!==null&&!be?(e.updateQueue=t.updateQueue,e.flags&=-2053,t.lanes&=~i,Kt(t,e,i)):(Q&&n&&Fc(e),e.flags|=1,Me(t,e,r,i),e.child)}function kh(t,e,n,r,i){if(t===null){var o=n.type;return typeof o=="function"&&!rf(o)&&o.defaultProps===void 0&&n.compare===null&&n.defaultProps===void 0?(e.tag=15,e.type=o,S0(t,e,o,r,i)):(t=Ss(n.type,null,r,e,e.mode,i),t.ref=e.ref,t.return=e,e.child=t)}if(o=t.child,!(t.lanes&i)){var s=o.memoizedProps;if(n=n.compare,n=n!==null?n:Yi,n(s,r)&&t.ref===e.ref)return Kt(t,e,i)}return e.flags|=1,t=wn(o,r),t.ref=e.ref,t.return=e,e.child=t}function S0(t,e,n,r,i){if(t!==null){var o=t.memoizedProps;if(Yi(o,r)&&t.ref===e.ref)if(be=!1,e.pendingProps=r=o,(t.lanes&i)!==0)t.flags&131072&&(be=!0);else return e.lanes=t.lanes,Kt(t,e,i)}return Nu(t,e,n,r,i)}function k0(t,e,n){var r=e.pendingProps,i=r.children,o=t!==null?t.memoizedState:null;if(r.mode==="hidden")if(!(e.mode&1))e.memoizedState={baseLanes:0,cachePool:null,transitions:null},J(xr,Ue),Ue|=n;else{if(!(n&1073741824))return t=o!==null?o.baseLanes|n:n,e.lanes=e.childLanes=1073741824,e.memoizedState={baseLanes:t,cachePool:null,transitions:null},e.updateQueue=null,J(xr,Ue),Ue|=t,null;e.memoizedState={baseLanes:0,cachePool:null,transitions:null},r=o!==null?o.baseLanes:n,J(xr,Ue),Ue|=r}else o!==null?(r=o.baseLanes|n,e.memoizedState=null):r=n,J(xr,Ue),Ue|=r;return Me(t,e,i,n),e.child}function w0(t,e){var n=e.ref;(t===null&&n!==null||t!==null&&t.ref!==n)&&(e.flags|=512,e.flags|=2097152)}function Nu(t,e,n,r,i){var o=$e(n)?Yn:Ce.current;return o=_r(e,o),Ar(e,i),n=Jc(t,e,n,r,o,i),r=Kc(),t!==null&&!be?(e.updateQueue=t.updateQueue,e.flags&=-2053,t.lanes&=~i,Kt(t,e,i)):(Q&&r&&Fc(e),e.flags|=1,Me(t,e,n,i),e.child)}function wh(t,e,n,r,i){if($e(n)){var o=!0;$s(e)}else o=!1;if(Ar(e,i),e.stateNode===null)ms(t,e),Kg(e,n,r),xu(e,n,r,i),r=!0;else if(t===null){var s=e.stateNode,l=e.memoizedProps;s.props=l;var a=s.context,u=n.contextType;typeof u=="object"&&u!==null?u=it(u):(u=$e(n)?Yn:Ce.current,u=_r(e,u));var c=n.getDerivedStateFromProps,f=typeof c=="function"||typeof s.getSnapshotBeforeUpdate=="function";f||typeof s.UNSAFE_componentWillReceiveProps!="function"&&typeof s.componentWillReceiveProps!="function"||(l!==r||a!==u)&&fh(e,s,r,u),Zt=!1;var d=e.memoizedState;s.state=d,Hs(e,r,s,i),a=e.memoizedState,l!==r||d!==a||Ve.current||Zt?(typeof c=="function"&&(vu(e,n,c,r),a=e.memoizedState),(l=Zt||ch(e,n,l,r,d,a,u))?(f||typeof s.UNSAFE_componentWillMount!="function"&&typeof s.componentWillMount!="function"||(typeof s.componentWillMount=="function"&&s.componentWillMount(),typeof s.UNSAFE_componentWillMount=="function"&&s.UNSAFE_componentWillMount()),typeof s.componentDidMount=="function"&&(e.flags|=4194308)):(typeof s.componentDidMount=="function"&&(e.flags|=4194308),e.memoizedProps=r,e.memoizedState=a),s.props=r,s.state=a,s.context=u,r=l):(typeof s.componentDidMount=="function"&&(e.flags|=4194308),r=!1)}else{s=e.stateNode,Hg(t,e),l=e.memoizedProps,u=e.type===e.elementType?l:at(e.type,l),s.props=u,f=e.pendingProps,d=s.context,a=n.contextType,typeof a=="object"&&a!==null?a=it(a):(a=$e(n)?Yn:Ce.current,a=_r(e,a));var p=n.getDerivedStateFromProps;(c=typeof p=="function"||typeof s.getSnapshotBeforeUpdate=="function")||typeof s.UNSAFE_componentWillReceiveProps!="function"&&typeof s.componentWillReceiveProps!="function"||(l!==f||d!==a)&&fh(e,s,r,a),Zt=!1,d=e.memoizedState,s.state=d,Hs(e,r,s,i);var h=e.memoizedState;l!==f||d!==h||Ve.current||Zt?(typeof p=="function"&&(vu(e,n,p,r),h=e.memoizedState),(u=Zt||ch(e,n,u,r,d,h,a)||!1)?(c||typeof s.UNSAFE_componentWillUpdate!="function"&&typeof s.componentWillUpdate!="function"||(typeof s.componentWillUpdate=="function"&&s.componentWillUpdate(r,h,a),typeof s.UNSAFE_componentWillUpdate=="function"&&s.UNSAFE_componentWillUpdate(r,h,a)),typeof s.componentDidUpdate=="function"&&(e.flags|=4),typeof s.getSnapshotBeforeUpdate=="function"&&(e.flags|=1024)):(typeof s.componentDidUpdate!="function"||l===t.memoizedProps&&d===t.memoizedState||(e.flags|=4),typeof s.getSnapshotBeforeUpdate!="function"||l===t.memoizedProps&&d===t.memoizedState||(e.flags|=1024),e.memoizedProps=r,e.memoizedState=h),s.props=r,s.state=h,s.context=a,r=u):(typeof s.componentDidUpdate!="function"||l===t.memoizedProps&&d===t.memoizedState||(e.flags|=4),typeof s.getSnapshotBeforeUpdate!="function"||l===t.memoizedProps&&d===t.memoizedState||(e.flags|=1024),r=!1)}return Mu(t,e,n,r,o,i)}function Mu(t,e,n,r,i,o){w0(t,e);var s=(e.flags&128)!==0;if(!r&&!s)return i&&oh(e,n,!1),Kt(t,e,o);r=e.stateNode,Ax.current=e;var l=s&&typeof n.getDerivedStateFromError!="function"?null:r.render();return e.flags|=1,t!==null&&s?(e.child=Ur(e,t.child,null,o),e.child=Ur(e,null,l,o)):Me(t,e,l,o),e.memoizedState=r.state,i&&oh(e,n,!0),e.child}function v0(t){var e=t.stateNode;e.pendingContext?ih(t,e.pendingContext,e.pendingContext!==e.context):e.context&&ih(t,e.context,!1),Wc(t,e.containerInfo)}function vh(t,e,n,r,i){return Wr(),bc(i),e.flags|=256,Me(t,e,n,r),e.child}var Eu={dehydrated:null,treeContext:null,retryLane:0};function Ou(t){return{baseLanes:t,cachePool:null,transitions:null}}function x0(t,e,n){var r=e.pendingProps,i=Y.current,o=!1,s=(e.flags&128)!==0,l;if((l=s)||(l=t!==null&&t.memoizedState===null?!1:(i&2)!==0),l?(o=!0,e.flags&=-129):(t===null||t.memoizedState!==null)&&(i|=1),J(Y,i&1),t===null)return ku(e),t=e.memoizedState,t!==null&&(t=t.dehydrated,t!==null)?(e.mode&1?t.data==="$!"?e.lanes=8:e.lanes=1073741824:e.lanes=1,null):(s=r.children,t=r.fallback,o?(r=e.mode,o=e.child,s={mode:"hidden",children:s},!(r&1)&&o!==null?(o.childLanes=0,o.pendingProps=s):o=gl(s,r,0,null),t=Kn(t,r,n,null),o.return=e,t.return=e,o.sibling=t,e.child=o,e.child.memoizedState=Ou(n),e.memoizedState=Eu,t):Yc(e,s));if(i=t.memoizedState,i!==null&&(l=i.dehydrated,l!==null))return Rx(t,e,s,r,l,i,n);if(o){o=r.fallback,s=e.mode,i=t.child,l=i.sibling;var a={mode:"hidden",children:r.children};return!(s&1)&&e.child!==i?(r=e.child,r.childLanes=0,r.pendingProps=a,e.deletions=null):(r=wn(i,a),r.subtreeFlags=i.subtreeFlags&14680064),l!==null?o=wn(l,o):(o=Kn(o,s,n,null),o.flags|=2),o.return=e,r.return=e,r.sibling=o,e.child=r,r=o,o=e.child,s=t.child.memoizedState,s=s===null?Ou(n):{baseLanes:s.baseLanes|n,cachePool:null,transitions:s.transitions},o.memoizedState=s,o.childLanes=t.childLanes&~n,e.memoizedState=Eu,r}return o=t.child,t=o.sibling,r=wn(o,{mode:"visible",children:r.children}),!(e.mode&1)&&(r.lanes=n),r.return=e,r.sibling=null,t!==null&&(n=e.deletions,n===null?(e.deletions=[t],e.flags|=16):n.push(t)),e.child=r,e.memoizedState=null,r}function Yc(t,e){return e=gl({mode:"visible",children:e},t.mode,0,null),e.return=t,t.child=e}function Jo(t,e,n,r){return r!==null&&bc(r),Ur(e,t.child,null,n),t=Yc(e,e.pendingProps.children),t.flags|=2,e.memoizedState=null,t}function Rx(t,e,n,r,i,o,s){if(n)return e.flags&256?(e.flags&=-257,r=ga(Error(N(422))),Jo(t,e,s,r)):e.memoizedState!==null?(e.child=t.child,e.flags|=128,null):(o=r.fallback,i=e.mode,r=gl({mode:"visible",children:r.children},i,0,null),o=Kn(o,i,s,null),o.flags|=2,r.return=e,o.return=e,r.sibling=o,e.child=r,e.mode&1&&Ur(e,t.child,null,s),e.child.memoizedState=Ou(s),e.memoizedState=Eu,o);if(!(e.mode&1))return Jo(t,e,s,null);if(i.data==="$!"){if(r=i.nextSibling&&i.nextSibling.dataset,r)var l=r.dgst;return r=l,o=Error(N(419)),r=ga(o,r,void 0),Jo(t,e,s,r)}if(l=(s&t.childLanes)!==0,be||l){if(r=fe,r!==null){switch(s&-s){case 4:i=2;break;case 16:i=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:i=32;break;case 536870912:i=268435456;break;default:i=0}i=i&(r.suspendedLanes|s)?0:i,i!==0&&i!==o.retryLane&&(o.retryLane=i,Jt(t,i),ht(r,t,i,-1))}return nf(),r=ga(Error(N(421))),Jo(t,e,s,r)}return i.data==="$?"?(e.flags|=128,e.child=t.child,e=jx.bind(null,t),i._reactRetry=e,null):(t=o.treeContext,He=gn(i.nextSibling),Ke=e,Q=!0,ft=null,t!==null&&(Xe[Ze++]=Bt,Xe[Ze++]=Vt,Xe[Ze++]=Gn,Bt=t.id,Vt=t.overflow,Gn=e),e=Yc(e,r.children),e.flags|=4096,e)}function xh(t,e,n){t.lanes|=e;var r=t.alternate;r!==null&&(r.lanes|=e),wu(t.return,e,n)}function ya(t,e,n,r,i){var o=t.memoizedState;o===null?t.memoizedState={isBackwards:e,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:i}:(o.isBackwards=e,o.rendering=null,o.renderingStartTime=0,o.last=r,o.tail=n,o.tailMode=i)}function C0(t,e,n){var r=e.pendingProps,i=r.revealOrder,o=r.tail;if(Me(t,e,r.children,n),r=Y.current,r&2)r=r&1|2,e.flags|=128;else{if(t!==null&&t.flags&128)e:for(t=e.child;t!==null;){if(t.tag===13)t.memoizedState!==null&&xh(t,n,e);else if(t.tag===19)xh(t,n,e);else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break e;for(;t.sibling===null;){if(t.return===null||t.return===e)break e;t=t.return}t.sibling.return=t.return,t=t.sibling}r&=1}if(J(Y,r),!(e.mode&1))e.memoizedState=null;else switch(i){case"forwards":for(n=e.child,i=null;n!==null;)t=n.alternate,t!==null&&Js(t)===null&&(i=n),n=n.sibling;n=i,n===null?(i=e.child,e.child=null):(i=n.sibling,n.sibling=null),ya(e,!1,i,n,o);break;case"backwards":for(n=null,i=e.child,e.child=null;i!==null;){if(t=i.alternate,t!==null&&Js(t)===null){e.child=i;break}t=i.sibling,i.sibling=n,n=i,i=t}ya(e,!0,n,null,o);break;case"together":ya(e,!1,null,null,void 0);break;default:e.memoizedState=null}return e.child}function ms(t,e){!(e.mode&1)&&t!==null&&(t.alternate=null,e.alternate=null,e.flags|=2)}function Kt(t,e,n){if(t!==null&&(e.dependencies=t.dependencies),Zn|=e.lanes,!(n&e.childLanes))return null;if(t!==null&&e.child!==t.child)throw Error(N(153));if(e.child!==null){for(t=e.child,n=wn(t,t.pendingProps),e.child=n,n.return=e;t.sibling!==null;)t=t.sibling,n=n.sibling=wn(t,t.pendingProps),n.return=e;n.sibling=null}return e.child}function Px(t,e,n){switch(e.tag){case 3:v0(e),Wr();break;case 5:Yg(e);break;case 1:$e(e.type)&&$s(e);break;case 4:Wc(e,e.stateNode.containerInfo);break;case 10:var r=e.type._context,i=e.memoizedProps.value;J(Us,r._currentValue),r._currentValue=i;break;case 13:if(r=e.memoizedState,r!==null)return r.dehydrated!==null?(J(Y,Y.current&1),e.flags|=128,null):n&e.child.childLanes?x0(t,e,n):(J(Y,Y.current&1),t=Kt(t,e,n),t!==null?t.sibling:null);J(Y,Y.current&1);break;case 19:if(r=(n&e.childLanes)!==0,t.flags&128){if(r)return C0(t,e,n);e.flags|=128}if(i=e.memoizedState,i!==null&&(i.rendering=null,i.tail=null,i.lastEffect=null),J(Y,Y.current),r)break;return null;case 22:case 23:return e.lanes=0,k0(t,e,n)}return Kt(t,e,n)}var N0,Du,M0,E0;N0=function(t,e){for(var n=e.child;n!==null;){if(n.tag===5||n.tag===6)t.appendChild(n.stateNode);else if(n.tag!==4&&n.child!==null){n.child.return=n,n=n.child;continue}if(n===e)break;for(;n.sibling===null;){if(n.return===null||n.return===e)return;n=n.return}n.sibling.return=n.return,n=n.sibling}};Du=function(){};M0=function(t,e,n,r){var i=t.memoizedProps;if(i!==r){t=e.stateNode,_n(Mt.current);var o=null;switch(n){case"input":i=Ya(t,i),r=Ya(t,r),o=[];break;case"select":i=X({},i,{value:void 0}),r=X({},r,{value:void 0}),o=[];break;case"textarea":i=Za(t,i),r=Za(t,r),o=[];break;default:typeof i.onClick!="function"&&typeof r.onClick=="function"&&(t.onclick=Bs)}tu(n,r);var s;n=null;for(u in i)if(!r.hasOwnProperty(u)&&i.hasOwnProperty(u)&&i[u]!=null)if(u==="style"){var l=i[u];for(s in l)l.hasOwnProperty(s)&&(n||(n={}),n[s]="")}else u!=="dangerouslySetInnerHTML"&&u!=="children"&&u!=="suppressContentEditableWarning"&&u!=="suppressHydrationWarning"&&u!=="autoFocus"&&(Ui.hasOwnProperty(u)?o||(o=[]):(o=o||[]).push(u,null));for(u in r){var a=r[u];if(l=i!=null?i[u]:void 0,r.hasOwnProperty(u)&&a!==l&&(a!=null||l!=null))if(u==="style")if(l){for(s in l)!l.hasOwnProperty(s)||a&&a.hasOwnProperty(s)||(n||(n={}),n[s]="");for(s in a)a.hasOwnProperty(s)&&l[s]!==a[s]&&(n||(n={}),n[s]=a[s])}else n||(o||(o=[]),o.push(u,n)),n=a;else u==="dangerouslySetInnerHTML"?(a=a?a.__html:void 0,l=l?l.__html:void 0,a!=null&&l!==a&&(o=o||[]).push(u,a)):u==="children"?typeof a!="string"&&typeof a!="number"||(o=o||[]).push(u,""+a):u!=="suppressContentEditableWarning"&&u!=="suppressHydrationWarning"&&(Ui.hasOwnProperty(u)?(a!=null&&u==="onScroll"&&K("scroll",t),o||l===a||(o=[])):(o=o||[]).push(u,a))}n&&(o=o||[]).push("style",n);var u=o;(e.updateQueue=u)&&(e.flags|=4)}};E0=function(t,e,n,r){n!==r&&(e.flags|=4)};function oi(t,e){if(!Q)switch(t.tailMode){case"hidden":e=t.tail;for(var n=null;e!==null;)e.alternate!==null&&(n=e),e=e.sibling;n===null?t.tail=null:n.sibling=null;break;case"collapsed":n=t.tail;for(var r=null;n!==null;)n.alternate!==null&&(r=n),n=n.sibling;r===null?e||t.tail===null?t.tail=null:t.tail.sibling=null:r.sibling=null}}function ke(t){var e=t.alternate!==null&&t.alternate.child===t.child,n=0,r=0;if(e)for(var i=t.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags&14680064,r|=i.flags&14680064,i.return=t,i=i.sibling;else for(i=t.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags,r|=i.flags,i.return=t,i=i.sibling;return t.subtreeFlags|=r,t.childLanes=n,e}function zx(t,e,n){var r=e.pendingProps;switch(Ic(e),e.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return ke(e),null;case 1:return $e(e.type)&&Vs(),ke(e),null;case 3:return r=e.stateNode,jr(),q(Ve),q(Ce),jc(),r.pendingContext&&(r.context=r.pendingContext,r.pendingContext=null),(t===null||t.child===null)&&(jo(e)?e.flags|=4:t===null||t.memoizedState.isDehydrated&&!(e.flags&256)||(e.flags|=1024,ft!==null&&(bu(ft),ft=null))),Du(t,e),ke(e),null;case 5:Uc(e);var i=_n(to.current);if(n=e.type,t!==null&&e.stateNode!=null)M0(t,e,n,r,i),t.ref!==e.ref&&(e.flags|=512,e.flags|=2097152);else{if(!r){if(e.stateNode===null)throw Error(N(166));return ke(e),null}if(t=_n(Mt.current),jo(e)){r=e.stateNode,n=e.type;var o=e.memoizedProps;switch(r[wt]=e,r[Zi]=o,t=(e.mode&1)!==0,n){case"dialog":K("cancel",r),K("close",r);break;case"iframe":case"object":case"embed":K("load",r);break;case"video":case"audio":for(i=0;i<\/script>",t=t.removeChild(t.firstChild)):typeof r.is=="string"?t=s.createElement(n,{is:r.is}):(t=s.createElement(n),n==="select"&&(s=t,r.multiple?s.multiple=!0:r.size&&(s.size=r.size))):t=s.createElementNS(t,n),t[wt]=e,t[Zi]=r,N0(t,e,!1,!1),e.stateNode=t;e:{switch(s=nu(n,r),n){case"dialog":K("cancel",t),K("close",t),i=r;break;case"iframe":case"object":case"embed":K("load",t),i=r;break;case"video":case"audio":for(i=0;iJr&&(e.flags|=128,r=!0,oi(o,!1),e.lanes=4194304)}else{if(!r)if(t=Js(s),t!==null){if(e.flags|=128,r=!0,n=t.updateQueue,n!==null&&(e.updateQueue=n,e.flags|=4),oi(o,!0),o.tail===null&&o.tailMode==="hidden"&&!s.alternate&&!Q)return ke(e),null}else 2*ne()-o.renderingStartTime>Jr&&n!==1073741824&&(e.flags|=128,r=!0,oi(o,!1),e.lanes=4194304);o.isBackwards?(s.sibling=e.child,e.child=s):(n=o.last,n!==null?n.sibling=s:e.child=s,o.last=s)}return o.tail!==null?(e=o.tail,o.rendering=e,o.tail=e.sibling,o.renderingStartTime=ne(),e.sibling=null,n=Y.current,J(Y,r?n&1|2:n&1),e):(ke(e),null);case 22:case 23:return tf(),r=e.memoizedState!==null,t!==null&&t.memoizedState!==null!==r&&(e.flags|=8192),r&&e.mode&1?Ue&1073741824&&(ke(e),e.subtreeFlags&6&&(e.flags|=8192)):ke(e),null;case 24:return null;case 25:return null}throw Error(N(156,e.tag))}function Fx(t,e){switch(Ic(e),e.tag){case 1:return $e(e.type)&&Vs(),t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 3:return jr(),q(Ve),q(Ce),jc(),t=e.flags,t&65536&&!(t&128)?(e.flags=t&-65537|128,e):null;case 5:return Uc(e),null;case 13:if(q(Y),t=e.memoizedState,t!==null&&t.dehydrated!==null){if(e.alternate===null)throw Error(N(340));Wr()}return t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 19:return q(Y),null;case 4:return jr(),null;case 10:return Vc(e.type._context),null;case 22:case 23:return tf(),null;case 24:return null;default:return null}}var Ko=!1,ve=!1,Ix=typeof WeakSet=="function"?WeakSet:Set,D=null;function vr(t,e){var n=t.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){Z(t,e,r)}else n.current=null}function Tu(t,e,n){try{n()}catch(r){Z(t,e,r)}}var Ch=!1;function bx(t,e){if(du=Is,t=Ag(),zc(t)){if("selectionStart"in t)var n={start:t.selectionStart,end:t.selectionEnd};else e:{n=(n=t.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var i=r.anchorOffset,o=r.focusNode;r=r.focusOffset;try{n.nodeType,o.nodeType}catch{n=null;break e}var s=0,l=-1,a=-1,u=0,c=0,f=t,d=null;t:for(;;){for(var p;f!==n||i!==0&&f.nodeType!==3||(l=s+i),f!==o||r!==0&&f.nodeType!==3||(a=s+r),f.nodeType===3&&(s+=f.nodeValue.length),(p=f.firstChild)!==null;)d=f,f=p;for(;;){if(f===t)break t;if(d===n&&++u===i&&(l=s),d===o&&++c===r&&(a=s),(p=f.nextSibling)!==null)break;f=d,d=f.parentNode}f=p}n=l===-1||a===-1?null:{start:l,end:a}}else n=null}n=n||{start:0,end:0}}else n=null;for(hu={focusedElem:t,selectionRange:n},Is=!1,D=e;D!==null;)if(e=D,t=e.child,(e.subtreeFlags&1028)!==0&&t!==null)t.return=e,D=t;else for(;D!==null;){e=D;try{var h=e.alternate;if(e.flags&1024)switch(e.tag){case 0:case 11:case 15:break;case 1:if(h!==null){var m=h.memoizedProps,k=h.memoizedState,g=e.stateNode,y=g.getSnapshotBeforeUpdate(e.elementType===e.type?m:at(e.type,m),k);g.__reactInternalSnapshotBeforeUpdate=y}break;case 3:var S=e.stateNode.containerInfo;S.nodeType===1?S.textContent="":S.nodeType===9&&S.documentElement&&S.removeChild(S.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(N(163))}}catch(w){Z(e,e.return,w)}if(t=e.sibling,t!==null){t.return=e.return,D=t;break}D=e.return}return h=Ch,Ch=!1,h}function Ri(t,e,n){var r=e.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var i=r=r.next;do{if((i.tag&t)===t){var o=i.destroy;i.destroy=void 0,o!==void 0&&Tu(e,n,o)}i=i.next}while(i!==r)}}function pl(t,e){if(e=e.updateQueue,e=e!==null?e.lastEffect:null,e!==null){var n=e=e.next;do{if((n.tag&t)===t){var r=n.create;n.destroy=r()}n=n.next}while(n!==e)}}function Au(t){var e=t.ref;if(e!==null){var n=t.stateNode;switch(t.tag){case 5:t=n;break;default:t=n}typeof e=="function"?e(t):e.current=t}}function O0(t){var e=t.alternate;e!==null&&(t.alternate=null,O0(e)),t.child=null,t.deletions=null,t.sibling=null,t.tag===5&&(e=t.stateNode,e!==null&&(delete e[wt],delete e[Zi],delete e[gu],delete e[Sx],delete e[kx])),t.stateNode=null,t.return=null,t.dependencies=null,t.memoizedProps=null,t.memoizedState=null,t.pendingProps=null,t.stateNode=null,t.updateQueue=null}function D0(t){return t.tag===5||t.tag===3||t.tag===4}function Nh(t){e:for(;;){for(;t.sibling===null;){if(t.return===null||D0(t.return))return null;t=t.return}for(t.sibling.return=t.return,t=t.sibling;t.tag!==5&&t.tag!==6&&t.tag!==18;){if(t.flags&2||t.child===null||t.tag===4)continue e;t.child.return=t,t=t.child}if(!(t.flags&2))return t.stateNode}}function Ru(t,e,n){var r=t.tag;if(r===5||r===6)t=t.stateNode,e?n.nodeType===8?n.parentNode.insertBefore(t,e):n.insertBefore(t,e):(n.nodeType===8?(e=n.parentNode,e.insertBefore(t,n)):(e=n,e.appendChild(t)),n=n._reactRootContainer,n!=null||e.onclick!==null||(e.onclick=Bs));else if(r!==4&&(t=t.child,t!==null))for(Ru(t,e,n),t=t.sibling;t!==null;)Ru(t,e,n),t=t.sibling}function Pu(t,e,n){var r=t.tag;if(r===5||r===6)t=t.stateNode,e?n.insertBefore(t,e):n.appendChild(t);else if(r!==4&&(t=t.child,t!==null))for(Pu(t,e,n),t=t.sibling;t!==null;)Pu(t,e,n),t=t.sibling}var he=null,ut=!1;function Qt(t,e,n){for(n=n.child;n!==null;)T0(t,e,n),n=n.sibling}function T0(t,e,n){if(Nt&&typeof Nt.onCommitFiberUnmount=="function")try{Nt.onCommitFiberUnmount(sl,n)}catch{}switch(n.tag){case 5:ve||vr(n,e);case 6:var r=he,i=ut;he=null,Qt(t,e,n),he=r,ut=i,he!==null&&(ut?(t=he,n=n.stateNode,t.nodeType===8?t.parentNode.removeChild(n):t.removeChild(n)):he.removeChild(n.stateNode));break;case 18:he!==null&&(ut?(t=he,n=n.stateNode,t.nodeType===8?ca(t.parentNode,n):t.nodeType===1&&ca(t,n),qi(t)):ca(he,n.stateNode));break;case 4:r=he,i=ut,he=n.stateNode.containerInfo,ut=!0,Qt(t,e,n),he=r,ut=i;break;case 0:case 11:case 14:case 15:if(!ve&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){i=r=r.next;do{var o=i,s=o.destroy;o=o.tag,s!==void 0&&(o&2||o&4)&&Tu(n,e,s),i=i.next}while(i!==r)}Qt(t,e,n);break;case 1:if(!ve&&(vr(n,e),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(l){Z(n,e,l)}Qt(t,e,n);break;case 21:Qt(t,e,n);break;case 22:n.mode&1?(ve=(r=ve)||n.memoizedState!==null,Qt(t,e,n),ve=r):Qt(t,e,n);break;default:Qt(t,e,n)}}function Mh(t){var e=t.updateQueue;if(e!==null){t.updateQueue=null;var n=t.stateNode;n===null&&(n=t.stateNode=new Ix),e.forEach(function(r){var i=Hx.bind(null,t,r);n.has(r)||(n.add(r),r.then(i,i))})}}function lt(t,e){var n=e.deletions;if(n!==null)for(var r=0;ri&&(i=s),r&=~o}if(r=i,r=ne()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*Bx(r/1960))-r,10t?16:t,cn===null)var r=!1;else{if(t=cn,cn=null,Gs=0,$&6)throw Error(N(331));var i=$;for($|=4,D=t.current;D!==null;){var o=D,s=o.child;if(D.flags&16){var l=o.deletions;if(l!==null){for(var a=0;ane()-Zc?Jn(t,0):Xc|=n),_e(t,e)}function L0(t,e){e===0&&(t.mode&1?(e=Bo,Bo<<=1,!(Bo&130023424)&&(Bo=4194304)):e=1);var n=De();t=Jt(t,e),t!==null&&(So(t,e,n),_e(t,n))}function jx(t){var e=t.memoizedState,n=0;e!==null&&(n=e.retryLane),L0(t,n)}function Hx(t,e){var n=0;switch(t.tag){case 13:var r=t.stateNode,i=t.memoizedState;i!==null&&(n=i.retryLane);break;case 19:r=t.stateNode;break;default:throw Error(N(314))}r!==null&&r.delete(e),L0(t,n)}var B0;B0=function(t,e,n){if(t!==null)if(t.memoizedProps!==e.pendingProps||Ve.current)be=!0;else{if(!(t.lanes&n)&&!(e.flags&128))return be=!1,Px(t,e,n);be=!!(t.flags&131072)}else be=!1,Q&&e.flags&1048576&&_g(e,Ws,e.index);switch(e.lanes=0,e.tag){case 2:var r=e.type;ms(t,e),t=e.pendingProps;var i=_r(e,Ce.current);Ar(e,n),i=Jc(null,e,r,t,i,n);var o=Kc();return e.flags|=1,typeof i=="object"&&i!==null&&typeof i.render=="function"&&i.$$typeof===void 0?(e.tag=1,e.memoizedState=null,e.updateQueue=null,$e(r)?(o=!0,$s(e)):o=!1,e.memoizedState=i.state!==null&&i.state!==void 0?i.state:null,_c(e),i.updater=dl,e.stateNode=i,i._reactInternals=e,xu(e,r,t,n),e=Mu(null,e,r,!0,o,n)):(e.tag=0,Q&&o&&Fc(e),Me(null,e,i,n),e=e.child),e;case 16:r=e.elementType;e:{switch(ms(t,e),t=e.pendingProps,i=r._init,r=i(r._payload),e.type=r,i=e.tag=Kx(r),t=at(r,t),i){case 0:e=Nu(null,e,r,t,n);break e;case 1:e=wh(null,e,r,t,n);break e;case 11:e=Sh(null,e,r,t,n);break e;case 14:e=kh(null,e,r,at(r.type,t),n);break e}throw Error(N(306,r,""))}return e;case 0:return r=e.type,i=e.pendingProps,i=e.elementType===r?i:at(r,i),Nu(t,e,r,i,n);case 1:return r=e.type,i=e.pendingProps,i=e.elementType===r?i:at(r,i),wh(t,e,r,i,n);case 3:e:{if(v0(e),t===null)throw Error(N(387));r=e.pendingProps,o=e.memoizedState,i=o.element,Hg(t,e),Hs(e,r,null,n);var s=e.memoizedState;if(r=s.element,o.isDehydrated)if(o={element:r,isDehydrated:!1,cache:s.cache,pendingSuspenseBoundaries:s.pendingSuspenseBoundaries,transitions:s.transitions},e.updateQueue.baseState=o,e.memoizedState=o,e.flags&256){i=Hr(Error(N(423)),e),e=vh(t,e,r,n,i);break e}else if(r!==i){i=Hr(Error(N(424)),e),e=vh(t,e,r,n,i);break e}else for(He=gn(e.stateNode.containerInfo.firstChild),Ke=e,Q=!0,ft=null,n=Qg(e,null,r,n),e.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(Wr(),r===i){e=Kt(t,e,n);break e}Me(t,e,r,n)}e=e.child}return e;case 5:return Yg(e),t===null&&ku(e),r=e.type,i=e.pendingProps,o=t!==null?t.memoizedProps:null,s=i.children,pu(r,i)?s=null:o!==null&&pu(r,o)&&(e.flags|=32),w0(t,e),Me(t,e,s,n),e.child;case 6:return t===null&&ku(e),null;case 13:return x0(t,e,n);case 4:return Wc(e,e.stateNode.containerInfo),r=e.pendingProps,t===null?e.child=Ur(e,null,r,n):Me(t,e,r,n),e.child;case 11:return r=e.type,i=e.pendingProps,i=e.elementType===r?i:at(r,i),Sh(t,e,r,i,n);case 7:return Me(t,e,e.pendingProps,n),e.child;case 8:return Me(t,e,e.pendingProps.children,n),e.child;case 12:return Me(t,e,e.pendingProps.children,n),e.child;case 10:e:{if(r=e.type._context,i=e.pendingProps,o=e.memoizedProps,s=i.value,J(Us,r._currentValue),r._currentValue=s,o!==null)if(mt(o.value,s)){if(o.children===i.children&&!Ve.current){e=Kt(t,e,n);break e}}else for(o=e.child,o!==null&&(o.return=e);o!==null;){var l=o.dependencies;if(l!==null){s=o.child;for(var a=l.firstContext;a!==null;){if(a.context===r){if(o.tag===1){a=_t(-1,n&-n),a.tag=2;var u=o.updateQueue;if(u!==null){u=u.shared;var c=u.pending;c===null?a.next=a:(a.next=c.next,c.next=a),u.pending=a}}o.lanes|=n,a=o.alternate,a!==null&&(a.lanes|=n),wu(o.return,n,e),l.lanes|=n;break}a=a.next}}else if(o.tag===10)s=o.type===e.type?null:o.child;else if(o.tag===18){if(s=o.return,s===null)throw Error(N(341));s.lanes|=n,l=s.alternate,l!==null&&(l.lanes|=n),wu(s,n,e),s=o.sibling}else s=o.child;if(s!==null)s.return=o;else for(s=o;s!==null;){if(s===e){s=null;break}if(o=s.sibling,o!==null){o.return=s.return,s=o;break}s=s.return}o=s}Me(t,e,i.children,n),e=e.child}return e;case 9:return i=e.type,r=e.pendingProps.children,Ar(e,n),i=it(i),r=r(i),e.flags|=1,Me(t,e,r,n),e.child;case 14:return r=e.type,i=at(r,e.pendingProps),i=at(r.type,i),kh(t,e,r,i,n);case 15:return S0(t,e,e.type,e.pendingProps,n);case 17:return r=e.type,i=e.pendingProps,i=e.elementType===r?i:at(r,i),ms(t,e),e.tag=1,$e(r)?(t=!0,$s(e)):t=!1,Ar(e,n),Kg(e,r,i),xu(e,r,i,n),Mu(null,e,r,!0,t,n);case 19:return C0(t,e,n);case 22:return k0(t,e,n)}throw Error(N(156,e.tag))};function V0(t,e){return fg(t,e)}function Jx(t,e,n,r){this.tag=t,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=e,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function tt(t,e,n,r){return new Jx(t,e,n,r)}function rf(t){return t=t.prototype,!(!t||!t.isReactComponent)}function Kx(t){if(typeof t=="function")return rf(t)?1:0;if(t!=null){if(t=t.$$typeof,t===xc)return 11;if(t===Cc)return 14}return 2}function wn(t,e){var n=t.alternate;return n===null?(n=tt(t.tag,e,t.key,t.mode),n.elementType=t.elementType,n.type=t.type,n.stateNode=t.stateNode,n.alternate=t,t.alternate=n):(n.pendingProps=e,n.type=t.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=t.flags&14680064,n.childLanes=t.childLanes,n.lanes=t.lanes,n.child=t.child,n.memoizedProps=t.memoizedProps,n.memoizedState=t.memoizedState,n.updateQueue=t.updateQueue,e=t.dependencies,n.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext},n.sibling=t.sibling,n.index=t.index,n.ref=t.ref,n}function Ss(t,e,n,r,i,o){var s=2;if(r=t,typeof t=="function")rf(t)&&(s=1);else if(typeof t=="string")s=5;else e:switch(t){case dr:return Kn(n.children,i,o,e);case vc:s=8,i|=8;break;case Ja:return t=tt(12,n,e,i|2),t.elementType=Ja,t.lanes=o,t;case Ka:return t=tt(13,n,e,i),t.elementType=Ka,t.lanes=o,t;case qa:return t=tt(19,n,e,i),t.elementType=qa,t.lanes=o,t;case qm:return gl(n,i,o,e);default:if(typeof t=="object"&&t!==null)switch(t.$$typeof){case Jm:s=10;break e;case Km:s=9;break e;case xc:s=11;break e;case Cc:s=14;break e;case Xt:s=16,r=null;break e}throw Error(N(130,t==null?t:typeof t,""))}return e=tt(s,n,e,i),e.elementType=t,e.type=r,e.lanes=o,e}function Kn(t,e,n,r){return t=tt(7,t,r,e),t.lanes=n,t}function gl(t,e,n,r){return t=tt(22,t,r,e),t.elementType=qm,t.lanes=n,t.stateNode={isHidden:!1},t}function Sa(t,e,n){return t=tt(6,t,null,e),t.lanes=n,t}function ka(t,e,n){return e=tt(4,t.children!==null?t.children:[],t.key,e),e.lanes=n,e.stateNode={containerInfo:t.containerInfo,pendingChildren:null,implementation:t.implementation},e}function qx(t,e,n,r,i){this.tag=e,this.containerInfo=t,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Zl(0),this.expirationTimes=Zl(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Zl(0),this.identifierPrefix=r,this.onRecoverableError=i,this.mutableSourceEagerHydrationData=null}function of(t,e,n,r,i,o,s,l,a){return t=new qx(t,e,n,l,a),e===1?(e=1,o===!0&&(e|=8)):e=0,o=tt(3,null,null,e),t.current=o,o.stateNode=t,o.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},_c(o),t}function Qx(t,e,n){var r=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(U0)}catch(t){console.error(t)}}U0(),_m.exports=Qe;var Kr=_m.exports,j0,zh=Kr;j0=zh.createRoot,zh.hydrateRoot;const xo=C.createContext(null),H0=C.createContext(null);function eC(t){const e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(t.editable),t.someProp("attributes",n=>{if(typeof n=="function"&&(n=n(t.state)),n)for(const r in n)r=="class"?e.class+=" "+n[r]:r=="style"?e.style=(e.style?e.style+";":"")+n[r]:!e[r]&&r!="contenteditable"&&r!="nodeName"&&(e[r]=String(n[r]))}),e.translate||(e.translate="no"),[me.node(0,t.state.doc.content.size,e)]}const tC=[],nC={},Lu=W.empty;class bn{constructor(e){this.members=e}map(e,n){const r=this.members.map(i=>i.map(e,n,nC));return bn.from(r)}forChild(e,n){if(n.isLeaf)return W.empty;let r=[];for(let i=0;in instanceof W)?e:e.reduce((n,r)=>n.concat(r instanceof W?r:r.members),[]))}}}function J0(t,e){return t.from-e.from||t.to-e.to}function rC(t){let e=t;for(let n=0;n0;)e++;t.splice(e,0,n)}function iC(t,e){const n=[];return t.someProp("decorations",r=>{const i=r(t.state);i&&i!=Lu&&n.push(i)}),e&&n.push(W.create(t.state.doc,[e])),bn.from(n)}const uf=function(t){for(let e=0;;e++)if(t=t.previousSibling,!t)return e},Ih=function(t){const e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e},oC=function(t,e,n,r){return n&&(bh(t,e,n,r,-1)||bh(t,e,n,r,1))},sC=/^(img|br|input|textarea|hr)$/i;function bh(t,e,n,r,i){for(;;){if(t==n&&e==r)return!0;if(e==(i<0?0:el(t))){const o=t.parentNode;if(!o||o.nodeType!=1||aC(t)||sC.test(t.nodeName)||t.contentEditable=="false")return!1;e=uf(t)+(i<0?0:1),t=o}else if(t.nodeType==1){if(t=t.childNodes[e+(i<0?-1:0)],t.contentEditable=="false")return!1;e=i<0?el(t):0}else return!1}}function el(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function lC(t,e,n){for(let r=e==0,i=e==el(t);r||i;){if(t==n)return!0;const o=uf(t);if(t=t.parentNode,!t)return!1;r=r&&o==0,i=i&&o==el(t)}return!1}function aC(t){let e;for(let n=t;n&&!(e=n.pmViewDesc);n=n.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==t||e.contentDOM==t)}const K0=function(t){return t.focusNode&&oC(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)},q0=C.createContext(null);function uC(t,e){const n=C.useContext(q0);C.useLayoutEffect(()=>n(t),e)}function Q0(t,e){const{view:n}=C.useContext(xo);uC(()=>{if(n)return t(n)},e&&[n,...e])}const cC=C.forwardRef(function({widget:e,pos:n,...r},i){const[o,s]=C.useState(!0),l=C.useRef(null);return C.useImperativeHandle(i,()=>l.current,[]),Q0(a=>{if(!a||!l.current)return;a.domObserver.disconnectSelection();const u=a.domSelection(),c=document.createRange(),f=l.current;f.nodeName=="IMG"&&f.parentNode?c.setEnd(f.parentNode,uf(f)+1):c.setEnd(f,0),c.collapse(!1),u.removeAllRanges(),u.addRange(c),s(!1),a.domObserver.connectSelection()},[]),o?F("img",{ref:l,className:"ProseMirror-separator","mark-placeholder":"true",alt:"",...r}):null});function fC(t,e){if(t==e)return!0;for(const n in t)if(t[n]!==e[n])return!1;for(const n in e)if(!(n in t))return!1;return!0}const dC={side:0};class so{constructor(e,n){this.Component=e,this.spec=n??dC,this.side=this.spec.side??0}map(e,n,r,i){const{pos:o,deleted:s}=e.mapResult(n.from+i,this.side<0?-1:1);return s?null:new me(o-r,o-r,this)}valid(){return!0}eq(e){return this==e||e instanceof so&&(this.spec.key&&this.spec.key==e.spec.key||this.Component==e.Component&&fC(this.spec,e.spec))}destroy(){}}function Y0(t,e,n){return new me(t,t,new so(e,n))}function wa(){return Math.floor(Math.random()*16777215).toString(16)}const lo=new po("@nytimes/react-prosemirror/reactKeys");function hC(){let t=!1;return new At({key:lo,state:{init(e,n){const r={posToKey:new Map,keyToPos:new Map};return n.doc.descendants((i,o)=>{const s=wa();return r.posToKey.set(o,s),r.keyToPos.set(s,o),!0}),r},apply(e,n,r,i){if(!e.docChanged||t)return n;const o=e.getMeta(lo),s=(o==null?void 0:o.type)==="bustKey"&&o.payload.key,l={posToKey:new Map,keyToPos:new Map},a=Array.from(n.posToKey.entries()).sort(([u],[c])=>u-c);for(const[u,c]of a){const{pos:f,deleted:d}=e.mapping.mapResult(u);if(d)continue;let p=c;s===c&&(p=wa()),l.posToKey.set(f,p),l.keyToPos.set(p,f)}return i.doc.descendants((u,c)=>{if(l.posToKey.has(c))return!0;const f=wa();return l.posToKey.set(c,f),l.keyToPos.set(f,c),!0}),l}},props:{handleDOMEvents:{compositionstart:()=>{t=!0},compositionend:()=>{t=!1}}}})}const pC=/\s/,mC=/[\u0021-\u0023\u0025-\u002A\u002C-\u002F\u003A\u003B\u003F\u0040\u005B-\u005D\u005F\u007B\u007D\u00A1\u00A7\u00AB\u00B6\u00B7\u00BB\u00BF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061E\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u0AF0\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166D\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E3B\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]/,gC=/['\u2018\u2019]/,ao=(t,e,n=-1)=>{if(t.resolve(e).parentOffset===0)return!1;const i=t.textBetween(e+n,e,null," ");return pC.test(i)?!1:gC.test(i)&&ao(t,e-1)?!0:!mC.test(i)};function va(t,e,n={}){var s,l;if(e===null)return!1;const r=n.from??t.state.selection.from,i=n.to??t.state.selection.to;if((s=t.someProp("handleTextInput"))!=null&&s(t,r,i,e))return!0;const{tr:o}=t.state;if(n.marks&&o.ensureMarks(n.marks),o.insertText(e,r,i),n.bust){const a=t.state.doc.resolve(r),u=a.sharedDepth(i),c=a.start(u),f=(l=lo.getState(t.state))==null?void 0:l.posToKey.get(c-1);o.setMeta(lo,{type:"bustKey",payload:{key:f}})}return t.dispatch(o),!0}function yC(t,e){let n=e;for(;!ao(t,n);)n--;for(;ao(t,n);)n--;return n}function SC(t,e){let n=e;for(;!ao(t,n,1);)n++;for(;ao(t,n,1);)n++;return n}function kC(t){let e=null,n=null;return new At({props:{handleDOMEvents:{compositionstart(r){var s;const{state:i}=r;r.dispatch(i.tr.deleteSelection());const o=i.selection.$from;return i.selection.empty&&(i.storedMarks||!o.textOffset&&o.parentOffset&&((s=o.nodeBefore)!=null&&s.marks.some(l=>l.type.spec.inclusive===!1)))&&t(Y0(i.selection.from,cC,{key:"cursor-wrapper",marks:i.storedMarks??o.marks()})),n=i.storedMarks??o.marks(),r.input.composing=!0,!0},compositionupdate(){return!0},compositionend(r){if(r.input.composing=!1,e!==null)return va(r,e,{bust:!0,marks:n}),e=null,n=null,t(null),!0},beforeinput(r,i){var o,s;switch(i.preventDefault(),i.inputType){case"insertCompositionText":{if(i.data===null)break;e=i.data;break}case"insertReplacementText":{const l=i.getTargetRanges();(s=(o=i.dataTransfer)==null?void 0:o.items[0])==null||s.getAsString(a=>{for(const u of l){const c=r.docView.posFromDOM(u.startContainer,u.startOffset,1),f=r.docView.posFromDOM(u.endContainer,u.endOffset,1);va(r,a,{from:c,to:f})}});break}case"insertText":{va(r,i.data);break}case"deleteWordBackward":{const{tr:l,doc:a,selection:u}=r.state,c=u.empty?yC(r.state.doc,u.from):u.from,f=u.to,d=a.resolve(c).marksAcross(a.resolve(f));l.delete(c,f).setStoredMarks(d),r.dispatch(l);break}case"deleteWordForward":{const{tr:l,doc:a,selection:u}=r.state,c=u.empty?SC(r.state.doc,u.from):u.from,f=u.to,d=a.resolve(c).marksAcross(a.resolve(f));l.delete(c,f).setStoredMarks(d),r.dispatch(l);break}case"deleteContentBackward":{const{tr:l,doc:a,selection:u}=r.state,c=u.empty?u.from-1:u.from,f=u.to,d=a.resolve(c).marksAcross(a.resolve(f));l.delete(c,f).setStoredMarks(d),r.dispatch(l);break}case"deleteContentForward":{const{tr:l,doc:a,selection:u}=r.state,c=u.from,f=u.empty?u.to+1:u.to,d=a.resolve(c).marksAcross(a.resolve(f));l.delete(c,f).setStoredMarks(d);break}case"deleteContent":{const{tr:l,doc:a,selection:u}=r.state,c=a.resolve(u.from).marksAcross(a.resolve(u.to));l.delete(u.from,u.to).setStoredMarks(c),r.dispatch(l);break}}return!0}}}})}const Tt=typeof navigator<"u"?navigator:null,Lh=typeof document<"u"?document:null,Dn=Tt&&Tt.userAgent||"",Bu=/Edge\/(\d+)/.exec(Dn),G0=/MSIE \d/.exec(Dn),Vu=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Dn),vl=!!(G0||Vu||Bu),wC=G0?document.documentMode:Vu?+Vu[1]:Bu?+Bu[1]:0,X0=!vl&&/gecko\/(\d+)/i.test(Dn),vC=X0&&+(/Firefox\/(\d+)/.exec(Dn)||[0,0])[1],$u=!vl&&/Chrome\/(\d+)/.exec(Dn),xC=!!$u,CC=$u?+$u[1]:0,Z0=!vl&&!!Tt&&/Apple Computer/.test(Tt.vendor),ey=Z0&&(/Mobile\/\w+/.test(Dn)||!!Tt&&Tt.maxTouchPoints>2),NC=ey||(Tt?/Mac/.test(Tt.platform):!1),MC=Tt?/Win/.test(Tt.platform):!1,EC=/Android \d/.test(Dn),ty=!!Lh&&"webkitFontSmoothing"in Lh.documentElement.style,OC=ty?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0,Le={ie:vl,ie_version:wC,gecko:X0,gecko_version:vC,chrome:xC,chrome_version:CC,safari:Z0,ios:ey,mac:NC,windows:MC,android:EC,webkit:ty,webkit_version:OC};function Bh(t){return t.editable&&!t.hasFocus()?!1:DC(t)}function DC(t){var n,r;const e=t.domSelectionRange();if(!e.anchorNode)return!1;try{return t.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(t.editable||t.dom.contains(((n=e.focusNode)==null?void 0:n.nodeType)==3?(r=e.focusNode)==null?void 0:r.parentNode:e.focusNode))}catch{return!1}}function TC(t,e,n,r){return t.someProp("createSelectionBetween",i=>i(t,e,n))||B.between(e,n,r)}function Vh(t,e=null){const n=t.domSelectionRange(),r=t.state.doc;if(!n.focusNode)return null;let i=t.docView.nearestDesc(n.focusNode);const o=i&&i.size==0,s=t.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(s<0)return null;const l=r.resolve(s);let a,u;if(K0(n)){for(a=l;i&&!i.node;)i=i.parent;const c=i.node;if(i&&c.isAtom&&z.isSelectable(c)&&i.parent&&!(c.isInline&&lC(n.focusNode,n.focusOffset,i.dom))){const f=i.posBefore;u=new z(s==f?l:r.resolve(f))}}else{const c=t.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(c<0)return null;a=r.resolve(c)}if(!u){const c=e=="pointer"||t.state.selection.head{(r.anchorNode!=i||r.anchorOffset!=o)&&(n.removeEventListener("selectionchange",e.input.hideSelectionGuard),setTimeout(()=>{(!ny(e)||e.state.selection.visible)&&e.dom.classList.remove("ProseMirror-hideselection")},20))})}const Hh=Le.safari||Le.chrome&&Le.chrome_version<63;function Yo(t,e=!1){const n=t,r=n.state.selection;if(PC(n,r),!!ny(n)){if(!e&&n.input.mouseDown&&n.input.mouseDown.allowDefault&&Le.chrome){const i=n.domSelectionRange(),o=n.domObserver.currentSelection;if(i.anchorNode&&o.anchorNode&&tl(i.anchorNode,i.anchorOffset,o.anchorNode,o.anchorOffset)){n.input.mouseDown.delayedSelectionSync=!0,n.domObserver.setCurSelection();return}}if(n.domObserver.disconnectSelection(),n.cursorWrapper)FC(n);else{const{anchor:i,head:o}=r;let s,l;Hh&&!(r instanceof B)&&(r.$from.parent.inlineContent||(s=Uh(n,r.from)),!r.empty&&!r.$from.parent.inlineContent&&(l=Uh(n,r.to))),n.docView.setSelection(i,o,n.root,e),Hh&&(s&&jh(s),l&&jh(l)),r.visible?n.dom.classList.remove("ProseMirror-hideselection"):(n.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&IC(n))}n.domObserver.setCurSelection(),n.domObserver.connectSelection()}}class bC{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}}class LC{constructor(e){this.view=e,this.flushingSoon=-1,this.currentSelection=new bC,this.suppressingSelectionUpdates=!1,this.view=e,this.onSelectionChange=this.onSelectionChange.bind(this)}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}stop(){this.disconnectSelection()}start(){this.connectSelection()}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;const n=new Set;let r;for(let o=e.focusNode;o;o=Ih(o))n.add(o);for(let o=e.anchorNode;o;o=Ih(o))if(n.has(o)){r=o;break}const i=r&&this.view.docView.nearestDesc(r);if(i&&i.ignoreMutation({type:"selection",target:(r==null?void 0:r.nodeType)==3?r==null?void 0:r.parentNode:r}))return this.setCurSelection(),!0}registerMutation(){}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}updateSelection(){const{view:e}=this,n=e.input.compositionPendingChanges||(e.composing?e.input.compositionID:0);e.input.compositionPendingChanges=0;const r=e.input.lastSelectionTime>Date.now()-50?e.input.lastSelectionOrigin:null,i=Vh(e,r);if(i&&!e.state.selection.eq(i)){const o=e.state.tr.setSelection(i);r=="pointer"?o.setMeta("pointer",!0):r=="key"&&o.scrollIntoView(),n&&o.setMeta("composition",n),e.dispatch(o)}}selectionToDOM(){const{view:e}=this;Yo(e);const n=e.domSelectionRange();this.currentSelection.set(n)}flush(){const{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;const n=e.domSelectionRange(),r=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(n)&&Bh(e)&&!this.ignoreSelectionChange(n);let i=null;r&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}onSelectionChange(){if(Bh(this.view)&&!this.view.composing){if(this.suppressingSelectionUpdates)return Yo(this.view);if(Le.ie&&Le.ie_version<=11&&!this.view.state.selection.empty){const e=this.view.domSelectionRange();if(e.focusNode&&tl(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}}const qr=0,Jh=1,Go=2,uo=3;class Co{constructor(e,n,r,i){this.parent=e,this.children=n,this.dom=r,this.contentDOM=i,this.dirty=qr,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,n,r){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let n=0;nen(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))i=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(n==0)for(let o=e;;o=o.parentNode){if(o==this.dom){i=!1;break}if(o.previousSibling)break}if(i==null&&n==e.childNodes.length)for(let o=e;;o=o.parentNode){if(o==this.dom){i=!0;break}if(o.nextSibling)break}}return i??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,n=!1){for(let r=!0,i=e;i;i=i.parentNode){const o=this.getDesc(i);let s;if(o&&(!n||o.node))if(r&&(s=o.nodeDOM)&&!(s.nodeType==1?s.contains(e.nodeType==1?e:e.parentNode):s==e))r=!1;else return o}}getDesc(e){const n=e.pmViewDesc;for(let r=n;r;r=r.parent)if(r==this)return n}posFromDOM(e,n,r){for(let i=e;i;i=i.parentNode){const o=this.getDesc(i);if(o)return o.localPosFromDOM(e,n,r)}return-1}descAt(e){for(let n=0,r=0;ne||s instanceof ry){i=e-o;break}o=l}if(i)return this.children[r].domFromPos(i-this.children[r].border,n);for(let o;r&&!(o=this.children[r-1]).size&&o instanceof cf&&o.side>=0;r--);if(n<=0){let o,s=!0;for(;o=r?this.children[r-1]:null,!(!o||o.dom.parentNode==this.contentDOM);r--,s=!1);return o&&n&&s&&!o.border&&!o.domAtom?o.domFromPos(o.size,n):{node:this.contentDOM,offset:o?en(o.dom)+1:0}}else{let o,s=!0;for(;o=r=c&&n<=u-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,n,c);e=s;for(let f=l;f>0;f--){const d=this.children[f-1];if(d.size&&d.dom.parentNode==this.contentDOM&&!d.emptyChildAt(1)){i=en(d.dom)+1;break}e-=d.size}i==-1&&(i=0)}if(i>-1&&(u>n||l==this.children.length-1)){n=u;for(let c=l+1;ch&&sn){const h=l;l=a,a=h}const p=document.createRange();p.setEnd(a.node,a.offset),p.setStart(l.node,l.offset),u.removeAllRanges(),u.addRange(p)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,n){for(let r=0,i=0;i=r:er){const l=r+o.border,a=s-o.border;if(e>=l&&n<=a){this.dirty=e==r||n==s?Go:Jh,e==l&&n==a&&(o.contentLost||o.dom.parentNode!=this.contentDOM)?o.dirty=uo:o.markDirty(e-l,n-l);return}else o.dirty=o.dom==o.contentDOM&&o.dom.parentNode==this.contentDOM&&!o.children.length?Go:uo}r=s}this.dirty=Go}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){const r=e==1?Go:Jh;n.dirtythis.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let n=this.children.length-1;n>=0;n--){const r=this.children[n];if(this.dom.contains(r.dom.parentNode)){e.contentElement=r.dom.parentNode;break}}e.contentElement||(e.getContent=()=>v.empty)}return e}matchesNode(e,n,r){return this.dirty==qr&&e.eq(this.node)&&_C(n,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}update(e,n,r,i){return!0}selectNode(){this.nodeDOM.nodeType==1&&this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.dom.draggable=!0)}deselectNode(){this.nodeDOM.nodeType==1&&this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.dom.removeAttribute("draggable")}get domAtom(){return this.node.isAtom}}class $C extends ff{constructor(e,n,r,i,o,s,l){super(e,n,r,i,o,s,null,l)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,n,r,i){return!0}inParent(){const e=this.parent.contentDOM;for(let n=this.nodeDOM;n;n=n.parentNode)if(n==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,n,r){return e==this.nodeDOM?this.posAtStart+Math.min(n,this.node.text.length):super.localPosFromDOM(e,n,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}markDirty(e,n){super.markDirty(e,n),this.dom!=this.nodeDOM&&(e==0||n==this.nodeDOM.nodeValue.length)&&(this.dirty=uo)}get domAtom(){return!1}}class ry extends Co{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==qr&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}function _C(t,e){if(t.length!=e.length)return!1;for(let n=0;n{u=!!a.call(this,s,l)}),u||l.defaultPrevented)return!0}return!1};e[r]=o}return new At({key:new po("@nytimes/react-prosemirror/componentEventListeners"),props:{handleDOMEvents:e}})}function UC(){const[t,e]=C.useState(new Map),n=C.useCallback((o,s)=>{const l=t.get(o)??[];l.unshift(s),t.has(o)||(t.set(o,l),e(new Map(t)))},[t]),r=C.useCallback((o,s)=>{const l=t.get(o);l==null||l.splice(l.indexOf(s),1)},[t]),i=C.useMemo(()=>WC(t),[t]);return{registerEventListener:n,unregisterEventListener:r,componentEventListenersPlugin:i}}function iy(){const[,t]=C.useReducer(e=>e+1,0);return t}class jC extends Tk{constructor(e,n){super(e,{state:on.create({schema:n.state.schema,plugins:n.state.plugins}),plugins:n.plugins}),this.shouldUpdatePluginViews=!1,this.shouldUpdatePluginViews=!0,this._props=n,this.oldProps={state:n.state},this.state=n.state,this.domObserver.stop(),this.domObserver=new LC(this),this.domObserver.start(),this.docView.dom.replaceChildren(),this.docView=n.docView}pureSetProps(e){this._props={...this._props,...e},this.state=this._props.state}runPendingEffects(){const e=this.props;this._props=this.oldProps,this.state=this._props.state,this.update(e)}update(e){super.update(e),this.oldProps=e}updatePluginViews(){this.shouldUpdatePluginViews&&super.updatePluginViews()}}const HC=new Sp({nodes:{doc:{content:"text*"},text:{inline:!0}}}),JC=on.create({schema:HC});function KC(t,e){const[n,r]=C.useState(null),[i,o]=C.useState(null),s=iy(),l=e.defaultState??JC,[a,u]=C.useState(l),c=e.state??a,{componentEventListenersPlugin:f,registerEventListener:d,unregisterEventListener:p}=UC(),h=C.useCallback(w=>{Kr.flushSync(()=>{o(w)})},[]),m=C.useMemo(()=>[...e.plugins??[],f,kC(h)],[e.plugins,f,h]);function k(w){Kr.flushSync(()=>{e.state||u(M=>M.apply(w)),e.dispatchTransaction&&e.dispatchTransaction.call(this,w)})}const g=document.createElement("div"),y=C.useRef(new ff(void 0,[],c.doc,[],W.empty,g,null,g)),S={...e,state:c,plugins:m,dispatchTransaction:k,docView:y.current};return C.useLayoutEffect(()=>{if(n&&n.dom!==t&&r(null),!!t&&!n){const w=new jC({mount:t},S);r(w),w.dom.addEventListener("compositionend",s);return}}),n==null||n.pureSetProps(S),C.useMemo(()=>({view:n,state:c,registerEventListener:d,unregisterEventListener:p,cursorWrapper:i,docViewDescRef:y}),[n,c,d,p,i])}function qC(t){C.useLayoutEffect(()=>{t==null||t.domObserver.selectionToDOM(),t==null||t.runPendingEffects()},[t,t==null?void 0:t.props])}function QC({children:t}){const e=C.useRef(new Set).current,n=C.useRef(new Set).current,r=C.useRef(!1),i=iy(),o=C.useRef(!0),s=C.useCallback(()=>{o.current||(i(),o.current=!0)},[i]),l=C.useCallback(a=>{let u;const c=()=>{u=a()};return e.add(c),s(),()=>{e.delete(c),u&&(r.current?(n.add(u),s()):u())}},[e,n,s]);return C.useLayoutEffect(()=>(o.current=!1,e.forEach(a=>a()),e.clear(),()=>{n.forEach(a=>a()),n.clear()})),C.useLayoutEffect(()=>(r.current=!0,()=>{r.current=!1}),[]),F(q0.Provider,{value:l,children:t})}const gt=C.createContext([]);function oy(t,e,n,r,i,o,s){const l=C.useRef(o),a=C.useContext(gt),u=[];return C.useLayoutEffect(()=>{if(!t||!n.current)return;const c=u[0];l.current?(l.current.parent=void 0,l.current.children=u,l.current.node=t,l.current.outerDeco=i,l.current.innerDeco=r,l.current.dom=(e==null?void 0:e.current)??n.current,l.current.dom.pmViewDesc=l.current,l.current.contentDOM=(s==null?void 0:s.current)??l.current.contentDOM??(c==null?void 0:c.dom.parentElement)??null,l.current.nodeDOM=n.current):l.current=new ff(void 0,u,t,i,r,(e==null?void 0:e.current)??n.current,(c==null?void 0:c.dom.parentElement)??null,n.current),a.push(l.current);for(const f of u)f.parent=l.current}),u}var sy={exports:{}};/*! Copyright (c) 2018 Jed Watson. Licensed under the MIT License (MIT), see http://jedwatson.github.io/classnames -*/(function(t){(function(){var e=function(){function n(){}n.prototype=Object.create(null);function r(f,d){for(var p=d.length,h=0;ho;)l.push(i[s++]);let d=o+c.nodeSize;if(c.isText){let h=d;s!h.inline):l.slice();r(c,p,e.forChild(o,c),o,f),o=d}}function xl(){const{state:t}=C.useContext(xo);return t}function ly(){const t=xl();return t&&lo.getState(t)}const df=C.forwardRef(function({outputSpec:e,children:n,...r},i){if(typeof e=="string")return F(Ku,{children:e});if(!Array.isArray(e))throw new Error("@nytimes/react-prosemirror only supports strings and arrays in toDOM");const s=e[0].replace(" ",":"),l=e[1],a={...r,ref:i};let u=1;if(l&&typeof l=="object"&&l.nodeType==null&&!Array.isArray(l)){u=2;for(const f in l)if(l[f]!=null){const d=f==="class"?"className":f.replace(" ",":");a[d]=l[f]}}const c=[];for(let f=u;fu)throw new RangeError("Content hole must be the only child of its parent node");return C.createElement(s,a,n)}c.push(F(df,{ref:void 0,outputSpec:d,children:n}))}return C.createElement(s,a,...c)}),ay=C.forwardRef(function({mark:e,children:n},r){var a,u;const i=C.useContext(Tt),o=[],s=C.useRef(null);C.useImperativeHandle(r,()=>s.current,[]);const l=(u=(a=e.type.spec).toDOM)==null?void 0:u.call(a,e,!0);if(!l)throw new Error(`Mark spec for ${e.type.name} is missing toDOM`);return C.useLayoutEffect(()=>{if(!s.current)return;const c=o[0],f=new VC(void 0,o,e,s.current,(c==null?void 0:c.dom.parentElement)??s.current);i.push(f);for(const d of o)d.parent=f}),F(df,{ref:s,outputSpec:l,children:F(Tt.Provider,{value:o,children:n})})});function eN({widget:t,pos:e}){const n=C.useContext(Tt),r=C.useRef(null),i=C.useRef(e);return i.current=e,Q0(o=>{if(!r.current)return;const s=t.type.toDOM;let l=typeof s=="function"?s(o,()=>i.current):s;if(!t.type.spec.raw){if(l.nodeType!=1){const a=document.createElement("span");a.appendChild(l),l=a}l.contentEditable="false",l.classList.add("ProseMirror-widget")}r.current.firstElementChild!==l&&r.current.replaceChildren(l)}),C.useLayoutEffect(()=>{if(!r.current)return;const o=new cf(void 0,t,r.current);n.push(o)}),F("span",{ref:r})}function uy({outerDeco:t,pos:e,node:n,innerDeco:r,...i}){var O,T,P;const o=C.useRef(null),s=C.useRef(null),l=C.useRef(null),a=C.useRef(n),u=C.useRef(t),c=C.useRef(r),f=C.useRef(e);f.current=e;const d=C.useRef(null),p=C.useRef(null),h=xl(),{nodeViews:m}=C.useContext(H0),{view:k}=C.useContext(xo);let g=null;const y=m[n.type.name],S=(O=k==null?void 0:k.someProp("nodeViews"))==null?void 0:O[n.type.name];C.useLayoutEffect(()=>{if(!p.current||!d.current)return;const{dom:A}=p.current;return s.current=d.current,d.current.appendChild(A),()=>{var H,st;(st=(H=p.current)==null?void 0:H.destroy)==null||st.call(H)}},[]),C.useLayoutEffect(()=>{if(!S||!p.current)return;const{destroy:A,update:H}=p.current;if(((H==null?void 0:H.call(p.current,n,t,r))??!0)||(A==null||A.call(p.current),!S||!d.current))return;a.current=n,u.current=t,c.current=r,p.current=S(a.current,k,()=>f.current,u.current,c.current);const{dom:Tn}=p.current;s.current=d.current,d.current.appendChild(Tn)},[S,k,r,n,t]);const w=oy(n,o,s,r,t,void 0,l);if(y)g=F(y,{...i,ref:s,nodeProps:{node:n,pos:e,decorations:t,innerDecorations:r,isSelected:(h==null?void 0:h.selection)instanceof z&&h.selection.node===n},children:F(Fi,{pos:e,node:n,innerDecorations:r})});else if(S){p.current||(p.current=S(a.current,k,()=>f.current,u.current,c.current));const{contentDOM:A}=p.current;l.current=A??null,g=C.createElement(n.isInline?"span":"div",{ref:d,contentEditable:!!A,suppressContentEditableWarning:!0},A&&Kr.createPortal(F(Fi,{pos:e,node:n,innerDecorations:r}),A))}else{const A=(P=(T=n.type.spec).toDOM)==null?void 0:P.call(T,n);A&&(g=F(df,{...i,ref:s,outputSpec:A,children:F(Fi,{pos:e,node:n,innerDecorations:r})}))}if(!g)throw new Error(`Node spec for ${n.type.name} is missing toDOM`);const M=C.cloneElement(t.reduce(hf,g),t.some(A=>A.type.attrs.nodeName)?{ref:o}:void 0),E=n.marks.reduce((A,H)=>F(ay,{mark:H,children:A}),M);return F(Tt.Provider,{value:w,children:C.cloneElement(E,n.marks.length||t.some(A=>A.type.attrs.nodeName)?{ref:o}:void 0)})}class tN extends C.Component{constructor(){super(...arguments),this.viewDescRef=null}updateEffect(){const{decorations:e,siblingDescriptors:n,node:r}=this.props,i=Kr.findDOMNode(this);if(!i)return;let o=i;for(;o.firstChild;)o=o.firstChild;!this.viewDescRef||this.viewDescRef instanceof BC?this.viewDescRef=new $C(void 0,[],r,e,W.empty,i,o):(this.viewDescRef.parent=void 0,this.viewDescRef.children=[],this.viewDescRef.node=r,this.viewDescRef.outerDeco=e,this.viewDescRef.innerDeco=W.empty,this.viewDescRef.dom=i,this.viewDescRef.nodeDOM=o),n.push(this.viewDescRef)}componentDidMount(){this.updateEffect()}componentDidUpdate(){this.updateEffect()}render(){const{node:e,decorations:n}=this.props;return n.reduce(hf,e.text)}}function nN(){const t=C.useContext(Tt),e=C.useRef(null);return C.useLayoutEffect(()=>{if(!e.current)return;const n=new ry(void 0,[],e.current,null);t.push(n)}),F("br",{ref:e,className:"ProseMirror-trailingBreak"})}function rN({widget:t,pos:e}){const n=C.useContext(Tt),r=C.useRef(null);C.useLayoutEffect(()=>{if(!r.current)return;const o=new cf(void 0,t,r.current);n.push(o)});const{Component:i}=t.type;return i&&F(i,{ref:r,widget:t,pos:e,contentEditable:!1})}function Kh(t){const e=`{"${t.replace(/;? *$/,"").replace(/;+ */g,'","').replace(/: */g,'":"')}"}`,n=JSON.parse(e);return Object.keys(n).reduce((r,i)=>{const o=i.startsWith("--")?i:i.replace(/-[a-z]/g,s=>{var l;return((l=s[1])==null?void 0:l.toUpperCase())??""});return{...r,[o]:n[i]}},{})}function hf(t,e){const{nodeName:n,class:r,style:i,contenteditable:o,spellcheck:s,...l}=e.type.attrs;return n||typeof t=="string"?C.createElement(n??"span",{className:r,contentEditable:o,spellCheck:s,style:i&&Kh(i),...l},t):C.cloneElement(t,{className:GC(t.props.className,r),contentEditable:o,spellCheck:s,style:{...t.props.style,...i&&Kh(i)},...l})}function _u({innerPos:t,childViews:e}){const{view:n}=C.useContext(xo),r=xl(),i=ly(),o=e.reduce((s,l)=>{var c;const a=s[s.length-1];if(!a)return[[l]];const u=a[a.length-1];return u?!l.marks.length&&!u.marks.length||l.marks.length&&u.marks.length&&((c=l.marks[0])!=null&&c.eq(u.marks[0]))?[...s.slice(0,s.length-1),[...a.slice(0,a.length),l]]:[...s,[l]]:[...s.slice(0,s.length),[l]]},[]);return F(Ku,{children:o.map(s=>{const l=s[0];if(!l)return null;const a=l.marks[0];return a?F(ay,{mark:a,children:F(_u,{innerPos:t,childViews:s.map(u=>({...u,marks:u.marks.slice(1)}))},Pr(r==null?void 0:r.doc,t,l,i==null?void 0:i.posToKey))},Pr(r==null?void 0:r.doc,t,l,i==null?void 0:i.posToKey)):s.map(u=>{const c=t+u.offset,f=u.type==="widget"?F(rN,{widget:u.widget,pos:c}):u.type==="native-widget"?F(eN,{widget:u.widget,pos:c}):u.node.isText?F(Tt.Consumer,{children:d=>F(tN,{view:n,node:u.node,pos:c,siblingDescriptors:d,decorations:u.outerDeco})}):F(uy,{node:u.node,pos:c,outerDeco:u.outerDeco,innerDeco:u.innerDeco});return C.cloneElement(f,{key:Pr(r==null?void 0:r.doc,t,u,i==null?void 0:i.posToKey)})})})})}function Pr(t,e,n,r){const i=e+n.offset,o=r==null?void 0:r.get(i);if(n.type==="widget"||n.type==="native-widget")return n.widget.type.spec.key?n.widget.type.spec.key:(console.warn(`Widget at position ${i} doesn't have a key specified. This has negative performance implications.`),`${o}-${n.index}`);if(o)return o;if(!t)return i;const s=t.resolve(i).start()-1,l=r==null?void 0:r.get(s);return l?`${l}-${n.offset}`:i}function iN(t){const e=t[t.length-1];if((e==null?void 0:e.type)!=="node")return;const n=e.marks;for(let r=t.length-2;r>=0;r--){const i=t[r];if((i==null?void 0:i.type)!=="widget"||i.widget.type.side<0)break;i.marks=i.marks.reduce((o,s)=>s.addToSet(o),n)}}function Fi({pos:t,node:e,innerDecorations:n}){const r=xl(),i=ly();if(!e)return null;const o=[],s=t+1,l=[];return ZC(e,n,(a,u,c,f)=>{var p,h;const d=a.type.spec.marks??[];u?l.push({type:"native-widget",widget:a,marks:a.type.side>=0?d:d.reduce((m,k)=>k.addToSet(m),((p=l[0])==null?void 0:p.marks)??[]),offset:c,index:f}):l.push({type:"widget",widget:a,marks:a.type.side>=0?d:d.reduce((m,k)=>k.addToSet(m),((h=l[0])==null?void 0:h.marks)??[]),offset:c,index:f})},(a,u,c,f)=>{if(!a.isInline){l.length&&(o.push(F(_u,{childViews:[...l],innerPos:s},Pr(r==null?void 0:r.doc,s,l[0],i==null?void 0:i.posToKey))),l.splice(0,l.length));const d=s+f,p=(i==null?void 0:i.posToKey.get(d))??d;o.push(F(uy,{outerDeco:u,node:a,innerDeco:c,pos:d},p));return}l.push({type:"node",node:a,marks:a.marks,innerDeco:c,outerDeco:u,offset:f}),iN(l)}),l.length&&o.push(F(_u,{childViews:l,innerPos:s},Pr(r==null?void 0:r.doc,s,l[0],i==null?void 0:i.posToKey))),o.length||o.push(F(nN,{},Pr(r==null?void 0:r.doc,s,{type:"trailinghack",offset:0},i==null?void 0:i.posToKey))),F(Ku,{children:o})}const oN=C.forwardRef(function({className:e,node:n,innerDeco:r,outerDeco:i,as:o,viewDesc:s},l){const a=C.useRef(null);C.useImperativeHandle(l,()=>a.current,[]);const u=oy(n,a,a,r,i,s),c={ref:a,className:e,suppressContentEditableWarning:!0},f=o?C.cloneElement(o,c,F(Tt.Provider,{value:u,children:F(Fi,{pos:-1,node:n,innerDecorations:r})})):C.createElement("div",c,F(Tt.Provider,{value:u,children:F(Fi,{pos:-1,node:n,innerDecorations:r})}));if(!n)return f;const d=i.filter(h=>!h.inline);return d.length?d.reduce(hf,f):f}),cy=C.createContext(null);function sN({as:t},e){const n=C.useRef(null),{setMount:r,...i}=C.useContext(cy);return C.useImperativeHandle(e,()=>n.current,[]),F(oN,{ref:o=>{n.current=o,r(o)},...i,as:t})}const lN=C.forwardRef(sN);function aN({className:t,children:e,nodeViews:n={},customNodeViews:r,...i}){var c;const[o,s]=C.useState(null),l=KC(o,{...i,nodeViews:r});qC(l.view);const a=l.view?iC(l.view,l.cursorWrapper):W.empty,u=l.view?eC(l.view):[];return F(QC,{children:F(xo.Provider,{value:l,children:F(H0.Provider,{value:{nodeViews:n},children:F(cy.Provider,{value:{className:t,setMount:s,node:(c=l.view)==null?void 0:c.state.doc,innerDeco:a,outerDeco:u,viewDesc:l.docViewDescRef.current},children:e})})})})}const U=new Sp({nodes:{doc:{content:"block+"},paragraph:{group:"block",content:"inline*",toDOM(){return["p",0]}},...kw({cellContent:"inline*",cellAttributes:{},tableGroup:"block"}),list:{group:"block",content:"list_item+",toDOM(){return["ul",0]}},list_item:{content:"paragraph+",toDOM(){return["li",0]}},image:{group:"block",toDOM(){return["div",["img",{src:"https://smoores.gitlab.io/storyteller/img/Storyteller_Logo.png",height:150,width:150}]]}},text:{group:"inline"}},marks:{em:{toDOM(){return["em",0]}},strong:{toDOM(){return["strong",0]}}}}),uN=on.create({schema:U,doc:U.nodes.doc.create({},[U.nodes.paragraph.create({},[U.text("This ",[U.marks.em.create()]),U.text("is",[U.marks.em.create(),U.marks.strong.create()]),U.text(" the first paragraph")]),U.nodes.paragraph.create({},U.text("This is the second paragraph")),U.nodes.paragraph.create(),U.nodes.image.create(),U.nodes.image.create(),U.nodes.paragraph.create({},U.text("This is the third paragraph")),U.nodes.table.create({},[U.nodes.table_row.create({},[U.nodes.table_header.create({},U.text("h1")),U.nodes.table_header.create({},U.text("h2"))]),U.nodes.table_row.create({},[U.nodes.table_cell.create({},U.text("c1")),U.nodes.table_cell.create({},U.text("c2"))])])]),plugins:[hC(),_k({rules:[Wk(/^\s*([-+*])\s$/,U.nodes.list)]}),Bw(),Yw()]}),cN=C.forwardRef(function({children:e,nodeProps:n,...r},i){return F("p",{ref:i,...r,children:e})}),fN=C.forwardRef(function({children:e,nodeProps:n,...r},i){return F("ul",{ref:i,...r,children:e})}),dN=C.forwardRef(function({children:e,nodeProps:n,...r},i){return F("li",{ref:i,...r,children:e})}),hN=C.forwardRef(function({widget:e,pos:n,...r},i){return F("span",{...r,ref:i,style:{display:"block",backgroundColor:"blue",width:"4px",height:"4px",position:"absolute",transform:"translateX(-2px)"},children:"Widget"})}),pN=new At({view(t){const e=t.coordsAtPos(t.state.selection.from),n=document.createElement("div");return n.style.width="4px",n.style.height="4px",n.style.position="absolute",n.style.top=`${e.top-2}px`,n.style.left=`${e.left-2}px`,n.style.backgroundColor="blue",document.body.appendChild(n),{update(r){const i=r.coordsAtPos(r.state.selection.from);n.style.top=`${i.top-2}px`,n.style.left=`${i.left-2}px`},destroy(){document.body.removeChild(n)}}}});new At({props:{decorations(t){return W.create(t.doc,[Y0(t.selection.from,hN,{side:0,key:"widget-plugin-widget"})])}},view(t){const e=t.coordsAtPos(t.state.selection.from),n=document.createElement("div");return n.style.width="4px",n.style.height="4px",n.style.position="absolute",n.style.top=`${e.top-2}px`,n.style.left=`${e.left-2}px`,n.style.backgroundColor="blue",document.body.appendChild(n),{update(r){const i=r.coordsAtPos(r.state.selection.from);n.style.top=`${i.top-2}px`,n.style.left=`${i.left-2}px`},destroy(){document.body.removeChild(n)}}}});const mN=[Jk({...Q1,"Mod-i":If(U.marks.em),"Mod-b":If(U.marks.strong)}),pN,Fk()],gN={paragraph:()=>{const t=document.createElement("p");return{dom:t,contentDOM:t}}};function yN(){const[t,e]=C.useState(uN),[n,r]=C.useState(!0);return Sf("main",{children:[F("h1",{children:"React ProseMirror Demo"}),Sf("button",{onClick:()=>{n?r(i=>!i):window.location.reload()},children:["Switch to"," ",n?"ProseMirror node views":"React node views (requires reload)"]}),F(aN,{className:"ProseMirror",state:t,dispatchTransaction:function(i){e(o=>o.apply(i))},plugins:mN,nodeViews:n?{paragraph:cN,list:fN,list_item:dN}:void 0,customNodeViews:n?void 0:gN,children:F(lN,{as:F("article",{})})},`${n}`)]})}const SN=j0(document.getElementById("root"));SN.render(F(yN,{})); +*/(function(t){(function(){var e=function(){function n(){}n.prototype=Object.create(null);function r(f,d){for(var p=d.length,h=0;ho;)l.push(i[s++]);let d=o+c.nodeSize;if(c.isText){let h=d;s!h.inline):l.slice();r(c,p,e.forChild(o,c),o,f),o=d}}function xl(){const{state:t}=C.useContext(xo);return t}function ly(){const t=xl();return t&&lo.getState(t)}const df=C.forwardRef(function({outputSpec:e,children:n,...r},i){if(typeof e=="string")return F(Ku,{children:e});if(!Array.isArray(e))throw new Error("@nytimes/react-prosemirror only supports strings and arrays in toDOM");const s=e[0].replace(" ",":"),l=e[1],a={...r,ref:i};let u=1;if(l&&typeof l=="object"&&l.nodeType==null&&!Array.isArray(l)){u=2;for(const f in l)if(l[f]!=null){const d=f==="class"?"className":f.replace(" ",":");a[d]=l[f]}}const c=[];for(let f=u;fu)throw new RangeError("Content hole must be the only child of its parent node");return C.createElement(s,a,n)}c.push(F(df,{ref:void 0,outputSpec:d,children:n}))}return C.createElement(s,a,...c)}),ay=C.forwardRef(function({mark:e,children:n},r){var a,u;const i=C.useContext(gt),o=[],s=C.useRef(null);C.useImperativeHandle(r,()=>s.current,[]);const l=(u=(a=e.type.spec).toDOM)==null?void 0:u.call(a,e,!0);if(!l)throw new Error(`Mark spec for ${e.type.name} is missing toDOM`);return C.useLayoutEffect(()=>{if(!s.current)return;const c=o[0],f=new VC(void 0,o,e,s.current,(c==null?void 0:c.dom.parentElement)??s.current);i.push(f);for(const d of o)d.parent=f}),F(df,{ref:s,outputSpec:l,children:F(gt.Provider,{value:o,children:n})})});function eN({widget:t,pos:e}){const n=C.useContext(gt),r=C.useRef(null),i=C.useRef(e);return i.current=e,Q0(o=>{if(!r.current)return;const s=t.type.toDOM;let l=typeof s=="function"?s(o,()=>i.current):s;if(!t.type.spec.raw){if(l.nodeType!=1){const a=document.createElement("span");a.appendChild(l),l=a}l.contentEditable="false",l.classList.add("ProseMirror-widget")}r.current.firstElementChild!==l&&r.current.replaceChildren(l)}),C.useLayoutEffect(()=>{if(!r.current)return;const o=new cf(void 0,t,r.current);n.push(o)}),F("span",{ref:r})}function uy({outerDeco:t,pos:e,node:n,innerDeco:r,...i}){var O,T,P;const o=C.useRef(null),s=C.useRef(null),l=C.useRef(null),a=C.useRef(n),u=C.useRef(t),c=C.useRef(r),f=C.useRef(e);f.current=e;const d=C.useRef(null),p=C.useRef(null),h=xl(),{nodeViews:m}=C.useContext(H0),{view:k}=C.useContext(xo);let g=null;const y=m[n.type.name],S=(O=k==null?void 0:k.someProp("nodeViews"))==null?void 0:O[n.type.name];C.useLayoutEffect(()=>{if(!p.current||!d.current)return;const{dom:A}=p.current;return s.current=d.current,d.current.appendChild(A),()=>{var H,st;(st=(H=p.current)==null?void 0:H.destroy)==null||st.call(H)}},[]),C.useLayoutEffect(()=>{if(!S||!p.current)return;const{destroy:A,update:H}=p.current;if(((H==null?void 0:H.call(p.current,n,t,r))??!0)||(A==null||A.call(p.current),!S||!d.current))return;a.current=n,u.current=t,c.current=r,p.current=S(a.current,k,()=>f.current,u.current,c.current);const{dom:Tn}=p.current;s.current=d.current,d.current.appendChild(Tn)},[S,k,r,n,t]);const w=oy(n,o,s,r,t,void 0,l);if(y)g=F(y,{...i,ref:s,nodeProps:{node:n,pos:e,decorations:t,innerDecorations:r,isSelected:(h==null?void 0:h.selection)instanceof z&&h.selection.node===n},children:F(Fi,{pos:e,node:n,innerDecorations:r})});else if(S){p.current||(p.current=S(a.current,k,()=>f.current,u.current,c.current));const{contentDOM:A}=p.current;l.current=A??null,g=C.createElement(n.isInline?"span":"div",{ref:d,contentEditable:!!A,suppressContentEditableWarning:!0},A&&Kr.createPortal(F(Fi,{pos:e,node:n,innerDecorations:r}),A))}else{const A=(P=(T=n.type.spec).toDOM)==null?void 0:P.call(T,n);A&&(g=F(df,{...i,ref:s,outputSpec:A,children:F(Fi,{pos:e,node:n,innerDecorations:r})}))}if(!g)throw new Error(`Node spec for ${n.type.name} is missing toDOM`);const M=C.cloneElement(t.reduce(hf,g),t.some(A=>A.type.attrs.nodeName)?{ref:o}:void 0),E=n.marks.reduce((A,H)=>F(ay,{mark:H,children:A}),M);return F(gt.Provider,{value:w,children:C.cloneElement(E,n.marks.length||t.some(A=>A.type.attrs.nodeName)?{ref:o}:void 0)})}class tN extends C.Component{constructor(){super(...arguments),this.viewDescRef=null}updateEffect(){const{decorations:e,siblingDescriptors:n,node:r}=this.props,i=Kr.findDOMNode(this);if(!i)return;let o=i;for(;o.firstChild;)o=o.firstChild;!this.viewDescRef||this.viewDescRef instanceof BC?this.viewDescRef=new $C(void 0,[],r,e,W.empty,i,o):(this.viewDescRef.parent=void 0,this.viewDescRef.children=[],this.viewDescRef.node=r,this.viewDescRef.outerDeco=e,this.viewDescRef.innerDeco=W.empty,this.viewDescRef.dom=i,this.viewDescRef.nodeDOM=o),n.push(this.viewDescRef)}componentDidMount(){this.updateEffect()}componentDidUpdate(){this.updateEffect()}render(){const{node:e,decorations:n}=this.props;return n.reduce(hf,e.text)}}function nN(){const t=C.useContext(gt),e=C.useRef(null);return C.useLayoutEffect(()=>{if(!e.current)return;const n=new ry(void 0,[],e.current,null);t.push(n)}),F("br",{ref:e,className:"ProseMirror-trailingBreak"})}function rN({widget:t,pos:e}){const n=C.useContext(gt),r=C.useRef(null);C.useLayoutEffect(()=>{if(!r.current)return;const o=new cf(void 0,t,r.current);n.push(o)});const{Component:i}=t.type;return i&&F(i,{ref:r,widget:t,pos:e,contentEditable:!1})}function Kh(t){const e=`{"${t.replace(/;? *$/,"").replace(/;+ */g,'","').replace(/: */g,'":"')}"}`,n=JSON.parse(e);return Object.keys(n).reduce((r,i)=>{const o=i.startsWith("--")?i:i.replace(/-[a-z]/g,s=>{var l;return((l=s[1])==null?void 0:l.toUpperCase())??""});return{...r,[o]:n[i]}},{})}function hf(t,e){const{nodeName:n,class:r,style:i,contenteditable:o,spellcheck:s,...l}=e.type.attrs;return n||typeof t=="string"?C.createElement(n??"span",{className:r,contentEditable:o,spellCheck:s,style:i&&Kh(i),...l},t):C.cloneElement(t,{className:GC(t.props.className,r),contentEditable:o,spellCheck:s,style:{...t.props.style,...i&&Kh(i)},...l})}function _u({innerPos:t,childViews:e}){const{view:n}=C.useContext(xo),r=xl(),i=ly(),o=e.reduce((s,l)=>{var c;const a=s[s.length-1];if(!a)return[[l]];const u=a[a.length-1];return u?!l.marks.length&&!u.marks.length||l.marks.length&&u.marks.length&&((c=l.marks[0])!=null&&c.eq(u.marks[0]))?[...s.slice(0,s.length-1),[...a.slice(0,a.length),l]]:[...s,[l]]:[...s.slice(0,s.length),[l]]},[]);return F(Ku,{children:o.map(s=>{const l=s[0];if(!l)return null;const a=l.marks[0];return a?F(ay,{mark:a,children:F(_u,{innerPos:t,childViews:s.map(u=>({...u,marks:u.marks.slice(1)}))},Pr(r==null?void 0:r.doc,t,l,i==null?void 0:i.posToKey))},Pr(r==null?void 0:r.doc,t,l,i==null?void 0:i.posToKey)):s.map(u=>{const c=t+u.offset,f=u.type==="widget"?F(rN,{widget:u.widget,pos:c}):u.type==="native-widget"?F(eN,{widget:u.widget,pos:c}):u.node.isText?F(gt.Consumer,{children:d=>F(tN,{view:n,node:u.node,pos:c,siblingDescriptors:d,decorations:u.outerDeco})}):F(uy,{node:u.node,pos:c,outerDeco:u.outerDeco,innerDeco:u.innerDeco});return C.cloneElement(f,{key:Pr(r==null?void 0:r.doc,t,u,i==null?void 0:i.posToKey)})})})})}function Pr(t,e,n,r){const i=e+n.offset,o=r==null?void 0:r.get(i);if(n.type==="widget"||n.type==="native-widget")return n.widget.type.spec.key?n.widget.type.spec.key:(console.warn(`Widget at position ${i} doesn't have a key specified. This has negative performance implications.`),`${o}-${n.index}`);if(o)return o;if(!t)return i;const s=t.resolve(i).start()-1,l=r==null?void 0:r.get(s);return l?`${l}-${n.offset}`:i}function iN(t){const e=t[t.length-1];if((e==null?void 0:e.type)!=="node")return;const n=e.marks;for(let r=t.length-2;r>=0;r--){const i=t[r];if((i==null?void 0:i.type)!=="widget"||i.widget.type.side<0)break;i.marks=i.marks.reduce((o,s)=>s.addToSet(o),n)}}function Fi({pos:t,node:e,innerDecorations:n}){const r=xl(),i=ly();if(!e)return null;const o=[],s=t+1,l=[];return ZC(e,n,(a,u,c,f)=>{var p,h;const d=a.type.spec.marks??[];u?l.push({type:"native-widget",widget:a,marks:a.type.side>=0?d:d.reduce((m,k)=>k.addToSet(m),((p=l[0])==null?void 0:p.marks)??[]),offset:c,index:f}):l.push({type:"widget",widget:a,marks:a.type.side>=0?d:d.reduce((m,k)=>k.addToSet(m),((h=l[0])==null?void 0:h.marks)??[]),offset:c,index:f})},(a,u,c,f)=>{if(!a.isInline){l.length&&(o.push(F(_u,{childViews:[...l],innerPos:s},Pr(r==null?void 0:r.doc,s,l[0],i==null?void 0:i.posToKey))),l.splice(0,l.length));const d=s+f,p=(i==null?void 0:i.posToKey.get(d))??d;o.push(F(uy,{outerDeco:u,node:a,innerDeco:c,pos:d},p));return}l.push({type:"node",node:a,marks:a.marks,innerDeco:c,outerDeco:u,offset:f}),iN(l)}),l.length&&o.push(F(_u,{childViews:l,innerPos:s},Pr(r==null?void 0:r.doc,s,l[0],i==null?void 0:i.posToKey))),o.length||o.push(F(nN,{},Pr(r==null?void 0:r.doc,s,{type:"trailinghack",offset:0},i==null?void 0:i.posToKey))),F(Ku,{children:o})}const oN=C.forwardRef(function({className:e,node:n,innerDeco:r,outerDeco:i,as:o,viewDesc:s},l){const a=C.useRef(null);C.useImperativeHandle(l,()=>a.current,[]);const u=oy(n,a,a,r,i,s),c={ref:a,className:e,suppressContentEditableWarning:!0},f=o?C.cloneElement(o,c,F(gt.Provider,{value:u,children:F(Fi,{pos:-1,node:n,innerDecorations:r})})):C.createElement("div",c,F(gt.Provider,{value:u,children:F(Fi,{pos:-1,node:n,innerDecorations:r})}));if(!n)return f;const d=i.filter(h=>!h.inline);return d.length?d.reduce(hf,f):f}),cy=C.createContext(null);function sN({as:t},e){const n=C.useRef(null),{setMount:r,...i}=C.useContext(cy);return C.useImperativeHandle(e,()=>n.current,[]),F(gt.Provider,{value:[],children:F(oN,{ref:o=>{n.current=o,r(o)},...i,as:t})})}const lN=C.forwardRef(sN);function aN({className:t,children:e,nodeViews:n={},customNodeViews:r,...i}){var c;const[o,s]=C.useState(null),l=KC(o,{...i,nodeViews:r});qC(l.view);const a=l.view?iC(l.view,l.cursorWrapper):W.empty,u=l.view?eC(l.view):[];return F(QC,{children:F(xo.Provider,{value:l,children:F(H0.Provider,{value:{nodeViews:n},children:F(cy.Provider,{value:{className:t,setMount:s,node:(c=l.view)==null?void 0:c.state.doc,innerDeco:a,outerDeco:u,viewDesc:l.docViewDescRef.current},children:e})})})})}const U=new Sp({nodes:{doc:{content:"block+"},paragraph:{group:"block",content:"inline*",toDOM(){return["p",0]}},...kw({cellContent:"inline*",cellAttributes:{},tableGroup:"block"}),list:{group:"block",content:"list_item+",toDOM(){return["ul",0]}},list_item:{content:"paragraph+",toDOM(){return["li",0]}},image:{group:"block",toDOM(){return["div",["img",{src:"https://smoores.gitlab.io/storyteller/img/Storyteller_Logo.png",height:150,width:150}]]}},text:{group:"inline"}},marks:{em:{toDOM(){return["em",0]}},strong:{toDOM(){return["strong",0]}}}}),uN=on.create({schema:U,doc:U.nodes.doc.create({},[U.nodes.paragraph.create({},[U.text("This ",[U.marks.em.create()]),U.text("is",[U.marks.em.create(),U.marks.strong.create()]),U.text(" the first paragraph")]),U.nodes.paragraph.create({},U.text("This is the second paragraph")),U.nodes.paragraph.create(),U.nodes.image.create(),U.nodes.image.create(),U.nodes.paragraph.create({},U.text("This is the third paragraph")),U.nodes.table.create({},[U.nodes.table_row.create({},[U.nodes.table_header.create({},U.text("h1")),U.nodes.table_header.create({},U.text("h2"))]),U.nodes.table_row.create({},[U.nodes.table_cell.create({},U.text("c1")),U.nodes.table_cell.create({},U.text("c2"))])])]),plugins:[hC(),_k({rules:[Wk(/^\s*([-+*])\s$/,U.nodes.list)]}),Bw(),Yw()]}),cN=C.forwardRef(function({children:e,nodeProps:n,...r},i){return F("p",{ref:i,...r,children:e})}),fN=C.forwardRef(function({children:e,nodeProps:n,...r},i){return F("ul",{ref:i,...r,children:e})}),dN=C.forwardRef(function({children:e,nodeProps:n,...r},i){return F("li",{ref:i,...r,children:e})}),hN=C.forwardRef(function({widget:e,pos:n,...r},i){return F("span",{...r,ref:i,style:{display:"block",backgroundColor:"blue",width:"4px",height:"4px",position:"absolute",transform:"translateX(-2px)"},children:"Widget"})}),pN=new At({view(t){const e=t.coordsAtPos(t.state.selection.from),n=document.createElement("div");return n.style.width="4px",n.style.height="4px",n.style.position="absolute",n.style.top=`${e.top-2}px`,n.style.left=`${e.left-2}px`,n.style.backgroundColor="blue",document.body.appendChild(n),{update(r){const i=r.coordsAtPos(r.state.selection.from);n.style.top=`${i.top-2}px`,n.style.left=`${i.left-2}px`},destroy(){document.body.removeChild(n)}}}});new At({props:{decorations(t){return W.create(t.doc,[Y0(t.selection.from,hN,{side:0,key:"widget-plugin-widget"})])}},view(t){const e=t.coordsAtPos(t.state.selection.from),n=document.createElement("div");return n.style.width="4px",n.style.height="4px",n.style.position="absolute",n.style.top=`${e.top-2}px`,n.style.left=`${e.left-2}px`,n.style.backgroundColor="blue",document.body.appendChild(n),{update(r){const i=r.coordsAtPos(r.state.selection.from);n.style.top=`${i.top-2}px`,n.style.left=`${i.left-2}px`},destroy(){document.body.removeChild(n)}}}});const mN=[Jk({...Q1,"Mod-i":If(U.marks.em),"Mod-b":If(U.marks.strong)}),pN,Fk()],gN={paragraph:()=>{const t=document.createElement("p");return{dom:t,contentDOM:t}}};function yN(){const[t,e]=C.useState(uN),[n,r]=C.useState(!0);return Sf("main",{children:[F("h1",{children:"React ProseMirror Demo"}),Sf("button",{onClick:()=>{n?r(i=>!i):window.location.reload()},children:["Switch to"," ",n?"ProseMirror node views":"React node views (requires reload)"]}),F(aN,{className:"ProseMirror",state:t,dispatchTransaction:function(i){e(o=>o.apply(i))},plugins:mN,nodeViews:n?{paragraph:cN,list:fN,list_item:dN}:void 0,customNodeViews:n?void 0:gN,children:F(lN,{as:F("article",{})})},`${n}`)]})}const SN=j0(document.getElementById("root"));SN.render(F(yN,{})); diff --git a/docs/index.html b/docs/index.html index 3c96cb68..6eb9ffc7 100644 --- a/docs/index.html +++ b/docs/index.html @@ -5,7 +5,7 @@ React-ProseMirror Demo - + diff --git a/src/components/ProseMirrorDoc.tsx b/src/components/ProseMirrorDoc.tsx index 1c2361db..a80f2655 100644 --- a/src/components/ProseMirrorDoc.tsx +++ b/src/components/ProseMirrorDoc.tsx @@ -8,6 +8,8 @@ import React, { useRef, } from "react"; +import { ChildDescriptorsContext } from "../contexts/ChildDescriptorsContext.js"; + import { DocNodeView, DocNodeViewProps } from "./DocNodeView.js"; type DocNodeViewContextValue = Omit & { @@ -38,14 +40,16 @@ function ProseMirrorDoc( ); return ( - { - innerRef.current = el; - setMount(el); - }} - {...docProps} - as={as} - /> + + { + innerRef.current = el; + setMount(el); + }} + {...docProps} + as={as} + /> + ); }