diff --git a/backend/src/Squidex/wwwroot/editor/squidex-editor.css b/backend/src/Squidex/wwwroot/editor/squidex-editor.css
index 0f8e29189..eaad49e60 100644
--- a/backend/src/Squidex/wwwroot/editor/squidex-editor.css
+++ b/backend/src/Squidex/wwwroot/editor/squidex-editor.css
@@ -1 +1 @@
-.remirror-theme{width:100%}.remirror-theme{position:relative}.remirror-theme *{box-sizing:border-box}.remirror-theme .ProseMirror p{margin-bottom:1rem!important}.remirror-editor{min-height:300px!important;max-height:500px}.MuiStack-root>.MuiBox-root{margin-right:5px}.MuiBox-root>.MuiButtonBase-root{border-color:#dedfe3!important;border-radius:0}.MuiBox-root>.MuiButtonBase-root{border-left-width:0!important}.MuiBox-root>.MuiBox-root:first-child>.MuiButtonBase-root{border-left-width:1px!important}.MuiStack-root>.MuiBox-root>.MuiButtonBase-root:first-child{border-left-width:1px!important}.MuiButtonBase-root.Mui-selected:hover{background-color:#3284f4!important}.remirror-editor-wrapper{padding-top:0!important}.custom-icon path{fill:#0000008a}.remirror-theme div.ProseMirror{border:1px solid #dedfe3!important;border-radius:0!important;box-shadow:none!important}.MuiTooltip-popper>div{background-color:#1a2129;border-radius:0;font-size:85%;font-weight:400;padding:.5rem}.MuiMenu-paper{transform:none!important}.squidex-editor-disabled{pointer-events:none}.squidex-editor-menu{border:1px solid #dedfe3;border-bottom:0;padding:5px}.squidex-editor-counter{border:1px solid #dedfe3;border-top:0;font-size:85%;font-weight:400;opacity:.8;padding:4px 10px 4px 4px;text-align:right}.squidex-editor-image-view{border:1px solid #dedfe3;border-radius:0;display:inline-block;margin-top:15px;margin-bottom:15px;overflow:hidden}.squidex-editor-image-buttons{bottom:10px;left:10px;position:absolute}.squidex-editor-image-element{display:block;max-width:400px;max-height:400px}.squidex-editor-image-info{left:10px;top:10px;position:absolute;background-color:#3284f4;color:#fff;font-size:85%;font-weight:400;padding:2px 6px}.squidex-editor-content-link{align-items:center;border-radius:2px;border:1px solid #dedfe3;padding:10px;display:flex;flex-direction:row;flex-wrap:nowrap;margin-top:10px;margin-bottom:10px}.squidex-editor-content-schema{display:block;overflow-x:hidden;overflow-y:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:100%;min-width:0;width:auto;border-right:1px solid #c2c4cc;color:#8b8f9d;flex-shrink:0;padding-left:10px;padding-right:10px;width:200px}.squidex-editor-content-name{display:block;overflow-x:hidden;overflow-y:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:100%;min-width:0;width:auto;padding-left:10px;padding-right:0}.squidex-editor-html{margin-bottom:10px;margin-top:10px;position:relative}.squidex-editor-html-label{left:6px;top:0;position:absolute;color:#8b8f9d;font-size:85%;font-weight:400}.squidex-editor-html textarea{font-family:monospace;padding:30px 20px 20px}.squidex-editor-button{align-items:center;background-color:#fff;border-radius:0;border:1px solid #dedfe3;bottom:10px;display:inline-flex;font-size:85%;font-weight:400;margin-right:5px;padding:6px 12px}.squidex-editor-button:hover{background-color:#f5f5f5}.squidex-editor-input{border:1px solid #dedfe3;border-radius:0;box-sizing:border-box;height:30px;margin-left:0;margin-right:5px;outline:none;padding:6px 12px}.squidex-editor-input:active{border-color:#3284f4}.squidex-editor-floating{border:1px solid #dedfe3}.squidex-editor-floating .MuiBox-root{margin-right:0!important}.squidex-editor-floating .MuiButtonBase-root{height:30px}.squidex-editor-modal-wrapper,.squidex-editor-modal-backdrop{bottom:0;left:0;right:0;top:0;position:absolute}.squidex-editor-modal-backdrop{background-color:#00000003}.squidex-editor-modal-window{left:50%;top:50%;background-color:#fff;border:0;border-radius:.25rem;box-sizing:border-box;box-shadow:0 3px 16px #0003;margin-top:-50px;margin-left:-150px;position:absolute;width:350px}.squidex-editor-modal-body{display:flex;flex-direction:row;flex-grow:1;padding-top:0!important}.squidex-editor-modal-body,.squidex-editor-modal-title{padding:15px}.squidex-editor-modal-title{font-size:85%}.squidex-editor-modal-window input{flex-grow:1}.b:before{content:"";font-family:monospace;font-size:90%}.b:after{content:"";font-family:monospace;font-size:90%}
+.remirror-theme{width:100%}.remirror-theme{position:relative}.remirror-theme *{box-sizing:border-box}.remirror-theme .ProseMirror p{margin-bottom:1rem!important}.remirror-editor{min-height:300px!important;max-height:500px}.MuiStack-root>.MuiBox-root{margin-right:5px}.MuiBox-root>.MuiButtonBase-root{border-color:#dedfe3!important;border-radius:0}.MuiBox-root>.MuiButtonBase-root{border-left-width:0!important}.MuiBox-root>.MuiBox-root:first-child>.MuiButtonBase-root{border-left-width:1px!important}.MuiStack-root>.MuiBox-root>.MuiButtonBase-root:first-child{border-left-width:1px!important}.MuiButtonBase-root.Mui-selected:hover{background-color:#3284f4!important}.remirror-editor-wrapper{padding-top:0!important}.custom-icon path{fill:#0000008a}.remirror-theme div.ProseMirror{border:1px solid #dedfe3!important;border-radius:0!important;box-shadow:none!important}.MuiTooltip-popper>div{background-color:#1a2129;border-radius:0;font-size:85%;font-weight:400;padding:.5rem}.MuiMenu-paper{transform:none!important}.squidex-editor-disabled{pointer-events:none}.squidex-editor-menu{border:1px solid #dedfe3;border-bottom:0;padding:5px}.squidex-editor-menu fieldset{border-radius:0;border:0;display:flex;outline:0;padding:0;pointer-events:none}.squidex-editor-menu fieldset:disabled{opacity:.5}.squidex-editor-counter{border:1px solid #dedfe3;border-top:0;font-size:85%;font-weight:400;opacity:.8;padding:4px 10px 4px 4px;text-align:right}.squidex-editor-image-view{border:1px solid #dedfe3;border-radius:0;display:inline-block;margin-top:15px;margin-bottom:15px;overflow:hidden}.squidex-editor-image-buttons{bottom:10px;left:10px;position:absolute}.squidex-editor-image-element{display:block;max-width:400px;max-height:400px}.squidex-editor-image-info{left:10px;top:10px;position:absolute;background-color:#3284f4;color:#fff;font-size:85%;font-weight:400;padding:2px 6px}.squidex-editor-main{position:relative}.squidex-editor-main .ace_editor{bottom:0;left:0;right:0;top:0;position:absolute;border:1px solid #dedfe3}.squidex-editor-content-link{align-items:center;border-radius:2px;border:1px solid #dedfe3;padding:10px;display:flex;flex-direction:row;flex-wrap:nowrap;margin-top:10px;margin-bottom:10px}.squidex-editor-content-schema{display:block;overflow-x:hidden;overflow-y:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:100%;min-width:0;width:auto;border-right:1px solid #c2c4cc;color:#8b8f9d;flex-shrink:0;padding-left:10px;padding-right:10px;width:200px}.squidex-editor-content-name{display:block;overflow-x:hidden;overflow-y:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:100%;min-width:0;width:auto;padding-left:10px;padding-right:0}.squidex-editor-html{margin-bottom:10px;margin-top:10px;position:relative}.squidex-editor-html-label{left:6px;top:0;position:absolute;color:#8b8f9d;font-size:85%;font-weight:400}.squidex-editor-html textarea{font-family:monospace;padding:30px 20px 20px}.squidex-editor-button{align-items:center;background-color:#fff;border-radius:0;border:1px solid #dedfe3;bottom:10px;display:inline-flex;font-size:85%;font-weight:400;margin-right:5px;padding:6px 12px}.squidex-editor-button:hover{background-color:#f5f5f5}.squidex-editor-input{border:1px solid #dedfe3;border-radius:0;box-sizing:border-box;height:30px;margin-left:0;margin-right:5px;outline:none;padding:6px 12px}.squidex-editor-input:active{border-color:#3284f4}.squidex-editor-floating{border:1px solid #dedfe3}.squidex-editor-floating .MuiBox-root{margin-right:0!important}.squidex-editor-floating .MuiButtonBase-root{height:30px}.squidex-editor-modal-wrapper,.squidex-editor-modal-backdrop{bottom:0;left:0;right:0;top:0;position:absolute}.squidex-editor-modal-backdrop{background-color:#00000003}.squidex-editor-modal-window{left:50%;top:50%;background-color:#fff;border:0;border-radius:.25rem;box-sizing:border-box;box-shadow:0 3px 16px #0003;margin-top:-50px;margin-left:-150px;position:absolute;width:350px}.squidex-editor-modal-body{display:flex;flex-direction:row;flex-grow:1;padding-top:0!important}.squidex-editor-modal-body,.squidex-editor-modal-title{padding:15px}.squidex-editor-modal-title{font-size:85%}.squidex-editor-modal-window input{flex-grow:1}.b:before{content:"";font-family:monospace;font-size:90%}.b:after{content:"";font-family:monospace;font-size:90%}
diff --git a/backend/src/Squidex/wwwroot/editor/squidex-editor.js b/backend/src/Squidex/wwwroot/editor/squidex-editor.js
index 6e983cf48..65509ef9a 100644
--- a/backend/src/Squidex/wwwroot/editor/squidex-editor.js
+++ b/backend/src/Squidex/wwwroot/editor/squidex-editor.js
@@ -1,4 +1,4 @@
-var $M=Object.defineProperty;var BM=(e,t,r)=>t in e?$M(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var Fe=(e,t,r)=>(BM(e,typeof t!="symbol"?t+"":t,r),r),HM=(e,t,r)=>{if(!t.has(e))throw TypeError("Cannot "+r)};var xg=(e,t,r)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,r)};var pp=(e,t,r)=>(HM(e,t,"access private method"),r);function FM(e,t){for(var r=0;rn[o]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))n(o);new MutationObserver(o=>{for(const i of o)if(i.type==="childList")for(const s of i.addedNodes)s.tagName==="LINK"&&s.rel==="modulepreload"&&n(s)}).observe(document,{childList:!0,subtree:!0});function r(o){const i={};return o.integrity&&(i.integrity=o.integrity),o.referrerPolicy&&(i.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?i.credentials="include":o.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function n(o){if(o.ep)return;o.ep=!0;const i=r(o);fetch(o.href,i)}})();var Zo=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function po(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var nC={exports:{}},Gh={},oC={exports:{}},we={};/**
+var r4=Object.defineProperty;var o4=(t,e,n)=>e in t?r4(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var ct=(t,e,n)=>(o4(t,typeof e!="symbol"?e+"":e,n),n),i4=(t,e,n)=>{if(!e.has(t))throw TypeError("Cannot "+n)};var Uv=(t,e,n)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,n)};var xf=(t,e,n)=>(i4(t,e,"access private method"),n);function s4(t,e){for(var n=0;nr[o]})}}}return Object.freeze(Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}))}(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))r(o);new MutationObserver(o=>{for(const i of o)if(i.type==="childList")for(const s of i.addedNodes)s.tagName==="LINK"&&s.rel==="modulepreload"&&r(s)}).observe(document,{childList:!0,subtree:!0});function n(o){const i={};return o.integrity&&(i.integrity=o.integrity),o.referrerPolicy&&(i.referrerPolicy=o.referrerPolicy),o.crossOrigin==="use-credentials"?i.credentials="include":o.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function r(o){if(o.ep)return;o.ep=!0;const i=n(o);fetch(o.href,i)}})();var ut=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function jo(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var H_={exports:{}},nm={},U_={exports:{}},Ve={};/**
* @license React
* react.production.min.js
*
@@ -6,7 +6,7 @@ var $M=Object.defineProperty;var BM=(e,t,r)=>t in e?$M(e,t,{enumerable:!0,config
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
- */var zd=Symbol.for("react.element"),UM=Symbol.for("react.portal"),VM=Symbol.for("react.fragment"),jM=Symbol.for("react.strict_mode"),GM=Symbol.for("react.profiler"),WM=Symbol.for("react.provider"),KM=Symbol.for("react.context"),YM=Symbol.for("react.forward_ref"),qM=Symbol.for("react.suspense"),XM=Symbol.for("react.memo"),ZM=Symbol.for("react.lazy"),bx=Symbol.iterator;function JM(e){return e===null||typeof e!="object"?null:(e=bx&&e[bx]||e["@@iterator"],typeof e=="function"?e:null)}var iC={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},sC=Object.assign,aC={};function lc(e,t,r){this.props=e,this.context=t,this.refs=aC,this.updater=r||iC}lc.prototype.isReactComponent={};lc.prototype.setState=function(e,t){if(typeof e!="object"&&typeof e!="function"&&e!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,e,t,"setState")};lc.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function lC(){}lC.prototype=lc.prototype;function Ly(e,t,r){this.props=e,this.context=t,this.refs=aC,this.updater=r||iC}var Dy=Ly.prototype=new lC;Dy.constructor=Ly;sC(Dy,lc.prototype);Dy.isPureReactComponent=!0;var Ex=Array.isArray,cC=Object.prototype.hasOwnProperty,Py={current:null},uC={key:!0,ref:!0,__self:!0,__source:!0};function dC(e,t,r){var n,o={},i=null,s=null;if(t!=null)for(n in t.ref!==void 0&&(s=t.ref),t.key!==void 0&&(i=""+t.key),t)cC.call(t,n)&&!uC.hasOwnProperty(n)&&(o[n]=t[n]);var a=arguments.length-2;if(a===1)o.children=r;else if(1t in e?$M(e,t,{enumerable:!0,config
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
- */var n4=S,o4=Symbol.for("react.element"),i4=Symbol.for("react.fragment"),s4=Object.prototype.hasOwnProperty,a4=n4.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,l4={key:!0,ref:!0,__self:!0,__source:!0};function pC(e,t,r){var n,o={},i=null,s=null;r!==void 0&&(i=""+r),t.key!==void 0&&(i=""+t.key),t.ref!==void 0&&(s=t.ref);for(n in t)s4.call(t,n)&&!l4.hasOwnProperty(n)&&(o[n]=t[n]);if(e&&e.defaultProps)for(n in t=e.defaultProps,t)o[n]===void 0&&(o[n]=t[n]);return{$$typeof:o4,type:e,key:i,ref:s,props:o,_owner:a4.current}}Gh.Fragment=i4;Gh.jsx=pC;Gh.jsxs=pC;nC.exports=Gh;var A=nC.exports,H1={exports:{}};(function(e,t){var r=typeof Reflect<"u"?Reflect.construct:void 0,n=Object.defineProperty,o=Error.captureStackTrace;o===void 0&&(o=function(c){var u=new Error;n(c,"stack",{configurable:!0,get:function(){var p=u.stack;return n(this,"stack",{configurable:!0,value:p,writable:!0}),p},set:function(p){n(c,"stack",{configurable:!0,value:p,writable:!0})}})});function i(l){l!==void 0&&n(this,"message",{configurable:!0,value:l,writable:!0});var c=this.constructor.name;c!==void 0&&c!==this.name&&n(this,"name",{configurable:!0,value:c,writable:!0}),o(this,this.constructor)}i.prototype=Object.create(Error.prototype,{constructor:{configurable:!0,value:i,writable:!0}});var s=function(){function l(u,d){return n(u,"name",{configurable:!0,value:d})}try{var c=function(){};if(l(c,"foo"),c.name==="foo")return l}catch{}}();function a(l,c){if(c==null||c===Error)c=i;else if(typeof c!="function")throw new TypeError("super_ should be a function");var u;if(typeof l=="string")u=l,l=r!==void 0?function(){return r(c,arguments,this.constructor)}:function(){c.apply(this,arguments)},s!==void 0&&(s(l,u),u=void 0);else if(typeof l!="function")throw new TypeError("constructor should be either a string or a function");l.super_=l.super=c;var d={constructor:{configurable:!0,value:l,writable:!0}};return u!==void 0&&(d.name={configurable:!0,value:u,writable:!0}),l.prototype=Object.create(c.prototype,d),l}t=e.exports=a,t.BaseError=i})(H1,H1.exports);var fC=H1.exports,xx="ProseMirror-selectednode",$y="",$i="\0",Sx="__state_override__",c4={LastNodeCompatible:"lastNodeCompatible",FormattingMark:"formattingMark",FormattingNode:"formattingNode",NodeCursor:"nodeCursor",FontStyle:"fontStyle",Link:"link",Color:"color",Alignment:"alignment",Indentation:"indentation",Behavior:"behavior",Code:"code",InlineNode:"inline",ListContainerNode:"listContainer",ListItemNode:"listItemNode",Block:"block",BlockNode:"block",TextBlock:"textBlock",ExcludeInputRules:"excludeFromInputRules",PreventExits:"preventsExits",Media:"media"},ie=c4,si=Symbol.for("__remirror__"),Vt=(e=>(e.PlainExtension="RemirrorPlainExtension",e.NodeExtension="RemirrorNodeExtension",e.MarkExtension="RemirrorMarkExtension",e.PlainExtensionConstructor="RemirrorPlainExtensionConstructor",e.NodeExtensionConstructor="RemirrorNodeExtensionConstructor",e.MarkExtensionConstructor="RemirrorMarkExtensionConstructor",e.Manager="RemirrorManager",e.Preset="RemirrorPreset",e.PresetConstructor="RemirrorPresetConstructor",e))(Vt||{}),Ue=(e=>(e[e.Critical=1e6]="Critical",e[e.Highest=1e5]="Highest",e[e.High=1e4]="High",e[e.Medium=1e3]="Medium",e[e.Default=100]="Default",e[e.Low=10]="Low",e[e.Lowest=0]="Lowest",e))(Ue||{}),Dr=(e=>(e[e.None=0]="None",e[e.Create=1]="Create",e[e.EditorView=2]="EditorView",e[e.Runtime=3]="Runtime",e[e.Destroy=4]="Destroy",e))(Dr||{}),V=(e=>(e.Undo="_|undo|_",e.Redo="_|redo|_",e.Bold="_|bold|_",e.Italic="_|italic|_",e.Underline="_|underline|_",e.Strike="_|strike|_",e.Code="_|code|_",e.Paragraph="_|paragraph|_",e.H1="_|h1|_",e.H2="_|h2|_",e.H3="_|h3|_",e.H4="_|h4|_",e.H5="_|h5|_",e.H6="_|h6|_",e.TaskList="_|task|_",e.BulletList="_|bullet|_",e.OrderedList="_|number|_",e.Quote="_|quote|_",e.Divider="_|divider|_",e.Codeblock="_|codeblock|_",e.ClearFormatting="_|clear|_",e.Superscript="_|sup|_",e.Subscript="_|sub|_",e.LeftAlignment="_|left-align|_",e.CenterAlignment="_|center-align|_",e.RightAlignment="_|right-align|_",e.JustifyAlignment="_|justify-align|_",e.InsertLink="_|link|_",e.Find="_|find|_",e.FindBackwards="_|find-backwards|_",e.FindReplace="_|find-replace|_",e.AddFootnote="_|footnote|_",e.AddComment="_|comment|_",e.ContextMenu="_|context-menu|_",e.IncreaseFontSize="_|inc-font-size|_",e.DecreaseFontSize="_|dec-font-size|_",e.IncreaseIndent="_|indent|_",e.DecreaseIndent="_|dedent|_",e.Shortcuts="_|shortcuts|_",e.Copy="_|copy|_",e.Cut="_|cut|_",e.Paste="_|paste|_",e.PastePlain="_|paste-plain|_",e.SelectAll="_|select-all|_",e.Format="_|format|_",e))(V||{}),U=(e=>(e.PROD="RMR0000",e.UNKNOWN="RMR0001",e.INVALID_COMMAND_ARGUMENTS="RMR0002",e.CUSTOM="RMR0003",e.CORE_HELPERS="RMR0004",e.MUTATION="RMR0005",e.INTERNAL="RMR0006",e.MISSING_REQUIRED_EXTENSION="RMR0007",e.MANAGER_PHASE_ERROR="RMR0008",e.INVALID_GET_EXTENSION="RMR0010",e.INVALID_MANAGER_ARGUMENTS="RMR0011",e.SCHEMA="RMR0012",e.HELPERS_CALLED_IN_OUTER_SCOPE="RMR0013",e.INVALID_MANAGER_EXTENSION="RMR0014",e.DUPLICATE_COMMAND_NAMES="RMR0016",e.DUPLICATE_HELPER_NAMES="RMR0017",e.NON_CHAINABLE_COMMAND="RMR0018",e.INVALID_EXTENSION="RMR0019",e.INVALID_CONTENT="RMR0021",e.INVALID_NAME="RMR0050",e.EXTENSION="RMR0100",e.EXTENSION_SPEC="RMR0101",e.EXTENSION_EXTRA_ATTRIBUTES="RMR0102",e.INVALID_SET_EXTENSION_OPTIONS="RMR0103",e.REACT_PROVIDER_CONTEXT="RMR0200",e.REACT_GET_ROOT_PROPS="RMR0201",e.REACT_EDITOR_VIEW="RMR0202",e.REACT_CONTROLLED="RMR0203",e.REACT_NODE_VIEW="RMR0204",e.REACT_GET_CONTEXT="RMR0205",e.REACT_COMPONENTS="RMR0206",e.REACT_HOOKS="RMR0207",e.I18N_CONTEXT="RMR0300",e))(U||{}),u4=function(t){return d4(t)&&!p4(t)};function d4(e){return!!e&&typeof e=="object"}function p4(e){var t=Object.prototype.toString.call(e);return t==="[object RegExp]"||t==="[object Date]"||m4(e)}var f4=typeof Symbol=="function"&&Symbol.for,h4=f4?Symbol.for("react.element"):60103;function m4(e){return e.$$typeof===h4}function g4(e){return Array.isArray(e)?[]:{}}function Uu(e,t){return t.clone!==!1&&t.isMergeableObject(e)?Il(g4(e),e,t):e}function y4(e,t,r){return e.concat(t).map(function(n){return Uu(n,r)})}function v4(e,t){if(!t.customMerge)return Il;var r=t.customMerge(e);return typeof r=="function"?r:Il}function b4(e){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(e).filter(function(t){return Object.propertyIsEnumerable.call(e,t)}):[]}function wx(e){return Object.keys(e).concat(b4(e))}function hC(e,t){try{return t in e}catch{return!1}}function E4(e,t){return hC(e,t)&&!(Object.hasOwnProperty.call(e,t)&&Object.propertyIsEnumerable.call(e,t))}function k4(e,t,r){var n={};return r.isMergeableObject(e)&&wx(e).forEach(function(o){n[o]=Uu(e[o],r)}),wx(t).forEach(function(o){E4(e,o)||(hC(e,o)&&r.isMergeableObject(t[o])?n[o]=v4(o,r)(e[o],t[o],r):n[o]=Uu(t[o],r))}),n}function Il(e,t,r){r=r||{},r.arrayMerge=r.arrayMerge||y4,r.isMergeableObject=r.isMergeableObject||u4,r.cloneUnlessOtherwiseSpecified=Uu;var n=Array.isArray(t),o=Array.isArray(e),i=n===o;return i?n?r.arrayMerge(e,t,r):k4(e,t,r):Uu(t,r)}Il.all=function(t,r){if(!Array.isArray(t))throw new Error("first argument should be an array");return t.reduce(function(n,o){return Il(n,o,r)},{})};var x4=Il,S4=x4;const w4=po(S4);var T4=function e(t,r){if(t===r)return!0;if(t&&r&&typeof t=="object"&&typeof r=="object"){if(t.constructor!==r.constructor)return!1;var n,o,i;if(Array.isArray(t)){if(n=t.length,n!=r.length)return!1;for(o=n;o--!==0;)if(!e(t[o],r[o]))return!1;return!0}if(t.constructor===RegExp)return t.source===r.source&&t.flags===r.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===r.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===r.toString();if(i=Object.keys(t),n=i.length,n!==Object.keys(r).length)return!1;for(o=n;o--!==0;)if(!Object.prototype.hasOwnProperty.call(r,i[o]))return!1;for(o=n;o--!==0;){var s=i[o];if(!e(t[s],r[s]))return!1}return!0}return t!==t&&r!==r};const C4=po(T4);/*!
+ */var k4=P,E4=Symbol.for("react.element"),S4=Symbol.for("react.fragment"),C4=Object.prototype.hasOwnProperty,T4=k4.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,A4={key:!0,ref:!0,__self:!0,__source:!0};function q_(t,e,n){var r,o={},i=null,s=null;n!==void 0&&(i=""+n),e.key!==void 0&&(i=""+e.key),e.ref!==void 0&&(s=e.ref);for(r in e)C4.call(e,r)&&!A4.hasOwnProperty(r)&&(o[r]=e[r]);if(t&&t.defaultProps)for(r in e=t.defaultProps,e)o[r]===void 0&&(o[r]=e[r]);return{$$typeof:E4,type:t,key:i,ref:s,props:o,_owner:T4.current}}nm.Fragment=S4;nm.jsx=q_;nm.jsxs=q_;H_.exports=nm;var j=H_.exports,c0={exports:{}};(function(t,e){var n=typeof Reflect<"u"?Reflect.construct:void 0,r=Object.defineProperty,o=Error.captureStackTrace;o===void 0&&(o=function(u){var c=new Error;r(u,"stack",{configurable:!0,get:function(){var h=c.stack;return r(this,"stack",{configurable:!0,value:h,writable:!0}),h},set:function(h){r(u,"stack",{configurable:!0,value:h,writable:!0})}})});function i(a){a!==void 0&&r(this,"message",{configurable:!0,value:a,writable:!0});var u=this.constructor.name;u!==void 0&&u!==this.name&&r(this,"name",{configurable:!0,value:u,writable:!0}),o(this,this.constructor)}i.prototype=Object.create(Error.prototype,{constructor:{configurable:!0,value:i,writable:!0}});var s=function(){function a(c,d){return r(c,"name",{configurable:!0,value:d})}try{var u=function(){};if(a(u,"foo"),u.name==="foo")return a}catch{}}();function l(a,u){if(u==null||u===Error)u=i;else if(typeof u!="function")throw new TypeError("super_ should be a function");var c;if(typeof a=="string")c=a,a=n!==void 0?function(){return n(u,arguments,this.constructor)}:function(){u.apply(this,arguments)},s!==void 0&&(s(a,c),c=void 0);else if(typeof a!="function")throw new TypeError("constructor should be either a string or a function");a.super_=a.super=u;var d={constructor:{configurable:!0,value:a,writable:!0}};return c!==void 0&&(d.name={configurable:!0,value:c,writable:!0}),a.prototype=Object.create(u.prototype,d),a}e=t.exports=l,e.BaseError=i})(c0,c0.exports);var Z_=c0.exports,ZE="ProseMirror-selectednode",cb="",ws="\0",QE="__state_override__",_4={LastNodeCompatible:"lastNodeCompatible",FormattingMark:"formattingMark",FormattingNode:"formattingNode",NodeCursor:"nodeCursor",FontStyle:"fontStyle",Link:"link",Color:"color",Alignment:"alignment",Indentation:"indentation",Behavior:"behavior",Code:"code",InlineNode:"inline",ListContainerNode:"listContainer",ListItemNode:"listItemNode",Block:"block",BlockNode:"block",TextBlock:"textBlock",ExcludeInputRules:"excludeFromInputRules",PreventExits:"preventsExits",Media:"media"},Ee=_4,Bi=Symbol.for("__remirror__"),bn=(t=>(t.PlainExtension="RemirrorPlainExtension",t.NodeExtension="RemirrorNodeExtension",t.MarkExtension="RemirrorMarkExtension",t.PlainExtensionConstructor="RemirrorPlainExtensionConstructor",t.NodeExtensionConstructor="RemirrorNodeExtensionConstructor",t.MarkExtensionConstructor="RemirrorMarkExtensionConstructor",t.Manager="RemirrorManager",t.Preset="RemirrorPreset",t.PresetConstructor="RemirrorPresetConstructor",t))(bn||{}),dt=(t=>(t[t.Critical=1e6]="Critical",t[t.Highest=1e5]="Highest",t[t.High=1e4]="High",t[t.Medium=1e3]="Medium",t[t.Default=100]="Default",t[t.Low=10]="Low",t[t.Lowest=0]="Lowest",t))(dt||{}),mr=(t=>(t[t.None=0]="None",t[t.Create=1]="Create",t[t.EditorView=2]="EditorView",t[t.Runtime=3]="Runtime",t[t.Destroy=4]="Destroy",t))(mr||{}),oe=(t=>(t.Undo="_|undo|_",t.Redo="_|redo|_",t.Bold="_|bold|_",t.Italic="_|italic|_",t.Underline="_|underline|_",t.Strike="_|strike|_",t.Code="_|code|_",t.Paragraph="_|paragraph|_",t.H1="_|h1|_",t.H2="_|h2|_",t.H3="_|h3|_",t.H4="_|h4|_",t.H5="_|h5|_",t.H6="_|h6|_",t.TaskList="_|task|_",t.BulletList="_|bullet|_",t.OrderedList="_|number|_",t.Quote="_|quote|_",t.Divider="_|divider|_",t.Codeblock="_|codeblock|_",t.ClearFormatting="_|clear|_",t.Superscript="_|sup|_",t.Subscript="_|sub|_",t.LeftAlignment="_|left-align|_",t.CenterAlignment="_|center-align|_",t.RightAlignment="_|right-align|_",t.JustifyAlignment="_|justify-align|_",t.InsertLink="_|link|_",t.Find="_|find|_",t.FindBackwards="_|find-backwards|_",t.FindReplace="_|find-replace|_",t.AddFootnote="_|footnote|_",t.AddComment="_|comment|_",t.ContextMenu="_|context-menu|_",t.IncreaseFontSize="_|inc-font-size|_",t.DecreaseFontSize="_|dec-font-size|_",t.IncreaseIndent="_|indent|_",t.DecreaseIndent="_|dedent|_",t.Shortcuts="_|shortcuts|_",t.Copy="_|copy|_",t.Cut="_|cut|_",t.Paste="_|paste|_",t.PastePlain="_|paste-plain|_",t.SelectAll="_|select-all|_",t.Format="_|format|_",t))(oe||{}),re=(t=>(t.PROD="RMR0000",t.UNKNOWN="RMR0001",t.INVALID_COMMAND_ARGUMENTS="RMR0002",t.CUSTOM="RMR0003",t.CORE_HELPERS="RMR0004",t.MUTATION="RMR0005",t.INTERNAL="RMR0006",t.MISSING_REQUIRED_EXTENSION="RMR0007",t.MANAGER_PHASE_ERROR="RMR0008",t.INVALID_GET_EXTENSION="RMR0010",t.INVALID_MANAGER_ARGUMENTS="RMR0011",t.SCHEMA="RMR0012",t.HELPERS_CALLED_IN_OUTER_SCOPE="RMR0013",t.INVALID_MANAGER_EXTENSION="RMR0014",t.DUPLICATE_COMMAND_NAMES="RMR0016",t.DUPLICATE_HELPER_NAMES="RMR0017",t.NON_CHAINABLE_COMMAND="RMR0018",t.INVALID_EXTENSION="RMR0019",t.INVALID_CONTENT="RMR0021",t.INVALID_NAME="RMR0050",t.EXTENSION="RMR0100",t.EXTENSION_SPEC="RMR0101",t.EXTENSION_EXTRA_ATTRIBUTES="RMR0102",t.INVALID_SET_EXTENSION_OPTIONS="RMR0103",t.REACT_PROVIDER_CONTEXT="RMR0200",t.REACT_GET_ROOT_PROPS="RMR0201",t.REACT_EDITOR_VIEW="RMR0202",t.REACT_CONTROLLED="RMR0203",t.REACT_NODE_VIEW="RMR0204",t.REACT_GET_CONTEXT="RMR0205",t.REACT_COMPONENTS="RMR0206",t.REACT_HOOKS="RMR0207",t.I18N_CONTEXT="RMR0300",t))(re||{}),R4=function(e){return M4(e)&&!O4(e)};function M4(t){return!!t&&typeof t=="object"}function O4(t){var e=Object.prototype.toString.call(t);return e==="[object RegExp]"||e==="[object Date]"||N4(t)}var I4=typeof Symbol=="function"&&Symbol.for,L4=I4?Symbol.for("react.element"):60103;function N4(t){return t.$$typeof===L4}function $4(t){return Array.isArray(t)?[]:{}}function Fd(t,e){return e.clone!==!1&&e.isMergeableObject(t)?_c($4(t),t,e):t}function D4(t,e,n){return t.concat(e).map(function(r){return Fd(r,n)})}function P4(t,e){if(!e.customMerge)return _c;var n=e.customMerge(t);return typeof n=="function"?n:_c}function z4(t){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(t).filter(function(e){return Object.propertyIsEnumerable.call(t,e)}):[]}function JE(t){return Object.keys(t).concat(z4(t))}function Q_(t,e){try{return e in t}catch{return!1}}function F4(t,e){return Q_(t,e)&&!(Object.hasOwnProperty.call(t,e)&&Object.propertyIsEnumerable.call(t,e))}function B4(t,e,n){var r={};return n.isMergeableObject(t)&&JE(t).forEach(function(o){r[o]=Fd(t[o],n)}),JE(e).forEach(function(o){F4(t,o)||(Q_(t,o)&&n.isMergeableObject(e[o])?r[o]=P4(o,n)(t[o],e[o],n):r[o]=Fd(e[o],n))}),r}function _c(t,e,n){n=n||{},n.arrayMerge=n.arrayMerge||D4,n.isMergeableObject=n.isMergeableObject||R4,n.cloneUnlessOtherwiseSpecified=Fd;var r=Array.isArray(e),o=Array.isArray(t),i=r===o;return i?r?n.arrayMerge(t,e,n):B4(t,e,n):Fd(e,n)}_c.all=function(e,n){if(!Array.isArray(e))throw new Error("first argument should be an array");return e.reduce(function(r,o){return _c(r,o,n)},{})};var H4=_c,U4=H4;const W4=jo(U4);var V4=function t(e,n){if(e===n)return!0;if(e&&n&&typeof e=="object"&&typeof n=="object"){if(e.constructor!==n.constructor)return!1;var r,o,i;if(Array.isArray(e)){if(r=e.length,r!=n.length)return!1;for(o=r;o--!==0;)if(!t(e[o],n[o]))return!1;return!0}if(e.constructor===RegExp)return e.source===n.source&&e.flags===n.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===n.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===n.toString();if(i=Object.keys(e),r=i.length,r!==Object.keys(n).length)return!1;for(o=r;o--!==0;)if(!Object.prototype.hasOwnProperty.call(n,i[o]))return!1;for(o=r;o--!==0;){var s=i[o];if(!t(e[s],n[s]))return!1}return!0}return e!==e&&n!==n};const j4=jo(V4);/*!
* isobject
*
* Copyright (c) 2014-2017, Jon Schlinkert.
* Released under the MIT License.
- */var mC=function(t){return t!=null&&typeof t=="object"&&Array.isArray(t)===!1};/*!
+ */var J_=function(e){return e!=null&&typeof e=="object"&&Array.isArray(e)===!1};/*!
* is-plain-object
*
* Copyright (c) 2014-2017, Jon Schlinkert.
* Released under the MIT License.
- */var O4=mC;function Tx(e){return O4(e)===!0&&Object.prototype.toString.call(e)==="[object Object]"}var A4=function(t){var r,n;return!(Tx(t)===!1||(r=t.constructor,typeof r!="function")||(n=r.prototype,Tx(n)===!1)||n.hasOwnProperty("isPrototypeOf")===!1)};/*!
+ */var G4=J_;function eS(t){return G4(t)===!0&&Object.prototype.toString.call(t)==="[object Object]"}var K4=function(e){var n,r;return!(eS(e)===!1||(n=e.constructor,typeof n!="function")||(r=n.prototype,eS(r)===!1)||r.hasOwnProperty("isPrototypeOf")===!1)};/*!
* is-extendable
*
* Copyright (c) 2015-2017, Jon Schlinkert.
* Released under the MIT License.
- */var N4=A4,R4=function(t){return N4(t)||typeof t=="function"||Array.isArray(t)};/*!
+ */var Y4=K4,X4=function(e){return Y4(e)||typeof e=="function"||Array.isArray(e)};/*!
* object.omit
*
* Copyright (c) 2014-2017, Jon Schlinkert.
* Released under the MIT License.
- */var _4=R4,I4=function(t,r,n){if(!_4(t))return{};typeof r=="function"&&(n=r,r=[]),typeof r=="string"&&(r=[r]);for(var o=typeof n=="function",i=Object.keys(t),s={},a=0;a
*
* Copyright (c) 2014-2015 Jon Schlinkert, contributors.
* Licensed under the MIT License
- */var M4=mC,L4=function(t,r){if(!M4(t)&&typeof t!="function")return{};var n={};if(typeof r=="string")return r in t&&(n[r]=t[r]),n;for(var o=r.length,i=-1;++i{let d=l.prefixes[u]||"",p=c;return r===!1&&(n&&(p=p.normalize("NFD").replace(new RegExp(`[^a-zA-ZØßø0-9${n.join("")}]`,"g"),"")),n||(p=p.normalize("NFD").replace(/[^a-zA-ZØßø0-9]/g,""),d="")),n&&(d=d.replace(new RegExp(`[^${n.join("")}]`,"g"),"")),u===0?d+p:!d&&!p?"":s&&!d&&o.match(/\s/)?" "+p:(d||o)+p}).filter(Boolean)}function z4(e){const t=e.matchAll(gC).next().value,r=t?t.index:0;return e.slice(0,r+1).toUpperCase()+e.slice(r+1).toLowerCase()}function vC(e,t){return yC(e,t).reduce((r,n)=>r+z4(n),"")}function Cx(e,t){return yC(e,{...t,prefix:"-"}).join("").toLowerCase()}function U1(e,t,r,n){var o,i=!1,s=0;function a(){o&&clearTimeout(o)}function l(){a(),i=!0}typeof t!="boolean"&&(n=r,r=t,t=void 0);function c(){for(var u=arguments.length,d=new Array(u),p=0;pe?m():t!==!0&&(o=setTimeout(n?b:m,n===void 0?e-h:e))}return c.cancel=l,c}function bC(e,t,r){return r===void 0?U1(e,t,!1):U1(e,r,t!==!1)}function lt(e,t,r){const n=e[t];return EC(!Kh(n),r),n}function EC(e,t){if(!e)throw new $4(t)}var $4=class extends fC.BaseError{constructor(){super(...arguments),this.name="AssertionError"}};function Dt(e){return Object.entries(e)}function Vu(e){return Object.keys(e)}function Wh(e){return Object.values(e)}function wr(e,t,r){return e.includes(t,r)}function te(e){return Object.assign(Object.create(null),e)}function kC(e){return Object.prototype.toString.call(e)}function xC(e){return kC(e).slice(8,-1)}function $d(e,t){return r=>typeof r!==e?!1:t?t(r):!0}function Hy(e){return t=>xC(t)===e}var Kh=$d("undefined"),oe=$d("string"),gn=$d("number",e=>!Number.isNaN(e)),De=$d("function");function B4(e){return e===null}function V1(e){return e===!0||e===!1}function gs(e){if(xC(e)!=="Object")return!1;const t=Object.getPrototypeOf(e);return t===null||t===Object.getPrototypeOf({})}function H4(e){return e==null||/^[bns]/.test(typeof e)}function ns(e){return B4(e)||Kh(e)}function nr(e){return!ns(e)&&(De(e)||$d("object")(e))}var F4=Hy("RegExp");function U4(e){return Hy("Map")(e)}function V4(e){return Hy("Set")(e)}function Af(e){return nr(e)&&!U4(e)&&!V4(e)&&Object.keys(e).length===0}var ft=Array.isArray;function is(e){return ft(e)&&e.length===0}function Ox(e){return ft(e)&&e.length>0}function j4(e){return e.charAt(0).toUpperCase()+e.slice(1)}function cc(e,t,r=n=>!!n){t.lastIndex=0;const n=[],o=t.flags;let i;o.includes("g")||(t=new RegExp(t.source,`g${o}`));do i=t.exec(e),i&&n.push(i);while(r(i));return t.lastIndex=0,n}function Nf(){const e=Date.now(),t=Nf.last||e;return Nf.last=e>t?e:t+1}Nf.last=0;function Ml(e=""){return`${e}${Nf().toString(36)}`}function SC(e){return By(e,t=>!Kh(t))}function G4(e){if(!gs(e))throw new Error("An invalid value was passed into this clone utility. Expected a plain object");return{...e}}var wC=C4;function Ll(e,t=!1){const r=t?[...e].reverse():e,n=new Set(r);return t?[...n].reverse():[...n]}function TC(e){const t=[];for(const r of e){const n=ft(r)?TC(r):[r];t.push(...n)}return t}function CC(){}function OC(...e){return w4.all(e,{isMergeableObject:gs})}function W4({min:e,max:t,value:r}){return rt?t:r}function K4(e){return e[e.length-1]}function ia(e,t){return[...e].map((r,n)=>({value:r,index:n})).sort((r,n)=>t(r.value,n.value)||r.index-n.index).map(({value:r})=>r)}function Y4(e,t,r){try{if(oe(t)&&t in e)return e[t];ft(t)&&(t=`['${t.join("']['")}']`);let n=e;return t.replace(/\[\s*(["'])(.*?)\1\s*]|^\s*(\w+)\s*(?=\.|\[|$)|\.\s*(\w*)\s*(?=\.|\[|$)|\[\s*(-?\d+)\s*]/g,(o,i,s,a,l,c)=>(n=n[s||a||l||c],"")),n===void 0?r:n}catch{return r}}function q4(e,t){const r=G4(t);let n=r;for(const[o,i]of e.entries()){const s=o>=e.length-1;let a=n[i];if(s){if(ft(n)){const l=Number.parseInt(i.toString(),10);gn(l)&&n.splice(l,1)}else Reflect.deleteProperty(n,i);return r}if(H4(a))return r;a=ft(a)?[...a]:{...a},n[i]=a,n=a}return r}function X4(e){return t=>Y4(t,e)}function Fy(e,t,r=!1){const n=[],o=new Set,i=De(t)?t:X4(t),s=r?[...e].reverse():e;for(const a of s){const l=i(a);o.has(l)||(o.add(l),n.push(a))}return r?n.reverse():n}function Uy(e,t){const r=ft(e)?e[0]:e;return gn(t)?r<=t?Array.from({length:t+1-r},(n,o)=>o+r):Array.from({length:r+1-t},(n,o)=>-1*o+r):Array.from({length:Math.abs(r)},(n,o)=>(r<0?-1:1)*o)}function Ax(e,...t){const r=t.filter(gn);return e>=Math.min(...r)&&e<=Math.max(...r)}function AC(e){return De(e)?e():e}var NC="https://remirror.io/docs/errors",Z4={[U.UNKNOWN]:"An error occurred but we're not quite sure why. 🧐",[U.INVALID_COMMAND_ARGUMENTS]:"The arguments passed to the command method were invalid.",[U.CUSTOM]:"This is a custom error, possibly thrown by an external library.",[U.CORE_HELPERS]:"An error occurred in a function called from the `@remirror/core-helpers` library.",[U.MUTATION]:"Mutation of immutable value detected.",[U.INTERNAL]:"This is an error which should not occur and is internal to the remirror codebase.",[U.MISSING_REQUIRED_EXTENSION]:"Your editor is missing a required extension.",[U.MANAGER_PHASE_ERROR]:"This occurs when accessing a method or property before it is available.",[U.INVALID_GET_EXTENSION]:"The user requested an invalid extension from the getExtensions method. Please check the `createExtensions` return method is returning an extension with the defined constructor.",[U.INVALID_MANAGER_ARGUMENTS]:"Invalid value(s) passed into `Manager` constructor. Only `Presets` and `Extensions` are supported.",[U.SCHEMA]:"There is a problem with the schema or you are trying to access a node / mark that doesn't exists.",[U.HELPERS_CALLED_IN_OUTER_SCOPE]:"The `helpers` method which is passed into the ``create*` method should only be called within returned method since it relies on an active view (not present in the outer scope).",[U.INVALID_MANAGER_EXTENSION]:"You requested an invalid extension from the manager.",[U.DUPLICATE_COMMAND_NAMES]:"Command method names must be unique within the editor.",[U.DUPLICATE_HELPER_NAMES]:"Helper method names must be unique within the editor.",[U.NON_CHAINABLE_COMMAND]:"Attempted to chain a non chainable command.",[U.INVALID_EXTENSION]:"The provided extension is invalid.",[U.INVALID_CONTENT]:"The content provided to the editor is not supported.",[U.INVALID_NAME]:"An invalid name was used for the extension.",[U.EXTENSION]:"An error occurred within an extension. More details should be made available.",[U.EXTENSION_SPEC]:"The spec was defined without calling the `defaults`, `parse` or `dom` methods.",[U.EXTENSION_EXTRA_ATTRIBUTES]:"Extra attributes must either be a string or an object.",[U.INVALID_SET_EXTENSION_OPTIONS]:"A call to `extension.setOptions` was made with invalid keys.",[U.REACT_PROVIDER_CONTEXT]:"`useRemirrorContext` was called outside of the `remirror` context. It can only be used within an active remirror context created by the ``.",[U.REACT_GET_ROOT_PROPS]:"`getRootProps` has been attached to the DOM more than once. It should only be attached to the dom once per editor.",[U.REACT_EDITOR_VIEW]:"A problem occurred adding the editor view to the dom.",[U.REACT_CONTROLLED]:"There is a problem with your controlled editor setup.",[U.REACT_NODE_VIEW]:"Something went wrong with your custom ReactNodeView Component.",[U.REACT_GET_CONTEXT]:"You attempted to call `getContext` provided by the `useRemirror` prop during the first render of the editor. This is not possible and should only be after the editor first mounts.",[U.REACT_COMPONENTS]:"An error occurred within a remirror component.",[U.REACT_HOOKS]:"An error occurred within a remirror hook.",[U.I18N_CONTEXT]:"You called `useI18n()` outside of an `I18nProvider` context."};function J4(e){return oe(e)&&wr(Wh(U),e)}function Q4(e,t){const r=Z4[e],n=r?`${r}
+ */var Q4=J_,J4=function(e,n){if(!Q4(e)&&typeof e!="function")return{};var r={};if(typeof n=="string")return n in e&&(r[n]=e[n]),r;for(var o=n.length,i=-1;++i{let d=a.prefixes[c]||"",h=u;return n===!1&&(r&&(h=h.normalize("NFD").replace(new RegExp(`[^a-zA-ZØßø0-9${r.join("")}]`,"g"),"")),r||(h=h.normalize("NFD").replace(/[^a-zA-ZØßø0-9]/g,""),d="")),r&&(d=d.replace(new RegExp(`[^${r.join("")}]`,"g"),"")),c===0?d+h:!d&&!h?"":s&&!d&&o.match(/\s/)?" "+h:(d||o)+h}).filter(Boolean)}function nD(t){const e=t.matchAll(eR).next().value,n=e?e.index:0;return t.slice(0,n+1).toUpperCase()+t.slice(n+1).toLowerCase()}function nR(t,e){return tR(t,e).reduce((n,r)=>n+nD(r),"")}function tS(t,e){return tR(t,{...e,prefix:"-"}).join("").toLowerCase()}function d0(t,e,n,r){var o,i=!1,s=0;function l(){o&&clearTimeout(o)}function a(){l(),i=!0}typeof e!="boolean"&&(r=n,n=e,e=void 0);function u(){for(var c=arguments.length,d=new Array(c),h=0;ht?g():e!==!0&&(o=setTimeout(r?m:g,r===void 0?t-p:t))}return u.cancel=a,u}function rR(t,e,n){return n===void 0?d0(t,e,!1):d0(t,n,e!==!1)}function Ot(t,e,n){const r=t[e];return oR(!om(r),n),r}function oR(t,e){if(!t)throw new rD(e)}var rD=class extends Z_.BaseError{constructor(){super(...arguments),this.name="AssertionError"}};function cn(t){return Object.entries(t)}function Bd(t){return Object.keys(t)}function rm(t){return Object.values(t)}function sr(t,e,n){return t.includes(e,n)}function be(t){return Object.assign(Object.create(null),t)}function iR(t){return Object.prototype.toString.call(t)}function sR(t){return iR(t).slice(8,-1)}function Dh(t,e){return n=>typeof n!==t?!1:e?e(n):!0}function db(t){return e=>sR(e)===t}var om=Dh("undefined"),ke=Dh("string"),Yr=Dh("number",t=>!Number.isNaN(t)),tt=Dh("function");function oD(t){return t===null}function h0(t){return t===!0||t===!1}function Zs(t){if(sR(t)!=="Object")return!1;const e=Object.getPrototypeOf(t);return e===null||e===Object.getPrototypeOf({})}function iD(t){return t==null||/^[bns]/.test(typeof t)}function Fs(t){return oD(t)||om(t)}function Dn(t){return!Fs(t)&&(tt(t)||Dh("object")(t))}var sD=db("RegExp");function aD(t){return db("Map")(t)}function lD(t){return db("Set")(t)}function Pp(t){return Dn(t)&&!aD(t)&&!lD(t)&&Object.keys(t).length===0}var Bt=Array.isArray;function Bs(t){return Bt(t)&&t.length===0}function nS(t){return Bt(t)&&t.length>0}function cD(t){return t.charAt(0).toUpperCase()+t.slice(1)}function su(t,e,n=r=>!!r){e.lastIndex=0;const r=[],o=e.flags;let i;o.includes("g")||(e=new RegExp(e.source,`g${o}`));do i=e.exec(t),i&&r.push(i);while(n(i));return e.lastIndex=0,r}function zp(){const t=Date.now(),e=zp.last||t;return zp.last=t>e?t:e+1}zp.last=0;function Rc(t=""){return`${t}${zp().toString(36)}`}function aR(t){return ub(t,e=>!om(e))}function uD(t){if(!Zs(t))throw new Error("An invalid value was passed into this clone utility. Expected a plain object");return{...t}}var lR=j4;function Mc(t,e=!1){const n=e?[...t].reverse():t,r=new Set(n);return e?[...r].reverse():[...r]}function cR(t){const e=[];for(const n of t){const r=Bt(n)?cR(n):[n];e.push(...r)}return e}function uR(){}function dR(...t){return W4.all(t,{isMergeableObject:Zs})}function dD({min:t,max:e,value:n}){return ne?e:n}function hD(t){return t[t.length-1]}function Ka(t,e){return[...t].map((n,r)=>({value:n,index:r})).sort((n,r)=>e(n.value,r.value)||n.index-r.index).map(({value:n})=>n)}function fD(t,e,n){try{if(ke(e)&&e in t)return t[e];Bt(e)&&(e=`['${e.join("']['")}']`);let r=t;return e.replace(/\[\s*(["'])(.*?)\1\s*]|^\s*(\w+)\s*(?=\.|\[|$)|\.\s*(\w*)\s*(?=\.|\[|$)|\[\s*(-?\d+)\s*]/g,(o,i,s,l,a,u)=>(r=r[s||l||a||u],"")),r===void 0?n:r}catch{return n}}function pD(t,e){const n=uD(e);let r=n;for(const[o,i]of t.entries()){const s=o>=t.length-1;let l=r[i];if(s){if(Bt(r)){const a=Number.parseInt(i.toString(),10);Yr(a)&&r.splice(a,1)}else Reflect.deleteProperty(r,i);return n}if(iD(l))return n;l=Bt(l)?[...l]:{...l},r[i]=l,r=l}return n}function gD(t){return e=>fD(e,t)}function hb(t,e,n=!1){const r=[],o=new Set,i=tt(e)?e:gD(e),s=n?[...t].reverse():t;for(const l of s){const a=i(l);o.has(a)||(o.add(a),r.push(l))}return n?r.reverse():r}function fb(t,e){const n=Bt(t)?t[0]:t;return Yr(e)?n<=e?Array.from({length:e+1-n},(r,o)=>o+n):Array.from({length:n+1-e},(r,o)=>-1*o+n):Array.from({length:Math.abs(n)},(r,o)=>(n<0?-1:1)*o)}function rS(t,...e){const n=e.filter(Yr);return t>=Math.min(...n)&&t<=Math.max(...n)}function hR(t){return tt(t)?t():t}var fR="https://remirror.io/docs/errors",mD={[re.UNKNOWN]:"An error occurred but we're not quite sure why. 🧐",[re.INVALID_COMMAND_ARGUMENTS]:"The arguments passed to the command method were invalid.",[re.CUSTOM]:"This is a custom error, possibly thrown by an external library.",[re.CORE_HELPERS]:"An error occurred in a function called from the `@remirror/core-helpers` library.",[re.MUTATION]:"Mutation of immutable value detected.",[re.INTERNAL]:"This is an error which should not occur and is internal to the remirror codebase.",[re.MISSING_REQUIRED_EXTENSION]:"Your editor is missing a required extension.",[re.MANAGER_PHASE_ERROR]:"This occurs when accessing a method or property before it is available.",[re.INVALID_GET_EXTENSION]:"The user requested an invalid extension from the getExtensions method. Please check the `createExtensions` return method is returning an extension with the defined constructor.",[re.INVALID_MANAGER_ARGUMENTS]:"Invalid value(s) passed into `Manager` constructor. Only `Presets` and `Extensions` are supported.",[re.SCHEMA]:"There is a problem with the schema or you are trying to access a node / mark that doesn't exists.",[re.HELPERS_CALLED_IN_OUTER_SCOPE]:"The `helpers` method which is passed into the ``create*` method should only be called within returned method since it relies on an active view (not present in the outer scope).",[re.INVALID_MANAGER_EXTENSION]:"You requested an invalid extension from the manager.",[re.DUPLICATE_COMMAND_NAMES]:"Command method names must be unique within the editor.",[re.DUPLICATE_HELPER_NAMES]:"Helper method names must be unique within the editor.",[re.NON_CHAINABLE_COMMAND]:"Attempted to chain a non chainable command.",[re.INVALID_EXTENSION]:"The provided extension is invalid.",[re.INVALID_CONTENT]:"The content provided to the editor is not supported.",[re.INVALID_NAME]:"An invalid name was used for the extension.",[re.EXTENSION]:"An error occurred within an extension. More details should be made available.",[re.EXTENSION_SPEC]:"The spec was defined without calling the `defaults`, `parse` or `dom` methods.",[re.EXTENSION_EXTRA_ATTRIBUTES]:"Extra attributes must either be a string or an object.",[re.INVALID_SET_EXTENSION_OPTIONS]:"A call to `extension.setOptions` was made with invalid keys.",[re.REACT_PROVIDER_CONTEXT]:"`useRemirrorContext` was called outside of the `remirror` context. It can only be used within an active remirror context created by the ``.",[re.REACT_GET_ROOT_PROPS]:"`getRootProps` has been attached to the DOM more than once. It should only be attached to the dom once per editor.",[re.REACT_EDITOR_VIEW]:"A problem occurred adding the editor view to the dom.",[re.REACT_CONTROLLED]:"There is a problem with your controlled editor setup.",[re.REACT_NODE_VIEW]:"Something went wrong with your custom ReactNodeView Component.",[re.REACT_GET_CONTEXT]:"You attempted to call `getContext` provided by the `useRemirror` prop during the first render of the editor. This is not possible and should only be after the editor first mounts.",[re.REACT_COMPONENTS]:"An error occurred within a remirror component.",[re.REACT_HOOKS]:"An error occurred within a remirror hook.",[re.I18N_CONTEXT]:"You called `useI18n()` outside of an `I18nProvider` context."};function vD(t){return ke(t)&&sr(rm(re),t)}function yD(t,e){const n=mD[t],r=n?`${n}
-`:"",o=t?`${t}
+`:"",o=e?`${e}
-`:"";return`${n}${o}For more information visit ${NC}#${e.toLowerCase()}`}var RC=class extends fC.BaseError{constructor({code:e,message:t,disableLogging:r=!1}={}){const n=J4(e)?e:U.CUSTOM;super(Q4(n,t)),this.errorCode=n,this.url=`${NC}#${n.toLowerCase()}`,r||console.error(this.message)}static create(e={}){return new RC(e)}};function re(e,t){if(!e)throw RC.create(t)}function Yh(e){if(typeof e!="object"||e===null)return e;const t=Symbol.toStringTag in e&&e[Symbol.toStringTag]==="Module"?e.default??e:e;return t&&typeof e=="object"&&"__esModule"in t&&t.__esModule&&t.default!==void 0?t.default:t}function Vs(e,t={}){return e}function Zt(e){this.content=e}Zt.prototype={constructor:Zt,find:function(e){for(var t=0;t>1}};Zt.from=function(e){if(e instanceof Zt)return e;var t=[];if(e)for(var r in e)t.push(r,e[r]);return new Zt(t)};function _C(e,t,r){for(let n=0;;n++){if(n==e.childCount||n==t.childCount)return e.childCount==t.childCount?null:r;let o=e.child(n),i=t.child(n);if(o==i){r+=o.nodeSize;continue}if(!o.sameMarkup(i))return r;if(o.isText&&o.text!=i.text){for(let s=0;o.text[s]==i.text[s];s++)r++;return r}if(o.content.size||i.content.size){let s=_C(o.content,i.content,r+1);if(s!=null)return s}r+=o.nodeSize}}function IC(e,t,r,n){for(let o=e.childCount,i=t.childCount;;){if(o==0||i==0)return o==i?null:{a:r,b:n};let s=e.child(--o),a=t.child(--i),l=s.nodeSize;if(s==a){r-=l,n-=l;continue}if(!s.sameMarkup(a))return{a:r,b:n};if(s.isText&&s.text!=a.text){let c=0,u=Math.min(s.text.length,a.text.length);for(;ct&&n(l,o+a,i||null,s)!==!1&&l.content.size){let u=a+1;l.nodesBetween(Math.max(0,t-u),Math.min(l.content.size,r-u),n,o+u)}a=c}}descendants(t){this.nodesBetween(0,this.size,t)}textBetween(t,r,n,o){let i="",s=!0;return this.nodesBetween(t,r,(a,l)=>{a.isText?(i+=a.text.slice(Math.max(t,l)-l,r-l),s=!n):a.isLeaf?(o?i+=typeof o=="function"?o(a):o:a.type.spec.leafText&&(i+=a.type.spec.leafText(a)),s=!n):!s&&a.isBlock&&(i+=n,s=!0)},0),i}append(t){if(!t.size)return this;if(!this.size)return t;let r=this.lastChild,n=t.firstChild,o=this.content.slice(),i=0;for(r.isText&&r.sameMarkup(n)&&(o[o.length-1]=r.withText(r.text+n.text),i=1);it)for(let i=0,s=0;st&&((sr)&&(a.isText?a=a.cut(Math.max(0,t-s),Math.min(a.text.length,r-s)):a=a.cut(Math.max(0,t-s-1),Math.min(a.content.size,r-s-1))),n.push(a),o+=a.nodeSize),s=l}return new I(n,o)}cutByIndex(t,r){return t==r?I.empty:t==0&&r==this.content.length?this:new I(this.content.slice(t,r))}replaceChild(t,r){let n=this.content[t];if(n==r)return this;let o=this.content.slice(),i=this.size+r.nodeSize-n.nodeSize;return o[t]=r,new I(o,i)}addToStart(t){return new I([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new I(this.content.concat(t),this.size+t.nodeSize)}eq(t){if(this.content.length!=t.content.length)return!1;for(let r=0;rthis.size||t<0)throw new RangeError(`Position ${t} outside of fragment (${this})`);for(let n=0,o=0;;n++){let i=this.child(n),s=o+i.nodeSize;if(s>=t)return s==t||r>0?hp(n+1,s):hp(n,o);o=s}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(t=>t.toJSON()):null}static fromJSON(t,r){if(!r)return I.empty;if(!Array.isArray(r))throw new RangeError("Invalid input for Fragment.fromJSON");return new I(r.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return I.empty;let r,n=0;for(let o=0;othis.type.rank&&(r||(r=t.slice(0,o)),r.push(this),n=!0),r&&r.push(i)}}return r||(r=t.slice()),n||r.push(this),r}removeFromSet(t){for(let r=0;rn.type.rank-o.type.rank),r}}Ne.none=[];class _f extends Error{}class W{constructor(t,r,n){this.content=t,this.openStart=r,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(t,r){let n=LC(this.content,t+this.openStart,r);return n&&new W(n,this.openStart,this.openEnd)}removeBetween(t,r){return new W(MC(this.content,t+this.openStart,r+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,r){if(!r)return W.empty;let n=r.openStart||0,o=r.openEnd||0;if(typeof n!="number"||typeof o!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new W(I.fromJSON(t,r.content),n,o)}static maxOpen(t,r=!0){let n=0,o=0;for(let i=t.firstChild;i&&!i.isLeaf&&(r||!i.type.spec.isolating);i=i.firstChild)n++;for(let i=t.lastChild;i&&!i.isLeaf&&(r||!i.type.spec.isolating);i=i.lastChild)o++;return new W(t,n,o)}}W.empty=new W(I.empty,0,0);function MC(e,t,r){let{index:n,offset:o}=e.findIndex(t),i=e.maybeChild(n),{index:s,offset:a}=e.findIndex(r);if(o==t||i.isText){if(a!=r&&!e.child(s).isText)throw new RangeError("Removing non-flat range");return e.cut(0,t).append(e.cut(r))}if(n!=s)throw new RangeError("Removing non-flat range");return e.replaceChild(n,i.copy(MC(i.content,t-o-1,r-o-1)))}function LC(e,t,r,n){let{index:o,offset:i}=e.findIndex(t),s=e.maybeChild(o);if(i==t||s.isText)return n&&!n.canReplace(o,o,r)?null:e.cut(0,t).append(r).append(e.cut(t));let a=LC(s.content,t-i-1,r);return a&&e.replaceChild(o,s.copy(a))}function eL(e,t,r){if(r.openStart>e.depth)throw new _f("Inserted content deeper than insertion position");if(e.depth-r.openStart!=t.depth-r.openEnd)throw new _f("Inconsistent open depths");return DC(e,t,r,0)}function DC(e,t,r,n){let o=e.index(n),i=e.node(n);if(o==t.index(n)&&n=0&&e.isText&&e.sameMarkup(t[r])?t[r]=e.withText(t[r].text+e.text):t.push(e)}function Su(e,t,r,n){let o=(t||e).node(r),i=0,s=t?t.index(r):o.childCount;e&&(i=e.index(r),e.depth>r?i++:e.textOffset&&(Js(e.nodeAfter,n),i++));for(let a=i;ao&&j1(e,t,o+1),s=n.depth>o&&j1(r,n,o+1),a=[];return Su(null,e,o,a),i&&s&&t.index(o)==r.index(o)?(PC(i,s),Js(Qs(i,zC(e,t,r,n,o+1)),a)):(i&&Js(Qs(i,If(e,t,o+1)),a),Su(t,r,o,a),s&&Js(Qs(s,If(r,n,o+1)),a)),Su(n,null,o,a),new I(a)}function If(e,t,r){let n=[];if(Su(null,e,r,n),e.depth>r){let o=j1(e,t,r+1);Js(Qs(o,If(e,t,r+1)),n)}return Su(t,null,r,n),new I(n)}function tL(e,t){let r=t.depth-e.openStart,o=t.node(r).copy(e.content);for(let i=r-1;i>=0;i--)o=t.node(i).copy(I.from(o));return{start:o.resolveNoCache(e.openStart+r),end:o.resolveNoCache(o.content.size-e.openEnd-r)}}class Dl{constructor(t,r,n){this.pos=t,this.path=r,this.parentOffset=n,this.depth=r.length/3-1}resolveDepth(t){return t==null?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[this.resolveDepth(t)*3]}index(t){return this.path[this.resolveDepth(t)*3+1]}indexAfter(t){return t=this.resolveDepth(t),this.index(t)+(t==this.depth&&!this.textOffset?0:1)}start(t){return t=this.resolveDepth(t),t==0?0:this.path[t*3-1]+1}end(t){return t=this.resolveDepth(t),this.start(t)+this.node(t).content.size}before(t){if(t=this.resolveDepth(t),!t)throw new RangeError("There is no position before the top-level node");return t==this.depth+1?this.pos:this.path[t*3-1]}after(t){if(t=this.resolveDepth(t),!t)throw new RangeError("There is no position after the top-level node");return t==this.depth+1?this.pos:this.path[t*3-1]+this.path[t*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let t=this.parent,r=this.index(this.depth);if(r==t.childCount)return null;let n=this.pos-this.path[this.path.length-1],o=t.child(r);return n?t.child(r).cut(n):o}get nodeBefore(){let t=this.index(this.depth),r=this.pos-this.path[this.path.length-1];return r?this.parent.child(t).cut(0,r):t==0?null:this.parent.child(t-1)}posAtIndex(t,r){r=this.resolveDepth(r);let n=this.path[r*3],o=r==0?0:this.path[r*3-1]+1;for(let i=0;i0;r--)if(this.start(r)<=t&&this.end(r)>=t)return r;return 0}blockRange(t=this,r){if(t.pos=0;n--)if(t.pos<=this.end(n)&&(!r||r(this.node(n))))return new sa(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=0&&r<=t.content.size))throw new RangeError("Position "+r+" out of range");let n=[],o=0,i=r;for(let s=t;;){let{index:a,offset:l}=s.content.findIndex(i),c=i-l;if(n.push(s,a,o+l),!c||(s=s.child(a),s.isText))break;i=c-1,o+=l+1}return new Dl(r,n,i)}static resolveCached(t,r){for(let o=0;ot&&this.nodesBetween(t,r,i=>(n.isInSet(i.marks)&&(o=!0),!o)),o}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let t=this.type.name;return this.content.size&&(t+="("+this.content.toStringInner()+")"),$C(this.marks,t)}contentMatchAt(t){let r=this.type.contentMatch.matchFragment(this.content,0,t);if(!r)throw new Error("Called contentMatchAt on a node with invalid content");return r}canReplace(t,r,n=I.empty,o=0,i=n.childCount){let s=this.contentMatchAt(t).matchFragment(n,o,i),a=s&&s.matchFragment(this.content,r);if(!a||!a.validEnd)return!1;for(let l=o;lr.type.name)}`);this.content.forEach(r=>r.check())}toJSON(){let t={type:this.type.name};for(let r 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(r=>r.toJSON())),t}static fromJSON(t,r){if(!r)throw new RangeError("Invalid input for Node.fromJSON");let n=null;if(r.marks){if(!Array.isArray(r.marks))throw new RangeError("Invalid mark data for Node.fromJSON");n=r.marks.map(t.markFromJSON)}if(r.type=="text"){if(typeof r.text!="string")throw new RangeError("Invalid text node in JSON");return t.text(r.text,n)}let o=I.fromJSON(t,r.content);return t.nodeType(r.type).create(r.attrs,o,n)}};ji.prototype.text=void 0;class Mf extends ji{constructor(t,r,n,o){if(super(t,r,null,o),!n)throw new RangeError("Empty text nodes are not allowed");this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):$C(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(t,r){return this.text.slice(t,r)}get nodeSize(){return this.text.length}mark(t){return t==this.marks?this:new Mf(this.type,this.attrs,this.text,t)}withText(t){return t==this.text?this:new Mf(this.type,this.attrs,t,this.marks)}cut(t=0,r=this.text.length){return t==0&&r==this.text.length?this:this.withText(this.text.slice(t,r))}eq(t){return this.sameMarkup(t)&&this.text==t.text}toJSON(){let t=super.toJSON();return t.text=this.text,t}}function $C(e,t){for(let r=e.length-1;r>=0;r--)t=e[r].type.name+"("+t+")";return t}class aa{constructor(t){this.validEnd=t,this.next=[],this.wrapCache=[]}static parse(t,r){let n=new oL(t,r);if(n.next==null)return aa.empty;let o=BC(n);n.next&&n.err("Unexpected trailing text");let i=dL(uL(o));return pL(i,n),i}matchType(t){for(let r=0;rc.createAndFill()));for(let c=0;c=this.next.length)throw new RangeError(`There's no ${t}th edge in this content match`);return this.next[t]}toString(){let t=[];function r(n){t.push(n);for(let o=0;o{let i=o+(n.validEnd?"*":" ")+" ";for(let s=0;s"+t.indexOf(n.next[s].next);return i}).join(`
-`)}}aa.empty=new aa(!0);class oL{constructor(t,r){this.string=t,this.nodeTypes=r,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 BC(e){let t=[];do t.push(iL(e));while(e.eat("|"));return t.length==1?t[0]:{type:"choice",exprs:t}}function iL(e){let t=[];do t.push(sL(e));while(e.next&&e.next!=")"&&e.next!="|");return t.length==1?t[0]:{type:"seq",exprs:t}}function sL(e){let t=cL(e);for(;;)if(e.eat("+"))t={type:"plus",expr:t};else if(e.eat("*"))t={type:"star",expr:t};else if(e.eat("?"))t={type:"opt",expr:t};else if(e.eat("{"))t=aL(e,t);else break;return t}function Nx(e){/\D/.test(e.next)&&e.err("Expected number, got '"+e.next+"'");let t=Number(e.next);return e.pos++,t}function aL(e,t){let r=Nx(e),n=r;return e.eat(",")&&(e.next!="}"?n=Nx(e):n=-1),e.eat("}")||e.err("Unclosed braced range"),{type:"range",min:r,max:n,expr:t}}function lL(e,t){let r=e.nodeTypes,n=r[t];if(n)return[n];let o=[];for(let i in r){let s=r[i];s.groups.indexOf(t)>-1&&o.push(s)}return o.length==0&&e.err("No node type or group '"+t+"' found"),o}function cL(e){if(e.eat("(")){let t=BC(e);return e.eat(")")||e.err("Missing closing paren"),t}else if(/\W/.test(e.next))e.err("Unexpected token '"+e.next+"'");else{let t=lL(e,e.next).map(r=>(e.inline==null?e.inline=r.isInline:e.inline!=r.isInline&&e.err("Mixing inline and block content"),{type:"name",value:r}));return e.pos++,t.length==1?t[0]:{type:"choice",exprs:t}}}function uL(e){let t=[[]];return o(i(e,0),r()),t;function r(){return t.push([])-1}function n(s,a,l){let c={term:l,to:a};return t[s].push(c),c}function o(s,a){s.forEach(l=>l.to=a)}function i(s,a){if(s.type=="choice")return s.exprs.reduce((l,c)=>l.concat(i(c,a)),[]);if(s.type=="seq")for(let l=0;;l++){let c=i(s.exprs[l],a);if(l==s.exprs.length-1)return c;o(c,a=r())}else if(s.type=="star"){let l=r();return n(a,l),o(i(s.expr,l),l),[n(l)]}else if(s.type=="plus"){let l=r();return o(i(s.expr,a),l),o(i(s.expr,l),l),[n(l)]}else{if(s.type=="opt")return[n(a)].concat(i(s.expr,a));if(s.type=="range"){let l=a;for(let c=0;c{e[s].forEach(({term:a,to:l})=>{if(!a)return;let c;for(let u=0;u{c||o.push([a,c=[]]),c.indexOf(u)==-1&&c.push(u)})})});let i=t[n.join(",")]=new aa(n.indexOf(e.length-1)>-1);for(let s=0;s-1}allowsMarks(t){if(this.markSet==null)return!0;for(let r=0;rn[i]=new jC(i,r,s));let o=r.spec.topNode||"doc";if(!n[o])throw new RangeError("Schema is missing its top node type ('"+o+"')");if(!n.text)throw new RangeError("Every schema needs a 'text' type");for(let i in n.text.attrs)throw new RangeError("The text node type should not have attributes");return n}};class fL{constructor(t){this.hasDefault=Object.prototype.hasOwnProperty.call(t,"default"),this.default=t.default}get isRequired(){return!this.hasDefault}}class Bd{constructor(t,r,n,o){this.name=t,this.rank=r,this.schema=n,this.spec=o,this.attrs=VC(o.attrs),this.excluded=null;let i=FC(this.attrs);this.instance=i?new Ne(this,i):null}create(t=null){return!t&&this.instance?this.instance:new Ne(this,UC(this.attrs,t))}static compile(t,r){let n=Object.create(null),o=0;return t.forEach((i,s)=>n[i]=new Bd(i,o++,r,s)),n}removeFromSet(t){for(var r=0;r-1}}let hL=class{constructor(t){this.cached=Object.create(null);let r=this.spec={};for(let o in t)r[o]=t[o];r.nodes=Zt.from(t.nodes),r.marks=Zt.from(t.marks||{}),this.nodes=W1.compile(this.spec.nodes,this),this.marks=Bd.compile(this.spec.marks,this);let n=Object.create(null);for(let o in this.nodes){if(o in this.marks)throw new RangeError(o+" can not be both a node and a mark");let i=this.nodes[o],s=i.spec.content||"",a=i.spec.marks;i.contentMatch=n[s]||(n[s]=aa.parse(s,this.nodes)),i.inlineContent=i.contentMatch.inlineContent,i.markSet=a=="_"?null:a?_x(this,a.split(" ")):a==""||!i.inlineContent?[]:null}for(let o in this.marks){let i=this.marks[o],s=i.spec.excludes;i.excluded=s==null?[i]:s==""?[]:_x(this,s.split(" "))}this.nodeFromJSON=this.nodeFromJSON.bind(this),this.markFromJSON=this.markFromJSON.bind(this),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(t,r=null,n,o){if(typeof t=="string")t=this.nodeType(t);else if(t instanceof W1){if(t.schema!=this)throw new RangeError("Node type from different schema used ("+t.name+")")}else throw new RangeError("Invalid node type: "+t);return t.createChecked(r,n,o)}text(t,r){let n=this.nodes.text;return new Mf(n,n.defaultAttrs,t,Ne.setFrom(r))}mark(t,r){return typeof t=="string"&&(t=this.marks[t]),t.create(r)}nodeFromJSON(t){return ji.fromJSON(this,t)}markFromJSON(t){return Ne.fromJSON(this,t)}nodeType(t){let r=this.nodes[t];if(!r)throw new RangeError("Unknown node type: "+t);return r}};function _x(e,t){let r=[];for(let n=0;n-1)&&r.push(s=l)}if(!s)throw new SyntaxError("Unknown mark type: '"+t[n]+"'")}return r}let Vy=class K1{constructor(t,r){this.schema=t,this.rules=r,this.tags=[],this.styles=[],r.forEach(n=>{n.tag?this.tags.push(n):n.style&&this.styles.push(n)}),this.normalizeLists=!this.tags.some(n=>{if(!/^(ul|ol)\b/.test(n.tag)||!n.node)return!1;let o=t.nodes[n.node];return o.contentMatch.matchType(o)})}parse(t,r={}){let n=new Mx(this,r,!1);return n.addAll(t,r.from,r.to),n.finish()}parseSlice(t,r={}){let n=new Mx(this,r,!0);return n.addAll(t,r.from,r.to),W.maxOpen(n.finish())}matchTag(t,r,n){for(let o=n?this.tags.indexOf(n)+1:0;ot.length&&(a.charCodeAt(t.length)!=61||a.slice(t.length+1)!=r))){if(s.getAttrs){let l=s.getAttrs(r);if(l===!1)continue;s.attrs=l||void 0}return s}}}static schemaRules(t){let r=[];function n(o){let i=o.priority==null?50:o.priority,s=0;for(;s{n(s=Lx(s)),s.mark||s.ignore||s.clearMark||(s.mark=o)})}for(let o in t.nodes){let i=t.nodes[o].spec.parseDOM;i&&i.forEach(s=>{n(s=Lx(s)),s.node||s.ignore||s.mark||(s.node=o)})}return r}static fromSchema(t){return t.cached.domParser||(t.cached.domParser=new K1(t,K1.schemaRules(t)))}};const GC={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},mL={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},WC={ol:!0,ul:!0},Lf=1,Df=2,wu=4;function Ix(e,t,r){return t!=null?(t?Lf:0)|(t==="full"?Df:0):e&&e.whitespace=="pre"?Lf|Df:r&~wu}class mp{constructor(t,r,n,o,i,s,a){this.type=t,this.attrs=r,this.marks=n,this.pendingMarks=o,this.solid=i,this.options=a,this.content=[],this.activeMarks=Ne.none,this.stashMarks=[],this.match=s||(a&wu?null:t.contentMatch)}findWrapping(t){if(!this.match){if(!this.type)return[];let r=this.type.contentMatch.fillBefore(I.from(t));if(r)this.match=this.type.contentMatch.matchFragment(r);else{let n=this.type.contentMatch,o;return(o=n.findWrapping(t.type))?(this.match=n,o):null}}return this.match.findWrapping(t.type)}finish(t){if(!(this.options&Lf)){let n=this.content[this.content.length-1],o;if(n&&n.isText&&(o=/[ \t\r\n\u000c]+$/.exec(n.text))){let i=n;n.text.length==o[0].length?this.content.pop():this.content[this.content.length-1]=i.withText(i.text.slice(0,i.text.length-o[0].length))}}let r=I.from(this.content);return!t&&this.match&&(r=r.append(this.match.fillBefore(I.empty,!0))),this.type?this.type.create(this.attrs,r,this.marks):r}popFromStashMark(t){for(let r=this.stashMarks.length-1;r>=0;r--)if(t.eq(this.stashMarks[r]))return this.stashMarks.splice(r,1)[0]}applyPending(t){for(let r=0,n=this.pendingMarks;rthis.addAll(t)),s&&this.sync(a),this.needsBlock=l}else this.withStyleRules(t,()=>{this.addElementByRule(t,i,i.consuming===!1?o:void 0)})}leafFallback(t){t.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(t.ownerDocument.createTextNode(`
-`))}ignoreFallback(t){t.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"))}readStyles(t){let r=Ne.none,n=Ne.none;for(let o=0;o{s.clearMark(a)&&(n=a.addToSet(n))}):r=this.parser.schema.marks[s.mark].create(s.attrs).addToSet(r),s.consuming===!1)i=s;else break}return[r,n]}addElementByRule(t,r,n){let o,i,s;r.node?(i=this.parser.schema.nodes[r.node],i.isLeaf?this.insertNode(i.create(r.attrs))||this.leafFallback(t):o=this.enter(i,r.attrs||null,r.preserveWhitespace)):(s=this.parser.schema.marks[r.mark].create(r.attrs),this.addPendingMark(s));let a=this.top;if(i&&i.isLeaf)this.findInside(t);else if(n)this.addElement(t,n);else if(r.getContent)this.findInside(t),r.getContent(t,this.parser.schema).forEach(l=>this.insertNode(l));else{let l=t;typeof r.contentElement=="string"?l=t.querySelector(r.contentElement):typeof r.contentElement=="function"?l=r.contentElement(t):r.contentElement&&(l=r.contentElement),this.findAround(t,l,!0),this.addAll(l)}o&&this.sync(a)&&this.open--,s&&this.removePendingMark(s,a)}addAll(t,r,n){let o=r||0;for(let i=r?t.childNodes[r]:t.firstChild,s=n==null?null:t.childNodes[n];i!=s;i=i.nextSibling,++o)this.findAtPoint(t,o),this.addDOM(i);this.findAtPoint(t,o)}findPlace(t){let r,n;for(let o=this.open;o>=0;o--){let i=this.nodes[o],s=i.findWrapping(t);if(s&&(!r||r.length>s.length)&&(r=s,n=i,!s.length)||i.solid)break}if(!r)return!1;this.sync(n);for(let o=0;othis.open){for(;r>this.open;r--)this.nodes[r-1].content.push(this.nodes[r].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 r=this.open;r>=0;r--)if(this.nodes[r]==t)return this.open=r,!0;return!1}get currentPos(){this.closeExtra();let t=0;for(let r=this.open;r>=0;r--){let n=this.nodes[r].content;for(let o=n.length-1;o>=0;o--)t+=n[o].nodeSize;r&&t++}return t}findAtPoint(t,r){if(this.find)for(let n=0;n-1)return t.split(/\s*\|\s*/).some(this.matchesContext,this);let r=t.split("/"),n=this.options.context,o=!this.isOpen&&(!n||n.parent.type==this.nodes[0].type),i=-(n?n.depth+1:0)+(o?0:1),s=(a,l)=>{for(;a>=0;a--){let c=r[a];if(c==""){if(a==r.length-1||a==0)continue;for(;l>=i;l--)if(s(a-1,l))return!0;return!1}else{let u=l>0||l==0&&o?this.nodes[l].type:n&&l>=i?n.node(l-i).type:null;if(!u||u.name!=c&&u.groups.indexOf(c)==-1)return!1;l--}}return!0};return s(r.length-1,this.open)}textblockFromContext(){let t=this.options.context;if(t)for(let r=t.depth;r>=0;r--){let n=t.node(r).contentMatchAt(t.indexAfter(r)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(let r in this.parser.schema.nodes){let n=this.parser.schema.nodes[r];if(n.isTextblock&&n.defaultAttrs)return n}}addPendingMark(t){let r=EL(t,this.top.pendingMarks);r&&this.top.stashMarks.push(r),this.top.pendingMarks=t.addToSet(this.top.pendingMarks)}removePendingMark(t,r){for(let n=this.open;n>=0;n--){let o=this.nodes[n];if(o.pendingMarks.lastIndexOf(t)>-1)o.pendingMarks=t.removeFromSet(o.pendingMarks);else{o.activeMarks=t.removeFromSet(o.activeMarks);let s=o.popFromStashMark(t);s&&o.type&&o.type.allowsMarkType(s.type)&&(o.activeMarks=s.addToSet(o.activeMarks))}if(o==r)break}}}function gL(e){for(let t=e.firstChild,r=null;t;t=t.nextSibling){let n=t.nodeType==1?t.nodeName.toLowerCase():null;n&&WC.hasOwnProperty(n)&&r?(r.appendChild(t),t=r):n=="li"?r=t:n&&(r=null)}}function yL(e,t){return(e.matches||e.msMatchesSelector||e.webkitMatchesSelector||e.mozMatchesSelector).call(e,t)}function vL(e){let t=/\s*([\w-]+)\s*:\s*([^;]+)/g,r,n=[];for(;r=t.exec(e);)n.push(r[1],r[2].trim());return n}function Lx(e){let t={};for(let r in e)t[r]=e[r];return t}function bL(e,t){let r=t.schema.nodes;for(let n in r){let o=r[n];if(!o.allowsMarkType(e))continue;let i=[],s=a=>{i.push(a);for(let l=0;l{if(i.length||s.marks.length){let a=0,l=0;for(;a=0;o--){let i=this.serializeMark(t.marks[o],t.isInline,r);i&&((i.contentDOM||i.dom).appendChild(n),n=i.dom)}return n}serializeMark(t,r,n={}){let o=this.marks[t.type.name];return o&&un.renderSpec(Og(n),o(t,r))}static renderSpec(t,r,n=null){if(typeof r=="string")return{dom:t.createTextNode(r)};if(r.nodeType!=null)return{dom:r};if(r.dom&&r.dom.nodeType!=null)return r;let o=r[0],i=o.indexOf(" ");i>0&&(n=o.slice(0,i),o=o.slice(i+1));let s,a=n?t.createElementNS(n,o):t.createElement(o),l=r[1],c=1;if(l&&typeof l=="object"&&l.nodeType==null&&!Array.isArray(l)){c=2;for(let u in l)if(l[u]!=null){let d=u.indexOf(" ");d>0?a.setAttributeNS(u.slice(0,d),u.slice(d+1),l[u]):a.setAttribute(u,l[u])}}for(let u=c;uc)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}else{let{dom:p,contentDOM:f}=un.renderSpec(t,d,n);if(a.appendChild(p),f){if(s)throw new RangeError("Multiple content holes");s=f}}}return{dom:a,contentDOM:s}}static fromSchema(t){return t.cached.domSerializer||(t.cached.domSerializer=new un(this.nodesFromSchema(t),this.marksFromSchema(t)))}static nodesFromSchema(t){let r=Dx(t.nodes);return r.text||(r.text=n=>n.text),r}static marksFromSchema(t){return Dx(t.marks)}}function Dx(e){let t={};for(let r in e){let n=e[r].spec.toDOM;n&&(t[r]=n)}return t}function Og(e){return e.document||window.document}const KC=65535,YC=Math.pow(2,16);function kL(e,t){return e+t*YC}function Px(e){return e&KC}function xL(e){return(e-(e&KC))/YC}const qC=1,XC=2,Yp=4,ZC=8;class Y1{constructor(t,r,n){this.pos=t,this.delInfo=r,this.recover=n}get deleted(){return(this.delInfo&ZC)>0}get deletedBefore(){return(this.delInfo&(qC|Yp))>0}get deletedAfter(){return(this.delInfo&(XC|Yp))>0}get deletedAcross(){return(this.delInfo&Yp)>0}}class an{constructor(t,r=!1){if(this.ranges=t,this.inverted=r,!t.length&&an.empty)return an.empty}recover(t){let r=0,n=Px(t);if(!this.inverted)for(let o=0;ot)break;let c=this.ranges[a+i],u=this.ranges[a+s],d=l+c;if(t<=d){let p=c?t==l?-1:t==d?1:r:r,f=l+o+(p<0?0:u);if(n)return f;let h=t==(r<0?l:d)?null:kL(a/3,t-l),m=t==l?XC:t==d?qC:Yp;return(r<0?t!=l:t!=d)&&(m|=ZC),new Y1(f,m,h)}o+=u-c}return n?t+o:new Y1(t+o,0,null)}touches(t,r){let n=0,o=Px(r),i=this.inverted?2:1,s=this.inverted?1:2;for(let a=0;at)break;let c=this.ranges[a+i],u=l+c;if(t<=u&&a==o*3)return!0;n+=this.ranges[a+s]-c}return!1}forEach(t){let r=this.inverted?2:1,n=this.inverted?1:2;for(let o=0,i=0;o=0;r--){let o=t.getMirror(r);this.appendMap(t.maps[r].invert(),o!=null&&o>r?n-o-1:void 0)}}invert(){let t=new vl;return t.appendMappingInverted(this),t}map(t,r=1){if(this.mirror)return this._map(t,r,!0);for(let n=this.from;ni&&l!s.isAtom||!a.type.allowsMarkType(this.mark.type)?s:s.mark(this.mark.addToSet(s.marks)),o),r.openStart,r.openEnd);return xt.fromReplace(t,this.from,this.to,i)}invert(){return new oo(this.from,this.to,this.mark)}map(t){let r=t.mapResult(this.from,1),n=t.mapResult(this.to,-1);return r.deleted&&n.deleted||r.pos>=n.pos?null:new Jo(r.pos,n.pos,this.mark)}merge(t){return t instanceof Jo&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new Jo(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,r){if(typeof r.from!="number"||typeof r.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new Jo(r.from,r.to,t.markFromJSON(r.mark))}}zt.jsonID("addMark",Jo);class oo extends zt{constructor(t,r,n){super(),this.from=t,this.to=r,this.mark=n}apply(t){let r=t.slice(this.from,this.to),n=new W(jy(r.content,o=>o.mark(this.mark.removeFromSet(o.marks)),t),r.openStart,r.openEnd);return xt.fromReplace(t,this.from,this.to,n)}invert(){return new Jo(this.from,this.to,this.mark)}map(t){let r=t.mapResult(this.from,1),n=t.mapResult(this.to,-1);return r.deleted&&n.deleted||r.pos>=n.pos?null:new oo(r.pos,n.pos,this.mark)}merge(t){return t instanceof oo&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new oo(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,r){if(typeof r.from!="number"||typeof r.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new oo(r.from,r.to,t.markFromJSON(r.mark))}}zt.jsonID("removeMark",oo);class Bi extends zt{constructor(t,r){super(),this.pos=t,this.mark=r}apply(t){let r=t.nodeAt(this.pos);if(!r)return xt.fail("No node at mark step's position");let n=r.type.create(r.attrs,null,this.mark.addToSet(r.marks));return xt.fromReplace(t,this.pos,this.pos+1,new W(I.from(n),0,r.isLeaf?0:1))}invert(t){let r=t.nodeAt(this.pos);if(r){let n=this.mark.addToSet(r.marks);if(n.length==r.marks.length){for(let o=0;on.pos?null:new St(r.pos,n.pos,o,i,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,r){if(typeof r.from!="number"||typeof r.to!="number"||typeof r.gapFrom!="number"||typeof r.gapTo!="number"||typeof r.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new St(r.from,r.to,r.gapFrom,r.gapTo,W.fromJSON(t,r.slice),r.insert,!!r.structure)}}zt.jsonID("replaceAround",St);function q1(e,t,r){let n=e.resolve(t),o=r-t,i=n.depth;for(;o>0&&i>0&&n.indexAfter(i)==n.node(i).childCount;)i--,o--;if(o>0){let s=n.node(i).maybeChild(n.indexAfter(i));for(;o>0;){if(!s||s.isLeaf)return!0;s=s.firstChild,o--}}return!1}function SL(e,t,r,n){let o=[],i=[],s,a;e.doc.nodesBetween(t,r,(l,c,u)=>{if(!l.isInline)return;let d=l.marks;if(!n.isInSet(d)&&u.type.allowsMarkType(n.type)){let p=Math.max(c,t),f=Math.min(c+l.nodeSize,r),h=n.addToSet(d);for(let m=0;me.step(l)),i.forEach(l=>e.step(l))}function wL(e,t,r,n){let o=[],i=0;e.doc.nodesBetween(t,r,(s,a)=>{if(!s.isInline)return;i++;let l=null;if(n instanceof Bd){let c=s.marks,u;for(;u=n.isInSet(c);)(l||(l=[])).push(u),c=u.removeFromSet(c)}else n?n.isInSet(s.marks)&&(l=[n]):l=s.marks;if(l&&l.length){let c=Math.min(a+s.nodeSize,r);for(let u=0;ue.step(new oo(s.from,s.to,s.style)))}function TL(e,t,r,n=r.contentMatch){let o=e.doc.nodeAt(t),i=[],s=t+1;for(let a=0;a=0;a--)e.step(i[a])}function CL(e,t,r){return(t==0||e.canReplace(t,e.childCount))&&(r==e.childCount||e.canReplace(0,r))}function uc(e){let r=e.parent.content.cutByIndex(e.startIndex,e.endIndex);for(let n=e.depth;;--n){let o=e.$from.node(n),i=e.$from.index(n),s=e.$to.indexAfter(n);if(nr;h--)m||n.index(h)>0?(m=!0,u=I.from(n.node(h).copy(u)),d++):l--;let p=I.empty,f=0;for(let h=i,m=!1;h>r;h--)m||o.after(h+1)=0;s--){if(n.size){let a=r[s].type.contentMatch.matchFragment(n);if(!a||!a.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}n=I.from(r[s].type.create(r[s].attrs,n))}let o=t.start,i=t.end;e.step(new St(o,i,o,i,new W(n,0,0),r.length,!0))}function _L(e,t,r,n,o){if(!n.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let i=e.steps.length;e.doc.nodesBetween(t,r,(s,a)=>{if(s.isTextblock&&!s.hasMarkup(n,o)&&IL(e.doc,e.mapping.slice(i).map(a),n)){e.clearIncompatible(e.mapping.slice(i).map(a,1),n);let l=e.mapping.slice(i),c=l.map(a,1),u=l.map(a+s.nodeSize,1);return e.step(new St(c,u,c+1,u-1,new W(I.from(n.create(o,null,s.marks)),0,0),1,!0)),!1}})}function IL(e,t,r){let n=e.resolve(t),o=n.index();return n.parent.canReplaceWith(o,o+1,r)}function ML(e,t,r,n,o){let i=e.doc.nodeAt(t);if(!i)throw new RangeError("No node at given position");r||(r=i.type);let s=r.create(n,null,o||i.marks);if(i.isLeaf)return e.replaceWith(t,t+i.nodeSize,s);if(!r.validContent(i.content))throw new RangeError("Invalid content for node type "+r.name);e.step(new St(t,t+i.nodeSize,t+1,t+i.nodeSize-1,new W(I.from(s),0,0),1,!0))}function bl(e,t,r=1,n){let o=e.resolve(t),i=o.depth-r,s=n&&n[n.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 c=o.depth-1,u=r-2;c>i;c--,u--){let d=o.node(c),p=o.index(c);if(d.type.spec.isolating)return!1;let f=d.content.cutByIndex(p,d.childCount),h=n&&n[u+1];h&&(f=f.replaceChild(0,h.type.create(h.attrs)));let m=n&&n[u]||d;if(!d.canReplace(p+1,d.childCount)||!m.type.validContent(f))return!1}let a=o.indexAfter(i),l=n&&n[0];return o.node(i).canReplaceWith(a,a,l?l.type:o.node(i+1).type)}function LL(e,t,r=1,n){let o=e.doc.resolve(t),i=I.empty,s=I.empty;for(let a=o.depth,l=o.depth-r,c=r-1;a>l;a--,c--){i=I.from(o.node(a).copy(i));let u=n&&n[c];s=I.from(u?u.type.create(u.attrs,s):o.node(a).copy(s))}e.step(new Ut(t,t,new W(i.append(s),r,r),!0))}function Hd(e,t){let r=e.resolve(t),n=r.index();return DL(r.nodeBefore,r.nodeAfter)&&r.parent.canReplace(n,n+1)}function DL(e,t){return!!(e&&t&&!e.isLeaf&&e.canAppend(t))}function PL(e,t,r){let n=new Ut(t-r,t+r,W.empty,!0);e.step(n)}function JC(e,t,r){let n=e.resolve(t);if(n.parent.canReplaceWith(n.index(),n.index(),r))return t;if(n.parentOffset==0)for(let o=n.depth-1;o>=0;o--){let i=n.index(o);if(n.node(o).canReplaceWith(i,i,r))return n.before(o+1);if(i>0)return null}if(n.parentOffset==n.parent.content.size)for(let o=n.depth-1;o>=0;o--){let i=n.indexAfter(o);if(n.node(o).canReplaceWith(i,i,r))return n.after(o+1);if(i=0;s--){let a=s==n.depth?0:n.pos<=(n.start(s+1)+n.end(s+1))/2?-1:1,l=n.index(s)+(a>0?1:0),c=n.node(s),u=!1;if(i==1)u=c.canReplace(l,l,o);else{let d=c.contentMatchAt(l).findWrapping(o.firstChild.type);u=d&&c.canReplaceWith(l,l,d[0])}if(u)return a==0?n.pos:a<0?n.before(s+1):n.after(s+1)}return null}function Wy(e,t,r=t,n=W.empty){if(t==r&&!n.size)return null;let o=e.resolve(t),i=e.resolve(r);return QC(o,i,n)?new Ut(t,r,n):new $L(o,i,n).fit()}function QC(e,t,r){return!r.openStart&&!r.openEnd&&e.start()==t.start()&&e.parent.canReplace(e.index(),t.index(),r.content)}class $L{constructor(t,r,n){this.$from=t,this.$to=r,this.unplaced=n,this.frontier=[],this.placed=I.empty;for(let o=0;o<=t.depth;o++){let i=t.node(o);this.frontier.push({type:i.type,match:i.contentMatchAt(t.indexAfter(o))})}for(let o=t.depth;o>0;o--)this.placed=I.from(t.node(o).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let c=this.findFittable();c?this.placeNodes(c):this.openMore()||this.dropNode()}let t=this.mustMoveInline(),r=this.placed.size-this.depth-this.$from.depth,n=this.$from,o=this.close(t<0?this.$to:n.doc.resolve(t));if(!o)return null;let i=this.placed,s=n.depth,a=o.depth;for(;s&&a&&i.childCount==1;)i=i.firstChild.content,s--,a--;let l=new W(i,s,a);return t>-1?new St(n.pos,t,this.$to.pos,this.$to.end(),l,r):l.size||n.pos!=this.$to.pos?new Ut(n.pos,o.pos,l):null}findFittable(){let t=this.unplaced.openStart;for(let r=this.unplaced.content,n=0,o=this.unplaced.openEnd;n1&&(o=0),i.type.spec.isolating&&o<=n){t=n;break}r=i.content}for(let r=1;r<=2;r++)for(let n=r==1?t:this.unplaced.openStart;n>=0;n--){let o,i=null;n?(i=Ng(this.unplaced.content,n-1).firstChild,o=i.content):o=this.unplaced.content;let s=o.firstChild;for(let a=this.depth;a>=0;a--){let{type:l,match:c}=this.frontier[a],u,d=null;if(r==1&&(s?c.matchType(s.type)||(d=c.fillBefore(I.from(s),!1)):i&&l.compatibleContent(i.type)))return{sliceDepth:n,frontierDepth:a,parent:i,inject:d};if(r==2&&s&&(u=c.findWrapping(s.type)))return{sliceDepth:n,frontierDepth:a,parent:i,wrap:u};if(i&&c.matchType(i.type))break}}}openMore(){let{content:t,openStart:r,openEnd:n}=this.unplaced,o=Ng(t,r);return!o.childCount||o.firstChild.isLeaf?!1:(this.unplaced=new W(t,r+1,Math.max(n,o.size+r>=t.size-n?r+1:0)),!0)}dropNode(){let{content:t,openStart:r,openEnd:n}=this.unplaced,o=Ng(t,r);if(o.childCount<=1&&r>0){let i=t.size-r<=r+o.size;this.unplaced=new W(Uc(t,r-1,1),r-1,i?r-1:n)}else this.unplaced=new W(Uc(t,r,1),r,n)}placeNodes({sliceDepth:t,frontierDepth:r,parent:n,inject:o,wrap:i}){for(;this.depth>r;)this.closeFrontierNode();if(i)for(let m=0;m1||l==0||m.content.size)&&(d=b,u.push(eO(m.mark(p.allowedMarks(m.marks)),c==1?l:0,c==a.childCount?f:-1)))}let h=c==a.childCount;h||(f=-1),this.placed=Vc(this.placed,r,I.from(u)),this.frontier[r].match=d,h&&f<0&&n&&n.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let m=0,b=a;m1&&o==this.$to.end(--n);)++o;return o}findCloseLevel(t){e:for(let r=Math.min(this.depth,t.depth);r>=0;r--){let{match:n,type:o}=this.frontier[r],i=r=0;a--){let{match:l,type:c}=this.frontier[a],u=Rg(t,a,c,l,!0);if(!u||u.childCount)continue e}return{depth:r,fit:s,move:i?t.doc.resolve(t.after(r+1)):t}}}}close(t){let r=this.findCloseLevel(t);if(!r)return null;for(;this.depth>r.depth;)this.closeFrontierNode();r.fit.childCount&&(this.placed=Vc(this.placed,r.depth,r.fit)),t=r.move;for(let n=r.depth+1;n<=t.depth;n++){let o=t.node(n),i=o.type.contentMatch.fillBefore(o.content,!0,t.index(n));this.openFrontierNode(o.type,o.attrs,i)}return t}openFrontierNode(t,r=null,n){let o=this.frontier[this.depth];o.match=o.match.matchType(t),this.placed=Vc(this.placed,this.depth,I.from(t.create(r,n))),this.frontier.push({type:t,match:t.contentMatch})}closeFrontierNode(){let r=this.frontier.pop().match.fillBefore(I.empty,!0);r.childCount&&(this.placed=Vc(this.placed,this.frontier.length,r))}}function Uc(e,t,r){return t==0?e.cutByIndex(r,e.childCount):e.replaceChild(0,e.firstChild.copy(Uc(e.firstChild.content,t-1,r)))}function Vc(e,t,r){return t==0?e.append(r):e.replaceChild(e.childCount-1,e.lastChild.copy(Vc(e.lastChild.content,t-1,r)))}function Ng(e,t){for(let r=0;r1&&(n=n.replaceChild(0,eO(n.firstChild,t-1,n.childCount==1?r-1:0))),t>0&&(n=e.type.contentMatch.fillBefore(n).append(n),r<=0&&(n=n.append(e.type.contentMatch.matchFragment(n).fillBefore(I.empty,!0)))),e.copy(n)}function Rg(e,t,r,n,o){let i=e.node(t),s=o?e.indexAfter(t):e.index(t);if(s==i.childCount&&!r.compatibleContent(i.type))return null;let a=n.fillBefore(i.content,!0,s);return a&&!BL(r,i.content,s)?a:null}function BL(e,t,r){for(let n=r;n0;p--,f--){let h=o.node(p).type.spec;if(h.defining||h.definingAsContext||h.isolating)break;s.indexOf(p)>-1?a=p:o.before(p)==f&&s.splice(1,0,-p)}let l=s.indexOf(a),c=[],u=n.openStart;for(let p=n.content,f=0;;f++){let h=p.firstChild;if(c.push(h),f==n.openStart)break;p=h.content}for(let p=u-1;p>=0;p--){let f=c[p],h=HL(f.type);if(h&&!f.sameMarkup(o.node(Math.abs(a)-1)))u=p;else if(h||!f.type.isTextblock)break}for(let p=n.openStart;p>=0;p--){let f=(p+u+1)%(n.openStart+1),h=c[f];if(h)for(let m=0;m=0&&(e.replace(t,r,n),!(e.steps.length>d));p--){let f=s[p];f<0||(t=o.before(f),r=i.after(f))}}function tO(e,t,r,n,o){if(tn){let i=o.contentMatchAt(0),s=i.fillBefore(e).append(e);e=s.append(i.matchFragment(s).fillBefore(I.empty,!0))}return e}function UL(e,t,r,n){if(!n.isInline&&t==r&&e.doc.resolve(t).parent.content.size){let o=JC(e.doc,t,n.type);o!=null&&(t=r=o)}e.replaceRange(t,r,new W(I.from(n),0,0))}function VL(e,t,r){let n=e.doc.resolve(t),o=e.doc.resolve(r),i=rO(n,o);for(let s=0;s0&&(l||n.node(a-1).canReplace(n.index(a-1),o.indexAfter(a-1))))return e.delete(n.before(a),o.after(a))}for(let s=1;s<=n.depth&&s<=o.depth;s++)if(t-n.start(s)==n.depth-s&&r>n.end(s)&&o.end(s)-r!=o.depth-s)return e.delete(n.before(s),r);e.delete(t,r)}function rO(e,t){let r=[],n=Math.min(e.depth,t.depth);for(let o=n;o>=0;o--){let i=e.start(o);if(it.pos+(t.depth-o)||e.node(o).type.spec.isolating||t.node(o).type.spec.isolating)break;(i==t.start(o)||o==e.depth&&o==t.depth&&e.parent.inlineContent&&t.parent.inlineContent&&o&&t.start(o-1)==i-1)&&r.push(o)}return r}class El extends zt{constructor(t,r,n){super(),this.pos=t,this.attr=r,this.value=n}apply(t){let r=t.nodeAt(this.pos);if(!r)return xt.fail("No node at attribute step's position");let n=Object.create(null);for(let i in r.attrs)n[i]=r.attrs[i];n[this.attr]=this.value;let o=r.type.create(n,null,r.marks);return xt.fromReplace(t,this.pos,this.pos+1,new W(I.from(o),0,r.isLeaf?0:1))}getMap(){return an.empty}invert(t){return new El(this.pos,this.attr,t.nodeAt(this.pos).attrs[this.attr])}map(t){let r=t.mapResult(this.pos,1);return r.deletedAfter?null:new El(r.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(t,r){if(typeof r.pos!="number"||typeof r.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new El(r.pos,r.attr,r.value)}}zt.jsonID("attr",El);class ju extends zt{constructor(t,r){super(),this.attr=t,this.value=r}apply(t){let r=Object.create(null);for(let o in t.attrs)r[o]=t.attrs[o];r[this.attr]=this.value;let n=t.type.create(r,t.content,t.marks);return xt.ok(n)}getMap(){return an.empty}invert(t){return new ju(this.attr,t.attrs[this.attr])}map(t){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(t,r){if(typeof r.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new ju(r.attr,r.value)}}zt.jsonID("docAttr",ju);let zl=class extends Error{};zl=function e(t){let r=Error.call(this,t);return r.__proto__=e.prototype,r};zl.prototype=Object.create(Error.prototype);zl.prototype.constructor=zl;zl.prototype.name="TransformError";class jL{constructor(t){this.doc=t,this.steps=[],this.docs=[],this.mapping=new vl}get before(){return this.docs.length?this.docs[0]:this.doc}step(t){let r=this.maybeStep(t);if(r.failed)throw new zl(r.failed);return this}maybeStep(t){let r=t.apply(this.doc);return r.failed||this.addStep(t,r.doc),r}get docChanged(){return this.steps.length>0}addStep(t,r){this.docs.push(this.doc),this.steps.push(t),this.mapping.appendMap(t.getMap()),this.doc=r}replace(t,r=t,n=W.empty){let o=Wy(this.doc,t,r,n);return o&&this.step(o),this}replaceWith(t,r,n){return this.replace(t,r,new W(I.from(n),0,0))}delete(t,r){return this.replace(t,r,W.empty)}insert(t,r){return this.replaceWith(t,t,r)}replaceRange(t,r,n){return FL(this,t,r,n),this}replaceRangeWith(t,r,n){return UL(this,t,r,n),this}deleteRange(t,r){return VL(this,t,r),this}lift(t,r){return OL(this,t,r),this}join(t,r=1){return PL(this,t,r),this}wrap(t,r){return RL(this,t,r),this}setBlockType(t,r=t,n,o=null){return _L(this,t,r,n,o),this}setNodeMarkup(t,r,n=null,o){return ML(this,t,r,n,o),this}setNodeAttribute(t,r,n){return this.step(new El(t,r,n)),this}setDocAttribute(t,r){return this.step(new ju(t,r)),this}addNodeMark(t,r){return this.step(new Bi(t,r)),this}removeNodeMark(t,r){if(!(r instanceof Ne)){let n=this.doc.nodeAt(t);if(!n)throw new RangeError("No node at position "+t);if(r=r.isInSet(n.marks),!r)return this}return this.step(new Pl(t,r)),this}split(t,r=1,n){return LL(this,t,r,n),this}addMark(t,r,n){return SL(this,t,r,n),this}removeMark(t,r,n){return wL(this,t,r,n),this}clearIncompatible(t,r,n){return TL(this,t,r,n),this}}const _g=Object.create(null);class ke{constructor(t,r,n){this.$anchor=t,this.$head=r,this.ranges=n||[new GL(t.min(r),t.max(r))]}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 r=0;r=0;i--){let s=r<0?qa(t.node(0),t.node(i),t.before(i+1),t.index(i),r,n):qa(t.node(0),t.node(i),t.after(i+1),t.index(i)+1,r,n);if(s)return s}return null}static near(t,r=1){return this.findFrom(t,r)||this.findFrom(t,-r)||new xr(t.node(0))}static atStart(t){return qa(t,t,0,0,1)||new xr(t)}static atEnd(t){return qa(t,t,t.content.size,t.childCount,-1)||new xr(t)}static fromJSON(t,r){if(!r||!r.type)throw new RangeError("Invalid input for Selection.fromJSON");let n=_g[r.type];if(!n)throw new RangeError(`No selection type ${r.type} defined`);return n.fromJSON(t,r)}static jsonID(t,r){if(t in _g)throw new RangeError("Duplicate use of selection JSON ID "+t);return _g[t]=r,r.prototype.jsonID=t,r}getBookmark(){return ue.between(this.$anchor,this.$head).getBookmark()}}ke.prototype.visible=!0;class GL{constructor(t,r){this.$from=t,this.$to=r}}let $x=!1;function Bx(e){!$x&&!e.parent.inlineContent&&($x=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+e.parent.type.name+")"))}class ue extends ke{constructor(t,r=t){Bx(t),Bx(r),super(t,r)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(t,r){let n=t.resolve(r.map(this.head));if(!n.parent.inlineContent)return ke.near(n);let o=t.resolve(r.map(this.anchor));return new ue(o.parent.inlineContent?o:n,n)}replace(t,r=W.empty){if(super.replace(t,r),r==W.empty){let n=this.$from.marksAcross(this.$to);n&&t.ensureMarks(n)}}eq(t){return t instanceof ue&&t.anchor==this.anchor&&t.head==this.head}getBookmark(){return new qh(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(t,r){if(typeof r.anchor!="number"||typeof r.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new ue(t.resolve(r.anchor),t.resolve(r.head))}static create(t,r,n=r){let o=t.resolve(r);return new this(o,n==r?o:t.resolve(n))}static between(t,r,n){let o=t.pos-r.pos;if((!n||o)&&(n=o>=0?1:-1),!r.parent.inlineContent){let i=ke.findFrom(r,n,!0)||ke.findFrom(r,-n,!0);if(i)r=i.$head;else return ke.near(r,n)}return t.parent.inlineContent||(o==0?t=r:(t=(ke.findFrom(t,-n,!0)||ke.findFrom(t,n,!0)).$anchor,t.pos0?0:1);o>0?s=0;s+=o){let a=t.child(s);if(a.isAtom){if(!i&&de.isSelectable(a))return de.create(e,r-(o<0?a.nodeSize:0))}else{let l=qa(e,a,r+o,o<0?a.childCount:0,o,i);if(l)return l}r+=a.nodeSize*o}return null}function Hx(e,t,r){let n=e.steps.length-1;if(n{s==null&&(s=u)}),e.setSelection(ke.near(e.doc.resolve(s),r))}const Fx=1,gp=2,Ux=4;class KL extends jL{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.curSelectionFor0}setStoredMarks(t){return this.storedMarks=t,this.updated|=gp,this}ensureMarks(t){return Ne.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(this.updated&gp)>0}addStep(t,r){super.addStep(t,r),this.updated=this.updated&~gp,this.storedMarks=null}setTime(t){return this.time=t,this}replaceSelection(t){return this.selection.replace(this,t),this}replaceSelectionWith(t,r=!0){let n=this.selection;return r&&(t=t.mark(this.storedMarks||(n.empty?n.$from.marks():n.$from.marksAcross(n.$to)||Ne.none))),n.replaceWith(this,t),this}deleteSelection(){return this.selection.replace(this),this}insertText(t,r,n){let o=this.doc.type.schema;if(r==null)return t?this.replaceSelectionWith(o.text(t),!0):this.deleteSelection();{if(n==null&&(n=r),n=n??r,!t)return this.deleteRange(r,n);let i=this.storedMarks;if(!i){let s=this.doc.resolve(r);i=n==r?s.marks():s.marksAcross(this.doc.resolve(n))}return this.replaceRangeWith(r,n,o.text(t,i)),this.selection.empty||this.setSelection(ke.near(this.selection.$to)),this}}setMeta(t,r){return this.meta[typeof t=="string"?t:t.key]=r,this}getMeta(t){return this.meta[typeof t=="string"?t:t.key]}get isGeneric(){for(let t in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=Ux,this}get scrolledIntoView(){return(this.updated&Ux)>0}}function Vx(e,t){return!t||!e?e:e.bind(t)}class jc{constructor(t,r,n){this.name=t,this.init=Vx(r.init,n),this.apply=Vx(r.apply,n)}}const YL=[new jc("doc",{init(e){return e.doc||e.schema.topNodeType.createAndFill()},apply(e){return e.doc}}),new jc("selection",{init(e,t){return e.selection||ke.atStart(t.doc)},apply(e){return e.selection}}),new jc("storedMarks",{init(e){return e.storedMarks||null},apply(e,t,r,n){return n.selection.$cursor?e.storedMarks:null}}),new jc("scrollToSelection",{init(){return 0},apply(e,t){return e.scrolledIntoView?t+1:t}})];class Ig{constructor(t,r){this.schema=t,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=YL.slice(),r&&r.forEach(n=>{if(this.pluginsByKey[n.key])throw new RangeError("Adding different instances of a keyed plugin ("+n.key+")");this.plugins.push(n),this.pluginsByKey[n.key]=n,n.spec.state&&this.fields.push(new jc(n.key,n.spec.state,n))})}}class js{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,r=-1){for(let n=0;nn.toJSON())),t&&typeof t=="object")for(let n in t){if(n=="doc"||n=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let o=t[n],i=o.spec.state;i&&i.toJSON&&(r[n]=i.toJSON.call(o,this[o.key]))}return r}static fromJSON(t,r,n){if(!r)throw new RangeError("Invalid input for EditorState.fromJSON");if(!t.schema)throw new RangeError("Required config field 'schema' missing");let o=new Ig(t.schema,t.plugins),i=new js(o);return o.fields.forEach(s=>{if(s.name=="doc")i.doc=ji.fromJSON(t.schema,r.doc);else if(s.name=="selection")i.selection=ke.fromJSON(i.doc,r.selection);else if(s.name=="storedMarks")r.storedMarks&&(i.storedMarks=r.storedMarks.map(t.schema.markFromJSON));else{if(n)for(let a in n){let l=n[a],c=l.spec.state;if(l.key==s.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(r,a)){i[s.name]=c.fromJSON.call(l,t,r[a],i);return}}i[s.name]=s.init(t,i)}}),i}}function nO(e,t,r){for(let n in e){let o=e[n];o instanceof Function?o=o.bind(t):n=="handleDOMEvents"&&(o=nO(o,t,{})),r[n]=o}return r}class Po{constructor(t){this.spec=t,this.props={},t.props&&nO(t.props,this,this.props),this.key=t.key?t.key.key:oO("plugin")}getState(t){return t[this.key]}}const Mg=Object.create(null);function oO(e){return e in Mg?e+"$"+ ++Mg[e]:(Mg[e]=0,e+"$")}class Ca{constructor(t="key"){this.key=oO(t)}get(t){return t.config.pluginsByKey[this.key]}getState(t){return t[this.key]}}var qL=/[A-Z]/g,XL=/^ms-/,Lg={};function ZL(e){return"-"+e.toLowerCase()}function JL(e){if(Lg.hasOwnProperty(e))return Lg[e];var t=e.replace(qL,ZL);return Lg[e]=XL.test(t)?"-"+t:t}function QL(e){return JL(e)}function e5(e,t){return QL(e)+":"+t}function t5(e){var t="";for(var r in e){var n=e[r];typeof n!="string"&&typeof n!="number"||(t&&(t+=";"),t+=e5(r,n))}return t}function r5(){return typeof document<"u"?document:null}var iO=r5;function sO(e,t){if(typeof e!="string")return[e];var r=[e];typeof t=="string"||Array.isArray(t)?t={brackets:t}:t||(t={});var n=t.brackets?Array.isArray(t.brackets)?t.brackets:[t.brackets]:["{}","[]","()"],o=t.escape||"___",i=!!t.flat;n.forEach(function(l){var c=new RegExp(["\\",l[0],"[^\\",l[0],"\\",l[1],"]*\\",l[1]].join("")),u=[];function d(p,f,h){var m=r.push(p.slice(l[0].length,-l[1].length))-1;return u.push(m),o+m+o}r.forEach(function(p,f){for(var h,m=0;p!=h;)if(h=p,p=p.replace(c,d),m++>1e4)throw Error("References have circular dependency. Please, check them.");r[f]=p}),u=u.reverse(),r=r.map(function(p){return u.forEach(function(f){p=p.replace(new RegExp("(\\"+o+f+"\\"+o+")","g"),l[0]+"$1"+l[1])}),p})});var s=new RegExp("\\"+o+"([0-9]+)\\"+o);function a(l,c,u){for(var d=[],p,f=0;p=s.exec(l);){if(f++>1e4)throw Error("Circular references in parenthesis");d.push(l.slice(0,p.index)),d.push(a(c[p[1]],c)),l=l.slice(p.index+p[0].length)}return d.push(l),d}return i?r:a(r[0],r)}function aO(e,t){if(t&&t.flat){var r=t&&t.escape||"___",n=e[0],o;if(!n)return"";for(var i=new RegExp("\\"+r+"([0-9]+)\\"+r),s=0;n!=o;){if(s++>1e4)throw Error("Circular references in "+e);o=n,n=n.replace(i,a)}return n}return e.reduce(function l(c,u){return Array.isArray(u)&&(u=u.reduce(l,"")),c+u},"");function a(l,c){if(e[c]==null)throw Error("Reference "+c+"is undefined");return e[c]}}function lO(e,t){return Array.isArray(e)?aO(e,t):sO(e,t)}lO.parse=sO;lO.stringify=aO;const n5={id:"extension.command.copy.label",message:"Copy",comment:"Label for copy command."},o5={id:"extension.command.copy.description",message:"Copy the selected text",comment:"Description for copy command."},i5={id:"extension.command.cut.label",message:"Cut",comment:"Label for cut command."},s5={id:"extension.command.cut.description",message:"Cut the selected text",comment:"Description for cut command."},a5={id:"extension.command.paste.label",message:"Paste",comment:"Label for paste command."},l5={id:"extension.command.paste.description",message:"Paste content into the editor",comment:"Description for paste command."},c5={id:"extension.command.select-all.label",message:"Select all",comment:"Label for select all command."},u5={id:"extension.command.select-all.description",message:"Select all content within the editor",comment:"Description for select all command."};var ss=Object.freeze({__proto__:null,COPY_DESCRIPTION:o5,COPY_LABEL:n5,CUT_DESCRIPTION:s5,CUT_LABEL:i5,PASTE_DESCRIPTION:l5,PASTE_LABEL:a5,SELECT_ALL_DESCRIPTION:u5,SELECT_ALL_LABEL:c5});const d5={id:"keyboard.shortcut.escape",message:"Enter",comment:"Label for escape key in shortcuts."},p5={id:"keyboard.shortcut.command",message:"Command",comment:"Label for command key in shortcuts."},f5={id:"keyboard.shortcut.control",message:"Control",comment:"Label for control key in shortcuts."},h5={id:"keyboard.shortcut.enter",message:"Enter",comment:"Label for enter key in shortcuts."},m5={id:"keyboard.shortcut.shift",message:"Shift",comment:"Label for shift key in shortcuts."},g5={id:"keyboard.shortcut.alt",message:"Alt",comment:"Label for alt key in shortcuts."},y5={id:"keyboard.shortcut.capsLock",message:"Caps Lock",comment:"Label for caps lock key in shortcuts."},v5={id:"keyboard.shortcut.backspace",message:"Backspace",comment:"Label for backspace key in shortcuts."},b5={id:"keyboard.shortcut.tab",message:"Tab",comment:"Label for tab key in shortcuts."},E5={id:"keyboard.shortcut.space",message:"Space",comment:"Label for space key in shortcuts."},k5={id:"keyboard.shortcut.delete",message:"Delete",comment:"Label for delete key in shortcuts."},x5={id:"keyboard.shortcut.pageUp",message:"Page Up",comment:"Label for page up key in shortcuts."},S5={id:"keyboard.shortcut.pageDown",message:"Page Down",comment:"Label for page down key in shortcuts."},w5={id:"keyboard.shortcut.home",message:"Home",comment:"Label for home key in shortcuts."},T5={id:"keyboard.shortcut.end",message:"End",comment:"Label for end key in shortcuts."},C5={id:"keyboard.shortcut.arrowLeft",message:"Arrow Left",comment:"Label for arrow left key in shortcuts."},O5={id:"keyboard.shortcut.arrowRight",message:"Arrow Right",comment:"Label for arrow right key in shortcuts."},A5={id:"keyboard.shortcut.arrowUp",message:"Arrow Up",comment:"Label for arrow up key in shortcuts."},N5={id:"keyboard.shortcut.arrowDown",message:"Arrow Down",comment:"Label for arrowDown key in shortcuts."};var _t=Object.freeze({__proto__:null,ALT_KEY:g5,ARROW_DOWN_KEY:N5,ARROW_LEFT_KEY:C5,ARROW_RIGHT_KEY:O5,ARROW_UP_KEY:A5,BACKSPACE_KEY:v5,CAPS_LOCK_KEY:y5,COMMAND_KEY:p5,CONTROL_KEY:f5,DELETE_KEY:k5,END_KEY:T5,ENTER_KEY:h5,ESCAPE_KEY:d5,HOME_KEY:w5,PAGE_DOWN_KEY:S5,PAGE_UP_KEY:x5,SHIFT_KEY:m5,SPACE_KEY:E5,TAB_KEY:b5});const R5={id:"extension.command.toggle-blockquote.label",message:"Blockquote",comment:"Label for blockquote formatting command."},_5={id:"extension.command.toggle-blockquote.description",message:"Add blockquote formatting to the selected text",comment:"Description for blockquote formatting command."};var jx=Object.freeze({__proto__:null,DESCRIPTION:_5,LABEL:R5});const I5={id:"extension.command.toggle-bold.label",message:"Bold",comment:"Label for bold formatting command."},M5={id:"extension.command.toggle-bold.description",message:"Add bold formatting to the selected text",comment:"Description for bold formatting command."};var Gx=Object.freeze({__proto__:null,DESCRIPTION:M5,LABEL:I5});const L5={id:"extension.command.toggle-code-block.label",message:"Codeblock",comment:"Label for the code block command."},D5={id:"extension.command.toggle-code-block.description",message:"Add a code block",comment:"Description for the code block command."};var P5=Object.freeze({__proto__:null,DESCRIPTION:D5,LABEL:L5});const z5={id:"extension.command.toggle-code.label",message:"Code",comment:"Label for the inline code formatting."},$5={id:"extension.command.toggle-code.description",message:"Add inline code formatting to the selected text",comment:"Description for the inline code formatting command."};var B5=Object.freeze({__proto__:null,DESCRIPTION:$5,LABEL:z5});const H5={id:"extension.command.toggle-heading.label",message:`{level, select, 1 {Heading 1}
+`:"";return`${r}${o}For more information visit ${fR}#${t.toLowerCase()}`}var pR=class extends Z_.BaseError{constructor({code:t,message:e,disableLogging:n=!1}={}){const r=vD(t)?t:re.CUSTOM;super(yD(r,e)),this.errorCode=r,this.url=`${fR}#${r.toLowerCase()}`,n||console.error(this.message)}static create(t={}){return new pR(t)}};function we(t,e){if(!t)throw pR.create(e)}function im(t){if(typeof t!="object"||t===null)return t;const e=Symbol.toStringTag in t&&t[Symbol.toStringTag]==="Module"?t.default??t:t;return e&&typeof t=="object"&&"__esModule"in e&&e.__esModule&&e.default!==void 0?e.default:e}function Oa(t,e={}){return t}function Mn(t){this.content=t}Mn.prototype={constructor:Mn,find:function(t){for(var e=0;e>1}};Mn.from=function(t){if(t instanceof Mn)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new Mn(e)};function gR(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){n+=o.nodeSize;continue}if(!o.sameMarkup(i))return n;if(o.isText&&o.text!=i.text){for(let s=0;o.text[s]==i.text[s];s++)n++;return n}if(o.content.size||i.content.size){let s=gR(o.content,i.content,n+1);if(s!=null)return s}n+=o.nodeSize}}function mR(t,e,n,r){for(let o=t.childCount,i=e.childCount;;){if(o==0||i==0)return o==i?null:{a:n,b:r};let s=t.child(--o),l=e.child(--i),a=s.nodeSize;if(s==l){n-=a,r-=a;continue}if(!s.sameMarkup(l))return{a:n,b:r};if(s.isText&&s.text!=l.text){let u=0,c=Math.min(s.text.length,l.text.length);for(;ue&&r(a,o+l,i||null,s)!==!1&&a.content.size){let c=l+1;a.nodesBetween(Math.max(0,e-c),Math.min(a.content.size,n-c),r,o+c)}l=u}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,r,o){let i="",s=!0;return this.nodesBetween(e,n,(l,a)=>{l.isText?(i+=l.text.slice(Math.max(e,a)-a,n-a),s=!r):l.isLeaf?(o?i+=typeof o=="function"?o(l):o:l.type.spec.leafText&&(i+=l.type.spec.leafText(l)),s=!r):!s&&l.isBlock&&(i+=r,s=!0)},0),i}append(e){if(!e.size)return this;if(!this.size)return e;let n=this.lastChild,r=e.firstChild,o=this.content.slice(),i=0;for(n.isText&&n.sameMarkup(r)&&(o[o.length-1]=n.withText(n.text+r.text),i=1);ie)for(let i=0,s=0;se&&((sn)&&(l.isText?l=l.cut(Math.max(0,e-s),Math.min(l.text.length,n-s)):l=l.cut(Math.max(0,e-s-1),Math.min(l.content.size,n-s-1))),r.push(l),o+=l.nodeSize),s=a}return new Q(r,o)}cutByIndex(e,n){return e==n?Q.empty:e==0&&n==this.content.length?this:new Q(this.content.slice(e,n))}replaceChild(e,n){let r=this.content[e];if(r==n)return this;let o=this.content.slice(),i=this.size+n.nodeSize-r.nodeSize;return o[e]=n,new Q(o,i)}addToStart(e){return new Q([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new Q(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let n=0;nthis.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let r=0,o=0;;r++){let i=this.child(r),s=o+i.nodeSize;if(s>=e)return s==e||n>0?Ef(r+1,s):Ef(r,o);o=s}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,n){if(!n)return Q.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new Q(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return Q.empty;let n,r=0;for(let o=0;othis.type.rank&&(n||(n=e.slice(0,o)),n.push(this),r=!0),n&&n.push(i)}}return n||(n=e.slice()),r||n.push(this),n}removeFromSet(e){for(let n=0;nr.type.rank-o.type.rank),n}}Ke.none=[];class Bp extends Error{}class ae{constructor(e,n,r){this.content=e,this.openStart=n,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,n){let r=yR(this.content,e+this.openStart,n);return r&&new ae(r,this.openStart,this.openEnd)}removeBetween(e,n){return new ae(vR(this.content,e+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,n){if(!n)return ae.empty;let r=n.openStart||0,o=n.openEnd||0;if(typeof r!="number"||typeof o!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new ae(Q.fromJSON(e,n.content),r,o)}static maxOpen(e,n=!0){let r=0,o=0;for(let i=e.firstChild;i&&!i.isLeaf&&(n||!i.type.spec.isolating);i=i.firstChild)r++;for(let i=e.lastChild;i&&!i.isLeaf&&(n||!i.type.spec.isolating);i=i.lastChild)o++;return new ae(e,r,o)}}ae.empty=new ae(Q.empty,0,0);function vR(t,e,n){let{index:r,offset:o}=t.findIndex(e),i=t.maybeChild(r),{index:s,offset:l}=t.findIndex(n);if(o==e||i.isText){if(l!=n&&!t.child(s).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(r!=s)throw new RangeError("Removing non-flat range");return t.replaceChild(r,i.copy(vR(i.content,e-o-1,n-o-1)))}function yR(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 l=yR(s.content,e-i-1,n);return l&&t.replaceChild(o,s.copy(l))}function bD(t,e,n){if(n.openStart>t.depth)throw new Bp("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new Bp("Inconsistent open depths");return bR(t,e,n,0)}function bR(t,e,n,r){let o=t.index(r),i=t.node(r);if(o==e.index(r)&&r=0&&t.isText&&t.sameMarkup(e[n])?e[n]=t.withText(e[n].text+t.text):e.push(t)}function wd(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&&(Ba(t.nodeAfter,r),i++));for(let l=i;lo&&f0(t,e,o+1),s=r.depth>o&&f0(n,r,o+1),l=[];return wd(null,t,o,l),i&&s&&e.index(o)==n.index(o)?(wR(i,s),Ba(Ha(i,xR(t,e,n,r,o+1)),l)):(i&&Ba(Ha(i,Hp(t,e,o+1)),l),wd(e,n,o,l),s&&Ba(Ha(s,Hp(n,r,o+1)),l)),wd(r,null,o,l),new Q(l)}function Hp(t,e,n){let r=[];if(wd(null,t,n,r),t.depth>n){let o=f0(t,e,n+1);Ba(Ha(o,Hp(t,e,n+1)),r)}return wd(e,null,n,r),new Q(r)}function wD(t,e){let n=e.depth-t.openStart,o=e.node(n).copy(t.content);for(let i=n-1;i>=0;i--)o=e.node(i).copy(Q.from(o));return{start:o.resolveNoCache(t.openStart+n),end:o.resolveNoCache(o.content.size-t.openEnd-n)}}class Oc{constructor(e,n,r){this.pos=e,this.path=n,this.parentOffset=r,this.depth=n.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,n=this.index(this.depth);if(n==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],o=e.child(n);return r?e.child(n).cut(r):o}get nodeBefore(){let e=this.index(this.depth),n=this.pos-this.path[this.path.length-1];return n?this.parent.child(e).cut(0,n):e==0?null:this.parent.child(e-1)}posAtIndex(e,n){n=this.resolveDepth(n);let r=this.path[n*3],o=n==0?0:this.path[n*3-1]+1;for(let i=0;i0;n--)if(this.start(n)<=e&&this.end(n)>=e)return n;return 0}blockRange(e=this,n){if(e.pos=0;r--)if(e.pos<=this.end(r)&&(!n||n(this.node(r))))return new Ya(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos=0&&n<=e.content.size))throw new RangeError("Position "+n+" out of range");let r=[],o=0,i=n;for(let s=e;;){let{index:l,offset:a}=s.content.findIndex(i),u=i-a;if(r.push(s,l,o+a),!u||(s=s.child(l),s.isText))break;i=u-1,o+=a+1}return new Oc(n,r,i)}static resolveCached(e,n){for(let o=0;oe&&this.nodesBetween(e,n,i=>(r.isInSet(i.marks)&&(o=!0),!o)),o}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),kR(this.marks,e)}contentMatchAt(e){let n=this.type.contentMatch.matchFragment(this.content,0,e);if(!n)throw new Error("Called contentMatchAt on a node with invalid content");return n}canReplace(e,n,r=Q.empty,o=0,i=r.childCount){let s=this.contentMatchAt(e).matchFragment(r,o,i),l=s&&s.matchFragment(this.content,n);if(!l||!l.validEnd)return!1;for(let a=o;an.type.name)}`);this.content.forEach(n=>n.check())}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(n=>n.toJSON())),e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Node.fromJSON");let r=null;if(n.marks){if(!Array.isArray(n.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=n.marks.map(e.markFromJSON)}if(n.type=="text"){if(typeof n.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(n.text,r)}let o=Q.fromJSON(e,n.content);return e.nodeType(n.type).create(n.attrs,o,r)}};Ts.prototype.text=void 0;class Up extends Ts{constructor(e,n,r,o){if(super(e,n,null,o),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):kR(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,n){return this.text.slice(e,n)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new Up(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new Up(this.type,this.attrs,e,this.marks)}cut(e=0,n=this.text.length){return e==0&&n==this.text.length?this:this.withText(this.text.slice(e,n))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function kR(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class Xa{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new ED(e,n);if(r.next==null)return Xa.empty;let o=ER(r);r.next&&r.err("Unexpected trailing text");let i=MD(RD(o));return OD(i,r),i}matchType(e){for(let n=0;nu.createAndFill()));for(let u=0;u=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function n(r){e.push(r);for(let o=0;o{let i=o+(r.validEnd?"*":" ")+" ";for(let s=0;s"+e.indexOf(r.next[s].next);return i}).join(`
+`)}}Xa.empty=new Xa(!0);class ED{constructor(e,n){this.string=e,this.nodeTypes=n,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}}function ER(t){let e=[];do e.push(SD(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function SD(t){let e=[];do e.push(CD(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function CD(t){let e=_D(t);for(;;)if(t.eat("+"))e={type:"plus",expr:e};else if(t.eat("*"))e={type:"star",expr:e};else if(t.eat("?"))e={type:"opt",expr:e};else if(t.eat("{"))e=TD(t,e);else break;return e}function oS(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function TD(t,e){let n=oS(t),r=n;return t.eat(",")&&(t.next!="}"?r=oS(t):r=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function AD(t,e){let n=t.nodeTypes,r=n[e];if(r)return[r];let o=[];for(let i in n){let s=n[i];s.groups.indexOf(e)>-1&&o.push(s)}return o.length==0&&t.err("No node type or group '"+e+"' found"),o}function _D(t){if(t.eat("(")){let e=ER(t);return t.eat(")")||t.err("Missing closing paren"),e}else if(/\W/.test(t.next))t.err("Unexpected token '"+t.next+"'");else{let e=AD(t,t.next).map(n=>(t.inline==null?t.inline=n.isInline:t.inline!=n.isInline&&t.err("Mixing inline and block content"),{type:"name",value:n}));return t.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function RD(t){let e=[[]];return o(i(t,0),n()),e;function n(){return e.push([])-1}function r(s,l,a){let u={term:a,to:l};return e[s].push(u),u}function o(s,l){s.forEach(a=>a.to=l)}function i(s,l){if(s.type=="choice")return s.exprs.reduce((a,u)=>a.concat(i(u,l)),[]);if(s.type=="seq")for(let a=0;;a++){let u=i(s.exprs[a],l);if(a==s.exprs.length-1)return u;o(u,l=n())}else if(s.type=="star"){let a=n();return r(l,a),o(i(s.expr,a),a),[r(a)]}else if(s.type=="plus"){let a=n();return o(i(s.expr,l),a),o(i(s.expr,a),a),[r(a)]}else{if(s.type=="opt")return[r(l)].concat(i(s.expr,l));if(s.type=="range"){let a=l;for(let u=0;u{t[s].forEach(({term:l,to:a})=>{if(!l)return;let u;for(let c=0;c{u||o.push([l,u=[]]),u.indexOf(c)==-1&&u.push(c)})})});let i=e[r.join(",")]=new Xa(r.indexOf(t.length-1)>-1);for(let s=0;s-1}allowsMarks(e){if(this.markSet==null)return!0;for(let n=0;nr[i]=new _R(i,n,s));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 i in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};class ID{constructor(e){this.hasDefault=Object.prototype.hasOwnProperty.call(e,"default"),this.default=e.default}get isRequired(){return!this.hasDefault}}class Ph{constructor(e,n,r,o){this.name=e,this.rank=n,this.schema=r,this.spec=o,this.attrs=AR(o.attrs),this.excluded=null;let i=CR(this.attrs);this.instance=i?new Ke(this,i):null}create(e=null){return!e&&this.instance?this.instance:new Ke(this,TR(this.attrs,e))}static compile(e,n){let r=Object.create(null),o=0;return e.forEach((i,s)=>r[i]=new Ph(i,o++,n,s)),r}removeFromSet(e){for(var n=0;n-1}}let LD=class{constructor(e){this.cached=Object.create(null);let n=this.spec={};for(let o in e)n[o]=e[o];n.nodes=Mn.from(e.nodes),n.marks=Mn.from(e.marks||{}),this.nodes=g0.compile(this.spec.nodes,this),this.marks=Ph.compile(this.spec.marks,this);let r=Object.create(null);for(let o in this.nodes){if(o in this.marks)throw new RangeError(o+" can not be both a node and a mark");let i=this.nodes[o],s=i.spec.content||"",l=i.spec.marks;i.contentMatch=r[s]||(r[s]=Xa.parse(s,this.nodes)),i.inlineContent=i.contentMatch.inlineContent,i.markSet=l=="_"?null:l?sS(this,l.split(" ")):l==""||!i.inlineContent?[]:null}for(let o in this.marks){let i=this.marks[o],s=i.spec.excludes;i.excluded=s==null?[i]:s==""?[]:sS(this,s.split(" "))}this.nodeFromJSON=this.nodeFromJSON.bind(this),this.markFromJSON=this.markFromJSON.bind(this),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,n=null,r,o){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof g0){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(n,r,o)}text(e,n){let r=this.nodes.text;return new Up(r,r.defaultAttrs,e,Ke.setFrom(n))}mark(e,n){return typeof e=="string"&&(e=this.marks[e]),e.create(n)}nodeFromJSON(e){return Ts.fromJSON(this,e)}markFromJSON(e){return Ke.fromJSON(this,e)}nodeType(e){let n=this.nodes[e];if(!n)throw new RangeError("Unknown node type: "+e);return n}};function sS(t,e){let n=[];for(let r=0;r-1)&&n.push(s=a)}if(!s)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return n}let pb=class m0{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[],n.forEach(r=>{r.tag?this.tags.push(r):r.style&&this.styles.push(r)}),this.normalizeLists=!this.tags.some(r=>{if(!/^(ul|ol)\b/.test(r.tag)||!r.node)return!1;let o=e.nodes[r.node];return o.contentMatch.matchType(o)})}parse(e,n={}){let r=new lS(this,n,!1);return r.addAll(e,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new lS(this,n,!0);return r.addAll(e,n.from,n.to),ae.maxOpen(r.finish())}matchTag(e,n,r){for(let o=r?this.tags.indexOf(r)+1:0;oe.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=n))){if(s.getAttrs){let a=s.getAttrs(n);if(a===!1)continue;s.attrs=a||void 0}return s}}}static schemaRules(e){let n=[];function r(o){let i=o.priority==null?50:o.priority,s=0;for(;s{r(s=cS(s)),s.mark||s.ignore||s.clearMark||(s.mark=o)})}for(let o in e.nodes){let i=e.nodes[o].spec.parseDOM;i&&i.forEach(s=>{r(s=cS(s)),s.node||s.ignore||s.mark||(s.node=o)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new m0(e,m0.schemaRules(e)))}};const RR={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},ND={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},MR={ol:!0,ul:!0},Wp=1,Vp=2,xd=4;function aS(t,e,n){return e!=null?(e?Wp:0)|(e==="full"?Vp:0):t&&t.whitespace=="pre"?Wp|Vp:n&~xd}class Sf{constructor(e,n,r,o,i,s,l){this.type=e,this.attrs=n,this.marks=r,this.pendingMarks=o,this.solid=i,this.options=l,this.content=[],this.activeMarks=Ke.none,this.stashMarks=[],this.match=s||(l&xd?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(Q.from(e));if(n)this.match=this.type.contentMatch.matchFragment(n);else{let r=this.type.contentMatch,o;return(o=r.findWrapping(e.type))?(this.match=r,o):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&Wp)){let r=this.content[this.content.length-1],o;if(r&&r.isText&&(o=/[ \t\r\n\u000c]+$/.exec(r.text))){let i=r;r.text.length==o[0].length?this.content.pop():this.content[this.content.length-1]=i.withText(i.text.slice(0,i.text.length-o[0].length))}}let n=Q.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(Q.empty,!0))),this.type?this.type.create(this.attrs,n,this.marks):n}popFromStashMark(e){for(let n=this.stashMarks.length-1;n>=0;n--)if(e.eq(this.stashMarks[n]))return this.stashMarks.splice(n,1)[0]}applyPending(e){for(let n=0,r=this.pendingMarks;nthis.addAll(e)),s&&this.sync(l),this.needsBlock=a}else this.withStyleRules(e,()=>{this.addElementByRule(e,i,i.consuming===!1?o:void 0)})}leafFallback(e){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
+`))}ignoreFallback(e){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"))}readStyles(e){let n=Ke.none,r=Ke.none;for(let o=0;o{s.clearMark(l)&&(r=l.addToSet(r))}):n=this.parser.schema.marks[s.mark].create(s.attrs).addToSet(n),s.consuming===!1)i=s;else break}return[n,r]}addElementByRule(e,n,r){let o,i,s;n.node?(i=this.parser.schema.nodes[n.node],i.isLeaf?this.insertNode(i.create(n.attrs))||this.leafFallback(e):o=this.enter(i,n.attrs||null,n.preserveWhitespace)):(s=this.parser.schema.marks[n.mark].create(n.attrs),this.addPendingMark(s));let l=this.top;if(i&&i.isLeaf)this.findInside(e);else if(r)this.addElement(e,r);else if(n.getContent)this.findInside(e),n.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a));else{let a=e;typeof n.contentElement=="string"?a=e.querySelector(n.contentElement):typeof n.contentElement=="function"?a=n.contentElement(e):n.contentElement&&(a=n.contentElement),this.findAround(e,a,!0),this.addAll(a)}o&&this.sync(l)&&this.open--,s&&this.removePendingMark(s,l)}addAll(e,n,r){let o=n||0;for(let i=n?e.childNodes[n]:e.firstChild,s=r==null?null:e.childNodes[r];i!=s;i=i.nextSibling,++o)this.findAtPoint(e,o),this.addDOM(i);this.findAtPoint(e,o)}findPlace(e){let n,r;for(let o=this.open;o>=0;o--){let i=this.nodes[o],s=i.findWrapping(e);if(s&&(!n||n.length>s.length)&&(n=s,r=i,!s.length)||i.solid)break}if(!n)return!1;this.sync(r);for(let o=0;othis.open){for(;n>this.open;n--)this.nodes[n-1].content.push(this.nodes[n].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(this.isOpen||this.options.topOpen)}sync(e){for(let n=this.open;n>=0;n--)if(this.nodes[n]==e)return this.open=n,!0;return!1}get currentPos(){this.closeExtra();let e=0;for(let n=this.open;n>=0;n--){let r=this.nodes[n].content;for(let o=r.length-1;o>=0;o--)e+=r[o].nodeSize;n&&e++}return e}findAtPoint(e,n){if(this.find)for(let r=0;r-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let n=e.split("/"),r=this.options.context,o=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),i=-(r?r.depth+1:0)+(o?0:1),s=(l,a)=>{for(;l>=0;l--){let u=n[l];if(u==""){if(l==n.length-1||l==0)continue;for(;a>=i;a--)if(s(l-1,a))return!0;return!1}else{let c=a>0||a==0&&o?this.nodes[a].type:r&&a>=i?r.node(a-i).type:null;if(!c||c.name!=u&&c.groups.indexOf(u)==-1)return!1;a--}}return!0};return s(n.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let n=e.depth;n>=0;n--){let r=e.node(n).contentMatchAt(e.indexAfter(n)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let n in this.parser.schema.nodes){let r=this.parser.schema.nodes[n];if(r.isTextblock&&r.defaultAttrs)return r}}addPendingMark(e){let n=FD(e,this.top.pendingMarks);n&&this.top.stashMarks.push(n),this.top.pendingMarks=e.addToSet(this.top.pendingMarks)}removePendingMark(e,n){for(let r=this.open;r>=0;r--){let o=this.nodes[r];if(o.pendingMarks.lastIndexOf(e)>-1)o.pendingMarks=e.removeFromSet(o.pendingMarks);else{o.activeMarks=e.removeFromSet(o.activeMarks);let s=o.popFromStashMark(e);s&&o.type&&o.type.allowsMarkType(s.type)&&(o.activeMarks=s.addToSet(o.activeMarks))}if(o==n)break}}}function $D(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&MR.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function DD(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function PD(t){let e=/\s*([\w-]+)\s*:\s*([^;]+)/g,n,r=[];for(;n=e.exec(t);)r.push(n[1],n[2].trim());return r}function cS(t){let e={};for(let n in t)e[n]=t[n];return e}function zD(t,e){let n=e.schema.nodes;for(let r in n){let o=n[r];if(!o.allowsMarkType(t))continue;let i=[],s=l=>{i.push(l);for(let a=0;a{if(i.length||s.marks.length){let l=0,a=0;for(;l=0;o--){let i=this.serializeMark(e.marks[o],e.isInline,n);i&&((i.contentDOM||i.dom).appendChild(r),r=i.dom)}return r}serializeMark(e,n,r={}){let o=this.marks[e.type.name];return o&&Ur.renderSpec(Kv(r),o(e,n))}static renderSpec(e,n,r=null){if(typeof n=="string")return{dom:e.createTextNode(n)};if(n.nodeType!=null)return{dom:n};if(n.dom&&n.dom.nodeType!=null)return n;let o=n[0],i=o.indexOf(" ");i>0&&(r=o.slice(0,i),o=o.slice(i+1));let s,l=r?e.createElementNS(r,o):e.createElement(o),a=n[1],u=1;if(a&&typeof a=="object"&&a.nodeType==null&&!Array.isArray(a)){u=2;for(let c in a)if(a[c]!=null){let d=c.indexOf(" ");d>0?l.setAttributeNS(c.slice(0,d),c.slice(d+1),a[c]):l.setAttribute(c,a[c])}}for(let c=u;cu)throw new RangeError("Content hole must be the only child of its parent node");return{dom:l,contentDOM:l}}else{let{dom:h,contentDOM:f}=Ur.renderSpec(e,d,r);if(l.appendChild(h),f){if(s)throw new RangeError("Multiple content holes");s=f}}}return{dom:l,contentDOM:s}}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new Ur(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=uS(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return uS(e.marks)}}function uS(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function Kv(t){return t.document||window.document}const OR=65535,IR=Math.pow(2,16);function BD(t,e){return t+e*IR}function dS(t){return t&OR}function HD(t){return(t-(t&OR))/IR}const LR=1,NR=2,op=4,$R=8;class v0{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&$R)>0}get deletedBefore(){return(this.delInfo&(LR|op))>0}get deletedAfter(){return(this.delInfo&(NR|op))>0}get deletedAcross(){return(this.delInfo&op)>0}}class Fr{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&Fr.empty)return Fr.empty}recover(e){let n=0,r=dS(e);if(!this.inverted)for(let o=0;oe)break;let u=this.ranges[l+i],c=this.ranges[l+s],d=a+u;if(e<=d){let h=u?e==a?-1:e==d?1:n:n,f=a+o+(h<0?0:c);if(r)return f;let p=e==(n<0?a:d)?null:BD(l/3,e-a),g=e==a?NR:e==d?LR:op;return(n<0?e!=a:e!=d)&&(g|=$R),new v0(f,g,p)}o+=c-u}return r?e+o:new v0(e+o,0,null)}touches(e,n){let r=0,o=dS(n),i=this.inverted?2:1,s=this.inverted?1:2;for(let l=0;le)break;let u=this.ranges[l+i],c=a+u;if(e<=c&&l==o*3)return!0;r+=this.ranges[l+s]-u}return!1}forEach(e){let n=this.inverted?2:1,r=this.inverted?1:2;for(let o=0,i=0;o=0;n--){let o=e.getMirror(n);this.appendMap(e.maps[n].invert(),o!=null&&o>n?r-o-1:void 0)}}invert(){let e=new pc;return e.appendMappingInverted(this),e}map(e,n=1){if(this.mirror)return this._map(e,n,!0);for(let r=this.from;ri&&a!s.isAtom||!l.type.allowsMarkType(this.mark.type)?s:s.mark(this.mark.addToSet(s.marks)),o),n.openStart,n.openEnd);return Xt.fromReplace(e,this.from,this.to,i)}invert(){return new Po(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new Ii(n.pos,r.pos,this.mark)}merge(e){return e instanceof Ii&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Ii(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new Ii(n.from,n.to,e.markFromJSON(n.mark))}}dn.jsonID("addMark",Ii);class Po extends dn{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=new ae(gb(n.content,o=>o.mark(this.mark.removeFromSet(o.marks)),e),n.openStart,n.openEnd);return Xt.fromReplace(e,this.from,this.to,r)}invert(){return new Ii(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new Po(n.pos,r.pos,this.mark)}merge(e){return e instanceof Po&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Po(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new Po(n.from,n.to,e.markFromJSON(n.mark))}}dn.jsonID("removeMark",Po);class xs extends dn{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return Xt.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return Xt.fromReplace(e,this.pos,this.pos+1,new ae(Q.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);if(n){let r=this.mark.addToSet(n.marks);if(r.length==n.marks.length){for(let o=0;or.pos?null:new qt(n.pos,r.pos,o,i,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number"||typeof n.gapFrom!="number"||typeof n.gapTo!="number"||typeof n.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new qt(n.from,n.to,n.gapFrom,n.gapTo,ae.fromJSON(e,n.slice),n.insert,!!n.structure)}}dn.jsonID("replaceAround",qt);function y0(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 s=r.node(i).maybeChild(r.indexAfter(i));for(;o>0;){if(!s||s.isLeaf)return!0;s=s.firstChild,o--}}return!1}function UD(t,e,n,r){let o=[],i=[],s,l;t.doc.nodesBetween(e,n,(a,u,c)=>{if(!a.isInline)return;let d=a.marks;if(!r.isInSet(d)&&c.type.allowsMarkType(r.type)){let h=Math.max(u,e),f=Math.min(u+a.nodeSize,n),p=r.addToSet(d);for(let g=0;gt.step(a)),i.forEach(a=>t.step(a))}function WD(t,e,n,r){let o=[],i=0;t.doc.nodesBetween(e,n,(s,l)=>{if(!s.isInline)return;i++;let a=null;if(r instanceof Ph){let u=s.marks,c;for(;c=r.isInSet(u);)(a||(a=[])).push(c),u=c.removeFromSet(u)}else r?r.isInSet(s.marks)&&(a=[r]):a=s.marks;if(a&&a.length){let u=Math.min(l+s.nodeSize,n);for(let c=0;ct.step(new Po(s.from,s.to,s.style)))}function VD(t,e,n,r=n.contentMatch){let o=t.doc.nodeAt(e),i=[],s=e+1;for(let l=0;l=0;l--)t.step(i[l])}function jD(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function au(t){let n=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let r=t.depth;;--r){let o=t.$from.node(r),i=t.$from.index(r),s=t.$to.indexAfter(r);if(rn;p--)g||r.index(p)>0?(g=!0,c=Q.from(r.node(p).copy(c)),d++):a--;let h=Q.empty,f=0;for(let p=i,g=!1;p>n;p--)g||o.after(p+1)=0;s--){if(r.size){let l=n[s].type.contentMatch.matchFragment(r);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=Q.from(n[s].type.create(n[s].attrs,r))}let o=e.start,i=e.end;t.step(new qt(o,i,o,i,new ae(r,0,0),n.length,!0))}function qD(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,(s,l)=>{if(s.isTextblock&&!s.hasMarkup(r,o)&&ZD(t.doc,t.mapping.slice(i).map(l),r)){t.clearIncompatible(t.mapping.slice(i).map(l,1),r);let a=t.mapping.slice(i),u=a.map(l,1),c=a.map(l+s.nodeSize,1);return t.step(new qt(u,c,u+1,c-1,new ae(Q.from(r.create(o,null,s.marks)),0,0),1,!0)),!1}})}function ZD(t,e,n){let r=t.resolve(e),o=r.index();return r.parent.canReplaceWith(o,o+1,n)}function QD(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 qt(e,e+i.nodeSize,e+1,e+i.nodeSize-1,new ae(Q.from(s),0,0),1,!0))}function gc(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 u=o.depth-1,c=n-2;u>i;u--,c--){let d=o.node(u),h=o.index(u);if(d.type.spec.isolating)return!1;let f=d.content.cutByIndex(h,d.childCount),p=r&&r[c+1];p&&(f=f.replaceChild(0,p.type.create(p.attrs)));let g=r&&r[c]||d;if(!d.canReplace(h+1,d.childCount)||!g.type.validContent(f))return!1}let l=o.indexAfter(i),a=r&&r[0];return o.node(i).canReplaceWith(l,l,a?a.type:o.node(i+1).type)}function JD(t,e,n=1,r){let o=t.doc.resolve(e),i=Q.empty,s=Q.empty;for(let l=o.depth,a=o.depth-n,u=n-1;l>a;l--,u--){i=Q.from(o.node(l).copy(i));let c=r&&r[u];s=Q.from(c?c.type.create(c.attrs,s):o.node(l).copy(s))}t.step(new yn(e,e,new ae(i.append(s),n,n),!0))}function zh(t,e){let n=t.resolve(e),r=n.index();return eP(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function eP(t,e){return!!(t&&e&&!t.isLeaf&&t.canAppend(e))}function tP(t,e,n){let r=new yn(e-n,e+n,ae.empty,!0);t.step(r)}function DR(t,e,n){let r=t.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),n))return e;if(r.parentOffset==0)for(let o=r.depth-1;o>=0;o--){let i=r.index(o);if(r.node(o).canReplaceWith(i,i,n))return r.before(o+1);if(i>0)return null}if(r.parentOffset==r.parent.content.size)for(let o=r.depth-1;o>=0;o--){let i=r.indexAfter(o);if(r.node(o).canReplaceWith(i,i,n))return r.after(o+1);if(i=0;s--){let l=s==r.depth?0:r.pos<=(r.start(s+1)+r.end(s+1))/2?-1:1,a=r.index(s)+(l>0?1:0),u=r.node(s),c=!1;if(i==1)c=u.canReplace(a,a,o);else{let d=u.contentMatchAt(a).findWrapping(o.firstChild.type);c=d&&u.canReplaceWith(a,a,d[0])}if(c)return l==0?r.pos:l<0?r.before(s+1):r.after(s+1)}return null}function vb(t,e,n=e,r=ae.empty){if(e==n&&!r.size)return null;let o=t.resolve(e),i=t.resolve(n);return PR(o,i,r)?new yn(e,n,r):new rP(o,i,r).fit()}function PR(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}class rP{constructor(e,n,r){this.$from=e,this.$to=n,this.unplaced=r,this.frontier=[],this.placed=Q.empty;for(let o=0;o<=e.depth;o++){let i=e.node(o);this.frontier.push({type:i.type,match:i.contentMatchAt(e.indexAfter(o))})}for(let o=e.depth;o>0;o--)this.placed=Q.from(e.node(o).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let u=this.findFittable();u?this.placeNodes(u):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),n=this.placed.size-this.depth-this.$from.depth,r=this.$from,o=this.close(e<0?this.$to:r.doc.resolve(e));if(!o)return null;let i=this.placed,s=r.depth,l=o.depth;for(;s&&l&&i.childCount==1;)i=i.firstChild.content,s--,l--;let a=new ae(i,s,l);return e>-1?new qt(r.pos,e,this.$to.pos,this.$to.end(),a,n):a.size||r.pos!=this.$to.pos?new yn(r.pos,o.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let n=this.unplaced.content,r=0,o=this.unplaced.openEnd;r1&&(o=0),i.type.spec.isolating&&o<=r){e=r;break}n=i.content}for(let n=1;n<=2;n++)for(let r=n==1?e:this.unplaced.openStart;r>=0;r--){let o,i=null;r?(i=Xv(this.unplaced.content,r-1).firstChild,o=i.content):o=this.unplaced.content;let s=o.firstChild;for(let l=this.depth;l>=0;l--){let{type:a,match:u}=this.frontier[l],c,d=null;if(n==1&&(s?u.matchType(s.type)||(d=u.fillBefore(Q.from(s),!1)):i&&a.compatibleContent(i.type)))return{sliceDepth:r,frontierDepth:l,parent:i,inject:d};if(n==2&&s&&(c=u.findWrapping(s.type)))return{sliceDepth:r,frontierDepth:l,parent:i,wrap:c};if(i&&u.matchType(i.type))break}}}openMore(){let{content:e,openStart:n,openEnd:r}=this.unplaced,o=Xv(e,n);return!o.childCount||o.firstChild.isLeaf?!1:(this.unplaced=new ae(e,n+1,Math.max(r,o.size+n>=e.size-r?n+1:0)),!0)}dropNode(){let{content:e,openStart:n,openEnd:r}=this.unplaced,o=Xv(e,n);if(o.childCount<=1&&n>0){let i=e.size-n<=n+o.size;this.unplaced=new ae(Fu(e,n-1,1),n-1,i?n-1:r)}else this.unplaced=new ae(Fu(e,n,1),n,r)}placeNodes({sliceDepth:e,frontierDepth:n,parent:r,inject:o,wrap:i}){for(;this.depth>n;)this.closeFrontierNode();if(i)for(let g=0;g1||a==0||g.content.size)&&(d=m,c.push(zR(g.mark(h.allowedMarks(g.marks)),u==1?a:0,u==l.childCount?f:-1)))}let p=u==l.childCount;p||(f=-1),this.placed=Bu(this.placed,n,Q.from(c)),this.frontier[n].match=d,p&&f<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let g=0,m=l;g1&&o==this.$to.end(--r);)++o;return o}findCloseLevel(e){e:for(let n=Math.min(this.depth,e.depth);n>=0;n--){let{match:r,type:o}=this.frontier[n],i=n=0;l--){let{match:a,type:u}=this.frontier[l],c=qv(e,l,u,a,!0);if(!c||c.childCount)continue e}return{depth:n,fit:s,move:i?e.doc.resolve(e.after(n+1)):e}}}}close(e){let n=this.findCloseLevel(e);if(!n)return null;for(;this.depth>n.depth;)this.closeFrontierNode();n.fit.childCount&&(this.placed=Bu(this.placed,n.depth,n.fit)),e=n.move;for(let r=n.depth+1;r<=e.depth;r++){let o=e.node(r),i=o.type.contentMatch.fillBefore(o.content,!0,e.index(r));this.openFrontierNode(o.type,o.attrs,i)}return e}openFrontierNode(e,n=null,r){let o=this.frontier[this.depth];o.match=o.match.matchType(e),this.placed=Bu(this.placed,this.depth,Q.from(e.create(n,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(Q.empty,!0);n.childCount&&(this.placed=Bu(this.placed,this.frontier.length,n))}}function Fu(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(Fu(t.firstChild.content,e-1,n)))}function Bu(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(Bu(t.lastChild.content,e-1,n)))}function Xv(t,e){for(let n=0;n1&&(r=r.replaceChild(0,zR(r.firstChild,e-1,r.childCount==1?n-1:0))),e>0&&(r=t.type.contentMatch.fillBefore(r).append(r),n<=0&&(r=r.append(t.type.contentMatch.matchFragment(r).fillBefore(Q.empty,!0)))),t.copy(r)}function qv(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 l=r.fillBefore(i.content,!0,s);return l&&!oP(n,i.content,s)?l:null}function oP(t,e,n){for(let r=n;r0;h--,f--){let p=o.node(h).type.spec;if(p.defining||p.definingAsContext||p.isolating)break;s.indexOf(h)>-1?l=h:o.before(h)==f&&s.splice(1,0,-h)}let a=s.indexOf(l),u=[],c=r.openStart;for(let h=r.content,f=0;;f++){let p=h.firstChild;if(u.push(p),f==r.openStart)break;h=p.content}for(let h=c-1;h>=0;h--){let f=u[h],p=iP(f.type);if(p&&!f.sameMarkup(o.node(Math.abs(l)-1)))c=h;else if(p||!f.type.isTextblock)break}for(let h=r.openStart;h>=0;h--){let f=(h+c+1)%(r.openStart+1),p=u[f];if(p)for(let g=0;g=0&&(t.replace(e,n,r),!(t.steps.length>d));h--){let f=s[h];f<0||(e=o.before(f),n=i.after(f))}}function FR(t,e,n,r,o){if(er){let i=o.contentMatchAt(0),s=i.fillBefore(t).append(t);t=s.append(i.matchFragment(s).fillBefore(Q.empty,!0))}return t}function aP(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let o=DR(t.doc,e,r.type);o!=null&&(e=n=o)}t.replaceRange(e,n,new ae(Q.from(r),0,0))}function lP(t,e,n){let r=t.doc.resolve(e),o=t.doc.resolve(n),i=BR(r,o);for(let s=0;s0&&(a||r.node(l-1).canReplace(r.index(l-1),o.indexAfter(l-1))))return t.delete(r.before(l),o.after(l))}for(let s=1;s<=r.depth&&s<=o.depth;s++)if(e-r.start(s)==r.depth-s&&n>r.end(s)&&o.end(s)-n!=o.depth-s)return t.delete(r.before(s),n);t.delete(e,n)}function BR(t,e){let n=[],r=Math.min(t.depth,e.depth);for(let o=r;o>=0;o--){let i=t.start(o);if(ie.pos+(e.depth-o)||t.node(o).type.spec.isolating||e.node(o).type.spec.isolating)break;(i==e.start(o)||o==t.depth&&o==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&o&&e.start(o-1)==i-1)&&n.push(o)}return n}class mc extends dn{constructor(e,n,r){super(),this.pos=e,this.attr=n,this.value=r}apply(e){let n=e.nodeAt(this.pos);if(!n)return Xt.fail("No node at attribute step's position");let r=Object.create(null);for(let i in n.attrs)r[i]=n.attrs[i];r[this.attr]=this.value;let o=n.type.create(r,null,n.marks);return Xt.fromReplace(e,this.pos,this.pos+1,new ae(Q.from(o),0,n.isLeaf?0:1))}getMap(){return Fr.empty}invert(e){return new mc(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new mc(n.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.pos!="number"||typeof n.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new mc(n.pos,n.attr,n.value)}}dn.jsonID("attr",mc);class Hd extends dn{constructor(e,n){super(),this.attr=e,this.value=n}apply(e){let n=Object.create(null);for(let o in e.attrs)n[o]=e.attrs[o];n[this.attr]=this.value;let r=e.type.create(n,e.content,e.marks);return Xt.ok(r)}getMap(){return Fr.empty}invert(e){return new Hd(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new Hd(n.attr,n.value)}}dn.jsonID("docAttr",Hd);let Lc=class extends Error{};Lc=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};Lc.prototype=Object.create(Error.prototype);Lc.prototype.constructor=Lc;Lc.prototype.name="TransformError";class cP{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new pc}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new Lc(n.failed);return this}maybeStep(e){let n=e.apply(this.doc);return n.failed||this.addStep(e,n.doc),n}get docChanged(){return this.steps.length>0}addStep(e,n){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=n}replace(e,n=e,r=ae.empty){let o=vb(this.doc,e,n,r);return o&&this.step(o),this}replaceWith(e,n,r){return this.replace(e,n,new ae(Q.from(r),0,0))}delete(e,n){return this.replace(e,n,ae.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,r){return sP(this,e,n,r),this}replaceRangeWith(e,n,r){return aP(this,e,n,r),this}deleteRange(e,n){return lP(this,e,n),this}lift(e,n){return GD(this,e,n),this}join(e,n=1){return tP(this,e,n),this}wrap(e,n){return XD(this,e,n),this}setBlockType(e,n=e,r,o=null){return qD(this,e,n,r,o),this}setNodeMarkup(e,n,r=null,o){return QD(this,e,n,r,o),this}setNodeAttribute(e,n,r){return this.step(new mc(e,n,r)),this}setDocAttribute(e,n){return this.step(new Hd(e,n)),this}addNodeMark(e,n){return this.step(new xs(e,n)),this}removeNodeMark(e,n){if(!(n instanceof Ke)){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(n=n.isInSet(r.marks),!n)return this}return this.step(new Ic(e,n)),this}split(e,n=1,r){return JD(this,e,n,r),this}addMark(e,n,r){return UD(this,e,n,r),this}removeMark(e,n,r){return WD(this,e,n,r),this}clearIncompatible(e,n,r){return VD(this,e,n,r),this}}const Zv=Object.create(null);class Ue{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new uP(e.min(n),e.max(n))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let n=0;n=0;i--){let s=n<0?Vl(e.node(0),e.node(i),e.before(i+1),e.index(i),n,r):Vl(e.node(0),e.node(i),e.after(i+1),e.index(i)+1,n,r);if(s)return s}return null}static near(e,n=1){return this.findFrom(e,n)||this.findFrom(e,-n)||new or(e.node(0))}static atStart(e){return Vl(e,e,0,0,1)||new or(e)}static atEnd(e){return Vl(e,e,e.content.size,e.childCount,-1)||new or(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=Zv[n.type];if(!r)throw new RangeError(`No selection type ${n.type} defined`);return r.fromJSON(e,n)}static jsonID(e,n){if(e in Zv)throw new RangeError("Duplicate use of selection JSON ID "+e);return Zv[e]=n,n.prototype.jsonID=e,n}getBookmark(){return Ie.between(this.$anchor,this.$head).getBookmark()}}Ue.prototype.visible=!0;class uP{constructor(e,n){this.$from=e,this.$to=n}}let fS=!1;function pS(t){!fS&&!t.parent.inlineContent&&(fS=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class Ie extends Ue{constructor(e,n=e){pS(e),pS(n),super(e,n)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,n){let r=e.resolve(n.map(this.head));if(!r.parent.inlineContent)return Ue.near(r);let o=e.resolve(n.map(this.anchor));return new Ie(o.parent.inlineContent?o:r,r)}replace(e,n=ae.empty){if(super.replace(e,n),n==ae.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof Ie&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new sm(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,n){if(typeof n.anchor!="number"||typeof n.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new Ie(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){let o=e.resolve(n);return new this(o,r==n?o:e.resolve(r))}static between(e,n,r){let o=e.pos-n.pos;if((!r||o)&&(r=o>=0?1:-1),!n.parent.inlineContent){let i=Ue.findFrom(n,r,!0)||Ue.findFrom(n,-r,!0);if(i)n=i.$head;else return Ue.near(n,r)}return e.parent.inlineContent||(o==0?e=n:(e=(Ue.findFrom(e,-r,!0)||Ue.findFrom(e,r,!0)).$anchor,e.pos0?0:1);o>0?s=0;s+=o){let l=e.child(s);if(l.isAtom){if(!i&&Le.isSelectable(l))return Le.create(t,n-(o<0?l.nodeSize:0))}else{let a=Vl(t,l,n+o,o<0?l.childCount:0,o,i);if(a)return a}n+=l.nodeSize*o}return null}function gS(t,e,n){let r=t.steps.length-1;if(r{s==null&&(s=c)}),t.setSelection(Ue.near(t.doc.resolve(s),n))}const mS=1,Cf=2,vS=4;class hP extends cP{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor0}setStoredMarks(e){return this.storedMarks=e,this.updated|=Cf,this}ensureMarks(e){return Ke.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&Cf)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~Cf,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,n=!0){let r=this.selection;return n&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||Ke.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,n,r){let o=this.doc.type.schema;if(n==null)return e?this.replaceSelectionWith(o.text(e),!0):this.deleteSelection();{if(r==null&&(r=n),r=r??n,!e)return this.deleteRange(n,r);let i=this.storedMarks;if(!i){let s=this.doc.resolve(n);i=r==n?s.marks():s.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(n,r,o.text(e,i)),this.selection.empty||this.setSelection(Ue.near(this.selection.$to)),this}}setMeta(e,n){return this.meta[typeof e=="string"?e:e.key]=n,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=vS,this}get scrolledIntoView(){return(this.updated&vS)>0}}function yS(t,e){return!e||!t?t:t.bind(e)}class Hu{constructor(e,n,r){this.name=e,this.init=yS(n.init,r),this.apply=yS(n.apply,r)}}const fP=[new Hu("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new Hu("selection",{init(t,e){return t.selection||Ue.atStart(e.doc)},apply(t){return t.selection}}),new Hu("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new Hu("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class Qv{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=fP.slice(),n&&n.forEach(r=>{if(this.pluginsByKey[r.key])throw new RangeError("Adding different instances of a keyed plugin ("+r.key+")");this.plugins.push(r),this.pluginsByKey[r.key]=r,r.spec.state&&this.fields.push(new Hu(r.key,r.spec.state,r))})}}class Ia{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,n=-1){for(let r=0;rr.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let o=e[r],i=o.spec.state;i&&i.toJSON&&(n[r]=i.toJSON.call(o,this[o.key]))}return n}static fromJSON(e,n,r){if(!n)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let o=new Qv(e.schema,e.plugins),i=new Ia(o);return o.fields.forEach(s=>{if(s.name=="doc")i.doc=Ts.fromJSON(e.schema,n.doc);else if(s.name=="selection")i.selection=Ue.fromJSON(i.doc,n.selection);else if(s.name=="storedMarks")n.storedMarks&&(i.storedMarks=n.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let l in r){let a=r[l],u=a.spec.state;if(a.key==s.name&&u&&u.fromJSON&&Object.prototype.hasOwnProperty.call(n,l)){i[s.name]=u.fromJSON.call(a,e,n[l],i);return}}i[s.name]=s.init(e,i)}}),i}}function HR(t,e,n){for(let r in t){let o=t[r];o instanceof Function?o=o.bind(e):r=="handleDOMEvents"&&(o=HR(o,e,{})),n[r]=o}return n}class gi{constructor(e){this.spec=e,this.props={},e.props&&HR(e.props,this,this.props),this.key=e.key?e.key.key:UR("plugin")}getState(e){return e[this.key]}}const Jv=Object.create(null);function UR(t){return t in Jv?t+"$"+ ++Jv[t]:(Jv[t]=0,t+"$")}class gl{constructor(e="key"){this.key=UR(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}var pP=/[A-Z]/g,gP=/^ms-/,e1={};function mP(t){return"-"+t.toLowerCase()}function vP(t){if(e1.hasOwnProperty(t))return e1[t];var e=t.replace(pP,mP);return e1[t]=gP.test(e)?"-"+e:e}function yP(t){return vP(t)}function bP(t,e){return yP(t)+":"+e}function wP(t){var e="";for(var n in t){var r=t[n];typeof r!="string"&&typeof r!="number"||(e&&(e+=";"),e+=bP(n,r))}return e}function xP(){return typeof document<"u"?document:null}var WR=xP;function VR(t,e){if(typeof t!="string")return[t];var n=[t];typeof e=="string"||Array.isArray(e)?e={brackets:e}:e||(e={});var r=e.brackets?Array.isArray(e.brackets)?e.brackets:[e.brackets]:["{}","[]","()"],o=e.escape||"___",i=!!e.flat;r.forEach(function(a){var u=new RegExp(["\\",a[0],"[^\\",a[0],"\\",a[1],"]*\\",a[1]].join("")),c=[];function d(h,f,p){var g=n.push(h.slice(a[0].length,-a[1].length))-1;return c.push(g),o+g+o}n.forEach(function(h,f){for(var p,g=0;h!=p;)if(p=h,h=h.replace(u,d),g++>1e4)throw Error("References have circular dependency. Please, check them.");n[f]=h}),c=c.reverse(),n=n.map(function(h){return c.forEach(function(f){h=h.replace(new RegExp("(\\"+o+f+"\\"+o+")","g"),a[0]+"$1"+a[1])}),h})});var s=new RegExp("\\"+o+"([0-9]+)\\"+o);function l(a,u,c){for(var d=[],h,f=0;h=s.exec(a);){if(f++>1e4)throw Error("Circular references in parenthesis");d.push(a.slice(0,h.index)),d.push(l(u[h[1]],u)),a=a.slice(h.index+h[0].length)}return d.push(a),d}return i?n:l(n[0],n)}function jR(t,e){if(e&&e.flat){var n=e&&e.escape||"___",r=t[0],o;if(!r)return"";for(var i=new RegExp("\\"+n+"([0-9]+)\\"+n),s=0;r!=o;){if(s++>1e4)throw Error("Circular references in "+t);o=r,r=r.replace(i,l)}return r}return t.reduce(function a(u,c){return Array.isArray(c)&&(c=c.reduce(a,"")),u+c},"");function l(a,u){if(t[u]==null)throw Error("Reference "+u+"is undefined");return t[u]}}function GR(t,e){return Array.isArray(t)?jR(t,e):VR(t,e)}GR.parse=VR;GR.stringify=jR;const kP={id:"extension.command.copy.label",message:"Copy",comment:"Label for copy command."},EP={id:"extension.command.copy.description",message:"Copy the selected text",comment:"Description for copy command."},SP={id:"extension.command.cut.label",message:"Cut",comment:"Label for cut command."},CP={id:"extension.command.cut.description",message:"Cut the selected text",comment:"Description for cut command."},TP={id:"extension.command.paste.label",message:"Paste",comment:"Label for paste command."},AP={id:"extension.command.paste.description",message:"Paste content into the editor",comment:"Description for paste command."},_P={id:"extension.command.select-all.label",message:"Select all",comment:"Label for select all command."},RP={id:"extension.command.select-all.description",message:"Select all content within the editor",comment:"Description for select all command."};var Hs=Object.freeze({__proto__:null,COPY_DESCRIPTION:EP,COPY_LABEL:kP,CUT_DESCRIPTION:CP,CUT_LABEL:SP,PASTE_DESCRIPTION:AP,PASTE_LABEL:TP,SELECT_ALL_DESCRIPTION:RP,SELECT_ALL_LABEL:_P});const MP={id:"keyboard.shortcut.escape",message:"Enter",comment:"Label for escape key in shortcuts."},OP={id:"keyboard.shortcut.command",message:"Command",comment:"Label for command key in shortcuts."},IP={id:"keyboard.shortcut.control",message:"Control",comment:"Label for control key in shortcuts."},LP={id:"keyboard.shortcut.enter",message:"Enter",comment:"Label for enter key in shortcuts."},NP={id:"keyboard.shortcut.shift",message:"Shift",comment:"Label for shift key in shortcuts."},$P={id:"keyboard.shortcut.alt",message:"Alt",comment:"Label for alt key in shortcuts."},DP={id:"keyboard.shortcut.capsLock",message:"Caps Lock",comment:"Label for caps lock key in shortcuts."},PP={id:"keyboard.shortcut.backspace",message:"Backspace",comment:"Label for backspace key in shortcuts."},zP={id:"keyboard.shortcut.tab",message:"Tab",comment:"Label for tab key in shortcuts."},FP={id:"keyboard.shortcut.space",message:"Space",comment:"Label for space key in shortcuts."},BP={id:"keyboard.shortcut.delete",message:"Delete",comment:"Label for delete key in shortcuts."},HP={id:"keyboard.shortcut.pageUp",message:"Page Up",comment:"Label for page up key in shortcuts."},UP={id:"keyboard.shortcut.pageDown",message:"Page Down",comment:"Label for page down key in shortcuts."},WP={id:"keyboard.shortcut.home",message:"Home",comment:"Label for home key in shortcuts."},VP={id:"keyboard.shortcut.end",message:"End",comment:"Label for end key in shortcuts."},jP={id:"keyboard.shortcut.arrowLeft",message:"Arrow Left",comment:"Label for arrow left key in shortcuts."},GP={id:"keyboard.shortcut.arrowRight",message:"Arrow Right",comment:"Label for arrow right key in shortcuts."},KP={id:"keyboard.shortcut.arrowUp",message:"Arrow Up",comment:"Label for arrow up key in shortcuts."},YP={id:"keyboard.shortcut.arrowDown",message:"Arrow Down",comment:"Label for arrowDown key in shortcuts."};var on=Object.freeze({__proto__:null,ALT_KEY:$P,ARROW_DOWN_KEY:YP,ARROW_LEFT_KEY:jP,ARROW_RIGHT_KEY:GP,ARROW_UP_KEY:KP,BACKSPACE_KEY:PP,CAPS_LOCK_KEY:DP,COMMAND_KEY:OP,CONTROL_KEY:IP,DELETE_KEY:BP,END_KEY:VP,ENTER_KEY:LP,ESCAPE_KEY:MP,HOME_KEY:WP,PAGE_DOWN_KEY:UP,PAGE_UP_KEY:HP,SHIFT_KEY:NP,SPACE_KEY:FP,TAB_KEY:zP});const XP={id:"extension.command.toggle-blockquote.label",message:"Blockquote",comment:"Label for blockquote formatting command."},qP={id:"extension.command.toggle-blockquote.description",message:"Add blockquote formatting to the selected text",comment:"Description for blockquote formatting command."};var bS=Object.freeze({__proto__:null,DESCRIPTION:qP,LABEL:XP});const ZP={id:"extension.command.toggle-bold.label",message:"Bold",comment:"Label for bold formatting command."},QP={id:"extension.command.toggle-bold.description",message:"Add bold formatting to the selected text",comment:"Description for bold formatting command."};var wS=Object.freeze({__proto__:null,DESCRIPTION:QP,LABEL:ZP});const JP={id:"extension.command.toggle-code-block.label",message:"Codeblock",comment:"Label for the code block command."},e5={id:"extension.command.toggle-code-block.description",message:"Add a code block",comment:"Description for the code block command."};var t5=Object.freeze({__proto__:null,DESCRIPTION:e5,LABEL:JP});const n5={id:"extension.command.toggle-code.label",message:"Code",comment:"Label for the inline code formatting."},r5={id:"extension.command.toggle-code.description",message:"Add inline code formatting to the selected text",comment:"Description for the inline code formatting command."};var o5=Object.freeze({__proto__:null,DESCRIPTION:r5,LABEL:n5});const i5={id:"extension.command.toggle-heading.label",message:`{level, select, 1 {Heading 1}
2 {Heading 2}
3 {Heading 3}
4 {Heading 4}
5 {Heading 5}
6 {Heading 6}
-other {Heading}}`,comment:"Label for heading command with support for levels."};var F5=Object.freeze({__proto__:null,LABEL:H5});const U5={id:"extension.command.undo.label",message:"Undo",comment:"Label for undo."},V5={id:"extension.command.undo.description",message:"Undo the most recent action",comment:"Description for undo."},j5={id:"extension.command.redo.label",message:"Redo",comment:"Label for redo."},G5={id:"extension.command.redo.description",message:"Redo the most recent action",comment:"Description for redo."};var Pf=Object.freeze({__proto__:null,REDO_DESCRIPTION:G5,REDO_LABEL:j5,UNDO_DESCRIPTION:V5,UNDO_LABEL:U5});const W5={id:"extension.command.insert-horizontal-rule.label",message:"Divider",comment:"Label for inserting a horizontal rule (divider) command."},K5={id:"extension.command.insert-horizontal-rule.description",message:"Separate content with a diving horizontal line",comment:"Description for inserting a horizontal rule (divider) command."};var Wx=Object.freeze({__proto__:null,DESCRIPTION:K5,LABEL:W5});const Y5={id:"extension.command.toggle-italic.label",message:"Italic",comment:"Label for italic formatting command."},q5={id:"extension.command.toggle-italic.description",message:"Italicize the selected text",comment:"Description for italic formatting command."};var Kx=Object.freeze({__proto__:null,DESCRIPTION:q5,LABEL:Y5});const X5={id:"extension.command.toggle-ordered-list.label",message:"Ordered list",comment:"Label for inserting an ordered list into the editor."},Z5={id:"extension.command.toggle-bullet-list.description",message:"Bulleted list",comment:"Description for inserting a bullet list into the editor."},J5={id:"extension.command.toggle-task-list.description",message:"Tasked list",comment:"Description for inserting a task list into the editor."};var Yy=Object.freeze({__proto__:null,BULLET_LIST_LABEL:Z5,ORDERED_LIST_LABEL:X5,TASK_LIST_LABEL:J5});const Q5={id:"extension.command.insert-paragraph.label",message:"Insert Paragraph",comment:"Label for inserting a paragraph."},eD={id:"extension.command.insert-paragraph.description",message:"Insert a new paragraph",comment:"Description for inserting a paragraph."},tD={id:"extension.command.convert-paragraph.label",message:"Convert Paragraph",comment:"Label for converting the current node into a paragraph."},rD={id:"extension.command.convert-paragraph.description",message:"Convert current block into a paragraph block.",comment:"Description for converting a paragraph."};var zf=Object.freeze({__proto__:null,CONVERT_DESCRIPTION:rD,CONVERT_LABEL:tD,INSERT_DESCRIPTION:eD,INSERT_LABEL:Q5});const nD={id:"extension.command.toggle-strike.label",message:"Strikethrough",comment:"Label for strike formatting command."},oD={id:"extension.command.toggle-strike.description",message:"Strikethrough the selected text",comment:"Description for strike formatting command."};var Yx=Object.freeze({__proto__:null,DESCRIPTION:oD,LABEL:nD});const iD={id:"extension.command.toggle-underline.label",message:"Underline",comment:"Label for underline formatting command."},sD={id:"extension.command.toggle-underline.description",message:"Underline the selected text",comment:"Description for underline formatting command."};var qx=Object.freeze({__proto__:null,DESCRIPTION:sD,LABEL:iD});class Oa{constructor(t,r){this.match=t,this.match=t,this.handler=typeof r=="string"?aD(r):r}}function aD(e){return function(t,r,n,o){let i=e;if(r[1]){let s=r[0].lastIndexOf(r[1]);i+=r[0].slice(s+r[1].length),n+=s;let a=n-o;a>0&&(i=r[0].slice(s-a,s)+i,n=o)}return t.tr.insertText(i,n,o)}}const lD=500;function cD({rules:e}){let t=new Po({state:{init(){return null},apply(r,n){let o=r.getMeta(this);return o||(r.selectionSet||r.docChanged?null:n)}},props:{handleTextInput(r,n,o,i){return Xx(r,n,o,i,e,t)},handleDOMEvents:{compositionend:r=>{setTimeout(()=>{let{$cursor:n}=r.state.selection;n&&Xx(r,n.pos,n.pos,"",e,t)})}}},isInputRules:!0});return t}function Xx(e,t,r,n,o,i){if(e.composing)return!1;let s=e.state,a=s.doc.resolve(t);if(a.parent.type.spec.code)return!1;let l=a.parent.textBetween(Math.max(0,a.parentOffset-lD),a.parentOffset,null,"")+n;for(let c=0;c{let r=e.plugins;for(let n=0;n=0;l--)s.step(a.steps[l].invert(a.docs[l]));if(i.text){let l=s.doc.resolve(i.from).marks();s.replaceWith(i.from,i.to,e.schema.text(i.text,l))}else s.delete(i.from,i.to);t(s)}return!0}}return!1};function Xh(e,t,r=null,n){return new Oa(e,(o,i,s,a)=>{let l=r instanceof Function?r(i):r,c=o.tr.delete(s,a),u=c.doc.resolve(s),d=u.blockRange(),p=d&&Gy(d,t,l);if(!p)return null;c.wrap(d,p);let f=c.doc.resolve(s-1).nodeBefore;return f&&f.type==t&&Hd(c.doc,s-1)&&(!n||n(i,f))&&c.join(s-1),c})}function dD(e,t,r=null){return new Oa(e,(n,o,i,s)=>{let a=n.doc.resolve(i),l=r instanceof Function?r(o):r;return a.node(-1).canReplaceWith(a.index(-1),a.indexAfter(-1),t)?n.tr.delete(i,s).setBlockType(i,i,t,l):null})}const Er=function(e){for(var t=0;;t++)if(e=e.previousSibling,!e)return t},Gu=function(e){let t=e.assignedSlot||e.parentNode;return t&&t.nodeType==11?t.host:t};let Zx=null;const Wo=function(e,t,r){let n=Zx||(Zx=document.createRange());return n.setEnd(e,r??e.nodeValue.length),n.setStart(e,t||0),n},la=function(e,t,r,n){return r&&(Jx(e,t,r,n,-1)||Jx(e,t,r,n,1))},pD=/^(img|br|input|textarea|hr)$/i;function Jx(e,t,r,n,o){for(;;){if(e==r&&t==n)return!0;if(t==(o<0?0:ko(e))){let i=e.parentNode;if(!i||i.nodeType!=1||qy(e)||pD.test(e.nodeName)||e.contentEditable=="false")return!1;t=Er(e)+(o<0?0:1),e=i}else if(e.nodeType==1){if(e=e.childNodes[t+(o<0?-1:0)],e.contentEditable=="false")return!1;t=o<0?ko(e):0}else return!1}}function ko(e){return e.nodeType==3?e.nodeValue.length:e.childNodes.length}function fD(e,t,r){for(let n=t==0,o=t==ko(e);n||o;){if(e==r)return!0;let i=Er(e);if(e=e.parentNode,!e)return!1;n=n&&i==0,o=o&&i==ko(e)}}function qy(e){let t;for(let r=e;r&&!(t=r.pmViewDesc);r=r.parentNode);return t&&t.node&&t.node.isBlock&&(t.dom==e||t.contentDOM==e)}const Zh=function(e){return e.focusNode&&la(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)};function Us(e,t){let r=document.createEvent("Event");return r.initEvent("keydown",!0,!0),r.keyCode=e,r.key=r.code=t,r}function hD(e){let t=e.activeElement;for(;t&&t.shadowRoot;)t=t.shadowRoot.activeElement;return t}function mD(e,t,r){if(e.caretPositionFromPoint)try{let n=e.caretPositionFromPoint(t,r);if(n)return{node:n.offsetNode,offset:n.offset}}catch{}if(e.caretRangeFromPoint){let n=e.caretRangeFromPoint(t,r);if(n)return{node:n.startContainer,offset:n.startOffset}}}const _o=typeof navigator<"u"?navigator:null,Qx=typeof document<"u"?document:null,ys=_o&&_o.userAgent||"",X1=/Edge\/(\d+)/.exec(ys),cO=/MSIE \d/.exec(ys),Z1=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(ys),Hr=!!(cO||Z1||X1),Gi=cO?document.documentMode:Z1?+Z1[1]:X1?+X1[1]:0,ao=!Hr&&/gecko\/(\d+)/i.test(ys);ao&&+(/Firefox\/(\d+)/.exec(ys)||[0,0])[1];const J1=!Hr&&/Chrome\/(\d+)/.exec(ys),hr=!!J1,gD=J1?+J1[1]:0,Tr=!Hr&&!!_o&&/Apple Computer/.test(_o.vendor),$l=Tr&&(/Mobile\/\w+/.test(ys)||!!_o&&_o.maxTouchPoints>2),Cn=$l||(_o?/Mac/.test(_o.platform):!1),yD=_o?/Win/.test(_o.platform):!1,eo=/Android \d/.test(ys),Fd=!!Qx&&"webkitFontSmoothing"in Qx.documentElement.style,vD=Fd?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function bD(e){return{left:0,right:e.documentElement.clientWidth,top:0,bottom:e.documentElement.clientHeight}}function Ho(e,t){return typeof e=="number"?e:e[t]}function ED(e){let t=e.getBoundingClientRect(),r=t.width/e.offsetWidth||1,n=t.height/e.offsetHeight||1;return{left:t.left,right:t.left+e.clientWidth*r,top:t.top,bottom:t.top+e.clientHeight*n}}function eS(e,t,r){let n=e.someProp("scrollThreshold")||0,o=e.someProp("scrollMargin")||5,i=e.dom.ownerDocument;for(let s=r||e.dom;s;s=Gu(s)){if(s.nodeType!=1)continue;let a=s,l=a==i.body,c=l?bD(i):ED(a),u=0,d=0;if(t.topc.bottom-Ho(n,"bottom")&&(d=t.bottom-t.top>c.bottom-c.top?t.top+Ho(o,"top")-c.top:t.bottom-c.bottom+Ho(o,"bottom")),t.leftc.right-Ho(n,"right")&&(u=t.right-c.right+Ho(o,"right")),u||d)if(l)i.defaultView.scrollBy(u,d);else{let p=a.scrollLeft,f=a.scrollTop;d&&(a.scrollTop+=d),u&&(a.scrollLeft+=u);let h=a.scrollLeft-p,m=a.scrollTop-f;t={left:t.left-h,top:t.top-m,right:t.right-h,bottom:t.bottom-m}}if(l||/^(fixed|sticky)$/.test(getComputedStyle(s).position))break}}function kD(e){let t=e.dom.getBoundingClientRect(),r=Math.max(0,t.top),n,o;for(let i=(t.left+t.right)/2,s=r+1;s=r-20){n=a,o=l.top;break}}return{refDOM:n,refTop:o,stack:uO(e.dom)}}function uO(e){let t=[],r=e.ownerDocument;for(let n=e;n&&(t.push({dom:n,top:n.scrollTop,left:n.scrollLeft}),e!=r);n=Gu(n));return t}function xD({refDOM:e,refTop:t,stack:r}){let n=e?e.getBoundingClientRect().top:0;dO(r,n==0?0:n-t)}function dO(e,t){for(let r=0;r=a){s=Math.max(h.bottom,s),a=Math.min(h.top,a);let m=h.left>t.left?h.left-t.left:h.right=(h.left+h.right)/2?1:0));continue}}else h.top>t.top&&!l&&h.left<=t.left&&h.right>=t.left&&(l=u,c={left:Math.max(h.left,Math.min(h.right,t.left)),top:h.top});!r&&(t.left>=h.right&&t.top>=h.top||t.left>=h.left&&t.top>=h.bottom)&&(i=d+1)}}return!r&&l&&(r=l,o=c,n=0),r&&r.nodeType==3?wD(r,o):!r||n&&r.nodeType==1?{node:e,offset:i}:pO(r,o)}function wD(e,t){let r=e.nodeValue.length,n=document.createRange();for(let o=0;o=(i.left+i.right)/2?1:0)}}return{node:e,offset:0}}function Xy(e,t){return e.left>=t.left-1&&e.left<=t.right+1&&e.top>=t.top-1&&e.top<=t.bottom+1}function TD(e,t){let r=e.parentNode;return r&&/^li$/i.test(r.nodeName)&&t.left(s.left+s.right)/2?1:-1}return e.docView.posFromDOM(n,o,i)}function OD(e,t,r,n){let o=-1;for(let i=t,s=!1;i!=e.dom;){let a=e.docView.nearestDesc(i,!0);if(!a)return null;if(a.dom.nodeType==1&&(a.node.isBlock&&a.parent&&!s||!a.contentDOM)){let l=a.dom.getBoundingClientRect();if(a.node.isBlock&&a.parent&&!s&&(s=!0,l.left>n.left||l.top>n.top?o=a.posBefore:(l.right-1?o:e.docView.posFromDOM(t,r,-1)}function fO(e,t,r){let n=e.childNodes.length;if(n&&r.topt.top&&o++}let c;Fd&&o&&n.nodeType==1&&(c=n.childNodes[o-1]).nodeType==1&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=t.top&&o--,n==e.dom&&o==n.childNodes.length-1&&n.lastChild.nodeType==1&&t.top>n.lastChild.getBoundingClientRect().bottom?a=e.state.doc.content.size:(o==0||n.nodeType!=1||n.childNodes[o-1].nodeName!="BR")&&(a=OD(e,n,o,t))}a==null&&(a=CD(e,s,t));let l=e.docView.nearestDesc(s,!0);return{pos:a,inside:l?l.posAtStart-l.border:-1}}function tS(e){return e.top=0&&o==n.nodeValue.length?(l--,u=1):r<0?l--:c++,Cc(Ti(Wo(n,l,c),u),u<0)}if(!e.state.doc.resolve(t-(i||0)).parent.inlineContent){if(i==null&&o&&(r<0||o==ko(n))){let l=n.childNodes[o-1];if(l.nodeType==1)return Dg(l.getBoundingClientRect(),!1)}if(i==null&&o=0)}if(i==null&&o&&(r<0||o==ko(n))){let l=n.childNodes[o-1],c=l.nodeType==3?Wo(l,ko(l)-(s?0:1)):l.nodeType==1&&(l.nodeName!="BR"||!l.nextSibling)?l:null;if(c)return Cc(Ti(c,1),!1)}if(i==null&&o=0)}function Cc(e,t){if(e.width==0)return e;let r=t?e.left:e.right;return{top:e.top,bottom:e.bottom,left:r,right:r}}function Dg(e,t){if(e.height==0)return e;let r=t?e.top:e.bottom;return{top:r,bottom:r,left:e.left,right:e.right}}function mO(e,t,r){let n=e.state,o=e.root.activeElement;n!=t&&e.updateState(t),o!=e.dom&&e.focus();try{return r()}finally{n!=t&&e.updateState(n),o!=e.dom&&o&&o.focus()}}function RD(e,t,r){let n=t.selection,o=r=="up"?n.$from:n.$to;return mO(e,t,()=>{let{node:i}=e.docView.domFromPos(o.pos,r=="up"?-1:1);for(;;){let a=e.docView.nearestDesc(i,!0);if(!a)break;if(a.node.isBlock){i=a.contentDOM||a.dom;break}i=a.dom.parentNode}let s=hO(e,o.pos,1);for(let a=i.firstChild;a;a=a.nextSibling){let l;if(a.nodeType==1)l=a.getClientRects();else if(a.nodeType==3)l=Wo(a,0,a.nodeValue.length).getClientRects();else continue;for(let c=0;cu.top+1&&(r=="up"?s.top-u.top>(u.bottom-s.top)*2:u.bottom-s.bottom>(s.bottom-u.top)*2))return!1}}return!0})}const _D=/[\u0590-\u08ac]/;function ID(e,t,r){let{$head:n}=t.selection;if(!n.parent.isTextblock)return!1;let o=n.parentOffset,i=!o,s=o==n.parent.content.size,a=e.domSelection();return!_D.test(n.parent.textContent)||!a.modify?r=="left"||r=="backward"?i:s:mO(e,t,()=>{let{focusNode:l,focusOffset:c,anchorNode:u,anchorOffset:d}=e.domSelectionRange(),p=a.caretBidiLevel;a.modify("move",r,"character");let f=n.depth?e.docView.domAfterPos(n.before()):e.dom,{focusNode:h,focusOffset:m}=e.domSelectionRange(),b=h&&!f.contains(h.nodeType==1?h:h.parentNode)||l==h&&c==m;try{a.collapse(u,d),l&&(l!=u||c!=d)&&a.extend&&a.extend(l,c)}catch{}return p!=null&&(a.caretBidiLevel=p),b})}let rS=null,nS=null,oS=!1;function MD(e,t,r){return rS==t&&nS==r?oS:(rS=t,nS=r,oS=r=="up"||r=="down"?RD(e,t,r):ID(e,t,r))}const In=0,iS=1,Gs=2,Io=3;class Ud{constructor(t,r,n,o){this.parent=t,this.children=r,this.dom=n,this.contentDOM=o,this.dirty=In,n.pmViewDesc=this}matchesWidget(t){return!1}matchesMark(t){return!1}matchesNode(t,r,n){return!1}matchesHack(t){return!1}parseRule(){return null}stopEvent(t){return!1}get size(){let t=0;for(let r=0;rEr(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))o=t.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(r==0)for(let i=t;;i=i.parentNode){if(i==this.dom){o=!1;break}if(i.previousSibling)break}if(o==null&&r==t.childNodes.length)for(let i=t;;i=i.parentNode){if(i==this.dom){o=!0;break}if(i.nextSibling)break}}return o??n>0?this.posAtEnd:this.posAtStart}nearestDesc(t,r=!1){for(let n=!0,o=t;o;o=o.parentNode){let i=this.getDesc(o),s;if(i&&(!r||i.node))if(n&&(s=i.nodeDOM)&&!(s.nodeType==1?s.contains(t.nodeType==1?t:t.parentNode):s==t))n=!1;else return i}}getDesc(t){let r=t.pmViewDesc;for(let n=r;n;n=n.parent)if(n==this)return r}posFromDOM(t,r,n){for(let o=t;o;o=o.parentNode){let i=this.getDesc(o);if(i)return i.localPosFromDOM(t,r,n)}return-1}descAt(t){for(let r=0,n=0;rt||s instanceof yO){o=t-i;break}i=a}if(o)return this.children[n].domFromPos(o-this.children[n].border,r);for(let i;n&&!(i=this.children[n-1]).size&&i instanceof gO&&i.side>=0;n--);if(r<=0){let i,s=!0;for(;i=n?this.children[n-1]:null,!(!i||i.dom.parentNode==this.contentDOM);n--,s=!1);return i&&r&&s&&!i.border&&!i.domAtom?i.domFromPos(i.size,r):{node:this.contentDOM,offset:i?Er(i.dom)+1:0}}else{let i,s=!0;for(;i=n=u&&r<=c-l.border&&l.node&&l.contentDOM&&this.contentDOM.contains(l.contentDOM))return l.parseRange(t,r,u);t=s;for(let d=a;d>0;d--){let p=this.children[d-1];if(p.size&&p.dom.parentNode==this.contentDOM&&!p.emptyChildAt(1)){o=Er(p.dom)+1;break}t-=p.size}o==-1&&(o=0)}if(o>-1&&(c>r||a==this.children.length-1)){r=c;for(let u=a+1;uf&&sr){let f=a;a=l,l=f}let p=document.createRange();p.setEnd(l.node,l.offset),p.setStart(a.node,a.offset),c.removeAllRanges(),c.addRange(p)}}ignoreMutation(t){return!this.contentDOM&&t.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(t,r){for(let n=0,o=0;o=n:tn){let a=n+i.border,l=s-i.border;if(t>=a&&r<=l){this.dirty=t==n||r==s?Gs:iS,t==a&&r==l&&(i.contentLost||i.dom.parentNode!=this.contentDOM)?i.dirty=Io:i.markDirty(t-a,r-a);return}else i.dirty=i.dom==i.contentDOM&&i.dom.parentNode==this.contentDOM&&!i.children.length?Gs:Io}n=s}this.dirty=Gs}markParentsDirty(){let t=1;for(let r=this.parent;r;r=r.parent,t++){let n=t==1?Gs:iS;r.dirty{if(!i)return o;if(i.parent)return i.parent.posBeforeChild(i)})),!r.type.spec.raw){if(s.nodeType!=1){let a=document.createElement("span");a.appendChild(s),s=a}s.contentEditable="false",s.classList.add("ProseMirror-widget")}super(t,[],s,null),this.widget=r,this.widget=r,i=this}matchesWidget(t){return this.dirty==In&&t.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(t){let r=this.widget.spec.stopEvent;return r?r(t):!1}ignoreMutation(t){return t.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get side(){return this.widget.type.side}}class LD extends Ud{constructor(t,r,n,o){super(t,[],r,null),this.textDOM=n,this.text=o}get size(){return this.text.length}localPosFromDOM(t,r){return t!=this.textDOM?this.posAtStart+(r?this.size:0):this.posAtStart+r}domFromPos(t){return{node:this.textDOM,offset:t}}ignoreMutation(t){return t.type==="characterData"&&t.target.nodeValue==t.oldValue}}class ca extends Ud{constructor(t,r,n,o){super(t,[],n,o),this.mark=r}static create(t,r,n,o){let i=o.nodeViews[r.type.name],s=i&&i(r,o,n);return(!s||!s.dom)&&(s=un.renderSpec(document,r.type.spec.toDOM(r,n))),new ca(t,r,s.dom,s.contentDOM||s.dom)}parseRule(){return this.dirty&Io||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(t){return this.dirty!=Io&&this.mark.eq(t)}markDirty(t,r){if(super.markDirty(t,r),this.dirty!=In){let n=this.parent;for(;!n.node;)n=n.parent;n.dirty0&&(i=t0(i,0,t,n));for(let a=0;a{if(!l)return s;if(l.parent)return l.parent.posBeforeChild(l)},n,o),u=c&&c.dom,d=c&&c.contentDOM;if(r.isText){if(!u)u=document.createTextNode(r.text);else if(u.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else u||({dom:u,contentDOM:d}=un.renderSpec(document,r.type.spec.toDOM(r)));!d&&!r.isText&&u.nodeName!="BR"&&(u.hasAttribute("contenteditable")||(u.contentEditable="false"),r.type.spec.draggable&&(u.draggable=!0));let p=u;return u=EO(u,n,r),c?l=new DD(t,r,n,o,u,d||null,p,c,i,s+1):r.isText?new Jh(t,r,n,o,u,p,i):new Wi(t,r,n,o,u,d||null,p,i,s+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let t={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(t.preserveWhitespace="full"),!this.contentDOM)t.getContent=()=>this.node.content;else if(!this.contentLost)t.contentElement=this.contentDOM;else{for(let r=this.children.length-1;r>=0;r--){let n=this.children[r];if(this.dom.contains(n.dom.parentNode)){t.contentElement=n.dom.parentNode;break}}t.contentElement||(t.getContent=()=>I.empty)}return t}matchesNode(t,r,n){return this.dirty==In&&t.eq(this.node)&&e0(r,this.outerDeco)&&n.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(t,r){let n=this.node.inlineContent,o=r,i=t.composing?this.localCompositionInfo(t,r):null,s=i&&i.pos>-1?i:null,a=i&&i.pos<0,l=new zD(this,s&&s.node,t);HD(this.node,this.innerDeco,(c,u,d)=>{c.spec.marks?l.syncToMarks(c.spec.marks,n,t):c.type.side>=0&&!d&&l.syncToMarks(u==this.node.childCount?Ne.none:this.node.child(u).marks,n,t),l.placeWidget(c,t,o)},(c,u,d,p)=>{l.syncToMarks(c.marks,n,t);let f;l.findNodeMatch(c,u,d,p)||a&&t.state.selection.from>o&&t.state.selection.to-1&&l.updateNodeAt(c,u,d,f,t)||l.updateNextNode(c,u,d,t,p,o)||l.addNode(c,u,d,t,o),o+=c.nodeSize}),l.syncToMarks([],n,t),this.node.isTextblock&&l.addTextblockHacks(),l.destroyRest(),(l.changed||this.dirty==Gs)&&(s&&this.protectLocalComposition(t,s),vO(this.contentDOM,this.children,t),$l&&FD(this.dom))}localCompositionInfo(t,r){let{from:n,to:o}=t.state.selection;if(!(t.state.selection instanceof ue)||nr+this.node.content.size)return null;let i=t.domSelectionRange(),s=UD(i.focusNode,i.focusOffset);if(!s||!this.dom.contains(s.parentNode))return null;if(this.node.inlineContent){let a=s.nodeValue,l=VD(this.node.content,a,n-r,o-r);return l<0?null:{node:s,pos:l,text:a}}else return{node:s,pos:-1,text:""}}protectLocalComposition(t,{node:r,pos:n,text:o}){if(this.getDesc(r))return;let i=r;for(;i.parentNode!=this.contentDOM;i=i.parentNode){for(;i.previousSibling;)i.parentNode.removeChild(i.previousSibling);for(;i.nextSibling;)i.parentNode.removeChild(i.nextSibling);i.pmViewDesc&&(i.pmViewDesc=void 0)}let s=new LD(this,i,r,o);t.input.compositionNodes.push(s),this.children=t0(this.children,n,n+o.length,t,s)}update(t,r,n,o){return this.dirty==Io||!t.sameMarkup(this.node)?!1:(this.updateInner(t,r,n,o),!0)}updateInner(t,r,n,o){this.updateOuterDeco(r),this.node=t,this.innerDeco=n,this.contentDOM&&this.updateChildren(o,this.posAtStart),this.dirty=In}updateOuterDeco(t){if(e0(t,this.outerDeco))return;let r=this.nodeDOM.nodeType!=1,n=this.dom;this.dom=bO(this.dom,this.nodeDOM,Q1(this.outerDeco,this.node,r),Q1(t,this.node,r)),this.dom!=n&&(n.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=t}selectNode(){this.nodeDOM.nodeType==1&&this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.dom.draggable=!0)}deselectNode(){this.nodeDOM.nodeType==1&&this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.dom.removeAttribute("draggable")}get domAtom(){return this.node.isAtom}}function sS(e,t,r,n,o){EO(n,t,e);let i=new Wi(void 0,e,t,r,n,n,n,o,0);return i.contentDOM&&i.updateChildren(o,0),i}class Jh extends Wi{constructor(t,r,n,o,i,s,a){super(t,r,n,o,i,null,s,a,0)}parseRule(){let t=this.nodeDOM.parentNode;for(;t&&t!=this.dom&&!t.pmIsDeco;)t=t.parentNode;return{skip:t||!0}}update(t,r,n,o){return this.dirty==Io||this.dirty!=In&&!this.inParent()||!t.sameMarkup(this.node)?!1:(this.updateOuterDeco(r),(this.dirty!=In||t.text!=this.node.text)&&t.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=t.text,o.trackWrites==this.nodeDOM&&(o.trackWrites=null)),this.node=t,this.dirty=In,!0)}inParent(){let t=this.parent.contentDOM;for(let r=this.nodeDOM;r;r=r.parentNode)if(r==t)return!0;return!1}domFromPos(t){return{node:this.nodeDOM,offset:t}}localPosFromDOM(t,r,n){return t==this.nodeDOM?this.posAtStart+Math.min(r,this.node.text.length):super.localPosFromDOM(t,r,n)}ignoreMutation(t){return t.type!="characterData"&&t.type!="selection"}slice(t,r,n){let o=this.node.cut(t,r),i=document.createTextNode(o.text);return new Jh(this.parent,o,this.outerDeco,this.innerDeco,i,i,n)}markDirty(t,r){super.markDirty(t,r),this.dom!=this.nodeDOM&&(t==0||r==this.nodeDOM.nodeValue.length)&&(this.dirty=Io)}get domAtom(){return!1}}class yO extends Ud{parseRule(){return{ignore:!0}}matchesHack(t){return this.dirty==In&&this.dom.nodeName==t}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class DD extends Wi{constructor(t,r,n,o,i,s,a,l,c,u){super(t,r,n,o,i,s,a,c,u),this.spec=l}update(t,r,n,o){if(this.dirty==Io)return!1;if(this.spec.update){let i=this.spec.update(t,r,n);return i&&this.updateInner(t,r,n,o),i}else return!this.contentDOM&&!t.isLeaf?!1:super.update(t,r,n,o)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(t,r,n,o){this.spec.setSelection?this.spec.setSelection(t,r,n):super.setSelection(t,r,n,o)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(t){return this.spec.stopEvent?this.spec.stopEvent(t):!1}ignoreMutation(t){return this.spec.ignoreMutation?this.spec.ignoreMutation(t):super.ignoreMutation(t)}}function vO(e,t,r){let n=e.firstChild,o=!1;for(let i=0;i>1,s=Math.min(i,t.length);for(;o-1)a>this.index&&(this.changed=!0,this.destroyBetween(this.index,a)),this.top=this.top.children[this.index];else{let l=ca.create(this.top,t[i],r,n);this.top.children.splice(this.index,0,l),this.top=l,this.changed=!0}this.index=0,i++}}findNodeMatch(t,r,n,o){let i=-1,s;if(o>=this.preMatch.index&&(s=this.preMatch.matches[o-this.preMatch.index]).parent==this.top&&s.matchesNode(t,r,n))i=this.top.children.indexOf(s,this.index);else for(let a=this.index,l=Math.min(this.top.children.length,a+5);a0;){let a;for(;;)if(n){let c=r.children[n-1];if(c instanceof ca)r=c,n=c.children.length;else{a=c,n--;break}}else{if(r==t)break e;n=r.parent.children.indexOf(r),r=r.parent}let l=a.node;if(l){if(l!=e.child(o-1))break;--o,i.set(a,o),s.push(a)}}return{index:o,matched:i,matches:s.reverse()}}function BD(e,t){return e.type.side-t.type.side}function HD(e,t,r,n){let o=t.locals(e),i=0;if(o.length==0){for(let c=0;ci;)a.push(o[s++]);let h=i+p.nodeSize;if(p.isText){let b=h;s!b.inline):a.slice();n(p,m,t.forChild(i,p),f),i=h}}function FD(e){if(e.nodeName=="UL"||e.nodeName=="OL"){let t=e.style.cssText;e.style.cssText=t+"; list-style: square !important",window.getComputedStyle(e).listStyle,e.style.cssText=t}}function UD(e,t){for(;;){if(e.nodeType==3)return e;if(e.nodeType==1&&t>0){if(e.childNodes.length>t&&e.childNodes[t].nodeType==3)return e.childNodes[t];e=e.childNodes[t-1],t=ko(e)}else if(e.nodeType==1&&t=r){if(i>=n&&l.slice(n-t.length-a,n-a)==t)return n-t.length;let c=a=0&&c+t.length+a>=r)return a+c;if(r==n&&l.length>=n+t.length-a&&l.slice(n-a,n-a+t.length)==t)return n}}return-1}function t0(e,t,r,n,o){let i=[];for(let s=0,a=0;s=r||u<=t?i.push(l):(cr&&i.push(l.slice(r-c,l.size,n)))}return i}function Zy(e,t=null){let r=e.domSelectionRange(),n=e.state.doc;if(!r.focusNode)return null;let o=e.docView.nearestDesc(r.focusNode),i=o&&o.size==0,s=e.docView.posFromDOM(r.focusNode,r.focusOffset,1);if(s<0)return null;let a=n.resolve(s),l,c;if(Zh(r)){for(l=a;o&&!o.node;)o=o.parent;let u=o.node;if(o&&u.isAtom&&de.isSelectable(u)&&o.parent&&!(u.isInline&&fD(r.focusNode,r.focusOffset,o.dom))){let d=o.posBefore;c=new de(s==d?a:n.resolve(d))}}else{let u=e.docView.posFromDOM(r.anchorNode,r.anchorOffset,1);if(u<0)return null;l=n.resolve(u)}if(!c){let u=t=="pointer"||e.state.selection.head{(r.anchorNode!=n||r.anchorOffset!=o)&&(t.removeEventListener("selectionchange",e.input.hideSelectionGuard),setTimeout(()=>{(!kO(e)||e.state.selection.visible)&&e.dom.classList.remove("ProseMirror-hideselection")},20))})}function GD(e){let t=e.domSelection(),r=document.createRange(),n=e.cursorWrapper.dom,o=n.nodeName=="IMG";o?r.setEnd(n.parentNode,Er(n)+1):r.setEnd(n,0),r.collapse(!1),t.removeAllRanges(),t.addRange(r),!o&&!e.state.selection.visible&&Hr&&Gi<=11&&(n.disabled=!0,n.disabled=!1)}function xO(e,t){if(t instanceof de){let r=e.docView.descAt(t.from);r!=e.lastSelectedViewDesc&&(dS(e),r&&r.selectNode(),e.lastSelectedViewDesc=r)}else dS(e)}function dS(e){e.lastSelectedViewDesc&&(e.lastSelectedViewDesc.parent&&e.lastSelectedViewDesc.deselectNode(),e.lastSelectedViewDesc=void 0)}function Jy(e,t,r,n){return e.someProp("createSelectionBetween",o=>o(e,t,r))||ue.between(t,r,n)}function pS(e){return e.editable&&!e.hasFocus()?!1:SO(e)}function SO(e){let t=e.domSelectionRange();if(!t.anchorNode)return!1;try{return e.dom.contains(t.anchorNode.nodeType==3?t.anchorNode.parentNode:t.anchorNode)&&(e.editable||e.dom.contains(t.focusNode.nodeType==3?t.focusNode.parentNode:t.focusNode))}catch{return!1}}function WD(e){let t=e.docView.domFromPos(e.state.selection.anchor,0),r=e.domSelectionRange();return la(t.node,t.offset,r.anchorNode,r.anchorOffset)}function r0(e,t){let{$anchor:r,$head:n}=e.selection,o=t>0?r.max(n):r.min(n),i=o.parent.inlineContent?o.depth?e.doc.resolve(t>0?o.after():o.before()):null:o;return i&&ke.findFrom(i,t)}function _i(e,t){return e.dispatch(e.state.tr.setSelection(t).scrollIntoView()),!0}function fS(e,t,r){let n=e.state.selection;if(n instanceof ue)if(r.indexOf("s")>-1){let{$head:o}=n,i=o.textOffset?null:t<0?o.nodeBefore:o.nodeAfter;if(!i||i.isText||!i.isLeaf)return!1;let s=e.state.doc.resolve(o.pos+i.nodeSize*(t<0?-1:1));return _i(e,new ue(n.$anchor,s))}else if(n.empty){if(e.endOfTextblock(t>0?"forward":"backward")){let o=r0(e.state,t);return o&&o instanceof de?_i(e,o):!1}else if(!(Cn&&r.indexOf("m")>-1)){let o=n.$head,i=o.textOffset?null:t<0?o.nodeBefore:o.nodeAfter,s;if(!i||i.isText)return!1;let a=t<0?o.pos-i.nodeSize:o.pos;return i.isAtom||(s=e.docView.descAt(a))&&!s.contentDOM?de.isSelectable(i)?_i(e,new de(t<0?e.state.doc.resolve(o.pos-i.nodeSize):o)):Fd?_i(e,new ue(e.state.doc.resolve(t<0?a:a+i.nodeSize))):!1:!1}}else return!1;else{if(n instanceof de&&n.node.isInline)return _i(e,new ue(t>0?n.$to:n.$from));{let o=r0(e.state,t);return o?_i(e,o):!1}}}function $f(e){return e.nodeType==3?e.nodeValue.length:e.childNodes.length}function Cu(e,t){let r=e.pmViewDesc;return r&&r.size==0&&(t<0||e.nextSibling||e.nodeName!="BR")}function $a(e,t){return t<0?KD(e):YD(e)}function KD(e){let t=e.domSelectionRange(),r=t.focusNode,n=t.focusOffset;if(!r)return;let o,i,s=!1;for(ao&&r.nodeType==1&&n<$f(r)&&Cu(r.childNodes[n],-1)&&(s=!0);;)if(n>0){if(r.nodeType!=1)break;{let a=r.childNodes[n-1];if(Cu(a,-1))o=r,i=--n;else if(a.nodeType==3)r=a,n=r.nodeValue.length;else break}}else{if(wO(r))break;{let a=r.previousSibling;for(;a&&Cu(a,-1);)o=r.parentNode,i=Er(a),a=a.previousSibling;if(a)r=a,n=$f(r);else{if(r=r.parentNode,r==e.dom)break;n=0}}}s?n0(e,r,n):o&&n0(e,o,i)}function YD(e){let t=e.domSelectionRange(),r=t.focusNode,n=t.focusOffset;if(!r)return;let o=$f(r),i,s;for(;;)if(n{e.state==o&&oi(e)},50)}function hS(e,t){let r=e.state.doc.resolve(t);if(!(hr||yD)&&r.parent.inlineContent){let o=e.coordsAtPos(t);if(t>r.start()){let i=e.coordsAtPos(t-1),s=(i.top+i.bottom)/2;if(s>o.top&&s1)return i.lefto.top&&s1)return i.left>o.left?"ltr":"rtl"}}return getComputedStyle(e.dom).direction=="rtl"?"rtl":"ltr"}function mS(e,t,r){let n=e.state.selection;if(n instanceof ue&&!n.empty||r.indexOf("s")>-1||Cn&&r.indexOf("m")>-1)return!1;let{$from:o,$to:i}=n;if(!o.parent.inlineContent||e.endOfTextblock(t<0?"up":"down")){let s=r0(e.state,t);if(s&&s instanceof de)return _i(e,s)}if(!o.parent.inlineContent){let s=t<0?o:i,a=n instanceof xr?ke.near(s,t):ke.findFrom(s,t);return a?_i(e,a):!1}return!1}function gS(e,t){if(!(e.state.selection instanceof ue))return!0;let{$head:r,$anchor:n,empty:o}=e.state.selection;if(!r.sameParent(n))return!0;if(!o)return!1;if(e.endOfTextblock(t>0?"forward":"backward"))return!0;let i=!r.textOffset&&(t<0?r.nodeBefore:r.nodeAfter);if(i&&!i.isText){let s=e.state.tr;return t<0?s.delete(r.pos-i.nodeSize,r.pos):s.delete(r.pos,r.pos+i.nodeSize),e.dispatch(s),!0}return!1}function yS(e,t,r){e.domObserver.stop(),t.contentEditable=r,e.domObserver.start()}function ZD(e){if(!Tr||e.state.selection.$head.parentOffset>0)return!1;let{focusNode:t,focusOffset:r}=e.domSelectionRange();if(t&&t.nodeType==1&&r==0&&t.firstChild&&t.firstChild.contentEditable=="false"){let n=t.firstChild;yS(e,n,"true"),setTimeout(()=>yS(e,n,"false"),20)}return!1}function JD(e){let t="";return e.ctrlKey&&(t+="c"),e.metaKey&&(t+="m"),e.altKey&&(t+="a"),e.shiftKey&&(t+="s"),t}function QD(e,t){let r=t.keyCode,n=JD(t);if(r==8||Cn&&r==72&&n=="c")return gS(e,-1)||$a(e,-1);if(r==46&&!t.shiftKey||Cn&&r==68&&n=="c")return gS(e,1)||$a(e,1);if(r==13||r==27)return!0;if(r==37||Cn&&r==66&&n=="c"){let o=r==37?hS(e,e.state.selection.from)=="ltr"?-1:1:-1;return fS(e,o,n)||$a(e,o)}else if(r==39||Cn&&r==70&&n=="c"){let o=r==39?hS(e,e.state.selection.from)=="ltr"?1:-1:1;return fS(e,o,n)||$a(e,o)}else{if(r==38||Cn&&r==80&&n=="c")return mS(e,-1,n)||$a(e,-1);if(r==40||Cn&&r==78&&n=="c")return ZD(e)||mS(e,1,n)||$a(e,1);if(n==(Cn?"m":"c")&&(r==66||r==73||r==89||r==90))return!0}return!1}function TO(e,t){e.someProp("transformCopied",f=>{t=f(t,e)});let r=[],{content:n,openStart:o,openEnd:i}=t;for(;o>1&&i>1&&n.childCount==1&&n.firstChild.childCount==1;){o--,i--;let f=n.firstChild;r.push(f.type.name,f.attrs!=f.type.defaultAttrs?f.attrs:null),n=f.content}let s=e.someProp("clipboardSerializer")||un.fromSchema(e.state.schema),a=_O(),l=a.createElement("div");l.appendChild(s.serializeFragment(n,{document:a}));let c=l.firstChild,u,d=0;for(;c&&c.nodeType==1&&(u=RO[c.nodeName.toLowerCase()]);){for(let f=u.length-1;f>=0;f--){let h=a.createElement(u[f]);for(;l.firstChild;)h.appendChild(l.firstChild);l.appendChild(h),d++}c=l.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${o} ${i}${d?` -${d}`:""} ${JSON.stringify(r)}`);let p=e.someProp("clipboardTextSerializer",f=>f(t,e))||t.content.textBetween(0,t.content.size,`
+other {Heading}}`,comment:"Label for heading command with support for levels."};var s5=Object.freeze({__proto__:null,LABEL:i5});const a5={id:"extension.command.undo.label",message:"Undo",comment:"Label for undo."},l5={id:"extension.command.undo.description",message:"Undo the most recent action",comment:"Description for undo."},c5={id:"extension.command.redo.label",message:"Redo",comment:"Label for redo."},u5={id:"extension.command.redo.description",message:"Redo the most recent action",comment:"Description for redo."};var jp=Object.freeze({__proto__:null,REDO_DESCRIPTION:u5,REDO_LABEL:c5,UNDO_DESCRIPTION:l5,UNDO_LABEL:a5});const d5={id:"extension.command.insert-horizontal-rule.label",message:"Divider",comment:"Label for inserting a horizontal rule (divider) command."},h5={id:"extension.command.insert-horizontal-rule.description",message:"Separate content with a diving horizontal line",comment:"Description for inserting a horizontal rule (divider) command."};var xS=Object.freeze({__proto__:null,DESCRIPTION:h5,LABEL:d5});const f5={id:"extension.command.toggle-italic.label",message:"Italic",comment:"Label for italic formatting command."},p5={id:"extension.command.toggle-italic.description",message:"Italicize the selected text",comment:"Description for italic formatting command."};var kS=Object.freeze({__proto__:null,DESCRIPTION:p5,LABEL:f5});const g5={id:"extension.command.toggle-ordered-list.label",message:"Ordered list",comment:"Label for inserting an ordered list into the editor."},m5={id:"extension.command.toggle-bullet-list.description",message:"Bulleted list",comment:"Description for inserting a bullet list into the editor."},v5={id:"extension.command.toggle-task-list.description",message:"Tasked list",comment:"Description for inserting a task list into the editor."};var bb=Object.freeze({__proto__:null,BULLET_LIST_LABEL:m5,ORDERED_LIST_LABEL:g5,TASK_LIST_LABEL:v5});const y5={id:"extension.command.insert-paragraph.label",message:"Insert Paragraph",comment:"Label for inserting a paragraph."},b5={id:"extension.command.insert-paragraph.description",message:"Insert a new paragraph",comment:"Description for inserting a paragraph."},w5={id:"extension.command.convert-paragraph.label",message:"Convert Paragraph",comment:"Label for converting the current node into a paragraph."},x5={id:"extension.command.convert-paragraph.description",message:"Convert current block into a paragraph block.",comment:"Description for converting a paragraph."};var Gp=Object.freeze({__proto__:null,CONVERT_DESCRIPTION:x5,CONVERT_LABEL:w5,INSERT_DESCRIPTION:b5,INSERT_LABEL:y5});const k5={id:"extension.command.toggle-strike.label",message:"Strikethrough",comment:"Label for strike formatting command."},E5={id:"extension.command.toggle-strike.description",message:"Strikethrough the selected text",comment:"Description for strike formatting command."};var ES=Object.freeze({__proto__:null,DESCRIPTION:E5,LABEL:k5});const S5={id:"extension.command.toggle-underline.label",message:"Underline",comment:"Label for underline formatting command."},C5={id:"extension.command.toggle-underline.description",message:"Underline the selected text",comment:"Description for underline formatting command."};var SS=Object.freeze({__proto__:null,DESCRIPTION:C5,LABEL:S5});class ml{constructor(e,n){this.match=e,this.match=e,this.handler=typeof n=="string"?T5(n):n}}function T5(t){return function(e,n,r,o){let i=t;if(n[1]){let s=n[0].lastIndexOf(n[1]);i+=n[0].slice(s+n[1].length),r+=s;let l=r-o;l>0&&(i=n[0].slice(s-l,s)+i,r=o)}return e.tr.insertText(i,r,o)}}const A5=500;function _5({rules:t}){let e=new gi({state:{init(){return null},apply(n,r){let o=n.getMeta(this);return o||(n.selectionSet||n.docChanged?null:r)}},props:{handleTextInput(n,r,o,i){return CS(n,r,o,i,t,e)},handleDOMEvents:{compositionend:n=>{setTimeout(()=>{let{$cursor:r}=n.state.selection;r&&CS(n,r.pos,r.pos,"",t,e)})}}},isInputRules:!0});return e}function CS(t,e,n,r,o,i){if(t.composing)return!1;let s=t.state,l=s.doc.resolve(e);if(l.parent.type.spec.code)return!1;let a=l.parent.textBetween(Math.max(0,l.parentOffset-A5),l.parentOffset,null,"")+r;for(let u=0;u{let n=t.plugins;for(let r=0;r=0;a--)s.step(l.steps[a].invert(l.docs[a]));if(i.text){let a=s.doc.resolve(i.from).marks();s.replaceWith(i.from,i.to,t.schema.text(i.text,a))}else s.delete(i.from,i.to);e(s)}return!0}}return!1};function am(t,e,n=null,r){return new ml(t,(o,i,s,l)=>{let a=n instanceof Function?n(i):n,u=o.tr.delete(s,l),c=u.doc.resolve(s),d=c.blockRange(),h=d&&mb(d,e,a);if(!h)return null;u.wrap(d,h);let f=u.doc.resolve(s-1).nodeBefore;return f&&f.type==e&&zh(u.doc,s-1)&&(!r||r(i,f))&&u.join(s-1),u})}function M5(t,e,n=null){return new ml(t,(r,o,i,s)=>{let l=r.doc.resolve(i),a=n instanceof Function?n(o):n;return l.node(-1).canReplaceWith(l.index(-1),l.indexAfter(-1),e)?r.tr.delete(i,s).setBlockType(i,i,e,a):null})}const nr=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},Ud=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let TS=null;const Ai=function(t,e,n){let r=TS||(TS=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r},qa=function(t,e,n,r){return n&&(AS(t,e,n,r,-1)||AS(t,e,n,r,1))},O5=/^(img|br|input|textarea|hr)$/i;function AS(t,e,n,r,o){for(;;){if(t==n&&e==r)return!0;if(e==(o<0?0:ei(t))){let i=t.parentNode;if(!i||i.nodeType!=1||wb(t)||O5.test(t.nodeName)||t.contentEditable=="false")return!1;e=nr(t)+(o<0?0:1),t=i}else if(t.nodeType==1){if(t=t.childNodes[e+(o<0?-1:0)],t.contentEditable=="false")return!1;e=o<0?ei(t):0}else return!1}}function ei(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function I5(t,e,n){for(let r=e==0,o=e==ei(t);r||o;){if(t==n)return!0;let i=nr(t);if(t=t.parentNode,!t)return!1;r=r&&i==0,o=o&&i==ei(t)}}function wb(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 lm=function(t){return t.focusNode&&qa(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function Ma(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}function L5(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function N5(t,e,n){if(t.caretPositionFromPoint)try{let r=t.caretPositionFromPoint(e,n);if(r)return{node:r.offsetNode,offset:r.offset}}catch{}if(t.caretRangeFromPoint){let r=t.caretRangeFromPoint(e,n);if(r)return{node:r.startContainer,offset:r.startOffset}}}const ui=typeof navigator<"u"?navigator:null,_S=typeof document<"u"?document:null,Qs=ui&&ui.userAgent||"",b0=/Edge\/(\d+)/.exec(Qs),KR=/MSIE \d/.exec(Qs),w0=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Qs),xr=!!(KR||w0||b0),As=KR?document.documentMode:w0?+w0[1]:b0?+b0[1]:0,Ho=!xr&&/gecko\/(\d+)/i.test(Qs);Ho&&+(/Firefox\/(\d+)/.exec(Qs)||[0,0])[1];const x0=!xr&&/Chrome\/(\d+)/.exec(Qs),Kn=!!x0,$5=x0?+x0[1]:0,ar=!xr&&!!ui&&/Apple Computer/.test(ui.vendor),Nc=ar&&(/Mobile\/\w+/.test(Qs)||!!ui&&ui.maxTouchPoints>2),oo=Nc||(ui?/Mac/.test(ui.platform):!1),D5=ui?/Win/.test(ui.platform):!1,Lo=/Android \d/.test(Qs),Fh=!!_S&&"webkitFontSmoothing"in _S.documentElement.style,P5=Fh?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function z5(t){return{left:0,right:t.documentElement.clientWidth,top:0,bottom:t.documentElement.clientHeight}}function wi(t,e){return typeof t=="number"?t:t[e]}function F5(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 RS(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=Ud(s)){if(s.nodeType!=1)continue;let l=s,a=l==i.body,u=a?z5(i):F5(l),c=0,d=0;if(e.topu.bottom-wi(r,"bottom")&&(d=e.bottom-e.top>u.bottom-u.top?e.top+wi(o,"top")-u.top:e.bottom-u.bottom+wi(o,"bottom")),e.leftu.right-wi(r,"right")&&(c=e.right-u.right+wi(o,"right")),c||d)if(a)i.defaultView.scrollBy(c,d);else{let h=l.scrollLeft,f=l.scrollTop;d&&(l.scrollTop+=d),c&&(l.scrollLeft+=c);let p=l.scrollLeft-h,g=l.scrollTop-f;e={left:e.left-p,top:e.top-g,right:e.right-p,bottom:e.bottom-g}}if(a||/^(fixed|sticky)$/.test(getComputedStyle(s).position))break}}function B5(t){let e=t.dom.getBoundingClientRect(),n=Math.max(0,e.top),r,o;for(let i=(e.left+e.right)/2,s=n+1;s=n-20){r=l,o=a.top;break}}return{refDOM:r,refTop:o,stack:YR(t.dom)}}function YR(t){let e=[],n=t.ownerDocument;for(let r=t;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t!=n);r=Ud(r));return e}function H5({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;XR(n,r==0?0:r-e)}function XR(t,e){for(let n=0;n=l){s=Math.max(p.bottom,s),l=Math.min(p.top,l);let g=p.left>e.left?p.left-e.left:p.right=(p.left+p.right)/2?1:0));continue}}else p.top>e.top&&!a&&p.left<=e.left&&p.right>=e.left&&(a=c,u={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)&&(i=d+1)}}return!n&&a&&(n=a,o=u,r=0),n&&n.nodeType==3?W5(n,o):!n||r&&n.nodeType==1?{node:t,offset:i}:qR(n,o)}function W5(t,e){let n=t.nodeValue.length,r=document.createRange();for(let o=0;o=(i.left+i.right)/2?1:0)}}return{node:t,offset:0}}function xb(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function V5(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left(s.left+s.right)/2?1:-1}return t.docView.posFromDOM(r,o,i)}function G5(t,e,n,r){let o=-1;for(let i=e,s=!1;i!=t.dom;){let l=t.docView.nearestDesc(i,!0);if(!l)return null;if(l.dom.nodeType==1&&(l.node.isBlock&&l.parent&&!s||!l.contentDOM)){let a=l.dom.getBoundingClientRect();if(l.node.isBlock&&l.parent&&!s&&(s=!0,a.left>r.left||a.top>r.top?o=l.posBefore:(a.right-1?o:t.docView.posFromDOM(e,n,-1)}function ZR(t,e,n){let r=t.childNodes.length;if(r&&n.tope.top&&o++}let u;Fh&&o&&r.nodeType==1&&(u=r.childNodes[o-1]).nodeType==1&&u.contentEditable=="false"&&u.getBoundingClientRect().top>=e.top&&o--,r==t.dom&&o==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?l=t.state.doc.content.size:(o==0||r.nodeType!=1||r.childNodes[o-1].nodeName!="BR")&&(l=G5(t,r,o,e))}l==null&&(l=j5(t,s,e));let a=t.docView.nearestDesc(s,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function MS(t){return t.top=0&&o==r.nodeValue.length?(a--,c=1):n<0?a--:u++,Eu(as(Ai(r,a,u),c),c<0)}if(!t.state.doc.resolve(e-(i||0)).parent.inlineContent){if(i==null&&o&&(n<0||o==ei(r))){let a=r.childNodes[o-1];if(a.nodeType==1)return t1(a.getBoundingClientRect(),!1)}if(i==null&&o=0)}if(i==null&&o&&(n<0||o==ei(r))){let a=r.childNodes[o-1],u=a.nodeType==3?Ai(a,ei(a)-(s?0:1)):a.nodeType==1&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(u)return Eu(as(u,1),!1)}if(i==null&&o=0)}function Eu(t,e){if(t.width==0)return t;let n=e?t.left:t.right;return{top:t.top,bottom:t.bottom,left:n,right:n}}function t1(t,e){if(t.height==0)return t;let n=e?t.top:t.bottom;return{top:n,bottom:n,left:t.left,right:t.right}}function JR(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()}}function X5(t,e,n){let r=e.selection,o=n=="up"?r.$from:r.$to;return JR(t,e,()=>{let{node:i}=t.docView.domFromPos(o.pos,n=="up"?-1:1);for(;;){let l=t.docView.nearestDesc(i,!0);if(!l)break;if(l.node.isBlock){i=l.contentDOM||l.dom;break}i=l.dom.parentNode}let s=QR(t,o.pos,1);for(let l=i.firstChild;l;l=l.nextSibling){let a;if(l.nodeType==1)a=l.getClientRects();else if(l.nodeType==3)a=Ai(l,0,l.nodeValue.length).getClientRects();else continue;for(let u=0;uc.top+1&&(n=="up"?s.top-c.top>(c.bottom-s.top)*2:c.bottom-s.bottom>(s.bottom-c.top)*2))return!1}}return!0})}const q5=/[\u0590-\u08ac]/;function Z5(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,l=t.domSelection();return!q5.test(r.parent.textContent)||!l.modify?n=="left"||n=="backward"?i:s:JR(t,e,()=>{let{focusNode:a,focusOffset:u,anchorNode:c,anchorOffset:d}=t.domSelectionRange(),h=l.caretBidiLevel;l.modify("move",n,"character");let f=r.depth?t.docView.domAfterPos(r.before()):t.dom,{focusNode:p,focusOffset:g}=t.domSelectionRange(),m=p&&!f.contains(p.nodeType==1?p:p.parentNode)||a==p&&u==g;try{l.collapse(c,d),a&&(a!=c||u!=d)&&l.extend&&l.extend(a,u)}catch{}return h!=null&&(l.caretBidiLevel=h),m})}let OS=null,IS=null,LS=!1;function Q5(t,e,n){return OS==e&&IS==n?LS:(OS=e,IS=n,LS=n=="up"||n=="down"?X5(t,e,n):Z5(t,e,n))}const uo=0,NS=1,La=2,di=3;class Bh{constructor(e,n,r,o){this.parent=e,this.children=n,this.dom=r,this.contentDOM=o,this.dirty=uo,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,n,r){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let n=0;nnr(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))o=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(n==0)for(let i=e;;i=i.parentNode){if(i==this.dom){o=!1;break}if(i.previousSibling)break}if(o==null&&n==e.childNodes.length)for(let i=e;;i=i.parentNode){if(i==this.dom){o=!0;break}if(i.nextSibling)break}}return o??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,n=!1){for(let r=!0,o=e;o;o=o.parentNode){let i=this.getDesc(o),s;if(i&&(!n||i.node))if(r&&(s=i.nodeDOM)&&!(s.nodeType==1?s.contains(e.nodeType==1?e:e.parentNode):s==e))r=!1;else return i}}getDesc(e){let n=e.pmViewDesc;for(let r=n;r;r=r.parent)if(r==this)return n}posFromDOM(e,n,r){for(let o=e;o;o=o.parentNode){let i=this.getDesc(o);if(i)return i.localPosFromDOM(e,n,r)}return-1}descAt(e){for(let n=0,r=0;ne||s instanceof t2){o=e-i;break}i=l}if(o)return this.children[r].domFromPos(o-this.children[r].border,n);for(let i;r&&!(i=this.children[r-1]).size&&i instanceof e2&&i.side>=0;r--);if(n<=0){let i,s=!0;for(;i=r?this.children[r-1]:null,!(!i||i.dom.parentNode==this.contentDOM);r--,s=!1);return i&&n&&s&&!i.border&&!i.domAtom?i.domFromPos(i.size,n):{node:this.contentDOM,offset:i?nr(i.dom)+1:0}}else{let i,s=!0;for(;i=r=c&&n<=u-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,n,c);e=s;for(let d=l;d>0;d--){let h=this.children[d-1];if(h.size&&h.dom.parentNode==this.contentDOM&&!h.emptyChildAt(1)){o=nr(h.dom)+1;break}e-=h.size}o==-1&&(o=0)}if(o>-1&&(u>n||l==this.children.length-1)){n=u;for(let c=l+1;cf&&sn){let f=l;l=a,a=f}let h=document.createRange();h.setEnd(a.node,a.offset),h.setStart(l.node,l.offset),u.removeAllRanges(),u.addRange(h)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,n){for(let r=0,o=0;o=r:er){let l=r+i.border,a=s-i.border;if(e>=l&&n<=a){this.dirty=e==r||n==s?La:NS,e==l&&n==a&&(i.contentLost||i.dom.parentNode!=this.contentDOM)?i.dirty=di:i.markDirty(e-l,n-l);return}else i.dirty=i.dom==i.contentDOM&&i.dom.parentNode==this.contentDOM&&!i.children.length?La:di}r=s}this.dirty=La}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let r=e==1?La:NS;n.dirty{if(!i)return o;if(i.parent)return i.parent.posBeforeChild(i)})),!n.type.spec.raw){if(s.nodeType!=1){let l=document.createElement("span");l.appendChild(s),s=l}s.contentEditable="false",s.classList.add("ProseMirror-widget")}super(e,[],s,null),this.widget=n,this.widget=n,i=this}matchesWidget(e){return this.dirty==uo&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let n=this.widget.spec.stopEvent;return n?n(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get side(){return this.widget.type.side}}class J5 extends Bh{constructor(e,n,r,o){super(e,[],n,null),this.textDOM=r,this.text=o}get size(){return this.text.length}localPosFromDOM(e,n){return e!=this.textDOM?this.posAtStart+(n?this.size:0):this.posAtStart+n}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}}class Za extends Bh{constructor(e,n,r,o){super(e,[],r,o),this.mark=n}static create(e,n,r,o){let i=o.nodeViews[n.type.name],s=i&&i(n,o,r);return(!s||!s.dom)&&(s=Ur.renderSpec(document,n.type.spec.toDOM(n,r))),new Za(e,n,s.dom,s.contentDOM||s.dom)}parseRule(){return this.dirty&di||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=di&&this.mark.eq(e)}markDirty(e,n){if(super.markDirty(e,n),this.dirty!=uo){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty0&&(i=S0(i,0,e,r));for(let l=0;l{if(!a)return s;if(a.parent)return a.parent.posBeforeChild(a)},r,o),c=u&&u.dom,d=u&&u.contentDOM;if(n.isText){if(!c)c=document.createTextNode(n.text);else if(c.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else c||({dom:c,contentDOM:d}=Ur.renderSpec(document,n.type.spec.toDOM(n)));!d&&!n.isText&&c.nodeName!="BR"&&(c.hasAttribute("contenteditable")||(c.contentEditable="false"),n.type.spec.draggable&&(c.draggable=!0));let h=c;return c=o2(c,r,n),u?a=new e3(e,n,r,o,c,d||null,h,u,i,s+1):n.isText?new cm(e,n,r,o,c,h,i):new _s(e,n,r,o,c,d||null,h,i,s+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(e.preserveWhitespace="full"),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let n=this.children.length-1;n>=0;n--){let r=this.children[n];if(this.dom.contains(r.dom.parentNode)){e.contentElement=r.dom.parentNode;break}}e.contentElement||(e.getContent=()=>Q.empty)}return e}matchesNode(e,n,r){return this.dirty==uo&&e.eq(this.node)&&E0(n,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,n){let r=this.node.inlineContent,o=n,i=e.composing?this.localCompositionInfo(e,n):null,s=i&&i.pos>-1?i:null,l=i&&i.pos<0,a=new n3(this,s&&s.node,e);i3(this.node,this.innerDeco,(u,c,d)=>{u.spec.marks?a.syncToMarks(u.spec.marks,r,e):u.type.side>=0&&!d&&a.syncToMarks(c==this.node.childCount?Ke.none:this.node.child(c).marks,r,e),a.placeWidget(u,e,o)},(u,c,d,h)=>{a.syncToMarks(u.marks,r,e);let f;a.findNodeMatch(u,c,d,h)||l&&e.state.selection.from>o&&e.state.selection.to-1&&a.updateNodeAt(u,c,d,f,e)||a.updateNextNode(u,c,d,e,h,o)||a.addNode(u,c,d,e,o),o+=u.nodeSize}),a.syncToMarks([],r,e),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==La)&&(s&&this.protectLocalComposition(e,s),n2(this.contentDOM,this.children,e),Nc&&s3(this.dom))}localCompositionInfo(e,n){let{from:r,to:o}=e.state.selection;if(!(e.state.selection instanceof Ie)||rn+this.node.content.size)return null;let i=e.domSelectionRange(),s=a3(i.focusNode,i.focusOffset);if(!s||!this.dom.contains(s.parentNode))return null;if(this.node.inlineContent){let l=s.nodeValue,a=l3(this.node.content,l,r-n,o-n);return a<0?null:{node:s,pos:a,text:l}}else return{node:s,pos:-1,text:""}}protectLocalComposition(e,{node:n,pos:r,text:o}){if(this.getDesc(n))return;let i=n;for(;i.parentNode!=this.contentDOM;i=i.parentNode){for(;i.previousSibling;)i.parentNode.removeChild(i.previousSibling);for(;i.nextSibling;)i.parentNode.removeChild(i.nextSibling);i.pmViewDesc&&(i.pmViewDesc=void 0)}let s=new J5(this,i,n,o);e.input.compositionNodes.push(s),this.children=S0(this.children,r,r+o.length,e,s)}update(e,n,r,o){return this.dirty==di||!e.sameMarkup(this.node)?!1:(this.updateInner(e,n,r,o),!0)}updateInner(e,n,r,o){this.updateOuterDeco(n),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(o,this.posAtStart),this.dirty=uo}updateOuterDeco(e){if(E0(e,this.outerDeco))return;let n=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=r2(this.dom,this.nodeDOM,k0(this.outerDeco,this.node,n),k0(e,this.node,n)),this.dom!=r&&(r.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.dom.draggable=!0)}deselectNode(){this.nodeDOM.nodeType==1&&this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.dom.removeAttribute("draggable")}get domAtom(){return this.node.isAtom}}function $S(t,e,n,r,o){o2(r,e,t);let i=new _s(void 0,t,e,n,r,r,r,o,0);return i.contentDOM&&i.updateChildren(o,0),i}class cm extends _s{constructor(e,n,r,o,i,s,l){super(e,n,r,o,i,null,s,l,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,n,r,o){return this.dirty==di||this.dirty!=uo&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(n),(this.dirty!=uo||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,o.trackWrites==this.nodeDOM&&(o.trackWrites=null)),this.node=e,this.dirty=uo,!0)}inParent(){let e=this.parent.contentDOM;for(let n=this.nodeDOM;n;n=n.parentNode)if(n==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,n,r){return e==this.nodeDOM?this.posAtStart+Math.min(n,this.node.text.length):super.localPosFromDOM(e,n,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,n,r){let o=this.node.cut(e,n),i=document.createTextNode(o.text);return new cm(this.parent,o,this.outerDeco,this.innerDeco,i,i,r)}markDirty(e,n){super.markDirty(e,n),this.dom!=this.nodeDOM&&(e==0||n==this.nodeDOM.nodeValue.length)&&(this.dirty=di)}get domAtom(){return!1}}class t2 extends Bh{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==uo&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class e3 extends _s{constructor(e,n,r,o,i,s,l,a,u,c){super(e,n,r,o,i,s,l,u,c),this.spec=a}update(e,n,r,o){if(this.dirty==di)return!1;if(this.spec.update){let i=this.spec.update(e,n,r);return i&&this.updateInner(e,n,r,o),i}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,n,r,o)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,n,r,o){this.spec.setSelection?this.spec.setSelection(e,n,r):super.setSelection(e,n,r,o)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function n2(t,e,n){let r=t.firstChild,o=!1;for(let i=0;i>1,s=Math.min(i,e.length);for(;o-1)l>this.index&&(this.changed=!0,this.destroyBetween(this.index,l)),this.top=this.top.children[this.index];else{let a=Za.create(this.top,e[i],n,r);this.top.children.splice(this.index,0,a),this.top=a,this.changed=!0}this.index=0,i++}}findNodeMatch(e,n,r,o){let i=-1,s;if(o>=this.preMatch.index&&(s=this.preMatch.matches[o-this.preMatch.index]).parent==this.top&&s.matchesNode(e,n,r))i=this.top.children.indexOf(s,this.index);else for(let l=this.index,a=Math.min(this.top.children.length,l+5);l0;){let l;for(;;)if(r){let u=n.children[r-1];if(u instanceof Za)n=u,r=u.children.length;else{l=u,r--;break}}else{if(n==e)break e;r=n.parent.children.indexOf(n),n=n.parent}let a=l.node;if(a){if(a!=t.child(o-1))break;--o,i.set(l,o),s.push(l)}}return{index:o,matched:i,matches:s.reverse()}}function o3(t,e){return t.type.side-e.type.side}function i3(t,e,n,r){let o=e.locals(t),i=0;if(o.length==0){for(let u=0;ui;)l.push(o[s++]);let p=i+h.nodeSize;if(h.isText){let m=p;s!m.inline):l.slice();r(h,g,e.forChild(i,h),f),i=p}}function s3(t){if(t.nodeName=="UL"||t.nodeName=="OL"){let e=t.style.cssText;t.style.cssText=e+"; list-style: square !important",window.getComputedStyle(t).listStyle,t.style.cssText=e}}function a3(t,e){for(;;){if(t.nodeType==3)return t;if(t.nodeType==1&&e>0){if(t.childNodes.length>e&&t.childNodes[e].nodeType==3)return t.childNodes[e];t=t.childNodes[e-1],e=ei(t)}else if(t.nodeType==1&&e=n){if(i>=r&&a.slice(r-e.length-l,r-l)==e)return r-e.length;let u=l=0&&u+e.length+l>=n)return l+u;if(n==r&&a.length>=r+e.length-l&&a.slice(r-l,r-l+e.length)==e)return r}}return-1}function S0(t,e,n,r,o){let i=[];for(let s=0,l=0;s=n||c<=e?i.push(a):(un&&i.push(a.slice(n-u,a.size,r)))}return i}function kb(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&&o.size==0,s=t.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(s<0)return null;let l=r.resolve(s),a,u;if(lm(n)){for(a=l;o&&!o.node;)o=o.parent;let c=o.node;if(o&&c.isAtom&&Le.isSelectable(c)&&o.parent&&!(c.isInline&&I5(n.focusNode,n.focusOffset,o.dom))){let d=o.posBefore;u=new Le(s==d?l:r.resolve(d))}}else{let c=t.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(c<0)return null;a=r.resolve(c)}if(!u){let c=e=="pointer"||t.state.selection.head{(n.anchorNode!=r||n.anchorOffset!=o)&&(e.removeEventListener("selectionchange",t.input.hideSelectionGuard),setTimeout(()=>{(!i2(t)||t.state.selection.visible)&&t.dom.classList.remove("ProseMirror-hideselection")},20))})}function u3(t){let e=t.domSelection(),n=document.createRange(),r=t.cursorWrapper.dom,o=r.nodeName=="IMG";o?n.setEnd(r.parentNode,nr(r)+1):n.setEnd(r,0),n.collapse(!1),e.removeAllRanges(),e.addRange(n),!o&&!t.state.selection.visible&&xr&&As<=11&&(r.disabled=!0,r.disabled=!1)}function s2(t,e){if(e instanceof Le){let n=t.docView.descAt(e.from);n!=t.lastSelectedViewDesc&&(BS(t),n&&n.selectNode(),t.lastSelectedViewDesc=n)}else BS(t)}function BS(t){t.lastSelectedViewDesc&&(t.lastSelectedViewDesc.parent&&t.lastSelectedViewDesc.deselectNode(),t.lastSelectedViewDesc=void 0)}function Eb(t,e,n,r){return t.someProp("createSelectionBetween",o=>o(t,e,n))||Ie.between(e,n,r)}function HS(t){return t.editable&&!t.hasFocus()?!1:a2(t)}function a2(t){let e=t.domSelectionRange();if(!e.anchorNode)return!1;try{return t.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(t.editable||t.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function d3(t){let e=t.docView.domFromPos(t.state.selection.anchor,0),n=t.domSelectionRange();return qa(e.node,e.offset,n.anchorNode,n.anchorOffset)}function C0(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&&Ue.findFrom(i,e)}function fs(t,e){return t.dispatch(t.state.tr.setSelection(e).scrollIntoView()),!0}function US(t,e,n){let r=t.state.selection;if(r instanceof Ie)if(n.indexOf("s")>-1){let{$head:o}=r,i=o.textOffset?null:e<0?o.nodeBefore:o.nodeAfter;if(!i||i.isText||!i.isLeaf)return!1;let s=t.state.doc.resolve(o.pos+i.nodeSize*(e<0?-1:1));return fs(t,new Ie(r.$anchor,s))}else if(r.empty){if(t.endOfTextblock(e>0?"forward":"backward")){let o=C0(t.state,e);return o&&o instanceof Le?fs(t,o):!1}else if(!(oo&&n.indexOf("m")>-1)){let o=r.$head,i=o.textOffset?null:e<0?o.nodeBefore:o.nodeAfter,s;if(!i||i.isText)return!1;let l=e<0?o.pos-i.nodeSize:o.pos;return i.isAtom||(s=t.docView.descAt(l))&&!s.contentDOM?Le.isSelectable(i)?fs(t,new Le(e<0?t.state.doc.resolve(o.pos-i.nodeSize):o)):Fh?fs(t,new Ie(t.state.doc.resolve(e<0?l:l+i.nodeSize))):!1:!1}}else return!1;else{if(r instanceof Le&&r.node.isInline)return fs(t,new Ie(e>0?r.$to:r.$from));{let o=C0(t.state,e);return o?fs(t,o):!1}}}function Kp(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function Ed(t,e){let n=t.pmViewDesc;return n&&n.size==0&&(e<0||t.nextSibling||t.nodeName!="BR")}function Ll(t,e){return e<0?h3(t):f3(t)}function h3(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let o,i,s=!1;for(Ho&&n.nodeType==1&&r0){if(n.nodeType!=1)break;{let l=n.childNodes[r-1];if(Ed(l,-1))o=n,i=--r;else if(l.nodeType==3)n=l,r=n.nodeValue.length;else break}}else{if(l2(n))break;{let l=n.previousSibling;for(;l&&Ed(l,-1);)o=n.parentNode,i=nr(l),l=l.previousSibling;if(l)n=l,r=Kp(n);else{if(n=n.parentNode,n==t.dom)break;r=0}}}s?T0(t,n,r):o&&T0(t,o,i)}function f3(t){let e=t.domSelectionRange(),n=e.focusNode,r=e.focusOffset;if(!n)return;let o=Kp(n),i,s;for(;;)if(r{t.state==o&&zi(t)},50)}function WS(t,e){let n=t.state.doc.resolve(e);if(!(Kn||D5)&&n.parent.inlineContent){let o=t.coordsAtPos(e);if(e>n.start()){let i=t.coordsAtPos(e-1),s=(i.top+i.bottom)/2;if(s>o.top&&s1)return i.lefto.top&&s1)return i.left>o.left?"ltr":"rtl"}}return getComputedStyle(t.dom).direction=="rtl"?"rtl":"ltr"}function VS(t,e,n){let r=t.state.selection;if(r instanceof Ie&&!r.empty||n.indexOf("s")>-1||oo&&n.indexOf("m")>-1)return!1;let{$from:o,$to:i}=r;if(!o.parent.inlineContent||t.endOfTextblock(e<0?"up":"down")){let s=C0(t.state,e);if(s&&s instanceof Le)return fs(t,s)}if(!o.parent.inlineContent){let s=e<0?o:i,l=r instanceof or?Ue.near(s,e):Ue.findFrom(s,e);return l?fs(t,l):!1}return!1}function jS(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 s=t.state.tr;return e<0?s.delete(n.pos-i.nodeSize,n.pos):s.delete(n.pos,n.pos+i.nodeSize),t.dispatch(s),!0}return!1}function GS(t,e,n){t.domObserver.stop(),e.contentEditable=n,t.domObserver.start()}function m3(t){if(!ar||t.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:n}=t.domSelectionRange();if(e&&e.nodeType==1&&n==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let r=e.firstChild;GS(t,r,"true"),setTimeout(()=>GS(t,r,"false"),20)}return!1}function v3(t){let e="";return t.ctrlKey&&(e+="c"),t.metaKey&&(e+="m"),t.altKey&&(e+="a"),t.shiftKey&&(e+="s"),e}function y3(t,e){let n=e.keyCode,r=v3(e);if(n==8||oo&&n==72&&r=="c")return jS(t,-1)||Ll(t,-1);if(n==46&&!e.shiftKey||oo&&n==68&&r=="c")return jS(t,1)||Ll(t,1);if(n==13||n==27)return!0;if(n==37||oo&&n==66&&r=="c"){let o=n==37?WS(t,t.state.selection.from)=="ltr"?-1:1:-1;return US(t,o,r)||Ll(t,o)}else if(n==39||oo&&n==70&&r=="c"){let o=n==39?WS(t,t.state.selection.from)=="ltr"?1:-1:1;return US(t,o,r)||Ll(t,o)}else{if(n==38||oo&&n==80&&r=="c")return VS(t,-1,r)||Ll(t,-1);if(n==40||oo&&n==78&&r=="c")return m3(t)||VS(t,1,r)||Ll(t,1);if(r==(oo?"m":"c")&&(n==66||n==73||n==89||n==90))return!0}return!1}function c2(t,e){t.someProp("transformCopied",f=>{e=f(e,t)});let n=[],{content:r,openStart:o,openEnd:i}=e;for(;o>1&&i>1&&r.childCount==1&&r.firstChild.childCount==1;){o--,i--;let f=r.firstChild;n.push(f.type.name,f.attrs!=f.type.defaultAttrs?f.attrs:null),r=f.content}let s=t.someProp("clipboardSerializer")||Ur.fromSchema(t.state.schema),l=g2(),a=l.createElement("div");a.appendChild(s.serializeFragment(r,{document:l}));let u=a.firstChild,c,d=0;for(;u&&u.nodeType==1&&(c=p2[u.nodeName.toLowerCase()]);){for(let f=c.length-1;f>=0;f--){let p=l.createElement(c[f]);for(;a.firstChild;)p.appendChild(a.firstChild);a.appendChild(p),d++}u=a.firstChild}u&&u.nodeType==1&&u.setAttribute("data-pm-slice",`${o} ${i}${d?` -${d}`:""} ${JSON.stringify(n)}`);let h=t.someProp("clipboardTextSerializer",f=>f(e,t))||e.content.textBetween(0,e.content.size,`
-`);return{dom:l,text:p}}function CO(e,t,r,n,o){let i=o.parent.type.spec.code,s,a;if(!r&&!t)return null;let l=t&&(n||i||!r);if(l){if(e.someProp("transformPastedText",p=>{t=p(t,i||n,e)}),i)return t?new W(I.from(e.state.schema.text(t.replace(/\r\n?/g,`
-`))),0,0):W.empty;let d=e.someProp("clipboardTextParser",p=>p(t,o,n,e));if(d)a=d;else{let p=o.marks(),{schema:f}=e.state,h=un.fromSchema(f);s=document.createElement("div"),t.split(/(?:\r\n?|\n)+/).forEach(m=>{let b=s.appendChild(document.createElement("p"));m&&b.appendChild(h.serializeNode(f.text(m,p)))})}}else e.someProp("transformPastedHTML",d=>{r=d(r,e)}),s=r3(r),Fd&&n3(s);let c=s&&s.querySelector("[data-pm-slice]"),u=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(u&&u[3])for(let d=+u[3];d>0;d--){let p=s.firstChild;for(;p&&p.nodeType!=1;)p=p.nextSibling;if(!p)break;s=p}if(a||(a=(e.someProp("clipboardParser")||e.someProp("domParser")||Vy.fromSchema(e.state.schema)).parseSlice(s,{preserveWhitespace:!!(l||u),context:o,ruleFromNode(p){return p.nodeName=="BR"&&!p.nextSibling&&p.parentNode&&!e3.test(p.parentNode.nodeName)?{ignore:!0}:null}})),u)a=o3(vS(a,+u[1],+u[2]),u[4]);else if(a=W.maxOpen(t3(a.content,o),!0),a.openStart||a.openEnd){let d=0,p=0;for(let f=a.content.firstChild;d{a=d(a,e)}),a}const e3=/^(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 t3(e,t){if(e.childCount<2)return e;for(let r=t.depth;r>=0;r--){let o=t.node(r).contentMatchAt(t.index(r)),i,s=[];if(e.forEach(a=>{if(!s)return;let l=o.findWrapping(a.type),c;if(!l)return s=null;if(c=s.length&&i.length&&AO(l,i,a,s[s.length-1],0))s[s.length-1]=c;else{s.length&&(s[s.length-1]=NO(s[s.length-1],i.length));let u=OO(a,l);s.push(u),o=o.matchType(u.type),i=l}}),s)return I.from(s)}return e}function OO(e,t,r=0){for(let n=t.length-1;n>=r;n--)e=t[n].create(null,I.from(e));return e}function AO(e,t,r,n,o){if(o1&&(i=0),o=r&&(a=t<0?s.contentMatchAt(0).fillBefore(a,i<=o).append(a):a.append(s.contentMatchAt(s.childCount).fillBefore(I.empty,!0))),e.replaceChild(t<0?0:e.childCount-1,s.copy(a))}function vS(e,t,r){return t]*>)*/.exec(e);t&&(e=e.slice(t[0].length));let r=_O().createElement("div"),n=/<([a-z][^>\s]+)/i.exec(e),o;if((o=n&&RO[n[1].toLowerCase()])&&(e=o.map(i=>"<"+i+">").join("")+e+o.map(i=>""+i+">").reverse().join("")),r.innerHTML=e,o)for(let i=0;i=0;a-=2){let l=r.nodes[n[a]];if(!l||l.hasRequiredAttrs())break;o=I.from(l.create(n[a+1],o)),i++,s++}return new W(o,i,s)}const Cr={},Or={},i3={touchstart:!0,touchmove:!0};class s3{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:""},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastAndroidDelete=0,this.composing=!1,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function a3(e){for(let t in Cr){let r=Cr[t];e.dom.addEventListener(t,e.input.eventHandlers[t]=n=>{c3(e,n)&&!Qy(e,n)&&(e.editable||!(n.type in Or))&&r(e,n)},i3[t]?{passive:!0}:void 0)}Tr&&e.dom.addEventListener("input",()=>null),i0(e)}function Hi(e,t){e.input.lastSelectionOrigin=t,e.input.lastSelectionTime=Date.now()}function l3(e){e.domObserver.stop();for(let t in e.input.eventHandlers)e.dom.removeEventListener(t,e.input.eventHandlers[t]);clearTimeout(e.input.composingTimeout),clearTimeout(e.input.lastIOSEnterFallbackTimeout)}function i0(e){e.someProp("handleDOMEvents",t=>{for(let r in t)e.input.eventHandlers[r]||e.dom.addEventListener(r,e.input.eventHandlers[r]=n=>Qy(e,n))})}function Qy(e,t){return e.someProp("handleDOMEvents",r=>{let n=r[t.type];return n?n(e,t)||t.defaultPrevented:!1})}function c3(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let r=t.target;r!=e.dom;r=r.parentNode)if(!r||r.nodeType==11||r.pmViewDesc&&r.pmViewDesc.stopEvent(t))return!1;return!0}function u3(e,t){!Qy(e,t)&&Cr[t.type]&&(e.editable||!(t.type in Or))&&Cr[t.type](e,t)}Or.keydown=(e,t)=>{let r=t;if(e.input.shiftKey=r.keyCode==16||r.shiftKey,!MO(e,r)&&(e.input.lastKeyCode=r.keyCode,e.input.lastKeyCodeTime=Date.now(),!(eo&&hr&&r.keyCode==13)))if(r.keyCode!=229&&e.domObserver.forceFlush(),$l&&r.keyCode==13&&!r.ctrlKey&&!r.altKey&&!r.metaKey){let n=Date.now();e.input.lastIOSEnter=n,e.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{e.input.lastIOSEnter==n&&(e.someProp("handleKeyDown",o=>o(e,Us(13,"Enter"))),e.input.lastIOSEnter=0)},200)}else e.someProp("handleKeyDown",n=>n(e,r))||QD(e,r)?r.preventDefault():Hi(e,"key")};Or.keyup=(e,t)=>{t.keyCode==16&&(e.input.shiftKey=!1)};Or.keypress=(e,t)=>{let r=t;if(MO(e,r)||!r.charCode||r.ctrlKey&&!r.altKey||Cn&&r.metaKey)return;if(e.someProp("handleKeyPress",o=>o(e,r))){r.preventDefault();return}let n=e.state.selection;if(!(n instanceof ue)||!n.$from.sameParent(n.$to)){let o=String.fromCharCode(r.charCode);!/[\r\n]/.test(o)&&!e.someProp("handleTextInput",i=>i(e,n.$from.pos,n.$to.pos,o))&&e.dispatch(e.state.tr.insertText(o).scrollIntoView()),r.preventDefault()}};function Qh(e){return{left:e.clientX,top:e.clientY}}function d3(e,t){let r=t.x-e.clientX,n=t.y-e.clientY;return r*r+n*n<100}function ev(e,t,r,n,o){if(n==-1)return!1;let i=e.state.doc.resolve(n);for(let s=i.depth+1;s>0;s--)if(e.someProp(t,a=>s>i.depth?a(e,r,i.nodeAfter,i.before(s),o,!0):a(e,r,i.node(s),i.before(s),o,!1)))return!0;return!1}function kl(e,t,r){e.focused||e.focus();let n=e.state.tr.setSelection(t);r=="pointer"&&n.setMeta("pointer",!0),e.dispatch(n)}function p3(e,t){if(t==-1)return!1;let r=e.state.doc.resolve(t),n=r.nodeAfter;return n&&n.isAtom&&de.isSelectable(n)?(kl(e,new de(r),"pointer"),!0):!1}function f3(e,t){if(t==-1)return!1;let r=e.state.selection,n,o;r instanceof de&&(n=r.node);let i=e.state.doc.resolve(t);for(let s=i.depth+1;s>0;s--){let a=s>i.depth?i.nodeAfter:i.node(s);if(de.isSelectable(a)){n&&r.$from.depth>0&&s>=r.$from.depth&&i.before(r.$from.depth+1)==r.$from.pos?o=i.before(r.$from.depth):o=i.before(s);break}}return o!=null?(kl(e,de.create(e.state.doc,o),"pointer"),!0):!1}function h3(e,t,r,n,o){return ev(e,"handleClickOn",t,r,n)||e.someProp("handleClick",i=>i(e,t,n))||(o?f3(e,r):p3(e,r))}function m3(e,t,r,n){return ev(e,"handleDoubleClickOn",t,r,n)||e.someProp("handleDoubleClick",o=>o(e,t,n))}function g3(e,t,r,n){return ev(e,"handleTripleClickOn",t,r,n)||e.someProp("handleTripleClick",o=>o(e,t,n))||y3(e,r,n)}function y3(e,t,r){if(r.button!=0)return!1;let n=e.state.doc;if(t==-1)return n.inlineContent?(kl(e,ue.create(n,0,n.content.size),"pointer"),!0):!1;let o=n.resolve(t);for(let i=o.depth+1;i>0;i--){let s=i>o.depth?o.nodeAfter:o.node(i),a=o.before(i);if(s.inlineContent)kl(e,ue.create(n,a+1,a+1+s.content.size),"pointer");else if(de.isSelectable(s))kl(e,de.create(n,a),"pointer");else continue;return!0}}function tv(e){return Bf(e)}const IO=Cn?"metaKey":"ctrlKey";Cr.mousedown=(e,t)=>{let r=t;e.input.shiftKey=r.shiftKey;let n=tv(e),o=Date.now(),i="singleClick";o-e.input.lastClick.time<500&&d3(r,e.input.lastClick)&&!r[IO]&&(e.input.lastClick.type=="singleClick"?i="doubleClick":e.input.lastClick.type=="doubleClick"&&(i="tripleClick")),e.input.lastClick={time:o,x:r.clientX,y:r.clientY,type:i};let s=e.posAtCoords(Qh(r));s&&(i=="singleClick"?(e.input.mouseDown&&e.input.mouseDown.done(),e.input.mouseDown=new v3(e,s,r,!!n)):(i=="doubleClick"?m3:g3)(e,s.pos,s.inside,r)?r.preventDefault():Hi(e,"pointer"))};class v3{constructor(t,r,n,o){this.view=t,this.pos=r,this.event=n,this.flushed=o,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=t.state.doc,this.selectNode=!!n[IO],this.allowDefault=n.shiftKey;let i,s;if(r.inside>-1)i=t.state.doc.nodeAt(r.inside),s=r.inside;else{let u=t.state.doc.resolve(r.pos);i=u.parent,s=u.depth?u.before():0}const a=o?null:n.target,l=a?t.docView.nearestDesc(a,!0):null;this.target=l?l.dom:null;let{selection:c}=t.state;(n.button==0&&i.type.spec.draggable&&i.type.spec.selectable!==!1||c instanceof de&&c.from<=s&&c.to>s)&&(this.mightDrag={node:i,pos:s,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&ao&&!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)),Hi(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(()=>oi(this.view)),this.view.input.mouseDown=null}up(t){if(this.done(),!this.view.dom.contains(t.target))return;let r=this.pos;this.view.state.doc!=this.startDoc&&(r=this.view.posAtCoords(Qh(t))),this.updateAllowDefault(t),this.allowDefault||!r?Hi(this.view,"pointer"):h3(this.view,r.pos,r.inside,t,this.selectNode)?t.preventDefault():t.button==0&&(this.flushed||Tr&&this.mightDrag&&!this.mightDrag.node.isAtom||hr&&!this.view.state.selection.visible&&Math.min(Math.abs(r.pos-this.view.state.selection.from),Math.abs(r.pos-this.view.state.selection.to))<=2)?(kl(this.view,ke.near(this.view.state.doc.resolve(r.pos)),"pointer"),t.preventDefault()):Hi(this.view,"pointer")}move(t){this.updateAllowDefault(t),Hi(this.view,"pointer"),t.buttons==0&&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)}}Cr.touchstart=e=>{e.input.lastTouch=Date.now(),tv(e),Hi(e,"pointer")};Cr.touchmove=e=>{e.input.lastTouch=Date.now(),Hi(e,"pointer")};Cr.contextmenu=e=>tv(e);function MO(e,t){return e.composing?!0:Tr&&Math.abs(t.timeStamp-e.input.compositionEndedAt)<500?(e.input.compositionEndedAt=-2e8,!0):!1}const b3=eo?5e3:-1;Or.compositionstart=Or.compositionupdate=e=>{if(!e.composing){e.domObserver.flush();let{state:t}=e,r=t.selection.$from;if(t.selection.empty&&(t.storedMarks||!r.textOffset&&r.parentOffset&&r.nodeBefore.marks.some(n=>n.type.spec.inclusive===!1)))e.markCursor=e.state.storedMarks||r.marks(),Bf(e,!0),e.markCursor=null;else if(Bf(e),ao&&t.selection.empty&&r.parentOffset&&!r.textOffset&&r.nodeBefore.marks.length){let n=e.domSelectionRange();for(let o=n.focusNode,i=n.focusOffset;o&&o.nodeType==1&&i!=0;){let s=i<0?o.lastChild:o.childNodes[i-1];if(!s)break;if(s.nodeType==3){e.domSelection().collapse(s,s.nodeValue.length);break}else o=s,i=-1}}e.input.composing=!0}LO(e,b3)};Or.compositionend=(e,t)=>{e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=t.timeStamp,e.input.compositionPendingChanges=e.domObserver.pendingRecords().length?e.input.compositionID:0,e.input.compositionPendingChanges&&Promise.resolve().then(()=>e.domObserver.flush()),e.input.compositionID++,LO(e,20))};function LO(e,t){clearTimeout(e.input.composingTimeout),t>-1&&(e.input.composingTimeout=setTimeout(()=>Bf(e),t))}function DO(e){for(e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=E3());e.input.compositionNodes.length>0;)e.input.compositionNodes.pop().markParentsDirty()}function E3(){let e=document.createEvent("Event");return e.initEvent("event",!0,!0),e.timeStamp}function Bf(e,t=!1){if(!(eo&&e.domObserver.flushingSoon>=0)){if(e.domObserver.forceFlush(),DO(e),t||e.docView&&e.docView.dirty){let r=Zy(e);return r&&!r.eq(e.state.selection)?e.dispatch(e.state.tr.setSelection(r)):e.updateState(e.state),!0}return!1}}function k3(e,t){if(!e.dom.parentNode)return;let r=e.dom.parentNode.appendChild(document.createElement("div"));r.appendChild(t),r.style.cssText="position: fixed; left: -10000px; top: 10px";let n=getSelection(),o=document.createRange();o.selectNodeContents(t),e.dom.blur(),n.removeAllRanges(),n.addRange(o),setTimeout(()=>{r.parentNode&&r.parentNode.removeChild(r),e.focus()},50)}const Bl=Hr&&Gi<15||$l&&vD<604;Cr.copy=Or.cut=(e,t)=>{let r=t,n=e.state.selection,o=r.type=="cut";if(n.empty)return;let i=Bl?null:r.clipboardData,s=n.content(),{dom:a,text:l}=TO(e,s);i?(r.preventDefault(),i.clearData(),i.setData("text/html",a.innerHTML),i.setData("text/plain",l)):k3(e,a),o&&e.dispatch(e.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function x3(e){return e.openStart==0&&e.openEnd==0&&e.content.childCount==1?e.content.firstChild:null}function S3(e,t){if(!e.dom.parentNode)return;let r=e.input.shiftKey||e.state.selection.$from.parent.type.spec.code,n=e.dom.parentNode.appendChild(document.createElement(r?"textarea":"div"));r||(n.contentEditable="true"),n.style.cssText="position: fixed; left: -10000px; top: 10px",n.focus();let o=e.input.shiftKey&&e.input.lastKeyCode!=45;setTimeout(()=>{e.focus(),n.parentNode&&n.parentNode.removeChild(n),r?Wu(e,n.value,null,o,t):Wu(e,n.textContent,n.innerHTML,o,t)},50)}function Wu(e,t,r,n,o){let i=CO(e,t,r,n,e.state.selection.$from);if(e.someProp("handlePaste",l=>l(e,o,i||W.empty)))return!0;if(!i)return!1;let s=x3(i),a=s?e.state.tr.replaceSelectionWith(s,n):e.state.tr.replaceSelection(i);return e.dispatch(a.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}Or.paste=(e,t)=>{let r=t;if(e.composing&&!eo)return;let n=Bl?null:r.clipboardData,o=e.input.shiftKey&&e.input.lastKeyCode!=45;n&&Wu(e,n.getData("text/plain"),n.getData("text/html"),o,r)?r.preventDefault():S3(e,r)};class w3{constructor(t,r){this.slice=t,this.move=r}}const PO=Cn?"altKey":"ctrlKey";Cr.dragstart=(e,t)=>{let r=t,n=e.input.mouseDown;if(n&&n.done(),!r.dataTransfer)return;let o=e.state.selection,i=o.empty?null:e.posAtCoords(Qh(r));if(!(i&&i.pos>=o.from&&i.pos<=(o instanceof de?o.to-1:o.to))){if(n&&n.mightDrag)e.dispatch(e.state.tr.setSelection(de.create(e.state.doc,n.mightDrag.pos)));else if(r.target&&r.target.nodeType==1){let c=e.docView.nearestDesc(r.target,!0);c&&c.node.type.spec.draggable&&c!=e.docView&&e.dispatch(e.state.tr.setSelection(de.create(e.state.doc,c.posBefore)))}}let s=e.state.selection.content(),{dom:a,text:l}=TO(e,s);r.dataTransfer.clearData(),r.dataTransfer.setData(Bl?"Text":"text/html",a.innerHTML),r.dataTransfer.effectAllowed="copyMove",Bl||r.dataTransfer.setData("text/plain",l),e.dragging=new w3(s,!r[PO])};Cr.dragend=e=>{let t=e.dragging;window.setTimeout(()=>{e.dragging==t&&(e.dragging=null)},50)};Or.dragover=Or.dragenter=(e,t)=>t.preventDefault();Or.drop=(e,t)=>{let r=t,n=e.dragging;if(e.dragging=null,!r.dataTransfer)return;let o=e.posAtCoords(Qh(r));if(!o)return;let i=e.state.doc.resolve(o.pos),s=n&&n.slice;s?e.someProp("transformPasted",h=>{s=h(s,e)}):s=CO(e,r.dataTransfer.getData(Bl?"Text":"text/plain"),Bl?null:r.dataTransfer.getData("text/html"),!1,i);let a=!!(n&&!r[PO]);if(e.someProp("handleDrop",h=>h(e,r,s||W.empty,a))){r.preventDefault();return}if(!s)return;r.preventDefault();let l=s?zL(e.state.doc,i.pos,s):i.pos;l==null&&(l=i.pos);let c=e.state.tr;a&&c.deleteSelection();let u=c.mapping.map(l),d=s.openStart==0&&s.openEnd==0&&s.content.childCount==1,p=c.doc;if(d?c.replaceRangeWith(u,u,s.content.firstChild):c.replaceRange(u,u,s),c.doc.eq(p))return;let f=c.doc.resolve(u);if(d&&de.isSelectable(s.content.firstChild)&&f.nodeAfter&&f.nodeAfter.sameMarkup(s.content.firstChild))c.setSelection(new de(f));else{let h=c.mapping.map(l);c.mapping.maps[c.mapping.maps.length-1].forEach((m,b,y,g)=>h=g),c.setSelection(Jy(e,f,c.doc.resolve(h)))}e.focus(),e.dispatch(c.setMeta("uiEvent","drop"))};Cr.focus=e=>{e.input.lastFocus=Date.now(),e.focused||(e.domObserver.stop(),e.dom.classList.add("ProseMirror-focused"),e.domObserver.start(),e.focused=!0,setTimeout(()=>{e.docView&&e.hasFocus()&&!e.domObserver.currentSelection.eq(e.domSelectionRange())&&oi(e)},20))};Cr.blur=(e,t)=>{let r=t;e.focused&&(e.domObserver.stop(),e.dom.classList.remove("ProseMirror-focused"),e.domObserver.start(),r.relatedTarget&&e.dom.contains(r.relatedTarget)&&e.domObserver.currentSelection.clear(),e.focused=!1)};Cr.beforeinput=(e,t)=>{if(hr&&eo&&t.inputType=="deleteContentBackward"){e.domObserver.flushSoon();let{domChangeCount:n}=e.input;setTimeout(()=>{if(e.input.domChangeCount!=n||(e.dom.blur(),e.focus(),e.someProp("handleKeyDown",i=>i(e,Us(8,"Backspace")))))return;let{$cursor:o}=e.state.selection;o&&o.pos>0&&e.dispatch(e.state.tr.delete(o.pos-1,o.pos).scrollIntoView())},50)}};for(let e in Or)Cr[e]=Or[e];function Ku(e,t){if(e==t)return!0;for(let r in e)if(e[r]!==t[r])return!1;for(let r in t)if(!(r in e))return!1;return!0}class Hf{constructor(t,r){this.toDOM=t,this.spec=r||ea,this.side=this.spec.side||0}map(t,r,n,o){let{pos:i,deleted:s}=t.mapResult(r.from+o,this.side<0?-1:1);return s?null:new Je(i-n,i-n,this)}valid(){return!0}eq(t){return this==t||t instanceof Hf&&(this.spec.key&&this.spec.key==t.spec.key||this.toDOM==t.toDOM&&Ku(this.spec,t.spec))}destroy(t){this.spec.destroy&&this.spec.destroy(t)}}class Ki{constructor(t,r){this.attrs=t,this.spec=r||ea}map(t,r,n,o){let i=t.map(r.from+o,this.spec.inclusiveStart?-1:1)-n,s=t.map(r.to+o,this.spec.inclusiveEnd?1:-1)-n;return i>=s?null:new Je(i,s,this)}valid(t,r){return r.from=t&&(!i||i(a.spec))&&n.push(a.copy(a.from+o,a.to+o))}for(let s=0;st){let a=this.children[s]+1;this.children[s+2].findInner(t-a,r-a,n,o+a,i)}}map(t,r,n){return this==dr||t.maps.length==0?this:this.mapInner(t,r,0,0,n||ea)}mapInner(t,r,n,o,i){let s;for(let a=0;a{let c=l+n,u;if(u=$O(r,a,c)){for(o||(o=this.children.slice());ia&&d.to=t){this.children[a]==t&&(n=this.children[a+2]);break}let i=t+1,s=i+r.content.size;for(let a=0;ai&&l.type instanceof Ki){let c=Math.max(i,l.from)-i,u=Math.min(s,l.to)-i;co.map(t,r,ea));return Di.from(n)}forChild(t,r){if(r.isLeaf)return Ce.empty;let n=[];for(let o=0;or instanceof Ce)?t:t.reduce((r,n)=>r.concat(n instanceof Ce?n:n.members),[]))}}}function T3(e,t,r,n,o,i,s){let a=e.slice();for(let c=0,u=i;c{let b=m-h-(f-p);for(let y=0;yg+u-d)continue;let v=a[y]+u-d;f>=v?a[y+1]=p<=v?-2:-1:h>=o&&b&&(a[y]+=b,a[y+1]+=b)}d+=b}),u=r.maps[c].map(u,-1)}let l=!1;for(let c=0;c=n.content.size){l=!0;continue}let p=r.map(e[c+1]+i,-1),f=p-o,{index:h,offset:m}=n.content.findIndex(d),b=n.maybeChild(h);if(b&&m==d&&m+b.nodeSize==f){let y=a[c+2].mapInner(r,b,u+1,e[c]+i+1,s);y!=dr?(a[c]=d,a[c+1]=f,a[c+2]=y):(a[c+1]=-2,l=!0)}else l=!0}if(l){let c=C3(a,e,t,r,o,i,s),u=Ff(c,n,0,s);t=u.local;for(let d=0;dr&&s.to{let c=$O(e,a,l+r);if(c){i=!0;let u=Ff(c,a,r+l+1,n);u!=dr&&o.push(l,l+a.nodeSize,u)}});let s=zO(i?BO(e):e,-r).sort(ta);for(let a=0;a0;)t++;e.splice(t,0,r)}function zg(e){let t=[];return e.someProp("decorations",r=>{let n=r(e.state);n&&n!=dr&&t.push(n)}),e.cursorWrapper&&t.push(Ce.create(e.state.doc,[e.cursorWrapper.deco])),Di.from(t)}const O3={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},A3=Hr&&Gi<=11;class N3{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 R3{constructor(t,r){this.view=t,this.handleDOMChange=r,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new N3,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.observer=window.MutationObserver&&new window.MutationObserver(n=>{for(let o=0;oo.type=="childList"&&o.removedNodes.length||o.type=="characterData"&&o.oldValue.length>o.target.nodeValue.length)?this.flushSoon():this.flush()}),A3&&(this.onCharData=n=>{this.queue.push({target:n.target,type:"characterData",oldValue:n.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,O3)),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 r=0;rthis.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(pS(this.view)){if(this.suppressingSelectionUpdates)return oi(this.view);if(Hr&&Gi<=11&&!this.view.state.selection.empty){let t=this.view.domSelectionRange();if(t.focusNode&&la(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 r=new Set,n;for(let i=t.focusNode;i;i=Gu(i))r.add(i);for(let i=t.anchorNode;i;i=Gu(i))if(r.has(i)){n=i;break}let o=n&&this.view.docView.nearestDesc(n);if(o&&o.ignoreMutation({type:"selection",target:n.nodeType==3?n.parentNode:n}))return this.setCurSelection(),!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 r=this.pendingRecords();r.length&&(this.queue=[]);let n=t.domSelectionRange(),o=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(n)&&pS(t)&&!this.ignoreSelectionChange(n),i=-1,s=-1,a=!1,l=[];if(t.editable)for(let u=0;u1){let u=l.filter(d=>d.nodeName=="BR");if(u.length==2){let d=u[0],p=u[1];d.parentNode&&d.parentNode.parentNode==p.parentNode?p.remove():d.remove()}}let c=null;i<0&&o&&t.input.lastFocus>Date.now()-200&&Math.max(t.input.lastTouch,t.input.lastClick.time)-1||o)&&(i>-1&&(t.docView.markDirty(i,s),_3(t)),this.handleDOMChange(i,s,a,l),t.docView&&t.docView.dirty?t.updateState(t.state):this.currentSelection.eq(n)||oi(t),this.currentSelection.set(n))}registerMutation(t,r){if(r.indexOf(t.target)>-1)return null;let n=this.view.docView.nearestDesc(t.target);if(t.type=="attributes"&&(n==this.view.docView||t.attributeName=="contenteditable"||t.attributeName=="style"&&!t.oldValue&&!t.target.getAttribute("style"))||!n||n.ignoreMutation(t))return null;if(t.type=="childList"){for(let u=0;uo;b--){let y=n.childNodes[b-1],g=y.pmViewDesc;if(y.nodeName=="BR"&&!g){i=b;break}if(!g||g.size)break}let d=e.state.doc,p=e.someProp("domParser")||Vy.fromSchema(e.state.schema),f=d.resolve(s),h=null,m=p.parse(n,{topNode:f.parent,topMatch:f.parent.contentMatchAt(f.index()),topOpen:!0,from:o,to:i,preserveWhitespace:f.parent.type.whitespace=="pre"?"full":!0,findPositions:c,ruleFromNode:L3,context:f});if(c&&c[0].pos!=null){let b=c[0].pos,y=c[1]&&c[1].pos;y==null&&(y=b),h={anchor:b+s,head:y+s}}return{doc:m,sel:h,from:s,to:a}}function L3(e){let t=e.pmViewDesc;if(t)return t.parseRule();if(e.nodeName=="BR"&&e.parentNode){if(Tr&&/^(ul|ol)$/i.test(e.parentNode.nodeName)){let r=document.createElement("div");return r.appendChild(document.createElement("li")),{skip:r}}else if(e.parentNode.lastChild==e||Tr&&/^(tr|table)$/i.test(e.parentNode.nodeName))return{ignore:!0}}else if(e.nodeName=="IMG"&&e.getAttribute("mark-placeholder"))return{ignore:!0};return null}const D3=/^(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 P3(e,t,r,n,o){let i=e.input.compositionPendingChanges||(e.composing?e.input.compositionID:0);if(e.input.compositionPendingChanges=0,t<0){let T=e.input.lastSelectionTime>Date.now()-50?e.input.lastSelectionOrigin:null,O=Zy(e,T);if(O&&!e.state.selection.eq(O)){if(hr&&eo&&e.input.lastKeyCode===13&&Date.now()-100P(e,Us(13,"Enter"))))return;let _=e.state.tr.setSelection(O);T=="pointer"?_.setMeta("pointer",!0):T=="key"&&_.scrollIntoView(),i&&_.setMeta("composition",i),e.dispatch(_)}return}let s=e.state.doc.resolve(t),a=s.sharedDepth(r);t=s.before(a+1),r=e.state.doc.resolve(r).after(a+1);let l=e.state.selection,c=M3(e,t,r),u=e.state.doc,d=u.slice(c.from,c.to),p,f;e.input.lastKeyCode===8&&Date.now()-100Date.now()-225||eo)&&o.some(T=>T.nodeType==1&&!D3.test(T.nodeName))&&(!h||h.endA>=h.endB)&&e.someProp("handleKeyDown",T=>T(e,Us(13,"Enter")))){e.input.lastIOSEnter=0;return}if(!h)if(n&&l instanceof ue&&!l.empty&&l.$head.sameParent(l.$anchor)&&!e.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))h={start:l.from,endA:l.to,endB:l.to};else{if(c.sel){let T=SS(e,e.state.doc,c.sel);if(T&&!T.eq(e.state.selection)){let O=e.state.tr.setSelection(T);i&&O.setMeta("composition",i),e.dispatch(O)}}return}if(hr&&e.cursorWrapper&&c.sel&&c.sel.anchor==e.cursorWrapper.deco.from&&c.sel.head==c.sel.anchor){let T=h.endB-h.start;c.sel={anchor:c.sel.anchor+T,head:c.sel.anchor+T}}e.input.domChangeCount++,e.state.selection.frome.state.selection.from&&h.start<=e.state.selection.from+2&&e.state.selection.from>=c.from?h.start=e.state.selection.from:h.endA=e.state.selection.to-2&&e.state.selection.to<=c.to&&(h.endB+=e.state.selection.to-h.endA,h.endA=e.state.selection.to)),Hr&&Gi<=11&&h.endB==h.start+1&&h.endA==h.start&&h.start>c.from&&c.doc.textBetween(h.start-c.from-1,h.start-c.from+1)==" "&&(h.start--,h.endA--,h.endB--);let m=c.doc.resolveNoCache(h.start-c.from),b=c.doc.resolveNoCache(h.endB-c.from),y=u.resolve(h.start),g=m.sameParent(b)&&m.parent.inlineContent&&y.end()>=h.endA,v;if(($l&&e.input.lastIOSEnter>Date.now()-225&&(!g||o.some(T=>T.nodeName=="DIV"||T.nodeName=="P"))||!g&&m.posT(e,Us(13,"Enter")))){e.input.lastIOSEnter=0;return}if(e.state.selection.anchor>h.start&&$3(u,h.start,h.endA,m,b)&&e.someProp("handleKeyDown",T=>T(e,Us(8,"Backspace")))){eo&&hr&&e.domObserver.suppressSelectionUpdates();return}hr&&eo&&h.endB==h.start&&(e.input.lastAndroidDelete=Date.now()),eo&&!g&&m.start()!=b.start()&&b.parentOffset==0&&m.depth==b.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==h.endA&&(h.endB-=2,b=c.doc.resolveNoCache(h.endB-c.from),setTimeout(()=>{e.someProp("handleKeyDown",function(T){return T(e,Us(13,"Enter"))})},20));let E=h.start,k=h.endA,x,w,C;if(g){if(m.pos==b.pos)Hr&&Gi<=11&&m.parentOffset==0&&(e.domObserver.suppressSelectionUpdates(),setTimeout(()=>oi(e),20)),x=e.state.tr.delete(E,k),w=u.resolve(h.start).marksAcross(u.resolve(h.endA));else if(h.endA==h.endB&&(C=z3(m.parent.content.cut(m.parentOffset,b.parentOffset),y.parent.content.cut(y.parentOffset,h.endA-y.start()))))x=e.state.tr,C.type=="add"?x.addMark(E,k,C.mark):x.removeMark(E,k,C.mark);else if(m.parent.child(m.index()).isText&&m.index()==b.index()-(b.textOffset?0:1)){let T=m.parent.textBetween(m.parentOffset,b.parentOffset);if(e.someProp("handleTextInput",O=>O(e,E,k,T)))return;x=e.state.tr.insertText(T,E,k)}}if(x||(x=e.state.tr.replace(E,k,c.doc.slice(h.start-c.from,h.endB-c.from))),c.sel){let T=SS(e,x.doc,c.sel);T&&!(hr&&eo&&e.composing&&T.empty&&(h.start!=h.endB||e.input.lastAndroidDeletet.content.size?null:Jy(e,t.resolve(r.anchor),t.resolve(r.head))}function z3(e,t){let r=e.firstChild.marks,n=t.firstChild.marks,o=r,i=n,s,a,l;for(let u=0;uu.mark(a.addToSet(u.marks));else if(o.length==0&&i.length==1)a=i[0],s="remove",l=u=>u.mark(a.removeFromSet(u.marks));else return null;let c=[];for(let u=0;ur||$g(s,!0,!1)0&&(t||e.indexAfter(n)==e.node(n).childCount);)n--,o++,t=!1;if(r){let i=e.node(n).maybeChild(e.indexAfter(n));for(;i&&!i.isLeaf;)i=i.firstChild,o++}return o}function B3(e,t,r,n,o){let i=e.findDiffStart(t,r);if(i==null)return null;let{a:s,b:a}=e.findDiffEnd(t,r+e.size,r+t.size);if(o=="end"){let l=Math.max(0,i-Math.min(s,a));n-=s+l-i}if(s