From 5b29bfa176a426f39a0d498a5d5f5b8de61e0871 Mon Sep 17 00:00:00 2001 From: Shane Friedman Date: Fri, 6 Oct 2023 15:23:15 -0400 Subject: [PATCH] Keep docView stable and only protect active text node during composition --- .../{index-191f530f.js => index-6451b138.js} | 30 ++++++------- docs/index.html | 2 +- src/components/ChildNodeViews.tsx | 1 + src/components/DocNodeView.tsx | 7 ++- src/components/ProseMirror.tsx | 32 ++++++++++++-- src/components/TextNodeView.tsx | 8 +++- src/hooks/useEditorView.ts | 10 ----- src/hooks/useNodeViewDescriptor.ts | 44 +++++++++++++------ src/prosemirror-view/index.ts | 4 +- src/prosemirror-view/viewdesc.ts | 2 +- 10 files changed, 92 insertions(+), 48 deletions(-) rename docs/assets/{index-191f530f.js => index-6451b138.js} (72%) diff --git a/docs/assets/index-191f530f.js b/docs/assets/index-6451b138.js similarity index 72% rename from docs/assets/index-191f530f.js rename to docs/assets/index-6451b138.js index 259caad0..530d9770 100644 --- a/docs/assets/index-191f530f.js +++ b/docs/assets/index-6451b138.js @@ -1,4 +1,4 @@ -(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const o of i)if(o.type==="childList")for(const l of o.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&r(l)}).observe(document,{childList:!0,subtree:!0});function n(i){const o={};return i.integrity&&(o.integrity=i.integrity),i.referrerPolicy&&(o.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?o.credentials="include":i.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function r(i){if(i.ep)return;i.ep=!0;const o=n(i);fetch(i.href,o)}})();function ug(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Sd={exports:{}},kl={},vd={exports:{}},B={};/** +(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const o of i)if(o.type==="childList")for(const l of o.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&r(l)}).observe(document,{childList:!0,subtree:!0});function n(i){const o={};return i.integrity&&(o.integrity=i.integrity),i.referrerPolicy&&(o.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?o.credentials="include":i.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function r(i){if(i.ep)return;i.ep=!0;const o=n(i);fetch(i.href,o)}})();function ug(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Sd={exports:{}},Sl={},vd={exports:{}},B={};/** * @license React * react.production.min.js * @@ -6,7 +6,7 @@ * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var Ui=Symbol.for("react.element"),ag=Symbol.for("react.portal"),cg=Symbol.for("react.fragment"),fg=Symbol.for("react.strict_mode"),dg=Symbol.for("react.profiler"),hg=Symbol.for("react.provider"),pg=Symbol.for("react.context"),mg=Symbol.for("react.forward_ref"),gg=Symbol.for("react.suspense"),yg=Symbol.for("react.memo"),kg=Symbol.for("react.lazy"),fc=Symbol.iterator;function Sg(t){return t===null||typeof t!="object"?null:(t=fc&&t[fc]||t["@@iterator"],typeof t=="function"?t:null)}var wd={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},xd=Object.assign,Cd={};function Rr(t,e,n){this.props=t,this.context=e,this.refs=Cd,this.updater=n||wd}Rr.prototype.isReactComponent={};Rr.prototype.setState=function(t,e){if(typeof t!="object"&&typeof t!="function"&&t!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,t,e,"setState")};Rr.prototype.forceUpdate=function(t){this.updater.enqueueForceUpdate(this,t,"forceUpdate")};function Ed(){}Ed.prototype=Rr.prototype;function ju(t,e,n){this.props=t,this.context=e,this.refs=Cd,this.updater=n||wd}var Ju=ju.prototype=new Ed;Ju.constructor=ju;xd(Ju,Rr.prototype);Ju.isPureReactComponent=!0;var dc=Array.isArray,Nd=Object.prototype.hasOwnProperty,Hu={current:null},Od={key:!0,ref:!0,__self:!0,__source:!0};function Md(t,e,n){var r,i={},o=null,l=null;if(e!=null)for(r in e.ref!==void 0&&(l=e.ref),e.key!==void 0&&(o=""+e.key),e)Nd.call(e,r)&&!Od.hasOwnProperty(r)&&(i[r]=e[r]);var s=arguments.length-2;if(s===1)i.children=n;else if(1>1}};se.from=function(t){if(t instanceof se)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new se(e)};function Rd(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 l=0;i.text[l]==o.text[l];l++)n++;return n}if(i.content.size||o.content.size){let l=Rd(i.content,o.content,n+1);if(l!=null)return l}n+=i.nodeSize}}function Pd(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 l=t.child(--i),s=e.child(--o),u=l.nodeSize;if(l==s){n-=u,r-=u;continue}if(!l.sameMarkup(s))return{a:n,b:r};if(l.isText&&l.text!=s.text){let a=0,c=Math.min(l.text.length,s.text.length);for(;ae&&r(u,i+s,o||null,l)!==!1&&u.content.size){let c=s+1;u.nodesBetween(Math.max(0,e-c),Math.min(u.content.size,n-c),r,i+c)}s=a}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,r,i){let o="",l=!0;return this.nodesBetween(e,n,(s,u)=>{s.isText?(o+=s.text.slice(Math.max(e,u)-u,n-u),l=!r):s.isLeaf?(i?o+=typeof i=="function"?i(s):i:s.type.spec.leafText&&(o+=s.type.spec.leafText(s)),l=!r):!l&&s.isBlock&&(o+=r,l=!0)},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,l=0;le&&((ln)&&(s.isText?s=s.cut(Math.max(0,e-l),Math.min(s.text.length,n-l)):s=s.cut(Math.max(0,e-l-1),Math.min(s.content.size,n-l-1))),r.push(s),i+=s.nodeSize),l=u}return new x(r,i)}cutByIndex(e,n){return e==n?x.empty:e==0&&n==this.content.length?this:new x(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 x(i,o)}addToStart(e){return new x([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new x(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),l=i+o.nodeSize;if(l>=e)return l==e||n>0?Zi(r+1,l):Zi(r,i);i=l}}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 x.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new x(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return x.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 yi extends Error{}class C{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=Ad(this.content,e+this.openStart,n);return r&&new C(r,this.openStart,this.openEnd)}removeBetween(e,n){return new C(zd(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 C.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 C(x.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 C(e,r,i)}}C.empty=new C(x.empty,0,0);function zd(t,e,n){let{index:r,offset:i}=t.findIndex(e),o=t.maybeChild(r),{index:l,offset:s}=t.findIndex(n);if(i==e||o.isText){if(s!=n&&!t.child(l).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(r!=l)throw new RangeError("Removing non-flat range");return t.replaceChild(r,o.copy(zd(o.content,e-i-1,n-i-1)))}function Ad(t,e,n,r){let{index:i,offset:o}=t.findIndex(e),l=t.maybeChild(i);if(o==e||l.isText)return r&&!r.canReplace(i,i,n)?null:t.cut(0,e).append(n).append(t.cut(e));let s=Ad(l.content,e-o-1,n);return s&&t.replaceChild(i,l.copy(s))}function Rg(t,e,n){if(n.openStart>t.depth)throw new yi("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new yi("Inconsistent open depths");return Id(t,e,n,0)}function Id(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 ei(t,e,n,r){let i=(e||t).node(n),o=0,l=e?e.index(n):i.childCount;t&&(o=t.index(n),t.depth>n?o++:t.textOffset&&(Rn(t.nodeAfter,r),o++));for(let s=o;si&&Ls(t,e,i+1),l=r.depth>i&&Ls(n,r,i+1),s=[];return ei(null,t,i,s),o&&l&&e.index(i)==n.index(i)?(Fd(o,l),Rn(Pn(o,Ld(t,e,n,r,i+1)),s)):(o&&Rn(Pn(o,_o(t,e,i+1)),s),ei(e,n,i,s),l&&Rn(Pn(l,_o(n,r,i+1)),s)),ei(r,null,i,s),new x(s)}function _o(t,e,n){let r=[];if(ei(null,t,n,r),t.depth>n){let i=Ls(t,e,n+1);Rn(Pn(i,_o(t,e,n+1)),r)}return ei(e,null,n,r),new x(r)}function Pg(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(x.from(i));return{start:i.resolveNoCache(t.openStart+n),end:i.resolveNoCache(i.content.size-t.openEnd-n)}}class ki{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 Ag(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 l=e;;){let{index:s,offset:u}=l.content.findIndex(o),a=o-u;if(r.push(l,s,i+u),!a||(l=l.child(s),l.isText))break;o=a-1,i+=u+1}return new ki(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()+")"),Bd(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=x.empty,i=0,o=r.childCount){let l=this.contentMatchAt(e).matchFragment(r,i,o),s=l&&l.matchFragment(this.content,n);if(!s||!s.validEnd)return!1;for(let u=i;un.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=x.fromJSON(e,n.content);return e.nodeType(n.type).create(n.attrs,i,r)}}ht.prototype.text=void 0;class bo extends ht{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):Bd(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 bo(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new bo(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 Bd(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class Ln{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new Fg(e,n);if(r.next==null)return Ln.empty;let i=Vd(r);r.next&&r.err("Unexpected trailing text");let o=Wg($g(i));return Ug(o,r),o}matchType(e){for(let n=0;na.createAndFill()));for(let a=0;a=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 l=0;l"+e.indexOf(r.next[l].next);return o}).join(` -`)}}Ln.empty=new Ln(!0);class Fg{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 Vd(t){let e=[];do e.push(Lg(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function Lg(t){let e=[];do e.push(Bg(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function Bg(t){let e=bg(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=Vg(t,e);else break;return e}function pc(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function Vg(t,e){let n=pc(t),r=n;return t.eat(",")&&(t.next!="}"?r=pc(t):r=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function _g(t,e){let n=t.nodeTypes,r=n[e];if(r)return[r];let i=[];for(let o in n){let l=n[o];l.groups.indexOf(e)>-1&&i.push(l)}return i.length==0&&t.err("No node type or group '"+e+"' found"),i}function bg(t){if(t.eat("(")){let e=Vd(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=_g(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 $g(t){let e=[[]];return i(o(t,0),n()),e;function n(){return e.push([])-1}function r(l,s,u){let a={term:u,to:s};return e[l].push(a),a}function i(l,s){l.forEach(u=>u.to=s)}function o(l,s){if(l.type=="choice")return l.exprs.reduce((u,a)=>u.concat(o(a,s)),[]);if(l.type=="seq")for(let u=0;;u++){let a=o(l.exprs[u],s);if(u==l.exprs.length-1)return a;i(a,s=n())}else if(l.type=="star"){let u=n();return r(s,u),i(o(l.expr,u),u),[r(u)]}else if(l.type=="plus"){let u=n();return i(o(l.expr,s),u),i(o(l.expr,u),u),[r(u)]}else{if(l.type=="opt")return[r(s)].concat(o(l.expr,s));if(l.type=="range"){let u=s;for(let a=0;a{t[l].forEach(({term:s,to:u})=>{if(!s)return;let a;for(let c=0;c{a||i.push([s,a=[]]),a.indexOf(c)==-1&&a.push(c)})})});let o=e[r.join(",")]=new Ln(r.indexOf(t.length-1)>-1);for(let l=0;l-1}allowsMarks(e){if(this.markSet==null)return!0;for(let n=0;nr[o]=new Ud(o,n,l));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 jg{constructor(e){this.hasDefault=Object.prototype.hasOwnProperty.call(e,"default"),this.default=e.default}get isRequired(){return!this.hasDefault}}class vl{constructor(e,n,r,i){this.name=e,this.rank=n,this.schema=r,this.spec=i,this.attrs=Wd(i.attrs),this.excluded=null;let o=bd(this.attrs);this.instance=o?new _(this,o):null}create(e=null){return!e&&this.instance?this.instance:new _(this,$d(this.attrs,e))}static compile(e,n){let r=Object.create(null),i=0;return e.forEach((o,l)=>r[o]=new vl(o,i++,n,l)),r}removeFromSet(e){for(var n=0;n-1}}class Jg{constructor(e){this.cached=Object.create(null);let n=this.spec={};for(let i in e)n[i]=e[i];n.nodes=se.from(e.nodes),n.marks=se.from(e.marks||{}),this.nodes=gc.compile(this.spec.nodes,this),this.marks=vl.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],l=o.spec.content||"",s=o.spec.marks;o.contentMatch=r[l]||(r[l]=Ln.parse(l,this.nodes)),o.inlineContent=o.contentMatch.inlineContent,o.markSet=s=="_"?null:s?yc(this,s.split(" ")):s==""||!o.inlineContent?[]:null}for(let i in this.marks){let o=this.marks[i],l=o.spec.excludes;o.excluded=l==null?[o]:l==""?[]:yc(this,l.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 gc){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 bo(r,r.defaultAttrs,e,_.setFrom(n))}mark(e,n){return typeof e=="string"&&(e=this.marks[e]),e.create(n)}nodeFromJSON(e){return ht.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 yc(t,e){let n=[];for(let r=0;r-1)&&n.push(l=u)}if(!l)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return n}class Si{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 Sc(this,n,!1);return r.addAll(e,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new Sc(this,n,!0);return r.addAll(e,n.from,n.to),C.maxOpen(r.finish())}matchTag(e,n,r){for(let i=r?this.tags.indexOf(r)+1:0;ie.length&&(s.charCodeAt(e.length)!=61||s.slice(e.length+1)!=n))){if(l.getAttrs){let u=l.getAttrs(n);if(u===!1)continue;l.attrs=u||void 0}return l}}}static schemaRules(e){let n=[];function r(i){let o=i.priority==null?50:i.priority,l=0;for(;l{r(l=vc(l)),l.mark||l.ignore||l.clearMark||(l.mark=i)})}for(let i in e.nodes){let o=e.nodes[i].spec.parseDOM;o&&o.forEach(l=>{r(l=vc(l)),l.node||l.ignore||l.mark||(l.node=i)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Si(e,Si.schemaRules(e)))}}const jd={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},Hg={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Jd={ol:!0,ul:!0},$o=1,Wo=2,ti=4;function kc(t,e,n){return e!=null?(e?$o:0)|(e==="full"?Wo:0):t&&t.whitespace=="pre"?$o|Wo:n&~ti}class eo{constructor(e,n,r,i,o,l,s){this.type=e,this.attrs=n,this.marks=r,this.pendingMarks=i,this.solid=o,this.options=s,this.content=[],this.activeMarks=_.none,this.stashMarks=[],this.match=l||(s&ti?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(x.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&$o)){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=x.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(x.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}};se.from=function(t){if(t instanceof se)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new se(e)};function Rd(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 l=0;i.text[l]==o.text[l];l++)n++;return n}if(i.content.size||o.content.size){let l=Rd(i.content,o.content,n+1);if(l!=null)return l}n+=i.nodeSize}}function Pd(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 l=t.child(--i),s=e.child(--o),u=l.nodeSize;if(l==s){n-=u,r-=u;continue}if(!l.sameMarkup(s))return{a:n,b:r};if(l.isText&&l.text!=s.text){let a=0,c=Math.min(l.text.length,s.text.length);for(;ae&&r(u,i+s,o||null,l)!==!1&&u.content.size){let c=s+1;u.nodesBetween(Math.max(0,e-c),Math.min(u.content.size,n-c),r,i+c)}s=a}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,r,i){let o="",l=!0;return this.nodesBetween(e,n,(s,u)=>{s.isText?(o+=s.text.slice(Math.max(e,u)-u,n-u),l=!r):s.isLeaf?(i?o+=typeof i=="function"?i(s):i:s.type.spec.leafText&&(o+=s.type.spec.leafText(s)),l=!r):!l&&s.isBlock&&(o+=r,l=!0)},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,l=0;le&&((ln)&&(s.isText?s=s.cut(Math.max(0,e-l),Math.min(s.text.length,n-l)):s=s.cut(Math.max(0,e-l-1),Math.min(s.content.size,n-l-1))),r.push(s),i+=s.nodeSize),l=u}return new x(r,i)}cutByIndex(e,n){return e==n?x.empty:e==0&&n==this.content.length?this:new x(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 x(i,o)}addToStart(e){return new x([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new x(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),l=i+o.nodeSize;if(l>=e)return l==e||n>0?eo(r+1,l):eo(r,i);i=l}}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 x.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new x(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return x.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 ki extends Error{}class C{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=Ad(this.content,e+this.openStart,n);return r&&new C(r,this.openStart,this.openEnd)}removeBetween(e,n){return new C(zd(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 C.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 C(x.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 C(e,r,i)}}C.empty=new C(x.empty,0,0);function zd(t,e,n){let{index:r,offset:i}=t.findIndex(e),o=t.maybeChild(r),{index:l,offset:s}=t.findIndex(n);if(i==e||o.isText){if(s!=n&&!t.child(l).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(r!=l)throw new RangeError("Removing non-flat range");return t.replaceChild(r,o.copy(zd(o.content,e-i-1,n-i-1)))}function Ad(t,e,n,r){let{index:i,offset:o}=t.findIndex(e),l=t.maybeChild(i);if(o==e||l.isText)return r&&!r.canReplace(i,i,n)?null:t.cut(0,e).append(n).append(t.cut(e));let s=Ad(l.content,e-o-1,n);return s&&t.replaceChild(i,l.copy(s))}function Rg(t,e,n){if(n.openStart>t.depth)throw new ki("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new ki("Inconsistent open depths");return Id(t,e,n,0)}function Id(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 ti(t,e,n,r){let i=(e||t).node(n),o=0,l=e?e.index(n):i.childCount;t&&(o=t.index(n),t.depth>n?o++:t.textOffset&&(Rn(t.nodeAfter,r),o++));for(let s=o;si&&Vs(t,e,i+1),l=r.depth>i&&Vs(n,r,i+1),s=[];return ti(null,t,i,s),o&&l&&e.index(i)==n.index(i)?(Fd(o,l),Rn(Pn(o,Ld(t,e,n,r,i+1)),s)):(o&&Rn(Pn(o,bo(t,e,i+1)),s),ti(e,n,i,s),l&&Rn(Pn(l,bo(n,r,i+1)),s)),ti(r,null,i,s),new x(s)}function bo(t,e,n){let r=[];if(ti(null,t,n,r),t.depth>n){let i=Vs(t,e,n+1);Rn(Pn(i,bo(t,e,n+1)),r)}return ti(e,null,n,r),new x(r)}function Pg(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(x.from(i));return{start:i.resolveNoCache(t.openStart+n),end:i.resolveNoCache(i.content.size-t.openEnd-n)}}class Si{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 Ag(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 l=e;;){let{index:s,offset:u}=l.content.findIndex(o),a=o-u;if(r.push(l,s,i+u),!a||(l=l.child(s),l.isText))break;o=a-1,i+=u+1}return new Si(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()+")"),Bd(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=x.empty,i=0,o=r.childCount){let l=this.contentMatchAt(e).matchFragment(r,i,o),s=l&&l.matchFragment(this.content,n);if(!s||!s.validEnd)return!1;for(let u=i;un.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=x.fromJSON(e,n.content);return e.nodeType(n.type).create(n.attrs,i,r)}}ht.prototype.text=void 0;class $o extends ht{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):Bd(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 $o(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new $o(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 Bd(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class Ln{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new Fg(e,n);if(r.next==null)return Ln.empty;let i=Vd(r);r.next&&r.err("Unexpected trailing text");let o=Wg($g(i));return Ug(o,r),o}matchType(e){for(let n=0;na.createAndFill()));for(let a=0;a=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 l=0;l"+e.indexOf(r.next[l].next);return o}).join(` +`)}}Ln.empty=new Ln(!0);class Fg{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 Vd(t){let e=[];do e.push(Lg(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function Lg(t){let e=[];do e.push(Bg(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function Bg(t){let e=bg(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=Vg(t,e);else break;return e}function mc(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function Vg(t,e){let n=mc(t),r=n;return t.eat(",")&&(t.next!="}"?r=mc(t):r=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function _g(t,e){let n=t.nodeTypes,r=n[e];if(r)return[r];let i=[];for(let o in n){let l=n[o];l.groups.indexOf(e)>-1&&i.push(l)}return i.length==0&&t.err("No node type or group '"+e+"' found"),i}function bg(t){if(t.eat("(")){let e=Vd(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=_g(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 $g(t){let e=[[]];return i(o(t,0),n()),e;function n(){return e.push([])-1}function r(l,s,u){let a={term:u,to:s};return e[l].push(a),a}function i(l,s){l.forEach(u=>u.to=s)}function o(l,s){if(l.type=="choice")return l.exprs.reduce((u,a)=>u.concat(o(a,s)),[]);if(l.type=="seq")for(let u=0;;u++){let a=o(l.exprs[u],s);if(u==l.exprs.length-1)return a;i(a,s=n())}else if(l.type=="star"){let u=n();return r(s,u),i(o(l.expr,u),u),[r(u)]}else if(l.type=="plus"){let u=n();return i(o(l.expr,s),u),i(o(l.expr,u),u),[r(u)]}else{if(l.type=="opt")return[r(s)].concat(o(l.expr,s));if(l.type=="range"){let u=s;for(let a=0;a{t[l].forEach(({term:s,to:u})=>{if(!s)return;let a;for(let c=0;c{a||i.push([s,a=[]]),a.indexOf(c)==-1&&a.push(c)})})});let o=e[r.join(",")]=new Ln(r.indexOf(t.length-1)>-1);for(let l=0;l-1}allowsMarks(e){if(this.markSet==null)return!0;for(let n=0;nr[o]=new Ud(o,n,l));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 jg{constructor(e){this.hasDefault=Object.prototype.hasOwnProperty.call(e,"default"),this.default=e.default}get isRequired(){return!this.hasDefault}}class wl{constructor(e,n,r,i){this.name=e,this.rank=n,this.schema=r,this.spec=i,this.attrs=Wd(i.attrs),this.excluded=null;let o=bd(this.attrs);this.instance=o?new _(this,o):null}create(e=null){return!e&&this.instance?this.instance:new _(this,$d(this.attrs,e))}static compile(e,n){let r=Object.create(null),i=0;return e.forEach((o,l)=>r[o]=new wl(o,i++,n,l)),r}removeFromSet(e){for(var n=0;n-1}}class Jg{constructor(e){this.cached=Object.create(null);let n=this.spec={};for(let i in e)n[i]=e[i];n.nodes=se.from(e.nodes),n.marks=se.from(e.marks||{}),this.nodes=yc.compile(this.spec.nodes,this),this.marks=wl.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],l=o.spec.content||"",s=o.spec.marks;o.contentMatch=r[l]||(r[l]=Ln.parse(l,this.nodes)),o.inlineContent=o.contentMatch.inlineContent,o.markSet=s=="_"?null:s?kc(this,s.split(" ")):s==""||!o.inlineContent?[]:null}for(let i in this.marks){let o=this.marks[i],l=o.spec.excludes;o.excluded=l==null?[o]:l==""?[]:kc(this,l.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 yc){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 $o(r,r.defaultAttrs,e,_.setFrom(n))}mark(e,n){return typeof e=="string"&&(e=this.marks[e]),e.create(n)}nodeFromJSON(e){return ht.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 kc(t,e){let n=[];for(let r=0;r-1)&&n.push(l=u)}if(!l)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return n}class vi{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 vc(this,n,!1);return r.addAll(e,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new vc(this,n,!0);return r.addAll(e,n.from,n.to),C.maxOpen(r.finish())}matchTag(e,n,r){for(let i=r?this.tags.indexOf(r)+1:0;ie.length&&(s.charCodeAt(e.length)!=61||s.slice(e.length+1)!=n))){if(l.getAttrs){let u=l.getAttrs(n);if(u===!1)continue;l.attrs=u||void 0}return l}}}static schemaRules(e){let n=[];function r(i){let o=i.priority==null?50:i.priority,l=0;for(;l{r(l=wc(l)),l.mark||l.ignore||l.clearMark||(l.mark=i)})}for(let i in e.nodes){let o=e.nodes[i].spec.parseDOM;o&&o.forEach(l=>{r(l=wc(l)),l.node||l.ignore||l.mark||(l.node=i)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new vi(e,vi.schemaRules(e)))}}const jd={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},Hg={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Jd={ol:!0,ul:!0},Wo=1,Uo=2,ni=4;function Sc(t,e,n){return e!=null?(e?Wo:0)|(e==="full"?Uo:0):t&&t.whitespace=="pre"?Wo|Uo:n&~ni}class to{constructor(e,n,r,i,o,l,s){this.type=e,this.attrs=n,this.marks=r,this.pendingMarks=i,this.solid=o,this.options=s,this.content=[],this.activeMarks=_.none,this.stashMarks=[],this.match=l||(s&ni?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(x.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&Wo)){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=x.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(x.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{l.clearMark(s)&&(r=s.addToSet(r))}):n=this.parser.schema.marks[l.mark].create(l.attrs).addToSet(n),l.consuming===!1)o=l;else break}return[n,r]}addElementByRule(e,n,r){let i,o,l;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)):(l=this.parser.schema.marks[n.mark].create(n.attrs),this.addPendingMark(l));let s=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(u=>this.insertNode(u));else{let u=e;typeof n.contentElement=="string"?u=e.querySelector(n.contentElement):typeof n.contentElement=="function"?u=n.contentElement(e):n.contentElement&&(u=n.contentElement),this.findAround(e,u,!0),this.addAll(u)}i&&this.sync(s)&&this.open--,l&&this.removePendingMark(l,s)}addAll(e,n,r){let i=n||0;for(let o=n?e.childNodes[n]:e.firstChild,l=r==null?null:e.childNodes[r];o!=l;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],l=o.findWrapping(e);if(l&&(!n||n.length>l.length)&&(n=l,r=o,!l.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),l=(s,u)=>{for(;s>=0;s--){let a=n[s];if(a==""){if(s==n.length-1||s==0)continue;for(;u>=o;u--)if(l(s-1,u))return!0;return!1}else{let c=u>0||u==0&&i?this.nodes[u].type:r&&u>=o?r.node(u-o).type:null;if(!c||c.name!=a&&c.groups.indexOf(a)==-1)return!1;u--}}return!0};return l(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=Gg(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 l=i.popFromStashMark(e);l&&i.type&&i.type.allowsMarkType(l.type)&&(i.activeMarks=l.addToSet(i.activeMarks))}if(i==n)break}}}function Kg(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&Jd.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function Qg(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function qg(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 vc(t){let e={};for(let n in t)e[n]=t[n];return e}function Yg(t,e){let n=e.schema.nodes;for(let r in n){let i=n[r];if(!i.allowsMarkType(t))continue;let o=[],l=s=>{o.push(s);for(let u=0;u{if(o.length||l.marks.length){let s=0,u=0;for(;s=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&&Nt.renderSpec(Yl(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 l,s=r?e.createElementNS(r,i):e.createElement(i),u=n[1],a=1;if(u&&typeof u=="object"&&u.nodeType==null&&!Array.isArray(u)){a=2;for(let c in u)if(u[c]!=null){let f=c.indexOf(" ");f>0?s.setAttributeNS(c.slice(0,f),c.slice(f+1),u[c]):s.setAttribute(c,u[c])}}for(let c=a;ca)throw new RangeError("Content hole must be the only child of its parent node");return{dom:s,contentDOM:s}}else{let{dom:d,contentDOM:p}=Nt.renderSpec(e,f,r);if(s.appendChild(d),p){if(l)throw new RangeError("Multiple content holes");l=p}}}return{dom:s,contentDOM:l}}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new Nt(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=wc(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return wc(e.marks)}}function wc(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function Yl(t){return t.document||window.document}const Hd=65535,Kd=Math.pow(2,16);function Xg(t,e){return t+e*Kd}function xc(t){return t&Hd}function Zg(t){return(t-(t&Hd))/Kd}const Qd=1,qd=2,xo=4,Yd=8;let Bs=class{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&Yd)>0}get deletedBefore(){return(this.delInfo&(Qd|xo))>0}get deletedAfter(){return(this.delInfo&(qd|xo))>0}get deletedAcross(){return(this.delInfo&xo)>0}},yr=class Qn{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&Qn.empty)return Qn.empty}recover(e){let n=0,r=xc(e);if(!this.inverted)for(let i=0;ie)break;let a=this.ranges[s+o],c=this.ranges[s+l],f=u+a;if(e<=f){let d=a?e==u?-1:e==f?1:n:n,p=u+i+(d<0?0:c);if(r)return p;let h=e==(n<0?u:f)?null:Xg(s/3,e-u),y=e==u?qd:e==f?Qd:xo;return(n<0?e!=u:e!=f)&&(y|=Yd),new Bs(p,y,h)}i+=c-a}return r?e+i:new Bs(e+i,0,null)}touches(e,n){let r=0,i=xc(n),o=this.inverted?2:1,l=this.inverted?1:2;for(let s=0;se)break;let a=this.ranges[s+o],c=u+a;if(e<=c&&s==i*3)return!0;r+=this.ranges[s+l]-a}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&&u!l.isAtom||!s.type.allowsMarkType(this.mark.type)?l:l.mark(this.mark.addToSet(l.marks)),i),n.openStart,n.openEnd);return De.fromReplace(e,this.from,this.to,o)}invert(){return new ji(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 jr(n.pos,r.pos,this.mark)}merge(e){return e instanceof jr&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new jr(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 jr(n.from,n.to,e.markFromJSON(n.mark))}};Fe.jsonID("addMark",Yu);let ji=class Jr extends Fe{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 C(qu(n.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),n.openStart,n.openEnd);return De.fromReplace(e,this.from,this.to,r)}invert(){return new Yu(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 Jr(n.pos,r.pos,this.mark)}merge(e){return e instanceof Jr&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Jr(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 Jr(n.from,n.to,e.markFromJSON(n.mark))}};Fe.jsonID("removeMark",ji);let Gu=class Hr extends Fe{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return De.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return De.fromReplace(e,this.pos,this.pos+1,new C(x.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 Co(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 Co(n.from,n.to,n.gapFrom,n.gapTo,C.fromJSON(e,n.slice),n.insert,!!n.structure)}};Fe.jsonID("replaceAround",Rt);function _s(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 l=r.node(o).maybeChild(r.indexAfter(o));for(;i>0;){if(!l||l.isLeaf)return!0;l=l.firstChild,i--}}return!1}function ey(t,e,n,r){let i=[],o=[],l,s;t.doc.nodesBetween(e,n,(u,a,c)=>{if(!u.isInline)return;let f=u.marks;if(!r.isInSet(f)&&c.type.allowsMarkType(r.type)){let d=Math.max(a,e),p=Math.min(a+u.nodeSize,n),h=r.addToSet(f);for(let y=0;yt.step(u)),o.forEach(u=>t.step(u))}function ty(t,e,n,r){let i=[],o=0;t.doc.nodesBetween(e,n,(l,s)=>{if(!l.isInline)return;o++;let u=null;if(r instanceof vl){let a=l.marks,c;for(;c=r.isInSet(a);)(u||(u=[])).push(c),a=c.removeFromSet(a)}else r?r.isInSet(l.marks)&&(u=[r]):u=l.marks;if(u&&u.length){let a=Math.min(s+l.nodeSize,n);for(let c=0;ct.step(new ji(l.from,l.to,l.style)))}function ny(t,e,n,r=n.contentMatch){let i=t.doc.nodeAt(e),o=[],l=e+1;for(let s=0;s=0;s--)t.step(o[s])}function ry(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function Zu(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),l=t.$to.indexAfter(r);if(rn;h--)y||r.index(h)>0?(y=!0,c=x.from(r.node(h).copy(c)),f++):u--;let d=x.empty,p=0;for(let h=o,y=!1;h>n;h--)y||i.after(h+1)=0;l--){if(r.size){let s=n[l].type.contentMatch.matchFragment(r);if(!s||!s.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=x.from(n[l].type.create(n[l].attrs,r))}let i=e.start,o=e.end;t.step(new Rt(i,o,i,o,new C(r,0,0),n.length,!0))}function ly(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,(l,s)=>{if(l.isTextblock&&!l.hasMarkup(r,i)&&sy(t.doc,t.mapping.slice(o).map(s),r)){t.clearIncompatible(t.mapping.slice(o).map(s,1),r);let u=t.mapping.slice(o),a=u.map(s,1),c=u.map(s+l.nodeSize,1);return t.step(new Rt(a,c,a+1,c-1,new C(x.from(r.create(i,null,l.marks)),0,0),1,!0)),!1}})}function sy(t,e,n){let r=t.resolve(e),i=r.index();return r.parent.canReplaceWith(i,i+1,n)}function uy(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 l=n.create(r,null,i||o.marks);if(o.isLeaf)return t.replaceWith(e,e+o.nodeSize,l);if(!n.validContent(o.content))throw new RangeError("Invalid content for node type "+n.name);t.step(new Rt(e,e+o.nodeSize,e+1,e+o.nodeSize-1,new C(x.from(l),0,0),1,!0))}function Eo(t,e,n=1,r){let i=t.resolve(e),o=i.depth-n,l=r&&r[r.length-1]||i.parent;if(o<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!l.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let a=i.depth-1,c=n-2;a>o;a--,c--){let f=i.node(a),d=i.index(a);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 s=i.indexAfter(o),u=r&&r[0];return i.node(o).canReplaceWith(s,s,u?u.type:i.node(o+1).type)}function ay(t,e,n=1,r){let i=t.doc.resolve(e),o=x.empty,l=x.empty;for(let s=i.depth,u=i.depth-n,a=n-1;s>u;s--,a--){o=x.from(i.node(s).copy(o));let c=r&&r[a];l=x.from(c?c.type.create(c.attrs,l):i.node(s).copy(l))}t.step(new an(e,e,new C(o.append(l),n,n),!0))}function Gd(t,e){let n=t.resolve(e),r=n.index();return cy(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function cy(t,e){return!!(t&&e&&!t.isLeaf&&t.canAppend(e))}function fy(t,e,n){let r=new an(e-n,e+n,C.empty,!0);t.step(r)}function dy(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=x.from(e.node(i).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let a=this.findFittable();a?this.placeNodes(a):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,l=r.depth,s=i.depth;for(;l&&s&&o.childCount==1;)o=o.firstChild.content,l--,s--;let u=new C(o,l,s);return e>-1?new Rt(r.pos,e,this.$to.pos,this.$to.end(),u,n):u.size||r.pos!=this.$to.pos?new an(r.pos,i.pos,u):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=Xl(this.unplaced.content,r-1).firstChild,i=o.content):i=this.unplaced.content;let l=i.firstChild;for(let s=this.depth;s>=0;s--){let{type:u,match:a}=this.frontier[s],c,f=null;if(n==1&&(l?a.matchType(l.type)||(f=a.fillBefore(x.from(l),!1)):o&&u.compatibleContent(o.type)))return{sliceDepth:r,frontierDepth:s,parent:o,inject:f};if(n==2&&l&&(c=a.findWrapping(l.type)))return{sliceDepth:r,frontierDepth:s,parent:o,wrap:c};if(o&&a.matchType(o.type))break}}}openMore(){let{content:e,openStart:n,openEnd:r}=this.unplaced,i=Xl(e,n);return!i.childCount||i.firstChild.isLeaf?!1:(this.unplaced=new C(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=Xl(e,n);if(i.childCount<=1&&n>0){let o=e.size-n<=n+i.size;this.unplaced=new C(Kr(e,n-1,1),n-1,o?n-1:r)}else this.unplaced=new C(Kr(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 y=0;y1||u==0||y.content.size)&&(f=S,c.push(Zd(y.mark(d.allowedMarks(y.marks)),a==1?u:0,a==s.childCount?p:-1)))}let h=a==s.childCount;h||(p=-1),this.placed=Qr(this.placed,n,x.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 y=0,S=s;y1&&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;s--){let{match:u,type:a}=this.frontier[s],c=Zl(e,s,a,u,!0);if(!c||c.childCount)continue e}return{depth:n,fit:l,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=Qr(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=Qr(this.placed,this.depth,x.from(e.create(n,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(x.empty,!0);n.childCount&&(this.placed=Qr(this.placed,this.frontier.length,n))}}function Kr(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(Kr(t.firstChild.content,e-1,n)))}function Qr(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(Qr(t.lastChild.content,e-1,n)))}function Xl(t,e){for(let n=0;n1&&(r=r.replaceChild(0,Zd(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(x.empty,!0)))),t.copy(r)}function Zl(t,e,n,r,i){let o=t.node(e),l=i?t.indexAfter(e):t.index(e);if(l==o.childCount&&!n.compatibleContent(o.type))return null;let s=r.fillBefore(o.content,!0,l);return s&&!py(n,o.content,l)?s:null}function py(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;l.indexOf(d)>-1?s=d:i.before(d)==p&&l.splice(1,0,-d)}let u=l.indexOf(s),a=[],c=r.openStart;for(let d=r.content,p=0;;p++){let h=d.firstChild;if(a.push(h),p==r.openStart)break;d=h.content}for(let d=c-1;d>=0;d--){let p=a[d].type,h=my(p);if(h&&i.node(u).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=a[p];if(h)for(let y=0;y=0&&(t.replace(e,n,r),!(t.steps.length>f));d--){let p=l[d];p<0||(e=i.before(p),n=o.after(p))}}function eh(t,e,n,r,i){if(er){let o=i.contentMatchAt(0),l=o.fillBefore(t).append(t);t=l.append(o.matchFragment(l).fillBefore(x.empty,!0))}return t}function yy(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let i=dy(t.doc,e,r.type);i!=null&&(e=n=i)}t.replaceRange(e,n,new C(x.from(r),0,0))}function ky(t,e,n){let r=t.doc.resolve(e),i=t.doc.resolve(n),o=th(r,i);for(let l=0;l0&&(u||r.node(s-1).canReplace(r.index(s-1),i.indexAfter(s-1))))return t.delete(r.before(s),i.after(s))}for(let l=1;l<=r.depth&&l<=i.depth;l++)if(e-r.start(l)==r.depth-l&&n>r.end(l)&&i.end(l)-n!=i.depth-l)return t.delete(r.before(l),n);t.delete(e,n)}function th(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 nh=class No extends Fe{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 De.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 De.fromReplace(e,this.pos,this.pos+1,new C(x.from(i),0,n.isLeaf?0:1))}getMap(){return yr.empty}invert(e){return new No(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 No(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 No(n.pos,n.attr,n.value)}};Fe.jsonID("attr",nh);let kr=class extends Error{};kr=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};kr.prototype=Object.create(Error.prototype);kr.prototype.constructor=kr;kr.prototype.name="TransformError";class Sy{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 kr(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=C.empty){let i=ea(this.doc,e,n,r);return i&&this.step(i),this}replaceWith(e,n,r){return this.replace(e,n,new C(x.from(r),0,0))}delete(e,n){return this.replace(e,n,C.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,r){return gy(this,e,n,r),this}replaceRangeWith(e,n,r){return yy(this,e,n,r),this}deleteRange(e,n){return ky(this,e,n),this}lift(e,n){return iy(this,e,n),this}join(e,n=1){return fy(this,e,n),this}wrap(e,n){return oy(this,e,n),this}setBlockType(e,n=e,r,i=null){return ly(this,e,n,r,i),this}setNodeMarkup(e,n,r=null,i){return uy(this,e,n,r,i),this}setNodeAttribute(e,n,r){return this.step(new nh(e,n,r)),this}addNodeMark(e,n){return this.step(new Gu(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 Xu(e,n)),this}split(e,n=1,r){return ay(this,e,n,r),this}addMark(e,n,r){return ey(this,e,n,r),this}removeMark(e,n,r){return ty(this,e,n,r),this}clearIncompatible(e,n,r){return ny(this,e,n,r),this}}const es=Object.create(null);class b{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new vy(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 l=n<0?qn(e.node(0),e.node(o),e.before(o+1),e.index(o),n,r):qn(e.node(0),e.node(o),e.after(o+1),e.index(o)+1,n,r);if(l)return l}return null}static near(e,n=1){return this.findFrom(e,n)||this.findFrom(e,-n)||new _e(e.node(0))}static atStart(e){return qn(e,e,0,0,1)||new _e(e)}static atEnd(e){return qn(e,e,e.content.size,e.childCount,-1)||new _e(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=es[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 es)throw new RangeError("Duplicate use of selection JSON ID "+e);return es[e]=n,n.prototype.jsonID=e,n}getBookmark(){return U.between(this.$anchor,this.$head).getBookmark()}}b.prototype.visible=!0;class vy{constructor(e,n){this.$from=e,this.$to=n}}let Cc=!1;function Ec(t){!Cc&&!t.parent.inlineContent&&(Cc=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class U extends b{constructor(e,n=e){Ec(e),Ec(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 b.near(r);let i=e.resolve(n.map(this.anchor));return new U(i.parent.inlineContent?i:r,r)}replace(e,n=C.empty){if(super.replace(e,n),n==C.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof U&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new wl(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 U(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=b.findFrom(n,r,!0)||b.findFrom(n,-r,!0);if(o)n=o.$head;else return b.near(n,r)}return e.parent.inlineContent||(i==0?e=n:(e=(b.findFrom(e,-r,!0)||b.findFrom(e,r,!0)).$anchor,e.pos0?0:1);i>0?l=0;l+=i){let s=e.child(l);if(s.isAtom){if(!o&&A.isSelectable(s))return A.create(t,n-(i<0?s.nodeSize:0))}else{let u=qn(t,s,n+i,i<0?s.childCount:0,i,o);if(u)return u}n+=s.nodeSize*i}return null}function Nc(t,e,n){let r=t.steps.length-1;if(r{l==null&&(l=c)}),t.setSelection(b.near(t.doc.resolve(l),n))}const Oc=1,to=2,Mc=4;class xy extends Sy{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 l=this.doc.resolve(n);o=r==n?l.marks():l.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(n,r,i.text(e,o)),this.selection.empty||this.setSelection(b.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|=Mc,this}get scrolledIntoView(){return(this.updated&Mc)>0}}function Tc(t,e){return!e||!t?t:t.bind(e)}class qr{constructor(e,n,r){this.name=e,this.init=Tc(n.init,r),this.apply=Tc(n.apply,r)}}const Cy=[new qr("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new qr("selection",{init(t,e){return t.selection||b.atStart(e.doc)},apply(t){return t.selection}}),new qr("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new qr("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class ts{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=Cy.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 qr(r.key,r.spec.state,r))})}}class Gn{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 ts(e.schema,e.plugins),o=new Gn(i);return i.fields.forEach(l=>{if(l.name=="doc")o.doc=ht.fromJSON(e.schema,n.doc);else if(l.name=="selection")o.selection=b.fromJSON(o.doc,n.selection);else if(l.name=="storedMarks")n.storedMarks&&(o.storedMarks=n.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let s in r){let u=r[s],a=u.spec.state;if(u.key==l.name&&a&&a.fromJSON&&Object.prototype.hasOwnProperty.call(n,s)){o[l.name]=a.fromJSON.call(u,e,n[s],o);return}}o[l.name]=l.init(e,o)}}),o}}function rh(t,e,n){for(let r in t){let i=t[r];i instanceof Function?i=i.bind(e):r=="handleDOMEvents"&&(i=rh(i,e,{})),n[r]=i}return n}class xl{constructor(e){this.spec=e,this.props={},e.props&&rh(e.props,this,this.props),this.key=e.key?e.key.key:ih("plugin")}getState(e){return e[this.key]}}const ns=Object.create(null);function ih(t){return t in ns?t+"$"+ ++ns[t]:(ns[t]=0,t+"$")}class oh{constructor(e="key"){this.key=ih(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const lh=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function Ey(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}const Ny=(t,e,n)=>{let r=Ey(t,n);if(!r)return!1;let i=sh(r);if(!i){let l=r.blockRange(),s=l&&Zu(l);return s==null?!1:(e&&e(t.tr.lift(l,s).scrollIntoView()),!0)}let o=i.nodeBefore;if(!o.type.spec.isolating&&ah(t,i,e))return!0;if(r.parent.content.size==0&&(Sr(o,"end")||A.isSelectable(o))){let l=ea(t.doc,r.before(),r.after(),C.empty);if(l&&l.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=sh(r)}let l=o&&o.nodeBefore;return!l||!A.isSelectable(l)?!1:(e&&e(t.tr.setSelection(A.create(t.doc,o.pos-l.nodeSize)).scrollIntoView()),!0)};function sh(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 My(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset{let r=My(t,n);if(!r)return!1;let i=uh(r);if(!i)return!1;let o=i.nodeAfter;if(ah(t,i,e))return!0;if(r.parent.content.size==0&&(Sr(o,"start")||A.isSelectable(o))){let l=ea(t.doc,r.before(),r.after(),C.empty);if(l&&l.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 na(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),l=na(i.contentMatchAt(o));if(!l||!i.canReplaceWith(o,o,l))return!1;if(e){let s=n.after(),u=t.tr.replaceWith(s,s,l.createAndFill());u.setSelection(b.near(u.doc.resolve(s),1)),e(u.scrollIntoView())}return!0},zy=(t,e)=>{let n=t.selection,{$from:r,$to:i}=n;if(n instanceof _e||r.parent.inlineContent||i.parent.inlineContent)return!1;let o=na(i.parent.contentMatchAt(i.indexAfter()));if(!o||!o.isTextblock)return!1;if(e){let l=(!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(Eo(t.doc,o))return e&&e(t.tr.split(o).scrollIntoView()),!0}let r=n.blockRange(),i=r&&Zu(r);return i==null?!1:(e&&e(t.tr.lift(r,i).scrollIntoView()),!0)};function Iy(t){return(e,n)=>{let{$from:r,$to:i}=e.selection;if(e.selection instanceof A&&e.selection.node.isBlock)return!r.parentOffset||!Eo(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,l=e.tr;(e.selection instanceof U||e.selection instanceof _e)&&l.deleteSelection();let s=r.depth==0?null:na(r.node(-1).contentMatchAt(r.indexAfter(-1))),u=t&&t(i.parent,o),a=u?[u]:o&&s?[{type:s}]:void 0,c=Eo(l.doc,l.mapping.map(r.pos),1,a);if(!a&&!c&&Eo(l.doc,l.mapping.map(r.pos),1,s?[{type:s}]:void 0)&&(s&&(a=[{type:s}]),c=!0),c&&(l.split(l.mapping.map(r.pos),1,a),!o&&!r.parentOffset&&r.parent.type!=s)){let f=l.mapping.map(r.before()),d=l.doc.resolve(f);s&&r.node(-1).canReplaceWith(d.index(),d.index()+1,s)&&l.setNodeMarkup(l.mapping.map(r.before()),s)}n(l.scrollIntoView())}return!0}}const Fy=Iy(),Ly=(t,e)=>(e&&e(t.tr.setSelection(new _e(t.doc))),!0);function By(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||Gd(t.doc,e.pos))?!1:(n&&n(t.tr.clearIncompatible(e.pos,r.type,r.contentMatchAt(r.childCount)).join(e.pos).scrollIntoView()),!0)}function ah(t,e,n){let r=e.nodeBefore,i=e.nodeAfter,o,l;if(r.type.spec.isolating||i.type.spec.isolating)return!1;if(By(t,e,n))return!0;let s=e.parent.canReplace(e.index(),e.index()+1);if(s&&(o=(l=r.contentMatchAt(r.childCount)).findWrapping(i.type))&&l.matchType(o[0]||i.type).validEnd){if(n){let f=e.pos+i.nodeSize,d=x.empty;for(let y=o.length-1;y>=0;y--)d=x.from(o[y].create(null,d));d=x.from(r.copy(d));let p=t.tr.step(new Rt(e.pos-1,f,e.pos,f,new C(d,1,0),o.length,!0)),h=f+2*o.length;Gd(p.doc,h)&&p.join(h),n(p.scrollIntoView())}return!0}let u=b.findFrom(e,1),a=u&&u.$from.blockRange(u.$to),c=a&&Zu(a);if(c!=null&&c>=e.depth)return n&&n(t.tr.lift(a,c).scrollIntoView()),!0;if(s&&Sr(i,"start",!0)&&Sr(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 y=x.empty;for(let g=d.length-1;g>=0;g--)y=x.from(d[g].copy(y));let S=t.tr.step(new Rt(e.pos-d.length,e.pos+i.nodeSize,e.pos+h,e.pos+i.nodeSize-h,new C(y,d.length,0),0,!0));n(S.scrollIntoView())}return!0}}return!1}function ch(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(U.create(e.doc,t<0?i.start(o):i.end(o)))),!0):!1}}const Vy=ch(-1),_y=ch(1);function by(t,e,n){for(let r=0;r{if(l)return!1;l=s.inlineContent&&s.type.allowsMarkType(n)}),l)return!0}return!1}function Dc(t,e=null){return function(n,r){let{empty:i,$cursor:o,ranges:l}=n.selection;if(i&&!o||!by(n.doc,l,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 s=!1,u=n.tr;for(let a=0;!s&&a",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Pc=typeof navigator<"u"&&/Chrome\/(\d+)/.exec(navigator.userAgent),Uy=typeof navigator<"u"&&/Mac/.test(navigator.platform),jy=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),Jy=Uy||Pc&&+Pc[1]<57;for(var ae=0;ae<10;ae++)on[48+ae]=on[96+ae]=String(ae);for(var ae=1;ae<=24;ae++)on[ae+111]="F"+ae;for(var ae=65;ae<=90;ae++)on[ae]=String.fromCharCode(ae+32),Uo[ae]=String.fromCharCode(ae);for(var is in on)Uo.hasOwnProperty(is)||(Uo[is]=on[is]);function Hy(t){var e=Jy&&(t.ctrlKey||t.altKey||t.metaKey)||jy&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?Uo:on)[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 Ky=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):!1;function Qy(t){let e=t.split(/-(?!$)/),n=e[e.length-1];n=="Space"&&(n=" ");let r,i,o,l;for(let s=0;s127)&&(o=on[r.keyCode])&&o!=i){let s=e[ls(o,r)];if(s&&s(n.state,n.dispatch,n))return!0}}return!1}}var dh={exports:{}},Ue={},hh={exports:{}},ph={};/** +`))}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;e:for(let i=0;i{l.clearMark(s)&&(r=s.addToSet(r))}):n=this.parser.schema.marks[l.mark].create(l.attrs).addToSet(n),l.consuming===!1)o=l;else break}return[n,r]}addElementByRule(e,n,r){let i,o,l;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)):(l=this.parser.schema.marks[n.mark].create(n.attrs),this.addPendingMark(l));let s=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(u=>this.insertNode(u));else{let u=e;typeof n.contentElement=="string"?u=e.querySelector(n.contentElement):typeof n.contentElement=="function"?u=n.contentElement(e):n.contentElement&&(u=n.contentElement),this.findAround(e,u,!0),this.addAll(u)}i&&this.sync(s)&&this.open--,l&&this.removePendingMark(l,s)}addAll(e,n,r){let i=n||0;for(let o=n?e.childNodes[n]:e.firstChild,l=r==null?null:e.childNodes[r];o!=l;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],l=o.findWrapping(e);if(l&&(!n||n.length>l.length)&&(n=l,r=o,!l.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),l=(s,u)=>{for(;s>=0;s--){let a=n[s];if(a==""){if(s==n.length-1||s==0)continue;for(;u>=o;u--)if(l(s-1,u))return!0;return!1}else{let c=u>0||u==0&&i?this.nodes[u].type:r&&u>=o?r.node(u-o).type:null;if(!c||c.name!=a&&c.groups.indexOf(a)==-1)return!1;u--}}return!0};return l(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=Gg(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 l=i.popFromStashMark(e);l&&i.type&&i.type.allowsMarkType(l.type)&&(i.activeMarks=l.addToSet(i.activeMarks))}if(i==n)break}}}function Kg(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&Jd.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function Qg(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function qg(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 wc(t){let e={};for(let n in t)e[n]=t[n];return e}function Yg(t,e){let n=e.schema.nodes;for(let r in n){let i=n[r];if(!i.allowsMarkType(t))continue;let o=[],l=s=>{o.push(s);for(let u=0;u{if(o.length||l.marks.length){let s=0,u=0;for(;s=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&&Ot.renderSpec(Gl(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 l,s=r?e.createElementNS(r,i):e.createElement(i),u=n[1],a=1;if(u&&typeof u=="object"&&u.nodeType==null&&!Array.isArray(u)){a=2;for(let c in u)if(u[c]!=null){let f=c.indexOf(" ");f>0?s.setAttributeNS(c.slice(0,f),c.slice(f+1),u[c]):s.setAttribute(c,u[c])}}for(let c=a;ca)throw new RangeError("Content hole must be the only child of its parent node");return{dom:s,contentDOM:s}}else{let{dom:d,contentDOM:p}=Ot.renderSpec(e,f,r);if(s.appendChild(d),p){if(l)throw new RangeError("Multiple content holes");l=p}}}return{dom:s,contentDOM:l}}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new Ot(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=xc(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return xc(e.marks)}}function xc(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function Gl(t){return t.document||window.document}const Hd=65535,Kd=Math.pow(2,16);function Xg(t,e){return t+e*Kd}function Cc(t){return t&Hd}function Zg(t){return(t-(t&Hd))/Kd}const Qd=1,qd=2,Co=4,Yd=8;let _s=class{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&Yd)>0}get deletedBefore(){return(this.delInfo&(Qd|Co))>0}get deletedAfter(){return(this.delInfo&(qd|Co))>0}get deletedAcross(){return(this.delInfo&Co)>0}},yr=class Qn{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&Qn.empty)return Qn.empty}recover(e){let n=0,r=Cc(e);if(!this.inverted)for(let i=0;ie)break;let a=this.ranges[s+o],c=this.ranges[s+l],f=u+a;if(e<=f){let d=a?e==u?-1:e==f?1:n:n,p=u+i+(d<0?0:c);if(r)return p;let h=e==(n<0?u:f)?null:Xg(s/3,e-u),y=e==u?qd:e==f?Qd:Co;return(n<0?e!=u:e!=f)&&(y|=Yd),new _s(p,y,h)}i+=c-a}return r?e+i:new _s(e+i,0,null)}touches(e,n){let r=0,i=Cc(n),o=this.inverted?2:1,l=this.inverted?1:2;for(let s=0;se)break;let a=this.ranges[s+o],c=u+a;if(e<=c&&s==i*3)return!0;r+=this.ranges[s+l]-a}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 ri;return e.appendMappingInverted(this),e}map(e,n=1){if(this.mirror)return this._map(e,n,!0);for(let r=this.from;ro&&u!l.isAtom||!s.type.allowsMarkType(this.mark.type)?l:l.mark(this.mark.addToSet(l.marks)),i),n.openStart,n.openEnd);return De.fromReplace(e,this.from,this.to,o)}invert(){return new Ji(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 jr(n.pos,r.pos,this.mark)}merge(e){return e instanceof jr&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new jr(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 jr(n.from,n.to,e.markFromJSON(n.mark))}};Le.jsonID("addMark",Gu);let Ji=class Jr extends Le{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 C(Yu(n.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),n.openStart,n.openEnd);return De.fromReplace(e,this.from,this.to,r)}invert(){return new Gu(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 Jr(n.pos,r.pos,this.mark)}merge(e){return e instanceof Jr&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Jr(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 Jr(n.from,n.to,e.markFromJSON(n.mark))}};Le.jsonID("removeMark",Ji);let Xu=class Hr extends Le{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return De.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return De.fromReplace(e,this.pos,this.pos+1,new C(x.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 Eo(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 Eo(n.from,n.to,n.gapFrom,n.gapTo,C.fromJSON(e,n.slice),n.insert,!!n.structure)}};Le.jsonID("replaceAround",Rt);function $s(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 l=r.node(o).maybeChild(r.indexAfter(o));for(;i>0;){if(!l||l.isLeaf)return!0;l=l.firstChild,i--}}return!1}function ey(t,e,n,r){let i=[],o=[],l,s;t.doc.nodesBetween(e,n,(u,a,c)=>{if(!u.isInline)return;let f=u.marks;if(!r.isInSet(f)&&c.type.allowsMarkType(r.type)){let d=Math.max(a,e),p=Math.min(a+u.nodeSize,n),h=r.addToSet(f);for(let y=0;yt.step(u)),o.forEach(u=>t.step(u))}function ty(t,e,n,r){let i=[],o=0;t.doc.nodesBetween(e,n,(l,s)=>{if(!l.isInline)return;o++;let u=null;if(r instanceof wl){let a=l.marks,c;for(;c=r.isInSet(a);)(u||(u=[])).push(c),a=c.removeFromSet(a)}else r?r.isInSet(l.marks)&&(u=[r]):u=l.marks;if(u&&u.length){let a=Math.min(s+l.nodeSize,n);for(let c=0;ct.step(new Ji(l.from,l.to,l.style)))}function ny(t,e,n,r=n.contentMatch){let i=t.doc.nodeAt(e),o=[],l=e+1;for(let s=0;s=0;s--)t.step(o[s])}function ry(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function ea(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),l=t.$to.indexAfter(r);if(rn;h--)y||r.index(h)>0?(y=!0,c=x.from(r.node(h).copy(c)),f++):u--;let d=x.empty,p=0;for(let h=o,y=!1;h>n;h--)y||i.after(h+1)=0;l--){if(r.size){let s=n[l].type.contentMatch.matchFragment(r);if(!s||!s.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=x.from(n[l].type.create(n[l].attrs,r))}let i=e.start,o=e.end;t.step(new Rt(i,o,i,o,new C(r,0,0),n.length,!0))}function ly(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,(l,s)=>{if(l.isTextblock&&!l.hasMarkup(r,i)&&sy(t.doc,t.mapping.slice(o).map(s),r)){t.clearIncompatible(t.mapping.slice(o).map(s,1),r);let u=t.mapping.slice(o),a=u.map(s,1),c=u.map(s+l.nodeSize,1);return t.step(new Rt(a,c,a+1,c-1,new C(x.from(r.create(i,null,l.marks)),0,0),1,!0)),!1}})}function sy(t,e,n){let r=t.resolve(e),i=r.index();return r.parent.canReplaceWith(i,i+1,n)}function uy(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 l=n.create(r,null,i||o.marks);if(o.isLeaf)return t.replaceWith(e,e+o.nodeSize,l);if(!n.validContent(o.content))throw new RangeError("Invalid content for node type "+n.name);t.step(new Rt(e,e+o.nodeSize,e+1,e+o.nodeSize-1,new C(x.from(l),0,0),1,!0))}function No(t,e,n=1,r){let i=t.resolve(e),o=i.depth-n,l=r&&r[r.length-1]||i.parent;if(o<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!l.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let a=i.depth-1,c=n-2;a>o;a--,c--){let f=i.node(a),d=i.index(a);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 s=i.indexAfter(o),u=r&&r[0];return i.node(o).canReplaceWith(s,s,u?u.type:i.node(o+1).type)}function ay(t,e,n=1,r){let i=t.doc.resolve(e),o=x.empty,l=x.empty;for(let s=i.depth,u=i.depth-n,a=n-1;s>u;s--,a--){o=x.from(i.node(s).copy(o));let c=r&&r[a];l=x.from(c?c.type.create(c.attrs,l):i.node(s).copy(l))}t.step(new an(e,e,new C(o.append(l),n,n),!0))}function Gd(t,e){let n=t.resolve(e),r=n.index();return cy(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function cy(t,e){return!!(t&&e&&!t.isLeaf&&t.canAppend(e))}function fy(t,e,n){let r=new an(e-n,e+n,C.empty,!0);t.step(r)}function dy(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=x.from(e.node(i).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let a=this.findFittable();a?this.placeNodes(a):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,l=r.depth,s=i.depth;for(;l&&s&&o.childCount==1;)o=o.firstChild.content,l--,s--;let u=new C(o,l,s);return e>-1?new Rt(r.pos,e,this.$to.pos,this.$to.end(),u,n):u.size||r.pos!=this.$to.pos?new an(r.pos,i.pos,u):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=Zl(this.unplaced.content,r-1).firstChild,i=o.content):i=this.unplaced.content;let l=i.firstChild;for(let s=this.depth;s>=0;s--){let{type:u,match:a}=this.frontier[s],c,f=null;if(n==1&&(l?a.matchType(l.type)||(f=a.fillBefore(x.from(l),!1)):o&&u.compatibleContent(o.type)))return{sliceDepth:r,frontierDepth:s,parent:o,inject:f};if(n==2&&l&&(c=a.findWrapping(l.type)))return{sliceDepth:r,frontierDepth:s,parent:o,wrap:c};if(o&&a.matchType(o.type))break}}}openMore(){let{content:e,openStart:n,openEnd:r}=this.unplaced,i=Zl(e,n);return!i.childCount||i.firstChild.isLeaf?!1:(this.unplaced=new C(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=Zl(e,n);if(i.childCount<=1&&n>0){let o=e.size-n<=n+i.size;this.unplaced=new C(Kr(e,n-1,1),n-1,o?n-1:r)}else this.unplaced=new C(Kr(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 y=0;y1||u==0||y.content.size)&&(f=S,c.push(Zd(y.mark(d.allowedMarks(y.marks)),a==1?u:0,a==s.childCount?p:-1)))}let h=a==s.childCount;h||(p=-1),this.placed=Qr(this.placed,n,x.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 y=0,S=s;y1&&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;s--){let{match:u,type:a}=this.frontier[s],c=es(e,s,a,u,!0);if(!c||c.childCount)continue e}return{depth:n,fit:l,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=Qr(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=Qr(this.placed,this.depth,x.from(e.create(n,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(x.empty,!0);n.childCount&&(this.placed=Qr(this.placed,this.frontier.length,n))}}function Kr(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(Kr(t.firstChild.content,e-1,n)))}function Qr(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(Qr(t.lastChild.content,e-1,n)))}function Zl(t,e){for(let n=0;n1&&(r=r.replaceChild(0,Zd(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(x.empty,!0)))),t.copy(r)}function es(t,e,n,r,i){let o=t.node(e),l=i?t.indexAfter(e):t.index(e);if(l==o.childCount&&!n.compatibleContent(o.type))return null;let s=r.fillBefore(o.content,!0,l);return s&&!py(n,o.content,l)?s:null}function py(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;l.indexOf(d)>-1?s=d:i.before(d)==p&&l.splice(1,0,-d)}let u=l.indexOf(s),a=[],c=r.openStart;for(let d=r.content,p=0;;p++){let h=d.firstChild;if(a.push(h),p==r.openStart)break;d=h.content}for(let d=c-1;d>=0;d--){let p=a[d].type,h=my(p);if(h&&i.node(u).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=a[p];if(h)for(let y=0;y=0&&(t.replace(e,n,r),!(t.steps.length>f));d--){let p=l[d];p<0||(e=i.before(p),n=o.after(p))}}function eh(t,e,n,r,i){if(er){let o=i.contentMatchAt(0),l=o.fillBefore(t).append(t);t=l.append(o.matchFragment(l).fillBefore(x.empty,!0))}return t}function yy(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let i=dy(t.doc,e,r.type);i!=null&&(e=n=i)}t.replaceRange(e,n,new C(x.from(r),0,0))}function ky(t,e,n){let r=t.doc.resolve(e),i=t.doc.resolve(n),o=th(r,i);for(let l=0;l0&&(u||r.node(s-1).canReplace(r.index(s-1),i.indexAfter(s-1))))return t.delete(r.before(s),i.after(s))}for(let l=1;l<=r.depth&&l<=i.depth;l++)if(e-r.start(l)==r.depth-l&&n>r.end(l)&&i.end(l)-n!=i.depth-l)return t.delete(r.before(l),n);t.delete(e,n)}function th(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 nh=class Oo extends Le{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 De.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 De.fromReplace(e,this.pos,this.pos+1,new C(x.from(i),0,n.isLeaf?0:1))}getMap(){return yr.empty}invert(e){return new Oo(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 Oo(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 Oo(n.pos,n.attr,n.value)}};Le.jsonID("attr",nh);let kr=class extends Error{};kr=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};kr.prototype=Object.create(Error.prototype);kr.prototype.constructor=kr;kr.prototype.name="TransformError";class Sy{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new ri}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new kr(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=C.empty){let i=ta(this.doc,e,n,r);return i&&this.step(i),this}replaceWith(e,n,r){return this.replace(e,n,new C(x.from(r),0,0))}delete(e,n){return this.replace(e,n,C.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,r){return gy(this,e,n,r),this}replaceRangeWith(e,n,r){return yy(this,e,n,r),this}deleteRange(e,n){return ky(this,e,n),this}lift(e,n){return iy(this,e,n),this}join(e,n=1){return fy(this,e,n),this}wrap(e,n){return oy(this,e,n),this}setBlockType(e,n=e,r,i=null){return ly(this,e,n,r,i),this}setNodeMarkup(e,n,r=null,i){return uy(this,e,n,r,i),this}setNodeAttribute(e,n,r){return this.step(new nh(e,n,r)),this}addNodeMark(e,n){return this.step(new Xu(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 Zu(e,n)),this}split(e,n=1,r){return ay(this,e,n,r),this}addMark(e,n,r){return ey(this,e,n,r),this}removeMark(e,n,r){return ty(this,e,n,r),this}clearIncompatible(e,n,r){return ny(this,e,n,r),this}}const ts=Object.create(null);class b{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new vy(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 l=n<0?qn(e.node(0),e.node(o),e.before(o+1),e.index(o),n,r):qn(e.node(0),e.node(o),e.after(o+1),e.index(o)+1,n,r);if(l)return l}return null}static near(e,n=1){return this.findFrom(e,n)||this.findFrom(e,-n)||new be(e.node(0))}static atStart(e){return qn(e,e,0,0,1)||new be(e)}static atEnd(e){return qn(e,e,e.content.size,e.childCount,-1)||new be(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=ts[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 ts)throw new RangeError("Duplicate use of selection JSON ID "+e);return ts[e]=n,n.prototype.jsonID=e,n}getBookmark(){return U.between(this.$anchor,this.$head).getBookmark()}}b.prototype.visible=!0;class vy{constructor(e,n){this.$from=e,this.$to=n}}let Ec=!1;function Nc(t){!Ec&&!t.parent.inlineContent&&(Ec=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class U extends b{constructor(e,n=e){Nc(e),Nc(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 b.near(r);let i=e.resolve(n.map(this.anchor));return new U(i.parent.inlineContent?i:r,r)}replace(e,n=C.empty){if(super.replace(e,n),n==C.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof U&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new xl(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 U(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=b.findFrom(n,r,!0)||b.findFrom(n,-r,!0);if(o)n=o.$head;else return b.near(n,r)}return e.parent.inlineContent||(i==0?e=n:(e=(b.findFrom(e,-r,!0)||b.findFrom(e,r,!0)).$anchor,e.pos0?0:1);i>0?l=0;l+=i){let s=e.child(l);if(s.isAtom){if(!o&&A.isSelectable(s))return A.create(t,n-(i<0?s.nodeSize:0))}else{let u=qn(t,s,n+i,i<0?s.childCount:0,i,o);if(u)return u}n+=s.nodeSize*i}return null}function Oc(t,e,n){let r=t.steps.length-1;if(r{l==null&&(l=c)}),t.setSelection(b.near(t.doc.resolve(l),n))}const Mc=1,no=2,Tc=4;class xy extends Sy{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|=no,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&no)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~no,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 l=this.doc.resolve(n);o=r==n?l.marks():l.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(n,r,i.text(e,o)),this.selection.empty||this.setSelection(b.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|=Tc,this}get scrolledIntoView(){return(this.updated&Tc)>0}}function Dc(t,e){return!e||!t?t:t.bind(e)}class qr{constructor(e,n,r){this.name=e,this.init=Dc(n.init,r),this.apply=Dc(n.apply,r)}}const Cy=[new qr("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new qr("selection",{init(t,e){return t.selection||b.atStart(e.doc)},apply(t){return t.selection}}),new qr("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new qr("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class ns{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=Cy.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 qr(r.key,r.spec.state,r))})}}class Gn{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 ns(e.schema,e.plugins),o=new Gn(i);return i.fields.forEach(l=>{if(l.name=="doc")o.doc=ht.fromJSON(e.schema,n.doc);else if(l.name=="selection")o.selection=b.fromJSON(o.doc,n.selection);else if(l.name=="storedMarks")n.storedMarks&&(o.storedMarks=n.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let s in r){let u=r[s],a=u.spec.state;if(u.key==l.name&&a&&a.fromJSON&&Object.prototype.hasOwnProperty.call(n,s)){o[l.name]=a.fromJSON.call(u,e,n[s],o);return}}o[l.name]=l.init(e,o)}}),o}}function rh(t,e,n){for(let r in t){let i=t[r];i instanceof Function?i=i.bind(e):r=="handleDOMEvents"&&(i=rh(i,e,{})),n[r]=i}return n}class Cl{constructor(e){this.spec=e,this.props={},e.props&&rh(e.props,this,this.props),this.key=e.key?e.key.key:ih("plugin")}getState(e){return e[this.key]}}const rs=Object.create(null);function ih(t){return t in rs?t+"$"+ ++rs[t]:(rs[t]=0,t+"$")}class oh{constructor(e="key"){this.key=ih(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const lh=(t,e)=>t.selection.empty?!1:(e&&e(t.tr.deleteSelection().scrollIntoView()),!0);function Ey(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}const Ny=(t,e,n)=>{let r=Ey(t,n);if(!r)return!1;let i=sh(r);if(!i){let l=r.blockRange(),s=l&&ea(l);return s==null?!1:(e&&e(t.tr.lift(l,s).scrollIntoView()),!0)}let o=i.nodeBefore;if(!o.type.spec.isolating&&ah(t,i,e))return!0;if(r.parent.content.size==0&&(Sr(o,"end")||A.isSelectable(o))){let l=ta(t.doc,r.before(),r.after(),C.empty);if(l&&l.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=sh(r)}let l=o&&o.nodeBefore;return!l||!A.isSelectable(l)?!1:(e&&e(t.tr.setSelection(A.create(t.doc,o.pos-l.nodeSize)).scrollIntoView()),!0)};function sh(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 My(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset{let r=My(t,n);if(!r)return!1;let i=uh(r);if(!i)return!1;let o=i.nodeAfter;if(ah(t,i,e))return!0;if(r.parent.content.size==0&&(Sr(o,"start")||A.isSelectable(o))){let l=ta(t.doc,r.before(),r.after(),C.empty);if(l&&l.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 ra(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),l=ra(i.contentMatchAt(o));if(!l||!i.canReplaceWith(o,o,l))return!1;if(e){let s=n.after(),u=t.tr.replaceWith(s,s,l.createAndFill());u.setSelection(b.near(u.doc.resolve(s),1)),e(u.scrollIntoView())}return!0},zy=(t,e)=>{let n=t.selection,{$from:r,$to:i}=n;if(n instanceof be||r.parent.inlineContent||i.parent.inlineContent)return!1;let o=ra(i.parent.contentMatchAt(i.indexAfter()));if(!o||!o.isTextblock)return!1;if(e){let l=(!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(No(t.doc,o))return e&&e(t.tr.split(o).scrollIntoView()),!0}let r=n.blockRange(),i=r&&ea(r);return i==null?!1:(e&&e(t.tr.lift(r,i).scrollIntoView()),!0)};function Iy(t){return(e,n)=>{let{$from:r,$to:i}=e.selection;if(e.selection instanceof A&&e.selection.node.isBlock)return!r.parentOffset||!No(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,l=e.tr;(e.selection instanceof U||e.selection instanceof be)&&l.deleteSelection();let s=r.depth==0?null:ra(r.node(-1).contentMatchAt(r.indexAfter(-1))),u=t&&t(i.parent,o),a=u?[u]:o&&s?[{type:s}]:void 0,c=No(l.doc,l.mapping.map(r.pos),1,a);if(!a&&!c&&No(l.doc,l.mapping.map(r.pos),1,s?[{type:s}]:void 0)&&(s&&(a=[{type:s}]),c=!0),c&&(l.split(l.mapping.map(r.pos),1,a),!o&&!r.parentOffset&&r.parent.type!=s)){let f=l.mapping.map(r.before()),d=l.doc.resolve(f);s&&r.node(-1).canReplaceWith(d.index(),d.index()+1,s)&&l.setNodeMarkup(l.mapping.map(r.before()),s)}n(l.scrollIntoView())}return!0}}const Fy=Iy(),Ly=(t,e)=>(e&&e(t.tr.setSelection(new be(t.doc))),!0);function By(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||Gd(t.doc,e.pos))?!1:(n&&n(t.tr.clearIncompatible(e.pos,r.type,r.contentMatchAt(r.childCount)).join(e.pos).scrollIntoView()),!0)}function ah(t,e,n){let r=e.nodeBefore,i=e.nodeAfter,o,l;if(r.type.spec.isolating||i.type.spec.isolating)return!1;if(By(t,e,n))return!0;let s=e.parent.canReplace(e.index(),e.index()+1);if(s&&(o=(l=r.contentMatchAt(r.childCount)).findWrapping(i.type))&&l.matchType(o[0]||i.type).validEnd){if(n){let f=e.pos+i.nodeSize,d=x.empty;for(let y=o.length-1;y>=0;y--)d=x.from(o[y].create(null,d));d=x.from(r.copy(d));let p=t.tr.step(new Rt(e.pos-1,f,e.pos,f,new C(d,1,0),o.length,!0)),h=f+2*o.length;Gd(p.doc,h)&&p.join(h),n(p.scrollIntoView())}return!0}let u=b.findFrom(e,1),a=u&&u.$from.blockRange(u.$to),c=a&&ea(a);if(c!=null&&c>=e.depth)return n&&n(t.tr.lift(a,c).scrollIntoView()),!0;if(s&&Sr(i,"start",!0)&&Sr(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 y=x.empty;for(let g=d.length-1;g>=0;g--)y=x.from(d[g].copy(y));let S=t.tr.step(new Rt(e.pos-d.length,e.pos+i.nodeSize,e.pos+h,e.pos+i.nodeSize-h,new C(y,d.length,0),0,!0));n(S.scrollIntoView())}return!0}}return!1}function ch(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(U.create(e.doc,t<0?i.start(o):i.end(o)))),!0):!1}}const Vy=ch(-1),_y=ch(1);function by(t,e,n){for(let r=0;r{if(l)return!1;l=s.inlineContent&&s.type.allowsMarkType(n)}),l)return!0}return!1}function Rc(t,e=null){return function(n,r){let{empty:i,$cursor:o,ranges:l}=n.selection;if(i&&!o||!by(n.doc,l,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 s=!1,u=n.tr;for(let a=0;!s&&a",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},zc=typeof navigator<"u"&&/Chrome\/(\d+)/.exec(navigator.userAgent),Uy=typeof navigator<"u"&&/Mac/.test(navigator.platform),jy=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),Jy=Uy||zc&&+zc[1]<57;for(var ae=0;ae<10;ae++)on[48+ae]=on[96+ae]=String(ae);for(var ae=1;ae<=24;ae++)on[ae+111]="F"+ae;for(var ae=65;ae<=90;ae++)on[ae]=String.fromCharCode(ae+32),jo[ae]=String.fromCharCode(ae);for(var ls in on)jo.hasOwnProperty(ls)||(jo[ls]=on[ls]);function Hy(t){var e=Jy&&(t.ctrlKey||t.altKey||t.metaKey)||jy&&t.shiftKey&&t.key&&t.key.length==1||t.key=="Unidentified",n=!e&&t.key||(t.shiftKey?jo:on)[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 Ky=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):!1;function Qy(t){let e=t.split(/-(?!$)/),n=e[e.length-1];n=="Space"&&(n=" ");let r,i,o,l;for(let s=0;s127)&&(o=on[r.keyCode])&&o!=i){let s=e[ss(o,r)];if(s&&s(n.state,n.dispatch,n))return!0}}return!1}}var dh={exports:{}},Ue={},hh={exports:{}},ph={};/** * @license React * scheduler.production.min.js * @@ -26,7 +26,7 @@ * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */(function(t){function e(T,I){var F=T.length;T.push(I);e:for(;0>>1,re=T[G];if(0>>1;Gi(Jl,F))gni(Gi,Jl)?(T[G]=Gi,T[gn]=F,G=gn):(T[G]=Jl,T[mn]=F,G=mn);else if(gni(Gi,F))T[G]=Gi,T[gn]=F,G=gn;else break e}}return I}function i(T,I){var F=T.sortIndex-I.sortIndex;return F!==0?F:T.id-I.id}if(typeof performance=="object"&&typeof performance.now=="function"){var o=performance;t.unstable_now=function(){return o.now()}}else{var l=Date,s=l.now();t.unstable_now=function(){return l.now()-s}}var u=[],a=[],c=1,f=null,d=3,p=!1,h=!1,y=!1,S=typeof setTimeout=="function"?setTimeout:null,g=typeof clearTimeout=="function"?clearTimeout:null,m=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function k(T){for(var I=n(a);I!==null;){if(I.callback===null)r(a);else if(I.startTime<=T)r(a),I.sortIndex=I.expirationTime,e(u,I);else break;I=n(a)}}function v(T){if(y=!1,k(T),!h)if(n(u)!==null)h=!0,Ul(E);else{var I=n(a);I!==null&&jl(v,I.startTime-T)}}function E(T,I){h=!1,y&&(y=!1,g(R),R=-1),p=!0;var F=d;try{for(k(I),f=n(u);f!==null&&(!(f.expirationTime>I)||T&&!de());){var G=f.callback;if(typeof G=="function"){f.callback=null,d=f.priorityLevel;var re=G(f.expirationTime<=I);I=t.unstable_now(),typeof re=="function"?f.callback=re:f===n(u)&&r(u),k(I)}else r(u);f=n(u)}if(f!==null)var Yi=!0;else{var mn=n(a);mn!==null&&jl(v,mn.startTime-I),Yi=!1}return Yi}finally{f=null,d=F,p=!1}}var N=!1,D=null,R=-1,P=5,z=-1;function de(){return!(t.unstable_now()-zT||125G?(T.sortIndex=F,e(a,T),n(u)===null&&T===n(a)&&(y?(g(R),R=-1):y=!0,jl(v,F-G))):(T.sortIndex=re,e(u,T),h||p||(h=!0,Ul(E))),T},t.unstable_shouldYield=de,t.unstable_wrapCallback=function(T){var I=d;return function(){var F=d;d=I;try{return T.apply(this,arguments)}finally{d=F}}}})(ph);hh.exports=ph;var Xy=hh.exports;/** + */(function(t){function e(T,I){var F=T.length;T.push(I);e:for(;0>>1,re=T[G];if(0>>1;Gi(Hl,F))gni(Xi,Hl)?(T[G]=Xi,T[gn]=F,G=gn):(T[G]=Hl,T[mn]=F,G=mn);else if(gni(Xi,F))T[G]=Xi,T[gn]=F,G=gn;else break e}}return I}function i(T,I){var F=T.sortIndex-I.sortIndex;return F!==0?F:T.id-I.id}if(typeof performance=="object"&&typeof performance.now=="function"){var o=performance;t.unstable_now=function(){return o.now()}}else{var l=Date,s=l.now();t.unstable_now=function(){return l.now()-s}}var u=[],a=[],c=1,f=null,d=3,p=!1,h=!1,y=!1,S=typeof setTimeout=="function"?setTimeout:null,g=typeof clearTimeout=="function"?clearTimeout:null,m=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function k(T){for(var I=n(a);I!==null;){if(I.callback===null)r(a);else if(I.startTime<=T)r(a),I.sortIndex=I.expirationTime,e(u,I);else break;I=n(a)}}function v(T){if(y=!1,k(T),!h)if(n(u)!==null)h=!0,jl(E);else{var I=n(a);I!==null&&Jl(v,I.startTime-T)}}function E(T,I){h=!1,y&&(y=!1,g(R),R=-1),p=!0;var F=d;try{for(k(I),f=n(u);f!==null&&(!(f.expirationTime>I)||T&&!de());){var G=f.callback;if(typeof G=="function"){f.callback=null,d=f.priorityLevel;var re=G(f.expirationTime<=I);I=t.unstable_now(),typeof re=="function"?f.callback=re:f===n(u)&&r(u),k(I)}else r(u);f=n(u)}if(f!==null)var Gi=!0;else{var mn=n(a);mn!==null&&Jl(v,mn.startTime-I),Gi=!1}return Gi}finally{f=null,d=F,p=!1}}var N=!1,D=null,R=-1,P=5,z=-1;function de(){return!(t.unstable_now()-zT||125G?(T.sortIndex=F,e(a,T),n(u)===null&&T===n(a)&&(y?(g(R),R=-1):y=!0,Jl(v,F-G))):(T.sortIndex=re,e(u,T),h||p||(h=!0,jl(E))),T},t.unstable_shouldYield=de,t.unstable_wrapCallback=function(T){var I=d;return function(){var F=d;d=I;try{return T.apply(this,arguments)}finally{d=F}}}})(ph);hh.exports=ph;var Xy=hh.exports;/** * @license React * react-dom.production.min.js * @@ -34,19 +34,19 @@ * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. - */var mh=O,We=Xy;function w(t){for(var e="https://reactjs.org/docs/error-decoder.html?invariant="+t,n=1;n"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),bs=Object.prototype.hasOwnProperty,Zy=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,zc={},Ac={};function e0(t){return bs.call(Ac,t)?!0:bs.call(zc,t)?!1:Zy.test(t)?Ac[t]=!0:(zc[t]=!0,!1)}function t0(t,e,n,r){if(n!==null&&n.type===0)return!1;switch(typeof e){case"function":case"symbol":return!0;case"boolean":return r?!1:n!==null?!n.acceptsBooleans:(t=t.toLowerCase().slice(0,5),t!=="data-"&&t!=="aria-");default:return!1}}function n0(t,e,n,r){if(e===null||typeof e>"u"||t0(t,e,n,r))return!0;if(r)return!1;if(n!==null)switch(n.type){case 3:return!e;case 4:return e===!1;case 5:return isNaN(e);case 6:return isNaN(e)||1>e}return!1}function Me(t,e,n,r,i,o,l){this.acceptsBooleans=e===2||e===3||e===4,this.attributeName=r,this.attributeNamespace=i,this.mustUseProperty=n,this.propertyName=t,this.type=e,this.sanitizeURL=o,this.removeEmptyString=l}var fe={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(t){fe[t]=new Me(t,0,!1,t,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(t){var e=t[0];fe[e]=new Me(e,1,!1,t[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(t){fe[t]=new Me(t,2,!1,t.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(t){fe[t]=new Me(t,2,!1,t,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(t){fe[t]=new Me(t,3,!1,t.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(t){fe[t]=new Me(t,3,!0,t,null,!1,!1)});["capture","download"].forEach(function(t){fe[t]=new Me(t,4,!1,t,null,!1,!1)});["cols","rows","size","span"].forEach(function(t){fe[t]=new Me(t,6,!1,t,null,!1,!1)});["rowSpan","start"].forEach(function(t){fe[t]=new Me(t,5,!1,t.toLowerCase(),null,!1,!1)});var ia=/[\-:]([a-z])/g;function oa(t){return t[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(t){var e=t.replace(ia,oa);fe[e]=new Me(e,1,!1,t,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(t){var e=t.replace(ia,oa);fe[e]=new Me(e,1,!1,t,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(t){var e=t.replace(ia,oa);fe[e]=new Me(e,1,!1,t,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(t){fe[t]=new Me(t,1,!1,t.toLowerCase(),null,!1,!1)});fe.xlinkHref=new Me("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(t){fe[t]=new Me(t,1,!1,t.toLowerCase(),null,!0,!0)});function la(t,e,n,r){var i=fe.hasOwnProperty(e)?fe[e]:null;(i!==null?i.type!==0:r||!(2"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Ws=Object.prototype.hasOwnProperty,Zy=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,Ac={},Ic={};function e0(t){return Ws.call(Ic,t)?!0:Ws.call(Ac,t)?!1:Zy.test(t)?Ic[t]=!0:(Ac[t]=!0,!1)}function t0(t,e,n,r){if(n!==null&&n.type===0)return!1;switch(typeof e){case"function":case"symbol":return!0;case"boolean":return r?!1:n!==null?!n.acceptsBooleans:(t=t.toLowerCase().slice(0,5),t!=="data-"&&t!=="aria-");default:return!1}}function n0(t,e,n,r){if(e===null||typeof e>"u"||t0(t,e,n,r))return!0;if(r)return!1;if(n!==null)switch(n.type){case 3:return!e;case 4:return e===!1;case 5:return isNaN(e);case 6:return isNaN(e)||1>e}return!1}function Me(t,e,n,r,i,o,l){this.acceptsBooleans=e===2||e===3||e===4,this.attributeName=r,this.attributeNamespace=i,this.mustUseProperty=n,this.propertyName=t,this.type=e,this.sanitizeURL=o,this.removeEmptyString=l}var fe={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(t){fe[t]=new Me(t,0,!1,t,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(t){var e=t[0];fe[e]=new Me(e,1,!1,t[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(t){fe[t]=new Me(t,2,!1,t.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(t){fe[t]=new Me(t,2,!1,t,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(t){fe[t]=new Me(t,3,!1,t.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(t){fe[t]=new Me(t,3,!0,t,null,!1,!1)});["capture","download"].forEach(function(t){fe[t]=new Me(t,4,!1,t,null,!1,!1)});["cols","rows","size","span"].forEach(function(t){fe[t]=new Me(t,6,!1,t,null,!1,!1)});["rowSpan","start"].forEach(function(t){fe[t]=new Me(t,5,!1,t.toLowerCase(),null,!1,!1)});var oa=/[\-:]([a-z])/g;function la(t){return t[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(t){var e=t.replace(oa,la);fe[e]=new Me(e,1,!1,t,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(t){var e=t.replace(oa,la);fe[e]=new Me(e,1,!1,t,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(t){var e=t.replace(oa,la);fe[e]=new Me(e,1,!1,t,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(t){fe[t]=new Me(t,1,!1,t.toLowerCase(),null,!1,!1)});fe.xlinkHref=new Me("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(t){fe[t]=new Me(t,1,!1,t.toLowerCase(),null,!0,!0)});function sa(t,e,n,r){var i=fe.hasOwnProperty(e)?fe[e]:null;(i!==null?i.type!==0:r||!(2s||i[l]!==o[s]){var u=` -`+i[l].replace(" at new "," at ");return t.displayName&&u.includes("")&&(u=u.replace("",t.displayName)),u}while(1<=l&&0<=s);break}}}finally{us=!1,Error.prepareStackTrace=n}return(t=t?t.displayName||t.name:"")?Yr(t):""}function r0(t){switch(t.tag){case 5:return Yr(t.type);case 16:return Yr("Lazy");case 13:return Yr("Suspense");case 19:return Yr("SuspenseList");case 0:case 2:case 15:return t=as(t.type,!1),t;case 11:return t=as(t.type.render,!1),t;case 1:return t=as(t.type,!0),t;default:return""}}function js(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 Zn:return"Fragment";case Xn:return"Portal";case $s:return"Profiler";case sa:return"StrictMode";case Ws:return"Suspense";case Us:return"SuspenseList"}if(typeof t=="object")switch(t.$$typeof){case kh:return(t.displayName||"Context")+".Consumer";case yh:return(t._context.displayName||"Context")+".Provider";case ua:var e=t.render;return t=t.displayName,t||(t=e.displayName||e.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case aa:return e=t.displayName||null,e!==null?e:js(t.type)||"Memo";case _t:e=t._payload,t=t._init;try{return js(t(e))}catch{}}return null}function i0(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 js(e);case 8:return e===sa?"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 ln(t){switch(typeof t){case"boolean":case"number":case"string":case"undefined":return t;case"object":return t;default:return""}}function vh(t){var e=t.type;return(t=t.nodeName)&&t.toLowerCase()==="input"&&(e==="checkbox"||e==="radio")}function o0(t){var e=vh(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(l){r=""+l,o.call(this,l)}}),Object.defineProperty(t,e,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(l){r=""+l},stopTracking:function(){t._valueTracker=null,delete t[e]}}}}function ro(t){t._valueTracker||(t._valueTracker=o0(t))}function wh(t){if(!t)return!1;var e=t._valueTracker;if(!e)return!0;var n=e.getValue(),r="";return t&&(r=vh(t)?t.checked?"true":"false":t.value),t=r,t!==n?(e.setValue(t),!0):!1}function jo(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 Js(t,e){var n=e.checked;return q({},e,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??t._wrapperState.initialChecked})}function Fc(t,e){var n=e.defaultValue==null?"":e.defaultValue,r=e.checked!=null?e.checked:e.defaultChecked;n=ln(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 xh(t,e){e=e.checked,e!=null&&la(t,"checked",e,!1)}function Hs(t,e){xh(t,e);var n=ln(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")?Ks(t,e.type,n):e.hasOwnProperty("defaultValue")&&Ks(t,e.type,ln(e.defaultValue)),e.checked==null&&e.defaultChecked!=null&&(t.defaultChecked=!!e.defaultChecked)}function Lc(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 Ks(t,e,n){(e!=="number"||jo(t.ownerDocument)!==t)&&(n==null?t.defaultValue=""+t._wrapperState.initialValue:t.defaultValue!==""+n&&(t.defaultValue=""+n))}var Gr=Array.isArray;function cr(t,e,n,r){if(t=t.options,e){e={};for(var i=0;i"+e.valueOf().toString()+"",e=io.firstChild;t.firstChild;)t.removeChild(t.firstChild);for(;e.firstChild;)t.appendChild(e.firstChild)}});function wi(t,e){if(e){var n=t.firstChild;if(n&&n===t.lastChild&&n.nodeType===3){n.nodeValue=e;return}}t.textContent=e}var ri={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},l0=["Webkit","ms","Moz","O"];Object.keys(ri).forEach(function(t){l0.forEach(function(e){e=e+t.charAt(0).toUpperCase()+t.substring(1),ri[e]=ri[t]})});function Oh(t,e,n){return e==null||typeof e=="boolean"||e===""?"":n||typeof e!="number"||e===0||ri.hasOwnProperty(t)&&ri[t]?(""+e).trim():e+"px"}function Mh(t,e){t=t.style;for(var n in e)if(e.hasOwnProperty(n)){var r=n.indexOf("--")===0,i=Oh(n,e[n],r);n==="float"&&(n="cssFloat"),r?t.setProperty(n,i):t[n]=i}}var s0=q({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 Ys(t,e){if(e){if(s0[t]&&(e.children!=null||e.dangerouslySetInnerHTML!=null))throw Error(w(137,t));if(e.dangerouslySetInnerHTML!=null){if(e.children!=null)throw Error(w(60));if(typeof e.dangerouslySetInnerHTML!="object"||!("__html"in e.dangerouslySetInnerHTML))throw Error(w(61))}if(e.style!=null&&typeof e.style!="object")throw Error(w(62))}}function Gs(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 Xs=null;function ca(t){return t=t.target||t.srcElement||window,t.correspondingUseElement&&(t=t.correspondingUseElement),t.nodeType===3?t.parentNode:t}var Zs=null,fr=null,dr=null;function _c(t){if(t=Ki(t)){if(typeof Zs!="function")throw Error(w(280));var e=t.stateNode;e&&(e=Ml(e),Zs(t.stateNode,t.type,e))}}function Th(t){fr?dr?dr.push(t):dr=[t]:fr=t}function Dh(){if(fr){var t=fr,e=dr;if(dr=fr=null,_c(t),e)for(t=0;t>>=0,t===0?32:31-(k0(t)/S0|0)|0}var oo=64,lo=4194304;function Xr(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 Qo(t,e){var n=t.pendingLanes;if(n===0)return 0;var r=0,i=t.suspendedLanes,o=t.pingedLanes,l=n&268435455;if(l!==0){var s=l&~i;s!==0?r=Xr(s):(o&=l,o!==0&&(r=Xr(o)))}else l=n&~i,l!==0?r=Xr(l):o!==0&&(r=Xr(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 Ji(t,e,n){t.pendingLanes|=e,e!==536870912&&(t.suspendedLanes=0,t.pingedLanes=0),t=t.eventTimes,e=31-ot(e),t[e]=n}function C0(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),Qc=String.fromCharCode(32),qc=!1;function qh(t,e){switch(t){case"keyup":return G0.indexOf(e.keyCode)!==-1;case"keydown":return e.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Yh(t){return t=t.detail,typeof t=="object"&&"data"in t?t.data:null}var er=!1;function Z0(t,e){switch(t){case"compositionend":return Yh(e);case"keypress":return e.which!==32?null:(qc=!0,Qc);case"textInput":return t=e.data,t===Qc&&qc?null:t;default:return null}}function e1(t,e){if(er)return t==="compositionend"||!ka&&qh(t,e)?(t=Kh(),Mo=ma=Jt=null,er=!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=Zc(n)}}function ep(t,e){return t&&e?t===e?!0:t&&t.nodeType===3?!1:e&&e.nodeType===3?ep(t,e.parentNode):"contains"in t?t.contains(e):t.compareDocumentPosition?!!(t.compareDocumentPosition(e)&16):!1:!1}function tp(){for(var t=window,e=jo();e instanceof t.HTMLIFrameElement;){try{var n=typeof e.contentWindow.location.href=="string"}catch{n=!1}if(n)t=e.contentWindow;else break;e=jo(t.document)}return e}function Sa(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 a1(t){var e=tp(),n=t.focusedElem,r=t.selectionRange;if(e!==n&&n&&n.ownerDocument&&ep(n.ownerDocument.documentElement,n)){if(r!==null&&Sa(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=ef(n,o);var l=ef(n,r);i&&l&&(t.rangeCount!==1||t.anchorNode!==i.node||t.anchorOffset!==i.offset||t.focusNode!==l.node||t.focusOffset!==l.offset)&&(e=e.createRange(),e.setStart(i.node,i.offset),t.removeAllRanges(),o>r?(t.addRange(e),t.extend(l.node,l.offset)):(e.setEnd(l.node,l.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,tr=null,ou=null,si=null,lu=!1;function tf(t,e,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;lu||tr==null||tr!==jo(r)||(r=tr,"selectionStart"in r&&Sa(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}),si&&Mi(si,r)||(si=r,r=Go(ou,"onSelect"),0ir||(t.current=du[ir],du[ir]=null,ir--)}function W(t,e){ir++,du[ir]=t.current,t.current=e}var sn={},Se=fn(sn),Pe=fn(!1),Bn=sn;function wr(t,e){var n=t.type.contextTypes;if(!n)return sn;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 ze(t){return t=t.childContextTypes,t!=null}function Zo(){J(Pe),J(Se)}function af(t,e,n){if(Se.current!==sn)throw Error(w(168));W(Se,e),W(Pe,n)}function cp(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(w(108,i0(t)||"Unknown",i));return q({},n,r)}function el(t){return t=(t=t.stateNode)&&t.__reactInternalMemoizedMergedChildContext||sn,Bn=Se.current,W(Se,t),W(Pe,Pe.current),!0}function cf(t,e,n){var r=t.stateNode;if(!r)throw Error(w(169));n?(t=cp(t,e,Bn),r.__reactInternalMemoizedMergedChildContext=t,J(Pe),J(Se),W(Se,t)):J(Pe),W(Pe,n)}var Et=null,Tl=!1,Cs=!1;function fp(t){Et===null?Et=[t]:Et.push(t)}function w1(t){Tl=!0,fp(t)}function dn(){if(!Cs&&Et!==null){Cs=!0;var t=0,e=$;try{var n=Et;for($=1;t>=l,i-=l,Ot=1<<32-ot(e)+i|n<R?(P=D,D=null):P=D.sibling;var z=d(g,D,k[R],v);if(z===null){D===null&&(D=P);break}t&&D&&z.alternate===null&&e(g,D),m=o(z,m,R),N===null?E=z:N.sibling=z,N=z,D=P}if(R===k.length)return n(g,D),H&&kn(g,R),E;if(D===null){for(;RR?(P=D,D=null):P=D.sibling;var de=d(g,D,z.value,v);if(de===null){D===null&&(D=P);break}t&&D&&de.alternate===null&&e(g,D),m=o(de,m,R),N===null?E=de:N.sibling=de,N=de,D=P}if(z.done)return n(g,D),H&&kn(g,R),E;if(D===null){for(;!z.done;R++,z=k.next())z=f(g,z.value,v),z!==null&&(m=o(z,m,R),N===null?E=z:N.sibling=z,N=z);return H&&kn(g,R),E}for(D=r(g,D);!z.done;R++,z=k.next())z=p(D,g,R,z.value,v),z!==null&&(t&&z.alternate!==null&&D.delete(z.key===null?R:z.key),m=o(z,m,R),N===null?E=z:N.sibling=z,N=z);return t&&D.forEach(function(pn){return e(g,pn)}),H&&kn(g,R),E}function S(g,m,k,v){if(typeof k=="object"&&k!==null&&k.type===Zn&&k.key===null&&(k=k.props.children),typeof k=="object"&&k!==null){switch(k.$$typeof){case no:e:{for(var E=k.key,N=m;N!==null;){if(N.key===E){if(E=k.type,E===Zn){if(N.tag===7){n(g,N.sibling),m=i(N,k.props.children),m.return=g,g=m;break e}}else if(N.elementType===E||typeof E=="object"&&E!==null&&E.$$typeof===_t&&yf(E)===N.type){n(g,N.sibling),m=i(N,k.props),m.ref=_r(g,N,k),m.return=g,g=m;break e}n(g,N);break}else e(g,N);N=N.sibling}k.type===Zn?(m=An(k.props.children,g.mode,v,k.key),m.return=g,g=m):(v=Fo(k.type,k.key,k.props,null,g.mode,v),v.ref=_r(g,m,k),v.return=g,g=v)}return l(g);case Xn:e:{for(N=k.key;m!==null;){if(m.key===N)if(m.tag===4&&m.stateNode.containerInfo===k.containerInfo&&m.stateNode.implementation===k.implementation){n(g,m.sibling),m=i(m,k.children||[]),m.return=g,g=m;break e}else{n(g,m);break}else e(g,m);m=m.sibling}m=Ps(k,g.mode,v),m.return=g,g=m}return l(g);case _t:return N=k._init,S(g,m,N(k._payload),v)}if(Gr(k))return h(g,m,k,v);if(Ir(k))return y(g,m,k,v);po(g,k)}return typeof k=="string"&&k!==""||typeof k=="number"?(k=""+k,m!==null&&m.tag===6?(n(g,m.sibling),m=i(m,k),m.return=g,g=m):(n(g,m),m=Rs(k,g.mode,v),m.return=g,g=m),l(g)):n(g,m)}return S}var Cr=Sp(!0),vp=Sp(!1),Qi={},mt=fn(Qi),Pi=fn(Qi),zi=fn(Qi);function En(t){if(t===Qi)throw Error(w(174));return t}function Ta(t,e){switch(W(zi,e),W(Pi,t),W(mt,Qi),t=e.nodeType,t){case 9:case 11:e=(e=e.documentElement)?e.namespaceURI:qs(null,"");break;default:t=t===8?e.parentNode:e,e=t.namespaceURI||null,t=t.tagName,e=qs(e,t)}J(mt),W(mt,e)}function Er(){J(mt),J(Pi),J(zi)}function wp(t){En(zi.current);var e=En(mt.current),n=qs(e,t.type);e!==n&&(W(Pi,t),W(mt,n))}function Da(t){Pi.current===t&&(J(mt),J(Pi))}var K=fn(0);function ll(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 Es=[];function Ra(){for(var t=0;tn?n:4,t(!0);var r=Ns.transition;Ns.transition={};try{t(!1),e()}finally{$=n,Ns.transition=r}}function Bp(){return Ze().memoizedState}function N1(t,e,n){var r=en(t);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},Vp(t))_p(e,n);else if(n=mp(t,e,n,r),n!==null){var i=xe();lt(n,t,r,i),bp(n,e,r)}}function O1(t,e,n){var r=en(t),i={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(Vp(t))_p(e,i);else{var o=t.alternate;if(t.lanes===0&&(o===null||o.lanes===0)&&(o=e.lastRenderedReducer,o!==null))try{var l=e.lastRenderedState,s=o(l,n);if(i.hasEagerState=!0,i.eagerState=s,st(s,l)){var u=e.interleaved;u===null?(i.next=i,Oa(e)):(i.next=u.next,u.next=i),e.interleaved=i;return}}catch{}finally{}n=mp(t,e,i,r),n!==null&&(i=xe(),lt(n,t,r,i),bp(n,e,r))}}function Vp(t){var e=t.alternate;return t===Q||e!==null&&e===Q}function _p(t,e){ui=sl=!0;var n=t.pending;n===null?e.next=e:(e.next=n.next,n.next=e),t.pending=e}function bp(t,e,n){if(n&4194240){var r=e.lanes;r&=t.pendingLanes,n|=r,e.lanes=n,da(t,n)}}var ul={readContext:Xe,useCallback:he,useContext:he,useEffect:he,useImperativeHandle:he,useInsertionEffect:he,useLayoutEffect:he,useMemo:he,useReducer:he,useRef:he,useState:he,useDebugValue:he,useDeferredValue:he,useTransition:he,useMutableSource:he,useSyncExternalStore:he,useId:he,unstable_isNewReconciler:!1},M1={readContext:Xe,useCallback:function(t,e){return ct().memoizedState=[t,e===void 0?null:e],t},useContext:Xe,useEffect:Sf,useImperativeHandle:function(t,e,n){return n=n!=null?n.concat([t]):null,Po(4194308,4,zp.bind(null,e,t),n)},useLayoutEffect:function(t,e){return Po(4194308,4,t,e)},useInsertionEffect:function(t,e){return Po(4,2,t,e)},useMemo:function(t,e){var n=ct();return e=e===void 0?null:e,t=t(),n.memoizedState=[t,e],t},useReducer:function(t,e,n){var r=ct();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=N1.bind(null,Q,t),[r.memoizedState,t]},useRef:function(t){var e=ct();return t={current:t},e.memoizedState=t},useState:kf,useDebugValue:Fa,useDeferredValue:function(t){return ct().memoizedState=t},useTransition:function(){var t=kf(!1),e=t[0];return t=E1.bind(null,t[1]),ct().memoizedState=t,[e,t]},useMutableSource:function(){},useSyncExternalStore:function(t,e,n){var r=Q,i=ct();if(H){if(n===void 0)throw Error(w(407));n=n()}else{if(n=e(),oe===null)throw Error(w(349));_n&30||Ep(r,e,n)}i.memoizedState=n;var o={value:n,getSnapshot:e};return i.queue=o,Sf(Op.bind(null,r,o,t),[t]),r.flags|=2048,Fi(9,Np.bind(null,r,o,n,e),void 0,null),n},useId:function(){var t=ct(),e=oe.identifierPrefix;if(H){var n=Mt,r=Ot;n=(r&~(1<<32-ot(r)-1)).toString(32)+n,e=":"+e+"R"+n,n=Ai++,0")&&(u=u.replace("",t.displayName)),u}while(1<=l&&0<=s);break}}}finally{as=!1,Error.prepareStackTrace=n}return(t=t?t.displayName||t.name:"")?Yr(t):""}function r0(t){switch(t.tag){case 5:return Yr(t.type);case 16:return Yr("Lazy");case 13:return Yr("Suspense");case 19:return Yr("SuspenseList");case 0:case 2:case 15:return t=cs(t.type,!1),t;case 11:return t=cs(t.type.render,!1),t;case 1:return t=cs(t.type,!0),t;default:return""}}function Hs(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 Zn:return"Fragment";case Xn:return"Portal";case Us:return"Profiler";case ua:return"StrictMode";case js:return"Suspense";case Js:return"SuspenseList"}if(typeof t=="object")switch(t.$$typeof){case kh:return(t.displayName||"Context")+".Consumer";case yh:return(t._context.displayName||"Context")+".Provider";case aa:var e=t.render;return t=t.displayName,t||(t=e.displayName||e.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case ca:return e=t.displayName||null,e!==null?e:Hs(t.type)||"Memo";case _t:e=t._payload,t=t._init;try{return Hs(t(e))}catch{}}return null}function i0(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 Hs(e);case 8:return e===ua?"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 ln(t){switch(typeof t){case"boolean":case"number":case"string":case"undefined":return t;case"object":return t;default:return""}}function vh(t){var e=t.type;return(t=t.nodeName)&&t.toLowerCase()==="input"&&(e==="checkbox"||e==="radio")}function o0(t){var e=vh(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(l){r=""+l,o.call(this,l)}}),Object.defineProperty(t,e,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(l){r=""+l},stopTracking:function(){t._valueTracker=null,delete t[e]}}}}function io(t){t._valueTracker||(t._valueTracker=o0(t))}function wh(t){if(!t)return!1;var e=t._valueTracker;if(!e)return!0;var n=e.getValue(),r="";return t&&(r=vh(t)?t.checked?"true":"false":t.value),t=r,t!==n?(e.setValue(t),!0):!1}function Jo(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 Ks(t,e){var n=e.checked;return q({},e,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??t._wrapperState.initialChecked})}function Lc(t,e){var n=e.defaultValue==null?"":e.defaultValue,r=e.checked!=null?e.checked:e.defaultChecked;n=ln(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 xh(t,e){e=e.checked,e!=null&&sa(t,"checked",e,!1)}function Qs(t,e){xh(t,e);var n=ln(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")?qs(t,e.type,n):e.hasOwnProperty("defaultValue")&&qs(t,e.type,ln(e.defaultValue)),e.checked==null&&e.defaultChecked!=null&&(t.defaultChecked=!!e.defaultChecked)}function Bc(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 qs(t,e,n){(e!=="number"||Jo(t.ownerDocument)!==t)&&(n==null?t.defaultValue=""+t._wrapperState.initialValue:t.defaultValue!==""+n&&(t.defaultValue=""+n))}var Gr=Array.isArray;function cr(t,e,n,r){if(t=t.options,e){e={};for(var i=0;i"+e.valueOf().toString()+"",e=oo.firstChild;t.firstChild;)t.removeChild(t.firstChild);for(;e.firstChild;)t.appendChild(e.firstChild)}});function xi(t,e){if(e){var n=t.firstChild;if(n&&n===t.lastChild&&n.nodeType===3){n.nodeValue=e;return}}t.textContent=e}var ii={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},l0=["Webkit","ms","Moz","O"];Object.keys(ii).forEach(function(t){l0.forEach(function(e){e=e+t.charAt(0).toUpperCase()+t.substring(1),ii[e]=ii[t]})});function Oh(t,e,n){return e==null||typeof e=="boolean"||e===""?"":n||typeof e!="number"||e===0||ii.hasOwnProperty(t)&&ii[t]?(""+e).trim():e+"px"}function Mh(t,e){t=t.style;for(var n in e)if(e.hasOwnProperty(n)){var r=n.indexOf("--")===0,i=Oh(n,e[n],r);n==="float"&&(n="cssFloat"),r?t.setProperty(n,i):t[n]=i}}var s0=q({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 Xs(t,e){if(e){if(s0[t]&&(e.children!=null||e.dangerouslySetInnerHTML!=null))throw Error(w(137,t));if(e.dangerouslySetInnerHTML!=null){if(e.children!=null)throw Error(w(60));if(typeof e.dangerouslySetInnerHTML!="object"||!("__html"in e.dangerouslySetInnerHTML))throw Error(w(61))}if(e.style!=null&&typeof e.style!="object")throw Error(w(62))}}function Zs(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 eu=null;function fa(t){return t=t.target||t.srcElement||window,t.correspondingUseElement&&(t=t.correspondingUseElement),t.nodeType===3?t.parentNode:t}var tu=null,fr=null,dr=null;function bc(t){if(t=Qi(t)){if(typeof tu!="function")throw Error(w(280));var e=t.stateNode;e&&(e=Tl(e),tu(t.stateNode,t.type,e))}}function Th(t){fr?dr?dr.push(t):dr=[t]:fr=t}function Dh(){if(fr){var t=fr,e=dr;if(dr=fr=null,bc(t),e)for(t=0;t>>=0,t===0?32:31-(k0(t)/S0|0)|0}var lo=64,so=4194304;function Xr(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 qo(t,e){var n=t.pendingLanes;if(n===0)return 0;var r=0,i=t.suspendedLanes,o=t.pingedLanes,l=n&268435455;if(l!==0){var s=l&~i;s!==0?r=Xr(s):(o&=l,o!==0&&(r=Xr(o)))}else l=n&~i,l!==0?r=Xr(l):o!==0&&(r=Xr(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 Hi(t,e,n){t.pendingLanes|=e,e!==536870912&&(t.suspendedLanes=0,t.pingedLanes=0),t=t.eventTimes,e=31-ot(e),t[e]=n}function C0(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=li),qc=String.fromCharCode(32),Yc=!1;function qh(t,e){switch(t){case"keyup":return G0.indexOf(e.keyCode)!==-1;case"keydown":return e.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Yh(t){return t=t.detail,typeof t=="object"&&"data"in t?t.data:null}var er=!1;function Z0(t,e){switch(t){case"compositionend":return Yh(e);case"keypress":return e.which!==32?null:(Yc=!0,qc);case"textInput":return t=e.data,t===qc&&Yc?null:t;default:return null}}function e1(t,e){if(er)return t==="compositionend"||!Sa&&qh(t,e)?(t=Kh(),To=ga=Jt=null,er=!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=ef(n)}}function ep(t,e){return t&&e?t===e?!0:t&&t.nodeType===3?!1:e&&e.nodeType===3?ep(t,e.parentNode):"contains"in t?t.contains(e):t.compareDocumentPosition?!!(t.compareDocumentPosition(e)&16):!1:!1}function tp(){for(var t=window,e=Jo();e instanceof t.HTMLIFrameElement;){try{var n=typeof e.contentWindow.location.href=="string"}catch{n=!1}if(n)t=e.contentWindow;else break;e=Jo(t.document)}return e}function va(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 a1(t){var e=tp(),n=t.focusedElem,r=t.selectionRange;if(e!==n&&n&&n.ownerDocument&&ep(n.ownerDocument.documentElement,n)){if(r!==null&&va(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=tf(n,o);var l=tf(n,r);i&&l&&(t.rangeCount!==1||t.anchorNode!==i.node||t.anchorOffset!==i.offset||t.focusNode!==l.node||t.focusOffset!==l.offset)&&(e=e.createRange(),e.setStart(i.node,i.offset),t.removeAllRanges(),o>r?(t.addRange(e),t.extend(l.node,l.offset)):(e.setEnd(l.node,l.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,tr=null,su=null,ui=null,uu=!1;function nf(t,e,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;uu||tr==null||tr!==Jo(r)||(r=tr,"selectionStart"in r&&va(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}),ui&&Ti(ui,r)||(ui=r,r=Xo(su,"onSelect"),0ir||(t.current=pu[ir],pu[ir]=null,ir--)}function W(t,e){ir++,pu[ir]=t.current,t.current=e}var sn={},Se=fn(sn),Pe=fn(!1),Bn=sn;function wr(t,e){var n=t.type.contextTypes;if(!n)return sn;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 ze(t){return t=t.childContextTypes,t!=null}function el(){J(Pe),J(Se)}function cf(t,e,n){if(Se.current!==sn)throw Error(w(168));W(Se,e),W(Pe,n)}function cp(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(w(108,i0(t)||"Unknown",i));return q({},n,r)}function tl(t){return t=(t=t.stateNode)&&t.__reactInternalMemoizedMergedChildContext||sn,Bn=Se.current,W(Se,t),W(Pe,Pe.current),!0}function ff(t,e,n){var r=t.stateNode;if(!r)throw Error(w(169));n?(t=cp(t,e,Bn),r.__reactInternalMemoizedMergedChildContext=t,J(Pe),J(Se),W(Se,t)):J(Pe),W(Pe,n)}var Nt=null,Dl=!1,Es=!1;function fp(t){Nt===null?Nt=[t]:Nt.push(t)}function w1(t){Dl=!0,fp(t)}function dn(){if(!Es&&Nt!==null){Es=!0;var t=0,e=$;try{var n=Nt;for($=1;t>=l,i-=l,Mt=1<<32-ot(e)+i|n<R?(P=D,D=null):P=D.sibling;var z=d(g,D,k[R],v);if(z===null){D===null&&(D=P);break}t&&D&&z.alternate===null&&e(g,D),m=o(z,m,R),N===null?E=z:N.sibling=z,N=z,D=P}if(R===k.length)return n(g,D),H&&kn(g,R),E;if(D===null){for(;RR?(P=D,D=null):P=D.sibling;var de=d(g,D,z.value,v);if(de===null){D===null&&(D=P);break}t&&D&&de.alternate===null&&e(g,D),m=o(de,m,R),N===null?E=de:N.sibling=de,N=de,D=P}if(z.done)return n(g,D),H&&kn(g,R),E;if(D===null){for(;!z.done;R++,z=k.next())z=f(g,z.value,v),z!==null&&(m=o(z,m,R),N===null?E=z:N.sibling=z,N=z);return H&&kn(g,R),E}for(D=r(g,D);!z.done;R++,z=k.next())z=p(D,g,R,z.value,v),z!==null&&(t&&z.alternate!==null&&D.delete(z.key===null?R:z.key),m=o(z,m,R),N===null?E=z:N.sibling=z,N=z);return t&&D.forEach(function(pn){return e(g,pn)}),H&&kn(g,R),E}function S(g,m,k,v){if(typeof k=="object"&&k!==null&&k.type===Zn&&k.key===null&&(k=k.props.children),typeof k=="object"&&k!==null){switch(k.$$typeof){case ro:e:{for(var E=k.key,N=m;N!==null;){if(N.key===E){if(E=k.type,E===Zn){if(N.tag===7){n(g,N.sibling),m=i(N,k.props.children),m.return=g,g=m;break e}}else if(N.elementType===E||typeof E=="object"&&E!==null&&E.$$typeof===_t&&kf(E)===N.type){n(g,N.sibling),m=i(N,k.props),m.ref=_r(g,N,k),m.return=g,g=m;break e}n(g,N);break}else e(g,N);N=N.sibling}k.type===Zn?(m=An(k.props.children,g.mode,v,k.key),m.return=g,g=m):(v=Lo(k.type,k.key,k.props,null,g.mode,v),v.ref=_r(g,m,k),v.return=g,g=v)}return l(g);case Xn:e:{for(N=k.key;m!==null;){if(m.key===N)if(m.tag===4&&m.stateNode.containerInfo===k.containerInfo&&m.stateNode.implementation===k.implementation){n(g,m.sibling),m=i(m,k.children||[]),m.return=g,g=m;break e}else{n(g,m);break}else e(g,m);m=m.sibling}m=zs(k,g.mode,v),m.return=g,g=m}return l(g);case _t:return N=k._init,S(g,m,N(k._payload),v)}if(Gr(k))return h(g,m,k,v);if(Ir(k))return y(g,m,k,v);mo(g,k)}return typeof k=="string"&&k!==""||typeof k=="number"?(k=""+k,m!==null&&m.tag===6?(n(g,m.sibling),m=i(m,k),m.return=g,g=m):(n(g,m),m=Ps(k,g.mode,v),m.return=g,g=m),l(g)):n(g,m)}return S}var Cr=Sp(!0),vp=Sp(!1),qi={},mt=fn(qi),zi=fn(qi),Ai=fn(qi);function En(t){if(t===qi)throw Error(w(174));return t}function Da(t,e){switch(W(Ai,e),W(zi,t),W(mt,qi),t=e.nodeType,t){case 9:case 11:e=(e=e.documentElement)?e.namespaceURI:Gs(null,"");break;default:t=t===8?e.parentNode:e,e=t.namespaceURI||null,t=t.tagName,e=Gs(e,t)}J(mt),W(mt,e)}function Er(){J(mt),J(zi),J(Ai)}function wp(t){En(Ai.current);var e=En(mt.current),n=Gs(e,t.type);e!==n&&(W(zi,t),W(mt,n))}function Ra(t){zi.current===t&&(J(mt),J(zi))}var K=fn(0);function sl(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 Ns=[];function Pa(){for(var t=0;tn?n:4,t(!0);var r=Os.transition;Os.transition={};try{t(!1),e()}finally{$=n,Os.transition=r}}function Bp(){return Ze().memoizedState}function N1(t,e,n){var r=en(t);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},Vp(t))_p(e,n);else if(n=mp(t,e,n,r),n!==null){var i=xe();lt(n,t,r,i),bp(n,e,r)}}function O1(t,e,n){var r=en(t),i={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(Vp(t))_p(e,i);else{var o=t.alternate;if(t.lanes===0&&(o===null||o.lanes===0)&&(o=e.lastRenderedReducer,o!==null))try{var l=e.lastRenderedState,s=o(l,n);if(i.hasEagerState=!0,i.eagerState=s,st(s,l)){var u=e.interleaved;u===null?(i.next=i,Ma(e)):(i.next=u.next,u.next=i),e.interleaved=i;return}}catch{}finally{}n=mp(t,e,i,r),n!==null&&(i=xe(),lt(n,t,r,i),bp(n,e,r))}}function Vp(t){var e=t.alternate;return t===Q||e!==null&&e===Q}function _p(t,e){ai=ul=!0;var n=t.pending;n===null?e.next=e:(e.next=n.next,n.next=e),t.pending=e}function bp(t,e,n){if(n&4194240){var r=e.lanes;r&=t.pendingLanes,n|=r,e.lanes=n,ha(t,n)}}var al={readContext:Xe,useCallback:he,useContext:he,useEffect:he,useImperativeHandle:he,useInsertionEffect:he,useLayoutEffect:he,useMemo:he,useReducer:he,useRef:he,useState:he,useDebugValue:he,useDeferredValue:he,useTransition:he,useMutableSource:he,useSyncExternalStore:he,useId:he,unstable_isNewReconciler:!1},M1={readContext:Xe,useCallback:function(t,e){return ct().memoizedState=[t,e===void 0?null:e],t},useContext:Xe,useEffect:vf,useImperativeHandle:function(t,e,n){return n=n!=null?n.concat([t]):null,zo(4194308,4,zp.bind(null,e,t),n)},useLayoutEffect:function(t,e){return zo(4194308,4,t,e)},useInsertionEffect:function(t,e){return zo(4,2,t,e)},useMemo:function(t,e){var n=ct();return e=e===void 0?null:e,t=t(),n.memoizedState=[t,e],t},useReducer:function(t,e,n){var r=ct();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=N1.bind(null,Q,t),[r.memoizedState,t]},useRef:function(t){var e=ct();return t={current:t},e.memoizedState=t},useState:Sf,useDebugValue:La,useDeferredValue:function(t){return ct().memoizedState=t},useTransition:function(){var t=Sf(!1),e=t[0];return t=E1.bind(null,t[1]),ct().memoizedState=t,[e,t]},useMutableSource:function(){},useSyncExternalStore:function(t,e,n){var r=Q,i=ct();if(H){if(n===void 0)throw Error(w(407));n=n()}else{if(n=e(),oe===null)throw Error(w(349));_n&30||Ep(r,e,n)}i.memoizedState=n;var o={value:n,getSnapshot:e};return i.queue=o,vf(Op.bind(null,r,o,t),[t]),r.flags|=2048,Li(9,Np.bind(null,r,o,n,e),void 0,null),n},useId:function(){var t=ct(),e=oe.identifierPrefix;if(H){var n=Tt,r=Mt;n=(r&~(1<<32-ot(r)-1)).toString(32)+n,e=":"+e+"R"+n,n=Ii++,0<\/script>",t=t.removeChild(t.firstChild)):typeof r.is=="string"?t=l.createElement(n,{is:r.is}):(t=l.createElement(n),n==="select"&&(l=t,r.multiple?l.multiple=!0:r.size&&(l.size=r.size))):t=l.createElementNS(t,n),t[ft]=e,t[Ri]=r,qp(t,e,!1,!1),e.stateNode=t;e:{switch(l=Gs(n,r),n){case"dialog":j("cancel",t),j("close",t),i=r;break;case"iframe":case"object":case"embed":j("load",t),i=r;break;case"video":case"audio":for(i=0;iOr&&(e.flags|=128,r=!0,br(o,!1),e.lanes=4194304)}else{if(!r)if(t=ll(l),t!==null){if(e.flags|=128,r=!0,n=t.updateQueue,n!==null&&(e.updateQueue=n,e.flags|=4),br(o,!0),o.tail===null&&o.tailMode==="hidden"&&!l.alternate&&!H)return pe(e),null}else 2*X()-o.renderingStartTime>Or&&n!==1073741824&&(e.flags|=128,r=!0,br(o,!1),e.lanes=4194304);o.isBackwards?(l.sibling=e.child,e.child=l):(n=o.last,n!==null?n.sibling=l:e.child=l,o.last=l)}return o.tail!==null?(e=o.tail,o.rendering=e,o.tail=e.sibling,o.renderingStartTime=X(),e.sibling=null,n=K.current,W(K,r?n&1|2:n&1),e):(pe(e),null);case 22:case 23:return $a(),r=e.memoizedState!==null,t!==null&&t.memoizedState!==null!==r&&(e.flags|=8192),r&&e.mode&1?Be&1073741824&&(pe(e),e.subtreeFlags&6&&(e.flags|=8192)):pe(e),null;case 24:return null;case 25:return null}throw Error(w(156,e.tag))}function F1(t,e){switch(wa(e),e.tag){case 1:return ze(e.type)&&Zo(),t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 3:return Er(),J(Pe),J(Se),Ra(),t=e.flags,t&65536&&!(t&128)?(e.flags=t&-65537|128,e):null;case 5:return Da(e),null;case 13:if(J(K),t=e.memoizedState,t!==null&&t.dehydrated!==null){if(e.alternate===null)throw Error(w(340));xr()}return t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 19:return J(K),null;case 4:return Er(),null;case 10:return Na(e.type._context),null;case 22:case 23:return $a(),null;case 24:return null;default:return null}}var go=!1,ge=!1,L1=typeof WeakSet=="function"?WeakSet:Set,M=null;function ur(t,e){var n=t.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){Y(t,e,r)}else n.current=null}function Eu(t,e,n){try{n()}catch(r){Y(t,e,r)}}var Tf=!1;function B1(t,e){if(su=qo,t=tp(),Sa(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 l=0,s=-1,u=-1,a=0,c=0,f=t,d=null;t:for(;;){for(var p;f!==n||i!==0&&f.nodeType!==3||(s=l+i),f!==o||r!==0&&f.nodeType!==3||(u=l+r),f.nodeType===3&&(l+=f.nodeValue.length),(p=f.firstChild)!==null;)d=f,f=p;for(;;){if(f===t)break t;if(d===n&&++a===i&&(s=l),d===o&&++c===r&&(u=l),(p=f.nextSibling)!==null)break;f=d,d=f.parentNode}f=p}n=s===-1||u===-1?null:{start:s,end:u}}else n=null}n=n||{start:0,end:0}}else n=null;for(uu={focusedElem:t,selectionRange:n},qo=!1,M=e;M!==null;)if(e=M,t=e.child,(e.subtreeFlags&1028)!==0&&t!==null)t.return=e,M=t;else for(;M!==null;){e=M;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 y=h.memoizedProps,S=h.memoizedState,g=e.stateNode,m=g.getSnapshotBeforeUpdate(e.elementType===e.type?y:tt(e.type,y),S);g.__reactInternalSnapshotBeforeUpdate=m}break;case 3:var k=e.stateNode.containerInfo;k.nodeType===1?k.textContent="":k.nodeType===9&&k.documentElement&&k.removeChild(k.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(w(163))}}catch(v){Y(e,e.return,v)}if(t=e.sibling,t!==null){t.return=e.return,M=t;break}M=e.return}return h=Tf,Tf=!1,h}function ai(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&&Eu(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 Nu(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 Xp(t){var e=t.alternate;e!==null&&(t.alternate=null,Xp(e)),t.child=null,t.deletions=null,t.sibling=null,t.tag===5&&(e=t.stateNode,e!==null&&(delete e[ft],delete e[Ri],delete e[fu],delete e[S1],delete e[v1])),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 Zp(t){return t.tag===5||t.tag===3||t.tag===4}function Df(t){e:for(;;){for(;t.sibling===null;){if(t.return===null||Zp(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 Ou(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=Xo));else if(r!==4&&(t=t.child,t!==null))for(Ou(t,e,n),t=t.sibling;t!==null;)Ou(t,e,n),t=t.sibling}function Mu(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(Mu(t,e,n),t=t.sibling;t!==null;)Mu(t,e,n),t=t.sibling}var ue=null,nt=!1;function Bt(t,e,n){for(n=n.child;n!==null;)em(t,e,n),n=n.sibling}function em(t,e,n){if(pt&&typeof pt.onCommitFiberUnmount=="function")try{pt.onCommitFiberUnmount(Cl,n)}catch{}switch(n.tag){case 5:ge||ur(n,e);case 6:var r=ue,i=nt;ue=null,Bt(t,e,n),ue=r,nt=i,ue!==null&&(nt?(t=ue,n=n.stateNode,t.nodeType===8?t.parentNode.removeChild(n):t.removeChild(n)):ue.removeChild(n.stateNode));break;case 18:ue!==null&&(nt?(t=ue,n=n.stateNode,t.nodeType===8?xs(t.parentNode,n):t.nodeType===1&&xs(t,n),Ni(t)):xs(ue,n.stateNode));break;case 4:r=ue,i=nt,ue=n.stateNode.containerInfo,nt=!0,Bt(t,e,n),ue=r,nt=i;break;case 0:case 11:case 14:case 15:if(!ge&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){i=r=r.next;do{var o=i,l=o.destroy;o=o.tag,l!==void 0&&(o&2||o&4)&&Eu(n,e,l),i=i.next}while(i!==r)}Bt(t,e,n);break;case 1:if(!ge&&(ur(n,e),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(s){Y(n,e,s)}Bt(t,e,n);break;case 21:Bt(t,e,n);break;case 22:n.mode&1?(ge=(r=ge)||n.memoizedState!==null,Bt(t,e,n),ge=r):Bt(t,e,n);break;default:Bt(t,e,n)}}function Rf(t){var e=t.updateQueue;if(e!==null){t.updateQueue=null;var n=t.stateNode;n===null&&(n=t.stateNode=new L1),e.forEach(function(r){var i=H1.bind(null,t,r);n.has(r)||(n.add(r),r.then(i,i))})}}function et(t,e){var n=e.deletions;if(n!==null)for(var r=0;ri&&(i=l),r&=~o}if(r=i,r=X()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*_1(r/1960))-r,10t?16:t,Ht===null)var r=!1;else{if(t=Ht,Ht=null,fl=0,V&6)throw Error(w(331));var i=V;for(V|=4,M=t.current;M!==null;){var o=M,l=o.child;if(M.flags&16){var s=o.deletions;if(s!==null){for(var u=0;uX()-_a?zn(t,0):Va|=n),Ae(t,e)}function um(t,e){e===0&&(t.mode&1?(e=lo,lo<<=1,!(lo&130023424)&&(lo=4194304)):e=1);var n=xe();t=At(t,e),t!==null&&(Ji(t,e,n),Ae(t,n))}function J1(t){var e=t.memoizedState,n=0;e!==null&&(n=e.retryLane),um(t,n)}function H1(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(w(314))}r!==null&&r.delete(e),um(t,n)}var am;am=function(t,e,n){if(t!==null)if(t.memoizedProps!==e.pendingProps||Pe.current)Re=!0;else{if(!(t.lanes&n)&&!(e.flags&128))return Re=!1,A1(t,e,n);Re=!!(t.flags&131072)}else Re=!1,H&&e.flags&1048576&&dp(e,nl,e.index);switch(e.lanes=0,e.tag){case 2:var r=e.type;zo(t,e),t=e.pendingProps;var i=wr(e,Se.current);pr(e,n),i=za(null,e,r,t,i,n);var o=Aa();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,ze(r)?(o=!0,el(e)):o=!1,e.memoizedState=i.state!==null&&i.state!==void 0?i.state:null,Ma(e),i.updater=Dl,e.stateNode=i,i._reactInternals=e,yu(e,r,t,n),e=vu(null,e,r,!0,o,n)):(e.tag=0,H&&o&&va(e),ve(null,e,i,n),e=e.child),e;case 16:r=e.elementType;e:{switch(zo(t,e),t=e.pendingProps,i=r._init,r=i(r._payload),e.type=r,i=e.tag=Q1(r),t=tt(r,t),i){case 0:e=Su(null,e,r,t,n);break e;case 1:e=Nf(null,e,r,t,n);break e;case 11:e=Cf(null,e,r,t,n);break e;case 14:e=Ef(null,e,r,tt(r.type,t),n);break e}throw Error(w(306,r,""))}return e;case 0:return r=e.type,i=e.pendingProps,i=e.elementType===r?i:tt(r,i),Su(t,e,r,i,n);case 1:return r=e.type,i=e.pendingProps,i=e.elementType===r?i:tt(r,i),Nf(t,e,r,i,n);case 3:e:{if(Hp(e),t===null)throw Error(w(387));r=e.pendingProps,o=e.memoizedState,i=o.element,gp(t,e),ol(e,r,null,n);var l=e.memoizedState;if(r=l.element,o.isDehydrated)if(o={element:r,isDehydrated:!1,cache:l.cache,pendingSuspenseBoundaries:l.pendingSuspenseBoundaries,transitions:l.transitions},e.updateQueue.baseState=o,e.memoizedState=o,e.flags&256){i=Nr(Error(w(423)),e),e=Of(t,e,r,n,i);break e}else if(r!==i){i=Nr(Error(w(424)),e),e=Of(t,e,r,n,i);break e}else for(Ve=Gt(e.stateNode.containerInfo.firstChild),be=e,H=!0,rt=null,n=vp(e,null,r,n),e.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(xr(),r===i){e=It(t,e,n);break e}ve(t,e,r,n)}e=e.child}return e;case 5:return wp(e),t===null&&pu(e),r=e.type,i=e.pendingProps,o=t!==null?t.memoizedProps:null,l=i.children,au(r,i)?l=null:o!==null&&au(r,o)&&(e.flags|=32),Jp(t,e),ve(t,e,l,n),e.child;case 6:return t===null&&pu(e),null;case 13:return Kp(t,e,n);case 4:return Ta(e,e.stateNode.containerInfo),r=e.pendingProps,t===null?e.child=Cr(e,null,r,n):ve(t,e,r,n),e.child;case 11:return r=e.type,i=e.pendingProps,i=e.elementType===r?i:tt(r,i),Cf(t,e,r,i,n);case 7:return ve(t,e,e.pendingProps,n),e.child;case 8:return ve(t,e,e.pendingProps.children,n),e.child;case 12:return ve(t,e,e.pendingProps.children,n),e.child;case 10:e:{if(r=e.type._context,i=e.pendingProps,o=e.memoizedProps,l=i.value,W(rl,r._currentValue),r._currentValue=l,o!==null)if(st(o.value,l)){if(o.children===i.children&&!Pe.current){e=It(t,e,n);break e}}else for(o=e.child,o!==null&&(o.return=e);o!==null;){var s=o.dependencies;if(s!==null){l=o.child;for(var u=s.firstContext;u!==null;){if(u.context===r){if(o.tag===1){u=Tt(-1,n&-n),u.tag=2;var a=o.updateQueue;if(a!==null){a=a.shared;var c=a.pending;c===null?u.next=u:(u.next=c.next,c.next=u),a.pending=u}}o.lanes|=n,u=o.alternate,u!==null&&(u.lanes|=n),mu(o.return,n,e),s.lanes|=n;break}u=u.next}}else if(o.tag===10)l=o.type===e.type?null:o.child;else if(o.tag===18){if(l=o.return,l===null)throw Error(w(341));l.lanes|=n,s=l.alternate,s!==null&&(s.lanes|=n),mu(l,n,e),l=o.sibling}else l=o.child;if(l!==null)l.return=o;else for(l=o;l!==null;){if(l===e){l=null;break}if(o=l.sibling,o!==null){o.return=l.return,l=o;break}l=l.return}o=l}ve(t,e,i.children,n),e=e.child}return e;case 9:return i=e.type,r=e.pendingProps.children,pr(e,n),i=Xe(i),r=r(i),e.flags|=1,ve(t,e,r,n),e.child;case 14:return r=e.type,i=tt(r,e.pendingProps),i=tt(r.type,i),Ef(t,e,r,i,n);case 15:return Up(t,e,e.type,e.pendingProps,n);case 17:return r=e.type,i=e.pendingProps,i=e.elementType===r?i:tt(r,i),zo(t,e),e.tag=1,ze(r)?(t=!0,el(e)):t=!1,pr(e,n),kp(e,r,i),yu(e,r,i,n),vu(null,e,r,!0,t,n);case 19:return Qp(t,e,n);case 22:return jp(t,e,n)}throw Error(w(156,e.tag))};function cm(t,e){return Lh(t,e)}function K1(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 qe(t,e,n,r){return new K1(t,e,n,r)}function Ua(t){return t=t.prototype,!(!t||!t.isReactComponent)}function Q1(t){if(typeof t=="function")return Ua(t)?1:0;if(t!=null){if(t=t.$$typeof,t===ua)return 11;if(t===aa)return 14}return 2}function tn(t,e){var n=t.alternate;return n===null?(n=qe(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 Fo(t,e,n,r,i,o){var l=2;if(r=t,typeof t=="function")Ua(t)&&(l=1);else if(typeof t=="string")l=5;else e:switch(t){case Zn:return An(n.children,i,o,e);case sa:l=8,i|=8;break;case $s:return t=qe(12,n,e,i|2),t.elementType=$s,t.lanes=o,t;case Ws:return t=qe(13,n,e,i),t.elementType=Ws,t.lanes=o,t;case Us:return t=qe(19,n,e,i),t.elementType=Us,t.lanes=o,t;case Sh:return Al(n,i,o,e);default:if(typeof t=="object"&&t!==null)switch(t.$$typeof){case yh:l=10;break e;case kh:l=9;break e;case ua:l=11;break e;case aa:l=14;break e;case _t:l=16,r=null;break e}throw Error(w(130,t==null?t:typeof t,""))}return e=qe(l,n,e,i),e.elementType=t,e.type=r,e.lanes=o,e}function An(t,e,n,r){return t=qe(7,t,r,e),t.lanes=n,t}function Al(t,e,n,r){return t=qe(22,t,r,e),t.elementType=Sh,t.lanes=n,t.stateNode={isHidden:!1},t}function Rs(t,e,n){return t=qe(6,t,null,e),t.lanes=n,t}function Ps(t,e,n){return e=qe(4,t.children!==null?t.children:[],t.key,e),e.lanes=n,e.stateNode={containerInfo:t.containerInfo,pendingChildren:null,implementation:t.implementation},e}function q1(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=fs(0),this.expirationTimes=fs(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=fs(0),this.identifierPrefix=r,this.onRecoverableError=i,this.mutableSourceEagerHydrationData=null}function ja(t,e,n,r,i,o,l,s,u){return t=new q1(t,e,n,s,u),e===1?(e=1,o===!0&&(e|=8)):e=0,o=qe(3,null,null,e),t.current=o,o.stateNode=t,o.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},Ma(o),t}function Y1(t,e,n){var r=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(pm)}catch(t){console.error(t)}}pm(),dh.exports=Ue;var Bi=dh.exports,mm,Vf=Bi;mm=Vf.createRoot,Vf.hydrateRoot;const Vl=O.createContext(null);Vl.Provider;function gm(){const[,t]=O.useReducer(e=>e+1,0);return t}const tk=()=>{const t=O.useRef(new Set).current,e=O.useRef(new Set).current,n=gm(),r=O.useRef(!0),i=O.useCallback(()=>{r.current||(n(),r.current=!0)},[n]),o=O.useCallback(l=>{let s;const u=()=>{s=l()};return t.add(u),i(),()=>{t.delete(u),s&&(e.add(s),i())}},[t,e,i]);return O.useLayoutEffect(()=>(r.current=!1,t.forEach(l=>l()),t.clear(),()=>{e.forEach(l=>l()),e.clear()})),o},nk=O.createContext(null);function rk({children:t}){const e=tk();return L(nk.Provider,{value:e,children:t})}const ym=O.createContext(null);function ik(t){const e={};for(const[r,i]of t.entries()){let o=function(l,s){for(const u of i){let a=!1;if(Bi.unstable_batchedUpdates(()=>{a=!!u.call(this,l,s)}),a||s.defaultPrevented)return!0}return!1};e[r]=o}return new xl({key:new oh("@nytimes/react-prosemirror/componentEventListeners"),props:{handleDOMEvents:e}})}function ok(){const[t,e]=O.useState(new Map),n=O.useCallback((o,l)=>{const s=t.get(o)??[];s.unshift(l),t.has(o)||(t.set(o,s),e(new Map(t)))},[t]),r=O.useCallback((o,l)=>{const s=t.get(o);s==null||s.splice(s.indexOf(l),1)},[t]),i=O.useMemo(()=>ik(t),[t]);return{registerEventListener:n,unregisterEventListener:r,componentEventListenersPlugin:i}}const we=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},Vi=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let _f=null;const wt=function(t,e,n){let r=_f||(_f=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r},Wn=function(t,e,n,r){return n&&(bf(t,e,n,r,-1)||bf(t,e,n,r,1))},lk=/^(img|br|input|textarea|hr)$/i;function bf(t,e,n,r,i){for(;;){if(t==n&&e==r)return!0;if(e==(i<0?0:dt(t))){let o=t.parentNode;if(!o||o.nodeType!=1||Qa(t)||lk.test(t.nodeName)||t.contentEditable=="false")return!1;e=we(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?dt(t):0}else return!1}}function dt(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function sk(t,e,n){for(let r=e==0,i=e==dt(t);r||i;){if(t==n)return!0;let o=we(t);if(t=t.parentNode,!t)return!1;r=r&&o==0,i=i&&o==dt(t)}}function Qa(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 _l=function(t){return t.focusNode&&Wn(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function vn(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}function uk(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function ak(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 yt=typeof navigator<"u"?navigator:null,$f=typeof document<"u"?document:null,hn=yt&&yt.userAgent||"",zu=/Edge\/(\d+)/.exec(hn),km=/MSIE \d/.exec(hn),Au=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(hn),Ie=!!(km||Au||zu),nn=km?document.documentMode:Au?+Au[1]:zu?+zu[1]:0,ut=!Ie&&/gecko\/(\d+)/i.test(hn);ut&&+(/Firefox\/(\d+)/.exec(hn)||[0,0])[1];const Iu=!Ie&&/Chrome\/(\d+)/.exec(hn),ye=!!Iu,ck=Iu?+Iu[1]:0,Ce=!Ie&&!!yt&&/Apple Computer/.test(yt.vendor),Mr=Ce&&(/Mobile\/\w+/.test(hn)||!!yt&&yt.maxTouchPoints>2),Je=Mr||(yt?/Mac/.test(yt.platform):!1),fk=yt?/Win/.test(yt.platform):!1,it=/Android \d/.test(hn),bl=!!$f&&"webkitFontSmoothing"in $f.documentElement.style,dk=bl?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function hk(t){return{left:0,right:t.documentElement.clientWidth,top:0,bottom:t.documentElement.clientHeight}}function St(t,e){return typeof t=="number"?t:t[e]}function pk(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 Wf(t,e,n){let r=t.someProp("scrollThreshold")||0,i=t.someProp("scrollMargin")||5,o=t.dom.ownerDocument;for(let l=n||t.dom;l;l=Vi(l)){if(l.nodeType!=1)continue;let s=l,u=s==o.body,a=u?hk(o):pk(s),c=0,f=0;if(e.topa.bottom-St(r,"bottom")&&(f=e.bottom-e.top>a.bottom-a.top?e.top+St(i,"top")-a.top:e.bottom-a.bottom+St(i,"bottom")),e.lefta.right-St(r,"right")&&(c=e.right-a.right+St(i,"right")),c||f)if(u)o.defaultView.scrollBy(c,f);else{let d=s.scrollLeft,p=s.scrollTop;f&&(s.scrollTop+=f),c&&(s.scrollLeft+=c);let h=s.scrollLeft-d,y=s.scrollTop-p;e={left:e.left-h,top:e.top-y,right:e.right-h,bottom:e.bottom-y}}if(u||/^(fixed|sticky)$/.test(getComputedStyle(l).position))break}}function Sm(t){let e=t.dom.getBoundingClientRect(),n=Math.max(0,e.top),r,i;for(let o=(e.left+e.right)/2,l=n+1;l=n-20){r=s,i=u.top;break}}return{refDOM:r,refTop:i,stack:vm(t.dom)}}function vm(t){let e=[],n=t.ownerDocument;for(let r=t;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t!=n);r=Vi(r));return e}function wm({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;xm(n,r==0?0:r-e)}function xm(t,e){for(let n=0;n=s){l=Math.max(h.bottom,l),s=Math.min(h.top,s);let y=h.left>e.left?h.left-e.left:h.right=(h.left+h.right)/2?1:0));continue}}else h.top>e.top&&!u&&h.left<=e.left&&h.right>=e.left&&(u=c,a={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&&u&&(n=u,i=a,r=0),n&&n.nodeType==3?gk(n,i):!n||r&&n.nodeType==1?{node:t,offset:o}:Cm(n,i)}function gk(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 qa(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function yk(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left(l.left+l.right)/2?1:-1}return t.docView.posFromDOM(r,i,o)}function Sk(t,e,n,r){let i=-1;for(let o=e,l=!1;o!=t.dom;){let s=t.docView.nearestDesc(o,!0);if(!s)return null;if(s.dom.nodeType==1&&(s.node.isBlock&&s.parent&&!l||!s.contentDOM)){let u=s.dom.getBoundingClientRect();if(s.node.isBlock&&s.parent&&!l&&(l=!0,u.left>r.left||u.top>r.top?i=s.posBefore:(u.right-1?i:t.docView.posFromDOM(e,n,-1)}function Em(t,e,n){let r=t.childNodes.length;if(r&&n.tope.top&&i++}r==t.dom&&i==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?s=t.state.doc.content.size:(i==0||r.nodeType!=1||r.childNodes[i-1].nodeName!="BR")&&(s=Sk(t,r,i,e))}s==null&&(s=kk(t,l,e));let u=t.docView.nearestDesc(l,!0);return{pos:s,inside:u?u.posAtStart-u.border:-1}}function Uf(t){return t.top=0&&i==r.nodeValue.length?(u--,c=1):n<0?u--:a++,Wr(Vt(wt(r,u,a),c),c<0)}if(!t.state.doc.resolve(e-(o||0)).parent.inlineContent){if(o==null&&i&&(n<0||i==dt(r))){let u=r.childNodes[i-1];if(u.nodeType==1)return zs(u.getBoundingClientRect(),!1)}if(o==null&&i=0)}if(o==null&&i&&(n<0||i==dt(r))){let u=r.childNodes[i-1],a=u.nodeType==3?wt(u,dt(u)-(l?0:1)):u.nodeType==1&&(u.nodeName!="BR"||!u.nextSibling)?u:null;if(a)return Wr(Vt(a,1),!1)}if(o==null&&i=0)}function Wr(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 zs(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 Om(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 xk(t,e,n){let r=e.selection,i=n=="up"?r.$from:r.$to;return Om(t,e,()=>{let{node:o}=t.docView.domFromPos(i.pos,n=="up"?-1:1);for(;;){let s=t.docView.nearestDesc(o,!0);if(!s)break;if(s.node.isBlock){o=s.contentDOM||s.dom;break}o=s.dom.parentNode}let l=Nm(t,i.pos,1);for(let s=o.firstChild;s;s=s.nextSibling){let u;if(s.nodeType==1)u=s.getClientRects();else if(s.nodeType==3)u=wt(s,0,s.nodeValue.length).getClientRects();else continue;for(let a=0;ac.top+1&&(n=="up"?l.top-c.top>(c.bottom-l.top)*2:c.bottom-l.bottom>(l.bottom-c.top)*2))return!1}}return!0})}const Ck=/[\u0590-\u08ac]/;function Ek(t,e,n){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let i=r.parentOffset,o=!i,l=i==r.parent.content.size,s=t.domSelection();return!Ck.test(r.parent.textContent)||!s.modify?n=="left"||n=="backward"?o:l:Om(t,e,()=>{let{focusNode:u,focusOffset:a,anchorNode:c,anchorOffset:f}=t.domSelectionRange(),d=s.caretBidiLevel;s.modify("move",n,"character");let p=r.depth?t.docView.domAfterPos(r.before()):t.dom,{focusNode:h,focusOffset:y}=t.domSelectionRange(),S=h&&!p.contains(h.nodeType==1?h:h.parentNode)||u==h&&a==y;try{s.collapse(c,f),u&&(u!=c||a!=f)&&s.extend&&s.extend(u,a)}catch{}return d!=null&&(s.caretBidiLevel=d),S})}let jf=null,Jf=null,Hf=!1;function Nk(t,e,n){return jf==e&&Jf==n?Hf:(jf=e,Jf=n,Hf=n=="up"||n=="down"?xk(t,e,n):Ek(t,e,n))}const Ge=0,Kf=1,Nn=2,kt=3;class qi{constructor(e,n,r,i){this.parent=e,this.children=n,this.dom=r,this.contentDOM=i,this.dirty=Ge,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;nwe(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),l;if(o&&(!n||o.node))if(r&&(l=o.nodeDOM)&&!(l.nodeType==1?l.contains(e.nodeType==1?e:e.parentNode):l==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||l instanceof Ga){i=e-o;break}o=s}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 Ya&&o.side>=0;r--);if(n<=0){let o,l=!0;for(;o=r?this.children[r-1]:null,!(!o||o.dom.parentNode==this.contentDOM);r--,l=!1);return o&&n&&l&&!o.border&&!o.domAtom?o.domFromPos(o.size,n):{node:this.contentDOM,offset:o?we(o.dom)+1:0}}else{let o,l=!0;for(;o=r=c&&n<=a-u.border&&u.node&&u.contentDOM&&this.contentDOM.contains(u.contentDOM))return u.parseRange(e,n,c);e=l;for(let f=s;f>0;f--){let d=this.children[f-1];if(d.size&&d.dom.parentNode==this.contentDOM&&!d.emptyChildAt(1)){i=we(d.dom)+1;break}e-=d.size}i==-1&&(i=0)}if(i>-1&&(a>n||s==this.children.length-1)){n=a;for(let c=s+1;cp&&ln){let p=s;s=u,u=p}let d=document.createRange();d.setEnd(u.node,u.offset),d.setStart(s.node,s.offset),a.removeAllRanges(),a.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 s=r+o.border,u=l-o.border;if(e>=s&&n<=u){this.dirty=e==r||n==l?Nn:Kf,e==s&&n==u&&(o.contentLost||o.dom.parentNode!=this.contentDOM)?o.dirty=kt:o.markDirty(e-s,n-s);return}else o.dirty=o.dom==o.contentDOM&&o.dom.parentNode==this.contentDOM&&!o.children.length?Nn:kt}r=l}this.dirty=Nn}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let r=e==1?Nn:Kf;n.dirty0&&(o=Bu(o,0,e,r));for(let s=0;s{if(!u)return l;if(u.parent)return u.parent.posBeforeChild(u)},r,i),c=a&&a.dom,f=a&&a.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}=Nt.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=Dm(c,r,n),a?u=new Mk(e,n,r,i,c,f||null,d,a,o,l+1):n.isText?new Tr(e,[],n,r,i,c,d):new Dt(e,[],n,r,i,c,f||null,d)}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=()=>x.empty)}return e}matchesNode(e,n,r){return this.dirty==Ge&&e.eq(this.node)&&Lu(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,l=o&&o.pos>-1?o:null,s=o&&o.pos<0,u=new Dk(this,l&&l.node,e);zk(this.node,this.innerDeco,(a,c,f)=>{a.spec.marks?u.syncToMarks(a.spec.marks,r,e):a.type.side>=0&&!f&&u.syncToMarks(c==this.node.childCount?_.none:this.node.child(c).marks,r,e),u.placeWidget(a,e,i)},(a,c,f,d)=>{u.syncToMarks(a.marks,r,e);let p;u.findNodeMatch(a,c,f,d)||s&&e.state.selection.from>i&&e.state.selection.to-1&&u.updateNodeAt(a,c,f,p,e)||u.updateNextNode(a,c,f,e,d,i)||u.addNode(a,c,f,e,i),i+=a.nodeSize}),u.syncToMarks([],r,e),this.node.isTextblock&&u.addTextblockHacks(),u.destroyRest(),(u.changed||this.dirty==Nn)&&(l&&this.protectLocalComposition(e,l),Mm(this.contentDOM,this.children,e),Mr&&Ak(this.dom))}localCompositionInfo(e,n){let{from:r,to:i}=e.state.selection;if(!(e.state.selection instanceof U)||rn+this.node.content.size)return null;let o=e.domSelectionRange(),l=Ik(o.focusNode,o.focusOffset);if(!l||!this.dom.contains(l.parentNode))return null;if(this.node.inlineContent){let s=l.nodeValue,u=Fk(this.node.content,s,r-n,i-n);return u<0?null:{node:l,pos:u,text:s}}else return{node:l,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 l=new Ok(this,o,n,i);e.input.compositionNodes.push(l),this.children=Bu(this.children,r,r+i.length,e,l)}update(e,n,r,i){return this.dirty==kt||!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=Ge}updateOuterDeco(e){if(Lu(e,this.outerDeco))return;let n=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=Tm(this.dom,this.nodeDOM,Fu(this.outerDeco,this.node,n),Fu(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 Qf(t,e,n,r,i){Dm(r,e,t);let o=new Dt(void 0,[],t,e,n,r,r,r);return o.contentDOM&&o.updateChildren(i,0),o}class Tr extends Dt{constructor(e,n,r,i,o,l,s){super(e,n,r,i,o,l,null,s)}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==kt||this.dirty!=Ge&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=Ge||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=Ge,!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 Tr(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=kt)}get domAtom(){return!1}}class Ga extends qi{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==Ge&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class Mk extends Dt{constructor(e,n,r,i,o,l,s,u,a,c){super(e,[],n,r,i,o,l,s),this.spec=u}update(e,n,r,i){if(this.dirty==kt)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 Mm(t,e,n){let r=t.firstChild,i=!1;for(let o=0;o>1,l=Math.min(o,e.length);for(;i-1)s>this.index&&(this.changed=!0,this.destroyBetween(this.index,s)),this.top=this.top.children[this.index];else{let u=un.create(this.top,e[o],n,r);this.top.children.splice(this.index,0,u),this.top=u,this.changed=!0}this.index=0,o++}}findNodeMatch(e,n,r,i){let o=-1,l;if(i>=this.preMatch.index&&(l=this.preMatch.matches[i-this.preMatch.index]).parent==this.top&&l.matchesNode(e,n,r))o=this.top.children.indexOf(l,this.index);else for(let s=this.index,u=Math.min(this.top.children.length,s+5);s0;){let s;for(;;)if(r){let a=n.children[r-1];if(a instanceof un)n=a,r=a.children.length;else{s=a,r--;break}}else{if(n==e)break e;r=n.parent.children.indexOf(n),n=n.parent}let u=s.node;if(u){if(u!=t.child(i-1))break;--i,o.set(s,i),l.push(s)}}return{index:i,matched:o,matches:l.reverse()}}function Pk(t,e){return t.type.side-e.type.side}function zk(t,e,n,r){let i=e.locals(t),o=0;if(i.length==0){for(let a=0;ao;)s.push(i[l++]);let d=o+c.nodeSize;if(c.isText){let h=d;l!h.inline):s.slice();r(c,p,e.forChild(o,c),f),o=d}}function Ak(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 Ik(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=dt(t)}else if(t.nodeType==1&&e=n){let a=s=0&&a+e.length+s>=n)return s+a;if(n==r&&u.length>=r+e.length-s&&u.slice(r-s,r-s+e.length)==e)return r}}return-1}function Bu(t,e,n,r,i){let o=[];for(let l=0,s=0;l=n||c<=e?o.push(u):(an&&o.push(u.slice(n-a,u.size,r)))}return o}const Rm=65535,Pm=Math.pow(2,16);function Lk(t,e){return t+e*Pm}function Yf(t){return t&Rm}function Bk(t){return(t-(t&Rm))/Pm}const zm=1,Am=2,Lo=4,Im=8;class Gf{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&Im)>0}get deletedBefore(){return(this.delInfo&(zm|Lo))>0}get deletedAfter(){return(this.delInfo&(Am|Lo))>0}get deletedAcross(){return(this.delInfo&Lo)>0}}class Qe{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&Qe.empty)return Qe.empty}recover(e){let n=0,r=Yf(e);if(!this.inverted)for(let i=0;ie)break;let a=this.ranges[s+o],c=this.ranges[s+l],f=u+a;if(e<=f){let d=a?e==u?-1:e==f?1:n:n,p=u+i+(d<0?0:c);if(r)return p;let h=e==(n<0?u:f)?null:Lk(s/3,e-u),y=e==u?Am:e==f?zm:Lo;return(n<0?e!=u:e!=f)&&(y|=Im),new Gf(p,y,h)}i+=c-a}return r?e+i:new Gf(e+i,0,null)}touches(e,n){let r=0,i=Yf(n),o=this.inverted?2:1,l=this.inverted?1:2;for(let s=0;se)break;let a=this.ranges[s+o],c=u+a;if(e<=c&&s==i*3)return!0;r+=this.ranges[s+l]-a}return!1}forEach(e){let n=this.inverted?2:1,r=this.inverted?1:2;for(let i=0,o=0;i!l.isAtom||!s.type.allowsMarkType(this.mark.type)?l:l.mark(this.mark.addToSet(l.marks)),i),n.openStart,n.openEnd);return ne.fromReplace(e,this.from,this.to,o)}invert(){return new Tn(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 Mn(n.pos,r.pos,this.mark)}merge(e){return e instanceof Mn&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Mn(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 Mn(n.from,n.to,e.markFromJSON(n.mark))}}Le.jsonID("addMark",Mn);class Tn extends Le{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 C(Xa(n.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),n.openStart,n.openEnd);return ne.fromReplace(e,this.from,this.to,r)}invert(){return new Mn(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 Tn(n.pos,r.pos,this.mark)}merge(e){return e instanceof Tn&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Tn(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 Tn(n.from,n.to,e.markFromJSON(n.mark))}}Le.jsonID("removeMark",Tn);class Dn extends Le{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return ne.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return ne.fromReplace(e,this.pos,this.pos+1,new C(x.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 hi(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 hi(n.from,n.to,n.gapFrom,n.gapTo,C.fromJSON(e,n.slice),n.insert,!!n.structure)}}Le.jsonID("replaceAround",hi);function Vu(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 l=r.node(o).maybeChild(r.indexAfter(o));for(;i>0;){if(!l||l.isLeaf)return!0;l=l.firstChild,i--}}return!1}function Vk(t,e,n){let r=t.resolve(e);if(!n.content.size)return e;let i=n.content;for(let o=0;o=0;l--){let s=l==r.depth?0:r.pos<=(r.start(l+1)+r.end(l+1))/2?-1:1,u=r.index(l)+(s>0?1:0),a=r.node(l),c=!1;if(o==1)c=a.canReplace(u,u,i);else{let f=a.contentMatchAt(u).findWrapping(i.firstChild.type);c=f&&a.canReplaceWith(u,u,f[0])}if(c)return s==0?r.pos:s<0?r.before(l+1):r.after(l+1)}return null}class pi extends Le{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 ne.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 ne.fromReplace(e,this.pos,this.pos+1,new C(x.from(i),0,n.isLeaf?0:1))}getMap(){return Qe.empty}invert(e){return new pi(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 pi(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 pi(n.pos,n.attr,n.value)}}Le.jsonID("attr",pi);let bi=class extends Error{};bi=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};bi.prototype=Object.create(Error.prototype);bi.prototype.constructor=bi;bi.prototype.name="TransformError";function Za(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,l=t.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(l<0)return null;let s=r.resolve(l),u,a;if(_l(n)){for(u=s;i&&!i.node;)i=i.parent;let c=i.node;if(i&&c.isAtom&&A.isSelectable(c)&&i.parent&&!(c.isInline&&sk(n.focusNode,n.focusOffset,i.dom))){let f=i.posBefore;a=new A(l==f?s:r.resolve(f))}}else{let c=t.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(c<0)return null;u=r.resolve(c)}if(!a){let c=e=="pointer"||t.state.selection.head{(n.anchorNode!=r||n.anchorOffset!=i)&&(e.removeEventListener("selectionchange",t.input.hideSelectionGuard),setTimeout(()=>{(!Fm(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function bk(t){let e=t.domSelection(),n=document.createRange(),r=t.cursorWrapper.dom,i=r.nodeName=="IMG";i?n.setEnd(r.parentNode,we(r)+1):n.setEnd(r,0),n.collapse(!1),e.removeAllRanges(),e.addRange(n),!i&&!t.state.selection.visible&&Ie&&nn<=11&&(r.disabled=!0,r.disabled=!1)}function Lm(t,e){if(e instanceof A){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(td(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else td(t)}function td(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function ec(t,e,n,r){return t.someProp("createSelectionBetween",i=>i(t,e,n))||U.between(e,n,r)}function nd(t){return t.editable&&!t.hasFocus()?!1:Bm(t)}function Bm(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 $k(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return Wn(e.node,e.offset,n.anchorNode,n.anchorOffset)}function _u(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&&b.findFrom(o,e)}function wn(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function rd(t,e,n){let r=t.state.selection;if(r instanceof U){if(!r.empty||n.indexOf("s")>-1)return!1;if(t.endOfTextblock(e>0?"forward":"backward")){let i=_u(t.state,e);return i&&i instanceof A?wn(t,i):!1}else if(!(Je&&n.indexOf("m")>-1)){let i=r.$head,o=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter,l;if(!o||o.isText)return!1;let s=e<0?i.pos-o.nodeSize:i.pos;return o.isAtom||(l=t.docView.descAt(s))&&!l.contentDOM?A.isSelectable(o)?wn(t,new A(e<0?t.state.doc.resolve(i.pos-o.nodeSize):i)):bl?wn(t,new U(t.state.doc.resolve(e<0?s:s+o.nodeSize))):!1:!1}}else{if(r instanceof A&&r.node.isInline)return wn(t,new U(e>0?r.$to:r.$from));{let i=_u(t.state,e);return i?wn(t,i):!1}}}function pl(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function mi(t,e){if(t.contentEditable=="false")return!0;let n=t.pmViewDesc;return n&&n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function Kn(t,e){return e<0?Wk(t):Uk(t)}function Wk(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i,o,l=!1;for(ut&&n.nodeType==1&&r0){if(n.nodeType!=1)break;{let s=n.childNodes[r-1];if(mi(s,-1))i=n,o=--r;else if(s.nodeType==3)n=s,r=n.nodeValue.length;else break}}else{if(Vm(n))break;{let s=n.previousSibling;for(;s&&mi(s,-1);)i=n.parentNode,o=we(s),s=s.previousSibling;if(s)n=s,r=pl(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}l?bu(t,n,r):i&&bu(t,i,o)}function Uk(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i=pl(n),o,l;for(;;)if(r{t.state==i&>(t)},50)}function id(t,e){let n=t.state.doc.resolve(e);if(!(ye||fk)&&n.parent.inlineContent){let i=t.coordsAtPos(e);if(e>n.start()){let o=t.coordsAtPos(e-1),l=(o.top+o.bottom)/2;if(l>i.top&&l1)return o.lefti.top&&l1)return o.left>i.left?"ltr":"rtl"}}return getComputedStyle(t.dom).direction=="rtl"?"rtl":"ltr"}function od(t,e,n){let r=t.state.selection;if(r instanceof U&&!r.empty||n.indexOf("s")>-1||Je&&n.indexOf("m")>-1)return!1;let{$from:i,$to:o}=r;if(!i.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let l=_u(t.state,e);if(l&&l instanceof A)return wn(t,l)}if(!i.parent.inlineContent){let l=e<0?i:o,s=r instanceof _e?b.near(l,e):b.findFrom(l,e);return s?wn(t,s):!1}return!1}function ld(t,e){if(!(t.state.selection instanceof U))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 l=t.state.tr;return e<0?l.delete(n.pos-o.nodeSize,n.pos):l.delete(n.pos,n.pos+o.nodeSize),t.dispatch(l),!0}return!1}function sd(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function Hk(t){if(!Ce||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;sd(t,r,"true"),setTimeout(()=>sd(t,r,"false"),20)}return!1}function Kk(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function Qk(t,e){let n=e.keyCode,r=Kk(e);if(n==8||Je&&n==72&&r=="c")return ld(t,-1)||Kn(t,-1);if(n==46&&!e.shiftKey||Je&&n==68&&r=="c")return ld(t,1)||Kn(t,1);if(n==13||n==27)return!0;if(n==37||Je&&n==66&&r=="c"){let i=n==37?id(t,t.state.selection.from)=="ltr"?-1:1:-1;return rd(t,i,r)||Kn(t,i)}else if(n==39||Je&&n==70&&r=="c"){let i=n==39?id(t,t.state.selection.from)=="ltr"?1:-1:1;return rd(t,i,r)||Kn(t,i)}else{if(n==38||Je&&n==80&&r=="c")return od(t,-1,r)||Kn(t,-1);if(n==40||Je&&n==78&&r=="c")return Hk(t)||od(t,1,r)||Kn(t,1);if(r==(Je?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function _m(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 l=t.someProp("clipboardSerializer")||Nt.fromSchema(t.state.schema),s=Jm(),u=s.createElement("div");u.appendChild(l.serializeFragment(r,{document:s}));let a=u.firstChild,c,f=0;for(;a&&a.nodeType==1&&(c=jm[a.nodeName.toLowerCase()]);){for(let p=c.length-1;p>=0;p--){let h=s.createElement(c[p]);for(;u.firstChild;)h.appendChild(u.firstChild);u.appendChild(h),f++}a=u.firstChild}a&&a.nodeType==1&&a.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,` +`+o.stack}return{value:t,source:e,stack:i,digest:null}}function Ds(t,e,n){return{value:t,source:null,stack:n??null,digest:e??null}}function vu(t,e){try{console.error(e.value)}catch(n){setTimeout(function(){throw n})}}var R1=typeof WeakMap=="function"?WeakMap:Map;function $p(t,e,n){n=Dt(-1,n),n.tag=3,n.payload={element:null};var r=e.value;return n.callback=function(){fl||(fl=!0,Ru=r),vu(t,e)},n}function Wp(t,e,n){n=Dt(-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(){vu(t,e)}}var o=t.stateNode;return o!==null&&typeof o.componentDidCatch=="function"&&(n.callback=function(){vu(t,e),typeof r!="function"&&(Zt===null?Zt=new Set([this]):Zt.add(this));var l=e.stack;this.componentDidCatch(e.value,{componentStack:l!==null?l:""})}),n}function wf(t,e,n){var r=t.pingCache;if(r===null){r=t.pingCache=new R1;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=j1.bind(null,t,e,n),e.then(t,t))}function xf(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 Cf(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=Dt(-1,1),e.tag=2,Xt(n,e,1))),n.lanes|=1),t)}var P1=Lt.ReactCurrentOwner,Re=!1;function ve(t,e,n,r){e.child=t===null?vp(e,null,n,r):Cr(e,t.child,n,r)}function Ef(t,e,n,r,i){n=n.render;var o=e.ref;return pr(e,i),r=Aa(t,e,n,r,o,i),n=Ia(),t!==null&&!Re?(e.updateQueue=t.updateQueue,e.flags&=-2053,t.lanes&=~i,It(t,e,i)):(H&&n&&wa(e),e.flags|=1,ve(t,e,r,i),e.child)}function Nf(t,e,n,r,i){if(t===null){var o=n.type;return typeof o=="function"&&!ja(o)&&o.defaultProps===void 0&&n.compare===null&&n.defaultProps===void 0?(e.tag=15,e.type=o,Up(t,e,o,r,i)):(t=Lo(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 l=o.memoizedProps;if(n=n.compare,n=n!==null?n:Ti,n(l,r)&&t.ref===e.ref)return It(t,e,i)}return e.flags|=1,t=tn(o,r),t.ref=e.ref,t.return=e,e.child=t}function Up(t,e,n,r,i){if(t!==null){var o=t.memoizedProps;if(Ti(o,r)&&t.ref===e.ref)if(Re=!1,e.pendingProps=r=o,(t.lanes&i)!==0)t.flags&131072&&(Re=!0);else return e.lanes=t.lanes,It(t,e,i)}return wu(t,e,n,r,i)}function jp(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},W(ar,Ve),Ve|=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,W(ar,Ve),Ve|=t,null;e.memoizedState={baseLanes:0,cachePool:null,transitions:null},r=o!==null?o.baseLanes:n,W(ar,Ve),Ve|=r}else o!==null?(r=o.baseLanes|n,e.memoizedState=null):r=n,W(ar,Ve),Ve|=r;return ve(t,e,i,n),e.child}function Jp(t,e){var n=e.ref;(t===null&&n!==null||t!==null&&t.ref!==n)&&(e.flags|=512,e.flags|=2097152)}function wu(t,e,n,r,i){var o=ze(n)?Bn:Se.current;return o=wr(e,o),pr(e,i),n=Aa(t,e,n,r,o,i),r=Ia(),t!==null&&!Re?(e.updateQueue=t.updateQueue,e.flags&=-2053,t.lanes&=~i,It(t,e,i)):(H&&r&&wa(e),e.flags|=1,ve(t,e,n,i),e.child)}function Of(t,e,n,r,i){if(ze(n)){var o=!0;tl(e)}else o=!1;if(pr(e,i),e.stateNode===null)Ao(t,e),kp(e,n,r),Su(e,n,r,i),r=!0;else if(t===null){var l=e.stateNode,s=e.memoizedProps;l.props=s;var u=l.context,a=n.contextType;typeof a=="object"&&a!==null?a=Xe(a):(a=ze(n)?Bn:Se.current,a=wr(e,a));var c=n.getDerivedStateFromProps,f=typeof c=="function"||typeof l.getSnapshotBeforeUpdate=="function";f||typeof l.UNSAFE_componentWillReceiveProps!="function"&&typeof l.componentWillReceiveProps!="function"||(s!==r||u!==a)&&yf(e,l,r,a),bt=!1;var d=e.memoizedState;l.state=d,ll(e,r,l,i),u=e.memoizedState,s!==r||d!==u||Pe.current||bt?(typeof c=="function"&&(ku(e,n,c,r),u=e.memoizedState),(s=bt||gf(e,n,s,r,d,u,a))?(f||typeof l.UNSAFE_componentWillMount!="function"&&typeof l.componentWillMount!="function"||(typeof l.componentWillMount=="function"&&l.componentWillMount(),typeof l.UNSAFE_componentWillMount=="function"&&l.UNSAFE_componentWillMount()),typeof l.componentDidMount=="function"&&(e.flags|=4194308)):(typeof l.componentDidMount=="function"&&(e.flags|=4194308),e.memoizedProps=r,e.memoizedState=u),l.props=r,l.state=u,l.context=a,r=s):(typeof l.componentDidMount=="function"&&(e.flags|=4194308),r=!1)}else{l=e.stateNode,gp(t,e),s=e.memoizedProps,a=e.type===e.elementType?s:tt(e.type,s),l.props=a,f=e.pendingProps,d=l.context,u=n.contextType,typeof u=="object"&&u!==null?u=Xe(u):(u=ze(n)?Bn:Se.current,u=wr(e,u));var p=n.getDerivedStateFromProps;(c=typeof p=="function"||typeof l.getSnapshotBeforeUpdate=="function")||typeof l.UNSAFE_componentWillReceiveProps!="function"&&typeof l.componentWillReceiveProps!="function"||(s!==f||d!==u)&&yf(e,l,r,u),bt=!1,d=e.memoizedState,l.state=d,ll(e,r,l,i);var h=e.memoizedState;s!==f||d!==h||Pe.current||bt?(typeof p=="function"&&(ku(e,n,p,r),h=e.memoizedState),(a=bt||gf(e,n,a,r,d,h,u)||!1)?(c||typeof l.UNSAFE_componentWillUpdate!="function"&&typeof l.componentWillUpdate!="function"||(typeof l.componentWillUpdate=="function"&&l.componentWillUpdate(r,h,u),typeof l.UNSAFE_componentWillUpdate=="function"&&l.UNSAFE_componentWillUpdate(r,h,u)),typeof l.componentDidUpdate=="function"&&(e.flags|=4),typeof l.getSnapshotBeforeUpdate=="function"&&(e.flags|=1024)):(typeof l.componentDidUpdate!="function"||s===t.memoizedProps&&d===t.memoizedState||(e.flags|=4),typeof l.getSnapshotBeforeUpdate!="function"||s===t.memoizedProps&&d===t.memoizedState||(e.flags|=1024),e.memoizedProps=r,e.memoizedState=h),l.props=r,l.state=h,l.context=u,r=a):(typeof l.componentDidUpdate!="function"||s===t.memoizedProps&&d===t.memoizedState||(e.flags|=4),typeof l.getSnapshotBeforeUpdate!="function"||s===t.memoizedProps&&d===t.memoizedState||(e.flags|=1024),r=!1)}return xu(t,e,n,r,o,i)}function xu(t,e,n,r,i,o){Jp(t,e);var l=(e.flags&128)!==0;if(!r&&!l)return i&&ff(e,n,!1),It(t,e,o);r=e.stateNode,P1.current=e;var s=l&&typeof n.getDerivedStateFromError!="function"?null:r.render();return e.flags|=1,t!==null&&l?(e.child=Cr(e,t.child,null,o),e.child=Cr(e,null,s,o)):ve(t,e,s,o),e.memoizedState=r.state,i&&ff(e,n,!0),e.child}function Hp(t){var e=t.stateNode;e.pendingContext?cf(t,e.pendingContext,e.pendingContext!==e.context):e.context&&cf(t,e.context,!1),Da(t,e.containerInfo)}function Mf(t,e,n,r,i){return xr(),Ca(i),e.flags|=256,ve(t,e,n,r),e.child}var Cu={dehydrated:null,treeContext:null,retryLane:0};function Eu(t){return{baseLanes:t,cachePool:null,transitions:null}}function Kp(t,e,n){var r=e.pendingProps,i=K.current,o=!1,l=(e.flags&128)!==0,s;if((s=l)||(s=t!==null&&t.memoizedState===null?!1:(i&2)!==0),s?(o=!0,e.flags&=-129):(t===null||t.memoizedState!==null)&&(i|=1),W(K,i&1),t===null)return gu(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):(l=r.children,t=r.fallback,o?(r=e.mode,o=e.child,l={mode:"hidden",children:l},!(r&1)&&o!==null?(o.childLanes=0,o.pendingProps=l):o=Il(l,r,0,null),t=An(t,r,n,null),o.return=e,t.return=e,o.sibling=t,e.child=o,e.child.memoizedState=Eu(n),e.memoizedState=Cu,t):Ba(e,l));if(i=t.memoizedState,i!==null&&(s=i.dehydrated,s!==null))return z1(t,e,l,r,s,i,n);if(o){o=r.fallback,l=e.mode,i=t.child,s=i.sibling;var u={mode:"hidden",children:r.children};return!(l&1)&&e.child!==i?(r=e.child,r.childLanes=0,r.pendingProps=u,e.deletions=null):(r=tn(i,u),r.subtreeFlags=i.subtreeFlags&14680064),s!==null?o=tn(s,o):(o=An(o,l,n,null),o.flags|=2),o.return=e,r.return=e,r.sibling=o,e.child=r,r=o,o=e.child,l=t.child.memoizedState,l=l===null?Eu(n):{baseLanes:l.baseLanes|n,cachePool:null,transitions:l.transitions},o.memoizedState=l,o.childLanes=t.childLanes&~n,e.memoizedState=Cu,r}return o=t.child,t=o.sibling,r=tn(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 Ba(t,e){return e=Il({mode:"visible",children:e},t.mode,0,null),e.return=t,t.child=e}function go(t,e,n,r){return r!==null&&Ca(r),Cr(e,t.child,null,n),t=Ba(e,e.pendingProps.children),t.flags|=2,e.memoizedState=null,t}function z1(t,e,n,r,i,o,l){if(n)return e.flags&256?(e.flags&=-257,r=Ds(Error(w(422))),go(t,e,l,r)):e.memoizedState!==null?(e.child=t.child,e.flags|=128,null):(o=r.fallback,i=e.mode,r=Il({mode:"visible",children:r.children},i,0,null),o=An(o,i,l,null),o.flags|=2,r.return=e,o.return=e,r.sibling=o,e.child=r,e.mode&1&&Cr(e,t.child,null,l),e.child.memoizedState=Eu(l),e.memoizedState=Cu,o);if(!(e.mode&1))return go(t,e,l,null);if(i.data==="$!"){if(r=i.nextSibling&&i.nextSibling.dataset,r)var s=r.dgst;return r=s,o=Error(w(419)),r=Ds(o,r,void 0),go(t,e,l,r)}if(s=(l&t.childLanes)!==0,Re||s){if(r=oe,r!==null){switch(l&-l){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|l)?0:i,i!==0&&i!==o.retryLane&&(o.retryLane=i,At(t,i),lt(r,t,i,-1))}return Ua(),r=Ds(Error(w(421))),go(t,e,l,r)}return i.data==="$?"?(e.flags|=128,e.child=t.child,e=J1.bind(null,t),i._reactRetry=e,null):(t=o.treeContext,_e=Gt(i.nextSibling),$e=e,H=!0,rt=null,t!==null&&(He[Ke++]=Mt,He[Ke++]=Tt,He[Ke++]=Vn,Mt=t.id,Tt=t.overflow,Vn=e),e=Ba(e,r.children),e.flags|=4096,e)}function Tf(t,e,n){t.lanes|=e;var r=t.alternate;r!==null&&(r.lanes|=e),yu(t.return,e,n)}function Rs(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 Qp(t,e,n){var r=e.pendingProps,i=r.revealOrder,o=r.tail;if(ve(t,e,r.children,n),r=K.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&&Tf(t,n,e);else if(t.tag===19)Tf(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(W(K,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&&sl(t)===null&&(i=n),n=n.sibling;n=i,n===null?(i=e.child,e.child=null):(i=n.sibling,n.sibling=null),Rs(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&&sl(t)===null){e.child=i;break}t=i.sibling,i.sibling=n,n=i,i=t}Rs(e,!0,n,null,o);break;case"together":Rs(e,!1,null,null,void 0);break;default:e.memoizedState=null}return e.child}function Ao(t,e){!(e.mode&1)&&t!==null&&(t.alternate=null,e.alternate=null,e.flags|=2)}function It(t,e,n){if(t!==null&&(e.dependencies=t.dependencies),bn|=e.lanes,!(n&e.childLanes))return null;if(t!==null&&e.child!==t.child)throw Error(w(153));if(e.child!==null){for(t=e.child,n=tn(t,t.pendingProps),e.child=n,n.return=e;t.sibling!==null;)t=t.sibling,n=n.sibling=tn(t,t.pendingProps),n.return=e;n.sibling=null}return e.child}function A1(t,e,n){switch(e.tag){case 3:Hp(e),xr();break;case 5:wp(e);break;case 1:ze(e.type)&&tl(e);break;case 4:Da(e,e.stateNode.containerInfo);break;case 10:var r=e.type._context,i=e.memoizedProps.value;W(il,r._currentValue),r._currentValue=i;break;case 13:if(r=e.memoizedState,r!==null)return r.dehydrated!==null?(W(K,K.current&1),e.flags|=128,null):n&e.child.childLanes?Kp(t,e,n):(W(K,K.current&1),t=It(t,e,n),t!==null?t.sibling:null);W(K,K.current&1);break;case 19:if(r=(n&e.childLanes)!==0,t.flags&128){if(r)return Qp(t,e,n);e.flags|=128}if(i=e.memoizedState,i!==null&&(i.rendering=null,i.tail=null,i.lastEffect=null),W(K,K.current),r)break;return null;case 22:case 23:return e.lanes=0,jp(t,e,n)}return It(t,e,n)}var qp,Nu,Yp,Gp;qp=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}};Nu=function(){};Yp=function(t,e,n,r){var i=t.memoizedProps;if(i!==r){t=e.stateNode,En(mt.current);var o=null;switch(n){case"input":i=Ks(t,i),r=Ks(t,r),o=[];break;case"select":i=q({},i,{value:void 0}),r=q({},r,{value:void 0}),o=[];break;case"textarea":i=Ys(t,i),r=Ys(t,r),o=[];break;default:typeof i.onClick!="function"&&typeof r.onClick=="function"&&(t.onclick=Zo)}Xs(n,r);var l;n=null;for(a in i)if(!r.hasOwnProperty(a)&&i.hasOwnProperty(a)&&i[a]!=null)if(a==="style"){var s=i[a];for(l in s)s.hasOwnProperty(l)&&(n||(n={}),n[l]="")}else a!=="dangerouslySetInnerHTML"&&a!=="children"&&a!=="suppressContentEditableWarning"&&a!=="suppressHydrationWarning"&&a!=="autoFocus"&&(wi.hasOwnProperty(a)?o||(o=[]):(o=o||[]).push(a,null));for(a in r){var u=r[a];if(s=i!=null?i[a]:void 0,r.hasOwnProperty(a)&&u!==s&&(u!=null||s!=null))if(a==="style")if(s){for(l in s)!s.hasOwnProperty(l)||u&&u.hasOwnProperty(l)||(n||(n={}),n[l]="");for(l in u)u.hasOwnProperty(l)&&s[l]!==u[l]&&(n||(n={}),n[l]=u[l])}else n||(o||(o=[]),o.push(a,n)),n=u;else a==="dangerouslySetInnerHTML"?(u=u?u.__html:void 0,s=s?s.__html:void 0,u!=null&&s!==u&&(o=o||[]).push(a,u)):a==="children"?typeof u!="string"&&typeof u!="number"||(o=o||[]).push(a,""+u):a!=="suppressContentEditableWarning"&&a!=="suppressHydrationWarning"&&(wi.hasOwnProperty(a)?(u!=null&&a==="onScroll"&&j("scroll",t),o||s===u||(o=[])):(o=o||[]).push(a,u))}n&&(o=o||[]).push("style",n);var a=o;(e.updateQueue=a)&&(e.flags|=4)}};Gp=function(t,e,n,r){n!==r&&(e.flags|=4)};function br(t,e){if(!H)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 pe(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 I1(t,e,n){var r=e.pendingProps;switch(xa(e),e.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return pe(e),null;case 1:return ze(e.type)&&el(),pe(e),null;case 3:return r=e.stateNode,Er(),J(Pe),J(Se),Pa(),r.pendingContext&&(r.context=r.pendingContext,r.pendingContext=null),(t===null||t.child===null)&&(po(e)?e.flags|=4:t===null||t.memoizedState.isDehydrated&&!(e.flags&256)||(e.flags|=1024,rt!==null&&(Au(rt),rt=null))),Nu(t,e),pe(e),null;case 5:Ra(e);var i=En(Ai.current);if(n=e.type,t!==null&&e.stateNode!=null)Yp(t,e,n,r,i),t.ref!==e.ref&&(e.flags|=512,e.flags|=2097152);else{if(!r){if(e.stateNode===null)throw Error(w(166));return pe(e),null}if(t=En(mt.current),po(e)){r=e.stateNode,n=e.type;var o=e.memoizedProps;switch(r[ft]=e,r[Pi]=o,t=(e.mode&1)!==0,n){case"dialog":j("cancel",r),j("close",r);break;case"iframe":case"object":case"embed":j("load",r);break;case"video":case"audio":for(i=0;i<\/script>",t=t.removeChild(t.firstChild)):typeof r.is=="string"?t=l.createElement(n,{is:r.is}):(t=l.createElement(n),n==="select"&&(l=t,r.multiple?l.multiple=!0:r.size&&(l.size=r.size))):t=l.createElementNS(t,n),t[ft]=e,t[Pi]=r,qp(t,e,!1,!1),e.stateNode=t;e:{switch(l=Zs(n,r),n){case"dialog":j("cancel",t),j("close",t),i=r;break;case"iframe":case"object":case"embed":j("load",t),i=r;break;case"video":case"audio":for(i=0;iOr&&(e.flags|=128,r=!0,br(o,!1),e.lanes=4194304)}else{if(!r)if(t=sl(l),t!==null){if(e.flags|=128,r=!0,n=t.updateQueue,n!==null&&(e.updateQueue=n,e.flags|=4),br(o,!0),o.tail===null&&o.tailMode==="hidden"&&!l.alternate&&!H)return pe(e),null}else 2*X()-o.renderingStartTime>Or&&n!==1073741824&&(e.flags|=128,r=!0,br(o,!1),e.lanes=4194304);o.isBackwards?(l.sibling=e.child,e.child=l):(n=o.last,n!==null?n.sibling=l:e.child=l,o.last=l)}return o.tail!==null?(e=o.tail,o.rendering=e,o.tail=e.sibling,o.renderingStartTime=X(),e.sibling=null,n=K.current,W(K,r?n&1|2:n&1),e):(pe(e),null);case 22:case 23:return Wa(),r=e.memoizedState!==null,t!==null&&t.memoizedState!==null!==r&&(e.flags|=8192),r&&e.mode&1?Ve&1073741824&&(pe(e),e.subtreeFlags&6&&(e.flags|=8192)):pe(e),null;case 24:return null;case 25:return null}throw Error(w(156,e.tag))}function F1(t,e){switch(xa(e),e.tag){case 1:return ze(e.type)&&el(),t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 3:return Er(),J(Pe),J(Se),Pa(),t=e.flags,t&65536&&!(t&128)?(e.flags=t&-65537|128,e):null;case 5:return Ra(e),null;case 13:if(J(K),t=e.memoizedState,t!==null&&t.dehydrated!==null){if(e.alternate===null)throw Error(w(340));xr()}return t=e.flags,t&65536?(e.flags=t&-65537|128,e):null;case 19:return J(K),null;case 4:return Er(),null;case 10:return Oa(e.type._context),null;case 22:case 23:return Wa(),null;case 24:return null;default:return null}}var yo=!1,ge=!1,L1=typeof WeakSet=="function"?WeakSet:Set,M=null;function ur(t,e){var n=t.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){Y(t,e,r)}else n.current=null}function Ou(t,e,n){try{n()}catch(r){Y(t,e,r)}}var Df=!1;function B1(t,e){if(au=Yo,t=tp(),va(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 l=0,s=-1,u=-1,a=0,c=0,f=t,d=null;t:for(;;){for(var p;f!==n||i!==0&&f.nodeType!==3||(s=l+i),f!==o||r!==0&&f.nodeType!==3||(u=l+r),f.nodeType===3&&(l+=f.nodeValue.length),(p=f.firstChild)!==null;)d=f,f=p;for(;;){if(f===t)break t;if(d===n&&++a===i&&(s=l),d===o&&++c===r&&(u=l),(p=f.nextSibling)!==null)break;f=d,d=f.parentNode}f=p}n=s===-1||u===-1?null:{start:s,end:u}}else n=null}n=n||{start:0,end:0}}else n=null;for(cu={focusedElem:t,selectionRange:n},Yo=!1,M=e;M!==null;)if(e=M,t=e.child,(e.subtreeFlags&1028)!==0&&t!==null)t.return=e,M=t;else for(;M!==null;){e=M;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 y=h.memoizedProps,S=h.memoizedState,g=e.stateNode,m=g.getSnapshotBeforeUpdate(e.elementType===e.type?y:tt(e.type,y),S);g.__reactInternalSnapshotBeforeUpdate=m}break;case 3:var k=e.stateNode.containerInfo;k.nodeType===1?k.textContent="":k.nodeType===9&&k.documentElement&&k.removeChild(k.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(w(163))}}catch(v){Y(e,e.return,v)}if(t=e.sibling,t!==null){t.return=e.return,M=t;break}M=e.return}return h=Df,Df=!1,h}function ci(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&&Ou(e,n,o)}i=i.next}while(i!==r)}}function zl(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 Mu(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 Xp(t){var e=t.alternate;e!==null&&(t.alternate=null,Xp(e)),t.child=null,t.deletions=null,t.sibling=null,t.tag===5&&(e=t.stateNode,e!==null&&(delete e[ft],delete e[Pi],delete e[hu],delete e[S1],delete e[v1])),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 Zp(t){return t.tag===5||t.tag===3||t.tag===4}function Rf(t){e:for(;;){for(;t.sibling===null;){if(t.return===null||Zp(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 Tu(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=Zo));else if(r!==4&&(t=t.child,t!==null))for(Tu(t,e,n),t=t.sibling;t!==null;)Tu(t,e,n),t=t.sibling}function Du(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(Du(t,e,n),t=t.sibling;t!==null;)Du(t,e,n),t=t.sibling}var ue=null,nt=!1;function Bt(t,e,n){for(n=n.child;n!==null;)em(t,e,n),n=n.sibling}function em(t,e,n){if(pt&&typeof pt.onCommitFiberUnmount=="function")try{pt.onCommitFiberUnmount(El,n)}catch{}switch(n.tag){case 5:ge||ur(n,e);case 6:var r=ue,i=nt;ue=null,Bt(t,e,n),ue=r,nt=i,ue!==null&&(nt?(t=ue,n=n.stateNode,t.nodeType===8?t.parentNode.removeChild(n):t.removeChild(n)):ue.removeChild(n.stateNode));break;case 18:ue!==null&&(nt?(t=ue,n=n.stateNode,t.nodeType===8?Cs(t.parentNode,n):t.nodeType===1&&Cs(t,n),Oi(t)):Cs(ue,n.stateNode));break;case 4:r=ue,i=nt,ue=n.stateNode.containerInfo,nt=!0,Bt(t,e,n),ue=r,nt=i;break;case 0:case 11:case 14:case 15:if(!ge&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){i=r=r.next;do{var o=i,l=o.destroy;o=o.tag,l!==void 0&&(o&2||o&4)&&Ou(n,e,l),i=i.next}while(i!==r)}Bt(t,e,n);break;case 1:if(!ge&&(ur(n,e),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(s){Y(n,e,s)}Bt(t,e,n);break;case 21:Bt(t,e,n);break;case 22:n.mode&1?(ge=(r=ge)||n.memoizedState!==null,Bt(t,e,n),ge=r):Bt(t,e,n);break;default:Bt(t,e,n)}}function Pf(t){var e=t.updateQueue;if(e!==null){t.updateQueue=null;var n=t.stateNode;n===null&&(n=t.stateNode=new L1),e.forEach(function(r){var i=H1.bind(null,t,r);n.has(r)||(n.add(r),r.then(i,i))})}}function et(t,e){var n=e.deletions;if(n!==null)for(var r=0;ri&&(i=l),r&=~o}if(r=i,r=X()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*_1(r/1960))-r,10t?16:t,Ht===null)var r=!1;else{if(t=Ht,Ht=null,dl=0,V&6)throw Error(w(331));var i=V;for(V|=4,M=t.current;M!==null;){var o=M,l=o.child;if(M.flags&16){var s=o.deletions;if(s!==null){for(var u=0;uX()-ba?zn(t,0):_a|=n),Ae(t,e)}function um(t,e){e===0&&(t.mode&1?(e=so,so<<=1,!(so&130023424)&&(so=4194304)):e=1);var n=xe();t=At(t,e),t!==null&&(Hi(t,e,n),Ae(t,n))}function J1(t){var e=t.memoizedState,n=0;e!==null&&(n=e.retryLane),um(t,n)}function H1(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(w(314))}r!==null&&r.delete(e),um(t,n)}var am;am=function(t,e,n){if(t!==null)if(t.memoizedProps!==e.pendingProps||Pe.current)Re=!0;else{if(!(t.lanes&n)&&!(e.flags&128))return Re=!1,A1(t,e,n);Re=!!(t.flags&131072)}else Re=!1,H&&e.flags&1048576&&dp(e,rl,e.index);switch(e.lanes=0,e.tag){case 2:var r=e.type;Ao(t,e),t=e.pendingProps;var i=wr(e,Se.current);pr(e,n),i=Aa(null,e,r,t,i,n);var o=Ia();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,ze(r)?(o=!0,tl(e)):o=!1,e.memoizedState=i.state!==null&&i.state!==void 0?i.state:null,Ta(e),i.updater=Rl,e.stateNode=i,i._reactInternals=e,Su(e,r,t,n),e=xu(null,e,r,!0,o,n)):(e.tag=0,H&&o&&wa(e),ve(null,e,i,n),e=e.child),e;case 16:r=e.elementType;e:{switch(Ao(t,e),t=e.pendingProps,i=r._init,r=i(r._payload),e.type=r,i=e.tag=Q1(r),t=tt(r,t),i){case 0:e=wu(null,e,r,t,n);break e;case 1:e=Of(null,e,r,t,n);break e;case 11:e=Ef(null,e,r,t,n);break e;case 14:e=Nf(null,e,r,tt(r.type,t),n);break e}throw Error(w(306,r,""))}return e;case 0:return r=e.type,i=e.pendingProps,i=e.elementType===r?i:tt(r,i),wu(t,e,r,i,n);case 1:return r=e.type,i=e.pendingProps,i=e.elementType===r?i:tt(r,i),Of(t,e,r,i,n);case 3:e:{if(Hp(e),t===null)throw Error(w(387));r=e.pendingProps,o=e.memoizedState,i=o.element,gp(t,e),ll(e,r,null,n);var l=e.memoizedState;if(r=l.element,o.isDehydrated)if(o={element:r,isDehydrated:!1,cache:l.cache,pendingSuspenseBoundaries:l.pendingSuspenseBoundaries,transitions:l.transitions},e.updateQueue.baseState=o,e.memoizedState=o,e.flags&256){i=Nr(Error(w(423)),e),e=Mf(t,e,r,n,i);break e}else if(r!==i){i=Nr(Error(w(424)),e),e=Mf(t,e,r,n,i);break e}else for(_e=Gt(e.stateNode.containerInfo.firstChild),$e=e,H=!0,rt=null,n=vp(e,null,r,n),e.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(xr(),r===i){e=It(t,e,n);break e}ve(t,e,r,n)}e=e.child}return e;case 5:return wp(e),t===null&&gu(e),r=e.type,i=e.pendingProps,o=t!==null?t.memoizedProps:null,l=i.children,fu(r,i)?l=null:o!==null&&fu(r,o)&&(e.flags|=32),Jp(t,e),ve(t,e,l,n),e.child;case 6:return t===null&&gu(e),null;case 13:return Kp(t,e,n);case 4:return Da(e,e.stateNode.containerInfo),r=e.pendingProps,t===null?e.child=Cr(e,null,r,n):ve(t,e,r,n),e.child;case 11:return r=e.type,i=e.pendingProps,i=e.elementType===r?i:tt(r,i),Ef(t,e,r,i,n);case 7:return ve(t,e,e.pendingProps,n),e.child;case 8:return ve(t,e,e.pendingProps.children,n),e.child;case 12:return ve(t,e,e.pendingProps.children,n),e.child;case 10:e:{if(r=e.type._context,i=e.pendingProps,o=e.memoizedProps,l=i.value,W(il,r._currentValue),r._currentValue=l,o!==null)if(st(o.value,l)){if(o.children===i.children&&!Pe.current){e=It(t,e,n);break e}}else for(o=e.child,o!==null&&(o.return=e);o!==null;){var s=o.dependencies;if(s!==null){l=o.child;for(var u=s.firstContext;u!==null;){if(u.context===r){if(o.tag===1){u=Dt(-1,n&-n),u.tag=2;var a=o.updateQueue;if(a!==null){a=a.shared;var c=a.pending;c===null?u.next=u:(u.next=c.next,c.next=u),a.pending=u}}o.lanes|=n,u=o.alternate,u!==null&&(u.lanes|=n),yu(o.return,n,e),s.lanes|=n;break}u=u.next}}else if(o.tag===10)l=o.type===e.type?null:o.child;else if(o.tag===18){if(l=o.return,l===null)throw Error(w(341));l.lanes|=n,s=l.alternate,s!==null&&(s.lanes|=n),yu(l,n,e),l=o.sibling}else l=o.child;if(l!==null)l.return=o;else for(l=o;l!==null;){if(l===e){l=null;break}if(o=l.sibling,o!==null){o.return=l.return,l=o;break}l=l.return}o=l}ve(t,e,i.children,n),e=e.child}return e;case 9:return i=e.type,r=e.pendingProps.children,pr(e,n),i=Xe(i),r=r(i),e.flags|=1,ve(t,e,r,n),e.child;case 14:return r=e.type,i=tt(r,e.pendingProps),i=tt(r.type,i),Nf(t,e,r,i,n);case 15:return Up(t,e,e.type,e.pendingProps,n);case 17:return r=e.type,i=e.pendingProps,i=e.elementType===r?i:tt(r,i),Ao(t,e),e.tag=1,ze(r)?(t=!0,tl(e)):t=!1,pr(e,n),kp(e,r,i),Su(e,r,i,n),xu(null,e,r,!0,t,n);case 19:return Qp(t,e,n);case 22:return jp(t,e,n)}throw Error(w(156,e.tag))};function cm(t,e){return Lh(t,e)}function K1(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 qe(t,e,n,r){return new K1(t,e,n,r)}function ja(t){return t=t.prototype,!(!t||!t.isReactComponent)}function Q1(t){if(typeof t=="function")return ja(t)?1:0;if(t!=null){if(t=t.$$typeof,t===aa)return 11;if(t===ca)return 14}return 2}function tn(t,e){var n=t.alternate;return n===null?(n=qe(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 Lo(t,e,n,r,i,o){var l=2;if(r=t,typeof t=="function")ja(t)&&(l=1);else if(typeof t=="string")l=5;else e:switch(t){case Zn:return An(n.children,i,o,e);case ua:l=8,i|=8;break;case Us:return t=qe(12,n,e,i|2),t.elementType=Us,t.lanes=o,t;case js:return t=qe(13,n,e,i),t.elementType=js,t.lanes=o,t;case Js:return t=qe(19,n,e,i),t.elementType=Js,t.lanes=o,t;case Sh:return Il(n,i,o,e);default:if(typeof t=="object"&&t!==null)switch(t.$$typeof){case yh:l=10;break e;case kh:l=9;break e;case aa:l=11;break e;case ca:l=14;break e;case _t:l=16,r=null;break e}throw Error(w(130,t==null?t:typeof t,""))}return e=qe(l,n,e,i),e.elementType=t,e.type=r,e.lanes=o,e}function An(t,e,n,r){return t=qe(7,t,r,e),t.lanes=n,t}function Il(t,e,n,r){return t=qe(22,t,r,e),t.elementType=Sh,t.lanes=n,t.stateNode={isHidden:!1},t}function Ps(t,e,n){return t=qe(6,t,null,e),t.lanes=n,t}function zs(t,e,n){return e=qe(4,t.children!==null?t.children:[],t.key,e),e.lanes=n,e.stateNode={containerInfo:t.containerInfo,pendingChildren:null,implementation:t.implementation},e}function q1(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=ds(0),this.expirationTimes=ds(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=ds(0),this.identifierPrefix=r,this.onRecoverableError=i,this.mutableSourceEagerHydrationData=null}function Ja(t,e,n,r,i,o,l,s,u){return t=new q1(t,e,n,s,u),e===1?(e=1,o===!0&&(e|=8)):e=0,o=qe(3,null,null,e),t.current=o,o.stateNode=t,o.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},Ta(o),t}function Y1(t,e,n){var r=3"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(pm)}catch(t){console.error(t)}}pm(),dh.exports=Ue;var Vi=dh.exports,mm,_f=Vi;mm=_f.createRoot,_f.hydrateRoot;const _l=O.createContext(null);_l.Provider;function gm(){const[,t]=O.useReducer(e=>e+1,0);return t}const tk=()=>{const t=O.useRef(new Set).current,e=O.useRef(new Set).current,n=gm(),r=O.useRef(!0),i=O.useCallback(()=>{r.current||(n(),r.current=!0)},[n]),o=O.useCallback(l=>{let s;const u=()=>{s=l()};return t.add(u),i(),()=>{t.delete(u),s&&(e.add(s),i())}},[t,e,i]);return O.useLayoutEffect(()=>(r.current=!1,t.forEach(l=>l()),t.clear(),()=>{e.forEach(l=>l()),e.clear()})),o},nk=O.createContext(null);function rk({children:t}){const e=tk();return L(nk.Provider,{value:e,children:t})}const ym=O.createContext(null);function ik(t){const e={};for(const[r,i]of t.entries()){let o=function(l,s){for(const u of i){let a=!1;if(Vi.unstable_batchedUpdates(()=>{a=!!u.call(this,l,s)}),a||s.defaultPrevented)return!0}return!1};e[r]=o}return new Cl({key:new oh("@nytimes/react-prosemirror/componentEventListeners"),props:{handleDOMEvents:e}})}function ok(){const[t,e]=O.useState(new Map),n=O.useCallback((o,l)=>{const s=t.get(o)??[];s.unshift(l),t.has(o)||(t.set(o,s),e(new Map(t)))},[t]),r=O.useCallback((o,l)=>{const s=t.get(o);s==null||s.splice(s.indexOf(l),1)},[t]),i=O.useMemo(()=>ik(t),[t]);return{registerEventListener:n,unregisterEventListener:r,componentEventListenersPlugin:i}}const we=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},_i=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let bf=null;const xt=function(t,e,n){let r=bf||(bf=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r},Wn=function(t,e,n,r){return n&&($f(t,e,n,r,-1)||$f(t,e,n,r,1))},lk=/^(img|br|input|textarea|hr)$/i;function $f(t,e,n,r,i){for(;;){if(t==n&&e==r)return!0;if(e==(i<0?0:dt(t))){let o=t.parentNode;if(!o||o.nodeType!=1||qa(t)||lk.test(t.nodeName)||t.contentEditable=="false")return!1;e=we(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?dt(t):0}else return!1}}function dt(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function sk(t,e,n){for(let r=e==0,i=e==dt(t);r||i;){if(t==n)return!0;let o=we(t);if(t=t.parentNode,!t)return!1;r=r&&o==0,i=i&&o==dt(t)}}function qa(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 bl=function(t){return t.focusNode&&Wn(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function vn(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}function uk(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function ak(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 kt=typeof navigator<"u"?navigator:null,Wf=typeof document<"u"?document:null,hn=kt&&kt.userAgent||"",Iu=/Edge\/(\d+)/.exec(hn),km=/MSIE \d/.exec(hn),Fu=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(hn),Ie=!!(km||Fu||Iu),nn=km?document.documentMode:Fu?+Fu[1]:Iu?+Iu[1]:0,ut=!Ie&&/gecko\/(\d+)/i.test(hn);ut&&+(/Firefox\/(\d+)/.exec(hn)||[0,0])[1];const Lu=!Ie&&/Chrome\/(\d+)/.exec(hn),ye=!!Lu,ck=Lu?+Lu[1]:0,Ce=!Ie&&!!kt&&/Apple Computer/.test(kt.vendor),Mr=Ce&&(/Mobile\/\w+/.test(hn)||!!kt&&kt.maxTouchPoints>2),Je=Mr||(kt?/Mac/.test(kt.platform):!1),fk=kt?/Win/.test(kt.platform):!1,it=/Android \d/.test(hn),$l=!!Wf&&"webkitFontSmoothing"in Wf.documentElement.style,dk=$l?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function hk(t){return{left:0,right:t.documentElement.clientWidth,top:0,bottom:t.documentElement.clientHeight}}function vt(t,e){return typeof t=="number"?t:t[e]}function pk(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 Uf(t,e,n){let r=t.someProp("scrollThreshold")||0,i=t.someProp("scrollMargin")||5,o=t.dom.ownerDocument;for(let l=n||t.dom;l;l=_i(l)){if(l.nodeType!=1)continue;let s=l,u=s==o.body,a=u?hk(o):pk(s),c=0,f=0;if(e.topa.bottom-vt(r,"bottom")&&(f=e.bottom-e.top>a.bottom-a.top?e.top+vt(i,"top")-a.top:e.bottom-a.bottom+vt(i,"bottom")),e.lefta.right-vt(r,"right")&&(c=e.right-a.right+vt(i,"right")),c||f)if(u)o.defaultView.scrollBy(c,f);else{let d=s.scrollLeft,p=s.scrollTop;f&&(s.scrollTop+=f),c&&(s.scrollLeft+=c);let h=s.scrollLeft-d,y=s.scrollTop-p;e={left:e.left-h,top:e.top-y,right:e.right-h,bottom:e.bottom-y}}if(u||/^(fixed|sticky)$/.test(getComputedStyle(l).position))break}}function Sm(t){let e=t.dom.getBoundingClientRect(),n=Math.max(0,e.top),r,i;for(let o=(e.left+e.right)/2,l=n+1;l=n-20){r=s,i=u.top;break}}return{refDOM:r,refTop:i,stack:vm(t.dom)}}function vm(t){let e=[],n=t.ownerDocument;for(let r=t;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t!=n);r=_i(r));return e}function wm({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;xm(n,r==0?0:r-e)}function xm(t,e){for(let n=0;n=s){l=Math.max(h.bottom,l),s=Math.min(h.top,s);let y=h.left>e.left?h.left-e.left:h.right=(h.left+h.right)/2?1:0));continue}}else h.top>e.top&&!u&&h.left<=e.left&&h.right>=e.left&&(u=c,a={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&&u&&(n=u,i=a,r=0),n&&n.nodeType==3?gk(n,i):!n||r&&n.nodeType==1?{node:t,offset:o}:Cm(n,i)}function gk(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 Ya(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function yk(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left(l.left+l.right)/2?1:-1}return t.docView.posFromDOM(r,i,o)}function Sk(t,e,n,r){let i=-1;for(let o=e,l=!1;o!=t.dom;){let s=t.docView.nearestDesc(o,!0);if(!s)return null;if(s.dom.nodeType==1&&(s.node.isBlock&&s.parent&&!l||!s.contentDOM)){let u=s.dom.getBoundingClientRect();if(s.node.isBlock&&s.parent&&!l&&(l=!0,u.left>r.left||u.top>r.top?i=s.posBefore:(u.right-1?i:t.docView.posFromDOM(e,n,-1)}function Em(t,e,n){let r=t.childNodes.length;if(r&&n.tope.top&&i++}r==t.dom&&i==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?s=t.state.doc.content.size:(i==0||r.nodeType!=1||r.childNodes[i-1].nodeName!="BR")&&(s=Sk(t,r,i,e))}s==null&&(s=kk(t,l,e));let u=t.docView.nearestDesc(l,!0);return{pos:s,inside:u?u.posAtStart-u.border:-1}}function jf(t){return t.top=0&&i==r.nodeValue.length?(u--,c=1):n<0?u--:a++,Wr(Vt(xt(r,u,a),c),c<0)}if(!t.state.doc.resolve(e-(o||0)).parent.inlineContent){if(o==null&&i&&(n<0||i==dt(r))){let u=r.childNodes[i-1];if(u.nodeType==1)return As(u.getBoundingClientRect(),!1)}if(o==null&&i=0)}if(o==null&&i&&(n<0||i==dt(r))){let u=r.childNodes[i-1],a=u.nodeType==3?xt(u,dt(u)-(l?0:1)):u.nodeType==1&&(u.nodeName!="BR"||!u.nextSibling)?u:null;if(a)return Wr(Vt(a,1),!1)}if(o==null&&i=0)}function Wr(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 As(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 Om(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 xk(t,e,n){let r=e.selection,i=n=="up"?r.$from:r.$to;return Om(t,e,()=>{let{node:o}=t.docView.domFromPos(i.pos,n=="up"?-1:1);for(;;){let s=t.docView.nearestDesc(o,!0);if(!s)break;if(s.node.isBlock){o=s.contentDOM||s.dom;break}o=s.dom.parentNode}let l=Nm(t,i.pos,1);for(let s=o.firstChild;s;s=s.nextSibling){let u;if(s.nodeType==1)u=s.getClientRects();else if(s.nodeType==3)u=xt(s,0,s.nodeValue.length).getClientRects();else continue;for(let a=0;ac.top+1&&(n=="up"?l.top-c.top>(c.bottom-l.top)*2:c.bottom-l.bottom>(l.bottom-c.top)*2))return!1}}return!0})}const Ck=/[\u0590-\u08ac]/;function Ek(t,e,n){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let i=r.parentOffset,o=!i,l=i==r.parent.content.size,s=t.domSelection();return!Ck.test(r.parent.textContent)||!s.modify?n=="left"||n=="backward"?o:l:Om(t,e,()=>{let{focusNode:u,focusOffset:a,anchorNode:c,anchorOffset:f}=t.domSelectionRange(),d=s.caretBidiLevel;s.modify("move",n,"character");let p=r.depth?t.docView.domAfterPos(r.before()):t.dom,{focusNode:h,focusOffset:y}=t.domSelectionRange(),S=h&&!p.contains(h.nodeType==1?h:h.parentNode)||u==h&&a==y;try{s.collapse(c,f),u&&(u!=c||a!=f)&&s.extend&&s.extend(u,a)}catch{}return d!=null&&(s.caretBidiLevel=d),S})}let Jf=null,Hf=null,Kf=!1;function Nk(t,e,n){return Jf==e&&Hf==n?Kf:(Jf=e,Hf=n,Kf=n=="up"||n=="down"?xk(t,e,n):Ek(t,e,n))}const Ge=0,Qf=1,Nn=2,St=3;class Yi{constructor(e,n,r,i){this.parent=e,this.children=n,this.dom=r,this.contentDOM=i,this.dirty=Ge,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;nwe(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),l;if(o&&(!n||o.node))if(r&&(l=o.nodeDOM)&&!(l.nodeType==1?l.contains(e.nodeType==1?e:e.parentNode):l==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||l instanceof Xa){i=e-o;break}o=s}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 Ga&&o.side>=0;r--);if(n<=0){let o,l=!0;for(;o=r?this.children[r-1]:null,!(!o||o.dom.parentNode==this.contentDOM);r--,l=!1);return o&&n&&l&&!o.border&&!o.domAtom?o.domFromPos(o.size,n):{node:this.contentDOM,offset:o?we(o.dom)+1:0}}else{let o,l=!0;for(;o=r=c&&n<=a-u.border&&u.node&&u.contentDOM&&this.contentDOM.contains(u.contentDOM))return u.parseRange(e,n,c);e=l;for(let f=s;f>0;f--){let d=this.children[f-1];if(d.size&&d.dom.parentNode==this.contentDOM&&!d.emptyChildAt(1)){i=we(d.dom)+1;break}e-=d.size}i==-1&&(i=0)}if(i>-1&&(a>n||s==this.children.length-1)){n=a;for(let c=s+1;cp&&ln){let p=s;s=u,u=p}let d=document.createRange();d.setEnd(u.node,u.offset),d.setStart(s.node,s.offset),a.removeAllRanges(),a.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 s=r+o.border,u=l-o.border;if(e>=s&&n<=u){this.dirty=e==r||n==l?Nn:Qf,e==s&&n==u&&(o.contentLost||o.dom.parentNode!=this.contentDOM)?o.dirty=St:o.markDirty(e-s,n-s);return}else o.dirty=o.dom==o.contentDOM&&o.dom.parentNode==this.contentDOM&&!o.children.length?Nn:St}r=l}this.dirty=Nn}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let r=e==1?Nn:Qf;n.dirty0&&(o=_u(o,0,e,r));for(let s=0;s{if(!u)return l;if(u.parent)return u.parent.posBeforeChild(u)},r,i),c=a&&a.dom,f=a&&a.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}=Ot.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=Dm(c,r,n),a?u=new Mk(e,n,r,i,c,f||null,d,a,o,l+1):n.isText?new Tr(e,[],n,r,i,c,d):new gt(e,[],n,r,i,c,f||null,d)}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=()=>x.empty)}return e}matchesNode(e,n,r){return this.dirty==Ge&&e.eq(this.node)&&Vu(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,l=o&&o.pos>-1?o:null,s=o&&o.pos<0,u=new Dk(this,l&&l.node,e);zk(this.node,this.innerDeco,(a,c,f)=>{a.spec.marks?u.syncToMarks(a.spec.marks,r,e):a.type.side>=0&&!f&&u.syncToMarks(c==this.node.childCount?_.none:this.node.child(c).marks,r,e),u.placeWidget(a,e,i)},(a,c,f,d)=>{u.syncToMarks(a.marks,r,e);let p;u.findNodeMatch(a,c,f,d)||s&&e.state.selection.from>i&&e.state.selection.to-1&&u.updateNodeAt(a,c,f,p,e)||u.updateNextNode(a,c,f,e,d,i)||u.addNode(a,c,f,e,i),i+=a.nodeSize}),u.syncToMarks([],r,e),this.node.isTextblock&&u.addTextblockHacks(),u.destroyRest(),(u.changed||this.dirty==Nn)&&(l&&this.protectLocalComposition(e,l),Mm(this.contentDOM,this.children,e),Mr&&Ak(this.dom))}localCompositionInfo(e,n){let{from:r,to:i}=e.state.selection;if(!(e.state.selection instanceof U)||rn+this.node.content.size)return null;let o=e.domSelectionRange(),l=Ik(o.focusNode,o.focusOffset);if(!l||!this.dom.contains(l.parentNode))return null;if(this.node.inlineContent){let s=l.nodeValue,u=Fk(this.node.content,s,r-n,i-n);return u<0?null:{node:l,pos:u,text:s}}else return{node:l,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 l=new Ok(this,o,n,i);e.input.compositionNodes.push(l),this.children=_u(this.children,r,r+i.length,e,l)}update(e,n,r,i){return this.dirty==St||!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=Ge}updateOuterDeco(e){if(Vu(e,this.outerDeco))return;let n=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=Tm(this.dom,this.nodeDOM,Bu(this.outerDeco,this.node,n),Bu(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 Is(t,e,n,r,i){Dm(r,e,t);let o=new gt(void 0,[],t,e,n,r,r,r);return o.contentDOM&&o.updateChildren(i,0),o}class Tr extends gt{constructor(e,n,r,i,o,l,s){super(e,n,r,i,o,l,null,s)}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==St||this.dirty!=Ge&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=Ge||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=Ge,!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 Tr(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=St)}get domAtom(){return!1}}class Xa extends Yi{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==Ge&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class Mk extends gt{constructor(e,n,r,i,o,l,s,u,a,c){super(e,[],n,r,i,o,l,s),this.spec=u}update(e,n,r,i){if(this.dirty==St)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 Mm(t,e,n){let r=t.firstChild,i=!1;for(let o=0;o>1,l=Math.min(o,e.length);for(;i-1)s>this.index&&(this.changed=!0,this.destroyBetween(this.index,s)),this.top=this.top.children[this.index];else{let u=un.create(this.top,e[o],n,r);this.top.children.splice(this.index,0,u),this.top=u,this.changed=!0}this.index=0,o++}}findNodeMatch(e,n,r,i){let o=-1,l;if(i>=this.preMatch.index&&(l=this.preMatch.matches[i-this.preMatch.index]).parent==this.top&&l.matchesNode(e,n,r))o=this.top.children.indexOf(l,this.index);else for(let s=this.index,u=Math.min(this.top.children.length,s+5);s0;){let s;for(;;)if(r){let a=n.children[r-1];if(a instanceof un)n=a,r=a.children.length;else{s=a,r--;break}}else{if(n==e)break e;r=n.parent.children.indexOf(n),n=n.parent}let u=s.node;if(u){if(u!=t.child(i-1))break;--i,o.set(s,i),l.push(s)}}return{index:i,matched:o,matches:l.reverse()}}function Pk(t,e){return t.type.side-e.type.side}function zk(t,e,n,r){let i=e.locals(t),o=0;if(i.length==0){for(let a=0;ao;)s.push(i[l++]);let d=o+c.nodeSize;if(c.isText){let h=d;l!h.inline):s.slice();r(c,p,e.forChild(o,c),f),o=d}}function Ak(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 Ik(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=dt(t)}else if(t.nodeType==1&&e=n){let a=s=0&&a+e.length+s>=n)return s+a;if(n==r&&u.length>=r+e.length-s&&u.slice(r-s,r-s+e.length)==e)return r}}return-1}function _u(t,e,n,r,i){let o=[];for(let l=0,s=0;l=n||c<=e?o.push(u):(an&&o.push(u.slice(n-a,u.size,r)))}return o}const Rm=65535,Pm=Math.pow(2,16);function Lk(t,e){return t+e*Pm}function Yf(t){return t&Rm}function Bk(t){return(t-(t&Rm))/Pm}const zm=1,Am=2,Bo=4,Im=8;class Gf{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&Im)>0}get deletedBefore(){return(this.delInfo&(zm|Bo))>0}get deletedAfter(){return(this.delInfo&(Am|Bo))>0}get deletedAcross(){return(this.delInfo&Bo)>0}}class Qe{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&Qe.empty)return Qe.empty}recover(e){let n=0,r=Yf(e);if(!this.inverted)for(let i=0;ie)break;let a=this.ranges[s+o],c=this.ranges[s+l],f=u+a;if(e<=f){let d=a?e==u?-1:e==f?1:n:n,p=u+i+(d<0?0:c);if(r)return p;let h=e==(n<0?u:f)?null:Lk(s/3,e-u),y=e==u?Am:e==f?zm:Bo;return(n<0?e!=u:e!=f)&&(y|=Im),new Gf(p,y,h)}i+=c-a}return r?e+i:new Gf(e+i,0,null)}touches(e,n){let r=0,i=Yf(n),o=this.inverted?2:1,l=this.inverted?1:2;for(let s=0;se)break;let a=this.ranges[s+o],c=u+a;if(e<=c&&s==i*3)return!0;r+=this.ranges[s+l]-a}return!1}forEach(e){let n=this.inverted?2:1,r=this.inverted?1:2;for(let i=0,o=0;i!l.isAtom||!s.type.allowsMarkType(this.mark.type)?l:l.mark(this.mark.addToSet(l.marks)),i),n.openStart,n.openEnd);return ne.fromReplace(e,this.from,this.to,o)}invert(){return new Tn(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 Mn(n.pos,r.pos,this.mark)}merge(e){return e instanceof Mn&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Mn(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 Mn(n.from,n.to,e.markFromJSON(n.mark))}}Be.jsonID("addMark",Mn);class Tn extends Be{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 C(Za(n.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),n.openStart,n.openEnd);return ne.fromReplace(e,this.from,this.to,r)}invert(){return new Mn(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 Tn(n.pos,r.pos,this.mark)}merge(e){return e instanceof Tn&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Tn(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 Tn(n.from,n.to,e.markFromJSON(n.mark))}}Be.jsonID("removeMark",Tn);class Dn extends Be{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return ne.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return ne.fromReplace(e,this.pos,this.pos+1,new C(x.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 pi(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 pi(n.from,n.to,n.gapFrom,n.gapTo,C.fromJSON(e,n.slice),n.insert,!!n.structure)}}Be.jsonID("replaceAround",pi);function bu(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 l=r.node(o).maybeChild(r.indexAfter(o));for(;i>0;){if(!l||l.isLeaf)return!0;l=l.firstChild,i--}}return!1}function Vk(t,e,n){let r=t.resolve(e);if(!n.content.size)return e;let i=n.content;for(let o=0;o=0;l--){let s=l==r.depth?0:r.pos<=(r.start(l+1)+r.end(l+1))/2?-1:1,u=r.index(l)+(s>0?1:0),a=r.node(l),c=!1;if(o==1)c=a.canReplace(u,u,i);else{let f=a.contentMatchAt(u).findWrapping(i.firstChild.type);c=f&&a.canReplaceWith(u,u,f[0])}if(c)return s==0?r.pos:s<0?r.before(l+1):r.after(l+1)}return null}class mi extends Be{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 ne.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 ne.fromReplace(e,this.pos,this.pos+1,new C(x.from(i),0,n.isLeaf?0:1))}getMap(){return Qe.empty}invert(e){return new mi(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 mi(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 mi(n.pos,n.attr,n.value)}}Be.jsonID("attr",mi);let $i=class extends Error{};$i=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};$i.prototype=Object.create(Error.prototype);$i.prototype.constructor=$i;$i.prototype.name="TransformError";function ec(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,l=t.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(l<0)return null;let s=r.resolve(l),u,a;if(bl(n)){for(u=s;i&&!i.node;)i=i.parent;let c=i.node;if(i&&c.isAtom&&A.isSelectable(c)&&i.parent&&!(c.isInline&&sk(n.focusNode,n.focusOffset,i.dom))){let f=i.posBefore;a=new A(l==f?s:r.resolve(f))}}else{let c=t.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(c<0)return null;u=r.resolve(c)}if(!a){let c=e=="pointer"||t.state.selection.head{(n.anchorNode!=r||n.anchorOffset!=i)&&(e.removeEventListener("selectionchange",t.input.hideSelectionGuard),setTimeout(()=>{(!Fm(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function bk(t){let e=t.domSelection(),n=document.createRange(),r=t.cursorWrapper.dom,i=r.nodeName=="IMG";i?n.setEnd(r.parentNode,we(r)+1):n.setEnd(r,0),n.collapse(!1),e.removeAllRanges(),e.addRange(n),!i&&!t.state.selection.visible&&Ie&&nn<=11&&(r.disabled=!0,r.disabled=!1)}function Lm(t,e){if(e instanceof A){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(td(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else td(t)}function td(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function tc(t,e,n,r){return t.someProp("createSelectionBetween",i=>i(t,e,n))||U.between(e,n,r)}function nd(t){return t.editable&&!t.hasFocus()?!1:Bm(t)}function Bm(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 $k(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return Wn(e.node,e.offset,n.anchorNode,n.anchorOffset)}function $u(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&&b.findFrom(o,e)}function wn(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function rd(t,e,n){let r=t.state.selection;if(r instanceof U){if(!r.empty||n.indexOf("s")>-1)return!1;if(t.endOfTextblock(e>0?"forward":"backward")){let i=$u(t.state,e);return i&&i instanceof A?wn(t,i):!1}else if(!(Je&&n.indexOf("m")>-1)){let i=r.$head,o=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter,l;if(!o||o.isText)return!1;let s=e<0?i.pos-o.nodeSize:i.pos;return o.isAtom||(l=t.docView.descAt(s))&&!l.contentDOM?A.isSelectable(o)?wn(t,new A(e<0?t.state.doc.resolve(i.pos-o.nodeSize):i)):$l?wn(t,new U(t.state.doc.resolve(e<0?s:s+o.nodeSize))):!1:!1}}else{if(r instanceof A&&r.node.isInline)return wn(t,new U(e>0?r.$to:r.$from));{let i=$u(t.state,e);return i?wn(t,i):!1}}}function ml(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function gi(t,e){if(t.contentEditable=="false")return!0;let n=t.pmViewDesc;return n&&n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function Kn(t,e){return e<0?Wk(t):Uk(t)}function Wk(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i,o,l=!1;for(ut&&n.nodeType==1&&r0){if(n.nodeType!=1)break;{let s=n.childNodes[r-1];if(gi(s,-1))i=n,o=--r;else if(s.nodeType==3)n=s,r=n.nodeValue.length;else break}}else{if(Vm(n))break;{let s=n.previousSibling;for(;s&&gi(s,-1);)i=n.parentNode,o=we(s),s=s.previousSibling;if(s)n=s,r=ml(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}l?Wu(t,n,r):i&&Wu(t,i,o)}function Uk(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let i=ml(n),o,l;for(;;)if(r{t.state==i&&yt(t)},50)}function id(t,e){let n=t.state.doc.resolve(e);if(!(ye||fk)&&n.parent.inlineContent){let i=t.coordsAtPos(e);if(e>n.start()){let o=t.coordsAtPos(e-1),l=(o.top+o.bottom)/2;if(l>i.top&&l1)return o.lefti.top&&l1)return o.left>i.left?"ltr":"rtl"}}return getComputedStyle(t.dom).direction=="rtl"?"rtl":"ltr"}function od(t,e,n){let r=t.state.selection;if(r instanceof U&&!r.empty||n.indexOf("s")>-1||Je&&n.indexOf("m")>-1)return!1;let{$from:i,$to:o}=r;if(!i.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let l=$u(t.state,e);if(l&&l instanceof A)return wn(t,l)}if(!i.parent.inlineContent){let l=e<0?i:o,s=r instanceof be?b.near(l,e):b.findFrom(l,e);return s?wn(t,s):!1}return!1}function ld(t,e){if(!(t.state.selection instanceof U))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 l=t.state.tr;return e<0?l.delete(n.pos-o.nodeSize,n.pos):l.delete(n.pos,n.pos+o.nodeSize),t.dispatch(l),!0}return!1}function sd(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function Hk(t){if(!Ce||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;sd(t,r,"true"),setTimeout(()=>sd(t,r,"false"),20)}return!1}function Kk(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function Qk(t,e){let n=e.keyCode,r=Kk(e);if(n==8||Je&&n==72&&r=="c")return ld(t,-1)||Kn(t,-1);if(n==46&&!e.shiftKey||Je&&n==68&&r=="c")return ld(t,1)||Kn(t,1);if(n==13||n==27)return!0;if(n==37||Je&&n==66&&r=="c"){let i=n==37?id(t,t.state.selection.from)=="ltr"?-1:1:-1;return rd(t,i,r)||Kn(t,i)}else if(n==39||Je&&n==70&&r=="c"){let i=n==39?id(t,t.state.selection.from)=="ltr"?1:-1:1;return rd(t,i,r)||Kn(t,i)}else{if(n==38||Je&&n==80&&r=="c")return od(t,-1,r)||Kn(t,-1);if(n==40||Je&&n==78&&r=="c")return Hk(t)||od(t,1,r)||Kn(t,1);if(r==(Je?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function _m(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 l=t.someProp("clipboardSerializer")||Ot.fromSchema(t.state.schema),s=Jm(),u=s.createElement("div");u.appendChild(l.serializeFragment(r,{document:s}));let a=u.firstChild,c,f=0;for(;a&&a.nodeType==1&&(c=jm[a.nodeName.toLowerCase()]);){for(let p=c.length-1;p>=0;p--){let h=s.createElement(c[p]);for(;u.firstChild;)h.appendChild(u.firstChild);u.appendChild(h),f++}a=u.firstChild}a&&a.nodeType==1&&a.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:u,text:d}}function bm(t,e,n,r,i){let o=i.parent.type.spec.code,l,s;if(!n&&!e)return null;let u=e&&(r||o||!n);if(u){if(t.someProp("transformPastedText",d=>{e=d(e,o||r,t)}),o)return e?new C(x.from(t.state.schema.text(e.replace(/\r\n?/g,` -`))),0,0):C.empty;let f=t.someProp("clipboardTextParser",d=>d(e,i,r,t));if(f)s=f;else{let d=i.marks(),{schema:p}=t.state,h=Nt.fromSchema(p);l=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(y=>{let S=l.appendChild(document.createElement("p"));y&&S.appendChild(h.serializeNode(p.text(y,d)))})}}else t.someProp("transformPastedHTML",f=>{n=f(n,t)}),l=Gk(n),bl&&Xk(l);let a=l&&l.querySelector("[data-pm-slice]"),c=a&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(a.getAttribute("data-pm-slice")||"");if(c&&c[3])for(let f=+c[3];f>0;f--){let d=l.firstChild;for(;d&&d.nodeType!=1;)d=d.nextSibling;if(!d)break;l=d}if(s||(s=(t.someProp("clipboardParser")||t.someProp("domParser")||Si.fromSchema(t.state.schema)).parseSlice(l,{preserveWhitespace:!!(u||c),context:i,ruleFromNode(d){return d.nodeName=="BR"&&!d.nextSibling&&d.parentNode&&!qk.test(d.parentNode.nodeName)?{ignore:!0}:null}})),c)s=Zk(ud(s,+c[1],+c[2]),c[4]);else if(s=C.maxOpen(Yk(s.content,i),!0),s.openStart||s.openEnd){let f=0,d=0;for(let p=s.content.firstChild;f{s=f(s,t)}),s}const qk=/^(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 Yk(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,l=[];if(t.forEach(s=>{if(!l)return;let u=i.findWrapping(s.type),a;if(!u)return l=null;if(a=l.length&&o.length&&Wm(u,o,s,l[l.length-1],0))l[l.length-1]=a;else{l.length&&(l[l.length-1]=Um(l[l.length-1],o.length));let c=$m(s,u);l.push(c),i=i.matchType(c.type),o=u}}),l)return x.from(l)}return t}function $m(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,x.from(t));return t}function Wm(t,e,n,r,i){if(i1&&(o=0),i=n&&(s=e<0?l.contentMatchAt(0).fillBefore(s,o<=i).append(s):s.append(l.contentMatchAt(l.childCount).fillBefore(x.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,l.copy(s))}function ud(t,e,n){return e]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=Jm().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(t),i;if((i=r&&jm[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;s-=2){let u=n.nodes[r[s]];if(!u||u.hasRequiredAttrs())break;i=x.from(u.create(r[s+1],i)),o++,l++}return new C(i,o,l)}const Ee={},Ne={},eS={touchstart:!0,touchmove:!0};class tS{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 nS(t){for(let e in Ee){let n=Ee[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=r=>{iS(t,r)&&!tc(t,r)&&(t.editable||!(r.type in Ne))&&n(t,r)},eS[e]?{passive:!0}:void 0)}Ce&&t.dom.addEventListener("input",()=>null),Wu(t)}function Kt(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function rS(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 Wu(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=r=>tc(t,r))})}function tc(t,e){return t.someProp("handleDOMEvents",n=>{let r=n[e.type];return r?r(t,e)||e.defaultPrevented:!1})}function iS(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 oS(t,e){!tc(t,e)&&Ee[e.type]&&(t.editable||!(e.type in Ne))&&Ee[e.type](t,e)}Ne.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!Km(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(it&&ye&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),Mr&&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,vn(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",r=>r(t,n))||Qk(t,n)?n.preventDefault():Kt(t,"key")};Ne.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};Ne.keypress=(t,e)=>{let n=e;if(Km(t,n)||!n.charCode||n.ctrlKey&&!n.altKey||Je&&n.metaKey)return;if(t.someProp("handleKeyPress",i=>i(t,n))){n.preventDefault();return}let r=t.state.selection;if(!(r instanceof U)||!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 $l(t){return{left:t.clientX,top:t.clientY}}function lS(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function nc(t,e,n,r,i){if(r==-1)return!1;let o=t.state.doc.resolve(r);for(let l=o.depth+1;l>0;l--)if(t.someProp(e,s=>l>o.depth?s(t,n,o.nodeAfter,o.before(l),i,!0):s(t,n,o.node(l),o.before(l),i,!1)))return!0;return!1}function gr(t,e,n){t.focused||t.focus();let r=t.state.tr.setSelection(e);n=="pointer"&&r.setMeta("pointer",!0),t.dispatch(r)}function sS(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&A.isSelectable(r)?(gr(t,new A(n),"pointer"),!0):!1}function uS(t,e){if(e==-1)return!1;let n=t.state.selection,r,i;n instanceof A&&(r=n.node);let o=t.state.doc.resolve(e);for(let l=o.depth+1;l>0;l--){let s=l>o.depth?o.nodeAfter:o.node(l);if(A.isSelectable(s)){r&&n.$from.depth>0&&l>=n.$from.depth&&o.before(n.$from.depth+1)==n.$from.pos?i=o.before(n.$from.depth):i=o.before(l);break}}return i!=null?(gr(t,A.create(t.state.doc,i),"pointer"),!0):!1}function aS(t,e,n,r,i){return nc(t,"handleClickOn",e,n,r)||t.someProp("handleClick",o=>o(t,e,r))||(i?uS(t,n):sS(t,n))}function cS(t,e,n,r){return nc(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",i=>i(t,e,r))}function fS(t,e,n,r){return nc(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",i=>i(t,e,r))||dS(t,n,r)}function dS(t,e,n){if(n.button!=0)return!1;let r=t.state.doc;if(e==-1)return r.inlineContent?(gr(t,U.create(r,0,r.content.size),"pointer"),!0):!1;let i=r.resolve(e);for(let o=i.depth+1;o>0;o--){let l=o>i.depth?i.nodeAfter:i.node(o),s=i.before(o);if(l.inlineContent)gr(t,U.create(r,s+1,s+1+l.content.size),"pointer");else if(A.isSelectable(l))gr(t,A.create(r,s),"pointer");else continue;return!0}}function rc(t){return ml(t)}const Hm=Je?"metaKey":"ctrlKey";Ee.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=rc(t),i=Date.now(),o="singleClick";i-t.input.lastClick.time<500&&lS(n,t.input.lastClick)&&!n[Hm]&&(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 l=t.posAtCoords($l(n));l&&(o=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new hS(t,l,n,!!r)):(o=="doubleClick"?cS:fS)(t,l.pos,l.inside,n)?n.preventDefault():Kt(t,"pointer"))};class hS{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[Hm],this.allowDefault=r.shiftKey;let o,l;if(n.inside>-1)o=e.state.doc.nodeAt(n.inside),l=n.inside;else{let c=e.state.doc.resolve(n.pos);o=c.parent,l=c.depth?c.before():0}const s=i?null:r.target,u=s?e.docView.nearestDesc(s,!0):null;this.target=u?u.dom:null;let{selection:a}=e.state;(r.button==0&&o.type.spec.draggable&&o.type.spec.selectable!==!1||a instanceof A&&a.from<=l&&a.to>l)&&(this.mightDrag={node:o,pos:l,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&ut&&!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)),Kt(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(()=>gt(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($l(e))),this.updateAllowDefault(e),this.allowDefault||!n?Kt(this.view,"pointer"):aS(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||Ce&&this.mightDrag&&!this.mightDrag.node.isAtom||ye&&!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)?(gr(this.view,b.near(this.view.state.doc.resolve(n.pos)),"pointer"),e.preventDefault()):Kt(this.view,"pointer")}move(e){this.updateAllowDefault(e),Kt(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)}}Ee.touchstart=t=>{t.input.lastTouch=Date.now(),rc(t),Kt(t,"pointer")};Ee.touchmove=t=>{t.input.lastTouch=Date.now(),Kt(t,"pointer")};Ee.contextmenu=t=>rc(t);function Km(t,e){return t.composing?!0:Ce&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const pS=it?5e3:-1;Ne.compositionstart=Ne.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(),ml(t,!0),t.markCursor=null;else if(ml(t),ut&&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 l=o<0?i.lastChild:i.childNodes[o-1];if(!l)break;if(l.nodeType==3){t.domSelection().collapse(l,l.nodeValue.length);break}else i=l,o=-1}}t.input.composing=!0}Qm(t,pS)};Ne.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++,Qm(t,20))};function Qm(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>ml(t),e))}function qm(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=mS());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function mS(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function ml(t,e=!1){if(!(it&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),qm(t),e||t.docView&&t.docView.dirty){let n=Za(t);return n&&!n.eq(t.state.selection)?t.dispatch(t.state.tr.setSelection(n)):t.updateState(t.state),!0}return!1}}function gS(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 Dr=Ie&&nn<15||Mr&&dk<604;Ee.copy=Ne.cut=(t,e)=>{let n=e,r=t.state.selection,i=n.type=="cut";if(r.empty)return;let o=Dr?null:n.clipboardData,l=r.content(),{dom:s,text:u}=_m(t,l);o?(n.preventDefault(),o.clearData(),o.setData("text/html",s.innerHTML),o.setData("text/plain",u)):gS(t,s),i&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function yS(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function kS(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=bm(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",u=>u(t,i,o||C.empty)))return!0;if(!o)return!1;let l=yS(o),s=l?t.state.tr.replaceSelectionWith(l,r):t.state.tr.replaceSelection(o);return t.dispatch(s.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}Ne.paste=(t,e)=>{let n=e;if(t.composing&&!it)return;let r=Dr?null:n.clipboardData,i=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&$i(t,r.getData("text/plain"),r.getData("text/html"),i,n)?n.preventDefault():kS(t,n)};class SS{constructor(e,n){this.slice=e,this.move=n}}const Ym=Je?"altKey":"ctrlKey";Ee.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($l(n));if(!(o&&o.pos>=i.from&&o.pos<=(i instanceof A?i.to-1:i.to))){if(r&&r.mightDrag)t.dispatch(t.state.tr.setSelection(A.create(t.state.doc,r.mightDrag.pos)));else if(n.target&&n.target.nodeType==1){let a=t.docView.nearestDesc(n.target,!0);a&&a.node.type.spec.draggable&&a!=t.docView&&t.dispatch(t.state.tr.setSelection(A.create(t.state.doc,a.posBefore)))}}let l=t.state.selection.content(),{dom:s,text:u}=_m(t,l);n.dataTransfer.clearData(),n.dataTransfer.setData(Dr?"Text":"text/html",s.innerHTML),n.dataTransfer.effectAllowed="copyMove",Dr||n.dataTransfer.setData("text/plain",u),t.dragging=new SS(l,!n[Ym])};Ee.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};Ne.dragover=Ne.dragenter=(t,e)=>e.preventDefault();Ne.drop=(t,e)=>{let n=e,r=t.dragging;if(t.dragging=null,!n.dataTransfer)return;let i=t.posAtCoords($l(n));if(!i)return;let o=t.state.doc.resolve(i.pos),l=r&&r.slice;l?t.someProp("transformPasted",h=>{l=h(l,t)}):l=bm(t,n.dataTransfer.getData(Dr?"Text":"text/plain"),Dr?null:n.dataTransfer.getData("text/html"),!1,o);let s=!!(r&&!n[Ym]);if(t.someProp("handleDrop",h=>h(t,n,l||C.empty,s))){n.preventDefault();return}if(!l)return;n.preventDefault();let u=l?Vk(t.state.doc,o.pos,l):o.pos;u==null&&(u=o.pos);let a=t.state.tr;s&&a.deleteSelection();let c=a.mapping.map(u),f=l.openStart==0&&l.openEnd==0&&l.content.childCount==1,d=a.doc;if(f?a.replaceRangeWith(c,c,l.content.firstChild):a.replaceRange(c,c,l),a.doc.eq(d))return;let p=a.doc.resolve(c);if(f&&A.isSelectable(l.content.firstChild)&&p.nodeAfter&&p.nodeAfter.sameMarkup(l.content.firstChild))a.setSelection(new A(p));else{let h=a.mapping.map(u);a.mapping.maps[a.mapping.maps.length-1].forEach((y,S,g,m)=>h=m),a.setSelection(ec(t,p,a.doc.resolve(h)))}t.focus(),t.dispatch(a.setMeta("uiEvent","drop"))};Ee.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)},20))};Ee.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)};Ee.beforeinput=(t,e)=>{if(ye&&it&&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,vn(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 Ne)Ee[t]=Ne[t];function Wi(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 ic{constructor(e,n){this.toDOM=e,this.spec=n||In,this.side=this.spec.side||0}map(e,n,r,i){let{pos:o,deleted:l}=e.mapResult(n.from+i,this.side<0?-1:1);return l?null:new ke(o-r,o-r,this)}valid(){return!0}eq(e){return this==e||e instanceof ic&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Wi(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class rn{constructor(e,n){this.attrs=e,this.spec=n||In}map(e,n,r,i){let o=e.map(n.from+i,this.spec.inclusiveStart?-1:1)-r,l=e.map(n.to+i,this.spec.inclusiveEnd?1:-1)-r;return o>=l?null:new ke(o,l,this)}valid(e,n){return n.from=t&&(!i||i(l.spec))&&n.push(l.copy(l.from+r,l.to+r))}for(let o=0;ot){let l=this.children[o]+1;this.children[o+2].findInner(t-l,e-l,n,r+l,i)}}map(t,e,n){return this==me||t.maps.length==0?this:this.mapInner(t,e,0,0,n||In)}mapInner(t,e,n,r,i){let o;for(let l=0;l{let u=s+n,a;if(a=Xm(e,l,u)){for(r||(r=this.children.slice());il&&c.to=t){this.children[l]==t&&(n=this.children[l+2]);break}let i=t+1,o=i+e.content.size;for(let l=0;li&&s.type instanceof rn){let u=Math.max(i,s.from)-i,a=Math.min(o,s.to)-i;ui.map(e,n,In));return jt.from(r)}forChild(e,n){if(n.isLeaf)return $e.empty;let r=[];for(let i=0;in instanceof $e)?e:e.reduce((n,r)=>n.concat(r instanceof $e?r:r.members),[]))}}}function vS(t,e,n,r,i,o,l){let s=t.slice();for(let a=0,c=o;a{let S=y-h-(p-d);for(let g=0;gm+c-f)continue;let k=s[g]+c-f;p>=k?s[g+1]=d<=k?-2:-1:h>=i&&S&&(s[g]+=S,s[g+1]+=S)}f+=S}),c=n.maps[a].map(c,-1)}let u=!1;for(let a=0;a=r.content.size){u=!0;continue}let d=n.map(t[a+1]+o,-1),p=d-i,{index:h,offset:y}=r.content.findIndex(f),S=r.maybeChild(h);if(S&&y==f&&y+S.nodeSize==p){let g=s[a+2].mapInner(n,S,c+1,t[a]+o+1,l);g!=me?(s[a]=f,s[a+1]=p,s[a+2]=g):(s[a+1]=-2,u=!0)}else u=!0}if(u){let a=wS(s,t,e,n,i,o,l),c=gl(a,r,0,l);e=c.local;for(let f=0;fn&&l.to{let a=Xm(t,s,u+n);if(a){o=!0;let c=gl(a,s,n+u+1,r);c!=me&&i.push(u,u+s.nodeSize,c)}});let l=Gm(o?Zm(t):t,-n).sort(Fn);for(let s=0;s0;)e++;t.splice(e,0,n)}function Bo(t){let e=[];return t.someProp("decorations",n=>{let r=n(t.state);r&&r!=me&&e.push(r)}),t.cursorWrapper&&e.push($e.create(t.state.doc,[t.cursorWrapper.deco])),jt.from(e)}const xS={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},CS=Ie&&nn<=11;class ES{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 NS{constructor(e,n){this.view=e,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new ES,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()}),CS&&(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,xS)),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(nd(this.view)){if(this.suppressingSelectionUpdates)return gt(this.view);if(Ie&&nn<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Wn(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=Vi(o))n.add(o);for(let o=e.anchorNode;o;o=Vi(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)&&nd(e)&&!this.ignoreSelectionChange(r),o=-1,l=-1,s=!1,u=[];if(e.editable)for(let c=0;c1){let c=u.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 a=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,l),OS(e)),this.handleDOMChange(o,l,s,u),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||gt(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;S--){let g=r.childNodes[S-1],m=g.pmViewDesc;if(g.nodeName=="BR"&&!m){o=S;break}if(!m||m.size)break}let f=t.state.doc,d=t.someProp("domParser")||Si.fromSchema(t.state.schema),p=f.resolve(l),h=null,y=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:a,ruleFromNode:DS,context:p});if(a&&a[0].pos!=null){let S=a[0].pos,g=a[1]&&a[1].pos;g==null&&(g=S),h={anchor:S+l,head:g+l}}return{doc:y,sel:h,from:l,to:s}}function DS(t){let e=t.pmViewDesc;if(e)return e.parseRule();if(t.nodeName=="BR"&&t.parentNode){if(Ce&&/^(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||Ce&&/^(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 RS=/^(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 PS(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,z=Za(t,P);if(z&&!t.state.selection.eq(z)){if(ye&&it&&t.input.lastKeyCode===13&&Date.now()-100pn(t,vn(13,"Enter"))))return;let de=t.state.tr.setSelection(z);P=="pointer"?de.setMeta("pointer",!0):P=="key"&&de.scrollIntoView(),o&&de.setMeta("composition",o),t.dispatch(de)}return}let l=t.state.doc.resolve(e),s=l.sharedDepth(n);e=l.before(s+1),n=t.state.doc.resolve(n).after(s+1);let u=t.state.selection,a=TS(t,e,n),c=t.state.doc,f=c.slice(a.from,a.to),d,p;t.input.lastKeyCode===8&&Date.now()-100Date.now()-225||it)&&i.some(P=>P.nodeType==1&&!RS.test(P.nodeName))&&(!h||h.endA>=h.endB)&&t.someProp("handleKeyDown",P=>P(t,vn(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!h)if(r&&u instanceof U&&!u.empty&&u.$head.sameParent(u.$anchor)&&!t.composing&&!(a.sel&&a.sel.anchor!=a.sel.head))h={start:u.from,endA:u.to,endB:u.to};else{if(a.sel){let P=hd(t,t.state.doc,a.sel);if(P&&!P.eq(t.state.selection)){let z=t.state.tr.setSelection(P);o&&z.setMeta("composition",o),t.dispatch(z)}}return}if(ye&&t.cursorWrapper&&a.sel&&a.sel.anchor==t.cursorWrapper.deco.from&&a.sel.head==a.sel.anchor){let P=h.endB-h.start;a.sel={anchor:a.sel.anchor+P,head:a.sel.anchor+P}}t.input.domChangeCount++,t.state.selection.fromt.state.selection.from&&h.start<=t.state.selection.from+2&&t.state.selection.from>=a.from?h.start=t.state.selection.from:h.endA=t.state.selection.to-2&&t.state.selection.to<=a.to&&(h.endB+=t.state.selection.to-h.endA,h.endA=t.state.selection.to)),Ie&&nn<=11&&h.endB==h.start+1&&h.endA==h.start&&h.start>a.from&&a.doc.textBetween(h.start-a.from-1,h.start-a.from+1)=="  "&&(h.start--,h.endA--,h.endB--);let y=a.doc.resolveNoCache(h.start-a.from),S=a.doc.resolveNoCache(h.endB-a.from),g=c.resolve(h.start),m=y.sameParent(S)&&y.parent.inlineContent&&g.end()>=h.endA,k;if((Mr&&t.input.lastIOSEnter>Date.now()-225&&(!m||i.some(P=>P.nodeName=="DIV"||P.nodeName=="P"))||!m&&y.posP(t,vn(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>h.start&&AS(c,h.start,h.endA,y,S)&&t.someProp("handleKeyDown",P=>P(t,vn(8,"Backspace")))){it&&ye&&t.domObserver.suppressSelectionUpdates();return}ye&&it&&h.endB==h.start&&(t.input.lastAndroidDelete=Date.now()),it&&!m&&y.start()!=S.start()&&S.parentOffset==0&&y.depth==S.depth&&a.sel&&a.sel.anchor==a.sel.head&&a.sel.head==h.endA&&(h.endB-=2,S=a.doc.resolveNoCache(h.endB-a.from),setTimeout(()=>{t.someProp("handleKeyDown",function(P){return P(t,vn(13,"Enter"))})},20));let v=h.start,E=h.endA,N,D,R;if(m){if(y.pos==S.pos)Ie&&nn<=11&&y.parentOffset==0&&(t.domObserver.suppressSelectionUpdates(),setTimeout(()=>gt(t),20)),N=t.state.tr.delete(v,E),D=c.resolve(h.start).marksAcross(c.resolve(h.endA));else if(h.endA==h.endB&&(R=zS(y.parent.content.cut(y.parentOffset,S.parentOffset),g.parent.content.cut(g.parentOffset,h.endA-g.start()))))N=t.state.tr,R.type=="add"?N.addMark(v,E,R.mark):N.removeMark(v,E,R.mark);else if(y.parent.child(y.index()).isText&&y.index()==S.index()-(S.textOffset?0:1)){let P=y.parent.textBetween(y.parentOffset,S.parentOffset);if(t.someProp("handleTextInput",z=>z(t,v,E,P)))return;N=t.state.tr.insertText(P,v,E)}}if(N||(N=t.state.tr.replace(v,E,a.doc.slice(h.start-a.from,h.endB-a.from))),a.sel){let P=hd(t,N.doc,a.sel);P&&!(ye&&it&&t.composing&&P.empty&&(h.start!=h.endB||t.input.lastAndroidDeletee.content.size?null:ec(t,e.resolve(n.anchor),e.resolve(n.head))}function zS(t,e){let n=t.firstChild.marks,r=e.firstChild.marks,i=n,o=r,l,s,u;for(let c=0;cc.mark(s.addToSet(c.marks));else if(i.length==0&&o.length==1)s=o[0],l="remove",u=c=>c.mark(s.removeFromSet(c.marks));else return null;let a=[];for(let c=0;cn||Fs(l,!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 IS(t,e,n,r,i){let o=t.findDiffStart(e,n);if(o==null)return null;let{a:l,b:s}=t.findDiffEnd(e,n+t.size,n+e.size);if(i=="end"){let u=Math.max(0,o-Math.min(l,s));r-=l+u-o}if(l=l?o-r:0;o-=u,s=o+(s-l),l=o}else if(s=s?o-r:0;o-=u,l=o+(l-s),s=o}return{start:o,endA:l,endB:s}}class FS{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 tS,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(yd),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=md(this),this.nodeViews=gd(this),this.docView=null,this.domObserver=new NS(this,(r,i,o,l)=>PS(this,r,i,o,l)),this.init()}initInput(){nS(this)}init(){pd(this),this.docView=Qf(this.state.doc,Uu(this),Bo(this),this.dom,this),this.domObserver.start(),this.initInput(),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&&Wu(this);let n=this._props;this._props=e,e.plugins&&(e.plugins.forEach(yd),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){let r=this.state,i=!1,o=!1;e.storedMarks&&this.composing&&(qm(this),o=!0),this.state=e;let l=r.plugins!=e.plugins||this._props.plugins!=n.plugins;if(l||this._props.plugins!=n.plugins||this._props.nodeViews!=n.nodeViews){let d=gd(this);BS(d,this.nodeViews)&&(this.nodeViews=d,i=!0)}(l||n.handleDOMEvents!=this._props.handleDOMEvents)&&Wu(this),this.editable=md(this),pd(this);let s=Bo(this),u=Uu(this),a=r.plugins!=e.plugins&&!r.doc.eq(e.doc)?"reset":e.scrollToSelection>r.scrollToSelection?"to selection":"preserve",c=i||!this.docView.matchesNode(e.doc,u,s);(c||!e.selection.eq(r.selection))&&(o=!0);let f=a=="preserve"&&o&&this.dom.style.overflowAnchor==null&&Sm(this);if(o){this.domObserver.stop();let d=c&&(Ie||ye)&&!this.composing&&!r.selection.empty&&!e.selection.empty&&LS(r.selection,e.selection);if(c){let p=ye?this.trackWrites=this.domSelectionRange().focusNode:null;(i||!this.docView.update(e.doc,u,s,this))&&(this.docView.updateOuterDeco([]),this.docView.destroy(),this.docView=Qf(e.doc,u,s,this.dom,this)),p&&!this.trackWrites&&(d=!0)}d||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&$k(this))?gt(this,d):(Lm(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(r),a=="reset"?this.dom.scrollTop=0:a=="to selection"?this.scrollToSelection():f&&wm(f)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!this.someProp("handleScrollToSelection",n=>n(this)))if(this.state.selection instanceof A){let n=this.docView.domAfterPos(this.state.selection.from);n.nodeType==1&&Wf(this,n.getBoundingClientRect(),e)}else Wf(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;nn.ownerDocument.getSelection()),this._root=n}return e||document}posAtCoords(e){return vk(this,e)}coordsAtPos(e,n=1){return Nm(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 Nk(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&&(rS(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Bo(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 oS(this,e)}dispatch(e){let n=this._props.dispatchTransaction;n?n.call(this,e):this.updateState(this.state.apply(e))}domSelectionRange(){return Ce&&this.root.nodeType===11&&uk(this.dom.ownerDocument)==this.dom?MS(this):this.domSelection()}domSelection(){return this.root.getSelection()}}function Uu(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"),[ke.node(0,t.state.doc.content.size,e)]}function pd(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:ke.widget(t.state.selection.head,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function md(t){return!t.someProp("editable",e=>e(t.state)===!1)}function LS(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 gd(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 BS(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 yd(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 VS extends FS{init(){this.domObserver.start(),this.initInput()}updateStateInner(e,n){this.editable=!this.someProp("editable",s=>s(this.state)===!1);const r=this.state;this.state=e;const i=r.plugins!=e.plugins&&!r.doc.eq(e.doc)?"reset":e.scrollToSelection>r.scrollToSelection?"to selection":"preserve",o=!e.selection.eq(r.selection),l=i=="preserve"&&o&&this.dom.style.overflowAnchor==null&&Sm(this);i=="reset"?this.dom.scrollTop=0:i=="to selection"?this.scrollToSelection():l&&wm(l)}set docView(e){}get docView(){return this.dom.pmViewDesc}}function _S(t){return function(...e){Bi.unstable_batchedUpdates(()=>{t.call(this,...e)})}}function bS(t){this.updateState(this.state.apply(t))}function $S(t,e){return{...t,dispatchTransaction:function(r){_S(t.dispatchTransaction??bS).call(this,r),e()}}}function WS(t,e){const[n,r]=O.useState(null),i=gm(),o=$S(e,i),l="defaultState"in o?o.defaultState:o.state;return O.useLayoutEffect(()=>{if(n&&n.dom!==t&&r(null),!!t&&!n){const s=new VS({mount:t},{...o,state:l});r(s);return}},[o,t,l,n]),n==null||n.setProps({...o,..."state"in o&&{state:o.state}}),n}function US(t){O.useEffect(()=>{if(!t)return;const{domObserver:e}=t;return e.connectSelection(),()=>e.disconnectSelection()},[t]),O.useEffect(()=>{t!=null&&t.state&&(t!=null&&t.composing||gt(t))})}function jS(t){const e=O.useRef(null),n=e.current;return e.current=t,n}function JS(t,e,n){const r=jS(e),i=O.useRef([]);O.useLayoutEffect(()=>{if(!(!t||!r))for(const o of i.current)o.update&&o.update(t,r)},[r,t]),O.useLayoutEffect(()=>{var o,l;if(t){i.current=[];for(const s of[...n,...t.state.plugins]){const u=(l=(o=s.spec).view)==null?void 0:l.call(o,t);u&&i.current.push(u)}}},[n,t]),O.useLayoutEffect(()=>()=>{for(const o of i.current)o.destroy&&o.destroy()},[])}const Ft=O.createContext([]);function eg(t,e,n,r,i){const o=O.useContext(Ft),l=[];return O.useLayoutEffect(()=>{if(!t||!n.current)return;const s=l[0],u=new Dt(void 0,l,t,i,r,(e==null?void 0:e.current)??n.current,(s==null?void 0:s.dom.parentElement)??null,n.current);o.push(u);for(const a of l)a.parent=u}),l}var tg={exports:{}};/*! +`))),0,0):C.empty;let f=t.someProp("clipboardTextParser",d=>d(e,i,r,t));if(f)s=f;else{let d=i.marks(),{schema:p}=t.state,h=Ot.fromSchema(p);l=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(y=>{let S=l.appendChild(document.createElement("p"));y&&S.appendChild(h.serializeNode(p.text(y,d)))})}}else t.someProp("transformPastedHTML",f=>{n=f(n,t)}),l=Gk(n),$l&&Xk(l);let a=l&&l.querySelector("[data-pm-slice]"),c=a&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(a.getAttribute("data-pm-slice")||"");if(c&&c[3])for(let f=+c[3];f>0;f--){let d=l.firstChild;for(;d&&d.nodeType!=1;)d=d.nextSibling;if(!d)break;l=d}if(s||(s=(t.someProp("clipboardParser")||t.someProp("domParser")||vi.fromSchema(t.state.schema)).parseSlice(l,{preserveWhitespace:!!(u||c),context:i,ruleFromNode(d){return d.nodeName=="BR"&&!d.nextSibling&&d.parentNode&&!qk.test(d.parentNode.nodeName)?{ignore:!0}:null}})),c)s=Zk(ud(s,+c[1],+c[2]),c[4]);else if(s=C.maxOpen(Yk(s.content,i),!0),s.openStart||s.openEnd){let f=0,d=0;for(let p=s.content.firstChild;f{s=f(s,t)}),s}const qk=/^(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 Yk(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,l=[];if(t.forEach(s=>{if(!l)return;let u=i.findWrapping(s.type),a;if(!u)return l=null;if(a=l.length&&o.length&&Wm(u,o,s,l[l.length-1],0))l[l.length-1]=a;else{l.length&&(l[l.length-1]=Um(l[l.length-1],o.length));let c=$m(s,u);l.push(c),i=i.matchType(c.type),o=u}}),l)return x.from(l)}return t}function $m(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,x.from(t));return t}function Wm(t,e,n,r,i){if(i1&&(o=0),i=n&&(s=e<0?l.contentMatchAt(0).fillBefore(s,o<=i).append(s):s.append(l.contentMatchAt(l.childCount).fillBefore(x.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,l.copy(s))}function ud(t,e,n){return e]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n=Jm().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(t),i;if((i=r&&jm[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;s-=2){let u=n.nodes[r[s]];if(!u||u.hasRequiredAttrs())break;i=x.from(u.create(r[s+1],i)),o++,l++}return new C(i,o,l)}const Ee={},Ne={},eS={touchstart:!0,touchmove:!0};class tS{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 nS(t){for(let e in Ee){let n=Ee[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=r=>{iS(t,r)&&!nc(t,r)&&(t.editable||!(r.type in Ne))&&n(t,r)},eS[e]?{passive:!0}:void 0)}Ce&&t.dom.addEventListener("input",()=>null),ju(t)}function Kt(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function rS(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 ju(t){t.someProp("handleDOMEvents",e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=r=>nc(t,r))})}function nc(t,e){return t.someProp("handleDOMEvents",n=>{let r=n[e.type];return r?r(t,e)||e.defaultPrevented:!1})}function iS(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 oS(t,e){!nc(t,e)&&Ee[e.type]&&(t.editable||!(e.type in Ne))&&Ee[e.type](t,e)}Ne.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=n.keyCode==16||n.shiftKey,!Km(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!(it&&ye&&n.keyCode==13)))if(n.keyCode!=229&&t.domObserver.forceFlush(),Mr&&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,vn(13,"Enter"))),t.input.lastIOSEnter=0)},200)}else t.someProp("handleKeyDown",r=>r(t,n))||Qk(t,n)?n.preventDefault():Kt(t,"key")};Ne.keyup=(t,e)=>{e.keyCode==16&&(t.input.shiftKey=!1)};Ne.keypress=(t,e)=>{let n=e;if(Km(t,n)||!n.charCode||n.ctrlKey&&!n.altKey||Je&&n.metaKey)return;if(t.someProp("handleKeyPress",i=>i(t,n))){n.preventDefault();return}let r=t.state.selection;if(!(r instanceof U)||!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 Wl(t){return{left:t.clientX,top:t.clientY}}function lS(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}function rc(t,e,n,r,i){if(r==-1)return!1;let o=t.state.doc.resolve(r);for(let l=o.depth+1;l>0;l--)if(t.someProp(e,s=>l>o.depth?s(t,n,o.nodeAfter,o.before(l),i,!0):s(t,n,o.node(l),o.before(l),i,!1)))return!0;return!1}function gr(t,e,n){t.focused||t.focus();let r=t.state.tr.setSelection(e);n=="pointer"&&r.setMeta("pointer",!0),t.dispatch(r)}function sS(t,e){if(e==-1)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return r&&r.isAtom&&A.isSelectable(r)?(gr(t,new A(n),"pointer"),!0):!1}function uS(t,e){if(e==-1)return!1;let n=t.state.selection,r,i;n instanceof A&&(r=n.node);let o=t.state.doc.resolve(e);for(let l=o.depth+1;l>0;l--){let s=l>o.depth?o.nodeAfter:o.node(l);if(A.isSelectable(s)){r&&n.$from.depth>0&&l>=n.$from.depth&&o.before(n.$from.depth+1)==n.$from.pos?i=o.before(n.$from.depth):i=o.before(l);break}}return i!=null?(gr(t,A.create(t.state.doc,i),"pointer"),!0):!1}function aS(t,e,n,r,i){return rc(t,"handleClickOn",e,n,r)||t.someProp("handleClick",o=>o(t,e,r))||(i?uS(t,n):sS(t,n))}function cS(t,e,n,r){return rc(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",i=>i(t,e,r))}function fS(t,e,n,r){return rc(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",i=>i(t,e,r))||dS(t,n,r)}function dS(t,e,n){if(n.button!=0)return!1;let r=t.state.doc;if(e==-1)return r.inlineContent?(gr(t,U.create(r,0,r.content.size),"pointer"),!0):!1;let i=r.resolve(e);for(let o=i.depth+1;o>0;o--){let l=o>i.depth?i.nodeAfter:i.node(o),s=i.before(o);if(l.inlineContent)gr(t,U.create(r,s+1,s+1+l.content.size),"pointer");else if(A.isSelectable(l))gr(t,A.create(r,s),"pointer");else continue;return!0}}function ic(t){return gl(t)}const Hm=Je?"metaKey":"ctrlKey";Ee.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=ic(t),i=Date.now(),o="singleClick";i-t.input.lastClick.time<500&&lS(n,t.input.lastClick)&&!n[Hm]&&(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 l=t.posAtCoords(Wl(n));l&&(o=="singleClick"?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new hS(t,l,n,!!r)):(o=="doubleClick"?cS:fS)(t,l.pos,l.inside,n)?n.preventDefault():Kt(t,"pointer"))};class hS{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[Hm],this.allowDefault=r.shiftKey;let o,l;if(n.inside>-1)o=e.state.doc.nodeAt(n.inside),l=n.inside;else{let c=e.state.doc.resolve(n.pos);o=c.parent,l=c.depth?c.before():0}const s=i?null:r.target,u=s?e.docView.nearestDesc(s,!0):null;this.target=u?u.dom:null;let{selection:a}=e.state;(r.button==0&&o.type.spec.draggable&&o.type.spec.selectable!==!1||a instanceof A&&a.from<=l&&a.to>l)&&(this.mightDrag={node:o,pos:l,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&ut&&!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)),Kt(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(()=>yt(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(Wl(e))),this.updateAllowDefault(e),this.allowDefault||!n?Kt(this.view,"pointer"):aS(this.view,n.pos,n.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||Ce&&this.mightDrag&&!this.mightDrag.node.isAtom||ye&&!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)?(gr(this.view,b.near(this.view.state.doc.resolve(n.pos)),"pointer"),e.preventDefault()):Kt(this.view,"pointer")}move(e){this.updateAllowDefault(e),Kt(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)}}Ee.touchstart=t=>{t.input.lastTouch=Date.now(),ic(t),Kt(t,"pointer")};Ee.touchmove=t=>{t.input.lastTouch=Date.now(),Kt(t,"pointer")};Ee.contextmenu=t=>ic(t);function Km(t,e){return t.composing?!0:Ce&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500?(t.input.compositionEndedAt=-2e8,!0):!1}const pS=it?5e3:-1;Ne.compositionstart=Ne.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(),gl(t,!0),t.markCursor=null;else if(gl(t),ut&&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 l=o<0?i.lastChild:i.childNodes[o-1];if(!l)break;if(l.nodeType==3){t.domSelection().collapse(l,l.nodeValue.length);break}else i=l,o=-1}}t.input.composing=!0}Qm(t,pS)};Ne.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++,Qm(t,20))};function Qm(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout(()=>gl(t),e))}function qm(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=mS());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function mS(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}function gl(t,e=!1){if(!(it&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),qm(t),e||t.docView&&t.docView.dirty){let n=ec(t);return n&&!n.eq(t.state.selection)?t.dispatch(t.state.tr.setSelection(n)):t.updateState(t.state),!0}return!1}}function gS(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 Dr=Ie&&nn<15||Mr&&dk<604;Ee.copy=Ne.cut=(t,e)=>{let n=e,r=t.state.selection,i=n.type=="cut";if(r.empty)return;let o=Dr?null:n.clipboardData,l=r.content(),{dom:s,text:u}=_m(t,l);o?(n.preventDefault(),o.clearData(),o.setData("text/html",s.innerHTML),o.setData("text/plain",u)):gS(t,s),i&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function yS(t){return t.openStart==0&&t.openEnd==0&&t.content.childCount==1?t.content.firstChild:null}function kS(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?Wi(t,r.value,null,i,e):Wi(t,r.textContent,r.innerHTML,i,e)},50)}function Wi(t,e,n,r,i){let o=bm(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",u=>u(t,i,o||C.empty)))return!0;if(!o)return!1;let l=yS(o),s=l?t.state.tr.replaceSelectionWith(l,r):t.state.tr.replaceSelection(o);return t.dispatch(s.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}Ne.paste=(t,e)=>{let n=e;if(t.composing&&!it)return;let r=Dr?null:n.clipboardData,i=t.input.shiftKey&&t.input.lastKeyCode!=45;r&&Wi(t,r.getData("text/plain"),r.getData("text/html"),i,n)?n.preventDefault():kS(t,n)};class SS{constructor(e,n){this.slice=e,this.move=n}}const Ym=Je?"altKey":"ctrlKey";Ee.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(Wl(n));if(!(o&&o.pos>=i.from&&o.pos<=(i instanceof A?i.to-1:i.to))){if(r&&r.mightDrag)t.dispatch(t.state.tr.setSelection(A.create(t.state.doc,r.mightDrag.pos)));else if(n.target&&n.target.nodeType==1){let a=t.docView.nearestDesc(n.target,!0);a&&a.node.type.spec.draggable&&a!=t.docView&&t.dispatch(t.state.tr.setSelection(A.create(t.state.doc,a.posBefore)))}}let l=t.state.selection.content(),{dom:s,text:u}=_m(t,l);n.dataTransfer.clearData(),n.dataTransfer.setData(Dr?"Text":"text/html",s.innerHTML),n.dataTransfer.effectAllowed="copyMove",Dr||n.dataTransfer.setData("text/plain",u),t.dragging=new SS(l,!n[Ym])};Ee.dragend=t=>{let e=t.dragging;window.setTimeout(()=>{t.dragging==e&&(t.dragging=null)},50)};Ne.dragover=Ne.dragenter=(t,e)=>e.preventDefault();Ne.drop=(t,e)=>{let n=e,r=t.dragging;if(t.dragging=null,!n.dataTransfer)return;let i=t.posAtCoords(Wl(n));if(!i)return;let o=t.state.doc.resolve(i.pos),l=r&&r.slice;l?t.someProp("transformPasted",h=>{l=h(l,t)}):l=bm(t,n.dataTransfer.getData(Dr?"Text":"text/plain"),Dr?null:n.dataTransfer.getData("text/html"),!1,o);let s=!!(r&&!n[Ym]);if(t.someProp("handleDrop",h=>h(t,n,l||C.empty,s))){n.preventDefault();return}if(!l)return;n.preventDefault();let u=l?Vk(t.state.doc,o.pos,l):o.pos;u==null&&(u=o.pos);let a=t.state.tr;s&&a.deleteSelection();let c=a.mapping.map(u),f=l.openStart==0&&l.openEnd==0&&l.content.childCount==1,d=a.doc;if(f?a.replaceRangeWith(c,c,l.content.firstChild):a.replaceRange(c,c,l),a.doc.eq(d))return;let p=a.doc.resolve(c);if(f&&A.isSelectable(l.content.firstChild)&&p.nodeAfter&&p.nodeAfter.sameMarkup(l.content.firstChild))a.setSelection(new A(p));else{let h=a.mapping.map(u);a.mapping.maps[a.mapping.maps.length-1].forEach((y,S,g,m)=>h=m),a.setSelection(tc(t,p,a.doc.resolve(h)))}t.focus(),t.dispatch(a.setMeta("uiEvent","drop"))};Ee.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())&&yt(t)},20))};Ee.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)};Ee.beforeinput=(t,e)=>{if(ye&&it&&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,vn(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 Ne)Ee[t]=Ne[t];function Ui(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 oc{constructor(e,n){this.toDOM=e,this.spec=n||In,this.side=this.spec.side||0}map(e,n,r,i){let{pos:o,deleted:l}=e.mapResult(n.from+i,this.side<0?-1:1);return l?null:new ke(o-r,o-r,this)}valid(){return!0}eq(e){return this==e||e instanceof oc&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Ui(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class rn{constructor(e,n){this.attrs=e,this.spec=n||In}map(e,n,r,i){let o=e.map(n.from+i,this.spec.inclusiveStart?-1:1)-r,l=e.map(n.to+i,this.spec.inclusiveEnd?1:-1)-r;return o>=l?null:new ke(o,l,this)}valid(e,n){return n.from=t&&(!i||i(l.spec))&&n.push(l.copy(l.from+r,l.to+r))}for(let o=0;ot){let l=this.children[o]+1;this.children[o+2].findInner(t-l,e-l,n,r+l,i)}}map(t,e,n){return this==me||t.maps.length==0?this:this.mapInner(t,e,0,0,n||In)}mapInner(t,e,n,r,i){let o;for(let l=0;l{let u=s+n,a;if(a=Xm(e,l,u)){for(r||(r=this.children.slice());il&&c.to=t){this.children[l]==t&&(n=this.children[l+2]);break}let i=t+1,o=i+e.content.size;for(let l=0;li&&s.type instanceof rn){let u=Math.max(i,s.from)-i,a=Math.min(o,s.to)-i;ui.map(e,n,In));return jt.from(r)}forChild(e,n){if(n.isLeaf)return Fe.empty;let r=[];for(let i=0;in instanceof Fe)?e:e.reduce((n,r)=>n.concat(r instanceof Fe?r:r.members),[]))}}}function vS(t,e,n,r,i,o,l){let s=t.slice();for(let a=0,c=o;a{let S=y-h-(p-d);for(let g=0;gm+c-f)continue;let k=s[g]+c-f;p>=k?s[g+1]=d<=k?-2:-1:h>=i&&S&&(s[g]+=S,s[g+1]+=S)}f+=S}),c=n.maps[a].map(c,-1)}let u=!1;for(let a=0;a=r.content.size){u=!0;continue}let d=n.map(t[a+1]+o,-1),p=d-i,{index:h,offset:y}=r.content.findIndex(f),S=r.maybeChild(h);if(S&&y==f&&y+S.nodeSize==p){let g=s[a+2].mapInner(n,S,c+1,t[a]+o+1,l);g!=me?(s[a]=f,s[a+1]=p,s[a+2]=g):(s[a+1]=-2,u=!0)}else u=!0}if(u){let a=wS(s,t,e,n,i,o,l),c=yl(a,r,0,l);e=c.local;for(let f=0;fn&&l.to{let a=Xm(t,s,u+n);if(a){o=!0;let c=yl(a,s,n+u+1,r);c!=me&&i.push(u,u+s.nodeSize,c)}});let l=Gm(o?Zm(t):t,-n).sort(Fn);for(let s=0;s0;)e++;t.splice(e,0,n)}function ei(t){let e=[];return t.someProp("decorations",n=>{let r=n(t.state);r&&r!=me&&e.push(r)}),t.cursorWrapper&&e.push(Fe.create(t.state.doc,[t.cursorWrapper.deco])),jt.from(e)}const xS={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},CS=Ie&&nn<=11;class ES{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 NS{constructor(e,n){this.view=e,this.handleDOMChange=n,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new ES,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()}),CS&&(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,xS)),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(nd(this.view)){if(this.suppressingSelectionUpdates)return yt(this.view);if(Ie&&nn<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Wn(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=_i(o))n.add(o);for(let o=e.anchorNode;o;o=_i(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)&&nd(e)&&!this.ignoreSelectionChange(r),o=-1,l=-1,s=!1,u=[];if(e.editable)for(let c=0;c1){let c=u.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 a=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,l),OS(e)),this.handleDOMChange(o,l,s,u),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||yt(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;S--){let g=r.childNodes[S-1],m=g.pmViewDesc;if(g.nodeName=="BR"&&!m){o=S;break}if(!m||m.size)break}let f=t.state.doc,d=t.someProp("domParser")||vi.fromSchema(t.state.schema),p=f.resolve(l),h=null,y=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:a,ruleFromNode:DS,context:p});if(a&&a[0].pos!=null){let S=a[0].pos,g=a[1]&&a[1].pos;g==null&&(g=S),h={anchor:S+l,head:g+l}}return{doc:y,sel:h,from:l,to:s}}function DS(t){let e=t.pmViewDesc;if(e)return e.parseRule();if(t.nodeName=="BR"&&t.parentNode){if(Ce&&/^(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||Ce&&/^(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 RS=/^(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 PS(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,z=ec(t,P);if(z&&!t.state.selection.eq(z)){if(ye&&it&&t.input.lastKeyCode===13&&Date.now()-100pn(t,vn(13,"Enter"))))return;let de=t.state.tr.setSelection(z);P=="pointer"?de.setMeta("pointer",!0):P=="key"&&de.scrollIntoView(),o&&de.setMeta("composition",o),t.dispatch(de)}return}let l=t.state.doc.resolve(e),s=l.sharedDepth(n);e=l.before(s+1),n=t.state.doc.resolve(n).after(s+1);let u=t.state.selection,a=TS(t,e,n),c=t.state.doc,f=c.slice(a.from,a.to),d,p;t.input.lastKeyCode===8&&Date.now()-100Date.now()-225||it)&&i.some(P=>P.nodeType==1&&!RS.test(P.nodeName))&&(!h||h.endA>=h.endB)&&t.someProp("handleKeyDown",P=>P(t,vn(13,"Enter")))){t.input.lastIOSEnter=0;return}if(!h)if(r&&u instanceof U&&!u.empty&&u.$head.sameParent(u.$anchor)&&!t.composing&&!(a.sel&&a.sel.anchor!=a.sel.head))h={start:u.from,endA:u.to,endB:u.to};else{if(a.sel){let P=hd(t,t.state.doc,a.sel);if(P&&!P.eq(t.state.selection)){let z=t.state.tr.setSelection(P);o&&z.setMeta("composition",o),t.dispatch(z)}}return}if(ye&&t.cursorWrapper&&a.sel&&a.sel.anchor==t.cursorWrapper.deco.from&&a.sel.head==a.sel.anchor){let P=h.endB-h.start;a.sel={anchor:a.sel.anchor+P,head:a.sel.anchor+P}}t.input.domChangeCount++,t.state.selection.fromt.state.selection.from&&h.start<=t.state.selection.from+2&&t.state.selection.from>=a.from?h.start=t.state.selection.from:h.endA=t.state.selection.to-2&&t.state.selection.to<=a.to&&(h.endB+=t.state.selection.to-h.endA,h.endA=t.state.selection.to)),Ie&&nn<=11&&h.endB==h.start+1&&h.endA==h.start&&h.start>a.from&&a.doc.textBetween(h.start-a.from-1,h.start-a.from+1)=="  "&&(h.start--,h.endA--,h.endB--);let y=a.doc.resolveNoCache(h.start-a.from),S=a.doc.resolveNoCache(h.endB-a.from),g=c.resolve(h.start),m=y.sameParent(S)&&y.parent.inlineContent&&g.end()>=h.endA,k;if((Mr&&t.input.lastIOSEnter>Date.now()-225&&(!m||i.some(P=>P.nodeName=="DIV"||P.nodeName=="P"))||!m&&y.posP(t,vn(13,"Enter")))){t.input.lastIOSEnter=0;return}if(t.state.selection.anchor>h.start&&AS(c,h.start,h.endA,y,S)&&t.someProp("handleKeyDown",P=>P(t,vn(8,"Backspace")))){it&&ye&&t.domObserver.suppressSelectionUpdates();return}ye&&it&&h.endB==h.start&&(t.input.lastAndroidDelete=Date.now()),it&&!m&&y.start()!=S.start()&&S.parentOffset==0&&y.depth==S.depth&&a.sel&&a.sel.anchor==a.sel.head&&a.sel.head==h.endA&&(h.endB-=2,S=a.doc.resolveNoCache(h.endB-a.from),setTimeout(()=>{t.someProp("handleKeyDown",function(P){return P(t,vn(13,"Enter"))})},20));let v=h.start,E=h.endA,N,D,R;if(m){if(y.pos==S.pos)Ie&&nn<=11&&y.parentOffset==0&&(t.domObserver.suppressSelectionUpdates(),setTimeout(()=>yt(t),20)),N=t.state.tr.delete(v,E),D=c.resolve(h.start).marksAcross(c.resolve(h.endA));else if(h.endA==h.endB&&(R=zS(y.parent.content.cut(y.parentOffset,S.parentOffset),g.parent.content.cut(g.parentOffset,h.endA-g.start()))))N=t.state.tr,R.type=="add"?N.addMark(v,E,R.mark):N.removeMark(v,E,R.mark);else if(y.parent.child(y.index()).isText&&y.index()==S.index()-(S.textOffset?0:1)){let P=y.parent.textBetween(y.parentOffset,S.parentOffset);if(t.someProp("handleTextInput",z=>z(t,v,E,P)))return;N=t.state.tr.insertText(P,v,E)}}if(N||(N=t.state.tr.replace(v,E,a.doc.slice(h.start-a.from,h.endB-a.from))),a.sel){let P=hd(t,N.doc,a.sel);P&&!(ye&&it&&t.composing&&P.empty&&(h.start!=h.endB||t.input.lastAndroidDeletee.content.size?null:tc(t,e.resolve(n.anchor),e.resolve(n.head))}function zS(t,e){let n=t.firstChild.marks,r=e.firstChild.marks,i=n,o=r,l,s,u;for(let c=0;cc.mark(s.addToSet(c.marks));else if(i.length==0&&o.length==1)s=o[0],l="remove",u=c=>c.mark(s.removeFromSet(c.marks));else return null;let a=[];for(let c=0;cn||Bs(l,!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 IS(t,e,n,r,i){let o=t.findDiffStart(e,n);if(o==null)return null;let{a:l,b:s}=t.findDiffEnd(e,n+t.size,n+e.size);if(i=="end"){let u=Math.max(0,o-Math.min(l,s));r-=l+u-o}if(l=l?o-r:0;o-=u,s=o+(s-l),l=o}else if(s=s?o-r:0;o-=u,l=o+(l-s),s=o}return{start:o,endA:l,endB:s}}class FS{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 tS,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=n,this.state=n.state,this.directPlugins=n.plugins||[],this.directPlugins.forEach(yd),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=md(this),this.nodeViews=gd(this),this.docView=n.docView??Is(this.state.doc,Vo(this),ei(this),this.dom,this),this.domObserver=new NS(this,(r,i,o,l)=>PS(this,r,i,o,l)),this.init()}initInput(){nS(this)}init(){pd(this),this.docView=Is(this.state.doc,Vo(this),ei(this),this.dom,this),this.domObserver.start(),this.initInput(),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&&ju(this);let n=this._props;this._props=e,e.plugins&&(e.plugins.forEach(yd),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){let r=this.state,i=!1,o=!1;e.storedMarks&&this.composing&&(qm(this),o=!0),this.state=e;let l=r.plugins!=e.plugins||this._props.plugins!=n.plugins;if(l||this._props.plugins!=n.plugins||this._props.nodeViews!=n.nodeViews){let d=gd(this);BS(d,this.nodeViews)&&(this.nodeViews=d,i=!0)}(l||n.handleDOMEvents!=this._props.handleDOMEvents)&&ju(this),this.editable=md(this),pd(this);let s=ei(this),u=Vo(this),a=r.plugins!=e.plugins&&!r.doc.eq(e.doc)?"reset":e.scrollToSelection>r.scrollToSelection?"to selection":"preserve",c=i||!this.docView.matchesNode(e.doc,u,s);(c||!e.selection.eq(r.selection))&&(o=!0);let f=a=="preserve"&&o&&this.dom.style.overflowAnchor==null&&Sm(this);if(o){this.domObserver.stop();let d=c&&(Ie||ye)&&!this.composing&&!r.selection.empty&&!e.selection.empty&&LS(r.selection,e.selection);if(c){let p=ye?this.trackWrites=this.domSelectionRange().focusNode:null;(i||!this.docView.update(e.doc,u,s,this))&&(this.docView.updateOuterDeco([]),this.docView.destroy(),this.docView=Is(e.doc,u,s,this.dom,this)),p&&!this.trackWrites&&(d=!0)}d||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&$k(this))?yt(this,d):(Lm(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(r),a=="reset"?this.dom.scrollTop=0:a=="to selection"?this.scrollToSelection():f&&wm(f)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!this.someProp("handleScrollToSelection",n=>n(this)))if(this.state.selection instanceof A){let n=this.docView.domAfterPos(this.state.selection.from);n.nodeType==1&&Uf(this,n.getBoundingClientRect(),e)}else Uf(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;nn.ownerDocument.getSelection()),this._root=n}return e||document}posAtCoords(e){return vk(this,e)}coordsAtPos(e,n=1){return Nm(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 Nk(this,n||this.state,e)}pasteHTML(e,n){return Wi(this,"",e,!1,n||new ClipboardEvent("paste"))}pasteText(e,n){return Wi(this,e,null,!0,n||new ClipboardEvent("paste"))}destroy(){this.docView&&(rS(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],ei(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 oS(this,e)}dispatch(e){let n=this._props.dispatchTransaction;n?n.call(this,e):this.updateState(this.state.apply(e))}domSelectionRange(){return Ce&&this.root.nodeType===11&&uk(this.dom.ownerDocument)==this.dom?MS(this):this.domSelection()}domSelection(){return this.root.getSelection()}}function Vo(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"),[ke.node(0,t.state.doc.content.size,e)]}function pd(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:ke.widget(t.state.selection.head,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function md(t){return!t.someProp("editable",e=>e(t.state)===!1)}function LS(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 gd(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 BS(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 yd(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 VS extends FS{init(){this.domObserver.start(),this.initInput()}updateStateInner(e,n){this.editable=!this.someProp("editable",s=>s(this.state)===!1);const r=this.state;this.state=e;const i=r.plugins!=e.plugins&&!r.doc.eq(e.doc)?"reset":e.scrollToSelection>r.scrollToSelection?"to selection":"preserve",o=!e.selection.eq(r.selection),l=i=="preserve"&&o&&this.dom.style.overflowAnchor==null&&Sm(this);i=="reset"?this.dom.scrollTop=0:i=="to selection"?this.scrollToSelection():l&&wm(l)}}function _S(t){return function(...e){Vi.unstable_batchedUpdates(()=>{t.call(this,...e)})}}function bS(t){this.updateState(this.state.apply(t))}function $S(t,e){return{...t,dispatchTransaction:function(r){_S(t.dispatchTransaction??bS).call(this,r),e()}}}function WS(t,e){const[n,r]=O.useState(null),i=gm(),o=$S(e,i),l="defaultState"in o?o.defaultState:o.state;return O.useLayoutEffect(()=>{if(n&&n.dom!==t&&r(null),!!t&&!n){const s=new VS({mount:t},{...o,state:l});r(s);return}},[o,t,l,n]),n==null||n.setProps({...o,..."state"in o&&{state:o.state}}),n}function US(t){O.useEffect(()=>{if(!t)return;const{domObserver:e}=t;return e.connectSelection(),()=>e.disconnectSelection()},[t]),O.useEffect(()=>{t!=null&&t.state&&(t!=null&&t.composing||yt(t))})}function jS(t){const e=O.useRef(null),n=e.current;return e.current=t,n}function JS(t,e,n){const r=jS(e),i=O.useRef([]);O.useLayoutEffect(()=>{if(!(!t||!r))for(const o of i.current)o.update&&o.update(t,r)},[r,t]),O.useLayoutEffect(()=>{var o,l;if(t){i.current=[];for(const s of[...n,...t.state.plugins]){const u=(l=(o=s.spec).view)==null?void 0:l.call(o,t);u&&i.current.push(u)}}},[n,t]),O.useLayoutEffect(()=>()=>{for(const o of i.current)o.destroy&&o.destroy()},[])}const Ft=O.createContext([]);function eg(t,e,n,r,i,o){const l=O.useRef(o),s=O.useContext(Ft),u=[];return O.useLayoutEffect(()=>{if(!t||!n.current)return;const a=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=(a==null?void 0:a.dom.parentElement)??null,l.current.nodeDOM=n.current):l.current=new gt(void 0,u,t,i,r,(e==null?void 0:e.current)??n.current,(a==null?void 0:a.dom.parentElement)??null,n.current),s.push(l.current);for(const c of u)c.parent=l.current}),u}var tg={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;)s.push(i[l++]);let d=o+c.nodeSize;if(c.isText){let h=d;l!h.inline):s.slice();r(c,p,e.forChild(o,c),o,f),o=d}}function Wl(){const{editorState:t}=O.useContext(Vl);return t}function So(t){const e=Math.floor(Math.random()*16777215).toString(16);return t.isTextblock&&t.textContent===""?`${e}-empty`:e}const ng=new oh("@nytimes/react-prosemirror/reactKeys");function YS(){let t=!1;return new xl({key:ng,state:{init(e,n){const r={posToKey:new Map,keyToPos:new Map};return n.doc.descendants((i,o)=>{const l=So(i);return r.posToKey.set(o,l),r.keyToPos.set(l,o),!0}),r},apply(e,n,r,i){if(!e.docChanged||t)return n;const o={posToKey:new Map,keyToPos:new Map},l=new Set;return i.doc.descendants((s,u)=>{const a=e.mapping.invert().map(u),c=n.posToKey.get(a)??So(s);let f=l.has(c)?So(s):c;return(f.endsWith("-empty")&&s.isTextblock&&s.textContent!==""||!f.endsWith("-empty")&&s.isTextblock&&s.textContent==="")&&(f=So(s)),o.posToKey.set(u,f),o.keyToPos.set(f,u),l.add(f),!0}),o}},props:{handleDOMEvents:{compositionstart:()=>{t=!0},compositionend:()=>{t=!1}}}})}function rg(){const t=Wl();return t&&ng.getState(t)}const sc=O.forwardRef(function({outputSpec:e,children:n,...r},i){if(typeof e=="string")return L(Sl,{children:e});if(!Array.isArray(e))throw new Error("@nytimes/react-prosemirror only supports strings and arrays in toDOM");const l=e[0].replace(" ",":"),s=e[1],u={...r,ref:i};let a=1;if(s&&typeof s=="object"&&s.nodeType==null&&!Array.isArray(s)){a=2;for(const f in s)if(s[f]!=null){const d=f==="class"?"className":f.replace(" ",":");u[d]=s[f]}}const c=[];for(let f=a;fa)throw new RangeError("Content hole must be the only child of its parent node");return O.createElement(l,u,n)}c.push(L(sc,{ref:void 0,outputSpec:d,children:n}))}return O.createElement(l,u,...c)}),ig=O.forwardRef(function({mark:e,children:n},r){var u,a;const i=O.useContext(Ft),o=[],l=O.useRef(null);O.useImperativeHandle(r,()=>l.current,[]);const s=(a=(u=e.type.spec).toDOM)==null?void 0:a.call(u,e,!0);if(!s)throw new Error(`Mark spec for ${e.type.name} is missing toDOM`);return O.useLayoutEffect(()=>{if(!l.current)return;const c=o[0],f=new un(void 0,o,e,l.current,(c==null?void 0:c.dom.parentElement)??l.current);i.push(f);for(const d of o)d.parent=f}),L(sc,{ref:l,outputSpec:s,children:L(Ft.Provider,{value:o,children:n})})});function og({outerDeco:t,pos:e,node:n,innerDeco:r,...i}){var h,y;const o=O.useRef(null),l=O.useRef(null),s=eg(n,o,l,r,t),u=Wl(),{nodeViews:a}=O.useContext(ym);let c=null;const f=a[n.type.name];if(f)c=L(f,{...i,ref:l,nodeProps:{node:n,pos:e,decorations:t,innerDecorations:r,isSelected:(u==null?void 0:u.selection)instanceof A&&u.selection.node===n},children:L(yl,{pos:e,node:n,innerDecorations:r})});else{const S=(y=(h=n.type.spec).toDOM)==null?void 0:y.call(h,n);S&&(c=L(sc,{...i,ref:l,outputSpec:S,children:L(yl,{pos:e,node:n,innerDecorations:r})}))}if(!c)throw new Error(`Node spec for ${n.type.name} is missing toDOM`);const d=O.cloneElement(t.reduce(uc,c),t.some(S=>S.type.attrs.nodeName)?{ref:o}:void 0),p=n.marks.reduce((S,g)=>L(ig,{mark:g,children:S}),d);return L(Ft.Provider,{value:s,children:O.cloneElement(p,n.marks.length||t.some(S=>S.type.attrs.nodeName)?{ref:o}:void 0)})}class GS extends O.Component{constructor(){super(...arguments),this.renderRef=null}componentDidMount(){const e=Bi.findDOMNode(this);if(!e)return;let n=e;for(;n.firstChild;)n=n.firstChild;const r=new Tr(void 0,[],this.props.node,this.props.decorations,$e.empty,e,n);this.props.siblingDescriptors.push(r)}componentDidUpdate(){const e=Bi.findDOMNode(this);if(!e)return;let n=e;for(;n.firstChild;)n=n.firstChild;const r=new Tr(void 0,[],this.props.node,this.props.decorations,$e.empty,e,n);this.props.siblingDescriptors.push(r)}render(){var e;return(e=this.props.view)!=null&&e.composing?this.renderRef:(this.renderRef=this.props.decorations.reduce(uc,this.props.node.text),this.renderRef)}}function XS(){const t=O.useContext(Ft),e=O.useRef(null);return O.useLayoutEffect(()=>{if(!e.current)return;const n=new Ga(void 0,[],e.current,null);t.push(n)}),L("br",{ref:e,className:"ProseMirror-trailingBreak"})}function ZS({widget:t,pos:e}){const n=O.useContext(Ft),r=O.useRef(null);O.useLayoutEffect(()=>{if(!r.current)return;const o=new Ya(void 0,t,r.current);n.push(o)});const{Component:i}=t.type;return i&&L(i,{ref:r,widget:t,pos:e,contentEditable:!1})}function kd(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,l=>{var s;return((s=l[1])==null?void 0:s.toUpperCase())??""});return{...r,[o]:n[i]}},{})}function uc(t,e){const{nodeName:n,class:r,style:i,contenteditable:o,spellcheck:l,...s}=e.type.attrs;return n||typeof t=="string"?O.createElement(n??"span",{className:r,contentEditable:o,spellCheck:l,style:i&&kd(i),...s},t):O.cloneElement(t,{className:KS(t.props.className,r),contentEditable:o,spellCheck:l,style:{...t.props.style,...i&&kd(i)},...s})}function lg({innerPos:t,childViews:e}){const{editorView:n}=O.useContext(Vl),r=Wl(),i=rg(),o=e.reduce((l,s)=>{var c;const u=l[l.length-1];if(!u)return[[s]];const a=u[u.length-1];return a?!s.marks.length&&!a.marks.length||s.marks.length&&a.marks.length&&((c=s.marks[0])!=null&&c.eq(a.marks[0]))?[...l.slice(0,l.length-1),[...u.slice(0,u.length),s]]:[...l,[s]]:[...l.slice(0,l.length),[s]]},[]);return L(Sl,{children:o.map(l=>{const s=l[0];if(!s)return null;const u=s.marks[0];return u?L(ig,{mark:u,children:L(lg,{innerPos:t,childViews:l.map(a=>({...a,marks:a.marks.slice(1)}))},gi(r==null?void 0:r.doc,t,s,i==null?void 0:i.posToKey))},gi(r==null?void 0:r.doc,t,s,i==null?void 0:i.posToKey)):l.map(a=>{const c=t+a.offset,f=a.type==="widget"?L(ZS,{widget:a.widget,pos:c}):a.node.isText?L(Ft.Consumer,{children:d=>L(GS,{view:n,node:a.node,siblingDescriptors:d,decorations:a.outerDeco})}):L(og,{node:a.node,pos:c,outerDeco:a.outerDeco,innerDeco:a.innerDeco});return O.cloneElement(f,{key:gi(r==null?void 0:r.doc,t,a,i==null?void 0:i.posToKey)})})})})}function gi(t,e,n,r){const i=e+n.offset,o=r==null?void 0:r.get(i);if(n.type==="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 l=t.resolve(i).start()-1,s=r==null?void 0:r.get(l);return s?`${s}-${n.offset}`:i}function ev(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,l)=>l.addToSet(o),n)}}function yl({pos:t,node:e,innerDecorations:n}){const r=Wl(),i=rg();if(!e)return null;const o=[],l=t+1,s=[];return qS(e,n,(u,a,c)=>{var d;const f=u.type.spec.marks??[];s.push({type:"widget",widget:u,marks:u.type.side>=0?f:f.reduce((p,h)=>h.addToSet(p),((d=s[0])==null?void 0:d.marks)??[]),offset:a,index:c})},(u,a,c,f)=>{if(!u.isInline){const d=l+f,p=(i==null?void 0:i.posToKey.get(d))??d;o.push(L(og,{outerDeco:a,node:u,innerDeco:c,pos:d},p));return}s.push({type:"node",node:u,marks:u.marks,innerDeco:c,outerDeco:a,offset:f}),ev(s)}),s.length&&o.push(L(lg,{childViews:s,innerPos:l},gi(r==null?void 0:r.doc,l,s[0],i==null?void 0:i.posToKey))),o.length||o.push(L(XS,{},gi(r==null?void 0:r.doc,l,{type:"trailinghack",offset:0},i==null?void 0:i.posToKey))),L(Sl,{children:o})}const tv=O.forwardRef(function({className:e,node:n,innerDeco:r,outerDeco:i,as:o},l){const s=O.useRef(null);O.useImperativeHandle(l,()=>s.current,[]);const u=eg(n,s,s,r,i),a={ref:s,className:e,suppressContentEditableWarning:!0},c=o?O.cloneElement(o,a,L(Ft.Provider,{value:u,children:L(yl,{pos:-1,node:n,innerDecorations:r})})):O.createElement("div",a,L(Ft.Provider,{value:u,children:L(yl,{pos:-1,node:n,innerDecorations:r})}));if(!n)return c;const f=i.filter(p=>!p.inline);return f.length?f.reduce(uc,c):c});function nv({className:t,children:e,nodeViews:n={},as:r,...i}){const[o,l]=O.useState(null),{componentEventListenersPlugin:s,registerEventListener:u,unregisterEventListener:a}=ok(),c=O.useMemo(()=>[...i.plugins??[],s],[i.plugins,s]),f=WS(o,{...i,plugins:c}),d="state"in i?i.state??null:(f==null?void 0:f.state)??null,p=O.useMemo(()=>({editorView:f,editorState:d,registerEventListener:u,unregisterEventListener:a}),[d,f,u,a]);f==null||f.domObserver.stop(),O.useEffect(()=>{f==null||f.domObserver.start()});const h=O.useMemo(()=>i.plugins??[],[i.plugins]);O.useEffect(()=>(f==null||f.domObserver.connectSelection(),()=>f==null?void 0:f.domObserver.disconnectSelection()),[f==null?void 0:f.domObserver]),US(f),JS(f,d,h);const y=f?Bo(f):$e.empty,S=f?Uu(f):[];return L(rk,{children:L(Vl.Provider,{value:p,children:L(ym.Provider,{value:{nodeViews:n},children:Dd(Sl,{children:[L(tv,{className:t,ref:l,node:f==null?void 0:f.state.doc,innerDeco:y,outerDeco:S,as:r}),e]})})})})}function rv(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 iv={side:0};class ac{constructor(e,n){this.Component=e,this.spec=n??iv,this.side=this.spec.side??0}map(e,n,r,i){const{pos:o,deleted:l}=e.mapResult(n.from+i,this.side<0?-1:1);return l?null:new ke(o-r,o-r,this)}valid(){return!0}eq(e){return this==e||e instanceof ac&&(this.spec.key&&this.spec.key==e.spec.key||this.Component==e.Component&&rv(this.spec,e.spec))}destroy(){}}function ov(t,e,n){return new ke(t,t,new ac(e,n))}const le=new Jg({nodes:{doc:{content:"block+"},paragraph:{group:"block",content:"inline*",toDOM(){return["p",0]}},img:{group:"inline",inline:!0,toDOM(){return["img",{src:"data:image/gif;base64,R0lGODlhBQAFAIABAAAAAP///yH5BAEKAAEALAAAAAAFAAUAAAIEjI+pWAA7"}]}},list:{group:"block",content:"list_item+",toDOM(){return["ul",0]}},list_item:{content:"paragraph+",toDOM(){return["li",0]}},text:{group:"inline"}},marks:{em:{toDOM(){return["em",0]}},strong:{toDOM(){return["strong",0]}}}}),lv=Gn.create({schema:le,doc:le.nodes.doc.create({},[le.nodes.paragraph.create({},[le.text("This ",[le.marks.em.create()]),le.text("is",[le.marks.em.create(),le.marks.strong.create()]),le.nodes.img.create(),le.text(" the first paragraph")]),le.nodes.paragraph.create({},le.text("This is the second paragraph")),le.nodes.paragraph.create(),le.nodes.paragraph.create({},le.text("This is the third paragraph"))]),plugins:[YS()]}),sv=O.forwardRef(function({children:e,nodeProps:n,...r},i){return L("p",{ref:i,...r,children:e})}),uv=O.forwardRef(function(e,n){return L("span",{...e,ref:n,style:{display:"inline-block",padding:"0.75rem 1rem",border:"solid thin black"},children:"Widget"})}),av=new xl({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)}}}}),cv=[Yy({...Wy,"Mod-i":Dc(le.marks.em),"Mod-b":Dc(le.marks.strong)}),av];function fv(){const[t,e]=O.useState(lv);return Dd("main",{children:[L("h1",{children:"React ProseMirror Demo"}),L(nv,{as:L("article",{}),className:"ProseMirror",state:t,dispatchTransaction:function(n){e(r=>r.apply(n))},decorations:n=>{const r=[ke.inline(5,15,{class:"inline-deco"})];return n.doc.forEach((i,o,l)=>{l===1&&r.push(ke.node(o,o+i.nodeSize,{nodeName:"div",class:"node-deco"})),l===2&&r.push(ke.node(o,o+i.nodeSize,{class:"node-deco"})),l===3&&r.push(ov(o+i.nodeSize-20,uv,{side:0,key:"widget-deco"}))}),$e.create(n.doc,r)},plugins:cv,nodeViews:{paragraph:sv}})]})}const dv=mm(document.getElementById("root"));dv.render(L(fv,{})); +*/(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;)s.push(i[l++]);let d=o+c.nodeSize;if(c.isText){let h=d;l!h.inline):s.slice();r(c,p,e.forChild(o,c),o,f),o=d}}function Ul(){const{editorState:t}=O.useContext(_l);return t}function vo(t){const e=Math.floor(Math.random()*16777215).toString(16);return t.isTextblock&&t.textContent===""?`${e}-empty`:e}const ng=new oh("@nytimes/react-prosemirror/reactKeys");function YS(){let t=!1;return new Cl({key:ng,state:{init(e,n){const r={posToKey:new Map,keyToPos:new Map};return n.doc.descendants((i,o)=>{const l=vo(i);return r.posToKey.set(o,l),r.keyToPos.set(l,o),!0}),r},apply(e,n,r,i){if(!e.docChanged||t)return n;const o={posToKey:new Map,keyToPos:new Map},l=new Set;return i.doc.descendants((s,u)=>{const a=e.mapping.invert().map(u),c=n.posToKey.get(a)??vo(s);let f=l.has(c)?vo(s):c;return(f.endsWith("-empty")&&s.isTextblock&&s.textContent!==""||!f.endsWith("-empty")&&s.isTextblock&&s.textContent==="")&&(f=vo(s)),o.posToKey.set(u,f),o.keyToPos.set(f,u),l.add(f),!0}),o}},props:{handleDOMEvents:{compositionstart:()=>{t=!0},compositionend:()=>{t=!1}}}})}function rg(){const t=Ul();return t&&ng.getState(t)}const uc=O.forwardRef(function({outputSpec:e,children:n,...r},i){if(typeof e=="string")return L(vl,{children:e});if(!Array.isArray(e))throw new Error("@nytimes/react-prosemirror only supports strings and arrays in toDOM");const l=e[0].replace(" ",":"),s=e[1],u={...r,ref:i};let a=1;if(s&&typeof s=="object"&&s.nodeType==null&&!Array.isArray(s)){a=2;for(const f in s)if(s[f]!=null){const d=f==="class"?"className":f.replace(" ",":");u[d]=s[f]}}const c=[];for(let f=a;fa)throw new RangeError("Content hole must be the only child of its parent node");return O.createElement(l,u,n)}c.push(L(uc,{ref:void 0,outputSpec:d,children:n}))}return O.createElement(l,u,...c)}),ig=O.forwardRef(function({mark:e,children:n},r){var u,a;const i=O.useContext(Ft),o=[],l=O.useRef(null);O.useImperativeHandle(r,()=>l.current,[]);const s=(a=(u=e.type.spec).toDOM)==null?void 0:a.call(u,e,!0);if(!s)throw new Error(`Mark spec for ${e.type.name} is missing toDOM`);return O.useLayoutEffect(()=>{if(!l.current)return;const c=o[0],f=new un(void 0,o,e,l.current,(c==null?void 0:c.dom.parentElement)??l.current);i.push(f);for(const d of o)d.parent=f}),L(uc,{ref:l,outputSpec:s,children:L(Ft.Provider,{value:o,children:n})})});function og({outerDeco:t,pos:e,node:n,innerDeco:r,...i}){var h,y;const o=O.useRef(null),l=O.useRef(null),s=eg(n,o,l,r,t),u=Ul(),{nodeViews:a}=O.useContext(ym);let c=null;const f=a[n.type.name];if(f)c=L(f,{...i,ref:l,nodeProps:{node:n,pos:e,decorations:t,innerDecorations:r,isSelected:(u==null?void 0:u.selection)instanceof A&&u.selection.node===n},children:L(kl,{pos:e,node:n,innerDecorations:r})});else{const S=(y=(h=n.type.spec).toDOM)==null?void 0:y.call(h,n);S&&(c=L(uc,{...i,ref:l,outputSpec:S,children:L(kl,{pos:e,node:n,innerDecorations:r})}))}if(!c)throw new Error(`Node spec for ${n.type.name} is missing toDOM`);const d=O.cloneElement(t.reduce(ac,c),t.some(S=>S.type.attrs.nodeName)?{ref:o}:void 0),p=n.marks.reduce((S,g)=>L(ig,{mark:g,children:S}),d);return L(Ft.Provider,{value:s,children:O.cloneElement(p,n.marks.length||t.some(S=>S.type.attrs.nodeName)?{ref:o}:void 0)})}class GS extends O.Component{constructor(){super(...arguments),this.renderRef=null}componentDidMount(){const e=Vi.findDOMNode(this);if(!e)return;let n=e;for(;n.firstChild;)n=n.firstChild;const r=new Tr(void 0,[],this.props.node,this.props.decorations,Fe.empty,e,n);this.props.siblingDescriptors.push(r)}componentDidUpdate(){const e=Vi.findDOMNode(this);if(!e)return;let n=e;for(;n.firstChild;)n=n.firstChild;const r=new Tr(void 0,[],this.props.node,this.props.decorations,Fe.empty,e,n);this.props.siblingDescriptors.push(r)}render(){const{view:e,pos:n,node:r}=this.props;return e!=null&&e.composing&&e.state.selection.from>=n&&e.state.selection.from<=n+r.nodeSize?this.renderRef:(this.renderRef=this.props.decorations.reduce(ac,this.props.node.text),this.renderRef)}}function XS(){const t=O.useContext(Ft),e=O.useRef(null);return O.useLayoutEffect(()=>{if(!e.current)return;const n=new Xa(void 0,[],e.current,null);t.push(n)}),L("br",{ref:e,className:"ProseMirror-trailingBreak"})}function ZS({widget:t,pos:e}){const n=O.useContext(Ft),r=O.useRef(null);O.useLayoutEffect(()=>{if(!r.current)return;const o=new Ga(void 0,t,r.current);n.push(o)});const{Component:i}=t.type;return i&&L(i,{ref:r,widget:t,pos:e,contentEditable:!1})}function kd(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,l=>{var s;return((s=l[1])==null?void 0:s.toUpperCase())??""});return{...r,[o]:n[i]}},{})}function ac(t,e){const{nodeName:n,class:r,style:i,contenteditable:o,spellcheck:l,...s}=e.type.attrs;return n||typeof t=="string"?O.createElement(n??"span",{className:r,contentEditable:o,spellCheck:l,style:i&&kd(i),...s},t):O.cloneElement(t,{className:KS(t.props.className,r),contentEditable:o,spellCheck:l,style:{...t.props.style,...i&&kd(i)},...s})}function lg({innerPos:t,childViews:e}){const{editorView:n}=O.useContext(_l),r=Ul(),i=rg(),o=e.reduce((l,s)=>{var c;const u=l[l.length-1];if(!u)return[[s]];const a=u[u.length-1];return a?!s.marks.length&&!a.marks.length||s.marks.length&&a.marks.length&&((c=s.marks[0])!=null&&c.eq(a.marks[0]))?[...l.slice(0,l.length-1),[...u.slice(0,u.length),s]]:[...l,[s]]:[...l.slice(0,l.length),[s]]},[]);return L(vl,{children:o.map(l=>{const s=l[0];if(!s)return null;const u=s.marks[0];return u?L(ig,{mark:u,children:L(lg,{innerPos:t,childViews:l.map(a=>({...a,marks:a.marks.slice(1)}))},yi(r==null?void 0:r.doc,t,s,i==null?void 0:i.posToKey))},yi(r==null?void 0:r.doc,t,s,i==null?void 0:i.posToKey)):l.map(a=>{const c=t+a.offset,f=a.type==="widget"?L(ZS,{widget:a.widget,pos:c}):a.node.isText?L(Ft.Consumer,{children:d=>L(GS,{view:n,node:a.node,pos:c,siblingDescriptors:d,decorations:a.outerDeco})}):L(og,{node:a.node,pos:c,outerDeco:a.outerDeco,innerDeco:a.innerDeco});return O.cloneElement(f,{key:yi(r==null?void 0:r.doc,t,a,i==null?void 0:i.posToKey)})})})})}function yi(t,e,n,r){const i=e+n.offset,o=r==null?void 0:r.get(i);if(n.type==="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 l=t.resolve(i).start()-1,s=r==null?void 0:r.get(l);return s?`${s}-${n.offset}`:i}function ev(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,l)=>l.addToSet(o),n)}}function kl({pos:t,node:e,innerDecorations:n}){const r=Ul(),i=rg();if(!e)return null;const o=[],l=t+1,s=[];return qS(e,n,(u,a,c)=>{var d;const f=u.type.spec.marks??[];s.push({type:"widget",widget:u,marks:u.type.side>=0?f:f.reduce((p,h)=>h.addToSet(p),((d=s[0])==null?void 0:d.marks)??[]),offset:a,index:c})},(u,a,c,f)=>{if(!u.isInline){const d=l+f,p=(i==null?void 0:i.posToKey.get(d))??d;o.push(L(og,{outerDeco:a,node:u,innerDeco:c,pos:d},p));return}s.push({type:"node",node:u,marks:u.marks,innerDeco:c,outerDeco:a,offset:f}),ev(s)}),s.length&&o.push(L(lg,{childViews:s,innerPos:l},yi(r==null?void 0:r.doc,l,s[0],i==null?void 0:i.posToKey))),o.length||o.push(L(XS,{},yi(r==null?void 0:r.doc,l,{type:"trailinghack",offset:0},i==null?void 0:i.posToKey))),L(vl,{children:o})}const tv=O.forwardRef(function({className:e,node:n,innerDeco:r,outerDeco:i,as:o,viewDesc:l},s){const u=O.useRef(null);O.useImperativeHandle(s,()=>u.current,[]);const a=eg(n,u,u,r,i,l),c={ref:u,className:e,suppressContentEditableWarning:!0},f=o?O.cloneElement(o,c,L(Ft.Provider,{value:a,children:L(kl,{pos:-1,node:n,innerDecorations:r})})):O.createElement("div",c,L(Ft.Provider,{value:a,children:L(kl,{pos:-1,node:n,innerDecorations:r})}));if(!n)return f;const d=i.filter(h=>!h.inline);return d.length?d.reduce(ac,f):f});function nv({className:t,children:e,nodeViews:n={},as:r,...i}){const[o,l]=O.useState(null),{componentEventListenersPlugin:s,registerEventListener:u,unregisterEventListener:a}=ok(),c=O.useMemo(()=>[...i.plugins??[],s],[i.plugins,s]),f="defaultState"in i?i.defaultState:i.state,d=document.createElement("div"),p=O.useRef(new gt(void 0,[],f.doc,[],Fe.empty,d,null,d)),h=WS(o,{...i,docView:p.current,plugins:c}),y="state"in i?i.state??null:(h==null?void 0:h.state)??null,S=O.useMemo(()=>({editorView:h,editorState:y,registerEventListener:u,unregisterEventListener:a}),[y,h,u,a]);h==null||h.domObserver.stop(),O.useEffect(()=>{h==null||h.domObserver.start()});const g=O.useMemo(()=>i.plugins??[],[i.plugins]);O.useEffect(()=>(h==null||h.domObserver.connectSelection(),()=>h==null?void 0:h.domObserver.disconnectSelection()),[h==null?void 0:h.domObserver]),US(h),JS(h,y,g);const m=h?ei(h):Fe.empty,k=h?Vo(h):[];return L(rk,{children:L(_l.Provider,{value:S,children:L(ym.Provider,{value:{nodeViews:n},children:Dd(vl,{children:[L(tv,{className:t,ref:l,node:h==null?void 0:h.state.doc,innerDeco:m,outerDeco:k,as:r,viewDesc:p.current}),e]})})})})}function rv(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 iv={side:0};class cc{constructor(e,n){this.Component=e,this.spec=n??iv,this.side=this.spec.side??0}map(e,n,r,i){const{pos:o,deleted:l}=e.mapResult(n.from+i,this.side<0?-1:1);return l?null:new ke(o-r,o-r,this)}valid(){return!0}eq(e){return this==e||e instanceof cc&&(this.spec.key&&this.spec.key==e.spec.key||this.Component==e.Component&&rv(this.spec,e.spec))}destroy(){}}function ov(t,e,n){return new ke(t,t,new cc(e,n))}const le=new Jg({nodes:{doc:{content:"block+"},paragraph:{group:"block",content:"inline*",toDOM(){return["p",0]}},img:{group:"inline",inline:!0,toDOM(){return["img",{src:"data:image/gif;base64,R0lGODlhBQAFAIABAAAAAP///yH5BAEKAAEALAAAAAAFAAUAAAIEjI+pWAA7"}]}},list:{group:"block",content:"list_item+",toDOM(){return["ul",0]}},list_item:{content:"paragraph+",toDOM(){return["li",0]}},text:{group:"inline"}},marks:{em:{toDOM(){return["em",0]}},strong:{toDOM(){return["strong",0]}}}}),lv=Gn.create({schema:le,doc:le.nodes.doc.create({},[le.nodes.paragraph.create({},[le.text("This ",[le.marks.em.create()]),le.text("is",[le.marks.em.create(),le.marks.strong.create()]),le.nodes.img.create(),le.text(" the first paragraph")]),le.nodes.paragraph.create({},le.text("This is the second paragraph")),le.nodes.paragraph.create(),le.nodes.paragraph.create({},le.text("This is the third paragraph"))]),plugins:[YS()]}),sv=O.forwardRef(function({children:e,nodeProps:n,...r},i){return L("p",{ref:i,...r,children:e})}),uv=O.forwardRef(function(e,n){return L("span",{...e,ref:n,style:{display:"inline-block",padding:"0.75rem 1rem",border:"solid thin black"},children:"Widget"})}),av=new Cl({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)}}}}),cv=[Yy({...Wy,"Mod-i":Rc(le.marks.em),"Mod-b":Rc(le.marks.strong)}),av];function fv(){const[t,e]=O.useState(lv);return Dd("main",{children:[L("h1",{children:"React ProseMirror Demo"}),L(nv,{as:L("article",{}),className:"ProseMirror",state:t,dispatchTransaction:function(n){e(r=>r.apply(n))},decorations:n=>{const r=[ke.inline(5,15,{class:"inline-deco"})];return n.doc.forEach((i,o,l)=>{l===1&&r.push(ke.node(o,o+i.nodeSize,{nodeName:"div",class:"node-deco"})),l===2&&r.push(ke.node(o,o+i.nodeSize,{class:"node-deco"})),l===3&&r.push(ov(o+i.nodeSize-20,uv,{side:0,key:"widget-deco"}))}),Fe.create(n.doc,r)},plugins:cv,nodeViews:{paragraph:sv}})]})}const dv=mm(document.getElementById("root"));dv.render(L(fv,{})); diff --git a/docs/index.html b/docs/index.html index 848d9244..6c2df375 100644 --- a/docs/index.html +++ b/docs/index.html @@ -5,7 +5,7 @@ React-ProseMirror Demo - + diff --git a/src/components/ChildNodeViews.tsx b/src/components/ChildNodeViews.tsx index 78b4743f..cee9e2b9 100644 --- a/src/components/ChildNodeViews.tsx +++ b/src/components/ChildNodeViews.tsx @@ -162,6 +162,7 @@ function InlineView({ innerPos, childViews }: SharedMarksProps) { diff --git a/src/components/DocNodeView.tsx b/src/components/DocNodeView.tsx index bcf53698..7e2e0753 100644 --- a/src/components/DocNodeView.tsx +++ b/src/components/DocNodeView.tsx @@ -18,6 +18,7 @@ import { Decoration, DecorationSource, } from "../prosemirror-view/decoration.js"; +import { NodeViewDesc } from "../prosemirror-view/viewdesc.js"; import { ChildNodeViews, wrapInDeco } from "./ChildNodeViews.js"; @@ -27,10 +28,11 @@ type Props = { innerDeco: DecorationSource; outerDeco: Decoration[]; as?: ReactElement; + viewDesc?: NodeViewDesc; }; export const DocNodeView = forwardRef(function DocNodeView( - { className, node, innerDeco, outerDeco, as }: Props, + { className, node, innerDeco, outerDeco, as, viewDesc }: Props, ref: ForwardedRef ) { const innerRef = useRef(null); @@ -48,7 +50,8 @@ export const DocNodeView = forwardRef(function DocNodeView( innerRef, innerRef, innerDeco, - outerDeco + outerDeco, + viewDesc ); const props = { diff --git a/src/components/ProseMirror.tsx b/src/components/ProseMirror.tsx index d8c93c85..affa5dfb 100644 --- a/src/components/ProseMirror.tsx +++ b/src/components/ProseMirror.tsx @@ -1,5 +1,4 @@ import { Command, EditorState, Transaction } from "prosemirror-state"; -import { DecorationSet } from "prosemirror-view"; import React, { ForwardRefExoticComponent, ReactElement, @@ -7,6 +6,7 @@ import React, { RefAttributes, useEffect, useMemo, + useRef, useState, } from "react"; @@ -17,13 +17,17 @@ import { useComponentEventListeners } from "../hooks/useComponentEventListeners. import { useEditorView } from "../hooks/useEditorView.js"; import { useSyncSelection } from "../hooks/useSyncSelection.js"; import { usePluginViews } from "../hooks/useViewPlugins.js"; -import { viewDecorations } from "../prosemirror-view/decoration.js"; +import { + DecorationSet, + viewDecorations, +} from "../prosemirror-view/decoration.js"; import { DecorationSet as DecorationSetInternal, DirectEditorProps, EditorView as EditorViewClass, computeDocDeco, } from "../prosemirror-view/index.js"; +import { NodeViewDesc } from "../prosemirror-view/viewdesc.js"; import { DocNodeView } from "./DocNodeView.js"; import { NodeViewComponentProps } from "./NodeViewComponentProps.js"; @@ -83,7 +87,28 @@ export function ProseMirror({ [props.plugins, componentEventListenersPlugin] ); - const editorView = useEditorView(mount, { ...props, plugins }); + const initialEditorState = ( + "defaultState" in props ? props.defaultState : props.state + ) as EditorState; + const tempDom = document.createElement("div"); + const docViewDescRef = useRef( + new NodeViewDesc( + undefined, + [], + initialEditorState.doc, + [], + DecorationSetInternal.empty, + tempDom, + null, + tempDom + ) + ); + + const editorView = useEditorView(mount, { + ...props, + docView: docViewDescRef.current, + plugins, + }); const editorState = "state" in props ? props.state ?? null : editorView?.state ?? null; @@ -139,6 +164,7 @@ export function ProseMirror({ innerDeco={innerDecos as unknown as DecorationSetInternal} outerDeco={outerDecos} as={as} + viewDesc={docViewDescRef.current} /> {children} diff --git a/src/components/TextNodeView.tsx b/src/components/TextNodeView.tsx index e5cd5705..61f43e2e 100644 --- a/src/components/TextNodeView.tsx +++ b/src/components/TextNodeView.tsx @@ -11,6 +11,7 @@ import { wrapInDeco } from "./ChildNodeViews.js"; type Props = { view: EditorView | null; node: Node; + pos: number; siblingDescriptors: ViewDesc[]; decorations: readonly Decoration[]; }; @@ -65,7 +66,12 @@ export class TextNodeView extends Component { } render() { - if (this.props.view?.composing) { + const { view, pos, node } = this.props; + if ( + view?.composing && + view.state.selection.from >= pos && + view.state.selection.from <= pos + node.nodeSize + ) { return this.renderRef; } diff --git a/src/hooks/useEditorView.ts b/src/hooks/useEditorView.ts index 2a7cfa37..98ba9a36 100644 --- a/src/hooks/useEditorView.ts +++ b/src/hooks/useEditorView.ts @@ -7,7 +7,6 @@ import { storeScrollPos, } from "../prosemirror-view/domcoords.js"; import { DirectEditorProps, EditorView } from "../prosemirror-view/index.js"; -import { NodeViewDesc } from "../prosemirror-view/viewdesc.js"; import { useForceUpdate } from "./useForceUpdate.js"; @@ -52,15 +51,6 @@ class ReactEditorView extends EditorView { resetScrollPos(oldScrollPos); } } - - // @ts-expect-error We need this to be an accessor - set docView(_) { - // disallowed - } - - get docView() { - return this.dom.pmViewDesc as NodeViewDesc; - } } function withBatchedUpdates( diff --git a/src/hooks/useNodeViewDescriptor.ts b/src/hooks/useNodeViewDescriptor.ts index 1bf321aa..d26ccacf 100644 --- a/src/hooks/useNodeViewDescriptor.ts +++ b/src/hooks/useNodeViewDescriptor.ts @@ -1,5 +1,5 @@ import { Node } from "prosemirror-model"; -import { MutableRefObject, useContext, useLayoutEffect } from "react"; +import { MutableRefObject, useContext, useLayoutEffect, useRef } from "react"; import { ChildDescriptorsContext } from "../contexts/ChildDescriptorsContext.js"; import { @@ -13,8 +13,10 @@ export function useNodeViewDescriptor( domRef: undefined | MutableRefObject, nodeDomRef: MutableRefObject, innerDecorations: DecorationSource, - outerDecorations: readonly Decoration[] + outerDecorations: readonly Decoration[], + viewDesc?: NodeViewDesc ) { + const nodeViewDescRef = useRef(viewDesc); const siblingDescriptors = useContext(ChildDescriptorsContext); const childDescriptors: ViewDesc[] = []; @@ -23,20 +25,34 @@ export function useNodeViewDescriptor( const firstChildDesc = childDescriptors[0]; - const desc = new NodeViewDesc( - undefined, - childDescriptors, - node, - outerDecorations, - innerDecorations, - domRef?.current ?? nodeDomRef.current, - firstChildDesc?.dom.parentElement ?? null, - nodeDomRef.current - ); - siblingDescriptors.push(desc); + if (!nodeViewDescRef.current) { + nodeViewDescRef.current = new NodeViewDesc( + undefined, + childDescriptors, + node, + outerDecorations, + innerDecorations, + domRef?.current ?? nodeDomRef.current, + firstChildDesc?.dom.parentElement ?? null, + nodeDomRef.current + ); + } else { + nodeViewDescRef.current.parent = undefined; + nodeViewDescRef.current.children = childDescriptors; + nodeViewDescRef.current.node = node; + nodeViewDescRef.current.outerDeco = outerDecorations; + nodeViewDescRef.current.innerDeco = innerDecorations; + nodeViewDescRef.current.dom = domRef?.current ?? nodeDomRef.current; + // @ts-expect-error ??? + nodeViewDescRef.current.dom.pmViewDesc = nodeViewDescRef.current; + nodeViewDescRef.current.contentDOM = + firstChildDesc?.dom.parentElement ?? null; + nodeViewDescRef.current.nodeDOM = nodeDomRef.current; + } + siblingDescriptors.push(nodeViewDescRef.current); for (const childDesc of childDescriptors) { - childDesc.parent = desc; + childDesc.parent = nodeViewDescRef.current; } }); diff --git a/src/prosemirror-view/index.ts b/src/prosemirror-view/index.ts index 338959d7..0c6a11ea 100644 --- a/src/prosemirror-view/index.ts +++ b/src/prosemirror-view/index.ts @@ -84,7 +84,7 @@ export class EditorView { this.editable = getEditable(this) this.nodeViews = buildNodeViews(this) - this.docView = null as unknown as NodeViewDesc + this.docView = props.docView ?? docViewDesc(this.state.doc, computeDocDeco(this), viewDecorations(this), this.dom, this) this.domObserver = new DOMObserver(this, (from, to, typeOver, added) => readDOMChange(this, from, to, typeOver, added)) this.init(); @@ -797,4 +797,6 @@ export interface DirectEditorProps extends EditorProps { /// [applied](#state.EditorState.apply). The callback will be bound to have /// the view instance as its `this` binding. dispatchTransaction?: (tr: Transaction) => void + + docView?: NodeViewDesc } diff --git a/src/prosemirror-view/viewdesc.ts b/src/prosemirror-view/viewdesc.ts index 08f29f0d..f4da6b1d 100644 --- a/src/prosemirror-view/viewdesc.ts +++ b/src/prosemirror-view/viewdesc.ts @@ -652,7 +652,7 @@ export class NodeViewDesc extends ViewDesc { public innerDeco: DecorationSource, dom: DOMNode, contentDOM: HTMLElement | null, - readonly nodeDOM: DOMNode, + public nodeDOM: DOMNode, ) { super(parent, children, dom, contentDOM) }