@alxgrn/prose-editor 0.0.31 → 0.0.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/prose-editor.umd.js
CHANGED
|
@@ -15,38 +15,38 @@
|
|
|
15
15
|
*
|
|
16
16
|
* This source code is licensed under the MIT license found in the
|
|
17
17
|
* LICENSE file in the root directory of this source tree.
|
|
18
|
-
*/var fi;function bf(){return fi||(fi=1,process.env.NODE_ENV!=="production"&&function(){function n(x){if(x==null)return null;if(typeof x=="function")return x.$$typeof===io?null:x.displayName||x.name||null;if(typeof x=="string")return x;switch(x){case
|
|
18
|
+
*/var fi;function bf(){return fi||(fi=1,process.env.NODE_ENV!=="production"&&function(){function n(x){if(x==null)return null;if(typeof x=="function")return x.$$typeof===io?null:x.displayName||x.name||null;if(typeof x=="string")return x;switch(x){case w:return"Fragment";case I:return"Portal";case z:return"Profiler";case V:return"StrictMode";case Et:return"Suspense";case Ae:return"SuspenseList"}if(typeof x=="object")switch(typeof x.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),x.$$typeof){case L:return(x.displayName||"Context")+".Provider";case T:return(x._context.displayName||"Context")+".Consumer";case we:var v=x.render;return x=x.displayName,x||(x=v.displayName||v.name||"",x=x!==""?"ForwardRef("+x+")":"ForwardRef"),x;case ze:return v=x.displayName||null,v!==null?v:n(x.type)||"Memo";case Yt:v=x._payload,x=x._init;try{return n(x(v))}catch{}}return null}function e(x){return""+x}function t(x){try{e(x);var v=!1}catch{v=!0}if(v){v=console;var A=v.error,B=typeof Symbol=="function"&&Symbol.toStringTag&&x[Symbol.toStringTag]||x.constructor.name||"Object";return A.call(v,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",B),e(x)}}function r(){}function o(){if(ir===0){Uu=console.log,Qu=console.info,Zu=console.warn,ef=console.error,tf=console.group,nf=console.groupCollapsed,rf=console.groupEnd;var x={configurable:!0,enumerable:!0,value:r,writable:!0};Object.defineProperties(console,{info:x,log:x,warn:x,error:x,group:x,groupCollapsed:x,groupEnd:x})}ir++}function s(){if(ir--,ir===0){var x={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:Xt({},x,{value:Uu}),info:Xt({},x,{value:Qu}),warn:Xt({},x,{value:Zu}),error:Xt({},x,{value:ef}),group:Xt({},x,{value:tf}),groupCollapsed:Xt({},x,{value:nf}),groupEnd:Xt({},x,{value:rf})})}0>ir&&console.error("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}function i(x){if(oi===void 0)try{throw Error()}catch(A){var v=A.stack.trim().match(/\n( *(at )?)/);oi=v&&v[1]||"",of=-1<A.stack.indexOf(`
|
|
19
19
|
at`)?" (<anonymous>)":-1<A.stack.indexOf("@")?"@unknown:0:0":""}return`
|
|
20
20
|
`+oi+x+of}function l(x,v){if(!x||si)return"";var A=ii.get(x);if(A!==void 0)return A;si=!0,A=Error.prepareStackTrace,Error.prepareStackTrace=void 0;var B=null;B=Gt.H,Gt.H=null,o();try{var ce={DetermineComponentFrameRoot:function(){try{if(v){var Dt=function(){throw Error()};if(Object.defineProperty(Dt.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(Dt,[])}catch(rt){var lo=rt}Reflect.construct(x,[],Dt)}else{try{Dt.call()}catch(rt){lo=rt}x.call(Dt.prototype)}}else{try{throw Error()}catch(rt){lo=rt}(Dt=x())&&typeof Dt.catch=="function"&&Dt.catch(function(){})}}catch(rt){if(rt&&lo&&typeof rt.stack=="string")return[rt.stack,lo.stack]}return[null,null]}};ce.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var _=Object.getOwnPropertyDescriptor(ce.DetermineComponentFrameRoot,"name");_&&_.configurable&&Object.defineProperty(ce.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var $=ce.DetermineComponentFrameRoot(),nt=$[0],bn=$[1];if(nt&&bn){var me=nt.split(`
|
|
21
21
|
`),Ut=bn.split(`
|
|
22
22
|
`);for($=_=0;_<me.length&&!me[_].includes("DetermineComponentFrameRoot");)_++;for(;$<Ut.length&&!Ut[$].includes("DetermineComponentFrameRoot");)$++;if(_===me.length||$===Ut.length)for(_=me.length-1,$=Ut.length-1;1<=_&&0<=$&&me[_]!==Ut[$];)$--;for(;1<=_&&0<=$;_--,$--)if(me[_]!==Ut[$]){if(_!==1||$!==1)do if(_--,$--,0>$||me[_]!==Ut[$]){var lr=`
|
|
23
|
-
`+me[_].replace(" at new "," at ");return x.displayName&&lr.includes("<anonymous>")&&(lr=lr.replace("<anonymous>",x.displayName)),typeof x=="function"&&ii.set(x,lr),lr}while(1<=_&&0<=$);break}}}finally{si=!1,Gt.H=B,s(),Error.prepareStackTrace=A}return me=(me=x?x.displayName||x.name:"")?i(me):"",typeof x=="function"&&ii.set(x,me),me}function a(x){if(x==null)return"";if(typeof x=="function"){var v=x.prototype;return l(x,!(!v||!v.isReactComponent))}if(typeof x=="string")return i(x);switch(x){case Et:return i("Suspense");case Ae:return i("SuspenseList")}if(typeof x=="object")switch(x.$$typeof){case we:return x=l(x.render,!1),x;case ze:return a(x.type);case Yt:v=x._payload,x=x._init;try{return a(x(v))}catch{}}return""}function c(){var x=Gt.A;return x===null?null:x.getOwner()}function u(x){if(Xu.call(x,"key")){var v=Object.getOwnPropertyDescriptor(x,"key").get;if(v&&v.isReactWarning)return!1}return x.key!==void 0}function f(x,v){function A(){sf||(sf=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",v))}A.isReactWarning=!0,Object.defineProperty(x,"key",{get:A,configurable:!0})}function d(){var x=n(this.type);return lf[x]||(lf[x]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),x=this.props.ref,x!==void 0?x:null}function
|
|
23
|
+
`+me[_].replace(" at new "," at ");return x.displayName&&lr.includes("<anonymous>")&&(lr=lr.replace("<anonymous>",x.displayName)),typeof x=="function"&&ii.set(x,lr),lr}while(1<=_&&0<=$);break}}}finally{si=!1,Gt.H=B,s(),Error.prepareStackTrace=A}return me=(me=x?x.displayName||x.name:"")?i(me):"",typeof x=="function"&&ii.set(x,me),me}function a(x){if(x==null)return"";if(typeof x=="function"){var v=x.prototype;return l(x,!(!v||!v.isReactComponent))}if(typeof x=="string")return i(x);switch(x){case Et:return i("Suspense");case Ae:return i("SuspenseList")}if(typeof x=="object")switch(x.$$typeof){case we:return x=l(x.render,!1),x;case ze:return a(x.type);case Yt:v=x._payload,x=x._init;try{return a(x(v))}catch{}}return""}function c(){var x=Gt.A;return x===null?null:x.getOwner()}function u(x){if(Xu.call(x,"key")){var v=Object.getOwnPropertyDescriptor(x,"key").get;if(v&&v.isReactWarning)return!1}return x.key!==void 0}function f(x,v){function A(){sf||(sf=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",v))}A.isReactWarning=!0,Object.defineProperty(x,"key",{get:A,configurable:!0})}function d(){var x=n(this.type);return lf[x]||(lf[x]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),x=this.props.ref,x!==void 0?x:null}function h(x,v,A,B,ce,_){return A=_.ref,x={$$typeof:O,type:x,key:v,props:_,_owner:ce},(A!==void 0?A:null)!==null?Object.defineProperty(x,"ref",{enumerable:!1,get:d}):Object.defineProperty(x,"ref",{enumerable:!1,value:null}),x._store={},Object.defineProperty(x._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(x,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.freeze&&(Object.freeze(x.props),Object.freeze(x)),x}function p(x,v,A,B,ce,_){if(typeof x=="string"||typeof x=="function"||x===w||x===z||x===V||x===Et||x===Ae||x===yn||typeof x=="object"&&x!==null&&(x.$$typeof===Yt||x.$$typeof===ze||x.$$typeof===L||x.$$typeof===T||x.$$typeof===we||x.$$typeof===N0||x.getModuleId!==void 0)){var $=v.children;if($!==void 0)if(B)if(ri($)){for(B=0;B<$.length;B++)b($[B],x);Object.freeze&&Object.freeze($)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else b($,x)}else $="",(x===void 0||typeof x=="object"&&x!==null&&Object.keys(x).length===0)&&($+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports."),x===null?B="null":ri(x)?B="array":x!==void 0&&x.$$typeof===O?(B="<"+(n(x.type)||"Unknown")+" />",$=" Did you accidentally export a JSX literal instead of a component?"):B=typeof x,console.error("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",B,$);if(Xu.call(v,"key")){$=n(x);var nt=Object.keys(v).filter(function(me){return me!=="key"});B=0<nt.length?"{key: someKey, "+nt.join(": ..., ")+": ...}":"{key: someKey}",af[$+B]||(nt=0<nt.length?"{"+nt.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
|
|
24
24
|
let props = %s;
|
|
25
25
|
<%s {...props} />
|
|
26
26
|
React keys must be passed directly to JSX without using spread:
|
|
27
27
|
let props = %s;
|
|
28
|
-
<%s key={someKey} {...props} />`,B,$,nt,$),af[$+B]=!0)}if($=null,A!==void 0&&(t(A),$=""+A),u(v)&&(t(v.key),$=""+v.key),"key"in v){A={};for(var bn in v)bn!=="key"&&(A[bn]=v[bn])}else A=v;return $&&f(A,typeof x=="function"?x.displayName||x.name||"Unknown":x),
|
|
28
|
+
<%s key={someKey} {...props} />`,B,$,nt,$),af[$+B]=!0)}if($=null,A!==void 0&&(t(A),$=""+A),u(v)&&(t(v.key),$=""+v.key),"key"in v){A={};for(var bn in v)bn!=="key"&&(A[bn]=v[bn])}else A=v;return $&&f(A,typeof x=="function"?x.displayName||x.name||"Unknown":x),h(x,$,_,ce,c(),A)}function b(x,v){if(typeof x=="object"&&x&&x.$$typeof!==E0){if(ri(x))for(var A=0;A<x.length;A++){var B=x[A];g(B)&&k(B,v)}else if(g(x))x._store&&(x._store.validated=1);else if(x===null||typeof x!="object"?A=null:(A=sr&&x[sr]||x["@@iterator"],A=typeof A=="function"?A:null),typeof A=="function"&&A!==x.entries&&(A=A.call(x),A!==x))for(;!(x=A.next()).done;)g(x.value)&&k(x.value,v)}}function g(x){return typeof x=="object"&&x!==null&&x.$$typeof===O}function k(x,v){if(x._store&&!x._store.validated&&x.key==null&&(x._store.validated=1,v=S(v),!cf[v])){cf[v]=!0;var A="";x&&x._owner!=null&&x._owner!==c()&&(A=null,typeof x._owner.tag=="number"?A=n(x._owner.type):typeof x._owner.name=="string"&&(A=x._owner.name),A=" It was passed a child from "+A+".");var B=Gt.getCurrentStack;Gt.getCurrentStack=function(){var ce=a(x.type);return B&&(ce+=B()||""),ce},console.error('Each child in a list should have a unique "key" prop.%s%s See https://react.dev/link/warning-keys for more information.',v,A),Gt.getCurrentStack=B}}function S(x){var v="",A=c();return A&&(A=n(A.type))&&(v=`
|
|
29
29
|
|
|
30
30
|
Check the render method of \``+A+"`."),v||(x=n(x))&&(v=`
|
|
31
31
|
|
|
32
|
-
Check the top-level render call using <`+x+">."),v}var M=m,O=Symbol.for("react.transitional.element"),I=Symbol.for("react.portal"),C=Symbol.for("react.fragment"),V=Symbol.for("react.strict_mode"),z=Symbol.for("react.profiler"),T=Symbol.for("react.consumer"),L=Symbol.for("react.context"),we=Symbol.for("react.forward_ref"),Et=Symbol.for("react.suspense"),Ae=Symbol.for("react.suspense_list"),ze=Symbol.for("react.memo"),Yt=Symbol.for("react.lazy"),yn=Symbol.for("react.offscreen"),sr=Symbol.iterator,io=Symbol.for("react.client.reference"),Gt=M.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Xu=Object.prototype.hasOwnProperty,Xt=Object.assign,N0=Symbol.for("react.client.reference"),ri=Array.isArray,ir=0,Uu,Qu,Zu,ef,tf,nf,rf;r.__reactDisabledLog=!0;var oi,of,si=!1,ii=new(typeof WeakMap=="function"?WeakMap:Map),E0=Symbol.for("react.client.reference"),sf,lf={},af={},cf={};wn.Fragment=C,wn.jsx=function(x,v,A,B,ce){return h(x,v,A,!1,B,ce)},wn.jsxs=function(x,v,A,B,ce){return h(x,v,A,!0,B,ce)}}()),wn}process.env.NODE_ENV==="production"?co.exports=yf():co.exports=bf();var y=co.exports;function Z(n){this.content=n}Z.prototype={constructor:Z,find:function(n){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===n)return e;return-1},get:function(n){var e=this.find(n);return e==-1?void 0:this.content[e+1]},update:function(n,e,t){var r=t&&t!=n?this.remove(t):this,o=r.find(n),s=r.content.slice();return o==-1?s.push(t||n,e):(s[o+1]=e,t&&(s[o]=t)),new Z(s)},remove:function(n){var e=this.find(n);if(e==-1)return this;var t=this.content.slice();return t.splice(e,2),new Z(t)},addToStart:function(n,e){return new Z([n,e].concat(this.remove(n).content))},addToEnd:function(n,e){var t=this.remove(n).content.slice();return t.push(n,e),new Z(t)},addBefore:function(n,e,t){var r=this.remove(e),o=r.content.slice(),s=r.find(n);return o.splice(s==-1?o.length:s,0,e,t),new Z(o)},forEach:function(n){for(var e=0;e<this.content.length;e+=2)n(this.content[e],this.content[e+1])},prepend:function(n){return n=Z.from(n),n.size?new Z(n.content.concat(this.subtract(n).content)):this},append:function(n){return n=Z.from(n),n.size?new Z(this.subtract(n).content.concat(n.content)):this},subtract:function(n){var e=this;n=Z.from(n);for(var t=0;t<n.content.length;t+=2)e=e.remove(n.content[t]);return e},toObject:function(){var n={};return this.forEach(function(e,t){n[e]=t}),n},get size(){return this.content.length>>1}},Z.from=function(n){if(n instanceof Z)return n;var e=[];if(n)for(var t in n)e.push(t,n[t]);return new Z(e)};function di(n,e,t){for(let r=0;;r++){if(r==n.childCount||r==e.childCount)return n.childCount==e.childCount?null:t;let o=n.child(r),s=e.child(r);if(o==s){t+=o.nodeSize;continue}if(!o.sameMarkup(s))return t;if(o.isText&&o.text!=s.text){for(let i=0;o.text[i]==s.text[i];i++)t++;return t}if(o.content.size||s.content.size){let i=di(o.content,s.content,t+1);if(i!=null)return i}t+=o.nodeSize}}function hi(n,e,t,r){for(let o=n.childCount,s=e.childCount;;){if(o==0||s==0)return o==s?null:{a:t,b:r};let i=n.child(--o),l=e.child(--s),a=i.nodeSize;if(i==l){t-=a,r-=a;continue}if(!i.sameMarkup(l))return{a:t,b:r};if(i.isText&&i.text!=l.text){let c=0,u=Math.min(i.text.length,l.text.length);for(;c<u&&i.text[i.text.length-c-1]==l.text[l.text.length-c-1];)c++,t--,r--;return{a:t,b:r}}if(i.content.size||l.content.size){let c=hi(i.content,l.content,t-1,r-1);if(c)return c}t-=a,r-=a}}class S{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,t,r,o=0,s){for(let i=0,l=0;l<t;i++){let a=this.content[i],c=l+a.nodeSize;if(c>e&&r(a,o+l,s||null,i)!==!1&&a.content.size){let u=l+1;a.nodesBetween(Math.max(0,e-u),Math.min(a.content.size,t-u),r,o+u)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,r,o){let s="",i=!0;return this.nodesBetween(e,t,(l,a)=>{let c=l.isText?l.text.slice(Math.max(e,a)-a,t-a):l.isLeaf?o?typeof o=="function"?o(l):o:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&c||l.isTextblock)&&r&&(i?i=!1:s+=r),s+=c},0),s}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,r=e.firstChild,o=this.content.slice(),s=0;for(t.isText&&t.sameMarkup(r)&&(o[o.length-1]=t.withText(t.text+r.text),s=1);s<e.content.length;s++)o.push(e.content[s]);return new S(o,this.size+e.size)}cut(e,t=this.size){if(e==0&&t==this.size)return this;let r=[],o=0;if(t>e)for(let s=0,i=0;i<t;s++){let l=this.content[s],a=i+l.nodeSize;a>e&&((i<e||a>t)&&(l.isText?l=l.cut(Math.max(0,e-i),Math.min(l.text.length,t-i)):l=l.cut(Math.max(0,e-i-1),Math.min(l.content.size,t-i-1))),r.push(l),o+=l.nodeSize),i=a}return new S(r,o)}cutByIndex(e,t){return e==t?S.empty:e==0&&t==this.content.length?this:new S(this.content.slice(e,t))}replaceChild(e,t){let r=this.content[e];if(r==t)return this;let o=this.content.slice(),s=this.size+t.nodeSize-r.nodeSize;return o[e]=t,new S(o,s)}addToStart(e){return new S([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new S(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw new RangeError("Index "+e+" out of range for "+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,r=0;t<this.content.length;t++){let o=this.content[t];e(o,r,t),r+=o.nodeSize}}findDiffStart(e,t=0){return di(this,e,t)}findDiffEnd(e,t=this.size,r=e.size){return hi(this,e,t,r)}findIndex(e,t=-1){if(e==0)return cr(0,e);if(e==this.size)return cr(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let r=0,o=0;;r++){let s=this.child(r),i=o+s.nodeSize;if(i>=e)return i==e||t>0?cr(r+1,i):cr(r,o);o=i}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,t){if(!t)return S.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new S(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return S.empty;let t,r=0;for(let o=0;o<e.length;o++){let s=e[o];r+=s.nodeSize,o&&s.isText&&e[o-1].sameMarkup(s)?(t||(t=e.slice(0,o)),t[t.length-1]=s.withText(t[t.length-1].text+s.text)):t&&t.push(s)}return new S(t||e,r)}static from(e){if(!e)return S.empty;if(e instanceof S)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new S([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}S.empty=new S([],0);const uo={index:0,offset:0};function cr(n,e){return uo.index=n,uo.offset=e,uo}function ur(n,e){if(n===e)return!0;if(!(n&&typeof n=="object")||!(e&&typeof e=="object"))return!1;let t=Array.isArray(n);if(Array.isArray(e)!=t)return!1;if(t){if(n.length!=e.length)return!1;for(let r=0;r<n.length;r++)if(!ur(n[r],e[r]))return!1}else{for(let r in n)if(!(r in e)||!ur(n[r],e[r]))return!1;for(let r in e)if(!(r in n))return!1}return!0}class F{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,r=!1;for(let o=0;o<e.length;o++){let s=e[o];if(this.eq(s))return e;if(this.type.excludes(s.type))t||(t=e.slice(0,o));else{if(s.type.excludes(this.type))return e;!r&&s.type.rank>this.type.rank&&(t||(t=e.slice(0,o)),t.push(this),r=!0),t&&t.push(s)}}return t||(t=e.slice()),r||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&ur(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Mark.fromJSON");let r=e.marks[t.type];if(!r)throw new RangeError(`There is no mark type ${t.type} in this schema`);let o=r.create(t.attrs);return r.checkAttrs(o.attrs),o}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(t[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return F.none;if(e instanceof F)return[e];let t=e.slice();return t.sort((r,o)=>r.type.rank-o.type.rank),t}}F.none=[];class fr extends Error{}class N{constructor(e,t,r){this.content=e,this.openStart=t,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let r=mi(this.content,e+this.openStart,t);return r&&new N(r,this.openStart,this.openEnd)}removeBetween(e,t){return new N(pi(this.content,e+this.openStart,t+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,t){if(!t)return N.empty;let r=t.openStart||0,o=t.openEnd||0;if(typeof r!="number"||typeof o!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new N(S.fromJSON(e,t.content),r,o)}static maxOpen(e,t=!0){let r=0,o=0;for(let s=e.firstChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.firstChild)r++;for(let s=e.lastChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.lastChild)o++;return new N(e,r,o)}}N.empty=new N(S.empty,0,0);function pi(n,e,t){let{index:r,offset:o}=n.findIndex(e),s=n.maybeChild(r),{index:i,offset:l}=n.findIndex(t);if(o==e||s.isText){if(l!=t&&!n.child(i).isText)throw new RangeError("Removing non-flat range");return n.cut(0,e).append(n.cut(t))}if(r!=i)throw new RangeError("Removing non-flat range");return n.replaceChild(r,s.copy(pi(s.content,e-o-1,t-o-1)))}function mi(n,e,t,r){let{index:o,offset:s}=n.findIndex(e),i=n.maybeChild(o);if(s==e||i.isText)return n.cut(0,e).append(t).append(n.cut(e));let l=mi(i.content,e-s-1,t);return l&&n.replaceChild(o,i.copy(l))}function xf(n,e,t){if(t.openStart>n.depth)throw new fr("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new fr("Inconsistent open depths");return gi(n,e,t,0)}function gi(n,e,t,r){let o=n.index(r),s=n.node(r);if(o==e.index(r)&&r<n.depth-t.openStart){let i=gi(n,e,t,r+1);return s.copy(s.content.replaceChild(o,i))}else if(t.content.size)if(!t.openStart&&!t.openEnd&&n.depth==r&&e.depth==r){let i=n.parent,l=i.content;return vt(i,l.cut(0,n.parentOffset).append(t.content).append(l.cut(e.parentOffset)))}else{let{start:i,end:l}=kf(t,n);return vt(s,bi(n,i,l,e,r))}else return vt(s,dr(n,e,r))}function yi(n,e){if(!e.type.compatibleContent(n.type))throw new fr("Cannot join "+e.type.name+" onto "+n.type.name)}function fo(n,e,t){let r=n.node(t);return yi(r,e.node(t)),r}function Tt(n,e){let t=e.length-1;t>=0&&n.isText&&n.sameMarkup(e[t])?e[t]=n.withText(e[t].text+n.text):e.push(n)}function Mn(n,e,t,r){let o=(e||n).node(t),s=0,i=e?e.index(t):o.childCount;n&&(s=n.index(t),n.depth>t?s++:n.textOffset&&(Tt(n.nodeAfter,r),s++));for(let l=s;l<i;l++)Tt(o.child(l),r);e&&e.depth==t&&e.textOffset&&Tt(e.nodeBefore,r)}function vt(n,e){return n.type.checkContent(e),n.copy(e)}function bi(n,e,t,r,o){let s=n.depth>o&&fo(n,e,o+1),i=r.depth>o&&fo(t,r,o+1),l=[];return Mn(null,n,o,l),s&&i&&e.index(o)==t.index(o)?(yi(s,i),Tt(vt(s,bi(n,e,t,r,o+1)),l)):(s&&Tt(vt(s,dr(n,e,o+1)),l),Mn(e,t,o,l),i&&Tt(vt(i,dr(t,r,o+1)),l)),Mn(r,null,o,l),new S(l)}function dr(n,e,t){let r=[];if(Mn(null,n,t,r),n.depth>t){let o=fo(n,e,t+1);Tt(vt(o,dr(n,e,t+1)),r)}return Mn(e,null,t,r),new S(r)}function kf(n,e){let t=e.depth-n.openStart,o=e.node(t).copy(n.content);for(let s=t-1;s>=0;s--)o=e.node(s).copy(S.from(o));return{start:o.resolveNoCache(n.openStart+t),end:o.resolveNoCache(o.content.size-n.openEnd-t)}}class Nn{constructor(e,t,r){this.pos=e,this.path=t,this.parentOffset=r,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],o=e.child(t);return r?e.child(t).cut(r):o}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let r=this.path[t*3],o=t==0?0:this.path[t*3-1]+1;for(let s=0;s<e;s++)o+=r.child(s).nodeSize;return o}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return F.none;if(this.textOffset)return e.child(t).marks;let r=e.maybeChild(t-1),o=e.maybeChild(t);if(!r){let l=r;r=o,o=l}let s=r.marks;for(var i=0;i<s.length;i++)s[i].type.spec.inclusive===!1&&(!o||!s[i].isInSet(o.marks))&&(s=s[i--].removeFromSet(s));return s}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let r=t.marks,o=e.parent.maybeChild(e.index());for(var s=0;s<r.length;s++)r[s].type.spec.inclusive===!1&&(!o||!r[s].isInSet(o.marks))&&(r=r[s--].removeFromSet(r));return r}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let r=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);r>=0;r--)if(e.pos<=this.end(r)&&(!t||t(this.node(r))))return new hr(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let t=1;t<=this.depth;t++)e+=(e?"/":"")+this.node(t).type.name+"_"+this.index(t-1);return e+":"+this.parentOffset}static resolve(e,t){if(!(t>=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let r=[],o=0,s=t;for(let i=e;;){let{index:l,offset:a}=i.content.findIndex(s),c=s-a;if(r.push(i,l,o+a),!c||(i=i.child(l),i.isText))break;s=c-1,o+=a+1}return new Nn(t,r,s)}static resolveCached(e,t){let r=xi.get(e);if(r)for(let s=0;s<r.elts.length;s++){let i=r.elts[s];if(i.pos==t)return i}else xi.set(e,r=new Sf);let o=r.elts[r.i]=Nn.resolve(e,t);return r.i=(r.i+1)%Cf,o}}class Sf{constructor(){this.elts=[],this.i=0}}const Cf=12,xi=new WeakMap;class hr{constructor(e,t,r){this.$from=e,this.$to=t,this.depth=r}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const wf=Object.create(null);class be{constructor(e,t,r,o=F.none){this.type=e,this.attrs=t,this.marks=o,this.content=r||S.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,r,o=0){this.content.nodesBetween(e,t,r,o,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,t,r,o){return this.content.textBetween(e,t,r,o)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,r){return this.type==e&&ur(this.attrs,t||e.defaultAttrs||wf)&&F.sameSet(this.marks,r||F.none)}copy(e=null){return e==this.content?this:new be(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new be(this.type,this.attrs,this.content,e)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,r=!1){if(e==t)return N.empty;let o=this.resolve(e),s=this.resolve(t),i=r?0:o.sharedDepth(t),l=o.start(i),c=o.node(i).content.cut(o.pos-l,s.pos-l);return new N(c,o.depth-i,s.depth-i)}replace(e,t,r){return xf(this.resolve(e),this.resolve(t),r)}nodeAt(e){for(let t=this;;){let{index:r,offset:o}=t.content.findIndex(e);if(t=t.maybeChild(r),!t)return null;if(o==e||t.isText)return t;e-=o+1}}childAfter(e){let{index:t,offset:r}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:r}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:r}=this.content.findIndex(e);if(r<e)return{node:this.content.child(t),index:t,offset:r};let o=this.content.child(t-1);return{node:o,index:t-1,offset:r-o.nodeSize}}resolve(e){return Nn.resolveCached(this,e)}resolveNoCache(e){return Nn.resolve(this,e)}rangeHasMark(e,t,r){let o=!1;return t>e&&this.nodesBetween(e,t,s=>(r.isInSet(s.marks)&&(o=!0),!o)),o}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),ki(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw new Error("Called contentMatchAt on a node with invalid content");return t}canReplace(e,t,r=S.empty,o=0,s=r.childCount){let i=this.contentMatchAt(e).matchFragment(r,o,s),l=i&&i.matchFragment(this.content,t);if(!l||!l.validEnd)return!1;for(let a=o;a<s;a++)if(!this.type.allowsMarks(r.child(a).marks))return!1;return!0}canReplaceWith(e,t,r,o){if(o&&!this.type.allowsMarks(o))return!1;let s=this.contentMatchAt(e).matchType(r),i=s&&s.matchFragment(this.content,t);return i?i.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=F.none;for(let t=0;t<this.marks.length;t++){let r=this.marks[t];r.type.checkAttrs(r.attrs),e=r.addToSet(e)}if(!F.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(t=>t.type.name)}`);this.content.forEach(t=>t.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(t=>t.toJSON())),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let r;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=t.marks.map(e.markFromJSON)}if(t.type=="text"){if(typeof t.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(t.text,r)}let o=S.fromJSON(e,t.content),s=e.nodeType(t.type).create(t.attrs,o,r);return s.type.checkAttrs(s.attrs),s}}be.prototype.text=void 0;class pr extends be{constructor(e,t,r,o){if(super(e,t,null,o),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):ki(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new pr(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new pr(this.type,this.attrs,e,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function ki(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}class At{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let r=new Mf(e,t);if(r.next==null)return At.empty;let o=Si(r);r.next&&r.err("Unexpected trailing text");let s=Af(vf(o));return Pf(s,r),s}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,r=e.childCount){let o=this;for(let s=t;o&&s<r;s++)o=o.matchType(e.child(s).type);return o}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let r=0;r<e.next.length;r++)if(this.next[t].type==e.next[r].type)return!0;return!1}fillBefore(e,t=!1,r=0){let o=[this];function s(i,l){let a=i.matchFragment(e,r);if(a&&(!t||a.validEnd))return S.from(l.map(c=>c.createAndFill()));for(let c=0;c<i.next.length;c++){let{type:u,next:f}=i.next[c];if(!(u.isText||u.hasRequiredAttrs())&&o.indexOf(f)==-1){o.push(f);let d=s(f,l.concat(u));if(d)return d}}return null}return s(this,[])}findWrapping(e){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==e)return this.wrapCache[r+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let o=r.shift(),s=o.match;if(s.matchType(e)){let i=[];for(let l=o;l.type;l=l.via)i.push(l.type);return i.reverse()}for(let i=0;i<s.next.length;i++){let{type:l,next:a}=s.next[i];!l.isLeaf&&!l.hasRequiredAttrs()&&!(l.name in t)&&(!o.type||a.validEnd)&&(r.push({match:l.contentMatch,type:l,via:o}),t[l.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(r){e.push(r);for(let o=0;o<r.next.length;o++)e.indexOf(r.next[o].next)==-1&&t(r.next[o].next)}return t(this),e.map((r,o)=>{let s=o+(r.validEnd?"*":" ")+" ";for(let i=0;i<r.next.length;i++)s+=(i?", ":"")+r.next[i].type.name+"->"+e.indexOf(r.next[i].next);return s}).join(`
|
|
33
|
-
`)}}At.empty=new At(!0);class Mf{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}}function Si(n){let e=[];do e.push(Nf(n));while(n.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function Nf(n){let e=[];do e.push(Ef(n));while(n.next&&n.next!=")"&&n.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function Ef(n){let e=Tf(n);for(;;)if(n.eat("+"))e={type:"plus",expr:e};else if(n.eat("*"))e={type:"star",expr:e};else if(n.eat("?"))e={type:"opt",expr:e};else if(n.eat("{"))e=Df(n,e);else break;return e}function Ci(n){/\D/.test(n.next)&&n.err("Expected number, got '"+n.next+"'");let e=Number(n.next);return n.pos++,e}function Df(n,e){let t=Ci(n),r=t;return n.eat(",")&&(n.next!="}"?r=Ci(n):r=-1),n.eat("}")||n.err("Unclosed braced range"),{type:"range",min:t,max:r,expr:e}}function Of(n,e){let t=n.nodeTypes,r=t[e];if(r)return[r];let o=[];for(let s in t){let i=t[s];i.isInGroup(e)&&o.push(i)}return o.length==0&&n.err("No node type or group '"+e+"' found"),o}function Tf(n){if(n.eat("(")){let e=Si(n);return n.eat(")")||n.err("Missing closing paren"),e}else if(/\W/.test(n.next))n.err("Unexpected token '"+n.next+"'");else{let e=Of(n,n.next).map(t=>(n.inline==null?n.inline=t.isInline:n.inline!=t.isInline&&n.err("Mixing inline and block content"),{type:"name",value:t}));return n.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function vf(n){let e=[[]];return o(s(n,0),t()),e;function t(){return e.push([])-1}function r(i,l,a){let c={term:a,to:l};return e[i].push(c),c}function o(i,l){i.forEach(a=>a.to=l)}function s(i,l){if(i.type=="choice")return i.exprs.reduce((a,c)=>a.concat(s(c,l)),[]);if(i.type=="seq")for(let a=0;;a++){let c=s(i.exprs[a],l);if(a==i.exprs.length-1)return c;o(c,l=t())}else if(i.type=="star"){let a=t();return r(l,a),o(s(i.expr,a),a),[r(a)]}else if(i.type=="plus"){let a=t();return o(s(i.expr,l),a),o(s(i.expr,a),a),[r(a)]}else{if(i.type=="opt")return[r(l)].concat(s(i.expr,l));if(i.type=="range"){let a=l;for(let c=0;c<i.min;c++){let u=t();o(s(i.expr,a),u),a=u}if(i.max==-1)o(s(i.expr,a),a);else for(let c=i.min;c<i.max;c++){let u=t();r(a,u),o(s(i.expr,a),u),a=u}return[r(a)]}else{if(i.type=="name")return[r(l,void 0,i.value)];throw new Error("Unknown expr type")}}}}function wi(n,e){return e-n}function Mi(n,e){let t=[];return r(e),t.sort(wi);function r(o){let s=n[o];if(s.length==1&&!s[0].term)return r(s[0].to);t.push(o);for(let i=0;i<s.length;i++){let{term:l,to:a}=s[i];!l&&t.indexOf(a)==-1&&r(a)}}}function Af(n){let e=Object.create(null);return t(Mi(n,0));function t(r){let o=[];r.forEach(i=>{n[i].forEach(({term:l,to:a})=>{if(!l)return;let c;for(let u=0;u<o.length;u++)o[u][0]==l&&(c=o[u][1]);Mi(n,a).forEach(u=>{c||o.push([l,c=[]]),c.indexOf(u)==-1&&c.push(u)})})});let s=e[r.join(",")]=new At(r.indexOf(n.length-1)>-1);for(let i=0;i<o.length;i++){let l=o[i][1].sort(wi);s.next.push({type:o[i][0],next:e[l.join(",")]||t(l)})}return s}}function Pf(n,e){for(let t=0,r=[n];t<r.length;t++){let o=r[t],s=!o.validEnd,i=[];for(let l=0;l<o.next.length;l++){let{type:a,next:c}=o.next[l];i.push(a.name),s&&!(a.isText||a.hasRequiredAttrs())&&(s=!1),r.indexOf(c)==-1&&r.push(c)}s&&e.err("Only non-generatable nodes ("+i.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function Ni(n){let e=Object.create(null);for(let t in n){let r=n[t];if(!r.hasDefault)return null;e[t]=r.default}return e}function Ei(n,e){let t=Object.create(null);for(let r in n){let o=e&&e[r];if(o===void 0){let s=n[r];if(s.hasDefault)o=s.default;else throw new RangeError("No value supplied for attribute "+r)}t[r]=o}return t}function Di(n,e,t,r){for(let o in e)if(!(o in n))throw new RangeError(`Unsupported attribute ${o} for ${t} of type ${o}`);for(let o in n){let s=n[o];s.validate&&s.validate(e[o])}}function Oi(n,e){let t=Object.create(null);if(e)for(let r in e)t[r]=new Vf(n,r,e[r]);return t}let Ti=class uf{constructor(e,t,r){this.name=e,this.schema=t,this.spec=r,this.markSet=null,this.groups=r.group?r.group.split(" "):[],this.attrs=Oi(e,r.attrs),this.defaultAttrs=Ni(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(r.inline||e=="text"),this.isText=e=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==At.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(e){return this.groups.indexOf(e)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:Ei(this.attrs,e)}create(e=null,t,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new be(this,this.computeAttrs(e),S.from(t),F.setFrom(r))}createChecked(e=null,t,r){return t=S.from(t),this.checkContent(t),new be(this,this.computeAttrs(e),t,F.setFrom(r))}createAndFill(e=null,t,r){if(e=this.computeAttrs(e),t=S.from(t),t.size){let i=this.contentMatch.fillBefore(t);if(!i)return null;t=i.append(t)}let o=this.contentMatch.matchFragment(t),s=o&&o.fillBefore(S.empty,!0);return s?new be(this,e,t.append(s),F.setFrom(r)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let r=0;r<e.childCount;r++)if(!this.allowsMarks(e.child(r).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){Di(this.attrs,e,"node",this.name)}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let t;for(let r=0;r<e.length;r++)this.allowsMarkType(e[r].type)?t&&t.push(e[r]):t||(t=e.slice(0,r));return t?t.length?t:F.none:e}static compile(e,t){let r=Object.create(null);e.forEach((s,i)=>r[s]=new uf(s,t,i));let o=t.spec.topNode||"doc";if(!r[o])throw new RangeError("Schema is missing its top node type ('"+o+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let s in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function If(n,e,t){let r=t.split("|");return o=>{let s=o===null?"null":typeof o;if(r.indexOf(s)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${n}, got ${s}`)}}class Vf{constructor(e,t,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?If(e,t,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class mr{constructor(e,t,r,o){this.name=e,this.rank=t,this.schema=r,this.spec=o,this.attrs=Oi(e,o.attrs),this.excluded=null;let s=Ni(this.attrs);this.instance=s?new F(this,s):null}create(e=null){return!e&&this.instance?this.instance:new F(this,Ei(this.attrs,e))}static compile(e,t){let r=Object.create(null),o=0;return e.forEach((s,i)=>r[s]=new mr(s,o++,t,i)),r}removeFromSet(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}checkAttrs(e){Di(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class gr{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let o in e)t[o]=e[o];t.nodes=Z.from(e.nodes),t.marks=Z.from(e.marks||{}),this.nodes=Ti.compile(this.spec.nodes,this),this.marks=mr.compile(this.spec.marks,this);let r=Object.create(null);for(let o in this.nodes){if(o in this.marks)throw new RangeError(o+" can not be both a node and a mark");let s=this.nodes[o],i=s.spec.content||"",l=s.spec.marks;if(s.contentMatch=r[i]||(r[i]=At.parse(i,this.nodes)),s.inlineContent=s.contentMatch.inlineContent,s.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!s.isInline||!s.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=s}s.markSet=l=="_"?null:l?vi(this,l.split(" ")):l==""||!s.inlineContent?[]:null}for(let o in this.marks){let s=this.marks[o],i=s.spec.excludes;s.excluded=i==null?[s]:i==""?[]:vi(this,i.split(" "))}this.nodeFromJSON=this.nodeFromJSON.bind(this),this.markFromJSON=this.markFromJSON.bind(this),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,r,o){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof Ti){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(t,r,o)}text(e,t){let r=this.nodes.text;return new pr(r,r.defaultAttrs,e,F.setFrom(t))}mark(e,t){return typeof e=="string"&&(e=this.marks[e]),e.create(t)}nodeFromJSON(e){return be.fromJSON(this,e)}markFromJSON(e){return F.fromJSON(this,e)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}}function vi(n,e){let t=[];for(let r=0;r<e.length;r++){let o=e[r],s=n.marks[o],i=s;if(s)t.push(s);else for(let l in n.marks){let a=n.marks[l];(o=="_"||a.spec.group&&a.spec.group.split(" ").indexOf(o)>-1)&&t.push(i=a)}if(!i)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return t}function Rf(n){return n.tag!=null}function zf(n){return n.style!=null}class Pt{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let r=this.matchedStyles=[];t.forEach(o=>{if(Rf(o))this.tags.push(o);else if(zf(o)){let s=/[^=]*/.exec(o.style)[0];r.indexOf(s)<0&&r.push(s),this.styles.push(o)}}),this.normalizeLists=!this.tags.some(o=>{if(!/^(ul|ol)\b/.test(o.tag)||!o.node)return!1;let s=e.nodes[o.node];return s.contentMatch.matchType(s)})}parse(e,t={}){let r=new Vi(this,t,!1);return r.addAll(e,F.none,t.from,t.to),r.finish()}parseSlice(e,t={}){let r=new Vi(this,t,!0);return r.addAll(e,F.none,t.from,t.to),N.maxOpen(r.finish())}matchTag(e,t,r){for(let o=r?this.tags.indexOf(r)+1:0;o<this.tags.length;o++){let s=this.tags[o];if(Bf(e,s.tag)&&(s.namespace===void 0||e.namespaceURI==s.namespace)&&(!s.context||t.matchesContext(s.context))){if(s.getAttrs){let i=s.getAttrs(e);if(i===!1)continue;s.attrs=i||void 0}return s}}}matchStyle(e,t,r,o){for(let s=o?this.styles.indexOf(o)+1:0;s<this.styles.length;s++){let i=this.styles[s],l=i.style;if(!(l.indexOf(e)!=0||i.context&&!r.matchesContext(i.context)||l.length>e.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=t))){if(i.getAttrs){let a=i.getAttrs(t);if(a===!1)continue;i.attrs=a||void 0}return i}}}static schemaRules(e){let t=[];function r(o){let s=o.priority==null?50:o.priority,i=0;for(;i<t.length;i++){let l=t[i];if((l.priority==null?50:l.priority)<s)break}t.splice(i,0,o)}for(let o in e.marks){let s=e.marks[o].spec.parseDOM;s&&s.forEach(i=>{r(i=Ri(i)),i.mark||i.ignore||i.clearMark||(i.mark=o)})}for(let o in e.nodes){let s=e.nodes[o].spec.parseDOM;s&&s.forEach(i=>{r(i=Ri(i)),i.node||i.ignore||i.mark||(i.node=o)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Pt(e,Pt.schemaRules(e)))}}const Ai={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},$f={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Pi={ol:!0,ul:!0},En=1,ho=2,yr=4;function Ii(n,e,t){return e!=null?(e?En:0)|(e==="full"?ho:0):n&&n.whitespace=="pre"?En|ho:t&-5}class br{constructor(e,t,r,o,s,i){this.type=e,this.attrs=t,this.marks=r,this.solid=o,this.options=i,this.content=[],this.activeMarks=F.none,this.match=s||(i&yr?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(S.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let r=this.type.contentMatch,o;return(o=r.findWrapping(e.type))?(this.match=r,o):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&En)){let r=this.content[this.content.length-1],o;if(r&&r.isText&&(o=/[ \t\r\n\u000c]+$/.exec(r.text))){let s=r;r.text.length==o[0].length?this.content.pop():this.content[this.content.length-1]=s.withText(s.text.slice(0,s.text.length-o[0].length))}}let t=S.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(S.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!Ai.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class Vi{constructor(e,t,r){this.parser=e,this.options=t,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let o=t.topNode,s,i=Ii(null,t.preserveWhitespace,0)|(r?yr:0);o?s=new br(o.type,o.attrs,F.none,!0,t.topMatch||o.type.contentMatch,i):r?s=new br(null,null,F.none,!0,null,i):s=new br(e.schema.topNodeType,null,F.none,!0,null,i),this.nodes=[s],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){e.nodeType==3?this.addTextNode(e,t):e.nodeType==1&&this.addElement(e,t)}addTextNode(e,t){let r=e.nodeValue,o=this.top,s=o.options&ho?"full":this.localPreserveWS||(o.options&En)>0;if(s==="full"||o.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(s)s!=="full"?r=r.replace(/\r?\n|\r/g," "):r=r.replace(/\r\n?/g,`
|
|
32
|
+
Check the top-level render call using <`+x+">."),v}var M=m,O=Symbol.for("react.transitional.element"),I=Symbol.for("react.portal"),w=Symbol.for("react.fragment"),V=Symbol.for("react.strict_mode"),z=Symbol.for("react.profiler"),T=Symbol.for("react.consumer"),L=Symbol.for("react.context"),we=Symbol.for("react.forward_ref"),Et=Symbol.for("react.suspense"),Ae=Symbol.for("react.suspense_list"),ze=Symbol.for("react.memo"),Yt=Symbol.for("react.lazy"),yn=Symbol.for("react.offscreen"),sr=Symbol.iterator,io=Symbol.for("react.client.reference"),Gt=M.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Xu=Object.prototype.hasOwnProperty,Xt=Object.assign,N0=Symbol.for("react.client.reference"),ri=Array.isArray,ir=0,Uu,Qu,Zu,ef,tf,nf,rf;r.__reactDisabledLog=!0;var oi,of,si=!1,ii=new(typeof WeakMap=="function"?WeakMap:Map),E0=Symbol.for("react.client.reference"),sf,lf={},af={},cf={};wn.Fragment=w,wn.jsx=function(x,v,A,B,ce){return p(x,v,A,!1,B,ce)},wn.jsxs=function(x,v,A,B,ce){return p(x,v,A,!0,B,ce)}}()),wn}process.env.NODE_ENV==="production"?co.exports=yf():co.exports=bf();var y=co.exports;function Z(n){this.content=n}Z.prototype={constructor:Z,find:function(n){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===n)return e;return-1},get:function(n){var e=this.find(n);return e==-1?void 0:this.content[e+1]},update:function(n,e,t){var r=t&&t!=n?this.remove(t):this,o=r.find(n),s=r.content.slice();return o==-1?s.push(t||n,e):(s[o+1]=e,t&&(s[o]=t)),new Z(s)},remove:function(n){var e=this.find(n);if(e==-1)return this;var t=this.content.slice();return t.splice(e,2),new Z(t)},addToStart:function(n,e){return new Z([n,e].concat(this.remove(n).content))},addToEnd:function(n,e){var t=this.remove(n).content.slice();return t.push(n,e),new Z(t)},addBefore:function(n,e,t){var r=this.remove(e),o=r.content.slice(),s=r.find(n);return o.splice(s==-1?o.length:s,0,e,t),new Z(o)},forEach:function(n){for(var e=0;e<this.content.length;e+=2)n(this.content[e],this.content[e+1])},prepend:function(n){return n=Z.from(n),n.size?new Z(n.content.concat(this.subtract(n).content)):this},append:function(n){return n=Z.from(n),n.size?new Z(this.subtract(n).content.concat(n.content)):this},subtract:function(n){var e=this;n=Z.from(n);for(var t=0;t<n.content.length;t+=2)e=e.remove(n.content[t]);return e},toObject:function(){var n={};return this.forEach(function(e,t){n[e]=t}),n},get size(){return this.content.length>>1}},Z.from=function(n){if(n instanceof Z)return n;var e=[];if(n)for(var t in n)e.push(t,n[t]);return new Z(e)};function di(n,e,t){for(let r=0;;r++){if(r==n.childCount||r==e.childCount)return n.childCount==e.childCount?null:t;let o=n.child(r),s=e.child(r);if(o==s){t+=o.nodeSize;continue}if(!o.sameMarkup(s))return t;if(o.isText&&o.text!=s.text){for(let i=0;o.text[i]==s.text[i];i++)t++;return t}if(o.content.size||s.content.size){let i=di(o.content,s.content,t+1);if(i!=null)return i}t+=o.nodeSize}}function hi(n,e,t,r){for(let o=n.childCount,s=e.childCount;;){if(o==0||s==0)return o==s?null:{a:t,b:r};let i=n.child(--o),l=e.child(--s),a=i.nodeSize;if(i==l){t-=a,r-=a;continue}if(!i.sameMarkup(l))return{a:t,b:r};if(i.isText&&i.text!=l.text){let c=0,u=Math.min(i.text.length,l.text.length);for(;c<u&&i.text[i.text.length-c-1]==l.text[l.text.length-c-1];)c++,t--,r--;return{a:t,b:r}}if(i.content.size||l.content.size){let c=hi(i.content,l.content,t-1,r-1);if(c)return c}t-=a,r-=a}}class C{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,t,r,o=0,s){for(let i=0,l=0;l<t;i++){let a=this.content[i],c=l+a.nodeSize;if(c>e&&r(a,o+l,s||null,i)!==!1&&a.content.size){let u=l+1;a.nodesBetween(Math.max(0,e-u),Math.min(a.content.size,t-u),r,o+u)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,r,o){let s="",i=!0;return this.nodesBetween(e,t,(l,a)=>{let c=l.isText?l.text.slice(Math.max(e,a)-a,t-a):l.isLeaf?o?typeof o=="function"?o(l):o:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&c||l.isTextblock)&&r&&(i?i=!1:s+=r),s+=c},0),s}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,r=e.firstChild,o=this.content.slice(),s=0;for(t.isText&&t.sameMarkup(r)&&(o[o.length-1]=t.withText(t.text+r.text),s=1);s<e.content.length;s++)o.push(e.content[s]);return new C(o,this.size+e.size)}cut(e,t=this.size){if(e==0&&t==this.size)return this;let r=[],o=0;if(t>e)for(let s=0,i=0;i<t;s++){let l=this.content[s],a=i+l.nodeSize;a>e&&((i<e||a>t)&&(l.isText?l=l.cut(Math.max(0,e-i),Math.min(l.text.length,t-i)):l=l.cut(Math.max(0,e-i-1),Math.min(l.content.size,t-i-1))),r.push(l),o+=l.nodeSize),i=a}return new C(r,o)}cutByIndex(e,t){return e==t?C.empty:e==0&&t==this.content.length?this:new C(this.content.slice(e,t))}replaceChild(e,t){let r=this.content[e];if(r==t)return this;let o=this.content.slice(),s=this.size+t.nodeSize-r.nodeSize;return o[e]=t,new C(o,s)}addToStart(e){return new C([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new C(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw new RangeError("Index "+e+" out of range for "+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,r=0;t<this.content.length;t++){let o=this.content[t];e(o,r,t),r+=o.nodeSize}}findDiffStart(e,t=0){return di(this,e,t)}findDiffEnd(e,t=this.size,r=e.size){return hi(this,e,t,r)}findIndex(e,t=-1){if(e==0)return cr(0,e);if(e==this.size)return cr(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let r=0,o=0;;r++){let s=this.child(r),i=o+s.nodeSize;if(i>=e)return i==e||t>0?cr(r+1,i):cr(r,o);o=i}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,t){if(!t)return C.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new C(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return C.empty;let t,r=0;for(let o=0;o<e.length;o++){let s=e[o];r+=s.nodeSize,o&&s.isText&&e[o-1].sameMarkup(s)?(t||(t=e.slice(0,o)),t[t.length-1]=s.withText(t[t.length-1].text+s.text)):t&&t.push(s)}return new C(t||e,r)}static from(e){if(!e)return C.empty;if(e instanceof C)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new C([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}C.empty=new C([],0);const uo={index:0,offset:0};function cr(n,e){return uo.index=n,uo.offset=e,uo}function ur(n,e){if(n===e)return!0;if(!(n&&typeof n=="object")||!(e&&typeof e=="object"))return!1;let t=Array.isArray(n);if(Array.isArray(e)!=t)return!1;if(t){if(n.length!=e.length)return!1;for(let r=0;r<n.length;r++)if(!ur(n[r],e[r]))return!1}else{for(let r in n)if(!(r in e)||!ur(n[r],e[r]))return!1;for(let r in e)if(!(r in n))return!1}return!0}class F{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,r=!1;for(let o=0;o<e.length;o++){let s=e[o];if(this.eq(s))return e;if(this.type.excludes(s.type))t||(t=e.slice(0,o));else{if(s.type.excludes(this.type))return e;!r&&s.type.rank>this.type.rank&&(t||(t=e.slice(0,o)),t.push(this),r=!0),t&&t.push(s)}}return t||(t=e.slice()),r||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&ur(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Mark.fromJSON");let r=e.marks[t.type];if(!r)throw new RangeError(`There is no mark type ${t.type} in this schema`);let o=r.create(t.attrs);return r.checkAttrs(o.attrs),o}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(t[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return F.none;if(e instanceof F)return[e];let t=e.slice();return t.sort((r,o)=>r.type.rank-o.type.rank),t}}F.none=[];class fr extends Error{}class N{constructor(e,t,r){this.content=e,this.openStart=t,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let r=mi(this.content,e+this.openStart,t);return r&&new N(r,this.openStart,this.openEnd)}removeBetween(e,t){return new N(pi(this.content,e+this.openStart,t+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,t){if(!t)return N.empty;let r=t.openStart||0,o=t.openEnd||0;if(typeof r!="number"||typeof o!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new N(C.fromJSON(e,t.content),r,o)}static maxOpen(e,t=!0){let r=0,o=0;for(let s=e.firstChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.firstChild)r++;for(let s=e.lastChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.lastChild)o++;return new N(e,r,o)}}N.empty=new N(C.empty,0,0);function pi(n,e,t){let{index:r,offset:o}=n.findIndex(e),s=n.maybeChild(r),{index:i,offset:l}=n.findIndex(t);if(o==e||s.isText){if(l!=t&&!n.child(i).isText)throw new RangeError("Removing non-flat range");return n.cut(0,e).append(n.cut(t))}if(r!=i)throw new RangeError("Removing non-flat range");return n.replaceChild(r,s.copy(pi(s.content,e-o-1,t-o-1)))}function mi(n,e,t,r){let{index:o,offset:s}=n.findIndex(e),i=n.maybeChild(o);if(s==e||i.isText)return n.cut(0,e).append(t).append(n.cut(e));let l=mi(i.content,e-s-1,t);return l&&n.replaceChild(o,i.copy(l))}function xf(n,e,t){if(t.openStart>n.depth)throw new fr("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new fr("Inconsistent open depths");return gi(n,e,t,0)}function gi(n,e,t,r){let o=n.index(r),s=n.node(r);if(o==e.index(r)&&r<n.depth-t.openStart){let i=gi(n,e,t,r+1);return s.copy(s.content.replaceChild(o,i))}else if(t.content.size)if(!t.openStart&&!t.openEnd&&n.depth==r&&e.depth==r){let i=n.parent,l=i.content;return vt(i,l.cut(0,n.parentOffset).append(t.content).append(l.cut(e.parentOffset)))}else{let{start:i,end:l}=kf(t,n);return vt(s,bi(n,i,l,e,r))}else return vt(s,dr(n,e,r))}function yi(n,e){if(!e.type.compatibleContent(n.type))throw new fr("Cannot join "+e.type.name+" onto "+n.type.name)}function fo(n,e,t){let r=n.node(t);return yi(r,e.node(t)),r}function Tt(n,e){let t=e.length-1;t>=0&&n.isText&&n.sameMarkup(e[t])?e[t]=n.withText(e[t].text+n.text):e.push(n)}function Mn(n,e,t,r){let o=(e||n).node(t),s=0,i=e?e.index(t):o.childCount;n&&(s=n.index(t),n.depth>t?s++:n.textOffset&&(Tt(n.nodeAfter,r),s++));for(let l=s;l<i;l++)Tt(o.child(l),r);e&&e.depth==t&&e.textOffset&&Tt(e.nodeBefore,r)}function vt(n,e){return n.type.checkContent(e),n.copy(e)}function bi(n,e,t,r,o){let s=n.depth>o&&fo(n,e,o+1),i=r.depth>o&&fo(t,r,o+1),l=[];return Mn(null,n,o,l),s&&i&&e.index(o)==t.index(o)?(yi(s,i),Tt(vt(s,bi(n,e,t,r,o+1)),l)):(s&&Tt(vt(s,dr(n,e,o+1)),l),Mn(e,t,o,l),i&&Tt(vt(i,dr(t,r,o+1)),l)),Mn(r,null,o,l),new C(l)}function dr(n,e,t){let r=[];if(Mn(null,n,t,r),n.depth>t){let o=fo(n,e,t+1);Tt(vt(o,dr(n,e,t+1)),r)}return Mn(e,null,t,r),new C(r)}function kf(n,e){let t=e.depth-n.openStart,o=e.node(t).copy(n.content);for(let s=t-1;s>=0;s--)o=e.node(s).copy(C.from(o));return{start:o.resolveNoCache(n.openStart+t),end:o.resolveNoCache(o.content.size-n.openEnd-t)}}class Nn{constructor(e,t,r){this.pos=e,this.path=t,this.parentOffset=r,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],o=e.child(t);return r?e.child(t).cut(r):o}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let r=this.path[t*3],o=t==0?0:this.path[t*3-1]+1;for(let s=0;s<e;s++)o+=r.child(s).nodeSize;return o}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return F.none;if(this.textOffset)return e.child(t).marks;let r=e.maybeChild(t-1),o=e.maybeChild(t);if(!r){let l=r;r=o,o=l}let s=r.marks;for(var i=0;i<s.length;i++)s[i].type.spec.inclusive===!1&&(!o||!s[i].isInSet(o.marks))&&(s=s[i--].removeFromSet(s));return s}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let r=t.marks,o=e.parent.maybeChild(e.index());for(var s=0;s<r.length;s++)r[s].type.spec.inclusive===!1&&(!o||!r[s].isInSet(o.marks))&&(r=r[s--].removeFromSet(r));return r}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let r=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);r>=0;r--)if(e.pos<=this.end(r)&&(!t||t(this.node(r))))return new hr(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let t=1;t<=this.depth;t++)e+=(e?"/":"")+this.node(t).type.name+"_"+this.index(t-1);return e+":"+this.parentOffset}static resolve(e,t){if(!(t>=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let r=[],o=0,s=t;for(let i=e;;){let{index:l,offset:a}=i.content.findIndex(s),c=s-a;if(r.push(i,l,o+a),!c||(i=i.child(l),i.isText))break;s=c-1,o+=a+1}return new Nn(t,r,s)}static resolveCached(e,t){let r=xi.get(e);if(r)for(let s=0;s<r.elts.length;s++){let i=r.elts[s];if(i.pos==t)return i}else xi.set(e,r=new Sf);let o=r.elts[r.i]=Nn.resolve(e,t);return r.i=(r.i+1)%Cf,o}}class Sf{constructor(){this.elts=[],this.i=0}}const Cf=12,xi=new WeakMap;class hr{constructor(e,t,r){this.$from=e,this.$to=t,this.depth=r}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const wf=Object.create(null);class be{constructor(e,t,r,o=F.none){this.type=e,this.attrs=t,this.marks=o,this.content=r||C.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,r,o=0){this.content.nodesBetween(e,t,r,o,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,t,r,o){return this.content.textBetween(e,t,r,o)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,r){return this.type==e&&ur(this.attrs,t||e.defaultAttrs||wf)&&F.sameSet(this.marks,r||F.none)}copy(e=null){return e==this.content?this:new be(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new be(this.type,this.attrs,this.content,e)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,r=!1){if(e==t)return N.empty;let o=this.resolve(e),s=this.resolve(t),i=r?0:o.sharedDepth(t),l=o.start(i),c=o.node(i).content.cut(o.pos-l,s.pos-l);return new N(c,o.depth-i,s.depth-i)}replace(e,t,r){return xf(this.resolve(e),this.resolve(t),r)}nodeAt(e){for(let t=this;;){let{index:r,offset:o}=t.content.findIndex(e);if(t=t.maybeChild(r),!t)return null;if(o==e||t.isText)return t;e-=o+1}}childAfter(e){let{index:t,offset:r}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:r}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:r}=this.content.findIndex(e);if(r<e)return{node:this.content.child(t),index:t,offset:r};let o=this.content.child(t-1);return{node:o,index:t-1,offset:r-o.nodeSize}}resolve(e){return Nn.resolveCached(this,e)}resolveNoCache(e){return Nn.resolve(this,e)}rangeHasMark(e,t,r){let o=!1;return t>e&&this.nodesBetween(e,t,s=>(r.isInSet(s.marks)&&(o=!0),!o)),o}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),ki(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw new Error("Called contentMatchAt on a node with invalid content");return t}canReplace(e,t,r=C.empty,o=0,s=r.childCount){let i=this.contentMatchAt(e).matchFragment(r,o,s),l=i&&i.matchFragment(this.content,t);if(!l||!l.validEnd)return!1;for(let a=o;a<s;a++)if(!this.type.allowsMarks(r.child(a).marks))return!1;return!0}canReplaceWith(e,t,r,o){if(o&&!this.type.allowsMarks(o))return!1;let s=this.contentMatchAt(e).matchType(r),i=s&&s.matchFragment(this.content,t);return i?i.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=F.none;for(let t=0;t<this.marks.length;t++){let r=this.marks[t];r.type.checkAttrs(r.attrs),e=r.addToSet(e)}if(!F.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(t=>t.type.name)}`);this.content.forEach(t=>t.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(t=>t.toJSON())),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let r;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=t.marks.map(e.markFromJSON)}if(t.type=="text"){if(typeof t.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(t.text,r)}let o=C.fromJSON(e,t.content),s=e.nodeType(t.type).create(t.attrs,o,r);return s.type.checkAttrs(s.attrs),s}}be.prototype.text=void 0;class pr extends be{constructor(e,t,r,o){if(super(e,t,null,o),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):ki(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new pr(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new pr(this.type,this.attrs,e,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function ki(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}class At{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let r=new Mf(e,t);if(r.next==null)return At.empty;let o=Si(r);r.next&&r.err("Unexpected trailing text");let s=Af(vf(o));return Pf(s,r),s}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,r=e.childCount){let o=this;for(let s=t;o&&s<r;s++)o=o.matchType(e.child(s).type);return o}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let r=0;r<e.next.length;r++)if(this.next[t].type==e.next[r].type)return!0;return!1}fillBefore(e,t=!1,r=0){let o=[this];function s(i,l){let a=i.matchFragment(e,r);if(a&&(!t||a.validEnd))return C.from(l.map(c=>c.createAndFill()));for(let c=0;c<i.next.length;c++){let{type:u,next:f}=i.next[c];if(!(u.isText||u.hasRequiredAttrs())&&o.indexOf(f)==-1){o.push(f);let d=s(f,l.concat(u));if(d)return d}}return null}return s(this,[])}findWrapping(e){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==e)return this.wrapCache[r+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let o=r.shift(),s=o.match;if(s.matchType(e)){let i=[];for(let l=o;l.type;l=l.via)i.push(l.type);return i.reverse()}for(let i=0;i<s.next.length;i++){let{type:l,next:a}=s.next[i];!l.isLeaf&&!l.hasRequiredAttrs()&&!(l.name in t)&&(!o.type||a.validEnd)&&(r.push({match:l.contentMatch,type:l,via:o}),t[l.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(r){e.push(r);for(let o=0;o<r.next.length;o++)e.indexOf(r.next[o].next)==-1&&t(r.next[o].next)}return t(this),e.map((r,o)=>{let s=o+(r.validEnd?"*":" ")+" ";for(let i=0;i<r.next.length;i++)s+=(i?", ":"")+r.next[i].type.name+"->"+e.indexOf(r.next[i].next);return s}).join(`
|
|
33
|
+
`)}}At.empty=new At(!0);class Mf{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}}function Si(n){let e=[];do e.push(Nf(n));while(n.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function Nf(n){let e=[];do e.push(Ef(n));while(n.next&&n.next!=")"&&n.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function Ef(n){let e=Tf(n);for(;;)if(n.eat("+"))e={type:"plus",expr:e};else if(n.eat("*"))e={type:"star",expr:e};else if(n.eat("?"))e={type:"opt",expr:e};else if(n.eat("{"))e=Df(n,e);else break;return e}function Ci(n){/\D/.test(n.next)&&n.err("Expected number, got '"+n.next+"'");let e=Number(n.next);return n.pos++,e}function Df(n,e){let t=Ci(n),r=t;return n.eat(",")&&(n.next!="}"?r=Ci(n):r=-1),n.eat("}")||n.err("Unclosed braced range"),{type:"range",min:t,max:r,expr:e}}function Of(n,e){let t=n.nodeTypes,r=t[e];if(r)return[r];let o=[];for(let s in t){let i=t[s];i.isInGroup(e)&&o.push(i)}return o.length==0&&n.err("No node type or group '"+e+"' found"),o}function Tf(n){if(n.eat("(")){let e=Si(n);return n.eat(")")||n.err("Missing closing paren"),e}else if(/\W/.test(n.next))n.err("Unexpected token '"+n.next+"'");else{let e=Of(n,n.next).map(t=>(n.inline==null?n.inline=t.isInline:n.inline!=t.isInline&&n.err("Mixing inline and block content"),{type:"name",value:t}));return n.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function vf(n){let e=[[]];return o(s(n,0),t()),e;function t(){return e.push([])-1}function r(i,l,a){let c={term:a,to:l};return e[i].push(c),c}function o(i,l){i.forEach(a=>a.to=l)}function s(i,l){if(i.type=="choice")return i.exprs.reduce((a,c)=>a.concat(s(c,l)),[]);if(i.type=="seq")for(let a=0;;a++){let c=s(i.exprs[a],l);if(a==i.exprs.length-1)return c;o(c,l=t())}else if(i.type=="star"){let a=t();return r(l,a),o(s(i.expr,a),a),[r(a)]}else if(i.type=="plus"){let a=t();return o(s(i.expr,l),a),o(s(i.expr,a),a),[r(a)]}else{if(i.type=="opt")return[r(l)].concat(s(i.expr,l));if(i.type=="range"){let a=l;for(let c=0;c<i.min;c++){let u=t();o(s(i.expr,a),u),a=u}if(i.max==-1)o(s(i.expr,a),a);else for(let c=i.min;c<i.max;c++){let u=t();r(a,u),o(s(i.expr,a),u),a=u}return[r(a)]}else{if(i.type=="name")return[r(l,void 0,i.value)];throw new Error("Unknown expr type")}}}}function wi(n,e){return e-n}function Mi(n,e){let t=[];return r(e),t.sort(wi);function r(o){let s=n[o];if(s.length==1&&!s[0].term)return r(s[0].to);t.push(o);for(let i=0;i<s.length;i++){let{term:l,to:a}=s[i];!l&&t.indexOf(a)==-1&&r(a)}}}function Af(n){let e=Object.create(null);return t(Mi(n,0));function t(r){let o=[];r.forEach(i=>{n[i].forEach(({term:l,to:a})=>{if(!l)return;let c;for(let u=0;u<o.length;u++)o[u][0]==l&&(c=o[u][1]);Mi(n,a).forEach(u=>{c||o.push([l,c=[]]),c.indexOf(u)==-1&&c.push(u)})})});let s=e[r.join(",")]=new At(r.indexOf(n.length-1)>-1);for(let i=0;i<o.length;i++){let l=o[i][1].sort(wi);s.next.push({type:o[i][0],next:e[l.join(",")]||t(l)})}return s}}function Pf(n,e){for(let t=0,r=[n];t<r.length;t++){let o=r[t],s=!o.validEnd,i=[];for(let l=0;l<o.next.length;l++){let{type:a,next:c}=o.next[l];i.push(a.name),s&&!(a.isText||a.hasRequiredAttrs())&&(s=!1),r.indexOf(c)==-1&&r.push(c)}s&&e.err("Only non-generatable nodes ("+i.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function Ni(n){let e=Object.create(null);for(let t in n){let r=n[t];if(!r.hasDefault)return null;e[t]=r.default}return e}function Ei(n,e){let t=Object.create(null);for(let r in n){let o=e&&e[r];if(o===void 0){let s=n[r];if(s.hasDefault)o=s.default;else throw new RangeError("No value supplied for attribute "+r)}t[r]=o}return t}function Di(n,e,t,r){for(let o in e)if(!(o in n))throw new RangeError(`Unsupported attribute ${o} for ${t} of type ${o}`);for(let o in n){let s=n[o];s.validate&&s.validate(e[o])}}function Oi(n,e){let t=Object.create(null);if(e)for(let r in e)t[r]=new Vf(n,r,e[r]);return t}let Ti=class uf{constructor(e,t,r){this.name=e,this.schema=t,this.spec=r,this.markSet=null,this.groups=r.group?r.group.split(" "):[],this.attrs=Oi(e,r.attrs),this.defaultAttrs=Ni(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(r.inline||e=="text"),this.isText=e=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==At.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(e){return this.groups.indexOf(e)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:Ei(this.attrs,e)}create(e=null,t,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new be(this,this.computeAttrs(e),C.from(t),F.setFrom(r))}createChecked(e=null,t,r){return t=C.from(t),this.checkContent(t),new be(this,this.computeAttrs(e),t,F.setFrom(r))}createAndFill(e=null,t,r){if(e=this.computeAttrs(e),t=C.from(t),t.size){let i=this.contentMatch.fillBefore(t);if(!i)return null;t=i.append(t)}let o=this.contentMatch.matchFragment(t),s=o&&o.fillBefore(C.empty,!0);return s?new be(this,e,t.append(s),F.setFrom(r)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let r=0;r<e.childCount;r++)if(!this.allowsMarks(e.child(r).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){Di(this.attrs,e,"node",this.name)}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let t;for(let r=0;r<e.length;r++)this.allowsMarkType(e[r].type)?t&&t.push(e[r]):t||(t=e.slice(0,r));return t?t.length?t:F.none:e}static compile(e,t){let r=Object.create(null);e.forEach((s,i)=>r[s]=new uf(s,t,i));let o=t.spec.topNode||"doc";if(!r[o])throw new RangeError("Schema is missing its top node type ('"+o+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let s in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function If(n,e,t){let r=t.split("|");return o=>{let s=o===null?"null":typeof o;if(r.indexOf(s)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${n}, got ${s}`)}}class Vf{constructor(e,t,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?If(e,t,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class mr{constructor(e,t,r,o){this.name=e,this.rank=t,this.schema=r,this.spec=o,this.attrs=Oi(e,o.attrs),this.excluded=null;let s=Ni(this.attrs);this.instance=s?new F(this,s):null}create(e=null){return!e&&this.instance?this.instance:new F(this,Ei(this.attrs,e))}static compile(e,t){let r=Object.create(null),o=0;return e.forEach((s,i)=>r[s]=new mr(s,o++,t,i)),r}removeFromSet(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}checkAttrs(e){Di(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class gr{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let o in e)t[o]=e[o];t.nodes=Z.from(e.nodes),t.marks=Z.from(e.marks||{}),this.nodes=Ti.compile(this.spec.nodes,this),this.marks=mr.compile(this.spec.marks,this);let r=Object.create(null);for(let o in this.nodes){if(o in this.marks)throw new RangeError(o+" can not be both a node and a mark");let s=this.nodes[o],i=s.spec.content||"",l=s.spec.marks;if(s.contentMatch=r[i]||(r[i]=At.parse(i,this.nodes)),s.inlineContent=s.contentMatch.inlineContent,s.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!s.isInline||!s.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=s}s.markSet=l=="_"?null:l?vi(this,l.split(" ")):l==""||!s.inlineContent?[]:null}for(let o in this.marks){let s=this.marks[o],i=s.spec.excludes;s.excluded=i==null?[s]:i==""?[]:vi(this,i.split(" "))}this.nodeFromJSON=this.nodeFromJSON.bind(this),this.markFromJSON=this.markFromJSON.bind(this),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,r,o){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof Ti){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(t,r,o)}text(e,t){let r=this.nodes.text;return new pr(r,r.defaultAttrs,e,F.setFrom(t))}mark(e,t){return typeof e=="string"&&(e=this.marks[e]),e.create(t)}nodeFromJSON(e){return be.fromJSON(this,e)}markFromJSON(e){return F.fromJSON(this,e)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}}function vi(n,e){let t=[];for(let r=0;r<e.length;r++){let o=e[r],s=n.marks[o],i=s;if(s)t.push(s);else for(let l in n.marks){let a=n.marks[l];(o=="_"||a.spec.group&&a.spec.group.split(" ").indexOf(o)>-1)&&t.push(i=a)}if(!i)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return t}function Rf(n){return n.tag!=null}function zf(n){return n.style!=null}class Pt{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let r=this.matchedStyles=[];t.forEach(o=>{if(Rf(o))this.tags.push(o);else if(zf(o)){let s=/[^=]*/.exec(o.style)[0];r.indexOf(s)<0&&r.push(s),this.styles.push(o)}}),this.normalizeLists=!this.tags.some(o=>{if(!/^(ul|ol)\b/.test(o.tag)||!o.node)return!1;let s=e.nodes[o.node];return s.contentMatch.matchType(s)})}parse(e,t={}){let r=new Vi(this,t,!1);return r.addAll(e,F.none,t.from,t.to),r.finish()}parseSlice(e,t={}){let r=new Vi(this,t,!0);return r.addAll(e,F.none,t.from,t.to),N.maxOpen(r.finish())}matchTag(e,t,r){for(let o=r?this.tags.indexOf(r)+1:0;o<this.tags.length;o++){let s=this.tags[o];if(Bf(e,s.tag)&&(s.namespace===void 0||e.namespaceURI==s.namespace)&&(!s.context||t.matchesContext(s.context))){if(s.getAttrs){let i=s.getAttrs(e);if(i===!1)continue;s.attrs=i||void 0}return s}}}matchStyle(e,t,r,o){for(let s=o?this.styles.indexOf(o)+1:0;s<this.styles.length;s++){let i=this.styles[s],l=i.style;if(!(l.indexOf(e)!=0||i.context&&!r.matchesContext(i.context)||l.length>e.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=t))){if(i.getAttrs){let a=i.getAttrs(t);if(a===!1)continue;i.attrs=a||void 0}return i}}}static schemaRules(e){let t=[];function r(o){let s=o.priority==null?50:o.priority,i=0;for(;i<t.length;i++){let l=t[i];if((l.priority==null?50:l.priority)<s)break}t.splice(i,0,o)}for(let o in e.marks){let s=e.marks[o].spec.parseDOM;s&&s.forEach(i=>{r(i=Ri(i)),i.mark||i.ignore||i.clearMark||(i.mark=o)})}for(let o in e.nodes){let s=e.nodes[o].spec.parseDOM;s&&s.forEach(i=>{r(i=Ri(i)),i.node||i.ignore||i.mark||(i.node=o)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Pt(e,Pt.schemaRules(e)))}}const Ai={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},$f={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Pi={ol:!0,ul:!0},En=1,ho=2,yr=4;function Ii(n,e,t){return e!=null?(e?En:0)|(e==="full"?ho:0):n&&n.whitespace=="pre"?En|ho:t&-5}class br{constructor(e,t,r,o,s,i){this.type=e,this.attrs=t,this.marks=r,this.solid=o,this.options=i,this.content=[],this.activeMarks=F.none,this.match=s||(i&yr?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(C.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let r=this.type.contentMatch,o;return(o=r.findWrapping(e.type))?(this.match=r,o):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&En)){let r=this.content[this.content.length-1],o;if(r&&r.isText&&(o=/[ \t\r\n\u000c]+$/.exec(r.text))){let s=r;r.text.length==o[0].length?this.content.pop():this.content[this.content.length-1]=s.withText(s.text.slice(0,s.text.length-o[0].length))}}let t=C.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(C.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!Ai.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class Vi{constructor(e,t,r){this.parser=e,this.options=t,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let o=t.topNode,s,i=Ii(null,t.preserveWhitespace,0)|(r?yr:0);o?s=new br(o.type,o.attrs,F.none,!0,t.topMatch||o.type.contentMatch,i):r?s=new br(null,null,F.none,!0,null,i):s=new br(e.schema.topNodeType,null,F.none,!0,null,i),this.nodes=[s],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){e.nodeType==3?this.addTextNode(e,t):e.nodeType==1&&this.addElement(e,t)}addTextNode(e,t){let r=e.nodeValue,o=this.top,s=o.options&ho?"full":this.localPreserveWS||(o.options&En)>0;if(s==="full"||o.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(s)s!=="full"?r=r.replace(/\r?\n|\r/g," "):r=r.replace(/\r\n?/g,`
|
|
34
34
|
`);else if(r=r.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(r)&&this.open==this.nodes.length-1){let i=o.content[o.content.length-1],l=e.previousSibling;(!i||l&&l.nodeName=="BR"||i.isText&&/[ \t\r\n\u000c]$/.test(i.text))&&(r=r.slice(1))}r&&this.insertNode(this.parser.schema.text(r),t,!/\S/.test(r)),this.findInText(e)}else this.findInside(e)}addElement(e,t,r){let o=this.localPreserveWS,s=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let i=e.nodeName.toLowerCase(),l;Pi.hasOwnProperty(i)&&this.parser.normalizeLists&&jf(e);let a=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(l=this.parser.matchTag(e,this,r));e:if(a?a.ignore:$f.hasOwnProperty(i))this.findInside(e),this.ignoreFallback(e,t);else if(!a||a.skip||a.closeParent){a&&a.closeParent?this.open=Math.max(0,this.open-1):a&&a.skip.nodeType&&(e=a.skip);let c,u=this.needsBlock;if(Ai.hasOwnProperty(i))s.content.length&&s.content[0].isInline&&this.open&&(this.open--,s=this.top),c=!0,s.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break e}let f=a&&a.skip?t:this.readStyles(e,t);f&&this.addAll(e,f),c&&this.sync(s),this.needsBlock=u}else{let c=this.readStyles(e,t);c&&this.addElementByRule(e,a,c,a.consuming===!1?l:void 0)}this.localPreserveWS=o}leafFallback(e,t){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
|
|
35
|
-
`),t)}ignoreFallback(e,t){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),t,!0)}readStyles(e,t){let r=e.style;if(r&&r.length)for(let o=0;o<this.parser.matchedStyles.length;o++){let s=this.parser.matchedStyles[o],i=r.getPropertyValue(s);if(i)for(let l=void 0;;){let a=this.parser.matchStyle(s,i,this,l);if(!a)break;if(a.ignore)return null;if(a.clearMark?t=t.filter(c=>!a.clearMark(c)):t=t.concat(this.parser.schema.marks[a.mark].create(a.attrs)),a.consuming===!1)l=a;else break}}return t}addElementByRule(e,t,r,o){let s,i;if(t.node)if(i=this.parser.schema.nodes[t.node],i.isLeaf)this.insertNode(i.create(t.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let a=this.enter(i,t.attrs||null,r,t.preserveWhitespace);a&&(s=!0,r=a)}else{let a=this.parser.schema.marks[t.mark];r=r.concat(a.create(t.attrs))}let l=this.top;if(i&&i.isLeaf)this.findInside(e);else if(o)this.addElement(e,r,o);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a,r,!1));else{let a=e;typeof t.contentElement=="string"?a=e.querySelector(t.contentElement):typeof t.contentElement=="function"?a=t.contentElement(e):t.contentElement&&(a=t.contentElement),this.findAround(e,a,!0),this.addAll(a,r),this.findAround(e,a,!1)}s&&this.sync(l)&&this.open--}addAll(e,t,r,o){let s=r||0;for(let i=r?e.childNodes[r]:e.firstChild,l=o==null?null:e.childNodes[o];i!=l;i=i.nextSibling,++s)this.findAtPoint(e,s),this.addDOM(i,t);this.findAtPoint(e,s)}findPlace(e,t,r){let o,s;for(let i=this.open,l=0;i>=0;i--){let a=this.nodes[i],c=a.findWrapping(e);if(c&&(!o||o.length>c.length+l)&&(o=c,s=a,!c.length))break;if(a.solid){if(r)break;l+=2}}if(!o)return null;this.sync(s);for(let i=0;i<o.length;i++)t=this.enterInner(o[i],null,t,!1);return t}insertNode(e,t,r){if(e.isInline&&this.needsBlock&&!this.top.type){let s=this.textblockFromContext();s&&(t=this.enterInner(s,null,t))}let o=this.findPlace(e,t,r);if(o){this.closeExtra();let s=this.top;s.match&&(s.match=s.match.matchType(e.type));let i=F.none;for(let l of o.concat(e.marks))(s.type?s.type.allowsMarkType(l.type):zi(l.type,e.type))&&(i=l.addToSet(i));return s.content.push(e.mark(i)),!0}return!1}enter(e,t,r,o){let s=this.findPlace(e.create(t),r,!1);return s&&(s=this.enterInner(e,t,r,!0,o)),s}enterInner(e,t,r,o=!1,s){this.closeExtra();let i=this.top;i.match=i.match&&i.match.matchType(e);let l=Ii(e,s,i.options);i.options&yr&&i.content.length==0&&(l|=yr);let a=F.none;return r=r.filter(c=>(i.type?i.type.allowsMarkType(c.type):zi(c.type,e))?(a=c.addToSet(a),!1):!0),this.nodes.push(new br(e,t,a,o,null,l)),this.open++,r}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let t=this.open;t>=0;t--){if(this.nodes[t]==e)return this.open=t,!0;this.localPreserveWS&&(this.nodes[t].options|=En)}return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let r=this.nodes[t].content;for(let o=r.length-1;o>=0;o--)e+=r[o].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==t&&(this.find[r].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].pos==null&&e.nodeType==1&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,r){if(e!=t&&this.find)for(let o=0;o<this.find.length;o++)this.find[o].pos==null&&e.nodeType==1&&e.contains(this.find[o].node)&&t.compareDocumentPosition(this.find[o].node)&(r?2:4)&&(this.find[o].pos=this.currentPos)}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split("/"),r=this.options.context,o=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),s=-(r?r.depth+1:0)+(o?0:1),i=(l,a)=>{for(;l>=0;l--){let c=t[l];if(c==""){if(l==t.length-1||l==0)continue;for(;a>=s;a--)if(i(l-1,a))return!0;return!1}else{let u=a>0||a==0&&o?this.nodes[a].type:r&&a>=s?r.node(a-s).type:null;if(!u||u.name!=c&&!u.isInGroup(c))return!1;a--}}return!0};return i(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let r=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let t in this.parser.schema.nodes){let r=this.parser.schema.nodes[t];if(r.isTextblock&&r.defaultAttrs)return r}}}function jf(n){for(let e=n.firstChild,t=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&Pi.hasOwnProperty(r)&&t?(t.appendChild(e),e=t):r=="li"?t=e:r&&(t=null)}}function Bf(n,e){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,e)}function Ri(n){let e={};for(let t in n)e[t]=n[t];return e}function zi(n,e){let t=e.schema.nodes;for(let r in t){let o=t[r];if(!o.allowsMarkType(n))continue;let s=[],i=l=>{s.push(l);for(let a=0;a<l.edgeCount;a++){let{type:c,next:u}=l.edge(a);if(c==e||s.indexOf(u)<0&&i(u))return!0}};if(i(o.contentMatch))return!0}}class $e{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},r){r||(r=po(t).createDocumentFragment());let o=r,s=[];return e.forEach(i=>{if(s.length||i.marks.length){let l=0,a=0;for(;l<s.length&&a<i.marks.length;){let c=i.marks[a];if(!this.marks[c.type.name]){a++;continue}if(!c.eq(s[l][0])||c.type.spec.spanning===!1)break;l++,a++}for(;l<s.length;)o=s.pop()[1];for(;a<i.marks.length;){let c=i.marks[a++],u=this.serializeMark(c,i.isInline,t);u&&(s.push([c,o]),o.appendChild(u.dom),o=u.contentDOM||u.dom)}}o.appendChild(this.serializeNodeInner(i,t))}),r}serializeNodeInner(e,t){let{dom:r,contentDOM:o}=xr(po(t),this.nodes[e.type.name](e),null,e.attrs);if(o){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,o)}return r}serializeNode(e,t={}){let r=this.serializeNodeInner(e,t);for(let o=e.marks.length-1;o>=0;o--){let s=this.serializeMark(e.marks[o],e.isInline,t);s&&((s.contentDOM||s.dom).appendChild(r),r=s.dom)}return r}serializeMark(e,t,r={}){let o=this.marks[e.type.name];return o&&xr(po(r),o(e,t),null,e.attrs)}static renderSpec(e,t,r=null,o){return xr(e,t,r,o)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new $e(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=$i(e.nodes);return t.text||(t.text=r=>r.text),t}static marksFromSchema(e){return $i(e.marks)}}function $i(n){let e={};for(let t in n){let r=n[t].spec.toDOM;r&&(e[t]=r)}return e}function po(n){return n.document||window.document}const ji=new WeakMap;function Ff(n){let e=ji.get(n);return e===void 0&&ji.set(n,e=Lf(n)),e}function Lf(n){let e=null;function t(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")e||(e=[]),e.push(r);else for(let o=0;o<r.length;o++)t(r[o]);else for(let o in r)t(r[o])}return t(n),e}function xr(n,e,t,r){if(typeof e=="string")return{dom:n.createTextNode(e)};if(e.nodeType!=null)return{dom:e};if(e.dom&&e.dom.nodeType!=null)return e;let o=e[0],s;if(typeof o!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(s=Ff(r))&&s.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let i=o.indexOf(" ");i>0&&(t=o.slice(0,i),o=o.slice(i+1));let l,a=t?n.createElementNS(t,o):n.createElement(o),c=e[1],u=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){u=2;for(let f in c)if(c[f]!=null){let d=f.indexOf(" ");d>0?a.setAttributeNS(f.slice(0,d),f.slice(d+1),c[f]):a.setAttribute(f,c[f])}}for(let f=u;f<e.length;f++){let d=e[f];if(d===0){if(f<e.length-1||f>u)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}else{let{dom:p,contentDOM:h}=xr(n,d,t,r);if(a.appendChild(p),h){if(l)throw new RangeError("Multiple content holes");l=h}}}return{dom:a,contentDOM:l}}const Bi=65535,Fi=Math.pow(2,16);function Wf(n,e){return n+e*Fi}function Li(n){return n&Bi}function _f(n){return(n-(n&Bi))/Fi}const Wi=1,_i=2,kr=4,qi=8;class mo{constructor(e,t,r){this.pos=e,this.delInfo=t,this.recover=r}get deleted(){return(this.delInfo&qi)>0}get deletedBefore(){return(this.delInfo&(Wi|kr))>0}get deletedAfter(){return(this.delInfo&(_i|kr))>0}get deletedAcross(){return(this.delInfo&kr)>0}}class xe{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&xe.empty)return xe.empty}recover(e){let t=0,r=Li(e);if(!this.inverted)for(let o=0;o<r;o++)t+=this.ranges[o*3+2]-this.ranges[o*3+1];return this.ranges[r*3]+t+_f(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,r){let o=0,s=this.inverted?2:1,i=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?o:0);if(a>e)break;let c=this.ranges[l+s],u=this.ranges[l+i],f=a+c;if(e<=f){let d=c?e==a?-1:e==f?1:t:t,p=a+o+(d<0?0:u);if(r)return p;let h=e==(t<0?a:f)?null:Wf(l/3,e-a),b=e==a?_i:e==f?Wi:kr;return(t<0?e!=a:e!=f)&&(b|=qi),new mo(p,b,h)}o+=u-c}return r?e+o:new mo(e+o,0,null)}touches(e,t){let r=0,o=Li(t),s=this.inverted?2:1,i=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?r:0);if(a>e)break;let c=this.ranges[l+s],u=a+c;if(e<=u&&l==o*3)return!0;r+=this.ranges[l+i]-c}return!1}forEach(e){let t=this.inverted?2:1,r=this.inverted?1:2;for(let o=0,s=0;o<this.ranges.length;o+=3){let i=this.ranges[o],l=i-(this.inverted?s:0),a=i+(this.inverted?0:s),c=this.ranges[o+t],u=this.ranges[o+r];e(l,l+c,a,a+u),s+=u-c}}invert(){return new xe(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?xe.empty:new xe(e<0?[0,-e,0]:[0,0,e])}}xe.empty=new xe([]);class Dn{constructor(e,t,r=0,o=e?e.length:0){this.mirror=t,this.from=r,this.to=o,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(e=0,t=this.maps.length){return new Dn(this._maps,this.mirror,e,t)}appendMap(e,t){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),t!=null&&this.setMirror(this._maps.length-1,t)}appendMapping(e){for(let t=0,r=this._maps.length;t<e._maps.length;t++){let o=e.getMirror(t);this.appendMap(e._maps[t],o!=null&&o<t?r+o:void 0)}}getMirror(e){if(this.mirror){for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}}setMirror(e,t){this.mirror||(this.mirror=[]),this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,r=this._maps.length+e._maps.length;t>=0;t--){let o=e.getMirror(t);this.appendMap(e._maps[t].invert(),o!=null&&o>t?r-o-1:void 0)}}invert(){let e=new Dn;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let r=this.from;r<this.to;r++)e=this._maps[r].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,r){let o=0;for(let s=this.from;s<this.to;s++){let i=this._maps[s],l=i.mapResult(e,t);if(l.recover!=null){let a=this.getMirror(s);if(a!=null&&a>s&&a<this.to){s=a,e=this._maps[a].recover(l.recover);continue}}o|=l.delInfo,e=l.pos}return r?e:new mo(e,o,null)}}const go=Object.create(null);class oe{getMap(){return xe.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=go[t.stepType];if(!r)throw new RangeError(`No step type ${t.stepType} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in go)throw new RangeError("Duplicate use of step JSON ID "+e);return go[e]=t,t.prototype.jsonID=e,t}}class K{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new K(e,null)}static fail(e){return new K(null,e)}static fromReplace(e,t,r,o){try{return K.ok(e.replace(t,r,o))}catch(s){if(s instanceof fr)return K.fail(s.message);throw s}}}function yo(n,e,t){let r=[];for(let o=0;o<n.childCount;o++){let s=n.child(o);s.content.size&&(s=s.copy(yo(s.content,e,s))),s.isInline&&(s=e(s,t,o)),r.push(s)}return S.fromArray(r)}class st extends oe{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=e.resolve(this.from),o=r.node(r.sharedDepth(this.to)),s=new N(yo(t.content,(i,l)=>!i.isAtom||!l.type.allowsMarkType(this.mark.type)?i:i.mark(this.mark.addToSet(i.marks)),o),t.openStart,t.openEnd);return K.fromReplace(e,this.from,this.to,s)}invert(){return new je(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new st(t.pos,r.pos,this.mark)}merge(e){return e instanceof st&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new st(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new st(t.from,t.to,e.markFromJSON(t.mark))}}oe.jsonID("addMark",st);class je extends oe{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=new N(yo(t.content,o=>o.mark(this.mark.removeFromSet(o.marks)),e),t.openStart,t.openEnd);return K.fromReplace(e,this.from,this.to,r)}invert(){return new st(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new je(t.pos,r.pos,this.mark)}merge(e){return e instanceof je&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new je(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new je(t.from,t.to,e.markFromJSON(t.mark))}}oe.jsonID("removeMark",je);class it extends oe{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return K.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return K.fromReplace(e,this.pos,this.pos+1,new N(S.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let r=this.mark.addToSet(t.marks);if(r.length==t.marks.length){for(let o=0;o<t.marks.length;o++)if(!t.marks[o].isInSet(r))return new it(this.pos,t.marks[o]);return new it(this.pos,this.mark)}}return new It(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new it(t.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new it(t.pos,e.markFromJSON(t.mark))}}oe.jsonID("addNodeMark",it);class It extends oe{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return K.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return K.fromReplace(e,this.pos,this.pos+1,new N(S.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new it(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new It(t.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new It(t.pos,e.markFromJSON(t.mark))}}oe.jsonID("removeNodeMark",It);class se extends oe{constructor(e,t,r,o=!1){super(),this.from=e,this.to=t,this.slice=r,this.structure=o}apply(e){return this.structure&&bo(e,this.from,this.to)?K.fail("Structure replace would overwrite content"):K.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new xe([this.from,this.to-this.from,this.slice.size])}invert(e){return new se(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deletedAcross&&r.deletedAcross?null:new se(t.pos,Math.max(t.pos,r.pos),this.slice,this.structure)}merge(e){if(!(e instanceof se)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let t=this.slice.size+e.slice.size==0?N.empty:new N(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new se(this.from,this.to+(e.to-e.from),t,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let t=this.slice.size+e.slice.size==0?N.empty:new N(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new se(e.from,this.to,t,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new se(t.from,t.to,N.fromJSON(e,t.slice),!!t.structure)}}oe.jsonID("replace",se);class ee extends oe{constructor(e,t,r,o,s,i,l=!1){super(),this.from=e,this.to=t,this.gapFrom=r,this.gapTo=o,this.slice=s,this.insert=i,this.structure=l}apply(e){if(this.structure&&(bo(e,this.from,this.gapFrom)||bo(e,this.gapTo,this.to)))return K.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return K.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,t.content);return r?K.fromReplace(e,this.from,this.to,r):K.fail("Content does not fit in gap")}getMap(){return new xe([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let t=this.gapTo-this.gapFrom;return new ee(this.from,this.from+this.slice.size+t,this.from+this.insert,this.from+this.insert+t,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),o=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),s=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return t.deletedAcross&&r.deletedAcross||o<t.pos||s>r.pos?null:new ee(t.pos,r.pos,o,s,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number"||typeof t.gapFrom!="number"||typeof t.gapTo!="number"||typeof t.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new ee(t.from,t.to,t.gapFrom,t.gapTo,N.fromJSON(e,t.slice),t.insert,!!t.structure)}}oe.jsonID("replaceAround",ee);function bo(n,e,t){let r=n.resolve(e),o=t-e,s=r.depth;for(;o>0&&s>0&&r.indexAfter(s)==r.node(s).childCount;)s--,o--;if(o>0){let i=r.node(s).maybeChild(r.indexAfter(s));for(;o>0;){if(!i||i.isLeaf)return!0;i=i.firstChild,o--}}return!1}function qf(n,e,t,r){let o=[],s=[],i,l;n.doc.nodesBetween(e,t,(a,c,u)=>{if(!a.isInline)return;let f=a.marks;if(!r.isInSet(f)&&u.type.allowsMarkType(r.type)){let d=Math.max(c,e),p=Math.min(c+a.nodeSize,t),h=r.addToSet(f);for(let b=0;b<f.length;b++)f[b].isInSet(h)||(i&&i.to==d&&i.mark.eq(f[b])?i.to=p:o.push(i=new je(d,p,f[b])));l&&l.to==d?l.to=p:s.push(l=new st(d,p,r))}}),o.forEach(a=>n.step(a)),s.forEach(a=>n.step(a))}function Hf(n,e,t,r){let o=[],s=0;n.doc.nodesBetween(e,t,(i,l)=>{if(!i.isInline)return;s++;let a=null;if(r instanceof mr){let c=i.marks,u;for(;u=r.isInSet(c);)(a||(a=[])).push(u),c=u.removeFromSet(c)}else r?r.isInSet(i.marks)&&(a=[r]):a=i.marks;if(a&&a.length){let c=Math.min(l+i.nodeSize,t);for(let u=0;u<a.length;u++){let f=a[u],d;for(let p=0;p<o.length;p++){let h=o[p];h.step==s-1&&f.eq(o[p].style)&&(d=h)}d?(d.to=c,d.step=s):o.push({style:f,from:Math.max(l,e),to:c,step:s})}}}),o.forEach(i=>n.step(new je(i.from,i.to,i.style)))}function xo(n,e,t,r=t.contentMatch,o=!0){let s=n.doc.nodeAt(e),i=[],l=e+1;for(let a=0;a<s.childCount;a++){let c=s.child(a),u=l+c.nodeSize,f=r.matchType(c.type);if(!f)i.push(new se(l,u,N.empty));else{r=f;for(let d=0;d<c.marks.length;d++)t.allowsMarkType(c.marks[d].type)||n.step(new je(l,u,c.marks[d]));if(o&&c.isText&&t.whitespace!="pre"){let d,p=/\r?\n|\r/g,h;for(;d=p.exec(c.text);)h||(h=new N(S.from(t.schema.text(" ",t.allowedMarks(c.marks))),0,0)),i.push(new se(l+d.index,l+d.index+d[0].length,h))}}l=u}if(!r.validEnd){let a=r.fillBefore(S.empty,!0);n.replace(l,l,new N(a,0,0))}for(let a=i.length-1;a>=0;a--)n.step(i[a])}function Kf(n,e,t){return(e==0||n.canReplace(e,n.childCount))&&(t==n.childCount||n.canReplace(0,t))}function On(n){let t=n.parent.content.cutByIndex(n.startIndex,n.endIndex);for(let r=n.depth;;--r){let o=n.$from.node(r),s=n.$from.index(r),i=n.$to.indexAfter(r);if(r<n.depth&&o.canReplace(s,i,t))return r;if(r==0||o.type.spec.isolating||!Kf(o,s,i))break}return null}function Jf(n,e,t){let{$from:r,$to:o,depth:s}=e,i=r.before(s+1),l=o.after(s+1),a=i,c=l,u=S.empty,f=0;for(let h=s,b=!1;h>t;h--)b||r.index(h)>0?(b=!0,u=S.from(r.node(h).copy(u)),f++):a--;let d=S.empty,p=0;for(let h=s,b=!1;h>t;h--)b||o.after(h+1)<o.end(h)?(b=!0,d=S.from(o.node(h).copy(d)),p++):c++;n.step(new ee(a,c,i,l,new N(u.append(d),f,p),u.size-f,!0))}function ko(n,e,t=null,r=n){let o=Yf(n,e),s=o&&Gf(r,e);return s?o.map(Hi).concat({type:e,attrs:t}).concat(s.map(Hi)):null}function Hi(n){return{type:n,attrs:null}}function Yf(n,e){let{parent:t,startIndex:r,endIndex:o}=n,s=t.contentMatchAt(r).findWrapping(e);if(!s)return null;let i=s.length?s[0]:e;return t.canReplaceWith(r,o,i)?s:null}function Gf(n,e){let{parent:t,startIndex:r,endIndex:o}=n,s=t.child(r),i=e.contentMatch.findWrapping(s.type);if(!i)return null;let a=(i.length?i[i.length-1]:e).contentMatch;for(let c=r;a&&c<o;c++)a=a.matchType(t.child(c).type);return!a||!a.validEnd?null:i}function Xf(n,e,t){let r=S.empty;for(let i=t.length-1;i>=0;i--){if(r.size){let l=t[i].type.contentMatch.matchFragment(r);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=S.from(t[i].type.create(t[i].attrs,r))}let o=e.start,s=e.end;n.step(new ee(o,s,o,s,new N(r,0,0),t.length,!0))}function Uf(n,e,t,r,o){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let s=n.steps.length;n.doc.nodesBetween(e,t,(i,l)=>{let a=typeof o=="function"?o(i):o;if(i.isTextblock&&!i.hasMarkup(r,a)&&Qf(n.doc,n.mapping.slice(s).map(l),r)){let c=null;if(r.schema.linebreakReplacement){let p=r.whitespace=="pre",h=!!r.contentMatch.matchType(r.schema.linebreakReplacement);p&&!h?c=!1:!p&&h&&(c=!0)}c===!1&&Ji(n,i,l,s),xo(n,n.mapping.slice(s).map(l,1),r,void 0,c===null);let u=n.mapping.slice(s),f=u.map(l,1),d=u.map(l+i.nodeSize,1);return n.step(new ee(f,d,f+1,d-1,new N(S.from(r.create(a,null,i.marks)),0,0),1,!0)),c===!0&&Ki(n,i,l,s),!1}})}function Ki(n,e,t,r){e.forEach((o,s)=>{if(o.isText){let i,l=/\r?\n|\r/g;for(;i=l.exec(o.text);){let a=n.mapping.slice(r).map(t+1+s+i.index);n.replaceWith(a,a+1,e.type.schema.linebreakReplacement.create())}}})}function Ji(n,e,t,r){e.forEach((o,s)=>{if(o.type==o.type.schema.linebreakReplacement){let i=n.mapping.slice(r).map(t+1+s);n.replaceWith(i,i+1,e.type.schema.text(`
|
|
36
|
-
`))}})}function Qf(n,e,t){let r=n.resolve(e),o=r.index();return r.parent.canReplaceWith(o,o+1,t)}function Zf(n,e,t,r,o){let s=n.doc.nodeAt(e);if(!s)throw new RangeError("No node at given position");t||(t=s.type);let i=t.create(r,null,o||s.marks);if(s.isLeaf)return n.replaceWith(e,e+s.nodeSize,i);if(!t.validContent(s.content))throw new RangeError("Invalid content for node type "+t.name);n.step(new ee(e,e+s.nodeSize,e+1,e+s.nodeSize-1,new N(S.from(i),0,0),1,!0))}function Qt(n,e,t=1,r){let o=n.resolve(e),s=o.depth-t,i=r&&r[r.length-1]||o.parent;if(s<0||o.parent.type.spec.isolating||!o.parent.canReplace(o.index(),o.parent.childCount)||!i.type.validContent(o.parent.content.cutByIndex(o.index(),o.parent.childCount)))return!1;for(let c=o.depth-1,u=t-2;c>s;c--,u--){let f=o.node(c),d=o.index(c);if(f.type.spec.isolating)return!1;let p=f.content.cutByIndex(d,f.childCount),h=r&&r[u+1];h&&(p=p.replaceChild(0,h.type.create(h.attrs)));let b=r&&r[u]||f;if(!f.canReplace(d+1,f.childCount)||!b.type.validContent(p))return!1}let l=o.indexAfter(s),a=r&&r[0];return o.node(s).canReplaceWith(l,l,a?a.type:o.node(s+1).type)}function ed(n,e,t=1,r){let o=n.doc.resolve(e),s=S.empty,i=S.empty;for(let l=o.depth,a=o.depth-t,c=t-1;l>a;l--,c--){s=S.from(o.node(l).copy(s));let u=r&&r[c];i=S.from(u?u.type.create(u.attrs,i):o.node(l).copy(i))}n.step(new se(e,e,new N(s.append(i),t,t),!0))}function Zt(n,e){let t=n.resolve(e),r=t.index();return Yi(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(r,r+1)}function td(n,e){e.content.size||n.type.compatibleContent(e.type);let t=n.contentMatchAt(n.childCount),{linebreakReplacement:r}=n.type.schema;for(let o=0;o<e.childCount;o++){let s=e.child(o),i=s.type==r?n.type.schema.nodes.text:s.type;if(t=t.matchType(i),!t||!n.type.allowsMarks(s.marks))return!1}return t.validEnd}function Yi(n,e){return!!(n&&e&&!n.isLeaf&&td(n,e))}function Gi(n,e,t=-1){let r=n.resolve(e);for(let o=r.depth;;o--){let s,i,l=r.index(o);if(o==r.depth?(s=r.nodeBefore,i=r.nodeAfter):t>0?(s=r.node(o+1),l++,i=r.node(o).maybeChild(l)):(s=r.node(o).maybeChild(l-1),i=r.node(o+1)),s&&!s.isTextblock&&Yi(s,i)&&r.node(o).canReplace(l,l+1))return e;if(o==0)break;e=t<0?r.before(o):r.after(o)}}function nd(n,e,t){let r=null,{linebreakReplacement:o}=n.doc.type.schema,s=n.doc.resolve(e-t),i=s.node().type;if(o&&i.inlineContent){let u=i.whitespace=="pre",f=!!i.contentMatch.matchType(o);u&&!f?r=!1:!u&&f&&(r=!0)}let l=n.steps.length;if(r===!1){let u=n.doc.resolve(e+t);Ji(n,u.node(),u.before(),l)}i.inlineContent&&xo(n,e+t-1,i,s.node().contentMatchAt(s.index()),r==null);let a=n.mapping.slice(l),c=a.map(e-t);if(n.step(new se(c,a.map(e+t,-1),N.empty,!0)),r===!0){let u=n.doc.resolve(c);Ki(n,u.node(),u.before(),n.steps.length)}return n}function rd(n,e,t){let r=n.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),t))return e;if(r.parentOffset==0)for(let o=r.depth-1;o>=0;o--){let s=r.index(o);if(r.node(o).canReplaceWith(s,s,t))return r.before(o+1);if(s>0)return null}if(r.parentOffset==r.parent.content.size)for(let o=r.depth-1;o>=0;o--){let s=r.indexAfter(o);if(r.node(o).canReplaceWith(s,s,t))return r.after(o+1);if(s<r.node(o).childCount)return null}return null}function So(n,e,t){let r=n.resolve(e);if(!t.content.size)return e;let o=t.content;for(let s=0;s<t.openStart;s++)o=o.firstChild.content;for(let s=1;s<=(t.openStart==0&&t.size?2:1);s++)for(let i=r.depth;i>=0;i--){let l=i==r.depth?0:r.pos<=(r.start(i+1)+r.end(i+1))/2?-1:1,a=r.index(i)+(l>0?1:0),c=r.node(i),u=!1;if(s==1)u=c.canReplace(a,a,o);else{let f=c.contentMatchAt(a).findWrapping(o.firstChild.type);u=f&&c.canReplaceWith(a,a,f[0])}if(u)return l==0?r.pos:l<0?r.before(i+1):r.after(i+1)}return null}function Co(n,e,t=e,r=N.empty){if(e==t&&!r.size)return null;let o=n.resolve(e),s=n.resolve(t);return Xi(o,s,r)?new se(e,t,r):new od(o,s,r).fit()}function Xi(n,e,t){return!t.openStart&&!t.openEnd&&n.start()==e.start()&&n.parent.canReplace(n.index(),e.index(),t.content)}class od{constructor(e,t,r){this.$from=e,this.$to=t,this.unplaced=r,this.frontier=[],this.placed=S.empty;for(let o=0;o<=e.depth;o++){let s=e.node(o);this.frontier.push({type:s.type,match:s.contentMatchAt(e.indexAfter(o))})}for(let o=e.depth;o>0;o--)this.placed=S.from(e.node(o).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let c=this.findFittable();c?this.placeNodes(c):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,r=this.$from,o=this.close(e<0?this.$to:r.doc.resolve(e));if(!o)return null;let s=this.placed,i=r.depth,l=o.depth;for(;i&&l&&s.childCount==1;)s=s.firstChild.content,i--,l--;let a=new N(s,i,l);return e>-1?new ee(r.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||r.pos!=this.$to.pos?new se(r.pos,o.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,r=0,o=this.unplaced.openEnd;r<e;r++){let s=t.firstChild;if(t.childCount>1&&(o=0),s.type.spec.isolating&&o<=r){e=r;break}t=s.content}for(let t=1;t<=2;t++)for(let r=t==1?e:this.unplaced.openStart;r>=0;r--){let o,s=null;r?(s=wo(this.unplaced.content,r-1).firstChild,o=s.content):o=this.unplaced.content;let i=o.firstChild;for(let l=this.depth;l>=0;l--){let{type:a,match:c}=this.frontier[l],u,f=null;if(t==1&&(i?c.matchType(i.type)||(f=c.fillBefore(S.from(i),!1)):s&&a.compatibleContent(s.type)))return{sliceDepth:r,frontierDepth:l,parent:s,inject:f};if(t==2&&i&&(u=c.findWrapping(i.type)))return{sliceDepth:r,frontierDepth:l,parent:s,wrap:u};if(s&&c.matchType(s.type))break}}}openMore(){let{content:e,openStart:t,openEnd:r}=this.unplaced,o=wo(e,t);return!o.childCount||o.firstChild.isLeaf?!1:(this.unplaced=new N(e,t+1,Math.max(r,o.size+t>=e.size-r?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:r}=this.unplaced,o=wo(e,t);if(o.childCount<=1&&t>0){let s=e.size-t<=t+o.size;this.unplaced=new N(Tn(e,t-1,1),t-1,s?t-1:r)}else this.unplaced=new N(Tn(e,t,1),t,r)}placeNodes({sliceDepth:e,frontierDepth:t,parent:r,inject:o,wrap:s}){for(;this.depth>t;)this.closeFrontierNode();if(s)for(let b=0;b<s.length;b++)this.openFrontierNode(s[b]);let i=this.unplaced,l=r?r.content:i.content,a=i.openStart-e,c=0,u=[],{match:f,type:d}=this.frontier[t];if(o){for(let b=0;b<o.childCount;b++)u.push(o.child(b));f=f.matchFragment(o)}let p=l.size+e-(i.content.size-i.openEnd);for(;c<l.childCount;){let b=l.child(c),g=f.matchType(b.type);if(!g)break;c++,(c>1||a==0||b.content.size)&&(f=g,u.push(Ui(b.mark(d.allowedMarks(b.marks)),c==1?a:0,c==l.childCount?p:-1)))}let h=c==l.childCount;h||(p=-1),this.placed=vn(this.placed,t,S.from(u)),this.frontier[t].match=f,h&&p<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let b=0,g=l;b<p;b++){let k=g.lastChild;this.frontier.push({type:k.type,match:k.contentMatchAt(k.childCount)}),g=k.content}this.unplaced=h?e==0?N.empty:new N(Tn(i.content,e-1,1),e-1,p<0?i.openEnd:e-1):new N(Tn(i.content,e,c),i.openStart,i.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],t;if(!e.type.isTextblock||!Mo(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(t=this.findCloseLevel(this.$to))&&t.depth==this.depth)return-1;let{depth:r}=this.$to,o=this.$to.after(r);for(;r>1&&o==this.$to.end(--r);)++o;return o}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:r,type:o}=this.frontier[t],s=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),i=Mo(e,t,o,r,s);if(i){for(let l=t-1;l>=0;l--){let{match:a,type:c}=this.frontier[l],u=Mo(e,l,c,a,!0);if(!u||u.childCount)continue e}return{depth:t,fit:i,move:s?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=vn(this.placed,t.depth,t.fit)),e=t.move;for(let r=t.depth+1;r<=e.depth;r++){let o=e.node(r),s=o.type.contentMatch.fillBefore(o.content,!0,e.index(r));this.openFrontierNode(o.type,o.attrs,s)}return e}openFrontierNode(e,t=null,r){let o=this.frontier[this.depth];o.match=o.match.matchType(e),this.placed=vn(this.placed,this.depth,S.from(e.create(t,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(S.empty,!0);t.childCount&&(this.placed=vn(this.placed,this.frontier.length,t))}}function Tn(n,e,t){return e==0?n.cutByIndex(t,n.childCount):n.replaceChild(0,n.firstChild.copy(Tn(n.firstChild.content,e-1,t)))}function vn(n,e,t){return e==0?n.append(t):n.replaceChild(n.childCount-1,n.lastChild.copy(vn(n.lastChild.content,e-1,t)))}function wo(n,e){for(let t=0;t<e;t++)n=n.firstChild.content;return n}function Ui(n,e,t){if(e<=0)return n;let r=n.content;return e>1&&(r=r.replaceChild(0,Ui(r.firstChild,e-1,r.childCount==1?t-1:0))),e>0&&(r=n.type.contentMatch.fillBefore(r).append(r),t<=0&&(r=r.append(n.type.contentMatch.matchFragment(r).fillBefore(S.empty,!0)))),n.copy(r)}function Mo(n,e,t,r,o){let s=n.node(e),i=o?n.indexAfter(e):n.index(e);if(i==s.childCount&&!t.compatibleContent(s.type))return null;let l=r.fillBefore(s.content,!0,i);return l&&!sd(t,s.content,i)?l:null}function sd(n,e,t){for(let r=t;r<e.childCount;r++)if(!n.allowsMarks(e.child(r).marks))return!0;return!1}function id(n){return n.spec.defining||n.spec.definingForContent}function ld(n,e,t,r){if(!r.size)return n.deleteRange(e,t);let o=n.doc.resolve(e),s=n.doc.resolve(t);if(Xi(o,s,r))return n.step(new se(e,t,r));let i=Zi(o,n.doc.resolve(t));i[i.length-1]==0&&i.pop();let l=-(o.depth+1);i.unshift(l);for(let d=o.depth,p=o.pos-1;d>0;d--,p--){let h=o.node(d).type.spec;if(h.defining||h.definingAsContext||h.isolating)break;i.indexOf(d)>-1?l=d:o.before(d)==p&&i.splice(1,0,-d)}let a=i.indexOf(l),c=[],u=r.openStart;for(let d=r.content,p=0;;p++){let h=d.firstChild;if(c.push(h),p==r.openStart)break;d=h.content}for(let d=u-1;d>=0;d--){let p=c[d],h=id(p.type);if(h&&!p.sameMarkup(o.node(Math.abs(l)-1)))u=d;else if(h||!p.type.isTextblock)break}for(let d=r.openStart;d>=0;d--){let p=(d+u+1)%(r.openStart+1),h=c[p];if(h)for(let b=0;b<i.length;b++){let g=i[(b+a)%i.length],k=!0;g<0&&(k=!1,g=-g);let w=o.node(g-1),M=o.index(g-1);if(w.canReplaceWith(M,M,h.type,h.marks))return n.replace(o.before(g),k?s.after(g):t,new N(Qi(r.content,0,r.openStart,p),p,r.openEnd))}}let f=n.steps.length;for(let d=i.length-1;d>=0&&(n.replace(e,t,r),!(n.steps.length>f));d--){let p=i[d];p<0||(e=o.before(p),t=s.after(p))}}function Qi(n,e,t,r,o){if(e<t){let s=n.firstChild;n=n.replaceChild(0,s.copy(Qi(s.content,e+1,t,r,s)))}if(e>r){let s=o.contentMatchAt(0),i=s.fillBefore(n).append(n);n=i.append(s.matchFragment(i).fillBefore(S.empty,!0))}return n}function ad(n,e,t,r){if(!r.isInline&&e==t&&n.doc.resolve(e).parent.content.size){let o=rd(n.doc,e,r.type);o!=null&&(e=t=o)}n.replaceRange(e,t,new N(S.from(r),0,0))}function cd(n,e,t){let r=n.doc.resolve(e),o=n.doc.resolve(t),s=Zi(r,o);for(let i=0;i<s.length;i++){let l=s[i],a=i==s.length-1;if(a&&l==0||r.node(l).type.contentMatch.validEnd)return n.delete(r.start(l),o.end(l));if(l>0&&(a||r.node(l-1).canReplace(r.index(l-1),o.indexAfter(l-1))))return n.delete(r.before(l),o.after(l))}for(let i=1;i<=r.depth&&i<=o.depth;i++)if(e-r.start(i)==r.depth-i&&t>r.end(i)&&o.end(i)-t!=o.depth-i&&r.start(i-1)==o.start(i-1)&&r.node(i-1).canReplace(r.index(i-1),o.index(i-1)))return n.delete(r.before(i),t);n.delete(e,t)}function Zi(n,e){let t=[],r=Math.min(n.depth,e.depth);for(let o=r;o>=0;o--){let s=n.start(o);if(s<n.pos-(n.depth-o)||e.end(o)>e.pos+(e.depth-o)||n.node(o).type.spec.isolating||e.node(o).type.spec.isolating)break;(s==e.start(o)||o==n.depth&&o==e.depth&&n.parent.inlineContent&&e.parent.inlineContent&&o&&e.start(o-1)==s-1)&&t.push(o)}return t}class en extends oe{constructor(e,t,r){super(),this.pos=e,this.attr=t,this.value=r}apply(e){let t=e.nodeAt(this.pos);if(!t)return K.fail("No node at attribute step's position");let r=Object.create(null);for(let s in t.attrs)r[s]=t.attrs[s];r[this.attr]=this.value;let o=t.type.create(r,null,t.marks);return K.fromReplace(e,this.pos,this.pos+1,new N(S.from(o),0,t.isLeaf?0:1))}getMap(){return xe.empty}invert(e){return new en(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new en(t.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.pos!="number"||typeof t.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new en(t.pos,t.attr,t.value)}}oe.jsonID("attr",en);class An extends oe{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let o in e.attrs)t[o]=e.attrs[o];t[this.attr]=this.value;let r=e.type.create(t,e.content,e.marks);return K.ok(r)}getMap(){return xe.empty}invert(e){return new An(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new An(t.attr,t.value)}}oe.jsonID("docAttr",An);let tn=class extends Error{};tn=function n(e){let t=Error.call(this,e);return t.__proto__=n.prototype,t},tn.prototype=Object.create(Error.prototype),tn.prototype.constructor=tn,tn.prototype.name="TransformError";class el{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Dn}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new tn(t.failed);return this}maybeStep(e){let t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t}get docChanged(){return this.steps.length>0}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,r=N.empty){let o=Co(this.doc,e,t,r);return o&&this.step(o),this}replaceWith(e,t,r){return this.replace(e,t,new N(S.from(r),0,0))}delete(e,t){return this.replace(e,t,N.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,r){return ld(this,e,t,r),this}replaceRangeWith(e,t,r){return ad(this,e,t,r),this}deleteRange(e,t){return cd(this,e,t),this}lift(e,t){return Jf(this,e,t),this}join(e,t=1){return nd(this,e,t),this}wrap(e,t){return Xf(this,e,t),this}setBlockType(e,t=e,r,o=null){return Uf(this,e,t,r,o),this}setNodeMarkup(e,t,r=null,o){return Zf(this,e,t,r,o),this}setNodeAttribute(e,t,r){return this.step(new en(e,t,r)),this}setDocAttribute(e,t){return this.step(new An(e,t)),this}addNodeMark(e,t){return this.step(new it(e,t)),this}removeNodeMark(e,t){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(t instanceof F)t.isInSet(r.marks)&&this.step(new It(e,t));else{let o=r.marks,s,i=[];for(;s=t.isInSet(o);)i.push(new It(e,s)),o=s.removeFromSet(o);for(let l=i.length-1;l>=0;l--)this.step(i[l])}return this}split(e,t=1,r){return ed(this,e,t,r),this}addMark(e,t,r){return qf(this,e,t,r),this}removeMark(e,t,r){return Hf(this,e,t,r),this}clearIncompatible(e,t,r){return xo(this,e,t,r),this}}const No=Object.create(null);class R{constructor(e,t,r){this.$anchor=e,this.$head=t,this.ranges=r||[new tl(e.min(t),e.max(t))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let t=0;t<e.length;t++)if(e[t].$from.pos!=e[t].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,t=N.empty){let r=t.content.lastChild,o=null;for(let l=0;l<t.openEnd;l++)o=r,r=r.lastChild;let s=e.steps.length,i=this.ranges;for(let l=0;l<i.length;l++){let{$from:a,$to:c}=i[l],u=e.mapping.slice(s);e.replaceRange(u.map(a.pos),u.map(c.pos),l?N.empty:t),l==0&&ol(e,s,(r?r.isInline:o&&o.isTextblock)?-1:1)}}replaceWith(e,t){let r=e.steps.length,o=this.ranges;for(let s=0;s<o.length;s++){let{$from:i,$to:l}=o[s],a=e.mapping.slice(r),c=a.map(i.pos),u=a.map(l.pos);s?e.deleteRange(c,u):(e.replaceRangeWith(c,u,t),ol(e,r,t.isInline?-1:1))}}static findFrom(e,t,r=!1){let o=e.parent.inlineContent?new P(e):nn(e.node(0),e.parent,e.pos,e.index(),t,r);if(o)return o;for(let s=e.depth-1;s>=0;s--){let i=t<0?nn(e.node(0),e.node(s),e.before(s+1),e.index(s),t,r):nn(e.node(0),e.node(s),e.after(s+1),e.index(s)+1,t,r);if(i)return i}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new ge(e.node(0))}static atStart(e){return nn(e,e,0,0,1)||new ge(e)}static atEnd(e){return nn(e,e,e.content.size,e.childCount,-1)||new ge(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=No[t.type];if(!r)throw new RangeError(`No selection type ${t.type} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in No)throw new RangeError("Duplicate use of selection JSON ID "+e);return No[e]=t,t.prototype.jsonID=e,t}getBookmark(){return P.between(this.$anchor,this.$head).getBookmark()}}R.prototype.visible=!0;class tl{constructor(e,t){this.$from=e,this.$to=t}}let nl=!1;function rl(n){!nl&&!n.parent.inlineContent&&(nl=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+n.parent.type.name+")"))}class P extends R{constructor(e,t=e){rl(e),rl(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let r=e.resolve(t.map(this.head));if(!r.parent.inlineContent)return R.near(r);let o=e.resolve(t.map(this.anchor));return new P(o.parent.inlineContent?o:r,r)}replace(e,t=N.empty){if(super.replace(e,t),t==N.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof P&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Sr(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if(typeof t.anchor!="number"||typeof t.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new P(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,r=t){let o=e.resolve(t);return new this(o,r==t?o:e.resolve(r))}static between(e,t,r){let o=e.pos-t.pos;if((!r||o)&&(r=o>=0?1:-1),!t.parent.inlineContent){let s=R.findFrom(t,r,!0)||R.findFrom(t,-r,!0);if(s)t=s.$head;else return R.near(t,r)}return e.parent.inlineContent||(o==0?e=t:(e=(R.findFrom(e,-r,!0)||R.findFrom(e,r,!0)).$anchor,e.pos<t.pos!=o<0&&(e=t))),new P(e,t)}}R.jsonID("text",P);class Sr{constructor(e,t){this.anchor=e,this.head=t}map(e){return new Sr(e.map(this.anchor),e.map(this.head))}resolve(e){return P.between(e.resolve(this.anchor),e.resolve(this.head))}}class D extends R{constructor(e){let t=e.nodeAfter,r=e.node(0).resolve(e.pos+t.nodeSize);super(e,r),this.node=t}map(e,t){let{deleted:r,pos:o}=t.mapResult(this.anchor),s=e.resolve(o);return r?R.near(s):new D(s)}content(){return new N(S.from(this.node),0,0)}eq(e){return e instanceof D&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new Eo(this.anchor)}static fromJSON(e,t){if(typeof t.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new D(e.resolve(t.anchor))}static create(e,t){return new D(e.resolve(t))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}D.prototype.visible=!1,R.jsonID("node",D);class Eo{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:r}=e.mapResult(this.anchor);return t?new Sr(r,r):new Eo(r)}resolve(e){let t=e.resolve(this.anchor),r=t.nodeAfter;return r&&D.isSelectable(r)?new D(t):R.near(t)}}class ge extends R{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=N.empty){if(t==N.empty){e.delete(0,e.doc.content.size);let r=R.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new ge(e)}map(e){return new ge(e)}eq(e){return e instanceof ge}getBookmark(){return ud}}R.jsonID("all",ge);const ud={map(){return this},resolve(n){return new ge(n)}};function nn(n,e,t,r,o,s=!1){if(e.inlineContent)return P.create(n,t);for(let i=r-(o>0?0:1);o>0?i<e.childCount:i>=0;i+=o){let l=e.child(i);if(l.isAtom){if(!s&&D.isSelectable(l))return D.create(n,t-(o<0?l.nodeSize:0))}else{let a=nn(n,l,t+o,o<0?l.childCount:0,o,s);if(a)return a}t+=l.nodeSize*o}return null}function ol(n,e,t){let r=n.steps.length-1;if(r<e)return;let o=n.steps[r];if(!(o instanceof se||o instanceof ee))return;let s=n.mapping.maps[r],i;s.forEach((l,a,c,u)=>{i==null&&(i=u)}),n.setSelection(R.near(n.doc.resolve(i),t))}const sl=1,il=2,ll=4;class fd extends el{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(e){if(e.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=(this.updated|sl)&-3,this.storedMarks=null,this}get selectionSet(){return(this.updated&sl)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=il,this}ensureMarks(e){return F.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&il)>0}addStep(e,t){super.addStep(e,t),this.updated=this.updated&-3,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let r=this.selection;return t&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||F.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,r){let o=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(o.text(e),!0):this.deleteSelection();{if(r==null&&(r=t),r=r??t,!e)return this.deleteRange(t,r);let s=this.storedMarks;if(!s){let i=this.doc.resolve(t);s=r==t?i.marks():i.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(t,r,o.text(e,s)),this.selection.empty||this.setSelection(R.near(this.selection.$to)),this}}setMeta(e,t){return this.meta[typeof e=="string"?e:e.key]=t,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|=ll,this}get scrolledIntoView(){return(this.updated&ll)>0}}function al(n,e){return!e||!n?n:n.bind(e)}class Pn{constructor(e,t,r){this.name=e,this.init=al(t.init,r),this.apply=al(t.apply,r)}}const dd=[new Pn("doc",{init(n){return n.doc||n.schema.topNodeType.createAndFill()},apply(n){return n.doc}}),new Pn("selection",{init(n,e){return n.selection||R.atStart(e.doc)},apply(n){return n.selection}}),new Pn("storedMarks",{init(n){return n.storedMarks||null},apply(n,e,t,r){return r.selection.$cursor?n.storedMarks:null}}),new Pn("scrollToSelection",{init(){return 0},apply(n,e){return n.scrolledIntoView?e+1:e}})];class Do{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=dd.slice(),t&&t.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 Pn(r.key,r.spec.state,r))})}}class Ge{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,t=-1){for(let r=0;r<this.config.plugins.length;r++)if(r!=t){let o=this.config.plugins[r];if(o.spec.filterTransaction&&!o.spec.filterTransaction.call(o,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let t=[e],r=this.applyInner(e),o=null;for(;;){let s=!1;for(let i=0;i<this.config.plugins.length;i++){let l=this.config.plugins[i];if(l.spec.appendTransaction){let a=o?o[i].n:0,c=o?o[i].state:this,u=a<t.length&&l.spec.appendTransaction.call(l,a?t.slice(a):t,c,r);if(u&&r.filterTransaction(u,i)){if(u.setMeta("appendedTransaction",e),!o){o=[];for(let f=0;f<this.config.plugins.length;f++)o.push(f<i?{state:r,n:t.length}:{state:this,n:0})}t.push(u),r=r.applyInner(u),s=!0}o&&(o[i]={state:r,n:t.length})}}if(!s)return{state:r,transactions:t}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let t=new Ge(this.config),r=this.config.fields;for(let o=0;o<r.length;o++){let s=r[o];t[s.name]=s.apply(e,this[s.name],this,t)}return t}get tr(){return new fd(this)}static create(e){let t=new Do(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new Ge(t);for(let o=0;o<t.fields.length;o++)r[t.fields[o].name]=t.fields[o].init(e,r);return r}reconfigure(e){let t=new Do(this.schema,e.plugins),r=t.fields,o=new Ge(t);for(let s=0;s<r.length;s++){let i=r[s].name;o[i]=this.hasOwnProperty(i)?this[i]:r[s].init(e,o)}return o}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map(r=>r.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 o=e[r],s=o.spec.state;s&&s.toJSON&&(t[r]=s.toJSON.call(o,this[o.key]))}return t}static fromJSON(e,t,r){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let o=new Do(e.schema,e.plugins),s=new Ge(o);return o.fields.forEach(i=>{if(i.name=="doc")s.doc=be.fromJSON(e.schema,t.doc);else if(i.name=="selection")s.selection=R.fromJSON(s.doc,t.selection);else if(i.name=="storedMarks")t.storedMarks&&(s.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let l in r){let a=r[l],c=a.spec.state;if(a.key==i.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(t,l)){s[i.name]=c.fromJSON.call(a,e,t[l],s);return}}s[i.name]=i.init(e,s)}}),s}}function cl(n,e,t){for(let r in n){let o=n[r];o instanceof Function?o=o.bind(e):r=="handleDOMEvents"&&(o=cl(o,e,{})),t[r]=o}return t}class Be{constructor(e){this.spec=e,this.props={},e.props&&cl(e.props,this,this.props),this.key=e.key?e.key.key:ul("plugin")}getState(e){return e[this.key]}}const Oo=Object.create(null);function ul(n){return n in Oo?n+"$"+ ++Oo[n]:(Oo[n]=0,n+"$")}class lt{constructor(e="key"){this.key=ul(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}var Cr=200,X=function(){};X.prototype.append=function(e){return e.length?(e=X.from(e),!this.length&&e||e.length<Cr&&this.leafAppend(e)||this.length<Cr&&e.leafPrepend(this)||this.appendInner(e)):this},X.prototype.prepend=function(e){return e.length?X.from(e).append(this):this},X.prototype.appendInner=function(e){return new hd(this,e)},X.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?X.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},X.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},X.prototype.forEach=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length),t<=r?this.forEachInner(e,t,r,0):this.forEachInvertedInner(e,t,r,0)},X.prototype.map=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length);var o=[];return this.forEach(function(s,i){return o.push(e(s,i))},t,r),o},X.from=function(e){return e instanceof X?e:e&&e.length?new fl(e):X.empty};var fl=function(n){function e(r){n.call(this),this.values=r}n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e;var t={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(o,s){return o==0&&s==this.length?this:new e(this.values.slice(o,s))},e.prototype.getInner=function(o){return this.values[o]},e.prototype.forEachInner=function(o,s,i,l){for(var a=s;a<i;a++)if(o(this.values[a],l+a)===!1)return!1},e.prototype.forEachInvertedInner=function(o,s,i,l){for(var a=s-1;a>=i;a--)if(o(this.values[a],l+a)===!1)return!1},e.prototype.leafAppend=function(o){if(this.length+o.length<=Cr)return new e(this.values.concat(o.flatten()))},e.prototype.leafPrepend=function(o){if(this.length+o.length<=Cr)return new e(o.flatten().concat(this.values))},t.length.get=function(){return this.values.length},t.depth.get=function(){return 0},Object.defineProperties(e.prototype,t),e}(X);X.empty=new fl([]);var hd=function(n){function e(t,r){n.call(this),this.left=t,this.right=r,this.length=t.length+r.length,this.depth=Math.max(t.depth,r.depth)+1}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(r){return r<this.left.length?this.left.get(r):this.right.get(r-this.left.length)},e.prototype.forEachInner=function(r,o,s,i){var l=this.left.length;if(o<l&&this.left.forEachInner(r,o,Math.min(s,l),i)===!1||s>l&&this.right.forEachInner(r,Math.max(o-l,0),Math.min(this.length,s)-l,i+l)===!1)return!1},e.prototype.forEachInvertedInner=function(r,o,s,i){var l=this.left.length;if(o>l&&this.right.forEachInvertedInner(r,o-l,Math.max(s,l)-l,i+l)===!1||s<l&&this.left.forEachInvertedInner(r,Math.min(o,l),s,i)===!1)return!1},e.prototype.sliceInner=function(r,o){if(r==0&&o==this.length)return this;var s=this.left.length;return o<=s?this.left.slice(r,o):r>=s?this.right.slice(r-s,o-s):this.left.slice(r,s).append(this.right.slice(0,o-s))},e.prototype.leafAppend=function(r){var o=this.right.leafAppend(r);if(o)return new e(this.left,o)},e.prototype.leafPrepend=function(r){var o=this.left.leafPrepend(r);if(o)return new e(o,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e}(X);const pd=500;class Pe{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let o,s;t&&(o=this.remapping(r,this.items.length),s=o.maps.length);let i=e.tr,l,a,c=[],u=[];return this.items.forEach((f,d)=>{if(!f.step){o||(o=this.remapping(r,d+1),s=o.maps.length),s--,u.push(f);return}if(o){u.push(new Fe(f.map));let p=f.step.map(o.slice(s)),h;p&&i.maybeStep(p).doc&&(h=i.mapping.maps[i.mapping.maps.length-1],c.push(new Fe(h,void 0,void 0,c.length+u.length))),s--,h&&o.appendMap(h,s)}else i.maybeStep(f.step);if(f.selection)return l=o?f.selection.map(o.slice(s)):f.selection,a=new Pe(this.items.slice(0,r).append(u.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:i,selection:l}}addTransform(e,t,r,o){let s=[],i=this.eventCount,l=this.items,a=!o&&l.length?l.get(l.length-1):null;for(let u=0;u<e.steps.length;u++){let f=e.steps[u].invert(e.docs[u]),d=new Fe(e.mapping.maps[u],f,t),p;(p=a&&a.merge(d))&&(d=p,u?s.pop():l=l.slice(0,l.length-1)),s.push(d),t&&(i++,t=void 0),o||(a=d)}let c=i-r.depth;return c>gd&&(l=md(l,c),i-=c),new Pe(l.append(s),i)}remapping(e,t){let r=new Dn;return this.items.forEach((o,s)=>{let i=o.mirrorOffset!=null&&s-o.mirrorOffset>=e?r.maps.length-o.mirrorOffset:void 0;r.appendMap(o.map,i)},e,t),r}addMaps(e){return this.eventCount==0?this:new Pe(this.items.append(e.map(t=>new Fe(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let r=[],o=Math.max(0,this.items.length-t),s=e.mapping,i=e.steps.length,l=this.eventCount;this.items.forEach(d=>{d.selection&&l--},o);let a=t;this.items.forEach(d=>{let p=s.getMirror(--a);if(p==null)return;i=Math.min(i,p);let h=s.maps[p];if(d.step){let b=e.steps[p].invert(e.docs[p]),g=d.selection&&d.selection.map(s.slice(a+1,p));g&&l++,r.push(new Fe(h,b,g))}else r.push(new Fe(h))},o);let c=[];for(let d=t;d<i;d++)c.push(new Fe(s.maps[d]));let u=this.items.slice(0,o).append(c).append(r),f=new Pe(u,l);return f.emptyItemCount()>pd&&(f=f.compress(this.items.length-r.length)),f}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),r=t.maps.length,o=[],s=0;return this.items.forEach((i,l)=>{if(l>=e)o.push(i),i.selection&&s++;else if(i.step){let a=i.step.map(t.slice(r)),c=a&&a.getMap();if(r--,c&&t.appendMap(c,r),a){let u=i.selection&&i.selection.map(t.slice(r));u&&s++;let f=new Fe(c.invert(),a,u),d,p=o.length-1;(d=o.length&&o[p].merge(f))?o[p]=d:o.push(f)}}else i.map&&r--},this.items.length,0),new Pe(X.from(o.reverse()),s)}}Pe.empty=new Pe(X.empty,0);function md(n,e){let t;return n.forEach((r,o)=>{if(r.selection&&e--==0)return t=o,!1}),n.slice(t)}class Fe{constructor(e,t,r,o){this.map=e,this.step=t,this.selection=r,this.mirrorOffset=o}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new Fe(t.getMap().invert(),t,this.selection)}}}class at{constructor(e,t,r,o,s){this.done=e,this.undone=t,this.prevRanges=r,this.prevTime=o,this.prevComposition=s}}const gd=20;function yd(n,e,t,r){let o=t.getMeta(ct),s;if(o)return o.historyState;t.getMeta(kd)&&(n=new at(n.done,n.undone,null,0,-1));let i=t.getMeta("appendedTransaction");if(t.steps.length==0)return n;if(i&&i.getMeta(ct))return i.getMeta(ct).redo?new at(n.done.addTransform(t,void 0,r,wr(e)),n.undone,dl(t.mapping.maps),n.prevTime,n.prevComposition):new at(n.done,n.undone.addTransform(t,void 0,r,wr(e)),null,n.prevTime,n.prevComposition);if(t.getMeta("addToHistory")!==!1&&!(i&&i.getMeta("addToHistory")===!1)){let l=t.getMeta("composition"),a=n.prevTime==0||!i&&n.prevComposition!=l&&(n.prevTime<(t.time||0)-r.newGroupDelay||!bd(t,n.prevRanges)),c=i?To(n.prevRanges,t.mapping):dl(t.mapping.maps);return new at(n.done.addTransform(t,a?e.selection.getBookmark():void 0,r,wr(e)),Pe.empty,c,t.time,l??n.prevComposition)}else return(s=t.getMeta("rebased"))?new at(n.done.rebased(t,s),n.undone.rebased(t,s),To(n.prevRanges,t.mapping),n.prevTime,n.prevComposition):new at(n.done.addMaps(t.mapping.maps),n.undone.addMaps(t.mapping.maps),To(n.prevRanges,t.mapping),n.prevTime,n.prevComposition)}function bd(n,e){if(!e)return!1;if(!n.docChanged)return!0;let t=!1;return n.mapping.maps[0].forEach((r,o)=>{for(let s=0;s<e.length;s+=2)r<=e[s+1]&&o>=e[s]&&(t=!0)}),t}function dl(n){let e=[];for(let t=n.length-1;t>=0&&e.length==0;t--)n[t].forEach((r,o,s,i)=>e.push(s,i));return e}function To(n,e){if(!n)return null;let t=[];for(let r=0;r<n.length;r+=2){let o=e.map(n[r],1),s=e.map(n[r+1],-1);o<=s&&t.push(o,s)}return t}function xd(n,e,t){let r=wr(e),o=ct.get(e).spec.config,s=(t?n.undone:n.done).popEvent(e,r);if(!s)return null;let i=s.selection.resolve(s.transform.doc),l=(t?n.done:n.undone).addTransform(s.transform,e.selection.getBookmark(),o,r),a=new at(t?l:s.remaining,t?s.remaining:l,null,0,-1);return s.transform.setSelection(i).setMeta(ct,{redo:t,historyState:a})}let vo=!1,hl=null;function wr(n){let e=n.plugins;if(hl!=e){vo=!1,hl=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){vo=!0;break}}return vo}const ct=new lt("history"),kd=new lt("closeHistory");function Sd(n={}){return n={depth:n.depth||100,newGroupDelay:n.newGroupDelay||500},new Be({key:ct,state:{init(){return new at(Pe.empty,Pe.empty,null,0,-1)},apply(e,t,r){return yd(t,r,e,n)}},config:n,props:{handleDOMEvents:{beforeinput(e,t){let r=t.inputType,o=r=="historyUndo"?Ao:r=="historyRedo"?Mr:null;return o?(t.preventDefault(),o(e.state,e.dispatch)):!1}}}})}function pl(n,e){return(t,r)=>{let o=ct.getState(t);if(!o||(n?o.undone:o.done).eventCount==0)return!1;if(r){let s=xd(o,t,n);s&&r(e?s.scrollIntoView():s)}return!0}}const Ao=pl(!1,!0),Mr=pl(!0,!0);function Po(n){let e=ct.getState(n);return e?e.done.eventCount:0}for(var ut={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},Nr={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Cd=typeof navigator<"u"&&/Mac/.test(navigator.platform),wd=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),te=0;te<10;te++)ut[48+te]=ut[96+te]=String(te);for(var te=1;te<=24;te++)ut[te+111]="F"+te;for(var te=65;te<=90;te++)ut[te]=String.fromCharCode(te+32),Nr[te]=String.fromCharCode(te);for(var Io in ut)Nr.hasOwnProperty(Io)||(Nr[Io]=ut[Io]);function Md(n){var e=Cd&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||wd&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?Nr:ut)[n.keyCode]||n.key||"Unidentified";return t=="Esc"&&(t="Escape"),t=="Del"&&(t="Delete"),t=="Left"&&(t="ArrowLeft"),t=="Up"&&(t="ArrowUp"),t=="Right"&&(t="ArrowRight"),t=="Down"&&(t="ArrowDown"),t}const Nd=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):!1;function Ed(n){let e=n.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");let r,o,s,i;for(let l=0;l<e.length-1;l++){let a=e[l];if(/^(cmd|meta|m)$/i.test(a))i=!0;else if(/^a(lt)?$/i.test(a))r=!0;else if(/^(c|ctrl|control)$/i.test(a))o=!0;else if(/^s(hift)?$/i.test(a))s=!0;else if(/^mod$/i.test(a))Nd?i=!0:o=!0;else throw new Error("Unrecognized modifier name: "+a)}return r&&(t="Alt-"+t),o&&(t="Ctrl-"+t),i&&(t="Meta-"+t),s&&(t="Shift-"+t),t}function Dd(n){let e=Object.create(null);for(let t in n)e[Ed(t)]=n[t];return e}function Vo(n,e,t=!0){return e.altKey&&(n="Alt-"+n),e.ctrlKey&&(n="Ctrl-"+n),e.metaKey&&(n="Meta-"+n),t&&e.shiftKey&&(n="Shift-"+n),n}function Ro(n){return new Be({props:{handleKeyDown:zo(n)}})}function zo(n){let e=Dd(n);return function(t,r){let o=Md(r),s,i=e[Vo(o,r)];if(i&&i(t.state,t.dispatch,t))return!0;if(o.length==1&&o!=" "){if(r.shiftKey){let l=e[Vo(o,r,!1)];if(l&&l(t.state,t.dispatch,t))return!0}if((r.shiftKey||r.altKey||r.metaKey||o.charCodeAt(0)>127)&&(s=ut[r.keyCode])&&s!=o){let l=e[Vo(s,r)];if(l&&l(t.state,t.dispatch,t))return!0}}return!1}}const ml=(n,e)=>n.selection.empty?!1:(e&&e(n.tr.deleteSelection().scrollIntoView()),!0);function Od(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("backward",n):t.parentOffset>0)?null:t}const Td=(n,e,t)=>{let r=Od(n,t);if(!r)return!1;let o=gl(r);if(!o){let i=r.blockRange(),l=i&&On(i);return l==null?!1:(e&&e(n.tr.lift(i,l).scrollIntoView()),!0)}let s=o.nodeBefore;if(kl(n,o,e,-1))return!0;if(r.parent.content.size==0&&(rn(s,"end")||D.isSelectable(s)))for(let i=r.depth;;i--){let l=Co(n.doc,r.before(i),r.after(i),N.empty);if(l&&l.slice.size<l.to-l.from){if(e){let a=n.tr.step(l);a.setSelection(rn(s,"end")?R.findFrom(a.doc.resolve(a.mapping.map(o.pos,-1)),-1):D.create(a.doc,o.pos-s.nodeSize)),e(a.scrollIntoView())}return!0}if(i==1||r.node(i-1).childCount>1)break}return s.isAtom&&o.depth==r.depth-1?(e&&e(n.tr.delete(o.pos-s.nodeSize,o.pos).scrollIntoView()),!0):!1};function rn(n,e,t=!1){for(let r=n;r;r=e=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(t&&r.childCount!=1)return!1}return!1}const vd=(n,e,t)=>{let{$head:r,empty:o}=n.selection,s=r;if(!o)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("backward",n):r.parentOffset>0)return!1;s=gl(r)}let i=s&&s.nodeBefore;return!i||!D.isSelectable(i)?!1:(e&&e(n.tr.setSelection(D.create(n.doc,s.pos-i.nodeSize)).scrollIntoView()),!0)};function gl(n){if(!n.parent.type.spec.isolating)for(let e=n.depth-1;e>=0;e--){if(n.index(e)>0)return n.doc.resolve(n.before(e+1));if(n.node(e).type.spec.isolating)break}return null}function Ad(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("forward",n):t.parentOffset<t.parent.content.size)?null:t}const Pd=(n,e,t)=>{let r=Ad(n,t);if(!r)return!1;let o=yl(r);if(!o)return!1;let s=o.nodeAfter;if(kl(n,o,e,1))return!0;if(r.parent.content.size==0&&(rn(s,"start")||D.isSelectable(s))){let i=Co(n.doc,r.before(),r.after(),N.empty);if(i&&i.slice.size<i.to-i.from){if(e){let l=n.tr.step(i);l.setSelection(rn(s,"start")?R.findFrom(l.doc.resolve(l.mapping.map(o.pos)),1):D.create(l.doc,l.mapping.map(o.pos))),e(l.scrollIntoView())}return!0}}return s.isAtom&&o.depth==r.depth-1?(e&&e(n.tr.delete(o.pos,o.pos+s.nodeSize).scrollIntoView()),!0):!1},Id=(n,e,t)=>{let{$head:r,empty:o}=n.selection,s=r;if(!o)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("forward",n):r.parentOffset<r.parent.content.size)return!1;s=yl(r)}let i=s&&s.nodeAfter;return!i||!D.isSelectable(i)?!1:(e&&e(n.tr.setSelection(D.create(n.doc,s.pos)).scrollIntoView()),!0)};function yl(n){if(!n.parent.type.spec.isolating)for(let e=n.depth-1;e>=0;e--){let t=n.node(e);if(n.index(e)+1<t.childCount)return n.doc.resolve(n.after(e+1));if(t.type.spec.isolating)break}return null}const bl=(n,e)=>{let t=n.selection,r=t instanceof D,o;if(r){if(t.node.isTextblock||!Zt(n.doc,t.from))return!1;o=t.from}else if(o=Gi(n.doc,t.from,-1),o==null)return!1;if(e){let s=n.tr.join(o);r&&s.setSelection(D.create(s.doc,o-n.doc.resolve(o).nodeBefore.nodeSize)),e(s.scrollIntoView())}return!0},Vd=(n,e)=>{let t=n.selection,r;if(t instanceof D){if(t.node.isTextblock||!Zt(n.doc,t.to))return!1;r=t.to}else if(r=Gi(n.doc,t.to,1),r==null)return!1;return e&&e(n.tr.join(r).scrollIntoView()),!0},$o=(n,e)=>{let{$from:t,$to:r}=n.selection,o=t.blockRange(r),s=o&&On(o);return s==null?!1:(e&&e(n.tr.lift(o,s).scrollIntoView()),!0)},Rd=(n,e)=>{let{$head:t,$anchor:r}=n.selection;return!t.parent.type.spec.code||!t.sameParent(r)?!1:(e&&e(n.tr.insertText(`
|
|
37
|
-
`).scrollIntoView()),!0)};function jo(n){for(let e=0;e<n.edgeCount;e++){let{type:t}=n.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}const xl=(n,e)=>{let{$head:t,$anchor:r}=n.selection;if(!t.parent.type.spec.code||!t.sameParent(r))return!1;let o=t.node(-1),s=t.indexAfter(-1),i=jo(o.contentMatchAt(s));if(!i||!o.canReplaceWith(s,s,i))return!1;if(e){let l=t.after(),a=n.tr.replaceWith(l,l,i.createAndFill());a.setSelection(R.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},zd=(n,e)=>{let t=n.selection,{$from:r,$to:o}=t;if(t instanceof ge||r.parent.inlineContent||o.parent.inlineContent)return!1;let s=jo(o.parent.contentMatchAt(o.indexAfter()));if(!s||!s.isTextblock)return!1;if(e){let i=(!r.parentOffset&&o.index()<o.parent.childCount?r:o).pos,l=n.tr.insert(i,s.createAndFill());l.setSelection(P.create(l.doc,i+1)),e(l.scrollIntoView())}return!0},$d=(n,e)=>{let{$cursor:t}=n.selection;if(!t||t.parent.content.size)return!1;if(t.depth>1&&t.after()!=t.end(-1)){let s=t.before();if(Qt(n.doc,s))return e&&e(n.tr.split(s).scrollIntoView()),!0}let r=t.blockRange(),o=r&&On(r);return o==null?!1:(e&&e(n.tr.lift(r,o).scrollIntoView()),!0)};function jd(n){return(e,t)=>{let{$from:r,$to:o}=e.selection;if(e.selection instanceof D&&e.selection.node.isBlock)return!r.parentOffset||!Qt(e.doc,r.pos)?!1:(t&&t(e.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let s=[],i,l,a=!1,c=!1;for(let p=r.depth;;p--)if(r.node(p).isBlock){a=r.end(p)==r.pos+(r.depth-p),c=r.start(p)==r.pos-(r.depth-p),l=jo(r.node(p-1).contentMatchAt(r.indexAfter(p-1))),s.unshift(a&&l?{type:l}:null),i=p;break}else{if(p==1)return!1;s.unshift(null)}let u=e.tr;(e.selection instanceof P||e.selection instanceof ge)&&u.deleteSelection();let f=u.mapping.map(r.pos),d=Qt(u.doc,f,s.length,s);if(d||(s[0]=l?{type:l}:null,d=Qt(u.doc,f,s.length,s)),!d)return!1;if(u.split(f,s.length,s),!a&&c&&r.node(i).type!=l){let p=u.mapping.map(r.before(i)),h=u.doc.resolve(p);l&&r.node(i-1).canReplaceWith(h.index(),h.index()+1,l)&&u.setNodeMarkup(u.mapping.map(r.before(i)),l)}return t&&t(u.scrollIntoView()),!0}}const Bd=jd(),Bo=(n,e)=>{let{$from:t,to:r}=n.selection,o,s=t.sharedDepth(r);return s==0?!1:(o=t.before(s),e&&e(n.tr.setSelection(D.create(n.doc,o))),!0)},Fd=(n,e)=>(e&&e(n.tr.setSelection(new ge(n.doc))),!0);function Ld(n,e,t){let r=e.nodeBefore,o=e.nodeAfter,s=e.index();return!r||!o||!r.type.compatibleContent(o.type)?!1:!r.content.size&&e.parent.canReplace(s-1,s)?(t&&t(n.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(s,s+1)||!(o.isTextblock||Zt(n.doc,e.pos))?!1:(t&&t(n.tr.join(e.pos).scrollIntoView()),!0)}function kl(n,e,t,r){let o=e.nodeBefore,s=e.nodeAfter,i,l,a=o.type.spec.isolating||s.type.spec.isolating;if(!a&&Ld(n,e,t))return!0;let c=!a&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(i=(l=o.contentMatchAt(o.childCount)).findWrapping(s.type))&&l.matchType(i[0]||s.type).validEnd){if(t){let p=e.pos+s.nodeSize,h=S.empty;for(let k=i.length-1;k>=0;k--)h=S.from(i[k].create(null,h));h=S.from(o.copy(h));let b=n.tr.step(new ee(e.pos-1,p,e.pos,p,new N(h,1,0),i.length,!0)),g=b.doc.resolve(p+2*i.length);g.nodeAfter&&g.nodeAfter.type==o.type&&Zt(b.doc,g.pos)&&b.join(g.pos),t(b.scrollIntoView())}return!0}let u=s.type.spec.isolating||r>0&&a?null:R.findFrom(e,1),f=u&&u.$from.blockRange(u.$to),d=f&&On(f);if(d!=null&&d>=e.depth)return t&&t(n.tr.lift(f,d).scrollIntoView()),!0;if(c&&rn(s,"start",!0)&&rn(o,"end")){let p=o,h=[];for(;h.push(p),!p.isTextblock;)p=p.lastChild;let b=s,g=1;for(;!b.isTextblock;b=b.firstChild)g++;if(p.canReplace(p.childCount,p.childCount,b.content)){if(t){let k=S.empty;for(let M=h.length-1;M>=0;M--)k=S.from(h[M].copy(k));let w=n.tr.step(new ee(e.pos-h.length,e.pos+s.nodeSize,e.pos+g,e.pos+s.nodeSize-g,new N(k,h.length,0),0,!0));t(w.scrollIntoView())}return!0}}return!1}function Sl(n){return function(e,t){let r=e.selection,o=n<0?r.$from:r.$to,s=o.depth;for(;o.node(s).isInline;){if(!s)return!1;s--}return o.node(s).isTextblock?(t&&t(e.tr.setSelection(P.create(e.doc,n<0?o.start(s):o.end(s)))),!0):!1}}const Wd=Sl(-1),_d=Sl(1);function Cl(n,e=null){return function(t,r){let{$from:o,$to:s}=t.selection,i=o.blockRange(s),l=i&&ko(i,n,e);return l?(r&&r(t.tr.wrap(i,l).scrollIntoView()),!0):!1}}function on(n,e=null){return function(t,r){let o=!1;for(let s=0;s<t.selection.ranges.length&&!o;s++){let{$from:{pos:i},$to:{pos:l}}=t.selection.ranges[s];t.doc.nodesBetween(i,l,(a,c)=>{if(o)return!1;if(!(!a.isTextblock||a.hasMarkup(n,e)))if(a.type==n)o=!0;else{let u=t.doc.resolve(c),f=u.index();o=u.parent.canReplaceWith(f,f+1,n)}})}if(!o)return!1;if(r){let s=t.tr;for(let i=0;i<t.selection.ranges.length;i++){let{$from:{pos:l},$to:{pos:a}}=t.selection.ranges[i];s.setBlockType(l,a,n,e)}r(s.scrollIntoView())}return!0}}function qd(n,e,t,r){for(let o=0;o<e.length;o++){let{$from:s,$to:i}=e[o],l=s.depth==0?n.inlineContent&&n.type.allowsMarkType(t):!1;if(n.nodesBetween(s.pos,i.pos,(a,c)=>{if(l)return!1;l=a.inlineContent&&a.type.allowsMarkType(t)}),l)return!0}return!1}function ke(n,e=null,t){return function(r,o){let{empty:s,$cursor:i,ranges:l}=r.selection;if(s&&!i||!qd(r.doc,l,n))return!1;if(o)if(i)n.isInSet(r.storedMarks||i.marks())?o(r.tr.removeStoredMark(n)):o(r.tr.addStoredMark(n.create(e)));else{let a,c=r.tr;a=!l.some(u=>r.doc.rangeHasMark(u.$from.pos,u.$to.pos,n));for(let u=0;u<l.length;u++){let{$from:f,$to:d}=l[u];if(!a)c.removeMark(f.pos,d.pos,n);else{let p=f.pos,h=d.pos,b=f.nodeAfter,g=d.nodeBefore,k=b&&b.isText?/^\s*/.exec(b.text)[0].length:0,w=g&&g.isText?/\s*$/.exec(g.text)[0].length:0;p+k<h&&(p+=k,h-=w),c.addMark(p,h,n.create(e))}}o(c.scrollIntoView())}return!0}}function Er(...n){return function(e,t,r){for(let o=0;o<n.length;o++)if(n[o](e,t,r))return!0;return!1}}let Fo=Er(ml,Td,vd),wl=Er(ml,Pd,Id);const Xe={Enter:Er(Rd,zd,$d,Bd),"Mod-Enter":xl,Backspace:Fo,"Mod-Backspace":Fo,"Shift-Backspace":Fo,Delete:wl,"Mod-Delete":wl,"Mod-a":Fd},Ml={"Ctrl-h":Xe.Backspace,"Alt-Backspace":Xe["Mod-Backspace"],"Ctrl-d":Xe.Delete,"Ctrl-Alt-Backspace":Xe["Mod-Delete"],"Alt-Delete":Xe["Mod-Delete"],"Alt-d":Xe["Mod-Delete"],"Ctrl-a":Wd,"Ctrl-e":_d};for(let n in Xe)Ml[n]=Xe[n];const Hd=(typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform?os.platform()=="darwin":!1)?Ml:Xe;function Kd(n={}){return new Be({view(e){return new Jd(e,n)}})}class Jd{constructor(e,t){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=t.width)!==null&&r!==void 0?r:1,this.color=t.color===!1?void 0:t.color||"black",this.class=t.class,this.handlers=["dragover","dragend","drop","dragleave"].map(o=>{let s=i=>{this[o](i)};return e.dom.addEventListener(o,s),{name:o,handler:s}})}destroy(){this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){this.cursorPos!=null&&t.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),t=!e.parent.inlineContent,r,o=this.editorView.dom,s=o.getBoundingClientRect(),i=s.width/o.offsetWidth,l=s.height/o.offsetHeight;if(t){let f=e.nodeBefore,d=e.nodeAfter;if(f||d){let p=this.editorView.nodeDOM(this.cursorPos-(f?f.nodeSize:0));if(p){let h=p.getBoundingClientRect(),b=f?h.bottom:h.top;f&&d&&(b=(b+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let g=this.width/2*l;r={left:h.left,right:h.right,top:b-g,bottom:b+g}}}}if(!r){let f=this.editorView.coordsAtPos(this.cursorPos),d=this.width/2*i;r={left:f.left-d,right:f.left+d,top:f.top,bottom:f.bottom}}let a=this.editorView.dom.offsetParent;this.element||(this.element=a.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",t),this.element.classList.toggle("prosemirror-dropcursor-inline",!t);let c,u;if(!a||a==document.body&&getComputedStyle(a).position=="static")c=-pageXOffset,u=-pageYOffset;else{let f=a.getBoundingClientRect(),d=f.width/a.offsetWidth,p=f.height/a.offsetHeight;c=f.left-a.scrollLeft*d,u=f.top-a.scrollTop*p}this.element.style.left=(r.left-c)/i+"px",this.element.style.top=(r.top-u)/l+"px",this.element.style.width=(r.right-r.left)/i+"px",this.element.style.height=(r.bottom-r.top)/l+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),o=r&&r.type.spec.disableDropCursor,s=typeof o=="function"?o(this.editorView,t,e):o;if(t&&!s){let i=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=So(this.editorView.state.doc,i,this.editorView.dragging.slice);l!=null&&(i=l)}this.setCursor(i),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}const ne=function(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e},In=function(n){let e=n.assignedSlot||n.parentNode;return e&&e.nodeType==11?e.host:e};let Lo=null;const Ue=function(n,e,t){let r=Lo||(Lo=document.createRange());return r.setEnd(n,t??n.nodeValue.length),r.setStart(n,e||0),r},Yd=function(){Lo=null},Vt=function(n,e,t,r){return t&&(Nl(n,e,t,r,-1)||Nl(n,e,t,r,1))},Gd=/^(img|br|input|textarea|hr)$/i;function Nl(n,e,t,r,o){for(;;){if(n==t&&e==r)return!0;if(e==(o<0?0:Me(n))){let s=n.parentNode;if(!s||s.nodeType!=1||Vn(n)||Gd.test(n.nodeName)||n.contentEditable=="false")return!1;e=ne(n)+(o<0?0:1),n=s}else if(n.nodeType==1){if(n=n.childNodes[e+(o<0?-1:0)],n.contentEditable=="false")return!1;e=o<0?Me(n):0}else return!1}}function Me(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Xd(n,e){for(;;){if(n.nodeType==3&&e)return n;if(n.nodeType==1&&e>0){if(n.contentEditable=="false")return null;n=n.childNodes[e-1],e=Me(n)}else if(n.parentNode&&!Vn(n))e=ne(n),n=n.parentNode;else return null}}function Ud(n,e){for(;;){if(n.nodeType==3&&e<n.nodeValue.length)return n;if(n.nodeType==1&&e<n.childNodes.length){if(n.contentEditable=="false")return null;n=n.childNodes[e],e=0}else if(n.parentNode&&!Vn(n))e=ne(n)+1,n=n.parentNode;else return null}}function Qd(n,e,t){for(let r=e==0,o=e==Me(n);r||o;){if(n==t)return!0;let s=ne(n);if(n=n.parentNode,!n)return!1;r=r&&s==0,o=o&&s==Me(n)}}function Vn(n){let e;for(let t=n;t&&!(e=t.pmViewDesc);t=t.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==n||e.contentDOM==n)}const Dr=function(n){return n.focusNode&&Vt(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)};function Rt(n,e){let t=document.createEvent("Event");return t.initEvent("keydown",!0,!0),t.keyCode=n,t.key=t.code=e,t}function Zd(n){let e=n.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function eh(n,e,t){if(n.caretPositionFromPoint)try{let r=n.caretPositionFromPoint(e,t);if(r)return{node:r.offsetNode,offset:Math.min(Me(r.offsetNode),r.offset)}}catch{}if(n.caretRangeFromPoint){let r=n.caretRangeFromPoint(e,t);if(r)return{node:r.startContainer,offset:Math.min(Me(r.startContainer),r.startOffset)}}}const Le=typeof navigator<"u"?navigator:null,El=typeof document<"u"?document:null,ft=Le&&Le.userAgent||"",Wo=/Edge\/(\d+)/.exec(ft),Dl=/MSIE \d/.exec(ft),_o=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(ft),ye=!!(Dl||_o||Wo),dt=Dl?document.documentMode:_o?+_o[1]:Wo?+Wo[1]:0,Ie=!ye&&/gecko\/(\d+)/i.test(ft);Ie&&+(/Firefox\/(\d+)/.exec(ft)||[0,0])[1];const qo=!ye&&/Chrome\/(\d+)/.exec(ft),ie=!!qo,Ol=qo?+qo[1]:0,ue=!ye&&!!Le&&/Apple Computer/.test(Le.vendor),sn=ue&&(/Mobile\/\w+/.test(ft)||!!Le&&Le.maxTouchPoints>2),Ne=sn||(Le?/Mac/.test(Le.platform):!1),th=Le?/Win/.test(Le.platform):!1,Qe=/Android \d/.test(ft),Rn=!!El&&"webkitFontSmoothing"in El.documentElement.style,nh=Rn?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function rh(n){let e=n.defaultView&&n.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:n.documentElement.clientWidth,top:0,bottom:n.documentElement.clientHeight}}function Ze(n,e){return typeof n=="number"?n:n[e]}function oh(n){let e=n.getBoundingClientRect(),t=e.width/n.offsetWidth||1,r=e.height/n.offsetHeight||1;return{left:e.left,right:e.left+n.clientWidth*t,top:e.top,bottom:e.top+n.clientHeight*r}}function Tl(n,e,t){let r=n.someProp("scrollThreshold")||0,o=n.someProp("scrollMargin")||5,s=n.dom.ownerDocument;for(let i=t||n.dom;i;i=In(i)){if(i.nodeType!=1)continue;let l=i,a=l==s.body,c=a?rh(s):oh(l),u=0,f=0;if(e.top<c.top+Ze(r,"top")?f=-(c.top-e.top+Ze(o,"top")):e.bottom>c.bottom-Ze(r,"bottom")&&(f=e.bottom-e.top>c.bottom-c.top?e.top+Ze(o,"top")-c.top:e.bottom-c.bottom+Ze(o,"bottom")),e.left<c.left+Ze(r,"left")?u=-(c.left-e.left+Ze(o,"left")):e.right>c.right-Ze(r,"right")&&(u=e.right-c.right+Ze(o,"right")),u||f)if(a)s.defaultView.scrollBy(u,f);else{let d=l.scrollLeft,p=l.scrollTop;f&&(l.scrollTop+=f),u&&(l.scrollLeft+=u);let h=l.scrollLeft-d,b=l.scrollTop-p;e={left:e.left-h,top:e.top-b,right:e.right-h,bottom:e.bottom-b}}if(a||/^(fixed|sticky)$/.test(getComputedStyle(i).position))break}}function sh(n){let e=n.dom.getBoundingClientRect(),t=Math.max(0,e.top),r,o;for(let s=(e.left+e.right)/2,i=t+1;i<Math.min(innerHeight,e.bottom);i+=5){let l=n.root.elementFromPoint(s,i);if(!l||l==n.dom||!n.dom.contains(l))continue;let a=l.getBoundingClientRect();if(a.top>=t-20){r=l,o=a.top;break}}return{refDOM:r,refTop:o,stack:vl(n.dom)}}function vl(n){let e=[],t=n.ownerDocument;for(let r=n;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),n!=t);r=In(r));return e}function ih({refDOM:n,refTop:e,stack:t}){let r=n?n.getBoundingClientRect().top:0;Al(t,r==0?0:r-e)}function Al(n,e){for(let t=0;t<n.length;t++){let{dom:r,top:o,left:s}=n[t];r.scrollTop!=o+e&&(r.scrollTop=o+e),r.scrollLeft!=s&&(r.scrollLeft=s)}}let ln=null;function lh(n){if(n.setActive)return n.setActive();if(ln)return n.focus(ln);let e=vl(n);n.focus(ln==null?{get preventScroll(){return ln={preventScroll:!0},!0}}:void 0),ln||(ln=!1,Al(e,0))}function Pl(n,e){let t,r=2e8,o,s=0,i=e.top,l=e.top,a,c;for(let u=n.firstChild,f=0;u;u=u.nextSibling,f++){let d;if(u.nodeType==1)d=u.getClientRects();else if(u.nodeType==3)d=Ue(u).getClientRects();else continue;for(let p=0;p<d.length;p++){let h=d[p];if(h.top<=i&&h.bottom>=l){i=Math.max(h.bottom,i),l=Math.min(h.top,l);let b=h.left>e.left?h.left-e.left:h.right<e.left?e.left-h.right:0;if(b<r){t=u,r=b,o=b&&t.nodeType==3?{left:h.right<e.left?h.right:h.left,top:e.top}:e,u.nodeType==1&&b&&(s=f+(e.left>=(h.left+h.right)/2?1:0));continue}}else h.top>e.top&&!a&&h.left<=e.left&&h.right>=e.left&&(a=u,c={left:Math.max(h.left,Math.min(h.right,e.left)),top:h.top});!t&&(e.left>=h.right&&e.top>=h.top||e.left>=h.left&&e.top>=h.bottom)&&(s=f+1)}}return!t&&a&&(t=a,o=c,r=0),t&&t.nodeType==3?ah(t,o):!t||r&&t.nodeType==1?{node:n,offset:s}:Pl(t,o)}function ah(n,e){let t=n.nodeValue.length,r=document.createRange();for(let o=0;o<t;o++){r.setEnd(n,o+1),r.setStart(n,o);let s=ht(r,1);if(s.top!=s.bottom&&Ho(e,s))return{node:n,offset:o+(e.left>=(s.left+s.right)/2?1:0)}}return{node:n,offset:0}}function Ho(n,e){return n.left>=e.left-1&&n.left<=e.right+1&&n.top>=e.top-1&&n.top<=e.bottom+1}function ch(n,e){let t=n.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left<n.getBoundingClientRect().left?t:n}function uh(n,e,t){let{node:r,offset:o}=Pl(e,t),s=-1;if(r.nodeType==1&&!r.firstChild){let i=r.getBoundingClientRect();s=i.left!=i.right&&t.left>(i.left+i.right)/2?1:-1}return n.docView.posFromDOM(r,o,s)}function fh(n,e,t,r){let o=-1;for(let s=e,i=!1;s!=n.dom;){let l=n.docView.nearestDesc(s,!0),a;if(!l)return null;if(l.dom.nodeType==1&&(l.node.isBlock&&l.parent||!l.contentDOM)&&((a=l.dom.getBoundingClientRect()).width||a.height)&&(l.node.isBlock&&l.parent&&(!i&&a.left>r.left||a.top>r.top?o=l.posBefore:(!i&&a.right<r.left||a.bottom<r.top)&&(o=l.posAfter),i=!0),!l.contentDOM&&o<0&&!l.node.isText))return(l.node.isBlock?r.top<(a.top+a.bottom)/2:r.left<(a.left+a.right)/2)?l.posBefore:l.posAfter;s=l.dom.parentNode}return o>-1?o:n.docView.posFromDOM(e,t,-1)}function Il(n,e,t){let r=n.childNodes.length;if(r&&t.top<t.bottom)for(let o=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-t.top)/(t.bottom-t.top))-2)),s=o;;){let i=n.childNodes[s];if(i.nodeType==1){let l=i.getClientRects();for(let a=0;a<l.length;a++){let c=l[a];if(Ho(e,c))return Il(i,e,c)}}if((s=(s+1)%r)==o)break}return n}function dh(n,e){let t=n.dom.ownerDocument,r,o=0,s=eh(t,e.left,e.top);s&&({node:r,offset:o}=s);let i=(n.root.elementFromPoint?n.root:t).elementFromPoint(e.left,e.top),l;if(!i||!n.dom.contains(i.nodeType!=1?i.parentNode:i)){let c=n.dom.getBoundingClientRect();if(!Ho(e,c)||(i=Il(n.dom,e,c),!i))return null}if(ue)for(let c=i;r&&c;c=In(c))c.draggable&&(r=void 0);if(i=ch(i,e),r){if(Ie&&r.nodeType==1&&(o=Math.min(o,r.childNodes.length),o<r.childNodes.length)){let u=r.childNodes[o],f;u.nodeName=="IMG"&&(f=u.getBoundingClientRect()).right<=e.left&&f.bottom>e.top&&o++}let c;Rn&&o&&r.nodeType==1&&(c=r.childNodes[o-1]).nodeType==1&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=e.top&&o--,r==n.dom&&o==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?l=n.state.doc.content.size:(o==0||r.nodeType!=1||r.childNodes[o-1].nodeName!="BR")&&(l=fh(n,r,o,e))}l==null&&(l=uh(n,i,e));let a=n.docView.nearestDesc(i,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function Vl(n){return n.top<n.bottom||n.left<n.right}function ht(n,e){let t=n.getClientRects();if(t.length){let r=t[e<0?0:t.length-1];if(Vl(r))return r}return Array.prototype.find.call(t,Vl)||n.getBoundingClientRect()}const hh=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function Rl(n,e,t){let{node:r,offset:o,atom:s}=n.docView.domFromPos(e,t<0?-1:1),i=Rn||Ie;if(r.nodeType==3)if(i&&(hh.test(r.nodeValue)||(t<0?!o:o==r.nodeValue.length))){let a=ht(Ue(r,o,o),t);if(Ie&&o&&/\s/.test(r.nodeValue[o-1])&&o<r.nodeValue.length){let c=ht(Ue(r,o-1,o-1),-1);if(c.top==a.top){let u=ht(Ue(r,o,o+1),-1);if(u.top!=a.top)return zn(u,u.left<c.left)}}return a}else{let a=o,c=o,u=t<0?1:-1;return t<0&&!o?(c++,u=-1):t>=0&&o==r.nodeValue.length?(a--,u=1):t<0?a--:c++,zn(ht(Ue(r,a,c),u),u<0)}if(!n.state.doc.resolve(e-(s||0)).parent.inlineContent){if(s==null&&o&&(t<0||o==Me(r))){let a=r.childNodes[o-1];if(a.nodeType==1)return Ko(a.getBoundingClientRect(),!1)}if(s==null&&o<Me(r)){let a=r.childNodes[o];if(a.nodeType==1)return Ko(a.getBoundingClientRect(),!0)}return Ko(r.getBoundingClientRect(),t>=0)}if(s==null&&o&&(t<0||o==Me(r))){let a=r.childNodes[o-1],c=a.nodeType==3?Ue(a,Me(a)-(i?0:1)):a.nodeType==1&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(c)return zn(ht(c,1),!1)}if(s==null&&o<Me(r)){let a=r.childNodes[o];for(;a.pmViewDesc&&a.pmViewDesc.ignoreForCoords;)a=a.nextSibling;let c=a?a.nodeType==3?Ue(a,0,i?0:1):a.nodeType==1?a:null:null;if(c)return zn(ht(c,-1),!0)}return zn(ht(r.nodeType==3?Ue(r):r,-t),t>=0)}function zn(n,e){if(n.width==0)return n;let t=e?n.left:n.right;return{top:n.top,bottom:n.bottom,left:t,right:t}}function Ko(n,e){if(n.height==0)return n;let t=e?n.top:n.bottom;return{top:t,bottom:t,left:n.left,right:n.right}}function zl(n,e,t){let r=n.state,o=n.root.activeElement;r!=e&&n.updateState(e),o!=n.dom&&n.focus();try{return t()}finally{r!=e&&n.updateState(r),o!=n.dom&&o&&o.focus()}}function ph(n,e,t){let r=e.selection,o=t=="up"?r.$from:r.$to;return zl(n,e,()=>{let{node:s}=n.docView.domFromPos(o.pos,t=="up"?-1:1);for(;;){let l=n.docView.nearestDesc(s,!0);if(!l)break;if(l.node.isBlock){s=l.contentDOM||l.dom;break}s=l.dom.parentNode}let i=Rl(n,o.pos,1);for(let l=s.firstChild;l;l=l.nextSibling){let a;if(l.nodeType==1)a=l.getClientRects();else if(l.nodeType==3)a=Ue(l,0,l.nodeValue.length).getClientRects();else continue;for(let c=0;c<a.length;c++){let u=a[c];if(u.bottom>u.top+1&&(t=="up"?i.top-u.top>(u.bottom-i.top)*2:u.bottom-i.bottom>(i.bottom-u.top)*2))return!1}}return!0})}const mh=/[\u0590-\u08ac]/;function gh(n,e,t){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let o=r.parentOffset,s=!o,i=o==r.parent.content.size,l=n.domSelection();return l?!mh.test(r.parent.textContent)||!l.modify?t=="left"||t=="backward"?s:i:zl(n,e,()=>{let{focusNode:a,focusOffset:c,anchorNode:u,anchorOffset:f}=n.domSelectionRange(),d=l.caretBidiLevel;l.modify("move",t,"character");let p=r.depth?n.docView.domAfterPos(r.before()):n.dom,{focusNode:h,focusOffset:b}=n.domSelectionRange(),g=h&&!p.contains(h.nodeType==1?h:h.parentNode)||a==h&&c==b;try{l.collapse(u,f),a&&(a!=u||c!=f)&&l.extend&&l.extend(a,c)}catch{}return d!=null&&(l.caretBidiLevel=d),g}):r.pos==r.start()||r.pos==r.end()}let $l=null,jl=null,Bl=!1;function yh(n,e,t){return $l==e&&jl==t?Bl:($l=e,jl=t,Bl=t=="up"||t=="down"?ph(n,e,t):gh(n,e,t))}const Ee=0,Fl=1,zt=2,We=3;let $n=class{constructor(e,t,r,o){this.parent=e,this.children=t,this.dom=r,this.contentDOM=o,this.dirty=Ee,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,r){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;t<this.children.length;t++)e+=this.children[t].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let t=0,r=this.posAtStart;;t++){let o=this.children[t];if(o==e)return r;r+=o.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,t,r){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(r<0){let s,i;if(e==this.contentDOM)s=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;s=e.previousSibling}for(;s&&!((i=s.pmViewDesc)&&i.parent==this);)s=s.previousSibling;return s?this.posBeforeChild(i)+i.size:this.posAtStart}else{let s,i;if(e==this.contentDOM)s=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;s=e.nextSibling}for(;s&&!((i=s.pmViewDesc)&&i.parent==this);)s=s.nextSibling;return s?this.posBeforeChild(i):this.posAtEnd}let o;if(e==this.dom&&this.contentDOM)o=t>ne(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))o=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(t==0)for(let s=e;;s=s.parentNode){if(s==this.dom){o=!1;break}if(s.previousSibling)break}if(o==null&&t==e.childNodes.length)for(let s=e;;s=s.parentNode){if(s==this.dom){o=!0;break}if(s.nextSibling)break}}return o??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let r=!0,o=e;o;o=o.parentNode){let s=this.getDesc(o),i;if(s&&(!t||s.node))if(r&&(i=s.nodeDOM)&&!(i.nodeType==1?i.contains(e.nodeType==1?e:e.parentNode):i==e))r=!1;else return s}}getDesc(e){let t=e.pmViewDesc;for(let r=t;r;r=r.parent)if(r==this)return t}posFromDOM(e,t,r){for(let o=e;o;o=o.parentNode){let s=this.getDesc(o);if(s)return s.localPosFromDOM(e,t,r)}return-1}descAt(e){for(let t=0,r=0;t<this.children.length;t++){let o=this.children[t],s=r+o.size;if(r==e&&s!=r){for(;!o.border&&o.children.length;)o=o.children[0];return o}if(e<s)return o.descAt(e-r-o.border);r=s}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let r=0,o=0;for(let s=0;r<this.children.length;r++){let i=this.children[r],l=s+i.size;if(l>e||i instanceof ql){o=e-s;break}s=l}if(o)return this.children[r].domFromPos(o-this.children[r].border,t);for(let s;r&&!(s=this.children[r-1]).size&&s instanceof Ll&&s.side>=0;r--);if(t<=0){let s,i=!0;for(;s=r?this.children[r-1]:null,!(!s||s.dom.parentNode==this.contentDOM);r--,i=!1);return s&&t&&i&&!s.border&&!s.domAtom?s.domFromPos(s.size,t):{node:this.contentDOM,offset:s?ne(s.dom)+1:0}}else{let s,i=!0;for(;s=r<this.children.length?this.children[r]:null,!(!s||s.dom.parentNode==this.contentDOM);r++,i=!1);return s&&i&&!s.border&&!s.domAtom?s.domFromPos(0,t):{node:this.contentDOM,offset:s?ne(s.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,r=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let o=-1,s=-1;for(let i=r,l=0;;l++){let a=this.children[l],c=i+a.size;if(o==-1&&e<=c){let u=i+a.border;if(e>=u&&t<=c-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,t,u);e=i;for(let f=l;f>0;f--){let d=this.children[f-1];if(d.size&&d.dom.parentNode==this.contentDOM&&!d.emptyChildAt(1)){o=ne(d.dom)+1;break}e-=d.size}o==-1&&(o=0)}if(o>-1&&(c>t||l==this.children.length-1)){t=c;for(let u=l+1;u<this.children.length;u++){let f=this.children[u];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(-1)){s=ne(f.dom);break}t+=f.size}s==-1&&(s=this.contentDOM.childNodes.length);break}i=c}return{node:this.contentDOM,from:e,to:t,fromOffset:o,toOffset:s}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let t=this.children[e<0?0:this.children.length-1];return t.size==0||t.emptyChildAt(e)}domAfterPos(e){let{node:t,offset:r}=this.domFromPos(e,0);if(t.nodeType!=1||r==t.childNodes.length)throw new RangeError("No node after pos "+e);return t.childNodes[r]}setSelection(e,t,r,o=!1){let s=Math.min(e,t),i=Math.max(e,t);for(let p=0,h=0;p<this.children.length;p++){let b=this.children[p],g=h+b.size;if(s>h&&i<g)return b.setSelection(e-h-b.border,t-h-b.border,r,o);h=g}let l=this.domFromPos(e,e?-1:1),a=t==e?l:this.domFromPos(t,t?-1:1),c=r.root.getSelection(),u=r.domSelectionRange(),f=!1;if((Ie||ue)&&e==t){let{node:p,offset:h}=l;if(p.nodeType==3){if(f=!!(h&&p.nodeValue[h-1]==`
|
|
38
|
-
`),f&&h==p.nodeValue.length)for(let b=p,g;b;b=b.parentNode){if(g=b.nextSibling){g.nodeName=="BR"&&(l=a={node:g.parentNode,offset:ne(g)+1});break}let k=b.pmViewDesc;if(k&&k.node&&k.node.isBlock)break}}else{let b=p.childNodes[h-1];f=b&&(b.nodeName=="BR"||b.contentEditable=="false")}}if(Ie&&u.focusNode&&u.focusNode!=a.node&&u.focusNode.nodeType==1){let p=u.focusNode.childNodes[u.focusOffset];p&&p.contentEditable=="false"&&(o=!0)}if(!(o||f&&ue)&&Vt(l.node,l.offset,u.anchorNode,u.anchorOffset)&&Vt(a.node,a.offset,u.focusNode,u.focusOffset))return;let d=!1;if((c.extend||e==t)&&!f){c.collapse(l.node,l.offset);try{e!=t&&c.extend(a.node,a.offset),d=!0}catch{}}if(!d){if(e>t){let h=l;l=a,a=h}let p=document.createRange();p.setEnd(a.node,a.offset),p.setStart(l.node,l.offset),c.removeAllRanges(),c.addRange(p)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let r=0,o=0;o<this.children.length;o++){let s=this.children[o],i=r+s.size;if(r==i?e<=i&&t>=r:e<i&&t>r){let l=r+s.border,a=i-s.border;if(e>=l&&t<=a){this.dirty=e==r||t==i?zt:Fl,e==l&&t==a&&(s.contentLost||s.dom.parentNode!=this.contentDOM)?s.dirty=We:s.markDirty(e-l,t-l);return}else s.dirty=s.dom==s.contentDOM&&s.dom.parentNode==this.contentDOM&&!s.children.length?zt:We}r=i}this.dirty=zt}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let r=e==1?zt:Fl;t.dirty<r&&(t.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}isText(e){return!1}},Ll=class extends $n{constructor(e,t,r,o){let s,i=t.type.toDOM;if(typeof i=="function"&&(i=i(r,()=>{if(!s)return o;if(s.parent)return s.parent.posBeforeChild(s)})),!t.type.spec.raw){if(i.nodeType!=1){let l=document.createElement("span");l.appendChild(i),i=l}i.contentEditable="false",i.classList.add("ProseMirror-widget")}super(e,[],i,null),this.widget=t,this.widget=t,s=this}matchesWidget(e){return this.dirty==Ee&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return t?t(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get side(){return this.widget.type.side}},bh=class extends $n{constructor(e,t,r,o){super(e,[],t,null),this.textDOM=r,this.text=o}get size(){return this.text.length}localPosFromDOM(e,t){return e!=this.textDOM?this.posAtStart+(t?this.size:0):this.posAtStart+t}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}},Or=class li extends $n{constructor(e,t,r,o,s){super(e,[],r,o),this.mark=t,this.spec=s}static create(e,t,r,o){let s=o.nodeViews[t.type.name],i=s&&s(t,o,r);return(!i||!i.dom)&&(i=$e.renderSpec(document,t.type.spec.toDOM(t,r),null,t.attrs)),new li(e,t,i.dom,i.contentDOM||i.dom,i)}parseRule(){return this.dirty&We||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=We&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=Ee){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=Ee}}slice(e,t,r){let o=li.create(this.parent,this.mark,!0,r),s=this.children,i=this.size;t<i&&(s=Yo(s,t,i,r)),e>0&&(s=Yo(s,0,e,r));for(let l=0;l<s.length;l++)s[l].parent=o;return o.children=s,o}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}},an=class ff extends $n{constructor(e,t,r,o,s,i,l,a,c){super(e,[],s,i),this.node=t,this.outerDeco=r,this.innerDeco=o,this.nodeDOM=l}static create(e,t,r,o,s,i){let l=s.nodeViews[t.type.name],a,c=l&&l(t,s,()=>{if(!a)return i;if(a.parent)return a.parent.posBeforeChild(a)},r,o),u=c&&c.dom,f=c&&c.contentDOM;if(t.isText){if(!u)u=document.createTextNode(t.text);else if(u.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else u||({dom:u,contentDOM:f}=$e.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs));!f&&!t.isText&&u.nodeName!="BR"&&(u.hasAttribute("contenteditable")||(u.contentEditable="false"),t.type.spec.draggable&&(u.draggable=!0));let d=u;return u=Jl(u,r,t),c?a=new xh(e,t,r,o,u,f||null,d,c,s,i+1):t.isText?new _l(e,t,r,o,u,d,s):new ff(e,t,r,o,u,f||null,d,s,i+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(e.preserveWhitespace="full"),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let t=this.children.length-1;t>=0;t--){let r=this.children[t];if(this.dom.contains(r.dom.parentNode)){e.contentElement=r.dom.parentNode;break}}e.contentElement||(e.getContent=()=>S.empty)}return e}matchesNode(e,t,r){return this.dirty==Ee&&e.eq(this.node)&&Tr(t,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let r=this.node.inlineContent,o=t,s=e.composing?this.localCompositionInfo(e,t):null,i=s&&s.pos>-1?s:null,l=s&&s.pos<0,a=new Sh(this,i&&i.node,e);Mh(this.node,this.innerDeco,(c,u,f)=>{c.spec.marks?a.syncToMarks(c.spec.marks,r,e):c.type.side>=0&&!f&&a.syncToMarks(u==this.node.childCount?F.none:this.node.child(u).marks,r,e),a.placeWidget(c,e,o)},(c,u,f,d)=>{a.syncToMarks(c.marks,r,e);let p;a.findNodeMatch(c,u,f,d)||l&&e.state.selection.from>o&&e.state.selection.to<o+c.nodeSize&&(p=a.findIndexWithChild(s.node))>-1&&a.updateNodeAt(c,u,f,p,e)||a.updateNextNode(c,u,f,e,d,o)||a.addNode(c,u,f,e,o),o+=c.nodeSize}),a.syncToMarks([],r,e),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==zt)&&(i&&this.protectLocalComposition(e,i),Hl(this.contentDOM,this.children,e),sn&&Nh(this.dom))}localCompositionInfo(e,t){let{from:r,to:o}=e.state.selection;if(!(e.state.selection instanceof P)||r<t||o>t+this.node.content.size)return null;let s=e.input.compositionNode;if(!s||!this.dom.contains(s.parentNode))return null;if(this.node.inlineContent){let i=s.nodeValue,l=Eh(this.node.content,i,r-t,o-t);return l<0?null:{node:s,pos:l,text:i}}else return{node:s,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:r,text:o}){if(this.getDesc(t))return;let s=t;for(;s.parentNode!=this.contentDOM;s=s.parentNode){for(;s.previousSibling;)s.parentNode.removeChild(s.previousSibling);for(;s.nextSibling;)s.parentNode.removeChild(s.nextSibling);s.pmViewDesc&&(s.pmViewDesc=void 0)}let i=new bh(this,s,t,o);e.input.compositionNodes.push(i),this.children=Yo(this.children,r,r+o.length,e,i)}update(e,t,r,o){return this.dirty==We||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,r,o),!0)}updateInner(e,t,r,o){this.updateOuterDeco(t),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(o,this.posAtStart),this.dirty=Ee}updateOuterDeco(e){if(Tr(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=Kl(this.dom,this.nodeDOM,Jo(this.outerDeco,this.node,t),Jo(e,this.node,t)),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 Wl(n,e,t,r,o){Jl(r,e,n);let s=new an(void 0,n,e,t,r,r,r,o,0);return s.contentDOM&&s.updateChildren(o,0),s}let _l=class df extends an{constructor(e,t,r,o,s,i,l){super(e,t,r,o,s,null,i,l,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,r,o){return this.dirty==We||this.dirty!=Ee&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=Ee||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,o.trackWrites==this.nodeDOM&&(o.trackWrites=null)),this.node=e,this.dirty=Ee,!0)}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,r){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,t,r){let o=this.node.cut(e,t),s=document.createTextNode(o.text);return new df(this.parent,o,this.outerDeco,this.innerDeco,s,s,r)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=We)}get domAtom(){return!1}isText(e){return this.node.text==e}},ql=class extends $n{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==Ee&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}};class xh extends an{constructor(e,t,r,o,s,i,l,a,c,u){super(e,t,r,o,s,i,l,c,u),this.spec=a}update(e,t,r,o){if(this.dirty==We)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let s=this.spec.update(e,t,r);return s&&this.updateInner(e,t,r,o),s}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,t,r,o)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,r,o){this.spec.setSelection?this.spec.setSelection(e,t,r.root):super.setSelection(e,t,r,o)}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 Hl(n,e,t){let r=n.firstChild,o=!1;for(let s=0;s<e.length;s++){let i=e[s],l=i.dom;if(l.parentNode==n){for(;l!=r;)r=Yl(r),o=!0;r=r.nextSibling}else o=!0,n.insertBefore(l,r);if(i instanceof Or){let a=r?r.previousSibling:n.lastChild;Hl(i.contentDOM,i.children,t),r=a?a.nextSibling:n.firstChild}}for(;r;)r=Yl(r),o=!0;o&&t.trackWrites==n&&(t.trackWrites=null)}const jn=function(n){n&&(this.nodeName=n)};jn.prototype=Object.create(null);const $t=[new jn];function Jo(n,e,t){if(n.length==0)return $t;let r=t?$t[0]:new jn,o=[r];for(let s=0;s<n.length;s++){let i=n[s].type.attrs;if(i){i.nodeName&&o.push(r=new jn(i.nodeName));for(let l in i){let a=i[l];a!=null&&(t&&o.length==1&&o.push(r=new jn(e.isInline?"span":"div")),l=="class"?r.class=(r.class?r.class+" ":"")+a:l=="style"?r.style=(r.style?r.style+";":"")+a:l!="nodeName"&&(r[l]=a))}}}return o}function Kl(n,e,t,r){if(t==$t&&r==$t)return e;let o=e;for(let s=0;s<r.length;s++){let i=r[s],l=t[s];if(s){let a;l&&l.nodeName==i.nodeName&&o!=n&&(a=o.parentNode)&&a.nodeName.toLowerCase()==i.nodeName||(a=document.createElement(i.nodeName),a.pmIsDeco=!0,a.appendChild(o),l=$t[0]),o=a}kh(o,l||$t[0],i)}return o}function kh(n,e,t){for(let r in e)r!="class"&&r!="style"&&r!="nodeName"&&!(r in t)&&n.removeAttribute(r);for(let r in t)r!="class"&&r!="style"&&r!="nodeName"&&t[r]!=e[r]&&n.setAttribute(r,t[r]);if(e.class!=t.class){let r=e.class?e.class.split(" ").filter(Boolean):[],o=t.class?t.class.split(" ").filter(Boolean):[];for(let s=0;s<r.length;s++)o.indexOf(r[s])==-1&&n.classList.remove(r[s]);for(let s=0;s<o.length;s++)r.indexOf(o[s])==-1&&n.classList.add(o[s]);n.classList.length==0&&n.removeAttribute("class")}if(e.style!=t.style){if(e.style){let r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,o;for(;o=r.exec(e.style);)n.style.removeProperty(o[1])}t.style&&(n.style.cssText+=t.style)}}function Jl(n,e,t){return Kl(n,n,$t,Jo(e,t,n.nodeType!=1))}function Tr(n,e){if(n.length!=e.length)return!1;for(let t=0;t<n.length;t++)if(!n[t].type.eq(e[t].type))return!1;return!0}function Yl(n){let e=n.nextSibling;return n.parentNode.removeChild(n),e}class Sh{constructor(e,t,r){this.lock=t,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=Ch(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let r=e;r<t;r++)this.top.children[r].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,r){let o=0,s=this.stack.length>>1,i=Math.min(s,e.length);for(;o<i&&(o==s-1?this.top:this.stack[o+1<<1]).matchesMark(e[o])&&e[o].type.spec.spanning!==!1;)o++;for(;o<s;)this.destroyRest(),this.top.dirty=Ee,this.index=this.stack.pop(),this.top=this.stack.pop(),s--;for(;s<e.length;){this.stack.push(this.top,this.index+1);let l=-1;for(let a=this.index;a<Math.min(this.index+3,this.top.children.length);a++){let c=this.top.children[a];if(c.matchesMark(e[s])&&!this.isLocked(c.dom)){l=a;break}}if(l>-1)l>this.index&&(this.changed=!0,this.destroyBetween(this.index,l)),this.top=this.top.children[this.index];else{let a=Or.create(this.top,e[s],t,r);this.top.children.splice(this.index,0,a),this.top=a,this.changed=!0}this.index=0,s++}}findNodeMatch(e,t,r,o){let s=-1,i;if(o>=this.preMatch.index&&(i=this.preMatch.matches[o-this.preMatch.index]).parent==this.top&&i.matchesNode(e,t,r))s=this.top.children.indexOf(i,this.index);else for(let l=this.index,a=Math.min(this.top.children.length,l+5);l<a;l++){let c=this.top.children[l];if(c.matchesNode(e,t,r)&&!this.preMatch.matched.has(c)){s=l;break}}return s<0?!1:(this.destroyBetween(this.index,s),this.index++,!0)}updateNodeAt(e,t,r,o,s){let i=this.top.children[o];return i.dirty==We&&i.dom==i.contentDOM&&(i.dirty=zt),i.update(e,t,r,s)?(this.destroyBetween(this.index,o),this.index++,!0):!1}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){let r=e.pmViewDesc;if(r){for(let o=this.index;o<this.top.children.length;o++)if(this.top.children[o]==r)return o}return-1}e=t}}updateNextNode(e,t,r,o,s,i){for(let l=this.index;l<this.top.children.length;l++){let a=this.top.children[l];if(a instanceof an){let c=this.preMatch.matched.get(a);if(c!=null&&c!=s)return!1;let u=a.dom,f,d=this.isLocked(u)&&!(e.isText&&a.node&&a.node.isText&&a.nodeDOM.nodeValue==e.text&&a.dirty!=We&&Tr(t,a.outerDeco));if(!d&&a.update(e,t,r,o))return this.destroyBetween(this.index,l),a.dom!=u&&(this.changed=!0),this.index++,!0;if(!d&&(f=this.recreateWrapper(a,e,t,r,o,i)))return this.destroyBetween(this.index,l),this.top.children[this.index]=f,f.contentDOM&&(f.dirty=zt,f.updateChildren(o,i+1),f.dirty=Ee),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,r,o,s,i){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!Tr(r,e.outerDeco)||!o.eq(e.innerDeco))return null;let l=an.create(this.top,t,r,o,s,i);if(l.contentDOM){l.children=e.children,e.children=[];for(let a of l.children)a.parent=l}return e.destroy(),l}addNode(e,t,r,o,s){let i=an.create(this.top,e,t,r,o,s);i.contentDOM&&i.updateChildren(o,s+1),this.top.children.splice(this.index++,0,i),this.changed=!0}placeWidget(e,t,r){let o=this.index<this.top.children.length?this.top.children[this.index]:null;if(o&&o.matchesWidget(e)&&(e==o.widget||!o.widget.type.toDOM.parentNode))this.index++;else{let s=new Ll(this.top,e,t,r);this.top.children.splice(this.index++,0,s),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof Or;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof _l)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((ue||ie)&&e&&e.dom.contentEditable=="false"&&this.addHackNode("IMG",t),this.addHackNode("BR",this.top))}addHackNode(e,t){if(t==this.top&&this.index<t.children.length&&t.children[this.index].matchesHack(e))this.index++;else{let r=document.createElement(e);e=="IMG"&&(r.className="ProseMirror-separator",r.alt=""),e=="BR"&&(r.className="ProseMirror-trailingBreak");let o=new ql(this.top,[],r,null);t!=this.top?t.children.push(o):t.children.splice(this.index++,0,o),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||e.nodeType==1&&e.contains(this.lock.parentNode))}}function Ch(n,e){let t=e,r=t.children.length,o=n.childCount,s=new Map,i=[];e:for(;o>0;){let l;for(;;)if(r){let c=t.children[r-1];if(c instanceof Or)t=c,r=c.children.length;else{l=c,r--;break}}else{if(t==e)break e;r=t.parent.children.indexOf(t),t=t.parent}let a=l.node;if(a){if(a!=n.child(o-1))break;--o,s.set(l,o),i.push(l)}}return{index:o,matched:s,matches:i.reverse()}}function wh(n,e){return n.type.side-e.type.side}function Mh(n,e,t,r){let o=e.locals(n),s=0;if(o.length==0){for(let c=0;c<n.childCount;c++){let u=n.child(c);r(u,o,e.forChild(s,u),c),s+=u.nodeSize}return}let i=0,l=[],a=null;for(let c=0;;){let u,f;for(;i<o.length&&o[i].to==s;){let g=o[i++];g.widget&&(u?(f||(f=[u])).push(g):u=g)}if(u)if(f){f.sort(wh);for(let g=0;g<f.length;g++)t(f[g],c,!!a)}else t(u,c,!!a);let d,p;if(a)p=-1,d=a,a=null;else if(c<n.childCount)p=c,d=n.child(c++);else break;for(let g=0;g<l.length;g++)l[g].to<=s&&l.splice(g--,1);for(;i<o.length&&o[i].from<=s&&o[i].to>s;)l.push(o[i++]);let h=s+d.nodeSize;if(d.isText){let g=h;i<o.length&&o[i].from<g&&(g=o[i].from);for(let k=0;k<l.length;k++)l[k].to<g&&(g=l[k].to);g<h&&(a=d.cut(g-s),d=d.cut(0,g-s),h=g,p=-1)}else for(;i<o.length&&o[i].to<h;)i++;let b=d.isInline&&!d.isLeaf?l.filter(g=>!g.inline):l.slice();r(d,b,e.forChild(s,d),p),s=h}}function Nh(n){if(n.nodeName=="UL"||n.nodeName=="OL"){let e=n.style.cssText;n.style.cssText=e+"; list-style: square !important",window.getComputedStyle(n).listStyle,n.style.cssText=e}}function Eh(n,e,t,r){for(let o=0,s=0;o<n.childCount&&s<=r;){let i=n.child(o++),l=s;if(s+=i.nodeSize,!i.isText)continue;let a=i.text;for(;o<n.childCount;){let c=n.child(o++);if(s+=c.nodeSize,!c.isText)break;a+=c.text}if(s>=t){if(s>=r&&a.slice(r-e.length-l,r-l)==e)return r-e.length;let c=l<r?a.lastIndexOf(e,r-l-1):-1;if(c>=0&&c+e.length+l>=t)return l+c;if(t==r&&a.length>=r+e.length-l&&a.slice(r-l,r-l+e.length)==e)return r}}return-1}function Yo(n,e,t,r,o){let s=[];for(let i=0,l=0;i<n.length;i++){let a=n[i],c=l,u=l+=a.size;c>=t||u<=e?s.push(a):(c<e&&s.push(a.slice(0,e-c,r)),o&&(s.push(o),o=void 0),u>t&&s.push(a.slice(t-c,a.size,r)))}return s}function Go(n,e=null){let t=n.domSelectionRange(),r=n.state.doc;if(!t.focusNode)return null;let o=n.docView.nearestDesc(t.focusNode),s=o&&o.size==0,i=n.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(i<0)return null;let l=r.resolve(i),a,c;if(Dr(t)){for(a=i;o&&!o.node;)o=o.parent;let f=o.node;if(o&&f.isAtom&&D.isSelectable(f)&&o.parent&&!(f.isInline&&Qd(t.focusNode,t.focusOffset,o.dom))){let d=o.posBefore;c=new D(i==d?l:r.resolve(d))}}else{if(t instanceof n.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let f=i,d=i;for(let p=0;p<t.rangeCount;p++){let h=t.getRangeAt(p);f=Math.min(f,n.docView.posFromDOM(h.startContainer,h.startOffset,1)),d=Math.max(d,n.docView.posFromDOM(h.endContainer,h.endOffset,-1))}if(f<0)return null;[a,i]=d==n.state.selection.anchor?[d,f]:[f,d],l=r.resolve(i)}else a=n.docView.posFromDOM(t.anchorNode,t.anchorOffset,1);if(a<0)return null}let u=r.resolve(a);if(!c){let f=e=="pointer"||n.state.selection.head<l.pos&&!s?1:-1;c=Uo(n,u,l,f)}return c}function Gl(n){return n.editable?n.hasFocus():na(n)&&document.activeElement&&document.activeElement.contains(n.dom)}function et(n,e=!1){let t=n.state.selection;if(Zl(n,t),!!Gl(n)){if(!e&&n.input.mouseDown&&n.input.mouseDown.allowDefault&&ie){let r=n.domSelectionRange(),o=n.domObserver.currentSelection;if(r.anchorNode&&o.anchorNode&&Vt(r.anchorNode,r.anchorOffset,o.anchorNode,o.anchorOffset)){n.input.mouseDown.delayedSelectionSync=!0,n.domObserver.setCurSelection();return}}if(n.domObserver.disconnectSelection(),n.cursorWrapper)Oh(n);else{let{anchor:r,head:o}=t,s,i;Xl&&!(t instanceof P)&&(t.$from.parent.inlineContent||(s=Ul(n,t.from)),!t.empty&&!t.$from.parent.inlineContent&&(i=Ul(n,t.to))),n.docView.setSelection(r,o,n,e),Xl&&(s&&Ql(s),i&&Ql(i)),t.visible?n.dom.classList.remove("ProseMirror-hideselection"):(n.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&Dh(n))}n.domObserver.setCurSelection(),n.domObserver.connectSelection()}}const Xl=ue||ie&&Ol<63;function Ul(n,e){let{node:t,offset:r}=n.docView.domFromPos(e,0),o=r<t.childNodes.length?t.childNodes[r]:null,s=r?t.childNodes[r-1]:null;if(ue&&o&&o.contentEditable=="false")return Xo(o);if((!o||o.contentEditable=="false")&&(!s||s.contentEditable=="false")){if(o)return Xo(o);if(s)return Xo(s)}}function Xo(n){return n.contentEditable="true",ue&&n.draggable&&(n.draggable=!1,n.wasDraggable=!0),n}function Ql(n){n.contentEditable="false",n.wasDraggable&&(n.draggable=!0,n.wasDraggable=null)}function Dh(n){let e=n.dom.ownerDocument;e.removeEventListener("selectionchange",n.input.hideSelectionGuard);let t=n.domSelectionRange(),r=t.anchorNode,o=t.anchorOffset;e.addEventListener("selectionchange",n.input.hideSelectionGuard=()=>{(t.anchorNode!=r||t.anchorOffset!=o)&&(e.removeEventListener("selectionchange",n.input.hideSelectionGuard),setTimeout(()=>{(!Gl(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function Oh(n){let e=n.domSelection(),t=document.createRange();if(!e)return;let r=n.cursorWrapper.dom,o=r.nodeName=="IMG";o?t.setStart(r.parentNode,ne(r)+1):t.setStart(r,0),t.collapse(!0),e.removeAllRanges(),e.addRange(t),!o&&!n.state.selection.visible&&ye&&dt<=11&&(r.disabled=!0,r.disabled=!1)}function Zl(n,e){if(e instanceof D){let t=n.docView.descAt(e.from);t!=n.lastSelectedViewDesc&&(ea(n),t&&t.selectNode(),n.lastSelectedViewDesc=t)}else ea(n)}function ea(n){n.lastSelectedViewDesc&&(n.lastSelectedViewDesc.parent&&n.lastSelectedViewDesc.deselectNode(),n.lastSelectedViewDesc=void 0)}function Uo(n,e,t,r){return n.someProp("createSelectionBetween",o=>o(n,e,t))||P.between(e,t,r)}function ta(n){return n.editable&&!n.hasFocus()?!1:na(n)}function na(n){let e=n.domSelectionRange();if(!e.anchorNode)return!1;try{return n.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(n.editable||n.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function Th(n){let e=n.docView.domFromPos(n.state.selection.anchor,0),t=n.domSelectionRange();return Vt(e.node,e.offset,t.anchorNode,t.anchorOffset)}function Qo(n,e){let{$anchor:t,$head:r}=n.selection,o=e>0?t.max(r):t.min(r),s=o.parent.inlineContent?o.depth?n.doc.resolve(e>0?o.after():o.before()):null:o;return s&&R.findFrom(s,e)}function pt(n,e){return n.dispatch(n.state.tr.setSelection(e).scrollIntoView()),!0}function ra(n,e,t){let r=n.state.selection;if(r instanceof P)if(t.indexOf("s")>-1){let{$head:o}=r,s=o.textOffset?null:e<0?o.nodeBefore:o.nodeAfter;if(!s||s.isText||!s.isLeaf)return!1;let i=n.state.doc.resolve(o.pos+s.nodeSize*(e<0?-1:1));return pt(n,new P(r.$anchor,i))}else if(r.empty){if(n.endOfTextblock(e>0?"forward":"backward")){let o=Qo(n.state,e);return o&&o instanceof D?pt(n,o):!1}else if(!(Ne&&t.indexOf("m")>-1)){let o=r.$head,s=o.textOffset?null:e<0?o.nodeBefore:o.nodeAfter,i;if(!s||s.isText)return!1;let l=e<0?o.pos-s.nodeSize:o.pos;return s.isAtom||(i=n.docView.descAt(l))&&!i.contentDOM?D.isSelectable(s)?pt(n,new D(e<0?n.state.doc.resolve(o.pos-s.nodeSize):o)):Rn?pt(n,new P(n.state.doc.resolve(e<0?l:l+s.nodeSize))):!1:!1}}else return!1;else{if(r instanceof D&&r.node.isInline)return pt(n,new P(e>0?r.$to:r.$from));{let o=Qo(n.state,e);return o?pt(n,o):!1}}}function vr(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Bn(n,e){let t=n.pmViewDesc;return t&&t.size==0&&(e<0||n.nextSibling||n.nodeName!="BR")}function cn(n,e){return e<0?vh(n):Ah(n)}function vh(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let o,s,i=!1;for(Ie&&t.nodeType==1&&r<vr(t)&&Bn(t.childNodes[r],-1)&&(i=!0);;)if(r>0){if(t.nodeType!=1)break;{let l=t.childNodes[r-1];if(Bn(l,-1))o=t,s=--r;else if(l.nodeType==3)t=l,r=t.nodeValue.length;else break}}else{if(oa(t))break;{let l=t.previousSibling;for(;l&&Bn(l,-1);)o=t.parentNode,s=ne(l),l=l.previousSibling;if(l)t=l,r=vr(t);else{if(t=t.parentNode,t==n.dom)break;r=0}}}i?Zo(n,t,r):o&&Zo(n,o,s)}function Ah(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let o=vr(t),s,i;for(;;)if(r<o){if(t.nodeType!=1)break;let l=t.childNodes[r];if(Bn(l,1))s=t,i=++r;else break}else{if(oa(t))break;{let l=t.nextSibling;for(;l&&Bn(l,1);)s=l.parentNode,i=ne(l)+1,l=l.nextSibling;if(l)t=l,r=0,o=vr(t);else{if(t=t.parentNode,t==n.dom)break;r=o=0}}}s&&Zo(n,s,i)}function oa(n){let e=n.pmViewDesc;return e&&e.node&&e.node.isBlock}function Ph(n,e){for(;n&&e==n.childNodes.length&&!Vn(n);)e=ne(n)+1,n=n.parentNode;for(;n&&e<n.childNodes.length;){let t=n.childNodes[e];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;n=t,e=0}}function Ih(n,e){for(;n&&!e&&!Vn(n);)e=ne(n),n=n.parentNode;for(;n&&e;){let t=n.childNodes[e-1];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;n=t,e=n.childNodes.length}}function Zo(n,e,t){if(e.nodeType!=3){let s,i;(i=Ph(e,t))?(e=i,t=0):(s=Ih(e,t))&&(e=s,t=s.nodeValue.length)}let r=n.domSelection();if(!r)return;if(Dr(r)){let s=document.createRange();s.setEnd(e,t),s.setStart(e,t),r.removeAllRanges(),r.addRange(s)}else r.extend&&r.extend(e,t);n.domObserver.setCurSelection();let{state:o}=n;setTimeout(()=>{n.state==o&&et(n)},50)}function sa(n,e){let t=n.state.doc.resolve(e);if(!(ie||th)&&t.parent.inlineContent){let o=n.coordsAtPos(e);if(e>t.start()){let s=n.coordsAtPos(e-1),i=(s.top+s.bottom)/2;if(i>o.top&&i<o.bottom&&Math.abs(s.left-o.left)>1)return s.left<o.left?"ltr":"rtl"}if(e<t.end()){let s=n.coordsAtPos(e+1),i=(s.top+s.bottom)/2;if(i>o.top&&i<o.bottom&&Math.abs(s.left-o.left)>1)return s.left>o.left?"ltr":"rtl"}}return getComputedStyle(n.dom).direction=="rtl"?"rtl":"ltr"}function ia(n,e,t){let r=n.state.selection;if(r instanceof P&&!r.empty||t.indexOf("s")>-1||Ne&&t.indexOf("m")>-1)return!1;let{$from:o,$to:s}=r;if(!o.parent.inlineContent||n.endOfTextblock(e<0?"up":"down")){let i=Qo(n.state,e);if(i&&i instanceof D)return pt(n,i)}if(!o.parent.inlineContent){let i=e<0?o:s,l=r instanceof ge?R.near(i,e):R.findFrom(i,e);return l?pt(n,l):!1}return!1}function la(n,e){if(!(n.state.selection instanceof P))return!0;let{$head:t,$anchor:r,empty:o}=n.state.selection;if(!t.sameParent(r))return!0;if(!o)return!1;if(n.endOfTextblock(e>0?"forward":"backward"))return!0;let s=!t.textOffset&&(e<0?t.nodeBefore:t.nodeAfter);if(s&&!s.isText){let i=n.state.tr;return e<0?i.delete(t.pos-s.nodeSize,t.pos):i.delete(t.pos,t.pos+s.nodeSize),n.dispatch(i),!0}return!1}function aa(n,e,t){n.domObserver.stop(),e.contentEditable=t,n.domObserver.start()}function Vh(n){if(!ue||n.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:t}=n.domSelectionRange();if(e&&e.nodeType==1&&t==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let r=e.firstChild;aa(n,r,"true"),setTimeout(()=>aa(n,r,"false"),20)}return!1}function Rh(n){let e="";return n.ctrlKey&&(e+="c"),n.metaKey&&(e+="m"),n.altKey&&(e+="a"),n.shiftKey&&(e+="s"),e}function zh(n,e){let t=e.keyCode,r=Rh(e);if(t==8||Ne&&t==72&&r=="c")return la(n,-1)||cn(n,-1);if(t==46&&!e.shiftKey||Ne&&t==68&&r=="c")return la(n,1)||cn(n,1);if(t==13||t==27)return!0;if(t==37||Ne&&t==66&&r=="c"){let o=t==37?sa(n,n.state.selection.from)=="ltr"?-1:1:-1;return ra(n,o,r)||cn(n,o)}else if(t==39||Ne&&t==70&&r=="c"){let o=t==39?sa(n,n.state.selection.from)=="ltr"?1:-1:1;return ra(n,o,r)||cn(n,o)}else{if(t==38||Ne&&t==80&&r=="c")return ia(n,-1,r)||cn(n,-1);if(t==40||Ne&&t==78&&r=="c")return Vh(n)||ia(n,1,r)||cn(n,1);if(r==(Ne?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function ca(n,e){n.someProp("transformCopied",p=>{e=p(e,n)});let t=[],{content:r,openStart:o,openEnd:s}=e;for(;o>1&&s>1&&r.childCount==1&&r.firstChild.childCount==1;){o--,s--;let p=r.firstChild;t.push(p.type.name,p.attrs!=p.type.defaultAttrs?p.attrs:null),r=p.content}let i=n.someProp("clipboardSerializer")||$e.fromSchema(n.state.schema),l=ya(),a=l.createElement("div");a.appendChild(i.serializeFragment(r,{document:l}));let c=a.firstChild,u,f=0;for(;c&&c.nodeType==1&&(u=ma[c.nodeName.toLowerCase()]);){for(let p=u.length-1;p>=0;p--){let h=l.createElement(u[p]);for(;a.firstChild;)h.appendChild(a.firstChild);a.appendChild(h),f++}c=a.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${o} ${s}${f?` -${f}`:""} ${JSON.stringify(t)}`);let d=n.someProp("clipboardTextSerializer",p=>p(e,n))||e.content.textBetween(0,e.content.size,`
|
|
35
|
+
`),t)}ignoreFallback(e,t){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),t,!0)}readStyles(e,t){let r=e.style;if(r&&r.length)for(let o=0;o<this.parser.matchedStyles.length;o++){let s=this.parser.matchedStyles[o],i=r.getPropertyValue(s);if(i)for(let l=void 0;;){let a=this.parser.matchStyle(s,i,this,l);if(!a)break;if(a.ignore)return null;if(a.clearMark?t=t.filter(c=>!a.clearMark(c)):t=t.concat(this.parser.schema.marks[a.mark].create(a.attrs)),a.consuming===!1)l=a;else break}}return t}addElementByRule(e,t,r,o){let s,i;if(t.node)if(i=this.parser.schema.nodes[t.node],i.isLeaf)this.insertNode(i.create(t.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let a=this.enter(i,t.attrs||null,r,t.preserveWhitespace);a&&(s=!0,r=a)}else{let a=this.parser.schema.marks[t.mark];r=r.concat(a.create(t.attrs))}let l=this.top;if(i&&i.isLeaf)this.findInside(e);else if(o)this.addElement(e,r,o);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a,r,!1));else{let a=e;typeof t.contentElement=="string"?a=e.querySelector(t.contentElement):typeof t.contentElement=="function"?a=t.contentElement(e):t.contentElement&&(a=t.contentElement),this.findAround(e,a,!0),this.addAll(a,r),this.findAround(e,a,!1)}s&&this.sync(l)&&this.open--}addAll(e,t,r,o){let s=r||0;for(let i=r?e.childNodes[r]:e.firstChild,l=o==null?null:e.childNodes[o];i!=l;i=i.nextSibling,++s)this.findAtPoint(e,s),this.addDOM(i,t);this.findAtPoint(e,s)}findPlace(e,t,r){let o,s;for(let i=this.open,l=0;i>=0;i--){let a=this.nodes[i],c=a.findWrapping(e);if(c&&(!o||o.length>c.length+l)&&(o=c,s=a,!c.length))break;if(a.solid){if(r)break;l+=2}}if(!o)return null;this.sync(s);for(let i=0;i<o.length;i++)t=this.enterInner(o[i],null,t,!1);return t}insertNode(e,t,r){if(e.isInline&&this.needsBlock&&!this.top.type){let s=this.textblockFromContext();s&&(t=this.enterInner(s,null,t))}let o=this.findPlace(e,t,r);if(o){this.closeExtra();let s=this.top;s.match&&(s.match=s.match.matchType(e.type));let i=F.none;for(let l of o.concat(e.marks))(s.type?s.type.allowsMarkType(l.type):zi(l.type,e.type))&&(i=l.addToSet(i));return s.content.push(e.mark(i)),!0}return!1}enter(e,t,r,o){let s=this.findPlace(e.create(t),r,!1);return s&&(s=this.enterInner(e,t,r,!0,o)),s}enterInner(e,t,r,o=!1,s){this.closeExtra();let i=this.top;i.match=i.match&&i.match.matchType(e);let l=Ii(e,s,i.options);i.options&yr&&i.content.length==0&&(l|=yr);let a=F.none;return r=r.filter(c=>(i.type?i.type.allowsMarkType(c.type):zi(c.type,e))?(a=c.addToSet(a),!1):!0),this.nodes.push(new br(e,t,a,o,null,l)),this.open++,r}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let t=this.open;t>=0;t--){if(this.nodes[t]==e)return this.open=t,!0;this.localPreserveWS&&(this.nodes[t].options|=En)}return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let r=this.nodes[t].content;for(let o=r.length-1;o>=0;o--)e+=r[o].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==t&&(this.find[r].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].pos==null&&e.nodeType==1&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,r){if(e!=t&&this.find)for(let o=0;o<this.find.length;o++)this.find[o].pos==null&&e.nodeType==1&&e.contains(this.find[o].node)&&t.compareDocumentPosition(this.find[o].node)&(r?2:4)&&(this.find[o].pos=this.currentPos)}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split("/"),r=this.options.context,o=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),s=-(r?r.depth+1:0)+(o?0:1),i=(l,a)=>{for(;l>=0;l--){let c=t[l];if(c==""){if(l==t.length-1||l==0)continue;for(;a>=s;a--)if(i(l-1,a))return!0;return!1}else{let u=a>0||a==0&&o?this.nodes[a].type:r&&a>=s?r.node(a-s).type:null;if(!u||u.name!=c&&!u.isInGroup(c))return!1;a--}}return!0};return i(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let r=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let t in this.parser.schema.nodes){let r=this.parser.schema.nodes[t];if(r.isTextblock&&r.defaultAttrs)return r}}}function jf(n){for(let e=n.firstChild,t=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&Pi.hasOwnProperty(r)&&t?(t.appendChild(e),e=t):r=="li"?t=e:r&&(t=null)}}function Bf(n,e){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,e)}function Ri(n){let e={};for(let t in n)e[t]=n[t];return e}function zi(n,e){let t=e.schema.nodes;for(let r in t){let o=t[r];if(!o.allowsMarkType(n))continue;let s=[],i=l=>{s.push(l);for(let a=0;a<l.edgeCount;a++){let{type:c,next:u}=l.edge(a);if(c==e||s.indexOf(u)<0&&i(u))return!0}};if(i(o.contentMatch))return!0}}class $e{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},r){r||(r=po(t).createDocumentFragment());let o=r,s=[];return e.forEach(i=>{if(s.length||i.marks.length){let l=0,a=0;for(;l<s.length&&a<i.marks.length;){let c=i.marks[a];if(!this.marks[c.type.name]){a++;continue}if(!c.eq(s[l][0])||c.type.spec.spanning===!1)break;l++,a++}for(;l<s.length;)o=s.pop()[1];for(;a<i.marks.length;){let c=i.marks[a++],u=this.serializeMark(c,i.isInline,t);u&&(s.push([c,o]),o.appendChild(u.dom),o=u.contentDOM||u.dom)}}o.appendChild(this.serializeNodeInner(i,t))}),r}serializeNodeInner(e,t){let{dom:r,contentDOM:o}=xr(po(t),this.nodes[e.type.name](e),null,e.attrs);if(o){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,o)}return r}serializeNode(e,t={}){let r=this.serializeNodeInner(e,t);for(let o=e.marks.length-1;o>=0;o--){let s=this.serializeMark(e.marks[o],e.isInline,t);s&&((s.contentDOM||s.dom).appendChild(r),r=s.dom)}return r}serializeMark(e,t,r={}){let o=this.marks[e.type.name];return o&&xr(po(r),o(e,t),null,e.attrs)}static renderSpec(e,t,r=null,o){return xr(e,t,r,o)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new $e(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=$i(e.nodes);return t.text||(t.text=r=>r.text),t}static marksFromSchema(e){return $i(e.marks)}}function $i(n){let e={};for(let t in n){let r=n[t].spec.toDOM;r&&(e[t]=r)}return e}function po(n){return n.document||window.document}const ji=new WeakMap;function Ff(n){let e=ji.get(n);return e===void 0&&ji.set(n,e=Lf(n)),e}function Lf(n){let e=null;function t(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")e||(e=[]),e.push(r);else for(let o=0;o<r.length;o++)t(r[o]);else for(let o in r)t(r[o])}return t(n),e}function xr(n,e,t,r){if(typeof e=="string")return{dom:n.createTextNode(e)};if(e.nodeType!=null)return{dom:e};if(e.dom&&e.dom.nodeType!=null)return e;let o=e[0],s;if(typeof o!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(s=Ff(r))&&s.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let i=o.indexOf(" ");i>0&&(t=o.slice(0,i),o=o.slice(i+1));let l,a=t?n.createElementNS(t,o):n.createElement(o),c=e[1],u=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){u=2;for(let f in c)if(c[f]!=null){let d=f.indexOf(" ");d>0?a.setAttributeNS(f.slice(0,d),f.slice(d+1),c[f]):a.setAttribute(f,c[f])}}for(let f=u;f<e.length;f++){let d=e[f];if(d===0){if(f<e.length-1||f>u)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}else{let{dom:h,contentDOM:p}=xr(n,d,t,r);if(a.appendChild(h),p){if(l)throw new RangeError("Multiple content holes");l=p}}}return{dom:a,contentDOM:l}}const Bi=65535,Fi=Math.pow(2,16);function Wf(n,e){return n+e*Fi}function Li(n){return n&Bi}function _f(n){return(n-(n&Bi))/Fi}const Wi=1,_i=2,kr=4,qi=8;class mo{constructor(e,t,r){this.pos=e,this.delInfo=t,this.recover=r}get deleted(){return(this.delInfo&qi)>0}get deletedBefore(){return(this.delInfo&(Wi|kr))>0}get deletedAfter(){return(this.delInfo&(_i|kr))>0}get deletedAcross(){return(this.delInfo&kr)>0}}class xe{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&xe.empty)return xe.empty}recover(e){let t=0,r=Li(e);if(!this.inverted)for(let o=0;o<r;o++)t+=this.ranges[o*3+2]-this.ranges[o*3+1];return this.ranges[r*3]+t+_f(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,r){let o=0,s=this.inverted?2:1,i=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?o:0);if(a>e)break;let c=this.ranges[l+s],u=this.ranges[l+i],f=a+c;if(e<=f){let d=c?e==a?-1:e==f?1:t:t,h=a+o+(d<0?0:u);if(r)return h;let p=e==(t<0?a:f)?null:Wf(l/3,e-a),b=e==a?_i:e==f?Wi:kr;return(t<0?e!=a:e!=f)&&(b|=qi),new mo(h,b,p)}o+=u-c}return r?e+o:new mo(e+o,0,null)}touches(e,t){let r=0,o=Li(t),s=this.inverted?2:1,i=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?r:0);if(a>e)break;let c=this.ranges[l+s],u=a+c;if(e<=u&&l==o*3)return!0;r+=this.ranges[l+i]-c}return!1}forEach(e){let t=this.inverted?2:1,r=this.inverted?1:2;for(let o=0,s=0;o<this.ranges.length;o+=3){let i=this.ranges[o],l=i-(this.inverted?s:0),a=i+(this.inverted?0:s),c=this.ranges[o+t],u=this.ranges[o+r];e(l,l+c,a,a+u),s+=u-c}}invert(){return new xe(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?xe.empty:new xe(e<0?[0,-e,0]:[0,0,e])}}xe.empty=new xe([]);class Dn{constructor(e,t,r=0,o=e?e.length:0){this.mirror=t,this.from=r,this.to=o,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(e=0,t=this.maps.length){return new Dn(this._maps,this.mirror,e,t)}appendMap(e,t){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),t!=null&&this.setMirror(this._maps.length-1,t)}appendMapping(e){for(let t=0,r=this._maps.length;t<e._maps.length;t++){let o=e.getMirror(t);this.appendMap(e._maps[t],o!=null&&o<t?r+o:void 0)}}getMirror(e){if(this.mirror){for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}}setMirror(e,t){this.mirror||(this.mirror=[]),this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,r=this._maps.length+e._maps.length;t>=0;t--){let o=e.getMirror(t);this.appendMap(e._maps[t].invert(),o!=null&&o>t?r-o-1:void 0)}}invert(){let e=new Dn;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let r=this.from;r<this.to;r++)e=this._maps[r].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,r){let o=0;for(let s=this.from;s<this.to;s++){let i=this._maps[s],l=i.mapResult(e,t);if(l.recover!=null){let a=this.getMirror(s);if(a!=null&&a>s&&a<this.to){s=a,e=this._maps[a].recover(l.recover);continue}}o|=l.delInfo,e=l.pos}return r?e:new mo(e,o,null)}}const go=Object.create(null);class oe{getMap(){return xe.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=go[t.stepType];if(!r)throw new RangeError(`No step type ${t.stepType} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in go)throw new RangeError("Duplicate use of step JSON ID "+e);return go[e]=t,t.prototype.jsonID=e,t}}class K{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new K(e,null)}static fail(e){return new K(null,e)}static fromReplace(e,t,r,o){try{return K.ok(e.replace(t,r,o))}catch(s){if(s instanceof fr)return K.fail(s.message);throw s}}}function yo(n,e,t){let r=[];for(let o=0;o<n.childCount;o++){let s=n.child(o);s.content.size&&(s=s.copy(yo(s.content,e,s))),s.isInline&&(s=e(s,t,o)),r.push(s)}return C.fromArray(r)}class st extends oe{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=e.resolve(this.from),o=r.node(r.sharedDepth(this.to)),s=new N(yo(t.content,(i,l)=>!i.isAtom||!l.type.allowsMarkType(this.mark.type)?i:i.mark(this.mark.addToSet(i.marks)),o),t.openStart,t.openEnd);return K.fromReplace(e,this.from,this.to,s)}invert(){return new je(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new st(t.pos,r.pos,this.mark)}merge(e){return e instanceof st&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new st(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new st(t.from,t.to,e.markFromJSON(t.mark))}}oe.jsonID("addMark",st);class je extends oe{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=new N(yo(t.content,o=>o.mark(this.mark.removeFromSet(o.marks)),e),t.openStart,t.openEnd);return K.fromReplace(e,this.from,this.to,r)}invert(){return new st(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new je(t.pos,r.pos,this.mark)}merge(e){return e instanceof je&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new je(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new je(t.from,t.to,e.markFromJSON(t.mark))}}oe.jsonID("removeMark",je);class it extends oe{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return K.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return K.fromReplace(e,this.pos,this.pos+1,new N(C.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let r=this.mark.addToSet(t.marks);if(r.length==t.marks.length){for(let o=0;o<t.marks.length;o++)if(!t.marks[o].isInSet(r))return new it(this.pos,t.marks[o]);return new it(this.pos,this.mark)}}return new It(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new it(t.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new it(t.pos,e.markFromJSON(t.mark))}}oe.jsonID("addNodeMark",it);class It extends oe{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return K.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return K.fromReplace(e,this.pos,this.pos+1,new N(C.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new it(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new It(t.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new It(t.pos,e.markFromJSON(t.mark))}}oe.jsonID("removeNodeMark",It);class se extends oe{constructor(e,t,r,o=!1){super(),this.from=e,this.to=t,this.slice=r,this.structure=o}apply(e){return this.structure&&bo(e,this.from,this.to)?K.fail("Structure replace would overwrite content"):K.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new xe([this.from,this.to-this.from,this.slice.size])}invert(e){return new se(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deletedAcross&&r.deletedAcross?null:new se(t.pos,Math.max(t.pos,r.pos),this.slice,this.structure)}merge(e){if(!(e instanceof se)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let t=this.slice.size+e.slice.size==0?N.empty:new N(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new se(this.from,this.to+(e.to-e.from),t,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let t=this.slice.size+e.slice.size==0?N.empty:new N(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new se(e.from,this.to,t,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new se(t.from,t.to,N.fromJSON(e,t.slice),!!t.structure)}}oe.jsonID("replace",se);class ee extends oe{constructor(e,t,r,o,s,i,l=!1){super(),this.from=e,this.to=t,this.gapFrom=r,this.gapTo=o,this.slice=s,this.insert=i,this.structure=l}apply(e){if(this.structure&&(bo(e,this.from,this.gapFrom)||bo(e,this.gapTo,this.to)))return K.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return K.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,t.content);return r?K.fromReplace(e,this.from,this.to,r):K.fail("Content does not fit in gap")}getMap(){return new xe([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let t=this.gapTo-this.gapFrom;return new ee(this.from,this.from+this.slice.size+t,this.from+this.insert,this.from+this.insert+t,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),o=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),s=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return t.deletedAcross&&r.deletedAcross||o<t.pos||s>r.pos?null:new ee(t.pos,r.pos,o,s,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number"||typeof t.gapFrom!="number"||typeof t.gapTo!="number"||typeof t.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new ee(t.from,t.to,t.gapFrom,t.gapTo,N.fromJSON(e,t.slice),t.insert,!!t.structure)}}oe.jsonID("replaceAround",ee);function bo(n,e,t){let r=n.resolve(e),o=t-e,s=r.depth;for(;o>0&&s>0&&r.indexAfter(s)==r.node(s).childCount;)s--,o--;if(o>0){let i=r.node(s).maybeChild(r.indexAfter(s));for(;o>0;){if(!i||i.isLeaf)return!0;i=i.firstChild,o--}}return!1}function qf(n,e,t,r){let o=[],s=[],i,l;n.doc.nodesBetween(e,t,(a,c,u)=>{if(!a.isInline)return;let f=a.marks;if(!r.isInSet(f)&&u.type.allowsMarkType(r.type)){let d=Math.max(c,e),h=Math.min(c+a.nodeSize,t),p=r.addToSet(f);for(let b=0;b<f.length;b++)f[b].isInSet(p)||(i&&i.to==d&&i.mark.eq(f[b])?i.to=h:o.push(i=new je(d,h,f[b])));l&&l.to==d?l.to=h:s.push(l=new st(d,h,r))}}),o.forEach(a=>n.step(a)),s.forEach(a=>n.step(a))}function Hf(n,e,t,r){let o=[],s=0;n.doc.nodesBetween(e,t,(i,l)=>{if(!i.isInline)return;s++;let a=null;if(r instanceof mr){let c=i.marks,u;for(;u=r.isInSet(c);)(a||(a=[])).push(u),c=u.removeFromSet(c)}else r?r.isInSet(i.marks)&&(a=[r]):a=i.marks;if(a&&a.length){let c=Math.min(l+i.nodeSize,t);for(let u=0;u<a.length;u++){let f=a[u],d;for(let h=0;h<o.length;h++){let p=o[h];p.step==s-1&&f.eq(o[h].style)&&(d=p)}d?(d.to=c,d.step=s):o.push({style:f,from:Math.max(l,e),to:c,step:s})}}}),o.forEach(i=>n.step(new je(i.from,i.to,i.style)))}function xo(n,e,t,r=t.contentMatch,o=!0){let s=n.doc.nodeAt(e),i=[],l=e+1;for(let a=0;a<s.childCount;a++){let c=s.child(a),u=l+c.nodeSize,f=r.matchType(c.type);if(!f)i.push(new se(l,u,N.empty));else{r=f;for(let d=0;d<c.marks.length;d++)t.allowsMarkType(c.marks[d].type)||n.step(new je(l,u,c.marks[d]));if(o&&c.isText&&t.whitespace!="pre"){let d,h=/\r?\n|\r/g,p;for(;d=h.exec(c.text);)p||(p=new N(C.from(t.schema.text(" ",t.allowedMarks(c.marks))),0,0)),i.push(new se(l+d.index,l+d.index+d[0].length,p))}}l=u}if(!r.validEnd){let a=r.fillBefore(C.empty,!0);n.replace(l,l,new N(a,0,0))}for(let a=i.length-1;a>=0;a--)n.step(i[a])}function Kf(n,e,t){return(e==0||n.canReplace(e,n.childCount))&&(t==n.childCount||n.canReplace(0,t))}function On(n){let t=n.parent.content.cutByIndex(n.startIndex,n.endIndex);for(let r=n.depth;;--r){let o=n.$from.node(r),s=n.$from.index(r),i=n.$to.indexAfter(r);if(r<n.depth&&o.canReplace(s,i,t))return r;if(r==0||o.type.spec.isolating||!Kf(o,s,i))break}return null}function Jf(n,e,t){let{$from:r,$to:o,depth:s}=e,i=r.before(s+1),l=o.after(s+1),a=i,c=l,u=C.empty,f=0;for(let p=s,b=!1;p>t;p--)b||r.index(p)>0?(b=!0,u=C.from(r.node(p).copy(u)),f++):a--;let d=C.empty,h=0;for(let p=s,b=!1;p>t;p--)b||o.after(p+1)<o.end(p)?(b=!0,d=C.from(o.node(p).copy(d)),h++):c++;n.step(new ee(a,c,i,l,new N(u.append(d),f,h),u.size-f,!0))}function ko(n,e,t=null,r=n){let o=Yf(n,e),s=o&&Gf(r,e);return s?o.map(Hi).concat({type:e,attrs:t}).concat(s.map(Hi)):null}function Hi(n){return{type:n,attrs:null}}function Yf(n,e){let{parent:t,startIndex:r,endIndex:o}=n,s=t.contentMatchAt(r).findWrapping(e);if(!s)return null;let i=s.length?s[0]:e;return t.canReplaceWith(r,o,i)?s:null}function Gf(n,e){let{parent:t,startIndex:r,endIndex:o}=n,s=t.child(r),i=e.contentMatch.findWrapping(s.type);if(!i)return null;let a=(i.length?i[i.length-1]:e).contentMatch;for(let c=r;a&&c<o;c++)a=a.matchType(t.child(c).type);return!a||!a.validEnd?null:i}function Xf(n,e,t){let r=C.empty;for(let i=t.length-1;i>=0;i--){if(r.size){let l=t[i].type.contentMatch.matchFragment(r);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=C.from(t[i].type.create(t[i].attrs,r))}let o=e.start,s=e.end;n.step(new ee(o,s,o,s,new N(r,0,0),t.length,!0))}function Uf(n,e,t,r,o){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let s=n.steps.length;n.doc.nodesBetween(e,t,(i,l)=>{let a=typeof o=="function"?o(i):o;if(i.isTextblock&&!i.hasMarkup(r,a)&&Qf(n.doc,n.mapping.slice(s).map(l),r)){let c=null;if(r.schema.linebreakReplacement){let h=r.whitespace=="pre",p=!!r.contentMatch.matchType(r.schema.linebreakReplacement);h&&!p?c=!1:!h&&p&&(c=!0)}c===!1&&Ji(n,i,l,s),xo(n,n.mapping.slice(s).map(l,1),r,void 0,c===null);let u=n.mapping.slice(s),f=u.map(l,1),d=u.map(l+i.nodeSize,1);return n.step(new ee(f,d,f+1,d-1,new N(C.from(r.create(a,null,i.marks)),0,0),1,!0)),c===!0&&Ki(n,i,l,s),!1}})}function Ki(n,e,t,r){e.forEach((o,s)=>{if(o.isText){let i,l=/\r?\n|\r/g;for(;i=l.exec(o.text);){let a=n.mapping.slice(r).map(t+1+s+i.index);n.replaceWith(a,a+1,e.type.schema.linebreakReplacement.create())}}})}function Ji(n,e,t,r){e.forEach((o,s)=>{if(o.type==o.type.schema.linebreakReplacement){let i=n.mapping.slice(r).map(t+1+s);n.replaceWith(i,i+1,e.type.schema.text(`
|
|
36
|
+
`))}})}function Qf(n,e,t){let r=n.resolve(e),o=r.index();return r.parent.canReplaceWith(o,o+1,t)}function Zf(n,e,t,r,o){let s=n.doc.nodeAt(e);if(!s)throw new RangeError("No node at given position");t||(t=s.type);let i=t.create(r,null,o||s.marks);if(s.isLeaf)return n.replaceWith(e,e+s.nodeSize,i);if(!t.validContent(s.content))throw new RangeError("Invalid content for node type "+t.name);n.step(new ee(e,e+s.nodeSize,e+1,e+s.nodeSize-1,new N(C.from(i),0,0),1,!0))}function Qt(n,e,t=1,r){let o=n.resolve(e),s=o.depth-t,i=r&&r[r.length-1]||o.parent;if(s<0||o.parent.type.spec.isolating||!o.parent.canReplace(o.index(),o.parent.childCount)||!i.type.validContent(o.parent.content.cutByIndex(o.index(),o.parent.childCount)))return!1;for(let c=o.depth-1,u=t-2;c>s;c--,u--){let f=o.node(c),d=o.index(c);if(f.type.spec.isolating)return!1;let h=f.content.cutByIndex(d,f.childCount),p=r&&r[u+1];p&&(h=h.replaceChild(0,p.type.create(p.attrs)));let b=r&&r[u]||f;if(!f.canReplace(d+1,f.childCount)||!b.type.validContent(h))return!1}let l=o.indexAfter(s),a=r&&r[0];return o.node(s).canReplaceWith(l,l,a?a.type:o.node(s+1).type)}function ed(n,e,t=1,r){let o=n.doc.resolve(e),s=C.empty,i=C.empty;for(let l=o.depth,a=o.depth-t,c=t-1;l>a;l--,c--){s=C.from(o.node(l).copy(s));let u=r&&r[c];i=C.from(u?u.type.create(u.attrs,i):o.node(l).copy(i))}n.step(new se(e,e,new N(s.append(i),t,t),!0))}function Zt(n,e){let t=n.resolve(e),r=t.index();return Yi(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(r,r+1)}function td(n,e){e.content.size||n.type.compatibleContent(e.type);let t=n.contentMatchAt(n.childCount),{linebreakReplacement:r}=n.type.schema;for(let o=0;o<e.childCount;o++){let s=e.child(o),i=s.type==r?n.type.schema.nodes.text:s.type;if(t=t.matchType(i),!t||!n.type.allowsMarks(s.marks))return!1}return t.validEnd}function Yi(n,e){return!!(n&&e&&!n.isLeaf&&td(n,e))}function Gi(n,e,t=-1){let r=n.resolve(e);for(let o=r.depth;;o--){let s,i,l=r.index(o);if(o==r.depth?(s=r.nodeBefore,i=r.nodeAfter):t>0?(s=r.node(o+1),l++,i=r.node(o).maybeChild(l)):(s=r.node(o).maybeChild(l-1),i=r.node(o+1)),s&&!s.isTextblock&&Yi(s,i)&&r.node(o).canReplace(l,l+1))return e;if(o==0)break;e=t<0?r.before(o):r.after(o)}}function nd(n,e,t){let r=null,{linebreakReplacement:o}=n.doc.type.schema,s=n.doc.resolve(e-t),i=s.node().type;if(o&&i.inlineContent){let u=i.whitespace=="pre",f=!!i.contentMatch.matchType(o);u&&!f?r=!1:!u&&f&&(r=!0)}let l=n.steps.length;if(r===!1){let u=n.doc.resolve(e+t);Ji(n,u.node(),u.before(),l)}i.inlineContent&&xo(n,e+t-1,i,s.node().contentMatchAt(s.index()),r==null);let a=n.mapping.slice(l),c=a.map(e-t);if(n.step(new se(c,a.map(e+t,-1),N.empty,!0)),r===!0){let u=n.doc.resolve(c);Ki(n,u.node(),u.before(),n.steps.length)}return n}function rd(n,e,t){let r=n.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),t))return e;if(r.parentOffset==0)for(let o=r.depth-1;o>=0;o--){let s=r.index(o);if(r.node(o).canReplaceWith(s,s,t))return r.before(o+1);if(s>0)return null}if(r.parentOffset==r.parent.content.size)for(let o=r.depth-1;o>=0;o--){let s=r.indexAfter(o);if(r.node(o).canReplaceWith(s,s,t))return r.after(o+1);if(s<r.node(o).childCount)return null}return null}function So(n,e,t){let r=n.resolve(e);if(!t.content.size)return e;let o=t.content;for(let s=0;s<t.openStart;s++)o=o.firstChild.content;for(let s=1;s<=(t.openStart==0&&t.size?2:1);s++)for(let i=r.depth;i>=0;i--){let l=i==r.depth?0:r.pos<=(r.start(i+1)+r.end(i+1))/2?-1:1,a=r.index(i)+(l>0?1:0),c=r.node(i),u=!1;if(s==1)u=c.canReplace(a,a,o);else{let f=c.contentMatchAt(a).findWrapping(o.firstChild.type);u=f&&c.canReplaceWith(a,a,f[0])}if(u)return l==0?r.pos:l<0?r.before(i+1):r.after(i+1)}return null}function Co(n,e,t=e,r=N.empty){if(e==t&&!r.size)return null;let o=n.resolve(e),s=n.resolve(t);return Xi(o,s,r)?new se(e,t,r):new od(o,s,r).fit()}function Xi(n,e,t){return!t.openStart&&!t.openEnd&&n.start()==e.start()&&n.parent.canReplace(n.index(),e.index(),t.content)}class od{constructor(e,t,r){this.$from=e,this.$to=t,this.unplaced=r,this.frontier=[],this.placed=C.empty;for(let o=0;o<=e.depth;o++){let s=e.node(o);this.frontier.push({type:s.type,match:s.contentMatchAt(e.indexAfter(o))})}for(let o=e.depth;o>0;o--)this.placed=C.from(e.node(o).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let c=this.findFittable();c?this.placeNodes(c):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,r=this.$from,o=this.close(e<0?this.$to:r.doc.resolve(e));if(!o)return null;let s=this.placed,i=r.depth,l=o.depth;for(;i&&l&&s.childCount==1;)s=s.firstChild.content,i--,l--;let a=new N(s,i,l);return e>-1?new ee(r.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||r.pos!=this.$to.pos?new se(r.pos,o.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,r=0,o=this.unplaced.openEnd;r<e;r++){let s=t.firstChild;if(t.childCount>1&&(o=0),s.type.spec.isolating&&o<=r){e=r;break}t=s.content}for(let t=1;t<=2;t++)for(let r=t==1?e:this.unplaced.openStart;r>=0;r--){let o,s=null;r?(s=wo(this.unplaced.content,r-1).firstChild,o=s.content):o=this.unplaced.content;let i=o.firstChild;for(let l=this.depth;l>=0;l--){let{type:a,match:c}=this.frontier[l],u,f=null;if(t==1&&(i?c.matchType(i.type)||(f=c.fillBefore(C.from(i),!1)):s&&a.compatibleContent(s.type)))return{sliceDepth:r,frontierDepth:l,parent:s,inject:f};if(t==2&&i&&(u=c.findWrapping(i.type)))return{sliceDepth:r,frontierDepth:l,parent:s,wrap:u};if(s&&c.matchType(s.type))break}}}openMore(){let{content:e,openStart:t,openEnd:r}=this.unplaced,o=wo(e,t);return!o.childCount||o.firstChild.isLeaf?!1:(this.unplaced=new N(e,t+1,Math.max(r,o.size+t>=e.size-r?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:r}=this.unplaced,o=wo(e,t);if(o.childCount<=1&&t>0){let s=e.size-t<=t+o.size;this.unplaced=new N(Tn(e,t-1,1),t-1,s?t-1:r)}else this.unplaced=new N(Tn(e,t,1),t,r)}placeNodes({sliceDepth:e,frontierDepth:t,parent:r,inject:o,wrap:s}){for(;this.depth>t;)this.closeFrontierNode();if(s)for(let b=0;b<s.length;b++)this.openFrontierNode(s[b]);let i=this.unplaced,l=r?r.content:i.content,a=i.openStart-e,c=0,u=[],{match:f,type:d}=this.frontier[t];if(o){for(let b=0;b<o.childCount;b++)u.push(o.child(b));f=f.matchFragment(o)}let h=l.size+e-(i.content.size-i.openEnd);for(;c<l.childCount;){let b=l.child(c),g=f.matchType(b.type);if(!g)break;c++,(c>1||a==0||b.content.size)&&(f=g,u.push(Ui(b.mark(d.allowedMarks(b.marks)),c==1?a:0,c==l.childCount?h:-1)))}let p=c==l.childCount;p||(h=-1),this.placed=vn(this.placed,t,C.from(u)),this.frontier[t].match=f,p&&h<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let b=0,g=l;b<h;b++){let k=g.lastChild;this.frontier.push({type:k.type,match:k.contentMatchAt(k.childCount)}),g=k.content}this.unplaced=p?e==0?N.empty:new N(Tn(i.content,e-1,1),e-1,h<0?i.openEnd:e-1):new N(Tn(i.content,e,c),i.openStart,i.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],t;if(!e.type.isTextblock||!Mo(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(t=this.findCloseLevel(this.$to))&&t.depth==this.depth)return-1;let{depth:r}=this.$to,o=this.$to.after(r);for(;r>1&&o==this.$to.end(--r);)++o;return o}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:r,type:o}=this.frontier[t],s=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),i=Mo(e,t,o,r,s);if(i){for(let l=t-1;l>=0;l--){let{match:a,type:c}=this.frontier[l],u=Mo(e,l,c,a,!0);if(!u||u.childCount)continue e}return{depth:t,fit:i,move:s?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=vn(this.placed,t.depth,t.fit)),e=t.move;for(let r=t.depth+1;r<=e.depth;r++){let o=e.node(r),s=o.type.contentMatch.fillBefore(o.content,!0,e.index(r));this.openFrontierNode(o.type,o.attrs,s)}return e}openFrontierNode(e,t=null,r){let o=this.frontier[this.depth];o.match=o.match.matchType(e),this.placed=vn(this.placed,this.depth,C.from(e.create(t,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(C.empty,!0);t.childCount&&(this.placed=vn(this.placed,this.frontier.length,t))}}function Tn(n,e,t){return e==0?n.cutByIndex(t,n.childCount):n.replaceChild(0,n.firstChild.copy(Tn(n.firstChild.content,e-1,t)))}function vn(n,e,t){return e==0?n.append(t):n.replaceChild(n.childCount-1,n.lastChild.copy(vn(n.lastChild.content,e-1,t)))}function wo(n,e){for(let t=0;t<e;t++)n=n.firstChild.content;return n}function Ui(n,e,t){if(e<=0)return n;let r=n.content;return e>1&&(r=r.replaceChild(0,Ui(r.firstChild,e-1,r.childCount==1?t-1:0))),e>0&&(r=n.type.contentMatch.fillBefore(r).append(r),t<=0&&(r=r.append(n.type.contentMatch.matchFragment(r).fillBefore(C.empty,!0)))),n.copy(r)}function Mo(n,e,t,r,o){let s=n.node(e),i=o?n.indexAfter(e):n.index(e);if(i==s.childCount&&!t.compatibleContent(s.type))return null;let l=r.fillBefore(s.content,!0,i);return l&&!sd(t,s.content,i)?l:null}function sd(n,e,t){for(let r=t;r<e.childCount;r++)if(!n.allowsMarks(e.child(r).marks))return!0;return!1}function id(n){return n.spec.defining||n.spec.definingForContent}function ld(n,e,t,r){if(!r.size)return n.deleteRange(e,t);let o=n.doc.resolve(e),s=n.doc.resolve(t);if(Xi(o,s,r))return n.step(new se(e,t,r));let i=Zi(o,n.doc.resolve(t));i[i.length-1]==0&&i.pop();let l=-(o.depth+1);i.unshift(l);for(let d=o.depth,h=o.pos-1;d>0;d--,h--){let p=o.node(d).type.spec;if(p.defining||p.definingAsContext||p.isolating)break;i.indexOf(d)>-1?l=d:o.before(d)==h&&i.splice(1,0,-d)}let a=i.indexOf(l),c=[],u=r.openStart;for(let d=r.content,h=0;;h++){let p=d.firstChild;if(c.push(p),h==r.openStart)break;d=p.content}for(let d=u-1;d>=0;d--){let h=c[d],p=id(h.type);if(p&&!h.sameMarkup(o.node(Math.abs(l)-1)))u=d;else if(p||!h.type.isTextblock)break}for(let d=r.openStart;d>=0;d--){let h=(d+u+1)%(r.openStart+1),p=c[h];if(p)for(let b=0;b<i.length;b++){let g=i[(b+a)%i.length],k=!0;g<0&&(k=!1,g=-g);let S=o.node(g-1),M=o.index(g-1);if(S.canReplaceWith(M,M,p.type,p.marks))return n.replace(o.before(g),k?s.after(g):t,new N(Qi(r.content,0,r.openStart,h),h,r.openEnd))}}let f=n.steps.length;for(let d=i.length-1;d>=0&&(n.replace(e,t,r),!(n.steps.length>f));d--){let h=i[d];h<0||(e=o.before(h),t=s.after(h))}}function Qi(n,e,t,r,o){if(e<t){let s=n.firstChild;n=n.replaceChild(0,s.copy(Qi(s.content,e+1,t,r,s)))}if(e>r){let s=o.contentMatchAt(0),i=s.fillBefore(n).append(n);n=i.append(s.matchFragment(i).fillBefore(C.empty,!0))}return n}function ad(n,e,t,r){if(!r.isInline&&e==t&&n.doc.resolve(e).parent.content.size){let o=rd(n.doc,e,r.type);o!=null&&(e=t=o)}n.replaceRange(e,t,new N(C.from(r),0,0))}function cd(n,e,t){let r=n.doc.resolve(e),o=n.doc.resolve(t),s=Zi(r,o);for(let i=0;i<s.length;i++){let l=s[i],a=i==s.length-1;if(a&&l==0||r.node(l).type.contentMatch.validEnd)return n.delete(r.start(l),o.end(l));if(l>0&&(a||r.node(l-1).canReplace(r.index(l-1),o.indexAfter(l-1))))return n.delete(r.before(l),o.after(l))}for(let i=1;i<=r.depth&&i<=o.depth;i++)if(e-r.start(i)==r.depth-i&&t>r.end(i)&&o.end(i)-t!=o.depth-i&&r.start(i-1)==o.start(i-1)&&r.node(i-1).canReplace(r.index(i-1),o.index(i-1)))return n.delete(r.before(i),t);n.delete(e,t)}function Zi(n,e){let t=[],r=Math.min(n.depth,e.depth);for(let o=r;o>=0;o--){let s=n.start(o);if(s<n.pos-(n.depth-o)||e.end(o)>e.pos+(e.depth-o)||n.node(o).type.spec.isolating||e.node(o).type.spec.isolating)break;(s==e.start(o)||o==n.depth&&o==e.depth&&n.parent.inlineContent&&e.parent.inlineContent&&o&&e.start(o-1)==s-1)&&t.push(o)}return t}class en extends oe{constructor(e,t,r){super(),this.pos=e,this.attr=t,this.value=r}apply(e){let t=e.nodeAt(this.pos);if(!t)return K.fail("No node at attribute step's position");let r=Object.create(null);for(let s in t.attrs)r[s]=t.attrs[s];r[this.attr]=this.value;let o=t.type.create(r,null,t.marks);return K.fromReplace(e,this.pos,this.pos+1,new N(C.from(o),0,t.isLeaf?0:1))}getMap(){return xe.empty}invert(e){return new en(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new en(t.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.pos!="number"||typeof t.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new en(t.pos,t.attr,t.value)}}oe.jsonID("attr",en);class An extends oe{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let o in e.attrs)t[o]=e.attrs[o];t[this.attr]=this.value;let r=e.type.create(t,e.content,e.marks);return K.ok(r)}getMap(){return xe.empty}invert(e){return new An(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new An(t.attr,t.value)}}oe.jsonID("docAttr",An);let tn=class extends Error{};tn=function n(e){let t=Error.call(this,e);return t.__proto__=n.prototype,t},tn.prototype=Object.create(Error.prototype),tn.prototype.constructor=tn,tn.prototype.name="TransformError";class el{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Dn}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new tn(t.failed);return this}maybeStep(e){let t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t}get docChanged(){return this.steps.length>0}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,r=N.empty){let o=Co(this.doc,e,t,r);return o&&this.step(o),this}replaceWith(e,t,r){return this.replace(e,t,new N(C.from(r),0,0))}delete(e,t){return this.replace(e,t,N.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,r){return ld(this,e,t,r),this}replaceRangeWith(e,t,r){return ad(this,e,t,r),this}deleteRange(e,t){return cd(this,e,t),this}lift(e,t){return Jf(this,e,t),this}join(e,t=1){return nd(this,e,t),this}wrap(e,t){return Xf(this,e,t),this}setBlockType(e,t=e,r,o=null){return Uf(this,e,t,r,o),this}setNodeMarkup(e,t,r=null,o){return Zf(this,e,t,r,o),this}setNodeAttribute(e,t,r){return this.step(new en(e,t,r)),this}setDocAttribute(e,t){return this.step(new An(e,t)),this}addNodeMark(e,t){return this.step(new it(e,t)),this}removeNodeMark(e,t){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(t instanceof F)t.isInSet(r.marks)&&this.step(new It(e,t));else{let o=r.marks,s,i=[];for(;s=t.isInSet(o);)i.push(new It(e,s)),o=s.removeFromSet(o);for(let l=i.length-1;l>=0;l--)this.step(i[l])}return this}split(e,t=1,r){return ed(this,e,t,r),this}addMark(e,t,r){return qf(this,e,t,r),this}removeMark(e,t,r){return Hf(this,e,t,r),this}clearIncompatible(e,t,r){return xo(this,e,t,r),this}}const No=Object.create(null);class R{constructor(e,t,r){this.$anchor=e,this.$head=t,this.ranges=r||[new tl(e.min(t),e.max(t))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let t=0;t<e.length;t++)if(e[t].$from.pos!=e[t].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,t=N.empty){let r=t.content.lastChild,o=null;for(let l=0;l<t.openEnd;l++)o=r,r=r.lastChild;let s=e.steps.length,i=this.ranges;for(let l=0;l<i.length;l++){let{$from:a,$to:c}=i[l],u=e.mapping.slice(s);e.replaceRange(u.map(a.pos),u.map(c.pos),l?N.empty:t),l==0&&ol(e,s,(r?r.isInline:o&&o.isTextblock)?-1:1)}}replaceWith(e,t){let r=e.steps.length,o=this.ranges;for(let s=0;s<o.length;s++){let{$from:i,$to:l}=o[s],a=e.mapping.slice(r),c=a.map(i.pos),u=a.map(l.pos);s?e.deleteRange(c,u):(e.replaceRangeWith(c,u,t),ol(e,r,t.isInline?-1:1))}}static findFrom(e,t,r=!1){let o=e.parent.inlineContent?new P(e):nn(e.node(0),e.parent,e.pos,e.index(),t,r);if(o)return o;for(let s=e.depth-1;s>=0;s--){let i=t<0?nn(e.node(0),e.node(s),e.before(s+1),e.index(s),t,r):nn(e.node(0),e.node(s),e.after(s+1),e.index(s)+1,t,r);if(i)return i}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new ge(e.node(0))}static atStart(e){return nn(e,e,0,0,1)||new ge(e)}static atEnd(e){return nn(e,e,e.content.size,e.childCount,-1)||new ge(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=No[t.type];if(!r)throw new RangeError(`No selection type ${t.type} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in No)throw new RangeError("Duplicate use of selection JSON ID "+e);return No[e]=t,t.prototype.jsonID=e,t}getBookmark(){return P.between(this.$anchor,this.$head).getBookmark()}}R.prototype.visible=!0;class tl{constructor(e,t){this.$from=e,this.$to=t}}let nl=!1;function rl(n){!nl&&!n.parent.inlineContent&&(nl=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+n.parent.type.name+")"))}class P extends R{constructor(e,t=e){rl(e),rl(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let r=e.resolve(t.map(this.head));if(!r.parent.inlineContent)return R.near(r);let o=e.resolve(t.map(this.anchor));return new P(o.parent.inlineContent?o:r,r)}replace(e,t=N.empty){if(super.replace(e,t),t==N.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof P&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Sr(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if(typeof t.anchor!="number"||typeof t.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new P(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,r=t){let o=e.resolve(t);return new this(o,r==t?o:e.resolve(r))}static between(e,t,r){let o=e.pos-t.pos;if((!r||o)&&(r=o>=0?1:-1),!t.parent.inlineContent){let s=R.findFrom(t,r,!0)||R.findFrom(t,-r,!0);if(s)t=s.$head;else return R.near(t,r)}return e.parent.inlineContent||(o==0?e=t:(e=(R.findFrom(e,-r,!0)||R.findFrom(e,r,!0)).$anchor,e.pos<t.pos!=o<0&&(e=t))),new P(e,t)}}R.jsonID("text",P);class Sr{constructor(e,t){this.anchor=e,this.head=t}map(e){return new Sr(e.map(this.anchor),e.map(this.head))}resolve(e){return P.between(e.resolve(this.anchor),e.resolve(this.head))}}class D extends R{constructor(e){let t=e.nodeAfter,r=e.node(0).resolve(e.pos+t.nodeSize);super(e,r),this.node=t}map(e,t){let{deleted:r,pos:o}=t.mapResult(this.anchor),s=e.resolve(o);return r?R.near(s):new D(s)}content(){return new N(C.from(this.node),0,0)}eq(e){return e instanceof D&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new Eo(this.anchor)}static fromJSON(e,t){if(typeof t.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new D(e.resolve(t.anchor))}static create(e,t){return new D(e.resolve(t))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}D.prototype.visible=!1,R.jsonID("node",D);class Eo{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:r}=e.mapResult(this.anchor);return t?new Sr(r,r):new Eo(r)}resolve(e){let t=e.resolve(this.anchor),r=t.nodeAfter;return r&&D.isSelectable(r)?new D(t):R.near(t)}}class ge extends R{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=N.empty){if(t==N.empty){e.delete(0,e.doc.content.size);let r=R.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new ge(e)}map(e){return new ge(e)}eq(e){return e instanceof ge}getBookmark(){return ud}}R.jsonID("all",ge);const ud={map(){return this},resolve(n){return new ge(n)}};function nn(n,e,t,r,o,s=!1){if(e.inlineContent)return P.create(n,t);for(let i=r-(o>0?0:1);o>0?i<e.childCount:i>=0;i+=o){let l=e.child(i);if(l.isAtom){if(!s&&D.isSelectable(l))return D.create(n,t-(o<0?l.nodeSize:0))}else{let a=nn(n,l,t+o,o<0?l.childCount:0,o,s);if(a)return a}t+=l.nodeSize*o}return null}function ol(n,e,t){let r=n.steps.length-1;if(r<e)return;let o=n.steps[r];if(!(o instanceof se||o instanceof ee))return;let s=n.mapping.maps[r],i;s.forEach((l,a,c,u)=>{i==null&&(i=u)}),n.setSelection(R.near(n.doc.resolve(i),t))}const sl=1,il=2,ll=4;class fd extends el{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(e){if(e.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=(this.updated|sl)&-3,this.storedMarks=null,this}get selectionSet(){return(this.updated&sl)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=il,this}ensureMarks(e){return F.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&il)>0}addStep(e,t){super.addStep(e,t),this.updated=this.updated&-3,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let r=this.selection;return t&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||F.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,r){let o=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(o.text(e),!0):this.deleteSelection();{if(r==null&&(r=t),r=r??t,!e)return this.deleteRange(t,r);let s=this.storedMarks;if(!s){let i=this.doc.resolve(t);s=r==t?i.marks():i.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(t,r,o.text(e,s)),this.selection.empty||this.setSelection(R.near(this.selection.$to)),this}}setMeta(e,t){return this.meta[typeof e=="string"?e:e.key]=t,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|=ll,this}get scrolledIntoView(){return(this.updated&ll)>0}}function al(n,e){return!e||!n?n:n.bind(e)}class Pn{constructor(e,t,r){this.name=e,this.init=al(t.init,r),this.apply=al(t.apply,r)}}const dd=[new Pn("doc",{init(n){return n.doc||n.schema.topNodeType.createAndFill()},apply(n){return n.doc}}),new Pn("selection",{init(n,e){return n.selection||R.atStart(e.doc)},apply(n){return n.selection}}),new Pn("storedMarks",{init(n){return n.storedMarks||null},apply(n,e,t,r){return r.selection.$cursor?n.storedMarks:null}}),new Pn("scrollToSelection",{init(){return 0},apply(n,e){return n.scrolledIntoView?e+1:e}})];class Do{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=dd.slice(),t&&t.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 Pn(r.key,r.spec.state,r))})}}class Ge{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,t=-1){for(let r=0;r<this.config.plugins.length;r++)if(r!=t){let o=this.config.plugins[r];if(o.spec.filterTransaction&&!o.spec.filterTransaction.call(o,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let t=[e],r=this.applyInner(e),o=null;for(;;){let s=!1;for(let i=0;i<this.config.plugins.length;i++){let l=this.config.plugins[i];if(l.spec.appendTransaction){let a=o?o[i].n:0,c=o?o[i].state:this,u=a<t.length&&l.spec.appendTransaction.call(l,a?t.slice(a):t,c,r);if(u&&r.filterTransaction(u,i)){if(u.setMeta("appendedTransaction",e),!o){o=[];for(let f=0;f<this.config.plugins.length;f++)o.push(f<i?{state:r,n:t.length}:{state:this,n:0})}t.push(u),r=r.applyInner(u),s=!0}o&&(o[i]={state:r,n:t.length})}}if(!s)return{state:r,transactions:t}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let t=new Ge(this.config),r=this.config.fields;for(let o=0;o<r.length;o++){let s=r[o];t[s.name]=s.apply(e,this[s.name],this,t)}return t}get tr(){return new fd(this)}static create(e){let t=new Do(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new Ge(t);for(let o=0;o<t.fields.length;o++)r[t.fields[o].name]=t.fields[o].init(e,r);return r}reconfigure(e){let t=new Do(this.schema,e.plugins),r=t.fields,o=new Ge(t);for(let s=0;s<r.length;s++){let i=r[s].name;o[i]=this.hasOwnProperty(i)?this[i]:r[s].init(e,o)}return o}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map(r=>r.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 o=e[r],s=o.spec.state;s&&s.toJSON&&(t[r]=s.toJSON.call(o,this[o.key]))}return t}static fromJSON(e,t,r){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let o=new Do(e.schema,e.plugins),s=new Ge(o);return o.fields.forEach(i=>{if(i.name=="doc")s.doc=be.fromJSON(e.schema,t.doc);else if(i.name=="selection")s.selection=R.fromJSON(s.doc,t.selection);else if(i.name=="storedMarks")t.storedMarks&&(s.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let l in r){let a=r[l],c=a.spec.state;if(a.key==i.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(t,l)){s[i.name]=c.fromJSON.call(a,e,t[l],s);return}}s[i.name]=i.init(e,s)}}),s}}function cl(n,e,t){for(let r in n){let o=n[r];o instanceof Function?o=o.bind(e):r=="handleDOMEvents"&&(o=cl(o,e,{})),t[r]=o}return t}class Be{constructor(e){this.spec=e,this.props={},e.props&&cl(e.props,this,this.props),this.key=e.key?e.key.key:ul("plugin")}getState(e){return e[this.key]}}const Oo=Object.create(null);function ul(n){return n in Oo?n+"$"+ ++Oo[n]:(Oo[n]=0,n+"$")}class lt{constructor(e="key"){this.key=ul(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}var Cr=200,X=function(){};X.prototype.append=function(e){return e.length?(e=X.from(e),!this.length&&e||e.length<Cr&&this.leafAppend(e)||this.length<Cr&&e.leafPrepend(this)||this.appendInner(e)):this},X.prototype.prepend=function(e){return e.length?X.from(e).append(this):this},X.prototype.appendInner=function(e){return new hd(this,e)},X.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?X.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},X.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},X.prototype.forEach=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length),t<=r?this.forEachInner(e,t,r,0):this.forEachInvertedInner(e,t,r,0)},X.prototype.map=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length);var o=[];return this.forEach(function(s,i){return o.push(e(s,i))},t,r),o},X.from=function(e){return e instanceof X?e:e&&e.length?new fl(e):X.empty};var fl=function(n){function e(r){n.call(this),this.values=r}n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e;var t={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(o,s){return o==0&&s==this.length?this:new e(this.values.slice(o,s))},e.prototype.getInner=function(o){return this.values[o]},e.prototype.forEachInner=function(o,s,i,l){for(var a=s;a<i;a++)if(o(this.values[a],l+a)===!1)return!1},e.prototype.forEachInvertedInner=function(o,s,i,l){for(var a=s-1;a>=i;a--)if(o(this.values[a],l+a)===!1)return!1},e.prototype.leafAppend=function(o){if(this.length+o.length<=Cr)return new e(this.values.concat(o.flatten()))},e.prototype.leafPrepend=function(o){if(this.length+o.length<=Cr)return new e(o.flatten().concat(this.values))},t.length.get=function(){return this.values.length},t.depth.get=function(){return 0},Object.defineProperties(e.prototype,t),e}(X);X.empty=new fl([]);var hd=function(n){function e(t,r){n.call(this),this.left=t,this.right=r,this.length=t.length+r.length,this.depth=Math.max(t.depth,r.depth)+1}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(r){return r<this.left.length?this.left.get(r):this.right.get(r-this.left.length)},e.prototype.forEachInner=function(r,o,s,i){var l=this.left.length;if(o<l&&this.left.forEachInner(r,o,Math.min(s,l),i)===!1||s>l&&this.right.forEachInner(r,Math.max(o-l,0),Math.min(this.length,s)-l,i+l)===!1)return!1},e.prototype.forEachInvertedInner=function(r,o,s,i){var l=this.left.length;if(o>l&&this.right.forEachInvertedInner(r,o-l,Math.max(s,l)-l,i+l)===!1||s<l&&this.left.forEachInvertedInner(r,Math.min(o,l),s,i)===!1)return!1},e.prototype.sliceInner=function(r,o){if(r==0&&o==this.length)return this;var s=this.left.length;return o<=s?this.left.slice(r,o):r>=s?this.right.slice(r-s,o-s):this.left.slice(r,s).append(this.right.slice(0,o-s))},e.prototype.leafAppend=function(r){var o=this.right.leafAppend(r);if(o)return new e(this.left,o)},e.prototype.leafPrepend=function(r){var o=this.left.leafPrepend(r);if(o)return new e(o,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e}(X);const pd=500;class Pe{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let o,s;t&&(o=this.remapping(r,this.items.length),s=o.maps.length);let i=e.tr,l,a,c=[],u=[];return this.items.forEach((f,d)=>{if(!f.step){o||(o=this.remapping(r,d+1),s=o.maps.length),s--,u.push(f);return}if(o){u.push(new Fe(f.map));let h=f.step.map(o.slice(s)),p;h&&i.maybeStep(h).doc&&(p=i.mapping.maps[i.mapping.maps.length-1],c.push(new Fe(p,void 0,void 0,c.length+u.length))),s--,p&&o.appendMap(p,s)}else i.maybeStep(f.step);if(f.selection)return l=o?f.selection.map(o.slice(s)):f.selection,a=new Pe(this.items.slice(0,r).append(u.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:i,selection:l}}addTransform(e,t,r,o){let s=[],i=this.eventCount,l=this.items,a=!o&&l.length?l.get(l.length-1):null;for(let u=0;u<e.steps.length;u++){let f=e.steps[u].invert(e.docs[u]),d=new Fe(e.mapping.maps[u],f,t),h;(h=a&&a.merge(d))&&(d=h,u?s.pop():l=l.slice(0,l.length-1)),s.push(d),t&&(i++,t=void 0),o||(a=d)}let c=i-r.depth;return c>gd&&(l=md(l,c),i-=c),new Pe(l.append(s),i)}remapping(e,t){let r=new Dn;return this.items.forEach((o,s)=>{let i=o.mirrorOffset!=null&&s-o.mirrorOffset>=e?r.maps.length-o.mirrorOffset:void 0;r.appendMap(o.map,i)},e,t),r}addMaps(e){return this.eventCount==0?this:new Pe(this.items.append(e.map(t=>new Fe(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let r=[],o=Math.max(0,this.items.length-t),s=e.mapping,i=e.steps.length,l=this.eventCount;this.items.forEach(d=>{d.selection&&l--},o);let a=t;this.items.forEach(d=>{let h=s.getMirror(--a);if(h==null)return;i=Math.min(i,h);let p=s.maps[h];if(d.step){let b=e.steps[h].invert(e.docs[h]),g=d.selection&&d.selection.map(s.slice(a+1,h));g&&l++,r.push(new Fe(p,b,g))}else r.push(new Fe(p))},o);let c=[];for(let d=t;d<i;d++)c.push(new Fe(s.maps[d]));let u=this.items.slice(0,o).append(c).append(r),f=new Pe(u,l);return f.emptyItemCount()>pd&&(f=f.compress(this.items.length-r.length)),f}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),r=t.maps.length,o=[],s=0;return this.items.forEach((i,l)=>{if(l>=e)o.push(i),i.selection&&s++;else if(i.step){let a=i.step.map(t.slice(r)),c=a&&a.getMap();if(r--,c&&t.appendMap(c,r),a){let u=i.selection&&i.selection.map(t.slice(r));u&&s++;let f=new Fe(c.invert(),a,u),d,h=o.length-1;(d=o.length&&o[h].merge(f))?o[h]=d:o.push(f)}}else i.map&&r--},this.items.length,0),new Pe(X.from(o.reverse()),s)}}Pe.empty=new Pe(X.empty,0);function md(n,e){let t;return n.forEach((r,o)=>{if(r.selection&&e--==0)return t=o,!1}),n.slice(t)}class Fe{constructor(e,t,r,o){this.map=e,this.step=t,this.selection=r,this.mirrorOffset=o}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new Fe(t.getMap().invert(),t,this.selection)}}}class at{constructor(e,t,r,o,s){this.done=e,this.undone=t,this.prevRanges=r,this.prevTime=o,this.prevComposition=s}}const gd=20;function yd(n,e,t,r){let o=t.getMeta(ct),s;if(o)return o.historyState;t.getMeta(kd)&&(n=new at(n.done,n.undone,null,0,-1));let i=t.getMeta("appendedTransaction");if(t.steps.length==0)return n;if(i&&i.getMeta(ct))return i.getMeta(ct).redo?new at(n.done.addTransform(t,void 0,r,wr(e)),n.undone,dl(t.mapping.maps),n.prevTime,n.prevComposition):new at(n.done,n.undone.addTransform(t,void 0,r,wr(e)),null,n.prevTime,n.prevComposition);if(t.getMeta("addToHistory")!==!1&&!(i&&i.getMeta("addToHistory")===!1)){let l=t.getMeta("composition"),a=n.prevTime==0||!i&&n.prevComposition!=l&&(n.prevTime<(t.time||0)-r.newGroupDelay||!bd(t,n.prevRanges)),c=i?To(n.prevRanges,t.mapping):dl(t.mapping.maps);return new at(n.done.addTransform(t,a?e.selection.getBookmark():void 0,r,wr(e)),Pe.empty,c,t.time,l??n.prevComposition)}else return(s=t.getMeta("rebased"))?new at(n.done.rebased(t,s),n.undone.rebased(t,s),To(n.prevRanges,t.mapping),n.prevTime,n.prevComposition):new at(n.done.addMaps(t.mapping.maps),n.undone.addMaps(t.mapping.maps),To(n.prevRanges,t.mapping),n.prevTime,n.prevComposition)}function bd(n,e){if(!e)return!1;if(!n.docChanged)return!0;let t=!1;return n.mapping.maps[0].forEach((r,o)=>{for(let s=0;s<e.length;s+=2)r<=e[s+1]&&o>=e[s]&&(t=!0)}),t}function dl(n){let e=[];for(let t=n.length-1;t>=0&&e.length==0;t--)n[t].forEach((r,o,s,i)=>e.push(s,i));return e}function To(n,e){if(!n)return null;let t=[];for(let r=0;r<n.length;r+=2){let o=e.map(n[r],1),s=e.map(n[r+1],-1);o<=s&&t.push(o,s)}return t}function xd(n,e,t){let r=wr(e),o=ct.get(e).spec.config,s=(t?n.undone:n.done).popEvent(e,r);if(!s)return null;let i=s.selection.resolve(s.transform.doc),l=(t?n.done:n.undone).addTransform(s.transform,e.selection.getBookmark(),o,r),a=new at(t?l:s.remaining,t?s.remaining:l,null,0,-1);return s.transform.setSelection(i).setMeta(ct,{redo:t,historyState:a})}let vo=!1,hl=null;function wr(n){let e=n.plugins;if(hl!=e){vo=!1,hl=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){vo=!0;break}}return vo}const ct=new lt("history"),kd=new lt("closeHistory");function Sd(n={}){return n={depth:n.depth||100,newGroupDelay:n.newGroupDelay||500},new Be({key:ct,state:{init(){return new at(Pe.empty,Pe.empty,null,0,-1)},apply(e,t,r){return yd(t,r,e,n)}},config:n,props:{handleDOMEvents:{beforeinput(e,t){let r=t.inputType,o=r=="historyUndo"?Ao:r=="historyRedo"?Mr:null;return o?(t.preventDefault(),o(e.state,e.dispatch)):!1}}}})}function pl(n,e){return(t,r)=>{let o=ct.getState(t);if(!o||(n?o.undone:o.done).eventCount==0)return!1;if(r){let s=xd(o,t,n);s&&r(e?s.scrollIntoView():s)}return!0}}const Ao=pl(!1,!0),Mr=pl(!0,!0);function Po(n){let e=ct.getState(n);return e?e.done.eventCount:0}for(var ut={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},Nr={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Cd=typeof navigator<"u"&&/Mac/.test(navigator.platform),wd=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),te=0;te<10;te++)ut[48+te]=ut[96+te]=String(te);for(var te=1;te<=24;te++)ut[te+111]="F"+te;for(var te=65;te<=90;te++)ut[te]=String.fromCharCode(te+32),Nr[te]=String.fromCharCode(te);for(var Io in ut)Nr.hasOwnProperty(Io)||(Nr[Io]=ut[Io]);function Md(n){var e=Cd&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||wd&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?Nr:ut)[n.keyCode]||n.key||"Unidentified";return t=="Esc"&&(t="Escape"),t=="Del"&&(t="Delete"),t=="Left"&&(t="ArrowLeft"),t=="Up"&&(t="ArrowUp"),t=="Right"&&(t="ArrowRight"),t=="Down"&&(t="ArrowDown"),t}const Nd=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):!1;function Ed(n){let e=n.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");let r,o,s,i;for(let l=0;l<e.length-1;l++){let a=e[l];if(/^(cmd|meta|m)$/i.test(a))i=!0;else if(/^a(lt)?$/i.test(a))r=!0;else if(/^(c|ctrl|control)$/i.test(a))o=!0;else if(/^s(hift)?$/i.test(a))s=!0;else if(/^mod$/i.test(a))Nd?i=!0:o=!0;else throw new Error("Unrecognized modifier name: "+a)}return r&&(t="Alt-"+t),o&&(t="Ctrl-"+t),i&&(t="Meta-"+t),s&&(t="Shift-"+t),t}function Dd(n){let e=Object.create(null);for(let t in n)e[Ed(t)]=n[t];return e}function Vo(n,e,t=!0){return e.altKey&&(n="Alt-"+n),e.ctrlKey&&(n="Ctrl-"+n),e.metaKey&&(n="Meta-"+n),t&&e.shiftKey&&(n="Shift-"+n),n}function Ro(n){return new Be({props:{handleKeyDown:zo(n)}})}function zo(n){let e=Dd(n);return function(t,r){let o=Md(r),s,i=e[Vo(o,r)];if(i&&i(t.state,t.dispatch,t))return!0;if(o.length==1&&o!=" "){if(r.shiftKey){let l=e[Vo(o,r,!1)];if(l&&l(t.state,t.dispatch,t))return!0}if((r.shiftKey||r.altKey||r.metaKey||o.charCodeAt(0)>127)&&(s=ut[r.keyCode])&&s!=o){let l=e[Vo(s,r)];if(l&&l(t.state,t.dispatch,t))return!0}}return!1}}const ml=(n,e)=>n.selection.empty?!1:(e&&e(n.tr.deleteSelection().scrollIntoView()),!0);function Od(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("backward",n):t.parentOffset>0)?null:t}const Td=(n,e,t)=>{let r=Od(n,t);if(!r)return!1;let o=gl(r);if(!o){let i=r.blockRange(),l=i&&On(i);return l==null?!1:(e&&e(n.tr.lift(i,l).scrollIntoView()),!0)}let s=o.nodeBefore;if(kl(n,o,e,-1))return!0;if(r.parent.content.size==0&&(rn(s,"end")||D.isSelectable(s)))for(let i=r.depth;;i--){let l=Co(n.doc,r.before(i),r.after(i),N.empty);if(l&&l.slice.size<l.to-l.from){if(e){let a=n.tr.step(l);a.setSelection(rn(s,"end")?R.findFrom(a.doc.resolve(a.mapping.map(o.pos,-1)),-1):D.create(a.doc,o.pos-s.nodeSize)),e(a.scrollIntoView())}return!0}if(i==1||r.node(i-1).childCount>1)break}return s.isAtom&&o.depth==r.depth-1?(e&&e(n.tr.delete(o.pos-s.nodeSize,o.pos).scrollIntoView()),!0):!1};function rn(n,e,t=!1){for(let r=n;r;r=e=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(t&&r.childCount!=1)return!1}return!1}const vd=(n,e,t)=>{let{$head:r,empty:o}=n.selection,s=r;if(!o)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("backward",n):r.parentOffset>0)return!1;s=gl(r)}let i=s&&s.nodeBefore;return!i||!D.isSelectable(i)?!1:(e&&e(n.tr.setSelection(D.create(n.doc,s.pos-i.nodeSize)).scrollIntoView()),!0)};function gl(n){if(!n.parent.type.spec.isolating)for(let e=n.depth-1;e>=0;e--){if(n.index(e)>0)return n.doc.resolve(n.before(e+1));if(n.node(e).type.spec.isolating)break}return null}function Ad(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("forward",n):t.parentOffset<t.parent.content.size)?null:t}const Pd=(n,e,t)=>{let r=Ad(n,t);if(!r)return!1;let o=yl(r);if(!o)return!1;let s=o.nodeAfter;if(kl(n,o,e,1))return!0;if(r.parent.content.size==0&&(rn(s,"start")||D.isSelectable(s))){let i=Co(n.doc,r.before(),r.after(),N.empty);if(i&&i.slice.size<i.to-i.from){if(e){let l=n.tr.step(i);l.setSelection(rn(s,"start")?R.findFrom(l.doc.resolve(l.mapping.map(o.pos)),1):D.create(l.doc,l.mapping.map(o.pos))),e(l.scrollIntoView())}return!0}}return s.isAtom&&o.depth==r.depth-1?(e&&e(n.tr.delete(o.pos,o.pos+s.nodeSize).scrollIntoView()),!0):!1},Id=(n,e,t)=>{let{$head:r,empty:o}=n.selection,s=r;if(!o)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("forward",n):r.parentOffset<r.parent.content.size)return!1;s=yl(r)}let i=s&&s.nodeAfter;return!i||!D.isSelectable(i)?!1:(e&&e(n.tr.setSelection(D.create(n.doc,s.pos)).scrollIntoView()),!0)};function yl(n){if(!n.parent.type.spec.isolating)for(let e=n.depth-1;e>=0;e--){let t=n.node(e);if(n.index(e)+1<t.childCount)return n.doc.resolve(n.after(e+1));if(t.type.spec.isolating)break}return null}const bl=(n,e)=>{let t=n.selection,r=t instanceof D,o;if(r){if(t.node.isTextblock||!Zt(n.doc,t.from))return!1;o=t.from}else if(o=Gi(n.doc,t.from,-1),o==null)return!1;if(e){let s=n.tr.join(o);r&&s.setSelection(D.create(s.doc,o-n.doc.resolve(o).nodeBefore.nodeSize)),e(s.scrollIntoView())}return!0},Vd=(n,e)=>{let t=n.selection,r;if(t instanceof D){if(t.node.isTextblock||!Zt(n.doc,t.to))return!1;r=t.to}else if(r=Gi(n.doc,t.to,1),r==null)return!1;return e&&e(n.tr.join(r).scrollIntoView()),!0},$o=(n,e)=>{let{$from:t,$to:r}=n.selection,o=t.blockRange(r),s=o&&On(o);return s==null?!1:(e&&e(n.tr.lift(o,s).scrollIntoView()),!0)},Rd=(n,e)=>{let{$head:t,$anchor:r}=n.selection;return!t.parent.type.spec.code||!t.sameParent(r)?!1:(e&&e(n.tr.insertText(`
|
|
37
|
+
`).scrollIntoView()),!0)};function jo(n){for(let e=0;e<n.edgeCount;e++){let{type:t}=n.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}const xl=(n,e)=>{let{$head:t,$anchor:r}=n.selection;if(!t.parent.type.spec.code||!t.sameParent(r))return!1;let o=t.node(-1),s=t.indexAfter(-1),i=jo(o.contentMatchAt(s));if(!i||!o.canReplaceWith(s,s,i))return!1;if(e){let l=t.after(),a=n.tr.replaceWith(l,l,i.createAndFill());a.setSelection(R.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},zd=(n,e)=>{let t=n.selection,{$from:r,$to:o}=t;if(t instanceof ge||r.parent.inlineContent||o.parent.inlineContent)return!1;let s=jo(o.parent.contentMatchAt(o.indexAfter()));if(!s||!s.isTextblock)return!1;if(e){let i=(!r.parentOffset&&o.index()<o.parent.childCount?r:o).pos,l=n.tr.insert(i,s.createAndFill());l.setSelection(P.create(l.doc,i+1)),e(l.scrollIntoView())}return!0},$d=(n,e)=>{let{$cursor:t}=n.selection;if(!t||t.parent.content.size)return!1;if(t.depth>1&&t.after()!=t.end(-1)){let s=t.before();if(Qt(n.doc,s))return e&&e(n.tr.split(s).scrollIntoView()),!0}let r=t.blockRange(),o=r&&On(r);return o==null?!1:(e&&e(n.tr.lift(r,o).scrollIntoView()),!0)};function jd(n){return(e,t)=>{let{$from:r,$to:o}=e.selection;if(e.selection instanceof D&&e.selection.node.isBlock)return!r.parentOffset||!Qt(e.doc,r.pos)?!1:(t&&t(e.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let s=[],i,l,a=!1,c=!1;for(let h=r.depth;;h--)if(r.node(h).isBlock){a=r.end(h)==r.pos+(r.depth-h),c=r.start(h)==r.pos-(r.depth-h),l=jo(r.node(h-1).contentMatchAt(r.indexAfter(h-1))),s.unshift(a&&l?{type:l}:null),i=h;break}else{if(h==1)return!1;s.unshift(null)}let u=e.tr;(e.selection instanceof P||e.selection instanceof ge)&&u.deleteSelection();let f=u.mapping.map(r.pos),d=Qt(u.doc,f,s.length,s);if(d||(s[0]=l?{type:l}:null,d=Qt(u.doc,f,s.length,s)),!d)return!1;if(u.split(f,s.length,s),!a&&c&&r.node(i).type!=l){let h=u.mapping.map(r.before(i)),p=u.doc.resolve(h);l&&r.node(i-1).canReplaceWith(p.index(),p.index()+1,l)&&u.setNodeMarkup(u.mapping.map(r.before(i)),l)}return t&&t(u.scrollIntoView()),!0}}const Bd=jd(),Bo=(n,e)=>{let{$from:t,to:r}=n.selection,o,s=t.sharedDepth(r);return s==0?!1:(o=t.before(s),e&&e(n.tr.setSelection(D.create(n.doc,o))),!0)},Fd=(n,e)=>(e&&e(n.tr.setSelection(new ge(n.doc))),!0);function Ld(n,e,t){let r=e.nodeBefore,o=e.nodeAfter,s=e.index();return!r||!o||!r.type.compatibleContent(o.type)?!1:!r.content.size&&e.parent.canReplace(s-1,s)?(t&&t(n.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(s,s+1)||!(o.isTextblock||Zt(n.doc,e.pos))?!1:(t&&t(n.tr.join(e.pos).scrollIntoView()),!0)}function kl(n,e,t,r){let o=e.nodeBefore,s=e.nodeAfter,i,l,a=o.type.spec.isolating||s.type.spec.isolating;if(!a&&Ld(n,e,t))return!0;let c=!a&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(i=(l=o.contentMatchAt(o.childCount)).findWrapping(s.type))&&l.matchType(i[0]||s.type).validEnd){if(t){let h=e.pos+s.nodeSize,p=C.empty;for(let k=i.length-1;k>=0;k--)p=C.from(i[k].create(null,p));p=C.from(o.copy(p));let b=n.tr.step(new ee(e.pos-1,h,e.pos,h,new N(p,1,0),i.length,!0)),g=b.doc.resolve(h+2*i.length);g.nodeAfter&&g.nodeAfter.type==o.type&&Zt(b.doc,g.pos)&&b.join(g.pos),t(b.scrollIntoView())}return!0}let u=s.type.spec.isolating||r>0&&a?null:R.findFrom(e,1),f=u&&u.$from.blockRange(u.$to),d=f&&On(f);if(d!=null&&d>=e.depth)return t&&t(n.tr.lift(f,d).scrollIntoView()),!0;if(c&&rn(s,"start",!0)&&rn(o,"end")){let h=o,p=[];for(;p.push(h),!h.isTextblock;)h=h.lastChild;let b=s,g=1;for(;!b.isTextblock;b=b.firstChild)g++;if(h.canReplace(h.childCount,h.childCount,b.content)){if(t){let k=C.empty;for(let M=p.length-1;M>=0;M--)k=C.from(p[M].copy(k));let S=n.tr.step(new ee(e.pos-p.length,e.pos+s.nodeSize,e.pos+g,e.pos+s.nodeSize-g,new N(k,p.length,0),0,!0));t(S.scrollIntoView())}return!0}}return!1}function Sl(n){return function(e,t){let r=e.selection,o=n<0?r.$from:r.$to,s=o.depth;for(;o.node(s).isInline;){if(!s)return!1;s--}return o.node(s).isTextblock?(t&&t(e.tr.setSelection(P.create(e.doc,n<0?o.start(s):o.end(s)))),!0):!1}}const Wd=Sl(-1),_d=Sl(1);function Cl(n,e=null){return function(t,r){let{$from:o,$to:s}=t.selection,i=o.blockRange(s),l=i&&ko(i,n,e);return l?(r&&r(t.tr.wrap(i,l).scrollIntoView()),!0):!1}}function on(n,e=null){return function(t,r){let o=!1;for(let s=0;s<t.selection.ranges.length&&!o;s++){let{$from:{pos:i},$to:{pos:l}}=t.selection.ranges[s];t.doc.nodesBetween(i,l,(a,c)=>{if(o)return!1;if(!(!a.isTextblock||a.hasMarkup(n,e)))if(a.type==n)o=!0;else{let u=t.doc.resolve(c),f=u.index();o=u.parent.canReplaceWith(f,f+1,n)}})}if(!o)return!1;if(r){let s=t.tr;for(let i=0;i<t.selection.ranges.length;i++){let{$from:{pos:l},$to:{pos:a}}=t.selection.ranges[i];s.setBlockType(l,a,n,e)}r(s.scrollIntoView())}return!0}}function qd(n,e,t,r){for(let o=0;o<e.length;o++){let{$from:s,$to:i}=e[o],l=s.depth==0?n.inlineContent&&n.type.allowsMarkType(t):!1;if(n.nodesBetween(s.pos,i.pos,(a,c)=>{if(l)return!1;l=a.inlineContent&&a.type.allowsMarkType(t)}),l)return!0}return!1}function ke(n,e=null,t){return function(r,o){let{empty:s,$cursor:i,ranges:l}=r.selection;if(s&&!i||!qd(r.doc,l,n))return!1;if(o)if(i)n.isInSet(r.storedMarks||i.marks())?o(r.tr.removeStoredMark(n)):o(r.tr.addStoredMark(n.create(e)));else{let a,c=r.tr;a=!l.some(u=>r.doc.rangeHasMark(u.$from.pos,u.$to.pos,n));for(let u=0;u<l.length;u++){let{$from:f,$to:d}=l[u];if(!a)c.removeMark(f.pos,d.pos,n);else{let h=f.pos,p=d.pos,b=f.nodeAfter,g=d.nodeBefore,k=b&&b.isText?/^\s*/.exec(b.text)[0].length:0,S=g&&g.isText?/\s*$/.exec(g.text)[0].length:0;h+k<p&&(h+=k,p-=S),c.addMark(h,p,n.create(e))}}o(c.scrollIntoView())}return!0}}function Er(...n){return function(e,t,r){for(let o=0;o<n.length;o++)if(n[o](e,t,r))return!0;return!1}}let Fo=Er(ml,Td,vd),wl=Er(ml,Pd,Id);const Xe={Enter:Er(Rd,zd,$d,Bd),"Mod-Enter":xl,Backspace:Fo,"Mod-Backspace":Fo,"Shift-Backspace":Fo,Delete:wl,"Mod-Delete":wl,"Mod-a":Fd},Ml={"Ctrl-h":Xe.Backspace,"Alt-Backspace":Xe["Mod-Backspace"],"Ctrl-d":Xe.Delete,"Ctrl-Alt-Backspace":Xe["Mod-Delete"],"Alt-Delete":Xe["Mod-Delete"],"Alt-d":Xe["Mod-Delete"],"Ctrl-a":Wd,"Ctrl-e":_d};for(let n in Xe)Ml[n]=Xe[n];const Hd=(typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform?os.platform()=="darwin":!1)?Ml:Xe;function Kd(n={}){return new Be({view(e){return new Jd(e,n)}})}class Jd{constructor(e,t){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=t.width)!==null&&r!==void 0?r:1,this.color=t.color===!1?void 0:t.color||"black",this.class=t.class,this.handlers=["dragover","dragend","drop","dragleave"].map(o=>{let s=i=>{this[o](i)};return e.dom.addEventListener(o,s),{name:o,handler:s}})}destroy(){this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){this.cursorPos!=null&&t.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),t=!e.parent.inlineContent,r,o=this.editorView.dom,s=o.getBoundingClientRect(),i=s.width/o.offsetWidth,l=s.height/o.offsetHeight;if(t){let f=e.nodeBefore,d=e.nodeAfter;if(f||d){let h=this.editorView.nodeDOM(this.cursorPos-(f?f.nodeSize:0));if(h){let p=h.getBoundingClientRect(),b=f?p.bottom:p.top;f&&d&&(b=(b+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let g=this.width/2*l;r={left:p.left,right:p.right,top:b-g,bottom:b+g}}}}if(!r){let f=this.editorView.coordsAtPos(this.cursorPos),d=this.width/2*i;r={left:f.left-d,right:f.left+d,top:f.top,bottom:f.bottom}}let a=this.editorView.dom.offsetParent;this.element||(this.element=a.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",t),this.element.classList.toggle("prosemirror-dropcursor-inline",!t);let c,u;if(!a||a==document.body&&getComputedStyle(a).position=="static")c=-pageXOffset,u=-pageYOffset;else{let f=a.getBoundingClientRect(),d=f.width/a.offsetWidth,h=f.height/a.offsetHeight;c=f.left-a.scrollLeft*d,u=f.top-a.scrollTop*h}this.element.style.left=(r.left-c)/i+"px",this.element.style.top=(r.top-u)/l+"px",this.element.style.width=(r.right-r.left)/i+"px",this.element.style.height=(r.bottom-r.top)/l+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),o=r&&r.type.spec.disableDropCursor,s=typeof o=="function"?o(this.editorView,t,e):o;if(t&&!s){let i=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=So(this.editorView.state.doc,i,this.editorView.dragging.slice);l!=null&&(i=l)}this.setCursor(i),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}const ne=function(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e},In=function(n){let e=n.assignedSlot||n.parentNode;return e&&e.nodeType==11?e.host:e};let Lo=null;const Ue=function(n,e,t){let r=Lo||(Lo=document.createRange());return r.setEnd(n,t??n.nodeValue.length),r.setStart(n,e||0),r},Yd=function(){Lo=null},Vt=function(n,e,t,r){return t&&(Nl(n,e,t,r,-1)||Nl(n,e,t,r,1))},Gd=/^(img|br|input|textarea|hr)$/i;function Nl(n,e,t,r,o){for(;;){if(n==t&&e==r)return!0;if(e==(o<0?0:Me(n))){let s=n.parentNode;if(!s||s.nodeType!=1||Vn(n)||Gd.test(n.nodeName)||n.contentEditable=="false")return!1;e=ne(n)+(o<0?0:1),n=s}else if(n.nodeType==1){if(n=n.childNodes[e+(o<0?-1:0)],n.contentEditable=="false")return!1;e=o<0?Me(n):0}else return!1}}function Me(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Xd(n,e){for(;;){if(n.nodeType==3&&e)return n;if(n.nodeType==1&&e>0){if(n.contentEditable=="false")return null;n=n.childNodes[e-1],e=Me(n)}else if(n.parentNode&&!Vn(n))e=ne(n),n=n.parentNode;else return null}}function Ud(n,e){for(;;){if(n.nodeType==3&&e<n.nodeValue.length)return n;if(n.nodeType==1&&e<n.childNodes.length){if(n.contentEditable=="false")return null;n=n.childNodes[e],e=0}else if(n.parentNode&&!Vn(n))e=ne(n)+1,n=n.parentNode;else return null}}function Qd(n,e,t){for(let r=e==0,o=e==Me(n);r||o;){if(n==t)return!0;let s=ne(n);if(n=n.parentNode,!n)return!1;r=r&&s==0,o=o&&s==Me(n)}}function Vn(n){let e;for(let t=n;t&&!(e=t.pmViewDesc);t=t.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==n||e.contentDOM==n)}const Dr=function(n){return n.focusNode&&Vt(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)};function Rt(n,e){let t=document.createEvent("Event");return t.initEvent("keydown",!0,!0),t.keyCode=n,t.key=t.code=e,t}function Zd(n){let e=n.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function eh(n,e,t){if(n.caretPositionFromPoint)try{let r=n.caretPositionFromPoint(e,t);if(r)return{node:r.offsetNode,offset:Math.min(Me(r.offsetNode),r.offset)}}catch{}if(n.caretRangeFromPoint){let r=n.caretRangeFromPoint(e,t);if(r)return{node:r.startContainer,offset:Math.min(Me(r.startContainer),r.startOffset)}}}const Le=typeof navigator<"u"?navigator:null,El=typeof document<"u"?document:null,ft=Le&&Le.userAgent||"",Wo=/Edge\/(\d+)/.exec(ft),Dl=/MSIE \d/.exec(ft),_o=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(ft),ye=!!(Dl||_o||Wo),dt=Dl?document.documentMode:_o?+_o[1]:Wo?+Wo[1]:0,Ie=!ye&&/gecko\/(\d+)/i.test(ft);Ie&&+(/Firefox\/(\d+)/.exec(ft)||[0,0])[1];const qo=!ye&&/Chrome\/(\d+)/.exec(ft),ie=!!qo,Ol=qo?+qo[1]:0,ue=!ye&&!!Le&&/Apple Computer/.test(Le.vendor),sn=ue&&(/Mobile\/\w+/.test(ft)||!!Le&&Le.maxTouchPoints>2),Ne=sn||(Le?/Mac/.test(Le.platform):!1),th=Le?/Win/.test(Le.platform):!1,Qe=/Android \d/.test(ft),Rn=!!El&&"webkitFontSmoothing"in El.documentElement.style,nh=Rn?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function rh(n){let e=n.defaultView&&n.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:n.documentElement.clientWidth,top:0,bottom:n.documentElement.clientHeight}}function Ze(n,e){return typeof n=="number"?n:n[e]}function oh(n){let e=n.getBoundingClientRect(),t=e.width/n.offsetWidth||1,r=e.height/n.offsetHeight||1;return{left:e.left,right:e.left+n.clientWidth*t,top:e.top,bottom:e.top+n.clientHeight*r}}function Tl(n,e,t){let r=n.someProp("scrollThreshold")||0,o=n.someProp("scrollMargin")||5,s=n.dom.ownerDocument;for(let i=t||n.dom;i;i=In(i)){if(i.nodeType!=1)continue;let l=i,a=l==s.body,c=a?rh(s):oh(l),u=0,f=0;if(e.top<c.top+Ze(r,"top")?f=-(c.top-e.top+Ze(o,"top")):e.bottom>c.bottom-Ze(r,"bottom")&&(f=e.bottom-e.top>c.bottom-c.top?e.top+Ze(o,"top")-c.top:e.bottom-c.bottom+Ze(o,"bottom")),e.left<c.left+Ze(r,"left")?u=-(c.left-e.left+Ze(o,"left")):e.right>c.right-Ze(r,"right")&&(u=e.right-c.right+Ze(o,"right")),u||f)if(a)s.defaultView.scrollBy(u,f);else{let d=l.scrollLeft,h=l.scrollTop;f&&(l.scrollTop+=f),u&&(l.scrollLeft+=u);let p=l.scrollLeft-d,b=l.scrollTop-h;e={left:e.left-p,top:e.top-b,right:e.right-p,bottom:e.bottom-b}}if(a||/^(fixed|sticky)$/.test(getComputedStyle(i).position))break}}function sh(n){let e=n.dom.getBoundingClientRect(),t=Math.max(0,e.top),r,o;for(let s=(e.left+e.right)/2,i=t+1;i<Math.min(innerHeight,e.bottom);i+=5){let l=n.root.elementFromPoint(s,i);if(!l||l==n.dom||!n.dom.contains(l))continue;let a=l.getBoundingClientRect();if(a.top>=t-20){r=l,o=a.top;break}}return{refDOM:r,refTop:o,stack:vl(n.dom)}}function vl(n){let e=[],t=n.ownerDocument;for(let r=n;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),n!=t);r=In(r));return e}function ih({refDOM:n,refTop:e,stack:t}){let r=n?n.getBoundingClientRect().top:0;Al(t,r==0?0:r-e)}function Al(n,e){for(let t=0;t<n.length;t++){let{dom:r,top:o,left:s}=n[t];r.scrollTop!=o+e&&(r.scrollTop=o+e),r.scrollLeft!=s&&(r.scrollLeft=s)}}let ln=null;function lh(n){if(n.setActive)return n.setActive();if(ln)return n.focus(ln);let e=vl(n);n.focus(ln==null?{get preventScroll(){return ln={preventScroll:!0},!0}}:void 0),ln||(ln=!1,Al(e,0))}function Pl(n,e){let t,r=2e8,o,s=0,i=e.top,l=e.top,a,c;for(let u=n.firstChild,f=0;u;u=u.nextSibling,f++){let d;if(u.nodeType==1)d=u.getClientRects();else if(u.nodeType==3)d=Ue(u).getClientRects();else continue;for(let h=0;h<d.length;h++){let p=d[h];if(p.top<=i&&p.bottom>=l){i=Math.max(p.bottom,i),l=Math.min(p.top,l);let b=p.left>e.left?p.left-e.left:p.right<e.left?e.left-p.right:0;if(b<r){t=u,r=b,o=b&&t.nodeType==3?{left:p.right<e.left?p.right:p.left,top:e.top}:e,u.nodeType==1&&b&&(s=f+(e.left>=(p.left+p.right)/2?1:0));continue}}else p.top>e.top&&!a&&p.left<=e.left&&p.right>=e.left&&(a=u,c={left:Math.max(p.left,Math.min(p.right,e.left)),top:p.top});!t&&(e.left>=p.right&&e.top>=p.top||e.left>=p.left&&e.top>=p.bottom)&&(s=f+1)}}return!t&&a&&(t=a,o=c,r=0),t&&t.nodeType==3?ah(t,o):!t||r&&t.nodeType==1?{node:n,offset:s}:Pl(t,o)}function ah(n,e){let t=n.nodeValue.length,r=document.createRange();for(let o=0;o<t;o++){r.setEnd(n,o+1),r.setStart(n,o);let s=ht(r,1);if(s.top!=s.bottom&&Ho(e,s))return{node:n,offset:o+(e.left>=(s.left+s.right)/2?1:0)}}return{node:n,offset:0}}function Ho(n,e){return n.left>=e.left-1&&n.left<=e.right+1&&n.top>=e.top-1&&n.top<=e.bottom+1}function ch(n,e){let t=n.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left<n.getBoundingClientRect().left?t:n}function uh(n,e,t){let{node:r,offset:o}=Pl(e,t),s=-1;if(r.nodeType==1&&!r.firstChild){let i=r.getBoundingClientRect();s=i.left!=i.right&&t.left>(i.left+i.right)/2?1:-1}return n.docView.posFromDOM(r,o,s)}function fh(n,e,t,r){let o=-1;for(let s=e,i=!1;s!=n.dom;){let l=n.docView.nearestDesc(s,!0),a;if(!l)return null;if(l.dom.nodeType==1&&(l.node.isBlock&&l.parent||!l.contentDOM)&&((a=l.dom.getBoundingClientRect()).width||a.height)&&(l.node.isBlock&&l.parent&&(!i&&a.left>r.left||a.top>r.top?o=l.posBefore:(!i&&a.right<r.left||a.bottom<r.top)&&(o=l.posAfter),i=!0),!l.contentDOM&&o<0&&!l.node.isText))return(l.node.isBlock?r.top<(a.top+a.bottom)/2:r.left<(a.left+a.right)/2)?l.posBefore:l.posAfter;s=l.dom.parentNode}return o>-1?o:n.docView.posFromDOM(e,t,-1)}function Il(n,e,t){let r=n.childNodes.length;if(r&&t.top<t.bottom)for(let o=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-t.top)/(t.bottom-t.top))-2)),s=o;;){let i=n.childNodes[s];if(i.nodeType==1){let l=i.getClientRects();for(let a=0;a<l.length;a++){let c=l[a];if(Ho(e,c))return Il(i,e,c)}}if((s=(s+1)%r)==o)break}return n}function dh(n,e){let t=n.dom.ownerDocument,r,o=0,s=eh(t,e.left,e.top);s&&({node:r,offset:o}=s);let i=(n.root.elementFromPoint?n.root:t).elementFromPoint(e.left,e.top),l;if(!i||!n.dom.contains(i.nodeType!=1?i.parentNode:i)){let c=n.dom.getBoundingClientRect();if(!Ho(e,c)||(i=Il(n.dom,e,c),!i))return null}if(ue)for(let c=i;r&&c;c=In(c))c.draggable&&(r=void 0);if(i=ch(i,e),r){if(Ie&&r.nodeType==1&&(o=Math.min(o,r.childNodes.length),o<r.childNodes.length)){let u=r.childNodes[o],f;u.nodeName=="IMG"&&(f=u.getBoundingClientRect()).right<=e.left&&f.bottom>e.top&&o++}let c;Rn&&o&&r.nodeType==1&&(c=r.childNodes[o-1]).nodeType==1&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=e.top&&o--,r==n.dom&&o==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?l=n.state.doc.content.size:(o==0||r.nodeType!=1||r.childNodes[o-1].nodeName!="BR")&&(l=fh(n,r,o,e))}l==null&&(l=uh(n,i,e));let a=n.docView.nearestDesc(i,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function Vl(n){return n.top<n.bottom||n.left<n.right}function ht(n,e){let t=n.getClientRects();if(t.length){let r=t[e<0?0:t.length-1];if(Vl(r))return r}return Array.prototype.find.call(t,Vl)||n.getBoundingClientRect()}const hh=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function Rl(n,e,t){let{node:r,offset:o,atom:s}=n.docView.domFromPos(e,t<0?-1:1),i=Rn||Ie;if(r.nodeType==3)if(i&&(hh.test(r.nodeValue)||(t<0?!o:o==r.nodeValue.length))){let a=ht(Ue(r,o,o),t);if(Ie&&o&&/\s/.test(r.nodeValue[o-1])&&o<r.nodeValue.length){let c=ht(Ue(r,o-1,o-1),-1);if(c.top==a.top){let u=ht(Ue(r,o,o+1),-1);if(u.top!=a.top)return zn(u,u.left<c.left)}}return a}else{let a=o,c=o,u=t<0?1:-1;return t<0&&!o?(c++,u=-1):t>=0&&o==r.nodeValue.length?(a--,u=1):t<0?a--:c++,zn(ht(Ue(r,a,c),u),u<0)}if(!n.state.doc.resolve(e-(s||0)).parent.inlineContent){if(s==null&&o&&(t<0||o==Me(r))){let a=r.childNodes[o-1];if(a.nodeType==1)return Ko(a.getBoundingClientRect(),!1)}if(s==null&&o<Me(r)){let a=r.childNodes[o];if(a.nodeType==1)return Ko(a.getBoundingClientRect(),!0)}return Ko(r.getBoundingClientRect(),t>=0)}if(s==null&&o&&(t<0||o==Me(r))){let a=r.childNodes[o-1],c=a.nodeType==3?Ue(a,Me(a)-(i?0:1)):a.nodeType==1&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(c)return zn(ht(c,1),!1)}if(s==null&&o<Me(r)){let a=r.childNodes[o];for(;a.pmViewDesc&&a.pmViewDesc.ignoreForCoords;)a=a.nextSibling;let c=a?a.nodeType==3?Ue(a,0,i?0:1):a.nodeType==1?a:null:null;if(c)return zn(ht(c,-1),!0)}return zn(ht(r.nodeType==3?Ue(r):r,-t),t>=0)}function zn(n,e){if(n.width==0)return n;let t=e?n.left:n.right;return{top:n.top,bottom:n.bottom,left:t,right:t}}function Ko(n,e){if(n.height==0)return n;let t=e?n.top:n.bottom;return{top:t,bottom:t,left:n.left,right:n.right}}function zl(n,e,t){let r=n.state,o=n.root.activeElement;r!=e&&n.updateState(e),o!=n.dom&&n.focus();try{return t()}finally{r!=e&&n.updateState(r),o!=n.dom&&o&&o.focus()}}function ph(n,e,t){let r=e.selection,o=t=="up"?r.$from:r.$to;return zl(n,e,()=>{let{node:s}=n.docView.domFromPos(o.pos,t=="up"?-1:1);for(;;){let l=n.docView.nearestDesc(s,!0);if(!l)break;if(l.node.isBlock){s=l.contentDOM||l.dom;break}s=l.dom.parentNode}let i=Rl(n,o.pos,1);for(let l=s.firstChild;l;l=l.nextSibling){let a;if(l.nodeType==1)a=l.getClientRects();else if(l.nodeType==3)a=Ue(l,0,l.nodeValue.length).getClientRects();else continue;for(let c=0;c<a.length;c++){let u=a[c];if(u.bottom>u.top+1&&(t=="up"?i.top-u.top>(u.bottom-i.top)*2:u.bottom-i.bottom>(i.bottom-u.top)*2))return!1}}return!0})}const mh=/[\u0590-\u08ac]/;function gh(n,e,t){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let o=r.parentOffset,s=!o,i=o==r.parent.content.size,l=n.domSelection();return l?!mh.test(r.parent.textContent)||!l.modify?t=="left"||t=="backward"?s:i:zl(n,e,()=>{let{focusNode:a,focusOffset:c,anchorNode:u,anchorOffset:f}=n.domSelectionRange(),d=l.caretBidiLevel;l.modify("move",t,"character");let h=r.depth?n.docView.domAfterPos(r.before()):n.dom,{focusNode:p,focusOffset:b}=n.domSelectionRange(),g=p&&!h.contains(p.nodeType==1?p:p.parentNode)||a==p&&c==b;try{l.collapse(u,f),a&&(a!=u||c!=f)&&l.extend&&l.extend(a,c)}catch{}return d!=null&&(l.caretBidiLevel=d),g}):r.pos==r.start()||r.pos==r.end()}let $l=null,jl=null,Bl=!1;function yh(n,e,t){return $l==e&&jl==t?Bl:($l=e,jl=t,Bl=t=="up"||t=="down"?ph(n,e,t):gh(n,e,t))}const Ee=0,Fl=1,zt=2,We=3;let $n=class{constructor(e,t,r,o){this.parent=e,this.children=t,this.dom=r,this.contentDOM=o,this.dirty=Ee,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,r){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;t<this.children.length;t++)e+=this.children[t].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let t=0,r=this.posAtStart;;t++){let o=this.children[t];if(o==e)return r;r+=o.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,t,r){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(r<0){let s,i;if(e==this.contentDOM)s=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;s=e.previousSibling}for(;s&&!((i=s.pmViewDesc)&&i.parent==this);)s=s.previousSibling;return s?this.posBeforeChild(i)+i.size:this.posAtStart}else{let s,i;if(e==this.contentDOM)s=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;s=e.nextSibling}for(;s&&!((i=s.pmViewDesc)&&i.parent==this);)s=s.nextSibling;return s?this.posBeforeChild(i):this.posAtEnd}let o;if(e==this.dom&&this.contentDOM)o=t>ne(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))o=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(t==0)for(let s=e;;s=s.parentNode){if(s==this.dom){o=!1;break}if(s.previousSibling)break}if(o==null&&t==e.childNodes.length)for(let s=e;;s=s.parentNode){if(s==this.dom){o=!0;break}if(s.nextSibling)break}}return o??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let r=!0,o=e;o;o=o.parentNode){let s=this.getDesc(o),i;if(s&&(!t||s.node))if(r&&(i=s.nodeDOM)&&!(i.nodeType==1?i.contains(e.nodeType==1?e:e.parentNode):i==e))r=!1;else return s}}getDesc(e){let t=e.pmViewDesc;for(let r=t;r;r=r.parent)if(r==this)return t}posFromDOM(e,t,r){for(let o=e;o;o=o.parentNode){let s=this.getDesc(o);if(s)return s.localPosFromDOM(e,t,r)}return-1}descAt(e){for(let t=0,r=0;t<this.children.length;t++){let o=this.children[t],s=r+o.size;if(r==e&&s!=r){for(;!o.border&&o.children.length;)o=o.children[0];return o}if(e<s)return o.descAt(e-r-o.border);r=s}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let r=0,o=0;for(let s=0;r<this.children.length;r++){let i=this.children[r],l=s+i.size;if(l>e||i instanceof ql){o=e-s;break}s=l}if(o)return this.children[r].domFromPos(o-this.children[r].border,t);for(let s;r&&!(s=this.children[r-1]).size&&s instanceof Ll&&s.side>=0;r--);if(t<=0){let s,i=!0;for(;s=r?this.children[r-1]:null,!(!s||s.dom.parentNode==this.contentDOM);r--,i=!1);return s&&t&&i&&!s.border&&!s.domAtom?s.domFromPos(s.size,t):{node:this.contentDOM,offset:s?ne(s.dom)+1:0}}else{let s,i=!0;for(;s=r<this.children.length?this.children[r]:null,!(!s||s.dom.parentNode==this.contentDOM);r++,i=!1);return s&&i&&!s.border&&!s.domAtom?s.domFromPos(0,t):{node:this.contentDOM,offset:s?ne(s.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,r=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let o=-1,s=-1;for(let i=r,l=0;;l++){let a=this.children[l],c=i+a.size;if(o==-1&&e<=c){let u=i+a.border;if(e>=u&&t<=c-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,t,u);e=i;for(let f=l;f>0;f--){let d=this.children[f-1];if(d.size&&d.dom.parentNode==this.contentDOM&&!d.emptyChildAt(1)){o=ne(d.dom)+1;break}e-=d.size}o==-1&&(o=0)}if(o>-1&&(c>t||l==this.children.length-1)){t=c;for(let u=l+1;u<this.children.length;u++){let f=this.children[u];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(-1)){s=ne(f.dom);break}t+=f.size}s==-1&&(s=this.contentDOM.childNodes.length);break}i=c}return{node:this.contentDOM,from:e,to:t,fromOffset:o,toOffset:s}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let t=this.children[e<0?0:this.children.length-1];return t.size==0||t.emptyChildAt(e)}domAfterPos(e){let{node:t,offset:r}=this.domFromPos(e,0);if(t.nodeType!=1||r==t.childNodes.length)throw new RangeError("No node after pos "+e);return t.childNodes[r]}setSelection(e,t,r,o=!1){let s=Math.min(e,t),i=Math.max(e,t);for(let h=0,p=0;h<this.children.length;h++){let b=this.children[h],g=p+b.size;if(s>p&&i<g)return b.setSelection(e-p-b.border,t-p-b.border,r,o);p=g}let l=this.domFromPos(e,e?-1:1),a=t==e?l:this.domFromPos(t,t?-1:1),c=r.root.getSelection(),u=r.domSelectionRange(),f=!1;if((Ie||ue)&&e==t){let{node:h,offset:p}=l;if(h.nodeType==3){if(f=!!(p&&h.nodeValue[p-1]==`
|
|
38
|
+
`),f&&p==h.nodeValue.length)for(let b=h,g;b;b=b.parentNode){if(g=b.nextSibling){g.nodeName=="BR"&&(l=a={node:g.parentNode,offset:ne(g)+1});break}let k=b.pmViewDesc;if(k&&k.node&&k.node.isBlock)break}}else{let b=h.childNodes[p-1];f=b&&(b.nodeName=="BR"||b.contentEditable=="false")}}if(Ie&&u.focusNode&&u.focusNode!=a.node&&u.focusNode.nodeType==1){let h=u.focusNode.childNodes[u.focusOffset];h&&h.contentEditable=="false"&&(o=!0)}if(!(o||f&&ue)&&Vt(l.node,l.offset,u.anchorNode,u.anchorOffset)&&Vt(a.node,a.offset,u.focusNode,u.focusOffset))return;let d=!1;if((c.extend||e==t)&&!f){c.collapse(l.node,l.offset);try{e!=t&&c.extend(a.node,a.offset),d=!0}catch{}}if(!d){if(e>t){let p=l;l=a,a=p}let h=document.createRange();h.setEnd(a.node,a.offset),h.setStart(l.node,l.offset),c.removeAllRanges(),c.addRange(h)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let r=0,o=0;o<this.children.length;o++){let s=this.children[o],i=r+s.size;if(r==i?e<=i&&t>=r:e<i&&t>r){let l=r+s.border,a=i-s.border;if(e>=l&&t<=a){this.dirty=e==r||t==i?zt:Fl,e==l&&t==a&&(s.contentLost||s.dom.parentNode!=this.contentDOM)?s.dirty=We:s.markDirty(e-l,t-l);return}else s.dirty=s.dom==s.contentDOM&&s.dom.parentNode==this.contentDOM&&!s.children.length?zt:We}r=i}this.dirty=zt}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let r=e==1?zt:Fl;t.dirty<r&&(t.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}isText(e){return!1}},Ll=class extends $n{constructor(e,t,r,o){let s,i=t.type.toDOM;if(typeof i=="function"&&(i=i(r,()=>{if(!s)return o;if(s.parent)return s.parent.posBeforeChild(s)})),!t.type.spec.raw){if(i.nodeType!=1){let l=document.createElement("span");l.appendChild(i),i=l}i.contentEditable="false",i.classList.add("ProseMirror-widget")}super(e,[],i,null),this.widget=t,this.widget=t,s=this}matchesWidget(e){return this.dirty==Ee&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return t?t(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get side(){return this.widget.type.side}},bh=class extends $n{constructor(e,t,r,o){super(e,[],t,null),this.textDOM=r,this.text=o}get size(){return this.text.length}localPosFromDOM(e,t){return e!=this.textDOM?this.posAtStart+(t?this.size:0):this.posAtStart+t}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}},Or=class li extends $n{constructor(e,t,r,o,s){super(e,[],r,o),this.mark=t,this.spec=s}static create(e,t,r,o){let s=o.nodeViews[t.type.name],i=s&&s(t,o,r);return(!i||!i.dom)&&(i=$e.renderSpec(document,t.type.spec.toDOM(t,r),null,t.attrs)),new li(e,t,i.dom,i.contentDOM||i.dom,i)}parseRule(){return this.dirty&We||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=We&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=Ee){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=Ee}}slice(e,t,r){let o=li.create(this.parent,this.mark,!0,r),s=this.children,i=this.size;t<i&&(s=Yo(s,t,i,r)),e>0&&(s=Yo(s,0,e,r));for(let l=0;l<s.length;l++)s[l].parent=o;return o.children=s,o}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}},an=class ff extends $n{constructor(e,t,r,o,s,i,l,a,c){super(e,[],s,i),this.node=t,this.outerDeco=r,this.innerDeco=o,this.nodeDOM=l}static create(e,t,r,o,s,i){let l=s.nodeViews[t.type.name],a,c=l&&l(t,s,()=>{if(!a)return i;if(a.parent)return a.parent.posBeforeChild(a)},r,o),u=c&&c.dom,f=c&&c.contentDOM;if(t.isText){if(!u)u=document.createTextNode(t.text);else if(u.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else u||({dom:u,contentDOM:f}=$e.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs));!f&&!t.isText&&u.nodeName!="BR"&&(u.hasAttribute("contenteditable")||(u.contentEditable="false"),t.type.spec.draggable&&(u.draggable=!0));let d=u;return u=Jl(u,r,t),c?a=new xh(e,t,r,o,u,f||null,d,c,s,i+1):t.isText?new _l(e,t,r,o,u,d,s):new ff(e,t,r,o,u,f||null,d,s,i+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(e.preserveWhitespace="full"),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let t=this.children.length-1;t>=0;t--){let r=this.children[t];if(this.dom.contains(r.dom.parentNode)){e.contentElement=r.dom.parentNode;break}}e.contentElement||(e.getContent=()=>C.empty)}return e}matchesNode(e,t,r){return this.dirty==Ee&&e.eq(this.node)&&Tr(t,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let r=this.node.inlineContent,o=t,s=e.composing?this.localCompositionInfo(e,t):null,i=s&&s.pos>-1?s:null,l=s&&s.pos<0,a=new Sh(this,i&&i.node,e);Mh(this.node,this.innerDeco,(c,u,f)=>{c.spec.marks?a.syncToMarks(c.spec.marks,r,e):c.type.side>=0&&!f&&a.syncToMarks(u==this.node.childCount?F.none:this.node.child(u).marks,r,e),a.placeWidget(c,e,o)},(c,u,f,d)=>{a.syncToMarks(c.marks,r,e);let h;a.findNodeMatch(c,u,f,d)||l&&e.state.selection.from>o&&e.state.selection.to<o+c.nodeSize&&(h=a.findIndexWithChild(s.node))>-1&&a.updateNodeAt(c,u,f,h,e)||a.updateNextNode(c,u,f,e,d,o)||a.addNode(c,u,f,e,o),o+=c.nodeSize}),a.syncToMarks([],r,e),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==zt)&&(i&&this.protectLocalComposition(e,i),Hl(this.contentDOM,this.children,e),sn&&Nh(this.dom))}localCompositionInfo(e,t){let{from:r,to:o}=e.state.selection;if(!(e.state.selection instanceof P)||r<t||o>t+this.node.content.size)return null;let s=e.input.compositionNode;if(!s||!this.dom.contains(s.parentNode))return null;if(this.node.inlineContent){let i=s.nodeValue,l=Eh(this.node.content,i,r-t,o-t);return l<0?null:{node:s,pos:l,text:i}}else return{node:s,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:r,text:o}){if(this.getDesc(t))return;let s=t;for(;s.parentNode!=this.contentDOM;s=s.parentNode){for(;s.previousSibling;)s.parentNode.removeChild(s.previousSibling);for(;s.nextSibling;)s.parentNode.removeChild(s.nextSibling);s.pmViewDesc&&(s.pmViewDesc=void 0)}let i=new bh(this,s,t,o);e.input.compositionNodes.push(i),this.children=Yo(this.children,r,r+o.length,e,i)}update(e,t,r,o){return this.dirty==We||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,r,o),!0)}updateInner(e,t,r,o){this.updateOuterDeco(t),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(o,this.posAtStart),this.dirty=Ee}updateOuterDeco(e){if(Tr(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=Kl(this.dom,this.nodeDOM,Jo(this.outerDeco,this.node,t),Jo(e,this.node,t)),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 Wl(n,e,t,r,o){Jl(r,e,n);let s=new an(void 0,n,e,t,r,r,r,o,0);return s.contentDOM&&s.updateChildren(o,0),s}let _l=class df extends an{constructor(e,t,r,o,s,i,l){super(e,t,r,o,s,null,i,l,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,r,o){return this.dirty==We||this.dirty!=Ee&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=Ee||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,o.trackWrites==this.nodeDOM&&(o.trackWrites=null)),this.node=e,this.dirty=Ee,!0)}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,r){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,t,r){let o=this.node.cut(e,t),s=document.createTextNode(o.text);return new df(this.parent,o,this.outerDeco,this.innerDeco,s,s,r)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=We)}get domAtom(){return!1}isText(e){return this.node.text==e}},ql=class extends $n{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==Ee&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}};class xh extends an{constructor(e,t,r,o,s,i,l,a,c,u){super(e,t,r,o,s,i,l,c,u),this.spec=a}update(e,t,r,o){if(this.dirty==We)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let s=this.spec.update(e,t,r);return s&&this.updateInner(e,t,r,o),s}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,t,r,o)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,r,o){this.spec.setSelection?this.spec.setSelection(e,t,r.root):super.setSelection(e,t,r,o)}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 Hl(n,e,t){let r=n.firstChild,o=!1;for(let s=0;s<e.length;s++){let i=e[s],l=i.dom;if(l.parentNode==n){for(;l!=r;)r=Yl(r),o=!0;r=r.nextSibling}else o=!0,n.insertBefore(l,r);if(i instanceof Or){let a=r?r.previousSibling:n.lastChild;Hl(i.contentDOM,i.children,t),r=a?a.nextSibling:n.firstChild}}for(;r;)r=Yl(r),o=!0;o&&t.trackWrites==n&&(t.trackWrites=null)}const jn=function(n){n&&(this.nodeName=n)};jn.prototype=Object.create(null);const $t=[new jn];function Jo(n,e,t){if(n.length==0)return $t;let r=t?$t[0]:new jn,o=[r];for(let s=0;s<n.length;s++){let i=n[s].type.attrs;if(i){i.nodeName&&o.push(r=new jn(i.nodeName));for(let l in i){let a=i[l];a!=null&&(t&&o.length==1&&o.push(r=new jn(e.isInline?"span":"div")),l=="class"?r.class=(r.class?r.class+" ":"")+a:l=="style"?r.style=(r.style?r.style+";":"")+a:l!="nodeName"&&(r[l]=a))}}}return o}function Kl(n,e,t,r){if(t==$t&&r==$t)return e;let o=e;for(let s=0;s<r.length;s++){let i=r[s],l=t[s];if(s){let a;l&&l.nodeName==i.nodeName&&o!=n&&(a=o.parentNode)&&a.nodeName.toLowerCase()==i.nodeName||(a=document.createElement(i.nodeName),a.pmIsDeco=!0,a.appendChild(o),l=$t[0]),o=a}kh(o,l||$t[0],i)}return o}function kh(n,e,t){for(let r in e)r!="class"&&r!="style"&&r!="nodeName"&&!(r in t)&&n.removeAttribute(r);for(let r in t)r!="class"&&r!="style"&&r!="nodeName"&&t[r]!=e[r]&&n.setAttribute(r,t[r]);if(e.class!=t.class){let r=e.class?e.class.split(" ").filter(Boolean):[],o=t.class?t.class.split(" ").filter(Boolean):[];for(let s=0;s<r.length;s++)o.indexOf(r[s])==-1&&n.classList.remove(r[s]);for(let s=0;s<o.length;s++)r.indexOf(o[s])==-1&&n.classList.add(o[s]);n.classList.length==0&&n.removeAttribute("class")}if(e.style!=t.style){if(e.style){let r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,o;for(;o=r.exec(e.style);)n.style.removeProperty(o[1])}t.style&&(n.style.cssText+=t.style)}}function Jl(n,e,t){return Kl(n,n,$t,Jo(e,t,n.nodeType!=1))}function Tr(n,e){if(n.length!=e.length)return!1;for(let t=0;t<n.length;t++)if(!n[t].type.eq(e[t].type))return!1;return!0}function Yl(n){let e=n.nextSibling;return n.parentNode.removeChild(n),e}class Sh{constructor(e,t,r){this.lock=t,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=Ch(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let r=e;r<t;r++)this.top.children[r].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,r){let o=0,s=this.stack.length>>1,i=Math.min(s,e.length);for(;o<i&&(o==s-1?this.top:this.stack[o+1<<1]).matchesMark(e[o])&&e[o].type.spec.spanning!==!1;)o++;for(;o<s;)this.destroyRest(),this.top.dirty=Ee,this.index=this.stack.pop(),this.top=this.stack.pop(),s--;for(;s<e.length;){this.stack.push(this.top,this.index+1);let l=-1;for(let a=this.index;a<Math.min(this.index+3,this.top.children.length);a++){let c=this.top.children[a];if(c.matchesMark(e[s])&&!this.isLocked(c.dom)){l=a;break}}if(l>-1)l>this.index&&(this.changed=!0,this.destroyBetween(this.index,l)),this.top=this.top.children[this.index];else{let a=Or.create(this.top,e[s],t,r);this.top.children.splice(this.index,0,a),this.top=a,this.changed=!0}this.index=0,s++}}findNodeMatch(e,t,r,o){let s=-1,i;if(o>=this.preMatch.index&&(i=this.preMatch.matches[o-this.preMatch.index]).parent==this.top&&i.matchesNode(e,t,r))s=this.top.children.indexOf(i,this.index);else for(let l=this.index,a=Math.min(this.top.children.length,l+5);l<a;l++){let c=this.top.children[l];if(c.matchesNode(e,t,r)&&!this.preMatch.matched.has(c)){s=l;break}}return s<0?!1:(this.destroyBetween(this.index,s),this.index++,!0)}updateNodeAt(e,t,r,o,s){let i=this.top.children[o];return i.dirty==We&&i.dom==i.contentDOM&&(i.dirty=zt),i.update(e,t,r,s)?(this.destroyBetween(this.index,o),this.index++,!0):!1}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){let r=e.pmViewDesc;if(r){for(let o=this.index;o<this.top.children.length;o++)if(this.top.children[o]==r)return o}return-1}e=t}}updateNextNode(e,t,r,o,s,i){for(let l=this.index;l<this.top.children.length;l++){let a=this.top.children[l];if(a instanceof an){let c=this.preMatch.matched.get(a);if(c!=null&&c!=s)return!1;let u=a.dom,f,d=this.isLocked(u)&&!(e.isText&&a.node&&a.node.isText&&a.nodeDOM.nodeValue==e.text&&a.dirty!=We&&Tr(t,a.outerDeco));if(!d&&a.update(e,t,r,o))return this.destroyBetween(this.index,l),a.dom!=u&&(this.changed=!0),this.index++,!0;if(!d&&(f=this.recreateWrapper(a,e,t,r,o,i)))return this.destroyBetween(this.index,l),this.top.children[this.index]=f,f.contentDOM&&(f.dirty=zt,f.updateChildren(o,i+1),f.dirty=Ee),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,r,o,s,i){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!Tr(r,e.outerDeco)||!o.eq(e.innerDeco))return null;let l=an.create(this.top,t,r,o,s,i);if(l.contentDOM){l.children=e.children,e.children=[];for(let a of l.children)a.parent=l}return e.destroy(),l}addNode(e,t,r,o,s){let i=an.create(this.top,e,t,r,o,s);i.contentDOM&&i.updateChildren(o,s+1),this.top.children.splice(this.index++,0,i),this.changed=!0}placeWidget(e,t,r){let o=this.index<this.top.children.length?this.top.children[this.index]:null;if(o&&o.matchesWidget(e)&&(e==o.widget||!o.widget.type.toDOM.parentNode))this.index++;else{let s=new Ll(this.top,e,t,r);this.top.children.splice(this.index++,0,s),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof Or;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof _l)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((ue||ie)&&e&&e.dom.contentEditable=="false"&&this.addHackNode("IMG",t),this.addHackNode("BR",this.top))}addHackNode(e,t){if(t==this.top&&this.index<t.children.length&&t.children[this.index].matchesHack(e))this.index++;else{let r=document.createElement(e);e=="IMG"&&(r.className="ProseMirror-separator",r.alt=""),e=="BR"&&(r.className="ProseMirror-trailingBreak");let o=new ql(this.top,[],r,null);t!=this.top?t.children.push(o):t.children.splice(this.index++,0,o),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||e.nodeType==1&&e.contains(this.lock.parentNode))}}function Ch(n,e){let t=e,r=t.children.length,o=n.childCount,s=new Map,i=[];e:for(;o>0;){let l;for(;;)if(r){let c=t.children[r-1];if(c instanceof Or)t=c,r=c.children.length;else{l=c,r--;break}}else{if(t==e)break e;r=t.parent.children.indexOf(t),t=t.parent}let a=l.node;if(a){if(a!=n.child(o-1))break;--o,s.set(l,o),i.push(l)}}return{index:o,matched:s,matches:i.reverse()}}function wh(n,e){return n.type.side-e.type.side}function Mh(n,e,t,r){let o=e.locals(n),s=0;if(o.length==0){for(let c=0;c<n.childCount;c++){let u=n.child(c);r(u,o,e.forChild(s,u),c),s+=u.nodeSize}return}let i=0,l=[],a=null;for(let c=0;;){let u,f;for(;i<o.length&&o[i].to==s;){let g=o[i++];g.widget&&(u?(f||(f=[u])).push(g):u=g)}if(u)if(f){f.sort(wh);for(let g=0;g<f.length;g++)t(f[g],c,!!a)}else t(u,c,!!a);let d,h;if(a)h=-1,d=a,a=null;else if(c<n.childCount)h=c,d=n.child(c++);else break;for(let g=0;g<l.length;g++)l[g].to<=s&&l.splice(g--,1);for(;i<o.length&&o[i].from<=s&&o[i].to>s;)l.push(o[i++]);let p=s+d.nodeSize;if(d.isText){let g=p;i<o.length&&o[i].from<g&&(g=o[i].from);for(let k=0;k<l.length;k++)l[k].to<g&&(g=l[k].to);g<p&&(a=d.cut(g-s),d=d.cut(0,g-s),p=g,h=-1)}else for(;i<o.length&&o[i].to<p;)i++;let b=d.isInline&&!d.isLeaf?l.filter(g=>!g.inline):l.slice();r(d,b,e.forChild(s,d),h),s=p}}function Nh(n){if(n.nodeName=="UL"||n.nodeName=="OL"){let e=n.style.cssText;n.style.cssText=e+"; list-style: square !important",window.getComputedStyle(n).listStyle,n.style.cssText=e}}function Eh(n,e,t,r){for(let o=0,s=0;o<n.childCount&&s<=r;){let i=n.child(o++),l=s;if(s+=i.nodeSize,!i.isText)continue;let a=i.text;for(;o<n.childCount;){let c=n.child(o++);if(s+=c.nodeSize,!c.isText)break;a+=c.text}if(s>=t){if(s>=r&&a.slice(r-e.length-l,r-l)==e)return r-e.length;let c=l<r?a.lastIndexOf(e,r-l-1):-1;if(c>=0&&c+e.length+l>=t)return l+c;if(t==r&&a.length>=r+e.length-l&&a.slice(r-l,r-l+e.length)==e)return r}}return-1}function Yo(n,e,t,r,o){let s=[];for(let i=0,l=0;i<n.length;i++){let a=n[i],c=l,u=l+=a.size;c>=t||u<=e?s.push(a):(c<e&&s.push(a.slice(0,e-c,r)),o&&(s.push(o),o=void 0),u>t&&s.push(a.slice(t-c,a.size,r)))}return s}function Go(n,e=null){let t=n.domSelectionRange(),r=n.state.doc;if(!t.focusNode)return null;let o=n.docView.nearestDesc(t.focusNode),s=o&&o.size==0,i=n.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(i<0)return null;let l=r.resolve(i),a,c;if(Dr(t)){for(a=i;o&&!o.node;)o=o.parent;let f=o.node;if(o&&f.isAtom&&D.isSelectable(f)&&o.parent&&!(f.isInline&&Qd(t.focusNode,t.focusOffset,o.dom))){let d=o.posBefore;c=new D(i==d?l:r.resolve(d))}}else{if(t instanceof n.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let f=i,d=i;for(let h=0;h<t.rangeCount;h++){let p=t.getRangeAt(h);f=Math.min(f,n.docView.posFromDOM(p.startContainer,p.startOffset,1)),d=Math.max(d,n.docView.posFromDOM(p.endContainer,p.endOffset,-1))}if(f<0)return null;[a,i]=d==n.state.selection.anchor?[d,f]:[f,d],l=r.resolve(i)}else a=n.docView.posFromDOM(t.anchorNode,t.anchorOffset,1);if(a<0)return null}let u=r.resolve(a);if(!c){let f=e=="pointer"||n.state.selection.head<l.pos&&!s?1:-1;c=Uo(n,u,l,f)}return c}function Gl(n){return n.editable?n.hasFocus():na(n)&&document.activeElement&&document.activeElement.contains(n.dom)}function et(n,e=!1){let t=n.state.selection;if(Zl(n,t),!!Gl(n)){if(!e&&n.input.mouseDown&&n.input.mouseDown.allowDefault&&ie){let r=n.domSelectionRange(),o=n.domObserver.currentSelection;if(r.anchorNode&&o.anchorNode&&Vt(r.anchorNode,r.anchorOffset,o.anchorNode,o.anchorOffset)){n.input.mouseDown.delayedSelectionSync=!0,n.domObserver.setCurSelection();return}}if(n.domObserver.disconnectSelection(),n.cursorWrapper)Oh(n);else{let{anchor:r,head:o}=t,s,i;Xl&&!(t instanceof P)&&(t.$from.parent.inlineContent||(s=Ul(n,t.from)),!t.empty&&!t.$from.parent.inlineContent&&(i=Ul(n,t.to))),n.docView.setSelection(r,o,n,e),Xl&&(s&&Ql(s),i&&Ql(i)),t.visible?n.dom.classList.remove("ProseMirror-hideselection"):(n.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&Dh(n))}n.domObserver.setCurSelection(),n.domObserver.connectSelection()}}const Xl=ue||ie&&Ol<63;function Ul(n,e){let{node:t,offset:r}=n.docView.domFromPos(e,0),o=r<t.childNodes.length?t.childNodes[r]:null,s=r?t.childNodes[r-1]:null;if(ue&&o&&o.contentEditable=="false")return Xo(o);if((!o||o.contentEditable=="false")&&(!s||s.contentEditable=="false")){if(o)return Xo(o);if(s)return Xo(s)}}function Xo(n){return n.contentEditable="true",ue&&n.draggable&&(n.draggable=!1,n.wasDraggable=!0),n}function Ql(n){n.contentEditable="false",n.wasDraggable&&(n.draggable=!0,n.wasDraggable=null)}function Dh(n){let e=n.dom.ownerDocument;e.removeEventListener("selectionchange",n.input.hideSelectionGuard);let t=n.domSelectionRange(),r=t.anchorNode,o=t.anchorOffset;e.addEventListener("selectionchange",n.input.hideSelectionGuard=()=>{(t.anchorNode!=r||t.anchorOffset!=o)&&(e.removeEventListener("selectionchange",n.input.hideSelectionGuard),setTimeout(()=>{(!Gl(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function Oh(n){let e=n.domSelection(),t=document.createRange();if(!e)return;let r=n.cursorWrapper.dom,o=r.nodeName=="IMG";o?t.setStart(r.parentNode,ne(r)+1):t.setStart(r,0),t.collapse(!0),e.removeAllRanges(),e.addRange(t),!o&&!n.state.selection.visible&&ye&&dt<=11&&(r.disabled=!0,r.disabled=!1)}function Zl(n,e){if(e instanceof D){let t=n.docView.descAt(e.from);t!=n.lastSelectedViewDesc&&(ea(n),t&&t.selectNode(),n.lastSelectedViewDesc=t)}else ea(n)}function ea(n){n.lastSelectedViewDesc&&(n.lastSelectedViewDesc.parent&&n.lastSelectedViewDesc.deselectNode(),n.lastSelectedViewDesc=void 0)}function Uo(n,e,t,r){return n.someProp("createSelectionBetween",o=>o(n,e,t))||P.between(e,t,r)}function ta(n){return n.editable&&!n.hasFocus()?!1:na(n)}function na(n){let e=n.domSelectionRange();if(!e.anchorNode)return!1;try{return n.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(n.editable||n.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function Th(n){let e=n.docView.domFromPos(n.state.selection.anchor,0),t=n.domSelectionRange();return Vt(e.node,e.offset,t.anchorNode,t.anchorOffset)}function Qo(n,e){let{$anchor:t,$head:r}=n.selection,o=e>0?t.max(r):t.min(r),s=o.parent.inlineContent?o.depth?n.doc.resolve(e>0?o.after():o.before()):null:o;return s&&R.findFrom(s,e)}function pt(n,e){return n.dispatch(n.state.tr.setSelection(e).scrollIntoView()),!0}function ra(n,e,t){let r=n.state.selection;if(r instanceof P)if(t.indexOf("s")>-1){let{$head:o}=r,s=o.textOffset?null:e<0?o.nodeBefore:o.nodeAfter;if(!s||s.isText||!s.isLeaf)return!1;let i=n.state.doc.resolve(o.pos+s.nodeSize*(e<0?-1:1));return pt(n,new P(r.$anchor,i))}else if(r.empty){if(n.endOfTextblock(e>0?"forward":"backward")){let o=Qo(n.state,e);return o&&o instanceof D?pt(n,o):!1}else if(!(Ne&&t.indexOf("m")>-1)){let o=r.$head,s=o.textOffset?null:e<0?o.nodeBefore:o.nodeAfter,i;if(!s||s.isText)return!1;let l=e<0?o.pos-s.nodeSize:o.pos;return s.isAtom||(i=n.docView.descAt(l))&&!i.contentDOM?D.isSelectable(s)?pt(n,new D(e<0?n.state.doc.resolve(o.pos-s.nodeSize):o)):Rn?pt(n,new P(n.state.doc.resolve(e<0?l:l+s.nodeSize))):!1:!1}}else return!1;else{if(r instanceof D&&r.node.isInline)return pt(n,new P(e>0?r.$to:r.$from));{let o=Qo(n.state,e);return o?pt(n,o):!1}}}function vr(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Bn(n,e){let t=n.pmViewDesc;return t&&t.size==0&&(e<0||n.nextSibling||n.nodeName!="BR")}function cn(n,e){return e<0?vh(n):Ah(n)}function vh(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let o,s,i=!1;for(Ie&&t.nodeType==1&&r<vr(t)&&Bn(t.childNodes[r],-1)&&(i=!0);;)if(r>0){if(t.nodeType!=1)break;{let l=t.childNodes[r-1];if(Bn(l,-1))o=t,s=--r;else if(l.nodeType==3)t=l,r=t.nodeValue.length;else break}}else{if(oa(t))break;{let l=t.previousSibling;for(;l&&Bn(l,-1);)o=t.parentNode,s=ne(l),l=l.previousSibling;if(l)t=l,r=vr(t);else{if(t=t.parentNode,t==n.dom)break;r=0}}}i?Zo(n,t,r):o&&Zo(n,o,s)}function Ah(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let o=vr(t),s,i;for(;;)if(r<o){if(t.nodeType!=1)break;let l=t.childNodes[r];if(Bn(l,1))s=t,i=++r;else break}else{if(oa(t))break;{let l=t.nextSibling;for(;l&&Bn(l,1);)s=l.parentNode,i=ne(l)+1,l=l.nextSibling;if(l)t=l,r=0,o=vr(t);else{if(t=t.parentNode,t==n.dom)break;r=o=0}}}s&&Zo(n,s,i)}function oa(n){let e=n.pmViewDesc;return e&&e.node&&e.node.isBlock}function Ph(n,e){for(;n&&e==n.childNodes.length&&!Vn(n);)e=ne(n)+1,n=n.parentNode;for(;n&&e<n.childNodes.length;){let t=n.childNodes[e];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;n=t,e=0}}function Ih(n,e){for(;n&&!e&&!Vn(n);)e=ne(n),n=n.parentNode;for(;n&&e;){let t=n.childNodes[e-1];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;n=t,e=n.childNodes.length}}function Zo(n,e,t){if(e.nodeType!=3){let s,i;(i=Ph(e,t))?(e=i,t=0):(s=Ih(e,t))&&(e=s,t=s.nodeValue.length)}let r=n.domSelection();if(!r)return;if(Dr(r)){let s=document.createRange();s.setEnd(e,t),s.setStart(e,t),r.removeAllRanges(),r.addRange(s)}else r.extend&&r.extend(e,t);n.domObserver.setCurSelection();let{state:o}=n;setTimeout(()=>{n.state==o&&et(n)},50)}function sa(n,e){let t=n.state.doc.resolve(e);if(!(ie||th)&&t.parent.inlineContent){let o=n.coordsAtPos(e);if(e>t.start()){let s=n.coordsAtPos(e-1),i=(s.top+s.bottom)/2;if(i>o.top&&i<o.bottom&&Math.abs(s.left-o.left)>1)return s.left<o.left?"ltr":"rtl"}if(e<t.end()){let s=n.coordsAtPos(e+1),i=(s.top+s.bottom)/2;if(i>o.top&&i<o.bottom&&Math.abs(s.left-o.left)>1)return s.left>o.left?"ltr":"rtl"}}return getComputedStyle(n.dom).direction=="rtl"?"rtl":"ltr"}function ia(n,e,t){let r=n.state.selection;if(r instanceof P&&!r.empty||t.indexOf("s")>-1||Ne&&t.indexOf("m")>-1)return!1;let{$from:o,$to:s}=r;if(!o.parent.inlineContent||n.endOfTextblock(e<0?"up":"down")){let i=Qo(n.state,e);if(i&&i instanceof D)return pt(n,i)}if(!o.parent.inlineContent){let i=e<0?o:s,l=r instanceof ge?R.near(i,e):R.findFrom(i,e);return l?pt(n,l):!1}return!1}function la(n,e){if(!(n.state.selection instanceof P))return!0;let{$head:t,$anchor:r,empty:o}=n.state.selection;if(!t.sameParent(r))return!0;if(!o)return!1;if(n.endOfTextblock(e>0?"forward":"backward"))return!0;let s=!t.textOffset&&(e<0?t.nodeBefore:t.nodeAfter);if(s&&!s.isText){let i=n.state.tr;return e<0?i.delete(t.pos-s.nodeSize,t.pos):i.delete(t.pos,t.pos+s.nodeSize),n.dispatch(i),!0}return!1}function aa(n,e,t){n.domObserver.stop(),e.contentEditable=t,n.domObserver.start()}function Vh(n){if(!ue||n.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:t}=n.domSelectionRange();if(e&&e.nodeType==1&&t==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let r=e.firstChild;aa(n,r,"true"),setTimeout(()=>aa(n,r,"false"),20)}return!1}function Rh(n){let e="";return n.ctrlKey&&(e+="c"),n.metaKey&&(e+="m"),n.altKey&&(e+="a"),n.shiftKey&&(e+="s"),e}function zh(n,e){let t=e.keyCode,r=Rh(e);if(t==8||Ne&&t==72&&r=="c")return la(n,-1)||cn(n,-1);if(t==46&&!e.shiftKey||Ne&&t==68&&r=="c")return la(n,1)||cn(n,1);if(t==13||t==27)return!0;if(t==37||Ne&&t==66&&r=="c"){let o=t==37?sa(n,n.state.selection.from)=="ltr"?-1:1:-1;return ra(n,o,r)||cn(n,o)}else if(t==39||Ne&&t==70&&r=="c"){let o=t==39?sa(n,n.state.selection.from)=="ltr"?1:-1:1;return ra(n,o,r)||cn(n,o)}else{if(t==38||Ne&&t==80&&r=="c")return ia(n,-1,r)||cn(n,-1);if(t==40||Ne&&t==78&&r=="c")return Vh(n)||ia(n,1,r)||cn(n,1);if(r==(Ne?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function ca(n,e){n.someProp("transformCopied",h=>{e=h(e,n)});let t=[],{content:r,openStart:o,openEnd:s}=e;for(;o>1&&s>1&&r.childCount==1&&r.firstChild.childCount==1;){o--,s--;let h=r.firstChild;t.push(h.type.name,h.attrs!=h.type.defaultAttrs?h.attrs:null),r=h.content}let i=n.someProp("clipboardSerializer")||$e.fromSchema(n.state.schema),l=ya(),a=l.createElement("div");a.appendChild(i.serializeFragment(r,{document:l}));let c=a.firstChild,u,f=0;for(;c&&c.nodeType==1&&(u=ma[c.nodeName.toLowerCase()]);){for(let h=u.length-1;h>=0;h--){let p=l.createElement(u[h]);for(;a.firstChild;)p.appendChild(a.firstChild);a.appendChild(p),f++}c=a.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${o} ${s}${f?` -${f}`:""} ${JSON.stringify(t)}`);let d=n.someProp("clipboardTextSerializer",h=>h(e,n))||e.content.textBetween(0,e.content.size,`
|
|
39
39
|
|
|
40
|
-
`);return{dom:a,text:d,slice:e}}function ua(n,e,t,r,o){let s=o.parent.type.spec.code,i,l;if(!t&&!e)return null;let a=e&&(r||s||!t);if(a){if(n.someProp("transformPastedText",d=>{e=d(e,s||r,n)}),s)return e?new N(
|
|
41
|
-
`))),0,0):N.empty;let f=n.someProp("clipboardTextParser",d=>d(e,o,r,n));if(f)l=f;else{let d=o.marks(),{schema:p}=n.state,h=$e.fromSchema(p);i=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(b=>{let g=i.appendChild(document.createElement("p"));b&&g.appendChild(h.serializeNode(p.text(b,d)))})}}else n.someProp("transformPastedHTML",f=>{t=f(t,n)}),i=Fh(t),Rn&&Lh(i);let c=i&&i.querySelector("[data-pm-slice]"),u=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(u&&u[3])for(let f=+u[3];f>0;f--){let d=i.firstChild;for(;d&&d.nodeType!=1;)d=d.nextSibling;if(!d)break;i=d}if(l||(l=(n.someProp("clipboardParser")||n.someProp("domParser")||Pt.fromSchema(n.state.schema)).parseSlice(i,{preserveWhitespace:!!(a||u),context:o,ruleFromNode(d){return d.nodeName=="BR"&&!d.nextSibling&&d.parentNode&&!$h.test(d.parentNode.nodeName)?{ignore:!0}:null}})),u)l=Wh(pa(l,+u[1],+u[2]),u[4]);else if(l=N.maxOpen(jh(l.content,o),!0),l.openStart||l.openEnd){let f=0,d=0;for(let p=l.content.firstChild;f<l.openStart&&!p.type.spec.isolating;f++,p=p.firstChild);for(let p=l.content.lastChild;d<l.openEnd&&!p.type.spec.isolating;d++,p=p.lastChild);l=pa(l,f,d)}return n.someProp("transformPasted",f=>{l=f(l,n)}),l}const $h=/^(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 jh(n,e){if(n.childCount<2)return n;for(let t=e.depth;t>=0;t--){let o=e.node(t).contentMatchAt(e.index(t)),s,i=[];if(n.forEach(l=>{if(!i)return;let a=o.findWrapping(l.type),c;if(!a)return i=null;if(c=i.length&&s.length&&da(a,s,l,i[i.length-1],0))i[i.length-1]=c;else{i.length&&(i[i.length-1]=ha(i[i.length-1],s.length));let u=fa(l,a);i.push(u),o=o.matchType(u.type),s=a}}),i)return S.from(i)}return n}function fa(n,e,t=0){for(let r=e.length-1;r>=t;r--)n=e[r].create(null,S.from(n));return n}function da(n,e,t,r,o){if(o<n.length&&o<e.length&&n[o]==e[o]){let s=da(n,e,t,r.lastChild,o+1);if(s)return r.copy(r.content.replaceChild(r.childCount-1,s));if(r.contentMatchAt(r.childCount).matchType(o==n.length-1?t.type:n[o+1]))return r.copy(r.content.append(S.from(fa(t,n,o+1))))}}function ha(n,e){if(e==0)return n;let t=n.content.replaceChild(n.childCount-1,ha(n.lastChild,e-1)),r=n.contentMatchAt(n.childCount).fillBefore(S.empty,!0);return n.copy(t.append(r))}function es(n,e,t,r,o,s){let i=e<0?n.firstChild:n.lastChild,l=i.content;return n.childCount>1&&(s=0),o<r-1&&(l=es(l,e,t,r,o+1,s)),o>=t&&(l=e<0?i.contentMatchAt(0).fillBefore(l,s<=o).append(l):l.append(i.contentMatchAt(i.childCount).fillBefore(S.empty,!0))),n.replaceChild(e<0?0:n.childCount-1,i.copy(l))}function pa(n,e,t){return e<n.openStart&&(n=new N(es(n.content,-1,e,n.openStart,0,n.openEnd),e,n.openEnd)),t<n.openEnd&&(n=new N(es(n.content,1,t,n.openEnd,0,0),n.openStart,t)),n}const ma={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};let ga=null;function ya(){return ga||(ga=document.implementation.createHTMLDocument("title"))}let ts=null;function Bh(n){let e=window.trustedTypes;return e?(ts||(ts=e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})),ts.createHTML(n)):n}function Fh(n){let e=/^(\s*<meta [^>]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=ya().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(n),o;if((o=r&&ma[r[1].toLowerCase()])&&(n=o.map(s=>"<"+s+">").join("")+n+o.map(s=>"</"+s+">").reverse().join("")),t.innerHTML=Bh(n),o)for(let s=0;s<o.length;s++)t=t.querySelector(o[s])||t;return t}function Lh(n){let e=n.querySelectorAll(ie?"span:not([class]):not([style])":"span.Apple-converted-space");for(let t=0;t<e.length;t++){let r=e[t];r.childNodes.length==1&&r.textContent==" "&&r.parentNode&&r.parentNode.replaceChild(n.ownerDocument.createTextNode(" "),r)}}function Wh(n,e){if(!n.size)return n;let t=n.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return n}let{content:o,openStart:s,openEnd:i}=n;for(let l=r.length-2;l>=0;l-=2){let a=t.nodes[r[l]];if(!a||a.hasRequiredAttrs())break;o=S.from(a.create(r[l+1],o)),s++,i++}return new N(o,s,i)}const fe={},de={},_h={touchstart:!0,touchmove:!0};class qh{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.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function Hh(n){for(let e in fe){let t=fe[e];n.dom.addEventListener(e,n.input.eventHandlers[e]=r=>{Jh(n,r)&&!rs(n,r)&&(n.editable||!(r.type in de))&&t(n,r)},_h[e]?{passive:!0}:void 0)}ue&&n.dom.addEventListener("input",()=>null),ns(n)}function mt(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}function Kh(n){n.domObserver.stop();for(let e in n.input.eventHandlers)n.dom.removeEventListener(e,n.input.eventHandlers[e]);clearTimeout(n.input.composingTimeout),clearTimeout(n.input.lastIOSEnterFallbackTimeout)}function ns(n){n.someProp("handleDOMEvents",e=>{for(let t in e)n.input.eventHandlers[t]||n.dom.addEventListener(t,n.input.eventHandlers[t]=r=>rs(n,r))})}function rs(n,e){return n.someProp("handleDOMEvents",t=>{let r=t[e.type];return r?r(n,e)||e.defaultPrevented:!1})}function Jh(n,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target;t!=n.dom;t=t.parentNode)if(!t||t.nodeType==11||t.pmViewDesc&&t.pmViewDesc.stopEvent(e))return!1;return!0}function Yh(n,e){!rs(n,e)&&fe[e.type]&&(n.editable||!(e.type in de))&&fe[e.type](n,e)}de.keydown=(n,e)=>{let t=e;if(n.input.shiftKey=t.keyCode==16||t.shiftKey,!xa(n,t)&&(n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),!(Qe&&ie&&t.keyCode==13)))if(t.keyCode!=229&&n.domObserver.forceFlush(),sn&&t.keyCode==13&&!t.ctrlKey&&!t.altKey&&!t.metaKey){let r=Date.now();n.input.lastIOSEnter=r,n.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{n.input.lastIOSEnter==r&&(n.someProp("handleKeyDown",o=>o(n,Rt(13,"Enter"))),n.input.lastIOSEnter=0)},200)}else n.someProp("handleKeyDown",r=>r(n,t))||zh(n,t)?t.preventDefault():mt(n,"key")},de.keyup=(n,e)=>{e.keyCode==16&&(n.input.shiftKey=!1)},de.keypress=(n,e)=>{let t=e;if(xa(n,t)||!t.charCode||t.ctrlKey&&!t.altKey||Ne&&t.metaKey)return;if(n.someProp("handleKeyPress",o=>o(n,t))){t.preventDefault();return}let r=n.state.selection;if(!(r instanceof P)||!r.$from.sameParent(r.$to)){let o=String.fromCharCode(t.charCode);!/[\r\n]/.test(o)&&!n.someProp("handleTextInput",s=>s(n,r.$from.pos,r.$to.pos,o))&&n.dispatch(n.state.tr.insertText(o).scrollIntoView()),t.preventDefault()}};function Ar(n){return{left:n.clientX,top:n.clientY}}function Gh(n,e){let t=e.x-n.clientX,r=e.y-n.clientY;return t*t+r*r<100}function ss(n,e,t,r,o){if(r==-1)return!1;let s=n.state.doc.resolve(r);for(let i=s.depth+1;i>0;i--)if(n.someProp(e,l=>i>s.depth?l(n,t,s.nodeAfter,s.before(i),o,!0):l(n,t,s.node(i),s.before(i),o,!1)))return!0;return!1}function un(n,e,t){if(n.focused||n.focus(),n.state.selection.eq(e))return;let r=n.state.tr.setSelection(e);r.setMeta("pointer",!0),n.dispatch(r)}function Xh(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),r=t.nodeAfter;return r&&r.isAtom&&D.isSelectable(r)?(un(n,new D(t)),!0):!1}function Uh(n,e){if(e==-1)return!1;let t=n.state.selection,r,o;t instanceof D&&(r=t.node);let s=n.state.doc.resolve(e);for(let i=s.depth+1;i>0;i--){let l=i>s.depth?s.nodeAfter:s.node(i);if(D.isSelectable(l)){r&&t.$from.depth>0&&i>=t.$from.depth&&s.before(t.$from.depth+1)==t.$from.pos?o=s.before(t.$from.depth):o=s.before(i);break}}return o!=null?(un(n,D.create(n.state.doc,o)),!0):!1}function Qh(n,e,t,r,o){return ss(n,"handleClickOn",e,t,r)||n.someProp("handleClick",s=>s(n,e,r))||(o?Uh(n,t):Xh(n,t))}function Zh(n,e,t,r){return ss(n,"handleDoubleClickOn",e,t,r)||n.someProp("handleDoubleClick",o=>o(n,e,r))}function ep(n,e,t,r){return ss(n,"handleTripleClickOn",e,t,r)||n.someProp("handleTripleClick",o=>o(n,e,r))||tp(n,t,r)}function tp(n,e,t){if(t.button!=0)return!1;let r=n.state.doc;if(e==-1)return r.inlineContent?(un(n,P.create(r,0,r.content.size)),!0):!1;let o=r.resolve(e);for(let s=o.depth+1;s>0;s--){let i=s>o.depth?o.nodeAfter:o.node(s),l=o.before(s);if(i.inlineContent)un(n,P.create(r,l+1,l+1+i.content.size));else if(D.isSelectable(i))un(n,D.create(r,l));else continue;return!0}}function is(n){return Pr(n)}const ba=Ne?"metaKey":"ctrlKey";fe.mousedown=(n,e)=>{let t=e;n.input.shiftKey=t.shiftKey;let r=is(n),o=Date.now(),s="singleClick";o-n.input.lastClick.time<500&&Gh(t,n.input.lastClick)&&!t[ba]&&(n.input.lastClick.type=="singleClick"?s="doubleClick":n.input.lastClick.type=="doubleClick"&&(s="tripleClick")),n.input.lastClick={time:o,x:t.clientX,y:t.clientY,type:s};let i=n.posAtCoords(Ar(t));i&&(s=="singleClick"?(n.input.mouseDown&&n.input.mouseDown.done(),n.input.mouseDown=new np(n,i,t,!!r)):(s=="doubleClick"?Zh:ep)(n,i.pos,i.inside,t)?t.preventDefault():mt(n,"pointer"))};let np=class{constructor(e,t,r,o){this.view=e,this.pos=t,this.event=r,this.flushed=o,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!r[ba],this.allowDefault=r.shiftKey;let s,i;if(t.inside>-1)s=e.state.doc.nodeAt(t.inside),i=t.inside;else{let u=e.state.doc.resolve(t.pos);s=u.parent,i=u.depth?u.before():0}const l=o?null:r.target,a=l?e.docView.nearestDesc(l,!0):null;this.target=a&&a.dom.nodeType==1?a.dom:null;let{selection:c}=e.state;(r.button==0&&s.type.spec.draggable&&s.type.spec.selectable!==!1||c instanceof D&&c.from<=i&&c.to>i)&&(this.mightDrag={node:s,pos:i,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Ie&&!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)),mt(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(()=>et(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(Ar(e))),this.updateAllowDefault(e),this.allowDefault||!t?mt(this.view,"pointer"):Qh(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||ue&&this.mightDrag&&!this.mightDrag.node.isAtom||ie&&!this.view.state.selection.visible&&Math.min(Math.abs(t.pos-this.view.state.selection.from),Math.abs(t.pos-this.view.state.selection.to))<=2)?(un(this.view,R.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):mt(this.view,"pointer")}move(e){this.updateAllowDefault(e),mt(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)}};fe.touchstart=n=>{n.input.lastTouch=Date.now(),is(n),mt(n,"pointer")},fe.touchmove=n=>{n.input.lastTouch=Date.now(),mt(n,"pointer")},fe.contextmenu=n=>is(n);function xa(n,e){return n.composing?!0:ue&&Math.abs(e.timeStamp-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}const rp=Qe?5e3:-1;de.compositionstart=de.compositionupdate=n=>{if(!n.composing){n.domObserver.flush();let{state:e}=n,t=e.selection.$to;if(e.selection instanceof P&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)))n.markCursor=n.state.storedMarks||t.marks(),Pr(n,!0),n.markCursor=null;else if(Pr(n,!e.selection.empty),Ie&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length){let r=n.domSelectionRange();for(let o=r.focusNode,s=r.focusOffset;o&&o.nodeType==1&&s!=0;){let i=s<0?o.lastChild:o.childNodes[s-1];if(!i)break;if(i.nodeType==3){let l=n.domSelection();l&&l.collapse(i,i.nodeValue.length);break}else o=i,s=-1}}n.input.composing=!0}ka(n,rp)},de.compositionend=(n,e)=>{n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=e.timeStamp,n.input.compositionPendingChanges=n.domObserver.pendingRecords().length?n.input.compositionID:0,n.input.compositionNode=null,n.input.compositionPendingChanges&&Promise.resolve().then(()=>n.domObserver.flush()),n.input.compositionID++,ka(n,20))};function ka(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>Pr(n),e))}function Sa(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=sp());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function op(n){let e=n.domSelectionRange();if(!e.focusNode)return null;let t=Xd(e.focusNode,e.focusOffset),r=Ud(e.focusNode,e.focusOffset);if(t&&r&&t!=r){let o=r.pmViewDesc,s=n.domObserver.lastChangedTextNode;if(t==s||r==s)return s;if(!o||!o.isText(r.nodeValue))return r;if(n.input.compositionNode==r){let i=t.pmViewDesc;if(!(!i||!i.isText(t.nodeValue)))return r}}return t||r}function sp(){let n=document.createEvent("Event");return n.initEvent("event",!0,!0),n.timeStamp}function Pr(n,e=!1){if(!(Qe&&n.domObserver.flushingSoon>=0)){if(n.domObserver.forceFlush(),Sa(n),e||n.docView&&n.docView.dirty){let t=Go(n);return t&&!t.eq(n.state.selection)?n.dispatch(n.state.tr.setSelection(t)):(n.markCursor||e)&&!n.state.selection.empty?n.dispatch(n.state.tr.deleteSelection()):n.updateState(n.state),!0}return!1}}function ip(n,e){if(!n.dom.parentNode)return;let t=n.dom.parentNode.appendChild(document.createElement("div"));t.appendChild(e),t.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),o=document.createRange();o.selectNodeContents(e),n.dom.blur(),r.removeAllRanges(),r.addRange(o),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t),n.focus()},50)}const Fn=ye&&dt<15||sn&&nh<604;fe.copy=de.cut=(n,e)=>{let t=e,r=n.state.selection,o=t.type=="cut";if(r.empty)return;let s=Fn?null:t.clipboardData,i=r.content(),{dom:l,text:a}=ca(n,i);s?(t.preventDefault(),s.clearData(),s.setData("text/html",l.innerHTML),s.setData("text/plain",a)):ip(n,l),o&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function lp(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function ap(n,e){if(!n.dom.parentNode)return;let t=n.input.shiftKey||n.state.selection.$from.parent.type.spec.code,r=n.dom.parentNode.appendChild(document.createElement(t?"textarea":"div"));t||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let o=n.input.shiftKey&&n.input.lastKeyCode!=45;setTimeout(()=>{n.focus(),r.parentNode&&r.parentNode.removeChild(r),t?Ln(n,r.value,null,o,e):Ln(n,r.textContent,r.innerHTML,o,e)},50)}function Ln(n,e,t,r,o){let s=ua(n,e,t,r,n.state.selection.$from);if(n.someProp("handlePaste",a=>a(n,o,s||N.empty)))return!0;if(!s)return!1;let i=lp(s),l=i?n.state.tr.replaceSelectionWith(i,r):n.state.tr.replaceSelection(s);return n.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Ca(n){let e=n.getData("text/plain")||n.getData("Text");if(e)return e;let t=n.getData("text/uri-list");return t?t.replace(/\r?\n/g," "):""}de.paste=(n,e)=>{let t=e;if(n.composing&&!Qe)return;let r=Fn?null:t.clipboardData,o=n.input.shiftKey&&n.input.lastKeyCode!=45;r&&Ln(n,Ca(r),r.getData("text/html"),o,t)?t.preventDefault():ap(n,t)};let wa=class{constructor(e,t,r){this.slice=e,this.move=t,this.node=r}};const Ma=Ne?"altKey":"ctrlKey";fe.dragstart=(n,e)=>{let t=e,r=n.input.mouseDown;if(r&&r.done(),!t.dataTransfer)return;let o=n.state.selection,s=o.empty?null:n.posAtCoords(Ar(t)),i;if(!(s&&s.pos>=o.from&&s.pos<=(o instanceof D?o.to-1:o.to))){if(r&&r.mightDrag)i=D.create(n.state.doc,r.mightDrag.pos);else if(t.target&&t.target.nodeType==1){let f=n.docView.nearestDesc(t.target,!0);f&&f.node.type.spec.draggable&&f!=n.docView&&(i=D.create(n.state.doc,f.posBefore))}}let l=(i||n.state.selection).content(),{dom:a,text:c,slice:u}=ca(n,l);(!t.dataTransfer.files.length||!ie||Ol>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(Fn?"Text":"text/html",a.innerHTML),t.dataTransfer.effectAllowed="copyMove",Fn||t.dataTransfer.setData("text/plain",c),n.dragging=new wa(u,!t[Ma],i)},fe.dragend=n=>{let e=n.dragging;window.setTimeout(()=>{n.dragging==e&&(n.dragging=null)},50)},de.dragover=de.dragenter=(n,e)=>e.preventDefault(),de.drop=(n,e)=>{let t=e,r=n.dragging;if(n.dragging=null,!t.dataTransfer)return;let o=n.posAtCoords(Ar(t));if(!o)return;let s=n.state.doc.resolve(o.pos),i=r&&r.slice;i?n.someProp("transformPasted",h=>{i=h(i,n)}):i=ua(n,Ca(t.dataTransfer),Fn?null:t.dataTransfer.getData("text/html"),!1,s);let l=!!(r&&!t[Ma]);if(n.someProp("handleDrop",h=>h(n,t,i||N.empty,l))){t.preventDefault();return}if(!i)return;t.preventDefault();let a=i?So(n.state.doc,s.pos,i):s.pos;a==null&&(a=s.pos);let c=n.state.tr;if(l){let{node:h}=r;h?h.replace(c):c.deleteSelection()}let u=c.mapping.map(a),f=i.openStart==0&&i.openEnd==0&&i.content.childCount==1,d=c.doc;if(f?c.replaceRangeWith(u,u,i.content.firstChild):c.replaceRange(u,u,i),c.doc.eq(d))return;let p=c.doc.resolve(u);if(f&&D.isSelectable(i.content.firstChild)&&p.nodeAfter&&p.nodeAfter.sameMarkup(i.content.firstChild))c.setSelection(new D(p));else{let h=c.mapping.map(a);c.mapping.maps[c.mapping.maps.length-1].forEach((b,g,k,w)=>h=w),c.setSelection(Uo(n,p,c.doc.resolve(h)))}n.focus(),n.dispatch(c.setMeta("uiEvent","drop"))},fe.focus=n=>{n.input.lastFocus=Date.now(),n.focused||(n.domObserver.stop(),n.dom.classList.add("ProseMirror-focused"),n.domObserver.start(),n.focused=!0,setTimeout(()=>{n.docView&&n.hasFocus()&&!n.domObserver.currentSelection.eq(n.domSelectionRange())&&et(n)},20))},fe.blur=(n,e)=>{let t=e;n.focused&&(n.domObserver.stop(),n.dom.classList.remove("ProseMirror-focused"),n.domObserver.start(),t.relatedTarget&&n.dom.contains(t.relatedTarget)&&n.domObserver.currentSelection.clear(),n.focused=!1)},fe.beforeinput=(n,e)=>{if(ie&&Qe&&e.inputType=="deleteContentBackward"){n.domObserver.flushSoon();let{domChangeCount:r}=n.input;setTimeout(()=>{if(n.input.domChangeCount!=r||(n.dom.blur(),n.focus(),n.someProp("handleKeyDown",s=>s(n,Rt(8,"Backspace")))))return;let{$cursor:o}=n.state.selection;o&&o.pos>0&&n.dispatch(n.state.tr.delete(o.pos-1,o.pos).scrollIntoView())},50)}};for(let n in de)fe[n]=de[n];function Wn(n,e){if(n==e)return!0;for(let t in n)if(n[t]!==e[t])return!1;for(let t in e)if(!(t in n))return!1;return!0}let Na=class hf{constructor(e,t){this.toDOM=e,this.spec=t||jt,this.side=this.spec.side||0}map(e,t,r,o){let{pos:s,deleted:i}=e.mapResult(t.from+o,this.side<0?-1:1);return i?null:new Ve(s-r,s-r,this)}valid(){return!0}eq(e){return this==e||e instanceof hf&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Wn(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}},_n=class ai{constructor(e,t){this.attrs=e,this.spec=t||jt}map(e,t,r,o){let s=e.map(t.from+o,this.spec.inclusiveStart?-1:1)-r,i=e.map(t.to+o,this.spec.inclusiveEnd?1:-1)-r;return s>=i?null:new Ve(s,i,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof ai&&Wn(this.attrs,e.attrs)&&Wn(this.spec,e.spec)}static is(e){return e.type instanceof ai}destroy(){}},cp=class pf{constructor(e,t){this.attrs=e,this.spec=t||jt}map(e,t,r,o){let s=e.mapResult(t.from+o,1);if(s.deleted)return null;let i=e.mapResult(t.to+o,-1);return i.deleted||i.pos<=s.pos?null:new Ve(s.pos-r,i.pos-r,this)}valid(e,t){let{index:r,offset:o}=e.content.findIndex(t.from),s;return o==t.from&&!(s=e.child(r)).isText&&o+s.nodeSize==t.to}eq(e){return this==e||e instanceof pf&&Wn(this.attrs,e.attrs)&&Wn(this.spec,e.spec)}destroy(){}},Ve=class ar{constructor(e,t,r){this.from=e,this.to=t,this.type=r}copy(e,t){return new ar(e,t,this.type)}eq(e,t=0){return this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to}map(e,t,r){return this.type.map(e,this,t,r)}static widget(e,t,r){return new ar(e,e,new Na(t,r))}static inline(e,t,r,o){return new ar(e,t,new _n(r,o))}static node(e,t,r,o){return new ar(e,t,new cp(r,o))}get spec(){return this.type.spec}get inline(){return this.type instanceof _n}get widget(){return this.type instanceof Na}};const fn=[],jt={};let H=class Ot{constructor(e,t){this.local=e.length?e:fn,this.children=t.length?t:fn}static create(e,t){return t.length?Ir(t,e,0,jt):le}find(e,t,r){let o=[];return this.findInner(e??0,t??1e9,o,0,r),o}findInner(e,t,r,o,s){for(let i=0;i<this.local.length;i++){let l=this.local[i];l.from<=t&&l.to>=e&&(!s||s(l.spec))&&r.push(l.copy(l.from+o,l.to+o))}for(let i=0;i<this.children.length;i+=3)if(this.children[i]<t&&this.children[i+1]>e){let l=this.children[i]+1;this.children[i+2].findInner(e-l,t-l,r,o+l,s)}}map(e,t,r){return this==le||e.maps.length==0?this:this.mapInner(e,t,0,0,r||jt)}mapInner(e,t,r,o,s){let i;for(let l=0;l<this.local.length;l++){let a=this.local[l].map(e,r,o);a&&a.type.valid(t,a)?(i||(i=[])).push(a):s.onRemove&&s.onRemove(this.local[l].spec)}return this.children.length?up(this.children,i||[],e,t,r,o,s):i?new Ot(i.sort(Bt),fn):le}add(e,t){return t.length?this==le?Ot.create(e,t):this.addInner(e,t,0):this}addInner(e,t,r){let o,s=0;e.forEach((l,a)=>{let c=a+r,u;if(u=Oa(t,l,c)){for(o||(o=this.children.slice());s<o.length&&o[s]<a;)s+=3;o[s]==a?o[s+2]=o[s+2].addInner(l,u,c+1):o.splice(s,0,a,a+l.nodeSize,Ir(u,l,c+1,jt)),s+=3}});let i=Da(s?Ta(t):t,-r);for(let l=0;l<i.length;l++)i[l].type.valid(e,i[l])||i.splice(l--,1);return new Ot(i.length?this.local.concat(i).sort(Bt):this.local,o||this.children)}remove(e){return e.length==0||this==le?this:this.removeInner(e,0)}removeInner(e,t){let r=this.children,o=this.local;for(let s=0;s<r.length;s+=3){let i,l=r[s]+t,a=r[s+1]+t;for(let u=0,f;u<e.length;u++)(f=e[u])&&f.from>l&&f.to<a&&(e[u]=null,(i||(i=[])).push(f));if(!i)continue;r==this.children&&(r=this.children.slice());let c=r[s+2].removeInner(i,l+1);c!=le?r[s+2]=c:(r.splice(s,3),s-=3)}if(o.length){for(let s=0,i;s<e.length;s++)if(i=e[s])for(let l=0;l<o.length;l++)o[l].eq(i,t)&&(o==this.local&&(o=this.local.slice()),o.splice(l--,1))}return r==this.children&&o==this.local?this:o.length||r.length?new Ot(o,r):le}forChild(e,t){if(this==le)return this;if(t.isLeaf)return Ot.empty;let r,o;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=e){this.children[l]==e&&(r=this.children[l+2]);break}let s=e+1,i=s+t.content.size;for(let l=0;l<this.local.length;l++){let a=this.local[l];if(a.from<i&&a.to>s&&a.type instanceof _n){let c=Math.max(s,a.from)-s,u=Math.min(i,a.to)-s;c<u&&(o||(o=[])).push(a.copy(c,u))}}if(o){let l=new Ot(o.sort(Bt),fn);return r?new Ea([l,r]):l}return r||le}eq(e){if(this==e)return!0;if(!(e instanceof Ot)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let t=0;t<this.local.length;t++)if(!this.local[t].eq(e.local[t]))return!1;for(let t=0;t<this.children.length;t+=3)if(this.children[t]!=e.children[t]||this.children[t+1]!=e.children[t+1]||!this.children[t+2].eq(e.children[t+2]))return!1;return!0}locals(e){return ls(this.localsInner(e))}localsInner(e){if(this==le)return fn;if(e.inlineContent||!this.local.some(_n.is))return this.local;let t=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof _n||t.push(this.local[r]);return t}forEachSet(e){e(this)}};H.empty=new H([],[]),H.removeOverlap=ls;const le=H.empty;let Ea=class xn{constructor(e){this.members=e}map(e,t){const r=this.members.map(o=>o.map(e,t,jt));return xn.from(r)}forChild(e,t){if(t.isLeaf)return H.empty;let r=[];for(let o=0;o<this.members.length;o++){let s=this.members[o].forChild(e,t);s!=le&&(s instanceof xn?r=r.concat(s.members):r.push(s))}return xn.from(r)}eq(e){if(!(e instanceof xn)||e.members.length!=this.members.length)return!1;for(let t=0;t<this.members.length;t++)if(!this.members[t].eq(e.members[t]))return!1;return!0}locals(e){let t,r=!0;for(let o=0;o<this.members.length;o++){let s=this.members[o].localsInner(e);if(s.length)if(!t)t=s;else{r&&(t=t.slice(),r=!1);for(let i=0;i<s.length;i++)t.push(s[i])}}return t?ls(r?t:t.sort(Bt)):fn}static from(e){switch(e.length){case 0:return le;case 1:return e[0];default:return new xn(e.every(t=>t instanceof H)?e:e.reduce((t,r)=>t.concat(r instanceof H?r:r.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}};function up(n,e,t,r,o,s,i){let l=n.slice();for(let c=0,u=s;c<t.maps.length;c++){let f=0;t.maps[c].forEach((d,p,h,b)=>{let g=b-h-(p-d);for(let k=0;k<l.length;k+=3){let w=l[k+1];if(w<0||d>w+u-f)continue;let M=l[k]+u-f;p>=M?l[k+1]=d<=M?-2:-1:d>=u&&g&&(l[k]+=g,l[k+1]+=g)}f+=g}),u=t.maps[c].map(u,-1)}let a=!1;for(let c=0;c<l.length;c+=3)if(l[c+1]<0){if(l[c+1]==-2){a=!0,l[c+1]=-1;continue}let u=t.map(n[c]+s),f=u-o;if(f<0||f>=r.content.size){a=!0;continue}let d=t.map(n[c+1]+s,-1),p=d-o,{index:h,offset:b}=r.content.findIndex(f),g=r.maybeChild(h);if(g&&b==f&&b+g.nodeSize==p){let k=l[c+2].mapInner(t,g,u+1,n[c]+s+1,i);k!=le?(l[c]=f,l[c+1]=p,l[c+2]=k):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=fp(l,n,e,t,o,s,i),u=Ir(c,r,0,i);e=u.local;for(let f=0;f<l.length;f+=3)l[f+1]<0&&(l.splice(f,3),f-=3);for(let f=0,d=0;f<u.children.length;f+=3){let p=u.children[f];for(;d<l.length&&l[d]<p;)d+=3;l.splice(d,0,u.children[f],u.children[f+1],u.children[f+2])}}return new H(e.sort(Bt),l)}function Da(n,e){if(!e||!n.length)return n;let t=[];for(let r=0;r<n.length;r++){let o=n[r];t.push(new Ve(o.from+e,o.to+e,o.type))}return t}function fp(n,e,t,r,o,s,i){function l(a,c){for(let u=0;u<a.local.length;u++){let f=a.local[u].map(r,o,c);f?t.push(f):i.onRemove&&i.onRemove(a.local[u].spec)}for(let u=0;u<a.children.length;u+=3)l(a.children[u+2],a.children[u]+c+1)}for(let a=0;a<n.length;a+=3)n[a+1]==-1&&l(n[a+2],e[a]+s+1);return t}function Oa(n,e,t){if(e.isLeaf)return null;let r=t+e.nodeSize,o=null;for(let s=0,i;s<n.length;s++)(i=n[s])&&i.from>t&&i.to<r&&((o||(o=[])).push(i),n[s]=null);return o}function Ta(n){let e=[];for(let t=0;t<n.length;t++)n[t]!=null&&e.push(n[t]);return e}function Ir(n,e,t,r){let o=[],s=!1;e.forEach((l,a)=>{let c=Oa(n,l,a+t);if(c){s=!0;let u=Ir(c,l,t+a+1,r);u!=le&&o.push(a,a+l.nodeSize,u)}});let i=Da(s?Ta(n):n,-t).sort(Bt);for(let l=0;l<i.length;l++)i[l].type.valid(e,i[l])||(r.onRemove&&r.onRemove(i[l].spec),i.splice(l--,1));return i.length||o.length?new H(i,o):le}function Bt(n,e){return n.from-e.from||n.to-e.to}function ls(n){let e=n;for(let t=0;t<e.length-1;t++){let r=e[t];if(r.from!=r.to)for(let o=t+1;o<e.length;o++){let s=e[o];if(s.from==r.from){s.to!=r.to&&(e==n&&(e=n.slice()),e[o]=s.copy(s.from,r.to),va(e,o+1,s.copy(r.to,s.to)));continue}else{s.from<r.to&&(e==n&&(e=n.slice()),e[t]=r.copy(r.from,s.from),va(e,o,r.copy(s.from,r.to)));break}}}return e}function va(n,e,t){for(;e<n.length&&Bt(t,n[e])>0;)e++;n.splice(e,0,t)}function as(n){let e=[];return n.someProp("decorations",t=>{let r=t(n.state);r&&r!=le&&e.push(r)}),n.cursorWrapper&&e.push(H.create(n.state.doc,[n.cursorWrapper.deco])),Ea.from(e)}const dp={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},hp=ye&&dt<=11;let pp=class{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}};class mp{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new pp,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let o=0;o<r.length;o++)this.queue.push(r[o]);ye&&dt<=11&&r.some(o=>o.type=="childList"&&o.removedNodes.length||o.type=="characterData"&&o.oldValue.length>o.target.nodeValue.length)?this.flushSoon():this.flush()}),hp&&(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,dp)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let t=0;t<e.length;t++)this.queue.push(e[t]);window.setTimeout(()=>this.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(ta(this.view)){if(this.suppressingSelectionUpdates)return et(this.view);if(ye&&dt<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Vt(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t=new Set,r;for(let s=e.focusNode;s;s=In(s))t.add(s);for(let s=e.anchorNode;s;s=In(s))if(t.has(s)){r=s;break}let o=r&&this.view.docView.nearestDesc(r);if(o&&o.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 t=this.pendingRecords();t.length&&(this.queue=[]);let r=e.domSelectionRange(),o=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&ta(e)&&!this.ignoreSelectionChange(r),s=-1,i=-1,l=!1,a=[];if(e.editable)for(let u=0;u<t.length;u++){let f=this.registerMutation(t[u],a);f&&(s=s<0?f.from:Math.min(f.from,s),i=i<0?f.to:Math.max(f.to,i),f.typeOver&&(l=!0))}if(Ie&&a.length){let u=a.filter(f=>f.nodeName=="BR");if(u.length==2){let[f,d]=u;f.parentNode&&f.parentNode.parentNode==d.parentNode?d.remove():f.remove()}else{let{focusNode:f}=this.currentSelection;for(let d of u){let p=d.parentNode;p&&p.nodeName=="LI"&&(!f||bp(e,f)!=p)&&d.remove()}}}let c=null;s<0&&o&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&Dr(r)&&(c=Go(e))&&c.eq(R.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,et(e),this.currentSelection.set(r),e.scrollToSelection()):(s>-1||o)&&(s>-1&&(e.docView.markDirty(s,i),gp(e)),this.handleDOMChange(s,i,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||et(e),this.currentSelection.set(r))}registerMutation(e,t){if(t.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 u=0;u<e.addedNodes.length;u++){let f=e.addedNodes[u];t.push(f),f.nodeType==3&&(this.lastChangedTextNode=f)}if(r.contentDOM&&r.contentDOM!=r.dom&&!r.contentDOM.contains(e.target))return{from:r.posBefore,to:r.posAfter};let o=e.previousSibling,s=e.nextSibling;if(ye&&dt<=11&&e.addedNodes.length)for(let u=0;u<e.addedNodes.length;u++){let{previousSibling:f,nextSibling:d}=e.addedNodes[u];(!f||Array.prototype.indexOf.call(e.addedNodes,f)<0)&&(o=f),(!d||Array.prototype.indexOf.call(e.addedNodes,d)<0)&&(s=d)}let i=o&&o.parentNode==e.target?ne(o)+1:0,l=r.localPosFromDOM(e.target,i,-1),a=s&&s.parentNode==e.target?ne(s):e.target.childNodes.length,c=r.localPosFromDOM(e.target,a,1);return{from:l,to:c}}else return e.type=="attributes"?{from:r.posAtStart-r.border,to:r.posAtEnd+r.border}:(this.lastChangedTextNode=e.target,{from:r.posAtStart,to:r.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let Aa=new WeakMap,Pa=!1;function gp(n){if(!Aa.has(n)&&(Aa.set(n,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(n.dom).whiteSpace)!==-1)){if(n.requiresGeckoHackNode=Ie,Pa)return;console.warn("ProseMirror expects the CSS white-space property to be set, preferably to 'pre-wrap'. It is recommended to load style/prosemirror.css from the prosemirror-view package."),Pa=!0}}function Ia(n,e){let t=e.startContainer,r=e.startOffset,o=e.endContainer,s=e.endOffset,i=n.domAtPos(n.state.selection.anchor);return Vt(i.node,i.offset,o,s)&&([t,r,o,s]=[o,s,t,r]),{anchorNode:t,anchorOffset:r,focusNode:o,focusOffset:s}}function yp(n,e){if(e.getComposedRanges){let o=e.getComposedRanges(n.root)[0];if(o)return Ia(n,o)}let t;function r(o){o.preventDefault(),o.stopImmediatePropagation(),t=o.getTargetRanges()[0]}return n.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),n.dom.removeEventListener("beforeinput",r,!0),t?Ia(n,t):null}function bp(n,e){for(let t=e.parentNode;t&&t!=n.dom;t=t.parentNode){let r=n.docView.nearestDesc(t,!0);if(r&&r.node.isBlock)return t}return null}function xp(n,e,t){let{node:r,fromOffset:o,toOffset:s,from:i,to:l}=n.docView.parseRange(e,t),a=n.domSelectionRange(),c,u=a.anchorNode;if(u&&n.dom.contains(u.nodeType==1?u:u.parentNode)&&(c=[{node:u,offset:a.anchorOffset}],Dr(a)||c.push({node:a.focusNode,offset:a.focusOffset})),ie&&n.input.lastKeyCode===8)for(let g=s;g>o;g--){let k=r.childNodes[g-1],w=k.pmViewDesc;if(k.nodeName=="BR"&&!w){s=g;break}if(!w||w.size)break}let f=n.state.doc,d=n.someProp("domParser")||Pt.fromSchema(n.state.schema),p=f.resolve(i),h=null,b=d.parse(r,{topNode:p.parent,topMatch:p.parent.contentMatchAt(p.index()),topOpen:!0,from:o,to:s,preserveWhitespace:p.parent.type.whitespace=="pre"?"full":!0,findPositions:c,ruleFromNode:kp,context:p});if(c&&c[0].pos!=null){let g=c[0].pos,k=c[1]&&c[1].pos;k==null&&(k=g),h={anchor:g+i,head:k+i}}return{doc:b,sel:h,from:i,to:l}}function kp(n){let e=n.pmViewDesc;if(e)return e.parseRule();if(n.nodeName=="BR"&&n.parentNode){if(ue&&/^(ul|ol)$/i.test(n.parentNode.nodeName)){let t=document.createElement("div");return t.appendChild(document.createElement("li")),{skip:t}}else if(n.parentNode.lastChild==n||ue&&/^(tr|table)$/i.test(n.parentNode.nodeName))return{ignore:!0}}else if(n.nodeName=="IMG"&&n.getAttribute("mark-placeholder"))return{ignore:!0};return null}const Sp=/^(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 Cp(n,e,t,r,o){let s=n.input.compositionPendingChanges||(n.composing?n.input.compositionID:0);if(n.input.compositionPendingChanges=0,e<0){let T=n.input.lastSelectionTime>Date.now()-50?n.input.lastSelectionOrigin:null,L=Go(n,T);if(L&&!n.state.selection.eq(L)){if(ie&&Qe&&n.input.lastKeyCode===13&&Date.now()-100<n.input.lastKeyCodeTime&&n.someProp("handleKeyDown",Et=>Et(n,Rt(13,"Enter"))))return;let we=n.state.tr.setSelection(L);T=="pointer"?we.setMeta("pointer",!0):T=="key"&&we.scrollIntoView(),s&&we.setMeta("composition",s),n.dispatch(we)}return}let i=n.state.doc.resolve(e),l=i.sharedDepth(t);e=i.before(l+1),t=n.state.doc.resolve(t).after(l+1);let a=n.state.selection,c=xp(n,e,t),u=n.state.doc,f=u.slice(c.from,c.to),d,p;n.input.lastKeyCode===8&&Date.now()-100<n.input.lastKeyCodeTime?(d=n.state.selection.to,p="end"):(d=n.state.selection.from,p="start"),n.input.lastKeyCode=null;let h=Np(f.content,c.doc.content,c.from,d,p);if(h&&n.input.domChangeCount++,(sn&&n.input.lastIOSEnter>Date.now()-225||Qe)&&o.some(T=>T.nodeType==1&&!Sp.test(T.nodeName))&&(!h||h.endA>=h.endB)&&n.someProp("handleKeyDown",T=>T(n,Rt(13,"Enter")))){n.input.lastIOSEnter=0;return}if(!h)if(r&&a instanceof P&&!a.empty&&a.$head.sameParent(a.$anchor)&&!n.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))h={start:a.from,endA:a.to,endB:a.to};else{if(c.sel){let T=Va(n,n.state.doc,c.sel);if(T&&!T.eq(n.state.selection)){let L=n.state.tr.setSelection(T);s&&L.setMeta("composition",s),n.dispatch(L)}}return}n.state.selection.from<n.state.selection.to&&h.start==h.endB&&n.state.selection instanceof P&&(h.start>n.state.selection.from&&h.start<=n.state.selection.from+2&&n.state.selection.from>=c.from?h.start=n.state.selection.from:h.endA<n.state.selection.to&&h.endA>=n.state.selection.to-2&&n.state.selection.to<=c.to&&(h.endB+=n.state.selection.to-h.endA,h.endA=n.state.selection.to)),ye&&dt<=11&&h.endB==h.start+1&&h.endA==h.start&&h.start>c.from&&c.doc.textBetween(h.start-c.from-1,h.start-c.from+1)==" "&&(h.start--,h.endA--,h.endB--);let b=c.doc.resolveNoCache(h.start-c.from),g=c.doc.resolveNoCache(h.endB-c.from),k=u.resolve(h.start),w=b.sameParent(g)&&b.parent.inlineContent&&k.end()>=h.endA,M;if((sn&&n.input.lastIOSEnter>Date.now()-225&&(!w||o.some(T=>T.nodeName=="DIV"||T.nodeName=="P"))||!w&&b.pos<c.doc.content.size&&!b.sameParent(g)&&(M=R.findFrom(c.doc.resolve(b.pos+1),1,!0))&&M.head==g.pos)&&n.someProp("handleKeyDown",T=>T(n,Rt(13,"Enter")))){n.input.lastIOSEnter=0;return}if(n.state.selection.anchor>h.start&&Mp(u,h.start,h.endA,b,g)&&n.someProp("handleKeyDown",T=>T(n,Rt(8,"Backspace")))){Qe&&ie&&n.domObserver.suppressSelectionUpdates();return}ie&&h.endB==h.start&&(n.input.lastChromeDelete=Date.now()),Qe&&!w&&b.start()!=g.start()&&g.parentOffset==0&&b.depth==g.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==h.endA&&(h.endB-=2,g=c.doc.resolveNoCache(h.endB-c.from),setTimeout(()=>{n.someProp("handleKeyDown",function(T){return T(n,Rt(13,"Enter"))})},20));let O=h.start,I=h.endA,C,V,z;if(w){if(b.pos==g.pos)ye&&dt<=11&&b.parentOffset==0&&(n.domObserver.suppressSelectionUpdates(),setTimeout(()=>et(n),20)),C=n.state.tr.delete(O,I),V=u.resolve(h.start).marksAcross(u.resolve(h.endA));else if(h.endA==h.endB&&(z=wp(b.parent.content.cut(b.parentOffset,g.parentOffset),k.parent.content.cut(k.parentOffset,h.endA-k.start()))))C=n.state.tr,z.type=="add"?C.addMark(O,I,z.mark):C.removeMark(O,I,z.mark);else if(b.parent.child(b.index()).isText&&b.index()==g.index()-(g.textOffset?0:1)){let T=b.parent.textBetween(b.parentOffset,g.parentOffset);if(n.someProp("handleTextInput",L=>L(n,O,I,T)))return;C=n.state.tr.insertText(T,O,I)}}if(C||(C=n.state.tr.replace(O,I,c.doc.slice(h.start-c.from,h.endB-c.from))),c.sel){let T=Va(n,C.doc,c.sel);T&&!(ie&&n.composing&&T.empty&&(h.start!=h.endB||n.input.lastChromeDelete<Date.now()-100)&&(T.head==O||T.head==C.mapping.map(I)-1)||ye&&T.empty&&T.head==O)&&C.setSelection(T)}V&&C.ensureMarks(V),s&&C.setMeta("composition",s),n.dispatch(C.scrollIntoView())}function Va(n,e,t){return Math.max(t.anchor,t.head)>e.content.size?null:Uo(n,e.resolve(t.anchor),e.resolve(t.head))}function wp(n,e){let t=n.firstChild.marks,r=e.firstChild.marks,o=t,s=r,i,l,a;for(let u=0;u<r.length;u++)o=r[u].removeFromSet(o);for(let u=0;u<t.length;u++)s=t[u].removeFromSet(s);if(o.length==1&&s.length==0)l=o[0],i="add",a=u=>u.mark(l.addToSet(u.marks));else if(o.length==0&&s.length==1)l=s[0],i="remove",a=u=>u.mark(l.removeFromSet(u.marks));else return null;let c=[];for(let u=0;u<e.childCount;u++)c.push(a(e.child(u)));if(S.from(c).eq(n))return{mark:l,type:i}}function Mp(n,e,t,r,o){if(t-e<=o.pos-r.pos||cs(r,!0,!1)<o.pos)return!1;let s=n.resolve(e);if(!r.parent.isTextblock){let l=s.nodeAfter;return l!=null&&t==e+l.nodeSize}if(s.parentOffset<s.parent.content.size||!s.parent.isTextblock)return!1;let i=n.resolve(cs(s,!0,!0));return!i.parent.isTextblock||i.pos>t||cs(i,!0,!1)<t?!1:r.parent.content.cut(r.parentOffset).eq(i.parent.content)}function cs(n,e,t){let r=n.depth,o=e?n.end():n.pos;for(;r>0&&(e||n.indexAfter(r)==n.node(r).childCount);)r--,o++,e=!1;if(t){let s=n.node(r).maybeChild(n.indexAfter(r));for(;s&&!s.isLeaf;)s=s.firstChild,o++}return o}function Np(n,e,t,r,o){let s=n.findDiffStart(e,t);if(s==null)return null;let{a:i,b:l}=n.findDiffEnd(e,t+n.size,t+e.size);if(o=="end"){let a=Math.max(0,s-Math.min(i,l));r-=i+a-s}if(i<s&&n.size<e.size){let a=r<=s&&r>=i?s-r:0;s-=a,s&&s<e.size&&Ra(e.textBetween(s-1,s+1))&&(s+=a?1:-1),l=s+(l-i),i=s}else if(l<s){let a=r<=s&&r>=l?s-r:0;s-=a,s&&s<n.size&&Ra(n.textBetween(s-1,s+1))&&(s+=a?1:-1),i=s+(i-l),l=s}return{start:s,endA:i,endB:l}}function Ra(n){if(n.length!=2)return!1;let e=n.charCodeAt(0),t=n.charCodeAt(1);return e>=56320&&e<=57343&&t>=55296&&t<=56319}class Ep{constructor(e,t){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new qh,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(Fa),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=ja(this),$a(this),this.nodeViews=Ba(this),this.docView=Wl(this.state.doc,za(this),as(this),this.dom,this),this.domObserver=new mp(this,(r,o,s,i)=>Cp(this,r,o,s,i)),this.domObserver.start(),Hh(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let t in e)this._props[t]=e[t];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&ns(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Fa),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let r in this._props)t[r]=this._props[r];t.state=this.state;for(let r in e)t[r]=e[r];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var r;let o=this.state,s=!1,i=!1;e.storedMarks&&this.composing&&(Sa(this),i=!0),this.state=e;let l=o.plugins!=e.plugins||this._props.plugins!=t.plugins;if(l||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let p=Ba(this);Op(p,this.nodeViews)&&(this.nodeViews=p,s=!0)}(l||t.handleDOMEvents!=this._props.handleDOMEvents)&&ns(this),this.editable=ja(this),$a(this);let a=as(this),c=za(this),u=o.plugins!=e.plugins&&!o.doc.eq(e.doc)?"reset":e.scrollToSelection>o.scrollToSelection?"to selection":"preserve",f=s||!this.docView.matchesNode(e.doc,c,a);(f||!e.selection.eq(o.selection))&&(i=!0);let d=u=="preserve"&&i&&this.dom.style.overflowAnchor==null&&sh(this);if(i){this.domObserver.stop();let p=f&&(ye||ie)&&!this.composing&&!o.selection.empty&&!e.selection.empty&&Dp(o.selection,e.selection);if(f){let h=ie?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=op(this)),(s||!this.docView.update(e.doc,c,a,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=Wl(e.doc,c,a,this.dom,this)),h&&!this.trackWrites&&(p=!0)}p||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&Th(this))?et(this,p):(Zl(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(o),!((r=this.dragging)===null||r===void 0)&&r.node&&!o.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,o),u=="reset"?this.dom.scrollTop=0:u=="to selection"?this.scrollToSelection():d&&ih(d)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof D){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&Tl(this,t.getBoundingClientRect(),e)}else Tl(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 t=0;t<this.directPlugins.length;t++){let r=this.directPlugins[t];r.spec.view&&this.pluginViews.push(r.spec.view(this))}for(let t=0;t<this.state.plugins.length;t++){let r=this.state.plugins[t];r.spec.view&&this.pluginViews.push(r.spec.view(this))}}else for(let t=0;t<this.pluginViews.length;t++){let r=this.pluginViews[t];r.update&&r.update(this,e)}}updateDraggedNode(e,t){let r=e.node,o=-1;if(this.state.doc.nodeAt(r.from)==r.node)o=r.from;else{let s=r.from+(this.state.doc.content.size-t.doc.content.size);(s>0&&this.state.doc.nodeAt(s))==r.node&&(o=s)}this.dragging=new wa(e.slice,e.move,o<0?void 0:D.create(this.state.doc,o))}someProp(e,t){let r=this._props&&this._props[e],o;if(r!=null&&(o=t?t(r):r))return o;for(let i=0;i<this.directPlugins.length;i++){let l=this.directPlugins[i].props[e];if(l!=null&&(o=t?t(l):l))return o}let s=this.state.plugins;if(s)for(let i=0;i<s.length;i++){let l=s[i].props[e];if(l!=null&&(o=t?t(l):l))return o}}hasFocus(){if(ye){let e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if(e.contentEditable=="false")return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&lh(this.dom),et(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let t=this.dom.parentNode;t;t=t.parentNode)if(t.nodeType==9||t.nodeType==11&&t.host)return t.getSelection||(Object.getPrototypeOf(t).getSelection=()=>t.ownerDocument.getSelection()),this._root=t}return e||document}updateRoot(){this._root=null}posAtCoords(e){return dh(this,e)}coordsAtPos(e,t=1){return Rl(this,e,t)}domAtPos(e,t=0){return this.docView.domFromPos(e,t)}nodeDOM(e){let t=this.docView.descAt(e);return t?t.nodeDOM:null}posAtDOM(e,t,r=-1){let o=this.docView.posFromDOM(e,t,r);if(o==null)throw new RangeError("DOM position not inside the editor");return o}endOfTextblock(e,t){return yh(this,t||this.state,e)}pasteHTML(e,t){return Ln(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return Ln(this,e,null,!0,t||new ClipboardEvent("paste"))}destroy(){this.docView&&(Kh(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],as(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Yd())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return Yh(this,e)}dispatch(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))}domSelectionRange(){let e=this.domSelection();return e?ue&&this.root.nodeType===11&&Zd(this.dom.ownerDocument)==this.dom&&yp(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}function za(n){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(n.editable),n.someProp("attributes",t=>{if(typeof t=="function"&&(t=t(n.state)),t)for(let r in t)r=="class"?e.class+=" "+t[r]:r=="style"?e.style=(e.style?e.style+";":"")+t[r]:!e[r]&&r!="contenteditable"&&r!="nodeName"&&(e[r]=String(t[r]))}),e.translate||(e.translate="no"),[Ve.node(0,n.state.doc.content.size,e)]}function $a(n){if(n.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),n.cursorWrapper={dom:e,deco:Ve.widget(n.state.selection.from,e,{raw:!0,marks:n.markCursor})}}else n.cursorWrapper=null}function ja(n){return!n.someProp("editable",e=>e(n.state)===!1)}function Dp(n,e){let t=Math.min(n.$anchor.sharedDepth(n.head),e.$anchor.sharedDepth(e.head));return n.$anchor.start(t)!=e.$anchor.start(t)}function Ba(n){let e=Object.create(null);function t(r){for(let o in r)Object.prototype.hasOwnProperty.call(e,o)||(e[o]=r[o])}return n.someProp("nodeViews",t),n.someProp("markViews",t),e}function Op(n,e){let t=0,r=0;for(let o in n){if(n[o]!=e[o])return!0;t++}for(let o in e)r++;return t!=r}function Fa(n){if(n.spec.state||n.spec.filterTransaction||n.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}class q extends R{constructor(e){super(e,e)}map(e,t){let r=e.resolve(t.map(this.head));return q.valid(r)?new q(r):R.near(r)}content(){return N.empty}eq(e){return e instanceof q&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new q(e.resolve(t.pos))}getBookmark(){return new us(this.anchor)}static valid(e){let t=e.parent;if(t.isTextblock||!Tp(e)||!vp(e))return!1;let r=t.type.spec.allowGapCursor;if(r!=null)return r;let o=t.contentMatchAt(e.index()).defaultType;return o&&o.isTextblock}static findGapCursorFrom(e,t,r=!1){e:for(;;){if(!r&&q.valid(e))return e;let o=e.pos,s=null;for(let i=e.depth;;i--){let l=e.node(i);if(t>0?e.indexAfter(i)<l.childCount:e.index(i)>0){s=l.child(t>0?e.indexAfter(i):e.index(i)-1);break}else if(i==0)return null;o+=t;let a=e.doc.resolve(o);if(q.valid(a))return a}for(;;){let i=t>0?s.firstChild:s.lastChild;if(!i){if(s.isAtom&&!s.isText&&!D.isSelectable(s)){e=e.doc.resolve(o+s.nodeSize*t),r=!1;continue e}break}s=i,o+=t;let l=e.doc.resolve(o);if(q.valid(l))return l}return null}}}q.prototype.visible=!1,q.findFrom=q.findGapCursorFrom,R.jsonID("gapcursor",q);class us{constructor(e){this.pos=e}map(e){return new us(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return q.valid(t)?new q(t):R.near(t)}}function Tp(n){for(let e=n.depth;e>=0;e--){let t=n.index(e),r=n.node(e);if(t==0){if(r.type.spec.isolating)return!0;continue}for(let o=r.child(t-1);;o=o.lastChild){if(o.childCount==0&&!o.inlineContent||o.isAtom||o.type.spec.isolating)return!0;if(o.inlineContent)return!1}}return!0}function vp(n){for(let e=n.depth;e>=0;e--){let t=n.indexAfter(e),r=n.node(e);if(t==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let o=r.child(t);;o=o.firstChild){if(o.childCount==0&&!o.inlineContent||o.isAtom||o.type.spec.isolating)return!0;if(o.inlineContent)return!1}}return!0}function Ap(){return new Be({props:{decorations:Rp,createSelectionBetween(n,e,t){return e.pos==t.pos&&q.valid(t)?new q(t):null},handleClick:Ip,handleKeyDown:Pp,handleDOMEvents:{beforeinput:Vp}}})}const Pp=zo({ArrowLeft:Vr("horiz",-1),ArrowRight:Vr("horiz",1),ArrowUp:Vr("vert",-1),ArrowDown:Vr("vert",1)});function Vr(n,e){const t=n=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,o,s){let i=r.selection,l=e>0?i.$to:i.$from,a=i.empty;if(i instanceof P){if(!s.endOfTextblock(t)||l.depth==0)return!1;a=!1,l=r.doc.resolve(e>0?l.after():l.before())}let c=q.findGapCursorFrom(l,e,a);return c?(o&&o(r.tr.setSelection(new q(c))),!0):!1}}function Ip(n,e,t){if(!n||!n.editable)return!1;let r=n.state.doc.resolve(e);if(!q.valid(r))return!1;let o=n.posAtCoords({left:t.clientX,top:t.clientY});return o&&o.inside>-1&&D.isSelectable(n.state.doc.nodeAt(o.inside))?!1:(n.dispatch(n.state.tr.setSelection(new q(r))),!0)}function Vp(n,e){if(e.inputType!="insertCompositionText"||!(n.state.selection instanceof q))return!1;let{$from:t}=n.state.selection,r=t.parent.contentMatchAt(t.index()).findWrapping(n.state.schema.nodes.text);if(!r)return!1;let o=S.empty;for(let i=r.length-1;i>=0;i--)o=S.from(r[i].createAndFill(null,o));let s=n.state.tr.replace(t.pos,t.pos,new N(o,0,0));return s.setSelection(P.near(s.doc.resolve(t.pos+1))),n.dispatch(s),!1}function Rp(n){if(!(n.selection instanceof q))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",H.create(n.doc,[Ve.widget(n.selection.head,e,{key:"gapcursor"})])}const zp=["ol",0],$p=["ul",0],jp=["li",0],Bp={attrs:{order:{default:1,validate:"number"}},parseDOM:[{tag:"ol",getAttrs(n){return{order:n.hasAttribute("start")?+n.getAttribute("start"):1}}}],toDOM(n){return n.attrs.order==1?zp:["ol",{start:n.attrs.order},0]}},Fp={parseDOM:[{tag:"ul"}],toDOM(){return $p}},Lp={parseDOM:[{tag:"li"}],toDOM(){return jp},defining:!0};function fs(n,e){let t={};for(let r in n)t[r]=n[r];for(let r in e)t[r]=e[r];return t}function Wp(n,e,t){return n.append({ordered_list:fs(Bp,{content:"list_item+",group:t}),bullet_list:fs(Fp,{content:"list_item+",group:t}),list_item:fs(Lp,{content:e})})}function Rr(n,e=null){return function(t,r){let{$from:o,$to:s}=t.selection,i=o.blockRange(s);if(!i)return!1;let l=r?t.tr:null;return _p(l,i,n,e)?(r&&r(l.scrollIntoView()),!0):!1}}function _p(n,e,t,r=null){let o=!1,s=e,i=e.$from.doc;if(e.depth>=2&&e.$from.node(e.depth-1).type.compatibleContent(t)&&e.startIndex==0){if(e.$from.index(e.depth-1)==0)return!1;let a=i.resolve(e.start-2);s=new hr(a,a,e.depth),e.endIndex<e.parent.childCount&&(e=new hr(e.$from,i.resolve(e.$to.end(e.depth)),e.depth)),o=!0}let l=ko(s,t,r,e);return l?(n&&qp(n,e,l,o,t),!0):!1}function qp(n,e,t,r,o){let s=S.empty;for(let u=t.length-1;u>=0;u--)s=S.from(t[u].type.create(t[u].attrs,s));n.step(new ee(e.start-(r?2:0),e.end,e.start,e.end,new N(s,0,0),t.length,!0));let i=0;for(let u=0;u<t.length;u++)t[u].type==o&&(i=u+1);let l=t.length-i,a=e.start+t.length-(r?2:0),c=e.parent;for(let u=e.startIndex,f=e.endIndex,d=!0;u<f;u++,d=!1)!d&&Qt(n.doc,a,l)&&(n.split(a,l),a+=2*l),a+=c.child(u).nodeSize;return n}function Hp(n,e){return function(t,r){let{$from:o,$to:s,node:i}=t.selection;if(i&&i.isBlock||o.depth<2||!o.sameParent(s))return!1;let l=o.node(-1);if(l.type!=n)return!1;if(o.parent.content.size==0&&o.node(-1).childCount==o.indexAfter(-1)){if(o.depth==3||o.node(-3).type!=n||o.index(-2)!=o.node(-2).childCount-1)return!1;if(r){let f=S.empty,d=o.index(-1)?1:o.index(-2)?2:3;for(let k=o.depth-d;k>=o.depth-3;k--)f=S.from(o.node(k).copy(f));let p=o.indexAfter(-1)<o.node(-2).childCount?1:o.indexAfter(-2)<o.node(-3).childCount?2:3;f=f.append(S.from(n.createAndFill()));let h=o.before(o.depth-(d-1)),b=t.tr.replace(h,o.after(-p),new N(f,4-d,0)),g=-1;b.doc.nodesBetween(h,b.doc.content.size,(k,w)=>{if(g>-1)return!1;k.isTextblock&&k.content.size==0&&(g=w+1)}),g>-1&&b.setSelection(R.near(b.doc.resolve(g))),r(b.scrollIntoView())}return!0}let a=s.pos==o.end()?l.contentMatchAt(0).defaultType:null,c=t.tr.delete(o.pos,s.pos),u=a?[null,{type:a}]:void 0;return Qt(c.doc,o.pos,2,u)?(r&&r(c.split(o.pos,2,u).scrollIntoView()),!0):!1}}function Kp(n){return function(e,t){let{$from:r,$to:o}=e.selection,s=r.blockRange(o,i=>i.childCount>0&&i.firstChild.type==n);return s?t?r.node(s.depth-1).type==n?Jp(e,t,n,s):Yp(e,t,s):!0:!1}}function Jp(n,e,t,r){let o=n.tr,s=r.end,i=r.$to.end(r.depth);s<i&&(o.step(new ee(s-1,i,s,i,new N(S.from(t.create(null,r.parent.copy())),1,0),1,!0)),r=new hr(o.doc.resolve(r.$from.pos),o.doc.resolve(i),r.depth));const l=On(r);if(l==null)return!1;o.lift(r,l);let a=o.doc.resolve(o.mapping.map(s,-1)-1);return Zt(o.doc,a.pos)&&a.nodeBefore.type==a.nodeAfter.type&&o.join(a.pos),e(o.scrollIntoView()),!0}function Yp(n,e,t){let r=n.tr,o=t.parent;for(let p=t.end,h=t.endIndex-1,b=t.startIndex;h>b;h--)p-=o.child(h).nodeSize,r.delete(p-1,p+1);let s=r.doc.resolve(t.start),i=s.nodeAfter;if(r.mapping.map(t.end)!=t.start+s.nodeAfter.nodeSize)return!1;let l=t.startIndex==0,a=t.endIndex==o.childCount,c=s.node(-1),u=s.index(-1);if(!c.canReplace(u+(l?0:1),u+1,i.content.append(a?S.empty:S.from(o))))return!1;let f=s.pos,d=f+i.nodeSize;return r.step(new ee(f-(l?1:0),d+(a?1:0),f+1,d-1,new N((l?S.empty:S.from(o.copy(S.empty))).append(a?S.empty:S.from(o.copy(S.empty))),l?0:1,a?0:1),l?0:1)),e(r.scrollIntoView()),!0}function Gp(n){return function(e,t){let{$from:r,$to:o}=e.selection,s=r.blockRange(o,c=>c.childCount>0&&c.firstChild.type==n);if(!s)return!1;let i=s.startIndex;if(i==0)return!1;let l=s.parent,a=l.child(i-1);if(a.type!=n)return!1;if(t){let c=a.lastChild&&a.lastChild.type==l.type,u=S.from(c?n.create():null),f=new N(S.from(n.create(null,S.from(l.type.create(null,u)))),c?3:1,0),d=s.start,p=s.end;t(e.tr.step(new ee(d-(c?3:1),p,d,p,f,1,!0)).scrollIntoView())}return!0}}class gt{constructor(e,t,r={}){this.match=e,this.match=e,this.handler=typeof t=="string"?Xp(t):t,this.undoable=r.undoable!==!1,this.inCode=r.inCode||!1,this.inCodeMark=r.inCodeMark!==!1}}function Xp(n){return function(e,t,r,o){let s=n;if(t[1]){let i=t[0].lastIndexOf(t[1]);s+=t[0].slice(i+t[1].length),r+=i;let l=r-o;l>0&&(s=t[0].slice(i-l,i)+s,r=o)}return e.tr.insertText(s,r,o)}}const Up=500;function Qp({rules:n}){let e=new Be({state:{init(){return null},apply(t,r){let o=t.getMeta(this);return o||(t.selectionSet||t.docChanged?null:r)}},props:{handleTextInput(t,r,o,s){return La(t,r,o,s,n,e)},handleDOMEvents:{compositionend:t=>{setTimeout(()=>{let{$cursor:r}=t.state.selection;r&&La(t,r.pos,r.pos,"",n,e)})}}},isInputRules:!0});return e}function La(n,e,t,r,o,s){if(n.composing)return!1;let i=n.state,l=i.doc.resolve(e),a=l.parent.textBetween(Math.max(0,l.parentOffset-Up),l.parentOffset,null,"")+r;for(let c=0;c<o.length;c++){let u=o[c];if(!u.inCodeMark&&l.marks().some(p=>p.type.spec.code))continue;if(l.parent.type.spec.code){if(!u.inCode)continue}else if(u.inCode==="only")continue;let f=u.match.exec(a),d=f&&f[0].length>=r.length&&u.handler(i,f,e-(f[0].length-r.length),t);if(d)return u.undoable&&d.setMeta(s,{transform:d,from:e,to:t,text:r}),n.dispatch(d),!0}return!1}const Zp=(n,e)=>{let t=n.plugins;for(let r=0;r<t.length;r++){let o=t[r],s;if(o.spec.isInputRules&&(s=o.getState(n))){if(e){let i=n.tr,l=s.transform;for(let a=l.steps.length-1;a>=0;a--)i.step(l.steps[a].invert(l.docs[a]));if(s.text){let a=i.doc.resolve(s.from).marks();i.replaceWith(s.from,s.to,n.schema.text(s.text,a))}else i.delete(s.from,s.to);e(i)}return!0}}return!1},em=new gt(/--$/,"—",{inCodeMark:!1}),tm=new gt(/\.\.\.$/,"…",{inCodeMark:!1}),nm=new gt(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,"“",{inCodeMark:!1}),rm=new gt(/"$/,"”",{inCodeMark:!1}),om=new gt(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,"‘",{inCodeMark:!1}),sm=new gt(/'$/,"’",{inCodeMark:!1}),im=[nm,rm,om,sm];function ds(n,e,t=null,r){return new gt(n,(o,s,i,l)=>{let a=t instanceof Function?t(s):t,c=o.tr.delete(i,l),u=c.doc.resolve(i),f=u.blockRange(),d=f&&ko(f,e,a);if(!d)return null;c.wrap(f,d);let p=c.doc.resolve(i-1).nodeBefore;return p&&p.type==e&&Zt(c.doc,i-1)&&(!r||r(s,p))&&c.join(i-1),c})}function Wa(n,e,t=null){return new gt(n,(r,o,s,i)=>{let l=r.doc.resolve(s),a=t instanceof Function?t(o):t;return l.node(-1).canReplaceWith(l.index(-1),l.indexAfter(-1),e)?r.tr.delete(s,i).setBlockType(s,s,e,a):null})}const _a=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):!1;function lm(n,e){let t={},r;function o(s,i){t[s]=i}if(o("Mod-z",Ao),o("Shift-Mod-z",Mr),o("Backspace",Zp),_a||o("Mod-y",Mr),o("Alt-ArrowUp",bl),o("Alt-ArrowDown",Vd),o("Mod-BracketLeft",$o),o("Escape",Bo),(r=n.marks.strong)&&(o("Mod-b",ke(r)),o("Mod-B",ke(r))),(r=n.marks.em)&&(o("Mod-i",ke(r)),o("Mod-I",ke(r))),(r=n.marks.code)&&o("Mod-`",ke(r)),(r=n.nodes.bullet_list)&&o("Shift-Ctrl-8",Rr(r)),(r=n.nodes.ordered_list)&&o("Shift-Ctrl-9",Rr(r)),(r=n.nodes.blockquote)&&o("Ctrl->",Cl(r)),r=n.nodes.hard_break){let s=r,i=Er(xl,(l,a)=>(a&&a(l.tr.replaceSelectionWith(s.create()).scrollIntoView()),!0));o("Mod-Enter",i),o("Shift-Enter",i),_a&&o("Ctrl-Enter",i)}if((r=n.nodes.list_item)&&(o("Enter",Hp(r)),o("Mod-[",Kp(r)),o("Mod-]",Gp(r))),(r=n.nodes.paragraph)&&o("Shift-Ctrl-0",on(r)),(r=n.nodes.code_block)&&o("Shift-Ctrl-\\",on(r)),r=n.nodes.heading)for(let s=1;s<=6;s++)o("Shift-Ctrl-"+s,on(r,{level:s}));if(r=n.nodes.horizontal_rule){let s=r;o("Mod-_",(i,l)=>(l&&l(i.tr.replaceSelectionWith(s.create()).scrollIntoView()),!0))}return t}function am(n){return ds(/^\s*>\s$/,n)}function cm(n){return ds(/^(\d+)\.\s$/,n,e=>({order:+e[1]}),(e,t)=>t.childCount+t.attrs.order==+e[1])}function um(n){return ds(/^\s*([-+*])\s$/,n)}function fm(n){return Wa(/^```$/,n)}function dm(n,e){return Wa(new RegExp("^(#{1,"+e+"})\\s$"),n,t=>({level:t[1].length}))}function hm(n){let e=im.concat(tm,em),t;return(t=n.nodes.blockquote)&&e.push(am(t)),(t=n.nodes.ordered_list)&&e.push(cm(t)),(t=n.nodes.bullet_list)&&e.push(um(t)),(t=n.nodes.code_block)&&e.push(fm(t)),(t=n.nodes.heading)&&e.push(dm(t,6)),Qp({rules:e})}const tt=new lt("ImagePluginKey"),pm=n=>new Be({key:tt,state:{init(){return{set:H.empty,schema:n.schema,upload:n.upload}},apply(t,r){let o=r.set.map(t.mapping,t.doc);const s=t.getMeta(tt);if(s&&s.add){const i=document.createElement("placeholder"),l=Ve.widget(s.add.pos,i,{id:s.add.id,key:`imgphd${s.add.id}`});o=o.add(t.doc,[l])}else s&&s.remove&&(o=o.remove(o.find(void 0,void 0,i=>i.id==s.remove.id)));return{...r,set:o}}},props:{decorations(t){var r;return(r=this.getState(t))==null?void 0:r.set}}}),mm=(n,e)=>{const t=tt.getState(n).set,r=t==null?void 0:t.find(void 0,void 0,o=>o.id==e);return r!=null&&r.length?r[0].from:null},gm=async(n,e,t,r)=>{if(!e)return;const o=Date.now(),s=n.state.tr;r===void 0&&(s.selection.empty||s.deleteSelection(),r=s.selection.from),s.setMeta(tt,{add:{id:o,pos:r}}),n.dispatch(s);try{const i=tt.getState(n.state),l=i.schema,a=i.upload;if(!a)throw new Error("uploadImage: Image upload function not defined");const c=await a(e);if(typeof c=="string")throw new Error(c);const u=mm(n.state,o);if(u===null){console.warn("uploadImage: The image was removed from the document during upload");return}n.dispatch(n.state.tr.replaceWith(u,u,l.nodes.image.create({fid:c,title:t})).setMeta(tt,{remove:{id:o}}))}catch(i){n.dispatch(n.state.tr.setMeta(tt,{remove:{id:o}})),console.error(`uploadImage: ${i}`)}},ym=(n,e,t,r)=>{if(!e)return;const o=n.state.tr;r===void 0&&(o.selection.empty||o.deleteSelection(),r=o.selection.from);const s=tt.getState(n.state).schema;n.dispatch(n.state.tr.replaceWith(r,r,s.nodes.image.create({src:e,title:t})))},Ft=function(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e},qa=function(n,e,t,r){return t&&(Ha(n,e,t,r,-1)||Ha(n,e,t,r,1))},bm=/^(img|br|input|textarea|hr)$/i;function Ha(n,e,t,r,o){for(;;){if(n==t&&e==r)return!0;if(e==(o<0?0:zr(n))){let s=n.parentNode;if(!s||s.nodeType!=1||hs(n)||bm.test(n.nodeName)||n.contentEditable=="false")return!1;e=Ft(n)+(o<0?0:1),n=s}else if(n.nodeType==1){if(n=n.childNodes[e+(o<0?-1:0)],n.contentEditable=="false")return!1;e=o<0?zr(n):0}else return!1}}function zr(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function xm(n,e,t){for(let r=e==0,o=e==zr(n);r||o;){if(n==t)return!0;let s=Ft(n);if(n=n.parentNode,!n)return!1;r=r&&s==0,o=o&&s==zr(n)}}function hs(n){let e;for(let t=n;t&&!(e=t.pmViewDesc);t=t.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==n||e.contentDOM==n)}const Ka=function(n){return n.focusNode&&qa(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)};function Ja(n,e){let t=document.createEvent("Event");return t.initEvent("keydown",!0,!0),t.keyCode=n,t.key=t.code=e,t}const _e=typeof navigator<"u"?navigator:null,Ya=typeof document<"u"?document:null,yt=_e&&_e.userAgent||"",ps=/Edge\/(\d+)/.exec(yt),Ga=/MSIE \d/.exec(yt),ms=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(yt),qn=!!(Ga||ms||ps),Xa=Ga?document.documentMode:ms?+ms[1]:ps?+ps[1]:0,$r=!qn&&/gecko\/(\d+)/i.test(yt);$r&&+(/Firefox\/(\d+)/.exec(yt)||[0,0])[1];const gs=!qn&&/Chrome\/(\d+)/.exec(yt),bt=!!gs,Ua=gs?+gs[1]:0,Lt=!qn&&!!_e&&/Apple Computer/.test(_e.vendor),ys=Lt&&(/Mobile\/\w+/.test(yt)||!!_e&&_e.maxTouchPoints>2),De=ys||(_e?/Mac/.test(_e.platform):!1),km=_e?/Win/.test(_e.platform):!1,Hn=/Android \d/.test(yt),bs=!!Ya&&"webkitFontSmoothing"in Ya.documentElement.style,Sm=bs?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Cm(n,e=null){let t=n.domSelectionRange(),r=n.state.doc;if(!t.focusNode)return null;let o=n.docView.nearestDesc(t.focusNode),s=o&&o.size==0,i=n.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(i<0)return null;let l=r.resolve(i),a,c;if(Ka(t)){for(a=i;o&&!o.node;)o=o.parent;let f=o.node;if(o&&f.isAtom&&D.isSelectable(f)&&o.parent&&!(f.isInline&&xm(t.focusNode,t.focusOffset,o.dom))){let d=o.posBefore;c=new D(i==d?l:r.resolve(d))}}else{if(t instanceof n.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let f=i,d=i;for(let p=0;p<t.rangeCount;p++){let h=t.getRangeAt(p);f=Math.min(f,n.docView.posFromDOM(h.startContainer,h.startOffset,1)),d=Math.max(d,n.docView.posFromDOM(h.endContainer,h.endOffset,-1))}if(f<0)return null;[a,i]=d==n.state.selection.anchor?[d,f]:[f,d],l=r.resolve(i)}else a=n.docView.posFromDOM(t.anchorNode,t.anchorOffset,1);if(a<0)return null}let u=r.resolve(a);if(!c){let f=e=="pointer"||n.state.selection.head<l.pos&&!s?1:-1;c=rc(n,u,l,f)}return c}function Qa(n){return n.editable?n.hasFocus():Em(n)&&document.activeElement&&document.activeElement.contains(n.dom)}function xs(n,e=!1){let t=n.state.selection;if(Nm(n,t),!!Qa(n)){if(!e&&n.input.mouseDown&&n.input.mouseDown.allowDefault&&bt){let r=n.domSelectionRange(),o=n.domObserver.currentSelection;if(r.anchorNode&&o.anchorNode&&qa(r.anchorNode,r.anchorOffset,o.anchorNode,o.anchorOffset)){n.input.mouseDown.delayedSelectionSync=!0,n.domObserver.setCurSelection();return}}if(n.domObserver.disconnectSelection(),n.cursorWrapper)Mm(n);else{let{anchor:r,head:o}=t,s,i;Za&&!(t instanceof P)&&(t.$from.parent.inlineContent||(s=ec(n,t.from)),!t.empty&&!t.$from.parent.inlineContent&&(i=ec(n,t.to))),n.docView.setSelection(r,o,n,e),Za&&(s&&tc(s),i&&tc(i)),t.visible?n.dom.classList.remove("ProseMirror-hideselection"):(n.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&wm(n))}n.domObserver.setCurSelection(),n.domObserver.connectSelection()}}const Za=Lt||bt&&Ua<63;function ec(n,e){let{node:t,offset:r}=n.docView.domFromPos(e,0),o=r<t.childNodes.length?t.childNodes[r]:null,s=r?t.childNodes[r-1]:null;if(Lt&&o&&o.contentEditable=="false")return ks(o);if((!o||o.contentEditable=="false")&&(!s||s.contentEditable=="false")){if(o)return ks(o);if(s)return ks(s)}}function ks(n){return n.contentEditable="true",Lt&&n.draggable&&(n.draggable=!1,n.wasDraggable=!0),n}function tc(n){n.contentEditable="false",n.wasDraggable&&(n.draggable=!0,n.wasDraggable=null)}function wm(n){let e=n.dom.ownerDocument;e.removeEventListener("selectionchange",n.input.hideSelectionGuard);let t=n.domSelectionRange(),r=t.anchorNode,o=t.anchorOffset;e.addEventListener("selectionchange",n.input.hideSelectionGuard=()=>{(t.anchorNode!=r||t.anchorOffset!=o)&&(e.removeEventListener("selectionchange",n.input.hideSelectionGuard),setTimeout(()=>{(!Qa(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function Mm(n){let e=n.domSelection(),t=document.createRange();if(!e)return;let r=n.cursorWrapper.dom,o=r.nodeName=="IMG";o?t.setStart(r.parentNode,Ft(r)+1):t.setStart(r,0),t.collapse(!0),e.removeAllRanges(),e.addRange(t),!o&&!n.state.selection.visible&&qn&&Xa<=11&&(r.disabled=!0,r.disabled=!1)}function Nm(n,e){if(e instanceof D){let t=n.docView.descAt(e.from);t!=n.lastSelectedViewDesc&&(nc(n),t&&t.selectNode(),n.lastSelectedViewDesc=t)}else nc(n)}function nc(n){n.lastSelectedViewDesc&&(n.lastSelectedViewDesc.parent&&n.lastSelectedViewDesc.deselectNode(),n.lastSelectedViewDesc=void 0)}function rc(n,e,t,r){return n.someProp("createSelectionBetween",o=>o(n,e,t))||P.between(e,t,r)}function Em(n){let e=n.domSelectionRange();if(!e.anchorNode)return!1;try{return n.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(n.editable||n.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function Ss(n,e){let{$anchor:t,$head:r}=n.selection,o=e>0?t.max(r):t.min(r),s=o.parent.inlineContent?o.depth?n.doc.resolve(e>0?o.after():o.before()):null:o;return s&&R.findFrom(s,e)}function xt(n,e){return n.dispatch(n.state.tr.setSelection(e).scrollIntoView()),!0}function oc(n,e,t){let r=n.state.selection;if(r instanceof P)if(t.indexOf("s")>-1){let{$head:o}=r,s=o.textOffset?null:e<0?o.nodeBefore:o.nodeAfter;if(!s||s.isText||!s.isLeaf)return!1;let i=n.state.doc.resolve(o.pos+s.nodeSize*(e<0?-1:1));return xt(n,new P(r.$anchor,i))}else if(r.empty){if(n.endOfTextblock(e>0?"forward":"backward")){let o=Ss(n.state,e);return o&&o instanceof D?xt(n,o):!1}else if(!(De&&t.indexOf("m")>-1)){let o=r.$head,s=o.textOffset?null:e<0?o.nodeBefore:o.nodeAfter,i;if(!s||s.isText)return!1;let l=e<0?o.pos-s.nodeSize:o.pos;return s.isAtom||(i=n.docView.descAt(l))&&!i.contentDOM?D.isSelectable(s)?xt(n,new D(e<0?n.state.doc.resolve(o.pos-s.nodeSize):o)):bs?xt(n,new P(n.state.doc.resolve(e<0?l:l+s.nodeSize))):!1:!1}}else return!1;else{if(r instanceof D&&r.node.isInline)return xt(n,new P(e>0?r.$to:r.$from));{let o=Ss(n.state,e);return o?xt(n,o):!1}}}function jr(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Kn(n,e){let t=n.pmViewDesc;return t&&t.size==0&&(e<0||n.nextSibling||n.nodeName!="BR")}function dn(n,e){return e<0?Dm(n):Om(n)}function Dm(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let o,s,i=!1;for($r&&t.nodeType==1&&r<jr(t)&&Kn(t.childNodes[r],-1)&&(i=!0);;)if(r>0){if(t.nodeType!=1)break;{let l=t.childNodes[r-1];if(Kn(l,-1))o=t,s=--r;else if(l.nodeType==3)t=l,r=t.nodeValue.length;else break}}else{if(sc(t))break;{let l=t.previousSibling;for(;l&&Kn(l,-1);)o=t.parentNode,s=Ft(l),l=l.previousSibling;if(l)t=l,r=jr(t);else{if(t=t.parentNode,t==n.dom)break;r=0}}}i?Cs(n,t,r):o&&Cs(n,o,s)}function Om(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let o=jr(t),s,i;for(;;)if(r<o){if(t.nodeType!=1)break;let l=t.childNodes[r];if(Kn(l,1))s=t,i=++r;else break}else{if(sc(t))break;{let l=t.nextSibling;for(;l&&Kn(l,1);)s=l.parentNode,i=Ft(l)+1,l=l.nextSibling;if(l)t=l,r=0,o=jr(t);else{if(t=t.parentNode,t==n.dom)break;r=o=0}}}s&&Cs(n,s,i)}function sc(n){let e=n.pmViewDesc;return e&&e.node&&e.node.isBlock}function Tm(n,e){for(;n&&e==n.childNodes.length&&!hs(n);)e=Ft(n)+1,n=n.parentNode;for(;n&&e<n.childNodes.length;){let t=n.childNodes[e];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;n=t,e=0}}function vm(n,e){for(;n&&!e&&!hs(n);)e=Ft(n),n=n.parentNode;for(;n&&e;){let t=n.childNodes[e-1];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;n=t,e=n.childNodes.length}}function Cs(n,e,t){if(e.nodeType!=3){let s,i;(i=Tm(e,t))?(e=i,t=0):(s=vm(e,t))&&(e=s,t=s.nodeValue.length)}let r=n.domSelection();if(!r)return;if(Ka(r)){let s=document.createRange();s.setEnd(e,t),s.setStart(e,t),r.removeAllRanges(),r.addRange(s)}else r.extend&&r.extend(e,t);n.domObserver.setCurSelection();let{state:o}=n;setTimeout(()=>{n.state==o&&xs(n)},50)}function ic(n,e){let t=n.state.doc.resolve(e);if(!(bt||km)&&t.parent.inlineContent){let o=n.coordsAtPos(e);if(e>t.start()){let s=n.coordsAtPos(e-1),i=(s.top+s.bottom)/2;if(i>o.top&&i<o.bottom&&Math.abs(s.left-o.left)>1)return s.left<o.left?"ltr":"rtl"}if(e<t.end()){let s=n.coordsAtPos(e+1),i=(s.top+s.bottom)/2;if(i>o.top&&i<o.bottom&&Math.abs(s.left-o.left)>1)return s.left>o.left?"ltr":"rtl"}}return getComputedStyle(n.dom).direction=="rtl"?"rtl":"ltr"}function lc(n,e,t){let r=n.state.selection;if(r instanceof P&&!r.empty||t.indexOf("s")>-1||De&&t.indexOf("m")>-1)return!1;let{$from:o,$to:s}=r;if(!o.parent.inlineContent||n.endOfTextblock(e<0?"up":"down")){let i=Ss(n.state,e);if(i&&i instanceof D)return xt(n,i)}if(!o.parent.inlineContent){let i=e<0?o:s,l=r instanceof ge?R.near(i,e):R.findFrom(i,e);return l?xt(n,l):!1}return!1}function ac(n,e){if(!(n.state.selection instanceof P))return!0;let{$head:t,$anchor:r,empty:o}=n.state.selection;if(!t.sameParent(r))return!0;if(!o)return!1;if(n.endOfTextblock(e>0?"forward":"backward"))return!0;let s=!t.textOffset&&(e<0?t.nodeBefore:t.nodeAfter);if(s&&!s.isText){let i=n.state.tr;return e<0?i.delete(t.pos-s.nodeSize,t.pos):i.delete(t.pos,t.pos+s.nodeSize),n.dispatch(i),!0}return!1}function cc(n,e,t){n.domObserver.stop(),e.contentEditable=t,n.domObserver.start()}function Am(n){if(!Lt||n.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:t}=n.domSelectionRange();if(e&&e.nodeType==1&&t==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let r=e.firstChild;cc(n,r,"true"),setTimeout(()=>cc(n,r,"false"),20)}return!1}function Pm(n){let e="";return n.ctrlKey&&(e+="c"),n.metaKey&&(e+="m"),n.altKey&&(e+="a"),n.shiftKey&&(e+="s"),e}function Im(n,e){let t=e.keyCode,r=Pm(e);if(t==8||De&&t==72&&r=="c")return ac(n,-1)||dn(n,-1);if(t==46&&!e.shiftKey||De&&t==68&&r=="c")return ac(n,1)||dn(n,1);if(t==13||t==27)return!0;if(t==37||De&&t==66&&r=="c"){let o=t==37?ic(n,n.state.selection.from)=="ltr"?-1:1:-1;return oc(n,o,r)||dn(n,o)}else if(t==39||De&&t==70&&r=="c"){let o=t==39?ic(n,n.state.selection.from)=="ltr"?1:-1:1;return oc(n,o,r)||dn(n,o)}else{if(t==38||De&&t==80&&r=="c")return lc(n,-1,r)||dn(n,-1);if(t==40||De&&t==78&&r=="c")return Am(n)||lc(n,1,r)||dn(n,1);if(r==(De?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function uc(n,e){n.someProp("transformCopied",p=>{e=p(e,n)});let t=[],{content:r,openStart:o,openEnd:s}=e;for(;o>1&&s>1&&r.childCount==1&&r.firstChild.childCount==1;){o--,s--;let p=r.firstChild;t.push(p.type.name,p.attrs!=p.type.defaultAttrs?p.attrs:null),r=p.content}let i=n.someProp("clipboardSerializer")||$e.fromSchema(n.state.schema),l=bc(),a=l.createElement("div");a.appendChild(i.serializeFragment(r,{document:l}));let c=a.firstChild,u,f=0;for(;c&&c.nodeType==1&&(u=gc[c.nodeName.toLowerCase()]);){for(let p=u.length-1;p>=0;p--){let h=l.createElement(u[p]);for(;a.firstChild;)h.appendChild(a.firstChild);a.appendChild(h),f++}c=a.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${o} ${s}${f?` -${f}`:""} ${JSON.stringify(t)}`);let d=n.someProp("clipboardTextSerializer",p=>p(e,n))||e.content.textBetween(0,e.content.size,`
|
|
40
|
+
`);return{dom:a,text:d,slice:e}}function ua(n,e,t,r,o){let s=o.parent.type.spec.code,i,l;if(!t&&!e)return null;let a=e&&(r||s||!t);if(a){if(n.someProp("transformPastedText",d=>{e=d(e,s||r,n)}),s)return e?new N(C.from(n.state.schema.text(e.replace(/\r\n?/g,`
|
|
41
|
+
`))),0,0):N.empty;let f=n.someProp("clipboardTextParser",d=>d(e,o,r,n));if(f)l=f;else{let d=o.marks(),{schema:h}=n.state,p=$e.fromSchema(h);i=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(b=>{let g=i.appendChild(document.createElement("p"));b&&g.appendChild(p.serializeNode(h.text(b,d)))})}}else n.someProp("transformPastedHTML",f=>{t=f(t,n)}),i=Fh(t),Rn&&Lh(i);let c=i&&i.querySelector("[data-pm-slice]"),u=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(u&&u[3])for(let f=+u[3];f>0;f--){let d=i.firstChild;for(;d&&d.nodeType!=1;)d=d.nextSibling;if(!d)break;i=d}if(l||(l=(n.someProp("clipboardParser")||n.someProp("domParser")||Pt.fromSchema(n.state.schema)).parseSlice(i,{preserveWhitespace:!!(a||u),context:o,ruleFromNode(d){return d.nodeName=="BR"&&!d.nextSibling&&d.parentNode&&!$h.test(d.parentNode.nodeName)?{ignore:!0}:null}})),u)l=Wh(pa(l,+u[1],+u[2]),u[4]);else if(l=N.maxOpen(jh(l.content,o),!0),l.openStart||l.openEnd){let f=0,d=0;for(let h=l.content.firstChild;f<l.openStart&&!h.type.spec.isolating;f++,h=h.firstChild);for(let h=l.content.lastChild;d<l.openEnd&&!h.type.spec.isolating;d++,h=h.lastChild);l=pa(l,f,d)}return n.someProp("transformPasted",f=>{l=f(l,n)}),l}const $h=/^(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 jh(n,e){if(n.childCount<2)return n;for(let t=e.depth;t>=0;t--){let o=e.node(t).contentMatchAt(e.index(t)),s,i=[];if(n.forEach(l=>{if(!i)return;let a=o.findWrapping(l.type),c;if(!a)return i=null;if(c=i.length&&s.length&&da(a,s,l,i[i.length-1],0))i[i.length-1]=c;else{i.length&&(i[i.length-1]=ha(i[i.length-1],s.length));let u=fa(l,a);i.push(u),o=o.matchType(u.type),s=a}}),i)return C.from(i)}return n}function fa(n,e,t=0){for(let r=e.length-1;r>=t;r--)n=e[r].create(null,C.from(n));return n}function da(n,e,t,r,o){if(o<n.length&&o<e.length&&n[o]==e[o]){let s=da(n,e,t,r.lastChild,o+1);if(s)return r.copy(r.content.replaceChild(r.childCount-1,s));if(r.contentMatchAt(r.childCount).matchType(o==n.length-1?t.type:n[o+1]))return r.copy(r.content.append(C.from(fa(t,n,o+1))))}}function ha(n,e){if(e==0)return n;let t=n.content.replaceChild(n.childCount-1,ha(n.lastChild,e-1)),r=n.contentMatchAt(n.childCount).fillBefore(C.empty,!0);return n.copy(t.append(r))}function es(n,e,t,r,o,s){let i=e<0?n.firstChild:n.lastChild,l=i.content;return n.childCount>1&&(s=0),o<r-1&&(l=es(l,e,t,r,o+1,s)),o>=t&&(l=e<0?i.contentMatchAt(0).fillBefore(l,s<=o).append(l):l.append(i.contentMatchAt(i.childCount).fillBefore(C.empty,!0))),n.replaceChild(e<0?0:n.childCount-1,i.copy(l))}function pa(n,e,t){return e<n.openStart&&(n=new N(es(n.content,-1,e,n.openStart,0,n.openEnd),e,n.openEnd)),t<n.openEnd&&(n=new N(es(n.content,1,t,n.openEnd,0,0),n.openStart,t)),n}const ma={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};let ga=null;function ya(){return ga||(ga=document.implementation.createHTMLDocument("title"))}let ts=null;function Bh(n){let e=window.trustedTypes;return e?(ts||(ts=e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})),ts.createHTML(n)):n}function Fh(n){let e=/^(\s*<meta [^>]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=ya().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(n),o;if((o=r&&ma[r[1].toLowerCase()])&&(n=o.map(s=>"<"+s+">").join("")+n+o.map(s=>"</"+s+">").reverse().join("")),t.innerHTML=Bh(n),o)for(let s=0;s<o.length;s++)t=t.querySelector(o[s])||t;return t}function Lh(n){let e=n.querySelectorAll(ie?"span:not([class]):not([style])":"span.Apple-converted-space");for(let t=0;t<e.length;t++){let r=e[t];r.childNodes.length==1&&r.textContent==" "&&r.parentNode&&r.parentNode.replaceChild(n.ownerDocument.createTextNode(" "),r)}}function Wh(n,e){if(!n.size)return n;let t=n.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return n}let{content:o,openStart:s,openEnd:i}=n;for(let l=r.length-2;l>=0;l-=2){let a=t.nodes[r[l]];if(!a||a.hasRequiredAttrs())break;o=C.from(a.create(r[l+1],o)),s++,i++}return new N(o,s,i)}const fe={},de={},_h={touchstart:!0,touchmove:!0};class qh{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.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function Hh(n){for(let e in fe){let t=fe[e];n.dom.addEventListener(e,n.input.eventHandlers[e]=r=>{Jh(n,r)&&!rs(n,r)&&(n.editable||!(r.type in de))&&t(n,r)},_h[e]?{passive:!0}:void 0)}ue&&n.dom.addEventListener("input",()=>null),ns(n)}function mt(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}function Kh(n){n.domObserver.stop();for(let e in n.input.eventHandlers)n.dom.removeEventListener(e,n.input.eventHandlers[e]);clearTimeout(n.input.composingTimeout),clearTimeout(n.input.lastIOSEnterFallbackTimeout)}function ns(n){n.someProp("handleDOMEvents",e=>{for(let t in e)n.input.eventHandlers[t]||n.dom.addEventListener(t,n.input.eventHandlers[t]=r=>rs(n,r))})}function rs(n,e){return n.someProp("handleDOMEvents",t=>{let r=t[e.type];return r?r(n,e)||e.defaultPrevented:!1})}function Jh(n,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target;t!=n.dom;t=t.parentNode)if(!t||t.nodeType==11||t.pmViewDesc&&t.pmViewDesc.stopEvent(e))return!1;return!0}function Yh(n,e){!rs(n,e)&&fe[e.type]&&(n.editable||!(e.type in de))&&fe[e.type](n,e)}de.keydown=(n,e)=>{let t=e;if(n.input.shiftKey=t.keyCode==16||t.shiftKey,!xa(n,t)&&(n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),!(Qe&&ie&&t.keyCode==13)))if(t.keyCode!=229&&n.domObserver.forceFlush(),sn&&t.keyCode==13&&!t.ctrlKey&&!t.altKey&&!t.metaKey){let r=Date.now();n.input.lastIOSEnter=r,n.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{n.input.lastIOSEnter==r&&(n.someProp("handleKeyDown",o=>o(n,Rt(13,"Enter"))),n.input.lastIOSEnter=0)},200)}else n.someProp("handleKeyDown",r=>r(n,t))||zh(n,t)?t.preventDefault():mt(n,"key")},de.keyup=(n,e)=>{e.keyCode==16&&(n.input.shiftKey=!1)},de.keypress=(n,e)=>{let t=e;if(xa(n,t)||!t.charCode||t.ctrlKey&&!t.altKey||Ne&&t.metaKey)return;if(n.someProp("handleKeyPress",o=>o(n,t))){t.preventDefault();return}let r=n.state.selection;if(!(r instanceof P)||!r.$from.sameParent(r.$to)){let o=String.fromCharCode(t.charCode);!/[\r\n]/.test(o)&&!n.someProp("handleTextInput",s=>s(n,r.$from.pos,r.$to.pos,o))&&n.dispatch(n.state.tr.insertText(o).scrollIntoView()),t.preventDefault()}};function Ar(n){return{left:n.clientX,top:n.clientY}}function Gh(n,e){let t=e.x-n.clientX,r=e.y-n.clientY;return t*t+r*r<100}function ss(n,e,t,r,o){if(r==-1)return!1;let s=n.state.doc.resolve(r);for(let i=s.depth+1;i>0;i--)if(n.someProp(e,l=>i>s.depth?l(n,t,s.nodeAfter,s.before(i),o,!0):l(n,t,s.node(i),s.before(i),o,!1)))return!0;return!1}function un(n,e,t){if(n.focused||n.focus(),n.state.selection.eq(e))return;let r=n.state.tr.setSelection(e);r.setMeta("pointer",!0),n.dispatch(r)}function Xh(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),r=t.nodeAfter;return r&&r.isAtom&&D.isSelectable(r)?(un(n,new D(t)),!0):!1}function Uh(n,e){if(e==-1)return!1;let t=n.state.selection,r,o;t instanceof D&&(r=t.node);let s=n.state.doc.resolve(e);for(let i=s.depth+1;i>0;i--){let l=i>s.depth?s.nodeAfter:s.node(i);if(D.isSelectable(l)){r&&t.$from.depth>0&&i>=t.$from.depth&&s.before(t.$from.depth+1)==t.$from.pos?o=s.before(t.$from.depth):o=s.before(i);break}}return o!=null?(un(n,D.create(n.state.doc,o)),!0):!1}function Qh(n,e,t,r,o){return ss(n,"handleClickOn",e,t,r)||n.someProp("handleClick",s=>s(n,e,r))||(o?Uh(n,t):Xh(n,t))}function Zh(n,e,t,r){return ss(n,"handleDoubleClickOn",e,t,r)||n.someProp("handleDoubleClick",o=>o(n,e,r))}function ep(n,e,t,r){return ss(n,"handleTripleClickOn",e,t,r)||n.someProp("handleTripleClick",o=>o(n,e,r))||tp(n,t,r)}function tp(n,e,t){if(t.button!=0)return!1;let r=n.state.doc;if(e==-1)return r.inlineContent?(un(n,P.create(r,0,r.content.size)),!0):!1;let o=r.resolve(e);for(let s=o.depth+1;s>0;s--){let i=s>o.depth?o.nodeAfter:o.node(s),l=o.before(s);if(i.inlineContent)un(n,P.create(r,l+1,l+1+i.content.size));else if(D.isSelectable(i))un(n,D.create(r,l));else continue;return!0}}function is(n){return Pr(n)}const ba=Ne?"metaKey":"ctrlKey";fe.mousedown=(n,e)=>{let t=e;n.input.shiftKey=t.shiftKey;let r=is(n),o=Date.now(),s="singleClick";o-n.input.lastClick.time<500&&Gh(t,n.input.lastClick)&&!t[ba]&&(n.input.lastClick.type=="singleClick"?s="doubleClick":n.input.lastClick.type=="doubleClick"&&(s="tripleClick")),n.input.lastClick={time:o,x:t.clientX,y:t.clientY,type:s};let i=n.posAtCoords(Ar(t));i&&(s=="singleClick"?(n.input.mouseDown&&n.input.mouseDown.done(),n.input.mouseDown=new np(n,i,t,!!r)):(s=="doubleClick"?Zh:ep)(n,i.pos,i.inside,t)?t.preventDefault():mt(n,"pointer"))};let np=class{constructor(e,t,r,o){this.view=e,this.pos=t,this.event=r,this.flushed=o,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!r[ba],this.allowDefault=r.shiftKey;let s,i;if(t.inside>-1)s=e.state.doc.nodeAt(t.inside),i=t.inside;else{let u=e.state.doc.resolve(t.pos);s=u.parent,i=u.depth?u.before():0}const l=o?null:r.target,a=l?e.docView.nearestDesc(l,!0):null;this.target=a&&a.dom.nodeType==1?a.dom:null;let{selection:c}=e.state;(r.button==0&&s.type.spec.draggable&&s.type.spec.selectable!==!1||c instanceof D&&c.from<=i&&c.to>i)&&(this.mightDrag={node:s,pos:i,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Ie&&!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)),mt(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(()=>et(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(Ar(e))),this.updateAllowDefault(e),this.allowDefault||!t?mt(this.view,"pointer"):Qh(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||ue&&this.mightDrag&&!this.mightDrag.node.isAtom||ie&&!this.view.state.selection.visible&&Math.min(Math.abs(t.pos-this.view.state.selection.from),Math.abs(t.pos-this.view.state.selection.to))<=2)?(un(this.view,R.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):mt(this.view,"pointer")}move(e){this.updateAllowDefault(e),mt(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)}};fe.touchstart=n=>{n.input.lastTouch=Date.now(),is(n),mt(n,"pointer")},fe.touchmove=n=>{n.input.lastTouch=Date.now(),mt(n,"pointer")},fe.contextmenu=n=>is(n);function xa(n,e){return n.composing?!0:ue&&Math.abs(e.timeStamp-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}const rp=Qe?5e3:-1;de.compositionstart=de.compositionupdate=n=>{if(!n.composing){n.domObserver.flush();let{state:e}=n,t=e.selection.$to;if(e.selection instanceof P&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)))n.markCursor=n.state.storedMarks||t.marks(),Pr(n,!0),n.markCursor=null;else if(Pr(n,!e.selection.empty),Ie&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length){let r=n.domSelectionRange();for(let o=r.focusNode,s=r.focusOffset;o&&o.nodeType==1&&s!=0;){let i=s<0?o.lastChild:o.childNodes[s-1];if(!i)break;if(i.nodeType==3){let l=n.domSelection();l&&l.collapse(i,i.nodeValue.length);break}else o=i,s=-1}}n.input.composing=!0}ka(n,rp)},de.compositionend=(n,e)=>{n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=e.timeStamp,n.input.compositionPendingChanges=n.domObserver.pendingRecords().length?n.input.compositionID:0,n.input.compositionNode=null,n.input.compositionPendingChanges&&Promise.resolve().then(()=>n.domObserver.flush()),n.input.compositionID++,ka(n,20))};function ka(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>Pr(n),e))}function Sa(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=sp());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function op(n){let e=n.domSelectionRange();if(!e.focusNode)return null;let t=Xd(e.focusNode,e.focusOffset),r=Ud(e.focusNode,e.focusOffset);if(t&&r&&t!=r){let o=r.pmViewDesc,s=n.domObserver.lastChangedTextNode;if(t==s||r==s)return s;if(!o||!o.isText(r.nodeValue))return r;if(n.input.compositionNode==r){let i=t.pmViewDesc;if(!(!i||!i.isText(t.nodeValue)))return r}}return t||r}function sp(){let n=document.createEvent("Event");return n.initEvent("event",!0,!0),n.timeStamp}function Pr(n,e=!1){if(!(Qe&&n.domObserver.flushingSoon>=0)){if(n.domObserver.forceFlush(),Sa(n),e||n.docView&&n.docView.dirty){let t=Go(n);return t&&!t.eq(n.state.selection)?n.dispatch(n.state.tr.setSelection(t)):(n.markCursor||e)&&!n.state.selection.empty?n.dispatch(n.state.tr.deleteSelection()):n.updateState(n.state),!0}return!1}}function ip(n,e){if(!n.dom.parentNode)return;let t=n.dom.parentNode.appendChild(document.createElement("div"));t.appendChild(e),t.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),o=document.createRange();o.selectNodeContents(e),n.dom.blur(),r.removeAllRanges(),r.addRange(o),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t),n.focus()},50)}const Fn=ye&&dt<15||sn&&nh<604;fe.copy=de.cut=(n,e)=>{let t=e,r=n.state.selection,o=t.type=="cut";if(r.empty)return;let s=Fn?null:t.clipboardData,i=r.content(),{dom:l,text:a}=ca(n,i);s?(t.preventDefault(),s.clearData(),s.setData("text/html",l.innerHTML),s.setData("text/plain",a)):ip(n,l),o&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function lp(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function ap(n,e){if(!n.dom.parentNode)return;let t=n.input.shiftKey||n.state.selection.$from.parent.type.spec.code,r=n.dom.parentNode.appendChild(document.createElement(t?"textarea":"div"));t||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let o=n.input.shiftKey&&n.input.lastKeyCode!=45;setTimeout(()=>{n.focus(),r.parentNode&&r.parentNode.removeChild(r),t?Ln(n,r.value,null,o,e):Ln(n,r.textContent,r.innerHTML,o,e)},50)}function Ln(n,e,t,r,o){let s=ua(n,e,t,r,n.state.selection.$from);if(n.someProp("handlePaste",a=>a(n,o,s||N.empty)))return!0;if(!s)return!1;let i=lp(s),l=i?n.state.tr.replaceSelectionWith(i,r):n.state.tr.replaceSelection(s);return n.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Ca(n){let e=n.getData("text/plain")||n.getData("Text");if(e)return e;let t=n.getData("text/uri-list");return t?t.replace(/\r?\n/g," "):""}de.paste=(n,e)=>{let t=e;if(n.composing&&!Qe)return;let r=Fn?null:t.clipboardData,o=n.input.shiftKey&&n.input.lastKeyCode!=45;r&&Ln(n,Ca(r),r.getData("text/html"),o,t)?t.preventDefault():ap(n,t)};let wa=class{constructor(e,t,r){this.slice=e,this.move=t,this.node=r}};const Ma=Ne?"altKey":"ctrlKey";fe.dragstart=(n,e)=>{let t=e,r=n.input.mouseDown;if(r&&r.done(),!t.dataTransfer)return;let o=n.state.selection,s=o.empty?null:n.posAtCoords(Ar(t)),i;if(!(s&&s.pos>=o.from&&s.pos<=(o instanceof D?o.to-1:o.to))){if(r&&r.mightDrag)i=D.create(n.state.doc,r.mightDrag.pos);else if(t.target&&t.target.nodeType==1){let f=n.docView.nearestDesc(t.target,!0);f&&f.node.type.spec.draggable&&f!=n.docView&&(i=D.create(n.state.doc,f.posBefore))}}let l=(i||n.state.selection).content(),{dom:a,text:c,slice:u}=ca(n,l);(!t.dataTransfer.files.length||!ie||Ol>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(Fn?"Text":"text/html",a.innerHTML),t.dataTransfer.effectAllowed="copyMove",Fn||t.dataTransfer.setData("text/plain",c),n.dragging=new wa(u,!t[Ma],i)},fe.dragend=n=>{let e=n.dragging;window.setTimeout(()=>{n.dragging==e&&(n.dragging=null)},50)},de.dragover=de.dragenter=(n,e)=>e.preventDefault(),de.drop=(n,e)=>{let t=e,r=n.dragging;if(n.dragging=null,!t.dataTransfer)return;let o=n.posAtCoords(Ar(t));if(!o)return;let s=n.state.doc.resolve(o.pos),i=r&&r.slice;i?n.someProp("transformPasted",p=>{i=p(i,n)}):i=ua(n,Ca(t.dataTransfer),Fn?null:t.dataTransfer.getData("text/html"),!1,s);let l=!!(r&&!t[Ma]);if(n.someProp("handleDrop",p=>p(n,t,i||N.empty,l))){t.preventDefault();return}if(!i)return;t.preventDefault();let a=i?So(n.state.doc,s.pos,i):s.pos;a==null&&(a=s.pos);let c=n.state.tr;if(l){let{node:p}=r;p?p.replace(c):c.deleteSelection()}let u=c.mapping.map(a),f=i.openStart==0&&i.openEnd==0&&i.content.childCount==1,d=c.doc;if(f?c.replaceRangeWith(u,u,i.content.firstChild):c.replaceRange(u,u,i),c.doc.eq(d))return;let h=c.doc.resolve(u);if(f&&D.isSelectable(i.content.firstChild)&&h.nodeAfter&&h.nodeAfter.sameMarkup(i.content.firstChild))c.setSelection(new D(h));else{let p=c.mapping.map(a);c.mapping.maps[c.mapping.maps.length-1].forEach((b,g,k,S)=>p=S),c.setSelection(Uo(n,h,c.doc.resolve(p)))}n.focus(),n.dispatch(c.setMeta("uiEvent","drop"))},fe.focus=n=>{n.input.lastFocus=Date.now(),n.focused||(n.domObserver.stop(),n.dom.classList.add("ProseMirror-focused"),n.domObserver.start(),n.focused=!0,setTimeout(()=>{n.docView&&n.hasFocus()&&!n.domObserver.currentSelection.eq(n.domSelectionRange())&&et(n)},20))},fe.blur=(n,e)=>{let t=e;n.focused&&(n.domObserver.stop(),n.dom.classList.remove("ProseMirror-focused"),n.domObserver.start(),t.relatedTarget&&n.dom.contains(t.relatedTarget)&&n.domObserver.currentSelection.clear(),n.focused=!1)},fe.beforeinput=(n,e)=>{if(ie&&Qe&&e.inputType=="deleteContentBackward"){n.domObserver.flushSoon();let{domChangeCount:r}=n.input;setTimeout(()=>{if(n.input.domChangeCount!=r||(n.dom.blur(),n.focus(),n.someProp("handleKeyDown",s=>s(n,Rt(8,"Backspace")))))return;let{$cursor:o}=n.state.selection;o&&o.pos>0&&n.dispatch(n.state.tr.delete(o.pos-1,o.pos).scrollIntoView())},50)}};for(let n in de)fe[n]=de[n];function Wn(n,e){if(n==e)return!0;for(let t in n)if(n[t]!==e[t])return!1;for(let t in e)if(!(t in n))return!1;return!0}let Na=class hf{constructor(e,t){this.toDOM=e,this.spec=t||jt,this.side=this.spec.side||0}map(e,t,r,o){let{pos:s,deleted:i}=e.mapResult(t.from+o,this.side<0?-1:1);return i?null:new Ve(s-r,s-r,this)}valid(){return!0}eq(e){return this==e||e instanceof hf&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Wn(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}},_n=class ai{constructor(e,t){this.attrs=e,this.spec=t||jt}map(e,t,r,o){let s=e.map(t.from+o,this.spec.inclusiveStart?-1:1)-r,i=e.map(t.to+o,this.spec.inclusiveEnd?1:-1)-r;return s>=i?null:new Ve(s,i,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof ai&&Wn(this.attrs,e.attrs)&&Wn(this.spec,e.spec)}static is(e){return e.type instanceof ai}destroy(){}},cp=class pf{constructor(e,t){this.attrs=e,this.spec=t||jt}map(e,t,r,o){let s=e.mapResult(t.from+o,1);if(s.deleted)return null;let i=e.mapResult(t.to+o,-1);return i.deleted||i.pos<=s.pos?null:new Ve(s.pos-r,i.pos-r,this)}valid(e,t){let{index:r,offset:o}=e.content.findIndex(t.from),s;return o==t.from&&!(s=e.child(r)).isText&&o+s.nodeSize==t.to}eq(e){return this==e||e instanceof pf&&Wn(this.attrs,e.attrs)&&Wn(this.spec,e.spec)}destroy(){}},Ve=class ar{constructor(e,t,r){this.from=e,this.to=t,this.type=r}copy(e,t){return new ar(e,t,this.type)}eq(e,t=0){return this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to}map(e,t,r){return this.type.map(e,this,t,r)}static widget(e,t,r){return new ar(e,e,new Na(t,r))}static inline(e,t,r,o){return new ar(e,t,new _n(r,o))}static node(e,t,r,o){return new ar(e,t,new cp(r,o))}get spec(){return this.type.spec}get inline(){return this.type instanceof _n}get widget(){return this.type instanceof Na}};const fn=[],jt={};let H=class Ot{constructor(e,t){this.local=e.length?e:fn,this.children=t.length?t:fn}static create(e,t){return t.length?Ir(t,e,0,jt):le}find(e,t,r){let o=[];return this.findInner(e??0,t??1e9,o,0,r),o}findInner(e,t,r,o,s){for(let i=0;i<this.local.length;i++){let l=this.local[i];l.from<=t&&l.to>=e&&(!s||s(l.spec))&&r.push(l.copy(l.from+o,l.to+o))}for(let i=0;i<this.children.length;i+=3)if(this.children[i]<t&&this.children[i+1]>e){let l=this.children[i]+1;this.children[i+2].findInner(e-l,t-l,r,o+l,s)}}map(e,t,r){return this==le||e.maps.length==0?this:this.mapInner(e,t,0,0,r||jt)}mapInner(e,t,r,o,s){let i;for(let l=0;l<this.local.length;l++){let a=this.local[l].map(e,r,o);a&&a.type.valid(t,a)?(i||(i=[])).push(a):s.onRemove&&s.onRemove(this.local[l].spec)}return this.children.length?up(this.children,i||[],e,t,r,o,s):i?new Ot(i.sort(Bt),fn):le}add(e,t){return t.length?this==le?Ot.create(e,t):this.addInner(e,t,0):this}addInner(e,t,r){let o,s=0;e.forEach((l,a)=>{let c=a+r,u;if(u=Oa(t,l,c)){for(o||(o=this.children.slice());s<o.length&&o[s]<a;)s+=3;o[s]==a?o[s+2]=o[s+2].addInner(l,u,c+1):o.splice(s,0,a,a+l.nodeSize,Ir(u,l,c+1,jt)),s+=3}});let i=Da(s?Ta(t):t,-r);for(let l=0;l<i.length;l++)i[l].type.valid(e,i[l])||i.splice(l--,1);return new Ot(i.length?this.local.concat(i).sort(Bt):this.local,o||this.children)}remove(e){return e.length==0||this==le?this:this.removeInner(e,0)}removeInner(e,t){let r=this.children,o=this.local;for(let s=0;s<r.length;s+=3){let i,l=r[s]+t,a=r[s+1]+t;for(let u=0,f;u<e.length;u++)(f=e[u])&&f.from>l&&f.to<a&&(e[u]=null,(i||(i=[])).push(f));if(!i)continue;r==this.children&&(r=this.children.slice());let c=r[s+2].removeInner(i,l+1);c!=le?r[s+2]=c:(r.splice(s,3),s-=3)}if(o.length){for(let s=0,i;s<e.length;s++)if(i=e[s])for(let l=0;l<o.length;l++)o[l].eq(i,t)&&(o==this.local&&(o=this.local.slice()),o.splice(l--,1))}return r==this.children&&o==this.local?this:o.length||r.length?new Ot(o,r):le}forChild(e,t){if(this==le)return this;if(t.isLeaf)return Ot.empty;let r,o;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=e){this.children[l]==e&&(r=this.children[l+2]);break}let s=e+1,i=s+t.content.size;for(let l=0;l<this.local.length;l++){let a=this.local[l];if(a.from<i&&a.to>s&&a.type instanceof _n){let c=Math.max(s,a.from)-s,u=Math.min(i,a.to)-s;c<u&&(o||(o=[])).push(a.copy(c,u))}}if(o){let l=new Ot(o.sort(Bt),fn);return r?new Ea([l,r]):l}return r||le}eq(e){if(this==e)return!0;if(!(e instanceof Ot)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let t=0;t<this.local.length;t++)if(!this.local[t].eq(e.local[t]))return!1;for(let t=0;t<this.children.length;t+=3)if(this.children[t]!=e.children[t]||this.children[t+1]!=e.children[t+1]||!this.children[t+2].eq(e.children[t+2]))return!1;return!0}locals(e){return ls(this.localsInner(e))}localsInner(e){if(this==le)return fn;if(e.inlineContent||!this.local.some(_n.is))return this.local;let t=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof _n||t.push(this.local[r]);return t}forEachSet(e){e(this)}};H.empty=new H([],[]),H.removeOverlap=ls;const le=H.empty;let Ea=class xn{constructor(e){this.members=e}map(e,t){const r=this.members.map(o=>o.map(e,t,jt));return xn.from(r)}forChild(e,t){if(t.isLeaf)return H.empty;let r=[];for(let o=0;o<this.members.length;o++){let s=this.members[o].forChild(e,t);s!=le&&(s instanceof xn?r=r.concat(s.members):r.push(s))}return xn.from(r)}eq(e){if(!(e instanceof xn)||e.members.length!=this.members.length)return!1;for(let t=0;t<this.members.length;t++)if(!this.members[t].eq(e.members[t]))return!1;return!0}locals(e){let t,r=!0;for(let o=0;o<this.members.length;o++){let s=this.members[o].localsInner(e);if(s.length)if(!t)t=s;else{r&&(t=t.slice(),r=!1);for(let i=0;i<s.length;i++)t.push(s[i])}}return t?ls(r?t:t.sort(Bt)):fn}static from(e){switch(e.length){case 0:return le;case 1:return e[0];default:return new xn(e.every(t=>t instanceof H)?e:e.reduce((t,r)=>t.concat(r instanceof H?r:r.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}};function up(n,e,t,r,o,s,i){let l=n.slice();for(let c=0,u=s;c<t.maps.length;c++){let f=0;t.maps[c].forEach((d,h,p,b)=>{let g=b-p-(h-d);for(let k=0;k<l.length;k+=3){let S=l[k+1];if(S<0||d>S+u-f)continue;let M=l[k]+u-f;h>=M?l[k+1]=d<=M?-2:-1:d>=u&&g&&(l[k]+=g,l[k+1]+=g)}f+=g}),u=t.maps[c].map(u,-1)}let a=!1;for(let c=0;c<l.length;c+=3)if(l[c+1]<0){if(l[c+1]==-2){a=!0,l[c+1]=-1;continue}let u=t.map(n[c]+s),f=u-o;if(f<0||f>=r.content.size){a=!0;continue}let d=t.map(n[c+1]+s,-1),h=d-o,{index:p,offset:b}=r.content.findIndex(f),g=r.maybeChild(p);if(g&&b==f&&b+g.nodeSize==h){let k=l[c+2].mapInner(t,g,u+1,n[c]+s+1,i);k!=le?(l[c]=f,l[c+1]=h,l[c+2]=k):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=fp(l,n,e,t,o,s,i),u=Ir(c,r,0,i);e=u.local;for(let f=0;f<l.length;f+=3)l[f+1]<0&&(l.splice(f,3),f-=3);for(let f=0,d=0;f<u.children.length;f+=3){let h=u.children[f];for(;d<l.length&&l[d]<h;)d+=3;l.splice(d,0,u.children[f],u.children[f+1],u.children[f+2])}}return new H(e.sort(Bt),l)}function Da(n,e){if(!e||!n.length)return n;let t=[];for(let r=0;r<n.length;r++){let o=n[r];t.push(new Ve(o.from+e,o.to+e,o.type))}return t}function fp(n,e,t,r,o,s,i){function l(a,c){for(let u=0;u<a.local.length;u++){let f=a.local[u].map(r,o,c);f?t.push(f):i.onRemove&&i.onRemove(a.local[u].spec)}for(let u=0;u<a.children.length;u+=3)l(a.children[u+2],a.children[u]+c+1)}for(let a=0;a<n.length;a+=3)n[a+1]==-1&&l(n[a+2],e[a]+s+1);return t}function Oa(n,e,t){if(e.isLeaf)return null;let r=t+e.nodeSize,o=null;for(let s=0,i;s<n.length;s++)(i=n[s])&&i.from>t&&i.to<r&&((o||(o=[])).push(i),n[s]=null);return o}function Ta(n){let e=[];for(let t=0;t<n.length;t++)n[t]!=null&&e.push(n[t]);return e}function Ir(n,e,t,r){let o=[],s=!1;e.forEach((l,a)=>{let c=Oa(n,l,a+t);if(c){s=!0;let u=Ir(c,l,t+a+1,r);u!=le&&o.push(a,a+l.nodeSize,u)}});let i=Da(s?Ta(n):n,-t).sort(Bt);for(let l=0;l<i.length;l++)i[l].type.valid(e,i[l])||(r.onRemove&&r.onRemove(i[l].spec),i.splice(l--,1));return i.length||o.length?new H(i,o):le}function Bt(n,e){return n.from-e.from||n.to-e.to}function ls(n){let e=n;for(let t=0;t<e.length-1;t++){let r=e[t];if(r.from!=r.to)for(let o=t+1;o<e.length;o++){let s=e[o];if(s.from==r.from){s.to!=r.to&&(e==n&&(e=n.slice()),e[o]=s.copy(s.from,r.to),va(e,o+1,s.copy(r.to,s.to)));continue}else{s.from<r.to&&(e==n&&(e=n.slice()),e[t]=r.copy(r.from,s.from),va(e,o,r.copy(s.from,r.to)));break}}}return e}function va(n,e,t){for(;e<n.length&&Bt(t,n[e])>0;)e++;n.splice(e,0,t)}function as(n){let e=[];return n.someProp("decorations",t=>{let r=t(n.state);r&&r!=le&&e.push(r)}),n.cursorWrapper&&e.push(H.create(n.state.doc,[n.cursorWrapper.deco])),Ea.from(e)}const dp={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},hp=ye&&dt<=11;let pp=class{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}};class mp{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new pp,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let o=0;o<r.length;o++)this.queue.push(r[o]);ye&&dt<=11&&r.some(o=>o.type=="childList"&&o.removedNodes.length||o.type=="characterData"&&o.oldValue.length>o.target.nodeValue.length)?this.flushSoon():this.flush()}),hp&&(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,dp)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let t=0;t<e.length;t++)this.queue.push(e[t]);window.setTimeout(()=>this.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(ta(this.view)){if(this.suppressingSelectionUpdates)return et(this.view);if(ye&&dt<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Vt(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t=new Set,r;for(let s=e.focusNode;s;s=In(s))t.add(s);for(let s=e.anchorNode;s;s=In(s))if(t.has(s)){r=s;break}let o=r&&this.view.docView.nearestDesc(r);if(o&&o.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 t=this.pendingRecords();t.length&&(this.queue=[]);let r=e.domSelectionRange(),o=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&ta(e)&&!this.ignoreSelectionChange(r),s=-1,i=-1,l=!1,a=[];if(e.editable)for(let u=0;u<t.length;u++){let f=this.registerMutation(t[u],a);f&&(s=s<0?f.from:Math.min(f.from,s),i=i<0?f.to:Math.max(f.to,i),f.typeOver&&(l=!0))}if(Ie&&a.length){let u=a.filter(f=>f.nodeName=="BR");if(u.length==2){let[f,d]=u;f.parentNode&&f.parentNode.parentNode==d.parentNode?d.remove():f.remove()}else{let{focusNode:f}=this.currentSelection;for(let d of u){let h=d.parentNode;h&&h.nodeName=="LI"&&(!f||bp(e,f)!=h)&&d.remove()}}}let c=null;s<0&&o&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&Dr(r)&&(c=Go(e))&&c.eq(R.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,et(e),this.currentSelection.set(r),e.scrollToSelection()):(s>-1||o)&&(s>-1&&(e.docView.markDirty(s,i),gp(e)),this.handleDOMChange(s,i,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||et(e),this.currentSelection.set(r))}registerMutation(e,t){if(t.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 u=0;u<e.addedNodes.length;u++){let f=e.addedNodes[u];t.push(f),f.nodeType==3&&(this.lastChangedTextNode=f)}if(r.contentDOM&&r.contentDOM!=r.dom&&!r.contentDOM.contains(e.target))return{from:r.posBefore,to:r.posAfter};let o=e.previousSibling,s=e.nextSibling;if(ye&&dt<=11&&e.addedNodes.length)for(let u=0;u<e.addedNodes.length;u++){let{previousSibling:f,nextSibling:d}=e.addedNodes[u];(!f||Array.prototype.indexOf.call(e.addedNodes,f)<0)&&(o=f),(!d||Array.prototype.indexOf.call(e.addedNodes,d)<0)&&(s=d)}let i=o&&o.parentNode==e.target?ne(o)+1:0,l=r.localPosFromDOM(e.target,i,-1),a=s&&s.parentNode==e.target?ne(s):e.target.childNodes.length,c=r.localPosFromDOM(e.target,a,1);return{from:l,to:c}}else return e.type=="attributes"?{from:r.posAtStart-r.border,to:r.posAtEnd+r.border}:(this.lastChangedTextNode=e.target,{from:r.posAtStart,to:r.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let Aa=new WeakMap,Pa=!1;function gp(n){if(!Aa.has(n)&&(Aa.set(n,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(n.dom).whiteSpace)!==-1)){if(n.requiresGeckoHackNode=Ie,Pa)return;console.warn("ProseMirror expects the CSS white-space property to be set, preferably to 'pre-wrap'. It is recommended to load style/prosemirror.css from the prosemirror-view package."),Pa=!0}}function Ia(n,e){let t=e.startContainer,r=e.startOffset,o=e.endContainer,s=e.endOffset,i=n.domAtPos(n.state.selection.anchor);return Vt(i.node,i.offset,o,s)&&([t,r,o,s]=[o,s,t,r]),{anchorNode:t,anchorOffset:r,focusNode:o,focusOffset:s}}function yp(n,e){if(e.getComposedRanges){let o=e.getComposedRanges(n.root)[0];if(o)return Ia(n,o)}let t;function r(o){o.preventDefault(),o.stopImmediatePropagation(),t=o.getTargetRanges()[0]}return n.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),n.dom.removeEventListener("beforeinput",r,!0),t?Ia(n,t):null}function bp(n,e){for(let t=e.parentNode;t&&t!=n.dom;t=t.parentNode){let r=n.docView.nearestDesc(t,!0);if(r&&r.node.isBlock)return t}return null}function xp(n,e,t){let{node:r,fromOffset:o,toOffset:s,from:i,to:l}=n.docView.parseRange(e,t),a=n.domSelectionRange(),c,u=a.anchorNode;if(u&&n.dom.contains(u.nodeType==1?u:u.parentNode)&&(c=[{node:u,offset:a.anchorOffset}],Dr(a)||c.push({node:a.focusNode,offset:a.focusOffset})),ie&&n.input.lastKeyCode===8)for(let g=s;g>o;g--){let k=r.childNodes[g-1],S=k.pmViewDesc;if(k.nodeName=="BR"&&!S){s=g;break}if(!S||S.size)break}let f=n.state.doc,d=n.someProp("domParser")||Pt.fromSchema(n.state.schema),h=f.resolve(i),p=null,b=d.parse(r,{topNode:h.parent,topMatch:h.parent.contentMatchAt(h.index()),topOpen:!0,from:o,to:s,preserveWhitespace:h.parent.type.whitespace=="pre"?"full":!0,findPositions:c,ruleFromNode:kp,context:h});if(c&&c[0].pos!=null){let g=c[0].pos,k=c[1]&&c[1].pos;k==null&&(k=g),p={anchor:g+i,head:k+i}}return{doc:b,sel:p,from:i,to:l}}function kp(n){let e=n.pmViewDesc;if(e)return e.parseRule();if(n.nodeName=="BR"&&n.parentNode){if(ue&&/^(ul|ol)$/i.test(n.parentNode.nodeName)){let t=document.createElement("div");return t.appendChild(document.createElement("li")),{skip:t}}else if(n.parentNode.lastChild==n||ue&&/^(tr|table)$/i.test(n.parentNode.nodeName))return{ignore:!0}}else if(n.nodeName=="IMG"&&n.getAttribute("mark-placeholder"))return{ignore:!0};return null}const Sp=/^(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 Cp(n,e,t,r,o){let s=n.input.compositionPendingChanges||(n.composing?n.input.compositionID:0);if(n.input.compositionPendingChanges=0,e<0){let T=n.input.lastSelectionTime>Date.now()-50?n.input.lastSelectionOrigin:null,L=Go(n,T);if(L&&!n.state.selection.eq(L)){if(ie&&Qe&&n.input.lastKeyCode===13&&Date.now()-100<n.input.lastKeyCodeTime&&n.someProp("handleKeyDown",Et=>Et(n,Rt(13,"Enter"))))return;let we=n.state.tr.setSelection(L);T=="pointer"?we.setMeta("pointer",!0):T=="key"&&we.scrollIntoView(),s&&we.setMeta("composition",s),n.dispatch(we)}return}let i=n.state.doc.resolve(e),l=i.sharedDepth(t);e=i.before(l+1),t=n.state.doc.resolve(t).after(l+1);let a=n.state.selection,c=xp(n,e,t),u=n.state.doc,f=u.slice(c.from,c.to),d,h;n.input.lastKeyCode===8&&Date.now()-100<n.input.lastKeyCodeTime?(d=n.state.selection.to,h="end"):(d=n.state.selection.from,h="start"),n.input.lastKeyCode=null;let p=Np(f.content,c.doc.content,c.from,d,h);if(p&&n.input.domChangeCount++,(sn&&n.input.lastIOSEnter>Date.now()-225||Qe)&&o.some(T=>T.nodeType==1&&!Sp.test(T.nodeName))&&(!p||p.endA>=p.endB)&&n.someProp("handleKeyDown",T=>T(n,Rt(13,"Enter")))){n.input.lastIOSEnter=0;return}if(!p)if(r&&a instanceof P&&!a.empty&&a.$head.sameParent(a.$anchor)&&!n.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))p={start:a.from,endA:a.to,endB:a.to};else{if(c.sel){let T=Va(n,n.state.doc,c.sel);if(T&&!T.eq(n.state.selection)){let L=n.state.tr.setSelection(T);s&&L.setMeta("composition",s),n.dispatch(L)}}return}n.state.selection.from<n.state.selection.to&&p.start==p.endB&&n.state.selection instanceof P&&(p.start>n.state.selection.from&&p.start<=n.state.selection.from+2&&n.state.selection.from>=c.from?p.start=n.state.selection.from:p.endA<n.state.selection.to&&p.endA>=n.state.selection.to-2&&n.state.selection.to<=c.to&&(p.endB+=n.state.selection.to-p.endA,p.endA=n.state.selection.to)),ye&&dt<=11&&p.endB==p.start+1&&p.endA==p.start&&p.start>c.from&&c.doc.textBetween(p.start-c.from-1,p.start-c.from+1)==" "&&(p.start--,p.endA--,p.endB--);let b=c.doc.resolveNoCache(p.start-c.from),g=c.doc.resolveNoCache(p.endB-c.from),k=u.resolve(p.start),S=b.sameParent(g)&&b.parent.inlineContent&&k.end()>=p.endA,M;if((sn&&n.input.lastIOSEnter>Date.now()-225&&(!S||o.some(T=>T.nodeName=="DIV"||T.nodeName=="P"))||!S&&b.pos<c.doc.content.size&&!b.sameParent(g)&&(M=R.findFrom(c.doc.resolve(b.pos+1),1,!0))&&M.head==g.pos)&&n.someProp("handleKeyDown",T=>T(n,Rt(13,"Enter")))){n.input.lastIOSEnter=0;return}if(n.state.selection.anchor>p.start&&Mp(u,p.start,p.endA,b,g)&&n.someProp("handleKeyDown",T=>T(n,Rt(8,"Backspace")))){Qe&&ie&&n.domObserver.suppressSelectionUpdates();return}ie&&p.endB==p.start&&(n.input.lastChromeDelete=Date.now()),Qe&&!S&&b.start()!=g.start()&&g.parentOffset==0&&b.depth==g.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==p.endA&&(p.endB-=2,g=c.doc.resolveNoCache(p.endB-c.from),setTimeout(()=>{n.someProp("handleKeyDown",function(T){return T(n,Rt(13,"Enter"))})},20));let O=p.start,I=p.endA,w,V,z;if(S){if(b.pos==g.pos)ye&&dt<=11&&b.parentOffset==0&&(n.domObserver.suppressSelectionUpdates(),setTimeout(()=>et(n),20)),w=n.state.tr.delete(O,I),V=u.resolve(p.start).marksAcross(u.resolve(p.endA));else if(p.endA==p.endB&&(z=wp(b.parent.content.cut(b.parentOffset,g.parentOffset),k.parent.content.cut(k.parentOffset,p.endA-k.start()))))w=n.state.tr,z.type=="add"?w.addMark(O,I,z.mark):w.removeMark(O,I,z.mark);else if(b.parent.child(b.index()).isText&&b.index()==g.index()-(g.textOffset?0:1)){let T=b.parent.textBetween(b.parentOffset,g.parentOffset);if(n.someProp("handleTextInput",L=>L(n,O,I,T)))return;w=n.state.tr.insertText(T,O,I)}}if(w||(w=n.state.tr.replace(O,I,c.doc.slice(p.start-c.from,p.endB-c.from))),c.sel){let T=Va(n,w.doc,c.sel);T&&!(ie&&n.composing&&T.empty&&(p.start!=p.endB||n.input.lastChromeDelete<Date.now()-100)&&(T.head==O||T.head==w.mapping.map(I)-1)||ye&&T.empty&&T.head==O)&&w.setSelection(T)}V&&w.ensureMarks(V),s&&w.setMeta("composition",s),n.dispatch(w.scrollIntoView())}function Va(n,e,t){return Math.max(t.anchor,t.head)>e.content.size?null:Uo(n,e.resolve(t.anchor),e.resolve(t.head))}function wp(n,e){let t=n.firstChild.marks,r=e.firstChild.marks,o=t,s=r,i,l,a;for(let u=0;u<r.length;u++)o=r[u].removeFromSet(o);for(let u=0;u<t.length;u++)s=t[u].removeFromSet(s);if(o.length==1&&s.length==0)l=o[0],i="add",a=u=>u.mark(l.addToSet(u.marks));else if(o.length==0&&s.length==1)l=s[0],i="remove",a=u=>u.mark(l.removeFromSet(u.marks));else return null;let c=[];for(let u=0;u<e.childCount;u++)c.push(a(e.child(u)));if(C.from(c).eq(n))return{mark:l,type:i}}function Mp(n,e,t,r,o){if(t-e<=o.pos-r.pos||cs(r,!0,!1)<o.pos)return!1;let s=n.resolve(e);if(!r.parent.isTextblock){let l=s.nodeAfter;return l!=null&&t==e+l.nodeSize}if(s.parentOffset<s.parent.content.size||!s.parent.isTextblock)return!1;let i=n.resolve(cs(s,!0,!0));return!i.parent.isTextblock||i.pos>t||cs(i,!0,!1)<t?!1:r.parent.content.cut(r.parentOffset).eq(i.parent.content)}function cs(n,e,t){let r=n.depth,o=e?n.end():n.pos;for(;r>0&&(e||n.indexAfter(r)==n.node(r).childCount);)r--,o++,e=!1;if(t){let s=n.node(r).maybeChild(n.indexAfter(r));for(;s&&!s.isLeaf;)s=s.firstChild,o++}return o}function Np(n,e,t,r,o){let s=n.findDiffStart(e,t);if(s==null)return null;let{a:i,b:l}=n.findDiffEnd(e,t+n.size,t+e.size);if(o=="end"){let a=Math.max(0,s-Math.min(i,l));r-=i+a-s}if(i<s&&n.size<e.size){let a=r<=s&&r>=i?s-r:0;s-=a,s&&s<e.size&&Ra(e.textBetween(s-1,s+1))&&(s+=a?1:-1),l=s+(l-i),i=s}else if(l<s){let a=r<=s&&r>=l?s-r:0;s-=a,s&&s<n.size&&Ra(n.textBetween(s-1,s+1))&&(s+=a?1:-1),i=s+(i-l),l=s}return{start:s,endA:i,endB:l}}function Ra(n){if(n.length!=2)return!1;let e=n.charCodeAt(0),t=n.charCodeAt(1);return e>=56320&&e<=57343&&t>=55296&&t<=56319}class Ep{constructor(e,t){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new qh,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(Fa),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=ja(this),$a(this),this.nodeViews=Ba(this),this.docView=Wl(this.state.doc,za(this),as(this),this.dom,this),this.domObserver=new mp(this,(r,o,s,i)=>Cp(this,r,o,s,i)),this.domObserver.start(),Hh(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let t in e)this._props[t]=e[t];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&ns(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Fa),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let r in this._props)t[r]=this._props[r];t.state=this.state;for(let r in e)t[r]=e[r];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var r;let o=this.state,s=!1,i=!1;e.storedMarks&&this.composing&&(Sa(this),i=!0),this.state=e;let l=o.plugins!=e.plugins||this._props.plugins!=t.plugins;if(l||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let h=Ba(this);Op(h,this.nodeViews)&&(this.nodeViews=h,s=!0)}(l||t.handleDOMEvents!=this._props.handleDOMEvents)&&ns(this),this.editable=ja(this),$a(this);let a=as(this),c=za(this),u=o.plugins!=e.plugins&&!o.doc.eq(e.doc)?"reset":e.scrollToSelection>o.scrollToSelection?"to selection":"preserve",f=s||!this.docView.matchesNode(e.doc,c,a);(f||!e.selection.eq(o.selection))&&(i=!0);let d=u=="preserve"&&i&&this.dom.style.overflowAnchor==null&&sh(this);if(i){this.domObserver.stop();let h=f&&(ye||ie)&&!this.composing&&!o.selection.empty&&!e.selection.empty&&Dp(o.selection,e.selection);if(f){let p=ie?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=op(this)),(s||!this.docView.update(e.doc,c,a,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=Wl(e.doc,c,a,this.dom,this)),p&&!this.trackWrites&&(h=!0)}h||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&Th(this))?et(this,h):(Zl(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(o),!((r=this.dragging)===null||r===void 0)&&r.node&&!o.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,o),u=="reset"?this.dom.scrollTop=0:u=="to selection"?this.scrollToSelection():d&&ih(d)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof D){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&Tl(this,t.getBoundingClientRect(),e)}else Tl(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 t=0;t<this.directPlugins.length;t++){let r=this.directPlugins[t];r.spec.view&&this.pluginViews.push(r.spec.view(this))}for(let t=0;t<this.state.plugins.length;t++){let r=this.state.plugins[t];r.spec.view&&this.pluginViews.push(r.spec.view(this))}}else for(let t=0;t<this.pluginViews.length;t++){let r=this.pluginViews[t];r.update&&r.update(this,e)}}updateDraggedNode(e,t){let r=e.node,o=-1;if(this.state.doc.nodeAt(r.from)==r.node)o=r.from;else{let s=r.from+(this.state.doc.content.size-t.doc.content.size);(s>0&&this.state.doc.nodeAt(s))==r.node&&(o=s)}this.dragging=new wa(e.slice,e.move,o<0?void 0:D.create(this.state.doc,o))}someProp(e,t){let r=this._props&&this._props[e],o;if(r!=null&&(o=t?t(r):r))return o;for(let i=0;i<this.directPlugins.length;i++){let l=this.directPlugins[i].props[e];if(l!=null&&(o=t?t(l):l))return o}let s=this.state.plugins;if(s)for(let i=0;i<s.length;i++){let l=s[i].props[e];if(l!=null&&(o=t?t(l):l))return o}}hasFocus(){if(ye){let e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if(e.contentEditable=="false")return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&lh(this.dom),et(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let t=this.dom.parentNode;t;t=t.parentNode)if(t.nodeType==9||t.nodeType==11&&t.host)return t.getSelection||(Object.getPrototypeOf(t).getSelection=()=>t.ownerDocument.getSelection()),this._root=t}return e||document}updateRoot(){this._root=null}posAtCoords(e){return dh(this,e)}coordsAtPos(e,t=1){return Rl(this,e,t)}domAtPos(e,t=0){return this.docView.domFromPos(e,t)}nodeDOM(e){let t=this.docView.descAt(e);return t?t.nodeDOM:null}posAtDOM(e,t,r=-1){let o=this.docView.posFromDOM(e,t,r);if(o==null)throw new RangeError("DOM position not inside the editor");return o}endOfTextblock(e,t){return yh(this,t||this.state,e)}pasteHTML(e,t){return Ln(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return Ln(this,e,null,!0,t||new ClipboardEvent("paste"))}destroy(){this.docView&&(Kh(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],as(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Yd())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return Yh(this,e)}dispatch(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))}domSelectionRange(){let e=this.domSelection();return e?ue&&this.root.nodeType===11&&Zd(this.dom.ownerDocument)==this.dom&&yp(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}function za(n){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(n.editable),n.someProp("attributes",t=>{if(typeof t=="function"&&(t=t(n.state)),t)for(let r in t)r=="class"?e.class+=" "+t[r]:r=="style"?e.style=(e.style?e.style+";":"")+t[r]:!e[r]&&r!="contenteditable"&&r!="nodeName"&&(e[r]=String(t[r]))}),e.translate||(e.translate="no"),[Ve.node(0,n.state.doc.content.size,e)]}function $a(n){if(n.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),n.cursorWrapper={dom:e,deco:Ve.widget(n.state.selection.from,e,{raw:!0,marks:n.markCursor})}}else n.cursorWrapper=null}function ja(n){return!n.someProp("editable",e=>e(n.state)===!1)}function Dp(n,e){let t=Math.min(n.$anchor.sharedDepth(n.head),e.$anchor.sharedDepth(e.head));return n.$anchor.start(t)!=e.$anchor.start(t)}function Ba(n){let e=Object.create(null);function t(r){for(let o in r)Object.prototype.hasOwnProperty.call(e,o)||(e[o]=r[o])}return n.someProp("nodeViews",t),n.someProp("markViews",t),e}function Op(n,e){let t=0,r=0;for(let o in n){if(n[o]!=e[o])return!0;t++}for(let o in e)r++;return t!=r}function Fa(n){if(n.spec.state||n.spec.filterTransaction||n.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}class q extends R{constructor(e){super(e,e)}map(e,t){let r=e.resolve(t.map(this.head));return q.valid(r)?new q(r):R.near(r)}content(){return N.empty}eq(e){return e instanceof q&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new q(e.resolve(t.pos))}getBookmark(){return new us(this.anchor)}static valid(e){let t=e.parent;if(t.isTextblock||!Tp(e)||!vp(e))return!1;let r=t.type.spec.allowGapCursor;if(r!=null)return r;let o=t.contentMatchAt(e.index()).defaultType;return o&&o.isTextblock}static findGapCursorFrom(e,t,r=!1){e:for(;;){if(!r&&q.valid(e))return e;let o=e.pos,s=null;for(let i=e.depth;;i--){let l=e.node(i);if(t>0?e.indexAfter(i)<l.childCount:e.index(i)>0){s=l.child(t>0?e.indexAfter(i):e.index(i)-1);break}else if(i==0)return null;o+=t;let a=e.doc.resolve(o);if(q.valid(a))return a}for(;;){let i=t>0?s.firstChild:s.lastChild;if(!i){if(s.isAtom&&!s.isText&&!D.isSelectable(s)){e=e.doc.resolve(o+s.nodeSize*t),r=!1;continue e}break}s=i,o+=t;let l=e.doc.resolve(o);if(q.valid(l))return l}return null}}}q.prototype.visible=!1,q.findFrom=q.findGapCursorFrom,R.jsonID("gapcursor",q);class us{constructor(e){this.pos=e}map(e){return new us(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return q.valid(t)?new q(t):R.near(t)}}function Tp(n){for(let e=n.depth;e>=0;e--){let t=n.index(e),r=n.node(e);if(t==0){if(r.type.spec.isolating)return!0;continue}for(let o=r.child(t-1);;o=o.lastChild){if(o.childCount==0&&!o.inlineContent||o.isAtom||o.type.spec.isolating)return!0;if(o.inlineContent)return!1}}return!0}function vp(n){for(let e=n.depth;e>=0;e--){let t=n.indexAfter(e),r=n.node(e);if(t==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let o=r.child(t);;o=o.firstChild){if(o.childCount==0&&!o.inlineContent||o.isAtom||o.type.spec.isolating)return!0;if(o.inlineContent)return!1}}return!0}function Ap(){return new Be({props:{decorations:Rp,createSelectionBetween(n,e,t){return e.pos==t.pos&&q.valid(t)?new q(t):null},handleClick:Ip,handleKeyDown:Pp,handleDOMEvents:{beforeinput:Vp}}})}const Pp=zo({ArrowLeft:Vr("horiz",-1),ArrowRight:Vr("horiz",1),ArrowUp:Vr("vert",-1),ArrowDown:Vr("vert",1)});function Vr(n,e){const t=n=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,o,s){let i=r.selection,l=e>0?i.$to:i.$from,a=i.empty;if(i instanceof P){if(!s.endOfTextblock(t)||l.depth==0)return!1;a=!1,l=r.doc.resolve(e>0?l.after():l.before())}let c=q.findGapCursorFrom(l,e,a);return c?(o&&o(r.tr.setSelection(new q(c))),!0):!1}}function Ip(n,e,t){if(!n||!n.editable)return!1;let r=n.state.doc.resolve(e);if(!q.valid(r))return!1;let o=n.posAtCoords({left:t.clientX,top:t.clientY});return o&&o.inside>-1&&D.isSelectable(n.state.doc.nodeAt(o.inside))?!1:(n.dispatch(n.state.tr.setSelection(new q(r))),!0)}function Vp(n,e){if(e.inputType!="insertCompositionText"||!(n.state.selection instanceof q))return!1;let{$from:t}=n.state.selection,r=t.parent.contentMatchAt(t.index()).findWrapping(n.state.schema.nodes.text);if(!r)return!1;let o=C.empty;for(let i=r.length-1;i>=0;i--)o=C.from(r[i].createAndFill(null,o));let s=n.state.tr.replace(t.pos,t.pos,new N(o,0,0));return s.setSelection(P.near(s.doc.resolve(t.pos+1))),n.dispatch(s),!1}function Rp(n){if(!(n.selection instanceof q))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",H.create(n.doc,[Ve.widget(n.selection.head,e,{key:"gapcursor"})])}const zp=["ol",0],$p=["ul",0],jp=["li",0],Bp={attrs:{order:{default:1,validate:"number"}},parseDOM:[{tag:"ol",getAttrs(n){return{order:n.hasAttribute("start")?+n.getAttribute("start"):1}}}],toDOM(n){return n.attrs.order==1?zp:["ol",{start:n.attrs.order},0]}},Fp={parseDOM:[{tag:"ul"}],toDOM(){return $p}},Lp={parseDOM:[{tag:"li"}],toDOM(){return jp},defining:!0};function fs(n,e){let t={};for(let r in n)t[r]=n[r];for(let r in e)t[r]=e[r];return t}function Wp(n,e,t){return n.append({ordered_list:fs(Bp,{content:"list_item+",group:t}),bullet_list:fs(Fp,{content:"list_item+",group:t}),list_item:fs(Lp,{content:e})})}function Rr(n,e=null){return function(t,r){let{$from:o,$to:s}=t.selection,i=o.blockRange(s);if(!i)return!1;let l=r?t.tr:null;return _p(l,i,n,e)?(r&&r(l.scrollIntoView()),!0):!1}}function _p(n,e,t,r=null){let o=!1,s=e,i=e.$from.doc;if(e.depth>=2&&e.$from.node(e.depth-1).type.compatibleContent(t)&&e.startIndex==0){if(e.$from.index(e.depth-1)==0)return!1;let a=i.resolve(e.start-2);s=new hr(a,a,e.depth),e.endIndex<e.parent.childCount&&(e=new hr(e.$from,i.resolve(e.$to.end(e.depth)),e.depth)),o=!0}let l=ko(s,t,r,e);return l?(n&&qp(n,e,l,o,t),!0):!1}function qp(n,e,t,r,o){let s=C.empty;for(let u=t.length-1;u>=0;u--)s=C.from(t[u].type.create(t[u].attrs,s));n.step(new ee(e.start-(r?2:0),e.end,e.start,e.end,new N(s,0,0),t.length,!0));let i=0;for(let u=0;u<t.length;u++)t[u].type==o&&(i=u+1);let l=t.length-i,a=e.start+t.length-(r?2:0),c=e.parent;for(let u=e.startIndex,f=e.endIndex,d=!0;u<f;u++,d=!1)!d&&Qt(n.doc,a,l)&&(n.split(a,l),a+=2*l),a+=c.child(u).nodeSize;return n}function Hp(n,e){return function(t,r){let{$from:o,$to:s,node:i}=t.selection;if(i&&i.isBlock||o.depth<2||!o.sameParent(s))return!1;let l=o.node(-1);if(l.type!=n)return!1;if(o.parent.content.size==0&&o.node(-1).childCount==o.indexAfter(-1)){if(o.depth==3||o.node(-3).type!=n||o.index(-2)!=o.node(-2).childCount-1)return!1;if(r){let f=C.empty,d=o.index(-1)?1:o.index(-2)?2:3;for(let k=o.depth-d;k>=o.depth-3;k--)f=C.from(o.node(k).copy(f));let h=o.indexAfter(-1)<o.node(-2).childCount?1:o.indexAfter(-2)<o.node(-3).childCount?2:3;f=f.append(C.from(n.createAndFill()));let p=o.before(o.depth-(d-1)),b=t.tr.replace(p,o.after(-h),new N(f,4-d,0)),g=-1;b.doc.nodesBetween(p,b.doc.content.size,(k,S)=>{if(g>-1)return!1;k.isTextblock&&k.content.size==0&&(g=S+1)}),g>-1&&b.setSelection(R.near(b.doc.resolve(g))),r(b.scrollIntoView())}return!0}let a=s.pos==o.end()?l.contentMatchAt(0).defaultType:null,c=t.tr.delete(o.pos,s.pos),u=a?[null,{type:a}]:void 0;return Qt(c.doc,o.pos,2,u)?(r&&r(c.split(o.pos,2,u).scrollIntoView()),!0):!1}}function Kp(n){return function(e,t){let{$from:r,$to:o}=e.selection,s=r.blockRange(o,i=>i.childCount>0&&i.firstChild.type==n);return s?t?r.node(s.depth-1).type==n?Jp(e,t,n,s):Yp(e,t,s):!0:!1}}function Jp(n,e,t,r){let o=n.tr,s=r.end,i=r.$to.end(r.depth);s<i&&(o.step(new ee(s-1,i,s,i,new N(C.from(t.create(null,r.parent.copy())),1,0),1,!0)),r=new hr(o.doc.resolve(r.$from.pos),o.doc.resolve(i),r.depth));const l=On(r);if(l==null)return!1;o.lift(r,l);let a=o.doc.resolve(o.mapping.map(s,-1)-1);return Zt(o.doc,a.pos)&&a.nodeBefore.type==a.nodeAfter.type&&o.join(a.pos),e(o.scrollIntoView()),!0}function Yp(n,e,t){let r=n.tr,o=t.parent;for(let h=t.end,p=t.endIndex-1,b=t.startIndex;p>b;p--)h-=o.child(p).nodeSize,r.delete(h-1,h+1);let s=r.doc.resolve(t.start),i=s.nodeAfter;if(r.mapping.map(t.end)!=t.start+s.nodeAfter.nodeSize)return!1;let l=t.startIndex==0,a=t.endIndex==o.childCount,c=s.node(-1),u=s.index(-1);if(!c.canReplace(u+(l?0:1),u+1,i.content.append(a?C.empty:C.from(o))))return!1;let f=s.pos,d=f+i.nodeSize;return r.step(new ee(f-(l?1:0),d+(a?1:0),f+1,d-1,new N((l?C.empty:C.from(o.copy(C.empty))).append(a?C.empty:C.from(o.copy(C.empty))),l?0:1,a?0:1),l?0:1)),e(r.scrollIntoView()),!0}function Gp(n){return function(e,t){let{$from:r,$to:o}=e.selection,s=r.blockRange(o,c=>c.childCount>0&&c.firstChild.type==n);if(!s)return!1;let i=s.startIndex;if(i==0)return!1;let l=s.parent,a=l.child(i-1);if(a.type!=n)return!1;if(t){let c=a.lastChild&&a.lastChild.type==l.type,u=C.from(c?n.create():null),f=new N(C.from(n.create(null,C.from(l.type.create(null,u)))),c?3:1,0),d=s.start,h=s.end;t(e.tr.step(new ee(d-(c?3:1),h,d,h,f,1,!0)).scrollIntoView())}return!0}}class gt{constructor(e,t,r={}){this.match=e,this.match=e,this.handler=typeof t=="string"?Xp(t):t,this.undoable=r.undoable!==!1,this.inCode=r.inCode||!1,this.inCodeMark=r.inCodeMark!==!1}}function Xp(n){return function(e,t,r,o){let s=n;if(t[1]){let i=t[0].lastIndexOf(t[1]);s+=t[0].slice(i+t[1].length),r+=i;let l=r-o;l>0&&(s=t[0].slice(i-l,i)+s,r=o)}return e.tr.insertText(s,r,o)}}const Up=500;function Qp({rules:n}){let e=new Be({state:{init(){return null},apply(t,r){let o=t.getMeta(this);return o||(t.selectionSet||t.docChanged?null:r)}},props:{handleTextInput(t,r,o,s){return La(t,r,o,s,n,e)},handleDOMEvents:{compositionend:t=>{setTimeout(()=>{let{$cursor:r}=t.state.selection;r&&La(t,r.pos,r.pos,"",n,e)})}}},isInputRules:!0});return e}function La(n,e,t,r,o,s){if(n.composing)return!1;let i=n.state,l=i.doc.resolve(e),a=l.parent.textBetween(Math.max(0,l.parentOffset-Up),l.parentOffset,null,"")+r;for(let c=0;c<o.length;c++){let u=o[c];if(!u.inCodeMark&&l.marks().some(h=>h.type.spec.code))continue;if(l.parent.type.spec.code){if(!u.inCode)continue}else if(u.inCode==="only")continue;let f=u.match.exec(a),d=f&&f[0].length>=r.length&&u.handler(i,f,e-(f[0].length-r.length),t);if(d)return u.undoable&&d.setMeta(s,{transform:d,from:e,to:t,text:r}),n.dispatch(d),!0}return!1}const Zp=(n,e)=>{let t=n.plugins;for(let r=0;r<t.length;r++){let o=t[r],s;if(o.spec.isInputRules&&(s=o.getState(n))){if(e){let i=n.tr,l=s.transform;for(let a=l.steps.length-1;a>=0;a--)i.step(l.steps[a].invert(l.docs[a]));if(s.text){let a=i.doc.resolve(s.from).marks();i.replaceWith(s.from,s.to,n.schema.text(s.text,a))}else i.delete(s.from,s.to);e(i)}return!0}}return!1},em=new gt(/--$/,"—",{inCodeMark:!1}),tm=new gt(/\.\.\.$/,"…",{inCodeMark:!1}),nm=new gt(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,"“",{inCodeMark:!1}),rm=new gt(/"$/,"”",{inCodeMark:!1}),om=new gt(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,"‘",{inCodeMark:!1}),sm=new gt(/'$/,"’",{inCodeMark:!1}),im=[nm,rm,om,sm];function ds(n,e,t=null,r){return new gt(n,(o,s,i,l)=>{let a=t instanceof Function?t(s):t,c=o.tr.delete(i,l),u=c.doc.resolve(i),f=u.blockRange(),d=f&&ko(f,e,a);if(!d)return null;c.wrap(f,d);let h=c.doc.resolve(i-1).nodeBefore;return h&&h.type==e&&Zt(c.doc,i-1)&&(!r||r(s,h))&&c.join(i-1),c})}function Wa(n,e,t=null){return new gt(n,(r,o,s,i)=>{let l=r.doc.resolve(s),a=t instanceof Function?t(o):t;return l.node(-1).canReplaceWith(l.index(-1),l.indexAfter(-1),e)?r.tr.delete(s,i).setBlockType(s,s,e,a):null})}const _a=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):!1;function lm(n,e){let t={},r;function o(s,i){t[s]=i}if(o("Mod-z",Ao),o("Shift-Mod-z",Mr),o("Backspace",Zp),_a||o("Mod-y",Mr),o("Alt-ArrowUp",bl),o("Alt-ArrowDown",Vd),o("Mod-BracketLeft",$o),o("Escape",Bo),(r=n.marks.strong)&&(o("Mod-b",ke(r)),o("Mod-B",ke(r))),(r=n.marks.em)&&(o("Mod-i",ke(r)),o("Mod-I",ke(r))),(r=n.marks.code)&&o("Mod-`",ke(r)),(r=n.nodes.bullet_list)&&o("Shift-Ctrl-8",Rr(r)),(r=n.nodes.ordered_list)&&o("Shift-Ctrl-9",Rr(r)),(r=n.nodes.blockquote)&&o("Ctrl->",Cl(r)),r=n.nodes.hard_break){let s=r,i=Er(xl,(l,a)=>(a&&a(l.tr.replaceSelectionWith(s.create()).scrollIntoView()),!0));o("Mod-Enter",i),o("Shift-Enter",i),_a&&o("Ctrl-Enter",i)}if((r=n.nodes.list_item)&&(o("Enter",Hp(r)),o("Mod-[",Kp(r)),o("Mod-]",Gp(r))),(r=n.nodes.paragraph)&&o("Shift-Ctrl-0",on(r)),(r=n.nodes.code_block)&&o("Shift-Ctrl-\\",on(r)),r=n.nodes.heading)for(let s=1;s<=6;s++)o("Shift-Ctrl-"+s,on(r,{level:s}));if(r=n.nodes.horizontal_rule){let s=r;o("Mod-_",(i,l)=>(l&&l(i.tr.replaceSelectionWith(s.create()).scrollIntoView()),!0))}return t}function am(n){return ds(/^\s*>\s$/,n)}function cm(n){return ds(/^(\d+)\.\s$/,n,e=>({order:+e[1]}),(e,t)=>t.childCount+t.attrs.order==+e[1])}function um(n){return ds(/^\s*([-+*])\s$/,n)}function fm(n){return Wa(/^```$/,n)}function dm(n,e){return Wa(new RegExp("^(#{1,"+e+"})\\s$"),n,t=>({level:t[1].length}))}function hm(n){let e=im.concat(tm,em),t;return(t=n.nodes.blockquote)&&e.push(am(t)),(t=n.nodes.ordered_list)&&e.push(cm(t)),(t=n.nodes.bullet_list)&&e.push(um(t)),(t=n.nodes.code_block)&&e.push(fm(t)),(t=n.nodes.heading)&&e.push(dm(t,6)),Qp({rules:e})}const tt=new lt("ImagePluginKey"),pm=n=>new Be({key:tt,state:{init(){return{set:H.empty,schema:n.schema,upload:n.upload}},apply(t,r){let o=r.set.map(t.mapping,t.doc);const s=t.getMeta(tt);if(s&&s.add){const i=document.createElement("placeholder"),l=Ve.widget(s.add.pos,i,{id:s.add.id,key:`imgphd${s.add.id}`});o=o.add(t.doc,[l])}else s&&s.remove&&(o=o.remove(o.find(void 0,void 0,i=>i.id==s.remove.id)));return{...r,set:o}}},props:{decorations(t){var r;return(r=this.getState(t))==null?void 0:r.set}}}),mm=(n,e)=>{const t=tt.getState(n).set,r=t==null?void 0:t.find(void 0,void 0,o=>o.id==e);return r!=null&&r.length?r[0].from:null},gm=async(n,e,t,r)=>{if(!e)return;const o=Date.now(),s=n.state.tr;r===void 0&&(s.selection.empty||s.deleteSelection(),r=s.selection.from),s.setMeta(tt,{add:{id:o,pos:r}}),n.dispatch(s);try{const i=tt.getState(n.state),l=i.schema,a=i.upload;if(!a)throw new Error("uploadImage: Image upload function not defined");const c=await a(e);if(typeof c=="string")throw new Error(c);const u=mm(n.state,o);if(u===null){console.warn("uploadImage: The image was removed from the document during upload");return}n.dispatch(n.state.tr.replaceWith(u,u,l.nodes.image.create({fid:c,title:t})).setMeta(tt,{remove:{id:o}}))}catch(i){n.dispatch(n.state.tr.setMeta(tt,{remove:{id:o}})),console.error(`uploadImage: ${i}`)}},ym=(n,e,t,r)=>{if(!e)return;const o=n.state.tr;r===void 0&&(o.selection.empty||o.deleteSelection(),r=o.selection.from);const s=tt.getState(n.state).schema;n.dispatch(n.state.tr.replaceWith(r,r,s.nodes.image.create({src:e,title:t})))},Ft=function(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e},qa=function(n,e,t,r){return t&&(Ha(n,e,t,r,-1)||Ha(n,e,t,r,1))},bm=/^(img|br|input|textarea|hr)$/i;function Ha(n,e,t,r,o){for(;;){if(n==t&&e==r)return!0;if(e==(o<0?0:zr(n))){let s=n.parentNode;if(!s||s.nodeType!=1||hs(n)||bm.test(n.nodeName)||n.contentEditable=="false")return!1;e=Ft(n)+(o<0?0:1),n=s}else if(n.nodeType==1){if(n=n.childNodes[e+(o<0?-1:0)],n.contentEditable=="false")return!1;e=o<0?zr(n):0}else return!1}}function zr(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function xm(n,e,t){for(let r=e==0,o=e==zr(n);r||o;){if(n==t)return!0;let s=Ft(n);if(n=n.parentNode,!n)return!1;r=r&&s==0,o=o&&s==zr(n)}}function hs(n){let e;for(let t=n;t&&!(e=t.pmViewDesc);t=t.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==n||e.contentDOM==n)}const Ka=function(n){return n.focusNode&&qa(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)};function Ja(n,e){let t=document.createEvent("Event");return t.initEvent("keydown",!0,!0),t.keyCode=n,t.key=t.code=e,t}const _e=typeof navigator<"u"?navigator:null,Ya=typeof document<"u"?document:null,yt=_e&&_e.userAgent||"",ps=/Edge\/(\d+)/.exec(yt),Ga=/MSIE \d/.exec(yt),ms=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(yt),qn=!!(Ga||ms||ps),Xa=Ga?document.documentMode:ms?+ms[1]:ps?+ps[1]:0,$r=!qn&&/gecko\/(\d+)/i.test(yt);$r&&+(/Firefox\/(\d+)/.exec(yt)||[0,0])[1];const gs=!qn&&/Chrome\/(\d+)/.exec(yt),bt=!!gs,Ua=gs?+gs[1]:0,Lt=!qn&&!!_e&&/Apple Computer/.test(_e.vendor),ys=Lt&&(/Mobile\/\w+/.test(yt)||!!_e&&_e.maxTouchPoints>2),De=ys||(_e?/Mac/.test(_e.platform):!1),km=_e?/Win/.test(_e.platform):!1,Hn=/Android \d/.test(yt),bs=!!Ya&&"webkitFontSmoothing"in Ya.documentElement.style,Sm=bs?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Cm(n,e=null){let t=n.domSelectionRange(),r=n.state.doc;if(!t.focusNode)return null;let o=n.docView.nearestDesc(t.focusNode),s=o&&o.size==0,i=n.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(i<0)return null;let l=r.resolve(i),a,c;if(Ka(t)){for(a=i;o&&!o.node;)o=o.parent;let f=o.node;if(o&&f.isAtom&&D.isSelectable(f)&&o.parent&&!(f.isInline&&xm(t.focusNode,t.focusOffset,o.dom))){let d=o.posBefore;c=new D(i==d?l:r.resolve(d))}}else{if(t instanceof n.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let f=i,d=i;for(let h=0;h<t.rangeCount;h++){let p=t.getRangeAt(h);f=Math.min(f,n.docView.posFromDOM(p.startContainer,p.startOffset,1)),d=Math.max(d,n.docView.posFromDOM(p.endContainer,p.endOffset,-1))}if(f<0)return null;[a,i]=d==n.state.selection.anchor?[d,f]:[f,d],l=r.resolve(i)}else a=n.docView.posFromDOM(t.anchorNode,t.anchorOffset,1);if(a<0)return null}let u=r.resolve(a);if(!c){let f=e=="pointer"||n.state.selection.head<l.pos&&!s?1:-1;c=rc(n,u,l,f)}return c}function Qa(n){return n.editable?n.hasFocus():Em(n)&&document.activeElement&&document.activeElement.contains(n.dom)}function xs(n,e=!1){let t=n.state.selection;if(Nm(n,t),!!Qa(n)){if(!e&&n.input.mouseDown&&n.input.mouseDown.allowDefault&&bt){let r=n.domSelectionRange(),o=n.domObserver.currentSelection;if(r.anchorNode&&o.anchorNode&&qa(r.anchorNode,r.anchorOffset,o.anchorNode,o.anchorOffset)){n.input.mouseDown.delayedSelectionSync=!0,n.domObserver.setCurSelection();return}}if(n.domObserver.disconnectSelection(),n.cursorWrapper)Mm(n);else{let{anchor:r,head:o}=t,s,i;Za&&!(t instanceof P)&&(t.$from.parent.inlineContent||(s=ec(n,t.from)),!t.empty&&!t.$from.parent.inlineContent&&(i=ec(n,t.to))),n.docView.setSelection(r,o,n,e),Za&&(s&&tc(s),i&&tc(i)),t.visible?n.dom.classList.remove("ProseMirror-hideselection"):(n.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&wm(n))}n.domObserver.setCurSelection(),n.domObserver.connectSelection()}}const Za=Lt||bt&&Ua<63;function ec(n,e){let{node:t,offset:r}=n.docView.domFromPos(e,0),o=r<t.childNodes.length?t.childNodes[r]:null,s=r?t.childNodes[r-1]:null;if(Lt&&o&&o.contentEditable=="false")return ks(o);if((!o||o.contentEditable=="false")&&(!s||s.contentEditable=="false")){if(o)return ks(o);if(s)return ks(s)}}function ks(n){return n.contentEditable="true",Lt&&n.draggable&&(n.draggable=!1,n.wasDraggable=!0),n}function tc(n){n.contentEditable="false",n.wasDraggable&&(n.draggable=!0,n.wasDraggable=null)}function wm(n){let e=n.dom.ownerDocument;e.removeEventListener("selectionchange",n.input.hideSelectionGuard);let t=n.domSelectionRange(),r=t.anchorNode,o=t.anchorOffset;e.addEventListener("selectionchange",n.input.hideSelectionGuard=()=>{(t.anchorNode!=r||t.anchorOffset!=o)&&(e.removeEventListener("selectionchange",n.input.hideSelectionGuard),setTimeout(()=>{(!Qa(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function Mm(n){let e=n.domSelection(),t=document.createRange();if(!e)return;let r=n.cursorWrapper.dom,o=r.nodeName=="IMG";o?t.setStart(r.parentNode,Ft(r)+1):t.setStart(r,0),t.collapse(!0),e.removeAllRanges(),e.addRange(t),!o&&!n.state.selection.visible&&qn&&Xa<=11&&(r.disabled=!0,r.disabled=!1)}function Nm(n,e){if(e instanceof D){let t=n.docView.descAt(e.from);t!=n.lastSelectedViewDesc&&(nc(n),t&&t.selectNode(),n.lastSelectedViewDesc=t)}else nc(n)}function nc(n){n.lastSelectedViewDesc&&(n.lastSelectedViewDesc.parent&&n.lastSelectedViewDesc.deselectNode(),n.lastSelectedViewDesc=void 0)}function rc(n,e,t,r){return n.someProp("createSelectionBetween",o=>o(n,e,t))||P.between(e,t,r)}function Em(n){let e=n.domSelectionRange();if(!e.anchorNode)return!1;try{return n.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(n.editable||n.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function Ss(n,e){let{$anchor:t,$head:r}=n.selection,o=e>0?t.max(r):t.min(r),s=o.parent.inlineContent?o.depth?n.doc.resolve(e>0?o.after():o.before()):null:o;return s&&R.findFrom(s,e)}function xt(n,e){return n.dispatch(n.state.tr.setSelection(e).scrollIntoView()),!0}function oc(n,e,t){let r=n.state.selection;if(r instanceof P)if(t.indexOf("s")>-1){let{$head:o}=r,s=o.textOffset?null:e<0?o.nodeBefore:o.nodeAfter;if(!s||s.isText||!s.isLeaf)return!1;let i=n.state.doc.resolve(o.pos+s.nodeSize*(e<0?-1:1));return xt(n,new P(r.$anchor,i))}else if(r.empty){if(n.endOfTextblock(e>0?"forward":"backward")){let o=Ss(n.state,e);return o&&o instanceof D?xt(n,o):!1}else if(!(De&&t.indexOf("m")>-1)){let o=r.$head,s=o.textOffset?null:e<0?o.nodeBefore:o.nodeAfter,i;if(!s||s.isText)return!1;let l=e<0?o.pos-s.nodeSize:o.pos;return s.isAtom||(i=n.docView.descAt(l))&&!i.contentDOM?D.isSelectable(s)?xt(n,new D(e<0?n.state.doc.resolve(o.pos-s.nodeSize):o)):bs?xt(n,new P(n.state.doc.resolve(e<0?l:l+s.nodeSize))):!1:!1}}else return!1;else{if(r instanceof D&&r.node.isInline)return xt(n,new P(e>0?r.$to:r.$from));{let o=Ss(n.state,e);return o?xt(n,o):!1}}}function jr(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Kn(n,e){let t=n.pmViewDesc;return t&&t.size==0&&(e<0||n.nextSibling||n.nodeName!="BR")}function dn(n,e){return e<0?Dm(n):Om(n)}function Dm(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let o,s,i=!1;for($r&&t.nodeType==1&&r<jr(t)&&Kn(t.childNodes[r],-1)&&(i=!0);;)if(r>0){if(t.nodeType!=1)break;{let l=t.childNodes[r-1];if(Kn(l,-1))o=t,s=--r;else if(l.nodeType==3)t=l,r=t.nodeValue.length;else break}}else{if(sc(t))break;{let l=t.previousSibling;for(;l&&Kn(l,-1);)o=t.parentNode,s=Ft(l),l=l.previousSibling;if(l)t=l,r=jr(t);else{if(t=t.parentNode,t==n.dom)break;r=0}}}i?Cs(n,t,r):o&&Cs(n,o,s)}function Om(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let o=jr(t),s,i;for(;;)if(r<o){if(t.nodeType!=1)break;let l=t.childNodes[r];if(Kn(l,1))s=t,i=++r;else break}else{if(sc(t))break;{let l=t.nextSibling;for(;l&&Kn(l,1);)s=l.parentNode,i=Ft(l)+1,l=l.nextSibling;if(l)t=l,r=0,o=jr(t);else{if(t=t.parentNode,t==n.dom)break;r=o=0}}}s&&Cs(n,s,i)}function sc(n){let e=n.pmViewDesc;return e&&e.node&&e.node.isBlock}function Tm(n,e){for(;n&&e==n.childNodes.length&&!hs(n);)e=Ft(n)+1,n=n.parentNode;for(;n&&e<n.childNodes.length;){let t=n.childNodes[e];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;n=t,e=0}}function vm(n,e){for(;n&&!e&&!hs(n);)e=Ft(n),n=n.parentNode;for(;n&&e;){let t=n.childNodes[e-1];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;n=t,e=n.childNodes.length}}function Cs(n,e,t){if(e.nodeType!=3){let s,i;(i=Tm(e,t))?(e=i,t=0):(s=vm(e,t))&&(e=s,t=s.nodeValue.length)}let r=n.domSelection();if(!r)return;if(Ka(r)){let s=document.createRange();s.setEnd(e,t),s.setStart(e,t),r.removeAllRanges(),r.addRange(s)}else r.extend&&r.extend(e,t);n.domObserver.setCurSelection();let{state:o}=n;setTimeout(()=>{n.state==o&&xs(n)},50)}function ic(n,e){let t=n.state.doc.resolve(e);if(!(bt||km)&&t.parent.inlineContent){let o=n.coordsAtPos(e);if(e>t.start()){let s=n.coordsAtPos(e-1),i=(s.top+s.bottom)/2;if(i>o.top&&i<o.bottom&&Math.abs(s.left-o.left)>1)return s.left<o.left?"ltr":"rtl"}if(e<t.end()){let s=n.coordsAtPos(e+1),i=(s.top+s.bottom)/2;if(i>o.top&&i<o.bottom&&Math.abs(s.left-o.left)>1)return s.left>o.left?"ltr":"rtl"}}return getComputedStyle(n.dom).direction=="rtl"?"rtl":"ltr"}function lc(n,e,t){let r=n.state.selection;if(r instanceof P&&!r.empty||t.indexOf("s")>-1||De&&t.indexOf("m")>-1)return!1;let{$from:o,$to:s}=r;if(!o.parent.inlineContent||n.endOfTextblock(e<0?"up":"down")){let i=Ss(n.state,e);if(i&&i instanceof D)return xt(n,i)}if(!o.parent.inlineContent){let i=e<0?o:s,l=r instanceof ge?R.near(i,e):R.findFrom(i,e);return l?xt(n,l):!1}return!1}function ac(n,e){if(!(n.state.selection instanceof P))return!0;let{$head:t,$anchor:r,empty:o}=n.state.selection;if(!t.sameParent(r))return!0;if(!o)return!1;if(n.endOfTextblock(e>0?"forward":"backward"))return!0;let s=!t.textOffset&&(e<0?t.nodeBefore:t.nodeAfter);if(s&&!s.isText){let i=n.state.tr;return e<0?i.delete(t.pos-s.nodeSize,t.pos):i.delete(t.pos,t.pos+s.nodeSize),n.dispatch(i),!0}return!1}function cc(n,e,t){n.domObserver.stop(),e.contentEditable=t,n.domObserver.start()}function Am(n){if(!Lt||n.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:t}=n.domSelectionRange();if(e&&e.nodeType==1&&t==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let r=e.firstChild;cc(n,r,"true"),setTimeout(()=>cc(n,r,"false"),20)}return!1}function Pm(n){let e="";return n.ctrlKey&&(e+="c"),n.metaKey&&(e+="m"),n.altKey&&(e+="a"),n.shiftKey&&(e+="s"),e}function Im(n,e){let t=e.keyCode,r=Pm(e);if(t==8||De&&t==72&&r=="c")return ac(n,-1)||dn(n,-1);if(t==46&&!e.shiftKey||De&&t==68&&r=="c")return ac(n,1)||dn(n,1);if(t==13||t==27)return!0;if(t==37||De&&t==66&&r=="c"){let o=t==37?ic(n,n.state.selection.from)=="ltr"?-1:1:-1;return oc(n,o,r)||dn(n,o)}else if(t==39||De&&t==70&&r=="c"){let o=t==39?ic(n,n.state.selection.from)=="ltr"?1:-1:1;return oc(n,o,r)||dn(n,o)}else{if(t==38||De&&t==80&&r=="c")return lc(n,-1,r)||dn(n,-1);if(t==40||De&&t==78&&r=="c")return Am(n)||lc(n,1,r)||dn(n,1);if(r==(De?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function uc(n,e){n.someProp("transformCopied",h=>{e=h(e,n)});let t=[],{content:r,openStart:o,openEnd:s}=e;for(;o>1&&s>1&&r.childCount==1&&r.firstChild.childCount==1;){o--,s--;let h=r.firstChild;t.push(h.type.name,h.attrs!=h.type.defaultAttrs?h.attrs:null),r=h.content}let i=n.someProp("clipboardSerializer")||$e.fromSchema(n.state.schema),l=bc(),a=l.createElement("div");a.appendChild(i.serializeFragment(r,{document:l}));let c=a.firstChild,u,f=0;for(;c&&c.nodeType==1&&(u=gc[c.nodeName.toLowerCase()]);){for(let h=u.length-1;h>=0;h--){let p=l.createElement(u[h]);for(;a.firstChild;)p.appendChild(a.firstChild);a.appendChild(p),f++}c=a.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${o} ${s}${f?` -${f}`:""} ${JSON.stringify(t)}`);let d=n.someProp("clipboardTextSerializer",h=>h(e,n))||e.content.textBetween(0,e.content.size,`
|
|
42
42
|
|
|
43
|
-
`);return{dom:a,text:d,slice:e}}function fc(n,e,t,r,o){let s=o.parent.type.spec.code,i,l;if(!t&&!e)return null;let a=e&&(r||s||!t);if(a){if(n.someProp("transformPastedText",d=>{e=d(e,s||r,n)}),s)return e?new N(
|
|
44
|
-
`))),0,0):N.empty;let f=n.someProp("clipboardTextParser",d=>d(e,o,r,n));if(f)l=f;else{let d=o.marks(),{schema:p}=n.state,h=$e.fromSchema(p);i=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(b=>{let g=i.appendChild(document.createElement("p"));b&&g.appendChild(h.serializeNode(p.text(b,d)))})}}else n.someProp("transformPastedHTML",f=>{t=f(t,n)}),i=$m(t),bs&&jm(i);let c=i&&i.querySelector("[data-pm-slice]"),u=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(u&&u[3])for(let f=+u[3];f>0;f--){let d=i.firstChild;for(;d&&d.nodeType!=1;)d=d.nextSibling;if(!d)break;i=d}if(l||(l=(n.someProp("clipboardParser")||n.someProp("domParser")||Pt.fromSchema(n.state.schema)).parseSlice(i,{preserveWhitespace:!!(a||u),context:o,ruleFromNode(d){return d.nodeName=="BR"&&!d.nextSibling&&d.parentNode&&!Vm.test(d.parentNode.nodeName)?{ignore:!0}:null}})),u)l=Bm(mc(l,+u[1],+u[2]),u[4]);else if(l=N.maxOpen(Rm(l.content,o),!0),l.openStart||l.openEnd){let f=0,d=0;for(let p=l.content.firstChild;f<l.openStart&&!p.type.spec.isolating;f++,p=p.firstChild);for(let p=l.content.lastChild;d<l.openEnd&&!p.type.spec.isolating;d++,p=p.lastChild);l=mc(l,f,d)}return n.someProp("transformPasted",f=>{l=f(l,n)}),l}const Vm=/^(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 Rm(n,e){if(n.childCount<2)return n;for(let t=e.depth;t>=0;t--){let o=e.node(t).contentMatchAt(e.index(t)),s,i=[];if(n.forEach(l=>{if(!i)return;let a=o.findWrapping(l.type),c;if(!a)return i=null;if(c=i.length&&s.length&&hc(a,s,l,i[i.length-1],0))i[i.length-1]=c;else{i.length&&(i[i.length-1]=pc(i[i.length-1],s.length));let u=dc(l,a);i.push(u),o=o.matchType(u.type),s=a}}),i)return S.from(i)}return n}function dc(n,e,t=0){for(let r=e.length-1;r>=t;r--)n=e[r].create(null,S.from(n));return n}function hc(n,e,t,r,o){if(o<n.length&&o<e.length&&n[o]==e[o]){let s=hc(n,e,t,r.lastChild,o+1);if(s)return r.copy(r.content.replaceChild(r.childCount-1,s));if(r.contentMatchAt(r.childCount).matchType(o==n.length-1?t.type:n[o+1]))return r.copy(r.content.append(S.from(dc(t,n,o+1))))}}function pc(n,e){if(e==0)return n;let t=n.content.replaceChild(n.childCount-1,pc(n.lastChild,e-1)),r=n.contentMatchAt(n.childCount).fillBefore(S.empty,!0);return n.copy(t.append(r))}function ws(n,e,t,r,o,s){let i=e<0?n.firstChild:n.lastChild,l=i.content;return n.childCount>1&&(s=0),o<r-1&&(l=ws(l,e,t,r,o+1,s)),o>=t&&(l=e<0?i.contentMatchAt(0).fillBefore(l,s<=o).append(l):l.append(i.contentMatchAt(i.childCount).fillBefore(S.empty,!0))),n.replaceChild(e<0?0:n.childCount-1,i.copy(l))}function mc(n,e,t){return e<n.openStart&&(n=new N(ws(n.content,-1,e,n.openStart,0,n.openEnd),e,n.openEnd)),t<n.openEnd&&(n=new N(ws(n.content,1,t,n.openEnd,0,0),n.openStart,t)),n}const gc={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};let yc=null;function bc(){return yc||(yc=document.implementation.createHTMLDocument("title"))}let Ms=null;function zm(n){let e=window.trustedTypes;return e?(Ms||(Ms=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})),Ms.createHTML(n)):n}function $m(n){let e=/^(\s*<meta [^>]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=bc().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(n),o;if((o=r&&gc[r[1].toLowerCase()])&&(n=o.map(s=>"<"+s+">").join("")+n+o.map(s=>"</"+s+">").reverse().join("")),t.innerHTML=zm(n),o)for(let s=0;s<o.length;s++)t=t.querySelector(o[s])||t;return t}function jm(n){let e=n.querySelectorAll(bt?"span:not([class]):not([style])":"span.Apple-converted-space");for(let t=0;t<e.length;t++){let r=e[t];r.childNodes.length==1&&r.textContent==" "&&r.parentNode&&r.parentNode.replaceChild(n.ownerDocument.createTextNode(" "),r)}}function Bm(n,e){if(!n.size)return n;let t=n.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return n}let{content:o,openStart:s,openEnd:i}=n;for(let l=r.length-2;l>=0;l-=2){let a=t.nodes[r[l]];if(!a||a.hasRequiredAttrs())break;o=S.from(a.create(r[l+1],o)),s++,i++}return new N(o,s,i)}const Re={},Se={};function kt(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}Se.keydown=(n,e)=>{let t=e;if(n.input.shiftKey=t.keyCode==16||t.shiftKey,!kc(n,t)&&(n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),!(Hn&&bt&&t.keyCode==13)))if(t.keyCode!=229&&n.domObserver.forceFlush(),ys&&t.keyCode==13&&!t.ctrlKey&&!t.altKey&&!t.metaKey){let r=Date.now();n.input.lastIOSEnter=r,n.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{n.input.lastIOSEnter==r&&(n.someProp("handleKeyDown",o=>o(n,Ja(13,"Enter"))),n.input.lastIOSEnter=0)},200)}else n.someProp("handleKeyDown",r=>r(n,t))||Im(n,t)?t.preventDefault():kt(n,"key")},Se.keyup=(n,e)=>{e.keyCode==16&&(n.input.shiftKey=!1)},Se.keypress=(n,e)=>{let t=e;if(kc(n,t)||!t.charCode||t.ctrlKey&&!t.altKey||De&&t.metaKey)return;if(n.someProp("handleKeyPress",o=>o(n,t))){t.preventDefault();return}let r=n.state.selection;if(!(r instanceof P)||!r.$from.sameParent(r.$to)){let o=String.fromCharCode(t.charCode);!/[\r\n]/.test(o)&&!n.someProp("handleTextInput",s=>s(n,r.$from.pos,r.$to.pos,o))&&n.dispatch(n.state.tr.insertText(o).scrollIntoView()),t.preventDefault()}};function Br(n){return{left:n.clientX,top:n.clientY}}function Fm(n,e){let t=e.x-n.clientX,r=e.y-n.clientY;return t*t+r*r<100}function Ns(n,e,t,r,o){if(r==-1)return!1;let s=n.state.doc.resolve(r);for(let i=s.depth+1;i>0;i--)if(n.someProp(e,l=>i>s.depth?l(n,t,s.nodeAfter,s.before(i),o,!0):l(n,t,s.node(i),s.before(i),o,!1)))return!0;return!1}function hn(n,e,t){if(n.focused||n.focus(),n.state.selection.eq(e))return;let r=n.state.tr.setSelection(e);r.setMeta("pointer",!0),n.dispatch(r)}function Lm(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),r=t.nodeAfter;return r&&r.isAtom&&D.isSelectable(r)?(hn(n,new D(t)),!0):!1}function Wm(n,e){if(e==-1)return!1;let t=n.state.selection,r,o;t instanceof D&&(r=t.node);let s=n.state.doc.resolve(e);for(let i=s.depth+1;i>0;i--){let l=i>s.depth?s.nodeAfter:s.node(i);if(D.isSelectable(l)){r&&t.$from.depth>0&&i>=t.$from.depth&&s.before(t.$from.depth+1)==t.$from.pos?o=s.before(t.$from.depth):o=s.before(i);break}}return o!=null?(hn(n,D.create(n.state.doc,o)),!0):!1}function _m(n,e,t,r,o){return Ns(n,"handleClickOn",e,t,r)||n.someProp("handleClick",s=>s(n,e,r))||(o?Wm(n,t):Lm(n,t))}function qm(n,e,t,r){return Ns(n,"handleDoubleClickOn",e,t,r)||n.someProp("handleDoubleClick",o=>o(n,e,r))}function Hm(n,e,t,r){return Ns(n,"handleTripleClickOn",e,t,r)||n.someProp("handleTripleClick",o=>o(n,e,r))||Km(n,t,r)}function Km(n,e,t){if(t.button!=0)return!1;let r=n.state.doc;if(e==-1)return r.inlineContent?(hn(n,P.create(r,0,r.content.size)),!0):!1;let o=r.resolve(e);for(let s=o.depth+1;s>0;s--){let i=s>o.depth?o.nodeAfter:o.node(s),l=o.before(s);if(i.inlineContent)hn(n,P.create(r,l+1,l+1+i.content.size));else if(D.isSelectable(i))hn(n,D.create(r,l));else continue;return!0}}function Es(n){return Fr(n)}const xc=De?"metaKey":"ctrlKey";Re.mousedown=(n,e)=>{let t=e;n.input.shiftKey=t.shiftKey;let r=Es(n),o=Date.now(),s="singleClick";o-n.input.lastClick.time<500&&Fm(t,n.input.lastClick)&&!t[xc]&&(n.input.lastClick.type=="singleClick"?s="doubleClick":n.input.lastClick.type=="doubleClick"&&(s="tripleClick")),n.input.lastClick={time:o,x:t.clientX,y:t.clientY,type:s};let i=n.posAtCoords(Br(t));i&&(s=="singleClick"?(n.input.mouseDown&&n.input.mouseDown.done(),n.input.mouseDown=new Jm(n,i,t,!!r)):(s=="doubleClick"?qm:Hm)(n,i.pos,i.inside,t)?t.preventDefault():kt(n,"pointer"))};class Jm{constructor(e,t,r,o){this.view=e,this.pos=t,this.event=r,this.flushed=o,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!r[xc],this.allowDefault=r.shiftKey;let s,i;if(t.inside>-1)s=e.state.doc.nodeAt(t.inside),i=t.inside;else{let u=e.state.doc.resolve(t.pos);s=u.parent,i=u.depth?u.before():0}const l=o?null:r.target,a=l?e.docView.nearestDesc(l,!0):null;this.target=a&&a.dom.nodeType==1?a.dom:null;let{selection:c}=e.state;(r.button==0&&s.type.spec.draggable&&s.type.spec.selectable!==!1||c instanceof D&&c.from<=i&&c.to>i)&&(this.mightDrag={node:s,pos:i,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&$r&&!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(()=>xs(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(Br(e))),this.updateAllowDefault(e),this.allowDefault||!t?kt(this.view,"pointer"):_m(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||Lt&&this.mightDrag&&!this.mightDrag.node.isAtom||bt&&!this.view.state.selection.visible&&Math.min(Math.abs(t.pos-this.view.state.selection.from),Math.abs(t.pos-this.view.state.selection.to))<=2)?(hn(this.view,R.near(this.view.state.doc.resolve(t.pos))),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)}}Re.touchstart=n=>{n.input.lastTouch=Date.now(),Es(n),kt(n,"pointer")},Re.touchmove=n=>{n.input.lastTouch=Date.now(),kt(n,"pointer")},Re.contextmenu=n=>Es(n);function kc(n,e){return n.composing?!0:Lt&&Math.abs(e.timeStamp-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}const Ym=Hn?5e3:-1;Se.compositionstart=Se.compositionupdate=n=>{if(!n.composing){n.domObserver.flush();let{state:e}=n,t=e.selection.$to;if(e.selection instanceof P&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)))n.markCursor=n.state.storedMarks||t.marks(),Fr(n,!0),n.markCursor=null;else if(Fr(n,!e.selection.empty),$r&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length){let r=n.domSelectionRange();for(let o=r.focusNode,s=r.focusOffset;o&&o.nodeType==1&&s!=0;){let i=s<0?o.lastChild:o.childNodes[s-1];if(!i)break;if(i.nodeType==3){let l=n.domSelection();l&&l.collapse(i,i.nodeValue.length);break}else o=i,s=-1}}n.input.composing=!0}Sc(n,Ym)},Se.compositionend=(n,e)=>{n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=e.timeStamp,n.input.compositionPendingChanges=n.domObserver.pendingRecords().length?n.input.compositionID:0,n.input.compositionNode=null,n.input.compositionPendingChanges&&Promise.resolve().then(()=>n.domObserver.flush()),n.input.compositionID++,Sc(n,20))};function Sc(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>Fr(n),e))}function Gm(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=Xm());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function Xm(){let n=document.createEvent("Event");return n.initEvent("event",!0,!0),n.timeStamp}function Fr(n,e=!1){if(!(Hn&&n.domObserver.flushingSoon>=0)){if(n.domObserver.forceFlush(),Gm(n),e||n.docView&&n.docView.dirty){let t=Cm(n);return t&&!t.eq(n.state.selection)?n.dispatch(n.state.tr.setSelection(t)):(n.markCursor||e)&&!n.state.selection.empty?n.dispatch(n.state.tr.deleteSelection()):n.updateState(n.state),!0}return!1}}function Um(n,e){if(!n.dom.parentNode)return;let t=n.dom.parentNode.appendChild(document.createElement("div"));t.appendChild(e),t.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),o=document.createRange();o.selectNodeContents(e),n.dom.blur(),r.removeAllRanges(),r.addRange(o),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t),n.focus()},50)}const Jn=qn&&Xa<15||ys&&Sm<604;Re.copy=Se.cut=(n,e)=>{let t=e,r=n.state.selection,o=t.type=="cut";if(r.empty)return;let s=Jn?null:t.clipboardData,i=r.content(),{dom:l,text:a}=uc(n,i);s?(t.preventDefault(),s.clearData(),s.setData("text/html",l.innerHTML),s.setData("text/plain",a)):Um(n,l),o&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function Qm(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function Zm(n,e){if(!n.dom.parentNode)return;let t=n.input.shiftKey||n.state.selection.$from.parent.type.spec.code,r=n.dom.parentNode.appendChild(document.createElement(t?"textarea":"div"));t||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let o=n.input.shiftKey&&n.input.lastKeyCode!=45;setTimeout(()=>{n.focus(),r.parentNode&&r.parentNode.removeChild(r),t?Ds(n,r.value,null,o,e):Ds(n,r.textContent,r.innerHTML,o,e)},50)}function Ds(n,e,t,r,o){let s=fc(n,e,t,r,n.state.selection.$from);if(n.someProp("handlePaste",a=>a(n,o,s||N.empty)))return!0;if(!s)return!1;let i=Qm(s),l=i?n.state.tr.replaceSelectionWith(i,r):n.state.tr.replaceSelection(s);return n.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Cc(n){let e=n.getData("text/plain")||n.getData("Text");if(e)return e;let t=n.getData("text/uri-list");return t?t.replace(/\r?\n/g," "):""}Se.paste=(n,e)=>{let t=e;if(n.composing&&!Hn)return;let r=Jn?null:t.clipboardData,o=n.input.shiftKey&&n.input.lastKeyCode!=45;r&&Ds(n,Cc(r),r.getData("text/html"),o,t)?t.preventDefault():Zm(n,t)};class eg{constructor(e,t,r){this.slice=e,this.move=t,this.node=r}}const tg=De?"altKey":"ctrlKey";function wc(n,e){let t=n.someProp("dragCopies",r=>!r(e));return t??!e[tg]}Re.dragstart=(n,e)=>{let t=e,r=n.input.mouseDown;if(r&&r.done(),!t.dataTransfer)return;let o=n.state.selection,s=o.empty?null:n.posAtCoords(Br(t)),i;if(!(s&&s.pos>=o.from&&s.pos<=(o instanceof D?o.to-1:o.to))){if(r&&r.mightDrag)i=D.create(n.state.doc,r.mightDrag.pos);else if(t.target&&t.target.nodeType==1){let f=n.docView.nearestDesc(t.target,!0);f&&f.node.type.spec.draggable&&f!=n.docView&&(i=D.create(n.state.doc,f.posBefore))}}let l=(i||n.state.selection).content(),{dom:a,text:c,slice:u}=uc(n,l);(!t.dataTransfer.files.length||!bt||Ua>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(Jn?"Text":"text/html",a.innerHTML),t.dataTransfer.effectAllowed="copyMove",Jn||t.dataTransfer.setData("text/plain",c),n.dragging=new eg(u,wc(n,t),i)},Re.dragend=n=>{let e=n.dragging;window.setTimeout(()=>{n.dragging==e&&(n.dragging=null)},50)},Se.dragover=Se.dragenter=(n,e)=>e.preventDefault(),Se.drop=(n,e)=>{let t=e,r=n.dragging;if(n.dragging=null,!t.dataTransfer)return;let o=n.posAtCoords(Br(t));if(!o)return;let s=n.state.doc.resolve(o.pos),i=r&&r.slice;i?n.someProp("transformPasted",h=>{i=h(i,n)}):i=fc(n,Cc(t.dataTransfer),Jn?null:t.dataTransfer.getData("text/html"),!1,s);let l=!!(r&&wc(n,t));if(n.someProp("handleDrop",h=>h(n,t,i||N.empty,l))){t.preventDefault();return}if(!i)return;t.preventDefault();let a=i?So(n.state.doc,s.pos,i):s.pos;a==null&&(a=s.pos);let c=n.state.tr;if(l){let{node:h}=r;h?h.replace(c):c.deleteSelection()}let u=c.mapping.map(a),f=i.openStart==0&&i.openEnd==0&&i.content.childCount==1,d=c.doc;if(f?c.replaceRangeWith(u,u,i.content.firstChild):c.replaceRange(u,u,i),c.doc.eq(d))return;let p=c.doc.resolve(u);if(f&&D.isSelectable(i.content.firstChild)&&p.nodeAfter&&p.nodeAfter.sameMarkup(i.content.firstChild))c.setSelection(new D(p));else{let h=c.mapping.map(a);c.mapping.maps[c.mapping.maps.length-1].forEach((b,g,k,w)=>h=w),c.setSelection(rc(n,p,c.doc.resolve(h)))}n.focus(),n.dispatch(c.setMeta("uiEvent","drop"))},Re.focus=n=>{n.input.lastFocus=Date.now(),n.focused||(n.domObserver.stop(),n.dom.classList.add("ProseMirror-focused"),n.domObserver.start(),n.focused=!0,setTimeout(()=>{n.docView&&n.hasFocus()&&!n.domObserver.currentSelection.eq(n.domSelectionRange())&&xs(n)},20))},Re.blur=(n,e)=>{let t=e;n.focused&&(n.domObserver.stop(),n.dom.classList.remove("ProseMirror-focused"),n.domObserver.start(),t.relatedTarget&&n.dom.contains(t.relatedTarget)&&n.domObserver.currentSelection.clear(),n.focused=!1)},Re.beforeinput=(n,e)=>{if(bt&&Hn&&e.inputType=="deleteContentBackward"){n.domObserver.flushSoon();let{domChangeCount:r}=n.input;setTimeout(()=>{if(n.input.domChangeCount!=r||(n.dom.blur(),n.focus(),n.someProp("handleKeyDown",s=>s(n,Ja(8,"Backspace")))))return;let{$cursor:o}=n.state.selection;o&&o.pos>0&&n.dispatch(n.state.tr.delete(o.pos-1,o.pos).scrollIntoView())},50)}};for(let n in Se)Re[n]=Se[n];function Yn(n,e){if(n==e)return!0;for(let t in n)if(n[t]!==e[t])return!1;for(let t in e)if(!(t in n))return!1;return!0}class Lr{constructor(e,t){this.toDOM=e,this.spec=t||Wt,this.side=this.spec.side||0}map(e,t,r,o){let{pos:s,deleted:i}=e.mapResult(t.from+o,this.side<0?-1:1);return i?null:new qe(s-r,s-r,this)}valid(){return!0}eq(e){return this==e||e instanceof Lr&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Yn(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class St{constructor(e,t){this.attrs=e,this.spec=t||Wt}map(e,t,r,o){let s=e.map(t.from+o,this.spec.inclusiveStart?-1:1)-r,i=e.map(t.to+o,this.spec.inclusiveEnd?1:-1)-r;return s>=i?null:new qe(s,i,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof St&&Yn(this.attrs,e.attrs)&&Yn(this.spec,e.spec)}static is(e){return e.type instanceof St}destroy(){}}class Os{constructor(e,t){this.attrs=e,this.spec=t||Wt}map(e,t,r,o){let s=e.mapResult(t.from+o,1);if(s.deleted)return null;let i=e.mapResult(t.to+o,-1);return i.deleted||i.pos<=s.pos?null:new qe(s.pos-r,i.pos-r,this)}valid(e,t){let{index:r,offset:o}=e.content.findIndex(t.from),s;return o==t.from&&!(s=e.child(r)).isText&&o+s.nodeSize==t.to}eq(e){return this==e||e instanceof Os&&Yn(this.attrs,e.attrs)&&Yn(this.spec,e.spec)}destroy(){}}class qe{constructor(e,t,r){this.from=e,this.to=t,this.type=r}copy(e,t){return new qe(e,t,this.type)}eq(e,t=0){return this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to}map(e,t,r){return this.type.map(e,this,t,r)}static widget(e,t,r){return new qe(e,e,new Lr(t,r))}static inline(e,t,r,o){return new qe(e,t,new St(r,o))}static node(e,t,r,o){return new qe(e,t,new Os(r,o))}get spec(){return this.type.spec}get inline(){return this.type instanceof St}get widget(){return this.type instanceof Lr}}const pn=[],Wt={};class U{constructor(e,t){this.local=e.length?e:pn,this.children=t.length?t:pn}static create(e,t){return t.length?Wr(t,e,0,Wt):he}find(e,t,r){let o=[];return this.findInner(e??0,t??1e9,o,0,r),o}findInner(e,t,r,o,s){for(let i=0;i<this.local.length;i++){let l=this.local[i];l.from<=t&&l.to>=e&&(!s||s(l.spec))&&r.push(l.copy(l.from+o,l.to+o))}for(let i=0;i<this.children.length;i+=3)if(this.children[i]<t&&this.children[i+1]>e){let l=this.children[i]+1;this.children[i+2].findInner(e-l,t-l,r,o+l,s)}}map(e,t,r){return this==he||e.maps.length==0?this:this.mapInner(e,t,0,0,r||Wt)}mapInner(e,t,r,o,s){let i;for(let l=0;l<this.local.length;l++){let a=this.local[l].map(e,r,o);a&&a.type.valid(t,a)?(i||(i=[])).push(a):s.onRemove&&s.onRemove(this.local[l].spec)}return this.children.length?rg(this.children,i||[],e,t,r,o,s):i?new U(i.sort(_t),pn):he}add(e,t){return t.length?this==he?U.create(e,t):this.addInner(e,t,0):this}addInner(e,t,r){let o,s=0;e.forEach((l,a)=>{let c=a+r,u;if(u=Nc(t,l,c)){for(o||(o=this.children.slice());s<o.length&&o[s]<a;)s+=3;o[s]==a?o[s+2]=o[s+2].addInner(l,u,c+1):o.splice(s,0,a,a+l.nodeSize,Wr(u,l,c+1,Wt)),s+=3}});let i=Mc(s?Ec(t):t,-r);for(let l=0;l<i.length;l++)i[l].type.valid(e,i[l])||i.splice(l--,1);return new U(i.length?this.local.concat(i).sort(_t):this.local,o||this.children)}remove(e){return e.length==0||this==he?this:this.removeInner(e,0)}removeInner(e,t){let r=this.children,o=this.local;for(let s=0;s<r.length;s+=3){let i,l=r[s]+t,a=r[s+1]+t;for(let u=0,f;u<e.length;u++)(f=e[u])&&f.from>l&&f.to<a&&(e[u]=null,(i||(i=[])).push(f));if(!i)continue;r==this.children&&(r=this.children.slice());let c=r[s+2].removeInner(i,l+1);c!=he?r[s+2]=c:(r.splice(s,3),s-=3)}if(o.length){for(let s=0,i;s<e.length;s++)if(i=e[s])for(let l=0;l<o.length;l++)o[l].eq(i,t)&&(o==this.local&&(o=this.local.slice()),o.splice(l--,1))}return r==this.children&&o==this.local?this:o.length||r.length?new U(o,r):he}forChild(e,t){if(this==he)return this;if(t.isLeaf)return U.empty;let r,o;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=e){this.children[l]==e&&(r=this.children[l+2]);break}let s=e+1,i=s+t.content.size;for(let l=0;l<this.local.length;l++){let a=this.local[l];if(a.from<i&&a.to>s&&a.type instanceof St){let c=Math.max(s,a.from)-s,u=Math.min(i,a.to)-s;c<u&&(o||(o=[])).push(a.copy(c,u))}}if(o){let l=new U(o.sort(_t),pn);return r?new ng([l,r]):l}return r||he}eq(e){if(this==e)return!0;if(!(e instanceof U)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let t=0;t<this.local.length;t++)if(!this.local[t].eq(e.local[t]))return!1;for(let t=0;t<this.children.length;t+=3)if(this.children[t]!=e.children[t]||this.children[t+1]!=e.children[t+1]||!this.children[t+2].eq(e.children[t+2]))return!1;return!0}locals(e){return Ts(this.localsInner(e))}localsInner(e){if(this==he)return pn;if(e.inlineContent||!this.local.some(St.is))return this.local;let t=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof St||t.push(this.local[r]);return t}forEachSet(e){e(this)}}U.empty=new U([],[]),U.removeOverlap=Ts;const he=U.empty;let ng=class kn{constructor(e){this.members=e}map(e,t){const r=this.members.map(o=>o.map(e,t,Wt));return kn.from(r)}forChild(e,t){if(t.isLeaf)return U.empty;let r=[];for(let o=0;o<this.members.length;o++){let s=this.members[o].forChild(e,t);s!=he&&(s instanceof kn?r=r.concat(s.members):r.push(s))}return kn.from(r)}eq(e){if(!(e instanceof kn)||e.members.length!=this.members.length)return!1;for(let t=0;t<this.members.length;t++)if(!this.members[t].eq(e.members[t]))return!1;return!0}locals(e){let t,r=!0;for(let o=0;o<this.members.length;o++){let s=this.members[o].localsInner(e);if(s.length)if(!t)t=s;else{r&&(t=t.slice(),r=!1);for(let i=0;i<s.length;i++)t.push(s[i])}}return t?Ts(r?t:t.sort(_t)):pn}static from(e){switch(e.length){case 0:return he;case 1:return e[0];default:return new kn(e.every(t=>t instanceof U)?e:e.reduce((t,r)=>t.concat(r instanceof U?r:r.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}};function rg(n,e,t,r,o,s,i){let l=n.slice();for(let c=0,u=s;c<t.maps.length;c++){let f=0;t.maps[c].forEach((d,p,h,b)=>{let g=b-h-(p-d);for(let k=0;k<l.length;k+=3){let w=l[k+1];if(w<0||d>w+u-f)continue;let M=l[k]+u-f;p>=M?l[k+1]=d<=M?-2:-1:d>=u&&g&&(l[k]+=g,l[k+1]+=g)}f+=g}),u=t.maps[c].map(u,-1)}let a=!1;for(let c=0;c<l.length;c+=3)if(l[c+1]<0){if(l[c+1]==-2){a=!0,l[c+1]=-1;continue}let u=t.map(n[c]+s),f=u-o;if(f<0||f>=r.content.size){a=!0;continue}let d=t.map(n[c+1]+s,-1),p=d-o,{index:h,offset:b}=r.content.findIndex(f),g=r.maybeChild(h);if(g&&b==f&&b+g.nodeSize==p){let k=l[c+2].mapInner(t,g,u+1,n[c]+s+1,i);k!=he?(l[c]=f,l[c+1]=p,l[c+2]=k):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=og(l,n,e,t,o,s,i),u=Wr(c,r,0,i);e=u.local;for(let f=0;f<l.length;f+=3)l[f+1]<0&&(l.splice(f,3),f-=3);for(let f=0,d=0;f<u.children.length;f+=3){let p=u.children[f];for(;d<l.length&&l[d]<p;)d+=3;l.splice(d,0,u.children[f],u.children[f+1],u.children[f+2])}}return new U(e.sort(_t),l)}function Mc(n,e){if(!e||!n.length)return n;let t=[];for(let r=0;r<n.length;r++){let o=n[r];t.push(new qe(o.from+e,o.to+e,o.type))}return t}function og(n,e,t,r,o,s,i){function l(a,c){for(let u=0;u<a.local.length;u++){let f=a.local[u].map(r,o,c);f?t.push(f):i.onRemove&&i.onRemove(a.local[u].spec)}for(let u=0;u<a.children.length;u+=3)l(a.children[u+2],a.children[u]+c+1)}for(let a=0;a<n.length;a+=3)n[a+1]==-1&&l(n[a+2],e[a]+s+1);return t}function Nc(n,e,t){if(e.isLeaf)return null;let r=t+e.nodeSize,o=null;for(let s=0,i;s<n.length;s++)(i=n[s])&&i.from>t&&i.to<r&&((o||(o=[])).push(i),n[s]=null);return o}function Ec(n){let e=[];for(let t=0;t<n.length;t++)n[t]!=null&&e.push(n[t]);return e}function Wr(n,e,t,r){let o=[],s=!1;e.forEach((l,a)=>{let c=Nc(n,l,a+t);if(c){s=!0;let u=Wr(c,l,t+a+1,r);u!=he&&o.push(a,a+l.nodeSize,u)}});let i=Mc(s?Ec(n):n,-t).sort(_t);for(let l=0;l<i.length;l++)i[l].type.valid(e,i[l])||(r.onRemove&&r.onRemove(i[l].spec),i.splice(l--,1));return i.length||o.length?new U(i,o):he}function _t(n,e){return n.from-e.from||n.to-e.to}function Ts(n){let e=n;for(let t=0;t<e.length-1;t++){let r=e[t];if(r.from!=r.to)for(let o=t+1;o<e.length;o++){let s=e[o];if(s.from==r.from){s.to!=r.to&&(e==n&&(e=n.slice()),e[o]=s.copy(s.from,r.to),Dc(e,o+1,s.copy(r.to,s.to)));continue}else{s.from<r.to&&(e==n&&(e=n.slice()),e[t]=r.copy(r.from,s.from),Dc(e,o,r.copy(s.from,r.to)));break}}}return e}function Dc(n,e,t){for(;e<n.length&&_t(t,n[e])>0;)e++;n.splice(e,0,t)}var vs,As;if(typeof WeakMap<"u"){let n=new WeakMap;vs=e=>n.get(e),As=(e,t)=>(n.set(e,t),t)}else{const n=[];let t=0;vs=r=>{for(let o=0;o<n.length;o+=2)if(n[o]==r)return n[o+1]},As=(r,o)=>(t==10&&(t=0),n[t++]=r,n[t++]=o)}var Q=class{constructor(n,e,t,r){this.width=n,this.height=e,this.map=t,this.problems=r}findCell(n){for(let e=0;e<this.map.length;e++){const t=this.map[e];if(t!=n)continue;const r=e%this.width,o=e/this.width|0;let s=r+1,i=o+1;for(let l=1;s<this.width&&this.map[e+l]==t;l++)s++;for(let l=1;i<this.height&&this.map[e+this.width*l]==t;l++)i++;return{left:r,top:o,right:s,bottom:i}}throw new RangeError(`No cell with offset ${n} found`)}colCount(n){for(let e=0;e<this.map.length;e++)if(this.map[e]==n)return e%this.width;throw new RangeError(`No cell with offset ${n} found`)}nextCell(n,e,t){const{left:r,right:o,top:s,bottom:i}=this.findCell(n);return e=="horiz"?(t<0?r==0:o==this.width)?null:this.map[s*this.width+(t<0?r-1:o)]:(t<0?s==0:i==this.height)?null:this.map[r+this.width*(t<0?s-1:i)]}rectBetween(n,e){const{left:t,right:r,top:o,bottom:s}=this.findCell(n),{left:i,right:l,top:a,bottom:c}=this.findCell(e);return{left:Math.min(t,i),top:Math.min(o,a),right:Math.max(r,l),bottom:Math.max(s,c)}}cellsInRect(n){const e=[],t={};for(let r=n.top;r<n.bottom;r++)for(let o=n.left;o<n.right;o++){const s=r*this.width+o,i=this.map[s];t[i]||(t[i]=!0,!(o==n.left&&o&&this.map[s-1]==i||r==n.top&&r&&this.map[s-this.width]==i)&&e.push(i))}return e}positionAt(n,e,t){for(let r=0,o=0;;r++){const s=o+t.child(r).nodeSize;if(r==n){let i=e+n*this.width;const l=(n+1)*this.width;for(;i<l&&this.map[i]<o;)i++;return i==l?s-1:this.map[i]}o=s}}static get(n){return vs(n)||As(n,sg(n))}};function sg(n){if(n.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+n.type.name);const e=ig(n),t=n.childCount,r=[];let o=0,s=null;const i=[];for(let c=0,u=e*t;c<u;c++)r[c]=0;for(let c=0,u=0;c<t;c++){const f=n.child(c);u++;for(let h=0;;h++){for(;o<r.length&&r[o]!=0;)o++;if(h==f.childCount)break;const b=f.child(h),{colspan:g,rowspan:k,colwidth:w}=b.attrs;for(let M=0;M<k;M++){if(M+c>=t){(s||(s=[])).push({type:"overlong_rowspan",pos:u,n:k-M});break}const O=o+M*e;for(let I=0;I<g;I++){r[O+I]==0?r[O+I]=u:(s||(s=[])).push({type:"collision",row:c,pos:u,n:g-I});const C=w&&w[I];if(C){const V=(O+I)%e*2,z=i[V];z==null||z!=C&&i[V+1]==1?(i[V]=C,i[V+1]=1):z==C&&i[V+1]++}}}o+=g,u+=b.nodeSize}const d=(c+1)*e;let p=0;for(;o<d;)r[o++]==0&&p++;p&&(s||(s=[])).push({type:"missing",row:c,n:p}),u++}(e===0||t===0)&&(s||(s=[])).push({type:"zero_sized"});const l=new Q(e,t,r,s);let a=!1;for(let c=0;!a&&c<i.length;c+=2)i[c]!=null&&i[c+1]<t&&(a=!0);return a&&lg(l,i,n),l}function ig(n){let e=-1,t=!1;for(let r=0;r<n.childCount;r++){const o=n.child(r);let s=0;if(t)for(let i=0;i<r;i++){const l=n.child(i);for(let a=0;a<l.childCount;a++){const c=l.child(a);i+c.attrs.rowspan>r&&(s+=c.attrs.colspan)}}for(let i=0;i<o.childCount;i++){const l=o.child(i);s+=l.attrs.colspan,l.attrs.rowspan>1&&(t=!0)}e==-1?e=s:e!=s&&(e=Math.max(e,s))}return e}function lg(n,e,t){n.problems||(n.problems=[]);const r={};for(let o=0;o<n.map.length;o++){const s=n.map[o];if(r[s])continue;r[s]=!0;const i=t.nodeAt(s);if(!i)throw new RangeError(`No cell with offset ${s} found`);let l=null;const a=i.attrs;for(let c=0;c<a.colspan;c++){const u=(o+c)%n.width,f=e[u*2];f!=null&&(!a.colwidth||a.colwidth[c]!=f)&&((l||(l=ag(a)))[c]=f)}l&&n.problems.unshift({type:"colwidth mismatch",pos:s,colwidth:l})}}function ag(n){if(n.colwidth)return n.colwidth.slice();const e=[];for(let t=0;t<n.colspan;t++)e.push(0);return e}function Oc(n,e){if(typeof n=="string")return{};const t=n.getAttribute("data-colwidth"),r=t&&/^\d+(,\d+)*$/.test(t)?t.split(",").map(i=>Number(i)):null,o=Number(n.getAttribute("colspan")||1),s={colspan:o,rowspan:Number(n.getAttribute("rowspan")||1),colwidth:r&&r.length==o?r:null};for(const i in e){const l=e[i].getFromDOM,a=l&&l(n);a!=null&&(s[i]=a)}return s}function Tc(n,e){const t={};n.attrs.colspan!=1&&(t.colspan=n.attrs.colspan),n.attrs.rowspan!=1&&(t.rowspan=n.attrs.rowspan),n.attrs.colwidth&&(t["data-colwidth"]=n.attrs.colwidth.join(","));for(const r in e){const o=e[r].setDOMAttr;o&&o(n.attrs[r],t)}return t}function cg(n){if(n!==null){if(!Array.isArray(n))throw new TypeError("colwidth must be null or an array");for(const e of n)if(typeof e!="number")throw new TypeError("colwidth must be null or an array of numbers")}}function ug(n){const e=n.cellAttributes||{},t={colspan:{default:1,validate:"number"},rowspan:{default:1,validate:"number"},colwidth:{default:null,validate:cg}};for(const r in e)t[r]={default:e[r].default,validate:e[r].validate};return{table:{content:"table_row+",tableRole:"table",isolating:!0,group:n.tableGroup,parseDOM:[{tag:"table"}],toDOM(){return["table",["tbody",0]]}},table_row:{content:"(table_cell | table_header)*",tableRole:"row",parseDOM:[{tag:"tr"}],toDOM(){return["tr",0]}},table_cell:{content:n.cellContent,attrs:t,tableRole:"cell",isolating:!0,parseDOM:[{tag:"td",getAttrs:r=>Oc(r,e)}],toDOM(r){return["td",Tc(r,e),0]}},table_header:{content:n.cellContent,attrs:t,tableRole:"header_cell",isolating:!0,parseDOM:[{tag:"th",getAttrs:r=>Oc(r,e)}],toDOM(r){return["th",Tc(r,e),0]}}}}function pe(n){let e=n.cached.tableNodeTypes;if(!e){e=n.cached.tableNodeTypes={};for(const t in n.nodes){const r=n.nodes[t],o=r.spec.tableRole;o&&(e[o]=r)}}return e}var Ct=new lt("selectingCells");function Gn(n){for(let e=n.depth-1;e>0;e--)if(n.node(e).type.spec.tableRole=="row")return n.node(0).resolve(n.before(e+1));return null}function fg(n){for(let e=n.depth;e>0;e--){const t=n.node(e).type.spec.tableRole;if(t==="cell"||t==="header_cell")return n.node(e)}return null}function Oe(n){const e=n.selection.$head;for(let t=e.depth;t>0;t--)if(e.node(t).type.spec.tableRole=="row")return!0;return!1}function _r(n){const e=n.selection;if("$anchorCell"in e&&e.$anchorCell)return e.$anchorCell.pos>e.$headCell.pos?e.$anchorCell:e.$headCell;if("node"in e&&e.node&&e.node.type.spec.tableRole=="cell")return e.$anchor;const t=Gn(e.$head)||dg(e.$head);if(t)return t;throw new RangeError(`No cell found around position ${e.head}`)}function dg(n){for(let e=n.nodeAfter,t=n.pos;e;e=e.firstChild,t++){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return n.doc.resolve(t)}for(let e=n.nodeBefore,t=n.pos;e;e=e.lastChild,t--){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return n.doc.resolve(t-e.nodeSize)}}function vc(n){return n.parent.type.spec.tableRole=="row"&&!!n.nodeAfter}function hg(n){return n.node(0).resolve(n.pos+n.nodeAfter.nodeSize)}function Ps(n,e){return n.depth==e.depth&&n.pos>=e.start(-1)&&n.pos<=e.end(-1)}function Ac(n,e,t){const r=n.node(-1),o=Q.get(r),s=n.start(-1),i=o.nextCell(n.pos-s,e,t);return i==null?null:n.node(0).resolve(s+i)}function qt(n,e,t=1){const r={...n,colspan:n.colspan-t};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(e,t),r.colwidth.some(o=>o>0)||(r.colwidth=null)),r}function Pc(n,e,t=1){const r={...n,colspan:n.colspan+t};if(r.colwidth){r.colwidth=r.colwidth.slice();for(let o=0;o<t;o++)r.colwidth.splice(e,0,0)}return r}function pg(n,e,t){const r=pe(e.type.schema).header_cell;for(let o=0;o<n.height;o++)if(e.nodeAt(n.map[t+o*n.width]).type!=r)return!1;return!0}var W=class ot extends R{constructor(e,t=e){const r=e.node(-1),o=Q.get(r),s=e.start(-1),i=o.rectBetween(e.pos-s,t.pos-s),l=e.node(0),a=o.cellsInRect(i).filter(u=>u!=t.pos-s);a.unshift(t.pos-s);const c=a.map(u=>{const f=r.nodeAt(u);if(!f)throw RangeError(`No cell with offset ${u} found`);const d=s+u+1;return new tl(l.resolve(d),l.resolve(d+f.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=e,this.$headCell=t}map(e,t){const r=e.resolve(t.map(this.$anchorCell.pos)),o=e.resolve(t.map(this.$headCell.pos));if(vc(r)&&vc(o)&&Ps(r,o)){const s=this.$anchorCell.node(-1)!=r.node(-1);return s&&this.isRowSelection()?ot.rowSelection(r,o):s&&this.isColSelection()?ot.colSelection(r,o):new ot(r,o)}return P.between(r,o)}content(){const e=this.$anchorCell.node(-1),t=Q.get(e),r=this.$anchorCell.start(-1),o=t.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),s={},i=[];for(let a=o.top;a<o.bottom;a++){const c=[];for(let u=a*t.width+o.left,f=o.left;f<o.right;f++,u++){const d=t.map[u];if(s[d])continue;s[d]=!0;const p=t.findCell(d);let h=e.nodeAt(d);if(!h)throw RangeError(`No cell with offset ${d} found`);const b=o.left-p.left,g=p.right-o.right;if(b>0||g>0){let k=h.attrs;if(b>0&&(k=qt(k,0,b)),g>0&&(k=qt(k,k.colspan-g,g)),p.left<o.left){if(h=h.type.createAndFill(k),!h)throw RangeError(`Could not create cell with attrs ${JSON.stringify(k)}`)}else h=h.type.create(k,h.content)}if(p.top<o.top||p.bottom>o.bottom){const k={...h.attrs,rowspan:Math.min(p.bottom,o.bottom)-Math.max(p.top,o.top)};p.top<o.top?h=h.type.createAndFill(k):h=h.type.create(k,h.content)}c.push(h)}i.push(e.child(a).copy(S.from(c)))}const l=this.isColSelection()&&this.isRowSelection()?e:i;return new N(S.from(l),1,1)}replace(e,t=N.empty){const r=e.steps.length,o=this.ranges;for(let i=0;i<o.length;i++){const{$from:l,$to:a}=o[i],c=e.mapping.slice(r);e.replace(c.map(l.pos),c.map(a.pos),i?N.empty:t)}const s=R.findFrom(e.doc.resolve(e.mapping.slice(r).map(this.to)),-1);s&&e.setSelection(s)}replaceWith(e,t){this.replace(e,new N(S.from(t),0,0))}forEachCell(e){const t=this.$anchorCell.node(-1),r=Q.get(t),o=this.$anchorCell.start(-1),s=r.cellsInRect(r.rectBetween(this.$anchorCell.pos-o,this.$headCell.pos-o));for(let i=0;i<s.length;i++)e(t.nodeAt(s[i]),o+s[i])}isColSelection(){const e=this.$anchorCell.index(-1),t=this.$headCell.index(-1);if(Math.min(e,t)>0)return!1;const r=e+this.$anchorCell.nodeAfter.attrs.rowspan,o=t+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(r,o)==this.$headCell.node(-1).childCount}static colSelection(e,t=e){const r=e.node(-1),o=Q.get(r),s=e.start(-1),i=o.findCell(e.pos-s),l=o.findCell(t.pos-s),a=e.node(0);return i.top<=l.top?(i.top>0&&(e=a.resolve(s+o.map[i.left])),l.bottom<o.height&&(t=a.resolve(s+o.map[o.width*(o.height-1)+l.right-1]))):(l.top>0&&(t=a.resolve(s+o.map[l.left])),i.bottom<o.height&&(e=a.resolve(s+o.map[o.width*(o.height-1)+i.right-1]))),new ot(e,t)}isRowSelection(){const e=this.$anchorCell.node(-1),t=Q.get(e),r=this.$anchorCell.start(-1),o=t.colCount(this.$anchorCell.pos-r),s=t.colCount(this.$headCell.pos-r);if(Math.min(o,s)>0)return!1;const i=o+this.$anchorCell.nodeAfter.attrs.colspan,l=s+this.$headCell.nodeAfter.attrs.colspan;return Math.max(i,l)==t.width}eq(e){return e instanceof ot&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,t=e){const r=e.node(-1),o=Q.get(r),s=e.start(-1),i=o.findCell(e.pos-s),l=o.findCell(t.pos-s),a=e.node(0);return i.left<=l.left?(i.left>0&&(e=a.resolve(s+o.map[i.top*o.width])),l.right<o.width&&(t=a.resolve(s+o.map[o.width*(l.top+1)-1]))):(l.left>0&&(t=a.resolve(s+o.map[l.top*o.width])),i.right<o.width&&(e=a.resolve(s+o.map[o.width*(i.top+1)-1]))),new ot(e,t)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,t){return new ot(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,r=t){return new ot(e.resolve(t),e.resolve(r))}getBookmark(){return new mg(this.$anchorCell.pos,this.$headCell.pos)}};W.prototype.visible=!1,R.jsonID("cell",W);var mg=class mf{constructor(e,t){this.anchor=e,this.head=t}map(e){return new mf(e.map(this.anchor),e.map(this.head))}resolve(e){const t=e.resolve(this.anchor),r=e.resolve(this.head);return t.parent.type.spec.tableRole=="row"&&r.parent.type.spec.tableRole=="row"&&t.index()<t.parent.childCount&&r.index()<r.parent.childCount&&Ps(t,r)?new W(t,r):R.near(r,1)}};function gg(n){if(!(n.selection instanceof W))return null;const e=[];return n.selection.forEachCell((t,r)=>{e.push(qe.node(r,r+t.nodeSize,{class:"selectedCell"}))}),U.create(n.doc,e)}function yg({$from:n,$to:e}){if(n.pos==e.pos||n.pos<e.pos-6)return!1;let t=n.pos,r=e.pos,o=n.depth;for(;o>=0&&!(n.after(o+1)<n.end(o));o--,t++);for(let s=e.depth;s>=0&&!(e.before(s+1)>e.start(s));s--,r--);return t==r&&/row|table/.test(n.node(o).type.spec.tableRole)}function bg({$from:n,$to:e}){let t,r;for(let o=n.depth;o>0;o--){const s=n.node(o);if(s.type.spec.tableRole==="cell"||s.type.spec.tableRole==="header_cell"){t=s;break}}for(let o=e.depth;o>0;o--){const s=e.node(o);if(s.type.spec.tableRole==="cell"||s.type.spec.tableRole==="header_cell"){r=s;break}}return t!==r&&e.parentOffset===0}function xg(n,e,t){const r=(e||n).selection,o=(e||n).doc;let s,i;if(r instanceof D&&(i=r.node.type.spec.tableRole)){if(i=="cell"||i=="header_cell")s=W.create(o,r.from);else if(i=="row"){const l=o.resolve(r.from+1);s=W.rowSelection(l,l)}else if(!t){const l=Q.get(r.node),a=r.from+1,c=a+l.map[l.width*l.height-1];s=W.create(o,a+1,c)}}else r instanceof P&&yg(r)?s=P.create(o,r.from):r instanceof P&&bg(r)&&(s=P.create(o,r.$from.start(),r.$from.end()));return s&&(e||(e=n.tr)).setSelection(s),e}var kg=new lt("fix-tables");function Ic(n,e,t,r){const o=n.childCount,s=e.childCount;e:for(let i=0,l=0;i<s;i++){const a=e.child(i);for(let c=l,u=Math.min(o,i+3);c<u;c++)if(n.child(c)==a){l=c+1,t+=a.nodeSize;continue e}r(a,t),l<o&&n.child(l).sameMarkup(a)?Ic(n.child(l),a,t+1,r):a.nodesBetween(0,a.content.size,r,t+1),t+=a.nodeSize}}function Is(n,e){let t;const r=(o,s)=>{o.type.spec.tableRole=="table"&&(t=Sg(n,o,s,t))};return e?e.doc!=n.doc&&Ic(e.doc,n.doc,0,r):n.doc.descendants(r),t}function Sg(n,e,t,r){const o=Q.get(e);if(!o.problems)return r;r||(r=n.tr);const s=[];for(let a=0;a<o.height;a++)s.push(0);for(let a=0;a<o.problems.length;a++){const c=o.problems[a];if(c.type=="collision"){const u=e.nodeAt(c.pos);if(!u)continue;const f=u.attrs;for(let d=0;d<f.rowspan;d++)s[c.row+d]+=c.n;r.setNodeMarkup(r.mapping.map(t+1+c.pos),null,qt(f,f.colspan-c.n,c.n))}else if(c.type=="missing")s[c.row]+=c.n;else if(c.type=="overlong_rowspan"){const u=e.nodeAt(c.pos);if(!u)continue;r.setNodeMarkup(r.mapping.map(t+1+c.pos),null,{...u.attrs,rowspan:u.attrs.rowspan-c.n})}else if(c.type=="colwidth mismatch"){const u=e.nodeAt(c.pos);if(!u)continue;r.setNodeMarkup(r.mapping.map(t+1+c.pos),null,{...u.attrs,colwidth:c.colwidth})}else if(c.type=="zero_sized"){const u=r.mapping.map(t);r.delete(u,u+e.nodeSize)}}let i,l;for(let a=0;a<s.length;a++)s[a]&&(i==null&&(i=a),l=a);for(let a=0,c=t+1;a<o.height;a++){const u=e.child(a),f=c+u.nodeSize,d=s[a];if(d>0){let p="cell";u.firstChild&&(p=u.firstChild.type.spec.tableRole);const h=[];for(let g=0;g<d;g++){const k=pe(n.schema)[p].createAndFill();k&&h.push(k)}const b=(a==0||i==a-1)&&l==a?c+1:f-1;r.insert(r.mapping.map(b),h)}c=f}return r.setMeta(kg,{fixTables:!0})}function He(n){const e=n.selection,t=_r(n),r=t.node(-1),o=t.start(-1),s=Q.get(r);return{...e instanceof W?s.rectBetween(e.$anchorCell.pos-o,e.$headCell.pos-o):s.findCell(t.pos-o),tableStart:o,map:s,table:r}}function Vc(n,{map:e,tableStart:t,table:r},o){let s=o>0?-1:0;pg(e,r,o+s)&&(s=o==0||o==e.width?null:0);for(let i=0;i<e.height;i++){const l=i*e.width+o;if(o>0&&o<e.width&&e.map[l-1]==e.map[l]){const a=e.map[l],c=r.nodeAt(a);n.setNodeMarkup(n.mapping.map(t+a),null,Pc(c.attrs,o-e.colCount(a))),i+=c.attrs.rowspan-1}else{const a=s==null?pe(r.type.schema).cell:r.nodeAt(e.map[l+s]).type,c=e.positionAt(i,o,r);n.insert(n.mapping.map(t+c),a.createAndFill())}}return n}function Cg(n,e){if(!Oe(n))return!1;if(e){const t=He(n);e(Vc(n.tr,t,t.left))}return!0}function wg(n,e){if(!Oe(n))return!1;if(e){const t=He(n);e(Vc(n.tr,t,t.right))}return!0}function Mg(n,{map:e,table:t,tableStart:r},o){const s=n.mapping.maps.length;for(let i=0;i<e.height;){const l=i*e.width+o,a=e.map[l],c=t.nodeAt(a),u=c.attrs;if(o>0&&e.map[l-1]==a||o<e.width-1&&e.map[l+1]==a)n.setNodeMarkup(n.mapping.slice(s).map(r+a),null,qt(u,o-e.colCount(a)));else{const f=n.mapping.slice(s).map(r+a);n.delete(f,f+c.nodeSize)}i+=u.rowspan}}function Ng(n,e){if(!Oe(n))return!1;if(e){const t=He(n),r=n.tr;if(t.left==0&&t.right==t.map.width)return!1;for(let o=t.right-1;Mg(r,t,o),o!=t.left;o--){const s=t.tableStart?r.doc.nodeAt(t.tableStart-1):r.doc;if(!s)throw RangeError("No table found");t.table=s,t.map=Q.get(s)}e(r)}return!0}function Eg(n,e,t){var r;const o=pe(e.type.schema).header_cell;for(let s=0;s<n.width;s++)if(((r=e.nodeAt(n.map[s+t*n.width]))==null?void 0:r.type)!=o)return!1;return!0}function Rc(n,{map:e,tableStart:t,table:r},o){var s;let i=t;for(let c=0;c<o;c++)i+=r.child(c).nodeSize;const l=[];let a=o>0?-1:0;Eg(e,r,o+a)&&(a=o==0||o==e.height?null:0);for(let c=0,u=e.width*o;c<e.width;c++,u++)if(o>0&&o<e.height&&e.map[u]==e.map[u-e.width]){const f=e.map[u],d=r.nodeAt(f).attrs;n.setNodeMarkup(t+f,null,{...d,rowspan:d.rowspan+1}),c+=d.colspan-1}else{const f=a==null?pe(r.type.schema).cell:(s=r.nodeAt(e.map[u+a*e.width]))==null?void 0:s.type,d=f==null?void 0:f.createAndFill();d&&l.push(d)}return n.insert(i,pe(r.type.schema).row.create(null,l)),n}function Dg(n,e){if(!Oe(n))return!1;if(e){const t=He(n);e(Rc(n.tr,t,t.top))}return!0}function Og(n,e){if(!Oe(n))return!1;if(e){const t=He(n);e(Rc(n.tr,t,t.bottom))}return!0}function Tg(n,{map:e,table:t,tableStart:r},o){let s=0;for(let c=0;c<o;c++)s+=t.child(c).nodeSize;const i=s+t.child(o).nodeSize,l=n.mapping.maps.length;n.delete(s+r,i+r);const a=new Set;for(let c=0,u=o*e.width;c<e.width;c++,u++){const f=e.map[u];if(!a.has(f)){if(a.add(f),o>0&&f==e.map[u-e.width]){const d=t.nodeAt(f).attrs;n.setNodeMarkup(n.mapping.slice(l).map(f+r),null,{...d,rowspan:d.rowspan-1}),c+=d.colspan-1}else if(o<e.height&&f==e.map[u+e.width]){const d=t.nodeAt(f),p=d.attrs,h=d.type.create({...p,rowspan:d.attrs.rowspan-1},d.content),b=e.positionAt(o+1,c,t);n.insert(n.mapping.slice(l).map(r+b),h),c+=p.colspan-1}}}}function vg(n,e){if(!Oe(n))return!1;if(e){const t=He(n),r=n.tr;if(t.top==0&&t.bottom==t.map.height)return!1;for(let o=t.bottom-1;Tg(r,t,o),o!=t.top;o--){const s=t.tableStart?r.doc.nodeAt(t.tableStart-1):r.doc;if(!s)throw RangeError("No table found");t.table=s,t.map=Q.get(t.table)}e(r)}return!0}function zc(n){const e=n.content;return e.childCount==1&&e.child(0).isTextblock&&e.child(0).childCount==0}function Ag({width:n,height:e,map:t},r){let o=r.top*n+r.left,s=o,i=(r.bottom-1)*n+r.left,l=o+(r.right-r.left-1);for(let a=r.top;a<r.bottom;a++){if(r.left>0&&t[s]==t[s-1]||r.right<n&&t[l]==t[l+1])return!0;s+=n,l+=n}for(let a=r.left;a<r.right;a++){if(r.top>0&&t[o]==t[o-n]||r.bottom<e&&t[i]==t[i+n])return!0;o++,i++}return!1}function Pg(n,e){const t=n.selection;if(!(t instanceof W)||t.$anchorCell.pos==t.$headCell.pos)return!1;const r=He(n),{map:o}=r;if(Ag(o,r))return!1;if(e){const s=n.tr,i={};let l=S.empty,a,c;for(let u=r.top;u<r.bottom;u++)for(let f=r.left;f<r.right;f++){const d=o.map[u*o.width+f],p=r.table.nodeAt(d);if(!(i[d]||!p))if(i[d]=!0,a==null)a=d,c=p;else{zc(p)||(l=l.append(p.content));const h=s.mapping.map(d+r.tableStart);s.delete(h,h+p.nodeSize)}}if(a==null||c==null)return!0;if(s.setNodeMarkup(a+r.tableStart,null,{...Pc(c.attrs,c.attrs.colspan,r.right-r.left-c.attrs.colspan),rowspan:r.bottom-r.top}),l.size){const u=a+1+c.content.size,f=zc(c)?a+1:u;s.replaceWith(f+r.tableStart,u+r.tableStart,l)}s.setSelection(new W(s.doc.resolve(a+r.tableStart))),e(s)}return!0}function Ig(n,e){const t=pe(n.schema);return Vg(({node:r})=>t[r.type.spec.tableRole])(n,e)}function Vg(n){return(e,t)=>{var r;const o=e.selection;let s,i;if(o instanceof W){if(o.$anchorCell.pos!=o.$headCell.pos)return!1;s=o.$anchorCell.nodeAfter,i=o.$anchorCell.pos}else{if(s=fg(o.$from),!s)return!1;i=(r=Gn(o.$from))==null?void 0:r.pos}if(s==null||i==null||s.attrs.colspan==1&&s.attrs.rowspan==1)return!1;if(t){let l=s.attrs;const a=[],c=l.colwidth;l.rowspan>1&&(l={...l,rowspan:1}),l.colspan>1&&(l={...l,colspan:1});const u=He(e),f=e.tr;for(let p=0;p<u.right-u.left;p++)a.push(c?{...l,colwidth:c&&c[p]?[c[p]]:null}:l);let d;for(let p=u.top;p<u.bottom;p++){let h=u.map.positionAt(p,u.left,u.table);p==u.top&&(h+=s.nodeSize);for(let b=u.left,g=0;b<u.right;b++,g++)b==u.left&&p==u.top||f.insert(d=f.mapping.map(h+u.tableStart,1),n({node:s,row:p,col:b}).createAndFill(a[g]))}f.setNodeMarkup(i,n({node:s,row:u.top,col:u.left}),a[0]),o instanceof W&&f.setSelection(new W(f.doc.resolve(o.$anchorCell.pos),d?f.doc.resolve(d):void 0)),t(f)}return!0}}function mn(n,e){return function(t,r){if(!Oe(t))return!1;const o=_r(t);if(o.nodeAfter.attrs[n]===e)return!1;if(r){const s=t.tr;t.selection instanceof W?t.selection.forEachCell((i,l)=>{i.attrs[n]!==e&&s.setNodeMarkup(l,null,{...i.attrs,[n]:e})}):s.setNodeMarkup(o.pos,null,{...o.nodeAfter.attrs,[n]:e}),r(s)}return!0}}function Rg(n){return function(e,t){if(!Oe(e))return!1;if(t){const r=pe(e.schema),o=He(e),s=e.tr,i=o.map.cellsInRect(n=="column"?{left:o.left,top:0,right:o.right,bottom:o.map.height}:n=="row"?{left:0,top:o.top,right:o.map.width,bottom:o.bottom}:o),l=i.map(a=>o.table.nodeAt(a));for(let a=0;a<i.length;a++)l[a].type==r.header_cell&&s.setNodeMarkup(o.tableStart+i[a],r.cell,l[a].attrs);if(s.steps.length==0)for(let a=0;a<i.length;a++)s.setNodeMarkup(o.tableStart+i[a],r.header_cell,l[a].attrs);t(s)}return!0}}function $c(n,e,t){const r=e.map.cellsInRect({left:0,top:0,right:n=="row"?e.map.width:1,bottom:n=="column"?e.map.height:1});for(let o=0;o<r.length;o++){const s=e.table.nodeAt(r[o]);if(s&&s.type!==t.header_cell)return!1}return!0}function Vs(n,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?Rg(n):function(t,r){if(!Oe(t))return!1;if(r){const o=pe(t.schema),s=He(t),i=t.tr,l=$c("row",s,o),a=$c("column",s,o),u=(n==="column"?l:n==="row"?a:!1)?1:0,f=n=="column"?{left:0,top:u,right:1,bottom:s.map.height}:n=="row"?{left:u,top:0,right:s.map.width,bottom:1}:s,d=n=="column"?a?o.cell:o.header_cell:n=="row"?l?o.cell:o.header_cell:o.cell;s.map.cellsInRect(f).forEach(p=>{const h=p+s.tableStart,b=i.doc.nodeAt(h);b&&i.setNodeMarkup(h,d,b.attrs)}),r(i)}return!0}}var zg=Vs("row",{useDeprecatedLogic:!0}),$g=Vs("column",{useDeprecatedLogic:!0}),jg=Vs("cell",{useDeprecatedLogic:!0});function Bg(n,e){if(e<0){const t=n.nodeBefore;if(t)return n.pos-t.nodeSize;for(let r=n.index(-1)-1,o=n.before();r>=0;r--){const s=n.node(-1).child(r),i=s.lastChild;if(i)return o-1-i.nodeSize;o-=s.nodeSize}}else{if(n.index()<n.parent.childCount-1)return n.pos+n.nodeAfter.nodeSize;const t=n.node(-1);for(let r=n.indexAfter(-1),o=n.after();r<t.childCount;r++){const s=t.child(r);if(s.childCount)return o+1;o+=s.nodeSize}}return null}function jc(n){return function(e,t){if(!Oe(e))return!1;const r=Bg(_r(e),n);if(r==null)return!1;if(t){const o=e.doc.resolve(r);t(e.tr.setSelection(P.between(o,hg(o))).scrollIntoView())}return!0}}function Fg(n,e){const t=n.selection.$anchor;for(let r=t.depth;r>0;r--)if(t.node(r).type.spec.tableRole=="table")return e&&e(n.tr.delete(t.before(r),t.after(r)).scrollIntoView()),!0;return!1}function qr(n,e){const t=n.selection;if(!(t instanceof W))return!1;if(e){const r=n.tr,o=pe(n.schema).cell.createAndFill().content;t.forEachCell((s,i)=>{s.content.eq(o)||r.replace(r.mapping.map(i+1),r.mapping.map(i+s.nodeSize-1),new N(o,0,0))}),r.docChanged&&e(r)}return!0}function Lg(n){if(!n.size)return null;let{content:e,openStart:t,openEnd:r}=n;for(;e.childCount==1&&(t>0&&r>0||e.child(0).type.spec.tableRole=="table");)t--,r--,e=e.child(0).content;const o=e.child(0),s=o.type.spec.tableRole,i=o.type.schema,l=[];if(s=="row")for(let a=0;a<e.childCount;a++){let c=e.child(a).content;const u=a?0:Math.max(0,t-1),f=a<e.childCount-1?0:Math.max(0,r-1);(u||f)&&(c=Rs(pe(i).row,new N(c,u,f)).content),l.push(c)}else if(s=="cell"||s=="header_cell")l.push(t||r?Rs(pe(i).row,new N(e,t,r)).content:e);else return null;return Wg(i,l)}function Wg(n,e){const t=[];for(let o=0;o<e.length;o++){const s=e[o];for(let i=s.childCount-1;i>=0;i--){const{rowspan:l,colspan:a}=s.child(i).attrs;for(let c=o;c<o+l;c++)t[c]=(t[c]||0)+a}}let r=0;for(let o=0;o<t.length;o++)r=Math.max(r,t[o]);for(let o=0;o<t.length;o++)if(o>=e.length&&e.push(S.empty),t[o]<r){const s=pe(n).cell.createAndFill(),i=[];for(let l=t[o];l<r;l++)i.push(s);e[o]=e[o].append(S.from(i))}return{height:e.length,width:r,rows:e}}function Rs(n,e){const t=n.createAndFill();return new el(t).replace(0,t.content.size,e).doc}function _g({width:n,height:e,rows:t},r,o){if(n!=r){const s=[],i=[];for(let l=0;l<t.length;l++){const a=t[l],c=[];for(let u=s[l]||0,f=0;u<r;f++){let d=a.child(f%a.childCount);u+d.attrs.colspan>r&&(d=d.type.createChecked(qt(d.attrs,d.attrs.colspan,u+d.attrs.colspan-r),d.content)),c.push(d),u+=d.attrs.colspan;for(let p=1;p<d.attrs.rowspan;p++)s[l+p]=(s[l+p]||0)+d.attrs.colspan}i.push(S.from(c))}t=i,n=r}if(e!=o){const s=[];for(let i=0,l=0;i<o;i++,l++){const a=[],c=t[l%e];for(let u=0;u<c.childCount;u++){let f=c.child(u);i+f.attrs.rowspan>o&&(f=f.type.create({...f.attrs,rowspan:Math.max(1,o-f.attrs.rowspan)},f.content)),a.push(f)}s.push(S.from(a))}t=s,e=o}return{width:n,height:e,rows:t}}function qg(n,e,t,r,o,s,i){const l=n.doc.type.schema,a=pe(l);let c,u;if(o>e.width)for(let f=0,d=0;f<e.height;f++){const p=t.child(f);d+=p.nodeSize;const h=[];let b;p.lastChild==null||p.lastChild.type==a.cell?b=c||(c=a.cell.createAndFill()):b=u||(u=a.header_cell.createAndFill());for(let g=e.width;g<o;g++)h.push(b);n.insert(n.mapping.slice(i).map(d-1+r),h)}if(s>e.height){const f=[];for(let h=0,b=(e.height-1)*e.width;h<Math.max(e.width,o);h++){const g=h>=e.width?!1:t.nodeAt(e.map[b+h]).type==a.header_cell;f.push(g?u||(u=a.header_cell.createAndFill()):c||(c=a.cell.createAndFill()))}const d=a.row.create(null,S.from(f)),p=[];for(let h=e.height;h<s;h++)p.push(d);n.insert(n.mapping.slice(i).map(r+t.nodeSize-2),p)}return!!(c||u)}function Bc(n,e,t,r,o,s,i,l){if(i==0||i==e.height)return!1;let a=!1;for(let c=o;c<s;c++){const u=i*e.width+c,f=e.map[u];if(e.map[u-e.width]==f){a=!0;const d=t.nodeAt(f),{top:p,left:h}=e.findCell(f);n.setNodeMarkup(n.mapping.slice(l).map(f+r),null,{...d.attrs,rowspan:i-p}),n.insert(n.mapping.slice(l).map(e.positionAt(i,h,t)),d.type.createAndFill({...d.attrs,rowspan:p+d.attrs.rowspan-i})),c+=d.attrs.colspan-1}}return a}function Fc(n,e,t,r,o,s,i,l){if(i==0||i==e.width)return!1;let a=!1;for(let c=o;c<s;c++){const u=c*e.width+i,f=e.map[u];if(e.map[u-1]==f){a=!0;const d=t.nodeAt(f),p=e.colCount(f),h=n.mapping.slice(l).map(f+r);n.setNodeMarkup(h,null,qt(d.attrs,i-p,d.attrs.colspan-(i-p))),n.insert(h+d.nodeSize,d.type.createAndFill(qt(d.attrs,0,i-p))),c+=d.attrs.rowspan-1}}return a}function Lc(n,e,t,r,o){let s=t?n.doc.nodeAt(t-1):n.doc;if(!s)throw new Error("No table found");let i=Q.get(s);const{top:l,left:a}=r,c=a+o.width,u=l+o.height,f=n.tr;let d=0;function p(){if(s=t?f.doc.nodeAt(t-1):f.doc,!s)throw new Error("No table found");i=Q.get(s),d=f.mapping.maps.length}qg(f,i,s,t,c,u,d)&&p(),Bc(f,i,s,t,a,c,l,d)&&p(),Bc(f,i,s,t,a,c,u,d)&&p(),Fc(f,i,s,t,l,u,a,d)&&p(),Fc(f,i,s,t,l,u,c,d)&&p();for(let h=l;h<u;h++){const b=i.positionAt(h,a,s),g=i.positionAt(h,c,s);f.replace(f.mapping.slice(d).map(b+t),f.mapping.slice(d).map(g+t),new N(o.rows[h-l],0,0))}p(),f.setSelection(new W(f.doc.resolve(t+i.positionAt(l,a,s)),f.doc.resolve(t+i.positionAt(u-1,c-1,s)))),e(f)}var Hg=zo({ArrowLeft:Kr("horiz",-1),ArrowRight:Kr("horiz",1),ArrowUp:Kr("vert",-1),ArrowDown:Kr("vert",1),"Shift-ArrowLeft":Jr("horiz",-1),"Shift-ArrowRight":Jr("horiz",1),"Shift-ArrowUp":Jr("vert",-1),"Shift-ArrowDown":Jr("vert",1),Backspace:qr,"Mod-Backspace":qr,Delete:qr,"Mod-Delete":qr});function Hr(n,e,t){return t.eq(n.selection)?!1:(e&&e(n.tr.setSelection(t).scrollIntoView()),!0)}function Kr(n,e){return(t,r,o)=>{if(!o)return!1;const s=t.selection;if(s instanceof W)return Hr(t,r,R.near(s.$headCell,e));if(n!="horiz"&&!s.empty)return!1;const i=Wc(o,n,e);if(i==null)return!1;if(n=="horiz")return Hr(t,r,R.near(t.doc.resolve(s.head+e),e));{const l=t.doc.resolve(i),a=Ac(l,n,e);let c;return a?c=R.near(a,1):e<0?c=R.near(t.doc.resolve(l.before(-1)),-1):c=R.near(t.doc.resolve(l.after(-1)),1),Hr(t,r,c)}}}function Jr(n,e){return(t,r,o)=>{if(!o)return!1;const s=t.selection;let i;if(s instanceof W)i=s;else{const a=Wc(o,n,e);if(a==null)return!1;i=new W(t.doc.resolve(a))}const l=Ac(i.$headCell,n,e);return l?Hr(t,r,new W(i.$anchorCell,l)):!1}}function Kg(n,e){const t=n.state.doc,r=Gn(t.resolve(e));return r?(n.dispatch(n.state.tr.setSelection(new W(r))),!0):!1}function Jg(n,e,t){if(!Oe(n.state))return!1;let r=Lg(t);const o=n.state.selection;if(o instanceof W){r||(r={width:1,height:1,rows:[S.from(Rs(pe(n.state.schema).cell,t))]});const s=o.$anchorCell.node(-1),i=o.$anchorCell.start(-1),l=Q.get(s).rectBetween(o.$anchorCell.pos-i,o.$headCell.pos-i);return r=_g(r,l.right-l.left,l.bottom-l.top),Lc(n.state,n.dispatch,i,l,r),!0}else if(r){const s=_r(n.state),i=s.start(-1);return Lc(n.state,n.dispatch,i,Q.get(s.node(-1)).findCell(s.pos-i),r),!0}else return!1}function Yg(n,e){var t;if(e.ctrlKey||e.metaKey)return;const r=_c(n,e.target);let o;if(e.shiftKey&&n.state.selection instanceof W)s(n.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&r&&(o=Gn(n.state.selection.$anchor))!=null&&((t=zs(n,e))==null?void 0:t.pos)!=o.pos)s(o,e),e.preventDefault();else if(!r)return;function s(a,c){let u=zs(n,c);const f=Ct.getState(n.state)==null;if(!u||!Ps(a,u))if(f)u=a;else return;const d=new W(a,u);if(f||!n.state.selection.eq(d)){const p=n.state.tr.setSelection(d);f&&p.setMeta(Ct,a.pos),n.dispatch(p)}}function i(){n.root.removeEventListener("mouseup",i),n.root.removeEventListener("dragstart",i),n.root.removeEventListener("mousemove",l),Ct.getState(n.state)!=null&&n.dispatch(n.state.tr.setMeta(Ct,-1))}function l(a){const c=a,u=Ct.getState(n.state);let f;if(u!=null)f=n.state.doc.resolve(u);else if(_c(n,c.target)!=r&&(f=zs(n,e),!f))return i();f&&s(f,c)}n.root.addEventListener("mouseup",i),n.root.addEventListener("dragstart",i),n.root.addEventListener("mousemove",l)}function Wc(n,e,t){if(!(n.state.selection instanceof P))return null;const{$head:r}=n.state.selection;for(let o=r.depth-1;o>=0;o--){const s=r.node(o);if((t<0?r.index(o):r.indexAfter(o))!=(t<0?0:s.childCount))return null;if(s.type.spec.tableRole=="cell"||s.type.spec.tableRole=="header_cell"){const l=r.before(o),a=e=="vert"?t>0?"down":"up":t>0?"right":"left";return n.endOfTextblock(a)?l:null}}return null}function _c(n,e){for(;e&&e!=n.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function zs(n,e){const t=n.posAtCoords({left:e.clientX,top:e.clientY});return t&&t?Gn(n.state.doc.resolve(t.pos)):null}new lt("tableColumnResizing");function Gg({allowTableNodeSelection:n=!1}={}){return new Be({key:Ct,state:{init(){return null},apply(e,t){const r=e.getMeta(Ct);if(r!=null)return r==-1?null:r;if(t==null||!e.docChanged)return t;const{deleted:o,pos:s}=e.mapping.mapResult(t);return o?null:s}},props:{decorations:gg,handleDOMEvents:{mousedown:Yg},createSelectionBetween(e){return Ct.getState(e.state)!=null?e.state.selection:null},handleTripleClick:Kg,handleKeyDown:Hg,handlePaste:Jg},appendTransaction(e,t,r){return xg(r,Is(r,t),n)}})}const wt=m.createContext(null),Xg=m.createContext(null),qc=m.createContext(null),Yr=new WeakMap;function Ug(n){const e=Object.create(null);e.class="ProseMirror",e.contenteditable=String(n.editable),n.someProp("attributes",o=>{if(typeof o=="function"&&(o=o(n.state)),o)for(const s in o)s=="class"?e.class+=" "+o[s]:s=="style"?e.style=(e.style?e.style+";":"")+o[s]:!e[s]&&s!="contenteditable"&&s!="nodeName"&&(e[s]=String(o[s]))}),e.translate||(e.translate="no");const t=[Ve.node(0,n.state.doc.content.size,e)],r=Yr.get(n);return!r||r[0].to!==n.state.doc.content.size||!r[0].type.eq(t[0].type)?(Yr.set(n,t),t):r}const Qg=[],Zg={},$s=H.empty;let Hc=class Sn{constructor(e){j(this,"members");this.members=e}map(e,t){const r=this.members.map(o=>o.map(e,t,Zg));return Sn.from(r)}forChild(e,t){if(t.isLeaf)return H.empty;let r=[];for(let o=0;o<this.members.length;o++){const s=this.members[o].forChild(e,t);s!=$s&&(s instanceof Sn?r=r.concat(s.members):r.push(s))}return Sn.from(r)}eq(e){if(!(e instanceof Sn)||e.members.length!=this.members.length)return!1;for(let t=0;t<this.members.length;t++)if(!this.members[t].eq(e.members[t]))return!1;return!0}locals(e){let t,r=!0;for(let o=0;o<this.members.length;o++){const s=this.members[o].localsInner(e);if(s.length)if(!t)t=s;else{r&&(t=t.slice(),r=!1);for(let i=0;i<s.length;i++)t.push(s[i])}}return t?ey(r?t:t.sort(Kc)):Qg}static from(e){switch(e.length){case 0:return $s;case 1:return e[0];default:return new Sn(e.every(t=>t instanceof H)?e:e.reduce((t,r)=>t.concat(r instanceof H?r:r.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}};function Kc(n,e){return n.from-e.from||n.to-e.to}function ey(n){let e=n;for(let t=0;t<e.length-1;t++){const r=e[t];if(r.from!=r.to)for(let o=t+1;o<e.length;o++){const s=e[o];if(s.from==r.from){s.to!=r.to&&(e==n&&(e=n.slice()),e[o]=s.copy(s.from,r.to),Jc(e,o+1,s.copy(r.to,s.to)));continue}else{s.from<r.to&&(e==n&&(e=n.slice()),e[t]=r.copy(r.from,s.from),Jc(e,o,r.copy(s.from,r.to)));break}}}return e}function Jc(n,e,t){for(;e<n.length&&Kc(t,n[e])>0;)e++;n.splice(e,0,t)}const js=new WeakMap;function ty(n,e){const t=[];n.someProp("decorations",i=>{const l=i(n.state);l&&l!=$s&&t.push(l)}),e&&t.push(H.create(n.state.doc,[e]));const r=js.get(n);if(!r){const i=Hc.from(t);return js.set(n,i),i}let o=0,s=!0;if(r.forEachSet(i=>{t[o++]!==i&&(s=!1)}),o!==t.length&&(s=!1),!s){const i=Hc.from(t);return js.set(n,i),i}return r}const Bs=function(n){for(let e=0;;e++)if(n=n.previousSibling,!n)return e},Yc=function(n){const e=n.assignedSlot||n.parentNode;return e&&e.nodeType==11?e.host:e},ny=function(n,e,t,r){return t&&(Gc(n,e,t,r,-1)||Gc(n,e,t,r,1))},ry=/^(img|br|input|textarea|hr)$/i;function Gc(n,e,t,r,o){for(;;){if(n==t&&e==r)return!0;if(e==(o<0?0:Gr(n))){const s=n.parentNode;if(!s||s.nodeType!=1||sy(n)||ry.test(n.nodeName)||n.contentEditable=="false")return!1;e=Bs(n)+(o<0?0:1),n=s}else if(n.nodeType==1){if(n=n.childNodes[e+(o<0?-1:0)],n.contentEditable=="false")return!1;e=o<0?Gr(n):0}else return!1}}function Gr(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function oy(n,e,t){for(let r=e==0,o=e==Gr(n);r||o;){if(n==t)return!0;const s=Bs(n);if(n=n.parentNode,!n)return!1;r=r&&s==0,o=o&&s==Gr(n)}return!1}function sy(n){let e;for(let t=n;t&&!(e=t.pmViewDesc);t=t.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==n||e.contentDOM==n)}const Xc=function(n){return n.focusNode&&ny(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)},Uc=m.createContext(null);function J(){for(var n=arguments.length,e=new Array(n),t=0;t<n;t++)e[t]=arguments[t];typeof document>"u"||m.useLayoutEffect(...e)}function iy(n,e){const t=m.useContext(Uc);J(()=>t(n),e)}function Ke(n,e){const{view:t,flushSyncRef:r}=m.useContext(wt);iy(()=>{if(t!=null&&t.docView){r.current=!1;const o=n(t);return r.current=!0,o}},e&&[t,...e])}const ly=m.forwardRef(function(e,t){let{widget:r,getPos:o,...s}=e;const[i,l]=m.useState(!0),a=m.useRef(null);return m.useImperativeHandle(t,()=>a.current,[]),Ke(c=>{if(!c||!a.current)return;c.domObserver.disconnectSelection();const u=c.domSelection(),f=document.createRange(),d=a.current;d.nodeName=="IMG"&&d.parentNode?f.setEnd(d.parentNode,Bs(d)+1):f.setEnd(d,0),f.collapse(!1),u.removeAllRanges(),u.addRange(f),l(!1),c.domObserver.connectSelection()},[]),i?m.createElement("img",{ref:a,className:"ProseMirror-separator","mark-placeholder":"true",alt:"",...s}):null});function ay(n,e){if(n==e)return!0;for(const t in n)if(n[t]!==e[t])return!1;for(const t in e)if(!(t in n))return!1;return!0}const cy={side:0};class Xn{constructor(e,t){j(this,"Component");j(this,"side");j(this,"spec");this.Component=e,this.spec=t??cy,this.side=this.spec.side??0}map(e,t,r,o){const{pos:s,deleted:i}=e.mapResult(t.from+o,this.side<0?-1:1);return i?null:new Ve(s-r,s-r,this)}valid(){return!0}eq(e){return this==e||e instanceof Xn&&(this.spec.key&&this.spec.key==e.spec.key||this.Component==e.Component&&ay(this.spec,e.spec))}destroy(){}}function uy(n,e,t){return new Ve(n,n,new Xn(e,t))}function Fs(){return Math.floor(Math.random()*0xffffffffffff).toString(16)}const Un=new lt("@handlewithcare/react-prosemirror/reactKeys");function fy(){let n=!1;return new Be({key:Un,state:{init(e,t){const r={posToKey:new Map,keyToPos:new Map};return t.doc.descendants((o,s)=>{const i=Fs();return r.posToKey.set(s,i),r.keyToPos.set(i,s),!0}),r},apply(e,t,r,o){if(!e.docChanged||n)return t;const s=e.getMeta(Un),i=(s==null?void 0:s.type)==="bustKey"&&s.payload.key,l={posToKey:new Map,keyToPos:new Map},a=Array.from(t.posToKey.entries()).sort((c,u)=>{let[f]=c,[d]=u;return f-d});for(const[c,u]of a){const{pos:f,deleted:d}=e.mapping.mapResult(c);if(d)continue;let p=u;i===u&&(p=Fs()),l.posToKey.set(f,p),l.keyToPos.set(p,f)}return o.doc.descendants((c,u)=>{if(l.posToKey.has(u))return!0;const f=Fs();return l.posToKey.set(u,f),l.keyToPos.set(f,u),!0}),l}},props:{handleDOMEvents:{compositionstart:()=>{n=!0},compositionend:()=>{n=!1}}}})}function Ls(n,e){var i;let t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(e===null)return!1;const r=t.from??n.state.selection.from,o=t.to??n.state.selection.to;if(n.someProp("handleTextInput",l=>l(n,r,o,e)))return!0;const{tr:s}=n.state;if(t.marks&&s.ensureMarks(t.marks),s.insertText(e,r,o),t.bust){const l=n.state.doc.resolve(r),a=l.sharedDepth(o),c=l.start(a),u=(i=Un.getState(n.state))==null?void 0:i.posToKey.get(c-1);s.setMeta(Un,{type:"bustKey",payload:{key:u}})}return n.dispatch(s),!0}function dy(n){let e=null,t=null;return new Be({props:{handleDOMEvents:{compositionstart(r){var i;const{state:o}=r;r.dispatch(o.tr.deleteSelection());const s=o.selection.$from;return o.selection.empty&&(o.storedMarks||!s.textOffset&&s.parentOffset&&((i=s.nodeBefore)!=null&&i.marks.some(l=>l.type.spec.inclusive===!1)))&&n(uy(o.selection.from,ly,{key:"cursor-wrapper",marks:o.storedMarks??s.marks()})),t=o.storedMarks??s.marks(),r.input.composing=!0,!0},compositionupdate(){return!0},compositionend(r){if(r.input.composing=!1,e!==null)return Ls(r,e,{bust:!0,marks:t}),e=null,t=null,n(null),!0},beforeinput(r,o){var s,i;switch(o.preventDefault(),o.inputType){case"insertCompositionText":{if(o.data===null)break;e=o.data;break}case"insertReplacementText":{const l=o.getTargetRanges();(i=(s=o.dataTransfer)==null?void 0:s.items[0])==null||i.getAsString(a=>{for(const c of l){const u=r.posAtDOM(c.startContainer,c.startOffset,1),f=r.posAtDOM(c.endContainer,c.endOffset,1);Ls(r,a,{from:u,to:f})}});break}case"insertText":{Ls(r,o.data);break}case"deleteWordBackward":case"deleteContentBackward":case"deleteWordForward":case"deleteContentForward":case"deleteContent":{const l=o.getTargetRanges(),{tr:a}=r.state;for(const c of l){const u=r.posAtDOM(c.startContainer,c.startOffset),f=r.posAtDOM(c.endContainer,c.endOffset),{doc:d}=r.state,p=d.resolve(u).marksAcross(d.resolve(f));a.delete(u,f).setStoredMarks(p)}r.dispatch(a);break}}return!0}}}})}const Je=typeof navigator<"u"?navigator:null,Qc=typeof document<"u"?document:null,Ht=Je&&Je.userAgent||"",Ws=/Edge\/(\d+)/.exec(Ht),Zc=/MSIE \d/.exec(Ht),_s=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Ht),Xr=!!(Zc||_s||Ws),hy=Zc?document.documentMode:_s?+_s[1]:Ws?+Ws[1]:0,eu=!Xr&&/gecko\/(\d+)/i.test(Ht);eu&&+(/Firefox\/(\d+)/.exec(Ht)||[0,0])[1];const qs=!Xr&&/Chrome\/(\d+)/.exec(Ht),py=!!qs,my=qs?+qs[1]:0,tu=!Xr&&!!Je&&/Apple Computer/.test(Je.vendor);tu&&(/Mobile\/\w+/.test(Ht)||!!Je&&Je.maxTouchPoints>2)||Je&&/Mac/.test(Je.platform),Je&&/Win/.test(Je.platform),!!Qc&&"webkitFontSmoothing"in Qc.documentElement.style&&+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1];const ae={ie:Xr,ie_version:hy,gecko:eu,chrome:py,chrome_version:my,safari:tu};function nu(n){return n.editable&&!n.hasFocus()?!1:gy(n)}function gy(n){var t,r;const e=n.domSelectionRange();if(!e.anchorNode)return!1;try{return n.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(n.editable||n.dom.contains(((t=e.focusNode)==null?void 0:t.nodeType)==3?(r=e.focusNode)==null?void 0:r.parentNode:e.focusNode))}catch{return!1}}function yy(n,e,t,r){return n.someProp("createSelectionBetween",o=>o(n,e,t))||P.between(e,t,r)}function ru(n){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null;const t=n.domSelectionRange(),r=n.state.doc;if(!t.focusNode)return null;let o=n.docView.nearestDesc(t.focusNode);const s=o&&o.size==0;let i=n.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(i<0)return null;let l=r.resolve(i),a,c;if(Xc(t)){for(a=i;o&&!o.node;)o=o.parent;const f=o.node;if(o&&f.isAtom&&D.isSelectable(f)&&o.parent&&!(f.isInline&&oy(t.focusNode,t.focusOffset,o.dom))){const d=o.posBefore;c=new D(i==d?l:r.resolve(d))}}else{if(t instanceof n.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let f=i,d=i;for(let p=0;p<t.rangeCount;p++){const h=t.getRangeAt(p);f=Math.min(f,n.docView.posFromDOM(h.startContainer,h.startOffset,1)),d=Math.max(d,n.docView.posFromDOM(h.endContainer,h.endOffset,-1))}if(f<0)return null;[a,i]=d==n.state.selection.anchor?[d,f]:[f,d],l=r.resolve(i)}else a=n.docView.posFromDOM(t.anchorNode,t.anchorOffset,1);if(a<0)return null}const u=r.resolve(a);if(!c){const f=e=="pointer"||n.state.selection.head<l.pos&&!s?1:-1;c=yy(n,u,l,f)}return c}const Ur=function(n,e,t,r){return t&&(ou(n,e,t,r,-1)||ou(n,e,t,r,1))};function by(n){let e;for(let t=n;t&&!(e=t.pmViewDesc);t=t.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==n||e.contentDOM==n)}const xy=/^(img|br|input|textarea|hr)$/i;function ou(n,e,t,r,o){for(;;){if(n==t&&e==r)return!0;if(e==(o<0?0:su(n))){const s=n.parentNode;if(!s||s.nodeType!=1||by(n)||xy.test(n.nodeName)||n.contentEditable=="false")return!1;e=Mt(n)+(o<0?0:1),n=s}else if(n.nodeType==1){if(n=n.childNodes[e+(o<0?-1:0)],n.contentEditable=="false")return!1;e=o<0?su(n):0}else return!1}}const Mt=function(n){let e=n;for(let t=0;;t++)if(e=e.previousSibling,!e)return t};function su(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function ky(n,e){const t=n;if(e instanceof D){const r=t.docView.descAt(e.from);r!=t.lastSelectedViewDesc&&(iu(t),r&&r.selectNode(),t.lastSelectedViewDesc=r)}else iu(t)}function iu(n){const e=n;e.lastSelectedViewDesc&&(e.lastSelectedViewDesc.parent&&e.lastSelectedViewDesc.deselectNode(),e.lastSelectedViewDesc=void 0)}function Sy(n){const e=n,t=e.domSelectionRange();if(!t.anchorNode)return!1;try{return e.dom.contains(t.anchorNode.nodeType==3?t.anchorNode.parentNode:t.anchorNode)&&(e.editable||e.dom.contains(t.focusNode.nodeType==3?t.focusNode.parentNode:t.focusNode))}catch{return!1}}function lu(n){return n.editable?n.hasFocus():Sy(n)&&document.activeElement&&document.activeElement.contains(n.dom)}function Cy(n){const e=n,t=e.domSelection(),r=document.createRange();if(!t)return;const o=e.cursorWrapper.dom,s=o.nodeName=="IMG";s?r.setStart(o.parentNode,Mt(o)+1):r.setStart(o,0),r.collapse(!0),t.removeAllRanges(),t.addRange(r),!s&&!e.state.selection.visible&&ae.ie&&ae.ie_version<=11&&(o.disabled=!0,o.disabled=!1)}function au(n,e){const t=n,{node:r,offset:o}=t.docView.domFromPos(e,0),s=o<r.childNodes.length?r.childNodes[o]:null,i=o?r.childNodes[o-1]:null;if(ae.safari&&s&&s.contentEditable=="false")return Hs(s);if((!s||s.contentEditable=="false")&&(!i||i.contentEditable=="false")){if(s)return Hs(s);if(i)return Hs(i)}}function Hs(n){return n.contentEditable="true",ae.safari&&n.draggable&&(n.draggable=!1,n.wasDraggable=!0),n}function cu(n){n.contentEditable="false",n.wasDraggable&&(n.draggable=!0,n.wasDraggable=null)}function wy(n){const e=n,t=e.dom.ownerDocument;t.removeEventListener("selectionchange",e.input.hideSelectionGuard);const r=e.domSelectionRange(),o=r.anchorNode,s=r.anchorOffset;t.addEventListener("selectionchange",e.input.hideSelectionGuard=()=>{(r.anchorNode!=o||r.anchorOffset!=s)&&(t.removeEventListener("selectionchange",e.input.hideSelectionGuard),setTimeout(()=>{(!lu(e)||e.state.selection.visible)&&e.dom.classList.remove("ProseMirror-hideselection")},20))})}const uu=ae.safari||ae.chrome&&ae.chrome_version<63;function Qr(n){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;const t=n,r=t.state.selection;if(ky(t,r),!!lu(t)){if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&ae.chrome){const o=t.domSelectionRange(),s=t.domObserver.currentSelection;if(o.anchorNode&&s.anchorNode&&Ur(o.anchorNode,o.anchorOffset,s.anchorNode,s.anchorOffset)){t.input.mouseDown.delayedSelectionSync=!0,t.domObserver.setCurSelection();return}}if(t.domObserver.disconnectSelection(),t.cursorWrapper)Cy(t);else{const{anchor:o,head:s}=r;let i,l;uu&&!(r instanceof P)&&(r.$from.parent.inlineContent||(i=au(t,r.from)),!r.empty&&!r.$from.parent.inlineContent&&(l=au(t,r.to))),t.docView.setSelection(o,s,t,e),uu&&(i&&cu(i),l&&cu(l)),r.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&wy(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}}let My=class{constructor(){j(this,"anchorNode",null);j(this,"anchorOffset",0);j(this,"focusNode",null);j(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 Ny{constructor(e){j(this,"view");j(this,"flushingSoon");j(this,"currentSelection");j(this,"suppressingSelectionUpdates");this.view=e,this.flushingSoon=-1,this.currentSelection=new My,this.suppressingSelectionUpdates=!1,this.view=e,this.onSelectionChange=this.onSelectionChange.bind(this)}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}stop(){this.disconnectSelection()}start(){this.connectSelection()}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;const t=new Set;let r;for(let s=e.focusNode;s;s=Yc(s))t.add(s);for(let s=e.anchorNode;s;s=Yc(s))if(t.has(s)){r=s;break}const o=r&&this.view.docView.nearestDesc(r);if(o&&o.ignoreMutation({type:"selection",target:(r==null?void 0:r.nodeType)==3?r==null?void 0:r.parentNode:r}))return this.setCurSelection(),!0}registerMutation(){}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}updateSelection(){const{view:e}=this,t=e.input.compositionPendingChanges||(e.composing?e.input.compositionID:0);e.input.compositionPendingChanges=0;const r=e.input.lastSelectionTime>Date.now()-50?e.input.lastSelectionOrigin:null,o=ru(e,r);if(o&&!e.state.selection.eq(o)){const s=e.state.tr.setSelection(o);r=="pointer"?s.setMeta("pointer",!0):r=="key"&&s.scrollIntoView(),t&&s.setMeta("composition",t),e.dispatch(s)}}selectionToDOM(){const{view:e}=this;Qr(e);const t=e.domSelectionRange();this.currentSelection.set(t)}flush(){const{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;const t=e.domSelectionRange(),r=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(t)&&nu(e)&&!this.ignoreSelectionChange(t);let o=null;r&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&Xc(t)&&(o=ru(e))&&o.eq(R.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,Qr(e),this.currentSelection.set(t),e.scrollToSelection()):r&&(this.updateSelection(),this.currentSelection.eq(t)||Qr(e),this.currentSelection.set(t))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}onSelectionChange(){if(nu(this.view)&&!this.view.composing){if(this.suppressingSelectionUpdates)return Qr(this.view);if(ae.ie&&ae.ie_version<=11&&!this.view.state.selection.empty){const e=this.view.domSelectionRange();if(e.focusNode&&Ur(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}}let Ey=class{add(){}remove(){}},fu=class ao{constructor(){j(this,"nodeName","div");j(this,"style",{})}get parent(){return new ao}get parentNode(){return new ao}appendChild(){return new ao}setAttribute(){}hasAttribute(){return!1}insertBefore(){}get classList(){return new Ey}get ownerDocument(){return new du}addEventListener(){}removeEventListener(){}replaceChildren(){}},du=class{createElement(){return new fu}addEventListener(){}removeEventListener(){}get documentElement(){return new fu}};function hu(){const n=globalThis.window;globalThis.window??(globalThis.window={visualViewport:null});const e=globalThis.document;return globalThis.document??(globalThis.document=new du),function(){globalThis.window!==n&&(globalThis.window=n),globalThis.document!==e&&(globalThis.document=e)}}function Kt(n,e){return n instanceof er?1:e instanceof er?-1:n.getPos()-e.getPos()}const gn=0,pu=1,Zr=2,Qn=3;class Zn{constructor(e,t,r,o,s){j(this,"parent");j(this,"children");j(this,"getPos");j(this,"dom");j(this,"contentDOM");j(this,"dirty");j(this,"node");this.parent=e,this.children=t,this.getPos=r,this.dom=o,this.contentDOM=s,this.dirty=gn,o.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,r){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;t<this.children.length;t++)e+=this.children[t].size;return e}get border(){return 0}destroy(){}posBeforeChild(e){for(let t=0,r=this.posAtStart;;t++){const o=this.children[t];if(o==e)return r;r+=o.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,t,r){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(r<0){let s,i;if(e==this.contentDOM)s=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;s=e.previousSibling}for(;s&&!((i=s.pmViewDesc)&&i.parent==this);)s=s.previousSibling;return s?this.posBeforeChild(i)+i.size:this.posAtStart}else{let s,i;if(e==this.contentDOM)s=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;s=e.nextSibling}for(;s&&!((i=s.pmViewDesc)&&i.parent==this);)s=s.nextSibling;return s?this.posBeforeChild(i):this.posAtEnd}let o;if(e==this.dom&&this.contentDOM)o=t>Mt(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))o=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(t==0)for(let s=e;;s=s.parentNode){if(s==this.dom){o=!1;break}if(s.previousSibling)break}if(o==null&&t==e.childNodes.length)for(let s=e;;s=s.parentNode){if(s==this.dom){o=!0;break}if(s.nextSibling)break}}return o??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;for(let r=!0,o=e;o;o=o.parentNode){const s=this.getDesc(o);let i;if(s&&(!t||s.node))if(r&&(i=s.nodeDOM)&&!(i.nodeType==1?i.contains(e.nodeType==1?e:e.parentNode):i==e))r=!1;else return s}}getDesc(e){const t=e.pmViewDesc;for(let r=t;r;r=r.parent)if(r==this)return t}posFromDOM(e,t,r){for(let o=e;o;o=o.parentNode){const s=this.getDesc(o);if(s)return s.localPosFromDOM(e,t,r)}return-1}descAt(e){for(let t=0,r=0;t<this.children.length;t++){let o=this.children[t];const s=r+o.size;if(r==e&&s!=r){for(;!o.border&&o.children.length;)o=o.children[0];return o}if(e<s)return o.descAt(e-r-o.border);r=s}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let r=0,o=0;for(let s=0;r<this.children.length;r++){const i=this.children[r],l=s+i.size;if(l>e||i instanceof er){o=e-s;break}s=l}if(o)return this.children[r].domFromPos(o-this.children[r].border,t);for(let s;r&&!(s=this.children[r-1]).size&&s instanceof Ks&&s.side>=0;r--);if(t<=0){let s,i=!0;for(;s=r?this.children[r-1]:null,!(!s||s.dom.parentNode==this.contentDOM);r--,i=!1);return s&&t&&i&&!s.border&&!s.domAtom?s.domFromPos(s.size,t):{node:this.contentDOM,offset:s?Mt(s.dom)+1:0}}else{let s,i=!0;for(;s=r<this.children.length?this.children[r]:null,!(!s||s.dom.parentNode==this.contentDOM);r++,i=!1);return s&&i&&!s.border&&!s.domAtom?s.domFromPos(0,t):{node:this.contentDOM,offset:s?Mt(s.dom):this.contentDOM.childNodes.length}}}parseRange(e,t){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0;if(this.children.length==0)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let o=-1,s=-1;for(let i=r,l=0;;l++){const a=this.children[l],c=i+a.size;if(o==-1&&e<=c){const u=i+a.border;if(e>=u&&t<=c-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,t,u);e=i;for(let f=l;f>0;f--){const d=this.children[f-1];if(d.size&&d.dom.parentNode==this.contentDOM&&!d.emptyChildAt(1)){o=Mt(d.dom)+1;break}e-=d.size}o==-1&&(o=0)}if(o>-1&&(c>t||l==this.children.length-1)){t=c;for(let u=l+1;u<this.children.length;u++){const f=this.children[u];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(-1)){s=Mt(f.dom);break}t+=f.size}s==-1&&(s=this.contentDOM.childNodes.length);break}i=c}return{node:this.contentDOM,from:e,to:t,fromOffset:o,toOffset:s}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;const t=this.children[e<0?0:this.children.length-1];return t.size==0||t.emptyChildAt(e)}domAfterPos(e){const{node:t,offset:r}=this.domFromPos(e,0);if(t.nodeType!=1||r==t.childNodes.length)throw new RangeError("No node after pos "+e);return t.childNodes[r]}setSelection(e,t,r){var p;let o=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1;const s=Math.min(e,t),i=Math.max(e,t);for(let h=0,b=0;h<this.children.length;h++){const g=this.children[h],k=b+g.size;if(s>b&&i<k)return g.setSelection(e-b-g.border,t-b-g.border,r,o);b=k}let l=this.domFromPos(e,e?-1:1),a=t==e?l:this.domFromPos(t,t?-1:1);const c=r.root.getSelection(),u=r.domSelectionRange();let f=!1;if((ae.gecko||ae.safari)&&e==t){const{node:h,offset:b}=l;if(h.nodeType==3){if(f=!!(b&&((p=h.nodeValue)==null?void 0:p[b-1])==`
|
|
45
|
-
`),f&&b==h.nodeValue.length)for(let g=h,k;g;g=g.parentNode){if(k=g.nextSibling){k.nodeName=="BR"&&(l=a={node:k.parentNode,offset:Mt(k)+1});break}const w=g.pmViewDesc;if(w&&w.node&&w.node.isBlock)break}}else{const g=h.childNodes[b-1];f=g&&(g.nodeName=="BR"||g.contentEditable=="false")}}if(ae.gecko&&u.focusNode&&u.focusNode!=a.node&&u.focusNode.nodeType==1){const h=u.focusNode.childNodes[u.focusOffset];h&&h.contentEditable=="false"&&(o=!0)}if(!(o||f&&ae.safari)&&Ur(l.node,l.offset,u.anchorNode,u.anchorOffset)&&Ur(a.node,a.offset,u.focusNode,u.focusOffset))return;let d=!1;if((c.extend||e==t)&&!f){c.collapse(l.node,l.offset);try{e!=t&&c.extend(a.node,a.offset),d=!0}catch{}}if(!d){if(e>t){const b=l;l=a,a=b}const h=document.createRange();h.setEnd(a.node,a.offset),h.setStart(l.node,l.offset),c.removeAllRanges(),c.addRange(h)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let r=0,o=0;o<this.children.length;o++){const s=this.children[o],i=r+s.size;if(r==i?e<=i&&t>=r:e<i&&t>r){const l=r+s.border,a=i-s.border;if(e>=l&&t<=a){this.dirty=e==r||t==i?Zr:pu,e==l&&t==a&&(s.contentLost||s.dom.parentNode!=this.contentDOM)?s.dirty=Qn:s.markDirty(e-l,t-l);return}else s.dirty=s.dom==s.contentDOM&&s.dom.parentNode==this.contentDOM&&!s.children.length?Zr:Qn}r=i}this.dirty=Zr}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){const r=e==1?Zr:pu;t.dirty<r&&(t.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}}class Ks extends Zn{constructor(t,r,o,s){super(t,[],r,s,null);j(this,"widget");this.widget=o,this.widget=o}matchesWidget(t){return this.dirty==gn&&t.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(t){const r=this.widget.spec.stopEvent;return r?r(t):!1}ignoreMutation(t){return t.type!="selection"||this.widget.spec.ignoreSelection}get domAtom(){return!0}get side(){return this.widget.type.side}}class eo extends Zn{constructor(t,r,o,s,i){super(t,[],r,o,null);j(this,"textDOM");j(this,"text");this.textDOM=s,this.text=i}get size(){return this.text.length}localPosFromDOM(t,r){return t!=this.textDOM?this.posAtStart+(r?this.size:0):this.posAtStart+r}domFromPos(t){return{node:this.textDOM,offset:t}}ignoreMutation(t){return t.type==="characterData"&&t.target.nodeValue==t.oldValue}}class Dy extends Zn{constructor(t,r,o,s,i,l,a){super(t,r,o,i,l);j(this,"mark");j(this,"spec");this.mark=s,this.spec=a}parseRule(){return this.dirty&Qn||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(t){return this.dirty!=Qn&&this.mark.eq(t)}markDirty(t,r){if(super.markDirty(t,r),this.dirty!=gn){let o=this.parent;for(;!o.node;)o=o.parent;o.dirty<this.dirty&&(o.dirty=this.dirty),this.dirty=gn}}ignoreMutation(t){return this.spec.ignoreMutation?this.spec.ignoreMutation(t):super.ignoreMutation(t)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class Js extends Zn{constructor(t,r,o,s,i,l,a,c,u,f,d,p,h){super(t,r,o,a,c);j(this,"node");j(this,"outerDeco");j(this,"innerDeco");j(this,"nodeDOM");j(this,"stopEvent");j(this,"selectNode");j(this,"deselectNode");j(this,"ignoreMutation");this.node=s,this.outerDeco=i,this.innerDeco=l,this.nodeDOM=u,this.stopEvent=f,this.selectNode=d,this.deselectNode=p,this.ignoreMutation=h}updateOuterDeco(){}parseRule(){if(this.node.type.spec.reparseInView)return null;const t={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(t.preserveWhitespace="full"),!this.contentDOM)t.getContent=()=>this.node.content;else if(!this.contentLost)t.contentElement=this.contentDOM;else{for(let r=this.children.length-1;r>=0;r--){const o=this.children[r];if(this.dom.contains(o.dom.parentNode)){t.contentElement=o.dom.parentNode;break}}t.contentElement||(t.getContent=()=>S.empty)}return t}matchesNode(t,r,o){return this.dirty==gn&&t.eq(this.node)&&Ty(r,this.outerDeco)&&o.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}update(t,r,o,s){return!0}get domAtom(){return this.node.isAtom}}class Oy extends Js{constructor(e,t,r,o,s,i,l,a){super(e,t,r,o,s,i,l,null,a,()=>!1,()=>{},()=>{},c=>c.type!="characterData"&&c.type!="selection")}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,r,o){return!0}inParent(){const e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,r){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,r)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=Qn)}get domAtom(){return!1}}class er extends Zn{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==gn&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}function Ty(n,e){if(n.length!=e.length)return!1;for(let t=0;t<n.length;t++)if(!n[t].type.eq(e[t].type))return!1;return!0}function vy(n){const e={};for(const[r,o]of n.entries()){let s=function(i,l){for(const a of o){let c=!1;if(Ye.unstable_batchedUpdates(()=>{c=!!a.call(this,i,l)}),c||l.defaultPrevented)return!0}return!1};e[r]=s}return new Be({key:new lt("@handlewithcare/react-prosemirror/componentEventListeners"),props:{handleDOMEvents:e}})}function Ay(){const[n,e]=m.useState(new Map),t=m.useCallback((s,i)=>{const l=n.get(s)??[];l.unshift(i),n.has(s)||(n.set(s,l),e(new Map(n)))},[n]),r=m.useCallback((s,i)=>{const l=n.get(s);l==null||l.splice(l.indexOf(i),1)},[n]),o=m.useMemo(()=>vy(n),[n]);return{registerEventListener:t,unregisterEventListener:r,componentEventListenersPlugin:o}}function Ys(){const[,n]=m.useReducer(e=>e+1,0);return n}function Py(n){const e=Object.create(null);function t(r){for(const o in r)Object.prototype.hasOwnProperty.call(e,o)||(e[o]=r[o])}return n.someProp("nodeViews",t),n.someProp("markViews",t),e}function Iy(n,e){let t=0,r=0;for(const o in n){if(n[o]!=e[o])return!0;t++}for(const o in e)r++;return t!=r}function Vy(n,e){for(const t of Object.keys(n))if(n[t]!==e[t])return!0;return!1}function mu(n){return!n.someProp("editable",e=>e(n.state)===!1)}class gu extends Ep{constructor(t,r){const o=hu();super(t,{state:Ge.create({schema:r.state.schema,plugins:r.state.plugins}),plugins:r.plugins});j(this,"shouldUpdatePluginViews",!1);j(this,"oldProps");j(this,"_props");o(),this.shouldUpdatePluginViews=!0,this._props=r,this.oldProps={state:r.state},this.state=r.state,this.domObserver.stop(),this.domObserver=new Ny(this),this.domObserver.start(),this.editable=mu(this),this.docView.dom.replaceChildren(),this.docView=r.docView}get needsRedraw(){if(this.oldProps.state.plugins===this._props.state.plugins&&this._props.plugins===this.oldProps.plugins)return!1;const t=Py(this);return Iy(this.nodeViews,t)}pureSetProps(t){this._props={...this._props,...t},this.state=this._props.state,this.editable=mu(this)}runPendingEffects(){if(Vy(this.props,this.oldProps)){const t=this.props;this._props=this.oldProps,this.state=this._props.state,this.update(t)}}update(t){super.update(t),this.oldProps=t}updatePluginViews(t){this.shouldUpdatePluginViews&&super.updatePluginViews(t)}destroy(){this.dom=document.createElement("div"),super.destroy()}}const Ry=new gr({nodes:{doc:{content:"text*"},text:{inline:!0}}}),zy=Ge.create({schema:Ry});let yu=!1;function $y(n,e){process.env.NODE_ENV!=="production"&&e.defaultState!==void 0&&e.state!==void 0&&!yu&&(console.error("A component contains a ProseMirror editor with both value and defaultValue props. ProseMirror editors must be either controlled or uncontrolled (specify either the state prop, or the defaultState prop, but not both). Decide between using a controlled or uncontrolled ProseMirror editor and remove one of these props. More info: https://reactjs.org/link/controlled-components"),yu=!0);const t=m.useRef(!0),[r,o]=m.useState(null),s=Ys(),i=e.defaultState??zy,[l,a]=m.useState(i),c=e.state??l,{componentEventListenersPlugin:u,registerEventListener:f,unregisterEventListener:d}=Ay(),p=m.useCallback(V=>{Ye.flushSync(()=>{o(V)})},[]),h=m.useMemo(()=>[...e.plugins??[],u,dy(p)],[e.plugins,u,p]),b=m.useCallback(function(z){t.current?Ye.flushSync(()=>{e.state||a(T=>T.apply(z)),e.dispatchTransaction&&e.dispatchTransaction.call(this,z)}):(e.state||a(T=>T.apply(z)),e.dispatchTransaction&&e.dispatchTransaction.call(this,z))},[e.dispatchTransaction,e.state]),g=hu(),k=document.createElement("div");g();const w=m.useRef(new Js(void 0,[],()=>-1,c.doc,[],H.empty,k,null,k,()=>!1,()=>{},()=>{},()=>!1)),M={...e,state:c,plugins:h,dispatchTransaction:b,docView:w.current},[O,I]=m.useState(()=>new gu(null,M));return J(()=>()=>{O==null||O.destroy()},[O]),J(()=>{if(!n){I(null);return}if(!O||O.dom!==n){const V=new gu({mount:n},M);I(V),V.dom.addEventListener("compositionend",s);return}if(O.needsRedraw){I(null);return}O==null||O.domObserver.selectionToDOM(),O==null||O.runPendingEffects()}),O==null||O.pureSetProps(M),{editor:m.useMemo(()=>({view:O,registerEventListener:f,unregisterEventListener:d,cursorWrapper:r,docViewDescRef:w,flushSyncRef:t}),[O,f,d,r]),state:c}}function jy(n){let{children:e}=n;const t=m.useRef(new Set).current,r=m.useRef(new Set).current,o=m.useRef(!1),s=Ys(),i=m.useRef(!0),l=m.useCallback(()=>{i.current||(s(),i.current=!0)},[s]),a=m.useCallback(c=>{let u;const f=()=>{u=c()};return t.add(f),l(),()=>{t.delete(f),u&&(o.current?(r.add(u),l()):u())}},[t,r,l]);return J(()=>(i.current=!1,t.forEach(c=>c()),t.clear(),()=>{r.forEach(c=>c()),r.clear()})),J(()=>(o.current=!0,()=>{o.current=!1}),[]),m.createElement(Uc.Provider,{value:a},e)}const Ce=m.createContext({parentRef:{current:void 0},siblingsRef:{current:[]}});function Gs(n,e,t,r,o,s,i,l){const{view:a}=m.useContext(wt),[c,u]=m.useState(!0),f=m.useRef(i),d=m.useRef(()=>!1),p=m.useCallback(C=>{d.current=C},[]),h=m.useRef(()=>!1),b=m.useCallback(C=>{h.current=C},[]),g=m.useRef(()=>{!r.current||!n||(r.current.nodeType==1&&r.current.classList.add("ProseMirror-selectednode"),(l!=null&&l.current||!n.type.spec.draggable)&&(((t==null?void 0:t.current)??r.current).draggable=!0))}),k=m.useRef(()=>{!r.current||!n||r.current.nodeType==1&&(r.current.classList.remove("ProseMirror-selectednode"),(l!=null&&l.current||!n.type.spec.draggable)&&((t==null?void 0:t.current)??r.current).removeAttribute("draggable"))}),w=m.useCallback((C,V)=>{g.current=C,k.current=V},[]),{siblingsRef:M,parentRef:O}=m.useContext(Ce),I=m.useRef([]);return J(()=>{const C=M.current;return()=>{if(f.current&&C.includes(f.current)){const V=C.indexOf(f.current);C.splice(V,1)}}},[M]),J(()=>{var V;if(!n||!r.current)return;const C=I.current[0];f.current?(f.current.parent=O.current,f.current.children=I.current,f.current.node=n,f.current.getPos=e,f.current.outerDeco=s,f.current.innerDeco=o,f.current.dom=(t==null?void 0:t.current)??r.current,f.current.dom.pmViewDesc=f.current,f.current.contentDOM=(l==null?void 0:l.current)??f.current.contentDOM??(C==null?void 0:C.dom.parentElement)??null,f.current.nodeDOM=r.current):f.current=new Js(O.current,I.current,e,n,s,o,(t==null?void 0:t.current)??r.current,(C==null?void 0:C.dom.parentElement)??null,r.current,z=>!!d.current(z),()=>g.current(),()=>k.current(),z=>h.current(z)),u(f.current.contentDOM!==null),M.current.includes(f.current)||M.current.push(f.current),M.current.sort(Kt);for(const z of I.current)if(z.parent=f.current,z instanceof eo){const T=(V=f.current.contentDOM)==null?void 0:V.firstChild;if(!T)throw new Error("Started a composition but couldn't find the text node it belongs to.");let L=T;for(;L.firstChild;)L=L.firstChild;if(!L||!(L instanceof Text))throw new Error("Started a composition but couldn't find the text node it belongs to.");z.dom=T,z.textDOM=L,z.text=L.data,z.textDOM.pmViewDesc=z,a==null||a.input.compositionNodes.push(z)}return()=>{var z,T,L,we;((z=f.current)==null?void 0:z.children[0])instanceof eo&&!(a!=null&&a.composing)&&((we=(T=f.current)==null?void 0:T.children[0].dom.parentNode)==null||we.removeChild((L=f.current)==null?void 0:L.children[0].dom))}}),{hasContentDOM:c,childDescriptors:I,nodeViewDescRef:f,setStopEvent:p,setSelectNode:w,setIgnoreMutation:b}}function By(n,e){return n.type.side-e.type.side}function Fy(n,e,t,r){const o=e.locals(n);let s=0;if(o.length==0){for(let c=0;c<n.childCount;c++){const u=n.child(c);r(u,o,e.forChild(s,u),s,c),s+=u.nodeSize}return}let i=0;const l=[];let a=null;for(let c=0;;){if(i<o.length&&o[i].to==s){const h=o[i++];let b;for(;i<o.length&&o[i].to==s;)(b||(b=[h])).push(o[i++]);if(b){b.sort(By);for(let g=0;g<b.length;g++)t(b[g],!(b[g].type instanceof Xn),s,c+g,!!a)}else t(h,!(h.type instanceof Xn),s,c,!!a)}let u,f;if(a)f=-1,u=a,a=null;else if(c<n.childCount)f=c,u=n.child(c++);else break;for(let h=0;h<l.length;h++)l[h].to<=s&&l.splice(h--,1);for(;i<o.length&&o[i].from<=s&&o[i].to>s;)l.push(o[i++]);let d=s+u.nodeSize;if(u.isText){let h=d;i<o.length&&o[i].from<h&&(h=o[i].from);for(let b=0;b<l.length;b++)l[b].to<h&&(h=l[b].to);h<d&&(a=u.cut(h-s),u=u.cut(0,h-s),d=h,f=-1)}const p=u.isInline&&!u.isLeaf?l.filter(h=>!h.inline):l.slice();r(u,p,e.forChild(s,u),s,f),s=d}}function Ly(){const{view:n}=m.useContext(wt);return n&&Un.getState(n.state)}var bu={exports:{}};/*!
|
|
43
|
+
`);return{dom:a,text:d,slice:e}}function fc(n,e,t,r,o){let s=o.parent.type.spec.code,i,l;if(!t&&!e)return null;let a=e&&(r||s||!t);if(a){if(n.someProp("transformPastedText",d=>{e=d(e,s||r,n)}),s)return e?new N(C.from(n.state.schema.text(e.replace(/\r\n?/g,`
|
|
44
|
+
`))),0,0):N.empty;let f=n.someProp("clipboardTextParser",d=>d(e,o,r,n));if(f)l=f;else{let d=o.marks(),{schema:h}=n.state,p=$e.fromSchema(h);i=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(b=>{let g=i.appendChild(document.createElement("p"));b&&g.appendChild(p.serializeNode(h.text(b,d)))})}}else n.someProp("transformPastedHTML",f=>{t=f(t,n)}),i=$m(t),bs&&jm(i);let c=i&&i.querySelector("[data-pm-slice]"),u=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(u&&u[3])for(let f=+u[3];f>0;f--){let d=i.firstChild;for(;d&&d.nodeType!=1;)d=d.nextSibling;if(!d)break;i=d}if(l||(l=(n.someProp("clipboardParser")||n.someProp("domParser")||Pt.fromSchema(n.state.schema)).parseSlice(i,{preserveWhitespace:!!(a||u),context:o,ruleFromNode(d){return d.nodeName=="BR"&&!d.nextSibling&&d.parentNode&&!Vm.test(d.parentNode.nodeName)?{ignore:!0}:null}})),u)l=Bm(mc(l,+u[1],+u[2]),u[4]);else if(l=N.maxOpen(Rm(l.content,o),!0),l.openStart||l.openEnd){let f=0,d=0;for(let h=l.content.firstChild;f<l.openStart&&!h.type.spec.isolating;f++,h=h.firstChild);for(let h=l.content.lastChild;d<l.openEnd&&!h.type.spec.isolating;d++,h=h.lastChild);l=mc(l,f,d)}return n.someProp("transformPasted",f=>{l=f(l,n)}),l}const Vm=/^(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 Rm(n,e){if(n.childCount<2)return n;for(let t=e.depth;t>=0;t--){let o=e.node(t).contentMatchAt(e.index(t)),s,i=[];if(n.forEach(l=>{if(!i)return;let a=o.findWrapping(l.type),c;if(!a)return i=null;if(c=i.length&&s.length&&hc(a,s,l,i[i.length-1],0))i[i.length-1]=c;else{i.length&&(i[i.length-1]=pc(i[i.length-1],s.length));let u=dc(l,a);i.push(u),o=o.matchType(u.type),s=a}}),i)return C.from(i)}return n}function dc(n,e,t=0){for(let r=e.length-1;r>=t;r--)n=e[r].create(null,C.from(n));return n}function hc(n,e,t,r,o){if(o<n.length&&o<e.length&&n[o]==e[o]){let s=hc(n,e,t,r.lastChild,o+1);if(s)return r.copy(r.content.replaceChild(r.childCount-1,s));if(r.contentMatchAt(r.childCount).matchType(o==n.length-1?t.type:n[o+1]))return r.copy(r.content.append(C.from(dc(t,n,o+1))))}}function pc(n,e){if(e==0)return n;let t=n.content.replaceChild(n.childCount-1,pc(n.lastChild,e-1)),r=n.contentMatchAt(n.childCount).fillBefore(C.empty,!0);return n.copy(t.append(r))}function ws(n,e,t,r,o,s){let i=e<0?n.firstChild:n.lastChild,l=i.content;return n.childCount>1&&(s=0),o<r-1&&(l=ws(l,e,t,r,o+1,s)),o>=t&&(l=e<0?i.contentMatchAt(0).fillBefore(l,s<=o).append(l):l.append(i.contentMatchAt(i.childCount).fillBefore(C.empty,!0))),n.replaceChild(e<0?0:n.childCount-1,i.copy(l))}function mc(n,e,t){return e<n.openStart&&(n=new N(ws(n.content,-1,e,n.openStart,0,n.openEnd),e,n.openEnd)),t<n.openEnd&&(n=new N(ws(n.content,1,t,n.openEnd,0,0),n.openStart,t)),n}const gc={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};let yc=null;function bc(){return yc||(yc=document.implementation.createHTMLDocument("title"))}let Ms=null;function zm(n){let e=window.trustedTypes;return e?(Ms||(Ms=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})),Ms.createHTML(n)):n}function $m(n){let e=/^(\s*<meta [^>]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=bc().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(n),o;if((o=r&&gc[r[1].toLowerCase()])&&(n=o.map(s=>"<"+s+">").join("")+n+o.map(s=>"</"+s+">").reverse().join("")),t.innerHTML=zm(n),o)for(let s=0;s<o.length;s++)t=t.querySelector(o[s])||t;return t}function jm(n){let e=n.querySelectorAll(bt?"span:not([class]):not([style])":"span.Apple-converted-space");for(let t=0;t<e.length;t++){let r=e[t];r.childNodes.length==1&&r.textContent==" "&&r.parentNode&&r.parentNode.replaceChild(n.ownerDocument.createTextNode(" "),r)}}function Bm(n,e){if(!n.size)return n;let t=n.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return n}let{content:o,openStart:s,openEnd:i}=n;for(let l=r.length-2;l>=0;l-=2){let a=t.nodes[r[l]];if(!a||a.hasRequiredAttrs())break;o=C.from(a.create(r[l+1],o)),s++,i++}return new N(o,s,i)}const Re={},Se={};function kt(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}Se.keydown=(n,e)=>{let t=e;if(n.input.shiftKey=t.keyCode==16||t.shiftKey,!kc(n,t)&&(n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),!(Hn&&bt&&t.keyCode==13)))if(t.keyCode!=229&&n.domObserver.forceFlush(),ys&&t.keyCode==13&&!t.ctrlKey&&!t.altKey&&!t.metaKey){let r=Date.now();n.input.lastIOSEnter=r,n.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{n.input.lastIOSEnter==r&&(n.someProp("handleKeyDown",o=>o(n,Ja(13,"Enter"))),n.input.lastIOSEnter=0)},200)}else n.someProp("handleKeyDown",r=>r(n,t))||Im(n,t)?t.preventDefault():kt(n,"key")},Se.keyup=(n,e)=>{e.keyCode==16&&(n.input.shiftKey=!1)},Se.keypress=(n,e)=>{let t=e;if(kc(n,t)||!t.charCode||t.ctrlKey&&!t.altKey||De&&t.metaKey)return;if(n.someProp("handleKeyPress",o=>o(n,t))){t.preventDefault();return}let r=n.state.selection;if(!(r instanceof P)||!r.$from.sameParent(r.$to)){let o=String.fromCharCode(t.charCode);!/[\r\n]/.test(o)&&!n.someProp("handleTextInput",s=>s(n,r.$from.pos,r.$to.pos,o))&&n.dispatch(n.state.tr.insertText(o).scrollIntoView()),t.preventDefault()}};function Br(n){return{left:n.clientX,top:n.clientY}}function Fm(n,e){let t=e.x-n.clientX,r=e.y-n.clientY;return t*t+r*r<100}function Ns(n,e,t,r,o){if(r==-1)return!1;let s=n.state.doc.resolve(r);for(let i=s.depth+1;i>0;i--)if(n.someProp(e,l=>i>s.depth?l(n,t,s.nodeAfter,s.before(i),o,!0):l(n,t,s.node(i),s.before(i),o,!1)))return!0;return!1}function hn(n,e,t){if(n.focused||n.focus(),n.state.selection.eq(e))return;let r=n.state.tr.setSelection(e);r.setMeta("pointer",!0),n.dispatch(r)}function Lm(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),r=t.nodeAfter;return r&&r.isAtom&&D.isSelectable(r)?(hn(n,new D(t)),!0):!1}function Wm(n,e){if(e==-1)return!1;let t=n.state.selection,r,o;t instanceof D&&(r=t.node);let s=n.state.doc.resolve(e);for(let i=s.depth+1;i>0;i--){let l=i>s.depth?s.nodeAfter:s.node(i);if(D.isSelectable(l)){r&&t.$from.depth>0&&i>=t.$from.depth&&s.before(t.$from.depth+1)==t.$from.pos?o=s.before(t.$from.depth):o=s.before(i);break}}return o!=null?(hn(n,D.create(n.state.doc,o)),!0):!1}function _m(n,e,t,r,o){return Ns(n,"handleClickOn",e,t,r)||n.someProp("handleClick",s=>s(n,e,r))||(o?Wm(n,t):Lm(n,t))}function qm(n,e,t,r){return Ns(n,"handleDoubleClickOn",e,t,r)||n.someProp("handleDoubleClick",o=>o(n,e,r))}function Hm(n,e,t,r){return Ns(n,"handleTripleClickOn",e,t,r)||n.someProp("handleTripleClick",o=>o(n,e,r))||Km(n,t,r)}function Km(n,e,t){if(t.button!=0)return!1;let r=n.state.doc;if(e==-1)return r.inlineContent?(hn(n,P.create(r,0,r.content.size)),!0):!1;let o=r.resolve(e);for(let s=o.depth+1;s>0;s--){let i=s>o.depth?o.nodeAfter:o.node(s),l=o.before(s);if(i.inlineContent)hn(n,P.create(r,l+1,l+1+i.content.size));else if(D.isSelectable(i))hn(n,D.create(r,l));else continue;return!0}}function Es(n){return Fr(n)}const xc=De?"metaKey":"ctrlKey";Re.mousedown=(n,e)=>{let t=e;n.input.shiftKey=t.shiftKey;let r=Es(n),o=Date.now(),s="singleClick";o-n.input.lastClick.time<500&&Fm(t,n.input.lastClick)&&!t[xc]&&(n.input.lastClick.type=="singleClick"?s="doubleClick":n.input.lastClick.type=="doubleClick"&&(s="tripleClick")),n.input.lastClick={time:o,x:t.clientX,y:t.clientY,type:s};let i=n.posAtCoords(Br(t));i&&(s=="singleClick"?(n.input.mouseDown&&n.input.mouseDown.done(),n.input.mouseDown=new Jm(n,i,t,!!r)):(s=="doubleClick"?qm:Hm)(n,i.pos,i.inside,t)?t.preventDefault():kt(n,"pointer"))};class Jm{constructor(e,t,r,o){this.view=e,this.pos=t,this.event=r,this.flushed=o,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!r[xc],this.allowDefault=r.shiftKey;let s,i;if(t.inside>-1)s=e.state.doc.nodeAt(t.inside),i=t.inside;else{let u=e.state.doc.resolve(t.pos);s=u.parent,i=u.depth?u.before():0}const l=o?null:r.target,a=l?e.docView.nearestDesc(l,!0):null;this.target=a&&a.dom.nodeType==1?a.dom:null;let{selection:c}=e.state;(r.button==0&&s.type.spec.draggable&&s.type.spec.selectable!==!1||c instanceof D&&c.from<=i&&c.to>i)&&(this.mightDrag={node:s,pos:i,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&$r&&!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(()=>xs(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(Br(e))),this.updateAllowDefault(e),this.allowDefault||!t?kt(this.view,"pointer"):_m(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||Lt&&this.mightDrag&&!this.mightDrag.node.isAtom||bt&&!this.view.state.selection.visible&&Math.min(Math.abs(t.pos-this.view.state.selection.from),Math.abs(t.pos-this.view.state.selection.to))<=2)?(hn(this.view,R.near(this.view.state.doc.resolve(t.pos))),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)}}Re.touchstart=n=>{n.input.lastTouch=Date.now(),Es(n),kt(n,"pointer")},Re.touchmove=n=>{n.input.lastTouch=Date.now(),kt(n,"pointer")},Re.contextmenu=n=>Es(n);function kc(n,e){return n.composing?!0:Lt&&Math.abs(e.timeStamp-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}const Ym=Hn?5e3:-1;Se.compositionstart=Se.compositionupdate=n=>{if(!n.composing){n.domObserver.flush();let{state:e}=n,t=e.selection.$to;if(e.selection instanceof P&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)))n.markCursor=n.state.storedMarks||t.marks(),Fr(n,!0),n.markCursor=null;else if(Fr(n,!e.selection.empty),$r&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length){let r=n.domSelectionRange();for(let o=r.focusNode,s=r.focusOffset;o&&o.nodeType==1&&s!=0;){let i=s<0?o.lastChild:o.childNodes[s-1];if(!i)break;if(i.nodeType==3){let l=n.domSelection();l&&l.collapse(i,i.nodeValue.length);break}else o=i,s=-1}}n.input.composing=!0}Sc(n,Ym)},Se.compositionend=(n,e)=>{n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=e.timeStamp,n.input.compositionPendingChanges=n.domObserver.pendingRecords().length?n.input.compositionID:0,n.input.compositionNode=null,n.input.compositionPendingChanges&&Promise.resolve().then(()=>n.domObserver.flush()),n.input.compositionID++,Sc(n,20))};function Sc(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>Fr(n),e))}function Gm(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=Xm());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function Xm(){let n=document.createEvent("Event");return n.initEvent("event",!0,!0),n.timeStamp}function Fr(n,e=!1){if(!(Hn&&n.domObserver.flushingSoon>=0)){if(n.domObserver.forceFlush(),Gm(n),e||n.docView&&n.docView.dirty){let t=Cm(n);return t&&!t.eq(n.state.selection)?n.dispatch(n.state.tr.setSelection(t)):(n.markCursor||e)&&!n.state.selection.empty?n.dispatch(n.state.tr.deleteSelection()):n.updateState(n.state),!0}return!1}}function Um(n,e){if(!n.dom.parentNode)return;let t=n.dom.parentNode.appendChild(document.createElement("div"));t.appendChild(e),t.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),o=document.createRange();o.selectNodeContents(e),n.dom.blur(),r.removeAllRanges(),r.addRange(o),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t),n.focus()},50)}const Jn=qn&&Xa<15||ys&&Sm<604;Re.copy=Se.cut=(n,e)=>{let t=e,r=n.state.selection,o=t.type=="cut";if(r.empty)return;let s=Jn?null:t.clipboardData,i=r.content(),{dom:l,text:a}=uc(n,i);s?(t.preventDefault(),s.clearData(),s.setData("text/html",l.innerHTML),s.setData("text/plain",a)):Um(n,l),o&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function Qm(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function Zm(n,e){if(!n.dom.parentNode)return;let t=n.input.shiftKey||n.state.selection.$from.parent.type.spec.code,r=n.dom.parentNode.appendChild(document.createElement(t?"textarea":"div"));t||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let o=n.input.shiftKey&&n.input.lastKeyCode!=45;setTimeout(()=>{n.focus(),r.parentNode&&r.parentNode.removeChild(r),t?Ds(n,r.value,null,o,e):Ds(n,r.textContent,r.innerHTML,o,e)},50)}function Ds(n,e,t,r,o){let s=fc(n,e,t,r,n.state.selection.$from);if(n.someProp("handlePaste",a=>a(n,o,s||N.empty)))return!0;if(!s)return!1;let i=Qm(s),l=i?n.state.tr.replaceSelectionWith(i,r):n.state.tr.replaceSelection(s);return n.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Cc(n){let e=n.getData("text/plain")||n.getData("Text");if(e)return e;let t=n.getData("text/uri-list");return t?t.replace(/\r?\n/g," "):""}Se.paste=(n,e)=>{let t=e;if(n.composing&&!Hn)return;let r=Jn?null:t.clipboardData,o=n.input.shiftKey&&n.input.lastKeyCode!=45;r&&Ds(n,Cc(r),r.getData("text/html"),o,t)?t.preventDefault():Zm(n,t)};class eg{constructor(e,t,r){this.slice=e,this.move=t,this.node=r}}const tg=De?"altKey":"ctrlKey";function wc(n,e){let t=n.someProp("dragCopies",r=>!r(e));return t??!e[tg]}Re.dragstart=(n,e)=>{let t=e,r=n.input.mouseDown;if(r&&r.done(),!t.dataTransfer)return;let o=n.state.selection,s=o.empty?null:n.posAtCoords(Br(t)),i;if(!(s&&s.pos>=o.from&&s.pos<=(o instanceof D?o.to-1:o.to))){if(r&&r.mightDrag)i=D.create(n.state.doc,r.mightDrag.pos);else if(t.target&&t.target.nodeType==1){let f=n.docView.nearestDesc(t.target,!0);f&&f.node.type.spec.draggable&&f!=n.docView&&(i=D.create(n.state.doc,f.posBefore))}}let l=(i||n.state.selection).content(),{dom:a,text:c,slice:u}=uc(n,l);(!t.dataTransfer.files.length||!bt||Ua>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(Jn?"Text":"text/html",a.innerHTML),t.dataTransfer.effectAllowed="copyMove",Jn||t.dataTransfer.setData("text/plain",c),n.dragging=new eg(u,wc(n,t),i)},Re.dragend=n=>{let e=n.dragging;window.setTimeout(()=>{n.dragging==e&&(n.dragging=null)},50)},Se.dragover=Se.dragenter=(n,e)=>e.preventDefault(),Se.drop=(n,e)=>{let t=e,r=n.dragging;if(n.dragging=null,!t.dataTransfer)return;let o=n.posAtCoords(Br(t));if(!o)return;let s=n.state.doc.resolve(o.pos),i=r&&r.slice;i?n.someProp("transformPasted",p=>{i=p(i,n)}):i=fc(n,Cc(t.dataTransfer),Jn?null:t.dataTransfer.getData("text/html"),!1,s);let l=!!(r&&wc(n,t));if(n.someProp("handleDrop",p=>p(n,t,i||N.empty,l))){t.preventDefault();return}if(!i)return;t.preventDefault();let a=i?So(n.state.doc,s.pos,i):s.pos;a==null&&(a=s.pos);let c=n.state.tr;if(l){let{node:p}=r;p?p.replace(c):c.deleteSelection()}let u=c.mapping.map(a),f=i.openStart==0&&i.openEnd==0&&i.content.childCount==1,d=c.doc;if(f?c.replaceRangeWith(u,u,i.content.firstChild):c.replaceRange(u,u,i),c.doc.eq(d))return;let h=c.doc.resolve(u);if(f&&D.isSelectable(i.content.firstChild)&&h.nodeAfter&&h.nodeAfter.sameMarkup(i.content.firstChild))c.setSelection(new D(h));else{let p=c.mapping.map(a);c.mapping.maps[c.mapping.maps.length-1].forEach((b,g,k,S)=>p=S),c.setSelection(rc(n,h,c.doc.resolve(p)))}n.focus(),n.dispatch(c.setMeta("uiEvent","drop"))},Re.focus=n=>{n.input.lastFocus=Date.now(),n.focused||(n.domObserver.stop(),n.dom.classList.add("ProseMirror-focused"),n.domObserver.start(),n.focused=!0,setTimeout(()=>{n.docView&&n.hasFocus()&&!n.domObserver.currentSelection.eq(n.domSelectionRange())&&xs(n)},20))},Re.blur=(n,e)=>{let t=e;n.focused&&(n.domObserver.stop(),n.dom.classList.remove("ProseMirror-focused"),n.domObserver.start(),t.relatedTarget&&n.dom.contains(t.relatedTarget)&&n.domObserver.currentSelection.clear(),n.focused=!1)},Re.beforeinput=(n,e)=>{if(bt&&Hn&&e.inputType=="deleteContentBackward"){n.domObserver.flushSoon();let{domChangeCount:r}=n.input;setTimeout(()=>{if(n.input.domChangeCount!=r||(n.dom.blur(),n.focus(),n.someProp("handleKeyDown",s=>s(n,Ja(8,"Backspace")))))return;let{$cursor:o}=n.state.selection;o&&o.pos>0&&n.dispatch(n.state.tr.delete(o.pos-1,o.pos).scrollIntoView())},50)}};for(let n in Se)Re[n]=Se[n];function Yn(n,e){if(n==e)return!0;for(let t in n)if(n[t]!==e[t])return!1;for(let t in e)if(!(t in n))return!1;return!0}class Lr{constructor(e,t){this.toDOM=e,this.spec=t||Wt,this.side=this.spec.side||0}map(e,t,r,o){let{pos:s,deleted:i}=e.mapResult(t.from+o,this.side<0?-1:1);return i?null:new qe(s-r,s-r,this)}valid(){return!0}eq(e){return this==e||e instanceof Lr&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Yn(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class St{constructor(e,t){this.attrs=e,this.spec=t||Wt}map(e,t,r,o){let s=e.map(t.from+o,this.spec.inclusiveStart?-1:1)-r,i=e.map(t.to+o,this.spec.inclusiveEnd?1:-1)-r;return s>=i?null:new qe(s,i,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof St&&Yn(this.attrs,e.attrs)&&Yn(this.spec,e.spec)}static is(e){return e.type instanceof St}destroy(){}}class Os{constructor(e,t){this.attrs=e,this.spec=t||Wt}map(e,t,r,o){let s=e.mapResult(t.from+o,1);if(s.deleted)return null;let i=e.mapResult(t.to+o,-1);return i.deleted||i.pos<=s.pos?null:new qe(s.pos-r,i.pos-r,this)}valid(e,t){let{index:r,offset:o}=e.content.findIndex(t.from),s;return o==t.from&&!(s=e.child(r)).isText&&o+s.nodeSize==t.to}eq(e){return this==e||e instanceof Os&&Yn(this.attrs,e.attrs)&&Yn(this.spec,e.spec)}destroy(){}}class qe{constructor(e,t,r){this.from=e,this.to=t,this.type=r}copy(e,t){return new qe(e,t,this.type)}eq(e,t=0){return this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to}map(e,t,r){return this.type.map(e,this,t,r)}static widget(e,t,r){return new qe(e,e,new Lr(t,r))}static inline(e,t,r,o){return new qe(e,t,new St(r,o))}static node(e,t,r,o){return new qe(e,t,new Os(r,o))}get spec(){return this.type.spec}get inline(){return this.type instanceof St}get widget(){return this.type instanceof Lr}}const pn=[],Wt={};class U{constructor(e,t){this.local=e.length?e:pn,this.children=t.length?t:pn}static create(e,t){return t.length?Wr(t,e,0,Wt):he}find(e,t,r){let o=[];return this.findInner(e??0,t??1e9,o,0,r),o}findInner(e,t,r,o,s){for(let i=0;i<this.local.length;i++){let l=this.local[i];l.from<=t&&l.to>=e&&(!s||s(l.spec))&&r.push(l.copy(l.from+o,l.to+o))}for(let i=0;i<this.children.length;i+=3)if(this.children[i]<t&&this.children[i+1]>e){let l=this.children[i]+1;this.children[i+2].findInner(e-l,t-l,r,o+l,s)}}map(e,t,r){return this==he||e.maps.length==0?this:this.mapInner(e,t,0,0,r||Wt)}mapInner(e,t,r,o,s){let i;for(let l=0;l<this.local.length;l++){let a=this.local[l].map(e,r,o);a&&a.type.valid(t,a)?(i||(i=[])).push(a):s.onRemove&&s.onRemove(this.local[l].spec)}return this.children.length?rg(this.children,i||[],e,t,r,o,s):i?new U(i.sort(_t),pn):he}add(e,t){return t.length?this==he?U.create(e,t):this.addInner(e,t,0):this}addInner(e,t,r){let o,s=0;e.forEach((l,a)=>{let c=a+r,u;if(u=Nc(t,l,c)){for(o||(o=this.children.slice());s<o.length&&o[s]<a;)s+=3;o[s]==a?o[s+2]=o[s+2].addInner(l,u,c+1):o.splice(s,0,a,a+l.nodeSize,Wr(u,l,c+1,Wt)),s+=3}});let i=Mc(s?Ec(t):t,-r);for(let l=0;l<i.length;l++)i[l].type.valid(e,i[l])||i.splice(l--,1);return new U(i.length?this.local.concat(i).sort(_t):this.local,o||this.children)}remove(e){return e.length==0||this==he?this:this.removeInner(e,0)}removeInner(e,t){let r=this.children,o=this.local;for(let s=0;s<r.length;s+=3){let i,l=r[s]+t,a=r[s+1]+t;for(let u=0,f;u<e.length;u++)(f=e[u])&&f.from>l&&f.to<a&&(e[u]=null,(i||(i=[])).push(f));if(!i)continue;r==this.children&&(r=this.children.slice());let c=r[s+2].removeInner(i,l+1);c!=he?r[s+2]=c:(r.splice(s,3),s-=3)}if(o.length){for(let s=0,i;s<e.length;s++)if(i=e[s])for(let l=0;l<o.length;l++)o[l].eq(i,t)&&(o==this.local&&(o=this.local.slice()),o.splice(l--,1))}return r==this.children&&o==this.local?this:o.length||r.length?new U(o,r):he}forChild(e,t){if(this==he)return this;if(t.isLeaf)return U.empty;let r,o;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=e){this.children[l]==e&&(r=this.children[l+2]);break}let s=e+1,i=s+t.content.size;for(let l=0;l<this.local.length;l++){let a=this.local[l];if(a.from<i&&a.to>s&&a.type instanceof St){let c=Math.max(s,a.from)-s,u=Math.min(i,a.to)-s;c<u&&(o||(o=[])).push(a.copy(c,u))}}if(o){let l=new U(o.sort(_t),pn);return r?new ng([l,r]):l}return r||he}eq(e){if(this==e)return!0;if(!(e instanceof U)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let t=0;t<this.local.length;t++)if(!this.local[t].eq(e.local[t]))return!1;for(let t=0;t<this.children.length;t+=3)if(this.children[t]!=e.children[t]||this.children[t+1]!=e.children[t+1]||!this.children[t+2].eq(e.children[t+2]))return!1;return!0}locals(e){return Ts(this.localsInner(e))}localsInner(e){if(this==he)return pn;if(e.inlineContent||!this.local.some(St.is))return this.local;let t=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof St||t.push(this.local[r]);return t}forEachSet(e){e(this)}}U.empty=new U([],[]),U.removeOverlap=Ts;const he=U.empty;let ng=class kn{constructor(e){this.members=e}map(e,t){const r=this.members.map(o=>o.map(e,t,Wt));return kn.from(r)}forChild(e,t){if(t.isLeaf)return U.empty;let r=[];for(let o=0;o<this.members.length;o++){let s=this.members[o].forChild(e,t);s!=he&&(s instanceof kn?r=r.concat(s.members):r.push(s))}return kn.from(r)}eq(e){if(!(e instanceof kn)||e.members.length!=this.members.length)return!1;for(let t=0;t<this.members.length;t++)if(!this.members[t].eq(e.members[t]))return!1;return!0}locals(e){let t,r=!0;for(let o=0;o<this.members.length;o++){let s=this.members[o].localsInner(e);if(s.length)if(!t)t=s;else{r&&(t=t.slice(),r=!1);for(let i=0;i<s.length;i++)t.push(s[i])}}return t?Ts(r?t:t.sort(_t)):pn}static from(e){switch(e.length){case 0:return he;case 1:return e[0];default:return new kn(e.every(t=>t instanceof U)?e:e.reduce((t,r)=>t.concat(r instanceof U?r:r.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}};function rg(n,e,t,r,o,s,i){let l=n.slice();for(let c=0,u=s;c<t.maps.length;c++){let f=0;t.maps[c].forEach((d,h,p,b)=>{let g=b-p-(h-d);for(let k=0;k<l.length;k+=3){let S=l[k+1];if(S<0||d>S+u-f)continue;let M=l[k]+u-f;h>=M?l[k+1]=d<=M?-2:-1:d>=u&&g&&(l[k]+=g,l[k+1]+=g)}f+=g}),u=t.maps[c].map(u,-1)}let a=!1;for(let c=0;c<l.length;c+=3)if(l[c+1]<0){if(l[c+1]==-2){a=!0,l[c+1]=-1;continue}let u=t.map(n[c]+s),f=u-o;if(f<0||f>=r.content.size){a=!0;continue}let d=t.map(n[c+1]+s,-1),h=d-o,{index:p,offset:b}=r.content.findIndex(f),g=r.maybeChild(p);if(g&&b==f&&b+g.nodeSize==h){let k=l[c+2].mapInner(t,g,u+1,n[c]+s+1,i);k!=he?(l[c]=f,l[c+1]=h,l[c+2]=k):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=og(l,n,e,t,o,s,i),u=Wr(c,r,0,i);e=u.local;for(let f=0;f<l.length;f+=3)l[f+1]<0&&(l.splice(f,3),f-=3);for(let f=0,d=0;f<u.children.length;f+=3){let h=u.children[f];for(;d<l.length&&l[d]<h;)d+=3;l.splice(d,0,u.children[f],u.children[f+1],u.children[f+2])}}return new U(e.sort(_t),l)}function Mc(n,e){if(!e||!n.length)return n;let t=[];for(let r=0;r<n.length;r++){let o=n[r];t.push(new qe(o.from+e,o.to+e,o.type))}return t}function og(n,e,t,r,o,s,i){function l(a,c){for(let u=0;u<a.local.length;u++){let f=a.local[u].map(r,o,c);f?t.push(f):i.onRemove&&i.onRemove(a.local[u].spec)}for(let u=0;u<a.children.length;u+=3)l(a.children[u+2],a.children[u]+c+1)}for(let a=0;a<n.length;a+=3)n[a+1]==-1&&l(n[a+2],e[a]+s+1);return t}function Nc(n,e,t){if(e.isLeaf)return null;let r=t+e.nodeSize,o=null;for(let s=0,i;s<n.length;s++)(i=n[s])&&i.from>t&&i.to<r&&((o||(o=[])).push(i),n[s]=null);return o}function Ec(n){let e=[];for(let t=0;t<n.length;t++)n[t]!=null&&e.push(n[t]);return e}function Wr(n,e,t,r){let o=[],s=!1;e.forEach((l,a)=>{let c=Nc(n,l,a+t);if(c){s=!0;let u=Wr(c,l,t+a+1,r);u!=he&&o.push(a,a+l.nodeSize,u)}});let i=Mc(s?Ec(n):n,-t).sort(_t);for(let l=0;l<i.length;l++)i[l].type.valid(e,i[l])||(r.onRemove&&r.onRemove(i[l].spec),i.splice(l--,1));return i.length||o.length?new U(i,o):he}function _t(n,e){return n.from-e.from||n.to-e.to}function Ts(n){let e=n;for(let t=0;t<e.length-1;t++){let r=e[t];if(r.from!=r.to)for(let o=t+1;o<e.length;o++){let s=e[o];if(s.from==r.from){s.to!=r.to&&(e==n&&(e=n.slice()),e[o]=s.copy(s.from,r.to),Dc(e,o+1,s.copy(r.to,s.to)));continue}else{s.from<r.to&&(e==n&&(e=n.slice()),e[t]=r.copy(r.from,s.from),Dc(e,o,r.copy(s.from,r.to)));break}}}return e}function Dc(n,e,t){for(;e<n.length&&_t(t,n[e])>0;)e++;n.splice(e,0,t)}var vs,As;if(typeof WeakMap<"u"){let n=new WeakMap;vs=e=>n.get(e),As=(e,t)=>(n.set(e,t),t)}else{const n=[];let t=0;vs=r=>{for(let o=0;o<n.length;o+=2)if(n[o]==r)return n[o+1]},As=(r,o)=>(t==10&&(t=0),n[t++]=r,n[t++]=o)}var Q=class{constructor(n,e,t,r){this.width=n,this.height=e,this.map=t,this.problems=r}findCell(n){for(let e=0;e<this.map.length;e++){const t=this.map[e];if(t!=n)continue;const r=e%this.width,o=e/this.width|0;let s=r+1,i=o+1;for(let l=1;s<this.width&&this.map[e+l]==t;l++)s++;for(let l=1;i<this.height&&this.map[e+this.width*l]==t;l++)i++;return{left:r,top:o,right:s,bottom:i}}throw new RangeError(`No cell with offset ${n} found`)}colCount(n){for(let e=0;e<this.map.length;e++)if(this.map[e]==n)return e%this.width;throw new RangeError(`No cell with offset ${n} found`)}nextCell(n,e,t){const{left:r,right:o,top:s,bottom:i}=this.findCell(n);return e=="horiz"?(t<0?r==0:o==this.width)?null:this.map[s*this.width+(t<0?r-1:o)]:(t<0?s==0:i==this.height)?null:this.map[r+this.width*(t<0?s-1:i)]}rectBetween(n,e){const{left:t,right:r,top:o,bottom:s}=this.findCell(n),{left:i,right:l,top:a,bottom:c}=this.findCell(e);return{left:Math.min(t,i),top:Math.min(o,a),right:Math.max(r,l),bottom:Math.max(s,c)}}cellsInRect(n){const e=[],t={};for(let r=n.top;r<n.bottom;r++)for(let o=n.left;o<n.right;o++){const s=r*this.width+o,i=this.map[s];t[i]||(t[i]=!0,!(o==n.left&&o&&this.map[s-1]==i||r==n.top&&r&&this.map[s-this.width]==i)&&e.push(i))}return e}positionAt(n,e,t){for(let r=0,o=0;;r++){const s=o+t.child(r).nodeSize;if(r==n){let i=e+n*this.width;const l=(n+1)*this.width;for(;i<l&&this.map[i]<o;)i++;return i==l?s-1:this.map[i]}o=s}}static get(n){return vs(n)||As(n,sg(n))}};function sg(n){if(n.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+n.type.name);const e=ig(n),t=n.childCount,r=[];let o=0,s=null;const i=[];for(let c=0,u=e*t;c<u;c++)r[c]=0;for(let c=0,u=0;c<t;c++){const f=n.child(c);u++;for(let p=0;;p++){for(;o<r.length&&r[o]!=0;)o++;if(p==f.childCount)break;const b=f.child(p),{colspan:g,rowspan:k,colwidth:S}=b.attrs;for(let M=0;M<k;M++){if(M+c>=t){(s||(s=[])).push({type:"overlong_rowspan",pos:u,n:k-M});break}const O=o+M*e;for(let I=0;I<g;I++){r[O+I]==0?r[O+I]=u:(s||(s=[])).push({type:"collision",row:c,pos:u,n:g-I});const w=S&&S[I];if(w){const V=(O+I)%e*2,z=i[V];z==null||z!=w&&i[V+1]==1?(i[V]=w,i[V+1]=1):z==w&&i[V+1]++}}}o+=g,u+=b.nodeSize}const d=(c+1)*e;let h=0;for(;o<d;)r[o++]==0&&h++;h&&(s||(s=[])).push({type:"missing",row:c,n:h}),u++}(e===0||t===0)&&(s||(s=[])).push({type:"zero_sized"});const l=new Q(e,t,r,s);let a=!1;for(let c=0;!a&&c<i.length;c+=2)i[c]!=null&&i[c+1]<t&&(a=!0);return a&&lg(l,i,n),l}function ig(n){let e=-1,t=!1;for(let r=0;r<n.childCount;r++){const o=n.child(r);let s=0;if(t)for(let i=0;i<r;i++){const l=n.child(i);for(let a=0;a<l.childCount;a++){const c=l.child(a);i+c.attrs.rowspan>r&&(s+=c.attrs.colspan)}}for(let i=0;i<o.childCount;i++){const l=o.child(i);s+=l.attrs.colspan,l.attrs.rowspan>1&&(t=!0)}e==-1?e=s:e!=s&&(e=Math.max(e,s))}return e}function lg(n,e,t){n.problems||(n.problems=[]);const r={};for(let o=0;o<n.map.length;o++){const s=n.map[o];if(r[s])continue;r[s]=!0;const i=t.nodeAt(s);if(!i)throw new RangeError(`No cell with offset ${s} found`);let l=null;const a=i.attrs;for(let c=0;c<a.colspan;c++){const u=(o+c)%n.width,f=e[u*2];f!=null&&(!a.colwidth||a.colwidth[c]!=f)&&((l||(l=ag(a)))[c]=f)}l&&n.problems.unshift({type:"colwidth mismatch",pos:s,colwidth:l})}}function ag(n){if(n.colwidth)return n.colwidth.slice();const e=[];for(let t=0;t<n.colspan;t++)e.push(0);return e}function Oc(n,e){if(typeof n=="string")return{};const t=n.getAttribute("data-colwidth"),r=t&&/^\d+(,\d+)*$/.test(t)?t.split(",").map(i=>Number(i)):null,o=Number(n.getAttribute("colspan")||1),s={colspan:o,rowspan:Number(n.getAttribute("rowspan")||1),colwidth:r&&r.length==o?r:null};for(const i in e){const l=e[i].getFromDOM,a=l&&l(n);a!=null&&(s[i]=a)}return s}function Tc(n,e){const t={};n.attrs.colspan!=1&&(t.colspan=n.attrs.colspan),n.attrs.rowspan!=1&&(t.rowspan=n.attrs.rowspan),n.attrs.colwidth&&(t["data-colwidth"]=n.attrs.colwidth.join(","));for(const r in e){const o=e[r].setDOMAttr;o&&o(n.attrs[r],t)}return t}function cg(n){if(n!==null){if(!Array.isArray(n))throw new TypeError("colwidth must be null or an array");for(const e of n)if(typeof e!="number")throw new TypeError("colwidth must be null or an array of numbers")}}function ug(n){const e=n.cellAttributes||{},t={colspan:{default:1,validate:"number"},rowspan:{default:1,validate:"number"},colwidth:{default:null,validate:cg}};for(const r in e)t[r]={default:e[r].default,validate:e[r].validate};return{table:{content:"table_row+",tableRole:"table",isolating:!0,group:n.tableGroup,parseDOM:[{tag:"table"}],toDOM(){return["table",["tbody",0]]}},table_row:{content:"(table_cell | table_header)*",tableRole:"row",parseDOM:[{tag:"tr"}],toDOM(){return["tr",0]}},table_cell:{content:n.cellContent,attrs:t,tableRole:"cell",isolating:!0,parseDOM:[{tag:"td",getAttrs:r=>Oc(r,e)}],toDOM(r){return["td",Tc(r,e),0]}},table_header:{content:n.cellContent,attrs:t,tableRole:"header_cell",isolating:!0,parseDOM:[{tag:"th",getAttrs:r=>Oc(r,e)}],toDOM(r){return["th",Tc(r,e),0]}}}}function pe(n){let e=n.cached.tableNodeTypes;if(!e){e=n.cached.tableNodeTypes={};for(const t in n.nodes){const r=n.nodes[t],o=r.spec.tableRole;o&&(e[o]=r)}}return e}var Ct=new lt("selectingCells");function Gn(n){for(let e=n.depth-1;e>0;e--)if(n.node(e).type.spec.tableRole=="row")return n.node(0).resolve(n.before(e+1));return null}function fg(n){for(let e=n.depth;e>0;e--){const t=n.node(e).type.spec.tableRole;if(t==="cell"||t==="header_cell")return n.node(e)}return null}function Oe(n){const e=n.selection.$head;for(let t=e.depth;t>0;t--)if(e.node(t).type.spec.tableRole=="row")return!0;return!1}function _r(n){const e=n.selection;if("$anchorCell"in e&&e.$anchorCell)return e.$anchorCell.pos>e.$headCell.pos?e.$anchorCell:e.$headCell;if("node"in e&&e.node&&e.node.type.spec.tableRole=="cell")return e.$anchor;const t=Gn(e.$head)||dg(e.$head);if(t)return t;throw new RangeError(`No cell found around position ${e.head}`)}function dg(n){for(let e=n.nodeAfter,t=n.pos;e;e=e.firstChild,t++){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return n.doc.resolve(t)}for(let e=n.nodeBefore,t=n.pos;e;e=e.lastChild,t--){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return n.doc.resolve(t-e.nodeSize)}}function vc(n){return n.parent.type.spec.tableRole=="row"&&!!n.nodeAfter}function hg(n){return n.node(0).resolve(n.pos+n.nodeAfter.nodeSize)}function Ps(n,e){return n.depth==e.depth&&n.pos>=e.start(-1)&&n.pos<=e.end(-1)}function Ac(n,e,t){const r=n.node(-1),o=Q.get(r),s=n.start(-1),i=o.nextCell(n.pos-s,e,t);return i==null?null:n.node(0).resolve(s+i)}function qt(n,e,t=1){const r={...n,colspan:n.colspan-t};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(e,t),r.colwidth.some(o=>o>0)||(r.colwidth=null)),r}function Pc(n,e,t=1){const r={...n,colspan:n.colspan+t};if(r.colwidth){r.colwidth=r.colwidth.slice();for(let o=0;o<t;o++)r.colwidth.splice(e,0,0)}return r}function pg(n,e,t){const r=pe(e.type.schema).header_cell;for(let o=0;o<n.height;o++)if(e.nodeAt(n.map[t+o*n.width]).type!=r)return!1;return!0}var W=class ot extends R{constructor(e,t=e){const r=e.node(-1),o=Q.get(r),s=e.start(-1),i=o.rectBetween(e.pos-s,t.pos-s),l=e.node(0),a=o.cellsInRect(i).filter(u=>u!=t.pos-s);a.unshift(t.pos-s);const c=a.map(u=>{const f=r.nodeAt(u);if(!f)throw RangeError(`No cell with offset ${u} found`);const d=s+u+1;return new tl(l.resolve(d),l.resolve(d+f.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=e,this.$headCell=t}map(e,t){const r=e.resolve(t.map(this.$anchorCell.pos)),o=e.resolve(t.map(this.$headCell.pos));if(vc(r)&&vc(o)&&Ps(r,o)){const s=this.$anchorCell.node(-1)!=r.node(-1);return s&&this.isRowSelection()?ot.rowSelection(r,o):s&&this.isColSelection()?ot.colSelection(r,o):new ot(r,o)}return P.between(r,o)}content(){const e=this.$anchorCell.node(-1),t=Q.get(e),r=this.$anchorCell.start(-1),o=t.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),s={},i=[];for(let a=o.top;a<o.bottom;a++){const c=[];for(let u=a*t.width+o.left,f=o.left;f<o.right;f++,u++){const d=t.map[u];if(s[d])continue;s[d]=!0;const h=t.findCell(d);let p=e.nodeAt(d);if(!p)throw RangeError(`No cell with offset ${d} found`);const b=o.left-h.left,g=h.right-o.right;if(b>0||g>0){let k=p.attrs;if(b>0&&(k=qt(k,0,b)),g>0&&(k=qt(k,k.colspan-g,g)),h.left<o.left){if(p=p.type.createAndFill(k),!p)throw RangeError(`Could not create cell with attrs ${JSON.stringify(k)}`)}else p=p.type.create(k,p.content)}if(h.top<o.top||h.bottom>o.bottom){const k={...p.attrs,rowspan:Math.min(h.bottom,o.bottom)-Math.max(h.top,o.top)};h.top<o.top?p=p.type.createAndFill(k):p=p.type.create(k,p.content)}c.push(p)}i.push(e.child(a).copy(C.from(c)))}const l=this.isColSelection()&&this.isRowSelection()?e:i;return new N(C.from(l),1,1)}replace(e,t=N.empty){const r=e.steps.length,o=this.ranges;for(let i=0;i<o.length;i++){const{$from:l,$to:a}=o[i],c=e.mapping.slice(r);e.replace(c.map(l.pos),c.map(a.pos),i?N.empty:t)}const s=R.findFrom(e.doc.resolve(e.mapping.slice(r).map(this.to)),-1);s&&e.setSelection(s)}replaceWith(e,t){this.replace(e,new N(C.from(t),0,0))}forEachCell(e){const t=this.$anchorCell.node(-1),r=Q.get(t),o=this.$anchorCell.start(-1),s=r.cellsInRect(r.rectBetween(this.$anchorCell.pos-o,this.$headCell.pos-o));for(let i=0;i<s.length;i++)e(t.nodeAt(s[i]),o+s[i])}isColSelection(){const e=this.$anchorCell.index(-1),t=this.$headCell.index(-1);if(Math.min(e,t)>0)return!1;const r=e+this.$anchorCell.nodeAfter.attrs.rowspan,o=t+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(r,o)==this.$headCell.node(-1).childCount}static colSelection(e,t=e){const r=e.node(-1),o=Q.get(r),s=e.start(-1),i=o.findCell(e.pos-s),l=o.findCell(t.pos-s),a=e.node(0);return i.top<=l.top?(i.top>0&&(e=a.resolve(s+o.map[i.left])),l.bottom<o.height&&(t=a.resolve(s+o.map[o.width*(o.height-1)+l.right-1]))):(l.top>0&&(t=a.resolve(s+o.map[l.left])),i.bottom<o.height&&(e=a.resolve(s+o.map[o.width*(o.height-1)+i.right-1]))),new ot(e,t)}isRowSelection(){const e=this.$anchorCell.node(-1),t=Q.get(e),r=this.$anchorCell.start(-1),o=t.colCount(this.$anchorCell.pos-r),s=t.colCount(this.$headCell.pos-r);if(Math.min(o,s)>0)return!1;const i=o+this.$anchorCell.nodeAfter.attrs.colspan,l=s+this.$headCell.nodeAfter.attrs.colspan;return Math.max(i,l)==t.width}eq(e){return e instanceof ot&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,t=e){const r=e.node(-1),o=Q.get(r),s=e.start(-1),i=o.findCell(e.pos-s),l=o.findCell(t.pos-s),a=e.node(0);return i.left<=l.left?(i.left>0&&(e=a.resolve(s+o.map[i.top*o.width])),l.right<o.width&&(t=a.resolve(s+o.map[o.width*(l.top+1)-1]))):(l.left>0&&(t=a.resolve(s+o.map[l.top*o.width])),i.right<o.width&&(e=a.resolve(s+o.map[o.width*(i.top+1)-1]))),new ot(e,t)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,t){return new ot(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,r=t){return new ot(e.resolve(t),e.resolve(r))}getBookmark(){return new mg(this.$anchorCell.pos,this.$headCell.pos)}};W.prototype.visible=!1,R.jsonID("cell",W);var mg=class mf{constructor(e,t){this.anchor=e,this.head=t}map(e){return new mf(e.map(this.anchor),e.map(this.head))}resolve(e){const t=e.resolve(this.anchor),r=e.resolve(this.head);return t.parent.type.spec.tableRole=="row"&&r.parent.type.spec.tableRole=="row"&&t.index()<t.parent.childCount&&r.index()<r.parent.childCount&&Ps(t,r)?new W(t,r):R.near(r,1)}};function gg(n){if(!(n.selection instanceof W))return null;const e=[];return n.selection.forEachCell((t,r)=>{e.push(qe.node(r,r+t.nodeSize,{class:"selectedCell"}))}),U.create(n.doc,e)}function yg({$from:n,$to:e}){if(n.pos==e.pos||n.pos<e.pos-6)return!1;let t=n.pos,r=e.pos,o=n.depth;for(;o>=0&&!(n.after(o+1)<n.end(o));o--,t++);for(let s=e.depth;s>=0&&!(e.before(s+1)>e.start(s));s--,r--);return t==r&&/row|table/.test(n.node(o).type.spec.tableRole)}function bg({$from:n,$to:e}){let t,r;for(let o=n.depth;o>0;o--){const s=n.node(o);if(s.type.spec.tableRole==="cell"||s.type.spec.tableRole==="header_cell"){t=s;break}}for(let o=e.depth;o>0;o--){const s=e.node(o);if(s.type.spec.tableRole==="cell"||s.type.spec.tableRole==="header_cell"){r=s;break}}return t!==r&&e.parentOffset===0}function xg(n,e,t){const r=(e||n).selection,o=(e||n).doc;let s,i;if(r instanceof D&&(i=r.node.type.spec.tableRole)){if(i=="cell"||i=="header_cell")s=W.create(o,r.from);else if(i=="row"){const l=o.resolve(r.from+1);s=W.rowSelection(l,l)}else if(!t){const l=Q.get(r.node),a=r.from+1,c=a+l.map[l.width*l.height-1];s=W.create(o,a+1,c)}}else r instanceof P&&yg(r)?s=P.create(o,r.from):r instanceof P&&bg(r)&&(s=P.create(o,r.$from.start(),r.$from.end()));return s&&(e||(e=n.tr)).setSelection(s),e}var kg=new lt("fix-tables");function Ic(n,e,t,r){const o=n.childCount,s=e.childCount;e:for(let i=0,l=0;i<s;i++){const a=e.child(i);for(let c=l,u=Math.min(o,i+3);c<u;c++)if(n.child(c)==a){l=c+1,t+=a.nodeSize;continue e}r(a,t),l<o&&n.child(l).sameMarkup(a)?Ic(n.child(l),a,t+1,r):a.nodesBetween(0,a.content.size,r,t+1),t+=a.nodeSize}}function Is(n,e){let t;const r=(o,s)=>{o.type.spec.tableRole=="table"&&(t=Sg(n,o,s,t))};return e?e.doc!=n.doc&&Ic(e.doc,n.doc,0,r):n.doc.descendants(r),t}function Sg(n,e,t,r){const o=Q.get(e);if(!o.problems)return r;r||(r=n.tr);const s=[];for(let a=0;a<o.height;a++)s.push(0);for(let a=0;a<o.problems.length;a++){const c=o.problems[a];if(c.type=="collision"){const u=e.nodeAt(c.pos);if(!u)continue;const f=u.attrs;for(let d=0;d<f.rowspan;d++)s[c.row+d]+=c.n;r.setNodeMarkup(r.mapping.map(t+1+c.pos),null,qt(f,f.colspan-c.n,c.n))}else if(c.type=="missing")s[c.row]+=c.n;else if(c.type=="overlong_rowspan"){const u=e.nodeAt(c.pos);if(!u)continue;r.setNodeMarkup(r.mapping.map(t+1+c.pos),null,{...u.attrs,rowspan:u.attrs.rowspan-c.n})}else if(c.type=="colwidth mismatch"){const u=e.nodeAt(c.pos);if(!u)continue;r.setNodeMarkup(r.mapping.map(t+1+c.pos),null,{...u.attrs,colwidth:c.colwidth})}else if(c.type=="zero_sized"){const u=r.mapping.map(t);r.delete(u,u+e.nodeSize)}}let i,l;for(let a=0;a<s.length;a++)s[a]&&(i==null&&(i=a),l=a);for(let a=0,c=t+1;a<o.height;a++){const u=e.child(a),f=c+u.nodeSize,d=s[a];if(d>0){let h="cell";u.firstChild&&(h=u.firstChild.type.spec.tableRole);const p=[];for(let g=0;g<d;g++){const k=pe(n.schema)[h].createAndFill();k&&p.push(k)}const b=(a==0||i==a-1)&&l==a?c+1:f-1;r.insert(r.mapping.map(b),p)}c=f}return r.setMeta(kg,{fixTables:!0})}function He(n){const e=n.selection,t=_r(n),r=t.node(-1),o=t.start(-1),s=Q.get(r);return{...e instanceof W?s.rectBetween(e.$anchorCell.pos-o,e.$headCell.pos-o):s.findCell(t.pos-o),tableStart:o,map:s,table:r}}function Vc(n,{map:e,tableStart:t,table:r},o){let s=o>0?-1:0;pg(e,r,o+s)&&(s=o==0||o==e.width?null:0);for(let i=0;i<e.height;i++){const l=i*e.width+o;if(o>0&&o<e.width&&e.map[l-1]==e.map[l]){const a=e.map[l],c=r.nodeAt(a);n.setNodeMarkup(n.mapping.map(t+a),null,Pc(c.attrs,o-e.colCount(a))),i+=c.attrs.rowspan-1}else{const a=s==null?pe(r.type.schema).cell:r.nodeAt(e.map[l+s]).type,c=e.positionAt(i,o,r);n.insert(n.mapping.map(t+c),a.createAndFill())}}return n}function Cg(n,e){if(!Oe(n))return!1;if(e){const t=He(n);e(Vc(n.tr,t,t.left))}return!0}function wg(n,e){if(!Oe(n))return!1;if(e){const t=He(n);e(Vc(n.tr,t,t.right))}return!0}function Mg(n,{map:e,table:t,tableStart:r},o){const s=n.mapping.maps.length;for(let i=0;i<e.height;){const l=i*e.width+o,a=e.map[l],c=t.nodeAt(a),u=c.attrs;if(o>0&&e.map[l-1]==a||o<e.width-1&&e.map[l+1]==a)n.setNodeMarkup(n.mapping.slice(s).map(r+a),null,qt(u,o-e.colCount(a)));else{const f=n.mapping.slice(s).map(r+a);n.delete(f,f+c.nodeSize)}i+=u.rowspan}}function Ng(n,e){if(!Oe(n))return!1;if(e){const t=He(n),r=n.tr;if(t.left==0&&t.right==t.map.width)return!1;for(let o=t.right-1;Mg(r,t,o),o!=t.left;o--){const s=t.tableStart?r.doc.nodeAt(t.tableStart-1):r.doc;if(!s)throw RangeError("No table found");t.table=s,t.map=Q.get(s)}e(r)}return!0}function Eg(n,e,t){var r;const o=pe(e.type.schema).header_cell;for(let s=0;s<n.width;s++)if(((r=e.nodeAt(n.map[s+t*n.width]))==null?void 0:r.type)!=o)return!1;return!0}function Rc(n,{map:e,tableStart:t,table:r},o){var s;let i=t;for(let c=0;c<o;c++)i+=r.child(c).nodeSize;const l=[];let a=o>0?-1:0;Eg(e,r,o+a)&&(a=o==0||o==e.height?null:0);for(let c=0,u=e.width*o;c<e.width;c++,u++)if(o>0&&o<e.height&&e.map[u]==e.map[u-e.width]){const f=e.map[u],d=r.nodeAt(f).attrs;n.setNodeMarkup(t+f,null,{...d,rowspan:d.rowspan+1}),c+=d.colspan-1}else{const f=a==null?pe(r.type.schema).cell:(s=r.nodeAt(e.map[u+a*e.width]))==null?void 0:s.type,d=f==null?void 0:f.createAndFill();d&&l.push(d)}return n.insert(i,pe(r.type.schema).row.create(null,l)),n}function Dg(n,e){if(!Oe(n))return!1;if(e){const t=He(n);e(Rc(n.tr,t,t.top))}return!0}function Og(n,e){if(!Oe(n))return!1;if(e){const t=He(n);e(Rc(n.tr,t,t.bottom))}return!0}function Tg(n,{map:e,table:t,tableStart:r},o){let s=0;for(let c=0;c<o;c++)s+=t.child(c).nodeSize;const i=s+t.child(o).nodeSize,l=n.mapping.maps.length;n.delete(s+r,i+r);const a=new Set;for(let c=0,u=o*e.width;c<e.width;c++,u++){const f=e.map[u];if(!a.has(f)){if(a.add(f),o>0&&f==e.map[u-e.width]){const d=t.nodeAt(f).attrs;n.setNodeMarkup(n.mapping.slice(l).map(f+r),null,{...d,rowspan:d.rowspan-1}),c+=d.colspan-1}else if(o<e.height&&f==e.map[u+e.width]){const d=t.nodeAt(f),h=d.attrs,p=d.type.create({...h,rowspan:d.attrs.rowspan-1},d.content),b=e.positionAt(o+1,c,t);n.insert(n.mapping.slice(l).map(r+b),p),c+=h.colspan-1}}}}function vg(n,e){if(!Oe(n))return!1;if(e){const t=He(n),r=n.tr;if(t.top==0&&t.bottom==t.map.height)return!1;for(let o=t.bottom-1;Tg(r,t,o),o!=t.top;o--){const s=t.tableStart?r.doc.nodeAt(t.tableStart-1):r.doc;if(!s)throw RangeError("No table found");t.table=s,t.map=Q.get(t.table)}e(r)}return!0}function zc(n){const e=n.content;return e.childCount==1&&e.child(0).isTextblock&&e.child(0).childCount==0}function Ag({width:n,height:e,map:t},r){let o=r.top*n+r.left,s=o,i=(r.bottom-1)*n+r.left,l=o+(r.right-r.left-1);for(let a=r.top;a<r.bottom;a++){if(r.left>0&&t[s]==t[s-1]||r.right<n&&t[l]==t[l+1])return!0;s+=n,l+=n}for(let a=r.left;a<r.right;a++){if(r.top>0&&t[o]==t[o-n]||r.bottom<e&&t[i]==t[i+n])return!0;o++,i++}return!1}function Pg(n,e){const t=n.selection;if(!(t instanceof W)||t.$anchorCell.pos==t.$headCell.pos)return!1;const r=He(n),{map:o}=r;if(Ag(o,r))return!1;if(e){const s=n.tr,i={};let l=C.empty,a,c;for(let u=r.top;u<r.bottom;u++)for(let f=r.left;f<r.right;f++){const d=o.map[u*o.width+f],h=r.table.nodeAt(d);if(!(i[d]||!h))if(i[d]=!0,a==null)a=d,c=h;else{zc(h)||(l=l.append(h.content));const p=s.mapping.map(d+r.tableStart);s.delete(p,p+h.nodeSize)}}if(a==null||c==null)return!0;if(s.setNodeMarkup(a+r.tableStart,null,{...Pc(c.attrs,c.attrs.colspan,r.right-r.left-c.attrs.colspan),rowspan:r.bottom-r.top}),l.size){const u=a+1+c.content.size,f=zc(c)?a+1:u;s.replaceWith(f+r.tableStart,u+r.tableStart,l)}s.setSelection(new W(s.doc.resolve(a+r.tableStart))),e(s)}return!0}function Ig(n,e){const t=pe(n.schema);return Vg(({node:r})=>t[r.type.spec.tableRole])(n,e)}function Vg(n){return(e,t)=>{var r;const o=e.selection;let s,i;if(o instanceof W){if(o.$anchorCell.pos!=o.$headCell.pos)return!1;s=o.$anchorCell.nodeAfter,i=o.$anchorCell.pos}else{if(s=fg(o.$from),!s)return!1;i=(r=Gn(o.$from))==null?void 0:r.pos}if(s==null||i==null||s.attrs.colspan==1&&s.attrs.rowspan==1)return!1;if(t){let l=s.attrs;const a=[],c=l.colwidth;l.rowspan>1&&(l={...l,rowspan:1}),l.colspan>1&&(l={...l,colspan:1});const u=He(e),f=e.tr;for(let h=0;h<u.right-u.left;h++)a.push(c?{...l,colwidth:c&&c[h]?[c[h]]:null}:l);let d;for(let h=u.top;h<u.bottom;h++){let p=u.map.positionAt(h,u.left,u.table);h==u.top&&(p+=s.nodeSize);for(let b=u.left,g=0;b<u.right;b++,g++)b==u.left&&h==u.top||f.insert(d=f.mapping.map(p+u.tableStart,1),n({node:s,row:h,col:b}).createAndFill(a[g]))}f.setNodeMarkup(i,n({node:s,row:u.top,col:u.left}),a[0]),o instanceof W&&f.setSelection(new W(f.doc.resolve(o.$anchorCell.pos),d?f.doc.resolve(d):void 0)),t(f)}return!0}}function mn(n,e){return function(t,r){if(!Oe(t))return!1;const o=_r(t);if(o.nodeAfter.attrs[n]===e)return!1;if(r){const s=t.tr;t.selection instanceof W?t.selection.forEachCell((i,l)=>{i.attrs[n]!==e&&s.setNodeMarkup(l,null,{...i.attrs,[n]:e})}):s.setNodeMarkup(o.pos,null,{...o.nodeAfter.attrs,[n]:e}),r(s)}return!0}}function Rg(n){return function(e,t){if(!Oe(e))return!1;if(t){const r=pe(e.schema),o=He(e),s=e.tr,i=o.map.cellsInRect(n=="column"?{left:o.left,top:0,right:o.right,bottom:o.map.height}:n=="row"?{left:0,top:o.top,right:o.map.width,bottom:o.bottom}:o),l=i.map(a=>o.table.nodeAt(a));for(let a=0;a<i.length;a++)l[a].type==r.header_cell&&s.setNodeMarkup(o.tableStart+i[a],r.cell,l[a].attrs);if(s.steps.length==0)for(let a=0;a<i.length;a++)s.setNodeMarkup(o.tableStart+i[a],r.header_cell,l[a].attrs);t(s)}return!0}}function $c(n,e,t){const r=e.map.cellsInRect({left:0,top:0,right:n=="row"?e.map.width:1,bottom:n=="column"?e.map.height:1});for(let o=0;o<r.length;o++){const s=e.table.nodeAt(r[o]);if(s&&s.type!==t.header_cell)return!1}return!0}function Vs(n,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?Rg(n):function(t,r){if(!Oe(t))return!1;if(r){const o=pe(t.schema),s=He(t),i=t.tr,l=$c("row",s,o),a=$c("column",s,o),u=(n==="column"?l:n==="row"?a:!1)?1:0,f=n=="column"?{left:0,top:u,right:1,bottom:s.map.height}:n=="row"?{left:u,top:0,right:s.map.width,bottom:1}:s,d=n=="column"?a?o.cell:o.header_cell:n=="row"?l?o.cell:o.header_cell:o.cell;s.map.cellsInRect(f).forEach(h=>{const p=h+s.tableStart,b=i.doc.nodeAt(p);b&&i.setNodeMarkup(p,d,b.attrs)}),r(i)}return!0}}var zg=Vs("row",{useDeprecatedLogic:!0}),$g=Vs("column",{useDeprecatedLogic:!0}),jg=Vs("cell",{useDeprecatedLogic:!0});function Bg(n,e){if(e<0){const t=n.nodeBefore;if(t)return n.pos-t.nodeSize;for(let r=n.index(-1)-1,o=n.before();r>=0;r--){const s=n.node(-1).child(r),i=s.lastChild;if(i)return o-1-i.nodeSize;o-=s.nodeSize}}else{if(n.index()<n.parent.childCount-1)return n.pos+n.nodeAfter.nodeSize;const t=n.node(-1);for(let r=n.indexAfter(-1),o=n.after();r<t.childCount;r++){const s=t.child(r);if(s.childCount)return o+1;o+=s.nodeSize}}return null}function jc(n){return function(e,t){if(!Oe(e))return!1;const r=Bg(_r(e),n);if(r==null)return!1;if(t){const o=e.doc.resolve(r);t(e.tr.setSelection(P.between(o,hg(o))).scrollIntoView())}return!0}}function Fg(n,e){const t=n.selection.$anchor;for(let r=t.depth;r>0;r--)if(t.node(r).type.spec.tableRole=="table")return e&&e(n.tr.delete(t.before(r),t.after(r)).scrollIntoView()),!0;return!1}function qr(n,e){const t=n.selection;if(!(t instanceof W))return!1;if(e){const r=n.tr,o=pe(n.schema).cell.createAndFill().content;t.forEachCell((s,i)=>{s.content.eq(o)||r.replace(r.mapping.map(i+1),r.mapping.map(i+s.nodeSize-1),new N(o,0,0))}),r.docChanged&&e(r)}return!0}function Lg(n){if(!n.size)return null;let{content:e,openStart:t,openEnd:r}=n;for(;e.childCount==1&&(t>0&&r>0||e.child(0).type.spec.tableRole=="table");)t--,r--,e=e.child(0).content;const o=e.child(0),s=o.type.spec.tableRole,i=o.type.schema,l=[];if(s=="row")for(let a=0;a<e.childCount;a++){let c=e.child(a).content;const u=a?0:Math.max(0,t-1),f=a<e.childCount-1?0:Math.max(0,r-1);(u||f)&&(c=Rs(pe(i).row,new N(c,u,f)).content),l.push(c)}else if(s=="cell"||s=="header_cell")l.push(t||r?Rs(pe(i).row,new N(e,t,r)).content:e);else return null;return Wg(i,l)}function Wg(n,e){const t=[];for(let o=0;o<e.length;o++){const s=e[o];for(let i=s.childCount-1;i>=0;i--){const{rowspan:l,colspan:a}=s.child(i).attrs;for(let c=o;c<o+l;c++)t[c]=(t[c]||0)+a}}let r=0;for(let o=0;o<t.length;o++)r=Math.max(r,t[o]);for(let o=0;o<t.length;o++)if(o>=e.length&&e.push(C.empty),t[o]<r){const s=pe(n).cell.createAndFill(),i=[];for(let l=t[o];l<r;l++)i.push(s);e[o]=e[o].append(C.from(i))}return{height:e.length,width:r,rows:e}}function Rs(n,e){const t=n.createAndFill();return new el(t).replace(0,t.content.size,e).doc}function _g({width:n,height:e,rows:t},r,o){if(n!=r){const s=[],i=[];for(let l=0;l<t.length;l++){const a=t[l],c=[];for(let u=s[l]||0,f=0;u<r;f++){let d=a.child(f%a.childCount);u+d.attrs.colspan>r&&(d=d.type.createChecked(qt(d.attrs,d.attrs.colspan,u+d.attrs.colspan-r),d.content)),c.push(d),u+=d.attrs.colspan;for(let h=1;h<d.attrs.rowspan;h++)s[l+h]=(s[l+h]||0)+d.attrs.colspan}i.push(C.from(c))}t=i,n=r}if(e!=o){const s=[];for(let i=0,l=0;i<o;i++,l++){const a=[],c=t[l%e];for(let u=0;u<c.childCount;u++){let f=c.child(u);i+f.attrs.rowspan>o&&(f=f.type.create({...f.attrs,rowspan:Math.max(1,o-f.attrs.rowspan)},f.content)),a.push(f)}s.push(C.from(a))}t=s,e=o}return{width:n,height:e,rows:t}}function qg(n,e,t,r,o,s,i){const l=n.doc.type.schema,a=pe(l);let c,u;if(o>e.width)for(let f=0,d=0;f<e.height;f++){const h=t.child(f);d+=h.nodeSize;const p=[];let b;h.lastChild==null||h.lastChild.type==a.cell?b=c||(c=a.cell.createAndFill()):b=u||(u=a.header_cell.createAndFill());for(let g=e.width;g<o;g++)p.push(b);n.insert(n.mapping.slice(i).map(d-1+r),p)}if(s>e.height){const f=[];for(let p=0,b=(e.height-1)*e.width;p<Math.max(e.width,o);p++){const g=p>=e.width?!1:t.nodeAt(e.map[b+p]).type==a.header_cell;f.push(g?u||(u=a.header_cell.createAndFill()):c||(c=a.cell.createAndFill()))}const d=a.row.create(null,C.from(f)),h=[];for(let p=e.height;p<s;p++)h.push(d);n.insert(n.mapping.slice(i).map(r+t.nodeSize-2),h)}return!!(c||u)}function Bc(n,e,t,r,o,s,i,l){if(i==0||i==e.height)return!1;let a=!1;for(let c=o;c<s;c++){const u=i*e.width+c,f=e.map[u];if(e.map[u-e.width]==f){a=!0;const d=t.nodeAt(f),{top:h,left:p}=e.findCell(f);n.setNodeMarkup(n.mapping.slice(l).map(f+r),null,{...d.attrs,rowspan:i-h}),n.insert(n.mapping.slice(l).map(e.positionAt(i,p,t)),d.type.createAndFill({...d.attrs,rowspan:h+d.attrs.rowspan-i})),c+=d.attrs.colspan-1}}return a}function Fc(n,e,t,r,o,s,i,l){if(i==0||i==e.width)return!1;let a=!1;for(let c=o;c<s;c++){const u=c*e.width+i,f=e.map[u];if(e.map[u-1]==f){a=!0;const d=t.nodeAt(f),h=e.colCount(f),p=n.mapping.slice(l).map(f+r);n.setNodeMarkup(p,null,qt(d.attrs,i-h,d.attrs.colspan-(i-h))),n.insert(p+d.nodeSize,d.type.createAndFill(qt(d.attrs,0,i-h))),c+=d.attrs.rowspan-1}}return a}function Lc(n,e,t,r,o){let s=t?n.doc.nodeAt(t-1):n.doc;if(!s)throw new Error("No table found");let i=Q.get(s);const{top:l,left:a}=r,c=a+o.width,u=l+o.height,f=n.tr;let d=0;function h(){if(s=t?f.doc.nodeAt(t-1):f.doc,!s)throw new Error("No table found");i=Q.get(s),d=f.mapping.maps.length}qg(f,i,s,t,c,u,d)&&h(),Bc(f,i,s,t,a,c,l,d)&&h(),Bc(f,i,s,t,a,c,u,d)&&h(),Fc(f,i,s,t,l,u,a,d)&&h(),Fc(f,i,s,t,l,u,c,d)&&h();for(let p=l;p<u;p++){const b=i.positionAt(p,a,s),g=i.positionAt(p,c,s);f.replace(f.mapping.slice(d).map(b+t),f.mapping.slice(d).map(g+t),new N(o.rows[p-l],0,0))}h(),f.setSelection(new W(f.doc.resolve(t+i.positionAt(l,a,s)),f.doc.resolve(t+i.positionAt(u-1,c-1,s)))),e(f)}var Hg=zo({ArrowLeft:Kr("horiz",-1),ArrowRight:Kr("horiz",1),ArrowUp:Kr("vert",-1),ArrowDown:Kr("vert",1),"Shift-ArrowLeft":Jr("horiz",-1),"Shift-ArrowRight":Jr("horiz",1),"Shift-ArrowUp":Jr("vert",-1),"Shift-ArrowDown":Jr("vert",1),Backspace:qr,"Mod-Backspace":qr,Delete:qr,"Mod-Delete":qr});function Hr(n,e,t){return t.eq(n.selection)?!1:(e&&e(n.tr.setSelection(t).scrollIntoView()),!0)}function Kr(n,e){return(t,r,o)=>{if(!o)return!1;const s=t.selection;if(s instanceof W)return Hr(t,r,R.near(s.$headCell,e));if(n!="horiz"&&!s.empty)return!1;const i=Wc(o,n,e);if(i==null)return!1;if(n=="horiz")return Hr(t,r,R.near(t.doc.resolve(s.head+e),e));{const l=t.doc.resolve(i),a=Ac(l,n,e);let c;return a?c=R.near(a,1):e<0?c=R.near(t.doc.resolve(l.before(-1)),-1):c=R.near(t.doc.resolve(l.after(-1)),1),Hr(t,r,c)}}}function Jr(n,e){return(t,r,o)=>{if(!o)return!1;const s=t.selection;let i;if(s instanceof W)i=s;else{const a=Wc(o,n,e);if(a==null)return!1;i=new W(t.doc.resolve(a))}const l=Ac(i.$headCell,n,e);return l?Hr(t,r,new W(i.$anchorCell,l)):!1}}function Kg(n,e){const t=n.state.doc,r=Gn(t.resolve(e));return r?(n.dispatch(n.state.tr.setSelection(new W(r))),!0):!1}function Jg(n,e,t){if(!Oe(n.state))return!1;let r=Lg(t);const o=n.state.selection;if(o instanceof W){r||(r={width:1,height:1,rows:[C.from(Rs(pe(n.state.schema).cell,t))]});const s=o.$anchorCell.node(-1),i=o.$anchorCell.start(-1),l=Q.get(s).rectBetween(o.$anchorCell.pos-i,o.$headCell.pos-i);return r=_g(r,l.right-l.left,l.bottom-l.top),Lc(n.state,n.dispatch,i,l,r),!0}else if(r){const s=_r(n.state),i=s.start(-1);return Lc(n.state,n.dispatch,i,Q.get(s.node(-1)).findCell(s.pos-i),r),!0}else return!1}function Yg(n,e){var t;if(e.ctrlKey||e.metaKey)return;const r=_c(n,e.target);let o;if(e.shiftKey&&n.state.selection instanceof W)s(n.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&r&&(o=Gn(n.state.selection.$anchor))!=null&&((t=zs(n,e))==null?void 0:t.pos)!=o.pos)s(o,e),e.preventDefault();else if(!r)return;function s(a,c){let u=zs(n,c);const f=Ct.getState(n.state)==null;if(!u||!Ps(a,u))if(f)u=a;else return;const d=new W(a,u);if(f||!n.state.selection.eq(d)){const h=n.state.tr.setSelection(d);f&&h.setMeta(Ct,a.pos),n.dispatch(h)}}function i(){n.root.removeEventListener("mouseup",i),n.root.removeEventListener("dragstart",i),n.root.removeEventListener("mousemove",l),Ct.getState(n.state)!=null&&n.dispatch(n.state.tr.setMeta(Ct,-1))}function l(a){const c=a,u=Ct.getState(n.state);let f;if(u!=null)f=n.state.doc.resolve(u);else if(_c(n,c.target)!=r&&(f=zs(n,e),!f))return i();f&&s(f,c)}n.root.addEventListener("mouseup",i),n.root.addEventListener("dragstart",i),n.root.addEventListener("mousemove",l)}function Wc(n,e,t){if(!(n.state.selection instanceof P))return null;const{$head:r}=n.state.selection;for(let o=r.depth-1;o>=0;o--){const s=r.node(o);if((t<0?r.index(o):r.indexAfter(o))!=(t<0?0:s.childCount))return null;if(s.type.spec.tableRole=="cell"||s.type.spec.tableRole=="header_cell"){const l=r.before(o),a=e=="vert"?t>0?"down":"up":t>0?"right":"left";return n.endOfTextblock(a)?l:null}}return null}function _c(n,e){for(;e&&e!=n.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function zs(n,e){const t=n.posAtCoords({left:e.clientX,top:e.clientY});return t&&t?Gn(n.state.doc.resolve(t.pos)):null}new lt("tableColumnResizing");function Gg({allowTableNodeSelection:n=!1}={}){return new Be({key:Ct,state:{init(){return null},apply(e,t){const r=e.getMeta(Ct);if(r!=null)return r==-1?null:r;if(t==null||!e.docChanged)return t;const{deleted:o,pos:s}=e.mapping.mapResult(t);return o?null:s}},props:{decorations:gg,handleDOMEvents:{mousedown:Yg},createSelectionBetween(e){return Ct.getState(e.state)!=null?e.state.selection:null},handleTripleClick:Kg,handleKeyDown:Hg,handlePaste:Jg},appendTransaction(e,t,r){return xg(r,Is(r,t),n)}})}const wt=m.createContext(null),Xg=m.createContext(null),qc=m.createContext(null),Yr=new WeakMap;function Ug(n){const e=Object.create(null);e.class="ProseMirror",e.contenteditable=String(n.editable),n.someProp("attributes",o=>{if(typeof o=="function"&&(o=o(n.state)),o)for(const s in o)s=="class"?e.class+=" "+o[s]:s=="style"?e.style=(e.style?e.style+";":"")+o[s]:!e[s]&&s!="contenteditable"&&s!="nodeName"&&(e[s]=String(o[s]))}),e.translate||(e.translate="no");const t=[Ve.node(0,n.state.doc.content.size,e)],r=Yr.get(n);return!r||r[0].to!==n.state.doc.content.size||!r[0].type.eq(t[0].type)?(Yr.set(n,t),t):r}const Qg=[],Zg={},$s=H.empty;let Hc=class Sn{constructor(e){j(this,"members");this.members=e}map(e,t){const r=this.members.map(o=>o.map(e,t,Zg));return Sn.from(r)}forChild(e,t){if(t.isLeaf)return H.empty;let r=[];for(let o=0;o<this.members.length;o++){const s=this.members[o].forChild(e,t);s!=$s&&(s instanceof Sn?r=r.concat(s.members):r.push(s))}return Sn.from(r)}eq(e){if(!(e instanceof Sn)||e.members.length!=this.members.length)return!1;for(let t=0;t<this.members.length;t++)if(!this.members[t].eq(e.members[t]))return!1;return!0}locals(e){let t,r=!0;for(let o=0;o<this.members.length;o++){const s=this.members[o].localsInner(e);if(s.length)if(!t)t=s;else{r&&(t=t.slice(),r=!1);for(let i=0;i<s.length;i++)t.push(s[i])}}return t?ey(r?t:t.sort(Kc)):Qg}static from(e){switch(e.length){case 0:return $s;case 1:return e[0];default:return new Sn(e.every(t=>t instanceof H)?e:e.reduce((t,r)=>t.concat(r instanceof H?r:r.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}};function Kc(n,e){return n.from-e.from||n.to-e.to}function ey(n){let e=n;for(let t=0;t<e.length-1;t++){const r=e[t];if(r.from!=r.to)for(let o=t+1;o<e.length;o++){const s=e[o];if(s.from==r.from){s.to!=r.to&&(e==n&&(e=n.slice()),e[o]=s.copy(s.from,r.to),Jc(e,o+1,s.copy(r.to,s.to)));continue}else{s.from<r.to&&(e==n&&(e=n.slice()),e[t]=r.copy(r.from,s.from),Jc(e,o,r.copy(s.from,r.to)));break}}}return e}function Jc(n,e,t){for(;e<n.length&&Kc(t,n[e])>0;)e++;n.splice(e,0,t)}const js=new WeakMap;function ty(n,e){const t=[];n.someProp("decorations",i=>{const l=i(n.state);l&&l!=$s&&t.push(l)}),e&&t.push(H.create(n.state.doc,[e]));const r=js.get(n);if(!r){const i=Hc.from(t);return js.set(n,i),i}let o=0,s=!0;if(r.forEachSet(i=>{t[o++]!==i&&(s=!1)}),o!==t.length&&(s=!1),!s){const i=Hc.from(t);return js.set(n,i),i}return r}const Bs=function(n){for(let e=0;;e++)if(n=n.previousSibling,!n)return e},Yc=function(n){const e=n.assignedSlot||n.parentNode;return e&&e.nodeType==11?e.host:e},ny=function(n,e,t,r){return t&&(Gc(n,e,t,r,-1)||Gc(n,e,t,r,1))},ry=/^(img|br|input|textarea|hr)$/i;function Gc(n,e,t,r,o){for(;;){if(n==t&&e==r)return!0;if(e==(o<0?0:Gr(n))){const s=n.parentNode;if(!s||s.nodeType!=1||sy(n)||ry.test(n.nodeName)||n.contentEditable=="false")return!1;e=Bs(n)+(o<0?0:1),n=s}else if(n.nodeType==1){if(n=n.childNodes[e+(o<0?-1:0)],n.contentEditable=="false")return!1;e=o<0?Gr(n):0}else return!1}}function Gr(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function oy(n,e,t){for(let r=e==0,o=e==Gr(n);r||o;){if(n==t)return!0;const s=Bs(n);if(n=n.parentNode,!n)return!1;r=r&&s==0,o=o&&s==Gr(n)}return!1}function sy(n){let e;for(let t=n;t&&!(e=t.pmViewDesc);t=t.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==n||e.contentDOM==n)}const Xc=function(n){return n.focusNode&&ny(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)},Uc=m.createContext(null);function J(){for(var n=arguments.length,e=new Array(n),t=0;t<n;t++)e[t]=arguments[t];typeof document>"u"||m.useLayoutEffect(...e)}function iy(n,e){const t=m.useContext(Uc);J(()=>t(n),e)}function Ke(n,e){const{view:t,flushSyncRef:r}=m.useContext(wt);iy(()=>{if(t!=null&&t.docView){r.current=!1;const o=n(t);return r.current=!0,o}},e&&[t,...e])}const ly=m.forwardRef(function(e,t){let{widget:r,getPos:o,...s}=e;const[i,l]=m.useState(!0),a=m.useRef(null);return m.useImperativeHandle(t,()=>a.current,[]),Ke(c=>{if(!c||!a.current)return;c.domObserver.disconnectSelection();const u=c.domSelection(),f=document.createRange(),d=a.current;d.nodeName=="IMG"&&d.parentNode?f.setEnd(d.parentNode,Bs(d)+1):f.setEnd(d,0),f.collapse(!1),u.removeAllRanges(),u.addRange(f),l(!1),c.domObserver.connectSelection()},[]),i?m.createElement("img",{ref:a,className:"ProseMirror-separator","mark-placeholder":"true",alt:"",...s}):null});function ay(n,e){if(n==e)return!0;for(const t in n)if(n[t]!==e[t])return!1;for(const t in e)if(!(t in n))return!1;return!0}const cy={side:0};class Xn{constructor(e,t){j(this,"Component");j(this,"side");j(this,"spec");this.Component=e,this.spec=t??cy,this.side=this.spec.side??0}map(e,t,r,o){const{pos:s,deleted:i}=e.mapResult(t.from+o,this.side<0?-1:1);return i?null:new Ve(s-r,s-r,this)}valid(){return!0}eq(e){return this==e||e instanceof Xn&&(this.spec.key&&this.spec.key==e.spec.key||this.Component==e.Component&&ay(this.spec,e.spec))}destroy(){}}function uy(n,e,t){return new Ve(n,n,new Xn(e,t))}function Fs(){return Math.floor(Math.random()*0xffffffffffff).toString(16)}const Un=new lt("@handlewithcare/react-prosemirror/reactKeys");function fy(){let n=!1;return new Be({key:Un,state:{init(e,t){const r={posToKey:new Map,keyToPos:new Map};return t.doc.descendants((o,s)=>{const i=Fs();return r.posToKey.set(s,i),r.keyToPos.set(i,s),!0}),r},apply(e,t,r,o){if(!e.docChanged||n)return t;const s=e.getMeta(Un),i=(s==null?void 0:s.type)==="bustKey"&&s.payload.key,l={posToKey:new Map,keyToPos:new Map},a=Array.from(t.posToKey.entries()).sort((c,u)=>{let[f]=c,[d]=u;return f-d});for(const[c,u]of a){const{pos:f,deleted:d}=e.mapping.mapResult(c);if(d)continue;let h=u;i===u&&(h=Fs()),l.posToKey.set(f,h),l.keyToPos.set(h,f)}return o.doc.descendants((c,u)=>{if(l.posToKey.has(u))return!0;const f=Fs();return l.posToKey.set(u,f),l.keyToPos.set(f,u),!0}),l}},props:{handleDOMEvents:{compositionstart:()=>{n=!0},compositionend:()=>{n=!1}}}})}function Ls(n,e){var i;let t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(e===null)return!1;const r=t.from??n.state.selection.from,o=t.to??n.state.selection.to;if(n.someProp("handleTextInput",l=>l(n,r,o,e)))return!0;const{tr:s}=n.state;if(t.marks&&s.ensureMarks(t.marks),s.insertText(e,r,o),t.bust){const l=n.state.doc.resolve(r),a=l.sharedDepth(o),c=l.start(a),u=(i=Un.getState(n.state))==null?void 0:i.posToKey.get(c-1);s.setMeta(Un,{type:"bustKey",payload:{key:u}})}return n.dispatch(s),!0}function dy(n){let e=null,t=null;return new Be({props:{handleDOMEvents:{compositionstart(r){var i;const{state:o}=r;r.dispatch(o.tr.deleteSelection());const s=o.selection.$from;return o.selection.empty&&(o.storedMarks||!s.textOffset&&s.parentOffset&&((i=s.nodeBefore)!=null&&i.marks.some(l=>l.type.spec.inclusive===!1)))&&n(uy(o.selection.from,ly,{key:"cursor-wrapper",marks:o.storedMarks??s.marks()})),t=o.storedMarks??s.marks(),r.input.composing=!0,!0},compositionupdate(){return!0},compositionend(r){if(r.input.composing=!1,e!==null)return Ls(r,e,{bust:!0,marks:t}),e=null,t=null,n(null),!0},beforeinput(r,o){var s,i;switch(o.preventDefault(),o.inputType){case"insertCompositionText":{if(o.data===null)break;e=o.data;break}case"insertReplacementText":{const l=o.getTargetRanges();(i=(s=o.dataTransfer)==null?void 0:s.items[0])==null||i.getAsString(a=>{for(const c of l){const u=r.posAtDOM(c.startContainer,c.startOffset,1),f=r.posAtDOM(c.endContainer,c.endOffset,1);Ls(r,a,{from:u,to:f})}});break}case"insertText":{Ls(r,o.data);break}case"deleteWordBackward":case"deleteContentBackward":case"deleteWordForward":case"deleteContentForward":case"deleteContent":{const l=o.getTargetRanges(),{tr:a}=r.state;for(const c of l){const u=r.posAtDOM(c.startContainer,c.startOffset),f=r.posAtDOM(c.endContainer,c.endOffset),{doc:d}=r.state,h=d.resolve(u).marksAcross(d.resolve(f));a.delete(u,f).setStoredMarks(h)}r.dispatch(a);break}}return!0}}}})}const Je=typeof navigator<"u"?navigator:null,Qc=typeof document<"u"?document:null,Ht=Je&&Je.userAgent||"",Ws=/Edge\/(\d+)/.exec(Ht),Zc=/MSIE \d/.exec(Ht),_s=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Ht),Xr=!!(Zc||_s||Ws),hy=Zc?document.documentMode:_s?+_s[1]:Ws?+Ws[1]:0,eu=!Xr&&/gecko\/(\d+)/i.test(Ht);eu&&+(/Firefox\/(\d+)/.exec(Ht)||[0,0])[1];const qs=!Xr&&/Chrome\/(\d+)/.exec(Ht),py=!!qs,my=qs?+qs[1]:0,tu=!Xr&&!!Je&&/Apple Computer/.test(Je.vendor);tu&&(/Mobile\/\w+/.test(Ht)||!!Je&&Je.maxTouchPoints>2)||Je&&/Mac/.test(Je.platform),Je&&/Win/.test(Je.platform),!!Qc&&"webkitFontSmoothing"in Qc.documentElement.style&&+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1];const ae={ie:Xr,ie_version:hy,gecko:eu,chrome:py,chrome_version:my,safari:tu};function nu(n){return n.editable&&!n.hasFocus()?!1:gy(n)}function gy(n){var t,r;const e=n.domSelectionRange();if(!e.anchorNode)return!1;try{return n.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(n.editable||n.dom.contains(((t=e.focusNode)==null?void 0:t.nodeType)==3?(r=e.focusNode)==null?void 0:r.parentNode:e.focusNode))}catch{return!1}}function yy(n,e,t,r){return n.someProp("createSelectionBetween",o=>o(n,e,t))||P.between(e,t,r)}function ru(n){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null;const t=n.domSelectionRange(),r=n.state.doc;if(!t.focusNode)return null;let o=n.docView.nearestDesc(t.focusNode);const s=o&&o.size==0;let i=n.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(i<0)return null;let l=r.resolve(i),a,c;if(Xc(t)){for(a=i;o&&!o.node;)o=o.parent;const f=o.node;if(o&&f.isAtom&&D.isSelectable(f)&&o.parent&&!(f.isInline&&oy(t.focusNode,t.focusOffset,o.dom))){const d=o.posBefore;c=new D(i==d?l:r.resolve(d))}}else{if(t instanceof n.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let f=i,d=i;for(let h=0;h<t.rangeCount;h++){const p=t.getRangeAt(h);f=Math.min(f,n.docView.posFromDOM(p.startContainer,p.startOffset,1)),d=Math.max(d,n.docView.posFromDOM(p.endContainer,p.endOffset,-1))}if(f<0)return null;[a,i]=d==n.state.selection.anchor?[d,f]:[f,d],l=r.resolve(i)}else a=n.docView.posFromDOM(t.anchorNode,t.anchorOffset,1);if(a<0)return null}const u=r.resolve(a);if(!c){const f=e=="pointer"||n.state.selection.head<l.pos&&!s?1:-1;c=yy(n,u,l,f)}return c}const Ur=function(n,e,t,r){return t&&(ou(n,e,t,r,-1)||ou(n,e,t,r,1))};function by(n){let e;for(let t=n;t&&!(e=t.pmViewDesc);t=t.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==n||e.contentDOM==n)}const xy=/^(img|br|input|textarea|hr)$/i;function ou(n,e,t,r,o){for(;;){if(n==t&&e==r)return!0;if(e==(o<0?0:su(n))){const s=n.parentNode;if(!s||s.nodeType!=1||by(n)||xy.test(n.nodeName)||n.contentEditable=="false")return!1;e=Mt(n)+(o<0?0:1),n=s}else if(n.nodeType==1){if(n=n.childNodes[e+(o<0?-1:0)],n.contentEditable=="false")return!1;e=o<0?su(n):0}else return!1}}const Mt=function(n){let e=n;for(let t=0;;t++)if(e=e.previousSibling,!e)return t};function su(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function ky(n,e){const t=n;if(e instanceof D){const r=t.docView.descAt(e.from);r!=t.lastSelectedViewDesc&&(iu(t),r&&r.selectNode(),t.lastSelectedViewDesc=r)}else iu(t)}function iu(n){const e=n;e.lastSelectedViewDesc&&(e.lastSelectedViewDesc.parent&&e.lastSelectedViewDesc.deselectNode(),e.lastSelectedViewDesc=void 0)}function Sy(n){const e=n,t=e.domSelectionRange();if(!t.anchorNode)return!1;try{return e.dom.contains(t.anchorNode.nodeType==3?t.anchorNode.parentNode:t.anchorNode)&&(e.editable||e.dom.contains(t.focusNode.nodeType==3?t.focusNode.parentNode:t.focusNode))}catch{return!1}}function lu(n){return n.editable?n.hasFocus():Sy(n)&&document.activeElement&&document.activeElement.contains(n.dom)}function Cy(n){const e=n,t=e.domSelection(),r=document.createRange();if(!t)return;const o=e.cursorWrapper.dom,s=o.nodeName=="IMG";s?r.setStart(o.parentNode,Mt(o)+1):r.setStart(o,0),r.collapse(!0),t.removeAllRanges(),t.addRange(r),!s&&!e.state.selection.visible&&ae.ie&&ae.ie_version<=11&&(o.disabled=!0,o.disabled=!1)}function au(n,e){const t=n,{node:r,offset:o}=t.docView.domFromPos(e,0),s=o<r.childNodes.length?r.childNodes[o]:null,i=o?r.childNodes[o-1]:null;if(ae.safari&&s&&s.contentEditable=="false")return Hs(s);if((!s||s.contentEditable=="false")&&(!i||i.contentEditable=="false")){if(s)return Hs(s);if(i)return Hs(i)}}function Hs(n){return n.contentEditable="true",ae.safari&&n.draggable&&(n.draggable=!1,n.wasDraggable=!0),n}function cu(n){n.contentEditable="false",n.wasDraggable&&(n.draggable=!0,n.wasDraggable=null)}function wy(n){const e=n,t=e.dom.ownerDocument;t.removeEventListener("selectionchange",e.input.hideSelectionGuard);const r=e.domSelectionRange(),o=r.anchorNode,s=r.anchorOffset;t.addEventListener("selectionchange",e.input.hideSelectionGuard=()=>{(r.anchorNode!=o||r.anchorOffset!=s)&&(t.removeEventListener("selectionchange",e.input.hideSelectionGuard),setTimeout(()=>{(!lu(e)||e.state.selection.visible)&&e.dom.classList.remove("ProseMirror-hideselection")},20))})}const uu=ae.safari||ae.chrome&&ae.chrome_version<63;function Qr(n){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;const t=n,r=t.state.selection;if(ky(t,r),!!lu(t)){if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&ae.chrome){const o=t.domSelectionRange(),s=t.domObserver.currentSelection;if(o.anchorNode&&s.anchorNode&&Ur(o.anchorNode,o.anchorOffset,s.anchorNode,s.anchorOffset)){t.input.mouseDown.delayedSelectionSync=!0,t.domObserver.setCurSelection();return}}if(t.domObserver.disconnectSelection(),t.cursorWrapper)Cy(t);else{const{anchor:o,head:s}=r;let i,l;uu&&!(r instanceof P)&&(r.$from.parent.inlineContent||(i=au(t,r.from)),!r.empty&&!r.$from.parent.inlineContent&&(l=au(t,r.to))),t.docView.setSelection(o,s,t,e),uu&&(i&&cu(i),l&&cu(l)),r.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&wy(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}}let My=class{constructor(){j(this,"anchorNode",null);j(this,"anchorOffset",0);j(this,"focusNode",null);j(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 Ny{constructor(e){j(this,"view");j(this,"flushingSoon");j(this,"currentSelection");j(this,"suppressingSelectionUpdates");this.view=e,this.flushingSoon=-1,this.currentSelection=new My,this.suppressingSelectionUpdates=!1,this.view=e,this.onSelectionChange=this.onSelectionChange.bind(this)}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}stop(){this.disconnectSelection()}start(){this.connectSelection()}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;const t=new Set;let r;for(let s=e.focusNode;s;s=Yc(s))t.add(s);for(let s=e.anchorNode;s;s=Yc(s))if(t.has(s)){r=s;break}const o=r&&this.view.docView.nearestDesc(r);if(o&&o.ignoreMutation({type:"selection",target:(r==null?void 0:r.nodeType)==3?r==null?void 0:r.parentNode:r}))return this.setCurSelection(),!0}registerMutation(){}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}updateSelection(){const{view:e}=this,t=e.input.compositionPendingChanges||(e.composing?e.input.compositionID:0);e.input.compositionPendingChanges=0;const r=e.input.lastSelectionTime>Date.now()-50?e.input.lastSelectionOrigin:null,o=ru(e,r);if(o&&!e.state.selection.eq(o)){const s=e.state.tr.setSelection(o);r=="pointer"?s.setMeta("pointer",!0):r=="key"&&s.scrollIntoView(),t&&s.setMeta("composition",t),e.dispatch(s)}}selectionToDOM(){const{view:e}=this;Qr(e);const t=e.domSelectionRange();this.currentSelection.set(t)}flush(){const{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;const t=e.domSelectionRange(),r=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(t)&&nu(e)&&!this.ignoreSelectionChange(t);let o=null;r&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&Xc(t)&&(o=ru(e))&&o.eq(R.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,Qr(e),this.currentSelection.set(t),e.scrollToSelection()):r&&(this.updateSelection(),this.currentSelection.eq(t)||Qr(e),this.currentSelection.set(t))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}onSelectionChange(){if(nu(this.view)&&!this.view.composing){if(this.suppressingSelectionUpdates)return Qr(this.view);if(ae.ie&&ae.ie_version<=11&&!this.view.state.selection.empty){const e=this.view.domSelectionRange();if(e.focusNode&&Ur(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}}let Ey=class{add(){}remove(){}},fu=class ao{constructor(){j(this,"nodeName","div");j(this,"style",{})}get parent(){return new ao}get parentNode(){return new ao}appendChild(){return new ao}setAttribute(){}hasAttribute(){return!1}insertBefore(){}get classList(){return new Ey}get ownerDocument(){return new du}addEventListener(){}removeEventListener(){}replaceChildren(){}},du=class{createElement(){return new fu}addEventListener(){}removeEventListener(){}get documentElement(){return new fu}};function hu(){const n=globalThis.window;globalThis.window??(globalThis.window={visualViewport:null});const e=globalThis.document;return globalThis.document??(globalThis.document=new du),function(){globalThis.window!==n&&(globalThis.window=n),globalThis.document!==e&&(globalThis.document=e)}}function Kt(n,e){return n instanceof er?1:e instanceof er?-1:n.getPos()-e.getPos()}const gn=0,pu=1,Zr=2,Qn=3;class Zn{constructor(e,t,r,o,s){j(this,"parent");j(this,"children");j(this,"getPos");j(this,"dom");j(this,"contentDOM");j(this,"dirty");j(this,"node");this.parent=e,this.children=t,this.getPos=r,this.dom=o,this.contentDOM=s,this.dirty=gn,o.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,r){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;t<this.children.length;t++)e+=this.children[t].size;return e}get border(){return 0}destroy(){}posBeforeChild(e){for(let t=0,r=this.posAtStart;;t++){const o=this.children[t];if(o==e)return r;r+=o.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,t,r){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(r<0){let s,i;if(e==this.contentDOM)s=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;s=e.previousSibling}for(;s&&!((i=s.pmViewDesc)&&i.parent==this);)s=s.previousSibling;return s?this.posBeforeChild(i)+i.size:this.posAtStart}else{let s,i;if(e==this.contentDOM)s=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;s=e.nextSibling}for(;s&&!((i=s.pmViewDesc)&&i.parent==this);)s=s.nextSibling;return s?this.posBeforeChild(i):this.posAtEnd}let o;if(e==this.dom&&this.contentDOM)o=t>Mt(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))o=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(t==0)for(let s=e;;s=s.parentNode){if(s==this.dom){o=!1;break}if(s.previousSibling)break}if(o==null&&t==e.childNodes.length)for(let s=e;;s=s.parentNode){if(s==this.dom){o=!0;break}if(s.nextSibling)break}}return o??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;for(let r=!0,o=e;o;o=o.parentNode){const s=this.getDesc(o);let i;if(s&&(!t||s.node))if(r&&(i=s.nodeDOM)&&!(i.nodeType==1?i.contains(e.nodeType==1?e:e.parentNode):i==e))r=!1;else return s}}getDesc(e){const t=e.pmViewDesc;for(let r=t;r;r=r.parent)if(r==this)return t}posFromDOM(e,t,r){for(let o=e;o;o=o.parentNode){const s=this.getDesc(o);if(s)return s.localPosFromDOM(e,t,r)}return-1}descAt(e){for(let t=0,r=0;t<this.children.length;t++){let o=this.children[t];const s=r+o.size;if(r==e&&s!=r){for(;!o.border&&o.children.length;)o=o.children[0];return o}if(e<s)return o.descAt(e-r-o.border);r=s}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let r=0,o=0;for(let s=0;r<this.children.length;r++){const i=this.children[r],l=s+i.size;if(l>e||i instanceof er){o=e-s;break}s=l}if(o)return this.children[r].domFromPos(o-this.children[r].border,t);for(let s;r&&!(s=this.children[r-1]).size&&s instanceof Ks&&s.side>=0;r--);if(t<=0){let s,i=!0;for(;s=r?this.children[r-1]:null,!(!s||s.dom.parentNode==this.contentDOM);r--,i=!1);return s&&t&&i&&!s.border&&!s.domAtom?s.domFromPos(s.size,t):{node:this.contentDOM,offset:s?Mt(s.dom)+1:0}}else{let s,i=!0;for(;s=r<this.children.length?this.children[r]:null,!(!s||s.dom.parentNode==this.contentDOM);r++,i=!1);return s&&i&&!s.border&&!s.domAtom?s.domFromPos(0,t):{node:this.contentDOM,offset:s?Mt(s.dom):this.contentDOM.childNodes.length}}}parseRange(e,t){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0;if(this.children.length==0)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let o=-1,s=-1;for(let i=r,l=0;;l++){const a=this.children[l],c=i+a.size;if(o==-1&&e<=c){const u=i+a.border;if(e>=u&&t<=c-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,t,u);e=i;for(let f=l;f>0;f--){const d=this.children[f-1];if(d.size&&d.dom.parentNode==this.contentDOM&&!d.emptyChildAt(1)){o=Mt(d.dom)+1;break}e-=d.size}o==-1&&(o=0)}if(o>-1&&(c>t||l==this.children.length-1)){t=c;for(let u=l+1;u<this.children.length;u++){const f=this.children[u];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(-1)){s=Mt(f.dom);break}t+=f.size}s==-1&&(s=this.contentDOM.childNodes.length);break}i=c}return{node:this.contentDOM,from:e,to:t,fromOffset:o,toOffset:s}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;const t=this.children[e<0?0:this.children.length-1];return t.size==0||t.emptyChildAt(e)}domAfterPos(e){const{node:t,offset:r}=this.domFromPos(e,0);if(t.nodeType!=1||r==t.childNodes.length)throw new RangeError("No node after pos "+e);return t.childNodes[r]}setSelection(e,t,r){var h;let o=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1;const s=Math.min(e,t),i=Math.max(e,t);for(let p=0,b=0;p<this.children.length;p++){const g=this.children[p],k=b+g.size;if(s>b&&i<k)return g.setSelection(e-b-g.border,t-b-g.border,r,o);b=k}let l=this.domFromPos(e,e?-1:1),a=t==e?l:this.domFromPos(t,t?-1:1);const c=r.root.getSelection(),u=r.domSelectionRange();let f=!1;if((ae.gecko||ae.safari)&&e==t){const{node:p,offset:b}=l;if(p.nodeType==3){if(f=!!(b&&((h=p.nodeValue)==null?void 0:h[b-1])==`
|
|
45
|
+
`),f&&b==p.nodeValue.length)for(let g=p,k;g;g=g.parentNode){if(k=g.nextSibling){k.nodeName=="BR"&&(l=a={node:k.parentNode,offset:Mt(k)+1});break}const S=g.pmViewDesc;if(S&&S.node&&S.node.isBlock)break}}else{const g=p.childNodes[b-1];f=g&&(g.nodeName=="BR"||g.contentEditable=="false")}}if(ae.gecko&&u.focusNode&&u.focusNode!=a.node&&u.focusNode.nodeType==1){const p=u.focusNode.childNodes[u.focusOffset];p&&p.contentEditable=="false"&&(o=!0)}if(!(o||f&&ae.safari)&&Ur(l.node,l.offset,u.anchorNode,u.anchorOffset)&&Ur(a.node,a.offset,u.focusNode,u.focusOffset))return;let d=!1;if((c.extend||e==t)&&!f){c.collapse(l.node,l.offset);try{e!=t&&c.extend(a.node,a.offset),d=!0}catch{}}if(!d){if(e>t){const b=l;l=a,a=b}const p=document.createRange();p.setEnd(a.node,a.offset),p.setStart(l.node,l.offset),c.removeAllRanges(),c.addRange(p)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let r=0,o=0;o<this.children.length;o++){const s=this.children[o],i=r+s.size;if(r==i?e<=i&&t>=r:e<i&&t>r){const l=r+s.border,a=i-s.border;if(e>=l&&t<=a){this.dirty=e==r||t==i?Zr:pu,e==l&&t==a&&(s.contentLost||s.dom.parentNode!=this.contentDOM)?s.dirty=Qn:s.markDirty(e-l,t-l);return}else s.dirty=s.dom==s.contentDOM&&s.dom.parentNode==this.contentDOM&&!s.children.length?Zr:Qn}r=i}this.dirty=Zr}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){const r=e==1?Zr:pu;t.dirty<r&&(t.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}}class Ks extends Zn{constructor(t,r,o,s){super(t,[],r,s,null);j(this,"widget");this.widget=o,this.widget=o}matchesWidget(t){return this.dirty==gn&&t.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(t){const r=this.widget.spec.stopEvent;return r?r(t):!1}ignoreMutation(t){return t.type!="selection"||this.widget.spec.ignoreSelection}get domAtom(){return!0}get side(){return this.widget.type.side}}class eo extends Zn{constructor(t,r,o,s,i){super(t,[],r,o,null);j(this,"textDOM");j(this,"text");this.textDOM=s,this.text=i}get size(){return this.text.length}localPosFromDOM(t,r){return t!=this.textDOM?this.posAtStart+(r?this.size:0):this.posAtStart+r}domFromPos(t){return{node:this.textDOM,offset:t}}ignoreMutation(t){return t.type==="characterData"&&t.target.nodeValue==t.oldValue}}class Dy extends Zn{constructor(t,r,o,s,i,l,a){super(t,r,o,i,l);j(this,"mark");j(this,"spec");this.mark=s,this.spec=a}parseRule(){return this.dirty&Qn||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(t){return this.dirty!=Qn&&this.mark.eq(t)}markDirty(t,r){if(super.markDirty(t,r),this.dirty!=gn){let o=this.parent;for(;!o.node;)o=o.parent;o.dirty<this.dirty&&(o.dirty=this.dirty),this.dirty=gn}}ignoreMutation(t){return this.spec.ignoreMutation?this.spec.ignoreMutation(t):super.ignoreMutation(t)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class Js extends Zn{constructor(t,r,o,s,i,l,a,c,u,f,d,h,p){super(t,r,o,a,c);j(this,"node");j(this,"outerDeco");j(this,"innerDeco");j(this,"nodeDOM");j(this,"stopEvent");j(this,"selectNode");j(this,"deselectNode");j(this,"ignoreMutation");this.node=s,this.outerDeco=i,this.innerDeco=l,this.nodeDOM=u,this.stopEvent=f,this.selectNode=d,this.deselectNode=h,this.ignoreMutation=p}updateOuterDeco(){}parseRule(){if(this.node.type.spec.reparseInView)return null;const t={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(t.preserveWhitespace="full"),!this.contentDOM)t.getContent=()=>this.node.content;else if(!this.contentLost)t.contentElement=this.contentDOM;else{for(let r=this.children.length-1;r>=0;r--){const o=this.children[r];if(this.dom.contains(o.dom.parentNode)){t.contentElement=o.dom.parentNode;break}}t.contentElement||(t.getContent=()=>C.empty)}return t}matchesNode(t,r,o){return this.dirty==gn&&t.eq(this.node)&&Ty(r,this.outerDeco)&&o.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}update(t,r,o,s){return!0}get domAtom(){return this.node.isAtom}}class Oy extends Js{constructor(e,t,r,o,s,i,l,a){super(e,t,r,o,s,i,l,null,a,()=>!1,()=>{},()=>{},c=>c.type!="characterData"&&c.type!="selection")}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,r,o){return!0}inParent(){const e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,r){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,r)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=Qn)}get domAtom(){return!1}}class er extends Zn{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==gn&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}function Ty(n,e){if(n.length!=e.length)return!1;for(let t=0;t<n.length;t++)if(!n[t].type.eq(e[t].type))return!1;return!0}function vy(n){const e={};for(const[r,o]of n.entries()){let s=function(i,l){for(const a of o){let c=!1;if(Ye.unstable_batchedUpdates(()=>{c=!!a.call(this,i,l)}),c||l.defaultPrevented)return!0}return!1};e[r]=s}return new Be({key:new lt("@handlewithcare/react-prosemirror/componentEventListeners"),props:{handleDOMEvents:e}})}function Ay(){const[n,e]=m.useState(new Map),t=m.useCallback((s,i)=>{const l=n.get(s)??[];l.unshift(i),n.has(s)||(n.set(s,l),e(new Map(n)))},[n]),r=m.useCallback((s,i)=>{const l=n.get(s);l==null||l.splice(l.indexOf(i),1)},[n]),o=m.useMemo(()=>vy(n),[n]);return{registerEventListener:t,unregisterEventListener:r,componentEventListenersPlugin:o}}function Ys(){const[,n]=m.useReducer(e=>e+1,0);return n}function Py(n){const e=Object.create(null);function t(r){for(const o in r)Object.prototype.hasOwnProperty.call(e,o)||(e[o]=r[o])}return n.someProp("nodeViews",t),n.someProp("markViews",t),e}function Iy(n,e){let t=0,r=0;for(const o in n){if(n[o]!=e[o])return!0;t++}for(const o in e)r++;return t!=r}function Vy(n,e){for(const t of Object.keys(n))if(n[t]!==e[t])return!0;return!1}function mu(n){return!n.someProp("editable",e=>e(n.state)===!1)}class gu extends Ep{constructor(t,r){const o=hu();super(t,{state:Ge.create({schema:r.state.schema,plugins:r.state.plugins}),plugins:r.plugins});j(this,"shouldUpdatePluginViews",!1);j(this,"oldProps");j(this,"_props");o(),this.shouldUpdatePluginViews=!0,this._props=r,this.oldProps={state:r.state},this.state=r.state,this.domObserver.stop(),this.domObserver=new Ny(this),this.domObserver.start(),this.editable=mu(this),this.docView.dom.replaceChildren(),this.docView=r.docView}get needsRedraw(){if(this.oldProps.state.plugins===this._props.state.plugins&&this._props.plugins===this.oldProps.plugins)return!1;const t=Py(this);return Iy(this.nodeViews,t)}pureSetProps(t){this._props={...this._props,...t},this.state=this._props.state,this.editable=mu(this)}runPendingEffects(){if(Vy(this.props,this.oldProps)){const t=this.props;this._props=this.oldProps,this.state=this._props.state,this.update(t)}}update(t){super.update(t),this.oldProps=t}updatePluginViews(t){this.shouldUpdatePluginViews&&super.updatePluginViews(t)}destroy(){this.dom=document.createElement("div"),super.destroy()}}const Ry=new gr({nodes:{doc:{content:"text*"},text:{inline:!0}}}),zy=Ge.create({schema:Ry});let yu=!1;function $y(n,e){process.env.NODE_ENV!=="production"&&e.defaultState!==void 0&&e.state!==void 0&&!yu&&(console.error("A component contains a ProseMirror editor with both value and defaultValue props. ProseMirror editors must be either controlled or uncontrolled (specify either the state prop, or the defaultState prop, but not both). Decide between using a controlled or uncontrolled ProseMirror editor and remove one of these props. More info: https://reactjs.org/link/controlled-components"),yu=!0);const t=m.useRef(!0),[r,o]=m.useState(null),s=Ys(),i=e.defaultState??zy,[l,a]=m.useState(i),c=e.state??l,{componentEventListenersPlugin:u,registerEventListener:f,unregisterEventListener:d}=Ay(),h=m.useCallback(V=>{Ye.flushSync(()=>{o(V)})},[]),p=m.useMemo(()=>[...e.plugins??[],u,dy(h)],[e.plugins,u,h]),b=m.useCallback(function(z){t.current?Ye.flushSync(()=>{e.state||a(T=>T.apply(z)),e.dispatchTransaction&&e.dispatchTransaction.call(this,z)}):(e.state||a(T=>T.apply(z)),e.dispatchTransaction&&e.dispatchTransaction.call(this,z))},[e.dispatchTransaction,e.state]),g=hu(),k=document.createElement("div");g();const S=m.useRef(new Js(void 0,[],()=>-1,c.doc,[],H.empty,k,null,k,()=>!1,()=>{},()=>{},()=>!1)),M={...e,state:c,plugins:p,dispatchTransaction:b,docView:S.current},[O,I]=m.useState(()=>new gu(null,M));return J(()=>()=>{O==null||O.destroy()},[O]),J(()=>{if(!n){I(null);return}if(!O||O.dom!==n){const V=new gu({mount:n},M);I(V),V.dom.addEventListener("compositionend",s);return}if(O.needsRedraw){I(null);return}O==null||O.domObserver.selectionToDOM(),O==null||O.runPendingEffects()}),O==null||O.pureSetProps(M),{editor:m.useMemo(()=>({view:O,registerEventListener:f,unregisterEventListener:d,cursorWrapper:r,docViewDescRef:S,flushSyncRef:t}),[O,f,d,r]),state:c}}function jy(n){let{children:e}=n;const t=m.useRef(new Set).current,r=m.useRef(new Set).current,o=m.useRef(!1),s=Ys(),i=m.useRef(!0),l=m.useCallback(()=>{i.current||(s(),i.current=!0)},[s]),a=m.useCallback(c=>{let u;const f=()=>{u=c()};return t.add(f),l(),()=>{t.delete(f),u&&(o.current?(r.add(u),l()):u())}},[t,r,l]);return J(()=>(i.current=!1,t.forEach(c=>c()),t.clear(),()=>{r.forEach(c=>c()),r.clear()})),J(()=>(o.current=!0,()=>{o.current=!1}),[]),m.createElement(Uc.Provider,{value:a},e)}const Ce=m.createContext({parentRef:{current:void 0},siblingsRef:{current:[]}});function Gs(n,e,t,r,o,s,i,l){const{view:a}=m.useContext(wt),[c,u]=m.useState(!0),f=m.useRef(i),d=m.useRef(()=>!1),h=m.useCallback(w=>{d.current=w},[]),p=m.useRef(()=>!1),b=m.useCallback(w=>{p.current=w},[]),g=m.useRef(()=>{!r.current||!n||(r.current.nodeType==1&&r.current.classList.add("ProseMirror-selectednode"),(l!=null&&l.current||!n.type.spec.draggable)&&(((t==null?void 0:t.current)??r.current).draggable=!0))}),k=m.useRef(()=>{!r.current||!n||r.current.nodeType==1&&(r.current.classList.remove("ProseMirror-selectednode"),(l!=null&&l.current||!n.type.spec.draggable)&&((t==null?void 0:t.current)??r.current).removeAttribute("draggable"))}),S=m.useCallback((w,V)=>{g.current=w,k.current=V},[]),{siblingsRef:M,parentRef:O}=m.useContext(Ce),I=m.useRef([]);return J(()=>{const w=M.current;return()=>{if(f.current&&w.includes(f.current)){const V=w.indexOf(f.current);w.splice(V,1)}}},[M]),J(()=>{var V;if(!n||!r.current)return;const w=I.current[0];f.current?(f.current.parent=O.current,f.current.children=I.current,f.current.node=n,f.current.getPos=e,f.current.outerDeco=s,f.current.innerDeco=o,f.current.dom=(t==null?void 0:t.current)??r.current,f.current.dom.pmViewDesc=f.current,f.current.contentDOM=(l==null?void 0:l.current)??f.current.contentDOM??(w==null?void 0:w.dom.parentElement)??null,f.current.nodeDOM=r.current):f.current=new Js(O.current,I.current,e,n,s,o,(t==null?void 0:t.current)??r.current,(w==null?void 0:w.dom.parentElement)??null,r.current,z=>!!d.current(z),()=>g.current(),()=>k.current(),z=>p.current(z)),u(f.current.contentDOM!==null),M.current.includes(f.current)||M.current.push(f.current),M.current.sort(Kt);for(const z of I.current)if(z.parent=f.current,z instanceof eo){const T=(V=f.current.contentDOM)==null?void 0:V.firstChild;if(!T)throw new Error("Started a composition but couldn't find the text node it belongs to.");let L=T;for(;L.firstChild;)L=L.firstChild;if(!L||!(L instanceof Text))throw new Error("Started a composition but couldn't find the text node it belongs to.");z.dom=T,z.textDOM=L,z.text=L.data,z.textDOM.pmViewDesc=z,a==null||a.input.compositionNodes.push(z)}return()=>{var z,T,L,we;((z=f.current)==null?void 0:z.children[0])instanceof eo&&!(a!=null&&a.composing)&&((we=(T=f.current)==null?void 0:T.children[0].dom.parentNode)==null||we.removeChild((L=f.current)==null?void 0:L.children[0].dom))}}),{hasContentDOM:c,childDescriptors:I,nodeViewDescRef:f,setStopEvent:h,setSelectNode:S,setIgnoreMutation:b}}function By(n,e){return n.type.side-e.type.side}function Fy(n,e,t,r){const o=e.locals(n);let s=0;if(o.length==0){for(let c=0;c<n.childCount;c++){const u=n.child(c);r(u,o,e.forChild(s,u),s,c),s+=u.nodeSize}return}let i=0;const l=[];let a=null;for(let c=0;;){if(i<o.length&&o[i].to==s){const p=o[i++];let b;for(;i<o.length&&o[i].to==s;)(b||(b=[p])).push(o[i++]);if(b){b.sort(By);for(let g=0;g<b.length;g++)t(b[g],!(b[g].type instanceof Xn),s,c+g,!!a)}else t(p,!(p.type instanceof Xn),s,c,!!a)}let u,f;if(a)f=-1,u=a,a=null;else if(c<n.childCount)f=c,u=n.child(c++);else break;for(let p=0;p<l.length;p++)l[p].to<=s&&l.splice(p--,1);for(;i<o.length&&o[i].from<=s&&o[i].to>s;)l.push(o[i++]);let d=s+u.nodeSize;if(u.isText){let p=d;i<o.length&&o[i].from<p&&(p=o[i].from);for(let b=0;b<l.length;b++)l[b].to<p&&(p=l[b].to);p<d&&(a=u.cut(p-s),u=u.cut(0,p-s),d=p,f=-1)}const h=u.isInline&&!u.isLeaf?l.filter(p=>!p.inline):l.slice();r(u,h,e.forChild(s,u),s,f),s=d}}function Ly(){const{view:n}=m.useContext(wt);return n&&Un.getState(n.state)}var bu={exports:{}};/*!
|
|
46
46
|
Copyright (c) 2018 Jed Watson.
|
|
47
47
|
Licensed under the MIT License (MIT), see
|
|
48
48
|
http://jedwatson.github.io/classnames
|
|
49
|
-
*/(function(n){(function(){var e={}.hasOwnProperty;function t(){for(var s="",i=0;i<arguments.length;i++){var l=arguments[i];l&&(s=o(s,r(l)))}return s}function r(s){if(typeof s=="string"||typeof s=="number")return s;if(typeof s!="object")return"";if(Array.isArray(s))return t.apply(null,s);if(s.toString!==Object.prototype.toString&&!s.toString.toString().includes("[native code]"))return s.toString();var i="";for(var l in s)e.call(s,l)&&s[l]&&(i=o(i,l));return i}function o(s,i){return i?s?s+" "+i:s+i:s}n.exports?(t.default=t,n.exports=t):window.classNames=t})()})(bu);var Wy=bu.exports;const _y=gf(Wy);let xu=!1;function qy(){if(xu)return;const n=console.error;console.error=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];const[o,s,i]=t;typeof o=="string"&&o.includes("Invalid DOM property `%s`. Did you mean `%s`?")&&s==="STYLE"&&i==="style"||n(...t)},xu=!0}function Hy(n,e){return"STYLE"in n?"STYLE"in e?`${n.STYLE.match(/;\s*$/)?n.STYLE:`${n.STYLE}`} ${e.STYLE}`:n.STYLE:"STYLE"in e?e.STYLE:void 0}function ku(n,e){return{...n,...e,className:_y(n.className,e.className),STYLE:Hy(n,e),style:{...n.style,...e.style}}}function Su(n){qy();const e={};for(const[t,r]of Object.entries(n))switch(t.toLowerCase()){case"class":{e.className=r;break}case"style":{e.STYLE=r;break}case"autocapitalize":{e.autoCapitalize=r;break}case"contenteditable":{if(r===""||r==="true"){e.contentEditable=!0;break}if(r==="false"){e.contentEditable=!1;break}if(r==="plaintext-only"){e.contentEditable="plaintext-only";break}e.contentEditable=null;break}case"draggable":{e.draggable=r!=null;break}case"enterkeyhint":{e.enterKeyHint=r;break}case"for":{e.htmlFor=r;break}case"hidden":{e.hidden=r;break}case"inputmode":{e.inputMode=r;break}case"itemprop":{e.itemProp=r;break}case"spellcheck":{if(r===""||r==="true"){e.spellCheck=!0;break}if(r==="false"){e.spellCheck=!1;break}e.spellCheck=null;break}case"tabindex":{const o=parseInt(r,10);Number.isNaN(o)||(e.tabIndex=o);break}case"autocomplete":{e.autoComplete=r;break}case"autofocus":{e.autoFocus=r!=null;break}case"formaction":{e.formAction=r;break}case"formenctype":{e.formEnctype=r;break}case"formmethod":{e.formMethod=r;break}case"formnovalidate":{e.formNoValidate=r;break}case"formtarget":{e.formTarget=r;break}case"maxlength":{const o=parseInt(r,10);Number.isNaN(o)||(e.maxLength=r);break}case"minlength":{const o=parseInt(r,10);Number.isNaN(o)||(e.minLength=r);break}case"max":{const o=parseInt(r,10);Number.isNaN(o)||(e.max=r);break}case"min":{const o=parseInt(r,10);Number.isNaN(o)||(e.min=r);break}case"multiple":{e.multiple=r!=null;break}case"readonly":{e.readOnly=r!=null;break}case"required":{e.required=r!=null;break}case"size":{const o=parseInt(r,10);Number.isNaN(o)||(e.size=r);break}case"step":{if(r==="any"){e.step=r;break}const o=parseInt(r,10);!Number.isNaN(o)&&o>0&&(e.step=r);break}case"disabled":{e.disabled=r!=null;break}case"rows":{const o=parseInt(r,10);Number.isNaN(o)||(e.rows=r);break}default:{e[t]=r;break}}return e}function Cu(n){if(!Array.isArray(n))throw new Error("@handlewithcare/react-prosemirror only supports strings and arrays in toDOM");const e=n[1];let t=1;e&&typeof e=="object"&&e.nodeType==null&&!Array.isArray(e)&&(t=2);for(let r=t;r<n.length;r++){const o=n[r];if(o===0||Cu(o))return!0}return!1}const Xs=m.memo(m.forwardRef(function(e,t){let{outputSpec:r,isMark:o,children:s,...i}=e;if(typeof r=="string")return m.createElement(m.Fragment,null,r);if(!Array.isArray(r))throw new Error("@handlewithcare/react-prosemirror only supports strings and arrays in toDOM");const a=r[0].replace(" ",":"),c=r[1];let u={ref:t,...i},f=1;c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)&&(f=2,u=ku(Su(c),u));const d=[];for(let p=f;p<r.length;p++){const h=r[p];if(h===0){if(p<r.length-1||p>f)throw new RangeError("Content hole must be the only child of its parent node");return m.createElement(a,u,s)}d.push(m.createElement(Xs,{outputSpec:h},s))}return o&&!Cu(r)&&d.push(s),m.createElement(a,u,...d)})),wu=m.memo(m.forwardRef(function(e,t){let{mark:r,getPos:o,children:s}=e;const{siblingsRef:i,parentRef:l}=m.useContext(Ce),a=m.useRef(void 0),c=m.useRef([]),u=m.useRef(null);m.useImperativeHandle(t,()=>u.current,[]);const f=m.useMemo(()=>{var p,h;return(h=(p=r.type.spec).toDOM)==null?void 0:h.call(p,r,!0)},[r]);if(!f)throw new Error(`Mark spec for ${r.type.name} is missing toDOM`);J(()=>{const p=i.current;return()=>{if(a.current&&p.includes(a.current)){const h=p.indexOf(a.current);p.splice(h,1)}}},[i]),J(()=>{if(!u.current)return;const p=c.current[0];a.current?(a.current.parent=l.current,a.current.spec.dom=a.current.dom=u.current,a.current.children=c.current,a.current.spec.contentDOM=a.current.contentDOM=(p==null?void 0:p.dom.parentElement)??u.current,a.current.mark=r,a.current.getPos=()=>o.current()):a.current=new Dy(l.current,c.current,()=>o.current(),r,u.current,(p==null?void 0:p.dom.parentElement)??u.current,{dom:u.current,contentDOM:(p==null?void 0:p.dom.parentElement)??u.current}),i.current.includes(a.current)||i.current.push(a.current),i.current.sort(Kt);for(const h of c.current)h.parent=a.current});const d=m.useMemo(()=>({parentRef:a,siblingsRef:c}),[c,a]);return m.createElement(Xs,{ref:u,outputSpec:f,isMark:!0},m.createElement(Ce.Provider,{value:d},s))}));function Ky(n){let{widget:e,getPos:t}=n;const{siblingsRef:r,parentRef:o}=m.useContext(Ce),s=m.useRef(null),i=m.useRef(null);return J(()=>{const l=r.current;return()=>{if(s.current&&l.includes(s.current)){const a=l.indexOf(s.current);l.splice(a,1)}}},[r]),Ke(l=>{if(!i.current)return;const a=e.type.toDOM;let c=typeof a=="function"?a(l,()=>t.current()):a;if(!e.type.spec.raw){if(c.nodeType!=1){const u=document.createElement("span");u.appendChild(c),c=u}c.contentEditable="false",c.classList.add("ProseMirror-widget")}i.current.firstElementChild!==c&&i.current.replaceChildren(c)}),J(()=>{i.current&&(s.current?(s.current.parent=o.current,s.current.widget=e,s.current.getPos=()=>t.current(),s.current.dom=i.current):s.current=new Ks(o.current,()=>t.current(),e,i.current),r.current.includes(s.current)||r.current.push(s.current),r.current.sort(Kt))}),m.createElement("span",{ref:i})}function Jy(){}function Yy(){return Jy}function Gy(){return m.useSyncExternalStore(Yy,()=>!0,()=>!1)}const Xy=m.memo(function(e){var Et;let{customNodeView:t,node:r,getPos:o,innerDeco:s,outerDeco:i}=e;const{view:l}=m.useContext(wt),a=m.useRef(null),c=m.useRef(null),u=m.useRef(null),f=m.useRef(()=>o.current()).current,d=m.useRef(r);d.current=r;const p=m.useRef(i);p.current=i;const h=m.useRef(s);h.current=s;const b=m.useRef(null),g=m.useRef(null),k=Ys(),w=Gy();J(()=>{var Yt,yn,sr;if(g.current||(g.current=t(d.current,l,f,p.current,h.current),g.current.stopEvent&&I(g.current.stopEvent.bind(g.current)),g.current.selectNode&&C(g.current.selectNode.bind(g.current),((Yt=g.current.deselectNode)==null?void 0:Yt.bind(g.current))??(()=>{})),g.current.ignoreMutation&&V(g.current.ignoreMutation.bind(g.current)),k()),!b.current)return;const{dom:Ae}=g.current;if(b.current.firstChild===Ae)return;c.current=b.current,b.current.appendChild(Ae),(l==null?void 0:l.state.selection)instanceof D&&l.state.selection.node===d.current&&((sr=(yn=g.current).selectNode)==null||sr.call(yn));const ze=g.current;return()=>{var io;(io=ze.destroy)==null||io.call(ze),g.current=null}},[t,f,l]),J(()=>{if(!t||!g.current)return;const{destroy:Ae,update:ze}=g.current;if(((ze==null?void 0:ze.call(g.current,r,i,s))??!0)||(Ae==null||Ae.call(g.current),!b.current))return;g.current=t(d.current,l,f,p.current,h.current);const{dom:yn}=g.current;c.current=b.current,b.current.appendChild(yn)},[t,l,s,r,i,o,f]);const{childDescriptors:M,nodeViewDescRef:O,setStopEvent:I,setSelectNode:C,setIgnoreMutation:V}=Gs(r,f,a,c,s,i,void 0,u),z=m.useMemo(()=>({parentRef:O,siblingsRef:M}),[M,O]);if(!w)return null;g.current||(g.current=t(d.current,l,()=>o.current(),p.current,h.current),g.current.stopEvent&&I(g.current.stopEvent.bind(g.current)),g.current.selectNode&&C(g.current.selectNode.bind(g.current),((Et=g.current.deselectNode)==null?void 0:Et.bind(g.current))??(()=>{})),g.current.ignoreMutation&&V(g.current.ignoreMutation.bind(g.current)));const{contentDOM:T}=g.current;u.current=T??null;const L=m.createElement(r.isInline?"span":"div",{ref:b,contentEditable:!!T,suppressContentEditableWarning:!0},T&&Ye.createPortal(m.createElement(tr,{getPos:o,node:r,innerDecorations:s}),T)),we=m.cloneElement(i.reduce(to,L),i.some(Ae=>Ae.type.attrs.nodeName)?{ref:a}:void 0);return m.createElement(Ce.Provider,{value:z},we)}),Uy=m.createContext(null),Qy=m.createContext(null),Mu=m.createContext(null),Zy=m.memo(function(e){let{outerDeco:t,getPos:r,node:o,innerDeco:s,...i}=e;const l=m.useRef(null),a=m.useRef(null),c=m.useRef(null),u=m.useRef(()=>r.current()).current,{nodeViews:f}=m.useContext(qc);let d=null;const p=f[o.type.name],h=m.useMemo(()=>{var T,L;return(L=(T=o.type.spec).toDOM)==null?void 0:L.call(T,o)},[o]),{hasContentDOM:b,childDescriptors:g,setStopEvent:k,setSelectNode:w,setIgnoreMutation:M,nodeViewDescRef:O}=Gs(o,()=>r.current(),l,a,s,t,void 0,c),I={...i,...!b&&{contentEditable:!1}},C=m.useMemo(()=>({node:o,getPos:u,decorations:t,innerDecorations:s}),[u,s,o,t]);if(p?d=m.createElement(p,{...I,ref:a,nodeProps:C},m.createElement(tr,{getPos:r,node:o,innerDecorations:s})):h&&(d=m.createElement(Xs,{...I,ref:a,outputSpec:h},m.createElement(tr,{getPos:r,node:o,innerDecorations:s}))),!d)throw new Error(`Node spec for ${o.type.name} is missing toDOM`);const V=m.cloneElement(t.reduce(to,d),t.some(T=>T.type.attrs.nodeName)?{ref:l}:void 0),z=m.useMemo(()=>({parentRef:O,siblingsRef:g}),[g,O]);return m.createElement(Qy.Provider,{value:w},m.createElement(Mu.Provider,{value:k},m.createElement(Uy.Provider,{value:M},m.createElement(Ce.Provider,{value:z},V))))}),Nu=m.memo(function(e){let{outerDeco:t,getPos:r,node:o,innerDeco:s,...i}=e;const{view:l}=m.useContext(wt),a=l==null?void 0:l.someProp("nodeViews",c=>c==null?void 0:c[o.type.name]);return a?m.createElement(Xy,{customNodeView:a,node:o,innerDeco:s,outerDeco:t,getPos:r}):m.createElement(Zy,{node:o,innerDeco:s,outerDeco:t,getPos:r,...i})});function eb(n){let{getPos:e}=n;const{siblingsRef:t,parentRef:r}=m.useContext(Ce),o=m.useRef(null),s=m.useRef(null),[i,l]=m.useState(!1);return J(()=>{const a=t.current;return()=>{if(o.current&&a.includes(o.current)){const c=a.indexOf(o.current);a.splice(c,1)}}},[t]),J(()=>{var c;const a=t.current[t.current.length-1];if((ae.safari||ae.chrome)&&((c=a==null?void 0:a.dom)==null?void 0:c.contentEditable)=="false"){l(!0);return}s.current&&(o.current?(o.current.parent=r.current,o.current.dom=s.current,o.current.getPos=()=>e.current()):o.current=new er(r.current,[],()=>e.current(),s.current,null),t.current.includes(o.current)||t.current.push(o.current),t.current.sort(Kt))}),i?m.createElement("img",{ref:s,className:"ProseMirror-separator"}):null}var Us={exports:{}},Te={};/**
|
|
49
|
+
*/(function(n){(function(){var e={}.hasOwnProperty;function t(){for(var s="",i=0;i<arguments.length;i++){var l=arguments[i];l&&(s=o(s,r(l)))}return s}function r(s){if(typeof s=="string"||typeof s=="number")return s;if(typeof s!="object")return"";if(Array.isArray(s))return t.apply(null,s);if(s.toString!==Object.prototype.toString&&!s.toString.toString().includes("[native code]"))return s.toString();var i="";for(var l in s)e.call(s,l)&&s[l]&&(i=o(i,l));return i}function o(s,i){return i?s?s+" "+i:s+i:s}n.exports?(t.default=t,n.exports=t):window.classNames=t})()})(bu);var Wy=bu.exports;const _y=gf(Wy);let xu=!1;function qy(){if(xu)return;const n=console.error;console.error=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];const[o,s,i]=t;typeof o=="string"&&o.includes("Invalid DOM property `%s`. Did you mean `%s`?")&&s==="STYLE"&&i==="style"||n(...t)},xu=!0}function Hy(n,e){return"STYLE"in n?"STYLE"in e?`${n.STYLE.match(/;\s*$/)?n.STYLE:`${n.STYLE}`} ${e.STYLE}`:n.STYLE:"STYLE"in e?e.STYLE:void 0}function ku(n,e){return{...n,...e,className:_y(n.className,e.className),STYLE:Hy(n,e),style:{...n.style,...e.style}}}function Su(n){qy();const e={};for(const[t,r]of Object.entries(n))switch(t.toLowerCase()){case"class":{e.className=r;break}case"style":{e.STYLE=r;break}case"autocapitalize":{e.autoCapitalize=r;break}case"contenteditable":{if(r===""||r==="true"){e.contentEditable=!0;break}if(r==="false"){e.contentEditable=!1;break}if(r==="plaintext-only"){e.contentEditable="plaintext-only";break}e.contentEditable=null;break}case"draggable":{e.draggable=r!=null;break}case"enterkeyhint":{e.enterKeyHint=r;break}case"for":{e.htmlFor=r;break}case"hidden":{e.hidden=r;break}case"inputmode":{e.inputMode=r;break}case"itemprop":{e.itemProp=r;break}case"spellcheck":{if(r===""||r==="true"){e.spellCheck=!0;break}if(r==="false"){e.spellCheck=!1;break}e.spellCheck=null;break}case"tabindex":{const o=parseInt(r,10);Number.isNaN(o)||(e.tabIndex=o);break}case"autocomplete":{e.autoComplete=r;break}case"autofocus":{e.autoFocus=r!=null;break}case"formaction":{e.formAction=r;break}case"formenctype":{e.formEnctype=r;break}case"formmethod":{e.formMethod=r;break}case"formnovalidate":{e.formNoValidate=r;break}case"formtarget":{e.formTarget=r;break}case"maxlength":{const o=parseInt(r,10);Number.isNaN(o)||(e.maxLength=r);break}case"minlength":{const o=parseInt(r,10);Number.isNaN(o)||(e.minLength=r);break}case"max":{const o=parseInt(r,10);Number.isNaN(o)||(e.max=r);break}case"min":{const o=parseInt(r,10);Number.isNaN(o)||(e.min=r);break}case"multiple":{e.multiple=r!=null;break}case"readonly":{e.readOnly=r!=null;break}case"required":{e.required=r!=null;break}case"size":{const o=parseInt(r,10);Number.isNaN(o)||(e.size=r);break}case"step":{if(r==="any"){e.step=r;break}const o=parseInt(r,10);!Number.isNaN(o)&&o>0&&(e.step=r);break}case"disabled":{e.disabled=r!=null;break}case"rows":{const o=parseInt(r,10);Number.isNaN(o)||(e.rows=r);break}default:{e[t]=r;break}}return e}function Cu(n){if(!Array.isArray(n))throw new Error("@handlewithcare/react-prosemirror only supports strings and arrays in toDOM");const e=n[1];let t=1;e&&typeof e=="object"&&e.nodeType==null&&!Array.isArray(e)&&(t=2);for(let r=t;r<n.length;r++){const o=n[r];if(o===0||Cu(o))return!0}return!1}const Xs=m.memo(m.forwardRef(function(e,t){let{outputSpec:r,isMark:o,children:s,...i}=e;if(typeof r=="string")return m.createElement(m.Fragment,null,r);if(!Array.isArray(r))throw new Error("@handlewithcare/react-prosemirror only supports strings and arrays in toDOM");const a=r[0].replace(" ",":"),c=r[1];let u={ref:t,...i},f=1;c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)&&(f=2,u=ku(Su(c),u));const d=[];for(let h=f;h<r.length;h++){const p=r[h];if(p===0){if(h<r.length-1||h>f)throw new RangeError("Content hole must be the only child of its parent node");return m.createElement(a,u,s)}d.push(m.createElement(Xs,{outputSpec:p},s))}return o&&!Cu(r)&&d.push(s),m.createElement(a,u,...d)})),wu=m.memo(m.forwardRef(function(e,t){let{mark:r,getPos:o,children:s}=e;const{siblingsRef:i,parentRef:l}=m.useContext(Ce),a=m.useRef(void 0),c=m.useRef([]),u=m.useRef(null);m.useImperativeHandle(t,()=>u.current,[]);const f=m.useMemo(()=>{var h,p;return(p=(h=r.type.spec).toDOM)==null?void 0:p.call(h,r,!0)},[r]);if(!f)throw new Error(`Mark spec for ${r.type.name} is missing toDOM`);J(()=>{const h=i.current;return()=>{if(a.current&&h.includes(a.current)){const p=h.indexOf(a.current);h.splice(p,1)}}},[i]),J(()=>{if(!u.current)return;const h=c.current[0];a.current?(a.current.parent=l.current,a.current.spec.dom=a.current.dom=u.current,a.current.children=c.current,a.current.spec.contentDOM=a.current.contentDOM=(h==null?void 0:h.dom.parentElement)??u.current,a.current.mark=r,a.current.getPos=()=>o.current()):a.current=new Dy(l.current,c.current,()=>o.current(),r,u.current,(h==null?void 0:h.dom.parentElement)??u.current,{dom:u.current,contentDOM:(h==null?void 0:h.dom.parentElement)??u.current}),i.current.includes(a.current)||i.current.push(a.current),i.current.sort(Kt);for(const p of c.current)p.parent=a.current});const d=m.useMemo(()=>({parentRef:a,siblingsRef:c}),[c,a]);return m.createElement(Xs,{ref:u,outputSpec:f,isMark:!0},m.createElement(Ce.Provider,{value:d},s))}));function Ky(n){let{widget:e,getPos:t}=n;const{siblingsRef:r,parentRef:o}=m.useContext(Ce),s=m.useRef(null),i=m.useRef(null);return J(()=>{const l=r.current;return()=>{if(s.current&&l.includes(s.current)){const a=l.indexOf(s.current);l.splice(a,1)}}},[r]),Ke(l=>{if(!i.current)return;const a=e.type.toDOM;let c=typeof a=="function"?a(l,()=>t.current()):a;if(!e.type.spec.raw){if(c.nodeType!=1){const u=document.createElement("span");u.appendChild(c),c=u}c.contentEditable="false",c.classList.add("ProseMirror-widget")}i.current.firstElementChild!==c&&i.current.replaceChildren(c)}),J(()=>{i.current&&(s.current?(s.current.parent=o.current,s.current.widget=e,s.current.getPos=()=>t.current(),s.current.dom=i.current):s.current=new Ks(o.current,()=>t.current(),e,i.current),r.current.includes(s.current)||r.current.push(s.current),r.current.sort(Kt))}),m.createElement("span",{ref:i})}function Jy(){}function Yy(){return Jy}function Gy(){return m.useSyncExternalStore(Yy,()=>!0,()=>!1)}const Xy=m.memo(function(e){var Et;let{customNodeView:t,node:r,getPos:o,innerDeco:s,outerDeco:i}=e;const{view:l}=m.useContext(wt),a=m.useRef(null),c=m.useRef(null),u=m.useRef(null),f=m.useRef(()=>o.current()).current,d=m.useRef(r);d.current=r;const h=m.useRef(i);h.current=i;const p=m.useRef(s);p.current=s;const b=m.useRef(null),g=m.useRef(null),k=Ys(),S=Gy();J(()=>{var Yt,yn,sr;if(g.current||(g.current=t(d.current,l,f,h.current,p.current),g.current.stopEvent&&I(g.current.stopEvent.bind(g.current)),g.current.selectNode&&w(g.current.selectNode.bind(g.current),((Yt=g.current.deselectNode)==null?void 0:Yt.bind(g.current))??(()=>{})),g.current.ignoreMutation&&V(g.current.ignoreMutation.bind(g.current)),k()),!b.current)return;const{dom:Ae}=g.current;if(b.current.firstChild===Ae)return;c.current=b.current,b.current.appendChild(Ae),(l==null?void 0:l.state.selection)instanceof D&&l.state.selection.node===d.current&&((sr=(yn=g.current).selectNode)==null||sr.call(yn));const ze=g.current;return()=>{var io;(io=ze.destroy)==null||io.call(ze),g.current=null}},[t,f,l]),J(()=>{if(!t||!g.current)return;const{destroy:Ae,update:ze}=g.current;if(((ze==null?void 0:ze.call(g.current,r,i,s))??!0)||(Ae==null||Ae.call(g.current),!b.current))return;g.current=t(d.current,l,f,h.current,p.current);const{dom:yn}=g.current;c.current=b.current,b.current.appendChild(yn)},[t,l,s,r,i,o,f]);const{childDescriptors:M,nodeViewDescRef:O,setStopEvent:I,setSelectNode:w,setIgnoreMutation:V}=Gs(r,f,a,c,s,i,void 0,u),z=m.useMemo(()=>({parentRef:O,siblingsRef:M}),[M,O]);if(!S)return null;g.current||(g.current=t(d.current,l,()=>o.current(),h.current,p.current),g.current.stopEvent&&I(g.current.stopEvent.bind(g.current)),g.current.selectNode&&w(g.current.selectNode.bind(g.current),((Et=g.current.deselectNode)==null?void 0:Et.bind(g.current))??(()=>{})),g.current.ignoreMutation&&V(g.current.ignoreMutation.bind(g.current)));const{contentDOM:T}=g.current;u.current=T??null;const L=m.createElement(r.isInline?"span":"div",{ref:b,contentEditable:!!T,suppressContentEditableWarning:!0},T&&Ye.createPortal(m.createElement(tr,{getPos:o,node:r,innerDecorations:s}),T)),we=m.cloneElement(i.reduce(to,L),i.some(Ae=>Ae.type.attrs.nodeName)?{ref:a}:void 0);return m.createElement(Ce.Provider,{value:z},we)}),Uy=m.createContext(null),Qy=m.createContext(null),Mu=m.createContext(null),Zy=m.memo(function(e){let{outerDeco:t,getPos:r,node:o,innerDeco:s,...i}=e;const l=m.useRef(null),a=m.useRef(null),c=m.useRef(null),u=m.useRef(()=>r.current()).current,{nodeViews:f}=m.useContext(qc);let d=null;const h=f[o.type.name],p=m.useMemo(()=>{var T,L;return(L=(T=o.type.spec).toDOM)==null?void 0:L.call(T,o)},[o]),{hasContentDOM:b,childDescriptors:g,setStopEvent:k,setSelectNode:S,setIgnoreMutation:M,nodeViewDescRef:O}=Gs(o,()=>r.current(),l,a,s,t,void 0,c),I={...i,...!b&&{contentEditable:!1}},w=m.useMemo(()=>({node:o,getPos:u,decorations:t,innerDecorations:s}),[u,s,o,t]);if(h?d=m.createElement(h,{...I,ref:a,nodeProps:w},m.createElement(tr,{getPos:r,node:o,innerDecorations:s})):p&&(d=m.createElement(Xs,{...I,ref:a,outputSpec:p},m.createElement(tr,{getPos:r,node:o,innerDecorations:s}))),!d)throw new Error(`Node spec for ${o.type.name} is missing toDOM`);const V=m.cloneElement(t.reduce(to,d),t.some(T=>T.type.attrs.nodeName)?{ref:l}:void 0),z=m.useMemo(()=>({parentRef:O,siblingsRef:g}),[g,O]);return m.createElement(Qy.Provider,{value:S},m.createElement(Mu.Provider,{value:k},m.createElement(Uy.Provider,{value:M},m.createElement(Ce.Provider,{value:z},V))))}),Nu=m.memo(function(e){let{outerDeco:t,getPos:r,node:o,innerDeco:s,...i}=e;const{view:l}=m.useContext(wt),a=l==null?void 0:l.someProp("nodeViews",c=>c==null?void 0:c[o.type.name]);return a?m.createElement(Xy,{customNodeView:a,node:o,innerDeco:s,outerDeco:t,getPos:r}):m.createElement(Zy,{node:o,innerDeco:s,outerDeco:t,getPos:r,...i})});function eb(n){let{getPos:e}=n;const{siblingsRef:t,parentRef:r}=m.useContext(Ce),o=m.useRef(null),s=m.useRef(null),[i,l]=m.useState(!1);return J(()=>{const a=t.current;return()=>{if(o.current&&a.includes(o.current)){const c=a.indexOf(o.current);a.splice(c,1)}}},[t]),J(()=>{var c;const a=t.current[t.current.length-1];if((ae.safari||ae.chrome)&&((c=a==null?void 0:a.dom)==null?void 0:c.contentEditable)=="false"){l(!0);return}s.current&&(o.current?(o.current.parent=r.current,o.current.dom=s.current,o.current.getPos=()=>e.current()):o.current=new er(r.current,[],()=>e.current(),s.current,null),t.current.includes(o.current)||t.current.push(o.current),t.current.sort(Kt))}),i?m.createElement("img",{ref:s,className:"ProseMirror-separator"}):null}var Us={exports:{}},Te={};/**
|
|
50
50
|
* @license React
|
|
51
51
|
* react-reconciler-reflection.production.js
|
|
52
52
|
*
|
|
@@ -54,7 +54,7 @@ Check the top-level render call using <`+x+">."),v}var M=m,O=Symbol.for("react.t
|
|
|
54
54
|
*
|
|
55
55
|
* This source code is licensed under the MIT license found in the
|
|
56
56
|
* LICENSE file in the root directory of this source tree.
|
|
57
|
-
*/var Eu;function tb(){if(Eu)return Te;Eu=1;function n(i){var l="https://react.dev/errors/"+i;if(1<arguments.length){l+="?args[]="+encodeURIComponent(arguments[1]);for(var a=2;a<arguments.length;a++)l+="&args[]="+encodeURIComponent(arguments[a])}return"Minified React error #"+i+"; visit "+l+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function e(i){var l=i,a=i;if(i.alternate)for(;l.return;)l=l.return;else{i=l;do l=i,l.flags&4098&&(a=l.return),i=l.return;while(i)}return l.tag===3?a:null}function t(i){if(e(i)!==i)throw Error(n(188))}function r(i){var l=i.alternate;if(!l){if(l=e(i),l===null)throw Error(n(188));return l!==i?null:i}for(var a=i,c=l;;){var u=a.return;if(u===null)break;var f=u.alternate;if(f===null){if(c=u.return,c!==null){a=c;continue}break}if(u.child===f.child){for(f=u.child;f;){if(f===a)return t(u),i;if(f===c)return t(u),l;f=f.sibling}throw Error(n(188))}if(a.return!==c.return)a=u,c=f;else{for(var d=!1,
|
|
57
|
+
*/var Eu;function tb(){if(Eu)return Te;Eu=1;function n(i){var l="https://react.dev/errors/"+i;if(1<arguments.length){l+="?args[]="+encodeURIComponent(arguments[1]);for(var a=2;a<arguments.length;a++)l+="&args[]="+encodeURIComponent(arguments[a])}return"Minified React error #"+i+"; visit "+l+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function e(i){var l=i,a=i;if(i.alternate)for(;l.return;)l=l.return;else{i=l;do l=i,l.flags&4098&&(a=l.return),i=l.return;while(i)}return l.tag===3?a:null}function t(i){if(e(i)!==i)throw Error(n(188))}function r(i){var l=i.alternate;if(!l){if(l=e(i),l===null)throw Error(n(188));return l!==i?null:i}for(var a=i,c=l;;){var u=a.return;if(u===null)break;var f=u.alternate;if(f===null){if(c=u.return,c!==null){a=c;continue}break}if(u.child===f.child){for(f=u.child;f;){if(f===a)return t(u),i;if(f===c)return t(u),l;f=f.sibling}throw Error(n(188))}if(a.return!==c.return)a=u,c=f;else{for(var d=!1,h=u.child;h;){if(h===a){d=!0,a=u,c=f;break}if(h===c){d=!0,c=u,a=f;break}h=h.sibling}if(!d){for(h=f.child;h;){if(h===a){d=!0,a=f,c=u;break}if(h===c){d=!0,c=f,a=u;break}h=h.sibling}if(!d)throw Error(n(189))}}if(a.alternate!==c)throw Error(n(190))}if(a.tag!==3)throw Error(n(188));return a.stateNode.current===a?i:l}function o(i){var l=i.tag;if(l===5||l===26||l===27||l===6)return i;for(i=i.child;i!==null;){if(l=o(i),l!==null)return l;i=i.sibling}return null}function s(i){var l=i.tag;if(l===5||l===26||l===27||l===6)return i;for(i=i.child;i!==null;){if(i.tag!==4&&(l=s(i),l!==null))return l;i=i.sibling}return null}return Te.doesFiberContain=function(i,l){for(var a=i.alternate;l!==null;){if(l===i||l===a)return!0;l=l.return}return!1},Te.findCurrentFiberUsingSlowPath=r,Te.findCurrentHostFiber=function(i){return i=r(i),i!==null?o(i):null},Te.findCurrentHostFiberWithNoPortals=function(i){return i=r(i),i!==null?s(i):null},Te.getContainerFromFiber=function(i){return i.tag===3?i.stateNode.containerInfo:null},Te.getNearestMountedFiber=e,Te.getSuspenseInstanceFromFiber=function(i){if(i.tag===13){var l=i.memoizedState;if(l===null&&(i=i.alternate,i!==null&&(l=i.memoizedState)),l!==null)return l.dehydrated}return null},Te.isFiberMounted=function(i){return e(i)===i},Te.isFiberSuspenseAndTimedOut=function(i){var l=i.memoizedState;return i.tag===13&&l!==null&&l.dehydrated===null},Te.isMounted=function(i){return(i=i._reactInternals)?e(i)===i:!1},Te}var ve={};/**
|
|
58
58
|
* @license React
|
|
59
59
|
* react-reconciler-reflection.development.js
|
|
60
60
|
*
|
|
@@ -62,5 +62,5 @@ Check the top-level render call using <`+x+">."),v}var M=m,O=Symbol.for("react.t
|
|
|
62
62
|
*
|
|
63
63
|
* This source code is licensed under the MIT license found in the
|
|
64
64
|
* LICENSE file in the root directory of this source tree.
|
|
65
|
-
*/var Du;function nb(){return Du||(Du=1,process.env.NODE_ENV!=="production"&&function(){function n(s){var i=s,l=s;if(s.alternate)for(;i.return;)i=i.return;else{s=i;do i=s,i.flags&4098&&(l=i.return),s=i.return;while(s)}return i.tag===3?l:null}function e(s){if(n(s)!==s)throw Error("Unable to find node on an unmounted component.")}function t(s){var i=s.alternate;if(!i){if(i=n(s),i===null)throw Error("Unable to find node on an unmounted component.");return i!==s?null:s}for(var l=s,a=i;;){var c=l.return;if(c===null)break;var u=c.alternate;if(u===null){if(a=c.return,a!==null){l=a;continue}break}if(c.child===u.child){for(u=c.child;u;){if(u===l)return e(c),s;if(u===a)return e(c),i;u=u.sibling}throw Error("Unable to find node on an unmounted component.")}if(l.return!==a.return)l=c,a=u;else{for(var f=!1,d=c.child;d;){if(d===l){f=!0,l=c,a=u;break}if(d===a){f=!0,a=c,l=u;break}d=d.sibling}if(!f){for(d=u.child;d;){if(d===l){f=!0,l=u,a=c;break}if(d===a){f=!0,a=u,l=c;break}d=d.sibling}if(!f)throw Error("Child was not found in either parent set. This indicates a bug in React related to the return pointer. Please file an issue.")}}if(l.alternate!==a)throw Error("Return fibers should always be each others' alternates. This error is likely caused by a bug in React. Please file an issue.")}if(l.tag!==3)throw Error("Unable to find node on an unmounted component.");return l.stateNode.current===l?s:i}function r(s){var i=s.tag;if(i===5||i===26||i===27||i===6)return s;for(s=s.child;s!==null;){if(i=r(s),i!==null)return i;s=s.sibling}return null}function o(s){var i=s.tag;if(i===5||i===26||i===27||i===6)return s;for(s=s.child;s!==null;){if(s.tag!==4&&(i=o(s),i!==null))return i;s=s.sibling}return null}ve.doesFiberContain=function(s,i){for(var l=s.alternate;i!==null;){if(i===s||i===l)return!0;i=i.return}return!1},ve.findCurrentFiberUsingSlowPath=t,ve.findCurrentHostFiber=function(s){return s=t(s),s!==null?r(s):null},ve.findCurrentHostFiberWithNoPortals=function(s){return s=t(s),s!==null?o(s):null},ve.getContainerFromFiber=function(s){return s.tag===3?s.stateNode.containerInfo:null},ve.getNearestMountedFiber=n,ve.getSuspenseInstanceFromFiber=function(s){if(s.tag===13){var i=s.memoizedState;if(i===null&&(s=s.alternate,s!==null&&(i=s.memoizedState)),i!==null)return i.dehydrated}return null},ve.isFiberMounted=function(s){return n(s)===s},ve.isFiberSuspenseAndTimedOut=function(s){var i=s.memoizedState;return s.tag===13&&i!==null&&i.dehydrated===null},ve.isMounted=function(s){return(s=s._reactInternals)?n(s)===s:!1}}()),ve}process.env.NODE_ENV==="production"?Us.exports=tb():Us.exports=nb();var rb=Us.exports;function ob(n){return n._reactInternals}function P0(n){return n}function sb(n){const e=ob(n);if(e===void 0){if(typeof n.render=="function")throw new Error("Unable to find node on an unmounted component.");{const r=Object.keys(n).join(",");throw new Error(`Argument appears to not be a ReactComponent. Keys: ${r}`)}}const t=rb.findCurrentHostFiber(e);return t===null?null:t.stateNode}function ib(n){return sb(n)}function lb(n,e){if(n===e)return!0;if(!n||!e)return!1;const t=Object.keys(n),r=Object.keys(e),o=t.length;if(r.length!==o)return!1;for(let s=0;s<o;s++){const i=t[s];if(n[i]!==e[i]||!Object.prototype.hasOwnProperty.call(e,i))return!1}return!0}class ab extends m.Component{constructor(){super(...arguments);j(this,"viewDescRef",null);j(this,"renderRef",null)}updateEffect(){const{view:t,decorations:r,siblingsRef:o,parentRef:s,getPos:i,node:l}=this.props,a=ib(this);if(!a){if(!(t!=null&&t.composing))return;this.viewDescRef=new eo(s.current,()=>i.current(),document.createElement("div"),document.createTextNode(l.text??""),l.text??"");return}let c=a;for(;c.firstChild;)c=c.firstChild;!this.viewDescRef||this.viewDescRef instanceof eo?this.viewDescRef=new Oy(void 0,[],()=>i.current(),l,r,H.empty,a,c):(this.viewDescRef.parent=s.current,this.viewDescRef.children=[],this.viewDescRef.node=l,this.viewDescRef.getPos=()=>i.current(),this.viewDescRef.outerDeco=r,this.viewDescRef.innerDeco=H.empty,this.viewDescRef.dom=a,this.viewDescRef.dom.pmViewDesc=this.viewDescRef,this.viewDescRef.nodeDOM=c),o.current.includes(this.viewDescRef)||o.current.push(this.viewDescRef),o.current.sort(Kt)}shouldComponentUpdate(t){return!lb(this.props,t)}componentDidMount(){this.updateEffect()}componentDidUpdate(){this.updateEffect()}componentWillUnmount(){const{siblingsRef:t}=this.props;if(this.viewDescRef&&t.current.includes(this.viewDescRef)){const r=t.current.indexOf(this.viewDescRef);t.current.splice(r,1)}}render(){const{view:t,getPos:r,node:o,decorations:s}=this.props;return t!=null&&t.composing&&t.state.selection.from>=r.current()&&t.state.selection.from<=r.current()+o.nodeSize?this.renderRef:(this.renderRef=s.reduce(to,o.text),this.renderRef)}}function cb(n){let{getPos:e}=n;const{siblingsRef:t,parentRef:r}=m.useContext(Ce),o=m.useRef(null),s=m.useRef(null);return J(()=>{const i=t.current;return()=>{if(o.current&&i.includes(o.current)){const l=i.indexOf(o.current);i.splice(l,1)}}},[t]),J(()=>{s.current&&(o.current?(o.current.parent=r.current,o.current.dom=s.current,o.current.getPos=()=>e.current()):o.current=new er(r.current,[],()=>e.current(),s.current,null),t.current.includes(o.current)||t.current.push(o.current),t.current.sort(Kt))}),m.createElement("br",{ref:s,className:"ProseMirror-trailingBreak"})}function ub(n){let{widget:e,getPos:t}=n;const{siblingsRef:r,parentRef:o}=m.useContext(Ce),s=m.useRef(null),i=m.useRef(()=>t.current()).current,l=m.useRef(null);J(()=>{const c=r.current;return()=>{if(s.current&&c.includes(s.current)){const u=c.indexOf(s.current);c.splice(u,1)}}},[r]),J(()=>{l.current&&(s.current?(s.current.parent=o.current,s.current.widget=e,s.current.getPos=()=>t.current(),s.current.dom=l.current):s.current=new Ks(o.current,()=>t.current(),e,l.current),r.current.includes(s.current)||r.current.push(s.current),r.current.sort(Kt))});const{Component:a}=e.type;return a&&m.createElement(a,{ref:l,widget:e,getPos:i,contentEditable:!1})}function to(n,e){const{nodeName:t,...r}=e.type.attrs,o=Su(r);return t||typeof n=="string"?m.createElement(t??"span",o,n):m.cloneElement(n,ku(n.props,o))}function Qs(n,e){var t,r,o;return n.type===e.type&&n.marks.every(s=>s.isInSet(e.marks))&&e.marks.every(s=>s.isInSet(n.marks))&&n.key===e.key&&(n.type==="node"?((t=n.outerDeco)==null?void 0:t.length)===((r=e.outerDeco)==null?void 0:r.length)&&((o=n.outerDeco)==null?void 0:o.every(s=>{var i;return(i=e.outerDeco)==null?void 0:i.some(l=>s.from===l.from&&s.to&&l.to&&s.type.eq(l.type))}))&&n.innerDeco.eq(e.innerDeco):!0)&&n.node===e.node&&n.widget===e.widget}const fb=m.memo(function(e){let{child:t,getInnerPos:r}=e;const{view:o}=m.useContext(wt),s=m.useRef(()=>r.current()+t.offset);return s.current=()=>r.current()+t.offset,t.type==="widget"?m.createElement(ub,{key:t.key,widget:t.widget,getPos:s}):t.type==="native-widget"?m.createElement(Ky,{key:t.key,widget:t.widget,getPos:s}):t.node.isText?m.createElement(Ce.Consumer,{key:t.key},i=>{let{siblingsRef:l,parentRef:a}=i;return m.createElement(ab,{view:o,node:t.node,getPos:s,siblingsRef:l,parentRef:a,decorations:t.outerDeco})}):m.createElement(Nu,{key:t.key,node:t.node,getPos:s,outerDeco:t.outerDeco,innerDeco:t.innerDeco})}),db=m.memo(function(e){let{childViews:t,getInnerPos:r}=e;const o=t[0],s=m.useRef(()=>r.current()+o.offset);s.current=()=>r.current()+o.offset;const i=o.marks[0];return i?m.createElement(wu,{getPos:s,key:o.key,mark:i},m.createElement(Zs,{key:o.key,getInnerPos:r,childViews:t.map(l=>({...l,marks:l.marks.slice(1)}))})):m.createElement(m.Fragment,null,t.map(l=>m.createElement(fb,{key:l.key,child:l,getInnerPos:r})))}),Zs=m.memo(function(e){let{getInnerPos:t,childViews:r}=e;const o=r.reduce((s,i)=>{var c;const l=s[s.length-1];if(!l)return[[i]];const a=l[l.length-1];return a?!i.marks.length&&!a.marks.length||i.marks.length&&a.marks.length&&((c=i.marks[0])!=null&&c.eq(a.marks[0]))?[...s.slice(0,s.length-1),[...l.slice(0,l.length),i]]:[...s,[i]]:[...s.slice(0,s.length),[i]]},[]);return m.createElement(m.Fragment,null,o.map(s=>{const i=s[0];return i?m.createElement(db,{key:i.key,childViews:s,getInnerPos:t}):null}))});function ei(n,e,t,r,o,s){const i=n+e,l=r==null?void 0:r.get(i);if(t==="widget"||t==="native-widget")return o.type.spec.key?o.type.spec.key:(console.warn(`Widget at position ${i} doesn't have a key specified. This may cause issues.`),`${l}-${s}`);if(l)return l;const a=n-1,c=r==null?void 0:r.get(a);return c?`${c}-${e}`:i}function hb(n,e){if(!e||e.widget.type.side>=0||!n||!n.node.isInline)return;const t=n.marks;e.marks=e.marks.reduce((r,o)=>o.addToSet(r),t)}function pb(n,e){if(!e.node.isInline)return;const t=e.marks;for(let r=n.length-1;r>=0;r--){const o=n[r];o.widget.type.side<0||(o.marks=o.marks.reduce((s,i)=>i.addToSet(s),t))}}const mb=m.memo(function(e){let{child:t,getInnerPos:r}=e;const o=m.useRef(()=>r.current()+t.offset);return o.current=()=>r.current()+t.offset,t.type==="node"?t.marks.reduce((s,i)=>m.createElement(wu,{getPos:o,mark:i},s),m.createElement(Nu,{key:t.key,outerDeco:t.outerDeco,node:t.node,innerDeco:t.innerDeco,getPos:o})):m.createElement(Zs,{key:t.key,childViews:[t],getInnerPos:r})});function gb(n,e){return n.length?n.every(t=>t.type!=="node"||t.node.isInline)?[m.createElement(Zs,{key:n[0].key,childViews:n,getInnerPos:e})]:n.map(t=>m.createElement(mb,{key:t.key,child:t,getInnerPos:e})):[]}const tr=m.memo(function(e){let{getPos:t,node:r,innerDecorations:o}=e;const s=Ly(),i=m.useRef(()=>t.current()+1),l=m.useRef(new Map).current;if(!r)return null;const a=new Set;let c=[],u=null;Fy(r,o,(h,b,g,k)=>{const w=h.type.spec.marks??[];let M;if(b){M=ei(i.current(),g,"native-widget",s==null?void 0:s.posToKey,h,k);const I={type:"native-widget",widget:h,marks:w,offset:g,index:k,key:M},C=l.get(M);C&&Qs(C,I)?C.offset=g:l.set(M,I),a.add(M)}else{M=ei(i.current(),g,"widget",s==null?void 0:s.posToKey,h,k);const I={type:"widget",widget:h,marks:w,offset:g,index:k,key:M},C=l.get(M);C&&Qs(C,I)?C.offset=g:l.set(M,I),a.add(M)}const O=l.get(M);c.push(O),hb(u,l.get(M))},(h,b,g,k)=>{const w=ei(i.current(),k,"node",s==null?void 0:s.posToKey),M={type:"node",node:h,marks:h.marks,innerDeco:g,outerDeco:b,offset:k,key:w},O=l.get(w);O&&Qs(O,M)?(O.offset=k,u=O):(l.set(w,M),u=M),a.add(w),pb(c,u),c=[]});for(const h of l.keys())a.has(h)||l.delete(h);const f=Array.from(l.values()).sort((h,b)=>h.offset-b.offset),d=gb(f,i),p=f[f.length-1];return(!p||p.type!=="node"||p.node.isInline&&!p.node.isText||/\n$/.test(p.node.text))&&d.push(m.createElement(eb,{getPos:i,key:"trailing-hack-img"}),m.createElement(cb,{getPos:i,key:"trailing-hack-br"})),m.createElement(m.Fragment,null,d)}),ti={current(){return-1}},yb=m.memo(m.forwardRef(function(e,t){let{className:r,node:o,innerDeco:s,outerDeco:i,as:l,viewDesc:a,...c}=e;const u=m.useRef(null);m.useImperativeHandle(t,()=>u.current,[]);const{childDescriptors:f,nodeViewDescRef:d}=Gs(o,()=>ti.current(),u,u,s,i,a),p=m.useMemo(()=>({parentRef:d,siblingsRef:f}),[f,d]),h={...c,ref:u,className:r,suppressContentEditableWarning:!0},b=l?m.cloneElement(l,h,m.createElement(Ce.Provider,{value:p},m.createElement(tr,{getPos:ti,node:o,innerDecorations:s}))):m.createElement("div",h,m.createElement(Ce.Provider,{value:p},m.createElement(tr,{getPos:ti,node:o,innerDecorations:s})));if(!o)return b;const g=i.filter(w=>!w.inline);return g.length?g.reduce(to,b):b})),Ou=m.createContext(null);function bb(n,e){let{as:t,...r}=n;const o=m.useRef([]),s=m.useRef(null),{setMount:i,...l}=m.useContext(Ou),a=m.useRef(void 0);m.useImperativeHandle(e,()=>s.current,[]);const c=m.useMemo(()=>({parentRef:a,siblingsRef:o}),[o,a]);return m.createElement(Ce.Provider,{value:c},m.createElement(yb,{ref:u=>{s.current=u,i(u)},...r,...l,as:t}))}const Tu=m.forwardRef(bb),xb=[];function kb(n){var h;let{className:e,children:t,nodeViews:r,customNodeViews:o,...s}=n;const[i,l]=m.useState(null),{editor:a,state:c}=$y(i,{...s,nodeViews:o}),u=a.view?ty(a.view,a.cursorWrapper):H.empty,f=a.view?Ug(a.view):xb,d=m.useMemo(()=>({nodeViews:r??{}}),[r]),p=m.useMemo(()=>{var b;return{className:e,setMount:l,node:(b=a.view)==null?void 0:b.state.doc,innerDeco:u,outerDeco:f,viewDesc:a.docViewDescRef.current}},[e,a.docViewDescRef,(h=a.view)==null?void 0:h.state.doc,u,f]);return m.createElement(wt.Provider,{value:a},m.createElement(Xg.Provider,{value:c},m.createElement(qc.Provider,{value:d},m.createElement(Ou.Provider,{value:p},t))))}function vu(n){return m.createElement(jy,null,m.createElement(kb,n))}function re(n){const e=m.useRef(n),{view:t}=m.useContext(wt);return Ke(()=>{e.current=n},[n]),m.useCallback(function(){for(var r=arguments.length,o=new Array(r),s=0;s<r;s++)o[s]=arguments[s];return e.current(t,...o)},[t])}function Au(n){const e=m.useContext(Mu),t=re(n);Ke(()=>{e(t)},[e,t])}const Pu=n=>[Gg(),Ro({Tab:jc(1),"Shift-Tab":jc(-1)}),hm(n.schema),Ro(lm(n.schema)),Ro(Hd),Kd({color:"#F00",width:2}),Ap(),Sd(),pm(n),fy()],Sb=["p",0],Cb=["blockquote",0],wb=["hr"],Mb=["pre",["code",0]],Nb=["br"],Eb={doc:{content:"block+"},paragraph:{content:"inline*",group:"block",parseDOM:[{tag:"p"}],toDOM(){return Sb}},blockquote:{content:"block+",group:"block",defining:!0,parseDOM:[{tag:"blockquote"}],toDOM(){return Cb}},horizontal_rule:{group:"block",parseDOM:[{tag:"hr"}],toDOM(){return wb}},heading:{attrs:{level:{default:1,validate:"number"}},content:"inline*",group:"block",defining:!0,parseDOM:[{tag:"h1",attrs:{level:1}},{tag:"h2",attrs:{level:2}},{tag:"h3",attrs:{level:3}},{tag:"h4",attrs:{level:4}},{tag:"h5",attrs:{level:5}},{tag:"h6",attrs:{level:6}}],toDOM(n){return["h"+n.attrs.level,0]}},code_block:{content:"text*",marks:"",group:"block",code:!0,defining:!0,parseDOM:[{tag:"pre",preserveWhitespace:"full"}],toDOM(){return Mb}},text:{group:"inline"},image:{inline:!0,attrs:{src:{validate:"string"},alt:{default:null,validate:"string|null"},title:{default:null,validate:"string|null"}},group:"inline",draggable:!0,parseDOM:[{tag:"img[src]",getAttrs(n){return{src:n.getAttribute("src"),title:n.getAttribute("title"),alt:n.getAttribute("alt")}}}],toDOM(n){let{src:e,alt:t,title:r}=n.attrs;return["img",{src:e,alt:t,title:r}]}},hard_break:{inline:!0,group:"inline",selectable:!1,parseDOM:[{tag:"br"}],toDOM(){return Nb}}},Db=["em",0],Ob=["strong",0],Tb=["code",0],vb={link:{attrs:{href:{validate:"string"},title:{default:null,validate:"string|null"}},inclusive:!1,parseDOM:[{tag:"a[href]",getAttrs(n){return{href:n.getAttribute("href"),title:n.getAttribute("title")}}}],toDOM(n){let{href:e,title:t}=n.attrs;return["a",{href:e,title:t},0]}},em:{parseDOM:[{tag:"i"},{tag:"em"},{style:"font-style=italic"},{style:"font-style=normal",clearMark:n=>n.type.name=="em"}],toDOM(){return Db}},strong:{parseDOM:[{tag:"strong"},{tag:"b",getAttrs:n=>n.style.fontWeight!="normal"&&null},{style:"font-weight=400",clearMark:n=>n.type.name=="strong"},{style:"font-weight",getAttrs:n=>/^(bold(er)?|[5-9]\d{2,})$/.test(n)&&null}],toDOM(){return Ob}},code:{code:!0,parseDOM:[{tag:"code"}],toDOM(){return Tb}}},Iu=new gr({nodes:Eb,marks:vb}),Vu=Iu.spec.marks.append({underline:{parseDOM:[{tag:"u"},{style:"font-style=underline"}],toDOM(){return["u",0]}},strikethrough:{parseDOM:[{tag:"s"},{style:"font-style=strike"},{style:"font-style=strikethrough"}],toDOM(){return["s",0]}}}),no="https://dailytelefrag.ru/api",ro="https://dailytelefrag.ru/error_image.png",Ru="https://dailytelefrag.ru/error_embed.png",Ab=(n,e)=>{try{const t=new URL(n);if(t.hostname!=="vkvideo.ru"&&t.hostname!=="vk.com")throw new Error;let r,o;if(t.pathname==="/video_ext.php")r=t.searchParams.get("id"),o=t.searchParams.get("oid");else if(t.pathname.startsWith("/video"))[o,r]=t.pathname.slice(6).split("_");else throw new Error;if(!r||!o)throw new Error;return e?`https://vkvideo.ru/video_ext.php?oid=${o}&id=${r}&hd=2`:!0}catch{return""}},Pb=(n,e)=>{try{const t=new URL(n);if(t.hostname!=="rutube.ru")throw new Error;let r;if(t.pathname.startsWith("/video/"))r=t.pathname.split("/")[2];else if(t.pathname.startsWith("/play/embed/"))r=t.pathname.split("/")[3];else throw new Error;if(!r)throw new Error;return e?`https://rutube.ru/play/embed/${r}`:!0}catch{return""}},Ib=(n,e)=>{try{const t=new URL(n);if(t.hostname!=="youtube.com"&&t.hostname!=="www.youtube.com"&&t.hostname!=="youtu.be")throw new Error;if(t.hostname==="youtu.be")return e?`https://youtube.com/embed${t.pathname}`:!0;let r;if(t.pathname==="/watch")r=t.searchParams.get("v");else if(t.pathname.startsWith("/live/"))r=t.pathname.split("/")[2];else if(t.pathname.startsWith("/embed/"))r=t.pathname.split("/")[2];else throw new Error;if(!r)throw new Error;return e?`https://youtube.com/embed/${r}`:!0}catch{return""}},oo=n=>{try{const e=new URL(n);switch(e.hostname){case"vkvideo.ru":case"vk.com":return Ab(e,!0)+"";case"rutube.ru":return Pb(e,!0)+"";case"youtube.com":case"www.youtube.com":case"youtu.be":return Ib(e,!0)+"";default:throw new Error}}catch{return""}},Vb={atom:!0,attrs:{fid:{default:null,validate:"string|null|number"},src:{default:null,validate:"string|null"},alt:{default:null,validate:"string|null"},title:{default:null,validate:"string|null"}},group:"block",parseDOM:[{tag:"img[src]",getAttrs(n){return{fid:n.getAttribute("fid"),src:n.getAttribute("src"),alt:n.getAttribute("alt"),title:n.getAttribute("title")}}}],toDOM(n){let{fid:e,src:t,alt:r,title:o}=n.attrs;return e&&(t=`${no}/files/${e}`),t||(t=ro),["div",{title:o,class:"image"},["img",{fid:e,src:t,alt:r,title:o}]]}},Rb={atom:!0,attrs:{src:{validate:"string"},title:{default:null,validate:"string|null"}},group:"block",parseDOM:[{tag:"iframe[src]",getAttrs(n){return{src:n.getAttribute("src"),title:n.getAttribute("title")}}}],toDOM(n){const{src:e,title:t}=n.attrs,r="fullscreen; accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share";return oo(e)?["div",{title:t,class:"video"},["iframe",{src:e,title:t,allow:r}]]:["div",{title:t,class:"image"},["img",{src:Ru}]]}},zb={content:"inline*",group:"block",attrs:{align:{default:null,validate:"string|null"}},parseDOM:[{tag:"p",getAttrs(n){let e=n.getAttribute("align");return e!=="right"&&e!=="center"&&e!=="justify"&&(e=null),{align:e}}}],toDOM(n){const{align:e}=n.attrs;return["p",{align:e},0]}},$b={attrs:{level:{default:1,validate:"number"}},content:"inline*",marks:"underline strikethrough",group:"block",parseDOM:[{tag:"h1",attrs:{level:1}},{tag:"h2",attrs:{level:2}},{tag:"h3",attrs:{level:3}},{tag:"h4",attrs:{level:4}},{tag:"h5",attrs:{level:5}},{tag:"h6",attrs:{level:6}}],toDOM(n){return["h"+n.attrs.level,0]}},jb={atom:!0,content:"image*",group:"block",toDOM(){return["div",{class:"carousel"},0]}},zu=Iu.spec.nodes.remove("image").append({image:Vb,video:Rb}),so=new gr({nodes:zu.remove("horizontal_rule").remove("heading"),marks:Vu}),Bb=zu.remove("heading").remove("paragraph").prepend({paragraph:zb}).append({heading:$b}).append({carousel:jb}).append(ug({tableGroup:"block",cellContent:"(paragraph | ordered_list | bullet_list)+",cellAttributes:{halign:{default:null,getFromDOM(n){const e=n.getAttribute("align")||null;return e==="left"||e==="right"||e==="center"?e:null},setDOMAttr(n,e){n&&(e.style=(e.style||"")+`text-align: ${n};`)}},valign:{default:null,getFromDOM(n){const e=n.style.verticalAlign||null;return e==="top"||e==="bottom"||e==="middle"?e:null},setDOMAttr(n,e){n&&(e.style=(e.style||"")+`vertical-align: ${n};`)}}}})),Nt=new gr({nodes:Wp(Bb,"(paragraph | ordered_list | bullet_list)+","block"),marks:Vu}),Fb=n=>{if(n)try{const e=be.fromJSON(Nt,JSON.parse(n)),t=$e.fromSchema(Nt).serializeFragment(e.content);return Pt.fromSchema(so).parse(t)}catch(e){console.error(`Can not convert content to simple schema: ${e}`)}},nr=({ref:n,item:e})=>{const[t,r]=m.useState(!0),[o,s]=m.useState(!1),[i,l]=m.useState(!1);Ke(c=>{c&&(r(e.isActive&&e.isActive(c.state)),l(e.isSelected&&!e.isSelected(c.state)),e.isDisabled?s(e.isDisabled(c.state)):s(!e.command(c.state)))});const a=re(c=>{c&&(o||e.command(c.state,c.dispatch,c),c.focus())});return i?null:y.jsx("div",{ref:n,className:`MenuItem ${t?"active":""} ${o?"disabled":""}`,onClick:c=>{c.stopPropagation(),c.preventDefault(),a()},children:e.icon})},$u=({schema:n})=>{const[e,t]=m.useState(void 0),[r,o]=m.useState(void 0);return m.useEffect(()=>{if(t(void 0),o(void 0),n.nodes.paragraph){const s=n.nodes.paragraph;t({icon:y.jsx(E.Icons.Type,{}),command:on(s)})}if(n.nodes.code_block){const s=n.nodes.code_block;o({icon:y.jsx(E.Icons.CodeXml,{}),command:on(s)})}},[n]),y.jsxs(y.Fragment,{children:[e&&y.jsx(nr,{item:e}),r&&y.jsx(nr,{item:r})]})},rr=({items:n})=>y.jsx("div",{className:"MenuBlock",children:n.map((e,t)=>y.jsx(nr,{item:e},t))}),Lb=({schema:n,isOpen:e,onClose:t})=>{const r=re((o,s)=>{o&&(ke(n.marks.link,{href:s})(o.state,o.dispatch),t(),o.focus())});return y.jsx(E.Prompt,{title:"Введите URL для ссылки",isOpen:e,onCancel:t,onSubmit:r})},ju=({schema:n})=>{const[e,t]=m.useState([]),[r,o]=m.useState(!1);return m.useEffect(()=>{const s=[];if(n.marks.strong){const i=n.marks.strong;s.push({icon:y.jsx(E.Icons.Bold,{}),command:ke(i),isActive:l=>Jt(l,i)})}if(n.marks.em){const i=n.marks.em;s.push({icon:y.jsx(E.Icons.Italic,{}),command:ke(i),isActive:l=>Jt(l,i)})}if(n.marks.underline){const i=n.marks.underline;s.push({icon:y.jsx(E.Icons.Underline,{}),command:ke(i),isActive:l=>Jt(l,i)})}if(n.marks.strikethrough){const i=n.marks.strikethrough;s.push({icon:y.jsx(E.Icons.Strikethrough,{}),command:ke(i),isActive:l=>Jt(l,i)})}if(n.marks.code){const i=n.marks.code;s.push({icon:y.jsx(E.Icons.Code,{}),command:ke(i),isActive:l=>Jt(l,i)})}if(n.marks.link){const i=n.marks.link;s.push({icon:y.jsx(E.Icons.Link,{}),isActive:l=>Jt(l,i),isDisabled:l=>l.selection.empty?!0:!ke(i)(l),command:(l,a,c)=>(Jt(l,i)?(ke(i)(l,a),c==null||c.focus()):o(!0),!0)})}t(s)},[n]),e.length<1?null:y.jsxs(y.Fragment,{children:[y.jsx(rr,{items:e}),y.jsx(Lb,{isOpen:r,schema:n,onClose:()=>o(!1)})]})};function Jt(n,e){let{from:t,$from:r,to:o,empty:s}=n.selection;return s?!!e.isInSet(n.storedMarks||r.marks()):n.doc.rangeHasMark(t,o,e)}const Bu=()=>y.jsxs("div",{className:"MenuBlock",children:[y.jsx(nr,{item:{icon:y.jsx(E.Icons.Undo,{}),command:Ao}}),y.jsx(nr,{item:{icon:y.jsx(E.Icons.Redo,{}),command:Mr}})]}),Fu=({schema:n})=>{const[e,t]=m.useState([]);return m.useEffect(()=>{const r=[];if(n.nodes.bullet_list){const o=n.nodes.bullet_list;r.push({icon:y.jsx(E.Icons.List,{}),command:(s,i)=>Rr(o)(s,i)})}if(n.nodes.ordered_list){const o=n.nodes.ordered_list;r.push({icon:y.jsx(E.Icons.ListOrdered,{}),command:(s,i)=>Rr(o)(s,i)})}if(n.nodes.blockquote){const o=n.nodes.blockquote;r.push({icon:y.jsx(E.Icons.Quote,{}),command:(s,i)=>Cl(o)(s,i)})}t(r)},[n]),e.length<1?null:y.jsx(rr,{items:e})},Lu=({pos:n,isOpen:e,onClose:t})=>{const[r,o]=m.useState(""),[s,i]=m.useState(),[l,a]=m.useState(""),[c,u]=m.useState(!1);m.useEffect(()=>{o(""),a(""),i(void 0)},[e]),Ke(d=>{if(!d||!e)return;const p=tt.getState(d.state);u(p.upload!==void 0)},[e]);const f=re(d=>{d&&(c?gm(d,s,l,n):ym(d,r,l,n),d.focus(),t())});return y.jsxs(E.Modal,{isOpen:e,onClose:t,children:[y.jsx("h1",{children:"Вставка картинки"}),y.jsxs(E.Form,{submit:"Вставить",submitType:"Success",onSubmit:f,onCancel:t,children:[c?y.jsx(E.Image,{id:"image",value:s,onChange:i,text:y.jsxs("span",{children:[y.jsx(E.Icons.Image,{}),y.jsx("br",{}),"Выберите файл"]}),required:!0,label:"Картинка"}):y.jsx(E.Input,{id:"href",value:r,onChange:o,required:!0,label:"Ссылка на картинку"}),y.jsx(E.Input,{id:"value",value:l,onChange:a,label:"Подпись"})]})]})},Wb=({schema:n,isOpen:e,onClose:t})=>{const[r,o]=m.useState(""),[s,i]=m.useState("");m.useEffect(()=>{o(""),i("")},[e]);const l=re(a=>{const c=n.nodes.video;if(!a||!r||!c)return;const u=oo(r);a.dispatch(a.state.tr.replaceSelectionWith(c.create({src:u,title:s}))),a.focus(),t()});return n.nodes.video?y.jsxs(E.Modal,{isOpen:e,onClose:t,children:[y.jsx("h1",{children:"Вставка видео"}),y.jsxs(E.Form,{submit:"Вставить",submitType:"Success",onSubmit:l,onCancel:t,children:[y.jsx(E.Input,{id:"src",value:r,onChange:o,label:"Ссылка на видео",bottom:"Поддерживаются VK Video, RuTube и YouTube",required:!0}),y.jsx(E.Input,{id:"value",value:s,onChange:i,label:"Подпись"})]})]}):null},Wu=({schema:n})=>{const[e,t]=m.useState([]),[r,o]=m.useState(!1),[s,i]=m.useState(!1);return m.useEffect(()=>{const l=[];if(n.nodes.image){const a=n.nodes.image;l.push({icon:y.jsx(E.Icons.Image,{}),isDisabled:c=>!ni(c,a),command:()=>(o(!0),!0)})}if(n.nodes.video){const a=n.nodes.video;l.push({icon:y.jsx(E.Icons.Film,{}),isDisabled:c=>!ni(c,a),command:()=>(i(!0),!0)})}if(n.nodes.horizontal_rule){const a=n.nodes.horizontal_rule;l.push({icon:y.jsx(E.Icons.FlipVertical,{}),isDisabled:c=>!ni(c,a),command:(c,u)=>u?(u(c.tr.replaceSelectionWith(a.create())),!0):!1})}n.nodes.table&&l.push({icon:y.jsx(E.Icons.Table,{}),isDisabled:Oe,command:_b()}),t(l)},[n]),e.length<1?null:y.jsxs(y.Fragment,{children:[y.jsx(rr,{items:e}),y.jsx(Lu,{isOpen:r,onClose:()=>o(!1)}),y.jsx(Wb,{isOpen:s,schema:n,onClose:()=>i(!1)})]})},ni=(n,e)=>{let t=n.selection.$from;for(let r=t.depth;r>=0;r--){let o=t.index(r);if(t.node(r).canReplaceWith(o,o,e))return!0}return!1};function _b(){return(n,e)=>{const t=n.tr.selection.anchor+1,r=n.tr,o=n.schema.nodes.table_cell.createAndFill(),s=n.schema.nodes.table.create(null,S.fromArray([n.schema.nodes.table_row.create(null,S.fromArray([o,o,o])),n.schema.nodes.table_row.create(null,S.fromArray([o,o,o]))]));return e&&e(r.replaceSelectionWith(s).scrollIntoView().setSelection(P.near(r.doc.resolve(t)))),!0}}const _u=({schema:n})=>n.nodes.carousel?y.jsx(rr,{items:[{icon:y.jsx(E.Icons.JoinUp,{}),command:bl},{icon:y.jsx(E.Icons.IndentDecrease,{}),command:$o},{icon:y.jsx(E.Icons.SquareDashed,{}),command:Bo}]}):y.jsx(rr,{items:[{icon:y.jsx(E.Icons.IndentDecrease,{}),command:$o},{icon:y.jsx(E.Icons.SquareDashed,{}),command:Bo}]}),qb=({schema:n})=>y.jsxs("div",{className:"SimpleMenuBar",children:[y.jsx("div",{className:"MenuBlock",children:y.jsx($u,{schema:n})}),y.jsx(ju,{schema:n}),y.jsx(Wu,{schema:n}),y.jsx(Fu,{schema:n}),y.jsx(_u,{schema:n}),y.jsx(Bu,{})]}),qu=m.forwardRef(function({children:e,nodeProps:t,...r},o){const[s,i]=m.useState(t.node.attrs.alt??""),[l,a]=m.useState(t.node.attrs.title??""),[c,u]=m.useState(!1),[f,d]=m.useState("");Au((k,w)=>k?!(w instanceof MouseEvent):!1),Ke(k=>{if(d(""),u(!1),!k||!k.state.schema.nodes.carousel)return;const w=t.getPos(),M=k.state.doc.resolve(w).parent;if(u(M.type.name!=="carousel"),M.type.name==="carousel"){let O=0;M.forEach((I,C)=>{I===t.node&&(O=C+1)}),d(O?`${O} / ${M.childCount}`:"")}});const p=re((k,w)=>{if(!k)return;i(w);const M=k.state.tr,O=t.getPos();k.dispatch(M.setNodeMarkup(O,null,{...t.node.attrs,alt:w})),k.focus()}),h=re((k,w)=>{if(!k)return;a(w);const M=k.state.tr,O=t.getPos();k.dispatch(M.setNodeMarkup(O,null,{...t.node.attrs,title:w})),k.focus()}),b=re(k=>{if(!k)return;const w=t.getPos(),M=t.node.nodeSize,O=t.node.attrs,I=k.state.schema,C=I.nodes.carousel.create(null,I.nodes.image.create(O));k.dispatch(k.state.tr.replaceWith(w,w+M,C))}),g=re(k=>{if(!k)return;const w=k.state.tr,M=t.getPos(),O=t.node.nodeSize;k.dispatch(w.delete(M,M+O))});return y.jsxs("div",{...r,ref:o,className:"image",title:t.node.attrs.title,children:[y.jsxs("div",{className:"image-buttons",children:[c&&y.jsx("div",{onClick:b,className:"text-button",children:"Сделать карусель"}),f&&y.jsx("div",{className:"text-button",children:f}),y.jsx("div",{onClick:g,children:y.jsx(E.Icons.Trash,{})})]}),y.jsx("div",{children:y.jsx(E.Editable,{value:s,placeholder:"Alt: описание изображения (не обязательно)",onChange:p,empty:!0,style:{textAlign:"center",cursor:"text"}})}),y.jsx("img",{title:t.node.attrs.title,alt:t.node.attrs.alt,src:t.node.attrs.fid?`${no}/files/${t.node.attrs.fid}`:t.node.attrs.src}),y.jsx("div",{children:y.jsx(E.Editable,{value:l,placeholder:"Title: подпись под изображением (не обязательно)",onChange:h,empty:!0,style:{textAlign:"center",cursor:"text"}})})]})}),Hu=m.forwardRef(function({children:e,nodeProps:t,...r},o){const[s,i]=m.useState(""),[l,a]=m.useState(t.node.attrs.title??""),c="fullscreen; accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share";Au(()=>!0),m.useEffect(()=>{i(oo(t.node.attrs.src))},[t]);const u=re((f,d)=>{if(!f)return;a(d);const{$from:p,$to:h}=f.state.selection,b=p.blockRange(h);if(b){const g=f.state.doc;let k=f.state.tr;g.nodesBetween(b.start,b.end,(w,M)=>{w.type.name==="video"&&(k=k.setNodeMarkup(M,null,{...t.node.attrs,title:d}))}),f.dispatch(k)}f.focus()});return y.jsxs("div",{...r,ref:o,className:s?"video":"image",title:t.node.attrs.title,children:[s?y.jsx("iframe",{src:s,allow:c}):y.jsx("img",{src:Ru}),y.jsx("div",{children:y.jsx(E.Editable,{value:l,placeholder:"Подпись под видео (не обязательно)",onChange:u,empty:!0,style:{textAlign:"center",cursor:"text"}})})]})}),Ku=({onSave:n,disabled:e=!1,notEmpty:t=!0,wasChanged:r=!0})=>{const[o,s]=m.useState(!0);Ke(l=>{let a=!1;const c=l.state.doc,u=!!c.textBetween(0,c.content.size,void 0," ").length,f=!!Po(l.state);r&&t?a=u&&f:r?a=f:t&&(a=u),s(a)});const i=re(l=>{try{let a;const c=Is(l.state);if(c){const u=l.state.apply(c.setMeta("addToHistory",!1));a=JSON.stringify(u.doc.toJSON())}else a=JSON.stringify(l.state.doc.toJSON());n({content:a,format:"prose"})}catch(a){console.error(`Can not save doc: ${a}`)}});return y.jsx(E.Button,{type:"Accent",disabled:e||!o,label:"Сохранить",size:"Small",onClick:i})},Hb=({title:n=!1,content:e,onSave:t,onCancel:r,onChange:o,onUpload:s})=>{const[i,l]=m.useState(""),[a,c]=m.useState();m.useEffect(()=>{const p=Ge.create({doc:Fb(e),schema:so,plugins:Pu({schema:so,upload:s})});c(p),n!==!1&&l(typeof n=="string"?n:"")},[n,e]);const u=()=>n!==!1?i.trim().length>0:!0,f=p=>{!t||!u()||t({...p,name:i})},d=()=>{r&&r()};return a?y.jsxs("div",{className:"ProseNotes",children:[n!==!1&&y.jsx("input",{className:"ProseNotesTitle",onChange:p=>l(p.currentTarget.value),value:i,placeholder:"Укажите заголовок"}),y.jsxs(vu,{state:a,dispatchTransaction:p=>c(h=>{const b=h==null?void 0:h.apply(p);return b&&o&&o(!!Po(b)),b}),nodeViews:{image:qu,video:Hu},children:[y.jsxs("div",{className:"ProseNotesContent",children:[y.jsx(qb,{schema:so}),y.jsx(Tu,{})]}),(t||r)&&y.jsxs("div",{className:"ProseNotesButtons",children:[r&&y.jsx("span",{className:"a small",onClick:d,children:"Отменить"}),t&&y.jsx(Ku,{onSave:f,disabled:!u(),wasChanged:!1})]})]})]}):null},Kb=({schema:n})=>{const e=m.useRef(null),[t,r]=m.useState([]),[o,s]=m.useState([]),[i,l]=m.useState(!1);Ke(c=>{const u=n.nodes.heading;if(!c||!u||!i)return;const f=[],d=[];for(let p=2;p<7;p++){const b=on(u,{level:p});d[p]=b,f[p]={id:p,icon:y.jsx(Jb,{level:p}),text:`уровень ${p}`,disabled:!b(c.state)}}r(f),s(d)},[i]);const a=re((c,u)=>{!c||!u.id||(o[u.id](c.state,c.dispatch,c),l(!1),c.focus())});return n.nodes.heading?y.jsxs(y.Fragment,{children:[y.jsx("div",{ref:e,className:"MenuItem",onClick:()=>l(!0),children:y.jsx(E.Icons.Heading,{})}),e.current&&y.jsx(E.Menu,{parent:e.current,items:t,isOpen:i,onClose:()=>l(!1),onClick:a,horizontal:"inner-left"})]}):null},Jb=({level:n})=>{switch(n){case 2:return y.jsx(E.Icons.Heading2,{});case 3:return y.jsx(E.Icons.Heading3,{});case 4:return y.jsx(E.Icons.Heading4,{});case 5:return y.jsx(E.Icons.Heading5,{});case 6:return y.jsx(E.Icons.Heading6,{});default:return y.jsx(E.Icons.Heading,{})}},Yb=[{id:"left",icon:y.jsx(E.Icons.AlignLeft,{}),text:"Прижать влево"},{id:"right",icon:y.jsx(E.Icons.AlignRight,{}),text:"Прижать вправо"},{id:"center",icon:y.jsx(E.Icons.AlignCenter,{}),text:"Отцентровать"},{id:"justify",icon:y.jsx(E.Icons.AlignJustify,{}),text:"Выровнять по краям"}],Gb=({schema:n})=>{const e=m.useRef(null),[t,r]=m.useState(!1),o=re((s,i)=>{if(!s||!i.id)return;const l=i.id==="left"?null:i.id,{$from:a,$to:c}=s.state.selection,u=a.blockRange(c);if(u){const f=s.state.doc;let d=s.state.tr;f.nodesBetween(u.start,u.end,(p,h)=>{p.type.name==="paragraph"&&(d=d.setNodeMarkup(h,null,{align:l}))}),s.dispatch(d)}s.focus(),r(!1)});return n.nodes.paragraph?y.jsxs(y.Fragment,{children:[y.jsx("div",{ref:e,className:"MenuItem",onClick:()=>r(!0),children:y.jsx(E.Icons.AlignLeft,{})}),e.current&&y.jsx(E.Menu,{parent:e.current,items:Yb,isOpen:t,onClose:()=>r(!1),onClick:o,horizontal:"inner-left"})]}):null},Xb=({schema:n,onSave:e})=>y.jsxs("div",{className:"MenuBar",children:[y.jsxs("div",{className:"MenuBlock",children:[y.jsx(Kb,{schema:n}),y.jsx($u,{schema:n})]}),y.jsx(ju,{schema:n}),y.jsx(Wu,{schema:n}),y.jsx(Fu,{schema:n}),y.jsx(Gb,{schema:n}),y.jsx(_u,{schema:n}),y.jsx(Bu,{}),y.jsx("div",{className:"MenuBlock",children:y.jsx(Ku,{onSave:e})})]}),Ub=7,Ju=1,or=50,Qb=({width:n,onChange:e,onWidth:t})=>{const[r,o]=m.useState(!1),[s,i]=m.useState(0),[l,a]=m.useState(0),[c,u]=m.useState(n),f=h=>{const b=n[l],g=n[l+1],k=[...c];return b+h<or&&(h=or-b),g-h<or&&(h=g-or),k[l]=b+h,k[l+1]=g-h,k};m.useEffect(()=>{u(n)},[n]),m.useEffect(()=>{const h=g=>{if(!r)return;o(!1),g.preventDefault(),g.stopPropagation();const k=g.clientX-s,w=f(k);t(w)},b=g=>{if(!r)return;g.preventDefault(),g.stopPropagation();const k=g.clientX-s,w=f(k);u(w),e(w)};return document.addEventListener("mouseup",h),document.addEventListener("mousemove",b),()=>{document.removeEventListener("mouseup",h),document.removeEventListener("mousemove",b)}},[r,l]);const d=(h,b)=>{b!==n.length-1&&(h.preventDefault(),h.stopPropagation(),o(!0),i(h.clientX),a(b))},p=h=>c.slice(0,h+1).reduce((b,g)=>b+g,0)+h+Ju-Math.floor(Ub/2);return y.jsx("div",{className:"table-resizer",children:c.map((h,b)=>y.jsx("div",{style:{left:p(b)+"px"},onMouseDown:g=>d(g,b)},b))})},Zb=m.forwardRef(function({children:e,nodeProps:t,...r},o){var f;const s=m.useRef(null),i=m.useRef(null),[l,a]=m.useState([]),c=re((d,p)=>{if(!d)return;const h=t.node,b=t.getPos()+1,g=Q.get(h),k=d.state.tr;for(let w=0;w<g.height;w++)for(let M=0;M<g.width;){const O=w*g.width+M,I=g.map[O],C=h.nodeAt(I).attrs,V=p.slice(M,M+C.colspan);w&&g.map[O]==g.map[O-g.width]||k.setNodeMarkup(b+I,null,{...C,colwidth:V}),M+=C.colspan}k.docChanged&&d.dispatch(k)});m.useEffect(()=>{if(!s.current||!i.current)return;const p=t.node.firstChild;if(!p)return;let h=[];for(let C=0;C<p.childCount;C++){const V=p.child(C),{colspan:z,colwidth:T}=V.attrs;h=h.concat(Array.isArray(T)?T:Array(z).fill(0))}const b=h.filter(C=>!C).length,g=h.reduce((C,V)=>C+V,0),k=(h.length+1)*Ju,w=Math.max(b?(s.current.offsetWidth-g-k)/b:0,or);h=h.map(C=>C||w);const M=h.reduce((C,V)=>C+V,0),O=i.current.offsetWidth-k-16,I=O/M;h=h.map(C=>Math.round(C*I)),h[h.length-1]+=O-h.reduce((C,V)=>C+V,0),a(h)},[t,s,i,(f=i.current)==null?void 0:f.offsetWidth]);const u=re(d=>{Fg(d.state,d.dispatch)});return y.jsxs("div",{...r,className:"table-wrapper",ref:d=>{i.current=d,o&&(typeof o=="function"?o(d):o.current=d)},children:[y.jsx(Qb,{width:l,onChange:a,onWidth:c}),y.jsxs("table",{ref:s,children:[y.jsx("colgroup",{children:l.map((d,p)=>y.jsx("col",{width:d},p))}),y.jsx("caption",{onClick:u,children:y.jsx(E.Icons.Trash,{})}),y.jsx("tbody",{children:e})]})]})}),e0=[{id:"toggleHeaderRow",text:"Toggle header row",icon:y.jsx(E.Icons.Heading,{})},{id:"addRowBefore",text:"Insert row before",icon:y.jsx(E.Icons.RowInsertBefore,{})},{id:"addRowAfter",text:"Insert row after",icon:y.jsx(E.Icons.RowInsertAfter,{})},{id:"deleteRow",text:"Delete row",icon:y.jsx(E.Icons.Trash,{})}],t0=[{id:"toggleHeaderColumn",text:"Toggle header column",icon:y.jsx(E.Icons.Heading,{})},{id:"addColumnBefore",text:"Insert column before",icon:y.jsx(E.Icons.ColumnInsertBefore,{})},{id:"addColumnAfter",text:"Insert column after",icon:y.jsx(E.Icons.ColumnInsertAfter,{})},{id:"deleteColumn",text:"Delete column",icon:y.jsx(E.Icons.Trash,{})}],n0=[{id:"toggleHeaderCell",text:"Toggle header",icon:y.jsx(E.Icons.Heading,{})},{id:"alignLeft",text:"Horizontal align left",icon:y.jsx(E.Icons.AlignLeft,{})},{id:"alignCenter",text:"Horizontal align center",icon:y.jsx(E.Icons.AlignCenter,{})},{id:"alignRight",text:"Horizontal align Right",icon:y.jsx(E.Icons.AlignRight,{})},{id:"alignTop",text:"Vertical align top",icon:y.jsx(E.Icons.AlignTop,{})},{id:"alignMiddle",text:"Vertical align middle",icon:y.jsx(E.Icons.AlignMiddle,{})},{id:"alignBottom",text:"Vertical align bottom",icon:y.jsx(E.Icons.AlignBottom,{})},{id:"mergeCells",text:"Merge cells",icon:y.jsx(E.Icons.CellsMerge,{})},{id:"splitCell",text:"Split cell",icon:y.jsx(E.Icons.CellsSplit,{})}],Yu=({parent:n,isRowMenuOpen:e,isCellMenuOpen:t,isColumnMenuOpen:r,onRowMenuClose:o,onCellMenuClose:s,onColumnMenuClose:i})=>{const l=re((a,c)=>{if(a){switch(c.id){case"toggleHeaderRow":zg(a.state,a.dispatch);break;case"addRowBefore":Dg(a.state,a.dispatch);break;case"addRowAfter":Og(a.state,a.dispatch);break;case"deleteRow":vg(a.state,a.dispatch);break;case"toggleHeaderColumn":$g(a.state,a.dispatch);break;case"addColumnBefore":Cg(a.state,a.dispatch);break;case"addColumnAfter":wg(a.state,a.dispatch);break;case"deleteColumn":Ng(a.state,a.dispatch);break;case"mergeCells":Pg(a.state,a.dispatch);break;case"splitCell":Ig(a.state,a.dispatch);break;case"toggleHeaderCell":jg(a.state,a.dispatch);break;case"alignLeft":mn("halign","left")(a.state,a.dispatch);break;case"alignCenter":mn("halign","center")(a.state,a.dispatch);break;case"alignRight":mn("halign","right")(a.state,a.dispatch);break;case"alignTop":mn("valign","top")(a.state,a.dispatch);break;case"alignMiddle":mn("valign","middle")(a.state,a.dispatch);break;case"alignBottom":mn("valign","bottom")(a.state,a.dispatch);break}o(),s(),i(),a.focus()}});return n?y.jsxs(y.Fragment,{children:[y.jsx(E.Menu,{parent:n,items:e0,isOpen:e,onClose:o,onClick:l,vertical:"top",horizontal:"inner-left"}),y.jsx(E.Menu,{parent:n,items:n0,isOpen:t,onClose:s,onClick:l,horizontal:"inner-left"}),y.jsx(E.Menu,{parent:n,items:t0,isOpen:r,onClose:i,onClick:l,vertical:"top",horizontal:"inner-left",margin:"var(--alxgrn-unit)"})]}):null},Gu=m.forwardRef(function({children:e,nodeProps:t,...r},o){const s=m.useRef(null),[i,l]=m.useState(!1),[a,c]=m.useState(!1),[u,f]=m.useState(!1);m.useEffect(()=>{const h=b=>{s.current!==b.target&&(l(!1),c(!1),f(!1))};return document.addEventListener("contextmenu",h,!0),()=>document.removeEventListener("contextmenu",h,!0)},[]);const d=h=>{h.preventDefault(),h.stopPropagation(),l(!1),c(!1),f(!1);const b=h.currentTarget.getBoundingClientRect();h.clientY<b.y?f(!0):h.clientX<b.x?l(!0):c(!0)},p=h=>{l(!1),c(!1),f(!1);const b=h.currentTarget.getBoundingClientRect();if(h.clientY<b.y)f(!0);else if(h.clientX<b.x)l(!0);else return;h.preventDefault(),h.stopPropagation()};return t.node.type.spec.tableRole==="header_cell"?y.jsxs("th",{...r,datatype:`width-${t.node.attrs.colwidth}`,colSpan:t.node.attrs.colspan,rowSpan:t.node.attrs.rowspan,style:{textAlign:t.node.attrs.halign,verticalAlign:t.node.attrs.valign},onClick:p,onContextMenu:d,ref:h=>{s.current=h,o&&(typeof o=="function"?o(h):o.current=h)},children:[e,y.jsx(Yu,{parent:s.current,isRowMenuOpen:i,onRowMenuClose:()=>l(!1),isCellMenuOpen:a,onCellMenuClose:()=>c(!1),isColumnMenuOpen:u,onColumnMenuClose:()=>f(!1)})]}):y.jsxs("td",{...r,datatype:`width-${t.node.attrs.colwidth}`,colSpan:t.node.attrs.colspan,rowSpan:t.node.attrs.rowspan,style:{textAlign:t.node.attrs.halign,verticalAlign:t.node.attrs.valign},onClick:p,onContextMenu:d,ref:h=>{s.current=h,o&&(typeof o=="function"?o(h):o.current=h)},children:[e,y.jsx(Yu,{parent:s.current,isRowMenuOpen:i,onRowMenuClose:()=>l(!1),isCellMenuOpen:a,onCellMenuClose:()=>c(!1),isColumnMenuOpen:u,onColumnMenuClose:()=>f(!1)})]})}),r0=m.forwardRef(function({children:e,nodeProps:t,...r},o){var I;const s=m.useRef(null),[i,l]=m.useState(!1),[a,c]=m.useState(!1),[u,f]=m.useState(!1),[d,p]=m.useState(),[h,b]=m.useState(),g=C=>{const V=C.scrollLeft,z=C.clientWidth,T=C.scrollWidth;c(V>0),f(V<T-z*1.5)};m.useEffect(()=>{s.current&&(h&&s.current.scrollWidth>h&&(s.current.scrollLeft=s.current.scrollWidth-s.current.clientWidth),b(s.current.scrollWidth))},[(I=s.current)==null?void 0:I.scrollWidth]),m.useEffect(()=>{p(t.getPos()+t.node.nodeSize-1),s.current&&t.node.childCount>1&&g(s.current)},[t,s]),Ke(C=>{if(!C||t.node.childCount>0)return;const V=C.state.tr,z=t.getPos(),T=t.node.nodeSize;C.dispatch(V.delete(z,z+T))},[t]);const k=re(C=>{if(!C)return;const V=t.getPos(),z=t.node.nodeSize;C.dispatch(C.state.tr.delete(V,V+z))}),w=()=>{l(!0)},M=C=>{g(C.currentTarget)},O=(C,V)=>{if(C.stopPropagation(),!s.current)return;const z=s.current.clientWidth;let T=s.current.scrollLeft+V*z;s.current.scrollLeft=T};return y.jsxs("div",{ref:o,...r,className:"carousel",children:[y.jsx("div",{className:"carousel-list",ref:s,onScroll:M,children:e}),y.jsxs("div",{className:"carousel-buttons",children:[y.jsx("div",{onClick:k,className:"text-button",children:"Удалить карусель"}),y.jsx("div",{onClick:w,children:y.jsx(E.Icons.Plus,{})})]}),a&&y.jsx("div",{className:"carousel-prev",onClick:C=>O(C,-1),children:y.jsx(E.Icons.ChevronLeft,{})}),u&&y.jsx("div",{className:"carousel-next",onClick:C=>O(C,1),children:y.jsx(E.Icons.ChevronRight,{})}),y.jsx(Lu,{pos:d,isOpen:i,onClose:()=>l(!1)})]})}),o0=({content:n,onSave:e,onChange:t,onUpload:r})=>{const[o,s]=m.useState();return m.useEffect(()=>{let i;if(n)try{i=be.fromJSON(Nt,JSON.parse(n))}catch(c){console.error(`Can not parse Prose format: ${c}`)}let l=Ge.create({doc:i,schema:Nt,plugins:Pu({schema:Nt,upload:r})});const a=Is(l);a&&(l=l.apply(a.setMeta("addToHistory",!1))),s(l)},[n]),o?y.jsx("div",{className:"ProseEditor",children:y.jsxs(vu,{state:o,dispatchTransaction:i=>s(l=>{const a=l==null?void 0:l.apply(i);return a&&t&&t(!!Po(a)),a}),nodeViews:{image:qu,video:Hu,table:Zb,table_header:Gu,table_cell:Gu,carousel:r0},children:[y.jsx(Xb,{schema:Nt,onSave:e}),y.jsx(Tu,{})]})}):null},s0=({node:n})=>{const[e,t]=m.useState();return m.useEffect(()=>{var o;const r=(o=n.attrs)==null?void 0:o.align;t(r!=="right"&&r!=="center"&&r!=="justify"?void 0:{textAlign:r})},[n]),y.jsx("p",{style:e,children:Array.isArray(n.content)&&n.content.map((r,o)=>y.jsx(Y,{node:r},o))})},i0=({node:n})=>{if(!n.text)return null;const e=(t,r)=>{var i;if(!Array.isArray(n.marks))return y.jsx(y.Fragment,{children:r});if(!t.length)return y.jsx(y.Fragment,{children:r});const o=t[0].type,s=(i=t[0].attrs)==null?void 0:i.href;switch(o){case"em":return y.jsx("em",{children:e(t.slice(1),r)});case"code":return y.jsx("code",{children:e(t.slice(1),r)});case"strong":return y.jsx("strong",{children:e(t.slice(1),r)});case"underline":return y.jsx("u",{children:e(t.slice(1),r)});case"strikethrough":return y.jsx("s",{children:e(t.slice(1),r)});case"link":return s?y.jsx("a",{target:"_blank",href:s,children:e(t.slice(1),r)}):y.jsx(y.Fragment,{children:e(t.slice(1),r)});default:return y.jsx(y.Fragment,{children:e(t.slice(1),r)})}};return e(n.marks,n.text)},l0=({node:n,className:e})=>y.jsx("div",{className:e,children:Array.isArray(n.content)&&n.content.map((t,r)=>y.jsx(Y,{node:t},r))}),a0=({node:n})=>{const e=m.useRef(null),[t,r]=m.useState(""),[o,s]=m.useState(""),[i,l]=m.useState(""),[a,c]=m.useState(!1);m.useEffect(()=>{const f=()=>{c(!!document.fullscreenElement)};return document.addEventListener("fullscreenchange",f),()=>document.removeEventListener("fullscreenchange",f)},[]),m.useEffect(()=>{var p,h,b,g,k,w,M;let f=(p=n.attrs)==null?void 0:p.fid,d=(h=n.attrs)!=null&&h.src?`${(b=n.attrs)==null?void 0:b.src}`:"";f&&(d=`${no}/files/${f}`),d||(d=ro),r(d),s((g=n.attrs)!=null&&g.alt?`${(k=n.attrs)==null?void 0:k.alt}`:""),l((w=n.attrs)!=null&&w.title?`${(M=n.attrs)==null?void 0:M.title}`:"")},[n]);const u=f=>{var d;f.stopPropagation(),a?document.exitFullscreen():(d=e.current)==null||d.requestFullscreen()};return t?y.jsxs("div",{ref:e,className:"image",children:[y.jsx("img",{src:t,onClick:u,alt:o,title:i}),i&&y.jsx("div",{className:"image-title",children:i}),y.jsx("div",{className:"image-full",onClick:u,children:a?y.jsx(E.Icons.Minimize,{}):y.jsx(E.Icons.Maximize,{})})]}):null},c0=({node:n})=>y.jsx("blockquote",{children:Array.isArray(n.content)&&n.content.map((e,t)=>y.jsx(Y,{node:e},t))}),u0=50,f0=({node:n})=>{const[e,t]=m.useState([]);return m.useEffect(()=>{if(t([]),!Array.isArray(n.content))return;const r=n.content[0];if(!Array.isArray(r.content))return;let o=[];for(let i=0;i<r.content.length;i++){const l=r.content[i].attrs;if(!l)return;const{colspan:a,colwidth:c}=l;o=o.concat(Array.isArray(c)?c:Array(a).fill(u0))}const s=o.reduce((i,l)=>i+l,0);o=o.map(i=>Math.round(i*100/s)),o[o.length-1]+=100-o.reduce((i,l)=>i+l,0),t(o)},[n]),y.jsxs("table",{children:[e.length>0&&y.jsx("colgroup",{children:e.map((r,o)=>y.jsx("col",{width:`${r}%`},o))}),y.jsx("tbody",{children:Array.isArray(n.content)&&n.content.map((r,o)=>y.jsx(Y,{node:r},o))})]})},d0=({node:n})=>y.jsx("tr",{children:Array.isArray(n.content)&&n.content.map((e,t)=>y.jsx(Y,{node:e},t))}),h0=({node:n})=>{const[e,t]=m.useState(),[r,o]=m.useState(),[s,i]=m.useState(),[l,a]=m.useState();return m.useEffect(()=>{var c,u,f,d;t((c=n.attrs)==null?void 0:c.halign),o((u=n.attrs)==null?void 0:u.valign),i((f=n.attrs)!=null&&f.rowspan?parseInt(n.attrs.rowspan+""):1),a((d=n.attrs)!=null&&d.colspan?parseInt(n.attrs.colspan+""):1)},[n]),n.type==="table_header"?y.jsx("th",{colSpan:l,rowSpan:s,style:{textAlign:e,verticalAlign:r},children:Array.isArray(n.content)&&n.content.map((c,u)=>y.jsx(Y,{node:c},u))}):y.jsx("td",{colSpan:l,rowSpan:s,style:{textAlign:e,verticalAlign:r},children:Array.isArray(n.content)&&n.content.map((c,u)=>y.jsx(Y,{node:c},u))})},p0=({node:n})=>{var e;if(!Array.isArray(n.content))return null;switch((e=n.attrs)==null?void 0:e.level){case 1:return y.jsx("h1",{children:n.content.map((t,r)=>y.jsx(Y,{node:t},r))});case 2:return y.jsx("h2",{children:n.content.map((t,r)=>y.jsx(Y,{node:t},r))});case 3:return y.jsx("h3",{children:n.content.map((t,r)=>y.jsx(Y,{node:t},r))});case 4:return y.jsx("h4",{children:n.content.map((t,r)=>y.jsx(Y,{node:t},r))});case 5:return y.jsx("h5",{children:n.content.map((t,r)=>y.jsx(Y,{node:t},r))});case 6:return y.jsx("h6",{children:n.content.map((t,r)=>y.jsx(Y,{node:t},r))});default:return y.jsx("h2",{children:n.content.map((t,r)=>y.jsx(Y,{node:t},r))})}},m0=({node:n})=>Array.isArray(n.content)?n.type==="bullet_list"?y.jsx("ul",{children:n.content.map((e,t)=>y.jsx(Y,{node:e},t))}):y.jsx("ol",{children:n.content.map((e,t)=>y.jsx(Y,{node:e},t))}):null,g0=({node:n})=>y.jsx("li",{children:Array.isArray(n.content)&&n.content.map((e,t)=>y.jsx(Y,{node:e},t))}),y0=({node:n})=>y.jsx("pre",{children:Array.isArray(n.content)&&n.content.map((e,t)=>y.jsx(Y,{node:e},t))}),b0=()=>y.jsx("hr",{}),x0=({node:n})=>{const[e,t]=m.useState(""),[r,o]=m.useState(""),s="fullscreen; accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share";return m.useEffect(()=>{var i,l,a,c;t((i=n.attrs)!=null&&i.src?`${(l=n.attrs)==null?void 0:l.src}`:""),o((a=n.attrs)!=null&&a.title?`${(c=n.attrs)==null?void 0:c.title}`:"")},[n]),oo(e)?y.jsx("div",{title:r,className:"video",children:y.jsx("iframe",{src:e,allow:s})}):y.jsx("div",{title:r,className:"image",children:y.jsx("img",{src:ro})})},k0=()=>y.jsx("br",{}),S0=({node:n})=>{const e=m.useRef(null),t=m.useRef(null),[r,o]=m.useState(!1),[s,i]=m.useState(!1),[l,a]=m.useState(!1),[c,u]=m.useState(1),[f,d]=m.useState(1),p=g=>{const k=g.scrollLeft,w=g.clientWidth,M=g.scrollWidth;i(k>w/2),a(k<M-w*1.5),u(Math.round(k/w+1))};m.useEffect(()=>{var g;a(Array.isArray(n.content)&&n.content.length>1),d(((g=n.content)==null?void 0:g.length)??1),u(1)},[n]),m.useEffect(()=>{const g=()=>{o(!!document.fullscreenElement)};return document.addEventListener("fullscreenchange",g),()=>document.removeEventListener("fullscreenchange",g)},[]),m.useEffect(()=>{if(!r)return;const g=k=>{k.key==="ArrowLeft"&&b(null,-1),k.key==="ArrowRight"&&b(null,1)};return document.body.addEventListener("keydown",g),()=>document.body.removeEventListener("keydown",g)},[r]);const h=g=>{var k;g.stopPropagation(),r?document.exitFullscreen():(k=t.current)==null||k.requestFullscreen()},b=(g,k)=>{if(g==null||g.stopPropagation(),!e.current)return;const w=e.current.clientWidth;let M=e.current.scrollLeft+k*w;e.current.scrollLeft=M};return Array.isArray(n.content)?y.jsxs("div",{className:"carousel",ref:t,children:[y.jsx("div",{className:"carousel-list",ref:e,onScroll:g=>p(g.currentTarget),children:n.content.map((g,k)=>y.jsx(C0,{node:g,onClick:h},k))}),y.jsxs("div",{className:"carousel-numb",children:[c," / ",f]}),y.jsx("div",{className:"carousel-full",onClick:h,children:r?y.jsx(E.Icons.Minimize,{}):y.jsx(E.Icons.Maximize,{})}),s&&y.jsx("div",{className:"carousel-prev",onClick:g=>b(g,-1),children:y.jsx(E.Icons.ChevronLeft,{})}),l&&y.jsx("div",{className:"carousel-next",onClick:g=>b(g,1),children:y.jsx(E.Icons.ChevronRight,{})})]}):null},C0=({node:n,onClick:e})=>{const[t,r]=m.useState(""),[o,s]=m.useState(""),[i,l]=m.useState("");return m.useEffect(()=>{var d,p,h,b;let a=(d=n.attrs)==null?void 0:d.fid,c=(p=n.attrs)!=null&&p.src?`${n.attrs.src}`:"",u=(h=n.attrs)!=null&&h.alt?`${n.attrs.alt}`:"",f=(b=n.attrs)!=null&&b.title?`${n.attrs.title}`:"";a&&(c=`${no}/files/${a}`),c||(c=ro),r(c),s(u),l(f)},[n]),n.type!=="image"?null:y.jsxs("div",{className:"image",children:[t&&y.jsx("img",{src:t,onClick:e,alt:o,title:i}),i&&y.jsx("div",{className:"image-title",children:i})]})},Y=({node:n,className:e})=>n?(r=>{switch(r.type){case"doc":return y.jsx(l0,{node:r,className:e});case"list_item":return y.jsx(g0,{node:r});case"bullet_list":case"ordered_list":return y.jsx(m0,{node:r});case"image":return y.jsx(a0,{node:r});case"video":return y.jsx(x0,{node:r});case"text":return y.jsx(i0,{node:r});case"table":return y.jsx(f0,{node:r});case"table_row":return y.jsx(d0,{node:r});case"table_cell":case"table_header":return y.jsx(h0,{node:r});case"heading":return y.jsx(p0,{node:r});case"code_block":return y.jsx(y0,{node:r});case"paragraph":return y.jsx(s0,{node:r});case"blockquote":return y.jsx(c0,{node:r});case"carousel":return y.jsx(S0,{node:r});case"horizontal_rule":return y.jsx(b0,{});case"hard_break":return y.jsx(k0,{});default:return y.jsx("span",{className:"unknown_node_type",children:r.type})}})(n):null,w0=({content:n})=>{const[e,t]=m.useState(),[r,o]=m.useState(!1);return m.useEffect(()=>{try{o(!1);const s=JSON.parse(n);t(s)}catch(s){o(!0),console.error(`Can not parse Prose format: ${s}`)}},[n]),r?y.jsx("div",{className:"error",children:"ОШИБКА"}):y.jsx(Y,{node:e,className:"ProseViewer"})},M0=({content:n})=>{const e=m.useRef(null),[t,r]=m.useState(!1);return m.useEffect(()=>{var o;try{r(!1);const s=be.fromJSON(Nt,JSON.parse(n)),i=$e.fromSchema(Nt).serializeFragment(s.content);(o=e.current)==null||o.appendChild(i)}catch(s){r(!0),console.error(`Can not parse Prose format: ${s}`)}},[e,n]),y.jsx("div",{ref:e,className:"ProseViewer",children:t&&y.jsx("div",{className:"error",children:"ОШИБКА"})})};G.DOM=M0,G.Editor=o0,G.Notes=Hb,G.Viewer=w0,Object.defineProperty(G,Symbol.toStringTag,{value:"Module"})});
|
|
65
|
+
*/var Du;function nb(){return Du||(Du=1,process.env.NODE_ENV!=="production"&&function(){function n(s){var i=s,l=s;if(s.alternate)for(;i.return;)i=i.return;else{s=i;do i=s,i.flags&4098&&(l=i.return),s=i.return;while(s)}return i.tag===3?l:null}function e(s){if(n(s)!==s)throw Error("Unable to find node on an unmounted component.")}function t(s){var i=s.alternate;if(!i){if(i=n(s),i===null)throw Error("Unable to find node on an unmounted component.");return i!==s?null:s}for(var l=s,a=i;;){var c=l.return;if(c===null)break;var u=c.alternate;if(u===null){if(a=c.return,a!==null){l=a;continue}break}if(c.child===u.child){for(u=c.child;u;){if(u===l)return e(c),s;if(u===a)return e(c),i;u=u.sibling}throw Error("Unable to find node on an unmounted component.")}if(l.return!==a.return)l=c,a=u;else{for(var f=!1,d=c.child;d;){if(d===l){f=!0,l=c,a=u;break}if(d===a){f=!0,a=c,l=u;break}d=d.sibling}if(!f){for(d=u.child;d;){if(d===l){f=!0,l=u,a=c;break}if(d===a){f=!0,a=u,l=c;break}d=d.sibling}if(!f)throw Error("Child was not found in either parent set. This indicates a bug in React related to the return pointer. Please file an issue.")}}if(l.alternate!==a)throw Error("Return fibers should always be each others' alternates. This error is likely caused by a bug in React. Please file an issue.")}if(l.tag!==3)throw Error("Unable to find node on an unmounted component.");return l.stateNode.current===l?s:i}function r(s){var i=s.tag;if(i===5||i===26||i===27||i===6)return s;for(s=s.child;s!==null;){if(i=r(s),i!==null)return i;s=s.sibling}return null}function o(s){var i=s.tag;if(i===5||i===26||i===27||i===6)return s;for(s=s.child;s!==null;){if(s.tag!==4&&(i=o(s),i!==null))return i;s=s.sibling}return null}ve.doesFiberContain=function(s,i){for(var l=s.alternate;i!==null;){if(i===s||i===l)return!0;i=i.return}return!1},ve.findCurrentFiberUsingSlowPath=t,ve.findCurrentHostFiber=function(s){return s=t(s),s!==null?r(s):null},ve.findCurrentHostFiberWithNoPortals=function(s){return s=t(s),s!==null?o(s):null},ve.getContainerFromFiber=function(s){return s.tag===3?s.stateNode.containerInfo:null},ve.getNearestMountedFiber=n,ve.getSuspenseInstanceFromFiber=function(s){if(s.tag===13){var i=s.memoizedState;if(i===null&&(s=s.alternate,s!==null&&(i=s.memoizedState)),i!==null)return i.dehydrated}return null},ve.isFiberMounted=function(s){return n(s)===s},ve.isFiberSuspenseAndTimedOut=function(s){var i=s.memoizedState;return s.tag===13&&i!==null&&i.dehydrated===null},ve.isMounted=function(s){return(s=s._reactInternals)?n(s)===s:!1}}()),ve}process.env.NODE_ENV==="production"?Us.exports=tb():Us.exports=nb();var rb=Us.exports;function ob(n){return n._reactInternals}function P0(n){return n}function sb(n){const e=ob(n);if(e===void 0){if(typeof n.render=="function")throw new Error("Unable to find node on an unmounted component.");{const r=Object.keys(n).join(",");throw new Error(`Argument appears to not be a ReactComponent. Keys: ${r}`)}}const t=rb.findCurrentHostFiber(e);return t===null?null:t.stateNode}function ib(n){return sb(n)}function lb(n,e){if(n===e)return!0;if(!n||!e)return!1;const t=Object.keys(n),r=Object.keys(e),o=t.length;if(r.length!==o)return!1;for(let s=0;s<o;s++){const i=t[s];if(n[i]!==e[i]||!Object.prototype.hasOwnProperty.call(e,i))return!1}return!0}class ab extends m.Component{constructor(){super(...arguments);j(this,"viewDescRef",null);j(this,"renderRef",null)}updateEffect(){const{view:t,decorations:r,siblingsRef:o,parentRef:s,getPos:i,node:l}=this.props,a=ib(this);if(!a){if(!(t!=null&&t.composing))return;this.viewDescRef=new eo(s.current,()=>i.current(),document.createElement("div"),document.createTextNode(l.text??""),l.text??"");return}let c=a;for(;c.firstChild;)c=c.firstChild;!this.viewDescRef||this.viewDescRef instanceof eo?this.viewDescRef=new Oy(void 0,[],()=>i.current(),l,r,H.empty,a,c):(this.viewDescRef.parent=s.current,this.viewDescRef.children=[],this.viewDescRef.node=l,this.viewDescRef.getPos=()=>i.current(),this.viewDescRef.outerDeco=r,this.viewDescRef.innerDeco=H.empty,this.viewDescRef.dom=a,this.viewDescRef.dom.pmViewDesc=this.viewDescRef,this.viewDescRef.nodeDOM=c),o.current.includes(this.viewDescRef)||o.current.push(this.viewDescRef),o.current.sort(Kt)}shouldComponentUpdate(t){return!lb(this.props,t)}componentDidMount(){this.updateEffect()}componentDidUpdate(){this.updateEffect()}componentWillUnmount(){const{siblingsRef:t}=this.props;if(this.viewDescRef&&t.current.includes(this.viewDescRef)){const r=t.current.indexOf(this.viewDescRef);t.current.splice(r,1)}}render(){const{view:t,getPos:r,node:o,decorations:s}=this.props;return t!=null&&t.composing&&t.state.selection.from>=r.current()&&t.state.selection.from<=r.current()+o.nodeSize?this.renderRef:(this.renderRef=s.reduce(to,o.text),this.renderRef)}}function cb(n){let{getPos:e}=n;const{siblingsRef:t,parentRef:r}=m.useContext(Ce),o=m.useRef(null),s=m.useRef(null);return J(()=>{const i=t.current;return()=>{if(o.current&&i.includes(o.current)){const l=i.indexOf(o.current);i.splice(l,1)}}},[t]),J(()=>{s.current&&(o.current?(o.current.parent=r.current,o.current.dom=s.current,o.current.getPos=()=>e.current()):o.current=new er(r.current,[],()=>e.current(),s.current,null),t.current.includes(o.current)||t.current.push(o.current),t.current.sort(Kt))}),m.createElement("br",{ref:s,className:"ProseMirror-trailingBreak"})}function ub(n){let{widget:e,getPos:t}=n;const{siblingsRef:r,parentRef:o}=m.useContext(Ce),s=m.useRef(null),i=m.useRef(()=>t.current()).current,l=m.useRef(null);J(()=>{const c=r.current;return()=>{if(s.current&&c.includes(s.current)){const u=c.indexOf(s.current);c.splice(u,1)}}},[r]),J(()=>{l.current&&(s.current?(s.current.parent=o.current,s.current.widget=e,s.current.getPos=()=>t.current(),s.current.dom=l.current):s.current=new Ks(o.current,()=>t.current(),e,l.current),r.current.includes(s.current)||r.current.push(s.current),r.current.sort(Kt))});const{Component:a}=e.type;return a&&m.createElement(a,{ref:l,widget:e,getPos:i,contentEditable:!1})}function to(n,e){const{nodeName:t,...r}=e.type.attrs,o=Su(r);return t||typeof n=="string"?m.createElement(t??"span",o,n):m.cloneElement(n,ku(n.props,o))}function Qs(n,e){var t,r,o;return n.type===e.type&&n.marks.every(s=>s.isInSet(e.marks))&&e.marks.every(s=>s.isInSet(n.marks))&&n.key===e.key&&(n.type==="node"?((t=n.outerDeco)==null?void 0:t.length)===((r=e.outerDeco)==null?void 0:r.length)&&((o=n.outerDeco)==null?void 0:o.every(s=>{var i;return(i=e.outerDeco)==null?void 0:i.some(l=>s.from===l.from&&s.to&&l.to&&s.type.eq(l.type))}))&&n.innerDeco.eq(e.innerDeco):!0)&&n.node===e.node&&n.widget===e.widget}const fb=m.memo(function(e){let{child:t,getInnerPos:r}=e;const{view:o}=m.useContext(wt),s=m.useRef(()=>r.current()+t.offset);return s.current=()=>r.current()+t.offset,t.type==="widget"?m.createElement(ub,{key:t.key,widget:t.widget,getPos:s}):t.type==="native-widget"?m.createElement(Ky,{key:t.key,widget:t.widget,getPos:s}):t.node.isText?m.createElement(Ce.Consumer,{key:t.key},i=>{let{siblingsRef:l,parentRef:a}=i;return m.createElement(ab,{view:o,node:t.node,getPos:s,siblingsRef:l,parentRef:a,decorations:t.outerDeco})}):m.createElement(Nu,{key:t.key,node:t.node,getPos:s,outerDeco:t.outerDeco,innerDeco:t.innerDeco})}),db=m.memo(function(e){let{childViews:t,getInnerPos:r}=e;const o=t[0],s=m.useRef(()=>r.current()+o.offset);s.current=()=>r.current()+o.offset;const i=o.marks[0];return i?m.createElement(wu,{getPos:s,key:o.key,mark:i},m.createElement(Zs,{key:o.key,getInnerPos:r,childViews:t.map(l=>({...l,marks:l.marks.slice(1)}))})):m.createElement(m.Fragment,null,t.map(l=>m.createElement(fb,{key:l.key,child:l,getInnerPos:r})))}),Zs=m.memo(function(e){let{getInnerPos:t,childViews:r}=e;const o=r.reduce((s,i)=>{var c;const l=s[s.length-1];if(!l)return[[i]];const a=l[l.length-1];return a?!i.marks.length&&!a.marks.length||i.marks.length&&a.marks.length&&((c=i.marks[0])!=null&&c.eq(a.marks[0]))?[...s.slice(0,s.length-1),[...l.slice(0,l.length),i]]:[...s,[i]]:[...s.slice(0,s.length),[i]]},[]);return m.createElement(m.Fragment,null,o.map(s=>{const i=s[0];return i?m.createElement(db,{key:i.key,childViews:s,getInnerPos:t}):null}))});function ei(n,e,t,r,o,s){const i=n+e,l=r==null?void 0:r.get(i);if(t==="widget"||t==="native-widget")return o.type.spec.key?o.type.spec.key:(console.warn(`Widget at position ${i} doesn't have a key specified. This may cause issues.`),`${l}-${s}`);if(l)return l;const a=n-1,c=r==null?void 0:r.get(a);return c?`${c}-${e}`:i}function hb(n,e){if(!e||e.widget.type.side>=0||!n||!n.node.isInline)return;const t=n.marks;e.marks=e.marks.reduce((r,o)=>o.addToSet(r),t)}function pb(n,e){if(!e.node.isInline)return;const t=e.marks;for(let r=n.length-1;r>=0;r--){const o=n[r];o.widget.type.side<0||(o.marks=o.marks.reduce((s,i)=>i.addToSet(s),t))}}const mb=m.memo(function(e){let{child:t,getInnerPos:r}=e;const o=m.useRef(()=>r.current()+t.offset);return o.current=()=>r.current()+t.offset,t.type==="node"?t.marks.reduce((s,i)=>m.createElement(wu,{getPos:o,mark:i},s),m.createElement(Nu,{key:t.key,outerDeco:t.outerDeco,node:t.node,innerDeco:t.innerDeco,getPos:o})):m.createElement(Zs,{key:t.key,childViews:[t],getInnerPos:r})});function gb(n,e){return n.length?n.every(t=>t.type!=="node"||t.node.isInline)?[m.createElement(Zs,{key:n[0].key,childViews:n,getInnerPos:e})]:n.map(t=>m.createElement(mb,{key:t.key,child:t,getInnerPos:e})):[]}const tr=m.memo(function(e){let{getPos:t,node:r,innerDecorations:o}=e;const s=Ly(),i=m.useRef(()=>t.current()+1),l=m.useRef(new Map).current;if(!r)return null;const a=new Set;let c=[],u=null;Fy(r,o,(p,b,g,k)=>{const S=p.type.spec.marks??[];let M;if(b){M=ei(i.current(),g,"native-widget",s==null?void 0:s.posToKey,p,k);const I={type:"native-widget",widget:p,marks:S,offset:g,index:k,key:M},w=l.get(M);w&&Qs(w,I)?w.offset=g:l.set(M,I),a.add(M)}else{M=ei(i.current(),g,"widget",s==null?void 0:s.posToKey,p,k);const I={type:"widget",widget:p,marks:S,offset:g,index:k,key:M},w=l.get(M);w&&Qs(w,I)?w.offset=g:l.set(M,I),a.add(M)}const O=l.get(M);c.push(O),hb(u,l.get(M))},(p,b,g,k)=>{const S=ei(i.current(),k,"node",s==null?void 0:s.posToKey),M={type:"node",node:p,marks:p.marks,innerDeco:g,outerDeco:b,offset:k,key:S},O=l.get(S);O&&Qs(O,M)?(O.offset=k,u=O):(l.set(S,M),u=M),a.add(S),pb(c,u),c=[]});for(const p of l.keys())a.has(p)||l.delete(p);const f=Array.from(l.values()).sort((p,b)=>p.offset-b.offset),d=gb(f,i),h=f[f.length-1];return(!h||h.type!=="node"||h.node.isInline&&!h.node.isText||/\n$/.test(h.node.text))&&d.push(m.createElement(eb,{getPos:i,key:"trailing-hack-img"}),m.createElement(cb,{getPos:i,key:"trailing-hack-br"})),m.createElement(m.Fragment,null,d)}),ti={current(){return-1}},yb=m.memo(m.forwardRef(function(e,t){let{className:r,node:o,innerDeco:s,outerDeco:i,as:l,viewDesc:a,...c}=e;const u=m.useRef(null);m.useImperativeHandle(t,()=>u.current,[]);const{childDescriptors:f,nodeViewDescRef:d}=Gs(o,()=>ti.current(),u,u,s,i,a),h=m.useMemo(()=>({parentRef:d,siblingsRef:f}),[f,d]),p={...c,ref:u,className:r,suppressContentEditableWarning:!0},b=l?m.cloneElement(l,p,m.createElement(Ce.Provider,{value:h},m.createElement(tr,{getPos:ti,node:o,innerDecorations:s}))):m.createElement("div",p,m.createElement(Ce.Provider,{value:h},m.createElement(tr,{getPos:ti,node:o,innerDecorations:s})));if(!o)return b;const g=i.filter(S=>!S.inline);return g.length?g.reduce(to,b):b})),Ou=m.createContext(null);function bb(n,e){let{as:t,...r}=n;const o=m.useRef([]),s=m.useRef(null),{setMount:i,...l}=m.useContext(Ou),a=m.useRef(void 0);m.useImperativeHandle(e,()=>s.current,[]);const c=m.useMemo(()=>({parentRef:a,siblingsRef:o}),[o,a]);return m.createElement(Ce.Provider,{value:c},m.createElement(yb,{ref:u=>{s.current=u,i(u)},...r,...l,as:t}))}const Tu=m.forwardRef(bb),xb=[];function kb(n){var p;let{className:e,children:t,nodeViews:r,customNodeViews:o,...s}=n;const[i,l]=m.useState(null),{editor:a,state:c}=$y(i,{...s,nodeViews:o}),u=a.view?ty(a.view,a.cursorWrapper):H.empty,f=a.view?Ug(a.view):xb,d=m.useMemo(()=>({nodeViews:r??{}}),[r]),h=m.useMemo(()=>{var b;return{className:e,setMount:l,node:(b=a.view)==null?void 0:b.state.doc,innerDeco:u,outerDeco:f,viewDesc:a.docViewDescRef.current}},[e,a.docViewDescRef,(p=a.view)==null?void 0:p.state.doc,u,f]);return m.createElement(wt.Provider,{value:a},m.createElement(Xg.Provider,{value:c},m.createElement(qc.Provider,{value:d},m.createElement(Ou.Provider,{value:h},t))))}function vu(n){return m.createElement(jy,null,m.createElement(kb,n))}function re(n){const e=m.useRef(n),{view:t}=m.useContext(wt);return Ke(()=>{e.current=n},[n]),m.useCallback(function(){for(var r=arguments.length,o=new Array(r),s=0;s<r;s++)o[s]=arguments[s];return e.current(t,...o)},[t])}function Au(n){const e=m.useContext(Mu),t=re(n);Ke(()=>{e(t)},[e,t])}const Pu=n=>[Gg(),Ro({Tab:jc(1),"Shift-Tab":jc(-1)}),hm(n.schema),Ro(lm(n.schema)),Ro(Hd),Kd({color:"#F00",width:2}),Ap(),Sd(),pm(n),fy()],Sb=["p",0],Cb=["blockquote",0],wb=["hr"],Mb=["pre",["code",0]],Nb=["br"],Eb={doc:{content:"block+"},paragraph:{content:"inline*",group:"block",parseDOM:[{tag:"p"}],toDOM(){return Sb}},blockquote:{content:"block+",group:"block",defining:!0,parseDOM:[{tag:"blockquote"}],toDOM(){return Cb}},horizontal_rule:{group:"block",parseDOM:[{tag:"hr"}],toDOM(){return wb}},heading:{attrs:{level:{default:1,validate:"number"}},content:"inline*",group:"block",defining:!0,parseDOM:[{tag:"h1",attrs:{level:1}},{tag:"h2",attrs:{level:2}},{tag:"h3",attrs:{level:3}},{tag:"h4",attrs:{level:4}},{tag:"h5",attrs:{level:5}},{tag:"h6",attrs:{level:6}}],toDOM(n){return["h"+n.attrs.level,0]}},code_block:{content:"text*",marks:"",group:"block",code:!0,defining:!0,parseDOM:[{tag:"pre",preserveWhitespace:"full"}],toDOM(){return Mb}},text:{group:"inline"},image:{inline:!0,attrs:{src:{validate:"string"},alt:{default:null,validate:"string|null"},title:{default:null,validate:"string|null"}},group:"inline",draggable:!0,parseDOM:[{tag:"img[src]",getAttrs(n){return{src:n.getAttribute("src"),title:n.getAttribute("title"),alt:n.getAttribute("alt")}}}],toDOM(n){let{src:e,alt:t,title:r}=n.attrs;return["img",{src:e,alt:t,title:r}]}},hard_break:{inline:!0,group:"inline",selectable:!1,parseDOM:[{tag:"br"}],toDOM(){return Nb}}},Db=["em",0],Ob=["strong",0],Tb=["code",0],vb={link:{attrs:{href:{validate:"string"},title:{default:null,validate:"string|null"}},inclusive:!1,parseDOM:[{tag:"a[href]",getAttrs(n){return{href:n.getAttribute("href"),title:n.getAttribute("title")}}}],toDOM(n){let{href:e,title:t}=n.attrs;return["a",{href:e,title:t},0]}},em:{parseDOM:[{tag:"i"},{tag:"em"},{style:"font-style=italic"},{style:"font-style=normal",clearMark:n=>n.type.name=="em"}],toDOM(){return Db}},strong:{parseDOM:[{tag:"strong"},{tag:"b",getAttrs:n=>n.style.fontWeight!="normal"&&null},{style:"font-weight=400",clearMark:n=>n.type.name=="strong"},{style:"font-weight",getAttrs:n=>/^(bold(er)?|[5-9]\d{2,})$/.test(n)&&null}],toDOM(){return Ob}},code:{code:!0,parseDOM:[{tag:"code"}],toDOM(){return Tb}}},Iu=new gr({nodes:Eb,marks:vb}),Vu=Iu.spec.marks.append({underline:{parseDOM:[{tag:"u"},{style:"font-style=underline"}],toDOM(){return["u",0]}},strikethrough:{parseDOM:[{tag:"s"},{style:"font-style=strike"},{style:"font-style=strikethrough"}],toDOM(){return["s",0]}}}),no="https://dailytelefrag.ru/api",ro="https://dailytelefrag.ru/error_image.png",Ru="https://dailytelefrag.ru/error_embed.png",Ab=(n,e)=>{try{const t=new URL(n);if(t.hostname!=="vkvideo.ru"&&t.hostname!=="vk.com")throw new Error;let r,o;if(t.pathname==="/video_ext.php")r=t.searchParams.get("id"),o=t.searchParams.get("oid");else if(t.pathname.startsWith("/video"))[o,r]=t.pathname.slice(6).split("_");else throw new Error;if(!r||!o)throw new Error;return e?`https://vkvideo.ru/video_ext.php?oid=${o}&id=${r}&hd=2`:!0}catch{return""}},Pb=(n,e)=>{try{const t=new URL(n);if(t.hostname!=="rutube.ru")throw new Error;let r;if(t.pathname.startsWith("/video/"))r=t.pathname.split("/")[2];else if(t.pathname.startsWith("/play/embed/"))r=t.pathname.split("/")[3];else throw new Error;if(!r)throw new Error;return e?`https://rutube.ru/play/embed/${r}`:!0}catch{return""}},Ib=(n,e)=>{try{const t=new URL(n);if(t.hostname!=="youtube.com"&&t.hostname!=="www.youtube.com"&&t.hostname!=="youtu.be")throw new Error;if(t.hostname==="youtu.be")return e?`https://youtube.com/embed${t.pathname}`:!0;let r;if(t.pathname==="/watch")r=t.searchParams.get("v");else if(t.pathname.startsWith("/live/"))r=t.pathname.split("/")[2];else if(t.pathname.startsWith("/embed/"))r=t.pathname.split("/")[2];else throw new Error;if(!r)throw new Error;return e?`https://youtube.com/embed/${r}`:!0}catch{return""}},oo=n=>{try{const e=new URL(n);switch(e.hostname){case"vkvideo.ru":case"vk.com":return Ab(e,!0)+"";case"rutube.ru":return Pb(e,!0)+"";case"youtube.com":case"www.youtube.com":case"youtu.be":return Ib(e,!0)+"";default:throw new Error}}catch{return""}},Vb={atom:!0,attrs:{fid:{default:null,validate:"string|null|number"},src:{default:null,validate:"string|null"},alt:{default:null,validate:"string|null"},title:{default:null,validate:"string|null"}},group:"block",parseDOM:[{tag:"img[src]",getAttrs(n){return{fid:n.getAttribute("fid"),src:n.getAttribute("src"),alt:n.getAttribute("alt"),title:n.getAttribute("title")}}}],toDOM(n){let{fid:e,src:t,alt:r,title:o}=n.attrs;return e&&(t=`${no}/files/${e}`),t||(t=ro),["div",{title:o,class:"image"},["img",{fid:e,src:t,alt:r,title:o}]]}},Rb={atom:!0,attrs:{src:{validate:"string"},title:{default:null,validate:"string|null"}},group:"block",parseDOM:[{tag:"iframe[src]",getAttrs(n){return{src:n.getAttribute("src"),title:n.getAttribute("title")}}}],toDOM(n){const{src:e,title:t}=n.attrs,r="fullscreen; accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share";return oo(e)?["div",{title:t,class:"video"},["iframe",{src:e,title:t,allow:r}]]:["div",{title:t,class:"image"},["img",{src:Ru}]]}},zb={content:"inline*",group:"block",attrs:{align:{default:null,validate:"string|null"}},parseDOM:[{tag:"p",getAttrs(n){let e=n.getAttribute("align");return e!=="right"&&e!=="center"&&e!=="justify"&&(e=null),{align:e}}}],toDOM(n){const{align:e}=n.attrs;return["p",{align:e},0]}},$b={attrs:{level:{default:1,validate:"number"}},content:"inline*",marks:"underline strikethrough",group:"block",parseDOM:[{tag:"h1",attrs:{level:1}},{tag:"h2",attrs:{level:2}},{tag:"h3",attrs:{level:3}},{tag:"h4",attrs:{level:4}},{tag:"h5",attrs:{level:5}},{tag:"h6",attrs:{level:6}}],toDOM(n){return["h"+n.attrs.level,0]}},jb={atom:!0,content:"image*",group:"block",toDOM(){return["div",{class:"carousel"},0]}},zu=Iu.spec.nodes.remove("image").append({image:Vb,video:Rb}),so=new gr({nodes:zu.remove("horizontal_rule").remove("heading"),marks:Vu}),Bb=zu.remove("heading").remove("paragraph").prepend({paragraph:zb}).append({heading:$b}).append({carousel:jb}).append(ug({tableGroup:"block",cellContent:"(paragraph | ordered_list | bullet_list)+",cellAttributes:{halign:{default:null,getFromDOM(n){const e=n.getAttribute("align")||null;return e==="left"||e==="right"||e==="center"?e:null},setDOMAttr(n,e){n&&(e.style=(e.style||"")+`text-align: ${n};`)}},valign:{default:null,getFromDOM(n){const e=n.style.verticalAlign||null;return e==="top"||e==="bottom"||e==="middle"?e:null},setDOMAttr(n,e){n&&(e.style=(e.style||"")+`vertical-align: ${n};`)}}}})),Nt=new gr({nodes:Wp(Bb,"(paragraph | ordered_list | bullet_list)+","block"),marks:Vu}),Fb=n=>{if(n)try{const e=be.fromJSON(Nt,JSON.parse(n)),t=$e.fromSchema(Nt).serializeFragment(e.content);return Pt.fromSchema(so).parse(t)}catch(e){console.error(`Can not convert content to simple schema: ${e}`)}},nr=({ref:n,item:e})=>{const[t,r]=m.useState(!0),[o,s]=m.useState(!1),[i,l]=m.useState(!1);Ke(c=>{c&&(r(e.isActive&&e.isActive(c.state)),l(e.isSelected&&!e.isSelected(c.state)),e.isDisabled?s(e.isDisabled(c.state)):s(!e.command(c.state)))});const a=re(c=>{c&&(o||e.command(c.state,c.dispatch,c),c.focus())});return i?null:y.jsx("div",{ref:n,className:`MenuItem ${t?"active":""} ${o?"disabled":""}`,onClick:c=>{c.stopPropagation(),c.preventDefault(),a()},children:e.icon})},$u=({schema:n})=>{const[e,t]=m.useState(void 0),[r,o]=m.useState(void 0);return m.useEffect(()=>{if(t(void 0),o(void 0),n.nodes.paragraph){const s=n.nodes.paragraph;t({icon:y.jsx(E.Icons.Type,{}),command:on(s)})}if(n.nodes.code_block){const s=n.nodes.code_block;o({icon:y.jsx(E.Icons.CodeXml,{}),command:on(s)})}},[n]),y.jsxs(y.Fragment,{children:[e&&y.jsx(nr,{item:e}),r&&y.jsx(nr,{item:r})]})},rr=({items:n})=>y.jsx("div",{className:"MenuBlock",children:n.map((e,t)=>y.jsx(nr,{item:e},t))}),Lb=({schema:n,isOpen:e,onClose:t})=>{const r=re((o,s)=>{o&&(ke(n.marks.link,{href:s})(o.state,o.dispatch),t(),o.focus())});return y.jsx(E.Prompt,{title:"Введите URL для ссылки",isOpen:e,onCancel:t,onSubmit:r})},ju=({schema:n})=>{const[e,t]=m.useState([]),[r,o]=m.useState(!1);return m.useEffect(()=>{const s=[];if(n.marks.strong){const i=n.marks.strong;s.push({icon:y.jsx(E.Icons.Bold,{}),command:ke(i),isActive:l=>Jt(l,i)})}if(n.marks.em){const i=n.marks.em;s.push({icon:y.jsx(E.Icons.Italic,{}),command:ke(i),isActive:l=>Jt(l,i)})}if(n.marks.underline){const i=n.marks.underline;s.push({icon:y.jsx(E.Icons.Underline,{}),command:ke(i),isActive:l=>Jt(l,i)})}if(n.marks.strikethrough){const i=n.marks.strikethrough;s.push({icon:y.jsx(E.Icons.Strikethrough,{}),command:ke(i),isActive:l=>Jt(l,i)})}if(n.marks.code){const i=n.marks.code;s.push({icon:y.jsx(E.Icons.Code,{}),command:ke(i),isActive:l=>Jt(l,i)})}if(n.marks.link){const i=n.marks.link;s.push({icon:y.jsx(E.Icons.Link,{}),isActive:l=>Jt(l,i),isDisabled:l=>l.selection.empty?!0:!ke(i)(l),command:(l,a,c)=>(Jt(l,i)?(ke(i)(l,a),c==null||c.focus()):o(!0),!0)})}t(s)},[n]),e.length<1?null:y.jsxs(y.Fragment,{children:[y.jsx(rr,{items:e}),y.jsx(Lb,{isOpen:r,schema:n,onClose:()=>o(!1)})]})};function Jt(n,e){let{from:t,$from:r,to:o,empty:s}=n.selection;return s?!!e.isInSet(n.storedMarks||r.marks()):n.doc.rangeHasMark(t,o,e)}const Bu=()=>y.jsxs("div",{className:"MenuBlock",children:[y.jsx(nr,{item:{icon:y.jsx(E.Icons.Undo,{}),command:Ao}}),y.jsx(nr,{item:{icon:y.jsx(E.Icons.Redo,{}),command:Mr}})]}),Fu=({schema:n})=>{const[e,t]=m.useState([]);return m.useEffect(()=>{const r=[];if(n.nodes.bullet_list){const o=n.nodes.bullet_list;r.push({icon:y.jsx(E.Icons.List,{}),command:(s,i)=>Rr(o)(s,i)})}if(n.nodes.ordered_list){const o=n.nodes.ordered_list;r.push({icon:y.jsx(E.Icons.ListOrdered,{}),command:(s,i)=>Rr(o)(s,i)})}if(n.nodes.blockquote){const o=n.nodes.blockquote;r.push({icon:y.jsx(E.Icons.Quote,{}),command:(s,i)=>Cl(o)(s,i)})}t(r)},[n]),e.length<1?null:y.jsx(rr,{items:e})},Lu=({pos:n,isOpen:e,onClose:t})=>{const[r,o]=m.useState(""),[s,i]=m.useState(),[l,a]=m.useState(""),[c,u]=m.useState(!1);m.useEffect(()=>{o(""),a(""),i(void 0)},[e]),Ke(d=>{if(!d||!e)return;const h=tt.getState(d.state);u(h.upload!==void 0)},[e]);const f=re(d=>{d&&(c?gm(d,s,l,n):ym(d,r,l,n),d.focus(),t())});return y.jsxs(E.Modal,{isOpen:e,onClose:t,children:[y.jsx("h1",{children:"Вставка картинки"}),y.jsxs(E.Form,{submit:"Вставить",submitType:"Success",onSubmit:f,onCancel:t,children:[c?y.jsx(E.Image,{id:"image",value:s,onChange:i,text:y.jsxs("span",{children:[y.jsx(E.Icons.Image,{}),y.jsx("br",{}),"Выберите файл"]}),required:!0,label:"Картинка"}):y.jsx(E.Input,{id:"href",value:r,onChange:o,required:!0,label:"Ссылка на картинку"}),y.jsx(E.Input,{id:"value",value:l,onChange:a,label:"Подпись"})]})]})},Wb=({schema:n,isOpen:e,onClose:t})=>{const[r,o]=m.useState(""),[s,i]=m.useState("");m.useEffect(()=>{o(""),i("")},[e]);const l=re(a=>{const c=n.nodes.video;if(!a||!r||!c)return;const u=oo(r);a.dispatch(a.state.tr.replaceSelectionWith(c.create({src:u,title:s}))),a.focus(),t()});return n.nodes.video?y.jsxs(E.Modal,{isOpen:e,onClose:t,children:[y.jsx("h1",{children:"Вставка видео"}),y.jsxs(E.Form,{submit:"Вставить",submitType:"Success",onSubmit:l,onCancel:t,children:[y.jsx(E.Input,{id:"src",value:r,onChange:o,label:"Ссылка на видео",bottom:"Поддерживаются VK Video, RuTube и YouTube",required:!0}),y.jsx(E.Input,{id:"value",value:s,onChange:i,label:"Подпись"})]})]}):null},Wu=({schema:n})=>{const[e,t]=m.useState([]),[r,o]=m.useState(!1),[s,i]=m.useState(!1);return m.useEffect(()=>{const l=[];if(n.nodes.image){const a=n.nodes.image;l.push({icon:y.jsx(E.Icons.Image,{}),isDisabled:c=>!ni(c,a),command:()=>(o(!0),!0)})}if(n.nodes.video){const a=n.nodes.video;l.push({icon:y.jsx(E.Icons.Film,{}),isDisabled:c=>!ni(c,a),command:()=>(i(!0),!0)})}if(n.nodes.horizontal_rule){const a=n.nodes.horizontal_rule;l.push({icon:y.jsx(E.Icons.FlipVertical,{}),isDisabled:c=>!ni(c,a),command:(c,u)=>u?(u(c.tr.replaceSelectionWith(a.create())),!0):!1})}n.nodes.table&&l.push({icon:y.jsx(E.Icons.Table,{}),isDisabled:Oe,command:_b()}),t(l)},[n]),e.length<1?null:y.jsxs(y.Fragment,{children:[y.jsx(rr,{items:e}),y.jsx(Lu,{isOpen:r,onClose:()=>o(!1)}),y.jsx(Wb,{isOpen:s,schema:n,onClose:()=>i(!1)})]})},ni=(n,e)=>{let t=n.selection.$from;for(let r=t.depth;r>=0;r--){let o=t.index(r);if(t.node(r).canReplaceWith(o,o,e))return!0}return!1};function _b(){return(n,e)=>{const t=n.tr.selection.anchor+1,r=n.tr,o=n.schema.nodes.table_cell.createAndFill(),s=n.schema.nodes.table.create(null,C.fromArray([n.schema.nodes.table_row.create(null,C.fromArray([o,o,o])),n.schema.nodes.table_row.create(null,C.fromArray([o,o,o]))]));return e&&e(r.replaceSelectionWith(s).scrollIntoView().setSelection(P.near(r.doc.resolve(t)))),!0}}const _u=({schema:n})=>n.nodes.carousel?y.jsx(rr,{items:[{icon:y.jsx(E.Icons.JoinUp,{}),command:bl},{icon:y.jsx(E.Icons.IndentDecrease,{}),command:$o},{icon:y.jsx(E.Icons.SquareDashed,{}),command:Bo}]}):y.jsx(rr,{items:[{icon:y.jsx(E.Icons.IndentDecrease,{}),command:$o},{icon:y.jsx(E.Icons.SquareDashed,{}),command:Bo}]}),qb=({schema:n})=>y.jsxs("div",{className:"SimpleMenuBar",children:[y.jsx("div",{className:"MenuBlock",children:y.jsx($u,{schema:n})}),y.jsx(ju,{schema:n}),y.jsx(Wu,{schema:n}),y.jsx(Fu,{schema:n}),y.jsx(_u,{schema:n}),y.jsx(Bu,{})]}),qu=m.forwardRef(function({children:e,nodeProps:t,...r},o){const[s,i]=m.useState(t.node.attrs.alt??""),[l,a]=m.useState(t.node.attrs.title??""),[c,u]=m.useState(!1),[f,d]=m.useState("");Au((k,S)=>k?!(S instanceof MouseEvent):!1),Ke(k=>{if(d(""),u(!1),!k||!k.state.schema.nodes.carousel)return;const S=t.getPos(),M=k.state.doc.resolve(S).parent;if(u(M.type.name!=="carousel"),M.type.name==="carousel"){let O=0;M.forEach((I,w)=>{I===t.node&&(O=w+1)}),d(O?`${O} / ${M.childCount}`:"")}});const h=re((k,S)=>{if(!k)return;i(S);const M=k.state.tr,O=t.getPos();k.dispatch(M.setNodeMarkup(O,null,{...t.node.attrs,alt:S})),k.focus()}),p=re((k,S)=>{if(!k)return;a(S);const M=k.state.tr,O=t.getPos();k.dispatch(M.setNodeMarkup(O,null,{...t.node.attrs,title:S})),k.focus()}),b=re(k=>{if(!k)return;const S=t.getPos(),M=t.node.nodeSize,O=t.node.attrs,I=k.state.schema,w=I.nodes.carousel.create(null,I.nodes.image.create(O));k.dispatch(k.state.tr.replaceWith(S,S+M,w))}),g=re(k=>{if(!k)return;const S=k.state.tr,M=t.getPos(),O=t.node.nodeSize;k.dispatch(S.delete(M,M+O))});return y.jsxs("div",{...r,ref:o,className:"image",title:t.node.attrs.title,children:[y.jsxs("div",{className:"image-buttons",children:[c&&y.jsx("div",{onClick:b,className:"text-button",children:"Сделать карусель"}),f&&y.jsx("div",{className:"text-button",children:f}),y.jsx("div",{onClick:g,children:y.jsx(E.Icons.Trash,{})})]}),y.jsx("div",{children:y.jsx(E.Editable,{value:s,placeholder:"Alt: описание изображения (не обязательно)",onChange:h,empty:!0,style:{textAlign:"center",cursor:"text"}})}),y.jsx("img",{title:t.node.attrs.title,alt:t.node.attrs.alt,src:t.node.attrs.fid?`${no}/files/${t.node.attrs.fid}`:t.node.attrs.src}),y.jsx("div",{children:y.jsx(E.Editable,{value:l,placeholder:"Title: подпись под изображением (не обязательно)",onChange:p,empty:!0,style:{textAlign:"center",cursor:"text"}})})]})}),Hu=m.forwardRef(function({children:e,nodeProps:t,...r},o){const[s,i]=m.useState(""),[l,a]=m.useState(t.node.attrs.title??""),c="fullscreen; accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share";Au(()=>!0),m.useEffect(()=>{i(oo(t.node.attrs.src))},[t]);const u=re((f,d)=>{if(!f)return;a(d);const{$from:h,$to:p}=f.state.selection,b=h.blockRange(p);if(b){const g=f.state.doc;let k=f.state.tr;g.nodesBetween(b.start,b.end,(S,M)=>{S.type.name==="video"&&(k=k.setNodeMarkup(M,null,{...t.node.attrs,title:d}))}),f.dispatch(k)}f.focus()});return y.jsxs("div",{...r,ref:o,className:s?"video":"image",title:t.node.attrs.title,children:[s?y.jsx("iframe",{src:s,allow:c}):y.jsx("img",{src:Ru}),y.jsx("div",{children:y.jsx(E.Editable,{value:l,placeholder:"Подпись под видео (не обязательно)",onChange:u,empty:!0,style:{textAlign:"center",cursor:"text"}})})]})}),Ku=({onSave:n,disabled:e=!1,notEmpty:t=!0,wasChanged:r=!0})=>{const[o,s]=m.useState(!0);Ke(l=>{let a=!1;const c=l.state.doc,u=!!c.textBetween(0,c.content.size,void 0," ").length,f=!!Po(l.state);r&&t?a=u&&f:r?a=f:t&&(a=u),s(a)});const i=re(l=>{try{let a;const c=Is(l.state);if(c){const u=l.state.apply(c.setMeta("addToHistory",!1));a=JSON.stringify(u.doc.toJSON())}else a=JSON.stringify(l.state.doc.toJSON());n({content:a,format:"prose"})}catch(a){console.error(`Can not save doc: ${a}`)}});return y.jsx(E.Button,{type:"Accent",disabled:e||!o,label:"Сохранить",size:"Small",onClick:i})},Hb=({title:n=!1,content:e,onSave:t,onCancel:r,onChange:o,onUpload:s})=>{const[i,l]=m.useState(""),[a,c]=m.useState();m.useEffect(()=>{const h=Ge.create({doc:Fb(e),schema:so,plugins:Pu({schema:so,upload:s})});c(h),n!==!1&&l(typeof n=="string"?n:"")},[n,e]);const u=()=>n!==!1?i.trim().length>0:!0,f=h=>{!t||!u()||t({...h,name:i})},d=()=>{r&&r()};return a?y.jsxs("div",{className:"ProseNotes",children:[n!==!1&&y.jsx("input",{className:"ProseNotesTitle",onChange:h=>l(h.currentTarget.value),value:i,placeholder:"Укажите заголовок"}),y.jsxs(vu,{state:a,dispatchTransaction:h=>c(p=>{const b=p==null?void 0:p.apply(h);return b&&o&&o(!!Po(b)),b}),nodeViews:{image:qu,video:Hu},children:[y.jsxs("div",{className:"ProseNotesContent",children:[y.jsx(qb,{schema:so}),y.jsx(Tu,{})]}),(t||r)&&y.jsxs("div",{className:"ProseNotesButtons",children:[r&&y.jsx("span",{className:"a small",onClick:d,children:"Отменить"}),t&&y.jsx(Ku,{onSave:f,disabled:!u(),wasChanged:!1})]})]})]}):null},Kb=({schema:n})=>{const e=m.useRef(null),[t,r]=m.useState([]),[o,s]=m.useState([]),[i,l]=m.useState(!1);Ke(c=>{const u=n.nodes.heading;if(!c||!u||!i)return;const f=[],d=[];for(let h=2;h<7;h++){const b=on(u,{level:h});d[h]=b,f[h]={id:h,icon:y.jsx(Jb,{level:h}),text:`уровень ${h}`,disabled:!b(c.state)}}r(f),s(d)},[i]);const a=re((c,u)=>{!c||!u.id||(o[u.id](c.state,c.dispatch,c),l(!1),c.focus())});return n.nodes.heading?y.jsxs(y.Fragment,{children:[y.jsx("div",{ref:e,className:"MenuItem",onClick:()=>l(!0),children:y.jsx(E.Icons.Heading,{})}),e.current&&y.jsx(E.Menu,{parent:e.current,items:t,isOpen:i,onClose:()=>l(!1),onClick:a,horizontal:"inner-left"})]}):null},Jb=({level:n})=>{switch(n){case 2:return y.jsx(E.Icons.Heading2,{});case 3:return y.jsx(E.Icons.Heading3,{});case 4:return y.jsx(E.Icons.Heading4,{});case 5:return y.jsx(E.Icons.Heading5,{});case 6:return y.jsx(E.Icons.Heading6,{});default:return y.jsx(E.Icons.Heading,{})}},Yb=[{id:"left",icon:y.jsx(E.Icons.AlignLeft,{}),text:"Прижать влево"},{id:"right",icon:y.jsx(E.Icons.AlignRight,{}),text:"Прижать вправо"},{id:"center",icon:y.jsx(E.Icons.AlignCenter,{}),text:"Отцентровать"},{id:"justify",icon:y.jsx(E.Icons.AlignJustify,{}),text:"Выровнять по краям"}],Gb=({schema:n})=>{const e=m.useRef(null),[t,r]=m.useState(!1),o=re((s,i)=>{if(!s||!i.id)return;const l=i.id==="left"?null:i.id,{$from:a,$to:c}=s.state.selection,u=a.blockRange(c);if(u){const f=s.state.doc;let d=s.state.tr;f.nodesBetween(u.start,u.end,(h,p)=>{h.type.name==="paragraph"&&(d=d.setNodeMarkup(p,null,{align:l}))}),s.dispatch(d)}s.focus(),r(!1)});return n.nodes.paragraph?y.jsxs(y.Fragment,{children:[y.jsx("div",{ref:e,className:"MenuItem",onClick:()=>r(!0),children:y.jsx(E.Icons.AlignLeft,{})}),e.current&&y.jsx(E.Menu,{parent:e.current,items:Yb,isOpen:t,onClose:()=>r(!1),onClick:o,horizontal:"inner-left"})]}):null},Xb=({schema:n,onSave:e})=>y.jsxs("div",{className:"MenuBar",children:[y.jsxs("div",{className:"MenuBlock",children:[y.jsx(Kb,{schema:n}),y.jsx($u,{schema:n})]}),y.jsx(ju,{schema:n}),y.jsx(Wu,{schema:n}),y.jsx(Fu,{schema:n}),y.jsx(Gb,{schema:n}),y.jsx(_u,{schema:n}),y.jsx(Bu,{}),y.jsx("div",{className:"MenuBlock",children:y.jsx(Ku,{onSave:e})})]}),Ub=7,Ju=1,or=50,Qb=({width:n,onChange:e,onWidth:t})=>{const[r,o]=m.useState(!1),[s,i]=m.useState(0),[l,a]=m.useState(0),[c,u]=m.useState(n),f=p=>{const b=n[l],g=n[l+1],k=[...c];return b+p<or&&(p=or-b),g-p<or&&(p=g-or),k[l]=b+p,k[l+1]=g-p,k};m.useEffect(()=>{u(n)},[n]),m.useEffect(()=>{const p=g=>{if(!r)return;o(!1),g.preventDefault(),g.stopPropagation();const k=g.clientX-s,S=f(k);t(S)},b=g=>{if(!r)return;g.preventDefault(),g.stopPropagation();const k=g.clientX-s,S=f(k);u(S),e(S)};return document.addEventListener("mouseup",p),document.addEventListener("mousemove",b),()=>{document.removeEventListener("mouseup",p),document.removeEventListener("mousemove",b)}},[r,l]);const d=(p,b)=>{b!==n.length-1&&(p.preventDefault(),p.stopPropagation(),o(!0),i(p.clientX),a(b))},h=p=>c.slice(0,p+1).reduce((b,g)=>b+g,0)+p+Ju-Math.floor(Ub/2);return y.jsx("div",{className:"table-resizer",children:c.map((p,b)=>y.jsx("div",{style:{left:h(b)+"px"},onMouseDown:g=>d(g,b)},b))})},Zb=m.forwardRef(function({children:e,nodeProps:t,...r},o){var f;const s=m.useRef(null),i=m.useRef(null),[l,a]=m.useState([]),c=re((d,h)=>{if(!d)return;const p=t.node,b=t.getPos()+1,g=Q.get(p),k=d.state.tr;for(let S=0;S<g.height;S++)for(let M=0;M<g.width;){const O=S*g.width+M,I=g.map[O],w=p.nodeAt(I).attrs,V=h.slice(M,M+w.colspan);S&&g.map[O]==g.map[O-g.width]||k.setNodeMarkup(b+I,null,{...w,colwidth:V}),M+=w.colspan}k.docChanged&&d.dispatch(k)});m.useEffect(()=>{if(!s.current||!i.current)return;const h=t.node.firstChild;if(!h)return;let p=[];for(let w=0;w<h.childCount;w++){const V=h.child(w),{colspan:z,colwidth:T}=V.attrs;p=p.concat(Array.isArray(T)?T:Array(z).fill(0))}const b=p.filter(w=>!w).length,g=p.reduce((w,V)=>w+V,0),k=(p.length+1)*Ju,S=Math.max(b?(s.current.offsetWidth-g-k)/b:0,or);p=p.map(w=>w||S);const M=p.reduce((w,V)=>w+V,0),O=i.current.offsetWidth-k-16,I=O/M;p=p.map(w=>Math.round(w*I)),p[p.length-1]+=O-p.reduce((w,V)=>w+V,0),a(p)},[t,s,i,(f=i.current)==null?void 0:f.offsetWidth]);const u=re(d=>{Fg(d.state,d.dispatch)});return y.jsxs("div",{...r,className:"table-wrapper",ref:d=>{i.current=d,o&&(typeof o=="function"?o(d):o.current=d)},children:[y.jsx(Qb,{width:l,onChange:a,onWidth:c}),y.jsxs("table",{ref:s,children:[y.jsx("colgroup",{children:l.map((d,h)=>y.jsx("col",{width:d},h))}),y.jsx("caption",{onClick:u,children:y.jsx(E.Icons.Trash,{})}),y.jsx("tbody",{children:e})]})]})}),e0=[{id:"toggleHeaderRow",text:"Toggle header row",icon:y.jsx(E.Icons.Heading,{})},{id:"addRowBefore",text:"Insert row before",icon:y.jsx(E.Icons.RowInsertBefore,{})},{id:"addRowAfter",text:"Insert row after",icon:y.jsx(E.Icons.RowInsertAfter,{})},{id:"deleteRow",text:"Delete row",icon:y.jsx(E.Icons.Trash,{})}],t0=[{id:"toggleHeaderColumn",text:"Toggle header column",icon:y.jsx(E.Icons.Heading,{})},{id:"addColumnBefore",text:"Insert column before",icon:y.jsx(E.Icons.ColumnInsertBefore,{})},{id:"addColumnAfter",text:"Insert column after",icon:y.jsx(E.Icons.ColumnInsertAfter,{})},{id:"deleteColumn",text:"Delete column",icon:y.jsx(E.Icons.Trash,{})}],n0=[{id:"toggleHeaderCell",text:"Toggle header",icon:y.jsx(E.Icons.Heading,{})},{id:"alignLeft",text:"Horizontal align left",icon:y.jsx(E.Icons.AlignLeft,{})},{id:"alignCenter",text:"Horizontal align center",icon:y.jsx(E.Icons.AlignCenter,{})},{id:"alignRight",text:"Horizontal align Right",icon:y.jsx(E.Icons.AlignRight,{})},{id:"alignTop",text:"Vertical align top",icon:y.jsx(E.Icons.AlignTop,{})},{id:"alignMiddle",text:"Vertical align middle",icon:y.jsx(E.Icons.AlignMiddle,{})},{id:"alignBottom",text:"Vertical align bottom",icon:y.jsx(E.Icons.AlignBottom,{})},{id:"mergeCells",text:"Merge cells",icon:y.jsx(E.Icons.CellsMerge,{})},{id:"splitCell",text:"Split cell",icon:y.jsx(E.Icons.CellsSplit,{})}],Yu=({x:n,y:e,isRowMenuOpen:t,isCellMenuOpen:r,isColumnMenuOpen:o,onRowMenuClose:s,onCellMenuClose:i,onColumnMenuClose:l})=>{const a=re((c,u)=>{if(c){switch(u.id){case"toggleHeaderRow":zg(c.state,c.dispatch);break;case"addRowBefore":Dg(c.state,c.dispatch);break;case"addRowAfter":Og(c.state,c.dispatch);break;case"deleteRow":vg(c.state,c.dispatch);break;case"toggleHeaderColumn":$g(c.state,c.dispatch);break;case"addColumnBefore":Cg(c.state,c.dispatch);break;case"addColumnAfter":wg(c.state,c.dispatch);break;case"deleteColumn":Ng(c.state,c.dispatch);break;case"mergeCells":Pg(c.state,c.dispatch);break;case"splitCell":Ig(c.state,c.dispatch);break;case"toggleHeaderCell":jg(c.state,c.dispatch);break;case"alignLeft":mn("halign","left")(c.state,c.dispatch);break;case"alignCenter":mn("halign","center")(c.state,c.dispatch);break;case"alignRight":mn("halign","right")(c.state,c.dispatch);break;case"alignTop":mn("valign","top")(c.state,c.dispatch);break;case"alignMiddle":mn("valign","middle")(c.state,c.dispatch);break;case"alignBottom":mn("valign","bottom")(c.state,c.dispatch);break}s(),i(),l(),c.focus()}});return y.jsxs(y.Fragment,{children:[y.jsx(E.Menu,{x:n,y:e,items:e0,isOpen:t,onClose:s,onClick:a}),y.jsx(E.Menu,{x:n,y:e,items:n0,isOpen:r,onClose:i,onClick:a}),y.jsx(E.Menu,{x:n,y:e,items:t0,isOpen:o,onClose:l,onClick:a})]})},Gu=m.forwardRef(function({children:e,nodeProps:t,...r},o){const s=m.useRef(null),[i,l]=m.useState(0),[a,c]=m.useState(0),[u,f]=m.useState(!1),[d,h]=m.useState(!1),[p,b]=m.useState(!1);m.useEffect(()=>{const S=M=>{s.current!==M.target&&(f(!1),h(!1),b(!1))};return document.addEventListener("contextmenu",S,!0),()=>document.removeEventListener("contextmenu",S,!0)},[]);const g=S=>{S.preventDefault(),S.stopPropagation(),f(!1),h(!1),b(!1),l(S.clientX),c(S.clientY);const M=S.currentTarget.getBoundingClientRect();S.clientY<M.y?b(!0):S.clientX<M.x?f(!0):h(!0)},k=S=>{f(!1),h(!1),b(!1),l(S.clientX),c(S.clientY);const M=S.currentTarget.getBoundingClientRect();if(S.clientY<M.y)b(!0);else if(S.clientX<M.x)f(!0);else return;S.preventDefault(),S.stopPropagation()};return t.node.type.spec.tableRole==="header_cell"?y.jsxs("th",{...r,datatype:`width-${t.node.attrs.colwidth}`,colSpan:t.node.attrs.colspan,rowSpan:t.node.attrs.rowspan,style:{textAlign:t.node.attrs.halign,verticalAlign:t.node.attrs.valign},onClick:k,onContextMenu:g,ref:S=>{s.current=S,o&&(typeof o=="function"?o(S):o.current=S)},children:[e,y.jsx(Yu,{x:i,y:a,isRowMenuOpen:u,onRowMenuClose:()=>f(!1),isCellMenuOpen:d,onCellMenuClose:()=>h(!1),isColumnMenuOpen:p,onColumnMenuClose:()=>b(!1)})]}):y.jsxs("td",{...r,datatype:`width-${t.node.attrs.colwidth}`,colSpan:t.node.attrs.colspan,rowSpan:t.node.attrs.rowspan,style:{textAlign:t.node.attrs.halign,verticalAlign:t.node.attrs.valign},onClick:k,onContextMenu:g,ref:S=>{s.current=S,o&&(typeof o=="function"?o(S):o.current=S)},children:[e,y.jsx(Yu,{x:i,y:a,isRowMenuOpen:u,onRowMenuClose:()=>f(!1),isCellMenuOpen:d,onCellMenuClose:()=>h(!1),isColumnMenuOpen:p,onColumnMenuClose:()=>b(!1)})]})}),r0=m.forwardRef(function({children:e,nodeProps:t,...r},o){var I;const s=m.useRef(null),[i,l]=m.useState(!1),[a,c]=m.useState(!1),[u,f]=m.useState(!1),[d,h]=m.useState(),[p,b]=m.useState(),g=w=>{const V=w.scrollLeft,z=w.clientWidth,T=w.scrollWidth;c(V>0),f(V<T-z*1.5)};m.useEffect(()=>{s.current&&(p&&s.current.scrollWidth>p&&(s.current.scrollLeft=s.current.scrollWidth-s.current.clientWidth),b(s.current.scrollWidth))},[(I=s.current)==null?void 0:I.scrollWidth]),m.useEffect(()=>{h(t.getPos()+t.node.nodeSize-1),s.current&&t.node.childCount>1&&g(s.current)},[t,s]),Ke(w=>{if(!w||t.node.childCount>0)return;const V=w.state.tr,z=t.getPos(),T=t.node.nodeSize;w.dispatch(V.delete(z,z+T))},[t]);const k=re(w=>{if(!w)return;const V=t.getPos(),z=t.node.nodeSize;w.dispatch(w.state.tr.delete(V,V+z))}),S=()=>{l(!0)},M=w=>{g(w.currentTarget)},O=(w,V)=>{if(w.stopPropagation(),!s.current)return;const z=s.current.clientWidth;let T=s.current.scrollLeft+V*z;s.current.scrollLeft=T};return y.jsxs("div",{ref:o,...r,className:"carousel",children:[y.jsx("div",{className:"carousel-list",ref:s,onScroll:M,children:e}),y.jsxs("div",{className:"carousel-buttons",children:[y.jsx("div",{onClick:k,className:"text-button",children:"Удалить карусель"}),y.jsx("div",{onClick:S,children:y.jsx(E.Icons.Plus,{})})]}),a&&y.jsx("div",{className:"carousel-prev",onClick:w=>O(w,-1),children:y.jsx(E.Icons.ChevronLeft,{})}),u&&y.jsx("div",{className:"carousel-next",onClick:w=>O(w,1),children:y.jsx(E.Icons.ChevronRight,{})}),y.jsx(Lu,{pos:d,isOpen:i,onClose:()=>l(!1)})]})}),o0=({content:n,onSave:e,onChange:t,onUpload:r})=>{const[o,s]=m.useState();return m.useEffect(()=>{let i;if(n)try{i=be.fromJSON(Nt,JSON.parse(n))}catch(c){console.error(`Can not parse Prose format: ${c}`)}let l=Ge.create({doc:i,schema:Nt,plugins:Pu({schema:Nt,upload:r})});const a=Is(l);a&&(l=l.apply(a.setMeta("addToHistory",!1))),s(l)},[n]),o?y.jsx("div",{className:"ProseEditor",children:y.jsxs(vu,{state:o,dispatchTransaction:i=>s(l=>{const a=l==null?void 0:l.apply(i);return a&&t&&t(!!Po(a)),a}),nodeViews:{image:qu,video:Hu,table:Zb,table_header:Gu,table_cell:Gu,carousel:r0},children:[y.jsx(Xb,{schema:Nt,onSave:e}),y.jsx(Tu,{})]})}):null},s0=({node:n})=>{const[e,t]=m.useState();return m.useEffect(()=>{var o;const r=(o=n.attrs)==null?void 0:o.align;t(r!=="right"&&r!=="center"&&r!=="justify"?void 0:{textAlign:r})},[n]),y.jsx("p",{style:e,children:Array.isArray(n.content)&&n.content.map((r,o)=>y.jsx(Y,{node:r},o))})},i0=({node:n})=>{if(!n.text)return null;const e=(t,r)=>{var i;if(!Array.isArray(n.marks))return y.jsx(y.Fragment,{children:r});if(!t.length)return y.jsx(y.Fragment,{children:r});const o=t[0].type,s=(i=t[0].attrs)==null?void 0:i.href;switch(o){case"em":return y.jsx("em",{children:e(t.slice(1),r)});case"code":return y.jsx("code",{children:e(t.slice(1),r)});case"strong":return y.jsx("strong",{children:e(t.slice(1),r)});case"underline":return y.jsx("u",{children:e(t.slice(1),r)});case"strikethrough":return y.jsx("s",{children:e(t.slice(1),r)});case"link":return s?y.jsx("a",{target:"_blank",href:s,children:e(t.slice(1),r)}):y.jsx(y.Fragment,{children:e(t.slice(1),r)});default:return y.jsx(y.Fragment,{children:e(t.slice(1),r)})}};return e(n.marks,n.text)},l0=({node:n,className:e})=>y.jsx("div",{className:e,children:Array.isArray(n.content)&&n.content.map((t,r)=>y.jsx(Y,{node:t},r))}),a0=({node:n})=>{const e=m.useRef(null),[t,r]=m.useState(""),[o,s]=m.useState(""),[i,l]=m.useState(""),[a,c]=m.useState(!1);m.useEffect(()=>{const f=()=>{c(!!document.fullscreenElement)};return document.addEventListener("fullscreenchange",f),()=>document.removeEventListener("fullscreenchange",f)},[]),m.useEffect(()=>{var h,p,b,g,k,S,M;let f=(h=n.attrs)==null?void 0:h.fid,d=(p=n.attrs)!=null&&p.src?`${(b=n.attrs)==null?void 0:b.src}`:"";f&&(d=`${no}/files/${f}`),d||(d=ro),r(d),s((g=n.attrs)!=null&&g.alt?`${(k=n.attrs)==null?void 0:k.alt}`:""),l((S=n.attrs)!=null&&S.title?`${(M=n.attrs)==null?void 0:M.title}`:"")},[n]);const u=f=>{var d;f.stopPropagation(),a?document.exitFullscreen():(d=e.current)==null||d.requestFullscreen()};return t?y.jsxs("div",{ref:e,className:"image",children:[y.jsx("img",{src:t,onClick:u,alt:o,title:i}),i&&y.jsx("div",{className:"image-title",children:i}),y.jsx("div",{className:"image-full",onClick:u,children:a?y.jsx(E.Icons.Minimize,{}):y.jsx(E.Icons.Maximize,{})})]}):null},c0=({node:n})=>y.jsx("blockquote",{children:Array.isArray(n.content)&&n.content.map((e,t)=>y.jsx(Y,{node:e},t))}),u0=50,f0=({node:n})=>{const[e,t]=m.useState([]);return m.useEffect(()=>{if(t([]),!Array.isArray(n.content))return;const r=n.content[0];if(!Array.isArray(r.content))return;let o=[];for(let i=0;i<r.content.length;i++){const l=r.content[i].attrs;if(!l)return;const{colspan:a,colwidth:c}=l;o=o.concat(Array.isArray(c)?c:Array(a).fill(u0))}const s=o.reduce((i,l)=>i+l,0);o=o.map(i=>Math.round(i*100/s)),o[o.length-1]+=100-o.reduce((i,l)=>i+l,0),t(o)},[n]),y.jsxs("table",{children:[e.length>0&&y.jsx("colgroup",{children:e.map((r,o)=>y.jsx("col",{width:`${r}%`},o))}),y.jsx("tbody",{children:Array.isArray(n.content)&&n.content.map((r,o)=>y.jsx(Y,{node:r},o))})]})},d0=({node:n})=>y.jsx("tr",{children:Array.isArray(n.content)&&n.content.map((e,t)=>y.jsx(Y,{node:e},t))}),h0=({node:n})=>{const[e,t]=m.useState(),[r,o]=m.useState(),[s,i]=m.useState(),[l,a]=m.useState();return m.useEffect(()=>{var c,u,f,d;t((c=n.attrs)==null?void 0:c.halign),o((u=n.attrs)==null?void 0:u.valign),i((f=n.attrs)!=null&&f.rowspan?parseInt(n.attrs.rowspan+""):1),a((d=n.attrs)!=null&&d.colspan?parseInt(n.attrs.colspan+""):1)},[n]),n.type==="table_header"?y.jsx("th",{colSpan:l,rowSpan:s,style:{textAlign:e,verticalAlign:r},children:Array.isArray(n.content)&&n.content.map((c,u)=>y.jsx(Y,{node:c},u))}):y.jsx("td",{colSpan:l,rowSpan:s,style:{textAlign:e,verticalAlign:r},children:Array.isArray(n.content)&&n.content.map((c,u)=>y.jsx(Y,{node:c},u))})},p0=({node:n})=>{var e;if(!Array.isArray(n.content))return null;switch((e=n.attrs)==null?void 0:e.level){case 1:return y.jsx("h1",{children:n.content.map((t,r)=>y.jsx(Y,{node:t},r))});case 2:return y.jsx("h2",{children:n.content.map((t,r)=>y.jsx(Y,{node:t},r))});case 3:return y.jsx("h3",{children:n.content.map((t,r)=>y.jsx(Y,{node:t},r))});case 4:return y.jsx("h4",{children:n.content.map((t,r)=>y.jsx(Y,{node:t},r))});case 5:return y.jsx("h5",{children:n.content.map((t,r)=>y.jsx(Y,{node:t},r))});case 6:return y.jsx("h6",{children:n.content.map((t,r)=>y.jsx(Y,{node:t},r))});default:return y.jsx("h2",{children:n.content.map((t,r)=>y.jsx(Y,{node:t},r))})}},m0=({node:n})=>Array.isArray(n.content)?n.type==="bullet_list"?y.jsx("ul",{children:n.content.map((e,t)=>y.jsx(Y,{node:e},t))}):y.jsx("ol",{children:n.content.map((e,t)=>y.jsx(Y,{node:e},t))}):null,g0=({node:n})=>y.jsx("li",{children:Array.isArray(n.content)&&n.content.map((e,t)=>y.jsx(Y,{node:e},t))}),y0=({node:n})=>y.jsx("pre",{children:Array.isArray(n.content)&&n.content.map((e,t)=>y.jsx(Y,{node:e},t))}),b0=()=>y.jsx("hr",{}),x0=({node:n})=>{const[e,t]=m.useState(""),[r,o]=m.useState(""),s="fullscreen; accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share";return m.useEffect(()=>{var i,l,a,c;t((i=n.attrs)!=null&&i.src?`${(l=n.attrs)==null?void 0:l.src}`:""),o((a=n.attrs)!=null&&a.title?`${(c=n.attrs)==null?void 0:c.title}`:"")},[n]),oo(e)?y.jsx("div",{title:r,className:"video",children:y.jsx("iframe",{src:e,allow:s})}):y.jsx("div",{title:r,className:"image",children:y.jsx("img",{src:ro})})},k0=()=>y.jsx("br",{}),S0=({node:n})=>{const e=m.useRef(null),t=m.useRef(null),[r,o]=m.useState(!1),[s,i]=m.useState(!1),[l,a]=m.useState(!1),[c,u]=m.useState(1),[f,d]=m.useState(1),h=g=>{const k=g.scrollLeft,S=g.clientWidth,M=g.scrollWidth;i(k>S/2),a(k<M-S*1.5),u(Math.round(k/S+1))};m.useEffect(()=>{var g;a(Array.isArray(n.content)&&n.content.length>1),d(((g=n.content)==null?void 0:g.length)??1),u(1)},[n]),m.useEffect(()=>{const g=()=>{o(!!document.fullscreenElement)};return document.addEventListener("fullscreenchange",g),()=>document.removeEventListener("fullscreenchange",g)},[]),m.useEffect(()=>{if(!r)return;const g=k=>{k.key==="ArrowLeft"&&b(null,-1),k.key==="ArrowRight"&&b(null,1)};return document.body.addEventListener("keydown",g),()=>document.body.removeEventListener("keydown",g)},[r]);const p=g=>{var k;g.stopPropagation(),r?document.exitFullscreen():(k=t.current)==null||k.requestFullscreen()},b=(g,k)=>{if(g==null||g.stopPropagation(),!e.current)return;const S=e.current.clientWidth;let M=e.current.scrollLeft+k*S;e.current.scrollLeft=M};return Array.isArray(n.content)?y.jsxs("div",{className:"carousel",ref:t,children:[y.jsx("div",{className:"carousel-list",ref:e,onScroll:g=>h(g.currentTarget),children:n.content.map((g,k)=>y.jsx(C0,{node:g,onClick:p},k))}),y.jsxs("div",{className:"carousel-numb",children:[c," / ",f]}),y.jsx("div",{className:"carousel-full",onClick:p,children:r?y.jsx(E.Icons.Minimize,{}):y.jsx(E.Icons.Maximize,{})}),s&&y.jsx("div",{className:"carousel-prev",onClick:g=>b(g,-1),children:y.jsx(E.Icons.ChevronLeft,{})}),l&&y.jsx("div",{className:"carousel-next",onClick:g=>b(g,1),children:y.jsx(E.Icons.ChevronRight,{})})]}):null},C0=({node:n,onClick:e})=>{const[t,r]=m.useState(""),[o,s]=m.useState(""),[i,l]=m.useState("");return m.useEffect(()=>{var d,h,p,b;let a=(d=n.attrs)==null?void 0:d.fid,c=(h=n.attrs)!=null&&h.src?`${n.attrs.src}`:"",u=(p=n.attrs)!=null&&p.alt?`${n.attrs.alt}`:"",f=(b=n.attrs)!=null&&b.title?`${n.attrs.title}`:"";a&&(c=`${no}/files/${a}`),c||(c=ro),r(c),s(u),l(f)},[n]),n.type!=="image"?null:y.jsxs("div",{className:"image",children:[t&&y.jsx("img",{src:t,onClick:e,alt:o,title:i}),i&&y.jsx("div",{className:"image-title",children:i})]})},Y=({node:n,className:e})=>n?(r=>{switch(r.type){case"doc":return y.jsx(l0,{node:r,className:e});case"list_item":return y.jsx(g0,{node:r});case"bullet_list":case"ordered_list":return y.jsx(m0,{node:r});case"image":return y.jsx(a0,{node:r});case"video":return y.jsx(x0,{node:r});case"text":return y.jsx(i0,{node:r});case"table":return y.jsx(f0,{node:r});case"table_row":return y.jsx(d0,{node:r});case"table_cell":case"table_header":return y.jsx(h0,{node:r});case"heading":return y.jsx(p0,{node:r});case"code_block":return y.jsx(y0,{node:r});case"paragraph":return y.jsx(s0,{node:r});case"blockquote":return y.jsx(c0,{node:r});case"carousel":return y.jsx(S0,{node:r});case"horizontal_rule":return y.jsx(b0,{});case"hard_break":return y.jsx(k0,{});default:return y.jsx("span",{className:"unknown_node_type",children:r.type})}})(n):null,w0=({content:n})=>{const[e,t]=m.useState(),[r,o]=m.useState(!1);return m.useEffect(()=>{try{o(!1);const s=JSON.parse(n);t(s)}catch(s){o(!0),console.error(`Can not parse Prose format: ${s}`)}},[n]),r?y.jsx("div",{className:"error",children:"ОШИБКА"}):y.jsx(Y,{node:e,className:"ProseViewer"})},M0=({content:n})=>{const e=m.useRef(null),[t,r]=m.useState(!1);return m.useEffect(()=>{var o;try{r(!1);const s=be.fromJSON(Nt,JSON.parse(n)),i=$e.fromSchema(Nt).serializeFragment(s.content);(o=e.current)==null||o.appendChild(i)}catch(s){r(!0),console.error(`Can not parse Prose format: ${s}`)}},[e,n]),y.jsx("div",{ref:e,className:"ProseViewer",children:t&&y.jsx("div",{className:"error",children:"ОШИБКА"})})};G.DOM=M0,G.Editor=o0,G.Notes=Hb,G.Viewer=w0,Object.defineProperty(G,Symbol.toStringTag,{value:"Module"})});
|
|
66
66
|
//# sourceMappingURL=prose-editor.umd.js.map
|