asma-ui-richeditor 0.1.2-beta9 → 0.1.3

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.
@@ -1,5 +1,5 @@
1
- (function(){"use strict";try{if(typeof document<"u"){var r=document.createElement("style");r.appendChild(document.createTextNode(".toolbar{position:absolute;top:0;left:0;width:100%;padding-block:4px;background-color:var(--colors-gray-100);display:flex;align-items:center;justify-content:space-between;flex-wrap:nowrap;border-inline:1px solid var(--colors-gray-500);border-bottom:1px solid var(--colors-gray-500);border-bottom-left-radius:4px;border-bottom-right-radius:4px;padding-inline:1rem;box-sizing:border-box;position:relative}.core-ui-rte:not(:focus-within):hover+.toolbar{border-inline:1px solid var(--colors-gama-300);border-bottom:1px solid var(--colors-gama-300)}.toolbar-error{border-inline:1px solid var(--colors-red-500);border-bottom:1px solid var(--colors-red-500)}.toolbar-focused{border-inline:1px solid var(--colors-gama-500);border-bottom:1px solid var(--colors-gama-500)}.font-size-select{appearance:none;-webkit-appearance:none;-moz-appearance:none;background-color:transparent;padding-right:25px;cursor:pointer;border-radius:4px;color:var(--colors-delta-700);font-size:14px;padding-left:4px}.font-size-select option{cursor:pointer}.font-size-select:focus{outline:none}.select-wrapper{position:relative;display:flex;align-items:center;justify-content:center}.chevron-icon{position:absolute;right:6px;top:8px;pointer-events:none;color:var(--colors-delta-700)}:root{--max-scrollable-height: 100px}*{box-sizing:border-box;padding:0;margin:0}.core-ui-rte{box-sizing:border-box;border-radius:4px;border:1px solid var(--colors-gray-500);overflow:hidden}.core-ui-rte:not(:focus-within):hover{border-color:var(--colors-gama-300)}.core-ui-rte:focus-within{border-color:var(--colors-gama-500)}.core-ui-rte.error-state:hover{border-color:var(--colors-red-500)}.core-ui-rte a{text-decoration:underline;cursor:pointer;color:var(--colors-gama-400);transition:color .3s ease-in}.core-ui-rte a:hover{color:var(--colors-gama-600)}.core-ui-rte ol{list-style-type:decimal}.core-ui-rte ul{list-style-type:disc}.core-ui-rte .tiptap :first-child{margin-top:0}.core-ui-rte .tiptap{flex:1 1 0%;outline:none;padding:8px 14px;overflow-y:auto;max-height:var(--max-scrollable-height);scrollbar-width:thin;scrollbar-color:var(--colors-gray-500) #fff}.core-ui-rte .tiptap ul,.core-ui-rte .tiptap ol{padding:0 1rem;margin:1.25rem 1rem 1.25rem .4rem}.core-ui-rte .tiptap ul li,.core-ui-rte .tiptap ol li{margin-top:.25em;margin-bottom:.25em}.core-ui-rte .tiptap .core-ui-rte ol{list-style-type:decimal}.core-ui-rte .tiptap .core-ui-rte ul{list-style-type:disc}.core-ui-rte .tiptap h1{font-size:2em;padding:0;margin:0}.core-ui-rte .tiptap h2{font-size:1.5em;padding:0;margin:0}.core-ui-rte.core-ui-rte-error{border-radius:4px;border:1px solid var(--colors-red-500)}.core-ui-rte.core-ui-rte-tools-error{border-radius:4px 4px 0 0;border:1px solid var(--colors-red-500);border-bottom:none}.core-ui-rte-edit-mode{border-radius:4px 4px 0 0;border-bottom:none;min-height:40px}.core-ui-rte-hide-toolbar{border:1px solid var(--colors-gray-500);border-radius:4px}.core-ui-rte.core-ui-rte-readonly-mode{min-height:100px;background-color:var(--colors-gray-10);border-color:var(--colors-gray-200)}.core-ui-rte.core-ui-rte-readonly-mode:hover{border-color:var(--colors-gray-200)}")),document.head.appendChild(r)}}catch(o){console.error("vite-plugin-css-injected-by-js",o)}})();
2
- import t,{forwardRef as e,useRef as n,useState as r,useDebugValue as o,useEffect as i,createContext as s,useContext as a,createElement as l,useCallback as c,useImperativeHandle as d}from"react";import h from"react-dom";import{StyledButton as u,LinkOutlineIcon as p,DotsVerticalIcon as f,StyledMenuItem as m,StyledDialog as g,StyledInputField as y,StyledFormControl as b,StyledFormHelperText as v}from"asma-core-ui";import{Popover as w}from"@mui/material";var k,x={exports:{}},S={};
1
+ (function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode(".toolbar{width:100%;padding-block:4px;background-color:var(--colors-delta-10);display:flex;align-items:center;justify-content:space-between;flex-wrap:nowrap;padding-inline:8px;border-top:1px solid var(--colors-delta-200)}.chevron-icon{position:absolute;right:6px;top:8px;pointer-events:none;color:var(--colors-delta-700)}.link-input-field{width:568px}@media (width <= 768px){.link-input-field{width:100%}}:root{--max-scrollable-height: 100px}*{box-sizing:border-box;padding:0;margin:0}.core-ui-rte{overflow:hidden}.core-ui-rte a{text-decoration:underline;cursor:pointer;color:var(--colors-gama-400);transition:color .3s ease-in}.core-ui-rte a:hover{color:var(--colors-gama-600)}.core-ui-rte ol{list-style-type:decimal}.core-ui-rte ul{list-style-type:disc}.core-ui-rte .tiptap :first-child{margin-top:0}.core-ui-rte .tiptap{outline:none;padding-block:8px;padding-left:14px;padding-right:14px;overflow-y:auto;max-height:var(--max-scrollable-height);scrollbar-width:thin;scrollbar-color:var(--colors-gray-500) transparent}.core-ui-rte .tiptap ul,.core-ui-rte .tiptap ol{padding:0 1rem;margin:1.25rem 1rem 1.25rem .4rem}.core-ui-rte .tiptap ul li,.core-ui-rte .tiptap ol li{margin-top:.25em;margin-bottom:.25em}.core-ui-rte .tiptap .core-ui-rte ol{list-style-type:decimal}.core-ui-rte .tiptap .core-ui-rte ul{list-style-type:disc}.core-ui-rte .tiptap h1{font-size:2em;padding:0;margin:0}.core-ui-rte .tiptap h2{font-size:1.5em;padding:0;margin:0}.core-ui-rte.displace-text .tiptap{padding-right:40px}.core-ui-rte.edit-mode .tiptap{min-height:40px;max-height:var(--max-scrollable-height)}.rte-wrapper{position:relative;display:flex;flex-direction:column;height:100%;border-radius:4px;overflow:hidden;outline:1px solid var(--colors-delta-500);outline-offset:-1px}.rte-wrapper:hover{outline:2px solid var(--colors-gama-300);outline-offset:-2px}.rte-wrapper.error-state{outline:1px solid var(--colors-red-500)}.rte-wrapper.error-state:hover{outline:2px solid var(--colors-red-500)}.rte-wrapper.error-focused-state{outline:2px solid var(--colors-red-500);outline-offset:-2px}.rte-wrapper.readonly-outlined .tiptap{min-height:100px;max-height:none;overflow:hidden}.rte-wrapper.readonly-outlined{background-color:var(--colors-gray-10);outline:1px solid var(--colors-gray-200);outline-offset:-1px}.rte-wrapper.readonly-outlined:hover{outline:1px solid var(--colors-gray-200);outline-offset:-1px}.rte-wrapper.readonly-plain .tiptap{max-height:none;overflow:hidden;padding:0;margin:0}.rte-wrapper.readonly-plain{background-color:#fff;border-radius:unset;outline:none}.rte-wrapper.readonly-plain:hover{outline:none}.rte-wrapper.focused-state{outline:2px solid var(--colors-gama-400);outline-offset:-2px}")),document.head.appendChild(e)}}catch(r){console.error("vite-plugin-css-injected-by-js",r)}})();
2
+ import t,{forwardRef as e,useRef as n,useState as r,useDebugValue as o,useEffect as i,createContext as s,useContext as a,createElement as l,useCallback as c,useLayoutEffect as d,useMemo as h,useImperativeHandle as u}from"react";import p from"react-dom";import{StyledMenuItem as f,StyledInputField as m,LinkOutlineIcon as g,StyledButton as y,DotsVerticalIcon as b,StyledDialog as v,StyledFormControl as w,StyledFormHelperText as k}from"asma-core-ui";import{Popover as x}from"@mui/material";var S,O={exports:{}},C={};
3
3
  /**
4
4
  * @license React
5
5
  * react-jsx-runtime.production.min.js
@@ -8,7 +8,7 @@ import t,{forwardRef as e,useRef as n,useState as r,useDebugValue as o,useEffect
8
8
  *
9
9
  * This source code is licensed under the MIT license found in the
10
10
  * LICENSE file in the root directory of this source tree.
11
- */var O,C={};
11
+ */var M,T={};
12
12
  /**
13
13
  * @license React
14
14
  * react-jsx-runtime.development.js
@@ -17,7 +17,7 @@ import t,{forwardRef as e,useRef as n,useState as r,useDebugValue as o,useEffect
17
17
  *
18
18
  * This source code is licensed under the MIT license found in the
19
19
  * LICENSE file in the root directory of this source tree.
20
- */"production"===process.env.NODE_ENV?x.exports=function(){if(k)return S;k=1;var e=t,n=Symbol.for("react.element"),r=Symbol.for("react.fragment"),o=Object.prototype.hasOwnProperty,i=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,s={key:!0,ref:!0,__self:!0,__source:!0};function a(t,e,r){var a,l={},c=null,d=null;for(a in void 0!==r&&(c=""+r),void 0!==e.key&&(c=""+e.key),void 0!==e.ref&&(d=e.ref),e)o.call(e,a)&&!s.hasOwnProperty(a)&&(l[a]=e[a]);if(t&&t.defaultProps)for(a in e=t.defaultProps)void 0===l[a]&&(l[a]=e[a]);return{$$typeof:n,type:t,key:c,ref:d,props:l,_owner:i.current}}return S.Fragment=r,S.jsx=a,S.jsxs=a,S}():x.exports=(O||(O=1,"production"!==process.env.NODE_ENV&&function(){var e=t,n=Symbol.for("react.element"),r=Symbol.for("react.portal"),o=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),a=Symbol.for("react.provider"),l=Symbol.for("react.context"),c=Symbol.for("react.forward_ref"),d=Symbol.for("react.suspense"),h=Symbol.for("react.suspense_list"),u=Symbol.for("react.memo"),p=Symbol.for("react.lazy"),f=Symbol.for("react.offscreen"),m=Symbol.iterator,g="@@iterator",y=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function b(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];!function(t,e,n){var r=y.ReactDebugCurrentFrame,o=r.getStackAddendum();""!==o&&(e+="%s",n=n.concat([o]));var i=n.map((function(t){return String(t)}));i.unshift("Warning: "+e),Function.prototype.apply.call(console[t],console,i)}("error",t,n)}var v,w=!1,k=!1,x=!1,S=!1,O=!1;function M(t){return t.displayName||"Context"}function T(t){if(null==t)return null;if("number"==typeof t.tag&&b("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),"function"==typeof t)return t.displayName||t.name||null;if("string"==typeof t)return t;switch(t){case o:return"Fragment";case r:return"Portal";case s:return"Profiler";case i:return"StrictMode";case d:return"Suspense";case h:return"SuspenseList"}if("object"==typeof t)switch(t.$$typeof){case l:return M(t)+".Consumer";case a:return M(t._context)+".Provider";case c:return function(t,e,n){var r=t.displayName;if(r)return r;var o=e.displayName||e.name||"";return""!==o?n+"("+o+")":n}(t,t.render,"ForwardRef");case u:var e=t.displayName||null;return null!==e?e:T(t.type)||"Memo";case p:var n=t,f=n._payload,m=n._init;try{return T(m(f))}catch{return null}}return null}v=Symbol.for("react.module.reference");var E,N,A,D,R,I,L,P=Object.assign,j=0;function z(){}z.__reactDisabledLog=!0;var $,B=y.ReactCurrentDispatcher;function F(t,e,n){if(void 0===$)try{throw Error()}catch(t){var r=t.stack.trim().match(/\n( *(at )?)/);$=r&&r[1]||""}return"\n"+$+t}var _,V=!1,H="function"==typeof WeakMap?WeakMap:Map;function W(t,e){if(!t||V)return"";var n,r=_.get(t);if(void 0!==r)return r;V=!0;var o,i=Error.prepareStackTrace;Error.prepareStackTrace=void 0,o=B.current,B.current=null,function(){if(0===j){E=console.log,N=console.info,A=console.warn,D=console.error,R=console.group,I=console.groupCollapsed,L=console.groupEnd;var t={configurable:!0,enumerable:!0,value:z,writable:!0};Object.defineProperties(console,{info:t,log:t,warn:t,error:t,group:t,groupCollapsed:t,groupEnd:t})}j++}();try{if(e){var s=function(){throw Error()};if(Object.defineProperty(s.prototype,"props",{set:function(){throw Error()}}),"object"==typeof Reflect&&Reflect.construct){try{Reflect.construct(s,[])}catch(t){n=t}Reflect.construct(t,[],s)}else{try{s.call()}catch(t){n=t}t.call(s.prototype)}}else{try{throw Error()}catch(t){n=t}t()}}catch(e){if(e&&n&&"string"==typeof e.stack){for(var a=e.stack.split("\n"),l=n.stack.split("\n"),c=a.length-1,d=l.length-1;c>=1&&d>=0&&a[c]!==l[d];)d--;for(;c>=1&&d>=0;c--,d--)if(a[c]!==l[d]){if(1!==c||1!==d)do{if(c--,--d<0||a[c]!==l[d]){var h="\n"+a[c].replace(" at new "," at ");return t.displayName&&h.includes("<anonymous>")&&(h=h.replace("<anonymous>",t.displayName)),"function"==typeof t&&_.set(t,h),h}}while(c>=1&&d>=0);break}}}finally{V=!1,B.current=o,function(){if(0==--j){var t={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:P({},t,{value:E}),info:P({},t,{value:N}),warn:P({},t,{value:A}),error:P({},t,{value:D}),group:P({},t,{value:R}),groupCollapsed:P({},t,{value:I}),groupEnd:P({},t,{value:L})})}j<0&&b("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}(),Error.prepareStackTrace=i}var u=t?t.displayName||t.name:"",p=u?F(u):"";return"function"==typeof t&&_.set(t,p),p}function K(t,e,n){if(null==t)return"";if("function"==typeof t)return W(t,function(t){var e=t.prototype;return!(!e||!e.isReactComponent)}(t));if("string"==typeof t)return F(t);switch(t){case d:return F("Suspense");case h:return F("SuspenseList")}if("object"==typeof t)switch(t.$$typeof){case c:return function(t,e,n){return W(t,!1)}(t.render);case u:return K(t.type,e,n);case p:var r=t,o=r._payload,i=r._init;try{return K(i(o),e,n)}catch{}}return""}_=new H;var q=Object.prototype.hasOwnProperty,J={},U=y.ReactDebugCurrentFrame;function G(t){if(t){var e=t._owner,n=K(t.type,t._source,e?e.type:null);U.setExtraStackFrame(n)}else U.setExtraStackFrame(null)}var Y=Array.isArray;function Q(t){return Y(t)}function X(t){return""+t}function Z(t){if(function(t){try{return X(t),!1}catch{return!0}}(t))return b("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",function(t){return"function"==typeof Symbol&&Symbol.toStringTag&&t[Symbol.toStringTag]||t.constructor.name||"Object"}(t)),X(t)}var tt,et,nt,rt=y.ReactCurrentOwner,ot={key:!0,ref:!0,__self:!0,__source:!0};nt={};var it=function(t,e,r,o,i,s,a){var l={$$typeof:n,type:t,key:e,ref:r,props:a,_owner:s,_store:{}};return Object.defineProperty(l._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(l,"_self",{configurable:!1,enumerable:!1,writable:!1,value:o}),Object.defineProperty(l,"_source",{configurable:!1,enumerable:!1,writable:!1,value:i}),Object.freeze&&(Object.freeze(l.props),Object.freeze(l)),l};function st(t,e,n,r,o){var i,s={},a=null,l=null;for(i in void 0!==n&&(Z(n),a=""+n),function(t){if(q.call(t,"key")){var e=Object.getOwnPropertyDescriptor(t,"key").get;if(e&&e.isReactWarning)return!1}return void 0!==t.key}(e)&&(Z(e.key),a=""+e.key),function(t){if(q.call(t,"ref")){var e=Object.getOwnPropertyDescriptor(t,"ref").get;if(e&&e.isReactWarning)return!1}return void 0!==t.ref}(e)&&(l=e.ref,function(t,e){if("string"==typeof t.ref&&rt.current&&e&&rt.current.stateNode!==e){var n=T(rt.current.type);nt[n]||(b('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref',T(rt.current.type),t.ref),nt[n]=!0)}}(e,o)),e)q.call(e,i)&&!ot.hasOwnProperty(i)&&(s[i]=e[i]);if(t&&t.defaultProps){var c=t.defaultProps;for(i in c)void 0===s[i]&&(s[i]=c[i])}if(a||l){var d="function"==typeof t?t.displayName||t.name||"Unknown":t;a&&function(t,e){var n=function(){tt||(tt=!0,b("%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://reactjs.org/link/special-props)",e))};n.isReactWarning=!0,Object.defineProperty(t,"key",{get:n,configurable:!0})}(s,d),l&&function(t,e){var n=function(){et||(et=!0,b("%s: `ref` 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://reactjs.org/link/special-props)",e))};n.isReactWarning=!0,Object.defineProperty(t,"ref",{get:n,configurable:!0})}(s,d)}return it(t,a,l,o,r,rt.current,s)}var at,lt=y.ReactCurrentOwner,ct=y.ReactDebugCurrentFrame;function dt(t){if(t){var e=t._owner,n=K(t.type,t._source,e?e.type:null);ct.setExtraStackFrame(n)}else ct.setExtraStackFrame(null)}function ht(t){return"object"==typeof t&&null!==t&&t.$$typeof===n}function ut(){if(lt.current){var t=T(lt.current.type);if(t)return"\n\nCheck the render method of `"+t+"`."}return""}at=!1;var pt={};function ft(t,e){if(t._store&&!t._store.validated&&null==t.key){t._store.validated=!0;var n=function(t){var e=ut();if(!e){var n="string"==typeof t?t:t.displayName||t.name;n&&(e="\n\nCheck the top-level render call using <"+n+">.")}return e}(e);if(!pt[n]){pt[n]=!0;var r="";t&&t._owner&&t._owner!==lt.current&&(r=" It was passed a child from "+T(t._owner.type)+"."),dt(t),b('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',n,r),dt(null)}}}function mt(t,e){if("object"==typeof t)if(Q(t))for(var n=0;n<t.length;n++){var r=t[n];ht(r)&&ft(r,e)}else if(ht(t))t._store&&(t._store.validated=!0);else if(t){var o=function(t){if(null===t||"object"!=typeof t)return null;var e=m&&t[m]||t[g];return"function"==typeof e?e:null}(t);if("function"==typeof o&&o!==t.entries)for(var i,s=o.call(t);!(i=s.next()).done;)ht(i.value)&&ft(i.value,e)}}function gt(t){var e,n=t.type;if(null!=n&&"string"!=typeof n){if("function"==typeof n)e=n.propTypes;else{if("object"!=typeof n||n.$$typeof!==c&&n.$$typeof!==u)return;e=n.propTypes}if(e){var r=T(n);!function(t,e,n,r,o){var i=Function.call.bind(q);for(var s in t)if(i(t,s)){var a=void 0;try{if("function"!=typeof t[s]){var l=Error((r||"React class")+": "+n+" type `"+s+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof t[s]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw l.name="Invariant Violation",l}a=t[s](e,s,r,n,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(t){a=t}a&&!(a instanceof Error)&&(G(o),b("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",r||"React class",n,s,typeof a),G(null)),a instanceof Error&&!(a.message in J)&&(J[a.message]=!0,G(o),b("Failed %s type: %s",n,a.message),G(null))}}(e,t.props,"prop",r,t)}else void 0===n.PropTypes||at||(at=!0,b("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",T(n)||"Unknown"));"function"==typeof n.getDefaultProps&&!n.getDefaultProps.isReactClassApproved&&b("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function yt(t,e,r,m,g,y){var C=function(t){return!!("string"==typeof t||"function"==typeof t||t===o||t===s||O||t===i||t===d||t===h||S||t===f||w||k||x||"object"==typeof t&&null!==t&&(t.$$typeof===p||t.$$typeof===u||t.$$typeof===a||t.$$typeof===l||t.$$typeof===c||t.$$typeof===v||void 0!==t.getModuleId))}(t);if(!C){var M="";(void 0===t||"object"==typeof t&&null!==t&&0===Object.keys(t).length)&&(M+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var E,N=function(t){return void 0!==t?"\n\nCheck your code at "+t.fileName.replace(/^.*[\\\/]/,"")+":"+t.lineNumber+".":""}(g);M+=N||ut(),null===t?E="null":Q(t)?E="array":void 0!==t&&t.$$typeof===n?(E="<"+(T(t.type)||"Unknown")+" />",M=" Did you accidentally export a JSX literal instead of a component?"):E=typeof t,b("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",E,M)}var A=st(t,e,r,g,y);if(null==A)return A;if(C){var D=e.children;if(void 0!==D)if(m)if(Q(D)){for(var R=0;R<D.length;R++)mt(D[R],t);Object.freeze&&Object.freeze(D)}else b("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 mt(D,t)}return t===o?function(t){for(var e=Object.keys(t.props),n=0;n<e.length;n++){var r=e[n];if("children"!==r&&"key"!==r){dt(t),b("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",r),dt(null);break}}null!==t.ref&&(dt(t),b("Invalid attribute `ref` supplied to `React.Fragment`."),dt(null))}(A):gt(A),A}var bt=function(t,e,n){return yt(t,e,n,!1)},vt=function(t,e,n){return yt(t,e,n,!0)};C.Fragment=o,C.jsx=bt,C.jsxs=vt}()),C);var M=x.exports;function T(t){var e,n,r="";if("string"==typeof t||"number"==typeof t)r+=t;else if("object"==typeof t)if(Array.isArray(t)){var o=t.length;for(e=0;e<o;e++)t[e]&&(n=T(t[e]))&&(r&&(r+=" "),r+=n)}else for(n in t)t[n]&&(r&&(r+=" "),r+=n);return r}function E(){for(var t,e,n=0,r="",o=arguments.length;n<o;n++)(t=arguments[n])&&(e=T(t))&&(r&&(r+=" "),r+=e);return r}function N(t){this.content=t}function A(t,e,n){for(let r=0;;r++){if(r==t.childCount||r==e.childCount)return t.childCount==e.childCount?null:n;let o=t.child(r),i=e.child(r);if(o!=i){if(!o.sameMarkup(i))return n;if(o.isText&&o.text!=i.text){for(let t=0;o.text[t]==i.text[t];t++)n++;return n}if(o.content.size||i.content.size){let t=A(o.content,i.content,n+1);if(null!=t)return t}n+=o.nodeSize}else n+=o.nodeSize}}function D(t,e,n,r){for(let o=t.childCount,i=e.childCount;;){if(0==o||0==i)return o==i?null:{a:n,b:r};let s=t.child(--o),a=e.child(--i),l=s.nodeSize;if(s!=a){if(!s.sameMarkup(a))return{a:n,b:r};if(s.isText&&s.text!=a.text){let t=0,e=Math.min(s.text.length,a.text.length);for(;t<e&&s.text[s.text.length-t-1]==a.text[a.text.length-t-1];)t++,n--,r--;return{a:n,b:r}}if(s.content.size||a.content.size){let t=D(s.content,a.content,n-1,r-1);if(t)return t}n-=l,r-=l}else n-=l,r-=l}}N.prototype={constructor:N,find:function(t){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===t)return e;return-1},get:function(t){var e=this.find(t);return-1==e?void 0:this.content[e+1]},update:function(t,e,n){var r=n&&n!=t?this.remove(n):this,o=r.find(t),i=r.content.slice();return-1==o?i.push(n||t,e):(i[o+1]=e,n&&(i[o]=n)),new N(i)},remove:function(t){var e=this.find(t);if(-1==e)return this;var n=this.content.slice();return n.splice(e,2),new N(n)},addToStart:function(t,e){return new N([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var n=this.remove(t).content.slice();return n.push(t,e),new N(n)},addBefore:function(t,e,n){var r=this.remove(e),o=r.content.slice(),i=r.find(t);return o.splice(-1==i?o.length:i,0,e,n),new N(o)},forEach:function(t){for(var e=0;e<this.content.length;e+=2)t(this.content[e],this.content[e+1])},prepend:function(t){return(t=N.from(t)).size?new N(t.content.concat(this.subtract(t).content)):this},append:function(t){return(t=N.from(t)).size?new N(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=N.from(t);for(var n=0;n<t.content.length;n+=2)e=e.remove(t.content[n]);return e},toObject:function(){var t={};return this.forEach((function(e,n){t[e]=n})),t},get size(){return this.content.length>>1}},N.from=function(t){if(t instanceof N)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new N(e)};class R{constructor(t,e){if(this.content=t,this.size=e||0,null==e)for(let e=0;e<t.length;e++)this.size+=t[e].nodeSize}nodesBetween(t,e,n,r=0,o){for(let i=0,s=0;s<e;i++){let a=this.content[i],l=s+a.nodeSize;if(l>t&&!1!==n(a,r+s,o||null,i)&&a.content.size){let o=s+1;a.nodesBetween(Math.max(0,t-o),Math.min(a.content.size,e-o),n,r+o)}s=l}}descendants(t){this.nodesBetween(0,this.size,t)}textBetween(t,e,n,r){let o="",i=!0;return this.nodesBetween(t,e,((s,a)=>{let l=s.isText?s.text.slice(Math.max(t,a)-a,e-a):s.isLeaf?r?"function"==typeof r?r(s):r:s.type.spec.leafText?s.type.spec.leafText(s):"":"";s.isBlock&&(s.isLeaf&&l||s.isTextblock)&&n&&(i?i=!1:o+=n),o+=l}),0),o}append(t){if(!t.size)return this;if(!this.size)return t;let e=this.lastChild,n=t.firstChild,r=this.content.slice(),o=0;for(e.isText&&e.sameMarkup(n)&&(r[r.length-1]=e.withText(e.text+n.text),o=1);o<t.content.length;o++)r.push(t.content[o]);return new R(r,this.size+t.size)}cut(t,e=this.size){if(0==t&&e==this.size)return this;let n=[],r=0;if(e>t)for(let o=0,i=0;i<e;o++){let s=this.content[o],a=i+s.nodeSize;a>t&&((i<t||a>e)&&(s=s.isText?s.cut(Math.max(0,t-i),Math.min(s.text.length,e-i)):s.cut(Math.max(0,t-i-1),Math.min(s.content.size,e-i-1))),n.push(s),r+=s.nodeSize),i=a}return new R(n,r)}cutByIndex(t,e){return t==e?R.empty:0==t&&e==this.content.length?this:new R(this.content.slice(t,e))}replaceChild(t,e){let n=this.content[t];if(n==e)return this;let r=this.content.slice(),o=this.size+e.nodeSize-n.nodeSize;return r[t]=e,new R(r,o)}addToStart(t){return new R([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new R(this.content.concat(t),this.size+t.nodeSize)}eq(t){if(this.content.length!=t.content.length)return!1;for(let e=0;e<this.content.length;e++)if(!this.content[e].eq(t.content[e]))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(t){let e=this.content[t];if(!e)throw new RangeError("Index "+t+" out of range for "+this);return e}maybeChild(t){return this.content[t]||null}forEach(t){for(let e=0,n=0;e<this.content.length;e++){let r=this.content[e];t(r,n,e),n+=r.nodeSize}}findDiffStart(t,e=0){return A(this,t,e)}findDiffEnd(t,e=this.size,n=t.size){return D(this,t,e,n)}findIndex(t,e=-1){if(0==t)return L(0,t);if(t==this.size)return L(this.content.length,t);if(t>this.size||t<0)throw new RangeError(`Position ${t} outside of fragment (${this})`);for(let n=0,r=0;;n++){let o=r+this.child(n).nodeSize;if(o>=t)return o==t||e>0?L(n+1,o):L(n,r);r=o}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map((t=>t.toJSON())):null}static fromJSON(t,e){if(!e)return R.empty;if(!Array.isArray(e))throw new RangeError("Invalid input for Fragment.fromJSON");return new R(e.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return R.empty;let e,n=0;for(let r=0;r<t.length;r++){let o=t[r];n+=o.nodeSize,r&&o.isText&&t[r-1].sameMarkup(o)?(e||(e=t.slice(0,r)),e[e.length-1]=o.withText(e[e.length-1].text+o.text)):e&&e.push(o)}return new R(e||t,n)}static from(t){if(!t)return R.empty;if(t instanceof R)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new R([t],t.nodeSize);throw new RangeError("Can not convert "+t+" to a Fragment"+(t.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}R.empty=new R([],0);const I={index:0,offset:0};function L(t,e){return I.index=t,I.offset=e,I}function P(t,e){if(t===e)return!0;if(!t||"object"!=typeof t||!e||"object"!=typeof e)return!1;let n=Array.isArray(t);if(Array.isArray(e)!=n)return!1;if(n){if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++)if(!P(t[n],e[n]))return!1}else{for(let n in t)if(!(n in e)||!P(t[n],e[n]))return!1;for(let n in e)if(!(n in t))return!1}return!0}let j=class t{constructor(t,e){this.type=t,this.attrs=e}addToSet(t){let e,n=!1;for(let r=0;r<t.length;r++){let o=t[r];if(this.eq(o))return t;if(this.type.excludes(o.type))e||(e=t.slice(0,r));else{if(o.type.excludes(this.type))return t;!n&&o.type.rank>this.type.rank&&(e||(e=t.slice(0,r)),e.push(this),n=!0),e&&e.push(o)}}return e||(e=t.slice()),n||e.push(this),e}removeFromSet(t){for(let e=0;e<t.length;e++)if(this.eq(t[e]))return t.slice(0,e).concat(t.slice(e+1));return t}isInSet(t){for(let e=0;e<t.length;e++)if(this.eq(t[e]))return!0;return!1}eq(t){return this==t||this.type==t.type&&P(this.attrs,t.attrs)}toJSON(){let t={type:this.type.name};for(let e in this.attrs){t.attrs=this.attrs;break}return t}static fromJSON(t,e){if(!e)throw new RangeError("Invalid input for Mark.fromJSON");let n=t.marks[e.type];if(!n)throw new RangeError(`There is no mark type ${e.type} in this schema`);let r=n.create(e.attrs);return n.checkAttrs(r.attrs),r}static sameSet(t,e){if(t==e)return!0;if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++)if(!t[n].eq(e[n]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&0==e.length)return t.none;if(e instanceof t)return[e];let n=e.slice();return n.sort(((t,e)=>t.type.rank-e.type.rank)),n}};j.none=[];class z extends Error{}class ${constructor(t,e,n){this.content=t,this.openStart=e,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(t,e){let n=F(this.content,t+this.openStart,e);return n&&new $(n,this.openStart,this.openEnd)}removeBetween(t,e){return new $(B(this.content,t+this.openStart,e+this.openStart),this.openStart,this.openEnd)}eq(t){return this.content.eq(t.content)&&this.openStart==t.openStart&&this.openEnd==t.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let t={content:this.content.toJSON()};return this.openStart>0&&(t.openStart=this.openStart),this.openEnd>0&&(t.openEnd=this.openEnd),t}static fromJSON(t,e){if(!e)return $.empty;let n=e.openStart||0,r=e.openEnd||0;if("number"!=typeof n||"number"!=typeof r)throw new RangeError("Invalid input for Slice.fromJSON");return new $(R.fromJSON(t,e.content),n,r)}static maxOpen(t,e=!0){let n=0,r=0;for(let r=t.firstChild;r&&!r.isLeaf&&(e||!r.type.spec.isolating);r=r.firstChild)n++;for(let n=t.lastChild;n&&!n.isLeaf&&(e||!n.type.spec.isolating);n=n.lastChild)r++;return new $(t,n,r)}}function B(t,e,n){let{index:r,offset:o}=t.findIndex(e),i=t.maybeChild(r),{index:s,offset:a}=t.findIndex(n);if(o==e||i.isText){if(a!=n&&!t.child(s).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(r!=s)throw new RangeError("Removing non-flat range");return t.replaceChild(r,i.copy(B(i.content,e-o-1,n-o-1)))}function F(t,e,n,r){let{index:o,offset:i}=t.findIndex(e),s=t.maybeChild(o);if(i==e||s.isText)return r&&!r.canReplace(o,o,n)?null:t.cut(0,e).append(n).append(t.cut(e));let a=F(s.content,e-i-1,n);return a&&t.replaceChild(o,s.copy(a))}function _(t,e,n){if(n.openStart>t.depth)throw new z("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new z("Inconsistent open depths");return V(t,e,n,0)}function V(t,e,n,r){let o=t.index(r),i=t.node(r);if(o==e.index(r)&&r<t.depth-n.openStart){let s=V(t,e,n,r+1);return i.copy(i.content.replaceChild(o,s))}if(n.content.size){if(n.openStart||n.openEnd||t.depth!=r||e.depth!=r){let{start:o,end:s}=function(t,e){let n=e.depth-t.openStart,r=e.node(n).copy(t.content);for(let t=n-1;t>=0;t--)r=e.node(t).copy(R.from(r));return{start:r.resolveNoCache(t.openStart+n),end:r.resolveNoCache(r.content.size-t.openEnd-n)}}(n,t);return J(i,U(t,o,s,e,r))}{let r=t.parent,o=r.content;return J(r,o.cut(0,t.parentOffset).append(n.content).append(o.cut(e.parentOffset)))}}return J(i,G(t,e,r))}function H(t,e){if(!e.type.compatibleContent(t.type))throw new z("Cannot join "+e.type.name+" onto "+t.type.name)}function W(t,e,n){let r=t.node(n);return H(r,e.node(n)),r}function K(t,e){let n=e.length-1;n>=0&&t.isText&&t.sameMarkup(e[n])?e[n]=t.withText(e[n].text+t.text):e.push(t)}function q(t,e,n,r){let o=(e||t).node(n),i=0,s=e?e.index(n):o.childCount;t&&(i=t.index(n),t.depth>n?i++:t.textOffset&&(K(t.nodeAfter,r),i++));for(let t=i;t<s;t++)K(o.child(t),r);e&&e.depth==n&&e.textOffset&&K(e.nodeBefore,r)}function J(t,e){return t.type.checkContent(e),t.copy(e)}function U(t,e,n,r,o){let i=t.depth>o&&W(t,e,o+1),s=r.depth>o&&W(n,r,o+1),a=[];return q(null,t,o,a),i&&s&&e.index(o)==n.index(o)?(H(i,s),K(J(i,U(t,e,n,r,o+1)),a)):(i&&K(J(i,G(t,e,o+1)),a),q(e,n,o,a),s&&K(J(s,G(n,r,o+1)),a)),q(r,null,o,a),new R(a)}function G(t,e,n){let r=[];if(q(null,t,n,r),t.depth>n){K(J(W(t,e,n+1),G(t,e,n+1)),r)}return q(e,null,n,r),new R(r)}$.empty=new $(R.empty,0,0);class Y{constructor(t,e,n){this.pos=t,this.path=e,this.parentOffset=n,this.depth=e.length/3-1}resolveDepth(t){return null==t?this.depth:t<0?this.depth+t:t}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(t){return this.path[3*this.resolveDepth(t)]}index(t){return this.path[3*this.resolveDepth(t)+1]}indexAfter(t){return t=this.resolveDepth(t),this.index(t)+(t!=this.depth||this.textOffset?1:0)}start(t){return 0==(t=this.resolveDepth(t))?0:this.path[3*t-1]+1}end(t){return t=this.resolveDepth(t),this.start(t)+this.node(t).content.size}before(t){if(!(t=this.resolveDepth(t)))throw new RangeError("There is no position before the top-level node");return t==this.depth+1?this.pos:this.path[3*t-1]}after(t){if(!(t=this.resolveDepth(t)))throw new RangeError("There is no position after the top-level node");return t==this.depth+1?this.pos:this.path[3*t-1]+this.path[3*t].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let t=this.parent,e=this.index(this.depth);if(e==t.childCount)return null;let n=this.pos-this.path[this.path.length-1],r=t.child(e);return n?t.child(e).cut(n):r}get nodeBefore(){let t=this.index(this.depth),e=this.pos-this.path[this.path.length-1];return e?this.parent.child(t).cut(0,e):0==t?null:this.parent.child(t-1)}posAtIndex(t,e){e=this.resolveDepth(e);let n=this.path[3*e],r=0==e?0:this.path[3*e-1]+1;for(let e=0;e<t;e++)r+=n.child(e).nodeSize;return r}marks(){let t=this.parent,e=this.index();if(0==t.content.size)return j.none;if(this.textOffset)return t.child(e).marks;let n=t.maybeChild(e-1),r=t.maybeChild(e);if(!n){let t=n;n=r,r=t}let o=n.marks;for(var i=0;i<o.length;i++)!1===o[i].type.spec.inclusive&&(!r||!o[i].isInSet(r.marks))&&(o=o[i--].removeFromSet(o));return o}marksAcross(t){let e=this.parent.maybeChild(this.index());if(!e||!e.isInline)return null;let n=e.marks,r=t.parent.maybeChild(t.index());for(var o=0;o<n.length;o++)!1===n[o].type.spec.inclusive&&(!r||!n[o].isInSet(r.marks))&&(n=n[o--].removeFromSet(n));return n}sharedDepth(t){for(let e=this.depth;e>0;e--)if(this.start(e)<=t&&this.end(e)>=t)return e;return 0}blockRange(t=this,e){if(t.pos<this.pos)return t.blockRange(this);for(let n=this.depth-(this.parent.inlineContent||this.pos==t.pos?1:0);n>=0;n--)if(t.pos<=this.end(n)&&(!e||e(this.node(n))))return new tt(this,t,n);return null}sameParent(t){return this.pos-this.parentOffset==t.pos-t.parentOffset}max(t){return t.pos>this.pos?t:this}min(t){return t.pos<this.pos?t:this}toString(){let t="";for(let e=1;e<=this.depth;e++)t+=(t?"/":"")+this.node(e).type.name+"_"+this.index(e-1);return t+":"+this.parentOffset}static resolve(t,e){if(!(e>=0&&e<=t.content.size))throw new RangeError("Position "+e+" out of range");let n=[],r=0,o=e;for(let e=t;;){let{index:t,offset:i}=e.content.findIndex(o),s=o-i;if(n.push(e,t,r+i),!s||(e=e.child(t),e.isText))break;o=s-1,r+=i+1}return new Y(e,n,o)}static resolveCached(t,e){let n=Z.get(t);if(n)for(let t=0;t<n.elts.length;t++){let r=n.elts[t];if(r.pos==e)return r}else Z.set(t,n=new Q);let r=n.elts[n.i]=Y.resolve(t,e);return n.i=(n.i+1)%X,r}}class Q{constructor(){this.elts=[],this.i=0}}const X=12,Z=new WeakMap;class tt{constructor(t,e,n){this.$from=t,this.$to=e,this.depth=n}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 et=Object.create(null);let nt=class t{constructor(t,e,n,r=j.none){this.type=t,this.attrs=e,this.marks=r,this.content=n||R.empty}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(t){return this.content.child(t)}maybeChild(t){return this.content.maybeChild(t)}forEach(t){this.content.forEach(t)}nodesBetween(t,e,n,r=0){this.content.nodesBetween(t,e,n,r,this)}descendants(t){this.nodesBetween(0,this.content.size,t)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(t,e,n,r){return this.content.textBetween(t,e,n,r)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(t){return this==t||this.sameMarkup(t)&&this.content.eq(t.content)}sameMarkup(t){return this.hasMarkup(t.type,t.attrs,t.marks)}hasMarkup(t,e,n){return this.type==t&&P(this.attrs,e||t.defaultAttrs||et)&&j.sameSet(this.marks,n||j.none)}copy(e=null){return e==this.content?this:new t(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new t(this.type,this.attrs,this.content,e)}cut(t,e=this.content.size){return 0==t&&e==this.content.size?this:this.copy(this.content.cut(t,e))}slice(t,e=this.content.size,n=!1){if(t==e)return $.empty;let r=this.resolve(t),o=this.resolve(e),i=n?0:r.sharedDepth(e),s=r.start(i),a=r.node(i).content.cut(r.pos-s,o.pos-s);return new $(a,r.depth-i,o.depth-i)}replace(t,e,n){return _(this.resolve(t),this.resolve(e),n)}nodeAt(t){for(let e=this;;){let{index:n,offset:r}=e.content.findIndex(t);if(e=e.maybeChild(n),!e)return null;if(r==t||e.isText)return e;t-=r+1}}childAfter(t){let{index:e,offset:n}=this.content.findIndex(t);return{node:this.content.maybeChild(e),index:e,offset:n}}childBefore(t){if(0==t)return{node:null,index:0,offset:0};let{index:e,offset:n}=this.content.findIndex(t);if(n<t)return{node:this.content.child(e),index:e,offset:n};let r=this.content.child(e-1);return{node:r,index:e-1,offset:n-r.nodeSize}}resolve(t){return Y.resolveCached(this,t)}resolveNoCache(t){return Y.resolve(this,t)}rangeHasMark(t,e,n){let r=!1;return e>t&&this.nodesBetween(t,e,(t=>(n.isInSet(t.marks)&&(r=!0),!r))),r}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 t=this.type.name;return this.content.size&&(t+="("+this.content.toStringInner()+")"),ot(this.marks,t)}contentMatchAt(t){let e=this.type.contentMatch.matchFragment(this.content,0,t);if(!e)throw new Error("Called contentMatchAt on a node with invalid content");return e}canReplace(t,e,n=R.empty,r=0,o=n.childCount){let i=this.contentMatchAt(t).matchFragment(n,r,o),s=i&&i.matchFragment(this.content,e);if(!s||!s.validEnd)return!1;for(let t=r;t<o;t++)if(!this.type.allowsMarks(n.child(t).marks))return!1;return!0}canReplaceWith(t,e,n,r){if(r&&!this.type.allowsMarks(r))return!1;let o=this.contentMatchAt(t).matchType(n),i=o&&o.matchFragment(this.content,e);return!!i&&i.validEnd}canAppend(t){return t.content.size?this.canReplace(this.childCount,this.childCount,t.content):this.type.compatibleContent(t.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let t=j.none;for(let e=0;e<this.marks.length;e++){let n=this.marks[e];n.type.checkAttrs(n.attrs),t=n.addToSet(t)}if(!j.sameSet(t,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 t={type:this.type.name};for(let e in this.attrs){t.attrs=this.attrs;break}return this.content.size&&(t.content=this.content.toJSON()),this.marks.length&&(t.marks=this.marks.map((t=>t.toJSON()))),t}static fromJSON(t,e){if(!e)throw new RangeError("Invalid input for Node.fromJSON");let n;if(e.marks){if(!Array.isArray(e.marks))throw new RangeError("Invalid mark data for Node.fromJSON");n=e.marks.map(t.markFromJSON)}if("text"==e.type){if("string"!=typeof e.text)throw new RangeError("Invalid text node in JSON");return t.text(e.text,n)}let r=R.fromJSON(t,e.content),o=t.nodeType(e.type).create(e.attrs,r,n);return o.type.checkAttrs(o.attrs),o}};nt.prototype.text=void 0;class rt extends nt{constructor(t,e,n,r){if(super(t,e,null,r),!n)throw new RangeError("Empty text nodes are not allowed");this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):ot(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(t,e){return this.text.slice(t,e)}get nodeSize(){return this.text.length}mark(t){return t==this.marks?this:new rt(this.type,this.attrs,this.text,t)}withText(t){return t==this.text?this:new rt(this.type,this.attrs,t,this.marks)}cut(t=0,e=this.text.length){return 0==t&&e==this.text.length?this:this.withText(this.text.slice(t,e))}eq(t){return this.sameMarkup(t)&&this.text==t.text}toJSON(){let t=super.toJSON();return t.text=this.text,t}}function ot(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class it{constructor(t){this.validEnd=t,this.next=[],this.wrapCache=[]}static parse(t,e){let n=new st(t,e);if(null==n.next)return it.empty;let r=at(n);n.next&&n.err("Unexpected trailing text");let o=function(t){let e=Object.create(null);return n(pt(t,0));function n(r){let o=[];r.forEach((e=>{t[e].forEach((({term:e,to:n})=>{if(!e)return;let r;for(let t=0;t<o.length;t++)o[t][0]==e&&(r=o[t][1]);pt(t,n).forEach((t=>{r||o.push([e,r=[]]),-1==r.indexOf(t)&&r.push(t)}))}))}));let i=e[r.join(",")]=new it(r.indexOf(t.length-1)>-1);for(let t=0;t<o.length;t++){let r=o[t][1].sort(ut);i.next.push({type:o[t][0],next:e[r.join(",")]||n(r)})}return i}}(function(t){let e=[[]];return o(i(t,0),n()),e;function n(){return e.push([])-1}function r(t,n,r){let o={term:r,to:n};return e[t].push(o),o}function o(t,e){t.forEach((t=>t.to=e))}function i(t,e){if("choice"==t.type)return t.exprs.reduce(((t,n)=>t.concat(i(n,e))),[]);if("seq"!=t.type){if("star"==t.type){let s=n();return r(e,s),o(i(t.expr,s),s),[r(s)]}if("plus"==t.type){let s=n();return o(i(t.expr,e),s),o(i(t.expr,s),s),[r(s)]}if("opt"==t.type)return[r(e)].concat(i(t.expr,e));if("range"==t.type){let s=e;for(let e=0;e<t.min;e++){let e=n();o(i(t.expr,s),e),s=e}if(-1==t.max)o(i(t.expr,s),s);else for(let e=t.min;e<t.max;e++){let e=n();r(s,e),o(i(t.expr,s),e),s=e}return[r(s)]}if("name"==t.type)return[r(e,void 0,t.value)];throw new Error("Unknown expr type")}for(let r=0;;r++){let s=i(t.exprs[r],e);if(r==t.exprs.length-1)return s;o(s,e=n())}}}(r));return function(t,e){for(let n=0,r=[t];n<r.length;n++){let t=r[n],o=!t.validEnd,i=[];for(let e=0;e<t.next.length;e++){let{type:n,next:s}=t.next[e];i.push(n.name),o&&!(n.isText||n.hasRequiredAttrs())&&(o=!1),-1==r.indexOf(s)&&r.push(s)}o&&e.err("Only non-generatable nodes ("+i.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}(o,n),o}matchType(t){for(let e=0;e<this.next.length;e++)if(this.next[e].type==t)return this.next[e].next;return null}matchFragment(t,e=0,n=t.childCount){let r=this;for(let o=e;r&&o<n;o++)r=r.matchType(t.child(o).type);return r}get inlineContent(){return 0!=this.next.length&&this.next[0].type.isInline}get defaultType(){for(let t=0;t<this.next.length;t++){let{type:e}=this.next[t];if(!e.isText&&!e.hasRequiredAttrs())return e}return null}compatible(t){for(let e=0;e<this.next.length;e++)for(let n=0;n<t.next.length;n++)if(this.next[e].type==t.next[n].type)return!0;return!1}fillBefore(t,e=!1,n=0){let r=[this];return function o(i,s){let a=i.matchFragment(t,n);if(a&&(!e||a.validEnd))return R.from(s.map((t=>t.createAndFill())));for(let t=0;t<i.next.length;t++){let{type:e,next:n}=i.next[t];if(!e.isText&&!e.hasRequiredAttrs()&&-1==r.indexOf(n)){r.push(n);let t=o(n,s.concat(e));if(t)return t}}return null}(this,[])}findWrapping(t){for(let e=0;e<this.wrapCache.length;e+=2)if(this.wrapCache[e]==t)return this.wrapCache[e+1];let e=this.computeWrapping(t);return this.wrapCache.push(t,e),e}computeWrapping(t){let e=Object.create(null),n=[{match:this,type:null,via:null}];for(;n.length;){let r=n.shift(),o=r.match;if(o.matchType(t)){let t=[];for(let e=r;e.type;e=e.via)t.push(e.type);return t.reverse()}for(let t=0;t<o.next.length;t++){let{type:i,next:s}=o.next[t];!i.isLeaf&&!i.hasRequiredAttrs()&&!(i.name in e)&&(!r.type||s.validEnd)&&(n.push({match:i.contentMatch,type:i,via:r}),e[i.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(t){if(t>=this.next.length)throw new RangeError(`There's no ${t}th edge in this content match`);return this.next[t]}toString(){let t=[];return function e(n){t.push(n);for(let r=0;r<n.next.length;r++)-1==t.indexOf(n.next[r].next)&&e(n.next[r].next)}(this),t.map(((e,n)=>{let r=n+(e.validEnd?"*":" ")+" ";for(let n=0;n<e.next.length;n++)r+=(n?", ":"")+e.next[n].type.name+"->"+t.indexOf(e.next[n].next);return r})).join("\n")}}it.empty=new it(!0);class st{constructor(t,e){this.string=t,this.nodeTypes=e,this.inline=null,this.pos=0,this.tokens=t.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(t){return this.next==t&&(this.pos++||!0)}err(t){throw new SyntaxError(t+" (in content expression '"+this.string+"')")}}function at(t){let e=[];do{e.push(lt(t))}while(t.eat("|"));return 1==e.length?e[0]:{type:"choice",exprs:e}}function lt(t){let e=[];do{e.push(ct(t))}while(t.next&&")"!=t.next&&"|"!=t.next);return 1==e.length?e[0]:{type:"seq",exprs:e}}function ct(t){let e=function(t){if(t.eat("(")){let e=at(t);return t.eat(")")||t.err("Missing closing paren"),e}if(!/\W/.test(t.next)){let e=function(t,e){let n=t.nodeTypes,r=n[e];if(r)return[r];let o=[];for(let t in n){let r=n[t];r.groups.indexOf(e)>-1&&o.push(r)}return 0==o.length&&t.err("No node type or group '"+e+"' found"),o}(t,t.next).map((e=>(null==t.inline?t.inline=e.isInline:t.inline!=e.isInline&&t.err("Mixing inline and block content"),{type:"name",value:e})));return t.pos++,1==e.length?e[0]:{type:"choice",exprs:e}}t.err("Unexpected token '"+t.next+"'")}(t);for(;;)if(t.eat("+"))e={type:"plus",expr:e};else if(t.eat("*"))e={type:"star",expr:e};else if(t.eat("?"))e={type:"opt",expr:e};else{if(!t.eat("{"))break;e=ht(t,e)}return e}function dt(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function ht(t,e){let n=dt(t),r=n;return t.eat(",")&&(r="}"!=t.next?dt(t):-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function ut(t,e){return e-t}function pt(t,e){let n=[];return function e(r){let o=t[r];if(1==o.length&&!o[0].term)return e(o[0].to);n.push(r);for(let t=0;t<o.length;t++){let{term:r,to:i}=o[t];!r&&-1==n.indexOf(i)&&e(i)}}(e),n.sort(ut)}function ft(t){let e=Object.create(null);for(let n in t){let r=t[n];if(!r.hasDefault)return null;e[n]=r.default}return e}function mt(t,e){let n=Object.create(null);for(let r in t){let o=e&&e[r];if(void 0===o){let e=t[r];if(!e.hasDefault)throw new RangeError("No value supplied for attribute "+r);o=e.default}n[r]=o}return n}function gt(t,e,n,r){for(let r in e)if(!(r in t))throw new RangeError(`Unsupported attribute ${r} for ${n} of type ${r}`);for(let n in t){let r=t[n];r.validate&&r.validate(e[n])}}function yt(t,e){let n=Object.create(null);if(e)for(let r in e)n[r]=new vt(t,r,e[r]);return n}let bt=class t{constructor(t,e,n){this.name=t,this.schema=e,this.spec=n,this.markSet=null,this.groups=n.group?n.group.split(" "):[],this.attrs=yt(t,n.attrs),this.defaultAttrs=ft(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(n.inline||"text"==t),this.isText="text"==t}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==it.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let t in this.attrs)if(this.attrs[t].isRequired)return!0;return!1}compatibleContent(t){return this==t||this.contentMatch.compatible(t.contentMatch)}computeAttrs(t){return!t&&this.defaultAttrs?this.defaultAttrs:mt(this.attrs,t)}create(t=null,e,n){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new nt(this,this.computeAttrs(t),R.from(e),j.setFrom(n))}createChecked(t=null,e,n){return e=R.from(e),this.checkContent(e),new nt(this,this.computeAttrs(t),e,j.setFrom(n))}createAndFill(t=null,e,n){if(t=this.computeAttrs(t),(e=R.from(e)).size){let t=this.contentMatch.fillBefore(e);if(!t)return null;e=t.append(e)}let r=this.contentMatch.matchFragment(e),o=r&&r.fillBefore(R.empty,!0);return o?new nt(this,t,e.append(o),j.setFrom(n)):null}validContent(t){let e=this.contentMatch.matchFragment(t);if(!e||!e.validEnd)return!1;for(let e=0;e<t.childCount;e++)if(!this.allowsMarks(t.child(e).marks))return!1;return!0}checkContent(t){if(!this.validContent(t))throw new RangeError(`Invalid content for node ${this.name}: ${t.toString().slice(0,50)}`)}checkAttrs(t){gt(this.attrs,t,"node",this.name)}allowsMarkType(t){return null==this.markSet||this.markSet.indexOf(t)>-1}allowsMarks(t){if(null==this.markSet)return!0;for(let e=0;e<t.length;e++)if(!this.allowsMarkType(t[e].type))return!1;return!0}allowedMarks(t){if(null==this.markSet)return t;let e;for(let n=0;n<t.length;n++)this.allowsMarkType(t[n].type)?e&&e.push(t[n]):e||(e=t.slice(0,n));return e?e.length?e:j.none:t}static compile(e,n){let r=Object.create(null);e.forEach(((e,o)=>r[e]=new t(e,n,o)));let o=n.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 t in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};class vt{constructor(t,e,n){this.hasDefault=Object.prototype.hasOwnProperty.call(n,"default"),this.default=n.default,this.validate="string"==typeof n.validate?function(t,e,n){let r=n.split("|");return n=>{let o=null===n?"null":typeof n;if(r.indexOf(o)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${t}, got ${o}`)}}(t,e,n.validate):n.validate}get isRequired(){return!this.hasDefault}}class wt{constructor(t,e,n,r){this.name=t,this.rank=e,this.schema=n,this.spec=r,this.attrs=yt(t,r.attrs),this.excluded=null;let o=ft(this.attrs);this.instance=o?new j(this,o):null}create(t=null){return!t&&this.instance?this.instance:new j(this,mt(this.attrs,t))}static compile(t,e){let n=Object.create(null),r=0;return t.forEach(((t,o)=>n[t]=new wt(t,r++,e,o))),n}removeFromSet(t){for(var e=0;e<t.length;e++)t[e].type==this&&(t=t.slice(0,e).concat(t.slice(e+1)),e--);return t}isInSet(t){for(let e=0;e<t.length;e++)if(t[e].type==this)return t[e]}checkAttrs(t){gt(this.attrs,t,"mark",this.name)}excludes(t){return this.excluded.indexOf(t)>-1}}class kt{constructor(t){this.linebreakReplacement=null,this.cached=Object.create(null);let e=this.spec={};for(let n in t)e[n]=t[n];e.nodes=N.from(t.nodes),e.marks=N.from(t.marks||{}),this.nodes=bt.compile(this.spec.nodes,this),this.marks=wt.compile(this.spec.marks,this);let n=Object.create(null);for(let t in this.nodes){if(t in this.marks)throw new RangeError(t+" can not be both a node and a mark");let e=this.nodes[t],r=e.spec.content||"",o=e.spec.marks;if(e.contentMatch=n[r]||(n[r]=it.parse(r,this.nodes)),e.inlineContent=e.contentMatch.inlineContent,e.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!e.isInline||!e.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=e}e.markSet="_"==o?null:o?xt(this,o.split(" ")):""!=o&&e.inlineContent?null:[]}for(let t in this.marks){let e=this.marks[t],n=e.spec.excludes;e.excluded=null==n?[e]:""==n?[]:xt(this,n.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(t,e=null,n,r){if("string"==typeof t)t=this.nodeType(t);else{if(!(t instanceof bt))throw new RangeError("Invalid node type: "+t);if(t.schema!=this)throw new RangeError("Node type from different schema used ("+t.name+")")}return t.createChecked(e,n,r)}text(t,e){let n=this.nodes.text;return new rt(n,n.defaultAttrs,t,j.setFrom(e))}mark(t,e){return"string"==typeof t&&(t=this.marks[t]),t.create(e)}nodeFromJSON(t){return nt.fromJSON(this,t)}markFromJSON(t){return j.fromJSON(this,t)}nodeType(t){let e=this.nodes[t];if(!e)throw new RangeError("Unknown node type: "+t);return e}}function xt(t,e){let n=[];for(let r=0;r<e.length;r++){let o=e[r],i=t.marks[o],s=i;if(i)n.push(i);else for(let e in t.marks){let r=t.marks[e];("_"==o||r.spec.group&&r.spec.group.split(" ").indexOf(o)>-1)&&n.push(s=r)}if(!s)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return n}class St{constructor(t,e){this.schema=t,this.rules=e,this.tags=[],this.styles=[];let n=this.matchedStyles=[];e.forEach((t=>{if(null!=t.tag)this.tags.push(t);else if(function(t){return null!=t.style}(t)){let e=/[^=]*/.exec(t.style)[0];n.indexOf(e)<0&&n.push(e),this.styles.push(t)}})),this.normalizeLists=!this.tags.some((e=>{if(!/^(ul|ol)\b/.test(e.tag)||!e.node)return!1;let n=t.nodes[e.node];return n.contentMatch.matchType(n)}))}parse(t,e={}){let n=new Nt(this,e,!1);return n.addAll(t,j.none,e.from,e.to),n.finish()}parseSlice(t,e={}){let n=new Nt(this,e,!0);return n.addAll(t,j.none,e.from,e.to),$.maxOpen(n.finish())}matchTag(t,e,n){for(let r=n?this.tags.indexOf(n)+1:0;r<this.tags.length;r++){let n=this.tags[r];if(At(t,n.tag)&&(void 0===n.namespace||t.namespaceURI==n.namespace)&&(!n.context||e.matchesContext(n.context))){if(n.getAttrs){let e=n.getAttrs(t);if(!1===e)continue;n.attrs=e||void 0}return n}}}matchStyle(t,e,n,r){for(let o=r?this.styles.indexOf(r)+1:0;o<this.styles.length;o++){let r=this.styles[o],i=r.style;if(!(0!=i.indexOf(t)||r.context&&!n.matchesContext(r.context)||i.length>t.length&&(61!=i.charCodeAt(t.length)||i.slice(t.length+1)!=e))){if(r.getAttrs){let t=r.getAttrs(e);if(!1===t)continue;r.attrs=t||void 0}return r}}}static schemaRules(t){let e=[];function n(t){let n=null==t.priority?50:t.priority,r=0;for(;r<e.length;r++){let t=e[r];if((null==t.priority?50:t.priority)<n)break}e.splice(r,0,t)}for(let e in t.marks){let r=t.marks[e].spec.parseDOM;r&&r.forEach((t=>{n(t=Dt(t)),t.mark||t.ignore||t.clearMark||(t.mark=e)}))}for(let e in t.nodes){let r=t.nodes[e].spec.parseDOM;r&&r.forEach((t=>{n(t=Dt(t)),t.node||t.ignore||t.mark||(t.node=e)}))}return e}static fromSchema(t){return t.cached.domParser||(t.cached.domParser=new St(t,St.schemaRules(t)))}}const Ot={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},Ct={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Mt={ol:!0,ul:!0};function Tt(t,e,n){return null!=e?(e?1:0)|("full"===e?2:0):t&&"pre"==t.whitespace?3:-5&n}class Et{constructor(t,e,n,r,o,i){this.type=t,this.attrs=e,this.marks=n,this.solid=r,this.options=i,this.content=[],this.activeMarks=j.none,this.match=o||(4&i?null:t.contentMatch)}findWrapping(t){if(!this.match){if(!this.type)return[];let e=this.type.contentMatch.fillBefore(R.from(t));if(!e){let e,n=this.type.contentMatch;return(e=n.findWrapping(t.type))?(this.match=n,e):null}this.match=this.type.contentMatch.matchFragment(e)}return this.match.findWrapping(t.type)}finish(t){if(!(1&this.options)){let t,e=this.content[this.content.length-1];if(e&&e.isText&&(t=/[ \t\r\n\u000c]+$/.exec(e.text))){let n=e;e.text.length==t[0].length?this.content.pop():this.content[this.content.length-1]=n.withText(n.text.slice(0,n.text.length-t[0].length))}}let e=R.from(this.content);return!t&&this.match&&(e=e.append(this.match.fillBefore(R.empty,!0))),this.type?this.type.create(this.attrs,e,this.marks):e}inlineContext(t){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:t.parentNode&&!Ot.hasOwnProperty(t.parentNode.nodeName.toLowerCase())}}class Nt{constructor(t,e,n){this.parser=t,this.options=e,this.isOpen=n,this.open=0;let r,o=e.topNode,i=Tt(null,e.preserveWhitespace,0)|(n?4:0);r=o?new Et(o.type,o.attrs,j.none,!0,e.topMatch||o.type.contentMatch,i):new Et(n?null:t.schema.topNodeType,null,j.none,!0,null,i),this.nodes=[r],this.find=e.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(t,e){3==t.nodeType?this.addTextNode(t,e):1==t.nodeType&&this.addElement(t,e)}addTextNode(t,e){let n=t.nodeValue,r=this.top;if(2&r.options||r.inlineContext(t)||/[^ \t\r\n\u000c]/.test(n)){if(1&r.options)n=2&r.options?n.replace(/\r\n?/g,"\n"):n.replace(/\r?\n|\r/g," ");else if(n=n.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(n)&&this.open==this.nodes.length-1){let e=r.content[r.content.length-1],o=t.previousSibling;(!e||o&&"BR"==o.nodeName||e.isText&&/[ \t\r\n\u000c]$/.test(e.text))&&(n=n.slice(1))}n&&this.insertNode(this.parser.schema.text(n),e),this.findInText(t)}else this.findInside(t)}addElement(t,e,n){let r,o=t.nodeName.toLowerCase();Mt.hasOwnProperty(o)&&this.parser.normalizeLists&&function(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let t=1==e.nodeType?e.nodeName.toLowerCase():null;t&&Mt.hasOwnProperty(t)&&n?(n.appendChild(e),e=n):"li"==t?n=e:t&&(n=null)}}(t);let i=this.options.ruleFromNode&&this.options.ruleFromNode(t)||(r=this.parser.matchTag(t,this,n));if(i?i.ignore:Ct.hasOwnProperty(o))this.findInside(t),this.ignoreFallback(t,e);else if(!i||i.skip||i.closeParent){i&&i.closeParent?this.open=Math.max(0,this.open-1):i&&i.skip.nodeType&&(t=i.skip);let n,r=this.top,s=this.needsBlock;if(Ot.hasOwnProperty(o))r.content.length&&r.content[0].isInline&&this.open&&(this.open--,r=this.top),n=!0,r.type||(this.needsBlock=!0);else if(!t.firstChild)return void this.leafFallback(t,e);let a=i&&i.skip?e:this.readStyles(t,e);a&&this.addAll(t,a),n&&this.sync(r),this.needsBlock=s}else{let n=this.readStyles(t,e);n&&this.addElementByRule(t,i,n,!1===i.consuming?r:void 0)}}leafFallback(t,e){"BR"==t.nodeName&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(t.ownerDocument.createTextNode("\n"),e)}ignoreFallback(t,e){"BR"==t.nodeName&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),e)}readStyles(t,e){let n=t.style;if(n&&n.length)for(let t=0;t<this.parser.matchedStyles.length;t++){let r=this.parser.matchedStyles[t],o=n.getPropertyValue(r);if(o)for(let t;;){let n=this.parser.matchStyle(r,o,this,t);if(!n)break;if(n.ignore)return null;if(e=n.clearMark?e.filter((t=>!n.clearMark(t))):e.concat(this.parser.schema.marks[n.mark].create(n.attrs)),!1!==n.consuming)break;t=n}}return e}addElementByRule(t,e,n,r){let o,i;if(e.node)if(i=this.parser.schema.nodes[e.node],i.isLeaf)this.insertNode(i.create(e.attrs),n)||this.leafFallback(t,n);else{let t=this.enter(i,e.attrs||null,n,e.preserveWhitespace);t&&(o=!0,n=t)}else{let t=this.parser.schema.marks[e.mark];n=n.concat(t.create(e.attrs))}let s=this.top;if(i&&i.isLeaf)this.findInside(t);else if(r)this.addElement(t,n,r);else if(e.getContent)this.findInside(t),e.getContent(t,this.parser.schema).forEach((t=>this.insertNode(t,n)));else{let r=t;"string"==typeof e.contentElement?r=t.querySelector(e.contentElement):"function"==typeof e.contentElement?r=e.contentElement(t):e.contentElement&&(r=e.contentElement),this.findAround(t,r,!0),this.addAll(r,n)}o&&this.sync(s)&&this.open--}addAll(t,e,n,r){let o=n||0;for(let i=n?t.childNodes[n]:t.firstChild,s=null==r?null:t.childNodes[r];i!=s;i=i.nextSibling,++o)this.findAtPoint(t,o),this.addDOM(i,e);this.findAtPoint(t,o)}findPlace(t,e){let n,r;for(let e=this.open;e>=0;e--){let o=this.nodes[e],i=o.findWrapping(t);if(i&&(!n||n.length>i.length)&&(n=i,r=o,!i.length)||o.solid)break}if(!n)return null;this.sync(r);for(let t=0;t<n.length;t++)e=this.enterInner(n[t],null,e,!1);return e}insertNode(t,e){if(t.isInline&&this.needsBlock&&!this.top.type){let t=this.textblockFromContext();t&&(e=this.enterInner(t,null,e))}let n=this.findPlace(t,e);if(n){this.closeExtra();let e=this.top;e.match&&(e.match=e.match.matchType(t.type));let r=j.none;for(let o of n.concat(t.marks))(e.type?e.type.allowsMarkType(o.type):Rt(o.type,t.type))&&(r=o.addToSet(r));return e.content.push(t.mark(r)),!0}return!1}enter(t,e,n,r){let o=this.findPlace(t.create(e),n);return o&&(o=this.enterInner(t,e,n,!0,r)),o}enterInner(t,e,n,r=!1,o){this.closeExtra();let i=this.top;i.match=i.match&&i.match.matchType(t);let s=Tt(t,o,i.options);4&i.options&&0==i.content.length&&(s|=4);let a=j.none;return n=n.filter((e=>!(i.type?i.type.allowsMarkType(e.type):Rt(e.type,t))||(a=e.addToSet(a),!1))),this.nodes.push(new Et(t,e,a,r,null,s)),this.open++,n}closeExtra(t=!1){let e=this.nodes.length-1;if(e>this.open){for(;e>this.open;e--)this.nodes[e-1].content.push(this.nodes[e].finish(t));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(t){for(let e=this.open;e>=0;e--)if(this.nodes[e]==t)return this.open=e,!0;return!1}get currentPos(){this.closeExtra();let t=0;for(let e=this.open;e>=0;e--){let n=this.nodes[e].content;for(let e=n.length-1;e>=0;e--)t+=n[e].nodeSize;e&&t++}return t}findAtPoint(t,e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==t&&this.find[n].offset==e&&(this.find[n].pos=this.currentPos)}findInside(t){if(this.find)for(let e=0;e<this.find.length;e++)null==this.find[e].pos&&1==t.nodeType&&t.contains(this.find[e].node)&&(this.find[e].pos=this.currentPos)}findAround(t,e,n){if(t!=e&&this.find)for(let r=0;r<this.find.length;r++)null==this.find[r].pos&&1==t.nodeType&&t.contains(this.find[r].node)&&e.compareDocumentPosition(this.find[r].node)&(n?2:4)&&(this.find[r].pos=this.currentPos)}findInText(t){if(this.find)for(let e=0;e<this.find.length;e++)this.find[e].node==t&&(this.find[e].pos=this.currentPos-(t.nodeValue.length-this.find[e].offset))}matchesContext(t){if(t.indexOf("|")>-1)return t.split(/\s*\|\s*/).some(this.matchesContext,this);let e=t.split("/"),n=this.options.context,r=!(this.isOpen||n&&n.parent.type!=this.nodes[0].type),o=-(n?n.depth+1:0)+(r?0:1),i=(t,s)=>{for(;t>=0;t--){let a=e[t];if(""==a){if(t==e.length-1||0==t)continue;for(;s>=o;s--)if(i(t-1,s))return!0;return!1}{let t=s>0||0==s&&r?this.nodes[s].type:n&&s>=o?n.node(s-o).type:null;if(!t||t.name!=a&&-1==t.groups.indexOf(a))return!1;s--}}return!0};return i(e.length-1,this.open)}textblockFromContext(){let t=this.options.context;if(t)for(let e=t.depth;e>=0;e--){let n=t.node(e).contentMatchAt(t.indexAfter(e)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(let t in this.parser.schema.nodes){let e=this.parser.schema.nodes[t];if(e.isTextblock&&e.defaultAttrs)return e}}}function At(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function Dt(t){let e={};for(let n in t)e[n]=t[n];return e}function Rt(t,e){let n=e.schema.nodes;for(let r in n){let o=n[r];if(!o.allowsMarkType(t))continue;let i=[],s=t=>{i.push(t);for(let n=0;n<t.edgeCount;n++){let{type:r,next:o}=t.edge(n);if(r==e||i.indexOf(o)<0&&s(o))return!0}};if(s(o.contentMatch))return!0}}class It{constructor(t,e){this.nodes=t,this.marks=e}serializeFragment(t,e={},n){n||(n=Pt(e).createDocumentFragment());let r=n,o=[];return t.forEach((t=>{if(o.length||t.marks.length){let n=0,i=0;for(;n<o.length&&i<t.marks.length;){let e=t.marks[i];if(this.marks[e.type.name]){if(!e.eq(o[n][0])||!1===e.type.spec.spanning)break;n++,i++}else i++}for(;n<o.length;)r=o.pop()[1];for(;i<t.marks.length;){let n=t.marks[i++],s=this.serializeMark(n,t.isInline,e);s&&(o.push([n,r]),r.appendChild(s.dom),r=s.contentDOM||s.dom)}}r.appendChild(this.serializeNodeInner(t,e))})),n}serializeNodeInner(t,e){let{dom:n,contentDOM:r}=$t(Pt(e),this.nodes[t.type.name](t),null,t.attrs);if(r){if(t.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(t.content,e,r)}return n}serializeNode(t,e={}){let n=this.serializeNodeInner(t,e);for(let r=t.marks.length-1;r>=0;r--){let o=this.serializeMark(t.marks[r],t.isInline,e);o&&((o.contentDOM||o.dom).appendChild(n),n=o.dom)}return n}serializeMark(t,e,n={}){let r=this.marks[t.type.name];return r&&$t(Pt(n),r(t,e),null,t.attrs)}static renderSpec(t,e,n=null,r){return $t(t,e,n,r)}static fromSchema(t){return t.cached.domSerializer||(t.cached.domSerializer=new It(this.nodesFromSchema(t),this.marksFromSchema(t)))}static nodesFromSchema(t){let e=Lt(t.nodes);return e.text||(e.text=t=>t.text),e}static marksFromSchema(t){return Lt(t.marks)}}function Lt(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function Pt(t){return t.document||window.document}const jt=new WeakMap;function zt(t){let e=jt.get(t);return void 0===e&&jt.set(t,e=function(t){let e=null;function n(t){if(t&&"object"==typeof t)if(Array.isArray(t))if("string"==typeof t[0])e||(e=[]),e.push(t);else for(let e=0;e<t.length;e++)n(t[e]);else for(let e in t)n(t[e])}return n(t),e}(t)),e}function $t(t,e,n,r){if("string"==typeof e)return{dom:t.createTextNode(e)};if(null!=e.nodeType)return{dom:e};if(e.dom&&null!=e.dom.nodeType)return e;let o,i=e[0];if("string"!=typeof i)throw new RangeError("Invalid array passed to renderSpec");if(r&&(o=zt(r))&&o.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 s=i.indexOf(" ");s>0&&(n=i.slice(0,s),i=i.slice(s+1));let a,l=n?t.createElementNS(n,i):t.createElement(i),c=e[1],d=1;if(c&&"object"==typeof c&&null==c.nodeType&&!Array.isArray(c)){d=2;for(let t in c)if(null!=c[t]){let e=t.indexOf(" ");e>0?l.setAttributeNS(t.slice(0,e),t.slice(e+1),c[t]):l.setAttribute(t,c[t])}}for(let o=d;o<e.length;o++){let i=e[o];if(0===i){if(o<e.length-1||o>d)throw new RangeError("Content hole must be the only child of its parent node");return{dom:l,contentDOM:l}}{let{dom:e,contentDOM:o}=$t(t,i,n,r);if(l.appendChild(e),o){if(a)throw new RangeError("Multiple content holes");a=o}}}return{dom:l,contentDOM:a}}const Bt=Math.pow(2,16);function Ft(t,e){return t+e*Bt}function _t(t){return 65535&t}class Vt{constructor(t,e,n){this.pos=t,this.delInfo=e,this.recover=n}get deleted(){return(8&this.delInfo)>0}get deletedBefore(){return(5&this.delInfo)>0}get deletedAfter(){return(6&this.delInfo)>0}get deletedAcross(){return(4&this.delInfo)>0}}class Ht{constructor(t,e=!1){if(this.ranges=t,this.inverted=e,!t.length&&Ht.empty)return Ht.empty}recover(t){let e=0,n=_t(t);if(!this.inverted)for(let t=0;t<n;t++)e+=this.ranges[3*t+2]-this.ranges[3*t+1];return this.ranges[3*n]+e+((r=t)-(65535&r))/Bt;var r}mapResult(t,e=1){return this._map(t,e,!1)}map(t,e=1){return this._map(t,e,!0)}_map(t,e,n){let r=0,o=this.inverted?2:1,i=this.inverted?1:2;for(let s=0;s<this.ranges.length;s+=3){let a=this.ranges[s]-(this.inverted?r:0);if(a>t)break;let l=this.ranges[s+o],c=this.ranges[s+i],d=a+l;if(t<=d){let o=a+r+((l?t==a?-1:t==d?1:e:e)<0?0:c);if(n)return o;let i=t==(e<0?a:d)?null:Ft(s/3,t-a),h=t==a?2:t==d?1:4;return(e<0?t!=a:t!=d)&&(h|=8),new Vt(o,h,i)}r+=c-l}return n?t+r:new Vt(t+r,0,null)}touches(t,e){let n=0,r=_t(e),o=this.inverted?2:1,i=this.inverted?1:2;for(let e=0;e<this.ranges.length;e+=3){let s=this.ranges[e]-(this.inverted?n:0);if(s>t)break;let a=this.ranges[e+o];if(t<=s+a&&e==3*r)return!0;n+=this.ranges[e+i]-a}return!1}forEach(t){let e=this.inverted?2:1,n=this.inverted?1:2;for(let r=0,o=0;r<this.ranges.length;r+=3){let i=this.ranges[r],s=i-(this.inverted?o:0),a=i+(this.inverted?0:o),l=this.ranges[r+e],c=this.ranges[r+n];t(s,s+l,a,a+c),o+=c-l}}invert(){return new Ht(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(t){return 0==t?Ht.empty:new Ht(t<0?[0,-t,0]:[0,0,t])}}Ht.empty=new Ht([]);class Wt{constructor(t=[],e,n=0,r=t.length){this.maps=t,this.mirror=e,this.from=n,this.to=r}slice(t=0,e=this.maps.length){return new Wt(this.maps,this.mirror,t,e)}copy(){return new Wt(this.maps.slice(),this.mirror&&this.mirror.slice(),this.from,this.to)}appendMap(t,e){this.to=this.maps.push(t),null!=e&&this.setMirror(this.maps.length-1,e)}appendMapping(t){for(let e=0,n=this.maps.length;e<t.maps.length;e++){let r=t.getMirror(e);this.appendMap(t.maps[e],null!=r&&r<e?n+r:void 0)}}getMirror(t){if(this.mirror)for(let e=0;e<this.mirror.length;e++)if(this.mirror[e]==t)return this.mirror[e+(e%2?-1:1)]}setMirror(t,e){this.mirror||(this.mirror=[]),this.mirror.push(t,e)}appendMappingInverted(t){for(let e=t.maps.length-1,n=this.maps.length+t.maps.length;e>=0;e--){let r=t.getMirror(e);this.appendMap(t.maps[e].invert(),null!=r&&r>e?n-r-1:void 0)}}invert(){let t=new Wt;return t.appendMappingInverted(this),t}map(t,e=1){if(this.mirror)return this._map(t,e,!0);for(let n=this.from;n<this.to;n++)t=this.maps[n].map(t,e);return t}mapResult(t,e=1){return this._map(t,e,!1)}_map(t,e,n){let r=0;for(let n=this.from;n<this.to;n++){let o=this.maps[n].mapResult(t,e);if(null!=o.recover){let e=this.getMirror(n);if(null!=e&&e>n&&e<this.to){n=e,t=this.maps[e].recover(o.recover);continue}}r|=o.delInfo,t=o.pos}return n?t:new Vt(t,r,null)}}const Kt=Object.create(null);class qt{getMap(){return Ht.empty}merge(t){return null}static fromJSON(t,e){if(!e||!e.stepType)throw new RangeError("Invalid input for Step.fromJSON");let n=Kt[e.stepType];if(!n)throw new RangeError(`No step type ${e.stepType} defined`);return n.fromJSON(t,e)}static jsonID(t,e){if(t in Kt)throw new RangeError("Duplicate use of step JSON ID "+t);return Kt[t]=e,e.prototype.jsonID=t,e}}class Jt{constructor(t,e){this.doc=t,this.failed=e}static ok(t){return new Jt(t,null)}static fail(t){return new Jt(null,t)}static fromReplace(t,e,n,r){try{return Jt.ok(t.replace(e,n,r))}catch(t){if(t instanceof z)return Jt.fail(t.message);throw t}}}function Ut(t,e,n){let r=[];for(let o=0;o<t.childCount;o++){let i=t.child(o);i.content.size&&(i=i.copy(Ut(i.content,e,i))),i.isInline&&(i=e(i,n,o)),r.push(i)}return R.fromArray(r)}class Gt extends qt{constructor(t,e,n){super(),this.from=t,this.to=e,this.mark=n}apply(t){let e=t.slice(this.from,this.to),n=t.resolve(this.from),r=n.node(n.sharedDepth(this.to)),o=new $(Ut(e.content,((t,e)=>t.isAtom&&e.type.allowsMarkType(this.mark.type)?t.mark(this.mark.addToSet(t.marks)):t),r),e.openStart,e.openEnd);return Jt.fromReplace(t,this.from,this.to,o)}invert(){return new Yt(this.from,this.to,this.mark)}map(t){let e=t.mapResult(this.from,1),n=t.mapResult(this.to,-1);return e.deleted&&n.deleted||e.pos>=n.pos?null:new Gt(e.pos,n.pos,this.mark)}merge(t){return t instanceof Gt&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new Gt(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,e){if("number"!=typeof e.from||"number"!=typeof e.to)throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new Gt(e.from,e.to,t.markFromJSON(e.mark))}}qt.jsonID("addMark",Gt);class Yt extends qt{constructor(t,e,n){super(),this.from=t,this.to=e,this.mark=n}apply(t){let e=t.slice(this.from,this.to),n=new $(Ut(e.content,(t=>t.mark(this.mark.removeFromSet(t.marks))),t),e.openStart,e.openEnd);return Jt.fromReplace(t,this.from,this.to,n)}invert(){return new Gt(this.from,this.to,this.mark)}map(t){let e=t.mapResult(this.from,1),n=t.mapResult(this.to,-1);return e.deleted&&n.deleted||e.pos>=n.pos?null:new Yt(e.pos,n.pos,this.mark)}merge(t){return t instanceof Yt&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new Yt(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,e){if("number"!=typeof e.from||"number"!=typeof e.to)throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new Yt(e.from,e.to,t.markFromJSON(e.mark))}}qt.jsonID("removeMark",Yt);class Qt extends qt{constructor(t,e){super(),this.pos=t,this.mark=e}apply(t){let e=t.nodeAt(this.pos);if(!e)return Jt.fail("No node at mark step's position");let n=e.type.create(e.attrs,null,this.mark.addToSet(e.marks));return Jt.fromReplace(t,this.pos,this.pos+1,new $(R.from(n),0,e.isLeaf?0:1))}invert(t){let e=t.nodeAt(this.pos);if(e){let t=this.mark.addToSet(e.marks);if(t.length==e.marks.length){for(let n=0;n<e.marks.length;n++)if(!e.marks[n].isInSet(t))return new Qt(this.pos,e.marks[n]);return new Qt(this.pos,this.mark)}}return new Xt(this.pos,this.mark)}map(t){let e=t.mapResult(this.pos,1);return e.deletedAfter?null:new Qt(e.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,e){if("number"!=typeof e.pos)throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new Qt(e.pos,t.markFromJSON(e.mark))}}qt.jsonID("addNodeMark",Qt);class Xt extends qt{constructor(t,e){super(),this.pos=t,this.mark=e}apply(t){let e=t.nodeAt(this.pos);if(!e)return Jt.fail("No node at mark step's position");let n=e.type.create(e.attrs,null,this.mark.removeFromSet(e.marks));return Jt.fromReplace(t,this.pos,this.pos+1,new $(R.from(n),0,e.isLeaf?0:1))}invert(t){let e=t.nodeAt(this.pos);return e&&this.mark.isInSet(e.marks)?new Qt(this.pos,this.mark):this}map(t){let e=t.mapResult(this.pos,1);return e.deletedAfter?null:new Xt(e.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,e){if("number"!=typeof e.pos)throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new Xt(e.pos,t.markFromJSON(e.mark))}}qt.jsonID("removeNodeMark",Xt);class Zt extends qt{constructor(t,e,n,r=!1){super(),this.from=t,this.to=e,this.slice=n,this.structure=r}apply(t){return this.structure&&ee(t,this.from,this.to)?Jt.fail("Structure replace would overwrite content"):Jt.fromReplace(t,this.from,this.to,this.slice)}getMap(){return new Ht([this.from,this.to-this.from,this.slice.size])}invert(t){return new Zt(this.from,this.from+this.slice.size,t.slice(this.from,this.to))}map(t){let e=t.mapResult(this.from,1),n=t.mapResult(this.to,-1);return e.deletedAcross&&n.deletedAcross?null:new Zt(e.pos,Math.max(e.pos,n.pos),this.slice)}merge(t){if(!(t instanceof Zt)||t.structure||this.structure)return null;if(this.from+this.slice.size!=t.from||this.slice.openEnd||t.slice.openStart){if(t.to!=this.from||this.slice.openStart||t.slice.openEnd)return null;{let e=this.slice.size+t.slice.size==0?$.empty:new $(t.slice.content.append(this.slice.content),t.slice.openStart,this.slice.openEnd);return new Zt(t.from,this.to,e,this.structure)}}{let e=this.slice.size+t.slice.size==0?$.empty:new $(this.slice.content.append(t.slice.content),this.slice.openStart,t.slice.openEnd);return new Zt(this.from,this.to+(t.to-t.from),e,this.structure)}}toJSON(){let t={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(t.slice=this.slice.toJSON()),this.structure&&(t.structure=!0),t}static fromJSON(t,e){if("number"!=typeof e.from||"number"!=typeof e.to)throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new Zt(e.from,e.to,$.fromJSON(t,e.slice),!!e.structure)}}qt.jsonID("replace",Zt);class te extends qt{constructor(t,e,n,r,o,i,s=!1){super(),this.from=t,this.to=e,this.gapFrom=n,this.gapTo=r,this.slice=o,this.insert=i,this.structure=s}apply(t){if(this.structure&&(ee(t,this.from,this.gapFrom)||ee(t,this.gapTo,this.to)))return Jt.fail("Structure gap-replace would overwrite content");let e=t.slice(this.gapFrom,this.gapTo);if(e.openStart||e.openEnd)return Jt.fail("Gap is not a flat range");let n=this.slice.insertAt(this.insert,e.content);return n?Jt.fromReplace(t,this.from,this.to,n):Jt.fail("Content does not fit in gap")}getMap(){return new Ht([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(t){let e=this.gapTo-this.gapFrom;return new te(this.from,this.from+this.slice.size+e,this.from+this.insert,this.from+this.insert+e,t.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(t){let e=t.mapResult(this.from,1),n=t.mapResult(this.to,-1),r=this.from==this.gapFrom?e.pos:t.map(this.gapFrom,-1),o=this.to==this.gapTo?n.pos:t.map(this.gapTo,1);return e.deletedAcross&&n.deletedAcross||r<e.pos||o>n.pos?null:new te(e.pos,n.pos,r,o,this.slice,this.insert,this.structure)}toJSON(){let t={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(t.slice=this.slice.toJSON()),this.structure&&(t.structure=!0),t}static fromJSON(t,e){if("number"!=typeof e.from||"number"!=typeof e.to||"number"!=typeof e.gapFrom||"number"!=typeof e.gapTo||"number"!=typeof e.insert)throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new te(e.from,e.to,e.gapFrom,e.gapTo,$.fromJSON(t,e.slice),e.insert,!!e.structure)}}function ee(t,e,n){let r=t.resolve(e),o=n-e,i=r.depth;for(;o>0&&i>0&&r.indexAfter(i)==r.node(i).childCount;)i--,o--;if(o>0){let t=r.node(i).maybeChild(r.indexAfter(i));for(;o>0;){if(!t||t.isLeaf)return!0;t=t.firstChild,o--}}return!1}function ne(t,e,n,r=n.contentMatch,o=!0){let i=t.doc.nodeAt(e),s=[],a=e+1;for(let e=0;e<i.childCount;e++){let l=i.child(e),c=a+l.nodeSize,d=r.matchType(l.type);if(d){r=d;for(let e=0;e<l.marks.length;e++)n.allowsMarkType(l.marks[e].type)||t.step(new Yt(a,c,l.marks[e]));if(o&&l.isText&&"pre"!=n.whitespace){let t,e,r=/\r?\n|\r/g;for(;t=r.exec(l.text);)e||(e=new $(R.from(n.schema.text(" ",n.allowedMarks(l.marks))),0,0)),s.push(new Zt(a+t.index,a+t.index+t[0].length,e))}}else s.push(new Zt(a,c,$.empty));a=c}if(!r.validEnd){let e=r.fillBefore(R.empty,!0);t.replace(a,a,new $(e,0,0))}for(let e=s.length-1;e>=0;e--)t.step(s[e])}function re(t,e,n){return(0==e||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function oe(t){let e=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let n=t.depth;;--n){let r=t.$from.node(n),o=t.$from.index(n),i=t.$to.indexAfter(n);if(n<t.depth&&r.canReplace(o,i,e))return n;if(0==n||r.type.spec.isolating||!re(r,o,i))break}return null}function ie(t,e,n=null,r=t){let o=function(t,e){let{parent:n,startIndex:r,endIndex:o}=t,i=n.contentMatchAt(r).findWrapping(e);if(!i)return null;let s=i.length?i[0]:e;return n.canReplaceWith(r,o,s)?i:null}(t,e),i=o&&function(t,e){let{parent:n,startIndex:r,endIndex:o}=t,i=n.child(r),s=e.contentMatch.findWrapping(i.type);if(!s)return null;let a=(s.length?s[s.length-1]:e).contentMatch;for(let t=r;a&&t<o;t++)a=a.matchType(n.child(t).type);return a&&a.validEnd?s:null}(r,e);return i?o.map(se).concat({type:e,attrs:n}).concat(i.map(se)):null}function se(t){return{type:t,attrs:null}}function ae(t,e,n=1,r){let o=t.resolve(e),i=o.depth-n,s=r&&r[r.length-1]||o.parent;if(i<0||o.parent.type.spec.isolating||!o.parent.canReplace(o.index(),o.parent.childCount)||!s.type.validContent(o.parent.content.cutByIndex(o.index(),o.parent.childCount)))return!1;for(let t=o.depth-1,e=n-2;t>i;t--,e--){let n=o.node(t),i=o.index(t);if(n.type.spec.isolating)return!1;let s=n.content.cutByIndex(i,n.childCount),a=r&&r[e+1];a&&(s=s.replaceChild(0,a.type.create(a.attrs)));let l=r&&r[e]||n;if(!n.canReplace(i+1,n.childCount)||!l.type.validContent(s))return!1}let a=o.indexAfter(i),l=r&&r[0];return o.node(i).canReplaceWith(a,a,l?l.type:o.node(i+1).type)}function le(t,e){let n=t.resolve(e),r=n.index();return ce(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function ce(t,e){return!(!t||!e||t.isLeaf||!t.canAppend(e))}function de(t,e,n=-1){let r=t.resolve(e);for(let t=r.depth;;t--){let o,i,s=r.index(t);if(t==r.depth?(o=r.nodeBefore,i=r.nodeAfter):n>0?(o=r.node(t+1),s++,i=r.node(t).maybeChild(s)):(o=r.node(t).maybeChild(s-1),i=r.node(t+1)),o&&!o.isTextblock&&ce(o,i)&&r.node(t).canReplace(s,s+1))return e;if(0==t)break;e=n<0?r.before(t):r.after(t)}}function he(t,e,n=e,r=$.empty){if(e==n&&!r.size)return null;let o=t.resolve(e),i=t.resolve(n);return ue(o,i,r)?new Zt(e,n,r):new pe(o,i,r).fit()}function ue(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}qt.jsonID("replaceAround",te);class pe{constructor(t,e,n){this.$from=t,this.$to=e,this.unplaced=n,this.frontier=[],this.placed=R.empty;for(let e=0;e<=t.depth;e++){let n=t.node(e);this.frontier.push({type:n.type,match:n.contentMatchAt(t.indexAfter(e))})}for(let e=t.depth;e>0;e--)this.placed=R.from(t.node(e).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let t=this.findFittable();t?this.placeNodes(t):this.openMore()||this.dropNode()}let t=this.mustMoveInline(),e=this.placed.size-this.depth-this.$from.depth,n=this.$from,r=this.close(t<0?this.$to:n.doc.resolve(t));if(!r)return null;let o=this.placed,i=n.depth,s=r.depth;for(;i&&s&&1==o.childCount;)o=o.firstChild.content,i--,s--;let a=new $(o,i,s);return t>-1?new te(n.pos,t,this.$to.pos,this.$to.end(),a,e):a.size||n.pos!=this.$to.pos?new Zt(n.pos,r.pos,a):null}findFittable(){let t=this.unplaced.openStart;for(let e=this.unplaced.content,n=0,r=this.unplaced.openEnd;n<t;n++){let o=e.firstChild;if(e.childCount>1&&(r=0),o.type.spec.isolating&&r<=n){t=n;break}e=o.content}for(let e=1;e<=2;e++)for(let n=1==e?t:this.unplaced.openStart;n>=0;n--){let t,r=null;n?(r=ge(this.unplaced.content,n-1).firstChild,t=r.content):t=this.unplaced.content;let o=t.firstChild;for(let t=this.depth;t>=0;t--){let i,{type:s,match:a}=this.frontier[t],l=null;if(1==e&&(o?a.matchType(o.type)||(l=a.fillBefore(R.from(o),!1)):r&&s.compatibleContent(r.type)))return{sliceDepth:n,frontierDepth:t,parent:r,inject:l};if(2==e&&o&&(i=a.findWrapping(o.type)))return{sliceDepth:n,frontierDepth:t,parent:r,wrap:i};if(r&&a.matchType(r.type))break}}}openMore(){let{content:t,openStart:e,openEnd:n}=this.unplaced,r=ge(t,e);return!(!r.childCount||r.firstChild.isLeaf)&&(this.unplaced=new $(t,e+1,Math.max(n,r.size+e>=t.size-n?e+1:0)),!0)}dropNode(){let{content:t,openStart:e,openEnd:n}=this.unplaced,r=ge(t,e);if(r.childCount<=1&&e>0){let o=t.size-e<=e+r.size;this.unplaced=new $(fe(t,e-1,1),e-1,o?e-1:n)}else this.unplaced=new $(fe(t,e,1),e,n)}placeNodes({sliceDepth:t,frontierDepth:e,parent:n,inject:r,wrap:o}){for(;this.depth>e;)this.closeFrontierNode();if(o)for(let t=0;t<o.length;t++)this.openFrontierNode(o[t]);let i=this.unplaced,s=n?n.content:i.content,a=i.openStart-t,l=0,c=[],{match:d,type:h}=this.frontier[e];if(r){for(let t=0;t<r.childCount;t++)c.push(r.child(t));d=d.matchFragment(r)}let u=s.size+t-(i.content.size-i.openEnd);for(;l<s.childCount;){let t=s.child(l),e=d.matchType(t.type);if(!e)break;l++,(l>1||0==a||t.content.size)&&(d=e,c.push(ye(t.mark(h.allowedMarks(t.marks)),1==l?a:0,l==s.childCount?u:-1)))}let p=l==s.childCount;p||(u=-1),this.placed=me(this.placed,e,R.from(c)),this.frontier[e].match=d,p&&u<0&&n&&n.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let t=0,e=s;t<u;t++){let t=e.lastChild;this.frontier.push({type:t.type,match:t.contentMatchAt(t.childCount)}),e=t.content}this.unplaced=p?0==t?$.empty:new $(fe(i.content,t-1,1),t-1,u<0?i.openEnd:t-1):new $(fe(i.content,t,l),i.openStart,i.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let t,e=this.frontier[this.depth];if(!e.type.isTextblock||!be(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:n}=this.$to,r=this.$to.after(n);for(;n>1&&r==this.$to.end(--n);)++r;return r}findCloseLevel(t){t:for(let e=Math.min(this.depth,t.depth);e>=0;e--){let{match:n,type:r}=this.frontier[e],o=e<t.depth&&t.end(e+1)==t.pos+(t.depth-(e+1)),i=be(t,e,r,n,o);if(i){for(let n=e-1;n>=0;n--){let{match:e,type:r}=this.frontier[n],o=be(t,n,r,e,!0);if(!o||o.childCount)continue t}return{depth:e,fit:i,move:o?t.doc.resolve(t.after(e+1)):t}}}}close(t){let e=this.findCloseLevel(t);if(!e)return null;for(;this.depth>e.depth;)this.closeFrontierNode();e.fit.childCount&&(this.placed=me(this.placed,e.depth,e.fit)),t=e.move;for(let n=e.depth+1;n<=t.depth;n++){let e=t.node(n),r=e.type.contentMatch.fillBefore(e.content,!0,t.index(n));this.openFrontierNode(e.type,e.attrs,r)}return t}openFrontierNode(t,e=null,n){let r=this.frontier[this.depth];r.match=r.match.matchType(t),this.placed=me(this.placed,this.depth,R.from(t.create(e,n))),this.frontier.push({type:t,match:t.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(R.empty,!0);t.childCount&&(this.placed=me(this.placed,this.frontier.length,t))}}function fe(t,e,n){return 0==e?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(fe(t.firstChild.content,e-1,n)))}function me(t,e,n){return 0==e?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(me(t.lastChild.content,e-1,n)))}function ge(t,e){for(let n=0;n<e;n++)t=t.firstChild.content;return t}function ye(t,e,n){if(e<=0)return t;let r=t.content;return e>1&&(r=r.replaceChild(0,ye(r.firstChild,e-1,1==r.childCount?n-1:0))),e>0&&(r=t.type.contentMatch.fillBefore(r).append(r),n<=0&&(r=r.append(t.type.contentMatch.matchFragment(r).fillBefore(R.empty,!0)))),t.copy(r)}function be(t,e,n,r,o){let i=t.node(e),s=o?t.indexAfter(e):t.index(e);if(s==i.childCount&&!n.compatibleContent(i.type))return null;let a=r.fillBefore(i.content,!0,s);return a&&!function(t,e,n){for(let r=n;r<e.childCount;r++)if(!t.allowsMarks(e.child(r).marks))return!0;return!1}(n,i.content,s)?a:null}function ve(t){return t.spec.defining||t.spec.definingForContent}function we(t,e,n,r,o){if(e<n){let o=t.firstChild;t=t.replaceChild(0,o.copy(we(o.content,e+1,n,r,o)))}if(e>r){let e=o.contentMatchAt(0),n=e.fillBefore(t).append(t);t=n.append(e.matchFragment(n).fillBefore(R.empty,!0))}return t}function ke(t,e){let n=[];for(let r=Math.min(t.depth,e.depth);r>=0;r--){let o=t.start(r);if(o<t.pos-(t.depth-r)||e.end(r)>e.pos+(e.depth-r)||t.node(r).type.spec.isolating||e.node(r).type.spec.isolating)break;(o==e.start(r)||r==t.depth&&r==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&r&&e.start(r-1)==o-1)&&n.push(r)}return n}class xe extends qt{constructor(t,e,n){super(),this.pos=t,this.attr=e,this.value=n}apply(t){let e=t.nodeAt(this.pos);if(!e)return Jt.fail("No node at attribute step's position");let n=Object.create(null);for(let t in e.attrs)n[t]=e.attrs[t];n[this.attr]=this.value;let r=e.type.create(n,null,e.marks);return Jt.fromReplace(t,this.pos,this.pos+1,new $(R.from(r),0,e.isLeaf?0:1))}getMap(){return Ht.empty}invert(t){return new xe(this.pos,this.attr,t.nodeAt(this.pos).attrs[this.attr])}map(t){let e=t.mapResult(this.pos,1);return e.deletedAfter?null:new xe(e.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(t,e){if("number"!=typeof e.pos||"string"!=typeof e.attr)throw new RangeError("Invalid input for AttrStep.fromJSON");return new xe(e.pos,e.attr,e.value)}}qt.jsonID("attr",xe);class Se extends qt{constructor(t,e){super(),this.attr=t,this.value=e}apply(t){let e=Object.create(null);for(let n in t.attrs)e[n]=t.attrs[n];e[this.attr]=this.value;let n=t.type.create(e,t.content,t.marks);return Jt.ok(n)}getMap(){return Ht.empty}invert(t){return new Se(this.attr,t.attrs[this.attr])}map(t){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(t,e){if("string"!=typeof e.attr)throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new Se(e.attr,e.value)}}qt.jsonID("docAttr",Se);let Oe=class extends Error{};Oe=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n},(Oe.prototype=Object.create(Error.prototype)).constructor=Oe,Oe.prototype.name="TransformError";class Ce{constructor(t){this.doc=t,this.steps=[],this.docs=[],this.mapping=new Wt}get before(){return this.docs.length?this.docs[0]:this.doc}step(t){let e=this.maybeStep(t);if(e.failed)throw new Oe(e.failed);return this}maybeStep(t){let e=t.apply(this.doc);return e.failed||this.addStep(t,e.doc),e}get docChanged(){return this.steps.length>0}addStep(t,e){this.docs.push(this.doc),this.steps.push(t),this.mapping.appendMap(t.getMap()),this.doc=e}replace(t,e=t,n=$.empty){let r=he(this.doc,t,e,n);return r&&this.step(r),this}replaceWith(t,e,n){return this.replace(t,e,new $(R.from(n),0,0))}delete(t,e){return this.replace(t,e,$.empty)}insert(t,e){return this.replaceWith(t,t,e)}replaceRange(t,e,n){return function(t,e,n,r){if(!r.size)return t.deleteRange(e,n);let o=t.doc.resolve(e),i=t.doc.resolve(n);if(ue(o,i,r))return t.step(new Zt(e,n,r));let s=ke(o,t.doc.resolve(n));0==s[s.length-1]&&s.pop();let a=-(o.depth+1);s.unshift(a);for(let t=o.depth,e=o.pos-1;t>0;t--,e--){let n=o.node(t).type.spec;if(n.defining||n.definingAsContext||n.isolating)break;s.indexOf(t)>-1?a=t:o.before(t)==e&&s.splice(1,0,-t)}let l=s.indexOf(a),c=[],d=r.openStart;for(let t=r.content,e=0;;e++){let n=t.firstChild;if(c.push(n),e==r.openStart)break;t=n.content}for(let t=d-1;t>=0;t--){let e=c[t],n=ve(e.type);if(n&&!e.sameMarkup(o.node(Math.abs(a)-1)))d=t;else if(n||!e.type.isTextblock)break}for(let e=r.openStart;e>=0;e--){let a=(e+d+1)%(r.openStart+1),h=c[a];if(h)for(let e=0;e<s.length;e++){let c=s[(e+l)%s.length],d=!0;c<0&&(d=!1,c=-c);let u=o.node(c-1),p=o.index(c-1);if(u.canReplaceWith(p,p,h.type,h.marks))return t.replace(o.before(c),d?i.after(c):n,new $(we(r.content,0,r.openStart,a),a,r.openEnd))}}let h=t.steps.length;for(let a=s.length-1;a>=0&&(t.replace(e,n,r),!(t.steps.length>h));a--){let t=s[a];t<0||(e=o.before(t),n=i.after(t))}}(this,t,e,n),this}replaceRangeWith(t,e,n){return function(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let o=function(t,e,n){let r=t.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),n))return e;if(0==r.parentOffset)for(let t=r.depth-1;t>=0;t--){let e=r.index(t);if(r.node(t).canReplaceWith(e,e,n))return r.before(t+1);if(e>0)return null}if(r.parentOffset==r.parent.content.size)for(let t=r.depth-1;t>=0;t--){let e=r.indexAfter(t);if(r.node(t).canReplaceWith(e,e,n))return r.after(t+1);if(e<r.node(t).childCount)return null}return null}(t.doc,e,r.type);null!=o&&(e=n=o)}t.replaceRange(e,n,new $(R.from(r),0,0))}(this,t,e,n),this}deleteRange(t,e){return function(t,e,n){let r=t.doc.resolve(e),o=t.doc.resolve(n),i=ke(r,o);for(let e=0;e<i.length;e++){let n=i[e],s=e==i.length-1;if(s&&0==n||r.node(n).type.contentMatch.validEnd)return t.delete(r.start(n),o.end(n));if(n>0&&(s||r.node(n-1).canReplace(r.index(n-1),o.indexAfter(n-1))))return t.delete(r.before(n),o.after(n))}for(let i=1;i<=r.depth&&i<=o.depth;i++)if(e-r.start(i)==r.depth-i&&n>r.end(i)&&o.end(i)-n!=o.depth-i)return t.delete(r.before(i),n);t.delete(e,n)}(this,t,e),this}lift(t,e){return function(t,e,n){let{$from:r,$to:o,depth:i}=e,s=r.before(i+1),a=o.after(i+1),l=s,c=a,d=R.empty,h=0;for(let t=i,e=!1;t>n;t--)e||r.index(t)>0?(e=!0,d=R.from(r.node(t).copy(d)),h++):l--;let u=R.empty,p=0;for(let t=i,e=!1;t>n;t--)e||o.after(t+1)<o.end(t)?(e=!0,u=R.from(o.node(t).copy(u)),p++):c++;t.step(new te(l,c,s,a,new $(d.append(u),h,p),d.size-h,!0))}(this,t,e),this}join(t,e=1){return function(t,e,n){let r=new Zt(e-n,e+n,$.empty,!0);t.step(r)}(this,t,e),this}wrap(t,e){return function(t,e,n){let r=R.empty;for(let t=n.length-1;t>=0;t--){if(r.size){let e=n[t].type.contentMatch.matchFragment(r);if(!e||!e.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=R.from(n[t].type.create(n[t].attrs,r))}let o=e.start,i=e.end;t.step(new te(o,i,o,i,new $(r,0,0),n.length,!0))}(this,t,e),this}setBlockType(t,e=t,n,r=null){return function(t,e,n,r,o){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let i=t.steps.length;t.doc.nodesBetween(e,n,((e,n)=>{let s="function"==typeof o?o(e):o;if(e.isTextblock&&!e.hasMarkup(r,s)&&function(t,e,n){let r=t.resolve(e),o=r.index();return r.parent.canReplaceWith(o,o+1,n)}(t.doc,t.mapping.slice(i).map(n),r)){let o=null;if(r.schema.linebreakReplacement){let t="pre"==r.whitespace,e=!!r.contentMatch.matchType(r.schema.linebreakReplacement);t&&!e?o=!1:!t&&e&&(o=!0)}!1===o&&function(t,e,n,r){e.forEach(((o,i)=>{if(o.type==o.type.schema.linebreakReplacement){let o=t.mapping.slice(r).map(n+1+i);t.replaceWith(o,o+1,e.type.schema.text("\n"))}}))}(t,e,n,i),ne(t,t.mapping.slice(i).map(n,1),r,void 0,null===o);let a=t.mapping.slice(i),l=a.map(n,1),c=a.map(n+e.nodeSize,1);return t.step(new te(l,c,l+1,c-1,new $(R.from(r.create(s,null,e.marks)),0,0),1,!0)),!0===o&&function(t,e,n,r){e.forEach(((o,i)=>{if(o.isText){let s,a=/\r?\n|\r/g;for(;s=a.exec(o.text);){let o=t.mapping.slice(r).map(n+1+i+s.index);t.replaceWith(o,o+1,e.type.schema.linebreakReplacement.create())}}}))}(t,e,n,i),!1}}))}(this,t,e,n,r),this}setNodeMarkup(t,e,n=null,r){return function(t,e,n,r,o){let i=t.doc.nodeAt(e);if(!i)throw new RangeError("No node at given position");n||(n=i.type);let s=n.create(r,null,o||i.marks);if(i.isLeaf)return t.replaceWith(e,e+i.nodeSize,s);if(!n.validContent(i.content))throw new RangeError("Invalid content for node type "+n.name);t.step(new te(e,e+i.nodeSize,e+1,e+i.nodeSize-1,new $(R.from(s),0,0),1,!0))}(this,t,e,n,r),this}setNodeAttribute(t,e,n){return this.step(new xe(t,e,n)),this}setDocAttribute(t,e){return this.step(new Se(t,e)),this}addNodeMark(t,e){return this.step(new Qt(t,e)),this}removeNodeMark(t,e){if(!(e instanceof j)){let n=this.doc.nodeAt(t);if(!n)throw new RangeError("No node at position "+t);if(!(e=e.isInSet(n.marks)))return this}return this.step(new Xt(t,e)),this}split(t,e=1,n){return function(t,e,n=1,r){let o=t.doc.resolve(e),i=R.empty,s=R.empty;for(let t=o.depth,e=o.depth-n,a=n-1;t>e;t--,a--){i=R.from(o.node(t).copy(i));let e=r&&r[a];s=R.from(e?e.type.create(e.attrs,s):o.node(t).copy(s))}t.step(new Zt(e,e,new $(i.append(s),n,n),!0))}(this,t,e,n),this}addMark(t,e,n){return function(t,e,n,r){let o,i,s=[],a=[];t.doc.nodesBetween(e,n,((t,l,c)=>{if(!t.isInline)return;let d=t.marks;if(!r.isInSet(d)&&c.type.allowsMarkType(r.type)){let c=Math.max(l,e),h=Math.min(l+t.nodeSize,n),u=r.addToSet(d);for(let t=0;t<d.length;t++)d[t].isInSet(u)||(o&&o.to==c&&o.mark.eq(d[t])?o.to=h:s.push(o=new Yt(c,h,d[t])));i&&i.to==c?i.to=h:a.push(i=new Gt(c,h,r))}})),s.forEach((e=>t.step(e))),a.forEach((e=>t.step(e)))}(this,t,e,n),this}removeMark(t,e,n){return function(t,e,n,r){let o=[],i=0;t.doc.nodesBetween(e,n,((t,s)=>{if(!t.isInline)return;i++;let a=null;if(r instanceof wt){let e,n=t.marks;for(;e=r.isInSet(n);)(a||(a=[])).push(e),n=e.removeFromSet(n)}else r?r.isInSet(t.marks)&&(a=[r]):a=t.marks;if(a&&a.length){let r=Math.min(s+t.nodeSize,n);for(let t=0;t<a.length;t++){let n,l=a[t];for(let t=0;t<o.length;t++){let e=o[t];e.step==i-1&&l.eq(o[t].style)&&(n=e)}n?(n.to=r,n.step=i):o.push({style:l,from:Math.max(s,e),to:r,step:i})}}})),o.forEach((e=>t.step(new Yt(e.from,e.to,e.style))))}(this,t,e,n),this}clearIncompatible(t,e,n){return ne(this,t,e,n),this}}const Me=Object.create(null);class Te{constructor(t,e,n){this.$anchor=t,this.$head=e,this.ranges=n||[new Ee(t.min(e),t.max(e))]}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 t=this.ranges;for(let e=0;e<t.length;e++)if(t[e].$from.pos!=t[e].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(t,e=$.empty){let n=e.content.lastChild,r=null;for(let t=0;t<e.openEnd;t++)r=n,n=n.lastChild;let o=t.steps.length,i=this.ranges;for(let s=0;s<i.length;s++){let{$from:a,$to:l}=i[s],c=t.mapping.slice(o);t.replaceRange(c.map(a.pos),c.map(l.pos),s?$.empty:e),0==s&&$e(t,o,(n?n.isInline:r&&r.isTextblock)?-1:1)}}replaceWith(t,e){let n=t.steps.length,r=this.ranges;for(let o=0;o<r.length;o++){let{$from:i,$to:s}=r[o],a=t.mapping.slice(n),l=a.map(i.pos),c=a.map(s.pos);o?t.deleteRange(l,c):(t.replaceRangeWith(l,c,e),$e(t,n,e.isInline?-1:1))}}static findFrom(t,e,n=!1){let r=t.parent.inlineContent?new De(t):ze(t.node(0),t.parent,t.pos,t.index(),e,n);if(r)return r;for(let r=t.depth-1;r>=0;r--){let o=e<0?ze(t.node(0),t.node(r),t.before(r+1),t.index(r),e,n):ze(t.node(0),t.node(r),t.after(r+1),t.index(r)+1,e,n);if(o)return o}return null}static near(t,e=1){return this.findFrom(t,e)||this.findFrom(t,-e)||new Pe(t.node(0))}static atStart(t){return ze(t,t,0,0,1)||new Pe(t)}static atEnd(t){return ze(t,t,t.content.size,t.childCount,-1)||new Pe(t)}static fromJSON(t,e){if(!e||!e.type)throw new RangeError("Invalid input for Selection.fromJSON");let n=Me[e.type];if(!n)throw new RangeError(`No selection type ${e.type} defined`);return n.fromJSON(t,e)}static jsonID(t,e){if(t in Me)throw new RangeError("Duplicate use of selection JSON ID "+t);return Me[t]=e,e.prototype.jsonID=t,e}getBookmark(){return De.between(this.$anchor,this.$head).getBookmark()}}Te.prototype.visible=!0;class Ee{constructor(t,e){this.$from=t,this.$to=e}}let Ne=!1;function Ae(t){!Ne&&!t.parent.inlineContent&&(Ne=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class De extends Te{constructor(t,e=t){Ae(t),Ae(e),super(t,e)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(t,e){let n=t.resolve(e.map(this.head));if(!n.parent.inlineContent)return Te.near(n);let r=t.resolve(e.map(this.anchor));return new De(r.parent.inlineContent?r:n,n)}replace(t,e=$.empty){if(super.replace(t,e),e==$.empty){let e=this.$from.marksAcross(this.$to);e&&t.ensureMarks(e)}}eq(t){return t instanceof De&&t.anchor==this.anchor&&t.head==this.head}getBookmark(){return new Re(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(t,e){if("number"!=typeof e.anchor||"number"!=typeof e.head)throw new RangeError("Invalid input for TextSelection.fromJSON");return new De(t.resolve(e.anchor),t.resolve(e.head))}static create(t,e,n=e){let r=t.resolve(e);return new this(r,n==e?r:t.resolve(n))}static between(t,e,n){let r=t.pos-e.pos;if((!n||r)&&(n=r>=0?1:-1),!e.parent.inlineContent){let t=Te.findFrom(e,n,!0)||Te.findFrom(e,-n,!0);if(!t)return Te.near(e,n);e=t.$head}return t.parent.inlineContent||(0==r?t=e:(t=(Te.findFrom(t,-n,!0)||Te.findFrom(t,n,!0)).$anchor).pos<e.pos!=r<0&&(t=e)),new De(t,e)}}Te.jsonID("text",De);class Re{constructor(t,e){this.anchor=t,this.head=e}map(t){return new Re(t.map(this.anchor),t.map(this.head))}resolve(t){return De.between(t.resolve(this.anchor),t.resolve(this.head))}}class Ie extends Te{constructor(t){let e=t.nodeAfter,n=t.node(0).resolve(t.pos+e.nodeSize);super(t,n),this.node=e}map(t,e){let{deleted:n,pos:r}=e.mapResult(this.anchor),o=t.resolve(r);return n?Te.near(o):new Ie(o)}content(){return new $(R.from(this.node),0,0)}eq(t){return t instanceof Ie&&t.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new Le(this.anchor)}static fromJSON(t,e){if("number"!=typeof e.anchor)throw new RangeError("Invalid input for NodeSelection.fromJSON");return new Ie(t.resolve(e.anchor))}static create(t,e){return new Ie(t.resolve(e))}static isSelectable(t){return!t.isText&&!1!==t.type.spec.selectable}}Ie.prototype.visible=!1,Te.jsonID("node",Ie);class Le{constructor(t){this.anchor=t}map(t){let{deleted:e,pos:n}=t.mapResult(this.anchor);return e?new Re(n,n):new Le(n)}resolve(t){let e=t.resolve(this.anchor),n=e.nodeAfter;return n&&Ie.isSelectable(n)?new Ie(e):Te.near(e)}}class Pe extends Te{constructor(t){super(t.resolve(0),t.resolve(t.content.size))}replace(t,e=$.empty){if(e==$.empty){t.delete(0,t.doc.content.size);let e=Te.atStart(t.doc);e.eq(t.selection)||t.setSelection(e)}else super.replace(t,e)}toJSON(){return{type:"all"}}static fromJSON(t){return new Pe(t)}map(t){return new Pe(t)}eq(t){return t instanceof Pe}getBookmark(){return je}}Te.jsonID("all",Pe);const je={map(){return this},resolve:t=>new Pe(t)};function ze(t,e,n,r,o,i=!1){if(e.inlineContent)return De.create(t,n);for(let s=r-(o>0?0:1);o>0?s<e.childCount:s>=0;s+=o){let r=e.child(s);if(r.isAtom){if(!i&&Ie.isSelectable(r))return Ie.create(t,n-(o<0?r.nodeSize:0))}else{let e=ze(t,r,n+o,o<0?r.childCount:0,o,i);if(e)return e}n+=r.nodeSize*o}return null}function $e(t,e,n){let r=t.steps.length-1;if(r<e)return;let o,i=t.steps[r];(i instanceof Zt||i instanceof te)&&(t.mapping.maps[r].forEach(((t,e,n,r)=>{null==o&&(o=r)})),t.setSelection(Te.near(t.doc.resolve(o),n)))}class Be extends Ce{constructor(t){super(t.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=t.selection,this.storedMarks=t.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(t){if(t.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=t,this.curSelectionFor=this.steps.length,this.updated=-3&(1|this.updated),this.storedMarks=null,this}get selectionSet(){return(1&this.updated)>0}setStoredMarks(t){return this.storedMarks=t,this.updated|=2,this}ensureMarks(t){return j.sameSet(this.storedMarks||this.selection.$from.marks(),t)||this.setStoredMarks(t),this}addStoredMark(t){return this.ensureMarks(t.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(t){return this.ensureMarks(t.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(2&this.updated)>0}addStep(t,e){super.addStep(t,e),this.updated=-3&this.updated,this.storedMarks=null}setTime(t){return this.time=t,this}replaceSelection(t){return this.selection.replace(this,t),this}replaceSelectionWith(t,e=!0){let n=this.selection;return e&&(t=t.mark(this.storedMarks||(n.empty?n.$from.marks():n.$from.marksAcross(n.$to)||j.none))),n.replaceWith(this,t),this}deleteSelection(){return this.selection.replace(this),this}insertText(t,e,n){let r=this.doc.type.schema;if(null==e)return t?this.replaceSelectionWith(r.text(t),!0):this.deleteSelection();{if(null==n&&(n=e),n=n??e,!t)return this.deleteRange(e,n);let o=this.storedMarks;if(!o){let t=this.doc.resolve(e);o=n==e?t.marks():t.marksAcross(this.doc.resolve(n))}return this.replaceRangeWith(e,n,r.text(t,o)),this.selection.empty||this.setSelection(Te.near(this.selection.$to)),this}}setMeta(t,e){return this.meta["string"==typeof t?t:t.key]=e,this}getMeta(t){return this.meta["string"==typeof t?t:t.key]}get isGeneric(){for(let t in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=4,this}get scrolledIntoView(){return(4&this.updated)>0}}function Fe(t,e){return e&&t?t.bind(e):t}class _e{constructor(t,e,n){this.name=t,this.init=Fe(e.init,n),this.apply=Fe(e.apply,n)}}const Ve=[new _e("doc",{init:t=>t.doc||t.schema.topNodeType.createAndFill(),apply:t=>t.doc}),new _e("selection",{init:(t,e)=>t.selection||Te.atStart(e.doc),apply:t=>t.selection}),new _e("storedMarks",{init:t=>t.storedMarks||null,apply:(t,e,n,r)=>r.selection.$cursor?t.storedMarks:null}),new _e("scrollToSelection",{init:()=>0,apply:(t,e)=>t.scrolledIntoView?e+1:e})];class He{constructor(t,e){this.schema=t,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=Ve.slice(),e&&e.forEach((t=>{if(this.pluginsByKey[t.key])throw new RangeError("Adding different instances of a keyed plugin ("+t.key+")");this.plugins.push(t),this.pluginsByKey[t.key]=t,t.spec.state&&this.fields.push(new _e(t.key,t.spec.state,t))}))}}class We{constructor(t){this.config=t}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(t){return this.applyTransaction(t).state}filterTransaction(t,e=-1){for(let n=0;n<this.config.plugins.length;n++)if(n!=e){let e=this.config.plugins[n];if(e.spec.filterTransaction&&!e.spec.filterTransaction.call(e,t,this))return!1}return!0}applyTransaction(t){if(!this.filterTransaction(t))return{state:this,transactions:[]};let e=[t],n=this.applyInner(t),r=null;for(;;){let o=!1;for(let i=0;i<this.config.plugins.length;i++){let s=this.config.plugins[i];if(s.spec.appendTransaction){let a=r?r[i].n:0,l=r?r[i].state:this,c=a<e.length&&s.spec.appendTransaction.call(s,a?e.slice(a):e,l,n);if(c&&n.filterTransaction(c,i)){if(c.setMeta("appendedTransaction",t),!r){r=[];for(let t=0;t<this.config.plugins.length;t++)r.push(t<i?{state:n,n:e.length}:{state:this,n:0})}e.push(c),n=n.applyInner(c),o=!0}r&&(r[i]={state:n,n:e.length})}}if(!o)return{state:n,transactions:e}}}applyInner(t){if(!t.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let e=new We(this.config),n=this.config.fields;for(let r=0;r<n.length;r++){let o=n[r];e[o.name]=o.apply(t,this[o.name],this,e)}return e}get tr(){return new Be(this)}static create(t){let e=new He(t.doc?t.doc.type.schema:t.schema,t.plugins),n=new We(e);for(let r=0;r<e.fields.length;r++)n[e.fields[r].name]=e.fields[r].init(t,n);return n}reconfigure(t){let e=new He(this.schema,t.plugins),n=e.fields,r=new We(e);for(let e=0;e<n.length;e++){let o=n[e].name;r[o]=this.hasOwnProperty(o)?this[o]:n[e].init(t,r)}return r}toJSON(t){let e={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(e.storedMarks=this.storedMarks.map((t=>t.toJSON()))),t&&"object"==typeof t)for(let n in t){if("doc"==n||"selection"==n)throw new RangeError("The JSON fields `doc` and `selection` are reserved");let r=t[n],o=r.spec.state;o&&o.toJSON&&(e[n]=o.toJSON.call(r,this[r.key]))}return e}static fromJSON(t,e,n){if(!e)throw new RangeError("Invalid input for EditorState.fromJSON");if(!t.schema)throw new RangeError("Required config field 'schema' missing");let r=new He(t.schema,t.plugins),o=new We(r);return r.fields.forEach((r=>{if("doc"==r.name)o.doc=nt.fromJSON(t.schema,e.doc);else if("selection"==r.name)o.selection=Te.fromJSON(o.doc,e.selection);else if("storedMarks"==r.name)e.storedMarks&&(o.storedMarks=e.storedMarks.map(t.schema.markFromJSON));else{if(n)for(let i in n){let s=n[i],a=s.spec.state;if(s.key==r.name&&a&&a.fromJSON&&Object.prototype.hasOwnProperty.call(e,i))return void(o[r.name]=a.fromJSON.call(s,t,e[i],o))}o[r.name]=r.init(t,o)}})),o}}function Ke(t,e,n){for(let r in t){let o=t[r];o instanceof Function?o=o.bind(e):"handleDOMEvents"==r&&(o=Ke(o,e,{})),n[r]=o}return n}class qe{constructor(t){this.spec=t,this.props={},t.props&&Ke(t.props,this,this.props),this.key=t.key?t.key.key:Ue("plugin")}getState(t){return t[this.key]}}const Je=Object.create(null);function Ue(t){return t in Je?t+"$"+ ++Je[t]:(Je[t]=0,t+"$")}class Ge{constructor(t="key"){this.key=Ue(t)}get(t){return t.config.pluginsByKey[this.key]}getState(t){return t[this.key]}}const Ye=function(t){for(var e=0;;e++)if(!(t=t.previousSibling))return e},Qe=function(t){let e=t.assignedSlot||t.parentNode;return e&&11==e.nodeType?e.host:e};let Xe=null;const Ze=function(t,e,n){let r=Xe||(Xe=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r},tn=function(t,e,n,r){return n&&(nn(t,e,n,r,-1)||nn(t,e,n,r,1))},en=/^(img|br|input|textarea|hr)$/i;function nn(t,e,n,r,o){for(;;){if(t==n&&e==r)return!0;if(e==(o<0?0:rn(t))){let n=t.parentNode;if(!n||1!=n.nodeType||on(t)||en.test(t.nodeName)||"false"==t.contentEditable)return!1;e=Ye(t)+(o<0?0:1),t=n}else{if(1!=t.nodeType)return!1;if("false"==(t=t.childNodes[e+(o<0?-1:0)]).contentEditable)return!1;e=o<0?rn(t):0}}}function rn(t){return 3==t.nodeType?t.nodeValue.length:t.childNodes.length}function on(t){let e;for(let n=t;n&&!(e=n.pmViewDesc);n=n.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==t||e.contentDOM==t)}const sn=function(t){return t.focusNode&&tn(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function an(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}const ln=typeof navigator<"u"?navigator:null,cn=typeof document<"u"?document:null,dn=ln&&ln.userAgent||"",hn=/Edge\/(\d+)/.exec(dn),un=/MSIE \d/.exec(dn),pn=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(dn),fn=!!(un||pn||hn),mn=un?document.documentMode:pn?+pn[1]:hn?+hn[1]:0,gn=!fn&&/gecko\/(\d+)/i.test(dn);gn&&(/Firefox\/(\d+)/.exec(dn)||[0,0])[1];const yn=!fn&&/Chrome\/(\d+)/.exec(dn),bn=!!yn,vn=yn?+yn[1]:0,wn=!fn&&!!ln&&/Apple Computer/.test(ln.vendor),kn=wn&&(/Mobile\/\w+/.test(dn)||!!ln&&ln.maxTouchPoints>2),xn=kn||!!ln&&/Mac/.test(ln.platform),Sn=!!ln&&/Win/.test(ln.platform),On=/Android \d/.test(dn),Cn=!!cn&&"webkitFontSmoothing"in cn.documentElement.style,Mn=Cn?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Tn(t){let e=t.defaultView&&t.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.documentElement.clientWidth,top:0,bottom:t.documentElement.clientHeight}}function En(t,e){return"number"==typeof t?t:t[e]}function Nn(t){let e=t.getBoundingClientRect(),n=e.width/t.offsetWidth||1,r=e.height/t.offsetHeight||1;return{left:e.left,right:e.left+t.clientWidth*n,top:e.top,bottom:e.top+t.clientHeight*r}}function An(t,e,n){let r=t.someProp("scrollThreshold")||0,o=t.someProp("scrollMargin")||5,i=t.dom.ownerDocument;for(let s=n||t.dom;s;s=Qe(s)){if(1!=s.nodeType)continue;let t=s,n=t==i.body,a=n?Tn(i):Nn(t),l=0,c=0;if(e.top<a.top+En(r,"top")?c=-(a.top-e.top+En(o,"top")):e.bottom>a.bottom-En(r,"bottom")&&(c=e.bottom-e.top>a.bottom-a.top?e.top+En(o,"top")-a.top:e.bottom-a.bottom+En(o,"bottom")),e.left<a.left+En(r,"left")?l=-(a.left-e.left+En(o,"left")):e.right>a.right-En(r,"right")&&(l=e.right-a.right+En(o,"right")),l||c)if(n)i.defaultView.scrollBy(l,c);else{let n=t.scrollLeft,r=t.scrollTop;c&&(t.scrollTop+=c),l&&(t.scrollLeft+=l);let o=t.scrollLeft-n,i=t.scrollTop-r;e={left:e.left-o,top:e.top-i,right:e.right-o,bottom:e.bottom-i}}if(n||/^(fixed|sticky)$/.test(getComputedStyle(s).position))break}}function Dn(t){let e=[],n=t.ownerDocument;for(let r=t;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t!=n);r=Qe(r));return e}function Rn(t,e){for(let n=0;n<t.length;n++){let{dom:r,top:o,left:i}=t[n];r.scrollTop!=o+e&&(r.scrollTop=o+e),r.scrollLeft!=i&&(r.scrollLeft=i)}}let In=null;function Ln(t,e){let n,r,o,i,s=2e8,a=0,l=e.top,c=e.top;for(let d=t.firstChild,h=0;d;d=d.nextSibling,h++){let t;if(1==d.nodeType)t=d.getClientRects();else{if(3!=d.nodeType)continue;t=Ze(d).getClientRects()}for(let u=0;u<t.length;u++){let p=t[u];if(p.top<=l&&p.bottom>=c){l=Math.max(p.bottom,l),c=Math.min(p.top,c);let t=p.left>e.left?p.left-e.left:p.right<e.left?e.left-p.right:0;if(t<s){n=d,s=t,r=t&&3==n.nodeType?{left:p.right<e.left?p.right:p.left,top:e.top}:e,1==d.nodeType&&t&&(a=h+(e.left>=(p.left+p.right)/2?1:0));continue}}else p.top>e.top&&!o&&p.left<=e.left&&p.right>=e.left&&(o=d,i={left:Math.max(p.left,Math.min(p.right,e.left)),top:p.top});!n&&(e.left>=p.right&&e.top>=p.top||e.left>=p.left&&e.top>=p.bottom)&&(a=h+1)}}return!n&&o&&(n=o,r=i,s=0),n&&3==n.nodeType?function(t,e){let n=t.nodeValue.length,r=document.createRange();for(let o=0;o<n;o++){r.setEnd(t,o+1),r.setStart(t,o);let n=Bn(r,1);if(n.top!=n.bottom&&Pn(e,n))return{node:t,offset:o+(e.left>=(n.left+n.right)/2?1:0)}}return{node:t,offset:0}}(n,r):!n||s&&1==n.nodeType?{node:t,offset:a}:Ln(n,r)}function Pn(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function jn(t,e,n){let r=t.childNodes.length;if(r&&n.top<n.bottom)for(let o=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-n.top)/(n.bottom-n.top))-2)),i=o;;){let n=t.childNodes[i];if(1==n.nodeType){let t=n.getClientRects();for(let r=0;r<t.length;r++){let o=t[r];if(Pn(e,o))return jn(n,e,o)}}if((i=(i+1)%r)==o)break}return t}function zn(t,e){let n,r=t.dom.ownerDocument,o=0,i=function(t,e,n){if(t.caretPositionFromPoint)try{let r=t.caretPositionFromPoint(e,n);if(r)return{node:r.offsetNode,offset:r.offset}}catch{}if(t.caretRangeFromPoint){let r=t.caretRangeFromPoint(e,n);if(r)return{node:r.startContainer,offset:r.startOffset}}}(r,e.left,e.top);i&&({node:n,offset:o}=i);let s,a=(t.root.elementFromPoint?t.root:r).elementFromPoint(e.left,e.top);if(!a||!t.dom.contains(1!=a.nodeType?a.parentNode:a)){let n=t.dom.getBoundingClientRect();if(!Pn(e,n)||(a=jn(t.dom,e,n),!a))return null}if(wn)for(let t=a;n&&t;t=Qe(t))t.draggable&&(n=void 0);if(a=function(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left<t.getBoundingClientRect().left?n:t}(a,e),n){if(gn&&1==n.nodeType&&(o=Math.min(o,n.childNodes.length),o<n.childNodes.length)){let t,r=n.childNodes[o];"IMG"==r.nodeName&&(t=r.getBoundingClientRect()).right<=e.left&&t.bottom>e.top&&o++}let r;Cn&&o&&1==n.nodeType&&1==(r=n.childNodes[o-1]).nodeType&&"false"==r.contentEditable&&r.getBoundingClientRect().top>=e.top&&o--,n==t.dom&&o==n.childNodes.length-1&&1==n.lastChild.nodeType&&e.top>n.lastChild.getBoundingClientRect().bottom?s=t.state.doc.content.size:(0==o||1!=n.nodeType||"BR"!=n.childNodes[o-1].nodeName)&&(s=function(t,e,n,r){let o=-1;for(let n=e,i=!1;n!=t.dom;){let e=t.docView.nearestDesc(n,!0);if(!e)return null;if(1==e.dom.nodeType&&(e.node.isBlock&&e.parent||!e.contentDOM)){let t=e.dom.getBoundingClientRect();if(e.node.isBlock&&e.parent&&(!i&&t.left>r.left||t.top>r.top?o=e.posBefore:(!i&&t.right<r.left||t.bottom<r.top)&&(o=e.posAfter),i=!0),!e.contentDOM&&o<0&&!e.node.isText)return(e.node.isBlock?r.top<(t.top+t.bottom)/2:r.left<(t.left+t.right)/2)?e.posBefore:e.posAfter}n=e.dom.parentNode}return o>-1?o:t.docView.posFromDOM(e,n,-1)}(t,n,o,e))}null==s&&(s=function(t,e,n){let{node:r,offset:o}=Ln(e,n),i=-1;if(1==r.nodeType&&!r.firstChild){let t=r.getBoundingClientRect();i=t.left!=t.right&&n.left>(t.left+t.right)/2?1:-1}return t.docView.posFromDOM(r,o,i)}(t,a,e));let l=t.docView.nearestDesc(a,!0);return{pos:s,inside:l?l.posAtStart-l.border:-1}}function $n(t){return t.top<t.bottom||t.left<t.right}function Bn(t,e){let n=t.getClientRects();if(n.length){let t=n[e<0?0:n.length-1];if($n(t))return t}return Array.prototype.find.call(n,$n)||t.getBoundingClientRect()}const Fn=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function _n(t,e,n){let{node:r,offset:o,atom:i}=t.docView.domFromPos(e,n<0?-1:1),s=Cn||gn;if(3==r.nodeType){if(!s||!Fn.test(r.nodeValue)&&(n<0?o:o!=r.nodeValue.length)){let t=o,e=o,i=n<0?1:-1;return n<0&&!o?(e++,i=-1):n>=0&&o==r.nodeValue.length?(t--,i=1):n<0?t--:e++,Vn(Bn(Ze(r,t,e),i),i<0)}{let t=Bn(Ze(r,o,o),n);if(gn&&o&&/\s/.test(r.nodeValue[o-1])&&o<r.nodeValue.length){let e=Bn(Ze(r,o-1,o-1),-1);if(e.top==t.top){let n=Bn(Ze(r,o,o+1),-1);if(n.top!=t.top)return Vn(n,n.left<e.left)}}return t}}if(!t.state.doc.resolve(e-(i||0)).parent.inlineContent){if(null==i&&o&&(n<0||o==rn(r))){let t=r.childNodes[o-1];if(1==t.nodeType)return Hn(t.getBoundingClientRect(),!1)}if(null==i&&o<rn(r)){let t=r.childNodes[o];if(1==t.nodeType)return Hn(t.getBoundingClientRect(),!0)}return Hn(r.getBoundingClientRect(),n>=0)}if(null==i&&o&&(n<0||o==rn(r))){let t=r.childNodes[o-1],e=3==t.nodeType?Ze(t,rn(t)-(s?0:1)):1!=t.nodeType||"BR"==t.nodeName&&t.nextSibling?null:t;if(e)return Vn(Bn(e,1),!1)}if(null==i&&o<rn(r)){let t=r.childNodes[o];for(;t.pmViewDesc&&t.pmViewDesc.ignoreForCoords;)t=t.nextSibling;let e=t?3==t.nodeType?Ze(t,0,s?0:1):1==t.nodeType?t:null:null;if(e)return Vn(Bn(e,-1),!0)}return Vn(Bn(3==r.nodeType?Ze(r):r,-n),n>=0)}function Vn(t,e){if(0==t.width)return t;let n=e?t.left:t.right;return{top:t.top,bottom:t.bottom,left:n,right:n}}function Hn(t,e){if(0==t.height)return t;let n=e?t.top:t.bottom;return{top:n,bottom:n,left:t.left,right:t.right}}function Wn(t,e,n){let r=t.state,o=t.root.activeElement;r!=e&&t.updateState(e),o!=t.dom&&t.focus();try{return n()}finally{r!=e&&t.updateState(r),o!=t.dom&&o&&o.focus()}}const Kn=/[\u0590-\u08ac]/;let qn=null,Jn=null,Un=!1;function Gn(t,e,n){return qn==e&&Jn==n?Un:(qn=e,Jn=n,Un="up"==n||"down"==n?function(t,e,n){let r=e.selection,o="up"==n?r.$from:r.$to;return Wn(t,e,(()=>{let{node:e}=t.docView.domFromPos(o.pos,"up"==n?-1:1);for(;;){let n=t.docView.nearestDesc(e,!0);if(!n)break;if(n.node.isBlock){e=n.contentDOM||n.dom;break}e=n.dom.parentNode}let r=_n(t,o.pos,1);for(let t=e.firstChild;t;t=t.nextSibling){let e;if(1==t.nodeType)e=t.getClientRects();else{if(3!=t.nodeType)continue;e=Ze(t,0,t.nodeValue.length).getClientRects()}for(let t=0;t<e.length;t++){let o=e[t];if(o.bottom>o.top+1&&("up"==n?r.top-o.top>2*(o.bottom-r.top):o.bottom-r.bottom>2*(r.bottom-o.top)))return!1}}return!0}))}(t,e,n):function(t,e,n){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let o=r.parentOffset,i=!o,s=o==r.parent.content.size,a=t.domSelection();return a?Kn.test(r.parent.textContent)&&a.modify?Wn(t,e,(()=>{let{focusNode:e,focusOffset:o,anchorNode:i,anchorOffset:s}=t.domSelectionRange(),l=a.caretBidiLevel;a.modify("move",n,"character");let c=r.depth?t.docView.domAfterPos(r.before()):t.dom,{focusNode:d,focusOffset:h}=t.domSelectionRange(),u=d&&!c.contains(1==d.nodeType?d:d.parentNode)||e==d&&o==h;try{a.collapse(i,s),e&&(e!=i||o!=s)&&a.extend&&a.extend(e,o)}catch{}return null!=l&&(a.caretBidiLevel=l),u})):"left"==n||"backward"==n?i:s:r.pos==r.start()||r.pos==r.end()}(t,e,n))}class Yn{constructor(t,e,n,r){this.parent=t,this.children=e,this.dom=n,this.contentDOM=r,this.dirty=0,n.pmViewDesc=this}matchesWidget(t){return!1}matchesMark(t){return!1}matchesNode(t,e,n){return!1}matchesHack(t){return!1}parseRule(){return null}stopEvent(t){return!1}get size(){let t=0;for(let e=0;e<this.children.length;e++)t+=this.children[e].size;return t}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let t=0;t<this.children.length;t++)this.children[t].destroy()}posBeforeChild(t){for(let e=0,n=this.posAtStart;;e++){let r=this.children[e];if(r==t)return n;n+=r.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(t,e,n){if(this.contentDOM&&this.contentDOM.contains(1==t.nodeType?t:t.parentNode)){if(n<0){let n,r;if(t==this.contentDOM)n=t.childNodes[e-1];else{for(;t.parentNode!=this.contentDOM;)t=t.parentNode;n=t.previousSibling}for(;n&&(!(r=n.pmViewDesc)||r.parent!=this);)n=n.previousSibling;return n?this.posBeforeChild(r)+r.size:this.posAtStart}{let n,r;if(t==this.contentDOM)n=t.childNodes[e];else{for(;t.parentNode!=this.contentDOM;)t=t.parentNode;n=t.nextSibling}for(;n&&(!(r=n.pmViewDesc)||r.parent!=this);)n=n.nextSibling;return n?this.posBeforeChild(r):this.posAtEnd}}let r;if(t==this.dom&&this.contentDOM)r=e>Ye(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))r=2&t.compareDocumentPosition(this.contentDOM);else if(this.dom.firstChild){if(0==e)for(let e=t;;e=e.parentNode){if(e==this.dom){r=!1;break}if(e.previousSibling)break}if(null==r&&e==t.childNodes.length)for(let e=t;;e=e.parentNode){if(e==this.dom){r=!0;break}if(e.nextSibling)break}}return r??n>0?this.posAtEnd:this.posAtStart}nearestDesc(t,e=!1){for(let n=!0,r=t;r;r=r.parentNode){let o,i=this.getDesc(r);if(i&&(!e||i.node)){if(!n||!(o=i.nodeDOM)||(1==o.nodeType?o.contains(1==t.nodeType?t:t.parentNode):o==t))return i;n=!1}}}getDesc(t){let e=t.pmViewDesc;for(let t=e;t;t=t.parent)if(t==this)return e}posFromDOM(t,e,n){for(let r=t;r;r=r.parentNode){let o=this.getDesc(r);if(o)return o.localPosFromDOM(t,e,n)}return-1}descAt(t){for(let e=0,n=0;e<this.children.length;e++){let r=this.children[e],o=n+r.size;if(n==t&&o!=n){for(;!r.border&&r.children.length;)r=r.children[0];return r}if(t<o)return r.descAt(t-n-r.border);n=o}}domFromPos(t,e){if(!this.contentDOM)return{node:this.dom,offset:0,atom:t+1};let n=0,r=0;for(let e=0;n<this.children.length;n++){let o=this.children[n],i=e+o.size;if(i>t||o instanceof rr){r=t-e;break}e=i}if(r)return this.children[n].domFromPos(r-this.children[n].border,e);for(let t;n&&!(t=this.children[n-1]).size&&t instanceof Qn&&t.side>=0;n--);if(e<=0){let t,r=!0;for(;t=n?this.children[n-1]:null,t&&t.dom.parentNode!=this.contentDOM;n--,r=!1);return t&&e&&r&&!t.border&&!t.domAtom?t.domFromPos(t.size,e):{node:this.contentDOM,offset:t?Ye(t.dom)+1:0}}{let t,r=!0;for(;t=n<this.children.length?this.children[n]:null,t&&t.dom.parentNode!=this.contentDOM;n++,r=!1);return t&&r&&!t.border&&!t.domAtom?t.domFromPos(0,e):{node:this.contentDOM,offset:t?Ye(t.dom):this.contentDOM.childNodes.length}}}parseRange(t,e,n=0){if(0==this.children.length)return{node:this.contentDOM,from:t,to:e,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let r=-1,o=-1;for(let i=n,s=0;;s++){let n=this.children[s],a=i+n.size;if(-1==r&&t<=a){let o=i+n.border;if(t>=o&&e<=a-n.border&&n.node&&n.contentDOM&&this.contentDOM.contains(n.contentDOM))return n.parseRange(t,e,o);t=i;for(let e=s;e>0;e--){let n=this.children[e-1];if(n.size&&n.dom.parentNode==this.contentDOM&&!n.emptyChildAt(1)){r=Ye(n.dom)+1;break}t-=n.size}-1==r&&(r=0)}if(r>-1&&(a>e||s==this.children.length-1)){e=a;for(let t=s+1;t<this.children.length;t++){let n=this.children[t];if(n.size&&n.dom.parentNode==this.contentDOM&&!n.emptyChildAt(-1)){o=Ye(n.dom);break}e+=n.size}-1==o&&(o=this.contentDOM.childNodes.length);break}i=a}return{node:this.contentDOM,from:t,to:e,fromOffset:r,toOffset:o}}emptyChildAt(t){if(this.border||!this.contentDOM||!this.children.length)return!1;let e=this.children[t<0?0:this.children.length-1];return 0==e.size||e.emptyChildAt(t)}domAfterPos(t){let{node:e,offset:n}=this.domFromPos(t,0);if(1!=e.nodeType||n==e.childNodes.length)throw new RangeError("No node after pos "+t);return e.childNodes[n]}setSelection(t,e,n,r=!1){let o=Math.min(t,e),i=Math.max(t,e);for(let s=0,a=0;s<this.children.length;s++){let l=this.children[s],c=a+l.size;if(o>a&&i<c)return l.setSelection(t-a-l.border,e-a-l.border,n,r);a=c}let s=this.domFromPos(t,t?-1:1),a=e==t?s:this.domFromPos(e,e?-1:1),l=n.getSelection(),c=!1;if((gn||wn)&&t==e){let{node:t,offset:e}=s;if(3==t.nodeType){if(c=!(!e||"\n"!=t.nodeValue[e-1]),c&&e==t.nodeValue.length)for(let e,n=t;n;n=n.parentNode){if(e=n.nextSibling){"BR"==e.nodeName&&(s=a={node:e.parentNode,offset:Ye(e)+1});break}let t=n.pmViewDesc;if(t&&t.node&&t.node.isBlock)break}}else{let n=t.childNodes[e-1];c=n&&("BR"==n.nodeName||"false"==n.contentEditable)}}if(gn&&l.focusNode&&l.focusNode!=a.node&&1==l.focusNode.nodeType){let t=l.focusNode.childNodes[l.focusOffset];t&&"false"==t.contentEditable&&(r=!0)}if(!(r||c&&wn)&&tn(s.node,s.offset,l.anchorNode,l.anchorOffset)&&tn(a.node,a.offset,l.focusNode,l.focusOffset))return;let d=!1;if((l.extend||t==e)&&!c){l.collapse(s.node,s.offset);try{t!=e&&l.extend(a.node,a.offset),d=!0}catch{}}if(!d){if(t>e){let t=s;s=a,a=t}let n=document.createRange();n.setEnd(a.node,a.offset),n.setStart(s.node,s.offset),l.removeAllRanges(),l.addRange(n)}}ignoreMutation(t){return!this.contentDOM&&"selection"!=t.type}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(t,e){for(let n=0,r=0;r<this.children.length;r++){let o=this.children[r],i=n+o.size;if(n==i?t<=i&&e>=n:t<i&&e>n){let r=n+o.border,s=i-o.border;if(t>=r&&e<=s)return this.dirty=t==n||e==i?2:1,void(t!=r||e!=s||!o.contentLost&&o.dom.parentNode==this.contentDOM?o.markDirty(t-r,e-r):o.dirty=3);o.dirty=o.dom!=o.contentDOM||o.dom.parentNode!=this.contentDOM||o.children.length?3:2}n=i}this.dirty=2}markParentsDirty(){let t=1;for(let e=this.parent;e;e=e.parent,t++){let n=1==t?2:1;e.dirty<n&&(e.dirty=n)}}get domAtom(){return!1}get ignoreForCoords(){return!1}isText(t){return!1}}class Qn extends Yn{constructor(t,e,n,r){let o,i=e.type.toDOM;if("function"==typeof i&&(i=i(n,(()=>o?o.parent?o.parent.posBeforeChild(o):void 0:r))),!e.type.spec.raw){if(1!=i.nodeType){let t=document.createElement("span");t.appendChild(i),i=t}i.contentEditable="false",i.classList.add("ProseMirror-widget")}super(t,[],i,null),this.widget=e,this.widget=e,o=this}matchesWidget(t){return 0==this.dirty&&t.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(t){let e=this.widget.spec.stopEvent;return!!e&&e(t)}ignoreMutation(t){return"selection"!=t.type||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get side(){return this.widget.type.side}}class Xn extends Yn{constructor(t,e,n,r){super(t,[],e,null),this.textDOM=n,this.text=r}get size(){return this.text.length}localPosFromDOM(t,e){return t!=this.textDOM?this.posAtStart+(e?this.size:0):this.posAtStart+e}domFromPos(t){return{node:this.textDOM,offset:t}}ignoreMutation(t){return"characterData"===t.type&&t.target.nodeValue==t.oldValue}}class Zn extends Yn{constructor(t,e,n,r){super(t,[],n,r),this.mark=e}static create(t,e,n,r){let o=r.nodeViews[e.type.name],i=o&&o(e,r,n);return(!i||!i.dom)&&(i=It.renderSpec(document,e.type.spec.toDOM(e,n),null,e.attrs)),new Zn(t,e,i.dom,i.contentDOM||i.dom)}parseRule(){return 3&this.dirty||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(t){return 3!=this.dirty&&this.mark.eq(t)}markDirty(t,e){if(super.markDirty(t,e),0!=this.dirty){let t=this.parent;for(;!t.node;)t=t.parent;t.dirty<this.dirty&&(t.dirty=this.dirty),this.dirty=0}}slice(t,e,n){let r=Zn.create(this.parent,this.mark,!0,n),o=this.children,i=this.size;e<i&&(o=gr(o,e,i,n)),t>0&&(o=gr(o,0,t,n));for(let t=0;t<o.length;t++)o[t].parent=r;return r.children=o,r}}class tr extends Yn{constructor(t,e,n,r,o,i,s,a,l){super(t,[],o,i),this.node=e,this.outerDeco=n,this.innerDeco=r,this.nodeDOM=s}static create(t,e,n,r,o,i){let s,a=o.nodeViews[e.type.name],l=a&&a(e,o,(()=>s?s.parent?s.parent.posBeforeChild(s):void 0:i),n,r),c=l&&l.dom,d=l&&l.contentDOM;if(e.isText)if(c){if(3!=c.nodeType)throw new RangeError("Text must be rendered as a DOM text node")}else c=document.createTextNode(e.text);else c||({dom:c,contentDOM:d}=It.renderSpec(document,e.type.spec.toDOM(e),null,e.attrs));!d&&!e.isText&&"BR"!=c.nodeName&&(c.hasAttribute("contenteditable")||(c.contentEditable="false"),e.type.spec.draggable&&(c.draggable=!0));let h=c;return c=hr(c,n,e),l?s=new or(t,e,n,r,c,d||null,h,l,o,i+1):e.isText?new nr(t,e,n,r,c,h,o):new tr(t,e,n,r,c,d||null,h,o,i+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let t={node:this.node.type.name,attrs:this.node.attrs};if("pre"==this.node.type.whitespace&&(t.preserveWhitespace="full"),this.contentDOM)if(this.contentLost){for(let e=this.children.length-1;e>=0;e--){let n=this.children[e];if(this.dom.contains(n.dom.parentNode)){t.contentElement=n.dom.parentNode;break}}t.contentElement||(t.getContent=()=>R.empty)}else t.contentElement=this.contentDOM;else t.getContent=()=>this.node.content;return t}matchesNode(t,e,n){return 0==this.dirty&&t.eq(this.node)&&ur(e,this.outerDeco)&&n.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(t,e){let n=this.node.inlineContent,r=e,o=t.composing?this.localCompositionInfo(t,e):null,i=o&&o.pos>-1?o:null,s=o&&o.pos<0,a=new fr(this,i&&i.node,t);(function(t,e,n,r){let o=e.locals(t),i=0;if(0==o.length){for(let n=0;n<t.childCount;n++){let s=t.child(n);r(s,o,e.forChild(i,s),n),i+=s.nodeSize}return}let s=0,a=[],l=null;for(let c=0;;){let d,h,u,p;for(;s<o.length&&o[s].to==i;){let t=o[s++];t.widget&&(d?(h||(h=[d])).push(t):d=t)}if(d)if(h){h.sort(mr);for(let t=0;t<h.length;t++)n(h[t],c,!!l)}else n(d,c,!!l);if(l)p=-1,u=l,l=null;else{if(!(c<t.childCount))break;p=c,u=t.child(c++)}for(let t=0;t<a.length;t++)a[t].to<=i&&a.splice(t--,1);for(;s<o.length&&o[s].from<=i&&o[s].to>i;)a.push(o[s++]);let f=i+u.nodeSize;if(u.isText){let t=f;s<o.length&&o[s].from<t&&(t=o[s].from);for(let e=0;e<a.length;e++)a[e].to<t&&(t=a[e].to);t<f&&(l=u.cut(t-i),u=u.cut(0,t-i),f=t,p=-1)}else for(;s<o.length&&o[s].to<f;)s++;r(u,u.isInline&&!u.isLeaf?a.filter((t=>!t.inline)):a.slice(),e.forChild(i,u),p),i=f}})(this.node,this.innerDeco,((e,o,i)=>{e.spec.marks?a.syncToMarks(e.spec.marks,n,t):e.type.side>=0&&!i&&a.syncToMarks(o==this.node.childCount?j.none:this.node.child(o).marks,n,t),a.placeWidget(e,t,r)}),((e,i,l,c)=>{let d;a.syncToMarks(e.marks,n,t),a.findNodeMatch(e,i,l,c)||s&&t.state.selection.from>r&&t.state.selection.to<r+e.nodeSize&&(d=a.findIndexWithChild(o.node))>-1&&a.updateNodeAt(e,i,l,d,t)||a.updateNextNode(e,i,l,t,c,r)||a.addNode(e,i,l,t,r),r+=e.nodeSize})),a.syncToMarks([],n,t),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||2==this.dirty)&&(i&&this.protectLocalComposition(t,i),ir(this.contentDOM,this.children,t),kn&&function(t){if("UL"==t.nodeName||"OL"==t.nodeName){let e=t.style.cssText;t.style.cssText=e+"; list-style: square !important",window.getComputedStyle(t).listStyle,t.style.cssText=e}}(this.dom))}localCompositionInfo(t,e){let{from:n,to:r}=t.state.selection;if(!(t.state.selection instanceof De)||n<e||r>e+this.node.content.size)return null;let o=t.input.compositionNode;if(!o||!this.dom.contains(o.parentNode))return null;if(this.node.inlineContent){let t=o.nodeValue,i=function(t,e,n,r){for(let o=0,i=0;o<t.childCount&&i<=r;){let s=t.child(o++),a=i;if(i+=s.nodeSize,!s.isText)continue;let l=s.text;for(;o<t.childCount;){let e=t.child(o++);if(i+=e.nodeSize,!e.isText)break;l+=e.text}if(i>=n){if(i>=r&&l.slice(r-e.length-a,r-a)==e)return r-e.length;let t=a<r?l.lastIndexOf(e,r-a-1):-1;if(t>=0&&t+e.length+a>=n)return a+t;if(n==r&&l.length>=r+e.length-a&&l.slice(r-a,r-a+e.length)==e)return r}}return-1}(this.node.content,t,n-e,r-e);return i<0?null:{node:o,pos:i,text:t}}return{node:o,pos:-1,text:""}}protectLocalComposition(t,{node:e,pos:n,text:r}){if(this.getDesc(e))return;let o=e;for(;o.parentNode!=this.contentDOM;o=o.parentNode){for(;o.previousSibling;)o.parentNode.removeChild(o.previousSibling);for(;o.nextSibling;)o.parentNode.removeChild(o.nextSibling);o.pmViewDesc&&(o.pmViewDesc=void 0)}let i=new Xn(this,o,e,r);t.input.compositionNodes.push(i),this.children=gr(this.children,n,n+r.length,t,i)}update(t,e,n,r){return!(3==this.dirty||!t.sameMarkup(this.node))&&(this.updateInner(t,e,n,r),!0)}updateInner(t,e,n,r){this.updateOuterDeco(e),this.node=t,this.innerDeco=n,this.contentDOM&&this.updateChildren(r,this.posAtStart),this.dirty=0}updateOuterDeco(t){if(ur(t,this.outerDeco))return;let e=1!=this.nodeDOM.nodeType,n=this.dom;this.dom=cr(this.dom,this.nodeDOM,lr(this.outerDeco,this.node,e),lr(t,this.node,e)),this.dom!=n&&(n.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=t}selectNode(){1==this.nodeDOM.nodeType&&this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.dom.draggable=!0)}deselectNode(){1==this.nodeDOM.nodeType&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.dom.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function er(t,e,n,r,o){hr(r,e,t);let i=new tr(void 0,t,e,n,r,r,r,o,0);return i.contentDOM&&i.updateChildren(o,0),i}class nr extends tr{constructor(t,e,n,r,o,i,s){super(t,e,n,r,o,null,i,s,0)}parseRule(){let t=this.nodeDOM.parentNode;for(;t&&t!=this.dom&&!t.pmIsDeco;)t=t.parentNode;return{skip:t||!0}}update(t,e,n,r){return!(3==this.dirty||0!=this.dirty&&!this.inParent()||!t.sameMarkup(this.node))&&(this.updateOuterDeco(e),(0!=this.dirty||t.text!=this.node.text)&&t.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=t.text,r.trackWrites==this.nodeDOM&&(r.trackWrites=null)),this.node=t,this.dirty=0,!0)}inParent(){let t=this.parent.contentDOM;for(let e=this.nodeDOM;e;e=e.parentNode)if(e==t)return!0;return!1}domFromPos(t){return{node:this.nodeDOM,offset:t}}localPosFromDOM(t,e,n){return t==this.nodeDOM?this.posAtStart+Math.min(e,this.node.text.length):super.localPosFromDOM(t,e,n)}ignoreMutation(t){return"characterData"!=t.type&&"selection"!=t.type}slice(t,e,n){let r=this.node.cut(t,e),o=document.createTextNode(r.text);return new nr(this.parent,r,this.outerDeco,this.innerDeco,o,o,n)}markDirty(t,e){super.markDirty(t,e),this.dom!=this.nodeDOM&&(0==t||e==this.nodeDOM.nodeValue.length)&&(this.dirty=3)}get domAtom(){return!1}isText(t){return this.node.text==t}}class rr extends Yn{parseRule(){return{ignore:!0}}matchesHack(t){return 0==this.dirty&&this.dom.nodeName==t}get domAtom(){return!0}get ignoreForCoords(){return"IMG"==this.dom.nodeName}}class or extends tr{constructor(t,e,n,r,o,i,s,a,l,c){super(t,e,n,r,o,i,s,l,c),this.spec=a}update(t,e,n,r){if(3==this.dirty)return!1;if(this.spec.update){let o=this.spec.update(t,e,n);return o&&this.updateInner(t,e,n,r),o}return!(!this.contentDOM&&!t.isLeaf)&&super.update(t,e,n,r)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(t,e,n,r){this.spec.setSelection?this.spec.setSelection(t,e,n):super.setSelection(t,e,n,r)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(t){return!!this.spec.stopEvent&&this.spec.stopEvent(t)}ignoreMutation(t){return this.spec.ignoreMutation?this.spec.ignoreMutation(t):super.ignoreMutation(t)}}function ir(t,e,n){let r=t.firstChild,o=!1;for(let i=0;i<e.length;i++){let s=e[i],a=s.dom;if(a.parentNode==t){for(;a!=r;)r=pr(r),o=!0;r=r.nextSibling}else o=!0,t.insertBefore(a,r);if(s instanceof Zn){let e=r?r.previousSibling:t.lastChild;ir(s.contentDOM,s.children,n),r=e?e.nextSibling:t.firstChild}}for(;r;)r=pr(r),o=!0;o&&n.trackWrites==t&&(n.trackWrites=null)}const sr=function(t){t&&(this.nodeName=t)};sr.prototype=Object.create(null);const ar=[new sr];function lr(t,e,n){if(0==t.length)return ar;let r=n?ar[0]:new sr,o=[r];for(let i=0;i<t.length;i++){let s=t[i].type.attrs;if(s){s.nodeName&&o.push(r=new sr(s.nodeName));for(let t in s){let i=s[t];null!=i&&(n&&1==o.length&&o.push(r=new sr(e.isInline?"span":"div")),"class"==t?r.class=(r.class?r.class+" ":"")+i:"style"==t?r.style=(r.style?r.style+";":"")+i:"nodeName"!=t&&(r[t]=i))}}}return o}function cr(t,e,n,r){if(n==ar&&r==ar)return e;let o=e;for(let e=0;e<r.length;e++){let i=r[e],s=n[e];if(e){let e;s&&s.nodeName==i.nodeName&&o!=t&&(e=o.parentNode)&&e.nodeName.toLowerCase()==i.nodeName||(e=document.createElement(i.nodeName),e.pmIsDeco=!0,e.appendChild(o),s=ar[0]),o=e}dr(o,s||ar[0],i)}return o}function dr(t,e,n){for(let r in e)"class"!=r&&"style"!=r&&"nodeName"!=r&&!(r in n)&&t.removeAttribute(r);for(let r in n)"class"!=r&&"style"!=r&&"nodeName"!=r&&n[r]!=e[r]&&t.setAttribute(r,n[r]);if(e.class!=n.class){let r=e.class?e.class.split(" ").filter(Boolean):[],o=n.class?n.class.split(" ").filter(Boolean):[];for(let e=0;e<r.length;e++)-1==o.indexOf(r[e])&&t.classList.remove(r[e]);for(let e=0;e<o.length;e++)-1==r.indexOf(o[e])&&t.classList.add(o[e]);0==t.classList.length&&t.removeAttribute("class")}if(e.style!=n.style){if(e.style){let n,r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g;for(;n=r.exec(e.style);)t.style.removeProperty(n[1])}n.style&&(t.style.cssText+=n.style)}}function hr(t,e,n){return cr(t,t,ar,lr(e,n,1!=t.nodeType))}function ur(t,e){if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++)if(!t[n].type.eq(e[n].type))return!1;return!0}function pr(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class fr{constructor(t,e,n){this.lock=e,this.view=n,this.index=0,this.stack=[],this.changed=!1,this.top=t,this.preMatch=function(t,e){let n=e,r=n.children.length,o=t.childCount,i=new Map,s=[];t:for(;o>0;){let a;for(;;)if(r){let t=n.children[r-1];if(!(t instanceof Zn)){a=t,r--;break}n=t,r=t.children.length}else{if(n==e)break t;r=n.parent.children.indexOf(n),n=n.parent}let l=a.node;if(l){if(l!=t.child(o-1))break;--o,i.set(a,o),s.push(a)}}return{index:o,matched:i,matches:s.reverse()}}(t.node.content,t)}destroyBetween(t,e){if(t!=e){for(let n=t;n<e;n++)this.top.children[n].destroy();this.top.children.splice(t,e-t),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(t,e,n){let r=0,o=this.stack.length>>1,i=Math.min(o,t.length);for(;r<i&&(r==o-1?this.top:this.stack[r+1<<1]).matchesMark(t[r])&&!1!==t[r].type.spec.spanning;)r++;for(;r<o;)this.destroyRest(),this.top.dirty=0,this.index=this.stack.pop(),this.top=this.stack.pop(),o--;for(;o<t.length;){this.stack.push(this.top,this.index+1);let r=-1;for(let e=this.index;e<Math.min(this.index+3,this.top.children.length);e++){let n=this.top.children[e];if(n.matchesMark(t[o])&&!this.isLocked(n.dom)){r=e;break}}if(r>-1)r>this.index&&(this.changed=!0,this.destroyBetween(this.index,r)),this.top=this.top.children[this.index];else{let r=Zn.create(this.top,t[o],e,n);this.top.children.splice(this.index,0,r),this.top=r,this.changed=!0}this.index=0,o++}}findNodeMatch(t,e,n,r){let o,i=-1;if(r>=this.preMatch.index&&(o=this.preMatch.matches[r-this.preMatch.index]).parent==this.top&&o.matchesNode(t,e,n))i=this.top.children.indexOf(o,this.index);else for(let r=this.index,o=Math.min(this.top.children.length,r+5);r<o;r++){let o=this.top.children[r];if(o.matchesNode(t,e,n)&&!this.preMatch.matched.has(o)){i=r;break}}return!(i<0)&&(this.destroyBetween(this.index,i),this.index++,!0)}updateNodeAt(t,e,n,r,o){let i=this.top.children[r];return 3==i.dirty&&i.dom==i.contentDOM&&(i.dirty=2),!!i.update(t,e,n,o)&&(this.destroyBetween(this.index,r),this.index++,!0)}findIndexWithChild(t){for(;;){let e=t.parentNode;if(!e)return-1;if(e==this.top.contentDOM){let e=t.pmViewDesc;if(e)for(let t=this.index;t<this.top.children.length;t++)if(this.top.children[t]==e)return t;return-1}t=e}}updateNextNode(t,e,n,r,o,i){for(let s=this.index;s<this.top.children.length;s++){let a=this.top.children[s];if(a instanceof tr){let l=this.preMatch.matched.get(a);if(null!=l&&l!=o)return!1;let c,d=a.dom,h=this.isLocked(d)&&!(t.isText&&a.node&&a.node.isText&&a.nodeDOM.nodeValue==t.text&&3!=a.dirty&&ur(e,a.outerDeco));if(!h&&a.update(t,e,n,r))return this.destroyBetween(this.index,s),a.dom!=d&&(this.changed=!0),this.index++,!0;if(!h&&(c=this.recreateWrapper(a,t,e,n,r,i)))return this.top.children[this.index]=c,c.contentDOM&&(c.dirty=2,c.updateChildren(r,i+1),c.dirty=0),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(t,e,n,r,o,i){if(t.dirty||e.isAtom||!t.children.length||!t.node.content.eq(e.content))return null;let s=tr.create(this.top,e,n,r,o,i);if(s.contentDOM){s.children=t.children,t.children=[];for(let t of s.children)t.parent=s}return t.destroy(),s}addNode(t,e,n,r,o){let i=tr.create(this.top,t,e,n,r,o);i.contentDOM&&i.updateChildren(r,o+1),this.top.children.splice(this.index++,0,i),this.changed=!0}placeWidget(t,e,n){let r=this.index<this.top.children.length?this.top.children[this.index]:null;if(!r||!r.matchesWidget(t)||t!=r.widget&&r.widget.type.toDOM.parentNode){let r=new Qn(this.top,t,e,n);this.top.children.splice(this.index++,0,r),this.changed=!0}else this.index++}addTextblockHacks(){let t=this.top.children[this.index-1],e=this.top;for(;t instanceof Zn;)e=t,t=e.children[e.children.length-1];(!t||!(t instanceof nr)||/\n$/.test(t.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(t.node.text))&&((wn||bn)&&t&&"false"==t.dom.contentEditable&&this.addHackNode("IMG",e),this.addHackNode("BR",this.top))}addHackNode(t,e){if(e==this.top&&this.index<e.children.length&&e.children[this.index].matchesHack(t))this.index++;else{let n=document.createElement(t);"IMG"==t&&(n.className="ProseMirror-separator",n.alt=""),"BR"==t&&(n.className="ProseMirror-trailingBreak");let r=new rr(this.top,[],n,null);e!=this.top?e.children.push(r):e.children.splice(this.index++,0,r),this.changed=!0}}isLocked(t){return this.lock&&(t==this.lock||1==t.nodeType&&t.contains(this.lock.parentNode))}}function mr(t,e){return t.type.side-e.type.side}function gr(t,e,n,r,o){let i=[];for(let s=0,a=0;s<t.length;s++){let l=t[s],c=a,d=a+=l.size;c>=n||d<=e?i.push(l):(c<e&&i.push(l.slice(0,e-c,r)),o&&(i.push(o),o=void 0),d>n&&i.push(l.slice(n-c,l.size,r)))}return i}function yr(t,e=null){let n=t.domSelectionRange(),r=t.state.doc;if(!n.focusNode)return null;let o=t.docView.nearestDesc(n.focusNode),i=o&&0==o.size,s=t.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(s<0)return null;let a,l,c=r.resolve(s);if(sn(n)){for(a=c;o&&!o.node;)o=o.parent;let t=o.node;if(o&&t.isAtom&&Ie.isSelectable(t)&&o.parent&&(!t.isInline||!function(t,e,n){for(let r=0==e,o=e==rn(t);r||o;){if(t==n)return!0;let e=Ye(t);if(!(t=t.parentNode))return!1;r=r&&0==e,o=o&&e==rn(t)}}(n.focusNode,n.focusOffset,o.dom))){let t=o.posBefore;l=new Ie(s==t?c:r.resolve(t))}}else{let e=t.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(e<0)return null;a=r.resolve(e)}if(!l){l=Mr(t,a,c,"pointer"==e||t.state.selection.head<c.pos&&!i?1:-1)}return l}function br(t){return t.editable?t.hasFocus():Er(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function vr(t,e=!1){let n=t.state.selection;if(Or(t,n),br(t)){if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&bn){let e=t.domSelectionRange(),n=t.domObserver.currentSelection;if(e.anchorNode&&n.anchorNode&&tn(e.anchorNode,e.anchorOffset,n.anchorNode,n.anchorOffset))return t.input.mouseDown.delayedSelectionSync=!0,void t.domObserver.setCurSelection()}if(t.domObserver.disconnectSelection(),t.cursorWrapper)!function(t){let e=t.domSelection(),n=document.createRange();if(!e)return;let r=t.cursorWrapper.dom,o="IMG"==r.nodeName;o?n.setStart(r.parentNode,Ye(r)+1):n.setStart(r,0),n.collapse(!0),e.removeAllRanges(),e.addRange(n),!o&&!t.state.selection.visible&&fn&&mn<=11&&(r.disabled=!0,r.disabled=!1)}(t);else{let r,o,{anchor:i,head:s}=n;wr&&!(n instanceof De)&&(n.$from.parent.inlineContent||(r=kr(t,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(o=kr(t,n.to))),t.docView.setSelection(i,s,t.root,e),wr&&(r&&Sr(r),o&&Sr(o)),n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&function(t){let e=t.dom.ownerDocument;e.removeEventListener("selectionchange",t.input.hideSelectionGuard);let n=t.domSelectionRange(),r=n.anchorNode,o=n.anchorOffset;e.addEventListener("selectionchange",t.input.hideSelectionGuard=()=>{(n.anchorNode!=r||n.anchorOffset!=o)&&(e.removeEventListener("selectionchange",t.input.hideSelectionGuard),setTimeout((()=>{(!br(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")}),20))})}(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}}const wr=wn||bn&&vn<63;function kr(t,e){let{node:n,offset:r}=t.docView.domFromPos(e,0),o=r<n.childNodes.length?n.childNodes[r]:null,i=r?n.childNodes[r-1]:null;if(wn&&o&&"false"==o.contentEditable)return xr(o);if(!(o&&"false"!=o.contentEditable||i&&"false"!=i.contentEditable)){if(o)return xr(o);if(i)return xr(i)}}function xr(t){return t.contentEditable="true",wn&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function Sr(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function Or(t,e){if(e instanceof Ie){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(Cr(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else Cr(t)}function Cr(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function Mr(t,e,n,r){return t.someProp("createSelectionBetween",(r=>r(t,e,n)))||De.between(e,n,r)}function Tr(t){return!(t.editable&&!t.hasFocus())&&Er(t)}function Er(t){let e=t.domSelectionRange();if(!e.anchorNode)return!1;try{return t.dom.contains(3==e.anchorNode.nodeType?e.anchorNode.parentNode:e.anchorNode)&&(t.editable||t.dom.contains(3==e.focusNode.nodeType?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function Nr(t,e){let{$anchor:n,$head:r}=t.selection,o=e>0?n.max(r):n.min(r),i=o.parent.inlineContent?o.depth?t.doc.resolve(e>0?o.after():o.before()):null:o;return i&&Te.findFrom(i,e)}function Ar(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function Dr(t,e,n){let r=t.state.selection;if(!(r instanceof De)){if(r instanceof Ie&&r.node.isInline)return Ar(t,new De(e>0?r.$to:r.$from));{let n=Nr(t.state,e);return!!n&&Ar(t,n)}}if(n.indexOf("s")>-1){let{$head:n}=r,o=n.textOffset?null:e<0?n.nodeBefore:n.nodeAfter;if(!o||o.isText||!o.isLeaf)return!1;let i=t.state.doc.resolve(n.pos+o.nodeSize*(e<0?-1:1));return Ar(t,new De(r.$anchor,i))}if(!r.empty)return!1;if(t.endOfTextblock(e>0?"forward":"backward")){let n=Nr(t.state,e);return!!(n&&n instanceof Ie)&&Ar(t,n)}if(!(xn&&n.indexOf("m")>-1)){let n,o=r.$head,i=o.textOffset?null:e<0?o.nodeBefore:o.nodeAfter;if(!i||i.isText)return!1;let s=e<0?o.pos-i.nodeSize:o.pos;return!!(i.isAtom||(n=t.docView.descAt(s))&&!n.contentDOM)&&(Ie.isSelectable(i)?Ar(t,new Ie(e<0?t.state.doc.resolve(o.pos-i.nodeSize):o)):!!Cn&&Ar(t,new De(t.state.doc.resolve(e<0?s:s+i.nodeSize))))}}function Rr(t){return 3==t.nodeType?t.nodeValue.length:t.childNodes.length}function Ir(t,e){let n=t.pmViewDesc;return n&&0==n.size&&(e<0||t.nextSibling||"BR"!=t.nodeName)}function Lr(t,e){return e<0?function(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let o,i,s=!1;for(gn&&1==n.nodeType&&r<Rr(n)&&Ir(n.childNodes[r],-1)&&(s=!0);;)if(r>0){if(1!=n.nodeType)break;{let t=n.childNodes[r-1];if(Ir(t,-1))o=n,i=--r;else{if(3!=t.nodeType)break;n=t,r=n.nodeValue.length}}}else{if(Pr(n))break;{let e=n.previousSibling;for(;e&&Ir(e,-1);)o=n.parentNode,i=Ye(e),e=e.previousSibling;if(e)n=e,r=Rr(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}s?jr(t,n,r):o&&jr(t,o,i)}(t):function(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let o,i,s=Rr(n);for(;;)if(r<s){if(1!=n.nodeType)break;if(!Ir(n.childNodes[r],1))break;o=n,i=++r}else{if(Pr(n))break;{let e=n.nextSibling;for(;e&&Ir(e,1);)o=e.parentNode,i=Ye(e)+1,e=e.nextSibling;if(e)n=e,r=0,s=Rr(n);else{if(n=n.parentNode,n==t.dom)break;r=s=0}}}o&&jr(t,o,i)}(t)}function Pr(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function jr(t,e,n){if(3!=e.nodeType){let t,r;(r=function(t,e){for(;t&&e==t.childNodes.length&&!on(t);)e=Ye(t)+1,t=t.parentNode;for(;t&&e<t.childNodes.length;){let n=t.childNodes[e];if(3==n.nodeType)return n;if(1==n.nodeType&&"false"==n.contentEditable)break;t=n,e=0}}(e,n))?(e=r,n=0):(t=function(t,e){for(;t&&!e&&!on(t);)e=Ye(t),t=t.parentNode;for(;t&&e;){let n=t.childNodes[e-1];if(3==n.nodeType)return n;if(1==n.nodeType&&"false"==n.contentEditable)break;e=(t=n).childNodes.length}}(e,n))&&(e=t,n=t.nodeValue.length)}let r=t.domSelection();if(!r)return;if(sn(r)){let t=document.createRange();t.setEnd(e,n),t.setStart(e,n),r.removeAllRanges(),r.addRange(t)}else r.extend&&r.extend(e,n);t.domObserver.setCurSelection();let{state:o}=t;setTimeout((()=>{t.state==o&&vr(t)}),50)}function zr(t,e){let n=t.state.doc.resolve(e);if(!bn&&!Sn&&n.parent.inlineContent){let r=t.coordsAtPos(e);if(e>n.start()){let n=t.coordsAtPos(e-1),o=(n.top+n.bottom)/2;if(o>r.top&&o<r.bottom&&Math.abs(n.left-r.left)>1)return n.left<r.left?"ltr":"rtl"}if(e<n.end()){let n=t.coordsAtPos(e+1),o=(n.top+n.bottom)/2;if(o>r.top&&o<r.bottom&&Math.abs(n.left-r.left)>1)return n.left>r.left?"ltr":"rtl"}}return"rtl"==getComputedStyle(t.dom).direction?"rtl":"ltr"}function $r(t,e,n){let r=t.state.selection;if(r instanceof De&&!r.empty||n.indexOf("s")>-1||xn&&n.indexOf("m")>-1)return!1;let{$from:o,$to:i}=r;if(!o.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let n=Nr(t.state,e);if(n&&n instanceof Ie)return Ar(t,n)}if(!o.parent.inlineContent){let n=e<0?o:i,s=r instanceof Pe?Te.near(n,e):Te.findFrom(n,e);return!!s&&Ar(t,s)}return!1}function Br(t,e){if(!(t.state.selection instanceof De))return!0;let{$head:n,$anchor:r,empty:o}=t.state.selection;if(!n.sameParent(r))return!0;if(!o)return!1;if(t.endOfTextblock(e>0?"forward":"backward"))return!0;let i=!n.textOffset&&(e<0?n.nodeBefore:n.nodeAfter);if(i&&!i.isText){let r=t.state.tr;return e<0?r.delete(n.pos-i.nodeSize,n.pos):r.delete(n.pos,n.pos+i.nodeSize),t.dispatch(r),!0}return!1}function Fr(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function _r(t,e){let n=e.keyCode,r=function(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}(e);if(8==n||xn&&72==n&&"c"==r)return Br(t,-1)||Lr(t,-1);if(46==n&&!e.shiftKey||xn&&68==n&&"c"==r)return Br(t,1)||Lr(t,1);if(13==n||27==n)return!0;if(37==n||xn&&66==n&&"c"==r){let e=37==n?"ltr"==zr(t,t.state.selection.from)?-1:1:-1;return Dr(t,e,r)||Lr(t,e)}if(39==n||xn&&70==n&&"c"==r){let e=39==n?"ltr"==zr(t,t.state.selection.from)?1:-1:1;return Dr(t,e,r)||Lr(t,e)}return 38==n||xn&&80==n&&"c"==r?$r(t,-1,r)||Lr(t,-1):40==n||xn&&78==n&&"c"==r?function(t){if(!wn||t.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(e&&1==e.nodeType&&0==n&&e.firstChild&&"false"==e.firstChild.contentEditable){let n=e.firstChild;Fr(t,n,"true"),setTimeout((()=>Fr(t,n,"false")),20)}return!1}(t)||$r(t,1,r)||Lr(t,1):r==(xn?"m":"c")&&(66==n||73==n||89==n||90==n)}function Vr(t,e){t.someProp("transformCopied",(n=>{e=n(e,t)}));let n=[],{content:r,openStart:o,openEnd:i}=e;for(;o>1&&i>1&&1==r.childCount&&1==r.firstChild.childCount;){o--,i--;let t=r.firstChild;n.push(t.type.name,t.attrs!=t.type.defaultAttrs?t.attrs:null),r=t.content}let s=t.someProp("clipboardSerializer")||It.fromSchema(t.state.schema),a=Xr(),l=a.createElement("div");l.appendChild(s.serializeFragment(r,{document:a}));let c,d=l.firstChild,h=0;for(;d&&1==d.nodeType&&(c=Yr[d.nodeName.toLowerCase()]);){for(let t=c.length-1;t>=0;t--){let e=a.createElement(c[t]);for(;l.firstChild;)e.appendChild(l.firstChild);l.appendChild(e),h++}d=l.firstChild}return d&&1==d.nodeType&&d.setAttribute("data-pm-slice",`${o} ${i}${h?` -${h}`:""} ${JSON.stringify(n)}`),{dom:l,text:t.someProp("clipboardTextSerializer",(n=>n(e,t)))||e.content.textBetween(0,e.content.size,"\n\n"),slice:e}}function Hr(t,e,n,r,o){let i,s,a=o.parent.type.spec.code;if(!n&&!e)return null;let l=e&&(r||a||!n);if(l){if(t.someProp("transformPastedText",(n=>{e=n(e,a||r,t)})),a)return e?new $(R.from(t.state.schema.text(e.replace(/\r\n?/g,"\n"))),0,0):$.empty;let n=t.someProp("clipboardTextParser",(n=>n(e,o,r,t)));if(n)s=n;else{let n=o.marks(),{schema:r}=t.state,s=It.fromSchema(r);i=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach((t=>{let e=i.appendChild(document.createElement("p"));t&&e.appendChild(s.serializeNode(r.text(t,n)))}))}}else t.someProp("transformPastedHTML",(e=>{n=e(n,t)})),i=function(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n,r=Xr().createElement("div"),o=/<([a-z][^>\s]+)/i.exec(t);if((n=o&&Yr[o[1].toLowerCase()])&&(t=n.map((t=>"<"+t+">")).join("")+t+n.map((t=>"</"+t+">")).reverse().join("")),r.innerHTML=t,n)for(let t=0;t<n.length;t++)r=r.querySelector(n[t])||r;return r}(n),Cn&&function(t){let e=t.querySelectorAll(bn?"span:not([class]):not([style])":"span.Apple-converted-space");for(let n=0;n<e.length;n++){let r=e[n];1==r.childNodes.length&&" "==r.textContent&&r.parentNode&&r.parentNode.replaceChild(t.ownerDocument.createTextNode(" "),r)}}(i);let c=i&&i.querySelector("[data-pm-slice]"),d=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(d&&d[3])for(let t=+d[3];t>0;t--){let t=i.firstChild;for(;t&&1!=t.nodeType;)t=t.nextSibling;if(!t)break;i=t}if(s||(s=(t.someProp("clipboardParser")||t.someProp("domParser")||St.fromSchema(t.state.schema)).parseSlice(i,{preserveWhitespace:!(!l&&!d),context:o,ruleFromNode:t=>"BR"!=t.nodeName||t.nextSibling||!t.parentNode||Wr.test(t.parentNode.nodeName)?null:{ignore:!0}})),d)s=function(t,e){if(!t.size)return t;let n,r=t.content.firstChild.type.schema;try{n=JSON.parse(e)}catch{return t}let{content:o,openStart:i,openEnd:s}=t;for(let t=n.length-2;t>=0;t-=2){let e=r.nodes[n[t]];if(!e||e.hasRequiredAttrs())break;o=R.from(e.create(n[t+1],o)),i++,s++}return new $(o,i,s)}(Gr(s,+d[1],+d[2]),d[4]);else if(s=$.maxOpen(function(t,e){if(t.childCount<2)return t;for(let n=e.depth;n>=0;n--){let r,o=e.node(n).contentMatchAt(e.index(n)),i=[];if(t.forEach((t=>{if(!i)return;let e,n=o.findWrapping(t.type);if(!n)return i=null;if(e=i.length&&r.length&&qr(n,r,t,i[i.length-1],0))i[i.length-1]=e;else{i.length&&(i[i.length-1]=Jr(i[i.length-1],r.length));let e=Kr(t,n);i.push(e),o=o.matchType(e.type),r=n}})),i)return R.from(i)}return t}(s.content,o),!0),s.openStart||s.openEnd){let t=0,e=0;for(let e=s.content.firstChild;t<s.openStart&&!e.type.spec.isolating;t++,e=e.firstChild);for(let t=s.content.lastChild;e<s.openEnd&&!t.type.spec.isolating;e++,t=t.lastChild);s=Gr(s,t,e)}return t.someProp("transformPasted",(e=>{s=e(s,t)})),s}const Wr=/^(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 Kr(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,R.from(t));return t}function qr(t,e,n,r,o){if(o<t.length&&o<e.length&&t[o]==e[o]){let i=qr(t,e,n,r.lastChild,o+1);if(i)return r.copy(r.content.replaceChild(r.childCount-1,i));if(r.contentMatchAt(r.childCount).matchType(o==t.length-1?n.type:t[o+1]))return r.copy(r.content.append(R.from(Kr(n,t,o+1))))}}function Jr(t,e){if(0==e)return t;let n=t.content.replaceChild(t.childCount-1,Jr(t.lastChild,e-1)),r=t.contentMatchAt(t.childCount).fillBefore(R.empty,!0);return t.copy(n.append(r))}function Ur(t,e,n,r,o,i){let s=e<0?t.firstChild:t.lastChild,a=s.content;return t.childCount>1&&(i=0),o<r-1&&(a=Ur(a,e,n,r,o+1,i)),o>=n&&(a=e<0?s.contentMatchAt(0).fillBefore(a,i<=o).append(a):a.append(s.contentMatchAt(s.childCount).fillBefore(R.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,s.copy(a))}function Gr(t,e,n){return e<t.openStart&&(t=new $(Ur(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new $(Ur(t.content,1,n,t.openEnd,0,0),t.openStart,n)),t}const Yr={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 Qr=null;function Xr(){return Qr||(Qr=document.implementation.createHTMLDocument("title"))}const Zr={},to={},eo={touchstart:!0,touchmove:!0};class no{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:""},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastAndroidDelete=0,this.composing=!1,this.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 ro(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function oo(t){t.someProp("handleDOMEvents",(e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=e=>io(t,e))}))}function io(t,e){return t.someProp("handleDOMEvents",(n=>{let r=n[e.type];return!!r&&(r(t,e)||e.defaultPrevented)}))}function so(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let n=e.target;n!=t.dom;n=n.parentNode)if(!n||11==n.nodeType||n.pmViewDesc&&n.pmViewDesc.stopEvent(e))return!1;return!0}function ao(t){return{left:t.clientX,top:t.clientY}}function lo(t,e,n,r,o){if(-1==r)return!1;let i=t.state.doc.resolve(r);for(let r=i.depth+1;r>0;r--)if(t.someProp(e,(e=>r>i.depth?e(t,n,i.nodeAfter,i.before(r),o,!0):e(t,n,i.node(r),i.before(r),o,!1))))return!0;return!1}function co(t,e,n){if(t.focused||t.focus(),t.state.selection.eq(e))return;let r=t.state.tr.setSelection(e);"pointer"==n&&r.setMeta("pointer",!0),t.dispatch(r)}function ho(t,e,n,r,o){return lo(t,"handleClickOn",e,n,r)||t.someProp("handleClick",(n=>n(t,e,r)))||(o?function(t,e){if(-1==e)return!1;let n,r,o=t.state.selection;o instanceof Ie&&(n=o.node);let i=t.state.doc.resolve(e);for(let t=i.depth+1;t>0;t--){let e=t>i.depth?i.nodeAfter:i.node(t);if(Ie.isSelectable(e)){r=n&&o.$from.depth>0&&t>=o.$from.depth&&i.before(o.$from.depth+1)==o.$from.pos?i.before(o.$from.depth):i.before(t);break}}return null!=r&&(co(t,Ie.create(t.state.doc,r),"pointer"),!0)}(t,n):function(t,e){if(-1==e)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return!!(r&&r.isAtom&&Ie.isSelectable(r))&&(co(t,new Ie(n),"pointer"),!0)}(t,n))}function uo(t,e,n,r){return lo(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",(n=>n(t,e,r)))}function po(t,e,n,r){return lo(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",(n=>n(t,e,r)))||function(t,e,n){if(0!=n.button)return!1;let r=t.state.doc;if(-1==e)return!!r.inlineContent&&(co(t,De.create(r,0,r.content.size),"pointer"),!0);let o=r.resolve(e);for(let e=o.depth+1;e>0;e--){let n=e>o.depth?o.nodeAfter:o.node(e),i=o.before(e);if(n.inlineContent)co(t,De.create(r,i+1,i+1+n.content.size),"pointer");else{if(!Ie.isSelectable(n))continue;co(t,Ie.create(r,i),"pointer")}return!0}}(t,n,r)}function fo(t){return xo(t)}to.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=16==n.keyCode||n.shiftKey,!yo(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!On||!bn||13!=n.keyCode))if(229!=n.keyCode&&t.domObserver.forceFlush(),!kn||13!=n.keyCode||n.ctrlKey||n.altKey||n.metaKey)t.someProp("handleKeyDown",(e=>e(t,n)))||_r(t,n)?n.preventDefault():ro(t,"key");else{let e=Date.now();t.input.lastIOSEnter=e,t.input.lastIOSEnterFallbackTimeout=setTimeout((()=>{t.input.lastIOSEnter==e&&(t.someProp("handleKeyDown",(e=>e(t,an(13,"Enter")))),t.input.lastIOSEnter=0)}),200)}},to.keyup=(t,e)=>{16==e.keyCode&&(t.input.shiftKey=!1)},to.keypress=(t,e)=>{let n=e;if(yo(t,n)||!n.charCode||n.ctrlKey&&!n.altKey||xn&&n.metaKey)return;if(t.someProp("handleKeyPress",(e=>e(t,n))))return void n.preventDefault();let r=t.state.selection;if(!(r instanceof De&&r.$from.sameParent(r.$to))){let e=String.fromCharCode(n.charCode);!/[\r\n]/.test(e)&&!t.someProp("handleTextInput",(n=>n(t,r.$from.pos,r.$to.pos,e)))&&t.dispatch(t.state.tr.insertText(e).scrollIntoView()),n.preventDefault()}};const mo=xn?"metaKey":"ctrlKey";Zr.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=fo(t),o=Date.now(),i="singleClick";o-t.input.lastClick.time<500&&function(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}(n,t.input.lastClick)&&!n[mo]&&("singleClick"==t.input.lastClick.type?i="doubleClick":"doubleClick"==t.input.lastClick.type&&(i="tripleClick")),t.input.lastClick={time:o,x:n.clientX,y:n.clientY,type:i};let s=t.posAtCoords(ao(n));s&&("singleClick"==i?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new go(t,s,n,!!r)):("doubleClick"==i?uo:po)(t,s.pos,s.inside,n)?n.preventDefault():ro(t,"pointer"))};class go{constructor(t,e,n,r){let o,i;if(this.view=t,this.pos=e,this.event=n,this.flushed=r,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=t.state.doc,this.selectNode=!!n[mo],this.allowDefault=n.shiftKey,e.inside>-1)o=t.state.doc.nodeAt(e.inside),i=e.inside;else{let n=t.state.doc.resolve(e.pos);o=n.parent,i=n.depth?n.before():0}const s=r?null:n.target,a=s?t.docView.nearestDesc(s,!0):null;this.target=a&&1==a.dom.nodeType?a.dom:null;let{selection:l}=t.state;(0==n.button&&o.type.spec.draggable&&!1!==o.type.spec.selectable||l instanceof Ie&&l.from<=i&&l.to>i)&&(this.mightDrag={node:o,pos:i,addAttr:!(!this.target||this.target.draggable),setUneditable:!(!this.target||!gn||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()),t.root.addEventListener("mouseup",this.up=this.up.bind(this)),t.root.addEventListener("mousemove",this.move=this.move.bind(this)),ro(t,"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((()=>vr(this.view))),this.view.input.mouseDown=null}up(t){if(this.done(),!this.view.dom.contains(t.target))return;let e=this.pos;this.view.state.doc!=this.startDoc&&(e=this.view.posAtCoords(ao(t))),this.updateAllowDefault(t),this.allowDefault||!e?ro(this.view,"pointer"):ho(this.view,e.pos,e.inside,t,this.selectNode)?t.preventDefault():0==t.button&&(this.flushed||wn&&this.mightDrag&&!this.mightDrag.node.isAtom||bn&&!this.view.state.selection.visible&&Math.min(Math.abs(e.pos-this.view.state.selection.from),Math.abs(e.pos-this.view.state.selection.to))<=2)?(co(this.view,Te.near(this.view.state.doc.resolve(e.pos)),"pointer"),t.preventDefault()):ro(this.view,"pointer")}move(t){this.updateAllowDefault(t),ro(this.view,"pointer"),0==t.buttons&&this.done()}updateAllowDefault(t){!this.allowDefault&&(Math.abs(this.event.x-t.clientX)>4||Math.abs(this.event.y-t.clientY)>4)&&(this.allowDefault=!0)}}function yo(t,e){return!!t.composing||!!(wn&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500)&&(t.input.compositionEndedAt=-2e8,!0)}Zr.touchstart=t=>{t.input.lastTouch=Date.now(),fo(t),ro(t,"pointer")},Zr.touchmove=t=>{t.input.lastTouch=Date.now(),ro(t,"pointer")},Zr.contextmenu=t=>fo(t);const bo=On?5e3:-1;function vo(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout((()=>xo(t)),e))}function wo(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=function(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function ko(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=function(t,e){for(;;){if(3==t.nodeType&&e)return t;if(1==t.nodeType&&e>0){if("false"==t.contentEditable)return null;e=rn(t=t.childNodes[e-1])}else{if(!t.parentNode||on(t))return null;e=Ye(t),t=t.parentNode}}}(e.focusNode,e.focusOffset),r=function(t,e){for(;;){if(3==t.nodeType&&e<t.nodeValue.length)return t;if(1==t.nodeType&&e<t.childNodes.length){if("false"==t.contentEditable)return null;t=t.childNodes[e],e=0}else{if(!t.parentNode||on(t))return null;e=Ye(t)+1,t=t.parentNode}}}(e.focusNode,e.focusOffset);if(n&&r&&n!=r){let e=r.pmViewDesc,o=t.domObserver.lastChangedTextNode;if(n==o||r==o)return o;if(!e||!e.isText(r.nodeValue))return r;if(t.input.compositionNode==r){let t=n.pmViewDesc;if(t&&t.isText(n.nodeValue))return r}}return n||r}function xo(t,e=!1){if(!(On&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),wo(t),e||t.docView&&t.docView.dirty){let n=yr(t);return n&&!n.eq(t.state.selection)?t.dispatch(t.state.tr.setSelection(n)):!t.markCursor&&!e||t.state.selection.empty?t.updateState(t.state):t.dispatch(t.state.tr.deleteSelection()),!0}return!1}}to.compositionstart=to.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof De&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some((t=>!1===t.type.spec.inclusive))))t.markCursor=t.state.storedMarks||n.marks(),xo(t,!0),t.markCursor=null;else if(xo(t,!e.selection.empty),gn&&e.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let e=t.domSelectionRange();for(let n=e.focusNode,r=e.focusOffset;n&&1==n.nodeType&&0!=r;){let e=r<0?n.lastChild:n.childNodes[r-1];if(!e)break;if(3==e.nodeType){let n=t.domSelection();n&&n.collapse(e,e.nodeValue.length);break}n=e,r=-1}}t.input.composing=!0}vo(t,bo)},to.compositionend=(t,e)=>{t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=e.timeStamp,t.input.compositionPendingChanges=t.domObserver.pendingRecords().length?t.input.compositionID:0,t.input.compositionNode=null,t.input.compositionPendingChanges&&Promise.resolve().then((()=>t.domObserver.flush())),t.input.compositionID++,vo(t,20))};const So=fn&&mn<15||kn&&Mn<604;function Oo(t,e,n,r,o){let i=Hr(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",(e=>e(t,o,i||$.empty))))return!0;if(!i)return!1;let s=function(t){return 0==t.openStart&&0==t.openEnd&&1==t.content.childCount?t.content.firstChild:null}(i),a=s?t.state.tr.replaceSelectionWith(s,r):t.state.tr.replaceSelection(i);return t.dispatch(a.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Co(t){let e=t.getData("text/plain")||t.getData("Text");if(e)return e;let n=t.getData("text/uri-list");return n?n.replace(/\r?\n/g," "):""}Zr.copy=to.cut=(t,e)=>{let n=e,r=t.state.selection,o="cut"==n.type;if(r.empty)return;let i=So?null:n.clipboardData,s=r.content(),{dom:a,text:l}=Vr(t,s);i?(n.preventDefault(),i.clearData(),i.setData("text/html",a.innerHTML),i.setData("text/plain",l)):function(t,e){if(!t.dom.parentNode)return;let n=t.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(e),n.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),o=document.createRange();o.selectNodeContents(e),t.dom.blur(),r.removeAllRanges(),r.addRange(o),setTimeout((()=>{n.parentNode&&n.parentNode.removeChild(n),t.focus()}),50)}(t,a),o&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))},to.paste=(t,e)=>{let n=e;if(t.composing&&!On)return;let r=So?null:n.clipboardData,o=t.input.shiftKey&&45!=t.input.lastKeyCode;r&&Oo(t,Co(r),r.getData("text/html"),o,n)?n.preventDefault():function(t,e){if(!t.dom.parentNode)return;let n=t.input.shiftKey||t.state.selection.$from.parent.type.spec.code,r=t.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let o=t.input.shiftKey&&45!=t.input.lastKeyCode;setTimeout((()=>{t.focus(),r.parentNode&&r.parentNode.removeChild(r),n?Oo(t,r.value,null,o,e):Oo(t,r.textContent,r.innerHTML,o,e)}),50)}(t,n)};class Mo{constructor(t,e,n){this.slice=t,this.move=e,this.node=n}}const To=xn?"altKey":"ctrlKey";Zr.dragstart=(t,e)=>{let n=e,r=t.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let o,i=t.state.selection,s=i.empty?null:t.posAtCoords(ao(n));if(!(s&&s.pos>=i.from&&s.pos<=(i instanceof Ie?i.to-1:i.to)))if(r&&r.mightDrag)o=Ie.create(t.state.doc,r.mightDrag.pos);else if(n.target&&1==n.target.nodeType){let e=t.docView.nearestDesc(n.target,!0);e&&e.node.type.spec.draggable&&e!=t.docView&&(o=Ie.create(t.state.doc,e.posBefore))}let a=(o||t.state.selection).content(),{dom:l,text:c,slice:d}=Vr(t,a);(!n.dataTransfer.files.length||!bn||vn>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(So?"Text":"text/html",l.innerHTML),n.dataTransfer.effectAllowed="copyMove",So||n.dataTransfer.setData("text/plain",c),t.dragging=new Mo(d,!n[To],o)},Zr.dragend=t=>{let e=t.dragging;window.setTimeout((()=>{t.dragging==e&&(t.dragging=null)}),50)},to.dragover=to.dragenter=(t,e)=>e.preventDefault(),to.drop=(t,e)=>{let n=e,r=t.dragging;if(t.dragging=null,!n.dataTransfer)return;let o=t.posAtCoords(ao(n));if(!o)return;let i=t.state.doc.resolve(o.pos),s=r&&r.slice;s?t.someProp("transformPasted",(e=>{s=e(s,t)})):s=Hr(t,Co(n.dataTransfer),So?null:n.dataTransfer.getData("text/html"),!1,i);let a=!(!r||n[To]);if(t.someProp("handleDrop",(e=>e(t,n,s||$.empty,a))))return void n.preventDefault();if(!s)return;n.preventDefault();let l=s?function(t,e,n){let r=t.resolve(e);if(!n.content.size)return e;let o=n.content;for(let t=0;t<n.openStart;t++)o=o.firstChild.content;for(let t=1;t<=(0==n.openStart&&n.size?2:1);t++)for(let e=r.depth;e>=0;e--){let n=e==r.depth?0:r.pos<=(r.start(e+1)+r.end(e+1))/2?-1:1,i=r.index(e)+(n>0?1:0),s=r.node(e),a=!1;if(1==t)a=s.canReplace(i,i,o);else{let t=s.contentMatchAt(i).findWrapping(o.firstChild.type);a=t&&s.canReplaceWith(i,i,t[0])}if(a)return 0==n?r.pos:n<0?r.before(e+1):r.after(e+1)}return null}(t.state.doc,i.pos,s):i.pos;null==l&&(l=i.pos);let c=t.state.tr;if(a){let{node:t}=r;t?t.replace(c):c.deleteSelection()}let d=c.mapping.map(l),h=0==s.openStart&&0==s.openEnd&&1==s.content.childCount,u=c.doc;if(h?c.replaceRangeWith(d,d,s.content.firstChild):c.replaceRange(d,d,s),c.doc.eq(u))return;let p=c.doc.resolve(d);if(h&&Ie.isSelectable(s.content.firstChild)&&p.nodeAfter&&p.nodeAfter.sameMarkup(s.content.firstChild))c.setSelection(new Ie(p));else{let e=c.mapping.map(l);c.mapping.maps[c.mapping.maps.length-1].forEach(((t,n,r,o)=>e=o)),c.setSelection(Mr(t,p,c.doc.resolve(e)))}t.focus(),t.dispatch(c.setMeta("uiEvent","drop"))},Zr.focus=t=>{t.input.lastFocus=Date.now(),t.focused||(t.domObserver.stop(),t.dom.classList.add("ProseMirror-focused"),t.domObserver.start(),t.focused=!0,setTimeout((()=>{t.docView&&t.hasFocus()&&!t.domObserver.currentSelection.eq(t.domSelectionRange())&&vr(t)}),20))},Zr.blur=(t,e)=>{let n=e;t.focused&&(t.domObserver.stop(),t.dom.classList.remove("ProseMirror-focused"),t.domObserver.start(),n.relatedTarget&&t.dom.contains(n.relatedTarget)&&t.domObserver.currentSelection.clear(),t.focused=!1)},Zr.beforeinput=(t,e)=>{if(bn&&On&&"deleteContentBackward"==e.inputType){t.domObserver.flushSoon();let{domChangeCount:e}=t.input;setTimeout((()=>{if(t.input.domChangeCount!=e||(t.dom.blur(),t.focus(),t.someProp("handleKeyDown",(e=>e(t,an(8,"Backspace"))))))return;let{$cursor:n}=t.state.selection;n&&n.pos>0&&t.dispatch(t.state.tr.delete(n.pos-1,n.pos).scrollIntoView())}),50)}};for(let t in to)Zr[t]=to[t];function Eo(t,e){if(t==e)return!0;for(let n in t)if(t[n]!==e[n])return!1;for(let n in e)if(!(n in t))return!1;return!0}class No{constructor(t,e){this.toDOM=t,this.spec=e||Lo,this.side=this.spec.side||0}map(t,e,n,r){let{pos:o,deleted:i}=t.mapResult(e.from+r,this.side<0?-1:1);return i?null:new Ro(o-n,o-n,this)}valid(){return!0}eq(t){return this==t||t instanceof No&&(this.spec.key&&this.spec.key==t.spec.key||this.toDOM==t.toDOM&&Eo(this.spec,t.spec))}destroy(t){this.spec.destroy&&this.spec.destroy(t)}}class Ao{constructor(t,e){this.attrs=t,this.spec=e||Lo}map(t,e,n,r){let o=t.map(e.from+r,this.spec.inclusiveStart?-1:1)-n,i=t.map(e.to+r,this.spec.inclusiveEnd?1:-1)-n;return o>=i?null:new Ro(o,i,this)}valid(t,e){return e.from<e.to}eq(t){return this==t||t instanceof Ao&&Eo(this.attrs,t.attrs)&&Eo(this.spec,t.spec)}static is(t){return t.type instanceof Ao}destroy(){}}class Do{constructor(t,e){this.attrs=t,this.spec=e||Lo}map(t,e,n,r){let o=t.mapResult(e.from+r,1);if(o.deleted)return null;let i=t.mapResult(e.to+r,-1);return i.deleted||i.pos<=o.pos?null:new Ro(o.pos-n,i.pos-n,this)}valid(t,e){let n,{index:r,offset:o}=t.content.findIndex(e.from);return o==e.from&&!(n=t.child(r)).isText&&o+n.nodeSize==e.to}eq(t){return this==t||t instanceof Do&&Eo(this.attrs,t.attrs)&&Eo(this.spec,t.spec)}destroy(){}}class Ro{constructor(t,e,n){this.from=t,this.to=e,this.type=n}copy(t,e){return new Ro(t,e,this.type)}eq(t,e=0){return this.type.eq(t.type)&&this.from+e==t.from&&this.to+e==t.to}map(t,e,n){return this.type.map(t,this,e,n)}static widget(t,e,n){return new Ro(t,t,new No(e,n))}static inline(t,e,n,r){return new Ro(t,e,new Ao(n,r))}static node(t,e,n,r){return new Ro(t,e,new Do(n,r))}get spec(){return this.type.spec}get inline(){return this.type instanceof Ao}get widget(){return this.type instanceof No}}const Io=[],Lo={};class Po{constructor(t,e){this.local=t.length?t:Io,this.children=e.length?e:Io}static create(t,e){return e.length?_o(e,t,0,Lo):jo}find(t,e,n){let r=[];return this.findInner(t??0,e??1e9,r,0,n),r}findInner(t,e,n,r,o){for(let i=0;i<this.local.length;i++){let s=this.local[i];s.from<=e&&s.to>=t&&(!o||o(s.spec))&&n.push(s.copy(s.from+r,s.to+r))}for(let i=0;i<this.children.length;i+=3)if(this.children[i]<e&&this.children[i+1]>t){let s=this.children[i]+1;this.children[i+2].findInner(t-s,e-s,n,r+s,o)}}map(t,e,n){return this==jo||0==t.maps.length?this:this.mapInner(t,e,0,0,n||Lo)}mapInner(t,e,n,r,o){let i;for(let s=0;s<this.local.length;s++){let a=this.local[s].map(t,n,r);a&&a.type.valid(e,a)?(i||(i=[])).push(a):o.onRemove&&o.onRemove(this.local[s].spec)}return this.children.length?function(t,e,n,r,o,i,s){let a=t.slice();for(let t=0,e=i;t<n.maps.length;t++){let r=0;n.maps[t].forEach(((t,n,o,i)=>{let s=i-o-(n-t);for(let o=0;o<a.length;o+=3){let i=a[o+1];if(i<0||t>i+e-r)continue;let l=a[o]+e-r;n>=l?a[o+1]=t<=l?-2:-1:t>=e&&s&&(a[o]+=s,a[o+1]+=s)}r+=s})),e=n.maps[t].map(e,-1)}let l=!1;for(let e=0;e<a.length;e+=3)if(a[e+1]<0){if(-2==a[e+1]){l=!0,a[e+1]=-1;continue}let c=n.map(t[e]+i),d=c-o;if(d<0||d>=r.content.size){l=!0;continue}let h=n.map(t[e+1]+i,-1)-o,{index:u,offset:p}=r.content.findIndex(d),f=r.maybeChild(u);if(f&&p==d&&p+f.nodeSize==h){let r=a[e+2].mapInner(n,f,c+1,t[e]+i+1,s);r!=jo?(a[e]=d,a[e+1]=h,a[e+2]=r):(a[e+1]=-2,l=!0)}else l=!0}if(l){let l=function(t,e,n,r,o,i,s){function a(t,e){for(let i=0;i<t.local.length;i++){let a=t.local[i].map(r,o,e);a?n.push(a):s.onRemove&&s.onRemove(t.local[i].spec)}for(let n=0;n<t.children.length;n+=3)a(t.children[n+2],t.children[n]+e+1)}for(let n=0;n<t.length;n+=3)-1==t[n+1]&&a(t[n+2],e[n]+i+1);return n}(a,t,e,n,o,i,s),c=_o(l,r,0,s);e=c.local;for(let t=0;t<a.length;t+=3)a[t+1]<0&&(a.splice(t,3),t-=3);for(let t=0,e=0;t<c.children.length;t+=3){let n=c.children[t];for(;e<a.length&&a[e]<n;)e+=3;a.splice(e,0,c.children[t],c.children[t+1],c.children[t+2])}}return new Po(e.sort(Vo),a)}(this.children,i||[],t,e,n,r,o):i?new Po(i.sort(Vo),Io):jo}add(t,e){return e.length?this==jo?Po.create(t,e):this.addInner(t,e,0):this}addInner(t,e,n){let r,o=0;t.forEach(((t,i)=>{let s,a=i+n;if(s=Bo(e,t,a)){for(r||(r=this.children.slice());o<r.length&&r[o]<i;)o+=3;r[o]==i?r[o+2]=r[o+2].addInner(t,s,a+1):r.splice(o,0,i,i+t.nodeSize,_o(s,t,a+1,Lo)),o+=3}}));let i=$o(o?Fo(e):e,-n);for(let e=0;e<i.length;e++)i[e].type.valid(t,i[e])||i.splice(e--,1);return new Po(i.length?this.local.concat(i).sort(Vo):this.local,r||this.children)}remove(t){return 0==t.length||this==jo?this:this.removeInner(t,0)}removeInner(t,e){let n=this.children,r=this.local;for(let r=0;r<n.length;r+=3){let o,i=n[r]+e,s=n[r+1]+e;for(let e,n=0;n<t.length;n++)(e=t[n])&&e.from>i&&e.to<s&&(t[n]=null,(o||(o=[])).push(e));if(!o)continue;n==this.children&&(n=this.children.slice());let a=n[r+2].removeInner(o,i+1);a!=jo?n[r+2]=a:(n.splice(r,3),r-=3)}if(r.length)for(let n,o=0;o<t.length;o++)if(n=t[o])for(let t=0;t<r.length;t++)r[t].eq(n,e)&&(r==this.local&&(r=this.local.slice()),r.splice(t--,1));return n==this.children&&r==this.local?this:r.length||n.length?new Po(r,n):jo}forChild(t,e){if(this==jo)return this;if(e.isLeaf)return Po.empty;let n,r;for(let e=0;e<this.children.length;e+=3)if(this.children[e]>=t){this.children[e]==t&&(n=this.children[e+2]);break}let o=t+1,i=o+e.content.size;for(let t=0;t<this.local.length;t++){let e=this.local[t];if(e.from<i&&e.to>o&&e.type instanceof Ao){let t=Math.max(o,e.from)-o,n=Math.min(i,e.to)-o;t<n&&(r||(r=[])).push(e.copy(t,n))}}if(r){let t=new Po(r.sort(Vo),Io);return n?new zo([t,n]):t}return n||jo}eq(t){if(this==t)return!0;if(!(t instanceof Po)||this.local.length!=t.local.length||this.children.length!=t.children.length)return!1;for(let e=0;e<this.local.length;e++)if(!this.local[e].eq(t.local[e]))return!1;for(let e=0;e<this.children.length;e+=3)if(this.children[e]!=t.children[e]||this.children[e+1]!=t.children[e+1]||!this.children[e+2].eq(t.children[e+2]))return!1;return!0}locals(t){return Ho(this.localsInner(t))}localsInner(t){if(this==jo)return Io;if(t.inlineContent||!this.local.some(Ao.is))return this.local;let e=[];for(let t=0;t<this.local.length;t++)this.local[t].type instanceof Ao||e.push(this.local[t]);return e}}Po.empty=new Po([],[]),Po.removeOverlap=Ho;const jo=Po.empty;class zo{constructor(t){this.members=t}map(t,e){const n=this.members.map((n=>n.map(t,e,Lo)));return zo.from(n)}forChild(t,e){if(e.isLeaf)return Po.empty;let n=[];for(let r=0;r<this.members.length;r++){let o=this.members[r].forChild(t,e);o!=jo&&(o instanceof zo?n=n.concat(o.members):n.push(o))}return zo.from(n)}eq(t){if(!(t instanceof zo)||t.members.length!=this.members.length)return!1;for(let e=0;e<this.members.length;e++)if(!this.members[e].eq(t.members[e]))return!1;return!0}locals(t){let e,n=!0;for(let r=0;r<this.members.length;r++){let o=this.members[r].localsInner(t);if(o.length)if(e){n&&(e=e.slice(),n=!1);for(let t=0;t<o.length;t++)e.push(o[t])}else e=o}return e?Ho(n?e:e.sort(Vo)):Io}static from(t){switch(t.length){case 0:return jo;case 1:return t[0];default:return new zo(t.every((t=>t instanceof Po))?t:t.reduce(((t,e)=>t.concat(e instanceof Po?e:e.members)),[]))}}}function $o(t,e){if(!e||!t.length)return t;let n=[];for(let r=0;r<t.length;r++){let o=t[r];n.push(new Ro(o.from+e,o.to+e,o.type))}return n}function Bo(t,e,n){if(e.isLeaf)return null;let r=n+e.nodeSize,o=null;for(let e,i=0;i<t.length;i++)(e=t[i])&&e.from>n&&e.to<r&&((o||(o=[])).push(e),t[i]=null);return o}function Fo(t){let e=[];for(let n=0;n<t.length;n++)null!=t[n]&&e.push(t[n]);return e}function _o(t,e,n,r){let o=[],i=!1;e.forEach(((e,s)=>{let a=Bo(t,e,s+n);if(a){i=!0;let t=_o(a,e,n+s+1,r);t!=jo&&o.push(s,s+e.nodeSize,t)}}));let s=$o(i?Fo(t):t,-n).sort(Vo);for(let t=0;t<s.length;t++)s[t].type.valid(e,s[t])||(r.onRemove&&r.onRemove(s[t].spec),s.splice(t--,1));return s.length||o.length?new Po(s,o):jo}function Vo(t,e){return t.from-e.from||t.to-e.to}function Ho(t){let e=t;for(let n=0;n<e.length-1;n++){let r=e[n];if(r.from!=r.to)for(let o=n+1;o<e.length;o++){let i=e[o];if(i.from!=r.from){i.from<r.to&&(e==t&&(e=t.slice()),e[n]=r.copy(r.from,i.from),Wo(e,o,r.copy(i.from,r.to)));break}i.to!=r.to&&(e==t&&(e=t.slice()),e[o]=i.copy(i.from,r.to),Wo(e,o+1,i.copy(r.to,i.to)))}}return e}function Wo(t,e,n){for(;e<t.length&&Vo(n,t[e])>0;)e++;t.splice(e,0,n)}function Ko(t){let e=[];return t.someProp("decorations",(n=>{let r=n(t.state);r&&r!=jo&&e.push(r)})),t.cursorWrapper&&e.push(Po.create(t.state.doc,[t.cursorWrapper.deco])),zo.from(e)}const qo={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},Jo=fn&&mn<=11;class Uo{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(t){this.anchorNode=t.anchorNode,this.anchorOffset=t.anchorOffset,this.focusNode=t.focusNode,this.focusOffset=t.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(t){return t.anchorNode==this.anchorNode&&t.anchorOffset==this.anchorOffset&&t.focusNode==this.focusNode&&t.focusOffset==this.focusOffset}}class Go{constructor(t,e){this.view=t,this.handleDOMChange=e,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new Uo,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver((t=>{for(let e=0;e<t.length;e++)this.queue.push(t[e]);fn&&mn<=11&&t.some((t=>"childList"==t.type&&t.removedNodes.length||"characterData"==t.type&&t.oldValue.length>t.target.nodeValue.length))?this.flushSoon():this.flush()})),Jo&&(this.onCharData=t=>{this.queue.push({target:t.target,type:"characterData",oldValue:t.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,qo)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let t=this.observer.takeRecords();if(t.length){for(let e=0;e<t.length;e++)this.queue.push(t[e]);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(Tr(this.view)){if(this.suppressingSelectionUpdates)return vr(this.view);if(fn&&mn<=11&&!this.view.state.selection.empty){let t=this.view.domSelectionRange();if(t.focusNode&&tn(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(t){if(!t.focusNode)return!0;let e,n=new Set;for(let e=t.focusNode;e;e=Qe(e))n.add(e);for(let r=t.anchorNode;r;r=Qe(r))if(n.has(r)){e=r;break}let r=e&&this.view.docView.nearestDesc(e);return r&&r.ignoreMutation({type:"selection",target:3==e.nodeType?e.parentNode:e})?(this.setCurSelection(),!0):void 0}pendingRecords(){if(this.observer)for(let t of this.observer.takeRecords())this.queue.push(t);return this.queue}flush(){let{view:t}=this;if(!t.docView||this.flushingSoon>-1)return;let e=this.pendingRecords();e.length&&(this.queue=[]);let n=t.domSelectionRange(),r=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(n)&&Tr(t)&&!this.ignoreSelectionChange(n),o=-1,i=-1,s=!1,a=[];if(t.editable)for(let t=0;t<e.length;t++){let n=this.registerMutation(e[t],a);n&&(o=o<0?n.from:Math.min(n.from,o),i=i<0?n.to:Math.max(n.to,i),n.typeOver&&(s=!0))}if(gn&&a.length){let e=a.filter((t=>"BR"==t.nodeName));if(2==e.length){let[t,n]=e;t.parentNode&&t.parentNode.parentNode==n.parentNode?n.remove():t.remove()}else{let{focusNode:n}=this.currentSelection;for(let r of e){let e=r.parentNode;e&&"LI"==e.nodeName&&(!n||Zo(t,n)!=e)&&r.remove()}}}let l=null;o<0&&r&&t.input.lastFocus>Date.now()-200&&Math.max(t.input.lastTouch,t.input.lastClick.time)<Date.now()-300&&sn(n)&&(l=yr(t))&&l.eq(Te.near(t.state.doc.resolve(0),1))?(t.input.lastFocus=0,vr(t),this.currentSelection.set(n),t.scrollToSelection()):(o>-1||r)&&(o>-1&&(t.docView.markDirty(o,i),function(t){if(!Yo.has(t)&&(Yo.set(t,null),-1!==["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace))){if(t.requiresGeckoHackNode=gn,Qo)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."),Qo=!0}}(t)),this.handleDOMChange(o,i,s,a),t.docView&&t.docView.dirty?t.updateState(t.state):this.currentSelection.eq(n)||vr(t),this.currentSelection.set(n))}registerMutation(t,e){if(e.indexOf(t.target)>-1)return null;let n=this.view.docView.nearestDesc(t.target);if("attributes"==t.type&&(n==this.view.docView||"contenteditable"==t.attributeName||"style"==t.attributeName&&!t.oldValue&&!t.target.getAttribute("style"))||!n||n.ignoreMutation(t))return null;if("childList"==t.type){for(let n=0;n<t.addedNodes.length;n++){let r=t.addedNodes[n];e.push(r),3==r.nodeType&&(this.lastChangedTextNode=r)}if(n.contentDOM&&n.contentDOM!=n.dom&&!n.contentDOM.contains(t.target))return{from:n.posBefore,to:n.posAfter};let r=t.previousSibling,o=t.nextSibling;if(fn&&mn<=11&&t.addedNodes.length)for(let e=0;e<t.addedNodes.length;e++){let{previousSibling:n,nextSibling:i}=t.addedNodes[e];(!n||Array.prototype.indexOf.call(t.addedNodes,n)<0)&&(r=n),(!i||Array.prototype.indexOf.call(t.addedNodes,i)<0)&&(o=i)}let i=r&&r.parentNode==t.target?Ye(r)+1:0,s=n.localPosFromDOM(t.target,i,-1),a=o&&o.parentNode==t.target?Ye(o):t.target.childNodes.length;return{from:s,to:n.localPosFromDOM(t.target,a,1)}}return"attributes"==t.type?{from:n.posAtStart-n.border,to:n.posAtEnd+n.border}:(this.lastChangedTextNode=t.target,{from:n.posAtStart,to:n.posAtEnd,typeOver:t.target.nodeValue==t.oldValue})}}let Yo=new WeakMap,Qo=!1;function Xo(t,e){let n=e.startContainer,r=e.startOffset,o=e.endContainer,i=e.endOffset,s=t.domAtPos(t.state.selection.anchor);return tn(s.node,s.offset,o,i)&&([n,r,o,i]=[o,i,n,r]),{anchorNode:n,anchorOffset:r,focusNode:o,focusOffset:i}}function Zo(t,e){for(let n=e.parentNode;n&&n!=t.dom;n=n.parentNode){let e=t.docView.nearestDesc(n,!0);if(e&&e.node.isBlock)return n}return null}function ti(t){let e=t.pmViewDesc;if(e)return e.parseRule();if("BR"==t.nodeName&&t.parentNode){if(wn&&/^(ul|ol)$/i.test(t.parentNode.nodeName)){let t=document.createElement("div");return t.appendChild(document.createElement("li")),{skip:t}}if(t.parentNode.lastChild==t||wn&&/^(tr|table)$/i.test(t.parentNode.nodeName))return{ignore:!0}}else if("IMG"==t.nodeName&&t.getAttribute("mark-placeholder"))return{ignore:!0};return null}const ei=/^(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 ni(t,e,n,r,o){let i=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,e<0){let e=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,n=yr(t,e);if(n&&!t.state.selection.eq(n)){if(bn&&On&&13===t.input.lastKeyCode&&Date.now()-100<t.input.lastKeyCodeTime&&t.someProp("handleKeyDown",(e=>e(t,an(13,"Enter")))))return;let r=t.state.tr.setSelection(n);"pointer"==e?r.setMeta("pointer",!0):"key"==e&&r.scrollIntoView(),i&&r.setMeta("composition",i),t.dispatch(r)}return}let s=t.state.doc.resolve(e),a=s.sharedDepth(n);e=s.before(a+1),n=t.state.doc.resolve(n).after(a+1);let l,c,d=t.state.selection,h=function(t,e,n){let r,{node:o,fromOffset:i,toOffset:s,from:a,to:l}=t.docView.parseRange(e,n),c=t.domSelectionRange(),d=c.anchorNode;if(d&&t.dom.contains(1==d.nodeType?d:d.parentNode)&&(r=[{node:d,offset:c.anchorOffset}],sn(c)||r.push({node:c.focusNode,offset:c.focusOffset})),bn&&8===t.input.lastKeyCode)for(let t=s;t>i;t--){let e=o.childNodes[t-1],n=e.pmViewDesc;if("BR"==e.nodeName&&!n){s=t;break}if(!n||n.size)break}let h=t.state.doc,u=t.someProp("domParser")||St.fromSchema(t.state.schema),p=h.resolve(a),f=null,m=u.parse(o,{topNode:p.parent,topMatch:p.parent.contentMatchAt(p.index()),topOpen:!0,from:i,to:s,preserveWhitespace:"pre"!=p.parent.type.whitespace||"full",findPositions:r,ruleFromNode:ti,context:p});if(r&&null!=r[0].pos){let t=r[0].pos,e=r[1]&&r[1].pos;null==e&&(e=t),f={anchor:t+a,head:e+a}}return{doc:m,sel:f,from:a,to:l}}(t,e,n),u=t.state.doc,p=u.slice(h.from,h.to);8===t.input.lastKeyCode&&Date.now()-100<t.input.lastKeyCodeTime?(l=t.state.selection.to,c="end"):(l=t.state.selection.from,c="start"),t.input.lastKeyCode=null;let f=function(t,e,n,r,o){let i=t.findDiffStart(e,n);if(null==i)return null;let{a:s,b:a}=t.findDiffEnd(e,n+t.size,n+e.size);if("end"==o){r-=s+Math.max(0,i-Math.min(s,a))-i}if(s<i&&t.size<e.size){let t=r<=i&&r>=s?i-r:0;i-=t,i&&i<e.size&&ii(e.textBetween(i-1,i+1))&&(i+=t?1:-1),a=i+(a-s),s=i}else if(a<i){let e=r<=i&&r>=a?i-r:0;i-=e,i&&i<t.size&&ii(t.textBetween(i-1,i+1))&&(i+=e?1:-1),s=i+(s-a),a=i}return{start:i,endA:s,endB:a}}(p.content,h.doc.content,h.from,l,c);if((kn&&t.input.lastIOSEnter>Date.now()-225||On)&&o.some((t=>1==t.nodeType&&!ei.test(t.nodeName)))&&(!f||f.endA>=f.endB)&&t.someProp("handleKeyDown",(e=>e(t,an(13,"Enter")))))return void(t.input.lastIOSEnter=0);if(!f){if(!(r&&d instanceof De&&!d.empty&&d.$head.sameParent(d.$anchor))||t.composing||h.sel&&h.sel.anchor!=h.sel.head){if(h.sel){let e=ri(t,t.state.doc,h.sel);if(e&&!e.eq(t.state.selection)){let n=t.state.tr.setSelection(e);i&&n.setMeta("composition",i),t.dispatch(n)}}return}f={start:d.from,endA:d.to,endB:d.to}}t.input.domChangeCount++,t.state.selection.from<t.state.selection.to&&f.start==f.endB&&t.state.selection instanceof De&&(f.start>t.state.selection.from&&f.start<=t.state.selection.from+2&&t.state.selection.from>=h.from?f.start=t.state.selection.from:f.endA<t.state.selection.to&&f.endA>=t.state.selection.to-2&&t.state.selection.to<=h.to&&(f.endB+=t.state.selection.to-f.endA,f.endA=t.state.selection.to)),fn&&mn<=11&&f.endB==f.start+1&&f.endA==f.start&&f.start>h.from&&"  "==h.doc.textBetween(f.start-h.from-1,f.start-h.from+1)&&(f.start--,f.endA--,f.endB--);let m,g=h.doc.resolveNoCache(f.start-h.from),y=h.doc.resolveNoCache(f.endB-h.from),b=u.resolve(f.start),v=g.sameParent(y)&&g.parent.inlineContent&&b.end()>=f.endA;if((kn&&t.input.lastIOSEnter>Date.now()-225&&(!v||o.some((t=>"DIV"==t.nodeName||"P"==t.nodeName)))||!v&&g.pos<h.doc.content.size&&!g.sameParent(y)&&(m=Te.findFrom(h.doc.resolve(g.pos+1),1,!0))&&m.head==y.pos)&&t.someProp("handleKeyDown",(e=>e(t,an(13,"Enter")))))return void(t.input.lastIOSEnter=0);if(t.state.selection.anchor>f.start&&function(t,e,n,r,o){if(n-e<=o.pos-r.pos||oi(r,!0,!1)<o.pos)return!1;let i=t.resolve(e);if(!r.parent.isTextblock){let t=i.nodeAfter;return null!=t&&n==e+t.nodeSize}if(i.parentOffset<i.parent.content.size||!i.parent.isTextblock)return!1;let s=t.resolve(oi(i,!0,!0));return!(!s.parent.isTextblock||s.pos>n||oi(s,!0,!1)<n)&&r.parent.content.cut(r.parentOffset).eq(s.parent.content)}(u,f.start,f.endA,g,y)&&t.someProp("handleKeyDown",(e=>e(t,an(8,"Backspace")))))return void(On&&bn&&t.domObserver.suppressSelectionUpdates());bn&&On&&f.endB==f.start&&(t.input.lastAndroidDelete=Date.now()),On&&!v&&g.start()!=y.start()&&0==y.parentOffset&&g.depth==y.depth&&h.sel&&h.sel.anchor==h.sel.head&&h.sel.head==f.endA&&(f.endB-=2,y=h.doc.resolveNoCache(f.endB-h.from),setTimeout((()=>{t.someProp("handleKeyDown",(function(e){return e(t,an(13,"Enter"))}))}),20));let w,k,x,S=f.start,O=f.endA;if(v)if(g.pos==y.pos)fn&&mn<=11&&0==g.parentOffset&&(t.domObserver.suppressSelectionUpdates(),setTimeout((()=>vr(t)),20)),w=t.state.tr.delete(S,O),k=u.resolve(f.start).marksAcross(u.resolve(f.endA));else if(f.endA==f.endB&&(x=function(t,e){let n,r,o,i=t.firstChild.marks,s=e.firstChild.marks,a=i,l=s;for(let t=0;t<s.length;t++)a=s[t].removeFromSet(a);for(let t=0;t<i.length;t++)l=i[t].removeFromSet(l);if(1==a.length&&0==l.length)r=a[0],n="add",o=t=>t.mark(r.addToSet(t.marks));else{if(0!=a.length||1!=l.length)return null;r=l[0],n="remove",o=t=>t.mark(r.removeFromSet(t.marks))}let c=[];for(let t=0;t<e.childCount;t++)c.push(o(e.child(t)));if(R.from(c).eq(t))return{mark:r,type:n}}(g.parent.content.cut(g.parentOffset,y.parentOffset),b.parent.content.cut(b.parentOffset,f.endA-b.start()))))w=t.state.tr,"add"==x.type?w.addMark(S,O,x.mark):w.removeMark(S,O,x.mark);else if(g.parent.child(g.index()).isText&&g.index()==y.index()-(y.textOffset?0:1)){let e=g.parent.textBetween(g.parentOffset,y.parentOffset);if(t.someProp("handleTextInput",(n=>n(t,S,O,e))))return;w=t.state.tr.insertText(e,S,O)}if(w||(w=t.state.tr.replace(S,O,h.doc.slice(f.start-h.from,f.endB-h.from))),h.sel){let e=ri(t,w.doc,h.sel);e&&!(bn&&On&&t.composing&&e.empty&&(f.start!=f.endB||t.input.lastAndroidDelete<Date.now()-100)&&(e.head==S||e.head==w.mapping.map(O)-1)||fn&&e.empty&&e.head==S)&&w.setSelection(e)}k&&w.ensureMarks(k),i&&w.setMeta("composition",i),t.dispatch(w.scrollIntoView())}function ri(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:Mr(t,e.resolve(n.anchor),e.resolve(n.head))}function oi(t,e,n){let r=t.depth,o=e?t.end():t.pos;for(;r>0&&(e||t.indexAfter(r)==t.node(r).childCount);)r--,o++,e=!1;if(n){let e=t.node(r).maybeChild(t.indexAfter(r));for(;e&&!e.isLeaf;)e=e.firstChild,o++}return o}function ii(t){if(2!=t.length)return!1;let e=t.charCodeAt(0),n=t.charCodeAt(1);return e>=56320&&e<=57343&&n>=55296&&n<=56319}class si{constructor(t,e){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 no,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=e,this.state=e.state,this.directPlugins=e.plugins||[],this.directPlugins.forEach(hi),this.dispatch=this.dispatch.bind(this),this.dom=t&&t.mount||document.createElement("div"),t&&(t.appendChild?t.appendChild(this.dom):"function"==typeof t?t(this.dom):t.mount&&(this.mounted=!0)),this.editable=ci(this),li(this),this.nodeViews=di(this),this.docView=er(this.state.doc,ai(this),Ko(this),this.dom,this),this.domObserver=new Go(this,((t,e,n,r)=>ni(this,t,e,n,r))),this.domObserver.start(),function(t){for(let e in Zr){let n=Zr[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=e=>{so(t,e)&&!io(t,e)&&(t.editable||!(e.type in to))&&n(t,e)},eo[e]?{passive:!0}:void 0)}wn&&t.dom.addEventListener("input",(()=>null)),oo(t)}(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let t=this._props;this._props={};for(let e in t)this._props[e]=t[e];this._props.state=this.state}return this._props}update(t){t.handleDOMEvents!=this._props.handleDOMEvents&&oo(this);let e=this._props;this._props=t,t.plugins&&(t.plugins.forEach(hi),this.directPlugins=t.plugins),this.updateStateInner(t.state,e)}setProps(t){let e={};for(let t in this._props)e[t]=this._props[t];e.state=this.state;for(let n in t)e[n]=t[n];this.update(e)}updateState(t){this.updateStateInner(t,this._props)}updateStateInner(t,e){var n;let r=this.state,o=!1,i=!1;t.storedMarks&&this.composing&&(wo(this),i=!0),this.state=t;let s=r.plugins!=t.plugins||this._props.plugins!=e.plugins;if(s||this._props.plugins!=e.plugins||this._props.nodeViews!=e.nodeViews){let t=di(this);(function(t,e){let n=0,r=0;for(let r in t){if(t[r]!=e[r])return!0;n++}for(let t in e)r++;return n!=r})(t,this.nodeViews)&&(this.nodeViews=t,o=!0)}(s||e.handleDOMEvents!=this._props.handleDOMEvents)&&oo(this),this.editable=ci(this),li(this);let a=Ko(this),l=ai(this),c=r.plugins==t.plugins||r.doc.eq(t.doc)?t.scrollToSelection>r.scrollToSelection?"to selection":"preserve":"reset",d=o||!this.docView.matchesNode(t.doc,l,a);(d||!t.selection.eq(r.selection))&&(i=!0);let h="preserve"==c&&i&&null==this.dom.style.overflowAnchor&&function(t){let e,n,r=t.dom.getBoundingClientRect(),o=Math.max(0,r.top);for(let i=(r.left+r.right)/2,s=o+1;s<Math.min(innerHeight,r.bottom);s+=5){let r=t.root.elementFromPoint(i,s);if(!r||r==t.dom||!t.dom.contains(r))continue;let a=r.getBoundingClientRect();if(a.top>=o-20){e=r,n=a.top;break}}return{refDOM:e,refTop:n,stack:Dn(t.dom)}}(this);if(i){this.domObserver.stop();let e=d&&(fn||bn)&&!this.composing&&!r.selection.empty&&!t.selection.empty&&function(t,e){let n=Math.min(t.$anchor.sharedDepth(t.head),e.$anchor.sharedDepth(e.head));return t.$anchor.start(n)!=e.$anchor.start(n)}(r.selection,t.selection);if(d){let n=bn?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=ko(this)),(o||!this.docView.update(t.doc,l,a,this))&&(this.docView.updateOuterDeco(l),this.docView.destroy(),this.docView=er(t.doc,l,a,this.dom,this)),n&&!this.trackWrites&&(e=!0)}e||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&function(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return tn(e.node,e.offset,n.anchorNode,n.anchorOffset)}(this))?vr(this,e):(Or(this,t.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(r),!(null===(n=this.dragging)||void 0===n)&&n.node&&!r.doc.eq(t.doc)&&this.updateDraggedNode(this.dragging,r),"reset"==c?this.dom.scrollTop=0:"to selection"==c?this.scrollToSelection():h&&function({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;Rn(n,0==r?0:r-e)}(h)}scrollToSelection(){let t=this.domSelectionRange().focusNode;if(!this.someProp("handleScrollToSelection",(t=>t(this))))if(this.state.selection instanceof Ie){let e=this.docView.domAfterPos(this.state.selection.from);1==e.nodeType&&An(this,e.getBoundingClientRect(),t)}else An(this,this.coordsAtPos(this.state.selection.head,1),t)}destroyPluginViews(){let t;for(;t=this.pluginViews.pop();)t.destroy&&t.destroy()}updatePluginViews(t){if(t&&t.plugins==this.state.plugins&&this.directPlugins==this.prevDirectPlugins)for(let e=0;e<this.pluginViews.length;e++){let n=this.pluginViews[e];n.update&&n.update(this,t)}else{this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let t=0;t<this.directPlugins.length;t++){let e=this.directPlugins[t];e.spec.view&&this.pluginViews.push(e.spec.view(this))}for(let t=0;t<this.state.plugins.length;t++){let e=this.state.plugins[t];e.spec.view&&this.pluginViews.push(e.spec.view(this))}}}updateDraggedNode(t,e){let n=t.node,r=-1;if(this.state.doc.nodeAt(n.from)==n.node)r=n.from;else{let t=n.from+(this.state.doc.content.size-e.doc.content.size);(t>0&&this.state.doc.nodeAt(t))==n.node&&(r=t)}this.dragging=new Mo(t.slice,t.move,r<0?void 0:Ie.create(this.state.doc,r))}someProp(t,e){let n,r=this._props&&this._props[t];if(null!=r&&(n=e?e(r):r))return n;for(let r=0;r<this.directPlugins.length;r++){let o=this.directPlugins[r].props[t];if(null!=o&&(n=e?e(o):o))return n}let o=this.state.plugins;if(o)for(let r=0;r<o.length;r++){let i=o[r].props[t];if(null!=i&&(n=e?e(i):i))return n}}hasFocus(){if(fn){let t=this.root.activeElement;if(t==this.dom)return!0;if(!t||!this.dom.contains(t))return!1;for(;t&&this.dom!=t&&this.dom.contains(t);){if("false"==t.contentEditable)return!1;t=t.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&function(t){if(t.setActive)return t.setActive();if(In)return t.focus(In);let e=Dn(t);t.focus(null==In?{get preventScroll(){return In={preventScroll:!0},!0}}:void 0),In||(In=!1,Rn(e,0))}(this.dom),vr(this),this.domObserver.start()}get root(){let t=this._root;if(null==t)for(let t=this.dom.parentNode;t;t=t.parentNode)if(9==t.nodeType||11==t.nodeType&&t.host)return t.getSelection||(Object.getPrototypeOf(t).getSelection=()=>t.ownerDocument.getSelection()),this._root=t;return t||document}updateRoot(){this._root=null}posAtCoords(t){return zn(this,t)}coordsAtPos(t,e=1){return _n(this,t,e)}domAtPos(t,e=0){return this.docView.domFromPos(t,e)}nodeDOM(t){let e=this.docView.descAt(t);return e?e.nodeDOM:null}posAtDOM(t,e,n=-1){let r=this.docView.posFromDOM(t,e,n);if(null==r)throw new RangeError("DOM position not inside the editor");return r}endOfTextblock(t,e){return Gn(this,e||this.state,t)}pasteHTML(t,e){return Oo(this,"",t,!1,e||new ClipboardEvent("paste"))}pasteText(t,e){return Oo(this,t,null,!0,e||new ClipboardEvent("paste"))}destroy(){this.docView&&(function(t){t.domObserver.stop();for(let e in t.input.eventHandlers)t.dom.removeEventListener(e,t.input.eventHandlers[e]);clearTimeout(t.input.composingTimeout),clearTimeout(t.input.lastIOSEnterFallbackTimeout)}(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Ko(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Xe=null)}get isDestroyed(){return null==this.docView}dispatchEvent(t){return function(t,e){!io(t,e)&&Zr[e.type]&&(t.editable||!(e.type in to))&&Zr[e.type](t,e)}(this,t)}dispatch(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))}domSelectionRange(){let t=this.domSelection();return t?wn&&11===this.root.nodeType&&function(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}(this.dom.ownerDocument)==this.dom&&function(t,e){if(e.getComposedRanges){let n=e.getComposedRanges(t.root)[0];if(n)return Xo(t,n)}let n;function r(t){t.preventDefault(),t.stopImmediatePropagation(),n=t.getTargetRanges()[0]}return t.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),t.dom.removeEventListener("beforeinput",r,!0),n?Xo(t,n):null}(this,t)||t:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}function ai(t){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(t.editable),t.someProp("attributes",(n=>{if("function"==typeof n&&(n=n(t.state)),n)for(let t in n)"class"==t?e.class+=" "+n[t]:"style"==t?e.style=(e.style?e.style+";":"")+n[t]:!e[t]&&"contenteditable"!=t&&"nodeName"!=t&&(e[t]=String(n[t]))})),e.translate||(e.translate="no"),[Ro.node(0,t.state.doc.content.size,e)]}function li(t){if(t.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),t.cursorWrapper={dom:e,deco:Ro.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function ci(t){return!t.someProp("editable",(e=>!1===e(t.state)))}function di(t){let e=Object.create(null);function n(t){for(let n in t)Object.prototype.hasOwnProperty.call(e,n)||(e[n]=t[n])}return t.someProp("nodeViews",n),t.someProp("markViews",n),e}function hi(t){if(t.spec.state||t.spec.filterTransaction||t.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}for(var ui={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:"'"},pi={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},fi=typeof navigator<"u"&&/Mac/.test(navigator.platform),mi=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),gi=0;gi<10;gi++)ui[48+gi]=ui[96+gi]=String(gi);for(gi=1;gi<=24;gi++)ui[gi+111]="F"+gi;for(gi=65;gi<=90;gi++)ui[gi]=String.fromCharCode(gi+32),pi[gi]=String.fromCharCode(gi);for(var yi in ui)pi.hasOwnProperty(yi)||(pi[yi]=ui[yi]);const bi=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform);function vi(t){let e,n,r,o,i=t.split(/-(?!$)/),s=i[i.length-1];"Space"==s&&(s=" ");for(let t=0;t<i.length-1;t++){let s=i[t];if(/^(cmd|meta|m)$/i.test(s))o=!0;else if(/^a(lt)?$/i.test(s))e=!0;else if(/^(c|ctrl|control)$/i.test(s))n=!0;else if(/^s(hift)?$/i.test(s))r=!0;else{if(!/^mod$/i.test(s))throw new Error("Unrecognized modifier name: "+s);bi?o=!0:n=!0}}return e&&(s="Alt-"+s),n&&(s="Ctrl-"+s),o&&(s="Meta-"+s),r&&(s="Shift-"+s),s}function wi(t,e,n=!0){return e.altKey&&(t="Alt-"+t),e.ctrlKey&&(t="Ctrl-"+t),e.metaKey&&(t="Meta-"+t),n&&e.shiftKey&&(t="Shift-"+t),t}function ki(t){let e=function(t){let e=Object.create(null);for(let n in t)e[vi(n)]=t[n];return e}(t);return function(t,n){let r,o=function(t){var e=!(fi&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||mi&&t.shiftKey&&t.key&&1==t.key.length||"Unidentified"==t.key)&&t.key||(t.shiftKey?pi:ui)[t.keyCode]||t.key||"Unidentified";return"Esc"==e&&(e="Escape"),"Del"==e&&(e="Delete"),"Left"==e&&(e="ArrowLeft"),"Up"==e&&(e="ArrowUp"),"Right"==e&&(e="ArrowRight"),"Down"==e&&(e="ArrowDown"),e}(n),i=e[wi(o,n)];if(i&&i(t.state,t.dispatch,t))return!0;if(1==o.length&&" "!=o){if(n.shiftKey){let r=e[wi(o,n,!1)];if(r&&r(t.state,t.dispatch,t))return!0}if((n.shiftKey||n.altKey||n.metaKey||o.charCodeAt(0)>127)&&(r=ui[n.keyCode])&&r!=o){let o=e[wi(r,n)];if(o&&o(t.state,t.dispatch,t))return!0}}return!1}}function xi(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}function Si(t,e,n){let r=e.nodeBefore,o=e.pos-1;for(;!r.isTextblock;o--){if(r.type.spec.isolating)return!1;let t=r.lastChild;if(!t)return!1;r=t}let i=e.nodeAfter,s=e.pos+1;for(;!i.isTextblock;s++){if(i.type.spec.isolating)return!1;let t=i.firstChild;if(!t)return!1;i=t}let a=he(t.doc,o,s,$.empty);if(!a||a.from!=o||a instanceof Zt&&a.slice.size>=s-o)return!1;if(n){let e=t.tr.step(a);e.setSelection(De.create(e.doc,o)),n(e.scrollIntoView())}return!0}function Oi(t,e,n=!1){for(let r=t;r;r="start"==e?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(n&&1!=r.childCount)return!1}return!1}function Ci(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){if(t.index(e)>0)return t.doc.resolve(t.before(e+1));if(t.node(e).type.spec.isolating)break}return null}function Mi(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset<n.parent.content.size)?null:n}function Ti(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){let n=t.node(e);if(t.index(e)+1<n.childCount)return t.doc.resolve(t.after(e+1));if(n.type.spec.isolating)break}return null}function Ei(t){for(let e=0;e<t.edgeCount;e++){let{type:n}=t.edge(e);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}function Ni(t,e,n,r){let o,i,s=e.nodeBefore,a=e.nodeAfter,l=s.type.spec.isolating||a.type.spec.isolating;if(!l&&function(t,e,n){let r=e.nodeBefore,o=e.nodeAfter,i=e.index();return!(!(r&&o&&r.type.compatibleContent(o.type))||(!r.content.size&&e.parent.canReplace(i-1,i)?(n&&n(t.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),0):!e.parent.canReplace(i,i+1)||!o.isTextblock&&!le(t.doc,e.pos)||(n&&n(t.tr.clearIncompatible(e.pos,r.type,r.contentMatchAt(r.childCount)).join(e.pos).scrollIntoView()),0)))}(t,e,n))return!0;let c=!l&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(o=(i=s.contentMatchAt(s.childCount)).findWrapping(a.type))&&i.matchType(o[0]||a.type).validEnd){if(n){let r=e.pos+a.nodeSize,i=R.empty;for(let t=o.length-1;t>=0;t--)i=R.from(o[t].create(null,i));i=R.from(s.copy(i));let l=t.tr.step(new te(e.pos-1,r,e.pos,r,new $(i,1,0),o.length,!0)),c=r+2*o.length;le(l.doc,c)&&l.join(c),n(l.scrollIntoView())}return!0}let d=a.type.spec.isolating||r>0&&l?null:Te.findFrom(e,1),h=d&&d.$from.blockRange(d.$to),u=h&&oe(h);if(null!=u&&u>=e.depth)return n&&n(t.tr.lift(h,u).scrollIntoView()),!0;if(c&&Oi(a,"start",!0)&&Oi(s,"end")){let r=s,o=[];for(;o.push(r),!r.isTextblock;)r=r.lastChild;let i=a,l=1;for(;!i.isTextblock;i=i.firstChild)l++;if(r.canReplace(r.childCount,r.childCount,i.content)){if(n){let r=R.empty;for(let t=o.length-1;t>=0;t--)r=R.from(o[t].copy(r));n(t.tr.step(new te(e.pos-o.length,e.pos+a.nodeSize,e.pos+l,e.pos+a.nodeSize-l,new $(r,o.length,0),0,!0)).scrollIntoView())}return!0}}return!1}function Ai(t){return function(e,n){let r=e.selection,o=t<0?r.$from:r.$to,i=o.depth;for(;o.node(i).isInline;){if(!i)return!1;i--}return!!o.node(i).isTextblock&&(n&&n(e.tr.setSelection(De.create(e.doc,t<0?o.start(i):o.end(i)))),!0)}}const Di=Ai(-1),Ri=Ai(1);function Ii(t,e=null){return function(n,r){let o=!1;for(let r=0;r<n.selection.ranges.length&&!o;r++){let{$from:{pos:i},$to:{pos:s}}=n.selection.ranges[r];n.doc.nodesBetween(i,s,((r,i)=>{if(o)return!1;if(r.isTextblock&&!r.hasMarkup(t,e))if(r.type==t)o=!0;else{let e=n.doc.resolve(i),r=e.index();o=e.parent.canReplaceWith(r,r+1,t)}}))}if(!o)return!1;if(r){let o=n.tr;for(let r=0;r<n.selection.ranges.length;r++){let{$from:{pos:i},$to:{pos:s}}=n.selection.ranges[r];o.setBlockType(i,s,t,e)}r(o.scrollIntoView())}return!0}}function Li(t,e=null){return function(n,r){let{$from:o,$to:i}=n.selection,s=o.blockRange(i),a=!1,l=s;if(!s)return!1;if(s.depth>=2&&o.node(s.depth-1).type.compatibleContent(t)&&0==s.startIndex){if(0==o.index(s.depth-1))return!1;let t=n.doc.resolve(s.start-2);l=new tt(t,t,s.depth),s.endIndex<s.parent.childCount&&(s=new tt(o,n.doc.resolve(i.end(s.depth)),s.depth)),a=!0}let c=ie(l,t,e,s);return!!c&&(r&&r(function(t,e,n,r,o){let i=R.empty;for(let t=n.length-1;t>=0;t--)i=R.from(n[t].type.create(n[t].attrs,i));t.step(new te(e.start-(r?2:0),e.end,e.start,e.end,new $(i,0,0),n.length,!0));let s=0;for(let t=0;t<n.length;t++)n[t].type==o&&(s=t+1);let a=n.length-s,l=e.start+n.length-(r?2:0),c=e.parent;for(let n=e.startIndex,r=e.endIndex,o=!0;n<r;n++,o=!1)!o&&ae(t.doc,l,a)&&(t.split(l,a),l+=2*a),l+=c.child(n).nodeSize;return t}(n.tr,s,c,a,t).scrollIntoView()),!0)}}function Pi(t){return function(e,n){let{$from:r,$to:o}=e.selection,i=r.blockRange(o,(e=>e.childCount>0&&e.firstChild.type==t));return!!i&&(!n||(r.node(i.depth-1).type==t?function(t,e,n,r){let o=t.tr,i=r.end,s=r.$to.end(r.depth);i<s&&(o.step(new te(i-1,s,i,s,new $(R.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new tt(o.doc.resolve(r.$from.pos),o.doc.resolve(s),r.depth));const a=oe(r);if(null==a)return!1;o.lift(r,a);let l=o.mapping.map(i,-1)-1;return le(o.doc,l)&&o.join(l),e(o.scrollIntoView()),!0}(e,n,t,i):function(t,e,n){let r=t.tr,o=n.parent;for(let t=n.end,e=n.endIndex-1,i=n.startIndex;e>i;e--)t-=o.child(e).nodeSize,r.delete(t-1,t+1);let i=r.doc.resolve(n.start),s=i.nodeAfter;if(r.mapping.map(n.end)!=n.start+i.nodeAfter.nodeSize)return!1;let a=0==n.startIndex,l=n.endIndex==o.childCount,c=i.node(-1),d=i.index(-1);if(!c.canReplace(d+(a?0:1),d+1,s.content.append(l?R.empty:R.from(o))))return!1;let h=i.pos,u=h+s.nodeSize;return r.step(new te(h-(a?1:0),u+(l?1:0),h+1,u-1,new $((a?R.empty:R.from(o.copy(R.empty))).append(l?R.empty:R.from(o.copy(R.empty))),a?0:1,l?0:1),a?0:1)),e(r.scrollIntoView()),!0}(e,n,i)))}}function ji(t){const{state:e,transaction:n}=t;let{selection:r}=n,{doc:o}=n,{storedMarks:i}=n;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return i},get selection(){return r},get doc(){return o},get tr(){return r=n.selection,o=n.doc,i=n.storedMarks,n}}}typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform();class zi{constructor(t){this.editor=t.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=t.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:t,editor:e,state:n}=this,{view:r}=e,{tr:o}=n,i=this.buildProps(o);return Object.fromEntries(Object.entries(t).map((([t,e])=>[t,(...t)=>{const n=e(...t)(i);return!o.getMeta("preventDispatch")&&!this.hasCustomState&&r.dispatch(o),n}])))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(t,e=!0){const{rawCommands:n,editor:r,state:o}=this,{view:i}=r,s=[],a=!!t,l=t||o.tr,c={...Object.fromEntries(Object.entries(n).map((([t,n])=>[t,(...t)=>{const r=this.buildProps(l,e),o=n(...t)(r);return s.push(o),c}]))),run:()=>(!a&&e&&!l.getMeta("preventDispatch")&&!this.hasCustomState&&i.dispatch(l),s.every((t=>!0===t)))};return c}createCan(t){const{rawCommands:e,state:n}=this,r=t||n.tr,o=this.buildProps(r,false);return{...Object.fromEntries(Object.entries(e).map((([t,e])=>[t,(...t)=>e(...t)({...o,dispatch:void 0})]))),chain:()=>this.createChain(r,false)}}buildProps(t,e=!0){const{rawCommands:n,editor:r,state:o}=this,{view:i}=r,s={tr:t,editor:r,view:i,state:ji({state:o,transaction:t}),dispatch:e?()=>{}:void 0,chain:()=>this.createChain(t,e),can:()=>this.createCan(t),get commands(){return Object.fromEntries(Object.entries(n).map((([t,e])=>[t,(...t)=>e(...t)(s)])))}};return s}}class $i{constructor(){this.callbacks={}}on(t,e){return this.callbacks[t]||(this.callbacks[t]=[]),this.callbacks[t].push(e),this}emit(t,...e){const n=this.callbacks[t];return n&&n.forEach((t=>t.apply(this,e))),this}off(t,e){const n=this.callbacks[t];return n&&(e?this.callbacks[t]=n.filter((t=>t!==e)):delete this.callbacks[t]),this}removeAllListeners(){this.callbacks={}}}function Bi(t,e,n){return void 0===t.config[e]&&t.parent?Bi(t.parent,e,n):"function"==typeof t.config[e]?t.config[e].bind({...n,parent:t.parent?Bi(t.parent,e,n):null}):t.config[e]}function Fi(t){return{baseExtensions:t.filter((t=>"extension"===t.type)),nodeExtensions:t.filter((t=>"node"===t.type)),markExtensions:t.filter((t=>"mark"===t.type))}}function _i(t){const e=[],{nodeExtensions:n,markExtensions:r}=Fi(t),o=[...n,...r],i={default:null,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return t.forEach((t=>{const n=Bi(t,"addGlobalAttributes",{name:t.name,options:t.options,storage:t.storage,extensions:o});n&&n().forEach((t=>{t.types.forEach((n=>{Object.entries(t.attributes).forEach((([t,r])=>{e.push({type:n,name:t,attribute:{...i,...r}})}))}))}))})),o.forEach((t=>{const n={name:t.name,options:t.options,storage:t.storage},r=Bi(t,"addAttributes",n);if(!r)return;const o=r();Object.entries(o).forEach((([n,r])=>{const o={...i,...r};"function"==typeof(null==o?void 0:o.default)&&(o.default=o.default()),null!=o&&o.isRequired&&void 0===(null==o?void 0:o.default)&&delete o.default,e.push({type:t.name,name:n,attribute:o})}))})),e}function Vi(t,e){if("string"==typeof t){if(!e.nodes[t])throw Error(`There is no node type named '${t}'. Maybe you forgot to add the extension?`);return e.nodes[t]}return t}function Hi(...t){return t.filter((t=>!!t)).reduce(((t,e)=>{const n={...t};return Object.entries(e).forEach((([t,e])=>{if(n[t])if("class"===t){const r=e?e.split(" "):[],o=n[t]?n[t].split(" "):[],i=r.filter((t=>!o.includes(t)));n[t]=[...o,...i].join(" ")}else if("style"===t){const r=e?e.split(";").map((t=>t.trim())).filter(Boolean):[],o=n[t]?n[t].split(";").map((t=>t.trim())).filter(Boolean):[],i=new Map;o.forEach((t=>{const[e,n]=t.split(":").map((t=>t.trim()));i.set(e,n)})),r.forEach((t=>{const[e,n]=t.split(":").map((t=>t.trim()));i.set(e,n)})),n[t]=Array.from(i.entries()).map((([t,e])=>`${t}: ${e}`)).join("; ")}else n[t]=e;else n[t]=e})),n}),{})}function Wi(t,e){return e.filter((e=>e.type===t.type.name)).filter((t=>t.attribute.rendered)).map((e=>e.attribute.renderHTML?e.attribute.renderHTML(t.attrs)||{}:{[e.name]:t.attrs[e.name]})).reduce(((t,e)=>Hi(t,e)),{})}function Ki(t){return"function"==typeof t}function qi(t,e=void 0,...n){return Ki(t)?e?t.bind(e)(...n):t(...n):t}function Ji(t,e){return"style"in t?t:{...t,getAttrs:n=>{const r=t.getAttrs?t.getAttrs(n):t.attrs;if(!1===r)return!1;const o=e.reduce(((t,e)=>{const r=e.attribute.parseHTML?e.attribute.parseHTML(n):function(t){return"string"!=typeof t?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):"true"===t||"false"!==t&&t}(n.getAttribute(e.name));return null==r?t:{...t,[e.name]:r}}),{});return{...r,...o}}}}function Ui(t){return Object.fromEntries(Object.entries(t).filter((([t,e])=>("attrs"!==t||!function(t={}){return 0===Object.keys(t).length&&t.constructor===Object}(e))&&null!=e)))}function Gi(t,e){return e.nodes[t]||e.marks[t]||null}function Yi(t,e){return Array.isArray(e)?e.some((e=>("string"==typeof e?e:e.name)===t.name)):e}const Qi=(t,e=500)=>{let n="";const r=t.parentOffset;return t.parent.nodesBetween(Math.max(0,r-e),r,((t,e,o,i)=>{var s,a;const l=(null===(a=(s=t.type.spec).toText)||void 0===a?void 0:a.call(s,{node:t,pos:e,parent:o,index:i}))||t.textContent||"%leaf%";n+=t.isAtom&&!t.isText?l:l.slice(0,Math.max(0,r-e))})),n};function Xi(t){return"[object RegExp]"===Object.prototype.toString.call(t)}class Zi{constructor(t){this.find=t.find,this.handler=t.handler}}const ts=(t,e)=>{if(Xi(e))return e.exec(t);const n=e(t);if(!n)return null;const r=[n.text];return r.index=n.index,r.input=t,r.data=n.data,n.replaceWith&&(n.text.includes(n.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),r.push(n.replaceWith)),r};function es(t){var e;const{editor:n,from:r,to:o,text:i,rules:s,plugin:a}=t,{view:l}=n;if(l.composing)return!1;const c=l.state.doc.resolve(r);if(c.parent.type.spec.code||null!==(e=c.nodeBefore||c.nodeAfter)&&void 0!==e&&e.marks.find((t=>t.type.spec.code)))return!1;let d=!1;const h=Qi(c)+i;return s.forEach((t=>{if(d)return;const e=ts(h,t.find);if(!e)return;const s=l.state.tr,c=ji({state:l.state,transaction:s}),u={from:r-(e[0].length-i.length),to:o},{commands:p,chain:f,can:m}=new zi({editor:n,state:c});null===t.handler({state:c,range:u,match:e,commands:p,chain:f,can:m})||!s.steps.length||(s.setMeta(a,{transform:s,from:r,to:o,text:i}),l.dispatch(s),d=!0)})),d}function ns(t){const{editor:e,rules:n}=t,r=new qe({state:{init:()=>null,apply(t,o){const i=t.getMeta(r);if(i)return i;const s=t.getMeta("applyInputRules");return!!s&&setTimeout((()=>{const{from:t,text:o}=s,i=t+o.length;es({editor:e,from:t,to:i,text:o,rules:n,plugin:r})})),t.selectionSet||t.docChanged?null:o}},props:{handleTextInput:(t,o,i,s)=>es({editor:e,from:o,to:i,text:s,rules:n,plugin:r}),handleDOMEvents:{compositionend:t=>(setTimeout((()=>{const{$cursor:o}=t.state.selection;o&&es({editor:e,from:o.pos,to:o.pos,text:"",rules:n,plugin:r})})),!1)},handleKeyDown(t,o){if("Enter"!==o.key)return!1;const{$cursor:i}=t.state.selection;return!!i&&es({editor:e,from:i.pos,to:i.pos,text:"\n",rules:n,plugin:r})}},isInputRules:!0});return r}function rs(t){return"Object"===function(t){return Object.prototype.toString.call(t).slice(8,-1)}(t)&&(t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype)}function is(t,e){const n={...t};return rs(t)&&rs(e)&&Object.keys(e).forEach((r=>{rs(e[r])&&rs(t[r])?n[r]=is(t[r],e[r]):n[r]=e[r]})),n}class ss{constructor(t={}){this.type="mark",this.name="mark",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...t},this.name=this.config.name,t.defaultOptions&&Object.keys(t.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=qi(Bi(this,"addOptions",{name:this.name}))),this.storage=qi(Bi(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(t={}){return new ss(t)}configure(t={}){const e=this.extend({...this.config,addOptions:()=>is(this.options,t)});return e.name=this.name,e.parent=this.parent,e}extend(t={}){const e=new ss(t);return e.parent=this,this.child=e,e.name=t.name?t.name:e.parent.name,t.defaultOptions&&Object.keys(t.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${e.name}".`),e.options=qi(Bi(e,"addOptions",{name:e.name})),e.storage=qi(Bi(e,"addStorage",{name:e.name,options:e.options})),e}static handleExit({editor:t,mark:e}){const{tr:n}=t.state,r=t.state.selection.$from;if(r.pos===r.end()){const o=r.marks();if(!o.find((t=>(null==t?void 0:t.type.name)===e.name)))return!1;const i=o.find((t=>(null==t?void 0:t.type.name)===e.name));return i&&n.removeStoredMark(i),n.insertText(" ",r.pos),t.view.dispatch(n),!0}return!1}}class as{constructor(t){this.find=t.find,this.handler=t.handler}}const ls=(t,e,n)=>{if(Xi(e))return[...t.matchAll(e)];const r=e(t,n);return r?r.map((e=>{const n=[e.text];return n.index=e.index,n.input=t,n.data=e.data,e.replaceWith&&(e.text.includes(e.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),n.push(e.replaceWith)),n})):[]};function cs(t){const{editor:e,rules:n}=t;let r=null,o=!1,i=!1,s=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,a=typeof DragEvent<"u"?new DragEvent("drop"):null;const l=({state:t,from:n,to:r,rule:o,pasteEvt:i})=>{const l=t.tr,c=ji({state:t,transaction:l});if(function(t){const{editor:e,state:n,from:r,to:o,rule:i,pasteEvent:s,dropEvent:a}=t,{commands:l,chain:c,can:d}=new zi({editor:e,state:n}),h=[];return n.doc.nodesBetween(r,o,((t,e)=>{if(!t.isTextblock||t.type.spec.code)return;const u=Math.max(r,e),p=Math.min(o,e+t.content.size),f=t.textBetween(u-e,p-e,void 0,"");ls(f,i.find,s).forEach((t=>{if(void 0===t.index)return;const e=u+t.index+1,r=e+t[0].length,o={from:n.tr.mapping.map(e),to:n.tr.mapping.map(r)},p=i.handler({state:n,range:o,match:t,commands:l,chain:c,can:d,pasteEvent:s,dropEvent:a});h.push(p)}))})),h.every((t=>null!==t))}({editor:e,state:c,from:Math.max(n-1,0),to:r.b-1,rule:o,pasteEvent:i,dropEvent:a})&&l.steps.length)return a=typeof DragEvent<"u"?new DragEvent("drop"):null,s=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,l};return n.map((t=>new qe({view(t){const e=e=>{var n;r=null!==(n=t.dom.parentElement)&&void 0!==n&&n.contains(e.target)?t.dom.parentElement:null};return window.addEventListener("dragstart",e),{destroy(){window.removeEventListener("dragstart",e)}}},props:{handleDOMEvents:{drop:(t,e)=>(i=r===t.dom.parentElement,a=e,!1),paste:(t,e)=>{var n;const r=null===(n=e.clipboardData)||void 0===n?void 0:n.getData("text/html");return s=e,o=!(null==r||!r.includes("data-pm-slice")),!1}}},appendTransaction:(e,n,r)=>{const a=e[0],c="paste"===a.getMeta("uiEvent")&&!o,d="drop"===a.getMeta("uiEvent")&&!i,h=a.getMeta("applyPasteRules"),u=!!h;if(!c&&!d&&!u)return;if(u){const{from:e,text:n}=h,o=e+n.length,i=(t=>{var e;const n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return null===(e=n.clipboardData)||void 0===e||e.setData("text/html",t),n})(n);return l({rule:t,state:r,from:e,to:{b:o},pasteEvt:i})}const p=n.doc.content.findDiffStart(r.doc.content),f=n.doc.content.findDiffEnd(r.doc.content);return function(t){return"number"==typeof t}(p)&&f&&p!==f.b?l({rule:t,state:r,from:p,to:f,pasteEvt:s}):void 0}})))}class ds{constructor(t,e){this.splittableMarks=[],this.editor=e,this.extensions=ds.resolve(t),this.schema=function(t,e){var n;const r=_i(t),{nodeExtensions:o,markExtensions:i}=Fi(t),s=null===(n=o.find((t=>Bi(t,"topNode"))))||void 0===n?void 0:n.name,a=Object.fromEntries(o.map((n=>{const o=r.filter((t=>t.type===n.name)),i={name:n.name,options:n.options,storage:n.storage,editor:e},s=Ui({...t.reduce(((t,e)=>{const r=Bi(e,"extendNodeSchema",i);return{...t,...r?r(n):{}}}),{}),content:qi(Bi(n,"content",i)),marks:qi(Bi(n,"marks",i)),group:qi(Bi(n,"group",i)),inline:qi(Bi(n,"inline",i)),atom:qi(Bi(n,"atom",i)),selectable:qi(Bi(n,"selectable",i)),draggable:qi(Bi(n,"draggable",i)),code:qi(Bi(n,"code",i)),whitespace:qi(Bi(n,"whitespace",i)),defining:qi(Bi(n,"defining",i)),isolating:qi(Bi(n,"isolating",i)),attrs:Object.fromEntries(o.map((t=>{var e;return[t.name,{default:null===(e=null==t?void 0:t.attribute)||void 0===e?void 0:e.default}]})))}),a=qi(Bi(n,"parseHTML",i));a&&(s.parseDOM=a.map((t=>Ji(t,o))));const l=Bi(n,"renderHTML",i);l&&(s.toDOM=t=>l({node:t,HTMLAttributes:Wi(t,o)}));const c=Bi(n,"renderText",i);return c&&(s.toText=c),[n.name,s]}))),l=Object.fromEntries(i.map((n=>{const o=r.filter((t=>t.type===n.name)),i={name:n.name,options:n.options,storage:n.storage,editor:e},s=Ui({...t.reduce(((t,e)=>{const r=Bi(e,"extendMarkSchema",i);return{...t,...r?r(n):{}}}),{}),inclusive:qi(Bi(n,"inclusive",i)),excludes:qi(Bi(n,"excludes",i)),group:qi(Bi(n,"group",i)),spanning:qi(Bi(n,"spanning",i)),code:qi(Bi(n,"code",i)),attrs:Object.fromEntries(o.map((t=>{var e;return[t.name,{default:null===(e=null==t?void 0:t.attribute)||void 0===e?void 0:e.default}]})))}),a=qi(Bi(n,"parseHTML",i));a&&(s.parseDOM=a.map((t=>Ji(t,o))));const l=Bi(n,"renderHTML",i);return l&&(s.toDOM=t=>l({mark:t,HTMLAttributes:Wi(t,o)})),[n.name,s]})));return new kt({topNode:s,nodes:a,marks:l})}(this.extensions,e),this.setupExtensions()}static resolve(t){const e=ds.sort(ds.flatten(t)),n=function(t){const e=t.filter(((e,n)=>t.indexOf(e)!==n));return Array.from(new Set(e))}(e.map((t=>t.name)));return n.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${n.map((t=>`'${t}'`)).join(", ")}]. This can lead to issues.`),e}static flatten(t){return t.map((t=>{const e=Bi(t,"addExtensions",{name:t.name,options:t.options,storage:t.storage});return e?[t,...this.flatten(e())]:t})).flat(10)}static sort(t){return t.sort(((t,e)=>{const n=Bi(t,"priority")||100,r=Bi(e,"priority")||100;return n>r?-1:n<r?1:0}))}get commands(){return this.extensions.reduce(((t,e)=>{const n=Bi(e,"addCommands",{name:e.name,options:e.options,storage:e.storage,editor:this.editor,type:Gi(e.name,this.schema)});return n?{...t,...n()}:t}),{})}get plugins(){const{editor:t}=this,e=ds.sort([...this.extensions].reverse()),n=[],r=[],o=e.map((e=>{const o={name:e.name,options:e.options,storage:e.storage,editor:t,type:Gi(e.name,this.schema)},i=[],s=Bi(e,"addKeyboardShortcuts",o);let a={};if("mark"===e.type&&Bi(e,"exitable",o)&&(a.ArrowRight=()=>ss.handleExit({editor:t,mark:e})),s){const e=Object.fromEntries(Object.entries(s()).map((([e,n])=>[e,()=>n({editor:t})])));a={...a,...e}}const l=new qe({props:{handleKeyDown:ki(a)}});i.push(l);const c=Bi(e,"addInputRules",o);Yi(e,t.options.enableInputRules)&&c&&n.push(...c());const d=Bi(e,"addPasteRules",o);Yi(e,t.options.enablePasteRules)&&d&&r.push(...d());const h=Bi(e,"addProseMirrorPlugins",o);if(h){const t=h();i.push(...t)}return i})).flat();return[ns({editor:t,rules:n}),...cs({editor:t,rules:r}),...o]}get attributes(){return _i(this.extensions)}get nodeViews(){const{editor:t}=this,{nodeExtensions:e}=Fi(this.extensions);return Object.fromEntries(e.filter((t=>!!Bi(t,"addNodeView"))).map((e=>{const n=this.attributes.filter((t=>t.type===e.name)),r={name:e.name,options:e.options,storage:e.storage,editor:t,type:Vi(e.name,this.schema)},o=Bi(e,"addNodeView",r);if(!o)return[];return[e.name,(r,i,s,a,l)=>{const c=Wi(r,n);return o()({node:r,view:i,getPos:s,decorations:a,innerDecorations:l,editor:t,extension:e,HTMLAttributes:c})}]})))}setupExtensions(){this.extensions.forEach((t=>{var e;this.editor.extensionStorage[t.name]=t.storage;const n={name:t.name,options:t.options,storage:t.storage,editor:this.editor,type:Gi(t.name,this.schema)};"mark"===t.type&&(null===(e=qi(Bi(t,"keepOnSplit",n)))||void 0===e||e)&&this.splittableMarks.push(t.name);const r=Bi(t,"onBeforeCreate",n),o=Bi(t,"onCreate",n),i=Bi(t,"onUpdate",n),s=Bi(t,"onSelectionUpdate",n),a=Bi(t,"onTransaction",n),l=Bi(t,"onFocus",n),c=Bi(t,"onBlur",n),d=Bi(t,"onDestroy",n);r&&this.editor.on("beforeCreate",r),o&&this.editor.on("create",o),i&&this.editor.on("update",i),s&&this.editor.on("selectionUpdate",s),a&&this.editor.on("transaction",a),l&&this.editor.on("focus",l),c&&this.editor.on("blur",c),d&&this.editor.on("destroy",d)}))}}class hs{constructor(t={}){this.type="extension",this.name="extension",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...t},this.name=this.config.name,t.defaultOptions&&Object.keys(t.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=qi(Bi(this,"addOptions",{name:this.name}))),this.storage=qi(Bi(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(t={}){return new hs(t)}configure(t={}){const e=this.extend({...this.config,addOptions:()=>is(this.options,t)});return e.name=this.name,e.parent=this.parent,e}extend(t={}){const e=new hs({...this.config,...t});return e.parent=this,this.child=e,e.name=t.name?t.name:e.parent.name,t.defaultOptions&&Object.keys(t.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${e.name}".`),e.options=qi(Bi(e,"addOptions",{name:e.name})),e.storage=qi(Bi(e,"addStorage",{name:e.name,options:e.options})),e}}function us(t,e,n){const{from:r,to:o}=e,{blockSeparator:i="\n\n",textSerializers:s={}}=n||{};let a="";return t.nodesBetween(r,o,((t,n,l,c)=>{var d;t.isBlock&&n>r&&(a+=i);const h=null==s?void 0:s[t.type.name];if(h)return l&&(a+=h({node:t,pos:n,parent:l,index:c,range:e})),!1;t.isText&&(a+=null===(d=null==t?void 0:t.text)||void 0===d?void 0:d.slice(Math.max(r,n)-n,o-n))})),a}function ps(t){return Object.fromEntries(Object.entries(t.nodes).filter((([,t])=>t.spec.toText)).map((([t,e])=>[t,e.spec.toText])))}const fs=hs.create({name:"clipboardTextSerializer",addOptions:()=>({blockSeparator:void 0}),addProseMirrorPlugins(){return[new qe({key:new Ge("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:t}=this,{state:e,schema:n}=t,{doc:r,selection:o}=e,{ranges:i}=o,s=Math.min(...i.map((t=>t.$from.pos))),a=Math.max(...i.map((t=>t.$to.pos))),l=ps(n);return us(r,{from:s,to:a},{...void 0!==this.options.blockSeparator?{blockSeparator:this.options.blockSeparator}:{},textSerializers:l})}}})]}});function ms(t,e,n={strict:!0}){const r=Object.keys(e);return!r.length||r.every((r=>n.strict?e[r]===t[r]:Xi(e[r])?e[r].test(t[r]):e[r]===t[r]))}function gs(t,e,n={}){return t.find((t=>t.type===e&&ms(t.attrs,n)))}function ys(t,e,n={}){return!!gs(t,e,n)}function bs(t,e,n={}){if(!t||!e)return;let r=t.parent.childAfter(t.parentOffset);if(t.parentOffset===r.offset&&0!==r.offset&&(r=t.parent.childBefore(t.parentOffset)),!r.node)return;const o=gs([...r.node.marks],e,n);if(!o)return;let i=r.index,s=t.start()+r.offset,a=i+1,l=s+r.node.nodeSize;for(gs([...r.node.marks],e,n);i>0&&o.isInSet(t.parent.child(i-1).marks);)i-=1,s-=t.parent.child(i).nodeSize;for(;a<t.parent.childCount&&ys([...t.parent.child(a).marks],e,n);)l+=t.parent.child(a).nodeSize,a+=1;return{from:s,to:l}}function vs(t,e){if("string"==typeof t){if(!e.marks[t])throw Error(`There is no mark type named '${t}'. Maybe you forgot to add the extension?`);return e.marks[t]}return t}function ws(t){return t instanceof De}function ks(t=0,e=0,n=0){return Math.min(Math.max(t,e),n)}function xs(t,e=null){if(!e)return null;const n=Te.atStart(t),r=Te.atEnd(t);if("start"===e||!0===e)return n;if("end"===e)return r;const o=n.from,i=r.to;return"all"===e?De.create(t,ks(0,o,i),ks(t.content.size,o,i)):De.create(t,ks(e,o,i),ks(e,o,i))}function Ss(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}const Os=t=>{const e=t.childNodes;for(let n=e.length-1;n>=0;n-=1){const r=e[n];3===r.nodeType&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?t.removeChild(r):1===r.nodeType&&Os(r)}return t};function Cs(t){const e=`<body>${t}</body>`,n=(new window.DOMParser).parseFromString(e,"text/html").body;return Os(n)}function Ms(t,e,n){n={slice:!0,parseOptions:{},...n};const r="string"==typeof t;if("object"==typeof t&&null!==t)try{if(Array.isArray(t)&&t.length>0)return R.fromArray(t.map((t=>e.nodeFromJSON(t))));const r=e.nodeFromJSON(t);return n.errorOnInvalidContent&&r.check(),r}catch(r){if(n.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:r});return console.warn("[tiptap warn]: Invalid content.","Passed value:",t,"Error:",r),Ms("",e,n)}if(r){if(n.errorOnInvalidContent){let r=!1,o="";const i=new kt({topNode:e.spec.topNode,marks:e.spec.marks,nodes:e.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:t=>(r=!0,o="string"==typeof t?t:t.outerHTML,null)}]}})});if(n.slice?St.fromSchema(i).parseSlice(Cs(t),n.parseOptions):St.fromSchema(i).parse(Cs(t),n.parseOptions),n.errorOnInvalidContent&&r)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${o}`)})}const r=St.fromSchema(e);return n.slice?r.parseSlice(Cs(t),n.parseOptions).content:r.parse(Cs(t),n.parseOptions)}return Ms("",e,n)}function Ts(){return typeof navigator<"u"&&/Mac/.test(navigator.platform)}function Es(t,e,n={}){const{from:r,to:o,empty:i}=t.selection,s=e?Vi(e,t.schema):null,a=[];t.doc.nodesBetween(r,o,((t,e)=>{if(t.isText)return;const n=Math.max(r,e),i=Math.min(o,e+t.nodeSize);a.push({node:t,from:n,to:i})}));const l=o-r,c=a.filter((t=>!s||s.name===t.node.type.name)).filter((t=>ms(t.node.attrs,n,{strict:!1})));return i?!!c.length:c.reduce(((t,e)=>t+e.to-e.from),0)>=l}function Ns(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function As(t,e){const n="string"==typeof e?[e]:e;return Object.keys(t).reduce(((e,r)=>(n.includes(r)||(e[r]=t[r]),e)),{})}function Ds(t,e,n={},r={}){return Ms(t,e,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}function Rs(t,e){const n=vs(e,t.schema),{from:r,to:o,empty:i}=t.selection,s=[];i?(t.storedMarks&&s.push(...t.storedMarks),s.push(...t.selection.$head.marks())):t.doc.nodesBetween(r,o,(t=>{s.push(...t.marks)}));const a=s.find((t=>t.type.name===n.name));return a?{...a.attrs}:{}}function Is(t){return e=>function(t,e){for(let n=t.depth;n>0;n-=1){const r=t.node(n);if(e(r))return{pos:n>0?t.before(n):0,start:t.start(n),depth:n,node:r}}}(e.$from,t)}function Ls(t,e){const n=Ns("string"==typeof e?e:e.name,t.schema);return"node"===n?function(t,e){const n=Vi(e,t.schema),{from:r,to:o}=t.selection,i=[];t.doc.nodesBetween(r,o,(t=>{i.push(t)}));const s=i.reverse().find((t=>t.type.name===n.name));return s?{...s.attrs}:{}}(t,e):"mark"===n?Rs(t,e):{}}function Ps(t){const e=function(t,e=JSON.stringify){const n={};return t.filter((t=>{const r=e(t);return!Object.prototype.hasOwnProperty.call(n,r)&&(n[r]=!0)}))}(t);return 1===e.length?e:e.filter(((t,n)=>!e.filter(((t,e)=>e!==n)).some((e=>t.oldRange.from>=e.oldRange.from&&t.oldRange.to<=e.oldRange.to&&t.newRange.from>=e.newRange.from&&t.newRange.to<=e.newRange.to))))}function js(t,e,n){const r=[];return t===e?n.resolve(t).marks().forEach((e=>{const o=bs(n.resolve(t),e.type);o&&r.push({mark:e,...o})})):n.nodesBetween(t,e,((t,e)=>{!t||void 0===(null==t?void 0:t.nodeSize)||r.push(...t.marks.map((n=>({from:e,to:e+t.nodeSize,mark:n}))))})),r}function zs(t,e,n){return Object.fromEntries(Object.entries(n).filter((([n])=>{const r=t.find((t=>t.type===e&&t.name===n));return!!r&&r.attribute.keepOnSplit})))}function $s(t,e,n={}){const{empty:r,ranges:o}=t.selection,i=e?vs(e,t.schema):null;if(r)return!!(t.storedMarks||t.selection.$from.marks()).filter((t=>!i||i.name===t.type.name)).find((t=>ms(t.attrs,n,{strict:!1})));let s=0;const a=[];if(o.forEach((({$from:e,$to:n})=>{const r=e.pos,o=n.pos;t.doc.nodesBetween(r,o,((t,e)=>{if(!t.isText&&!t.marks.length)return;const n=Math.max(r,e),i=Math.min(o,e+t.nodeSize);s+=i-n,a.push(...t.marks.map((t=>({mark:t,from:n,to:i}))))}))})),0===s)return!1;const l=a.filter((t=>!i||i.name===t.mark.type.name)).filter((t=>ms(t.mark.attrs,n,{strict:!1}))).reduce(((t,e)=>t+e.to-e.from),0),c=a.filter((t=>!i||t.mark.type!==i&&t.mark.type.excludes(i))).reduce(((t,e)=>t+e.to-e.from),0);return(l>0?l+c:l)>=s}function Bs(t,e){const{nodeExtensions:n}=Fi(e),r=n.find((e=>e.name===t));if(!r)return!1;const o=qi(Bi(r,"group",{name:r.name,options:r.options,storage:r.storage}));return"string"==typeof o&&o.split(" ").includes("list")}function Fs(t,{checkChildren:e=!0,ignoreWhitespace:n=!1}={}){var r;if(n){if("hardBreak"===t.type.name)return!0;if(t.isText)return/^\s*$/m.test(null!==(r=t.text)&&void 0!==r?r:"")}if(t.isText)return!t.text;if(t.isAtom||t.isLeaf)return!1;if(0===t.content.childCount)return!0;if(e){let r=!0;return t.content.forEach((t=>{!1!==r&&(Fs(t,{ignoreWhitespace:n,checkChildren:e})||(r=!1))})),r}return!1}function _s(t,e){const n=t.storedMarks||t.selection.$to.parentOffset&&t.selection.$from.marks();if(n){const r=n.filter((t=>null==e?void 0:e.includes(t.type.name)));t.tr.ensureMarks(r)}}const Vs=(t,e)=>{const n=Is((t=>t.type===e))(t.selection);if(!n)return!0;const r=t.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(void 0===r)return!0;const o=t.doc.nodeAt(r);return n.node.type===(null==o?void 0:o.type)&&le(t.doc,n.pos)&&t.join(n.pos),!0},Hs=(t,e)=>{const n=Is((t=>t.type===e))(t.selection);if(!n)return!0;const r=t.doc.resolve(n.start).after(n.depth);if(void 0===r)return!0;const o=t.doc.nodeAt(r);return n.node.type===(null==o?void 0:o.type)&&le(t.doc,r)&&t.join(r),!0};var Ws=Object.freeze({__proto__:null,blur:()=>({editor:t,view:e})=>(requestAnimationFrame((()=>{var n;t.isDestroyed||(e.dom.blur(),null===(n=null==window?void 0:window.getSelection())||void 0===n||n.removeAllRanges())})),!0),clearContent:(t=!1)=>({commands:e})=>e.setContent("",t),clearNodes:()=>({state:t,tr:e,dispatch:n})=>{const{selection:r}=e,{ranges:o}=r;return n&&o.forEach((({$from:n,$to:r})=>{t.doc.nodesBetween(n.pos,r.pos,((t,n)=>{if(t.type.isText)return;const{doc:r,mapping:o}=e,i=r.resolve(o.map(n)),s=r.resolve(o.map(n+t.nodeSize)),a=i.blockRange(s);if(!a)return;const l=oe(a);if(t.type.isTextblock){const{defaultType:t}=i.parent.contentMatchAt(i.index());e.setNodeMarkup(a.start,t)}(l||0===l)&&e.lift(a,l)}))})),!0},command:t=>e=>t(e),createParagraphNear:()=>({state:t,dispatch:e})=>((t,e)=>{let n=t.selection,{$from:r,$to:o}=n;if(n instanceof Pe||r.parent.inlineContent||o.parent.inlineContent)return!1;let i=Ei(o.parent.contentMatchAt(o.indexAfter()));if(!i||!i.isTextblock)return!1;if(e){let n=(!r.parentOffset&&o.index()<o.parent.childCount?r:o).pos,s=t.tr.insert(n,i.createAndFill());s.setSelection(De.create(s.doc,n+1)),e(s.scrollIntoView())}return!0})(t,e),cut:(t,e)=>({editor:n,tr:r})=>{const{state:o}=n,i=o.doc.slice(t.from,t.to);r.deleteRange(t.from,t.to);const s=r.mapping.map(e);return r.insert(s,i.content),r.setSelection(new De(r.doc.resolve(s-1))),!0},deleteCurrentNode:()=>({tr:t,dispatch:e})=>{const{selection:n}=t,r=n.$anchor.node();if(r.content.size>0)return!1;const o=t.selection.$anchor;for(let n=o.depth;n>0;n-=1)if(o.node(n).type===r.type){if(e){const e=o.before(n),r=o.after(n);t.delete(e,r).scrollIntoView()}return!0}return!1},deleteNode:t=>({tr:e,state:n,dispatch:r})=>{const o=Vi(t,n.schema),i=e.selection.$anchor;for(let t=i.depth;t>0;t-=1)if(i.node(t).type===o){if(r){const n=i.before(t),r=i.after(t);e.delete(n,r).scrollIntoView()}return!0}return!1},deleteRange:t=>({tr:e,dispatch:n})=>{const{from:r,to:o}=t;return n&&e.delete(r,o),!0},deleteSelection:()=>({state:t,dispatch:e})=>((t,e)=>!t.selection.empty&&(e&&e(t.tr.deleteSelection().scrollIntoView()),!0))(t,e),enter:()=>({commands:t})=>t.keyboardShortcut("Enter"),exitCode:()=>({state:t,dispatch:e})=>((t,e)=>{let{$head:n,$anchor:r}=t.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let o=n.node(-1),i=n.indexAfter(-1),s=Ei(o.contentMatchAt(i));if(!s||!o.canReplaceWith(i,i,s))return!1;if(e){let r=n.after(),o=t.tr.replaceWith(r,r,s.createAndFill());o.setSelection(Te.near(o.doc.resolve(r),1)),e(o.scrollIntoView())}return!0})(t,e),extendMarkRange:(t,e={})=>({tr:n,state:r,dispatch:o})=>{const i=vs(t,r.schema),{doc:s,selection:a}=n,{$from:l,from:c,to:d}=a;if(o){const t=bs(l,i,e);if(t&&t.from<=c&&t.to>=d){const e=De.create(s,t.from,t.to);n.setSelection(e)}}return!0},first:t=>e=>{const n="function"==typeof t?t(e):t;for(let t=0;t<n.length;t+=1)if(n[t](e))return!0;return!1},focus:(t=null,e={})=>({editor:n,view:r,tr:o,dispatch:i})=>{e={scrollIntoView:!0,...e};const s=()=>{Ss()&&r.dom.focus(),requestAnimationFrame((()=>{n.isDestroyed||(r.focus(),null!=e&&e.scrollIntoView&&n.commands.scrollIntoView())}))};if(r.hasFocus()&&null===t||!1===t)return!0;if(i&&null===t&&!ws(n.state.selection))return s(),!0;const a=xs(o.doc,t)||n.state.selection,l=n.state.selection.eq(a);return i&&(l||o.setSelection(a),l&&o.storedMarks&&o.setStoredMarks(o.storedMarks),s()),!0},forEach:(t,e)=>n=>t.every(((t,r)=>e(t,{...n,index:r}))),insertContent:(t,e)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},t,e),insertContentAt:(t,e,n)=>({tr:r,dispatch:o,editor:i})=>{var s;if(o){let o;n={parseOptions:{},updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n};try{o=Ms(e,i.schema,{parseOptions:{preserveWhitespace:"full",...n.parseOptions},errorOnInvalidContent:null!==(s=n.errorOnInvalidContent)&&void 0!==s?s:i.options.enableContentCheck})}catch(t){return i.emit("contentError",{editor:i,error:t,disableCollaboration:()=>{console.error("[tiptap error]: Unable to disable collaboration at this point in time")}}),!1}let a,{from:l,to:c}="number"==typeof t?{from:t,to:t}:{from:t.from,to:t.to},d=!0,h=!0;if(((t=>!("type"in t))(o)?o:[o]).forEach((t=>{t.check(),d=!!d&&(t.isText&&0===t.marks.length),h=!!h&&t.isBlock})),l===c&&h){const{parent:t}=r.doc.resolve(l);t.isTextblock&&!t.type.spec.code&&!t.childCount&&(l-=1,c+=1)}d?(a=Array.isArray(e)?e.map((t=>t.text||"")).join(""):"object"==typeof e&&e&&e.text?e.text:e,r.insertText(a,l,c)):(a=o,r.replaceWith(l,c,a)),n.updateSelection&&function(t,e,n){const r=t.steps.length-1;if(r<e)return;const o=t.steps[r];if(!(o instanceof Zt||o instanceof te))return;const i=t.mapping.maps[r];let s=0;i.forEach(((t,e,n,r)=>{0===s&&(s=r)})),t.setSelection(Te.near(t.doc.resolve(s),n))}(r,r.steps.length-1,-1),n.applyInputRules&&r.setMeta("applyInputRules",{from:l,text:a}),n.applyPasteRules&&r.setMeta("applyPasteRules",{from:l,text:a})}return!0},joinBackward:()=>({state:t,dispatch:e})=>((t,e,n)=>{let r=xi(t,n);if(!r)return!1;let o=Ci(r);if(!o){let n=r.blockRange(),o=n&&oe(n);return null!=o&&(e&&e(t.tr.lift(n,o).scrollIntoView()),!0)}let i=o.nodeBefore;if(Ni(t,o,e,-1))return!0;if(0==r.parent.content.size&&(Oi(i,"end")||Ie.isSelectable(i)))for(let n=r.depth;;n--){let s=he(t.doc,r.before(n),r.after(n),$.empty);if(s&&s.slice.size<s.to-s.from){if(e){let n=t.tr.step(s);n.setSelection(Oi(i,"end")?Te.findFrom(n.doc.resolve(n.mapping.map(o.pos,-1)),-1):Ie.create(n.doc,o.pos-i.nodeSize)),e(n.scrollIntoView())}return!0}if(1==n||r.node(n-1).childCount>1)break}return!(!i.isAtom||o.depth!=r.depth-1||(e&&e(t.tr.delete(o.pos-i.nodeSize,o.pos).scrollIntoView()),0))})(t,e),joinDown:()=>({state:t,dispatch:e})=>((t,e)=>{let n,r=t.selection;if(r instanceof Ie){if(r.node.isTextblock||!le(t.doc,r.to))return!1;n=r.to}else if(n=de(t.doc,r.to,1),null==n)return!1;return e&&e(t.tr.join(n).scrollIntoView()),!0})(t,e),joinForward:()=>({state:t,dispatch:e})=>((t,e,n)=>{let r=Mi(t,n);if(!r)return!1;let o=Ti(r);if(!o)return!1;let i=o.nodeAfter;if(Ni(t,o,e,1))return!0;if(0==r.parent.content.size&&(Oi(i,"start")||Ie.isSelectable(i))){let n=he(t.doc,r.before(),r.after(),$.empty);if(n&&n.slice.size<n.to-n.from){if(e){let r=t.tr.step(n);r.setSelection(Oi(i,"start")?Te.findFrom(r.doc.resolve(r.mapping.map(o.pos)),1):Ie.create(r.doc,r.mapping.map(o.pos))),e(r.scrollIntoView())}return!0}}return!(!i.isAtom||o.depth!=r.depth-1||(e&&e(t.tr.delete(o.pos,o.pos+i.nodeSize).scrollIntoView()),0))})(t,e),joinItemBackward:()=>({state:t,dispatch:e,tr:n})=>{try{const r=de(t.doc,t.selection.$from.pos,-1);return null!=r&&(n.join(r,2),e&&e(n),!0)}catch{return!1}},joinItemForward:()=>({state:t,dispatch:e,tr:n})=>{try{const r=de(t.doc,t.selection.$from.pos,1);return null!=r&&(n.join(r,2),e&&e(n),!0)}catch{return!1}},joinTextblockBackward:()=>({state:t,dispatch:e})=>((t,e,n)=>{let r=xi(t,n);if(!r)return!1;let o=Ci(r);return!!o&&Si(t,o,e)})(t,e),joinTextblockForward:()=>({state:t,dispatch:e})=>((t,e,n)=>{let r=Mi(t,n);if(!r)return!1;let o=Ti(r);return!!o&&Si(t,o,e)})(t,e),joinUp:()=>({state:t,dispatch:e})=>((t,e)=>{let n,r=t.selection,o=r instanceof Ie;if(o){if(r.node.isTextblock||!le(t.doc,r.from))return!1;n=r.from}else if(n=de(t.doc,r.from,-1),null==n)return!1;if(e){let r=t.tr.join(n);o&&r.setSelection(Ie.create(r.doc,n-t.doc.resolve(n).nodeBefore.nodeSize)),e(r.scrollIntoView())}return!0})(t,e),keyboardShortcut:t=>({editor:e,view:n,tr:r,dispatch:o})=>{const i=function(t){const e=t.split(/-(?!$)/);let n,r,o,i,s=e[e.length-1];"Space"===s&&(s=" ");for(let t=0;t<e.length-1;t+=1){const s=e[t];if(/^(cmd|meta|m)$/i.test(s))i=!0;else if(/^a(lt)?$/i.test(s))n=!0;else if(/^(c|ctrl|control)$/i.test(s))r=!0;else if(/^s(hift)?$/i.test(s))o=!0;else{if(!/^mod$/i.test(s))throw new Error(`Unrecognized modifier name: ${s}`);Ss()||Ts()?i=!0:r=!0}}return n&&(s=`Alt-${s}`),r&&(s=`Ctrl-${s}`),i&&(s=`Meta-${s}`),o&&(s=`Shift-${s}`),s}(t).split(/-(?!$)/),s=i.find((t=>!["Alt","Ctrl","Meta","Shift"].includes(t))),a=new KeyboardEvent("keydown",{key:"Space"===s?" ":s,altKey:i.includes("Alt"),ctrlKey:i.includes("Ctrl"),metaKey:i.includes("Meta"),shiftKey:i.includes("Shift"),bubbles:!0,cancelable:!0}),l=e.captureTransaction((()=>{n.someProp("handleKeyDown",(t=>t(n,a)))}));return null==l||l.steps.forEach((t=>{const e=t.map(r.mapping);e&&o&&r.maybeStep(e)})),!0},lift:(t,e={})=>({state:n,dispatch:r})=>!!Es(n,Vi(t,n.schema),e)&&((t,e)=>{let{$from:n,$to:r}=t.selection,o=n.blockRange(r),i=o&&oe(o);return null!=i&&(e&&e(t.tr.lift(o,i).scrollIntoView()),!0)})(n,r),liftEmptyBlock:()=>({state:t,dispatch:e})=>((t,e)=>{let{$cursor:n}=t.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let r=n.before();if(ae(t.doc,r))return e&&e(t.tr.split(r).scrollIntoView()),!0}let r=n.blockRange(),o=r&&oe(r);return null!=o&&(e&&e(t.tr.lift(r,o).scrollIntoView()),!0)})(t,e),liftListItem:t=>({state:e,dispatch:n})=>Pi(Vi(t,e.schema))(e,n),newlineInCode:()=>({state:t,dispatch:e})=>((t,e)=>{let{$head:n,$anchor:r}=t.selection;return!(!n.parent.type.spec.code||!n.sameParent(r)||(e&&e(t.tr.insertText("\n").scrollIntoView()),0))})(t,e),resetAttributes:(t,e)=>({tr:n,state:r,dispatch:o})=>{let i=null,s=null;const a=Ns("string"==typeof t?t:t.name,r.schema);return!!a&&("node"===a&&(i=Vi(t,r.schema)),"mark"===a&&(s=vs(t,r.schema)),o&&n.selection.ranges.forEach((t=>{r.doc.nodesBetween(t.$from.pos,t.$to.pos,((t,r)=>{i&&i===t.type&&n.setNodeMarkup(r,void 0,As(t.attrs,e)),s&&t.marks.length&&t.marks.forEach((o=>{s===o.type&&n.addMark(r,r+t.nodeSize,s.create(As(o.attrs,e)))}))}))})),!0)},scrollIntoView:()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),selectAll:()=>({tr:t,commands:e})=>e.setTextSelection({from:0,to:t.doc.content.size}),selectNodeBackward:()=>({state:t,dispatch:e})=>((t,e,n)=>{let{$head:r,empty:o}=t.selection,i=r;if(!o)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("backward",t):r.parentOffset>0)return!1;i=Ci(r)}let s=i&&i.nodeBefore;return!(!s||!Ie.isSelectable(s)||(e&&e(t.tr.setSelection(Ie.create(t.doc,i.pos-s.nodeSize)).scrollIntoView()),0))})(t,e),selectNodeForward:()=>({state:t,dispatch:e})=>((t,e,n)=>{let{$head:r,empty:o}=t.selection,i=r;if(!o)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("forward",t):r.parentOffset<r.parent.content.size)return!1;i=Ti(r)}let s=i&&i.nodeAfter;return!(!s||!Ie.isSelectable(s)||(e&&e(t.tr.setSelection(Ie.create(t.doc,i.pos)).scrollIntoView()),0))})(t,e),selectParentNode:()=>({state:t,dispatch:e})=>((t,e)=>{let n,{$from:r,to:o}=t.selection,i=r.sharedDepth(o);return 0!=i&&(n=r.before(i),e&&e(t.tr.setSelection(Ie.create(t.doc,n))),!0)})(t,e),selectTextblockEnd:()=>({state:t,dispatch:e})=>Ri(t,e),selectTextblockStart:()=>({state:t,dispatch:e})=>Di(t,e),setContent:(t,e=!1,n={},r={})=>({editor:o,tr:i,dispatch:s,commands:a})=>{var l,c;const{doc:d}=i;if("full"!==n.preserveWhitespace){const a=Ds(t,o.schema,n,{errorOnInvalidContent:null!==(l=r.errorOnInvalidContent)&&void 0!==l?l:o.options.enableContentCheck});return s&&i.replaceWith(0,d.content.size,a).setMeta("preventUpdate",!e),!0}return s&&i.setMeta("preventUpdate",!e),a.insertContentAt({from:0,to:d.content.size},t,{parseOptions:n,errorOnInvalidContent:null!==(c=r.errorOnInvalidContent)&&void 0!==c?c:o.options.enableContentCheck})},setMark:(t,e={})=>({tr:n,state:r,dispatch:o})=>{const{selection:i}=n,{empty:s,ranges:a}=i,l=vs(t,r.schema);if(o)if(s){const t=Rs(r,l);n.addStoredMark(l.create({...t,...e}))}else a.forEach((t=>{const o=t.$from.pos,i=t.$to.pos;r.doc.nodesBetween(o,i,((t,r)=>{const s=Math.max(r,o),a=Math.min(r+t.nodeSize,i);t.marks.find((t=>t.type===l))?t.marks.forEach((t=>{l===t.type&&n.addMark(s,a,l.create({...t.attrs,...e}))})):n.addMark(s,a,l.create(e))}))}));return function(t,e,n){var r;const{selection:o}=e;let i=null;if(ws(o)&&(i=o.$cursor),i){const e=null!==(r=t.storedMarks)&&void 0!==r?r:i.marks();return!!n.isInSet(e)||!e.some((t=>t.type.excludes(n)))}const{ranges:s}=o;return s.some((({$from:e,$to:r})=>{let o=0===e.depth&&t.doc.inlineContent&&t.doc.type.allowsMarkType(n);return t.doc.nodesBetween(e.pos,r.pos,((t,e,r)=>{if(o)return!1;if(t.isInline){const e=!r||r.type.allowsMarkType(n),i=!!n.isInSet(t.marks)||!t.marks.some((t=>t.type.excludes(n)));o=e&&i}return!o})),o}))}(r,n,l)},setMeta:(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),setNode:(t,e={})=>({state:n,dispatch:r,chain:o})=>{const i=Vi(t,n.schema);return i.isTextblock?o().command((({commands:t})=>!!Ii(i,e)(n)||t.clearNodes())).command((({state:t})=>Ii(i,e)(t,r))).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},setNodeSelection:t=>({tr:e,dispatch:n})=>{if(n){const{doc:n}=e,r=ks(t,0,n.content.size),o=Ie.create(n,r);e.setSelection(o)}return!0},setTextSelection:t=>({tr:e,dispatch:n})=>{if(n){const{doc:n}=e,{from:r,to:o}="number"==typeof t?{from:t,to:t}:t,i=De.atStart(n).from,s=De.atEnd(n).to,a=ks(r,i,s),l=ks(o,i,s),c=De.create(n,a,l);e.setSelection(c)}return!0},sinkListItem:t=>({state:e,dispatch:n})=>function(t){return function(e,n){let{$from:r,$to:o}=e.selection,i=r.blockRange(o,(e=>e.childCount>0&&e.firstChild.type==t));if(!i)return!1;let s=i.startIndex;if(0==s)return!1;let a=i.parent,l=a.child(s-1);if(l.type!=t)return!1;if(n){let r=l.lastChild&&l.lastChild.type==a.type,o=R.from(r?t.create():null),s=new $(R.from(t.create(null,R.from(a.type.create(null,o)))),r?3:1,0),c=i.start,d=i.end;n(e.tr.step(new te(c-(r?3:1),d,c,d,s,1,!0)).scrollIntoView())}return!0}}(Vi(t,e.schema))(e,n),splitBlock:({keepMarks:t=!0}={})=>({tr:e,state:n,dispatch:r,editor:o})=>{const{selection:i,doc:s}=e,{$from:a,$to:l}=i,c=zs(o.extensionManager.attributes,a.node().type.name,a.node().attrs);if(i instanceof Ie&&i.node.isBlock)return!(!a.parentOffset||!ae(s,a.pos))&&(r&&(t&&_s(n,o.extensionManager.splittableMarks),e.split(a.pos).scrollIntoView()),!0);if(!a.parent.isBlock)return!1;const d=l.parentOffset===l.parent.content.size,h=0===a.depth?void 0:function(t){for(let e=0;e<t.edgeCount;e+=1){const{type:n}=t.edge(e);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}(a.node(-1).contentMatchAt(a.indexAfter(-1)));let u=d&&h?[{type:h,attrs:c}]:void 0,p=ae(e.doc,e.mapping.map(a.pos),1,u);if(!u&&!p&&ae(e.doc,e.mapping.map(a.pos),1,h?[{type:h}]:void 0)&&(p=!0,u=h?[{type:h,attrs:c}]:void 0),r){if(p&&(i instanceof De&&e.deleteSelection(),e.split(e.mapping.map(a.pos),1,u),h&&!d&&!a.parentOffset&&a.parent.type!==h)){const t=e.mapping.map(a.before()),n=e.doc.resolve(t);a.node(-1).canReplaceWith(n.index(),n.index()+1,h)&&e.setNodeMarkup(e.mapping.map(a.before()),h)}t&&_s(n,o.extensionManager.splittableMarks),e.scrollIntoView()}return p},splitListItem:(t,e={})=>({tr:n,state:r,dispatch:o,editor:i})=>{var s;const a=Vi(t,r.schema),{$from:l,$to:c}=r.selection,d=r.selection.node;if(d&&d.isBlock||l.depth<2||!l.sameParent(c))return!1;const h=l.node(-1);if(h.type!==a)return!1;const u=i.extensionManager.attributes;if(0===l.parent.content.size&&l.node(-1).childCount===l.indexAfter(-1)){if(2===l.depth||l.node(-3).type!==a||l.index(-2)!==l.node(-2).childCount-1)return!1;if(o){let t=R.empty;const r=l.index(-1)?1:l.index(-2)?2:3;for(let e=l.depth-r;e>=l.depth-3;e-=1)t=R.from(l.node(e).copy(t));const o=l.indexAfter(-1)<l.node(-2).childCount?1:l.indexAfter(-2)<l.node(-3).childCount?2:3,i={...zs(u,l.node().type.name,l.node().attrs),...e},c=(null===(s=a.contentMatch.defaultType)||void 0===s?void 0:s.createAndFill(i))||void 0;t=t.append(R.from(a.createAndFill(null,c)||void 0));const d=l.before(l.depth-(r-1));n.replace(d,l.after(-o),new $(t,4-r,0));let h=-1;n.doc.nodesBetween(d,n.doc.content.size,((t,e)=>{if(h>-1)return!1;t.isTextblock&&0===t.content.size&&(h=e+1)})),h>-1&&n.setSelection(De.near(n.doc.resolve(h))),n.scrollIntoView()}return!0}const p=c.pos===l.end()?h.contentMatchAt(0).defaultType:null,f={...zs(u,h.type.name,h.attrs),...e},m={...zs(u,l.node().type.name,l.node().attrs),...e};n.delete(l.pos,c.pos);const g=p?[{type:a,attrs:f},{type:p,attrs:m}]:[{type:a,attrs:f}];if(!ae(n.doc,l.pos,2))return!1;if(o){const{selection:t,storedMarks:e}=r,{splittableMarks:s}=i.extensionManager,a=e||t.$to.parentOffset&&t.$from.marks();if(n.split(l.pos,2,g).scrollIntoView(),!a||!o)return!0;const c=a.filter((t=>s.includes(t.type.name)));n.ensureMarks(c)}return!0},toggleList:(t,e,n,r={})=>({editor:o,tr:i,state:s,dispatch:a,chain:l,commands:c,can:d})=>{const{extensions:h,splittableMarks:u}=o.extensionManager,p=Vi(t,s.schema),f=Vi(e,s.schema),{selection:m,storedMarks:g}=s,{$from:y,$to:b}=m,v=y.blockRange(b),w=g||m.$to.parentOffset&&m.$from.marks();if(!v)return!1;const k=Is((t=>Bs(t.type.name,h)))(m);if(v.depth>=1&&k&&v.depth-k.depth<=1){if(k.node.type===p)return c.liftListItem(f);if(Bs(k.node.type.name,h)&&p.validContent(k.node.content)&&a)return l().command((()=>(i.setNodeMarkup(k.pos,p),!0))).command((()=>Vs(i,p))).command((()=>Hs(i,p))).run()}return n&&w&&a?l().command((()=>{const t=d().wrapInList(p,r),e=w.filter((t=>u.includes(t.type.name)));return i.ensureMarks(e),!!t||c.clearNodes()})).wrapInList(p,r).command((()=>Vs(i,p))).command((()=>Hs(i,p))).run():l().command((()=>!!d().wrapInList(p,r)||c.clearNodes())).wrapInList(p,r).command((()=>Vs(i,p))).command((()=>Hs(i,p))).run()},toggleMark:(t,e={},n={})=>({state:r,commands:o})=>{const{extendEmptyMarkRange:i=!1}=n,s=vs(t,r.schema);return $s(r,s,e)?o.unsetMark(s,{extendEmptyMarkRange:i}):o.setMark(s,e)},toggleNode:(t,e,n={})=>({state:r,commands:o})=>{const i=Vi(t,r.schema),s=Vi(e,r.schema),a=Es(r,i,n);let l;return r.selection.$anchor.sameParent(r.selection.$head)&&(l=r.selection.$anchor.parent.attrs),a?o.setNode(s,l):o.setNode(i,{...l,...n})},toggleWrap:(t,e={})=>({state:n,commands:r})=>{const o=Vi(t,n.schema);return Es(n,o,e)?r.lift(o):r.wrapIn(o,e)},undoInputRule:()=>({state:t,dispatch:e})=>{const n=t.plugins;for(let r=0;r<n.length;r+=1){const o=n[r];let i;if(o.spec.isInputRules&&(i=o.getState(t))){if(e){const e=t.tr,n=i.transform;for(let t=n.steps.length-1;t>=0;t-=1)e.step(n.steps[t].invert(n.docs[t]));if(i.text){const n=e.doc.resolve(i.from).marks();e.replaceWith(i.from,i.to,t.schema.text(i.text,n))}else e.delete(i.from,i.to)}return!0}}return!1},unsetAllMarks:()=>({tr:t,dispatch:e})=>{const{selection:n}=t,{empty:r,ranges:o}=n;return r||e&&o.forEach((e=>{t.removeMark(e.$from.pos,e.$to.pos)})),!0},unsetMark:(t,e={})=>({tr:n,state:r,dispatch:o})=>{var i;const{extendEmptyMarkRange:s=!1}=e,{selection:a}=n,l=vs(t,r.schema),{$from:c,empty:d,ranges:h}=a;if(!o)return!0;if(d&&s){let{from:t,to:e}=a;const r=null===(i=c.marks().find((t=>t.type===l)))||void 0===i?void 0:i.attrs,o=bs(c,l,r);o&&(t=o.from,e=o.to),n.removeMark(t,e,l)}else h.forEach((t=>{n.removeMark(t.$from.pos,t.$to.pos,l)}));return n.removeStoredMark(l),!0},updateAttributes:(t,e={})=>({tr:n,state:r,dispatch:o})=>{let i=null,s=null;const a=Ns("string"==typeof t?t:t.name,r.schema);return!!a&&("node"===a&&(i=Vi(t,r.schema)),"mark"===a&&(s=vs(t,r.schema)),o&&n.selection.ranges.forEach((t=>{const o=t.$from.pos,a=t.$to.pos;r.doc.nodesBetween(o,a,((t,r)=>{i&&i===t.type&&n.setNodeMarkup(r,void 0,{...t.attrs,...e}),s&&t.marks.length&&t.marks.forEach((i=>{if(s===i.type){const l=Math.max(r,o),c=Math.min(r+t.nodeSize,a);n.addMark(l,c,s.create({...i.attrs,...e}))}}))}))})),!0)},wrapIn:(t,e={})=>({state:n,dispatch:r})=>function(t,e=null){return function(n,r){let{$from:o,$to:i}=n.selection,s=o.blockRange(i),a=s&&ie(s,t,e);return!!a&&(r&&r(n.tr.wrap(s,a).scrollIntoView()),!0)}}(Vi(t,n.schema),e)(n,r),wrapInList:(t,e={})=>({state:n,dispatch:r})=>Li(Vi(t,n.schema),e)(n,r)});const Ks=hs.create({name:"commands",addCommands:()=>({...Ws})}),qs=hs.create({name:"drop",addProseMirrorPlugins(){return[new qe({key:new Ge("tiptapDrop"),props:{handleDrop:(t,e,n,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:n,moved:r})}}})]}}),Js=hs.create({name:"editable",addProseMirrorPlugins(){return[new qe({key:new Ge("editable"),props:{editable:()=>this.editor.options.editable}})]}}),Us=hs.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new qe({key:new Ge("focusEvents"),props:{handleDOMEvents:{focus:(e,n)=>{t.isFocused=!0;const r=t.state.tr.setMeta("focus",{event:n}).setMeta("addToHistory",!1);return e.dispatch(r),!1},blur:(e,n)=>{t.isFocused=!1;const r=t.state.tr.setMeta("blur",{event:n}).setMeta("addToHistory",!1);return e.dispatch(r),!1}}}})]}}),Gs=hs.create({name:"keymap",addKeyboardShortcuts(){const t=()=>this.editor.commands.first((({commands:t})=>[()=>t.undoInputRule(),()=>t.command((({tr:e})=>{const{selection:n,doc:r}=e,{empty:o,$anchor:i}=n,{pos:s,parent:a}=i,l=i.parent.isTextblock&&s>0?e.doc.resolve(s-1):i,c=l.parent.type.spec.isolating,d=i.pos-i.parentOffset,h=c&&1===l.parent.childCount?d===i.pos:Te.atStart(r).from===s;return!(!o||!a.type.isTextblock||a.textContent.length||!h||h&&"paragraph"===i.parent.type.name)&&t.clearNodes()})),()=>t.deleteSelection(),()=>t.joinBackward(),()=>t.selectNodeBackward()])),e=()=>this.editor.commands.first((({commands:t})=>[()=>t.deleteSelection(),()=>t.deleteCurrentNode(),()=>t.joinForward(),()=>t.selectNodeForward()])),n={Enter:()=>this.editor.commands.first((({commands:t})=>[()=>t.newlineInCode(),()=>t.createParagraphNear(),()=>t.liftEmptyBlock(),()=>t.splitBlock()])),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:t,"Mod-Backspace":t,"Shift-Backspace":t,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},r={...n},o={...n,"Ctrl-h":t,"Alt-Backspace":t,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return Ss()||Ts()?o:r},addProseMirrorPlugins(){return[new qe({key:new Ge("clearDocument"),appendTransaction:(t,e,n)=>{const r=t.some((t=>t.docChanged))&&!e.doc.eq(n.doc),o=t.some((t=>t.getMeta("preventClearDocument")));if(!r||o)return;const{empty:i,from:s,to:a}=e.selection,l=Te.atStart(e.doc).from,c=Te.atEnd(e.doc).to;if(i||s!==l||a!==c||!Fs(n.doc))return;const d=n.tr,h=ji({state:n,transaction:d}),{commands:u}=new zi({editor:this.editor,state:h});return u.clearNodes(),d.steps.length?d:void 0}})]}}),Ys=hs.create({name:"paste",addProseMirrorPlugins(){return[new qe({key:new Ge("tiptapPaste"),props:{handlePaste:(t,e,n)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:n})}}})]}}),Qs=hs.create({name:"tabindex",addProseMirrorPlugins(){return[new qe({key:new Ge("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}});class Xs{get name(){return this.node.type.name}constructor(t,e,n=!1,r=null){this.currentNode=null,this.actualDepth=null,this.isBlock=n,this.resolvedPos=t,this.editor=e,this.currentNode=r}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var t;return null!==(t=this.actualDepth)&&void 0!==t?t:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(t){let e=this.from,n=this.to;if(this.isBlock){if(0===this.content.size)return void console.error(`You can’t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);e=this.from+1,n=this.to-1}this.editor.commands.insertContentAt({from:e,to:n},t)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+(this.node.isText?0:1)}get parent(){if(0===this.depth)return null;const t=this.resolvedPos.start(this.resolvedPos.depth-1),e=this.resolvedPos.doc.resolve(t);return new Xs(e,this.editor)}get before(){let t=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return t.depth!==this.depth&&(t=this.resolvedPos.doc.resolve(this.from-3)),new Xs(t,this.editor)}get after(){let t=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return t.depth!==this.depth&&(t=this.resolvedPos.doc.resolve(this.to+3)),new Xs(t,this.editor)}get children(){const t=[];return this.node.content.forEach(((e,n)=>{const r=e.isBlock&&!e.isTextblock,o=this.pos+n+1,i=this.resolvedPos.doc.resolve(o);if(!r&&i.depth<=this.depth)return;const s=new Xs(i,this.editor,r,r?e:null);r&&(s.actualDepth=this.depth+1),t.push(new Xs(i,this.editor,r,r?e:null))})),t}get firstChild(){return this.children[0]||null}get lastChild(){const t=this.children;return t[t.length-1]||null}closest(t,e={}){let n=null,r=this.parent;for(;r&&!n;){if(r.node.type.name===t)if(Object.keys(e).length>0){const t=r.node.attrs,n=Object.keys(e);for(let r=0;r<n.length;r+=1){const o=n[r];if(t[o]!==e[o])break}}else n=r;r=r.parent}return n}querySelector(t,e={}){return this.querySelectorAll(t,e,!0)[0]||null}querySelectorAll(t,e={},n=!1){let r=[];if(!this.children||0===this.children.length)return r;const o=Object.keys(e);return this.children.forEach((i=>{n&&r.length>0||(i.node.type.name===t&&o.every((t=>e[t]===i.node.attrs[t]))&&r.push(i),!(n&&r.length>0)&&(r=r.concat(i.querySelectorAll(t,e,n))))})),r}setAttribute(t){const e=this.editor.state.selection;this.editor.chain().setTextSelection(this.from).updateAttributes(this.node.type.name,t).setTextSelection(e.from).run()}}class Zs extends $i{constructor(t={}){super(),this.isFocused=!1,this.isInitialized=!1,this.extensionStorage={},this.options={element:document.createElement("div"),content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,onBeforeCreate:()=>null,onCreate:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:t})=>{throw t},onPaste:()=>null,onDrop:()=>null},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.setOptions(t),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.on("contentError",this.options.onContentError),this.createView(),this.injectCSS(),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.options.onFocus),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),this.on("drop",(({event:t,slice:e,moved:n})=>this.options.onDrop(t,e,n))),this.on("paste",(({event:t,slice:e})=>this.options.onPaste(t,e))),window.setTimeout((()=>{this.isDestroyed||(this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}),this.isInitialized=!0)}),0)}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager.chain()}can(){return this.commandManager.can()}injectCSS(){this.options.injectCSS&&document&&(this.css=function(t,e,n){const r=document.querySelector(`style[data-tiptap-style${n?`-${n}`:""}]`);if(null!==r)return r;const o=document.createElement("style");return e&&o.setAttribute("nonce",e),o.setAttribute("data-tiptap-style"+(n?`-${n}`:""),""),o.innerHTML=t,document.getElementsByTagName("head")[0].appendChild(o),o}('.ProseMirror {\n position: relative;\n}\n\n.ProseMirror {\n word-wrap: break-word;\n white-space: pre-wrap;\n white-space: break-spaces;\n -webkit-font-variant-ligatures: none;\n font-variant-ligatures: none;\n font-feature-settings: "liga" 0; /* the above doesn\'t seem to work in Edge */\n}\n\n.ProseMirror [contenteditable="false"] {\n white-space: normal;\n}\n\n.ProseMirror [contenteditable="false"] [contenteditable="true"] {\n white-space: pre-wrap;\n}\n\n.ProseMirror pre {\n white-space: pre-wrap;\n}\n\nimg.ProseMirror-separator {\n display: inline !important;\n border: none !important;\n margin: 0 !important;\n width: 0 !important;\n height: 0 !important;\n}\n\n.ProseMirror-gapcursor {\n display: none;\n pointer-events: none;\n position: absolute;\n margin: 0;\n}\n\n.ProseMirror-gapcursor:after {\n content: "";\n display: block;\n position: absolute;\n top: -2px;\n width: 20px;\n border-top: 1px solid black;\n animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;\n}\n\n@keyframes ProseMirror-cursor-blink {\n to {\n visibility: hidden;\n }\n}\n\n.ProseMirror-hideselection *::selection {\n background: transparent;\n}\n\n.ProseMirror-hideselection *::-moz-selection {\n background: transparent;\n}\n\n.ProseMirror-hideselection * {\n caret-color: transparent;\n}\n\n.ProseMirror-focused .ProseMirror-gapcursor {\n display: block;\n}\n\n.tippy-box[data-animation=fade][data-state=hidden] {\n opacity: 0\n}',this.options.injectNonce))}setOptions(t={}){this.options={...this.options,...t},this.view&&this.state&&!this.isDestroyed&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}setEditable(t,e=!0){this.setOptions({editable:t}),e&&this.emit("update",{editor:this,transaction:this.state.tr})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get state(){return this.view.state}registerPlugin(t,e){const n=Ki(e)?e(t,[...this.state.plugins]):[...this.state.plugins,t],r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}unregisterPlugin(t){if(this.isDestroyed)return;const e="string"==typeof t?`${t}$`:t.key,n=this.state.reconfigure({plugins:this.state.plugins.filter((t=>!t.key.startsWith(e)))});return this.view.updateState(n),n}createExtensionManager(){var t,e;const n=[...this.options.enableCoreExtensions?[Js,fs.configure({blockSeparator:null===(e=null===(t=this.options.coreExtensionOptions)||void 0===t?void 0:t.clipboardTextSerializer)||void 0===e?void 0:e.blockSeparator}),Ks,Us,Gs,Qs,qs,Ys].filter((t=>"object"!=typeof this.options.enableCoreExtensions||!1!==this.options.enableCoreExtensions[t.name])):[],...this.options.extensions].filter((t=>["extension","node","mark"].includes(null==t?void 0:t.type)));this.extensionManager=new ds(n,this)}createCommandManager(){this.commandManager=new zi({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createView(){let t;try{t=Ds(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(e){if(!(e instanceof Error&&["[tiptap error]: Invalid JSON content","[tiptap error]: Invalid HTML content"].includes(e.message)))throw e;this.emit("contentError",{editor:this,error:e,disableCollaboration:()=>{this.options.extensions=this.options.extensions.filter((t=>"collaboration"!==t.name)),this.createExtensionManager()}}),t=Ds(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}const e=xs(t,this.options.autofocus);this.view=new si(this.options.element,{...this.options.editorProps,dispatchTransaction:this.dispatchTransaction.bind(this),state:We.create({doc:t,selection:e||void 0})});const n=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(n),this.createNodeViews(),this.prependClass();this.view.dom.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`tiptap ${this.view.dom.className}`}captureTransaction(t){this.isCapturingTransaction=!0,t(),this.isCapturingTransaction=!1;const e=this.capturedTransaction;return this.capturedTransaction=null,e}dispatchTransaction(t){if(this.view.isDestroyed)return;if(this.isCapturingTransaction)return this.capturedTransaction?void t.steps.forEach((t=>{var e;return null===(e=this.capturedTransaction)||void 0===e?void 0:e.step(t)})):void(this.capturedTransaction=t);const e=this.state.apply(t),n=!this.state.selection.eq(e.selection);this.emit("beforeTransaction",{editor:this,transaction:t,nextState:e}),this.view.updateState(e),this.emit("transaction",{editor:this,transaction:t}),n&&this.emit("selectionUpdate",{editor:this,transaction:t});const r=t.getMeta("focus"),o=t.getMeta("blur");r&&this.emit("focus",{editor:this,event:r.event,transaction:t}),o&&this.emit("blur",{editor:this,event:o.event,transaction:t}),t.docChanged&&!t.getMeta("preventUpdate")&&this.emit("update",{editor:this,transaction:t})}getAttributes(t){return Ls(this.state,t)}isActive(t,e){const n="string"==typeof t?t:null,r="string"==typeof t?e:t;return function(t,e,n={}){if(!e)return Es(t,null,n)||$s(t,null,n);const r=Ns(e,t.schema);return"node"===r?Es(t,e,n):"mark"===r&&$s(t,e,n)}(this.state,n,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return function(t,e){const n=It.fromSchema(e).serializeFragment(t),r=document.implementation.createHTMLDocument().createElement("div");return r.appendChild(n),r.innerHTML}(this.state.doc.content,this.schema)}getText(t){const{blockSeparator:e="\n\n",textSerializers:n={}}=t||{};return function(t,e){return us(t,{from:0,to:t.content.size},e)}(this.state.doc,{blockSeparator:e,textSerializers:{...ps(this.schema),...n}})}get isEmpty(){return Fs(this.state.doc)}getCharacterCount(){return console.warn('[tiptap warn]: "editor.getCharacterCount()" is deprecated. Please use "editor.storage.characterCount.characters()" instead.'),this.state.doc.content.size-2}destroy(){if(this.emit("destroy"),this.view){const t=this.view.dom;t&&t.editor&&delete t.editor,this.view.destroy()}this.removeAllListeners()}get isDestroyed(){var t;return!(null!==(t=this.view)&&void 0!==t&&t.docView)}$node(t,e){var n;return(null===(n=this.$doc)||void 0===n?void 0:n.querySelector(t,e))||null}$nodes(t,e){var n;return(null===(n=this.$doc)||void 0===n?void 0:n.querySelectorAll(t,e))||null}$pos(t){const e=this.state.doc.resolve(t);return new Xs(e,this)}get $doc(){return this.$pos(0)}}function ta(t){return new Zi({find:t.find,handler:({state:e,range:n,match:r})=>{const o=qi(t.getAttributes,void 0,r);if(!1===o||null===o)return null;const{tr:i}=e,s=r[r.length-1],a=r[0];if(s){const r=a.search(/\S/),l=n.from+a.indexOf(s),c=l+s.length;if(js(n.from,n.to,e.doc).filter((e=>e.mark.type.excluded.find((n=>n===t.type&&n!==e.mark.type)))).filter((t=>t.to>l)).length)return null;c<n.to&&i.delete(c,n.to),l>n.from&&i.delete(n.from+r,l);const d=n.from+r+s.length;i.addMark(n.from+r,d,t.type.create(o||{})),i.removeStoredMark(t.type)}}})}function ea(t){return new Zi({find:t.find,handler:({state:e,range:n,match:r,chain:o})=>{const i=qi(t.getAttributes,void 0,r)||{},s=e.tr.delete(n.from,n.to),a=s.doc.resolve(n.from).blockRange(),l=a&&ie(a,t.type,i);if(!l)return null;if(s.wrap(a,l),t.keepMarks&&t.editor){const{selection:n,storedMarks:r}=e,{splittableMarks:o}=t.editor.extensionManager,i=r||n.$to.parentOffset&&n.$from.marks();if(i){const t=i.filter((t=>o.includes(t.type.name)));s.ensureMarks(t)}}if(t.keepAttributes){const e="bulletList"===t.type.name||"orderedList"===t.type.name?"listItem":"taskList";o().updateAttributes(e,i).run()}const c=s.doc.resolve(n.from-1).nodeBefore;c&&c.type===t.type&&le(s.doc,n.from-1)&&(!t.joinPredicate||t.joinPredicate(r,c))&&s.join(n.from-1)}})}class na{constructor(t={}){this.type="node",this.name="node",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...t},this.name=this.config.name,t.defaultOptions&&Object.keys(t.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=qi(Bi(this,"addOptions",{name:this.name}))),this.storage=qi(Bi(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(t={}){return new na(t)}configure(t={}){const e=this.extend({...this.config,addOptions:()=>is(this.options,t)});return e.name=this.name,e.parent=this.parent,e}extend(t={}){const e=new na(t);return e.parent=this,this.child=e,e.name=t.name?t.name:e.parent.name,t.defaultOptions&&Object.keys(t.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${e.name}".`),e.options=qi(Bi(e,"addOptions",{name:e.name})),e.storage=qi(Bi(e,"addStorage",{name:e.name,options:e.options})),e}}function ra(t){return new as({find:t.find,handler:({state:e,range:n,match:r,pasteEvent:o})=>{const i=qi(t.getAttributes,void 0,r,o);if(!1===i||null===i)return null;const{tr:s}=e,a=r[r.length-1],l=r[0];let c=n.to;if(a){const r=l.search(/\S/),o=n.from+l.indexOf(a),d=o+a.length;if(js(n.from,n.to,e.doc).filter((e=>e.mark.type.excluded.find((n=>n===t.type&&n!==e.mark.type)))).filter((t=>t.to>o)).length)return null;d<n.to&&s.delete(d,n.to),o>n.from&&s.delete(n.from+r,o),c=n.from+r+a.length,s.addMark(n.from+r,c,t.type.create(i||{})),s.removeStoredMark(t.type)}}})}var oa,ia={exports:{}},sa={};
20
+ */"production"===process.env.NODE_ENV?O.exports=function(){if(S)return C;S=1;var e=t,n=Symbol.for("react.element"),r=Symbol.for("react.fragment"),o=Object.prototype.hasOwnProperty,i=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,s={key:!0,ref:!0,__self:!0,__source:!0};function a(t,e,r){var a,l={},c=null,d=null;for(a in void 0!==r&&(c=""+r),void 0!==e.key&&(c=""+e.key),void 0!==e.ref&&(d=e.ref),e)o.call(e,a)&&!s.hasOwnProperty(a)&&(l[a]=e[a]);if(t&&t.defaultProps)for(a in e=t.defaultProps)void 0===l[a]&&(l[a]=e[a]);return{$$typeof:n,type:t,key:c,ref:d,props:l,_owner:i.current}}return C.Fragment=r,C.jsx=a,C.jsxs=a,C}():O.exports=(M||(M=1,"production"!==process.env.NODE_ENV&&function(){var e=t,n=Symbol.for("react.element"),r=Symbol.for("react.portal"),o=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),a=Symbol.for("react.provider"),l=Symbol.for("react.context"),c=Symbol.for("react.forward_ref"),d=Symbol.for("react.suspense"),h=Symbol.for("react.suspense_list"),u=Symbol.for("react.memo"),p=Symbol.for("react.lazy"),f=Symbol.for("react.offscreen"),m=Symbol.iterator,g="@@iterator",y=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function b(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];!function(t,e,n){var r=y.ReactDebugCurrentFrame,o=r.getStackAddendum();""!==o&&(e+="%s",n=n.concat([o]));var i=n.map((function(t){return String(t)}));i.unshift("Warning: "+e),Function.prototype.apply.call(console[t],console,i)}("error",t,n)}var v,w=!1,k=!1,x=!1,S=!1,O=!1;function C(t){return t.displayName||"Context"}function M(t){if(null==t)return null;if("number"==typeof t.tag&&b("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),"function"==typeof t)return t.displayName||t.name||null;if("string"==typeof t)return t;switch(t){case o:return"Fragment";case r:return"Portal";case s:return"Profiler";case i:return"StrictMode";case d:return"Suspense";case h:return"SuspenseList"}if("object"==typeof t)switch(t.$$typeof){case l:return C(t)+".Consumer";case a:return C(t._context)+".Provider";case c:return function(t,e,n){var r=t.displayName;if(r)return r;var o=e.displayName||e.name||"";return""!==o?n+"("+o+")":n}(t,t.render,"ForwardRef");case u:var e=t.displayName||null;return null!==e?e:M(t.type)||"Memo";case p:var n=t,f=n._payload,m=n._init;try{return M(m(f))}catch{return null}}return null}v=Symbol.for("react.module.reference");var E,N,A,D,R,I,L,P=Object.assign,j=0;function z(){}z.__reactDisabledLog=!0;var $,B=y.ReactCurrentDispatcher;function F(t,e,n){if(void 0===$)try{throw Error()}catch(t){var r=t.stack.trim().match(/\n( *(at )?)/);$=r&&r[1]||""}return"\n"+$+t}var _,V=!1,H="function"==typeof WeakMap?WeakMap:Map;function W(t,e){if(!t||V)return"";var n,r=_.get(t);if(void 0!==r)return r;V=!0;var o,i=Error.prepareStackTrace;Error.prepareStackTrace=void 0,o=B.current,B.current=null,function(){if(0===j){E=console.log,N=console.info,A=console.warn,D=console.error,R=console.group,I=console.groupCollapsed,L=console.groupEnd;var t={configurable:!0,enumerable:!0,value:z,writable:!0};Object.defineProperties(console,{info:t,log:t,warn:t,error:t,group:t,groupCollapsed:t,groupEnd:t})}j++}();try{if(e){var s=function(){throw Error()};if(Object.defineProperty(s.prototype,"props",{set:function(){throw Error()}}),"object"==typeof Reflect&&Reflect.construct){try{Reflect.construct(s,[])}catch(t){n=t}Reflect.construct(t,[],s)}else{try{s.call()}catch(t){n=t}t.call(s.prototype)}}else{try{throw Error()}catch(t){n=t}t()}}catch(e){if(e&&n&&"string"==typeof e.stack){for(var a=e.stack.split("\n"),l=n.stack.split("\n"),c=a.length-1,d=l.length-1;c>=1&&d>=0&&a[c]!==l[d];)d--;for(;c>=1&&d>=0;c--,d--)if(a[c]!==l[d]){if(1!==c||1!==d)do{if(c--,--d<0||a[c]!==l[d]){var h="\n"+a[c].replace(" at new "," at ");return t.displayName&&h.includes("<anonymous>")&&(h=h.replace("<anonymous>",t.displayName)),"function"==typeof t&&_.set(t,h),h}}while(c>=1&&d>=0);break}}}finally{V=!1,B.current=o,function(){if(0==--j){var t={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:P({},t,{value:E}),info:P({},t,{value:N}),warn:P({},t,{value:A}),error:P({},t,{value:D}),group:P({},t,{value:R}),groupCollapsed:P({},t,{value:I}),groupEnd:P({},t,{value:L})})}j<0&&b("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}(),Error.prepareStackTrace=i}var u=t?t.displayName||t.name:"",p=u?F(u):"";return"function"==typeof t&&_.set(t,p),p}function K(t,e,n){if(null==t)return"";if("function"==typeof t)return W(t,function(t){var e=t.prototype;return!(!e||!e.isReactComponent)}(t));if("string"==typeof t)return F(t);switch(t){case d:return F("Suspense");case h:return F("SuspenseList")}if("object"==typeof t)switch(t.$$typeof){case c:return function(t,e,n){return W(t,!1)}(t.render);case u:return K(t.type,e,n);case p:var r=t,o=r._payload,i=r._init;try{return K(i(o),e,n)}catch{}}return""}_=new H;var q=Object.prototype.hasOwnProperty,J={},U=y.ReactDebugCurrentFrame;function G(t){if(t){var e=t._owner,n=K(t.type,t._source,e?e.type:null);U.setExtraStackFrame(n)}else U.setExtraStackFrame(null)}var Y=Array.isArray;function Q(t){return Y(t)}function X(t){return""+t}function Z(t){if(function(t){try{return X(t),!1}catch{return!0}}(t))return b("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",function(t){return"function"==typeof Symbol&&Symbol.toStringTag&&t[Symbol.toStringTag]||t.constructor.name||"Object"}(t)),X(t)}var tt,et,nt,rt=y.ReactCurrentOwner,ot={key:!0,ref:!0,__self:!0,__source:!0};nt={};var it=function(t,e,r,o,i,s,a){var l={$$typeof:n,type:t,key:e,ref:r,props:a,_owner:s,_store:{}};return Object.defineProperty(l._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(l,"_self",{configurable:!1,enumerable:!1,writable:!1,value:o}),Object.defineProperty(l,"_source",{configurable:!1,enumerable:!1,writable:!1,value:i}),Object.freeze&&(Object.freeze(l.props),Object.freeze(l)),l};function st(t,e,n,r,o){var i,s={},a=null,l=null;for(i in void 0!==n&&(Z(n),a=""+n),function(t){if(q.call(t,"key")){var e=Object.getOwnPropertyDescriptor(t,"key").get;if(e&&e.isReactWarning)return!1}return void 0!==t.key}(e)&&(Z(e.key),a=""+e.key),function(t){if(q.call(t,"ref")){var e=Object.getOwnPropertyDescriptor(t,"ref").get;if(e&&e.isReactWarning)return!1}return void 0!==t.ref}(e)&&(l=e.ref,function(t,e){if("string"==typeof t.ref&&rt.current&&e&&rt.current.stateNode!==e){var n=M(rt.current.type);nt[n]||(b('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref',M(rt.current.type),t.ref),nt[n]=!0)}}(e,o)),e)q.call(e,i)&&!ot.hasOwnProperty(i)&&(s[i]=e[i]);if(t&&t.defaultProps){var c=t.defaultProps;for(i in c)void 0===s[i]&&(s[i]=c[i])}if(a||l){var d="function"==typeof t?t.displayName||t.name||"Unknown":t;a&&function(t,e){var n=function(){tt||(tt=!0,b("%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://reactjs.org/link/special-props)",e))};n.isReactWarning=!0,Object.defineProperty(t,"key",{get:n,configurable:!0})}(s,d),l&&function(t,e){var n=function(){et||(et=!0,b("%s: `ref` 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://reactjs.org/link/special-props)",e))};n.isReactWarning=!0,Object.defineProperty(t,"ref",{get:n,configurable:!0})}(s,d)}return it(t,a,l,o,r,rt.current,s)}var at,lt=y.ReactCurrentOwner,ct=y.ReactDebugCurrentFrame;function dt(t){if(t){var e=t._owner,n=K(t.type,t._source,e?e.type:null);ct.setExtraStackFrame(n)}else ct.setExtraStackFrame(null)}function ht(t){return"object"==typeof t&&null!==t&&t.$$typeof===n}function ut(){if(lt.current){var t=M(lt.current.type);if(t)return"\n\nCheck the render method of `"+t+"`."}return""}at=!1;var pt={};function ft(t,e){if(t._store&&!t._store.validated&&null==t.key){t._store.validated=!0;var n=function(t){var e=ut();if(!e){var n="string"==typeof t?t:t.displayName||t.name;n&&(e="\n\nCheck the top-level render call using <"+n+">.")}return e}(e);if(!pt[n]){pt[n]=!0;var r="";t&&t._owner&&t._owner!==lt.current&&(r=" It was passed a child from "+M(t._owner.type)+"."),dt(t),b('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',n,r),dt(null)}}}function mt(t,e){if("object"==typeof t)if(Q(t))for(var n=0;n<t.length;n++){var r=t[n];ht(r)&&ft(r,e)}else if(ht(t))t._store&&(t._store.validated=!0);else if(t){var o=function(t){if(null===t||"object"!=typeof t)return null;var e=m&&t[m]||t[g];return"function"==typeof e?e:null}(t);if("function"==typeof o&&o!==t.entries)for(var i,s=o.call(t);!(i=s.next()).done;)ht(i.value)&&ft(i.value,e)}}function gt(t){var e,n=t.type;if(null!=n&&"string"!=typeof n){if("function"==typeof n)e=n.propTypes;else{if("object"!=typeof n||n.$$typeof!==c&&n.$$typeof!==u)return;e=n.propTypes}if(e){var r=M(n);!function(t,e,n,r,o){var i=Function.call.bind(q);for(var s in t)if(i(t,s)){var a=void 0;try{if("function"!=typeof t[s]){var l=Error((r||"React class")+": "+n+" type `"+s+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof t[s]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw l.name="Invariant Violation",l}a=t[s](e,s,r,n,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(t){a=t}a&&!(a instanceof Error)&&(G(o),b("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",r||"React class",n,s,typeof a),G(null)),a instanceof Error&&!(a.message in J)&&(J[a.message]=!0,G(o),b("Failed %s type: %s",n,a.message),G(null))}}(e,t.props,"prop",r,t)}else void 0===n.PropTypes||at||(at=!0,b("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",M(n)||"Unknown"));"function"==typeof n.getDefaultProps&&!n.getDefaultProps.isReactClassApproved&&b("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function yt(t,e,r,m,g,y){var C=function(t){return!!("string"==typeof t||"function"==typeof t||t===o||t===s||O||t===i||t===d||t===h||S||t===f||w||k||x||"object"==typeof t&&null!==t&&(t.$$typeof===p||t.$$typeof===u||t.$$typeof===a||t.$$typeof===l||t.$$typeof===c||t.$$typeof===v||void 0!==t.getModuleId))}(t);if(!C){var T="";(void 0===t||"object"==typeof t&&null!==t&&0===Object.keys(t).length)&&(T+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var E,N=function(t){return void 0!==t?"\n\nCheck your code at "+t.fileName.replace(/^.*[\\\/]/,"")+":"+t.lineNumber+".":""}(g);T+=N||ut(),null===t?E="null":Q(t)?E="array":void 0!==t&&t.$$typeof===n?(E="<"+(M(t.type)||"Unknown")+" />",T=" Did you accidentally export a JSX literal instead of a component?"):E=typeof t,b("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",E,T)}var A=st(t,e,r,g,y);if(null==A)return A;if(C){var D=e.children;if(void 0!==D)if(m)if(Q(D)){for(var R=0;R<D.length;R++)mt(D[R],t);Object.freeze&&Object.freeze(D)}else b("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 mt(D,t)}return t===o?function(t){for(var e=Object.keys(t.props),n=0;n<e.length;n++){var r=e[n];if("children"!==r&&"key"!==r){dt(t),b("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",r),dt(null);break}}null!==t.ref&&(dt(t),b("Invalid attribute `ref` supplied to `React.Fragment`."),dt(null))}(A):gt(A),A}var bt=function(t,e,n){return yt(t,e,n,!1)},vt=function(t,e,n){return yt(t,e,n,!0)};T.Fragment=o,T.jsx=bt,T.jsxs=vt}()),T);var E=O.exports;function N(t){var e,n,r="";if("string"==typeof t||"number"==typeof t)r+=t;else if("object"==typeof t)if(Array.isArray(t)){var o=t.length;for(e=0;e<o;e++)t[e]&&(n=N(t[e]))&&(r&&(r+=" "),r+=n)}else for(n in t)t[n]&&(r&&(r+=" "),r+=n);return r}function A(){for(var t,e,n=0,r="",o=arguments.length;n<o;n++)(t=arguments[n])&&(e=N(t))&&(r&&(r+=" "),r+=e);return r}function D(t){this.content=t}function R(t,e,n){for(let r=0;;r++){if(r==t.childCount||r==e.childCount)return t.childCount==e.childCount?null:n;let o=t.child(r),i=e.child(r);if(o!=i){if(!o.sameMarkup(i))return n;if(o.isText&&o.text!=i.text){for(let t=0;o.text[t]==i.text[t];t++)n++;return n}if(o.content.size||i.content.size){let t=R(o.content,i.content,n+1);if(null!=t)return t}n+=o.nodeSize}else n+=o.nodeSize}}function I(t,e,n,r){for(let o=t.childCount,i=e.childCount;;){if(0==o||0==i)return o==i?null:{a:n,b:r};let s=t.child(--o),a=e.child(--i),l=s.nodeSize;if(s!=a){if(!s.sameMarkup(a))return{a:n,b:r};if(s.isText&&s.text!=a.text){let t=0,e=Math.min(s.text.length,a.text.length);for(;t<e&&s.text[s.text.length-t-1]==a.text[a.text.length-t-1];)t++,n--,r--;return{a:n,b:r}}if(s.content.size||a.content.size){let t=I(s.content,a.content,n-1,r-1);if(t)return t}n-=l,r-=l}else n-=l,r-=l}}D.prototype={constructor:D,find:function(t){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===t)return e;return-1},get:function(t){var e=this.find(t);return-1==e?void 0:this.content[e+1]},update:function(t,e,n){var r=n&&n!=t?this.remove(n):this,o=r.find(t),i=r.content.slice();return-1==o?i.push(n||t,e):(i[o+1]=e,n&&(i[o]=n)),new D(i)},remove:function(t){var e=this.find(t);if(-1==e)return this;var n=this.content.slice();return n.splice(e,2),new D(n)},addToStart:function(t,e){return new D([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var n=this.remove(t).content.slice();return n.push(t,e),new D(n)},addBefore:function(t,e,n){var r=this.remove(e),o=r.content.slice(),i=r.find(t);return o.splice(-1==i?o.length:i,0,e,n),new D(o)},forEach:function(t){for(var e=0;e<this.content.length;e+=2)t(this.content[e],this.content[e+1])},prepend:function(t){return(t=D.from(t)).size?new D(t.content.concat(this.subtract(t).content)):this},append:function(t){return(t=D.from(t)).size?new D(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=D.from(t);for(var n=0;n<t.content.length;n+=2)e=e.remove(t.content[n]);return e},toObject:function(){var t={};return this.forEach((function(e,n){t[e]=n})),t},get size(){return this.content.length>>1}},D.from=function(t){if(t instanceof D)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new D(e)};class L{constructor(t,e){if(this.content=t,this.size=e||0,null==e)for(let e=0;e<t.length;e++)this.size+=t[e].nodeSize}nodesBetween(t,e,n,r=0,o){for(let i=0,s=0;s<e;i++){let a=this.content[i],l=s+a.nodeSize;if(l>t&&!1!==n(a,r+s,o||null,i)&&a.content.size){let o=s+1;a.nodesBetween(Math.max(0,t-o),Math.min(a.content.size,e-o),n,r+o)}s=l}}descendants(t){this.nodesBetween(0,this.size,t)}textBetween(t,e,n,r){let o="",i=!0;return this.nodesBetween(t,e,((s,a)=>{let l=s.isText?s.text.slice(Math.max(t,a)-a,e-a):s.isLeaf?r?"function"==typeof r?r(s):r:s.type.spec.leafText?s.type.spec.leafText(s):"":"";s.isBlock&&(s.isLeaf&&l||s.isTextblock)&&n&&(i?i=!1:o+=n),o+=l}),0),o}append(t){if(!t.size)return this;if(!this.size)return t;let e=this.lastChild,n=t.firstChild,r=this.content.slice(),o=0;for(e.isText&&e.sameMarkup(n)&&(r[r.length-1]=e.withText(e.text+n.text),o=1);o<t.content.length;o++)r.push(t.content[o]);return new L(r,this.size+t.size)}cut(t,e=this.size){if(0==t&&e==this.size)return this;let n=[],r=0;if(e>t)for(let o=0,i=0;i<e;o++){let s=this.content[o],a=i+s.nodeSize;a>t&&((i<t||a>e)&&(s=s.isText?s.cut(Math.max(0,t-i),Math.min(s.text.length,e-i)):s.cut(Math.max(0,t-i-1),Math.min(s.content.size,e-i-1))),n.push(s),r+=s.nodeSize),i=a}return new L(n,r)}cutByIndex(t,e){return t==e?L.empty:0==t&&e==this.content.length?this:new L(this.content.slice(t,e))}replaceChild(t,e){let n=this.content[t];if(n==e)return this;let r=this.content.slice(),o=this.size+e.nodeSize-n.nodeSize;return r[t]=e,new L(r,o)}addToStart(t){return new L([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new L(this.content.concat(t),this.size+t.nodeSize)}eq(t){if(this.content.length!=t.content.length)return!1;for(let e=0;e<this.content.length;e++)if(!this.content[e].eq(t.content[e]))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(t){let e=this.content[t];if(!e)throw new RangeError("Index "+t+" out of range for "+this);return e}maybeChild(t){return this.content[t]||null}forEach(t){for(let e=0,n=0;e<this.content.length;e++){let r=this.content[e];t(r,n,e),n+=r.nodeSize}}findDiffStart(t,e=0){return R(this,t,e)}findDiffEnd(t,e=this.size,n=t.size){return I(this,t,e,n)}findIndex(t,e=-1){if(0==t)return j(0,t);if(t==this.size)return j(this.content.length,t);if(t>this.size||t<0)throw new RangeError(`Position ${t} outside of fragment (${this})`);for(let n=0,r=0;;n++){let o=r+this.child(n).nodeSize;if(o>=t)return o==t||e>0?j(n+1,o):j(n,r);r=o}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map((t=>t.toJSON())):null}static fromJSON(t,e){if(!e)return L.empty;if(!Array.isArray(e))throw new RangeError("Invalid input for Fragment.fromJSON");return new L(e.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return L.empty;let e,n=0;for(let r=0;r<t.length;r++){let o=t[r];n+=o.nodeSize,r&&o.isText&&t[r-1].sameMarkup(o)?(e||(e=t.slice(0,r)),e[e.length-1]=o.withText(e[e.length-1].text+o.text)):e&&e.push(o)}return new L(e||t,n)}static from(t){if(!t)return L.empty;if(t instanceof L)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new L([t],t.nodeSize);throw new RangeError("Can not convert "+t+" to a Fragment"+(t.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}L.empty=new L([],0);const P={index:0,offset:0};function j(t,e){return P.index=t,P.offset=e,P}function z(t,e){if(t===e)return!0;if(!t||"object"!=typeof t||!e||"object"!=typeof e)return!1;let n=Array.isArray(t);if(Array.isArray(e)!=n)return!1;if(n){if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++)if(!z(t[n],e[n]))return!1}else{for(let n in t)if(!(n in e)||!z(t[n],e[n]))return!1;for(let n in e)if(!(n in t))return!1}return!0}let $=class t{constructor(t,e){this.type=t,this.attrs=e}addToSet(t){let e,n=!1;for(let r=0;r<t.length;r++){let o=t[r];if(this.eq(o))return t;if(this.type.excludes(o.type))e||(e=t.slice(0,r));else{if(o.type.excludes(this.type))return t;!n&&o.type.rank>this.type.rank&&(e||(e=t.slice(0,r)),e.push(this),n=!0),e&&e.push(o)}}return e||(e=t.slice()),n||e.push(this),e}removeFromSet(t){for(let e=0;e<t.length;e++)if(this.eq(t[e]))return t.slice(0,e).concat(t.slice(e+1));return t}isInSet(t){for(let e=0;e<t.length;e++)if(this.eq(t[e]))return!0;return!1}eq(t){return this==t||this.type==t.type&&z(this.attrs,t.attrs)}toJSON(){let t={type:this.type.name};for(let e in this.attrs){t.attrs=this.attrs;break}return t}static fromJSON(t,e){if(!e)throw new RangeError("Invalid input for Mark.fromJSON");let n=t.marks[e.type];if(!n)throw new RangeError(`There is no mark type ${e.type} in this schema`);let r=n.create(e.attrs);return n.checkAttrs(r.attrs),r}static sameSet(t,e){if(t==e)return!0;if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++)if(!t[n].eq(e[n]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&0==e.length)return t.none;if(e instanceof t)return[e];let n=e.slice();return n.sort(((t,e)=>t.type.rank-e.type.rank)),n}};$.none=[];class B extends Error{}class F{constructor(t,e,n){this.content=t,this.openStart=e,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(t,e){let n=V(this.content,t+this.openStart,e);return n&&new F(n,this.openStart,this.openEnd)}removeBetween(t,e){return new F(_(this.content,t+this.openStart,e+this.openStart),this.openStart,this.openEnd)}eq(t){return this.content.eq(t.content)&&this.openStart==t.openStart&&this.openEnd==t.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let t={content:this.content.toJSON()};return this.openStart>0&&(t.openStart=this.openStart),this.openEnd>0&&(t.openEnd=this.openEnd),t}static fromJSON(t,e){if(!e)return F.empty;let n=e.openStart||0,r=e.openEnd||0;if("number"!=typeof n||"number"!=typeof r)throw new RangeError("Invalid input for Slice.fromJSON");return new F(L.fromJSON(t,e.content),n,r)}static maxOpen(t,e=!0){let n=0,r=0;for(let r=t.firstChild;r&&!r.isLeaf&&(e||!r.type.spec.isolating);r=r.firstChild)n++;for(let n=t.lastChild;n&&!n.isLeaf&&(e||!n.type.spec.isolating);n=n.lastChild)r++;return new F(t,n,r)}}function _(t,e,n){let{index:r,offset:o}=t.findIndex(e),i=t.maybeChild(r),{index:s,offset:a}=t.findIndex(n);if(o==e||i.isText){if(a!=n&&!t.child(s).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(r!=s)throw new RangeError("Removing non-flat range");return t.replaceChild(r,i.copy(_(i.content,e-o-1,n-o-1)))}function V(t,e,n,r){let{index:o,offset:i}=t.findIndex(e),s=t.maybeChild(o);if(i==e||s.isText)return r&&!r.canReplace(o,o,n)?null:t.cut(0,e).append(n).append(t.cut(e));let a=V(s.content,e-i-1,n);return a&&t.replaceChild(o,s.copy(a))}function H(t,e,n){if(n.openStart>t.depth)throw new B("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new B("Inconsistent open depths");return W(t,e,n,0)}function W(t,e,n,r){let o=t.index(r),i=t.node(r);if(o==e.index(r)&&r<t.depth-n.openStart){let s=W(t,e,n,r+1);return i.copy(i.content.replaceChild(o,s))}if(n.content.size){if(n.openStart||n.openEnd||t.depth!=r||e.depth!=r){let{start:o,end:s}=function(t,e){let n=e.depth-t.openStart,r=e.node(n).copy(t.content);for(let t=n-1;t>=0;t--)r=e.node(t).copy(L.from(r));return{start:r.resolveNoCache(t.openStart+n),end:r.resolveNoCache(r.content.size-t.openEnd-n)}}(n,t);return G(i,Y(t,o,s,e,r))}{let r=t.parent,o=r.content;return G(r,o.cut(0,t.parentOffset).append(n.content).append(o.cut(e.parentOffset)))}}return G(i,Q(t,e,r))}function K(t,e){if(!e.type.compatibleContent(t.type))throw new B("Cannot join "+e.type.name+" onto "+t.type.name)}function q(t,e,n){let r=t.node(n);return K(r,e.node(n)),r}function J(t,e){let n=e.length-1;n>=0&&t.isText&&t.sameMarkup(e[n])?e[n]=t.withText(e[n].text+t.text):e.push(t)}function U(t,e,n,r){let o=(e||t).node(n),i=0,s=e?e.index(n):o.childCount;t&&(i=t.index(n),t.depth>n?i++:t.textOffset&&(J(t.nodeAfter,r),i++));for(let t=i;t<s;t++)J(o.child(t),r);e&&e.depth==n&&e.textOffset&&J(e.nodeBefore,r)}function G(t,e){return t.type.checkContent(e),t.copy(e)}function Y(t,e,n,r,o){let i=t.depth>o&&q(t,e,o+1),s=r.depth>o&&q(n,r,o+1),a=[];return U(null,t,o,a),i&&s&&e.index(o)==n.index(o)?(K(i,s),J(G(i,Y(t,e,n,r,o+1)),a)):(i&&J(G(i,Q(t,e,o+1)),a),U(e,n,o,a),s&&J(G(s,Q(n,r,o+1)),a)),U(r,null,o,a),new L(a)}function Q(t,e,n){let r=[];if(U(null,t,n,r),t.depth>n){J(G(q(t,e,n+1),Q(t,e,n+1)),r)}return U(e,null,n,r),new L(r)}F.empty=new F(L.empty,0,0);class X{constructor(t,e,n){this.pos=t,this.path=e,this.parentOffset=n,this.depth=e.length/3-1}resolveDepth(t){return null==t?this.depth:t<0?this.depth+t:t}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(t){return this.path[3*this.resolveDepth(t)]}index(t){return this.path[3*this.resolveDepth(t)+1]}indexAfter(t){return t=this.resolveDepth(t),this.index(t)+(t!=this.depth||this.textOffset?1:0)}start(t){return 0==(t=this.resolveDepth(t))?0:this.path[3*t-1]+1}end(t){return t=this.resolveDepth(t),this.start(t)+this.node(t).content.size}before(t){if(!(t=this.resolveDepth(t)))throw new RangeError("There is no position before the top-level node");return t==this.depth+1?this.pos:this.path[3*t-1]}after(t){if(!(t=this.resolveDepth(t)))throw new RangeError("There is no position after the top-level node");return t==this.depth+1?this.pos:this.path[3*t-1]+this.path[3*t].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let t=this.parent,e=this.index(this.depth);if(e==t.childCount)return null;let n=this.pos-this.path[this.path.length-1],r=t.child(e);return n?t.child(e).cut(n):r}get nodeBefore(){let t=this.index(this.depth),e=this.pos-this.path[this.path.length-1];return e?this.parent.child(t).cut(0,e):0==t?null:this.parent.child(t-1)}posAtIndex(t,e){e=this.resolveDepth(e);let n=this.path[3*e],r=0==e?0:this.path[3*e-1]+1;for(let e=0;e<t;e++)r+=n.child(e).nodeSize;return r}marks(){let t=this.parent,e=this.index();if(0==t.content.size)return $.none;if(this.textOffset)return t.child(e).marks;let n=t.maybeChild(e-1),r=t.maybeChild(e);if(!n){let t=n;n=r,r=t}let o=n.marks;for(var i=0;i<o.length;i++)!1===o[i].type.spec.inclusive&&(!r||!o[i].isInSet(r.marks))&&(o=o[i--].removeFromSet(o));return o}marksAcross(t){let e=this.parent.maybeChild(this.index());if(!e||!e.isInline)return null;let n=e.marks,r=t.parent.maybeChild(t.index());for(var o=0;o<n.length;o++)!1===n[o].type.spec.inclusive&&(!r||!n[o].isInSet(r.marks))&&(n=n[o--].removeFromSet(n));return n}sharedDepth(t){for(let e=this.depth;e>0;e--)if(this.start(e)<=t&&this.end(e)>=t)return e;return 0}blockRange(t=this,e){if(t.pos<this.pos)return t.blockRange(this);for(let n=this.depth-(this.parent.inlineContent||this.pos==t.pos?1:0);n>=0;n--)if(t.pos<=this.end(n)&&(!e||e(this.node(n))))return new nt(this,t,n);return null}sameParent(t){return this.pos-this.parentOffset==t.pos-t.parentOffset}max(t){return t.pos>this.pos?t:this}min(t){return t.pos<this.pos?t:this}toString(){let t="";for(let e=1;e<=this.depth;e++)t+=(t?"/":"")+this.node(e).type.name+"_"+this.index(e-1);return t+":"+this.parentOffset}static resolve(t,e){if(!(e>=0&&e<=t.content.size))throw new RangeError("Position "+e+" out of range");let n=[],r=0,o=e;for(let e=t;;){let{index:t,offset:i}=e.content.findIndex(o),s=o-i;if(n.push(e,t,r+i),!s||(e=e.child(t),e.isText))break;o=s-1,r+=i+1}return new X(e,n,o)}static resolveCached(t,e){let n=et.get(t);if(n)for(let t=0;t<n.elts.length;t++){let r=n.elts[t];if(r.pos==e)return r}else et.set(t,n=new Z);let r=n.elts[n.i]=X.resolve(t,e);return n.i=(n.i+1)%tt,r}}class Z{constructor(){this.elts=[],this.i=0}}const tt=12,et=new WeakMap;class nt{constructor(t,e,n){this.$from=t,this.$to=e,this.depth=n}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 rt=Object.create(null);let ot=class t{constructor(t,e,n,r=$.none){this.type=t,this.attrs=e,this.marks=r,this.content=n||L.empty}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(t){return this.content.child(t)}maybeChild(t){return this.content.maybeChild(t)}forEach(t){this.content.forEach(t)}nodesBetween(t,e,n,r=0){this.content.nodesBetween(t,e,n,r,this)}descendants(t){this.nodesBetween(0,this.content.size,t)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(t,e,n,r){return this.content.textBetween(t,e,n,r)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(t){return this==t||this.sameMarkup(t)&&this.content.eq(t.content)}sameMarkup(t){return this.hasMarkup(t.type,t.attrs,t.marks)}hasMarkup(t,e,n){return this.type==t&&z(this.attrs,e||t.defaultAttrs||rt)&&$.sameSet(this.marks,n||$.none)}copy(e=null){return e==this.content?this:new t(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new t(this.type,this.attrs,this.content,e)}cut(t,e=this.content.size){return 0==t&&e==this.content.size?this:this.copy(this.content.cut(t,e))}slice(t,e=this.content.size,n=!1){if(t==e)return F.empty;let r=this.resolve(t),o=this.resolve(e),i=n?0:r.sharedDepth(e),s=r.start(i),a=r.node(i).content.cut(r.pos-s,o.pos-s);return new F(a,r.depth-i,o.depth-i)}replace(t,e,n){return H(this.resolve(t),this.resolve(e),n)}nodeAt(t){for(let e=this;;){let{index:n,offset:r}=e.content.findIndex(t);if(e=e.maybeChild(n),!e)return null;if(r==t||e.isText)return e;t-=r+1}}childAfter(t){let{index:e,offset:n}=this.content.findIndex(t);return{node:this.content.maybeChild(e),index:e,offset:n}}childBefore(t){if(0==t)return{node:null,index:0,offset:0};let{index:e,offset:n}=this.content.findIndex(t);if(n<t)return{node:this.content.child(e),index:e,offset:n};let r=this.content.child(e-1);return{node:r,index:e-1,offset:n-r.nodeSize}}resolve(t){return X.resolveCached(this,t)}resolveNoCache(t){return X.resolve(this,t)}rangeHasMark(t,e,n){let r=!1;return e>t&&this.nodesBetween(t,e,(t=>(n.isInSet(t.marks)&&(r=!0),!r))),r}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 t=this.type.name;return this.content.size&&(t+="("+this.content.toStringInner()+")"),st(this.marks,t)}contentMatchAt(t){let e=this.type.contentMatch.matchFragment(this.content,0,t);if(!e)throw new Error("Called contentMatchAt on a node with invalid content");return e}canReplace(t,e,n=L.empty,r=0,o=n.childCount){let i=this.contentMatchAt(t).matchFragment(n,r,o),s=i&&i.matchFragment(this.content,e);if(!s||!s.validEnd)return!1;for(let t=r;t<o;t++)if(!this.type.allowsMarks(n.child(t).marks))return!1;return!0}canReplaceWith(t,e,n,r){if(r&&!this.type.allowsMarks(r))return!1;let o=this.contentMatchAt(t).matchType(n),i=o&&o.matchFragment(this.content,e);return!!i&&i.validEnd}canAppend(t){return t.content.size?this.canReplace(this.childCount,this.childCount,t.content):this.type.compatibleContent(t.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let t=$.none;for(let e=0;e<this.marks.length;e++){let n=this.marks[e];n.type.checkAttrs(n.attrs),t=n.addToSet(t)}if(!$.sameSet(t,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 t={type:this.type.name};for(let e in this.attrs){t.attrs=this.attrs;break}return this.content.size&&(t.content=this.content.toJSON()),this.marks.length&&(t.marks=this.marks.map((t=>t.toJSON()))),t}static fromJSON(t,e){if(!e)throw new RangeError("Invalid input for Node.fromJSON");let n;if(e.marks){if(!Array.isArray(e.marks))throw new RangeError("Invalid mark data for Node.fromJSON");n=e.marks.map(t.markFromJSON)}if("text"==e.type){if("string"!=typeof e.text)throw new RangeError("Invalid text node in JSON");return t.text(e.text,n)}let r=L.fromJSON(t,e.content),o=t.nodeType(e.type).create(e.attrs,r,n);return o.type.checkAttrs(o.attrs),o}};ot.prototype.text=void 0;class it extends ot{constructor(t,e,n,r){if(super(t,e,null,r),!n)throw new RangeError("Empty text nodes are not allowed");this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):st(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(t,e){return this.text.slice(t,e)}get nodeSize(){return this.text.length}mark(t){return t==this.marks?this:new it(this.type,this.attrs,this.text,t)}withText(t){return t==this.text?this:new it(this.type,this.attrs,t,this.marks)}cut(t=0,e=this.text.length){return 0==t&&e==this.text.length?this:this.withText(this.text.slice(t,e))}eq(t){return this.sameMarkup(t)&&this.text==t.text}toJSON(){let t=super.toJSON();return t.text=this.text,t}}function st(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class at{constructor(t){this.validEnd=t,this.next=[],this.wrapCache=[]}static parse(t,e){let n=new lt(t,e);if(null==n.next)return at.empty;let r=ct(n);n.next&&n.err("Unexpected trailing text");let o=function(t){let e=Object.create(null);return n(mt(t,0));function n(r){let o=[];r.forEach((e=>{t[e].forEach((({term:e,to:n})=>{if(!e)return;let r;for(let t=0;t<o.length;t++)o[t][0]==e&&(r=o[t][1]);mt(t,n).forEach((t=>{r||o.push([e,r=[]]),-1==r.indexOf(t)&&r.push(t)}))}))}));let i=e[r.join(",")]=new at(r.indexOf(t.length-1)>-1);for(let t=0;t<o.length;t++){let r=o[t][1].sort(ft);i.next.push({type:o[t][0],next:e[r.join(",")]||n(r)})}return i}}(function(t){let e=[[]];return o(i(t,0),n()),e;function n(){return e.push([])-1}function r(t,n,r){let o={term:r,to:n};return e[t].push(o),o}function o(t,e){t.forEach((t=>t.to=e))}function i(t,e){if("choice"==t.type)return t.exprs.reduce(((t,n)=>t.concat(i(n,e))),[]);if("seq"!=t.type){if("star"==t.type){let s=n();return r(e,s),o(i(t.expr,s),s),[r(s)]}if("plus"==t.type){let s=n();return o(i(t.expr,e),s),o(i(t.expr,s),s),[r(s)]}if("opt"==t.type)return[r(e)].concat(i(t.expr,e));if("range"==t.type){let s=e;for(let e=0;e<t.min;e++){let e=n();o(i(t.expr,s),e),s=e}if(-1==t.max)o(i(t.expr,s),s);else for(let e=t.min;e<t.max;e++){let e=n();r(s,e),o(i(t.expr,s),e),s=e}return[r(s)]}if("name"==t.type)return[r(e,void 0,t.value)];throw new Error("Unknown expr type")}for(let r=0;;r++){let s=i(t.exprs[r],e);if(r==t.exprs.length-1)return s;o(s,e=n())}}}(r));return function(t,e){for(let n=0,r=[t];n<r.length;n++){let t=r[n],o=!t.validEnd,i=[];for(let e=0;e<t.next.length;e++){let{type:n,next:s}=t.next[e];i.push(n.name),o&&!(n.isText||n.hasRequiredAttrs())&&(o=!1),-1==r.indexOf(s)&&r.push(s)}o&&e.err("Only non-generatable nodes ("+i.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}(o,n),o}matchType(t){for(let e=0;e<this.next.length;e++)if(this.next[e].type==t)return this.next[e].next;return null}matchFragment(t,e=0,n=t.childCount){let r=this;for(let o=e;r&&o<n;o++)r=r.matchType(t.child(o).type);return r}get inlineContent(){return 0!=this.next.length&&this.next[0].type.isInline}get defaultType(){for(let t=0;t<this.next.length;t++){let{type:e}=this.next[t];if(!e.isText&&!e.hasRequiredAttrs())return e}return null}compatible(t){for(let e=0;e<this.next.length;e++)for(let n=0;n<t.next.length;n++)if(this.next[e].type==t.next[n].type)return!0;return!1}fillBefore(t,e=!1,n=0){let r=[this];return function o(i,s){let a=i.matchFragment(t,n);if(a&&(!e||a.validEnd))return L.from(s.map((t=>t.createAndFill())));for(let t=0;t<i.next.length;t++){let{type:e,next:n}=i.next[t];if(!e.isText&&!e.hasRequiredAttrs()&&-1==r.indexOf(n)){r.push(n);let t=o(n,s.concat(e));if(t)return t}}return null}(this,[])}findWrapping(t){for(let e=0;e<this.wrapCache.length;e+=2)if(this.wrapCache[e]==t)return this.wrapCache[e+1];let e=this.computeWrapping(t);return this.wrapCache.push(t,e),e}computeWrapping(t){let e=Object.create(null),n=[{match:this,type:null,via:null}];for(;n.length;){let r=n.shift(),o=r.match;if(o.matchType(t)){let t=[];for(let e=r;e.type;e=e.via)t.push(e.type);return t.reverse()}for(let t=0;t<o.next.length;t++){let{type:i,next:s}=o.next[t];!i.isLeaf&&!i.hasRequiredAttrs()&&!(i.name in e)&&(!r.type||s.validEnd)&&(n.push({match:i.contentMatch,type:i,via:r}),e[i.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(t){if(t>=this.next.length)throw new RangeError(`There's no ${t}th edge in this content match`);return this.next[t]}toString(){let t=[];return function e(n){t.push(n);for(let r=0;r<n.next.length;r++)-1==t.indexOf(n.next[r].next)&&e(n.next[r].next)}(this),t.map(((e,n)=>{let r=n+(e.validEnd?"*":" ")+" ";for(let n=0;n<e.next.length;n++)r+=(n?", ":"")+e.next[n].type.name+"->"+t.indexOf(e.next[n].next);return r})).join("\n")}}at.empty=new at(!0);class lt{constructor(t,e){this.string=t,this.nodeTypes=e,this.inline=null,this.pos=0,this.tokens=t.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(t){return this.next==t&&(this.pos++||!0)}err(t){throw new SyntaxError(t+" (in content expression '"+this.string+"')")}}function ct(t){let e=[];do{e.push(dt(t))}while(t.eat("|"));return 1==e.length?e[0]:{type:"choice",exprs:e}}function dt(t){let e=[];do{e.push(ht(t))}while(t.next&&")"!=t.next&&"|"!=t.next);return 1==e.length?e[0]:{type:"seq",exprs:e}}function ht(t){let e=function(t){if(t.eat("(")){let e=ct(t);return t.eat(")")||t.err("Missing closing paren"),e}if(!/\W/.test(t.next)){let e=function(t,e){let n=t.nodeTypes,r=n[e];if(r)return[r];let o=[];for(let t in n){let r=n[t];r.groups.indexOf(e)>-1&&o.push(r)}return 0==o.length&&t.err("No node type or group '"+e+"' found"),o}(t,t.next).map((e=>(null==t.inline?t.inline=e.isInline:t.inline!=e.isInline&&t.err("Mixing inline and block content"),{type:"name",value:e})));return t.pos++,1==e.length?e[0]:{type:"choice",exprs:e}}t.err("Unexpected token '"+t.next+"'")}(t);for(;;)if(t.eat("+"))e={type:"plus",expr:e};else if(t.eat("*"))e={type:"star",expr:e};else if(t.eat("?"))e={type:"opt",expr:e};else{if(!t.eat("{"))break;e=pt(t,e)}return e}function ut(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function pt(t,e){let n=ut(t),r=n;return t.eat(",")&&(r="}"!=t.next?ut(t):-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function ft(t,e){return e-t}function mt(t,e){let n=[];return function e(r){let o=t[r];if(1==o.length&&!o[0].term)return e(o[0].to);n.push(r);for(let t=0;t<o.length;t++){let{term:r,to:i}=o[t];!r&&-1==n.indexOf(i)&&e(i)}}(e),n.sort(ft)}function gt(t){let e=Object.create(null);for(let n in t){let r=t[n];if(!r.hasDefault)return null;e[n]=r.default}return e}function yt(t,e){let n=Object.create(null);for(let r in t){let o=e&&e[r];if(void 0===o){let e=t[r];if(!e.hasDefault)throw new RangeError("No value supplied for attribute "+r);o=e.default}n[r]=o}return n}function bt(t,e,n,r){for(let r in e)if(!(r in t))throw new RangeError(`Unsupported attribute ${r} for ${n} of type ${r}`);for(let n in t){let r=t[n];r.validate&&r.validate(e[n])}}function vt(t,e){let n=Object.create(null);if(e)for(let r in e)n[r]=new kt(t,r,e[r]);return n}let wt=class t{constructor(t,e,n){this.name=t,this.schema=e,this.spec=n,this.markSet=null,this.groups=n.group?n.group.split(" "):[],this.attrs=vt(t,n.attrs),this.defaultAttrs=gt(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(n.inline||"text"==t),this.isText="text"==t}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}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let t in this.attrs)if(this.attrs[t].isRequired)return!0;return!1}compatibleContent(t){return this==t||this.contentMatch.compatible(t.contentMatch)}computeAttrs(t){return!t&&this.defaultAttrs?this.defaultAttrs:yt(this.attrs,t)}create(t=null,e,n){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new ot(this,this.computeAttrs(t),L.from(e),$.setFrom(n))}createChecked(t=null,e,n){return e=L.from(e),this.checkContent(e),new ot(this,this.computeAttrs(t),e,$.setFrom(n))}createAndFill(t=null,e,n){if(t=this.computeAttrs(t),(e=L.from(e)).size){let t=this.contentMatch.fillBefore(e);if(!t)return null;e=t.append(e)}let r=this.contentMatch.matchFragment(e),o=r&&r.fillBefore(L.empty,!0);return o?new ot(this,t,e.append(o),$.setFrom(n)):null}validContent(t){let e=this.contentMatch.matchFragment(t);if(!e||!e.validEnd)return!1;for(let e=0;e<t.childCount;e++)if(!this.allowsMarks(t.child(e).marks))return!1;return!0}checkContent(t){if(!this.validContent(t))throw new RangeError(`Invalid content for node ${this.name}: ${t.toString().slice(0,50)}`)}checkAttrs(t){bt(this.attrs,t,"node",this.name)}allowsMarkType(t){return null==this.markSet||this.markSet.indexOf(t)>-1}allowsMarks(t){if(null==this.markSet)return!0;for(let e=0;e<t.length;e++)if(!this.allowsMarkType(t[e].type))return!1;return!0}allowedMarks(t){if(null==this.markSet)return t;let e;for(let n=0;n<t.length;n++)this.allowsMarkType(t[n].type)?e&&e.push(t[n]):e||(e=t.slice(0,n));return e?e.length?e:$.none:t}static compile(e,n){let r=Object.create(null);e.forEach(((e,o)=>r[e]=new t(e,n,o)));let o=n.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 t in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};class kt{constructor(t,e,n){this.hasDefault=Object.prototype.hasOwnProperty.call(n,"default"),this.default=n.default,this.validate="string"==typeof n.validate?function(t,e,n){let r=n.split("|");return n=>{let o=null===n?"null":typeof n;if(r.indexOf(o)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${t}, got ${o}`)}}(t,e,n.validate):n.validate}get isRequired(){return!this.hasDefault}}class xt{constructor(t,e,n,r){this.name=t,this.rank=e,this.schema=n,this.spec=r,this.attrs=vt(t,r.attrs),this.excluded=null;let o=gt(this.attrs);this.instance=o?new $(this,o):null}create(t=null){return!t&&this.instance?this.instance:new $(this,yt(this.attrs,t))}static compile(t,e){let n=Object.create(null),r=0;return t.forEach(((t,o)=>n[t]=new xt(t,r++,e,o))),n}removeFromSet(t){for(var e=0;e<t.length;e++)t[e].type==this&&(t=t.slice(0,e).concat(t.slice(e+1)),e--);return t}isInSet(t){for(let e=0;e<t.length;e++)if(t[e].type==this)return t[e]}checkAttrs(t){bt(this.attrs,t,"mark",this.name)}excludes(t){return this.excluded.indexOf(t)>-1}}class St{constructor(t){this.linebreakReplacement=null,this.cached=Object.create(null);let e=this.spec={};for(let n in t)e[n]=t[n];e.nodes=D.from(t.nodes),e.marks=D.from(t.marks||{}),this.nodes=wt.compile(this.spec.nodes,this),this.marks=xt.compile(this.spec.marks,this);let n=Object.create(null);for(let t in this.nodes){if(t in this.marks)throw new RangeError(t+" can not be both a node and a mark");let e=this.nodes[t],r=e.spec.content||"",o=e.spec.marks;if(e.contentMatch=n[r]||(n[r]=at.parse(r,this.nodes)),e.inlineContent=e.contentMatch.inlineContent,e.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!e.isInline||!e.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=e}e.markSet="_"==o?null:o?Ot(this,o.split(" ")):""!=o&&e.inlineContent?null:[]}for(let t in this.marks){let e=this.marks[t],n=e.spec.excludes;e.excluded=null==n?[e]:""==n?[]:Ot(this,n.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(t,e=null,n,r){if("string"==typeof t)t=this.nodeType(t);else{if(!(t instanceof wt))throw new RangeError("Invalid node type: "+t);if(t.schema!=this)throw new RangeError("Node type from different schema used ("+t.name+")")}return t.createChecked(e,n,r)}text(t,e){let n=this.nodes.text;return new it(n,n.defaultAttrs,t,$.setFrom(e))}mark(t,e){return"string"==typeof t&&(t=this.marks[t]),t.create(e)}nodeFromJSON(t){return ot.fromJSON(this,t)}markFromJSON(t){return $.fromJSON(this,t)}nodeType(t){let e=this.nodes[t];if(!e)throw new RangeError("Unknown node type: "+t);return e}}function Ot(t,e){let n=[];for(let r=0;r<e.length;r++){let o=e[r],i=t.marks[o],s=i;if(i)n.push(i);else for(let e in t.marks){let r=t.marks[e];("_"==o||r.spec.group&&r.spec.group.split(" ").indexOf(o)>-1)&&n.push(s=r)}if(!s)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return n}class Ct{constructor(t,e){this.schema=t,this.rules=e,this.tags=[],this.styles=[];let n=this.matchedStyles=[];e.forEach((t=>{if(null!=t.tag)this.tags.push(t);else if(function(t){return null!=t.style}(t)){let e=/[^=]*/.exec(t.style)[0];n.indexOf(e)<0&&n.push(e),this.styles.push(t)}})),this.normalizeLists=!this.tags.some((e=>{if(!/^(ul|ol)\b/.test(e.tag)||!e.node)return!1;let n=t.nodes[e.node];return n.contentMatch.matchType(n)}))}parse(t,e={}){let n=new Dt(this,e,!1);return n.addAll(t,$.none,e.from,e.to),n.finish()}parseSlice(t,e={}){let n=new Dt(this,e,!0);return n.addAll(t,$.none,e.from,e.to),F.maxOpen(n.finish())}matchTag(t,e,n){for(let r=n?this.tags.indexOf(n)+1:0;r<this.tags.length;r++){let n=this.tags[r];if(Rt(t,n.tag)&&(void 0===n.namespace||t.namespaceURI==n.namespace)&&(!n.context||e.matchesContext(n.context))){if(n.getAttrs){let e=n.getAttrs(t);if(!1===e)continue;n.attrs=e||void 0}return n}}}matchStyle(t,e,n,r){for(let o=r?this.styles.indexOf(r)+1:0;o<this.styles.length;o++){let r=this.styles[o],i=r.style;if(!(0!=i.indexOf(t)||r.context&&!n.matchesContext(r.context)||i.length>t.length&&(61!=i.charCodeAt(t.length)||i.slice(t.length+1)!=e))){if(r.getAttrs){let t=r.getAttrs(e);if(!1===t)continue;r.attrs=t||void 0}return r}}}static schemaRules(t){let e=[];function n(t){let n=null==t.priority?50:t.priority,r=0;for(;r<e.length;r++){let t=e[r];if((null==t.priority?50:t.priority)<n)break}e.splice(r,0,t)}for(let e in t.marks){let r=t.marks[e].spec.parseDOM;r&&r.forEach((t=>{n(t=It(t)),t.mark||t.ignore||t.clearMark||(t.mark=e)}))}for(let e in t.nodes){let r=t.nodes[e].spec.parseDOM;r&&r.forEach((t=>{n(t=It(t)),t.node||t.ignore||t.mark||(t.node=e)}))}return e}static fromSchema(t){return t.cached.domParser||(t.cached.domParser=new Ct(t,Ct.schemaRules(t)))}}const Mt={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},Tt={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Et={ol:!0,ul:!0};function Nt(t,e,n){return null!=e?(e?1:0)|("full"===e?2:0):t&&"pre"==t.whitespace?3:-5&n}class At{constructor(t,e,n,r,o,i){this.type=t,this.attrs=e,this.marks=n,this.solid=r,this.options=i,this.content=[],this.activeMarks=$.none,this.match=o||(4&i?null:t.contentMatch)}findWrapping(t){if(!this.match){if(!this.type)return[];let e=this.type.contentMatch.fillBefore(L.from(t));if(!e){let e,n=this.type.contentMatch;return(e=n.findWrapping(t.type))?(this.match=n,e):null}this.match=this.type.contentMatch.matchFragment(e)}return this.match.findWrapping(t.type)}finish(t){if(!(1&this.options)){let t,e=this.content[this.content.length-1];if(e&&e.isText&&(t=/[ \t\r\n\u000c]+$/.exec(e.text))){let n=e;e.text.length==t[0].length?this.content.pop():this.content[this.content.length-1]=n.withText(n.text.slice(0,n.text.length-t[0].length))}}let e=L.from(this.content);return!t&&this.match&&(e=e.append(this.match.fillBefore(L.empty,!0))),this.type?this.type.create(this.attrs,e,this.marks):e}inlineContext(t){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:t.parentNode&&!Mt.hasOwnProperty(t.parentNode.nodeName.toLowerCase())}}class Dt{constructor(t,e,n){this.parser=t,this.options=e,this.isOpen=n,this.open=0;let r,o=e.topNode,i=Nt(null,e.preserveWhitespace,0)|(n?4:0);r=o?new At(o.type,o.attrs,$.none,!0,e.topMatch||o.type.contentMatch,i):new At(n?null:t.schema.topNodeType,null,$.none,!0,null,i),this.nodes=[r],this.find=e.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(t,e){3==t.nodeType?this.addTextNode(t,e):1==t.nodeType&&this.addElement(t,e)}addTextNode(t,e){let n=t.nodeValue,r=this.top;if(2&r.options||r.inlineContext(t)||/[^ \t\r\n\u000c]/.test(n)){if(1&r.options)n=2&r.options?n.replace(/\r\n?/g,"\n"):n.replace(/\r?\n|\r/g," ");else if(n=n.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(n)&&this.open==this.nodes.length-1){let e=r.content[r.content.length-1],o=t.previousSibling;(!e||o&&"BR"==o.nodeName||e.isText&&/[ \t\r\n\u000c]$/.test(e.text))&&(n=n.slice(1))}n&&this.insertNode(this.parser.schema.text(n),e),this.findInText(t)}else this.findInside(t)}addElement(t,e,n){let r,o=t.nodeName.toLowerCase();Et.hasOwnProperty(o)&&this.parser.normalizeLists&&function(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let t=1==e.nodeType?e.nodeName.toLowerCase():null;t&&Et.hasOwnProperty(t)&&n?(n.appendChild(e),e=n):"li"==t?n=e:t&&(n=null)}}(t);let i=this.options.ruleFromNode&&this.options.ruleFromNode(t)||(r=this.parser.matchTag(t,this,n));if(i?i.ignore:Tt.hasOwnProperty(o))this.findInside(t),this.ignoreFallback(t,e);else if(!i||i.skip||i.closeParent){i&&i.closeParent?this.open=Math.max(0,this.open-1):i&&i.skip.nodeType&&(t=i.skip);let n,r=this.top,s=this.needsBlock;if(Mt.hasOwnProperty(o))r.content.length&&r.content[0].isInline&&this.open&&(this.open--,r=this.top),n=!0,r.type||(this.needsBlock=!0);else if(!t.firstChild)return void this.leafFallback(t,e);let a=i&&i.skip?e:this.readStyles(t,e);a&&this.addAll(t,a),n&&this.sync(r),this.needsBlock=s}else{let n=this.readStyles(t,e);n&&this.addElementByRule(t,i,n,!1===i.consuming?r:void 0)}}leafFallback(t,e){"BR"==t.nodeName&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(t.ownerDocument.createTextNode("\n"),e)}ignoreFallback(t,e){"BR"==t.nodeName&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),e)}readStyles(t,e){let n=t.style;if(n&&n.length)for(let t=0;t<this.parser.matchedStyles.length;t++){let r=this.parser.matchedStyles[t],o=n.getPropertyValue(r);if(o)for(let t;;){let n=this.parser.matchStyle(r,o,this,t);if(!n)break;if(n.ignore)return null;if(e=n.clearMark?e.filter((t=>!n.clearMark(t))):e.concat(this.parser.schema.marks[n.mark].create(n.attrs)),!1!==n.consuming)break;t=n}}return e}addElementByRule(t,e,n,r){let o,i;if(e.node)if(i=this.parser.schema.nodes[e.node],i.isLeaf)this.insertNode(i.create(e.attrs),n)||this.leafFallback(t,n);else{let t=this.enter(i,e.attrs||null,n,e.preserveWhitespace);t&&(o=!0,n=t)}else{let t=this.parser.schema.marks[e.mark];n=n.concat(t.create(e.attrs))}let s=this.top;if(i&&i.isLeaf)this.findInside(t);else if(r)this.addElement(t,n,r);else if(e.getContent)this.findInside(t),e.getContent(t,this.parser.schema).forEach((t=>this.insertNode(t,n)));else{let r=t;"string"==typeof e.contentElement?r=t.querySelector(e.contentElement):"function"==typeof e.contentElement?r=e.contentElement(t):e.contentElement&&(r=e.contentElement),this.findAround(t,r,!0),this.addAll(r,n)}o&&this.sync(s)&&this.open--}addAll(t,e,n,r){let o=n||0;for(let i=n?t.childNodes[n]:t.firstChild,s=null==r?null:t.childNodes[r];i!=s;i=i.nextSibling,++o)this.findAtPoint(t,o),this.addDOM(i,e);this.findAtPoint(t,o)}findPlace(t,e){let n,r;for(let e=this.open;e>=0;e--){let o=this.nodes[e],i=o.findWrapping(t);if(i&&(!n||n.length>i.length)&&(n=i,r=o,!i.length)||o.solid)break}if(!n)return null;this.sync(r);for(let t=0;t<n.length;t++)e=this.enterInner(n[t],null,e,!1);return e}insertNode(t,e){if(t.isInline&&this.needsBlock&&!this.top.type){let t=this.textblockFromContext();t&&(e=this.enterInner(t,null,e))}let n=this.findPlace(t,e);if(n){this.closeExtra();let e=this.top;e.match&&(e.match=e.match.matchType(t.type));let r=$.none;for(let o of n.concat(t.marks))(e.type?e.type.allowsMarkType(o.type):Lt(o.type,t.type))&&(r=o.addToSet(r));return e.content.push(t.mark(r)),!0}return!1}enter(t,e,n,r){let o=this.findPlace(t.create(e),n);return o&&(o=this.enterInner(t,e,n,!0,r)),o}enterInner(t,e,n,r=!1,o){this.closeExtra();let i=this.top;i.match=i.match&&i.match.matchType(t);let s=Nt(t,o,i.options);4&i.options&&0==i.content.length&&(s|=4);let a=$.none;return n=n.filter((e=>!(i.type?i.type.allowsMarkType(e.type):Lt(e.type,t))||(a=e.addToSet(a),!1))),this.nodes.push(new At(t,e,a,r,null,s)),this.open++,n}closeExtra(t=!1){let e=this.nodes.length-1;if(e>this.open){for(;e>this.open;e--)this.nodes[e-1].content.push(this.nodes[e].finish(t));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(t){for(let e=this.open;e>=0;e--)if(this.nodes[e]==t)return this.open=e,!0;return!1}get currentPos(){this.closeExtra();let t=0;for(let e=this.open;e>=0;e--){let n=this.nodes[e].content;for(let e=n.length-1;e>=0;e--)t+=n[e].nodeSize;e&&t++}return t}findAtPoint(t,e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==t&&this.find[n].offset==e&&(this.find[n].pos=this.currentPos)}findInside(t){if(this.find)for(let e=0;e<this.find.length;e++)null==this.find[e].pos&&1==t.nodeType&&t.contains(this.find[e].node)&&(this.find[e].pos=this.currentPos)}findAround(t,e,n){if(t!=e&&this.find)for(let r=0;r<this.find.length;r++)null==this.find[r].pos&&1==t.nodeType&&t.contains(this.find[r].node)&&e.compareDocumentPosition(this.find[r].node)&(n?2:4)&&(this.find[r].pos=this.currentPos)}findInText(t){if(this.find)for(let e=0;e<this.find.length;e++)this.find[e].node==t&&(this.find[e].pos=this.currentPos-(t.nodeValue.length-this.find[e].offset))}matchesContext(t){if(t.indexOf("|")>-1)return t.split(/\s*\|\s*/).some(this.matchesContext,this);let e=t.split("/"),n=this.options.context,r=!(this.isOpen||n&&n.parent.type!=this.nodes[0].type),o=-(n?n.depth+1:0)+(r?0:1),i=(t,s)=>{for(;t>=0;t--){let a=e[t];if(""==a){if(t==e.length-1||0==t)continue;for(;s>=o;s--)if(i(t-1,s))return!0;return!1}{let t=s>0||0==s&&r?this.nodes[s].type:n&&s>=o?n.node(s-o).type:null;if(!t||t.name!=a&&-1==t.groups.indexOf(a))return!1;s--}}return!0};return i(e.length-1,this.open)}textblockFromContext(){let t=this.options.context;if(t)for(let e=t.depth;e>=0;e--){let n=t.node(e).contentMatchAt(t.indexAfter(e)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(let t in this.parser.schema.nodes){let e=this.parser.schema.nodes[t];if(e.isTextblock&&e.defaultAttrs)return e}}}function Rt(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function It(t){let e={};for(let n in t)e[n]=t[n];return e}function Lt(t,e){let n=e.schema.nodes;for(let r in n){let o=n[r];if(!o.allowsMarkType(t))continue;let i=[],s=t=>{i.push(t);for(let n=0;n<t.edgeCount;n++){let{type:r,next:o}=t.edge(n);if(r==e||i.indexOf(o)<0&&s(o))return!0}};if(s(o.contentMatch))return!0}}class Pt{constructor(t,e){this.nodes=t,this.marks=e}serializeFragment(t,e={},n){n||(n=zt(e).createDocumentFragment());let r=n,o=[];return t.forEach((t=>{if(o.length||t.marks.length){let n=0,i=0;for(;n<o.length&&i<t.marks.length;){let e=t.marks[i];if(this.marks[e.type.name]){if(!e.eq(o[n][0])||!1===e.type.spec.spanning)break;n++,i++}else i++}for(;n<o.length;)r=o.pop()[1];for(;i<t.marks.length;){let n=t.marks[i++],s=this.serializeMark(n,t.isInline,e);s&&(o.push([n,r]),r.appendChild(s.dom),r=s.contentDOM||s.dom)}}r.appendChild(this.serializeNodeInner(t,e))})),n}serializeNodeInner(t,e){let{dom:n,contentDOM:r}=Ft(zt(e),this.nodes[t.type.name](t),null,t.attrs);if(r){if(t.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(t.content,e,r)}return n}serializeNode(t,e={}){let n=this.serializeNodeInner(t,e);for(let r=t.marks.length-1;r>=0;r--){let o=this.serializeMark(t.marks[r],t.isInline,e);o&&((o.contentDOM||o.dom).appendChild(n),n=o.dom)}return n}serializeMark(t,e,n={}){let r=this.marks[t.type.name];return r&&Ft(zt(n),r(t,e),null,t.attrs)}static renderSpec(t,e,n=null,r){return Ft(t,e,n,r)}static fromSchema(t){return t.cached.domSerializer||(t.cached.domSerializer=new Pt(this.nodesFromSchema(t),this.marksFromSchema(t)))}static nodesFromSchema(t){let e=jt(t.nodes);return e.text||(e.text=t=>t.text),e}static marksFromSchema(t){return jt(t.marks)}}function jt(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function zt(t){return t.document||window.document}const $t=new WeakMap;function Bt(t){let e=$t.get(t);return void 0===e&&$t.set(t,e=function(t){let e=null;function n(t){if(t&&"object"==typeof t)if(Array.isArray(t))if("string"==typeof t[0])e||(e=[]),e.push(t);else for(let e=0;e<t.length;e++)n(t[e]);else for(let e in t)n(t[e])}return n(t),e}(t)),e}function Ft(t,e,n,r){if("string"==typeof e)return{dom:t.createTextNode(e)};if(null!=e.nodeType)return{dom:e};if(e.dom&&null!=e.dom.nodeType)return e;let o,i=e[0];if("string"!=typeof i)throw new RangeError("Invalid array passed to renderSpec");if(r&&(o=Bt(r))&&o.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 s=i.indexOf(" ");s>0&&(n=i.slice(0,s),i=i.slice(s+1));let a,l=n?t.createElementNS(n,i):t.createElement(i),c=e[1],d=1;if(c&&"object"==typeof c&&null==c.nodeType&&!Array.isArray(c)){d=2;for(let t in c)if(null!=c[t]){let e=t.indexOf(" ");e>0?l.setAttributeNS(t.slice(0,e),t.slice(e+1),c[t]):l.setAttribute(t,c[t])}}for(let o=d;o<e.length;o++){let i=e[o];if(0===i){if(o<e.length-1||o>d)throw new RangeError("Content hole must be the only child of its parent node");return{dom:l,contentDOM:l}}{let{dom:e,contentDOM:o}=Ft(t,i,n,r);if(l.appendChild(e),o){if(a)throw new RangeError("Multiple content holes");a=o}}}return{dom:l,contentDOM:a}}const _t=Math.pow(2,16);function Vt(t,e){return t+e*_t}function Ht(t){return 65535&t}class Wt{constructor(t,e,n){this.pos=t,this.delInfo=e,this.recover=n}get deleted(){return(8&this.delInfo)>0}get deletedBefore(){return(5&this.delInfo)>0}get deletedAfter(){return(6&this.delInfo)>0}get deletedAcross(){return(4&this.delInfo)>0}}class Kt{constructor(t,e=!1){if(this.ranges=t,this.inverted=e,!t.length&&Kt.empty)return Kt.empty}recover(t){let e=0,n=Ht(t);if(!this.inverted)for(let t=0;t<n;t++)e+=this.ranges[3*t+2]-this.ranges[3*t+1];return this.ranges[3*n]+e+((r=t)-(65535&r))/_t;var r}mapResult(t,e=1){return this._map(t,e,!1)}map(t,e=1){return this._map(t,e,!0)}_map(t,e,n){let r=0,o=this.inverted?2:1,i=this.inverted?1:2;for(let s=0;s<this.ranges.length;s+=3){let a=this.ranges[s]-(this.inverted?r:0);if(a>t)break;let l=this.ranges[s+o],c=this.ranges[s+i],d=a+l;if(t<=d){let o=a+r+((l?t==a?-1:t==d?1:e:e)<0?0:c);if(n)return o;let i=t==(e<0?a:d)?null:Vt(s/3,t-a),h=t==a?2:t==d?1:4;return(e<0?t!=a:t!=d)&&(h|=8),new Wt(o,h,i)}r+=c-l}return n?t+r:new Wt(t+r,0,null)}touches(t,e){let n=0,r=Ht(e),o=this.inverted?2:1,i=this.inverted?1:2;for(let e=0;e<this.ranges.length;e+=3){let s=this.ranges[e]-(this.inverted?n:0);if(s>t)break;let a=this.ranges[e+o];if(t<=s+a&&e==3*r)return!0;n+=this.ranges[e+i]-a}return!1}forEach(t){let e=this.inverted?2:1,n=this.inverted?1:2;for(let r=0,o=0;r<this.ranges.length;r+=3){let i=this.ranges[r],s=i-(this.inverted?o:0),a=i+(this.inverted?0:o),l=this.ranges[r+e],c=this.ranges[r+n];t(s,s+l,a,a+c),o+=c-l}}invert(){return new Kt(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(t){return 0==t?Kt.empty:new Kt(t<0?[0,-t,0]:[0,0,t])}}Kt.empty=new Kt([]);class qt{constructor(t=[],e,n=0,r=t.length){this.maps=t,this.mirror=e,this.from=n,this.to=r}slice(t=0,e=this.maps.length){return new qt(this.maps,this.mirror,t,e)}copy(){return new qt(this.maps.slice(),this.mirror&&this.mirror.slice(),this.from,this.to)}appendMap(t,e){this.to=this.maps.push(t),null!=e&&this.setMirror(this.maps.length-1,e)}appendMapping(t){for(let e=0,n=this.maps.length;e<t.maps.length;e++){let r=t.getMirror(e);this.appendMap(t.maps[e],null!=r&&r<e?n+r:void 0)}}getMirror(t){if(this.mirror)for(let e=0;e<this.mirror.length;e++)if(this.mirror[e]==t)return this.mirror[e+(e%2?-1:1)]}setMirror(t,e){this.mirror||(this.mirror=[]),this.mirror.push(t,e)}appendMappingInverted(t){for(let e=t.maps.length-1,n=this.maps.length+t.maps.length;e>=0;e--){let r=t.getMirror(e);this.appendMap(t.maps[e].invert(),null!=r&&r>e?n-r-1:void 0)}}invert(){let t=new qt;return t.appendMappingInverted(this),t}map(t,e=1){if(this.mirror)return this._map(t,e,!0);for(let n=this.from;n<this.to;n++)t=this.maps[n].map(t,e);return t}mapResult(t,e=1){return this._map(t,e,!1)}_map(t,e,n){let r=0;for(let n=this.from;n<this.to;n++){let o=this.maps[n].mapResult(t,e);if(null!=o.recover){let e=this.getMirror(n);if(null!=e&&e>n&&e<this.to){n=e,t=this.maps[e].recover(o.recover);continue}}r|=o.delInfo,t=o.pos}return n?t:new Wt(t,r,null)}}const Jt=Object.create(null);class Ut{getMap(){return Kt.empty}merge(t){return null}static fromJSON(t,e){if(!e||!e.stepType)throw new RangeError("Invalid input for Step.fromJSON");let n=Jt[e.stepType];if(!n)throw new RangeError(`No step type ${e.stepType} defined`);return n.fromJSON(t,e)}static jsonID(t,e){if(t in Jt)throw new RangeError("Duplicate use of step JSON ID "+t);return Jt[t]=e,e.prototype.jsonID=t,e}}class Gt{constructor(t,e){this.doc=t,this.failed=e}static ok(t){return new Gt(t,null)}static fail(t){return new Gt(null,t)}static fromReplace(t,e,n,r){try{return Gt.ok(t.replace(e,n,r))}catch(t){if(t instanceof B)return Gt.fail(t.message);throw t}}}function Yt(t,e,n){let r=[];for(let o=0;o<t.childCount;o++){let i=t.child(o);i.content.size&&(i=i.copy(Yt(i.content,e,i))),i.isInline&&(i=e(i,n,o)),r.push(i)}return L.fromArray(r)}class Qt extends Ut{constructor(t,e,n){super(),this.from=t,this.to=e,this.mark=n}apply(t){let e=t.slice(this.from,this.to),n=t.resolve(this.from),r=n.node(n.sharedDepth(this.to)),o=new F(Yt(e.content,((t,e)=>t.isAtom&&e.type.allowsMarkType(this.mark.type)?t.mark(this.mark.addToSet(t.marks)):t),r),e.openStart,e.openEnd);return Gt.fromReplace(t,this.from,this.to,o)}invert(){return new Xt(this.from,this.to,this.mark)}map(t){let e=t.mapResult(this.from,1),n=t.mapResult(this.to,-1);return e.deleted&&n.deleted||e.pos>=n.pos?null:new Qt(e.pos,n.pos,this.mark)}merge(t){return t instanceof Qt&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new Qt(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,e){if("number"!=typeof e.from||"number"!=typeof e.to)throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new Qt(e.from,e.to,t.markFromJSON(e.mark))}}Ut.jsonID("addMark",Qt);class Xt extends Ut{constructor(t,e,n){super(),this.from=t,this.to=e,this.mark=n}apply(t){let e=t.slice(this.from,this.to),n=new F(Yt(e.content,(t=>t.mark(this.mark.removeFromSet(t.marks))),t),e.openStart,e.openEnd);return Gt.fromReplace(t,this.from,this.to,n)}invert(){return new Qt(this.from,this.to,this.mark)}map(t){let e=t.mapResult(this.from,1),n=t.mapResult(this.to,-1);return e.deleted&&n.deleted||e.pos>=n.pos?null:new Xt(e.pos,n.pos,this.mark)}merge(t){return t instanceof Xt&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new Xt(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,e){if("number"!=typeof e.from||"number"!=typeof e.to)throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new Xt(e.from,e.to,t.markFromJSON(e.mark))}}Ut.jsonID("removeMark",Xt);class Zt extends Ut{constructor(t,e){super(),this.pos=t,this.mark=e}apply(t){let e=t.nodeAt(this.pos);if(!e)return Gt.fail("No node at mark step's position");let n=e.type.create(e.attrs,null,this.mark.addToSet(e.marks));return Gt.fromReplace(t,this.pos,this.pos+1,new F(L.from(n),0,e.isLeaf?0:1))}invert(t){let e=t.nodeAt(this.pos);if(e){let t=this.mark.addToSet(e.marks);if(t.length==e.marks.length){for(let n=0;n<e.marks.length;n++)if(!e.marks[n].isInSet(t))return new Zt(this.pos,e.marks[n]);return new Zt(this.pos,this.mark)}}return new te(this.pos,this.mark)}map(t){let e=t.mapResult(this.pos,1);return e.deletedAfter?null:new Zt(e.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,e){if("number"!=typeof e.pos)throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new Zt(e.pos,t.markFromJSON(e.mark))}}Ut.jsonID("addNodeMark",Zt);class te extends Ut{constructor(t,e){super(),this.pos=t,this.mark=e}apply(t){let e=t.nodeAt(this.pos);if(!e)return Gt.fail("No node at mark step's position");let n=e.type.create(e.attrs,null,this.mark.removeFromSet(e.marks));return Gt.fromReplace(t,this.pos,this.pos+1,new F(L.from(n),0,e.isLeaf?0:1))}invert(t){let e=t.nodeAt(this.pos);return e&&this.mark.isInSet(e.marks)?new Zt(this.pos,this.mark):this}map(t){let e=t.mapResult(this.pos,1);return e.deletedAfter?null:new te(e.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,e){if("number"!=typeof e.pos)throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new te(e.pos,t.markFromJSON(e.mark))}}Ut.jsonID("removeNodeMark",te);class ee extends Ut{constructor(t,e,n,r=!1){super(),this.from=t,this.to=e,this.slice=n,this.structure=r}apply(t){return this.structure&&re(t,this.from,this.to)?Gt.fail("Structure replace would overwrite content"):Gt.fromReplace(t,this.from,this.to,this.slice)}getMap(){return new Kt([this.from,this.to-this.from,this.slice.size])}invert(t){return new ee(this.from,this.from+this.slice.size,t.slice(this.from,this.to))}map(t){let e=t.mapResult(this.from,1),n=t.mapResult(this.to,-1);return e.deletedAcross&&n.deletedAcross?null:new ee(e.pos,Math.max(e.pos,n.pos),this.slice)}merge(t){if(!(t instanceof ee)||t.structure||this.structure)return null;if(this.from+this.slice.size!=t.from||this.slice.openEnd||t.slice.openStart){if(t.to!=this.from||this.slice.openStart||t.slice.openEnd)return null;{let e=this.slice.size+t.slice.size==0?F.empty:new F(t.slice.content.append(this.slice.content),t.slice.openStart,this.slice.openEnd);return new ee(t.from,this.to,e,this.structure)}}{let e=this.slice.size+t.slice.size==0?F.empty:new F(this.slice.content.append(t.slice.content),this.slice.openStart,t.slice.openEnd);return new ee(this.from,this.to+(t.to-t.from),e,this.structure)}}toJSON(){let t={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(t.slice=this.slice.toJSON()),this.structure&&(t.structure=!0),t}static fromJSON(t,e){if("number"!=typeof e.from||"number"!=typeof e.to)throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new ee(e.from,e.to,F.fromJSON(t,e.slice),!!e.structure)}}Ut.jsonID("replace",ee);class ne extends Ut{constructor(t,e,n,r,o,i,s=!1){super(),this.from=t,this.to=e,this.gapFrom=n,this.gapTo=r,this.slice=o,this.insert=i,this.structure=s}apply(t){if(this.structure&&(re(t,this.from,this.gapFrom)||re(t,this.gapTo,this.to)))return Gt.fail("Structure gap-replace would overwrite content");let e=t.slice(this.gapFrom,this.gapTo);if(e.openStart||e.openEnd)return Gt.fail("Gap is not a flat range");let n=this.slice.insertAt(this.insert,e.content);return n?Gt.fromReplace(t,this.from,this.to,n):Gt.fail("Content does not fit in gap")}getMap(){return new Kt([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(t){let e=this.gapTo-this.gapFrom;return new ne(this.from,this.from+this.slice.size+e,this.from+this.insert,this.from+this.insert+e,t.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(t){let e=t.mapResult(this.from,1),n=t.mapResult(this.to,-1),r=this.from==this.gapFrom?e.pos:t.map(this.gapFrom,-1),o=this.to==this.gapTo?n.pos:t.map(this.gapTo,1);return e.deletedAcross&&n.deletedAcross||r<e.pos||o>n.pos?null:new ne(e.pos,n.pos,r,o,this.slice,this.insert,this.structure)}toJSON(){let t={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(t.slice=this.slice.toJSON()),this.structure&&(t.structure=!0),t}static fromJSON(t,e){if("number"!=typeof e.from||"number"!=typeof e.to||"number"!=typeof e.gapFrom||"number"!=typeof e.gapTo||"number"!=typeof e.insert)throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new ne(e.from,e.to,e.gapFrom,e.gapTo,F.fromJSON(t,e.slice),e.insert,!!e.structure)}}function re(t,e,n){let r=t.resolve(e),o=n-e,i=r.depth;for(;o>0&&i>0&&r.indexAfter(i)==r.node(i).childCount;)i--,o--;if(o>0){let t=r.node(i).maybeChild(r.indexAfter(i));for(;o>0;){if(!t||t.isLeaf)return!0;t=t.firstChild,o--}}return!1}function oe(t,e,n,r=n.contentMatch,o=!0){let i=t.doc.nodeAt(e),s=[],a=e+1;for(let e=0;e<i.childCount;e++){let l=i.child(e),c=a+l.nodeSize,d=r.matchType(l.type);if(d){r=d;for(let e=0;e<l.marks.length;e++)n.allowsMarkType(l.marks[e].type)||t.step(new Xt(a,c,l.marks[e]));if(o&&l.isText&&"pre"!=n.whitespace){let t,e,r=/\r?\n|\r/g;for(;t=r.exec(l.text);)e||(e=new F(L.from(n.schema.text(" ",n.allowedMarks(l.marks))),0,0)),s.push(new ee(a+t.index,a+t.index+t[0].length,e))}}else s.push(new ee(a,c,F.empty));a=c}if(!r.validEnd){let e=r.fillBefore(L.empty,!0);t.replace(a,a,new F(e,0,0))}for(let e=s.length-1;e>=0;e--)t.step(s[e])}function ie(t,e,n){return(0==e||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function se(t){let e=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let n=t.depth;;--n){let r=t.$from.node(n),o=t.$from.index(n),i=t.$to.indexAfter(n);if(n<t.depth&&r.canReplace(o,i,e))return n;if(0==n||r.type.spec.isolating||!ie(r,o,i))break}return null}function ae(t,e,n=null,r=t){let o=function(t,e){let{parent:n,startIndex:r,endIndex:o}=t,i=n.contentMatchAt(r).findWrapping(e);if(!i)return null;let s=i.length?i[0]:e;return n.canReplaceWith(r,o,s)?i:null}(t,e),i=o&&function(t,e){let{parent:n,startIndex:r,endIndex:o}=t,i=n.child(r),s=e.contentMatch.findWrapping(i.type);if(!s)return null;let a=(s.length?s[s.length-1]:e).contentMatch;for(let t=r;a&&t<o;t++)a=a.matchType(n.child(t).type);return a&&a.validEnd?s:null}(r,e);return i?o.map(le).concat({type:e,attrs:n}).concat(i.map(le)):null}function le(t){return{type:t,attrs:null}}function ce(t,e,n=1,r){let o=t.resolve(e),i=o.depth-n,s=r&&r[r.length-1]||o.parent;if(i<0||o.parent.type.spec.isolating||!o.parent.canReplace(o.index(),o.parent.childCount)||!s.type.validContent(o.parent.content.cutByIndex(o.index(),o.parent.childCount)))return!1;for(let t=o.depth-1,e=n-2;t>i;t--,e--){let n=o.node(t),i=o.index(t);if(n.type.spec.isolating)return!1;let s=n.content.cutByIndex(i,n.childCount),a=r&&r[e+1];a&&(s=s.replaceChild(0,a.type.create(a.attrs)));let l=r&&r[e]||n;if(!n.canReplace(i+1,n.childCount)||!l.type.validContent(s))return!1}let a=o.indexAfter(i),l=r&&r[0];return o.node(i).canReplaceWith(a,a,l?l.type:o.node(i+1).type)}function de(t,e){let n=t.resolve(e),r=n.index();return he(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function he(t,e){return!(!t||!e||t.isLeaf||!t.canAppend(e))}function ue(t,e,n=-1){let r=t.resolve(e);for(let t=r.depth;;t--){let o,i,s=r.index(t);if(t==r.depth?(o=r.nodeBefore,i=r.nodeAfter):n>0?(o=r.node(t+1),s++,i=r.node(t).maybeChild(s)):(o=r.node(t).maybeChild(s-1),i=r.node(t+1)),o&&!o.isTextblock&&he(o,i)&&r.node(t).canReplace(s,s+1))return e;if(0==t)break;e=n<0?r.before(t):r.after(t)}}function pe(t,e,n=e,r=F.empty){if(e==n&&!r.size)return null;let o=t.resolve(e),i=t.resolve(n);return fe(o,i,r)?new ee(e,n,r):new me(o,i,r).fit()}function fe(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}Ut.jsonID("replaceAround",ne);class me{constructor(t,e,n){this.$from=t,this.$to=e,this.unplaced=n,this.frontier=[],this.placed=L.empty;for(let e=0;e<=t.depth;e++){let n=t.node(e);this.frontier.push({type:n.type,match:n.contentMatchAt(t.indexAfter(e))})}for(let e=t.depth;e>0;e--)this.placed=L.from(t.node(e).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let t=this.findFittable();t?this.placeNodes(t):this.openMore()||this.dropNode()}let t=this.mustMoveInline(),e=this.placed.size-this.depth-this.$from.depth,n=this.$from,r=this.close(t<0?this.$to:n.doc.resolve(t));if(!r)return null;let o=this.placed,i=n.depth,s=r.depth;for(;i&&s&&1==o.childCount;)o=o.firstChild.content,i--,s--;let a=new F(o,i,s);return t>-1?new ne(n.pos,t,this.$to.pos,this.$to.end(),a,e):a.size||n.pos!=this.$to.pos?new ee(n.pos,r.pos,a):null}findFittable(){let t=this.unplaced.openStart;for(let e=this.unplaced.content,n=0,r=this.unplaced.openEnd;n<t;n++){let o=e.firstChild;if(e.childCount>1&&(r=0),o.type.spec.isolating&&r<=n){t=n;break}e=o.content}for(let e=1;e<=2;e++)for(let n=1==e?t:this.unplaced.openStart;n>=0;n--){let t,r=null;n?(r=be(this.unplaced.content,n-1).firstChild,t=r.content):t=this.unplaced.content;let o=t.firstChild;for(let t=this.depth;t>=0;t--){let i,{type:s,match:a}=this.frontier[t],l=null;if(1==e&&(o?a.matchType(o.type)||(l=a.fillBefore(L.from(o),!1)):r&&s.compatibleContent(r.type)))return{sliceDepth:n,frontierDepth:t,parent:r,inject:l};if(2==e&&o&&(i=a.findWrapping(o.type)))return{sliceDepth:n,frontierDepth:t,parent:r,wrap:i};if(r&&a.matchType(r.type))break}}}openMore(){let{content:t,openStart:e,openEnd:n}=this.unplaced,r=be(t,e);return!(!r.childCount||r.firstChild.isLeaf)&&(this.unplaced=new F(t,e+1,Math.max(n,r.size+e>=t.size-n?e+1:0)),!0)}dropNode(){let{content:t,openStart:e,openEnd:n}=this.unplaced,r=be(t,e);if(r.childCount<=1&&e>0){let o=t.size-e<=e+r.size;this.unplaced=new F(ge(t,e-1,1),e-1,o?e-1:n)}else this.unplaced=new F(ge(t,e,1),e,n)}placeNodes({sliceDepth:t,frontierDepth:e,parent:n,inject:r,wrap:o}){for(;this.depth>e;)this.closeFrontierNode();if(o)for(let t=0;t<o.length;t++)this.openFrontierNode(o[t]);let i=this.unplaced,s=n?n.content:i.content,a=i.openStart-t,l=0,c=[],{match:d,type:h}=this.frontier[e];if(r){for(let t=0;t<r.childCount;t++)c.push(r.child(t));d=d.matchFragment(r)}let u=s.size+t-(i.content.size-i.openEnd);for(;l<s.childCount;){let t=s.child(l),e=d.matchType(t.type);if(!e)break;l++,(l>1||0==a||t.content.size)&&(d=e,c.push(ve(t.mark(h.allowedMarks(t.marks)),1==l?a:0,l==s.childCount?u:-1)))}let p=l==s.childCount;p||(u=-1),this.placed=ye(this.placed,e,L.from(c)),this.frontier[e].match=d,p&&u<0&&n&&n.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let t=0,e=s;t<u;t++){let t=e.lastChild;this.frontier.push({type:t.type,match:t.contentMatchAt(t.childCount)}),e=t.content}this.unplaced=p?0==t?F.empty:new F(ge(i.content,t-1,1),t-1,u<0?i.openEnd:t-1):new F(ge(i.content,t,l),i.openStart,i.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let t,e=this.frontier[this.depth];if(!e.type.isTextblock||!we(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:n}=this.$to,r=this.$to.after(n);for(;n>1&&r==this.$to.end(--n);)++r;return r}findCloseLevel(t){t:for(let e=Math.min(this.depth,t.depth);e>=0;e--){let{match:n,type:r}=this.frontier[e],o=e<t.depth&&t.end(e+1)==t.pos+(t.depth-(e+1)),i=we(t,e,r,n,o);if(i){for(let n=e-1;n>=0;n--){let{match:e,type:r}=this.frontier[n],o=we(t,n,r,e,!0);if(!o||o.childCount)continue t}return{depth:e,fit:i,move:o?t.doc.resolve(t.after(e+1)):t}}}}close(t){let e=this.findCloseLevel(t);if(!e)return null;for(;this.depth>e.depth;)this.closeFrontierNode();e.fit.childCount&&(this.placed=ye(this.placed,e.depth,e.fit)),t=e.move;for(let n=e.depth+1;n<=t.depth;n++){let e=t.node(n),r=e.type.contentMatch.fillBefore(e.content,!0,t.index(n));this.openFrontierNode(e.type,e.attrs,r)}return t}openFrontierNode(t,e=null,n){let r=this.frontier[this.depth];r.match=r.match.matchType(t),this.placed=ye(this.placed,this.depth,L.from(t.create(e,n))),this.frontier.push({type:t,match:t.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(L.empty,!0);t.childCount&&(this.placed=ye(this.placed,this.frontier.length,t))}}function ge(t,e,n){return 0==e?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(ge(t.firstChild.content,e-1,n)))}function ye(t,e,n){return 0==e?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(ye(t.lastChild.content,e-1,n)))}function be(t,e){for(let n=0;n<e;n++)t=t.firstChild.content;return t}function ve(t,e,n){if(e<=0)return t;let r=t.content;return e>1&&(r=r.replaceChild(0,ve(r.firstChild,e-1,1==r.childCount?n-1:0))),e>0&&(r=t.type.contentMatch.fillBefore(r).append(r),n<=0&&(r=r.append(t.type.contentMatch.matchFragment(r).fillBefore(L.empty,!0)))),t.copy(r)}function we(t,e,n,r,o){let i=t.node(e),s=o?t.indexAfter(e):t.index(e);if(s==i.childCount&&!n.compatibleContent(i.type))return null;let a=r.fillBefore(i.content,!0,s);return a&&!function(t,e,n){for(let r=n;r<e.childCount;r++)if(!t.allowsMarks(e.child(r).marks))return!0;return!1}(n,i.content,s)?a:null}function ke(t){return t.spec.defining||t.spec.definingForContent}function xe(t,e,n,r,o){if(e<n){let o=t.firstChild;t=t.replaceChild(0,o.copy(xe(o.content,e+1,n,r,o)))}if(e>r){let e=o.contentMatchAt(0),n=e.fillBefore(t).append(t);t=n.append(e.matchFragment(n).fillBefore(L.empty,!0))}return t}function Se(t,e){let n=[];for(let r=Math.min(t.depth,e.depth);r>=0;r--){let o=t.start(r);if(o<t.pos-(t.depth-r)||e.end(r)>e.pos+(e.depth-r)||t.node(r).type.spec.isolating||e.node(r).type.spec.isolating)break;(o==e.start(r)||r==t.depth&&r==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&r&&e.start(r-1)==o-1)&&n.push(r)}return n}class Oe extends Ut{constructor(t,e,n){super(),this.pos=t,this.attr=e,this.value=n}apply(t){let e=t.nodeAt(this.pos);if(!e)return Gt.fail("No node at attribute step's position");let n=Object.create(null);for(let t in e.attrs)n[t]=e.attrs[t];n[this.attr]=this.value;let r=e.type.create(n,null,e.marks);return Gt.fromReplace(t,this.pos,this.pos+1,new F(L.from(r),0,e.isLeaf?0:1))}getMap(){return Kt.empty}invert(t){return new Oe(this.pos,this.attr,t.nodeAt(this.pos).attrs[this.attr])}map(t){let e=t.mapResult(this.pos,1);return e.deletedAfter?null:new Oe(e.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(t,e){if("number"!=typeof e.pos||"string"!=typeof e.attr)throw new RangeError("Invalid input for AttrStep.fromJSON");return new Oe(e.pos,e.attr,e.value)}}Ut.jsonID("attr",Oe);class Ce extends Ut{constructor(t,e){super(),this.attr=t,this.value=e}apply(t){let e=Object.create(null);for(let n in t.attrs)e[n]=t.attrs[n];e[this.attr]=this.value;let n=t.type.create(e,t.content,t.marks);return Gt.ok(n)}getMap(){return Kt.empty}invert(t){return new Ce(this.attr,t.attrs[this.attr])}map(t){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(t,e){if("string"!=typeof e.attr)throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new Ce(e.attr,e.value)}}Ut.jsonID("docAttr",Ce);let Me=class extends Error{};Me=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n},(Me.prototype=Object.create(Error.prototype)).constructor=Me,Me.prototype.name="TransformError";class Te{constructor(t){this.doc=t,this.steps=[],this.docs=[],this.mapping=new qt}get before(){return this.docs.length?this.docs[0]:this.doc}step(t){let e=this.maybeStep(t);if(e.failed)throw new Me(e.failed);return this}maybeStep(t){let e=t.apply(this.doc);return e.failed||this.addStep(t,e.doc),e}get docChanged(){return this.steps.length>0}addStep(t,e){this.docs.push(this.doc),this.steps.push(t),this.mapping.appendMap(t.getMap()),this.doc=e}replace(t,e=t,n=F.empty){let r=pe(this.doc,t,e,n);return r&&this.step(r),this}replaceWith(t,e,n){return this.replace(t,e,new F(L.from(n),0,0))}delete(t,e){return this.replace(t,e,F.empty)}insert(t,e){return this.replaceWith(t,t,e)}replaceRange(t,e,n){return function(t,e,n,r){if(!r.size)return t.deleteRange(e,n);let o=t.doc.resolve(e),i=t.doc.resolve(n);if(fe(o,i,r))return t.step(new ee(e,n,r));let s=Se(o,t.doc.resolve(n));0==s[s.length-1]&&s.pop();let a=-(o.depth+1);s.unshift(a);for(let t=o.depth,e=o.pos-1;t>0;t--,e--){let n=o.node(t).type.spec;if(n.defining||n.definingAsContext||n.isolating)break;s.indexOf(t)>-1?a=t:o.before(t)==e&&s.splice(1,0,-t)}let l=s.indexOf(a),c=[],d=r.openStart;for(let t=r.content,e=0;;e++){let n=t.firstChild;if(c.push(n),e==r.openStart)break;t=n.content}for(let t=d-1;t>=0;t--){let e=c[t],n=ke(e.type);if(n&&!e.sameMarkup(o.node(Math.abs(a)-1)))d=t;else if(n||!e.type.isTextblock)break}for(let e=r.openStart;e>=0;e--){let a=(e+d+1)%(r.openStart+1),h=c[a];if(h)for(let e=0;e<s.length;e++){let c=s[(e+l)%s.length],d=!0;c<0&&(d=!1,c=-c);let u=o.node(c-1),p=o.index(c-1);if(u.canReplaceWith(p,p,h.type,h.marks))return t.replace(o.before(c),d?i.after(c):n,new F(xe(r.content,0,r.openStart,a),a,r.openEnd))}}let h=t.steps.length;for(let a=s.length-1;a>=0&&(t.replace(e,n,r),!(t.steps.length>h));a--){let t=s[a];t<0||(e=o.before(t),n=i.after(t))}}(this,t,e,n),this}replaceRangeWith(t,e,n){return function(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let o=function(t,e,n){let r=t.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),n))return e;if(0==r.parentOffset)for(let t=r.depth-1;t>=0;t--){let e=r.index(t);if(r.node(t).canReplaceWith(e,e,n))return r.before(t+1);if(e>0)return null}if(r.parentOffset==r.parent.content.size)for(let t=r.depth-1;t>=0;t--){let e=r.indexAfter(t);if(r.node(t).canReplaceWith(e,e,n))return r.after(t+1);if(e<r.node(t).childCount)return null}return null}(t.doc,e,r.type);null!=o&&(e=n=o)}t.replaceRange(e,n,new F(L.from(r),0,0))}(this,t,e,n),this}deleteRange(t,e){return function(t,e,n){let r=t.doc.resolve(e),o=t.doc.resolve(n),i=Se(r,o);for(let e=0;e<i.length;e++){let n=i[e],s=e==i.length-1;if(s&&0==n||r.node(n).type.contentMatch.validEnd)return t.delete(r.start(n),o.end(n));if(n>0&&(s||r.node(n-1).canReplace(r.index(n-1),o.indexAfter(n-1))))return t.delete(r.before(n),o.after(n))}for(let i=1;i<=r.depth&&i<=o.depth;i++)if(e-r.start(i)==r.depth-i&&n>r.end(i)&&o.end(i)-n!=o.depth-i)return t.delete(r.before(i),n);t.delete(e,n)}(this,t,e),this}lift(t,e){return function(t,e,n){let{$from:r,$to:o,depth:i}=e,s=r.before(i+1),a=o.after(i+1),l=s,c=a,d=L.empty,h=0;for(let t=i,e=!1;t>n;t--)e||r.index(t)>0?(e=!0,d=L.from(r.node(t).copy(d)),h++):l--;let u=L.empty,p=0;for(let t=i,e=!1;t>n;t--)e||o.after(t+1)<o.end(t)?(e=!0,u=L.from(o.node(t).copy(u)),p++):c++;t.step(new ne(l,c,s,a,new F(d.append(u),h,p),d.size-h,!0))}(this,t,e),this}join(t,e=1){return function(t,e,n){let r=new ee(e-n,e+n,F.empty,!0);t.step(r)}(this,t,e),this}wrap(t,e){return function(t,e,n){let r=L.empty;for(let t=n.length-1;t>=0;t--){if(r.size){let e=n[t].type.contentMatch.matchFragment(r);if(!e||!e.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=L.from(n[t].type.create(n[t].attrs,r))}let o=e.start,i=e.end;t.step(new ne(o,i,o,i,new F(r,0,0),n.length,!0))}(this,t,e),this}setBlockType(t,e=t,n,r=null){return function(t,e,n,r,o){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let i=t.steps.length;t.doc.nodesBetween(e,n,((e,n)=>{let s="function"==typeof o?o(e):o;if(e.isTextblock&&!e.hasMarkup(r,s)&&function(t,e,n){let r=t.resolve(e),o=r.index();return r.parent.canReplaceWith(o,o+1,n)}(t.doc,t.mapping.slice(i).map(n),r)){let o=null;if(r.schema.linebreakReplacement){let t="pre"==r.whitespace,e=!!r.contentMatch.matchType(r.schema.linebreakReplacement);t&&!e?o=!1:!t&&e&&(o=!0)}!1===o&&function(t,e,n,r){e.forEach(((o,i)=>{if(o.type==o.type.schema.linebreakReplacement){let o=t.mapping.slice(r).map(n+1+i);t.replaceWith(o,o+1,e.type.schema.text("\n"))}}))}(t,e,n,i),oe(t,t.mapping.slice(i).map(n,1),r,void 0,null===o);let a=t.mapping.slice(i),l=a.map(n,1),c=a.map(n+e.nodeSize,1);return t.step(new ne(l,c,l+1,c-1,new F(L.from(r.create(s,null,e.marks)),0,0),1,!0)),!0===o&&function(t,e,n,r){e.forEach(((o,i)=>{if(o.isText){let s,a=/\r?\n|\r/g;for(;s=a.exec(o.text);){let o=t.mapping.slice(r).map(n+1+i+s.index);t.replaceWith(o,o+1,e.type.schema.linebreakReplacement.create())}}}))}(t,e,n,i),!1}}))}(this,t,e,n,r),this}setNodeMarkup(t,e,n=null,r){return function(t,e,n,r,o){let i=t.doc.nodeAt(e);if(!i)throw new RangeError("No node at given position");n||(n=i.type);let s=n.create(r,null,o||i.marks);if(i.isLeaf)return t.replaceWith(e,e+i.nodeSize,s);if(!n.validContent(i.content))throw new RangeError("Invalid content for node type "+n.name);t.step(new ne(e,e+i.nodeSize,e+1,e+i.nodeSize-1,new F(L.from(s),0,0),1,!0))}(this,t,e,n,r),this}setNodeAttribute(t,e,n){return this.step(new Oe(t,e,n)),this}setDocAttribute(t,e){return this.step(new Ce(t,e)),this}addNodeMark(t,e){return this.step(new Zt(t,e)),this}removeNodeMark(t,e){if(!(e instanceof $)){let n=this.doc.nodeAt(t);if(!n)throw new RangeError("No node at position "+t);if(!(e=e.isInSet(n.marks)))return this}return this.step(new te(t,e)),this}split(t,e=1,n){return function(t,e,n=1,r){let o=t.doc.resolve(e),i=L.empty,s=L.empty;for(let t=o.depth,e=o.depth-n,a=n-1;t>e;t--,a--){i=L.from(o.node(t).copy(i));let e=r&&r[a];s=L.from(e?e.type.create(e.attrs,s):o.node(t).copy(s))}t.step(new ee(e,e,new F(i.append(s),n,n),!0))}(this,t,e,n),this}addMark(t,e,n){return function(t,e,n,r){let o,i,s=[],a=[];t.doc.nodesBetween(e,n,((t,l,c)=>{if(!t.isInline)return;let d=t.marks;if(!r.isInSet(d)&&c.type.allowsMarkType(r.type)){let c=Math.max(l,e),h=Math.min(l+t.nodeSize,n),u=r.addToSet(d);for(let t=0;t<d.length;t++)d[t].isInSet(u)||(o&&o.to==c&&o.mark.eq(d[t])?o.to=h:s.push(o=new Xt(c,h,d[t])));i&&i.to==c?i.to=h:a.push(i=new Qt(c,h,r))}})),s.forEach((e=>t.step(e))),a.forEach((e=>t.step(e)))}(this,t,e,n),this}removeMark(t,e,n){return function(t,e,n,r){let o=[],i=0;t.doc.nodesBetween(e,n,((t,s)=>{if(!t.isInline)return;i++;let a=null;if(r instanceof xt){let e,n=t.marks;for(;e=r.isInSet(n);)(a||(a=[])).push(e),n=e.removeFromSet(n)}else r?r.isInSet(t.marks)&&(a=[r]):a=t.marks;if(a&&a.length){let r=Math.min(s+t.nodeSize,n);for(let t=0;t<a.length;t++){let n,l=a[t];for(let t=0;t<o.length;t++){let e=o[t];e.step==i-1&&l.eq(o[t].style)&&(n=e)}n?(n.to=r,n.step=i):o.push({style:l,from:Math.max(s,e),to:r,step:i})}}})),o.forEach((e=>t.step(new Xt(e.from,e.to,e.style))))}(this,t,e,n),this}clearIncompatible(t,e,n){return oe(this,t,e,n),this}}const Ee=Object.create(null);class Ne{constructor(t,e,n){this.$anchor=t,this.$head=e,this.ranges=n||[new Ae(t.min(e),t.max(e))]}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 t=this.ranges;for(let e=0;e<t.length;e++)if(t[e].$from.pos!=t[e].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(t,e=F.empty){let n=e.content.lastChild,r=null;for(let t=0;t<e.openEnd;t++)r=n,n=n.lastChild;let o=t.steps.length,i=this.ranges;for(let s=0;s<i.length;s++){let{$from:a,$to:l}=i[s],c=t.mapping.slice(o);t.replaceRange(c.map(a.pos),c.map(l.pos),s?F.empty:e),0==s&&Fe(t,o,(n?n.isInline:r&&r.isTextblock)?-1:1)}}replaceWith(t,e){let n=t.steps.length,r=this.ranges;for(let o=0;o<r.length;o++){let{$from:i,$to:s}=r[o],a=t.mapping.slice(n),l=a.map(i.pos),c=a.map(s.pos);o?t.deleteRange(l,c):(t.replaceRangeWith(l,c,e),Fe(t,n,e.isInline?-1:1))}}static findFrom(t,e,n=!1){let r=t.parent.inlineContent?new Ie(t):Be(t.node(0),t.parent,t.pos,t.index(),e,n);if(r)return r;for(let r=t.depth-1;r>=0;r--){let o=e<0?Be(t.node(0),t.node(r),t.before(r+1),t.index(r),e,n):Be(t.node(0),t.node(r),t.after(r+1),t.index(r)+1,e,n);if(o)return o}return null}static near(t,e=1){return this.findFrom(t,e)||this.findFrom(t,-e)||new ze(t.node(0))}static atStart(t){return Be(t,t,0,0,1)||new ze(t)}static atEnd(t){return Be(t,t,t.content.size,t.childCount,-1)||new ze(t)}static fromJSON(t,e){if(!e||!e.type)throw new RangeError("Invalid input for Selection.fromJSON");let n=Ee[e.type];if(!n)throw new RangeError(`No selection type ${e.type} defined`);return n.fromJSON(t,e)}static jsonID(t,e){if(t in Ee)throw new RangeError("Duplicate use of selection JSON ID "+t);return Ee[t]=e,e.prototype.jsonID=t,e}getBookmark(){return Ie.between(this.$anchor,this.$head).getBookmark()}}Ne.prototype.visible=!0;class Ae{constructor(t,e){this.$from=t,this.$to=e}}let De=!1;function Re(t){!De&&!t.parent.inlineContent&&(De=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class Ie extends Ne{constructor(t,e=t){Re(t),Re(e),super(t,e)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(t,e){let n=t.resolve(e.map(this.head));if(!n.parent.inlineContent)return Ne.near(n);let r=t.resolve(e.map(this.anchor));return new Ie(r.parent.inlineContent?r:n,n)}replace(t,e=F.empty){if(super.replace(t,e),e==F.empty){let e=this.$from.marksAcross(this.$to);e&&t.ensureMarks(e)}}eq(t){return t instanceof Ie&&t.anchor==this.anchor&&t.head==this.head}getBookmark(){return new Le(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(t,e){if("number"!=typeof e.anchor||"number"!=typeof e.head)throw new RangeError("Invalid input for TextSelection.fromJSON");return new Ie(t.resolve(e.anchor),t.resolve(e.head))}static create(t,e,n=e){let r=t.resolve(e);return new this(r,n==e?r:t.resolve(n))}static between(t,e,n){let r=t.pos-e.pos;if((!n||r)&&(n=r>=0?1:-1),!e.parent.inlineContent){let t=Ne.findFrom(e,n,!0)||Ne.findFrom(e,-n,!0);if(!t)return Ne.near(e,n);e=t.$head}return t.parent.inlineContent||(0==r?t=e:(t=(Ne.findFrom(t,-n,!0)||Ne.findFrom(t,n,!0)).$anchor).pos<e.pos!=r<0&&(t=e)),new Ie(t,e)}}Ne.jsonID("text",Ie);class Le{constructor(t,e){this.anchor=t,this.head=e}map(t){return new Le(t.map(this.anchor),t.map(this.head))}resolve(t){return Ie.between(t.resolve(this.anchor),t.resolve(this.head))}}class Pe extends Ne{constructor(t){let e=t.nodeAfter,n=t.node(0).resolve(t.pos+e.nodeSize);super(t,n),this.node=e}map(t,e){let{deleted:n,pos:r}=e.mapResult(this.anchor),o=t.resolve(r);return n?Ne.near(o):new Pe(o)}content(){return new F(L.from(this.node),0,0)}eq(t){return t instanceof Pe&&t.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new je(this.anchor)}static fromJSON(t,e){if("number"!=typeof e.anchor)throw new RangeError("Invalid input for NodeSelection.fromJSON");return new Pe(t.resolve(e.anchor))}static create(t,e){return new Pe(t.resolve(e))}static isSelectable(t){return!t.isText&&!1!==t.type.spec.selectable}}Pe.prototype.visible=!1,Ne.jsonID("node",Pe);class je{constructor(t){this.anchor=t}map(t){let{deleted:e,pos:n}=t.mapResult(this.anchor);return e?new Le(n,n):new je(n)}resolve(t){let e=t.resolve(this.anchor),n=e.nodeAfter;return n&&Pe.isSelectable(n)?new Pe(e):Ne.near(e)}}class ze extends Ne{constructor(t){super(t.resolve(0),t.resolve(t.content.size))}replace(t,e=F.empty){if(e==F.empty){t.delete(0,t.doc.content.size);let e=Ne.atStart(t.doc);e.eq(t.selection)||t.setSelection(e)}else super.replace(t,e)}toJSON(){return{type:"all"}}static fromJSON(t){return new ze(t)}map(t){return new ze(t)}eq(t){return t instanceof ze}getBookmark(){return $e}}Ne.jsonID("all",ze);const $e={map(){return this},resolve:t=>new ze(t)};function Be(t,e,n,r,o,i=!1){if(e.inlineContent)return Ie.create(t,n);for(let s=r-(o>0?0:1);o>0?s<e.childCount:s>=0;s+=o){let r=e.child(s);if(r.isAtom){if(!i&&Pe.isSelectable(r))return Pe.create(t,n-(o<0?r.nodeSize:0))}else{let e=Be(t,r,n+o,o<0?r.childCount:0,o,i);if(e)return e}n+=r.nodeSize*o}return null}function Fe(t,e,n){let r=t.steps.length-1;if(r<e)return;let o,i=t.steps[r];(i instanceof ee||i instanceof ne)&&(t.mapping.maps[r].forEach(((t,e,n,r)=>{null==o&&(o=r)})),t.setSelection(Ne.near(t.doc.resolve(o),n)))}class _e extends Te{constructor(t){super(t.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=t.selection,this.storedMarks=t.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(t){if(t.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=t,this.curSelectionFor=this.steps.length,this.updated=-3&(1|this.updated),this.storedMarks=null,this}get selectionSet(){return(1&this.updated)>0}setStoredMarks(t){return this.storedMarks=t,this.updated|=2,this}ensureMarks(t){return $.sameSet(this.storedMarks||this.selection.$from.marks(),t)||this.setStoredMarks(t),this}addStoredMark(t){return this.ensureMarks(t.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(t){return this.ensureMarks(t.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(2&this.updated)>0}addStep(t,e){super.addStep(t,e),this.updated=-3&this.updated,this.storedMarks=null}setTime(t){return this.time=t,this}replaceSelection(t){return this.selection.replace(this,t),this}replaceSelectionWith(t,e=!0){let n=this.selection;return e&&(t=t.mark(this.storedMarks||(n.empty?n.$from.marks():n.$from.marksAcross(n.$to)||$.none))),n.replaceWith(this,t),this}deleteSelection(){return this.selection.replace(this),this}insertText(t,e,n){let r=this.doc.type.schema;if(null==e)return t?this.replaceSelectionWith(r.text(t),!0):this.deleteSelection();{if(null==n&&(n=e),n=n??e,!t)return this.deleteRange(e,n);let o=this.storedMarks;if(!o){let t=this.doc.resolve(e);o=n==e?t.marks():t.marksAcross(this.doc.resolve(n))}return this.replaceRangeWith(e,n,r.text(t,o)),this.selection.empty||this.setSelection(Ne.near(this.selection.$to)),this}}setMeta(t,e){return this.meta["string"==typeof t?t:t.key]=e,this}getMeta(t){return this.meta["string"==typeof t?t:t.key]}get isGeneric(){for(let t in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=4,this}get scrolledIntoView(){return(4&this.updated)>0}}function Ve(t,e){return e&&t?t.bind(e):t}class He{constructor(t,e,n){this.name=t,this.init=Ve(e.init,n),this.apply=Ve(e.apply,n)}}const We=[new He("doc",{init:t=>t.doc||t.schema.topNodeType.createAndFill(),apply:t=>t.doc}),new He("selection",{init:(t,e)=>t.selection||Ne.atStart(e.doc),apply:t=>t.selection}),new He("storedMarks",{init:t=>t.storedMarks||null,apply:(t,e,n,r)=>r.selection.$cursor?t.storedMarks:null}),new He("scrollToSelection",{init:()=>0,apply:(t,e)=>t.scrolledIntoView?e+1:e})];class Ke{constructor(t,e){this.schema=t,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=We.slice(),e&&e.forEach((t=>{if(this.pluginsByKey[t.key])throw new RangeError("Adding different instances of a keyed plugin ("+t.key+")");this.plugins.push(t),this.pluginsByKey[t.key]=t,t.spec.state&&this.fields.push(new He(t.key,t.spec.state,t))}))}}class qe{constructor(t){this.config=t}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(t){return this.applyTransaction(t).state}filterTransaction(t,e=-1){for(let n=0;n<this.config.plugins.length;n++)if(n!=e){let e=this.config.plugins[n];if(e.spec.filterTransaction&&!e.spec.filterTransaction.call(e,t,this))return!1}return!0}applyTransaction(t){if(!this.filterTransaction(t))return{state:this,transactions:[]};let e=[t],n=this.applyInner(t),r=null;for(;;){let o=!1;for(let i=0;i<this.config.plugins.length;i++){let s=this.config.plugins[i];if(s.spec.appendTransaction){let a=r?r[i].n:0,l=r?r[i].state:this,c=a<e.length&&s.spec.appendTransaction.call(s,a?e.slice(a):e,l,n);if(c&&n.filterTransaction(c,i)){if(c.setMeta("appendedTransaction",t),!r){r=[];for(let t=0;t<this.config.plugins.length;t++)r.push(t<i?{state:n,n:e.length}:{state:this,n:0})}e.push(c),n=n.applyInner(c),o=!0}r&&(r[i]={state:n,n:e.length})}}if(!o)return{state:n,transactions:e}}}applyInner(t){if(!t.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let e=new qe(this.config),n=this.config.fields;for(let r=0;r<n.length;r++){let o=n[r];e[o.name]=o.apply(t,this[o.name],this,e)}return e}get tr(){return new _e(this)}static create(t){let e=new Ke(t.doc?t.doc.type.schema:t.schema,t.plugins),n=new qe(e);for(let r=0;r<e.fields.length;r++)n[e.fields[r].name]=e.fields[r].init(t,n);return n}reconfigure(t){let e=new Ke(this.schema,t.plugins),n=e.fields,r=new qe(e);for(let e=0;e<n.length;e++){let o=n[e].name;r[o]=this.hasOwnProperty(o)?this[o]:n[e].init(t,r)}return r}toJSON(t){let e={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(e.storedMarks=this.storedMarks.map((t=>t.toJSON()))),t&&"object"==typeof t)for(let n in t){if("doc"==n||"selection"==n)throw new RangeError("The JSON fields `doc` and `selection` are reserved");let r=t[n],o=r.spec.state;o&&o.toJSON&&(e[n]=o.toJSON.call(r,this[r.key]))}return e}static fromJSON(t,e,n){if(!e)throw new RangeError("Invalid input for EditorState.fromJSON");if(!t.schema)throw new RangeError("Required config field 'schema' missing");let r=new Ke(t.schema,t.plugins),o=new qe(r);return r.fields.forEach((r=>{if("doc"==r.name)o.doc=ot.fromJSON(t.schema,e.doc);else if("selection"==r.name)o.selection=Ne.fromJSON(o.doc,e.selection);else if("storedMarks"==r.name)e.storedMarks&&(o.storedMarks=e.storedMarks.map(t.schema.markFromJSON));else{if(n)for(let i in n){let s=n[i],a=s.spec.state;if(s.key==r.name&&a&&a.fromJSON&&Object.prototype.hasOwnProperty.call(e,i))return void(o[r.name]=a.fromJSON.call(s,t,e[i],o))}o[r.name]=r.init(t,o)}})),o}}function Je(t,e,n){for(let r in t){let o=t[r];o instanceof Function?o=o.bind(e):"handleDOMEvents"==r&&(o=Je(o,e,{})),n[r]=o}return n}class Ue{constructor(t){this.spec=t,this.props={},t.props&&Je(t.props,this,this.props),this.key=t.key?t.key.key:Ye("plugin")}getState(t){return t[this.key]}}const Ge=Object.create(null);function Ye(t){return t in Ge?t+"$"+ ++Ge[t]:(Ge[t]=0,t+"$")}class Qe{constructor(t="key"){this.key=Ye(t)}get(t){return t.config.pluginsByKey[this.key]}getState(t){return t[this.key]}}const Xe=function(t){for(var e=0;;e++)if(!(t=t.previousSibling))return e},Ze=function(t){let e=t.assignedSlot||t.parentNode;return e&&11==e.nodeType?e.host:e};let tn=null;const en=function(t,e,n){let r=tn||(tn=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r},nn=function(t,e,n,r){return n&&(on(t,e,n,r,-1)||on(t,e,n,r,1))},rn=/^(img|br|input|textarea|hr)$/i;function on(t,e,n,r,o){for(;;){if(t==n&&e==r)return!0;if(e==(o<0?0:sn(t))){let n=t.parentNode;if(!n||1!=n.nodeType||an(t)||rn.test(t.nodeName)||"false"==t.contentEditable)return!1;e=Xe(t)+(o<0?0:1),t=n}else{if(1!=t.nodeType)return!1;if("false"==(t=t.childNodes[e+(o<0?-1:0)]).contentEditable)return!1;e=o<0?sn(t):0}}}function sn(t){return 3==t.nodeType?t.nodeValue.length:t.childNodes.length}function an(t){let e;for(let n=t;n&&!(e=n.pmViewDesc);n=n.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==t||e.contentDOM==t)}const ln=function(t){return t.focusNode&&nn(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function cn(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}const dn=typeof navigator<"u"?navigator:null,hn=typeof document<"u"?document:null,un=dn&&dn.userAgent||"",pn=/Edge\/(\d+)/.exec(un),fn=/MSIE \d/.exec(un),mn=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(un),gn=!!(fn||mn||pn),yn=fn?document.documentMode:mn?+mn[1]:pn?+pn[1]:0,bn=!gn&&/gecko\/(\d+)/i.test(un);bn&&(/Firefox\/(\d+)/.exec(un)||[0,0])[1];const vn=!gn&&/Chrome\/(\d+)/.exec(un),wn=!!vn,kn=vn?+vn[1]:0,xn=!gn&&!!dn&&/Apple Computer/.test(dn.vendor),Sn=xn&&(/Mobile\/\w+/.test(un)||!!dn&&dn.maxTouchPoints>2),On=Sn||!!dn&&/Mac/.test(dn.platform),Cn=!!dn&&/Win/.test(dn.platform),Mn=/Android \d/.test(un),Tn=!!hn&&"webkitFontSmoothing"in hn.documentElement.style,En=Tn?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Nn(t){let e=t.defaultView&&t.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:t.documentElement.clientWidth,top:0,bottom:t.documentElement.clientHeight}}function An(t,e){return"number"==typeof t?t:t[e]}function Dn(t){let e=t.getBoundingClientRect(),n=e.width/t.offsetWidth||1,r=e.height/t.offsetHeight||1;return{left:e.left,right:e.left+t.clientWidth*n,top:e.top,bottom:e.top+t.clientHeight*r}}function Rn(t,e,n){let r=t.someProp("scrollThreshold")||0,o=t.someProp("scrollMargin")||5,i=t.dom.ownerDocument;for(let s=n||t.dom;s;s=Ze(s)){if(1!=s.nodeType)continue;let t=s,n=t==i.body,a=n?Nn(i):Dn(t),l=0,c=0;if(e.top<a.top+An(r,"top")?c=-(a.top-e.top+An(o,"top")):e.bottom>a.bottom-An(r,"bottom")&&(c=e.bottom-e.top>a.bottom-a.top?e.top+An(o,"top")-a.top:e.bottom-a.bottom+An(o,"bottom")),e.left<a.left+An(r,"left")?l=-(a.left-e.left+An(o,"left")):e.right>a.right-An(r,"right")&&(l=e.right-a.right+An(o,"right")),l||c)if(n)i.defaultView.scrollBy(l,c);else{let n=t.scrollLeft,r=t.scrollTop;c&&(t.scrollTop+=c),l&&(t.scrollLeft+=l);let o=t.scrollLeft-n,i=t.scrollTop-r;e={left:e.left-o,top:e.top-i,right:e.right-o,bottom:e.bottom-i}}if(n||/^(fixed|sticky)$/.test(getComputedStyle(s).position))break}}function In(t){let e=[],n=t.ownerDocument;for(let r=t;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t!=n);r=Ze(r));return e}function Ln(t,e){for(let n=0;n<t.length;n++){let{dom:r,top:o,left:i}=t[n];r.scrollTop!=o+e&&(r.scrollTop=o+e),r.scrollLeft!=i&&(r.scrollLeft=i)}}let Pn=null;function jn(t,e){let n,r,o,i,s=2e8,a=0,l=e.top,c=e.top;for(let d=t.firstChild,h=0;d;d=d.nextSibling,h++){let t;if(1==d.nodeType)t=d.getClientRects();else{if(3!=d.nodeType)continue;t=en(d).getClientRects()}for(let u=0;u<t.length;u++){let p=t[u];if(p.top<=l&&p.bottom>=c){l=Math.max(p.bottom,l),c=Math.min(p.top,c);let t=p.left>e.left?p.left-e.left:p.right<e.left?e.left-p.right:0;if(t<s){n=d,s=t,r=t&&3==n.nodeType?{left:p.right<e.left?p.right:p.left,top:e.top}:e,1==d.nodeType&&t&&(a=h+(e.left>=(p.left+p.right)/2?1:0));continue}}else p.top>e.top&&!o&&p.left<=e.left&&p.right>=e.left&&(o=d,i={left:Math.max(p.left,Math.min(p.right,e.left)),top:p.top});!n&&(e.left>=p.right&&e.top>=p.top||e.left>=p.left&&e.top>=p.bottom)&&(a=h+1)}}return!n&&o&&(n=o,r=i,s=0),n&&3==n.nodeType?function(t,e){let n=t.nodeValue.length,r=document.createRange();for(let o=0;o<n;o++){r.setEnd(t,o+1),r.setStart(t,o);let n=_n(r,1);if(n.top!=n.bottom&&zn(e,n))return{node:t,offset:o+(e.left>=(n.left+n.right)/2?1:0)}}return{node:t,offset:0}}(n,r):!n||s&&1==n.nodeType?{node:t,offset:a}:jn(n,r)}function zn(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function $n(t,e,n){let r=t.childNodes.length;if(r&&n.top<n.bottom)for(let o=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-n.top)/(n.bottom-n.top))-2)),i=o;;){let n=t.childNodes[i];if(1==n.nodeType){let t=n.getClientRects();for(let r=0;r<t.length;r++){let o=t[r];if(zn(e,o))return $n(n,e,o)}}if((i=(i+1)%r)==o)break}return t}function Bn(t,e){let n,r=t.dom.ownerDocument,o=0,i=function(t,e,n){if(t.caretPositionFromPoint)try{let r=t.caretPositionFromPoint(e,n);if(r)return{node:r.offsetNode,offset:r.offset}}catch{}if(t.caretRangeFromPoint){let r=t.caretRangeFromPoint(e,n);if(r)return{node:r.startContainer,offset:r.startOffset}}}(r,e.left,e.top);i&&({node:n,offset:o}=i);let s,a=(t.root.elementFromPoint?t.root:r).elementFromPoint(e.left,e.top);if(!a||!t.dom.contains(1!=a.nodeType?a.parentNode:a)){let n=t.dom.getBoundingClientRect();if(!zn(e,n)||(a=$n(t.dom,e,n),!a))return null}if(xn)for(let t=a;n&&t;t=Ze(t))t.draggable&&(n=void 0);if(a=function(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left<t.getBoundingClientRect().left?n:t}(a,e),n){if(bn&&1==n.nodeType&&(o=Math.min(o,n.childNodes.length),o<n.childNodes.length)){let t,r=n.childNodes[o];"IMG"==r.nodeName&&(t=r.getBoundingClientRect()).right<=e.left&&t.bottom>e.top&&o++}let r;Tn&&o&&1==n.nodeType&&1==(r=n.childNodes[o-1]).nodeType&&"false"==r.contentEditable&&r.getBoundingClientRect().top>=e.top&&o--,n==t.dom&&o==n.childNodes.length-1&&1==n.lastChild.nodeType&&e.top>n.lastChild.getBoundingClientRect().bottom?s=t.state.doc.content.size:(0==o||1!=n.nodeType||"BR"!=n.childNodes[o-1].nodeName)&&(s=function(t,e,n,r){let o=-1;for(let n=e,i=!1;n!=t.dom;){let e=t.docView.nearestDesc(n,!0);if(!e)return null;if(1==e.dom.nodeType&&(e.node.isBlock&&e.parent||!e.contentDOM)){let t=e.dom.getBoundingClientRect();if(e.node.isBlock&&e.parent&&(!i&&t.left>r.left||t.top>r.top?o=e.posBefore:(!i&&t.right<r.left||t.bottom<r.top)&&(o=e.posAfter),i=!0),!e.contentDOM&&o<0&&!e.node.isText)return(e.node.isBlock?r.top<(t.top+t.bottom)/2:r.left<(t.left+t.right)/2)?e.posBefore:e.posAfter}n=e.dom.parentNode}return o>-1?o:t.docView.posFromDOM(e,n,-1)}(t,n,o,e))}null==s&&(s=function(t,e,n){let{node:r,offset:o}=jn(e,n),i=-1;if(1==r.nodeType&&!r.firstChild){let t=r.getBoundingClientRect();i=t.left!=t.right&&n.left>(t.left+t.right)/2?1:-1}return t.docView.posFromDOM(r,o,i)}(t,a,e));let l=t.docView.nearestDesc(a,!0);return{pos:s,inside:l?l.posAtStart-l.border:-1}}function Fn(t){return t.top<t.bottom||t.left<t.right}function _n(t,e){let n=t.getClientRects();if(n.length){let t=n[e<0?0:n.length-1];if(Fn(t))return t}return Array.prototype.find.call(n,Fn)||t.getBoundingClientRect()}const Vn=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function Hn(t,e,n){let{node:r,offset:o,atom:i}=t.docView.domFromPos(e,n<0?-1:1),s=Tn||bn;if(3==r.nodeType){if(!s||!Vn.test(r.nodeValue)&&(n<0?o:o!=r.nodeValue.length)){let t=o,e=o,i=n<0?1:-1;return n<0&&!o?(e++,i=-1):n>=0&&o==r.nodeValue.length?(t--,i=1):n<0?t--:e++,Wn(_n(en(r,t,e),i),i<0)}{let t=_n(en(r,o,o),n);if(bn&&o&&/\s/.test(r.nodeValue[o-1])&&o<r.nodeValue.length){let e=_n(en(r,o-1,o-1),-1);if(e.top==t.top){let n=_n(en(r,o,o+1),-1);if(n.top!=t.top)return Wn(n,n.left<e.left)}}return t}}if(!t.state.doc.resolve(e-(i||0)).parent.inlineContent){if(null==i&&o&&(n<0||o==sn(r))){let t=r.childNodes[o-1];if(1==t.nodeType)return Kn(t.getBoundingClientRect(),!1)}if(null==i&&o<sn(r)){let t=r.childNodes[o];if(1==t.nodeType)return Kn(t.getBoundingClientRect(),!0)}return Kn(r.getBoundingClientRect(),n>=0)}if(null==i&&o&&(n<0||o==sn(r))){let t=r.childNodes[o-1],e=3==t.nodeType?en(t,sn(t)-(s?0:1)):1!=t.nodeType||"BR"==t.nodeName&&t.nextSibling?null:t;if(e)return Wn(_n(e,1),!1)}if(null==i&&o<sn(r)){let t=r.childNodes[o];for(;t.pmViewDesc&&t.pmViewDesc.ignoreForCoords;)t=t.nextSibling;let e=t?3==t.nodeType?en(t,0,s?0:1):1==t.nodeType?t:null:null;if(e)return Wn(_n(e,-1),!0)}return Wn(_n(3==r.nodeType?en(r):r,-n),n>=0)}function Wn(t,e){if(0==t.width)return t;let n=e?t.left:t.right;return{top:t.top,bottom:t.bottom,left:n,right:n}}function Kn(t,e){if(0==t.height)return t;let n=e?t.top:t.bottom;return{top:n,bottom:n,left:t.left,right:t.right}}function qn(t,e,n){let r=t.state,o=t.root.activeElement;r!=e&&t.updateState(e),o!=t.dom&&t.focus();try{return n()}finally{r!=e&&t.updateState(r),o!=t.dom&&o&&o.focus()}}const Jn=/[\u0590-\u08ac]/;let Un=null,Gn=null,Yn=!1;function Qn(t,e,n){return Un==e&&Gn==n?Yn:(Un=e,Gn=n,Yn="up"==n||"down"==n?function(t,e,n){let r=e.selection,o="up"==n?r.$from:r.$to;return qn(t,e,(()=>{let{node:e}=t.docView.domFromPos(o.pos,"up"==n?-1:1);for(;;){let n=t.docView.nearestDesc(e,!0);if(!n)break;if(n.node.isBlock){e=n.contentDOM||n.dom;break}e=n.dom.parentNode}let r=Hn(t,o.pos,1);for(let t=e.firstChild;t;t=t.nextSibling){let e;if(1==t.nodeType)e=t.getClientRects();else{if(3!=t.nodeType)continue;e=en(t,0,t.nodeValue.length).getClientRects()}for(let t=0;t<e.length;t++){let o=e[t];if(o.bottom>o.top+1&&("up"==n?r.top-o.top>2*(o.bottom-r.top):o.bottom-r.bottom>2*(r.bottom-o.top)))return!1}}return!0}))}(t,e,n):function(t,e,n){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let o=r.parentOffset,i=!o,s=o==r.parent.content.size,a=t.domSelection();return a?Jn.test(r.parent.textContent)&&a.modify?qn(t,e,(()=>{let{focusNode:e,focusOffset:o,anchorNode:i,anchorOffset:s}=t.domSelectionRange(),l=a.caretBidiLevel;a.modify("move",n,"character");let c=r.depth?t.docView.domAfterPos(r.before()):t.dom,{focusNode:d,focusOffset:h}=t.domSelectionRange(),u=d&&!c.contains(1==d.nodeType?d:d.parentNode)||e==d&&o==h;try{a.collapse(i,s),e&&(e!=i||o!=s)&&a.extend&&a.extend(e,o)}catch{}return null!=l&&(a.caretBidiLevel=l),u})):"left"==n||"backward"==n?i:s:r.pos==r.start()||r.pos==r.end()}(t,e,n))}class Xn{constructor(t,e,n,r){this.parent=t,this.children=e,this.dom=n,this.contentDOM=r,this.dirty=0,n.pmViewDesc=this}matchesWidget(t){return!1}matchesMark(t){return!1}matchesNode(t,e,n){return!1}matchesHack(t){return!1}parseRule(){return null}stopEvent(t){return!1}get size(){let t=0;for(let e=0;e<this.children.length;e++)t+=this.children[e].size;return t}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let t=0;t<this.children.length;t++)this.children[t].destroy()}posBeforeChild(t){for(let e=0,n=this.posAtStart;;e++){let r=this.children[e];if(r==t)return n;n+=r.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(t,e,n){if(this.contentDOM&&this.contentDOM.contains(1==t.nodeType?t:t.parentNode)){if(n<0){let n,r;if(t==this.contentDOM)n=t.childNodes[e-1];else{for(;t.parentNode!=this.contentDOM;)t=t.parentNode;n=t.previousSibling}for(;n&&(!(r=n.pmViewDesc)||r.parent!=this);)n=n.previousSibling;return n?this.posBeforeChild(r)+r.size:this.posAtStart}{let n,r;if(t==this.contentDOM)n=t.childNodes[e];else{for(;t.parentNode!=this.contentDOM;)t=t.parentNode;n=t.nextSibling}for(;n&&(!(r=n.pmViewDesc)||r.parent!=this);)n=n.nextSibling;return n?this.posBeforeChild(r):this.posAtEnd}}let r;if(t==this.dom&&this.contentDOM)r=e>Xe(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))r=2&t.compareDocumentPosition(this.contentDOM);else if(this.dom.firstChild){if(0==e)for(let e=t;;e=e.parentNode){if(e==this.dom){r=!1;break}if(e.previousSibling)break}if(null==r&&e==t.childNodes.length)for(let e=t;;e=e.parentNode){if(e==this.dom){r=!0;break}if(e.nextSibling)break}}return r??n>0?this.posAtEnd:this.posAtStart}nearestDesc(t,e=!1){for(let n=!0,r=t;r;r=r.parentNode){let o,i=this.getDesc(r);if(i&&(!e||i.node)){if(!n||!(o=i.nodeDOM)||(1==o.nodeType?o.contains(1==t.nodeType?t:t.parentNode):o==t))return i;n=!1}}}getDesc(t){let e=t.pmViewDesc;for(let t=e;t;t=t.parent)if(t==this)return e}posFromDOM(t,e,n){for(let r=t;r;r=r.parentNode){let o=this.getDesc(r);if(o)return o.localPosFromDOM(t,e,n)}return-1}descAt(t){for(let e=0,n=0;e<this.children.length;e++){let r=this.children[e],o=n+r.size;if(n==t&&o!=n){for(;!r.border&&r.children.length;)r=r.children[0];return r}if(t<o)return r.descAt(t-n-r.border);n=o}}domFromPos(t,e){if(!this.contentDOM)return{node:this.dom,offset:0,atom:t+1};let n=0,r=0;for(let e=0;n<this.children.length;n++){let o=this.children[n],i=e+o.size;if(i>t||o instanceof ir){r=t-e;break}e=i}if(r)return this.children[n].domFromPos(r-this.children[n].border,e);for(let t;n&&!(t=this.children[n-1]).size&&t instanceof Zn&&t.side>=0;n--);if(e<=0){let t,r=!0;for(;t=n?this.children[n-1]:null,t&&t.dom.parentNode!=this.contentDOM;n--,r=!1);return t&&e&&r&&!t.border&&!t.domAtom?t.domFromPos(t.size,e):{node:this.contentDOM,offset:t?Xe(t.dom)+1:0}}{let t,r=!0;for(;t=n<this.children.length?this.children[n]:null,t&&t.dom.parentNode!=this.contentDOM;n++,r=!1);return t&&r&&!t.border&&!t.domAtom?t.domFromPos(0,e):{node:this.contentDOM,offset:t?Xe(t.dom):this.contentDOM.childNodes.length}}}parseRange(t,e,n=0){if(0==this.children.length)return{node:this.contentDOM,from:t,to:e,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let r=-1,o=-1;for(let i=n,s=0;;s++){let n=this.children[s],a=i+n.size;if(-1==r&&t<=a){let o=i+n.border;if(t>=o&&e<=a-n.border&&n.node&&n.contentDOM&&this.contentDOM.contains(n.contentDOM))return n.parseRange(t,e,o);t=i;for(let e=s;e>0;e--){let n=this.children[e-1];if(n.size&&n.dom.parentNode==this.contentDOM&&!n.emptyChildAt(1)){r=Xe(n.dom)+1;break}t-=n.size}-1==r&&(r=0)}if(r>-1&&(a>e||s==this.children.length-1)){e=a;for(let t=s+1;t<this.children.length;t++){let n=this.children[t];if(n.size&&n.dom.parentNode==this.contentDOM&&!n.emptyChildAt(-1)){o=Xe(n.dom);break}e+=n.size}-1==o&&(o=this.contentDOM.childNodes.length);break}i=a}return{node:this.contentDOM,from:t,to:e,fromOffset:r,toOffset:o}}emptyChildAt(t){if(this.border||!this.contentDOM||!this.children.length)return!1;let e=this.children[t<0?0:this.children.length-1];return 0==e.size||e.emptyChildAt(t)}domAfterPos(t){let{node:e,offset:n}=this.domFromPos(t,0);if(1!=e.nodeType||n==e.childNodes.length)throw new RangeError("No node after pos "+t);return e.childNodes[n]}setSelection(t,e,n,r=!1){let o=Math.min(t,e),i=Math.max(t,e);for(let s=0,a=0;s<this.children.length;s++){let l=this.children[s],c=a+l.size;if(o>a&&i<c)return l.setSelection(t-a-l.border,e-a-l.border,n,r);a=c}let s=this.domFromPos(t,t?-1:1),a=e==t?s:this.domFromPos(e,e?-1:1),l=n.getSelection(),c=!1;if((bn||xn)&&t==e){let{node:t,offset:e}=s;if(3==t.nodeType){if(c=!(!e||"\n"!=t.nodeValue[e-1]),c&&e==t.nodeValue.length)for(let e,n=t;n;n=n.parentNode){if(e=n.nextSibling){"BR"==e.nodeName&&(s=a={node:e.parentNode,offset:Xe(e)+1});break}let t=n.pmViewDesc;if(t&&t.node&&t.node.isBlock)break}}else{let n=t.childNodes[e-1];c=n&&("BR"==n.nodeName||"false"==n.contentEditable)}}if(bn&&l.focusNode&&l.focusNode!=a.node&&1==l.focusNode.nodeType){let t=l.focusNode.childNodes[l.focusOffset];t&&"false"==t.contentEditable&&(r=!0)}if(!(r||c&&xn)&&nn(s.node,s.offset,l.anchorNode,l.anchorOffset)&&nn(a.node,a.offset,l.focusNode,l.focusOffset))return;let d=!1;if((l.extend||t==e)&&!c){l.collapse(s.node,s.offset);try{t!=e&&l.extend(a.node,a.offset),d=!0}catch{}}if(!d){if(t>e){let t=s;s=a,a=t}let n=document.createRange();n.setEnd(a.node,a.offset),n.setStart(s.node,s.offset),l.removeAllRanges(),l.addRange(n)}}ignoreMutation(t){return!this.contentDOM&&"selection"!=t.type}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(t,e){for(let n=0,r=0;r<this.children.length;r++){let o=this.children[r],i=n+o.size;if(n==i?t<=i&&e>=n:t<i&&e>n){let r=n+o.border,s=i-o.border;if(t>=r&&e<=s)return this.dirty=t==n||e==i?2:1,void(t!=r||e!=s||!o.contentLost&&o.dom.parentNode==this.contentDOM?o.markDirty(t-r,e-r):o.dirty=3);o.dirty=o.dom!=o.contentDOM||o.dom.parentNode!=this.contentDOM||o.children.length?3:2}n=i}this.dirty=2}markParentsDirty(){let t=1;for(let e=this.parent;e;e=e.parent,t++){let n=1==t?2:1;e.dirty<n&&(e.dirty=n)}}get domAtom(){return!1}get ignoreForCoords(){return!1}isText(t){return!1}}class Zn extends Xn{constructor(t,e,n,r){let o,i=e.type.toDOM;if("function"==typeof i&&(i=i(n,(()=>o?o.parent?o.parent.posBeforeChild(o):void 0:r))),!e.type.spec.raw){if(1!=i.nodeType){let t=document.createElement("span");t.appendChild(i),i=t}i.contentEditable="false",i.classList.add("ProseMirror-widget")}super(t,[],i,null),this.widget=e,this.widget=e,o=this}matchesWidget(t){return 0==this.dirty&&t.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(t){let e=this.widget.spec.stopEvent;return!!e&&e(t)}ignoreMutation(t){return"selection"!=t.type||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get side(){return this.widget.type.side}}class tr extends Xn{constructor(t,e,n,r){super(t,[],e,null),this.textDOM=n,this.text=r}get size(){return this.text.length}localPosFromDOM(t,e){return t!=this.textDOM?this.posAtStart+(e?this.size:0):this.posAtStart+e}domFromPos(t){return{node:this.textDOM,offset:t}}ignoreMutation(t){return"characterData"===t.type&&t.target.nodeValue==t.oldValue}}class er extends Xn{constructor(t,e,n,r){super(t,[],n,r),this.mark=e}static create(t,e,n,r){let o=r.nodeViews[e.type.name],i=o&&o(e,r,n);return(!i||!i.dom)&&(i=Pt.renderSpec(document,e.type.spec.toDOM(e,n),null,e.attrs)),new er(t,e,i.dom,i.contentDOM||i.dom)}parseRule(){return 3&this.dirty||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(t){return 3!=this.dirty&&this.mark.eq(t)}markDirty(t,e){if(super.markDirty(t,e),0!=this.dirty){let t=this.parent;for(;!t.node;)t=t.parent;t.dirty<this.dirty&&(t.dirty=this.dirty),this.dirty=0}}slice(t,e,n){let r=er.create(this.parent,this.mark,!0,n),o=this.children,i=this.size;e<i&&(o=br(o,e,i,n)),t>0&&(o=br(o,0,t,n));for(let t=0;t<o.length;t++)o[t].parent=r;return r.children=o,r}}class nr extends Xn{constructor(t,e,n,r,o,i,s,a,l){super(t,[],o,i),this.node=e,this.outerDeco=n,this.innerDeco=r,this.nodeDOM=s}static create(t,e,n,r,o,i){let s,a=o.nodeViews[e.type.name],l=a&&a(e,o,(()=>s?s.parent?s.parent.posBeforeChild(s):void 0:i),n,r),c=l&&l.dom,d=l&&l.contentDOM;if(e.isText)if(c){if(3!=c.nodeType)throw new RangeError("Text must be rendered as a DOM text node")}else c=document.createTextNode(e.text);else c||({dom:c,contentDOM:d}=Pt.renderSpec(document,e.type.spec.toDOM(e),null,e.attrs));!d&&!e.isText&&"BR"!=c.nodeName&&(c.hasAttribute("contenteditable")||(c.contentEditable="false"),e.type.spec.draggable&&(c.draggable=!0));let h=c;return c=pr(c,n,e),l?s=new sr(t,e,n,r,c,d||null,h,l,o,i+1):e.isText?new or(t,e,n,r,c,h,o):new nr(t,e,n,r,c,d||null,h,o,i+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let t={node:this.node.type.name,attrs:this.node.attrs};if("pre"==this.node.type.whitespace&&(t.preserveWhitespace="full"),this.contentDOM)if(this.contentLost){for(let e=this.children.length-1;e>=0;e--){let n=this.children[e];if(this.dom.contains(n.dom.parentNode)){t.contentElement=n.dom.parentNode;break}}t.contentElement||(t.getContent=()=>L.empty)}else t.contentElement=this.contentDOM;else t.getContent=()=>this.node.content;return t}matchesNode(t,e,n){return 0==this.dirty&&t.eq(this.node)&&fr(e,this.outerDeco)&&n.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(t,e){let n=this.node.inlineContent,r=e,o=t.composing?this.localCompositionInfo(t,e):null,i=o&&o.pos>-1?o:null,s=o&&o.pos<0,a=new gr(this,i&&i.node,t);(function(t,e,n,r){let o=e.locals(t),i=0;if(0==o.length){for(let n=0;n<t.childCount;n++){let s=t.child(n);r(s,o,e.forChild(i,s),n),i+=s.nodeSize}return}let s=0,a=[],l=null;for(let c=0;;){let d,h,u,p;for(;s<o.length&&o[s].to==i;){let t=o[s++];t.widget&&(d?(h||(h=[d])).push(t):d=t)}if(d)if(h){h.sort(yr);for(let t=0;t<h.length;t++)n(h[t],c,!!l)}else n(d,c,!!l);if(l)p=-1,u=l,l=null;else{if(!(c<t.childCount))break;p=c,u=t.child(c++)}for(let t=0;t<a.length;t++)a[t].to<=i&&a.splice(t--,1);for(;s<o.length&&o[s].from<=i&&o[s].to>i;)a.push(o[s++]);let f=i+u.nodeSize;if(u.isText){let t=f;s<o.length&&o[s].from<t&&(t=o[s].from);for(let e=0;e<a.length;e++)a[e].to<t&&(t=a[e].to);t<f&&(l=u.cut(t-i),u=u.cut(0,t-i),f=t,p=-1)}else for(;s<o.length&&o[s].to<f;)s++;r(u,u.isInline&&!u.isLeaf?a.filter((t=>!t.inline)):a.slice(),e.forChild(i,u),p),i=f}})(this.node,this.innerDeco,((e,o,i)=>{e.spec.marks?a.syncToMarks(e.spec.marks,n,t):e.type.side>=0&&!i&&a.syncToMarks(o==this.node.childCount?$.none:this.node.child(o).marks,n,t),a.placeWidget(e,t,r)}),((e,i,l,c)=>{let d;a.syncToMarks(e.marks,n,t),a.findNodeMatch(e,i,l,c)||s&&t.state.selection.from>r&&t.state.selection.to<r+e.nodeSize&&(d=a.findIndexWithChild(o.node))>-1&&a.updateNodeAt(e,i,l,d,t)||a.updateNextNode(e,i,l,t,c,r)||a.addNode(e,i,l,t,r),r+=e.nodeSize})),a.syncToMarks([],n,t),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||2==this.dirty)&&(i&&this.protectLocalComposition(t,i),ar(this.contentDOM,this.children,t),Sn&&function(t){if("UL"==t.nodeName||"OL"==t.nodeName){let e=t.style.cssText;t.style.cssText=e+"; list-style: square !important",window.getComputedStyle(t).listStyle,t.style.cssText=e}}(this.dom))}localCompositionInfo(t,e){let{from:n,to:r}=t.state.selection;if(!(t.state.selection instanceof Ie)||n<e||r>e+this.node.content.size)return null;let o=t.input.compositionNode;if(!o||!this.dom.contains(o.parentNode))return null;if(this.node.inlineContent){let t=o.nodeValue,i=function(t,e,n,r){for(let o=0,i=0;o<t.childCount&&i<=r;){let s=t.child(o++),a=i;if(i+=s.nodeSize,!s.isText)continue;let l=s.text;for(;o<t.childCount;){let e=t.child(o++);if(i+=e.nodeSize,!e.isText)break;l+=e.text}if(i>=n){if(i>=r&&l.slice(r-e.length-a,r-a)==e)return r-e.length;let t=a<r?l.lastIndexOf(e,r-a-1):-1;if(t>=0&&t+e.length+a>=n)return a+t;if(n==r&&l.length>=r+e.length-a&&l.slice(r-a,r-a+e.length)==e)return r}}return-1}(this.node.content,t,n-e,r-e);return i<0?null:{node:o,pos:i,text:t}}return{node:o,pos:-1,text:""}}protectLocalComposition(t,{node:e,pos:n,text:r}){if(this.getDesc(e))return;let o=e;for(;o.parentNode!=this.contentDOM;o=o.parentNode){for(;o.previousSibling;)o.parentNode.removeChild(o.previousSibling);for(;o.nextSibling;)o.parentNode.removeChild(o.nextSibling);o.pmViewDesc&&(o.pmViewDesc=void 0)}let i=new tr(this,o,e,r);t.input.compositionNodes.push(i),this.children=br(this.children,n,n+r.length,t,i)}update(t,e,n,r){return!(3==this.dirty||!t.sameMarkup(this.node))&&(this.updateInner(t,e,n,r),!0)}updateInner(t,e,n,r){this.updateOuterDeco(e),this.node=t,this.innerDeco=n,this.contentDOM&&this.updateChildren(r,this.posAtStart),this.dirty=0}updateOuterDeco(t){if(fr(t,this.outerDeco))return;let e=1!=this.nodeDOM.nodeType,n=this.dom;this.dom=hr(this.dom,this.nodeDOM,dr(this.outerDeco,this.node,e),dr(t,this.node,e)),this.dom!=n&&(n.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=t}selectNode(){1==this.nodeDOM.nodeType&&this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.dom.draggable=!0)}deselectNode(){1==this.nodeDOM.nodeType&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.dom.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function rr(t,e,n,r,o){pr(r,e,t);let i=new nr(void 0,t,e,n,r,r,r,o,0);return i.contentDOM&&i.updateChildren(o,0),i}class or extends nr{constructor(t,e,n,r,o,i,s){super(t,e,n,r,o,null,i,s,0)}parseRule(){let t=this.nodeDOM.parentNode;for(;t&&t!=this.dom&&!t.pmIsDeco;)t=t.parentNode;return{skip:t||!0}}update(t,e,n,r){return!(3==this.dirty||0!=this.dirty&&!this.inParent()||!t.sameMarkup(this.node))&&(this.updateOuterDeco(e),(0!=this.dirty||t.text!=this.node.text)&&t.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=t.text,r.trackWrites==this.nodeDOM&&(r.trackWrites=null)),this.node=t,this.dirty=0,!0)}inParent(){let t=this.parent.contentDOM;for(let e=this.nodeDOM;e;e=e.parentNode)if(e==t)return!0;return!1}domFromPos(t){return{node:this.nodeDOM,offset:t}}localPosFromDOM(t,e,n){return t==this.nodeDOM?this.posAtStart+Math.min(e,this.node.text.length):super.localPosFromDOM(t,e,n)}ignoreMutation(t){return"characterData"!=t.type&&"selection"!=t.type}slice(t,e,n){let r=this.node.cut(t,e),o=document.createTextNode(r.text);return new or(this.parent,r,this.outerDeco,this.innerDeco,o,o,n)}markDirty(t,e){super.markDirty(t,e),this.dom!=this.nodeDOM&&(0==t||e==this.nodeDOM.nodeValue.length)&&(this.dirty=3)}get domAtom(){return!1}isText(t){return this.node.text==t}}class ir extends Xn{parseRule(){return{ignore:!0}}matchesHack(t){return 0==this.dirty&&this.dom.nodeName==t}get domAtom(){return!0}get ignoreForCoords(){return"IMG"==this.dom.nodeName}}class sr extends nr{constructor(t,e,n,r,o,i,s,a,l,c){super(t,e,n,r,o,i,s,l,c),this.spec=a}update(t,e,n,r){if(3==this.dirty)return!1;if(this.spec.update){let o=this.spec.update(t,e,n);return o&&this.updateInner(t,e,n,r),o}return!(!this.contentDOM&&!t.isLeaf)&&super.update(t,e,n,r)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(t,e,n,r){this.spec.setSelection?this.spec.setSelection(t,e,n):super.setSelection(t,e,n,r)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(t){return!!this.spec.stopEvent&&this.spec.stopEvent(t)}ignoreMutation(t){return this.spec.ignoreMutation?this.spec.ignoreMutation(t):super.ignoreMutation(t)}}function ar(t,e,n){let r=t.firstChild,o=!1;for(let i=0;i<e.length;i++){let s=e[i],a=s.dom;if(a.parentNode==t){for(;a!=r;)r=mr(r),o=!0;r=r.nextSibling}else o=!0,t.insertBefore(a,r);if(s instanceof er){let e=r?r.previousSibling:t.lastChild;ar(s.contentDOM,s.children,n),r=e?e.nextSibling:t.firstChild}}for(;r;)r=mr(r),o=!0;o&&n.trackWrites==t&&(n.trackWrites=null)}const lr=function(t){t&&(this.nodeName=t)};lr.prototype=Object.create(null);const cr=[new lr];function dr(t,e,n){if(0==t.length)return cr;let r=n?cr[0]:new lr,o=[r];for(let i=0;i<t.length;i++){let s=t[i].type.attrs;if(s){s.nodeName&&o.push(r=new lr(s.nodeName));for(let t in s){let i=s[t];null!=i&&(n&&1==o.length&&o.push(r=new lr(e.isInline?"span":"div")),"class"==t?r.class=(r.class?r.class+" ":"")+i:"style"==t?r.style=(r.style?r.style+";":"")+i:"nodeName"!=t&&(r[t]=i))}}}return o}function hr(t,e,n,r){if(n==cr&&r==cr)return e;let o=e;for(let e=0;e<r.length;e++){let i=r[e],s=n[e];if(e){let e;s&&s.nodeName==i.nodeName&&o!=t&&(e=o.parentNode)&&e.nodeName.toLowerCase()==i.nodeName||(e=document.createElement(i.nodeName),e.pmIsDeco=!0,e.appendChild(o),s=cr[0]),o=e}ur(o,s||cr[0],i)}return o}function ur(t,e,n){for(let r in e)"class"!=r&&"style"!=r&&"nodeName"!=r&&!(r in n)&&t.removeAttribute(r);for(let r in n)"class"!=r&&"style"!=r&&"nodeName"!=r&&n[r]!=e[r]&&t.setAttribute(r,n[r]);if(e.class!=n.class){let r=e.class?e.class.split(" ").filter(Boolean):[],o=n.class?n.class.split(" ").filter(Boolean):[];for(let e=0;e<r.length;e++)-1==o.indexOf(r[e])&&t.classList.remove(r[e]);for(let e=0;e<o.length;e++)-1==r.indexOf(o[e])&&t.classList.add(o[e]);0==t.classList.length&&t.removeAttribute("class")}if(e.style!=n.style){if(e.style){let n,r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g;for(;n=r.exec(e.style);)t.style.removeProperty(n[1])}n.style&&(t.style.cssText+=n.style)}}function pr(t,e,n){return hr(t,t,cr,dr(e,n,1!=t.nodeType))}function fr(t,e){if(t.length!=e.length)return!1;for(let n=0;n<t.length;n++)if(!t[n].type.eq(e[n].type))return!1;return!0}function mr(t){let e=t.nextSibling;return t.parentNode.removeChild(t),e}class gr{constructor(t,e,n){this.lock=e,this.view=n,this.index=0,this.stack=[],this.changed=!1,this.top=t,this.preMatch=function(t,e){let n=e,r=n.children.length,o=t.childCount,i=new Map,s=[];t:for(;o>0;){let a;for(;;)if(r){let t=n.children[r-1];if(!(t instanceof er)){a=t,r--;break}n=t,r=t.children.length}else{if(n==e)break t;r=n.parent.children.indexOf(n),n=n.parent}let l=a.node;if(l){if(l!=t.child(o-1))break;--o,i.set(a,o),s.push(a)}}return{index:o,matched:i,matches:s.reverse()}}(t.node.content,t)}destroyBetween(t,e){if(t!=e){for(let n=t;n<e;n++)this.top.children[n].destroy();this.top.children.splice(t,e-t),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(t,e,n){let r=0,o=this.stack.length>>1,i=Math.min(o,t.length);for(;r<i&&(r==o-1?this.top:this.stack[r+1<<1]).matchesMark(t[r])&&!1!==t[r].type.spec.spanning;)r++;for(;r<o;)this.destroyRest(),this.top.dirty=0,this.index=this.stack.pop(),this.top=this.stack.pop(),o--;for(;o<t.length;){this.stack.push(this.top,this.index+1);let r=-1;for(let e=this.index;e<Math.min(this.index+3,this.top.children.length);e++){let n=this.top.children[e];if(n.matchesMark(t[o])&&!this.isLocked(n.dom)){r=e;break}}if(r>-1)r>this.index&&(this.changed=!0,this.destroyBetween(this.index,r)),this.top=this.top.children[this.index];else{let r=er.create(this.top,t[o],e,n);this.top.children.splice(this.index,0,r),this.top=r,this.changed=!0}this.index=0,o++}}findNodeMatch(t,e,n,r){let o,i=-1;if(r>=this.preMatch.index&&(o=this.preMatch.matches[r-this.preMatch.index]).parent==this.top&&o.matchesNode(t,e,n))i=this.top.children.indexOf(o,this.index);else for(let r=this.index,o=Math.min(this.top.children.length,r+5);r<o;r++){let o=this.top.children[r];if(o.matchesNode(t,e,n)&&!this.preMatch.matched.has(o)){i=r;break}}return!(i<0)&&(this.destroyBetween(this.index,i),this.index++,!0)}updateNodeAt(t,e,n,r,o){let i=this.top.children[r];return 3==i.dirty&&i.dom==i.contentDOM&&(i.dirty=2),!!i.update(t,e,n,o)&&(this.destroyBetween(this.index,r),this.index++,!0)}findIndexWithChild(t){for(;;){let e=t.parentNode;if(!e)return-1;if(e==this.top.contentDOM){let e=t.pmViewDesc;if(e)for(let t=this.index;t<this.top.children.length;t++)if(this.top.children[t]==e)return t;return-1}t=e}}updateNextNode(t,e,n,r,o,i){for(let s=this.index;s<this.top.children.length;s++){let a=this.top.children[s];if(a instanceof nr){let l=this.preMatch.matched.get(a);if(null!=l&&l!=o)return!1;let c,d=a.dom,h=this.isLocked(d)&&!(t.isText&&a.node&&a.node.isText&&a.nodeDOM.nodeValue==t.text&&3!=a.dirty&&fr(e,a.outerDeco));if(!h&&a.update(t,e,n,r))return this.destroyBetween(this.index,s),a.dom!=d&&(this.changed=!0),this.index++,!0;if(!h&&(c=this.recreateWrapper(a,t,e,n,r,i)))return this.top.children[this.index]=c,c.contentDOM&&(c.dirty=2,c.updateChildren(r,i+1),c.dirty=0),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(t,e,n,r,o,i){if(t.dirty||e.isAtom||!t.children.length||!t.node.content.eq(e.content))return null;let s=nr.create(this.top,e,n,r,o,i);if(s.contentDOM){s.children=t.children,t.children=[];for(let t of s.children)t.parent=s}return t.destroy(),s}addNode(t,e,n,r,o){let i=nr.create(this.top,t,e,n,r,o);i.contentDOM&&i.updateChildren(r,o+1),this.top.children.splice(this.index++,0,i),this.changed=!0}placeWidget(t,e,n){let r=this.index<this.top.children.length?this.top.children[this.index]:null;if(!r||!r.matchesWidget(t)||t!=r.widget&&r.widget.type.toDOM.parentNode){let r=new Zn(this.top,t,e,n);this.top.children.splice(this.index++,0,r),this.changed=!0}else this.index++}addTextblockHacks(){let t=this.top.children[this.index-1],e=this.top;for(;t instanceof er;)e=t,t=e.children[e.children.length-1];(!t||!(t instanceof or)||/\n$/.test(t.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(t.node.text))&&((xn||wn)&&t&&"false"==t.dom.contentEditable&&this.addHackNode("IMG",e),this.addHackNode("BR",this.top))}addHackNode(t,e){if(e==this.top&&this.index<e.children.length&&e.children[this.index].matchesHack(t))this.index++;else{let n=document.createElement(t);"IMG"==t&&(n.className="ProseMirror-separator",n.alt=""),"BR"==t&&(n.className="ProseMirror-trailingBreak");let r=new ir(this.top,[],n,null);e!=this.top?e.children.push(r):e.children.splice(this.index++,0,r),this.changed=!0}}isLocked(t){return this.lock&&(t==this.lock||1==t.nodeType&&t.contains(this.lock.parentNode))}}function yr(t,e){return t.type.side-e.type.side}function br(t,e,n,r,o){let i=[];for(let s=0,a=0;s<t.length;s++){let l=t[s],c=a,d=a+=l.size;c>=n||d<=e?i.push(l):(c<e&&i.push(l.slice(0,e-c,r)),o&&(i.push(o),o=void 0),d>n&&i.push(l.slice(n-c,l.size,r)))}return i}function vr(t,e=null){let n=t.domSelectionRange(),r=t.state.doc;if(!n.focusNode)return null;let o=t.docView.nearestDesc(n.focusNode),i=o&&0==o.size,s=t.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(s<0)return null;let a,l,c=r.resolve(s);if(ln(n)){for(a=c;o&&!o.node;)o=o.parent;let t=o.node;if(o&&t.isAtom&&Pe.isSelectable(t)&&o.parent&&(!t.isInline||!function(t,e,n){for(let r=0==e,o=e==sn(t);r||o;){if(t==n)return!0;let e=Xe(t);if(!(t=t.parentNode))return!1;r=r&&0==e,o=o&&e==sn(t)}}(n.focusNode,n.focusOffset,o.dom))){let t=o.posBefore;l=new Pe(s==t?c:r.resolve(t))}}else{let e=t.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(e<0)return null;a=r.resolve(e)}if(!l){l=Er(t,a,c,"pointer"==e||t.state.selection.head<c.pos&&!i?1:-1)}return l}function wr(t){return t.editable?t.hasFocus():Ar(t)&&document.activeElement&&document.activeElement.contains(t.dom)}function kr(t,e=!1){let n=t.state.selection;if(Mr(t,n),wr(t)){if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&wn){let e=t.domSelectionRange(),n=t.domObserver.currentSelection;if(e.anchorNode&&n.anchorNode&&nn(e.anchorNode,e.anchorOffset,n.anchorNode,n.anchorOffset))return t.input.mouseDown.delayedSelectionSync=!0,void t.domObserver.setCurSelection()}if(t.domObserver.disconnectSelection(),t.cursorWrapper)!function(t){let e=t.domSelection(),n=document.createRange();if(!e)return;let r=t.cursorWrapper.dom,o="IMG"==r.nodeName;o?n.setStart(r.parentNode,Xe(r)+1):n.setStart(r,0),n.collapse(!0),e.removeAllRanges(),e.addRange(n),!o&&!t.state.selection.visible&&gn&&yn<=11&&(r.disabled=!0,r.disabled=!1)}(t);else{let r,o,{anchor:i,head:s}=n;xr&&!(n instanceof Ie)&&(n.$from.parent.inlineContent||(r=Sr(t,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(o=Sr(t,n.to))),t.docView.setSelection(i,s,t.root,e),xr&&(r&&Cr(r),o&&Cr(o)),n.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&function(t){let e=t.dom.ownerDocument;e.removeEventListener("selectionchange",t.input.hideSelectionGuard);let n=t.domSelectionRange(),r=n.anchorNode,o=n.anchorOffset;e.addEventListener("selectionchange",t.input.hideSelectionGuard=()=>{(n.anchorNode!=r||n.anchorOffset!=o)&&(e.removeEventListener("selectionchange",t.input.hideSelectionGuard),setTimeout((()=>{(!wr(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")}),20))})}(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}}const xr=xn||wn&&kn<63;function Sr(t,e){let{node:n,offset:r}=t.docView.domFromPos(e,0),o=r<n.childNodes.length?n.childNodes[r]:null,i=r?n.childNodes[r-1]:null;if(xn&&o&&"false"==o.contentEditable)return Or(o);if(!(o&&"false"!=o.contentEditable||i&&"false"!=i.contentEditable)){if(o)return Or(o);if(i)return Or(i)}}function Or(t){return t.contentEditable="true",xn&&t.draggable&&(t.draggable=!1,t.wasDraggable=!0),t}function Cr(t){t.contentEditable="false",t.wasDraggable&&(t.draggable=!0,t.wasDraggable=null)}function Mr(t,e){if(e instanceof Pe){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(Tr(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else Tr(t)}function Tr(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function Er(t,e,n,r){return t.someProp("createSelectionBetween",(r=>r(t,e,n)))||Ie.between(e,n,r)}function Nr(t){return!(t.editable&&!t.hasFocus())&&Ar(t)}function Ar(t){let e=t.domSelectionRange();if(!e.anchorNode)return!1;try{return t.dom.contains(3==e.anchorNode.nodeType?e.anchorNode.parentNode:e.anchorNode)&&(t.editable||t.dom.contains(3==e.focusNode.nodeType?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function Dr(t,e){let{$anchor:n,$head:r}=t.selection,o=e>0?n.max(r):n.min(r),i=o.parent.inlineContent?o.depth?t.doc.resolve(e>0?o.after():o.before()):null:o;return i&&Ne.findFrom(i,e)}function Rr(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function Ir(t,e,n){let r=t.state.selection;if(!(r instanceof Ie)){if(r instanceof Pe&&r.node.isInline)return Rr(t,new Ie(e>0?r.$to:r.$from));{let n=Dr(t.state,e);return!!n&&Rr(t,n)}}if(n.indexOf("s")>-1){let{$head:n}=r,o=n.textOffset?null:e<0?n.nodeBefore:n.nodeAfter;if(!o||o.isText||!o.isLeaf)return!1;let i=t.state.doc.resolve(n.pos+o.nodeSize*(e<0?-1:1));return Rr(t,new Ie(r.$anchor,i))}if(!r.empty)return!1;if(t.endOfTextblock(e>0?"forward":"backward")){let n=Dr(t.state,e);return!!(n&&n instanceof Pe)&&Rr(t,n)}if(!(On&&n.indexOf("m")>-1)){let n,o=r.$head,i=o.textOffset?null:e<0?o.nodeBefore:o.nodeAfter;if(!i||i.isText)return!1;let s=e<0?o.pos-i.nodeSize:o.pos;return!!(i.isAtom||(n=t.docView.descAt(s))&&!n.contentDOM)&&(Pe.isSelectable(i)?Rr(t,new Pe(e<0?t.state.doc.resolve(o.pos-i.nodeSize):o)):!!Tn&&Rr(t,new Ie(t.state.doc.resolve(e<0?s:s+i.nodeSize))))}}function Lr(t){return 3==t.nodeType?t.nodeValue.length:t.childNodes.length}function Pr(t,e){let n=t.pmViewDesc;return n&&0==n.size&&(e<0||t.nextSibling||"BR"!=t.nodeName)}function jr(t,e){return e<0?function(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let o,i,s=!1;for(bn&&1==n.nodeType&&r<Lr(n)&&Pr(n.childNodes[r],-1)&&(s=!0);;)if(r>0){if(1!=n.nodeType)break;{let t=n.childNodes[r-1];if(Pr(t,-1))o=n,i=--r;else{if(3!=t.nodeType)break;n=t,r=n.nodeValue.length}}}else{if(zr(n))break;{let e=n.previousSibling;for(;e&&Pr(e,-1);)o=n.parentNode,i=Xe(e),e=e.previousSibling;if(e)n=e,r=Lr(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}s?$r(t,n,r):o&&$r(t,o,i)}(t):function(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let o,i,s=Lr(n);for(;;)if(r<s){if(1!=n.nodeType)break;if(!Pr(n.childNodes[r],1))break;o=n,i=++r}else{if(zr(n))break;{let e=n.nextSibling;for(;e&&Pr(e,1);)o=e.parentNode,i=Xe(e)+1,e=e.nextSibling;if(e)n=e,r=0,s=Lr(n);else{if(n=n.parentNode,n==t.dom)break;r=s=0}}}o&&$r(t,o,i)}(t)}function zr(t){let e=t.pmViewDesc;return e&&e.node&&e.node.isBlock}function $r(t,e,n){if(3!=e.nodeType){let t,r;(r=function(t,e){for(;t&&e==t.childNodes.length&&!an(t);)e=Xe(t)+1,t=t.parentNode;for(;t&&e<t.childNodes.length;){let n=t.childNodes[e];if(3==n.nodeType)return n;if(1==n.nodeType&&"false"==n.contentEditable)break;t=n,e=0}}(e,n))?(e=r,n=0):(t=function(t,e){for(;t&&!e&&!an(t);)e=Xe(t),t=t.parentNode;for(;t&&e;){let n=t.childNodes[e-1];if(3==n.nodeType)return n;if(1==n.nodeType&&"false"==n.contentEditable)break;e=(t=n).childNodes.length}}(e,n))&&(e=t,n=t.nodeValue.length)}let r=t.domSelection();if(!r)return;if(ln(r)){let t=document.createRange();t.setEnd(e,n),t.setStart(e,n),r.removeAllRanges(),r.addRange(t)}else r.extend&&r.extend(e,n);t.domObserver.setCurSelection();let{state:o}=t;setTimeout((()=>{t.state==o&&kr(t)}),50)}function Br(t,e){let n=t.state.doc.resolve(e);if(!wn&&!Cn&&n.parent.inlineContent){let r=t.coordsAtPos(e);if(e>n.start()){let n=t.coordsAtPos(e-1),o=(n.top+n.bottom)/2;if(o>r.top&&o<r.bottom&&Math.abs(n.left-r.left)>1)return n.left<r.left?"ltr":"rtl"}if(e<n.end()){let n=t.coordsAtPos(e+1),o=(n.top+n.bottom)/2;if(o>r.top&&o<r.bottom&&Math.abs(n.left-r.left)>1)return n.left>r.left?"ltr":"rtl"}}return"rtl"==getComputedStyle(t.dom).direction?"rtl":"ltr"}function Fr(t,e,n){let r=t.state.selection;if(r instanceof Ie&&!r.empty||n.indexOf("s")>-1||On&&n.indexOf("m")>-1)return!1;let{$from:o,$to:i}=r;if(!o.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let n=Dr(t.state,e);if(n&&n instanceof Pe)return Rr(t,n)}if(!o.parent.inlineContent){let n=e<0?o:i,s=r instanceof ze?Ne.near(n,e):Ne.findFrom(n,e);return!!s&&Rr(t,s)}return!1}function _r(t,e){if(!(t.state.selection instanceof Ie))return!0;let{$head:n,$anchor:r,empty:o}=t.state.selection;if(!n.sameParent(r))return!0;if(!o)return!1;if(t.endOfTextblock(e>0?"forward":"backward"))return!0;let i=!n.textOffset&&(e<0?n.nodeBefore:n.nodeAfter);if(i&&!i.isText){let r=t.state.tr;return e<0?r.delete(n.pos-i.nodeSize,n.pos):r.delete(n.pos,n.pos+i.nodeSize),t.dispatch(r),!0}return!1}function Vr(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function Hr(t,e){let n=e.keyCode,r=function(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}(e);if(8==n||On&&72==n&&"c"==r)return _r(t,-1)||jr(t,-1);if(46==n&&!e.shiftKey||On&&68==n&&"c"==r)return _r(t,1)||jr(t,1);if(13==n||27==n)return!0;if(37==n||On&&66==n&&"c"==r){let e=37==n?"ltr"==Br(t,t.state.selection.from)?-1:1:-1;return Ir(t,e,r)||jr(t,e)}if(39==n||On&&70==n&&"c"==r){let e=39==n?"ltr"==Br(t,t.state.selection.from)?1:-1:1;return Ir(t,e,r)||jr(t,e)}return 38==n||On&&80==n&&"c"==r?Fr(t,-1,r)||jr(t,-1):40==n||On&&78==n&&"c"==r?function(t){if(!xn||t.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(e&&1==e.nodeType&&0==n&&e.firstChild&&"false"==e.firstChild.contentEditable){let n=e.firstChild;Vr(t,n,"true"),setTimeout((()=>Vr(t,n,"false")),20)}return!1}(t)||Fr(t,1,r)||jr(t,1):r==(On?"m":"c")&&(66==n||73==n||89==n||90==n)}function Wr(t,e){t.someProp("transformCopied",(n=>{e=n(e,t)}));let n=[],{content:r,openStart:o,openEnd:i}=e;for(;o>1&&i>1&&1==r.childCount&&1==r.firstChild.childCount;){o--,i--;let t=r.firstChild;n.push(t.type.name,t.attrs!=t.type.defaultAttrs?t.attrs:null),r=t.content}let s=t.someProp("clipboardSerializer")||Pt.fromSchema(t.state.schema),a=to(),l=a.createElement("div");l.appendChild(s.serializeFragment(r,{document:a}));let c,d=l.firstChild,h=0;for(;d&&1==d.nodeType&&(c=Xr[d.nodeName.toLowerCase()]);){for(let t=c.length-1;t>=0;t--){let e=a.createElement(c[t]);for(;l.firstChild;)e.appendChild(l.firstChild);l.appendChild(e),h++}d=l.firstChild}return d&&1==d.nodeType&&d.setAttribute("data-pm-slice",`${o} ${i}${h?` -${h}`:""} ${JSON.stringify(n)}`),{dom:l,text:t.someProp("clipboardTextSerializer",(n=>n(e,t)))||e.content.textBetween(0,e.content.size,"\n\n"),slice:e}}function Kr(t,e,n,r,o){let i,s,a=o.parent.type.spec.code;if(!n&&!e)return null;let l=e&&(r||a||!n);if(l){if(t.someProp("transformPastedText",(n=>{e=n(e,a||r,t)})),a)return e?new F(L.from(t.state.schema.text(e.replace(/\r\n?/g,"\n"))),0,0):F.empty;let n=t.someProp("clipboardTextParser",(n=>n(e,o,r,t)));if(n)s=n;else{let n=o.marks(),{schema:r}=t.state,s=Pt.fromSchema(r);i=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach((t=>{let e=i.appendChild(document.createElement("p"));t&&e.appendChild(s.serializeNode(r.text(t,n)))}))}}else t.someProp("transformPastedHTML",(e=>{n=e(n,t)})),i=function(t){let e=/^(\s*<meta [^>]*>)*/.exec(t);e&&(t=t.slice(e[0].length));let n,r=to().createElement("div"),o=/<([a-z][^>\s]+)/i.exec(t);if((n=o&&Xr[o[1].toLowerCase()])&&(t=n.map((t=>"<"+t+">")).join("")+t+n.map((t=>"</"+t+">")).reverse().join("")),r.innerHTML=t,n)for(let t=0;t<n.length;t++)r=r.querySelector(n[t])||r;return r}(n),Tn&&function(t){let e=t.querySelectorAll(wn?"span:not([class]):not([style])":"span.Apple-converted-space");for(let n=0;n<e.length;n++){let r=e[n];1==r.childNodes.length&&" "==r.textContent&&r.parentNode&&r.parentNode.replaceChild(t.ownerDocument.createTextNode(" "),r)}}(i);let c=i&&i.querySelector("[data-pm-slice]"),d=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(d&&d[3])for(let t=+d[3];t>0;t--){let t=i.firstChild;for(;t&&1!=t.nodeType;)t=t.nextSibling;if(!t)break;i=t}if(s||(s=(t.someProp("clipboardParser")||t.someProp("domParser")||Ct.fromSchema(t.state.schema)).parseSlice(i,{preserveWhitespace:!(!l&&!d),context:o,ruleFromNode:t=>"BR"!=t.nodeName||t.nextSibling||!t.parentNode||qr.test(t.parentNode.nodeName)?null:{ignore:!0}})),d)s=function(t,e){if(!t.size)return t;let n,r=t.content.firstChild.type.schema;try{n=JSON.parse(e)}catch{return t}let{content:o,openStart:i,openEnd:s}=t;for(let t=n.length-2;t>=0;t-=2){let e=r.nodes[n[t]];if(!e||e.hasRequiredAttrs())break;o=L.from(e.create(n[t+1],o)),i++,s++}return new F(o,i,s)}(Qr(s,+d[1],+d[2]),d[4]);else if(s=F.maxOpen(function(t,e){if(t.childCount<2)return t;for(let n=e.depth;n>=0;n--){let r,o=e.node(n).contentMatchAt(e.index(n)),i=[];if(t.forEach((t=>{if(!i)return;let e,n=o.findWrapping(t.type);if(!n)return i=null;if(e=i.length&&r.length&&Ur(n,r,t,i[i.length-1],0))i[i.length-1]=e;else{i.length&&(i[i.length-1]=Gr(i[i.length-1],r.length));let e=Jr(t,n);i.push(e),o=o.matchType(e.type),r=n}})),i)return L.from(i)}return t}(s.content,o),!0),s.openStart||s.openEnd){let t=0,e=0;for(let e=s.content.firstChild;t<s.openStart&&!e.type.spec.isolating;t++,e=e.firstChild);for(let t=s.content.lastChild;e<s.openEnd&&!t.type.spec.isolating;e++,t=t.lastChild);s=Qr(s,t,e)}return t.someProp("transformPasted",(e=>{s=e(s,t)})),s}const qr=/^(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 Jr(t,e,n=0){for(let r=e.length-1;r>=n;r--)t=e[r].create(null,L.from(t));return t}function Ur(t,e,n,r,o){if(o<t.length&&o<e.length&&t[o]==e[o]){let i=Ur(t,e,n,r.lastChild,o+1);if(i)return r.copy(r.content.replaceChild(r.childCount-1,i));if(r.contentMatchAt(r.childCount).matchType(o==t.length-1?n.type:t[o+1]))return r.copy(r.content.append(L.from(Jr(n,t,o+1))))}}function Gr(t,e){if(0==e)return t;let n=t.content.replaceChild(t.childCount-1,Gr(t.lastChild,e-1)),r=t.contentMatchAt(t.childCount).fillBefore(L.empty,!0);return t.copy(n.append(r))}function Yr(t,e,n,r,o,i){let s=e<0?t.firstChild:t.lastChild,a=s.content;return t.childCount>1&&(i=0),o<r-1&&(a=Yr(a,e,n,r,o+1,i)),o>=n&&(a=e<0?s.contentMatchAt(0).fillBefore(a,i<=o).append(a):a.append(s.contentMatchAt(s.childCount).fillBefore(L.empty,!0))),t.replaceChild(e<0?0:t.childCount-1,s.copy(a))}function Qr(t,e,n){return e<t.openStart&&(t=new F(Yr(t.content,-1,e,t.openStart,0,t.openEnd),e,t.openEnd)),n<t.openEnd&&(t=new F(Yr(t.content,1,n,t.openEnd,0,0),t.openStart,n)),t}const Xr={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 Zr=null;function to(){return Zr||(Zr=document.implementation.createHTMLDocument("title"))}const eo={},no={},ro={touchstart:!0,touchmove:!0};class oo{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:""},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastAndroidDelete=0,this.composing=!1,this.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 io(t,e){t.input.lastSelectionOrigin=e,t.input.lastSelectionTime=Date.now()}function so(t){t.someProp("handleDOMEvents",(e=>{for(let n in e)t.input.eventHandlers[n]||t.dom.addEventListener(n,t.input.eventHandlers[n]=e=>ao(t,e))}))}function ao(t,e){return t.someProp("handleDOMEvents",(n=>{let r=n[e.type];return!!r&&(r(t,e)||e.defaultPrevented)}))}function lo(t,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let n=e.target;n!=t.dom;n=n.parentNode)if(!n||11==n.nodeType||n.pmViewDesc&&n.pmViewDesc.stopEvent(e))return!1;return!0}function co(t){return{left:t.clientX,top:t.clientY}}function ho(t,e,n,r,o){if(-1==r)return!1;let i=t.state.doc.resolve(r);for(let r=i.depth+1;r>0;r--)if(t.someProp(e,(e=>r>i.depth?e(t,n,i.nodeAfter,i.before(r),o,!0):e(t,n,i.node(r),i.before(r),o,!1))))return!0;return!1}function uo(t,e,n){if(t.focused||t.focus(),t.state.selection.eq(e))return;let r=t.state.tr.setSelection(e);"pointer"==n&&r.setMeta("pointer",!0),t.dispatch(r)}function po(t,e,n,r,o){return ho(t,"handleClickOn",e,n,r)||t.someProp("handleClick",(n=>n(t,e,r)))||(o?function(t,e){if(-1==e)return!1;let n,r,o=t.state.selection;o instanceof Pe&&(n=o.node);let i=t.state.doc.resolve(e);for(let t=i.depth+1;t>0;t--){let e=t>i.depth?i.nodeAfter:i.node(t);if(Pe.isSelectable(e)){r=n&&o.$from.depth>0&&t>=o.$from.depth&&i.before(o.$from.depth+1)==o.$from.pos?i.before(o.$from.depth):i.before(t);break}}return null!=r&&(uo(t,Pe.create(t.state.doc,r),"pointer"),!0)}(t,n):function(t,e){if(-1==e)return!1;let n=t.state.doc.resolve(e),r=n.nodeAfter;return!!(r&&r.isAtom&&Pe.isSelectable(r))&&(uo(t,new Pe(n),"pointer"),!0)}(t,n))}function fo(t,e,n,r){return ho(t,"handleDoubleClickOn",e,n,r)||t.someProp("handleDoubleClick",(n=>n(t,e,r)))}function mo(t,e,n,r){return ho(t,"handleTripleClickOn",e,n,r)||t.someProp("handleTripleClick",(n=>n(t,e,r)))||function(t,e,n){if(0!=n.button)return!1;let r=t.state.doc;if(-1==e)return!!r.inlineContent&&(uo(t,Ie.create(r,0,r.content.size),"pointer"),!0);let o=r.resolve(e);for(let e=o.depth+1;e>0;e--){let n=e>o.depth?o.nodeAfter:o.node(e),i=o.before(e);if(n.inlineContent)uo(t,Ie.create(r,i+1,i+1+n.content.size),"pointer");else{if(!Pe.isSelectable(n))continue;uo(t,Pe.create(r,i),"pointer")}return!0}}(t,n,r)}function go(t){return Oo(t)}no.keydown=(t,e)=>{let n=e;if(t.input.shiftKey=16==n.keyCode||n.shiftKey,!vo(t,n)&&(t.input.lastKeyCode=n.keyCode,t.input.lastKeyCodeTime=Date.now(),!Mn||!wn||13!=n.keyCode))if(229!=n.keyCode&&t.domObserver.forceFlush(),!Sn||13!=n.keyCode||n.ctrlKey||n.altKey||n.metaKey)t.someProp("handleKeyDown",(e=>e(t,n)))||Hr(t,n)?n.preventDefault():io(t,"key");else{let e=Date.now();t.input.lastIOSEnter=e,t.input.lastIOSEnterFallbackTimeout=setTimeout((()=>{t.input.lastIOSEnter==e&&(t.someProp("handleKeyDown",(e=>e(t,cn(13,"Enter")))),t.input.lastIOSEnter=0)}),200)}},no.keyup=(t,e)=>{16==e.keyCode&&(t.input.shiftKey=!1)},no.keypress=(t,e)=>{let n=e;if(vo(t,n)||!n.charCode||n.ctrlKey&&!n.altKey||On&&n.metaKey)return;if(t.someProp("handleKeyPress",(e=>e(t,n))))return void n.preventDefault();let r=t.state.selection;if(!(r instanceof Ie&&r.$from.sameParent(r.$to))){let e=String.fromCharCode(n.charCode);!/[\r\n]/.test(e)&&!t.someProp("handleTextInput",(n=>n(t,r.$from.pos,r.$to.pos,e)))&&t.dispatch(t.state.tr.insertText(e).scrollIntoView()),n.preventDefault()}};const yo=On?"metaKey":"ctrlKey";eo.mousedown=(t,e)=>{let n=e;t.input.shiftKey=n.shiftKey;let r=go(t),o=Date.now(),i="singleClick";o-t.input.lastClick.time<500&&function(t,e){let n=e.x-t.clientX,r=e.y-t.clientY;return n*n+r*r<100}(n,t.input.lastClick)&&!n[yo]&&("singleClick"==t.input.lastClick.type?i="doubleClick":"doubleClick"==t.input.lastClick.type&&(i="tripleClick")),t.input.lastClick={time:o,x:n.clientX,y:n.clientY,type:i};let s=t.posAtCoords(co(n));s&&("singleClick"==i?(t.input.mouseDown&&t.input.mouseDown.done(),t.input.mouseDown=new bo(t,s,n,!!r)):("doubleClick"==i?fo:mo)(t,s.pos,s.inside,n)?n.preventDefault():io(t,"pointer"))};class bo{constructor(t,e,n,r){let o,i;if(this.view=t,this.pos=e,this.event=n,this.flushed=r,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=t.state.doc,this.selectNode=!!n[yo],this.allowDefault=n.shiftKey,e.inside>-1)o=t.state.doc.nodeAt(e.inside),i=e.inside;else{let n=t.state.doc.resolve(e.pos);o=n.parent,i=n.depth?n.before():0}const s=r?null:n.target,a=s?t.docView.nearestDesc(s,!0):null;this.target=a&&1==a.dom.nodeType?a.dom:null;let{selection:l}=t.state;(0==n.button&&o.type.spec.draggable&&!1!==o.type.spec.selectable||l instanceof Pe&&l.from<=i&&l.to>i)&&(this.mightDrag={node:o,pos:i,addAttr:!(!this.target||this.target.draggable),setUneditable:!(!this.target||!bn||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()),t.root.addEventListener("mouseup",this.up=this.up.bind(this)),t.root.addEventListener("mousemove",this.move=this.move.bind(this)),io(t,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout((()=>kr(this.view))),this.view.input.mouseDown=null}up(t){if(this.done(),!this.view.dom.contains(t.target))return;let e=this.pos;this.view.state.doc!=this.startDoc&&(e=this.view.posAtCoords(co(t))),this.updateAllowDefault(t),this.allowDefault||!e?io(this.view,"pointer"):po(this.view,e.pos,e.inside,t,this.selectNode)?t.preventDefault():0==t.button&&(this.flushed||xn&&this.mightDrag&&!this.mightDrag.node.isAtom||wn&&!this.view.state.selection.visible&&Math.min(Math.abs(e.pos-this.view.state.selection.from),Math.abs(e.pos-this.view.state.selection.to))<=2)?(uo(this.view,Ne.near(this.view.state.doc.resolve(e.pos)),"pointer"),t.preventDefault()):io(this.view,"pointer")}move(t){this.updateAllowDefault(t),io(this.view,"pointer"),0==t.buttons&&this.done()}updateAllowDefault(t){!this.allowDefault&&(Math.abs(this.event.x-t.clientX)>4||Math.abs(this.event.y-t.clientY)>4)&&(this.allowDefault=!0)}}function vo(t,e){return!!t.composing||!!(xn&&Math.abs(e.timeStamp-t.input.compositionEndedAt)<500)&&(t.input.compositionEndedAt=-2e8,!0)}eo.touchstart=t=>{t.input.lastTouch=Date.now(),go(t),io(t,"pointer")},eo.touchmove=t=>{t.input.lastTouch=Date.now(),io(t,"pointer")},eo.contextmenu=t=>go(t);const wo=Mn?5e3:-1;function ko(t,e){clearTimeout(t.input.composingTimeout),e>-1&&(t.input.composingTimeout=setTimeout((()=>Oo(t)),e))}function xo(t){for(t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=function(){let t=document.createEvent("Event");return t.initEvent("event",!0,!0),t.timeStamp}());t.input.compositionNodes.length>0;)t.input.compositionNodes.pop().markParentsDirty()}function So(t){let e=t.domSelectionRange();if(!e.focusNode)return null;let n=function(t,e){for(;;){if(3==t.nodeType&&e)return t;if(1==t.nodeType&&e>0){if("false"==t.contentEditable)return null;e=sn(t=t.childNodes[e-1])}else{if(!t.parentNode||an(t))return null;e=Xe(t),t=t.parentNode}}}(e.focusNode,e.focusOffset),r=function(t,e){for(;;){if(3==t.nodeType&&e<t.nodeValue.length)return t;if(1==t.nodeType&&e<t.childNodes.length){if("false"==t.contentEditable)return null;t=t.childNodes[e],e=0}else{if(!t.parentNode||an(t))return null;e=Xe(t)+1,t=t.parentNode}}}(e.focusNode,e.focusOffset);if(n&&r&&n!=r){let e=r.pmViewDesc,o=t.domObserver.lastChangedTextNode;if(n==o||r==o)return o;if(!e||!e.isText(r.nodeValue))return r;if(t.input.compositionNode==r){let t=n.pmViewDesc;if(t&&t.isText(n.nodeValue))return r}}return n||r}function Oo(t,e=!1){if(!(Mn&&t.domObserver.flushingSoon>=0)){if(t.domObserver.forceFlush(),xo(t),e||t.docView&&t.docView.dirty){let n=vr(t);return n&&!n.eq(t.state.selection)?t.dispatch(t.state.tr.setSelection(n)):!t.markCursor&&!e||t.state.selection.empty?t.updateState(t.state):t.dispatch(t.state.tr.deleteSelection()),!0}return!1}}no.compositionstart=no.compositionupdate=t=>{if(!t.composing){t.domObserver.flush();let{state:e}=t,n=e.selection.$to;if(e.selection instanceof Ie&&(e.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some((t=>!1===t.type.spec.inclusive))))t.markCursor=t.state.storedMarks||n.marks(),Oo(t,!0),t.markCursor=null;else if(Oo(t,!e.selection.empty),bn&&e.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let e=t.domSelectionRange();for(let n=e.focusNode,r=e.focusOffset;n&&1==n.nodeType&&0!=r;){let e=r<0?n.lastChild:n.childNodes[r-1];if(!e)break;if(3==e.nodeType){let n=t.domSelection();n&&n.collapse(e,e.nodeValue.length);break}n=e,r=-1}}t.input.composing=!0}ko(t,wo)},no.compositionend=(t,e)=>{t.composing&&(t.input.composing=!1,t.input.compositionEndedAt=e.timeStamp,t.input.compositionPendingChanges=t.domObserver.pendingRecords().length?t.input.compositionID:0,t.input.compositionNode=null,t.input.compositionPendingChanges&&Promise.resolve().then((()=>t.domObserver.flush())),t.input.compositionID++,ko(t,20))};const Co=gn&&yn<15||Sn&&En<604;function Mo(t,e,n,r,o){let i=Kr(t,e,n,r,t.state.selection.$from);if(t.someProp("handlePaste",(e=>e(t,o,i||F.empty))))return!0;if(!i)return!1;let s=function(t){return 0==t.openStart&&0==t.openEnd&&1==t.content.childCount?t.content.firstChild:null}(i),a=s?t.state.tr.replaceSelectionWith(s,r):t.state.tr.replaceSelection(i);return t.dispatch(a.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function To(t){let e=t.getData("text/plain")||t.getData("Text");if(e)return e;let n=t.getData("text/uri-list");return n?n.replace(/\r?\n/g," "):""}eo.copy=no.cut=(t,e)=>{let n=e,r=t.state.selection,o="cut"==n.type;if(r.empty)return;let i=Co?null:n.clipboardData,s=r.content(),{dom:a,text:l}=Wr(t,s);i?(n.preventDefault(),i.clearData(),i.setData("text/html",a.innerHTML),i.setData("text/plain",l)):function(t,e){if(!t.dom.parentNode)return;let n=t.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(e),n.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),o=document.createRange();o.selectNodeContents(e),t.dom.blur(),r.removeAllRanges(),r.addRange(o),setTimeout((()=>{n.parentNode&&n.parentNode.removeChild(n),t.focus()}),50)}(t,a),o&&t.dispatch(t.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))},no.paste=(t,e)=>{let n=e;if(t.composing&&!Mn)return;let r=Co?null:n.clipboardData,o=t.input.shiftKey&&45!=t.input.lastKeyCode;r&&Mo(t,To(r),r.getData("text/html"),o,n)?n.preventDefault():function(t,e){if(!t.dom.parentNode)return;let n=t.input.shiftKey||t.state.selection.$from.parent.type.spec.code,r=t.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let o=t.input.shiftKey&&45!=t.input.lastKeyCode;setTimeout((()=>{t.focus(),r.parentNode&&r.parentNode.removeChild(r),n?Mo(t,r.value,null,o,e):Mo(t,r.textContent,r.innerHTML,o,e)}),50)}(t,n)};class Eo{constructor(t,e,n){this.slice=t,this.move=e,this.node=n}}const No=On?"altKey":"ctrlKey";eo.dragstart=(t,e)=>{let n=e,r=t.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let o,i=t.state.selection,s=i.empty?null:t.posAtCoords(co(n));if(!(s&&s.pos>=i.from&&s.pos<=(i instanceof Pe?i.to-1:i.to)))if(r&&r.mightDrag)o=Pe.create(t.state.doc,r.mightDrag.pos);else if(n.target&&1==n.target.nodeType){let e=t.docView.nearestDesc(n.target,!0);e&&e.node.type.spec.draggable&&e!=t.docView&&(o=Pe.create(t.state.doc,e.posBefore))}let a=(o||t.state.selection).content(),{dom:l,text:c,slice:d}=Wr(t,a);(!n.dataTransfer.files.length||!wn||kn>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(Co?"Text":"text/html",l.innerHTML),n.dataTransfer.effectAllowed="copyMove",Co||n.dataTransfer.setData("text/plain",c),t.dragging=new Eo(d,!n[No],o)},eo.dragend=t=>{let e=t.dragging;window.setTimeout((()=>{t.dragging==e&&(t.dragging=null)}),50)},no.dragover=no.dragenter=(t,e)=>e.preventDefault(),no.drop=(t,e)=>{let n=e,r=t.dragging;if(t.dragging=null,!n.dataTransfer)return;let o=t.posAtCoords(co(n));if(!o)return;let i=t.state.doc.resolve(o.pos),s=r&&r.slice;s?t.someProp("transformPasted",(e=>{s=e(s,t)})):s=Kr(t,To(n.dataTransfer),Co?null:n.dataTransfer.getData("text/html"),!1,i);let a=!(!r||n[No]);if(t.someProp("handleDrop",(e=>e(t,n,s||F.empty,a))))return void n.preventDefault();if(!s)return;n.preventDefault();let l=s?function(t,e,n){let r=t.resolve(e);if(!n.content.size)return e;let o=n.content;for(let t=0;t<n.openStart;t++)o=o.firstChild.content;for(let t=1;t<=(0==n.openStart&&n.size?2:1);t++)for(let e=r.depth;e>=0;e--){let n=e==r.depth?0:r.pos<=(r.start(e+1)+r.end(e+1))/2?-1:1,i=r.index(e)+(n>0?1:0),s=r.node(e),a=!1;if(1==t)a=s.canReplace(i,i,o);else{let t=s.contentMatchAt(i).findWrapping(o.firstChild.type);a=t&&s.canReplaceWith(i,i,t[0])}if(a)return 0==n?r.pos:n<0?r.before(e+1):r.after(e+1)}return null}(t.state.doc,i.pos,s):i.pos;null==l&&(l=i.pos);let c=t.state.tr;if(a){let{node:t}=r;t?t.replace(c):c.deleteSelection()}let d=c.mapping.map(l),h=0==s.openStart&&0==s.openEnd&&1==s.content.childCount,u=c.doc;if(h?c.replaceRangeWith(d,d,s.content.firstChild):c.replaceRange(d,d,s),c.doc.eq(u))return;let p=c.doc.resolve(d);if(h&&Pe.isSelectable(s.content.firstChild)&&p.nodeAfter&&p.nodeAfter.sameMarkup(s.content.firstChild))c.setSelection(new Pe(p));else{let e=c.mapping.map(l);c.mapping.maps[c.mapping.maps.length-1].forEach(((t,n,r,o)=>e=o)),c.setSelection(Er(t,p,c.doc.resolve(e)))}t.focus(),t.dispatch(c.setMeta("uiEvent","drop"))},eo.focus=t=>{t.input.lastFocus=Date.now(),t.focused||(t.domObserver.stop(),t.dom.classList.add("ProseMirror-focused"),t.domObserver.start(),t.focused=!0,setTimeout((()=>{t.docView&&t.hasFocus()&&!t.domObserver.currentSelection.eq(t.domSelectionRange())&&kr(t)}),20))},eo.blur=(t,e)=>{let n=e;t.focused&&(t.domObserver.stop(),t.dom.classList.remove("ProseMirror-focused"),t.domObserver.start(),n.relatedTarget&&t.dom.contains(n.relatedTarget)&&t.domObserver.currentSelection.clear(),t.focused=!1)},eo.beforeinput=(t,e)=>{if(wn&&Mn&&"deleteContentBackward"==e.inputType){t.domObserver.flushSoon();let{domChangeCount:e}=t.input;setTimeout((()=>{if(t.input.domChangeCount!=e||(t.dom.blur(),t.focus(),t.someProp("handleKeyDown",(e=>e(t,cn(8,"Backspace"))))))return;let{$cursor:n}=t.state.selection;n&&n.pos>0&&t.dispatch(t.state.tr.delete(n.pos-1,n.pos).scrollIntoView())}),50)}};for(let t in no)eo[t]=no[t];function Ao(t,e){if(t==e)return!0;for(let n in t)if(t[n]!==e[n])return!1;for(let n in e)if(!(n in t))return!1;return!0}class Do{constructor(t,e){this.toDOM=t,this.spec=e||jo,this.side=this.spec.side||0}map(t,e,n,r){let{pos:o,deleted:i}=t.mapResult(e.from+r,this.side<0?-1:1);return i?null:new Lo(o-n,o-n,this)}valid(){return!0}eq(t){return this==t||t instanceof Do&&(this.spec.key&&this.spec.key==t.spec.key||this.toDOM==t.toDOM&&Ao(this.spec,t.spec))}destroy(t){this.spec.destroy&&this.spec.destroy(t)}}class Ro{constructor(t,e){this.attrs=t,this.spec=e||jo}map(t,e,n,r){let o=t.map(e.from+r,this.spec.inclusiveStart?-1:1)-n,i=t.map(e.to+r,this.spec.inclusiveEnd?1:-1)-n;return o>=i?null:new Lo(o,i,this)}valid(t,e){return e.from<e.to}eq(t){return this==t||t instanceof Ro&&Ao(this.attrs,t.attrs)&&Ao(this.spec,t.spec)}static is(t){return t.type instanceof Ro}destroy(){}}class Io{constructor(t,e){this.attrs=t,this.spec=e||jo}map(t,e,n,r){let o=t.mapResult(e.from+r,1);if(o.deleted)return null;let i=t.mapResult(e.to+r,-1);return i.deleted||i.pos<=o.pos?null:new Lo(o.pos-n,i.pos-n,this)}valid(t,e){let n,{index:r,offset:o}=t.content.findIndex(e.from);return o==e.from&&!(n=t.child(r)).isText&&o+n.nodeSize==e.to}eq(t){return this==t||t instanceof Io&&Ao(this.attrs,t.attrs)&&Ao(this.spec,t.spec)}destroy(){}}class Lo{constructor(t,e,n){this.from=t,this.to=e,this.type=n}copy(t,e){return new Lo(t,e,this.type)}eq(t,e=0){return this.type.eq(t.type)&&this.from+e==t.from&&this.to+e==t.to}map(t,e,n){return this.type.map(t,this,e,n)}static widget(t,e,n){return new Lo(t,t,new Do(e,n))}static inline(t,e,n,r){return new Lo(t,e,new Ro(n,r))}static node(t,e,n,r){return new Lo(t,e,new Io(n,r))}get spec(){return this.type.spec}get inline(){return this.type instanceof Ro}get widget(){return this.type instanceof Do}}const Po=[],jo={};class zo{constructor(t,e){this.local=t.length?t:Po,this.children=e.length?e:Po}static create(t,e){return e.length?Ho(e,t,0,jo):$o}find(t,e,n){let r=[];return this.findInner(t??0,e??1e9,r,0,n),r}findInner(t,e,n,r,o){for(let i=0;i<this.local.length;i++){let s=this.local[i];s.from<=e&&s.to>=t&&(!o||o(s.spec))&&n.push(s.copy(s.from+r,s.to+r))}for(let i=0;i<this.children.length;i+=3)if(this.children[i]<e&&this.children[i+1]>t){let s=this.children[i]+1;this.children[i+2].findInner(t-s,e-s,n,r+s,o)}}map(t,e,n){return this==$o||0==t.maps.length?this:this.mapInner(t,e,0,0,n||jo)}mapInner(t,e,n,r,o){let i;for(let s=0;s<this.local.length;s++){let a=this.local[s].map(t,n,r);a&&a.type.valid(e,a)?(i||(i=[])).push(a):o.onRemove&&o.onRemove(this.local[s].spec)}return this.children.length?function(t,e,n,r,o,i,s){let a=t.slice();for(let t=0,e=i;t<n.maps.length;t++){let r=0;n.maps[t].forEach(((t,n,o,i)=>{let s=i-o-(n-t);for(let o=0;o<a.length;o+=3){let i=a[o+1];if(i<0||t>i+e-r)continue;let l=a[o]+e-r;n>=l?a[o+1]=t<=l?-2:-1:t>=e&&s&&(a[o]+=s,a[o+1]+=s)}r+=s})),e=n.maps[t].map(e,-1)}let l=!1;for(let e=0;e<a.length;e+=3)if(a[e+1]<0){if(-2==a[e+1]){l=!0,a[e+1]=-1;continue}let c=n.map(t[e]+i),d=c-o;if(d<0||d>=r.content.size){l=!0;continue}let h=n.map(t[e+1]+i,-1)-o,{index:u,offset:p}=r.content.findIndex(d),f=r.maybeChild(u);if(f&&p==d&&p+f.nodeSize==h){let r=a[e+2].mapInner(n,f,c+1,t[e]+i+1,s);r!=$o?(a[e]=d,a[e+1]=h,a[e+2]=r):(a[e+1]=-2,l=!0)}else l=!0}if(l){let l=function(t,e,n,r,o,i,s){function a(t,e){for(let i=0;i<t.local.length;i++){let a=t.local[i].map(r,o,e);a?n.push(a):s.onRemove&&s.onRemove(t.local[i].spec)}for(let n=0;n<t.children.length;n+=3)a(t.children[n+2],t.children[n]+e+1)}for(let n=0;n<t.length;n+=3)-1==t[n+1]&&a(t[n+2],e[n]+i+1);return n}(a,t,e,n,o,i,s),c=Ho(l,r,0,s);e=c.local;for(let t=0;t<a.length;t+=3)a[t+1]<0&&(a.splice(t,3),t-=3);for(let t=0,e=0;t<c.children.length;t+=3){let n=c.children[t];for(;e<a.length&&a[e]<n;)e+=3;a.splice(e,0,c.children[t],c.children[t+1],c.children[t+2])}}return new zo(e.sort(Wo),a)}(this.children,i||[],t,e,n,r,o):i?new zo(i.sort(Wo),Po):$o}add(t,e){return e.length?this==$o?zo.create(t,e):this.addInner(t,e,0):this}addInner(t,e,n){let r,o=0;t.forEach(((t,i)=>{let s,a=i+n;if(s=_o(e,t,a)){for(r||(r=this.children.slice());o<r.length&&r[o]<i;)o+=3;r[o]==i?r[o+2]=r[o+2].addInner(t,s,a+1):r.splice(o,0,i,i+t.nodeSize,Ho(s,t,a+1,jo)),o+=3}}));let i=Fo(o?Vo(e):e,-n);for(let e=0;e<i.length;e++)i[e].type.valid(t,i[e])||i.splice(e--,1);return new zo(i.length?this.local.concat(i).sort(Wo):this.local,r||this.children)}remove(t){return 0==t.length||this==$o?this:this.removeInner(t,0)}removeInner(t,e){let n=this.children,r=this.local;for(let r=0;r<n.length;r+=3){let o,i=n[r]+e,s=n[r+1]+e;for(let e,n=0;n<t.length;n++)(e=t[n])&&e.from>i&&e.to<s&&(t[n]=null,(o||(o=[])).push(e));if(!o)continue;n==this.children&&(n=this.children.slice());let a=n[r+2].removeInner(o,i+1);a!=$o?n[r+2]=a:(n.splice(r,3),r-=3)}if(r.length)for(let n,o=0;o<t.length;o++)if(n=t[o])for(let t=0;t<r.length;t++)r[t].eq(n,e)&&(r==this.local&&(r=this.local.slice()),r.splice(t--,1));return n==this.children&&r==this.local?this:r.length||n.length?new zo(r,n):$o}forChild(t,e){if(this==$o)return this;if(e.isLeaf)return zo.empty;let n,r;for(let e=0;e<this.children.length;e+=3)if(this.children[e]>=t){this.children[e]==t&&(n=this.children[e+2]);break}let o=t+1,i=o+e.content.size;for(let t=0;t<this.local.length;t++){let e=this.local[t];if(e.from<i&&e.to>o&&e.type instanceof Ro){let t=Math.max(o,e.from)-o,n=Math.min(i,e.to)-o;t<n&&(r||(r=[])).push(e.copy(t,n))}}if(r){let t=new zo(r.sort(Wo),Po);return n?new Bo([t,n]):t}return n||$o}eq(t){if(this==t)return!0;if(!(t instanceof zo)||this.local.length!=t.local.length||this.children.length!=t.children.length)return!1;for(let e=0;e<this.local.length;e++)if(!this.local[e].eq(t.local[e]))return!1;for(let e=0;e<this.children.length;e+=3)if(this.children[e]!=t.children[e]||this.children[e+1]!=t.children[e+1]||!this.children[e+2].eq(t.children[e+2]))return!1;return!0}locals(t){return Ko(this.localsInner(t))}localsInner(t){if(this==$o)return Po;if(t.inlineContent||!this.local.some(Ro.is))return this.local;let e=[];for(let t=0;t<this.local.length;t++)this.local[t].type instanceof Ro||e.push(this.local[t]);return e}}zo.empty=new zo([],[]),zo.removeOverlap=Ko;const $o=zo.empty;class Bo{constructor(t){this.members=t}map(t,e){const n=this.members.map((n=>n.map(t,e,jo)));return Bo.from(n)}forChild(t,e){if(e.isLeaf)return zo.empty;let n=[];for(let r=0;r<this.members.length;r++){let o=this.members[r].forChild(t,e);o!=$o&&(o instanceof Bo?n=n.concat(o.members):n.push(o))}return Bo.from(n)}eq(t){if(!(t instanceof Bo)||t.members.length!=this.members.length)return!1;for(let e=0;e<this.members.length;e++)if(!this.members[e].eq(t.members[e]))return!1;return!0}locals(t){let e,n=!0;for(let r=0;r<this.members.length;r++){let o=this.members[r].localsInner(t);if(o.length)if(e){n&&(e=e.slice(),n=!1);for(let t=0;t<o.length;t++)e.push(o[t])}else e=o}return e?Ko(n?e:e.sort(Wo)):Po}static from(t){switch(t.length){case 0:return $o;case 1:return t[0];default:return new Bo(t.every((t=>t instanceof zo))?t:t.reduce(((t,e)=>t.concat(e instanceof zo?e:e.members)),[]))}}}function Fo(t,e){if(!e||!t.length)return t;let n=[];for(let r=0;r<t.length;r++){let o=t[r];n.push(new Lo(o.from+e,o.to+e,o.type))}return n}function _o(t,e,n){if(e.isLeaf)return null;let r=n+e.nodeSize,o=null;for(let e,i=0;i<t.length;i++)(e=t[i])&&e.from>n&&e.to<r&&((o||(o=[])).push(e),t[i]=null);return o}function Vo(t){let e=[];for(let n=0;n<t.length;n++)null!=t[n]&&e.push(t[n]);return e}function Ho(t,e,n,r){let o=[],i=!1;e.forEach(((e,s)=>{let a=_o(t,e,s+n);if(a){i=!0;let t=Ho(a,e,n+s+1,r);t!=$o&&o.push(s,s+e.nodeSize,t)}}));let s=Fo(i?Vo(t):t,-n).sort(Wo);for(let t=0;t<s.length;t++)s[t].type.valid(e,s[t])||(r.onRemove&&r.onRemove(s[t].spec),s.splice(t--,1));return s.length||o.length?new zo(s,o):$o}function Wo(t,e){return t.from-e.from||t.to-e.to}function Ko(t){let e=t;for(let n=0;n<e.length-1;n++){let r=e[n];if(r.from!=r.to)for(let o=n+1;o<e.length;o++){let i=e[o];if(i.from!=r.from){i.from<r.to&&(e==t&&(e=t.slice()),e[n]=r.copy(r.from,i.from),qo(e,o,r.copy(i.from,r.to)));break}i.to!=r.to&&(e==t&&(e=t.slice()),e[o]=i.copy(i.from,r.to),qo(e,o+1,i.copy(r.to,i.to)))}}return e}function qo(t,e,n){for(;e<t.length&&Wo(n,t[e])>0;)e++;t.splice(e,0,n)}function Jo(t){let e=[];return t.someProp("decorations",(n=>{let r=n(t.state);r&&r!=$o&&e.push(r)})),t.cursorWrapper&&e.push(zo.create(t.state.doc,[t.cursorWrapper.deco])),Bo.from(e)}const Uo={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},Go=gn&&yn<=11;class Yo{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(t){this.anchorNode=t.anchorNode,this.anchorOffset=t.anchorOffset,this.focusNode=t.focusNode,this.focusOffset=t.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(t){return t.anchorNode==this.anchorNode&&t.anchorOffset==this.anchorOffset&&t.focusNode==this.focusNode&&t.focusOffset==this.focusOffset}}class Qo{constructor(t,e){this.view=t,this.handleDOMChange=e,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new Yo,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver((t=>{for(let e=0;e<t.length;e++)this.queue.push(t[e]);gn&&yn<=11&&t.some((t=>"childList"==t.type&&t.removedNodes.length||"characterData"==t.type&&t.oldValue.length>t.target.nodeValue.length))?this.flushSoon():this.flush()})),Go&&(this.onCharData=t=>{this.queue.push({target:t.target,type:"characterData",oldValue:t.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,Uo)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let t=this.observer.takeRecords();if(t.length){for(let e=0;e<t.length;e++)this.queue.push(t[e]);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(Nr(this.view)){if(this.suppressingSelectionUpdates)return kr(this.view);if(gn&&yn<=11&&!this.view.state.selection.empty){let t=this.view.domSelectionRange();if(t.focusNode&&nn(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(t){if(!t.focusNode)return!0;let e,n=new Set;for(let e=t.focusNode;e;e=Ze(e))n.add(e);for(let r=t.anchorNode;r;r=Ze(r))if(n.has(r)){e=r;break}let r=e&&this.view.docView.nearestDesc(e);return r&&r.ignoreMutation({type:"selection",target:3==e.nodeType?e.parentNode:e})?(this.setCurSelection(),!0):void 0}pendingRecords(){if(this.observer)for(let t of this.observer.takeRecords())this.queue.push(t);return this.queue}flush(){let{view:t}=this;if(!t.docView||this.flushingSoon>-1)return;let e=this.pendingRecords();e.length&&(this.queue=[]);let n=t.domSelectionRange(),r=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(n)&&Nr(t)&&!this.ignoreSelectionChange(n),o=-1,i=-1,s=!1,a=[];if(t.editable)for(let t=0;t<e.length;t++){let n=this.registerMutation(e[t],a);n&&(o=o<0?n.from:Math.min(n.from,o),i=i<0?n.to:Math.max(n.to,i),n.typeOver&&(s=!0))}if(bn&&a.length){let e=a.filter((t=>"BR"==t.nodeName));if(2==e.length){let[t,n]=e;t.parentNode&&t.parentNode.parentNode==n.parentNode?n.remove():t.remove()}else{let{focusNode:n}=this.currentSelection;for(let r of e){let e=r.parentNode;e&&"LI"==e.nodeName&&(!n||ei(t,n)!=e)&&r.remove()}}}let l=null;o<0&&r&&t.input.lastFocus>Date.now()-200&&Math.max(t.input.lastTouch,t.input.lastClick.time)<Date.now()-300&&ln(n)&&(l=vr(t))&&l.eq(Ne.near(t.state.doc.resolve(0),1))?(t.input.lastFocus=0,kr(t),this.currentSelection.set(n),t.scrollToSelection()):(o>-1||r)&&(o>-1&&(t.docView.markDirty(o,i),function(t){if(!Xo.has(t)&&(Xo.set(t,null),-1!==["normal","nowrap","pre-line"].indexOf(getComputedStyle(t.dom).whiteSpace))){if(t.requiresGeckoHackNode=bn,Zo)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."),Zo=!0}}(t)),this.handleDOMChange(o,i,s,a),t.docView&&t.docView.dirty?t.updateState(t.state):this.currentSelection.eq(n)||kr(t),this.currentSelection.set(n))}registerMutation(t,e){if(e.indexOf(t.target)>-1)return null;let n=this.view.docView.nearestDesc(t.target);if("attributes"==t.type&&(n==this.view.docView||"contenteditable"==t.attributeName||"style"==t.attributeName&&!t.oldValue&&!t.target.getAttribute("style"))||!n||n.ignoreMutation(t))return null;if("childList"==t.type){for(let n=0;n<t.addedNodes.length;n++){let r=t.addedNodes[n];e.push(r),3==r.nodeType&&(this.lastChangedTextNode=r)}if(n.contentDOM&&n.contentDOM!=n.dom&&!n.contentDOM.contains(t.target))return{from:n.posBefore,to:n.posAfter};let r=t.previousSibling,o=t.nextSibling;if(gn&&yn<=11&&t.addedNodes.length)for(let e=0;e<t.addedNodes.length;e++){let{previousSibling:n,nextSibling:i}=t.addedNodes[e];(!n||Array.prototype.indexOf.call(t.addedNodes,n)<0)&&(r=n),(!i||Array.prototype.indexOf.call(t.addedNodes,i)<0)&&(o=i)}let i=r&&r.parentNode==t.target?Xe(r)+1:0,s=n.localPosFromDOM(t.target,i,-1),a=o&&o.parentNode==t.target?Xe(o):t.target.childNodes.length;return{from:s,to:n.localPosFromDOM(t.target,a,1)}}return"attributes"==t.type?{from:n.posAtStart-n.border,to:n.posAtEnd+n.border}:(this.lastChangedTextNode=t.target,{from:n.posAtStart,to:n.posAtEnd,typeOver:t.target.nodeValue==t.oldValue})}}let Xo=new WeakMap,Zo=!1;function ti(t,e){let n=e.startContainer,r=e.startOffset,o=e.endContainer,i=e.endOffset,s=t.domAtPos(t.state.selection.anchor);return nn(s.node,s.offset,o,i)&&([n,r,o,i]=[o,i,n,r]),{anchorNode:n,anchorOffset:r,focusNode:o,focusOffset:i}}function ei(t,e){for(let n=e.parentNode;n&&n!=t.dom;n=n.parentNode){let e=t.docView.nearestDesc(n,!0);if(e&&e.node.isBlock)return n}return null}function ni(t){let e=t.pmViewDesc;if(e)return e.parseRule();if("BR"==t.nodeName&&t.parentNode){if(xn&&/^(ul|ol)$/i.test(t.parentNode.nodeName)){let t=document.createElement("div");return t.appendChild(document.createElement("li")),{skip:t}}if(t.parentNode.lastChild==t||xn&&/^(tr|table)$/i.test(t.parentNode.nodeName))return{ignore:!0}}else if("IMG"==t.nodeName&&t.getAttribute("mark-placeholder"))return{ignore:!0};return null}const ri=/^(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 oi(t,e,n,r,o){let i=t.input.compositionPendingChanges||(t.composing?t.input.compositionID:0);if(t.input.compositionPendingChanges=0,e<0){let e=t.input.lastSelectionTime>Date.now()-50?t.input.lastSelectionOrigin:null,n=vr(t,e);if(n&&!t.state.selection.eq(n)){if(wn&&Mn&&13===t.input.lastKeyCode&&Date.now()-100<t.input.lastKeyCodeTime&&t.someProp("handleKeyDown",(e=>e(t,cn(13,"Enter")))))return;let r=t.state.tr.setSelection(n);"pointer"==e?r.setMeta("pointer",!0):"key"==e&&r.scrollIntoView(),i&&r.setMeta("composition",i),t.dispatch(r)}return}let s=t.state.doc.resolve(e),a=s.sharedDepth(n);e=s.before(a+1),n=t.state.doc.resolve(n).after(a+1);let l,c,d=t.state.selection,h=function(t,e,n){let r,{node:o,fromOffset:i,toOffset:s,from:a,to:l}=t.docView.parseRange(e,n),c=t.domSelectionRange(),d=c.anchorNode;if(d&&t.dom.contains(1==d.nodeType?d:d.parentNode)&&(r=[{node:d,offset:c.anchorOffset}],ln(c)||r.push({node:c.focusNode,offset:c.focusOffset})),wn&&8===t.input.lastKeyCode)for(let t=s;t>i;t--){let e=o.childNodes[t-1],n=e.pmViewDesc;if("BR"==e.nodeName&&!n){s=t;break}if(!n||n.size)break}let h=t.state.doc,u=t.someProp("domParser")||Ct.fromSchema(t.state.schema),p=h.resolve(a),f=null,m=u.parse(o,{topNode:p.parent,topMatch:p.parent.contentMatchAt(p.index()),topOpen:!0,from:i,to:s,preserveWhitespace:"pre"!=p.parent.type.whitespace||"full",findPositions:r,ruleFromNode:ni,context:p});if(r&&null!=r[0].pos){let t=r[0].pos,e=r[1]&&r[1].pos;null==e&&(e=t),f={anchor:t+a,head:e+a}}return{doc:m,sel:f,from:a,to:l}}(t,e,n),u=t.state.doc,p=u.slice(h.from,h.to);8===t.input.lastKeyCode&&Date.now()-100<t.input.lastKeyCodeTime?(l=t.state.selection.to,c="end"):(l=t.state.selection.from,c="start"),t.input.lastKeyCode=null;let f=function(t,e,n,r,o){let i=t.findDiffStart(e,n);if(null==i)return null;let{a:s,b:a}=t.findDiffEnd(e,n+t.size,n+e.size);if("end"==o){r-=s+Math.max(0,i-Math.min(s,a))-i}if(s<i&&t.size<e.size){let t=r<=i&&r>=s?i-r:0;i-=t,i&&i<e.size&&ai(e.textBetween(i-1,i+1))&&(i+=t?1:-1),a=i+(a-s),s=i}else if(a<i){let e=r<=i&&r>=a?i-r:0;i-=e,i&&i<t.size&&ai(t.textBetween(i-1,i+1))&&(i+=e?1:-1),s=i+(s-a),a=i}return{start:i,endA:s,endB:a}}(p.content,h.doc.content,h.from,l,c);if((Sn&&t.input.lastIOSEnter>Date.now()-225||Mn)&&o.some((t=>1==t.nodeType&&!ri.test(t.nodeName)))&&(!f||f.endA>=f.endB)&&t.someProp("handleKeyDown",(e=>e(t,cn(13,"Enter")))))return void(t.input.lastIOSEnter=0);if(!f){if(!(r&&d instanceof Ie&&!d.empty&&d.$head.sameParent(d.$anchor))||t.composing||h.sel&&h.sel.anchor!=h.sel.head){if(h.sel){let e=ii(t,t.state.doc,h.sel);if(e&&!e.eq(t.state.selection)){let n=t.state.tr.setSelection(e);i&&n.setMeta("composition",i),t.dispatch(n)}}return}f={start:d.from,endA:d.to,endB:d.to}}t.input.domChangeCount++,t.state.selection.from<t.state.selection.to&&f.start==f.endB&&t.state.selection instanceof Ie&&(f.start>t.state.selection.from&&f.start<=t.state.selection.from+2&&t.state.selection.from>=h.from?f.start=t.state.selection.from:f.endA<t.state.selection.to&&f.endA>=t.state.selection.to-2&&t.state.selection.to<=h.to&&(f.endB+=t.state.selection.to-f.endA,f.endA=t.state.selection.to)),gn&&yn<=11&&f.endB==f.start+1&&f.endA==f.start&&f.start>h.from&&"  "==h.doc.textBetween(f.start-h.from-1,f.start-h.from+1)&&(f.start--,f.endA--,f.endB--);let m,g=h.doc.resolveNoCache(f.start-h.from),y=h.doc.resolveNoCache(f.endB-h.from),b=u.resolve(f.start),v=g.sameParent(y)&&g.parent.inlineContent&&b.end()>=f.endA;if((Sn&&t.input.lastIOSEnter>Date.now()-225&&(!v||o.some((t=>"DIV"==t.nodeName||"P"==t.nodeName)))||!v&&g.pos<h.doc.content.size&&!g.sameParent(y)&&(m=Ne.findFrom(h.doc.resolve(g.pos+1),1,!0))&&m.head==y.pos)&&t.someProp("handleKeyDown",(e=>e(t,cn(13,"Enter")))))return void(t.input.lastIOSEnter=0);if(t.state.selection.anchor>f.start&&function(t,e,n,r,o){if(n-e<=o.pos-r.pos||si(r,!0,!1)<o.pos)return!1;let i=t.resolve(e);if(!r.parent.isTextblock){let t=i.nodeAfter;return null!=t&&n==e+t.nodeSize}if(i.parentOffset<i.parent.content.size||!i.parent.isTextblock)return!1;let s=t.resolve(si(i,!0,!0));return!(!s.parent.isTextblock||s.pos>n||si(s,!0,!1)<n)&&r.parent.content.cut(r.parentOffset).eq(s.parent.content)}(u,f.start,f.endA,g,y)&&t.someProp("handleKeyDown",(e=>e(t,cn(8,"Backspace")))))return void(Mn&&wn&&t.domObserver.suppressSelectionUpdates());wn&&Mn&&f.endB==f.start&&(t.input.lastAndroidDelete=Date.now()),Mn&&!v&&g.start()!=y.start()&&0==y.parentOffset&&g.depth==y.depth&&h.sel&&h.sel.anchor==h.sel.head&&h.sel.head==f.endA&&(f.endB-=2,y=h.doc.resolveNoCache(f.endB-h.from),setTimeout((()=>{t.someProp("handleKeyDown",(function(e){return e(t,cn(13,"Enter"))}))}),20));let w,k,x,S=f.start,O=f.endA;if(v)if(g.pos==y.pos)gn&&yn<=11&&0==g.parentOffset&&(t.domObserver.suppressSelectionUpdates(),setTimeout((()=>kr(t)),20)),w=t.state.tr.delete(S,O),k=u.resolve(f.start).marksAcross(u.resolve(f.endA));else if(f.endA==f.endB&&(x=function(t,e){let n,r,o,i=t.firstChild.marks,s=e.firstChild.marks,a=i,l=s;for(let t=0;t<s.length;t++)a=s[t].removeFromSet(a);for(let t=0;t<i.length;t++)l=i[t].removeFromSet(l);if(1==a.length&&0==l.length)r=a[0],n="add",o=t=>t.mark(r.addToSet(t.marks));else{if(0!=a.length||1!=l.length)return null;r=l[0],n="remove",o=t=>t.mark(r.removeFromSet(t.marks))}let c=[];for(let t=0;t<e.childCount;t++)c.push(o(e.child(t)));if(L.from(c).eq(t))return{mark:r,type:n}}(g.parent.content.cut(g.parentOffset,y.parentOffset),b.parent.content.cut(b.parentOffset,f.endA-b.start()))))w=t.state.tr,"add"==x.type?w.addMark(S,O,x.mark):w.removeMark(S,O,x.mark);else if(g.parent.child(g.index()).isText&&g.index()==y.index()-(y.textOffset?0:1)){let e=g.parent.textBetween(g.parentOffset,y.parentOffset);if(t.someProp("handleTextInput",(n=>n(t,S,O,e))))return;w=t.state.tr.insertText(e,S,O)}if(w||(w=t.state.tr.replace(S,O,h.doc.slice(f.start-h.from,f.endB-h.from))),h.sel){let e=ii(t,w.doc,h.sel);e&&!(wn&&Mn&&t.composing&&e.empty&&(f.start!=f.endB||t.input.lastAndroidDelete<Date.now()-100)&&(e.head==S||e.head==w.mapping.map(O)-1)||gn&&e.empty&&e.head==S)&&w.setSelection(e)}k&&w.ensureMarks(k),i&&w.setMeta("composition",i),t.dispatch(w.scrollIntoView())}function ii(t,e,n){return Math.max(n.anchor,n.head)>e.content.size?null:Er(t,e.resolve(n.anchor),e.resolve(n.head))}function si(t,e,n){let r=t.depth,o=e?t.end():t.pos;for(;r>0&&(e||t.indexAfter(r)==t.node(r).childCount);)r--,o++,e=!1;if(n){let e=t.node(r).maybeChild(t.indexAfter(r));for(;e&&!e.isLeaf;)e=e.firstChild,o++}return o}function ai(t){if(2!=t.length)return!1;let e=t.charCodeAt(0),n=t.charCodeAt(1);return e>=56320&&e<=57343&&n>=55296&&n<=56319}class li{constructor(t,e){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 oo,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=e,this.state=e.state,this.directPlugins=e.plugins||[],this.directPlugins.forEach(pi),this.dispatch=this.dispatch.bind(this),this.dom=t&&t.mount||document.createElement("div"),t&&(t.appendChild?t.appendChild(this.dom):"function"==typeof t?t(this.dom):t.mount&&(this.mounted=!0)),this.editable=hi(this),di(this),this.nodeViews=ui(this),this.docView=rr(this.state.doc,ci(this),Jo(this),this.dom,this),this.domObserver=new Qo(this,((t,e,n,r)=>oi(this,t,e,n,r))),this.domObserver.start(),function(t){for(let e in eo){let n=eo[e];t.dom.addEventListener(e,t.input.eventHandlers[e]=e=>{lo(t,e)&&!ao(t,e)&&(t.editable||!(e.type in no))&&n(t,e)},ro[e]?{passive:!0}:void 0)}xn&&t.dom.addEventListener("input",(()=>null)),so(t)}(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let t=this._props;this._props={};for(let e in t)this._props[e]=t[e];this._props.state=this.state}return this._props}update(t){t.handleDOMEvents!=this._props.handleDOMEvents&&so(this);let e=this._props;this._props=t,t.plugins&&(t.plugins.forEach(pi),this.directPlugins=t.plugins),this.updateStateInner(t.state,e)}setProps(t){let e={};for(let t in this._props)e[t]=this._props[t];e.state=this.state;for(let n in t)e[n]=t[n];this.update(e)}updateState(t){this.updateStateInner(t,this._props)}updateStateInner(t,e){var n;let r=this.state,o=!1,i=!1;t.storedMarks&&this.composing&&(xo(this),i=!0),this.state=t;let s=r.plugins!=t.plugins||this._props.plugins!=e.plugins;if(s||this._props.plugins!=e.plugins||this._props.nodeViews!=e.nodeViews){let t=ui(this);(function(t,e){let n=0,r=0;for(let r in t){if(t[r]!=e[r])return!0;n++}for(let t in e)r++;return n!=r})(t,this.nodeViews)&&(this.nodeViews=t,o=!0)}(s||e.handleDOMEvents!=this._props.handleDOMEvents)&&so(this),this.editable=hi(this),di(this);let a=Jo(this),l=ci(this),c=r.plugins==t.plugins||r.doc.eq(t.doc)?t.scrollToSelection>r.scrollToSelection?"to selection":"preserve":"reset",d=o||!this.docView.matchesNode(t.doc,l,a);(d||!t.selection.eq(r.selection))&&(i=!0);let h="preserve"==c&&i&&null==this.dom.style.overflowAnchor&&function(t){let e,n,r=t.dom.getBoundingClientRect(),o=Math.max(0,r.top);for(let i=(r.left+r.right)/2,s=o+1;s<Math.min(innerHeight,r.bottom);s+=5){let r=t.root.elementFromPoint(i,s);if(!r||r==t.dom||!t.dom.contains(r))continue;let a=r.getBoundingClientRect();if(a.top>=o-20){e=r,n=a.top;break}}return{refDOM:e,refTop:n,stack:In(t.dom)}}(this);if(i){this.domObserver.stop();let e=d&&(gn||wn)&&!this.composing&&!r.selection.empty&&!t.selection.empty&&function(t,e){let n=Math.min(t.$anchor.sharedDepth(t.head),e.$anchor.sharedDepth(e.head));return t.$anchor.start(n)!=e.$anchor.start(n)}(r.selection,t.selection);if(d){let n=wn?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=So(this)),(o||!this.docView.update(t.doc,l,a,this))&&(this.docView.updateOuterDeco(l),this.docView.destroy(),this.docView=rr(t.doc,l,a,this.dom,this)),n&&!this.trackWrites&&(e=!0)}e||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&function(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return nn(e.node,e.offset,n.anchorNode,n.anchorOffset)}(this))?kr(this,e):(Mr(this,t.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(r),!(null===(n=this.dragging)||void 0===n)&&n.node&&!r.doc.eq(t.doc)&&this.updateDraggedNode(this.dragging,r),"reset"==c?this.dom.scrollTop=0:"to selection"==c?this.scrollToSelection():h&&function({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;Ln(n,0==r?0:r-e)}(h)}scrollToSelection(){let t=this.domSelectionRange().focusNode;if(!this.someProp("handleScrollToSelection",(t=>t(this))))if(this.state.selection instanceof Pe){let e=this.docView.domAfterPos(this.state.selection.from);1==e.nodeType&&Rn(this,e.getBoundingClientRect(),t)}else Rn(this,this.coordsAtPos(this.state.selection.head,1),t)}destroyPluginViews(){let t;for(;t=this.pluginViews.pop();)t.destroy&&t.destroy()}updatePluginViews(t){if(t&&t.plugins==this.state.plugins&&this.directPlugins==this.prevDirectPlugins)for(let e=0;e<this.pluginViews.length;e++){let n=this.pluginViews[e];n.update&&n.update(this,t)}else{this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let t=0;t<this.directPlugins.length;t++){let e=this.directPlugins[t];e.spec.view&&this.pluginViews.push(e.spec.view(this))}for(let t=0;t<this.state.plugins.length;t++){let e=this.state.plugins[t];e.spec.view&&this.pluginViews.push(e.spec.view(this))}}}updateDraggedNode(t,e){let n=t.node,r=-1;if(this.state.doc.nodeAt(n.from)==n.node)r=n.from;else{let t=n.from+(this.state.doc.content.size-e.doc.content.size);(t>0&&this.state.doc.nodeAt(t))==n.node&&(r=t)}this.dragging=new Eo(t.slice,t.move,r<0?void 0:Pe.create(this.state.doc,r))}someProp(t,e){let n,r=this._props&&this._props[t];if(null!=r&&(n=e?e(r):r))return n;for(let r=0;r<this.directPlugins.length;r++){let o=this.directPlugins[r].props[t];if(null!=o&&(n=e?e(o):o))return n}let o=this.state.plugins;if(o)for(let r=0;r<o.length;r++){let i=o[r].props[t];if(null!=i&&(n=e?e(i):i))return n}}hasFocus(){if(gn){let t=this.root.activeElement;if(t==this.dom)return!0;if(!t||!this.dom.contains(t))return!1;for(;t&&this.dom!=t&&this.dom.contains(t);){if("false"==t.contentEditable)return!1;t=t.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&function(t){if(t.setActive)return t.setActive();if(Pn)return t.focus(Pn);let e=In(t);t.focus(null==Pn?{get preventScroll(){return Pn={preventScroll:!0},!0}}:void 0),Pn||(Pn=!1,Ln(e,0))}(this.dom),kr(this),this.domObserver.start()}get root(){let t=this._root;if(null==t)for(let t=this.dom.parentNode;t;t=t.parentNode)if(9==t.nodeType||11==t.nodeType&&t.host)return t.getSelection||(Object.getPrototypeOf(t).getSelection=()=>t.ownerDocument.getSelection()),this._root=t;return t||document}updateRoot(){this._root=null}posAtCoords(t){return Bn(this,t)}coordsAtPos(t,e=1){return Hn(this,t,e)}domAtPos(t,e=0){return this.docView.domFromPos(t,e)}nodeDOM(t){let e=this.docView.descAt(t);return e?e.nodeDOM:null}posAtDOM(t,e,n=-1){let r=this.docView.posFromDOM(t,e,n);if(null==r)throw new RangeError("DOM position not inside the editor");return r}endOfTextblock(t,e){return Qn(this,e||this.state,t)}pasteHTML(t,e){return Mo(this,"",t,!1,e||new ClipboardEvent("paste"))}pasteText(t,e){return Mo(this,t,null,!0,e||new ClipboardEvent("paste"))}destroy(){this.docView&&(function(t){t.domObserver.stop();for(let e in t.input.eventHandlers)t.dom.removeEventListener(e,t.input.eventHandlers[e]);clearTimeout(t.input.composingTimeout),clearTimeout(t.input.lastIOSEnterFallbackTimeout)}(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],Jo(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,tn=null)}get isDestroyed(){return null==this.docView}dispatchEvent(t){return function(t,e){!ao(t,e)&&eo[e.type]&&(t.editable||!(e.type in no))&&eo[e.type](t,e)}(this,t)}dispatch(t){let e=this._props.dispatchTransaction;e?e.call(this,t):this.updateState(this.state.apply(t))}domSelectionRange(){let t=this.domSelection();return t?xn&&11===this.root.nodeType&&function(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}(this.dom.ownerDocument)==this.dom&&function(t,e){if(e.getComposedRanges){let n=e.getComposedRanges(t.root)[0];if(n)return ti(t,n)}let n;function r(t){t.preventDefault(),t.stopImmediatePropagation(),n=t.getTargetRanges()[0]}return t.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),t.dom.removeEventListener("beforeinput",r,!0),n?ti(t,n):null}(this,t)||t:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}function ci(t){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(t.editable),t.someProp("attributes",(n=>{if("function"==typeof n&&(n=n(t.state)),n)for(let t in n)"class"==t?e.class+=" "+n[t]:"style"==t?e.style=(e.style?e.style+";":"")+n[t]:!e[t]&&"contenteditable"!=t&&"nodeName"!=t&&(e[t]=String(n[t]))})),e.translate||(e.translate="no"),[Lo.node(0,t.state.doc.content.size,e)]}function di(t){if(t.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),t.cursorWrapper={dom:e,deco:Lo.widget(t.state.selection.from,e,{raw:!0,marks:t.markCursor})}}else t.cursorWrapper=null}function hi(t){return!t.someProp("editable",(e=>!1===e(t.state)))}function ui(t){let e=Object.create(null);function n(t){for(let n in t)Object.prototype.hasOwnProperty.call(e,n)||(e[n]=t[n])}return t.someProp("nodeViews",n),t.someProp("markViews",n),e}function pi(t){if(t.spec.state||t.spec.filterTransaction||t.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}for(var fi={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:"'"},mi={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},gi=typeof navigator<"u"&&/Mac/.test(navigator.platform),yi=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),bi=0;bi<10;bi++)fi[48+bi]=fi[96+bi]=String(bi);for(bi=1;bi<=24;bi++)fi[bi+111]="F"+bi;for(bi=65;bi<=90;bi++)fi[bi]=String.fromCharCode(bi+32),mi[bi]=String.fromCharCode(bi);for(var vi in fi)mi.hasOwnProperty(vi)||(mi[vi]=fi[vi]);const wi=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform);function ki(t){let e,n,r,o,i=t.split(/-(?!$)/),s=i[i.length-1];"Space"==s&&(s=" ");for(let t=0;t<i.length-1;t++){let s=i[t];if(/^(cmd|meta|m)$/i.test(s))o=!0;else if(/^a(lt)?$/i.test(s))e=!0;else if(/^(c|ctrl|control)$/i.test(s))n=!0;else if(/^s(hift)?$/i.test(s))r=!0;else{if(!/^mod$/i.test(s))throw new Error("Unrecognized modifier name: "+s);wi?o=!0:n=!0}}return e&&(s="Alt-"+s),n&&(s="Ctrl-"+s),o&&(s="Meta-"+s),r&&(s="Shift-"+s),s}function xi(t,e,n=!0){return e.altKey&&(t="Alt-"+t),e.ctrlKey&&(t="Ctrl-"+t),e.metaKey&&(t="Meta-"+t),n&&e.shiftKey&&(t="Shift-"+t),t}function Si(t){let e=function(t){let e=Object.create(null);for(let n in t)e[ki(n)]=t[n];return e}(t);return function(t,n){let r,o=function(t){var e=!(gi&&t.metaKey&&t.shiftKey&&!t.ctrlKey&&!t.altKey||yi&&t.shiftKey&&t.key&&1==t.key.length||"Unidentified"==t.key)&&t.key||(t.shiftKey?mi:fi)[t.keyCode]||t.key||"Unidentified";return"Esc"==e&&(e="Escape"),"Del"==e&&(e="Delete"),"Left"==e&&(e="ArrowLeft"),"Up"==e&&(e="ArrowUp"),"Right"==e&&(e="ArrowRight"),"Down"==e&&(e="ArrowDown"),e}(n),i=e[xi(o,n)];if(i&&i(t.state,t.dispatch,t))return!0;if(1==o.length&&" "!=o){if(n.shiftKey){let r=e[xi(o,n,!1)];if(r&&r(t.state,t.dispatch,t))return!0}if((n.shiftKey||n.altKey||n.metaKey||o.charCodeAt(0)>127)&&(r=fi[n.keyCode])&&r!=o){let o=e[xi(r,n)];if(o&&o(t.state,t.dispatch,t))return!0}}return!1}}function Oi(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("backward",t):n.parentOffset>0)?null:n}function Ci(t,e,n){let r=e.nodeBefore,o=e.pos-1;for(;!r.isTextblock;o--){if(r.type.spec.isolating)return!1;let t=r.lastChild;if(!t)return!1;r=t}let i=e.nodeAfter,s=e.pos+1;for(;!i.isTextblock;s++){if(i.type.spec.isolating)return!1;let t=i.firstChild;if(!t)return!1;i=t}let a=pe(t.doc,o,s,F.empty);if(!a||a.from!=o||a instanceof ee&&a.slice.size>=s-o)return!1;if(n){let e=t.tr.step(a);e.setSelection(Ie.create(e.doc,o)),n(e.scrollIntoView())}return!0}function Mi(t,e,n=!1){for(let r=t;r;r="start"==e?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(n&&1!=r.childCount)return!1}return!1}function Ti(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){if(t.index(e)>0)return t.doc.resolve(t.before(e+1));if(t.node(e).type.spec.isolating)break}return null}function Ei(t,e){let{$cursor:n}=t.selection;return!n||(e?!e.endOfTextblock("forward",t):n.parentOffset<n.parent.content.size)?null:n}function Ni(t){if(!t.parent.type.spec.isolating)for(let e=t.depth-1;e>=0;e--){let n=t.node(e);if(t.index(e)+1<n.childCount)return t.doc.resolve(t.after(e+1));if(n.type.spec.isolating)break}return null}function Ai(t){for(let e=0;e<t.edgeCount;e++){let{type:n}=t.edge(e);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}function Di(t,e,n,r){let o,i,s=e.nodeBefore,a=e.nodeAfter,l=s.type.spec.isolating||a.type.spec.isolating;if(!l&&function(t,e,n){let r=e.nodeBefore,o=e.nodeAfter,i=e.index();return!(!(r&&o&&r.type.compatibleContent(o.type))||(!r.content.size&&e.parent.canReplace(i-1,i)?(n&&n(t.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),0):!e.parent.canReplace(i,i+1)||!o.isTextblock&&!de(t.doc,e.pos)||(n&&n(t.tr.clearIncompatible(e.pos,r.type,r.contentMatchAt(r.childCount)).join(e.pos).scrollIntoView()),0)))}(t,e,n))return!0;let c=!l&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(o=(i=s.contentMatchAt(s.childCount)).findWrapping(a.type))&&i.matchType(o[0]||a.type).validEnd){if(n){let r=e.pos+a.nodeSize,i=L.empty;for(let t=o.length-1;t>=0;t--)i=L.from(o[t].create(null,i));i=L.from(s.copy(i));let l=t.tr.step(new ne(e.pos-1,r,e.pos,r,new F(i,1,0),o.length,!0)),c=r+2*o.length;de(l.doc,c)&&l.join(c),n(l.scrollIntoView())}return!0}let d=a.type.spec.isolating||r>0&&l?null:Ne.findFrom(e,1),h=d&&d.$from.blockRange(d.$to),u=h&&se(h);if(null!=u&&u>=e.depth)return n&&n(t.tr.lift(h,u).scrollIntoView()),!0;if(c&&Mi(a,"start",!0)&&Mi(s,"end")){let r=s,o=[];for(;o.push(r),!r.isTextblock;)r=r.lastChild;let i=a,l=1;for(;!i.isTextblock;i=i.firstChild)l++;if(r.canReplace(r.childCount,r.childCount,i.content)){if(n){let r=L.empty;for(let t=o.length-1;t>=0;t--)r=L.from(o[t].copy(r));n(t.tr.step(new ne(e.pos-o.length,e.pos+a.nodeSize,e.pos+l,e.pos+a.nodeSize-l,new F(r,o.length,0),0,!0)).scrollIntoView())}return!0}}return!1}function Ri(t){return function(e,n){let r=e.selection,o=t<0?r.$from:r.$to,i=o.depth;for(;o.node(i).isInline;){if(!i)return!1;i--}return!!o.node(i).isTextblock&&(n&&n(e.tr.setSelection(Ie.create(e.doc,t<0?o.start(i):o.end(i)))),!0)}}const Ii=Ri(-1),Li=Ri(1);function Pi(t,e=null){return function(n,r){let o=!1;for(let r=0;r<n.selection.ranges.length&&!o;r++){let{$from:{pos:i},$to:{pos:s}}=n.selection.ranges[r];n.doc.nodesBetween(i,s,((r,i)=>{if(o)return!1;if(r.isTextblock&&!r.hasMarkup(t,e))if(r.type==t)o=!0;else{let e=n.doc.resolve(i),r=e.index();o=e.parent.canReplaceWith(r,r+1,t)}}))}if(!o)return!1;if(r){let o=n.tr;for(let r=0;r<n.selection.ranges.length;r++){let{$from:{pos:i},$to:{pos:s}}=n.selection.ranges[r];o.setBlockType(i,s,t,e)}r(o.scrollIntoView())}return!0}}function ji(t,e=null){return function(n,r){let{$from:o,$to:i}=n.selection,s=o.blockRange(i),a=!1,l=s;if(!s)return!1;if(s.depth>=2&&o.node(s.depth-1).type.compatibleContent(t)&&0==s.startIndex){if(0==o.index(s.depth-1))return!1;let t=n.doc.resolve(s.start-2);l=new nt(t,t,s.depth),s.endIndex<s.parent.childCount&&(s=new nt(o,n.doc.resolve(i.end(s.depth)),s.depth)),a=!0}let c=ae(l,t,e,s);return!!c&&(r&&r(function(t,e,n,r,o){let i=L.empty;for(let t=n.length-1;t>=0;t--)i=L.from(n[t].type.create(n[t].attrs,i));t.step(new ne(e.start-(r?2:0),e.end,e.start,e.end,new F(i,0,0),n.length,!0));let s=0;for(let t=0;t<n.length;t++)n[t].type==o&&(s=t+1);let a=n.length-s,l=e.start+n.length-(r?2:0),c=e.parent;for(let n=e.startIndex,r=e.endIndex,o=!0;n<r;n++,o=!1)!o&&ce(t.doc,l,a)&&(t.split(l,a),l+=2*a),l+=c.child(n).nodeSize;return t}(n.tr,s,c,a,t).scrollIntoView()),!0)}}function zi(t){return function(e,n){let{$from:r,$to:o}=e.selection,i=r.blockRange(o,(e=>e.childCount>0&&e.firstChild.type==t));return!!i&&(!n||(r.node(i.depth-1).type==t?function(t,e,n,r){let o=t.tr,i=r.end,s=r.$to.end(r.depth);i<s&&(o.step(new ne(i-1,s,i,s,new F(L.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new nt(o.doc.resolve(r.$from.pos),o.doc.resolve(s),r.depth));const a=se(r);if(null==a)return!1;o.lift(r,a);let l=o.mapping.map(i,-1)-1;return de(o.doc,l)&&o.join(l),e(o.scrollIntoView()),!0}(e,n,t,i):function(t,e,n){let r=t.tr,o=n.parent;for(let t=n.end,e=n.endIndex-1,i=n.startIndex;e>i;e--)t-=o.child(e).nodeSize,r.delete(t-1,t+1);let i=r.doc.resolve(n.start),s=i.nodeAfter;if(r.mapping.map(n.end)!=n.start+i.nodeAfter.nodeSize)return!1;let a=0==n.startIndex,l=n.endIndex==o.childCount,c=i.node(-1),d=i.index(-1);if(!c.canReplace(d+(a?0:1),d+1,s.content.append(l?L.empty:L.from(o))))return!1;let h=i.pos,u=h+s.nodeSize;return r.step(new ne(h-(a?1:0),u+(l?1:0),h+1,u-1,new F((a?L.empty:L.from(o.copy(L.empty))).append(l?L.empty:L.from(o.copy(L.empty))),a?0:1,l?0:1),a?0:1)),e(r.scrollIntoView()),!0}(e,n,i)))}}function $i(t){const{state:e,transaction:n}=t;let{selection:r}=n,{doc:o}=n,{storedMarks:i}=n;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return i},get selection(){return r},get doc(){return o},get tr(){return r=n.selection,o=n.doc,i=n.storedMarks,n}}}typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform&&os.platform();class Bi{constructor(t){this.editor=t.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=t.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:t,editor:e,state:n}=this,{view:r}=e,{tr:o}=n,i=this.buildProps(o);return Object.fromEntries(Object.entries(t).map((([t,e])=>[t,(...t)=>{const n=e(...t)(i);return!o.getMeta("preventDispatch")&&!this.hasCustomState&&r.dispatch(o),n}])))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(t,e=!0){const{rawCommands:n,editor:r,state:o}=this,{view:i}=r,s=[],a=!!t,l=t||o.tr,c={...Object.fromEntries(Object.entries(n).map((([t,n])=>[t,(...t)=>{const r=this.buildProps(l,e),o=n(...t)(r);return s.push(o),c}]))),run:()=>(!a&&e&&!l.getMeta("preventDispatch")&&!this.hasCustomState&&i.dispatch(l),s.every((t=>!0===t)))};return c}createCan(t){const{rawCommands:e,state:n}=this,r=t||n.tr,o=this.buildProps(r,false);return{...Object.fromEntries(Object.entries(e).map((([t,e])=>[t,(...t)=>e(...t)({...o,dispatch:void 0})]))),chain:()=>this.createChain(r,false)}}buildProps(t,e=!0){const{rawCommands:n,editor:r,state:o}=this,{view:i}=r,s={tr:t,editor:r,view:i,state:$i({state:o,transaction:t}),dispatch:e?()=>{}:void 0,chain:()=>this.createChain(t,e),can:()=>this.createCan(t),get commands(){return Object.fromEntries(Object.entries(n).map((([t,e])=>[t,(...t)=>e(...t)(s)])))}};return s}}class Fi{constructor(){this.callbacks={}}on(t,e){return this.callbacks[t]||(this.callbacks[t]=[]),this.callbacks[t].push(e),this}emit(t,...e){const n=this.callbacks[t];return n&&n.forEach((t=>t.apply(this,e))),this}off(t,e){const n=this.callbacks[t];return n&&(e?this.callbacks[t]=n.filter((t=>t!==e)):delete this.callbacks[t]),this}removeAllListeners(){this.callbacks={}}}function _i(t,e,n){return void 0===t.config[e]&&t.parent?_i(t.parent,e,n):"function"==typeof t.config[e]?t.config[e].bind({...n,parent:t.parent?_i(t.parent,e,n):null}):t.config[e]}function Vi(t){return{baseExtensions:t.filter((t=>"extension"===t.type)),nodeExtensions:t.filter((t=>"node"===t.type)),markExtensions:t.filter((t=>"mark"===t.type))}}function Hi(t){const e=[],{nodeExtensions:n,markExtensions:r}=Vi(t),o=[...n,...r],i={default:null,rendered:!0,renderHTML:null,parseHTML:null,keepOnSplit:!0,isRequired:!1};return t.forEach((t=>{const n=_i(t,"addGlobalAttributes",{name:t.name,options:t.options,storage:t.storage,extensions:o});n&&n().forEach((t=>{t.types.forEach((n=>{Object.entries(t.attributes).forEach((([t,r])=>{e.push({type:n,name:t,attribute:{...i,...r}})}))}))}))})),o.forEach((t=>{const n={name:t.name,options:t.options,storage:t.storage},r=_i(t,"addAttributes",n);if(!r)return;const o=r();Object.entries(o).forEach((([n,r])=>{const o={...i,...r};"function"==typeof(null==o?void 0:o.default)&&(o.default=o.default()),null!=o&&o.isRequired&&void 0===(null==o?void 0:o.default)&&delete o.default,e.push({type:t.name,name:n,attribute:o})}))})),e}function Wi(t,e){if("string"==typeof t){if(!e.nodes[t])throw Error(`There is no node type named '${t}'. Maybe you forgot to add the extension?`);return e.nodes[t]}return t}function Ki(...t){return t.filter((t=>!!t)).reduce(((t,e)=>{const n={...t};return Object.entries(e).forEach((([t,e])=>{if(n[t])if("class"===t){const r=e?e.split(" "):[],o=n[t]?n[t].split(" "):[],i=r.filter((t=>!o.includes(t)));n[t]=[...o,...i].join(" ")}else if("style"===t){const r=e?e.split(";").map((t=>t.trim())).filter(Boolean):[],o=n[t]?n[t].split(";").map((t=>t.trim())).filter(Boolean):[],i=new Map;o.forEach((t=>{const[e,n]=t.split(":").map((t=>t.trim()));i.set(e,n)})),r.forEach((t=>{const[e,n]=t.split(":").map((t=>t.trim()));i.set(e,n)})),n[t]=Array.from(i.entries()).map((([t,e])=>`${t}: ${e}`)).join("; ")}else n[t]=e;else n[t]=e})),n}),{})}function qi(t,e){return e.filter((e=>e.type===t.type.name)).filter((t=>t.attribute.rendered)).map((e=>e.attribute.renderHTML?e.attribute.renderHTML(t.attrs)||{}:{[e.name]:t.attrs[e.name]})).reduce(((t,e)=>Ki(t,e)),{})}function Ji(t){return"function"==typeof t}function Ui(t,e=void 0,...n){return Ji(t)?e?t.bind(e)(...n):t(...n):t}function Gi(t,e){return"style"in t?t:{...t,getAttrs:n=>{const r=t.getAttrs?t.getAttrs(n):t.attrs;if(!1===r)return!1;const o=e.reduce(((t,e)=>{const r=e.attribute.parseHTML?e.attribute.parseHTML(n):function(t){return"string"!=typeof t?t:t.match(/^[+-]?(?:\d*\.)?\d+$/)?Number(t):"true"===t||"false"!==t&&t}(n.getAttribute(e.name));return null==r?t:{...t,[e.name]:r}}),{});return{...r,...o}}}}function Yi(t){return Object.fromEntries(Object.entries(t).filter((([t,e])=>("attrs"!==t||!function(t={}){return 0===Object.keys(t).length&&t.constructor===Object}(e))&&null!=e)))}function Qi(t,e){return e.nodes[t]||e.marks[t]||null}function Xi(t,e){return Array.isArray(e)?e.some((e=>("string"==typeof e?e:e.name)===t.name)):e}const Zi=(t,e=500)=>{let n="";const r=t.parentOffset;return t.parent.nodesBetween(Math.max(0,r-e),r,((t,e,o,i)=>{var s,a;const l=(null===(a=(s=t.type.spec).toText)||void 0===a?void 0:a.call(s,{node:t,pos:e,parent:o,index:i}))||t.textContent||"%leaf%";n+=t.isAtom&&!t.isText?l:l.slice(0,Math.max(0,r-e))})),n};function ts(t){return"[object RegExp]"===Object.prototype.toString.call(t)}class es{constructor(t){this.find=t.find,this.handler=t.handler}}const ns=(t,e)=>{if(ts(e))return e.exec(t);const n=e(t);if(!n)return null;const r=[n.text];return r.index=n.index,r.input=t,r.data=n.data,n.replaceWith&&(n.text.includes(n.replaceWith)||console.warn('[tiptap warn]: "inputRuleMatch.replaceWith" must be part of "inputRuleMatch.text".'),r.push(n.replaceWith)),r};function rs(t){var e;const{editor:n,from:r,to:o,text:i,rules:s,plugin:a}=t,{view:l}=n;if(l.composing)return!1;const c=l.state.doc.resolve(r);if(c.parent.type.spec.code||null!==(e=c.nodeBefore||c.nodeAfter)&&void 0!==e&&e.marks.find((t=>t.type.spec.code)))return!1;let d=!1;const h=Zi(c)+i;return s.forEach((t=>{if(d)return;const e=ns(h,t.find);if(!e)return;const s=l.state.tr,c=$i({state:l.state,transaction:s}),u={from:r-(e[0].length-i.length),to:o},{commands:p,chain:f,can:m}=new Bi({editor:n,state:c});null===t.handler({state:c,range:u,match:e,commands:p,chain:f,can:m})||!s.steps.length||(s.setMeta(a,{transform:s,from:r,to:o,text:i}),l.dispatch(s),d=!0)})),d}function is(t){const{editor:e,rules:n}=t,r=new Ue({state:{init:()=>null,apply(t,o){const i=t.getMeta(r);if(i)return i;const s=t.getMeta("applyInputRules");return!!s&&setTimeout((()=>{const{from:t,text:o}=s,i=t+o.length;rs({editor:e,from:t,to:i,text:o,rules:n,plugin:r})})),t.selectionSet||t.docChanged?null:o}},props:{handleTextInput:(t,o,i,s)=>rs({editor:e,from:o,to:i,text:s,rules:n,plugin:r}),handleDOMEvents:{compositionend:t=>(setTimeout((()=>{const{$cursor:o}=t.state.selection;o&&rs({editor:e,from:o.pos,to:o.pos,text:"",rules:n,plugin:r})})),!1)},handleKeyDown(t,o){if("Enter"!==o.key)return!1;const{$cursor:i}=t.state.selection;return!!i&&rs({editor:e,from:i.pos,to:i.pos,text:"\n",rules:n,plugin:r})}},isInputRules:!0});return r}function ss(t){return"Object"===function(t){return Object.prototype.toString.call(t).slice(8,-1)}(t)&&(t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype)}function as(t,e){const n={...t};return ss(t)&&ss(e)&&Object.keys(e).forEach((r=>{ss(e[r])&&ss(t[r])?n[r]=as(t[r],e[r]):n[r]=e[r]})),n}class ls{constructor(t={}){this.type="mark",this.name="mark",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...t},this.name=this.config.name,t.defaultOptions&&Object.keys(t.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=Ui(_i(this,"addOptions",{name:this.name}))),this.storage=Ui(_i(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(t={}){return new ls(t)}configure(t={}){const e=this.extend({...this.config,addOptions:()=>as(this.options,t)});return e.name=this.name,e.parent=this.parent,e}extend(t={}){const e=new ls(t);return e.parent=this,this.child=e,e.name=t.name?t.name:e.parent.name,t.defaultOptions&&Object.keys(t.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${e.name}".`),e.options=Ui(_i(e,"addOptions",{name:e.name})),e.storage=Ui(_i(e,"addStorage",{name:e.name,options:e.options})),e}static handleExit({editor:t,mark:e}){const{tr:n}=t.state,r=t.state.selection.$from;if(r.pos===r.end()){const o=r.marks();if(!o.find((t=>(null==t?void 0:t.type.name)===e.name)))return!1;const i=o.find((t=>(null==t?void 0:t.type.name)===e.name));return i&&n.removeStoredMark(i),n.insertText(" ",r.pos),t.view.dispatch(n),!0}return!1}}class cs{constructor(t){this.find=t.find,this.handler=t.handler}}const ds=(t,e,n)=>{if(ts(e))return[...t.matchAll(e)];const r=e(t,n);return r?r.map((e=>{const n=[e.text];return n.index=e.index,n.input=t,n.data=e.data,e.replaceWith&&(e.text.includes(e.replaceWith)||console.warn('[tiptap warn]: "pasteRuleMatch.replaceWith" must be part of "pasteRuleMatch.text".'),n.push(e.replaceWith)),n})):[]};function hs(t){const{editor:e,rules:n}=t;let r=null,o=!1,i=!1,s=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,a=typeof DragEvent<"u"?new DragEvent("drop"):null;const l=({state:t,from:n,to:r,rule:o,pasteEvt:i})=>{const l=t.tr,c=$i({state:t,transaction:l});if(function(t){const{editor:e,state:n,from:r,to:o,rule:i,pasteEvent:s,dropEvent:a}=t,{commands:l,chain:c,can:d}=new Bi({editor:e,state:n}),h=[];return n.doc.nodesBetween(r,o,((t,e)=>{if(!t.isTextblock||t.type.spec.code)return;const u=Math.max(r,e),p=Math.min(o,e+t.content.size),f=t.textBetween(u-e,p-e,void 0,"");ds(f,i.find,s).forEach((t=>{if(void 0===t.index)return;const e=u+t.index+1,r=e+t[0].length,o={from:n.tr.mapping.map(e),to:n.tr.mapping.map(r)},p=i.handler({state:n,range:o,match:t,commands:l,chain:c,can:d,pasteEvent:s,dropEvent:a});h.push(p)}))})),h.every((t=>null!==t))}({editor:e,state:c,from:Math.max(n-1,0),to:r.b-1,rule:o,pasteEvent:i,dropEvent:a})&&l.steps.length)return a=typeof DragEvent<"u"?new DragEvent("drop"):null,s=typeof ClipboardEvent<"u"?new ClipboardEvent("paste"):null,l};return n.map((t=>new Ue({view(t){const e=e=>{var n;r=null!==(n=t.dom.parentElement)&&void 0!==n&&n.contains(e.target)?t.dom.parentElement:null};return window.addEventListener("dragstart",e),{destroy(){window.removeEventListener("dragstart",e)}}},props:{handleDOMEvents:{drop:(t,e)=>(i=r===t.dom.parentElement,a=e,!1),paste:(t,e)=>{var n;const r=null===(n=e.clipboardData)||void 0===n?void 0:n.getData("text/html");return s=e,o=!(null==r||!r.includes("data-pm-slice")),!1}}},appendTransaction:(e,n,r)=>{const a=e[0],c="paste"===a.getMeta("uiEvent")&&!o,d="drop"===a.getMeta("uiEvent")&&!i,h=a.getMeta("applyPasteRules"),u=!!h;if(!c&&!d&&!u)return;if(u){const{from:e,text:n}=h,o=e+n.length,i=(t=>{var e;const n=new ClipboardEvent("paste",{clipboardData:new DataTransfer});return null===(e=n.clipboardData)||void 0===e||e.setData("text/html",t),n})(n);return l({rule:t,state:r,from:e,to:{b:o},pasteEvt:i})}const p=n.doc.content.findDiffStart(r.doc.content),f=n.doc.content.findDiffEnd(r.doc.content);return function(t){return"number"==typeof t}(p)&&f&&p!==f.b?l({rule:t,state:r,from:p,to:f,pasteEvt:s}):void 0}})))}class us{constructor(t,e){this.splittableMarks=[],this.editor=e,this.extensions=us.resolve(t),this.schema=function(t,e){var n;const r=Hi(t),{nodeExtensions:o,markExtensions:i}=Vi(t),s=null===(n=o.find((t=>_i(t,"topNode"))))||void 0===n?void 0:n.name,a=Object.fromEntries(o.map((n=>{const o=r.filter((t=>t.type===n.name)),i={name:n.name,options:n.options,storage:n.storage,editor:e},s=Yi({...t.reduce(((t,e)=>{const r=_i(e,"extendNodeSchema",i);return{...t,...r?r(n):{}}}),{}),content:Ui(_i(n,"content",i)),marks:Ui(_i(n,"marks",i)),group:Ui(_i(n,"group",i)),inline:Ui(_i(n,"inline",i)),atom:Ui(_i(n,"atom",i)),selectable:Ui(_i(n,"selectable",i)),draggable:Ui(_i(n,"draggable",i)),code:Ui(_i(n,"code",i)),whitespace:Ui(_i(n,"whitespace",i)),defining:Ui(_i(n,"defining",i)),isolating:Ui(_i(n,"isolating",i)),attrs:Object.fromEntries(o.map((t=>{var e;return[t.name,{default:null===(e=null==t?void 0:t.attribute)||void 0===e?void 0:e.default}]})))}),a=Ui(_i(n,"parseHTML",i));a&&(s.parseDOM=a.map((t=>Gi(t,o))));const l=_i(n,"renderHTML",i);l&&(s.toDOM=t=>l({node:t,HTMLAttributes:qi(t,o)}));const c=_i(n,"renderText",i);return c&&(s.toText=c),[n.name,s]}))),l=Object.fromEntries(i.map((n=>{const o=r.filter((t=>t.type===n.name)),i={name:n.name,options:n.options,storage:n.storage,editor:e},s=Yi({...t.reduce(((t,e)=>{const r=_i(e,"extendMarkSchema",i);return{...t,...r?r(n):{}}}),{}),inclusive:Ui(_i(n,"inclusive",i)),excludes:Ui(_i(n,"excludes",i)),group:Ui(_i(n,"group",i)),spanning:Ui(_i(n,"spanning",i)),code:Ui(_i(n,"code",i)),attrs:Object.fromEntries(o.map((t=>{var e;return[t.name,{default:null===(e=null==t?void 0:t.attribute)||void 0===e?void 0:e.default}]})))}),a=Ui(_i(n,"parseHTML",i));a&&(s.parseDOM=a.map((t=>Gi(t,o))));const l=_i(n,"renderHTML",i);return l&&(s.toDOM=t=>l({mark:t,HTMLAttributes:qi(t,o)})),[n.name,s]})));return new St({topNode:s,nodes:a,marks:l})}(this.extensions,e),this.setupExtensions()}static resolve(t){const e=us.sort(us.flatten(t)),n=function(t){const e=t.filter(((e,n)=>t.indexOf(e)!==n));return Array.from(new Set(e))}(e.map((t=>t.name)));return n.length&&console.warn(`[tiptap warn]: Duplicate extension names found: [${n.map((t=>`'${t}'`)).join(", ")}]. This can lead to issues.`),e}static flatten(t){return t.map((t=>{const e=_i(t,"addExtensions",{name:t.name,options:t.options,storage:t.storage});return e?[t,...this.flatten(e())]:t})).flat(10)}static sort(t){return t.sort(((t,e)=>{const n=_i(t,"priority")||100,r=_i(e,"priority")||100;return n>r?-1:n<r?1:0}))}get commands(){return this.extensions.reduce(((t,e)=>{const n=_i(e,"addCommands",{name:e.name,options:e.options,storage:e.storage,editor:this.editor,type:Qi(e.name,this.schema)});return n?{...t,...n()}:t}),{})}get plugins(){const{editor:t}=this,e=us.sort([...this.extensions].reverse()),n=[],r=[],o=e.map((e=>{const o={name:e.name,options:e.options,storage:e.storage,editor:t,type:Qi(e.name,this.schema)},i=[],s=_i(e,"addKeyboardShortcuts",o);let a={};if("mark"===e.type&&_i(e,"exitable",o)&&(a.ArrowRight=()=>ls.handleExit({editor:t,mark:e})),s){const e=Object.fromEntries(Object.entries(s()).map((([e,n])=>[e,()=>n({editor:t})])));a={...a,...e}}const l=new Ue({props:{handleKeyDown:Si(a)}});i.push(l);const c=_i(e,"addInputRules",o);Xi(e,t.options.enableInputRules)&&c&&n.push(...c());const d=_i(e,"addPasteRules",o);Xi(e,t.options.enablePasteRules)&&d&&r.push(...d());const h=_i(e,"addProseMirrorPlugins",o);if(h){const t=h();i.push(...t)}return i})).flat();return[is({editor:t,rules:n}),...hs({editor:t,rules:r}),...o]}get attributes(){return Hi(this.extensions)}get nodeViews(){const{editor:t}=this,{nodeExtensions:e}=Vi(this.extensions);return Object.fromEntries(e.filter((t=>!!_i(t,"addNodeView"))).map((e=>{const n=this.attributes.filter((t=>t.type===e.name)),r={name:e.name,options:e.options,storage:e.storage,editor:t,type:Wi(e.name,this.schema)},o=_i(e,"addNodeView",r);if(!o)return[];return[e.name,(r,i,s,a,l)=>{const c=qi(r,n);return o()({node:r,view:i,getPos:s,decorations:a,innerDecorations:l,editor:t,extension:e,HTMLAttributes:c})}]})))}setupExtensions(){this.extensions.forEach((t=>{var e;this.editor.extensionStorage[t.name]=t.storage;const n={name:t.name,options:t.options,storage:t.storage,editor:this.editor,type:Qi(t.name,this.schema)};"mark"===t.type&&(null===(e=Ui(_i(t,"keepOnSplit",n)))||void 0===e||e)&&this.splittableMarks.push(t.name);const r=_i(t,"onBeforeCreate",n),o=_i(t,"onCreate",n),i=_i(t,"onUpdate",n),s=_i(t,"onSelectionUpdate",n),a=_i(t,"onTransaction",n),l=_i(t,"onFocus",n),c=_i(t,"onBlur",n),d=_i(t,"onDestroy",n);r&&this.editor.on("beforeCreate",r),o&&this.editor.on("create",o),i&&this.editor.on("update",i),s&&this.editor.on("selectionUpdate",s),a&&this.editor.on("transaction",a),l&&this.editor.on("focus",l),c&&this.editor.on("blur",c),d&&this.editor.on("destroy",d)}))}}class ps{constructor(t={}){this.type="extension",this.name="extension",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...t},this.name=this.config.name,t.defaultOptions&&Object.keys(t.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=Ui(_i(this,"addOptions",{name:this.name}))),this.storage=Ui(_i(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(t={}){return new ps(t)}configure(t={}){const e=this.extend({...this.config,addOptions:()=>as(this.options,t)});return e.name=this.name,e.parent=this.parent,e}extend(t={}){const e=new ps({...this.config,...t});return e.parent=this,this.child=e,e.name=t.name?t.name:e.parent.name,t.defaultOptions&&Object.keys(t.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${e.name}".`),e.options=Ui(_i(e,"addOptions",{name:e.name})),e.storage=Ui(_i(e,"addStorage",{name:e.name,options:e.options})),e}}function fs(t,e,n){const{from:r,to:o}=e,{blockSeparator:i="\n\n",textSerializers:s={}}=n||{};let a="";return t.nodesBetween(r,o,((t,n,l,c)=>{var d;t.isBlock&&n>r&&(a+=i);const h=null==s?void 0:s[t.type.name];if(h)return l&&(a+=h({node:t,pos:n,parent:l,index:c,range:e})),!1;t.isText&&(a+=null===(d=null==t?void 0:t.text)||void 0===d?void 0:d.slice(Math.max(r,n)-n,o-n))})),a}function ms(t){return Object.fromEntries(Object.entries(t.nodes).filter((([,t])=>t.spec.toText)).map((([t,e])=>[t,e.spec.toText])))}const gs=ps.create({name:"clipboardTextSerializer",addOptions:()=>({blockSeparator:void 0}),addProseMirrorPlugins(){return[new Ue({key:new Qe("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:t}=this,{state:e,schema:n}=t,{doc:r,selection:o}=e,{ranges:i}=o,s=Math.min(...i.map((t=>t.$from.pos))),a=Math.max(...i.map((t=>t.$to.pos))),l=ms(n);return fs(r,{from:s,to:a},{...void 0!==this.options.blockSeparator?{blockSeparator:this.options.blockSeparator}:{},textSerializers:l})}}})]}});function ys(t,e,n={strict:!0}){const r=Object.keys(e);return!r.length||r.every((r=>n.strict?e[r]===t[r]:ts(e[r])?e[r].test(t[r]):e[r]===t[r]))}function bs(t,e,n={}){return t.find((t=>t.type===e&&ys(t.attrs,n)))}function vs(t,e,n={}){return!!bs(t,e,n)}function ws(t,e,n={}){if(!t||!e)return;let r=t.parent.childAfter(t.parentOffset);if(t.parentOffset===r.offset&&0!==r.offset&&(r=t.parent.childBefore(t.parentOffset)),!r.node)return;const o=bs([...r.node.marks],e,n);if(!o)return;let i=r.index,s=t.start()+r.offset,a=i+1,l=s+r.node.nodeSize;for(bs([...r.node.marks],e,n);i>0&&o.isInSet(t.parent.child(i-1).marks);)i-=1,s-=t.parent.child(i).nodeSize;for(;a<t.parent.childCount&&vs([...t.parent.child(a).marks],e,n);)l+=t.parent.child(a).nodeSize,a+=1;return{from:s,to:l}}function ks(t,e){if("string"==typeof t){if(!e.marks[t])throw Error(`There is no mark type named '${t}'. Maybe you forgot to add the extension?`);return e.marks[t]}return t}function xs(t){return t instanceof Ie}function Ss(t=0,e=0,n=0){return Math.min(Math.max(t,e),n)}function Os(t,e=null){if(!e)return null;const n=Ne.atStart(t),r=Ne.atEnd(t);if("start"===e||!0===e)return n;if("end"===e)return r;const o=n.from,i=r.to;return"all"===e?Ie.create(t,Ss(0,o,i),Ss(t.content.size,o,i)):Ie.create(t,Ss(e,o,i),Ss(e,o,i))}function Cs(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}const Ms=t=>{const e=t.childNodes;for(let n=e.length-1;n>=0;n-=1){const r=e[n];3===r.nodeType&&r.nodeValue&&/^(\n\s\s|\n)$/.test(r.nodeValue)?t.removeChild(r):1===r.nodeType&&Ms(r)}return t};function Ts(t){const e=`<body>${t}</body>`,n=(new window.DOMParser).parseFromString(e,"text/html").body;return Ms(n)}function Es(t,e,n){n={slice:!0,parseOptions:{},...n};const r="string"==typeof t;if("object"==typeof t&&null!==t)try{if(Array.isArray(t)&&t.length>0)return L.fromArray(t.map((t=>e.nodeFromJSON(t))));const r=e.nodeFromJSON(t);return n.errorOnInvalidContent&&r.check(),r}catch(r){if(n.errorOnInvalidContent)throw new Error("[tiptap error]: Invalid JSON content",{cause:r});return console.warn("[tiptap warn]: Invalid content.","Passed value:",t,"Error:",r),Es("",e,n)}if(r){if(n.errorOnInvalidContent){let r=!1,o="";const i=new St({topNode:e.spec.topNode,marks:e.spec.marks,nodes:e.spec.nodes.append({__tiptap__private__unknown__catch__all__node:{content:"inline*",group:"block",parseDOM:[{tag:"*",getAttrs:t=>(r=!0,o="string"==typeof t?t:t.outerHTML,null)}]}})});if(n.slice?Ct.fromSchema(i).parseSlice(Ts(t),n.parseOptions):Ct.fromSchema(i).parse(Ts(t),n.parseOptions),n.errorOnInvalidContent&&r)throw new Error("[tiptap error]: Invalid HTML content",{cause:new Error(`Invalid element found: ${o}`)})}const r=Ct.fromSchema(e);return n.slice?r.parseSlice(Ts(t),n.parseOptions).content:r.parse(Ts(t),n.parseOptions)}return Es("",e,n)}function Ns(){return typeof navigator<"u"&&/Mac/.test(navigator.platform)}function As(t,e,n={}){const{from:r,to:o,empty:i}=t.selection,s=e?Wi(e,t.schema):null,a=[];t.doc.nodesBetween(r,o,((t,e)=>{if(t.isText)return;const n=Math.max(r,e),i=Math.min(o,e+t.nodeSize);a.push({node:t,from:n,to:i})}));const l=o-r,c=a.filter((t=>!s||s.name===t.node.type.name)).filter((t=>ys(t.node.attrs,n,{strict:!1})));return i?!!c.length:c.reduce(((t,e)=>t+e.to-e.from),0)>=l}function Ds(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function Rs(t,e){const n="string"==typeof e?[e]:e;return Object.keys(t).reduce(((e,r)=>(n.includes(r)||(e[r]=t[r]),e)),{})}function Is(t,e,n={},r={}){return Es(t,e,{slice:!1,parseOptions:n,errorOnInvalidContent:r.errorOnInvalidContent})}function Ls(t,e){const n=ks(e,t.schema),{from:r,to:o,empty:i}=t.selection,s=[];i?(t.storedMarks&&s.push(...t.storedMarks),s.push(...t.selection.$head.marks())):t.doc.nodesBetween(r,o,(t=>{s.push(...t.marks)}));const a=s.find((t=>t.type.name===n.name));return a?{...a.attrs}:{}}function Ps(t){return e=>function(t,e){for(let n=t.depth;n>0;n-=1){const r=t.node(n);if(e(r))return{pos:n>0?t.before(n):0,start:t.start(n),depth:n,node:r}}}(e.$from,t)}function js(t,e){const n=Ds("string"==typeof e?e:e.name,t.schema);return"node"===n?function(t,e){const n=Wi(e,t.schema),{from:r,to:o}=t.selection,i=[];t.doc.nodesBetween(r,o,(t=>{i.push(t)}));const s=i.reverse().find((t=>t.type.name===n.name));return s?{...s.attrs}:{}}(t,e):"mark"===n?Ls(t,e):{}}function zs(t){const e=function(t,e=JSON.stringify){const n={};return t.filter((t=>{const r=e(t);return!Object.prototype.hasOwnProperty.call(n,r)&&(n[r]=!0)}))}(t);return 1===e.length?e:e.filter(((t,n)=>!e.filter(((t,e)=>e!==n)).some((e=>t.oldRange.from>=e.oldRange.from&&t.oldRange.to<=e.oldRange.to&&t.newRange.from>=e.newRange.from&&t.newRange.to<=e.newRange.to))))}function $s(t,e,n){const r=[];return t===e?n.resolve(t).marks().forEach((e=>{const o=ws(n.resolve(t),e.type);o&&r.push({mark:e,...o})})):n.nodesBetween(t,e,((t,e)=>{!t||void 0===(null==t?void 0:t.nodeSize)||r.push(...t.marks.map((n=>({from:e,to:e+t.nodeSize,mark:n}))))})),r}function Bs(t,e,n){return Object.fromEntries(Object.entries(n).filter((([n])=>{const r=t.find((t=>t.type===e&&t.name===n));return!!r&&r.attribute.keepOnSplit})))}function Fs(t,e,n={}){const{empty:r,ranges:o}=t.selection,i=e?ks(e,t.schema):null;if(r)return!!(t.storedMarks||t.selection.$from.marks()).filter((t=>!i||i.name===t.type.name)).find((t=>ys(t.attrs,n,{strict:!1})));let s=0;const a=[];if(o.forEach((({$from:e,$to:n})=>{const r=e.pos,o=n.pos;t.doc.nodesBetween(r,o,((t,e)=>{if(!t.isText&&!t.marks.length)return;const n=Math.max(r,e),i=Math.min(o,e+t.nodeSize);s+=i-n,a.push(...t.marks.map((t=>({mark:t,from:n,to:i}))))}))})),0===s)return!1;const l=a.filter((t=>!i||i.name===t.mark.type.name)).filter((t=>ys(t.mark.attrs,n,{strict:!1}))).reduce(((t,e)=>t+e.to-e.from),0),c=a.filter((t=>!i||t.mark.type!==i&&t.mark.type.excludes(i))).reduce(((t,e)=>t+e.to-e.from),0);return(l>0?l+c:l)>=s}function _s(t,e){const{nodeExtensions:n}=Vi(e),r=n.find((e=>e.name===t));if(!r)return!1;const o=Ui(_i(r,"group",{name:r.name,options:r.options,storage:r.storage}));return"string"==typeof o&&o.split(" ").includes("list")}function Vs(t,{checkChildren:e=!0,ignoreWhitespace:n=!1}={}){var r;if(n){if("hardBreak"===t.type.name)return!0;if(t.isText)return/^\s*$/m.test(null!==(r=t.text)&&void 0!==r?r:"")}if(t.isText)return!t.text;if(t.isAtom||t.isLeaf)return!1;if(0===t.content.childCount)return!0;if(e){let r=!0;return t.content.forEach((t=>{!1!==r&&(Vs(t,{ignoreWhitespace:n,checkChildren:e})||(r=!1))})),r}return!1}function Hs(t,e){const n=t.storedMarks||t.selection.$to.parentOffset&&t.selection.$from.marks();if(n){const r=n.filter((t=>null==e?void 0:e.includes(t.type.name)));t.tr.ensureMarks(r)}}const Ws=(t,e)=>{const n=Ps((t=>t.type===e))(t.selection);if(!n)return!0;const r=t.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(void 0===r)return!0;const o=t.doc.nodeAt(r);return n.node.type===(null==o?void 0:o.type)&&de(t.doc,n.pos)&&t.join(n.pos),!0},Ks=(t,e)=>{const n=Ps((t=>t.type===e))(t.selection);if(!n)return!0;const r=t.doc.resolve(n.start).after(n.depth);if(void 0===r)return!0;const o=t.doc.nodeAt(r);return n.node.type===(null==o?void 0:o.type)&&de(t.doc,r)&&t.join(r),!0};var qs=Object.freeze({__proto__:null,blur:()=>({editor:t,view:e})=>(requestAnimationFrame((()=>{var n;t.isDestroyed||(e.dom.blur(),null===(n=null==window?void 0:window.getSelection())||void 0===n||n.removeAllRanges())})),!0),clearContent:(t=!1)=>({commands:e})=>e.setContent("",t),clearNodes:()=>({state:t,tr:e,dispatch:n})=>{const{selection:r}=e,{ranges:o}=r;return n&&o.forEach((({$from:n,$to:r})=>{t.doc.nodesBetween(n.pos,r.pos,((t,n)=>{if(t.type.isText)return;const{doc:r,mapping:o}=e,i=r.resolve(o.map(n)),s=r.resolve(o.map(n+t.nodeSize)),a=i.blockRange(s);if(!a)return;const l=se(a);if(t.type.isTextblock){const{defaultType:t}=i.parent.contentMatchAt(i.index());e.setNodeMarkup(a.start,t)}(l||0===l)&&e.lift(a,l)}))})),!0},command:t=>e=>t(e),createParagraphNear:()=>({state:t,dispatch:e})=>((t,e)=>{let n=t.selection,{$from:r,$to:o}=n;if(n instanceof ze||r.parent.inlineContent||o.parent.inlineContent)return!1;let i=Ai(o.parent.contentMatchAt(o.indexAfter()));if(!i||!i.isTextblock)return!1;if(e){let n=(!r.parentOffset&&o.index()<o.parent.childCount?r:o).pos,s=t.tr.insert(n,i.createAndFill());s.setSelection(Ie.create(s.doc,n+1)),e(s.scrollIntoView())}return!0})(t,e),cut:(t,e)=>({editor:n,tr:r})=>{const{state:o}=n,i=o.doc.slice(t.from,t.to);r.deleteRange(t.from,t.to);const s=r.mapping.map(e);return r.insert(s,i.content),r.setSelection(new Ie(r.doc.resolve(s-1))),!0},deleteCurrentNode:()=>({tr:t,dispatch:e})=>{const{selection:n}=t,r=n.$anchor.node();if(r.content.size>0)return!1;const o=t.selection.$anchor;for(let n=o.depth;n>0;n-=1)if(o.node(n).type===r.type){if(e){const e=o.before(n),r=o.after(n);t.delete(e,r).scrollIntoView()}return!0}return!1},deleteNode:t=>({tr:e,state:n,dispatch:r})=>{const o=Wi(t,n.schema),i=e.selection.$anchor;for(let t=i.depth;t>0;t-=1)if(i.node(t).type===o){if(r){const n=i.before(t),r=i.after(t);e.delete(n,r).scrollIntoView()}return!0}return!1},deleteRange:t=>({tr:e,dispatch:n})=>{const{from:r,to:o}=t;return n&&e.delete(r,o),!0},deleteSelection:()=>({state:t,dispatch:e})=>((t,e)=>!t.selection.empty&&(e&&e(t.tr.deleteSelection().scrollIntoView()),!0))(t,e),enter:()=>({commands:t})=>t.keyboardShortcut("Enter"),exitCode:()=>({state:t,dispatch:e})=>((t,e)=>{let{$head:n,$anchor:r}=t.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let o=n.node(-1),i=n.indexAfter(-1),s=Ai(o.contentMatchAt(i));if(!s||!o.canReplaceWith(i,i,s))return!1;if(e){let r=n.after(),o=t.tr.replaceWith(r,r,s.createAndFill());o.setSelection(Ne.near(o.doc.resolve(r),1)),e(o.scrollIntoView())}return!0})(t,e),extendMarkRange:(t,e={})=>({tr:n,state:r,dispatch:o})=>{const i=ks(t,r.schema),{doc:s,selection:a}=n,{$from:l,from:c,to:d}=a;if(o){const t=ws(l,i,e);if(t&&t.from<=c&&t.to>=d){const e=Ie.create(s,t.from,t.to);n.setSelection(e)}}return!0},first:t=>e=>{const n="function"==typeof t?t(e):t;for(let t=0;t<n.length;t+=1)if(n[t](e))return!0;return!1},focus:(t=null,e={})=>({editor:n,view:r,tr:o,dispatch:i})=>{e={scrollIntoView:!0,...e};const s=()=>{Cs()&&r.dom.focus(),requestAnimationFrame((()=>{n.isDestroyed||(r.focus(),null!=e&&e.scrollIntoView&&n.commands.scrollIntoView())}))};if(r.hasFocus()&&null===t||!1===t)return!0;if(i&&null===t&&!xs(n.state.selection))return s(),!0;const a=Os(o.doc,t)||n.state.selection,l=n.state.selection.eq(a);return i&&(l||o.setSelection(a),l&&o.storedMarks&&o.setStoredMarks(o.storedMarks),s()),!0},forEach:(t,e)=>n=>t.every(((t,r)=>e(t,{...n,index:r}))),insertContent:(t,e)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},t,e),insertContentAt:(t,e,n)=>({tr:r,dispatch:o,editor:i})=>{var s;if(o){let o;n={parseOptions:{},updateSelection:!0,applyInputRules:!1,applyPasteRules:!1,...n};try{o=Es(e,i.schema,{parseOptions:{preserveWhitespace:"full",...n.parseOptions},errorOnInvalidContent:null!==(s=n.errorOnInvalidContent)&&void 0!==s?s:i.options.enableContentCheck})}catch(t){return i.emit("contentError",{editor:i,error:t,disableCollaboration:()=>{console.error("[tiptap error]: Unable to disable collaboration at this point in time")}}),!1}let a,{from:l,to:c}="number"==typeof t?{from:t,to:t}:{from:t.from,to:t.to},d=!0,h=!0;if(((t=>!("type"in t))(o)?o:[o]).forEach((t=>{t.check(),d=!!d&&(t.isText&&0===t.marks.length),h=!!h&&t.isBlock})),l===c&&h){const{parent:t}=r.doc.resolve(l);t.isTextblock&&!t.type.spec.code&&!t.childCount&&(l-=1,c+=1)}d?(a=Array.isArray(e)?e.map((t=>t.text||"")).join(""):"object"==typeof e&&e&&e.text?e.text:e,r.insertText(a,l,c)):(a=o,r.replaceWith(l,c,a)),n.updateSelection&&function(t,e,n){const r=t.steps.length-1;if(r<e)return;const o=t.steps[r];if(!(o instanceof ee||o instanceof ne))return;const i=t.mapping.maps[r];let s=0;i.forEach(((t,e,n,r)=>{0===s&&(s=r)})),t.setSelection(Ne.near(t.doc.resolve(s),n))}(r,r.steps.length-1,-1),n.applyInputRules&&r.setMeta("applyInputRules",{from:l,text:a}),n.applyPasteRules&&r.setMeta("applyPasteRules",{from:l,text:a})}return!0},joinBackward:()=>({state:t,dispatch:e})=>((t,e,n)=>{let r=Oi(t,n);if(!r)return!1;let o=Ti(r);if(!o){let n=r.blockRange(),o=n&&se(n);return null!=o&&(e&&e(t.tr.lift(n,o).scrollIntoView()),!0)}let i=o.nodeBefore;if(Di(t,o,e,-1))return!0;if(0==r.parent.content.size&&(Mi(i,"end")||Pe.isSelectable(i)))for(let n=r.depth;;n--){let s=pe(t.doc,r.before(n),r.after(n),F.empty);if(s&&s.slice.size<s.to-s.from){if(e){let n=t.tr.step(s);n.setSelection(Mi(i,"end")?Ne.findFrom(n.doc.resolve(n.mapping.map(o.pos,-1)),-1):Pe.create(n.doc,o.pos-i.nodeSize)),e(n.scrollIntoView())}return!0}if(1==n||r.node(n-1).childCount>1)break}return!(!i.isAtom||o.depth!=r.depth-1||(e&&e(t.tr.delete(o.pos-i.nodeSize,o.pos).scrollIntoView()),0))})(t,e),joinDown:()=>({state:t,dispatch:e})=>((t,e)=>{let n,r=t.selection;if(r instanceof Pe){if(r.node.isTextblock||!de(t.doc,r.to))return!1;n=r.to}else if(n=ue(t.doc,r.to,1),null==n)return!1;return e&&e(t.tr.join(n).scrollIntoView()),!0})(t,e),joinForward:()=>({state:t,dispatch:e})=>((t,e,n)=>{let r=Ei(t,n);if(!r)return!1;let o=Ni(r);if(!o)return!1;let i=o.nodeAfter;if(Di(t,o,e,1))return!0;if(0==r.parent.content.size&&(Mi(i,"start")||Pe.isSelectable(i))){let n=pe(t.doc,r.before(),r.after(),F.empty);if(n&&n.slice.size<n.to-n.from){if(e){let r=t.tr.step(n);r.setSelection(Mi(i,"start")?Ne.findFrom(r.doc.resolve(r.mapping.map(o.pos)),1):Pe.create(r.doc,r.mapping.map(o.pos))),e(r.scrollIntoView())}return!0}}return!(!i.isAtom||o.depth!=r.depth-1||(e&&e(t.tr.delete(o.pos,o.pos+i.nodeSize).scrollIntoView()),0))})(t,e),joinItemBackward:()=>({state:t,dispatch:e,tr:n})=>{try{const r=ue(t.doc,t.selection.$from.pos,-1);return null!=r&&(n.join(r,2),e&&e(n),!0)}catch{return!1}},joinItemForward:()=>({state:t,dispatch:e,tr:n})=>{try{const r=ue(t.doc,t.selection.$from.pos,1);return null!=r&&(n.join(r,2),e&&e(n),!0)}catch{return!1}},joinTextblockBackward:()=>({state:t,dispatch:e})=>((t,e,n)=>{let r=Oi(t,n);if(!r)return!1;let o=Ti(r);return!!o&&Ci(t,o,e)})(t,e),joinTextblockForward:()=>({state:t,dispatch:e})=>((t,e,n)=>{let r=Ei(t,n);if(!r)return!1;let o=Ni(r);return!!o&&Ci(t,o,e)})(t,e),joinUp:()=>({state:t,dispatch:e})=>((t,e)=>{let n,r=t.selection,o=r instanceof Pe;if(o){if(r.node.isTextblock||!de(t.doc,r.from))return!1;n=r.from}else if(n=ue(t.doc,r.from,-1),null==n)return!1;if(e){let r=t.tr.join(n);o&&r.setSelection(Pe.create(r.doc,n-t.doc.resolve(n).nodeBefore.nodeSize)),e(r.scrollIntoView())}return!0})(t,e),keyboardShortcut:t=>({editor:e,view:n,tr:r,dispatch:o})=>{const i=function(t){const e=t.split(/-(?!$)/);let n,r,o,i,s=e[e.length-1];"Space"===s&&(s=" ");for(let t=0;t<e.length-1;t+=1){const s=e[t];if(/^(cmd|meta|m)$/i.test(s))i=!0;else if(/^a(lt)?$/i.test(s))n=!0;else if(/^(c|ctrl|control)$/i.test(s))r=!0;else if(/^s(hift)?$/i.test(s))o=!0;else{if(!/^mod$/i.test(s))throw new Error(`Unrecognized modifier name: ${s}`);Cs()||Ns()?i=!0:r=!0}}return n&&(s=`Alt-${s}`),r&&(s=`Ctrl-${s}`),i&&(s=`Meta-${s}`),o&&(s=`Shift-${s}`),s}(t).split(/-(?!$)/),s=i.find((t=>!["Alt","Ctrl","Meta","Shift"].includes(t))),a=new KeyboardEvent("keydown",{key:"Space"===s?" ":s,altKey:i.includes("Alt"),ctrlKey:i.includes("Ctrl"),metaKey:i.includes("Meta"),shiftKey:i.includes("Shift"),bubbles:!0,cancelable:!0}),l=e.captureTransaction((()=>{n.someProp("handleKeyDown",(t=>t(n,a)))}));return null==l||l.steps.forEach((t=>{const e=t.map(r.mapping);e&&o&&r.maybeStep(e)})),!0},lift:(t,e={})=>({state:n,dispatch:r})=>!!As(n,Wi(t,n.schema),e)&&((t,e)=>{let{$from:n,$to:r}=t.selection,o=n.blockRange(r),i=o&&se(o);return null!=i&&(e&&e(t.tr.lift(o,i).scrollIntoView()),!0)})(n,r),liftEmptyBlock:()=>({state:t,dispatch:e})=>((t,e)=>{let{$cursor:n}=t.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let r=n.before();if(ce(t.doc,r))return e&&e(t.tr.split(r).scrollIntoView()),!0}let r=n.blockRange(),o=r&&se(r);return null!=o&&(e&&e(t.tr.lift(r,o).scrollIntoView()),!0)})(t,e),liftListItem:t=>({state:e,dispatch:n})=>zi(Wi(t,e.schema))(e,n),newlineInCode:()=>({state:t,dispatch:e})=>((t,e)=>{let{$head:n,$anchor:r}=t.selection;return!(!n.parent.type.spec.code||!n.sameParent(r)||(e&&e(t.tr.insertText("\n").scrollIntoView()),0))})(t,e),resetAttributes:(t,e)=>({tr:n,state:r,dispatch:o})=>{let i=null,s=null;const a=Ds("string"==typeof t?t:t.name,r.schema);return!!a&&("node"===a&&(i=Wi(t,r.schema)),"mark"===a&&(s=ks(t,r.schema)),o&&n.selection.ranges.forEach((t=>{r.doc.nodesBetween(t.$from.pos,t.$to.pos,((t,r)=>{i&&i===t.type&&n.setNodeMarkup(r,void 0,Rs(t.attrs,e)),s&&t.marks.length&&t.marks.forEach((o=>{s===o.type&&n.addMark(r,r+t.nodeSize,s.create(Rs(o.attrs,e)))}))}))})),!0)},scrollIntoView:()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),selectAll:()=>({tr:t,commands:e})=>e.setTextSelection({from:0,to:t.doc.content.size}),selectNodeBackward:()=>({state:t,dispatch:e})=>((t,e,n)=>{let{$head:r,empty:o}=t.selection,i=r;if(!o)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("backward",t):r.parentOffset>0)return!1;i=Ti(r)}let s=i&&i.nodeBefore;return!(!s||!Pe.isSelectable(s)||(e&&e(t.tr.setSelection(Pe.create(t.doc,i.pos-s.nodeSize)).scrollIntoView()),0))})(t,e),selectNodeForward:()=>({state:t,dispatch:e})=>((t,e,n)=>{let{$head:r,empty:o}=t.selection,i=r;if(!o)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("forward",t):r.parentOffset<r.parent.content.size)return!1;i=Ni(r)}let s=i&&i.nodeAfter;return!(!s||!Pe.isSelectable(s)||(e&&e(t.tr.setSelection(Pe.create(t.doc,i.pos)).scrollIntoView()),0))})(t,e),selectParentNode:()=>({state:t,dispatch:e})=>((t,e)=>{let n,{$from:r,to:o}=t.selection,i=r.sharedDepth(o);return 0!=i&&(n=r.before(i),e&&e(t.tr.setSelection(Pe.create(t.doc,n))),!0)})(t,e),selectTextblockEnd:()=>({state:t,dispatch:e})=>Li(t,e),selectTextblockStart:()=>({state:t,dispatch:e})=>Ii(t,e),setContent:(t,e=!1,n={},r={})=>({editor:o,tr:i,dispatch:s,commands:a})=>{var l,c;const{doc:d}=i;if("full"!==n.preserveWhitespace){const a=Is(t,o.schema,n,{errorOnInvalidContent:null!==(l=r.errorOnInvalidContent)&&void 0!==l?l:o.options.enableContentCheck});return s&&i.replaceWith(0,d.content.size,a).setMeta("preventUpdate",!e),!0}return s&&i.setMeta("preventUpdate",!e),a.insertContentAt({from:0,to:d.content.size},t,{parseOptions:n,errorOnInvalidContent:null!==(c=r.errorOnInvalidContent)&&void 0!==c?c:o.options.enableContentCheck})},setMark:(t,e={})=>({tr:n,state:r,dispatch:o})=>{const{selection:i}=n,{empty:s,ranges:a}=i,l=ks(t,r.schema);if(o)if(s){const t=Ls(r,l);n.addStoredMark(l.create({...t,...e}))}else a.forEach((t=>{const o=t.$from.pos,i=t.$to.pos;r.doc.nodesBetween(o,i,((t,r)=>{const s=Math.max(r,o),a=Math.min(r+t.nodeSize,i);t.marks.find((t=>t.type===l))?t.marks.forEach((t=>{l===t.type&&n.addMark(s,a,l.create({...t.attrs,...e}))})):n.addMark(s,a,l.create(e))}))}));return function(t,e,n){var r;const{selection:o}=e;let i=null;if(xs(o)&&(i=o.$cursor),i){const e=null!==(r=t.storedMarks)&&void 0!==r?r:i.marks();return!!n.isInSet(e)||!e.some((t=>t.type.excludes(n)))}const{ranges:s}=o;return s.some((({$from:e,$to:r})=>{let o=0===e.depth&&t.doc.inlineContent&&t.doc.type.allowsMarkType(n);return t.doc.nodesBetween(e.pos,r.pos,((t,e,r)=>{if(o)return!1;if(t.isInline){const e=!r||r.type.allowsMarkType(n),i=!!n.isInSet(t.marks)||!t.marks.some((t=>t.type.excludes(n)));o=e&&i}return!o})),o}))}(r,n,l)},setMeta:(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),setNode:(t,e={})=>({state:n,dispatch:r,chain:o})=>{const i=Wi(t,n.schema);return i.isTextblock?o().command((({commands:t})=>!!Pi(i,e)(n)||t.clearNodes())).command((({state:t})=>Pi(i,e)(t,r))).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},setNodeSelection:t=>({tr:e,dispatch:n})=>{if(n){const{doc:n}=e,r=Ss(t,0,n.content.size),o=Pe.create(n,r);e.setSelection(o)}return!0},setTextSelection:t=>({tr:e,dispatch:n})=>{if(n){const{doc:n}=e,{from:r,to:o}="number"==typeof t?{from:t,to:t}:t,i=Ie.atStart(n).from,s=Ie.atEnd(n).to,a=Ss(r,i,s),l=Ss(o,i,s),c=Ie.create(n,a,l);e.setSelection(c)}return!0},sinkListItem:t=>({state:e,dispatch:n})=>function(t){return function(e,n){let{$from:r,$to:o}=e.selection,i=r.blockRange(o,(e=>e.childCount>0&&e.firstChild.type==t));if(!i)return!1;let s=i.startIndex;if(0==s)return!1;let a=i.parent,l=a.child(s-1);if(l.type!=t)return!1;if(n){let r=l.lastChild&&l.lastChild.type==a.type,o=L.from(r?t.create():null),s=new F(L.from(t.create(null,L.from(a.type.create(null,o)))),r?3:1,0),c=i.start,d=i.end;n(e.tr.step(new ne(c-(r?3:1),d,c,d,s,1,!0)).scrollIntoView())}return!0}}(Wi(t,e.schema))(e,n),splitBlock:({keepMarks:t=!0}={})=>({tr:e,state:n,dispatch:r,editor:o})=>{const{selection:i,doc:s}=e,{$from:a,$to:l}=i,c=Bs(o.extensionManager.attributes,a.node().type.name,a.node().attrs);if(i instanceof Pe&&i.node.isBlock)return!(!a.parentOffset||!ce(s,a.pos))&&(r&&(t&&Hs(n,o.extensionManager.splittableMarks),e.split(a.pos).scrollIntoView()),!0);if(!a.parent.isBlock)return!1;const d=l.parentOffset===l.parent.content.size,h=0===a.depth?void 0:function(t){for(let e=0;e<t.edgeCount;e+=1){const{type:n}=t.edge(e);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}(a.node(-1).contentMatchAt(a.indexAfter(-1)));let u=d&&h?[{type:h,attrs:c}]:void 0,p=ce(e.doc,e.mapping.map(a.pos),1,u);if(!u&&!p&&ce(e.doc,e.mapping.map(a.pos),1,h?[{type:h}]:void 0)&&(p=!0,u=h?[{type:h,attrs:c}]:void 0),r){if(p&&(i instanceof Ie&&e.deleteSelection(),e.split(e.mapping.map(a.pos),1,u),h&&!d&&!a.parentOffset&&a.parent.type!==h)){const t=e.mapping.map(a.before()),n=e.doc.resolve(t);a.node(-1).canReplaceWith(n.index(),n.index()+1,h)&&e.setNodeMarkup(e.mapping.map(a.before()),h)}t&&Hs(n,o.extensionManager.splittableMarks),e.scrollIntoView()}return p},splitListItem:(t,e={})=>({tr:n,state:r,dispatch:o,editor:i})=>{var s;const a=Wi(t,r.schema),{$from:l,$to:c}=r.selection,d=r.selection.node;if(d&&d.isBlock||l.depth<2||!l.sameParent(c))return!1;const h=l.node(-1);if(h.type!==a)return!1;const u=i.extensionManager.attributes;if(0===l.parent.content.size&&l.node(-1).childCount===l.indexAfter(-1)){if(2===l.depth||l.node(-3).type!==a||l.index(-2)!==l.node(-2).childCount-1)return!1;if(o){let t=L.empty;const r=l.index(-1)?1:l.index(-2)?2:3;for(let e=l.depth-r;e>=l.depth-3;e-=1)t=L.from(l.node(e).copy(t));const o=l.indexAfter(-1)<l.node(-2).childCount?1:l.indexAfter(-2)<l.node(-3).childCount?2:3,i={...Bs(u,l.node().type.name,l.node().attrs),...e},c=(null===(s=a.contentMatch.defaultType)||void 0===s?void 0:s.createAndFill(i))||void 0;t=t.append(L.from(a.createAndFill(null,c)||void 0));const d=l.before(l.depth-(r-1));n.replace(d,l.after(-o),new F(t,4-r,0));let h=-1;n.doc.nodesBetween(d,n.doc.content.size,((t,e)=>{if(h>-1)return!1;t.isTextblock&&0===t.content.size&&(h=e+1)})),h>-1&&n.setSelection(Ie.near(n.doc.resolve(h))),n.scrollIntoView()}return!0}const p=c.pos===l.end()?h.contentMatchAt(0).defaultType:null,f={...Bs(u,h.type.name,h.attrs),...e},m={...Bs(u,l.node().type.name,l.node().attrs),...e};n.delete(l.pos,c.pos);const g=p?[{type:a,attrs:f},{type:p,attrs:m}]:[{type:a,attrs:f}];if(!ce(n.doc,l.pos,2))return!1;if(o){const{selection:t,storedMarks:e}=r,{splittableMarks:s}=i.extensionManager,a=e||t.$to.parentOffset&&t.$from.marks();if(n.split(l.pos,2,g).scrollIntoView(),!a||!o)return!0;const c=a.filter((t=>s.includes(t.type.name)));n.ensureMarks(c)}return!0},toggleList:(t,e,n,r={})=>({editor:o,tr:i,state:s,dispatch:a,chain:l,commands:c,can:d})=>{const{extensions:h,splittableMarks:u}=o.extensionManager,p=Wi(t,s.schema),f=Wi(e,s.schema),{selection:m,storedMarks:g}=s,{$from:y,$to:b}=m,v=y.blockRange(b),w=g||m.$to.parentOffset&&m.$from.marks();if(!v)return!1;const k=Ps((t=>_s(t.type.name,h)))(m);if(v.depth>=1&&k&&v.depth-k.depth<=1){if(k.node.type===p)return c.liftListItem(f);if(_s(k.node.type.name,h)&&p.validContent(k.node.content)&&a)return l().command((()=>(i.setNodeMarkup(k.pos,p),!0))).command((()=>Ws(i,p))).command((()=>Ks(i,p))).run()}return n&&w&&a?l().command((()=>{const t=d().wrapInList(p,r),e=w.filter((t=>u.includes(t.type.name)));return i.ensureMarks(e),!!t||c.clearNodes()})).wrapInList(p,r).command((()=>Ws(i,p))).command((()=>Ks(i,p))).run():l().command((()=>!!d().wrapInList(p,r)||c.clearNodes())).wrapInList(p,r).command((()=>Ws(i,p))).command((()=>Ks(i,p))).run()},toggleMark:(t,e={},n={})=>({state:r,commands:o})=>{const{extendEmptyMarkRange:i=!1}=n,s=ks(t,r.schema);return Fs(r,s,e)?o.unsetMark(s,{extendEmptyMarkRange:i}):o.setMark(s,e)},toggleNode:(t,e,n={})=>({state:r,commands:o})=>{const i=Wi(t,r.schema),s=Wi(e,r.schema),a=As(r,i,n);let l;return r.selection.$anchor.sameParent(r.selection.$head)&&(l=r.selection.$anchor.parent.attrs),a?o.setNode(s,l):o.setNode(i,{...l,...n})},toggleWrap:(t,e={})=>({state:n,commands:r})=>{const o=Wi(t,n.schema);return As(n,o,e)?r.lift(o):r.wrapIn(o,e)},undoInputRule:()=>({state:t,dispatch:e})=>{const n=t.plugins;for(let r=0;r<n.length;r+=1){const o=n[r];let i;if(o.spec.isInputRules&&(i=o.getState(t))){if(e){const e=t.tr,n=i.transform;for(let t=n.steps.length-1;t>=0;t-=1)e.step(n.steps[t].invert(n.docs[t]));if(i.text){const n=e.doc.resolve(i.from).marks();e.replaceWith(i.from,i.to,t.schema.text(i.text,n))}else e.delete(i.from,i.to)}return!0}}return!1},unsetAllMarks:()=>({tr:t,dispatch:e})=>{const{selection:n}=t,{empty:r,ranges:o}=n;return r||e&&o.forEach((e=>{t.removeMark(e.$from.pos,e.$to.pos)})),!0},unsetMark:(t,e={})=>({tr:n,state:r,dispatch:o})=>{var i;const{extendEmptyMarkRange:s=!1}=e,{selection:a}=n,l=ks(t,r.schema),{$from:c,empty:d,ranges:h}=a;if(!o)return!0;if(d&&s){let{from:t,to:e}=a;const r=null===(i=c.marks().find((t=>t.type===l)))||void 0===i?void 0:i.attrs,o=ws(c,l,r);o&&(t=o.from,e=o.to),n.removeMark(t,e,l)}else h.forEach((t=>{n.removeMark(t.$from.pos,t.$to.pos,l)}));return n.removeStoredMark(l),!0},updateAttributes:(t,e={})=>({tr:n,state:r,dispatch:o})=>{let i=null,s=null;const a=Ds("string"==typeof t?t:t.name,r.schema);return!!a&&("node"===a&&(i=Wi(t,r.schema)),"mark"===a&&(s=ks(t,r.schema)),o&&n.selection.ranges.forEach((t=>{const o=t.$from.pos,a=t.$to.pos;r.doc.nodesBetween(o,a,((t,r)=>{i&&i===t.type&&n.setNodeMarkup(r,void 0,{...t.attrs,...e}),s&&t.marks.length&&t.marks.forEach((i=>{if(s===i.type){const l=Math.max(r,o),c=Math.min(r+t.nodeSize,a);n.addMark(l,c,s.create({...i.attrs,...e}))}}))}))})),!0)},wrapIn:(t,e={})=>({state:n,dispatch:r})=>function(t,e=null){return function(n,r){let{$from:o,$to:i}=n.selection,s=o.blockRange(i),a=s&&ae(s,t,e);return!!a&&(r&&r(n.tr.wrap(s,a).scrollIntoView()),!0)}}(Wi(t,n.schema),e)(n,r),wrapInList:(t,e={})=>({state:n,dispatch:r})=>ji(Wi(t,n.schema),e)(n,r)});const Js=ps.create({name:"commands",addCommands:()=>({...qs})}),Us=ps.create({name:"drop",addProseMirrorPlugins(){return[new Ue({key:new Qe("tiptapDrop"),props:{handleDrop:(t,e,n,r)=>{this.editor.emit("drop",{editor:this.editor,event:e,slice:n,moved:r})}}})]}}),Gs=ps.create({name:"editable",addProseMirrorPlugins(){return[new Ue({key:new Qe("editable"),props:{editable:()=>this.editor.options.editable}})]}}),Ys=ps.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new Ue({key:new Qe("focusEvents"),props:{handleDOMEvents:{focus:(e,n)=>{t.isFocused=!0;const r=t.state.tr.setMeta("focus",{event:n}).setMeta("addToHistory",!1);return e.dispatch(r),!1},blur:(e,n)=>{t.isFocused=!1;const r=t.state.tr.setMeta("blur",{event:n}).setMeta("addToHistory",!1);return e.dispatch(r),!1}}}})]}}),Qs=ps.create({name:"keymap",addKeyboardShortcuts(){const t=()=>this.editor.commands.first((({commands:t})=>[()=>t.undoInputRule(),()=>t.command((({tr:e})=>{const{selection:n,doc:r}=e,{empty:o,$anchor:i}=n,{pos:s,parent:a}=i,l=i.parent.isTextblock&&s>0?e.doc.resolve(s-1):i,c=l.parent.type.spec.isolating,d=i.pos-i.parentOffset,h=c&&1===l.parent.childCount?d===i.pos:Ne.atStart(r).from===s;return!(!o||!a.type.isTextblock||a.textContent.length||!h||h&&"paragraph"===i.parent.type.name)&&t.clearNodes()})),()=>t.deleteSelection(),()=>t.joinBackward(),()=>t.selectNodeBackward()])),e=()=>this.editor.commands.first((({commands:t})=>[()=>t.deleteSelection(),()=>t.deleteCurrentNode(),()=>t.joinForward(),()=>t.selectNodeForward()])),n={Enter:()=>this.editor.commands.first((({commands:t})=>[()=>t.newlineInCode(),()=>t.createParagraphNear(),()=>t.liftEmptyBlock(),()=>t.splitBlock()])),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:t,"Mod-Backspace":t,"Shift-Backspace":t,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},r={...n},o={...n,"Ctrl-h":t,"Alt-Backspace":t,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return Cs()||Ns()?o:r},addProseMirrorPlugins(){return[new Ue({key:new Qe("clearDocument"),appendTransaction:(t,e,n)=>{const r=t.some((t=>t.docChanged))&&!e.doc.eq(n.doc),o=t.some((t=>t.getMeta("preventClearDocument")));if(!r||o)return;const{empty:i,from:s,to:a}=e.selection,l=Ne.atStart(e.doc).from,c=Ne.atEnd(e.doc).to;if(i||s!==l||a!==c||!Vs(n.doc))return;const d=n.tr,h=$i({state:n,transaction:d}),{commands:u}=new Bi({editor:this.editor,state:h});return u.clearNodes(),d.steps.length?d:void 0}})]}}),Xs=ps.create({name:"paste",addProseMirrorPlugins(){return[new Ue({key:new Qe("tiptapPaste"),props:{handlePaste:(t,e,n)=>{this.editor.emit("paste",{editor:this.editor,event:e,slice:n})}}})]}}),Zs=ps.create({name:"tabindex",addProseMirrorPlugins(){return[new Ue({key:new Qe("tabindex"),props:{attributes:()=>this.editor.isEditable?{tabindex:"0"}:{}}})]}});class ta{get name(){return this.node.type.name}constructor(t,e,n=!1,r=null){this.currentNode=null,this.actualDepth=null,this.isBlock=n,this.resolvedPos=t,this.editor=e,this.currentNode=r}get node(){return this.currentNode||this.resolvedPos.node()}get element(){return this.editor.view.domAtPos(this.pos).node}get depth(){var t;return null!==(t=this.actualDepth)&&void 0!==t?t:this.resolvedPos.depth}get pos(){return this.resolvedPos.pos}get content(){return this.node.content}set content(t){let e=this.from,n=this.to;if(this.isBlock){if(0===this.content.size)return void console.error(`You can’t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);e=this.from+1,n=this.to-1}this.editor.commands.insertContentAt({from:e,to:n},t)}get attributes(){return this.node.attrs}get textContent(){return this.node.textContent}get size(){return this.node.nodeSize}get from(){return this.isBlock?this.pos:this.resolvedPos.start(this.resolvedPos.depth)}get range(){return{from:this.from,to:this.to}}get to(){return this.isBlock?this.pos+this.size:this.resolvedPos.end(this.resolvedPos.depth)+(this.node.isText?0:1)}get parent(){if(0===this.depth)return null;const t=this.resolvedPos.start(this.resolvedPos.depth-1),e=this.resolvedPos.doc.resolve(t);return new ta(e,this.editor)}get before(){let t=this.resolvedPos.doc.resolve(this.from-(this.isBlock?1:2));return t.depth!==this.depth&&(t=this.resolvedPos.doc.resolve(this.from-3)),new ta(t,this.editor)}get after(){let t=this.resolvedPos.doc.resolve(this.to+(this.isBlock?2:1));return t.depth!==this.depth&&(t=this.resolvedPos.doc.resolve(this.to+3)),new ta(t,this.editor)}get children(){const t=[];return this.node.content.forEach(((e,n)=>{const r=e.isBlock&&!e.isTextblock,o=this.pos+n+1,i=this.resolvedPos.doc.resolve(o);if(!r&&i.depth<=this.depth)return;const s=new ta(i,this.editor,r,r?e:null);r&&(s.actualDepth=this.depth+1),t.push(new ta(i,this.editor,r,r?e:null))})),t}get firstChild(){return this.children[0]||null}get lastChild(){const t=this.children;return t[t.length-1]||null}closest(t,e={}){let n=null,r=this.parent;for(;r&&!n;){if(r.node.type.name===t)if(Object.keys(e).length>0){const t=r.node.attrs,n=Object.keys(e);for(let r=0;r<n.length;r+=1){const o=n[r];if(t[o]!==e[o])break}}else n=r;r=r.parent}return n}querySelector(t,e={}){return this.querySelectorAll(t,e,!0)[0]||null}querySelectorAll(t,e={},n=!1){let r=[];if(!this.children||0===this.children.length)return r;const o=Object.keys(e);return this.children.forEach((i=>{n&&r.length>0||(i.node.type.name===t&&o.every((t=>e[t]===i.node.attrs[t]))&&r.push(i),!(n&&r.length>0)&&(r=r.concat(i.querySelectorAll(t,e,n))))})),r}setAttribute(t){const e=this.editor.state.selection;this.editor.chain().setTextSelection(this.from).updateAttributes(this.node.type.name,t).setTextSelection(e.from).run()}}class ea extends Fi{constructor(t={}){super(),this.isFocused=!1,this.isInitialized=!1,this.extensionStorage={},this.options={element:document.createElement("div"),content:"",injectCSS:!0,injectNonce:void 0,extensions:[],autofocus:!1,editable:!0,editorProps:{},parseOptions:{},coreExtensionOptions:{},enableInputRules:!0,enablePasteRules:!0,enableCoreExtensions:!0,enableContentCheck:!1,onBeforeCreate:()=>null,onCreate:()=>null,onUpdate:()=>null,onSelectionUpdate:()=>null,onTransaction:()=>null,onFocus:()=>null,onBlur:()=>null,onDestroy:()=>null,onContentError:({error:t})=>{throw t},onPaste:()=>null,onDrop:()=>null},this.isCapturingTransaction=!1,this.capturedTransaction=null,this.setOptions(t),this.createExtensionManager(),this.createCommandManager(),this.createSchema(),this.on("beforeCreate",this.options.onBeforeCreate),this.emit("beforeCreate",{editor:this}),this.on("contentError",this.options.onContentError),this.createView(),this.injectCSS(),this.on("create",this.options.onCreate),this.on("update",this.options.onUpdate),this.on("selectionUpdate",this.options.onSelectionUpdate),this.on("transaction",this.options.onTransaction),this.on("focus",this.options.onFocus),this.on("blur",this.options.onBlur),this.on("destroy",this.options.onDestroy),this.on("drop",(({event:t,slice:e,moved:n})=>this.options.onDrop(t,e,n))),this.on("paste",(({event:t,slice:e})=>this.options.onPaste(t,e))),window.setTimeout((()=>{this.isDestroyed||(this.commands.focus(this.options.autofocus),this.emit("create",{editor:this}),this.isInitialized=!0)}),0)}get storage(){return this.extensionStorage}get commands(){return this.commandManager.commands}chain(){return this.commandManager.chain()}can(){return this.commandManager.can()}injectCSS(){this.options.injectCSS&&document&&(this.css=function(t,e,n){const r=document.querySelector(`style[data-tiptap-style${n?`-${n}`:""}]`);if(null!==r)return r;const o=document.createElement("style");return e&&o.setAttribute("nonce",e),o.setAttribute("data-tiptap-style"+(n?`-${n}`:""),""),o.innerHTML=t,document.getElementsByTagName("head")[0].appendChild(o),o}('.ProseMirror {\n position: relative;\n}\n\n.ProseMirror {\n word-wrap: break-word;\n white-space: pre-wrap;\n white-space: break-spaces;\n -webkit-font-variant-ligatures: none;\n font-variant-ligatures: none;\n font-feature-settings: "liga" 0; /* the above doesn\'t seem to work in Edge */\n}\n\n.ProseMirror [contenteditable="false"] {\n white-space: normal;\n}\n\n.ProseMirror [contenteditable="false"] [contenteditable="true"] {\n white-space: pre-wrap;\n}\n\n.ProseMirror pre {\n white-space: pre-wrap;\n}\n\nimg.ProseMirror-separator {\n display: inline !important;\n border: none !important;\n margin: 0 !important;\n width: 0 !important;\n height: 0 !important;\n}\n\n.ProseMirror-gapcursor {\n display: none;\n pointer-events: none;\n position: absolute;\n margin: 0;\n}\n\n.ProseMirror-gapcursor:after {\n content: "";\n display: block;\n position: absolute;\n top: -2px;\n width: 20px;\n border-top: 1px solid black;\n animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;\n}\n\n@keyframes ProseMirror-cursor-blink {\n to {\n visibility: hidden;\n }\n}\n\n.ProseMirror-hideselection *::selection {\n background: transparent;\n}\n\n.ProseMirror-hideselection *::-moz-selection {\n background: transparent;\n}\n\n.ProseMirror-hideselection * {\n caret-color: transparent;\n}\n\n.ProseMirror-focused .ProseMirror-gapcursor {\n display: block;\n}\n\n.tippy-box[data-animation=fade][data-state=hidden] {\n opacity: 0\n}',this.options.injectNonce))}setOptions(t={}){this.options={...this.options,...t},this.view&&this.state&&!this.isDestroyed&&(this.options.editorProps&&this.view.setProps(this.options.editorProps),this.view.updateState(this.state))}setEditable(t,e=!0){this.setOptions({editable:t}),e&&this.emit("update",{editor:this,transaction:this.state.tr})}get isEditable(){return this.options.editable&&this.view&&this.view.editable}get state(){return this.view.state}registerPlugin(t,e){const n=Ji(e)?e(t,[...this.state.plugins]):[...this.state.plugins,t],r=this.state.reconfigure({plugins:n});return this.view.updateState(r),r}unregisterPlugin(t){if(this.isDestroyed)return;const e="string"==typeof t?`${t}$`:t.key,n=this.state.reconfigure({plugins:this.state.plugins.filter((t=>!t.key.startsWith(e)))});return this.view.updateState(n),n}createExtensionManager(){var t,e;const n=[...this.options.enableCoreExtensions?[Gs,gs.configure({blockSeparator:null===(e=null===(t=this.options.coreExtensionOptions)||void 0===t?void 0:t.clipboardTextSerializer)||void 0===e?void 0:e.blockSeparator}),Js,Ys,Qs,Zs,Us,Xs].filter((t=>"object"!=typeof this.options.enableCoreExtensions||!1!==this.options.enableCoreExtensions[t.name])):[],...this.options.extensions].filter((t=>["extension","node","mark"].includes(null==t?void 0:t.type)));this.extensionManager=new us(n,this)}createCommandManager(){this.commandManager=new Bi({editor:this})}createSchema(){this.schema=this.extensionManager.schema}createView(){let t;try{t=Is(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:this.options.enableContentCheck})}catch(e){if(!(e instanceof Error&&["[tiptap error]: Invalid JSON content","[tiptap error]: Invalid HTML content"].includes(e.message)))throw e;this.emit("contentError",{editor:this,error:e,disableCollaboration:()=>{this.options.extensions=this.options.extensions.filter((t=>"collaboration"!==t.name)),this.createExtensionManager()}}),t=Is(this.options.content,this.schema,this.options.parseOptions,{errorOnInvalidContent:!1})}const e=Os(t,this.options.autofocus);this.view=new li(this.options.element,{...this.options.editorProps,dispatchTransaction:this.dispatchTransaction.bind(this),state:qe.create({doc:t,selection:e||void 0})});const n=this.state.reconfigure({plugins:this.extensionManager.plugins});this.view.updateState(n),this.createNodeViews(),this.prependClass();this.view.dom.editor=this}createNodeViews(){this.view.isDestroyed||this.view.setProps({nodeViews:this.extensionManager.nodeViews})}prependClass(){this.view.dom.className=`tiptap ${this.view.dom.className}`}captureTransaction(t){this.isCapturingTransaction=!0,t(),this.isCapturingTransaction=!1;const e=this.capturedTransaction;return this.capturedTransaction=null,e}dispatchTransaction(t){if(this.view.isDestroyed)return;if(this.isCapturingTransaction)return this.capturedTransaction?void t.steps.forEach((t=>{var e;return null===(e=this.capturedTransaction)||void 0===e?void 0:e.step(t)})):void(this.capturedTransaction=t);const e=this.state.apply(t),n=!this.state.selection.eq(e.selection);this.emit("beforeTransaction",{editor:this,transaction:t,nextState:e}),this.view.updateState(e),this.emit("transaction",{editor:this,transaction:t}),n&&this.emit("selectionUpdate",{editor:this,transaction:t});const r=t.getMeta("focus"),o=t.getMeta("blur");r&&this.emit("focus",{editor:this,event:r.event,transaction:t}),o&&this.emit("blur",{editor:this,event:o.event,transaction:t}),t.docChanged&&!t.getMeta("preventUpdate")&&this.emit("update",{editor:this,transaction:t})}getAttributes(t){return js(this.state,t)}isActive(t,e){const n="string"==typeof t?t:null,r="string"==typeof t?e:t;return function(t,e,n={}){if(!e)return As(t,null,n)||Fs(t,null,n);const r=Ds(e,t.schema);return"node"===r?As(t,e,n):"mark"===r&&Fs(t,e,n)}(this.state,n,r)}getJSON(){return this.state.doc.toJSON()}getHTML(){return function(t,e){const n=Pt.fromSchema(e).serializeFragment(t),r=document.implementation.createHTMLDocument().createElement("div");return r.appendChild(n),r.innerHTML}(this.state.doc.content,this.schema)}getText(t){const{blockSeparator:e="\n\n",textSerializers:n={}}=t||{};return function(t,e){return fs(t,{from:0,to:t.content.size},e)}(this.state.doc,{blockSeparator:e,textSerializers:{...ms(this.schema),...n}})}get isEmpty(){return Vs(this.state.doc)}getCharacterCount(){return console.warn('[tiptap warn]: "editor.getCharacterCount()" is deprecated. Please use "editor.storage.characterCount.characters()" instead.'),this.state.doc.content.size-2}destroy(){if(this.emit("destroy"),this.view){const t=this.view.dom;t&&t.editor&&delete t.editor,this.view.destroy()}this.removeAllListeners()}get isDestroyed(){var t;return!(null!==(t=this.view)&&void 0!==t&&t.docView)}$node(t,e){var n;return(null===(n=this.$doc)||void 0===n?void 0:n.querySelector(t,e))||null}$nodes(t,e){var n;return(null===(n=this.$doc)||void 0===n?void 0:n.querySelectorAll(t,e))||null}$pos(t){const e=this.state.doc.resolve(t);return new ta(e,this)}get $doc(){return this.$pos(0)}}function na(t){return new es({find:t.find,handler:({state:e,range:n,match:r})=>{const o=Ui(t.getAttributes,void 0,r);if(!1===o||null===o)return null;const{tr:i}=e,s=r[r.length-1],a=r[0];if(s){const r=a.search(/\S/),l=n.from+a.indexOf(s),c=l+s.length;if($s(n.from,n.to,e.doc).filter((e=>e.mark.type.excluded.find((n=>n===t.type&&n!==e.mark.type)))).filter((t=>t.to>l)).length)return null;c<n.to&&i.delete(c,n.to),l>n.from&&i.delete(n.from+r,l);const d=n.from+r+s.length;i.addMark(n.from+r,d,t.type.create(o||{})),i.removeStoredMark(t.type)}}})}function ra(t){return new es({find:t.find,handler:({state:e,range:n,match:r,chain:o})=>{const i=Ui(t.getAttributes,void 0,r)||{},s=e.tr.delete(n.from,n.to),a=s.doc.resolve(n.from).blockRange(),l=a&&ae(a,t.type,i);if(!l)return null;if(s.wrap(a,l),t.keepMarks&&t.editor){const{selection:n,storedMarks:r}=e,{splittableMarks:o}=t.editor.extensionManager,i=r||n.$to.parentOffset&&n.$from.marks();if(i){const t=i.filter((t=>o.includes(t.type.name)));s.ensureMarks(t)}}if(t.keepAttributes){const e="bulletList"===t.type.name||"orderedList"===t.type.name?"listItem":"taskList";o().updateAttributes(e,i).run()}const c=s.doc.resolve(n.from-1).nodeBefore;c&&c.type===t.type&&de(s.doc,n.from-1)&&(!t.joinPredicate||t.joinPredicate(r,c))&&s.join(n.from-1)}})}class oa{constructor(t={}){this.type="node",this.name="node",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...t},this.name=this.config.name,t.defaultOptions&&Object.keys(t.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=Ui(_i(this,"addOptions",{name:this.name}))),this.storage=Ui(_i(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(t={}){return new oa(t)}configure(t={}){const e=this.extend({...this.config,addOptions:()=>as(this.options,t)});return e.name=this.name,e.parent=this.parent,e}extend(t={}){const e=new oa(t);return e.parent=this,this.child=e,e.name=t.name?t.name:e.parent.name,t.defaultOptions&&Object.keys(t.defaultOptions).length>0&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${e.name}".`),e.options=Ui(_i(e,"addOptions",{name:e.name})),e.storage=Ui(_i(e,"addStorage",{name:e.name,options:e.options})),e}}function ia(t){return new cs({find:t.find,handler:({state:e,range:n,match:r,pasteEvent:o})=>{const i=Ui(t.getAttributes,void 0,r,o);if(!1===i||null===i)return null;const{tr:s}=e,a=r[r.length-1],l=r[0];let c=n.to;if(a){const r=l.search(/\S/),o=n.from+l.indexOf(a),d=o+a.length;if($s(n.from,n.to,e.doc).filter((e=>e.mark.type.excluded.find((n=>n===t.type&&n!==e.mark.type)))).filter((t=>t.to>o)).length)return null;d<n.to&&s.delete(d,n.to),o>n.from&&s.delete(n.from+r,o),c=n.from+r+a.length,s.addMark(n.from+r,c,t.type.create(i||{})),s.removeStoredMark(t.type)}}})}var sa,aa={exports:{}},la={};
21
21
  /**
22
22
  * @license React
23
23
  * use-sync-external-store-shim.production.min.js
@@ -26,7 +26,7 @@ import t,{forwardRef as e,useRef as n,useState as r,useDebugValue as o,useEffect
26
26
  *
27
27
  * This source code is licensed under the MIT license found in the
28
28
  * LICENSE file in the root directory of this source tree.
29
- */var aa,la={};
29
+ */var ca,da={};
30
30
  /**
31
31
  * @license React
32
32
  * use-sync-external-store-shim.development.js
@@ -35,7 +35,7 @@ import t,{forwardRef as e,useRef as n,useState as r,useDebugValue as o,useEffect
35
35
  *
36
36
  * This source code is licensed under the MIT license found in the
37
37
  * LICENSE file in the root directory of this source tree.
38
- */"production"===process.env.NODE_ENV?ia.exports=function(){if(oa)return sa;oa=1;var e=t,n="function"==typeof Object.is?Object.is:function(t,e){return t===e&&(0!==t||1/t==1/e)||t!=t&&e!=e},r=e.useState,o=e.useEffect,i=e.useLayoutEffect,s=e.useDebugValue;function a(t){var e=t.getSnapshot;t=t.value;try{var r=e();return!n(t,r)}catch{return!0}}var l=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?function(t,e){return e()}:function(t,e){var n=e(),l=r({inst:{value:n,getSnapshot:e}}),c=l[0].inst,d=l[1];return i((function(){c.value=n,c.getSnapshot=e,a(c)&&d({inst:c})}),[t,n,e]),o((function(){return a(c)&&d({inst:c}),t((function(){a(c)&&d({inst:c})}))}),[t]),s(n),n};return sa.useSyncExternalStore=void 0!==e.useSyncExternalStore?e.useSyncExternalStore:l,sa}():ia.exports=(aa||(aa=1,"production"!==process.env.NODE_ENV&&function(){typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&"function"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error);var e=t,n=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function r(t){for(var e=arguments.length,r=new Array(e>1?e-1:0),o=1;o<e;o++)r[o-1]=arguments[o];!function(t,e,r){var o=n.ReactDebugCurrentFrame,i=o.getStackAddendum();""!==i&&(e+="%s",r=r.concat([i]));var s=r.map((function(t){return String(t)}));s.unshift("Warning: "+e),Function.prototype.apply.call(console[t],console,s)}("error",t,r)}var o="function"==typeof Object.is?Object.is:function(t,e){return t===e&&(0!==t||1/t==1/e)||t!=t&&e!=e},i=e.useState,s=e.useEffect,a=e.useLayoutEffect,l=e.useDebugValue,c=!1,d=!1;function h(t){var e=t.getSnapshot,n=t.value;try{var r=e();return!o(n,r)}catch{return!0}}var u=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u"?function(t,n,u){c||void 0!==e.startTransition&&(c=!0,r("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."));var p=n();if(!d){var f=n();o(p,f)||(r("The result of getSnapshot should be cached to avoid an infinite loop"),d=!0)}var m=i({inst:{value:p,getSnapshot:n}}),g=m[0].inst,y=m[1];return a((function(){g.value=p,g.getSnapshot=n,h(g)&&y({inst:g})}),[t,p,n]),s((function(){return h(g)&&y({inst:g}),t((function(){h(g)&&y({inst:g})}))}),[t]),l(p),p}:function(t,e,n){return e()},p=void 0!==e.useSyncExternalStore?e.useSyncExternalStore:u;la.useSyncExternalStore=p,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&"function"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error)}()),la);var ca=ia.exports;const da=(...t)=>e=>{t.forEach((t=>{"function"==typeof t?t(e):t&&(t.current=e)}))},ha=({contentComponent:e})=>{const n=ca.useSyncExternalStore(e.subscribe,e.getSnapshot,e.getServerSnapshot);return t.createElement(t.Fragment,null,Object.values(n))};class ua extends t.Component{constructor(e){var n;super(e),this.editorContentRef=t.createRef(),this.initialized=!1,this.state={hasContentComponentInitialized:!(null===(n=e.editor)||void 0===n||!n.contentComponent)}}componentDidMount(){this.init()}componentDidUpdate(){this.init()}init(){const t=this.props.editor;if(t&&!t.isDestroyed&&t.options.element){if(t.contentComponent)return;const e=this.editorContentRef.current;e.append(...t.options.element.childNodes),t.setOptions({element:e}),t.contentComponent=function(){const t=new Set;let e={};return{subscribe:e=>(t.add(e),()=>{t.delete(e)}),getSnapshot:()=>e,getServerSnapshot:()=>e,setRenderer(n,r){e={...e,[n]:h.createPortal(r.reactElement,r.element,n)},t.forEach((t=>t()))},removeRenderer(n){const r={...e};delete r[n],e=r,t.forEach((t=>t()))}}}(),this.state.hasContentComponentInitialized||(this.unsubscribeToContentComponent=t.contentComponent.subscribe((()=>{this.setState((t=>t.hasContentComponentInitialized?t:{hasContentComponentInitialized:!0})),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent()}))),t.createNodeViews(),this.initialized=!0}}componentWillUnmount(){const t=this.props.editor;if(!t||(this.initialized=!1,t.isDestroyed||t.view.setProps({nodeViews:{}}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent(),t.contentComponent=null,!t.options.element.firstChild))return;const e=document.createElement("div");e.append(...t.options.element.childNodes),t.setOptions({element:e})}render(){const{editor:e,innerRef:n,...r}=this.props;return t.createElement(t.Fragment,null,t.createElement("div",{ref:da(n,this.editorContentRef),...r}),(null==e?void 0:e.contentComponent)&&t.createElement(ha,{contentComponent:e.contentComponent}))}}const pa=e(((e,n)=>{const r=t.useMemo((()=>Math.floor(4294967295*Math.random()).toString()),[e.editor]);return t.createElement(ua,{key:r,innerRef:n,...e})})),fa=t.memo(pa);var ma,ga={exports:{}},ya={};
38
+ */"production"===process.env.NODE_ENV?aa.exports=function(){if(sa)return la;sa=1;var e=t,n="function"==typeof Object.is?Object.is:function(t,e){return t===e&&(0!==t||1/t==1/e)||t!=t&&e!=e},r=e.useState,o=e.useEffect,i=e.useLayoutEffect,s=e.useDebugValue;function a(t){var e=t.getSnapshot;t=t.value;try{var r=e();return!n(t,r)}catch{return!0}}var l=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?function(t,e){return e()}:function(t,e){var n=e(),l=r({inst:{value:n,getSnapshot:e}}),c=l[0].inst,d=l[1];return i((function(){c.value=n,c.getSnapshot=e,a(c)&&d({inst:c})}),[t,n,e]),o((function(){return a(c)&&d({inst:c}),t((function(){a(c)&&d({inst:c})}))}),[t]),s(n),n};return la.useSyncExternalStore=void 0!==e.useSyncExternalStore?e.useSyncExternalStore:l,la}():aa.exports=(ca||(ca=1,"production"!==process.env.NODE_ENV&&function(){typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&"function"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error);var e=t,n=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function r(t){for(var e=arguments.length,r=new Array(e>1?e-1:0),o=1;o<e;o++)r[o-1]=arguments[o];!function(t,e,r){var o=n.ReactDebugCurrentFrame,i=o.getStackAddendum();""!==i&&(e+="%s",r=r.concat([i]));var s=r.map((function(t){return String(t)}));s.unshift("Warning: "+e),Function.prototype.apply.call(console[t],console,s)}("error",t,r)}var o="function"==typeof Object.is?Object.is:function(t,e){return t===e&&(0!==t||1/t==1/e)||t!=t&&e!=e},i=e.useState,s=e.useEffect,a=e.useLayoutEffect,l=e.useDebugValue,c=!1,d=!1;function h(t){var e=t.getSnapshot,n=t.value;try{var r=e();return!o(n,r)}catch{return!0}}var u=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u"?function(t,n,u){c||void 0!==e.startTransition&&(c=!0,r("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."));var p=n();if(!d){var f=n();o(p,f)||(r("The result of getSnapshot should be cached to avoid an infinite loop"),d=!0)}var m=i({inst:{value:p,getSnapshot:n}}),g=m[0].inst,y=m[1];return a((function(){g.value=p,g.getSnapshot=n,h(g)&&y({inst:g})}),[t,p,n]),s((function(){return h(g)&&y({inst:g}),t((function(){h(g)&&y({inst:g})}))}),[t]),l(p),p}:function(t,e,n){return e()},p=void 0!==e.useSyncExternalStore?e.useSyncExternalStore:u;da.useSyncExternalStore=p,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&"function"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error)}()),da);var ha=aa.exports;const ua=(...t)=>e=>{t.forEach((t=>{"function"==typeof t?t(e):t&&(t.current=e)}))},pa=({contentComponent:e})=>{const n=ha.useSyncExternalStore(e.subscribe,e.getSnapshot,e.getServerSnapshot);return t.createElement(t.Fragment,null,Object.values(n))};class fa extends t.Component{constructor(e){var n;super(e),this.editorContentRef=t.createRef(),this.initialized=!1,this.state={hasContentComponentInitialized:!(null===(n=e.editor)||void 0===n||!n.contentComponent)}}componentDidMount(){this.init()}componentDidUpdate(){this.init()}init(){const t=this.props.editor;if(t&&!t.isDestroyed&&t.options.element){if(t.contentComponent)return;const e=this.editorContentRef.current;e.append(...t.options.element.childNodes),t.setOptions({element:e}),t.contentComponent=function(){const t=new Set;let e={};return{subscribe:e=>(t.add(e),()=>{t.delete(e)}),getSnapshot:()=>e,getServerSnapshot:()=>e,setRenderer(n,r){e={...e,[n]:p.createPortal(r.reactElement,r.element,n)},t.forEach((t=>t()))},removeRenderer(n){const r={...e};delete r[n],e=r,t.forEach((t=>t()))}}}(),this.state.hasContentComponentInitialized||(this.unsubscribeToContentComponent=t.contentComponent.subscribe((()=>{this.setState((t=>t.hasContentComponentInitialized?t:{hasContentComponentInitialized:!0})),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent()}))),t.createNodeViews(),this.initialized=!0}}componentWillUnmount(){const t=this.props.editor;if(!t||(this.initialized=!1,t.isDestroyed||t.view.setProps({nodeViews:{}}),this.unsubscribeToContentComponent&&this.unsubscribeToContentComponent(),t.contentComponent=null,!t.options.element.firstChild))return;const e=document.createElement("div");e.append(...t.options.element.childNodes),t.setOptions({element:e})}render(){const{editor:e,innerRef:n,...r}=this.props;return t.createElement(t.Fragment,null,t.createElement("div",{ref:ua(n,this.editorContentRef),...r}),(null==e?void 0:e.contentComponent)&&t.createElement(pa,{contentComponent:e.contentComponent}))}}const ma=e(((e,n)=>{const r=t.useMemo((()=>Math.floor(4294967295*Math.random()).toString()),[e.editor]);return t.createElement(fa,{key:r,innerRef:n,...e})})),ga=t.memo(ma);var ya,ba={exports:{}},va={};
39
39
  /**
40
40
  * @license React
41
41
  * use-sync-external-store-shim/with-selector.production.min.js
@@ -44,7 +44,7 @@ import t,{forwardRef as e,useRef as n,useState as r,useDebugValue as o,useEffect
44
44
  *
45
45
  * This source code is licensed under the MIT license found in the
46
46
  * LICENSE file in the root directory of this source tree.
47
- */var ba,va={};
47
+ */var wa,ka={};
48
48
  /**
49
49
  * @license React
50
50
  * use-sync-external-store-shim/with-selector.development.js
@@ -53,4 +53,4 @@ import t,{forwardRef as e,useRef as n,useState as r,useDebugValue as o,useEffect
53
53
  *
54
54
  * This source code is licensed under the MIT license found in the
55
55
  * LICENSE file in the root directory of this source tree.
56
- */"production"===process.env.NODE_ENV?ga.exports=function(){if(ma)return ya;ma=1;var e=t,n=ca,r="function"==typeof Object.is?Object.is:function(t,e){return t===e&&(0!==t||1/t==1/e)||t!=t&&e!=e},o=n.useSyncExternalStore,i=e.useRef,s=e.useEffect,a=e.useMemo,l=e.useDebugValue;return ya.useSyncExternalStoreWithSelector=function(t,e,n,c,d){var h=i(null);if(null===h.current){var u={hasValue:!1,value:null};h.current=u}else u=h.current;h=a((function(){function t(t){if(!s){if(s=!0,o=t,t=c(t),void 0!==d&&u.hasValue){var e=u.value;if(d(e,t))return i=e}return i=t}if(e=i,r(o,t))return e;var n=c(t);return void 0!==d&&d(e,n)?e:(o=t,i=n)}var o,i,s=!1,a=void 0===n?null:n;return[function(){return t(e())},null===a?void 0:function(){return t(a())}]}),[e,n,c,d]);var p=o(t,h[0],h[1]);return s((function(){u.hasValue=!0,u.value=p}),[p]),l(p),p},ya}():ga.exports=(ba||(ba=1,"production"!==process.env.NODE_ENV&&function(){typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&"function"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error);var e=t,n=ca,r="function"==typeof Object.is?Object.is:function(t,e){return t===e&&(0!==t||1/t==1/e)||t!=t&&e!=e},o=n.useSyncExternalStore,i=e.useRef,s=e.useEffect,a=e.useMemo,l=e.useDebugValue;va.useSyncExternalStoreWithSelector=function(t,e,n,c,d){var h,u=i(null);null===u.current?(h={hasValue:!1,value:null},u.current=h):h=u.current;var p=a((function(){var t,o,i=!1,s=function(e){if(!i){i=!0,t=e;var n=c(e);if(void 0!==d&&h.hasValue){var s=h.value;if(d(s,n))return o=s,s}return o=n,n}var a=o;if(r(t,e))return a;var l=c(e);return void 0!==d&&d(a,l)?a:(t=e,o=l,l)},a=void 0===n?null:n;return[function(){return s(e())},null===a?void 0:function(){return s(a())}]}),[e,n,c,d]),f=p[0],m=p[1],g=o(t,f,m);return s((function(){h.hasValue=!0,h.value=g}),[g]),l(g),g},typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&"function"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error)}()),va);var wa=ga.exports;class ka{constructor(t){this.transactionNumber=0,this.lastTransactionNumber=0,this.subscribers=new Set,this.editor=t,this.lastSnapshot={editor:t,transactionNumber:0},this.getSnapshot=this.getSnapshot.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.watch=this.watch.bind(this),this.subscribe=this.subscribe.bind(this)}getSnapshot(){return this.transactionNumber===this.lastTransactionNumber||(this.lastTransactionNumber=this.transactionNumber,this.lastSnapshot={editor:this.editor,transactionNumber:this.transactionNumber}),this.lastSnapshot}getServerSnapshot(){return{editor:null,transactionNumber:0}}subscribe(t){return this.subscribers.add(t),()=>{this.subscribers.delete(t)}}watch(t){if(this.editor=t,this.editor){const t=()=>{this.transactionNumber+=1,this.subscribers.forEach((t=>t()))},e=this.editor;return e.on("transaction",t),()=>{e.off("transaction",t)}}}}const xa="production"!==process.env.NODE_ENV,Sa=typeof window>"u",Oa=Sa||!!(typeof window<"u"&&window.next);class Ca{constructor(t){this.editor=null,this.subscriptions=new Set,this.isComponentMounted=!1,this.previousDeps=null,this.instanceId="",this.options=t,this.subscriptions=new Set,this.setEditor(this.getInitialEditor()),this.scheduleDestroy(),this.getEditor=this.getEditor.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.subscribe=this.subscribe.bind(this),this.refreshEditorInstance=this.refreshEditorInstance.bind(this),this.scheduleDestroy=this.scheduleDestroy.bind(this),this.onRender=this.onRender.bind(this),this.createEditor=this.createEditor.bind(this)}setEditor(t){this.editor=t,this.instanceId=Math.random().toString(36).slice(2,9),this.subscriptions.forEach((t=>t()))}getInitialEditor(){if(void 0===this.options.current.immediatelyRender)return Sa||Oa?(xa&&console.warn("Tiptap Error: SSR has been detected, please set `immediatelyRender` explicitly to `false` to avoid hydration mismatches."),null):this.createEditor();if(this.options.current.immediatelyRender&&Sa&&xa)throw new Error("Tiptap Error: SSR has been detected, and `immediatelyRender` has been set to `true` this is an unsupported configuration that may result in errors, explicitly set `immediatelyRender` to `false` to avoid hydration mismatches.");return this.options.current.immediatelyRender?this.createEditor():null}createEditor(){const t={...this.options.current,onBeforeCreate:(...t)=>{var e,n;return null===(n=(e=this.options.current).onBeforeCreate)||void 0===n?void 0:n.call(e,...t)},onBlur:(...t)=>{var e,n;return null===(n=(e=this.options.current).onBlur)||void 0===n?void 0:n.call(e,...t)},onCreate:(...t)=>{var e,n;return null===(n=(e=this.options.current).onCreate)||void 0===n?void 0:n.call(e,...t)},onDestroy:(...t)=>{var e,n;return null===(n=(e=this.options.current).onDestroy)||void 0===n?void 0:n.call(e,...t)},onFocus:(...t)=>{var e,n;return null===(n=(e=this.options.current).onFocus)||void 0===n?void 0:n.call(e,...t)},onSelectionUpdate:(...t)=>{var e,n;return null===(n=(e=this.options.current).onSelectionUpdate)||void 0===n?void 0:n.call(e,...t)},onTransaction:(...t)=>{var e,n;return null===(n=(e=this.options.current).onTransaction)||void 0===n?void 0:n.call(e,...t)},onUpdate:(...t)=>{var e,n;return null===(n=(e=this.options.current).onUpdate)||void 0===n?void 0:n.call(e,...t)},onContentError:(...t)=>{var e,n;return null===(n=(e=this.options.current).onContentError)||void 0===n?void 0:n.call(e,...t)}};return new Zs(t)}getEditor(){return this.editor}getServerSnapshot(){return null}subscribe(t){return this.subscriptions.add(t),()=>{this.subscriptions.delete(t)}}onRender(t){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&0===t.length?this.editor.setOptions(this.options.current):this.refreshEditorInstance(t),()=>{this.isComponentMounted=!1,this.scheduleDestroy()})}refreshEditorInstance(t){if(this.editor&&!this.editor.isDestroyed){if(null===this.previousDeps)return void(this.previousDeps=t);if(this.previousDeps.length===t.length&&this.previousDeps.every(((e,n)=>e===t[n])))return}this.editor&&!this.editor.isDestroyed&&this.editor.destroy(),this.setEditor(this.createEditor()),this.previousDeps=t}scheduleDestroy(){const t=this.instanceId,e=this.editor;this.scheduledDestructionTimeout=setTimeout((()=>{this.isComponentMounted&&this.instanceId===t?e&&e.setOptions(this.options.current):e&&!e.isDestroyed&&(e.destroy(),this.instanceId===t&&this.setEditor(null))}),1)}}function Ma(t={},e=[]){const s=n(t);s.current=t;const[a]=r((()=>new Ca(s))),l=ca.useSyncExternalStore(a.subscribe,a.getEditor,a.getServerSnapshot);return o(l),i(a.onRender(e)),function(t){const[e]=r((()=>new ka(t.editor))),n=wa.useSyncExternalStoreWithSelector(e.subscribe,e.getSnapshot,e.getServerSnapshot,t.selector,t.equalityFn);i((()=>e.watch(t.editor)),[t.editor,e]),o(n)}({editor:l,selector:({transactionNumber:e})=>!1===t.shouldRerenderOnTransaction?null:t.immediatelyRender&&0===e?0:e+1}),l}s({editor:null}).Consumer;const Ta=s({onDragStart:void 0});t.forwardRef(((e,n)=>{const{onDragStart:r}=a(Ta),o=e.as||"div";return t.createElement(o,{...e,ref:n,"data-node-view-wrapper":"",onDragStart:r,style:{whiteSpace:"normal",...e.style}})}));const Ea=Object.freeze({left:0,top:0,width:16,height:16}),Na=Object.freeze({rotate:0,vFlip:!1,hFlip:!1}),Aa=Object.freeze({...Ea,...Na}),Da=Object.freeze({...Aa,body:"",hidden:!1});function Ra(t,e){const n=function(t,e){const n={};!t.hFlip!=!e.hFlip&&(n.hFlip=!0),!t.vFlip!=!e.vFlip&&(n.vFlip=!0);const r=((t.rotate||0)+(e.rotate||0))%4;return r&&(n.rotate=r),n}(t,e);for(const r in Da)r in Na?r in t&&!(r in n)&&(n[r]=Na[r]):r in e?n[r]=e[r]:r in t&&(n[r]=t[r]);return n}function Ia(t,e,n){const r=t.icons,o=t.aliases||Object.create(null);let i={};function s(t){i=Ra(r[t]||o[t],i)}return s(e),n.forEach(s),Ra(t,i)}function La(t,e){const n=[];if("object"!=typeof t||"object"!=typeof t.icons)return n;t.not_found instanceof Array&&t.not_found.forEach((t=>{e(t,null),n.push(t)}));const r=function(t,e){const n=t.icons,r=t.aliases||Object.create(null),o=Object.create(null);return(e||Object.keys(n).concat(Object.keys(r))).forEach((function t(e){if(n[e])return o[e]=[];if(!(e in o)){o[e]=null;const n=r[e]&&r[e].parent,i=n&&t(n);i&&(o[e]=[n].concat(i))}return o[e]})),o}(t);for(const o in r){const i=r[o];i&&(e(o,Ia(t,o,i)),n.push(o))}return n}const Pa=/^[a-z0-9]+(-[a-z0-9]+)*$/,ja=(t,e,n,r="")=>{const o=t.split(":");if("@"===t.slice(0,1)){if(o.length<2||o.length>3)return null;r=o.shift().slice(1)}if(o.length>3||!o.length)return null;if(o.length>1){const t=o.pop(),n=o.pop(),i={provider:o.length>0?o[0]:r,prefix:n,name:t};return e&&!za(i)?null:i}const i=o[0],s=i.split("-");if(s.length>1){const t={provider:r,prefix:s.shift(),name:s.join("-")};return e&&!za(t)?null:t}if(n&&""===r){const t={provider:r,prefix:"",name:i};return e&&!za(t,n)?null:t}return null},za=(t,e)=>!!t&&!(""!==t.provider&&!t.provider.match(Pa)||!(e&&""===t.prefix||t.prefix.match(Pa))||!t.name.match(Pa)),$a={provider:"",aliases:{},not_found:{},...Ea};function Ba(t,e){for(const n in e)if(n in t&&typeof t[n]!=typeof e[n])return!1;return!0}function Fa(t){if("object"!=typeof t||null===t)return null;const e=t;if("string"!=typeof e.prefix||!t.icons||"object"!=typeof t.icons||!Ba(t,$a))return null;const n=e.icons;for(const t in n){const e=n[t];if(!t.match(Pa)||"string"!=typeof e.body||!Ba(e,Da))return null}const r=e.aliases||Object.create(null);for(const t in r){const e=r[t],o=e.parent;if(!t.match(Pa)||"string"!=typeof o||!n[o]&&!r[o]||!Ba(e,Da))return null}return e}const _a=Object.create(null);function Va(t,e){const n=_a[t]||(_a[t]=Object.create(null));return n[e]||(n[e]=function(t,e){return{provider:t,prefix:e,icons:Object.create(null),missing:new Set}}(t,e))}function Ha(t,e){return Fa(e)?La(e,((e,n)=>{n?t.icons[e]=n:t.missing.add(e)})):[]}let Wa=!1;function Ka(t){return"boolean"==typeof t&&(Wa=t),Wa}function qa(t){const e="string"==typeof t?ja(t,!0,Wa):t;if(e){const t=Va(e.provider,e.prefix),n=e.name;return t.icons[n]||(t.missing.has(n)?null:void 0)}}function Ja(t,e){if("object"!=typeof t)return!1;if("string"!=typeof e&&(e=t.provider||""),Wa&&!e&&!t.prefix){let e=!1;return Fa(t)&&(t.prefix="",La(t,((t,n)=>{n&&function(t,e){const n=ja(t,!0,Wa);return!!n&&function(t,e,n){try{if("string"==typeof n.body)return t.icons[e]={...n},!0}catch{}return!1}(Va(n.provider,n.prefix),n.name,e)}(t,n)&&(e=!0)}))),e}const n=t.prefix;if(!za({provider:e,prefix:n,name:"a"}))return!1;return!!Ha(Va(e,n),t)}const Ua=Object.freeze({width:null,height:null}),Ga=Object.freeze({...Ua,...Na}),Ya=/(-?[0-9.]*[0-9]+[0-9.]*)/g,Qa=/^-?[0-9.]*[0-9]+[0-9.]*$/g;function Xa(t,e,n){if(1===e)return t;if(n=n||100,"number"==typeof t)return Math.ceil(t*e*n)/n;if("string"!=typeof t)return t;const r=t.split(Ya);if(null===r||!r.length)return t;const o=[];let i=r.shift(),s=Qa.test(i);for(;;){if(s){const t=parseFloat(i);isNaN(t)?o.push(i):o.push(Math.ceil(t*e*n)/n)}else o.push(i);if(i=r.shift(),void 0===i)return o.join("");s=!s}}const Za=/\sid="(\S+)"/g,tl="IconifyId"+Date.now().toString(16)+(16777216*Math.random()|0).toString(16);let el=0;function nl(t,e=tl){const n=[];let r;for(;r=Za.exec(t);)n.push(r[1]);if(!n.length)return t;const o="suffix"+(16777216*Math.random()|Date.now()).toString(16);return n.forEach((n=>{const r="function"==typeof e?e(n):e+(el++).toString(),i=n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");t=t.replace(new RegExp('([#;"])('+i+')([")]|\\.[a-z])',"g"),"$1"+r+o+"$3")})),t=t.replace(new RegExp(o,"g"),"")}const rl=Object.create(null);function ol(t){return rl[t]||rl[""]}function il(t){let e;if("string"==typeof t.resources)e=[t.resources];else if(e=t.resources,!(e instanceof Array&&e.length))return null;return{resources:e,path:t.path||"/",maxURL:t.maxURL||500,rotate:t.rotate||750,timeout:t.timeout||5e3,random:!0===t.random,index:t.index||0,dataAfterTimeout:!1!==t.dataAfterTimeout}}const sl=Object.create(null),al=["https://api.simplesvg.com","https://api.unisvg.com"],ll=[];for(;al.length>0;)1===al.length||Math.random()>.5?ll.push(al.shift()):ll.push(al.pop());function cl(t,e){const n=il(e);return null!==n&&(sl[t]=n,!0)}function dl(t){return sl[t]}sl[""]=il({resources:["https://api.iconify.design"].concat(ll)});let hl=(()=>{let t;try{if(t=fetch,"function"==typeof t)return t}catch{}})();const ul={prepare:(t,e,n)=>{const r=[],o=function(t,e){const n=dl(t);if(!n)return 0;let r;if(n.maxURL){let t=0;n.resources.forEach((e=>{t=Math.max(t,e.length)}));const o=e+".json?icons=";r=n.maxURL-t-n.path.length-o.length}else r=0;return r}(t,e),i="icons";let s={type:i,provider:t,prefix:e,icons:[]},a=0;return n.forEach(((n,l)=>{a+=n.length+1,a>=o&&l>0&&(r.push(s),s={type:i,provider:t,prefix:e,icons:[]},a=n.length),s.icons.push(n)})),r.push(s),r},send:(t,e,n)=>{if(!hl)return void n("abort",424);let r=function(t){if("string"==typeof t){const e=dl(t);if(e)return e.path}return"/"}(e.provider);switch(e.type){case"icons":{const t=e.prefix,n=e.icons.join(",");r+=t+".json?"+new URLSearchParams({icons:n}).toString();break}case"custom":{const t=e.uri;r+="/"===t.slice(0,1)?t.slice(1):t;break}default:return void n("abort",400)}let o=503;hl(t+r).then((t=>{const e=t.status;if(200===e)return o=501,t.json();setTimeout((()=>{n(function(t){return 404===t}(e)?"abort":"next",e)}))})).then((t=>{"object"==typeof t&&null!==t?setTimeout((()=>{n("success",t)})):setTimeout((()=>{404===t?n("abort",t):n("next",o)}))})).catch((()=>{n("next",o)}))}};function pl(t,e){t.forEach((t=>{const n=t.loaderCallbacks;n&&(t.loaderCallbacks=n.filter((t=>t.id!==e)))}))}let fl=0;var ml={resources:[],index:0,timeout:2e3,rotate:750,random:!1,dataAfterTimeout:!1};function gl(t,e,n,r){const o=t.resources.length,i=t.random?Math.floor(Math.random()*o):t.index;let s;if(t.random){let e=t.resources.slice(0);for(s=[];e.length>1;){const t=Math.floor(Math.random()*e.length);s.push(e[t]),e=e.slice(0,t).concat(e.slice(t+1))}s=s.concat(e)}else s=t.resources.slice(i).concat(t.resources.slice(0,i));const a=Date.now();let l,c="pending",d=0,h=null,u=[],p=[];function f(){h&&(clearTimeout(h),h=null)}function m(){"pending"===c&&(c="aborted"),f(),u.forEach((t=>{"pending"===t.status&&(t.status="aborted")})),u=[]}function g(t,e){e&&(p=[]),"function"==typeof t&&p.push(t)}function y(){c="failed",p.forEach((t=>{t(void 0,l)}))}function b(){u.forEach((t=>{"pending"===t.status&&(t.status="aborted")})),u=[]}function v(){if("pending"!==c)return;f();const r=s.shift();if(void 0===r)return u.length?void(h=setTimeout((()=>{f(),"pending"===c&&(b(),y())}),t.timeout)):void y();const o={status:"pending",resource:r,callback:(e,n)=>{!function(e,n,r){const o="success"!==n;switch(u=u.filter((t=>t!==e)),c){case"pending":break;case"failed":if(o||!t.dataAfterTimeout)return;break;default:return}if("abort"===n)return l=r,void y();if(o)return l=r,void(u.length||(s.length?v():y()));if(f(),b(),!t.random){const n=t.resources.indexOf(e.resource);-1!==n&&n!==t.index&&(t.index=n)}c="completed",p.forEach((t=>{t(r)}))}(o,e,n)}};u.push(o),d++,h=setTimeout(v,t.rotate),n(r,e,o.callback)}return"function"==typeof r&&p.push(r),setTimeout(v),function(){return{startTime:a,payload:e,status:c,queriesSent:d,queriesPending:u.length,subscribe:g,abort:m}}}function yl(t){const e={...ml,...t};let n=[];function r(){n=n.filter((t=>"pending"===t().status))}return{query:function(t,o,i){const s=gl(e,t,o,((t,e)=>{r(),i&&i(t,e)}));return n.push(s),s},find:function(t){return n.find((e=>t(e)))||null},setIndex:t=>{e.index=t},getIndex:()=>e.index,cleanup:r}}function bl(){}const vl=Object.create(null);function wl(t,e,n){let r,o;if("string"==typeof t){const e=ol(t);if(!e)return n(void 0,424),bl;o=e.send;const i=function(t){if(!vl[t]){const e=dl(t);if(!e)return;const n={config:e,redundancy:yl(e)};vl[t]=n}return vl[t]}(t);i&&(r=i.redundancy)}else{const e=il(t);if(e){r=yl(e);const n=ol(t.resources?t.resources[0]:"");n&&(o=n.send)}}return r&&o?r.query(e,o,n)().abort:(n(void 0,424),bl)}const kl="iconify2",xl="iconify",Sl=xl+"-count",Ol=xl+"-version",Cl=36e5,Ml=168,Tl=50;function El(t,e){try{return t.getItem(e)}catch{}}function Nl(t,e,n){try{return t.setItem(e,n),!0}catch{}}function Al(t,e){try{t.removeItem(e)}catch{}}function Dl(t,e){return Nl(t,Sl,e.toString())}function Rl(t){return parseInt(El(t,Sl))||0}const Il={local:!0,session:!0},Ll={local:new Set,session:new Set};let Pl=!1;let jl=typeof window>"u"?{}:window;function zl(t){const e=t+"Storage";try{if(jl&&jl[e]&&"number"==typeof jl[e].length)return jl[e]}catch{}Il[t]=!1}function $l(t,e){const n=zl(t);if(!n)return;const r=El(n,Ol);if(r!==kl){if(r){const t=Rl(n);for(let e=0;e<t;e++)Al(n,xl+e.toString())}return Nl(n,Ol,kl),void Dl(n,0)}const o=Math.floor(Date.now()/Cl)-Ml,i=t=>{const r=xl+t.toString(),i=El(n,r);if("string"==typeof i){try{const n=JSON.parse(i);if("object"==typeof n&&"number"==typeof n.cached&&n.cached>o&&"string"==typeof n.provider&&"object"==typeof n.data&&"string"==typeof n.data.prefix&&e(n,t))return!0}catch{}Al(n,r)}};let s=Rl(n);for(let e=s-1;e>=0;e--)i(e)||(e===s-1?(s--,Dl(n,s)):Ll[t].add(e))}function Bl(){if(!Pl){Pl=!0;for(const t in Il)$l(t,(t=>{const e=t.data,n=Va(t.provider,e.prefix);if(!Ha(n,e).length)return!1;const r=e.lastModified||-1;return n.lastModifiedCached=n.lastModifiedCached?Math.min(n.lastModifiedCached,r):r,!0}))}}function Fl(t,e){function n(n){let r;if(!Il[n]||!(r=zl(n)))return;const o=Ll[n];let i;if(o.size)o.delete(i=Array.from(o).shift());else if(i=Rl(r),i>=Tl||!Dl(r,i+1))return;const s={cached:Math.floor(Date.now()/Cl),provider:t.provider,data:e};return Nl(r,xl+i.toString(),JSON.stringify(s))}Pl||Bl(),e.lastModified&&!function(t,e){const n=t.lastModifiedCached;if(n&&n>=e)return n===e;if(t.lastModifiedCached=e,n)for(const n in Il)$l(n,(n=>{const r=n.data;return n.provider!==t.provider||r.prefix!==t.prefix||r.lastModified===e}));return!0}(t,e.lastModified)||Object.keys(e.icons).length&&(e.not_found&&delete(e=Object.assign({},e)).not_found,n("local")||n("session"))}function _l(){}function Vl(t){t.iconsLoaderFlag||(t.iconsLoaderFlag=!0,setTimeout((()=>{t.iconsLoaderFlag=!1,function(t){t.pendingCallbacksFlag||(t.pendingCallbacksFlag=!0,setTimeout((()=>{t.pendingCallbacksFlag=!1;const e=t.loaderCallbacks?t.loaderCallbacks.slice(0):[];if(!e.length)return;let n=!1;const r=t.provider,o=t.prefix;e.forEach((e=>{const i=e.icons,s=i.pending.length;i.pending=i.pending.filter((e=>{if(e.prefix!==o)return!0;const s=e.name;if(t.icons[s])i.loaded.push({provider:r,prefix:o,name:s});else{if(!t.missing.has(s))return n=!0,!0;i.missing.push({provider:r,prefix:o,name:s})}return!1})),i.pending.length!==s&&(n||pl([t],e.id),e.callback(i.loaded.slice(0),i.missing.slice(0),i.pending.slice(0),e.abort))}))})))}(t)})))}const Hl=(t,e)=>{const n=function(t,e=!0,n=!1){const r=[];return t.forEach((t=>{const o="string"==typeof t?ja(t,e,n):t;o&&r.push(o)})),r}(t,!0,Ka()),r=function(t){const e={loaded:[],missing:[],pending:[]},n=Object.create(null);t.sort(((t,e)=>t.provider!==e.provider?t.provider.localeCompare(e.provider):t.prefix!==e.prefix?t.prefix.localeCompare(e.prefix):t.name.localeCompare(e.name)));let r={provider:"",prefix:"",name:""};return t.forEach((t=>{if(r.name===t.name&&r.prefix===t.prefix&&r.provider===t.provider)return;r=t;const o=t.provider,i=t.prefix,s=t.name,a=n[o]||(n[o]=Object.create(null)),l=a[i]||(a[i]=Va(o,i));let c;c=s in l.icons?e.loaded:""===i||l.missing.has(s)?e.missing:e.pending;const d={provider:o,prefix:i,name:s};c.push(d)})),e}(n);if(!r.pending.length){let t=!0;return e&&setTimeout((()=>{t&&e(r.loaded,r.missing,r.pending,_l)})),()=>{t=!1}}const o=Object.create(null),i=[];let s,a;return r.pending.forEach((t=>{const{provider:e,prefix:n}=t;if(n===a&&e===s)return;s=e,a=n,i.push(Va(e,n));const r=o[e]||(o[e]=Object.create(null));r[n]||(r[n]=[])})),r.pending.forEach((t=>{const{provider:e,prefix:n,name:r}=t,i=Va(e,n),s=i.pendingIcons||(i.pendingIcons=new Set);s.has(r)||(s.add(r),o[e][n].push(r))})),i.forEach((t=>{const{provider:e,prefix:n}=t;o[e][n].length&&function(t,e){t.iconsToLoad?t.iconsToLoad=t.iconsToLoad.concat(e).sort():t.iconsToLoad=e,t.iconsQueueFlag||(t.iconsQueueFlag=!0,setTimeout((()=>{t.iconsQueueFlag=!1;const{provider:e,prefix:n}=t,r=t.iconsToLoad;let o;delete t.iconsToLoad,r&&(o=ol(e))&&o.prepare(e,n,r).forEach((n=>{wl(e,n,(e=>{if("object"!=typeof e)n.icons.forEach((e=>{t.missing.add(e)}));else try{const n=Ha(t,e);if(!n.length)return;const r=t.pendingIcons;r&&n.forEach((t=>{r.delete(t)})),Fl(t,e)}catch(t){console.error(t)}Vl(t)}))}))})))}(t,o[e][n])})),e?function(t,e,n){const r=fl++,o=pl.bind(null,n,r);if(!e.pending.length)return o;const i={id:r,icons:e,callback:t,abort:o};return n.forEach((t=>{(t.loaderCallbacks||(t.loaderCallbacks=[])).push(i)})),o}(e,r,i):_l};const Wl=/[\s,]+/;function Kl(t,e){e.split(Wl).forEach((e=>{switch(e.trim()){case"horizontal":t.hFlip=!0;break;case"vertical":t.vFlip=!0}}))}function ql(t,e=0){const n=t.replace(/^-?[0-9.]*/,"");function r(t){for(;t<0;)t+=4;return t%4}if(""===n){const e=parseInt(t);return isNaN(e)?0:r(e)}if(n!==t){let e=0;switch(n){case"%":e=25;break;case"deg":e=90}if(e){let o=parseFloat(t.slice(0,t.length-n.length));return isNaN(o)?0:(o/=e,o%1==0?r(o):0)}}return e}function Jl(t){return'url("'+function(t){return"data:image/svg+xml,"+function(t){return t.replace(/"/g,"'").replace(/%/g,"%25").replace(/#/g,"%23").replace(/</g,"%3C").replace(/>/g,"%3E").replace(/\s+/g," ")}(t)}(t)+'")'}let Ul;function Gl(t){return void 0===Ul&&function(){try{Ul=window.trustedTypes.createPolicy("iconify",{createHTML:t=>t})}catch{Ul=null}}(),Ul?Ul.createHTML(t):t}const Yl={...Ga,inline:!1},Ql={xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":!0,role:"img"},Xl={display:"inline-block"},Zl={backgroundColor:"currentColor"},tc={backgroundColor:"transparent"},ec={Image:"var(--svg)",Repeat:"no-repeat",Size:"100% 100%"},nc={WebkitMask:Zl,mask:Zl,background:tc};for(const t in nc){const e=nc[t];for(const n in ec)e[t+n]=ec[n]}const rc={...Yl,inline:!0};function oc(t){return t+(t.match(/^[-0-9.]+$/)?"px":"")}const ic=(t,e,n)=>{const r=e.inline?rc:Yl,o=function(t,e){const n={...t};for(const t in e){const r=e[t],o=typeof r;t in Ua?(null===r||r&&("string"===o||"number"===o))&&(n[t]=r):o===typeof n[t]&&(n[t]="rotate"===t?r%4:r)}return n}(r,e),i=e.mode||"svg",s={},a=e.style||{},c={..."svg"===i?Ql:{}};if(n){const t=ja(n,!1,!0);if(t){const e=["iconify"],n=["provider","prefix"];for(const r of n)t[r]&&e.push("iconify--"+t[r]);c.className=e.join(" ")}}for(let t in e){const n=e[t];if(void 0!==n)switch(t){case"icon":case"style":case"children":case"onLoad":case"mode":case"ssr":break;case"_ref":c.ref=n;break;case"className":c[t]=(c[t]?c[t]+" ":"")+n;break;case"inline":case"hFlip":case"vFlip":o[t]=!0===n||"true"===n||1===n;break;case"flip":"string"==typeof n&&Kl(o,n);break;case"color":s.color=n;break;case"rotate":"string"==typeof n?o[t]=ql(n):"number"==typeof n&&(o[t]=n);break;case"ariaHidden":case"aria-hidden":!0!==n&&"true"!==n&&delete c["aria-hidden"];break;default:void 0===r[t]&&(c[t]=n)}}const d=function(t,e){const n={...Aa,...t},r={...Ga,...e},o={left:n.left,top:n.top,width:n.width,height:n.height};let i=n.body;[n,r].forEach((t=>{const e=[],n=t.hFlip,r=t.vFlip;let s,a=t.rotate;switch(n?r?a+=2:(e.push("translate("+(o.width+o.left).toString()+" "+(0-o.top).toString()+")"),e.push("scale(-1 1)"),o.top=o.left=0):r&&(e.push("translate("+(0-o.left).toString()+" "+(o.height+o.top).toString()+")"),e.push("scale(1 -1)"),o.top=o.left=0),a<0&&(a-=4*Math.floor(a/4)),a%=4,a){case 1:s=o.height/2+o.top,e.unshift("rotate(90 "+s.toString()+" "+s.toString()+")");break;case 2:e.unshift("rotate(180 "+(o.width/2+o.left).toString()+" "+(o.height/2+o.top).toString()+")");break;case 3:s=o.width/2+o.left,e.unshift("rotate(-90 "+s.toString()+" "+s.toString()+")")}a%2==1&&(o.left!==o.top&&(s=o.left,o.left=o.top,o.top=s),o.width!==o.height&&(s=o.width,o.width=o.height,o.height=s)),e.length&&(i=function(t,e,n){const r=function(t,e="defs"){let n="";const r=t.indexOf("<"+e);for(;r>=0;){const o=t.indexOf(">",r),i=t.indexOf("</"+e);if(-1===o||-1===i)break;const s=t.indexOf(">",i);if(-1===s)break;n+=t.slice(o+1,i).trim(),t=t.slice(0,r).trim()+t.slice(s+1)}return{defs:n,content:t}}(t);return function(t,e){return t?"<defs>"+t+"</defs>"+e:e}(r.defs,e+r.content+n)}(i,'<g transform="'+e.join(" ")+'">',"</g>"))}));const s=r.width,a=r.height,l=o.width,c=o.height;let d,h;null===s?(h=null===a?"1em":"auto"===a?c:a,d=Xa(h,l/c)):(d="auto"===s?l:s,h=null===a?Xa(d,c/l):"auto"===a?c:a);const u={},p=(t,e)=>{(t=>"unset"===t||"undefined"===t||"none"===t)(e)||(u[t]=e.toString())};p("width",d),p("height",h);const f=[o.left,o.top,l,c];return u.viewBox=f.join(" "),{attributes:u,viewBox:f,body:i}}(t,o),h=d.attributes;if(o.inline&&(s.verticalAlign="-0.125em"),"svg"===i){c.style={...s,...a},Object.assign(c,h);let t=0,n=e.id;return"string"==typeof n&&(n=n.replace(/-/g,"_")),c.dangerouslySetInnerHTML={__html:Gl(nl(d.body,n?()=>n+"ID"+t++:"iconifyReact"))},l("svg",c)}const{body:u,width:p,height:f}=t,m="mask"===i||"bg"!==i&&-1!==u.indexOf("currentColor"),g=function(t,e){let n=-1===t.indexOf("xlink:")?"":' xmlns:xlink="http://www.w3.org/1999/xlink"';for(const t in e)n+=" "+t+'="'+e[t]+'"';return'<svg xmlns="http://www.w3.org/2000/svg"'+n+">"+t+"</svg>"}(u,{...h,width:p+"",height:f+""});return c.style={...s,"--svg":Jl(g),width:oc(h.width),height:oc(h.height),...Xl,...m?Zl:tc,...a},l("span",c)};var sc;if(Ka(!0),sc=ul,rl[""]=sc,typeof document<"u"&&typeof window<"u"){Bl();const t=window;if(void 0!==t.IconifyPreload){const e=t.IconifyPreload,n="Invalid IconifyPreload syntax.";"object"==typeof e&&null!==e&&(e instanceof Array?e:[e]).forEach((t=>{try{("object"!=typeof t||null===t||t instanceof Array||"object"!=typeof t.icons||"string"!=typeof t.prefix||!Ja(t))&&console.error(n)}catch{console.error(n)}}))}if(void 0!==t.IconifyProviders){const e=t.IconifyProviders;if("object"==typeof e&&null!==e)for(let t in e){const n="IconifyProviders["+t+"] is invalid.";try{const r=e[t];if("object"!=typeof r||!r||void 0===r.resources)continue;cl(t,r)||console.error(n)}catch{console.error(n)}}}}function ac(t){const[e,n]=r(!!t.ssr),[o,s]=r({});const[a,c]=r(function(e){if(e){const e=t.icon;if("object"==typeof e)return{name:"",data:e};const n=qa(e);if(n)return{name:e,data:n}}return{name:""}}(!!t.ssr));function d(){const t=o.callback;t&&(t(),s({}))}function h(t){if(JSON.stringify(a)!==JSON.stringify(t))return d(),c(t),!0}function u(){var e;const n=t.icon;if("object"==typeof n)return void h({name:"",data:n});const r=qa(n);if(h({name:n,data:r}))if(void 0===r){const t=Hl([n],u);s({callback:t})}else r&&(null===(e=t.onLoad)||void 0===e||e.call(t,n))}i((()=>(n(!0),d)),[]),i((()=>{e&&u()}),[t.icon,e]);const{name:p,data:f}=a;return f?ic({...Aa,...f},t,p):t.children?t.children:l("span",{})}const lc=e(((t,e)=>ac({...t,_ref:e})));e(((t,e)=>ac({inline:!0,...t,_ref:e})));const cc=()=>{const t=new URLSearchParams(window.location.search).get("lang")||localStorage.getItem("lang")||"en";return{Norsk:"no"===t,English:"en"===t}},dc=({editor:t,onClose:e,error:o,focused:s,openLinkDialog:a})=>{const[l,d]=r(0),h=n(null),{Norsk:g}=cc(),y=g?"Lukk":"Close",[b,v]=r(!1),[k,x]=r([]);i((()=>{const e=new ResizeObserver((()=>{var e;if(h.current){const n=h.current.clientWidth;v(n<432);const r=null==(e=[{width:156,buttons:0},{width:192,buttons:1},{width:270,buttons:2},{width:316,buttons:3},{width:352,buttons:4},{width:388,buttons:5},{width:428,buttons:6},{width:432,buttons:7},{width:1/0,buttons:8}].find((t=>n<t.width)))?void 0:e.buttons;d(void 0!==r?r:8);const o=[];Number(r)<8&&o.push(M.jsx(m,{className:"flex items-center justify-center",onClick:a,children:M.jsx(p,{})},"link")),Number(r)<7&&o.push(M.jsx(m,{className:"flex items-center justify-center",onClick:()=>t.chain().focus().toggleItalic().run(),children:M.jsx(lc,{icon:"material-symbols:format-italic",height:20})},"italic")),Number(r)<6&&o.push(M.jsx(m,{className:"flex items-center justify-center",onClick:()=>t.chain().focus().toggleBold().run(),children:M.jsx(lc,{icon:"ooui:bold-b"})},"bold")),Number(r)<5&&o.push(M.jsx(m,{className:"flex items-center justify-center",onClick:()=>t.chain().focus().toggleOrderedList().run(),children:M.jsx(lc,{icon:"mdi:format-list-numbered",fontSize:20})},"ordered")),Number(r)<4&&o.push(M.jsx(m,{className:"flex items-center justify-center",onClick:()=>t.chain().focus().toggleBulletList().run(),children:M.jsx(lc,{icon:"mdi:format-list-bulleted",fontSize:20})},"bullet")),x(o)}}));return h.current&&e.observe(h.current),()=>e.disconnect()}),[t,a]);const{anchorEl:S,open:O,handleClose:C,handleOpen:T}=(()=>{const[t,e]=r(null),n=!!t,o=c((t=>{e(t.currentTarget)}),[]);return{open:n,handleClose:c((()=>{e(null)}),[]),handleOpen:o,anchorEl:t}})();return M.jsx(M.Fragment,{children:M.jsxs("div",{className:E("toolbar",{"toolbar-error":o,"toolbar-focused":s}),ref:h,children:[M.jsx("div",{className:"absolute top-0 left-0 w-full bg-gray-300 h-[0.5px] overflow-hidden"}),M.jsxs("div",{className:"flex flex-row gap-1",children:[l>=1&&M.jsx(u,{dataTest:"richeditor-h1-button",size:"small",variant:t.isActive("heading",{level:1})?"outlined":"textGray",onClick:()=>{t.chain().focus().setMark("textStyle",{fontSize:void 0}).run(),t.chain().focus().setNode("heading",{level:1}).run()},children:M.jsx(lc,{icon:"bi:type-h1"})}),l>=2&&M.jsx(u,{dataTest:"richeditor-h2-button",size:"small",variant:t.isActive("heading",{level:2})?"outlined":"textGray",onClick:()=>{t.chain().focus().setMark("textStyle",{fontSize:void 0}).run(),t.chain().focus().setNode("heading",{level:2}).run()},children:M.jsx(lc,{icon:"bi:type-h2"})}),l>=3&&M.jsxs("div",{className:"select-wrapper",children:[M.jsxs("select",{className:"font-size-select",onChange:e=>{const n=e.target.value;t.chain().focus().setMark("textStyle",{fontSize:{small:"10px",normal:"16px",large:"24px",huge:"32px"}[n]}).run()},defaultValue:"normal",children:[M.jsx("option",{value:"small",children:"Small"}),M.jsx("option",{value:"normal",children:"Normal"}),M.jsx("option",{value:"large",children:"Large"}),M.jsx("option",{value:"huge",children:"Huge"})]}),M.jsx(lc,{icon:"tabler:caret-up-down-filled",className:"chevron-icon"})]}),l>=4&&M.jsx(u,{dataTest:"richeditor-bullet-list-button",size:"small",variant:t.isActive("bulletList")?"outlined":"textGray",onClick:()=>t.chain().focus().toggleBulletList().run(),children:M.jsx(lc,{icon:"mdi:format-list-bulleted",fontSize:20})}),l>=5&&M.jsx(u,{dataTest:"richeditor-ordered-list-button",size:"small",variant:t.isActive("orderedList")?"outlined":"textGray",onClick:()=>t.chain().focus().toggleOrderedList().run(),children:M.jsx(lc,{icon:"mdi:format-list-numbered",fontSize:20})}),l>=6&&M.jsx(u,{dataTest:"richeditor-bold-button",size:"small",variant:t.isActive("bold")?"outlined":"textGray",onClick:()=>t.chain().focus().toggleBold().run(),children:M.jsx(lc,{icon:"ooui:bold-b"})}),l>=7&&M.jsx(u,{dataTest:"richeditor-italic-button",size:"small",variant:t.isActive("italic")?"outlined":"textGray",onClick:()=>t.chain().focus().toggleItalic().run(),children:M.jsx(lc,{icon:"material-symbols:format-italic",height:20})}),l>=8&&M.jsx(u,{dataTest:"richeditor-link-button",size:"small",variant:t.isActive("link")?"outlined":"textGray",onClick:a,children:M.jsx(p,{})})]}),M.jsxs("div",{className:"flex flex-row",children:[b&&M.jsxs(M.Fragment,{children:[M.jsx(u,{size:"small",dataTest:"richeditor-more-menu-button",variant:"text",onClick:t=>{t.stopPropagation(),t.preventDefault(),T(t)},onMouseDown:t=>{t.stopPropagation(),t.preventDefault()},onMouseUp:t=>{t.stopPropagation(),t.preventDefault()},children:M.jsx(f,{className:"text-delta-800",width:20,height:20})}),M.jsx(w,{open:O,anchorEl:S,onClose:C,onClick:C,anchorOrigin:{horizontal:"center",vertical:"bottom"},transformOrigin:{vertical:"top",horizontal:"right"},children:k})]}),M.jsx(u,{dataTest:"richeditor-close-toolbar-button",size:"small",variant:"text",onClick:e,children:y})]})]})})},hc=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,uc=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,pc=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,fc=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,mc=ss.create({name:"bold",addOptions:()=>({HTMLAttributes:{}}),parseHTML:()=>[{tag:"strong"},{tag:"b",getAttrs:t=>"normal"!==t.style.fontWeight&&null},{style:"font-weight",getAttrs:t=>/^(bold(er)?|[5-9]\d{2,})$/.test(t)&&null}],renderHTML({HTMLAttributes:t}){return["strong",Hi(this.options.HTMLAttributes,t),0]},addCommands(){return{setBold:()=>({commands:t})=>t.setMark(this.name),toggleBold:()=>({commands:t})=>t.toggleMark(this.name),unsetBold:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[ta({find:hc,type:this.type}),ta({find:pc,type:this.type})]},addPasteRules(){return[ra({find:uc,type:this.type}),ra({find:fc,type:this.type})]}}),gc=na.create({name:"listItem",addOptions:()=>({HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}),content:"paragraph block*",defining:!0,parseHTML:()=>[{tag:"li"}],renderHTML({HTMLAttributes:t}){return["li",Hi(this.options.HTMLAttributes,t),0]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),yc=ss.create({name:"textStyle",priority:101,addOptions:()=>({HTMLAttributes:{}}),parseHTML:()=>[{tag:"span",getAttrs:t=>!!t.hasAttribute("style")&&{}}],renderHTML({HTMLAttributes:t}){return["span",Hi(this.options.HTMLAttributes,t),0]},addCommands(){return{removeEmptyTextStyle:()=>({state:t,commands:e})=>{const n=Rs(t,this.type);return!!Object.entries(n).some((([,t])=>!!t))||e.unsetMark(this.name)}}}}),bc=/^\s*([-+*])\s$/,vc=na.create({name:"bulletList",addOptions:()=>({itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}),group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML:()=>[{tag:"ul"}],renderHTML({HTMLAttributes:t}){return["ul",Hi(this.options.HTMLAttributes,t),0]},addCommands(){return{toggleBulletList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(gc.name,this.editor.getAttributes(yc.name)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=ea({find:bc,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=ea({find:bc,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(yc.name),editor:this.editor})),[t]}}),wc=na.create({name:"heading",addOptions:()=>({levels:[1,2,3,4,5,6],HTMLAttributes:{}}),content:"inline*",group:"block",defining:!0,addAttributes:()=>({level:{default:1,rendered:!1}}),parseHTML(){return this.options.levels.map((t=>({tag:`h${t}`,attrs:{level:t}})))},renderHTML({node:t,HTMLAttributes:e}){return[`h${this.options.levels.includes(t.attrs.level)?t.attrs.level:this.options.levels[0]}`,Hi(this.options.HTMLAttributes,e),0]},addCommands(){return{setHeading:t=>({commands:e})=>!!this.options.levels.includes(t.level)&&e.setNode(this.name,t),toggleHeading:t=>({commands:e})=>!!this.options.levels.includes(t.level)&&e.toggleNode(this.name,"paragraph",t)}},addKeyboardShortcuts(){return this.options.levels.reduce(((t,e)=>({...t,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})})),{})},addInputRules(){return this.options.levels.map((t=>function(t){return new Zi({find:t.find,handler:({state:e,range:n,match:r})=>{const o=e.doc.resolve(n.from),i=qi(t.getAttributes,void 0,r)||{};if(!o.node(-1).canReplaceWith(o.index(-1),o.indexAfter(-1),t.type))return null;e.tr.delete(n.from,n.to).setBlockType(n.from,n.from,t.type,i)}})}({find:new RegExp(`^(#{1,${t}})\\s$`),type:this.type,getAttributes:{level:t}})))}}),kc=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,xc=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,Sc=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,Oc=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,Cc=ss.create({name:"italic",addOptions:()=>({HTMLAttributes:{}}),parseHTML:()=>[{tag:"em"},{tag:"i",getAttrs:t=>"normal"!==t.style.fontStyle&&null},{style:"font-style=italic"}],renderHTML({HTMLAttributes:t}){return["em",Hi(this.options.HTMLAttributes,t),0]},addCommands(){return{setItalic:()=>({commands:t})=>t.setMark(this.name),toggleItalic:()=>({commands:t})=>t.toggleMark(this.name),unsetItalic:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[ta({find:kc,type:this.type}),ta({find:Sc,type:this.type})]},addPasteRules(){return[ra({find:xc,type:this.type}),ra({find:Oc,type:this.type})]}}),Mc="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4vianca6w0s2x0a2z0ure5ba0by2idu3namex3narepublic11d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2ntley5rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0cast4mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dabur3d1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0ardian6cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6logistics9properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3ncaster6d0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2psy3ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2tura4vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9dnavy5lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0america6xi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0a1b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp2w2ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4finity6ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",Tc="ελ1υ2бг1ел3дети4ею2католик6ом3мкд2он1сква6онлайн5рг3рус2ф2сайт3рб3укр3қаз3հայ3ישראל5קום3ابوظبي5رامكو5لاردن4بحرين5جزائر5سعودية6عليان5مغرب5مارات5یران5بارت2زار4يتك3ھارت5تونس4سودان3رية5شبكة4عراق2ب2مان4فلسطين6قطر3كاثوليك6وم3مصر2ليسيا5وريتانيا7قع4همراه5پاکستان7ڀارت4कॉम3नेट3भारत0म्3ोत5संगठन5বাংলা5ভারত2ৰত4ਭਾਰਤ4ભારત4ଭାରତ4இந்தியா6லங்கை6சிங்கப்பூர்11భారత్5ಭಾರತ4ഭാരതം5ලංකා4คอม3ไทย3ລາວ3გე2みんな3アマゾン4クラウド4グーグル4コム2ストア3セール3ファッション6ポイント4世界2中信1国1國1文网3亚马逊3企业2佛山2信息2健康2八卦2公司1益2台湾1灣2商城1店1标2嘉里0大酒店5在线2大拿2天主教3娱乐2家電2广东2微博2慈善2我爱你3手机2招聘2政务1府2新加坡2闻2时尚2書籍2机构2淡马锡3游戏2澳門2点看2移动2组织机构4网址1店1站1络2联通2谷歌2购物2通販2集团2電訊盈科4飞利浦3食品2餐厅2香格里拉3港2닷넷1컴2삼성2한국2",Ec=(t,e)=>{for(const n in e)t[n]=e[n];return t},Nc="numeric",Ac="ascii",Dc="alpha",Rc="asciinumeric",Ic="alphanumeric",Lc="domain",Pc="emoji",jc="scheme",zc="slashscheme",$c="whitespace";function Bc(t,e){return t in e||(e[t]=[]),e[t]}function Fc(t,e,n){e[Nc]&&(e[Rc]=!0,e[Ic]=!0),e[Ac]&&(e[Rc]=!0,e[Dc]=!0),e[Rc]&&(e[Ic]=!0),e[Dc]&&(e[Ic]=!0),e[Ic]&&(e[Lc]=!0),e[Pc]&&(e[Lc]=!0);for(const r in e){const e=Bc(r,n);e.indexOf(t)<0&&e.push(t)}}function _c(t){void 0===t&&(t=null),this.j={},this.jr=[],this.jd=null,this.t=t}_c.groups={},_c.prototype={accepts(){return!!this.t},go(t){const e=this,n=e.j[t];if(n)return n;for(let n=0;n<e.jr.length;n++){const r=e.jr[n][0],o=e.jr[n][1];if(o&&r.test(t))return o}return e.jd},has(t,e){return void 0===e&&(e=!1),e?t in this.j:!!this.go(t)},ta(t,e,n,r){for(let o=0;o<t.length;o++)this.tt(t[o],e,n,r)},tr(t,e,n,r){let o;return r=r||_c.groups,e&&e.j?o=e:(o=new _c(e),n&&r&&Fc(e,n,r)),this.jr.push([t,o]),o},ts(t,e,n,r){let o=this;const i=t.length;if(!i)return o;for(let e=0;e<i-1;e++)o=o.tt(t[e]);return o.tt(t[i-1],e,n,r)},tt(t,e,n,r){r=r||_c.groups;const o=this;if(e&&e.j)return o.j[t]=e,e;const i=e;let s,a=o.go(t);if(a?(s=new _c,Ec(s.j,a.j),s.jr.push.apply(s.jr,a.jr),s.jd=a.jd,s.t=a.t):s=new _c,i){if(r)if(s.t&&"string"==typeof s.t){const t=Ec(function(t,e){const n={};for(const r in e)e[r].indexOf(t)>=0&&(n[r]=!0);return n}(s.t,r),n);Fc(i,t,r)}else n&&Fc(i,n,r);s.t=i}return o.j[t]=s,s}};const Vc=(t,e,n,r,o)=>t.ta(e,n,r,o),Hc=(t,e,n,r,o)=>t.tr(e,n,r,o),Wc=(t,e,n,r,o)=>t.ts(e,n,r,o),Kc=(t,e,n,r,o)=>t.tt(e,n,r,o),qc="WORD",Jc="UWORD",Uc="LOCALHOST",Gc="TLD",Yc="UTLD",Qc="SCHEME",Xc="SLASH_SCHEME",Zc="NUM",td="WS",ed="NL",nd="OPENBRACE",rd="CLOSEBRACE",od="OPENBRACKET",id="CLOSEBRACKET",sd="OPENPAREN",ad="CLOSEPAREN",ld="OPENANGLEBRACKET",cd="CLOSEANGLEBRACKET",dd="FULLWIDTHLEFTPAREN",hd="FULLWIDTHRIGHTPAREN",ud="LEFTCORNERBRACKET",pd="RIGHTCORNERBRACKET",fd="LEFTWHITECORNERBRACKET",md="RIGHTWHITECORNERBRACKET",gd="FULLWIDTHLESSTHAN",yd="FULLWIDTHGREATERTHAN",bd="AMPERSAND",vd="APOSTROPHE",wd="ASTERISK",kd="AT",xd="BACKSLASH",Sd="BACKTICK",Od="CARET",Cd="COLON",Md="COMMA",Td="DOLLAR",Ed="DOT",Nd="EQUALS",Ad="EXCLAMATION",Dd="HYPHEN",Rd="PERCENT",Id="PIPE",Ld="PLUS",Pd="POUND",jd="QUERY",zd="QUOTE",$d="SEMI",Bd="SLASH",Fd="TILDE",_d="UNDERSCORE",Vd="EMOJI",Hd="SYM";var Wd=Object.freeze({__proto__:null,WORD:qc,UWORD:Jc,LOCALHOST:Uc,TLD:Gc,UTLD:Yc,SCHEME:Qc,SLASH_SCHEME:Xc,NUM:Zc,WS:td,NL:ed,OPENBRACE:nd,CLOSEBRACE:rd,OPENBRACKET:od,CLOSEBRACKET:id,OPENPAREN:sd,CLOSEPAREN:ad,OPENANGLEBRACKET:ld,CLOSEANGLEBRACKET:cd,FULLWIDTHLEFTPAREN:dd,FULLWIDTHRIGHTPAREN:hd,LEFTCORNERBRACKET:ud,RIGHTCORNERBRACKET:pd,LEFTWHITECORNERBRACKET:fd,RIGHTWHITECORNERBRACKET:md,FULLWIDTHLESSTHAN:gd,FULLWIDTHGREATERTHAN:yd,AMPERSAND:bd,APOSTROPHE:vd,ASTERISK:wd,AT:kd,BACKSLASH:xd,BACKTICK:Sd,CARET:Od,COLON:Cd,COMMA:Md,DOLLAR:Td,DOT:Ed,EQUALS:Nd,EXCLAMATION:Ad,HYPHEN:Dd,PERCENT:Rd,PIPE:Id,PLUS:Ld,POUND:Pd,QUERY:jd,QUOTE:zd,SEMI:$d,SLASH:Bd,TILDE:Fd,UNDERSCORE:_d,EMOJI:Vd,SYM:Hd});const Kd=/[a-z]/,qd=/\p{L}/u,Jd=/\p{Emoji}/u,Ud=/\d/,Gd=/\s/,Yd="\n",Qd="️",Xd="‍";let Zd=null,th=null;function eh(t,e,n,r,o){let i;const s=e.length;for(let n=0;n<s-1;n++){const s=e[n];t.j[s]?i=t.j[s]:(i=new _c(r),i.jr=o.slice(),t.j[s]=i),t=i}return i=new _c(n),i.jr=o.slice(),t.j[e[s-1]]=i,i}function nh(t){const e=[],n=[];let r=0;for(;r<t.length;){let o=0;for(;"0123456789".indexOf(t[r+o])>=0;)o++;if(o>0){e.push(n.join(""));for(let e=parseInt(t.substring(r,r+o),10);e>0;e--)n.pop();r+=o}else n.push(t[r]),r++}return e}const rh={defaultProtocol:"http",events:null,format:ih,formatHref:ih,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function oh(t,e){void 0===e&&(e=null);let n=Ec({},rh);t&&(n=Ec(n,t instanceof oh?t.o:t));const r=n.ignoreTags,o=[];for(let t=0;t<r.length;t++)o.push(r[t].toUpperCase());this.o=n,e&&(this.defaultRender=e),this.ignoreTags=o}function ih(t){return t}function sh(t,e){this.t="token",this.v=t,this.tk=e}function ah(t,e){class n extends sh{constructor(e,n){super(e,n),this.t=t}}for(const t in e)n.prototype[t]=e[t];return n.t=t,n}oh.prototype={o:rh,ignoreTags:[],defaultRender:t=>t,check(t){return this.get("validate",t.toString(),t)},get(t,e,n){const r=null!=e;let o=this.o[t];return o&&("object"==typeof o?(o=n.t in o?o[n.t]:rh[t],"function"==typeof o&&r&&(o=o(e,n))):"function"==typeof o&&r&&(o=o(e,n.t,n)),o)},getObj(t,e,n){let r=this.o[t];return"function"==typeof r&&null!=e&&(r=r(e,n.t,n)),r},render(t){const e=t.render(this);return(this.get("render",null,t)||this.defaultRender)(e,t.t,t)}},sh.prototype={isLink:!1,toString(){return this.v},toHref(t){return this.toString()},toFormattedString(t){const e=this.toString(),n=t.get("truncate",e,this),r=t.get("format",e,this);return n&&r.length>n?r.substring(0,n)+"…":r},toFormattedHref(t){return t.get("formatHref",this.toHref(t.get("defaultProtocol")),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(t){return void 0===t&&(t=rh.defaultProtocol),{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(t),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(t){return{type:this.t,value:this.toFormattedString(t),isLink:this.isLink,href:this.toFormattedHref(t),start:this.startIndex(),end:this.endIndex()}},validate(t){return t.get("validate",this.toString(),this)},render(t){const e=this,n=this.toHref(t.get("defaultProtocol")),r=t.get("formatHref",n,this),o=t.get("tagName",n,e),i=this.toFormattedString(t),s={},a=t.get("className",n,e),l=t.get("target",n,e),c=t.get("rel",n,e),d=t.getObj("attributes",n,e),h=t.getObj("events",n,e);return s.href=r,a&&(s.class=a),l&&(s.target=l),c&&(s.rel=c),d&&Ec(s,d),{tagName:o,attributes:s,content:i,eventListeners:h}}};const lh=ah("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),ch=ah("text"),dh=ah("nl"),hh=ah("url",{isLink:!0,toHref(t){return void 0===t&&(t=rh.defaultProtocol),this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){const t=this.tk;return t.length>=2&&t[0].t!==Uc&&t[1].t===Cd}}),uh=t=>new _c(t);function ph(t,e,n){const r=n[0].s,o=n[n.length-1].e;return new t(e.slice(r,o),n)}const fh=typeof console<"u"&&console&&console.warn||(()=>{}),mh={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function gh(t,e){if(void 0===e&&(e=!1),mh.initialized&&fh(`linkifyjs: already initialized - will not register custom scheme "${t}" until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(t))throw new Error('linkifyjs: incorrect scheme format.\n1. Must only contain digits, lowercase ASCII letters or "-"\n2. Cannot start or end with "-"\n3. "-" cannot repeat');mh.customSchemes.push([t,e])}function yh(){mh.scanner=function(t){void 0===t&&(t=[]);const e={};_c.groups=e;const n=new _c;null==Zd&&(Zd=nh(Mc)),null==th&&(th=nh(Tc)),Kc(n,"'",vd),Kc(n,"{",nd),Kc(n,"}",rd),Kc(n,"[",od),Kc(n,"]",id),Kc(n,"(",sd),Kc(n,")",ad),Kc(n,"<",ld),Kc(n,">",cd),Kc(n,"(",dd),Kc(n,")",hd),Kc(n,"「",ud),Kc(n,"」",pd),Kc(n,"『",fd),Kc(n,"』",md),Kc(n,"<",gd),Kc(n,">",yd),Kc(n,"&",bd),Kc(n,"*",wd),Kc(n,"@",kd),Kc(n,"`",Sd),Kc(n,"^",Od),Kc(n,":",Cd),Kc(n,",",Md),Kc(n,"$",Td),Kc(n,".",Ed),Kc(n,"=",Nd),Kc(n,"!",Ad),Kc(n,"-",Dd),Kc(n,"%",Rd),Kc(n,"|",Id),Kc(n,"+",Ld),Kc(n,"#",Pd),Kc(n,"?",jd),Kc(n,'"',zd),Kc(n,"/",Bd),Kc(n,";",$d),Kc(n,"~",Fd),Kc(n,"_",_d),Kc(n,"\\",xd);const r=Hc(n,Ud,Zc,{[Nc]:!0});Hc(r,Ud,r);const o=Hc(n,Kd,qc,{[Ac]:!0});Hc(o,Kd,o);const i=Hc(n,qd,Jc,{[Dc]:!0});Hc(i,Kd),Hc(i,qd,i);const s=Hc(n,Gd,td,{[$c]:!0});Kc(n,Yd,ed,{[$c]:!0}),Kc(s,Yd),Hc(s,Gd,s);const a=Hc(n,Jd,Vd,{[Pc]:!0});Hc(a,Jd,a),Kc(a,Qd,a);const l=Kc(a,Xd);Hc(l,Jd,a);const c=[[Kd,o]],d=[[Kd,null],[qd,i]];for(let t=0;t<Zd.length;t++)eh(n,Zd[t],Gc,qc,c);for(let t=0;t<th.length;t++)eh(n,th[t],Yc,Jc,d);Fc(Gc,{tld:!0,ascii:!0},e),Fc(Yc,{utld:!0,alpha:!0},e),eh(n,"file",Qc,qc,c),eh(n,"mailto",Qc,qc,c),eh(n,"http",Xc,qc,c),eh(n,"https",Xc,qc,c),eh(n,"ftp",Xc,qc,c),eh(n,"ftps",Xc,qc,c),Fc(Qc,{scheme:!0,ascii:!0},e),Fc(Xc,{slashscheme:!0,ascii:!0},e),t=t.sort(((t,e)=>t[0]>e[0]?1:-1));for(let e=0;e<t.length;e++){const r=t[e][0],o=t[e][1]?{[jc]:!0}:{[zc]:!0};r.indexOf("-")>=0?o[Lc]=!0:Kd.test(r)?Ud.test(r)?o[Rc]=!0:o[Ac]=!0:o[Nc]=!0,Wc(n,r,r,o)}return Wc(n,"localhost",Uc,{ascii:!0}),n.jd=new _c(Hd),{start:n,tokens:Ec({groups:e},Wd)}}(mh.customSchemes);for(let t=0;t<mh.tokenQueue.length;t++)mh.tokenQueue[t][1]({scanner:mh.scanner});mh.parser=function(t){let{groups:e}=t;const n=e.domain.concat([bd,wd,kd,xd,Sd,Od,Td,Nd,Dd,Zc,Rd,Id,Ld,Pd,Bd,Hd,Fd,_d]),r=[vd,Cd,Md,Ed,Ad,jd,zd,$d,ld,cd,nd,rd,id,od,sd,ad,dd,hd,ud,pd,fd,md,gd,yd],o=[bd,vd,wd,xd,Sd,Od,Td,Nd,Dd,nd,rd,Rd,Id,Ld,Pd,jd,Bd,Hd,Fd,_d],i=uh(),s=Kc(i,Fd);Vc(s,o,s),Vc(s,e.domain,s);const a=uh(),l=uh(),c=uh();Vc(i,e.domain,a),Vc(i,e.scheme,l),Vc(i,e.slashscheme,c),Vc(a,o,s),Vc(a,e.domain,a);const d=Kc(a,kd);Kc(s,kd,d),Kc(l,kd,d),Kc(c,kd,d);const h=Kc(s,Ed);Vc(h,o,s),Vc(h,e.domain,s);const u=uh();Vc(d,e.domain,u),Vc(u,e.domain,u);const p=Kc(u,Ed);Vc(p,e.domain,u);const f=uh(lh);Vc(p,e.tld,f),Vc(p,e.utld,f),Kc(d,Uc,f);const m=Kc(u,Dd);Vc(m,e.domain,u),Vc(f,e.domain,u),Kc(f,Ed,p),Kc(f,Dd,m);const g=Kc(f,Cd);Vc(g,e.numeric,lh);const y=Kc(a,Dd),b=Kc(a,Ed);Vc(y,e.domain,a),Vc(b,o,s),Vc(b,e.domain,a);const v=uh(hh);Vc(b,e.tld,v),Vc(b,e.utld,v),Vc(v,e.domain,a),Vc(v,o,s),Kc(v,Ed,b),Kc(v,Dd,y),Kc(v,kd,d);const w=Kc(v,Cd),k=uh(hh);Vc(w,e.numeric,k);const x=uh(hh),S=uh();Vc(x,n,x),Vc(x,r,S),Vc(S,n,x),Vc(S,r,S),Kc(v,Bd,x),Kc(k,Bd,x);const O=Kc(l,Cd),C=Kc(c,Cd),M=Kc(C,Bd),T=Kc(M,Bd);Vc(l,e.domain,a),Kc(l,Ed,b),Kc(l,Dd,y),Vc(c,e.domain,a),Kc(c,Ed,b),Kc(c,Dd,y),Vc(O,e.domain,x),Kc(O,Bd,x),Vc(T,e.domain,x),Vc(T,n,x),Kc(T,Bd,x);const E=[[nd,rd],[od,id],[sd,ad],[ld,cd],[dd,hd],[ud,pd],[fd,md],[gd,yd]];for(let t=0;t<E.length;t++){const[e,o]=E[t],i=Kc(x,e);Kc(S,e,i),Kc(i,o,x);const s=uh(hh);Vc(i,n,s);const a=uh();Vc(i,r),Vc(s,n,s),Vc(s,r,a),Vc(a,n,s),Vc(a,r,a),Kc(s,o,x),Kc(a,o,x)}return Kc(i,Uc,v),Kc(i,ed,dh),{start:i,tokens:Wd}}(mh.scanner.tokens);for(let t=0;t<mh.pluginQueue.length;t++)mh.pluginQueue[t][1]({scanner:mh.scanner,parser:mh.parser});mh.initialized=!0}function bh(t){return mh.initialized||yh(),function(t,e,n){let r=n.length,o=0,i=[],s=[];for(;o<r;){let a=t,l=null,c=null,d=0,h=null,u=-1;for(;o<r&&!(l=a.go(n[o].t));)s.push(n[o++]);for(;o<r&&(c=l||a.go(n[o].t));)l=null,a=c,a.accepts()?(u=0,h=a):u>=0&&u++,o++,d++;if(u<0)o-=d,o<r&&(s.push(n[o]),o++);else{s.length>0&&(i.push(ph(ch,e,s)),s=[]),o-=u,d-=u;const t=h.t,r=n.slice(o-d,o);i.push(ph(t,e,r))}}return s.length>0&&i.push(ph(ch,e,s)),i}(mh.parser.start,t,function(t,e){const n=function(t){const e=[],n=t.length;let r=0;for(;r<n;){let o,i=t.charCodeAt(r),s=i<55296||i>56319||r+1===n||(o=t.charCodeAt(r+1))<56320||o>57343?t[r]:t.slice(r,r+2);e.push(s),r+=s.length}return e}(e.replace(/[A-Z]/g,(t=>t.toLowerCase()))),r=n.length,o=[];let i=0,s=0;for(;s<r;){let a=t,l=null,c=0,d=null,h=-1,u=-1;for(;s<r&&(l=a.go(n[s]));)a=l,a.accepts()?(h=0,u=0,d=a):h>=0&&(h+=n[s].length,u++),c+=n[s].length,i+=n[s].length,s++;i-=h,s-=u,c-=h,o.push({t:d.t,v:e.slice(i-c,i),s:i-c,e:i})}return o}(mh.scanner.start,t))}function vh(t,e,n){if(void 0===e&&(e=null),void 0===n&&(n=null),e&&"object"==typeof e){if(n)throw Error(`linkifyjs: Invalid link type ${e}; must be a string`);n=e,e=null}const r=new oh(n),o=bh(t),i=[];for(let t=0;t<o.length;t++){const n=o[t];n.isLink&&(!e||n.t===e)&&r.check(n)&&i.push(n.toFormattedObject(r))}return i}function wh(t){return new qe({key:new Ge("autolink"),appendTransaction:(e,n,r)=>{const o=e.some((t=>t.docChanged))&&!n.doc.eq(r.doc),i=e.some((t=>t.getMeta("preventAutolink")));if(!o||i)return;const{tr:s}=r,a=function(t,e){const n=new Ce(t);return e.forEach((t=>{t.steps.forEach((t=>{n.step(t)}))})),n}(n.doc,[...e]);return function(t){const{mapping:e,steps:n}=t,r=[];return e.maps.forEach(((t,o)=>{const i=[];if(t.ranges.length)t.forEach(((t,e)=>{i.push({from:t,to:e})}));else{const{from:t,to:e}=n[o];if(void 0===t||void 0===e)return;i.push({from:t,to:e})}i.forEach((({from:t,to:n})=>{const i=e.slice(o).map(t,-1),s=e.slice(o).map(n),a=e.invert().map(i,-1),l=e.invert().map(s);r.push({oldRange:{from:a,to:l},newRange:{from:i,to:s}})}))})),Ps(r)}(a).forEach((({newRange:e})=>{const n=function(t,e,n){const r=[];return t.nodesBetween(e.from,e.to,((t,e)=>{n(t)&&r.push({node:t,pos:e})})),r}(r.doc,e,(t=>t.isTextblock));let o,i;if(n.length>1?(o=n[0],i=r.doc.textBetween(o.pos,o.pos+o.node.nodeSize,void 0," ")):n.length&&r.doc.textBetween(e.from,e.to," "," ").endsWith(" ")&&(o=n[0],i=r.doc.textBetween(o.pos,e.to,void 0," ")),o&&i){const e=i.split(" ").filter((t=>""!==t));if(e.length<=0)return!1;const n=e[e.length-1],a=o.pos+i.lastIndexOf(n);if(!n)return!1;const l=bh(n).map((e=>e.toObject(t.defaultProtocol)));if(!function(t){return 1===t.length?t[0].isLink:!(3!==t.length||!t[1].isLink)&&["()","[]"].includes(t[0].value+t[2].value)}(l))return!1;l.filter((t=>t.isLink)).map((t=>({...t,from:a+t.start+1,to:a+t.end+1}))).filter((t=>!r.schema.marks.code||!r.doc.rangeHasMark(t.from,t.to,r.schema.marks.code))).filter((e=>t.validate(e.value))).forEach((e=>{js(e.from,e.to,r.doc).some((e=>e.mark.type===t.type))||s.addMark(e.from,e.to,t.type.create({href:e.href}))}))}})),s.steps.length?s:void 0}})}const kh=/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g;function xh(t,e){const n=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return e&&e.forEach((t=>{const e="string"==typeof t?t:t.scheme;e&&n.push(e)})),!t||t.replace(kh,"").match(new RegExp(`^(?:(?:${n.join("|")}):|[^a-z]|[a-z+.-]+(?:[^a-z+.-:]|$))`,"i"))}const Sh=ss.create({name:"link",priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.protocols.forEach((t=>{"string"!=typeof t?gh(t.scheme,t.optionalSlashes):gh(t)}))},onDestroy(){_c.groups={},mh.scanner=null,mh.parser=null,mh.tokenQueue=[],mh.pluginQueue=[],mh.customSchemes=[],mh.initialized=!1},inclusive(){return this.options.autolink},addOptions:()=>({openOnClick:!0,linkOnPaste:!0,autolink:!0,protocols:[],defaultProtocol:"http",HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},validate:t=>!!t}),addAttributes(){return{href:{default:null,parseHTML:t=>t.getAttribute("href")},target:{default:this.options.HTMLAttributes.target},rel:{default:this.options.HTMLAttributes.rel},class:{default:this.options.HTMLAttributes.class}}},parseHTML(){return[{tag:"a[href]",getAttrs:t=>{const e=t.getAttribute("href");return!(!e||!xh(e,this.options.protocols))&&null}}]},renderHTML({HTMLAttributes:t}){return xh(t.href,this.options.protocols)?["a",Hi(this.options.HTMLAttributes,t),0]:["a",Hi(this.options.HTMLAttributes,{...t,href:""}),0]},addCommands(){return{setLink:t=>({chain:e})=>e().setMark(this.name,t).setMeta("preventAutolink",!0).run(),toggleLink:t=>({chain:e})=>e().toggleMark(this.name,t,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run(),unsetLink:()=>({chain:t})=>t().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addPasteRules(){return[ra({find:t=>{const e=[];if(t){const{validate:n}=this.options,r=vh(t).filter((t=>t.isLink&&n(t.value)));r.length&&r.forEach((t=>e.push({text:t.value,data:{href:t.href},index:t.start})))}return e},type:this.type,getAttributes:t=>{var e;return{href:null===(e=t.data)||void 0===e?void 0:e.href}}})]},addProseMirrorPlugins(){const t=[];return this.options.autolink&&t.push(wh({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:this.options.validate})),!0===this.options.openOnClick&&t.push(function(t){return new qe({key:new Ge("handleClickLink"),props:{handleClick:(e,n,r)=>{var o,i;if(0!==r.button||!e.editable)return!1;let s=r.target;const a=[];for(;"DIV"!==s.nodeName;)a.push(s),s=s.parentNode;if(!a.find((t=>"A"===t.nodeName)))return!1;const l=Ls(e.state,t.type.name),c=r.target,d=null!==(o=null==c?void 0:c.href)&&void 0!==o?o:l.href,h=null!==(i=null==c?void 0:c.target)&&void 0!==i?i:l.target;return!(!c||!d||(window.open(d,h),0))}}})}({type:this.type})),this.options.linkOnPaste&&t.push(function(t){return new qe({key:new Ge("handlePasteLink"),props:{handlePaste:(e,n,r)=>{const{state:o}=e,{selection:i}=o,{empty:s}=i;if(s)return!1;let a="";r.content.forEach((t=>{a+=t.textContent}));const l=vh(a,{defaultProtocol:t.defaultProtocol}).find((t=>t.isLink&&t.value===a));return!(!a||!l||(t.editor.commands.setMark(t.type,{href:l.href}),0))}}})}({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type})),t}}),Oh=na.create({name:"listItem",addOptions:()=>({HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}),content:"paragraph block*",defining:!0,parseHTML:()=>[{tag:"li"}],renderHTML({HTMLAttributes:t}){return["li",Hi(this.options.HTMLAttributes,t),0]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),Ch=na.create({name:"listItem",addOptions:()=>({HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}),content:"paragraph block*",defining:!0,parseHTML:()=>[{tag:"li"}],renderHTML({HTMLAttributes:t}){return["li",Hi(this.options.HTMLAttributes,t),0]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),Mh=ss.create({name:"textStyle",priority:101,addOptions:()=>({HTMLAttributes:{}}),parseHTML:()=>[{tag:"span",getAttrs:t=>!!t.hasAttribute("style")&&{}}],renderHTML({HTMLAttributes:t}){return["span",Hi(this.options.HTMLAttributes,t),0]},addCommands(){return{removeEmptyTextStyle:()=>({state:t,commands:e})=>{const n=Rs(t,this.type);return!!Object.entries(n).some((([,t])=>!!t))||e.unsetMark(this.name)}}}}),Th=/^(\d+)\.\s$/,Eh=na.create({name:"orderedList",addOptions:()=>({itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}),group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes:()=>({start:{default:1,parseHTML:t=>t.hasAttribute("start")?parseInt(t.getAttribute("start")||"",10):1},type:{default:void 0,parseHTML:t=>t.getAttribute("type")}}),parseHTML:()=>[{tag:"ol"}],renderHTML({HTMLAttributes:t}){const{start:e,...n}=t;return 1===e?["ol",Hi(this.options.HTMLAttributes,n),0]:["ol",Hi(this.options.HTMLAttributes,t),0]},addCommands(){return{toggleOrderedList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(Ch.name,this.editor.getAttributes(Mh.name)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=ea({find:Th,type:this.type,getAttributes:t=>({start:+t[1]}),joinPredicate:(t,e)=>e.childCount+e.attrs.start===+t[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(t=ea({find:Th,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:t=>({start:+t[1],...this.editor.getAttributes(Mh.name)}),joinPredicate:(t,e)=>e.childCount+e.attrs.start===+t[1],editor:this.editor})),[t]}}),Nh=na.create({name:"doc",topNode:!0,content:"block+"}),Ah=na.create({name:"paragraph",priority:1e3,addOptions:()=>({HTMLAttributes:{}}),group:"block",content:"inline*",parseHTML:()=>[{tag:"p"}],renderHTML({HTMLAttributes:t}){return["p",Hi(this.options.HTMLAttributes,t),0]},addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),Dh=na.create({name:"text",group:"inline"}),Rh=ss.create({name:"textStyle",priority:101,addOptions:()=>({HTMLAttributes:{}}),parseHTML:()=>[{tag:"span",getAttrs:t=>!!t.hasAttribute("style")&&{}}],renderHTML({HTMLAttributes:t}){return["span",Hi(this.options.HTMLAttributes,t),0]},addCommands(){return{removeEmptyTextStyle:()=>({state:t,commands:e})=>{const n=Rs(t,this.type);return!!Object.entries(n).some((([,t])=>!!t))||e.unsetMark(this.name)}}}});var Ih=hs.create({name:"fontSize",addOptions:function(){return{types:["textStyle"]}},addGlobalAttributes:function(){return[{types:this.options.types,attributes:{fontSize:{default:null,parseHTML:function(t){return t.style.fontSize.replace(/['"]+/g,"")},renderHTML:function(t){return t.fontSize?{style:"font-size: "+t.fontSize}:{}}}}}]},addCommands:function(){return{setFontSize:function(t){return function(e){return(0,e.chain)().setMark("textStyle",{fontSize:t}).run()}},unsetFontSize:function(){return function(t){return(0,t.chain)().setMark("textStyle",{fontSize:null}).removeEmptyTextStyle().run()}}}}});const Lh=[Nh,Ah,Dh,Rh],Ph=[wc.configure({levels:[1,2]}),Oh,vc,Eh,Sh,mc,Cc,Ih],jh=({open:t,setOpen:e,editor:n})=>{const[o,s]=r("");i((()=>{if(t){const{from:t,to:e}=n.state.selection;let r=null;n.state.doc.nodesBetween(t-1,e,(t=>{if(t.marks){const e=t.marks.find((t=>"link"===t.type.name));e&&(r=e.attrs.href)}})),s(r||"");const o=document.querySelector('[data-test="link-input-field"]');null==o||o.focus()}}),[t,n]);const{Norsk:a}=cc(),l=a?"Legg til lenke":"Add link",c=a?"Gå tilbake":"Go back";return M.jsx(g,{open:t,dataTest:"link-modal-rte",onClose:()=>e(!1),className:"z-[99]",dialogTitle:M.jsx("div",{className:"text-gray-700",children:l}),children:M.jsxs("main",{className:"flex flex-col items-start p-0 gap-6 m-4",children:[M.jsx("div",{children:M.jsx(y,{autoFocus:!0,dataTest:"link-input-field",size:"small",value:o,onChange:t=>s(t.target.value)})}),M.jsxs("div",{className:"flex gap-2 p-0 w-full justify-end",children:[M.jsx(u,{dataTest:"delete-customer-confirm-button",size:"medium",variant:"contained",onClick:()=>{n.chain().focus().setLink({href:o}).run(),e(!1),s("")},children:l}),M.jsx(u,{dataTest:"delete-customer-reject-button",size:"medium",variant:"outlined",onClick:()=>{e(!1),s("")},children:c})]})]})})},zh=hs.create({name:"placeholder",addOptions:()=>({emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}),addProseMirrorPlugins(){return[new qe({key:new Ge("placeholder"),props:{decorations:({doc:t,selection:e})=>{const n=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:r}=e,o=[];if(!n)return null;const i=this.editor.isEmpty;return t.descendants(((t,e)=>{const n=r>=e&&r<=e+t.nodeSize,s=!t.isLeaf&&Fs(t);if((n||!this.options.showOnlyCurrent)&&s){const r=[this.options.emptyNodeClass];i&&r.push(this.options.emptyEditorClass);const s=Ro.node(e,e+t.nodeSize,{class:r.join(" "),"data-placeholder":"function"==typeof this.options.placeholder?this.options.placeholder({editor:this.editor,node:t,pos:e,hasAnchor:n}):this.options.placeholder});o.push(s)}return this.options.includeChildren})),Po.create(t,o)}}})]}}),$h=({dataTest:t,id:e,inputRef:n,className:o,disabled:s,readOnly:a,error:l,placeholder:c,helperText:h,required:p,hideToolbar:f,noDefaultStyles:m,...g})=>{const y=Ma({...g,extensions:[zh.configure({placeholder:c}),...Lh,...Ph,...g.extensions||[]],shouldRerenderOnTransaction:g.shouldRerenderOnTransaction||!1,immediatelyRender:g.immediatelyRender||!0,editable:g.editable||!s&&!a}),[w,k]=r(g.toolbarDefaultVisible),[x,S]=r(!1);d(n,(()=>y));const[O,C]=r(!1);return i((()=>{const t=()=>C(!0),e=()=>C(!1);return null==y||y.on("focus",t),null==y||y.on("blur",e),()=>{null==y||y.off("focus",t),null==y||y.off("blur",e)}}),[y]),y?M.jsxs(M.Fragment,{children:[M.jsxs(b,{className:o,children:[g.title&&M.jsx("p",{className:"font-semibold text-base text-gray-700 mb-2",children:g.title}),M.jsxs("div",{className:E("flex flex-col h-full"),children:[M.jsx(fa,{"data-test":t,id:e,className:E("flex justify-between",!m&&"core-ui-rte",!m&&!s&&!a&&"core-ui-rte-edit-mode",a&&"core-ui-rte-readonly-mode",l&&(w?"core-ui-rte-tools-error":"core-ui-rte-error"),(f||!w)&&"core-ui-rte-hide-toolbar",l&&"error-state"),editor:y,onClick:()=>y.chain().focus().run(),style:{"--max-scrollable-height":g.maxScrollableHeight?`${g.maxScrollableHeight}${"number"==typeof g.maxScrollableHeight?"px":""}`:"none"},children:!f&&!s&&!a&&!w&&M.jsx(u,{className:"mt-1 mr-1 ml-[1px]",dataTest:"richeditor-show-toolbar-button",size:"small",variant:"textGray",onClick:()=>k(!0),children:M.jsx(lc,{icon:"material-symbols:format-color-text"})})}),!f&&!s&&!a&&w&&M.jsx(dc,{editor:y,onClose:()=>k(!1),error:l,focused:O,openLinkDialog:()=>S(!0)})]}),(l||p)&&!a&&M.jsx(v,{error:l,"data-test":`error-${t}`,children:h})]}),M.jsx(jh,{open:x,setOpen:S,editor:y})]}):null};export{$h as RichInput};
56
+ */"production"===process.env.NODE_ENV?ba.exports=function(){if(ya)return va;ya=1;var e=t,n=ha,r="function"==typeof Object.is?Object.is:function(t,e){return t===e&&(0!==t||1/t==1/e)||t!=t&&e!=e},o=n.useSyncExternalStore,i=e.useRef,s=e.useEffect,a=e.useMemo,l=e.useDebugValue;return va.useSyncExternalStoreWithSelector=function(t,e,n,c,d){var h=i(null);if(null===h.current){var u={hasValue:!1,value:null};h.current=u}else u=h.current;h=a((function(){function t(t){if(!s){if(s=!0,o=t,t=c(t),void 0!==d&&u.hasValue){var e=u.value;if(d(e,t))return i=e}return i=t}if(e=i,r(o,t))return e;var n=c(t);return void 0!==d&&d(e,n)?e:(o=t,i=n)}var o,i,s=!1,a=void 0===n?null:n;return[function(){return t(e())},null===a?void 0:function(){return t(a())}]}),[e,n,c,d]);var p=o(t,h[0],h[1]);return s((function(){u.hasValue=!0,u.value=p}),[p]),l(p),p},va}():ba.exports=(wa||(wa=1,"production"!==process.env.NODE_ENV&&function(){typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&"function"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error);var e=t,n=ha,r="function"==typeof Object.is?Object.is:function(t,e){return t===e&&(0!==t||1/t==1/e)||t!=t&&e!=e},o=n.useSyncExternalStore,i=e.useRef,s=e.useEffect,a=e.useMemo,l=e.useDebugValue;ka.useSyncExternalStoreWithSelector=function(t,e,n,c,d){var h,u=i(null);null===u.current?(h={hasValue:!1,value:null},u.current=h):h=u.current;var p=a((function(){var t,o,i=!1,s=function(e){if(!i){i=!0,t=e;var n=c(e);if(void 0!==d&&h.hasValue){var s=h.value;if(d(s,n))return o=s,s}return o=n,n}var a=o;if(r(t,e))return a;var l=c(e);return void 0!==d&&d(a,l)?a:(t=e,o=l,l)},a=void 0===n?null:n;return[function(){return s(e())},null===a?void 0:function(){return s(a())}]}),[e,n,c,d]),f=p[0],m=p[1],g=o(t,f,m);return s((function(){h.hasValue=!0,h.value=g}),[g]),l(g),g},typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&"function"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error)}()),ka);var xa=ba.exports;class Sa{constructor(t){this.transactionNumber=0,this.lastTransactionNumber=0,this.subscribers=new Set,this.editor=t,this.lastSnapshot={editor:t,transactionNumber:0},this.getSnapshot=this.getSnapshot.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.watch=this.watch.bind(this),this.subscribe=this.subscribe.bind(this)}getSnapshot(){return this.transactionNumber===this.lastTransactionNumber||(this.lastTransactionNumber=this.transactionNumber,this.lastSnapshot={editor:this.editor,transactionNumber:this.transactionNumber}),this.lastSnapshot}getServerSnapshot(){return{editor:null,transactionNumber:0}}subscribe(t){return this.subscribers.add(t),()=>{this.subscribers.delete(t)}}watch(t){if(this.editor=t,this.editor){const t=()=>{this.transactionNumber+=1,this.subscribers.forEach((t=>t()))},e=this.editor;return e.on("transaction",t),()=>{e.off("transaction",t)}}}}const Oa="production"!==process.env.NODE_ENV,Ca=typeof window>"u",Ma=Ca||!!(typeof window<"u"&&window.next);class Ta{constructor(t){this.editor=null,this.subscriptions=new Set,this.isComponentMounted=!1,this.previousDeps=null,this.instanceId="",this.options=t,this.subscriptions=new Set,this.setEditor(this.getInitialEditor()),this.scheduleDestroy(),this.getEditor=this.getEditor.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.subscribe=this.subscribe.bind(this),this.refreshEditorInstance=this.refreshEditorInstance.bind(this),this.scheduleDestroy=this.scheduleDestroy.bind(this),this.onRender=this.onRender.bind(this),this.createEditor=this.createEditor.bind(this)}setEditor(t){this.editor=t,this.instanceId=Math.random().toString(36).slice(2,9),this.subscriptions.forEach((t=>t()))}getInitialEditor(){if(void 0===this.options.current.immediatelyRender)return Ca||Ma?(Oa&&console.warn("Tiptap Error: SSR has been detected, please set `immediatelyRender` explicitly to `false` to avoid hydration mismatches."),null):this.createEditor();if(this.options.current.immediatelyRender&&Ca&&Oa)throw new Error("Tiptap Error: SSR has been detected, and `immediatelyRender` has been set to `true` this is an unsupported configuration that may result in errors, explicitly set `immediatelyRender` to `false` to avoid hydration mismatches.");return this.options.current.immediatelyRender?this.createEditor():null}createEditor(){const t={...this.options.current,onBeforeCreate:(...t)=>{var e,n;return null===(n=(e=this.options.current).onBeforeCreate)||void 0===n?void 0:n.call(e,...t)},onBlur:(...t)=>{var e,n;return null===(n=(e=this.options.current).onBlur)||void 0===n?void 0:n.call(e,...t)},onCreate:(...t)=>{var e,n;return null===(n=(e=this.options.current).onCreate)||void 0===n?void 0:n.call(e,...t)},onDestroy:(...t)=>{var e,n;return null===(n=(e=this.options.current).onDestroy)||void 0===n?void 0:n.call(e,...t)},onFocus:(...t)=>{var e,n;return null===(n=(e=this.options.current).onFocus)||void 0===n?void 0:n.call(e,...t)},onSelectionUpdate:(...t)=>{var e,n;return null===(n=(e=this.options.current).onSelectionUpdate)||void 0===n?void 0:n.call(e,...t)},onTransaction:(...t)=>{var e,n;return null===(n=(e=this.options.current).onTransaction)||void 0===n?void 0:n.call(e,...t)},onUpdate:(...t)=>{var e,n;return null===(n=(e=this.options.current).onUpdate)||void 0===n?void 0:n.call(e,...t)},onContentError:(...t)=>{var e,n;return null===(n=(e=this.options.current).onContentError)||void 0===n?void 0:n.call(e,...t)}};return new ea(t)}getEditor(){return this.editor}getServerSnapshot(){return null}subscribe(t){return this.subscriptions.add(t),()=>{this.subscriptions.delete(t)}}onRender(t){return()=>(this.isComponentMounted=!0,clearTimeout(this.scheduledDestructionTimeout),this.editor&&!this.editor.isDestroyed&&0===t.length?this.editor.setOptions(this.options.current):this.refreshEditorInstance(t),()=>{this.isComponentMounted=!1,this.scheduleDestroy()})}refreshEditorInstance(t){if(this.editor&&!this.editor.isDestroyed){if(null===this.previousDeps)return void(this.previousDeps=t);if(this.previousDeps.length===t.length&&this.previousDeps.every(((e,n)=>e===t[n])))return}this.editor&&!this.editor.isDestroyed&&this.editor.destroy(),this.setEditor(this.createEditor()),this.previousDeps=t}scheduleDestroy(){const t=this.instanceId,e=this.editor;this.scheduledDestructionTimeout=setTimeout((()=>{this.isComponentMounted&&this.instanceId===t?e&&e.setOptions(this.options.current):e&&!e.isDestroyed&&(e.destroy(),this.instanceId===t&&this.setEditor(null))}),1)}}function Ea(t={},e=[]){const s=n(t);s.current=t;const[a]=r((()=>new Ta(s))),l=ha.useSyncExternalStore(a.subscribe,a.getEditor,a.getServerSnapshot);return o(l),i(a.onRender(e)),function(t){const[e]=r((()=>new Sa(t.editor))),n=xa.useSyncExternalStoreWithSelector(e.subscribe,e.getSnapshot,e.getServerSnapshot,t.selector,t.equalityFn);i((()=>e.watch(t.editor)),[t.editor,e]),o(n)}({editor:l,selector:({transactionNumber:e})=>!1===t.shouldRerenderOnTransaction?null:t.immediatelyRender&&0===e?0:e+1}),l}s({editor:null}).Consumer;const Na=s({onDragStart:void 0});t.forwardRef(((e,n)=>{const{onDragStart:r}=a(Na),o=e.as||"div";return t.createElement(o,{...e,ref:n,"data-node-view-wrapper":"",onDragStart:r,style:{whiteSpace:"normal",...e.style}})}));const Aa=Object.freeze({left:0,top:0,width:16,height:16}),Da=Object.freeze({rotate:0,vFlip:!1,hFlip:!1}),Ra=Object.freeze({...Aa,...Da}),Ia=Object.freeze({...Ra,body:"",hidden:!1});function La(t,e){const n=function(t,e){const n={};!t.hFlip!=!e.hFlip&&(n.hFlip=!0),!t.vFlip!=!e.vFlip&&(n.vFlip=!0);const r=((t.rotate||0)+(e.rotate||0))%4;return r&&(n.rotate=r),n}(t,e);for(const r in Ia)r in Da?r in t&&!(r in n)&&(n[r]=Da[r]):r in e?n[r]=e[r]:r in t&&(n[r]=t[r]);return n}function Pa(t,e,n){const r=t.icons,o=t.aliases||Object.create(null);let i={};function s(t){i=La(r[t]||o[t],i)}return s(e),n.forEach(s),La(t,i)}function ja(t,e){const n=[];if("object"!=typeof t||"object"!=typeof t.icons)return n;t.not_found instanceof Array&&t.not_found.forEach((t=>{e(t,null),n.push(t)}));const r=function(t,e){const n=t.icons,r=t.aliases||Object.create(null),o=Object.create(null);return(e||Object.keys(n).concat(Object.keys(r))).forEach((function t(e){if(n[e])return o[e]=[];if(!(e in o)){o[e]=null;const n=r[e]&&r[e].parent,i=n&&t(n);i&&(o[e]=[n].concat(i))}return o[e]})),o}(t);for(const o in r){const i=r[o];i&&(e(o,Pa(t,o,i)),n.push(o))}return n}const za=/^[a-z0-9]+(-[a-z0-9]+)*$/,$a=(t,e,n,r="")=>{const o=t.split(":");if("@"===t.slice(0,1)){if(o.length<2||o.length>3)return null;r=o.shift().slice(1)}if(o.length>3||!o.length)return null;if(o.length>1){const t=o.pop(),n=o.pop(),i={provider:o.length>0?o[0]:r,prefix:n,name:t};return e&&!Ba(i)?null:i}const i=o[0],s=i.split("-");if(s.length>1){const t={provider:r,prefix:s.shift(),name:s.join("-")};return e&&!Ba(t)?null:t}if(n&&""===r){const t={provider:r,prefix:"",name:i};return e&&!Ba(t,n)?null:t}return null},Ba=(t,e)=>!!t&&!(""!==t.provider&&!t.provider.match(za)||!(e&&""===t.prefix||t.prefix.match(za))||!t.name.match(za)),Fa={provider:"",aliases:{},not_found:{},...Aa};function _a(t,e){for(const n in e)if(n in t&&typeof t[n]!=typeof e[n])return!1;return!0}function Va(t){if("object"!=typeof t||null===t)return null;const e=t;if("string"!=typeof e.prefix||!t.icons||"object"!=typeof t.icons||!_a(t,Fa))return null;const n=e.icons;for(const t in n){const e=n[t];if(!t.match(za)||"string"!=typeof e.body||!_a(e,Ia))return null}const r=e.aliases||Object.create(null);for(const t in r){const e=r[t],o=e.parent;if(!t.match(za)||"string"!=typeof o||!n[o]&&!r[o]||!_a(e,Ia))return null}return e}const Ha=Object.create(null);function Wa(t,e){const n=Ha[t]||(Ha[t]=Object.create(null));return n[e]||(n[e]=function(t,e){return{provider:t,prefix:e,icons:Object.create(null),missing:new Set}}(t,e))}function Ka(t,e){return Va(e)?ja(e,((e,n)=>{n?t.icons[e]=n:t.missing.add(e)})):[]}let qa=!1;function Ja(t){return"boolean"==typeof t&&(qa=t),qa}function Ua(t){const e="string"==typeof t?$a(t,!0,qa):t;if(e){const t=Wa(e.provider,e.prefix),n=e.name;return t.icons[n]||(t.missing.has(n)?null:void 0)}}function Ga(t,e){if("object"!=typeof t)return!1;if("string"!=typeof e&&(e=t.provider||""),qa&&!e&&!t.prefix){let e=!1;return Va(t)&&(t.prefix="",ja(t,((t,n)=>{n&&function(t,e){const n=$a(t,!0,qa);return!!n&&function(t,e,n){try{if("string"==typeof n.body)return t.icons[e]={...n},!0}catch{}return!1}(Wa(n.provider,n.prefix),n.name,e)}(t,n)&&(e=!0)}))),e}const n=t.prefix;if(!Ba({provider:e,prefix:n,name:"a"}))return!1;return!!Ka(Wa(e,n),t)}const Ya=Object.freeze({width:null,height:null}),Qa=Object.freeze({...Ya,...Da}),Xa=/(-?[0-9.]*[0-9]+[0-9.]*)/g,Za=/^-?[0-9.]*[0-9]+[0-9.]*$/g;function tl(t,e,n){if(1===e)return t;if(n=n||100,"number"==typeof t)return Math.ceil(t*e*n)/n;if("string"!=typeof t)return t;const r=t.split(Xa);if(null===r||!r.length)return t;const o=[];let i=r.shift(),s=Za.test(i);for(;;){if(s){const t=parseFloat(i);isNaN(t)?o.push(i):o.push(Math.ceil(t*e*n)/n)}else o.push(i);if(i=r.shift(),void 0===i)return o.join("");s=!s}}const el=/\sid="(\S+)"/g,nl="IconifyId"+Date.now().toString(16)+(16777216*Math.random()|0).toString(16);let rl=0;function ol(t,e=nl){const n=[];let r;for(;r=el.exec(t);)n.push(r[1]);if(!n.length)return t;const o="suffix"+(16777216*Math.random()|Date.now()).toString(16);return n.forEach((n=>{const r="function"==typeof e?e(n):e+(rl++).toString(),i=n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");t=t.replace(new RegExp('([#;"])('+i+')([")]|\\.[a-z])',"g"),"$1"+r+o+"$3")})),t=t.replace(new RegExp(o,"g"),"")}const il=Object.create(null);function sl(t){return il[t]||il[""]}function al(t){let e;if("string"==typeof t.resources)e=[t.resources];else if(e=t.resources,!(e instanceof Array&&e.length))return null;return{resources:e,path:t.path||"/",maxURL:t.maxURL||500,rotate:t.rotate||750,timeout:t.timeout||5e3,random:!0===t.random,index:t.index||0,dataAfterTimeout:!1!==t.dataAfterTimeout}}const ll=Object.create(null),cl=["https://api.simplesvg.com","https://api.unisvg.com"],dl=[];for(;cl.length>0;)1===cl.length||Math.random()>.5?dl.push(cl.shift()):dl.push(cl.pop());function hl(t,e){const n=al(e);return null!==n&&(ll[t]=n,!0)}function ul(t){return ll[t]}ll[""]=al({resources:["https://api.iconify.design"].concat(dl)});let pl=(()=>{let t;try{if(t=fetch,"function"==typeof t)return t}catch{}})();const fl={prepare:(t,e,n)=>{const r=[],o=function(t,e){const n=ul(t);if(!n)return 0;let r;if(n.maxURL){let t=0;n.resources.forEach((e=>{t=Math.max(t,e.length)}));const o=e+".json?icons=";r=n.maxURL-t-n.path.length-o.length}else r=0;return r}(t,e),i="icons";let s={type:i,provider:t,prefix:e,icons:[]},a=0;return n.forEach(((n,l)=>{a+=n.length+1,a>=o&&l>0&&(r.push(s),s={type:i,provider:t,prefix:e,icons:[]},a=n.length),s.icons.push(n)})),r.push(s),r},send:(t,e,n)=>{if(!pl)return void n("abort",424);let r=function(t){if("string"==typeof t){const e=ul(t);if(e)return e.path}return"/"}(e.provider);switch(e.type){case"icons":{const t=e.prefix,n=e.icons.join(",");r+=t+".json?"+new URLSearchParams({icons:n}).toString();break}case"custom":{const t=e.uri;r+="/"===t.slice(0,1)?t.slice(1):t;break}default:return void n("abort",400)}let o=503;pl(t+r).then((t=>{const e=t.status;if(200===e)return o=501,t.json();setTimeout((()=>{n(function(t){return 404===t}(e)?"abort":"next",e)}))})).then((t=>{"object"==typeof t&&null!==t?setTimeout((()=>{n("success",t)})):setTimeout((()=>{404===t?n("abort",t):n("next",o)}))})).catch((()=>{n("next",o)}))}};function ml(t,e){t.forEach((t=>{const n=t.loaderCallbacks;n&&(t.loaderCallbacks=n.filter((t=>t.id!==e)))}))}let gl=0;var yl={resources:[],index:0,timeout:2e3,rotate:750,random:!1,dataAfterTimeout:!1};function bl(t,e,n,r){const o=t.resources.length,i=t.random?Math.floor(Math.random()*o):t.index;let s;if(t.random){let e=t.resources.slice(0);for(s=[];e.length>1;){const t=Math.floor(Math.random()*e.length);s.push(e[t]),e=e.slice(0,t).concat(e.slice(t+1))}s=s.concat(e)}else s=t.resources.slice(i).concat(t.resources.slice(0,i));const a=Date.now();let l,c="pending",d=0,h=null,u=[],p=[];function f(){h&&(clearTimeout(h),h=null)}function m(){"pending"===c&&(c="aborted"),f(),u.forEach((t=>{"pending"===t.status&&(t.status="aborted")})),u=[]}function g(t,e){e&&(p=[]),"function"==typeof t&&p.push(t)}function y(){c="failed",p.forEach((t=>{t(void 0,l)}))}function b(){u.forEach((t=>{"pending"===t.status&&(t.status="aborted")})),u=[]}function v(){if("pending"!==c)return;f();const r=s.shift();if(void 0===r)return u.length?void(h=setTimeout((()=>{f(),"pending"===c&&(b(),y())}),t.timeout)):void y();const o={status:"pending",resource:r,callback:(e,n)=>{!function(e,n,r){const o="success"!==n;switch(u=u.filter((t=>t!==e)),c){case"pending":break;case"failed":if(o||!t.dataAfterTimeout)return;break;default:return}if("abort"===n)return l=r,void y();if(o)return l=r,void(u.length||(s.length?v():y()));if(f(),b(),!t.random){const n=t.resources.indexOf(e.resource);-1!==n&&n!==t.index&&(t.index=n)}c="completed",p.forEach((t=>{t(r)}))}(o,e,n)}};u.push(o),d++,h=setTimeout(v,t.rotate),n(r,e,o.callback)}return"function"==typeof r&&p.push(r),setTimeout(v),function(){return{startTime:a,payload:e,status:c,queriesSent:d,queriesPending:u.length,subscribe:g,abort:m}}}function vl(t){const e={...yl,...t};let n=[];function r(){n=n.filter((t=>"pending"===t().status))}return{query:function(t,o,i){const s=bl(e,t,o,((t,e)=>{r(),i&&i(t,e)}));return n.push(s),s},find:function(t){return n.find((e=>t(e)))||null},setIndex:t=>{e.index=t},getIndex:()=>e.index,cleanup:r}}function wl(){}const kl=Object.create(null);function xl(t,e,n){let r,o;if("string"==typeof t){const e=sl(t);if(!e)return n(void 0,424),wl;o=e.send;const i=function(t){if(!kl[t]){const e=ul(t);if(!e)return;const n={config:e,redundancy:vl(e)};kl[t]=n}return kl[t]}(t);i&&(r=i.redundancy)}else{const e=al(t);if(e){r=vl(e);const n=sl(t.resources?t.resources[0]:"");n&&(o=n.send)}}return r&&o?r.query(e,o,n)().abort:(n(void 0,424),wl)}const Sl="iconify2",Ol="iconify",Cl=Ol+"-count",Ml=Ol+"-version",Tl=36e5,El=168,Nl=50;function Al(t,e){try{return t.getItem(e)}catch{}}function Dl(t,e,n){try{return t.setItem(e,n),!0}catch{}}function Rl(t,e){try{t.removeItem(e)}catch{}}function Il(t,e){return Dl(t,Cl,e.toString())}function Ll(t){return parseInt(Al(t,Cl))||0}const Pl={local:!0,session:!0},jl={local:new Set,session:new Set};let zl=!1;let $l=typeof window>"u"?{}:window;function Bl(t){const e=t+"Storage";try{if($l&&$l[e]&&"number"==typeof $l[e].length)return $l[e]}catch{}Pl[t]=!1}function Fl(t,e){const n=Bl(t);if(!n)return;const r=Al(n,Ml);if(r!==Sl){if(r){const t=Ll(n);for(let e=0;e<t;e++)Rl(n,Ol+e.toString())}return Dl(n,Ml,Sl),void Il(n,0)}const o=Math.floor(Date.now()/Tl)-El,i=t=>{const r=Ol+t.toString(),i=Al(n,r);if("string"==typeof i){try{const n=JSON.parse(i);if("object"==typeof n&&"number"==typeof n.cached&&n.cached>o&&"string"==typeof n.provider&&"object"==typeof n.data&&"string"==typeof n.data.prefix&&e(n,t))return!0}catch{}Rl(n,r)}};let s=Ll(n);for(let e=s-1;e>=0;e--)i(e)||(e===s-1?(s--,Il(n,s)):jl[t].add(e))}function _l(){if(!zl){zl=!0;for(const t in Pl)Fl(t,(t=>{const e=t.data,n=Wa(t.provider,e.prefix);if(!Ka(n,e).length)return!1;const r=e.lastModified||-1;return n.lastModifiedCached=n.lastModifiedCached?Math.min(n.lastModifiedCached,r):r,!0}))}}function Vl(t,e){function n(n){let r;if(!Pl[n]||!(r=Bl(n)))return;const o=jl[n];let i;if(o.size)o.delete(i=Array.from(o).shift());else if(i=Ll(r),i>=Nl||!Il(r,i+1))return;const s={cached:Math.floor(Date.now()/Tl),provider:t.provider,data:e};return Dl(r,Ol+i.toString(),JSON.stringify(s))}zl||_l(),e.lastModified&&!function(t,e){const n=t.lastModifiedCached;if(n&&n>=e)return n===e;if(t.lastModifiedCached=e,n)for(const n in Pl)Fl(n,(n=>{const r=n.data;return n.provider!==t.provider||r.prefix!==t.prefix||r.lastModified===e}));return!0}(t,e.lastModified)||Object.keys(e.icons).length&&(e.not_found&&delete(e=Object.assign({},e)).not_found,n("local")||n("session"))}function Hl(){}function Wl(t){t.iconsLoaderFlag||(t.iconsLoaderFlag=!0,setTimeout((()=>{t.iconsLoaderFlag=!1,function(t){t.pendingCallbacksFlag||(t.pendingCallbacksFlag=!0,setTimeout((()=>{t.pendingCallbacksFlag=!1;const e=t.loaderCallbacks?t.loaderCallbacks.slice(0):[];if(!e.length)return;let n=!1;const r=t.provider,o=t.prefix;e.forEach((e=>{const i=e.icons,s=i.pending.length;i.pending=i.pending.filter((e=>{if(e.prefix!==o)return!0;const s=e.name;if(t.icons[s])i.loaded.push({provider:r,prefix:o,name:s});else{if(!t.missing.has(s))return n=!0,!0;i.missing.push({provider:r,prefix:o,name:s})}return!1})),i.pending.length!==s&&(n||ml([t],e.id),e.callback(i.loaded.slice(0),i.missing.slice(0),i.pending.slice(0),e.abort))}))})))}(t)})))}const Kl=(t,e)=>{const n=function(t,e=!0,n=!1){const r=[];return t.forEach((t=>{const o="string"==typeof t?$a(t,e,n):t;o&&r.push(o)})),r}(t,!0,Ja()),r=function(t){const e={loaded:[],missing:[],pending:[]},n=Object.create(null);t.sort(((t,e)=>t.provider!==e.provider?t.provider.localeCompare(e.provider):t.prefix!==e.prefix?t.prefix.localeCompare(e.prefix):t.name.localeCompare(e.name)));let r={provider:"",prefix:"",name:""};return t.forEach((t=>{if(r.name===t.name&&r.prefix===t.prefix&&r.provider===t.provider)return;r=t;const o=t.provider,i=t.prefix,s=t.name,a=n[o]||(n[o]=Object.create(null)),l=a[i]||(a[i]=Wa(o,i));let c;c=s in l.icons?e.loaded:""===i||l.missing.has(s)?e.missing:e.pending;const d={provider:o,prefix:i,name:s};c.push(d)})),e}(n);if(!r.pending.length){let t=!0;return e&&setTimeout((()=>{t&&e(r.loaded,r.missing,r.pending,Hl)})),()=>{t=!1}}const o=Object.create(null),i=[];let s,a;return r.pending.forEach((t=>{const{provider:e,prefix:n}=t;if(n===a&&e===s)return;s=e,a=n,i.push(Wa(e,n));const r=o[e]||(o[e]=Object.create(null));r[n]||(r[n]=[])})),r.pending.forEach((t=>{const{provider:e,prefix:n,name:r}=t,i=Wa(e,n),s=i.pendingIcons||(i.pendingIcons=new Set);s.has(r)||(s.add(r),o[e][n].push(r))})),i.forEach((t=>{const{provider:e,prefix:n}=t;o[e][n].length&&function(t,e){t.iconsToLoad?t.iconsToLoad=t.iconsToLoad.concat(e).sort():t.iconsToLoad=e,t.iconsQueueFlag||(t.iconsQueueFlag=!0,setTimeout((()=>{t.iconsQueueFlag=!1;const{provider:e,prefix:n}=t,r=t.iconsToLoad;let o;delete t.iconsToLoad,r&&(o=sl(e))&&o.prepare(e,n,r).forEach((n=>{xl(e,n,(e=>{if("object"!=typeof e)n.icons.forEach((e=>{t.missing.add(e)}));else try{const n=Ka(t,e);if(!n.length)return;const r=t.pendingIcons;r&&n.forEach((t=>{r.delete(t)})),Vl(t,e)}catch(t){console.error(t)}Wl(t)}))}))})))}(t,o[e][n])})),e?function(t,e,n){const r=gl++,o=ml.bind(null,n,r);if(!e.pending.length)return o;const i={id:r,icons:e,callback:t,abort:o};return n.forEach((t=>{(t.loaderCallbacks||(t.loaderCallbacks=[])).push(i)})),o}(e,r,i):Hl};const ql=/[\s,]+/;function Jl(t,e){e.split(ql).forEach((e=>{switch(e.trim()){case"horizontal":t.hFlip=!0;break;case"vertical":t.vFlip=!0}}))}function Ul(t,e=0){const n=t.replace(/^-?[0-9.]*/,"");function r(t){for(;t<0;)t+=4;return t%4}if(""===n){const e=parseInt(t);return isNaN(e)?0:r(e)}if(n!==t){let e=0;switch(n){case"%":e=25;break;case"deg":e=90}if(e){let o=parseFloat(t.slice(0,t.length-n.length));return isNaN(o)?0:(o/=e,o%1==0?r(o):0)}}return e}function Gl(t){return'url("'+function(t){return"data:image/svg+xml,"+function(t){return t.replace(/"/g,"'").replace(/%/g,"%25").replace(/#/g,"%23").replace(/</g,"%3C").replace(/>/g,"%3E").replace(/\s+/g," ")}(t)}(t)+'")'}let Yl;function Ql(t){return void 0===Yl&&function(){try{Yl=window.trustedTypes.createPolicy("iconify",{createHTML:t=>t})}catch{Yl=null}}(),Yl?Yl.createHTML(t):t}const Xl={...Qa,inline:!1},Zl={xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":!0,role:"img"},tc={display:"inline-block"},ec={backgroundColor:"currentColor"},nc={backgroundColor:"transparent"},rc={Image:"var(--svg)",Repeat:"no-repeat",Size:"100% 100%"},oc={WebkitMask:ec,mask:ec,background:nc};for(const t in oc){const e=oc[t];for(const n in rc)e[t+n]=rc[n]}const ic={...Xl,inline:!0};function sc(t){return t+(t.match(/^[-0-9.]+$/)?"px":"")}const ac=(t,e,n)=>{const r=e.inline?ic:Xl,o=function(t,e){const n={...t};for(const t in e){const r=e[t],o=typeof r;t in Ya?(null===r||r&&("string"===o||"number"===o))&&(n[t]=r):o===typeof n[t]&&(n[t]="rotate"===t?r%4:r)}return n}(r,e),i=e.mode||"svg",s={},a=e.style||{},c={..."svg"===i?Zl:{}};if(n){const t=$a(n,!1,!0);if(t){const e=["iconify"],n=["provider","prefix"];for(const r of n)t[r]&&e.push("iconify--"+t[r]);c.className=e.join(" ")}}for(let t in e){const n=e[t];if(void 0!==n)switch(t){case"icon":case"style":case"children":case"onLoad":case"mode":case"ssr":break;case"_ref":c.ref=n;break;case"className":c[t]=(c[t]?c[t]+" ":"")+n;break;case"inline":case"hFlip":case"vFlip":o[t]=!0===n||"true"===n||1===n;break;case"flip":"string"==typeof n&&Jl(o,n);break;case"color":s.color=n;break;case"rotate":"string"==typeof n?o[t]=Ul(n):"number"==typeof n&&(o[t]=n);break;case"ariaHidden":case"aria-hidden":!0!==n&&"true"!==n&&delete c["aria-hidden"];break;default:void 0===r[t]&&(c[t]=n)}}const d=function(t,e){const n={...Ra,...t},r={...Qa,...e},o={left:n.left,top:n.top,width:n.width,height:n.height};let i=n.body;[n,r].forEach((t=>{const e=[],n=t.hFlip,r=t.vFlip;let s,a=t.rotate;switch(n?r?a+=2:(e.push("translate("+(o.width+o.left).toString()+" "+(0-o.top).toString()+")"),e.push("scale(-1 1)"),o.top=o.left=0):r&&(e.push("translate("+(0-o.left).toString()+" "+(o.height+o.top).toString()+")"),e.push("scale(1 -1)"),o.top=o.left=0),a<0&&(a-=4*Math.floor(a/4)),a%=4,a){case 1:s=o.height/2+o.top,e.unshift("rotate(90 "+s.toString()+" "+s.toString()+")");break;case 2:e.unshift("rotate(180 "+(o.width/2+o.left).toString()+" "+(o.height/2+o.top).toString()+")");break;case 3:s=o.width/2+o.left,e.unshift("rotate(-90 "+s.toString()+" "+s.toString()+")")}a%2==1&&(o.left!==o.top&&(s=o.left,o.left=o.top,o.top=s),o.width!==o.height&&(s=o.width,o.width=o.height,o.height=s)),e.length&&(i=function(t,e,n){const r=function(t,e="defs"){let n="";const r=t.indexOf("<"+e);for(;r>=0;){const o=t.indexOf(">",r),i=t.indexOf("</"+e);if(-1===o||-1===i)break;const s=t.indexOf(">",i);if(-1===s)break;n+=t.slice(o+1,i).trim(),t=t.slice(0,r).trim()+t.slice(s+1)}return{defs:n,content:t}}(t);return function(t,e){return t?"<defs>"+t+"</defs>"+e:e}(r.defs,e+r.content+n)}(i,'<g transform="'+e.join(" ")+'">',"</g>"))}));const s=r.width,a=r.height,l=o.width,c=o.height;let d,h;null===s?(h=null===a?"1em":"auto"===a?c:a,d=tl(h,l/c)):(d="auto"===s?l:s,h=null===a?tl(d,c/l):"auto"===a?c:a);const u={},p=(t,e)=>{(t=>"unset"===t||"undefined"===t||"none"===t)(e)||(u[t]=e.toString())};p("width",d),p("height",h);const f=[o.left,o.top,l,c];return u.viewBox=f.join(" "),{attributes:u,viewBox:f,body:i}}(t,o),h=d.attributes;if(o.inline&&(s.verticalAlign="-0.125em"),"svg"===i){c.style={...s,...a},Object.assign(c,h);let t=0,n=e.id;return"string"==typeof n&&(n=n.replace(/-/g,"_")),c.dangerouslySetInnerHTML={__html:Ql(ol(d.body,n?()=>n+"ID"+t++:"iconifyReact"))},l("svg",c)}const{body:u,width:p,height:f}=t,m="mask"===i||"bg"!==i&&-1!==u.indexOf("currentColor"),g=function(t,e){let n=-1===t.indexOf("xlink:")?"":' xmlns:xlink="http://www.w3.org/1999/xlink"';for(const t in e)n+=" "+t+'="'+e[t]+'"';return'<svg xmlns="http://www.w3.org/2000/svg"'+n+">"+t+"</svg>"}(u,{...h,width:p+"",height:f+""});return c.style={...s,"--svg":Gl(g),width:sc(h.width),height:sc(h.height),...tc,...m?ec:nc,...a},l("span",c)};var lc;if(Ja(!0),lc=fl,il[""]=lc,typeof document<"u"&&typeof window<"u"){_l();const t=window;if(void 0!==t.IconifyPreload){const e=t.IconifyPreload,n="Invalid IconifyPreload syntax.";"object"==typeof e&&null!==e&&(e instanceof Array?e:[e]).forEach((t=>{try{("object"!=typeof t||null===t||t instanceof Array||"object"!=typeof t.icons||"string"!=typeof t.prefix||!Ga(t))&&console.error(n)}catch{console.error(n)}}))}if(void 0!==t.IconifyProviders){const e=t.IconifyProviders;if("object"==typeof e&&null!==e)for(let t in e){const n="IconifyProviders["+t+"] is invalid.";try{const r=e[t];if("object"!=typeof r||!r||void 0===r.resources)continue;hl(t,r)||console.error(n)}catch{console.error(n)}}}}function cc(t){const[e,n]=r(!!t.ssr),[o,s]=r({});const[a,c]=r(function(e){if(e){const e=t.icon;if("object"==typeof e)return{name:"",data:e};const n=Ua(e);if(n)return{name:e,data:n}}return{name:""}}(!!t.ssr));function d(){const t=o.callback;t&&(t(),s({}))}function h(t){if(JSON.stringify(a)!==JSON.stringify(t))return d(),c(t),!0}function u(){var e;const n=t.icon;if("object"==typeof n)return void h({name:"",data:n});const r=Ua(n);if(h({name:n,data:r}))if(void 0===r){const t=Kl([n],u);s({callback:t})}else r&&(null===(e=t.onLoad)||void 0===e||e.call(t,n))}i((()=>(n(!0),d)),[]),i((()=>{e&&u()}),[t.icon,e]);const{name:p,data:f}=a;return f?ac({...Ra,...f},t,p):t.children?t.children:l("span",{})}const dc=e(((t,e)=>cc({...t,_ref:e})));e(((t,e)=>cc({inline:!0,...t,_ref:e})));const hc=t=>E.jsx(f,{...t,sx:{"&.MuiMenuItem-root":{color:"var(--colors-delta-700)",fontSize:"14px",lineHeight:"20px"}},children:t.children}),uc={small:"10px",normal:"16px",large:"24px",huge:"32px"},pc=t=>{const{editor:e}=t,[n,o]=r("normal");return d((()=>{const{from:t,to:n}=e.state.selection;e.state.doc.nodesBetween(t-1,n,(t=>{if(t.marks){const e=t.marks.find((t=>"textStyle"===t.type.name)),n=null==e?void 0:e.attrs.fontSize,r=Object.keys(uc).find((t=>uc[t]===n))||"normal";o(r)}}))}),[e.state.selection,e.state.doc]),E.jsx(m,{...t,select:!0,size:"small",dataTest:"font-size-select",onChange:t=>{const n=t.target.value;e.chain().focus().setMark("textStyle",{fontSize:uc[n]}).run(),o(n)},value:n,SelectProps:{IconComponent:()=>null},InputProps:{endAdornment:E.jsx(dc,{icon:"tabler:caret-up-down-filled",className:"chevron-icon"})},sx:{".MuiSelect-select":{border:"none",padding:0,overflow:"hidden",display:"flex",alignItems:"center",color:"var(--colors-delta-700)",fontSize:"14px",lineHeight:"20px"},".MuiOutlinedInput-root":{height:"32px",width:"75px","& .MuiOutlinedInput-notchedOutline":{border:"none"}}},children:t.children})},fc=({editor:t,onClose:e,error:o,focused:i,openLinkDialog:s,locale:a})=>{const[l,u]=r(0),p=n(null),m=h((()=>"no"===a),[a]),[v,w]=r(!1),[k,S]=r([]);d((()=>{const e=new ResizeObserver((()=>{var e;if(p.current){const n=p.current.clientWidth;w(n<(m?416:420));const r=null==(e=[{width:m?296:300,buttons:3},{width:m?340:342,buttons:4},{width:m?374:378,buttons:5},{width:m?416:420,buttons:6},{width:m?416:420,buttons:7},{width:1/0,buttons:8}].find((t=>n<t.width)))?void 0:e.buttons;u(void 0!==r?r:8);const o=[];Number(r)<8&&o.push(E.jsx(f,{className:"flex items-center justify-center",onClick:s,selected:t.isActive("link"),children:E.jsx(g,{})},"link")),Number(r)<7&&o.push(E.jsx(f,{className:"flex items-center justify-center",onClick:()=>t.chain().focus().toggleItalic().run(),selected:t.isActive("italic"),children:E.jsx(dc,{icon:"material-symbols:format-italic",height:20})},"italic")),Number(r)<6&&o.push(E.jsx(f,{className:"flex items-center justify-center",onClick:()=>t.chain().focus().toggleBold().run(),selected:t.isActive("bold"),children:E.jsx(dc,{icon:"ooui:bold-b"})},"bold")),Number(r)<5&&o.push(E.jsx(f,{className:"flex items-center justify-center",onClick:()=>t.chain().focus().toggleOrderedList().run(),selected:t.isActive("orderedList"),children:E.jsx(dc,{icon:"mdi:format-list-numbered",fontSize:20})},"ordered")),Number(r)<4&&o.push(E.jsx(f,{className:"flex items-center justify-center",onClick:()=>t.chain().focus().toggleBulletList().run(),selected:t.isActive("bulletList"),children:E.jsx(dc,{icon:"mdi:format-list-bulleted",fontSize:20})},"bullet")),S(o)}}));return p.current&&e.observe(p.current),()=>e.disconnect()}),[t,s,m]);const{anchorEl:O,open:C,handleClose:M,handleOpen:T}=(()=>{const[t,e]=r(null),n=!!t,o=c((t=>{e(t.currentTarget)}),[]);return{open:n,handleClose:c((()=>{e(null)}),[]),handleOpen:o,anchorEl:t}})();return E.jsx(E.Fragment,{children:E.jsxs("div",{className:A("toolbar",{"toolbar-error":o,"toolbar-focused":i}),ref:p,children:[E.jsxs("div",{className:"flex flex-row items-center gap-1",children:[l>=1&&E.jsx(y,{dataTest:"richeditor-h1-button",size:"small",variant:t.isActive("heading",{level:1})?"text":"textGray",onClick:()=>{t.chain().focus().setMark("textStyle",{fontSize:void 0}).run(),t.chain().focus().toggleHeading({level:1}).run()},children:E.jsx(dc,{icon:"bi:type-h1"})}),l>=2&&E.jsx(y,{dataTest:"richeditor-h2-button",size:"small",variant:t.isActive("heading",{level:2})?"text":"textGray",onClick:()=>{t.chain().focus().setMark("textStyle",{fontSize:void 0}).run(),t.chain().focus().toggleHeading({level:2}).run()},children:E.jsx(dc,{icon:"bi:type-h2"})}),l>=3&&E.jsxs(pc,{editor:t,children:[E.jsx(hc,{value:"small",children:m?"Liten":"Small"}),E.jsx(hc,{value:"normal",children:"Normal"}),E.jsx(hc,{value:"large",children:m?"Stor":"Large"}),E.jsx(hc,{value:"huge",children:m?"Enorm":"Huge"})]}),l>=4&&E.jsx(y,{dataTest:"richeditor-bullet-list-button",size:"small",variant:t.isActive("bulletList")?"text":"textGray",onClick:()=>t.chain().focus().toggleBulletList().run(),children:E.jsx(dc,{icon:"mdi:format-list-bulleted",fontSize:20})}),l>=5&&E.jsx(y,{dataTest:"richeditor-ordered-list-button",size:"small",variant:t.isActive("orderedList")?"text":"textGray",onClick:()=>t.chain().focus().toggleOrderedList().run(),children:E.jsx(dc,{icon:"mdi:format-list-numbered",fontSize:20})}),l>=6&&E.jsx(y,{dataTest:"richeditor-bold-button",size:"small",variant:t.isActive("bold")?"text":"textGray",onClick:()=>t.chain().focus().toggleBold().run(),children:E.jsx(dc,{icon:"ooui:bold-b"})}),l>=7&&E.jsx(y,{dataTest:"richeditor-italic-button",size:"small",variant:t.isActive("italic")?"text":"textGray",onClick:()=>t.chain().focus().toggleItalic().run(),children:E.jsx(dc,{icon:"material-symbols:format-italic",height:20})}),l>=8&&E.jsx(y,{dataTest:"richeditor-link-button",size:"small",variant:t.isActive("link")?"text":"textGray",onClick:s,children:E.jsx(g,{})}),v&&E.jsxs(E.Fragment,{children:[E.jsx(y,{size:"small",dataTest:"richeditor-more-menu-button",variant:"text",onClick:t=>{t.stopPropagation(),t.preventDefault(),T(t)},onMouseDown:t=>{t.stopPropagation(),t.preventDefault()},onMouseUp:t=>{t.stopPropagation(),t.preventDefault()},children:E.jsx(b,{className:"text-delta-800",width:20,height:20})}),E.jsx(x,{open:C,anchorEl:O,onClose:M,onClick:M,anchorOrigin:{horizontal:"center",vertical:"bottom"},transformOrigin:{vertical:"top",horizontal:"right"},children:k})]})]}),E.jsx(y,{dataTest:"richeditor-close-toolbar-button",size:"small",variant:"text",onClick:e,children:m?"Lukk":"Close"})]})})},mc=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,gc=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,yc=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,bc=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,vc=ls.create({name:"bold",addOptions:()=>({HTMLAttributes:{}}),parseHTML:()=>[{tag:"strong"},{tag:"b",getAttrs:t=>"normal"!==t.style.fontWeight&&null},{style:"font-weight",getAttrs:t=>/^(bold(er)?|[5-9]\d{2,})$/.test(t)&&null}],renderHTML({HTMLAttributes:t}){return["strong",Ki(this.options.HTMLAttributes,t),0]},addCommands(){return{setBold:()=>({commands:t})=>t.setMark(this.name),toggleBold:()=>({commands:t})=>t.toggleMark(this.name),unsetBold:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[na({find:mc,type:this.type}),na({find:yc,type:this.type})]},addPasteRules(){return[ia({find:gc,type:this.type}),ia({find:bc,type:this.type})]}}),wc=oa.create({name:"listItem",addOptions:()=>({HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}),content:"paragraph block*",defining:!0,parseHTML:()=>[{tag:"li"}],renderHTML({HTMLAttributes:t}){return["li",Ki(this.options.HTMLAttributes,t),0]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),kc=ls.create({name:"textStyle",priority:101,addOptions:()=>({HTMLAttributes:{}}),parseHTML:()=>[{tag:"span",getAttrs:t=>!!t.hasAttribute("style")&&{}}],renderHTML({HTMLAttributes:t}){return["span",Ki(this.options.HTMLAttributes,t),0]},addCommands(){return{removeEmptyTextStyle:()=>({state:t,commands:e})=>{const n=Ls(t,this.type);return!!Object.entries(n).some((([,t])=>!!t))||e.unsetMark(this.name)}}}}),xc=/^\s*([-+*])\s$/,Sc=oa.create({name:"bulletList",addOptions:()=>({itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}),group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML:()=>[{tag:"ul"}],renderHTML({HTMLAttributes:t}){return["ul",Ki(this.options.HTMLAttributes,t),0]},addCommands(){return{toggleBulletList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(wc.name,this.editor.getAttributes(kc.name)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let t=ra({find:xc,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(t=ra({find:xc,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(kc.name),editor:this.editor})),[t]}}),Oc=oa.create({name:"heading",addOptions:()=>({levels:[1,2,3,4,5,6],HTMLAttributes:{}}),content:"inline*",group:"block",defining:!0,addAttributes:()=>({level:{default:1,rendered:!1}}),parseHTML(){return this.options.levels.map((t=>({tag:`h${t}`,attrs:{level:t}})))},renderHTML({node:t,HTMLAttributes:e}){return[`h${this.options.levels.includes(t.attrs.level)?t.attrs.level:this.options.levels[0]}`,Ki(this.options.HTMLAttributes,e),0]},addCommands(){return{setHeading:t=>({commands:e})=>!!this.options.levels.includes(t.level)&&e.setNode(this.name,t),toggleHeading:t=>({commands:e})=>!!this.options.levels.includes(t.level)&&e.toggleNode(this.name,"paragraph",t)}},addKeyboardShortcuts(){return this.options.levels.reduce(((t,e)=>({...t,[`Mod-Alt-${e}`]:()=>this.editor.commands.toggleHeading({level:e})})),{})},addInputRules(){return this.options.levels.map((t=>function(t){return new es({find:t.find,handler:({state:e,range:n,match:r})=>{const o=e.doc.resolve(n.from),i=Ui(t.getAttributes,void 0,r)||{};if(!o.node(-1).canReplaceWith(o.index(-1),o.indexAfter(-1),t.type))return null;e.tr.delete(n.from,n.to).setBlockType(n.from,n.from,t.type,i)}})}({find:new RegExp(`^(#{1,${t}})\\s$`),type:this.type,getAttributes:{level:t}})))}}),Cc=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))$/,Mc=/(?:^|\s)(\*(?!\s+\*)((?:[^*]+))\*(?!\s+\*))/g,Tc=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))$/,Ec=/(?:^|\s)(_(?!\s+_)((?:[^_]+))_(?!\s+_))/g,Nc=ls.create({name:"italic",addOptions:()=>({HTMLAttributes:{}}),parseHTML:()=>[{tag:"em"},{tag:"i",getAttrs:t=>"normal"!==t.style.fontStyle&&null},{style:"font-style=italic"}],renderHTML({HTMLAttributes:t}){return["em",Ki(this.options.HTMLAttributes,t),0]},addCommands(){return{setItalic:()=>({commands:t})=>t.setMark(this.name),toggleItalic:()=>({commands:t})=>t.toggleMark(this.name),unsetItalic:()=>({commands:t})=>t.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-i":()=>this.editor.commands.toggleItalic(),"Mod-I":()=>this.editor.commands.toggleItalic()}},addInputRules(){return[na({find:Cc,type:this.type}),na({find:Tc,type:this.type})]},addPasteRules(){return[ia({find:Mc,type:this.type}),ia({find:Ec,type:this.type})]}}),Ac="aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4vianca6w0s2x0a2z0ure5ba0by2idu3namex3narepublic11d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2ntley5rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0cast4mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dabur3d1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3nlop4pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2o0dyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0ardian6cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6logistics9properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3ncaster6d0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2psy3ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rckmsd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2tura4vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9dnavy5lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0america6xi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0stone5umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0a1b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp2w2ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2olterskluwer11odside6rk0s2ld3w2s1tc1f3xbox3erox4finity6ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2",Dc="ελ1υ2бг1ел3дети4ею2католик6ом3мкд2он1сква6онлайн5рг3рус2ф2сайт3рб3укр3қаз3հայ3ישראל5קום3ابوظبي5رامكو5لاردن4بحرين5جزائر5سعودية6عليان5مغرب5مارات5یران5بارت2زار4يتك3ھارت5تونس4سودان3رية5شبكة4عراق2ب2مان4فلسطين6قطر3كاثوليك6وم3مصر2ليسيا5وريتانيا7قع4همراه5پاکستان7ڀارت4कॉम3नेट3भारत0म्3ोत5संगठन5বাংলা5ভারত2ৰত4ਭਾਰਤ4ભારત4ଭାରତ4இந்தியா6லங்கை6சிங்கப்பூர்11భారత్5ಭಾರತ4ഭാരതം5ලංකා4คอม3ไทย3ລາວ3გე2みんな3アマゾン4クラウド4グーグル4コム2ストア3セール3ファッション6ポイント4世界2中信1国1國1文网3亚马逊3企业2佛山2信息2健康2八卦2公司1益2台湾1灣2商城1店1标2嘉里0大酒店5在线2大拿2天主教3娱乐2家電2广东2微博2慈善2我爱你3手机2招聘2政务1府2新加坡2闻2时尚2書籍2机构2淡马锡3游戏2澳門2点看2移动2组织机构4网址1店1站1络2联通2谷歌2购物2通販2集团2電訊盈科4飞利浦3食品2餐厅2香格里拉3港2닷넷1컴2삼성2한국2",Rc=(t,e)=>{for(const n in e)t[n]=e[n];return t},Ic="numeric",Lc="ascii",Pc="alpha",jc="asciinumeric",zc="alphanumeric",$c="domain",Bc="emoji",Fc="scheme",_c="slashscheme",Vc="whitespace";function Hc(t,e){return t in e||(e[t]=[]),e[t]}function Wc(t,e,n){e[Ic]&&(e[jc]=!0,e[zc]=!0),e[Lc]&&(e[jc]=!0,e[Pc]=!0),e[jc]&&(e[zc]=!0),e[Pc]&&(e[zc]=!0),e[zc]&&(e[$c]=!0),e[Bc]&&(e[$c]=!0);for(const r in e){const e=Hc(r,n);e.indexOf(t)<0&&e.push(t)}}function Kc(t){void 0===t&&(t=null),this.j={},this.jr=[],this.jd=null,this.t=t}Kc.groups={},Kc.prototype={accepts(){return!!this.t},go(t){const e=this,n=e.j[t];if(n)return n;for(let n=0;n<e.jr.length;n++){const r=e.jr[n][0],o=e.jr[n][1];if(o&&r.test(t))return o}return e.jd},has(t,e){return void 0===e&&(e=!1),e?t in this.j:!!this.go(t)},ta(t,e,n,r){for(let o=0;o<t.length;o++)this.tt(t[o],e,n,r)},tr(t,e,n,r){let o;return r=r||Kc.groups,e&&e.j?o=e:(o=new Kc(e),n&&r&&Wc(e,n,r)),this.jr.push([t,o]),o},ts(t,e,n,r){let o=this;const i=t.length;if(!i)return o;for(let e=0;e<i-1;e++)o=o.tt(t[e]);return o.tt(t[i-1],e,n,r)},tt(t,e,n,r){r=r||Kc.groups;const o=this;if(e&&e.j)return o.j[t]=e,e;const i=e;let s,a=o.go(t);if(a?(s=new Kc,Rc(s.j,a.j),s.jr.push.apply(s.jr,a.jr),s.jd=a.jd,s.t=a.t):s=new Kc,i){if(r)if(s.t&&"string"==typeof s.t){const t=Rc(function(t,e){const n={};for(const r in e)e[r].indexOf(t)>=0&&(n[r]=!0);return n}(s.t,r),n);Wc(i,t,r)}else n&&Wc(i,n,r);s.t=i}return o.j[t]=s,s}};const qc=(t,e,n,r,o)=>t.ta(e,n,r,o),Jc=(t,e,n,r,o)=>t.tr(e,n,r,o),Uc=(t,e,n,r,o)=>t.ts(e,n,r,o),Gc=(t,e,n,r,o)=>t.tt(e,n,r,o),Yc="WORD",Qc="UWORD",Xc="LOCALHOST",Zc="TLD",td="UTLD",ed="SCHEME",nd="SLASH_SCHEME",rd="NUM",od="WS",id="NL",sd="OPENBRACE",ad="CLOSEBRACE",ld="OPENBRACKET",cd="CLOSEBRACKET",dd="OPENPAREN",hd="CLOSEPAREN",ud="OPENANGLEBRACKET",pd="CLOSEANGLEBRACKET",fd="FULLWIDTHLEFTPAREN",md="FULLWIDTHRIGHTPAREN",gd="LEFTCORNERBRACKET",yd="RIGHTCORNERBRACKET",bd="LEFTWHITECORNERBRACKET",vd="RIGHTWHITECORNERBRACKET",wd="FULLWIDTHLESSTHAN",kd="FULLWIDTHGREATERTHAN",xd="AMPERSAND",Sd="APOSTROPHE",Od="ASTERISK",Cd="AT",Md="BACKSLASH",Td="BACKTICK",Ed="CARET",Nd="COLON",Ad="COMMA",Dd="DOLLAR",Rd="DOT",Id="EQUALS",Ld="EXCLAMATION",Pd="HYPHEN",jd="PERCENT",zd="PIPE",$d="PLUS",Bd="POUND",Fd="QUERY",_d="QUOTE",Vd="SEMI",Hd="SLASH",Wd="TILDE",Kd="UNDERSCORE",qd="EMOJI",Jd="SYM";var Ud=Object.freeze({__proto__:null,WORD:Yc,UWORD:Qc,LOCALHOST:Xc,TLD:Zc,UTLD:td,SCHEME:ed,SLASH_SCHEME:nd,NUM:rd,WS:od,NL:id,OPENBRACE:sd,CLOSEBRACE:ad,OPENBRACKET:ld,CLOSEBRACKET:cd,OPENPAREN:dd,CLOSEPAREN:hd,OPENANGLEBRACKET:ud,CLOSEANGLEBRACKET:pd,FULLWIDTHLEFTPAREN:fd,FULLWIDTHRIGHTPAREN:md,LEFTCORNERBRACKET:gd,RIGHTCORNERBRACKET:yd,LEFTWHITECORNERBRACKET:bd,RIGHTWHITECORNERBRACKET:vd,FULLWIDTHLESSTHAN:wd,FULLWIDTHGREATERTHAN:kd,AMPERSAND:xd,APOSTROPHE:Sd,ASTERISK:Od,AT:Cd,BACKSLASH:Md,BACKTICK:Td,CARET:Ed,COLON:Nd,COMMA:Ad,DOLLAR:Dd,DOT:Rd,EQUALS:Id,EXCLAMATION:Ld,HYPHEN:Pd,PERCENT:jd,PIPE:zd,PLUS:$d,POUND:Bd,QUERY:Fd,QUOTE:_d,SEMI:Vd,SLASH:Hd,TILDE:Wd,UNDERSCORE:Kd,EMOJI:qd,SYM:Jd});const Gd=/[a-z]/,Yd=/\p{L}/u,Qd=/\p{Emoji}/u,Xd=/\d/,Zd=/\s/,th="\n",eh="️",nh="‍";let rh=null,oh=null;function ih(t,e,n,r,o){let i;const s=e.length;for(let n=0;n<s-1;n++){const s=e[n];t.j[s]?i=t.j[s]:(i=new Kc(r),i.jr=o.slice(),t.j[s]=i),t=i}return i=new Kc(n),i.jr=o.slice(),t.j[e[s-1]]=i,i}function sh(t){const e=[],n=[];let r=0;for(;r<t.length;){let o=0;for(;"0123456789".indexOf(t[r+o])>=0;)o++;if(o>0){e.push(n.join(""));for(let e=parseInt(t.substring(r,r+o),10);e>0;e--)n.pop();r+=o}else n.push(t[r]),r++}return e}const ah={defaultProtocol:"http",events:null,format:ch,formatHref:ch,nl2br:!1,tagName:"a",target:null,rel:null,validate:!0,truncate:1/0,className:null,attributes:null,ignoreTags:[],render:null};function lh(t,e){void 0===e&&(e=null);let n=Rc({},ah);t&&(n=Rc(n,t instanceof lh?t.o:t));const r=n.ignoreTags,o=[];for(let t=0;t<r.length;t++)o.push(r[t].toUpperCase());this.o=n,e&&(this.defaultRender=e),this.ignoreTags=o}function ch(t){return t}function dh(t,e){this.t="token",this.v=t,this.tk=e}function hh(t,e){class n extends dh{constructor(e,n){super(e,n),this.t=t}}for(const t in e)n.prototype[t]=e[t];return n.t=t,n}lh.prototype={o:ah,ignoreTags:[],defaultRender:t=>t,check(t){return this.get("validate",t.toString(),t)},get(t,e,n){const r=null!=e;let o=this.o[t];return o&&("object"==typeof o?(o=n.t in o?o[n.t]:ah[t],"function"==typeof o&&r&&(o=o(e,n))):"function"==typeof o&&r&&(o=o(e,n.t,n)),o)},getObj(t,e,n){let r=this.o[t];return"function"==typeof r&&null!=e&&(r=r(e,n.t,n)),r},render(t){const e=t.render(this);return(this.get("render",null,t)||this.defaultRender)(e,t.t,t)}},dh.prototype={isLink:!1,toString(){return this.v},toHref(t){return this.toString()},toFormattedString(t){const e=this.toString(),n=t.get("truncate",e,this),r=t.get("format",e,this);return n&&r.length>n?r.substring(0,n)+"…":r},toFormattedHref(t){return t.get("formatHref",this.toHref(t.get("defaultProtocol")),this)},startIndex(){return this.tk[0].s},endIndex(){return this.tk[this.tk.length-1].e},toObject(t){return void 0===t&&(t=ah.defaultProtocol),{type:this.t,value:this.toString(),isLink:this.isLink,href:this.toHref(t),start:this.startIndex(),end:this.endIndex()}},toFormattedObject(t){return{type:this.t,value:this.toFormattedString(t),isLink:this.isLink,href:this.toFormattedHref(t),start:this.startIndex(),end:this.endIndex()}},validate(t){return t.get("validate",this.toString(),this)},render(t){const e=this,n=this.toHref(t.get("defaultProtocol")),r=t.get("formatHref",n,this),o=t.get("tagName",n,e),i=this.toFormattedString(t),s={},a=t.get("className",n,e),l=t.get("target",n,e),c=t.get("rel",n,e),d=t.getObj("attributes",n,e),h=t.getObj("events",n,e);return s.href=r,a&&(s.class=a),l&&(s.target=l),c&&(s.rel=c),d&&Rc(s,d),{tagName:o,attributes:s,content:i,eventListeners:h}}};const uh=hh("email",{isLink:!0,toHref(){return"mailto:"+this.toString()}}),ph=hh("text"),fh=hh("nl"),mh=hh("url",{isLink:!0,toHref(t){return void 0===t&&(t=ah.defaultProtocol),this.hasProtocol()?this.v:`${t}://${this.v}`},hasProtocol(){const t=this.tk;return t.length>=2&&t[0].t!==Xc&&t[1].t===Nd}}),gh=t=>new Kc(t);function yh(t,e,n){const r=n[0].s,o=n[n.length-1].e;return new t(e.slice(r,o),n)}const bh=typeof console<"u"&&console&&console.warn||(()=>{}),vh={scanner:null,parser:null,tokenQueue:[],pluginQueue:[],customSchemes:[],initialized:!1};function wh(t,e){if(void 0===e&&(e=!1),vh.initialized&&bh(`linkifyjs: already initialized - will not register custom scheme "${t}" until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.`),!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(t))throw new Error('linkifyjs: incorrect scheme format.\n1. Must only contain digits, lowercase ASCII letters or "-"\n2. Cannot start or end with "-"\n3. "-" cannot repeat');vh.customSchemes.push([t,e])}function kh(){vh.scanner=function(t){void 0===t&&(t=[]);const e={};Kc.groups=e;const n=new Kc;null==rh&&(rh=sh(Ac)),null==oh&&(oh=sh(Dc)),Gc(n,"'",Sd),Gc(n,"{",sd),Gc(n,"}",ad),Gc(n,"[",ld),Gc(n,"]",cd),Gc(n,"(",dd),Gc(n,")",hd),Gc(n,"<",ud),Gc(n,">",pd),Gc(n,"(",fd),Gc(n,")",md),Gc(n,"「",gd),Gc(n,"」",yd),Gc(n,"『",bd),Gc(n,"』",vd),Gc(n,"<",wd),Gc(n,">",kd),Gc(n,"&",xd),Gc(n,"*",Od),Gc(n,"@",Cd),Gc(n,"`",Td),Gc(n,"^",Ed),Gc(n,":",Nd),Gc(n,",",Ad),Gc(n,"$",Dd),Gc(n,".",Rd),Gc(n,"=",Id),Gc(n,"!",Ld),Gc(n,"-",Pd),Gc(n,"%",jd),Gc(n,"|",zd),Gc(n,"+",$d),Gc(n,"#",Bd),Gc(n,"?",Fd),Gc(n,'"',_d),Gc(n,"/",Hd),Gc(n,";",Vd),Gc(n,"~",Wd),Gc(n,"_",Kd),Gc(n,"\\",Md);const r=Jc(n,Xd,rd,{[Ic]:!0});Jc(r,Xd,r);const o=Jc(n,Gd,Yc,{[Lc]:!0});Jc(o,Gd,o);const i=Jc(n,Yd,Qc,{[Pc]:!0});Jc(i,Gd),Jc(i,Yd,i);const s=Jc(n,Zd,od,{[Vc]:!0});Gc(n,th,id,{[Vc]:!0}),Gc(s,th),Jc(s,Zd,s);const a=Jc(n,Qd,qd,{[Bc]:!0});Jc(a,Qd,a),Gc(a,eh,a);const l=Gc(a,nh);Jc(l,Qd,a);const c=[[Gd,o]],d=[[Gd,null],[Yd,i]];for(let t=0;t<rh.length;t++)ih(n,rh[t],Zc,Yc,c);for(let t=0;t<oh.length;t++)ih(n,oh[t],td,Qc,d);Wc(Zc,{tld:!0,ascii:!0},e),Wc(td,{utld:!0,alpha:!0},e),ih(n,"file",ed,Yc,c),ih(n,"mailto",ed,Yc,c),ih(n,"http",nd,Yc,c),ih(n,"https",nd,Yc,c),ih(n,"ftp",nd,Yc,c),ih(n,"ftps",nd,Yc,c),Wc(ed,{scheme:!0,ascii:!0},e),Wc(nd,{slashscheme:!0,ascii:!0},e),t=t.sort(((t,e)=>t[0]>e[0]?1:-1));for(let e=0;e<t.length;e++){const r=t[e][0],o=t[e][1]?{[Fc]:!0}:{[_c]:!0};r.indexOf("-")>=0?o[$c]=!0:Gd.test(r)?Xd.test(r)?o[jc]=!0:o[Lc]=!0:o[Ic]=!0,Uc(n,r,r,o)}return Uc(n,"localhost",Xc,{ascii:!0}),n.jd=new Kc(Jd),{start:n,tokens:Rc({groups:e},Ud)}}(vh.customSchemes);for(let t=0;t<vh.tokenQueue.length;t++)vh.tokenQueue[t][1]({scanner:vh.scanner});vh.parser=function(t){let{groups:e}=t;const n=e.domain.concat([xd,Od,Cd,Md,Td,Ed,Dd,Id,Pd,rd,jd,zd,$d,Bd,Hd,Jd,Wd,Kd]),r=[Sd,Nd,Ad,Rd,Ld,Fd,_d,Vd,ud,pd,sd,ad,cd,ld,dd,hd,fd,md,gd,yd,bd,vd,wd,kd],o=[xd,Sd,Od,Md,Td,Ed,Dd,Id,Pd,sd,ad,jd,zd,$d,Bd,Fd,Hd,Jd,Wd,Kd],i=gh(),s=Gc(i,Wd);qc(s,o,s),qc(s,e.domain,s);const a=gh(),l=gh(),c=gh();qc(i,e.domain,a),qc(i,e.scheme,l),qc(i,e.slashscheme,c),qc(a,o,s),qc(a,e.domain,a);const d=Gc(a,Cd);Gc(s,Cd,d),Gc(l,Cd,d),Gc(c,Cd,d);const h=Gc(s,Rd);qc(h,o,s),qc(h,e.domain,s);const u=gh();qc(d,e.domain,u),qc(u,e.domain,u);const p=Gc(u,Rd);qc(p,e.domain,u);const f=gh(uh);qc(p,e.tld,f),qc(p,e.utld,f),Gc(d,Xc,f);const m=Gc(u,Pd);qc(m,e.domain,u),qc(f,e.domain,u),Gc(f,Rd,p),Gc(f,Pd,m);const g=Gc(f,Nd);qc(g,e.numeric,uh);const y=Gc(a,Pd),b=Gc(a,Rd);qc(y,e.domain,a),qc(b,o,s),qc(b,e.domain,a);const v=gh(mh);qc(b,e.tld,v),qc(b,e.utld,v),qc(v,e.domain,a),qc(v,o,s),Gc(v,Rd,b),Gc(v,Pd,y),Gc(v,Cd,d);const w=Gc(v,Nd),k=gh(mh);qc(w,e.numeric,k);const x=gh(mh),S=gh();qc(x,n,x),qc(x,r,S),qc(S,n,x),qc(S,r,S),Gc(v,Hd,x),Gc(k,Hd,x);const O=Gc(l,Nd),C=Gc(c,Nd),M=Gc(C,Hd),T=Gc(M,Hd);qc(l,e.domain,a),Gc(l,Rd,b),Gc(l,Pd,y),qc(c,e.domain,a),Gc(c,Rd,b),Gc(c,Pd,y),qc(O,e.domain,x),Gc(O,Hd,x),qc(T,e.domain,x),qc(T,n,x),Gc(T,Hd,x);const E=[[sd,ad],[ld,cd],[dd,hd],[ud,pd],[fd,md],[gd,yd],[bd,vd],[wd,kd]];for(let t=0;t<E.length;t++){const[e,o]=E[t],i=Gc(x,e);Gc(S,e,i),Gc(i,o,x);const s=gh(mh);qc(i,n,s);const a=gh();qc(i,r),qc(s,n,s),qc(s,r,a),qc(a,n,s),qc(a,r,a),Gc(s,o,x),Gc(a,o,x)}return Gc(i,Xc,v),Gc(i,id,fh),{start:i,tokens:Ud}}(vh.scanner.tokens);for(let t=0;t<vh.pluginQueue.length;t++)vh.pluginQueue[t][1]({scanner:vh.scanner,parser:vh.parser});vh.initialized=!0}function xh(t){return vh.initialized||kh(),function(t,e,n){let r=n.length,o=0,i=[],s=[];for(;o<r;){let a=t,l=null,c=null,d=0,h=null,u=-1;for(;o<r&&!(l=a.go(n[o].t));)s.push(n[o++]);for(;o<r&&(c=l||a.go(n[o].t));)l=null,a=c,a.accepts()?(u=0,h=a):u>=0&&u++,o++,d++;if(u<0)o-=d,o<r&&(s.push(n[o]),o++);else{s.length>0&&(i.push(yh(ph,e,s)),s=[]),o-=u,d-=u;const t=h.t,r=n.slice(o-d,o);i.push(yh(t,e,r))}}return s.length>0&&i.push(yh(ph,e,s)),i}(vh.parser.start,t,function(t,e){const n=function(t){const e=[],n=t.length;let r=0;for(;r<n;){let o,i=t.charCodeAt(r),s=i<55296||i>56319||r+1===n||(o=t.charCodeAt(r+1))<56320||o>57343?t[r]:t.slice(r,r+2);e.push(s),r+=s.length}return e}(e.replace(/[A-Z]/g,(t=>t.toLowerCase()))),r=n.length,o=[];let i=0,s=0;for(;s<r;){let a=t,l=null,c=0,d=null,h=-1,u=-1;for(;s<r&&(l=a.go(n[s]));)a=l,a.accepts()?(h=0,u=0,d=a):h>=0&&(h+=n[s].length,u++),c+=n[s].length,i+=n[s].length,s++;i-=h,s-=u,c-=h,o.push({t:d.t,v:e.slice(i-c,i),s:i-c,e:i})}return o}(vh.scanner.start,t))}function Sh(t,e,n){if(void 0===e&&(e=null),void 0===n&&(n=null),e&&"object"==typeof e){if(n)throw Error(`linkifyjs: Invalid link type ${e}; must be a string`);n=e,e=null}const r=new lh(n),o=xh(t),i=[];for(let t=0;t<o.length;t++){const n=o[t];n.isLink&&(!e||n.t===e)&&r.check(n)&&i.push(n.toFormattedObject(r))}return i}function Oh(t){return new Ue({key:new Qe("autolink"),appendTransaction:(e,n,r)=>{const o=e.some((t=>t.docChanged))&&!n.doc.eq(r.doc),i=e.some((t=>t.getMeta("preventAutolink")));if(!o||i)return;const{tr:s}=r,a=function(t,e){const n=new Te(t);return e.forEach((t=>{t.steps.forEach((t=>{n.step(t)}))})),n}(n.doc,[...e]);return function(t){const{mapping:e,steps:n}=t,r=[];return e.maps.forEach(((t,o)=>{const i=[];if(t.ranges.length)t.forEach(((t,e)=>{i.push({from:t,to:e})}));else{const{from:t,to:e}=n[o];if(void 0===t||void 0===e)return;i.push({from:t,to:e})}i.forEach((({from:t,to:n})=>{const i=e.slice(o).map(t,-1),s=e.slice(o).map(n),a=e.invert().map(i,-1),l=e.invert().map(s);r.push({oldRange:{from:a,to:l},newRange:{from:i,to:s}})}))})),zs(r)}(a).forEach((({newRange:e})=>{const n=function(t,e,n){const r=[];return t.nodesBetween(e.from,e.to,((t,e)=>{n(t)&&r.push({node:t,pos:e})})),r}(r.doc,e,(t=>t.isTextblock));let o,i;if(n.length>1?(o=n[0],i=r.doc.textBetween(o.pos,o.pos+o.node.nodeSize,void 0," ")):n.length&&r.doc.textBetween(e.from,e.to," "," ").endsWith(" ")&&(o=n[0],i=r.doc.textBetween(o.pos,e.to,void 0," ")),o&&i){const e=i.split(" ").filter((t=>""!==t));if(e.length<=0)return!1;const n=e[e.length-1],a=o.pos+i.lastIndexOf(n);if(!n)return!1;const l=xh(n).map((e=>e.toObject(t.defaultProtocol)));if(!function(t){return 1===t.length?t[0].isLink:!(3!==t.length||!t[1].isLink)&&["()","[]"].includes(t[0].value+t[2].value)}(l))return!1;l.filter((t=>t.isLink)).map((t=>({...t,from:a+t.start+1,to:a+t.end+1}))).filter((t=>!r.schema.marks.code||!r.doc.rangeHasMark(t.from,t.to,r.schema.marks.code))).filter((e=>t.validate(e.value))).forEach((e=>{$s(e.from,e.to,r.doc).some((e=>e.mark.type===t.type))||s.addMark(e.from,e.to,t.type.create({href:e.href}))}))}})),s.steps.length?s:void 0}})}const Ch=/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g;function Mh(t,e){const n=["http","https","ftp","ftps","mailto","tel","callto","sms","cid","xmpp"];return e&&e.forEach((t=>{const e="string"==typeof t?t:t.scheme;e&&n.push(e)})),!t||t.replace(Ch,"").match(new RegExp(`^(?:(?:${n.join("|")}):|[^a-z]|[a-z+.-]+(?:[^a-z+.-:]|$))`,"i"))}const Th=ls.create({name:"link",priority:1e3,keepOnSplit:!1,exitable:!0,onCreate(){this.options.protocols.forEach((t=>{"string"!=typeof t?wh(t.scheme,t.optionalSlashes):wh(t)}))},onDestroy(){Kc.groups={},vh.scanner=null,vh.parser=null,vh.tokenQueue=[],vh.pluginQueue=[],vh.customSchemes=[],vh.initialized=!1},inclusive(){return this.options.autolink},addOptions:()=>({openOnClick:!0,linkOnPaste:!0,autolink:!0,protocols:[],defaultProtocol:"http",HTMLAttributes:{target:"_blank",rel:"noopener noreferrer nofollow",class:null},validate:t=>!!t}),addAttributes(){return{href:{default:null,parseHTML:t=>t.getAttribute("href")},target:{default:this.options.HTMLAttributes.target},rel:{default:this.options.HTMLAttributes.rel},class:{default:this.options.HTMLAttributes.class}}},parseHTML(){return[{tag:"a[href]",getAttrs:t=>{const e=t.getAttribute("href");return!(!e||!Mh(e,this.options.protocols))&&null}}]},renderHTML({HTMLAttributes:t}){return Mh(t.href,this.options.protocols)?["a",Ki(this.options.HTMLAttributes,t),0]:["a",Ki(this.options.HTMLAttributes,{...t,href:""}),0]},addCommands(){return{setLink:t=>({chain:e})=>e().setMark(this.name,t).setMeta("preventAutolink",!0).run(),toggleLink:t=>({chain:e})=>e().toggleMark(this.name,t,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run(),unsetLink:()=>({chain:t})=>t().unsetMark(this.name,{extendEmptyMarkRange:!0}).setMeta("preventAutolink",!0).run()}},addPasteRules(){return[ia({find:t=>{const e=[];if(t){const{validate:n}=this.options,r=Sh(t).filter((t=>t.isLink&&n(t.value)));r.length&&r.forEach((t=>e.push({text:t.value,data:{href:t.href},index:t.start})))}return e},type:this.type,getAttributes:t=>{var e;return{href:null===(e=t.data)||void 0===e?void 0:e.href}}})]},addProseMirrorPlugins(){const t=[];return this.options.autolink&&t.push(Oh({type:this.type,defaultProtocol:this.options.defaultProtocol,validate:this.options.validate})),!0===this.options.openOnClick&&t.push(function(t){return new Ue({key:new Qe("handleClickLink"),props:{handleClick:(e,n,r)=>{var o,i;if(0!==r.button||!e.editable)return!1;let s=r.target;const a=[];for(;"DIV"!==s.nodeName;)a.push(s),s=s.parentNode;if(!a.find((t=>"A"===t.nodeName)))return!1;const l=js(e.state,t.type.name),c=r.target,d=null!==(o=null==c?void 0:c.href)&&void 0!==o?o:l.href,h=null!==(i=null==c?void 0:c.target)&&void 0!==i?i:l.target;return!(!c||!d||(window.open(d,h),0))}}})}({type:this.type})),this.options.linkOnPaste&&t.push(function(t){return new Ue({key:new Qe("handlePasteLink"),props:{handlePaste:(e,n,r)=>{const{state:o}=e,{selection:i}=o,{empty:s}=i;if(s)return!1;let a="";r.content.forEach((t=>{a+=t.textContent}));const l=Sh(a,{defaultProtocol:t.defaultProtocol}).find((t=>t.isLink&&t.value===a));return!(!a||!l||(t.editor.commands.setMark(t.type,{href:l.href}),0))}}})}({editor:this.editor,defaultProtocol:this.options.defaultProtocol,type:this.type})),t}}),Eh=oa.create({name:"listItem",addOptions:()=>({HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}),content:"paragraph block*",defining:!0,parseHTML:()=>[{tag:"li"}],renderHTML({HTMLAttributes:t}){return["li",Ki(this.options.HTMLAttributes,t),0]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),Nh=oa.create({name:"listItem",addOptions:()=>({HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}),content:"paragraph block*",defining:!0,parseHTML:()=>[{tag:"li"}],renderHTML({HTMLAttributes:t}){return["li",Ki(this.options.HTMLAttributes,t),0]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),Ah=ls.create({name:"textStyle",priority:101,addOptions:()=>({HTMLAttributes:{}}),parseHTML:()=>[{tag:"span",getAttrs:t=>!!t.hasAttribute("style")&&{}}],renderHTML({HTMLAttributes:t}){return["span",Ki(this.options.HTMLAttributes,t),0]},addCommands(){return{removeEmptyTextStyle:()=>({state:t,commands:e})=>{const n=Ls(t,this.type);return!!Object.entries(n).some((([,t])=>!!t))||e.unsetMark(this.name)}}}}),Dh=/^(\d+)\.\s$/,Rh=oa.create({name:"orderedList",addOptions:()=>({itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}),group:"block list",content(){return`${this.options.itemTypeName}+`},addAttributes:()=>({start:{default:1,parseHTML:t=>t.hasAttribute("start")?parseInt(t.getAttribute("start")||"",10):1},type:{default:void 0,parseHTML:t=>t.getAttribute("type")}}),parseHTML:()=>[{tag:"ol"}],renderHTML({HTMLAttributes:t}){const{start:e,...n}=t;return 1===e?["ol",Ki(this.options.HTMLAttributes,n),0]:["ol",Ki(this.options.HTMLAttributes,t),0]},addCommands(){return{toggleOrderedList:()=>({commands:t,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(Nh.name,this.editor.getAttributes(Ah.name)).run():t.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-7":()=>this.editor.commands.toggleOrderedList()}},addInputRules(){let t=ra({find:Dh,type:this.type,getAttributes:t=>({start:+t[1]}),joinPredicate:(t,e)=>e.childCount+e.attrs.start===+t[1]});return(this.options.keepMarks||this.options.keepAttributes)&&(t=ra({find:Dh,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:t=>({start:+t[1],...this.editor.getAttributes(Ah.name)}),joinPredicate:(t,e)=>e.childCount+e.attrs.start===+t[1],editor:this.editor})),[t]}}),Ih=oa.create({name:"doc",topNode:!0,content:"block+"}),Lh=oa.create({name:"paragraph",priority:1e3,addOptions:()=>({HTMLAttributes:{}}),group:"block",content:"inline*",parseHTML:()=>[{tag:"p"}],renderHTML({HTMLAttributes:t}){return["p",Ki(this.options.HTMLAttributes,t),0]},addCommands(){return{setParagraph:()=>({commands:t})=>t.setNode(this.name)}},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setParagraph()}}}),Ph=oa.create({name:"text",group:"inline"}),jh=ls.create({name:"textStyle",priority:101,addOptions:()=>({HTMLAttributes:{}}),parseHTML:()=>[{tag:"span",getAttrs:t=>!!t.hasAttribute("style")&&{}}],renderHTML({HTMLAttributes:t}){return["span",Ki(this.options.HTMLAttributes,t),0]},addCommands(){return{removeEmptyTextStyle:()=>({state:t,commands:e})=>{const n=Ls(t,this.type);return!!Object.entries(n).some((([,t])=>!!t))||e.unsetMark(this.name)}}}});var zh=ps.create({name:"fontSize",addOptions:function(){return{types:["textStyle"]}},addGlobalAttributes:function(){return[{types:this.options.types,attributes:{fontSize:{default:null,parseHTML:function(t){return t.style.fontSize.replace(/['"]+/g,"")},renderHTML:function(t){return t.fontSize?{style:"font-size: "+t.fontSize}:{}}}}}]},addCommands:function(){return{setFontSize:function(t){return function(e){return(0,e.chain)().setMark("textStyle",{fontSize:t}).run()}},unsetFontSize:function(){return function(t){return(0,t.chain)().setMark("textStyle",{fontSize:null}).removeEmptyTextStyle().run()}}}}});const $h=[Ih,Lh,Ph,jh],Bh=[Oc.configure({levels:[1,2]}),Eh,Sc,Rh,Th,vc,Nc,zh],Fh=({open:t,setOpen:e,editor:n,locale:o})=>{const[i,s]=r(""),a=h((()=>"no"===o),[o]);d((()=>{if(t){const{from:t,to:e}=n.state.selection;let r=null;n.state.doc.nodesBetween(t-1,e,(t=>{if(t.marks){const e=t.marks.find((t=>"link"===t.type.name));e&&(r=e.attrs.href)}})),s(r||"");const o=document.querySelector('[data-test="link-input-field"]');null==o||o.focus()}}),[t,n]);return E.jsx(v,{open:t,dataTest:"link-modal-rte",onClose:()=>e(!1),className:"z-[99]",dialogTitle:E.jsx("div",{className:"text-gray-700",children:a?"Legg til lenke":"Add link"}),children:E.jsxs("main",{className:"flex flex-col items-start justify-center p-0 gap-6 m-4 h-full",children:[E.jsx("div",{className:"link-input-field",children:E.jsx(m,{autoFocus:!0,multiline:!0,className:"w-full",dataTest:"link-input-field",size:"small",sx:{"& .MuiInputBase-root":{minHeight:64,alignItems:"start"}},value:i,onChange:t=>s(t.target.value)})}),E.jsxs("div",{className:"flex gap-2 p-0 w-full justify-end",children:[E.jsx(y,{dataTest:"delete-customer-reject-button",size:"medium",variant:"outlined",onClick:()=>{e(!1),s("")},children:a?"Avbryt":"Cancel"}),E.jsx(y,{dataTest:"delete-customer-confirm-button",size:"medium",variant:"contained",onClick:()=>{n.chain().focus().setLink({href:i}).run(),e(!1),s("")},children:a?"Legg til lenke":"Add link"})]})]})})},_h=ps.create({name:"placeholder",addOptions:()=>({emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something …",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}),addProseMirrorPlugins(){return[new Ue({key:new Qe("placeholder"),props:{decorations:({doc:t,selection:e})=>{const n=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:r}=e,o=[];if(!n)return null;const i=this.editor.isEmpty;return t.descendants(((t,e)=>{const n=r>=e&&r<=e+t.nodeSize,s=!t.isLeaf&&Vs(t);if((n||!this.options.showOnlyCurrent)&&s){const r=[this.options.emptyNodeClass];i&&r.push(this.options.emptyEditorClass);const s=Lo.node(e,e+t.nodeSize,{class:r.join(" "),"data-placeholder":"function"==typeof this.options.placeholder?this.options.placeholder({editor:this.editor,node:t,pos:e,hasAnchor:n}):this.options.placeholder});o.push(s)}return this.options.includeChildren})),zo.create(t,o)}}})]}}),Vh=({dataTest:t,id:e,inputRef:n,className:o,editorClassName:s,disabled:a,readOnly:l,error:c,placeholder:d,helperText:h,required:p,hideToolbar:f,noDefaultStyles:m,...g})=>{const y=Ea({...g,extensions:[_h.configure({placeholder:d}),...$h,...Bh,...g.extensions||[]],shouldRerenderOnTransaction:g.shouldRerenderOnTransaction||!1,immediatelyRender:g.immediatelyRender||!0,editable:g.editable||!a&&!l}),[b,v]=r(g.toolbarDefaultVisible),[x,S]=r(!1);u(n,(()=>y));const[O,C]=r(!1);return i((()=>{const t=()=>C(!0),e=()=>C(!1);return null==y||y.on("focus",t),null==y||y.on("blur",e),()=>{null==y||y.off("focus",t),null==y||y.off("blur",e)}}),[y]),y?E.jsxs(E.Fragment,{children:[E.jsxs(w,{className:o,children:[g.title&&E.jsx("p",{className:"font-semibold text-base text-gray-700 mb-2",children:g.title}),E.jsxs("div",{className:A("rte-wrapper","outlined"===l&&"readonly-outlined","plain"===l&&"readonly-plain",c&&!O&&"error-state",O&&!l&&(c?"error-focused-state":"focused-state")),children:[E.jsx(ga,{"data-test":t,id:e,className:A("border-none rounded-none",!m&&"core-ui-rte",!f&&!a&&!l&&!b&&"displace-text",!m&&!a&&!l&&"edit-mode",s),editor:y,onClick:()=>null==y?void 0:y.chain().focus().run(),style:{"--max-scrollable-height":g.maxScrollableHeight?`${g.maxScrollableHeight}${"number"==typeof g.maxScrollableHeight?"px":""}`:"none"}}),!f&&!a&&!l&&!b&&E.jsx(dc,{onClick:()=>v(!0),className:"cursor-pointer absolute bottom-2.5 right-4",icon:"material-symbols:format-color-text",color:"var(--colors-gray-700)",height:24,width:24}),!f&&!a&&!l&&b&&E.jsx(fc,{editor:y,onClose:()=>v(!1),error:c,focused:O,openLinkDialog:()=>S(!0),locale:g.locale})]}),(c||p)&&!l&&E.jsx(k,{error:c,"data-test":`error-${t}`,children:h})]}),E.jsx(Fh,{open:x,setOpen:S,editor:y,locale:g.locale})]}):null};export{Vh as RichInput};