Offline, privacy-first grammar checker. Fast, open-source, Rust-powered
<!-- biome-ignore-all lint: This file is a captured third-party test fixture. -->
<!doctype html>
<!-- Captured from https://prosemirror.net/ as a deterministic local Chrome extension test fixture. -->
<html lang=en-US>
<meta http-equiv="Content-Security-Policy" content="default-src 'self' data: blob:; script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline'; img-src 'self' data: blob:; font-src 'self' data:; frame-src 'none'; connect-src 'self'">
<meta charset=utf8>
<meta name="viewport" content="width=device-width, initial-scale=1"><meta property="og:title" content="ProseMirror"><meta property="og:type" content="website"><meta property="og:url" content="https://prosemirror.net/"><meta property="og:image" content="https://prosemirror.net/img/picture.png"><meta property="og:description" content="In-browser structured text editing component"><title>ProseMirror</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
@font-face {
font-family: 'Merriweather';
font-style: normal;
font-weight: 700;
src: local('Merriweather Bold'), local('Merriweather-Bold'), none format('woff2');
}
@font-face {
font-family: 'Source Sans Pro';
font-style: normal;
font-weight: 400;
src: local('Source Sans Pro'), local('SourceSansPro-Regular'), none format('woff2');
}
@font-face {
font-family: 'Source Sans Pro';
font-style: normal;
font-weight: 600;
src: local('Source Sans Pro Semibold'), local('SourceSansPro-Semibold'), none format('woff2');
}
@font-face {
font-family: 'Source Sans Pro';
font-style: italic;
font-weight: 400;
src: local('Source Sans Pro Italic'), local('SourceSansPro-It'), none format('woff2');
}
html {
background: white;
font-family: 'Source Sans Pro';
}
body {
margin: 0;
line-height: 1.45;
font-size: 16px;
overflow-y: scroll;
overflow-x: hidden;
position: relative;
}
header, article, footer nav {
max-width: 720px;
margin: 0 auto;
}
h1, h2, h3, h4, h5 { font-family: Merriweather; font-weight: 700; }
h1 { font-size: 32px; line-height: 40px }
h2 { font-size: 26px; line-height: 33px; margin: 37px 0 12px; }
h3 { font-size: 22px; line-height: 26px; margin: 26px 0 12px; }
h4 { font-size: 18px; line-height: 22px; margin: 25px 0 12px; }
a { text-decoration: none }
header.frontpage > h1 { z-index: 0; }
header.frontpage > h1:before {
content: "";
position: absolute;
left: -1000px;
right: -1000px;
bottom: -213px;
height: calc(100% + 850px);
background-size: 100px 100px;
background-image: linear-gradient(to right, #1a1a1a 2px, transparent 1px), linear-gradient(to bottom, #1a1a1a 2px, black 1px);
background-position: left 40px bottom 60px;
transform: rotate(-5deg);
transform-origin: 50% 50%;
z-index: -1;
}
header > * { z-index: 2; position: relative; }
header {
position: relative;
padding: 62px 6px 0;
}
header.frontpage {
color: white;
margin-bottom: 40px;
}
header > h1 {
text-align: center;
margin: 63px 0 50px;
}
header nav, footer nav {
display: flex;
justify-content: space-between;
flex-wrap: wrap;
font-weight: 600;
}
strong { font-weight: 600; }
nav a:link, nav a:visited, a.blocklink:link, a.blocklink:visited, code a:link, code a:visited,
h2 a:link, h2 a:visited, h3 a:link, h3 a:visited, h4 a:link, h4 a:visited {
color: inherit;
}
code, pre { font-size: 14px; }
h2 code, h3 code { font-size: inherit; }
pre {
line-height: 22px;
padding-left: 20px;
overflow-x: auto;
}
pre > code {
margin: 0;
}
a.blocklink:hover {
color: #0045ff;
}
nav a.active, a:link, a:visited {
color: #0045ff;
}
a.logo {
padding-left: 45px;
letter-spacing: -1.5px;
background-image: none;
background-size: 32px;
background-position: top 1px left;
background-repeat: no-repeat;
font-size: 34px;
line-height: 37px;
}
footer a.logo, header.frontpage a.logo {
background-image: none;
}
.navlinks {
flex-grow: 1;
font-size: 14px;
display: flex;
flex-wrap: wrap;
justify-content: flex-end;
align-items: flex-end;
}
footer .navlinks {
align-items: center;
}
.navlinks > a {
margin-left: 17px;
padding-bottom: 3px;
}
.navlinks > a:hover { color: #0045ff; }
nav#toc a.current-section {
color: black;
}
nav#toc {
position: absolute;
top: 140px;
right: calc(50% + 360px);
color: #888;
min-width: 150px;
max-width: 200px;
width: fit-content;
width: -moz-fit-content;
width: -webkit-fit-content;
padding: 10px 40px 30px 10px;
direction: rtl;
font-size: 14px;
line-height: 23.2px;
font-weight: 600;
}
nav#toc.fixed {
position: fixed;
overflow-y: auto;
max-height: 100%;
}
nav#toc > * {
direction: ltr;
}
.toc-toggle { display: none }
nav#toc input {
border: none;
width: 100%;
box-sizing: border-box;
line-height: inherit;
font: inherit;
background: transparent;
color: inherit;
outline: none;
margin-top: 20px;
}
nav#toc ul {
list-style: none;
margin: 0;
padding: 0;
}
nav#toc ul ul {
padding-left: 20px;
}
article {
padding: 10px 6px 100px;
}
footer {
padding: 14px 6px;
color: white;
background: black;
}
h2.hr {
font-size: 12px;
margin: 50px 0 37px;
}
hr, h2.hr:after {
display: block;
content: "";
border: none;
border-bottom: 2px solid #e5e5e5;
margin-top: 2px;
}
hr {
margin: 45px 0 39px;
}
h2.above-list {
font-size: 12px;
line-height: 15px;
margin-bottom: 37px;
margin-top: 42px;
}
h2.module {
margin-top: 250px;
font-size: 28px;
line-height: 30px;
padding-top: 10px;
border-bottom: 1px solid black;
}
ul.grid-list {
list-style: none;
padding: 0;
margin: 36px 0 -36px;
display: flex;
justify-content: space-between;
flex-wrap: wrap;
position: relative;
}
ul.grid-list > li {
display: block;
max-width: 340px;
min-width: 40%;
width: 100%;
margin-bottom: 36px;
font-size: 14px;
line-height: 20px;
}
ul.grid-list p {
margin: 0;
}
p, dl, dd, ul, ol, pre { margin-bottom: 23px }
p, dl { margin-top: 1em; }
ul.grid-list h3 {
margin: 0 0 9px;
line-height: 1;
font-size: 20px;
}
@media screen and (max-width: 830px) {
h1 { font-size: 22px }
a.logo {
padding-left: 38px;
letter-spacing: -1px;
background-size: 28px 28px;
background-position: top left;
background-repeat: no-repeat;
font-size: 24px;
line-height: 30px;
}
}
@media screen and (max-width: 1130px) {
nav#toc {
position: static;
max-width: 720px;
box-sizing: border-box;
padding: 15px 3px 0;
width: auto;
margin: 0 auto;
direction: ltr;
color: black;
display: none;
}
nav#toc.fixed { position: static; }
nav#toc.open { display: block; }
.toc-toggle { display: inline; cursor: pointer; }
}
code { margin: 0 2px }
dd p, dd ul, dd ol { margin: 0 }
dd { margin-left: 20px }
dt { line-height: 1.35 }
.breaktype {
padding-left: 20px;
}
h2 .keyword, h3 .keyword, h4 .keyword {
font-weight: 600;
margin-bottom: -4px;
color: black;
}
h2 .keyword { font-size: 18px }
h3 .keyword { font-size: 16px }
h4 .keyword { font-size: 14px }
div.figure { margin: 1em; }
.figure img {
width: 400px;
max-width: 90%;
}
.sponsorlist {
display: flex;
flex-wrap: wrap;
align-items: center;
position: relative;
}
a.sponsor {
display: block;
margin: .5em 0 .5em 20px;
min-width: 45%;
}
a.sponsor img {
max-width: 100%;
}
a.sponsor.diamond img { height: 100px }
a.sponsor.gold img { height: 70px }
a.sponsor.silver img { height: 35px }
a.sponsor.bronze img { height: 25px }
/* Code highlighting styles */
.tok-keyword, .fn, .keyword {color: #708;}
.tok-atom, .tok-bool {color: #219;}
.tok-number, .prim {color: #164;}
.tok-variableName.tok-definition {color: #00f;}
.tok-variableName2, .tok-typeName, .type {color: #05a;}
.tok-comment {color: #a50;}
.tok-string, .string {color: #a11;}
.tok-string2 {color: #f50;}
.tok-meta {color: #555;}
.tok-tag {color: #170;}
.tok-attribute {color: #00c;}
.param, .prop {font-style: italic;}
.prim {color: #075;}
.defaultvalue {color: #777;}
</style><header class=frontpage>
<nav>
<a class=logo href="/">ProseMirror</a>
<div class=navlinks><a href="/examples/" >Examples</a>
<a href="/docs/" >Documentation</a>
<a href="https://discuss.prosemirror.net/">Discuss</a>
<a href="https://code.haverbeke.berlin/prosemirror">Code</a>
</div>
</nav><h1>A toolkit for building rich-text editors on the web</h1>
<div id=editor></div></header><article><style>
.ProseMirror { padding: 2px 20px; min-height: 180px; outline: none; }
p.callout {
padding: 0 20px 0 15px;
font-weight: 600;
}
</style>
<div id="content" style="display: none">
<p>Like this one!</p>
<p>Try it out by typing in here or see more <a href="examples">examples</a>.</p>
</div>
<p>Rich content editors should, ideally, produce clean, semantically
meaningful documents while still being easy for users to understand.
ProseMirror tries to bridge the gap between editing explicit,
unambiguous content like <a href="http://commonmark.org/">Markdown</a>
or XML, and
classical <a href="https://en.wikipedia.org/wiki/WYSIWYG">WYSIWYG</a>
editors.</p>
<p>It does this by implementing a WYSIWYG-style editing interface for
documents more constrained and structured than plain HTML. You can
customize the shape and structure of the documents your editor
creates, and tailor them to your application's needs.</p>
<h2 class=hr id=features>Features</h2>
<ul class=grid-list>
<li>
<h3>Collaborative editing</h3>
<p>ProseMirror has built-in, ground-up, rock solid support for
collaborative editing, where multiple people work on the same
document in real time.</p>
</li>
<li>
<h3>Extensible schemas</h3>
<p>Document schemas allow editing documents with a custom
structure without writing your own editor from scratch.</p>
</li>
<li>
<h3>Modular</h3>
<p>A modular architecture makes sure you only load the code you
need, and can replace parts of the system as needed.</p>
</li>
<li>
<h3>Pluggable</h3>
<p>A plugin system allows you to easily enable additional
functionality, and package your own extensions in a convenient
format.</p>
</li>
<li>
<h3>Functional</h3>
<p>A largely functional and immutable architecture makes it easy
to integrate ProseMirror into modern web apps, and confidently
implement complex behavior.</p>
</li>
<li>
<h3>Unopinionated</h3>
<p>The core library is small and generic, providing a base onto
which very different types of editors can be built.</p>
</li>
</ul>
<h2 class=hr id=about>About</h2>
<p>ProseMirror
is <a href="https://code.haverbeke.berlin/prosemirror/prosemirror/src/branch/main/LICENSE">open
source</a>, and you are legally free to use it commercially. Yet,
writing, maintaining, supporting, and setting up infrastructure for
such a project takes a lot of work and energy. Therefore...</p>
<p class=callout>If you are using ProseMirror to make profit, there is
a <u>social</u> expectation that you help
fund its maintenance.
<a class=fund-button href="http://marijnhaverbeke.nl/fund/">Start here.</a>
</p>
<p>ProseMirror is being developed
on <a href="https://code.haverbeke.berlin/prosemirror/">Forgejo</a>. Contributions
are <a href="https://code.haverbeke.berlin/prosemirror/prosemirror/src/branch/main/CONTRIBUTING.md">welcome</a>.</p>
<p>The easiest way to install ProseMirror is
with <a href="https://www.npmjs.com/search?q=prosemirror-">npm</a>.
Take a look at the <a href="examples/basic/">examples</a> to get
started.</p>
<p>The library works on recent versions of Firefox, Chrome, Safari,
and Edge, as well as on Internet Explorer 11.</p>
<p>Discussing the project, or asking questions, is best done on
the <a href="https://discuss.prosemirror.net/">forum</a>.
Bugs should be reported through
the <a href="https://code.haverbeke.berlin/prosemirror/prosemirror/issues">issue
tracker</a>. We aim to be an inclusive, welcoming community. To make
that explicit, we have
a <a href="http://contributor-covenant.org/version/1/1/0/">code of
conduct</a> that applies to communication around the project.</p>
<h2 class=hr id=sponsors>Sponsors</h2>
<p>Initial development of the software
was <a href="https://www.indiegogo.com/projects/prosemirror/">crowd-funded</a>
by these 414 excellent <a href="backers.html">individuals and
organizations</a>.</p>
<p>Ongoing development is supported by these companies:</p>
<div class=sponsorlist>
<a href="https://posit.co" class="sponsor diamond"></a>
<a href="https://www.nytimes.com/" class="sponsor diamond"></a>
<a href="https://tiptap.dev/" class="sponsor diamond"></a>
<a href="https://www.progress.com/" class="sponsor gold"></a>
<a href="https://www.scripto.live/" class="sponsor gold"></a>
<a href="https://asana.com/" class="sponsor silver"></a>
<a href="https://www.blocknotejs.org/" class="sponsor silver"></a>
<a href="https://box.com/" class="sponsor silver"></a>
<a href="https://desmos.com/" class="sponsor silver"></a>
<a href="https://nextjournal.com/" class="sponsor silver"></a>
<a href="https://plickers.com/" class="sponsor silver"></a>
<a href="https://theguardian.com" class="sponsor silver"></a>
<a href="https://www.yarn.so" class="sponsor silver"></a>
<a href="https://fellow.app/" class="sponsor bronze"></a>
<a href="https://sunsama.com/" class="sponsor bronze"></a>
</div>
<style>
.ProseMirror {
position: relative;
}
.ProseMirror {
word-wrap: break-word;
white-space: pre-wrap;
white-space: break-spaces;
-webkit-font-variant-ligatures: none;
font-variant-ligatures: none;
font-feature-settings: "liga" 0; /* the above doesn't seem to work in Edge */
}
.ProseMirror pre {
white-space: pre-wrap;
}
.ProseMirror li {
position: relative;
}
.ProseMirror-hideselection *::selection { background: transparent; }
.ProseMirror-hideselection *::-moz-selection { background: transparent; }
.ProseMirror-hideselection { caret-color: transparent; }
/* See https://code.haverbeke.berlin/prosemirror/prosemirror/issues/1421#issuecomment-1759320191 */
.ProseMirror [draggable][contenteditable=false] { user-select: text }
.ProseMirror-selectednode {
outline: 2px solid #8cf;
}
/* Make sure li selections wrap around markers */
li.ProseMirror-selectednode {
outline: none;
}
li.ProseMirror-selectednode:after {
content: "";
position: absolute;
left: -32px;
right: -2px; top: -2px; bottom: -2px;
border: 2px solid #8cf;
pointer-events: none;
}
/* Protect against generic img rules */
img.ProseMirror-separator {
display: inline !important;
border: none !important;
margin: 0 !important;
}
.ProseMirror-textblock-dropdown {
min-width: 3em;
}
.ProseMirror-menu {
margin: 0 -4px;
line-height: 1;
}
.ProseMirror-tooltip .ProseMirror-menu {
width: -webkit-fit-content;
width: fit-content;
white-space: pre;
}
.ProseMirror-menuitem {
margin-right: 3px;
display: inline-block;
}
.ProseMirror-menuitem button {
border: none;
background: transparent;
box-shadow: none;
color: inherit;
font-size: inherit;
font-family: inherit;
}
.ProseMirror-menuseparator {
border-right: 1px solid #ddd;
margin-right: 3px;
}
.ProseMirror-menuitem .ProseMirror-menu-dropdown, .ProseMirror-menu-dropdown-menu {
font-size: 90%;
white-space: nowrap;
}
.ProseMirror-menuitem .ProseMirror-menu-dropdown {
vertical-align: 1px;
cursor: pointer;
position: relative;
padding-right: 15px;
}
.ProseMirror-menu-dropdown-wrap {
padding: 1px 0 1px 4px;
display: inline-block;
position: relative;
}
.ProseMirror-menu-dropdown:after {
content: "";
border-left: 4px solid transparent;
border-right: 4px solid transparent;
border-top: 4px solid currentColor;
opacity: .6;
position: absolute;
right: 4px;
top: calc(50% - 2px);
}
.ProseMirror-menu-dropdown-menu, .ProseMirror-menu-submenu {
position: absolute;
background: white;
color: #666;
border: 1px solid #aaa;
padding: 2px;
}
.ProseMirror-menu-dropdown-menu ul,
.ProseMirror-menu-dropdown-menu ol,
.ProseMirror-menu-submenu ul,
.ProseMirror-menu-submenu ol {
margin: 0;
padding: 0;
list-style: none;
}
.ProseMirror-menu-dropdown-menu {
z-index: 15;
min-width: 6em;
}
.ProseMirror-menu-dropdown-item button {
cursor: pointer;
padding: 2px 8px 2px 4px;
}
.ProseMirror-menu-dropdown-item:hover,
.ProseMirror-menu-dropdown-item:focus-within {
background: #f2f2f2;
}
.ProseMirror-menu-submenu-wrap {
position: relative;
margin-right: -4px;
}
.ProseMirror-menu-submenu-label:after {
content: "";
border-top: 4px solid transparent;
border-bottom: 4px solid transparent;
border-left: 4px solid currentColor;
opacity: .6;
position: absolute;
right: 4px;
top: calc(50% - 4px);
}
.ProseMirror-menu-submenu {
display: none;
min-width: 4em;
left: 100%;
top: -3px;
}
.ProseMirror-menuitem .ProseMirror-menu-active {
background: #eee;
border-radius: 4px;
}
.ProseMirror-menuitem .ProseMirror-menu-disabled {
opacity: .3;
}
.ProseMirror-menu-submenu-wrap:hover .ProseMirror-menu-submenu,
.ProseMirror-menu-submenu:focus-within,
.ProseMirror-menu-submenu-wrap-active .ProseMirror-menu-submenu {
display: block;
}
.ProseMirror-menubar {
border-top-left-radius: inherit;
border-top-right-radius: inherit;
position: relative;
min-height: 1em;
color: #666;
padding: 1px 6px;
top: 0; left: 0; right: 0;
border-bottom: 1px solid silver;
background: white;
z-index: 10;
-moz-box-sizing: border-box;
box-sizing: border-box;
overflow: visible;
}
.ProseMirror-icon {
display: inline-block;
line-height: .8;
vertical-align: -2px; /* Compensate for padding */
padding: 2px 8px;
cursor: pointer;
}
.ProseMirror-menu-disabled.ProseMirror-icon {
cursor: default;
}
.ProseMirror-icon svg {
fill: currentColor;
height: 1em;
}
.ProseMirror-icon span {
vertical-align: text-top;
}
.ProseMirror-gapcursor {
display: none;
pointer-events: none;
position: absolute;
}
.ProseMirror-gapcursor:after {
content: "";
display: block;
position: absolute;
top: -2px;
width: 20px;
border-top: 1px solid black;
animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;
}
@keyframes ProseMirror-cursor-blink {
to {
visibility: hidden;
}
}
.ProseMirror-focused .ProseMirror-gapcursor {
display: block;
}
/* Add space around the hr to make clicking it easier */
.ProseMirror-example-setup-style hr {
padding: 2px 10px;
border: none;
margin: 1em 0;
}
.ProseMirror-example-setup-style hr:after {
content: "";
display: block;
height: 1px;
background-color: silver;
line-height: 2px;
}
.ProseMirror ul, .ProseMirror ol {
padding-left: 30px;
}
.ProseMirror blockquote {
padding-left: 1em;
border-left: 3px solid #eee;
margin-left: 0; margin-right: 0;
}
.ProseMirror-example-setup-style img {
cursor: default;
}
.ProseMirror-prompt {
background: white;
padding: 5px 10px 5px 15px;
border: 1px solid silver;
position: fixed;
border-radius: 3px;
z-index: 11;
box-shadow: -.5px 2px 5px rgba(0, 0, 0, .2);
}
.ProseMirror-prompt h5 {
margin: 0;
font-weight: normal;
font-size: 100%;
color: #444;
}
.ProseMirror-prompt input[type="text"],
.ProseMirror-prompt textarea {
background: #eee;
border: none;
outline: none;
}
.ProseMirror-prompt input[type="text"] {
padding: 0 4px;
}
.ProseMirror-prompt-close {
position: absolute;
left: 2px; top: 1px;
color: #666;
border: none; background: transparent; padding: 0;
}
.ProseMirror-prompt-close:after {
content: "✕";
font-size: 12px;
}
.ProseMirror-invalid {
background: #ffc;
border: 1px solid #cc7;
border-radius: 4px;
padding: 5px 10px;
position: absolute;
min-width: 10em;
}
.ProseMirror-prompt-buttons {
margin-top: 5px;
display: none;
}
#editor, .editor {
background: white;
color: black;
background-clip: padding-box;
border-radius: 4px;
border: 2px solid rgba(0, 0, 0, 0.2);
padding: 5px 0;
margin-bottom: 23px;
}
.ProseMirror p:first-child,
.ProseMirror h1:first-child,
.ProseMirror h2:first-child,
.ProseMirror h3:first-child,
.ProseMirror h4:first-child,
.ProseMirror h5:first-child,
.ProseMirror h6:first-child {
margin-top: 10px;
}
.ProseMirror {
padding: 4px 8px 4px 14px;
line-height: 1.2;
outline: none;
}
.ProseMirror p { margin-bottom: 1em }
</style>
<script>
!function(){"use strict";function e(e){this.content=e}function t(e,n,i){for(let s=0;;s++){if(s==e.childCount||s==n.childCount)return e.childCount==n.childCount?null:i;let l=e.child(s),a=n.child(s);if(l!=a){if(!l.sameMarkup(a))return i;if(l.isText&&l.text!=a.text){let e=l.text,t=a.text,n=0;for(;e[n]==t[n];n++)i++;return n&&n<e.length&&n<t.length&&o(e.charCodeAt(n-1))&&r(e.charCodeAt(n))&&i--,i}if(l.content.size||a.content.size){let e=t(l.content,a.content,i+1);if(null!=e)return e}i+=l.nodeSize}else i+=l.nodeSize}}function n(e,t,i,s){for(let l=e.childCount,a=t.childCount;;){if(0==l||0==a)return l==a?null:{a:i,b:s};let c=e.child(--l),h=t.child(--a),d=c.nodeSize;if(c!=h){if(!c.sameMarkup(h))return{a:i,b:s};if(c.isText&&c.text!=h.text){let e=c.text,t=h.text,n=e.length,l=t.length;for(;n>0&&l>0&&e[n-1]==t[l-1];)n--,l--,i--,s--;return n&&l&&n<e.length&&o(e.charCodeAt(n-1))&&r(e.charCodeAt(n))&&(i++,s++),{a:i,b:s}}if(c.content.size||h.content.size){let e=n(c.content,h.content,i-1,s-1);if(e)return e}i-=d,s-=d}else i-=d,s-=d}}function r(e){return e>=56320&&e<57344}function o(e){return e>=55296&&e<56320}e.prototype={constructor:e,find:function(e){for(var t=0;t<this.content.length;t+=2)if(this.content[t]===e)return t;return-1},get:function(e){var t=this.find(e);return-1==t?void 0:this.content[t+1]},update:function(t,n,r){var o=r&&r!=t?this.remove(r):this,i=o.find(t),s=o.content.slice();return-1==i?s.push(r||t,n):(s[i+1]=n,r&&(s[i]=r)),new e(s)},remove:function(t){var n=this.find(t);if(-1==n)return this;var r=this.content.slice();return r.splice(n,2),new e(r)},addToStart:function(t,n){return new e([t,n].concat(this.remove(t).content))},addToEnd:function(t,n){var r=this.remove(t).content.slice();return r.push(t,n),new e(r)},addBefore:function(t,n,r){var o=this.remove(n),i=o.content.slice(),s=o.find(t);return i.splice(-1==s?i.length:s,0,n,r),new e(i)},forEach:function(e){for(var t=0;t<this.content.length;t+=2)e(this.content[t],this.content[t+1])},prepend:function(t){return(t=e.from(t)).size?new e(t.content.concat(this.subtract(t).content)):this},append:function(t){return(t=e.from(t)).size?new e(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var n=this;t=e.from(t);for(var r=0;r<t.content.length;r+=2)n=n.remove(t.content[r]);return n},toObject:function(){var e={};return this.forEach(function(t,n){e[t]=n}),e},get size(){return this.content.length>>1}},e.from=function(t){if(t instanceof e)return t;var n=[];if(t)for(var r in t)n.push(r,t[r]);return new e(n)};class i{constructor(e,t){if(this.content=e,this.size=t||0,null==t)for(let t=0;t<e.length;t++)this.size+=e[t].nodeSize}nodesBetween(e,t,n,r=0,o){for(let i=0,s=0;s<t;i++){let l=this.content[i],a=s+l.nodeSize;if(a>e&&!1!==n(l,r+s,o||null,i)&&l.content.size){let o=s+1;l.nodesBetween(Math.max(0,e-o),Math.min(l.content.size,t-o),n,r+o)}s=a}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,n,r){let o="",i=!0;return this.nodesBetween(e,t,(s,l)=>{let a=s.isText?s.text.slice(Math.max(e,l)-l,t-l):s.isLeaf?r?"function"==typeof r?r(s):r:s.type.spec.leafText?s.type.spec.leafText(s):"":"";s.isBlock&&(s.isLeaf&&a||s.isTextblock)&&n&&(i?i=!1:o+=n),o+=a},0),o}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,n=e.firstChild,r=this.content.slice(),o=0;for(t.isText&&t.sameMarkup(n)&&(r[r.length-1]=t.withText(t.text+n.text),o=1);o<e.content.length;o++)r.push(e.content[o]);return new i(r,this.size+e.size)}cut(e,t=this.size){if(0==e&&t==this.size)return this;let n=[],r=0;if(t>e)for(let o=0,i=0;i<t;o++){let s=this.content[o],l=i+s.nodeSize;l>e&&((i<e||l>t)&&(s=s.isText?s.cut(Math.max(0,e-i),Math.min(s.text.length,t-i)):s.cut(Math.max(0,e-i-1),Math.min(s.content.size,t-i-1))),n.push(s),r+=s.nodeSize),i=l}return new i(n,r)}cutByIndex(e,t){return e==t?i.empty:0==e&&t==this.content.length?this:new i(this.content.slice(e,t))}replaceChild(e,t){let n=this.content[e];if(n==t)return this;let r=this.content.slice(),o=this.size+t.nodeSize-n.nodeSize;return r[e]=t,new i(r,o)}addToStart(e){return new i([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new i(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw new RangeError("Index "+e+" out of range for "+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,n=0;t<this.content.length;t++){let r=this.content[t];e(r,n,t),n+=r.nodeSize}}findDiffStart(e,n=0){return t(this,e,n)}findDiffEnd(e,t=this.size,r=e.size){return n(this,e,t,r)}findIndex(e){if(0==e)return l(0,e);if(e==this.size)return l(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let t=0,n=0;;t++){let r=n+this.child(t).nodeSize;if(r>=e)return r==e?l(t+1,r):l(t,n);n=r}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,t){if(!t)return i.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return i.fromArray(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return i.empty;let t,n=0;for(let r=0;r<e.length;r++){let o=e[r];n+=o.nodeSize,r&&o.isText&&e[r-1].sameMarkup(o)?(t||(t=e.slice(0,r)),t[t.length-1]=o.withText(t[t.length-1].text+o.text)):t&&t.push(o)}return new i(t||e,n)}static from(e){if(!e)return i.empty;if(e instanceof i)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new i([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}i.empty=new i([],0);const s={index:0,offset:0};function l(e,t){return s.index=e,s.offset=t,s}function a(e,t){if(e===t)return!0;if(!e||"object"!=typeof e||!t||"object"!=typeof t)return!1;let n=Array.isArray(e);if(Array.isArray(t)!=n)return!1;if(n){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!a(e[n],t[n]))return!1}else{for(let n in e)if(!(n in t)||!a(e[n],t[n]))return!1;for(let n in t)if(!(n in e))return!1}return!0}class c{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,n=!1;for(let r=0;r<e.length;r++){let o=e[r];if(this.eq(o))return e;if(this.type.excludes(o.type))t||(t=e.slice(0,r));else{if(o.type.excludes(this.type))return e;!n&&o.type.rank>this.type.rank&&(t||(t=e.slice(0,r)),t.push(this),n=!0),t&&t.push(o)}}return t||(t=e.slice()),n||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&a(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Mark.fromJSON");let n=e.marks[t.type];if(!n)throw new RangeError(`There is no mark type ${t.type} in this schema`);let r=n.create(t.attrs);return n.checkAttrs(r.attrs),r}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].eq(t[n]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&0==e.length)return c.none;if(e instanceof c)return[e];let t=e.slice();return t.sort((e,t)=>e.type.rank-t.type.rank),t}}c.none=[];class h extends Error{}class d{constructor(e,t,n){this.content=e,this.openStart=t,this.openEnd=n}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let n=u(this.content,e+this.openStart,t,this.openStart+1,this.openEnd+1);return n&&new d(n,this.openStart,this.openEnd)}removeBetween(e,t){return new d(p(this.content,e+this.openStart,t+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,t){if(!t)return d.empty;let n=t.openStart||0,r=t.openEnd||0;if("number"!=typeof n||"number"!=typeof r)throw new RangeError("Invalid input for Slice.fromJSON");return new d(i.fromJSON(e,t.content),n,r)}static maxOpen(e,t=!0){let n=0,r=0;for(let r=e.firstChild;r&&!r.isLeaf&&(t||!r.type.spec.isolating);r=r.firstChild)n++;for(let n=e.lastChild;n&&!n.isLeaf&&(t||!n.type.spec.isolating);n=n.lastChild)r++;return new d(e,n,r)}}function p(e,t,n){let{index:r,offset:o}=e.findIndex(t),i=e.maybeChild(r),{index:s,offset:l}=e.findIndex(n);if(o==t||i.isText){if(l!=n&&!e.child(s).isText)throw new RangeError("Removing non-flat range");return e.cut(0,t).append(e.cut(n))}if(r!=s)throw new RangeError("Removing non-flat range");return e.replaceChild(r,i.copy(p(i.content,t-o-1,n-o-1)))}function u(e,t,n,r,o,i){let{index:s,offset:l}=e.findIndex(t),a=e.maybeChild(s);if(l==t||a.isText)return i&&r<=0&&o<=0&&!i.canReplace(s,s,n)?null:e.cut(0,t).append(n).append(e.cut(t));let c=u(a.content,t-l-1,n,0==s?r-1:0,s==e.childCount-1?o-1:0,a);return c&&e.replaceChild(s,a.copy(c))}function f(e,t,n){if(n.openStart>e.depth)throw new h("Inserted content deeper than insertion position");if(e.depth-n.openStart!=t.depth-n.openEnd)throw new h("Inconsistent open depths");return m(e,t,n,0)}function m(e,t,n,r){let o=e.index(r),s=e.node(r);if(o==t.index(r)&&r<e.depth-n.openStart){let i=m(e,t,n,r+1);return s.copy(s.content.replaceChild(o,i))}if(n.content.size){if(n.openStart||n.openEnd||e.depth!=r||t.depth!=r){let{start:o,end:l}=function(e,t){let n=t.depth-e.openStart,r=t.node(n).copy(e.content);for(let e=n-1;e>=0;e--)r=t.node(e).copy(i.from(r));return{start:r.resolveNoCache(e.openStart+n),end:r.resolveNoCache(r.content.size-e.openEnd-n)}}(n,e);return b(s,k(e,o,l,t,r))}{let r=e.parent,o=r.content;return b(r,o.cut(0,e.parentOffset).append(n.content).append(o.cut(t.parentOffset)))}}return b(s,x(e,t,r))}function g(e,t){if(!t.type.compatibleContent(e.type))throw new h("Cannot join "+t.type.name+" onto "+e.type.name)}function y(e,t,n){let r=e.node(n);return g(r,t.node(n)),r}function w(e,t){let n=t.length-1;n>=0&&e.isText&&e.sameMarkup(t[n])?t[n]=e.withText(t[n].text+e.text):t.push(e)}function v(e,t,n,r){let o=(t||e).node(n),i=0,s=t?t.index(n):o.childCount;e&&(i=e.index(n),e.depth>n?i++:e.textOffset&&(w(e.nodeAfter,r),i++));for(let e=i;e<s;e++)w(o.child(e),r);t&&t.depth==n&&t.textOffset&&w(t.nodeBefore,r)}function b(e,t){if(!e.type.validContent(t))throw new h("Invalid content for node "+e.type.name);return e.copy(t)}function k(e,t,n,r,o){let s=e.depth>o&&y(e,t,o+1),l=r.depth>o&&y(n,r,o+1),a=[];return v(null,e,o,a),s&&l&&t.index(o)==n.index(o)?(g(s,l),w(b(s,k(e,t,n,r,o+1)),a)):(s&&w(b(s,x(e,t,o+1)),a),v(t,n,o,a),l&&w(b(l,x(n,r,o+1)),a)),v(r,null,o,a),new i(a)}function x(e,t,n){let r=[];if(v(null,e,n,r),e.depth>n){w(b(y(e,t,n+1),x(e,t,n+1)),r)}return v(t,null,n,r),new i(r)}d.empty=new d(i.empty,0,0);class S{constructor(e,t,n){this.pos=e,this.path=t,this.parentOffset=n,this.depth=t.length/3-1}resolveDepth(e){return null==e?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[3*this.resolveDepth(e)]}index(e){return this.path[3*this.resolveDepth(e)+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e!=this.depth||this.textOffset?1:0)}start(e){return 0==(e=this.resolveDepth(e))?0:this.path[3*e-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(!(e=this.resolveDepth(e)))throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[3*e-1]}after(e){if(!(e=this.resolveDepth(e)))throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[3*e-1]+this.path[3*e].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let n=this.pos-this.path[this.path.length-1],r=e.child(t);return n?e.child(t).cut(n):r}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):0==e?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let n=this.path[3*t],r=0==t?0:this.path[3*t-1]+1;for(let t=0;t<e;t++)r+=n.child(t).nodeSize;return r}marks(){let e=this.parent,t=this.index();if(0==e.content.size)return c.none;if(this.textOffset)return e.child(t).marks;let n=e.maybeChild(t-1),r=e.maybeChild(t);if(!n){let e=n;n=r,r=e}let o=n.marks;for(var i=0;i<o.length;i++)!1!==o[i].type.spec.inclusive||r&&o[i].isInSet(r.marks)||(o=o[i--].removeFromSet(o));return o}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let n=t.marks,r=e.parent.maybeChild(e.index());for(var o=0;o<n.length;o++)!1!==n[o].type.spec.inclusive||r&&n[o].isInSet(r.marks)||(n=n[o--].removeFromSet(n));return n}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let n=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);n>=0;n--)if(e.pos<=this.end(n)&&(!t||t(this.node(n))))return new N(this,e,n);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let t=1;t<=this.depth;t++)e+=(e?"/":"")+this.node(t).type.name+"_"+this.index(t-1);return e+":"+this.parentOffset}static resolve(e,t){if(!(t>=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let n=[],r=0,o=t;for(let t=e;;){let{index:e,offset:i}=t.content.findIndex(o),s=o-i;if(n.push(t,e,r+i),!s)break;if(t=t.child(e),t.isText)break;o=s-1,r+=i+1}return new S(t,n,o)}static resolveCached(e,t){let n=O.get(e);if(n)for(let e=0;e<n.elts.length;e++){let r=n.elts[e];if(r.pos==t)return r}else O.set(e,n=new C);let r=n.elts[n.i]=S.resolve(e,t);return n.i=(n.i+1)%M,r}}class C{constructor(){this.elts=[],this.i=0}}const M=12,O=new WeakMap;class N{constructor(e,t,n){this.$from=e,this.$to=t,this.depth=n}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const D=Object.create(null);class T{constructor(e,t,n,r=c.none){this.type=e,this.attrs=t,this.marks=r,this.content=n||i.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,n,r=0){this.content.nodesBetween(e,t,n,r,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,t,n,r){return this.content.textBetween(e,t,n,r)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,n){return this.type==e&&a(this.attrs,t||e.defaultAttrs||D)&&c.sameSet(this.marks,n||c.none)}copy(e=null){return e==this.content?this:new T(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new T(this.type,this.attrs,this.content,e)}cut(e,t=this.content.size){return 0==e&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,n=!1){if(e==t)return d.empty;let r=this.resolve(e),o=this.resolve(t),i=n?0:r.sharedDepth(t),s=r.start(i),l=r.node(i).content.cut(r.pos-s,o.pos-s);return new d(l,r.depth-i,o.depth-i)}replace(e,t,n){return f(this.resolve(e),this.resolve(t),n)}nodeAt(e){for(let t=this;;){let{index:n,offset:r}=t.content.findIndex(e);if(t=t.maybeChild(n),!t)return null;if(r==e||t.isText)return t;e-=r+1}}childAfter(e){let{index:t,offset:n}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:n}}childBefore(e){if(0==e)return{node:null,index:0,offset:0};let{index:t,offset:n}=this.content.findIndex(e);if(n<e)return{node:this.content.child(t),index:t,offset:n};let r=this.content.child(t-1);return{node:r,index:t-1,offset:n-r.nodeSize}}resolve(e){return S.resolveCached(this,e)}resolveNoCache(e){return S.resolve(this,e)}rangeHasMark(e,t,n){let r=!1;return t>e&&this.nodesBetween(e,t,e=>(n.isInSet(e.marks)&&(r=!0),!r)),r}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),A(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw new Error("Called contentMatchAt on a node with invalid content");return t}canReplace(e,t,n=i.empty,r=0,o=n.childCount){let s=this.contentMatchAt(e).matchFragment(n,r,o),l=s&&s.matchFragment(this.content,t);if(!l||!l.validEnd)return!1;for(let e=r;e<o;e++)if(!this.type.allowsMarks(n.child(e).marks))return!1;return!0}canReplaceWith(e,t,n,r){if(r&&!this.type.allowsMarks(r))return!1;let o=this.contentMatchAt(e).matchType(n),i=o&&o.matchFragment(this.content,t);return!!i&&i.validEnd}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=c.none;for(let t=0;t<this.marks.length;t++){let n=this.marks[t];n.type.checkAttrs(n.attrs),e=n.addToSet(e)}if(!c.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(e=>e.type.name)}`);this.content.forEach(e=>e.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(e=>e.toJSON())),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let n;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");n=t.marks.map(e.markFromJSON)}if("text"==t.type){if("string"!=typeof t.text)throw new RangeError("Invalid text node in JSON");return e.text(t.text,n)}let r=i.fromJSON(e,t.content),o=e.nodeType(t.type).create(t.attrs,r,n);return o.type.checkAttrs(o.attrs),o}}T.prototype.text=void 0;class E extends T{constructor(e,t,n,r){if(super(e,t,null,r),!n)throw new RangeError("Empty text nodes are not allowed");this.text=n}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):A(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,t){return this.text.slice(e,t)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new E(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new E(this.type,this.attrs,e,this.marks)}cut(e=0,t=this.text.length){return 0==e&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function A(e,t){for(let n=e.length-1;n>=0;n--)t=e[n].type.name+"("+t+")";return t}class I{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let n=new R(e,t);if(null==n.next)return I.empty;let r=z(n);n.next&&n.err("Unexpected trailing text");let o=function(e){let t=Object.create(null);return n(q(e,0));function n(r){let o=[];r.forEach(t=>{e[t].forEach(({term:t,to:n})=>{if(!t)return;let r;for(let e=0;e<o.length;e++)o[e][0]==t&&(r=o[e][1]);q(e,n).forEach(e=>{r||o.push([t,r=[]]),-1==r.indexOf(e)&&r.push(e)})})});let i=t[r.join(",")]=new I(r.indexOf(e.length-1)>-1);for(let e=0;e<o.length;e++){let r=o[e][1].sort(F);i.next.push({type:o[e][0],next:t[r.join(",")]||n(r)})}return i}}(function(e){let t=[[]];return o(i(e,0),n()),t;function n(){return t.push([])-1}function r(e,n,r){let o={term:r,to:n};return t[e].push(o),o}function o(e,t){e.forEach(e=>e.to=t)}function i(e,t){if("choice"==e.type)return e.exprs.reduce((e,n)=>e.concat(i(n,t)),[]);if("seq"!=e.type){if("star"==e.type){let s=n();return r(t,s),o(i(e.expr,s),s),[r(s)]}if("plus"==e.type){let s=n();return o(i(e.expr,t),s),o(i(e.expr,s),s),[r(s)]}if("opt"==e.type)return[r(t)].concat(i(e.expr,t));if("range"==e.type){let s=t;for(let t=0;t<e.min;t++){let t=n();o(i(e.expr,s),t),s=t}if(-1==e.max)o(i(e.expr,s),s);else for(let t=e.min;t<e.max;t++){let t=n();r(s,t),o(i(e.expr,s),t),s=t}return[r(s)]}if("name"==e.type)return[r(t,void 0,e.value)];throw new Error("Unknown expr type")}for(let r=0;;r++){let s=i(e.exprs[r],t);if(r==e.exprs.length-1)return s;o(s,t=n())}}}(r));return function(e,t){for(let n=0,r=[e];n<r.length;n++){let e=r[n],o=!e.validEnd,i=[];for(let t=0;t<e.next.length;t++){let{type:n,next:s}=e.next[t];i.push(n.name),!o||n.isText||n.hasRequiredAttrs()||(o=!1),-1==r.indexOf(s)&&r.push(s)}o&&t.err("Only non-generatable nodes ("+i.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}(o,n),o}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,n=e.childCount){let r=this;for(let o=t;r&&o<n;o++)r=r.matchType(e.child(o).type);return r}get inlineContent(){return 0!=this.next.length&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!t.isText&&!t.hasRequiredAttrs())return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let n=0;n<e.next.length;n++)if(this.next[t].type==e.next[n].type)return!0;return!1}fillBefore(e,t=!1,n=0){let r=[this];return function o(s,l){let a=s.matchFragment(e,n);if(a&&(!t||a.validEnd))return i.from(l.map(e=>e.createAndFill()));for(let e=0;e<s.next.length;e++){let{type:t,next:n}=s.next[e];if(!t.isText&&!t.hasRequiredAttrs()&&-1==r.indexOf(n)){r.push(n);let e=o(n,l.concat(t));if(e)return e}}return null}(this,[])}findWrapping(e){for(let t=0;t<this.wrapCache.length;t+=2)if(this.wrapCache[t]==e)return this.wrapCache[t+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),n=[{match:this,type:null,via:null}];for(;n.length;){let r=n.shift(),o=r.match;if(o.matchType(e)){let e=[];for(let t=r;t.type;t=t.via)e.push(t.type);return e.reverse()}for(let e=0;e<o.next.length;e++){let{type:i,next:s}=o.next[e];i.isLeaf||i.hasRequiredAttrs()||i.name in t||r.type&&!s.validEnd||(n.push({match:i.contentMatch,type:i,via:r}),t[i.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];return function t(n){e.push(n);for(let r=0;r<n.next.length;r++)-1==e.indexOf(n.next[r].next)&&t(n.next[r].next)}(this),e.map((t,n)=>{let r=n+(t.validEnd?"*":" ")+" ";for(let n=0;n<t.next.length;n++)r+=(n?", ":"")+t.next[n].type.name+"->"+e.indexOf(t.next[n].next);return r}).join("\n")}}I.empty=new I(!0);class R{constructor(e,t){this.string=e,this.nodeTypes=t,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),""==this.tokens[this.tokens.length-1]&&this.tokens.pop(),""==this.tokens[0]&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}}function z(e){let t=[];do{t.push(P(e))}while(e.eat("|"));return 1==t.length?t[0]:{type:"choice",exprs:t}}function P(e){let t=[];do{t.push(B(e))}while(e.next&&")"!=e.next&&"|"!=e.next);return 1==t.length?t[0]:{type:"seq",exprs:t}}function B(e){let t=function(e){if(e.eat("(")){let t=z(e);return e.eat(")")||e.err("Missing closing paren"),t}if(!/\W/.test(e.next)){let t=function(e,t){let n=e.nodeTypes,r=n[t];if(r)return[r];let o=[];for(let e in n){let r=n[e];r.isInGroup(t)&&o.push(r)}0==o.length&&e.err("No node type or group '"+t+"' found");return o}(e,e.next).map(t=>(null==e.inline?e.inline=t.isInline:e.inline!=t.isInline&&e.err("Mixing inline and block content"),{type:"name",value:t}));return e.pos++,1==t.length?t[0]:{type:"choice",exprs:t}}e.err("Unexpected token '"+e.next+"'")}(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("{"))break;t=V(e,t)}return t}function $(e){/\D/.test(e.next)&&e.err("Expected number, got '"+e.next+"'");let t=Number(e.next);return e.pos++,t}function V(e,t){let n=$(e),r=n;return e.eat(",")&&(r="}"!=e.next?$(e):-1),e.eat("}")||e.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:t}}function F(e,t){return t-e}function q(e,t){let n=[];return function t(r){let o=e[r];if(1==o.length&&!o[0].term)return t(o[0].to);n.push(r);for(let e=0;e<o.length;e++){let{term:r,to:i}=o[e];r||-1!=n.indexOf(i)||t(i)}}(t),n.sort(F)}function L(e){let t=Object.create(null);for(let n in e){let r=e[n];if(!r.hasDefault)return null;t[n]=r.default}return t}function _(e,t){let n=Object.create(null);for(let r in e){let o=t&&t[r];if(void 0===o){let t=e[r];if(!t.hasDefault)throw new RangeError("No value supplied for attribute "+r);o=t.default}n[r]=o}return n}function W(e,t,n,r){for(let o in t)if(!(o in e))throw new RangeError(`Unsupported attribute ${o} for ${n} of type ${r}`);for(let n in e)e[n].validate&&e[n].validate(t[n])}function J(e,t){let n=Object.create(null);if(t)for(let r in t)n[r]=new K(e,r,t[r]);return n}class j{constructor(e,t,n){this.name=e,this.schema=t,this.spec=n,this.markSet=null,this.groups=n.group?n.group.split(" "):[],this.attrs=J(e,n.attrs),this.defaultAttrs=L(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(n.inline||"text"==e),this.isText="text"==e}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==I.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(e){return this.groups.indexOf(e)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:_(this.attrs,e)}create(e=null,t,n){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new T(this,this.computeAttrs(e),i.from(t),c.setFrom(n))}createChecked(e=null,t,n){return t=i.from(t),this.checkContent(t),new T(this,this.computeAttrs(e),t,c.setFrom(n))}createAndFill(e=null,t,n){if(e=this.computeAttrs(e),(t=i.from(t)).size){let e=this.contentMatch.fillBefore(t);if(!e)return null;t=e.append(t)}let r=this.contentMatch.matchFragment(t),o=r&&r.fillBefore(i.empty,!0);return o?new T(this,e,t.append(o),c.setFrom(n)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let t=0;t<e.childCount;t++)if(!this.allowsMarks(e.child(t).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){W(this.attrs,e,"node",this.name)}allowsMarkType(e){return null==this.markSet||this.markSet.indexOf(e)>-1}allowsMarks(e){if(null==this.markSet)return!0;for(let t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){if(null==this.markSet)return e;let t;for(let n=0;n<e.length;n++)this.allowsMarkType(e[n].type)?t&&t.push(e[n]):t||(t=e.slice(0,n));return t?t.length?t:c.none:e}static compile(e,t){let n=Object.create(null);e.forEach((e,r)=>n[e]=new j(e,t,r));let r=t.spec.topNode||"doc";if(!n[r])throw new RangeError("Schema is missing its top node type ('"+r+"')");if(!n.text)throw new RangeError("Every schema needs a 'text' type");for(let e in n.text.attrs)throw new RangeError("The text node type should not have attributes");return n}}class K{constructor(e,t,n){this.hasDefault=Object.prototype.hasOwnProperty.call(n,"default"),this.default=n.default,this.validate="string"==typeof n.validate?function(e,t,n){let r=n.split("|");return n=>{let o=null===n?"null":typeof n;if(r.indexOf(o)<0)throw new RangeError(`Expected value of type ${r} for attribute ${t} on type ${e}, got ${o}`)}}(e,t,n.validate):n.validate}get isRequired(){return!this.hasDefault}}class H{constructor(e,t,n,r){this.name=e,this.rank=t,this.schema=n,this.spec=r,this.attrs=J(e,r.attrs),this.excluded=null;let o=L(this.attrs);this.instance=o?new c(this,o):null}create(e=null){return!e&&this.instance?this.instance:new c(this,_(this.attrs,e))}static compile(e,t){let n=Object.create(null),r=0;return e.forEach((e,o)=>n[e]=new H(e,r++,t,o)),n}removeFromSet(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}checkAttrs(e){W(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class U{constructor(t){this.linebreakReplacement=null,this.cached=Object.create(null);let n=this.spec={};for(let e in t)n[e]=t[e];n.nodes=e.from(t.nodes),n.marks=e.from(t.marks||{}),this.nodes=j.compile(this.spec.nodes,this),this.marks=H.compile(this.spec.marks,this);let r=Object.create(null);for(let e in this.nodes){if(e in this.marks)throw new RangeError(e+" can not be both a node and a mark");let t=this.nodes[e],n=t.spec.content||"",o=t.spec.marks;if(t.contentMatch=r[n]||(r[n]=I.parse(n,this.nodes)),t.inlineContent=t.contentMatch.inlineContent,t.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!t.isInline||!t.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=t}t.markSet="_"==o?null:o?G(this,o.split(" ")):""!=o&&t.inlineContent?null:[]}for(let e in this.marks){let t=this.marks[e],n=t.spec.excludes;t.excluded=null==n?[t]:""==n?[]:G(this,n.split(" "))}this.nodeFromJSON=e=>T.fromJSON(this,e),this.markFromJSON=e=>c.fromJSON(this,e),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,n,r){if("string"==typeof e)e=this.nodeType(e);else{if(!(e instanceof j))throw new RangeError("Invalid node type: "+e);if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}return e.createChecked(t,n,r)}text(e,t){let n=this.nodes.text;return new E(n,n.defaultAttrs,e,c.setFrom(t))}mark(e,t){return"string"==typeof e&&(e=this.marks[e]),e.create(t)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}}function G(e,t){let n=[];for(let r=0;r<t.length;r++){let o=t[r],i=e.marks[o],s=i;if(i)n.push(i);else for(let t in e.marks){let r=e.marks[t];("_"==o||r.spec.group&&r.spec.group.split(" ").indexOf(o)>-1)&&n.push(s=r)}if(!s)throw new SyntaxError("Unknown mark type: '"+t[r]+"'")}return n}class Y{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let n=this.matchedStyles=[];t.forEach(e=>{if(function(e){return null!=e.tag}(e))this.tags.push(e);else if(function(e){return null!=e.style}(e)){let t=/[^=]*/.exec(e.style)[0];n.indexOf(t)<0&&n.push(t),this.styles.push(e)}}),this.normalizeLists=!this.tags.some(t=>{if(!/^(ul|ol)\b/.test(t.tag)||!t.node)return!1;let n=e.nodes[t.node];return n.contentMatch.matchType(n)})}parse(e,t={}){let n=new ne(this,t,!1);return n.addAll(e,c.none,t.from,t.to),n.finish()}parseSlice(e,t={}){let n=new ne(this,t,!0);return n.addAll(e,c.none,t.from,t.to),d.maxOpen(n.finish())}matchTag(e,t,n){for(let r=n?this.tags.indexOf(n)+1:0;r<this.tags.length;r++){let n=this.tags[r];if(re(e,n.tag)&&(void 0===n.namespace||e.namespaceURI==n.namespace)&&(!n.context||t.matchesContext(n.context))){if(n.getAttrs){let t=n.getAttrs(e);if(!1===t)continue;n.attrs=t||void 0}return n}}}matchStyle(e,t,n,r){for(let o=r?this.styles.indexOf(r)+1:0;o<this.styles.length;o++){let r=this.styles[o],i=r.style;if(!(0!=i.indexOf(e)||r.context&&!n.matchesContext(r.context)||i.length>e.length&&(61!=i.charCodeAt(e.length)||i.slice(e.length+1)!=t))){if(r.getAttrs){let e=r.getAttrs(t);if(!1===e)continue;r.attrs=e||void 0}return r}}}static schemaRules(e){let t=[];function n(e){let n=null==e.priority?50:e.priority,r=0;for(;r<t.length;r++){let e=t[r];if((null==e.priority?50:e.priority)<n)break}t.splice(r,0,e)}for(let t in e.marks){let r=e.marks[t].spec.parseDOM;r&&r.forEach(e=>{n(e=oe(e)),e.mark||e.ignore||e.clearMark||(e.mark=t)})}for(let t in e.nodes){let r=e.nodes[t].spec.parseDOM;r&&r.forEach(e=>{n(e=oe(e)),e.node||e.ignore||e.mark||(e.node=t)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Y(e,Y.schemaRules(e)))}}const Q={address:!0,article:!0,aside:!0,blockquote:!0,body:!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},X={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Z={ol:!0,ul:!0};function ee(e,t,n){return null!=t?(t?1:0)|("full"===t?2:0):e&&"pre"==e.whitespace?3:-5&n}class te{constructor(e,t,n,r,o,i){this.type=e,this.attrs=t,this.marks=n,this.solid=r,this.options=i,this.content=[],this.activeMarks=c.none,this.match=o||(4&i?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(i.from(e));if(!t){let t,n=this.type.contentMatch;return(t=n.findWrapping(e.type))?(this.match=n,t):null}this.match=this.type.contentMatch.matchFragment(t)}return this.match.findWrapping(e.type)}finish(e){if(!(1&this.options)){let e,t=this.content[this.content.length-1];if(t&&t.isText&&(e=/[ \t\r\n\u000c]+$/.exec(t.text))){let n=t;t.text.length==e[0].length?this.content.pop():this.content[this.content.length-1]=n.withText(n.text.slice(0,n.text.length-e[0].length))}}let t=i.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(i.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!Q.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class ne{constructor(e,t,n){this.parser=e,this.options=t,this.isOpen=n,this.open=0,this.localPreserveWS=!1;let r,o=t.topNode,i=ee(null,t.preserveWhitespace,0)|(n?4:0);r=o?new te(o.type,o.attrs,c.none,!0,t.topMatch||o.type.contentMatch,i):new te(n?null:e.schema.topNodeType,null,c.none,!0,null,i),this.nodes=[r],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){3==e.nodeType?this.addTextNode(e,t):1==e.nodeType&&this.addElement(e,t)}addTextNode(e,t){let n=e.nodeValue,r=this.top,o=2&r.options?"full":this.localPreserveWS||(1&r.options)>0,{schema:i}=this.parser;if("full"===o||r.inlineContext(e)||/[^ \t\r\n\u000c]/.test(n)){if(o)if("full"===o)n=n.replace(/\r\n?/g,"\n");else if(i.linebreakReplacement&&/[\r\n]/.test(n)&&this.top.findWrapping(i.linebreakReplacement.create())){let e=n.split(/\r?\n|\r/);for(let n=0;n<e.length;n++)n&&this.insertNode(i.linebreakReplacement.create(),t,!0),e[n]&&this.insertNode(i.text(e[n]),t,!/\S/.test(e[n]));n=""}else n=n.replace(/\r?\n|\r/g," ");else if(n=n.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(n)&&this.open==this.nodes.length-1){let t=r.content[r.content.length-1],o=e.previousSibling;(!t||o&&"BR"==o.nodeName||t.isText&&/[ \t\r\n\u000c]$/.test(t.text))&&(n=n.slice(1))}n&&this.insertNode(i.text(n),t,!/\S/.test(n)),this.findInText(e)}else this.findInside(e)}addElement(e,t,n){let r=this.localPreserveWS,o=this.top;("PRE"==e.tagName||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let i,s=e.nodeName.toLowerCase();Z.hasOwnProperty(s)&&this.parser.normalizeLists&&function(e){for(let t=e.firstChild,n=null;t;t=t.nextSibling){let e=1==t.nodeType?t.nodeName.toLowerCase():null;e&&Z.hasOwnProperty(e)&&n?(n.appendChild(t),t=n):"li"==e?n=t:e&&(n=null)}}(e);let l=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(i=this.parser.matchTag(e,this,n));e:if(l?l.ignore:X.hasOwnProperty(s))this.findInside(e),this.ignoreFallback(e,t);else if(!l||l.skip||l.closeParent){l&&l.closeParent?this.open=Math.max(0,this.open-1):l&&l.skip.nodeType&&(e=l.skip);let n,r=this.needsBlock;if(Q.hasOwnProperty(s))o.content.length&&o.content[0].isInline&&this.open&&(this.open--,o=this.top),n=!0,o.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break e}let i=l&&l.skip?t:this.readStyles(e,t);i&&this.addAll(e,i),n&&this.sync(o),this.needsBlock=r}else{let n=this.readStyles(e,t);n&&this.addElementByRule(e,l,n,!1===l.consuming?i:void 0)}this.localPreserveWS=r}leafFallback(e,t){"BR"==e.nodeName&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode("\n"),t)}ignoreFallback(e,t){"BR"!=e.nodeName||this.top.type&&this.top.type.inlineContent||this.findPlace(this.parser.schema.text("-"),t,!0)}readStyles(e,t){let n=e.style;if(n&&n.length)for(let e=0;e<this.parser.matchedStyles.length;e++){let r=this.parser.matchedStyles[e],o=n.getPropertyValue(r);if(o)for(let e;;){let n=this.parser.matchStyle(r,o,this,e);if(!n)break;if(n.ignore)return null;if(t=n.clearMark?t.filter(e=>!n.clearMark(e)):t.concat(this.parser.schema.marks[n.mark].create(n.attrs)),!1!==n.consuming)break;e=n}}return t}addElementByRule(e,t,n,r){let o,i;if(t.node)if(i=this.parser.schema.nodes[t.node],i.isLeaf)this.insertNode(i.create(t.attrs),n,"BR"==e.nodeName)||this.leafFallback(e,n);else{let e=this.enter(i,t.attrs||null,n,t.preserveWhitespace);e&&(o=!0,n=e)}else{let e=this.parser.schema.marks[t.mark];n=n.concat(e.create(t.attrs))}let s=this.top;if(i&&i.isLeaf)this.findInside(e);else if(r)this.addElement(e,n,r);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(e=>this.insertNode(e,n,!1));else{let r=e;"string"==typeof t.contentElement?r=e.querySelector(t.contentElement):"function"==typeof t.contentElement?r=t.contentElement(e):t.contentElement&&(r=t.contentElement),this.findAround(e,r,!0),this.addAll(r,n),this.findAround(e,r,!1)}o&&this.sync(s)&&this.open--}addAll(e,t,n,r){let o=n||0;for(let i=n?e.childNodes[n]:e.firstChild,s=null==r?null:e.childNodes[r];i!=s;i=i.nextSibling,++o)this.findAtPoint(e,o),this.addDOM(i,t);this.findAtPoint(e,o)}findPlace(e,t,n){let r,o;for(let t=this.open,i=0;t>=0;t--){let s=this.nodes[t],l=s.findWrapping(e);if(l&&(!r||r.length>l.length+i)&&(r=l,o=s,!l.length))break;if(s.solid){if(n)break;i+=2}}if(!r)return null;this.sync(o);for(let e=0;e<r.length;e++)t=this.enterInner(r[e],null,t,!1);return t}insertNode(e,t,n){if(e.isInline&&this.needsBlock&&!this.top.type){let e=this.textblockFromContext();e&&(t=this.enterInner(e,null,t))}let r=this.findPlace(e,t,n);if(r){this.closeExtra();let t=this.top;t.match&&(t.match=t.match.matchType(e.type));let n=c.none;for(let o of r.concat(e.marks))(t.type?t.type.allowsMarkType(o.type):ie(o.type,e.type))&&(n=o.addToSet(n));return t.content.push(e.mark(n)),!0}return!1}enter(e,t,n,r){let o=this.findPlace(e.create(t),n,!1);return o&&(o=this.enterInner(e,t,n,!0,r)),o}enterInner(e,t,n,r=!1,o){this.closeExtra();let i=this.top;i.match=i.match&&i.match.matchType(e);let s=ee(e,o,i.options);4&i.options&&0==i.content.length&&(s|=4);let l=c.none;return n=n.filter(t=>!(i.type?i.type.allowsMarkType(t.type):ie(t.type,e))||(l=t.addToSet(l),!1)),this.nodes.push(new te(e,t,l,r,null,s)),this.open++,n}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!(!this.isOpen&&!this.options.topOpen))}sync(e){for(let t=this.open;t>=0;t--){if(this.nodes[t]==e)return this.open=t,!0;this.localPreserveWS&&(this.nodes[t].options|=1)}return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let n=this.nodes[t].content;for(let t=n.length-1;t>=0;t--)e+=n[t].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&this.find[n].offset==t&&(this.find[n].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)null==this.find[t].pos&&1==e.nodeType&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,n){if(e!=t&&this.find)for(let r=0;r<this.find.length;r++)if(null==this.find[r].pos&&1==e.nodeType&&e.contains(this.find[r].node)){t.compareDocumentPosition(this.find[r].node)&(n?2:4)&&(this.find[r].pos=this.currentPos)}}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split("/"),n=this.options.context,r=!(this.isOpen||n&&n.parent.type!=this.nodes[0].type),o=-(n?n.depth+1:0)+(r?0:1),i=(e,s)=>{for(;e>=0;e--){let l=t[e];if(""==l){if(e==t.length-1||0==e)continue;for(;s>=o;s--)if(i(e-1,s))return!0;return!1}{let e=s>0||0==s&&r?this.nodes[s].type:n&&s>=o?n.node(s-o).type:null;if(!e||e.name!=l&&!e.isInGroup(l))return!1;s--}}return!0};return i(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let n=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(n&&n.isTextblock&&n.defaultAttrs)return n}for(let e in this.parser.schema.nodes){let t=this.parser.schema.nodes[e];if(t.isTextblock&&t.defaultAttrs)return t}}}function re(e,t){return(e.matches||e.msMatchesSelector||e.webkitMatchesSelector||e.mozMatchesSelector).call(e,t)}function oe(e){let t={};for(let n in e)t[n]=e[n];return t}function ie(e,t){let n=t.schema.nodes;for(let r in n){let o=n[r];if(!o.allowsMarkType(e))continue;let i=[],s=e=>{i.push(e);for(let n=0;n<e.edgeCount;n++){let{type:r,next:o}=e.edge(n);if(r==t)return!0;if(i.indexOf(o)<0&&s(o))return!0}};if(s(o.contentMatch))return!0}}class se{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},n){n||(n=ae(t).createDocumentFragment());let r=n,o=[];return e.forEach(e=>{if(o.length||e.marks.length){let n=0,i=0;for(;n<o.length&&i<e.marks.length;){let t=e.marks[i];if(this.marks[t.type.name]){if(!t.eq(o[n][0])||!1===t.type.spec.spanning)break;n++,i++}else i++}for(;n<o.length;)r=o.pop()[1];for(;i<e.marks.length;){let n=e.marks[i++],s=this.serializeMark(n,e.isInline,t);s&&(o.push([n,r]),r.appendChild(s.dom),r=s.contentDOM||s.dom)}}r.appendChild(this.serializeNodeInner(e,t))}),n}serializeNodeInner(e,t){if(e.isText)return ae(t).createTextNode(e.text);let{dom:n,contentDOM:r}=de(ae(t),this.nodes[e.type.name](e),null,e.attrs);if(r){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,r)}return n}serializeNode(e,t={}){let n=this.serializeNodeInner(e,t);for(let r=e.marks.length-1;r>=0;r--){let o=this.serializeMark(e.marks[r],e.isInline,t);o&&((o.contentDOM||o.dom).appendChild(n),n=o.dom)}return n}serializeMark(e,t,n={}){let r=this.marks[e.type.name];return r&&de(ae(n),r(e,t),null,e.attrs)}static renderSpec(e,t,n=null,r){return"string"==typeof t?{dom:e.createTextNode(t)}:de(e,t,n,r)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new se(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=le(e.nodes);return t.text||(t.text=e=>e.text),t}static marksFromSchema(e){return le(e.marks)}}function le(e){let t={};for(let n in e){let r=e[n].spec.toDOM;r&&(t[n]=r)}return t}function ae(e){return e.document||window.document}const ce=new WeakMap;function he(e){let t=ce.get(e);return void 0===t&&ce.set(e,t=function(e){let t=null;function n(e){if(e&&"object"==typeof e)if(Array.isArray(e))if("string"==typeof e[0])t||(t=[]),t.push(e);else for(let t=0;t<e.length;t++)n(e[t]);else for(let t in e)n(e[t])}return n(e),t}(e)),t}function de(e,t,n,r){if(1==t.nodeType)return{dom:t};if(t.dom&&1==t.dom.nodeType)return t;let o,i=t[0];if("string"!=typeof i)throw new RangeError("Invalid array passed to renderSpec");if(r&&(o=he(r))&&o.indexOf(t)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let s,l=i.indexOf(" ");l>0&&(n=i.slice(0,l),i=i.slice(l+1));let a=n?e.createElementNS(n,i):e.createElement(i),c=t[1],h=1;if(c&&"object"==typeof c&&null==c.nodeType&&!Array.isArray(c)){h=2;for(let e in c)if(null!=c[e]){let t=e.indexOf(" ");t>0?a.setAttributeNS(e.slice(0,t),e.slice(t+1),c[e]):"style"==e&&a.style?a.style.cssText=c[e]:a.setAttribute(e,c[e])}}for(let o=h;o<t.length;o++){let i=t[o];if(0===i){if(o<t.length-1||o>h)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}if("string"==typeof i)a.appendChild(e.createTextNode(i));else{let{dom:t,contentDOM:o}=de(e,i,n,r);if(a.appendChild(t),o){if(s)throw new RangeError("Multiple content holes");s=o}}}return{dom:a,contentDOM:s}}var pe=Object.freeze({__proto__:null,ContentMatch:I,DOMParser:Y,DOMSerializer:se,Fragment:i,Mark:c,MarkType:H,Node:T,NodeRange:N,NodeType:j,ReplaceError:h,ResolvedPos:S,Schema:U,Slice:d});const ue=Math.pow(2,16);function fe(e,t){return e+t*ue}function me(e){return 65535&e}class ge{constructor(e,t,n){this.pos=e,this.delInfo=t,this.recover=n}get deleted(){return(8&this.delInfo)>0}get deletedBefore(){return(5&this.delInfo)>0}get deletedAfter(){return(6&this.delInfo)>0}get deletedAcross(){return(4&this.delInfo)>0}}class ye{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&ye.empty)return ye.empty}recover(e){let t=0,n=me(e);if(!this.inverted)for(let e=0;e<n;e++)t+=this.ranges[3*e+2]-this.ranges[3*e+1];return this.ranges[3*n]+t+function(e){return(e-(65535&e))/ue}(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,n){let r=0,o=this.inverted?2:1,i=this.inverted?1:2;for(let s=0;s<this.ranges.length;s+=3){let l=this.ranges[s]-(this.inverted?r:0);if(l>e)break;let a=this.ranges[s+o],c=this.ranges[s+i],h=l+a;if(e<=h){let o=l+r+((a?e==l?-1:e==h?1:t:t)<0?0:c);if(n)return o;let i=e==(t<0?l:h)?null:fe(s/3,e-l),d=e==l?2:e==h?1:4;return(t<0?e!=l:e!=h)&&(d|=8),new ge(o,d,i)}r+=c-a}return n?e+r:new ge(e+r,0,null)}touches(e,t){let n=0,r=me(t),o=this.inverted?2:1,i=this.inverted?1:2;for(let t=0;t<this.ranges.length;t+=3){let s=this.ranges[t]-(this.inverted?n:0);if(s>e)break;let l=this.ranges[t+o];if(e<=s+l&&t==3*r)return!0;n+=this.ranges[t+i]-l}return!1}forEach(e){let t=this.inverted?2:1,n=this.inverted?1:2;for(let r=0,o=0;r<this.ranges.length;r+=3){let i=this.ranges[r],s=i-(this.inverted?o:0),l=i+(this.inverted?0:o),a=this.ranges[r+t],c=this.ranges[r+n];e(s,s+a,l,l+c),o+=c-a}}invert(){return new ye(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return 0==e?ye.empty:new ye(e<0?[0,-e,0]:[0,0,e])}}ye.empty=new ye([]);class we{constructor(e,t,n=0,r=(e?e.length:0)){this.mirror=t,this.from=n,this.to=r,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(e=0,t=this.maps.length){return new we(this._maps,this.mirror,e,t)}appendMap(e,t){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),null!=t&&this.setMirror(this._maps.length-1,t)}appendMapping(e){for(let t=0,n=this._maps.length;t<e._maps.length;t++){let r=e.getMirror(t);this.appendMap(e._maps[t],null!=r&&r<t?n+r:void 0)}}getMirror(e){if(this.mirror)for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}setMirror(e,t){this.mirror||(this.mirror=[]),this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,n=this._maps.length+e._maps.length;t>=0;t--){let r=e.getMirror(t);this.appendMap(e._maps[t].invert(),null!=r&&r>t?n-r-1:void 0)}}invert(){let e=new we;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let n=this.from;n<this.to;n++)e=this._maps[n].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,n){let r=0;for(let n=this.from;n<this.to;n++){let o=this._maps[n].mapResult(e,t);if(null!=o.recover){let t=this.getMirror(n);if(null!=t&&t>n&&t<this.to){n=t,e=this._maps[t].recover(o.recover);continue}}r|=o.delInfo,e=o.pos}return n?e:new ge(e,r,null)}}const ve=Object.create(null);class be{getMap(){return ye.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let n=ve[t.stepType];if(!n)throw new RangeError(`No step type ${t.stepType} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in ve)throw new RangeError("Duplicate use of step JSON ID "+e);return ve[e]=t,t.prototype.jsonID=e,t}}class ke{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new ke(e,null)}static fail(e){return new ke(null,e)}static fromReplace(e,t,n,r){try{return ke.ok(e.replace(t,n,r))}catch(e){if(e instanceof h)return ke.fail(e.message);throw e}}}function xe(e,t,n){let r=[];for(let o=0;o<e.childCount;o++){let i=e.child(o);i.content.size&&(i=i.copy(xe(i.content,t,i))),i.isInline&&(i=t(i,n,o)),r.push(i)}return i.fromArray(r)}class Se extends be{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=e.resolve(this.from),r=n.node(n.sharedDepth(this.to)),o=new d(xe(t.content,(e,t)=>e.isAtom&&t.type.allowsMarkType(this.mark.type)?e.mark(this.mark.addToSet(e.marks)):e,r),t.openStart,t.openEnd);return ke.fromReplace(e,this.from,this.to,o)}invert(){return new Ce(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return t.deleted&&n.deleted||t.pos>=n.pos?null:new Se(t.pos,n.pos,this.mark)}merge(e){return e instanceof Se&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Se(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if("number"!=typeof t.from||"number"!=typeof t.to)throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new Se(t.from,t.to,e.markFromJSON(t.mark))}}be.jsonID("addMark",Se);class Ce extends be{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=new d(xe(t.content,e=>e.mark(this.mark.removeFromSet(e.marks)),e),t.openStart,t.openEnd);return ke.fromReplace(e,this.from,this.to,n)}invert(){return new Se(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return t.deleted&&n.deleted||t.pos>=n.pos?null:new Ce(t.pos,n.pos,this.mark)}merge(e){return e instanceof Ce&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Ce(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if("number"!=typeof t.from||"number"!=typeof t.to)throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new Ce(t.from,t.to,e.markFromJSON(t.mark))}}be.jsonID("removeMark",Ce);class Me extends be{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return ke.fail("No node at mark step's position");let n=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return ke.fromReplace(e,this.pos,this.pos+1,new d(i.from(n),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let e=this.mark.addToSet(t.marks);if(e.length==t.marks.length){for(let n=0;n<t.marks.length;n++)if(!t.marks[n].isInSet(e))return new Me(this.pos,t.marks[n]);return new Me(this.pos,this.mark)}}return new Oe(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new Me(t.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if("number"!=typeof t.pos)throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new Me(t.pos,e.markFromJSON(t.mark))}}be.jsonID("addNodeMark",Me);class Oe extends be{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return ke.fail("No node at mark step's position");let n=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return ke.fromReplace(e,this.pos,this.pos+1,new d(i.from(n),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return t&&this.mark.isInSet(t.marks)?new Me(this.pos,this.mark):this}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new Oe(t.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if("number"!=typeof t.pos)throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new Oe(t.pos,e.markFromJSON(t.mark))}}be.jsonID("removeNodeMark",Oe);class Ne extends be{constructor(e,t,n,r=!1){super(),this.from=e,this.to=t,this.slice=n,this.structure=r}apply(e){return this.structure&&Te(e,this.from,this.to)?ke.fail("Structure replace would overwrite content"):ke.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new ye([this.from,this.to-this.from,this.slice.size])}invert(e){return new Ne(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.to,-1),n=this.from==this.to&&Ne.MAP_BIAS<0?t:e.mapResult(this.from,1);return n.deletedAcross&&t.deletedAcross?null:new Ne(n.pos,Math.max(n.pos,t.pos),this.slice,this.structure)}merge(e){if(!(e instanceof Ne)||e.structure||this.structure)return null;if(this.from+this.slice.size!=e.from||this.slice.openEnd||e.slice.openStart){if(e.to!=this.from||this.slice.openStart||e.slice.openEnd)return null;{let t=this.slice.size+e.slice.size==0?d.empty:new d(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new Ne(e.from,this.to,t,this.structure)}}{let t=this.slice.size+e.slice.size==0?d.empty:new d(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new Ne(this.from,this.to+(e.to-e.from),t,this.structure)}}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if("number"!=typeof t.from||"number"!=typeof t.to)throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new Ne(t.from,t.to,d.fromJSON(e,t.slice),!!t.structure)}}Ne.MAP_BIAS=1,be.jsonID("replace",Ne);class De extends be{constructor(e,t,n,r,o,i,s=!1){super(),this.from=e,this.to=t,this.gapFrom=n,this.gapTo=r,this.slice=o,this.insert=i,this.structure=s}apply(e){if(this.structure&&(Te(e,this.from,this.gapFrom)||Te(e,this.gapTo,this.to)))return ke.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return ke.fail("Gap is not a flat range");let n=this.slice.insertAt(this.insert,t.content);return n?ke.fromReplace(e,this.from,this.to,n):ke.fail("Content does not fit in gap")}getMap(){return new ye([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let t=this.gapTo-this.gapFrom;return new De(this.from,this.from+this.slice.size+t,this.from+this.insert,this.from+this.insert+t,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1),r=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),o=this.to==this.gapTo?n.pos:e.map(this.gapTo,1);return t.deletedAcross&&n.deletedAcross||r<t.pos||o>n.pos?null:new De(t.pos,n.pos,r,o,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if("number"!=typeof t.from||"number"!=typeof t.to||"number"!=typeof t.gapFrom||"number"!=typeof t.gapTo||"number"!=typeof t.insert)throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new De(t.from,t.to,t.gapFrom,t.gapTo,d.fromJSON(e,t.slice),t.insert,!!t.structure)}}function Te(e,t,n){let r=e.resolve(t),o=n-t,i=r.depth;for(;o>0&&i>0&&r.indexAfter(i)==r.node(i).childCount;)i--,o--;if(o>0){let e=r.node(i).maybeChild(r.indexAfter(i));for(;o>0;){if(!e||e.isLeaf)return!0;e=e.firstChild,o--}}return!1}function Ee(e,t,n,r=n.contentMatch,o=!0){let s=e.doc.nodeAt(t),l=[],a=t+1;for(let t=0;t<s.childCount;t++){let c=s.child(t),h=a+c.nodeSize,p=r.matchType(c.type);if(p){r=p;for(let t=0;t<c.marks.length;t++)n.allowsMarkType(c.marks[t].type)||e.step(new Ce(a,h,c.marks[t]));if(o&&c.isText&&"pre"!=n.whitespace){let e,t,r=/\r?\n|\r/g;for(;e=r.exec(c.text);)t||(t=new d(i.from(n.schema.text(" ",n.allowedMarks(c.marks))),0,0)),l.push(new Ne(a+e.index,a+e.index+e[0].length,t))}}else l.push(new Ne(a,h,d.empty));a=h}if(!r.validEnd){let t=r.fillBefore(i.empty,!0);e.replace(a,a,new d(t,0,0))}for(let t=l.length-1;t>=0;t--)e.step(l[t])}function Ae(e,t,n){return(0==t||e.canReplace(t,e.childCount))&&(n==e.childCount||e.canReplace(0,n))}function Ie(e){let t=e.parent.content.cutByIndex(e.startIndex,e.endIndex);for(let n=e.depth,r=0,o=0;;--n){let i=e.$from.node(n),s=e.$from.index(n)+r,l=e.$to.indexAfter(n)-o;if(n<e.depth&&i.canReplace(s,l,t))return n;if(0==n||i.type.spec.isolating||!Ae(i,s,l))break;s&&(r=1),l<i.childCount&&(o=1)}return null}function Re(e,t,n=null,r=e){let o=function(e,t){let{parent:n,startIndex:r,endIndex:o}=e,i=n.contentMatchAt(r).findWrapping(t);if(!i)return null;let s=i.length?i[0]:t;return n.canReplaceWith(r,o,s)?i:null}(e,t),i=o&&function(e,t){let{parent:n,startIndex:r,endIndex:o}=e,i=n.child(r),s=t.contentMatch.findWrapping(i.type);if(!s)return null;let l=(s.length?s[s.length-1]:t).contentMatch;for(let e=r;l&&e<o;e++)l=l.matchType(n.child(e).type);return l&&l.validEnd?s:null}(r,t);return i?o.map(ze).concat({type:t,attrs:n}).concat(i.map(ze)):null}function ze(e){return{type:e,attrs:null}}function Pe(e,t,n,r){t.forEach((o,i)=>{if(o.isText){let s,l=/\r?\n|\r/g;for(;s=l.exec(o.text);){let o=e.mapping.slice(r).map(n+1+i+s.index);e.replaceWith(o,o+1,t.type.schema.linebreakReplacement.create())}}})}function Be(e,t,n,r){t.forEach((o,i)=>{if(o.type==o.type.schema.linebreakReplacement){let o=e.mapping.slice(r).map(n+1+i);e.replaceWith(o,o+1,t.type.schema.text("\n"))}})}function $e(e,t,n=1,r){let o=e.resolve(t),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 e=o.depth-1,t=n-2;e>i;e--,t--){let n=o.node(e),i=o.index(e);if(n.type.spec.isolating)return!1;let s=n.content.cutByIndex(i,n.childCount),l=r&&r[t+1];l&&(s=s.replaceChild(0,l.type.create(l.attrs)));let a=r&&r[t]||n;if(!n.canReplace(i+1,n.childCount)||!a.type.validContent(s))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 Ve(e,t){let n=e.resolve(t),r=n.index();return Fe(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function Fe(e,t){return!(!e||!t||e.isLeaf||!function(e,t){t.content.size||e.type.compatibleContent(t.type);let n=e.contentMatchAt(e.childCount),{linebreakReplacement:r}=e.type.schema;for(let o=0;o<t.childCount;o++){let i=t.child(o),s=i.type==r?e.type.schema.nodes.text:i.type;if(n=n.matchType(s),!n)return!1;if(!e.type.allowsMarks(i.marks))return!1}return n.validEnd}(e,t))}function qe(e,t,n=-1){let r=e.resolve(t);for(let e=r.depth;;e--){let o,i,s=r.index(e);if(e==r.depth?(o=r.nodeBefore,i=r.nodeAfter):n>0?(o=r.node(e+1),s++,i=r.node(e).maybeChild(s)):(o=r.node(e).maybeChild(s-1),i=r.node(e+1)),o&&!o.isTextblock&&Fe(o,i)&&r.node(e).canReplace(s,s+1))return t;if(0==e)break;t=n<0?r.before(e):r.after(e)}}function Le(e,t,n){let r=e.resolve(t);if(r.parent.canReplaceWith(r.index(),r.index(),n))return t;if(0==r.parentOffset)for(let e=r.depth-1;e>=0;e--){let t=r.index(e);if(r.node(e).canReplaceWith(t,t,n))return r.before(e+1);if(t>0)return null}if(r.parentOffset==r.parent.content.size)for(let e=r.depth-1;e>=0;e--){let t=r.indexAfter(e);if(r.node(e).canReplaceWith(t,t,n))return r.after(e+1);if(t<r.node(e).childCount)return null}return null}function _e(e,t,n){let r=e.resolve(t);if(!n.content.size)return t;let o=n.content;for(let e=0;e<n.openStart;e++)o=o.firstChild.content;for(let e=1;e<=(0==n.openStart&&n.size?2:1);e++)for(let t=r.depth;t>=0;t--){let n=t==r.depth?0:r.pos<=(r.start(t+1)+r.end(t+1))/2?-1:1,i=r.index(t)+(n>0?1:0),s=r.node(t),l=!1;if(1==e)l=s.canReplace(i,i,o);else{let e=s.contentMatchAt(i).findWrapping(o.firstChild.type);l=e&&s.canReplaceWith(i,i,e[0])}if(l)return 0==n?r.pos:n<0?r.before(t+1):r.after(t+1)}return null}function We(e,t,n=t,r=d.empty){if(t==n&&!r.size)return null;let o=e.resolve(t),i=e.resolve(n);return Je(o,i,r)?new Ne(t,n,r):new je(o,i,r).fit()}function Je(e,t,n){return!n.openStart&&!n.openEnd&&e.start()==t.start()&&e.parent.canReplace(e.index(),t.index(),n.content)}be.jsonID("replaceAround",De);class je{constructor(e,t,n){this.$from=e,this.$to=t,this.unplaced=n,this.frontier=[],this.placed=i.empty;for(let t=0;t<=e.depth;t++){let n=e.node(t);this.frontier.push({type:n.type,match:n.contentMatchAt(e.indexAfter(t))})}for(let t=e.depth;t>0;t--)this.placed=i.from(e.node(t).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let e=this.findFittable();e?this.placeNodes(e):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,n=this.$from,r=this.close(e<0?this.$to:n.doc.resolve(e));if(!r)return null;let o=this.placed,i=n.depth,s=r.depth;for(;i&&s&&1==o.childCount;)o=o.firstChild.content,i--,s--;let l=new d(o,i,s);return e>-1?new De(n.pos,e,this.$to.pos,this.$to.end(),l,t):l.size||n.pos!=this.$to.pos?new Ne(n.pos,r.pos,l):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,n=0,r=this.unplaced.openEnd;n<e;n++){let o=t.firstChild;if(t.childCount>1&&(r=0),o.type.spec.isolating&&r<=n){e=n;break}t=o.content}for(let t=1;t<=2;t++)for(let n=1==t?e:this.unplaced.openStart;n>=0;n--){let e,r=null;n?(r=Ue(this.unplaced.content,n-1).firstChild,e=r.content):e=this.unplaced.content;let o=e.firstChild;for(let e=this.depth;e>=0;e--){let s,{type:l,match:a}=this.frontier[e],c=null;if(1==t&&(o?a.matchType(o.type)||(c=a.fillBefore(i.from(o),!1)):r&&l.compatibleContent(r.type)))return{sliceDepth:n,frontierDepth:e,parent:r,inject:c};if(2==t&&o&&(s=a.findWrapping(o.type)))return{sliceDepth:n,frontierDepth:e,parent:r,wrap:s};if(r&&a.matchType(r.type))break}}}openMore(){let{content:e,openStart:t,openEnd:n}=this.unplaced,r=Ue(e,t);return!(!r.childCount||r.firstChild.isLeaf)&&(this.unplaced=new d(e,t+1,Math.max(n,r.size+t>=e.size-n?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:n}=this.unplaced,r=Ue(e,t);if(r.childCount<=1&&t>0){let o=e.size-t<=t+r.size;this.unplaced=new d(Ke(e,t-1,1),t-1,o?t-1:n)}else this.unplaced=new d(Ke(e,t,1),t,n)}placeNodes({sliceDepth:e,frontierDepth:t,parent:n,inject:r,wrap:o}){for(;this.depth>t;)this.closeFrontierNode();if(o)for(let e=0;e<o.length;e++)this.openFrontierNode(o[e]);let s=this.unplaced,l=n?n.content:s.content,a=s.openStart-e,c=0,h=[],{match:p,type:u}=this.frontier[t];if(r){for(let e=0;e<r.childCount;e++)h.push(r.child(e));p=p.matchFragment(r)}let f=l.size+e-(s.content.size-s.openEnd);for(;c<l.childCount;){let e=l.child(c),t=p.matchType(e.type);if(!t)break;c++,(c>1||0==a||e.content.size)&&(p=t,h.push(Ge(e.mark(u.allowedMarks(e.marks)),1==c?a:0,c==l.childCount?f:-1)))}let m=c==l.childCount;m||(f=-1),this.placed=He(this.placed,t,i.from(h)),this.frontier[t].match=p,m&&f<0&&n&&n.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let e=0,t=l;e<f;e++){let e=t.lastChild;this.frontier.push({type:e.type,match:e.contentMatchAt(e.childCount)}),t=e.content}this.unplaced=m?0==e?d.empty:new d(Ke(s.content,e-1,1),e-1,f<0?s.openEnd:e-1):new d(Ke(s.content,e,c),s.openStart,s.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e,t=this.frontier[this.depth];if(!t.type.isTextblock||!Ye(this.$to,this.$to.depth,t.type,t.match,!1)||this.$to.depth==this.depth&&(e=this.findCloseLevel(this.$to))&&e.depth==this.depth)return-1;let{depth:n}=this.$to,r=this.$to.after(n);for(;n>1&&r==this.$to.end(--n);)++r;return r}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:n,type:r}=this.frontier[t],o=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),i=Ye(e,t,r,n,o);if(i){for(let n=t-1;n>=0;n--){let{match:t,type:r}=this.frontier[n],o=Ye(e,n,r,t,!0);if(!o||o.childCount)continue e}return{depth:t,fit:i,move:o?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=He(this.placed,t.depth,t.fit)),e=t.move;for(let n=t.depth+1;n<=e.depth;n++){let t=e.node(n),r=t.type.contentMatch.fillBefore(t.content,!0,e.index(n));this.openFrontierNode(t.type,t.attrs,r)}return e}openFrontierNode(e,t=null,n){let r=this.frontier[this.depth];r.match=r.match.matchType(e),this.placed=He(this.placed,this.depth,i.from(e.create(t,n))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let e=this.frontier.pop().match.fillBefore(i.empty,!0);e.childCount&&(this.placed=He(this.placed,this.frontier.length,e))}}function Ke(e,t,n){return 0==t?e.cutByIndex(n,e.childCount):e.replaceChild(0,e.firstChild.copy(Ke(e.firstChild.content,t-1,n)))}function He(e,t,n){return 0==t?e.append(n):e.replaceChild(e.childCount-1,e.lastChild.copy(He(e.lastChild.content,t-1,n)))}function Ue(e,t){for(let n=0;n<t;n++)e=e.firstChild.content;return e}function Ge(e,t,n){if(t<=0)return e;let r=e.content;return t>1&&(r=r.replaceChild(0,Ge(r.firstChild,t-1,1==r.childCount?n-1:0))),t>0&&(r=e.type.contentMatch.fillBefore(r).append(r),n<=0&&(r=r.append(e.type.contentMatch.matchFragment(r).fillBefore(i.empty,!0)))),e.copy(r)}function Ye(e,t,n,r,o){let i=e.node(t),s=o?e.indexAfter(t):e.index(t);if(s==i.childCount&&!n.compatibleContent(i.type))return null;let l=r.fillBefore(i.content,!0,s);return l&&!function(e,t,n){for(let r=n;r<t.childCount;r++)if(!e.allowsMarks(t.child(r).marks))return!0;return!1}(n,i.content,s)?l:null}function Qe(e){return e.spec.defining||e.spec.definingForContent}function Xe(e,t,n,r,o){if(t<n){let o=e.firstChild;e=e.replaceChild(0,o.copy(Xe(o.content,t+1,n,r,o)))}if(t>r){let t=o.contentMatchAt(0),n=t.fillBefore(e).append(e);e=n.append(t.matchFragment(n).fillBefore(i.empty,!0))}return e}function Ze(e,t){let n=[];for(let r=Math.min(e.depth,t.depth);r>=0;r--){let o=e.start(r);if(o<e.pos-(e.depth-r)||t.end(r)>t.pos+(t.depth-r)||e.node(r).type.spec.isolating||t.node(r).type.spec.isolating)break;(o==t.start(r)||r==e.depth&&r==t.depth&&e.parent.inlineContent&&t.parent.inlineContent&&r&&t.start(r-1)==o-1)&&n.push(r)}return n}class et extends be{constructor(e,t,n){super(),this.pos=e,this.attr=t,this.value=n}apply(e){let t=e.nodeAt(this.pos);if(!t)return ke.fail("No node at attribute step's position");let n=Object.create(null);for(let e in t.attrs)n[e]=t.attrs[e];n[this.attr]=this.value;let r=t.type.create(n,null,t.marks);return ke.fromReplace(e,this.pos,this.pos+1,new d(i.from(r),0,t.isLeaf?0:1))}getMap(){return ye.empty}invert(e){return new et(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new et(t.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,t){if("number"!=typeof t.pos||"string"!=typeof t.attr)throw new RangeError("Invalid input for AttrStep.fromJSON");return new et(t.pos,t.attr,t.value)}}be.jsonID("attr",et);class tt extends be{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let n in e.attrs)t[n]=e.attrs[n];t[this.attr]=this.value;let n=e.type.create(t,e.content,e.marks);return ke.ok(n)}getMap(){return ye.empty}invert(e){return new tt(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,t){if("string"!=typeof t.attr)throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new tt(t.attr,t.value)}}be.jsonID("docAttr",tt);let nt=class extends Error{};nt=function e(t){let n=Error.call(this,t);return n.__proto__=e.prototype,n},(nt.prototype=Object.create(Error.prototype)).constructor=nt,nt.prototype.name="TransformError";class rt{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new we}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new nt(t.failed);return this}maybeStep(e){let t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t}get docChanged(){return this.steps.length>0}changedRange(){let e=1e9,t=-1e9;for(let n=0;n<this.mapping.maps.length;n++){let r=this.mapping.maps[n];n&&(e=r.map(e,1),t=r.map(t,-1)),r.forEach((n,r,o,i)=>{e=Math.min(e,o),t=Math.max(t,i)})}return 1e9==e?null:{from:e,to:t}}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,n=d.empty){let r=We(this.doc,e,t,n);return r&&this.step(r),this}replaceWith(e,t,n){return this.replace(e,t,new d(i.from(n),0,0))}delete(e,t){return this.replace(e,t,d.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,n){return function(e,t,n,r){if(!r.size)return e.deleteRange(t,n);let o=e.doc.resolve(t),i=e.doc.resolve(n);if(Je(o,i,r))return e.step(new Ne(t,n,r));let s=Ze(o,i);0==s[s.length-1]&&s.pop();let l=-(o.depth+1);s.unshift(l);for(let e=o.depth,t=o.pos-1;e>0;e--,t--){let n=o.node(e).type.spec;if(n.defining||n.definingAsContext||n.isolating)break;s.indexOf(e)>-1?l=e:o.before(e)==t&&s.splice(1,0,-e)}let a=s.indexOf(l),c=[],h=r.openStart;for(let e=r.content,t=0;;t++){let n=e.firstChild;if(c.push(n),t==r.openStart)break;e=n.content}for(let e=h-1;e>=0;e--){let t=c[e],n=Qe(t.type);if(n&&!t.sameMarkup(o.node(Math.abs(l)-1)))h=e;else if(n||!t.type.isTextblock)break}for(let t=r.openStart;t>=0;t--){let l=(t+h+1)%(r.openStart+1),p=c[l];if(p)for(let t=0;t<s.length;t++){let c=s[(t+a)%s.length],h=!0;c<0&&(h=!1,c=-c);let u=o.node(c-1),f=o.index(c-1);if(u.canReplaceWith(f,f,p.type,p.marks))return e.replace(o.before(c),h?i.after(c):n,new d(Xe(r.content,0,r.openStart,l),l,r.openEnd))}}let p=e.steps.length;for(let l=s.length-1;l>=0&&(e.replace(t,n,r),!(e.steps.length>p));l--){let e=s[l];e<0||(t=o.before(e),n=i.after(e))}}(this,e,t,n),this}replaceRangeWith(e,t,n){return function(e,t,n,r){if(!r.isInline&&t==n&&e.doc.resolve(t).parent.content.size){let o=Le(e.doc,t,r.type);null!=o&&(t=n=o)}e.replaceRange(t,n,new d(i.from(r),0,0))}(this,e,t,n),this}deleteRange(e,t){return function(e,t,n){let r=e.doc.resolve(t),o=e.doc.resolve(n);if(r.parent.isTextblock&&o.parent.isTextblock&&r.start()!=o.start()&&0==r.parentOffset&&0==o.parentOffset){let i=r.sharedDepth(n),s=!1;for(let e=r.depth;e>i;e--)r.node(e).type.spec.isolating&&(s=!0);for(let e=o.depth;e>i;e--)o.node(e).type.spec.isolating&&(s=!0);if(!s){for(let e=r.depth;e>0&&t==r.start(e);e--)t=r.before(e);for(let e=o.depth;e>0&&n==o.start(e);e--)n=o.before(e);r=e.doc.resolve(t),o=e.doc.resolve(n)}}let i=Ze(r,o);for(let t=0;t<i.length;t++){let n=i[t],s=t==i.length-1;if(s&&0==n||r.node(n).type.contentMatch.validEnd)return e.delete(r.start(n),o.end(n));if(n>0&&(s||r.node(n-1).canReplace(r.index(n-1),o.indexAfter(n-1))))return e.delete(r.before(n),o.after(n))}for(let i=1;i<=r.depth&&i<=o.depth;i++)if(t-r.start(i)==r.depth-i&&n>r.end(i)&&o.end(i)-n!=o.depth-i&&r.start(i-1)==o.start(i-1)&&r.node(i-1).canReplace(r.index(i-1),o.index(i-1)))return e.delete(r.before(i),n);e.delete(t,n)}(this,e,t),this}lift(e,t){return function(e,t,n){let{$from:r,$to:o,depth:s}=t,l=r.before(s+1),a=o.after(s+1),c=l,h=a,p=i.empty,u=0;for(let e=s,t=!1;e>n;e--)t||r.index(e)>0?(t=!0,p=i.from(r.node(e).copy(p)),u++):c--;let f=i.empty,m=0;for(let e=s,t=!1;e>n;e--)t||o.after(e+1)<o.end(e)?(t=!0,f=i.from(o.node(e).copy(f)),m++):h++;e.step(new De(c,h,l,a,new d(p.append(f),u,m),p.size-u,!0))}(this,e,t),this}join(e,t=1){return function(e,t,n){let r=null,{linebreakReplacement:o}=e.doc.type.schema,i=e.doc.resolve(t-n),s=i.node().type;if(o&&s.inlineContent){let e="pre"==s.whitespace,t=!!s.contentMatch.matchType(o);e&&!t?r=!1:!e&&t&&(r=!0)}let l=e.steps.length;if(!1===r){let r=e.doc.resolve(t+n);Be(e,r.node(),r.before(),l)}s.inlineContent&&Ee(e,t+n-1,s,i.node().contentMatchAt(i.index()),null==r);let a=e.mapping.slice(l),c=a.map(t-n);if(e.step(new Ne(c,a.map(t+n,-1),d.empty,!0)),!0===r){let t=e.doc.resolve(c);Pe(e,t.node(),t.before(),e.steps.length)}}(this,e,t),this}wrap(e,t){return function(e,t,n){let r=i.empty;for(let e=n.length-1;e>=0;e--){if(r.size){let t=n[e].type.contentMatch.matchFragment(r);if(!t||!t.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=i.from(n[e].type.create(n[e].attrs,r))}let o=t.start,s=t.end;e.step(new De(o,s,o,s,new d(r,0,0),n.length,!0))}(this,e,t),this}setBlockType(e,t=e,n,r=null){return function(e,t,n,r,o){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let s=e.steps.length;e.doc.nodesBetween(t,n,(t,n)=>{let l="function"==typeof o?o(t):o;if(t.isTextblock&&!t.hasMarkup(r,l)&&function(e,t,n){let r=e.resolve(t),o=r.index();return r.parent.canReplaceWith(o,o+1,n)}(e.doc,e.mapping.slice(s).map(n),r)){let o=null;if(r.schema.linebreakReplacement){let e="pre"==r.whitespace,t=!!r.contentMatch.matchType(r.schema.linebreakReplacement);e&&!t?o=!1:!e&&t&&(o=!0)}!1===o&&Be(e,t,n,s),Ee(e,e.mapping.slice(s).map(n,1),r,void 0,null===o);let a=e.mapping.slice(s),c=a.map(n,1),h=a.map(n+t.nodeSize,1);return e.step(new De(c,h,c+1,h-1,new d(i.from(r.create(l,null,t.marks)),0,0),1,!0)),!0===o&&Pe(e,t,n,s),!1}})}(this,e,t,n,r),this}setNodeMarkup(e,t,n=null,r){return function(e,t,n,r,o){let s=e.doc.nodeAt(t);if(!s)throw new RangeError("No node at given position");n||(n=s.type);let l=n.create(r,null,o||s.marks);if(s.isLeaf)return e.replaceWith(t,t+s.nodeSize,l);if(!n.validContent(s.content))throw new RangeError("Invalid content for node type "+n.name);e.step(new De(t,t+s.nodeSize,t+1,t+s.nodeSize-1,new d(i.from(l),0,0),1,!0))}(this,e,t,n,r),this}setNodeAttribute(e,t,n){return this.step(new et(e,t,n)),this}setDocAttribute(e,t){return this.step(new tt(e,t)),this}addNodeMark(e,t){return this.step(new Me(e,t)),this}removeNodeMark(e,t){let n=this.doc.nodeAt(e);if(!n)throw new RangeError("No node at position "+e);if(t instanceof c)t.isInSet(n.marks)&&this.step(new Oe(e,t));else{let r,o=n.marks,i=[];for(;r=t.isInSet(o);)i.push(new Oe(e,r)),o=r.removeFromSet(o);for(let e=i.length-1;e>=0;e--)this.step(i[e])}return this}split(e,t=1,n){return function(e,t,n=1,r){let o=e.doc.resolve(t),s=i.empty,l=i.empty;for(let e=o.depth,t=o.depth-n,a=n-1;e>t;e--,a--){s=i.from(o.node(e).copy(s));let t=r&&r[a];l=i.from(t?t.type.create(t.attrs,l):o.node(e).copy(l))}e.step(new Ne(t,t,new d(s.append(l),n,n),!0))}(this,e,t,n),this}addMark(e,t,n){return function(e,t,n,r){let o,i,s=[],l=[];e.doc.nodesBetween(t,n,(e,a,c)=>{if(!e.isInline)return;let h=e.marks;if(!r.isInSet(h)&&c.type.allowsMarkType(r.type)){let c=Math.max(a,t),d=Math.min(a+e.nodeSize,n),p=r.addToSet(h);for(let e=0;e<h.length;e++)h[e].isInSet(p)||(o&&o.to==c&&o.mark.eq(h[e])?o.to=d:s.push(o=new Ce(c,d,h[e])));i&&i.to==c?i.to=d:l.push(i=new Se(c,d,r))}}),s.forEach(t=>e.step(t)),l.forEach(t=>e.step(t))}(this,e,t,n),this}removeMark(e,t,n){return function(e,t,n,r){let o=[],i=0;e.doc.nodesBetween(t,n,(e,s)=>{if(!e.isInline)return;i++;let l=null;if(r instanceof H){let t,n=e.marks;for(;t=r.isInSet(n);)(l||(l=[])).push(t),n=t.removeFromSet(n)}else r?r.isInSet(e.marks)&&(l=[r]):l=e.marks;if(l&&l.length){let r=Math.min(s+e.nodeSize,n);for(let e=0;e<l.length;e++){let n,a=l[e];for(let e=0;e<o.length;e++){let t=o[e];t.step==i-1&&a.eq(o[e].style)&&(n=t)}n?(n.to=r,n.step=i):o.push({style:a,from:Math.max(s,t),to:r,step:i})}}}),o.forEach(t=>e.step(new Ce(t.from,t.to,t.style)))}(this,e,t,n),this}clearIncompatible(e,t,n){return Ee(this,e,t,n),this}}var ot=Object.freeze({__proto__:null,AddMarkStep:Se,AddNodeMarkStep:Me,AttrStep:et,DocAttrStep:tt,MapResult:ge,Mapping:we,RemoveMarkStep:Ce,RemoveNodeMarkStep:Oe,ReplaceAroundStep:De,ReplaceStep:Ne,Step:be,StepMap:ye,StepResult:ke,Transform:rt,get TransformError(){return nt},canJoin:Ve,canSplit:$e,dropPoint:_e,findWrapping:Re,insertPoint:Le,joinPoint:qe,liftTarget:Ie,replaceStep:We});const it=Object.create(null);class st{constructor(e,t,n){this.$anchor=e,this.$head=t,this.ranges=n||[new lt(e.min(t),e.max(t))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let t=0;t<e.length;t++)if(e[t].$from.pos!=e[t].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,t=d.empty){let n=t.content.lastChild,r=null;for(let e=0;e<t.openEnd;e++)r=n,n=n.lastChild;let o=e.steps.length,i=this.ranges;for(let s=0;s<i.length;s++){let{$from:l,$to:a}=i[s],c=e.mapping.slice(o);e.replaceRange(c.map(l.pos),c.map(a.pos),s?d.empty:t),0==s&&yt(e,o,(n?n.isInline:r&&r.isTextblock)?-1:1)}}replaceWith(e,t){let n=e.steps.length,r=this.ranges;for(let o=0;o<r.length;o++){let{$from:i,$to:s}=r[o],l=e.mapping.slice(n),a=l.map(i.pos),c=l.map(s.pos);o?e.deleteRange(a,c):(e.replaceRangeWith(a,c,t),yt(e,n,t.isInline?-1:1))}}static findFrom(e,t,n=!1){let r=e.parent.inlineContent?new ht(e):gt(e.node(0),e.parent,e.pos,e.index(),t,n);if(r)return r;for(let r=e.depth-1;r>=0;r--){let o=t<0?gt(e.node(0),e.node(r),e.before(r+1),e.index(r),t,n):gt(e.node(0),e.node(r),e.after(r+1),e.index(r)+1,t,n);if(o)return o}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new ft(e.node(0))}static atStart(e){return gt(e,e,0,0,1)||new ft(e)}static atEnd(e){return gt(e,e,e.content.size,e.childCount,-1)||new ft(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let n=it[t.type];if(!n)throw new RangeError(`No selection type ${t.type} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in it)throw new RangeError("Duplicate use of selection JSON ID "+e);return it[e]=t,t.prototype.jsonID=e,t}getBookmark(){return ht.between(this.$anchor,this.$head).getBookmark()}}st.prototype.visible=!0;class lt{constructor(e,t){this.$from=e,this.$to=t}}let at=!1;function ct(e){at||e.parent.inlineContent||(at=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+e.parent.type.name+")"))}class ht extends st{constructor(e,t=e){ct(e),ct(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let n=e.resolve(t.map(this.head));if(!n.parent.inlineContent)return st.near(n);let r=e.resolve(t.map(this.anchor));return new ht(r.parent.inlineContent?r:n,n)}replace(e,t=d.empty){if(super.replace(e,t),t==d.empty){let t=this.$from.marksAcross(this.$to);t&&e.ensureMarks(t)}}eq(e){return e instanceof ht&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new dt(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if("number"!=typeof t.anchor||"number"!=typeof t.head)throw new RangeError("Invalid input for TextSelection.fromJSON");return new ht(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,n=t){let r=e.resolve(t);return new this(r,n==t?r:e.resolve(n))}static between(e,t,n){let r=e.pos-t.pos;if(n&&!r||(n=r>=0?1:-1),!t.parent.inlineContent){let e=st.findFrom(t,n,!0)||st.findFrom(t,-n,!0);if(!e)return st.near(t,n);t=e.$head}return e.parent.inlineContent||(0==r||(e=(st.findFrom(e,-n,!0)||st.findFrom(e,n,!0)).$anchor).pos<t.pos!=r<0)&&(e=t),new ht(e,t)}}st.jsonID("text",ht);class dt{constructor(e,t){this.anchor=e,this.head=t}map(e){return new dt(e.map(this.anchor),e.map(this.head))}resolve(e){return ht.between(e.resolve(this.anchor),e.resolve(this.head))}}class pt extends st{constructor(e){let t=e.nodeAfter,n=e.node(0).resolve(e.pos+t.nodeSize);super(e,n),this.node=t}map(e,t){let{deleted:n,pos:r}=t.mapResult(this.anchor),o=e.resolve(r);return n?st.near(o):new pt(o)}content(){return new d(i.from(this.node),0,0)}eq(e){return e instanceof pt&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new ut(this.anchor)}static fromJSON(e,t){if("number"!=typeof t.anchor)throw new RangeError("Invalid input for NodeSelection.fromJSON");return new pt(e.resolve(t.anchor))}static create(e,t){return new pt(e.resolve(t))}static isSelectable(e){return!e.isText&&!1!==e.type.spec.selectable}}pt.prototype.visible=!1,st.jsonID("node",pt);class ut{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:n}=e.mapResult(this.anchor);return t?new dt(n,n):new ut(n)}resolve(e){let t=e.resolve(this.anchor),n=t.nodeAfter;return n&&pt.isSelectable(n)?new pt(t):st.near(t)}}class ft extends st{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=d.empty){if(t==d.empty){e.delete(0,e.doc.content.size);let t=st.atStart(e.doc);t.eq(e.selection)||e.setSelection(t)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new ft(e)}map(e){return new ft(e)}eq(e){return e instanceof ft}getBookmark(){return mt}}st.jsonID("all",ft);const mt={map(){return this},resolve:e=>new ft(e)};function gt(e,t,n,r,o,i=!1){if(t.inlineContent)return ht.create(e,n);for(let s=r-(o>0?0:1);o>0?s<t.childCount:s>=0;s+=o){let r=t.child(s);if(r.isAtom){if(!i&&pt.isSelectable(r))return pt.create(e,n-(o<0?r.nodeSize:0))}else{let t=gt(e,r,n+o,o<0?r.childCount:0,o,i);if(t)return t}n+=r.nodeSize*o}return null}function yt(e,t,n){let r=e.steps.length-1;if(r<t)return;let o,i=e.steps[r];(i instanceof Ne||i instanceof De)&&(e.mapping.maps[r].forEach((e,t,n,r)=>{null==o&&(o=r)}),e.setSelection(st.near(e.doc.resolve(o),n)))}class wt extends rt{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(e){if(e.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=-3&this.updated|1,this.storedMarks=null,this}get selectionSet(){return(1&this.updated)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=2,this}ensureMarks(e){return c.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(2&this.updated)>0}addStep(e,t){super.addStep(e,t),this.updated=-3&this.updated,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let n=this.selection;return t&&(e=e.mark(this.storedMarks||(n.empty?n.$from.marks():n.$from.marksAcross(n.$to)||c.none))),n.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,n){let r=this.doc.type.schema;if(null==t)return e?this.replaceSelectionWith(r.text(e),!0):this.deleteSelection();{if(null==n&&(n=t),!e)return this.deleteRange(t,n);let o=this.storedMarks;if(!o){let e=this.doc.resolve(t);o=n==t?e.marks():e.marksAcross(this.doc.resolve(n))}return this.replaceRangeWith(t,n,r.text(e,o)),this.selection.empty||this.selection.to!=t+e.length||this.setSelection(st.near(this.selection.$to)),this}}setMeta(e,t){return this.meta["string"==typeof e?e:e.key]=t,this}getMeta(e){return this.meta["string"==typeof e?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=4,this}get scrolledIntoView(){return(4&this.updated)>0}}function vt(e,t){return t&&e?e.bind(t):e}class bt{constructor(e,t,n){this.name=e,this.init=vt(t.init,n),this.apply=vt(t.apply,n)}}const kt=[new bt("doc",{init:e=>e.doc||e.schema.topNodeType.createAndFill(),apply:e=>e.doc}),new bt("selection",{init:(e,t)=>e.selection||st.atStart(t.doc),apply:e=>e.selection}),new bt("storedMarks",{init:e=>e.storedMarks||null,apply:(e,t,n,r)=>r.selection.$cursor?e.storedMarks:null}),new bt("scrollToSelection",{init:()=>0,apply:(e,t)=>e.scrolledIntoView?t+1:t})];class xt{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=kt.slice(),t&&t.forEach(e=>{if(this.pluginsByKey[e.key])throw new RangeError("Adding different instances of a keyed plugin ("+e.key+")");this.plugins.push(e),this.pluginsByKey[e.key]=e,e.spec.state&&this.fields.push(new bt(e.key,e.spec.state,e))})}}class St{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,t=-1){for(let n=0;n<this.config.plugins.length;n++)if(n!=t){let t=this.config.plugins[n];if(t.spec.filterTransaction&&!t.spec.filterTransaction.call(t,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let t=[e],n=this.applyInner(e),r=null;for(;;){let o=!1;for(let i=0;i<this.config.plugins.length;i++){let s=this.config.plugins[i];if(s.spec.appendTransaction){let l=r?r[i].n:0,a=r?r[i].state:this,c=l<t.length&&s.spec.appendTransaction.call(s,l?t.slice(l):t,a,n);if(c&&n.filterTransaction(c,i)){if(c.setMeta("appendedTransaction",e),!r){r=[];for(let e=0;e<this.config.plugins.length;e++)r.push(e<i?{state:n,n:t.length}:{state:this,n:0})}t.push(c),n=n.applyInner(c),o=!0}r&&(r[i]={state:n,n:t.length})}}if(!o)return{state:n,transactions:t}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let t=new St(this.config),n=this.config.fields;for(let r=0;r<n.length;r++){let o=n[r];t[o.name]=o.apply(e,this[o.name],this,t)}return t}get tr(){return new wt(this)}static create(e){let t=new xt(e.doc?e.doc.type.schema:e.schema,e.plugins),n=new St(t);for(let r=0;r<t.fields.length;r++)n[t.fields[r].name]=t.fields[r].init(e,n);return n}reconfigure(e){let t=new xt(this.schema,e.plugins),n=t.fields,r=new St(t);for(let t=0;t<n.length;t++){let o=n[t].name;r[o]=this.hasOwnProperty(o)?this[o]:n[t].init(e,r)}return r}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map(e=>e.toJSON())),e&&"object"==typeof e)for(let n in e){if("doc"==n||"selection"==n)throw new RangeError("The JSON fields `doc` and `selection` are reserved");let r=e[n],o=r.spec.state;o&&o.toJSON&&(t[n]=o.toJSON.call(r,this[r.key]))}return t}static fromJSON(e,t,n){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let r=new xt(e.schema,e.plugins),o=new St(r);return r.fields.forEach(r=>{if("doc"==r.name)o.doc=T.fromJSON(e.schema,t.doc);else if("selection"==r.name)o.selection=st.fromJSON(o.doc,t.selection);else if("storedMarks"==r.name)t.storedMarks&&(o.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(n)for(let i in n){let s=n[i],l=s.spec.state;if(s.key==r.name&&l&&l.fromJSON&&Object.prototype.hasOwnProperty.call(t,i))return void(o[r.name]=l.fromJSON.call(s,e,t[i],o))}o[r.name]=r.init(e,o)}}),o}}function Ct(e,t,n){for(let r in e){let o=e[r];o instanceof Function?o=o.bind(t):"handleDOMEvents"==r&&(o=Ct(o,t,{})),n[r]=o}return n}class Mt{constructor(e){this.spec=e,this.props={},e.props&&Ct(e.props,this,this.props),this.key=e.key?e.key.key:Nt("plugin")}getState(e){return e[this.key]}}const Ot=Object.create(null);function Nt(e){return e in Ot?e+"$"+ ++Ot[e]:(Ot[e]=0,e+"$")}class Dt{constructor(e="key"){this.key=Nt(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}var Tt=Object.freeze({__proto__:null,AllSelection:ft,EditorState:St,NodeSelection:pt,Plugin:Mt,PluginKey:Dt,Selection:st,SelectionRange:lt,TextSelection:ht,Transaction:wt});const Et=function(e){for(var t=0;;t++)if(!(e=e.previousSibling))return t},At=function(e){let t=e.assignedSlot||e.parentNode;return t&&11==t.nodeType?t.host:t};let It=null;const Rt=function(e,t,n){let r=It||(It=document.createRange());return r.setEnd(e,null==n?e.nodeValue.length:n),r.setStart(e,t||0),r},zt=function(e,t,n,r){return n&&(Bt(e,t,n,r,-1)||Bt(e,t,n,r,1))},Pt=/^(img|br|input|textarea|hr)$/i;function Bt(e,t,n,r,o){for(var i;;){if(e==n&&t==r)return!0;if(t==(o<0?0:$t(e))){let n=e.parentNode;if(!n||1!=n.nodeType||Vt(e)||Pt.test(e.nodeName)||"false"==e.contentEditable)return!1;t=Et(e)+(o<0?0:1),e=n}else{if(1!=e.nodeType)return!1;{let n=e.childNodes[t+(o<0?-1:0)];if(1==n.nodeType&&"false"==n.contentEditable){if(!(null===(i=n.pmViewDesc)||void 0===i?void 0:i.ignoreForSelection))return!1;t+=o}else e=n,t=o<0?$t(e):0}}}}function $t(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function Vt(e){let t;for(let n=e;n&&!(t=n.pmViewDesc);n=n.parentNode);return t&&t.node&&t.node.isBlock&&(t.dom==e||t.contentDOM==e)}const Ft=function(e){return e.focusNode&&zt(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)};function qt(e,t){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=e,n.key=n.code=t,n}const Lt="undefined"!=typeof navigator?navigator:null,_t="undefined"!=typeof document?document:null,Wt=Lt&&Lt.userAgent||"",Jt=/Edge\/(\d+)/.exec(Wt),jt=/MSIE \d/.exec(Wt),Kt=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Wt),Ht=!!(jt||Kt||Jt),Ut=jt?document.documentMode:Kt?+Kt[1]:Jt?+Jt[1]:0,Gt=!Ht&&/gecko\/(\d+)/i.test(Wt);Gt&&(/Firefox\/(\d+)/.exec(Wt)||[0,0])[1];const Yt=!Ht&&/Chrome\/(\d+)/.exec(Wt),Qt=!!Yt,Xt=Yt?+Yt[1]:0,Zt=!Ht&&!!Lt&&/Apple Computer/.test(Lt.vendor),en=Zt&&(/Mobile\/\w+/.test(Wt)||!!Lt&&Lt.maxTouchPoints>2),tn=en||!!Lt&&/Mac/.test(Lt.platform),nn=!!Lt&&/Win/.test(Lt.platform),rn=/Android \d/.test(Wt),on=!!_t&&"webkitFontSmoothing"in _t.documentElement.style,sn=on?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function ln(e){let t=e.defaultView&&e.defaultView.visualViewport;return t?{left:0,right:t.width,top:0,bottom:t.height}:{left:0,right:e.documentElement.clientWidth,top:0,bottom:e.documentElement.clientHeight}}function an(e,t){return"number"==typeof e?e:e[t]}function cn(e){let t=e.getBoundingClientRect(),n=t.width/e.offsetWidth||1,r=t.height/e.offsetHeight||1;return{left:t.left,right:t.left+e.clientWidth*n,top:t.top,bottom:t.top+e.clientHeight*r}}function hn(e,t,n){if(!wn(t)&&0==t.left)return;let r=e.someProp("scrollThreshold")||0,o=e.someProp("scrollMargin")||5,i=e.dom.ownerDocument;for(let s=n||e.dom;s;){if(1!=s.nodeType){s=At(s);continue}let e=s,n=e==i.body,l=n?ln(i):cn(e),a=0,c=0;if(t.top<l.top+an(r,"top")?c=-(l.top-t.top+an(o,"top")):t.bottom>l.bottom-an(r,"bottom")&&(c=t.bottom-t.top>l.bottom-l.top?t.top+an(o,"top")-l.top:t.bottom-l.bottom+an(o,"bottom")),t.left<l.left+an(r,"left")?a=-(l.left-t.left+an(o,"left")):t.right>l.right-an(r,"right")&&(a=t.right-l.right+an(o,"right")),a||c)if(n)i.defaultView.scrollBy(a,c);else{let n=e.scrollLeft,r=e.scrollTop;c&&(e.scrollTop+=c),a&&(e.scrollLeft+=a);let o=e.scrollLeft-n,i=e.scrollTop-r;t={left:t.left-o,top:t.top-i,right:t.right-o,bottom:t.bottom-i}}let h=n?"fixed":getComputedStyle(s).position;if(/^(fixed|sticky)$/.test(h))break;s="absolute"==h?s.offsetParent:At(s)}}function dn(e){let t=[],n=e.ownerDocument;for(let r=e;r&&(t.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),e!=n);r=At(r));return t}function pn(e,t){for(let n=0;n<e.length;n++){let{dom:r,top:o,left:i}=e[n];r.scrollTop!=o+t&&(r.scrollTop=o+t),r.scrollLeft!=i&&(r.scrollLeft=i)}}let un=null;function fn(e,t){let n,r,o,i,s=2e8,l=0,a=t.top,c=t.top;for(let h=e.firstChild,d=0;h;h=h.nextSibling,d++){let e;if(1==h.nodeType)e=h.getClientRects();else{if(3!=h.nodeType)continue;e=Rt(h).getClientRects()}for(let p=0;p<e.length;p++){let u=e[p];if(u.top<=a&&u.bottom>=c){a=Math.max(u.bottom,a),c=Math.min(u.top,c);let e=u.left>t.left?u.left-t.left:u.right<t.left?t.left-u.right:0;if(e<s){n=h,s=e,r=e&&3==n.nodeType?{left:u.right<t.left?u.right:u.left,top:t.top}:t,1==h.nodeType&&e&&(l=d+(t.left>=(u.left+u.right)/2?1:0));continue}}else u.top>t.top&&!o&&u.left<=t.left&&u.right>=t.left&&(o=h,i={left:Math.max(u.left,Math.min(u.right,t.left)),top:u.top});!n&&(t.left>=u.right&&t.top>=u.top||t.left>=u.left&&t.top>=u.bottom)&&(l=d+1)}}return!n&&o&&(n=o,r=i,s=0),n&&3==n.nodeType?function(e,t){let n,r=e.nodeValue.length,o=document.createRange();for(let i=0;i<r;i++){o.setEnd(e,i+1),o.setStart(e,i);let r=vn(o,1);if(r.top!=r.bottom&&mn(t,r)){n={node:e,offset:i+(t.left>=(r.left+r.right)/2?1:0)};break}}return o.detach(),n||{node:e,offset:0}}(n,r):!n||s&&1==n.nodeType?{node:e,offset:l}:fn(n,r)}function mn(e,t){return e.left>=t.left-1&&e.left<=t.right+1&&e.top>=t.top-1&&e.top<=t.bottom+1}function gn(e,t,n){let r=e.childNodes.length;if(r&&n.top<n.bottom)for(let o=Math.max(0,Math.min(r-1,Math.floor(r*(t.top-n.top)/(n.bottom-n.top))-2)),i=o;;){let n=e.childNodes[i];if(1==n.nodeType){let e=n.getClientRects();for(let r=0;r<e.length;r++){let o=e[r];if(mn(t,o))return gn(n,t,o)}}if((i=(i+1)%r)==o)break}return e}function yn(e,t){let n,r=e.dom.ownerDocument,o=0,i=function(e,t,n){if(e.caretPositionFromPoint)try{let r=e.caretPositionFromPoint(t,n);if(r)return{node:r.offsetNode,offset:Math.min($t(r.offsetNode),r.offset)}}catch(e){}if(e.caretRangeFromPoint){let r=e.caretRangeFromPoint(t,n);if(r)return{node:r.startContainer,offset:Math.min($t(r.startContainer),r.startOffset)}}}(r,t.left,t.top);i&&({node:n,offset:o}=i);let s,l=(e.root.elementFromPoint?e.root:r).elementFromPoint(t.left,t.top);if(!l||!e.dom.contains(1!=l.nodeType?l.parentNode:l)){let n=e.dom.getBoundingClientRect();if(!mn(t,n))return null;if(l=gn(e.dom,t,n),!l)return null}if(Zt)for(let e=l;n&&e;e=At(e))e.draggable&&(n=void 0);if(l=function(e,t){let n=e.parentNode;return n&&/^li$/i.test(n.nodeName)&&t.left<e.getBoundingClientRect().left?n:e}(l,t),n){if(Gt&&1==n.nodeType&&(o=Math.min(o,n.childNodes.length),o<n.childNodes.length)){let e,r=n.childNodes[o];"IMG"==r.nodeName&&(e=r.getBoundingClientRect()).right<=t.left&&e.bottom>t.top&&o++}let r;on&&o&&1==n.nodeType&&1==(r=n.childNodes[o-1]).nodeType&&"false"==r.contentEditable&&r.getBoundingClientRect().top>=t.top&&o--,n==e.dom&&o==n.childNodes.length-1&&1==n.lastChild.nodeType&&t.top>n.lastChild.getBoundingClientRect().bottom?s=e.state.doc.content.size:0!=o&&1==n.nodeType&&"BR"==n.childNodes[o-1].nodeName||(s=function(e,t,n,r){let o=-1;for(let n=t,i=!1;n!=e.dom;){let t,s=e.docView.nearestDesc(n,!0);if(!s)return null;if(1==s.dom.nodeType&&(s.node.isBlock&&s.parent||!s.contentDOM)&&((t=s.dom.getBoundingClientRect()).width||t.height)&&(s.node.isBlock&&s.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(s.dom.nodeName)&&(!i&&t.left>r.left||t.top>r.top?o=s.posBefore:(!i&&t.right<r.left||t.bottom<r.top)&&(o=s.posAfter),i=!0),!s.contentDOM&&o<0&&!s.node.isText))return(s.node.isBlock?r.top<(t.top+t.bottom)/2:r.left<(t.left+t.right)/2)?s.posBefore:s.posAfter;n=s.dom.parentNode}return o>-1?o:e.docView.posFromDOM(t,n,-1)}(e,n,o,t))}null==s&&(s=function(e,t,n){let{node:r,offset:o}=fn(t,n),i=-1;if(1==r.nodeType&&!r.firstChild){let e=r.getBoundingClientRect();i=e.left!=e.right&&n.left>(e.left+e.right)/2?1:-1}return e.docView.posFromDOM(r,o,i)}(e,l,t));let a=e.docView.nearestDesc(l,!0);return{pos:s,inside:a?a.posAtStart-a.border:-1}}function wn(e){return e.top<e.bottom||e.left<e.right}function vn(e,t){let n=e.getClientRects();if(n.length){let e=n[t<0?0:n.length-1];if(wn(e))return e}return Array.prototype.find.call(n,wn)||e.getBoundingClientRect()}const bn=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function kn(e,t,n){let{node:r,offset:o,atom:i}=e.docView.domFromPos(t,n<0?-1:1),s=on||Gt;if(3==r.nodeType){if(!s||!bn.test(r.nodeValue)&&(n<0?o:o!=r.nodeValue.length)){let e=o,t=o,i=n<0?1:-1;return n<0&&!o?(t++,i=-1):n>=0&&o==r.nodeValue.length?(e--,i=1):n<0?e--:t++,xn(vn(Rt(r,e,t),i),i<0)}{let e=vn(Rt(r,o,o),n);if(Gt&&o&&/\s/.test(r.nodeValue[o-1])&&o<r.nodeValue.length){let t=vn(Rt(r,o-1,o-1),-1);if(t.top==e.top){let n=vn(Rt(r,o,o+1),-1);if(n.top!=e.top)return xn(n,n.left<t.left)}}return e}}if(!e.state.doc.resolve(t-(i||0)).parent.inlineContent){if(null==i&&o&&(n<0||o==$t(r))){let e=r.childNodes[o-1];if(1==e.nodeType)return Sn(e.getBoundingClientRect(),!1)}if(null==i&&o<$t(r)){let e=r.childNodes[o];if(1==e.nodeType)return Sn(e.getBoundingClientRect(),!0)}return Sn(r.getBoundingClientRect(),n>=0)}if(null==i&&o&&(n<0||o==$t(r))){let e=r.childNodes[o-1],t=3==e.nodeType?Rt(e,$t(e)-(s?0:1)):1!=e.nodeType||"BR"==e.nodeName&&e.nextSibling?null:e;if(t)return xn(vn(t,1),!1)}if(null==i&&o<$t(r)){let e=r.childNodes[o];for(;e.pmViewDesc&&e.pmViewDesc.ignoreForCoords;)e=e.nextSibling;let t=e?3==e.nodeType?Rt(e,0,s?0:1):1==e.nodeType?e:null:null;if(t)return xn(vn(t,-1),!0)}return xn(vn(3==r.nodeType?Rt(r):r,-n),n>=0)}function xn(e,t){if(0==e.width)return e;let n=t?e.left:e.right;return{top:e.top,bottom:e.bottom,left:n,right:n}}function Sn(e,t){if(0==e.height)return e;let n=t?e.top:e.bottom;return{top:n,bottom:n,left:e.left,right:e.right}}function Cn(e,t,n){let r=e.state,o=e.root.activeElement;r!=t&&e.updateState(t),o!=e.dom&&e.focus();try{return n()}finally{r!=t&&e.updateState(r),o!=e.dom&&o&&o.focus()}}const Mn=/[\u0590-\u08ac]/;let On=null,Nn=null,Dn=!1;function Tn(e,t,n){return On==t&&Nn==n?Dn:(On=t,Nn=n,Dn="up"==n||"down"==n?function(e,t,n){let r=t.selection,o="up"==n?r.$from:r.$to;return Cn(e,t,()=>{let{node:t}=e.docView.domFromPos(o.pos,"up"==n?-1:1);for(;;){let n=e.docView.nearestDesc(t,!0);if(!n)break;if(n.node.isBlock){t=n.contentDOM||n.dom;break}t=n.dom.parentNode}let r=kn(e,o.pos,1);for(let e=t.firstChild;e;e=e.nextSibling){let t;if(1==e.nodeType)t=e.getClientRects();else{if(3!=e.nodeType)continue;t=Rt(e,0,e.nodeValue.length).getClientRects()}for(let e=0;e<t.length;e++){let o=t[e];if(o.bottom>o.top+1&&("up"==n?r.top-o.top>2*(o.bottom-r.top):o.bottom-r.bottom>2*(r.bottom-o.top)))return!1}}return!0})}(e,t,n):function(e,t,n){let{$head:r}=t.selection;if(!r.parent.isTextblock)return!1;let o=r.parentOffset,i=!o,s=o==r.parent.content.size,l=e.domSelection();return l?Mn.test(r.parent.textContent)&&l.modify?Cn(e,t,()=>{let{focusNode:t,focusOffset:o,anchorNode:i,anchorOffset:s}=e.domSelectionRange(),a=l.caretBidiLevel;l.modify("move",n,"character");let c=r.depth?e.docView.domAfterPos(r.before()):e.dom,{focusNode:h,focusOffset:d}=e.domSelectionRange(),p=h&&!c.contains(1==h.nodeType?h:h.parentNode)||t==h&&o==d;try{l.collapse(i,s),t&&(t!=i||o!=s)&&l.extend&&l.extend(t,o)}catch(e){}return null!=a&&(l.caretBidiLevel=a),p}):"left"==n||"backward"==n?i:s:r.pos==r.start()||r.pos==r.end()}(e,t,n))}class En{constructor(e,t,n,r){this.parent=e,this.children=t,this.dom=n,this.contentDOM=r,this.dirty=0,n.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,n){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;t<this.children.length;t++)e+=this.children[t].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let t=0,n=this.posAtStart;;t++){let r=this.children[t];if(r==e)return n;n+=r.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,t,n){if(this.contentDOM&&this.contentDOM.contains(1==e.nodeType?e:e.parentNode)){if(n<0){let n,r;if(e==this.contentDOM)n=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;n=e.previousSibling}for(;n&&(!(r=n.pmViewDesc)||r.parent!=this);)n=n.previousSibling;return n?this.posBeforeChild(r)+r.size:this.posAtStart}{let n,r;if(e==this.contentDOM)n=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;n=e.nextSibling}for(;n&&(!(r=n.pmViewDesc)||r.parent!=this);)n=n.nextSibling;return n?this.posBeforeChild(r):this.posAtEnd}}let r;if(e==this.dom&&this.contentDOM)r=t>Et(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))r=2&e.compareDocumentPosition(this.contentDOM);else if(this.dom.firstChild){if(0==t)for(let t=e;;t=t.parentNode){if(t==this.dom){r=!1;break}if(t.previousSibling)break}if(null==r&&t==e.childNodes.length)for(let t=e;;t=t.parentNode){if(t==this.dom){r=!0;break}if(t.nextSibling)break}}return(null==r?n>0:r)?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let n=!0,r=e;r;r=r.parentNode){let o,i=this.getDesc(r);if(i&&(!t||i.node)){if(!n||!(o=i.nodeDOM)||(1==o.nodeType?o.contains(1==e.nodeType?e:e.parentNode):o==e))return i;n=!1}}}getDesc(e){let t=e.pmViewDesc;for(let e=t;e;e=e.parent)if(e==this)return t}posFromDOM(e,t,n){for(let r=e;r;r=r.parentNode){let o=this.getDesc(r);if(o)return o.localPosFromDOM(e,t,n)}return-1}descAt(e){for(let t=0,n=0;t<this.children.length;t++){let r=this.children[t],o=n+r.size;if(n==e&&o!=n){for(;!r.border&&r.children.length;)for(let e=0;e<r.children.length;e++){let t=r.children[e];if(t.size){r=t;break}}return r}if(e<o)return r.descAt(e-n-r.border);n=o}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let n=0,r=0;for(let t=0;n<this.children.length;n++){let o=this.children[n],i=t+o.size;if(i>e||o instanceof $n){r=e-t;break}t=i}if(r)return this.children[n].domFromPos(r-this.children[n].border,t);for(let e;n&&!(e=this.children[n-1]).size&&e instanceof An&&e.side>=0;n--);if(t<=0){let e,r=!0;for(;e=n?this.children[n-1]:null,e&&e.dom.parentNode!=this.contentDOM;n--,r=!1);return e&&t&&r&&!e.border&&!e.domAtom?e.domFromPos(e.size,t):{node:this.contentDOM,offset:e?Et(e.dom)+1:0}}{let e,r=!0;for(;e=n<this.children.length?this.children[n]:null,e&&e.dom.parentNode!=this.contentDOM;n++,r=!1);return e&&r&&!e.border&&!e.domAtom?e.domFromPos(0,t):{node:this.contentDOM,offset:e?Et(e.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,n=0){if(0==this.children.length)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let r=-1,o=-1;for(let i=n,s=0;;s++){let n=this.children[s],l=i+n.size;if(-1==r&&e<=l){let o=i+n.border;if(e>=o&&t<=l-n.border&&n.node&&n.contentDOM&&this.contentDOM.contains(n.contentDOM))return n.parseRange(e,t,o);e=i;for(let t=s;t>0;t--){let n=this.children[t-1];if(n.size&&n.dom.parentNode==this.contentDOM&&!n.emptyChildAt(1)){r=Et(n.dom)+1;break}e-=n.size}-1==r&&(r=0)}if(r>-1&&(l>t||s==this.children.length-1)){t=l;for(let e=s+1;e<this.children.length;e++){let n=this.children[e];if(n.size&&n.dom.parentNode==this.contentDOM&&!n.emptyChildAt(-1)){o=Et(n.dom);break}t+=n.size}-1==o&&(o=this.contentDOM.childNodes.length);break}i=l}return{node:this.contentDOM,from:e,to:t,fromOffset:r,toOffset:o}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let t=this.children[e<0?0:this.children.length-1];return 0==t.size||t.emptyChildAt(e)}domAfterPos(e){let{node:t,offset:n}=this.domFromPos(e,0);if(1!=t.nodeType||n==t.childNodes.length)throw new RangeError("No node after pos "+e);return t.childNodes[n]}setSelection(e,t,n,r=!1){let o=Math.min(e,t),i=Math.max(e,t);for(let s=0,l=0;s<this.children.length;s++){let a=this.children[s],c=l+a.size;if(o>l&&i<c)return a.setSelection(e-l-a.border,t-l-a.border,n,r);l=c}let s=this.domFromPos(e,e?-1:1),l=t==e?s:this.domFromPos(t,t?-1:1),a=n.root.getSelection(),c=n.domSelectionRange(),h=!1;if((Gt||Zt)&&e==t){let{node:e,offset:t}=s;if(3==e.nodeType){if(h=!(!t||"\n"!=e.nodeValue[t-1]),h&&t==e.nodeValue.length)for(let t,n=e;n;n=n.parentNode){if(t=n.nextSibling){"BR"==t.nodeName&&(s=l={node:t.parentNode,offset:Et(t)+1});break}let e=n.pmViewDesc;if(e&&e.node&&e.node.isBlock)break}}else{let n=e.childNodes[t-1];h=n&&("BR"==n.nodeName||"false"==n.contentEditable)}}if(Gt&&c.focusNode&&c.focusNode!=l.node&&1==c.focusNode.nodeType){let e=c.focusNode.childNodes[c.focusOffset];e&&"false"==e.contentEditable&&(r=!0)}if(!(r||h&&Zt)&&zt(s.node,s.offset,c.anchorNode,c.anchorOffset)&&zt(l.node,l.offset,c.focusNode,c.focusOffset))return;let d=!1;if((a.extend||e==t)&&(!h||!Gt)){a.collapse(s.node,s.offset);try{e!=t&&a.extend(l.node,l.offset),d=!0}catch(e){}}if(!d){if(e>t){let e=s;s=l,l=e}let n=document.createRange();n.setEnd(l.node,l.offset),n.setStart(s.node,s.offset),a.removeAllRanges(),a.addRange(n)}}ignoreMutation(e){return!this.contentDOM&&"selection"!=e.type}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let n=0,r=0;r<this.children.length;r++){let o=this.children[r],i=n+o.size;if(n==i?e<=i&&t>=n:e<i&&t>n){let r=n+o.border,s=i-o.border;if(e>=r&&t<=s)return this.dirty=e==n||t==i?2:1,void(e!=r||t!=s||!o.contentLost&&o.dom.parentNode==this.contentDOM?o.markDirty(e-r,t-r):o.dirty=3);o.dirty=o.dom!=o.contentDOM||o.dom.parentNode!=this.contentDOM||o.children.length?3:2}n=i}this.dirty=2}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let n=1==e?2:1;t.dirty<n&&(t.dirty=n)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class An extends En{constructor(e,t,n,r){let o,i=t.type.toDOM;if("function"==typeof i&&(i=i(n,()=>o?o.parent?o.parent.posBeforeChild(o):void 0:r)),!t.type.spec.raw){if(1!=i.nodeType){let e=document.createElement("span");e.appendChild(i),i=e}i.contentEditable="false",i.classList.add("ProseMirror-widget")}super(e,[],i,null),this.widget=t,this.widget=t,o=this}matchesWidget(e){return 0==this.dirty&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return!!t&&t(e)}ignoreMutation(e){return"selection"!=e.type||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}}class In extends En{constructor(e,t,n,r){super(e,[],t,null),this.textDOM=n,this.text=r}get size(){return this.text.length}localPosFromDOM(e,t){return e!=this.textDOM?this.posAtStart+(t?this.size:0):this.posAtStart+t}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return"characterData"===e.type&&e.target.nodeValue==e.oldValue}}class Rn extends En{constructor(e,t,n,r,o){super(e,[],n,r),this.mark=t,this.spec=o}static create(e,t,n,r){let o=r.nodeViews[t.type.name],i=o&&o(t,r,n);return i&&i.dom||(i=se.renderSpec(document,t.type.spec.toDOM(t,n),null,t.attrs)),new Rn(e,t,i.dom,i.contentDOM||i.dom,i)}parseRule(){return 3&this.dirty||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return 3!=this.dirty&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),0!=this.dirty){let e=this.parent;for(;!e.node;)e=e.parent;e.dirty<this.dirty&&(e.dirty=this.dirty),this.dirty=0}}slice(e,t,n){let r=Rn.create(this.parent,this.mark,!0,n),o=this.children,i=this.size;t<i&&(o=Yn(o,t,i,n)),e>0&&(o=Yn(o,0,e,n));for(let e=0;e<o.length;e++)o[e].parent=r;return r.children=o,r}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class zn extends En{constructor(e,t,n,r,o,i,s){super(e,[],o,i),this.node=t,this.outerDeco=n,this.innerDeco=r,this.nodeDOM=s}static create(e,t,n,r,o,i){let s,l=o.nodeViews[t.type.name],a=l&&l(t,o,()=>s?s.parent?s.parent.posBeforeChild(s):void 0:i,n,r),c=a&&a.dom,h=a&&a.contentDOM;if(t.isText)if(c){if(3!=c.nodeType)throw new RangeError("Text must be rendered as a DOM text node")}else c=document.createTextNode(t.text);else if(!c){let e=se.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs);({dom:c,contentDOM:h}=e)}h||t.isText||"BR"==c.nodeName||(c.hasAttribute("contenteditable")||(c.contentEditable="false"),t.type.spec.draggable&&(c.draggable=!0));let d=c;return c=jn(c,n,t),a?s=new Vn(e,t,n,r,c,h||null,d,a):t.isText?new Bn(e,t,n,r,c,d):new zn(e,t,n,r,c,h||null,d)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if("pre"==this.node.type.whitespace&&(e.preserveWhitespace="full"),this.contentDOM)if(this.contentLost){for(let t=this.children.length-1;t>=0;t--){let n=this.children[t];if(this.dom.contains(n.dom.parentNode)){e.contentElement=n.dom.parentNode;break}}e.contentElement||(e.getContent=()=>i.empty)}else e.contentElement=this.contentDOM;else e.getContent=()=>this.node.content;return e}matchesNode(e,t,n){return 0==this.dirty&&e.eq(this.node)&&Kn(t,this.outerDeco)&&n.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let n=this.node.inlineContent,r=t,o=e.composing?this.localCompositionInfo(e,t):null,i=o&&o.pos>-1?o:null,s=o&&o.pos<0,l=new Un(this,i&&i.node,e);!function(e,t,n,r){let o=t.locals(e),i=0;if(0==o.length){for(let n=0;n<e.childCount;n++){let s=e.child(n);r(s,o,t.forChild(i,s),n),i+=s.nodeSize}return}let s=0,l=[],a=null;for(let c=0;;){let h,d,p,u;for(;s<o.length&&o[s].to==i;){let e=o[s++];e.widget&&(h?(d||(d=[h])).push(e):h=e)}if(h)if(d){d.sort(Gn);for(let e=0;e<d.length;e++)n(d[e],c,!!a)}else n(h,c,!!a);if(a)u=-1,p=a,a=null;else{if(!(c<e.childCount))break;u=c,p=e.child(c++)}for(let e=0;e<l.length;e++)l[e].to<=i&&l.splice(e--,1);for(;s<o.length&&o[s].from<=i&&o[s].to>i;)l.push(o[s++]);let f=i+p.nodeSize;if(p.isText){let e=f;s<o.length&&o[s].from<e&&(e=o[s].from);for(let t=0;t<l.length;t++)l[t].to<e&&(e=l[t].to);e<f&&(a=p.cut(e-i),p=p.cut(0,e-i),f=e,u=-1)}else for(;s<o.length&&o[s].to<f;)s++;r(p,p.isInline&&!p.isLeaf?l.filter(e=>!e.inline):l.slice(),t.forChild(i,p),u),i=f}}(this.node,this.innerDeco,(t,o,i)=>{t.spec.marks?l.syncToMarks(t.spec.marks,n,e,o):t.type.side>=0&&!i&&l.syncToMarks(o==this.node.childCount?c.none:this.node.child(o).marks,n,e,o),l.placeWidget(t,e,r)},(t,i,a,c)=>{let h;l.syncToMarks(t.marks,n,e,c),l.findNodeMatch(t,i,a,c)||s&&e.state.selection.from>r&&e.state.selection.to<r+t.nodeSize&&(h=l.findIndexWithChild(o.node))>-1&&l.updateNodeAt(t,i,a,h,e)||l.updateNextNode(t,i,a,e,c,r)||l.addNode(t,i,a,e,r),r+=t.nodeSize}),l.syncToMarks([],n,e,0),this.node.isTextblock&&l.addTextblockHacks(),l.destroyRest(),(l.changed||2==this.dirty)&&(i&&this.protectLocalComposition(e,i),Fn(this.contentDOM,this.children,e),en&&function(e){if("UL"==e.nodeName||"OL"==e.nodeName){let t=e.style.cssText;e.style.cssText=t+"; list-style: square !important",window.getComputedStyle(e).listStyle,e.style.cssText=t}}(this.dom))}localCompositionInfo(e,t){let{from:n,to:r}=e.state.selection;if(!(e.state.selection instanceof ht)||n<t||r>t+this.node.content.size)return null;let o=e.input.compositionNode;if(!o||!this.dom.contains(o.parentNode))return null;if(this.node.inlineContent){let e=o.nodeValue,i=function(e,t,n,r){for(let o=0,i=0;o<e.childCount&&i<=r;){let s=e.child(o++),l=i;if(i+=s.nodeSize,!s.isText)continue;let a=s.text;for(;o<e.childCount;){let t=e.child(o++);if(i+=t.nodeSize,!t.isText)break;a+=t.text}if(i>=n){if(i>=r&&a.slice(r-t.length-l,r-l)==t)return r-t.length;let e=l<r?a.lastIndexOf(t,r-l-1):-1;if(e>=0&&e+t.length+l>=n)return l+e;if(n==r&&a.length>=r+t.length-l&&a.slice(r-l,r-l+t.length)==t)return r}}return-1}(this.node.content,e,n-t,r-t);return i<0?null:{node:o,pos:i,text:e}}return{node:o,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:n,text:r}){if(this.getDesc(t))return;let o=t;for(;o.parentNode!=this.contentDOM;o=o.parentNode){for(;o.previousSibling;)o.parentNode.removeChild(o.previousSibling);for(;o.nextSibling;)o.parentNode.removeChild(o.nextSibling);o.pmViewDesc&&(o.pmViewDesc=void 0)}let i=new In(this,o,t,r);e.input.compositionNodes.push(i),this.children=Yn(this.children,n,n+r.length,e,i)}update(e,t,n,r){return!(3==this.dirty||!e.sameMarkup(this.node))&&(this.updateInner(e,t,n,r),!0)}updateInner(e,t,n,r){this.updateOuterDeco(t),this.node=e,this.innerDeco=n,this.contentDOM&&this.updateChildren(r,this.posAtStart),this.dirty=0}updateOuterDeco(e){if(Kn(e,this.outerDeco))return;let t=1!=this.nodeDOM.nodeType,n=this.dom;this.dom=Wn(this.dom,this.nodeDOM,_n(this.outerDeco,this.node,t),_n(e,this.node,t)),this.dom!=n&&(n.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){1==this.nodeDOM.nodeType&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),!this.contentDOM&&this.node.type.spec.draggable||(this.nodeDOM.draggable=!0))}deselectNode(){1==this.nodeDOM.nodeType&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),!this.contentDOM&&this.node.type.spec.draggable||this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function Pn(e,t,n,r,o){jn(r,t,e);let i=new zn(void 0,e,t,n,r,r,r);return i.contentDOM&&i.updateChildren(o,0),i}class Bn extends zn{constructor(e,t,n,r,o,i){super(e,t,n,r,o,null,i)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,n,r){return!(3==this.dirty||0!=this.dirty&&!this.inParent()||!e.sameMarkup(this.node))&&(this.updateOuterDeco(t),0==this.dirty&&e.text==this.node.text||e.text==this.nodeDOM.nodeValue||(this.nodeDOM.nodeValue=e.text,r.trackWrites==this.nodeDOM&&(r.trackWrites=null)),this.node=e,this.dirty=0,!0)}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,n){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,n)}ignoreMutation(e){return"characterData"!=e.type&&"selection"!=e.type}slice(e,t,n){let r=this.node.cut(e,t),o=document.createTextNode(r.text);return new Bn(this.parent,r,this.outerDeco,this.innerDeco,o,o)}markDirty(e,t){super.markDirty(e,t),this.dom==this.nodeDOM||0!=e&&t!=this.nodeDOM.nodeValue.length||(this.dirty=3)}get domAtom(){return!1}isText(e){return this.node.text==e}}class $n extends En{parseRule(){return{ignore:!0}}matchesHack(e){return 0==this.dirty&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return"IMG"==this.dom.nodeName}}class Vn extends zn{constructor(e,t,n,r,o,i,s,l){super(e,t,n,r,o,i,s),this.spec=l}update(e,t,n,r){if(3==this.dirty)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let o=this.spec.update(e,t,n);return o&&this.updateInner(e,t,n,r),o}return!(!this.contentDOM&&!e.isLeaf)&&super.update(e,t,n,r)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,n,r){this.spec.setSelection?this.spec.setSelection(e,t,n.root):super.setSelection(e,t,n,r)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return!!this.spec.stopEvent&&this.spec.stopEvent(e)}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function Fn(e,t,n){let r=e.firstChild,o=!1;for(let i=0;i<t.length;i++){let s=t[i],l=s.dom;if(l.parentNode==e){for(;l!=r;)r=Hn(r),o=!0;r=r.nextSibling}else o=!0,e.insertBefore(l,r);if(s instanceof Rn){let t=r?r.previousSibling:e.lastChild;Fn(s.contentDOM,s.children,n),r=t?t.nextSibling:e.firstChild}}for(;r;)r=Hn(r),o=!0;o&&n.trackWrites==e&&(n.trackWrites=null)}const qn=function(e){e&&(this.nodeName=e)};qn.prototype=Object.create(null);const Ln=[new qn];function _n(e,t,n){if(0==e.length)return Ln;let r=n?Ln[0]:new qn,o=[r];for(let i=0;i<e.length;i++){let s=e[i].type.attrs;if(s){s.nodeName&&o.push(r=new qn(s.nodeName));for(let e in s){let i=s[e];null!=i&&(n&&1==o.length&&o.push(r=new qn(t.isInline?"span":"div")),"class"==e?r.class=(r.class?r.class+" ":"")+i:"style"==e?r.style=(r.style?r.style+";":"")+i:"nodeName"!=e&&(r[e]=i))}}}return o}function Wn(e,t,n,r){if(n==Ln&&r==Ln)return t;let o=t;for(let t=0;t<r.length;t++){let i=r[t],s=n[t];if(t){let t;s&&s.nodeName==i.nodeName&&o!=e&&(t=o.parentNode)&&t.nodeName.toLowerCase()==i.nodeName||(t=document.createElement(i.nodeName),t.pmIsDeco=!0,t.appendChild(o),s=Ln[0]),o=t}Jn(o,s||Ln[0],i)}return o}function Jn(e,t,n){for(let r in t)"class"==r||"style"==r||"nodeName"==r||r in n||e.removeAttribute(r);for(let r in n)"class"!=r&&"style"!=r&&"nodeName"!=r&&n[r]!=t[r]&&e.setAttribute(r,n[r]);if(t.class!=n.class){let r=t.class?t.class.split(" ").filter(Boolean):[],o=n.class?n.class.split(" ").filter(Boolean):[];for(let t=0;t<r.length;t++)-1==o.indexOf(r[t])&&e.classList.remove(r[t]);for(let t=0;t<o.length;t++)-1==r.indexOf(o[t])&&e.classList.add(o[t]);0==e.classList.length&&e.removeAttribute("class")}if(t.style!=n.style){if(t.style){let n,r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g;for(;n=r.exec(t.style);)e.style.removeProperty(n[1])}n.style&&(e.style.cssText+=n.style)}}function jn(e,t,n){return Wn(e,e,Ln,_n(t,n,1!=e.nodeType))}function Kn(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].type.eq(t[n].type))return!1;return!0}function Hn(e){let t=e.nextSibling;return e.parentNode.removeChild(e),t}class Un{constructor(e,t,n){this.lock=t,this.view=n,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=function(e,t){let n=t,r=n.children.length,o=e.childCount,i=new Map,s=[];e:for(;o>0;){let l;for(;;)if(r){let e=n.children[r-1];if(!(e instanceof Rn)){l=e,r--;break}n=e,r=e.children.length}else{if(n==t)break e;r=n.parent.children.indexOf(n),n=n.parent}let a=l.node;if(a){if(a!=e.child(o-1))break;--o,i.set(l,o),s.push(l)}}return{index:o,matched:i,matches:s.reverse()}}(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let n=e;n<t;n++)this.top.children[n].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,n,r){let o=0,i=this.stack.length>>1,s=Math.min(i,e.length);for(;o<s&&(o==i-1?this.top:this.stack[o+1<<1]).matchesMark(e[o])&&!1!==e[o].type.spec.spanning;)o++;for(;o<i;)this.destroyRest(),this.top.dirty=0,this.index=this.stack.pop(),this.top=this.stack.pop(),i--;for(;i<e.length;){this.stack.push(this.top,this.index+1);let o=-1,s=this.top.children.length;r<this.preMatch.index&&(s=Math.min(this.index+3,s));for(let t=this.index;t<s;t++){let n=this.top.children[t];if(n.matchesMark(e[i])&&!this.isLocked(n.dom)){o=t;break}}if(o<0&&this.index<this.top.children.length){let t=this.top.children[this.index];t instanceof Rn&&3!=t.dirty&&t.mark.type==e[i].type&&t.spec.update&&!this.isLocked(t.dom)&&t.spec.update(e[i])&&(t.mark=e[i],o=this.index,this.changed=!0)}if(o>-1)o>this.index&&(this.changed=!0,this.destroyBetween(this.index,o)),this.top=this.top.children[this.index];else{let r=Rn.create(this.top,e[i],t,n);this.top.children.splice(this.index,0,r),this.top=r,this.changed=!0}this.index=0,i++}}findNodeMatch(e,t,n,r){let o,i=-1;if(r>=this.preMatch.index&&(o=this.preMatch.matches[r-this.preMatch.index]).parent==this.top&&o.matchesNode(e,t,n))i=this.top.children.indexOf(o,this.index);else for(let r=this.index,o=Math.min(this.top.children.length,r+5);r<o;r++){let o=this.top.children[r];if(o.matchesNode(e,t,n)&&!this.preMatch.matched.has(o)){i=r;break}}return!(i<0)&&(this.destroyBetween(this.index,i),this.index++,!0)}updateNodeAt(e,t,n,r,o){let i=this.top.children[r];return 3==i.dirty&&i.dom==i.contentDOM&&(i.dirty=2),!!i.update(e,t,n,o)&&(this.destroyBetween(this.index,r),this.index++,!0)}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){let t=e.pmViewDesc;if(t)for(let e=this.index;e<this.top.children.length;e++)if(this.top.children[e]==t)return e;return-1}e=t}}updateNextNode(e,t,n,r,o,i){for(let s=this.index;s<this.top.children.length;s++){let l=this.top.children[s];if(l instanceof zn){let a=this.preMatch.matched.get(l);if(null!=a&&a!=o)return!1;let c,h=l.dom,d=this.isLocked(h)&&!(e.isText&&l.node&&l.node.isText&&l.nodeDOM.nodeValue==e.text&&3!=l.dirty&&Kn(t,l.outerDeco));if(!d&&l.update(e,t,n,r))return this.destroyBetween(this.index,s),l.dom!=h&&(this.changed=!0),this.index++,!0;if(!d&&(c=this.recreateWrapper(l,e,t,n,r,i)))return this.destroyBetween(this.index,s),this.top.children[this.index]=c,c.contentDOM&&(c.dirty=2,c.updateChildren(r,i+1),c.dirty=0),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,n,r,o,i){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!Kn(n,e.outerDeco)||!r.eq(e.innerDeco))return null;let s=zn.create(this.top,t,n,r,o,i);if(s.contentDOM){s.children=e.children,e.children=[];for(let e of s.children)e.parent=s}return e.destroy(),s}addNode(e,t,n,r,o){let i=zn.create(this.top,e,t,n,r,o);i.contentDOM&&i.updateChildren(r,o+1),this.top.children.splice(this.index++,0,i),this.changed=!0}placeWidget(e,t,n){let r=this.index<this.top.children.length?this.top.children[this.index]:null;if(!r||!r.matchesWidget(e)||e!=r.widget&&r.widget.type.toDOM.parentNode){let r=new An(this.top,e,t,n);this.top.children.splice(this.index++,0,r),this.changed=!0}else this.index++}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof Rn;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof Bn)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((Zt||Qt)&&e&&"false"==e.dom.contentEditable&&this.addHackNode("IMG",t),this.addHackNode("BR",this.top))}addHackNode(e,t){if(t==this.top&&this.index<t.children.length&&t.children[this.index].matchesHack(e))this.index++;else{let n=document.createElement(e);"IMG"==e&&(n.className="ProseMirror-separator",n.alt=""),"BR"==e&&(n.className="ProseMirror-trailingBreak");let r=new $n(this.top,[],n,null);t!=this.top?t.children.push(r):t.children.splice(this.index++,0,r),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||1==e.nodeType&&e.contains(this.lock.parentNode))}}function Gn(e,t){return e.type.side-t.type.side}function Yn(e,t,n,r,o){let i=[];for(let s=0,l=0;s<e.length;s++){let a=e[s],c=l,h=l+=a.size;c>=n||h<=t?i.push(a):(c<t&&i.push(a.slice(0,t-c,r)),o&&(i.push(o),o=void 0),h>n&&i.push(a.slice(n-c,a.size,r)))}return i}function Qn(e,t=null){let n=e.domSelectionRange(),r=e.state.doc;if(!n.focusNode)return null;let o=e.docView.nearestDesc(n.focusNode),i=o&&0==o.size,s=e.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(s<0)return null;let l,a,c=r.resolve(s);if(Ft(n)){for(l=s;o&&!o.node;)o=o.parent;let e=o.node;if(o&&e.isAtom&&pt.isSelectable(e)&&o.parent&&(!e.isInline||!function(e,t,n){for(let r=0==t,o=t==$t(e);r||o;){if(e==n)return!0;let t=Et(e);if(!(e=e.parentNode))return!1;r=r&&0==t,o=o&&t==$t(e)}}(n.focusNode,n.focusOffset,o.dom))){let e=o.posBefore;a=new pt(s==e?c:r.resolve(e))}}else{if(n instanceof e.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let t=s,o=s;for(let r=0;r<n.rangeCount;r++){let i=n.getRangeAt(r);t=Math.min(t,e.docView.posFromDOM(i.startContainer,i.startOffset,1)),o=Math.max(o,e.docView.posFromDOM(i.endContainer,i.endOffset,-1))}if(t<0)return null;[l,s]=o==e.state.selection.anchor?[o,t]:[t,o],c=r.resolve(s)}else l=e.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(l<0)return null}let h=r.resolve(l);if(!a){a=sr(e,h,c,"pointer"==t||e.state.selection.head<c.pos&&!i?1:-1)}return a}function Xn(e){return e.editable?e.hasFocus():ar(e)&&document.activeElement&&document.activeElement.contains(e.dom)}function Zn(e,t=!1){let n=e.state.selection;if(or(e,n),!Xn(e))return;let r=e.input.mouseDown;if(!t&&Qt&&r){let t=e.domSelectionRange(),n=e.domObserver.currentSelection;if(t.anchorNode&&n.anchorNode&&zt(t.anchorNode,t.anchorOffset,n.anchorNode,n.anchorOffset)&&r.delaySelUpdate())return void e.domObserver.setCurSelection()}if(e.domObserver.disconnectSelection(),e.cursorWrapper)!function(e){let t=e.domSelection();if(!t)return;let n=e.cursorWrapper.dom,r="IMG"==n.nodeName;r?t.collapse(n.parentNode,Et(n)+1):t.collapse(n,0);!r&&!e.state.selection.visible&&Ht&&Ut<=11&&(n.disabled=!0,n.disabled=!1)}(e);else{let r,o,{anchor:i,head:s}=n;!er||n instanceof ht||(n.$from.parent.inlineContent||(r=tr(e,n.from)),n.empty||n.$from.parent.inlineContent||(o=tr(e,n.to))),e.docView.setSelection(i,s,e,t),er&&(r&&rr(r),o&&rr(o)),n.visible?e.dom.classList.remove("ProseMirror-hideselection"):(e.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&function(e){let t=e.dom.ownerDocument;t.removeEventListener("selectionchange",e.input.hideSelectionGuard);let n=e.domSelectionRange(),r=n.anchorNode,o=n.anchorOffset;t.addEventListener("selectionchange",e.input.hideSelectionGuard=()=>{n.anchorNode==r&&n.anchorOffset==o||(t.removeEventListener("selectionchange",e.input.hideSelectionGuard),setTimeout(()=>{Xn(e)&&!e.state.selection.visible||e.dom.classList.remove("ProseMirror-hideselection")},20))})}(e))}e.domObserver.setCurSelection(),e.domObserver.connectSelection()}const er=Zt||Qt&&Xt<63;function tr(e,t){let{node:n,offset:r}=e.docView.domFromPos(t,0),o=r<n.childNodes.length?n.childNodes[r]:null,i=r?n.childNodes[r-1]:null;if(Zt&&o&&"false"==o.contentEditable)return nr(o);if(!(o&&"false"!=o.contentEditable||i&&"false"!=i.contentEditable)){if(o)return nr(o);if(i)return nr(i)}}function nr(e){return e.contentEditable="true",Zt&&e.draggable&&(e.draggable=!1,e.wasDraggable=!0),e}function rr(e){e.contentEditable="false",e.wasDraggable&&(e.draggable=!0,e.wasDraggable=null)}function or(e,t){if(t instanceof pt){let n=e.docView.descAt(t.from);n!=e.lastSelectedViewDesc&&(ir(e),n&&n.selectNode(),e.lastSelectedViewDesc=n)}else ir(e)}function ir(e){e.lastSelectedViewDesc&&(e.lastSelectedViewDesc.parent&&e.lastSelectedViewDesc.deselectNode(),e.lastSelectedViewDesc=void 0)}function sr(e,t,n,r){return e.someProp("createSelectionBetween",r=>r(e,t,n))||ht.between(t,n,r)}function lr(e){return!(e.editable&&!e.hasFocus())&&ar(e)}function ar(e){let t=e.domSelectionRange();if(!t.anchorNode)return!1;try{return e.dom.contains(3==t.anchorNode.nodeType?t.anchorNode.parentNode:t.anchorNode)&&(e.editable||e.dom.contains(3==t.focusNode.nodeType?t.focusNode.parentNode:t.focusNode))}catch(e){return!1}}function cr(e,t){let{$anchor:n,$head:r}=e.selection,o=t>0?n.max(r):n.min(r),i=o.parent.inlineContent?o.depth?e.doc.resolve(t>0?o.after():o.before()):null:o;return i&&st.findFrom(i,t)}function hr(e,t){return e.dispatch(e.state.tr.setSelection(t).scrollIntoView()),!0}function dr(e,t,n){let r=e.state.selection;if(!(r instanceof ht)){if(r instanceof pt&&r.node.isInline)return hr(e,new ht(t>0?r.$to:r.$from));{let n=cr(e.state,t);return!!n&&hr(e,n)}}if(n.indexOf("s")>-1){let{$head:n}=r,o=n.textOffset?null:t<0?n.nodeBefore:n.nodeAfter;if(!o||o.isText||!o.isLeaf)return!1;let i=e.state.doc.resolve(n.pos+o.nodeSize*(t<0?-1:1));return hr(e,new ht(r.$anchor,i))}if(!r.empty)return!1;if(e.endOfTextblock(t>0?"forward":"backward")){let n=cr(e.state,t);return!!(n&&n instanceof pt)&&hr(e,n)}if(!(tn&&n.indexOf("m")>-1)){let n,o=r.$head,i=o.textOffset?null:t<0?o.nodeBefore:o.nodeAfter;if(!i||i.isText)return!1;let s=t<0?o.pos-i.nodeSize:o.pos;return!!(i.isAtom||(n=e.docView.descAt(s))&&!n.contentDOM)&&(pt.isSelectable(i)?hr(e,new pt(t<0?e.state.doc.resolve(o.pos-i.nodeSize):o)):!!on&&hr(e,new ht(e.state.doc.resolve(t<0?s:s+i.nodeSize))))}}function pr(e){return 3==e.nodeType?e.nodeValue.length:e.childNodes.length}function ur(e,t){let n=e.pmViewDesc;return n&&0==n.size&&(t<0||e.nextSibling||"BR"!=e.nodeName)}function fr(e,t){return t<0?function(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let o,i,s=!1;Gt&&1==n.nodeType&&r<pr(n)&&ur(n.childNodes[r],-1)&&(s=!0);for(;;)if(r>0){if(1!=n.nodeType)break;{let e=n.childNodes[r-1];if(ur(e,-1))o=n,i=--r;else{if(3!=e.nodeType)break;n=e,r=n.nodeValue.length}}}else{if(mr(n))break;{let t=n.previousSibling;for(;t&&ur(t,-1);)o=n.parentNode,i=Et(t),t=t.previousSibling;if(t)n=t,r=pr(n);else{if(n=n.parentNode,n==e.dom)break;r=0}}}s?gr(e,n,r):o&&gr(e,o,i)}(e):function(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let o,i,s=pr(n);for(;;)if(r<s){if(1!=n.nodeType)break;if(!ur(n.childNodes[r],1))break;o=n,i=++r}else{if(mr(n))break;{let t=n.nextSibling;for(;t&&ur(t,1);)o=t.parentNode,i=Et(t)+1,t=t.nextSibling;if(t)n=t,r=0,s=pr(n);else{if(n=n.parentNode,n==e.dom)break;r=s=0}}}o&&gr(e,o,i)}(e)}function mr(e){let t=e.pmViewDesc;return t&&t.node&&t.node.isBlock}function gr(e,t,n){if(3!=t.nodeType){let e,r;(r=function(e,t){for(;e&&t==e.childNodes.length&&!Vt(e);)t=Et(e)+1,e=e.parentNode;for(;e&&t<e.childNodes.length;){let n=e.childNodes[t];if(3==n.nodeType)return n;if(1==n.nodeType&&"false"==n.contentEditable)break;e=n,t=0}}(t,n))?(t=r,n=0):(e=function(e,t){for(;e&&!t&&!Vt(e);)t=Et(e),e=e.parentNode;for(;e&&t;){let n=e.childNodes[t-1];if(3==n.nodeType)return n;if(1==n.nodeType&&"false"==n.contentEditable)break;t=(e=n).childNodes.length}}(t,n))&&(t=e,n=e.nodeValue.length)}let r=e.domSelection();if(!r)return;if(Ft(r)){let e=document.createRange();e.setEnd(t,n),e.setStart(t,n),r.removeAllRanges(),r.addRange(e)}else r.extend&&r.extend(t,n);e.domObserver.setCurSelection();let{state:o}=e;setTimeout(()=>{e.state==o&&Zn(e)},50)}function yr(e,t){let n=e.state.doc.resolve(t);if(!Qt&&!nn&&n.parent.inlineContent){let r=e.coordsAtPos(t);if(t>n.start()){let n=e.coordsAtPos(t-1),o=(n.top+n.bottom)/2;if(o>r.top&&o<r.bottom&&Math.abs(n.left-r.left)>1)return n.left<r.left?"ltr":"rtl"}if(t<n.end()){let n=e.coordsAtPos(t+1),o=(n.top+n.bottom)/2;if(o>r.top&&o<r.bottom&&Math.abs(n.left-r.left)>1)return n.left>r.left?"ltr":"rtl"}}return"rtl"==getComputedStyle(e.dom).direction?"rtl":"ltr"}function wr(e,t,n){let r=e.state.selection;if(r instanceof ht&&!r.empty||n.indexOf("s")>-1)return!1;if(tn&&n.indexOf("m")>-1)return!1;let{$from:o,$to:i}=r;if(!o.parent.inlineContent||e.endOfTextblock(t<0?"up":"down")){let n=cr(e.state,t);if(n&&n instanceof pt)return hr(e,n)}if(!o.parent.inlineContent){let n=t<0?o:i,s=r instanceof ft?st.near(n,t):st.findFrom(n,t);return!!s&&hr(e,s)}return!1}function vr(e,t){if(!(e.state.selection instanceof ht))return!0;let{$head:n,$anchor:r,empty:o}=e.state.selection;if(!n.sameParent(r))return!0;if(!o)return!1;if(e.endOfTextblock(t>0?"forward":"backward"))return!0;let i=!n.textOffset&&(t<0?n.nodeBefore:n.nodeAfter);if(i&&!i.isText){let r=e.state.tr;return t<0?r.delete(n.pos-i.nodeSize,n.pos):r.delete(n.pos,n.pos+i.nodeSize),e.dispatch(r),!0}return!1}function br(e,t,n){e.domObserver.stop(),t.contentEditable=n,e.domObserver.start()}function kr(e,t){let n=t.keyCode,r=function(e){let t="";return e.ctrlKey&&(t+="c"),e.metaKey&&(t+="m"),e.altKey&&(t+="a"),e.shiftKey&&(t+="s"),t}(t);if(8==n||tn&&72==n&&"c"==r)return vr(e,-1)||fr(e,-1);if(46==n&&!t.shiftKey||tn&&68==n&&"c"==r)return vr(e,1)||fr(e,1);if(13==n||27==n)return!0;if(37==n||tn&&66==n&&"c"==r){let t=37==n?"ltr"==yr(e,e.state.selection.from)?-1:1:-1;return dr(e,t,r)||fr(e,t)}if(39==n||tn&&70==n&&"c"==r){let t=39==n?"ltr"==yr(e,e.state.selection.from)?1:-1:1;return dr(e,t,r)||fr(e,t)}return 38==n||tn&&80==n&&"c"==r?wr(e,-1,r)||fr(e,-1):40==n||tn&&78==n&&"c"==r?function(e){if(!Zt||e.state.selection.$head.parentOffset>0)return!1;let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(t&&1==t.nodeType&&0==n&&t.firstChild&&"false"==t.firstChild.contentEditable){let n=t.firstChild;br(e,n,"true"),setTimeout(()=>br(e,n,"false"),20)}return!1}(e)||wr(e,1,r)||fr(e,1):r==(tn?"m":"c")&&(66==n||73==n||89==n||90==n)}function xr(e,t){e.someProp("transformCopied",n=>{t=n(t,e)});let n=[],{content:r,openStart:o,openEnd:i}=t;for(;o>1&&i>1&&1==r.childCount&&1==r.firstChild.childCount;){o--,i--;let e=r.firstChild;n.push(e.type.name,e.attrs!=e.type.defaultAttrs?e.attrs:null),r=e.content}let s=e.someProp("clipboardSerializer")||se.fromSchema(e.state.schema),l=Ar(),a=l.createElement("div");a.appendChild(s.serializeFragment(r,{document:l}));let c,h=a.firstChild,d=0;for(;h&&1==h.nodeType&&(c=Er[h.nodeName.toLowerCase()]);){for(let e=c.length-1;e>=0;e--){let t=l.createElement(c[e]);for(;a.firstChild;)t.appendChild(a.firstChild);a.appendChild(t),d++}h=a.firstChild}return h&&1==h.nodeType&&h.setAttribute("data-pm-slice",`${o} ${i}${d?` -${d}`:""} ${JSON.stringify(n)}`),{dom:a,text:e.someProp("clipboardTextSerializer",n=>n(t,e))||t.content.textBetween(0,t.content.size,"\n\n"),slice:t}}function Sr(e,t,n,r,o){let s,l,a=o.parent.type.spec.code;if(!n&&!t)return null;let c=!!t&&(r||a||!n);if(c){if(e.someProp("transformPastedText",n=>{t=n(t,a||r,e)}),a)return l=new d(i.from(e.state.schema.text(t.replace(/\r\n?/g,"\n"))),0,0),e.someProp("transformPasted",t=>{l=t(l,e,!0)}),l;let n=e.someProp("clipboardTextParser",n=>n(t,o,r,e));if(n)l=n;else{let n=o.marks(),{schema:r}=e.state,i=se.fromSchema(r);s=document.createElement("div"),t.split(/(?:\r\n?|\n)+/).forEach(e=>{let t=s.appendChild(document.createElement("p"));e&&t.appendChild(i.serializeNode(r.text(e,n)))})}}else e.someProp("transformPastedHTML",t=>{n=t(n,e)}),s=function(e){let t=/^(\s*<meta [^>]*>)*/.exec(e);t&&(e=e.slice(t[0].length));let n,r=Ar(),o=r.body,i=/<([a-z][^>\s]+)/i.exec(e);(n=i&&Er[i[1].toLowerCase()])&&(e=n.map(e=>"<"+e+">").join("")+e+n.map(e=>"</"+e+">").reverse().join(""));if(o.innerHTML=function(e){let t=window.trustedTypes;if(!t)return e;Ir||(Ir=t.defaultPolicy||t.createPolicy("ProseMirrorClipboard",{createHTML:e=>e}));return Ir.createHTML(e)}(e),n)for(let e=0;e<n.length;e++)o=o.querySelector(n[e])||o;for(let e=0;e<r.styleSheets.length;e++){let t=r.styleSheets[e];for(let e=0;e<t.rules.length;e++){let n=t.rules[e];if(n instanceof CSSStyleRule){let e=o.querySelectorAll(n.selectorText);for(let t=0;t<e.length;t++)e[t].style.cssText+=n.style.cssText}}}return o}(n),on&&function(e){let t=e.querySelectorAll(Qt?"span:not([class]):not([style])":"span.Apple-converted-space");for(let n=0;n<t.length;n++){let r=t[n];1==r.childNodes.length&&" "==r.textContent&&r.parentNode&&r.parentNode.replaceChild(e.ownerDocument.createTextNode(" "),r)}}(s);let h=s&&s.querySelector("[data-pm-slice]"),p=h&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(h.getAttribute("data-pm-slice")||"");if(p&&p[3])for(let e=+p[3];e>0;e--){let e=s.firstChild;for(;e&&1!=e.nodeType;)e=e.nextSibling;if(!e)break;s=e}if(!l){let t=e.someProp("clipboardParser")||e.someProp("domParser")||Y.fromSchema(e.state.schema);l=t.parseSlice(s,{preserveWhitespace:!(!c&&!p),context:o,ruleFromNode:e=>"BR"!=e.nodeName||e.nextSibling||!e.parentNode||Cr.test(e.parentNode.nodeName)?null:{ignore:!0}})}if(p)l=function(e,t){if(!e.size)return e;let n,r=e.content.firstChild.type.schema;try{n=JSON.parse(t)}catch(t){return e}let{content:o,openStart:s,openEnd:l}=e;for(let e=n.length-2;e>=0;e-=2){let t=r.nodes[n[e]];if(!t||t.hasRequiredAttrs())break;o=i.from(t.create(n[e+1],o)),s++,l++}return new d(o,s,l)}(Tr(l,+p[1],+p[2]),p[4]);else if(l=d.maxOpen(function(e,t){if(e.childCount<2)return e;for(let n=t.depth;n>=0;n--){let r,o=t.node(n).contentMatchAt(t.index(n)),s=[];if(e.forEach(e=>{if(!s)return;let t,n=o.findWrapping(e.type);if(!n)return s=null;if(t=s.length&&r.length&&Or(n,r,e,s[s.length-1],0))s[s.length-1]=t;else{s.length&&(s[s.length-1]=Nr(s[s.length-1],r.length));let t=Mr(e,n);s.push(t),o=o.matchType(t.type),r=n}}),s)return i.from(s)}return e}(l.content,o),!0),l.openStart||l.openEnd){let e=0,t=0;for(let t=l.content.firstChild;e<l.openStart&&!t.type.spec.isolating;e++,t=t.firstChild);for(let e=l.content.lastChild;t<l.openEnd&&!e.type.spec.isolating;t++,e=e.lastChild);l=Tr(l,e,t)}return e.someProp("transformPasted",t=>{l=t(l,e,c)}),l}const Cr=/^(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 Mr(e,t,n=0){for(let r=t.length-1;r>=n;r--)e=t[r].create(null,i.from(e));return e}function Or(e,t,n,r,o){if(o<e.length&&o<t.length&&e[o]==t[o]){let s=Or(e,t,n,r.lastChild,o+1);if(s)return r.copy(r.content.replaceChild(r.childCount-1,s));if(r.contentMatchAt(r.childCount).matchType(o==e.length-1?n.type:e[o+1]))return r.copy(r.content.append(i.from(Mr(n,e,o+1))))}}function Nr(e,t){if(0==t)return e;let n=e.content.replaceChild(e.childCount-1,Nr(e.lastChild,t-1)),r=e.contentMatchAt(e.childCount).fillBefore(i.empty,!0);return e.copy(n.append(r))}function Dr(e,t,n,r,o,s){let l=t<0?e.firstChild:e.lastChild,a=l.content;return e.childCount>1&&(s=0),o<r-1&&(a=Dr(a,t,n,r,o+1,s)),o>=n&&(a=t<0?l.contentMatchAt(0).fillBefore(a,s<=o).append(a):a.append(l.contentMatchAt(l.childCount).fillBefore(i.empty,!0))),e.replaceChild(t<0?0:e.childCount-1,l.copy(a))}function Tr(e,t,n){return t<e.openStart&&(e=new d(Dr(e.content,-1,t,e.openStart,0,e.openEnd),t,e.openEnd)),n<e.openEnd&&(e=new d(Dr(e.content,1,n,e.openEnd,0,0),e.openStart,n)),e}const Er={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};function Ar(){return document.implementation.createHTMLDocument("title")}let Ir=null;const Rr={},zr={},Pr={touchstart:!0,touchmove:!0};class Br{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:"",button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.badSafariComposition=!1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function $r(e,t){e.input.lastSelectionOrigin=t,e.input.lastSelectionTime=Date.now()}function Vr(e){e.someProp("handleDOMEvents",t=>{for(let n in t)e.input.eventHandlers[n]||e.dom.addEventListener(n,e.input.eventHandlers[n]=t=>Fr(e,t))})}function Fr(e,t){return e.someProp("handleDOMEvents",n=>{let r=n[t.type];return!!r&&(r(e,t)||t.defaultPrevented)})}function qr(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let n=t.target;n!=e.dom;n=n.parentNode)if(!n||11==n.nodeType||n.pmViewDesc&&n.pmViewDesc.stopEvent(t))return!1;return!0}function Lr(e){return{left:e.clientX,top:e.clientY}}function _r(e,t,n,r,o){if(-1==r)return!1;let i=e.state.doc.resolve(r);for(let r=i.depth+1;r>0;r--)if(e.someProp(t,t=>r>i.depth?t(e,n,i.nodeAfter,i.before(r),o,!0):t(e,n,i.node(r),i.before(r),o,!1)))return!0;return!1}function Wr(e,t,n){if(e.focused||e.focus(),e.state.selection.eq(t))return;let r=e.state.tr.setSelection(t);"pointer"==n&&r.setMeta("pointer",!0),e.dispatch(r)}function Jr(e,t,n,r,o){return _r(e,"handleClickOn",t,n,r)||e.someProp("handleClick",n=>n(e,t,r))||(o?function(e,t){if(-1==t)return!1;let n,r,o=e.state.selection;o instanceof pt&&(n=o.node);let i=e.state.doc.resolve(t);for(let e=i.depth+1;e>0;e--){let t=e>i.depth?i.nodeAfter:i.node(e);if(pt.isSelectable(t)){r=n&&o.$from.depth>0&&e>=o.$from.depth&&i.before(o.$from.depth+1)==o.$from.pos?i.before(o.$from.depth):i.before(e);break}}return null!=r&&(Wr(e,pt.create(e.state.doc,r),"pointer"),!0)}(e,n):function(e,t){if(-1==t)return!1;let n=e.state.doc.resolve(t),r=n.nodeAfter;return!!(r&&r.isAtom&&pt.isSelectable(r))&&(Wr(e,new pt(n),"pointer"),!0)}(e,n))}function jr(e,t,n,r){return _r(e,"handleDoubleClickOn",t,n,r)||e.someProp("handleDoubleClick",n=>n(e,t,r))}function Kr(e,t,n,r){return _r(e,"handleTripleClickOn",t,n,r)||e.someProp("handleTripleClick",n=>n(e,t,r))||function(e,t,n){if(0!=n.button)return!1;let r=Hr(e,t,!0),o=e.state.doc;if(!r)return!1;Wr(e,r,"pointer"),r instanceof ht&&o.eq(e.state.doc)&&(e.input.mouseDown=new Xr(e,r));return!0}(e,n,r)}function Hr(e,t,n){let r=e.state.doc;if(-1==t)return r.inlineContent?ht.create(r,0,r.content.size):null;let o=r.resolve(t);for(let e=o.depth+1;e>0;e--){let t=e>o.depth?o.nodeAfter:o.node(e),i=o.before(e);if(t.inlineContent)return ht.create(r,i+1,i+1+t.content.size);if(n&&pt.isSelectable(t))return pt.create(r,i)}return null}function Ur(e){return oo(e)}zr.keydown=(e,t)=>{let n=t;if(e.input.shiftKey=16==n.keyCode||n.shiftKey,!Zr(e)&&(e.input.lastKeyCode=n.keyCode,e.input.lastKeyCodeTime=Date.now(),!rn||!Qt||13!=n.keyCode))if(229!=n.keyCode&&e.domObserver.forceFlush(),!en||13!=n.keyCode||n.ctrlKey||n.altKey||n.metaKey)e.someProp("handleKeyDown",t=>t(e,n))||kr(e,n)?n.preventDefault():$r(e,"key");else{let t=Date.now();e.input.lastIOSEnter=t,e.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{e.input.lastIOSEnter==t&&(e.someProp("handleKeyDown",t=>t(e,qt(13,"Enter"))),e.input.lastIOSEnter=0)},200)}},zr.keyup=(e,t)=>{16==t.keyCode&&(e.input.shiftKey=!1)},zr.keypress=(e,t)=>{let n=t;if(Zr(e)||!n.charCode||n.ctrlKey&&!n.altKey||tn&&n.metaKey)return;if(e.someProp("handleKeyPress",t=>t(e,n)))return void n.preventDefault();let r=e.state.selection;if(!(r instanceof ht&&r.$from.sameParent(r.$to))){let t=String.fromCharCode(n.charCode),o=()=>e.state.tr.insertText(t).scrollIntoView();/[\r\n]/.test(t)||e.someProp("handleTextInput",n=>n(e,r.$from.pos,r.$to.pos,t,o))||e.dispatch(o()),n.preventDefault()}};const Gr=tn?"metaKey":"ctrlKey";Rr.mousedown=(e,t)=>{let n=t;e.input.shiftKey=n.shiftKey;let r=Ur(e),o=Date.now(),i="singleClick";o-e.input.lastClick.time<500&&function(e,t){let n=t.x-e.clientX,r=t.y-e.clientY;return n*n+r*r<100}(n,e.input.lastClick)&&!n[Gr]&&e.input.lastClick.button==n.button&&("singleClick"==e.input.lastClick.type?i="doubleClick":"doubleClick"==e.input.lastClick.type&&(i="tripleClick")),e.input.lastClick={time:o,x:n.clientX,y:n.clientY,type:i,button:n.button},e.input.mouseDown&&e.input.mouseDown.done();let s=e.posAtCoords(Lr(n));s&&("singleClick"==i?e.input.mouseDown=new Qr(e,s,n,!!r):("doubleClick"==i?jr:Kr)(e,s.pos,s.inside,n)?n.preventDefault():$r(e,"pointer"))};class Yr{constructor(e){this.view=e,this.mightDrag=null,e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this))}up(e){this.done()}move(e){0==e.buttons&&this.done()}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.view.input.mouseDown==this&&(this.view.input.mouseDown=null)}delaySelUpdate(){return!1}}class Qr extends Yr{constructor(e,t,n,r){let o,i;if(super(e),this.pos=t,this.event=n,this.flushed=r,this.delayedSelectionSync=!1,this.startDoc=e.state.doc,this.selectNode=!!n[Gr],this.allowDefault=n.shiftKey,t.inside>-1)o=e.state.doc.nodeAt(t.inside),i=t.inside;else{let n=e.state.doc.resolve(t.pos);o=n.parent,i=n.depth?n.before():0}const s=r?null:n.target,l=s?e.docView.nearestDesc(s,!0):null;this.target=l&&1==l.nodeDOM.nodeType?l.nodeDOM:null;let{selection:a}=e.state;0==n.button&&(o.type.spec.draggable&&!1!==o.type.spec.selectable||a instanceof pt&&a.from<=i&&a.to>i)&&(this.mightDrag={node:o,pos:i,addAttr:!(!this.target||this.target.draggable),setUneditable:!(!this.target||!Gt||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()),$r(e,"pointer")}done(){super.done(),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(()=>{this.view.isDestroyed||Zn(this.view)})}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(Lr(e))),this.updateAllowDefault(e),this.allowDefault||!t?$r(this.view,"pointer"):Jr(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():0==e.button&&(this.flushed||Zt&&this.mightDrag&&!this.mightDrag.node.isAtom||Qt&&!this.view.state.selection.visible&&Math.min(Math.abs(t.pos-this.view.state.selection.from),Math.abs(t.pos-this.view.state.selection.to))<=2)?(Wr(this.view,st.near(this.view.state.doc.resolve(t.pos)),"pointer"),e.preventDefault()):$r(this.view,"pointer")}move(e){this.updateAllowDefault(e),$r(this.view,"pointer"),super.move(e)}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}delaySelUpdate(){return!!this.allowDefault&&(this.delayedSelectionSync=!0,!0)}}class Xr extends Yr{constructor(e,t){super(e),this.startSelection=t,this.startDoc=e.state.doc}move(e){if(0==e.buttons||this.view.isDestroyed||!this.view.state.doc.eq(this.startDoc))return void this.done();e.preventDefault(),$r(this.view,"pointer");let t=this.view.posAtCoords(Lr(e)),n=t&&Hr(this.view,t.inside,!1);if(!n)return;let{doc:r}=this.view.state,o=this.startSelection,[i,s]=n.from<o.from?[o.to,n.from]:[o.from,n.to];Wr(this.view,ht.create(r,i,s),"pointer")}}function Zr(e,t){return!!e.composing||!!(Zt&&Math.abs(Date.now()-e.input.compositionEndedAt)<500)&&(e.input.compositionEndedAt=-2e8,!0)}Rr.touchstart=e=>{e.input.lastTouch=Date.now(),Ur(e),$r(e,"pointer")},Rr.touchmove=e=>{e.input.lastTouch=Date.now(),$r(e,"pointer")},Rr.contextmenu=e=>Ur(e);const eo=rn?5e3:-1;function to(e,t){clearTimeout(e.input.composingTimeout),t>-1&&(e.input.composingTimeout=setTimeout(()=>oo(e),t))}function no(e){for(e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=Date.now());e.input.compositionNodes.length>0;)e.input.compositionNodes.pop().markParentsDirty()}function ro(e){let t=e.domSelectionRange();if(!t.focusNode)return null;let n=function(e,t){for(;;){if(3==e.nodeType&&t)return e;if(1==e.nodeType&&t>0){if("false"==e.contentEditable)return null;t=$t(e=e.childNodes[t-1])}else{if(!e.parentNode||Vt(e))return null;t=Et(e),e=e.parentNode}}}(t.focusNode,t.focusOffset),r=function(e,t){for(;;){if(3==e.nodeType&&t<e.nodeValue.length)return e;if(1==e.nodeType&&t<e.childNodes.length){if("false"==e.contentEditable)return null;e=e.childNodes[t],t=0}else{if(!e.parentNode||Vt(e))return null;t=Et(e)+1,e=e.parentNode}}}(t.focusNode,t.focusOffset);if(n&&r&&n!=r){let t=r.pmViewDesc,o=e.domObserver.lastChangedTextNode;if(n==o||r==o)return o;if(!t||!t.isText(r.nodeValue))return r;if(e.input.compositionNode==r){let e=n.pmViewDesc;if(e&&e.isText(n.nodeValue))return r}}return n||r}function oo(e,t=!1){if(!(rn&&e.domObserver.flushingSoon>=0)){if(e.domObserver.forceFlush(),no(e),t||e.docView&&e.docView.dirty){let n=Qn(e),r=e.state.selection;return n&&!n.eq(r)?e.dispatch(e.state.tr.setSelection(n)):!e.markCursor&&!t||r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?e.updateState(e.state):e.dispatch(e.state.tr.deleteSelection()),!0}return!1}}zr.compositionstart=zr.compositionupdate=e=>{if(!e.composing){e.domObserver.flush();let{state:t}=e,n=t.selection.$to;if(t.selection instanceof ht&&(t.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(e=>!1===e.type.spec.inclusive)||Qt&&nn&&function(e){let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(!t||1!=t.nodeType||n>=t.childNodes.length)return!1;let r=t.childNodes[n];return 1==r.nodeType&&"false"==r.contentEditable}(e)))e.markCursor=e.state.storedMarks||n.marks(),oo(e,!0),e.markCursor=null;else if(oo(e,!t.selection.empty),Gt&&t.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let t=e.domSelectionRange();for(let n=t.focusNode,r=t.focusOffset;n&&1==n.nodeType&&0!=r;){let t=r<0?n.lastChild:n.childNodes[r-1];if(!t)break;if(3==t.nodeType){let n=e.domSelection();n&&n.collapse(t,t.nodeValue.length);break}n=t,r=-1}}e.input.composing=!0}to(e,eo)},zr.compositionend=(e,t)=>{e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=Date.now(),e.input.compositionPendingChanges=e.domObserver.pendingRecords().length?e.input.compositionID:0,e.input.compositionNode=null,e.input.badSafariComposition?e.domObserver.forceFlush():e.input.compositionPendingChanges&&Promise.resolve().then(()=>e.domObserver.flush()),e.input.compositionID++,to(e,20))};const io=Ht&&Ut<15||en&&sn<604;function so(e,t,n,r,o){let i=Sr(e,t,n,r,e.state.selection.$from);if(e.someProp("handlePaste",t=>t(e,o,i||d.empty)))return!0;if(!i)return!1;let s=function(e){return 0==e.openStart&&0==e.openEnd&&1==e.content.childCount?e.content.firstChild:null}(i),l=s?e.state.tr.replaceSelectionWith(s,r):e.state.tr.replaceSelection(i);return e.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function lo(e){let t=e.getData("text/plain")||e.getData("Text");if(t)return t;let n=e.getData("text/uri-list");return n?n.replace(/\r?\n/g," "):""}Rr.copy=zr.cut=(e,t)=>{let n=t,r=e.state.selection,o="cut"==n.type;if(r.empty)return;let i=io?null:n.clipboardData,s=r.content(),{dom:l,text:a}=xr(e,s);i?(n.preventDefault(),i.clearData(),i.setData("text/html",l.innerHTML),i.setData("text/plain",a)):function(e,t){if(!e.dom.parentNode)return;let n=e.dom.parentNode.appendChild(document.createElement("div"));n.appendChild(t),n.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),o=document.createRange();o.selectNodeContents(t),e.dom.blur(),r.removeAllRanges(),r.addRange(o),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),e.focus()},50)}(e,l),o&&e.dispatch(e.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))},zr.paste=(e,t)=>{let n=t;if(e.composing&&!rn)return;let r=io?null:n.clipboardData,o=e.input.shiftKey&&45!=e.input.lastKeyCode;r&&so(e,lo(r),r.getData("text/html"),o,n)?n.preventDefault():function(e,t){if(!e.dom.parentNode)return;let n=e.input.shiftKey||e.state.selection.$from.parent.type.spec.code,r=e.dom.parentNode.appendChild(document.createElement(n?"textarea":"div"));n||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let o=e.input.shiftKey&&45!=e.input.lastKeyCode;setTimeout(()=>{e.focus(),r.parentNode&&r.parentNode.removeChild(r),n?so(e,r.value,null,o,t):so(e,r.textContent,r.innerHTML,o,t)},50)}(e,n)};class ao{constructor(e,t,n){this.slice=e,this.move=t,this.node=n}}const co=tn?"altKey":"ctrlKey";function ho(e,t){let n;return e.someProp("dragCopies",e=>{n=n||e(t)}),null!=n?!n:!t[co]}Rr.dragstart=(e,t)=>{let n=t,r=e.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let o,i=e.state.selection,s=i.empty?null:e.posAtCoords(Lr(n));if(s&&s.pos>=i.from&&s.pos<=(i instanceof pt?i.to-1:i.to));else if(r&&r.mightDrag)o=pt.create(e.state.doc,r.mightDrag.pos);else if(n.target&&1==n.target.nodeType){let t=e.docView.nearestDesc(n.target,!0);t&&t.node.type.spec.draggable&&t!=e.docView&&(o=pt.create(e.state.doc,t.posBefore))}let l=(o||e.state.selection).content(),{dom:a,text:c,slice:h}=xr(e,l);(!n.dataTransfer.files.length||!Qt||Xt>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(io?"Text":"text/html",a.innerHTML),n.dataTransfer.effectAllowed="copyMove",io||n.dataTransfer.setData("text/plain",c),e.dragging=new ao(h,ho(e,n),o)},Rr.dragend=e=>{let t=e.dragging;window.setTimeout(()=>{e.dragging==t&&(e.dragging=null)},50)},zr.dragover=zr.dragenter=(e,t)=>t.preventDefault(),zr.drop=(e,t)=>{try{!function(e,t,n){if(!t.dataTransfer)return;let r=e.posAtCoords(Lr(t));if(!r)return;let o=e.state.doc.resolve(r.pos),i=n&&n.slice;i?e.someProp("transformPasted",t=>{i=t(i,e,!1)}):i=Sr(e,lo(t.dataTransfer),io?null:t.dataTransfer.getData("text/html"),!1,o);let s=!(!n||!ho(e,t));if(e.someProp("handleDrop",n=>n(e,t,i||d.empty,s)))return void t.preventDefault();if(!i)return;t.preventDefault();let l=i?_e(e.state.doc,o.pos,i):o.pos;null==l&&(l=o.pos);let a=e.state.tr;if(s){let{node:e}=n;e?e.replace(a):a.deleteSelection()}let c=a.mapping.map(l),h=0==i.openStart&&0==i.openEnd&&1==i.content.childCount,p=a.doc;h?a.replaceRangeWith(c,c,i.content.firstChild):a.replaceRange(c,c,i);if(a.doc.eq(p))return;let u=a.doc.resolve(c);if(h&&pt.isSelectable(i.content.firstChild)&&u.nodeAfter&&u.nodeAfter.sameMarkup(i.content.firstChild))a.setSelection(new pt(u));else{let t=a.mapping.map(l);a.mapping.maps[a.mapping.maps.length-1].forEach((e,n,r,o)=>t=o),a.setSelection(sr(e,u,a.doc.resolve(t)))}e.focus(),e.dispatch(a.setMeta("uiEvent","drop"))}(e,t,e.dragging)}finally{e.dragging=null}},Rr.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())&&Zn(e)},20))},Rr.blur=(e,t)=>{let n=t;e.focused&&(e.domObserver.stop(),e.dom.classList.remove("ProseMirror-focused"),e.domObserver.start(),n.relatedTarget&&e.dom.contains(n.relatedTarget)&&e.domObserver.currentSelection.clear(),e.focused=!1)},Rr.beforeinput=(e,t)=>{if(Qt&&rn&&"deleteContentBackward"==t.inputType){e.domObserver.flushSoon();let{domChangeCount:t}=e.input;setTimeout(()=>{if(e.input.domChangeCount!=t)return;if(e.dom.blur(),e.focus(),e.someProp("handleKeyDown",t=>t(e,qt(8,"Backspace"))))return;let{$cursor:n}=e.state.selection;n&&n.pos>0&&e.dispatch(e.state.tr.delete(n.pos-1,n.pos).scrollIntoView())},50)}};for(let e in zr)Rr[e]=zr[e];function po(e,t){if(e==t)return!0;for(let n in e)if(e[n]!==t[n])return!1;for(let n in t)if(!(n in e))return!1;return!0}class uo{constructor(e,t){this.toDOM=e,this.spec=t||wo,this.side=this.spec.side||0}map(e,t,n,r){let{pos:o,deleted:i}=e.mapResult(t.from+r,this.side<0?-1:1);return i?null:new go(o-n,o-n,this)}valid(){return!0}eq(e){return this==e||e instanceof uo&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&po(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class fo{constructor(e,t){this.attrs=e,this.spec=t||wo}map(e,t,n,r){let o=e.map(t.from+r,this.spec.inclusiveStart?-1:1)-n,i=e.map(t.to+r,this.spec.inclusiveEnd?1:-1)-n;return o>=i?null:new go(o,i,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof fo&&po(this.attrs,e.attrs)&&po(this.spec,e.spec)}static is(e){return e.type instanceof fo}destroy(){}}class mo{constructor(e,t){this.attrs=e,this.spec=t||wo}map(e,t,n,r){let o=e.mapResult(t.from+r,1);if(o.deleted)return null;let i=e.mapResult(t.to+r,-1);return i.deleted||i.pos<=o.pos?null:new go(o.pos-n,i.pos-n,this)}valid(e,t){let n,{index:r,offset:o}=e.content.findIndex(t.from);return o==t.from&&!(n=e.child(r)).isText&&o+n.nodeSize==t.to}eq(e){return this==e||e instanceof mo&&po(this.attrs,e.attrs)&&po(this.spec,e.spec)}destroy(){}}class go{constructor(e,t,n){this.from=e,this.to=t,this.type=n}copy(e,t){return new go(e,t,this.type)}eq(e,t=0){return this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to}map(e,t,n){return this.type.map(e,this,t,n)}static widget(e,t,n){return new go(e,e,new uo(t,n))}static inline(e,t,n,r){return new go(e,t,new fo(n,r))}static node(e,t,n,r){return new go(e,t,new mo(n,r))}get spec(){return this.type.spec}get inline(){return this.type instanceof fo}get widget(){return this.type instanceof uo}}const yo=[],wo={};class vo{constructor(e,t){this.local=e.length?e:yo,this.children=t.length?t:yo}static create(e,t){return t.length?Mo(t,e,0,wo):bo}find(e,t,n){let r=[];return this.findInner(null==e?0:e,null==t?1e9:t,r,0,n),r}findInner(e,t,n,r,o){for(let i=0;i<this.local.length;i++){let s=this.local[i];s.from<=t&&s.to>=e&&(!o||o(s.spec))&&n.push(s.copy(s.from+r,s.to+r))}for(let i=0;i<this.children.length;i+=3)if(this.children[i]<t&&this.children[i+1]>e){let s=this.children[i]+1;this.children[i+2].findInner(e-s,t-s,n,r+s,o)}}map(e,t,n){return this==bo||0==e.maps.length?this:this.mapInner(e,t,0,0,n||wo)}mapInner(e,t,n,r,o){let i;for(let s=0;s<this.local.length;s++){let l=this.local[s].map(e,n,r);l&&l.type.valid(t,l)?(i||(i=[])).push(l):o.onRemove&&o.onRemove(this.local[s].spec)}return this.children.length?function(e,t,n,r,o,i,s){let l=e.slice();for(let e=0,t=i;e<n.maps.length;e++){let r=0;n.maps[e].forEach((e,n,o,i)=>{let s=i-o-(n-e);for(let o=0;o<l.length;o+=3){let i=l[o+1];if(i<0||e>i+t-r)continue;let a=l[o]+t-r;n>=a?l[o+1]=e<=a?-2:-1:e>=t&&s&&(l[o]+=s,l[o+1]+=s)}r+=s}),t=n.maps[e].map(t,-1)}let a=!1;for(let t=0;t<l.length;t+=3)if(l[t+1]<0){if(-2==l[t+1]){a=!0,l[t+1]=-1;continue}let c=n.map(e[t]+i),h=c-o;if(h<0||h>=r.content.size){a=!0;continue}let d=n.map(e[t+1]+i,-1)-o,{index:p,offset:u}=r.content.findIndex(h),f=r.maybeChild(p);if(f&&u==h&&u+f.nodeSize==d){let r=l[t+2].mapInner(n,f,c+1,e[t]+i+1,s);r!=bo?(l[t]=h,l[t+1]=d,l[t+2]=r):(l[t+1]=-2,a=!0)}else a=!0}if(a){let a=function(e,t,n,r,o,i,s){function l(e,t){for(let i=0;i<e.local.length;i++){let l=e.local[i].map(r,o,t);l?n.push(l):s.onRemove&&s.onRemove(e.local[i].spec)}for(let n=0;n<e.children.length;n+=3)l(e.children[n+2],e.children[n]+t+1)}for(let n=0;n<e.length;n+=3)-1==e[n+1]&&l(e[n+2],t[n]+i+1);return n}(l,e,t,n,o,i,s),c=Mo(a,r,0,s);t=c.local;for(let e=0;e<l.length;e+=3)l[e+1]<0&&(l.splice(e,3),e-=3);for(let e=0,t=0;e<c.children.length;e+=3){let n=c.children[e];for(;t<l.length&&l[t]<n;)t+=3;l.splice(t,0,c.children[e],c.children[e+1],c.children[e+2])}}return new vo(t.sort(Oo),l)}(this.children,i||[],e,t,n,r,o):i?new vo(i.sort(Oo),yo):bo}add(e,t){return t.length?this==bo?vo.create(e,t):this.addInner(e,t,0):this}addInner(e,t,n){let r,o=0;e.forEach((e,i)=>{let s,l=i+n;if(s=So(t,e,l)){for(r||(r=this.children.slice());o<r.length&&r[o]<i;)o+=3;r[o]==i?r[o+2]=r[o+2].addInner(e,s,l+1):r.splice(o,0,i,i+e.nodeSize,Mo(s,e,l+1,wo)),o+=3}});let i=xo(o?Co(t):t,-n);for(let t=0;t<i.length;t++)i[t].type.valid(e,i[t])||i.splice(t--,1);return new vo(i.length?this.local.concat(i).sort(Oo):this.local,r||this.children)}remove(e){return 0==e.length||this==bo?this:this.removeInner(e,0)}removeInner(e,t){let n=this.children,r=this.local;for(let r=0;r<n.length;r+=3){let o,i=n[r]+t,s=n[r+1]+t;for(let t,n=0;n<e.length;n++)(t=e[n])&&t.from>i&&t.to<s&&(e[n]=null,(o||(o=[])).push(t));if(!o)continue;n==this.children&&(n=this.children.slice());let l=n[r+2].removeInner(o,i+1);l!=bo?n[r+2]=l:(n.splice(r,3),r-=3)}if(r.length)for(let n,o=0;o<e.length;o++)if(n=e[o])for(let e=0;e<r.length;e++)r[e].eq(n,t)&&(r==this.local&&(r=this.local.slice()),r.splice(e--,1));return n==this.children&&r==this.local?this:r.length||n.length?new vo(r,n):bo}forChild(e,t){if(this==bo)return this;if(t.isLeaf)return vo.empty;let n,r;for(let t=0;t<this.children.length;t+=3)if(this.children[t]>=e){this.children[t]==e&&(n=this.children[t+2]);break}let o=e+1,i=o+t.content.size;for(let e=0;e<this.local.length;e++){let t=this.local[e];if(t.from<i&&t.to>o&&t.type instanceof fo){let e=Math.max(o,t.from)-o,n=Math.min(i,t.to)-o;e<n&&(r||(r=[])).push(t.copy(e,n))}}if(r){let e=new vo(r.sort(Oo),yo);return n?new ko([e,n]):e}return n||bo}eq(e){if(this==e)return!0;if(!(e instanceof vo)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let t=0;t<this.local.length;t++)if(!this.local[t].eq(e.local[t]))return!1;for(let t=0;t<this.children.length;t+=3)if(this.children[t]!=e.children[t]||this.children[t+1]!=e.children[t+1]||!this.children[t+2].eq(e.children[t+2]))return!1;return!0}locals(e){return No(this.localsInner(e))}localsInner(e){if(this==bo)return yo;if(e.inlineContent||!this.local.some(fo.is))return this.local;let t=[];for(let e=0;e<this.local.length;e++)this.local[e].type instanceof fo||t.push(this.local[e]);return t}forEachSet(e){e(this)}}vo.empty=new vo([],[]),vo.removeOverlap=No;const bo=vo.empty;class ko{constructor(e){this.members=e}map(e,t){const n=this.members.map(n=>n.map(e,t,wo));return ko.from(n)}forChild(e,t){if(t.isLeaf)return vo.empty;let n=[];for(let r=0;r<this.members.length;r++){let o=this.members[r].forChild(e,t);o!=bo&&(o instanceof ko?n=n.concat(o.members):n.push(o))}return ko.from(n)}eq(e){if(!(e instanceof ko)||e.members.length!=this.members.length)return!1;for(let t=0;t<this.members.length;t++)if(!this.members[t].eq(e.members[t]))return!1;return!0}locals(e){let t,n=!0;for(let r=0;r<this.members.length;r++){let o=this.members[r].localsInner(e);if(o.length)if(t){n&&(t=t.slice(),n=!1);for(let e=0;e<o.length;e++)t.push(o[e])}else t=o}return t?No(n?t:t.sort(Oo)):yo}static from(e){switch(e.length){case 0:return bo;case 1:return e[0];default:return new ko(e.every(e=>e instanceof vo)?e:e.reduce((e,t)=>e.concat(t instanceof vo?t:t.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}}function xo(e,t){if(!t||!e.length)return e;let n=[];for(let r=0;r<e.length;r++){let o=e[r];n.push(new go(o.from+t,o.to+t,o.type))}return n}function So(e,t,n){if(t.isLeaf)return null;let r=n+t.nodeSize,o=null;for(let t,i=0;i<e.length;i++)(t=e[i])&&t.from>n&&t.to<r&&((o||(o=[])).push(t),e[i]=null);return o}function Co(e){let t=[];for(let n=0;n<e.length;n++)null!=e[n]&&t.push(e[n]);return t}function Mo(e,t,n,r){let o=[],i=!1;t.forEach((t,s)=>{let l=So(e,t,s+n);if(l){i=!0;let e=Mo(l,t,n+s+1,r);e!=bo&&o.push(s,s+t.nodeSize,e)}});let s=xo(i?Co(e):e,-n).sort(Oo);for(let e=0;e<s.length;e++)s[e].type.valid(t,s[e])||(r.onRemove&&r.onRemove(s[e].spec),s.splice(e--,1));return s.length||o.length?new vo(s,o):bo}function Oo(e,t){return e.from-t.from||e.to-t.to}function No(e){let t=e;for(let n=0;n<t.length-1;n++){let r=t[n];if(r.from!=r.to)for(let o=n+1;o<t.length;o++){let i=t[o];if(i.from!=r.from){i.from<r.to&&(t==e&&(t=e.slice()),t[n]=r.copy(r.from,i.from),Do(t,o,r.copy(i.from,r.to)));break}i.to!=r.to&&(t==e&&(t=e.slice()),t[o]=i.copy(i.from,r.to),Do(t,o+1,i.copy(r.to,i.to)))}}return t}function Do(e,t,n){for(;t<e.length&&Oo(n,e[t])>0;)t++;e.splice(t,0,n)}function To(e){let t=[];return e.someProp("decorations",n=>{let r=n(e.state);r&&r!=bo&&t.push(r)}),e.cursorWrapper&&t.push(vo.create(e.state.doc,[e.cursorWrapper.deco])),ko.from(t)}const Eo={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},Ao=Ht&&Ut<=11;class Io{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}}class Ro{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new Io,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(t=>{for(let e=0;e<t.length;e++)this.queue.push(t[e]);Ht&&Ut<=11&&t.some(e=>"childList"==e.type&&e.removedNodes.length||"characterData"==e.type&&e.oldValue.length>e.target.nodeValue.length)?this.flushSoon():Zt&&e.composing&&t.some(e=>"childList"==e.type&&"TR"==e.target.nodeName)?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),Ao&&(this.onCharData=e=>{this.queue.push({target:e.target,type:"characterData",oldValue:e.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,Eo)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let t=0;t<e.length;t++)this.queue.push(e[t]);window.setTimeout(()=>this.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(lr(this.view)){if(this.suppressingSelectionUpdates)return Zn(this.view);if(Ht&&Ut<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&zt(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t,n=new Set;for(let t=e.focusNode;t;t=At(t))n.add(t);for(let r=e.anchorNode;r;r=At(r))if(n.has(r)){t=r;break}let r=t&&this.view.docView.nearestDesc(t);return r&&r.ignoreMutation({type:"selection",target:3==t.nodeType?t.parentNode:t})?(this.setCurSelection(),!0):void 0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.pendingRecords();t.length&&(this.queue=[]);let n=e.domSelectionRange(),r=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(n)&&lr(e)&&!this.ignoreSelectionChange(n),o=-1,i=-1,s=!1,l=[];if(e.editable)for(let e=0;e<t.length;e++){let n=this.registerMutation(t[e],l);n&&(o=o<0?n.from:Math.min(n.from,o),i=i<0?n.to:Math.max(n.to,i),n.typeOver&&(s=!0))}if(l.some(e=>"BR"==e.nodeName)&&(8==e.input.lastKeyCode||46==e.input.lastKeyCode||Qt&&(e.composing||e.input.compositionEndedAt>Date.now()-50)&&t.some(e=>"childList"==e.type&&e.removedNodes.length))){for(let e of l)if("BR"==e.nodeName&&e.parentNode){let t=e.nextSibling;for(;t&&1==t.nodeType;){if("false"==t.contentEditable){e.parentNode.removeChild(e);break}t=t.firstChild}}}else if(Gt&&l.length){let t=l.filter(e=>"BR"==e.nodeName);if(2==t.length){let[e,n]=t;e.parentNode&&e.parentNode.parentNode==n.parentNode?n.remove():e.remove()}else{let{focusNode:n}=this.currentSelection;for(let r of t){let t=r.parentNode;!t||"LI"!=t.nodeName||n&&$o(e,n)==t||r.remove()}}}let a=null;o<0&&r&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&Ft(n)&&(a=Qn(e))&&a.eq(st.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,Zn(e),this.currentSelection.set(n),e.scrollToSelection()):(o>-1||r)&&(o>-1&&(e.docView.markDirty(o,i),function(e){if(zo.has(e))return;if(zo.set(e,null),-1!==["normal","nowrap","pre-line"].indexOf(getComputedStyle(e.dom).whiteSpace)){if(e.requiresGeckoHackNode=Gt,Po)return;console.warn("ProseMirror expects the CSS white-space property to be set, preferably to 'pre-wrap'. It is recommended to load style/prosemirror.css from the prosemirror-view package."),Po=!0}}(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,function(e,t){var n;let{focusNode:r,focusOffset:o}=e.domSelectionRange();for(let i of t)if("TR"==(null===(n=i.parentNode)||void 0===n?void 0:n.nodeName)){let t=i.nextSibling;for(;t&&"TD"!=t.nodeName&&"TH"!=t.nodeName;)t=t.nextSibling;if(t){let n=t;for(;;){let e=n.firstChild;if(!e||1!=e.nodeType||"false"==e.contentEditable||/^(BR|IMG)$/.test(e.nodeName))break;n=e}n.insertBefore(i,n.firstChild),r==i&&e.domSelection().collapse(i,o)}else i.parentNode.removeChild(i)}}(e,l)),this.handleDOMChange(o,i,s,l),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(n)||Zn(e),this.currentSelection.set(n))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let n=this.view.docView.nearestDesc(e.target);if("attributes"==e.type&&(n==this.view.docView||"contenteditable"==e.attributeName||"style"==e.attributeName&&!e.oldValue&&!e.target.getAttribute("style")))return null;if(!n||n.ignoreMutation(e))return null;if("childList"==e.type){for(let n=0;n<e.addedNodes.length;n++){let r=e.addedNodes[n];t.push(r),3==r.nodeType&&(this.lastChangedTextNode=r)}if(n.contentDOM&&n.contentDOM!=n.dom&&!n.contentDOM.contains(e.target))return{from:n.posBefore,to:n.posAfter};let r=e.previousSibling,o=e.nextSibling;if(Ht&&Ut<=11&&e.addedNodes.length)for(let t=0;t<e.addedNodes.length;t++){let{previousSibling:n,nextSibling:i}=e.addedNodes[t];(!n||Array.prototype.indexOf.call(e.addedNodes,n)<0)&&(r=n),(!i||Array.prototype.indexOf.call(e.addedNodes,i)<0)&&(o=i)}let i=r&&r.parentNode==e.target?Et(r)+1:0,s=n.localPosFromDOM(e.target,i,-1),l=o&&o.parentNode==e.target?Et(o):e.target.childNodes.length;return{from:s,to:n.localPosFromDOM(e.target,l,1)}}return"attributes"==e.type?{from:n.posAtStart-n.border,to:n.posAtEnd+n.border}:(this.lastChangedTextNode=e.target,{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let zo=new WeakMap,Po=!1;function Bo(e,t){let n=t.startContainer,r=t.startOffset,o=t.endContainer,i=t.endOffset,s=e.domAtPos(e.state.selection.anchor);return zt(s.node,s.offset,o,i)&&([n,r,o,i]=[o,i,n,r]),{anchorNode:n,anchorOffset:r,focusNode:o,focusOffset:i}}function $o(e,t){for(let n=t.parentNode;n&&n!=e.dom;n=n.parentNode){let t=e.docView.nearestDesc(n,!0);if(t&&t.node.isBlock)return n}return null}function Vo(e){let t=e.pmViewDesc;if(t)return t.parseRule();if("BR"==e.nodeName&&e.parentNode){if(Zt&&/^(ul|ol)$/i.test(e.parentNode.nodeName)){let e=document.createElement("div");return e.appendChild(document.createElement("li")),{skip:e}}if(e.parentNode.lastChild==e||Zt&&/^(tr|table)$/i.test(e.parentNode.nodeName))return{ignore:!0}}else if("IMG"==e.nodeName&&e.getAttribute("mark-placeholder"))return{ignore:!0};return null}const Fo=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function qo(e,t,n,r,o){let s=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,n=Qn(e,t);if(n&&!e.state.selection.eq(n)){if(Qt&&rn&&13===e.input.lastKeyCode&&Date.now()-100<e.input.lastKeyCodeTime&&e.someProp("handleKeyDown",t=>t(e,qt(13,"Enter"))))return;let r=e.state.tr.setSelection(n);"pointer"==t?r.setMeta("pointer",!0):"key"==t&&r.scrollIntoView(),s&&r.setMeta("composition",s),e.dispatch(r)}return}let l=e.state.doc.resolve(t),a=l.sharedDepth(n);t=l.before(a+1),n=e.state.doc.resolve(n).after(a+1);let c,h,d=e.state.selection,p=function(e,t,n){let r,{node:o,fromOffset:i,toOffset:s,from:l,to:a}=e.docView.parseRange(t,n),c=e.domSelectionRange(),h=c.anchorNode;if(h&&e.dom.contains(1==h.nodeType?h:h.parentNode)&&(r=[{node:h,offset:c.anchorOffset}],Ft(c)||r.push({node:c.focusNode,offset:c.focusOffset})),Qt&&8===e.input.lastKeyCode)for(let e=s;e>i;e--){let t=o.childNodes[e-1],n=t.pmViewDesc;if("BR"==t.nodeName&&!n){s=e;break}if(!n||n.size)break}let d=e.state.doc,p=e.someProp("domParser")||Y.fromSchema(e.state.schema),u=d.resolve(l),f=null,m=p.parse(o,{topNode:u.parent,topMatch:u.parent.contentMatchAt(u.index()),topOpen:!0,from:i,to:s,preserveWhitespace:"pre"!=u.parent.type.whitespace||"full",findPositions:r,ruleFromNode:Vo,context:u});if(r&&null!=r[0].pos){let e=r[0].pos,t=r[1]&&r[1].pos;null==t&&(t=e),f={anchor:e+l,head:t+l}}return{doc:m,sel:f,from:l,to:a}}(e,t,n),u=e.state.doc,f=u.slice(p.from,p.to);8===e.input.lastKeyCode&&Date.now()-100<e.input.lastKeyCodeTime?(c=e.state.selection.to,h="end"):(c=e.state.selection.from,h="start"),e.input.lastKeyCode=null;let m=function(e,t,n,r,o){let i=e.findDiffStart(t,n),s=n+e.size,l=n+t.size;if(null==i)return null;let{a:a,b:c}=e.findDiffEnd(t,s,l);if("end"==o){r-=a+Math.max(0,i-Math.min(a,c))-i}if(a<i&&s<l){i-=r<=i&&r>=a?i-r:0,c=i+(c-a),a=i}else if(c<i){i-=r<=i&&r>=c?i-r:0,a=i+(a-c),c=i}return{start:i,endA:a,endB:c}}(f.content,p.doc.content,p.from,c,h);if(m&&e.input.domChangeCount++,(en&&e.input.lastIOSEnter>Date.now()-225||rn)&&o.some(e=>1==e.nodeType&&!Fo.test(e.nodeName))&&(!m||m.endA>=m.endB)&&e.someProp("handleKeyDown",t=>t(e,qt(13,"Enter"))))return void(e.input.lastIOSEnter=0);if(!m){if(!(r&&d instanceof ht&&!d.empty&&d.$head.sameParent(d.$anchor))||e.composing||p.sel&&p.sel.anchor!=p.sel.head){if(p.sel){let t=Lo(e,e.state.doc,p.sel);if(t&&!t.eq(e.state.selection)){let n=e.state.tr.setSelection(t);s&&n.setMeta("composition",s),e.dispatch(n)}}return}m={start:d.from,endA:d.to,endB:d.to}}e.state.selection.from<e.state.selection.to&&m.start==m.endB&&e.state.selection instanceof ht&&(m.start>e.state.selection.from&&m.start<=e.state.selection.from+2&&e.state.selection.from>=p.from?m.start=e.state.selection.from:m.endA<e.state.selection.to&&m.endA>=e.state.selection.to-2&&e.state.selection.to<=p.to&&(m.endB+=e.state.selection.to-m.endA,m.endA=e.state.selection.to)),Ht&&Ut<=11&&m.endB==m.start+1&&m.endA==m.start&&m.start>p.from&&" "==p.doc.textBetween(m.start-p.from-1,m.start-p.from+1)&&(m.start--,m.endA--,m.endB--);let g=p.doc.resolveNoCache(m.start-p.from),y=p.doc.resolveNoCache(m.endB-p.from),w=u.resolve(m.start),v=g.sameParent(y)&&g.parent.inlineContent&&w.end()>=m.endA;if((en&&e.input.lastIOSEnter>Date.now()-225&&(!v||o.some(e=>"DIV"==e.nodeName||"P"==e.nodeName))||!v&&g.pos<p.doc.content.size&&(!g.sameParent(y)||!g.parent.inlineContent)&&g.pos<y.pos&&!/\S/.test(p.doc.textBetween(g.pos,y.pos,"","")))&&e.someProp("handleKeyDown",t=>t(e,qt(13,"Enter"))))return void(e.input.lastIOSEnter=0);if(e.state.selection.anchor>m.start&&function(e,t,n,r,o){if(n-t<=o.pos-r.pos||_o(r,!0,!1)<o.pos)return!1;let i=e.resolve(t);if(!r.parent.isTextblock){let e=i.nodeAfter;return null!=e&&n==t+e.nodeSize}if(i.parentOffset<i.parent.content.size||!i.parent.isTextblock)return!1;let s=e.resolve(_o(i,!0,!0));return!(!s.parent.isTextblock||s.pos>n||_o(s,!0,!1)<n)&&r.parent.content.cut(r.parentOffset).eq(s.parent.content)}(u,m.start,m.endA,g,y)&&e.someProp("handleKeyDown",t=>t(e,qt(8,"Backspace"))))return void(rn&&Qt&&e.domObserver.suppressSelectionUpdates());Qt&&m.endB==m.start&&(e.input.lastChromeDelete=Date.now()),rn&&!v&&g.start()!=y.start()&&0==y.parentOffset&&g.depth==y.depth&&p.sel&&p.sel.anchor==p.sel.head&&p.sel.head==m.endA&&(m.endB-=2,y=p.doc.resolveNoCache(m.endB-p.from),setTimeout(()=>{e.someProp("handleKeyDown",function(t){return t(e,qt(13,"Enter"))})},20));let b,k=m.start,x=m.endA,S=t=>{let n=t||e.state.tr.replace(k,x,p.doc.slice(m.start-p.from,m.endB-p.from));if(p.sel){let t=Lo(e,n.doc,p.sel);t&&!(Qt&&e.composing&&t.empty&&(m.start!=m.endB||e.input.lastChromeDelete<Date.now()-100)&&(t.head==k||t.head==n.mapping.map(x)-1)||Ht&&t.empty&&t.head==k)&&n.setSelection(t)}return s&&n.setMeta("composition",s),n.scrollIntoView()};if(v)if(g.pos==y.pos){Ht&&Ut<=11&&0==g.parentOffset&&(e.domObserver.suppressSelectionUpdates(),setTimeout(()=>Zn(e),20));let t=S(e.state.tr.delete(k,x)),n=u.resolve(m.start).marksAcross(u.resolve(m.endA));n&&t.ensureMarks(n),e.dispatch(t)}else if(m.endA==m.endB&&(b=function(e,t){let n,r,o,s=e.firstChild.marks,l=t.firstChild.marks,a=s,c=l;for(let e=0;e<l.length;e++)a=l[e].removeFromSet(a);for(let e=0;e<s.length;e++)c=s[e].removeFromSet(c);if(1==a.length&&0==c.length)r=a[0],n="add",o=e=>e.mark(r.addToSet(e.marks));else{if(0!=a.length||1!=c.length)return null;r=c[0],n="remove",o=e=>e.mark(r.removeFromSet(e.marks))}let h=[];for(let e=0;e<t.childCount;e++)h.push(o(t.child(e)));if(i.from(h).eq(e))return{mark:r,type:n}}(g.parent.content.cut(g.parentOffset,y.parentOffset),w.parent.content.cut(w.parentOffset,m.endA-w.start())))){let t=S(e.state.tr);"add"==b.type?t.addMark(k,x,b.mark):t.removeMark(k,x,b.mark),e.dispatch(t)}else if(g.parent.child(g.index()).isText&&g.index()==y.index()-(y.textOffset?0:1)){let t=g.parent.textBetween(g.parentOffset,y.parentOffset),n=()=>S(e.state.tr.insertText(t,k,x));e.someProp("handleTextInput",r=>r(e,k,x,t,n))||e.dispatch(n())}else e.dispatch(S());else e.dispatch(S())}function Lo(e,t,n){return Math.max(n.anchor,n.head)>t.content.size?null:sr(e,t.resolve(n.anchor),t.resolve(n.head))}function _o(e,t,n){let r=e.depth,o=t?e.end():e.pos;for(;r>0&&(t||e.indexAfter(r)==e.node(r).childCount);)r--,o++,t=!1;if(n){let t=e.node(r).maybeChild(e.indexAfter(r));for(;t&&!t.isLeaf;)t=t.firstChild,o++}return o}const Wo=Sr,Jo=oo;class jo{constructor(e,t){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new Br,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(Yo),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):"function"==typeof e?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=Uo(this),Ho(this),this.nodeViews=Go(this),this.docView=Pn(this.state.doc,Ko(this),To(this),this.dom,this),this.domObserver=new Ro(this,(e,t,n,r)=>qo(this,e,t,n,r)),this.domObserver.start(),function(e){for(let t in Rr){let n=Rr[t];e.dom.addEventListener(t,e.input.eventHandlers[t]=t=>{!qr(e,t)||Fr(e,t)||!e.editable&&t.type in zr||n(e,t)},Pr[t]?{passive:!0}:void 0)}Zt&&e.dom.addEventListener("input",()=>null),Vr(e)}(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let t in e)this._props[t]=e[t];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&Vr(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Yo),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let e in this._props)t[e]=this._props[e];t.state=this.state;for(let n in e)t[n]=e[n];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var n;let r=this.state,o=!1,i=!1;e.storedMarks&&this.composing&&(no(this),i=!0),this.state=e;let s=r.plugins!=e.plugins||this._props.plugins!=t.plugins;if(s||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let e=Go(this);(function(e,t){let n=0,r=0;for(let r in e){if(e[r]!=t[r])return!0;n++}for(let e in t)r++;return n!=r})(e,this.nodeViews)&&(this.nodeViews=e,o=!0)}(s||t.handleDOMEvents!=this._props.handleDOMEvents)&&Vr(this),this.editable=Uo(this),Ho(this);let l=To(this),a=Ko(this),c=r.plugins==e.plugins||r.doc.eq(e.doc)?e.scrollToSelection>r.scrollToSelection?"to selection":"preserve":"reset",h=o||!this.docView.matchesNode(e.doc,a,l);!h&&e.selection.eq(r.selection)||(i=!0);let d="preserve"==c&&i&&null==this.dom.style.overflowAnchor&&function(e){let t,n,r=e.dom.getBoundingClientRect(),o=Math.max(0,r.top);for(let i=(r.left+r.right)/2,s=o+1;s<Math.min(innerHeight,r.bottom);s+=5){let r=e.root.elementFromPoint(i,s);if(!r||r==e.dom||!e.dom.contains(r))continue;let l=r.getBoundingClientRect();if(l.top>=o-20){t=r,n=l.top;break}}return{refDOM:t,refTop:n,stack:dn(e.dom)}}(this);if(i){this.domObserver.stop();let t=h&&(Ht||Qt)&&!this.composing&&!r.selection.empty&&!e.selection.empty&&function(e,t){let n=Math.min(e.$anchor.sharedDepth(e.head),t.$anchor.sharedDepth(t.head));return e.$anchor.start(n)!=t.$anchor.start(n)}(r.selection,e.selection);if(h){let n=Qt?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=ro(this)),!o&&this.docView.update(e.doc,a,l,this)||(this.docView.updateOuterDeco(a),this.docView.destroy(),this.docView=Pn(e.doc,a,l,this.dom,this)),!n||this.trackWrites&&this.dom.contains(this.trackWrites)||(t=!0)}let n=this.input.mouseDown;t||!(n&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&function(e){let t=e.docView.domFromPos(e.state.selection.anchor,0),n=e.domSelectionRange();return zt(t.node,t.offset,n.anchorNode,n.anchorOffset)}(this)&&n.delaySelUpdate())?Zn(this,t):(or(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(r),(null===(n=this.dragging)||void 0===n?void 0:n.node)&&!r.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,r),"reset"==c?this.dom.scrollTop=0:"to selection"==c?this.scrollToSelection():d&&function({refDOM:e,refTop:t,stack:n}){let r=e?e.getBoundingClientRect().top:0;pn(n,0==r?0:r-t)}(d)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(e&&this.dom.contains(1==e.nodeType?e:e.parentNode))if(this.someProp("handleScrollToSelection",e=>e(this)));else if(this.state.selection instanceof pt){let t=this.docView.domAfterPos(this.state.selection.from);1==t.nodeType&&hn(this,t.getBoundingClientRect(),e)}else hn(this,this.coordsAtPos(this.state.selection.head,1),e);else;}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(e&&e.plugins==this.state.plugins&&this.directPlugins==this.prevDirectPlugins)for(let t=0;t<this.pluginViews.length;t++){let n=this.pluginViews[t];n.update&&n.update(this,e)}else{this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let e=0;e<this.directPlugins.length;e++){let t=this.directPlugins[e];t.spec.view&&this.pluginViews.push(t.spec.view(this))}for(let e=0;e<this.state.plugins.length;e++){let t=this.state.plugins[e];t.spec.view&&this.pluginViews.push(t.spec.view(this))}}}updateDraggedNode(e,t){let n=e.node,r=-1;if(n.from<this.state.doc.content.size&&this.state.doc.nodeAt(n.from)==n.node)r=n.from;else{let e=n.from+(this.state.doc.content.size-t.doc.content.size);(e>0&&e<this.state.doc.content.size&&this.state.doc.nodeAt(e))==n.node&&(r=e)}this.dragging=new ao(e.slice,e.move,r<0?void 0:pt.create(this.state.doc,r))}someProp(e,t){let n,r=this._props&&this._props[e];if(null!=r&&(n=t?t(r):r))return n;for(let r=0;r<this.directPlugins.length;r++){let o=this.directPlugins[r].props[e];if(null!=o&&(n=t?t(o):o))return n}let o=this.state.plugins;if(o)for(let r=0;r<o.length;r++){let i=o[r].props[e];if(null!=i&&(n=t?t(i):i))return n}}hasFocus(){if(Ht){let e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if("false"==e.contentEditable)return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&function(e){if(e.setActive)return e.setActive();if(un)return e.focus(un);let t=dn(e);e.focus(null==un?{get preventScroll(){return un={preventScroll:!0},!0}}:void 0),un||(un=!1,pn(t,0))}(this.dom),Zn(this),this.domObserver.start()}get root(){let e=this._root;if(null==e)for(let e=this.dom.parentNode;e;e=e.parentNode)if(9==e.nodeType||11==e.nodeType&&e.host)return e.getSelection||(Object.getPrototypeOf(e).getSelection=()=>e.ownerDocument.getSelection()),this._root=e;return e||document}updateRoot(){this._root=null}posAtCoords(e){return yn(this,e)}coordsAtPos(e,t=1){return kn(this,e,t)}domAtPos(e,t=0){return this.docView.domFromPos(e,t)}nodeDOM(e){let t=this.docView.descAt(e);return t?t.nodeDOM:null}posAtDOM(e,t,n=-1){let r=this.docView.posFromDOM(e,t,n);if(null==r)throw new RangeError("DOM position not inside the editor");return r}endOfTextblock(e,t){return Tn(this,t||this.state,e)}pasteHTML(e,t){return so(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return so(this,e,null,!0,t||new ClipboardEvent("paste"))}serializeForClipboard(e){return xr(this,e)}destroy(){this.docView&&(!function(e){e.input.mouseDown&&e.input.mouseDown.done(),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)}(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],To(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,It=null)}get isDestroyed(){return null==this.docView}dispatchEvent(e){return function(e,t){Fr(e,t)||!Rr[t.type]||!e.editable&&t.type in zr||Rr[t.type](e,t)}(this,e)}domSelectionRange(){let e=this.domSelection();return e?Zt&&11===this.root.nodeType&&function(e){let t=e.activeElement;for(;t&&t.shadowRoot;)t=t.shadowRoot.activeElement;return t}(this.dom.ownerDocument)==this.dom&&function(e,t){if(t.getComposedRanges){let n=t.getComposedRanges(e.root)[0];if(n)return Bo(e,n)}let n;function r(e){e.preventDefault(),e.stopImmediatePropagation(),n=e.getTargetRanges()[0]}return e.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),e.dom.removeEventListener("beforeinput",r,!0),n?Bo(e,n):null}(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}function Ko(e){let t=Object.create(null);return t.class="ProseMirror",t.contenteditable=String(e.editable),e.someProp("attributes",n=>{if("function"==typeof n&&(n=n(e.state)),n)for(let e in n)"class"==e?t.class+=" "+n[e]:"style"==e?t.style=(t.style?t.style+";":"")+n[e]:t[e]||"contenteditable"==e||"nodeName"==e||(t[e]=String(n[e]))}),t.translate||(t.translate="no"),[go.node(0,e.state.doc.content.size,t)]}function Ho(e){if(e.markCursor){let t=document.createElement("img");t.className="ProseMirror-separator",t.setAttribute("mark-placeholder","true"),t.setAttribute("alt",""),e.cursorWrapper={dom:t,deco:go.widget(e.state.selection.from,t,{raw:!0,marks:e.markCursor})}}else e.cursorWrapper=null}function Uo(e){return!e.someProp("editable",t=>!1===t(e.state))}function Go(e){let t=Object.create(null);function n(e){for(let n in e)Object.prototype.hasOwnProperty.call(t,n)||(t[n]=e[n])}return e.someProp("nodeViews",n),e.someProp("markViews",n),t}function Yo(e){if(e.spec.state||e.spec.filterTransaction||e.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}jo.prototype.dispatch=function(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))};for(var Qo=Object.freeze({__proto__:null,Decoration:go,DecorationSet:vo,EditorView:jo,__endComposition:Jo,__parseFromClipboard:Wo}),Xo={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},Zo={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},ei="undefined"!=typeof navigator&&/Mac/.test(navigator.platform),ti="undefined"!=typeof navigator&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),ni=0;ni<10;ni++)Xo[48+ni]=Xo[96+ni]=String(ni);for(ni=1;ni<=24;ni++)Xo[ni+111]="F"+ni;for(ni=65;ni<=90;ni++)Xo[ni]=String.fromCharCode(ni+32),Zo[ni]=String.fromCharCode(ni);for(var ri in Xo)Zo.hasOwnProperty(ri)||(Zo[ri]=Xo[ri]);const oi="undefined"!=typeof navigator&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),ii="undefined"!=typeof navigator&&/Win/.test(navigator.platform);function si(e){let t,n,r,o,i=e.split(/-(?!$)/),s=i[i.length-1];"Space"==s&&(s=" ");for(let e=0;e<i.length-1;e++){let s=i[e];if(/^(cmd|meta|m)$/i.test(s))o=!0;else if(/^a(lt)?$/i.test(s))t=!0;else if(/^(c|ctrl|control)$/i.test(s))n=!0;else if(/^s(hift)?$/i.test(s))r=!0;else{if(!/^mod$/i.test(s))throw new Error("Unrecognized modifier name: "+s);oi?o=!0:n=!0}}return t&&(s="Alt-"+s),n&&(s="Ctrl-"+s),o&&(s="Meta-"+s),r&&(s="Shift-"+s),s}function li(e,t,n=!0){return t.altKey&&(e="Alt-"+e),t.ctrlKey&&(e="Ctrl-"+e),t.metaKey&&(e="Meta-"+e),n&&t.shiftKey&&(e="Shift-"+e),e}function ai(e){return new Mt({props:{handleKeyDown:ci(e)}})}function ci(e){let t=function(e){let t=Object.create(null);for(let n in e)t[si(n)]=e[n];return t}(e);return function(e,n){let r,o=function(e){var t=!(ei&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||ti&&e.shiftKey&&e.key&&1==e.key.length||"Unidentified"==e.key)&&e.key||(e.shiftKey?Zo:Xo)[e.keyCode]||e.key||"Unidentified";return"Esc"==t&&(t="Escape"),"Del"==t&&(t="Delete"),"Left"==t&&(t="ArrowLeft"),"Up"==t&&(t="ArrowUp"),"Right"==t&&(t="ArrowRight"),"Down"==t&&(t="ArrowDown"),t}(n),i=t[li(o,n)];if(i&&i(e.state,e.dispatch,e))return!0;if(1==o.length&&" "!=o){if(n.shiftKey){let r=t[li(o,n,!1)];if(r&&r(e.state,e.dispatch,e))return!0}if((n.altKey||n.metaKey||n.ctrlKey)&&!(ii&&n.ctrlKey&&n.altKey)&&(r=Xo[n.keyCode])&&r!=o){let o=t[li(r,n)];if(o&&o(e.state,e.dispatch,e))return!0}}return!1}}var hi=Object.freeze({__proto__:null,keydownHandler:ci,keymap:ai});class di{constructor(e,t,n={}){var r;this.match=e,this.match=e,this.handler="string"==typeof t?(r=t,function(e,t,n,o){let i=r;if(t[1]){let e=t[0].lastIndexOf(t[1]);i+=t[0].slice(e+t[1].length);let r=(n+=e)-o;r>0&&(i=t[0].slice(e-r,e)+i,n=o)}return e.tr.insertText(i,n,o)}):t,this.undoable=!1!==n.undoable,this.inCode=n.inCode||!1,this.inCodeMark=!1!==n.inCodeMark}}function pi({rules:e}){let t=new Mt({state:{init:()=>null,apply(e,t){let n=e.getMeta(this);return n||(e.selectionSet||e.docChanged?null:t)}},props:{handleTextInput:(n,r,o,i)=>ui(n,r,o,i,e,t),handleDOMEvents:{compositionend:n=>{setTimeout(()=>{let{$cursor:r}=n.state.selection;r&&ui(n,r.pos,r.pos,"",e,t)})}}},isInputRules:!0});return t}function ui(e,t,n,r,o,i){if(e.composing)return!1;let s=e.state,l=s.doc.resolve(t),a=l.parent.textBetween(Math.max(0,l.parentOffset-500),l.parentOffset,null,"")+r;for(let c=0;c<o.length;c++){let h=o[c];if(!h.inCodeMark&&l.marks().some(e=>e.type.spec.code))continue;if(l.parent.type.spec.code){if(!h.inCode)continue}else if("only"===h.inCode)continue;let d=h.match.exec(a);if(!d||d[0].length<r.length)continue;let p=t-(d[0].length-r.length);if(!h.inCodeMark){let e=!1;if(s.doc.nodesBetween(p,l.pos,t=>{t.isInline&&t.marks.some(e=>e.type.spec.code)&&(e=!0)}),e)continue}let u=h.handler(s,d,p,n);if(u)return h.undoable&&u.setMeta(i,{transform:u,from:t,to:n,text:r}),e.dispatch(u),!0}return!1}const fi=(e,t)=>{let n=e.plugins;for(let r=0;r<n.length;r++){let o,i=n[r];if(i.spec.isInputRules&&(o=i.getState(e))){if(t){let n=e.tr,r=o.transform;for(let e=r.steps.length-1;e>=0;e--)n.step(r.steps[e].invert(r.docs[e]));if(o.text){let t=n.doc.resolve(o.from).marks();n.replaceWith(o.from,o.to,e.schema.text(o.text,t))}else n.delete(o.from,o.to);t(n)}return!0}}return!1},mi=new di(/--$/,"—",{inCodeMark:!1}),gi=new di(/\.\.\.$/,"…",{inCodeMark:!1}),yi=new di(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,"“",{inCodeMark:!1}),wi=new di(/"$/,"”",{inCodeMark:!1}),vi=new di(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,"‘",{inCodeMark:!1}),bi=new di(/'$/,"’",{inCodeMark:!1}),ki=[yi,wi,vi,bi];function xi(e,t,n=null,r){return new di(e,(e,o,i,s)=>{let l=n instanceof Function?n(o):n,a=e.tr.delete(i,s),c=a.doc.resolve(i).blockRange(),h=c&&Re(c,t,l);if(!h)return null;a.wrap(c,h);let d=a.doc.resolve(i-1).nodeBefore;return d&&d.type==t&&Ve(a.doc,i-1)&&(!r||r(o,d))&&a.join(i-1),a})}function Si(e,t,n=null){return new di(e,(e,r,o,i)=>{let s=e.doc.resolve(o),l=n instanceof Function?n(r):n;return s.node(-1).canReplaceWith(s.index(-1),s.indexAfter(-1),t)?e.tr.delete(o,i).setBlockType(o,o,t,l):null})}var Ci=Object.freeze({__proto__:null,InputRule:di,closeDoubleQuote:wi,closeSingleQuote:bi,ellipsis:gi,emDash:mi,inputRules:pi,openDoubleQuote:yi,openSingleQuote:vi,smartQuotes:ki,textblockTypeInputRule:Si,undoInputRule:fi,wrappingInputRule:xi}),Mi=200,Oi=function(){};Oi.prototype.append=function(e){return e.length?(e=Oi.from(e),!this.length&&e||e.length<Mi&&this.leafAppend(e)||this.length<Mi&&e.leafPrepend(this)||this.appendInner(e)):this},Oi.prototype.prepend=function(e){return e.length?Oi.from(e).append(this):this},Oi.prototype.appendInner=function(e){return new Di(this,e)},Oi.prototype.slice=function(e,t){return void 0===e&&(e=0),void 0===t&&(t=this.length),e>=t?Oi.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},Oi.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},Oi.prototype.forEach=function(e,t,n){void 0===t&&(t=0),void 0===n&&(n=this.length),t<=n?this.forEachInner(e,t,n,0):this.forEachInvertedInner(e,t,n,0)},Oi.prototype.map=function(e,t,n){void 0===t&&(t=0),void 0===n&&(n=this.length);var r=[];return this.forEach(function(t,n){return r.push(e(t,n))},t,n),r},Oi.from=function(e){return e instanceof Oi?e:e&&e.length?new Ni(e):Oi.empty};var Ni=function(e){function t(t){e.call(this),this.values=t}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var n={length:{configurable:!0},depth:{configurable:!0}};return t.prototype.flatten=function(){return this.values},t.prototype.sliceInner=function(e,n){return 0==e&&n==this.length?this:new t(this.values.slice(e,n))},t.prototype.getInner=function(e){return this.values[e]},t.prototype.forEachInner=function(e,t,n,r){for(var o=t;o<n;o++)if(!1===e(this.values[o],r+o))return!1},t.prototype.forEachInvertedInner=function(e,t,n,r){for(var o=t-1;o>=n;o--)if(!1===e(this.values[o],r+o))return!1},t.prototype.leafAppend=function(e){if(this.length+e.length<=Mi)return new t(this.values.concat(e.flatten()))},t.prototype.leafPrepend=function(e){if(this.length+e.length<=Mi)return new t(e.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(t.prototype,n),t}(Oi);Oi.empty=new Ni([]);var Di=function(e){function t(t,n){e.call(this),this.left=t,this.right=n,this.length=t.length+n.length,this.depth=Math.max(t.depth,n.depth)+1}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},t.prototype.getInner=function(e){return e<this.left.length?this.left.get(e):this.right.get(e-this.left.length)},t.prototype.forEachInner=function(e,t,n,r){var o=this.left.length;return!(t<o&&!1===this.left.forEachInner(e,t,Math.min(n,o),r))&&(!(n>o&&!1===this.right.forEachInner(e,Math.max(t-o,0),Math.min(this.length,n)-o,r+o))&&void 0)},t.prototype.forEachInvertedInner=function(e,t,n,r){var o=this.left.length;return!(t>o&&!1===this.right.forEachInvertedInner(e,t-o,Math.max(n,o)-o,r+o))&&(!(n<o&&!1===this.left.forEachInvertedInner(e,Math.min(t,o),n,r))&&void 0)},t.prototype.sliceInner=function(e,t){if(0==e&&t==this.length)return this;var n=this.left.length;return t<=n?this.left.slice(e,t):e>=n?this.right.slice(e-n,t-n):this.left.slice(e,n).append(this.right.slice(0,t-n))},t.prototype.leafAppend=function(e){var n=this.right.leafAppend(e);if(n)return new t(this.left,n)},t.prototype.leafPrepend=function(e){var n=this.left.leafPrepend(e);if(n)return new t(n,this.right)},t.prototype.appendInner=function(e){return this.left.depth>=Math.max(this.right.depth,e.depth)+1?new t(this.left,new t(this.right,e)):new t(this,e)},t}(Oi);class Ti{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(0==this.eventCount)return null;let n,r,o=this.items.length;for(;;o--){if(this.items.get(o-1).selection){--o;break}}t&&(n=this.remapping(o,this.items.length),r=n.maps.length);let i,s,l=e.tr,a=[],c=[];return this.items.forEach((e,t)=>{if(!e.step)return n||(n=this.remapping(o,t+1),r=n.maps.length),r--,void c.push(e);if(n){c.push(new Ei(e.map));let t,o=e.step.map(n.slice(r));o&&l.maybeStep(o).doc&&(t=l.mapping.maps[l.mapping.maps.length-1],a.push(new Ei(t,void 0,void 0,a.length+c.length))),r--,t&&n.appendMap(t,r)}else l.maybeStep(e.step);return e.selection?(i=n?e.selection.map(n.slice(r)):e.selection,s=new Ti(this.items.slice(0,o).append(c.reverse().concat(a)),this.eventCount-1),!1):void 0},this.items.length,0),{remaining:s,transform:l,selection:i}}addTransform(e,t,n,r){let o=[],i=this.eventCount,s=this.items,l=!r&&s.length?s.get(s.length-1):null;for(let n=0;n<e.steps.length;n++){let a,c=e.steps[n].invert(e.docs[n]),h=new Ei(e.mapping.maps[n],c,t);(a=l&&l.merge(h))&&(h=a,n?o.pop():s=s.slice(0,s.length-1)),o.push(h),t&&(i++,t=void 0),r||(l=h)}let a=i-n.depth;return a>Ii&&(s=function(e,t){let n;return e.forEach((e,r)=>{if(e.selection&&0==t--)return n=r,!1}),e.slice(n)}(s,a),i-=a),new Ti(s.append(o),i)}remapping(e,t){let n=new we;return this.items.forEach((t,r)=>{let o=null!=t.mirrorOffset&&r-t.mirrorOffset>=e?n.maps.length-t.mirrorOffset:void 0;n.appendMap(t.map,o)},e,t),n}addMaps(e){return 0==this.eventCount?this:new Ti(this.items.append(e.map(e=>new Ei(e))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let n=[],r=Math.max(0,this.items.length-t),o=e.mapping,i=e.steps.length,s=this.eventCount;this.items.forEach(e=>{e.selection&&s--},r);let l=t;this.items.forEach(t=>{let r=o.getMirror(--l);if(null==r)return;i=Math.min(i,r);let a=o.maps[r];if(t.step){let i=e.steps[r].invert(e.docs[r]),c=t.selection&&t.selection.map(o.slice(l+1,r));c&&s++,n.push(new Ei(a,i,c))}else n.push(new Ei(a))},r);let a=[];for(let e=t;e<i;e++)a.push(new Ei(o.maps[e]));let c=this.items.slice(0,r).append(a).append(n),h=new Ti(c,s);return h.emptyItemCount()>500&&(h=h.compress(this.items.length-n.length)),h}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),n=t.maps.length,r=[],o=0;return this.items.forEach((i,s)=>{if(s>=e)r.push(i),i.selection&&o++;else if(i.step){let e=i.step.map(t.slice(n)),s=e&&e.getMap();if(n--,s&&t.appendMap(s,n),e){let l=i.selection&&i.selection.map(t.slice(n));l&&o++;let a,c=new Ei(s.invert(),e,l),h=r.length-1;(a=r.length&&r[h].merge(c))?r[h]=a:r.push(c)}}else i.map&&n--},this.items.length,0),new Ti(Oi.from(r.reverse()),o)}}Ti.empty=new Ti(Oi.empty,0);class Ei{constructor(e,t,n,r){this.map=e,this.step=t,this.selection=n,this.mirrorOffset=r}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new Ei(t.getMap().invert(),t,this.selection)}}}class Ai{constructor(e,t,n,r,o){this.done=e,this.undone=t,this.prevRanges=n,this.prevTime=r,this.prevComposition=o}}const Ii=20;function Ri(e){let t=[];for(let n=e.length-1;n>=0&&0==t.length;n--)e[n].forEach((e,n,r,o)=>t.push(r,o));return t}function zi(e,t){if(!e)return null;let n=[];for(let r=0;r<e.length;r+=2){let o=t.map(e[r],1),i=t.map(e[r+1],-1);o<=i&&n.push(o,i)}return n}let Pi=!1,Bi=null;function $i(e){let t=e.plugins;if(Bi!=t){Pi=!1,Bi=t;for(let e=0;e<t.length;e++)if(t[e].spec.historyPreserveItems){Pi=!0;break}}return Pi}const Vi=new Dt("history"),Fi=new Dt("closeHistory");function qi(e={}){return e={depth:e.depth||100,newGroupDelay:e.newGroupDelay||500},new Mt({key:Vi,state:{init:()=>new Ai(Ti.empty,Ti.empty,null,0,-1),apply:(t,n,r)=>function(e,t,n,r){let o,i=n.getMeta(Vi);if(i)return i.historyState;n.getMeta(Fi)&&(e=new Ai(e.done,e.undone,null,0,-1));let s=n.getMeta("appendedTransaction");if(0==n.steps.length)return e;if(s&&s.getMeta(Vi))return s.getMeta(Vi).redo?new Ai(e.done.addTransform(n,void 0,r,$i(t)),e.undone,Ri(n.mapping.maps),e.prevTime,e.prevComposition):new Ai(e.done,e.undone.addTransform(n,void 0,r,$i(t)),null,e.prevTime,e.prevComposition);if(!1===n.getMeta("addToHistory")||s&&!1===s.getMeta("addToHistory"))return(o=n.getMeta("rebased"))?new Ai(e.done.rebased(n,o),e.undone.rebased(n,o),zi(e.prevRanges,n.mapping),e.prevTime,e.prevComposition):new Ai(e.done.addMaps(n.mapping.maps),e.undone.addMaps(n.mapping.maps),zi(e.prevRanges,n.mapping),e.prevTime,e.prevComposition);{let o=n.getMeta("composition"),i=0==e.prevTime||!s&&e.prevComposition!=o&&(e.prevTime<(n.time||0)-r.newGroupDelay||!function(e,t){if(!t)return!1;if(!e.docChanged)return!0;let n=!1;return e.mapping.maps[0].forEach((e,r)=>{for(let o=0;o<t.length;o+=2)e<=t[o+1]&&r>=t[o]&&(n=!0)}),n}(n,e.prevRanges)),l=s?zi(e.prevRanges,n.mapping):Ri(n.mapping.maps);return new Ai(e.done.addTransform(n,i?t.selection.getBookmark():void 0,r,$i(t)),Ti.empty,l,n.time,null==o?e.prevComposition:o)}}(n,r,t,e)},config:e,props:{handleDOMEvents:{beforeinput(e,t){let n=t.inputType,r="historyUndo"==n?_i:"historyRedo"==n?Wi:null;return!(!r||!e.editable)&&(t.preventDefault(),r(e.state,e.dispatch))}}}})}function Li(e,t){return(n,r)=>{let o=Vi.getState(n);if(!o||0==(e?o.undone:o.done).eventCount)return!1;if(r){let i=function(e,t,n){let r=$i(t),o=Vi.get(t).spec.config,i=(n?e.undone:e.done).popEvent(t,r);if(!i)return null;let s=i.selection.resolve(i.transform.doc),l=(n?e.done:e.undone).addTransform(i.transform,t.selection.getBookmark(),o,r),a=new Ai(n?l:i.remaining,n?i.remaining:l,null,0,-1);return i.transform.setSelection(s).setMeta(Vi,{redo:n,historyState:a})}(o,n,e);i&&r(t?i.scrollIntoView():i)}return!0}}const _i=Li(!1,!0),Wi=Li(!0,!0),Ji=Li(!1,!1),ji=Li(!0,!1);var Ki=Object.freeze({__proto__:null,closeHistory:function(e){return e.setMeta(Fi,!0)},history:qi,isHistoryTransaction:function(e){return null!=e.getMeta(Vi)},redo:Wi,redoDepth:function(e){let t=Vi.getState(e);return t?t.undone.eventCount:0},redoNoScroll:ji,undo:_i,undoDepth:function(e){let t=Vi.getState(e);return t?t.done.eventCount:0},undoNoScroll:Ji});const Hi=(e,t)=>!e.selection.empty&&(t&&t(e.tr.deleteSelection().scrollIntoView()),!0);function Ui(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock("backward",e):n.parentOffset>0)?null:n}const Gi=(e,t,n)=>{let r=Ui(e,n);if(!r)return!1;let o=Zi(r);if(!o){let n=r.blockRange(),o=n&&Ie(n);return null!=o&&(t&&t(e.tr.lift(n,o).scrollIntoView()),!0)}let i=o.nodeBefore;if(ys(e,o,t,-1))return!0;if(0==r.parent.content.size&&(Qi(i,"end")||pt.isSelectable(i)))for(let n=r.depth;;n--){let s=We(e.doc,r.before(n),r.after(n),d.empty);if(s&&s.slice.size<s.to-s.from){if(t){let n=e.tr.step(s);n.setSelection(Qi(i,"end")?st.findFrom(n.doc.resolve(n.mapping.map(o.pos,-1)),-1):pt.create(n.doc,o.pos-i.nodeSize)),t(n.scrollIntoView())}return!0}if(1==n||r.node(n-1).childCount>1)break}return!(!i.isAtom||o.depth!=r.depth-1)&&(t&&t(e.tr.delete(o.pos-i.nodeSize,o.pos).scrollIntoView()),!0)};function Yi(e,t,n){let r=t.nodeBefore,o=t.pos-1;for(;!r.isTextblock;o--){if(r.type.spec.isolating)return!1;let e=r.lastChild;if(!e)return!1;r=e}let i=t.nodeAfter,s=t.pos+1;for(;!i.isTextblock;s++){if(i.type.spec.isolating)return!1;let e=i.firstChild;if(!e)return!1;i=e}let l=We(e.doc,o,s,d.empty);if(!l||l.from!=o||l instanceof Ne&&l.slice.size>=s-o)return!1;if(n){let t=e.tr.step(l);t.setSelection(ht.create(t.doc,o)),n(t.scrollIntoView())}return!0}function Qi(e,t,n=!1){for(let r=e;r;r="start"==t?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(n&&1!=r.childCount)return!1}return!1}const Xi=(e,t,n)=>{let{$head:r,empty:o}=e.selection,i=r;if(!o)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("backward",e):r.parentOffset>0)return!1;i=Zi(r)}let s=i&&i.nodeBefore;return!(!s||!pt.isSelectable(s))&&(t&&t(e.tr.setSelection(pt.create(e.doc,i.pos-s.nodeSize)).scrollIntoView()),!0)};function Zi(e){if(!e.parent.type.spec.isolating)for(let t=e.depth-1;t>=0;t--){if(e.index(t)>0)return e.doc.resolve(e.before(t+1));if(e.node(t).type.spec.isolating)break}return null}function es(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock("forward",e):n.parentOffset<n.parent.content.size)?null:n}const ts=(e,t,n)=>{let r=es(e,n);if(!r)return!1;let o=rs(r);if(!o)return!1;let i=o.nodeAfter;if(ys(e,o,t,1))return!0;if(0==r.parent.content.size&&(Qi(i,"start")||pt.isSelectable(i))){let n=We(e.doc,r.before(),r.after(),d.empty);if(n&&n.slice.size<n.to-n.from){if(t){let r=e.tr.step(n);r.setSelection(Qi(i,"start")?st.findFrom(r.doc.resolve(r.mapping.map(o.pos)),1):pt.create(r.doc,r.mapping.map(o.pos))),t(r.scrollIntoView())}return!0}}return!(!i.isAtom||o.depth!=r.depth-1)&&(t&&t(e.tr.delete(o.pos,o.pos+i.nodeSize).scrollIntoView()),!0)},ns=(e,t,n)=>{let{$head:r,empty:o}=e.selection,i=r;if(!o)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock("forward",e):r.parentOffset<r.parent.content.size)return!1;i=rs(r)}let s=i&&i.nodeAfter;return!(!s||!pt.isSelectable(s))&&(t&&t(e.tr.setSelection(pt.create(e.doc,i.pos)).scrollIntoView()),!0)};function rs(e){if(!e.parent.type.spec.isolating)for(let t=e.depth-1;t>=0;t--){let n=e.node(t);if(e.index(t)+1<n.childCount)return e.doc.resolve(e.after(t+1));if(n.type.spec.isolating)break}return null}const is=(e,t)=>{let n,r=e.selection,o=r instanceof pt;if(o){if(r.node.isTextblock||!Ve(e.doc,r.from))return!1;n=r.from}else if(n=qe(e.doc,r.from,-1),null==n)return!1;if(t){let r=e.tr.join(n);o&&r.setSelection(pt.create(r.doc,n-e.doc.resolve(n).nodeBefore.nodeSize)),t(r.scrollIntoView())}return!0},ss=(e,t)=>{let n,r=e.selection;if(r instanceof pt){if(r.node.isTextblock||!Ve(e.doc,r.to))return!1;n=r.to}else if(n=qe(e.doc,r.to,1),null==n)return!1;return t&&t(e.tr.join(n).scrollIntoView()),!0},ls=(e,t)=>{let{$from:n,$to:r}=e.selection,o=n.blockRange(r),i=o&&Ie(o);return null!=i&&(t&&t(e.tr.lift(o,i).scrollIntoView()),!0)},as=(e,t)=>{let{$head:n,$anchor:r}=e.selection;return!(!n.parent.type.spec.code||!n.sameParent(r))&&(t&&t(e.tr.insertText("\n").scrollIntoView()),!0)};function cs(e){for(let t=0;t<e.edgeCount;t++){let{type:n}=e.edge(t);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}const hs=(e,t)=>{let{$head:n,$anchor:r}=e.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let o=n.node(-1),i=n.indexAfter(-1),s=cs(o.contentMatchAt(i));if(!s||!o.canReplaceWith(i,i,s))return!1;if(t){let r=n.after(),o=e.tr.replaceWith(r,r,s.createAndFill());o.setSelection(st.near(o.doc.resolve(r),1)),t(o.scrollIntoView())}return!0},ds=(e,t)=>{let n=e.selection,{$from:r,$to:o}=n;if(n instanceof ft||r.parent.inlineContent||o.parent.inlineContent)return!1;let i=cs(o.parent.contentMatchAt(o.indexAfter()));if(!i||!i.isTextblock)return!1;if(t){let n=(!r.parentOffset&&o.index()<o.parent.childCount?r:o).pos,s=e.tr.insert(n,i.createAndFill());s.setSelection(ht.create(s.doc,n+1)),t(s.scrollIntoView())}return!0},ps=(e,t)=>{let{$cursor:n}=e.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let r=n.before();if($e(e.doc,r))return t&&t(e.tr.split(r).scrollIntoView()),!0}let r=n.blockRange(),o=r&&Ie(r);return null!=o&&(t&&t(e.tr.lift(r,o).scrollIntoView()),!0)};function us(e){return(t,n)=>{let{$from:r,$to:o}=t.selection;if(t.selection instanceof pt&&t.selection.node.isBlock)return!(!r.parentOffset||!$e(t.doc,r.pos))&&(n&&n(t.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let i,s,l=[],a=!1,c=!1;for(let t=r.depth;;t--){if(r.node(t).isBlock){a=r.end(t)==r.pos+(r.depth-t),c=r.start(t)==r.pos-(r.depth-t),s=cs(r.node(t-1).contentMatchAt(r.indexAfter(t-1)));let n=e&&e(o.parent,a,r);l.unshift(n||(a&&s?{type:s}:null)),i=t;break}if(1==t)return!1;l.unshift(null)}let h=t.tr;(t.selection instanceof ht||t.selection instanceof ft)&&h.deleteSelection();let d=h.mapping.map(r.pos),p=$e(h.doc,d,l.length,l);if(p||(l[0]=s?{type:s}:null,p=$e(h.doc,d,l.length,l)),!p)return!1;if(h.split(d,l.length,l),!a&&c&&r.node(i).type!=s){let e=h.mapping.map(r.before(i)),t=h.doc.resolve(e);s&&r.node(i-1).canReplaceWith(t.index(),t.index()+1,s)&&h.setNodeMarkup(h.mapping.map(r.before(i)),s)}return n&&n(h.scrollIntoView()),!0}}const fs=us(),ms=(e,t)=>{let n,{$from:r,to:o}=e.selection,i=r.sharedDepth(o);return 0!=i&&(n=r.before(i),t&&t(e.tr.setSelection(pt.create(e.doc,n))),!0)},gs=(e,t)=>(t&&t(e.tr.setSelection(new ft(e.doc))),!0);function ys(e,t,n,r){let o,s,l=t.nodeBefore,a=t.nodeAfter,c=l.type.spec.isolating||a.type.spec.isolating;if(!c&&function(e,t,n){let r=t.nodeBefore,o=t.nodeAfter,i=t.index();return!(!(r&&o&&r.type.compatibleContent(o.type))||(!r.content.size&&t.parent.canReplace(i-1,i)?(n&&n(e.tr.delete(t.pos-r.nodeSize,t.pos).scrollIntoView()),0):!t.parent.canReplace(i,i+1)||!o.isTextblock&&!Ve(e.doc,t.pos)||(n&&n(e.tr.join(t.pos).scrollIntoView()),0)))}(e,t,n))return!0;let h=!c&&t.parent.canReplace(t.index(),t.index()+1);if(h&&(o=(s=l.contentMatchAt(l.childCount)).findWrapping(a.type))&&s.matchType(o[0]||a.type).validEnd){if(n){let r=t.pos+a.nodeSize,s=i.empty;for(let e=o.length-1;e>=0;e--)s=i.from(o[e].create(null,s));s=i.from(l.copy(s));let c=e.tr.step(new De(t.pos-1,r,t.pos,r,new d(s,1,0),o.length,!0)),h=c.doc.resolve(r+2*o.length);h.nodeAfter&&h.nodeAfter.type==l.type&&Ve(c.doc,h.pos)&&c.join(h.pos),n(c.scrollIntoView())}return!0}let p=a.type.spec.isolating||r>0&&c?null:st.findFrom(t,1),u=p&&p.$from.blockRange(p.$to),f=u&&Ie(u);if(null!=f&&f>=t.depth)return n&&n(e.tr.lift(u,f).scrollIntoView()),!0;if(h&&Qi(a,"start",!0)&&Qi(l,"end")){let r=l,o=[];for(;o.push(r),!r.isTextblock;)r=r.lastChild;let s=a,c=1;for(;!s.isTextblock;s=s.firstChild)c++;if(r.canReplace(r.childCount,r.childCount,s.content)){if(n){let r=i.empty;for(let e=o.length-1;e>=0;e--)r=i.from(o[e].copy(r));n(e.tr.step(new De(t.pos-o.length,t.pos+a.nodeSize,t.pos+c,t.pos+a.nodeSize-c,new d(r,o.length,0),0,!0)).scrollIntoView())}return!0}}return!1}function ws(e){return function(t,n){let r=t.selection,o=e<0?r.$from:r.$to,i=o.depth;for(;o.node(i).isInline;){if(!i)return!1;i--}return!!o.node(i).isTextblock&&(n&&n(t.tr.setSelection(ht.create(t.doc,e<0?o.start(i):o.end(i)))),!0)}}const vs=ws(-1),bs=ws(1);function ks(e,t=null){return function(n,r){let{$from:o,$to:i}=n.selection,s=o.blockRange(i),l=s&&Re(s,e,t);return!!l&&(r&&r(n.tr.wrap(s,l).scrollIntoView()),!0)}}function xs(e,t=null){return function(n,r){let o=!1;for(let r=0;r<n.selection.ranges.length&&!o;r++){let{$from:{pos:i},$to:{pos:s}}=n.selection.ranges[r];n.doc.nodesBetween(i,s,(r,i)=>{if(o)return!1;if(r.isTextblock&&!r.hasMarkup(e,t))if(r.type==e)o=!0;else{let t=n.doc.resolve(i),r=t.index();o=t.parent.canReplaceWith(r,r+1,e)}})}if(!o)return!1;if(r){let o=n.tr;for(let r=0;r<n.selection.ranges.length;r++){let{$from:{pos:i},$to:{pos:s}}=n.selection.ranges[r];o.setBlockType(i,s,e,t)}r(o.scrollIntoView())}return!0}}function Ss(e,t=null,n){let r=!1!==(n&&n.removeWhenPresent),o=!1!==(n&&n.enterInlineAtoms),i=!(n&&n.includeWhitespace);return function(n,s){let{empty:l,$cursor:a,ranges:c}=n.selection;if(l&&!a||!function(e,t,n,r){for(let o=0;o<t.length;o++){let{$from:i,$to:s}=t[o],l=0==i.depth&&e.inlineContent&&e.type.allowsMarkType(n);if(e.nodesBetween(i.pos,s.pos,(e,t)=>{if(l||!r&&e.isAtom&&e.isInline&&t>=i.pos&&t+e.nodeSize<=s.pos)return!1;l=e.inlineContent&&e.type.allowsMarkType(n)}),l)return!0}return!1}(n.doc,c,e,o))return!1;if(s)if(a)e.isInSet(n.storedMarks||a.marks())?s(n.tr.removeStoredMark(e)):s(n.tr.addStoredMark(e.create(t)));else{let l,a=n.tr;o||(c=function(e){let t=[];for(let n=0;n<e.length;n++){let{$from:r,$to:o}=e[n];r.doc.nodesBetween(r.pos,o.pos,(e,n)=>{if(e.isAtom&&e.content.size&&e.isInline&&n>=r.pos&&n+e.nodeSize<=o.pos)return n+1>r.pos&&t.push(new lt(r,r.doc.resolve(n+1))),r=r.doc.resolve(n+1+e.content.size),!1}),r.pos<o.pos&&t.push(new lt(r,o))}return t}(c)),l=r?!c.some(t=>n.doc.rangeHasMark(t.$from.pos,t.$to.pos,e)):!c.every(t=>{let n=!1;return a.doc.nodesBetween(t.$from.pos,t.$to.pos,(r,o,i)=>{if(n)return!1;n=!e.isInSet(r.marks)&&!!i&&i.type.allowsMarkType(e)&&!(r.isText&&/^\s*$/.test(r.textBetween(Math.max(0,t.$from.pos-o),Math.min(r.nodeSize,t.$to.pos-o))))}),!n});for(let n=0;n<c.length;n++){let{$from:r,$to:o}=c[n];if(l){let n=r.pos,s=o.pos,l=r.nodeAfter,c=o.nodeBefore,h=i&&l&&l.isText?/^\s*/.exec(l.text)[0].length:0,d=i&&c&&c.isText?/\s*$/.exec(c.text)[0].length:0;n+h<s&&(n+=h,s-=d),a.addMark(n,s,e.create(t))}else a.removeMark(r.pos,o.pos,e)}s(a.scrollIntoView())}return!0}}function Cs(e,t){return n=>{if(!n.isGeneric)return e(n);let r=[];for(let e=0;e<n.mapping.maps.length;e++){let t=n.mapping.maps[e];for(let e=0;e<r.length;e++)r[e]=t.map(r[e]);t.forEach((e,t,n,o)=>r.push(n,o))}let o=[];for(let e=0;e<r.length;e+=2){let i=r[e],s=r[e+1],l=n.doc.resolve(i),a=l.sharedDepth(s),c=l.node(a);for(let e=l.indexAfter(a),n=l.after(a+1);n<=s;++e){let r=c.maybeChild(e);if(!r)break;if(e&&-1==o.indexOf(n)){let i=c.child(e-1);i.type==r.type&&t(i,r)&&o.push(n)}n+=r.nodeSize}}o.sort((e,t)=>e-t);for(let e=o.length-1;e>=0;e--)Ve(n.doc,o[e])&&n.join(o[e]);e(n)}}function Ms(...e){return function(t,n,r){for(let o=0;o<e.length;o++)if(e[o](t,n,r))return!0;return!1}}let Os=Ms(Hi,Gi,Xi),Ns=Ms(Hi,ts,ns);const Ds={Enter:Ms(as,ds,ps,fs),"Mod-Enter":hs,Backspace:Os,"Mod-Backspace":Os,"Shift-Backspace":Os,Delete:Ns,"Mod-Delete":Ns,"Mod-a":gs},Ts={"Ctrl-h":Ds.Backspace,"Alt-Backspace":Ds["Mod-Backspace"],"Ctrl-d":Ds.Delete,"Ctrl-Alt-Backspace":Ds["Mod-Delete"],"Alt-Delete":Ds["Mod-Delete"],"Alt-d":Ds["Mod-Delete"],"Ctrl-a":vs,"Ctrl-e":bs};for(let e in Ds)Ts[e]=Ds[e];const Es=("undefined"!=typeof navigator?/Mac|iP(hone|[oa]d)/.test(navigator.platform):!("undefined"==typeof os||!os.platform)&&"darwin"==os.platform())?Ts:Ds;var As=Object.freeze({__proto__:null,autoJoin:function(e,t){let n=Array.isArray(t)?e=>t.indexOf(e.type.name)>-1:t;return(t,r,o)=>e(t,r&&Cs(r,n),o)},baseKeymap:Es,chainCommands:Ms,createParagraphNear:ds,deleteSelection:Hi,exitCode:hs,joinBackward:Gi,joinDown:ss,joinForward:ts,joinTextblockBackward:(e,t,n)=>{let r=Ui(e,n);if(!r)return!1;let o=Zi(r);return!!o&&Yi(e,o,t)},joinTextblockForward:(e,t,n)=>{let r=es(e,n);if(!r)return!1;let o=rs(r);return!!o&&Yi(e,o,t)},joinUp:is,lift:ls,liftEmptyBlock:ps,macBaseKeymap:Ts,newlineInCode:as,pcBaseKeymap:Ds,selectAll:gs,selectNodeBackward:Xi,selectNodeForward:ns,selectParentNode:ms,selectTextblockEnd:bs,selectTextblockStart:vs,setBlockType:xs,splitBlock:fs,splitBlockAs:us,splitBlockKeepMarks:(e,t)=>fs(e,t&&(n=>{let r=e.storedMarks||e.selection.$to.parentOffset&&e.selection.$from.marks();r&&n.ensureMarks(r),t(n)})),toggleMark:Ss,wrapIn:ks});const Is=["p",0],Rs=["blockquote",0],zs=["hr"],Ps=["pre",["code",0]],Bs=["br"],$s={doc:{content:"block+"},paragraph:{content:"inline*",group:"block",parseDOM:[{tag:"p"}],toDOM:()=>Is},blockquote:{content:"block+",group:"block",defining:!0,parseDOM:[{tag:"blockquote"}],toDOM:()=>Rs},horizontal_rule:{group:"block",parseDOM:[{tag:"hr"}],toDOM:()=>zs},heading:{attrs:{level:{default:1,validate:"number"}},content:"inline*",group:"block",defining:!0,parseDOM:[{tag:"h1",attrs:{level:1}},{tag:"h2",attrs:{level:2}},{tag:"h3",attrs:{level:3}},{tag:"h4",attrs:{level:4}},{tag:"h5",attrs:{level:5}},{tag:"h6",attrs:{level:6}}],toDOM:e=>["h"+e.attrs.level,0]},code_block:{content:"text*",marks:"",group:"block",code:!0,defining:!0,parseDOM:[{tag:"pre",preserveWhitespace:"full"}],toDOM:()=>Ps},text:{group:"inline"},image:{inline:!0,attrs:{src:{validate:"string"},alt:{default:null,validate:"string|null"},title:{default:null,validate:"string|null"}},group:"inline",draggable:!0,parseDOM:[{tag:"img[src]",getAttrs:e=>({src:e.getAttribute("src"),title:e.getAttribute("title"),alt:e.getAttribute("alt")})}],toDOM(e){let{src:t,alt:n,title:r}=e.attrs;return["img",{src:t,alt:n,title:r}]}},hard_break:{inline:!0,group:"inline",selectable:!1,parseDOM:[{tag:"br"}],toDOM:()=>Bs}},Vs=["em",0],Fs=["strong",0],qs=["code",0],Ls={link:{attrs:{href:{validate:"string"},title:{default:null,validate:"string|null"}},inclusive:!1,parseDOM:[{tag:"a[href]",getAttrs:e=>({href:e.getAttribute("href"),title:e.getAttribute("title")})}],toDOM(e){let{href:t,title:n}=e.attrs;return["a",{href:t,title:n},0]}},em:{parseDOM:[{tag:"i"},{tag:"em"},{style:"font-style=italic"},{style:"font-style=normal",clearMark:e=>"em"==e.type.name}],toDOM:()=>Vs},strong:{parseDOM:[{tag:"strong"},{tag:"b",getAttrs:e=>"normal"!=e.style.fontWeight&&null},{style:"font-weight=400",clearMark:e=>"strong"==e.type.name},{style:"font-weight",getAttrs:e=>/^(bold(er)?|[5-9]\d{2,})$/.test(e)&&null}],toDOM:()=>Fs},code:{code:!0,parseDOM:[{tag:"code"}],toDOM:()=>qs}},_s=new U({nodes:$s,marks:Ls});var Ws=Object.freeze({__proto__:null,marks:Ls,nodes:$s,schema:_s});const Js=["ol",0],js=["ul",0],Ks=["li",0],Hs={attrs:{order:{default:1,validate:"number"}},parseDOM:[{tag:"ol",getAttrs:e=>({order:e.hasAttribute("start")?+e.getAttribute("start"):1})}],toDOM:e=>1==e.attrs.order?Js:["ol",{start:e.attrs.order},0]},Us={parseDOM:[{tag:"ul"}],toDOM:()=>js},Gs={parseDOM:[{tag:"li"}],toDOM:()=>Ks,defining:!0};function Ys(e,t){let n={};for(let t in e)n[t]=e[t];for(let e in t)n[e]=t[e];return n}function Qs(e,t=null){return function(n,r){let{$from:o,$to:i}=n.selection,s=o.blockRange(i);if(!s)return!1;let l=r?n.tr:null;return!!Xs(l,s,e,t)&&(r&&r(l.scrollIntoView()),!0)}}function Xs(e,t,n,r=null){let o=!1,s=t,l=t.$from.doc;if(t.depth>=2&&t.$from.node(t.depth-1).type.compatibleContent(n)&&0==t.startIndex){if(0==t.$from.index(t.depth-1))return!1;let e=l.resolve(t.start-2);s=new N(e,e,t.depth),t.endIndex<t.parent.childCount&&(t=new N(t.$from,l.resolve(t.$to.end(t.depth)),t.depth)),o=!0}let a=Re(s,n,r,t);return!!a&&(e&&function(e,t,n,r,o){let s=i.empty;for(let e=n.length-1;e>=0;e--)s=i.from(n[e].type.create(n[e].attrs,s));e.step(new De(t.start-(r?2:0),t.end,t.start,t.end,new d(s,0,0),n.length,!0));let l=0;for(let e=0;e<n.length;e++)n[e].type==o&&(l=e+1);let a=n.length-l,c=t.start+n.length-(r?2:0),h=t.parent;for(let n=t.startIndex,r=t.endIndex,o=!0;n<r;n++,o=!1)!o&&$e(e.doc,c,a)&&(e.split(c,a),c+=2*a),c+=h.child(n).nodeSize}(e,t,a,o,n),!0)}function Zs(e,t){return function(n,r){let{$from:o,$to:s,node:l}=n.selection;if(l&&l.isBlock||o.depth<2||!o.sameParent(s))return!1;let a=o.node(-1);if(a.type!=e)return!1;if(0==o.parent.content.size&&o.node(-1).childCount==o.indexAfter(-1)){if(3==o.depth||o.node(-3).type!=e||o.index(-2)!=o.node(-2).childCount-1)return!1;if(r){let t=i.empty,s=o.index(-1)?1:o.index(-2)?2:3;for(let e=o.depth-s;e>=o.depth-3;e--)t=i.from(o.node(e).copy(t));let l=o.indexAfter(-1)<o.node(-2).childCount?1:o.indexAfter(-2)<o.node(-3).childCount?2:3;t=t.append(i.from(e.createAndFill()));let a=o.before(o.depth-(s-1)),c=n.tr.replace(a,o.after(-l),new d(t,4-s,0)),h=-1;c.doc.nodesBetween(a,c.doc.content.size,(e,t)=>{if(h>-1)return!1;e.isTextblock&&0==e.content.size&&(h=t+1)}),h>-1&&c.setSelection(st.near(c.doc.resolve(h))),r(c.scrollIntoView())}return!0}let c=s.pos==o.end()?a.contentMatchAt(0).defaultType:null,h=n.tr.delete(o.pos,s.pos),p=c?[t?{type:e,attrs:t}:null,{type:c}]:void 0;return!!$e(h.doc,o.pos,2,p)&&(r&&r(h.split(o.pos,2,p).scrollIntoView()),!0)}}function el(e){return function(t,n){let{$from:r,$to:o}=t.selection,s=r.blockRange(o,t=>t.childCount>0&&t.firstChild.type==e);return!!s&&(!n||(r.node(s.depth-1).type==e?function(e,t,n,r){let o=e.tr,s=r.end,l=r.$to.end(r.depth);s<l&&(o.step(new De(s-1,l,s,l,new d(i.from(n.create(null,r.parent.copy())),1,0),1,!0)),r=new N(o.doc.resolve(r.$from.pos),o.doc.resolve(l),r.depth));const a=Ie(r);if(null==a)return!1;o.lift(r,a);let c=o.doc.resolve(o.mapping.map(s,-1)-1);Ve(o.doc,c.pos)&&c.nodeBefore.type==c.nodeAfter.type&&o.join(c.pos);return t(o.scrollIntoView()),!0}(t,n,e,s):function(e,t,n){let r=e.tr,o=n.parent;for(let e=n.end,t=n.endIndex-1,i=n.startIndex;t>i;t--)e-=o.child(t).nodeSize,r.delete(e-1,e+1);let s=r.doc.resolve(n.start),l=s.nodeAfter;if(r.mapping.map(n.end)!=n.start+s.nodeAfter.nodeSize)return!1;let a=0==n.startIndex,c=n.endIndex==o.childCount,h=s.node(-1),p=s.index(-1);if(!h.canReplace(p+(a?0:1),p+1,l.content.append(c?i.empty:i.from(o))))return!1;let u=s.pos,f=u+l.nodeSize;return r.step(new De(u-(a?1:0),f+(c?1:0),u+1,f-1,new d((a?i.empty:i.from(o.copy(i.empty))).append(c?i.empty:i.from(o.copy(i.empty))),a?0:1,c?0:1),a?0:1)),t(r.scrollIntoView()),!0}(t,n,s)))}}function tl(e){return function(t,n){let{$from:r,$to:o}=t.selection,s=r.blockRange(o,t=>t.childCount>0&&t.firstChild.type==e);if(!s)return!1;let l=s.startIndex;if(0==l)return!1;let a=s.parent,c=a.child(l-1);if(c.type!=e)return!1;if(n){let r=c.lastChild&&c.lastChild.type==a.type,o=i.from(r?e.create():null),l=new d(i.from(e.create(null,i.from(a.type.create(null,o)))),r?3:1,0),h=s.start,p=s.end;n(t.tr.step(new De(h-(r?3:1),p,h,p,l,1,!0)).scrollIntoView())}return!0}}var nl=Object.freeze({__proto__:null,addListNodes:function(e,t,n){return e.append({ordered_list:Ys(Hs,{content:"list_item+",group:n}),bullet_list:Ys(Us,{content:"list_item+",group:n}),list_item:Ys(Gs,{content:t})})},bulletList:Us,liftListItem:el,listItem:Gs,orderedList:Hs,sinkListItem:tl,splitListItem:Zs,splitListItemKeepMarks:function(e,t){let n=Zs(e,t);return(e,t)=>n(e,t&&(n=>{let r=e.storedMarks||e.selection.$to.parentOffset&&e.selection.$from.marks();r&&n.ensureMarks(r),t(n)}))},wrapInList:Qs,wrapRangeInList:Xs});function rl(e={}){return new Mt({view:t=>new ol(t,e)})}class ol{constructor(e,t){var n;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.lastDragEvent=null,this.width=null!==(n=t.width)&&void 0!==n?n:1,this.color=!1===t.color?void 0:t.color||"black",this.class=t.class,this.handlers=["dragover","dragend","drop","dragleave"].map(t=>{let n=e=>{this[t](e)};return e.dom.addEventListener(t,n),{name:t,handler:n}})}destroy(){this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){if(null!=this.cursorPos&&t.doc!=e.state.doc)if(this.lastDragEvent){let e=this.computeTarget(this.lastDragEvent);e==this.cursorPos?this.updateOverlay():this.setCursor(e)}else this.updateOverlay()}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,null==e?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e,t=this.editorView.state.doc.resolve(this.cursorPos),n=!t.parent.inlineContent,r=this.editorView.dom,o=r.getBoundingClientRect(),i=o.width/r.offsetWidth,s=o.height/r.offsetHeight;if(n){let n=t.nodeBefore,r=t.nodeAfter;if(n||r){let t=this.editorView.nodeDOM(this.cursorPos-(n?n.nodeSize:0));if(t){let o=t.getBoundingClientRect(),i=n?o.bottom:o.top;n&&r&&(i=(i+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let l=this.width/2*s;e={left:o.left,right:o.right,top:i-l,bottom:i+l}}}}if(!e){let t=this.editorView.coordsAtPos(this.cursorPos),n=this.width/2*i;e={left:t.left-n,right:t.left+n,top:t.top,bottom:t.bottom}}let l,a,c=this.editorView.dom.offsetParent;if(this.element||(this.element=c.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",n),this.element.classList.toggle("prosemirror-dropcursor-inline",!n),!c||c==document.body&&"static"==getComputedStyle(c).position)l=-pageXOffset,a=-pageYOffset;else{let e=c.getBoundingClientRect(),t=e.width/c.offsetWidth,n=e.height/c.offsetHeight;l=e.left-c.scrollLeft*t,a=e.top-c.scrollTop*n}this.element.style.left=(e.left-l)/i+"px",this.element.style.top=(e.top-a)/s+"px",this.element.style.width=(e.right-e.left)/i+"px",this.element.style.height=(e.bottom-e.top)/s+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}computeTarget(e){let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),n=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),r=n&&n.type.spec.disableDropCursor,o="function"==typeof r?r(this.editorView,t,e):r;if(!t||o)return null;let i=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let e=_e(this.editorView.state.doc,i,this.editorView.dragging.slice);null!=e&&(i=e)}return i}dragover(e){if(!this.editorView.editable)return;this.lastDragEvent=e;let t=this.computeTarget(e);null!=t&&(this.setCursor(t),this.scheduleRemoval(5e3))}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}var il=Object.freeze({__proto__:null,dropCursor:rl});class sl extends st{constructor(e){super(e,e)}map(e,t){let n=e.resolve(t.map(this.head));return sl.valid(n)?new sl(n):st.near(n)}content(){return d.empty}eq(e){return e instanceof sl&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,t){if("number"!=typeof t.pos)throw new RangeError("Invalid input for GapCursor.fromJSON");return new sl(e.resolve(t.pos))}getBookmark(){return new ll(this.anchor)}static valid(e){let t=e.parent;if(t.inlineContent||!function(e){for(let t=e.depth;t>=0;t--){let n=e.index(t),r=e.node(t);if(0!=n)for(let e=r.child(n-1);;e=e.lastChild){if(0==e.childCount&&!e.inlineContent||al(e.type))return!0;if(e.inlineContent)return!1}else if(r.type.spec.isolating)return!0}return!0}(e)||!function(e){for(let t=e.depth;t>=0;t--){let n=e.indexAfter(t),r=e.node(t);if(n!=r.childCount)for(let e=r.child(n);;e=e.firstChild){if(0==e.childCount&&!e.inlineContent||al(e.type))return!0;if(e.inlineContent)return!1}else if(r.type.spec.isolating)return!0}return!0}(e))return!1;let n=t.type.spec.allowGapCursor;if(null!=n)return n;let r=t.contentMatchAt(e.index()).defaultType;return r&&r.isTextblock}static findGapCursorFrom(e,t,n=!1){e:for(;;){if(!n&&sl.valid(e))return e;let r=e.pos,o=null;for(let n=e.depth;;n--){let i=e.node(n);if(t>0?e.indexAfter(n)<i.childCount:e.index(n)>0){o=i.child(t>0?e.indexAfter(n):e.index(n)-1);break}if(0==n)return null;r+=t;let s=e.doc.resolve(r);if(sl.valid(s))return s}for(;;){let i=t>0?o.firstChild:o.lastChild;if(!i){if(o.isAtom&&!o.isText&&!pt.isSelectable(o)){e=e.doc.resolve(r+o.nodeSize*t),n=!1;continue e}break}o=i,r+=t;let s=e.doc.resolve(r);if(sl.valid(s))return s}return null}}}sl.prototype.visible=!1,sl.findFrom=sl.findGapCursorFrom,st.jsonID("gapcursor",sl);class ll{constructor(e){this.pos=e}map(e){return new ll(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return sl.valid(t)?new sl(t):st.near(t)}}function al(e){return e.isAtom||e.spec.isolating||e.spec.createGapCursor}function cl(){return new Mt({props:{decorations:fl,createSelectionBetween:(e,t,n)=>t.pos==n.pos&&sl.valid(n)?new sl(n):null,handleClick:pl,handleKeyDown:hl,handleDOMEvents:{beforeinput:ul}}})}const hl=ci({ArrowLeft:dl("horiz",-1),ArrowRight:dl("horiz",1),ArrowUp:dl("vert",-1),ArrowDown:dl("vert",1)});function dl(e,t){const n="vert"==e?t>0?"down":"up":t>0?"right":"left";return function(e,r,o){let i=e.selection,s=t>0?i.$to:i.$from,l=i.empty;if(i instanceof ht){if(!o.endOfTextblock(n)||0==s.depth)return!1;l=!1,s=e.doc.resolve(t>0?s.after():s.before())}let a=sl.findGapCursorFrom(s,t,l);return!!a&&(r&&r(e.tr.setSelection(new sl(a))),!0)}}function pl(e,t,n){if(!e||!e.editable)return!1;let r=e.state.doc.resolve(t);if(!sl.valid(r))return!1;let o=e.posAtCoords({left:n.clientX,top:n.clientY});return!(o&&o.inside>-1&&pt.isSelectable(e.state.doc.nodeAt(o.inside)))&&(e.dispatch(e.state.tr.setSelection(new sl(r))),!0)}function ul(e,t){if("insertCompositionText"!=t.inputType||!(e.state.selection instanceof sl))return!1;let{$from:n}=e.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(e.state.schema.nodes.text);if(!r)return!1;let o=i.empty;for(let e=r.length-1;e>=0;e--)o=i.from(r[e].createAndFill(null,o));let s=e.state.tr.replace(n.pos,n.pos,new d(o,0,0));return s.setSelection(ht.near(s.doc.resolve(n.pos+1))),e.dispatch(s),!1}function fl(e){if(!(e.selection instanceof sl))return null;let t=document.createElement("div");return t.className="ProseMirror-gapcursor",vo.create(e.doc,[go.widget(e.selection.head,t,{key:"gapcursor"})])}var ml=Object.freeze({__proto__:null,GapCursor:sl,gapCursor:cl});function gl(){var e=arguments[0];"string"==typeof e&&(e=document.createElement(e));var t=1,n=arguments[1];if(n&&"object"==typeof n&&null==n.nodeType&&!Array.isArray(n)){for(var r in n)if(Object.prototype.hasOwnProperty.call(n,r)){var o=n[r];"string"==typeof o?e.setAttribute(r,o):null!=o&&(e[r]=o)}t++}for(;t<arguments.length;t++)yl(e,arguments[t]);return e}function yl(e,t){if("string"==typeof t)e.appendChild(document.createTextNode(t));else if(null==t);else if(null!=t.nodeType)e.appendChild(t);else{if(!Array.isArray(t))throw new RangeError("Unsupported child node: "+t);for(var n=0;n<t.length;n++)yl(e,t[n])}}const wl="http://www.w3.org/2000/svg",vl="ProseMirror-icon";function bl(e,t){let n=(9==e.nodeType?e:e.ownerDocument)||document,r=n.createElement("button");if(r.className=vl,r.type="button",t.path){let{path:o,width:i,height:s}=t,l="pm-icon-"+function(e){let t=0;for(let n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n)|0;return t}(o).toString(16);n.getElementById(l)||function(e,t,n){let[r,o]=9==e.nodeType?[e,e.body]:[e.ownerDocument||document,e],i=r.getElementById(vl+"-collection");i||(i=r.createElementNS(wl,"svg"),i.id=vl+"-collection",i.style.display="none",o.insertBefore(i,o.firstChild));let s=r.createElementNS(wl,"symbol");s.id=t,s.setAttribute("viewBox","0 0 "+n.width+" "+n.height);let l=s.appendChild(r.createElementNS(wl,"path"));l.setAttribute("d",n.path),i.appendChild(s)}(e,l,t);let a=r.appendChild(n.createElementNS(wl,"svg"));a.style.width=i/s+"em",a.appendChild(n.createElementNS(wl,"use")).setAttributeNS("http://www.w3.org/1999/xlink","href",/([^#]*)/.exec(n.location.toString())[1]+"#"+l)}else if(t.dom)r.appendChild(t.dom.cloneNode(!0));else{let{text:e,css:o}=t;r.appendChild(n.createElement("span")).textContent=e||"",o&&(r.firstChild.style.cssText=o)}return r}const kl="ProseMirror-menu";class xl{constructor(e){this.spec=e}render(e){let t=this.spec,n=t.render?t.render(e):t.icon?bl(e.root,t.icon):t.label?gl("button",{type:"button"},Sl(e,t.label)):null;if(!n)throw new RangeError("MenuItem without icon or label property");if(t.title){let r="function"==typeof t.title?t.title(e.state):t.title;n.setAttribute("title",Sl(e,r))}return t.class&&n.classList.add(t.class),t.css&&(n.style.cssText+=t.css),n.addEventListener("click",r=>{if(!n.classList.contains(kl+"-disabled")){let o=document.activeElement==n||document.activeElement==e.dom;t.run(e.state,e.dispatch,e,r),o&&document.activeElement==n&&e.focus()}}),n.addEventListener("mousedown",e=>e.preventDefault()),{dom:n,update:function(e){if(t.select){let r=t.select(e);if(n.style.display=r?"":"none",!r)return!1}let r=!0;if(t.enable&&(r=t.enable(e)||!1,Wl(n,kl+"-disabled",!r),n.setAttribute("aria-disabled",(!r).toString())),t.active){let o=r&&t.active(e)||!1;Wl(n,kl+"-active",o),n.setAttribute("aria-pressed",o.toString())}return!0}}}}function Sl(e,t){return e._props.translate?e._props.translate(t):t}let Cl={time:0,node:null};function Ml(e){Cl.time=Date.now(),Cl.node=e.target}function Ol(e){return Date.now()-100<Cl.time&&Cl.node&&e.contains(Cl.node)}class Nl{constructor(e,t={}){this.options=t,this.focusables=[],this.focusIndex=0,this.focusTimeout=-1,this.options=t||{},this.content=Array.isArray(e)?e:[e]}render(e){let t=El(this.content,e);this.focusables=t.focusables;let n=e.dom.ownerDocument.defaultView||window,r=gl("button",{type:"button",class:kl+"-dropdown "+(this.options.class||""),style:this.options.css,"aria-haspopup":"menu","aria-expanded":"false"},Sl(e,this.options.label||""));this.options.title&&r.setAttribute("title",Sl(e,this.options.title));let o=gl("div",{class:kl+"-dropdown-wrap"},r),i=null,s=null,l=()=>{i&&i.close()&&(i=null,n.removeEventListener("click",s))};return r.addEventListener("click",e=>{if(Ml(e),i)l();else{if(i=this.expand(o,t.dom,r),n.addEventListener("click",s=()=>{Ol(o)||l()}),0===e.detail){let e=Dl(this.focusables,-1,1);null!=e&&this.setFocusIndex(e)}i.node.addEventListener("keydown",e=>{Ml(e),Tl(this,e,"vertical")||"Escape"===e.key&&(e.preventDefault(),e.stopPropagation(),r.focus(),l())}),i.node.addEventListener("focusout",()=>{clearTimeout(this.focusTimeout),this.focusTimeout=setTimeout(()=>{let e=n.document.activeElement;e&&i&&!i.node.contains(e)&&l()},20)})}}),r.addEventListener("mousedown",e=>e.preventDefault()),{dom:o,update:function(e){let n=t.update(e);return o.style.display=n?"":"none",n},focusable:r}}expand(e,t,n){let r=gl("div",{class:kl+"-dropdown-menu "+(this.options.class||"")},t),o=!1;return e.appendChild(r),n.ariaControlsElements=[t],n.setAttribute("aria-expanded","true"),{close:function(){return!o&&(o=!0,e.removeChild(r),n.ariaControlsElements=[],n.setAttribute("aria-expanded","false"),!0)},node:r}}setFocusIndex(e){if(this.focusables.length<=1)return;this.focusables[this.focusIndex].setAttribute("tabindex","-1"),this.focusIndex=e;let t=this.focusables[e];t.setAttribute("tabindex","0"),t.focus()}}function Dl(e,t,n){let r=e.length;for(let o=0,i=t+n;;i+=n,o++){let t=(i+r)%r;if("none"!=e[t].style.display)return t;if(o==r)return null}}function Tl(e,t,n){let{focusables:r,focusIndex:o}=e,i=t.key==("vertical"==n?"ArrowDown":"ArrowRight")?Dl(r,o,1):t.key==("vertical"==n?"ArrowUp":"ArrowLeft")?Dl(r,o,-1):"Home"==t.key?Dl(r,-1,1):"End"==t.key?Dl(r,r.length,-1):null;return null!=i&&(t.preventDefault(),t.stopPropagation(),e.setFocusIndex(i),!0)}function El(e,t){let n=[],r=[],o=[];for(let i=0;i<e.length;i++){let s=e[i],{dom:l,update:a,focusable:c}=s.render(t);n.push(gl("li",{class:`${kl}-dropdown-item`,role:"menuitem",tabindex:"-1"},l)),r.push(c||l),o.push(a)}return{dom:gl("ul",{role:"menu"},n),update:function(e){let t=!1;for(let r=0;r<n.length;r++){let i=n[r],s=o[r](e);s&&(t=!0),i.style.display=s?"":"none"}return t},focusables:r}}function Al(e,t){return n=>{let r=!1;for(let o=0;o<e.length;o++){let i=e[o](n);t[o].style.display=i?"":"none",i&&(r=!0)}return r}}class Il{constructor(e,t={}){this.options=t,this.focusables=[],this.focusIndex=0,this.focusTimeout=-1,this.content=Array.isArray(e)?e:[e]}render(e){let t=El(this.content,e);this.focusables=t.focusables;let n=e.dom.ownerDocument.defaultView||window,r=gl("button",{type:"button",class:kl+"-submenu-label"},Sl(e,this.options.label||"")),o=gl("div",{class:kl+"-submenu-wrap"},r,gl("div",{class:kl+"-submenu"},t.dom)),i=null,s=e=>{if(e.preventDefault(),e.stopPropagation(),Ml(e),Wl(o,kl+"-submenu-wrap-active",!0),i||n.addEventListener("click",i=()=>{Ol(o)||(o.classList.remove(kl+"-submenu-wrap-active"),n.removeEventListener("click",i),i=null)}),"click"!=e.type||!e.detail){let e=Dl(this.focusables,-1,1);null!=e&&this.setFocusIndex(e)}};return r.addEventListener("click",s),r.addEventListener("keydown",e=>{"ArrowRight"===e.key&&s(e)}),r.addEventListener("mousedown",e=>e.preventDefault()),t.dom.addEventListener("keydown",e=>{Ml(e),Tl(this,e,"vertical")||"Escape"!==e.key&&"ArrowLeft"!==e.key||(e.preventDefault(),e.stopPropagation(),Wl(o,kl+"-submenu-wrap-active",!1),r.focus())}),t.dom.addEventListener("focusout",()=>{clearTimeout(this.focusTimeout),this.focusTimeout=setTimeout(()=>{let e=n.document.activeElement;e&&!t.dom.contains(e)&&o.classList.remove(kl+"-submenu-wrap-active")},20)}),{dom:o,update:function(e){let n=t.update(e);return o.style.display=n?"":"none",n},focusable:r}}setFocusIndex(e){if(this.focusables.length<=1)return;this.focusables[this.focusIndex].setAttribute("tabindex","-1"),this.focusIndex=e;let t=this.focusables[e];t.setAttribute("tabindex","0"),t.focus()}}function Rl(e,t){let n=document.createDocumentFragment(),r=[],o=[],i=[];for(let s=0;s<t.length;s++){let l=t[s],a=[],c=[];for(let t=0;t<l.length;t++){let{dom:r,update:i,focusable:s}=l[t].render(e);o.push(s||r);let h=gl("span",{class:kl+"item"},r);n.appendChild(h),c.push(h),a.push(i)}a.length&&(r.push(Al(a,c)),s<t.length-1&&i.push(n.appendChild(zl())))}return{dom:n,update:function(e){let t=!1,n=!1;for(let o=0;o<r.length;o++){let s=r[o](e);o&&(i[o-1].style.display=n&&s?"":"none"),n=s,s&&(t=!0)}return t},focusables:o}}function zl(){return gl("span",{class:kl+"separator",role:"separator"})}const Pl={join:{width:800,height:900,path:"M0 75h800v125h-800z M0 825h800v-125h-800z M250 400h100v-100h100v100h100v100h-100v100h-100v-100h-100z"},lift:{width:1024,height:1024,path:"M219 310v329q0 7-5 12t-12 5q-8 0-13-5l-164-164q-5-5-5-13t5-13l164-164q5-5 13-5 7 0 12 5t5 12zM1024 749v109q0 7-5 12t-12 5h-987q-7 0-12-5t-5-12v-109q0-7 5-12t12-5h987q7 0 12 5t5 12zM1024 530v109q0 7-5 12t-12 5h-621q-7 0-12-5t-5-12v-109q0-7 5-12t12-5h621q7 0 12 5t5 12zM1024 310v109q0 7-5 12t-12 5h-621q-7 0-12-5t-5-12v-109q0-7 5-12t12-5h621q7 0 12 5t5 12zM1024 91v109q0 7-5 12t-12 5h-987q-7 0-12-5t-5-12v-109q0-7 5-12t12-5h987q7 0 12 5t5 12z"},selectParentNode:{text:"⬚",css:"font-weight: bold"},undo:{width:1024,height:1024,path:"M761 1024c113-206 132-520-313-509v253l-384-384 384-384v248c534-13 594 472 313 775z"},redo:{width:1024,height:1024,path:"M576 248v-248l384 384-384 384v-253c-446-10-427 303-313 509-280-303-221-789 313-775z"},strong:{width:805,height:1024,path:"M317 869q42 18 80 18 214 0 214-191 0-65-23-102-15-25-35-42t-38-26-46-14-48-6-54-1q-41 0-57 5 0 30-0 90t-0 90q0 4-0 38t-0 55 2 47 6 38zM309 442q24 4 62 4 46 0 81-7t62-25 42-51 14-81q0-40-16-70t-45-46-61-24-70-8q-28 0-74 7 0 28 2 86t2 86q0 15-0 45t-0 45q0 26 0 39zM0 950l1-53q8-2 48-9t60-15q4-6 7-15t4-19 3-18 1-21 0-19v-37q0-561-12-585-2-4-12-8t-25-6-28-4-27-2-17-1l-2-47q56-1 194-6t213-5q13 0 39 0t38 0q40 0 78 7t73 24 61 40 42 59 16 78q0 29-9 54t-22 41-36 32-41 25-48 22q88 20 146 76t58 141q0 57-20 102t-53 74-78 48-93 27-100 8q-25 0-75-1t-75-1q-60 0-175 6t-132 6z"},em:{width:585,height:1024,path:"M0 949l9-48q3-1 46-12t63-21q16-20 23-57 0-4 35-165t65-310 29-169v-14q-13-7-31-10t-39-4-33-3l10-58q18 1 68 3t85 4 68 1q27 0 56-1t69-4 56-3q-2 22-10 50-17 5-58 16t-62 19q-4 10-8 24t-5 22-4 26-3 24q-15 84-50 239t-44 203q-1 5-7 33t-11 51-9 47-3 32l0 10q9 2 105 17-1 25-9 56-6 0-18 0t-18 0q-16 0-49-5t-49-5q-78-1-117-1-29 0-81 5t-69 6z"},code:{width:896,height:1024,path:"M608 192l-96 96 224 224-224 224 96 96 288-320-288-320zM288 192l-288 320 288 320 96-96-224-224 224-224-96-96z"},link:{width:951,height:1024,path:"M832 694q0-22-16-38l-118-118q-16-16-38-16-24 0-41 18 1 1 10 10t12 12 8 10 7 14 2 15q0 22-16 38t-38 16q-8 0-15-2t-14-7-10-8-12-12-10-10q-18 17-18 41 0 22 16 38l117 118q15 15 38 15 22 0 38-14l84-83q16-16 16-38zM430 292q0-22-16-38l-117-118q-16-16-38-16-22 0-38 15l-84 83q-16 16-16 38 0 22 16 38l118 118q15 15 38 15 24 0 41-17-1-1-10-10t-12-12-8-10-7-14-2-15q0-22 16-38t38-16q8 0 15 2t14 7 10 8 12 12 10 10q18-17 18-41zM941 694q0 68-48 116l-84 83q-47 47-116 47-69 0-116-48l-117-118q-47-47-47-116 0-70 50-119l-50-50q-49 50-118 50-68 0-116-48l-118-118q-48-48-48-116t48-116l84-83q47-47 116-47 69 0 116 48l117 118q47 47 47 116 0 70-50 119l50 50q49-50 118-50 68 0 116 48l118 118q48 48 48 116z"},bulletList:{width:768,height:896,path:"M0 512h128v-128h-128v128zM0 256h128v-128h-128v128zM0 768h128v-128h-128v128zM256 512h512v-128h-512v128zM256 256h512v-128h-512v128zM256 768h512v-128h-512v128z"},orderedList:{width:768,height:896,path:"M320 512h448v-128h-448v128zM320 768h448v-128h-448v128zM320 128v128h448v-128h-448zM79 384h78v-256h-36l-85 23v50l43-2v185zM189 590c0-36-12-78-96-78-33 0-64 6-83 16l1 66c21-10 42-15 67-15s32 11 32 28c0 26-30 58-110 112v50h192v-67l-91 2c49-30 87-66 87-113l1-1z"},blockquote:{width:640,height:896,path:"M0 448v256h256v-256h-128c0 0 0-128 128-128v-128c0 0-256 0-256 256zM640 320v-128c0 0-256 0-256 256v256h256v-256h-128c0 0 0-128 128-128z"}},Bl=new xl({title:"Join with above block",run:is,select:e=>is(e),icon:Pl.join}),$l=new xl({title:"Lift out of enclosing block",run:ls,select:e=>ls(e),icon:Pl.lift}),Vl=new xl({title:"Select parent node",run:ms,select:e=>ms(e),icon:Pl.selectParentNode});let Fl=new xl({title:"Undo last change",run:_i,enable:e=>_i(e),icon:Pl.undo}),ql=new xl({title:"Redo last undone change",run:Wi,enable:e=>Wi(e),icon:Pl.redo});function Ll(e,t){let n={run:(n,r)=>ks(e,t.attrs)(n,r),select:n=>ks(e,t.attrs)(n)};for(let e in t)n[e]=t[e];return new xl(n)}function _l(e,t){let n=xs(e,t.attrs),r={run:n,enable:e=>n(e),active(n){let{$from:r,to:o,node:i}=n.selection;return i?i.hasMarkup(e,t.attrs):o<=r.end()&&r.parent.hasMarkup(e,t.attrs)}};for(let e in t)r[e]=t[e];return new xl(r)}function Wl(e,t,n){n?e.classList.add(t):e.classList.remove(t)}const Jl="ProseMirror-menubar";function jl(e){return new Mt({view:t=>new Kl(t,e)})}class Kl{constructor(e,t){this.editorView=e,this.options=t,this.focusables=[],this.focusIndex=0,this.spacer=null,this.maxHeight=0,this.widthForMaxHeight=0,this.floating=!1,this.scrollHandler=null,this.root=e.root,this.wrapper=gl("div",{class:Jl+"-wrapper"}),this.menu=this.wrapper.appendChild(gl("div",{class:Jl,role:"toolbar"})),this.menu.className=Jl,this.menu.ariaControlsElements=[e.dom],e.dom.parentNode&&e.dom.parentNode.replaceChild(this.wrapper,e.dom),"after"===t.position?this.wrapper.insertBefore(e.dom,this.wrapper.firstChild):this.wrapper.appendChild(e.dom);let{dom:n,update:r,focusables:o}=Rl(this.editorView,this.options.content);if(this.contentUpdate=r,this.focusables=o,this.menu.appendChild(n),t.floating&&!function(){if("undefined"==typeof navigator)return!1;let e=navigator.userAgent;return!/Edge\/\d/.test(e)&&/AppleWebKit/.test(e)&&/Mobile\/\w+/.test(e)}()){this.updateFloat();let e=function(e){let t=[e.ownerDocument.defaultView||window];for(let n=e.parentNode;n;n=n.parentNode)t.push(n);return t}(this.wrapper);this.scrollHandler=t=>{let n=this.editorView.root;(n.body||n).contains(this.wrapper)?this.updateFloat(t.target.getBoundingClientRect?t.target:void 0):e.forEach(e=>e.removeEventListener("scroll",this.scrollHandler))},e.forEach(e=>e.addEventListener("scroll",this.scrollHandler))}for(let e=0;e<o.length;e++){let t=o[e];e&&t.setAttribute("tabindex","-1"),t.addEventListener("focus",()=>{if(this.focusIndex===e)return;this.focusables[this.focusIndex].setAttribute("tabindex","-1"),t.setAttribute("tabindex","0"),this.focusIndex=e})}this.menu.addEventListener("keydown",e=>{Tl(this,e,"horizontal")}),this.update()}setFocusIndex(e){if(this.focusables.length<=1)return;this.focusables[this.focusIndex].setAttribute("tabindex","-1"),this.focusIndex=e;let t=this.focusables[e];t.setAttribute("tabindex","0"),t.focus()}update(){if(this.editorView.root!=this.root){let{dom:e,update:t}=Rl(this.editorView,this.options.content);this.contentUpdate=t,this.menu.replaceChild(e,this.menu.firstChild),this.root=this.editorView.root}let e=this.editorView.dom.ownerDocument.activeElement==this.focusables[this.focusIndex];if(this.contentUpdate(this.editorView.state),e&&"none"==this.focusables[this.focusIndex].style.display){let e=Dl(this.focusables,this.focusIndex,1);null!=e&&this.setFocusIndex(e)}this.floating?this.updateScrollCursor():(this.menu.offsetWidth!=this.widthForMaxHeight&&(this.widthForMaxHeight=this.menu.offsetWidth,this.maxHeight=0),this.menu.offsetHeight>this.maxHeight&&(this.maxHeight=this.menu.offsetHeight,this.menu.style.minHeight=this.maxHeight+"px"))}updateScrollCursor(){let e=this.editorView.root.getSelection();if(!e.focusNode)return;let t=e.getRangeAt(0).getClientRects(),n=t[function(e){return e.anchorNode==e.focusNode?e.anchorOffset>e.focusOffset:e.anchorNode.compareDocumentPosition(e.focusNode)==Node.DOCUMENT_POSITION_FOLLOWING}(e)?0:t.length-1];if(!n)return;let r=this.menu.getBoundingClientRect();if(n.top<r.bottom&&n.bottom>r.top){let e=function(e){for(let t=e.parentNode;t;t=t.parentNode)if(t.scrollHeight>t.clientHeight)return t}(this.wrapper);e&&(e.scrollTop-=r.bottom-n.top)}}updateFloat(e){let t=this.wrapper,n=t.getBoundingClientRect(),r=e?Math.max(0,e.getBoundingClientRect().top):0;if(this.floating)if(n.top>=r||n.bottom<this.menu.offsetHeight+10)this.floating=!1,this.menu.style.position=this.menu.style.left=this.menu.style.top=this.menu.style.width="",this.menu.style.display="",this.spacer.parentNode.removeChild(this.spacer),this.spacer=null;else{let o=(t.offsetWidth-t.clientWidth)/2;this.menu.style.left=n.left+o+"px",this.menu.style.display=n.top>(this.editorView.dom.ownerDocument.defaultView||window).innerHeight?"none":"",e&&(this.menu.style.top=r+"px")}else if(n.top<r&&n.bottom>=this.menu.offsetHeight+10){this.floating=!0;let n=this.menu.getBoundingClientRect();this.menu.style.left=n.left+"px",this.menu.style.width=n.width+"px",e&&(this.menu.style.top=r+"px"),this.menu.style.position="fixed",this.spacer=gl("div",{class:Jl+"-spacer",style:`height: ${n.height}px`}),t.insertBefore(this.spacer,this.menu)}}destroy(){this.wrapper.parentNode&&this.wrapper.parentNode.replaceChild(this.editorView.dom,this.wrapper)}}var Hl=Object.freeze({__proto__:null,Dropdown:Nl,DropdownSubmenu:Il,MenuItem:xl,blockTypeItem:_l,icons:Pl,joinUpItem:Bl,liftItem:$l,menuBar:jl,redoItem:ql,renderGrouped:Rl,selectParentNodeItem:Vl,undoItem:Fl,wrapItem:Ll});const Ul="ProseMirror-prompt";function Gl(e){let t=document.body.appendChild(document.createElement("div"));t.className=Ul;let n=e=>{t.contains(e.target)||r()};setTimeout(()=>window.addEventListener("mousedown",n),50);let r=()=>{window.removeEventListener("mousedown",n),t.parentNode&&t.parentNode.removeChild(t)},o=[];for(let t in e.fields)o.push(e.fields[t].render());let i=document.createElement("button");i.type="submit",i.className=Ul+"-submit",i.textContent="OK";let s=document.createElement("button");s.type="button",s.className=Ul+"-cancel",s.textContent="Cancel",s.addEventListener("click",r);let l=t.appendChild(document.createElement("form"));e.title&&(l.appendChild(document.createElement("h5")).textContent=e.title),o.forEach(e=>{l.appendChild(document.createElement("div")).appendChild(e)});let a=l.appendChild(document.createElement("div"));a.className=Ul+"-buttons",a.appendChild(i),a.appendChild(document.createTextNode(" ")),a.appendChild(s);let c=t.getBoundingClientRect();t.style.top=(window.innerHeight-c.height)/2+"px",t.style.left=(window.innerWidth-c.width)/2+"px";let h=()=>{let t=function(e,t){let n=Object.create(null),r=0;for(let o in e){let i=e[o],s=t[r++],l=i.read(s),a=i.validate(l);if(a)return Yl(s,a),null;n[o]=i.clean(l)}return n}(e.fields,o);t&&(r(),e.callback(t))};l.addEventListener("submit",e=>{e.preventDefault(),h()}),l.addEventListener("keydown",e=>{27==e.keyCode?(e.preventDefault(),r()):13!=e.keyCode||e.ctrlKey||e.metaKey||e.shiftKey?9==e.keyCode&&window.setTimeout(()=>{t.contains(document.activeElement)||r()},500):(e.preventDefault(),h())});let d=l.elements[0];d&&d.focus()}function Yl(e,t){let n=e.parentNode,r=n.appendChild(document.createElement("div"));r.style.left=e.offsetLeft+e.offsetWidth+2+"px",r.style.top=e.offsetTop-5+"px",r.className="ProseMirror-invalid",r.textContent=t,setTimeout(()=>n.removeChild(r),1500)}class Ql{constructor(e){this.options=e}read(e){return e.value}validateType(e){return null}validate(e){return!e&&this.options.required?"Required field":this.validateType(e)||(this.options.validate?this.options.validate(e):null)}clean(e){return this.options.clean?this.options.clean(e):e}}class Xl extends Ql{render(){let e=document.createElement("input");return e.type="text",e.placeholder=this.options.label,e.value=this.options.value||"",e.autocomplete="off",e}}function Zl(e,t){let n=e.selection.$from;for(let e=n.depth;e>=0;e--){let r=n.index(e);if(n.node(e).canReplaceWith(r,r,t))return!0}return!1}function ea(e,t){let n={label:t.title,run:e};for(let e in t)n[e]=t[e];return t.enable||t.select||(n[t.enable?"enable":"select"]=t=>e(t)),new xl(n)}function ta(e,t){let{from:n,$from:r,to:o,empty:i}=e.selection;return i?!!t.isInSet(e.storedMarks||r.marks()):e.doc.rangeHasMark(n,o,t)}function na(e,t){let n={active:t=>ta(t,e)};for(let e in t)n[e]=t[e];return ea(Ss(e),n)}function ra(e,t){return ea(Qs(e,t.attrs),t)}function oa(e){let t,n={};var r;let o;var i;if((t=e.marks.strong)&&(n.toggleStrong=na(t,{title:"Toggle strong style",icon:Pl.strong})),(t=e.marks.em)&&(n.toggleEm=na(t,{title:"Toggle emphasis",icon:Pl.em})),(t=e.marks.code)&&(n.toggleCode=na(t,{title:"Toggle code font",icon:Pl.code})),(t=e.marks.link)&&(n.toggleLink=(r=t,new xl({title:"Add or remove link",icon:Pl.link,active:e=>ta(e,r),enable:e=>!e.selection.empty,run(e,t,n){if(ta(e,r))return Ss(r)(e,t),!0;Gl({title:"Create a link",fields:{href:new Xl({label:"Link target",required:!0}),title:new Xl({label:"Title"})},callback(e){Ss(r,e)(n.state,n.dispatch),n.focus()}})}}))),(o=e.nodes.image)&&(n.insertImage=(i=o,new xl({title:"Insert image",label:"Image",enable:e=>Zl(e,i),run(e,t,n){let{from:r,to:o}=e.selection,s=null;e.selection instanceof pt&&e.selection.node.type==i&&(s=e.selection.node.attrs),Gl({title:"Insert image",fields:{src:new Xl({label:"Location",required:!0,value:s&&s.src}),title:new Xl({label:"Title",value:s&&s.title}),alt:new Xl({label:"Description",value:s?s.alt:e.doc.textBetween(r,o," ")})},callback(e){n.dispatch(n.state.tr.replaceSelectionWith(i.createAndFill(e))),n.focus()}})}}))),(o=e.nodes.bullet_list)&&(n.wrapBulletList=ra(o,{title:"Wrap in bullet list",icon:Pl.bulletList})),(o=e.nodes.ordered_list)&&(n.wrapOrderedList=ra(o,{title:"Wrap in ordered list",icon:Pl.orderedList})),(o=e.nodes.blockquote)&&(n.wrapBlockQuote=Ll(o,{title:"Wrap in block quote",icon:Pl.blockquote})),(o=e.nodes.paragraph)&&(n.makeParagraph=_l(o,{title:"Change to paragraph",label:"Plain"})),(o=e.nodes.code_block)&&(n.makeCodeBlock=_l(o,{title:"Change to code block",label:"Code"})),o=e.nodes.heading)for(let e=1;e<=10;e++)n["makeHead"+e]=_l(o,{title:"Change to heading "+e,label:"Level "+e,attrs:{level:e}});if(o=e.nodes.horizontal_rule){let e=o;n.insertHorizontalRule=new xl({title:"Insert horizontal rule",label:"Horizontal rule",enable:t=>Zl(t,e),run(t,n){n(t.tr.replaceSelectionWith(e.create()))}})}let s=e=>e.filter(e=>e);return n.insertMenu=new Nl(s([n.insertImage,n.insertHorizontalRule]),{label:"Insert"}),n.typeMenu=new Nl(s([n.makeParagraph,n.makeCodeBlock,n.makeHead1&&new Il(s([n.makeHead1,n.makeHead2,n.makeHead3,n.makeHead4,n.makeHead5,n.makeHead6]),{label:"Heading"})]),{label:"Type..."}),n.inlineMenu=[s([n.toggleStrong,n.toggleEm,n.toggleCode,n.toggleLink])],n.blockMenu=[s([n.wrapBulletList,n.wrapOrderedList,n.wrapBlockQuote,Bl,$l,Vl])],n.fullMenu=n.inlineMenu.concat([[n.insertMenu,n.typeMenu]],[[Fl,ql]],n.blockMenu),n}const ia="undefined"!=typeof navigator&&/Mac|iP(hone|[oa]d)/.test(navigator.platform);function sa(e,t){let n,r={};function o(e,n){if(t){let n=t[e];if(!1===n)return;n&&(e=n)}r[e]=n}if(o("Mod-z",_i),o("Shift-Mod-z",Wi),o("Backspace",fi),ia||o("Mod-y",Wi),o("Alt-ArrowUp",is),o("Alt-ArrowDown",ss),o("Mod-BracketLeft",ls),o("Escape",ms),(n=e.marks.strong)&&(o("Mod-b",Ss(n)),o("Mod-B",Ss(n))),(n=e.marks.em)&&(o("Mod-i",Ss(n)),o("Mod-I",Ss(n))),(n=e.marks.code)&&o("Mod-`",Ss(n)),(n=e.nodes.bullet_list)&&o("Shift-Ctrl-8",Qs(n)),(n=e.nodes.ordered_list)&&o("Shift-Ctrl-9",Qs(n)),(n=e.nodes.blockquote)&&o("Ctrl->",ks(n)),n=e.nodes.hard_break){let e=n,t=Ms(hs,(t,n)=>(n&&n(t.tr.replaceSelectionWith(e.create()).scrollIntoView()),!0));o("Mod-Enter",t),o("Shift-Enter",t),ia&&o("Ctrl-Enter",t)}if((n=e.nodes.list_item)&&(o("Enter",Zs(n)),o("Mod-[",el(n)),o("Mod-]",tl(n))),(n=e.nodes.paragraph)&&o("Shift-Ctrl-0",xs(n)),(n=e.nodes.code_block)&&o("Shift-Ctrl-\\",xs(n)),n=e.nodes.heading)for(let e=1;e<=6;e++)o("Shift-Ctrl-"+e,xs(n,{level:e}));if(n=e.nodes.horizontal_rule){let e=n;o("Mod-_",(t,n)=>(n&&n(t.tr.replaceSelectionWith(e.create()).scrollIntoView()),!0))}return r}function la(e){let t,n=ki.concat(gi,mi);return(t=e.nodes.blockquote)&&n.push(xi(/^\s*>\s$/,t)),(t=e.nodes.ordered_list)&&n.push(function(e){return xi(/^(\d+)\.\s$/,e,e=>({order:+e[1]}),(e,t)=>t.childCount+t.attrs.order==+e[1])}(t)),(t=e.nodes.bullet_list)&&n.push(function(e){return xi(/^\s*([-+*])\s$/,e)}(t)),(t=e.nodes.code_block)&&n.push(function(e){return Si(/^```$/,e)}(t)),(t=e.nodes.heading)&&n.push(function(e,t){return Si(new RegExp("^(#{1,"+t+"})\\s$"),e,e=>({level:e[1].length}))}(t,6)),pi({rules:n})}var aa=Object.freeze({__proto__:null,buildInputRules:la,buildKeymap:sa,buildMenuItems:oa,exampleSetup:function(e){let t=[la(e.schema),ai(sa(e.schema,e.mapKeys)),ai(Es),rl(),cl()];return!1!==e.menuBar&&t.push(jl({floating:!1!==e.floatingMenu,content:e.menuContent||oa(e.schema).fullMenu})),!1!==e.history&&t.push(qi()),t.concat(new Mt({props:{attributes:{class:"ProseMirror-example-setup-style"}}}))}});window.PM={model:pe,transform:ot,state:Tt,view:Qo,keymap:hi,inputrules:Ci,history:Ki,commands:As,schema_basic:Ws,schema_list:nl,dropcursor:il,menu:Hl,example_setup:aa,gapcursor:ml}}();
</script>
<script>
(function (prosemirrorState, prosemirrorView, prosemirrorModel, prosemirrorSchemaBasic, prosemirrorSchemaList, prosemirrorExampleSetup) {
'use strict';
// code{
// Mix the nodes from prosemirror-schema-list into the basic schema to
// create a schema with list support.
const mySchema = new prosemirrorModel.Schema({
nodes: prosemirrorSchemaList.addListNodes(prosemirrorSchemaBasic.schema.spec.nodes, "paragraph block*", "block"),
marks: prosemirrorSchemaBasic.schema.spec.marks
});
window.view = new prosemirrorView.EditorView(document.querySelector("#editor"), {
state: prosemirrorState.EditorState.create({
doc: prosemirrorModel.DOMParser.fromSchema(mySchema).parse(document.querySelector("#content")),
plugins: prosemirrorExampleSetup.exampleSetup({schema: mySchema})
})
});
// }
})(PM.state, PM.view, PM.model, PM.schema_basic, PM.schema_list, PM.example_setup);
</script></article>
<footer>
<nav>
<a class=logo href="."> </a>
<div class=navlinks>
<a href="/backers.html">Backers</a>
<a href="http://contributor-covenant.org/version/1/1/0/">Code of Conduct</a>
<a href="https://discuss.prosemirror.net/">Discuss</a>
<a href="https://code.haverbeke.berlin/prosemirror/prosemirror/issues">Report an Issue</a>
</div>
</nav>
</footer>
</html>