@alxgrn/prose-editor 0.0.41 → 0.0.42
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.css +1 -1
- package/dist/prose-editor.umd.js +15 -15
- package/package.json +1 -1
package/dist/prose-editor.umd.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(G,m){typeof exports=="object"&&typeof module<"u"?m(exports,require("react"),require("react-dom"),require("@alxgrn/telefrag-ui")):typeof define=="function"&&define.amd?define(["exports","react","react-dom","@alxgrn/telefrag-ui"],m):(G=typeof globalThis<"u"?globalThis:G||self,m(G.ProseEditor={},G.React,G.ReactDOM,G["@alxgrn/telefrag-ui"]))})(this,function(G,m,Ye,N){"use strict";var D0=Object.defineProperty;var O0=(G,m,Ye)=>m in G?D0(G,m,{enumerable:!0,configurable:!0,writable:!0,value:Ye}):G[m]=Ye;var j=(G,m,Ye)=>O0(G,typeof m!="symbol"?m+"":m,Ye);var di=document.createElement("style");di.textContent=`placeholder.ProseMirror-widget{display:flex;align-items:center;justify-content:center;margin:var(--alxgrn-unit) auto;border-radius:var(--alxgrn-unit-small);width:100%;height:200px;background-color:var(--alxgrn-logo-color-beige);font-style:normal;font-weight:400;font-size:var(--alxgrn-font-size)}placeholder.ProseMirror-widget:after{content:"Загрузка..."}div.carousel div.carousel-list span{display:block;scroll-snap-align:start;flex:0 0 auto;width:100%;margin:0}div.carousel placeholder.ProseMirror-widget{height:unset;aspect-ratio:16 / 9;margin:0}.MenuItem{display:flex;align-items:center;justify-content:center;cursor:pointer;padding:var(--alxgrn-unit-smallest)}.MenuItem.active{background:var(--alxgrn-bg-accent);border-radius:var(--alxgrn-unit-smallest)}.MenuItem.disabled{cursor:default;opacity:.3}.MenuBlock{flex:0 0 auto;display:flex;align-items:center;gap:var(--alxgrn-unit-small);border-right:1px solid var(--alxgrn-border);padding-right:var(--alxgrn-unit-small)}.MenuBlock:last-child{border-right:none;padding-right:0;flex:1 1 auto;justify-content:flex-end}.SimpleMenuBar{display:flex;align-items:center;gap:var(--alxgrn-unit-small);flex-wrap:wrap;padding:var(--alxgrn-unit-small)}.ProseMirror{position:relative;outline:none;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}.ProseMirror li{position:relative}.ProseMirror-hideselection *::selection{background:transparent}.ProseMirror-hideselection *::-moz-selection{background:transparent}.ProseMirror-hideselection{caret-color:transparent}.ProseMirror [draggable][contenteditable=false]{-webkit-user-select:text;user-select:text}.ProseMirror-selectednode{outline:2px solid #8cf;border-radius:var(--alxgrn-unit-half)}li.ProseMirror-selectednode{outline:none}li.ProseMirror-selectednode:after{content:"";position:absolute;left:calc(-2px - var(--alxgrn-unit-double));right:-2px;top:-2px;bottom:-2px;border:2px solid #8cf;pointer-events:none;border-radius:var(--alxgrn-unit-half)}.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,.ProseViewer{display:block}.ProseViewer .unknown_node_type{display:block;color:red}.ProseNotes p,.ProseEditor p,.ProseViewer p{margin:var(--alxgrn-unit) 0;padding:0}.ProseNotes p:first-child,.ProseEditor p:first-child,.ProseViewer p:first-child{margin-top:0}.ProseNotes p:last-child,.ProseEditor p:last-child,.ProseViewer p:last-child{margin-bottom:0}.ProseNotes ul,.ProseEditor ul,.ProseViewer ul,.ProseNotes ol,.ProseEditor ol,.ProseViewer ol{margin:var(--alxgrn-unit) 0;padding:0}.ProseNotes li,.ProseEditor li,.ProseViewer li{padding:0;margin:0;margin-left:var(--alxgrn-unit-double)}.ProseNotes blockquote,.ProseEditor blockquote,.ProseViewer blockquote{display:block;margin:0;border-left:var(--alxgrn-unit-small) solid var(--alxgrn-color-accent);margin:var(--alxgrn-unit) 0;padding:var(--alxgrn-unit-half);border-radius:var(--alxgrn-unit-small);background-color:var(--alxgrn-bg-accent)}.ProseNotes div.image,.ProseEditor div.image,.ProseViewer div.image,.ProseNotes div.video,.ProseEditor div.video,.ProseViewer div.video{display:block;margin:var(--alxgrn-unit) auto;text-align:center;position:relative}.ProseViewer div.video .video-switcher,.ProseEditor div.video .video-switcher,.ProseNotes div.video .video-switcher{position:absolute;display:flex;gap:var(--alxgrn-unit-small);margin:var(--alxgrn-unit-small);z-index:10}.ProseViewer div.video .video-switcher div,.ProseEditor div.video .video-switcher div,.ProseNotes div.video .video-switcher div{padding:0 var(--alxgrn-unit);font-style:normal;font-size:var(--alxgrn-font-size-small);color:var(--alxgrn-button-color);background-color:var(--alxgrn-button-bg);border-radius:var(--alxgrn-unit-small);cursor:pointer;height:var(--alxgrn-unit-double);opacity:.9;display:flex;align-items:center;justify-content:center}.ProseViewer div.video .video-switcher div.active,.ProseEditor div.video .video-switcher div.active,.ProseNotes div.video .video-switcher div.active{background-color:var(--alxgrn-button-bg-accent)}.ProseViewer div.video .video-switcher div:hover,.ProseEditor div.video .video-switcher div:hover,.ProseNotes div.video .video-switcher div:hover{opacity:1}.ProseViewer div.video .video-title,.ProseEditor div.video .video-title,.ProseNotes div.video .video-title{font-style:italic;display:block;width:80%;margin:0 auto}.ProseNotes div.image img,.ProseEditor div.image img,.ProseViewer div.image img,.ProseNotes div.video img,.ProseEditor div.video img,.ProseViewer div.video img{display:block;border-radius:var(--alxgrn-unit-half);max-width:100%;max-height:75vh;margin:0 auto}.ProseViewer div.image .image-title,.ProseEditor div.image .image-title,.ProseNotes div.image .image-title{font-style:italic;display:block;width:80%;margin:0 auto}.ProseViewer div.image img{cursor:pointer}.ProseViewer div.image:fullscreen{background-color:#000;border-radius:0;display:flex;justify-content:center;align-items:center}.ProseViewer div.image:fullscreen .image-title{display:none}.ProseViewer div.image:fullscreen img{border-radius:0;max-width:100%;max-height:100%}.ProseEditor div.image div.image-buttons{position:absolute;gap:var(--alxgrn-unit-small);top:0;right:0;width:auto;margin:var(--alxgrn-unit-small);display:flex;align-items:stretch;justify-content:stretch}.ProseEditor div.carousel div.carousel-buttons{z-index:10;position:absolute;gap:var(--alxgrn-unit-small);top:0;left:0;width:auto;margin:var(--alxgrn-unit-small);display:flex;align-items:stretch;justify-content:stretch}.ProseViewer div.image div.image-full,.ProseEditor div.image div.image-buttons div,.ProseEditor div.carousel div.carousel-buttons div{display:flex;align-items:center;justify-content:center;color:var(--alxgrn-button-color);background-color:var(--alxgrn-button-bg);border-radius:var(--alxgrn-unit-small);cursor:pointer;height:var(--alxgrn-unit-double);width:var(--alxgrn-unit-double);padding:0;opacity:.9;z-index:10}.ProseViewer div.image div.image-full{position:absolute;top:var(--alxgrn-unit-half);right:var(--alxgrn-unit-half)}.ProseViewer div.image div.image-full:hover{opacity:1}.ProseEditor div.image div.image-buttons div.text-button,.ProseEditor div.carousel div.carousel-buttons div.text-button{width:unset;padding:0 var(--alxgrn-unit);font-style:normal;font-size:var(--alxgrn-font-size-small)}.ProseEditor div.image div.image-buttons div:hover,.ProseEditor div.carousel div.carousel-buttons div:hover{opacity:1}.ProseNotes div.image div.image-buttons{display:none}.ProseNotes div.video iframe,.ProseEditor div.video iframe,.ProseViewer div.video iframe{display:block;border-radius:var(--alxgrn-unit-half);width:100%;aspect-ratio:16 / 9;border:none;margin:0 auto;background-color:var(--alxgrn-border)}.ProseNotes pre,.ProseEditor pre,.ProseViewer pre{white-space:pre-wrap;background-color:var(--alxgrn-bg-light);border-radius:var(--alxgrn-unit-small);padding:var(--alxgrn-unit-small) var(--alxgrn-unit-half)}.ProseViewer hr,.ProseEditor hr{display:block;border:none;border-top:1px solid var(--alxgrn-border);margin:var(--alxgrn-unit) 0}.ProseViewer table{width:100%;margin:var(--alxgrn-unit) 0;border-spacing:0}.ProseViewer th,.ProseViewer td{text-align:left;vertical-align:top;min-width:var(--alxgrn-unit);border-right:1px solid var(--alxgrn-border);border-bottom:1px solid var(--alxgrn-border);padding:var(--alxgrn-unit-small) var(--alxgrn-unit-half)}.ProseViewer th{font-weight:700;text-align:center;vertical-align:middle;background-color:var(--alxgrn-bg-light)}.ProseViewer th:first-child,.ProseViewer td:first-child{border-left:1px solid var(--alxgrn-border)}.ProseViewer tr:first-child>th,.ProseViewer tr:first-child>td{border-top:1px solid var(--alxgrn-border)}.ProseViewer tr:first-child>th:first-child,.ProseViewer tr:first-child>td:first-child{border-top-left-radius:var(--alxgrn-unit-small)}.ProseViewer tr:first-child>th:last-child,.ProseViewer tr:first-child>td:last-child{border-top-right-radius:var(--alxgrn-unit-small)}.ProseViewer tr:last-child>th:first-child,.ProseViewer tr:last-child>td:first-child{border-bottom-left-radius:var(--alxgrn-unit-small)}.ProseViewer tr:last-child>th:last-child,.ProseViewer tr:last-child>td:last-child{border-bottom-right-radius:var(--alxgrn-unit-small)}.ProseNotes{display:flex;gap:var(--alxgrn-unit-half);flex-direction:column}.ProseNotesContent{border:1px solid var(--alxgrn-border);padding:var(--alxgrn-unit-small);border-radius:var(--alxgrn-unit-small)}.ProseNotesTitle,.ProseNotesTitle:focus{width:100%;color:var(--alxgrn-color-text);border:1px solid var(--alxgrn-border);border-radius:var(--alxgrn-unit-small);background-color:transparent;outline:none;padding:var(--alxgrn-unit-half);font-size:var(--alxgrn-font-size)}.ProseNotesTitle::placeholder{color:var(--alxgrn-color-text);opacity:.5;font-style:italic}.ProseNotes .ProseMirror{overflow:auto;min-height:20vh;max-height:45vh;padding:var(--alxgrn-unit-small);padding-right:var(--alxgrn-unit-half);margin-top:var(--alxgrn-unit-small)}.ProseNotesButtons{display:flex;gap:var(--alxgrn-unit);align-items:center;justify-content:flex-end}.ProseNotes .ProseMirror::-webkit-scrollbar{width:var(--alxgrn-unit-small);height:var(--alxgrn-unit-small)}.ProseNotes .ProseMirror::-webkit-scrollbar-track{background-color:transparent;border-radius:var(--alxgrn-unit-small)}.ProseNotes .ProseMirror::-webkit-scrollbar-thumb{background-color:var(--alxgrn-color-scroll);border-radius:var(--alxgrn-unit-small);cursor:default}.ProseNotes .ProseMirror::-webkit-scrollbar-corner{background-color:transparent}.MenuBar{display:flex;align-items:center;gap:var(--alxgrn-unit-small);flex-wrap:wrap;border:none;border-bottom:2px solid var(--alxgrn-color-text)!important;position:sticky;top:var(--alxgrn-layout-header-height);background-color:var(--alxgrn-bg-panel);z-index:100;padding:var(--alxgrn-unit-half) 0;margin-bottom:var(--alxgrn-unit)}.ProseMirror .tableWrapper,.ProseMirror .table-wrapper{overflow:hidden;margin:var(--alxgrn-unit) 0}.ProseMirror .table-resizer{height:var(--alxgrn-unit);position:relative;margin-left:var(--alxgrn-unit)}.ProseMirror .table-resizer div{top:0;height:100%;width:7px;position:absolute;background-color:transparent;cursor:ew-resize;cursor:col-resize;z-index:100}.ProseMirror .table-resizer div:last-child{display:none}.ProseMirror table{position:relative;border-collapse:collapse;table-layout:fixed;width:calc(100% - var(--alxgrn-unit));margin-left:var(--alxgrn-unit)}.ProseMirror td,.ProseMirror th{text-align:left;vertical-align:top;box-sizing:border-box;position:relative;min-width:1em;border:1px solid var(--alxgrn-border);padding:var(--alxgrn-unit-small) var(--alxgrn-unit-half)}.ProseMirror th{font-weight:700;text-align:center;vertical-align:middle;background-color:var(--alxgrn-bg-light)}.ProseMirror td:not([data-colwidth]):not(.column-resize-dragging),.ProseMirror th:not([data-colwidth]):not(.column-resize-dragging){min-width:var(--default-cell-min-width)}.ProseMirror .column-resize-handle{position:absolute;right:-2px;top:0;bottom:0;width:4px;z-index:20;background-color:#adf;pointer-events:none}.ProseMirror.resize-cursor{cursor:ew-resize;cursor:col-resize}.ProseMirror .selectedCell{background-color:#adf}.ProseMirror table caption{position:absolute;top:calc(-1 * var(--alxgrn-unit));left:calc(-1 * var(--alxgrn-unit));display:flex;align-items:center;justify-content:center;padding:0;border:none;width:var(--alxgrn-unit);height:var(--alxgrn-unit);font-size:var(--alxgrn-font-size-small);cursor:pointer;color:var(--alxgrn-color-light);background-color:transparent}.ProseMirror table caption:hover{color:var(--alxgrn-color-accent)}.ProseMirror table tbody tr th:first-child:after,.ProseMirror table tbody tr td:first-child:after{content:" ";display:block;background-color:var(--alxgrn-border);position:absolute;top:0;bottom:0;right:100%;width:var(--alxgrn-unit);border-top-left-radius:var(--alxgrn-unit-small);border-bottom-left-radius:var(--alxgrn-unit-small);cursor:pointer}.ProseMirror table tbody tr:last-child th:first-child:after,.ProseMirror table tbody tr:last-child td:first-child:after{bottom:-1px}.ProseMirror table tbody tr:first-child th:before,.ProseMirror table tbody tr:first-child td:before{content:" ";display:block;background-color:var(--alxgrn-border);position:absolute;left:0;right:0;bottom:100%;height:var(--alxgrn-unit);border-top-left-radius:var(--alxgrn-unit-small);border-top-right-radius:var(--alxgrn-unit-small);cursor:pointer}.ProseMirror table tbody tr:first-child th:first-child:before,.ProseMirror table tbody tr:first-child td:first-child:before{left:0}.ProseMirror table tbody tr:first-child th:last-child:before,.ProseMirror table tbody tr:first-child td:last-child:before{right:-1px}.ProseMirror table tr .col-menu:hover,.ProseMirror table tr .row-menu:hover{background-color:var(--alxgrn-color-text)}div.carousel{width:100%;position:relative;text-align:center;margin:var(--alxgrn-unit) 0;border-radius:var(--alxgrn-unit-half);overflow:hidden;-webkit-touch-callout:none;-webkit-user-select:none;-khtml-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}div.carousel:fullscreen{display:flex;border-radius:0;background-color:#000;justify-content:center;align-items:center}div.carousel div.carousel-numb,div.carousel div.carousel-full,div.carousel div.carousel-prev,div.carousel div.carousel-next{position:absolute;top:calc(50% - var(--alxgrn-unit));left:var(--alxgrn-unit-small);height:var(--alxgrn-unit-double);width:var(--alxgrn-unit-double);color:var(--alxgrn-button-color);background-color:var(--alxgrn-button-bg);cursor:pointer;border-radius:var(--alxgrn-unit-small);opacity:.9;display:flex;justify-content:center;align-items:center}div.carousel div.carousel-next{left:unset;right:var(--alxgrn-unit-small)}div.carousel div.carousel-numb{top:var(--alxgrn-unit-small);font-size:var(--alxgrn-font-size-small);font-style:normal;padding:0 var(--alxgrn-unit-half);width:unset}div.carousel div.carousel-full{top:var(--alxgrn-unit-small);left:unset;right:var(--alxgrn-unit-small)}div.carousel:hover div.carousel-numb:hover,div.carousel:hover div.carousel-full:hover,div.carousel:hover div.carousel-prev:hover,div.carousel:hover div.carousel-next:hover{opacity:1}div.carousel div.carousel-list{display:flex;align-items:center;overflow-x:auto;scroll-snap-type:x mandatory;scroll-behavior:smooth;-webkit-overflow-scrolling:touch}div.carousel div.carousel-list div.image{scroll-snap-align:start;flex:0 0 auto;width:100%;margin:0}div.carousel:fullscreen div.carousel-list div.image .image-title{display:none}div.carousel:fullscreen div.carousel-list div.image img{border-radius:0;max-width:100%;max-height:100%}div.carousel div.carousel-list::-webkit-scrollbar{width:0;height:0}div.carousel div.carousel-list::-webkit-scrollbar-thumb{border:none;background:transparent}div.carousel div.carousel-list::-webkit-scrollbar-track{border:none;background:transparent}.ProseEditor .ProseMirror{min-height:100vh}
|
|
1
|
+
(function(G,m){typeof exports=="object"&&typeof module<"u"?m(exports,require("react"),require("react-dom"),require("@alxgrn/telefrag-ui")):typeof define=="function"&&define.amd?define(["exports","react","react-dom","@alxgrn/telefrag-ui"],m):(G=typeof globalThis<"u"?globalThis:G||self,m(G.ProseEditor={},G.React,G.ReactDOM,G["@alxgrn/telefrag-ui"]))})(this,function(G,m,Ye,N){"use strict";var D0=Object.defineProperty;var v0=(G,m,Ye)=>m in G?D0(G,m,{enumerable:!0,configurable:!0,writable:!0,value:Ye}):G[m]=Ye;var j=(G,m,Ye)=>v0(G,typeof m!="symbol"?m+"":m,Ye);var di=document.createElement("style");di.textContent=`placeholder.ProseMirror-widget{display:flex;align-items:center;justify-content:center;margin:var(--alxgrn-unit) auto;border-radius:var(--alxgrn-unit-small);width:100%;height:200px;background-color:var(--alxgrn-logo-color-beige);font-style:normal;font-weight:400;font-size:var(--alxgrn-font-size)}placeholder.ProseMirror-widget:after{content:"Загрузка..."}div.carousel div.carousel-list span{display:block;scroll-snap-align:start;flex:0 0 auto;width:100%;margin:0}div.carousel placeholder.ProseMirror-widget{height:unset;aspect-ratio:16 / 9;margin:0}.MenuItem{display:flex;align-items:center;justify-content:center;cursor:pointer;padding:var(--alxgrn-unit-smallest)}.MenuItem.active{background:var(--alxgrn-bg-accent);border-radius:var(--alxgrn-unit-smallest)}.MenuItem.disabled{cursor:default;opacity:.3}.MenuBlock{flex:0 0 auto;display:flex;align-items:center;gap:var(--alxgrn-unit-small);border-right:1px solid var(--alxgrn-border);padding-right:var(--alxgrn-unit-small)}.MenuBlock:last-child{border-right:none;padding-right:0;flex:1 1 auto;justify-content:flex-end}.SimpleMenuBar{display:flex;align-items:center;gap:var(--alxgrn-unit-small);flex-wrap:wrap;padding:var(--alxgrn-unit-small)}.ProseMirror{position:relative;outline:none;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}.ProseMirror li{position:relative}.ProseMirror-hideselection *::selection{background:transparent}.ProseMirror-hideselection *::-moz-selection{background:transparent}.ProseMirror-hideselection{caret-color:transparent}.ProseMirror [draggable][contenteditable=false]{-webkit-user-select:text;user-select:text}.ProseMirror-selectednode{outline:2px solid #8cf;border-radius:var(--alxgrn-unit-half)}li.ProseMirror-selectednode{outline:none}li.ProseMirror-selectednode:after{content:"";position:absolute;left:calc(-2px - var(--alxgrn-unit-double));right:-2px;top:-2px;bottom:-2px;border:2px solid #8cf;pointer-events:none;border-radius:var(--alxgrn-unit-half)}.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}:root{--prose-button-bg: rgba(136, 136, 136, .9);--prose-button-color: #fff;--prose-button-bg-hover: rgba(136, 136, 136, 1);--prose-button-color-hover: #fff;--prose-button-accent-bg: rgba(70, 130, 180, .9);--prose-button-accent-color: #fff;--prose-button-accent-bg-hover: rgba(70, 130, 180, 1);--prose-button-accent-color-hover: #fff}.ProseViewer{display:block}.ProseViewer .unknown_node_type{display:block;color:red}.ProseNotes p,.ProseEditor p,.ProseViewer p{margin:var(--alxgrn-unit) 0;padding:0}.ProseNotes p:first-child,.ProseEditor p:first-child,.ProseViewer p:first-child{margin-top:0}.ProseNotes p:last-child,.ProseEditor p:last-child,.ProseViewer p:last-child{margin-bottom:0}.ProseNotes ul,.ProseEditor ul,.ProseViewer ul,.ProseNotes ol,.ProseEditor ol,.ProseViewer ol{margin:var(--alxgrn-unit) 0;padding:0}.ProseNotes ul ul,.ProseEditor ul ul,.ProseViewer ul ul,.ProseNotes ul ol,.ProseEditor ul ol,.ProseViewer ul ol,.ProseNotes ol ul,.ProseEditor ol ul,.ProseViewer ol ul,.ProseNotes ol ol,.ProseEditor ol ol,.ProseViewer ol ol,.ProseNotes ul p,.ProseEditor ul p,.ProseViewer ul p,.ProseNotes ol p,.ProseEditor ol p,.ProseViewer ol p{margin:0}.ProseNotes li,.ProseEditor li,.ProseViewer li{padding:0;margin:0;margin-left:var(--alxgrn-unit-double)}.ProseNotes blockquote,.ProseEditor blockquote,.ProseViewer blockquote{display:block;margin:0;border-left:var(--alxgrn-unit-small) solid var(--alxgrn-color-accent);margin:var(--alxgrn-unit) 0;padding:var(--alxgrn-unit-half);border-radius:var(--alxgrn-unit-small);background-color:var(--alxgrn-bg-accent)}.ProseNotes div.image,.ProseEditor div.image,.ProseViewer div.image,.ProseNotes div.video,.ProseEditor div.video,.ProseViewer div.video{display:block;margin:var(--alxgrn-unit) auto;text-align:center;position:relative}.ProseViewer div.video .video-switcher,.ProseEditor div.video .video-switcher,.ProseNotes div.video .video-switcher{position:absolute;display:flex;gap:var(--alxgrn-unit-small);margin:var(--alxgrn-unit-small);z-index:10}.ProseViewer div.video .video-switcher div,.ProseEditor div.video .video-switcher div,.ProseNotes div.video .video-switcher div{padding:0 var(--alxgrn-unit);font-style:normal;font-size:var(--alxgrn-font-size-small);color:var(--prose-button-color);background-color:var(--prose-button-bg);border-radius:var(--alxgrn-unit-small);cursor:pointer;height:var(--alxgrn-unit-double);display:flex;align-items:center;justify-content:center}.ProseViewer div.video .video-switcher div:hover,.ProseEditor div.video .video-switcher div:hover,.ProseNotes div.video .video-switcher div:hover{color:var(--prose-button-color-hover);background-color:var(--prose-button-bg-hover)}.ProseViewer div.video .video-switcher div.active,.ProseEditor div.video .video-switcher div.active,.ProseNotes div.video .video-switcher div.active{color:var(--prose-button-accent-color);background-color:var(--prose-button-accent-bg)}.ProseViewer div.video .video-switcher div.active:hover,.ProseEditor div.video .video-switcher div.active:hover,.ProseNotes div.video .video-switcher div.active:hover{color:var(--prose-button-accent-color-hover);background-color:var(--prose-button-accent-bg-hover)}.ProseViewer div.video .video-title,.ProseEditor div.video .video-title,.ProseNotes div.video .video-title{font-style:italic;display:block;width:80%;margin:0 auto}.ProseNotes div.image img,.ProseEditor div.image img,.ProseViewer div.image img,.ProseNotes div.video img,.ProseEditor div.video img,.ProseViewer div.video img{display:block;border-radius:var(--alxgrn-unit-half);max-width:100%;max-height:75vh;margin:0 auto}.ProseViewer div.image .image-title,.ProseEditor div.image .image-title,.ProseNotes div.image .image-title{font-style:italic;display:block;width:80%;margin:0 auto}.ProseViewer div.image img{cursor:pointer}.ProseViewer div.image:fullscreen{background-color:#000;border-radius:0;display:flex;justify-content:center;align-items:center}.ProseViewer div.image:fullscreen .image-title{display:none}.ProseViewer div.image:fullscreen img{border-radius:0;max-width:100%;max-height:100%}.ProseEditor div.image div.image-buttons{position:absolute;gap:var(--alxgrn-unit-small);top:0;right:0;width:auto;margin:var(--alxgrn-unit-small);display:flex;align-items:stretch;justify-content:stretch}.ProseEditor div.carousel div.carousel-buttons{z-index:10;position:absolute;gap:var(--alxgrn-unit-small);top:0;left:0;width:auto;margin:var(--alxgrn-unit-small);display:flex;align-items:stretch;justify-content:stretch}.ProseViewer div.image div.image-full,.ProseEditor div.image div.image-buttons div,.ProseEditor div.carousel div.carousel-buttons div{display:flex;align-items:center;justify-content:center;color:var(--prose-button-color);background-color:var(--prose-button-bg);border-radius:var(--alxgrn-unit-small);cursor:pointer;height:var(--alxgrn-unit-double);width:var(--alxgrn-unit-double);padding:0;z-index:10}.ProseViewer div.image div.image-full{position:absolute;top:var(--alxgrn-unit-half);right:var(--alxgrn-unit-half)}.ProseViewer div.image div.image-full:hover{color:var(--prose-button-color-hover);background-color:var(--prose-button-bg-hover)}.ProseEditor div.image div.image-buttons div.text-button,.ProseEditor div.carousel div.carousel-buttons div.text-button{width:unset;padding:0 var(--alxgrn-unit);font-style:normal;font-size:var(--alxgrn-font-size-small)}.ProseEditor div.image div.image-buttons div:hover,.ProseEditor div.carousel div.carousel-buttons div:hover{color:var(--prose-button-color-hover);background-color:var(--prose-button-bg-hover)}.ProseNotes div.image div.image-buttons{display:none}.ProseNotes div.video iframe,.ProseEditor div.video iframe,.ProseViewer div.video iframe{display:block;border-radius:var(--alxgrn-unit-half);width:100%;aspect-ratio:16 / 9;border:none;margin:0 auto;background-color:var(--alxgrn-border)}.ProseNotes pre,.ProseEditor pre,.ProseViewer pre{white-space:pre-wrap;background-color:var(--alxgrn-bg-light);border-radius:var(--alxgrn-unit-small);padding:var(--alxgrn-unit-small) var(--alxgrn-unit-half)}.ProseViewer hr,.ProseEditor hr{display:block;border:none;border-top:1px solid var(--alxgrn-border);margin:var(--alxgrn-unit) 0}.ProseViewer table{width:100%;margin:var(--alxgrn-unit) 0;border-spacing:0}.ProseViewer th,.ProseViewer td{text-align:left;vertical-align:top;min-width:var(--alxgrn-unit);border-right:1px solid var(--alxgrn-border);border-bottom:1px solid var(--alxgrn-border);padding:var(--alxgrn-unit-small) var(--alxgrn-unit-half)}.ProseViewer th{font-weight:700;text-align:center;vertical-align:middle;background-color:var(--alxgrn-bg-light)}.ProseViewer th:first-child,.ProseViewer td:first-child{border-left:1px solid var(--alxgrn-border)}.ProseViewer tr:first-child>th,.ProseViewer tr:first-child>td{border-top:1px solid var(--alxgrn-border)}.ProseViewer tr:first-child>th:first-child,.ProseViewer tr:first-child>td:first-child{border-top-left-radius:var(--alxgrn-unit-small)}.ProseViewer tr:first-child>th:last-child,.ProseViewer tr:first-child>td:last-child{border-top-right-radius:var(--alxgrn-unit-small)}.ProseViewer tr:last-child>th:first-child,.ProseViewer tr:last-child>td:first-child{border-bottom-left-radius:var(--alxgrn-unit-small)}.ProseViewer tr:last-child>th:last-child,.ProseViewer tr:last-child>td:last-child{border-bottom-right-radius:var(--alxgrn-unit-small)}.ProseNotes{display:flex;gap:var(--alxgrn-unit-half);flex-direction:column}.ProseNotesContent{border:1px solid var(--alxgrn-border);padding:var(--alxgrn-unit-small);border-radius:var(--alxgrn-unit-small)}.ProseNotesTitle,.ProseNotesTitle:focus{width:100%;color:var(--alxgrn-color-text);border:1px solid var(--alxgrn-border);border-radius:var(--alxgrn-unit-small);background-color:transparent;outline:none;padding:var(--alxgrn-unit-half);font-size:var(--alxgrn-font-size)}.ProseNotesTitle::placeholder{color:var(--alxgrn-color-text);opacity:.5;font-style:italic}.ProseNotes .ProseMirror{overflow:auto;min-height:20vh;max-height:45vh;padding:var(--alxgrn-unit-small);padding-right:var(--alxgrn-unit-half);margin-top:var(--alxgrn-unit-small)}.ProseNotesButtons{display:flex;gap:var(--alxgrn-unit);align-items:center;justify-content:flex-end}.ProseNotes .ProseMirror::-webkit-scrollbar{width:var(--alxgrn-unit-small);height:var(--alxgrn-unit-small)}.ProseNotes .ProseMirror::-webkit-scrollbar-track{background-color:transparent;border-radius:var(--alxgrn-unit-small)}.ProseNotes .ProseMirror::-webkit-scrollbar-thumb{background-color:var(--alxgrn-color-scroll);border-radius:var(--alxgrn-unit-small);cursor:default}.ProseNotes .ProseMirror::-webkit-scrollbar-corner{background-color:transparent}.MenuBar{display:flex;align-items:center;gap:var(--alxgrn-unit-small);flex-wrap:wrap;border:none;border-bottom:2px solid var(--alxgrn-color-text)!important;position:sticky;top:var(--alxgrn-layout-header-height);background-color:var(--alxgrn-bg-panel);z-index:100;padding:var(--alxgrn-unit-half) 0;margin-bottom:var(--alxgrn-unit)}.ProseMirror .tableWrapper,.ProseMirror .table-wrapper{overflow:hidden;margin:var(--alxgrn-unit) 0}.ProseMirror .table-resizer{height:var(--alxgrn-unit);position:relative;margin-left:var(--alxgrn-unit)}.ProseMirror .table-resizer div{top:0;height:100%;width:7px;position:absolute;background-color:transparent;cursor:ew-resize;cursor:col-resize;z-index:100}.ProseMirror .table-resizer div:last-child{display:none}.ProseMirror table{position:relative;border-collapse:collapse;table-layout:fixed;width:calc(100% - var(--alxgrn-unit));margin-left:var(--alxgrn-unit)}.ProseMirror td,.ProseMirror th{text-align:left;vertical-align:top;box-sizing:border-box;position:relative;min-width:1em;border:1px solid var(--alxgrn-border);padding:var(--alxgrn-unit-small) var(--alxgrn-unit-half)}.ProseMirror th{font-weight:700;text-align:center;vertical-align:middle;background-color:var(--alxgrn-bg-light)}.ProseMirror td:not([data-colwidth]):not(.column-resize-dragging),.ProseMirror th:not([data-colwidth]):not(.column-resize-dragging){min-width:var(--default-cell-min-width)}.ProseMirror .column-resize-handle{position:absolute;right:-2px;top:0;bottom:0;width:4px;z-index:20;background-color:#adf;pointer-events:none}.ProseMirror.resize-cursor{cursor:ew-resize;cursor:col-resize}.ProseMirror .selectedCell{background-color:#adf}.ProseMirror table caption{position:absolute;top:calc(-1 * var(--alxgrn-unit));left:calc(-1 * var(--alxgrn-unit));display:flex;align-items:center;justify-content:center;padding:0;border:none;width:var(--alxgrn-unit);height:var(--alxgrn-unit);font-size:var(--alxgrn-font-size-small);cursor:pointer;color:var(--alxgrn-color-light);background-color:transparent}.ProseMirror table caption:hover{color:var(--alxgrn-color-accent)}.ProseMirror table tbody tr th:first-child:after,.ProseMirror table tbody tr td:first-child:after{content:" ";display:block;background-color:var(--alxgrn-border);position:absolute;top:0;bottom:0;right:100%;width:var(--alxgrn-unit);border-top-left-radius:var(--alxgrn-unit-small);border-bottom-left-radius:var(--alxgrn-unit-small);cursor:pointer}.ProseMirror table tbody tr:last-child th:first-child:after,.ProseMirror table tbody tr:last-child td:first-child:after{bottom:-1px}.ProseMirror table tbody tr:first-child th:before,.ProseMirror table tbody tr:first-child td:before{content:" ";display:block;background-color:var(--alxgrn-border);position:absolute;left:0;right:0;bottom:100%;height:var(--alxgrn-unit);border-top-left-radius:var(--alxgrn-unit-small);border-top-right-radius:var(--alxgrn-unit-small);cursor:pointer}.ProseMirror table tbody tr:first-child th:first-child:before,.ProseMirror table tbody tr:first-child td:first-child:before{left:0}.ProseMirror table tbody tr:first-child th:last-child:before,.ProseMirror table tbody tr:first-child td:last-child:before{right:-1px}.ProseMirror table tr .col-menu:hover,.ProseMirror table tr .row-menu:hover{background-color:var(--alxgrn-color-text)}div.carousel{width:100%;position:relative;text-align:center;margin:var(--alxgrn-unit) 0;border-radius:var(--alxgrn-unit-half);overflow:hidden;-webkit-touch-callout:none;-webkit-user-select:none;-khtml-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}div.carousel:fullscreen{display:flex;border-radius:0;background-color:#000;justify-content:center;align-items:center}div.carousel div.carousel-numb,div.carousel div.carousel-full,div.carousel div.carousel-prev,div.carousel div.carousel-next{position:absolute;top:calc(50% - var(--alxgrn-unit));left:var(--alxgrn-unit-small);height:var(--alxgrn-unit-double);width:var(--alxgrn-unit-double);color:var(--prose-button-color);background-color:var(--prose-button-bg);cursor:pointer;border-radius:var(--alxgrn-unit-small);display:flex;justify-content:center;align-items:center}div.carousel div.carousel-next{left:unset;right:var(--alxgrn-unit-small)}div.carousel div.carousel-numb{top:var(--alxgrn-unit-small);font-size:var(--alxgrn-font-size-small);font-style:normal;padding:0 var(--alxgrn-unit-half);width:unset}div.carousel div.carousel-full{top:var(--alxgrn-unit-small);left:unset;right:var(--alxgrn-unit-small)}div.carousel:hover div.carousel-numb:hover,div.carousel:hover div.carousel-full:hover,div.carousel:hover div.carousel-prev:hover,div.carousel:hover div.carousel-next:hover{color:var(--prose-button-color-hover);background-color:var(--prose-button-bg-hover)}div.carousel div.carousel-list{display:flex;align-items:center;overflow-x:auto;scroll-snap-type:x mandatory;scroll-behavior:smooth;-webkit-overflow-scrolling:touch}div.carousel div.carousel-list div.image{scroll-snap-align:start;flex:0 0 auto;width:100%;margin:0}div.carousel:fullscreen div.carousel-list div.image .image-title{display:none}div.carousel:fullscreen div.carousel-list div.image img{border-radius:0;max-width:100%;max-height:100%}div.carousel div.carousel-list::-webkit-scrollbar{width:0;height:0}div.carousel div.carousel-list::-webkit-scrollbar-thumb{border:none;background:transparent}div.carousel div.carousel-list::-webkit-scrollbar-track{border:none;background:transparent}.ProseEditor .ProseMirror{min-height:100vh}
|
|
2
2
|
/*$vite$:1*/`,document.head.appendChild(di);function bf(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var uo={exports:{}},Cn={};/**
|
|
3
3
|
* @license React
|
|
4
4
|
* react-jsx-runtime.production.js
|
|
@@ -15,12 +15,12 @@
|
|
|
15
15
|
*
|
|
16
16
|
* This source code is licensed under the MIT license found in the
|
|
17
17
|
* LICENSE file in the root directory of this source tree.
|
|
18
|
-
*/var pi;function kf(){return pi||(pi=1,process.env.NODE_ENV!=="production"&&function(){function n(k){if(k==null)return null;if(typeof k=="function")return k.$$typeof===lo?null:k.displayName||k.name||null;if(typeof k=="string")return k;switch(k){case M:return"Fragment";case T:return"Portal";case z:return"Profiler";case I:return"StrictMode";case Et:return"Suspense";case Ae:return"SuspenseList"}if(typeof k=="object")switch(typeof k.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),k.$$typeof){case L:return(k.displayName||"Context")+".Provider";case
|
|
18
|
+
*/var pi;function kf(){return pi||(pi=1,process.env.NODE_ENV!=="production"&&function(){function n(k){if(k==null)return null;if(typeof k=="function")return k.$$typeof===lo?null:k.displayName||k.name||null;if(typeof k=="string")return k;switch(k){case M:return"Fragment";case T:return"Portal";case z:return"Profiler";case I:return"StrictMode";case Et:return"Suspense";case Ae:return"SuspenseList"}if(typeof k=="object")switch(typeof k.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),k.$$typeof){case L:return(k.displayName||"Context")+".Provider";case O:return(k._context.displayName||"Context")+".Consumer";case we:var A=k.render;return k=k.displayName,k||(k=A.displayName||A.name||"",k=k!==""?"ForwardRef("+k+")":"ForwardRef"),k;case ze:return A=k.displayName||null,A!==null?A:n(k.type)||"Memo";case Yt:A=k._payload,k=k._init;try{return n(k(A))}catch{}}return null}function e(k){return""+k}function t(k){try{e(k);var A=!1}catch{A=!0}if(A){A=console;var P=A.error,B=typeof Symbol=="function"&&Symbol.toStringTag&&k[Symbol.toStringTag]||k.constructor.name||"Object";return P.call(A,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",B),e(k)}}function r(){}function o(){if(cr===0){Zu=console.log,ef=console.info,tf=console.warn,nf=console.error,rf=console.group,of=console.groupCollapsed,sf=console.groupEnd;var k={configurable:!0,enumerable:!0,value:r,writable:!0};Object.defineProperties(console,{info:k,log:k,warn:k,error:k,group:k,groupCollapsed:k,groupEnd:k})}cr++}function s(){if(cr--,cr===0){var k={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:Xt({},k,{value:Zu}),info:Xt({},k,{value:ef}),warn:Xt({},k,{value:tf}),error:Xt({},k,{value:nf}),group:Xt({},k,{value:rf}),groupCollapsed:Xt({},k,{value:of}),groupEnd:Xt({},k,{value:sf})})}0>cr&&console.error("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}function i(k){if(li===void 0)try{throw Error()}catch(P){var A=P.stack.trim().match(/\n( *(at )?)/);li=A&&A[1]||"",lf=-1<P.stack.indexOf(`
|
|
19
19
|
at`)?" (<anonymous>)":-1<P.stack.indexOf("@")?"@unknown:0:0":""}return`
|
|
20
20
|
`+li+k+lf}function l(k,A){if(!k||ai)return"";var P=ci.get(k);if(P!==void 0)return P;ai=!0,P=Error.prepareStackTrace,Error.prepareStackTrace=void 0;var B=null;B=Gt.H,Gt.H=null,o();try{var ce={DetermineComponentFrameRoot:function(){try{if(A){var Dt=function(){throw Error()};if(Object.defineProperty(Dt.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(Dt,[])}catch(rt){var ao=rt}Reflect.construct(k,[],Dt)}else{try{Dt.call()}catch(rt){ao=rt}k.call(Dt.prototype)}}else{try{throw Error()}catch(rt){ao=rt}(Dt=k())&&typeof Dt.catch=="function"&&Dt.catch(function(){})}}catch(rt){if(rt&&ao&&typeof rt.stack=="string")return[rt.stack,ao.stack]}return[null,null]}};ce.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var _=Object.getOwnPropertyDescriptor(ce.DetermineComponentFrameRoot,"name");_&&_.configurable&&Object.defineProperty(ce.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var $=ce.DetermineComponentFrameRoot(),nt=$[0],bn=$[1];if(nt&&bn){var me=nt.split(`
|
|
21
21
|
`),Ut=bn.split(`
|
|
22
22
|
`);for($=_=0;_<me.length&&!me[_].includes("DetermineComponentFrameRoot");)_++;for(;$<Ut.length&&!Ut[$].includes("DetermineComponentFrameRoot");)$++;if(_===me.length||$===Ut.length)for(_=me.length-1,$=Ut.length-1;1<=_&&0<=$&&me[_]!==Ut[$];)$--;for(;1<=_&&0<=$;_--,$--)if(me[_]!==Ut[$]){if(_!==1||$!==1)do if(_--,$--,0>$||me[_]!==Ut[$]){var ur=`
|
|
23
|
-
`+me[_].replace(" at new "," at ");return k.displayName&&ur.includes("<anonymous>")&&(ur=ur.replace("<anonymous>",k.displayName)),typeof k=="function"&&ci.set(k,ur),ur}while(1<=_&&0<=$);break}}}finally{ai=!1,Gt.H=B,s(),Error.prepareStackTrace=P}return me=(me=k?k.displayName||k.name:"")?i(me):"",typeof k=="function"&&ci.set(k,me),me}function a(k){if(k==null)return"";if(typeof k=="function"){var A=k.prototype;return l(k,!(!A||!A.isReactComponent))}if(typeof k=="string")return i(k);switch(k){case Et:return i("Suspense");case Ae:return i("SuspenseList")}if(typeof k=="object")switch(k.$$typeof){case we:return k=l(k.render,!1),k;case ze:return a(k.type);case Yt:A=k._payload,k=k._init;try{return a(k(A))}catch{}}return""}function c(){var k=Gt.A;return k===null?null:k.getOwner()}function u(k){if(Qu.call(k,"key")){var A=Object.getOwnPropertyDescriptor(k,"key").get;if(A&&A.isReactWarning)return!1}return k.key!==void 0}function f(k,A){function P(){af||(af=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",A))}P.isReactWarning=!0,Object.defineProperty(k,"key",{get:P,configurable:!0})}function d(){var k=n(this.type);return cf[k]||(cf[k]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),k=this.props.ref,k!==void 0?k:null}function p(k,A,P,B,ce,_){return P=_.ref,k={$$typeof:D,type:k,key:A,props:_,_owner:ce},(P!==void 0?P:null)!==null?Object.defineProperty(k,"ref",{enumerable:!1,get:d}):Object.defineProperty(k,"ref",{enumerable:!1,value:null}),k._store={},Object.defineProperty(k._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(k,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.freeze&&(Object.freeze(k.props),Object.freeze(k)),k}function h(k,A,P,B,ce,_){if(typeof k=="string"||typeof k=="function"||k===M||k===z||k===I||k===Et||k===Ae||k===yn||typeof k=="object"&&k!==null&&(k.$$typeof===Yt||k.$$typeof===ze||k.$$typeof===L||k.$$typeof===
|
|
23
|
+
`+me[_].replace(" at new "," at ");return k.displayName&&ur.includes("<anonymous>")&&(ur=ur.replace("<anonymous>",k.displayName)),typeof k=="function"&&ci.set(k,ur),ur}while(1<=_&&0<=$);break}}}finally{ai=!1,Gt.H=B,s(),Error.prepareStackTrace=P}return me=(me=k?k.displayName||k.name:"")?i(me):"",typeof k=="function"&&ci.set(k,me),me}function a(k){if(k==null)return"";if(typeof k=="function"){var A=k.prototype;return l(k,!(!A||!A.isReactComponent))}if(typeof k=="string")return i(k);switch(k){case Et:return i("Suspense");case Ae:return i("SuspenseList")}if(typeof k=="object")switch(k.$$typeof){case we:return k=l(k.render,!1),k;case ze:return a(k.type);case Yt:A=k._payload,k=k._init;try{return a(k(A))}catch{}}return""}function c(){var k=Gt.A;return k===null?null:k.getOwner()}function u(k){if(Qu.call(k,"key")){var A=Object.getOwnPropertyDescriptor(k,"key").get;if(A&&A.isReactWarning)return!1}return k.key!==void 0}function f(k,A){function P(){af||(af=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",A))}P.isReactWarning=!0,Object.defineProperty(k,"key",{get:P,configurable:!0})}function d(){var k=n(this.type);return cf[k]||(cf[k]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),k=this.props.ref,k!==void 0?k:null}function p(k,A,P,B,ce,_){return P=_.ref,k={$$typeof:D,type:k,key:A,props:_,_owner:ce},(P!==void 0?P:null)!==null?Object.defineProperty(k,"ref",{enumerable:!1,get:d}):Object.defineProperty(k,"ref",{enumerable:!1,value:null}),k._store={},Object.defineProperty(k._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(k,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.freeze&&(Object.freeze(k.props),Object.freeze(k)),k}function h(k,A,P,B,ce,_){if(typeof k=="string"||typeof k=="function"||k===M||k===z||k===I||k===Et||k===Ae||k===yn||typeof k=="object"&&k!==null&&(k.$$typeof===Yt||k.$$typeof===ze||k.$$typeof===L||k.$$typeof===O||k.$$typeof===we||k.$$typeof===N0||k.getModuleId!==void 0)){var $=A.children;if($!==void 0)if(B)if(ii($)){for(B=0;B<$.length;B++)b($[B],k);Object.freeze&&Object.freeze($)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else b($,k)}else $="",(k===void 0||typeof k=="object"&&k!==null&&Object.keys(k).length===0)&&($+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports."),k===null?B="null":ii(k)?B="array":k!==void 0&&k.$$typeof===D?(B="<"+(n(k.type)||"Unknown")+" />",$=" Did you accidentally export a JSX literal instead of a component?"):B=typeof k,console.error("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",B,$);if(Qu.call(A,"key")){$=n(k);var nt=Object.keys(A).filter(function(me){return me!=="key"});B=0<nt.length?"{key: someKey, "+nt.join(": ..., ")+": ...}":"{key: someKey}",uf[$+B]||(nt=0<nt.length?"{"+nt.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
|
|
24
24
|
let props = %s;
|
|
25
25
|
<%s {...props} />
|
|
26
26
|
React keys must be passed directly to JSX without using spread:
|
|
@@ -29,24 +29,24 @@ React keys must be passed directly to JSX without using spread:
|
|
|
29
29
|
|
|
30
30
|
Check the render method of \``+P+"`."),A||(k=n(k))&&(A=`
|
|
31
31
|
|
|
32
|
-
Check the top-level render call using <`+k+">."),A}var w=m,D=Symbol.for("react.transitional.element"),T=Symbol.for("react.portal"),M=Symbol.for("react.fragment"),I=Symbol.for("react.strict_mode"),z=Symbol.for("react.profiler"),v=Symbol.for("react.consumer"),L=Symbol.for("react.context"),we=Symbol.for("react.forward_ref"),Et=Symbol.for("react.suspense"),Ae=Symbol.for("react.suspense_list"),ze=Symbol.for("react.memo"),Yt=Symbol.for("react.lazy"),yn=Symbol.for("react.offscreen"),ar=Symbol.iterator,lo=Symbol.for("react.client.reference"),Gt=w.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Qu=Object.prototype.hasOwnProperty,Xt=Object.assign,N0=Symbol.for("react.client.reference"),ii=Array.isArray,cr=0,Zu,ef,tf,nf,rf,of,sf;r.__reactDisabledLog=!0;var li,lf,ai=!1,ci=new(typeof WeakMap=="function"?WeakMap:Map),E0=Symbol.for("react.client.reference"),af,cf={},uf={},ff={};wn.Fragment=M,wn.jsx=function(k,A,P,B,ce){return h(k,A,P,!1,B,ce)},wn.jsxs=function(k,A,P,B,ce){return h(k,A,P,!0,B,ce)}}()),wn}process.env.NODE_ENV==="production"?uo.exports=xf():uo.exports=kf();var y=uo.exports;function Z(n){this.content=n}Z.prototype={constructor:Z,find:function(n){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===n)return e;return-1},get:function(n){var e=this.find(n);return e==-1?void 0:this.content[e+1]},update:function(n,e,t){var r=t&&t!=n?this.remove(t):this,o=r.find(n),s=r.content.slice();return o==-1?s.push(t||n,e):(s[o+1]=e,t&&(s[o]=t)),new Z(s)},remove:function(n){var e=this.find(n);if(e==-1)return this;var t=this.content.slice();return t.splice(e,2),new Z(t)},addToStart:function(n,e){return new Z([n,e].concat(this.remove(n).content))},addToEnd:function(n,e){var t=this.remove(n).content.slice();return t.push(n,e),new Z(t)},addBefore:function(n,e,t){var r=this.remove(e),o=r.content.slice(),s=r.find(n);return o.splice(s==-1?o.length:s,0,e,t),new Z(o)},forEach:function(n){for(var e=0;e<this.content.length;e+=2)n(this.content[e],this.content[e+1])},prepend:function(n){return n=Z.from(n),n.size?new Z(n.content.concat(this.subtract(n).content)):this},append:function(n){return n=Z.from(n),n.size?new Z(this.subtract(n).content.concat(n.content)):this},subtract:function(n){var e=this;n=Z.from(n);for(var t=0;t<n.content.length;t+=2)e=e.remove(n.content[t]);return e},toObject:function(){var n={};return this.forEach(function(e,t){n[e]=t}),n},get size(){return this.content.length>>1}},Z.from=function(n){if(n instanceof Z)return n;var e=[];if(n)for(var t in n)e.push(t,n[t]);return new Z(e)};function mi(n,e,t){for(let r=0;;r++){if(r==n.childCount||r==e.childCount)return n.childCount==e.childCount?null:t;let o=n.child(r),s=e.child(r);if(o==s){t+=o.nodeSize;continue}if(!o.sameMarkup(s))return t;if(o.isText&&o.text!=s.text){for(let i=0;o.text[i]==s.text[i];i++)t++;return t}if(o.content.size||s.content.size){let i=mi(o.content,s.content,t+1);if(i!=null)return i}t+=o.nodeSize}}function gi(n,e,t,r){for(let o=n.childCount,s=e.childCount;;){if(o==0||s==0)return o==s?null:{a:t,b:r};let i=n.child(--o),l=e.child(--s),a=i.nodeSize;if(i==l){t-=a,r-=a;continue}if(!i.sameMarkup(l))return{a:t,b:r};if(i.isText&&i.text!=l.text){let c=0,u=Math.min(i.text.length,l.text.length);for(;c<u&&i.text[i.text.length-c-1]==l.text[l.text.length-c-1];)c++,t--,r--;return{a:t,b:r}}if(i.content.size||l.content.size){let c=gi(i.content,l.content,t-1,r-1);if(c)return c}t-=a,r-=a}}class C{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,t,r,o=0,s){for(let i=0,l=0;l<t;i++){let a=this.content[i],c=l+a.nodeSize;if(c>e&&r(a,o+l,s||null,i)!==!1&&a.content.size){let u=l+1;a.nodesBetween(Math.max(0,e-u),Math.min(a.content.size,t-u),r,o+u)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,r,o){let s="",i=!0;return this.nodesBetween(e,t,(l,a)=>{let c=l.isText?l.text.slice(Math.max(e,a)-a,t-a):l.isLeaf?o?typeof o=="function"?o(l):o:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&c||l.isTextblock)&&r&&(i?i=!1:s+=r),s+=c},0),s}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,r=e.firstChild,o=this.content.slice(),s=0;for(t.isText&&t.sameMarkup(r)&&(o[o.length-1]=t.withText(t.text+r.text),s=1);s<e.content.length;s++)o.push(e.content[s]);return new C(o,this.size+e.size)}cut(e,t=this.size){if(e==0&&t==this.size)return this;let r=[],o=0;if(t>e)for(let s=0,i=0;i<t;s++){let l=this.content[s],a=i+l.nodeSize;a>e&&((i<e||a>t)&&(l.isText?l=l.cut(Math.max(0,e-i),Math.min(l.text.length,t-i)):l=l.cut(Math.max(0,e-i-1),Math.min(l.content.size,t-i-1))),r.push(l),o+=l.nodeSize),i=a}return new C(r,o)}cutByIndex(e,t){return e==t?C.empty:e==0&&t==this.content.length?this:new C(this.content.slice(e,t))}replaceChild(e,t){let r=this.content[e];if(r==t)return this;let o=this.content.slice(),s=this.size+t.nodeSize-r.nodeSize;return o[e]=t,new C(o,s)}addToStart(e){return new C([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new C(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw new RangeError("Index "+e+" out of range for "+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,r=0;t<this.content.length;t++){let o=this.content[t];e(o,r,t),r+=o.nodeSize}}findDiffStart(e,t=0){return mi(this,e,t)}findDiffEnd(e,t=this.size,r=e.size){return gi(this,e,t,r)}findIndex(e,t=-1){if(e==0)return dr(0,e);if(e==this.size)return dr(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let r=0,o=0;;r++){let s=this.child(r),i=o+s.nodeSize;if(i>=e)return i==e||t>0?dr(r+1,i):dr(r,o);o=i}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,t){if(!t)return C.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new C(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return C.empty;let t,r=0;for(let o=0;o<e.length;o++){let s=e[o];r+=s.nodeSize,o&&s.isText&&e[o-1].sameMarkup(s)?(t||(t=e.slice(0,o)),t[t.length-1]=s.withText(t[t.length-1].text+s.text)):t&&t.push(s)}return new C(t||e,r)}static from(e){if(!e)return C.empty;if(e instanceof C)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new C([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}C.empty=new C([],0);const fo={index:0,offset:0};function dr(n,e){return fo.index=n,fo.offset=e,fo}function hr(n,e){if(n===e)return!0;if(!(n&&typeof n=="object")||!(e&&typeof e=="object"))return!1;let t=Array.isArray(n);if(Array.isArray(e)!=t)return!1;if(t){if(n.length!=e.length)return!1;for(let r=0;r<n.length;r++)if(!hr(n[r],e[r]))return!1}else{for(let r in n)if(!(r in e)||!hr(n[r],e[r]))return!1;for(let r in e)if(!(r in n))return!1}return!0}class F{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,r=!1;for(let o=0;o<e.length;o++){let s=e[o];if(this.eq(s))return e;if(this.type.excludes(s.type))t||(t=e.slice(0,o));else{if(s.type.excludes(this.type))return e;!r&&s.type.rank>this.type.rank&&(t||(t=e.slice(0,o)),t.push(this),r=!0),t&&t.push(s)}}return t||(t=e.slice()),r||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&hr(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Mark.fromJSON");let r=e.marks[t.type];if(!r)throw new RangeError(`There is no mark type ${t.type} in this schema`);let o=r.create(t.attrs);return r.checkAttrs(o.attrs),o}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(t[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return F.none;if(e instanceof F)return[e];let t=e.slice();return t.sort((r,o)=>r.type.rank-o.type.rank),t}}F.none=[];class pr extends Error{}class E{constructor(e,t,r){this.content=e,this.openStart=t,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let r=bi(this.content,e+this.openStart,t);return r&&new E(r,this.openStart,this.openEnd)}removeBetween(e,t){return new E(yi(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 E.empty;let r=t.openStart||0,o=t.openEnd||0;if(typeof r!="number"||typeof o!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new E(C.fromJSON(e,t.content),r,o)}static maxOpen(e,t=!0){let r=0,o=0;for(let s=e.firstChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.firstChild)r++;for(let s=e.lastChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.lastChild)o++;return new E(e,r,o)}}E.empty=new E(C.empty,0,0);function yi(n,e,t){let{index:r,offset:o}=n.findIndex(e),s=n.maybeChild(r),{index:i,offset:l}=n.findIndex(t);if(o==e||s.isText){if(l!=t&&!n.child(i).isText)throw new RangeError("Removing non-flat range");return n.cut(0,e).append(n.cut(t))}if(r!=i)throw new RangeError("Removing non-flat range");return n.replaceChild(r,s.copy(yi(s.content,e-o-1,t-o-1)))}function bi(n,e,t,r){let{index:o,offset:s}=n.findIndex(e),i=n.maybeChild(o);if(s==e||i.isText)return n.cut(0,e).append(t).append(n.cut(e));let l=bi(i.content,e-s-1,t);return l&&n.replaceChild(o,i.copy(l))}function Sf(n,e,t){if(t.openStart>n.depth)throw new pr("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new pr("Inconsistent open depths");return xi(n,e,t,0)}function xi(n,e,t,r){let o=n.index(r),s=n.node(r);if(o==e.index(r)&&r<n.depth-t.openStart){let i=xi(n,e,t,r+1);return s.copy(s.content.replaceChild(o,i))}else if(t.content.size)if(!t.openStart&&!t.openEnd&&n.depth==r&&e.depth==r){let i=n.parent,l=i.content;return Tt(i,l.cut(0,n.parentOffset).append(t.content).append(l.cut(e.parentOffset)))}else{let{start:i,end:l}=Cf(t,n);return Tt(s,Si(n,i,l,e,r))}else return Tt(s,mr(n,e,r))}function ki(n,e){if(!e.type.compatibleContent(n.type))throw new pr("Cannot join "+e.type.name+" onto "+n.type.name)}function ho(n,e,t){let r=n.node(t);return ki(r,e.node(t)),r}function vt(n,e){let t=e.length-1;t>=0&&n.isText&&n.sameMarkup(e[t])?e[t]=n.withText(e[t].text+n.text):e.push(n)}function Mn(n,e,t,r){let o=(e||n).node(t),s=0,i=e?e.index(t):o.childCount;n&&(s=n.index(t),n.depth>t?s++:n.textOffset&&(vt(n.nodeAfter,r),s++));for(let l=s;l<i;l++)vt(o.child(l),r);e&&e.depth==t&&e.textOffset&&vt(e.nodeBefore,r)}function Tt(n,e){return n.type.checkContent(e),n.copy(e)}function Si(n,e,t,r,o){let s=n.depth>o&&ho(n,e,o+1),i=r.depth>o&&ho(t,r,o+1),l=[];return Mn(null,n,o,l),s&&i&&e.index(o)==t.index(o)?(ki(s,i),vt(Tt(s,Si(n,e,t,r,o+1)),l)):(s&&vt(Tt(s,mr(n,e,o+1)),l),Mn(e,t,o,l),i&&vt(Tt(i,mr(t,r,o+1)),l)),Mn(r,null,o,l),new C(l)}function mr(n,e,t){let r=[];if(Mn(null,n,t,r),n.depth>t){let o=ho(n,e,t+1);vt(Tt(o,mr(n,e,t+1)),r)}return Mn(e,null,t,r),new C(r)}function Cf(n,e){let t=e.depth-n.openStart,o=e.node(t).copy(n.content);for(let s=t-1;s>=0;s--)o=e.node(s).copy(C.from(o));return{start:o.resolveNoCache(n.openStart+t),end:o.resolveNoCache(o.content.size-n.openEnd-t)}}class Nn{constructor(e,t,r){this.pos=e,this.path=t,this.parentOffset=r,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],o=e.child(t);return r?e.child(t).cut(r):o}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let r=this.path[t*3],o=t==0?0:this.path[t*3-1]+1;for(let s=0;s<e;s++)o+=r.child(s).nodeSize;return o}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return F.none;if(this.textOffset)return e.child(t).marks;let r=e.maybeChild(t-1),o=e.maybeChild(t);if(!r){let l=r;r=o,o=l}let s=r.marks;for(var i=0;i<s.length;i++)s[i].type.spec.inclusive===!1&&(!o||!s[i].isInSet(o.marks))&&(s=s[i--].removeFromSet(s));return s}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let r=t.marks,o=e.parent.maybeChild(e.index());for(var s=0;s<r.length;s++)r[s].type.spec.inclusive===!1&&(!o||!r[s].isInSet(o.marks))&&(r=r[s--].removeFromSet(r));return r}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let r=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);r>=0;r--)if(e.pos<=this.end(r)&&(!t||t(this.node(r))))return new gr(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let t=1;t<=this.depth;t++)e+=(e?"/":"")+this.node(t).type.name+"_"+this.index(t-1);return e+":"+this.parentOffset}static resolve(e,t){if(!(t>=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let r=[],o=0,s=t;for(let i=e;;){let{index:l,offset:a}=i.content.findIndex(s),c=s-a;if(r.push(i,l,o+a),!c||(i=i.child(l),i.isText))break;s=c-1,o+=a+1}return new Nn(t,r,s)}static resolveCached(e,t){let r=Ci.get(e);if(r)for(let s=0;s<r.elts.length;s++){let i=r.elts[s];if(i.pos==t)return i}else Ci.set(e,r=new wf);let o=r.elts[r.i]=Nn.resolve(e,t);return r.i=(r.i+1)%Mf,o}}class wf{constructor(){this.elts=[],this.i=0}}const Mf=12,Ci=new WeakMap;class gr{constructor(e,t,r){this.$from=e,this.$to=t,this.depth=r}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const Nf=Object.create(null);class be{constructor(e,t,r,o=F.none){this.type=e,this.attrs=t,this.marks=o,this.content=r||C.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,r,o=0){this.content.nodesBetween(e,t,r,o,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,t,r,o){return this.content.textBetween(e,t,r,o)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,r){return this.type==e&&hr(this.attrs,t||e.defaultAttrs||Nf)&&F.sameSet(this.marks,r||F.none)}copy(e=null){return e==this.content?this:new be(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new be(this.type,this.attrs,this.content,e)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,r=!1){if(e==t)return E.empty;let o=this.resolve(e),s=this.resolve(t),i=r?0:o.sharedDepth(t),l=o.start(i),c=o.node(i).content.cut(o.pos-l,s.pos-l);return new E(c,o.depth-i,s.depth-i)}replace(e,t,r){return Sf(this.resolve(e),this.resolve(t),r)}nodeAt(e){for(let t=this;;){let{index:r,offset:o}=t.content.findIndex(e);if(t=t.maybeChild(r),!t)return null;if(o==e||t.isText)return t;e-=o+1}}childAfter(e){let{index:t,offset:r}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:r}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:r}=this.content.findIndex(e);if(r<e)return{node:this.content.child(t),index:t,offset:r};let o=this.content.child(t-1);return{node:o,index:t-1,offset:r-o.nodeSize}}resolve(e){return Nn.resolveCached(this,e)}resolveNoCache(e){return Nn.resolve(this,e)}rangeHasMark(e,t,r){let o=!1;return t>e&&this.nodesBetween(e,t,s=>(r.isInSet(s.marks)&&(o=!0),!o)),o}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),wi(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw new Error("Called contentMatchAt on a node with invalid content");return t}canReplace(e,t,r=C.empty,o=0,s=r.childCount){let i=this.contentMatchAt(e).matchFragment(r,o,s),l=i&&i.matchFragment(this.content,t);if(!l||!l.validEnd)return!1;for(let a=o;a<s;a++)if(!this.type.allowsMarks(r.child(a).marks))return!1;return!0}canReplaceWith(e,t,r,o){if(o&&!this.type.allowsMarks(o))return!1;let s=this.contentMatchAt(e).matchType(r),i=s&&s.matchFragment(this.content,t);return i?i.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=F.none;for(let t=0;t<this.marks.length;t++){let r=this.marks[t];r.type.checkAttrs(r.attrs),e=r.addToSet(e)}if(!F.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(t=>t.type.name)}`);this.content.forEach(t=>t.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(t=>t.toJSON())),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let r;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=t.marks.map(e.markFromJSON)}if(t.type=="text"){if(typeof t.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(t.text,r)}let o=C.fromJSON(e,t.content),s=e.nodeType(t.type).create(t.attrs,o,r);return s.type.checkAttrs(s.attrs),s}}be.prototype.text=void 0;class yr extends be{constructor(e,t,r,o){if(super(e,t,null,o),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):wi(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 yr(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new yr(this.type,this.attrs,e,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function wi(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}class At{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let r=new Ef(e,t);if(r.next==null)return At.empty;let o=Mi(r);r.next&&r.err("Unexpected trailing text");let s=If(Pf(o));return Vf(s,r),s}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,r=e.childCount){let o=this;for(let s=t;o&&s<r;s++)o=o.matchType(e.child(s).type);return o}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let r=0;r<e.next.length;r++)if(this.next[t].type==e.next[r].type)return!0;return!1}fillBefore(e,t=!1,r=0){let o=[this];function s(i,l){let a=i.matchFragment(e,r);if(a&&(!t||a.validEnd))return C.from(l.map(c=>c.createAndFill()));for(let c=0;c<i.next.length;c++){let{type:u,next:f}=i.next[c];if(!(u.isText||u.hasRequiredAttrs())&&o.indexOf(f)==-1){o.push(f);let d=s(f,l.concat(u));if(d)return d}}return null}return s(this,[])}findWrapping(e){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==e)return this.wrapCache[r+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let o=r.shift(),s=o.match;if(s.matchType(e)){let i=[];for(let l=o;l.type;l=l.via)i.push(l.type);return i.reverse()}for(let i=0;i<s.next.length;i++){let{type:l,next:a}=s.next[i];!l.isLeaf&&!l.hasRequiredAttrs()&&!(l.name in t)&&(!o.type||a.validEnd)&&(r.push({match:l.contentMatch,type:l,via:o}),t[l.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(r){e.push(r);for(let o=0;o<r.next.length;o++)e.indexOf(r.next[o].next)==-1&&t(r.next[o].next)}return t(this),e.map((r,o)=>{let s=o+(r.validEnd?"*":" ")+" ";for(let i=0;i<r.next.length;i++)s+=(i?", ":"")+r.next[i].type.name+"->"+e.indexOf(r.next[i].next);return s}).join(`
|
|
33
|
-
`)}}At.empty=new At(!0);class Ef{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 Mi(n){let e=[];do e.push(Df(n));while(n.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function Df(n){let e=[];do e.push(Of(n));while(n.next&&n.next!=")"&&n.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function Of(n){let e=Af(n);for(;;)if(n.eat("+"))e={type:"plus",expr:e};else if(n.eat("*"))e={type:"star",expr:e};else if(n.eat("?"))e={type:"opt",expr:e};else if(n.eat("{"))e=vf(n,e);else break;return e}function Ni(n){/\D/.test(n.next)&&n.err("Expected number, got '"+n.next+"'");let e=Number(n.next);return n.pos++,e}function vf(n,e){let t=Ni(n),r=t;return n.eat(",")&&(n.next!="}"?r=Ni(n):r=-1),n.eat("}")||n.err("Unclosed braced range"),{type:"range",min:t,max:r,expr:e}}function Tf(n,e){let t=n.nodeTypes,r=t[e];if(r)return[r];let o=[];for(let s in t){let i=t[s];i.isInGroup(e)&&o.push(i)}return o.length==0&&n.err("No node type or group '"+e+"' found"),o}function Af(n){if(n.eat("(")){let e=Mi(n);return n.eat(")")||n.err("Missing closing paren"),e}else if(/\W/.test(n.next))n.err("Unexpected token '"+n.next+"'");else{let e=Tf(n,n.next).map(t=>(n.inline==null?n.inline=t.isInline:n.inline!=t.isInline&&n.err("Mixing inline and block content"),{type:"name",value:t}));return n.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function Pf(n){let e=[[]];return o(s(n,0),t()),e;function t(){return e.push([])-1}function r(i,l,a){let c={term:a,to:l};return e[i].push(c),c}function o(i,l){i.forEach(a=>a.to=l)}function s(i,l){if(i.type=="choice")return i.exprs.reduce((a,c)=>a.concat(s(c,l)),[]);if(i.type=="seq")for(let a=0;;a++){let c=s(i.exprs[a],l);if(a==i.exprs.length-1)return c;o(c,l=t())}else if(i.type=="star"){let a=t();return r(l,a),o(s(i.expr,a),a),[r(a)]}else if(i.type=="plus"){let a=t();return o(s(i.expr,l),a),o(s(i.expr,a),a),[r(a)]}else{if(i.type=="opt")return[r(l)].concat(s(i.expr,l));if(i.type=="range"){let a=l;for(let c=0;c<i.min;c++){let u=t();o(s(i.expr,a),u),a=u}if(i.max==-1)o(s(i.expr,a),a);else for(let c=i.min;c<i.max;c++){let u=t();r(a,u),o(s(i.expr,a),u),a=u}return[r(a)]}else{if(i.type=="name")return[r(l,void 0,i.value)];throw new Error("Unknown expr type")}}}}function Ei(n,e){return e-n}function Di(n,e){let t=[];return r(e),t.sort(Ei);function r(o){let s=n[o];if(s.length==1&&!s[0].term)return r(s[0].to);t.push(o);for(let i=0;i<s.length;i++){let{term:l,to:a}=s[i];!l&&t.indexOf(a)==-1&&r(a)}}}function If(n){let e=Object.create(null);return t(Di(n,0));function t(r){let o=[];r.forEach(i=>{n[i].forEach(({term:l,to:a})=>{if(!l)return;let c;for(let u=0;u<o.length;u++)o[u][0]==l&&(c=o[u][1]);Di(n,a).forEach(u=>{c||o.push([l,c=[]]),c.indexOf(u)==-1&&c.push(u)})})});let s=e[r.join(",")]=new At(r.indexOf(n.length-1)>-1);for(let i=0;i<o.length;i++){let l=o[i][1].sort(Ei);s.next.push({type:o[i][0],next:e[l.join(",")]||t(l)})}return s}}function Vf(n,e){for(let t=0,r=[n];t<r.length;t++){let o=r[t],s=!o.validEnd,i=[];for(let l=0;l<o.next.length;l++){let{type:a,next:c}=o.next[l];i.push(a.name),s&&!(a.isText||a.hasRequiredAttrs())&&(s=!1),r.indexOf(c)==-1&&r.push(c)}s&&e.err("Only non-generatable nodes ("+i.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function Oi(n){let e=Object.create(null);for(let t in n){let r=n[t];if(!r.hasDefault)return null;e[t]=r.default}return e}function vi(n,e){let t=Object.create(null);for(let r in n){let o=e&&e[r];if(o===void 0){let s=n[r];if(s.hasDefault)o=s.default;else throw new RangeError("No value supplied for attribute "+r)}t[r]=o}return t}function Ti(n,e,t,r){for(let o in e)if(!(o in n))throw new RangeError(`Unsupported attribute ${o} for ${t} of type ${o}`);for(let o in n){let s=n[o];s.validate&&s.validate(e[o])}}function Ai(n,e){let t=Object.create(null);if(e)for(let r in e)t[r]=new zf(n,r,e[r]);return t}let Pi=class df{constructor(e,t,r){this.name=e,this.schema=t,this.spec=r,this.markSet=null,this.groups=r.group?r.group.split(" "):[],this.attrs=Ai(e,r.attrs),this.defaultAttrs=Oi(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(r.inline||e=="text"),this.isText=e=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==At.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(e){return this.groups.indexOf(e)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:vi(this.attrs,e)}create(e=null,t,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new be(this,this.computeAttrs(e),C.from(t),F.setFrom(r))}createChecked(e=null,t,r){return t=C.from(t),this.checkContent(t),new be(this,this.computeAttrs(e),t,F.setFrom(r))}createAndFill(e=null,t,r){if(e=this.computeAttrs(e),t=C.from(t),t.size){let i=this.contentMatch.fillBefore(t);if(!i)return null;t=i.append(t)}let o=this.contentMatch.matchFragment(t),s=o&&o.fillBefore(C.empty,!0);return s?new be(this,e,t.append(s),F.setFrom(r)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let r=0;r<e.childCount;r++)if(!this.allowsMarks(e.child(r).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){Ti(this.attrs,e,"node",this.name)}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let t;for(let r=0;r<e.length;r++)this.allowsMarkType(e[r].type)?t&&t.push(e[r]):t||(t=e.slice(0,r));return t?t.length?t:F.none:e}static compile(e,t){let r=Object.create(null);e.forEach((s,i)=>r[s]=new df(s,t,i));let o=t.spec.topNode||"doc";if(!r[o])throw new RangeError("Schema is missing its top node type ('"+o+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let s in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function Rf(n,e,t){let r=t.split("|");return o=>{let s=o===null?"null":typeof o;if(r.indexOf(s)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${n}, got ${s}`)}}class zf{constructor(e,t,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?Rf(e,t,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class br{constructor(e,t,r,o){this.name=e,this.rank=t,this.schema=r,this.spec=o,this.attrs=Ai(e,o.attrs),this.excluded=null;let s=Oi(this.attrs);this.instance=s?new F(this,s):null}create(e=null){return!e&&this.instance?this.instance:new F(this,vi(this.attrs,e))}static compile(e,t){let r=Object.create(null),o=0;return e.forEach((s,i)=>r[s]=new br(s,o++,t,i)),r}removeFromSet(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}checkAttrs(e){Ti(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class xr{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let o in e)t[o]=e[o];t.nodes=Z.from(e.nodes),t.marks=Z.from(e.marks||{}),this.nodes=Pi.compile(this.spec.nodes,this),this.marks=br.compile(this.spec.marks,this);let r=Object.create(null);for(let o in this.nodes){if(o in this.marks)throw new RangeError(o+" can not be both a node and a mark");let s=this.nodes[o],i=s.spec.content||"",l=s.spec.marks;if(s.contentMatch=r[i]||(r[i]=At.parse(i,this.nodes)),s.inlineContent=s.contentMatch.inlineContent,s.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!s.isInline||!s.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=s}s.markSet=l=="_"?null:l?Ii(this,l.split(" ")):l==""||!s.inlineContent?[]:null}for(let o in this.marks){let s=this.marks[o],i=s.spec.excludes;s.excluded=i==null?[s]:i==""?[]:Ii(this,i.split(" "))}this.nodeFromJSON=this.nodeFromJSON.bind(this),this.markFromJSON=this.markFromJSON.bind(this),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,r,o){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof Pi){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(t,r,o)}text(e,t){let r=this.nodes.text;return new yr(r,r.defaultAttrs,e,F.setFrom(t))}mark(e,t){return typeof e=="string"&&(e=this.marks[e]),e.create(t)}nodeFromJSON(e){return be.fromJSON(this,e)}markFromJSON(e){return F.fromJSON(this,e)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}}function Ii(n,e){let t=[];for(let r=0;r<e.length;r++){let o=e[r],s=n.marks[o],i=s;if(s)t.push(s);else for(let l in n.marks){let a=n.marks[l];(o=="_"||a.spec.group&&a.spec.group.split(" ").indexOf(o)>-1)&&t.push(i=a)}if(!i)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return t}function $f(n){return n.tag!=null}function jf(n){return n.style!=null}class Pt{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let r=this.matchedStyles=[];t.forEach(o=>{if($f(o))this.tags.push(o);else if(jf(o)){let s=/[^=]*/.exec(o.style)[0];r.indexOf(s)<0&&r.push(s),this.styles.push(o)}}),this.normalizeLists=!this.tags.some(o=>{if(!/^(ul|ol)\b/.test(o.tag)||!o.node)return!1;let s=e.nodes[o.node];return s.contentMatch.matchType(s)})}parse(e,t={}){let r=new $i(this,t,!1);return r.addAll(e,F.none,t.from,t.to),r.finish()}parseSlice(e,t={}){let r=new $i(this,t,!0);return r.addAll(e,F.none,t.from,t.to),E.maxOpen(r.finish())}matchTag(e,t,r){for(let o=r?this.tags.indexOf(r)+1:0;o<this.tags.length;o++){let s=this.tags[o];if(Lf(e,s.tag)&&(s.namespace===void 0||e.namespaceURI==s.namespace)&&(!s.context||t.matchesContext(s.context))){if(s.getAttrs){let i=s.getAttrs(e);if(i===!1)continue;s.attrs=i||void 0}return s}}}matchStyle(e,t,r,o){for(let s=o?this.styles.indexOf(o)+1:0;s<this.styles.length;s++){let i=this.styles[s],l=i.style;if(!(l.indexOf(e)!=0||i.context&&!r.matchesContext(i.context)||l.length>e.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=t))){if(i.getAttrs){let a=i.getAttrs(t);if(a===!1)continue;i.attrs=a||void 0}return i}}}static schemaRules(e){let t=[];function r(o){let s=o.priority==null?50:o.priority,i=0;for(;i<t.length;i++){let l=t[i];if((l.priority==null?50:l.priority)<s)break}t.splice(i,0,o)}for(let o in e.marks){let s=e.marks[o].spec.parseDOM;s&&s.forEach(i=>{r(i=ji(i)),i.mark||i.ignore||i.clearMark||(i.mark=o)})}for(let o in e.nodes){let s=e.nodes[o].spec.parseDOM;s&&s.forEach(i=>{r(i=ji(i)),i.node||i.ignore||i.mark||(i.node=o)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Pt(e,Pt.schemaRules(e)))}}const Vi={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},Bf={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Ri={ol:!0,ul:!0},En=1,po=2,kr=4;function zi(n,e,t){return e!=null?(e?En:0)|(e==="full"?po:0):n&&n.whitespace=="pre"?En|po:t&-5}class Sr{constructor(e,t,r,o,s,i){this.type=e,this.attrs=t,this.marks=r,this.solid=o,this.options=i,this.content=[],this.activeMarks=F.none,this.match=s||(i&kr?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(C.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let r=this.type.contentMatch,o;return(o=r.findWrapping(e.type))?(this.match=r,o):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&En)){let r=this.content[this.content.length-1],o;if(r&&r.isText&&(o=/[ \t\r\n\u000c]+$/.exec(r.text))){let s=r;r.text.length==o[0].length?this.content.pop():this.content[this.content.length-1]=s.withText(s.text.slice(0,s.text.length-o[0].length))}}let t=C.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(C.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!Vi.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class $i{constructor(e,t,r){this.parser=e,this.options=t,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let o=t.topNode,s,i=zi(null,t.preserveWhitespace,0)|(r?kr:0);o?s=new Sr(o.type,o.attrs,F.none,!0,t.topMatch||o.type.contentMatch,i):r?s=new Sr(null,null,F.none,!0,null,i):s=new Sr(e.schema.topNodeType,null,F.none,!0,null,i),this.nodes=[s],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){e.nodeType==3?this.addTextNode(e,t):e.nodeType==1&&this.addElement(e,t)}addTextNode(e,t){let r=e.nodeValue,o=this.top,s=o.options&po?"full":this.localPreserveWS||(o.options&En)>0;if(s==="full"||o.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(s)s!=="full"?r=r.replace(/\r?\n|\r/g," "):r=r.replace(/\r\n?/g,`
|
|
32
|
+
Check the top-level render call using <`+k+">."),A}var w=m,D=Symbol.for("react.transitional.element"),T=Symbol.for("react.portal"),M=Symbol.for("react.fragment"),I=Symbol.for("react.strict_mode"),z=Symbol.for("react.profiler"),O=Symbol.for("react.consumer"),L=Symbol.for("react.context"),we=Symbol.for("react.forward_ref"),Et=Symbol.for("react.suspense"),Ae=Symbol.for("react.suspense_list"),ze=Symbol.for("react.memo"),Yt=Symbol.for("react.lazy"),yn=Symbol.for("react.offscreen"),ar=Symbol.iterator,lo=Symbol.for("react.client.reference"),Gt=w.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,Qu=Object.prototype.hasOwnProperty,Xt=Object.assign,N0=Symbol.for("react.client.reference"),ii=Array.isArray,cr=0,Zu,ef,tf,nf,rf,of,sf;r.__reactDisabledLog=!0;var li,lf,ai=!1,ci=new(typeof WeakMap=="function"?WeakMap:Map),E0=Symbol.for("react.client.reference"),af,cf={},uf={},ff={};wn.Fragment=M,wn.jsx=function(k,A,P,B,ce){return h(k,A,P,!1,B,ce)},wn.jsxs=function(k,A,P,B,ce){return h(k,A,P,!0,B,ce)}}()),wn}process.env.NODE_ENV==="production"?uo.exports=xf():uo.exports=kf();var y=uo.exports;function Z(n){this.content=n}Z.prototype={constructor:Z,find:function(n){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===n)return e;return-1},get:function(n){var e=this.find(n);return e==-1?void 0:this.content[e+1]},update:function(n,e,t){var r=t&&t!=n?this.remove(t):this,o=r.find(n),s=r.content.slice();return o==-1?s.push(t||n,e):(s[o+1]=e,t&&(s[o]=t)),new Z(s)},remove:function(n){var e=this.find(n);if(e==-1)return this;var t=this.content.slice();return t.splice(e,2),new Z(t)},addToStart:function(n,e){return new Z([n,e].concat(this.remove(n).content))},addToEnd:function(n,e){var t=this.remove(n).content.slice();return t.push(n,e),new Z(t)},addBefore:function(n,e,t){var r=this.remove(e),o=r.content.slice(),s=r.find(n);return o.splice(s==-1?o.length:s,0,e,t),new Z(o)},forEach:function(n){for(var e=0;e<this.content.length;e+=2)n(this.content[e],this.content[e+1])},prepend:function(n){return n=Z.from(n),n.size?new Z(n.content.concat(this.subtract(n).content)):this},append:function(n){return n=Z.from(n),n.size?new Z(this.subtract(n).content.concat(n.content)):this},subtract:function(n){var e=this;n=Z.from(n);for(var t=0;t<n.content.length;t+=2)e=e.remove(n.content[t]);return e},toObject:function(){var n={};return this.forEach(function(e,t){n[e]=t}),n},get size(){return this.content.length>>1}},Z.from=function(n){if(n instanceof Z)return n;var e=[];if(n)for(var t in n)e.push(t,n[t]);return new Z(e)};function mi(n,e,t){for(let r=0;;r++){if(r==n.childCount||r==e.childCount)return n.childCount==e.childCount?null:t;let o=n.child(r),s=e.child(r);if(o==s){t+=o.nodeSize;continue}if(!o.sameMarkup(s))return t;if(o.isText&&o.text!=s.text){for(let i=0;o.text[i]==s.text[i];i++)t++;return t}if(o.content.size||s.content.size){let i=mi(o.content,s.content,t+1);if(i!=null)return i}t+=o.nodeSize}}function gi(n,e,t,r){for(let o=n.childCount,s=e.childCount;;){if(o==0||s==0)return o==s?null:{a:t,b:r};let i=n.child(--o),l=e.child(--s),a=i.nodeSize;if(i==l){t-=a,r-=a;continue}if(!i.sameMarkup(l))return{a:t,b:r};if(i.isText&&i.text!=l.text){let c=0,u=Math.min(i.text.length,l.text.length);for(;c<u&&i.text[i.text.length-c-1]==l.text[l.text.length-c-1];)c++,t--,r--;return{a:t,b:r}}if(i.content.size||l.content.size){let c=gi(i.content,l.content,t-1,r-1);if(c)return c}t-=a,r-=a}}class C{constructor(e,t){if(this.content=e,this.size=t||0,t==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,t,r,o=0,s){for(let i=0,l=0;l<t;i++){let a=this.content[i],c=l+a.nodeSize;if(c>e&&r(a,o+l,s||null,i)!==!1&&a.content.size){let u=l+1;a.nodesBetween(Math.max(0,e-u),Math.min(a.content.size,t-u),r,o+u)}l=c}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,t,r,o){let s="",i=!0;return this.nodesBetween(e,t,(l,a)=>{let c=l.isText?l.text.slice(Math.max(e,a)-a,t-a):l.isLeaf?o?typeof o=="function"?o(l):o:l.type.spec.leafText?l.type.spec.leafText(l):"":"";l.isBlock&&(l.isLeaf&&c||l.isTextblock)&&r&&(i?i=!1:s+=r),s+=c},0),s}append(e){if(!e.size)return this;if(!this.size)return e;let t=this.lastChild,r=e.firstChild,o=this.content.slice(),s=0;for(t.isText&&t.sameMarkup(r)&&(o[o.length-1]=t.withText(t.text+r.text),s=1);s<e.content.length;s++)o.push(e.content[s]);return new C(o,this.size+e.size)}cut(e,t=this.size){if(e==0&&t==this.size)return this;let r=[],o=0;if(t>e)for(let s=0,i=0;i<t;s++){let l=this.content[s],a=i+l.nodeSize;a>e&&((i<e||a>t)&&(l.isText?l=l.cut(Math.max(0,e-i),Math.min(l.text.length,t-i)):l=l.cut(Math.max(0,e-i-1),Math.min(l.content.size,t-i-1))),r.push(l),o+=l.nodeSize),i=a}return new C(r,o)}cutByIndex(e,t){return e==t?C.empty:e==0&&t==this.content.length?this:new C(this.content.slice(e,t))}replaceChild(e,t){let r=this.content[e];if(r==t)return this;let o=this.content.slice(),s=this.size+t.nodeSize-r.nodeSize;return o[e]=t,new C(o,s)}addToStart(e){return new C([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new C(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let t=0;t<this.content.length;t++)if(!this.content[t].eq(e.content[t]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let t=this.content[e];if(!t)throw new RangeError("Index "+e+" out of range for "+this);return t}maybeChild(e){return this.content[e]||null}forEach(e){for(let t=0,r=0;t<this.content.length;t++){let o=this.content[t];e(o,r,t),r+=o.nodeSize}}findDiffStart(e,t=0){return mi(this,e,t)}findDiffEnd(e,t=this.size,r=e.size){return gi(this,e,t,r)}findIndex(e,t=-1){if(e==0)return dr(0,e);if(e==this.size)return dr(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let r=0,o=0;;r++){let s=this.child(r),i=o+s.nodeSize;if(i>=e)return i==e||t>0?dr(r+1,i):dr(r,o);o=i}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,t){if(!t)return C.empty;if(!Array.isArray(t))throw new RangeError("Invalid input for Fragment.fromJSON");return new C(t.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return C.empty;let t,r=0;for(let o=0;o<e.length;o++){let s=e[o];r+=s.nodeSize,o&&s.isText&&e[o-1].sameMarkup(s)?(t||(t=e.slice(0,o)),t[t.length-1]=s.withText(t[t.length-1].text+s.text)):t&&t.push(s)}return new C(t||e,r)}static from(e){if(!e)return C.empty;if(e instanceof C)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new C([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}C.empty=new C([],0);const fo={index:0,offset:0};function dr(n,e){return fo.index=n,fo.offset=e,fo}function hr(n,e){if(n===e)return!0;if(!(n&&typeof n=="object")||!(e&&typeof e=="object"))return!1;let t=Array.isArray(n);if(Array.isArray(e)!=t)return!1;if(t){if(n.length!=e.length)return!1;for(let r=0;r<n.length;r++)if(!hr(n[r],e[r]))return!1}else{for(let r in n)if(!(r in e)||!hr(n[r],e[r]))return!1;for(let r in e)if(!(r in n))return!1}return!0}class F{constructor(e,t){this.type=e,this.attrs=t}addToSet(e){let t,r=!1;for(let o=0;o<e.length;o++){let s=e[o];if(this.eq(s))return e;if(this.type.excludes(s.type))t||(t=e.slice(0,o));else{if(s.type.excludes(this.type))return e;!r&&s.type.rank>this.type.rank&&(t||(t=e.slice(0,o)),t.push(this),r=!0),t&&t.push(s)}}return t||(t=e.slice()),r||t.push(this),t}removeFromSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return e.slice(0,t).concat(e.slice(t+1));return e}isInSet(e){for(let t=0;t<e.length;t++)if(this.eq(e[t]))return!0;return!1}eq(e){return this==e||this.type==e.type&&hr(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Mark.fromJSON");let r=e.marks[t.type];if(!r)throw new RangeError(`There is no mark type ${t.type} in this schema`);let o=r.create(t.attrs);return r.checkAttrs(o.attrs),o}static sameSet(e,t){if(e==t)return!0;if(e.length!=t.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(t[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return F.none;if(e instanceof F)return[e];let t=e.slice();return t.sort((r,o)=>r.type.rank-o.type.rank),t}}F.none=[];class pr extends Error{}class E{constructor(e,t,r){this.content=e,this.openStart=t,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,t){let r=bi(this.content,e+this.openStart,t);return r&&new E(r,this.openStart,this.openEnd)}removeBetween(e,t){return new E(yi(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 E.empty;let r=t.openStart||0,o=t.openEnd||0;if(typeof r!="number"||typeof o!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new E(C.fromJSON(e,t.content),r,o)}static maxOpen(e,t=!0){let r=0,o=0;for(let s=e.firstChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.firstChild)r++;for(let s=e.lastChild;s&&!s.isLeaf&&(t||!s.type.spec.isolating);s=s.lastChild)o++;return new E(e,r,o)}}E.empty=new E(C.empty,0,0);function yi(n,e,t){let{index:r,offset:o}=n.findIndex(e),s=n.maybeChild(r),{index:i,offset:l}=n.findIndex(t);if(o==e||s.isText){if(l!=t&&!n.child(i).isText)throw new RangeError("Removing non-flat range");return n.cut(0,e).append(n.cut(t))}if(r!=i)throw new RangeError("Removing non-flat range");return n.replaceChild(r,s.copy(yi(s.content,e-o-1,t-o-1)))}function bi(n,e,t,r){let{index:o,offset:s}=n.findIndex(e),i=n.maybeChild(o);if(s==e||i.isText)return n.cut(0,e).append(t).append(n.cut(e));let l=bi(i.content,e-s-1,t);return l&&n.replaceChild(o,i.copy(l))}function Sf(n,e,t){if(t.openStart>n.depth)throw new pr("Inserted content deeper than insertion position");if(n.depth-t.openStart!=e.depth-t.openEnd)throw new pr("Inconsistent open depths");return xi(n,e,t,0)}function xi(n,e,t,r){let o=n.index(r),s=n.node(r);if(o==e.index(r)&&r<n.depth-t.openStart){let i=xi(n,e,t,r+1);return s.copy(s.content.replaceChild(o,i))}else if(t.content.size)if(!t.openStart&&!t.openEnd&&n.depth==r&&e.depth==r){let i=n.parent,l=i.content;return Tt(i,l.cut(0,n.parentOffset).append(t.content).append(l.cut(e.parentOffset)))}else{let{start:i,end:l}=Cf(t,n);return Tt(s,Si(n,i,l,e,r))}else return Tt(s,mr(n,e,r))}function ki(n,e){if(!e.type.compatibleContent(n.type))throw new pr("Cannot join "+e.type.name+" onto "+n.type.name)}function ho(n,e,t){let r=n.node(t);return ki(r,e.node(t)),r}function Ot(n,e){let t=e.length-1;t>=0&&n.isText&&n.sameMarkup(e[t])?e[t]=n.withText(e[t].text+n.text):e.push(n)}function Mn(n,e,t,r){let o=(e||n).node(t),s=0,i=e?e.index(t):o.childCount;n&&(s=n.index(t),n.depth>t?s++:n.textOffset&&(Ot(n.nodeAfter,r),s++));for(let l=s;l<i;l++)Ot(o.child(l),r);e&&e.depth==t&&e.textOffset&&Ot(e.nodeBefore,r)}function Tt(n,e){return n.type.checkContent(e),n.copy(e)}function Si(n,e,t,r,o){let s=n.depth>o&&ho(n,e,o+1),i=r.depth>o&&ho(t,r,o+1),l=[];return Mn(null,n,o,l),s&&i&&e.index(o)==t.index(o)?(ki(s,i),Ot(Tt(s,Si(n,e,t,r,o+1)),l)):(s&&Ot(Tt(s,mr(n,e,o+1)),l),Mn(e,t,o,l),i&&Ot(Tt(i,mr(t,r,o+1)),l)),Mn(r,null,o,l),new C(l)}function mr(n,e,t){let r=[];if(Mn(null,n,t,r),n.depth>t){let o=ho(n,e,t+1);Ot(Tt(o,mr(n,e,t+1)),r)}return Mn(e,null,t,r),new C(r)}function Cf(n,e){let t=e.depth-n.openStart,o=e.node(t).copy(n.content);for(let s=t-1;s>=0;s--)o=e.node(s).copy(C.from(o));return{start:o.resolveNoCache(n.openStart+t),end:o.resolveNoCache(o.content.size-n.openEnd-t)}}class Nn{constructor(e,t,r){this.pos=e,this.path=t,this.parentOffset=r,this.depth=t.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,t=this.index(this.depth);if(t==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],o=e.child(t);return r?e.child(t).cut(r):o}get nodeBefore(){let e=this.index(this.depth),t=this.pos-this.path[this.path.length-1];return t?this.parent.child(e).cut(0,t):e==0?null:this.parent.child(e-1)}posAtIndex(e,t){t=this.resolveDepth(t);let r=this.path[t*3],o=t==0?0:this.path[t*3-1]+1;for(let s=0;s<e;s++)o+=r.child(s).nodeSize;return o}marks(){let e=this.parent,t=this.index();if(e.content.size==0)return F.none;if(this.textOffset)return e.child(t).marks;let r=e.maybeChild(t-1),o=e.maybeChild(t);if(!r){let l=r;r=o,o=l}let s=r.marks;for(var i=0;i<s.length;i++)s[i].type.spec.inclusive===!1&&(!o||!s[i].isInSet(o.marks))&&(s=s[i--].removeFromSet(s));return s}marksAcross(e){let t=this.parent.maybeChild(this.index());if(!t||!t.isInline)return null;let r=t.marks,o=e.parent.maybeChild(e.index());for(var s=0;s<r.length;s++)r[s].type.spec.inclusive===!1&&(!o||!r[s].isInSet(o.marks))&&(r=r[s--].removeFromSet(r));return r}sharedDepth(e){for(let t=this.depth;t>0;t--)if(this.start(t)<=e&&this.end(t)>=e)return t;return 0}blockRange(e=this,t){if(e.pos<this.pos)return e.blockRange(this);for(let r=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);r>=0;r--)if(e.pos<=this.end(r)&&(!t||t(this.node(r))))return new gr(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let t=1;t<=this.depth;t++)e+=(e?"/":"")+this.node(t).type.name+"_"+this.index(t-1);return e+":"+this.parentOffset}static resolve(e,t){if(!(t>=0&&t<=e.content.size))throw new RangeError("Position "+t+" out of range");let r=[],o=0,s=t;for(let i=e;;){let{index:l,offset:a}=i.content.findIndex(s),c=s-a;if(r.push(i,l,o+a),!c||(i=i.child(l),i.isText))break;s=c-1,o+=a+1}return new Nn(t,r,s)}static resolveCached(e,t){let r=Ci.get(e);if(r)for(let s=0;s<r.elts.length;s++){let i=r.elts[s];if(i.pos==t)return i}else Ci.set(e,r=new wf);let o=r.elts[r.i]=Nn.resolve(e,t);return r.i=(r.i+1)%Mf,o}}class wf{constructor(){this.elts=[],this.i=0}}const Mf=12,Ci=new WeakMap;class gr{constructor(e,t,r){this.$from=e,this.$to=t,this.depth=r}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const Nf=Object.create(null);class be{constructor(e,t,r,o=F.none){this.type=e,this.attrs=t,this.marks=o,this.content=r||C.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,t,r,o=0){this.content.nodesBetween(e,t,r,o,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,t,r,o){return this.content.textBetween(e,t,r,o)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,t,r){return this.type==e&&hr(this.attrs,t||e.defaultAttrs||Nf)&&F.sameSet(this.marks,r||F.none)}copy(e=null){return e==this.content?this:new be(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new be(this.type,this.attrs,this.content,e)}cut(e,t=this.content.size){return e==0&&t==this.content.size?this:this.copy(this.content.cut(e,t))}slice(e,t=this.content.size,r=!1){if(e==t)return E.empty;let o=this.resolve(e),s=this.resolve(t),i=r?0:o.sharedDepth(t),l=o.start(i),c=o.node(i).content.cut(o.pos-l,s.pos-l);return new E(c,o.depth-i,s.depth-i)}replace(e,t,r){return Sf(this.resolve(e),this.resolve(t),r)}nodeAt(e){for(let t=this;;){let{index:r,offset:o}=t.content.findIndex(e);if(t=t.maybeChild(r),!t)return null;if(o==e||t.isText)return t;e-=o+1}}childAfter(e){let{index:t,offset:r}=this.content.findIndex(e);return{node:this.content.maybeChild(t),index:t,offset:r}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:t,offset:r}=this.content.findIndex(e);if(r<e)return{node:this.content.child(t),index:t,offset:r};let o=this.content.child(t-1);return{node:o,index:t-1,offset:r-o.nodeSize}}resolve(e){return Nn.resolveCached(this,e)}resolveNoCache(e){return Nn.resolve(this,e)}rangeHasMark(e,t,r){let o=!1;return t>e&&this.nodesBetween(e,t,s=>(r.isInSet(s.marks)&&(o=!0),!o)),o}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),wi(this.marks,e)}contentMatchAt(e){let t=this.type.contentMatch.matchFragment(this.content,0,e);if(!t)throw new Error("Called contentMatchAt on a node with invalid content");return t}canReplace(e,t,r=C.empty,o=0,s=r.childCount){let i=this.contentMatchAt(e).matchFragment(r,o,s),l=i&&i.matchFragment(this.content,t);if(!l||!l.validEnd)return!1;for(let a=o;a<s;a++)if(!this.type.allowsMarks(r.child(a).marks))return!1;return!0}canReplaceWith(e,t,r,o){if(o&&!this.type.allowsMarks(o))return!1;let s=this.contentMatchAt(e).matchType(r),i=s&&s.matchFragment(this.content,t);return i?i.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=F.none;for(let t=0;t<this.marks.length;t++){let r=this.marks[t];r.type.checkAttrs(r.attrs),e=r.addToSet(e)}if(!F.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(t=>t.type.name)}`);this.content.forEach(t=>t.check())}toJSON(){let e={type:this.type.name};for(let t in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(t=>t.toJSON())),e}static fromJSON(e,t){if(!t)throw new RangeError("Invalid input for Node.fromJSON");let r;if(t.marks){if(!Array.isArray(t.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=t.marks.map(e.markFromJSON)}if(t.type=="text"){if(typeof t.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(t.text,r)}let o=C.fromJSON(e,t.content),s=e.nodeType(t.type).create(t.attrs,o,r);return s.type.checkAttrs(s.attrs),s}}be.prototype.text=void 0;class yr extends be{constructor(e,t,r,o){if(super(e,t,null,o),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):wi(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 yr(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new yr(this.type,this.attrs,e,this.marks)}cut(e=0,t=this.text.length){return e==0&&t==this.text.length?this:this.withText(this.text.slice(e,t))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function wi(n,e){for(let t=n.length-1;t>=0;t--)e=n[t].type.name+"("+e+")";return e}class At{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,t){let r=new Ef(e,t);if(r.next==null)return At.empty;let o=Mi(r);r.next&&r.err("Unexpected trailing text");let s=If(Pf(o));return Vf(s,r),s}matchType(e){for(let t=0;t<this.next.length;t++)if(this.next[t].type==e)return this.next[t].next;return null}matchFragment(e,t=0,r=e.childCount){let o=this;for(let s=t;o&&s<r;s++)o=o.matchType(e.child(s).type);return o}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:t}=this.next[e];if(!(t.isText||t.hasRequiredAttrs()))return t}return null}compatible(e){for(let t=0;t<this.next.length;t++)for(let r=0;r<e.next.length;r++)if(this.next[t].type==e.next[r].type)return!0;return!1}fillBefore(e,t=!1,r=0){let o=[this];function s(i,l){let a=i.matchFragment(e,r);if(a&&(!t||a.validEnd))return C.from(l.map(c=>c.createAndFill()));for(let c=0;c<i.next.length;c++){let{type:u,next:f}=i.next[c];if(!(u.isText||u.hasRequiredAttrs())&&o.indexOf(f)==-1){o.push(f);let d=s(f,l.concat(u));if(d)return d}}return null}return s(this,[])}findWrapping(e){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==e)return this.wrapCache[r+1];let t=this.computeWrapping(e);return this.wrapCache.push(e,t),t}computeWrapping(e){let t=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let o=r.shift(),s=o.match;if(s.matchType(e)){let i=[];for(let l=o;l.type;l=l.via)i.push(l.type);return i.reverse()}for(let i=0;i<s.next.length;i++){let{type:l,next:a}=s.next[i];!l.isLeaf&&!l.hasRequiredAttrs()&&!(l.name in t)&&(!o.type||a.validEnd)&&(r.push({match:l.contentMatch,type:l,via:o}),t[l.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function t(r){e.push(r);for(let o=0;o<r.next.length;o++)e.indexOf(r.next[o].next)==-1&&t(r.next[o].next)}return t(this),e.map((r,o)=>{let s=o+(r.validEnd?"*":" ")+" ";for(let i=0;i<r.next.length;i++)s+=(i?", ":"")+r.next[i].type.name+"->"+e.indexOf(r.next[i].next);return s}).join(`
|
|
33
|
+
`)}}At.empty=new At(!0);class Ef{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 Mi(n){let e=[];do e.push(Df(n));while(n.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function Df(n){let e=[];do e.push(vf(n));while(n.next&&n.next!=")"&&n.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function vf(n){let e=Af(n);for(;;)if(n.eat("+"))e={type:"plus",expr:e};else if(n.eat("*"))e={type:"star",expr:e};else if(n.eat("?"))e={type:"opt",expr:e};else if(n.eat("{"))e=Of(n,e);else break;return e}function Ni(n){/\D/.test(n.next)&&n.err("Expected number, got '"+n.next+"'");let e=Number(n.next);return n.pos++,e}function Of(n,e){let t=Ni(n),r=t;return n.eat(",")&&(n.next!="}"?r=Ni(n):r=-1),n.eat("}")||n.err("Unclosed braced range"),{type:"range",min:t,max:r,expr:e}}function Tf(n,e){let t=n.nodeTypes,r=t[e];if(r)return[r];let o=[];for(let s in t){let i=t[s];i.isInGroup(e)&&o.push(i)}return o.length==0&&n.err("No node type or group '"+e+"' found"),o}function Af(n){if(n.eat("(")){let e=Mi(n);return n.eat(")")||n.err("Missing closing paren"),e}else if(/\W/.test(n.next))n.err("Unexpected token '"+n.next+"'");else{let e=Tf(n,n.next).map(t=>(n.inline==null?n.inline=t.isInline:n.inline!=t.isInline&&n.err("Mixing inline and block content"),{type:"name",value:t}));return n.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function Pf(n){let e=[[]];return o(s(n,0),t()),e;function t(){return e.push([])-1}function r(i,l,a){let c={term:a,to:l};return e[i].push(c),c}function o(i,l){i.forEach(a=>a.to=l)}function s(i,l){if(i.type=="choice")return i.exprs.reduce((a,c)=>a.concat(s(c,l)),[]);if(i.type=="seq")for(let a=0;;a++){let c=s(i.exprs[a],l);if(a==i.exprs.length-1)return c;o(c,l=t())}else if(i.type=="star"){let a=t();return r(l,a),o(s(i.expr,a),a),[r(a)]}else if(i.type=="plus"){let a=t();return o(s(i.expr,l),a),o(s(i.expr,a),a),[r(a)]}else{if(i.type=="opt")return[r(l)].concat(s(i.expr,l));if(i.type=="range"){let a=l;for(let c=0;c<i.min;c++){let u=t();o(s(i.expr,a),u),a=u}if(i.max==-1)o(s(i.expr,a),a);else for(let c=i.min;c<i.max;c++){let u=t();r(a,u),o(s(i.expr,a),u),a=u}return[r(a)]}else{if(i.type=="name")return[r(l,void 0,i.value)];throw new Error("Unknown expr type")}}}}function Ei(n,e){return e-n}function Di(n,e){let t=[];return r(e),t.sort(Ei);function r(o){let s=n[o];if(s.length==1&&!s[0].term)return r(s[0].to);t.push(o);for(let i=0;i<s.length;i++){let{term:l,to:a}=s[i];!l&&t.indexOf(a)==-1&&r(a)}}}function If(n){let e=Object.create(null);return t(Di(n,0));function t(r){let o=[];r.forEach(i=>{n[i].forEach(({term:l,to:a})=>{if(!l)return;let c;for(let u=0;u<o.length;u++)o[u][0]==l&&(c=o[u][1]);Di(n,a).forEach(u=>{c||o.push([l,c=[]]),c.indexOf(u)==-1&&c.push(u)})})});let s=e[r.join(",")]=new At(r.indexOf(n.length-1)>-1);for(let i=0;i<o.length;i++){let l=o[i][1].sort(Ei);s.next.push({type:o[i][0],next:e[l.join(",")]||t(l)})}return s}}function Vf(n,e){for(let t=0,r=[n];t<r.length;t++){let o=r[t],s=!o.validEnd,i=[];for(let l=0;l<o.next.length;l++){let{type:a,next:c}=o.next[l];i.push(a.name),s&&!(a.isText||a.hasRequiredAttrs())&&(s=!1),r.indexOf(c)==-1&&r.push(c)}s&&e.err("Only non-generatable nodes ("+i.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function vi(n){let e=Object.create(null);for(let t in n){let r=n[t];if(!r.hasDefault)return null;e[t]=r.default}return e}function Oi(n,e){let t=Object.create(null);for(let r in n){let o=e&&e[r];if(o===void 0){let s=n[r];if(s.hasDefault)o=s.default;else throw new RangeError("No value supplied for attribute "+r)}t[r]=o}return t}function Ti(n,e,t,r){for(let o in e)if(!(o in n))throw new RangeError(`Unsupported attribute ${o} for ${t} of type ${o}`);for(let o in n){let s=n[o];s.validate&&s.validate(e[o])}}function Ai(n,e){let t=Object.create(null);if(e)for(let r in e)t[r]=new zf(n,r,e[r]);return t}let Pi=class df{constructor(e,t,r){this.name=e,this.schema=t,this.spec=r,this.markSet=null,this.groups=r.group?r.group.split(" "):[],this.attrs=Ai(e,r.attrs),this.defaultAttrs=vi(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(r.inline||e=="text"),this.isText=e=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==At.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(e){return this.groups.indexOf(e)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:Oi(this.attrs,e)}create(e=null,t,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new be(this,this.computeAttrs(e),C.from(t),F.setFrom(r))}createChecked(e=null,t,r){return t=C.from(t),this.checkContent(t),new be(this,this.computeAttrs(e),t,F.setFrom(r))}createAndFill(e=null,t,r){if(e=this.computeAttrs(e),t=C.from(t),t.size){let i=this.contentMatch.fillBefore(t);if(!i)return null;t=i.append(t)}let o=this.contentMatch.matchFragment(t),s=o&&o.fillBefore(C.empty,!0);return s?new be(this,e,t.append(s),F.setFrom(r)):null}validContent(e){let t=this.contentMatch.matchFragment(e);if(!t||!t.validEnd)return!1;for(let r=0;r<e.childCount;r++)if(!this.allowsMarks(e.child(r).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){Ti(this.attrs,e,"node",this.name)}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let t=0;t<e.length;t++)if(!this.allowsMarkType(e[t].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let t;for(let r=0;r<e.length;r++)this.allowsMarkType(e[r].type)?t&&t.push(e[r]):t||(t=e.slice(0,r));return t?t.length?t:F.none:e}static compile(e,t){let r=Object.create(null);e.forEach((s,i)=>r[s]=new df(s,t,i));let o=t.spec.topNode||"doc";if(!r[o])throw new RangeError("Schema is missing its top node type ('"+o+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let s in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function Rf(n,e,t){let r=t.split("|");return o=>{let s=o===null?"null":typeof o;if(r.indexOf(s)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${n}, got ${s}`)}}class zf{constructor(e,t,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?Rf(e,t,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class br{constructor(e,t,r,o){this.name=e,this.rank=t,this.schema=r,this.spec=o,this.attrs=Ai(e,o.attrs),this.excluded=null;let s=vi(this.attrs);this.instance=s?new F(this,s):null}create(e=null){return!e&&this.instance?this.instance:new F(this,Oi(this.attrs,e))}static compile(e,t){let r=Object.create(null),o=0;return e.forEach((s,i)=>r[s]=new br(s,o++,t,i)),r}removeFromSet(e){for(var t=0;t<e.length;t++)e[t].type==this&&(e=e.slice(0,t).concat(e.slice(t+1)),t--);return e}isInSet(e){for(let t=0;t<e.length;t++)if(e[t].type==this)return e[t]}checkAttrs(e){Ti(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}class xr{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let t=this.spec={};for(let o in e)t[o]=e[o];t.nodes=Z.from(e.nodes),t.marks=Z.from(e.marks||{}),this.nodes=Pi.compile(this.spec.nodes,this),this.marks=br.compile(this.spec.marks,this);let r=Object.create(null);for(let o in this.nodes){if(o in this.marks)throw new RangeError(o+" can not be both a node and a mark");let s=this.nodes[o],i=s.spec.content||"",l=s.spec.marks;if(s.contentMatch=r[i]||(r[i]=At.parse(i,this.nodes)),s.inlineContent=s.contentMatch.inlineContent,s.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!s.isInline||!s.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=s}s.markSet=l=="_"?null:l?Ii(this,l.split(" ")):l==""||!s.inlineContent?[]:null}for(let o in this.marks){let s=this.marks[o],i=s.spec.excludes;s.excluded=i==null?[s]:i==""?[]:Ii(this,i.split(" "))}this.nodeFromJSON=this.nodeFromJSON.bind(this),this.markFromJSON=this.markFromJSON.bind(this),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,t=null,r,o){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof Pi){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(t,r,o)}text(e,t){let r=this.nodes.text;return new yr(r,r.defaultAttrs,e,F.setFrom(t))}mark(e,t){return typeof e=="string"&&(e=this.marks[e]),e.create(t)}nodeFromJSON(e){return be.fromJSON(this,e)}markFromJSON(e){return F.fromJSON(this,e)}nodeType(e){let t=this.nodes[e];if(!t)throw new RangeError("Unknown node type: "+e);return t}}function Ii(n,e){let t=[];for(let r=0;r<e.length;r++){let o=e[r],s=n.marks[o],i=s;if(s)t.push(s);else for(let l in n.marks){let a=n.marks[l];(o=="_"||a.spec.group&&a.spec.group.split(" ").indexOf(o)>-1)&&t.push(i=a)}if(!i)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return t}function $f(n){return n.tag!=null}function jf(n){return n.style!=null}class Pt{constructor(e,t){this.schema=e,this.rules=t,this.tags=[],this.styles=[];let r=this.matchedStyles=[];t.forEach(o=>{if($f(o))this.tags.push(o);else if(jf(o)){let s=/[^=]*/.exec(o.style)[0];r.indexOf(s)<0&&r.push(s),this.styles.push(o)}}),this.normalizeLists=!this.tags.some(o=>{if(!/^(ul|ol)\b/.test(o.tag)||!o.node)return!1;let s=e.nodes[o.node];return s.contentMatch.matchType(s)})}parse(e,t={}){let r=new $i(this,t,!1);return r.addAll(e,F.none,t.from,t.to),r.finish()}parseSlice(e,t={}){let r=new $i(this,t,!0);return r.addAll(e,F.none,t.from,t.to),E.maxOpen(r.finish())}matchTag(e,t,r){for(let o=r?this.tags.indexOf(r)+1:0;o<this.tags.length;o++){let s=this.tags[o];if(Lf(e,s.tag)&&(s.namespace===void 0||e.namespaceURI==s.namespace)&&(!s.context||t.matchesContext(s.context))){if(s.getAttrs){let i=s.getAttrs(e);if(i===!1)continue;s.attrs=i||void 0}return s}}}matchStyle(e,t,r,o){for(let s=o?this.styles.indexOf(o)+1:0;s<this.styles.length;s++){let i=this.styles[s],l=i.style;if(!(l.indexOf(e)!=0||i.context&&!r.matchesContext(i.context)||l.length>e.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=t))){if(i.getAttrs){let a=i.getAttrs(t);if(a===!1)continue;i.attrs=a||void 0}return i}}}static schemaRules(e){let t=[];function r(o){let s=o.priority==null?50:o.priority,i=0;for(;i<t.length;i++){let l=t[i];if((l.priority==null?50:l.priority)<s)break}t.splice(i,0,o)}for(let o in e.marks){let s=e.marks[o].spec.parseDOM;s&&s.forEach(i=>{r(i=ji(i)),i.mark||i.ignore||i.clearMark||(i.mark=o)})}for(let o in e.nodes){let s=e.nodes[o].spec.parseDOM;s&&s.forEach(i=>{r(i=ji(i)),i.node||i.ignore||i.mark||(i.node=o)})}return t}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Pt(e,Pt.schemaRules(e)))}}const Vi={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},Bf={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Ri={ol:!0,ul:!0},En=1,po=2,kr=4;function zi(n,e,t){return e!=null?(e?En:0)|(e==="full"?po:0):n&&n.whitespace=="pre"?En|po:t&-5}class Sr{constructor(e,t,r,o,s,i){this.type=e,this.attrs=t,this.marks=r,this.solid=o,this.options=i,this.content=[],this.activeMarks=F.none,this.match=s||(i&kr?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let t=this.type.contentMatch.fillBefore(C.from(e));if(t)this.match=this.type.contentMatch.matchFragment(t);else{let r=this.type.contentMatch,o;return(o=r.findWrapping(e.type))?(this.match=r,o):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&En)){let r=this.content[this.content.length-1],o;if(r&&r.isText&&(o=/[ \t\r\n\u000c]+$/.exec(r.text))){let s=r;r.text.length==o[0].length?this.content.pop():this.content[this.content.length-1]=s.withText(s.text.slice(0,s.text.length-o[0].length))}}let t=C.from(this.content);return!e&&this.match&&(t=t.append(this.match.fillBefore(C.empty,!0))),this.type?this.type.create(this.attrs,t,this.marks):t}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!Vi.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class $i{constructor(e,t,r){this.parser=e,this.options=t,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let o=t.topNode,s,i=zi(null,t.preserveWhitespace,0)|(r?kr:0);o?s=new Sr(o.type,o.attrs,F.none,!0,t.topMatch||o.type.contentMatch,i):r?s=new Sr(null,null,F.none,!0,null,i):s=new Sr(e.schema.topNodeType,null,F.none,!0,null,i),this.nodes=[s],this.find=t.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,t){e.nodeType==3?this.addTextNode(e,t):e.nodeType==1&&this.addElement(e,t)}addTextNode(e,t){let r=e.nodeValue,o=this.top,s=o.options&po?"full":this.localPreserveWS||(o.options&En)>0;if(s==="full"||o.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(s)s!=="full"?r=r.replace(/\r?\n|\r/g," "):r=r.replace(/\r\n?/g,`
|
|
34
34
|
`);else if(r=r.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(r)&&this.open==this.nodes.length-1){let i=o.content[o.content.length-1],l=e.previousSibling;(!i||l&&l.nodeName=="BR"||i.isText&&/[ \t\r\n\u000c]$/.test(i.text))&&(r=r.slice(1))}r&&this.insertNode(this.parser.schema.text(r),t,!/\S/.test(r)),this.findInText(e)}else this.findInside(e)}addElement(e,t,r){let o=this.localPreserveWS,s=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let i=e.nodeName.toLowerCase(),l;Ri.hasOwnProperty(i)&&this.parser.normalizeLists&&Ff(e);let a=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(l=this.parser.matchTag(e,this,r));e:if(a?a.ignore:Bf.hasOwnProperty(i))this.findInside(e),this.ignoreFallback(e,t);else if(!a||a.skip||a.closeParent){a&&a.closeParent?this.open=Math.max(0,this.open-1):a&&a.skip.nodeType&&(e=a.skip);let c,u=this.needsBlock;if(Vi.hasOwnProperty(i))s.content.length&&s.content[0].isInline&&this.open&&(this.open--,s=this.top),c=!0,s.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,t);break e}let f=a&&a.skip?t:this.readStyles(e,t);f&&this.addAll(e,f),c&&this.sync(s),this.needsBlock=u}else{let c=this.readStyles(e,t);c&&this.addElementByRule(e,a,c,a.consuming===!1?l:void 0)}this.localPreserveWS=o}leafFallback(e,t){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
|
|
35
|
-
`),t)}ignoreFallback(e,t){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),t,!0)}readStyles(e,t){let r=e.style;if(r&&r.length)for(let o=0;o<this.parser.matchedStyles.length;o++){let s=this.parser.matchedStyles[o],i=r.getPropertyValue(s);if(i)for(let l=void 0;;){let a=this.parser.matchStyle(s,i,this,l);if(!a)break;if(a.ignore)return null;if(a.clearMark?t=t.filter(c=>!a.clearMark(c)):t=t.concat(this.parser.schema.marks[a.mark].create(a.attrs)),a.consuming===!1)l=a;else break}}return t}addElementByRule(e,t,r,o){let s,i;if(t.node)if(i=this.parser.schema.nodes[t.node],i.isLeaf)this.insertNode(i.create(t.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let a=this.enter(i,t.attrs||null,r,t.preserveWhitespace);a&&(s=!0,r=a)}else{let a=this.parser.schema.marks[t.mark];r=r.concat(a.create(t.attrs))}let l=this.top;if(i&&i.isLeaf)this.findInside(e);else if(o)this.addElement(e,r,o);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a,r,!1));else{let a=e;typeof t.contentElement=="string"?a=e.querySelector(t.contentElement):typeof t.contentElement=="function"?a=t.contentElement(e):t.contentElement&&(a=t.contentElement),this.findAround(e,a,!0),this.addAll(a,r),this.findAround(e,a,!1)}s&&this.sync(l)&&this.open--}addAll(e,t,r,o){let s=r||0;for(let i=r?e.childNodes[r]:e.firstChild,l=o==null?null:e.childNodes[o];i!=l;i=i.nextSibling,++s)this.findAtPoint(e,s),this.addDOM(i,t);this.findAtPoint(e,s)}findPlace(e,t,r){let o,s;for(let i=this.open,l=0;i>=0;i--){let a=this.nodes[i],c=a.findWrapping(e);if(c&&(!o||o.length>c.length+l)&&(o=c,s=a,!c.length))break;if(a.solid){if(r)break;l+=2}}if(!o)return null;this.sync(s);for(let i=0;i<o.length;i++)t=this.enterInner(o[i],null,t,!1);return t}insertNode(e,t,r){if(e.isInline&&this.needsBlock&&!this.top.type){let s=this.textblockFromContext();s&&(t=this.enterInner(s,null,t))}let o=this.findPlace(e,t,r);if(o){this.closeExtra();let s=this.top;s.match&&(s.match=s.match.matchType(e.type));let i=F.none;for(let l of o.concat(e.marks))(s.type?s.type.allowsMarkType(l.type):Bi(l.type,e.type))&&(i=l.addToSet(i));return s.content.push(e.mark(i)),!0}return!1}enter(e,t,r,o){let s=this.findPlace(e.create(t),r,!1);return s&&(s=this.enterInner(e,t,r,!0,o)),s}enterInner(e,t,r,o=!1,s){this.closeExtra();let i=this.top;i.match=i.match&&i.match.matchType(e);let l=zi(e,s,i.options);i.options&kr&&i.content.length==0&&(l|=kr);let a=F.none;return r=r.filter(c=>(i.type?i.type.allowsMarkType(c.type):Bi(c.type,e))?(a=c.addToSet(a),!1):!0),this.nodes.push(new Sr(e,t,a,o,null,l)),this.open++,r}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let t=this.open;t>=0;t--){if(this.nodes[t]==e)return this.open=t,!0;this.localPreserveWS&&(this.nodes[t].options|=En)}return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let r=this.nodes[t].content;for(let o=r.length-1;o>=0;o--)e+=r[o].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==t&&(this.find[r].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].pos==null&&e.nodeType==1&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,r){if(e!=t&&this.find)for(let o=0;o<this.find.length;o++)this.find[o].pos==null&&e.nodeType==1&&e.contains(this.find[o].node)&&t.compareDocumentPosition(this.find[o].node)&(r?2:4)&&(this.find[o].pos=this.currentPos)}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split("/"),r=this.options.context,o=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),s=-(r?r.depth+1:0)+(o?0:1),i=(l,a)=>{for(;l>=0;l--){let c=t[l];if(c==""){if(l==t.length-1||l==0)continue;for(;a>=s;a--)if(i(l-1,a))return!0;return!1}else{let u=a>0||a==0&&o?this.nodes[a].type:r&&a>=s?r.node(a-s).type:null;if(!u||u.name!=c&&!u.isInGroup(c))return!1;a--}}return!0};return i(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let r=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let t in this.parser.schema.nodes){let r=this.parser.schema.nodes[t];if(r.isTextblock&&r.defaultAttrs)return r}}}function Ff(n){for(let e=n.firstChild,t=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&Ri.hasOwnProperty(r)&&t?(t.appendChild(e),e=t):r=="li"?t=e:r&&(t=null)}}function Lf(n,e){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,e)}function ji(n){let e={};for(let t in n)e[t]=n[t];return e}function Bi(n,e){let t=e.schema.nodes;for(let r in t){let o=t[r];if(!o.allowsMarkType(n))continue;let s=[],i=l=>{s.push(l);for(let a=0;a<l.edgeCount;a++){let{type:c,next:u}=l.edge(a);if(c==e||s.indexOf(u)<0&&i(u))return!0}};if(i(o.contentMatch))return!0}}class $e{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},r){r||(r=mo(t).createDocumentFragment());let o=r,s=[];return e.forEach(i=>{if(s.length||i.marks.length){let l=0,a=0;for(;l<s.length&&a<i.marks.length;){let c=i.marks[a];if(!this.marks[c.type.name]){a++;continue}if(!c.eq(s[l][0])||c.type.spec.spanning===!1)break;l++,a++}for(;l<s.length;)o=s.pop()[1];for(;a<i.marks.length;){let c=i.marks[a++],u=this.serializeMark(c,i.isInline,t);u&&(s.push([c,o]),o.appendChild(u.dom),o=u.contentDOM||u.dom)}}o.appendChild(this.serializeNodeInner(i,t))}),r}serializeNodeInner(e,t){let{dom:r,contentDOM:o}=Cr(mo(t),this.nodes[e.type.name](e),null,e.attrs);if(o){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,o)}return r}serializeNode(e,t={}){let r=this.serializeNodeInner(e,t);for(let o=e.marks.length-1;o>=0;o--){let s=this.serializeMark(e.marks[o],e.isInline,t);s&&((s.contentDOM||s.dom).appendChild(r),r=s.dom)}return r}serializeMark(e,t,r={}){let o=this.marks[e.type.name];return o&&Cr(mo(r),o(e,t),null,e.attrs)}static renderSpec(e,t,r=null,o){return Cr(e,t,r,o)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new $e(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=Fi(e.nodes);return t.text||(t.text=r=>r.text),t}static marksFromSchema(e){return Fi(e.marks)}}function Fi(n){let e={};for(let t in n){let r=n[t].spec.toDOM;r&&(e[t]=r)}return e}function mo(n){return n.document||window.document}const Li=new WeakMap;function Wf(n){let e=Li.get(n);return e===void 0&&Li.set(n,e=_f(n)),e}function _f(n){let e=null;function t(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")e||(e=[]),e.push(r);else for(let o=0;o<r.length;o++)t(r[o]);else for(let o in r)t(r[o])}return t(n),e}function Cr(n,e,t,r){if(typeof e=="string")return{dom:n.createTextNode(e)};if(e.nodeType!=null)return{dom:e};if(e.dom&&e.dom.nodeType!=null)return e;let o=e[0],s;if(typeof o!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(s=Wf(r))&&s.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let i=o.indexOf(" ");i>0&&(t=o.slice(0,i),o=o.slice(i+1));let l,a=t?n.createElementNS(t,o):n.createElement(o),c=e[1],u=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){u=2;for(let f in c)if(c[f]!=null){let d=f.indexOf(" ");d>0?a.setAttributeNS(f.slice(0,d),f.slice(d+1),c[f]):a.setAttribute(f,c[f])}}for(let f=u;f<e.length;f++){let d=e[f];if(d===0){if(f<e.length-1||f>u)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}else{let{dom:p,contentDOM:h}=Cr(n,d,t,r);if(a.appendChild(p),h){if(l)throw new RangeError("Multiple content holes");l=h}}}return{dom:a,contentDOM:l}}const Wi=65535,_i=Math.pow(2,16);function qf(n,e){return n+e*_i}function qi(n){return n&Wi}function Hf(n){return(n-(n&Wi))/_i}const Hi=1,Ki=2,wr=4,Ji=8;class go{constructor(e,t,r){this.pos=e,this.delInfo=t,this.recover=r}get deleted(){return(this.delInfo&Ji)>0}get deletedBefore(){return(this.delInfo&(Hi|wr))>0}get deletedAfter(){return(this.delInfo&(Ki|wr))>0}get deletedAcross(){return(this.delInfo&wr)>0}}class xe{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&xe.empty)return xe.empty}recover(e){let t=0,r=qi(e);if(!this.inverted)for(let o=0;o<r;o++)t+=this.ranges[o*3+2]-this.ranges[o*3+1];return this.ranges[r*3]+t+Hf(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,r){let o=0,s=this.inverted?2:1,i=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?o:0);if(a>e)break;let c=this.ranges[l+s],u=this.ranges[l+i],f=a+c;if(e<=f){let d=c?e==a?-1:e==f?1:t:t,p=a+o+(d<0?0:u);if(r)return p;let h=e==(t<0?a:f)?null:qf(l/3,e-a),b=e==a?Ki:e==f?Hi:wr;return(t<0?e!=a:e!=f)&&(b|=Ji),new go(p,b,h)}o+=u-c}return r?e+o:new go(e+o,0,null)}touches(e,t){let r=0,o=qi(t),s=this.inverted?2:1,i=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?r:0);if(a>e)break;let c=this.ranges[l+s],u=a+c;if(e<=u&&l==o*3)return!0;r+=this.ranges[l+i]-c}return!1}forEach(e){let t=this.inverted?2:1,r=this.inverted?1:2;for(let o=0,s=0;o<this.ranges.length;o+=3){let i=this.ranges[o],l=i-(this.inverted?s:0),a=i+(this.inverted?0:s),c=this.ranges[o+t],u=this.ranges[o+r];e(l,l+c,a,a+u),s+=u-c}}invert(){return new xe(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?xe.empty:new xe(e<0?[0,-e,0]:[0,0,e])}}xe.empty=new xe([]);class Dn{constructor(e,t,r=0,o=e?e.length:0){this.mirror=t,this.from=r,this.to=o,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(e=0,t=this.maps.length){return new Dn(this._maps,this.mirror,e,t)}appendMap(e,t){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),t!=null&&this.setMirror(this._maps.length-1,t)}appendMapping(e){for(let t=0,r=this._maps.length;t<e._maps.length;t++){let o=e.getMirror(t);this.appendMap(e._maps[t],o!=null&&o<t?r+o:void 0)}}getMirror(e){if(this.mirror){for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}}setMirror(e,t){this.mirror||(this.mirror=[]),this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,r=this._maps.length+e._maps.length;t>=0;t--){let o=e.getMirror(t);this.appendMap(e._maps[t].invert(),o!=null&&o>t?r-o-1:void 0)}}invert(){let e=new Dn;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let r=this.from;r<this.to;r++)e=this._maps[r].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,r){let o=0;for(let s=this.from;s<this.to;s++){let i=this._maps[s],l=i.mapResult(e,t);if(l.recover!=null){let a=this.getMirror(s);if(a!=null&&a>s&&a<this.to){s=a,e=this._maps[a].recover(l.recover);continue}}o|=l.delInfo,e=l.pos}return r?e:new go(e,o,null)}}const yo=Object.create(null);class oe{getMap(){return xe.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=yo[t.stepType];if(!r)throw new RangeError(`No step type ${t.stepType} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in yo)throw new RangeError("Duplicate use of step JSON ID "+e);return yo[e]=t,t.prototype.jsonID=e,t}}class K{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new K(e,null)}static fail(e){return new K(null,e)}static fromReplace(e,t,r,o){try{return K.ok(e.replace(t,r,o))}catch(s){if(s instanceof pr)return K.fail(s.message);throw s}}}function bo(n,e,t){let r=[];for(let o=0;o<n.childCount;o++){let s=n.child(o);s.content.size&&(s=s.copy(bo(s.content,e,s))),s.isInline&&(s=e(s,t,o)),r.push(s)}return C.fromArray(r)}class st extends oe{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=e.resolve(this.from),o=r.node(r.sharedDepth(this.to)),s=new E(bo(t.content,(i,l)=>!i.isAtom||!l.type.allowsMarkType(this.mark.type)?i:i.mark(this.mark.addToSet(i.marks)),o),t.openStart,t.openEnd);return K.fromReplace(e,this.from,this.to,s)}invert(){return new je(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new st(t.pos,r.pos,this.mark)}merge(e){return e instanceof st&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new st(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new st(t.from,t.to,e.markFromJSON(t.mark))}}oe.jsonID("addMark",st);class je extends oe{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=new E(bo(t.content,o=>o.mark(this.mark.removeFromSet(o.marks)),e),t.openStart,t.openEnd);return K.fromReplace(e,this.from,this.to,r)}invert(){return new st(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new je(t.pos,r.pos,this.mark)}merge(e){return e instanceof je&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new je(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new je(t.from,t.to,e.markFromJSON(t.mark))}}oe.jsonID("removeMark",je);class it extends oe{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return K.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return K.fromReplace(e,this.pos,this.pos+1,new E(C.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let r=this.mark.addToSet(t.marks);if(r.length==t.marks.length){for(let o=0;o<t.marks.length;o++)if(!t.marks[o].isInSet(r))return new it(this.pos,t.marks[o]);return new it(this.pos,this.mark)}}return new It(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new it(t.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new it(t.pos,e.markFromJSON(t.mark))}}oe.jsonID("addNodeMark",it);class It extends oe{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return K.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return K.fromReplace(e,this.pos,this.pos+1,new E(C.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new it(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new It(t.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new It(t.pos,e.markFromJSON(t.mark))}}oe.jsonID("removeNodeMark",It);class se extends oe{constructor(e,t,r,o=!1){super(),this.from=e,this.to=t,this.slice=r,this.structure=o}apply(e){return this.structure&&xo(e,this.from,this.to)?K.fail("Structure replace would overwrite content"):K.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new xe([this.from,this.to-this.from,this.slice.size])}invert(e){return new se(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deletedAcross&&r.deletedAcross?null:new se(t.pos,Math.max(t.pos,r.pos),this.slice,this.structure)}merge(e){if(!(e instanceof se)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let t=this.slice.size+e.slice.size==0?E.empty:new E(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new se(this.from,this.to+(e.to-e.from),t,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let t=this.slice.size+e.slice.size==0?E.empty:new E(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new se(e.from,this.to,t,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new se(t.from,t.to,E.fromJSON(e,t.slice),!!t.structure)}}oe.jsonID("replace",se);class ee extends oe{constructor(e,t,r,o,s,i,l=!1){super(),this.from=e,this.to=t,this.gapFrom=r,this.gapTo=o,this.slice=s,this.insert=i,this.structure=l}apply(e){if(this.structure&&(xo(e,this.from,this.gapFrom)||xo(e,this.gapTo,this.to)))return K.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return K.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,t.content);return r?K.fromReplace(e,this.from,this.to,r):K.fail("Content does not fit in gap")}getMap(){return new xe([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let t=this.gapTo-this.gapFrom;return new ee(this.from,this.from+this.slice.size+t,this.from+this.insert,this.from+this.insert+t,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),o=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),s=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return t.deletedAcross&&r.deletedAcross||o<t.pos||s>r.pos?null:new ee(t.pos,r.pos,o,s,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number"||typeof t.gapFrom!="number"||typeof t.gapTo!="number"||typeof t.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new ee(t.from,t.to,t.gapFrom,t.gapTo,E.fromJSON(e,t.slice),t.insert,!!t.structure)}}oe.jsonID("replaceAround",ee);function xo(n,e,t){let r=n.resolve(e),o=t-e,s=r.depth;for(;o>0&&s>0&&r.indexAfter(s)==r.node(s).childCount;)s--,o--;if(o>0){let i=r.node(s).maybeChild(r.indexAfter(s));for(;o>0;){if(!i||i.isLeaf)return!0;i=i.firstChild,o--}}return!1}function Kf(n,e,t,r){let o=[],s=[],i,l;n.doc.nodesBetween(e,t,(a,c,u)=>{if(!a.isInline)return;let f=a.marks;if(!r.isInSet(f)&&u.type.allowsMarkType(r.type)){let d=Math.max(c,e),p=Math.min(c+a.nodeSize,t),h=r.addToSet(f);for(let b=0;b<f.length;b++)f[b].isInSet(h)||(i&&i.to==d&&i.mark.eq(f[b])?i.to=p:o.push(i=new je(d,p,f[b])));l&&l.to==d?l.to=p:s.push(l=new st(d,p,r))}}),o.forEach(a=>n.step(a)),s.forEach(a=>n.step(a))}function Jf(n,e,t,r){let o=[],s=0;n.doc.nodesBetween(e,t,(i,l)=>{if(!i.isInline)return;s++;let a=null;if(r instanceof br){let c=i.marks,u;for(;u=r.isInSet(c);)(a||(a=[])).push(u),c=u.removeFromSet(c)}else r?r.isInSet(i.marks)&&(a=[r]):a=i.marks;if(a&&a.length){let c=Math.min(l+i.nodeSize,t);for(let u=0;u<a.length;u++){let f=a[u],d;for(let p=0;p<o.length;p++){let h=o[p];h.step==s-1&&f.eq(o[p].style)&&(d=h)}d?(d.to=c,d.step=s):o.push({style:f,from:Math.max(l,e),to:c,step:s})}}}),o.forEach(i=>n.step(new je(i.from,i.to,i.style)))}function ko(n,e,t,r=t.contentMatch,o=!0){let s=n.doc.nodeAt(e),i=[],l=e+1;for(let a=0;a<s.childCount;a++){let c=s.child(a),u=l+c.nodeSize,f=r.matchType(c.type);if(!f)i.push(new se(l,u,E.empty));else{r=f;for(let d=0;d<c.marks.length;d++)t.allowsMarkType(c.marks[d].type)||n.step(new je(l,u,c.marks[d]));if(o&&c.isText&&t.whitespace!="pre"){let d,p=/\r?\n|\r/g,h;for(;d=p.exec(c.text);)h||(h=new E(C.from(t.schema.text(" ",t.allowedMarks(c.marks))),0,0)),i.push(new se(l+d.index,l+d.index+d[0].length,h))}}l=u}if(!r.validEnd){let a=r.fillBefore(C.empty,!0);n.replace(l,l,new E(a,0,0))}for(let a=i.length-1;a>=0;a--)n.step(i[a])}function Yf(n,e,t){return(e==0||n.canReplace(e,n.childCount))&&(t==n.childCount||n.canReplace(0,t))}function On(n){let t=n.parent.content.cutByIndex(n.startIndex,n.endIndex);for(let r=n.depth;;--r){let o=n.$from.node(r),s=n.$from.index(r),i=n.$to.indexAfter(r);if(r<n.depth&&o.canReplace(s,i,t))return r;if(r==0||o.type.spec.isolating||!Yf(o,s,i))break}return null}function Gf(n,e,t){let{$from:r,$to:o,depth:s}=e,i=r.before(s+1),l=o.after(s+1),a=i,c=l,u=C.empty,f=0;for(let h=s,b=!1;h>t;h--)b||r.index(h)>0?(b=!0,u=C.from(r.node(h).copy(u)),f++):a--;let d=C.empty,p=0;for(let h=s,b=!1;h>t;h--)b||o.after(h+1)<o.end(h)?(b=!0,d=C.from(o.node(h).copy(d)),p++):c++;n.step(new ee(a,c,i,l,new E(u.append(d),f,p),u.size-f,!0))}function So(n,e,t=null,r=n){let o=Xf(n,e),s=o&&Uf(r,e);return s?o.map(Yi).concat({type:e,attrs:t}).concat(s.map(Yi)):null}function Yi(n){return{type:n,attrs:null}}function Xf(n,e){let{parent:t,startIndex:r,endIndex:o}=n,s=t.contentMatchAt(r).findWrapping(e);if(!s)return null;let i=s.length?s[0]:e;return t.canReplaceWith(r,o,i)?s:null}function Uf(n,e){let{parent:t,startIndex:r,endIndex:o}=n,s=t.child(r),i=e.contentMatch.findWrapping(s.type);if(!i)return null;let a=(i.length?i[i.length-1]:e).contentMatch;for(let c=r;a&&c<o;c++)a=a.matchType(t.child(c).type);return!a||!a.validEnd?null:i}function Qf(n,e,t){let r=C.empty;for(let i=t.length-1;i>=0;i--){if(r.size){let l=t[i].type.contentMatch.matchFragment(r);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=C.from(t[i].type.create(t[i].attrs,r))}let o=e.start,s=e.end;n.step(new ee(o,s,o,s,new E(r,0,0),t.length,!0))}function Zf(n,e,t,r,o){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let s=n.steps.length;n.doc.nodesBetween(e,t,(i,l)=>{let a=typeof o=="function"?o(i):o;if(i.isTextblock&&!i.hasMarkup(r,a)&&ed(n.doc,n.mapping.slice(s).map(l),r)){let c=null;if(r.schema.linebreakReplacement){let p=r.whitespace=="pre",h=!!r.contentMatch.matchType(r.schema.linebreakReplacement);p&&!h?c=!1:!p&&h&&(c=!0)}c===!1&&Xi(n,i,l,s),ko(n,n.mapping.slice(s).map(l,1),r,void 0,c===null);let u=n.mapping.slice(s),f=u.map(l,1),d=u.map(l+i.nodeSize,1);return n.step(new ee(f,d,f+1,d-1,new E(C.from(r.create(a,null,i.marks)),0,0),1,!0)),c===!0&&Gi(n,i,l,s),!1}})}function Gi(n,e,t,r){e.forEach((o,s)=>{if(o.isText){let i,l=/\r?\n|\r/g;for(;i=l.exec(o.text);){let a=n.mapping.slice(r).map(t+1+s+i.index);n.replaceWith(a,a+1,e.type.schema.linebreakReplacement.create())}}})}function Xi(n,e,t,r){e.forEach((o,s)=>{if(o.type==o.type.schema.linebreakReplacement){let i=n.mapping.slice(r).map(t+1+s);n.replaceWith(i,i+1,e.type.schema.text(`
|
|
36
|
-
`))}})}function ed(n,e,t){let r=n.resolve(e),o=r.index();return r.parent.canReplaceWith(o,o+1,t)}function td(n,e,t,r,o){let s=n.doc.nodeAt(e);if(!s)throw new RangeError("No node at given position");t||(t=s.type);let i=t.create(r,null,o||s.marks);if(s.isLeaf)return n.replaceWith(e,e+s.nodeSize,i);if(!t.validContent(s.content))throw new RangeError("Invalid content for node type "+t.name);n.step(new ee(e,e+s.nodeSize,e+1,e+s.nodeSize-1,new E(C.from(i),0,0),1,!0))}function Qt(n,e,t=1,r){let o=n.resolve(e),s=o.depth-t,i=r&&r[r.length-1]||o.parent;if(s<0||o.parent.type.spec.isolating||!o.parent.canReplace(o.index(),o.parent.childCount)||!i.type.validContent(o.parent.content.cutByIndex(o.index(),o.parent.childCount)))return!1;for(let c=o.depth-1,u=t-2;c>s;c--,u--){let f=o.node(c),d=o.index(c);if(f.type.spec.isolating)return!1;let p=f.content.cutByIndex(d,f.childCount),h=r&&r[u+1];h&&(p=p.replaceChild(0,h.type.create(h.attrs)));let b=r&&r[u]||f;if(!f.canReplace(d+1,f.childCount)||!b.type.validContent(p))return!1}let l=o.indexAfter(s),a=r&&r[0];return o.node(s).canReplaceWith(l,l,a?a.type:o.node(s+1).type)}function nd(n,e,t=1,r){let o=n.doc.resolve(e),s=C.empty,i=C.empty;for(let l=o.depth,a=o.depth-t,c=t-1;l>a;l--,c--){s=C.from(o.node(l).copy(s));let u=r&&r[c];i=C.from(u?u.type.create(u.attrs,i):o.node(l).copy(i))}n.step(new se(e,e,new E(s.append(i),t,t),!0))}function Zt(n,e){let t=n.resolve(e),r=t.index();return Ui(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(r,r+1)}function rd(n,e){e.content.size||n.type.compatibleContent(e.type);let t=n.contentMatchAt(n.childCount),{linebreakReplacement:r}=n.type.schema;for(let o=0;o<e.childCount;o++){let s=e.child(o),i=s.type==r?n.type.schema.nodes.text:s.type;if(t=t.matchType(i),!t||!n.type.allowsMarks(s.marks))return!1}return t.validEnd}function Ui(n,e){return!!(n&&e&&!n.isLeaf&&rd(n,e))}function Qi(n,e,t=-1){let r=n.resolve(e);for(let o=r.depth;;o--){let s,i,l=r.index(o);if(o==r.depth?(s=r.nodeBefore,i=r.nodeAfter):t>0?(s=r.node(o+1),l++,i=r.node(o).maybeChild(l)):(s=r.node(o).maybeChild(l-1),i=r.node(o+1)),s&&!s.isTextblock&&Ui(s,i)&&r.node(o).canReplace(l,l+1))return e;if(o==0)break;e=t<0?r.before(o):r.after(o)}}function od(n,e,t){let r=null,{linebreakReplacement:o}=n.doc.type.schema,s=n.doc.resolve(e-t),i=s.node().type;if(o&&i.inlineContent){let u=i.whitespace=="pre",f=!!i.contentMatch.matchType(o);u&&!f?r=!1:!u&&f&&(r=!0)}let l=n.steps.length;if(r===!1){let u=n.doc.resolve(e+t);Xi(n,u.node(),u.before(),l)}i.inlineContent&&ko(n,e+t-1,i,s.node().contentMatchAt(s.index()),r==null);let a=n.mapping.slice(l),c=a.map(e-t);if(n.step(new se(c,a.map(e+t,-1),E.empty,!0)),r===!0){let u=n.doc.resolve(c);Gi(n,u.node(),u.before(),n.steps.length)}return n}function sd(n,e,t){let r=n.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),t))return e;if(r.parentOffset==0)for(let o=r.depth-1;o>=0;o--){let s=r.index(o);if(r.node(o).canReplaceWith(s,s,t))return r.before(o+1);if(s>0)return null}if(r.parentOffset==r.parent.content.size)for(let o=r.depth-1;o>=0;o--){let s=r.indexAfter(o);if(r.node(o).canReplaceWith(s,s,t))return r.after(o+1);if(s<r.node(o).childCount)return null}return null}function Co(n,e,t){let r=n.resolve(e);if(!t.content.size)return e;let o=t.content;for(let s=0;s<t.openStart;s++)o=o.firstChild.content;for(let s=1;s<=(t.openStart==0&&t.size?2:1);s++)for(let i=r.depth;i>=0;i--){let l=i==r.depth?0:r.pos<=(r.start(i+1)+r.end(i+1))/2?-1:1,a=r.index(i)+(l>0?1:0),c=r.node(i),u=!1;if(s==1)u=c.canReplace(a,a,o);else{let f=c.contentMatchAt(a).findWrapping(o.firstChild.type);u=f&&c.canReplaceWith(a,a,f[0])}if(u)return l==0?r.pos:l<0?r.before(i+1):r.after(i+1)}return null}function wo(n,e,t=e,r=E.empty){if(e==t&&!r.size)return null;let o=n.resolve(e),s=n.resolve(t);return Zi(o,s,r)?new se(e,t,r):new id(o,s,r).fit()}function Zi(n,e,t){return!t.openStart&&!t.openEnd&&n.start()==e.start()&&n.parent.canReplace(n.index(),e.index(),t.content)}class id{constructor(e,t,r){this.$from=e,this.$to=t,this.unplaced=r,this.frontier=[],this.placed=C.empty;for(let o=0;o<=e.depth;o++){let s=e.node(o);this.frontier.push({type:s.type,match:s.contentMatchAt(e.indexAfter(o))})}for(let o=e.depth;o>0;o--)this.placed=C.from(e.node(o).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let c=this.findFittable();c?this.placeNodes(c):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,r=this.$from,o=this.close(e<0?this.$to:r.doc.resolve(e));if(!o)return null;let s=this.placed,i=r.depth,l=o.depth;for(;i&&l&&s.childCount==1;)s=s.firstChild.content,i--,l--;let a=new E(s,i,l);return e>-1?new ee(r.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||r.pos!=this.$to.pos?new se(r.pos,o.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,r=0,o=this.unplaced.openEnd;r<e;r++){let s=t.firstChild;if(t.childCount>1&&(o=0),s.type.spec.isolating&&o<=r){e=r;break}t=s.content}for(let t=1;t<=2;t++)for(let r=t==1?e:this.unplaced.openStart;r>=0;r--){let o,s=null;r?(s=Mo(this.unplaced.content,r-1).firstChild,o=s.content):o=this.unplaced.content;let i=o.firstChild;for(let l=this.depth;l>=0;l--){let{type:a,match:c}=this.frontier[l],u,f=null;if(t==1&&(i?c.matchType(i.type)||(f=c.fillBefore(C.from(i),!1)):s&&a.compatibleContent(s.type)))return{sliceDepth:r,frontierDepth:l,parent:s,inject:f};if(t==2&&i&&(u=c.findWrapping(i.type)))return{sliceDepth:r,frontierDepth:l,parent:s,wrap:u};if(s&&c.matchType(s.type))break}}}openMore(){let{content:e,openStart:t,openEnd:r}=this.unplaced,o=Mo(e,t);return!o.childCount||o.firstChild.isLeaf?!1:(this.unplaced=new E(e,t+1,Math.max(r,o.size+t>=e.size-r?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:r}=this.unplaced,o=Mo(e,t);if(o.childCount<=1&&t>0){let s=e.size-t<=t+o.size;this.unplaced=new E(vn(e,t-1,1),t-1,s?t-1:r)}else this.unplaced=new E(vn(e,t,1),t,r)}placeNodes({sliceDepth:e,frontierDepth:t,parent:r,inject:o,wrap:s}){for(;this.depth>t;)this.closeFrontierNode();if(s)for(let b=0;b<s.length;b++)this.openFrontierNode(s[b]);let i=this.unplaced,l=r?r.content:i.content,a=i.openStart-e,c=0,u=[],{match:f,type:d}=this.frontier[t];if(o){for(let b=0;b<o.childCount;b++)u.push(o.child(b));f=f.matchFragment(o)}let p=l.size+e-(i.content.size-i.openEnd);for(;c<l.childCount;){let b=l.child(c),g=f.matchType(b.type);if(!g)break;c++,(c>1||a==0||b.content.size)&&(f=g,u.push(el(b.mark(d.allowedMarks(b.marks)),c==1?a:0,c==l.childCount?p:-1)))}let h=c==l.childCount;h||(p=-1),this.placed=Tn(this.placed,t,C.from(u)),this.frontier[t].match=f,h&&p<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let b=0,g=l;b<p;b++){let x=g.lastChild;this.frontier.push({type:x.type,match:x.contentMatchAt(x.childCount)}),g=x.content}this.unplaced=h?e==0?E.empty:new E(vn(i.content,e-1,1),e-1,p<0?i.openEnd:e-1):new E(vn(i.content,e,c),i.openStart,i.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],t;if(!e.type.isTextblock||!No(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(t=this.findCloseLevel(this.$to))&&t.depth==this.depth)return-1;let{depth:r}=this.$to,o=this.$to.after(r);for(;r>1&&o==this.$to.end(--r);)++o;return o}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:r,type:o}=this.frontier[t],s=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),i=No(e,t,o,r,s);if(i){for(let l=t-1;l>=0;l--){let{match:a,type:c}=this.frontier[l],u=No(e,l,c,a,!0);if(!u||u.childCount)continue e}return{depth:t,fit:i,move:s?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=Tn(this.placed,t.depth,t.fit)),e=t.move;for(let r=t.depth+1;r<=e.depth;r++){let o=e.node(r),s=o.type.contentMatch.fillBefore(o.content,!0,e.index(r));this.openFrontierNode(o.type,o.attrs,s)}return e}openFrontierNode(e,t=null,r){let o=this.frontier[this.depth];o.match=o.match.matchType(e),this.placed=Tn(this.placed,this.depth,C.from(e.create(t,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(C.empty,!0);t.childCount&&(this.placed=Tn(this.placed,this.frontier.length,t))}}function vn(n,e,t){return e==0?n.cutByIndex(t,n.childCount):n.replaceChild(0,n.firstChild.copy(vn(n.firstChild.content,e-1,t)))}function Tn(n,e,t){return e==0?n.append(t):n.replaceChild(n.childCount-1,n.lastChild.copy(Tn(n.lastChild.content,e-1,t)))}function Mo(n,e){for(let t=0;t<e;t++)n=n.firstChild.content;return n}function el(n,e,t){if(e<=0)return n;let r=n.content;return e>1&&(r=r.replaceChild(0,el(r.firstChild,e-1,r.childCount==1?t-1:0))),e>0&&(r=n.type.contentMatch.fillBefore(r).append(r),t<=0&&(r=r.append(n.type.contentMatch.matchFragment(r).fillBefore(C.empty,!0)))),n.copy(r)}function No(n,e,t,r,o){let s=n.node(e),i=o?n.indexAfter(e):n.index(e);if(i==s.childCount&&!t.compatibleContent(s.type))return null;let l=r.fillBefore(s.content,!0,i);return l&&!ld(t,s.content,i)?l:null}function ld(n,e,t){for(let r=t;r<e.childCount;r++)if(!n.allowsMarks(e.child(r).marks))return!0;return!1}function ad(n){return n.spec.defining||n.spec.definingForContent}function cd(n,e,t,r){if(!r.size)return n.deleteRange(e,t);let o=n.doc.resolve(e),s=n.doc.resolve(t);if(Zi(o,s,r))return n.step(new se(e,t,r));let i=nl(o,n.doc.resolve(t));i[i.length-1]==0&&i.pop();let l=-(o.depth+1);i.unshift(l);for(let d=o.depth,p=o.pos-1;d>0;d--,p--){let h=o.node(d).type.spec;if(h.defining||h.definingAsContext||h.isolating)break;i.indexOf(d)>-1?l=d:o.before(d)==p&&i.splice(1,0,-d)}let a=i.indexOf(l),c=[],u=r.openStart;for(let d=r.content,p=0;;p++){let h=d.firstChild;if(c.push(h),p==r.openStart)break;d=h.content}for(let d=u-1;d>=0;d--){let p=c[d],h=ad(p.type);if(h&&!p.sameMarkup(o.node(Math.abs(l)-1)))u=d;else if(h||!p.type.isTextblock)break}for(let d=r.openStart;d>=0;d--){let p=(d+u+1)%(r.openStart+1),h=c[p];if(h)for(let b=0;b<i.length;b++){let g=i[(b+a)%i.length],x=!0;g<0&&(x=!1,g=-g);let S=o.node(g-1),w=o.index(g-1);if(S.canReplaceWith(w,w,h.type,h.marks))return n.replace(o.before(g),x?s.after(g):t,new E(tl(r.content,0,r.openStart,p),p,r.openEnd))}}let f=n.steps.length;for(let d=i.length-1;d>=0&&(n.replace(e,t,r),!(n.steps.length>f));d--){let p=i[d];p<0||(e=o.before(p),t=s.after(p))}}function tl(n,e,t,r,o){if(e<t){let s=n.firstChild;n=n.replaceChild(0,s.copy(tl(s.content,e+1,t,r,s)))}if(e>r){let s=o.contentMatchAt(0),i=s.fillBefore(n).append(n);n=i.append(s.matchFragment(i).fillBefore(C.empty,!0))}return n}function ud(n,e,t,r){if(!r.isInline&&e==t&&n.doc.resolve(e).parent.content.size){let o=sd(n.doc,e,r.type);o!=null&&(e=t=o)}n.replaceRange(e,t,new E(C.from(r),0,0))}function fd(n,e,t){let r=n.doc.resolve(e),o=n.doc.resolve(t),s=nl(r,o);for(let i=0;i<s.length;i++){let l=s[i],a=i==s.length-1;if(a&&l==0||r.node(l).type.contentMatch.validEnd)return n.delete(r.start(l),o.end(l));if(l>0&&(a||r.node(l-1).canReplace(r.index(l-1),o.indexAfter(l-1))))return n.delete(r.before(l),o.after(l))}for(let i=1;i<=r.depth&&i<=o.depth;i++)if(e-r.start(i)==r.depth-i&&t>r.end(i)&&o.end(i)-t!=o.depth-i&&r.start(i-1)==o.start(i-1)&&r.node(i-1).canReplace(r.index(i-1),o.index(i-1)))return n.delete(r.before(i),t);n.delete(e,t)}function nl(n,e){let t=[],r=Math.min(n.depth,e.depth);for(let o=r;o>=0;o--){let s=n.start(o);if(s<n.pos-(n.depth-o)||e.end(o)>e.pos+(e.depth-o)||n.node(o).type.spec.isolating||e.node(o).type.spec.isolating)break;(s==e.start(o)||o==n.depth&&o==e.depth&&n.parent.inlineContent&&e.parent.inlineContent&&o&&e.start(o-1)==s-1)&&t.push(o)}return t}class en extends oe{constructor(e,t,r){super(),this.pos=e,this.attr=t,this.value=r}apply(e){let t=e.nodeAt(this.pos);if(!t)return K.fail("No node at attribute step's position");let r=Object.create(null);for(let s in t.attrs)r[s]=t.attrs[s];r[this.attr]=this.value;let o=t.type.create(r,null,t.marks);return K.fromReplace(e,this.pos,this.pos+1,new E(C.from(o),0,t.isLeaf?0:1))}getMap(){return xe.empty}invert(e){return new en(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new en(t.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.pos!="number"||typeof t.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new en(t.pos,t.attr,t.value)}}oe.jsonID("attr",en);class An extends oe{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let o in e.attrs)t[o]=e.attrs[o];t[this.attr]=this.value;let r=e.type.create(t,e.content,e.marks);return K.ok(r)}getMap(){return xe.empty}invert(e){return new An(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new An(t.attr,t.value)}}oe.jsonID("docAttr",An);let tn=class extends Error{};tn=function n(e){let t=Error.call(this,e);return t.__proto__=n.prototype,t},tn.prototype=Object.create(Error.prototype),tn.prototype.constructor=tn,tn.prototype.name="TransformError";class rl{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Dn}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new tn(t.failed);return this}maybeStep(e){let t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t}get docChanged(){return this.steps.length>0}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,r=E.empty){let o=wo(this.doc,e,t,r);return o&&this.step(o),this}replaceWith(e,t,r){return this.replace(e,t,new E(C.from(r),0,0))}delete(e,t){return this.replace(e,t,E.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,r){return cd(this,e,t,r),this}replaceRangeWith(e,t,r){return ud(this,e,t,r),this}deleteRange(e,t){return fd(this,e,t),this}lift(e,t){return Gf(this,e,t),this}join(e,t=1){return od(this,e,t),this}wrap(e,t){return Qf(this,e,t),this}setBlockType(e,t=e,r,o=null){return Zf(this,e,t,r,o),this}setNodeMarkup(e,t,r=null,o){return td(this,e,t,r,o),this}setNodeAttribute(e,t,r){return this.step(new en(e,t,r)),this}setDocAttribute(e,t){return this.step(new An(e,t)),this}addNodeMark(e,t){return this.step(new it(e,t)),this}removeNodeMark(e,t){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(t instanceof F)t.isInSet(r.marks)&&this.step(new It(e,t));else{let o=r.marks,s,i=[];for(;s=t.isInSet(o);)i.push(new It(e,s)),o=s.removeFromSet(o);for(let l=i.length-1;l>=0;l--)this.step(i[l])}return this}split(e,t=1,r){return nd(this,e,t,r),this}addMark(e,t,r){return Kf(this,e,t,r),this}removeMark(e,t,r){return Jf(this,e,t,r),this}clearIncompatible(e,t,r){return ko(this,e,t,r),this}}const Eo=Object.create(null);class R{constructor(e,t,r){this.$anchor=e,this.$head=t,this.ranges=r||[new ol(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=E.empty){let r=t.content.lastChild,o=null;for(let l=0;l<t.openEnd;l++)o=r,r=r.lastChild;let s=e.steps.length,i=this.ranges;for(let l=0;l<i.length;l++){let{$from:a,$to:c}=i[l],u=e.mapping.slice(s);e.replaceRange(u.map(a.pos),u.map(c.pos),l?E.empty:t),l==0&&ll(e,s,(r?r.isInline:o&&o.isTextblock)?-1:1)}}replaceWith(e,t){let r=e.steps.length,o=this.ranges;for(let s=0;s<o.length;s++){let{$from:i,$to:l}=o[s],a=e.mapping.slice(r),c=a.map(i.pos),u=a.map(l.pos);s?e.deleteRange(c,u):(e.replaceRangeWith(c,u,t),ll(e,r,t.isInline?-1:1))}}static findFrom(e,t,r=!1){let o=e.parent.inlineContent?new V(e):nn(e.node(0),e.parent,e.pos,e.index(),t,r);if(o)return o;for(let s=e.depth-1;s>=0;s--){let i=t<0?nn(e.node(0),e.node(s),e.before(s+1),e.index(s),t,r):nn(e.node(0),e.node(s),e.after(s+1),e.index(s)+1,t,r);if(i)return i}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new ge(e.node(0))}static atStart(e){return nn(e,e,0,0,1)||new ge(e)}static atEnd(e){return nn(e,e,e.content.size,e.childCount,-1)||new ge(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=Eo[t.type];if(!r)throw new RangeError(`No selection type ${t.type} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in Eo)throw new RangeError("Duplicate use of selection JSON ID "+e);return Eo[e]=t,t.prototype.jsonID=e,t}getBookmark(){return V.between(this.$anchor,this.$head).getBookmark()}}R.prototype.visible=!0;class ol{constructor(e,t){this.$from=e,this.$to=t}}let sl=!1;function il(n){!sl&&!n.parent.inlineContent&&(sl=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+n.parent.type.name+")"))}class V extends R{constructor(e,t=e){il(e),il(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let r=e.resolve(t.map(this.head));if(!r.parent.inlineContent)return R.near(r);let o=e.resolve(t.map(this.anchor));return new V(o.parent.inlineContent?o:r,r)}replace(e,t=E.empty){if(super.replace(e,t),t==E.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof V&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Mr(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if(typeof t.anchor!="number"||typeof t.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new V(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,r=t){let o=e.resolve(t);return new this(o,r==t?o:e.resolve(r))}static between(e,t,r){let o=e.pos-t.pos;if((!r||o)&&(r=o>=0?1:-1),!t.parent.inlineContent){let s=R.findFrom(t,r,!0)||R.findFrom(t,-r,!0);if(s)t=s.$head;else return R.near(t,r)}return e.parent.inlineContent||(o==0?e=t:(e=(R.findFrom(e,-r,!0)||R.findFrom(e,r,!0)).$anchor,e.pos<t.pos!=o<0&&(e=t))),new V(e,t)}}R.jsonID("text",V);class Mr{constructor(e,t){this.anchor=e,this.head=t}map(e){return new Mr(e.map(this.anchor),e.map(this.head))}resolve(e){return V.between(e.resolve(this.anchor),e.resolve(this.head))}}class O extends R{constructor(e){let t=e.nodeAfter,r=e.node(0).resolve(e.pos+t.nodeSize);super(e,r),this.node=t}map(e,t){let{deleted:r,pos:o}=t.mapResult(this.anchor),s=e.resolve(o);return r?R.near(s):new O(s)}content(){return new E(C.from(this.node),0,0)}eq(e){return e instanceof O&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new Do(this.anchor)}static fromJSON(e,t){if(typeof t.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new O(e.resolve(t.anchor))}static create(e,t){return new O(e.resolve(t))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}O.prototype.visible=!1,R.jsonID("node",O);class Do{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:r}=e.mapResult(this.anchor);return t?new Mr(r,r):new Do(r)}resolve(e){let t=e.resolve(this.anchor),r=t.nodeAfter;return r&&O.isSelectable(r)?new O(t):R.near(t)}}class ge extends R{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=E.empty){if(t==E.empty){e.delete(0,e.doc.content.size);let r=R.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new ge(e)}map(e){return new ge(e)}eq(e){return e instanceof ge}getBookmark(){return dd}}R.jsonID("all",ge);const dd={map(){return this},resolve(n){return new ge(n)}};function nn(n,e,t,r,o,s=!1){if(e.inlineContent)return V.create(n,t);for(let i=r-(o>0?0:1);o>0?i<e.childCount:i>=0;i+=o){let l=e.child(i);if(l.isAtom){if(!s&&O.isSelectable(l))return O.create(n,t-(o<0?l.nodeSize:0))}else{let a=nn(n,l,t+o,o<0?l.childCount:0,o,s);if(a)return a}t+=l.nodeSize*o}return null}function ll(n,e,t){let r=n.steps.length-1;if(r<e)return;let o=n.steps[r];if(!(o instanceof se||o instanceof ee))return;let s=n.mapping.maps[r],i;s.forEach((l,a,c,u)=>{i==null&&(i=u)}),n.setSelection(R.near(n.doc.resolve(i),t))}const al=1,cl=2,ul=4;class hd extends rl{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(e){if(e.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=(this.updated|al)&-3,this.storedMarks=null,this}get selectionSet(){return(this.updated&al)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=cl,this}ensureMarks(e){return F.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&cl)>0}addStep(e,t){super.addStep(e,t),this.updated=this.updated&-3,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let r=this.selection;return t&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||F.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,r){let o=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(o.text(e),!0):this.deleteSelection();{if(r==null&&(r=t),r=r??t,!e)return this.deleteRange(t,r);let s=this.storedMarks;if(!s){let i=this.doc.resolve(t);s=r==t?i.marks():i.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(t,r,o.text(e,s)),this.selection.empty||this.setSelection(R.near(this.selection.$to)),this}}setMeta(e,t){return this.meta[typeof e=="string"?e:e.key]=t,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=ul,this}get scrolledIntoView(){return(this.updated&ul)>0}}function fl(n,e){return!e||!n?n:n.bind(e)}class Pn{constructor(e,t,r){this.name=e,this.init=fl(t.init,r),this.apply=fl(t.apply,r)}}const pd=[new Pn("doc",{init(n){return n.doc||n.schema.topNodeType.createAndFill()},apply(n){return n.doc}}),new Pn("selection",{init(n,e){return n.selection||R.atStart(e.doc)},apply(n){return n.selection}}),new Pn("storedMarks",{init(n){return n.storedMarks||null},apply(n,e,t,r){return r.selection.$cursor?n.storedMarks:null}}),new Pn("scrollToSelection",{init(){return 0},apply(n,e){return n.scrolledIntoView?e+1:e}})];class Oo{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=pd.slice(),t&&t.forEach(r=>{if(this.pluginsByKey[r.key])throw new RangeError("Adding different instances of a keyed plugin ("+r.key+")");this.plugins.push(r),this.pluginsByKey[r.key]=r,r.spec.state&&this.fields.push(new Pn(r.key,r.spec.state,r))})}}class Ge{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,t=-1){for(let r=0;r<this.config.plugins.length;r++)if(r!=t){let o=this.config.plugins[r];if(o.spec.filterTransaction&&!o.spec.filterTransaction.call(o,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let t=[e],r=this.applyInner(e),o=null;for(;;){let s=!1;for(let i=0;i<this.config.plugins.length;i++){let l=this.config.plugins[i];if(l.spec.appendTransaction){let a=o?o[i].n:0,c=o?o[i].state:this,u=a<t.length&&l.spec.appendTransaction.call(l,a?t.slice(a):t,c,r);if(u&&r.filterTransaction(u,i)){if(u.setMeta("appendedTransaction",e),!o){o=[];for(let f=0;f<this.config.plugins.length;f++)o.push(f<i?{state:r,n:t.length}:{state:this,n:0})}t.push(u),r=r.applyInner(u),s=!0}o&&(o[i]={state:r,n:t.length})}}if(!s)return{state:r,transactions:t}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let t=new Ge(this.config),r=this.config.fields;for(let o=0;o<r.length;o++){let s=r[o];t[s.name]=s.apply(e,this[s.name],this,t)}return t}get tr(){return new hd(this)}static create(e){let t=new Oo(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new Ge(t);for(let o=0;o<t.fields.length;o++)r[t.fields[o].name]=t.fields[o].init(e,r);return r}reconfigure(e){let t=new Oo(this.schema,e.plugins),r=t.fields,o=new Ge(t);for(let s=0;s<r.length;s++){let i=r[s].name;o[i]=this.hasOwnProperty(i)?this[i]:r[s].init(e,o)}return o}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map(r=>r.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let o=e[r],s=o.spec.state;s&&s.toJSON&&(t[r]=s.toJSON.call(o,this[o.key]))}return t}static fromJSON(e,t,r){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let o=new Oo(e.schema,e.plugins),s=new Ge(o);return o.fields.forEach(i=>{if(i.name=="doc")s.doc=be.fromJSON(e.schema,t.doc);else if(i.name=="selection")s.selection=R.fromJSON(s.doc,t.selection);else if(i.name=="storedMarks")t.storedMarks&&(s.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let l in r){let a=r[l],c=a.spec.state;if(a.key==i.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(t,l)){s[i.name]=c.fromJSON.call(a,e,t[l],s);return}}s[i.name]=i.init(e,s)}}),s}}function dl(n,e,t){for(let r in n){let o=n[r];o instanceof Function?o=o.bind(e):r=="handleDOMEvents"&&(o=dl(o,e,{})),t[r]=o}return t}class Be{constructor(e){this.spec=e,this.props={},e.props&&dl(e.props,this,this.props),this.key=e.key?e.key.key:hl("plugin")}getState(e){return e[this.key]}}const vo=Object.create(null);function hl(n){return n in vo?n+"$"+ ++vo[n]:(vo[n]=0,n+"$")}class lt{constructor(e="key"){this.key=hl(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}var Nr=200,X=function(){};X.prototype.append=function(e){return e.length?(e=X.from(e),!this.length&&e||e.length<Nr&&this.leafAppend(e)||this.length<Nr&&e.leafPrepend(this)||this.appendInner(e)):this},X.prototype.prepend=function(e){return e.length?X.from(e).append(this):this},X.prototype.appendInner=function(e){return new md(this,e)},X.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?X.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},X.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},X.prototype.forEach=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length),t<=r?this.forEachInner(e,t,r,0):this.forEachInvertedInner(e,t,r,0)},X.prototype.map=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length);var o=[];return this.forEach(function(s,i){return o.push(e(s,i))},t,r),o},X.from=function(e){return e instanceof X?e:e&&e.length?new pl(e):X.empty};var pl=function(n){function e(r){n.call(this),this.values=r}n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e;var t={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(o,s){return o==0&&s==this.length?this:new e(this.values.slice(o,s))},e.prototype.getInner=function(o){return this.values[o]},e.prototype.forEachInner=function(o,s,i,l){for(var a=s;a<i;a++)if(o(this.values[a],l+a)===!1)return!1},e.prototype.forEachInvertedInner=function(o,s,i,l){for(var a=s-1;a>=i;a--)if(o(this.values[a],l+a)===!1)return!1},e.prototype.leafAppend=function(o){if(this.length+o.length<=Nr)return new e(this.values.concat(o.flatten()))},e.prototype.leafPrepend=function(o){if(this.length+o.length<=Nr)return new e(o.flatten().concat(this.values))},t.length.get=function(){return this.values.length},t.depth.get=function(){return 0},Object.defineProperties(e.prototype,t),e}(X);X.empty=new pl([]);var md=function(n){function e(t,r){n.call(this),this.left=t,this.right=r,this.length=t.length+r.length,this.depth=Math.max(t.depth,r.depth)+1}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(r){return r<this.left.length?this.left.get(r):this.right.get(r-this.left.length)},e.prototype.forEachInner=function(r,o,s,i){var l=this.left.length;if(o<l&&this.left.forEachInner(r,o,Math.min(s,l),i)===!1||s>l&&this.right.forEachInner(r,Math.max(o-l,0),Math.min(this.length,s)-l,i+l)===!1)return!1},e.prototype.forEachInvertedInner=function(r,o,s,i){var l=this.left.length;if(o>l&&this.right.forEachInvertedInner(r,o-l,Math.max(s,l)-l,i+l)===!1||s<l&&this.left.forEachInvertedInner(r,Math.min(o,l),s,i)===!1)return!1},e.prototype.sliceInner=function(r,o){if(r==0&&o==this.length)return this;var s=this.left.length;return o<=s?this.left.slice(r,o):r>=s?this.right.slice(r-s,o-s):this.left.slice(r,s).append(this.right.slice(0,o-s))},e.prototype.leafAppend=function(r){var o=this.right.leafAppend(r);if(o)return new e(this.left,o)},e.prototype.leafPrepend=function(r){var o=this.left.leafPrepend(r);if(o)return new e(o,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e}(X);const gd=500;class Pe{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let o,s;t&&(o=this.remapping(r,this.items.length),s=o.maps.length);let i=e.tr,l,a,c=[],u=[];return this.items.forEach((f,d)=>{if(!f.step){o||(o=this.remapping(r,d+1),s=o.maps.length),s--,u.push(f);return}if(o){u.push(new Fe(f.map));let p=f.step.map(o.slice(s)),h;p&&i.maybeStep(p).doc&&(h=i.mapping.maps[i.mapping.maps.length-1],c.push(new Fe(h,void 0,void 0,c.length+u.length))),s--,h&&o.appendMap(h,s)}else i.maybeStep(f.step);if(f.selection)return l=o?f.selection.map(o.slice(s)):f.selection,a=new Pe(this.items.slice(0,r).append(u.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:i,selection:l}}addTransform(e,t,r,o){let s=[],i=this.eventCount,l=this.items,a=!o&&l.length?l.get(l.length-1):null;for(let u=0;u<e.steps.length;u++){let f=e.steps[u].invert(e.docs[u]),d=new Fe(e.mapping.maps[u],f,t),p;(p=a&&a.merge(d))&&(d=p,u?s.pop():l=l.slice(0,l.length-1)),s.push(d),t&&(i++,t=void 0),o||(a=d)}let c=i-r.depth;return c>bd&&(l=yd(l,c),i-=c),new Pe(l.append(s),i)}remapping(e,t){let r=new Dn;return this.items.forEach((o,s)=>{let i=o.mirrorOffset!=null&&s-o.mirrorOffset>=e?r.maps.length-o.mirrorOffset:void 0;r.appendMap(o.map,i)},e,t),r}addMaps(e){return this.eventCount==0?this:new Pe(this.items.append(e.map(t=>new Fe(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let r=[],o=Math.max(0,this.items.length-t),s=e.mapping,i=e.steps.length,l=this.eventCount;this.items.forEach(d=>{d.selection&&l--},o);let a=t;this.items.forEach(d=>{let p=s.getMirror(--a);if(p==null)return;i=Math.min(i,p);let h=s.maps[p];if(d.step){let b=e.steps[p].invert(e.docs[p]),g=d.selection&&d.selection.map(s.slice(a+1,p));g&&l++,r.push(new Fe(h,b,g))}else r.push(new Fe(h))},o);let c=[];for(let d=t;d<i;d++)c.push(new Fe(s.maps[d]));let u=this.items.slice(0,o).append(c).append(r),f=new Pe(u,l);return f.emptyItemCount()>gd&&(f=f.compress(this.items.length-r.length)),f}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),r=t.maps.length,o=[],s=0;return this.items.forEach((i,l)=>{if(l>=e)o.push(i),i.selection&&s++;else if(i.step){let a=i.step.map(t.slice(r)),c=a&&a.getMap();if(r--,c&&t.appendMap(c,r),a){let u=i.selection&&i.selection.map(t.slice(r));u&&s++;let f=new Fe(c.invert(),a,u),d,p=o.length-1;(d=o.length&&o[p].merge(f))?o[p]=d:o.push(f)}}else i.map&&r--},this.items.length,0),new Pe(X.from(o.reverse()),s)}}Pe.empty=new Pe(X.empty,0);function yd(n,e){let t;return n.forEach((r,o)=>{if(r.selection&&e--==0)return t=o,!1}),n.slice(t)}class Fe{constructor(e,t,r,o){this.map=e,this.step=t,this.selection=r,this.mirrorOffset=o}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new Fe(t.getMap().invert(),t,this.selection)}}}class at{constructor(e,t,r,o,s){this.done=e,this.undone=t,this.prevRanges=r,this.prevTime=o,this.prevComposition=s}}const bd=20;function xd(n,e,t,r){let o=t.getMeta(ct),s;if(o)return o.historyState;t.getMeta(Cd)&&(n=new at(n.done,n.undone,null,0,-1));let i=t.getMeta("appendedTransaction");if(t.steps.length==0)return n;if(i&&i.getMeta(ct))return i.getMeta(ct).redo?new at(n.done.addTransform(t,void 0,r,Er(e)),n.undone,ml(t.mapping.maps),n.prevTime,n.prevComposition):new at(n.done,n.undone.addTransform(t,void 0,r,Er(e)),null,n.prevTime,n.prevComposition);if(t.getMeta("addToHistory")!==!1&&!(i&&i.getMeta("addToHistory")===!1)){let l=t.getMeta("composition"),a=n.prevTime==0||!i&&n.prevComposition!=l&&(n.prevTime<(t.time||0)-r.newGroupDelay||!kd(t,n.prevRanges)),c=i?To(n.prevRanges,t.mapping):ml(t.mapping.maps);return new at(n.done.addTransform(t,a?e.selection.getBookmark():void 0,r,Er(e)),Pe.empty,c,t.time,l??n.prevComposition)}else return(s=t.getMeta("rebased"))?new at(n.done.rebased(t,s),n.undone.rebased(t,s),To(n.prevRanges,t.mapping),n.prevTime,n.prevComposition):new at(n.done.addMaps(t.mapping.maps),n.undone.addMaps(t.mapping.maps),To(n.prevRanges,t.mapping),n.prevTime,n.prevComposition)}function kd(n,e){if(!e)return!1;if(!n.docChanged)return!0;let t=!1;return n.mapping.maps[0].forEach((r,o)=>{for(let s=0;s<e.length;s+=2)r<=e[s+1]&&o>=e[s]&&(t=!0)}),t}function ml(n){let e=[];for(let t=n.length-1;t>=0&&e.length==0;t--)n[t].forEach((r,o,s,i)=>e.push(s,i));return e}function To(n,e){if(!n)return null;let t=[];for(let r=0;r<n.length;r+=2){let o=e.map(n[r],1),s=e.map(n[r+1],-1);o<=s&&t.push(o,s)}return t}function Sd(n,e,t){let r=Er(e),o=ct.get(e).spec.config,s=(t?n.undone:n.done).popEvent(e,r);if(!s)return null;let i=s.selection.resolve(s.transform.doc),l=(t?n.done:n.undone).addTransform(s.transform,e.selection.getBookmark(),o,r),a=new at(t?l:s.remaining,t?s.remaining:l,null,0,-1);return s.transform.setSelection(i).setMeta(ct,{redo:t,historyState:a})}let Ao=!1,gl=null;function Er(n){let e=n.plugins;if(gl!=e){Ao=!1,gl=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){Ao=!0;break}}return Ao}const ct=new lt("history"),Cd=new lt("closeHistory");function wd(n={}){return n={depth:n.depth||100,newGroupDelay:n.newGroupDelay||500},new Be({key:ct,state:{init(){return new at(Pe.empty,Pe.empty,null,0,-1)},apply(e,t,r){return xd(t,r,e,n)}},config:n,props:{handleDOMEvents:{beforeinput(e,t){let r=t.inputType,o=r=="historyUndo"?Po:r=="historyRedo"?Dr:null;return o?(t.preventDefault(),o(e.state,e.dispatch)):!1}}}})}function yl(n,e){return(t,r)=>{let o=ct.getState(t);if(!o||(n?o.undone:o.done).eventCount==0)return!1;if(r){let s=Sd(o,t,n);s&&r(e?s.scrollIntoView():s)}return!0}}const Po=yl(!1,!0),Dr=yl(!0,!0);function Md(n){let e=ct.getState(n);return e?e.done.eventCount:0}for(var ut={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},Or={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Nd=typeof navigator<"u"&&/Mac/.test(navigator.platform),Ed=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),te=0;te<10;te++)ut[48+te]=ut[96+te]=String(te);for(var te=1;te<=24;te++)ut[te+111]="F"+te;for(var te=65;te<=90;te++)ut[te]=String.fromCharCode(te+32),Or[te]=String.fromCharCode(te);for(var Io in ut)Or.hasOwnProperty(Io)||(Or[Io]=ut[Io]);function Dd(n){var e=Nd&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||Ed&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?Or:ut)[n.keyCode]||n.key||"Unidentified";return t=="Esc"&&(t="Escape"),t=="Del"&&(t="Delete"),t=="Left"&&(t="ArrowLeft"),t=="Up"&&(t="ArrowUp"),t=="Right"&&(t="ArrowRight"),t=="Down"&&(t="ArrowDown"),t}const Od=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):!1;function vd(n){let e=n.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");let r,o,s,i;for(let l=0;l<e.length-1;l++){let a=e[l];if(/^(cmd|meta|m)$/i.test(a))i=!0;else if(/^a(lt)?$/i.test(a))r=!0;else if(/^(c|ctrl|control)$/i.test(a))o=!0;else if(/^s(hift)?$/i.test(a))s=!0;else if(/^mod$/i.test(a))Od?i=!0:o=!0;else throw new Error("Unrecognized modifier name: "+a)}return r&&(t="Alt-"+t),o&&(t="Ctrl-"+t),i&&(t="Meta-"+t),s&&(t="Shift-"+t),t}function Td(n){let e=Object.create(null);for(let t in n)e[vd(t)]=n[t];return e}function Vo(n,e,t=!0){return e.altKey&&(n="Alt-"+n),e.ctrlKey&&(n="Ctrl-"+n),e.metaKey&&(n="Meta-"+n),t&&e.shiftKey&&(n="Shift-"+n),n}function Ro(n){return new Be({props:{handleKeyDown:zo(n)}})}function zo(n){let e=Td(n);return function(t,r){let o=Dd(r),s,i=e[Vo(o,r)];if(i&&i(t.state,t.dispatch,t))return!0;if(o.length==1&&o!=" "){if(r.shiftKey){let l=e[Vo(o,r,!1)];if(l&&l(t.state,t.dispatch,t))return!0}if((r.shiftKey||r.altKey||r.metaKey||o.charCodeAt(0)>127)&&(s=ut[r.keyCode])&&s!=o){let l=e[Vo(s,r)];if(l&&l(t.state,t.dispatch,t))return!0}}return!1}}const bl=(n,e)=>n.selection.empty?!1:(e&&e(n.tr.deleteSelection().scrollIntoView()),!0);function Ad(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("backward",n):t.parentOffset>0)?null:t}const Pd=(n,e,t)=>{let r=Ad(n,t);if(!r)return!1;let o=xl(r);if(!o){let i=r.blockRange(),l=i&&On(i);return l==null?!1:(e&&e(n.tr.lift(i,l).scrollIntoView()),!0)}let s=o.nodeBefore;if(wl(n,o,e,-1))return!0;if(r.parent.content.size==0&&(rn(s,"end")||O.isSelectable(s)))for(let i=r.depth;;i--){let l=wo(n.doc,r.before(i),r.after(i),E.empty);if(l&&l.slice.size<l.to-l.from){if(e){let a=n.tr.step(l);a.setSelection(rn(s,"end")?R.findFrom(a.doc.resolve(a.mapping.map(o.pos,-1)),-1):O.create(a.doc,o.pos-s.nodeSize)),e(a.scrollIntoView())}return!0}if(i==1||r.node(i-1).childCount>1)break}return s.isAtom&&o.depth==r.depth-1?(e&&e(n.tr.delete(o.pos-s.nodeSize,o.pos).scrollIntoView()),!0):!1};function rn(n,e,t=!1){for(let r=n;r;r=e=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(t&&r.childCount!=1)return!1}return!1}const Id=(n,e,t)=>{let{$head:r,empty:o}=n.selection,s=r;if(!o)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("backward",n):r.parentOffset>0)return!1;s=xl(r)}let i=s&&s.nodeBefore;return!i||!O.isSelectable(i)?!1:(e&&e(n.tr.setSelection(O.create(n.doc,s.pos-i.nodeSize)).scrollIntoView()),!0)};function xl(n){if(!n.parent.type.spec.isolating)for(let e=n.depth-1;e>=0;e--){if(n.index(e)>0)return n.doc.resolve(n.before(e+1));if(n.node(e).type.spec.isolating)break}return null}function Vd(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("forward",n):t.parentOffset<t.parent.content.size)?null:t}const Rd=(n,e,t)=>{let r=Vd(n,t);if(!r)return!1;let o=kl(r);if(!o)return!1;let s=o.nodeAfter;if(wl(n,o,e,1))return!0;if(r.parent.content.size==0&&(rn(s,"start")||O.isSelectable(s))){let i=wo(n.doc,r.before(),r.after(),E.empty);if(i&&i.slice.size<i.to-i.from){if(e){let l=n.tr.step(i);l.setSelection(rn(s,"start")?R.findFrom(l.doc.resolve(l.mapping.map(o.pos)),1):O.create(l.doc,l.mapping.map(o.pos))),e(l.scrollIntoView())}return!0}}return s.isAtom&&o.depth==r.depth-1?(e&&e(n.tr.delete(o.pos,o.pos+s.nodeSize).scrollIntoView()),!0):!1},zd=(n,e,t)=>{let{$head:r,empty:o}=n.selection,s=r;if(!o)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("forward",n):r.parentOffset<r.parent.content.size)return!1;s=kl(r)}let i=s&&s.nodeAfter;return!i||!O.isSelectable(i)?!1:(e&&e(n.tr.setSelection(O.create(n.doc,s.pos)).scrollIntoView()),!0)};function kl(n){if(!n.parent.type.spec.isolating)for(let e=n.depth-1;e>=0;e--){let t=n.node(e);if(n.index(e)+1<t.childCount)return n.doc.resolve(n.after(e+1));if(t.type.spec.isolating)break}return null}const Sl=(n,e)=>{let t=n.selection,r=t instanceof O,o;if(r){if(t.node.isTextblock||!Zt(n.doc,t.from))return!1;o=t.from}else if(o=Qi(n.doc,t.from,-1),o==null)return!1;if(e){let s=n.tr.join(o);r&&s.setSelection(O.create(s.doc,o-n.doc.resolve(o).nodeBefore.nodeSize)),e(s.scrollIntoView())}return!0},$d=(n,e)=>{let t=n.selection,r;if(t instanceof O){if(t.node.isTextblock||!Zt(n.doc,t.to))return!1;r=t.to}else if(r=Qi(n.doc,t.to,1),r==null)return!1;return e&&e(n.tr.join(r).scrollIntoView()),!0},$o=(n,e)=>{let{$from:t,$to:r}=n.selection,o=t.blockRange(r),s=o&&On(o);return s==null?!1:(e&&e(n.tr.lift(o,s).scrollIntoView()),!0)},jd=(n,e)=>{let{$head:t,$anchor:r}=n.selection;return!t.parent.type.spec.code||!t.sameParent(r)?!1:(e&&e(n.tr.insertText(`
|
|
37
|
-
`).scrollIntoView()),!0)};function jo(n){for(let e=0;e<n.edgeCount;e++){let{type:t}=n.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}const Cl=(n,e)=>{let{$head:t,$anchor:r}=n.selection;if(!t.parent.type.spec.code||!t.sameParent(r))return!1;let o=t.node(-1),s=t.indexAfter(-1),i=jo(o.contentMatchAt(s));if(!i||!o.canReplaceWith(s,s,i))return!1;if(e){let l=t.after(),a=n.tr.replaceWith(l,l,i.createAndFill());a.setSelection(R.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},Bd=(n,e)=>{let t=n.selection,{$from:r,$to:o}=t;if(t instanceof ge||r.parent.inlineContent||o.parent.inlineContent)return!1;let s=jo(o.parent.contentMatchAt(o.indexAfter()));if(!s||!s.isTextblock)return!1;if(e){let i=(!r.parentOffset&&o.index()<o.parent.childCount?r:o).pos,l=n.tr.insert(i,s.createAndFill());l.setSelection(V.create(l.doc,i+1)),e(l.scrollIntoView())}return!0},Fd=(n,e)=>{let{$cursor:t}=n.selection;if(!t||t.parent.content.size)return!1;if(t.depth>1&&t.after()!=t.end(-1)){let s=t.before();if(Qt(n.doc,s))return e&&e(n.tr.split(s).scrollIntoView()),!0}let r=t.blockRange(),o=r&&On(r);return o==null?!1:(e&&e(n.tr.lift(r,o).scrollIntoView()),!0)};function Ld(n){return(e,t)=>{let{$from:r,$to:o}=e.selection;if(e.selection instanceof O&&e.selection.node.isBlock)return!r.parentOffset||!Qt(e.doc,r.pos)?!1:(t&&t(e.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let s=[],i,l,a=!1,c=!1;for(let p=r.depth;;p--)if(r.node(p).isBlock){a=r.end(p)==r.pos+(r.depth-p),c=r.start(p)==r.pos-(r.depth-p),l=jo(r.node(p-1).contentMatchAt(r.indexAfter(p-1))),s.unshift(a&&l?{type:l}:null),i=p;break}else{if(p==1)return!1;s.unshift(null)}let u=e.tr;(e.selection instanceof V||e.selection instanceof ge)&&u.deleteSelection();let f=u.mapping.map(r.pos),d=Qt(u.doc,f,s.length,s);if(d||(s[0]=l?{type:l}:null,d=Qt(u.doc,f,s.length,s)),!d)return!1;if(u.split(f,s.length,s),!a&&c&&r.node(i).type!=l){let p=u.mapping.map(r.before(i)),h=u.doc.resolve(p);l&&r.node(i-1).canReplaceWith(h.index(),h.index()+1,l)&&u.setNodeMarkup(u.mapping.map(r.before(i)),l)}return t&&t(u.scrollIntoView()),!0}}const Wd=Ld(),Bo=(n,e)=>{let{$from:t,to:r}=n.selection,o,s=t.sharedDepth(r);return s==0?!1:(o=t.before(s),e&&e(n.tr.setSelection(O.create(n.doc,o))),!0)},_d=(n,e)=>(e&&e(n.tr.setSelection(new ge(n.doc))),!0);function qd(n,e,t){let r=e.nodeBefore,o=e.nodeAfter,s=e.index();return!r||!o||!r.type.compatibleContent(o.type)?!1:!r.content.size&&e.parent.canReplace(s-1,s)?(t&&t(n.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(s,s+1)||!(o.isTextblock||Zt(n.doc,e.pos))?!1:(t&&t(n.tr.join(e.pos).scrollIntoView()),!0)}function wl(n,e,t,r){let o=e.nodeBefore,s=e.nodeAfter,i,l,a=o.type.spec.isolating||s.type.spec.isolating;if(!a&&qd(n,e,t))return!0;let c=!a&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(i=(l=o.contentMatchAt(o.childCount)).findWrapping(s.type))&&l.matchType(i[0]||s.type).validEnd){if(t){let p=e.pos+s.nodeSize,h=C.empty;for(let x=i.length-1;x>=0;x--)h=C.from(i[x].create(null,h));h=C.from(o.copy(h));let b=n.tr.step(new ee(e.pos-1,p,e.pos,p,new E(h,1,0),i.length,!0)),g=b.doc.resolve(p+2*i.length);g.nodeAfter&&g.nodeAfter.type==o.type&&Zt(b.doc,g.pos)&&b.join(g.pos),t(b.scrollIntoView())}return!0}let u=s.type.spec.isolating||r>0&&a?null:R.findFrom(e,1),f=u&&u.$from.blockRange(u.$to),d=f&&On(f);if(d!=null&&d>=e.depth)return t&&t(n.tr.lift(f,d).scrollIntoView()),!0;if(c&&rn(s,"start",!0)&&rn(o,"end")){let p=o,h=[];for(;h.push(p),!p.isTextblock;)p=p.lastChild;let b=s,g=1;for(;!b.isTextblock;b=b.firstChild)g++;if(p.canReplace(p.childCount,p.childCount,b.content)){if(t){let x=C.empty;for(let w=h.length-1;w>=0;w--)x=C.from(h[w].copy(x));let S=n.tr.step(new ee(e.pos-h.length,e.pos+s.nodeSize,e.pos+g,e.pos+s.nodeSize-g,new E(x,h.length,0),0,!0));t(S.scrollIntoView())}return!0}}return!1}function Ml(n){return function(e,t){let r=e.selection,o=n<0?r.$from:r.$to,s=o.depth;for(;o.node(s).isInline;){if(!s)return!1;s--}return o.node(s).isTextblock?(t&&t(e.tr.setSelection(V.create(e.doc,n<0?o.start(s):o.end(s)))),!0):!1}}const Hd=Ml(-1),Kd=Ml(1);function Nl(n,e=null){return function(t,r){let{$from:o,$to:s}=t.selection,i=o.blockRange(s),l=i&&So(i,n,e);return l?(r&&r(t.tr.wrap(i,l).scrollIntoView()),!0):!1}}function on(n,e=null){return function(t,r){let o=!1;for(let s=0;s<t.selection.ranges.length&&!o;s++){let{$from:{pos:i},$to:{pos:l}}=t.selection.ranges[s];t.doc.nodesBetween(i,l,(a,c)=>{if(o)return!1;if(!(!a.isTextblock||a.hasMarkup(n,e)))if(a.type==n)o=!0;else{let u=t.doc.resolve(c),f=u.index();o=u.parent.canReplaceWith(f,f+1,n)}})}if(!o)return!1;if(r){let s=t.tr;for(let i=0;i<t.selection.ranges.length;i++){let{$from:{pos:l},$to:{pos:a}}=t.selection.ranges[i];s.setBlockType(l,a,n,e)}r(s.scrollIntoView())}return!0}}function Jd(n,e,t,r){for(let o=0;o<e.length;o++){let{$from:s,$to:i}=e[o],l=s.depth==0?n.inlineContent&&n.type.allowsMarkType(t):!1;if(n.nodesBetween(s.pos,i.pos,(a,c)=>{if(l)return!1;l=a.inlineContent&&a.type.allowsMarkType(t)}),l)return!0}return!1}function ke(n,e=null,t){return function(r,o){let{empty:s,$cursor:i,ranges:l}=r.selection;if(s&&!i||!Jd(r.doc,l,n))return!1;if(o)if(i)n.isInSet(r.storedMarks||i.marks())?o(r.tr.removeStoredMark(n)):o(r.tr.addStoredMark(n.create(e)));else{let a,c=r.tr;a=!l.some(u=>r.doc.rangeHasMark(u.$from.pos,u.$to.pos,n));for(let u=0;u<l.length;u++){let{$from:f,$to:d}=l[u];if(!a)c.removeMark(f.pos,d.pos,n);else{let p=f.pos,h=d.pos,b=f.nodeAfter,g=d.nodeBefore,x=b&&b.isText?/^\s*/.exec(b.text)[0].length:0,S=g&&g.isText?/\s*$/.exec(g.text)[0].length:0;p+x<h&&(p+=x,h-=S),c.addMark(p,h,n.create(e))}}o(c.scrollIntoView())}return!0}}function vr(...n){return function(e,t,r){for(let o=0;o<n.length;o++)if(n[o](e,t,r))return!0;return!1}}let Fo=vr(bl,Pd,Id),El=vr(bl,Rd,zd);const Xe={Enter:vr(jd,Bd,Fd,Wd),"Mod-Enter":Cl,Backspace:Fo,"Mod-Backspace":Fo,"Shift-Backspace":Fo,Delete:El,"Mod-Delete":El,"Mod-a":_d},Dl={"Ctrl-h":Xe.Backspace,"Alt-Backspace":Xe["Mod-Backspace"],"Ctrl-d":Xe.Delete,"Ctrl-Alt-Backspace":Xe["Mod-Delete"],"Alt-Delete":Xe["Mod-Delete"],"Alt-d":Xe["Mod-Delete"],"Ctrl-a":Hd,"Ctrl-e":Kd};for(let n in Xe)Dl[n]=Xe[n];const Yd=(typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform?os.platform()=="darwin":!1)?Dl:Xe;function Gd(n={}){return new Be({view(e){return new Xd(e,n)}})}class Xd{constructor(e,t){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=t.width)!==null&&r!==void 0?r:1,this.color=t.color===!1?void 0:t.color||"black",this.class=t.class,this.handlers=["dragover","dragend","drop","dragleave"].map(o=>{let s=i=>{this[o](i)};return e.dom.addEventListener(o,s),{name:o,handler:s}})}destroy(){this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){this.cursorPos!=null&&t.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),t=!e.parent.inlineContent,r,o=this.editorView.dom,s=o.getBoundingClientRect(),i=s.width/o.offsetWidth,l=s.height/o.offsetHeight;if(t){let f=e.nodeBefore,d=e.nodeAfter;if(f||d){let p=this.editorView.nodeDOM(this.cursorPos-(f?f.nodeSize:0));if(p){let h=p.getBoundingClientRect(),b=f?h.bottom:h.top;f&&d&&(b=(b+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let g=this.width/2*l;r={left:h.left,right:h.right,top:b-g,bottom:b+g}}}}if(!r){let f=this.editorView.coordsAtPos(this.cursorPos),d=this.width/2*i;r={left:f.left-d,right:f.left+d,top:f.top,bottom:f.bottom}}let a=this.editorView.dom.offsetParent;this.element||(this.element=a.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",t),this.element.classList.toggle("prosemirror-dropcursor-inline",!t);let c,u;if(!a||a==document.body&&getComputedStyle(a).position=="static")c=-pageXOffset,u=-pageYOffset;else{let f=a.getBoundingClientRect(),d=f.width/a.offsetWidth,p=f.height/a.offsetHeight;c=f.left-a.scrollLeft*d,u=f.top-a.scrollTop*p}this.element.style.left=(r.left-c)/i+"px",this.element.style.top=(r.top-u)/l+"px",this.element.style.width=(r.right-r.left)/i+"px",this.element.style.height=(r.bottom-r.top)/l+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),o=r&&r.type.spec.disableDropCursor,s=typeof o=="function"?o(this.editorView,t,e):o;if(t&&!s){let i=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=Co(this.editorView.state.doc,i,this.editorView.dragging.slice);l!=null&&(i=l)}this.setCursor(i),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}const ne=function(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e},In=function(n){let e=n.assignedSlot||n.parentNode;return e&&e.nodeType==11?e.host:e};let Lo=null;const Ue=function(n,e,t){let r=Lo||(Lo=document.createRange());return r.setEnd(n,t??n.nodeValue.length),r.setStart(n,e||0),r},Ud=function(){Lo=null},Vt=function(n,e,t,r){return t&&(Ol(n,e,t,r,-1)||Ol(n,e,t,r,1))},Qd=/^(img|br|input|textarea|hr)$/i;function Ol(n,e,t,r,o){for(;;){if(n==t&&e==r)return!0;if(e==(o<0?0:Me(n))){let s=n.parentNode;if(!s||s.nodeType!=1||Vn(n)||Qd.test(n.nodeName)||n.contentEditable=="false")return!1;e=ne(n)+(o<0?0:1),n=s}else if(n.nodeType==1){if(n=n.childNodes[e+(o<0?-1:0)],n.contentEditable=="false")return!1;e=o<0?Me(n):0}else return!1}}function Me(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Zd(n,e){for(;;){if(n.nodeType==3&&e)return n;if(n.nodeType==1&&e>0){if(n.contentEditable=="false")return null;n=n.childNodes[e-1],e=Me(n)}else if(n.parentNode&&!Vn(n))e=ne(n),n=n.parentNode;else return null}}function eh(n,e){for(;;){if(n.nodeType==3&&e<n.nodeValue.length)return n;if(n.nodeType==1&&e<n.childNodes.length){if(n.contentEditable=="false")return null;n=n.childNodes[e],e=0}else if(n.parentNode&&!Vn(n))e=ne(n)+1,n=n.parentNode;else return null}}function th(n,e,t){for(let r=e==0,o=e==Me(n);r||o;){if(n==t)return!0;let s=ne(n);if(n=n.parentNode,!n)return!1;r=r&&s==0,o=o&&s==Me(n)}}function Vn(n){let e;for(let t=n;t&&!(e=t.pmViewDesc);t=t.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==n||e.contentDOM==n)}const Tr=function(n){return n.focusNode&&Vt(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)};function Rt(n,e){let t=document.createEvent("Event");return t.initEvent("keydown",!0,!0),t.keyCode=n,t.key=t.code=e,t}function nh(n){let e=n.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function rh(n,e,t){if(n.caretPositionFromPoint)try{let r=n.caretPositionFromPoint(e,t);if(r)return{node:r.offsetNode,offset:Math.min(Me(r.offsetNode),r.offset)}}catch{}if(n.caretRangeFromPoint){let r=n.caretRangeFromPoint(e,t);if(r)return{node:r.startContainer,offset:Math.min(Me(r.startContainer),r.startOffset)}}}const Le=typeof navigator<"u"?navigator:null,vl=typeof document<"u"?document:null,ft=Le&&Le.userAgent||"",Wo=/Edge\/(\d+)/.exec(ft),Tl=/MSIE \d/.exec(ft),_o=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(ft),ye=!!(Tl||_o||Wo),dt=Tl?document.documentMode:_o?+_o[1]:Wo?+Wo[1]:0,Ie=!ye&&/gecko\/(\d+)/i.test(ft);Ie&&+(/Firefox\/(\d+)/.exec(ft)||[0,0])[1];const qo=!ye&&/Chrome\/(\d+)/.exec(ft),ie=!!qo,Al=qo?+qo[1]:0,ue=!ye&&!!Le&&/Apple Computer/.test(Le.vendor),sn=ue&&(/Mobile\/\w+/.test(ft)||!!Le&&Le.maxTouchPoints>2),Ne=sn||(Le?/Mac/.test(Le.platform):!1),oh=Le?/Win/.test(Le.platform):!1,Qe=/Android \d/.test(ft),Rn=!!vl&&"webkitFontSmoothing"in vl.documentElement.style,sh=Rn?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function ih(n){let e=n.defaultView&&n.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:n.documentElement.clientWidth,top:0,bottom:n.documentElement.clientHeight}}function Ze(n,e){return typeof n=="number"?n:n[e]}function lh(n){let e=n.getBoundingClientRect(),t=e.width/n.offsetWidth||1,r=e.height/n.offsetHeight||1;return{left:e.left,right:e.left+n.clientWidth*t,top:e.top,bottom:e.top+n.clientHeight*r}}function Pl(n,e,t){let r=n.someProp("scrollThreshold")||0,o=n.someProp("scrollMargin")||5,s=n.dom.ownerDocument;for(let i=t||n.dom;i;i=In(i)){if(i.nodeType!=1)continue;let l=i,a=l==s.body,c=a?ih(s):lh(l),u=0,f=0;if(e.top<c.top+Ze(r,"top")?f=-(c.top-e.top+Ze(o,"top")):e.bottom>c.bottom-Ze(r,"bottom")&&(f=e.bottom-e.top>c.bottom-c.top?e.top+Ze(o,"top")-c.top:e.bottom-c.bottom+Ze(o,"bottom")),e.left<c.left+Ze(r,"left")?u=-(c.left-e.left+Ze(o,"left")):e.right>c.right-Ze(r,"right")&&(u=e.right-c.right+Ze(o,"right")),u||f)if(a)s.defaultView.scrollBy(u,f);else{let d=l.scrollLeft,p=l.scrollTop;f&&(l.scrollTop+=f),u&&(l.scrollLeft+=u);let h=l.scrollLeft-d,b=l.scrollTop-p;e={left:e.left-h,top:e.top-b,right:e.right-h,bottom:e.bottom-b}}if(a||/^(fixed|sticky)$/.test(getComputedStyle(i).position))break}}function ah(n){let e=n.dom.getBoundingClientRect(),t=Math.max(0,e.top),r,o;for(let s=(e.left+e.right)/2,i=t+1;i<Math.min(innerHeight,e.bottom);i+=5){let l=n.root.elementFromPoint(s,i);if(!l||l==n.dom||!n.dom.contains(l))continue;let a=l.getBoundingClientRect();if(a.top>=t-20){r=l,o=a.top;break}}return{refDOM:r,refTop:o,stack:Il(n.dom)}}function Il(n){let e=[],t=n.ownerDocument;for(let r=n;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),n!=t);r=In(r));return e}function ch({refDOM:n,refTop:e,stack:t}){let r=n?n.getBoundingClientRect().top:0;Vl(t,r==0?0:r-e)}function Vl(n,e){for(let t=0;t<n.length;t++){let{dom:r,top:o,left:s}=n[t];r.scrollTop!=o+e&&(r.scrollTop=o+e),r.scrollLeft!=s&&(r.scrollLeft=s)}}let ln=null;function uh(n){if(n.setActive)return n.setActive();if(ln)return n.focus(ln);let e=Il(n);n.focus(ln==null?{get preventScroll(){return ln={preventScroll:!0},!0}}:void 0),ln||(ln=!1,Vl(e,0))}function Rl(n,e){let t,r=2e8,o,s=0,i=e.top,l=e.top,a,c;for(let u=n.firstChild,f=0;u;u=u.nextSibling,f++){let d;if(u.nodeType==1)d=u.getClientRects();else if(u.nodeType==3)d=Ue(u).getClientRects();else continue;for(let p=0;p<d.length;p++){let h=d[p];if(h.top<=i&&h.bottom>=l){i=Math.max(h.bottom,i),l=Math.min(h.top,l);let b=h.left>e.left?h.left-e.left:h.right<e.left?e.left-h.right:0;if(b<r){t=u,r=b,o=b&&t.nodeType==3?{left:h.right<e.left?h.right:h.left,top:e.top}:e,u.nodeType==1&&b&&(s=f+(e.left>=(h.left+h.right)/2?1:0));continue}}else h.top>e.top&&!a&&h.left<=e.left&&h.right>=e.left&&(a=u,c={left:Math.max(h.left,Math.min(h.right,e.left)),top:h.top});!t&&(e.left>=h.right&&e.top>=h.top||e.left>=h.left&&e.top>=h.bottom)&&(s=f+1)}}return!t&&a&&(t=a,o=c,r=0),t&&t.nodeType==3?fh(t,o):!t||r&&t.nodeType==1?{node:n,offset:s}:Rl(t,o)}function fh(n,e){let t=n.nodeValue.length,r=document.createRange();for(let o=0;o<t;o++){r.setEnd(n,o+1),r.setStart(n,o);let s=ht(r,1);if(s.top!=s.bottom&&Ho(e,s))return{node:n,offset:o+(e.left>=(s.left+s.right)/2?1:0)}}return{node:n,offset:0}}function Ho(n,e){return n.left>=e.left-1&&n.left<=e.right+1&&n.top>=e.top-1&&n.top<=e.bottom+1}function dh(n,e){let t=n.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left<n.getBoundingClientRect().left?t:n}function hh(n,e,t){let{node:r,offset:o}=Rl(e,t),s=-1;if(r.nodeType==1&&!r.firstChild){let i=r.getBoundingClientRect();s=i.left!=i.right&&t.left>(i.left+i.right)/2?1:-1}return n.docView.posFromDOM(r,o,s)}function ph(n,e,t,r){let o=-1;for(let s=e,i=!1;s!=n.dom;){let l=n.docView.nearestDesc(s,!0),a;if(!l)return null;if(l.dom.nodeType==1&&(l.node.isBlock&&l.parent||!l.contentDOM)&&((a=l.dom.getBoundingClientRect()).width||a.height)&&(l.node.isBlock&&l.parent&&(!i&&a.left>r.left||a.top>r.top?o=l.posBefore:(!i&&a.right<r.left||a.bottom<r.top)&&(o=l.posAfter),i=!0),!l.contentDOM&&o<0&&!l.node.isText))return(l.node.isBlock?r.top<(a.top+a.bottom)/2:r.left<(a.left+a.right)/2)?l.posBefore:l.posAfter;s=l.dom.parentNode}return o>-1?o:n.docView.posFromDOM(e,t,-1)}function zl(n,e,t){let r=n.childNodes.length;if(r&&t.top<t.bottom)for(let o=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-t.top)/(t.bottom-t.top))-2)),s=o;;){let i=n.childNodes[s];if(i.nodeType==1){let l=i.getClientRects();for(let a=0;a<l.length;a++){let c=l[a];if(Ho(e,c))return zl(i,e,c)}}if((s=(s+1)%r)==o)break}return n}function mh(n,e){let t=n.dom.ownerDocument,r,o=0,s=rh(t,e.left,e.top);s&&({node:r,offset:o}=s);let i=(n.root.elementFromPoint?n.root:t).elementFromPoint(e.left,e.top),l;if(!i||!n.dom.contains(i.nodeType!=1?i.parentNode:i)){let c=n.dom.getBoundingClientRect();if(!Ho(e,c)||(i=zl(n.dom,e,c),!i))return null}if(ue)for(let c=i;r&&c;c=In(c))c.draggable&&(r=void 0);if(i=dh(i,e),r){if(Ie&&r.nodeType==1&&(o=Math.min(o,r.childNodes.length),o<r.childNodes.length)){let u=r.childNodes[o],f;u.nodeName=="IMG"&&(f=u.getBoundingClientRect()).right<=e.left&&f.bottom>e.top&&o++}let c;Rn&&o&&r.nodeType==1&&(c=r.childNodes[o-1]).nodeType==1&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=e.top&&o--,r==n.dom&&o==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?l=n.state.doc.content.size:(o==0||r.nodeType!=1||r.childNodes[o-1].nodeName!="BR")&&(l=ph(n,r,o,e))}l==null&&(l=hh(n,i,e));let a=n.docView.nearestDesc(i,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function $l(n){return n.top<n.bottom||n.left<n.right}function ht(n,e){let t=n.getClientRects();if(t.length){let r=t[e<0?0:t.length-1];if($l(r))return r}return Array.prototype.find.call(t,$l)||n.getBoundingClientRect()}const gh=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function jl(n,e,t){let{node:r,offset:o,atom:s}=n.docView.domFromPos(e,t<0?-1:1),i=Rn||Ie;if(r.nodeType==3)if(i&&(gh.test(r.nodeValue)||(t<0?!o:o==r.nodeValue.length))){let a=ht(Ue(r,o,o),t);if(Ie&&o&&/\s/.test(r.nodeValue[o-1])&&o<r.nodeValue.length){let c=ht(Ue(r,o-1,o-1),-1);if(c.top==a.top){let u=ht(Ue(r,o,o+1),-1);if(u.top!=a.top)return zn(u,u.left<c.left)}}return a}else{let a=o,c=o,u=t<0?1:-1;return t<0&&!o?(c++,u=-1):t>=0&&o==r.nodeValue.length?(a--,u=1):t<0?a--:c++,zn(ht(Ue(r,a,c),u),u<0)}if(!n.state.doc.resolve(e-(s||0)).parent.inlineContent){if(s==null&&o&&(t<0||o==Me(r))){let a=r.childNodes[o-1];if(a.nodeType==1)return Ko(a.getBoundingClientRect(),!1)}if(s==null&&o<Me(r)){let a=r.childNodes[o];if(a.nodeType==1)return Ko(a.getBoundingClientRect(),!0)}return Ko(r.getBoundingClientRect(),t>=0)}if(s==null&&o&&(t<0||o==Me(r))){let a=r.childNodes[o-1],c=a.nodeType==3?Ue(a,Me(a)-(i?0:1)):a.nodeType==1&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(c)return zn(ht(c,1),!1)}if(s==null&&o<Me(r)){let a=r.childNodes[o];for(;a.pmViewDesc&&a.pmViewDesc.ignoreForCoords;)a=a.nextSibling;let c=a?a.nodeType==3?Ue(a,0,i?0:1):a.nodeType==1?a:null:null;if(c)return zn(ht(c,-1),!0)}return zn(ht(r.nodeType==3?Ue(r):r,-t),t>=0)}function zn(n,e){if(n.width==0)return n;let t=e?n.left:n.right;return{top:n.top,bottom:n.bottom,left:t,right:t}}function Ko(n,e){if(n.height==0)return n;let t=e?n.top:n.bottom;return{top:t,bottom:t,left:n.left,right:n.right}}function Bl(n,e,t){let r=n.state,o=n.root.activeElement;r!=e&&n.updateState(e),o!=n.dom&&n.focus();try{return t()}finally{r!=e&&n.updateState(r),o!=n.dom&&o&&o.focus()}}function yh(n,e,t){let r=e.selection,o=t=="up"?r.$from:r.$to;return Bl(n,e,()=>{let{node:s}=n.docView.domFromPos(o.pos,t=="up"?-1:1);for(;;){let l=n.docView.nearestDesc(s,!0);if(!l)break;if(l.node.isBlock){s=l.contentDOM||l.dom;break}s=l.dom.parentNode}let i=jl(n,o.pos,1);for(let l=s.firstChild;l;l=l.nextSibling){let a;if(l.nodeType==1)a=l.getClientRects();else if(l.nodeType==3)a=Ue(l,0,l.nodeValue.length).getClientRects();else continue;for(let c=0;c<a.length;c++){let u=a[c];if(u.bottom>u.top+1&&(t=="up"?i.top-u.top>(u.bottom-i.top)*2:u.bottom-i.bottom>(i.bottom-u.top)*2))return!1}}return!0})}const bh=/[\u0590-\u08ac]/;function xh(n,e,t){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let o=r.parentOffset,s=!o,i=o==r.parent.content.size,l=n.domSelection();return l?!bh.test(r.parent.textContent)||!l.modify?t=="left"||t=="backward"?s:i:Bl(n,e,()=>{let{focusNode:a,focusOffset:c,anchorNode:u,anchorOffset:f}=n.domSelectionRange(),d=l.caretBidiLevel;l.modify("move",t,"character");let p=r.depth?n.docView.domAfterPos(r.before()):n.dom,{focusNode:h,focusOffset:b}=n.domSelectionRange(),g=h&&!p.contains(h.nodeType==1?h:h.parentNode)||a==h&&c==b;try{l.collapse(u,f),a&&(a!=u||c!=f)&&l.extend&&l.extend(a,c)}catch{}return d!=null&&(l.caretBidiLevel=d),g}):r.pos==r.start()||r.pos==r.end()}let Fl=null,Ll=null,Wl=!1;function kh(n,e,t){return Fl==e&&Ll==t?Wl:(Fl=e,Ll=t,Wl=t=="up"||t=="down"?yh(n,e,t):xh(n,e,t))}const Ee=0,_l=1,zt=2,We=3;let $n=class{constructor(e,t,r,o){this.parent=e,this.children=t,this.dom=r,this.contentDOM=o,this.dirty=Ee,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,r){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;t<this.children.length;t++)e+=this.children[t].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let t=0,r=this.posAtStart;;t++){let o=this.children[t];if(o==e)return r;r+=o.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,t,r){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(r<0){let s,i;if(e==this.contentDOM)s=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;s=e.previousSibling}for(;s&&!((i=s.pmViewDesc)&&i.parent==this);)s=s.previousSibling;return s?this.posBeforeChild(i)+i.size:this.posAtStart}else{let s,i;if(e==this.contentDOM)s=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;s=e.nextSibling}for(;s&&!((i=s.pmViewDesc)&&i.parent==this);)s=s.nextSibling;return s?this.posBeforeChild(i):this.posAtEnd}let o;if(e==this.dom&&this.contentDOM)o=t>ne(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))o=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(t==0)for(let s=e;;s=s.parentNode){if(s==this.dom){o=!1;break}if(s.previousSibling)break}if(o==null&&t==e.childNodes.length)for(let s=e;;s=s.parentNode){if(s==this.dom){o=!0;break}if(s.nextSibling)break}}return o??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let r=!0,o=e;o;o=o.parentNode){let s=this.getDesc(o),i;if(s&&(!t||s.node))if(r&&(i=s.nodeDOM)&&!(i.nodeType==1?i.contains(e.nodeType==1?e:e.parentNode):i==e))r=!1;else return s}}getDesc(e){let t=e.pmViewDesc;for(let r=t;r;r=r.parent)if(r==this)return t}posFromDOM(e,t,r){for(let o=e;o;o=o.parentNode){let s=this.getDesc(o);if(s)return s.localPosFromDOM(e,t,r)}return-1}descAt(e){for(let t=0,r=0;t<this.children.length;t++){let o=this.children[t],s=r+o.size;if(r==e&&s!=r){for(;!o.border&&o.children.length;)o=o.children[0];return o}if(e<s)return o.descAt(e-r-o.border);r=s}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let r=0,o=0;for(let s=0;r<this.children.length;r++){let i=this.children[r],l=s+i.size;if(l>e||i instanceof Jl){o=e-s;break}s=l}if(o)return this.children[r].domFromPos(o-this.children[r].border,t);for(let s;r&&!(s=this.children[r-1]).size&&s instanceof ql&&s.side>=0;r--);if(t<=0){let s,i=!0;for(;s=r?this.children[r-1]:null,!(!s||s.dom.parentNode==this.contentDOM);r--,i=!1);return s&&t&&i&&!s.border&&!s.domAtom?s.domFromPos(s.size,t):{node:this.contentDOM,offset:s?ne(s.dom)+1:0}}else{let s,i=!0;for(;s=r<this.children.length?this.children[r]:null,!(!s||s.dom.parentNode==this.contentDOM);r++,i=!1);return s&&i&&!s.border&&!s.domAtom?s.domFromPos(0,t):{node:this.contentDOM,offset:s?ne(s.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,r=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let o=-1,s=-1;for(let i=r,l=0;;l++){let a=this.children[l],c=i+a.size;if(o==-1&&e<=c){let u=i+a.border;if(e>=u&&t<=c-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,t,u);e=i;for(let f=l;f>0;f--){let d=this.children[f-1];if(d.size&&d.dom.parentNode==this.contentDOM&&!d.emptyChildAt(1)){o=ne(d.dom)+1;break}e-=d.size}o==-1&&(o=0)}if(o>-1&&(c>t||l==this.children.length-1)){t=c;for(let u=l+1;u<this.children.length;u++){let f=this.children[u];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(-1)){s=ne(f.dom);break}t+=f.size}s==-1&&(s=this.contentDOM.childNodes.length);break}i=c}return{node:this.contentDOM,from:e,to:t,fromOffset:o,toOffset:s}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let t=this.children[e<0?0:this.children.length-1];return t.size==0||t.emptyChildAt(e)}domAfterPos(e){let{node:t,offset:r}=this.domFromPos(e,0);if(t.nodeType!=1||r==t.childNodes.length)throw new RangeError("No node after pos "+e);return t.childNodes[r]}setSelection(e,t,r,o=!1){let s=Math.min(e,t),i=Math.max(e,t);for(let p=0,h=0;p<this.children.length;p++){let b=this.children[p],g=h+b.size;if(s>h&&i<g)return b.setSelection(e-h-b.border,t-h-b.border,r,o);h=g}let l=this.domFromPos(e,e?-1:1),a=t==e?l:this.domFromPos(t,t?-1:1),c=r.root.getSelection(),u=r.domSelectionRange(),f=!1;if((Ie||ue)&&e==t){let{node:p,offset:h}=l;if(p.nodeType==3){if(f=!!(h&&p.nodeValue[h-1]==`
|
|
38
|
-
`),f&&h==p.nodeValue.length)for(let b=p,g;b;b=b.parentNode){if(g=b.nextSibling){g.nodeName=="BR"&&(l=a={node:g.parentNode,offset:ne(g)+1});break}let x=b.pmViewDesc;if(x&&x.node&&x.node.isBlock)break}}else{let b=p.childNodes[h-1];f=b&&(b.nodeName=="BR"||b.contentEditable=="false")}}if(Ie&&u.focusNode&&u.focusNode!=a.node&&u.focusNode.nodeType==1){let p=u.focusNode.childNodes[u.focusOffset];p&&p.contentEditable=="false"&&(o=!0)}if(!(o||f&&ue)&&Vt(l.node,l.offset,u.anchorNode,u.anchorOffset)&&Vt(a.node,a.offset,u.focusNode,u.focusOffset))return;let d=!1;if((c.extend||e==t)&&!f){c.collapse(l.node,l.offset);try{e!=t&&c.extend(a.node,a.offset),d=!0}catch{}}if(!d){if(e>t){let h=l;l=a,a=h}let p=document.createRange();p.setEnd(a.node,a.offset),p.setStart(l.node,l.offset),c.removeAllRanges(),c.addRange(p)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let r=0,o=0;o<this.children.length;o++){let s=this.children[o],i=r+s.size;if(r==i?e<=i&&t>=r:e<i&&t>r){let l=r+s.border,a=i-s.border;if(e>=l&&t<=a){this.dirty=e==r||t==i?zt:_l,e==l&&t==a&&(s.contentLost||s.dom.parentNode!=this.contentDOM)?s.dirty=We:s.markDirty(e-l,t-l);return}else s.dirty=s.dom==s.contentDOM&&s.dom.parentNode==this.contentDOM&&!s.children.length?zt:We}r=i}this.dirty=zt}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let r=e==1?zt:_l;t.dirty<r&&(t.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}isText(e){return!1}},ql=class extends $n{constructor(e,t,r,o){let s,i=t.type.toDOM;if(typeof i=="function"&&(i=i(r,()=>{if(!s)return o;if(s.parent)return s.parent.posBeforeChild(s)})),!t.type.spec.raw){if(i.nodeType!=1){let l=document.createElement("span");l.appendChild(i),i=l}i.contentEditable="false",i.classList.add("ProseMirror-widget")}super(e,[],i,null),this.widget=t,this.widget=t,s=this}matchesWidget(e){return this.dirty==Ee&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return t?t(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get side(){return this.widget.type.side}},Sh=class extends $n{constructor(e,t,r,o){super(e,[],t,null),this.textDOM=r,this.text=o}get size(){return this.text.length}localPosFromDOM(e,t){return e!=this.textDOM?this.posAtStart+(t?this.size:0):this.posAtStart+t}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}},Ar=class ui extends $n{constructor(e,t,r,o,s){super(e,[],r,o),this.mark=t,this.spec=s}static create(e,t,r,o){let s=o.nodeViews[t.type.name],i=s&&s(t,o,r);return(!i||!i.dom)&&(i=$e.renderSpec(document,t.type.spec.toDOM(t,r),null,t.attrs)),new ui(e,t,i.dom,i.contentDOM||i.dom,i)}parseRule(){return this.dirty&We||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=We&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=Ee){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=Ee}}slice(e,t,r){let o=ui.create(this.parent,this.mark,!0,r),s=this.children,i=this.size;t<i&&(s=Yo(s,t,i,r)),e>0&&(s=Yo(s,0,e,r));for(let l=0;l<s.length;l++)s[l].parent=o;return o.children=s,o}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}},an=class hf extends $n{constructor(e,t,r,o,s,i,l,a,c){super(e,[],s,i),this.node=t,this.outerDeco=r,this.innerDeco=o,this.nodeDOM=l}static create(e,t,r,o,s,i){let l=s.nodeViews[t.type.name],a,c=l&&l(t,s,()=>{if(!a)return i;if(a.parent)return a.parent.posBeforeChild(a)},r,o),u=c&&c.dom,f=c&&c.contentDOM;if(t.isText){if(!u)u=document.createTextNode(t.text);else if(u.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else u||({dom:u,contentDOM:f}=$e.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs));!f&&!t.isText&&u.nodeName!="BR"&&(u.hasAttribute("contenteditable")||(u.contentEditable="false"),t.type.spec.draggable&&(u.draggable=!0));let d=u;return u=Xl(u,r,t),c?a=new Ch(e,t,r,o,u,f||null,d,c,s,i+1):t.isText?new Kl(e,t,r,o,u,d,s):new hf(e,t,r,o,u,f||null,d,s,i+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(e.preserveWhitespace="full"),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let t=this.children.length-1;t>=0;t--){let r=this.children[t];if(this.dom.contains(r.dom.parentNode)){e.contentElement=r.dom.parentNode;break}}e.contentElement||(e.getContent=()=>C.empty)}return e}matchesNode(e,t,r){return this.dirty==Ee&&e.eq(this.node)&&Pr(t,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let r=this.node.inlineContent,o=t,s=e.composing?this.localCompositionInfo(e,t):null,i=s&&s.pos>-1?s:null,l=s&&s.pos<0,a=new Mh(this,i&&i.node,e);Dh(this.node,this.innerDeco,(c,u,f)=>{c.spec.marks?a.syncToMarks(c.spec.marks,r,e):c.type.side>=0&&!f&&a.syncToMarks(u==this.node.childCount?F.none:this.node.child(u).marks,r,e),a.placeWidget(c,e,o)},(c,u,f,d)=>{a.syncToMarks(c.marks,r,e);let p;a.findNodeMatch(c,u,f,d)||l&&e.state.selection.from>o&&e.state.selection.to<o+c.nodeSize&&(p=a.findIndexWithChild(s.node))>-1&&a.updateNodeAt(c,u,f,p,e)||a.updateNextNode(c,u,f,e,d,o)||a.addNode(c,u,f,e,o),o+=c.nodeSize}),a.syncToMarks([],r,e),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==zt)&&(i&&this.protectLocalComposition(e,i),Yl(this.contentDOM,this.children,e),sn&&Oh(this.dom))}localCompositionInfo(e,t){let{from:r,to:o}=e.state.selection;if(!(e.state.selection instanceof V)||r<t||o>t+this.node.content.size)return null;let s=e.input.compositionNode;if(!s||!this.dom.contains(s.parentNode))return null;if(this.node.inlineContent){let i=s.nodeValue,l=vh(this.node.content,i,r-t,o-t);return l<0?null:{node:s,pos:l,text:i}}else return{node:s,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:r,text:o}){if(this.getDesc(t))return;let s=t;for(;s.parentNode!=this.contentDOM;s=s.parentNode){for(;s.previousSibling;)s.parentNode.removeChild(s.previousSibling);for(;s.nextSibling;)s.parentNode.removeChild(s.nextSibling);s.pmViewDesc&&(s.pmViewDesc=void 0)}let i=new Sh(this,s,t,o);e.input.compositionNodes.push(i),this.children=Yo(this.children,r,r+o.length,e,i)}update(e,t,r,o){return this.dirty==We||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,r,o),!0)}updateInner(e,t,r,o){this.updateOuterDeco(t),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(o,this.posAtStart),this.dirty=Ee}updateOuterDeco(e){if(Pr(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=Gl(this.dom,this.nodeDOM,Jo(this.outerDeco,this.node,t),Jo(e,this.node,t)),this.dom!=r&&(r.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.dom.draggable=!0)}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.dom.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}};function Hl(n,e,t,r,o){Xl(r,e,n);let s=new an(void 0,n,e,t,r,r,r,o,0);return s.contentDOM&&s.updateChildren(o,0),s}let Kl=class pf extends an{constructor(e,t,r,o,s,i,l){super(e,t,r,o,s,null,i,l,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,r,o){return this.dirty==We||this.dirty!=Ee&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=Ee||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,o.trackWrites==this.nodeDOM&&(o.trackWrites=null)),this.node=e,this.dirty=Ee,!0)}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,r){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,t,r){let o=this.node.cut(e,t),s=document.createTextNode(o.text);return new pf(this.parent,o,this.outerDeco,this.innerDeco,s,s,r)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=We)}get domAtom(){return!1}isText(e){return this.node.text==e}},Jl=class extends $n{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==Ee&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}};class Ch extends an{constructor(e,t,r,o,s,i,l,a,c,u){super(e,t,r,o,s,i,l,c,u),this.spec=a}update(e,t,r,o){if(this.dirty==We)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let s=this.spec.update(e,t,r);return s&&this.updateInner(e,t,r,o),s}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,t,r,o)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,r,o){this.spec.setSelection?this.spec.setSelection(e,t,r.root):super.setSelection(e,t,r,o)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function Yl(n,e,t){let r=n.firstChild,o=!1;for(let s=0;s<e.length;s++){let i=e[s],l=i.dom;if(l.parentNode==n){for(;l!=r;)r=Ul(r),o=!0;r=r.nextSibling}else o=!0,n.insertBefore(l,r);if(i instanceof Ar){let a=r?r.previousSibling:n.lastChild;Yl(i.contentDOM,i.children,t),r=a?a.nextSibling:n.firstChild}}for(;r;)r=Ul(r),o=!0;o&&t.trackWrites==n&&(t.trackWrites=null)}const jn=function(n){n&&(this.nodeName=n)};jn.prototype=Object.create(null);const $t=[new jn];function Jo(n,e,t){if(n.length==0)return $t;let r=t?$t[0]:new jn,o=[r];for(let s=0;s<n.length;s++){let i=n[s].type.attrs;if(i){i.nodeName&&o.push(r=new jn(i.nodeName));for(let l in i){let a=i[l];a!=null&&(t&&o.length==1&&o.push(r=new jn(e.isInline?"span":"div")),l=="class"?r.class=(r.class?r.class+" ":"")+a:l=="style"?r.style=(r.style?r.style+";":"")+a:l!="nodeName"&&(r[l]=a))}}}return o}function Gl(n,e,t,r){if(t==$t&&r==$t)return e;let o=e;for(let s=0;s<r.length;s++){let i=r[s],l=t[s];if(s){let a;l&&l.nodeName==i.nodeName&&o!=n&&(a=o.parentNode)&&a.nodeName.toLowerCase()==i.nodeName||(a=document.createElement(i.nodeName),a.pmIsDeco=!0,a.appendChild(o),l=$t[0]),o=a}wh(o,l||$t[0],i)}return o}function wh(n,e,t){for(let r in e)r!="class"&&r!="style"&&r!="nodeName"&&!(r in t)&&n.removeAttribute(r);for(let r in t)r!="class"&&r!="style"&&r!="nodeName"&&t[r]!=e[r]&&n.setAttribute(r,t[r]);if(e.class!=t.class){let r=e.class?e.class.split(" ").filter(Boolean):[],o=t.class?t.class.split(" ").filter(Boolean):[];for(let s=0;s<r.length;s++)o.indexOf(r[s])==-1&&n.classList.remove(r[s]);for(let s=0;s<o.length;s++)r.indexOf(o[s])==-1&&n.classList.add(o[s]);n.classList.length==0&&n.removeAttribute("class")}if(e.style!=t.style){if(e.style){let r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,o;for(;o=r.exec(e.style);)n.style.removeProperty(o[1])}t.style&&(n.style.cssText+=t.style)}}function Xl(n,e,t){return Gl(n,n,$t,Jo(e,t,n.nodeType!=1))}function Pr(n,e){if(n.length!=e.length)return!1;for(let t=0;t<n.length;t++)if(!n[t].type.eq(e[t].type))return!1;return!0}function Ul(n){let e=n.nextSibling;return n.parentNode.removeChild(n),e}class Mh{constructor(e,t,r){this.lock=t,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=Nh(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let r=e;r<t;r++)this.top.children[r].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,r){let o=0,s=this.stack.length>>1,i=Math.min(s,e.length);for(;o<i&&(o==s-1?this.top:this.stack[o+1<<1]).matchesMark(e[o])&&e[o].type.spec.spanning!==!1;)o++;for(;o<s;)this.destroyRest(),this.top.dirty=Ee,this.index=this.stack.pop(),this.top=this.stack.pop(),s--;for(;s<e.length;){this.stack.push(this.top,this.index+1);let l=-1;for(let a=this.index;a<Math.min(this.index+3,this.top.children.length);a++){let c=this.top.children[a];if(c.matchesMark(e[s])&&!this.isLocked(c.dom)){l=a;break}}if(l>-1)l>this.index&&(this.changed=!0,this.destroyBetween(this.index,l)),this.top=this.top.children[this.index];else{let a=Ar.create(this.top,e[s],t,r);this.top.children.splice(this.index,0,a),this.top=a,this.changed=!0}this.index=0,s++}}findNodeMatch(e,t,r,o){let s=-1,i;if(o>=this.preMatch.index&&(i=this.preMatch.matches[o-this.preMatch.index]).parent==this.top&&i.matchesNode(e,t,r))s=this.top.children.indexOf(i,this.index);else for(let l=this.index,a=Math.min(this.top.children.length,l+5);l<a;l++){let c=this.top.children[l];if(c.matchesNode(e,t,r)&&!this.preMatch.matched.has(c)){s=l;break}}return s<0?!1:(this.destroyBetween(this.index,s),this.index++,!0)}updateNodeAt(e,t,r,o,s){let i=this.top.children[o];return i.dirty==We&&i.dom==i.contentDOM&&(i.dirty=zt),i.update(e,t,r,s)?(this.destroyBetween(this.index,o),this.index++,!0):!1}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){let r=e.pmViewDesc;if(r){for(let o=this.index;o<this.top.children.length;o++)if(this.top.children[o]==r)return o}return-1}e=t}}updateNextNode(e,t,r,o,s,i){for(let l=this.index;l<this.top.children.length;l++){let a=this.top.children[l];if(a instanceof an){let c=this.preMatch.matched.get(a);if(c!=null&&c!=s)return!1;let u=a.dom,f,d=this.isLocked(u)&&!(e.isText&&a.node&&a.node.isText&&a.nodeDOM.nodeValue==e.text&&a.dirty!=We&&Pr(t,a.outerDeco));if(!d&&a.update(e,t,r,o))return this.destroyBetween(this.index,l),a.dom!=u&&(this.changed=!0),this.index++,!0;if(!d&&(f=this.recreateWrapper(a,e,t,r,o,i)))return this.destroyBetween(this.index,l),this.top.children[this.index]=f,f.contentDOM&&(f.dirty=zt,f.updateChildren(o,i+1),f.dirty=Ee),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,r,o,s,i){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!Pr(r,e.outerDeco)||!o.eq(e.innerDeco))return null;let l=an.create(this.top,t,r,o,s,i);if(l.contentDOM){l.children=e.children,e.children=[];for(let a of l.children)a.parent=l}return e.destroy(),l}addNode(e,t,r,o,s){let i=an.create(this.top,e,t,r,o,s);i.contentDOM&&i.updateChildren(o,s+1),this.top.children.splice(this.index++,0,i),this.changed=!0}placeWidget(e,t,r){let o=this.index<this.top.children.length?this.top.children[this.index]:null;if(o&&o.matchesWidget(e)&&(e==o.widget||!o.widget.type.toDOM.parentNode))this.index++;else{let s=new ql(this.top,e,t,r);this.top.children.splice(this.index++,0,s),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof Ar;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof Kl)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((ue||ie)&&e&&e.dom.contentEditable=="false"&&this.addHackNode("IMG",t),this.addHackNode("BR",this.top))}addHackNode(e,t){if(t==this.top&&this.index<t.children.length&&t.children[this.index].matchesHack(e))this.index++;else{let r=document.createElement(e);e=="IMG"&&(r.className="ProseMirror-separator",r.alt=""),e=="BR"&&(r.className="ProseMirror-trailingBreak");let o=new Jl(this.top,[],r,null);t!=this.top?t.children.push(o):t.children.splice(this.index++,0,o),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||e.nodeType==1&&e.contains(this.lock.parentNode))}}function Nh(n,e){let t=e,r=t.children.length,o=n.childCount,s=new Map,i=[];e:for(;o>0;){let l;for(;;)if(r){let c=t.children[r-1];if(c instanceof Ar)t=c,r=c.children.length;else{l=c,r--;break}}else{if(t==e)break e;r=t.parent.children.indexOf(t),t=t.parent}let a=l.node;if(a){if(a!=n.child(o-1))break;--o,s.set(l,o),i.push(l)}}return{index:o,matched:s,matches:i.reverse()}}function Eh(n,e){return n.type.side-e.type.side}function Dh(n,e,t,r){let o=e.locals(n),s=0;if(o.length==0){for(let c=0;c<n.childCount;c++){let u=n.child(c);r(u,o,e.forChild(s,u),c),s+=u.nodeSize}return}let i=0,l=[],a=null;for(let c=0;;){let u,f;for(;i<o.length&&o[i].to==s;){let g=o[i++];g.widget&&(u?(f||(f=[u])).push(g):u=g)}if(u)if(f){f.sort(Eh);for(let g=0;g<f.length;g++)t(f[g],c,!!a)}else t(u,c,!!a);let d,p;if(a)p=-1,d=a,a=null;else if(c<n.childCount)p=c,d=n.child(c++);else break;for(let g=0;g<l.length;g++)l[g].to<=s&&l.splice(g--,1);for(;i<o.length&&o[i].from<=s&&o[i].to>s;)l.push(o[i++]);let h=s+d.nodeSize;if(d.isText){let g=h;i<o.length&&o[i].from<g&&(g=o[i].from);for(let x=0;x<l.length;x++)l[x].to<g&&(g=l[x].to);g<h&&(a=d.cut(g-s),d=d.cut(0,g-s),h=g,p=-1)}else for(;i<o.length&&o[i].to<h;)i++;let b=d.isInline&&!d.isLeaf?l.filter(g=>!g.inline):l.slice();r(d,b,e.forChild(s,d),p),s=h}}function Oh(n){if(n.nodeName=="UL"||n.nodeName=="OL"){let e=n.style.cssText;n.style.cssText=e+"; list-style: square !important",window.getComputedStyle(n).listStyle,n.style.cssText=e}}function vh(n,e,t,r){for(let o=0,s=0;o<n.childCount&&s<=r;){let i=n.child(o++),l=s;if(s+=i.nodeSize,!i.isText)continue;let a=i.text;for(;o<n.childCount;){let c=n.child(o++);if(s+=c.nodeSize,!c.isText)break;a+=c.text}if(s>=t){if(s>=r&&a.slice(r-e.length-l,r-l)==e)return r-e.length;let c=l<r?a.lastIndexOf(e,r-l-1):-1;if(c>=0&&c+e.length+l>=t)return l+c;if(t==r&&a.length>=r+e.length-l&&a.slice(r-l,r-l+e.length)==e)return r}}return-1}function Yo(n,e,t,r,o){let s=[];for(let i=0,l=0;i<n.length;i++){let a=n[i],c=l,u=l+=a.size;c>=t||u<=e?s.push(a):(c<e&&s.push(a.slice(0,e-c,r)),o&&(s.push(o),o=void 0),u>t&&s.push(a.slice(t-c,a.size,r)))}return s}function Go(n,e=null){let t=n.domSelectionRange(),r=n.state.doc;if(!t.focusNode)return null;let o=n.docView.nearestDesc(t.focusNode),s=o&&o.size==0,i=n.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(i<0)return null;let l=r.resolve(i),a,c;if(Tr(t)){for(a=i;o&&!o.node;)o=o.parent;let f=o.node;if(o&&f.isAtom&&O.isSelectable(f)&&o.parent&&!(f.isInline&&th(t.focusNode,t.focusOffset,o.dom))){let d=o.posBefore;c=new O(i==d?l:r.resolve(d))}}else{if(t instanceof n.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let f=i,d=i;for(let p=0;p<t.rangeCount;p++){let h=t.getRangeAt(p);f=Math.min(f,n.docView.posFromDOM(h.startContainer,h.startOffset,1)),d=Math.max(d,n.docView.posFromDOM(h.endContainer,h.endOffset,-1))}if(f<0)return null;[a,i]=d==n.state.selection.anchor?[d,f]:[f,d],l=r.resolve(i)}else a=n.docView.posFromDOM(t.anchorNode,t.anchorOffset,1);if(a<0)return null}let u=r.resolve(a);if(!c){let f=e=="pointer"||n.state.selection.head<l.pos&&!s?1:-1;c=Uo(n,u,l,f)}return c}function Ql(n){return n.editable?n.hasFocus():sa(n)&&document.activeElement&&document.activeElement.contains(n.dom)}function et(n,e=!1){let t=n.state.selection;if(na(n,t),!!Ql(n)){if(!e&&n.input.mouseDown&&n.input.mouseDown.allowDefault&&ie){let r=n.domSelectionRange(),o=n.domObserver.currentSelection;if(r.anchorNode&&o.anchorNode&&Vt(r.anchorNode,r.anchorOffset,o.anchorNode,o.anchorOffset)){n.input.mouseDown.delayedSelectionSync=!0,n.domObserver.setCurSelection();return}}if(n.domObserver.disconnectSelection(),n.cursorWrapper)Ah(n);else{let{anchor:r,head:o}=t,s,i;Zl&&!(t instanceof V)&&(t.$from.parent.inlineContent||(s=ea(n,t.from)),!t.empty&&!t.$from.parent.inlineContent&&(i=ea(n,t.to))),n.docView.setSelection(r,o,n,e),Zl&&(s&&ta(s),i&&ta(i)),t.visible?n.dom.classList.remove("ProseMirror-hideselection"):(n.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&Th(n))}n.domObserver.setCurSelection(),n.domObserver.connectSelection()}}const Zl=ue||ie&&Al<63;function ea(n,e){let{node:t,offset:r}=n.docView.domFromPos(e,0),o=r<t.childNodes.length?t.childNodes[r]:null,s=r?t.childNodes[r-1]:null;if(ue&&o&&o.contentEditable=="false")return Xo(o);if((!o||o.contentEditable=="false")&&(!s||s.contentEditable=="false")){if(o)return Xo(o);if(s)return Xo(s)}}function Xo(n){return n.contentEditable="true",ue&&n.draggable&&(n.draggable=!1,n.wasDraggable=!0),n}function ta(n){n.contentEditable="false",n.wasDraggable&&(n.draggable=!0,n.wasDraggable=null)}function Th(n){let e=n.dom.ownerDocument;e.removeEventListener("selectionchange",n.input.hideSelectionGuard);let t=n.domSelectionRange(),r=t.anchorNode,o=t.anchorOffset;e.addEventListener("selectionchange",n.input.hideSelectionGuard=()=>{(t.anchorNode!=r||t.anchorOffset!=o)&&(e.removeEventListener("selectionchange",n.input.hideSelectionGuard),setTimeout(()=>{(!Ql(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function Ah(n){let e=n.domSelection(),t=document.createRange();if(!e)return;let r=n.cursorWrapper.dom,o=r.nodeName=="IMG";o?t.setStart(r.parentNode,ne(r)+1):t.setStart(r,0),t.collapse(!0),e.removeAllRanges(),e.addRange(t),!o&&!n.state.selection.visible&&ye&&dt<=11&&(r.disabled=!0,r.disabled=!1)}function na(n,e){if(e instanceof O){let t=n.docView.descAt(e.from);t!=n.lastSelectedViewDesc&&(ra(n),t&&t.selectNode(),n.lastSelectedViewDesc=t)}else ra(n)}function ra(n){n.lastSelectedViewDesc&&(n.lastSelectedViewDesc.parent&&n.lastSelectedViewDesc.deselectNode(),n.lastSelectedViewDesc=void 0)}function Uo(n,e,t,r){return n.someProp("createSelectionBetween",o=>o(n,e,t))||V.between(e,t,r)}function oa(n){return n.editable&&!n.hasFocus()?!1:sa(n)}function sa(n){let e=n.domSelectionRange();if(!e.anchorNode)return!1;try{return n.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(n.editable||n.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function Ph(n){let e=n.docView.domFromPos(n.state.selection.anchor,0),t=n.domSelectionRange();return Vt(e.node,e.offset,t.anchorNode,t.anchorOffset)}function Qo(n,e){let{$anchor:t,$head:r}=n.selection,o=e>0?t.max(r):t.min(r),s=o.parent.inlineContent?o.depth?n.doc.resolve(e>0?o.after():o.before()):null:o;return s&&R.findFrom(s,e)}function pt(n,e){return n.dispatch(n.state.tr.setSelection(e).scrollIntoView()),!0}function ia(n,e,t){let r=n.state.selection;if(r instanceof V)if(t.indexOf("s")>-1){let{$head:o}=r,s=o.textOffset?null:e<0?o.nodeBefore:o.nodeAfter;if(!s||s.isText||!s.isLeaf)return!1;let i=n.state.doc.resolve(o.pos+s.nodeSize*(e<0?-1:1));return pt(n,new V(r.$anchor,i))}else if(r.empty){if(n.endOfTextblock(e>0?"forward":"backward")){let o=Qo(n.state,e);return o&&o instanceof O?pt(n,o):!1}else if(!(Ne&&t.indexOf("m")>-1)){let o=r.$head,s=o.textOffset?null:e<0?o.nodeBefore:o.nodeAfter,i;if(!s||s.isText)return!1;let l=e<0?o.pos-s.nodeSize:o.pos;return s.isAtom||(i=n.docView.descAt(l))&&!i.contentDOM?O.isSelectable(s)?pt(n,new O(e<0?n.state.doc.resolve(o.pos-s.nodeSize):o)):Rn?pt(n,new V(n.state.doc.resolve(e<0?l:l+s.nodeSize))):!1:!1}}else return!1;else{if(r instanceof O&&r.node.isInline)return pt(n,new V(e>0?r.$to:r.$from));{let o=Qo(n.state,e);return o?pt(n,o):!1}}}function Ir(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Bn(n,e){let t=n.pmViewDesc;return t&&t.size==0&&(e<0||n.nextSibling||n.nodeName!="BR")}function cn(n,e){return e<0?Ih(n):Vh(n)}function Ih(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let o,s,i=!1;for(Ie&&t.nodeType==1&&r<Ir(t)&&Bn(t.childNodes[r],-1)&&(i=!0);;)if(r>0){if(t.nodeType!=1)break;{let l=t.childNodes[r-1];if(Bn(l,-1))o=t,s=--r;else if(l.nodeType==3)t=l,r=t.nodeValue.length;else break}}else{if(la(t))break;{let l=t.previousSibling;for(;l&&Bn(l,-1);)o=t.parentNode,s=ne(l),l=l.previousSibling;if(l)t=l,r=Ir(t);else{if(t=t.parentNode,t==n.dom)break;r=0}}}i?Zo(n,t,r):o&&Zo(n,o,s)}function Vh(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let o=Ir(t),s,i;for(;;)if(r<o){if(t.nodeType!=1)break;let l=t.childNodes[r];if(Bn(l,1))s=t,i=++r;else break}else{if(la(t))break;{let l=t.nextSibling;for(;l&&Bn(l,1);)s=l.parentNode,i=ne(l)+1,l=l.nextSibling;if(l)t=l,r=0,o=Ir(t);else{if(t=t.parentNode,t==n.dom)break;r=o=0}}}s&&Zo(n,s,i)}function la(n){let e=n.pmViewDesc;return e&&e.node&&e.node.isBlock}function Rh(n,e){for(;n&&e==n.childNodes.length&&!Vn(n);)e=ne(n)+1,n=n.parentNode;for(;n&&e<n.childNodes.length;){let t=n.childNodes[e];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;n=t,e=0}}function zh(n,e){for(;n&&!e&&!Vn(n);)e=ne(n),n=n.parentNode;for(;n&&e;){let t=n.childNodes[e-1];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;n=t,e=n.childNodes.length}}function Zo(n,e,t){if(e.nodeType!=3){let s,i;(i=Rh(e,t))?(e=i,t=0):(s=zh(e,t))&&(e=s,t=s.nodeValue.length)}let r=n.domSelection();if(!r)return;if(Tr(r)){let s=document.createRange();s.setEnd(e,t),s.setStart(e,t),r.removeAllRanges(),r.addRange(s)}else r.extend&&r.extend(e,t);n.domObserver.setCurSelection();let{state:o}=n;setTimeout(()=>{n.state==o&&et(n)},50)}function aa(n,e){let t=n.state.doc.resolve(e);if(!(ie||oh)&&t.parent.inlineContent){let o=n.coordsAtPos(e);if(e>t.start()){let s=n.coordsAtPos(e-1),i=(s.top+s.bottom)/2;if(i>o.top&&i<o.bottom&&Math.abs(s.left-o.left)>1)return s.left<o.left?"ltr":"rtl"}if(e<t.end()){let s=n.coordsAtPos(e+1),i=(s.top+s.bottom)/2;if(i>o.top&&i<o.bottom&&Math.abs(s.left-o.left)>1)return s.left>o.left?"ltr":"rtl"}}return getComputedStyle(n.dom).direction=="rtl"?"rtl":"ltr"}function ca(n,e,t){let r=n.state.selection;if(r instanceof V&&!r.empty||t.indexOf("s")>-1||Ne&&t.indexOf("m")>-1)return!1;let{$from:o,$to:s}=r;if(!o.parent.inlineContent||n.endOfTextblock(e<0?"up":"down")){let i=Qo(n.state,e);if(i&&i instanceof O)return pt(n,i)}if(!o.parent.inlineContent){let i=e<0?o:s,l=r instanceof ge?R.near(i,e):R.findFrom(i,e);return l?pt(n,l):!1}return!1}function ua(n,e){if(!(n.state.selection instanceof V))return!0;let{$head:t,$anchor:r,empty:o}=n.state.selection;if(!t.sameParent(r))return!0;if(!o)return!1;if(n.endOfTextblock(e>0?"forward":"backward"))return!0;let s=!t.textOffset&&(e<0?t.nodeBefore:t.nodeAfter);if(s&&!s.isText){let i=n.state.tr;return e<0?i.delete(t.pos-s.nodeSize,t.pos):i.delete(t.pos,t.pos+s.nodeSize),n.dispatch(i),!0}return!1}function fa(n,e,t){n.domObserver.stop(),e.contentEditable=t,n.domObserver.start()}function $h(n){if(!ue||n.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:t}=n.domSelectionRange();if(e&&e.nodeType==1&&t==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let r=e.firstChild;fa(n,r,"true"),setTimeout(()=>fa(n,r,"false"),20)}return!1}function jh(n){let e="";return n.ctrlKey&&(e+="c"),n.metaKey&&(e+="m"),n.altKey&&(e+="a"),n.shiftKey&&(e+="s"),e}function Bh(n,e){let t=e.keyCode,r=jh(e);if(t==8||Ne&&t==72&&r=="c")return ua(n,-1)||cn(n,-1);if(t==46&&!e.shiftKey||Ne&&t==68&&r=="c")return ua(n,1)||cn(n,1);if(t==13||t==27)return!0;if(t==37||Ne&&t==66&&r=="c"){let o=t==37?aa(n,n.state.selection.from)=="ltr"?-1:1:-1;return ia(n,o,r)||cn(n,o)}else if(t==39||Ne&&t==70&&r=="c"){let o=t==39?aa(n,n.state.selection.from)=="ltr"?1:-1:1;return ia(n,o,r)||cn(n,o)}else{if(t==38||Ne&&t==80&&r=="c")return ca(n,-1,r)||cn(n,-1);if(t==40||Ne&&t==78&&r=="c")return $h(n)||ca(n,1,r)||cn(n,1);if(r==(Ne?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function da(n,e){n.someProp("transformCopied",p=>{e=p(e,n)});let t=[],{content:r,openStart:o,openEnd:s}=e;for(;o>1&&s>1&&r.childCount==1&&r.firstChild.childCount==1;){o--,s--;let p=r.firstChild;t.push(p.type.name,p.attrs!=p.type.defaultAttrs?p.attrs:null),r=p.content}let i=n.someProp("clipboardSerializer")||$e.fromSchema(n.state.schema),l=ka(),a=l.createElement("div");a.appendChild(i.serializeFragment(r,{document:l}));let c=a.firstChild,u,f=0;for(;c&&c.nodeType==1&&(u=ba[c.nodeName.toLowerCase()]);){for(let p=u.length-1;p>=0;p--){let h=l.createElement(u[p]);for(;a.firstChild;)h.appendChild(a.firstChild);a.appendChild(h),f++}c=a.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${o} ${s}${f?` -${f}`:""} ${JSON.stringify(t)}`);let d=n.someProp("clipboardTextSerializer",p=>p(e,n))||e.content.textBetween(0,e.content.size,`
|
|
35
|
+
`),t)}ignoreFallback(e,t){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),t,!0)}readStyles(e,t){let r=e.style;if(r&&r.length)for(let o=0;o<this.parser.matchedStyles.length;o++){let s=this.parser.matchedStyles[o],i=r.getPropertyValue(s);if(i)for(let l=void 0;;){let a=this.parser.matchStyle(s,i,this,l);if(!a)break;if(a.ignore)return null;if(a.clearMark?t=t.filter(c=>!a.clearMark(c)):t=t.concat(this.parser.schema.marks[a.mark].create(a.attrs)),a.consuming===!1)l=a;else break}}return t}addElementByRule(e,t,r,o){let s,i;if(t.node)if(i=this.parser.schema.nodes[t.node],i.isLeaf)this.insertNode(i.create(t.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let a=this.enter(i,t.attrs||null,r,t.preserveWhitespace);a&&(s=!0,r=a)}else{let a=this.parser.schema.marks[t.mark];r=r.concat(a.create(t.attrs))}let l=this.top;if(i&&i.isLeaf)this.findInside(e);else if(o)this.addElement(e,r,o);else if(t.getContent)this.findInside(e),t.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a,r,!1));else{let a=e;typeof t.contentElement=="string"?a=e.querySelector(t.contentElement):typeof t.contentElement=="function"?a=t.contentElement(e):t.contentElement&&(a=t.contentElement),this.findAround(e,a,!0),this.addAll(a,r),this.findAround(e,a,!1)}s&&this.sync(l)&&this.open--}addAll(e,t,r,o){let s=r||0;for(let i=r?e.childNodes[r]:e.firstChild,l=o==null?null:e.childNodes[o];i!=l;i=i.nextSibling,++s)this.findAtPoint(e,s),this.addDOM(i,t);this.findAtPoint(e,s)}findPlace(e,t,r){let o,s;for(let i=this.open,l=0;i>=0;i--){let a=this.nodes[i],c=a.findWrapping(e);if(c&&(!o||o.length>c.length+l)&&(o=c,s=a,!c.length))break;if(a.solid){if(r)break;l+=2}}if(!o)return null;this.sync(s);for(let i=0;i<o.length;i++)t=this.enterInner(o[i],null,t,!1);return t}insertNode(e,t,r){if(e.isInline&&this.needsBlock&&!this.top.type){let s=this.textblockFromContext();s&&(t=this.enterInner(s,null,t))}let o=this.findPlace(e,t,r);if(o){this.closeExtra();let s=this.top;s.match&&(s.match=s.match.matchType(e.type));let i=F.none;for(let l of o.concat(e.marks))(s.type?s.type.allowsMarkType(l.type):Bi(l.type,e.type))&&(i=l.addToSet(i));return s.content.push(e.mark(i)),!0}return!1}enter(e,t,r,o){let s=this.findPlace(e.create(t),r,!1);return s&&(s=this.enterInner(e,t,r,!0,o)),s}enterInner(e,t,r,o=!1,s){this.closeExtra();let i=this.top;i.match=i.match&&i.match.matchType(e);let l=zi(e,s,i.options);i.options&kr&&i.content.length==0&&(l|=kr);let a=F.none;return r=r.filter(c=>(i.type?i.type.allowsMarkType(c.type):Bi(c.type,e))?(a=c.addToSet(a),!1):!0),this.nodes.push(new Sr(e,t,a,o,null,l)),this.open++,r}closeExtra(e=!1){let t=this.nodes.length-1;if(t>this.open){for(;t>this.open;t--)this.nodes[t-1].content.push(this.nodes[t].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let t=this.open;t>=0;t--){if(this.nodes[t]==e)return this.open=t,!0;this.localPreserveWS&&(this.nodes[t].options|=En)}return!1}get currentPos(){this.closeExtra();let e=0;for(let t=this.open;t>=0;t--){let r=this.nodes[t].content;for(let o=r.length-1;o>=0;o--)e+=r[o].nodeSize;t&&e++}return e}findAtPoint(e,t){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==t&&(this.find[r].pos=this.currentPos)}findInside(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].pos==null&&e.nodeType==1&&e.contains(this.find[t].node)&&(this.find[t].pos=this.currentPos)}findAround(e,t,r){if(e!=t&&this.find)for(let o=0;o<this.find.length;o++)this.find[o].pos==null&&e.nodeType==1&&e.contains(this.find[o].node)&&t.compareDocumentPosition(this.find[o].node)&(r?2:4)&&(this.find[o].pos=this.currentPos)}findInText(e){if(this.find)for(let t=0;t<this.find.length;t++)this.find[t].node==e&&(this.find[t].pos=this.currentPos-(e.nodeValue.length-this.find[t].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let t=e.split("/"),r=this.options.context,o=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),s=-(r?r.depth+1:0)+(o?0:1),i=(l,a)=>{for(;l>=0;l--){let c=t[l];if(c==""){if(l==t.length-1||l==0)continue;for(;a>=s;a--)if(i(l-1,a))return!0;return!1}else{let u=a>0||a==0&&o?this.nodes[a].type:r&&a>=s?r.node(a-s).type:null;if(!u||u.name!=c&&!u.isInGroup(c))return!1;a--}}return!0};return i(t.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let t=e.depth;t>=0;t--){let r=e.node(t).contentMatchAt(e.indexAfter(t)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let t in this.parser.schema.nodes){let r=this.parser.schema.nodes[t];if(r.isTextblock&&r.defaultAttrs)return r}}}function Ff(n){for(let e=n.firstChild,t=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&Ri.hasOwnProperty(r)&&t?(t.appendChild(e),e=t):r=="li"?t=e:r&&(t=null)}}function Lf(n,e){return(n.matches||n.msMatchesSelector||n.webkitMatchesSelector||n.mozMatchesSelector).call(n,e)}function ji(n){let e={};for(let t in n)e[t]=n[t];return e}function Bi(n,e){let t=e.schema.nodes;for(let r in t){let o=t[r];if(!o.allowsMarkType(n))continue;let s=[],i=l=>{s.push(l);for(let a=0;a<l.edgeCount;a++){let{type:c,next:u}=l.edge(a);if(c==e||s.indexOf(u)<0&&i(u))return!0}};if(i(o.contentMatch))return!0}}class $e{constructor(e,t){this.nodes=e,this.marks=t}serializeFragment(e,t={},r){r||(r=mo(t).createDocumentFragment());let o=r,s=[];return e.forEach(i=>{if(s.length||i.marks.length){let l=0,a=0;for(;l<s.length&&a<i.marks.length;){let c=i.marks[a];if(!this.marks[c.type.name]){a++;continue}if(!c.eq(s[l][0])||c.type.spec.spanning===!1)break;l++,a++}for(;l<s.length;)o=s.pop()[1];for(;a<i.marks.length;){let c=i.marks[a++],u=this.serializeMark(c,i.isInline,t);u&&(s.push([c,o]),o.appendChild(u.dom),o=u.contentDOM||u.dom)}}o.appendChild(this.serializeNodeInner(i,t))}),r}serializeNodeInner(e,t){let{dom:r,contentDOM:o}=Cr(mo(t),this.nodes[e.type.name](e),null,e.attrs);if(o){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,t,o)}return r}serializeNode(e,t={}){let r=this.serializeNodeInner(e,t);for(let o=e.marks.length-1;o>=0;o--){let s=this.serializeMark(e.marks[o],e.isInline,t);s&&((s.contentDOM||s.dom).appendChild(r),r=s.dom)}return r}serializeMark(e,t,r={}){let o=this.marks[e.type.name];return o&&Cr(mo(r),o(e,t),null,e.attrs)}static renderSpec(e,t,r=null,o){return Cr(e,t,r,o)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new $e(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let t=Fi(e.nodes);return t.text||(t.text=r=>r.text),t}static marksFromSchema(e){return Fi(e.marks)}}function Fi(n){let e={};for(let t in n){let r=n[t].spec.toDOM;r&&(e[t]=r)}return e}function mo(n){return n.document||window.document}const Li=new WeakMap;function Wf(n){let e=Li.get(n);return e===void 0&&Li.set(n,e=_f(n)),e}function _f(n){let e=null;function t(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")e||(e=[]),e.push(r);else for(let o=0;o<r.length;o++)t(r[o]);else for(let o in r)t(r[o])}return t(n),e}function Cr(n,e,t,r){if(typeof e=="string")return{dom:n.createTextNode(e)};if(e.nodeType!=null)return{dom:e};if(e.dom&&e.dom.nodeType!=null)return e;let o=e[0],s;if(typeof o!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(s=Wf(r))&&s.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let i=o.indexOf(" ");i>0&&(t=o.slice(0,i),o=o.slice(i+1));let l,a=t?n.createElementNS(t,o):n.createElement(o),c=e[1],u=1;if(c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)){u=2;for(let f in c)if(c[f]!=null){let d=f.indexOf(" ");d>0?a.setAttributeNS(f.slice(0,d),f.slice(d+1),c[f]):a.setAttribute(f,c[f])}}for(let f=u;f<e.length;f++){let d=e[f];if(d===0){if(f<e.length-1||f>u)throw new RangeError("Content hole must be the only child of its parent node");return{dom:a,contentDOM:a}}else{let{dom:p,contentDOM:h}=Cr(n,d,t,r);if(a.appendChild(p),h){if(l)throw new RangeError("Multiple content holes");l=h}}}return{dom:a,contentDOM:l}}const Wi=65535,_i=Math.pow(2,16);function qf(n,e){return n+e*_i}function qi(n){return n&Wi}function Hf(n){return(n-(n&Wi))/_i}const Hi=1,Ki=2,wr=4,Ji=8;class go{constructor(e,t,r){this.pos=e,this.delInfo=t,this.recover=r}get deleted(){return(this.delInfo&Ji)>0}get deletedBefore(){return(this.delInfo&(Hi|wr))>0}get deletedAfter(){return(this.delInfo&(Ki|wr))>0}get deletedAcross(){return(this.delInfo&wr)>0}}class xe{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&xe.empty)return xe.empty}recover(e){let t=0,r=qi(e);if(!this.inverted)for(let o=0;o<r;o++)t+=this.ranges[o*3+2]-this.ranges[o*3+1];return this.ranges[r*3]+t+Hf(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,r){let o=0,s=this.inverted?2:1,i=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?o:0);if(a>e)break;let c=this.ranges[l+s],u=this.ranges[l+i],f=a+c;if(e<=f){let d=c?e==a?-1:e==f?1:t:t,p=a+o+(d<0?0:u);if(r)return p;let h=e==(t<0?a:f)?null:qf(l/3,e-a),b=e==a?Ki:e==f?Hi:wr;return(t<0?e!=a:e!=f)&&(b|=Ji),new go(p,b,h)}o+=u-c}return r?e+o:new go(e+o,0,null)}touches(e,t){let r=0,o=qi(t),s=this.inverted?2:1,i=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?r:0);if(a>e)break;let c=this.ranges[l+s],u=a+c;if(e<=u&&l==o*3)return!0;r+=this.ranges[l+i]-c}return!1}forEach(e){let t=this.inverted?2:1,r=this.inverted?1:2;for(let o=0,s=0;o<this.ranges.length;o+=3){let i=this.ranges[o],l=i-(this.inverted?s:0),a=i+(this.inverted?0:s),c=this.ranges[o+t],u=this.ranges[o+r];e(l,l+c,a,a+u),s+=u-c}}invert(){return new xe(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?xe.empty:new xe(e<0?[0,-e,0]:[0,0,e])}}xe.empty=new xe([]);class Dn{constructor(e,t,r=0,o=e?e.length:0){this.mirror=t,this.from=r,this.to=o,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(e=0,t=this.maps.length){return new Dn(this._maps,this.mirror,e,t)}appendMap(e,t){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),t!=null&&this.setMirror(this._maps.length-1,t)}appendMapping(e){for(let t=0,r=this._maps.length;t<e._maps.length;t++){let o=e.getMirror(t);this.appendMap(e._maps[t],o!=null&&o<t?r+o:void 0)}}getMirror(e){if(this.mirror){for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}}setMirror(e,t){this.mirror||(this.mirror=[]),this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,r=this._maps.length+e._maps.length;t>=0;t--){let o=e.getMirror(t);this.appendMap(e._maps[t].invert(),o!=null&&o>t?r-o-1:void 0)}}invert(){let e=new Dn;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let r=this.from;r<this.to;r++)e=this._maps[r].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,r){let o=0;for(let s=this.from;s<this.to;s++){let i=this._maps[s],l=i.mapResult(e,t);if(l.recover!=null){let a=this.getMirror(s);if(a!=null&&a>s&&a<this.to){s=a,e=this._maps[a].recover(l.recover);continue}}o|=l.delInfo,e=l.pos}return r?e:new go(e,o,null)}}const yo=Object.create(null);class oe{getMap(){return xe.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=yo[t.stepType];if(!r)throw new RangeError(`No step type ${t.stepType} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in yo)throw new RangeError("Duplicate use of step JSON ID "+e);return yo[e]=t,t.prototype.jsonID=e,t}}class K{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new K(e,null)}static fail(e){return new K(null,e)}static fromReplace(e,t,r,o){try{return K.ok(e.replace(t,r,o))}catch(s){if(s instanceof pr)return K.fail(s.message);throw s}}}function bo(n,e,t){let r=[];for(let o=0;o<n.childCount;o++){let s=n.child(o);s.content.size&&(s=s.copy(bo(s.content,e,s))),s.isInline&&(s=e(s,t,o)),r.push(s)}return C.fromArray(r)}class st extends oe{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=e.resolve(this.from),o=r.node(r.sharedDepth(this.to)),s=new E(bo(t.content,(i,l)=>!i.isAtom||!l.type.allowsMarkType(this.mark.type)?i:i.mark(this.mark.addToSet(i.marks)),o),t.openStart,t.openEnd);return K.fromReplace(e,this.from,this.to,s)}invert(){return new je(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new st(t.pos,r.pos,this.mark)}merge(e){return e instanceof st&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new st(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new st(t.from,t.to,e.markFromJSON(t.mark))}}oe.jsonID("addMark",st);class je extends oe{constructor(e,t,r){super(),this.from=e,this.to=t,this.mark=r}apply(e){let t=e.slice(this.from,this.to),r=new E(bo(t.content,o=>o.mark(this.mark.removeFromSet(o.marks)),e),t.openStart,t.openEnd);return K.fromReplace(e,this.from,this.to,r)}invert(){return new st(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deleted&&r.deleted||t.pos>=r.pos?null:new je(t.pos,r.pos,this.mark)}merge(e){return e instanceof je&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new je(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new je(t.from,t.to,e.markFromJSON(t.mark))}}oe.jsonID("removeMark",je);class it extends oe{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return K.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return K.fromReplace(e,this.pos,this.pos+1,new E(C.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let r=this.mark.addToSet(t.marks);if(r.length==t.marks.length){for(let o=0;o<t.marks.length;o++)if(!t.marks[o].isInSet(r))return new it(this.pos,t.marks[o]);return new it(this.pos,this.mark)}}return new It(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new it(t.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new it(t.pos,e.markFromJSON(t.mark))}}oe.jsonID("addNodeMark",it);class It extends oe{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return K.fail("No node at mark step's position");let r=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return K.fromReplace(e,this.pos,this.pos+1,new E(C.from(r),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new it(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new It(t.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new It(t.pos,e.markFromJSON(t.mark))}}oe.jsonID("removeNodeMark",It);class se extends oe{constructor(e,t,r,o=!1){super(),this.from=e,this.to=t,this.slice=r,this.structure=o}apply(e){return this.structure&&xo(e,this.from,this.to)?K.fail("Structure replace would overwrite content"):K.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new xe([this.from,this.to-this.from,this.slice.size])}invert(e){return new se(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return t.deletedAcross&&r.deletedAcross?null:new se(t.pos,Math.max(t.pos,r.pos),this.slice,this.structure)}merge(e){if(!(e instanceof se)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let t=this.slice.size+e.slice.size==0?E.empty:new E(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new se(this.from,this.to+(e.to-e.from),t,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let t=this.slice.size+e.slice.size==0?E.empty:new E(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new se(e.from,this.to,t,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new se(t.from,t.to,E.fromJSON(e,t.slice),!!t.structure)}}oe.jsonID("replace",se);class ee extends oe{constructor(e,t,r,o,s,i,l=!1){super(),this.from=e,this.to=t,this.gapFrom=r,this.gapTo=o,this.slice=s,this.insert=i,this.structure=l}apply(e){if(this.structure&&(xo(e,this.from,this.gapFrom)||xo(e,this.gapTo,this.to)))return K.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return K.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,t.content);return r?K.fromReplace(e,this.from,this.to,r):K.fail("Content does not fit in gap")}getMap(){return new xe([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let t=this.gapTo-this.gapFrom;return new ee(this.from,this.from+this.slice.size+t,this.from+this.insert,this.from+this.insert+t,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let t=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),o=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),s=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return t.deletedAcross&&r.deletedAcross||o<t.pos||s>r.pos?null:new ee(t.pos,r.pos,o,s,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number"||typeof t.gapFrom!="number"||typeof t.gapTo!="number"||typeof t.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new ee(t.from,t.to,t.gapFrom,t.gapTo,E.fromJSON(e,t.slice),t.insert,!!t.structure)}}oe.jsonID("replaceAround",ee);function xo(n,e,t){let r=n.resolve(e),o=t-e,s=r.depth;for(;o>0&&s>0&&r.indexAfter(s)==r.node(s).childCount;)s--,o--;if(o>0){let i=r.node(s).maybeChild(r.indexAfter(s));for(;o>0;){if(!i||i.isLeaf)return!0;i=i.firstChild,o--}}return!1}function Kf(n,e,t,r){let o=[],s=[],i,l;n.doc.nodesBetween(e,t,(a,c,u)=>{if(!a.isInline)return;let f=a.marks;if(!r.isInSet(f)&&u.type.allowsMarkType(r.type)){let d=Math.max(c,e),p=Math.min(c+a.nodeSize,t),h=r.addToSet(f);for(let b=0;b<f.length;b++)f[b].isInSet(h)||(i&&i.to==d&&i.mark.eq(f[b])?i.to=p:o.push(i=new je(d,p,f[b])));l&&l.to==d?l.to=p:s.push(l=new st(d,p,r))}}),o.forEach(a=>n.step(a)),s.forEach(a=>n.step(a))}function Jf(n,e,t,r){let o=[],s=0;n.doc.nodesBetween(e,t,(i,l)=>{if(!i.isInline)return;s++;let a=null;if(r instanceof br){let c=i.marks,u;for(;u=r.isInSet(c);)(a||(a=[])).push(u),c=u.removeFromSet(c)}else r?r.isInSet(i.marks)&&(a=[r]):a=i.marks;if(a&&a.length){let c=Math.min(l+i.nodeSize,t);for(let u=0;u<a.length;u++){let f=a[u],d;for(let p=0;p<o.length;p++){let h=o[p];h.step==s-1&&f.eq(o[p].style)&&(d=h)}d?(d.to=c,d.step=s):o.push({style:f,from:Math.max(l,e),to:c,step:s})}}}),o.forEach(i=>n.step(new je(i.from,i.to,i.style)))}function ko(n,e,t,r=t.contentMatch,o=!0){let s=n.doc.nodeAt(e),i=[],l=e+1;for(let a=0;a<s.childCount;a++){let c=s.child(a),u=l+c.nodeSize,f=r.matchType(c.type);if(!f)i.push(new se(l,u,E.empty));else{r=f;for(let d=0;d<c.marks.length;d++)t.allowsMarkType(c.marks[d].type)||n.step(new je(l,u,c.marks[d]));if(o&&c.isText&&t.whitespace!="pre"){let d,p=/\r?\n|\r/g,h;for(;d=p.exec(c.text);)h||(h=new E(C.from(t.schema.text(" ",t.allowedMarks(c.marks))),0,0)),i.push(new se(l+d.index,l+d.index+d[0].length,h))}}l=u}if(!r.validEnd){let a=r.fillBefore(C.empty,!0);n.replace(l,l,new E(a,0,0))}for(let a=i.length-1;a>=0;a--)n.step(i[a])}function Yf(n,e,t){return(e==0||n.canReplace(e,n.childCount))&&(t==n.childCount||n.canReplace(0,t))}function vn(n){let t=n.parent.content.cutByIndex(n.startIndex,n.endIndex);for(let r=n.depth;;--r){let o=n.$from.node(r),s=n.$from.index(r),i=n.$to.indexAfter(r);if(r<n.depth&&o.canReplace(s,i,t))return r;if(r==0||o.type.spec.isolating||!Yf(o,s,i))break}return null}function Gf(n,e,t){let{$from:r,$to:o,depth:s}=e,i=r.before(s+1),l=o.after(s+1),a=i,c=l,u=C.empty,f=0;for(let h=s,b=!1;h>t;h--)b||r.index(h)>0?(b=!0,u=C.from(r.node(h).copy(u)),f++):a--;let d=C.empty,p=0;for(let h=s,b=!1;h>t;h--)b||o.after(h+1)<o.end(h)?(b=!0,d=C.from(o.node(h).copy(d)),p++):c++;n.step(new ee(a,c,i,l,new E(u.append(d),f,p),u.size-f,!0))}function So(n,e,t=null,r=n){let o=Xf(n,e),s=o&&Uf(r,e);return s?o.map(Yi).concat({type:e,attrs:t}).concat(s.map(Yi)):null}function Yi(n){return{type:n,attrs:null}}function Xf(n,e){let{parent:t,startIndex:r,endIndex:o}=n,s=t.contentMatchAt(r).findWrapping(e);if(!s)return null;let i=s.length?s[0]:e;return t.canReplaceWith(r,o,i)?s:null}function Uf(n,e){let{parent:t,startIndex:r,endIndex:o}=n,s=t.child(r),i=e.contentMatch.findWrapping(s.type);if(!i)return null;let a=(i.length?i[i.length-1]:e).contentMatch;for(let c=r;a&&c<o;c++)a=a.matchType(t.child(c).type);return!a||!a.validEnd?null:i}function Qf(n,e,t){let r=C.empty;for(let i=t.length-1;i>=0;i--){if(r.size){let l=t[i].type.contentMatch.matchFragment(r);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=C.from(t[i].type.create(t[i].attrs,r))}let o=e.start,s=e.end;n.step(new ee(o,s,o,s,new E(r,0,0),t.length,!0))}function Zf(n,e,t,r,o){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let s=n.steps.length;n.doc.nodesBetween(e,t,(i,l)=>{let a=typeof o=="function"?o(i):o;if(i.isTextblock&&!i.hasMarkup(r,a)&&ed(n.doc,n.mapping.slice(s).map(l),r)){let c=null;if(r.schema.linebreakReplacement){let p=r.whitespace=="pre",h=!!r.contentMatch.matchType(r.schema.linebreakReplacement);p&&!h?c=!1:!p&&h&&(c=!0)}c===!1&&Xi(n,i,l,s),ko(n,n.mapping.slice(s).map(l,1),r,void 0,c===null);let u=n.mapping.slice(s),f=u.map(l,1),d=u.map(l+i.nodeSize,1);return n.step(new ee(f,d,f+1,d-1,new E(C.from(r.create(a,null,i.marks)),0,0),1,!0)),c===!0&&Gi(n,i,l,s),!1}})}function Gi(n,e,t,r){e.forEach((o,s)=>{if(o.isText){let i,l=/\r?\n|\r/g;for(;i=l.exec(o.text);){let a=n.mapping.slice(r).map(t+1+s+i.index);n.replaceWith(a,a+1,e.type.schema.linebreakReplacement.create())}}})}function Xi(n,e,t,r){e.forEach((o,s)=>{if(o.type==o.type.schema.linebreakReplacement){let i=n.mapping.slice(r).map(t+1+s);n.replaceWith(i,i+1,e.type.schema.text(`
|
|
36
|
+
`))}})}function ed(n,e,t){let r=n.resolve(e),o=r.index();return r.parent.canReplaceWith(o,o+1,t)}function td(n,e,t,r,o){let s=n.doc.nodeAt(e);if(!s)throw new RangeError("No node at given position");t||(t=s.type);let i=t.create(r,null,o||s.marks);if(s.isLeaf)return n.replaceWith(e,e+s.nodeSize,i);if(!t.validContent(s.content))throw new RangeError("Invalid content for node type "+t.name);n.step(new ee(e,e+s.nodeSize,e+1,e+s.nodeSize-1,new E(C.from(i),0,0),1,!0))}function Qt(n,e,t=1,r){let o=n.resolve(e),s=o.depth-t,i=r&&r[r.length-1]||o.parent;if(s<0||o.parent.type.spec.isolating||!o.parent.canReplace(o.index(),o.parent.childCount)||!i.type.validContent(o.parent.content.cutByIndex(o.index(),o.parent.childCount)))return!1;for(let c=o.depth-1,u=t-2;c>s;c--,u--){let f=o.node(c),d=o.index(c);if(f.type.spec.isolating)return!1;let p=f.content.cutByIndex(d,f.childCount),h=r&&r[u+1];h&&(p=p.replaceChild(0,h.type.create(h.attrs)));let b=r&&r[u]||f;if(!f.canReplace(d+1,f.childCount)||!b.type.validContent(p))return!1}let l=o.indexAfter(s),a=r&&r[0];return o.node(s).canReplaceWith(l,l,a?a.type:o.node(s+1).type)}function nd(n,e,t=1,r){let o=n.doc.resolve(e),s=C.empty,i=C.empty;for(let l=o.depth,a=o.depth-t,c=t-1;l>a;l--,c--){s=C.from(o.node(l).copy(s));let u=r&&r[c];i=C.from(u?u.type.create(u.attrs,i):o.node(l).copy(i))}n.step(new se(e,e,new E(s.append(i),t,t),!0))}function Zt(n,e){let t=n.resolve(e),r=t.index();return Ui(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(r,r+1)}function rd(n,e){e.content.size||n.type.compatibleContent(e.type);let t=n.contentMatchAt(n.childCount),{linebreakReplacement:r}=n.type.schema;for(let o=0;o<e.childCount;o++){let s=e.child(o),i=s.type==r?n.type.schema.nodes.text:s.type;if(t=t.matchType(i),!t||!n.type.allowsMarks(s.marks))return!1}return t.validEnd}function Ui(n,e){return!!(n&&e&&!n.isLeaf&&rd(n,e))}function Qi(n,e,t=-1){let r=n.resolve(e);for(let o=r.depth;;o--){let s,i,l=r.index(o);if(o==r.depth?(s=r.nodeBefore,i=r.nodeAfter):t>0?(s=r.node(o+1),l++,i=r.node(o).maybeChild(l)):(s=r.node(o).maybeChild(l-1),i=r.node(o+1)),s&&!s.isTextblock&&Ui(s,i)&&r.node(o).canReplace(l,l+1))return e;if(o==0)break;e=t<0?r.before(o):r.after(o)}}function od(n,e,t){let r=null,{linebreakReplacement:o}=n.doc.type.schema,s=n.doc.resolve(e-t),i=s.node().type;if(o&&i.inlineContent){let u=i.whitespace=="pre",f=!!i.contentMatch.matchType(o);u&&!f?r=!1:!u&&f&&(r=!0)}let l=n.steps.length;if(r===!1){let u=n.doc.resolve(e+t);Xi(n,u.node(),u.before(),l)}i.inlineContent&&ko(n,e+t-1,i,s.node().contentMatchAt(s.index()),r==null);let a=n.mapping.slice(l),c=a.map(e-t);if(n.step(new se(c,a.map(e+t,-1),E.empty,!0)),r===!0){let u=n.doc.resolve(c);Gi(n,u.node(),u.before(),n.steps.length)}return n}function sd(n,e,t){let r=n.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),t))return e;if(r.parentOffset==0)for(let o=r.depth-1;o>=0;o--){let s=r.index(o);if(r.node(o).canReplaceWith(s,s,t))return r.before(o+1);if(s>0)return null}if(r.parentOffset==r.parent.content.size)for(let o=r.depth-1;o>=0;o--){let s=r.indexAfter(o);if(r.node(o).canReplaceWith(s,s,t))return r.after(o+1);if(s<r.node(o).childCount)return null}return null}function Co(n,e,t){let r=n.resolve(e);if(!t.content.size)return e;let o=t.content;for(let s=0;s<t.openStart;s++)o=o.firstChild.content;for(let s=1;s<=(t.openStart==0&&t.size?2:1);s++)for(let i=r.depth;i>=0;i--){let l=i==r.depth?0:r.pos<=(r.start(i+1)+r.end(i+1))/2?-1:1,a=r.index(i)+(l>0?1:0),c=r.node(i),u=!1;if(s==1)u=c.canReplace(a,a,o);else{let f=c.contentMatchAt(a).findWrapping(o.firstChild.type);u=f&&c.canReplaceWith(a,a,f[0])}if(u)return l==0?r.pos:l<0?r.before(i+1):r.after(i+1)}return null}function wo(n,e,t=e,r=E.empty){if(e==t&&!r.size)return null;let o=n.resolve(e),s=n.resolve(t);return Zi(o,s,r)?new se(e,t,r):new id(o,s,r).fit()}function Zi(n,e,t){return!t.openStart&&!t.openEnd&&n.start()==e.start()&&n.parent.canReplace(n.index(),e.index(),t.content)}class id{constructor(e,t,r){this.$from=e,this.$to=t,this.unplaced=r,this.frontier=[],this.placed=C.empty;for(let o=0;o<=e.depth;o++){let s=e.node(o);this.frontier.push({type:s.type,match:s.contentMatchAt(e.indexAfter(o))})}for(let o=e.depth;o>0;o--)this.placed=C.from(e.node(o).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let c=this.findFittable();c?this.placeNodes(c):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,r=this.$from,o=this.close(e<0?this.$to:r.doc.resolve(e));if(!o)return null;let s=this.placed,i=r.depth,l=o.depth;for(;i&&l&&s.childCount==1;)s=s.firstChild.content,i--,l--;let a=new E(s,i,l);return e>-1?new ee(r.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||r.pos!=this.$to.pos?new se(r.pos,o.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,r=0,o=this.unplaced.openEnd;r<e;r++){let s=t.firstChild;if(t.childCount>1&&(o=0),s.type.spec.isolating&&o<=r){e=r;break}t=s.content}for(let t=1;t<=2;t++)for(let r=t==1?e:this.unplaced.openStart;r>=0;r--){let o,s=null;r?(s=Mo(this.unplaced.content,r-1).firstChild,o=s.content):o=this.unplaced.content;let i=o.firstChild;for(let l=this.depth;l>=0;l--){let{type:a,match:c}=this.frontier[l],u,f=null;if(t==1&&(i?c.matchType(i.type)||(f=c.fillBefore(C.from(i),!1)):s&&a.compatibleContent(s.type)))return{sliceDepth:r,frontierDepth:l,parent:s,inject:f};if(t==2&&i&&(u=c.findWrapping(i.type)))return{sliceDepth:r,frontierDepth:l,parent:s,wrap:u};if(s&&c.matchType(s.type))break}}}openMore(){let{content:e,openStart:t,openEnd:r}=this.unplaced,o=Mo(e,t);return!o.childCount||o.firstChild.isLeaf?!1:(this.unplaced=new E(e,t+1,Math.max(r,o.size+t>=e.size-r?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:r}=this.unplaced,o=Mo(e,t);if(o.childCount<=1&&t>0){let s=e.size-t<=t+o.size;this.unplaced=new E(On(e,t-1,1),t-1,s?t-1:r)}else this.unplaced=new E(On(e,t,1),t,r)}placeNodes({sliceDepth:e,frontierDepth:t,parent:r,inject:o,wrap:s}){for(;this.depth>t;)this.closeFrontierNode();if(s)for(let b=0;b<s.length;b++)this.openFrontierNode(s[b]);let i=this.unplaced,l=r?r.content:i.content,a=i.openStart-e,c=0,u=[],{match:f,type:d}=this.frontier[t];if(o){for(let b=0;b<o.childCount;b++)u.push(o.child(b));f=f.matchFragment(o)}let p=l.size+e-(i.content.size-i.openEnd);for(;c<l.childCount;){let b=l.child(c),g=f.matchType(b.type);if(!g)break;c++,(c>1||a==0||b.content.size)&&(f=g,u.push(el(b.mark(d.allowedMarks(b.marks)),c==1?a:0,c==l.childCount?p:-1)))}let h=c==l.childCount;h||(p=-1),this.placed=Tn(this.placed,t,C.from(u)),this.frontier[t].match=f,h&&p<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let b=0,g=l;b<p;b++){let x=g.lastChild;this.frontier.push({type:x.type,match:x.contentMatchAt(x.childCount)}),g=x.content}this.unplaced=h?e==0?E.empty:new E(On(i.content,e-1,1),e-1,p<0?i.openEnd:e-1):new E(On(i.content,e,c),i.openStart,i.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],t;if(!e.type.isTextblock||!No(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(t=this.findCloseLevel(this.$to))&&t.depth==this.depth)return-1;let{depth:r}=this.$to,o=this.$to.after(r);for(;r>1&&o==this.$to.end(--r);)++o;return o}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:r,type:o}=this.frontier[t],s=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),i=No(e,t,o,r,s);if(i){for(let l=t-1;l>=0;l--){let{match:a,type:c}=this.frontier[l],u=No(e,l,c,a,!0);if(!u||u.childCount)continue e}return{depth:t,fit:i,move:s?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=Tn(this.placed,t.depth,t.fit)),e=t.move;for(let r=t.depth+1;r<=e.depth;r++){let o=e.node(r),s=o.type.contentMatch.fillBefore(o.content,!0,e.index(r));this.openFrontierNode(o.type,o.attrs,s)}return e}openFrontierNode(e,t=null,r){let o=this.frontier[this.depth];o.match=o.match.matchType(e),this.placed=Tn(this.placed,this.depth,C.from(e.create(t,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(C.empty,!0);t.childCount&&(this.placed=Tn(this.placed,this.frontier.length,t))}}function On(n,e,t){return e==0?n.cutByIndex(t,n.childCount):n.replaceChild(0,n.firstChild.copy(On(n.firstChild.content,e-1,t)))}function Tn(n,e,t){return e==0?n.append(t):n.replaceChild(n.childCount-1,n.lastChild.copy(Tn(n.lastChild.content,e-1,t)))}function Mo(n,e){for(let t=0;t<e;t++)n=n.firstChild.content;return n}function el(n,e,t){if(e<=0)return n;let r=n.content;return e>1&&(r=r.replaceChild(0,el(r.firstChild,e-1,r.childCount==1?t-1:0))),e>0&&(r=n.type.contentMatch.fillBefore(r).append(r),t<=0&&(r=r.append(n.type.contentMatch.matchFragment(r).fillBefore(C.empty,!0)))),n.copy(r)}function No(n,e,t,r,o){let s=n.node(e),i=o?n.indexAfter(e):n.index(e);if(i==s.childCount&&!t.compatibleContent(s.type))return null;let l=r.fillBefore(s.content,!0,i);return l&&!ld(t,s.content,i)?l:null}function ld(n,e,t){for(let r=t;r<e.childCount;r++)if(!n.allowsMarks(e.child(r).marks))return!0;return!1}function ad(n){return n.spec.defining||n.spec.definingForContent}function cd(n,e,t,r){if(!r.size)return n.deleteRange(e,t);let o=n.doc.resolve(e),s=n.doc.resolve(t);if(Zi(o,s,r))return n.step(new se(e,t,r));let i=nl(o,n.doc.resolve(t));i[i.length-1]==0&&i.pop();let l=-(o.depth+1);i.unshift(l);for(let d=o.depth,p=o.pos-1;d>0;d--,p--){let h=o.node(d).type.spec;if(h.defining||h.definingAsContext||h.isolating)break;i.indexOf(d)>-1?l=d:o.before(d)==p&&i.splice(1,0,-d)}let a=i.indexOf(l),c=[],u=r.openStart;for(let d=r.content,p=0;;p++){let h=d.firstChild;if(c.push(h),p==r.openStart)break;d=h.content}for(let d=u-1;d>=0;d--){let p=c[d],h=ad(p.type);if(h&&!p.sameMarkup(o.node(Math.abs(l)-1)))u=d;else if(h||!p.type.isTextblock)break}for(let d=r.openStart;d>=0;d--){let p=(d+u+1)%(r.openStart+1),h=c[p];if(h)for(let b=0;b<i.length;b++){let g=i[(b+a)%i.length],x=!0;g<0&&(x=!1,g=-g);let S=o.node(g-1),w=o.index(g-1);if(S.canReplaceWith(w,w,h.type,h.marks))return n.replace(o.before(g),x?s.after(g):t,new E(tl(r.content,0,r.openStart,p),p,r.openEnd))}}let f=n.steps.length;for(let d=i.length-1;d>=0&&(n.replace(e,t,r),!(n.steps.length>f));d--){let p=i[d];p<0||(e=o.before(p),t=s.after(p))}}function tl(n,e,t,r,o){if(e<t){let s=n.firstChild;n=n.replaceChild(0,s.copy(tl(s.content,e+1,t,r,s)))}if(e>r){let s=o.contentMatchAt(0),i=s.fillBefore(n).append(n);n=i.append(s.matchFragment(i).fillBefore(C.empty,!0))}return n}function ud(n,e,t,r){if(!r.isInline&&e==t&&n.doc.resolve(e).parent.content.size){let o=sd(n.doc,e,r.type);o!=null&&(e=t=o)}n.replaceRange(e,t,new E(C.from(r),0,0))}function fd(n,e,t){let r=n.doc.resolve(e),o=n.doc.resolve(t),s=nl(r,o);for(let i=0;i<s.length;i++){let l=s[i],a=i==s.length-1;if(a&&l==0||r.node(l).type.contentMatch.validEnd)return n.delete(r.start(l),o.end(l));if(l>0&&(a||r.node(l-1).canReplace(r.index(l-1),o.indexAfter(l-1))))return n.delete(r.before(l),o.after(l))}for(let i=1;i<=r.depth&&i<=o.depth;i++)if(e-r.start(i)==r.depth-i&&t>r.end(i)&&o.end(i)-t!=o.depth-i&&r.start(i-1)==o.start(i-1)&&r.node(i-1).canReplace(r.index(i-1),o.index(i-1)))return n.delete(r.before(i),t);n.delete(e,t)}function nl(n,e){let t=[],r=Math.min(n.depth,e.depth);for(let o=r;o>=0;o--){let s=n.start(o);if(s<n.pos-(n.depth-o)||e.end(o)>e.pos+(e.depth-o)||n.node(o).type.spec.isolating||e.node(o).type.spec.isolating)break;(s==e.start(o)||o==n.depth&&o==e.depth&&n.parent.inlineContent&&e.parent.inlineContent&&o&&e.start(o-1)==s-1)&&t.push(o)}return t}class en extends oe{constructor(e,t,r){super(),this.pos=e,this.attr=t,this.value=r}apply(e){let t=e.nodeAt(this.pos);if(!t)return K.fail("No node at attribute step's position");let r=Object.create(null);for(let s in t.attrs)r[s]=t.attrs[s];r[this.attr]=this.value;let o=t.type.create(r,null,t.marks);return K.fromReplace(e,this.pos,this.pos+1,new E(C.from(o),0,t.isLeaf?0:1))}getMap(){return xe.empty}invert(e){return new en(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new en(t.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.pos!="number"||typeof t.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new en(t.pos,t.attr,t.value)}}oe.jsonID("attr",en);class An extends oe{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let o in e.attrs)t[o]=e.attrs[o];t[this.attr]=this.value;let r=e.type.create(t,e.content,e.marks);return K.ok(r)}getMap(){return xe.empty}invert(e){return new An(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new An(t.attr,t.value)}}oe.jsonID("docAttr",An);let tn=class extends Error{};tn=function n(e){let t=Error.call(this,e);return t.__proto__=n.prototype,t},tn.prototype=Object.create(Error.prototype),tn.prototype.constructor=tn,tn.prototype.name="TransformError";class rl{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Dn}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new tn(t.failed);return this}maybeStep(e){let t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t}get docChanged(){return this.steps.length>0}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,r=E.empty){let o=wo(this.doc,e,t,r);return o&&this.step(o),this}replaceWith(e,t,r){return this.replace(e,t,new E(C.from(r),0,0))}delete(e,t){return this.replace(e,t,E.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,r){return cd(this,e,t,r),this}replaceRangeWith(e,t,r){return ud(this,e,t,r),this}deleteRange(e,t){return fd(this,e,t),this}lift(e,t){return Gf(this,e,t),this}join(e,t=1){return od(this,e,t),this}wrap(e,t){return Qf(this,e,t),this}setBlockType(e,t=e,r,o=null){return Zf(this,e,t,r,o),this}setNodeMarkup(e,t,r=null,o){return td(this,e,t,r,o),this}setNodeAttribute(e,t,r){return this.step(new en(e,t,r)),this}setDocAttribute(e,t){return this.step(new An(e,t)),this}addNodeMark(e,t){return this.step(new it(e,t)),this}removeNodeMark(e,t){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(t instanceof F)t.isInSet(r.marks)&&this.step(new It(e,t));else{let o=r.marks,s,i=[];for(;s=t.isInSet(o);)i.push(new It(e,s)),o=s.removeFromSet(o);for(let l=i.length-1;l>=0;l--)this.step(i[l])}return this}split(e,t=1,r){return nd(this,e,t,r),this}addMark(e,t,r){return Kf(this,e,t,r),this}removeMark(e,t,r){return Jf(this,e,t,r),this}clearIncompatible(e,t,r){return ko(this,e,t,r),this}}const Eo=Object.create(null);class R{constructor(e,t,r){this.$anchor=e,this.$head=t,this.ranges=r||[new ol(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=E.empty){let r=t.content.lastChild,o=null;for(let l=0;l<t.openEnd;l++)o=r,r=r.lastChild;let s=e.steps.length,i=this.ranges;for(let l=0;l<i.length;l++){let{$from:a,$to:c}=i[l],u=e.mapping.slice(s);e.replaceRange(u.map(a.pos),u.map(c.pos),l?E.empty:t),l==0&&ll(e,s,(r?r.isInline:o&&o.isTextblock)?-1:1)}}replaceWith(e,t){let r=e.steps.length,o=this.ranges;for(let s=0;s<o.length;s++){let{$from:i,$to:l}=o[s],a=e.mapping.slice(r),c=a.map(i.pos),u=a.map(l.pos);s?e.deleteRange(c,u):(e.replaceRangeWith(c,u,t),ll(e,r,t.isInline?-1:1))}}static findFrom(e,t,r=!1){let o=e.parent.inlineContent?new V(e):nn(e.node(0),e.parent,e.pos,e.index(),t,r);if(o)return o;for(let s=e.depth-1;s>=0;s--){let i=t<0?nn(e.node(0),e.node(s),e.before(s+1),e.index(s),t,r):nn(e.node(0),e.node(s),e.after(s+1),e.index(s)+1,t,r);if(i)return i}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new ge(e.node(0))}static atStart(e){return nn(e,e,0,0,1)||new ge(e)}static atEnd(e){return nn(e,e,e.content.size,e.childCount,-1)||new ge(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=Eo[t.type];if(!r)throw new RangeError(`No selection type ${t.type} defined`);return r.fromJSON(e,t)}static jsonID(e,t){if(e in Eo)throw new RangeError("Duplicate use of selection JSON ID "+e);return Eo[e]=t,t.prototype.jsonID=e,t}getBookmark(){return V.between(this.$anchor,this.$head).getBookmark()}}R.prototype.visible=!0;class ol{constructor(e,t){this.$from=e,this.$to=t}}let sl=!1;function il(n){!sl&&!n.parent.inlineContent&&(sl=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+n.parent.type.name+")"))}class V extends R{constructor(e,t=e){il(e),il(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let r=e.resolve(t.map(this.head));if(!r.parent.inlineContent)return R.near(r);let o=e.resolve(t.map(this.anchor));return new V(o.parent.inlineContent?o:r,r)}replace(e,t=E.empty){if(super.replace(e,t),t==E.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof V&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Mr(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if(typeof t.anchor!="number"||typeof t.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new V(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,r=t){let o=e.resolve(t);return new this(o,r==t?o:e.resolve(r))}static between(e,t,r){let o=e.pos-t.pos;if((!r||o)&&(r=o>=0?1:-1),!t.parent.inlineContent){let s=R.findFrom(t,r,!0)||R.findFrom(t,-r,!0);if(s)t=s.$head;else return R.near(t,r)}return e.parent.inlineContent||(o==0?e=t:(e=(R.findFrom(e,-r,!0)||R.findFrom(e,r,!0)).$anchor,e.pos<t.pos!=o<0&&(e=t))),new V(e,t)}}R.jsonID("text",V);class Mr{constructor(e,t){this.anchor=e,this.head=t}map(e){return new Mr(e.map(this.anchor),e.map(this.head))}resolve(e){return V.between(e.resolve(this.anchor),e.resolve(this.head))}}class v extends R{constructor(e){let t=e.nodeAfter,r=e.node(0).resolve(e.pos+t.nodeSize);super(e,r),this.node=t}map(e,t){let{deleted:r,pos:o}=t.mapResult(this.anchor),s=e.resolve(o);return r?R.near(s):new v(s)}content(){return new E(C.from(this.node),0,0)}eq(e){return e instanceof v&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new Do(this.anchor)}static fromJSON(e,t){if(typeof t.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new v(e.resolve(t.anchor))}static create(e,t){return new v(e.resolve(t))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}v.prototype.visible=!1,R.jsonID("node",v);class Do{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:r}=e.mapResult(this.anchor);return t?new Mr(r,r):new Do(r)}resolve(e){let t=e.resolve(this.anchor),r=t.nodeAfter;return r&&v.isSelectable(r)?new v(t):R.near(t)}}class ge extends R{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=E.empty){if(t==E.empty){e.delete(0,e.doc.content.size);let r=R.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new ge(e)}map(e){return new ge(e)}eq(e){return e instanceof ge}getBookmark(){return dd}}R.jsonID("all",ge);const dd={map(){return this},resolve(n){return new ge(n)}};function nn(n,e,t,r,o,s=!1){if(e.inlineContent)return V.create(n,t);for(let i=r-(o>0?0:1);o>0?i<e.childCount:i>=0;i+=o){let l=e.child(i);if(l.isAtom){if(!s&&v.isSelectable(l))return v.create(n,t-(o<0?l.nodeSize:0))}else{let a=nn(n,l,t+o,o<0?l.childCount:0,o,s);if(a)return a}t+=l.nodeSize*o}return null}function ll(n,e,t){let r=n.steps.length-1;if(r<e)return;let o=n.steps[r];if(!(o instanceof se||o instanceof ee))return;let s=n.mapping.maps[r],i;s.forEach((l,a,c,u)=>{i==null&&(i=u)}),n.setSelection(R.near(n.doc.resolve(i),t))}const al=1,cl=2,ul=4;class hd extends rl{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(e){if(e.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=(this.updated|al)&-3,this.storedMarks=null,this}get selectionSet(){return(this.updated&al)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=cl,this}ensureMarks(e){return F.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&cl)>0}addStep(e,t){super.addStep(e,t),this.updated=this.updated&-3,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let r=this.selection;return t&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||F.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,r){let o=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(o.text(e),!0):this.deleteSelection();{if(r==null&&(r=t),r=r??t,!e)return this.deleteRange(t,r);let s=this.storedMarks;if(!s){let i=this.doc.resolve(t);s=r==t?i.marks():i.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(t,r,o.text(e,s)),this.selection.empty||this.setSelection(R.near(this.selection.$to)),this}}setMeta(e,t){return this.meta[typeof e=="string"?e:e.key]=t,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=ul,this}get scrolledIntoView(){return(this.updated&ul)>0}}function fl(n,e){return!e||!n?n:n.bind(e)}class Pn{constructor(e,t,r){this.name=e,this.init=fl(t.init,r),this.apply=fl(t.apply,r)}}const pd=[new Pn("doc",{init(n){return n.doc||n.schema.topNodeType.createAndFill()},apply(n){return n.doc}}),new Pn("selection",{init(n,e){return n.selection||R.atStart(e.doc)},apply(n){return n.selection}}),new Pn("storedMarks",{init(n){return n.storedMarks||null},apply(n,e,t,r){return r.selection.$cursor?n.storedMarks:null}}),new Pn("scrollToSelection",{init(){return 0},apply(n,e){return n.scrolledIntoView?e+1:e}})];class vo{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=pd.slice(),t&&t.forEach(r=>{if(this.pluginsByKey[r.key])throw new RangeError("Adding different instances of a keyed plugin ("+r.key+")");this.plugins.push(r),this.pluginsByKey[r.key]=r,r.spec.state&&this.fields.push(new Pn(r.key,r.spec.state,r))})}}class Ge{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,t=-1){for(let r=0;r<this.config.plugins.length;r++)if(r!=t){let o=this.config.plugins[r];if(o.spec.filterTransaction&&!o.spec.filterTransaction.call(o,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let t=[e],r=this.applyInner(e),o=null;for(;;){let s=!1;for(let i=0;i<this.config.plugins.length;i++){let l=this.config.plugins[i];if(l.spec.appendTransaction){let a=o?o[i].n:0,c=o?o[i].state:this,u=a<t.length&&l.spec.appendTransaction.call(l,a?t.slice(a):t,c,r);if(u&&r.filterTransaction(u,i)){if(u.setMeta("appendedTransaction",e),!o){o=[];for(let f=0;f<this.config.plugins.length;f++)o.push(f<i?{state:r,n:t.length}:{state:this,n:0})}t.push(u),r=r.applyInner(u),s=!0}o&&(o[i]={state:r,n:t.length})}}if(!s)return{state:r,transactions:t}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let t=new Ge(this.config),r=this.config.fields;for(let o=0;o<r.length;o++){let s=r[o];t[s.name]=s.apply(e,this[s.name],this,t)}return t}get tr(){return new hd(this)}static create(e){let t=new vo(e.doc?e.doc.type.schema:e.schema,e.plugins),r=new Ge(t);for(let o=0;o<t.fields.length;o++)r[t.fields[o].name]=t.fields[o].init(e,r);return r}reconfigure(e){let t=new vo(this.schema,e.plugins),r=t.fields,o=new Ge(t);for(let s=0;s<r.length;s++){let i=r[s].name;o[i]=this.hasOwnProperty(i)?this[i]:r[s].init(e,o)}return o}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map(r=>r.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let o=e[r],s=o.spec.state;s&&s.toJSON&&(t[r]=s.toJSON.call(o,this[o.key]))}return t}static fromJSON(e,t,r){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let o=new vo(e.schema,e.plugins),s=new Ge(o);return o.fields.forEach(i=>{if(i.name=="doc")s.doc=be.fromJSON(e.schema,t.doc);else if(i.name=="selection")s.selection=R.fromJSON(s.doc,t.selection);else if(i.name=="storedMarks")t.storedMarks&&(s.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let l in r){let a=r[l],c=a.spec.state;if(a.key==i.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(t,l)){s[i.name]=c.fromJSON.call(a,e,t[l],s);return}}s[i.name]=i.init(e,s)}}),s}}function dl(n,e,t){for(let r in n){let o=n[r];o instanceof Function?o=o.bind(e):r=="handleDOMEvents"&&(o=dl(o,e,{})),t[r]=o}return t}class Be{constructor(e){this.spec=e,this.props={},e.props&&dl(e.props,this,this.props),this.key=e.key?e.key.key:hl("plugin")}getState(e){return e[this.key]}}const Oo=Object.create(null);function hl(n){return n in Oo?n+"$"+ ++Oo[n]:(Oo[n]=0,n+"$")}class lt{constructor(e="key"){this.key=hl(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}var Nr=200,X=function(){};X.prototype.append=function(e){return e.length?(e=X.from(e),!this.length&&e||e.length<Nr&&this.leafAppend(e)||this.length<Nr&&e.leafPrepend(this)||this.appendInner(e)):this},X.prototype.prepend=function(e){return e.length?X.from(e).append(this):this},X.prototype.appendInner=function(e){return new md(this,e)},X.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?X.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},X.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},X.prototype.forEach=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length),t<=r?this.forEachInner(e,t,r,0):this.forEachInvertedInner(e,t,r,0)},X.prototype.map=function(e,t,r){t===void 0&&(t=0),r===void 0&&(r=this.length);var o=[];return this.forEach(function(s,i){return o.push(e(s,i))},t,r),o},X.from=function(e){return e instanceof X?e:e&&e.length?new pl(e):X.empty};var pl=function(n){function e(r){n.call(this),this.values=r}n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e;var t={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(o,s){return o==0&&s==this.length?this:new e(this.values.slice(o,s))},e.prototype.getInner=function(o){return this.values[o]},e.prototype.forEachInner=function(o,s,i,l){for(var a=s;a<i;a++)if(o(this.values[a],l+a)===!1)return!1},e.prototype.forEachInvertedInner=function(o,s,i,l){for(var a=s-1;a>=i;a--)if(o(this.values[a],l+a)===!1)return!1},e.prototype.leafAppend=function(o){if(this.length+o.length<=Nr)return new e(this.values.concat(o.flatten()))},e.prototype.leafPrepend=function(o){if(this.length+o.length<=Nr)return new e(o.flatten().concat(this.values))},t.length.get=function(){return this.values.length},t.depth.get=function(){return 0},Object.defineProperties(e.prototype,t),e}(X);X.empty=new pl([]);var md=function(n){function e(t,r){n.call(this),this.left=t,this.right=r,this.length=t.length+r.length,this.depth=Math.max(t.depth,r.depth)+1}return n&&(e.__proto__=n),e.prototype=Object.create(n&&n.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(r){return r<this.left.length?this.left.get(r):this.right.get(r-this.left.length)},e.prototype.forEachInner=function(r,o,s,i){var l=this.left.length;if(o<l&&this.left.forEachInner(r,o,Math.min(s,l),i)===!1||s>l&&this.right.forEachInner(r,Math.max(o-l,0),Math.min(this.length,s)-l,i+l)===!1)return!1},e.prototype.forEachInvertedInner=function(r,o,s,i){var l=this.left.length;if(o>l&&this.right.forEachInvertedInner(r,o-l,Math.max(s,l)-l,i+l)===!1||s<l&&this.left.forEachInvertedInner(r,Math.min(o,l),s,i)===!1)return!1},e.prototype.sliceInner=function(r,o){if(r==0&&o==this.length)return this;var s=this.left.length;return o<=s?this.left.slice(r,o):r>=s?this.right.slice(r-s,o-s):this.left.slice(r,s).append(this.right.slice(0,o-s))},e.prototype.leafAppend=function(r){var o=this.right.leafAppend(r);if(o)return new e(this.left,o)},e.prototype.leafPrepend=function(r){var o=this.left.leafPrepend(r);if(o)return new e(o,this.right)},e.prototype.appendInner=function(r){return this.left.depth>=Math.max(this.right.depth,r.depth)+1?new e(this.left,new e(this.right,r)):new e(this,r)},e}(X);const gd=500;class Pe{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let o,s;t&&(o=this.remapping(r,this.items.length),s=o.maps.length);let i=e.tr,l,a,c=[],u=[];return this.items.forEach((f,d)=>{if(!f.step){o||(o=this.remapping(r,d+1),s=o.maps.length),s--,u.push(f);return}if(o){u.push(new Fe(f.map));let p=f.step.map(o.slice(s)),h;p&&i.maybeStep(p).doc&&(h=i.mapping.maps[i.mapping.maps.length-1],c.push(new Fe(h,void 0,void 0,c.length+u.length))),s--,h&&o.appendMap(h,s)}else i.maybeStep(f.step);if(f.selection)return l=o?f.selection.map(o.slice(s)):f.selection,a=new Pe(this.items.slice(0,r).append(u.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:i,selection:l}}addTransform(e,t,r,o){let s=[],i=this.eventCount,l=this.items,a=!o&&l.length?l.get(l.length-1):null;for(let u=0;u<e.steps.length;u++){let f=e.steps[u].invert(e.docs[u]),d=new Fe(e.mapping.maps[u],f,t),p;(p=a&&a.merge(d))&&(d=p,u?s.pop():l=l.slice(0,l.length-1)),s.push(d),t&&(i++,t=void 0),o||(a=d)}let c=i-r.depth;return c>bd&&(l=yd(l,c),i-=c),new Pe(l.append(s),i)}remapping(e,t){let r=new Dn;return this.items.forEach((o,s)=>{let i=o.mirrorOffset!=null&&s-o.mirrorOffset>=e?r.maps.length-o.mirrorOffset:void 0;r.appendMap(o.map,i)},e,t),r}addMaps(e){return this.eventCount==0?this:new Pe(this.items.append(e.map(t=>new Fe(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let r=[],o=Math.max(0,this.items.length-t),s=e.mapping,i=e.steps.length,l=this.eventCount;this.items.forEach(d=>{d.selection&&l--},o);let a=t;this.items.forEach(d=>{let p=s.getMirror(--a);if(p==null)return;i=Math.min(i,p);let h=s.maps[p];if(d.step){let b=e.steps[p].invert(e.docs[p]),g=d.selection&&d.selection.map(s.slice(a+1,p));g&&l++,r.push(new Fe(h,b,g))}else r.push(new Fe(h))},o);let c=[];for(let d=t;d<i;d++)c.push(new Fe(s.maps[d]));let u=this.items.slice(0,o).append(c).append(r),f=new Pe(u,l);return f.emptyItemCount()>gd&&(f=f.compress(this.items.length-r.length)),f}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),r=t.maps.length,o=[],s=0;return this.items.forEach((i,l)=>{if(l>=e)o.push(i),i.selection&&s++;else if(i.step){let a=i.step.map(t.slice(r)),c=a&&a.getMap();if(r--,c&&t.appendMap(c,r),a){let u=i.selection&&i.selection.map(t.slice(r));u&&s++;let f=new Fe(c.invert(),a,u),d,p=o.length-1;(d=o.length&&o[p].merge(f))?o[p]=d:o.push(f)}}else i.map&&r--},this.items.length,0),new Pe(X.from(o.reverse()),s)}}Pe.empty=new Pe(X.empty,0);function yd(n,e){let t;return n.forEach((r,o)=>{if(r.selection&&e--==0)return t=o,!1}),n.slice(t)}class Fe{constructor(e,t,r,o){this.map=e,this.step=t,this.selection=r,this.mirrorOffset=o}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new Fe(t.getMap().invert(),t,this.selection)}}}class at{constructor(e,t,r,o,s){this.done=e,this.undone=t,this.prevRanges=r,this.prevTime=o,this.prevComposition=s}}const bd=20;function xd(n,e,t,r){let o=t.getMeta(ct),s;if(o)return o.historyState;t.getMeta(Cd)&&(n=new at(n.done,n.undone,null,0,-1));let i=t.getMeta("appendedTransaction");if(t.steps.length==0)return n;if(i&&i.getMeta(ct))return i.getMeta(ct).redo?new at(n.done.addTransform(t,void 0,r,Er(e)),n.undone,ml(t.mapping.maps),n.prevTime,n.prevComposition):new at(n.done,n.undone.addTransform(t,void 0,r,Er(e)),null,n.prevTime,n.prevComposition);if(t.getMeta("addToHistory")!==!1&&!(i&&i.getMeta("addToHistory")===!1)){let l=t.getMeta("composition"),a=n.prevTime==0||!i&&n.prevComposition!=l&&(n.prevTime<(t.time||0)-r.newGroupDelay||!kd(t,n.prevRanges)),c=i?To(n.prevRanges,t.mapping):ml(t.mapping.maps);return new at(n.done.addTransform(t,a?e.selection.getBookmark():void 0,r,Er(e)),Pe.empty,c,t.time,l??n.prevComposition)}else return(s=t.getMeta("rebased"))?new at(n.done.rebased(t,s),n.undone.rebased(t,s),To(n.prevRanges,t.mapping),n.prevTime,n.prevComposition):new at(n.done.addMaps(t.mapping.maps),n.undone.addMaps(t.mapping.maps),To(n.prevRanges,t.mapping),n.prevTime,n.prevComposition)}function kd(n,e){if(!e)return!1;if(!n.docChanged)return!0;let t=!1;return n.mapping.maps[0].forEach((r,o)=>{for(let s=0;s<e.length;s+=2)r<=e[s+1]&&o>=e[s]&&(t=!0)}),t}function ml(n){let e=[];for(let t=n.length-1;t>=0&&e.length==0;t--)n[t].forEach((r,o,s,i)=>e.push(s,i));return e}function To(n,e){if(!n)return null;let t=[];for(let r=0;r<n.length;r+=2){let o=e.map(n[r],1),s=e.map(n[r+1],-1);o<=s&&t.push(o,s)}return t}function Sd(n,e,t){let r=Er(e),o=ct.get(e).spec.config,s=(t?n.undone:n.done).popEvent(e,r);if(!s)return null;let i=s.selection.resolve(s.transform.doc),l=(t?n.done:n.undone).addTransform(s.transform,e.selection.getBookmark(),o,r),a=new at(t?l:s.remaining,t?s.remaining:l,null,0,-1);return s.transform.setSelection(i).setMeta(ct,{redo:t,historyState:a})}let Ao=!1,gl=null;function Er(n){let e=n.plugins;if(gl!=e){Ao=!1,gl=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){Ao=!0;break}}return Ao}const ct=new lt("history"),Cd=new lt("closeHistory");function wd(n={}){return n={depth:n.depth||100,newGroupDelay:n.newGroupDelay||500},new Be({key:ct,state:{init(){return new at(Pe.empty,Pe.empty,null,0,-1)},apply(e,t,r){return xd(t,r,e,n)}},config:n,props:{handleDOMEvents:{beforeinput(e,t){let r=t.inputType,o=r=="historyUndo"?Po:r=="historyRedo"?Dr:null;return o?(t.preventDefault(),o(e.state,e.dispatch)):!1}}}})}function yl(n,e){return(t,r)=>{let o=ct.getState(t);if(!o||(n?o.undone:o.done).eventCount==0)return!1;if(r){let s=Sd(o,t,n);s&&r(e?s.scrollIntoView():s)}return!0}}const Po=yl(!1,!0),Dr=yl(!0,!0);function Md(n){let e=ct.getState(n);return e?e.done.eventCount:0}for(var ut={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},vr={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},Nd=typeof navigator<"u"&&/Mac/.test(navigator.platform),Ed=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),te=0;te<10;te++)ut[48+te]=ut[96+te]=String(te);for(var te=1;te<=24;te++)ut[te+111]="F"+te;for(var te=65;te<=90;te++)ut[te]=String.fromCharCode(te+32),vr[te]=String.fromCharCode(te);for(var Io in ut)vr.hasOwnProperty(Io)||(vr[Io]=ut[Io]);function Dd(n){var e=Nd&&n.metaKey&&n.shiftKey&&!n.ctrlKey&&!n.altKey||Ed&&n.shiftKey&&n.key&&n.key.length==1||n.key=="Unidentified",t=!e&&n.key||(n.shiftKey?vr:ut)[n.keyCode]||n.key||"Unidentified";return t=="Esc"&&(t="Escape"),t=="Del"&&(t="Delete"),t=="Left"&&(t="ArrowLeft"),t=="Up"&&(t="ArrowUp"),t=="Right"&&(t="ArrowRight"),t=="Down"&&(t="ArrowDown"),t}const vd=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):!1;function Od(n){let e=n.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");let r,o,s,i;for(let l=0;l<e.length-1;l++){let a=e[l];if(/^(cmd|meta|m)$/i.test(a))i=!0;else if(/^a(lt)?$/i.test(a))r=!0;else if(/^(c|ctrl|control)$/i.test(a))o=!0;else if(/^s(hift)?$/i.test(a))s=!0;else if(/^mod$/i.test(a))vd?i=!0:o=!0;else throw new Error("Unrecognized modifier name: "+a)}return r&&(t="Alt-"+t),o&&(t="Ctrl-"+t),i&&(t="Meta-"+t),s&&(t="Shift-"+t),t}function Td(n){let e=Object.create(null);for(let t in n)e[Od(t)]=n[t];return e}function Vo(n,e,t=!0){return e.altKey&&(n="Alt-"+n),e.ctrlKey&&(n="Ctrl-"+n),e.metaKey&&(n="Meta-"+n),t&&e.shiftKey&&(n="Shift-"+n),n}function Ro(n){return new Be({props:{handleKeyDown:zo(n)}})}function zo(n){let e=Td(n);return function(t,r){let o=Dd(r),s,i=e[Vo(o,r)];if(i&&i(t.state,t.dispatch,t))return!0;if(o.length==1&&o!=" "){if(r.shiftKey){let l=e[Vo(o,r,!1)];if(l&&l(t.state,t.dispatch,t))return!0}if((r.shiftKey||r.altKey||r.metaKey||o.charCodeAt(0)>127)&&(s=ut[r.keyCode])&&s!=o){let l=e[Vo(s,r)];if(l&&l(t.state,t.dispatch,t))return!0}}return!1}}const bl=(n,e)=>n.selection.empty?!1:(e&&e(n.tr.deleteSelection().scrollIntoView()),!0);function Ad(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("backward",n):t.parentOffset>0)?null:t}const Pd=(n,e,t)=>{let r=Ad(n,t);if(!r)return!1;let o=xl(r);if(!o){let i=r.blockRange(),l=i&&vn(i);return l==null?!1:(e&&e(n.tr.lift(i,l).scrollIntoView()),!0)}let s=o.nodeBefore;if(wl(n,o,e,-1))return!0;if(r.parent.content.size==0&&(rn(s,"end")||v.isSelectable(s)))for(let i=r.depth;;i--){let l=wo(n.doc,r.before(i),r.after(i),E.empty);if(l&&l.slice.size<l.to-l.from){if(e){let a=n.tr.step(l);a.setSelection(rn(s,"end")?R.findFrom(a.doc.resolve(a.mapping.map(o.pos,-1)),-1):v.create(a.doc,o.pos-s.nodeSize)),e(a.scrollIntoView())}return!0}if(i==1||r.node(i-1).childCount>1)break}return s.isAtom&&o.depth==r.depth-1?(e&&e(n.tr.delete(o.pos-s.nodeSize,o.pos).scrollIntoView()),!0):!1};function rn(n,e,t=!1){for(let r=n;r;r=e=="start"?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(t&&r.childCount!=1)return!1}return!1}const Id=(n,e,t)=>{let{$head:r,empty:o}=n.selection,s=r;if(!o)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("backward",n):r.parentOffset>0)return!1;s=xl(r)}let i=s&&s.nodeBefore;return!i||!v.isSelectable(i)?!1:(e&&e(n.tr.setSelection(v.create(n.doc,s.pos-i.nodeSize)).scrollIntoView()),!0)};function xl(n){if(!n.parent.type.spec.isolating)for(let e=n.depth-1;e>=0;e--){if(n.index(e)>0)return n.doc.resolve(n.before(e+1));if(n.node(e).type.spec.isolating)break}return null}function Vd(n,e){let{$cursor:t}=n.selection;return!t||(e?!e.endOfTextblock("forward",n):t.parentOffset<t.parent.content.size)?null:t}const Rd=(n,e,t)=>{let r=Vd(n,t);if(!r)return!1;let o=kl(r);if(!o)return!1;let s=o.nodeAfter;if(wl(n,o,e,1))return!0;if(r.parent.content.size==0&&(rn(s,"start")||v.isSelectable(s))){let i=wo(n.doc,r.before(),r.after(),E.empty);if(i&&i.slice.size<i.to-i.from){if(e){let l=n.tr.step(i);l.setSelection(rn(s,"start")?R.findFrom(l.doc.resolve(l.mapping.map(o.pos)),1):v.create(l.doc,l.mapping.map(o.pos))),e(l.scrollIntoView())}return!0}}return s.isAtom&&o.depth==r.depth-1?(e&&e(n.tr.delete(o.pos,o.pos+s.nodeSize).scrollIntoView()),!0):!1},zd=(n,e,t)=>{let{$head:r,empty:o}=n.selection,s=r;if(!o)return!1;if(r.parent.isTextblock){if(t?!t.endOfTextblock("forward",n):r.parentOffset<r.parent.content.size)return!1;s=kl(r)}let i=s&&s.nodeAfter;return!i||!v.isSelectable(i)?!1:(e&&e(n.tr.setSelection(v.create(n.doc,s.pos)).scrollIntoView()),!0)};function kl(n){if(!n.parent.type.spec.isolating)for(let e=n.depth-1;e>=0;e--){let t=n.node(e);if(n.index(e)+1<t.childCount)return n.doc.resolve(n.after(e+1));if(t.type.spec.isolating)break}return null}const Sl=(n,e)=>{let t=n.selection,r=t instanceof v,o;if(r){if(t.node.isTextblock||!Zt(n.doc,t.from))return!1;o=t.from}else if(o=Qi(n.doc,t.from,-1),o==null)return!1;if(e){let s=n.tr.join(o);r&&s.setSelection(v.create(s.doc,o-n.doc.resolve(o).nodeBefore.nodeSize)),e(s.scrollIntoView())}return!0},$d=(n,e)=>{let t=n.selection,r;if(t instanceof v){if(t.node.isTextblock||!Zt(n.doc,t.to))return!1;r=t.to}else if(r=Qi(n.doc,t.to,1),r==null)return!1;return e&&e(n.tr.join(r).scrollIntoView()),!0},$o=(n,e)=>{let{$from:t,$to:r}=n.selection,o=t.blockRange(r),s=o&&vn(o);return s==null?!1:(e&&e(n.tr.lift(o,s).scrollIntoView()),!0)},jd=(n,e)=>{let{$head:t,$anchor:r}=n.selection;return!t.parent.type.spec.code||!t.sameParent(r)?!1:(e&&e(n.tr.insertText(`
|
|
37
|
+
`).scrollIntoView()),!0)};function jo(n){for(let e=0;e<n.edgeCount;e++){let{type:t}=n.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}const Cl=(n,e)=>{let{$head:t,$anchor:r}=n.selection;if(!t.parent.type.spec.code||!t.sameParent(r))return!1;let o=t.node(-1),s=t.indexAfter(-1),i=jo(o.contentMatchAt(s));if(!i||!o.canReplaceWith(s,s,i))return!1;if(e){let l=t.after(),a=n.tr.replaceWith(l,l,i.createAndFill());a.setSelection(R.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},Bd=(n,e)=>{let t=n.selection,{$from:r,$to:o}=t;if(t instanceof ge||r.parent.inlineContent||o.parent.inlineContent)return!1;let s=jo(o.parent.contentMatchAt(o.indexAfter()));if(!s||!s.isTextblock)return!1;if(e){let i=(!r.parentOffset&&o.index()<o.parent.childCount?r:o).pos,l=n.tr.insert(i,s.createAndFill());l.setSelection(V.create(l.doc,i+1)),e(l.scrollIntoView())}return!0},Fd=(n,e)=>{let{$cursor:t}=n.selection;if(!t||t.parent.content.size)return!1;if(t.depth>1&&t.after()!=t.end(-1)){let s=t.before();if(Qt(n.doc,s))return e&&e(n.tr.split(s).scrollIntoView()),!0}let r=t.blockRange(),o=r&&vn(r);return o==null?!1:(e&&e(n.tr.lift(r,o).scrollIntoView()),!0)};function Ld(n){return(e,t)=>{let{$from:r,$to:o}=e.selection;if(e.selection instanceof v&&e.selection.node.isBlock)return!r.parentOffset||!Qt(e.doc,r.pos)?!1:(t&&t(e.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let s=[],i,l,a=!1,c=!1;for(let p=r.depth;;p--)if(r.node(p).isBlock){a=r.end(p)==r.pos+(r.depth-p),c=r.start(p)==r.pos-(r.depth-p),l=jo(r.node(p-1).contentMatchAt(r.indexAfter(p-1))),s.unshift(a&&l?{type:l}:null),i=p;break}else{if(p==1)return!1;s.unshift(null)}let u=e.tr;(e.selection instanceof V||e.selection instanceof ge)&&u.deleteSelection();let f=u.mapping.map(r.pos),d=Qt(u.doc,f,s.length,s);if(d||(s[0]=l?{type:l}:null,d=Qt(u.doc,f,s.length,s)),!d)return!1;if(u.split(f,s.length,s),!a&&c&&r.node(i).type!=l){let p=u.mapping.map(r.before(i)),h=u.doc.resolve(p);l&&r.node(i-1).canReplaceWith(h.index(),h.index()+1,l)&&u.setNodeMarkup(u.mapping.map(r.before(i)),l)}return t&&t(u.scrollIntoView()),!0}}const Wd=Ld(),Bo=(n,e)=>{let{$from:t,to:r}=n.selection,o,s=t.sharedDepth(r);return s==0?!1:(o=t.before(s),e&&e(n.tr.setSelection(v.create(n.doc,o))),!0)},_d=(n,e)=>(e&&e(n.tr.setSelection(new ge(n.doc))),!0);function qd(n,e,t){let r=e.nodeBefore,o=e.nodeAfter,s=e.index();return!r||!o||!r.type.compatibleContent(o.type)?!1:!r.content.size&&e.parent.canReplace(s-1,s)?(t&&t(n.tr.delete(e.pos-r.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(s,s+1)||!(o.isTextblock||Zt(n.doc,e.pos))?!1:(t&&t(n.tr.join(e.pos).scrollIntoView()),!0)}function wl(n,e,t,r){let o=e.nodeBefore,s=e.nodeAfter,i,l,a=o.type.spec.isolating||s.type.spec.isolating;if(!a&&qd(n,e,t))return!0;let c=!a&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(i=(l=o.contentMatchAt(o.childCount)).findWrapping(s.type))&&l.matchType(i[0]||s.type).validEnd){if(t){let p=e.pos+s.nodeSize,h=C.empty;for(let x=i.length-1;x>=0;x--)h=C.from(i[x].create(null,h));h=C.from(o.copy(h));let b=n.tr.step(new ee(e.pos-1,p,e.pos,p,new E(h,1,0),i.length,!0)),g=b.doc.resolve(p+2*i.length);g.nodeAfter&&g.nodeAfter.type==o.type&&Zt(b.doc,g.pos)&&b.join(g.pos),t(b.scrollIntoView())}return!0}let u=s.type.spec.isolating||r>0&&a?null:R.findFrom(e,1),f=u&&u.$from.blockRange(u.$to),d=f&&vn(f);if(d!=null&&d>=e.depth)return t&&t(n.tr.lift(f,d).scrollIntoView()),!0;if(c&&rn(s,"start",!0)&&rn(o,"end")){let p=o,h=[];for(;h.push(p),!p.isTextblock;)p=p.lastChild;let b=s,g=1;for(;!b.isTextblock;b=b.firstChild)g++;if(p.canReplace(p.childCount,p.childCount,b.content)){if(t){let x=C.empty;for(let w=h.length-1;w>=0;w--)x=C.from(h[w].copy(x));let S=n.tr.step(new ee(e.pos-h.length,e.pos+s.nodeSize,e.pos+g,e.pos+s.nodeSize-g,new E(x,h.length,0),0,!0));t(S.scrollIntoView())}return!0}}return!1}function Ml(n){return function(e,t){let r=e.selection,o=n<0?r.$from:r.$to,s=o.depth;for(;o.node(s).isInline;){if(!s)return!1;s--}return o.node(s).isTextblock?(t&&t(e.tr.setSelection(V.create(e.doc,n<0?o.start(s):o.end(s)))),!0):!1}}const Hd=Ml(-1),Kd=Ml(1);function Nl(n,e=null){return function(t,r){let{$from:o,$to:s}=t.selection,i=o.blockRange(s),l=i&&So(i,n,e);return l?(r&&r(t.tr.wrap(i,l).scrollIntoView()),!0):!1}}function on(n,e=null){return function(t,r){let o=!1;for(let s=0;s<t.selection.ranges.length&&!o;s++){let{$from:{pos:i},$to:{pos:l}}=t.selection.ranges[s];t.doc.nodesBetween(i,l,(a,c)=>{if(o)return!1;if(!(!a.isTextblock||a.hasMarkup(n,e)))if(a.type==n)o=!0;else{let u=t.doc.resolve(c),f=u.index();o=u.parent.canReplaceWith(f,f+1,n)}})}if(!o)return!1;if(r){let s=t.tr;for(let i=0;i<t.selection.ranges.length;i++){let{$from:{pos:l},$to:{pos:a}}=t.selection.ranges[i];s.setBlockType(l,a,n,e)}r(s.scrollIntoView())}return!0}}function Jd(n,e,t,r){for(let o=0;o<e.length;o++){let{$from:s,$to:i}=e[o],l=s.depth==0?n.inlineContent&&n.type.allowsMarkType(t):!1;if(n.nodesBetween(s.pos,i.pos,(a,c)=>{if(l)return!1;l=a.inlineContent&&a.type.allowsMarkType(t)}),l)return!0}return!1}function ke(n,e=null,t){return function(r,o){let{empty:s,$cursor:i,ranges:l}=r.selection;if(s&&!i||!Jd(r.doc,l,n))return!1;if(o)if(i)n.isInSet(r.storedMarks||i.marks())?o(r.tr.removeStoredMark(n)):o(r.tr.addStoredMark(n.create(e)));else{let a,c=r.tr;a=!l.some(u=>r.doc.rangeHasMark(u.$from.pos,u.$to.pos,n));for(let u=0;u<l.length;u++){let{$from:f,$to:d}=l[u];if(!a)c.removeMark(f.pos,d.pos,n);else{let p=f.pos,h=d.pos,b=f.nodeAfter,g=d.nodeBefore,x=b&&b.isText?/^\s*/.exec(b.text)[0].length:0,S=g&&g.isText?/\s*$/.exec(g.text)[0].length:0;p+x<h&&(p+=x,h-=S),c.addMark(p,h,n.create(e))}}o(c.scrollIntoView())}return!0}}function Or(...n){return function(e,t,r){for(let o=0;o<n.length;o++)if(n[o](e,t,r))return!0;return!1}}let Fo=Or(bl,Pd,Id),El=Or(bl,Rd,zd);const Xe={Enter:Or(jd,Bd,Fd,Wd),"Mod-Enter":Cl,Backspace:Fo,"Mod-Backspace":Fo,"Shift-Backspace":Fo,Delete:El,"Mod-Delete":El,"Mod-a":_d},Dl={"Ctrl-h":Xe.Backspace,"Alt-Backspace":Xe["Mod-Backspace"],"Ctrl-d":Xe.Delete,"Ctrl-Alt-Backspace":Xe["Mod-Delete"],"Alt-Delete":Xe["Mod-Delete"],"Alt-d":Xe["Mod-Delete"],"Ctrl-a":Hd,"Ctrl-e":Kd};for(let n in Xe)Dl[n]=Xe[n];const Yd=(typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform?os.platform()=="darwin":!1)?Dl:Xe;function Gd(n={}){return new Be({view(e){return new Xd(e,n)}})}class Xd{constructor(e,t){var r;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(r=t.width)!==null&&r!==void 0?r:1,this.color=t.color===!1?void 0:t.color||"black",this.class=t.class,this.handlers=["dragover","dragend","drop","dragleave"].map(o=>{let s=i=>{this[o](i)};return e.dom.addEventListener(o,s),{name:o,handler:s}})}destroy(){this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){this.cursorPos!=null&&t.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),t=!e.parent.inlineContent,r,o=this.editorView.dom,s=o.getBoundingClientRect(),i=s.width/o.offsetWidth,l=s.height/o.offsetHeight;if(t){let f=e.nodeBefore,d=e.nodeAfter;if(f||d){let p=this.editorView.nodeDOM(this.cursorPos-(f?f.nodeSize:0));if(p){let h=p.getBoundingClientRect(),b=f?h.bottom:h.top;f&&d&&(b=(b+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let g=this.width/2*l;r={left:h.left,right:h.right,top:b-g,bottom:b+g}}}}if(!r){let f=this.editorView.coordsAtPos(this.cursorPos),d=this.width/2*i;r={left:f.left-d,right:f.left+d,top:f.top,bottom:f.bottom}}let a=this.editorView.dom.offsetParent;this.element||(this.element=a.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",t),this.element.classList.toggle("prosemirror-dropcursor-inline",!t);let c,u;if(!a||a==document.body&&getComputedStyle(a).position=="static")c=-pageXOffset,u=-pageYOffset;else{let f=a.getBoundingClientRect(),d=f.width/a.offsetWidth,p=f.height/a.offsetHeight;c=f.left-a.scrollLeft*d,u=f.top-a.scrollTop*p}this.element.style.left=(r.left-c)/i+"px",this.element.style.top=(r.top-u)/l+"px",this.element.style.width=(r.right-r.left)/i+"px",this.element.style.height=(r.bottom-r.top)/l+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),r=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),o=r&&r.type.spec.disableDropCursor,s=typeof o=="function"?o(this.editorView,t,e):o;if(t&&!s){let i=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=Co(this.editorView.state.doc,i,this.editorView.dragging.slice);l!=null&&(i=l)}this.setCursor(i),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}const ne=function(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e},In=function(n){let e=n.assignedSlot||n.parentNode;return e&&e.nodeType==11?e.host:e};let Lo=null;const Ue=function(n,e,t){let r=Lo||(Lo=document.createRange());return r.setEnd(n,t??n.nodeValue.length),r.setStart(n,e||0),r},Ud=function(){Lo=null},Vt=function(n,e,t,r){return t&&(vl(n,e,t,r,-1)||vl(n,e,t,r,1))},Qd=/^(img|br|input|textarea|hr)$/i;function vl(n,e,t,r,o){for(;;){if(n==t&&e==r)return!0;if(e==(o<0?0:Me(n))){let s=n.parentNode;if(!s||s.nodeType!=1||Vn(n)||Qd.test(n.nodeName)||n.contentEditable=="false")return!1;e=ne(n)+(o<0?0:1),n=s}else if(n.nodeType==1){if(n=n.childNodes[e+(o<0?-1:0)],n.contentEditable=="false")return!1;e=o<0?Me(n):0}else return!1}}function Me(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Zd(n,e){for(;;){if(n.nodeType==3&&e)return n;if(n.nodeType==1&&e>0){if(n.contentEditable=="false")return null;n=n.childNodes[e-1],e=Me(n)}else if(n.parentNode&&!Vn(n))e=ne(n),n=n.parentNode;else return null}}function eh(n,e){for(;;){if(n.nodeType==3&&e<n.nodeValue.length)return n;if(n.nodeType==1&&e<n.childNodes.length){if(n.contentEditable=="false")return null;n=n.childNodes[e],e=0}else if(n.parentNode&&!Vn(n))e=ne(n)+1,n=n.parentNode;else return null}}function th(n,e,t){for(let r=e==0,o=e==Me(n);r||o;){if(n==t)return!0;let s=ne(n);if(n=n.parentNode,!n)return!1;r=r&&s==0,o=o&&s==Me(n)}}function Vn(n){let e;for(let t=n;t&&!(e=t.pmViewDesc);t=t.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==n||e.contentDOM==n)}const Tr=function(n){return n.focusNode&&Vt(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)};function Rt(n,e){let t=document.createEvent("Event");return t.initEvent("keydown",!0,!0),t.keyCode=n,t.key=t.code=e,t}function nh(n){let e=n.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function rh(n,e,t){if(n.caretPositionFromPoint)try{let r=n.caretPositionFromPoint(e,t);if(r)return{node:r.offsetNode,offset:Math.min(Me(r.offsetNode),r.offset)}}catch{}if(n.caretRangeFromPoint){let r=n.caretRangeFromPoint(e,t);if(r)return{node:r.startContainer,offset:Math.min(Me(r.startContainer),r.startOffset)}}}const Le=typeof navigator<"u"?navigator:null,Ol=typeof document<"u"?document:null,ft=Le&&Le.userAgent||"",Wo=/Edge\/(\d+)/.exec(ft),Tl=/MSIE \d/.exec(ft),_o=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(ft),ye=!!(Tl||_o||Wo),dt=Tl?document.documentMode:_o?+_o[1]:Wo?+Wo[1]:0,Ie=!ye&&/gecko\/(\d+)/i.test(ft);Ie&&+(/Firefox\/(\d+)/.exec(ft)||[0,0])[1];const qo=!ye&&/Chrome\/(\d+)/.exec(ft),ie=!!qo,Al=qo?+qo[1]:0,ue=!ye&&!!Le&&/Apple Computer/.test(Le.vendor),sn=ue&&(/Mobile\/\w+/.test(ft)||!!Le&&Le.maxTouchPoints>2),Ne=sn||(Le?/Mac/.test(Le.platform):!1),oh=Le?/Win/.test(Le.platform):!1,Qe=/Android \d/.test(ft),Rn=!!Ol&&"webkitFontSmoothing"in Ol.documentElement.style,sh=Rn?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function ih(n){let e=n.defaultView&&n.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:n.documentElement.clientWidth,top:0,bottom:n.documentElement.clientHeight}}function Ze(n,e){return typeof n=="number"?n:n[e]}function lh(n){let e=n.getBoundingClientRect(),t=e.width/n.offsetWidth||1,r=e.height/n.offsetHeight||1;return{left:e.left,right:e.left+n.clientWidth*t,top:e.top,bottom:e.top+n.clientHeight*r}}function Pl(n,e,t){let r=n.someProp("scrollThreshold")||0,o=n.someProp("scrollMargin")||5,s=n.dom.ownerDocument;for(let i=t||n.dom;i;i=In(i)){if(i.nodeType!=1)continue;let l=i,a=l==s.body,c=a?ih(s):lh(l),u=0,f=0;if(e.top<c.top+Ze(r,"top")?f=-(c.top-e.top+Ze(o,"top")):e.bottom>c.bottom-Ze(r,"bottom")&&(f=e.bottom-e.top>c.bottom-c.top?e.top+Ze(o,"top")-c.top:e.bottom-c.bottom+Ze(o,"bottom")),e.left<c.left+Ze(r,"left")?u=-(c.left-e.left+Ze(o,"left")):e.right>c.right-Ze(r,"right")&&(u=e.right-c.right+Ze(o,"right")),u||f)if(a)s.defaultView.scrollBy(u,f);else{let d=l.scrollLeft,p=l.scrollTop;f&&(l.scrollTop+=f),u&&(l.scrollLeft+=u);let h=l.scrollLeft-d,b=l.scrollTop-p;e={left:e.left-h,top:e.top-b,right:e.right-h,bottom:e.bottom-b}}if(a||/^(fixed|sticky)$/.test(getComputedStyle(i).position))break}}function ah(n){let e=n.dom.getBoundingClientRect(),t=Math.max(0,e.top),r,o;for(let s=(e.left+e.right)/2,i=t+1;i<Math.min(innerHeight,e.bottom);i+=5){let l=n.root.elementFromPoint(s,i);if(!l||l==n.dom||!n.dom.contains(l))continue;let a=l.getBoundingClientRect();if(a.top>=t-20){r=l,o=a.top;break}}return{refDOM:r,refTop:o,stack:Il(n.dom)}}function Il(n){let e=[],t=n.ownerDocument;for(let r=n;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),n!=t);r=In(r));return e}function ch({refDOM:n,refTop:e,stack:t}){let r=n?n.getBoundingClientRect().top:0;Vl(t,r==0?0:r-e)}function Vl(n,e){for(let t=0;t<n.length;t++){let{dom:r,top:o,left:s}=n[t];r.scrollTop!=o+e&&(r.scrollTop=o+e),r.scrollLeft!=s&&(r.scrollLeft=s)}}let ln=null;function uh(n){if(n.setActive)return n.setActive();if(ln)return n.focus(ln);let e=Il(n);n.focus(ln==null?{get preventScroll(){return ln={preventScroll:!0},!0}}:void 0),ln||(ln=!1,Vl(e,0))}function Rl(n,e){let t,r=2e8,o,s=0,i=e.top,l=e.top,a,c;for(let u=n.firstChild,f=0;u;u=u.nextSibling,f++){let d;if(u.nodeType==1)d=u.getClientRects();else if(u.nodeType==3)d=Ue(u).getClientRects();else continue;for(let p=0;p<d.length;p++){let h=d[p];if(h.top<=i&&h.bottom>=l){i=Math.max(h.bottom,i),l=Math.min(h.top,l);let b=h.left>e.left?h.left-e.left:h.right<e.left?e.left-h.right:0;if(b<r){t=u,r=b,o=b&&t.nodeType==3?{left:h.right<e.left?h.right:h.left,top:e.top}:e,u.nodeType==1&&b&&(s=f+(e.left>=(h.left+h.right)/2?1:0));continue}}else h.top>e.top&&!a&&h.left<=e.left&&h.right>=e.left&&(a=u,c={left:Math.max(h.left,Math.min(h.right,e.left)),top:h.top});!t&&(e.left>=h.right&&e.top>=h.top||e.left>=h.left&&e.top>=h.bottom)&&(s=f+1)}}return!t&&a&&(t=a,o=c,r=0),t&&t.nodeType==3?fh(t,o):!t||r&&t.nodeType==1?{node:n,offset:s}:Rl(t,o)}function fh(n,e){let t=n.nodeValue.length,r=document.createRange();for(let o=0;o<t;o++){r.setEnd(n,o+1),r.setStart(n,o);let s=ht(r,1);if(s.top!=s.bottom&&Ho(e,s))return{node:n,offset:o+(e.left>=(s.left+s.right)/2?1:0)}}return{node:n,offset:0}}function Ho(n,e){return n.left>=e.left-1&&n.left<=e.right+1&&n.top>=e.top-1&&n.top<=e.bottom+1}function dh(n,e){let t=n.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left<n.getBoundingClientRect().left?t:n}function hh(n,e,t){let{node:r,offset:o}=Rl(e,t),s=-1;if(r.nodeType==1&&!r.firstChild){let i=r.getBoundingClientRect();s=i.left!=i.right&&t.left>(i.left+i.right)/2?1:-1}return n.docView.posFromDOM(r,o,s)}function ph(n,e,t,r){let o=-1;for(let s=e,i=!1;s!=n.dom;){let l=n.docView.nearestDesc(s,!0),a;if(!l)return null;if(l.dom.nodeType==1&&(l.node.isBlock&&l.parent||!l.contentDOM)&&((a=l.dom.getBoundingClientRect()).width||a.height)&&(l.node.isBlock&&l.parent&&(!i&&a.left>r.left||a.top>r.top?o=l.posBefore:(!i&&a.right<r.left||a.bottom<r.top)&&(o=l.posAfter),i=!0),!l.contentDOM&&o<0&&!l.node.isText))return(l.node.isBlock?r.top<(a.top+a.bottom)/2:r.left<(a.left+a.right)/2)?l.posBefore:l.posAfter;s=l.dom.parentNode}return o>-1?o:n.docView.posFromDOM(e,t,-1)}function zl(n,e,t){let r=n.childNodes.length;if(r&&t.top<t.bottom)for(let o=Math.max(0,Math.min(r-1,Math.floor(r*(e.top-t.top)/(t.bottom-t.top))-2)),s=o;;){let i=n.childNodes[s];if(i.nodeType==1){let l=i.getClientRects();for(let a=0;a<l.length;a++){let c=l[a];if(Ho(e,c))return zl(i,e,c)}}if((s=(s+1)%r)==o)break}return n}function mh(n,e){let t=n.dom.ownerDocument,r,o=0,s=rh(t,e.left,e.top);s&&({node:r,offset:o}=s);let i=(n.root.elementFromPoint?n.root:t).elementFromPoint(e.left,e.top),l;if(!i||!n.dom.contains(i.nodeType!=1?i.parentNode:i)){let c=n.dom.getBoundingClientRect();if(!Ho(e,c)||(i=zl(n.dom,e,c),!i))return null}if(ue)for(let c=i;r&&c;c=In(c))c.draggable&&(r=void 0);if(i=dh(i,e),r){if(Ie&&r.nodeType==1&&(o=Math.min(o,r.childNodes.length),o<r.childNodes.length)){let u=r.childNodes[o],f;u.nodeName=="IMG"&&(f=u.getBoundingClientRect()).right<=e.left&&f.bottom>e.top&&o++}let c;Rn&&o&&r.nodeType==1&&(c=r.childNodes[o-1]).nodeType==1&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=e.top&&o--,r==n.dom&&o==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?l=n.state.doc.content.size:(o==0||r.nodeType!=1||r.childNodes[o-1].nodeName!="BR")&&(l=ph(n,r,o,e))}l==null&&(l=hh(n,i,e));let a=n.docView.nearestDesc(i,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function $l(n){return n.top<n.bottom||n.left<n.right}function ht(n,e){let t=n.getClientRects();if(t.length){let r=t[e<0?0:t.length-1];if($l(r))return r}return Array.prototype.find.call(t,$l)||n.getBoundingClientRect()}const gh=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function jl(n,e,t){let{node:r,offset:o,atom:s}=n.docView.domFromPos(e,t<0?-1:1),i=Rn||Ie;if(r.nodeType==3)if(i&&(gh.test(r.nodeValue)||(t<0?!o:o==r.nodeValue.length))){let a=ht(Ue(r,o,o),t);if(Ie&&o&&/\s/.test(r.nodeValue[o-1])&&o<r.nodeValue.length){let c=ht(Ue(r,o-1,o-1),-1);if(c.top==a.top){let u=ht(Ue(r,o,o+1),-1);if(u.top!=a.top)return zn(u,u.left<c.left)}}return a}else{let a=o,c=o,u=t<0?1:-1;return t<0&&!o?(c++,u=-1):t>=0&&o==r.nodeValue.length?(a--,u=1):t<0?a--:c++,zn(ht(Ue(r,a,c),u),u<0)}if(!n.state.doc.resolve(e-(s||0)).parent.inlineContent){if(s==null&&o&&(t<0||o==Me(r))){let a=r.childNodes[o-1];if(a.nodeType==1)return Ko(a.getBoundingClientRect(),!1)}if(s==null&&o<Me(r)){let a=r.childNodes[o];if(a.nodeType==1)return Ko(a.getBoundingClientRect(),!0)}return Ko(r.getBoundingClientRect(),t>=0)}if(s==null&&o&&(t<0||o==Me(r))){let a=r.childNodes[o-1],c=a.nodeType==3?Ue(a,Me(a)-(i?0:1)):a.nodeType==1&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(c)return zn(ht(c,1),!1)}if(s==null&&o<Me(r)){let a=r.childNodes[o];for(;a.pmViewDesc&&a.pmViewDesc.ignoreForCoords;)a=a.nextSibling;let c=a?a.nodeType==3?Ue(a,0,i?0:1):a.nodeType==1?a:null:null;if(c)return zn(ht(c,-1),!0)}return zn(ht(r.nodeType==3?Ue(r):r,-t),t>=0)}function zn(n,e){if(n.width==0)return n;let t=e?n.left:n.right;return{top:n.top,bottom:n.bottom,left:t,right:t}}function Ko(n,e){if(n.height==0)return n;let t=e?n.top:n.bottom;return{top:t,bottom:t,left:n.left,right:n.right}}function Bl(n,e,t){let r=n.state,o=n.root.activeElement;r!=e&&n.updateState(e),o!=n.dom&&n.focus();try{return t()}finally{r!=e&&n.updateState(r),o!=n.dom&&o&&o.focus()}}function yh(n,e,t){let r=e.selection,o=t=="up"?r.$from:r.$to;return Bl(n,e,()=>{let{node:s}=n.docView.domFromPos(o.pos,t=="up"?-1:1);for(;;){let l=n.docView.nearestDesc(s,!0);if(!l)break;if(l.node.isBlock){s=l.contentDOM||l.dom;break}s=l.dom.parentNode}let i=jl(n,o.pos,1);for(let l=s.firstChild;l;l=l.nextSibling){let a;if(l.nodeType==1)a=l.getClientRects();else if(l.nodeType==3)a=Ue(l,0,l.nodeValue.length).getClientRects();else continue;for(let c=0;c<a.length;c++){let u=a[c];if(u.bottom>u.top+1&&(t=="up"?i.top-u.top>(u.bottom-i.top)*2:u.bottom-i.bottom>(i.bottom-u.top)*2))return!1}}return!0})}const bh=/[\u0590-\u08ac]/;function xh(n,e,t){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let o=r.parentOffset,s=!o,i=o==r.parent.content.size,l=n.domSelection();return l?!bh.test(r.parent.textContent)||!l.modify?t=="left"||t=="backward"?s:i:Bl(n,e,()=>{let{focusNode:a,focusOffset:c,anchorNode:u,anchorOffset:f}=n.domSelectionRange(),d=l.caretBidiLevel;l.modify("move",t,"character");let p=r.depth?n.docView.domAfterPos(r.before()):n.dom,{focusNode:h,focusOffset:b}=n.domSelectionRange(),g=h&&!p.contains(h.nodeType==1?h:h.parentNode)||a==h&&c==b;try{l.collapse(u,f),a&&(a!=u||c!=f)&&l.extend&&l.extend(a,c)}catch{}return d!=null&&(l.caretBidiLevel=d),g}):r.pos==r.start()||r.pos==r.end()}let Fl=null,Ll=null,Wl=!1;function kh(n,e,t){return Fl==e&&Ll==t?Wl:(Fl=e,Ll=t,Wl=t=="up"||t=="down"?yh(n,e,t):xh(n,e,t))}const Ee=0,_l=1,zt=2,We=3;let $n=class{constructor(e,t,r,o){this.parent=e,this.children=t,this.dom=r,this.contentDOM=o,this.dirty=Ee,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,r){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;t<this.children.length;t++)e+=this.children[t].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let t=0,r=this.posAtStart;;t++){let o=this.children[t];if(o==e)return r;r+=o.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,t,r){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(r<0){let s,i;if(e==this.contentDOM)s=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;s=e.previousSibling}for(;s&&!((i=s.pmViewDesc)&&i.parent==this);)s=s.previousSibling;return s?this.posBeforeChild(i)+i.size:this.posAtStart}else{let s,i;if(e==this.contentDOM)s=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;s=e.nextSibling}for(;s&&!((i=s.pmViewDesc)&&i.parent==this);)s=s.nextSibling;return s?this.posBeforeChild(i):this.posAtEnd}let o;if(e==this.dom&&this.contentDOM)o=t>ne(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))o=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(t==0)for(let s=e;;s=s.parentNode){if(s==this.dom){o=!1;break}if(s.previousSibling)break}if(o==null&&t==e.childNodes.length)for(let s=e;;s=s.parentNode){if(s==this.dom){o=!0;break}if(s.nextSibling)break}}return o??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let r=!0,o=e;o;o=o.parentNode){let s=this.getDesc(o),i;if(s&&(!t||s.node))if(r&&(i=s.nodeDOM)&&!(i.nodeType==1?i.contains(e.nodeType==1?e:e.parentNode):i==e))r=!1;else return s}}getDesc(e){let t=e.pmViewDesc;for(let r=t;r;r=r.parent)if(r==this)return t}posFromDOM(e,t,r){for(let o=e;o;o=o.parentNode){let s=this.getDesc(o);if(s)return s.localPosFromDOM(e,t,r)}return-1}descAt(e){for(let t=0,r=0;t<this.children.length;t++){let o=this.children[t],s=r+o.size;if(r==e&&s!=r){for(;!o.border&&o.children.length;)o=o.children[0];return o}if(e<s)return o.descAt(e-r-o.border);r=s}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let r=0,o=0;for(let s=0;r<this.children.length;r++){let i=this.children[r],l=s+i.size;if(l>e||i instanceof Jl){o=e-s;break}s=l}if(o)return this.children[r].domFromPos(o-this.children[r].border,t);for(let s;r&&!(s=this.children[r-1]).size&&s instanceof ql&&s.side>=0;r--);if(t<=0){let s,i=!0;for(;s=r?this.children[r-1]:null,!(!s||s.dom.parentNode==this.contentDOM);r--,i=!1);return s&&t&&i&&!s.border&&!s.domAtom?s.domFromPos(s.size,t):{node:this.contentDOM,offset:s?ne(s.dom)+1:0}}else{let s,i=!0;for(;s=r<this.children.length?this.children[r]:null,!(!s||s.dom.parentNode==this.contentDOM);r++,i=!1);return s&&i&&!s.border&&!s.domAtom?s.domFromPos(0,t):{node:this.contentDOM,offset:s?ne(s.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,r=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let o=-1,s=-1;for(let i=r,l=0;;l++){let a=this.children[l],c=i+a.size;if(o==-1&&e<=c){let u=i+a.border;if(e>=u&&t<=c-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,t,u);e=i;for(let f=l;f>0;f--){let d=this.children[f-1];if(d.size&&d.dom.parentNode==this.contentDOM&&!d.emptyChildAt(1)){o=ne(d.dom)+1;break}e-=d.size}o==-1&&(o=0)}if(o>-1&&(c>t||l==this.children.length-1)){t=c;for(let u=l+1;u<this.children.length;u++){let f=this.children[u];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(-1)){s=ne(f.dom);break}t+=f.size}s==-1&&(s=this.contentDOM.childNodes.length);break}i=c}return{node:this.contentDOM,from:e,to:t,fromOffset:o,toOffset:s}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let t=this.children[e<0?0:this.children.length-1];return t.size==0||t.emptyChildAt(e)}domAfterPos(e){let{node:t,offset:r}=this.domFromPos(e,0);if(t.nodeType!=1||r==t.childNodes.length)throw new RangeError("No node after pos "+e);return t.childNodes[r]}setSelection(e,t,r,o=!1){let s=Math.min(e,t),i=Math.max(e,t);for(let p=0,h=0;p<this.children.length;p++){let b=this.children[p],g=h+b.size;if(s>h&&i<g)return b.setSelection(e-h-b.border,t-h-b.border,r,o);h=g}let l=this.domFromPos(e,e?-1:1),a=t==e?l:this.domFromPos(t,t?-1:1),c=r.root.getSelection(),u=r.domSelectionRange(),f=!1;if((Ie||ue)&&e==t){let{node:p,offset:h}=l;if(p.nodeType==3){if(f=!!(h&&p.nodeValue[h-1]==`
|
|
38
|
+
`),f&&h==p.nodeValue.length)for(let b=p,g;b;b=b.parentNode){if(g=b.nextSibling){g.nodeName=="BR"&&(l=a={node:g.parentNode,offset:ne(g)+1});break}let x=b.pmViewDesc;if(x&&x.node&&x.node.isBlock)break}}else{let b=p.childNodes[h-1];f=b&&(b.nodeName=="BR"||b.contentEditable=="false")}}if(Ie&&u.focusNode&&u.focusNode!=a.node&&u.focusNode.nodeType==1){let p=u.focusNode.childNodes[u.focusOffset];p&&p.contentEditable=="false"&&(o=!0)}if(!(o||f&&ue)&&Vt(l.node,l.offset,u.anchorNode,u.anchorOffset)&&Vt(a.node,a.offset,u.focusNode,u.focusOffset))return;let d=!1;if((c.extend||e==t)&&!f){c.collapse(l.node,l.offset);try{e!=t&&c.extend(a.node,a.offset),d=!0}catch{}}if(!d){if(e>t){let h=l;l=a,a=h}let p=document.createRange();p.setEnd(a.node,a.offset),p.setStart(l.node,l.offset),c.removeAllRanges(),c.addRange(p)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let r=0,o=0;o<this.children.length;o++){let s=this.children[o],i=r+s.size;if(r==i?e<=i&&t>=r:e<i&&t>r){let l=r+s.border,a=i-s.border;if(e>=l&&t<=a){this.dirty=e==r||t==i?zt:_l,e==l&&t==a&&(s.contentLost||s.dom.parentNode!=this.contentDOM)?s.dirty=We:s.markDirty(e-l,t-l);return}else s.dirty=s.dom==s.contentDOM&&s.dom.parentNode==this.contentDOM&&!s.children.length?zt:We}r=i}this.dirty=zt}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let r=e==1?zt:_l;t.dirty<r&&(t.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}isText(e){return!1}},ql=class extends $n{constructor(e,t,r,o){let s,i=t.type.toDOM;if(typeof i=="function"&&(i=i(r,()=>{if(!s)return o;if(s.parent)return s.parent.posBeforeChild(s)})),!t.type.spec.raw){if(i.nodeType!=1){let l=document.createElement("span");l.appendChild(i),i=l}i.contentEditable="false",i.classList.add("ProseMirror-widget")}super(e,[],i,null),this.widget=t,this.widget=t,s=this}matchesWidget(e){return this.dirty==Ee&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return t?t(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get side(){return this.widget.type.side}},Sh=class extends $n{constructor(e,t,r,o){super(e,[],t,null),this.textDOM=r,this.text=o}get size(){return this.text.length}localPosFromDOM(e,t){return e!=this.textDOM?this.posAtStart+(t?this.size:0):this.posAtStart+t}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}},Ar=class ui extends $n{constructor(e,t,r,o,s){super(e,[],r,o),this.mark=t,this.spec=s}static create(e,t,r,o){let s=o.nodeViews[t.type.name],i=s&&s(t,o,r);return(!i||!i.dom)&&(i=$e.renderSpec(document,t.type.spec.toDOM(t,r),null,t.attrs)),new ui(e,t,i.dom,i.contentDOM||i.dom,i)}parseRule(){return this.dirty&We||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=We&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=Ee){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty<this.dirty&&(r.dirty=this.dirty),this.dirty=Ee}}slice(e,t,r){let o=ui.create(this.parent,this.mark,!0,r),s=this.children,i=this.size;t<i&&(s=Yo(s,t,i,r)),e>0&&(s=Yo(s,0,e,r));for(let l=0;l<s.length;l++)s[l].parent=o;return o.children=s,o}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}},an=class hf extends $n{constructor(e,t,r,o,s,i,l,a,c){super(e,[],s,i),this.node=t,this.outerDeco=r,this.innerDeco=o,this.nodeDOM=l}static create(e,t,r,o,s,i){let l=s.nodeViews[t.type.name],a,c=l&&l(t,s,()=>{if(!a)return i;if(a.parent)return a.parent.posBeforeChild(a)},r,o),u=c&&c.dom,f=c&&c.contentDOM;if(t.isText){if(!u)u=document.createTextNode(t.text);else if(u.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else u||({dom:u,contentDOM:f}=$e.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs));!f&&!t.isText&&u.nodeName!="BR"&&(u.hasAttribute("contenteditable")||(u.contentEditable="false"),t.type.spec.draggable&&(u.draggable=!0));let d=u;return u=Xl(u,r,t),c?a=new Ch(e,t,r,o,u,f||null,d,c,s,i+1):t.isText?new Kl(e,t,r,o,u,d,s):new hf(e,t,r,o,u,f||null,d,s,i+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(e.preserveWhitespace="full"),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let t=this.children.length-1;t>=0;t--){let r=this.children[t];if(this.dom.contains(r.dom.parentNode)){e.contentElement=r.dom.parentNode;break}}e.contentElement||(e.getContent=()=>C.empty)}return e}matchesNode(e,t,r){return this.dirty==Ee&&e.eq(this.node)&&Pr(t,this.outerDeco)&&r.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let r=this.node.inlineContent,o=t,s=e.composing?this.localCompositionInfo(e,t):null,i=s&&s.pos>-1?s:null,l=s&&s.pos<0,a=new Mh(this,i&&i.node,e);Dh(this.node,this.innerDeco,(c,u,f)=>{c.spec.marks?a.syncToMarks(c.spec.marks,r,e):c.type.side>=0&&!f&&a.syncToMarks(u==this.node.childCount?F.none:this.node.child(u).marks,r,e),a.placeWidget(c,e,o)},(c,u,f,d)=>{a.syncToMarks(c.marks,r,e);let p;a.findNodeMatch(c,u,f,d)||l&&e.state.selection.from>o&&e.state.selection.to<o+c.nodeSize&&(p=a.findIndexWithChild(s.node))>-1&&a.updateNodeAt(c,u,f,p,e)||a.updateNextNode(c,u,f,e,d,o)||a.addNode(c,u,f,e,o),o+=c.nodeSize}),a.syncToMarks([],r,e),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==zt)&&(i&&this.protectLocalComposition(e,i),Yl(this.contentDOM,this.children,e),sn&&vh(this.dom))}localCompositionInfo(e,t){let{from:r,to:o}=e.state.selection;if(!(e.state.selection instanceof V)||r<t||o>t+this.node.content.size)return null;let s=e.input.compositionNode;if(!s||!this.dom.contains(s.parentNode))return null;if(this.node.inlineContent){let i=s.nodeValue,l=Oh(this.node.content,i,r-t,o-t);return l<0?null:{node:s,pos:l,text:i}}else return{node:s,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:r,text:o}){if(this.getDesc(t))return;let s=t;for(;s.parentNode!=this.contentDOM;s=s.parentNode){for(;s.previousSibling;)s.parentNode.removeChild(s.previousSibling);for(;s.nextSibling;)s.parentNode.removeChild(s.nextSibling);s.pmViewDesc&&(s.pmViewDesc=void 0)}let i=new Sh(this,s,t,o);e.input.compositionNodes.push(i),this.children=Yo(this.children,r,r+o.length,e,i)}update(e,t,r,o){return this.dirty==We||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,r,o),!0)}updateInner(e,t,r,o){this.updateOuterDeco(t),this.node=e,this.innerDeco=r,this.contentDOM&&this.updateChildren(o,this.posAtStart),this.dirty=Ee}updateOuterDeco(e){if(Pr(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=Gl(this.dom,this.nodeDOM,Jo(this.outerDeco,this.node,t),Jo(e,this.node,t)),this.dom!=r&&(r.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.dom.draggable=!0)}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.dom.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}};function Hl(n,e,t,r,o){Xl(r,e,n);let s=new an(void 0,n,e,t,r,r,r,o,0);return s.contentDOM&&s.updateChildren(o,0),s}let Kl=class pf extends an{constructor(e,t,r,o,s,i,l){super(e,t,r,o,s,null,i,l,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,r,o){return this.dirty==We||this.dirty!=Ee&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=Ee||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,o.trackWrites==this.nodeDOM&&(o.trackWrites=null)),this.node=e,this.dirty=Ee,!0)}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,r){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,r)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,t,r){let o=this.node.cut(e,t),s=document.createTextNode(o.text);return new pf(this.parent,o,this.outerDeco,this.innerDeco,s,s,r)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=We)}get domAtom(){return!1}isText(e){return this.node.text==e}},Jl=class extends $n{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==Ee&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}};class Ch extends an{constructor(e,t,r,o,s,i,l,a,c,u){super(e,t,r,o,s,i,l,c,u),this.spec=a}update(e,t,r,o){if(this.dirty==We)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let s=this.spec.update(e,t,r);return s&&this.updateInner(e,t,r,o),s}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,t,r,o)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,r,o){this.spec.setSelection?this.spec.setSelection(e,t,r.root):super.setSelection(e,t,r,o)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function Yl(n,e,t){let r=n.firstChild,o=!1;for(let s=0;s<e.length;s++){let i=e[s],l=i.dom;if(l.parentNode==n){for(;l!=r;)r=Ul(r),o=!0;r=r.nextSibling}else o=!0,n.insertBefore(l,r);if(i instanceof Ar){let a=r?r.previousSibling:n.lastChild;Yl(i.contentDOM,i.children,t),r=a?a.nextSibling:n.firstChild}}for(;r;)r=Ul(r),o=!0;o&&t.trackWrites==n&&(t.trackWrites=null)}const jn=function(n){n&&(this.nodeName=n)};jn.prototype=Object.create(null);const $t=[new jn];function Jo(n,e,t){if(n.length==0)return $t;let r=t?$t[0]:new jn,o=[r];for(let s=0;s<n.length;s++){let i=n[s].type.attrs;if(i){i.nodeName&&o.push(r=new jn(i.nodeName));for(let l in i){let a=i[l];a!=null&&(t&&o.length==1&&o.push(r=new jn(e.isInline?"span":"div")),l=="class"?r.class=(r.class?r.class+" ":"")+a:l=="style"?r.style=(r.style?r.style+";":"")+a:l!="nodeName"&&(r[l]=a))}}}return o}function Gl(n,e,t,r){if(t==$t&&r==$t)return e;let o=e;for(let s=0;s<r.length;s++){let i=r[s],l=t[s];if(s){let a;l&&l.nodeName==i.nodeName&&o!=n&&(a=o.parentNode)&&a.nodeName.toLowerCase()==i.nodeName||(a=document.createElement(i.nodeName),a.pmIsDeco=!0,a.appendChild(o),l=$t[0]),o=a}wh(o,l||$t[0],i)}return o}function wh(n,e,t){for(let r in e)r!="class"&&r!="style"&&r!="nodeName"&&!(r in t)&&n.removeAttribute(r);for(let r in t)r!="class"&&r!="style"&&r!="nodeName"&&t[r]!=e[r]&&n.setAttribute(r,t[r]);if(e.class!=t.class){let r=e.class?e.class.split(" ").filter(Boolean):[],o=t.class?t.class.split(" ").filter(Boolean):[];for(let s=0;s<r.length;s++)o.indexOf(r[s])==-1&&n.classList.remove(r[s]);for(let s=0;s<o.length;s++)r.indexOf(o[s])==-1&&n.classList.add(o[s]);n.classList.length==0&&n.removeAttribute("class")}if(e.style!=t.style){if(e.style){let r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,o;for(;o=r.exec(e.style);)n.style.removeProperty(o[1])}t.style&&(n.style.cssText+=t.style)}}function Xl(n,e,t){return Gl(n,n,$t,Jo(e,t,n.nodeType!=1))}function Pr(n,e){if(n.length!=e.length)return!1;for(let t=0;t<n.length;t++)if(!n[t].type.eq(e[t].type))return!1;return!0}function Ul(n){let e=n.nextSibling;return n.parentNode.removeChild(n),e}class Mh{constructor(e,t,r){this.lock=t,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=Nh(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let r=e;r<t;r++)this.top.children[r].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,r){let o=0,s=this.stack.length>>1,i=Math.min(s,e.length);for(;o<i&&(o==s-1?this.top:this.stack[o+1<<1]).matchesMark(e[o])&&e[o].type.spec.spanning!==!1;)o++;for(;o<s;)this.destroyRest(),this.top.dirty=Ee,this.index=this.stack.pop(),this.top=this.stack.pop(),s--;for(;s<e.length;){this.stack.push(this.top,this.index+1);let l=-1;for(let a=this.index;a<Math.min(this.index+3,this.top.children.length);a++){let c=this.top.children[a];if(c.matchesMark(e[s])&&!this.isLocked(c.dom)){l=a;break}}if(l>-1)l>this.index&&(this.changed=!0,this.destroyBetween(this.index,l)),this.top=this.top.children[this.index];else{let a=Ar.create(this.top,e[s],t,r);this.top.children.splice(this.index,0,a),this.top=a,this.changed=!0}this.index=0,s++}}findNodeMatch(e,t,r,o){let s=-1,i;if(o>=this.preMatch.index&&(i=this.preMatch.matches[o-this.preMatch.index]).parent==this.top&&i.matchesNode(e,t,r))s=this.top.children.indexOf(i,this.index);else for(let l=this.index,a=Math.min(this.top.children.length,l+5);l<a;l++){let c=this.top.children[l];if(c.matchesNode(e,t,r)&&!this.preMatch.matched.has(c)){s=l;break}}return s<0?!1:(this.destroyBetween(this.index,s),this.index++,!0)}updateNodeAt(e,t,r,o,s){let i=this.top.children[o];return i.dirty==We&&i.dom==i.contentDOM&&(i.dirty=zt),i.update(e,t,r,s)?(this.destroyBetween(this.index,o),this.index++,!0):!1}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){let r=e.pmViewDesc;if(r){for(let o=this.index;o<this.top.children.length;o++)if(this.top.children[o]==r)return o}return-1}e=t}}updateNextNode(e,t,r,o,s,i){for(let l=this.index;l<this.top.children.length;l++){let a=this.top.children[l];if(a instanceof an){let c=this.preMatch.matched.get(a);if(c!=null&&c!=s)return!1;let u=a.dom,f,d=this.isLocked(u)&&!(e.isText&&a.node&&a.node.isText&&a.nodeDOM.nodeValue==e.text&&a.dirty!=We&&Pr(t,a.outerDeco));if(!d&&a.update(e,t,r,o))return this.destroyBetween(this.index,l),a.dom!=u&&(this.changed=!0),this.index++,!0;if(!d&&(f=this.recreateWrapper(a,e,t,r,o,i)))return this.destroyBetween(this.index,l),this.top.children[this.index]=f,f.contentDOM&&(f.dirty=zt,f.updateChildren(o,i+1),f.dirty=Ee),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,r,o,s,i){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!Pr(r,e.outerDeco)||!o.eq(e.innerDeco))return null;let l=an.create(this.top,t,r,o,s,i);if(l.contentDOM){l.children=e.children,e.children=[];for(let a of l.children)a.parent=l}return e.destroy(),l}addNode(e,t,r,o,s){let i=an.create(this.top,e,t,r,o,s);i.contentDOM&&i.updateChildren(o,s+1),this.top.children.splice(this.index++,0,i),this.changed=!0}placeWidget(e,t,r){let o=this.index<this.top.children.length?this.top.children[this.index]:null;if(o&&o.matchesWidget(e)&&(e==o.widget||!o.widget.type.toDOM.parentNode))this.index++;else{let s=new ql(this.top,e,t,r);this.top.children.splice(this.index++,0,s),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof Ar;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof Kl)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((ue||ie)&&e&&e.dom.contentEditable=="false"&&this.addHackNode("IMG",t),this.addHackNode("BR",this.top))}addHackNode(e,t){if(t==this.top&&this.index<t.children.length&&t.children[this.index].matchesHack(e))this.index++;else{let r=document.createElement(e);e=="IMG"&&(r.className="ProseMirror-separator",r.alt=""),e=="BR"&&(r.className="ProseMirror-trailingBreak");let o=new Jl(this.top,[],r,null);t!=this.top?t.children.push(o):t.children.splice(this.index++,0,o),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||e.nodeType==1&&e.contains(this.lock.parentNode))}}function Nh(n,e){let t=e,r=t.children.length,o=n.childCount,s=new Map,i=[];e:for(;o>0;){let l;for(;;)if(r){let c=t.children[r-1];if(c instanceof Ar)t=c,r=c.children.length;else{l=c,r--;break}}else{if(t==e)break e;r=t.parent.children.indexOf(t),t=t.parent}let a=l.node;if(a){if(a!=n.child(o-1))break;--o,s.set(l,o),i.push(l)}}return{index:o,matched:s,matches:i.reverse()}}function Eh(n,e){return n.type.side-e.type.side}function Dh(n,e,t,r){let o=e.locals(n),s=0;if(o.length==0){for(let c=0;c<n.childCount;c++){let u=n.child(c);r(u,o,e.forChild(s,u),c),s+=u.nodeSize}return}let i=0,l=[],a=null;for(let c=0;;){let u,f;for(;i<o.length&&o[i].to==s;){let g=o[i++];g.widget&&(u?(f||(f=[u])).push(g):u=g)}if(u)if(f){f.sort(Eh);for(let g=0;g<f.length;g++)t(f[g],c,!!a)}else t(u,c,!!a);let d,p;if(a)p=-1,d=a,a=null;else if(c<n.childCount)p=c,d=n.child(c++);else break;for(let g=0;g<l.length;g++)l[g].to<=s&&l.splice(g--,1);for(;i<o.length&&o[i].from<=s&&o[i].to>s;)l.push(o[i++]);let h=s+d.nodeSize;if(d.isText){let g=h;i<o.length&&o[i].from<g&&(g=o[i].from);for(let x=0;x<l.length;x++)l[x].to<g&&(g=l[x].to);g<h&&(a=d.cut(g-s),d=d.cut(0,g-s),h=g,p=-1)}else for(;i<o.length&&o[i].to<h;)i++;let b=d.isInline&&!d.isLeaf?l.filter(g=>!g.inline):l.slice();r(d,b,e.forChild(s,d),p),s=h}}function vh(n){if(n.nodeName=="UL"||n.nodeName=="OL"){let e=n.style.cssText;n.style.cssText=e+"; list-style: square !important",window.getComputedStyle(n).listStyle,n.style.cssText=e}}function Oh(n,e,t,r){for(let o=0,s=0;o<n.childCount&&s<=r;){let i=n.child(o++),l=s;if(s+=i.nodeSize,!i.isText)continue;let a=i.text;for(;o<n.childCount;){let c=n.child(o++);if(s+=c.nodeSize,!c.isText)break;a+=c.text}if(s>=t){if(s>=r&&a.slice(r-e.length-l,r-l)==e)return r-e.length;let c=l<r?a.lastIndexOf(e,r-l-1):-1;if(c>=0&&c+e.length+l>=t)return l+c;if(t==r&&a.length>=r+e.length-l&&a.slice(r-l,r-l+e.length)==e)return r}}return-1}function Yo(n,e,t,r,o){let s=[];for(let i=0,l=0;i<n.length;i++){let a=n[i],c=l,u=l+=a.size;c>=t||u<=e?s.push(a):(c<e&&s.push(a.slice(0,e-c,r)),o&&(s.push(o),o=void 0),u>t&&s.push(a.slice(t-c,a.size,r)))}return s}function Go(n,e=null){let t=n.domSelectionRange(),r=n.state.doc;if(!t.focusNode)return null;let o=n.docView.nearestDesc(t.focusNode),s=o&&o.size==0,i=n.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(i<0)return null;let l=r.resolve(i),a,c;if(Tr(t)){for(a=i;o&&!o.node;)o=o.parent;let f=o.node;if(o&&f.isAtom&&v.isSelectable(f)&&o.parent&&!(f.isInline&&th(t.focusNode,t.focusOffset,o.dom))){let d=o.posBefore;c=new v(i==d?l:r.resolve(d))}}else{if(t instanceof n.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let f=i,d=i;for(let p=0;p<t.rangeCount;p++){let h=t.getRangeAt(p);f=Math.min(f,n.docView.posFromDOM(h.startContainer,h.startOffset,1)),d=Math.max(d,n.docView.posFromDOM(h.endContainer,h.endOffset,-1))}if(f<0)return null;[a,i]=d==n.state.selection.anchor?[d,f]:[f,d],l=r.resolve(i)}else a=n.docView.posFromDOM(t.anchorNode,t.anchorOffset,1);if(a<0)return null}let u=r.resolve(a);if(!c){let f=e=="pointer"||n.state.selection.head<l.pos&&!s?1:-1;c=Uo(n,u,l,f)}return c}function Ql(n){return n.editable?n.hasFocus():sa(n)&&document.activeElement&&document.activeElement.contains(n.dom)}function et(n,e=!1){let t=n.state.selection;if(na(n,t),!!Ql(n)){if(!e&&n.input.mouseDown&&n.input.mouseDown.allowDefault&&ie){let r=n.domSelectionRange(),o=n.domObserver.currentSelection;if(r.anchorNode&&o.anchorNode&&Vt(r.anchorNode,r.anchorOffset,o.anchorNode,o.anchorOffset)){n.input.mouseDown.delayedSelectionSync=!0,n.domObserver.setCurSelection();return}}if(n.domObserver.disconnectSelection(),n.cursorWrapper)Ah(n);else{let{anchor:r,head:o}=t,s,i;Zl&&!(t instanceof V)&&(t.$from.parent.inlineContent||(s=ea(n,t.from)),!t.empty&&!t.$from.parent.inlineContent&&(i=ea(n,t.to))),n.docView.setSelection(r,o,n,e),Zl&&(s&&ta(s),i&&ta(i)),t.visible?n.dom.classList.remove("ProseMirror-hideselection"):(n.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&Th(n))}n.domObserver.setCurSelection(),n.domObserver.connectSelection()}}const Zl=ue||ie&&Al<63;function ea(n,e){let{node:t,offset:r}=n.docView.domFromPos(e,0),o=r<t.childNodes.length?t.childNodes[r]:null,s=r?t.childNodes[r-1]:null;if(ue&&o&&o.contentEditable=="false")return Xo(o);if((!o||o.contentEditable=="false")&&(!s||s.contentEditable=="false")){if(o)return Xo(o);if(s)return Xo(s)}}function Xo(n){return n.contentEditable="true",ue&&n.draggable&&(n.draggable=!1,n.wasDraggable=!0),n}function ta(n){n.contentEditable="false",n.wasDraggable&&(n.draggable=!0,n.wasDraggable=null)}function Th(n){let e=n.dom.ownerDocument;e.removeEventListener("selectionchange",n.input.hideSelectionGuard);let t=n.domSelectionRange(),r=t.anchorNode,o=t.anchorOffset;e.addEventListener("selectionchange",n.input.hideSelectionGuard=()=>{(t.anchorNode!=r||t.anchorOffset!=o)&&(e.removeEventListener("selectionchange",n.input.hideSelectionGuard),setTimeout(()=>{(!Ql(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function Ah(n){let e=n.domSelection(),t=document.createRange();if(!e)return;let r=n.cursorWrapper.dom,o=r.nodeName=="IMG";o?t.setStart(r.parentNode,ne(r)+1):t.setStart(r,0),t.collapse(!0),e.removeAllRanges(),e.addRange(t),!o&&!n.state.selection.visible&&ye&&dt<=11&&(r.disabled=!0,r.disabled=!1)}function na(n,e){if(e instanceof v){let t=n.docView.descAt(e.from);t!=n.lastSelectedViewDesc&&(ra(n),t&&t.selectNode(),n.lastSelectedViewDesc=t)}else ra(n)}function ra(n){n.lastSelectedViewDesc&&(n.lastSelectedViewDesc.parent&&n.lastSelectedViewDesc.deselectNode(),n.lastSelectedViewDesc=void 0)}function Uo(n,e,t,r){return n.someProp("createSelectionBetween",o=>o(n,e,t))||V.between(e,t,r)}function oa(n){return n.editable&&!n.hasFocus()?!1:sa(n)}function sa(n){let e=n.domSelectionRange();if(!e.anchorNode)return!1;try{return n.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(n.editable||n.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function Ph(n){let e=n.docView.domFromPos(n.state.selection.anchor,0),t=n.domSelectionRange();return Vt(e.node,e.offset,t.anchorNode,t.anchorOffset)}function Qo(n,e){let{$anchor:t,$head:r}=n.selection,o=e>0?t.max(r):t.min(r),s=o.parent.inlineContent?o.depth?n.doc.resolve(e>0?o.after():o.before()):null:o;return s&&R.findFrom(s,e)}function pt(n,e){return n.dispatch(n.state.tr.setSelection(e).scrollIntoView()),!0}function ia(n,e,t){let r=n.state.selection;if(r instanceof V)if(t.indexOf("s")>-1){let{$head:o}=r,s=o.textOffset?null:e<0?o.nodeBefore:o.nodeAfter;if(!s||s.isText||!s.isLeaf)return!1;let i=n.state.doc.resolve(o.pos+s.nodeSize*(e<0?-1:1));return pt(n,new V(r.$anchor,i))}else if(r.empty){if(n.endOfTextblock(e>0?"forward":"backward")){let o=Qo(n.state,e);return o&&o instanceof v?pt(n,o):!1}else if(!(Ne&&t.indexOf("m")>-1)){let o=r.$head,s=o.textOffset?null:e<0?o.nodeBefore:o.nodeAfter,i;if(!s||s.isText)return!1;let l=e<0?o.pos-s.nodeSize:o.pos;return s.isAtom||(i=n.docView.descAt(l))&&!i.contentDOM?v.isSelectable(s)?pt(n,new v(e<0?n.state.doc.resolve(o.pos-s.nodeSize):o)):Rn?pt(n,new V(n.state.doc.resolve(e<0?l:l+s.nodeSize))):!1:!1}}else return!1;else{if(r instanceof v&&r.node.isInline)return pt(n,new V(e>0?r.$to:r.$from));{let o=Qo(n.state,e);return o?pt(n,o):!1}}}function Ir(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Bn(n,e){let t=n.pmViewDesc;return t&&t.size==0&&(e<0||n.nextSibling||n.nodeName!="BR")}function cn(n,e){return e<0?Ih(n):Vh(n)}function Ih(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let o,s,i=!1;for(Ie&&t.nodeType==1&&r<Ir(t)&&Bn(t.childNodes[r],-1)&&(i=!0);;)if(r>0){if(t.nodeType!=1)break;{let l=t.childNodes[r-1];if(Bn(l,-1))o=t,s=--r;else if(l.nodeType==3)t=l,r=t.nodeValue.length;else break}}else{if(la(t))break;{let l=t.previousSibling;for(;l&&Bn(l,-1);)o=t.parentNode,s=ne(l),l=l.previousSibling;if(l)t=l,r=Ir(t);else{if(t=t.parentNode,t==n.dom)break;r=0}}}i?Zo(n,t,r):o&&Zo(n,o,s)}function Vh(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let o=Ir(t),s,i;for(;;)if(r<o){if(t.nodeType!=1)break;let l=t.childNodes[r];if(Bn(l,1))s=t,i=++r;else break}else{if(la(t))break;{let l=t.nextSibling;for(;l&&Bn(l,1);)s=l.parentNode,i=ne(l)+1,l=l.nextSibling;if(l)t=l,r=0,o=Ir(t);else{if(t=t.parentNode,t==n.dom)break;r=o=0}}}s&&Zo(n,s,i)}function la(n){let e=n.pmViewDesc;return e&&e.node&&e.node.isBlock}function Rh(n,e){for(;n&&e==n.childNodes.length&&!Vn(n);)e=ne(n)+1,n=n.parentNode;for(;n&&e<n.childNodes.length;){let t=n.childNodes[e];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;n=t,e=0}}function zh(n,e){for(;n&&!e&&!Vn(n);)e=ne(n),n=n.parentNode;for(;n&&e;){let t=n.childNodes[e-1];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;n=t,e=n.childNodes.length}}function Zo(n,e,t){if(e.nodeType!=3){let s,i;(i=Rh(e,t))?(e=i,t=0):(s=zh(e,t))&&(e=s,t=s.nodeValue.length)}let r=n.domSelection();if(!r)return;if(Tr(r)){let s=document.createRange();s.setEnd(e,t),s.setStart(e,t),r.removeAllRanges(),r.addRange(s)}else r.extend&&r.extend(e,t);n.domObserver.setCurSelection();let{state:o}=n;setTimeout(()=>{n.state==o&&et(n)},50)}function aa(n,e){let t=n.state.doc.resolve(e);if(!(ie||oh)&&t.parent.inlineContent){let o=n.coordsAtPos(e);if(e>t.start()){let s=n.coordsAtPos(e-1),i=(s.top+s.bottom)/2;if(i>o.top&&i<o.bottom&&Math.abs(s.left-o.left)>1)return s.left<o.left?"ltr":"rtl"}if(e<t.end()){let s=n.coordsAtPos(e+1),i=(s.top+s.bottom)/2;if(i>o.top&&i<o.bottom&&Math.abs(s.left-o.left)>1)return s.left>o.left?"ltr":"rtl"}}return getComputedStyle(n.dom).direction=="rtl"?"rtl":"ltr"}function ca(n,e,t){let r=n.state.selection;if(r instanceof V&&!r.empty||t.indexOf("s")>-1||Ne&&t.indexOf("m")>-1)return!1;let{$from:o,$to:s}=r;if(!o.parent.inlineContent||n.endOfTextblock(e<0?"up":"down")){let i=Qo(n.state,e);if(i&&i instanceof v)return pt(n,i)}if(!o.parent.inlineContent){let i=e<0?o:s,l=r instanceof ge?R.near(i,e):R.findFrom(i,e);return l?pt(n,l):!1}return!1}function ua(n,e){if(!(n.state.selection instanceof V))return!0;let{$head:t,$anchor:r,empty:o}=n.state.selection;if(!t.sameParent(r))return!0;if(!o)return!1;if(n.endOfTextblock(e>0?"forward":"backward"))return!0;let s=!t.textOffset&&(e<0?t.nodeBefore:t.nodeAfter);if(s&&!s.isText){let i=n.state.tr;return e<0?i.delete(t.pos-s.nodeSize,t.pos):i.delete(t.pos,t.pos+s.nodeSize),n.dispatch(i),!0}return!1}function fa(n,e,t){n.domObserver.stop(),e.contentEditable=t,n.domObserver.start()}function $h(n){if(!ue||n.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:t}=n.domSelectionRange();if(e&&e.nodeType==1&&t==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let r=e.firstChild;fa(n,r,"true"),setTimeout(()=>fa(n,r,"false"),20)}return!1}function jh(n){let e="";return n.ctrlKey&&(e+="c"),n.metaKey&&(e+="m"),n.altKey&&(e+="a"),n.shiftKey&&(e+="s"),e}function Bh(n,e){let t=e.keyCode,r=jh(e);if(t==8||Ne&&t==72&&r=="c")return ua(n,-1)||cn(n,-1);if(t==46&&!e.shiftKey||Ne&&t==68&&r=="c")return ua(n,1)||cn(n,1);if(t==13||t==27)return!0;if(t==37||Ne&&t==66&&r=="c"){let o=t==37?aa(n,n.state.selection.from)=="ltr"?-1:1:-1;return ia(n,o,r)||cn(n,o)}else if(t==39||Ne&&t==70&&r=="c"){let o=t==39?aa(n,n.state.selection.from)=="ltr"?1:-1:1;return ia(n,o,r)||cn(n,o)}else{if(t==38||Ne&&t==80&&r=="c")return ca(n,-1,r)||cn(n,-1);if(t==40||Ne&&t==78&&r=="c")return $h(n)||ca(n,1,r)||cn(n,1);if(r==(Ne?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function da(n,e){n.someProp("transformCopied",p=>{e=p(e,n)});let t=[],{content:r,openStart:o,openEnd:s}=e;for(;o>1&&s>1&&r.childCount==1&&r.firstChild.childCount==1;){o--,s--;let p=r.firstChild;t.push(p.type.name,p.attrs!=p.type.defaultAttrs?p.attrs:null),r=p.content}let i=n.someProp("clipboardSerializer")||$e.fromSchema(n.state.schema),l=ka(),a=l.createElement("div");a.appendChild(i.serializeFragment(r,{document:l}));let c=a.firstChild,u,f=0;for(;c&&c.nodeType==1&&(u=ba[c.nodeName.toLowerCase()]);){for(let p=u.length-1;p>=0;p--){let h=l.createElement(u[p]);for(;a.firstChild;)h.appendChild(a.firstChild);a.appendChild(h),f++}c=a.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${o} ${s}${f?` -${f}`:""} ${JSON.stringify(t)}`);let d=n.someProp("clipboardTextSerializer",p=>p(e,n))||e.content.textBetween(0,e.content.size,`
|
|
39
39
|
|
|
40
40
|
`);return{dom:a,text:d,slice:e}}function ha(n,e,t,r,o){let s=o.parent.type.spec.code,i,l;if(!t&&!e)return null;let a=e&&(r||s||!t);if(a){if(n.someProp("transformPastedText",d=>{e=d(e,s||r,n)}),s)return e?new E(C.from(n.state.schema.text(e.replace(/\r\n?/g,`
|
|
41
|
-
`))),0,0):E.empty;let f=n.someProp("clipboardTextParser",d=>d(e,o,r,n));if(f)l=f;else{let d=o.marks(),{schema:p}=n.state,h=$e.fromSchema(p);i=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(b=>{let g=i.appendChild(document.createElement("p"));b&&g.appendChild(h.serializeNode(p.text(b,d)))})}}else n.someProp("transformPastedHTML",f=>{t=f(t,n)}),i=_h(t),Rn&&qh(i);let c=i&&i.querySelector("[data-pm-slice]"),u=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(u&&u[3])for(let f=+u[3];f>0;f--){let d=i.firstChild;for(;d&&d.nodeType!=1;)d=d.nextSibling;if(!d)break;i=d}if(l||(l=(n.someProp("clipboardParser")||n.someProp("domParser")||Pt.fromSchema(n.state.schema)).parseSlice(i,{preserveWhitespace:!!(a||u),context:o,ruleFromNode(d){return d.nodeName=="BR"&&!d.nextSibling&&d.parentNode&&!Fh.test(d.parentNode.nodeName)?{ignore:!0}:null}})),u)l=Hh(ya(l,+u[1],+u[2]),u[4]);else if(l=E.maxOpen(Lh(l.content,o),!0),l.openStart||l.openEnd){let f=0,d=0;for(let p=l.content.firstChild;f<l.openStart&&!p.type.spec.isolating;f++,p=p.firstChild);for(let p=l.content.lastChild;d<l.openEnd&&!p.type.spec.isolating;d++,p=p.lastChild);l=ya(l,f,d)}return n.someProp("transformPasted",f=>{l=f(l,n)}),l}const Fh=/^(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 Lh(n,e){if(n.childCount<2)return n;for(let t=e.depth;t>=0;t--){let o=e.node(t).contentMatchAt(e.index(t)),s,i=[];if(n.forEach(l=>{if(!i)return;let a=o.findWrapping(l.type),c;if(!a)return i=null;if(c=i.length&&s.length&&ma(a,s,l,i[i.length-1],0))i[i.length-1]=c;else{i.length&&(i[i.length-1]=ga(i[i.length-1],s.length));let u=pa(l,a);i.push(u),o=o.matchType(u.type),s=a}}),i)return C.from(i)}return n}function pa(n,e,t=0){for(let r=e.length-1;r>=t;r--)n=e[r].create(null,C.from(n));return n}function ma(n,e,t,r,o){if(o<n.length&&o<e.length&&n[o]==e[o]){let s=ma(n,e,t,r.lastChild,o+1);if(s)return r.copy(r.content.replaceChild(r.childCount-1,s));if(r.contentMatchAt(r.childCount).matchType(o==n.length-1?t.type:n[o+1]))return r.copy(r.content.append(C.from(pa(t,n,o+1))))}}function ga(n,e){if(e==0)return n;let t=n.content.replaceChild(n.childCount-1,ga(n.lastChild,e-1)),r=n.contentMatchAt(n.childCount).fillBefore(C.empty,!0);return n.copy(t.append(r))}function es(n,e,t,r,o,s){let i=e<0?n.firstChild:n.lastChild,l=i.content;return n.childCount>1&&(s=0),o<r-1&&(l=es(l,e,t,r,o+1,s)),o>=t&&(l=e<0?i.contentMatchAt(0).fillBefore(l,s<=o).append(l):l.append(i.contentMatchAt(i.childCount).fillBefore(C.empty,!0))),n.replaceChild(e<0?0:n.childCount-1,i.copy(l))}function ya(n,e,t){return e<n.openStart&&(n=new E(es(n.content,-1,e,n.openStart,0,n.openEnd),e,n.openEnd)),t<n.openEnd&&(n=new E(es(n.content,1,t,n.openEnd,0,0),n.openStart,t)),n}const ba={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};let xa=null;function ka(){return xa||(xa=document.implementation.createHTMLDocument("title"))}let ts=null;function Wh(n){let e=window.trustedTypes;return e?(ts||(ts=e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})),ts.createHTML(n)):n}function _h(n){let e=/^(\s*<meta [^>]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=ka().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(n),o;if((o=r&&ba[r[1].toLowerCase()])&&(n=o.map(s=>"<"+s+">").join("")+n+o.map(s=>"</"+s+">").reverse().join("")),t.innerHTML=Wh(n),o)for(let s=0;s<o.length;s++)t=t.querySelector(o[s])||t;return t}function qh(n){let e=n.querySelectorAll(ie?"span:not([class]):not([style])":"span.Apple-converted-space");for(let t=0;t<e.length;t++){let r=e[t];r.childNodes.length==1&&r.textContent==" "&&r.parentNode&&r.parentNode.replaceChild(n.ownerDocument.createTextNode(" "),r)}}function Hh(n,e){if(!n.size)return n;let t=n.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return n}let{content:o,openStart:s,openEnd:i}=n;for(let l=r.length-2;l>=0;l-=2){let a=t.nodes[r[l]];if(!a||a.hasRequiredAttrs())break;o=C.from(a.create(r[l+1],o)),s++,i++}return new E(o,s,i)}const fe={},de={},Kh={touchstart:!0,touchmove:!0};class Jh{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:""},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function Yh(n){for(let e in fe){let t=fe[e];n.dom.addEventListener(e,n.input.eventHandlers[e]=r=>{Xh(n,r)&&!rs(n,r)&&(n.editable||!(r.type in de))&&t(n,r)},Kh[e]?{passive:!0}:void 0)}ue&&n.dom.addEventListener("input",()=>null),ns(n)}function mt(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}function Gh(n){n.domObserver.stop();for(let e in n.input.eventHandlers)n.dom.removeEventListener(e,n.input.eventHandlers[e]);clearTimeout(n.input.composingTimeout),clearTimeout(n.input.lastIOSEnterFallbackTimeout)}function ns(n){n.someProp("handleDOMEvents",e=>{for(let t in e)n.input.eventHandlers[t]||n.dom.addEventListener(t,n.input.eventHandlers[t]=r=>rs(n,r))})}function rs(n,e){return n.someProp("handleDOMEvents",t=>{let r=t[e.type];return r?r(n,e)||e.defaultPrevented:!1})}function Xh(n,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target;t!=n.dom;t=t.parentNode)if(!t||t.nodeType==11||t.pmViewDesc&&t.pmViewDesc.stopEvent(e))return!1;return!0}function Uh(n,e){!rs(n,e)&&fe[e.type]&&(n.editable||!(e.type in de))&&fe[e.type](n,e)}de.keydown=(n,e)=>{let t=e;if(n.input.shiftKey=t.keyCode==16||t.shiftKey,!Ca(n,t)&&(n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),!(Qe&&ie&&t.keyCode==13)))if(t.keyCode!=229&&n.domObserver.forceFlush(),sn&&t.keyCode==13&&!t.ctrlKey&&!t.altKey&&!t.metaKey){let r=Date.now();n.input.lastIOSEnter=r,n.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{n.input.lastIOSEnter==r&&(n.someProp("handleKeyDown",o=>o(n,Rt(13,"Enter"))),n.input.lastIOSEnter=0)},200)}else n.someProp("handleKeyDown",r=>r(n,t))||Bh(n,t)?t.preventDefault():mt(n,"key")},de.keyup=(n,e)=>{e.keyCode==16&&(n.input.shiftKey=!1)},de.keypress=(n,e)=>{let t=e;if(Ca(n,t)||!t.charCode||t.ctrlKey&&!t.altKey||Ne&&t.metaKey)return;if(n.someProp("handleKeyPress",o=>o(n,t))){t.preventDefault();return}let r=n.state.selection;if(!(r instanceof V)||!r.$from.sameParent(r.$to)){let o=String.fromCharCode(t.charCode);!/[\r\n]/.test(o)&&!n.someProp("handleTextInput",s=>s(n,r.$from.pos,r.$to.pos,o))&&n.dispatch(n.state.tr.insertText(o).scrollIntoView()),t.preventDefault()}};function Vr(n){return{left:n.clientX,top:n.clientY}}function Qh(n,e){let t=e.x-n.clientX,r=e.y-n.clientY;return t*t+r*r<100}function ss(n,e,t,r,o){if(r==-1)return!1;let s=n.state.doc.resolve(r);for(let i=s.depth+1;i>0;i--)if(n.someProp(e,l=>i>s.depth?l(n,t,s.nodeAfter,s.before(i),o,!0):l(n,t,s.node(i),s.before(i),o,!1)))return!0;return!1}function un(n,e,t){if(n.focused||n.focus(),n.state.selection.eq(e))return;let r=n.state.tr.setSelection(e);r.setMeta("pointer",!0),n.dispatch(r)}function Zh(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),r=t.nodeAfter;return r&&r.isAtom&&O.isSelectable(r)?(un(n,new O(t)),!0):!1}function ep(n,e){if(e==-1)return!1;let t=n.state.selection,r,o;t instanceof O&&(r=t.node);let s=n.state.doc.resolve(e);for(let i=s.depth+1;i>0;i--){let l=i>s.depth?s.nodeAfter:s.node(i);if(O.isSelectable(l)){r&&t.$from.depth>0&&i>=t.$from.depth&&s.before(t.$from.depth+1)==t.$from.pos?o=s.before(t.$from.depth):o=s.before(i);break}}return o!=null?(un(n,O.create(n.state.doc,o)),!0):!1}function tp(n,e,t,r,o){return ss(n,"handleClickOn",e,t,r)||n.someProp("handleClick",s=>s(n,e,r))||(o?ep(n,t):Zh(n,t))}function np(n,e,t,r){return ss(n,"handleDoubleClickOn",e,t,r)||n.someProp("handleDoubleClick",o=>o(n,e,r))}function rp(n,e,t,r){return ss(n,"handleTripleClickOn",e,t,r)||n.someProp("handleTripleClick",o=>o(n,e,r))||op(n,t,r)}function op(n,e,t){if(t.button!=0)return!1;let r=n.state.doc;if(e==-1)return r.inlineContent?(un(n,V.create(r,0,r.content.size)),!0):!1;let o=r.resolve(e);for(let s=o.depth+1;s>0;s--){let i=s>o.depth?o.nodeAfter:o.node(s),l=o.before(s);if(i.inlineContent)un(n,V.create(r,l+1,l+1+i.content.size));else if(O.isSelectable(i))un(n,O.create(r,l));else continue;return!0}}function is(n){return Rr(n)}const Sa=Ne?"metaKey":"ctrlKey";fe.mousedown=(n,e)=>{let t=e;n.input.shiftKey=t.shiftKey;let r=is(n),o=Date.now(),s="singleClick";o-n.input.lastClick.time<500&&Qh(t,n.input.lastClick)&&!t[Sa]&&(n.input.lastClick.type=="singleClick"?s="doubleClick":n.input.lastClick.type=="doubleClick"&&(s="tripleClick")),n.input.lastClick={time:o,x:t.clientX,y:t.clientY,type:s};let i=n.posAtCoords(Vr(t));i&&(s=="singleClick"?(n.input.mouseDown&&n.input.mouseDown.done(),n.input.mouseDown=new sp(n,i,t,!!r)):(s=="doubleClick"?np:rp)(n,i.pos,i.inside,t)?t.preventDefault():mt(n,"pointer"))};let sp=class{constructor(e,t,r,o){this.view=e,this.pos=t,this.event=r,this.flushed=o,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!r[Sa],this.allowDefault=r.shiftKey;let s,i;if(t.inside>-1)s=e.state.doc.nodeAt(t.inside),i=t.inside;else{let u=e.state.doc.resolve(t.pos);s=u.parent,i=u.depth?u.before():0}const l=o?null:r.target,a=l?e.docView.nearestDesc(l,!0):null;this.target=a&&a.dom.nodeType==1?a.dom:null;let{selection:c}=e.state;(r.button==0&&s.type.spec.draggable&&s.type.spec.selectable!==!1||c instanceof O&&c.from<=i&&c.to>i)&&(this.mightDrag={node:s,pos:i,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Ie&&!this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this)),mt(e,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>et(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(Vr(e))),this.updateAllowDefault(e),this.allowDefault||!t?mt(this.view,"pointer"):tp(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||ue&&this.mightDrag&&!this.mightDrag.node.isAtom||ie&&!this.view.state.selection.visible&&Math.min(Math.abs(t.pos-this.view.state.selection.from),Math.abs(t.pos-this.view.state.selection.to))<=2)?(un(this.view,R.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):mt(this.view,"pointer")}move(e){this.updateAllowDefault(e),mt(this.view,"pointer"),e.buttons==0&&this.done()}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}};fe.touchstart=n=>{n.input.lastTouch=Date.now(),is(n),mt(n,"pointer")},fe.touchmove=n=>{n.input.lastTouch=Date.now(),mt(n,"pointer")},fe.contextmenu=n=>is(n);function Ca(n,e){return n.composing?!0:ue&&Math.abs(e.timeStamp-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}const ip=Qe?5e3:-1;de.compositionstart=de.compositionupdate=n=>{if(!n.composing){n.domObserver.flush();let{state:e}=n,t=e.selection.$to;if(e.selection instanceof V&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)))n.markCursor=n.state.storedMarks||t.marks(),Rr(n,!0),n.markCursor=null;else if(Rr(n,!e.selection.empty),Ie&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length){let r=n.domSelectionRange();for(let o=r.focusNode,s=r.focusOffset;o&&o.nodeType==1&&s!=0;){let i=s<0?o.lastChild:o.childNodes[s-1];if(!i)break;if(i.nodeType==3){let l=n.domSelection();l&&l.collapse(i,i.nodeValue.length);break}else o=i,s=-1}}n.input.composing=!0}wa(n,ip)},de.compositionend=(n,e)=>{n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=e.timeStamp,n.input.compositionPendingChanges=n.domObserver.pendingRecords().length?n.input.compositionID:0,n.input.compositionNode=null,n.input.compositionPendingChanges&&Promise.resolve().then(()=>n.domObserver.flush()),n.input.compositionID++,wa(n,20))};function wa(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>Rr(n),e))}function Ma(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=ap());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function lp(n){let e=n.domSelectionRange();if(!e.focusNode)return null;let t=Zd(e.focusNode,e.focusOffset),r=eh(e.focusNode,e.focusOffset);if(t&&r&&t!=r){let o=r.pmViewDesc,s=n.domObserver.lastChangedTextNode;if(t==s||r==s)return s;if(!o||!o.isText(r.nodeValue))return r;if(n.input.compositionNode==r){let i=t.pmViewDesc;if(!(!i||!i.isText(t.nodeValue)))return r}}return t||r}function ap(){let n=document.createEvent("Event");return n.initEvent("event",!0,!0),n.timeStamp}function Rr(n,e=!1){if(!(Qe&&n.domObserver.flushingSoon>=0)){if(n.domObserver.forceFlush(),Ma(n),e||n.docView&&n.docView.dirty){let t=Go(n);return t&&!t.eq(n.state.selection)?n.dispatch(n.state.tr.setSelection(t)):(n.markCursor||e)&&!n.state.selection.empty?n.dispatch(n.state.tr.deleteSelection()):n.updateState(n.state),!0}return!1}}function cp(n,e){if(!n.dom.parentNode)return;let t=n.dom.parentNode.appendChild(document.createElement("div"));t.appendChild(e),t.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),o=document.createRange();o.selectNodeContents(e),n.dom.blur(),r.removeAllRanges(),r.addRange(o),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t),n.focus()},50)}const Fn=ye&&dt<15||sn&&sh<604;fe.copy=de.cut=(n,e)=>{let t=e,r=n.state.selection,o=t.type=="cut";if(r.empty)return;let s=Fn?null:t.clipboardData,i=r.content(),{dom:l,text:a}=da(n,i);s?(t.preventDefault(),s.clearData(),s.setData("text/html",l.innerHTML),s.setData("text/plain",a)):cp(n,l),o&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function up(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function fp(n,e){if(!n.dom.parentNode)return;let t=n.input.shiftKey||n.state.selection.$from.parent.type.spec.code,r=n.dom.parentNode.appendChild(document.createElement(t?"textarea":"div"));t||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let o=n.input.shiftKey&&n.input.lastKeyCode!=45;setTimeout(()=>{n.focus(),r.parentNode&&r.parentNode.removeChild(r),t?Ln(n,r.value,null,o,e):Ln(n,r.textContent,r.innerHTML,o,e)},50)}function Ln(n,e,t,r,o){let s=ha(n,e,t,r,n.state.selection.$from);if(n.someProp("handlePaste",a=>a(n,o,s||E.empty)))return!0;if(!s)return!1;let i=up(s),l=i?n.state.tr.replaceSelectionWith(i,r):n.state.tr.replaceSelection(s);return n.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Na(n){let e=n.getData("text/plain")||n.getData("Text");if(e)return e;let t=n.getData("text/uri-list");return t?t.replace(/\r?\n/g," "):""}de.paste=(n,e)=>{let t=e;if(n.composing&&!Qe)return;let r=Fn?null:t.clipboardData,o=n.input.shiftKey&&n.input.lastKeyCode!=45;r&&Ln(n,Na(r),r.getData("text/html"),o,t)?t.preventDefault():fp(n,t)};let Ea=class{constructor(e,t,r){this.slice=e,this.move=t,this.node=r}};const Da=Ne?"altKey":"ctrlKey";fe.dragstart=(n,e)=>{let t=e,r=n.input.mouseDown;if(r&&r.done(),!t.dataTransfer)return;let o=n.state.selection,s=o.empty?null:n.posAtCoords(Vr(t)),i;if(!(s&&s.pos>=o.from&&s.pos<=(o instanceof O?o.to-1:o.to))){if(r&&r.mightDrag)i=O.create(n.state.doc,r.mightDrag.pos);else if(t.target&&t.target.nodeType==1){let f=n.docView.nearestDesc(t.target,!0);f&&f.node.type.spec.draggable&&f!=n.docView&&(i=O.create(n.state.doc,f.posBefore))}}let l=(i||n.state.selection).content(),{dom:a,text:c,slice:u}=da(n,l);(!t.dataTransfer.files.length||!ie||Al>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(Fn?"Text":"text/html",a.innerHTML),t.dataTransfer.effectAllowed="copyMove",Fn||t.dataTransfer.setData("text/plain",c),n.dragging=new Ea(u,!t[Da],i)},fe.dragend=n=>{let e=n.dragging;window.setTimeout(()=>{n.dragging==e&&(n.dragging=null)},50)},de.dragover=de.dragenter=(n,e)=>e.preventDefault(),de.drop=(n,e)=>{let t=e,r=n.dragging;if(n.dragging=null,!t.dataTransfer)return;let o=n.posAtCoords(Vr(t));if(!o)return;let s=n.state.doc.resolve(o.pos),i=r&&r.slice;i?n.someProp("transformPasted",h=>{i=h(i,n)}):i=ha(n,Na(t.dataTransfer),Fn?null:t.dataTransfer.getData("text/html"),!1,s);let l=!!(r&&!t[Da]);if(n.someProp("handleDrop",h=>h(n,t,i||E.empty,l))){t.preventDefault();return}if(!i)return;t.preventDefault();let a=i?Co(n.state.doc,s.pos,i):s.pos;a==null&&(a=s.pos);let c=n.state.tr;if(l){let{node:h}=r;h?h.replace(c):c.deleteSelection()}let u=c.mapping.map(a),f=i.openStart==0&&i.openEnd==0&&i.content.childCount==1,d=c.doc;if(f?c.replaceRangeWith(u,u,i.content.firstChild):c.replaceRange(u,u,i),c.doc.eq(d))return;let p=c.doc.resolve(u);if(f&&O.isSelectable(i.content.firstChild)&&p.nodeAfter&&p.nodeAfter.sameMarkup(i.content.firstChild))c.setSelection(new O(p));else{let h=c.mapping.map(a);c.mapping.maps[c.mapping.maps.length-1].forEach((b,g,x,S)=>h=S),c.setSelection(Uo(n,p,c.doc.resolve(h)))}n.focus(),n.dispatch(c.setMeta("uiEvent","drop"))},fe.focus=n=>{n.input.lastFocus=Date.now(),n.focused||(n.domObserver.stop(),n.dom.classList.add("ProseMirror-focused"),n.domObserver.start(),n.focused=!0,setTimeout(()=>{n.docView&&n.hasFocus()&&!n.domObserver.currentSelection.eq(n.domSelectionRange())&&et(n)},20))},fe.blur=(n,e)=>{let t=e;n.focused&&(n.domObserver.stop(),n.dom.classList.remove("ProseMirror-focused"),n.domObserver.start(),t.relatedTarget&&n.dom.contains(t.relatedTarget)&&n.domObserver.currentSelection.clear(),n.focused=!1)},fe.beforeinput=(n,e)=>{if(ie&&Qe&&e.inputType=="deleteContentBackward"){n.domObserver.flushSoon();let{domChangeCount:r}=n.input;setTimeout(()=>{if(n.input.domChangeCount!=r||(n.dom.blur(),n.focus(),n.someProp("handleKeyDown",s=>s(n,Rt(8,"Backspace")))))return;let{$cursor:o}=n.state.selection;o&&o.pos>0&&n.dispatch(n.state.tr.delete(o.pos-1,o.pos).scrollIntoView())},50)}};for(let n in de)fe[n]=de[n];function Wn(n,e){if(n==e)return!0;for(let t in n)if(n[t]!==e[t])return!1;for(let t in e)if(!(t in n))return!1;return!0}let Oa=class mf{constructor(e,t){this.toDOM=e,this.spec=t||jt,this.side=this.spec.side||0}map(e,t,r,o){let{pos:s,deleted:i}=e.mapResult(t.from+o,this.side<0?-1:1);return i?null:new Ve(s-r,s-r,this)}valid(){return!0}eq(e){return this==e||e instanceof mf&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Wn(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}},_n=class fi{constructor(e,t){this.attrs=e,this.spec=t||jt}map(e,t,r,o){let s=e.map(t.from+o,this.spec.inclusiveStart?-1:1)-r,i=e.map(t.to+o,this.spec.inclusiveEnd?1:-1)-r;return s>=i?null:new Ve(s,i,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof fi&&Wn(this.attrs,e.attrs)&&Wn(this.spec,e.spec)}static is(e){return e.type instanceof fi}destroy(){}},dp=class gf{constructor(e,t){this.attrs=e,this.spec=t||jt}map(e,t,r,o){let s=e.mapResult(t.from+o,1);if(s.deleted)return null;let i=e.mapResult(t.to+o,-1);return i.deleted||i.pos<=s.pos?null:new Ve(s.pos-r,i.pos-r,this)}valid(e,t){let{index:r,offset:o}=e.content.findIndex(t.from),s;return o==t.from&&!(s=e.child(r)).isText&&o+s.nodeSize==t.to}eq(e){return this==e||e instanceof gf&&Wn(this.attrs,e.attrs)&&Wn(this.spec,e.spec)}destroy(){}},Ve=class fr{constructor(e,t,r){this.from=e,this.to=t,this.type=r}copy(e,t){return new fr(e,t,this.type)}eq(e,t=0){return this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to}map(e,t,r){return this.type.map(e,this,t,r)}static widget(e,t,r){return new fr(e,e,new Oa(t,r))}static inline(e,t,r,o){return new fr(e,t,new _n(r,o))}static node(e,t,r,o){return new fr(e,t,new dp(r,o))}get spec(){return this.type.spec}get inline(){return this.type instanceof _n}get widget(){return this.type instanceof Oa}};const fn=[],jt={};let H=class Ot{constructor(e,t){this.local=e.length?e:fn,this.children=t.length?t:fn}static create(e,t){return t.length?zr(t,e,0,jt):le}find(e,t,r){let o=[];return this.findInner(e??0,t??1e9,o,0,r),o}findInner(e,t,r,o,s){for(let i=0;i<this.local.length;i++){let l=this.local[i];l.from<=t&&l.to>=e&&(!s||s(l.spec))&&r.push(l.copy(l.from+o,l.to+o))}for(let i=0;i<this.children.length;i+=3)if(this.children[i]<t&&this.children[i+1]>e){let l=this.children[i]+1;this.children[i+2].findInner(e-l,t-l,r,o+l,s)}}map(e,t,r){return this==le||e.maps.length==0?this:this.mapInner(e,t,0,0,r||jt)}mapInner(e,t,r,o,s){let i;for(let l=0;l<this.local.length;l++){let a=this.local[l].map(e,r,o);a&&a.type.valid(t,a)?(i||(i=[])).push(a):s.onRemove&&s.onRemove(this.local[l].spec)}return this.children.length?hp(this.children,i||[],e,t,r,o,s):i?new Ot(i.sort(Bt),fn):le}add(e,t){return t.length?this==le?Ot.create(e,t):this.addInner(e,t,0):this}addInner(e,t,r){let o,s=0;e.forEach((l,a)=>{let c=a+r,u;if(u=Aa(t,l,c)){for(o||(o=this.children.slice());s<o.length&&o[s]<a;)s+=3;o[s]==a?o[s+2]=o[s+2].addInner(l,u,c+1):o.splice(s,0,a,a+l.nodeSize,zr(u,l,c+1,jt)),s+=3}});let i=Ta(s?Pa(t):t,-r);for(let l=0;l<i.length;l++)i[l].type.valid(e,i[l])||i.splice(l--,1);return new Ot(i.length?this.local.concat(i).sort(Bt):this.local,o||this.children)}remove(e){return e.length==0||this==le?this:this.removeInner(e,0)}removeInner(e,t){let r=this.children,o=this.local;for(let s=0;s<r.length;s+=3){let i,l=r[s]+t,a=r[s+1]+t;for(let u=0,f;u<e.length;u++)(f=e[u])&&f.from>l&&f.to<a&&(e[u]=null,(i||(i=[])).push(f));if(!i)continue;r==this.children&&(r=this.children.slice());let c=r[s+2].removeInner(i,l+1);c!=le?r[s+2]=c:(r.splice(s,3),s-=3)}if(o.length){for(let s=0,i;s<e.length;s++)if(i=e[s])for(let l=0;l<o.length;l++)o[l].eq(i,t)&&(o==this.local&&(o=this.local.slice()),o.splice(l--,1))}return r==this.children&&o==this.local?this:o.length||r.length?new Ot(o,r):le}forChild(e,t){if(this==le)return this;if(t.isLeaf)return Ot.empty;let r,o;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=e){this.children[l]==e&&(r=this.children[l+2]);break}let s=e+1,i=s+t.content.size;for(let l=0;l<this.local.length;l++){let a=this.local[l];if(a.from<i&&a.to>s&&a.type instanceof _n){let c=Math.max(s,a.from)-s,u=Math.min(i,a.to)-s;c<u&&(o||(o=[])).push(a.copy(c,u))}}if(o){let l=new Ot(o.sort(Bt),fn);return r?new va([l,r]):l}return r||le}eq(e){if(this==e)return!0;if(!(e instanceof Ot)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let t=0;t<this.local.length;t++)if(!this.local[t].eq(e.local[t]))return!1;for(let t=0;t<this.children.length;t+=3)if(this.children[t]!=e.children[t]||this.children[t+1]!=e.children[t+1]||!this.children[t+2].eq(e.children[t+2]))return!1;return!0}locals(e){return ls(this.localsInner(e))}localsInner(e){if(this==le)return fn;if(e.inlineContent||!this.local.some(_n.is))return this.local;let t=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof _n||t.push(this.local[r]);return t}forEachSet(e){e(this)}};H.empty=new H([],[]),H.removeOverlap=ls;const le=H.empty;let va=class xn{constructor(e){this.members=e}map(e,t){const r=this.members.map(o=>o.map(e,t,jt));return xn.from(r)}forChild(e,t){if(t.isLeaf)return H.empty;let r=[];for(let o=0;o<this.members.length;o++){let s=this.members[o].forChild(e,t);s!=le&&(s instanceof xn?r=r.concat(s.members):r.push(s))}return xn.from(r)}eq(e){if(!(e instanceof xn)||e.members.length!=this.members.length)return!1;for(let t=0;t<this.members.length;t++)if(!this.members[t].eq(e.members[t]))return!1;return!0}locals(e){let t,r=!0;for(let o=0;o<this.members.length;o++){let s=this.members[o].localsInner(e);if(s.length)if(!t)t=s;else{r&&(t=t.slice(),r=!1);for(let i=0;i<s.length;i++)t.push(s[i])}}return t?ls(r?t:t.sort(Bt)):fn}static from(e){switch(e.length){case 0:return le;case 1:return e[0];default:return new xn(e.every(t=>t instanceof H)?e:e.reduce((t,r)=>t.concat(r instanceof H?r:r.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}};function hp(n,e,t,r,o,s,i){let l=n.slice();for(let c=0,u=s;c<t.maps.length;c++){let f=0;t.maps[c].forEach((d,p,h,b)=>{let g=b-h-(p-d);for(let x=0;x<l.length;x+=3){let S=l[x+1];if(S<0||d>S+u-f)continue;let w=l[x]+u-f;p>=w?l[x+1]=d<=w?-2:-1:d>=u&&g&&(l[x]+=g,l[x+1]+=g)}f+=g}),u=t.maps[c].map(u,-1)}let a=!1;for(let c=0;c<l.length;c+=3)if(l[c+1]<0){if(l[c+1]==-2){a=!0,l[c+1]=-1;continue}let u=t.map(n[c]+s),f=u-o;if(f<0||f>=r.content.size){a=!0;continue}let d=t.map(n[c+1]+s,-1),p=d-o,{index:h,offset:b}=r.content.findIndex(f),g=r.maybeChild(h);if(g&&b==f&&b+g.nodeSize==p){let x=l[c+2].mapInner(t,g,u+1,n[c]+s+1,i);x!=le?(l[c]=f,l[c+1]=p,l[c+2]=x):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=pp(l,n,e,t,o,s,i),u=zr(c,r,0,i);e=u.local;for(let f=0;f<l.length;f+=3)l[f+1]<0&&(l.splice(f,3),f-=3);for(let f=0,d=0;f<u.children.length;f+=3){let p=u.children[f];for(;d<l.length&&l[d]<p;)d+=3;l.splice(d,0,u.children[f],u.children[f+1],u.children[f+2])}}return new H(e.sort(Bt),l)}function Ta(n,e){if(!e||!n.length)return n;let t=[];for(let r=0;r<n.length;r++){let o=n[r];t.push(new Ve(o.from+e,o.to+e,o.type))}return t}function pp(n,e,t,r,o,s,i){function l(a,c){for(let u=0;u<a.local.length;u++){let f=a.local[u].map(r,o,c);f?t.push(f):i.onRemove&&i.onRemove(a.local[u].spec)}for(let u=0;u<a.children.length;u+=3)l(a.children[u+2],a.children[u]+c+1)}for(let a=0;a<n.length;a+=3)n[a+1]==-1&&l(n[a+2],e[a]+s+1);return t}function Aa(n,e,t){if(e.isLeaf)return null;let r=t+e.nodeSize,o=null;for(let s=0,i;s<n.length;s++)(i=n[s])&&i.from>t&&i.to<r&&((o||(o=[])).push(i),n[s]=null);return o}function Pa(n){let e=[];for(let t=0;t<n.length;t++)n[t]!=null&&e.push(n[t]);return e}function zr(n,e,t,r){let o=[],s=!1;e.forEach((l,a)=>{let c=Aa(n,l,a+t);if(c){s=!0;let u=zr(c,l,t+a+1,r);u!=le&&o.push(a,a+l.nodeSize,u)}});let i=Ta(s?Pa(n):n,-t).sort(Bt);for(let l=0;l<i.length;l++)i[l].type.valid(e,i[l])||(r.onRemove&&r.onRemove(i[l].spec),i.splice(l--,1));return i.length||o.length?new H(i,o):le}function Bt(n,e){return n.from-e.from||n.to-e.to}function ls(n){let e=n;for(let t=0;t<e.length-1;t++){let r=e[t];if(r.from!=r.to)for(let o=t+1;o<e.length;o++){let s=e[o];if(s.from==r.from){s.to!=r.to&&(e==n&&(e=n.slice()),e[o]=s.copy(s.from,r.to),Ia(e,o+1,s.copy(r.to,s.to)));continue}else{s.from<r.to&&(e==n&&(e=n.slice()),e[t]=r.copy(r.from,s.from),Ia(e,o,r.copy(s.from,r.to)));break}}}return e}function Ia(n,e,t){for(;e<n.length&&Bt(t,n[e])>0;)e++;n.splice(e,0,t)}function as(n){let e=[];return n.someProp("decorations",t=>{let r=t(n.state);r&&r!=le&&e.push(r)}),n.cursorWrapper&&e.push(H.create(n.state.doc,[n.cursorWrapper.deco])),va.from(e)}const mp={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},gp=ye&&dt<=11;let yp=class{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}};class bp{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new yp,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let o=0;o<r.length;o++)this.queue.push(r[o]);ye&&dt<=11&&r.some(o=>o.type=="childList"&&o.removedNodes.length||o.type=="characterData"&&o.oldValue.length>o.target.nodeValue.length)?this.flushSoon():this.flush()}),gp&&(this.onCharData=r=>{this.queue.push({target:r.target,type:"characterData",oldValue:r.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,mp)),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(oa(this.view)){if(this.suppressingSelectionUpdates)return et(this.view);if(ye&&dt<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Vt(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t=new Set,r;for(let s=e.focusNode;s;s=In(s))t.add(s);for(let s=e.anchorNode;s;s=In(s))if(t.has(s)){r=s;break}let o=r&&this.view.docView.nearestDesc(r);if(o&&o.ignoreMutation({type:"selection",target:r.nodeType==3?r.parentNode:r}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.pendingRecords();t.length&&(this.queue=[]);let r=e.domSelectionRange(),o=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&oa(e)&&!this.ignoreSelectionChange(r),s=-1,i=-1,l=!1,a=[];if(e.editable)for(let u=0;u<t.length;u++){let f=this.registerMutation(t[u],a);f&&(s=s<0?f.from:Math.min(f.from,s),i=i<0?f.to:Math.max(f.to,i),f.typeOver&&(l=!0))}if(Ie&&a.length){let u=a.filter(f=>f.nodeName=="BR");if(u.length==2){let[f,d]=u;f.parentNode&&f.parentNode.parentNode==d.parentNode?d.remove():f.remove()}else{let{focusNode:f}=this.currentSelection;for(let d of u){let p=d.parentNode;p&&p.nodeName=="LI"&&(!f||Sp(e,f)!=p)&&d.remove()}}}let c=null;s<0&&o&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&Tr(r)&&(c=Go(e))&&c.eq(R.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,et(e),this.currentSelection.set(r),e.scrollToSelection()):(s>-1||o)&&(s>-1&&(e.docView.markDirty(s,i),xp(e)),this.handleDOMChange(s,i,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||et(e),this.currentSelection.set(r))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let r=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(r==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!r||r.ignoreMutation(e))return null;if(e.type=="childList"){for(let u=0;u<e.addedNodes.length;u++){let f=e.addedNodes[u];t.push(f),f.nodeType==3&&(this.lastChangedTextNode=f)}if(r.contentDOM&&r.contentDOM!=r.dom&&!r.contentDOM.contains(e.target))return{from:r.posBefore,to:r.posAfter};let o=e.previousSibling,s=e.nextSibling;if(ye&&dt<=11&&e.addedNodes.length)for(let u=0;u<e.addedNodes.length;u++){let{previousSibling:f,nextSibling:d}=e.addedNodes[u];(!f||Array.prototype.indexOf.call(e.addedNodes,f)<0)&&(o=f),(!d||Array.prototype.indexOf.call(e.addedNodes,d)<0)&&(s=d)}let i=o&&o.parentNode==e.target?ne(o)+1:0,l=r.localPosFromDOM(e.target,i,-1),a=s&&s.parentNode==e.target?ne(s):e.target.childNodes.length,c=r.localPosFromDOM(e.target,a,1);return{from:l,to:c}}else return e.type=="attributes"?{from:r.posAtStart-r.border,to:r.posAtEnd+r.border}:(this.lastChangedTextNode=e.target,{from:r.posAtStart,to:r.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let Va=new WeakMap,Ra=!1;function xp(n){if(!Va.has(n)&&(Va.set(n,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(n.dom).whiteSpace)!==-1)){if(n.requiresGeckoHackNode=Ie,Ra)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."),Ra=!0}}function za(n,e){let t=e.startContainer,r=e.startOffset,o=e.endContainer,s=e.endOffset,i=n.domAtPos(n.state.selection.anchor);return Vt(i.node,i.offset,o,s)&&([t,r,o,s]=[o,s,t,r]),{anchorNode:t,anchorOffset:r,focusNode:o,focusOffset:s}}function kp(n,e){if(e.getComposedRanges){let o=e.getComposedRanges(n.root)[0];if(o)return za(n,o)}let t;function r(o){o.preventDefault(),o.stopImmediatePropagation(),t=o.getTargetRanges()[0]}return n.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),n.dom.removeEventListener("beforeinput",r,!0),t?za(n,t):null}function Sp(n,e){for(let t=e.parentNode;t&&t!=n.dom;t=t.parentNode){let r=n.docView.nearestDesc(t,!0);if(r&&r.node.isBlock)return t}return null}function Cp(n,e,t){let{node:r,fromOffset:o,toOffset:s,from:i,to:l}=n.docView.parseRange(e,t),a=n.domSelectionRange(),c,u=a.anchorNode;if(u&&n.dom.contains(u.nodeType==1?u:u.parentNode)&&(c=[{node:u,offset:a.anchorOffset}],Tr(a)||c.push({node:a.focusNode,offset:a.focusOffset})),ie&&n.input.lastKeyCode===8)for(let g=s;g>o;g--){let x=r.childNodes[g-1],S=x.pmViewDesc;if(x.nodeName=="BR"&&!S){s=g;break}if(!S||S.size)break}let f=n.state.doc,d=n.someProp("domParser")||Pt.fromSchema(n.state.schema),p=f.resolve(i),h=null,b=d.parse(r,{topNode:p.parent,topMatch:p.parent.contentMatchAt(p.index()),topOpen:!0,from:o,to:s,preserveWhitespace:p.parent.type.whitespace=="pre"?"full":!0,findPositions:c,ruleFromNode:wp,context:p});if(c&&c[0].pos!=null){let g=c[0].pos,x=c[1]&&c[1].pos;x==null&&(x=g),h={anchor:g+i,head:x+i}}return{doc:b,sel:h,from:i,to:l}}function wp(n){let e=n.pmViewDesc;if(e)return e.parseRule();if(n.nodeName=="BR"&&n.parentNode){if(ue&&/^(ul|ol)$/i.test(n.parentNode.nodeName)){let t=document.createElement("div");return t.appendChild(document.createElement("li")),{skip:t}}else if(n.parentNode.lastChild==n||ue&&/^(tr|table)$/i.test(n.parentNode.nodeName))return{ignore:!0}}else if(n.nodeName=="IMG"&&n.getAttribute("mark-placeholder"))return{ignore:!0};return null}const Mp=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function Np(n,e,t,r,o){let s=n.input.compositionPendingChanges||(n.composing?n.input.compositionID:0);if(n.input.compositionPendingChanges=0,e<0){let v=n.input.lastSelectionTime>Date.now()-50?n.input.lastSelectionOrigin:null,L=Go(n,v);if(L&&!n.state.selection.eq(L)){if(ie&&Qe&&n.input.lastKeyCode===13&&Date.now()-100<n.input.lastKeyCodeTime&&n.someProp("handleKeyDown",Et=>Et(n,Rt(13,"Enter"))))return;let we=n.state.tr.setSelection(L);v=="pointer"?we.setMeta("pointer",!0):v=="key"&&we.scrollIntoView(),s&&we.setMeta("composition",s),n.dispatch(we)}return}let i=n.state.doc.resolve(e),l=i.sharedDepth(t);e=i.before(l+1),t=n.state.doc.resolve(t).after(l+1);let a=n.state.selection,c=Cp(n,e,t),u=n.state.doc,f=u.slice(c.from,c.to),d,p;n.input.lastKeyCode===8&&Date.now()-100<n.input.lastKeyCodeTime?(d=n.state.selection.to,p="end"):(d=n.state.selection.from,p="start"),n.input.lastKeyCode=null;let h=Op(f.content,c.doc.content,c.from,d,p);if(h&&n.input.domChangeCount++,(sn&&n.input.lastIOSEnter>Date.now()-225||Qe)&&o.some(v=>v.nodeType==1&&!Mp.test(v.nodeName))&&(!h||h.endA>=h.endB)&&n.someProp("handleKeyDown",v=>v(n,Rt(13,"Enter")))){n.input.lastIOSEnter=0;return}if(!h)if(r&&a instanceof V&&!a.empty&&a.$head.sameParent(a.$anchor)&&!n.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))h={start:a.from,endA:a.to,endB:a.to};else{if(c.sel){let v=$a(n,n.state.doc,c.sel);if(v&&!v.eq(n.state.selection)){let L=n.state.tr.setSelection(v);s&&L.setMeta("composition",s),n.dispatch(L)}}return}n.state.selection.from<n.state.selection.to&&h.start==h.endB&&n.state.selection instanceof V&&(h.start>n.state.selection.from&&h.start<=n.state.selection.from+2&&n.state.selection.from>=c.from?h.start=n.state.selection.from:h.endA<n.state.selection.to&&h.endA>=n.state.selection.to-2&&n.state.selection.to<=c.to&&(h.endB+=n.state.selection.to-h.endA,h.endA=n.state.selection.to)),ye&&dt<=11&&h.endB==h.start+1&&h.endA==h.start&&h.start>c.from&&c.doc.textBetween(h.start-c.from-1,h.start-c.from+1)==" "&&(h.start--,h.endA--,h.endB--);let b=c.doc.resolveNoCache(h.start-c.from),g=c.doc.resolveNoCache(h.endB-c.from),x=u.resolve(h.start),S=b.sameParent(g)&&b.parent.inlineContent&&x.end()>=h.endA,w;if((sn&&n.input.lastIOSEnter>Date.now()-225&&(!S||o.some(v=>v.nodeName=="DIV"||v.nodeName=="P"))||!S&&b.pos<c.doc.content.size&&!b.sameParent(g)&&(w=R.findFrom(c.doc.resolve(b.pos+1),1,!0))&&w.head==g.pos)&&n.someProp("handleKeyDown",v=>v(n,Rt(13,"Enter")))){n.input.lastIOSEnter=0;return}if(n.state.selection.anchor>h.start&&Dp(u,h.start,h.endA,b,g)&&n.someProp("handleKeyDown",v=>v(n,Rt(8,"Backspace")))){Qe&&ie&&n.domObserver.suppressSelectionUpdates();return}ie&&h.endB==h.start&&(n.input.lastChromeDelete=Date.now()),Qe&&!S&&b.start()!=g.start()&&g.parentOffset==0&&b.depth==g.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==h.endA&&(h.endB-=2,g=c.doc.resolveNoCache(h.endB-c.from),setTimeout(()=>{n.someProp("handleKeyDown",function(v){return v(n,Rt(13,"Enter"))})},20));let D=h.start,T=h.endA,M,I,z;if(S){if(b.pos==g.pos)ye&&dt<=11&&b.parentOffset==0&&(n.domObserver.suppressSelectionUpdates(),setTimeout(()=>et(n),20)),M=n.state.tr.delete(D,T),I=u.resolve(h.start).marksAcross(u.resolve(h.endA));else if(h.endA==h.endB&&(z=Ep(b.parent.content.cut(b.parentOffset,g.parentOffset),x.parent.content.cut(x.parentOffset,h.endA-x.start()))))M=n.state.tr,z.type=="add"?M.addMark(D,T,z.mark):M.removeMark(D,T,z.mark);else if(b.parent.child(b.index()).isText&&b.index()==g.index()-(g.textOffset?0:1)){let v=b.parent.textBetween(b.parentOffset,g.parentOffset);if(n.someProp("handleTextInput",L=>L(n,D,T,v)))return;M=n.state.tr.insertText(v,D,T)}}if(M||(M=n.state.tr.replace(D,T,c.doc.slice(h.start-c.from,h.endB-c.from))),c.sel){let v=$a(n,M.doc,c.sel);v&&!(ie&&n.composing&&v.empty&&(h.start!=h.endB||n.input.lastChromeDelete<Date.now()-100)&&(v.head==D||v.head==M.mapping.map(T)-1)||ye&&v.empty&&v.head==D)&&M.setSelection(v)}I&&M.ensureMarks(I),s&&M.setMeta("composition",s),n.dispatch(M.scrollIntoView())}function $a(n,e,t){return Math.max(t.anchor,t.head)>e.content.size?null:Uo(n,e.resolve(t.anchor),e.resolve(t.head))}function Ep(n,e){let t=n.firstChild.marks,r=e.firstChild.marks,o=t,s=r,i,l,a;for(let u=0;u<r.length;u++)o=r[u].removeFromSet(o);for(let u=0;u<t.length;u++)s=t[u].removeFromSet(s);if(o.length==1&&s.length==0)l=o[0],i="add",a=u=>u.mark(l.addToSet(u.marks));else if(o.length==0&&s.length==1)l=s[0],i="remove",a=u=>u.mark(l.removeFromSet(u.marks));else return null;let c=[];for(let u=0;u<e.childCount;u++)c.push(a(e.child(u)));if(C.from(c).eq(n))return{mark:l,type:i}}function Dp(n,e,t,r,o){if(t-e<=o.pos-r.pos||cs(r,!0,!1)<o.pos)return!1;let s=n.resolve(e);if(!r.parent.isTextblock){let l=s.nodeAfter;return l!=null&&t==e+l.nodeSize}if(s.parentOffset<s.parent.content.size||!s.parent.isTextblock)return!1;let i=n.resolve(cs(s,!0,!0));return!i.parent.isTextblock||i.pos>t||cs(i,!0,!1)<t?!1:r.parent.content.cut(r.parentOffset).eq(i.parent.content)}function cs(n,e,t){let r=n.depth,o=e?n.end():n.pos;for(;r>0&&(e||n.indexAfter(r)==n.node(r).childCount);)r--,o++,e=!1;if(t){let s=n.node(r).maybeChild(n.indexAfter(r));for(;s&&!s.isLeaf;)s=s.firstChild,o++}return o}function Op(n,e,t,r,o){let s=n.findDiffStart(e,t);if(s==null)return null;let{a:i,b:l}=n.findDiffEnd(e,t+n.size,t+e.size);if(o=="end"){let a=Math.max(0,s-Math.min(i,l));r-=i+a-s}if(i<s&&n.size<e.size){let a=r<=s&&r>=i?s-r:0;s-=a,s&&s<e.size&&ja(e.textBetween(s-1,s+1))&&(s+=a?1:-1),l=s+(l-i),i=s}else if(l<s){let a=r<=s&&r>=l?s-r:0;s-=a,s&&s<n.size&&ja(n.textBetween(s-1,s+1))&&(s+=a?1:-1),i=s+(i-l),l=s}return{start:s,endA:i,endB:l}}function ja(n){if(n.length!=2)return!1;let e=n.charCodeAt(0),t=n.charCodeAt(1);return e>=56320&&e<=57343&&t>=55296&&t<=56319}class vp{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 Jh,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(_a),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):typeof e=="function"?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=La(this),Fa(this),this.nodeViews=Wa(this),this.docView=Hl(this.state.doc,Ba(this),as(this),this.dom,this),this.domObserver=new bp(this,(r,o,s,i)=>Np(this,r,o,s,i)),this.domObserver.start(),Yh(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let t in e)this._props[t]=e[t];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&ns(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(_a),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let r in this._props)t[r]=this._props[r];t.state=this.state;for(let r in e)t[r]=e[r];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var r;let o=this.state,s=!1,i=!1;e.storedMarks&&this.composing&&(Ma(this),i=!0),this.state=e;let l=o.plugins!=e.plugins||this._props.plugins!=t.plugins;if(l||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let p=Wa(this);Ap(p,this.nodeViews)&&(this.nodeViews=p,s=!0)}(l||t.handleDOMEvents!=this._props.handleDOMEvents)&&ns(this),this.editable=La(this),Fa(this);let a=as(this),c=Ba(this),u=o.plugins!=e.plugins&&!o.doc.eq(e.doc)?"reset":e.scrollToSelection>o.scrollToSelection?"to selection":"preserve",f=s||!this.docView.matchesNode(e.doc,c,a);(f||!e.selection.eq(o.selection))&&(i=!0);let d=u=="preserve"&&i&&this.dom.style.overflowAnchor==null&&ah(this);if(i){this.domObserver.stop();let p=f&&(ye||ie)&&!this.composing&&!o.selection.empty&&!e.selection.empty&&Tp(o.selection,e.selection);if(f){let h=ie?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=lp(this)),(s||!this.docView.update(e.doc,c,a,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=Hl(e.doc,c,a,this.dom,this)),h&&!this.trackWrites&&(p=!0)}p||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&Ph(this))?et(this,p):(na(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(o),!((r=this.dragging)===null||r===void 0)&&r.node&&!o.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,o),u=="reset"?this.dom.scrollTop=0:u=="to selection"?this.scrollToSelection():d&&ch(d)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof O){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&Pl(this,t.getBoundingClientRect(),e)}else Pl(this,this.coordsAtPos(this.state.selection.head,1),e)}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let t=0;t<this.directPlugins.length;t++){let r=this.directPlugins[t];r.spec.view&&this.pluginViews.push(r.spec.view(this))}for(let t=0;t<this.state.plugins.length;t++){let r=this.state.plugins[t];r.spec.view&&this.pluginViews.push(r.spec.view(this))}}else for(let t=0;t<this.pluginViews.length;t++){let r=this.pluginViews[t];r.update&&r.update(this,e)}}updateDraggedNode(e,t){let r=e.node,o=-1;if(this.state.doc.nodeAt(r.from)==r.node)o=r.from;else{let s=r.from+(this.state.doc.content.size-t.doc.content.size);(s>0&&this.state.doc.nodeAt(s))==r.node&&(o=s)}this.dragging=new Ea(e.slice,e.move,o<0?void 0:O.create(this.state.doc,o))}someProp(e,t){let r=this._props&&this._props[e],o;if(r!=null&&(o=t?t(r):r))return o;for(let i=0;i<this.directPlugins.length;i++){let l=this.directPlugins[i].props[e];if(l!=null&&(o=t?t(l):l))return o}let s=this.state.plugins;if(s)for(let i=0;i<s.length;i++){let l=s[i].props[e];if(l!=null&&(o=t?t(l):l))return o}}hasFocus(){if(ye){let e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if(e.contentEditable=="false")return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&uh(this.dom),et(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let t=this.dom.parentNode;t;t=t.parentNode)if(t.nodeType==9||t.nodeType==11&&t.host)return t.getSelection||(Object.getPrototypeOf(t).getSelection=()=>t.ownerDocument.getSelection()),this._root=t}return e||document}updateRoot(){this._root=null}posAtCoords(e){return mh(this,e)}coordsAtPos(e,t=1){return jl(this,e,t)}domAtPos(e,t=0){return this.docView.domFromPos(e,t)}nodeDOM(e){let t=this.docView.descAt(e);return t?t.nodeDOM:null}posAtDOM(e,t,r=-1){let o=this.docView.posFromDOM(e,t,r);if(o==null)throw new RangeError("DOM position not inside the editor");return o}endOfTextblock(e,t){return kh(this,t||this.state,e)}pasteHTML(e,t){return Ln(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return Ln(this,e,null,!0,t||new ClipboardEvent("paste"))}destroy(){this.docView&&(Gh(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],as(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Ud())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return Uh(this,e)}dispatch(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))}domSelectionRange(){let e=this.domSelection();return e?ue&&this.root.nodeType===11&&nh(this.dom.ownerDocument)==this.dom&&kp(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}function Ba(n){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(n.editable),n.someProp("attributes",t=>{if(typeof t=="function"&&(t=t(n.state)),t)for(let r in t)r=="class"?e.class+=" "+t[r]:r=="style"?e.style=(e.style?e.style+";":"")+t[r]:!e[r]&&r!="contenteditable"&&r!="nodeName"&&(e[r]=String(t[r]))}),e.translate||(e.translate="no"),[Ve.node(0,n.state.doc.content.size,e)]}function Fa(n){if(n.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),n.cursorWrapper={dom:e,deco:Ve.widget(n.state.selection.from,e,{raw:!0,marks:n.markCursor})}}else n.cursorWrapper=null}function La(n){return!n.someProp("editable",e=>e(n.state)===!1)}function Tp(n,e){let t=Math.min(n.$anchor.sharedDepth(n.head),e.$anchor.sharedDepth(e.head));return n.$anchor.start(t)!=e.$anchor.start(t)}function Wa(n){let e=Object.create(null);function t(r){for(let o in r)Object.prototype.hasOwnProperty.call(e,o)||(e[o]=r[o])}return n.someProp("nodeViews",t),n.someProp("markViews",t),e}function Ap(n,e){let t=0,r=0;for(let o in n){if(n[o]!=e[o])return!0;t++}for(let o in e)r++;return t!=r}function _a(n){if(n.spec.state||n.spec.filterTransaction||n.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}class q extends R{constructor(e){super(e,e)}map(e,t){let r=e.resolve(t.map(this.head));return q.valid(r)?new q(r):R.near(r)}content(){return E.empty}eq(e){return e instanceof q&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new q(e.resolve(t.pos))}getBookmark(){return new us(this.anchor)}static valid(e){let t=e.parent;if(t.isTextblock||!Pp(e)||!Ip(e))return!1;let r=t.type.spec.allowGapCursor;if(r!=null)return r;let o=t.contentMatchAt(e.index()).defaultType;return o&&o.isTextblock}static findGapCursorFrom(e,t,r=!1){e:for(;;){if(!r&&q.valid(e))return e;let o=e.pos,s=null;for(let i=e.depth;;i--){let l=e.node(i);if(t>0?e.indexAfter(i)<l.childCount:e.index(i)>0){s=l.child(t>0?e.indexAfter(i):e.index(i)-1);break}else if(i==0)return null;o+=t;let a=e.doc.resolve(o);if(q.valid(a))return a}for(;;){let i=t>0?s.firstChild:s.lastChild;if(!i){if(s.isAtom&&!s.isText&&!O.isSelectable(s)){e=e.doc.resolve(o+s.nodeSize*t),r=!1;continue e}break}s=i,o+=t;let l=e.doc.resolve(o);if(q.valid(l))return l}return null}}}q.prototype.visible=!1,q.findFrom=q.findGapCursorFrom,R.jsonID("gapcursor",q);class us{constructor(e){this.pos=e}map(e){return new us(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return q.valid(t)?new q(t):R.near(t)}}function Pp(n){for(let e=n.depth;e>=0;e--){let t=n.index(e),r=n.node(e);if(t==0){if(r.type.spec.isolating)return!0;continue}for(let o=r.child(t-1);;o=o.lastChild){if(o.childCount==0&&!o.inlineContent||o.isAtom||o.type.spec.isolating)return!0;if(o.inlineContent)return!1}}return!0}function Ip(n){for(let e=n.depth;e>=0;e--){let t=n.indexAfter(e),r=n.node(e);if(t==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let o=r.child(t);;o=o.firstChild){if(o.childCount==0&&!o.inlineContent||o.isAtom||o.type.spec.isolating)return!0;if(o.inlineContent)return!1}}return!0}function Vp(){return new Be({props:{decorations:jp,createSelectionBetween(n,e,t){return e.pos==t.pos&&q.valid(t)?new q(t):null},handleClick:zp,handleKeyDown:Rp,handleDOMEvents:{beforeinput:$p}}})}const Rp=zo({ArrowLeft:$r("horiz",-1),ArrowRight:$r("horiz",1),ArrowUp:$r("vert",-1),ArrowDown:$r("vert",1)});function $r(n,e){const t=n=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,o,s){let i=r.selection,l=e>0?i.$to:i.$from,a=i.empty;if(i instanceof V){if(!s.endOfTextblock(t)||l.depth==0)return!1;a=!1,l=r.doc.resolve(e>0?l.after():l.before())}let c=q.findGapCursorFrom(l,e,a);return c?(o&&o(r.tr.setSelection(new q(c))),!0):!1}}function zp(n,e,t){if(!n||!n.editable)return!1;let r=n.state.doc.resolve(e);if(!q.valid(r))return!1;let o=n.posAtCoords({left:t.clientX,top:t.clientY});return o&&o.inside>-1&&O.isSelectable(n.state.doc.nodeAt(o.inside))?!1:(n.dispatch(n.state.tr.setSelection(new q(r))),!0)}function $p(n,e){if(e.inputType!="insertCompositionText"||!(n.state.selection instanceof q))return!1;let{$from:t}=n.state.selection,r=t.parent.contentMatchAt(t.index()).findWrapping(n.state.schema.nodes.text);if(!r)return!1;let o=C.empty;for(let i=r.length-1;i>=0;i--)o=C.from(r[i].createAndFill(null,o));let s=n.state.tr.replace(t.pos,t.pos,new E(o,0,0));return s.setSelection(V.near(s.doc.resolve(t.pos+1))),n.dispatch(s),!1}function jp(n){if(!(n.selection instanceof q))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",H.create(n.doc,[Ve.widget(n.selection.head,e,{key:"gapcursor"})])}const Bp=["ol",0],Fp=["ul",0],Lp=["li",0],Wp={attrs:{order:{default:1,validate:"number"}},parseDOM:[{tag:"ol",getAttrs(n){return{order:n.hasAttribute("start")?+n.getAttribute("start"):1}}}],toDOM(n){return n.attrs.order==1?Bp:["ol",{start:n.attrs.order},0]}},_p={parseDOM:[{tag:"ul"}],toDOM(){return Fp}},qp={parseDOM:[{tag:"li"}],toDOM(){return Lp},defining:!0};function fs(n,e){let t={};for(let r in n)t[r]=n[r];for(let r in e)t[r]=e[r];return t}function Hp(n,e,t){return n.append({ordered_list:fs(Wp,{content:"list_item+",group:t}),bullet_list:fs(_p,{content:"list_item+",group:t}),list_item:fs(qp,{content:e})})}function jr(n,e=null){return function(t,r){let{$from:o,$to:s}=t.selection,i=o.blockRange(s);if(!i)return!1;let l=r?t.tr:null;return Kp(l,i,n,e)?(r&&r(l.scrollIntoView()),!0):!1}}function Kp(n,e,t,r=null){let o=!1,s=e,i=e.$from.doc;if(e.depth>=2&&e.$from.node(e.depth-1).type.compatibleContent(t)&&e.startIndex==0){if(e.$from.index(e.depth-1)==0)return!1;let a=i.resolve(e.start-2);s=new gr(a,a,e.depth),e.endIndex<e.parent.childCount&&(e=new gr(e.$from,i.resolve(e.$to.end(e.depth)),e.depth)),o=!0}let l=So(s,t,r,e);return l?(n&&Jp(n,e,l,o,t),!0):!1}function Jp(n,e,t,r,o){let s=C.empty;for(let u=t.length-1;u>=0;u--)s=C.from(t[u].type.create(t[u].attrs,s));n.step(new ee(e.start-(r?2:0),e.end,e.start,e.end,new E(s,0,0),t.length,!0));let i=0;for(let u=0;u<t.length;u++)t[u].type==o&&(i=u+1);let l=t.length-i,a=e.start+t.length-(r?2:0),c=e.parent;for(let u=e.startIndex,f=e.endIndex,d=!0;u<f;u++,d=!1)!d&&Qt(n.doc,a,l)&&(n.split(a,l),a+=2*l),a+=c.child(u).nodeSize;return n}function Yp(n,e){return function(t,r){let{$from:o,$to:s,node:i}=t.selection;if(i&&i.isBlock||o.depth<2||!o.sameParent(s))return!1;let l=o.node(-1);if(l.type!=n)return!1;if(o.parent.content.size==0&&o.node(-1).childCount==o.indexAfter(-1)){if(o.depth==3||o.node(-3).type!=n||o.index(-2)!=o.node(-2).childCount-1)return!1;if(r){let f=C.empty,d=o.index(-1)?1:o.index(-2)?2:3;for(let x=o.depth-d;x>=o.depth-3;x--)f=C.from(o.node(x).copy(f));let p=o.indexAfter(-1)<o.node(-2).childCount?1:o.indexAfter(-2)<o.node(-3).childCount?2:3;f=f.append(C.from(n.createAndFill()));let h=o.before(o.depth-(d-1)),b=t.tr.replace(h,o.after(-p),new E(f,4-d,0)),g=-1;b.doc.nodesBetween(h,b.doc.content.size,(x,S)=>{if(g>-1)return!1;x.isTextblock&&x.content.size==0&&(g=S+1)}),g>-1&&b.setSelection(R.near(b.doc.resolve(g))),r(b.scrollIntoView())}return!0}let a=s.pos==o.end()?l.contentMatchAt(0).defaultType:null,c=t.tr.delete(o.pos,s.pos),u=a?[null,{type:a}]:void 0;return Qt(c.doc,o.pos,2,u)?(r&&r(c.split(o.pos,2,u).scrollIntoView()),!0):!1}}function Gp(n){return function(e,t){let{$from:r,$to:o}=e.selection,s=r.blockRange(o,i=>i.childCount>0&&i.firstChild.type==n);return s?t?r.node(s.depth-1).type==n?Xp(e,t,n,s):Up(e,t,s):!0:!1}}function Xp(n,e,t,r){let o=n.tr,s=r.end,i=r.$to.end(r.depth);s<i&&(o.step(new ee(s-1,i,s,i,new E(C.from(t.create(null,r.parent.copy())),1,0),1,!0)),r=new gr(o.doc.resolve(r.$from.pos),o.doc.resolve(i),r.depth));const l=On(r);if(l==null)return!1;o.lift(r,l);let a=o.doc.resolve(o.mapping.map(s,-1)-1);return Zt(o.doc,a.pos)&&a.nodeBefore.type==a.nodeAfter.type&&o.join(a.pos),e(o.scrollIntoView()),!0}function Up(n,e,t){let r=n.tr,o=t.parent;for(let p=t.end,h=t.endIndex-1,b=t.startIndex;h>b;h--)p-=o.child(h).nodeSize,r.delete(p-1,p+1);let s=r.doc.resolve(t.start),i=s.nodeAfter;if(r.mapping.map(t.end)!=t.start+s.nodeAfter.nodeSize)return!1;let l=t.startIndex==0,a=t.endIndex==o.childCount,c=s.node(-1),u=s.index(-1);if(!c.canReplace(u+(l?0:1),u+1,i.content.append(a?C.empty:C.from(o))))return!1;let f=s.pos,d=f+i.nodeSize;return r.step(new ee(f-(l?1:0),d+(a?1:0),f+1,d-1,new E((l?C.empty:C.from(o.copy(C.empty))).append(a?C.empty:C.from(o.copy(C.empty))),l?0:1,a?0:1),l?0:1)),e(r.scrollIntoView()),!0}function Qp(n){return function(e,t){let{$from:r,$to:o}=e.selection,s=r.blockRange(o,c=>c.childCount>0&&c.firstChild.type==n);if(!s)return!1;let i=s.startIndex;if(i==0)return!1;let l=s.parent,a=l.child(i-1);if(a.type!=n)return!1;if(t){let c=a.lastChild&&a.lastChild.type==l.type,u=C.from(c?n.create():null),f=new E(C.from(n.create(null,C.from(l.type.create(null,u)))),c?3:1,0),d=s.start,p=s.end;t(e.tr.step(new ee(d-(c?3:1),p,d,p,f,1,!0)).scrollIntoView())}return!0}}class gt{constructor(e,t,r={}){this.match=e,this.match=e,this.handler=typeof t=="string"?Zp(t):t,this.undoable=r.undoable!==!1,this.inCode=r.inCode||!1,this.inCodeMark=r.inCodeMark!==!1}}function Zp(n){return function(e,t,r,o){let s=n;if(t[1]){let i=t[0].lastIndexOf(t[1]);s+=t[0].slice(i+t[1].length),r+=i;let l=r-o;l>0&&(s=t[0].slice(i-l,i)+s,r=o)}return e.tr.insertText(s,r,o)}}const em=500;function tm({rules:n}){let e=new Be({state:{init(){return null},apply(t,r){let o=t.getMeta(this);return o||(t.selectionSet||t.docChanged?null:r)}},props:{handleTextInput(t,r,o,s){return qa(t,r,o,s,n,e)},handleDOMEvents:{compositionend:t=>{setTimeout(()=>{let{$cursor:r}=t.state.selection;r&&qa(t,r.pos,r.pos,"",n,e)})}}},isInputRules:!0});return e}function qa(n,e,t,r,o,s){if(n.composing)return!1;let i=n.state,l=i.doc.resolve(e),a=l.parent.textBetween(Math.max(0,l.parentOffset-em),l.parentOffset,null,"")+r;for(let c=0;c<o.length;c++){let u=o[c];if(!u.inCodeMark&&l.marks().some(p=>p.type.spec.code))continue;if(l.parent.type.spec.code){if(!u.inCode)continue}else if(u.inCode==="only")continue;let f=u.match.exec(a),d=f&&f[0].length>=r.length&&u.handler(i,f,e-(f[0].length-r.length),t);if(d)return u.undoable&&d.setMeta(s,{transform:d,from:e,to:t,text:r}),n.dispatch(d),!0}return!1}const nm=(n,e)=>{let t=n.plugins;for(let r=0;r<t.length;r++){let o=t[r],s;if(o.spec.isInputRules&&(s=o.getState(n))){if(e){let i=n.tr,l=s.transform;for(let a=l.steps.length-1;a>=0;a--)i.step(l.steps[a].invert(l.docs[a]));if(s.text){let a=i.doc.resolve(s.from).marks();i.replaceWith(s.from,s.to,n.schema.text(s.text,a))}else i.delete(s.from,s.to);e(i)}return!0}}return!1},rm=new gt(/--$/,"—",{inCodeMark:!1}),om=new gt(/\.\.\.$/,"…",{inCodeMark:!1}),sm=new gt(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,"“",{inCodeMark:!1}),im=new gt(/"$/,"”",{inCodeMark:!1}),lm=new gt(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,"‘",{inCodeMark:!1}),am=new gt(/'$/,"’",{inCodeMark:!1}),cm=[sm,im,lm,am];function ds(n,e,t=null,r){return new gt(n,(o,s,i,l)=>{let a=t instanceof Function?t(s):t,c=o.tr.delete(i,l),u=c.doc.resolve(i),f=u.blockRange(),d=f&&So(f,e,a);if(!d)return null;c.wrap(f,d);let p=c.doc.resolve(i-1).nodeBefore;return p&&p.type==e&&Zt(c.doc,i-1)&&(!r||r(s,p))&&c.join(i-1),c})}function Ha(n,e,t=null){return new gt(n,(r,o,s,i)=>{let l=r.doc.resolve(s),a=t instanceof Function?t(o):t;return l.node(-1).canReplaceWith(l.index(-1),l.indexAfter(-1),e)?r.tr.delete(s,i).setBlockType(s,s,e,a):null})}const Ka=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):!1;function um(n,e){let t={},r;function o(s,i){t[s]=i}if(o("Mod-z",Po),o("Shift-Mod-z",Dr),o("Backspace",nm),Ka||o("Mod-y",Dr),o("Alt-ArrowUp",Sl),o("Alt-ArrowDown",$d),o("Mod-BracketLeft",$o),o("Escape",Bo),(r=n.marks.strong)&&(o("Mod-b",ke(r)),o("Mod-B",ke(r))),(r=n.marks.em)&&(o("Mod-i",ke(r)),o("Mod-I",ke(r))),(r=n.marks.code)&&o("Mod-`",ke(r)),(r=n.nodes.bullet_list)&&o("Shift-Ctrl-8",jr(r)),(r=n.nodes.ordered_list)&&o("Shift-Ctrl-9",jr(r)),(r=n.nodes.blockquote)&&o("Ctrl->",Nl(r)),r=n.nodes.hard_break){let s=r,i=vr(Cl,(l,a)=>(a&&a(l.tr.replaceSelectionWith(s.create()).scrollIntoView()),!0));o("Mod-Enter",i),o("Shift-Enter",i),Ka&&o("Ctrl-Enter",i)}if((r=n.nodes.list_item)&&(o("Enter",Yp(r)),o("Mod-[",Gp(r)),o("Mod-]",Qp(r))),(r=n.nodes.paragraph)&&o("Shift-Ctrl-0",on(r)),(r=n.nodes.code_block)&&o("Shift-Ctrl-\\",on(r)),r=n.nodes.heading)for(let s=1;s<=6;s++)o("Shift-Ctrl-"+s,on(r,{level:s}));if(r=n.nodes.horizontal_rule){let s=r;o("Mod-_",(i,l)=>(l&&l(i.tr.replaceSelectionWith(s.create()).scrollIntoView()),!0))}return t}function fm(n){return ds(/^\s*>\s$/,n)}function dm(n){return ds(/^(\d+)\.\s$/,n,e=>({order:+e[1]}),(e,t)=>t.childCount+t.attrs.order==+e[1])}function hm(n){return ds(/^\s*([-+*])\s$/,n)}function pm(n){return Ha(/^```$/,n)}function mm(n,e){return Ha(new RegExp("^(#{1,"+e+"})\\s$"),n,t=>({level:t[1].length}))}function gm(n){let e=cm.concat(om,rm),t;return(t=n.nodes.blockquote)&&e.push(fm(t)),(t=n.nodes.ordered_list)&&e.push(dm(t)),(t=n.nodes.bullet_list)&&e.push(hm(t)),(t=n.nodes.code_block)&&e.push(pm(t)),(t=n.nodes.heading)&&e.push(mm(t,6)),tm({rules:e})}const tt=new lt("ImagePluginKey"),ym=n=>new Be({key:tt,state:{init(){return{set:H.empty,schema:n.schema,upload:n.upload}},apply(t,r){let o=r.set.map(t.mapping,t.doc);const s=t.getMeta(tt);if(s&&s.add){const i=document.createElement("placeholder"),l=Ve.widget(s.add.pos,i,{id:s.add.id,key:`imgphd${s.add.id}`});o=o.add(t.doc,[l])}else s&&s.remove&&(o=o.remove(o.find(void 0,void 0,i=>i.id==s.remove.id)));return{...r,set:o}}},props:{decorations(t){var r;return(r=this.getState(t))==null?void 0:r.set}}}),bm=(n,e)=>{const t=tt.getState(n).set,r=t==null?void 0:t.find(void 0,void 0,o=>o.id==e);return r!=null&&r.length?r[0].from:null},xm=async(n,e,t,r)=>{if(!e)return;const o=Date.now(),s=n.state.tr;r===void 0&&(s.selection.empty||s.deleteSelection(),r=s.selection.from),s.setMeta(tt,{add:{id:o,pos:r}}),n.dispatch(s);try{const i=tt.getState(n.state),l=i.schema,a=i.upload;if(!a)throw new Error("uploadImage: Image upload function not defined");const c=await a(e);if(typeof c=="string")throw new Error(c);const u=bm(n.state,o);if(u===null){console.warn("uploadImage: The image was removed from the document during upload");return}n.dispatch(n.state.tr.replaceWith(u,u,l.nodes.image.create({fid:c,title:t})).setMeta(tt,{remove:{id:o}}))}catch(i){n.dispatch(n.state.tr.setMeta(tt,{remove:{id:o}})),console.error(`uploadImage: ${i}`)}},km=(n,e,t,r)=>{if(!e)return;const o=n.state.tr;r===void 0&&(o.selection.empty||o.deleteSelection(),r=o.selection.from);const s=tt.getState(n.state).schema;n.dispatch(n.state.tr.replaceWith(r,r,s.nodes.image.create({src:e,title:t})))},Ft=function(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e},Ja=function(n,e,t,r){return t&&(Ya(n,e,t,r,-1)||Ya(n,e,t,r,1))},Sm=/^(img|br|input|textarea|hr)$/i;function Ya(n,e,t,r,o){for(;;){if(n==t&&e==r)return!0;if(e==(o<0?0:Br(n))){let s=n.parentNode;if(!s||s.nodeType!=1||hs(n)||Sm.test(n.nodeName)||n.contentEditable=="false")return!1;e=Ft(n)+(o<0?0:1),n=s}else if(n.nodeType==1){if(n=n.childNodes[e+(o<0?-1:0)],n.contentEditable=="false")return!1;e=o<0?Br(n):0}else return!1}}function Br(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Cm(n,e,t){for(let r=e==0,o=e==Br(n);r||o;){if(n==t)return!0;let s=Ft(n);if(n=n.parentNode,!n)return!1;r=r&&s==0,o=o&&s==Br(n)}}function hs(n){let e;for(let t=n;t&&!(e=t.pmViewDesc);t=t.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==n||e.contentDOM==n)}const Ga=function(n){return n.focusNode&&Ja(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)};function Xa(n,e){let t=document.createEvent("Event");return t.initEvent("keydown",!0,!0),t.keyCode=n,t.key=t.code=e,t}const _e=typeof navigator<"u"?navigator:null,Ua=typeof document<"u"?document:null,yt=_e&&_e.userAgent||"",ps=/Edge\/(\d+)/.exec(yt),Qa=/MSIE \d/.exec(yt),ms=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(yt),qn=!!(Qa||ms||ps),Za=Qa?document.documentMode:ms?+ms[1]:ps?+ps[1]:0,Fr=!qn&&/gecko\/(\d+)/i.test(yt);Fr&&+(/Firefox\/(\d+)/.exec(yt)||[0,0])[1];const gs=!qn&&/Chrome\/(\d+)/.exec(yt),bt=!!gs,ec=gs?+gs[1]:0,Lt=!qn&&!!_e&&/Apple Computer/.test(_e.vendor),ys=Lt&&(/Mobile\/\w+/.test(yt)||!!_e&&_e.maxTouchPoints>2),De=ys||(_e?/Mac/.test(_e.platform):!1),wm=_e?/Win/.test(_e.platform):!1,Hn=/Android \d/.test(yt),bs=!!Ua&&"webkitFontSmoothing"in Ua.documentElement.style,Mm=bs?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Nm(n,e=null){let t=n.domSelectionRange(),r=n.state.doc;if(!t.focusNode)return null;let o=n.docView.nearestDesc(t.focusNode),s=o&&o.size==0,i=n.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(i<0)return null;let l=r.resolve(i),a,c;if(Ga(t)){for(a=i;o&&!o.node;)o=o.parent;let f=o.node;if(o&&f.isAtom&&O.isSelectable(f)&&o.parent&&!(f.isInline&&Cm(t.focusNode,t.focusOffset,o.dom))){let d=o.posBefore;c=new O(i==d?l:r.resolve(d))}}else{if(t instanceof n.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let f=i,d=i;for(let p=0;p<t.rangeCount;p++){let h=t.getRangeAt(p);f=Math.min(f,n.docView.posFromDOM(h.startContainer,h.startOffset,1)),d=Math.max(d,n.docView.posFromDOM(h.endContainer,h.endOffset,-1))}if(f<0)return null;[a,i]=d==n.state.selection.anchor?[d,f]:[f,d],l=r.resolve(i)}else a=n.docView.posFromDOM(t.anchorNode,t.anchorOffset,1);if(a<0)return null}let u=r.resolve(a);if(!c){let f=e=="pointer"||n.state.selection.head<l.pos&&!s?1:-1;c=ic(n,u,l,f)}return c}function tc(n){return n.editable?n.hasFocus():vm(n)&&document.activeElement&&document.activeElement.contains(n.dom)}function xs(n,e=!1){let t=n.state.selection;if(Om(n,t),!!tc(n)){if(!e&&n.input.mouseDown&&n.input.mouseDown.allowDefault&&bt){let r=n.domSelectionRange(),o=n.domObserver.currentSelection;if(r.anchorNode&&o.anchorNode&&Ja(r.anchorNode,r.anchorOffset,o.anchorNode,o.anchorOffset)){n.input.mouseDown.delayedSelectionSync=!0,n.domObserver.setCurSelection();return}}if(n.domObserver.disconnectSelection(),n.cursorWrapper)Dm(n);else{let{anchor:r,head:o}=t,s,i;nc&&!(t instanceof V)&&(t.$from.parent.inlineContent||(s=rc(n,t.from)),!t.empty&&!t.$from.parent.inlineContent&&(i=rc(n,t.to))),n.docView.setSelection(r,o,n,e),nc&&(s&&oc(s),i&&oc(i)),t.visible?n.dom.classList.remove("ProseMirror-hideselection"):(n.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&Em(n))}n.domObserver.setCurSelection(),n.domObserver.connectSelection()}}const nc=Lt||bt&&ec<63;function rc(n,e){let{node:t,offset:r}=n.docView.domFromPos(e,0),o=r<t.childNodes.length?t.childNodes[r]:null,s=r?t.childNodes[r-1]:null;if(Lt&&o&&o.contentEditable=="false")return ks(o);if((!o||o.contentEditable=="false")&&(!s||s.contentEditable=="false")){if(o)return ks(o);if(s)return ks(s)}}function ks(n){return n.contentEditable="true",Lt&&n.draggable&&(n.draggable=!1,n.wasDraggable=!0),n}function oc(n){n.contentEditable="false",n.wasDraggable&&(n.draggable=!0,n.wasDraggable=null)}function Em(n){let e=n.dom.ownerDocument;e.removeEventListener("selectionchange",n.input.hideSelectionGuard);let t=n.domSelectionRange(),r=t.anchorNode,o=t.anchorOffset;e.addEventListener("selectionchange",n.input.hideSelectionGuard=()=>{(t.anchorNode!=r||t.anchorOffset!=o)&&(e.removeEventListener("selectionchange",n.input.hideSelectionGuard),setTimeout(()=>{(!tc(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function Dm(n){let e=n.domSelection(),t=document.createRange();if(!e)return;let r=n.cursorWrapper.dom,o=r.nodeName=="IMG";o?t.setStart(r.parentNode,Ft(r)+1):t.setStart(r,0),t.collapse(!0),e.removeAllRanges(),e.addRange(t),!o&&!n.state.selection.visible&&qn&&Za<=11&&(r.disabled=!0,r.disabled=!1)}function Om(n,e){if(e instanceof O){let t=n.docView.descAt(e.from);t!=n.lastSelectedViewDesc&&(sc(n),t&&t.selectNode(),n.lastSelectedViewDesc=t)}else sc(n)}function sc(n){n.lastSelectedViewDesc&&(n.lastSelectedViewDesc.parent&&n.lastSelectedViewDesc.deselectNode(),n.lastSelectedViewDesc=void 0)}function ic(n,e,t,r){return n.someProp("createSelectionBetween",o=>o(n,e,t))||V.between(e,t,r)}function vm(n){let e=n.domSelectionRange();if(!e.anchorNode)return!1;try{return n.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(n.editable||n.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function Ss(n,e){let{$anchor:t,$head:r}=n.selection,o=e>0?t.max(r):t.min(r),s=o.parent.inlineContent?o.depth?n.doc.resolve(e>0?o.after():o.before()):null:o;return s&&R.findFrom(s,e)}function xt(n,e){return n.dispatch(n.state.tr.setSelection(e).scrollIntoView()),!0}function lc(n,e,t){let r=n.state.selection;if(r instanceof V)if(t.indexOf("s")>-1){let{$head:o}=r,s=o.textOffset?null:e<0?o.nodeBefore:o.nodeAfter;if(!s||s.isText||!s.isLeaf)return!1;let i=n.state.doc.resolve(o.pos+s.nodeSize*(e<0?-1:1));return xt(n,new V(r.$anchor,i))}else if(r.empty){if(n.endOfTextblock(e>0?"forward":"backward")){let o=Ss(n.state,e);return o&&o instanceof O?xt(n,o):!1}else if(!(De&&t.indexOf("m")>-1)){let o=r.$head,s=o.textOffset?null:e<0?o.nodeBefore:o.nodeAfter,i;if(!s||s.isText)return!1;let l=e<0?o.pos-s.nodeSize:o.pos;return s.isAtom||(i=n.docView.descAt(l))&&!i.contentDOM?O.isSelectable(s)?xt(n,new O(e<0?n.state.doc.resolve(o.pos-s.nodeSize):o)):bs?xt(n,new V(n.state.doc.resolve(e<0?l:l+s.nodeSize))):!1:!1}}else return!1;else{if(r instanceof O&&r.node.isInline)return xt(n,new V(e>0?r.$to:r.$from));{let o=Ss(n.state,e);return o?xt(n,o):!1}}}function Lr(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Kn(n,e){let t=n.pmViewDesc;return t&&t.size==0&&(e<0||n.nextSibling||n.nodeName!="BR")}function dn(n,e){return e<0?Tm(n):Am(n)}function Tm(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let o,s,i=!1;for(Fr&&t.nodeType==1&&r<Lr(t)&&Kn(t.childNodes[r],-1)&&(i=!0);;)if(r>0){if(t.nodeType!=1)break;{let l=t.childNodes[r-1];if(Kn(l,-1))o=t,s=--r;else if(l.nodeType==3)t=l,r=t.nodeValue.length;else break}}else{if(ac(t))break;{let l=t.previousSibling;for(;l&&Kn(l,-1);)o=t.parentNode,s=Ft(l),l=l.previousSibling;if(l)t=l,r=Lr(t);else{if(t=t.parentNode,t==n.dom)break;r=0}}}i?Cs(n,t,r):o&&Cs(n,o,s)}function Am(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let o=Lr(t),s,i;for(;;)if(r<o){if(t.nodeType!=1)break;let l=t.childNodes[r];if(Kn(l,1))s=t,i=++r;else break}else{if(ac(t))break;{let l=t.nextSibling;for(;l&&Kn(l,1);)s=l.parentNode,i=Ft(l)+1,l=l.nextSibling;if(l)t=l,r=0,o=Lr(t);else{if(t=t.parentNode,t==n.dom)break;r=o=0}}}s&&Cs(n,s,i)}function ac(n){let e=n.pmViewDesc;return e&&e.node&&e.node.isBlock}function Pm(n,e){for(;n&&e==n.childNodes.length&&!hs(n);)e=Ft(n)+1,n=n.parentNode;for(;n&&e<n.childNodes.length;){let t=n.childNodes[e];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;n=t,e=0}}function Im(n,e){for(;n&&!e&&!hs(n);)e=Ft(n),n=n.parentNode;for(;n&&e;){let t=n.childNodes[e-1];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;n=t,e=n.childNodes.length}}function Cs(n,e,t){if(e.nodeType!=3){let s,i;(i=Pm(e,t))?(e=i,t=0):(s=Im(e,t))&&(e=s,t=s.nodeValue.length)}let r=n.domSelection();if(!r)return;if(Ga(r)){let s=document.createRange();s.setEnd(e,t),s.setStart(e,t),r.removeAllRanges(),r.addRange(s)}else r.extend&&r.extend(e,t);n.domObserver.setCurSelection();let{state:o}=n;setTimeout(()=>{n.state==o&&xs(n)},50)}function cc(n,e){let t=n.state.doc.resolve(e);if(!(bt||wm)&&t.parent.inlineContent){let o=n.coordsAtPos(e);if(e>t.start()){let s=n.coordsAtPos(e-1),i=(s.top+s.bottom)/2;if(i>o.top&&i<o.bottom&&Math.abs(s.left-o.left)>1)return s.left<o.left?"ltr":"rtl"}if(e<t.end()){let s=n.coordsAtPos(e+1),i=(s.top+s.bottom)/2;if(i>o.top&&i<o.bottom&&Math.abs(s.left-o.left)>1)return s.left>o.left?"ltr":"rtl"}}return getComputedStyle(n.dom).direction=="rtl"?"rtl":"ltr"}function uc(n,e,t){let r=n.state.selection;if(r instanceof V&&!r.empty||t.indexOf("s")>-1||De&&t.indexOf("m")>-1)return!1;let{$from:o,$to:s}=r;if(!o.parent.inlineContent||n.endOfTextblock(e<0?"up":"down")){let i=Ss(n.state,e);if(i&&i instanceof O)return xt(n,i)}if(!o.parent.inlineContent){let i=e<0?o:s,l=r instanceof ge?R.near(i,e):R.findFrom(i,e);return l?xt(n,l):!1}return!1}function fc(n,e){if(!(n.state.selection instanceof V))return!0;let{$head:t,$anchor:r,empty:o}=n.state.selection;if(!t.sameParent(r))return!0;if(!o)return!1;if(n.endOfTextblock(e>0?"forward":"backward"))return!0;let s=!t.textOffset&&(e<0?t.nodeBefore:t.nodeAfter);if(s&&!s.isText){let i=n.state.tr;return e<0?i.delete(t.pos-s.nodeSize,t.pos):i.delete(t.pos,t.pos+s.nodeSize),n.dispatch(i),!0}return!1}function dc(n,e,t){n.domObserver.stop(),e.contentEditable=t,n.domObserver.start()}function Vm(n){if(!Lt||n.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:t}=n.domSelectionRange();if(e&&e.nodeType==1&&t==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let r=e.firstChild;dc(n,r,"true"),setTimeout(()=>dc(n,r,"false"),20)}return!1}function Rm(n){let e="";return n.ctrlKey&&(e+="c"),n.metaKey&&(e+="m"),n.altKey&&(e+="a"),n.shiftKey&&(e+="s"),e}function zm(n,e){let t=e.keyCode,r=Rm(e);if(t==8||De&&t==72&&r=="c")return fc(n,-1)||dn(n,-1);if(t==46&&!e.shiftKey||De&&t==68&&r=="c")return fc(n,1)||dn(n,1);if(t==13||t==27)return!0;if(t==37||De&&t==66&&r=="c"){let o=t==37?cc(n,n.state.selection.from)=="ltr"?-1:1:-1;return lc(n,o,r)||dn(n,o)}else if(t==39||De&&t==70&&r=="c"){let o=t==39?cc(n,n.state.selection.from)=="ltr"?1:-1:1;return lc(n,o,r)||dn(n,o)}else{if(t==38||De&&t==80&&r=="c")return uc(n,-1,r)||dn(n,-1);if(t==40||De&&t==78&&r=="c")return Vm(n)||uc(n,1,r)||dn(n,1);if(r==(De?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function hc(n,e){n.someProp("transformCopied",p=>{e=p(e,n)});let t=[],{content:r,openStart:o,openEnd:s}=e;for(;o>1&&s>1&&r.childCount==1&&r.firstChild.childCount==1;){o--,s--;let p=r.firstChild;t.push(p.type.name,p.attrs!=p.type.defaultAttrs?p.attrs:null),r=p.content}let i=n.someProp("clipboardSerializer")||$e.fromSchema(n.state.schema),l=Sc(),a=l.createElement("div");a.appendChild(i.serializeFragment(r,{document:l}));let c=a.firstChild,u,f=0;for(;c&&c.nodeType==1&&(u=xc[c.nodeName.toLowerCase()]);){for(let p=u.length-1;p>=0;p--){let h=l.createElement(u[p]);for(;a.firstChild;)h.appendChild(a.firstChild);a.appendChild(h),f++}c=a.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${o} ${s}${f?` -${f}`:""} ${JSON.stringify(t)}`);let d=n.someProp("clipboardTextSerializer",p=>p(e,n))||e.content.textBetween(0,e.content.size,`
|
|
41
|
+
`))),0,0):E.empty;let f=n.someProp("clipboardTextParser",d=>d(e,o,r,n));if(f)l=f;else{let d=o.marks(),{schema:p}=n.state,h=$e.fromSchema(p);i=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(b=>{let g=i.appendChild(document.createElement("p"));b&&g.appendChild(h.serializeNode(p.text(b,d)))})}}else n.someProp("transformPastedHTML",f=>{t=f(t,n)}),i=_h(t),Rn&&qh(i);let c=i&&i.querySelector("[data-pm-slice]"),u=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(u&&u[3])for(let f=+u[3];f>0;f--){let d=i.firstChild;for(;d&&d.nodeType!=1;)d=d.nextSibling;if(!d)break;i=d}if(l||(l=(n.someProp("clipboardParser")||n.someProp("domParser")||Pt.fromSchema(n.state.schema)).parseSlice(i,{preserveWhitespace:!!(a||u),context:o,ruleFromNode(d){return d.nodeName=="BR"&&!d.nextSibling&&d.parentNode&&!Fh.test(d.parentNode.nodeName)?{ignore:!0}:null}})),u)l=Hh(ya(l,+u[1],+u[2]),u[4]);else if(l=E.maxOpen(Lh(l.content,o),!0),l.openStart||l.openEnd){let f=0,d=0;for(let p=l.content.firstChild;f<l.openStart&&!p.type.spec.isolating;f++,p=p.firstChild);for(let p=l.content.lastChild;d<l.openEnd&&!p.type.spec.isolating;d++,p=p.lastChild);l=ya(l,f,d)}return n.someProp("transformPasted",f=>{l=f(l,n)}),l}const Fh=/^(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 Lh(n,e){if(n.childCount<2)return n;for(let t=e.depth;t>=0;t--){let o=e.node(t).contentMatchAt(e.index(t)),s,i=[];if(n.forEach(l=>{if(!i)return;let a=o.findWrapping(l.type),c;if(!a)return i=null;if(c=i.length&&s.length&&ma(a,s,l,i[i.length-1],0))i[i.length-1]=c;else{i.length&&(i[i.length-1]=ga(i[i.length-1],s.length));let u=pa(l,a);i.push(u),o=o.matchType(u.type),s=a}}),i)return C.from(i)}return n}function pa(n,e,t=0){for(let r=e.length-1;r>=t;r--)n=e[r].create(null,C.from(n));return n}function ma(n,e,t,r,o){if(o<n.length&&o<e.length&&n[o]==e[o]){let s=ma(n,e,t,r.lastChild,o+1);if(s)return r.copy(r.content.replaceChild(r.childCount-1,s));if(r.contentMatchAt(r.childCount).matchType(o==n.length-1?t.type:n[o+1]))return r.copy(r.content.append(C.from(pa(t,n,o+1))))}}function ga(n,e){if(e==0)return n;let t=n.content.replaceChild(n.childCount-1,ga(n.lastChild,e-1)),r=n.contentMatchAt(n.childCount).fillBefore(C.empty,!0);return n.copy(t.append(r))}function es(n,e,t,r,o,s){let i=e<0?n.firstChild:n.lastChild,l=i.content;return n.childCount>1&&(s=0),o<r-1&&(l=es(l,e,t,r,o+1,s)),o>=t&&(l=e<0?i.contentMatchAt(0).fillBefore(l,s<=o).append(l):l.append(i.contentMatchAt(i.childCount).fillBefore(C.empty,!0))),n.replaceChild(e<0?0:n.childCount-1,i.copy(l))}function ya(n,e,t){return e<n.openStart&&(n=new E(es(n.content,-1,e,n.openStart,0,n.openEnd),e,n.openEnd)),t<n.openEnd&&(n=new E(es(n.content,1,t,n.openEnd,0,0),n.openStart,t)),n}const ba={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};let xa=null;function ka(){return xa||(xa=document.implementation.createHTMLDocument("title"))}let ts=null;function Wh(n){let e=window.trustedTypes;return e?(ts||(ts=e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})),ts.createHTML(n)):n}function _h(n){let e=/^(\s*<meta [^>]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=ka().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(n),o;if((o=r&&ba[r[1].toLowerCase()])&&(n=o.map(s=>"<"+s+">").join("")+n+o.map(s=>"</"+s+">").reverse().join("")),t.innerHTML=Wh(n),o)for(let s=0;s<o.length;s++)t=t.querySelector(o[s])||t;return t}function qh(n){let e=n.querySelectorAll(ie?"span:not([class]):not([style])":"span.Apple-converted-space");for(let t=0;t<e.length;t++){let r=e[t];r.childNodes.length==1&&r.textContent==" "&&r.parentNode&&r.parentNode.replaceChild(n.ownerDocument.createTextNode(" "),r)}}function Hh(n,e){if(!n.size)return n;let t=n.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return n}let{content:o,openStart:s,openEnd:i}=n;for(let l=r.length-2;l>=0;l-=2){let a=t.nodes[r[l]];if(!a||a.hasRequiredAttrs())break;o=C.from(a.create(r[l+1],o)),s++,i++}return new E(o,s,i)}const fe={},de={},Kh={touchstart:!0,touchmove:!0};class Jh{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:""},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function Yh(n){for(let e in fe){let t=fe[e];n.dom.addEventListener(e,n.input.eventHandlers[e]=r=>{Xh(n,r)&&!rs(n,r)&&(n.editable||!(r.type in de))&&t(n,r)},Kh[e]?{passive:!0}:void 0)}ue&&n.dom.addEventListener("input",()=>null),ns(n)}function mt(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}function Gh(n){n.domObserver.stop();for(let e in n.input.eventHandlers)n.dom.removeEventListener(e,n.input.eventHandlers[e]);clearTimeout(n.input.composingTimeout),clearTimeout(n.input.lastIOSEnterFallbackTimeout)}function ns(n){n.someProp("handleDOMEvents",e=>{for(let t in e)n.input.eventHandlers[t]||n.dom.addEventListener(t,n.input.eventHandlers[t]=r=>rs(n,r))})}function rs(n,e){return n.someProp("handleDOMEvents",t=>{let r=t[e.type];return r?r(n,e)||e.defaultPrevented:!1})}function Xh(n,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target;t!=n.dom;t=t.parentNode)if(!t||t.nodeType==11||t.pmViewDesc&&t.pmViewDesc.stopEvent(e))return!1;return!0}function Uh(n,e){!rs(n,e)&&fe[e.type]&&(n.editable||!(e.type in de))&&fe[e.type](n,e)}de.keydown=(n,e)=>{let t=e;if(n.input.shiftKey=t.keyCode==16||t.shiftKey,!Ca(n,t)&&(n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),!(Qe&&ie&&t.keyCode==13)))if(t.keyCode!=229&&n.domObserver.forceFlush(),sn&&t.keyCode==13&&!t.ctrlKey&&!t.altKey&&!t.metaKey){let r=Date.now();n.input.lastIOSEnter=r,n.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{n.input.lastIOSEnter==r&&(n.someProp("handleKeyDown",o=>o(n,Rt(13,"Enter"))),n.input.lastIOSEnter=0)},200)}else n.someProp("handleKeyDown",r=>r(n,t))||Bh(n,t)?t.preventDefault():mt(n,"key")},de.keyup=(n,e)=>{e.keyCode==16&&(n.input.shiftKey=!1)},de.keypress=(n,e)=>{let t=e;if(Ca(n,t)||!t.charCode||t.ctrlKey&&!t.altKey||Ne&&t.metaKey)return;if(n.someProp("handleKeyPress",o=>o(n,t))){t.preventDefault();return}let r=n.state.selection;if(!(r instanceof V)||!r.$from.sameParent(r.$to)){let o=String.fromCharCode(t.charCode);!/[\r\n]/.test(o)&&!n.someProp("handleTextInput",s=>s(n,r.$from.pos,r.$to.pos,o))&&n.dispatch(n.state.tr.insertText(o).scrollIntoView()),t.preventDefault()}};function Vr(n){return{left:n.clientX,top:n.clientY}}function Qh(n,e){let t=e.x-n.clientX,r=e.y-n.clientY;return t*t+r*r<100}function ss(n,e,t,r,o){if(r==-1)return!1;let s=n.state.doc.resolve(r);for(let i=s.depth+1;i>0;i--)if(n.someProp(e,l=>i>s.depth?l(n,t,s.nodeAfter,s.before(i),o,!0):l(n,t,s.node(i),s.before(i),o,!1)))return!0;return!1}function un(n,e,t){if(n.focused||n.focus(),n.state.selection.eq(e))return;let r=n.state.tr.setSelection(e);r.setMeta("pointer",!0),n.dispatch(r)}function Zh(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),r=t.nodeAfter;return r&&r.isAtom&&v.isSelectable(r)?(un(n,new v(t)),!0):!1}function ep(n,e){if(e==-1)return!1;let t=n.state.selection,r,o;t instanceof v&&(r=t.node);let s=n.state.doc.resolve(e);for(let i=s.depth+1;i>0;i--){let l=i>s.depth?s.nodeAfter:s.node(i);if(v.isSelectable(l)){r&&t.$from.depth>0&&i>=t.$from.depth&&s.before(t.$from.depth+1)==t.$from.pos?o=s.before(t.$from.depth):o=s.before(i);break}}return o!=null?(un(n,v.create(n.state.doc,o)),!0):!1}function tp(n,e,t,r,o){return ss(n,"handleClickOn",e,t,r)||n.someProp("handleClick",s=>s(n,e,r))||(o?ep(n,t):Zh(n,t))}function np(n,e,t,r){return ss(n,"handleDoubleClickOn",e,t,r)||n.someProp("handleDoubleClick",o=>o(n,e,r))}function rp(n,e,t,r){return ss(n,"handleTripleClickOn",e,t,r)||n.someProp("handleTripleClick",o=>o(n,e,r))||op(n,t,r)}function op(n,e,t){if(t.button!=0)return!1;let r=n.state.doc;if(e==-1)return r.inlineContent?(un(n,V.create(r,0,r.content.size)),!0):!1;let o=r.resolve(e);for(let s=o.depth+1;s>0;s--){let i=s>o.depth?o.nodeAfter:o.node(s),l=o.before(s);if(i.inlineContent)un(n,V.create(r,l+1,l+1+i.content.size));else if(v.isSelectable(i))un(n,v.create(r,l));else continue;return!0}}function is(n){return Rr(n)}const Sa=Ne?"metaKey":"ctrlKey";fe.mousedown=(n,e)=>{let t=e;n.input.shiftKey=t.shiftKey;let r=is(n),o=Date.now(),s="singleClick";o-n.input.lastClick.time<500&&Qh(t,n.input.lastClick)&&!t[Sa]&&(n.input.lastClick.type=="singleClick"?s="doubleClick":n.input.lastClick.type=="doubleClick"&&(s="tripleClick")),n.input.lastClick={time:o,x:t.clientX,y:t.clientY,type:s};let i=n.posAtCoords(Vr(t));i&&(s=="singleClick"?(n.input.mouseDown&&n.input.mouseDown.done(),n.input.mouseDown=new sp(n,i,t,!!r)):(s=="doubleClick"?np:rp)(n,i.pos,i.inside,t)?t.preventDefault():mt(n,"pointer"))};let sp=class{constructor(e,t,r,o){this.view=e,this.pos=t,this.event=r,this.flushed=o,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!r[Sa],this.allowDefault=r.shiftKey;let s,i;if(t.inside>-1)s=e.state.doc.nodeAt(t.inside),i=t.inside;else{let u=e.state.doc.resolve(t.pos);s=u.parent,i=u.depth?u.before():0}const l=o?null:r.target,a=l?e.docView.nearestDesc(l,!0):null;this.target=a&&a.dom.nodeType==1?a.dom:null;let{selection:c}=e.state;(r.button==0&&s.type.spec.draggable&&s.type.spec.selectable!==!1||c instanceof v&&c.from<=i&&c.to>i)&&(this.mightDrag={node:s,pos:i,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Ie&&!this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this)),mt(e,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>et(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(Vr(e))),this.updateAllowDefault(e),this.allowDefault||!t?mt(this.view,"pointer"):tp(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||ue&&this.mightDrag&&!this.mightDrag.node.isAtom||ie&&!this.view.state.selection.visible&&Math.min(Math.abs(t.pos-this.view.state.selection.from),Math.abs(t.pos-this.view.state.selection.to))<=2)?(un(this.view,R.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):mt(this.view,"pointer")}move(e){this.updateAllowDefault(e),mt(this.view,"pointer"),e.buttons==0&&this.done()}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}};fe.touchstart=n=>{n.input.lastTouch=Date.now(),is(n),mt(n,"pointer")},fe.touchmove=n=>{n.input.lastTouch=Date.now(),mt(n,"pointer")},fe.contextmenu=n=>is(n);function Ca(n,e){return n.composing?!0:ue&&Math.abs(e.timeStamp-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}const ip=Qe?5e3:-1;de.compositionstart=de.compositionupdate=n=>{if(!n.composing){n.domObserver.flush();let{state:e}=n,t=e.selection.$to;if(e.selection instanceof V&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)))n.markCursor=n.state.storedMarks||t.marks(),Rr(n,!0),n.markCursor=null;else if(Rr(n,!e.selection.empty),Ie&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length){let r=n.domSelectionRange();for(let o=r.focusNode,s=r.focusOffset;o&&o.nodeType==1&&s!=0;){let i=s<0?o.lastChild:o.childNodes[s-1];if(!i)break;if(i.nodeType==3){let l=n.domSelection();l&&l.collapse(i,i.nodeValue.length);break}else o=i,s=-1}}n.input.composing=!0}wa(n,ip)},de.compositionend=(n,e)=>{n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=e.timeStamp,n.input.compositionPendingChanges=n.domObserver.pendingRecords().length?n.input.compositionID:0,n.input.compositionNode=null,n.input.compositionPendingChanges&&Promise.resolve().then(()=>n.domObserver.flush()),n.input.compositionID++,wa(n,20))};function wa(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>Rr(n),e))}function Ma(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=ap());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function lp(n){let e=n.domSelectionRange();if(!e.focusNode)return null;let t=Zd(e.focusNode,e.focusOffset),r=eh(e.focusNode,e.focusOffset);if(t&&r&&t!=r){let o=r.pmViewDesc,s=n.domObserver.lastChangedTextNode;if(t==s||r==s)return s;if(!o||!o.isText(r.nodeValue))return r;if(n.input.compositionNode==r){let i=t.pmViewDesc;if(!(!i||!i.isText(t.nodeValue)))return r}}return t||r}function ap(){let n=document.createEvent("Event");return n.initEvent("event",!0,!0),n.timeStamp}function Rr(n,e=!1){if(!(Qe&&n.domObserver.flushingSoon>=0)){if(n.domObserver.forceFlush(),Ma(n),e||n.docView&&n.docView.dirty){let t=Go(n);return t&&!t.eq(n.state.selection)?n.dispatch(n.state.tr.setSelection(t)):(n.markCursor||e)&&!n.state.selection.empty?n.dispatch(n.state.tr.deleteSelection()):n.updateState(n.state),!0}return!1}}function cp(n,e){if(!n.dom.parentNode)return;let t=n.dom.parentNode.appendChild(document.createElement("div"));t.appendChild(e),t.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),o=document.createRange();o.selectNodeContents(e),n.dom.blur(),r.removeAllRanges(),r.addRange(o),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t),n.focus()},50)}const Fn=ye&&dt<15||sn&&sh<604;fe.copy=de.cut=(n,e)=>{let t=e,r=n.state.selection,o=t.type=="cut";if(r.empty)return;let s=Fn?null:t.clipboardData,i=r.content(),{dom:l,text:a}=da(n,i);s?(t.preventDefault(),s.clearData(),s.setData("text/html",l.innerHTML),s.setData("text/plain",a)):cp(n,l),o&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function up(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function fp(n,e){if(!n.dom.parentNode)return;let t=n.input.shiftKey||n.state.selection.$from.parent.type.spec.code,r=n.dom.parentNode.appendChild(document.createElement(t?"textarea":"div"));t||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let o=n.input.shiftKey&&n.input.lastKeyCode!=45;setTimeout(()=>{n.focus(),r.parentNode&&r.parentNode.removeChild(r),t?Ln(n,r.value,null,o,e):Ln(n,r.textContent,r.innerHTML,o,e)},50)}function Ln(n,e,t,r,o){let s=ha(n,e,t,r,n.state.selection.$from);if(n.someProp("handlePaste",a=>a(n,o,s||E.empty)))return!0;if(!s)return!1;let i=up(s),l=i?n.state.tr.replaceSelectionWith(i,r):n.state.tr.replaceSelection(s);return n.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Na(n){let e=n.getData("text/plain")||n.getData("Text");if(e)return e;let t=n.getData("text/uri-list");return t?t.replace(/\r?\n/g," "):""}de.paste=(n,e)=>{let t=e;if(n.composing&&!Qe)return;let r=Fn?null:t.clipboardData,o=n.input.shiftKey&&n.input.lastKeyCode!=45;r&&Ln(n,Na(r),r.getData("text/html"),o,t)?t.preventDefault():fp(n,t)};let Ea=class{constructor(e,t,r){this.slice=e,this.move=t,this.node=r}};const Da=Ne?"altKey":"ctrlKey";fe.dragstart=(n,e)=>{let t=e,r=n.input.mouseDown;if(r&&r.done(),!t.dataTransfer)return;let o=n.state.selection,s=o.empty?null:n.posAtCoords(Vr(t)),i;if(!(s&&s.pos>=o.from&&s.pos<=(o instanceof v?o.to-1:o.to))){if(r&&r.mightDrag)i=v.create(n.state.doc,r.mightDrag.pos);else if(t.target&&t.target.nodeType==1){let f=n.docView.nearestDesc(t.target,!0);f&&f.node.type.spec.draggable&&f!=n.docView&&(i=v.create(n.state.doc,f.posBefore))}}let l=(i||n.state.selection).content(),{dom:a,text:c,slice:u}=da(n,l);(!t.dataTransfer.files.length||!ie||Al>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(Fn?"Text":"text/html",a.innerHTML),t.dataTransfer.effectAllowed="copyMove",Fn||t.dataTransfer.setData("text/plain",c),n.dragging=new Ea(u,!t[Da],i)},fe.dragend=n=>{let e=n.dragging;window.setTimeout(()=>{n.dragging==e&&(n.dragging=null)},50)},de.dragover=de.dragenter=(n,e)=>e.preventDefault(),de.drop=(n,e)=>{let t=e,r=n.dragging;if(n.dragging=null,!t.dataTransfer)return;let o=n.posAtCoords(Vr(t));if(!o)return;let s=n.state.doc.resolve(o.pos),i=r&&r.slice;i?n.someProp("transformPasted",h=>{i=h(i,n)}):i=ha(n,Na(t.dataTransfer),Fn?null:t.dataTransfer.getData("text/html"),!1,s);let l=!!(r&&!t[Da]);if(n.someProp("handleDrop",h=>h(n,t,i||E.empty,l))){t.preventDefault();return}if(!i)return;t.preventDefault();let a=i?Co(n.state.doc,s.pos,i):s.pos;a==null&&(a=s.pos);let c=n.state.tr;if(l){let{node:h}=r;h?h.replace(c):c.deleteSelection()}let u=c.mapping.map(a),f=i.openStart==0&&i.openEnd==0&&i.content.childCount==1,d=c.doc;if(f?c.replaceRangeWith(u,u,i.content.firstChild):c.replaceRange(u,u,i),c.doc.eq(d))return;let p=c.doc.resolve(u);if(f&&v.isSelectable(i.content.firstChild)&&p.nodeAfter&&p.nodeAfter.sameMarkup(i.content.firstChild))c.setSelection(new v(p));else{let h=c.mapping.map(a);c.mapping.maps[c.mapping.maps.length-1].forEach((b,g,x,S)=>h=S),c.setSelection(Uo(n,p,c.doc.resolve(h)))}n.focus(),n.dispatch(c.setMeta("uiEvent","drop"))},fe.focus=n=>{n.input.lastFocus=Date.now(),n.focused||(n.domObserver.stop(),n.dom.classList.add("ProseMirror-focused"),n.domObserver.start(),n.focused=!0,setTimeout(()=>{n.docView&&n.hasFocus()&&!n.domObserver.currentSelection.eq(n.domSelectionRange())&&et(n)},20))},fe.blur=(n,e)=>{let t=e;n.focused&&(n.domObserver.stop(),n.dom.classList.remove("ProseMirror-focused"),n.domObserver.start(),t.relatedTarget&&n.dom.contains(t.relatedTarget)&&n.domObserver.currentSelection.clear(),n.focused=!1)},fe.beforeinput=(n,e)=>{if(ie&&Qe&&e.inputType=="deleteContentBackward"){n.domObserver.flushSoon();let{domChangeCount:r}=n.input;setTimeout(()=>{if(n.input.domChangeCount!=r||(n.dom.blur(),n.focus(),n.someProp("handleKeyDown",s=>s(n,Rt(8,"Backspace")))))return;let{$cursor:o}=n.state.selection;o&&o.pos>0&&n.dispatch(n.state.tr.delete(o.pos-1,o.pos).scrollIntoView())},50)}};for(let n in de)fe[n]=de[n];function Wn(n,e){if(n==e)return!0;for(let t in n)if(n[t]!==e[t])return!1;for(let t in e)if(!(t in n))return!1;return!0}let va=class mf{constructor(e,t){this.toDOM=e,this.spec=t||jt,this.side=this.spec.side||0}map(e,t,r,o){let{pos:s,deleted:i}=e.mapResult(t.from+o,this.side<0?-1:1);return i?null:new Ve(s-r,s-r,this)}valid(){return!0}eq(e){return this==e||e instanceof mf&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Wn(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}},_n=class fi{constructor(e,t){this.attrs=e,this.spec=t||jt}map(e,t,r,o){let s=e.map(t.from+o,this.spec.inclusiveStart?-1:1)-r,i=e.map(t.to+o,this.spec.inclusiveEnd?1:-1)-r;return s>=i?null:new Ve(s,i,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof fi&&Wn(this.attrs,e.attrs)&&Wn(this.spec,e.spec)}static is(e){return e.type instanceof fi}destroy(){}},dp=class gf{constructor(e,t){this.attrs=e,this.spec=t||jt}map(e,t,r,o){let s=e.mapResult(t.from+o,1);if(s.deleted)return null;let i=e.mapResult(t.to+o,-1);return i.deleted||i.pos<=s.pos?null:new Ve(s.pos-r,i.pos-r,this)}valid(e,t){let{index:r,offset:o}=e.content.findIndex(t.from),s;return o==t.from&&!(s=e.child(r)).isText&&o+s.nodeSize==t.to}eq(e){return this==e||e instanceof gf&&Wn(this.attrs,e.attrs)&&Wn(this.spec,e.spec)}destroy(){}},Ve=class fr{constructor(e,t,r){this.from=e,this.to=t,this.type=r}copy(e,t){return new fr(e,t,this.type)}eq(e,t=0){return this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to}map(e,t,r){return this.type.map(e,this,t,r)}static widget(e,t,r){return new fr(e,e,new va(t,r))}static inline(e,t,r,o){return new fr(e,t,new _n(r,o))}static node(e,t,r,o){return new fr(e,t,new dp(r,o))}get spec(){return this.type.spec}get inline(){return this.type instanceof _n}get widget(){return this.type instanceof va}};const fn=[],jt={};let H=class vt{constructor(e,t){this.local=e.length?e:fn,this.children=t.length?t:fn}static create(e,t){return t.length?zr(t,e,0,jt):le}find(e,t,r){let o=[];return this.findInner(e??0,t??1e9,o,0,r),o}findInner(e,t,r,o,s){for(let i=0;i<this.local.length;i++){let l=this.local[i];l.from<=t&&l.to>=e&&(!s||s(l.spec))&&r.push(l.copy(l.from+o,l.to+o))}for(let i=0;i<this.children.length;i+=3)if(this.children[i]<t&&this.children[i+1]>e){let l=this.children[i]+1;this.children[i+2].findInner(e-l,t-l,r,o+l,s)}}map(e,t,r){return this==le||e.maps.length==0?this:this.mapInner(e,t,0,0,r||jt)}mapInner(e,t,r,o,s){let i;for(let l=0;l<this.local.length;l++){let a=this.local[l].map(e,r,o);a&&a.type.valid(t,a)?(i||(i=[])).push(a):s.onRemove&&s.onRemove(this.local[l].spec)}return this.children.length?hp(this.children,i||[],e,t,r,o,s):i?new vt(i.sort(Bt),fn):le}add(e,t){return t.length?this==le?vt.create(e,t):this.addInner(e,t,0):this}addInner(e,t,r){let o,s=0;e.forEach((l,a)=>{let c=a+r,u;if(u=Aa(t,l,c)){for(o||(o=this.children.slice());s<o.length&&o[s]<a;)s+=3;o[s]==a?o[s+2]=o[s+2].addInner(l,u,c+1):o.splice(s,0,a,a+l.nodeSize,zr(u,l,c+1,jt)),s+=3}});let i=Ta(s?Pa(t):t,-r);for(let l=0;l<i.length;l++)i[l].type.valid(e,i[l])||i.splice(l--,1);return new vt(i.length?this.local.concat(i).sort(Bt):this.local,o||this.children)}remove(e){return e.length==0||this==le?this:this.removeInner(e,0)}removeInner(e,t){let r=this.children,o=this.local;for(let s=0;s<r.length;s+=3){let i,l=r[s]+t,a=r[s+1]+t;for(let u=0,f;u<e.length;u++)(f=e[u])&&f.from>l&&f.to<a&&(e[u]=null,(i||(i=[])).push(f));if(!i)continue;r==this.children&&(r=this.children.slice());let c=r[s+2].removeInner(i,l+1);c!=le?r[s+2]=c:(r.splice(s,3),s-=3)}if(o.length){for(let s=0,i;s<e.length;s++)if(i=e[s])for(let l=0;l<o.length;l++)o[l].eq(i,t)&&(o==this.local&&(o=this.local.slice()),o.splice(l--,1))}return r==this.children&&o==this.local?this:o.length||r.length?new vt(o,r):le}forChild(e,t){if(this==le)return this;if(t.isLeaf)return vt.empty;let r,o;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=e){this.children[l]==e&&(r=this.children[l+2]);break}let s=e+1,i=s+t.content.size;for(let l=0;l<this.local.length;l++){let a=this.local[l];if(a.from<i&&a.to>s&&a.type instanceof _n){let c=Math.max(s,a.from)-s,u=Math.min(i,a.to)-s;c<u&&(o||(o=[])).push(a.copy(c,u))}}if(o){let l=new vt(o.sort(Bt),fn);return r?new Oa([l,r]):l}return r||le}eq(e){if(this==e)return!0;if(!(e instanceof vt)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let t=0;t<this.local.length;t++)if(!this.local[t].eq(e.local[t]))return!1;for(let t=0;t<this.children.length;t+=3)if(this.children[t]!=e.children[t]||this.children[t+1]!=e.children[t+1]||!this.children[t+2].eq(e.children[t+2]))return!1;return!0}locals(e){return ls(this.localsInner(e))}localsInner(e){if(this==le)return fn;if(e.inlineContent||!this.local.some(_n.is))return this.local;let t=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof _n||t.push(this.local[r]);return t}forEachSet(e){e(this)}};H.empty=new H([],[]),H.removeOverlap=ls;const le=H.empty;let Oa=class xn{constructor(e){this.members=e}map(e,t){const r=this.members.map(o=>o.map(e,t,jt));return xn.from(r)}forChild(e,t){if(t.isLeaf)return H.empty;let r=[];for(let o=0;o<this.members.length;o++){let s=this.members[o].forChild(e,t);s!=le&&(s instanceof xn?r=r.concat(s.members):r.push(s))}return xn.from(r)}eq(e){if(!(e instanceof xn)||e.members.length!=this.members.length)return!1;for(let t=0;t<this.members.length;t++)if(!this.members[t].eq(e.members[t]))return!1;return!0}locals(e){let t,r=!0;for(let o=0;o<this.members.length;o++){let s=this.members[o].localsInner(e);if(s.length)if(!t)t=s;else{r&&(t=t.slice(),r=!1);for(let i=0;i<s.length;i++)t.push(s[i])}}return t?ls(r?t:t.sort(Bt)):fn}static from(e){switch(e.length){case 0:return le;case 1:return e[0];default:return new xn(e.every(t=>t instanceof H)?e:e.reduce((t,r)=>t.concat(r instanceof H?r:r.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}};function hp(n,e,t,r,o,s,i){let l=n.slice();for(let c=0,u=s;c<t.maps.length;c++){let f=0;t.maps[c].forEach((d,p,h,b)=>{let g=b-h-(p-d);for(let x=0;x<l.length;x+=3){let S=l[x+1];if(S<0||d>S+u-f)continue;let w=l[x]+u-f;p>=w?l[x+1]=d<=w?-2:-1:d>=u&&g&&(l[x]+=g,l[x+1]+=g)}f+=g}),u=t.maps[c].map(u,-1)}let a=!1;for(let c=0;c<l.length;c+=3)if(l[c+1]<0){if(l[c+1]==-2){a=!0,l[c+1]=-1;continue}let u=t.map(n[c]+s),f=u-o;if(f<0||f>=r.content.size){a=!0;continue}let d=t.map(n[c+1]+s,-1),p=d-o,{index:h,offset:b}=r.content.findIndex(f),g=r.maybeChild(h);if(g&&b==f&&b+g.nodeSize==p){let x=l[c+2].mapInner(t,g,u+1,n[c]+s+1,i);x!=le?(l[c]=f,l[c+1]=p,l[c+2]=x):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=pp(l,n,e,t,o,s,i),u=zr(c,r,0,i);e=u.local;for(let f=0;f<l.length;f+=3)l[f+1]<0&&(l.splice(f,3),f-=3);for(let f=0,d=0;f<u.children.length;f+=3){let p=u.children[f];for(;d<l.length&&l[d]<p;)d+=3;l.splice(d,0,u.children[f],u.children[f+1],u.children[f+2])}}return new H(e.sort(Bt),l)}function Ta(n,e){if(!e||!n.length)return n;let t=[];for(let r=0;r<n.length;r++){let o=n[r];t.push(new Ve(o.from+e,o.to+e,o.type))}return t}function pp(n,e,t,r,o,s,i){function l(a,c){for(let u=0;u<a.local.length;u++){let f=a.local[u].map(r,o,c);f?t.push(f):i.onRemove&&i.onRemove(a.local[u].spec)}for(let u=0;u<a.children.length;u+=3)l(a.children[u+2],a.children[u]+c+1)}for(let a=0;a<n.length;a+=3)n[a+1]==-1&&l(n[a+2],e[a]+s+1);return t}function Aa(n,e,t){if(e.isLeaf)return null;let r=t+e.nodeSize,o=null;for(let s=0,i;s<n.length;s++)(i=n[s])&&i.from>t&&i.to<r&&((o||(o=[])).push(i),n[s]=null);return o}function Pa(n){let e=[];for(let t=0;t<n.length;t++)n[t]!=null&&e.push(n[t]);return e}function zr(n,e,t,r){let o=[],s=!1;e.forEach((l,a)=>{let c=Aa(n,l,a+t);if(c){s=!0;let u=zr(c,l,t+a+1,r);u!=le&&o.push(a,a+l.nodeSize,u)}});let i=Ta(s?Pa(n):n,-t).sort(Bt);for(let l=0;l<i.length;l++)i[l].type.valid(e,i[l])||(r.onRemove&&r.onRemove(i[l].spec),i.splice(l--,1));return i.length||o.length?new H(i,o):le}function Bt(n,e){return n.from-e.from||n.to-e.to}function ls(n){let e=n;for(let t=0;t<e.length-1;t++){let r=e[t];if(r.from!=r.to)for(let o=t+1;o<e.length;o++){let s=e[o];if(s.from==r.from){s.to!=r.to&&(e==n&&(e=n.slice()),e[o]=s.copy(s.from,r.to),Ia(e,o+1,s.copy(r.to,s.to)));continue}else{s.from<r.to&&(e==n&&(e=n.slice()),e[t]=r.copy(r.from,s.from),Ia(e,o,r.copy(s.from,r.to)));break}}}return e}function Ia(n,e,t){for(;e<n.length&&Bt(t,n[e])>0;)e++;n.splice(e,0,t)}function as(n){let e=[];return n.someProp("decorations",t=>{let r=t(n.state);r&&r!=le&&e.push(r)}),n.cursorWrapper&&e.push(H.create(n.state.doc,[n.cursorWrapper.deco])),Oa.from(e)}const mp={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},gp=ye&&dt<=11;let yp=class{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}};class bp{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new yp,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(r=>{for(let o=0;o<r.length;o++)this.queue.push(r[o]);ye&&dt<=11&&r.some(o=>o.type=="childList"&&o.removedNodes.length||o.type=="characterData"&&o.oldValue.length>o.target.nodeValue.length)?this.flushSoon():this.flush()}),gp&&(this.onCharData=r=>{this.queue.push({target:r.target,type:"characterData",oldValue:r.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,mp)),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(oa(this.view)){if(this.suppressingSelectionUpdates)return et(this.view);if(ye&&dt<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&Vt(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t=new Set,r;for(let s=e.focusNode;s;s=In(s))t.add(s);for(let s=e.anchorNode;s;s=In(s))if(t.has(s)){r=s;break}let o=r&&this.view.docView.nearestDesc(r);if(o&&o.ignoreMutation({type:"selection",target:r.nodeType==3?r.parentNode:r}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.pendingRecords();t.length&&(this.queue=[]);let r=e.domSelectionRange(),o=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(r)&&oa(e)&&!this.ignoreSelectionChange(r),s=-1,i=-1,l=!1,a=[];if(e.editable)for(let u=0;u<t.length;u++){let f=this.registerMutation(t[u],a);f&&(s=s<0?f.from:Math.min(f.from,s),i=i<0?f.to:Math.max(f.to,i),f.typeOver&&(l=!0))}if(Ie&&a.length){let u=a.filter(f=>f.nodeName=="BR");if(u.length==2){let[f,d]=u;f.parentNode&&f.parentNode.parentNode==d.parentNode?d.remove():f.remove()}else{let{focusNode:f}=this.currentSelection;for(let d of u){let p=d.parentNode;p&&p.nodeName=="LI"&&(!f||Sp(e,f)!=p)&&d.remove()}}}let c=null;s<0&&o&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&Tr(r)&&(c=Go(e))&&c.eq(R.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,et(e),this.currentSelection.set(r),e.scrollToSelection()):(s>-1||o)&&(s>-1&&(e.docView.markDirty(s,i),xp(e)),this.handleDOMChange(s,i,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||et(e),this.currentSelection.set(r))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let r=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(r==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!r||r.ignoreMutation(e))return null;if(e.type=="childList"){for(let u=0;u<e.addedNodes.length;u++){let f=e.addedNodes[u];t.push(f),f.nodeType==3&&(this.lastChangedTextNode=f)}if(r.contentDOM&&r.contentDOM!=r.dom&&!r.contentDOM.contains(e.target))return{from:r.posBefore,to:r.posAfter};let o=e.previousSibling,s=e.nextSibling;if(ye&&dt<=11&&e.addedNodes.length)for(let u=0;u<e.addedNodes.length;u++){let{previousSibling:f,nextSibling:d}=e.addedNodes[u];(!f||Array.prototype.indexOf.call(e.addedNodes,f)<0)&&(o=f),(!d||Array.prototype.indexOf.call(e.addedNodes,d)<0)&&(s=d)}let i=o&&o.parentNode==e.target?ne(o)+1:0,l=r.localPosFromDOM(e.target,i,-1),a=s&&s.parentNode==e.target?ne(s):e.target.childNodes.length,c=r.localPosFromDOM(e.target,a,1);return{from:l,to:c}}else return e.type=="attributes"?{from:r.posAtStart-r.border,to:r.posAtEnd+r.border}:(this.lastChangedTextNode=e.target,{from:r.posAtStart,to:r.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let Va=new WeakMap,Ra=!1;function xp(n){if(!Va.has(n)&&(Va.set(n,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(n.dom).whiteSpace)!==-1)){if(n.requiresGeckoHackNode=Ie,Ra)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."),Ra=!0}}function za(n,e){let t=e.startContainer,r=e.startOffset,o=e.endContainer,s=e.endOffset,i=n.domAtPos(n.state.selection.anchor);return Vt(i.node,i.offset,o,s)&&([t,r,o,s]=[o,s,t,r]),{anchorNode:t,anchorOffset:r,focusNode:o,focusOffset:s}}function kp(n,e){if(e.getComposedRanges){let o=e.getComposedRanges(n.root)[0];if(o)return za(n,o)}let t;function r(o){o.preventDefault(),o.stopImmediatePropagation(),t=o.getTargetRanges()[0]}return n.dom.addEventListener("beforeinput",r,!0),document.execCommand("indent"),n.dom.removeEventListener("beforeinput",r,!0),t?za(n,t):null}function Sp(n,e){for(let t=e.parentNode;t&&t!=n.dom;t=t.parentNode){let r=n.docView.nearestDesc(t,!0);if(r&&r.node.isBlock)return t}return null}function Cp(n,e,t){let{node:r,fromOffset:o,toOffset:s,from:i,to:l}=n.docView.parseRange(e,t),a=n.domSelectionRange(),c,u=a.anchorNode;if(u&&n.dom.contains(u.nodeType==1?u:u.parentNode)&&(c=[{node:u,offset:a.anchorOffset}],Tr(a)||c.push({node:a.focusNode,offset:a.focusOffset})),ie&&n.input.lastKeyCode===8)for(let g=s;g>o;g--){let x=r.childNodes[g-1],S=x.pmViewDesc;if(x.nodeName=="BR"&&!S){s=g;break}if(!S||S.size)break}let f=n.state.doc,d=n.someProp("domParser")||Pt.fromSchema(n.state.schema),p=f.resolve(i),h=null,b=d.parse(r,{topNode:p.parent,topMatch:p.parent.contentMatchAt(p.index()),topOpen:!0,from:o,to:s,preserveWhitespace:p.parent.type.whitespace=="pre"?"full":!0,findPositions:c,ruleFromNode:wp,context:p});if(c&&c[0].pos!=null){let g=c[0].pos,x=c[1]&&c[1].pos;x==null&&(x=g),h={anchor:g+i,head:x+i}}return{doc:b,sel:h,from:i,to:l}}function wp(n){let e=n.pmViewDesc;if(e)return e.parseRule();if(n.nodeName=="BR"&&n.parentNode){if(ue&&/^(ul|ol)$/i.test(n.parentNode.nodeName)){let t=document.createElement("div");return t.appendChild(document.createElement("li")),{skip:t}}else if(n.parentNode.lastChild==n||ue&&/^(tr|table)$/i.test(n.parentNode.nodeName))return{ignore:!0}}else if(n.nodeName=="IMG"&&n.getAttribute("mark-placeholder"))return{ignore:!0};return null}const Mp=/^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;function Np(n,e,t,r,o){let s=n.input.compositionPendingChanges||(n.composing?n.input.compositionID:0);if(n.input.compositionPendingChanges=0,e<0){let O=n.input.lastSelectionTime>Date.now()-50?n.input.lastSelectionOrigin:null,L=Go(n,O);if(L&&!n.state.selection.eq(L)){if(ie&&Qe&&n.input.lastKeyCode===13&&Date.now()-100<n.input.lastKeyCodeTime&&n.someProp("handleKeyDown",Et=>Et(n,Rt(13,"Enter"))))return;let we=n.state.tr.setSelection(L);O=="pointer"?we.setMeta("pointer",!0):O=="key"&&we.scrollIntoView(),s&&we.setMeta("composition",s),n.dispatch(we)}return}let i=n.state.doc.resolve(e),l=i.sharedDepth(t);e=i.before(l+1),t=n.state.doc.resolve(t).after(l+1);let a=n.state.selection,c=Cp(n,e,t),u=n.state.doc,f=u.slice(c.from,c.to),d,p;n.input.lastKeyCode===8&&Date.now()-100<n.input.lastKeyCodeTime?(d=n.state.selection.to,p="end"):(d=n.state.selection.from,p="start"),n.input.lastKeyCode=null;let h=vp(f.content,c.doc.content,c.from,d,p);if(h&&n.input.domChangeCount++,(sn&&n.input.lastIOSEnter>Date.now()-225||Qe)&&o.some(O=>O.nodeType==1&&!Mp.test(O.nodeName))&&(!h||h.endA>=h.endB)&&n.someProp("handleKeyDown",O=>O(n,Rt(13,"Enter")))){n.input.lastIOSEnter=0;return}if(!h)if(r&&a instanceof V&&!a.empty&&a.$head.sameParent(a.$anchor)&&!n.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))h={start:a.from,endA:a.to,endB:a.to};else{if(c.sel){let O=$a(n,n.state.doc,c.sel);if(O&&!O.eq(n.state.selection)){let L=n.state.tr.setSelection(O);s&&L.setMeta("composition",s),n.dispatch(L)}}return}n.state.selection.from<n.state.selection.to&&h.start==h.endB&&n.state.selection instanceof V&&(h.start>n.state.selection.from&&h.start<=n.state.selection.from+2&&n.state.selection.from>=c.from?h.start=n.state.selection.from:h.endA<n.state.selection.to&&h.endA>=n.state.selection.to-2&&n.state.selection.to<=c.to&&(h.endB+=n.state.selection.to-h.endA,h.endA=n.state.selection.to)),ye&&dt<=11&&h.endB==h.start+1&&h.endA==h.start&&h.start>c.from&&c.doc.textBetween(h.start-c.from-1,h.start-c.from+1)==" "&&(h.start--,h.endA--,h.endB--);let b=c.doc.resolveNoCache(h.start-c.from),g=c.doc.resolveNoCache(h.endB-c.from),x=u.resolve(h.start),S=b.sameParent(g)&&b.parent.inlineContent&&x.end()>=h.endA,w;if((sn&&n.input.lastIOSEnter>Date.now()-225&&(!S||o.some(O=>O.nodeName=="DIV"||O.nodeName=="P"))||!S&&b.pos<c.doc.content.size&&!b.sameParent(g)&&(w=R.findFrom(c.doc.resolve(b.pos+1),1,!0))&&w.head==g.pos)&&n.someProp("handleKeyDown",O=>O(n,Rt(13,"Enter")))){n.input.lastIOSEnter=0;return}if(n.state.selection.anchor>h.start&&Dp(u,h.start,h.endA,b,g)&&n.someProp("handleKeyDown",O=>O(n,Rt(8,"Backspace")))){Qe&&ie&&n.domObserver.suppressSelectionUpdates();return}ie&&h.endB==h.start&&(n.input.lastChromeDelete=Date.now()),Qe&&!S&&b.start()!=g.start()&&g.parentOffset==0&&b.depth==g.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==h.endA&&(h.endB-=2,g=c.doc.resolveNoCache(h.endB-c.from),setTimeout(()=>{n.someProp("handleKeyDown",function(O){return O(n,Rt(13,"Enter"))})},20));let D=h.start,T=h.endA,M,I,z;if(S){if(b.pos==g.pos)ye&&dt<=11&&b.parentOffset==0&&(n.domObserver.suppressSelectionUpdates(),setTimeout(()=>et(n),20)),M=n.state.tr.delete(D,T),I=u.resolve(h.start).marksAcross(u.resolve(h.endA));else if(h.endA==h.endB&&(z=Ep(b.parent.content.cut(b.parentOffset,g.parentOffset),x.parent.content.cut(x.parentOffset,h.endA-x.start()))))M=n.state.tr,z.type=="add"?M.addMark(D,T,z.mark):M.removeMark(D,T,z.mark);else if(b.parent.child(b.index()).isText&&b.index()==g.index()-(g.textOffset?0:1)){let O=b.parent.textBetween(b.parentOffset,g.parentOffset);if(n.someProp("handleTextInput",L=>L(n,D,T,O)))return;M=n.state.tr.insertText(O,D,T)}}if(M||(M=n.state.tr.replace(D,T,c.doc.slice(h.start-c.from,h.endB-c.from))),c.sel){let O=$a(n,M.doc,c.sel);O&&!(ie&&n.composing&&O.empty&&(h.start!=h.endB||n.input.lastChromeDelete<Date.now()-100)&&(O.head==D||O.head==M.mapping.map(T)-1)||ye&&O.empty&&O.head==D)&&M.setSelection(O)}I&&M.ensureMarks(I),s&&M.setMeta("composition",s),n.dispatch(M.scrollIntoView())}function $a(n,e,t){return Math.max(t.anchor,t.head)>e.content.size?null:Uo(n,e.resolve(t.anchor),e.resolve(t.head))}function Ep(n,e){let t=n.firstChild.marks,r=e.firstChild.marks,o=t,s=r,i,l,a;for(let u=0;u<r.length;u++)o=r[u].removeFromSet(o);for(let u=0;u<t.length;u++)s=t[u].removeFromSet(s);if(o.length==1&&s.length==0)l=o[0],i="add",a=u=>u.mark(l.addToSet(u.marks));else if(o.length==0&&s.length==1)l=s[0],i="remove",a=u=>u.mark(l.removeFromSet(u.marks));else return null;let c=[];for(let u=0;u<e.childCount;u++)c.push(a(e.child(u)));if(C.from(c).eq(n))return{mark:l,type:i}}function Dp(n,e,t,r,o){if(t-e<=o.pos-r.pos||cs(r,!0,!1)<o.pos)return!1;let s=n.resolve(e);if(!r.parent.isTextblock){let l=s.nodeAfter;return l!=null&&t==e+l.nodeSize}if(s.parentOffset<s.parent.content.size||!s.parent.isTextblock)return!1;let i=n.resolve(cs(s,!0,!0));return!i.parent.isTextblock||i.pos>t||cs(i,!0,!1)<t?!1:r.parent.content.cut(r.parentOffset).eq(i.parent.content)}function cs(n,e,t){let r=n.depth,o=e?n.end():n.pos;for(;r>0&&(e||n.indexAfter(r)==n.node(r).childCount);)r--,o++,e=!1;if(t){let s=n.node(r).maybeChild(n.indexAfter(r));for(;s&&!s.isLeaf;)s=s.firstChild,o++}return o}function vp(n,e,t,r,o){let s=n.findDiffStart(e,t);if(s==null)return null;let{a:i,b:l}=n.findDiffEnd(e,t+n.size,t+e.size);if(o=="end"){let a=Math.max(0,s-Math.min(i,l));r-=i+a-s}if(i<s&&n.size<e.size){let a=r<=s&&r>=i?s-r:0;s-=a,s&&s<e.size&&ja(e.textBetween(s-1,s+1))&&(s+=a?1:-1),l=s+(l-i),i=s}else if(l<s){let a=r<=s&&r>=l?s-r:0;s-=a,s&&s<n.size&&ja(n.textBetween(s-1,s+1))&&(s+=a?1:-1),i=s+(i-l),l=s}return{start:s,endA:i,endB:l}}function ja(n){if(n.length!=2)return!1;let e=n.charCodeAt(0),t=n.charCodeAt(1);return e>=56320&&e<=57343&&t>=55296&&t<=56319}class Op{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 Jh,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(_a),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):typeof e=="function"?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=La(this),Fa(this),this.nodeViews=Wa(this),this.docView=Hl(this.state.doc,Ba(this),as(this),this.dom,this),this.domObserver=new bp(this,(r,o,s,i)=>Np(this,r,o,s,i)),this.domObserver.start(),Yh(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let t in e)this._props[t]=e[t];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&ns(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(_a),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let r in this._props)t[r]=this._props[r];t.state=this.state;for(let r in e)t[r]=e[r];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var r;let o=this.state,s=!1,i=!1;e.storedMarks&&this.composing&&(Ma(this),i=!0),this.state=e;let l=o.plugins!=e.plugins||this._props.plugins!=t.plugins;if(l||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let p=Wa(this);Ap(p,this.nodeViews)&&(this.nodeViews=p,s=!0)}(l||t.handleDOMEvents!=this._props.handleDOMEvents)&&ns(this),this.editable=La(this),Fa(this);let a=as(this),c=Ba(this),u=o.plugins!=e.plugins&&!o.doc.eq(e.doc)?"reset":e.scrollToSelection>o.scrollToSelection?"to selection":"preserve",f=s||!this.docView.matchesNode(e.doc,c,a);(f||!e.selection.eq(o.selection))&&(i=!0);let d=u=="preserve"&&i&&this.dom.style.overflowAnchor==null&&ah(this);if(i){this.domObserver.stop();let p=f&&(ye||ie)&&!this.composing&&!o.selection.empty&&!e.selection.empty&&Tp(o.selection,e.selection);if(f){let h=ie?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=lp(this)),(s||!this.docView.update(e.doc,c,a,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=Hl(e.doc,c,a,this.dom,this)),h&&!this.trackWrites&&(p=!0)}p||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&Ph(this))?et(this,p):(na(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(o),!((r=this.dragging)===null||r===void 0)&&r.node&&!o.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,o),u=="reset"?this.dom.scrollTop=0:u=="to selection"?this.scrollToSelection():d&&ch(d)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof v){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&Pl(this,t.getBoundingClientRect(),e)}else Pl(this,this.coordsAtPos(this.state.selection.head,1),e)}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let t=0;t<this.directPlugins.length;t++){let r=this.directPlugins[t];r.spec.view&&this.pluginViews.push(r.spec.view(this))}for(let t=0;t<this.state.plugins.length;t++){let r=this.state.plugins[t];r.spec.view&&this.pluginViews.push(r.spec.view(this))}}else for(let t=0;t<this.pluginViews.length;t++){let r=this.pluginViews[t];r.update&&r.update(this,e)}}updateDraggedNode(e,t){let r=e.node,o=-1;if(this.state.doc.nodeAt(r.from)==r.node)o=r.from;else{let s=r.from+(this.state.doc.content.size-t.doc.content.size);(s>0&&this.state.doc.nodeAt(s))==r.node&&(o=s)}this.dragging=new Ea(e.slice,e.move,o<0?void 0:v.create(this.state.doc,o))}someProp(e,t){let r=this._props&&this._props[e],o;if(r!=null&&(o=t?t(r):r))return o;for(let i=0;i<this.directPlugins.length;i++){let l=this.directPlugins[i].props[e];if(l!=null&&(o=t?t(l):l))return o}let s=this.state.plugins;if(s)for(let i=0;i<s.length;i++){let l=s[i].props[e];if(l!=null&&(o=t?t(l):l))return o}}hasFocus(){if(ye){let e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if(e.contentEditable=="false")return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&uh(this.dom),et(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let t=this.dom.parentNode;t;t=t.parentNode)if(t.nodeType==9||t.nodeType==11&&t.host)return t.getSelection||(Object.getPrototypeOf(t).getSelection=()=>t.ownerDocument.getSelection()),this._root=t}return e||document}updateRoot(){this._root=null}posAtCoords(e){return mh(this,e)}coordsAtPos(e,t=1){return jl(this,e,t)}domAtPos(e,t=0){return this.docView.domFromPos(e,t)}nodeDOM(e){let t=this.docView.descAt(e);return t?t.nodeDOM:null}posAtDOM(e,t,r=-1){let o=this.docView.posFromDOM(e,t,r);if(o==null)throw new RangeError("DOM position not inside the editor");return o}endOfTextblock(e,t){return kh(this,t||this.state,e)}pasteHTML(e,t){return Ln(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return Ln(this,e,null,!0,t||new ClipboardEvent("paste"))}destroy(){this.docView&&(Gh(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],as(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Ud())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return Uh(this,e)}dispatch(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))}domSelectionRange(){let e=this.domSelection();return e?ue&&this.root.nodeType===11&&nh(this.dom.ownerDocument)==this.dom&&kp(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}function Ba(n){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(n.editable),n.someProp("attributes",t=>{if(typeof t=="function"&&(t=t(n.state)),t)for(let r in t)r=="class"?e.class+=" "+t[r]:r=="style"?e.style=(e.style?e.style+";":"")+t[r]:!e[r]&&r!="contenteditable"&&r!="nodeName"&&(e[r]=String(t[r]))}),e.translate||(e.translate="no"),[Ve.node(0,n.state.doc.content.size,e)]}function Fa(n){if(n.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),n.cursorWrapper={dom:e,deco:Ve.widget(n.state.selection.from,e,{raw:!0,marks:n.markCursor})}}else n.cursorWrapper=null}function La(n){return!n.someProp("editable",e=>e(n.state)===!1)}function Tp(n,e){let t=Math.min(n.$anchor.sharedDepth(n.head),e.$anchor.sharedDepth(e.head));return n.$anchor.start(t)!=e.$anchor.start(t)}function Wa(n){let e=Object.create(null);function t(r){for(let o in r)Object.prototype.hasOwnProperty.call(e,o)||(e[o]=r[o])}return n.someProp("nodeViews",t),n.someProp("markViews",t),e}function Ap(n,e){let t=0,r=0;for(let o in n){if(n[o]!=e[o])return!0;t++}for(let o in e)r++;return t!=r}function _a(n){if(n.spec.state||n.spec.filterTransaction||n.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}class q extends R{constructor(e){super(e,e)}map(e,t){let r=e.resolve(t.map(this.head));return q.valid(r)?new q(r):R.near(r)}content(){return E.empty}eq(e){return e instanceof q&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new q(e.resolve(t.pos))}getBookmark(){return new us(this.anchor)}static valid(e){let t=e.parent;if(t.isTextblock||!Pp(e)||!Ip(e))return!1;let r=t.type.spec.allowGapCursor;if(r!=null)return r;let o=t.contentMatchAt(e.index()).defaultType;return o&&o.isTextblock}static findGapCursorFrom(e,t,r=!1){e:for(;;){if(!r&&q.valid(e))return e;let o=e.pos,s=null;for(let i=e.depth;;i--){let l=e.node(i);if(t>0?e.indexAfter(i)<l.childCount:e.index(i)>0){s=l.child(t>0?e.indexAfter(i):e.index(i)-1);break}else if(i==0)return null;o+=t;let a=e.doc.resolve(o);if(q.valid(a))return a}for(;;){let i=t>0?s.firstChild:s.lastChild;if(!i){if(s.isAtom&&!s.isText&&!v.isSelectable(s)){e=e.doc.resolve(o+s.nodeSize*t),r=!1;continue e}break}s=i,o+=t;let l=e.doc.resolve(o);if(q.valid(l))return l}return null}}}q.prototype.visible=!1,q.findFrom=q.findGapCursorFrom,R.jsonID("gapcursor",q);class us{constructor(e){this.pos=e}map(e){return new us(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return q.valid(t)?new q(t):R.near(t)}}function Pp(n){for(let e=n.depth;e>=0;e--){let t=n.index(e),r=n.node(e);if(t==0){if(r.type.spec.isolating)return!0;continue}for(let o=r.child(t-1);;o=o.lastChild){if(o.childCount==0&&!o.inlineContent||o.isAtom||o.type.spec.isolating)return!0;if(o.inlineContent)return!1}}return!0}function Ip(n){for(let e=n.depth;e>=0;e--){let t=n.indexAfter(e),r=n.node(e);if(t==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let o=r.child(t);;o=o.firstChild){if(o.childCount==0&&!o.inlineContent||o.isAtom||o.type.spec.isolating)return!0;if(o.inlineContent)return!1}}return!0}function Vp(){return new Be({props:{decorations:jp,createSelectionBetween(n,e,t){return e.pos==t.pos&&q.valid(t)?new q(t):null},handleClick:zp,handleKeyDown:Rp,handleDOMEvents:{beforeinput:$p}}})}const Rp=zo({ArrowLeft:$r("horiz",-1),ArrowRight:$r("horiz",1),ArrowUp:$r("vert",-1),ArrowDown:$r("vert",1)});function $r(n,e){const t=n=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,o,s){let i=r.selection,l=e>0?i.$to:i.$from,a=i.empty;if(i instanceof V){if(!s.endOfTextblock(t)||l.depth==0)return!1;a=!1,l=r.doc.resolve(e>0?l.after():l.before())}let c=q.findGapCursorFrom(l,e,a);return c?(o&&o(r.tr.setSelection(new q(c))),!0):!1}}function zp(n,e,t){if(!n||!n.editable)return!1;let r=n.state.doc.resolve(e);if(!q.valid(r))return!1;let o=n.posAtCoords({left:t.clientX,top:t.clientY});return o&&o.inside>-1&&v.isSelectable(n.state.doc.nodeAt(o.inside))?!1:(n.dispatch(n.state.tr.setSelection(new q(r))),!0)}function $p(n,e){if(e.inputType!="insertCompositionText"||!(n.state.selection instanceof q))return!1;let{$from:t}=n.state.selection,r=t.parent.contentMatchAt(t.index()).findWrapping(n.state.schema.nodes.text);if(!r)return!1;let o=C.empty;for(let i=r.length-1;i>=0;i--)o=C.from(r[i].createAndFill(null,o));let s=n.state.tr.replace(t.pos,t.pos,new E(o,0,0));return s.setSelection(V.near(s.doc.resolve(t.pos+1))),n.dispatch(s),!1}function jp(n){if(!(n.selection instanceof q))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",H.create(n.doc,[Ve.widget(n.selection.head,e,{key:"gapcursor"})])}const Bp=["ol",0],Fp=["ul",0],Lp=["li",0],Wp={attrs:{order:{default:1,validate:"number"}},parseDOM:[{tag:"ol",getAttrs(n){return{order:n.hasAttribute("start")?+n.getAttribute("start"):1}}}],toDOM(n){return n.attrs.order==1?Bp:["ol",{start:n.attrs.order},0]}},_p={parseDOM:[{tag:"ul"}],toDOM(){return Fp}},qp={parseDOM:[{tag:"li"}],toDOM(){return Lp},defining:!0};function fs(n,e){let t={};for(let r in n)t[r]=n[r];for(let r in e)t[r]=e[r];return t}function Hp(n,e,t){return n.append({ordered_list:fs(Wp,{content:"list_item+",group:t}),bullet_list:fs(_p,{content:"list_item+",group:t}),list_item:fs(qp,{content:e})})}function jr(n,e=null){return function(t,r){let{$from:o,$to:s}=t.selection,i=o.blockRange(s);if(!i)return!1;let l=r?t.tr:null;return Kp(l,i,n,e)?(r&&r(l.scrollIntoView()),!0):!1}}function Kp(n,e,t,r=null){let o=!1,s=e,i=e.$from.doc;if(e.depth>=2&&e.$from.node(e.depth-1).type.compatibleContent(t)&&e.startIndex==0){if(e.$from.index(e.depth-1)==0)return!1;let a=i.resolve(e.start-2);s=new gr(a,a,e.depth),e.endIndex<e.parent.childCount&&(e=new gr(e.$from,i.resolve(e.$to.end(e.depth)),e.depth)),o=!0}let l=So(s,t,r,e);return l?(n&&Jp(n,e,l,o,t),!0):!1}function Jp(n,e,t,r,o){let s=C.empty;for(let u=t.length-1;u>=0;u--)s=C.from(t[u].type.create(t[u].attrs,s));n.step(new ee(e.start-(r?2:0),e.end,e.start,e.end,new E(s,0,0),t.length,!0));let i=0;for(let u=0;u<t.length;u++)t[u].type==o&&(i=u+1);let l=t.length-i,a=e.start+t.length-(r?2:0),c=e.parent;for(let u=e.startIndex,f=e.endIndex,d=!0;u<f;u++,d=!1)!d&&Qt(n.doc,a,l)&&(n.split(a,l),a+=2*l),a+=c.child(u).nodeSize;return n}function Yp(n,e){return function(t,r){let{$from:o,$to:s,node:i}=t.selection;if(i&&i.isBlock||o.depth<2||!o.sameParent(s))return!1;let l=o.node(-1);if(l.type!=n)return!1;if(o.parent.content.size==0&&o.node(-1).childCount==o.indexAfter(-1)){if(o.depth==3||o.node(-3).type!=n||o.index(-2)!=o.node(-2).childCount-1)return!1;if(r){let f=C.empty,d=o.index(-1)?1:o.index(-2)?2:3;for(let x=o.depth-d;x>=o.depth-3;x--)f=C.from(o.node(x).copy(f));let p=o.indexAfter(-1)<o.node(-2).childCount?1:o.indexAfter(-2)<o.node(-3).childCount?2:3;f=f.append(C.from(n.createAndFill()));let h=o.before(o.depth-(d-1)),b=t.tr.replace(h,o.after(-p),new E(f,4-d,0)),g=-1;b.doc.nodesBetween(h,b.doc.content.size,(x,S)=>{if(g>-1)return!1;x.isTextblock&&x.content.size==0&&(g=S+1)}),g>-1&&b.setSelection(R.near(b.doc.resolve(g))),r(b.scrollIntoView())}return!0}let a=s.pos==o.end()?l.contentMatchAt(0).defaultType:null,c=t.tr.delete(o.pos,s.pos),u=a?[null,{type:a}]:void 0;return Qt(c.doc,o.pos,2,u)?(r&&r(c.split(o.pos,2,u).scrollIntoView()),!0):!1}}function Gp(n){return function(e,t){let{$from:r,$to:o}=e.selection,s=r.blockRange(o,i=>i.childCount>0&&i.firstChild.type==n);return s?t?r.node(s.depth-1).type==n?Xp(e,t,n,s):Up(e,t,s):!0:!1}}function Xp(n,e,t,r){let o=n.tr,s=r.end,i=r.$to.end(r.depth);s<i&&(o.step(new ee(s-1,i,s,i,new E(C.from(t.create(null,r.parent.copy())),1,0),1,!0)),r=new gr(o.doc.resolve(r.$from.pos),o.doc.resolve(i),r.depth));const l=vn(r);if(l==null)return!1;o.lift(r,l);let a=o.doc.resolve(o.mapping.map(s,-1)-1);return Zt(o.doc,a.pos)&&a.nodeBefore.type==a.nodeAfter.type&&o.join(a.pos),e(o.scrollIntoView()),!0}function Up(n,e,t){let r=n.tr,o=t.parent;for(let p=t.end,h=t.endIndex-1,b=t.startIndex;h>b;h--)p-=o.child(h).nodeSize,r.delete(p-1,p+1);let s=r.doc.resolve(t.start),i=s.nodeAfter;if(r.mapping.map(t.end)!=t.start+s.nodeAfter.nodeSize)return!1;let l=t.startIndex==0,a=t.endIndex==o.childCount,c=s.node(-1),u=s.index(-1);if(!c.canReplace(u+(l?0:1),u+1,i.content.append(a?C.empty:C.from(o))))return!1;let f=s.pos,d=f+i.nodeSize;return r.step(new ee(f-(l?1:0),d+(a?1:0),f+1,d-1,new E((l?C.empty:C.from(o.copy(C.empty))).append(a?C.empty:C.from(o.copy(C.empty))),l?0:1,a?0:1),l?0:1)),e(r.scrollIntoView()),!0}function Qp(n){return function(e,t){let{$from:r,$to:o}=e.selection,s=r.blockRange(o,c=>c.childCount>0&&c.firstChild.type==n);if(!s)return!1;let i=s.startIndex;if(i==0)return!1;let l=s.parent,a=l.child(i-1);if(a.type!=n)return!1;if(t){let c=a.lastChild&&a.lastChild.type==l.type,u=C.from(c?n.create():null),f=new E(C.from(n.create(null,C.from(l.type.create(null,u)))),c?3:1,0),d=s.start,p=s.end;t(e.tr.step(new ee(d-(c?3:1),p,d,p,f,1,!0)).scrollIntoView())}return!0}}class gt{constructor(e,t,r={}){this.match=e,this.match=e,this.handler=typeof t=="string"?Zp(t):t,this.undoable=r.undoable!==!1,this.inCode=r.inCode||!1,this.inCodeMark=r.inCodeMark!==!1}}function Zp(n){return function(e,t,r,o){let s=n;if(t[1]){let i=t[0].lastIndexOf(t[1]);s+=t[0].slice(i+t[1].length),r+=i;let l=r-o;l>0&&(s=t[0].slice(i-l,i)+s,r=o)}return e.tr.insertText(s,r,o)}}const em=500;function tm({rules:n}){let e=new Be({state:{init(){return null},apply(t,r){let o=t.getMeta(this);return o||(t.selectionSet||t.docChanged?null:r)}},props:{handleTextInput(t,r,o,s){return qa(t,r,o,s,n,e)},handleDOMEvents:{compositionend:t=>{setTimeout(()=>{let{$cursor:r}=t.state.selection;r&&qa(t,r.pos,r.pos,"",n,e)})}}},isInputRules:!0});return e}function qa(n,e,t,r,o,s){if(n.composing)return!1;let i=n.state,l=i.doc.resolve(e),a=l.parent.textBetween(Math.max(0,l.parentOffset-em),l.parentOffset,null,"")+r;for(let c=0;c<o.length;c++){let u=o[c];if(!u.inCodeMark&&l.marks().some(p=>p.type.spec.code))continue;if(l.parent.type.spec.code){if(!u.inCode)continue}else if(u.inCode==="only")continue;let f=u.match.exec(a),d=f&&f[0].length>=r.length&&u.handler(i,f,e-(f[0].length-r.length),t);if(d)return u.undoable&&d.setMeta(s,{transform:d,from:e,to:t,text:r}),n.dispatch(d),!0}return!1}const nm=(n,e)=>{let t=n.plugins;for(let r=0;r<t.length;r++){let o=t[r],s;if(o.spec.isInputRules&&(s=o.getState(n))){if(e){let i=n.tr,l=s.transform;for(let a=l.steps.length-1;a>=0;a--)i.step(l.steps[a].invert(l.docs[a]));if(s.text){let a=i.doc.resolve(s.from).marks();i.replaceWith(s.from,s.to,n.schema.text(s.text,a))}else i.delete(s.from,s.to);e(i)}return!0}}return!1},rm=new gt(/--$/,"—",{inCodeMark:!1}),om=new gt(/\.\.\.$/,"…",{inCodeMark:!1}),sm=new gt(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,"“",{inCodeMark:!1}),im=new gt(/"$/,"”",{inCodeMark:!1}),lm=new gt(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,"‘",{inCodeMark:!1}),am=new gt(/'$/,"’",{inCodeMark:!1}),cm=[sm,im,lm,am];function ds(n,e,t=null,r){return new gt(n,(o,s,i,l)=>{let a=t instanceof Function?t(s):t,c=o.tr.delete(i,l),u=c.doc.resolve(i),f=u.blockRange(),d=f&&So(f,e,a);if(!d)return null;c.wrap(f,d);let p=c.doc.resolve(i-1).nodeBefore;return p&&p.type==e&&Zt(c.doc,i-1)&&(!r||r(s,p))&&c.join(i-1),c})}function Ha(n,e,t=null){return new gt(n,(r,o,s,i)=>{let l=r.doc.resolve(s),a=t instanceof Function?t(o):t;return l.node(-1).canReplaceWith(l.index(-1),l.indexAfter(-1),e)?r.tr.delete(s,i).setBlockType(s,s,e,a):null})}const Ka=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):!1;function um(n,e){let t={},r;function o(s,i){t[s]=i}if(o("Mod-z",Po),o("Shift-Mod-z",Dr),o("Backspace",nm),Ka||o("Mod-y",Dr),o("Alt-ArrowUp",Sl),o("Alt-ArrowDown",$d),o("Mod-BracketLeft",$o),o("Escape",Bo),(r=n.marks.strong)&&(o("Mod-b",ke(r)),o("Mod-B",ke(r))),(r=n.marks.em)&&(o("Mod-i",ke(r)),o("Mod-I",ke(r))),(r=n.marks.code)&&o("Mod-`",ke(r)),(r=n.nodes.bullet_list)&&o("Shift-Ctrl-8",jr(r)),(r=n.nodes.ordered_list)&&o("Shift-Ctrl-9",jr(r)),(r=n.nodes.blockquote)&&o("Ctrl->",Nl(r)),r=n.nodes.hard_break){let s=r,i=Or(Cl,(l,a)=>(a&&a(l.tr.replaceSelectionWith(s.create()).scrollIntoView()),!0));o("Mod-Enter",i),o("Shift-Enter",i),Ka&&o("Ctrl-Enter",i)}if((r=n.nodes.list_item)&&(o("Enter",Yp(r)),o("Mod-[",Gp(r)),o("Mod-]",Qp(r))),(r=n.nodes.paragraph)&&o("Shift-Ctrl-0",on(r)),(r=n.nodes.code_block)&&o("Shift-Ctrl-\\",on(r)),r=n.nodes.heading)for(let s=1;s<=6;s++)o("Shift-Ctrl-"+s,on(r,{level:s}));if(r=n.nodes.horizontal_rule){let s=r;o("Mod-_",(i,l)=>(l&&l(i.tr.replaceSelectionWith(s.create()).scrollIntoView()),!0))}return t}function fm(n){return ds(/^\s*>\s$/,n)}function dm(n){return ds(/^(\d+)\.\s$/,n,e=>({order:+e[1]}),(e,t)=>t.childCount+t.attrs.order==+e[1])}function hm(n){return ds(/^\s*([-+*])\s$/,n)}function pm(n){return Ha(/^```$/,n)}function mm(n,e){return Ha(new RegExp("^(#{1,"+e+"})\\s$"),n,t=>({level:t[1].length}))}function gm(n){let e=cm.concat(om,rm),t;return(t=n.nodes.blockquote)&&e.push(fm(t)),(t=n.nodes.ordered_list)&&e.push(dm(t)),(t=n.nodes.bullet_list)&&e.push(hm(t)),(t=n.nodes.code_block)&&e.push(pm(t)),(t=n.nodes.heading)&&e.push(mm(t,6)),tm({rules:e})}const tt=new lt("ImagePluginKey"),ym=n=>new Be({key:tt,state:{init(){return{set:H.empty,schema:n.schema,upload:n.upload}},apply(t,r){let o=r.set.map(t.mapping,t.doc);const s=t.getMeta(tt);if(s&&s.add){const i=document.createElement("placeholder"),l=Ve.widget(s.add.pos,i,{id:s.add.id,key:`imgphd${s.add.id}`});o=o.add(t.doc,[l])}else s&&s.remove&&(o=o.remove(o.find(void 0,void 0,i=>i.id==s.remove.id)));return{...r,set:o}}},props:{decorations(t){var r;return(r=this.getState(t))==null?void 0:r.set}}}),bm=(n,e)=>{const t=tt.getState(n).set,r=t==null?void 0:t.find(void 0,void 0,o=>o.id==e);return r!=null&&r.length?r[0].from:null},xm=async(n,e,t,r)=>{if(!e)return;const o=Date.now(),s=n.state.tr;r===void 0&&(s.selection.empty||s.deleteSelection(),r=s.selection.from),s.setMeta(tt,{add:{id:o,pos:r}}),n.dispatch(s);try{const i=tt.getState(n.state),l=i.schema,a=i.upload;if(!a)throw new Error("uploadImage: Image upload function not defined");const c=await a(e);if(typeof c=="string")throw new Error(c);const u=bm(n.state,o);if(u===null){console.warn("uploadImage: The image was removed from the document during upload");return}n.dispatch(n.state.tr.replaceWith(u,u,l.nodes.image.create({fid:c,title:t})).setMeta(tt,{remove:{id:o}}))}catch(i){n.dispatch(n.state.tr.setMeta(tt,{remove:{id:o}})),console.error(`uploadImage: ${i}`)}},km=(n,e,t,r)=>{if(!e)return;const o=n.state.tr;r===void 0&&(o.selection.empty||o.deleteSelection(),r=o.selection.from);const s=tt.getState(n.state).schema;n.dispatch(n.state.tr.replaceWith(r,r,s.nodes.image.create({src:e,title:t})))},Ft=function(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e},Ja=function(n,e,t,r){return t&&(Ya(n,e,t,r,-1)||Ya(n,e,t,r,1))},Sm=/^(img|br|input|textarea|hr)$/i;function Ya(n,e,t,r,o){for(;;){if(n==t&&e==r)return!0;if(e==(o<0?0:Br(n))){let s=n.parentNode;if(!s||s.nodeType!=1||hs(n)||Sm.test(n.nodeName)||n.contentEditable=="false")return!1;e=Ft(n)+(o<0?0:1),n=s}else if(n.nodeType==1){if(n=n.childNodes[e+(o<0?-1:0)],n.contentEditable=="false")return!1;e=o<0?Br(n):0}else return!1}}function Br(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Cm(n,e,t){for(let r=e==0,o=e==Br(n);r||o;){if(n==t)return!0;let s=Ft(n);if(n=n.parentNode,!n)return!1;r=r&&s==0,o=o&&s==Br(n)}}function hs(n){let e;for(let t=n;t&&!(e=t.pmViewDesc);t=t.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==n||e.contentDOM==n)}const Ga=function(n){return n.focusNode&&Ja(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)};function Xa(n,e){let t=document.createEvent("Event");return t.initEvent("keydown",!0,!0),t.keyCode=n,t.key=t.code=e,t}const _e=typeof navigator<"u"?navigator:null,Ua=typeof document<"u"?document:null,yt=_e&&_e.userAgent||"",ps=/Edge\/(\d+)/.exec(yt),Qa=/MSIE \d/.exec(yt),ms=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(yt),qn=!!(Qa||ms||ps),Za=Qa?document.documentMode:ms?+ms[1]:ps?+ps[1]:0,Fr=!qn&&/gecko\/(\d+)/i.test(yt);Fr&&+(/Firefox\/(\d+)/.exec(yt)||[0,0])[1];const gs=!qn&&/Chrome\/(\d+)/.exec(yt),bt=!!gs,ec=gs?+gs[1]:0,Lt=!qn&&!!_e&&/Apple Computer/.test(_e.vendor),ys=Lt&&(/Mobile\/\w+/.test(yt)||!!_e&&_e.maxTouchPoints>2),De=ys||(_e?/Mac/.test(_e.platform):!1),wm=_e?/Win/.test(_e.platform):!1,Hn=/Android \d/.test(yt),bs=!!Ua&&"webkitFontSmoothing"in Ua.documentElement.style,Mm=bs?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Nm(n,e=null){let t=n.domSelectionRange(),r=n.state.doc;if(!t.focusNode)return null;let o=n.docView.nearestDesc(t.focusNode),s=o&&o.size==0,i=n.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(i<0)return null;let l=r.resolve(i),a,c;if(Ga(t)){for(a=i;o&&!o.node;)o=o.parent;let f=o.node;if(o&&f.isAtom&&v.isSelectable(f)&&o.parent&&!(f.isInline&&Cm(t.focusNode,t.focusOffset,o.dom))){let d=o.posBefore;c=new v(i==d?l:r.resolve(d))}}else{if(t instanceof n.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let f=i,d=i;for(let p=0;p<t.rangeCount;p++){let h=t.getRangeAt(p);f=Math.min(f,n.docView.posFromDOM(h.startContainer,h.startOffset,1)),d=Math.max(d,n.docView.posFromDOM(h.endContainer,h.endOffset,-1))}if(f<0)return null;[a,i]=d==n.state.selection.anchor?[d,f]:[f,d],l=r.resolve(i)}else a=n.docView.posFromDOM(t.anchorNode,t.anchorOffset,1);if(a<0)return null}let u=r.resolve(a);if(!c){let f=e=="pointer"||n.state.selection.head<l.pos&&!s?1:-1;c=ic(n,u,l,f)}return c}function tc(n){return n.editable?n.hasFocus():Om(n)&&document.activeElement&&document.activeElement.contains(n.dom)}function xs(n,e=!1){let t=n.state.selection;if(vm(n,t),!!tc(n)){if(!e&&n.input.mouseDown&&n.input.mouseDown.allowDefault&&bt){let r=n.domSelectionRange(),o=n.domObserver.currentSelection;if(r.anchorNode&&o.anchorNode&&Ja(r.anchorNode,r.anchorOffset,o.anchorNode,o.anchorOffset)){n.input.mouseDown.delayedSelectionSync=!0,n.domObserver.setCurSelection();return}}if(n.domObserver.disconnectSelection(),n.cursorWrapper)Dm(n);else{let{anchor:r,head:o}=t,s,i;nc&&!(t instanceof V)&&(t.$from.parent.inlineContent||(s=rc(n,t.from)),!t.empty&&!t.$from.parent.inlineContent&&(i=rc(n,t.to))),n.docView.setSelection(r,o,n,e),nc&&(s&&oc(s),i&&oc(i)),t.visible?n.dom.classList.remove("ProseMirror-hideselection"):(n.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&Em(n))}n.domObserver.setCurSelection(),n.domObserver.connectSelection()}}const nc=Lt||bt&&ec<63;function rc(n,e){let{node:t,offset:r}=n.docView.domFromPos(e,0),o=r<t.childNodes.length?t.childNodes[r]:null,s=r?t.childNodes[r-1]:null;if(Lt&&o&&o.contentEditable=="false")return ks(o);if((!o||o.contentEditable=="false")&&(!s||s.contentEditable=="false")){if(o)return ks(o);if(s)return ks(s)}}function ks(n){return n.contentEditable="true",Lt&&n.draggable&&(n.draggable=!1,n.wasDraggable=!0),n}function oc(n){n.contentEditable="false",n.wasDraggable&&(n.draggable=!0,n.wasDraggable=null)}function Em(n){let e=n.dom.ownerDocument;e.removeEventListener("selectionchange",n.input.hideSelectionGuard);let t=n.domSelectionRange(),r=t.anchorNode,o=t.anchorOffset;e.addEventListener("selectionchange",n.input.hideSelectionGuard=()=>{(t.anchorNode!=r||t.anchorOffset!=o)&&(e.removeEventListener("selectionchange",n.input.hideSelectionGuard),setTimeout(()=>{(!tc(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function Dm(n){let e=n.domSelection(),t=document.createRange();if(!e)return;let r=n.cursorWrapper.dom,o=r.nodeName=="IMG";o?t.setStart(r.parentNode,Ft(r)+1):t.setStart(r,0),t.collapse(!0),e.removeAllRanges(),e.addRange(t),!o&&!n.state.selection.visible&&qn&&Za<=11&&(r.disabled=!0,r.disabled=!1)}function vm(n,e){if(e instanceof v){let t=n.docView.descAt(e.from);t!=n.lastSelectedViewDesc&&(sc(n),t&&t.selectNode(),n.lastSelectedViewDesc=t)}else sc(n)}function sc(n){n.lastSelectedViewDesc&&(n.lastSelectedViewDesc.parent&&n.lastSelectedViewDesc.deselectNode(),n.lastSelectedViewDesc=void 0)}function ic(n,e,t,r){return n.someProp("createSelectionBetween",o=>o(n,e,t))||V.between(e,t,r)}function Om(n){let e=n.domSelectionRange();if(!e.anchorNode)return!1;try{return n.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(n.editable||n.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function Ss(n,e){let{$anchor:t,$head:r}=n.selection,o=e>0?t.max(r):t.min(r),s=o.parent.inlineContent?o.depth?n.doc.resolve(e>0?o.after():o.before()):null:o;return s&&R.findFrom(s,e)}function xt(n,e){return n.dispatch(n.state.tr.setSelection(e).scrollIntoView()),!0}function lc(n,e,t){let r=n.state.selection;if(r instanceof V)if(t.indexOf("s")>-1){let{$head:o}=r,s=o.textOffset?null:e<0?o.nodeBefore:o.nodeAfter;if(!s||s.isText||!s.isLeaf)return!1;let i=n.state.doc.resolve(o.pos+s.nodeSize*(e<0?-1:1));return xt(n,new V(r.$anchor,i))}else if(r.empty){if(n.endOfTextblock(e>0?"forward":"backward")){let o=Ss(n.state,e);return o&&o instanceof v?xt(n,o):!1}else if(!(De&&t.indexOf("m")>-1)){let o=r.$head,s=o.textOffset?null:e<0?o.nodeBefore:o.nodeAfter,i;if(!s||s.isText)return!1;let l=e<0?o.pos-s.nodeSize:o.pos;return s.isAtom||(i=n.docView.descAt(l))&&!i.contentDOM?v.isSelectable(s)?xt(n,new v(e<0?n.state.doc.resolve(o.pos-s.nodeSize):o)):bs?xt(n,new V(n.state.doc.resolve(e<0?l:l+s.nodeSize))):!1:!1}}else return!1;else{if(r instanceof v&&r.node.isInline)return xt(n,new V(e>0?r.$to:r.$from));{let o=Ss(n.state,e);return o?xt(n,o):!1}}}function Lr(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Kn(n,e){let t=n.pmViewDesc;return t&&t.size==0&&(e<0||n.nextSibling||n.nodeName!="BR")}function dn(n,e){return e<0?Tm(n):Am(n)}function Tm(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let o,s,i=!1;for(Fr&&t.nodeType==1&&r<Lr(t)&&Kn(t.childNodes[r],-1)&&(i=!0);;)if(r>0){if(t.nodeType!=1)break;{let l=t.childNodes[r-1];if(Kn(l,-1))o=t,s=--r;else if(l.nodeType==3)t=l,r=t.nodeValue.length;else break}}else{if(ac(t))break;{let l=t.previousSibling;for(;l&&Kn(l,-1);)o=t.parentNode,s=Ft(l),l=l.previousSibling;if(l)t=l,r=Lr(t);else{if(t=t.parentNode,t==n.dom)break;r=0}}}i?Cs(n,t,r):o&&Cs(n,o,s)}function Am(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let o=Lr(t),s,i;for(;;)if(r<o){if(t.nodeType!=1)break;let l=t.childNodes[r];if(Kn(l,1))s=t,i=++r;else break}else{if(ac(t))break;{let l=t.nextSibling;for(;l&&Kn(l,1);)s=l.parentNode,i=Ft(l)+1,l=l.nextSibling;if(l)t=l,r=0,o=Lr(t);else{if(t=t.parentNode,t==n.dom)break;r=o=0}}}s&&Cs(n,s,i)}function ac(n){let e=n.pmViewDesc;return e&&e.node&&e.node.isBlock}function Pm(n,e){for(;n&&e==n.childNodes.length&&!hs(n);)e=Ft(n)+1,n=n.parentNode;for(;n&&e<n.childNodes.length;){let t=n.childNodes[e];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;n=t,e=0}}function Im(n,e){for(;n&&!e&&!hs(n);)e=Ft(n),n=n.parentNode;for(;n&&e;){let t=n.childNodes[e-1];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;n=t,e=n.childNodes.length}}function Cs(n,e,t){if(e.nodeType!=3){let s,i;(i=Pm(e,t))?(e=i,t=0):(s=Im(e,t))&&(e=s,t=s.nodeValue.length)}let r=n.domSelection();if(!r)return;if(Ga(r)){let s=document.createRange();s.setEnd(e,t),s.setStart(e,t),r.removeAllRanges(),r.addRange(s)}else r.extend&&r.extend(e,t);n.domObserver.setCurSelection();let{state:o}=n;setTimeout(()=>{n.state==o&&xs(n)},50)}function cc(n,e){let t=n.state.doc.resolve(e);if(!(bt||wm)&&t.parent.inlineContent){let o=n.coordsAtPos(e);if(e>t.start()){let s=n.coordsAtPos(e-1),i=(s.top+s.bottom)/2;if(i>o.top&&i<o.bottom&&Math.abs(s.left-o.left)>1)return s.left<o.left?"ltr":"rtl"}if(e<t.end()){let s=n.coordsAtPos(e+1),i=(s.top+s.bottom)/2;if(i>o.top&&i<o.bottom&&Math.abs(s.left-o.left)>1)return s.left>o.left?"ltr":"rtl"}}return getComputedStyle(n.dom).direction=="rtl"?"rtl":"ltr"}function uc(n,e,t){let r=n.state.selection;if(r instanceof V&&!r.empty||t.indexOf("s")>-1||De&&t.indexOf("m")>-1)return!1;let{$from:o,$to:s}=r;if(!o.parent.inlineContent||n.endOfTextblock(e<0?"up":"down")){let i=Ss(n.state,e);if(i&&i instanceof v)return xt(n,i)}if(!o.parent.inlineContent){let i=e<0?o:s,l=r instanceof ge?R.near(i,e):R.findFrom(i,e);return l?xt(n,l):!1}return!1}function fc(n,e){if(!(n.state.selection instanceof V))return!0;let{$head:t,$anchor:r,empty:o}=n.state.selection;if(!t.sameParent(r))return!0;if(!o)return!1;if(n.endOfTextblock(e>0?"forward":"backward"))return!0;let s=!t.textOffset&&(e<0?t.nodeBefore:t.nodeAfter);if(s&&!s.isText){let i=n.state.tr;return e<0?i.delete(t.pos-s.nodeSize,t.pos):i.delete(t.pos,t.pos+s.nodeSize),n.dispatch(i),!0}return!1}function dc(n,e,t){n.domObserver.stop(),e.contentEditable=t,n.domObserver.start()}function Vm(n){if(!Lt||n.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:t}=n.domSelectionRange();if(e&&e.nodeType==1&&t==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let r=e.firstChild;dc(n,r,"true"),setTimeout(()=>dc(n,r,"false"),20)}return!1}function Rm(n){let e="";return n.ctrlKey&&(e+="c"),n.metaKey&&(e+="m"),n.altKey&&(e+="a"),n.shiftKey&&(e+="s"),e}function zm(n,e){let t=e.keyCode,r=Rm(e);if(t==8||De&&t==72&&r=="c")return fc(n,-1)||dn(n,-1);if(t==46&&!e.shiftKey||De&&t==68&&r=="c")return fc(n,1)||dn(n,1);if(t==13||t==27)return!0;if(t==37||De&&t==66&&r=="c"){let o=t==37?cc(n,n.state.selection.from)=="ltr"?-1:1:-1;return lc(n,o,r)||dn(n,o)}else if(t==39||De&&t==70&&r=="c"){let o=t==39?cc(n,n.state.selection.from)=="ltr"?1:-1:1;return lc(n,o,r)||dn(n,o)}else{if(t==38||De&&t==80&&r=="c")return uc(n,-1,r)||dn(n,-1);if(t==40||De&&t==78&&r=="c")return Vm(n)||uc(n,1,r)||dn(n,1);if(r==(De?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function hc(n,e){n.someProp("transformCopied",p=>{e=p(e,n)});let t=[],{content:r,openStart:o,openEnd:s}=e;for(;o>1&&s>1&&r.childCount==1&&r.firstChild.childCount==1;){o--,s--;let p=r.firstChild;t.push(p.type.name,p.attrs!=p.type.defaultAttrs?p.attrs:null),r=p.content}let i=n.someProp("clipboardSerializer")||$e.fromSchema(n.state.schema),l=Sc(),a=l.createElement("div");a.appendChild(i.serializeFragment(r,{document:l}));let c=a.firstChild,u,f=0;for(;c&&c.nodeType==1&&(u=xc[c.nodeName.toLowerCase()]);){for(let p=u.length-1;p>=0;p--){let h=l.createElement(u[p]);for(;a.firstChild;)h.appendChild(a.firstChild);a.appendChild(h),f++}c=a.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${o} ${s}${f?` -${f}`:""} ${JSON.stringify(t)}`);let d=n.someProp("clipboardTextSerializer",p=>p(e,n))||e.content.textBetween(0,e.content.size,`
|
|
42
42
|
|
|
43
43
|
`);return{dom:a,text:d,slice:e}}function pc(n,e,t,r,o){let s=o.parent.type.spec.code,i,l;if(!t&&!e)return null;let a=e&&(r||s||!t);if(a){if(n.someProp("transformPastedText",d=>{e=d(e,s||r,n)}),s)return e?new E(C.from(n.state.schema.text(e.replace(/\r\n?/g,`
|
|
44
|
-
`))),0,0):E.empty;let f=n.someProp("clipboardTextParser",d=>d(e,o,r,n));if(f)l=f;else{let d=o.marks(),{schema:p}=n.state,h=$e.fromSchema(p);i=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(b=>{let g=i.appendChild(document.createElement("p"));b&&g.appendChild(h.serializeNode(p.text(b,d)))})}}else n.someProp("transformPastedHTML",f=>{t=f(t,n)}),i=Fm(t),bs&&Lm(i);let c=i&&i.querySelector("[data-pm-slice]"),u=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(u&&u[3])for(let f=+u[3];f>0;f--){let d=i.firstChild;for(;d&&d.nodeType!=1;)d=d.nextSibling;if(!d)break;i=d}if(l||(l=(n.someProp("clipboardParser")||n.someProp("domParser")||Pt.fromSchema(n.state.schema)).parseSlice(i,{preserveWhitespace:!!(a||u),context:o,ruleFromNode(d){return d.nodeName=="BR"&&!d.nextSibling&&d.parentNode&&!$m.test(d.parentNode.nodeName)?{ignore:!0}:null}})),u)l=Wm(bc(l,+u[1],+u[2]),u[4]);else if(l=E.maxOpen(jm(l.content,o),!0),l.openStart||l.openEnd){let f=0,d=0;for(let p=l.content.firstChild;f<l.openStart&&!p.type.spec.isolating;f++,p=p.firstChild);for(let p=l.content.lastChild;d<l.openEnd&&!p.type.spec.isolating;d++,p=p.lastChild);l=bc(l,f,d)}return n.someProp("transformPasted",f=>{l=f(l,n)}),l}const $m=/^(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 jm(n,e){if(n.childCount<2)return n;for(let t=e.depth;t>=0;t--){let o=e.node(t).contentMatchAt(e.index(t)),s,i=[];if(n.forEach(l=>{if(!i)return;let a=o.findWrapping(l.type),c;if(!a)return i=null;if(c=i.length&&s.length&&gc(a,s,l,i[i.length-1],0))i[i.length-1]=c;else{i.length&&(i[i.length-1]=yc(i[i.length-1],s.length));let u=mc(l,a);i.push(u),o=o.matchType(u.type),s=a}}),i)return C.from(i)}return n}function mc(n,e,t=0){for(let r=e.length-1;r>=t;r--)n=e[r].create(null,C.from(n));return n}function gc(n,e,t,r,o){if(o<n.length&&o<e.length&&n[o]==e[o]){let s=gc(n,e,t,r.lastChild,o+1);if(s)return r.copy(r.content.replaceChild(r.childCount-1,s));if(r.contentMatchAt(r.childCount).matchType(o==n.length-1?t.type:n[o+1]))return r.copy(r.content.append(C.from(mc(t,n,o+1))))}}function yc(n,e){if(e==0)return n;let t=n.content.replaceChild(n.childCount-1,yc(n.lastChild,e-1)),r=n.contentMatchAt(n.childCount).fillBefore(C.empty,!0);return n.copy(t.append(r))}function ws(n,e,t,r,o,s){let i=e<0?n.firstChild:n.lastChild,l=i.content;return n.childCount>1&&(s=0),o<r-1&&(l=ws(l,e,t,r,o+1,s)),o>=t&&(l=e<0?i.contentMatchAt(0).fillBefore(l,s<=o).append(l):l.append(i.contentMatchAt(i.childCount).fillBefore(C.empty,!0))),n.replaceChild(e<0?0:n.childCount-1,i.copy(l))}function bc(n,e,t){return e<n.openStart&&(n=new E(ws(n.content,-1,e,n.openStart,0,n.openEnd),e,n.openEnd)),t<n.openEnd&&(n=new E(ws(n.content,1,t,n.openEnd,0,0),n.openStart,t)),n}const xc={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};let kc=null;function Sc(){return kc||(kc=document.implementation.createHTMLDocument("title"))}let Ms=null;function Bm(n){let e=window.trustedTypes;return e?(Ms||(Ms=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})),Ms.createHTML(n)):n}function Fm(n){let e=/^(\s*<meta [^>]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=Sc().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(n),o;if((o=r&&xc[r[1].toLowerCase()])&&(n=o.map(s=>"<"+s+">").join("")+n+o.map(s=>"</"+s+">").reverse().join("")),t.innerHTML=Bm(n),o)for(let s=0;s<o.length;s++)t=t.querySelector(o[s])||t;return t}function Lm(n){let e=n.querySelectorAll(bt?"span:not([class]):not([style])":"span.Apple-converted-space");for(let t=0;t<e.length;t++){let r=e[t];r.childNodes.length==1&&r.textContent==" "&&r.parentNode&&r.parentNode.replaceChild(n.ownerDocument.createTextNode(" "),r)}}function Wm(n,e){if(!n.size)return n;let t=n.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return n}let{content:o,openStart:s,openEnd:i}=n;for(let l=r.length-2;l>=0;l-=2){let a=t.nodes[r[l]];if(!a||a.hasRequiredAttrs())break;o=C.from(a.create(r[l+1],o)),s++,i++}return new E(o,s,i)}const Re={},Se={};function kt(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}Se.keydown=(n,e)=>{let t=e;if(n.input.shiftKey=t.keyCode==16||t.shiftKey,!wc(n,t)&&(n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),!(Hn&&bt&&t.keyCode==13)))if(t.keyCode!=229&&n.domObserver.forceFlush(),ys&&t.keyCode==13&&!t.ctrlKey&&!t.altKey&&!t.metaKey){let r=Date.now();n.input.lastIOSEnter=r,n.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{n.input.lastIOSEnter==r&&(n.someProp("handleKeyDown",o=>o(n,Xa(13,"Enter"))),n.input.lastIOSEnter=0)},200)}else n.someProp("handleKeyDown",r=>r(n,t))||zm(n,t)?t.preventDefault():kt(n,"key")},Se.keyup=(n,e)=>{e.keyCode==16&&(n.input.shiftKey=!1)},Se.keypress=(n,e)=>{let t=e;if(wc(n,t)||!t.charCode||t.ctrlKey&&!t.altKey||De&&t.metaKey)return;if(n.someProp("handleKeyPress",o=>o(n,t))){t.preventDefault();return}let r=n.state.selection;if(!(r instanceof V)||!r.$from.sameParent(r.$to)){let o=String.fromCharCode(t.charCode);!/[\r\n]/.test(o)&&!n.someProp("handleTextInput",s=>s(n,r.$from.pos,r.$to.pos,o))&&n.dispatch(n.state.tr.insertText(o).scrollIntoView()),t.preventDefault()}};function Wr(n){return{left:n.clientX,top:n.clientY}}function _m(n,e){let t=e.x-n.clientX,r=e.y-n.clientY;return t*t+r*r<100}function Ns(n,e,t,r,o){if(r==-1)return!1;let s=n.state.doc.resolve(r);for(let i=s.depth+1;i>0;i--)if(n.someProp(e,l=>i>s.depth?l(n,t,s.nodeAfter,s.before(i),o,!0):l(n,t,s.node(i),s.before(i),o,!1)))return!0;return!1}function hn(n,e,t){if(n.focused||n.focus(),n.state.selection.eq(e))return;let r=n.state.tr.setSelection(e);r.setMeta("pointer",!0),n.dispatch(r)}function qm(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),r=t.nodeAfter;return r&&r.isAtom&&O.isSelectable(r)?(hn(n,new O(t)),!0):!1}function Hm(n,e){if(e==-1)return!1;let t=n.state.selection,r,o;t instanceof O&&(r=t.node);let s=n.state.doc.resolve(e);for(let i=s.depth+1;i>0;i--){let l=i>s.depth?s.nodeAfter:s.node(i);if(O.isSelectable(l)){r&&t.$from.depth>0&&i>=t.$from.depth&&s.before(t.$from.depth+1)==t.$from.pos?o=s.before(t.$from.depth):o=s.before(i);break}}return o!=null?(hn(n,O.create(n.state.doc,o)),!0):!1}function Km(n,e,t,r,o){return Ns(n,"handleClickOn",e,t,r)||n.someProp("handleClick",s=>s(n,e,r))||(o?Hm(n,t):qm(n,t))}function Jm(n,e,t,r){return Ns(n,"handleDoubleClickOn",e,t,r)||n.someProp("handleDoubleClick",o=>o(n,e,r))}function Ym(n,e,t,r){return Ns(n,"handleTripleClickOn",e,t,r)||n.someProp("handleTripleClick",o=>o(n,e,r))||Gm(n,t,r)}function Gm(n,e,t){if(t.button!=0)return!1;let r=n.state.doc;if(e==-1)return r.inlineContent?(hn(n,V.create(r,0,r.content.size)),!0):!1;let o=r.resolve(e);for(let s=o.depth+1;s>0;s--){let i=s>o.depth?o.nodeAfter:o.node(s),l=o.before(s);if(i.inlineContent)hn(n,V.create(r,l+1,l+1+i.content.size));else if(O.isSelectable(i))hn(n,O.create(r,l));else continue;return!0}}function Es(n){return _r(n)}const Cc=De?"metaKey":"ctrlKey";Re.mousedown=(n,e)=>{let t=e;n.input.shiftKey=t.shiftKey;let r=Es(n),o=Date.now(),s="singleClick";o-n.input.lastClick.time<500&&_m(t,n.input.lastClick)&&!t[Cc]&&(n.input.lastClick.type=="singleClick"?s="doubleClick":n.input.lastClick.type=="doubleClick"&&(s="tripleClick")),n.input.lastClick={time:o,x:t.clientX,y:t.clientY,type:s};let i=n.posAtCoords(Wr(t));i&&(s=="singleClick"?(n.input.mouseDown&&n.input.mouseDown.done(),n.input.mouseDown=new Xm(n,i,t,!!r)):(s=="doubleClick"?Jm:Ym)(n,i.pos,i.inside,t)?t.preventDefault():kt(n,"pointer"))};class Xm{constructor(e,t,r,o){this.view=e,this.pos=t,this.event=r,this.flushed=o,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!r[Cc],this.allowDefault=r.shiftKey;let s,i;if(t.inside>-1)s=e.state.doc.nodeAt(t.inside),i=t.inside;else{let u=e.state.doc.resolve(t.pos);s=u.parent,i=u.depth?u.before():0}const l=o?null:r.target,a=l?e.docView.nearestDesc(l,!0):null;this.target=a&&a.dom.nodeType==1?a.dom:null;let{selection:c}=e.state;(r.button==0&&s.type.spec.draggable&&s.type.spec.selectable!==!1||c instanceof O&&c.from<=i&&c.to>i)&&(this.mightDrag={node:s,pos:i,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Fr&&!this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this)),kt(e,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>xs(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(Wr(e))),this.updateAllowDefault(e),this.allowDefault||!t?kt(this.view,"pointer"):Km(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||Lt&&this.mightDrag&&!this.mightDrag.node.isAtom||bt&&!this.view.state.selection.visible&&Math.min(Math.abs(t.pos-this.view.state.selection.from),Math.abs(t.pos-this.view.state.selection.to))<=2)?(hn(this.view,R.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):kt(this.view,"pointer")}move(e){this.updateAllowDefault(e),kt(this.view,"pointer"),e.buttons==0&&this.done()}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}}Re.touchstart=n=>{n.input.lastTouch=Date.now(),Es(n),kt(n,"pointer")},Re.touchmove=n=>{n.input.lastTouch=Date.now(),kt(n,"pointer")},Re.contextmenu=n=>Es(n);function wc(n,e){return n.composing?!0:Lt&&Math.abs(e.timeStamp-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}const Um=Hn?5e3:-1;Se.compositionstart=Se.compositionupdate=n=>{if(!n.composing){n.domObserver.flush();let{state:e}=n,t=e.selection.$to;if(e.selection instanceof V&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)))n.markCursor=n.state.storedMarks||t.marks(),_r(n,!0),n.markCursor=null;else if(_r(n,!e.selection.empty),Fr&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length){let r=n.domSelectionRange();for(let o=r.focusNode,s=r.focusOffset;o&&o.nodeType==1&&s!=0;){let i=s<0?o.lastChild:o.childNodes[s-1];if(!i)break;if(i.nodeType==3){let l=n.domSelection();l&&l.collapse(i,i.nodeValue.length);break}else o=i,s=-1}}n.input.composing=!0}Mc(n,Um)},Se.compositionend=(n,e)=>{n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=e.timeStamp,n.input.compositionPendingChanges=n.domObserver.pendingRecords().length?n.input.compositionID:0,n.input.compositionNode=null,n.input.compositionPendingChanges&&Promise.resolve().then(()=>n.domObserver.flush()),n.input.compositionID++,Mc(n,20))};function Mc(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>_r(n),e))}function Qm(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=Zm());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function Zm(){let n=document.createEvent("Event");return n.initEvent("event",!0,!0),n.timeStamp}function _r(n,e=!1){if(!(Hn&&n.domObserver.flushingSoon>=0)){if(n.domObserver.forceFlush(),Qm(n),e||n.docView&&n.docView.dirty){let t=Nm(n);return t&&!t.eq(n.state.selection)?n.dispatch(n.state.tr.setSelection(t)):(n.markCursor||e)&&!n.state.selection.empty?n.dispatch(n.state.tr.deleteSelection()):n.updateState(n.state),!0}return!1}}function eg(n,e){if(!n.dom.parentNode)return;let t=n.dom.parentNode.appendChild(document.createElement("div"));t.appendChild(e),t.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),o=document.createRange();o.selectNodeContents(e),n.dom.blur(),r.removeAllRanges(),r.addRange(o),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t),n.focus()},50)}const Jn=qn&&Za<15||ys&&Mm<604;Re.copy=Se.cut=(n,e)=>{let t=e,r=n.state.selection,o=t.type=="cut";if(r.empty)return;let s=Jn?null:t.clipboardData,i=r.content(),{dom:l,text:a}=hc(n,i);s?(t.preventDefault(),s.clearData(),s.setData("text/html",l.innerHTML),s.setData("text/plain",a)):eg(n,l),o&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function tg(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function ng(n,e){if(!n.dom.parentNode)return;let t=n.input.shiftKey||n.state.selection.$from.parent.type.spec.code,r=n.dom.parentNode.appendChild(document.createElement(t?"textarea":"div"));t||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let o=n.input.shiftKey&&n.input.lastKeyCode!=45;setTimeout(()=>{n.focus(),r.parentNode&&r.parentNode.removeChild(r),t?Ds(n,r.value,null,o,e):Ds(n,r.textContent,r.innerHTML,o,e)},50)}function Ds(n,e,t,r,o){let s=pc(n,e,t,r,n.state.selection.$from);if(n.someProp("handlePaste",a=>a(n,o,s||E.empty)))return!0;if(!s)return!1;let i=tg(s),l=i?n.state.tr.replaceSelectionWith(i,r):n.state.tr.replaceSelection(s);return n.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Nc(n){let e=n.getData("text/plain")||n.getData("Text");if(e)return e;let t=n.getData("text/uri-list");return t?t.replace(/\r?\n/g," "):""}Se.paste=(n,e)=>{let t=e;if(n.composing&&!Hn)return;let r=Jn?null:t.clipboardData,o=n.input.shiftKey&&n.input.lastKeyCode!=45;r&&Ds(n,Nc(r),r.getData("text/html"),o,t)?t.preventDefault():ng(n,t)};class rg{constructor(e,t,r){this.slice=e,this.move=t,this.node=r}}const og=De?"altKey":"ctrlKey";function Ec(n,e){let t=n.someProp("dragCopies",r=>!r(e));return t??!e[og]}Re.dragstart=(n,e)=>{let t=e,r=n.input.mouseDown;if(r&&r.done(),!t.dataTransfer)return;let o=n.state.selection,s=o.empty?null:n.posAtCoords(Wr(t)),i;if(!(s&&s.pos>=o.from&&s.pos<=(o instanceof O?o.to-1:o.to))){if(r&&r.mightDrag)i=O.create(n.state.doc,r.mightDrag.pos);else if(t.target&&t.target.nodeType==1){let f=n.docView.nearestDesc(t.target,!0);f&&f.node.type.spec.draggable&&f!=n.docView&&(i=O.create(n.state.doc,f.posBefore))}}let l=(i||n.state.selection).content(),{dom:a,text:c,slice:u}=hc(n,l);(!t.dataTransfer.files.length||!bt||ec>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(Jn?"Text":"text/html",a.innerHTML),t.dataTransfer.effectAllowed="copyMove",Jn||t.dataTransfer.setData("text/plain",c),n.dragging=new rg(u,Ec(n,t),i)},Re.dragend=n=>{let e=n.dragging;window.setTimeout(()=>{n.dragging==e&&(n.dragging=null)},50)},Se.dragover=Se.dragenter=(n,e)=>e.preventDefault(),Se.drop=(n,e)=>{let t=e,r=n.dragging;if(n.dragging=null,!t.dataTransfer)return;let o=n.posAtCoords(Wr(t));if(!o)return;let s=n.state.doc.resolve(o.pos),i=r&&r.slice;i?n.someProp("transformPasted",h=>{i=h(i,n)}):i=pc(n,Nc(t.dataTransfer),Jn?null:t.dataTransfer.getData("text/html"),!1,s);let l=!!(r&&Ec(n,t));if(n.someProp("handleDrop",h=>h(n,t,i||E.empty,l))){t.preventDefault();return}if(!i)return;t.preventDefault();let a=i?Co(n.state.doc,s.pos,i):s.pos;a==null&&(a=s.pos);let c=n.state.tr;if(l){let{node:h}=r;h?h.replace(c):c.deleteSelection()}let u=c.mapping.map(a),f=i.openStart==0&&i.openEnd==0&&i.content.childCount==1,d=c.doc;if(f?c.replaceRangeWith(u,u,i.content.firstChild):c.replaceRange(u,u,i),c.doc.eq(d))return;let p=c.doc.resolve(u);if(f&&O.isSelectable(i.content.firstChild)&&p.nodeAfter&&p.nodeAfter.sameMarkup(i.content.firstChild))c.setSelection(new O(p));else{let h=c.mapping.map(a);c.mapping.maps[c.mapping.maps.length-1].forEach((b,g,x,S)=>h=S),c.setSelection(ic(n,p,c.doc.resolve(h)))}n.focus(),n.dispatch(c.setMeta("uiEvent","drop"))},Re.focus=n=>{n.input.lastFocus=Date.now(),n.focused||(n.domObserver.stop(),n.dom.classList.add("ProseMirror-focused"),n.domObserver.start(),n.focused=!0,setTimeout(()=>{n.docView&&n.hasFocus()&&!n.domObserver.currentSelection.eq(n.domSelectionRange())&&xs(n)},20))},Re.blur=(n,e)=>{let t=e;n.focused&&(n.domObserver.stop(),n.dom.classList.remove("ProseMirror-focused"),n.domObserver.start(),t.relatedTarget&&n.dom.contains(t.relatedTarget)&&n.domObserver.currentSelection.clear(),n.focused=!1)},Re.beforeinput=(n,e)=>{if(bt&&Hn&&e.inputType=="deleteContentBackward"){n.domObserver.flushSoon();let{domChangeCount:r}=n.input;setTimeout(()=>{if(n.input.domChangeCount!=r||(n.dom.blur(),n.focus(),n.someProp("handleKeyDown",s=>s(n,Xa(8,"Backspace")))))return;let{$cursor:o}=n.state.selection;o&&o.pos>0&&n.dispatch(n.state.tr.delete(o.pos-1,o.pos).scrollIntoView())},50)}};for(let n in Se)Re[n]=Se[n];function Yn(n,e){if(n==e)return!0;for(let t in n)if(n[t]!==e[t])return!1;for(let t in e)if(!(t in n))return!1;return!0}class qr{constructor(e,t){this.toDOM=e,this.spec=t||Wt,this.side=this.spec.side||0}map(e,t,r,o){let{pos:s,deleted:i}=e.mapResult(t.from+o,this.side<0?-1:1);return i?null:new qe(s-r,s-r,this)}valid(){return!0}eq(e){return this==e||e instanceof qr&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Yn(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class St{constructor(e,t){this.attrs=e,this.spec=t||Wt}map(e,t,r,o){let s=e.map(t.from+o,this.spec.inclusiveStart?-1:1)-r,i=e.map(t.to+o,this.spec.inclusiveEnd?1:-1)-r;return s>=i?null:new qe(s,i,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof St&&Yn(this.attrs,e.attrs)&&Yn(this.spec,e.spec)}static is(e){return e.type instanceof St}destroy(){}}class Os{constructor(e,t){this.attrs=e,this.spec=t||Wt}map(e,t,r,o){let s=e.mapResult(t.from+o,1);if(s.deleted)return null;let i=e.mapResult(t.to+o,-1);return i.deleted||i.pos<=s.pos?null:new qe(s.pos-r,i.pos-r,this)}valid(e,t){let{index:r,offset:o}=e.content.findIndex(t.from),s;return o==t.from&&!(s=e.child(r)).isText&&o+s.nodeSize==t.to}eq(e){return this==e||e instanceof Os&&Yn(this.attrs,e.attrs)&&Yn(this.spec,e.spec)}destroy(){}}class qe{constructor(e,t,r){this.from=e,this.to=t,this.type=r}copy(e,t){return new qe(e,t,this.type)}eq(e,t=0){return this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to}map(e,t,r){return this.type.map(e,this,t,r)}static widget(e,t,r){return new qe(e,e,new qr(t,r))}static inline(e,t,r,o){return new qe(e,t,new St(r,o))}static node(e,t,r,o){return new qe(e,t,new Os(r,o))}get spec(){return this.type.spec}get inline(){return this.type instanceof St}get widget(){return this.type instanceof qr}}const pn=[],Wt={};class U{constructor(e,t){this.local=e.length?e:pn,this.children=t.length?t:pn}static create(e,t){return t.length?Hr(t,e,0,Wt):he}find(e,t,r){let o=[];return this.findInner(e??0,t??1e9,o,0,r),o}findInner(e,t,r,o,s){for(let i=0;i<this.local.length;i++){let l=this.local[i];l.from<=t&&l.to>=e&&(!s||s(l.spec))&&r.push(l.copy(l.from+o,l.to+o))}for(let i=0;i<this.children.length;i+=3)if(this.children[i]<t&&this.children[i+1]>e){let l=this.children[i]+1;this.children[i+2].findInner(e-l,t-l,r,o+l,s)}}map(e,t,r){return this==he||e.maps.length==0?this:this.mapInner(e,t,0,0,r||Wt)}mapInner(e,t,r,o,s){let i;for(let l=0;l<this.local.length;l++){let a=this.local[l].map(e,r,o);a&&a.type.valid(t,a)?(i||(i=[])).push(a):s.onRemove&&s.onRemove(this.local[l].spec)}return this.children.length?ig(this.children,i||[],e,t,r,o,s):i?new U(i.sort(_t),pn):he}add(e,t){return t.length?this==he?U.create(e,t):this.addInner(e,t,0):this}addInner(e,t,r){let o,s=0;e.forEach((l,a)=>{let c=a+r,u;if(u=Oc(t,l,c)){for(o||(o=this.children.slice());s<o.length&&o[s]<a;)s+=3;o[s]==a?o[s+2]=o[s+2].addInner(l,u,c+1):o.splice(s,0,a,a+l.nodeSize,Hr(u,l,c+1,Wt)),s+=3}});let i=Dc(s?vc(t):t,-r);for(let l=0;l<i.length;l++)i[l].type.valid(e,i[l])||i.splice(l--,1);return new U(i.length?this.local.concat(i).sort(_t):this.local,o||this.children)}remove(e){return e.length==0||this==he?this:this.removeInner(e,0)}removeInner(e,t){let r=this.children,o=this.local;for(let s=0;s<r.length;s+=3){let i,l=r[s]+t,a=r[s+1]+t;for(let u=0,f;u<e.length;u++)(f=e[u])&&f.from>l&&f.to<a&&(e[u]=null,(i||(i=[])).push(f));if(!i)continue;r==this.children&&(r=this.children.slice());let c=r[s+2].removeInner(i,l+1);c!=he?r[s+2]=c:(r.splice(s,3),s-=3)}if(o.length){for(let s=0,i;s<e.length;s++)if(i=e[s])for(let l=0;l<o.length;l++)o[l].eq(i,t)&&(o==this.local&&(o=this.local.slice()),o.splice(l--,1))}return r==this.children&&o==this.local?this:o.length||r.length?new U(o,r):he}forChild(e,t){if(this==he)return this;if(t.isLeaf)return U.empty;let r,o;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=e){this.children[l]==e&&(r=this.children[l+2]);break}let s=e+1,i=s+t.content.size;for(let l=0;l<this.local.length;l++){let a=this.local[l];if(a.from<i&&a.to>s&&a.type instanceof St){let c=Math.max(s,a.from)-s,u=Math.min(i,a.to)-s;c<u&&(o||(o=[])).push(a.copy(c,u))}}if(o){let l=new U(o.sort(_t),pn);return r?new sg([l,r]):l}return r||he}eq(e){if(this==e)return!0;if(!(e instanceof U)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let t=0;t<this.local.length;t++)if(!this.local[t].eq(e.local[t]))return!1;for(let t=0;t<this.children.length;t+=3)if(this.children[t]!=e.children[t]||this.children[t+1]!=e.children[t+1]||!this.children[t+2].eq(e.children[t+2]))return!1;return!0}locals(e){return vs(this.localsInner(e))}localsInner(e){if(this==he)return pn;if(e.inlineContent||!this.local.some(St.is))return this.local;let t=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof St||t.push(this.local[r]);return t}forEachSet(e){e(this)}}U.empty=new U([],[]),U.removeOverlap=vs;const he=U.empty;let sg=class kn{constructor(e){this.members=e}map(e,t){const r=this.members.map(o=>o.map(e,t,Wt));return kn.from(r)}forChild(e,t){if(t.isLeaf)return U.empty;let r=[];for(let o=0;o<this.members.length;o++){let s=this.members[o].forChild(e,t);s!=he&&(s instanceof kn?r=r.concat(s.members):r.push(s))}return kn.from(r)}eq(e){if(!(e instanceof kn)||e.members.length!=this.members.length)return!1;for(let t=0;t<this.members.length;t++)if(!this.members[t].eq(e.members[t]))return!1;return!0}locals(e){let t,r=!0;for(let o=0;o<this.members.length;o++){let s=this.members[o].localsInner(e);if(s.length)if(!t)t=s;else{r&&(t=t.slice(),r=!1);for(let i=0;i<s.length;i++)t.push(s[i])}}return t?vs(r?t:t.sort(_t)):pn}static from(e){switch(e.length){case 0:return he;case 1:return e[0];default:return new kn(e.every(t=>t instanceof U)?e:e.reduce((t,r)=>t.concat(r instanceof U?r:r.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}};function ig(n,e,t,r,o,s,i){let l=n.slice();for(let c=0,u=s;c<t.maps.length;c++){let f=0;t.maps[c].forEach((d,p,h,b)=>{let g=b-h-(p-d);for(let x=0;x<l.length;x+=3){let S=l[x+1];if(S<0||d>S+u-f)continue;let w=l[x]+u-f;p>=w?l[x+1]=d<=w?-2:-1:d>=u&&g&&(l[x]+=g,l[x+1]+=g)}f+=g}),u=t.maps[c].map(u,-1)}let a=!1;for(let c=0;c<l.length;c+=3)if(l[c+1]<0){if(l[c+1]==-2){a=!0,l[c+1]=-1;continue}let u=t.map(n[c]+s),f=u-o;if(f<0||f>=r.content.size){a=!0;continue}let d=t.map(n[c+1]+s,-1),p=d-o,{index:h,offset:b}=r.content.findIndex(f),g=r.maybeChild(h);if(g&&b==f&&b+g.nodeSize==p){let x=l[c+2].mapInner(t,g,u+1,n[c]+s+1,i);x!=he?(l[c]=f,l[c+1]=p,l[c+2]=x):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=lg(l,n,e,t,o,s,i),u=Hr(c,r,0,i);e=u.local;for(let f=0;f<l.length;f+=3)l[f+1]<0&&(l.splice(f,3),f-=3);for(let f=0,d=0;f<u.children.length;f+=3){let p=u.children[f];for(;d<l.length&&l[d]<p;)d+=3;l.splice(d,0,u.children[f],u.children[f+1],u.children[f+2])}}return new U(e.sort(_t),l)}function Dc(n,e){if(!e||!n.length)return n;let t=[];for(let r=0;r<n.length;r++){let o=n[r];t.push(new qe(o.from+e,o.to+e,o.type))}return t}function lg(n,e,t,r,o,s,i){function l(a,c){for(let u=0;u<a.local.length;u++){let f=a.local[u].map(r,o,c);f?t.push(f):i.onRemove&&i.onRemove(a.local[u].spec)}for(let u=0;u<a.children.length;u+=3)l(a.children[u+2],a.children[u]+c+1)}for(let a=0;a<n.length;a+=3)n[a+1]==-1&&l(n[a+2],e[a]+s+1);return t}function Oc(n,e,t){if(e.isLeaf)return null;let r=t+e.nodeSize,o=null;for(let s=0,i;s<n.length;s++)(i=n[s])&&i.from>t&&i.to<r&&((o||(o=[])).push(i),n[s]=null);return o}function vc(n){let e=[];for(let t=0;t<n.length;t++)n[t]!=null&&e.push(n[t]);return e}function Hr(n,e,t,r){let o=[],s=!1;e.forEach((l,a)=>{let c=Oc(n,l,a+t);if(c){s=!0;let u=Hr(c,l,t+a+1,r);u!=he&&o.push(a,a+l.nodeSize,u)}});let i=Dc(s?vc(n):n,-t).sort(_t);for(let l=0;l<i.length;l++)i[l].type.valid(e,i[l])||(r.onRemove&&r.onRemove(i[l].spec),i.splice(l--,1));return i.length||o.length?new U(i,o):he}function _t(n,e){return n.from-e.from||n.to-e.to}function vs(n){let e=n;for(let t=0;t<e.length-1;t++){let r=e[t];if(r.from!=r.to)for(let o=t+1;o<e.length;o++){let s=e[o];if(s.from==r.from){s.to!=r.to&&(e==n&&(e=n.slice()),e[o]=s.copy(s.from,r.to),Tc(e,o+1,s.copy(r.to,s.to)));continue}else{s.from<r.to&&(e==n&&(e=n.slice()),e[t]=r.copy(r.from,s.from),Tc(e,o,r.copy(s.from,r.to)));break}}}return e}function Tc(n,e,t){for(;e<n.length&&_t(t,n[e])>0;)e++;n.splice(e,0,t)}var Ts,As;if(typeof WeakMap<"u"){let n=new WeakMap;Ts=e=>n.get(e),As=(e,t)=>(n.set(e,t),t)}else{const n=[];let t=0;Ts=r=>{for(let o=0;o<n.length;o+=2)if(n[o]==r)return n[o+1]},As=(r,o)=>(t==10&&(t=0),n[t++]=r,n[t++]=o)}var Q=class{constructor(n,e,t,r){this.width=n,this.height=e,this.map=t,this.problems=r}findCell(n){for(let e=0;e<this.map.length;e++){const t=this.map[e];if(t!=n)continue;const r=e%this.width,o=e/this.width|0;let s=r+1,i=o+1;for(let l=1;s<this.width&&this.map[e+l]==t;l++)s++;for(let l=1;i<this.height&&this.map[e+this.width*l]==t;l++)i++;return{left:r,top:o,right:s,bottom:i}}throw new RangeError(`No cell with offset ${n} found`)}colCount(n){for(let e=0;e<this.map.length;e++)if(this.map[e]==n)return e%this.width;throw new RangeError(`No cell with offset ${n} found`)}nextCell(n,e,t){const{left:r,right:o,top:s,bottom:i}=this.findCell(n);return e=="horiz"?(t<0?r==0:o==this.width)?null:this.map[s*this.width+(t<0?r-1:o)]:(t<0?s==0:i==this.height)?null:this.map[r+this.width*(t<0?s-1:i)]}rectBetween(n,e){const{left:t,right:r,top:o,bottom:s}=this.findCell(n),{left:i,right:l,top:a,bottom:c}=this.findCell(e);return{left:Math.min(t,i),top:Math.min(o,a),right:Math.max(r,l),bottom:Math.max(s,c)}}cellsInRect(n){const e=[],t={};for(let r=n.top;r<n.bottom;r++)for(let o=n.left;o<n.right;o++){const s=r*this.width+o,i=this.map[s];t[i]||(t[i]=!0,!(o==n.left&&o&&this.map[s-1]==i||r==n.top&&r&&this.map[s-this.width]==i)&&e.push(i))}return e}positionAt(n,e,t){for(let r=0,o=0;;r++){const s=o+t.child(r).nodeSize;if(r==n){let i=e+n*this.width;const l=(n+1)*this.width;for(;i<l&&this.map[i]<o;)i++;return i==l?s-1:this.map[i]}o=s}}static get(n){return Ts(n)||As(n,ag(n))}};function ag(n){if(n.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+n.type.name);const e=cg(n),t=n.childCount,r=[];let o=0,s=null;const i=[];for(let c=0,u=e*t;c<u;c++)r[c]=0;for(let c=0,u=0;c<t;c++){const f=n.child(c);u++;for(let h=0;;h++){for(;o<r.length&&r[o]!=0;)o++;if(h==f.childCount)break;const b=f.child(h),{colspan:g,rowspan:x,colwidth:S}=b.attrs;for(let w=0;w<x;w++){if(w+c>=t){(s||(s=[])).push({type:"overlong_rowspan",pos:u,n:x-w});break}const D=o+w*e;for(let T=0;T<g;T++){r[D+T]==0?r[D+T]=u:(s||(s=[])).push({type:"collision",row:c,pos:u,n:g-T});const M=S&&S[T];if(M){const I=(D+T)%e*2,z=i[I];z==null||z!=M&&i[I+1]==1?(i[I]=M,i[I+1]=1):z==M&&i[I+1]++}}}o+=g,u+=b.nodeSize}const d=(c+1)*e;let p=0;for(;o<d;)r[o++]==0&&p++;p&&(s||(s=[])).push({type:"missing",row:c,n:p}),u++}(e===0||t===0)&&(s||(s=[])).push({type:"zero_sized"});const l=new Q(e,t,r,s);let a=!1;for(let c=0;!a&&c<i.length;c+=2)i[c]!=null&&i[c+1]<t&&(a=!0);return a&&ug(l,i,n),l}function cg(n){let e=-1,t=!1;for(let r=0;r<n.childCount;r++){const o=n.child(r);let s=0;if(t)for(let i=0;i<r;i++){const l=n.child(i);for(let a=0;a<l.childCount;a++){const c=l.child(a);i+c.attrs.rowspan>r&&(s+=c.attrs.colspan)}}for(let i=0;i<o.childCount;i++){const l=o.child(i);s+=l.attrs.colspan,l.attrs.rowspan>1&&(t=!0)}e==-1?e=s:e!=s&&(e=Math.max(e,s))}return e}function ug(n,e,t){n.problems||(n.problems=[]);const r={};for(let o=0;o<n.map.length;o++){const s=n.map[o];if(r[s])continue;r[s]=!0;const i=t.nodeAt(s);if(!i)throw new RangeError(`No cell with offset ${s} found`);let l=null;const a=i.attrs;for(let c=0;c<a.colspan;c++){const u=(o+c)%n.width,f=e[u*2];f!=null&&(!a.colwidth||a.colwidth[c]!=f)&&((l||(l=fg(a)))[c]=f)}l&&n.problems.unshift({type:"colwidth mismatch",pos:s,colwidth:l})}}function fg(n){if(n.colwidth)return n.colwidth.slice();const e=[];for(let t=0;t<n.colspan;t++)e.push(0);return e}function Ac(n,e){if(typeof n=="string")return{};const t=n.getAttribute("data-colwidth"),r=t&&/^\d+(,\d+)*$/.test(t)?t.split(",").map(i=>Number(i)):null,o=Number(n.getAttribute("colspan")||1),s={colspan:o,rowspan:Number(n.getAttribute("rowspan")||1),colwidth:r&&r.length==o?r:null};for(const i in e){const l=e[i].getFromDOM,a=l&&l(n);a!=null&&(s[i]=a)}return s}function Pc(n,e){const t={};n.attrs.colspan!=1&&(t.colspan=n.attrs.colspan),n.attrs.rowspan!=1&&(t.rowspan=n.attrs.rowspan),n.attrs.colwidth&&(t["data-colwidth"]=n.attrs.colwidth.join(","));for(const r in e){const o=e[r].setDOMAttr;o&&o(n.attrs[r],t)}return t}function dg(n){if(n!==null){if(!Array.isArray(n))throw new TypeError("colwidth must be null or an array");for(const e of n)if(typeof e!="number")throw new TypeError("colwidth must be null or an array of numbers")}}function hg(n){const e=n.cellAttributes||{},t={colspan:{default:1,validate:"number"},rowspan:{default:1,validate:"number"},colwidth:{default:null,validate:dg}};for(const r in e)t[r]={default:e[r].default,validate:e[r].validate};return{table:{content:"table_row+",tableRole:"table",isolating:!0,group:n.tableGroup,parseDOM:[{tag:"table"}],toDOM(){return["table",["tbody",0]]}},table_row:{content:"(table_cell | table_header)*",tableRole:"row",parseDOM:[{tag:"tr"}],toDOM(){return["tr",0]}},table_cell:{content:n.cellContent,attrs:t,tableRole:"cell",isolating:!0,parseDOM:[{tag:"td",getAttrs:r=>Ac(r,e)}],toDOM(r){return["td",Pc(r,e),0]}},table_header:{content:n.cellContent,attrs:t,tableRole:"header_cell",isolating:!0,parseDOM:[{tag:"th",getAttrs:r=>Ac(r,e)}],toDOM(r){return["th",Pc(r,e),0]}}}}function pe(n){let e=n.cached.tableNodeTypes;if(!e){e=n.cached.tableNodeTypes={};for(const t in n.nodes){const r=n.nodes[t],o=r.spec.tableRole;o&&(e[o]=r)}}return e}var Ct=new lt("selectingCells");function Gn(n){for(let e=n.depth-1;e>0;e--)if(n.node(e).type.spec.tableRole=="row")return n.node(0).resolve(n.before(e+1));return null}function pg(n){for(let e=n.depth;e>0;e--){const t=n.node(e).type.spec.tableRole;if(t==="cell"||t==="header_cell")return n.node(e)}return null}function Oe(n){const e=n.selection.$head;for(let t=e.depth;t>0;t--)if(e.node(t).type.spec.tableRole=="row")return!0;return!1}function Kr(n){const e=n.selection;if("$anchorCell"in e&&e.$anchorCell)return e.$anchorCell.pos>e.$headCell.pos?e.$anchorCell:e.$headCell;if("node"in e&&e.node&&e.node.type.spec.tableRole=="cell")return e.$anchor;const t=Gn(e.$head)||mg(e.$head);if(t)return t;throw new RangeError(`No cell found around position ${e.head}`)}function mg(n){for(let e=n.nodeAfter,t=n.pos;e;e=e.firstChild,t++){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return n.doc.resolve(t)}for(let e=n.nodeBefore,t=n.pos;e;e=e.lastChild,t--){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return n.doc.resolve(t-e.nodeSize)}}function Ic(n){return n.parent.type.spec.tableRole=="row"&&!!n.nodeAfter}function gg(n){return n.node(0).resolve(n.pos+n.nodeAfter.nodeSize)}function Ps(n,e){return n.depth==e.depth&&n.pos>=e.start(-1)&&n.pos<=e.end(-1)}function Vc(n,e,t){const r=n.node(-1),o=Q.get(r),s=n.start(-1),i=o.nextCell(n.pos-s,e,t);return i==null?null:n.node(0).resolve(s+i)}function qt(n,e,t=1){const r={...n,colspan:n.colspan-t};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(e,t),r.colwidth.some(o=>o>0)||(r.colwidth=null)),r}function Rc(n,e,t=1){const r={...n,colspan:n.colspan+t};if(r.colwidth){r.colwidth=r.colwidth.slice();for(let o=0;o<t;o++)r.colwidth.splice(e,0,0)}return r}function yg(n,e,t){const r=pe(e.type.schema).header_cell;for(let o=0;o<n.height;o++)if(e.nodeAt(n.map[t+o*n.width]).type!=r)return!1;return!0}var W=class ot extends R{constructor(e,t=e){const r=e.node(-1),o=Q.get(r),s=e.start(-1),i=o.rectBetween(e.pos-s,t.pos-s),l=e.node(0),a=o.cellsInRect(i).filter(u=>u!=t.pos-s);a.unshift(t.pos-s);const c=a.map(u=>{const f=r.nodeAt(u);if(!f)throw RangeError(`No cell with offset ${u} found`);const d=s+u+1;return new ol(l.resolve(d),l.resolve(d+f.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=e,this.$headCell=t}map(e,t){const r=e.resolve(t.map(this.$anchorCell.pos)),o=e.resolve(t.map(this.$headCell.pos));if(Ic(r)&&Ic(o)&&Ps(r,o)){const s=this.$anchorCell.node(-1)!=r.node(-1);return s&&this.isRowSelection()?ot.rowSelection(r,o):s&&this.isColSelection()?ot.colSelection(r,o):new ot(r,o)}return V.between(r,o)}content(){const e=this.$anchorCell.node(-1),t=Q.get(e),r=this.$anchorCell.start(-1),o=t.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),s={},i=[];for(let a=o.top;a<o.bottom;a++){const c=[];for(let u=a*t.width+o.left,f=o.left;f<o.right;f++,u++){const d=t.map[u];if(s[d])continue;s[d]=!0;const p=t.findCell(d);let h=e.nodeAt(d);if(!h)throw RangeError(`No cell with offset ${d} found`);const b=o.left-p.left,g=p.right-o.right;if(b>0||g>0){let x=h.attrs;if(b>0&&(x=qt(x,0,b)),g>0&&(x=qt(x,x.colspan-g,g)),p.left<o.left){if(h=h.type.createAndFill(x),!h)throw RangeError(`Could not create cell with attrs ${JSON.stringify(x)}`)}else h=h.type.create(x,h.content)}if(p.top<o.top||p.bottom>o.bottom){const x={...h.attrs,rowspan:Math.min(p.bottom,o.bottom)-Math.max(p.top,o.top)};p.top<o.top?h=h.type.createAndFill(x):h=h.type.create(x,h.content)}c.push(h)}i.push(e.child(a).copy(C.from(c)))}const l=this.isColSelection()&&this.isRowSelection()?e:i;return new E(C.from(l),1,1)}replace(e,t=E.empty){const r=e.steps.length,o=this.ranges;for(let i=0;i<o.length;i++){const{$from:l,$to:a}=o[i],c=e.mapping.slice(r);e.replace(c.map(l.pos),c.map(a.pos),i?E.empty:t)}const s=R.findFrom(e.doc.resolve(e.mapping.slice(r).map(this.to)),-1);s&&e.setSelection(s)}replaceWith(e,t){this.replace(e,new E(C.from(t),0,0))}forEachCell(e){const t=this.$anchorCell.node(-1),r=Q.get(t),o=this.$anchorCell.start(-1),s=r.cellsInRect(r.rectBetween(this.$anchorCell.pos-o,this.$headCell.pos-o));for(let i=0;i<s.length;i++)e(t.nodeAt(s[i]),o+s[i])}isColSelection(){const e=this.$anchorCell.index(-1),t=this.$headCell.index(-1);if(Math.min(e,t)>0)return!1;const r=e+this.$anchorCell.nodeAfter.attrs.rowspan,o=t+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(r,o)==this.$headCell.node(-1).childCount}static colSelection(e,t=e){const r=e.node(-1),o=Q.get(r),s=e.start(-1),i=o.findCell(e.pos-s),l=o.findCell(t.pos-s),a=e.node(0);return i.top<=l.top?(i.top>0&&(e=a.resolve(s+o.map[i.left])),l.bottom<o.height&&(t=a.resolve(s+o.map[o.width*(o.height-1)+l.right-1]))):(l.top>0&&(t=a.resolve(s+o.map[l.left])),i.bottom<o.height&&(e=a.resolve(s+o.map[o.width*(o.height-1)+i.right-1]))),new ot(e,t)}isRowSelection(){const e=this.$anchorCell.node(-1),t=Q.get(e),r=this.$anchorCell.start(-1),o=t.colCount(this.$anchorCell.pos-r),s=t.colCount(this.$headCell.pos-r);if(Math.min(o,s)>0)return!1;const i=o+this.$anchorCell.nodeAfter.attrs.colspan,l=s+this.$headCell.nodeAfter.attrs.colspan;return Math.max(i,l)==t.width}eq(e){return e instanceof ot&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,t=e){const r=e.node(-1),o=Q.get(r),s=e.start(-1),i=o.findCell(e.pos-s),l=o.findCell(t.pos-s),a=e.node(0);return i.left<=l.left?(i.left>0&&(e=a.resolve(s+o.map[i.top*o.width])),l.right<o.width&&(t=a.resolve(s+o.map[o.width*(l.top+1)-1]))):(l.left>0&&(t=a.resolve(s+o.map[l.top*o.width])),i.right<o.width&&(e=a.resolve(s+o.map[o.width*(i.top+1)-1]))),new ot(e,t)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,t){return new ot(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,r=t){return new ot(e.resolve(t),e.resolve(r))}getBookmark(){return new bg(this.$anchorCell.pos,this.$headCell.pos)}};W.prototype.visible=!1,R.jsonID("cell",W);var bg=class yf{constructor(e,t){this.anchor=e,this.head=t}map(e){return new yf(e.map(this.anchor),e.map(this.head))}resolve(e){const t=e.resolve(this.anchor),r=e.resolve(this.head);return t.parent.type.spec.tableRole=="row"&&r.parent.type.spec.tableRole=="row"&&t.index()<t.parent.childCount&&r.index()<r.parent.childCount&&Ps(t,r)?new W(t,r):R.near(r,1)}};function xg(n){if(!(n.selection instanceof W))return null;const e=[];return n.selection.forEachCell((t,r)=>{e.push(qe.node(r,r+t.nodeSize,{class:"selectedCell"}))}),U.create(n.doc,e)}function kg({$from:n,$to:e}){if(n.pos==e.pos||n.pos<e.pos-6)return!1;let t=n.pos,r=e.pos,o=n.depth;for(;o>=0&&!(n.after(o+1)<n.end(o));o--,t++);for(let s=e.depth;s>=0&&!(e.before(s+1)>e.start(s));s--,r--);return t==r&&/row|table/.test(n.node(o).type.spec.tableRole)}function Sg({$from:n,$to:e}){let t,r;for(let o=n.depth;o>0;o--){const s=n.node(o);if(s.type.spec.tableRole==="cell"||s.type.spec.tableRole==="header_cell"){t=s;break}}for(let o=e.depth;o>0;o--){const s=e.node(o);if(s.type.spec.tableRole==="cell"||s.type.spec.tableRole==="header_cell"){r=s;break}}return t!==r&&e.parentOffset===0}function Cg(n,e,t){const r=(e||n).selection,o=(e||n).doc;let s,i;if(r instanceof O&&(i=r.node.type.spec.tableRole)){if(i=="cell"||i=="header_cell")s=W.create(o,r.from);else if(i=="row"){const l=o.resolve(r.from+1);s=W.rowSelection(l,l)}else if(!t){const l=Q.get(r.node),a=r.from+1,c=a+l.map[l.width*l.height-1];s=W.create(o,a+1,c)}}else r instanceof V&&kg(r)?s=V.create(o,r.from):r instanceof V&&Sg(r)&&(s=V.create(o,r.$from.start(),r.$from.end()));return s&&(e||(e=n.tr)).setSelection(s),e}var wg=new lt("fix-tables");function zc(n,e,t,r){const o=n.childCount,s=e.childCount;e:for(let i=0,l=0;i<s;i++){const a=e.child(i);for(let c=l,u=Math.min(o,i+3);c<u;c++)if(n.child(c)==a){l=c+1,t+=a.nodeSize;continue e}r(a,t),l<o&&n.child(l).sameMarkup(a)?zc(n.child(l),a,t+1,r):a.nodesBetween(0,a.content.size,r,t+1),t+=a.nodeSize}}function Is(n,e){let t;const r=(o,s)=>{o.type.spec.tableRole=="table"&&(t=Mg(n,o,s,t))};return e?e.doc!=n.doc&&zc(e.doc,n.doc,0,r):n.doc.descendants(r),t}function Mg(n,e,t,r){const o=Q.get(e);if(!o.problems)return r;r||(r=n.tr);const s=[];for(let a=0;a<o.height;a++)s.push(0);for(let a=0;a<o.problems.length;a++){const c=o.problems[a];if(c.type=="collision"){const u=e.nodeAt(c.pos);if(!u)continue;const f=u.attrs;for(let d=0;d<f.rowspan;d++)s[c.row+d]+=c.n;r.setNodeMarkup(r.mapping.map(t+1+c.pos),null,qt(f,f.colspan-c.n,c.n))}else if(c.type=="missing")s[c.row]+=c.n;else if(c.type=="overlong_rowspan"){const u=e.nodeAt(c.pos);if(!u)continue;r.setNodeMarkup(r.mapping.map(t+1+c.pos),null,{...u.attrs,rowspan:u.attrs.rowspan-c.n})}else if(c.type=="colwidth mismatch"){const u=e.nodeAt(c.pos);if(!u)continue;r.setNodeMarkup(r.mapping.map(t+1+c.pos),null,{...u.attrs,colwidth:c.colwidth})}else if(c.type=="zero_sized"){const u=r.mapping.map(t);r.delete(u,u+e.nodeSize)}}let i,l;for(let a=0;a<s.length;a++)s[a]&&(i==null&&(i=a),l=a);for(let a=0,c=t+1;a<o.height;a++){const u=e.child(a),f=c+u.nodeSize,d=s[a];if(d>0){let p="cell";u.firstChild&&(p=u.firstChild.type.spec.tableRole);const h=[];for(let g=0;g<d;g++){const x=pe(n.schema)[p].createAndFill();x&&h.push(x)}const b=(a==0||i==a-1)&&l==a?c+1:f-1;r.insert(r.mapping.map(b),h)}c=f}return r.setMeta(wg,{fixTables:!0})}function He(n){const e=n.selection,t=Kr(n),r=t.node(-1),o=t.start(-1),s=Q.get(r);return{...e instanceof W?s.rectBetween(e.$anchorCell.pos-o,e.$headCell.pos-o):s.findCell(t.pos-o),tableStart:o,map:s,table:r}}function $c(n,{map:e,tableStart:t,table:r},o){let s=o>0?-1:0;yg(e,r,o+s)&&(s=o==0||o==e.width?null:0);for(let i=0;i<e.height;i++){const l=i*e.width+o;if(o>0&&o<e.width&&e.map[l-1]==e.map[l]){const a=e.map[l],c=r.nodeAt(a);n.setNodeMarkup(n.mapping.map(t+a),null,Rc(c.attrs,o-e.colCount(a))),i+=c.attrs.rowspan-1}else{const a=s==null?pe(r.type.schema).cell:r.nodeAt(e.map[l+s]).type,c=e.positionAt(i,o,r);n.insert(n.mapping.map(t+c),a.createAndFill())}}return n}function Ng(n,e){if(!Oe(n))return!1;if(e){const t=He(n);e($c(n.tr,t,t.left))}return!0}function Eg(n,e){if(!Oe(n))return!1;if(e){const t=He(n);e($c(n.tr,t,t.right))}return!0}function Dg(n,{map:e,table:t,tableStart:r},o){const s=n.mapping.maps.length;for(let i=0;i<e.height;){const l=i*e.width+o,a=e.map[l],c=t.nodeAt(a),u=c.attrs;if(o>0&&e.map[l-1]==a||o<e.width-1&&e.map[l+1]==a)n.setNodeMarkup(n.mapping.slice(s).map(r+a),null,qt(u,o-e.colCount(a)));else{const f=n.mapping.slice(s).map(r+a);n.delete(f,f+c.nodeSize)}i+=u.rowspan}}function Og(n,e){if(!Oe(n))return!1;if(e){const t=He(n),r=n.tr;if(t.left==0&&t.right==t.map.width)return!1;for(let o=t.right-1;Dg(r,t,o),o!=t.left;o--){const s=t.tableStart?r.doc.nodeAt(t.tableStart-1):r.doc;if(!s)throw RangeError("No table found");t.table=s,t.map=Q.get(s)}e(r)}return!0}function vg(n,e,t){var r;const o=pe(e.type.schema).header_cell;for(let s=0;s<n.width;s++)if(((r=e.nodeAt(n.map[s+t*n.width]))==null?void 0:r.type)!=o)return!1;return!0}function jc(n,{map:e,tableStart:t,table:r},o){var s;let i=t;for(let c=0;c<o;c++)i+=r.child(c).nodeSize;const l=[];let a=o>0?-1:0;vg(e,r,o+a)&&(a=o==0||o==e.height?null:0);for(let c=0,u=e.width*o;c<e.width;c++,u++)if(o>0&&o<e.height&&e.map[u]==e.map[u-e.width]){const f=e.map[u],d=r.nodeAt(f).attrs;n.setNodeMarkup(t+f,null,{...d,rowspan:d.rowspan+1}),c+=d.colspan-1}else{const f=a==null?pe(r.type.schema).cell:(s=r.nodeAt(e.map[u+a*e.width]))==null?void 0:s.type,d=f==null?void 0:f.createAndFill();d&&l.push(d)}return n.insert(i,pe(r.type.schema).row.create(null,l)),n}function Tg(n,e){if(!Oe(n))return!1;if(e){const t=He(n);e(jc(n.tr,t,t.top))}return!0}function Ag(n,e){if(!Oe(n))return!1;if(e){const t=He(n);e(jc(n.tr,t,t.bottom))}return!0}function Pg(n,{map:e,table:t,tableStart:r},o){let s=0;for(let c=0;c<o;c++)s+=t.child(c).nodeSize;const i=s+t.child(o).nodeSize,l=n.mapping.maps.length;n.delete(s+r,i+r);const a=new Set;for(let c=0,u=o*e.width;c<e.width;c++,u++){const f=e.map[u];if(!a.has(f)){if(a.add(f),o>0&&f==e.map[u-e.width]){const d=t.nodeAt(f).attrs;n.setNodeMarkup(n.mapping.slice(l).map(f+r),null,{...d,rowspan:d.rowspan-1}),c+=d.colspan-1}else if(o<e.height&&f==e.map[u+e.width]){const d=t.nodeAt(f),p=d.attrs,h=d.type.create({...p,rowspan:d.attrs.rowspan-1},d.content),b=e.positionAt(o+1,c,t);n.insert(n.mapping.slice(l).map(r+b),h),c+=p.colspan-1}}}}function Ig(n,e){if(!Oe(n))return!1;if(e){const t=He(n),r=n.tr;if(t.top==0&&t.bottom==t.map.height)return!1;for(let o=t.bottom-1;Pg(r,t,o),o!=t.top;o--){const s=t.tableStart?r.doc.nodeAt(t.tableStart-1):r.doc;if(!s)throw RangeError("No table found");t.table=s,t.map=Q.get(t.table)}e(r)}return!0}function Bc(n){const e=n.content;return e.childCount==1&&e.child(0).isTextblock&&e.child(0).childCount==0}function Vg({width:n,height:e,map:t},r){let o=r.top*n+r.left,s=o,i=(r.bottom-1)*n+r.left,l=o+(r.right-r.left-1);for(let a=r.top;a<r.bottom;a++){if(r.left>0&&t[s]==t[s-1]||r.right<n&&t[l]==t[l+1])return!0;s+=n,l+=n}for(let a=r.left;a<r.right;a++){if(r.top>0&&t[o]==t[o-n]||r.bottom<e&&t[i]==t[i+n])return!0;o++,i++}return!1}function Rg(n,e){const t=n.selection;if(!(t instanceof W)||t.$anchorCell.pos==t.$headCell.pos)return!1;const r=He(n),{map:o}=r;if(Vg(o,r))return!1;if(e){const s=n.tr,i={};let l=C.empty,a,c;for(let u=r.top;u<r.bottom;u++)for(let f=r.left;f<r.right;f++){const d=o.map[u*o.width+f],p=r.table.nodeAt(d);if(!(i[d]||!p))if(i[d]=!0,a==null)a=d,c=p;else{Bc(p)||(l=l.append(p.content));const h=s.mapping.map(d+r.tableStart);s.delete(h,h+p.nodeSize)}}if(a==null||c==null)return!0;if(s.setNodeMarkup(a+r.tableStart,null,{...Rc(c.attrs,c.attrs.colspan,r.right-r.left-c.attrs.colspan),rowspan:r.bottom-r.top}),l.size){const u=a+1+c.content.size,f=Bc(c)?a+1:u;s.replaceWith(f+r.tableStart,u+r.tableStart,l)}s.setSelection(new W(s.doc.resolve(a+r.tableStart))),e(s)}return!0}function zg(n,e){const t=pe(n.schema);return $g(({node:r})=>t[r.type.spec.tableRole])(n,e)}function $g(n){return(e,t)=>{var r;const o=e.selection;let s,i;if(o instanceof W){if(o.$anchorCell.pos!=o.$headCell.pos)return!1;s=o.$anchorCell.nodeAfter,i=o.$anchorCell.pos}else{if(s=pg(o.$from),!s)return!1;i=(r=Gn(o.$from))==null?void 0:r.pos}if(s==null||i==null||s.attrs.colspan==1&&s.attrs.rowspan==1)return!1;if(t){let l=s.attrs;const a=[],c=l.colwidth;l.rowspan>1&&(l={...l,rowspan:1}),l.colspan>1&&(l={...l,colspan:1});const u=He(e),f=e.tr;for(let p=0;p<u.right-u.left;p++)a.push(c?{...l,colwidth:c&&c[p]?[c[p]]:null}:l);let d;for(let p=u.top;p<u.bottom;p++){let h=u.map.positionAt(p,u.left,u.table);p==u.top&&(h+=s.nodeSize);for(let b=u.left,g=0;b<u.right;b++,g++)b==u.left&&p==u.top||f.insert(d=f.mapping.map(h+u.tableStart,1),n({node:s,row:p,col:b}).createAndFill(a[g]))}f.setNodeMarkup(i,n({node:s,row:u.top,col:u.left}),a[0]),o instanceof W&&f.setSelection(new W(f.doc.resolve(o.$anchorCell.pos),d?f.doc.resolve(d):void 0)),t(f)}return!0}}function mn(n,e){return function(t,r){if(!Oe(t))return!1;const o=Kr(t);if(o.nodeAfter.attrs[n]===e)return!1;if(r){const s=t.tr;t.selection instanceof W?t.selection.forEachCell((i,l)=>{i.attrs[n]!==e&&s.setNodeMarkup(l,null,{...i.attrs,[n]:e})}):s.setNodeMarkup(o.pos,null,{...o.nodeAfter.attrs,[n]:e}),r(s)}return!0}}function jg(n){return function(e,t){if(!Oe(e))return!1;if(t){const r=pe(e.schema),o=He(e),s=e.tr,i=o.map.cellsInRect(n=="column"?{left:o.left,top:0,right:o.right,bottom:o.map.height}:n=="row"?{left:0,top:o.top,right:o.map.width,bottom:o.bottom}:o),l=i.map(a=>o.table.nodeAt(a));for(let a=0;a<i.length;a++)l[a].type==r.header_cell&&s.setNodeMarkup(o.tableStart+i[a],r.cell,l[a].attrs);if(s.steps.length==0)for(let a=0;a<i.length;a++)s.setNodeMarkup(o.tableStart+i[a],r.header_cell,l[a].attrs);t(s)}return!0}}function Fc(n,e,t){const r=e.map.cellsInRect({left:0,top:0,right:n=="row"?e.map.width:1,bottom:n=="column"?e.map.height:1});for(let o=0;o<r.length;o++){const s=e.table.nodeAt(r[o]);if(s&&s.type!==t.header_cell)return!1}return!0}function Vs(n,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?jg(n):function(t,r){if(!Oe(t))return!1;if(r){const o=pe(t.schema),s=He(t),i=t.tr,l=Fc("row",s,o),a=Fc("column",s,o),u=(n==="column"?l:n==="row"?a:!1)?1:0,f=n=="column"?{left:0,top:u,right:1,bottom:s.map.height}:n=="row"?{left:u,top:0,right:s.map.width,bottom:1}:s,d=n=="column"?a?o.cell:o.header_cell:n=="row"?l?o.cell:o.header_cell:o.cell;s.map.cellsInRect(f).forEach(p=>{const h=p+s.tableStart,b=i.doc.nodeAt(h);b&&i.setNodeMarkup(h,d,b.attrs)}),r(i)}return!0}}var Bg=Vs("row",{useDeprecatedLogic:!0}),Fg=Vs("column",{useDeprecatedLogic:!0}),Lg=Vs("cell",{useDeprecatedLogic:!0});function Wg(n,e){if(e<0){const t=n.nodeBefore;if(t)return n.pos-t.nodeSize;for(let r=n.index(-1)-1,o=n.before();r>=0;r--){const s=n.node(-1).child(r),i=s.lastChild;if(i)return o-1-i.nodeSize;o-=s.nodeSize}}else{if(n.index()<n.parent.childCount-1)return n.pos+n.nodeAfter.nodeSize;const t=n.node(-1);for(let r=n.indexAfter(-1),o=n.after();r<t.childCount;r++){const s=t.child(r);if(s.childCount)return o+1;o+=s.nodeSize}}return null}function Lc(n){return function(e,t){if(!Oe(e))return!1;const r=Wg(Kr(e),n);if(r==null)return!1;if(t){const o=e.doc.resolve(r);t(e.tr.setSelection(V.between(o,gg(o))).scrollIntoView())}return!0}}function _g(n,e){const t=n.selection.$anchor;for(let r=t.depth;r>0;r--)if(t.node(r).type.spec.tableRole=="table")return e&&e(n.tr.delete(t.before(r),t.after(r)).scrollIntoView()),!0;return!1}function Jr(n,e){const t=n.selection;if(!(t instanceof W))return!1;if(e){const r=n.tr,o=pe(n.schema).cell.createAndFill().content;t.forEachCell((s,i)=>{s.content.eq(o)||r.replace(r.mapping.map(i+1),r.mapping.map(i+s.nodeSize-1),new E(o,0,0))}),r.docChanged&&e(r)}return!0}function qg(n){if(!n.size)return null;let{content:e,openStart:t,openEnd:r}=n;for(;e.childCount==1&&(t>0&&r>0||e.child(0).type.spec.tableRole=="table");)t--,r--,e=e.child(0).content;const o=e.child(0),s=o.type.spec.tableRole,i=o.type.schema,l=[];if(s=="row")for(let a=0;a<e.childCount;a++){let c=e.child(a).content;const u=a?0:Math.max(0,t-1),f=a<e.childCount-1?0:Math.max(0,r-1);(u||f)&&(c=Rs(pe(i).row,new E(c,u,f)).content),l.push(c)}else if(s=="cell"||s=="header_cell")l.push(t||r?Rs(pe(i).row,new E(e,t,r)).content:e);else return null;return Hg(i,l)}function Hg(n,e){const t=[];for(let o=0;o<e.length;o++){const s=e[o];for(let i=s.childCount-1;i>=0;i--){const{rowspan:l,colspan:a}=s.child(i).attrs;for(let c=o;c<o+l;c++)t[c]=(t[c]||0)+a}}let r=0;for(let o=0;o<t.length;o++)r=Math.max(r,t[o]);for(let o=0;o<t.length;o++)if(o>=e.length&&e.push(C.empty),t[o]<r){const s=pe(n).cell.createAndFill(),i=[];for(let l=t[o];l<r;l++)i.push(s);e[o]=e[o].append(C.from(i))}return{height:e.length,width:r,rows:e}}function Rs(n,e){const t=n.createAndFill();return new rl(t).replace(0,t.content.size,e).doc}function Kg({width:n,height:e,rows:t},r,o){if(n!=r){const s=[],i=[];for(let l=0;l<t.length;l++){const a=t[l],c=[];for(let u=s[l]||0,f=0;u<r;f++){let d=a.child(f%a.childCount);u+d.attrs.colspan>r&&(d=d.type.createChecked(qt(d.attrs,d.attrs.colspan,u+d.attrs.colspan-r),d.content)),c.push(d),u+=d.attrs.colspan;for(let p=1;p<d.attrs.rowspan;p++)s[l+p]=(s[l+p]||0)+d.attrs.colspan}i.push(C.from(c))}t=i,n=r}if(e!=o){const s=[];for(let i=0,l=0;i<o;i++,l++){const a=[],c=t[l%e];for(let u=0;u<c.childCount;u++){let f=c.child(u);i+f.attrs.rowspan>o&&(f=f.type.create({...f.attrs,rowspan:Math.max(1,o-f.attrs.rowspan)},f.content)),a.push(f)}s.push(C.from(a))}t=s,e=o}return{width:n,height:e,rows:t}}function Jg(n,e,t,r,o,s,i){const l=n.doc.type.schema,a=pe(l);let c,u;if(o>e.width)for(let f=0,d=0;f<e.height;f++){const p=t.child(f);d+=p.nodeSize;const h=[];let b;p.lastChild==null||p.lastChild.type==a.cell?b=c||(c=a.cell.createAndFill()):b=u||(u=a.header_cell.createAndFill());for(let g=e.width;g<o;g++)h.push(b);n.insert(n.mapping.slice(i).map(d-1+r),h)}if(s>e.height){const f=[];for(let h=0,b=(e.height-1)*e.width;h<Math.max(e.width,o);h++){const g=h>=e.width?!1:t.nodeAt(e.map[b+h]).type==a.header_cell;f.push(g?u||(u=a.header_cell.createAndFill()):c||(c=a.cell.createAndFill()))}const d=a.row.create(null,C.from(f)),p=[];for(let h=e.height;h<s;h++)p.push(d);n.insert(n.mapping.slice(i).map(r+t.nodeSize-2),p)}return!!(c||u)}function Wc(n,e,t,r,o,s,i,l){if(i==0||i==e.height)return!1;let a=!1;for(let c=o;c<s;c++){const u=i*e.width+c,f=e.map[u];if(e.map[u-e.width]==f){a=!0;const d=t.nodeAt(f),{top:p,left:h}=e.findCell(f);n.setNodeMarkup(n.mapping.slice(l).map(f+r),null,{...d.attrs,rowspan:i-p}),n.insert(n.mapping.slice(l).map(e.positionAt(i,h,t)),d.type.createAndFill({...d.attrs,rowspan:p+d.attrs.rowspan-i})),c+=d.attrs.colspan-1}}return a}function _c(n,e,t,r,o,s,i,l){if(i==0||i==e.width)return!1;let a=!1;for(let c=o;c<s;c++){const u=c*e.width+i,f=e.map[u];if(e.map[u-1]==f){a=!0;const d=t.nodeAt(f),p=e.colCount(f),h=n.mapping.slice(l).map(f+r);n.setNodeMarkup(h,null,qt(d.attrs,i-p,d.attrs.colspan-(i-p))),n.insert(h+d.nodeSize,d.type.createAndFill(qt(d.attrs,0,i-p))),c+=d.attrs.rowspan-1}}return a}function qc(n,e,t,r,o){let s=t?n.doc.nodeAt(t-1):n.doc;if(!s)throw new Error("No table found");let i=Q.get(s);const{top:l,left:a}=r,c=a+o.width,u=l+o.height,f=n.tr;let d=0;function p(){if(s=t?f.doc.nodeAt(t-1):f.doc,!s)throw new Error("No table found");i=Q.get(s),d=f.mapping.maps.length}Jg(f,i,s,t,c,u,d)&&p(),Wc(f,i,s,t,a,c,l,d)&&p(),Wc(f,i,s,t,a,c,u,d)&&p(),_c(f,i,s,t,l,u,a,d)&&p(),_c(f,i,s,t,l,u,c,d)&&p();for(let h=l;h<u;h++){const b=i.positionAt(h,a,s),g=i.positionAt(h,c,s);f.replace(f.mapping.slice(d).map(b+t),f.mapping.slice(d).map(g+t),new E(o.rows[h-l],0,0))}p(),f.setSelection(new W(f.doc.resolve(t+i.positionAt(l,a,s)),f.doc.resolve(t+i.positionAt(u-1,c-1,s)))),e(f)}var Yg=zo({ArrowLeft:Gr("horiz",-1),ArrowRight:Gr("horiz",1),ArrowUp:Gr("vert",-1),ArrowDown:Gr("vert",1),"Shift-ArrowLeft":Xr("horiz",-1),"Shift-ArrowRight":Xr("horiz",1),"Shift-ArrowUp":Xr("vert",-1),"Shift-ArrowDown":Xr("vert",1),Backspace:Jr,"Mod-Backspace":Jr,Delete:Jr,"Mod-Delete":Jr});function Yr(n,e,t){return t.eq(n.selection)?!1:(e&&e(n.tr.setSelection(t).scrollIntoView()),!0)}function Gr(n,e){return(t,r,o)=>{if(!o)return!1;const s=t.selection;if(s instanceof W)return Yr(t,r,R.near(s.$headCell,e));if(n!="horiz"&&!s.empty)return!1;const i=Hc(o,n,e);if(i==null)return!1;if(n=="horiz")return Yr(t,r,R.near(t.doc.resolve(s.head+e),e));{const l=t.doc.resolve(i),a=Vc(l,n,e);let c;return a?c=R.near(a,1):e<0?c=R.near(t.doc.resolve(l.before(-1)),-1):c=R.near(t.doc.resolve(l.after(-1)),1),Yr(t,r,c)}}}function Xr(n,e){return(t,r,o)=>{if(!o)return!1;const s=t.selection;let i;if(s instanceof W)i=s;else{const a=Hc(o,n,e);if(a==null)return!1;i=new W(t.doc.resolve(a))}const l=Vc(i.$headCell,n,e);return l?Yr(t,r,new W(i.$anchorCell,l)):!1}}function Gg(n,e){const t=n.state.doc,r=Gn(t.resolve(e));return r?(n.dispatch(n.state.tr.setSelection(new W(r))),!0):!1}function Xg(n,e,t){if(!Oe(n.state))return!1;let r=qg(t);const o=n.state.selection;if(o instanceof W){r||(r={width:1,height:1,rows:[C.from(Rs(pe(n.state.schema).cell,t))]});const s=o.$anchorCell.node(-1),i=o.$anchorCell.start(-1),l=Q.get(s).rectBetween(o.$anchorCell.pos-i,o.$headCell.pos-i);return r=Kg(r,l.right-l.left,l.bottom-l.top),qc(n.state,n.dispatch,i,l,r),!0}else if(r){const s=Kr(n.state),i=s.start(-1);return qc(n.state,n.dispatch,i,Q.get(s.node(-1)).findCell(s.pos-i),r),!0}else return!1}function Ug(n,e){var t;if(e.ctrlKey||e.metaKey)return;const r=Kc(n,e.target);let o;if(e.shiftKey&&n.state.selection instanceof W)s(n.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&r&&(o=Gn(n.state.selection.$anchor))!=null&&((t=zs(n,e))==null?void 0:t.pos)!=o.pos)s(o,e),e.preventDefault();else if(!r)return;function s(a,c){let u=zs(n,c);const f=Ct.getState(n.state)==null;if(!u||!Ps(a,u))if(f)u=a;else return;const d=new W(a,u);if(f||!n.state.selection.eq(d)){const p=n.state.tr.setSelection(d);f&&p.setMeta(Ct,a.pos),n.dispatch(p)}}function i(){n.root.removeEventListener("mouseup",i),n.root.removeEventListener("dragstart",i),n.root.removeEventListener("mousemove",l),Ct.getState(n.state)!=null&&n.dispatch(n.state.tr.setMeta(Ct,-1))}function l(a){const c=a,u=Ct.getState(n.state);let f;if(u!=null)f=n.state.doc.resolve(u);else if(Kc(n,c.target)!=r&&(f=zs(n,e),!f))return i();f&&s(f,c)}n.root.addEventListener("mouseup",i),n.root.addEventListener("dragstart",i),n.root.addEventListener("mousemove",l)}function Hc(n,e,t){if(!(n.state.selection instanceof V))return null;const{$head:r}=n.state.selection;for(let o=r.depth-1;o>=0;o--){const s=r.node(o);if((t<0?r.index(o):r.indexAfter(o))!=(t<0?0:s.childCount))return null;if(s.type.spec.tableRole=="cell"||s.type.spec.tableRole=="header_cell"){const l=r.before(o),a=e=="vert"?t>0?"down":"up":t>0?"right":"left";return n.endOfTextblock(a)?l:null}}return null}function Kc(n,e){for(;e&&e!=n.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function zs(n,e){const t=n.posAtCoords({left:e.clientX,top:e.clientY});return t&&t?Gn(n.state.doc.resolve(t.pos)):null}new lt("tableColumnResizing");function Qg({allowTableNodeSelection:n=!1}={}){return new Be({key:Ct,state:{init(){return null},apply(e,t){const r=e.getMeta(Ct);if(r!=null)return r==-1?null:r;if(t==null||!e.docChanged)return t;const{deleted:o,pos:s}=e.mapping.mapResult(t);return o?null:s}},props:{decorations:xg,handleDOMEvents:{mousedown:Ug},createSelectionBetween(e){return Ct.getState(e.state)!=null?e.state.selection:null},handleTripleClick:Gg,handleKeyDown:Yg,handlePaste:Xg},appendTransaction(e,t,r){return Cg(r,Is(r,t),n)}})}const wt=m.createContext(null),Zg=m.createContext(null),Jc=m.createContext(null),Ur=new WeakMap;function ey(n){const e=Object.create(null);e.class="ProseMirror",e.contenteditable=String(n.editable),n.someProp("attributes",o=>{if(typeof o=="function"&&(o=o(n.state)),o)for(const s in o)s=="class"?e.class+=" "+o[s]:s=="style"?e.style=(e.style?e.style+";":"")+o[s]:!e[s]&&s!="contenteditable"&&s!="nodeName"&&(e[s]=String(o[s]))}),e.translate||(e.translate="no");const t=[Ve.node(0,n.state.doc.content.size,e)],r=Ur.get(n);return!r||r[0].to!==n.state.doc.content.size||!r[0].type.eq(t[0].type)?(Ur.set(n,t),t):r}const ty=[],ny={},$s=H.empty;let Yc=class Sn{constructor(e){j(this,"members");this.members=e}map(e,t){const r=this.members.map(o=>o.map(e,t,ny));return Sn.from(r)}forChild(e,t){if(t.isLeaf)return H.empty;let r=[];for(let o=0;o<this.members.length;o++){const s=this.members[o].forChild(e,t);s!=$s&&(s instanceof Sn?r=r.concat(s.members):r.push(s))}return Sn.from(r)}eq(e){if(!(e instanceof Sn)||e.members.length!=this.members.length)return!1;for(let t=0;t<this.members.length;t++)if(!this.members[t].eq(e.members[t]))return!1;return!0}locals(e){let t,r=!0;for(let o=0;o<this.members.length;o++){const s=this.members[o].localsInner(e);if(s.length)if(!t)t=s;else{r&&(t=t.slice(),r=!1);for(let i=0;i<s.length;i++)t.push(s[i])}}return t?ry(r?t:t.sort(Gc)):ty}static from(e){switch(e.length){case 0:return $s;case 1:return e[0];default:return new Sn(e.every(t=>t instanceof H)?e:e.reduce((t,r)=>t.concat(r instanceof H?r:r.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}};function Gc(n,e){return n.from-e.from||n.to-e.to}function ry(n){let e=n;for(let t=0;t<e.length-1;t++){const r=e[t];if(r.from!=r.to)for(let o=t+1;o<e.length;o++){const s=e[o];if(s.from==r.from){s.to!=r.to&&(e==n&&(e=n.slice()),e[o]=s.copy(s.from,r.to),Xc(e,o+1,s.copy(r.to,s.to)));continue}else{s.from<r.to&&(e==n&&(e=n.slice()),e[t]=r.copy(r.from,s.from),Xc(e,o,r.copy(s.from,r.to)));break}}}return e}function Xc(n,e,t){for(;e<n.length&&Gc(t,n[e])>0;)e++;n.splice(e,0,t)}const js=new WeakMap;function oy(n,e){const t=[];n.someProp("decorations",i=>{const l=i(n.state);l&&l!=$s&&t.push(l)}),e&&t.push(H.create(n.state.doc,[e]));const r=js.get(n);if(!r){const i=Yc.from(t);return js.set(n,i),i}let o=0,s=!0;if(r.forEachSet(i=>{t[o++]!==i&&(s=!1)}),o!==t.length&&(s=!1),!s){const i=Yc.from(t);return js.set(n,i),i}return r}const Bs=function(n){for(let e=0;;e++)if(n=n.previousSibling,!n)return e},Uc=function(n){const e=n.assignedSlot||n.parentNode;return e&&e.nodeType==11?e.host:e},sy=function(n,e,t,r){return t&&(Qc(n,e,t,r,-1)||Qc(n,e,t,r,1))},iy=/^(img|br|input|textarea|hr)$/i;function Qc(n,e,t,r,o){for(;;){if(n==t&&e==r)return!0;if(e==(o<0?0:Qr(n))){const s=n.parentNode;if(!s||s.nodeType!=1||ay(n)||iy.test(n.nodeName)||n.contentEditable=="false")return!1;e=Bs(n)+(o<0?0:1),n=s}else if(n.nodeType==1){if(n=n.childNodes[e+(o<0?-1:0)],n.contentEditable=="false")return!1;e=o<0?Qr(n):0}else return!1}}function Qr(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function ly(n,e,t){for(let r=e==0,o=e==Qr(n);r||o;){if(n==t)return!0;const s=Bs(n);if(n=n.parentNode,!n)return!1;r=r&&s==0,o=o&&s==Qr(n)}return!1}function ay(n){let e;for(let t=n;t&&!(e=t.pmViewDesc);t=t.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==n||e.contentDOM==n)}const Zc=function(n){return n.focusNode&&sy(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)},eu=m.createContext(null);function J(){for(var n=arguments.length,e=new Array(n),t=0;t<n;t++)e[t]=arguments[t];typeof document>"u"||m.useLayoutEffect(...e)}function cy(n,e){const t=m.useContext(eu);J(()=>t(n),e)}function Ke(n,e){const{view:t,flushSyncRef:r}=m.useContext(wt);cy(()=>{if(t!=null&&t.docView){r.current=!1;const o=n(t);return r.current=!0,o}},e&&[t,...e])}const uy=m.forwardRef(function(e,t){let{widget:r,getPos:o,...s}=e;const[i,l]=m.useState(!0),a=m.useRef(null);return m.useImperativeHandle(t,()=>a.current,[]),Ke(c=>{if(!c||!a.current)return;c.domObserver.disconnectSelection();const u=c.domSelection(),f=document.createRange(),d=a.current;d.nodeName=="IMG"&&d.parentNode?f.setEnd(d.parentNode,Bs(d)+1):f.setEnd(d,0),f.collapse(!1),u.removeAllRanges(),u.addRange(f),l(!1),c.domObserver.connectSelection()},[]),i?m.createElement("img",{ref:a,className:"ProseMirror-separator","mark-placeholder":"true",alt:"",...s}):null});function fy(n,e){if(n==e)return!0;for(const t in n)if(n[t]!==e[t])return!1;for(const t in e)if(!(t in n))return!1;return!0}const dy={side:0};class Xn{constructor(e,t){j(this,"Component");j(this,"side");j(this,"spec");this.Component=e,this.spec=t??dy,this.side=this.spec.side??0}map(e,t,r,o){const{pos:s,deleted:i}=e.mapResult(t.from+o,this.side<0?-1:1);return i?null:new Ve(s-r,s-r,this)}valid(){return!0}eq(e){return this==e||e instanceof Xn&&(this.spec.key&&this.spec.key==e.spec.key||this.Component==e.Component&&fy(this.spec,e.spec))}destroy(){}}function hy(n,e,t){return new Ve(n,n,new Xn(e,t))}function Fs(){return Math.floor(Math.random()*0xffffffffffff).toString(16)}const Un=new lt("@handlewithcare/react-prosemirror/reactKeys");function py(){let n=!1;return new Be({key:Un,state:{init(e,t){const r={posToKey:new Map,keyToPos:new Map};return t.doc.descendants((o,s)=>{const i=Fs();return r.posToKey.set(s,i),r.keyToPos.set(i,s),!0}),r},apply(e,t,r,o){if(!e.docChanged||n)return t;const s=e.getMeta(Un),i=(s==null?void 0:s.type)==="bustKey"&&s.payload.key,l={posToKey:new Map,keyToPos:new Map},a=Array.from(t.posToKey.entries()).sort((c,u)=>{let[f]=c,[d]=u;return f-d});for(const[c,u]of a){const{pos:f,deleted:d}=e.mapping.mapResult(c);if(d)continue;let p=u;i===u&&(p=Fs()),l.posToKey.set(f,p),l.keyToPos.set(p,f)}return o.doc.descendants((c,u)=>{if(l.posToKey.has(u))return!0;const f=Fs();return l.posToKey.set(u,f),l.keyToPos.set(f,u),!0}),l}},props:{handleDOMEvents:{compositionstart:()=>{n=!0},compositionend:()=>{n=!1}}}})}function Ls(n,e){var i;let t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(e===null)return!1;const r=t.from??n.state.selection.from,o=t.to??n.state.selection.to;if(n.someProp("handleTextInput",l=>l(n,r,o,e)))return!0;const{tr:s}=n.state;if(t.marks&&s.ensureMarks(t.marks),s.insertText(e,r,o),t.bust){const l=n.state.doc.resolve(r),a=l.sharedDepth(o),c=l.start(a),u=(i=Un.getState(n.state))==null?void 0:i.posToKey.get(c-1);s.setMeta(Un,{type:"bustKey",payload:{key:u}})}return n.dispatch(s),!0}function my(n){let e=null,t=null;return new Be({props:{handleDOMEvents:{compositionstart(r){var i;const{state:o}=r;r.dispatch(o.tr.deleteSelection());const s=o.selection.$from;return o.selection.empty&&(o.storedMarks||!s.textOffset&&s.parentOffset&&((i=s.nodeBefore)!=null&&i.marks.some(l=>l.type.spec.inclusive===!1)))&&n(hy(o.selection.from,uy,{key:"cursor-wrapper",marks:o.storedMarks??s.marks()})),t=o.storedMarks??s.marks(),r.input.composing=!0,!0},compositionupdate(){return!0},compositionend(r){if(r.input.composing=!1,e!==null)return Ls(r,e,{bust:!0,marks:t}),e=null,t=null,n(null),!0},beforeinput(r,o){var s,i;switch(o.preventDefault(),o.inputType){case"insertCompositionText":{if(o.data===null)break;e=o.data;break}case"insertReplacementText":{const l=o.getTargetRanges();(i=(s=o.dataTransfer)==null?void 0:s.items[0])==null||i.getAsString(a=>{for(const c of l){const u=r.posAtDOM(c.startContainer,c.startOffset,1),f=r.posAtDOM(c.endContainer,c.endOffset,1);Ls(r,a,{from:u,to:f})}});break}case"insertText":{Ls(r,o.data);break}case"deleteWordBackward":case"deleteContentBackward":case"deleteWordForward":case"deleteContentForward":case"deleteContent":{const l=o.getTargetRanges(),{tr:a}=r.state;for(const c of l){const u=r.posAtDOM(c.startContainer,c.startOffset),f=r.posAtDOM(c.endContainer,c.endOffset),{doc:d}=r.state,p=d.resolve(u).marksAcross(d.resolve(f));a.delete(u,f).setStoredMarks(p)}r.dispatch(a);break}}return!0}}}})}const Je=typeof navigator<"u"?navigator:null,tu=typeof document<"u"?document:null,Ht=Je&&Je.userAgent||"",Ws=/Edge\/(\d+)/.exec(Ht),nu=/MSIE \d/.exec(Ht),_s=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Ht),Zr=!!(nu||_s||Ws),gy=nu?document.documentMode:_s?+_s[1]:Ws?+Ws[1]:0,ru=!Zr&&/gecko\/(\d+)/i.test(Ht);ru&&+(/Firefox\/(\d+)/.exec(Ht)||[0,0])[1];const qs=!Zr&&/Chrome\/(\d+)/.exec(Ht),yy=!!qs,by=qs?+qs[1]:0,ou=!Zr&&!!Je&&/Apple Computer/.test(Je.vendor);ou&&(/Mobile\/\w+/.test(Ht)||!!Je&&Je.maxTouchPoints>2)||Je&&/Mac/.test(Je.platform),Je&&/Win/.test(Je.platform),!!tu&&"webkitFontSmoothing"in tu.documentElement.style&&+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1];const ae={ie:Zr,ie_version:gy,gecko:ru,chrome:yy,chrome_version:by,safari:ou};function su(n){return n.editable&&!n.hasFocus()?!1:xy(n)}function xy(n){var t,r;const e=n.domSelectionRange();if(!e.anchorNode)return!1;try{return n.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(n.editable||n.dom.contains(((t=e.focusNode)==null?void 0:t.nodeType)==3?(r=e.focusNode)==null?void 0:r.parentNode:e.focusNode))}catch{return!1}}function ky(n,e,t,r){return n.someProp("createSelectionBetween",o=>o(n,e,t))||V.between(e,t,r)}function iu(n){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null;const t=n.domSelectionRange(),r=n.state.doc;if(!t.focusNode)return null;let o=n.docView.nearestDesc(t.focusNode);const s=o&&o.size==0;let i=n.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(i<0)return null;let l=r.resolve(i),a,c;if(Zc(t)){for(a=i;o&&!o.node;)o=o.parent;const f=o.node;if(o&&f.isAtom&&O.isSelectable(f)&&o.parent&&!(f.isInline&&ly(t.focusNode,t.focusOffset,o.dom))){const d=o.posBefore;c=new O(i==d?l:r.resolve(d))}}else{if(t instanceof n.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let f=i,d=i;for(let p=0;p<t.rangeCount;p++){const h=t.getRangeAt(p);f=Math.min(f,n.docView.posFromDOM(h.startContainer,h.startOffset,1)),d=Math.max(d,n.docView.posFromDOM(h.endContainer,h.endOffset,-1))}if(f<0)return null;[a,i]=d==n.state.selection.anchor?[d,f]:[f,d],l=r.resolve(i)}else a=n.docView.posFromDOM(t.anchorNode,t.anchorOffset,1);if(a<0)return null}const u=r.resolve(a);if(!c){const f=e=="pointer"||n.state.selection.head<l.pos&&!s?1:-1;c=ky(n,u,l,f)}return c}const eo=function(n,e,t,r){return t&&(lu(n,e,t,r,-1)||lu(n,e,t,r,1))};function Sy(n){let e;for(let t=n;t&&!(e=t.pmViewDesc);t=t.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==n||e.contentDOM==n)}const Cy=/^(img|br|input|textarea|hr)$/i;function lu(n,e,t,r,o){for(;;){if(n==t&&e==r)return!0;if(e==(o<0?0:au(n))){const s=n.parentNode;if(!s||s.nodeType!=1||Sy(n)||Cy.test(n.nodeName)||n.contentEditable=="false")return!1;e=Mt(n)+(o<0?0:1),n=s}else if(n.nodeType==1){if(n=n.childNodes[e+(o<0?-1:0)],n.contentEditable=="false")return!1;e=o<0?au(n):0}else return!1}}const Mt=function(n){let e=n;for(let t=0;;t++)if(e=e.previousSibling,!e)return t};function au(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function wy(n,e){const t=n;if(e instanceof O){const r=t.docView.descAt(e.from);r!=t.lastSelectedViewDesc&&(cu(t),r&&r.selectNode(),t.lastSelectedViewDesc=r)}else cu(t)}function cu(n){const e=n;e.lastSelectedViewDesc&&(e.lastSelectedViewDesc.parent&&e.lastSelectedViewDesc.deselectNode(),e.lastSelectedViewDesc=void 0)}function My(n){const e=n,t=e.domSelectionRange();if(!t.anchorNode)return!1;try{return e.dom.contains(t.anchorNode.nodeType==3?t.anchorNode.parentNode:t.anchorNode)&&(e.editable||e.dom.contains(t.focusNode.nodeType==3?t.focusNode.parentNode:t.focusNode))}catch{return!1}}function uu(n){return n.editable?n.hasFocus():My(n)&&document.activeElement&&document.activeElement.contains(n.dom)}function Ny(n){const e=n,t=e.domSelection(),r=document.createRange();if(!t)return;const o=e.cursorWrapper.dom,s=o.nodeName=="IMG";s?r.setStart(o.parentNode,Mt(o)+1):r.setStart(o,0),r.collapse(!0),t.removeAllRanges(),t.addRange(r),!s&&!e.state.selection.visible&&ae.ie&&ae.ie_version<=11&&(o.disabled=!0,o.disabled=!1)}function fu(n,e){const t=n,{node:r,offset:o}=t.docView.domFromPos(e,0),s=o<r.childNodes.length?r.childNodes[o]:null,i=o?r.childNodes[o-1]:null;if(ae.safari&&s&&s.contentEditable=="false")return Hs(s);if((!s||s.contentEditable=="false")&&(!i||i.contentEditable=="false")){if(s)return Hs(s);if(i)return Hs(i)}}function Hs(n){return n.contentEditable="true",ae.safari&&n.draggable&&(n.draggable=!1,n.wasDraggable=!0),n}function du(n){n.contentEditable="false",n.wasDraggable&&(n.draggable=!0,n.wasDraggable=null)}function Ey(n){const e=n,t=e.dom.ownerDocument;t.removeEventListener("selectionchange",e.input.hideSelectionGuard);const r=e.domSelectionRange(),o=r.anchorNode,s=r.anchorOffset;t.addEventListener("selectionchange",e.input.hideSelectionGuard=()=>{(r.anchorNode!=o||r.anchorOffset!=s)&&(t.removeEventListener("selectionchange",e.input.hideSelectionGuard),setTimeout(()=>{(!uu(e)||e.state.selection.visible)&&e.dom.classList.remove("ProseMirror-hideselection")},20))})}const hu=ae.safari||ae.chrome&&ae.chrome_version<63;function to(n){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;const t=n,r=t.state.selection;if(wy(t,r),!!uu(t)){if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&ae.chrome){const o=t.domSelectionRange(),s=t.domObserver.currentSelection;if(o.anchorNode&&s.anchorNode&&eo(o.anchorNode,o.anchorOffset,s.anchorNode,s.anchorOffset)){t.input.mouseDown.delayedSelectionSync=!0,t.domObserver.setCurSelection();return}}if(t.domObserver.disconnectSelection(),t.cursorWrapper)Ny(t);else{const{anchor:o,head:s}=r;let i,l;hu&&!(r instanceof V)&&(r.$from.parent.inlineContent||(i=fu(t,r.from)),!r.empty&&!r.$from.parent.inlineContent&&(l=fu(t,r.to))),t.docView.setSelection(o,s,t,e),hu&&(i&&du(i),l&&du(l)),r.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&Ey(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}}let Dy=class{constructor(){j(this,"anchorNode",null);j(this,"anchorOffset",0);j(this,"focusNode",null);j(this,"focusOffset",0)}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}};class Oy{constructor(e){j(this,"view");j(this,"flushingSoon");j(this,"currentSelection");j(this,"suppressingSelectionUpdates");this.view=e,this.flushingSoon=-1,this.currentSelection=new Dy,this.suppressingSelectionUpdates=!1,this.view=e,this.onSelectionChange=this.onSelectionChange.bind(this)}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}stop(){this.disconnectSelection()}start(){this.connectSelection()}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;const t=new Set;let r;for(let s=e.focusNode;s;s=Uc(s))t.add(s);for(let s=e.anchorNode;s;s=Uc(s))if(t.has(s)){r=s;break}const o=r&&this.view.docView.nearestDesc(r);if(o&&o.ignoreMutation({type:"selection",target:(r==null?void 0:r.nodeType)==3?r==null?void 0:r.parentNode:r}))return this.setCurSelection(),!0}registerMutation(){}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}updateSelection(){const{view:e}=this,t=e.input.compositionPendingChanges||(e.composing?e.input.compositionID:0);e.input.compositionPendingChanges=0;const r=e.input.lastSelectionTime>Date.now()-50?e.input.lastSelectionOrigin:null,o=iu(e,r);if(o&&!e.state.selection.eq(o)){const s=e.state.tr.setSelection(o);r=="pointer"?s.setMeta("pointer",!0):r=="key"&&s.scrollIntoView(),t&&s.setMeta("composition",t),e.dispatch(s)}}selectionToDOM(){const{view:e}=this;to(e);const t=e.domSelectionRange();this.currentSelection.set(t)}flush(){const{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;const t=e.domSelectionRange(),r=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(t)&&su(e)&&!this.ignoreSelectionChange(t);let o=null;r&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&Zc(t)&&(o=iu(e))&&o.eq(R.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,to(e),this.currentSelection.set(t),e.scrollToSelection()):r&&(this.updateSelection(),this.currentSelection.eq(t)||to(e),this.currentSelection.set(t))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}onSelectionChange(){if(su(this.view)&&!this.view.composing){if(this.suppressingSelectionUpdates)return to(this.view);if(ae.ie&&ae.ie_version<=11&&!this.view.state.selection.empty){const e=this.view.domSelectionRange();if(e.focusNode&&eo(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}}let vy=class{add(){}remove(){}},pu=class co{constructor(){j(this,"nodeName","div");j(this,"style",{})}get parent(){return new co}get parentNode(){return new co}appendChild(){return new co}setAttribute(){}hasAttribute(){return!1}insertBefore(){}get classList(){return new vy}get ownerDocument(){return new mu}addEventListener(){}removeEventListener(){}replaceChildren(){}},mu=class{createElement(){return new pu}addEventListener(){}removeEventListener(){}get documentElement(){return new pu}};function gu(){const n=globalThis.window;globalThis.window??(globalThis.window={visualViewport:null});const e=globalThis.document;return globalThis.document??(globalThis.document=new mu),function(){globalThis.window!==n&&(globalThis.window=n),globalThis.document!==e&&(globalThis.document=e)}}function Kt(n,e){return n instanceof er?1:e instanceof er?-1:n.getPos()-e.getPos()}const gn=0,yu=1,no=2,Qn=3;class Zn{constructor(e,t,r,o,s){j(this,"parent");j(this,"children");j(this,"getPos");j(this,"dom");j(this,"contentDOM");j(this,"dirty");j(this,"node");this.parent=e,this.children=t,this.getPos=r,this.dom=o,this.contentDOM=s,this.dirty=gn,o.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,r){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;t<this.children.length;t++)e+=this.children[t].size;return e}get border(){return 0}destroy(){}posBeforeChild(e){for(let t=0,r=this.posAtStart;;t++){const o=this.children[t];if(o==e)return r;r+=o.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,t,r){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(r<0){let s,i;if(e==this.contentDOM)s=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;s=e.previousSibling}for(;s&&!((i=s.pmViewDesc)&&i.parent==this);)s=s.previousSibling;return s?this.posBeforeChild(i)+i.size:this.posAtStart}else{let s,i;if(e==this.contentDOM)s=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;s=e.nextSibling}for(;s&&!((i=s.pmViewDesc)&&i.parent==this);)s=s.nextSibling;return s?this.posBeforeChild(i):this.posAtEnd}let o;if(e==this.dom&&this.contentDOM)o=t>Mt(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))o=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(t==0)for(let s=e;;s=s.parentNode){if(s==this.dom){o=!1;break}if(s.previousSibling)break}if(o==null&&t==e.childNodes.length)for(let s=e;;s=s.parentNode){if(s==this.dom){o=!0;break}if(s.nextSibling)break}}return o??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;for(let r=!0,o=e;o;o=o.parentNode){const s=this.getDesc(o);let i;if(s&&(!t||s.node))if(r&&(i=s.nodeDOM)&&!(i.nodeType==1?i.contains(e.nodeType==1?e:e.parentNode):i==e))r=!1;else return s}}getDesc(e){const t=e.pmViewDesc;for(let r=t;r;r=r.parent)if(r==this)return t}posFromDOM(e,t,r){for(let o=e;o;o=o.parentNode){const s=this.getDesc(o);if(s)return s.localPosFromDOM(e,t,r)}return-1}descAt(e){for(let t=0,r=0;t<this.children.length;t++){let o=this.children[t];const s=r+o.size;if(r==e&&s!=r){for(;!o.border&&o.children.length;)o=o.children[0];return o}if(e<s)return o.descAt(e-r-o.border);r=s}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let r=0,o=0;for(let s=0;r<this.children.length;r++){const i=this.children[r],l=s+i.size;if(l>e||i instanceof er){o=e-s;break}s=l}if(o)return this.children[r].domFromPos(o-this.children[r].border,t);for(let s;r&&!(s=this.children[r-1]).size&&s instanceof Ks&&s.side>=0;r--);if(t<=0){let s,i=!0;for(;s=r?this.children[r-1]:null,!(!s||s.dom.parentNode==this.contentDOM);r--,i=!1);return s&&t&&i&&!s.border&&!s.domAtom?s.domFromPos(s.size,t):{node:this.contentDOM,offset:s?Mt(s.dom)+1:0}}else{let s,i=!0;for(;s=r<this.children.length?this.children[r]:null,!(!s||s.dom.parentNode==this.contentDOM);r++,i=!1);return s&&i&&!s.border&&!s.domAtom?s.domFromPos(0,t):{node:this.contentDOM,offset:s?Mt(s.dom):this.contentDOM.childNodes.length}}}parseRange(e,t){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0;if(this.children.length==0)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let o=-1,s=-1;for(let i=r,l=0;;l++){const a=this.children[l],c=i+a.size;if(o==-1&&e<=c){const u=i+a.border;if(e>=u&&t<=c-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,t,u);e=i;for(let f=l;f>0;f--){const d=this.children[f-1];if(d.size&&d.dom.parentNode==this.contentDOM&&!d.emptyChildAt(1)){o=Mt(d.dom)+1;break}e-=d.size}o==-1&&(o=0)}if(o>-1&&(c>t||l==this.children.length-1)){t=c;for(let u=l+1;u<this.children.length;u++){const f=this.children[u];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(-1)){s=Mt(f.dom);break}t+=f.size}s==-1&&(s=this.contentDOM.childNodes.length);break}i=c}return{node:this.contentDOM,from:e,to:t,fromOffset:o,toOffset:s}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;const t=this.children[e<0?0:this.children.length-1];return t.size==0||t.emptyChildAt(e)}domAfterPos(e){const{node:t,offset:r}=this.domFromPos(e,0);if(t.nodeType!=1||r==t.childNodes.length)throw new RangeError("No node after pos "+e);return t.childNodes[r]}setSelection(e,t,r){var p;let o=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1;const s=Math.min(e,t),i=Math.max(e,t);for(let h=0,b=0;h<this.children.length;h++){const g=this.children[h],x=b+g.size;if(s>b&&i<x)return g.setSelection(e-b-g.border,t-b-g.border,r,o);b=x}let l=this.domFromPos(e,e?-1:1),a=t==e?l:this.domFromPos(t,t?-1:1);const c=r.root.getSelection(),u=r.domSelectionRange();let f=!1;if((ae.gecko||ae.safari)&&e==t){const{node:h,offset:b}=l;if(h.nodeType==3){if(f=!!(b&&((p=h.nodeValue)==null?void 0:p[b-1])==`
|
|
45
|
-
`),f&&b==h.nodeValue.length)for(let g=h,x;g;g=g.parentNode){if(x=g.nextSibling){x.nodeName=="BR"&&(l=a={node:x.parentNode,offset:Mt(x)+1});break}const S=g.pmViewDesc;if(S&&S.node&&S.node.isBlock)break}}else{const g=h.childNodes[b-1];f=g&&(g.nodeName=="BR"||g.contentEditable=="false")}}if(ae.gecko&&u.focusNode&&u.focusNode!=a.node&&u.focusNode.nodeType==1){const h=u.focusNode.childNodes[u.focusOffset];h&&h.contentEditable=="false"&&(o=!0)}if(!(o||f&&ae.safari)&&eo(l.node,l.offset,u.anchorNode,u.anchorOffset)&&eo(a.node,a.offset,u.focusNode,u.focusOffset))return;let d=!1;if((c.extend||e==t)&&!f){c.collapse(l.node,l.offset);try{e!=t&&c.extend(a.node,a.offset),d=!0}catch{}}if(!d){if(e>t){const b=l;l=a,a=b}const h=document.createRange();h.setEnd(a.node,a.offset),h.setStart(l.node,l.offset),c.removeAllRanges(),c.addRange(h)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let r=0,o=0;o<this.children.length;o++){const s=this.children[o],i=r+s.size;if(r==i?e<=i&&t>=r:e<i&&t>r){const l=r+s.border,a=i-s.border;if(e>=l&&t<=a){this.dirty=e==r||t==i?no:yu,e==l&&t==a&&(s.contentLost||s.dom.parentNode!=this.contentDOM)?s.dirty=Qn:s.markDirty(e-l,t-l);return}else s.dirty=s.dom==s.contentDOM&&s.dom.parentNode==this.contentDOM&&!s.children.length?no:Qn}r=i}this.dirty=no}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){const r=e==1?no:yu;t.dirty<r&&(t.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}}class Ks extends Zn{constructor(t,r,o,s){super(t,[],r,s,null);j(this,"widget");this.widget=o,this.widget=o}matchesWidget(t){return this.dirty==gn&&t.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(t){const r=this.widget.spec.stopEvent;return r?r(t):!1}ignoreMutation(t){return t.type!="selection"||this.widget.spec.ignoreSelection}get domAtom(){return!0}get side(){return this.widget.type.side}}class ro extends Zn{constructor(t,r,o,s,i){super(t,[],r,o,null);j(this,"textDOM");j(this,"text");this.textDOM=s,this.text=i}get size(){return this.text.length}localPosFromDOM(t,r){return t!=this.textDOM?this.posAtStart+(r?this.size:0):this.posAtStart+r}domFromPos(t){return{node:this.textDOM,offset:t}}ignoreMutation(t){return t.type==="characterData"&&t.target.nodeValue==t.oldValue}}class Ty extends Zn{constructor(t,r,o,s,i,l,a){super(t,r,o,i,l);j(this,"mark");j(this,"spec");this.mark=s,this.spec=a}parseRule(){return this.dirty&Qn||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(t){return this.dirty!=Qn&&this.mark.eq(t)}markDirty(t,r){if(super.markDirty(t,r),this.dirty!=gn){let o=this.parent;for(;!o.node;)o=o.parent;o.dirty<this.dirty&&(o.dirty=this.dirty),this.dirty=gn}}ignoreMutation(t){return this.spec.ignoreMutation?this.spec.ignoreMutation(t):super.ignoreMutation(t)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class Js extends Zn{constructor(t,r,o,s,i,l,a,c,u,f,d,p,h){super(t,r,o,a,c);j(this,"node");j(this,"outerDeco");j(this,"innerDeco");j(this,"nodeDOM");j(this,"stopEvent");j(this,"selectNode");j(this,"deselectNode");j(this,"ignoreMutation");this.node=s,this.outerDeco=i,this.innerDeco=l,this.nodeDOM=u,this.stopEvent=f,this.selectNode=d,this.deselectNode=p,this.ignoreMutation=h}updateOuterDeco(){}parseRule(){if(this.node.type.spec.reparseInView)return null;const t={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(t.preserveWhitespace="full"),!this.contentDOM)t.getContent=()=>this.node.content;else if(!this.contentLost)t.contentElement=this.contentDOM;else{for(let r=this.children.length-1;r>=0;r--){const o=this.children[r];if(this.dom.contains(o.dom.parentNode)){t.contentElement=o.dom.parentNode;break}}t.contentElement||(t.getContent=()=>C.empty)}return t}matchesNode(t,r,o){return this.dirty==gn&&t.eq(this.node)&&Py(r,this.outerDeco)&&o.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}update(t,r,o,s){return!0}get domAtom(){return this.node.isAtom}}class Ay extends Js{constructor(e,t,r,o,s,i,l,a){super(e,t,r,o,s,i,l,null,a,()=>!1,()=>{},()=>{},c=>c.type!="characterData"&&c.type!="selection")}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,r,o){return!0}inParent(){const e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,r){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,r)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=Qn)}get domAtom(){return!1}}class er extends Zn{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==gn&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}function Py(n,e){if(n.length!=e.length)return!1;for(let t=0;t<n.length;t++)if(!n[t].type.eq(e[t].type))return!1;return!0}function Iy(n){const e={};for(const[r,o]of n.entries()){let s=function(i,l){for(const a of o){let c=!1;if(Ye.unstable_batchedUpdates(()=>{c=!!a.call(this,i,l)}),c||l.defaultPrevented)return!0}return!1};e[r]=s}return new Be({key:new lt("@handlewithcare/react-prosemirror/componentEventListeners"),props:{handleDOMEvents:e}})}function Vy(){const[n,e]=m.useState(new Map),t=m.useCallback((s,i)=>{const l=n.get(s)??[];l.unshift(i),n.has(s)||(n.set(s,l),e(new Map(n)))},[n]),r=m.useCallback((s,i)=>{const l=n.get(s);l==null||l.splice(l.indexOf(i),1)},[n]),o=m.useMemo(()=>Iy(n),[n]);return{registerEventListener:t,unregisterEventListener:r,componentEventListenersPlugin:o}}function Ys(){const[,n]=m.useReducer(e=>e+1,0);return n}function Ry(n){const e=Object.create(null);function t(r){for(const o in r)Object.prototype.hasOwnProperty.call(e,o)||(e[o]=r[o])}return n.someProp("nodeViews",t),n.someProp("markViews",t),e}function zy(n,e){let t=0,r=0;for(const o in n){if(n[o]!=e[o])return!0;t++}for(const o in e)r++;return t!=r}function $y(n,e){for(const t of Object.keys(n))if(n[t]!==e[t])return!0;return!1}function bu(n){return!n.someProp("editable",e=>e(n.state)===!1)}class xu extends vp{constructor(t,r){const o=gu();super(t,{state:Ge.create({schema:r.state.schema,plugins:r.state.plugins}),plugins:r.plugins});j(this,"shouldUpdatePluginViews",!1);j(this,"oldProps");j(this,"_props");o(),this.shouldUpdatePluginViews=!0,this._props=r,this.oldProps={state:r.state},this.state=r.state,this.domObserver.stop(),this.domObserver=new Oy(this),this.domObserver.start(),this.editable=bu(this),this.docView.dom.replaceChildren(),this.docView=r.docView}get needsRedraw(){if(this.oldProps.state.plugins===this._props.state.plugins&&this._props.plugins===this.oldProps.plugins)return!1;const t=Ry(this);return zy(this.nodeViews,t)}pureSetProps(t){this._props={...this._props,...t},this.state=this._props.state,this.editable=bu(this)}runPendingEffects(){if($y(this.props,this.oldProps)){const t=this.props;this._props=this.oldProps,this.state=this._props.state,this.update(t)}}update(t){super.update(t),this.oldProps=t}updatePluginViews(t){this.shouldUpdatePluginViews&&super.updatePluginViews(t)}destroy(){this.dom=document.createElement("div"),super.destroy()}}const jy=new xr({nodes:{doc:{content:"text*"},text:{inline:!0}}}),By=Ge.create({schema:jy});let ku=!1;function Fy(n,e){process.env.NODE_ENV!=="production"&&e.defaultState!==void 0&&e.state!==void 0&&!ku&&(console.error("A component contains a ProseMirror editor with both value and defaultValue props. ProseMirror editors must be either controlled or uncontrolled (specify either the state prop, or the defaultState prop, but not both). Decide between using a controlled or uncontrolled ProseMirror editor and remove one of these props. More info: https://reactjs.org/link/controlled-components"),ku=!0);const t=m.useRef(!0),[r,o]=m.useState(null),s=Ys(),i=e.defaultState??By,[l,a]=m.useState(i),c=e.state??l,{componentEventListenersPlugin:u,registerEventListener:f,unregisterEventListener:d}=Vy(),p=m.useCallback(I=>{Ye.flushSync(()=>{o(I)})},[]),h=m.useMemo(()=>[...e.plugins??[],u,my(p)],[e.plugins,u,p]),b=m.useCallback(function(z){t.current?Ye.flushSync(()=>{e.state||a(v=>v.apply(z)),e.dispatchTransaction&&e.dispatchTransaction.call(this,z)}):(e.state||a(v=>v.apply(z)),e.dispatchTransaction&&e.dispatchTransaction.call(this,z))},[e.dispatchTransaction,e.state]),g=gu(),x=document.createElement("div");g();const S=m.useRef(new Js(void 0,[],()=>-1,c.doc,[],H.empty,x,null,x,()=>!1,()=>{},()=>{},()=>!1)),w={...e,state:c,plugins:h,dispatchTransaction:b,docView:S.current},[D,T]=m.useState(()=>new xu(null,w));return J(()=>()=>{D==null||D.destroy()},[D]),J(()=>{if(!n){T(null);return}if(!D||D.dom!==n){const I=new xu({mount:n},w);T(I),I.dom.addEventListener("compositionend",s);return}if(D.needsRedraw){T(null);return}D==null||D.domObserver.selectionToDOM(),D==null||D.runPendingEffects()}),D==null||D.pureSetProps(w),{editor:m.useMemo(()=>({view:D,registerEventListener:f,unregisterEventListener:d,cursorWrapper:r,docViewDescRef:S,flushSyncRef:t}),[D,f,d,r]),state:c}}function Ly(n){let{children:e}=n;const t=m.useRef(new Set).current,r=m.useRef(new Set).current,o=m.useRef(!1),s=Ys(),i=m.useRef(!0),l=m.useCallback(()=>{i.current||(s(),i.current=!0)},[s]),a=m.useCallback(c=>{let u;const f=()=>{u=c()};return t.add(f),l(),()=>{t.delete(f),u&&(o.current?(r.add(u),l()):u())}},[t,r,l]);return J(()=>(i.current=!1,t.forEach(c=>c()),t.clear(),()=>{r.forEach(c=>c()),r.clear()})),J(()=>(o.current=!0,()=>{o.current=!1}),[]),m.createElement(eu.Provider,{value:a},e)}const Ce=m.createContext({parentRef:{current:void 0},siblingsRef:{current:[]}});function Gs(n,e,t,r,o,s,i,l){const{view:a}=m.useContext(wt),[c,u]=m.useState(!0),f=m.useRef(i),d=m.useRef(()=>!1),p=m.useCallback(M=>{d.current=M},[]),h=m.useRef(()=>!1),b=m.useCallback(M=>{h.current=M},[]),g=m.useRef(()=>{!r.current||!n||(r.current.nodeType==1&&r.current.classList.add("ProseMirror-selectednode"),(l!=null&&l.current||!n.type.spec.draggable)&&(((t==null?void 0:t.current)??r.current).draggable=!0))}),x=m.useRef(()=>{!r.current||!n||r.current.nodeType==1&&(r.current.classList.remove("ProseMirror-selectednode"),(l!=null&&l.current||!n.type.spec.draggable)&&((t==null?void 0:t.current)??r.current).removeAttribute("draggable"))}),S=m.useCallback((M,I)=>{g.current=M,x.current=I},[]),{siblingsRef:w,parentRef:D}=m.useContext(Ce),T=m.useRef([]);return J(()=>{const M=w.current;return()=>{if(f.current&&M.includes(f.current)){const I=M.indexOf(f.current);M.splice(I,1)}}},[w]),J(()=>{var I;if(!n||!r.current)return;const M=T.current[0];f.current?(f.current.parent=D.current,f.current.children=T.current,f.current.node=n,f.current.getPos=e,f.current.outerDeco=s,f.current.innerDeco=o,f.current.dom=(t==null?void 0:t.current)??r.current,f.current.dom.pmViewDesc=f.current,f.current.contentDOM=(l==null?void 0:l.current)??f.current.contentDOM??(M==null?void 0:M.dom.parentElement)??null,f.current.nodeDOM=r.current):f.current=new Js(D.current,T.current,e,n,s,o,(t==null?void 0:t.current)??r.current,(M==null?void 0:M.dom.parentElement)??null,r.current,z=>!!d.current(z),()=>g.current(),()=>x.current(),z=>h.current(z)),u(f.current.contentDOM!==null),w.current.includes(f.current)||w.current.push(f.current),w.current.sort(Kt);for(const z of T.current)if(z.parent=f.current,z instanceof ro){const v=(I=f.current.contentDOM)==null?void 0:I.firstChild;if(!v)throw new Error("Started a composition but couldn't find the text node it belongs to.");let L=v;for(;L.firstChild;)L=L.firstChild;if(!L||!(L instanceof Text))throw new Error("Started a composition but couldn't find the text node it belongs to.");z.dom=v,z.textDOM=L,z.text=L.data,z.textDOM.pmViewDesc=z,a==null||a.input.compositionNodes.push(z)}return()=>{var z,v,L,we;((z=f.current)==null?void 0:z.children[0])instanceof ro&&!(a!=null&&a.composing)&&((we=(v=f.current)==null?void 0:v.children[0].dom.parentNode)==null||we.removeChild((L=f.current)==null?void 0:L.children[0].dom))}}),{hasContentDOM:c,childDescriptors:T,nodeViewDescRef:f,setStopEvent:p,setSelectNode:S,setIgnoreMutation:b}}function Wy(n,e){return n.type.side-e.type.side}function _y(n,e,t,r){const o=e.locals(n);let s=0;if(o.length==0){for(let c=0;c<n.childCount;c++){const u=n.child(c);r(u,o,e.forChild(s,u),s,c),s+=u.nodeSize}return}let i=0;const l=[];let a=null;for(let c=0;;){if(i<o.length&&o[i].to==s){const h=o[i++];let b;for(;i<o.length&&o[i].to==s;)(b||(b=[h])).push(o[i++]);if(b){b.sort(Wy);for(let g=0;g<b.length;g++)t(b[g],!(b[g].type instanceof Xn),s,c+g,!!a)}else t(h,!(h.type instanceof Xn),s,c,!!a)}let u,f;if(a)f=-1,u=a,a=null;else if(c<n.childCount)f=c,u=n.child(c++);else break;for(let h=0;h<l.length;h++)l[h].to<=s&&l.splice(h--,1);for(;i<o.length&&o[i].from<=s&&o[i].to>s;)l.push(o[i++]);let d=s+u.nodeSize;if(u.isText){let h=d;i<o.length&&o[i].from<h&&(h=o[i].from);for(let b=0;b<l.length;b++)l[b].to<h&&(h=l[b].to);h<d&&(a=u.cut(h-s),u=u.cut(0,h-s),d=h,f=-1)}const p=u.isInline&&!u.isLeaf?l.filter(h=>!h.inline):l.slice();r(u,p,e.forChild(s,u),s,f),s=d}}function qy(){const{view:n}=m.useContext(wt);return n&&Un.getState(n.state)}var Su={exports:{}};/*!
|
|
44
|
+
`))),0,0):E.empty;let f=n.someProp("clipboardTextParser",d=>d(e,o,r,n));if(f)l=f;else{let d=o.marks(),{schema:p}=n.state,h=$e.fromSchema(p);i=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(b=>{let g=i.appendChild(document.createElement("p"));b&&g.appendChild(h.serializeNode(p.text(b,d)))})}}else n.someProp("transformPastedHTML",f=>{t=f(t,n)}),i=Fm(t),bs&&Lm(i);let c=i&&i.querySelector("[data-pm-slice]"),u=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(u&&u[3])for(let f=+u[3];f>0;f--){let d=i.firstChild;for(;d&&d.nodeType!=1;)d=d.nextSibling;if(!d)break;i=d}if(l||(l=(n.someProp("clipboardParser")||n.someProp("domParser")||Pt.fromSchema(n.state.schema)).parseSlice(i,{preserveWhitespace:!!(a||u),context:o,ruleFromNode(d){return d.nodeName=="BR"&&!d.nextSibling&&d.parentNode&&!$m.test(d.parentNode.nodeName)?{ignore:!0}:null}})),u)l=Wm(bc(l,+u[1],+u[2]),u[4]);else if(l=E.maxOpen(jm(l.content,o),!0),l.openStart||l.openEnd){let f=0,d=0;for(let p=l.content.firstChild;f<l.openStart&&!p.type.spec.isolating;f++,p=p.firstChild);for(let p=l.content.lastChild;d<l.openEnd&&!p.type.spec.isolating;d++,p=p.lastChild);l=bc(l,f,d)}return n.someProp("transformPasted",f=>{l=f(l,n)}),l}const $m=/^(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 jm(n,e){if(n.childCount<2)return n;for(let t=e.depth;t>=0;t--){let o=e.node(t).contentMatchAt(e.index(t)),s,i=[];if(n.forEach(l=>{if(!i)return;let a=o.findWrapping(l.type),c;if(!a)return i=null;if(c=i.length&&s.length&&gc(a,s,l,i[i.length-1],0))i[i.length-1]=c;else{i.length&&(i[i.length-1]=yc(i[i.length-1],s.length));let u=mc(l,a);i.push(u),o=o.matchType(u.type),s=a}}),i)return C.from(i)}return n}function mc(n,e,t=0){for(let r=e.length-1;r>=t;r--)n=e[r].create(null,C.from(n));return n}function gc(n,e,t,r,o){if(o<n.length&&o<e.length&&n[o]==e[o]){let s=gc(n,e,t,r.lastChild,o+1);if(s)return r.copy(r.content.replaceChild(r.childCount-1,s));if(r.contentMatchAt(r.childCount).matchType(o==n.length-1?t.type:n[o+1]))return r.copy(r.content.append(C.from(mc(t,n,o+1))))}}function yc(n,e){if(e==0)return n;let t=n.content.replaceChild(n.childCount-1,yc(n.lastChild,e-1)),r=n.contentMatchAt(n.childCount).fillBefore(C.empty,!0);return n.copy(t.append(r))}function ws(n,e,t,r,o,s){let i=e<0?n.firstChild:n.lastChild,l=i.content;return n.childCount>1&&(s=0),o<r-1&&(l=ws(l,e,t,r,o+1,s)),o>=t&&(l=e<0?i.contentMatchAt(0).fillBefore(l,s<=o).append(l):l.append(i.contentMatchAt(i.childCount).fillBefore(C.empty,!0))),n.replaceChild(e<0?0:n.childCount-1,i.copy(l))}function bc(n,e,t){return e<n.openStart&&(n=new E(ws(n.content,-1,e,n.openStart,0,n.openEnd),e,n.openEnd)),t<n.openEnd&&(n=new E(ws(n.content,1,t,n.openEnd,0,0),n.openStart,t)),n}const xc={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};let kc=null;function Sc(){return kc||(kc=document.implementation.createHTMLDocument("title"))}let Ms=null;function Bm(n){let e=window.trustedTypes;return e?(Ms||(Ms=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})),Ms.createHTML(n)):n}function Fm(n){let e=/^(\s*<meta [^>]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=Sc().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(n),o;if((o=r&&xc[r[1].toLowerCase()])&&(n=o.map(s=>"<"+s+">").join("")+n+o.map(s=>"</"+s+">").reverse().join("")),t.innerHTML=Bm(n),o)for(let s=0;s<o.length;s++)t=t.querySelector(o[s])||t;return t}function Lm(n){let e=n.querySelectorAll(bt?"span:not([class]):not([style])":"span.Apple-converted-space");for(let t=0;t<e.length;t++){let r=e[t];r.childNodes.length==1&&r.textContent==" "&&r.parentNode&&r.parentNode.replaceChild(n.ownerDocument.createTextNode(" "),r)}}function Wm(n,e){if(!n.size)return n;let t=n.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return n}let{content:o,openStart:s,openEnd:i}=n;for(let l=r.length-2;l>=0;l-=2){let a=t.nodes[r[l]];if(!a||a.hasRequiredAttrs())break;o=C.from(a.create(r[l+1],o)),s++,i++}return new E(o,s,i)}const Re={},Se={};function kt(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}Se.keydown=(n,e)=>{let t=e;if(n.input.shiftKey=t.keyCode==16||t.shiftKey,!wc(n,t)&&(n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),!(Hn&&bt&&t.keyCode==13)))if(t.keyCode!=229&&n.domObserver.forceFlush(),ys&&t.keyCode==13&&!t.ctrlKey&&!t.altKey&&!t.metaKey){let r=Date.now();n.input.lastIOSEnter=r,n.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{n.input.lastIOSEnter==r&&(n.someProp("handleKeyDown",o=>o(n,Xa(13,"Enter"))),n.input.lastIOSEnter=0)},200)}else n.someProp("handleKeyDown",r=>r(n,t))||zm(n,t)?t.preventDefault():kt(n,"key")},Se.keyup=(n,e)=>{e.keyCode==16&&(n.input.shiftKey=!1)},Se.keypress=(n,e)=>{let t=e;if(wc(n,t)||!t.charCode||t.ctrlKey&&!t.altKey||De&&t.metaKey)return;if(n.someProp("handleKeyPress",o=>o(n,t))){t.preventDefault();return}let r=n.state.selection;if(!(r instanceof V)||!r.$from.sameParent(r.$to)){let o=String.fromCharCode(t.charCode);!/[\r\n]/.test(o)&&!n.someProp("handleTextInput",s=>s(n,r.$from.pos,r.$to.pos,o))&&n.dispatch(n.state.tr.insertText(o).scrollIntoView()),t.preventDefault()}};function Wr(n){return{left:n.clientX,top:n.clientY}}function _m(n,e){let t=e.x-n.clientX,r=e.y-n.clientY;return t*t+r*r<100}function Ns(n,e,t,r,o){if(r==-1)return!1;let s=n.state.doc.resolve(r);for(let i=s.depth+1;i>0;i--)if(n.someProp(e,l=>i>s.depth?l(n,t,s.nodeAfter,s.before(i),o,!0):l(n,t,s.node(i),s.before(i),o,!1)))return!0;return!1}function hn(n,e,t){if(n.focused||n.focus(),n.state.selection.eq(e))return;let r=n.state.tr.setSelection(e);r.setMeta("pointer",!0),n.dispatch(r)}function qm(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),r=t.nodeAfter;return r&&r.isAtom&&v.isSelectable(r)?(hn(n,new v(t)),!0):!1}function Hm(n,e){if(e==-1)return!1;let t=n.state.selection,r,o;t instanceof v&&(r=t.node);let s=n.state.doc.resolve(e);for(let i=s.depth+1;i>0;i--){let l=i>s.depth?s.nodeAfter:s.node(i);if(v.isSelectable(l)){r&&t.$from.depth>0&&i>=t.$from.depth&&s.before(t.$from.depth+1)==t.$from.pos?o=s.before(t.$from.depth):o=s.before(i);break}}return o!=null?(hn(n,v.create(n.state.doc,o)),!0):!1}function Km(n,e,t,r,o){return Ns(n,"handleClickOn",e,t,r)||n.someProp("handleClick",s=>s(n,e,r))||(o?Hm(n,t):qm(n,t))}function Jm(n,e,t,r){return Ns(n,"handleDoubleClickOn",e,t,r)||n.someProp("handleDoubleClick",o=>o(n,e,r))}function Ym(n,e,t,r){return Ns(n,"handleTripleClickOn",e,t,r)||n.someProp("handleTripleClick",o=>o(n,e,r))||Gm(n,t,r)}function Gm(n,e,t){if(t.button!=0)return!1;let r=n.state.doc;if(e==-1)return r.inlineContent?(hn(n,V.create(r,0,r.content.size)),!0):!1;let o=r.resolve(e);for(let s=o.depth+1;s>0;s--){let i=s>o.depth?o.nodeAfter:o.node(s),l=o.before(s);if(i.inlineContent)hn(n,V.create(r,l+1,l+1+i.content.size));else if(v.isSelectable(i))hn(n,v.create(r,l));else continue;return!0}}function Es(n){return _r(n)}const Cc=De?"metaKey":"ctrlKey";Re.mousedown=(n,e)=>{let t=e;n.input.shiftKey=t.shiftKey;let r=Es(n),o=Date.now(),s="singleClick";o-n.input.lastClick.time<500&&_m(t,n.input.lastClick)&&!t[Cc]&&(n.input.lastClick.type=="singleClick"?s="doubleClick":n.input.lastClick.type=="doubleClick"&&(s="tripleClick")),n.input.lastClick={time:o,x:t.clientX,y:t.clientY,type:s};let i=n.posAtCoords(Wr(t));i&&(s=="singleClick"?(n.input.mouseDown&&n.input.mouseDown.done(),n.input.mouseDown=new Xm(n,i,t,!!r)):(s=="doubleClick"?Jm:Ym)(n,i.pos,i.inside,t)?t.preventDefault():kt(n,"pointer"))};class Xm{constructor(e,t,r,o){this.view=e,this.pos=t,this.event=r,this.flushed=o,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!r[Cc],this.allowDefault=r.shiftKey;let s,i;if(t.inside>-1)s=e.state.doc.nodeAt(t.inside),i=t.inside;else{let u=e.state.doc.resolve(t.pos);s=u.parent,i=u.depth?u.before():0}const l=o?null:r.target,a=l?e.docView.nearestDesc(l,!0):null;this.target=a&&a.dom.nodeType==1?a.dom:null;let{selection:c}=e.state;(r.button==0&&s.type.spec.draggable&&s.type.spec.selectable!==!1||c instanceof v&&c.from<=i&&c.to>i)&&(this.mightDrag={node:s,pos:i,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Fr&&!this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this)),kt(e,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>xs(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(Wr(e))),this.updateAllowDefault(e),this.allowDefault||!t?kt(this.view,"pointer"):Km(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||Lt&&this.mightDrag&&!this.mightDrag.node.isAtom||bt&&!this.view.state.selection.visible&&Math.min(Math.abs(t.pos-this.view.state.selection.from),Math.abs(t.pos-this.view.state.selection.to))<=2)?(hn(this.view,R.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):kt(this.view,"pointer")}move(e){this.updateAllowDefault(e),kt(this.view,"pointer"),e.buttons==0&&this.done()}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}}Re.touchstart=n=>{n.input.lastTouch=Date.now(),Es(n),kt(n,"pointer")},Re.touchmove=n=>{n.input.lastTouch=Date.now(),kt(n,"pointer")},Re.contextmenu=n=>Es(n);function wc(n,e){return n.composing?!0:Lt&&Math.abs(e.timeStamp-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}const Um=Hn?5e3:-1;Se.compositionstart=Se.compositionupdate=n=>{if(!n.composing){n.domObserver.flush();let{state:e}=n,t=e.selection.$to;if(e.selection instanceof V&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)))n.markCursor=n.state.storedMarks||t.marks(),_r(n,!0),n.markCursor=null;else if(_r(n,!e.selection.empty),Fr&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length){let r=n.domSelectionRange();for(let o=r.focusNode,s=r.focusOffset;o&&o.nodeType==1&&s!=0;){let i=s<0?o.lastChild:o.childNodes[s-1];if(!i)break;if(i.nodeType==3){let l=n.domSelection();l&&l.collapse(i,i.nodeValue.length);break}else o=i,s=-1}}n.input.composing=!0}Mc(n,Um)},Se.compositionend=(n,e)=>{n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=e.timeStamp,n.input.compositionPendingChanges=n.domObserver.pendingRecords().length?n.input.compositionID:0,n.input.compositionNode=null,n.input.compositionPendingChanges&&Promise.resolve().then(()=>n.domObserver.flush()),n.input.compositionID++,Mc(n,20))};function Mc(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>_r(n),e))}function Qm(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=Zm());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function Zm(){let n=document.createEvent("Event");return n.initEvent("event",!0,!0),n.timeStamp}function _r(n,e=!1){if(!(Hn&&n.domObserver.flushingSoon>=0)){if(n.domObserver.forceFlush(),Qm(n),e||n.docView&&n.docView.dirty){let t=Nm(n);return t&&!t.eq(n.state.selection)?n.dispatch(n.state.tr.setSelection(t)):(n.markCursor||e)&&!n.state.selection.empty?n.dispatch(n.state.tr.deleteSelection()):n.updateState(n.state),!0}return!1}}function eg(n,e){if(!n.dom.parentNode)return;let t=n.dom.parentNode.appendChild(document.createElement("div"));t.appendChild(e),t.style.cssText="position: fixed; left: -10000px; top: 10px";let r=getSelection(),o=document.createRange();o.selectNodeContents(e),n.dom.blur(),r.removeAllRanges(),r.addRange(o),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t),n.focus()},50)}const Jn=qn&&Za<15||ys&&Mm<604;Re.copy=Se.cut=(n,e)=>{let t=e,r=n.state.selection,o=t.type=="cut";if(r.empty)return;let s=Jn?null:t.clipboardData,i=r.content(),{dom:l,text:a}=hc(n,i);s?(t.preventDefault(),s.clearData(),s.setData("text/html",l.innerHTML),s.setData("text/plain",a)):eg(n,l),o&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function tg(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function ng(n,e){if(!n.dom.parentNode)return;let t=n.input.shiftKey||n.state.selection.$from.parent.type.spec.code,r=n.dom.parentNode.appendChild(document.createElement(t?"textarea":"div"));t||(r.contentEditable="true"),r.style.cssText="position: fixed; left: -10000px; top: 10px",r.focus();let o=n.input.shiftKey&&n.input.lastKeyCode!=45;setTimeout(()=>{n.focus(),r.parentNode&&r.parentNode.removeChild(r),t?Ds(n,r.value,null,o,e):Ds(n,r.textContent,r.innerHTML,o,e)},50)}function Ds(n,e,t,r,o){let s=pc(n,e,t,r,n.state.selection.$from);if(n.someProp("handlePaste",a=>a(n,o,s||E.empty)))return!0;if(!s)return!1;let i=tg(s),l=i?n.state.tr.replaceSelectionWith(i,r):n.state.tr.replaceSelection(s);return n.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Nc(n){let e=n.getData("text/plain")||n.getData("Text");if(e)return e;let t=n.getData("text/uri-list");return t?t.replace(/\r?\n/g," "):""}Se.paste=(n,e)=>{let t=e;if(n.composing&&!Hn)return;let r=Jn?null:t.clipboardData,o=n.input.shiftKey&&n.input.lastKeyCode!=45;r&&Ds(n,Nc(r),r.getData("text/html"),o,t)?t.preventDefault():ng(n,t)};class rg{constructor(e,t,r){this.slice=e,this.move=t,this.node=r}}const og=De?"altKey":"ctrlKey";function Ec(n,e){let t=n.someProp("dragCopies",r=>!r(e));return t??!e[og]}Re.dragstart=(n,e)=>{let t=e,r=n.input.mouseDown;if(r&&r.done(),!t.dataTransfer)return;let o=n.state.selection,s=o.empty?null:n.posAtCoords(Wr(t)),i;if(!(s&&s.pos>=o.from&&s.pos<=(o instanceof v?o.to-1:o.to))){if(r&&r.mightDrag)i=v.create(n.state.doc,r.mightDrag.pos);else if(t.target&&t.target.nodeType==1){let f=n.docView.nearestDesc(t.target,!0);f&&f.node.type.spec.draggable&&f!=n.docView&&(i=v.create(n.state.doc,f.posBefore))}}let l=(i||n.state.selection).content(),{dom:a,text:c,slice:u}=hc(n,l);(!t.dataTransfer.files.length||!bt||ec>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(Jn?"Text":"text/html",a.innerHTML),t.dataTransfer.effectAllowed="copyMove",Jn||t.dataTransfer.setData("text/plain",c),n.dragging=new rg(u,Ec(n,t),i)},Re.dragend=n=>{let e=n.dragging;window.setTimeout(()=>{n.dragging==e&&(n.dragging=null)},50)},Se.dragover=Se.dragenter=(n,e)=>e.preventDefault(),Se.drop=(n,e)=>{let t=e,r=n.dragging;if(n.dragging=null,!t.dataTransfer)return;let o=n.posAtCoords(Wr(t));if(!o)return;let s=n.state.doc.resolve(o.pos),i=r&&r.slice;i?n.someProp("transformPasted",h=>{i=h(i,n)}):i=pc(n,Nc(t.dataTransfer),Jn?null:t.dataTransfer.getData("text/html"),!1,s);let l=!!(r&&Ec(n,t));if(n.someProp("handleDrop",h=>h(n,t,i||E.empty,l))){t.preventDefault();return}if(!i)return;t.preventDefault();let a=i?Co(n.state.doc,s.pos,i):s.pos;a==null&&(a=s.pos);let c=n.state.tr;if(l){let{node:h}=r;h?h.replace(c):c.deleteSelection()}let u=c.mapping.map(a),f=i.openStart==0&&i.openEnd==0&&i.content.childCount==1,d=c.doc;if(f?c.replaceRangeWith(u,u,i.content.firstChild):c.replaceRange(u,u,i),c.doc.eq(d))return;let p=c.doc.resolve(u);if(f&&v.isSelectable(i.content.firstChild)&&p.nodeAfter&&p.nodeAfter.sameMarkup(i.content.firstChild))c.setSelection(new v(p));else{let h=c.mapping.map(a);c.mapping.maps[c.mapping.maps.length-1].forEach((b,g,x,S)=>h=S),c.setSelection(ic(n,p,c.doc.resolve(h)))}n.focus(),n.dispatch(c.setMeta("uiEvent","drop"))},Re.focus=n=>{n.input.lastFocus=Date.now(),n.focused||(n.domObserver.stop(),n.dom.classList.add("ProseMirror-focused"),n.domObserver.start(),n.focused=!0,setTimeout(()=>{n.docView&&n.hasFocus()&&!n.domObserver.currentSelection.eq(n.domSelectionRange())&&xs(n)},20))},Re.blur=(n,e)=>{let t=e;n.focused&&(n.domObserver.stop(),n.dom.classList.remove("ProseMirror-focused"),n.domObserver.start(),t.relatedTarget&&n.dom.contains(t.relatedTarget)&&n.domObserver.currentSelection.clear(),n.focused=!1)},Re.beforeinput=(n,e)=>{if(bt&&Hn&&e.inputType=="deleteContentBackward"){n.domObserver.flushSoon();let{domChangeCount:r}=n.input;setTimeout(()=>{if(n.input.domChangeCount!=r||(n.dom.blur(),n.focus(),n.someProp("handleKeyDown",s=>s(n,Xa(8,"Backspace")))))return;let{$cursor:o}=n.state.selection;o&&o.pos>0&&n.dispatch(n.state.tr.delete(o.pos-1,o.pos).scrollIntoView())},50)}};for(let n in Se)Re[n]=Se[n];function Yn(n,e){if(n==e)return!0;for(let t in n)if(n[t]!==e[t])return!1;for(let t in e)if(!(t in n))return!1;return!0}class qr{constructor(e,t){this.toDOM=e,this.spec=t||Wt,this.side=this.spec.side||0}map(e,t,r,o){let{pos:s,deleted:i}=e.mapResult(t.from+o,this.side<0?-1:1);return i?null:new qe(s-r,s-r,this)}valid(){return!0}eq(e){return this==e||e instanceof qr&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Yn(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class St{constructor(e,t){this.attrs=e,this.spec=t||Wt}map(e,t,r,o){let s=e.map(t.from+o,this.spec.inclusiveStart?-1:1)-r,i=e.map(t.to+o,this.spec.inclusiveEnd?1:-1)-r;return s>=i?null:new qe(s,i,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof St&&Yn(this.attrs,e.attrs)&&Yn(this.spec,e.spec)}static is(e){return e.type instanceof St}destroy(){}}class vs{constructor(e,t){this.attrs=e,this.spec=t||Wt}map(e,t,r,o){let s=e.mapResult(t.from+o,1);if(s.deleted)return null;let i=e.mapResult(t.to+o,-1);return i.deleted||i.pos<=s.pos?null:new qe(s.pos-r,i.pos-r,this)}valid(e,t){let{index:r,offset:o}=e.content.findIndex(t.from),s;return o==t.from&&!(s=e.child(r)).isText&&o+s.nodeSize==t.to}eq(e){return this==e||e instanceof vs&&Yn(this.attrs,e.attrs)&&Yn(this.spec,e.spec)}destroy(){}}class qe{constructor(e,t,r){this.from=e,this.to=t,this.type=r}copy(e,t){return new qe(e,t,this.type)}eq(e,t=0){return this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to}map(e,t,r){return this.type.map(e,this,t,r)}static widget(e,t,r){return new qe(e,e,new qr(t,r))}static inline(e,t,r,o){return new qe(e,t,new St(r,o))}static node(e,t,r,o){return new qe(e,t,new vs(r,o))}get spec(){return this.type.spec}get inline(){return this.type instanceof St}get widget(){return this.type instanceof qr}}const pn=[],Wt={};class U{constructor(e,t){this.local=e.length?e:pn,this.children=t.length?t:pn}static create(e,t){return t.length?Hr(t,e,0,Wt):he}find(e,t,r){let o=[];return this.findInner(e??0,t??1e9,o,0,r),o}findInner(e,t,r,o,s){for(let i=0;i<this.local.length;i++){let l=this.local[i];l.from<=t&&l.to>=e&&(!s||s(l.spec))&&r.push(l.copy(l.from+o,l.to+o))}for(let i=0;i<this.children.length;i+=3)if(this.children[i]<t&&this.children[i+1]>e){let l=this.children[i]+1;this.children[i+2].findInner(e-l,t-l,r,o+l,s)}}map(e,t,r){return this==he||e.maps.length==0?this:this.mapInner(e,t,0,0,r||Wt)}mapInner(e,t,r,o,s){let i;for(let l=0;l<this.local.length;l++){let a=this.local[l].map(e,r,o);a&&a.type.valid(t,a)?(i||(i=[])).push(a):s.onRemove&&s.onRemove(this.local[l].spec)}return this.children.length?ig(this.children,i||[],e,t,r,o,s):i?new U(i.sort(_t),pn):he}add(e,t){return t.length?this==he?U.create(e,t):this.addInner(e,t,0):this}addInner(e,t,r){let o,s=0;e.forEach((l,a)=>{let c=a+r,u;if(u=vc(t,l,c)){for(o||(o=this.children.slice());s<o.length&&o[s]<a;)s+=3;o[s]==a?o[s+2]=o[s+2].addInner(l,u,c+1):o.splice(s,0,a,a+l.nodeSize,Hr(u,l,c+1,Wt)),s+=3}});let i=Dc(s?Oc(t):t,-r);for(let l=0;l<i.length;l++)i[l].type.valid(e,i[l])||i.splice(l--,1);return new U(i.length?this.local.concat(i).sort(_t):this.local,o||this.children)}remove(e){return e.length==0||this==he?this:this.removeInner(e,0)}removeInner(e,t){let r=this.children,o=this.local;for(let s=0;s<r.length;s+=3){let i,l=r[s]+t,a=r[s+1]+t;for(let u=0,f;u<e.length;u++)(f=e[u])&&f.from>l&&f.to<a&&(e[u]=null,(i||(i=[])).push(f));if(!i)continue;r==this.children&&(r=this.children.slice());let c=r[s+2].removeInner(i,l+1);c!=he?r[s+2]=c:(r.splice(s,3),s-=3)}if(o.length){for(let s=0,i;s<e.length;s++)if(i=e[s])for(let l=0;l<o.length;l++)o[l].eq(i,t)&&(o==this.local&&(o=this.local.slice()),o.splice(l--,1))}return r==this.children&&o==this.local?this:o.length||r.length?new U(o,r):he}forChild(e,t){if(this==he)return this;if(t.isLeaf)return U.empty;let r,o;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=e){this.children[l]==e&&(r=this.children[l+2]);break}let s=e+1,i=s+t.content.size;for(let l=0;l<this.local.length;l++){let a=this.local[l];if(a.from<i&&a.to>s&&a.type instanceof St){let c=Math.max(s,a.from)-s,u=Math.min(i,a.to)-s;c<u&&(o||(o=[])).push(a.copy(c,u))}}if(o){let l=new U(o.sort(_t),pn);return r?new sg([l,r]):l}return r||he}eq(e){if(this==e)return!0;if(!(e instanceof U)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let t=0;t<this.local.length;t++)if(!this.local[t].eq(e.local[t]))return!1;for(let t=0;t<this.children.length;t+=3)if(this.children[t]!=e.children[t]||this.children[t+1]!=e.children[t+1]||!this.children[t+2].eq(e.children[t+2]))return!1;return!0}locals(e){return Os(this.localsInner(e))}localsInner(e){if(this==he)return pn;if(e.inlineContent||!this.local.some(St.is))return this.local;let t=[];for(let r=0;r<this.local.length;r++)this.local[r].type instanceof St||t.push(this.local[r]);return t}forEachSet(e){e(this)}}U.empty=new U([],[]),U.removeOverlap=Os;const he=U.empty;let sg=class kn{constructor(e){this.members=e}map(e,t){const r=this.members.map(o=>o.map(e,t,Wt));return kn.from(r)}forChild(e,t){if(t.isLeaf)return U.empty;let r=[];for(let o=0;o<this.members.length;o++){let s=this.members[o].forChild(e,t);s!=he&&(s instanceof kn?r=r.concat(s.members):r.push(s))}return kn.from(r)}eq(e){if(!(e instanceof kn)||e.members.length!=this.members.length)return!1;for(let t=0;t<this.members.length;t++)if(!this.members[t].eq(e.members[t]))return!1;return!0}locals(e){let t,r=!0;for(let o=0;o<this.members.length;o++){let s=this.members[o].localsInner(e);if(s.length)if(!t)t=s;else{r&&(t=t.slice(),r=!1);for(let i=0;i<s.length;i++)t.push(s[i])}}return t?Os(r?t:t.sort(_t)):pn}static from(e){switch(e.length){case 0:return he;case 1:return e[0];default:return new kn(e.every(t=>t instanceof U)?e:e.reduce((t,r)=>t.concat(r instanceof U?r:r.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}};function ig(n,e,t,r,o,s,i){let l=n.slice();for(let c=0,u=s;c<t.maps.length;c++){let f=0;t.maps[c].forEach((d,p,h,b)=>{let g=b-h-(p-d);for(let x=0;x<l.length;x+=3){let S=l[x+1];if(S<0||d>S+u-f)continue;let w=l[x]+u-f;p>=w?l[x+1]=d<=w?-2:-1:d>=u&&g&&(l[x]+=g,l[x+1]+=g)}f+=g}),u=t.maps[c].map(u,-1)}let a=!1;for(let c=0;c<l.length;c+=3)if(l[c+1]<0){if(l[c+1]==-2){a=!0,l[c+1]=-1;continue}let u=t.map(n[c]+s),f=u-o;if(f<0||f>=r.content.size){a=!0;continue}let d=t.map(n[c+1]+s,-1),p=d-o,{index:h,offset:b}=r.content.findIndex(f),g=r.maybeChild(h);if(g&&b==f&&b+g.nodeSize==p){let x=l[c+2].mapInner(t,g,u+1,n[c]+s+1,i);x!=he?(l[c]=f,l[c+1]=p,l[c+2]=x):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=lg(l,n,e,t,o,s,i),u=Hr(c,r,0,i);e=u.local;for(let f=0;f<l.length;f+=3)l[f+1]<0&&(l.splice(f,3),f-=3);for(let f=0,d=0;f<u.children.length;f+=3){let p=u.children[f];for(;d<l.length&&l[d]<p;)d+=3;l.splice(d,0,u.children[f],u.children[f+1],u.children[f+2])}}return new U(e.sort(_t),l)}function Dc(n,e){if(!e||!n.length)return n;let t=[];for(let r=0;r<n.length;r++){let o=n[r];t.push(new qe(o.from+e,o.to+e,o.type))}return t}function lg(n,e,t,r,o,s,i){function l(a,c){for(let u=0;u<a.local.length;u++){let f=a.local[u].map(r,o,c);f?t.push(f):i.onRemove&&i.onRemove(a.local[u].spec)}for(let u=0;u<a.children.length;u+=3)l(a.children[u+2],a.children[u]+c+1)}for(let a=0;a<n.length;a+=3)n[a+1]==-1&&l(n[a+2],e[a]+s+1);return t}function vc(n,e,t){if(e.isLeaf)return null;let r=t+e.nodeSize,o=null;for(let s=0,i;s<n.length;s++)(i=n[s])&&i.from>t&&i.to<r&&((o||(o=[])).push(i),n[s]=null);return o}function Oc(n){let e=[];for(let t=0;t<n.length;t++)n[t]!=null&&e.push(n[t]);return e}function Hr(n,e,t,r){let o=[],s=!1;e.forEach((l,a)=>{let c=vc(n,l,a+t);if(c){s=!0;let u=Hr(c,l,t+a+1,r);u!=he&&o.push(a,a+l.nodeSize,u)}});let i=Dc(s?Oc(n):n,-t).sort(_t);for(let l=0;l<i.length;l++)i[l].type.valid(e,i[l])||(r.onRemove&&r.onRemove(i[l].spec),i.splice(l--,1));return i.length||o.length?new U(i,o):he}function _t(n,e){return n.from-e.from||n.to-e.to}function Os(n){let e=n;for(let t=0;t<e.length-1;t++){let r=e[t];if(r.from!=r.to)for(let o=t+1;o<e.length;o++){let s=e[o];if(s.from==r.from){s.to!=r.to&&(e==n&&(e=n.slice()),e[o]=s.copy(s.from,r.to),Tc(e,o+1,s.copy(r.to,s.to)));continue}else{s.from<r.to&&(e==n&&(e=n.slice()),e[t]=r.copy(r.from,s.from),Tc(e,o,r.copy(s.from,r.to)));break}}}return e}function Tc(n,e,t){for(;e<n.length&&_t(t,n[e])>0;)e++;n.splice(e,0,t)}var Ts,As;if(typeof WeakMap<"u"){let n=new WeakMap;Ts=e=>n.get(e),As=(e,t)=>(n.set(e,t),t)}else{const n=[];let t=0;Ts=r=>{for(let o=0;o<n.length;o+=2)if(n[o]==r)return n[o+1]},As=(r,o)=>(t==10&&(t=0),n[t++]=r,n[t++]=o)}var Q=class{constructor(n,e,t,r){this.width=n,this.height=e,this.map=t,this.problems=r}findCell(n){for(let e=0;e<this.map.length;e++){const t=this.map[e];if(t!=n)continue;const r=e%this.width,o=e/this.width|0;let s=r+1,i=o+1;for(let l=1;s<this.width&&this.map[e+l]==t;l++)s++;for(let l=1;i<this.height&&this.map[e+this.width*l]==t;l++)i++;return{left:r,top:o,right:s,bottom:i}}throw new RangeError(`No cell with offset ${n} found`)}colCount(n){for(let e=0;e<this.map.length;e++)if(this.map[e]==n)return e%this.width;throw new RangeError(`No cell with offset ${n} found`)}nextCell(n,e,t){const{left:r,right:o,top:s,bottom:i}=this.findCell(n);return e=="horiz"?(t<0?r==0:o==this.width)?null:this.map[s*this.width+(t<0?r-1:o)]:(t<0?s==0:i==this.height)?null:this.map[r+this.width*(t<0?s-1:i)]}rectBetween(n,e){const{left:t,right:r,top:o,bottom:s}=this.findCell(n),{left:i,right:l,top:a,bottom:c}=this.findCell(e);return{left:Math.min(t,i),top:Math.min(o,a),right:Math.max(r,l),bottom:Math.max(s,c)}}cellsInRect(n){const e=[],t={};for(let r=n.top;r<n.bottom;r++)for(let o=n.left;o<n.right;o++){const s=r*this.width+o,i=this.map[s];t[i]||(t[i]=!0,!(o==n.left&&o&&this.map[s-1]==i||r==n.top&&r&&this.map[s-this.width]==i)&&e.push(i))}return e}positionAt(n,e,t){for(let r=0,o=0;;r++){const s=o+t.child(r).nodeSize;if(r==n){let i=e+n*this.width;const l=(n+1)*this.width;for(;i<l&&this.map[i]<o;)i++;return i==l?s-1:this.map[i]}o=s}}static get(n){return Ts(n)||As(n,ag(n))}};function ag(n){if(n.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+n.type.name);const e=cg(n),t=n.childCount,r=[];let o=0,s=null;const i=[];for(let c=0,u=e*t;c<u;c++)r[c]=0;for(let c=0,u=0;c<t;c++){const f=n.child(c);u++;for(let h=0;;h++){for(;o<r.length&&r[o]!=0;)o++;if(h==f.childCount)break;const b=f.child(h),{colspan:g,rowspan:x,colwidth:S}=b.attrs;for(let w=0;w<x;w++){if(w+c>=t){(s||(s=[])).push({type:"overlong_rowspan",pos:u,n:x-w});break}const D=o+w*e;for(let T=0;T<g;T++){r[D+T]==0?r[D+T]=u:(s||(s=[])).push({type:"collision",row:c,pos:u,n:g-T});const M=S&&S[T];if(M){const I=(D+T)%e*2,z=i[I];z==null||z!=M&&i[I+1]==1?(i[I]=M,i[I+1]=1):z==M&&i[I+1]++}}}o+=g,u+=b.nodeSize}const d=(c+1)*e;let p=0;for(;o<d;)r[o++]==0&&p++;p&&(s||(s=[])).push({type:"missing",row:c,n:p}),u++}(e===0||t===0)&&(s||(s=[])).push({type:"zero_sized"});const l=new Q(e,t,r,s);let a=!1;for(let c=0;!a&&c<i.length;c+=2)i[c]!=null&&i[c+1]<t&&(a=!0);return a&&ug(l,i,n),l}function cg(n){let e=-1,t=!1;for(let r=0;r<n.childCount;r++){const o=n.child(r);let s=0;if(t)for(let i=0;i<r;i++){const l=n.child(i);for(let a=0;a<l.childCount;a++){const c=l.child(a);i+c.attrs.rowspan>r&&(s+=c.attrs.colspan)}}for(let i=0;i<o.childCount;i++){const l=o.child(i);s+=l.attrs.colspan,l.attrs.rowspan>1&&(t=!0)}e==-1?e=s:e!=s&&(e=Math.max(e,s))}return e}function ug(n,e,t){n.problems||(n.problems=[]);const r={};for(let o=0;o<n.map.length;o++){const s=n.map[o];if(r[s])continue;r[s]=!0;const i=t.nodeAt(s);if(!i)throw new RangeError(`No cell with offset ${s} found`);let l=null;const a=i.attrs;for(let c=0;c<a.colspan;c++){const u=(o+c)%n.width,f=e[u*2];f!=null&&(!a.colwidth||a.colwidth[c]!=f)&&((l||(l=fg(a)))[c]=f)}l&&n.problems.unshift({type:"colwidth mismatch",pos:s,colwidth:l})}}function fg(n){if(n.colwidth)return n.colwidth.slice();const e=[];for(let t=0;t<n.colspan;t++)e.push(0);return e}function Ac(n,e){if(typeof n=="string")return{};const t=n.getAttribute("data-colwidth"),r=t&&/^\d+(,\d+)*$/.test(t)?t.split(",").map(i=>Number(i)):null,o=Number(n.getAttribute("colspan")||1),s={colspan:o,rowspan:Number(n.getAttribute("rowspan")||1),colwidth:r&&r.length==o?r:null};for(const i in e){const l=e[i].getFromDOM,a=l&&l(n);a!=null&&(s[i]=a)}return s}function Pc(n,e){const t={};n.attrs.colspan!=1&&(t.colspan=n.attrs.colspan),n.attrs.rowspan!=1&&(t.rowspan=n.attrs.rowspan),n.attrs.colwidth&&(t["data-colwidth"]=n.attrs.colwidth.join(","));for(const r in e){const o=e[r].setDOMAttr;o&&o(n.attrs[r],t)}return t}function dg(n){if(n!==null){if(!Array.isArray(n))throw new TypeError("colwidth must be null or an array");for(const e of n)if(typeof e!="number")throw new TypeError("colwidth must be null or an array of numbers")}}function hg(n){const e=n.cellAttributes||{},t={colspan:{default:1,validate:"number"},rowspan:{default:1,validate:"number"},colwidth:{default:null,validate:dg}};for(const r in e)t[r]={default:e[r].default,validate:e[r].validate};return{table:{content:"table_row+",tableRole:"table",isolating:!0,group:n.tableGroup,parseDOM:[{tag:"table"}],toDOM(){return["table",["tbody",0]]}},table_row:{content:"(table_cell | table_header)*",tableRole:"row",parseDOM:[{tag:"tr"}],toDOM(){return["tr",0]}},table_cell:{content:n.cellContent,attrs:t,tableRole:"cell",isolating:!0,parseDOM:[{tag:"td",getAttrs:r=>Ac(r,e)}],toDOM(r){return["td",Pc(r,e),0]}},table_header:{content:n.cellContent,attrs:t,tableRole:"header_cell",isolating:!0,parseDOM:[{tag:"th",getAttrs:r=>Ac(r,e)}],toDOM(r){return["th",Pc(r,e),0]}}}}function pe(n){let e=n.cached.tableNodeTypes;if(!e){e=n.cached.tableNodeTypes={};for(const t in n.nodes){const r=n.nodes[t],o=r.spec.tableRole;o&&(e[o]=r)}}return e}var Ct=new lt("selectingCells");function Gn(n){for(let e=n.depth-1;e>0;e--)if(n.node(e).type.spec.tableRole=="row")return n.node(0).resolve(n.before(e+1));return null}function pg(n){for(let e=n.depth;e>0;e--){const t=n.node(e).type.spec.tableRole;if(t==="cell"||t==="header_cell")return n.node(e)}return null}function ve(n){const e=n.selection.$head;for(let t=e.depth;t>0;t--)if(e.node(t).type.spec.tableRole=="row")return!0;return!1}function Kr(n){const e=n.selection;if("$anchorCell"in e&&e.$anchorCell)return e.$anchorCell.pos>e.$headCell.pos?e.$anchorCell:e.$headCell;if("node"in e&&e.node&&e.node.type.spec.tableRole=="cell")return e.$anchor;const t=Gn(e.$head)||mg(e.$head);if(t)return t;throw new RangeError(`No cell found around position ${e.head}`)}function mg(n){for(let e=n.nodeAfter,t=n.pos;e;e=e.firstChild,t++){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return n.doc.resolve(t)}for(let e=n.nodeBefore,t=n.pos;e;e=e.lastChild,t--){const r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return n.doc.resolve(t-e.nodeSize)}}function Ic(n){return n.parent.type.spec.tableRole=="row"&&!!n.nodeAfter}function gg(n){return n.node(0).resolve(n.pos+n.nodeAfter.nodeSize)}function Ps(n,e){return n.depth==e.depth&&n.pos>=e.start(-1)&&n.pos<=e.end(-1)}function Vc(n,e,t){const r=n.node(-1),o=Q.get(r),s=n.start(-1),i=o.nextCell(n.pos-s,e,t);return i==null?null:n.node(0).resolve(s+i)}function qt(n,e,t=1){const r={...n,colspan:n.colspan-t};return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(e,t),r.colwidth.some(o=>o>0)||(r.colwidth=null)),r}function Rc(n,e,t=1){const r={...n,colspan:n.colspan+t};if(r.colwidth){r.colwidth=r.colwidth.slice();for(let o=0;o<t;o++)r.colwidth.splice(e,0,0)}return r}function yg(n,e,t){const r=pe(e.type.schema).header_cell;for(let o=0;o<n.height;o++)if(e.nodeAt(n.map[t+o*n.width]).type!=r)return!1;return!0}var W=class ot extends R{constructor(e,t=e){const r=e.node(-1),o=Q.get(r),s=e.start(-1),i=o.rectBetween(e.pos-s,t.pos-s),l=e.node(0),a=o.cellsInRect(i).filter(u=>u!=t.pos-s);a.unshift(t.pos-s);const c=a.map(u=>{const f=r.nodeAt(u);if(!f)throw RangeError(`No cell with offset ${u} found`);const d=s+u+1;return new ol(l.resolve(d),l.resolve(d+f.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=e,this.$headCell=t}map(e,t){const r=e.resolve(t.map(this.$anchorCell.pos)),o=e.resolve(t.map(this.$headCell.pos));if(Ic(r)&&Ic(o)&&Ps(r,o)){const s=this.$anchorCell.node(-1)!=r.node(-1);return s&&this.isRowSelection()?ot.rowSelection(r,o):s&&this.isColSelection()?ot.colSelection(r,o):new ot(r,o)}return V.between(r,o)}content(){const e=this.$anchorCell.node(-1),t=Q.get(e),r=this.$anchorCell.start(-1),o=t.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),s={},i=[];for(let a=o.top;a<o.bottom;a++){const c=[];for(let u=a*t.width+o.left,f=o.left;f<o.right;f++,u++){const d=t.map[u];if(s[d])continue;s[d]=!0;const p=t.findCell(d);let h=e.nodeAt(d);if(!h)throw RangeError(`No cell with offset ${d} found`);const b=o.left-p.left,g=p.right-o.right;if(b>0||g>0){let x=h.attrs;if(b>0&&(x=qt(x,0,b)),g>0&&(x=qt(x,x.colspan-g,g)),p.left<o.left){if(h=h.type.createAndFill(x),!h)throw RangeError(`Could not create cell with attrs ${JSON.stringify(x)}`)}else h=h.type.create(x,h.content)}if(p.top<o.top||p.bottom>o.bottom){const x={...h.attrs,rowspan:Math.min(p.bottom,o.bottom)-Math.max(p.top,o.top)};p.top<o.top?h=h.type.createAndFill(x):h=h.type.create(x,h.content)}c.push(h)}i.push(e.child(a).copy(C.from(c)))}const l=this.isColSelection()&&this.isRowSelection()?e:i;return new E(C.from(l),1,1)}replace(e,t=E.empty){const r=e.steps.length,o=this.ranges;for(let i=0;i<o.length;i++){const{$from:l,$to:a}=o[i],c=e.mapping.slice(r);e.replace(c.map(l.pos),c.map(a.pos),i?E.empty:t)}const s=R.findFrom(e.doc.resolve(e.mapping.slice(r).map(this.to)),-1);s&&e.setSelection(s)}replaceWith(e,t){this.replace(e,new E(C.from(t),0,0))}forEachCell(e){const t=this.$anchorCell.node(-1),r=Q.get(t),o=this.$anchorCell.start(-1),s=r.cellsInRect(r.rectBetween(this.$anchorCell.pos-o,this.$headCell.pos-o));for(let i=0;i<s.length;i++)e(t.nodeAt(s[i]),o+s[i])}isColSelection(){const e=this.$anchorCell.index(-1),t=this.$headCell.index(-1);if(Math.min(e,t)>0)return!1;const r=e+this.$anchorCell.nodeAfter.attrs.rowspan,o=t+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(r,o)==this.$headCell.node(-1).childCount}static colSelection(e,t=e){const r=e.node(-1),o=Q.get(r),s=e.start(-1),i=o.findCell(e.pos-s),l=o.findCell(t.pos-s),a=e.node(0);return i.top<=l.top?(i.top>0&&(e=a.resolve(s+o.map[i.left])),l.bottom<o.height&&(t=a.resolve(s+o.map[o.width*(o.height-1)+l.right-1]))):(l.top>0&&(t=a.resolve(s+o.map[l.left])),i.bottom<o.height&&(e=a.resolve(s+o.map[o.width*(o.height-1)+i.right-1]))),new ot(e,t)}isRowSelection(){const e=this.$anchorCell.node(-1),t=Q.get(e),r=this.$anchorCell.start(-1),o=t.colCount(this.$anchorCell.pos-r),s=t.colCount(this.$headCell.pos-r);if(Math.min(o,s)>0)return!1;const i=o+this.$anchorCell.nodeAfter.attrs.colspan,l=s+this.$headCell.nodeAfter.attrs.colspan;return Math.max(i,l)==t.width}eq(e){return e instanceof ot&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,t=e){const r=e.node(-1),o=Q.get(r),s=e.start(-1),i=o.findCell(e.pos-s),l=o.findCell(t.pos-s),a=e.node(0);return i.left<=l.left?(i.left>0&&(e=a.resolve(s+o.map[i.top*o.width])),l.right<o.width&&(t=a.resolve(s+o.map[o.width*(l.top+1)-1]))):(l.left>0&&(t=a.resolve(s+o.map[l.top*o.width])),i.right<o.width&&(e=a.resolve(s+o.map[o.width*(i.top+1)-1]))),new ot(e,t)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,t){return new ot(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,r=t){return new ot(e.resolve(t),e.resolve(r))}getBookmark(){return new bg(this.$anchorCell.pos,this.$headCell.pos)}};W.prototype.visible=!1,R.jsonID("cell",W);var bg=class yf{constructor(e,t){this.anchor=e,this.head=t}map(e){return new yf(e.map(this.anchor),e.map(this.head))}resolve(e){const t=e.resolve(this.anchor),r=e.resolve(this.head);return t.parent.type.spec.tableRole=="row"&&r.parent.type.spec.tableRole=="row"&&t.index()<t.parent.childCount&&r.index()<r.parent.childCount&&Ps(t,r)?new W(t,r):R.near(r,1)}};function xg(n){if(!(n.selection instanceof W))return null;const e=[];return n.selection.forEachCell((t,r)=>{e.push(qe.node(r,r+t.nodeSize,{class:"selectedCell"}))}),U.create(n.doc,e)}function kg({$from:n,$to:e}){if(n.pos==e.pos||n.pos<e.pos-6)return!1;let t=n.pos,r=e.pos,o=n.depth;for(;o>=0&&!(n.after(o+1)<n.end(o));o--,t++);for(let s=e.depth;s>=0&&!(e.before(s+1)>e.start(s));s--,r--);return t==r&&/row|table/.test(n.node(o).type.spec.tableRole)}function Sg({$from:n,$to:e}){let t,r;for(let o=n.depth;o>0;o--){const s=n.node(o);if(s.type.spec.tableRole==="cell"||s.type.spec.tableRole==="header_cell"){t=s;break}}for(let o=e.depth;o>0;o--){const s=e.node(o);if(s.type.spec.tableRole==="cell"||s.type.spec.tableRole==="header_cell"){r=s;break}}return t!==r&&e.parentOffset===0}function Cg(n,e,t){const r=(e||n).selection,o=(e||n).doc;let s,i;if(r instanceof v&&(i=r.node.type.spec.tableRole)){if(i=="cell"||i=="header_cell")s=W.create(o,r.from);else if(i=="row"){const l=o.resolve(r.from+1);s=W.rowSelection(l,l)}else if(!t){const l=Q.get(r.node),a=r.from+1,c=a+l.map[l.width*l.height-1];s=W.create(o,a+1,c)}}else r instanceof V&&kg(r)?s=V.create(o,r.from):r instanceof V&&Sg(r)&&(s=V.create(o,r.$from.start(),r.$from.end()));return s&&(e||(e=n.tr)).setSelection(s),e}var wg=new lt("fix-tables");function zc(n,e,t,r){const o=n.childCount,s=e.childCount;e:for(let i=0,l=0;i<s;i++){const a=e.child(i);for(let c=l,u=Math.min(o,i+3);c<u;c++)if(n.child(c)==a){l=c+1,t+=a.nodeSize;continue e}r(a,t),l<o&&n.child(l).sameMarkup(a)?zc(n.child(l),a,t+1,r):a.nodesBetween(0,a.content.size,r,t+1),t+=a.nodeSize}}function Is(n,e){let t;const r=(o,s)=>{o.type.spec.tableRole=="table"&&(t=Mg(n,o,s,t))};return e?e.doc!=n.doc&&zc(e.doc,n.doc,0,r):n.doc.descendants(r),t}function Mg(n,e,t,r){const o=Q.get(e);if(!o.problems)return r;r||(r=n.tr);const s=[];for(let a=0;a<o.height;a++)s.push(0);for(let a=0;a<o.problems.length;a++){const c=o.problems[a];if(c.type=="collision"){const u=e.nodeAt(c.pos);if(!u)continue;const f=u.attrs;for(let d=0;d<f.rowspan;d++)s[c.row+d]+=c.n;r.setNodeMarkup(r.mapping.map(t+1+c.pos),null,qt(f,f.colspan-c.n,c.n))}else if(c.type=="missing")s[c.row]+=c.n;else if(c.type=="overlong_rowspan"){const u=e.nodeAt(c.pos);if(!u)continue;r.setNodeMarkup(r.mapping.map(t+1+c.pos),null,{...u.attrs,rowspan:u.attrs.rowspan-c.n})}else if(c.type=="colwidth mismatch"){const u=e.nodeAt(c.pos);if(!u)continue;r.setNodeMarkup(r.mapping.map(t+1+c.pos),null,{...u.attrs,colwidth:c.colwidth})}else if(c.type=="zero_sized"){const u=r.mapping.map(t);r.delete(u,u+e.nodeSize)}}let i,l;for(let a=0;a<s.length;a++)s[a]&&(i==null&&(i=a),l=a);for(let a=0,c=t+1;a<o.height;a++){const u=e.child(a),f=c+u.nodeSize,d=s[a];if(d>0){let p="cell";u.firstChild&&(p=u.firstChild.type.spec.tableRole);const h=[];for(let g=0;g<d;g++){const x=pe(n.schema)[p].createAndFill();x&&h.push(x)}const b=(a==0||i==a-1)&&l==a?c+1:f-1;r.insert(r.mapping.map(b),h)}c=f}return r.setMeta(wg,{fixTables:!0})}function He(n){const e=n.selection,t=Kr(n),r=t.node(-1),o=t.start(-1),s=Q.get(r);return{...e instanceof W?s.rectBetween(e.$anchorCell.pos-o,e.$headCell.pos-o):s.findCell(t.pos-o),tableStart:o,map:s,table:r}}function $c(n,{map:e,tableStart:t,table:r},o){let s=o>0?-1:0;yg(e,r,o+s)&&(s=o==0||o==e.width?null:0);for(let i=0;i<e.height;i++){const l=i*e.width+o;if(o>0&&o<e.width&&e.map[l-1]==e.map[l]){const a=e.map[l],c=r.nodeAt(a);n.setNodeMarkup(n.mapping.map(t+a),null,Rc(c.attrs,o-e.colCount(a))),i+=c.attrs.rowspan-1}else{const a=s==null?pe(r.type.schema).cell:r.nodeAt(e.map[l+s]).type,c=e.positionAt(i,o,r);n.insert(n.mapping.map(t+c),a.createAndFill())}}return n}function Ng(n,e){if(!ve(n))return!1;if(e){const t=He(n);e($c(n.tr,t,t.left))}return!0}function Eg(n,e){if(!ve(n))return!1;if(e){const t=He(n);e($c(n.tr,t,t.right))}return!0}function Dg(n,{map:e,table:t,tableStart:r},o){const s=n.mapping.maps.length;for(let i=0;i<e.height;){const l=i*e.width+o,a=e.map[l],c=t.nodeAt(a),u=c.attrs;if(o>0&&e.map[l-1]==a||o<e.width-1&&e.map[l+1]==a)n.setNodeMarkup(n.mapping.slice(s).map(r+a),null,qt(u,o-e.colCount(a)));else{const f=n.mapping.slice(s).map(r+a);n.delete(f,f+c.nodeSize)}i+=u.rowspan}}function vg(n,e){if(!ve(n))return!1;if(e){const t=He(n),r=n.tr;if(t.left==0&&t.right==t.map.width)return!1;for(let o=t.right-1;Dg(r,t,o),o!=t.left;o--){const s=t.tableStart?r.doc.nodeAt(t.tableStart-1):r.doc;if(!s)throw RangeError("No table found");t.table=s,t.map=Q.get(s)}e(r)}return!0}function Og(n,e,t){var r;const o=pe(e.type.schema).header_cell;for(let s=0;s<n.width;s++)if(((r=e.nodeAt(n.map[s+t*n.width]))==null?void 0:r.type)!=o)return!1;return!0}function jc(n,{map:e,tableStart:t,table:r},o){var s;let i=t;for(let c=0;c<o;c++)i+=r.child(c).nodeSize;const l=[];let a=o>0?-1:0;Og(e,r,o+a)&&(a=o==0||o==e.height?null:0);for(let c=0,u=e.width*o;c<e.width;c++,u++)if(o>0&&o<e.height&&e.map[u]==e.map[u-e.width]){const f=e.map[u],d=r.nodeAt(f).attrs;n.setNodeMarkup(t+f,null,{...d,rowspan:d.rowspan+1}),c+=d.colspan-1}else{const f=a==null?pe(r.type.schema).cell:(s=r.nodeAt(e.map[u+a*e.width]))==null?void 0:s.type,d=f==null?void 0:f.createAndFill();d&&l.push(d)}return n.insert(i,pe(r.type.schema).row.create(null,l)),n}function Tg(n,e){if(!ve(n))return!1;if(e){const t=He(n);e(jc(n.tr,t,t.top))}return!0}function Ag(n,e){if(!ve(n))return!1;if(e){const t=He(n);e(jc(n.tr,t,t.bottom))}return!0}function Pg(n,{map:e,table:t,tableStart:r},o){let s=0;for(let c=0;c<o;c++)s+=t.child(c).nodeSize;const i=s+t.child(o).nodeSize,l=n.mapping.maps.length;n.delete(s+r,i+r);const a=new Set;for(let c=0,u=o*e.width;c<e.width;c++,u++){const f=e.map[u];if(!a.has(f)){if(a.add(f),o>0&&f==e.map[u-e.width]){const d=t.nodeAt(f).attrs;n.setNodeMarkup(n.mapping.slice(l).map(f+r),null,{...d,rowspan:d.rowspan-1}),c+=d.colspan-1}else if(o<e.height&&f==e.map[u+e.width]){const d=t.nodeAt(f),p=d.attrs,h=d.type.create({...p,rowspan:d.attrs.rowspan-1},d.content),b=e.positionAt(o+1,c,t);n.insert(n.mapping.slice(l).map(r+b),h),c+=p.colspan-1}}}}function Ig(n,e){if(!ve(n))return!1;if(e){const t=He(n),r=n.tr;if(t.top==0&&t.bottom==t.map.height)return!1;for(let o=t.bottom-1;Pg(r,t,o),o!=t.top;o--){const s=t.tableStart?r.doc.nodeAt(t.tableStart-1):r.doc;if(!s)throw RangeError("No table found");t.table=s,t.map=Q.get(t.table)}e(r)}return!0}function Bc(n){const e=n.content;return e.childCount==1&&e.child(0).isTextblock&&e.child(0).childCount==0}function Vg({width:n,height:e,map:t},r){let o=r.top*n+r.left,s=o,i=(r.bottom-1)*n+r.left,l=o+(r.right-r.left-1);for(let a=r.top;a<r.bottom;a++){if(r.left>0&&t[s]==t[s-1]||r.right<n&&t[l]==t[l+1])return!0;s+=n,l+=n}for(let a=r.left;a<r.right;a++){if(r.top>0&&t[o]==t[o-n]||r.bottom<e&&t[i]==t[i+n])return!0;o++,i++}return!1}function Rg(n,e){const t=n.selection;if(!(t instanceof W)||t.$anchorCell.pos==t.$headCell.pos)return!1;const r=He(n),{map:o}=r;if(Vg(o,r))return!1;if(e){const s=n.tr,i={};let l=C.empty,a,c;for(let u=r.top;u<r.bottom;u++)for(let f=r.left;f<r.right;f++){const d=o.map[u*o.width+f],p=r.table.nodeAt(d);if(!(i[d]||!p))if(i[d]=!0,a==null)a=d,c=p;else{Bc(p)||(l=l.append(p.content));const h=s.mapping.map(d+r.tableStart);s.delete(h,h+p.nodeSize)}}if(a==null||c==null)return!0;if(s.setNodeMarkup(a+r.tableStart,null,{...Rc(c.attrs,c.attrs.colspan,r.right-r.left-c.attrs.colspan),rowspan:r.bottom-r.top}),l.size){const u=a+1+c.content.size,f=Bc(c)?a+1:u;s.replaceWith(f+r.tableStart,u+r.tableStart,l)}s.setSelection(new W(s.doc.resolve(a+r.tableStart))),e(s)}return!0}function zg(n,e){const t=pe(n.schema);return $g(({node:r})=>t[r.type.spec.tableRole])(n,e)}function $g(n){return(e,t)=>{var r;const o=e.selection;let s,i;if(o instanceof W){if(o.$anchorCell.pos!=o.$headCell.pos)return!1;s=o.$anchorCell.nodeAfter,i=o.$anchorCell.pos}else{if(s=pg(o.$from),!s)return!1;i=(r=Gn(o.$from))==null?void 0:r.pos}if(s==null||i==null||s.attrs.colspan==1&&s.attrs.rowspan==1)return!1;if(t){let l=s.attrs;const a=[],c=l.colwidth;l.rowspan>1&&(l={...l,rowspan:1}),l.colspan>1&&(l={...l,colspan:1});const u=He(e),f=e.tr;for(let p=0;p<u.right-u.left;p++)a.push(c?{...l,colwidth:c&&c[p]?[c[p]]:null}:l);let d;for(let p=u.top;p<u.bottom;p++){let h=u.map.positionAt(p,u.left,u.table);p==u.top&&(h+=s.nodeSize);for(let b=u.left,g=0;b<u.right;b++,g++)b==u.left&&p==u.top||f.insert(d=f.mapping.map(h+u.tableStart,1),n({node:s,row:p,col:b}).createAndFill(a[g]))}f.setNodeMarkup(i,n({node:s,row:u.top,col:u.left}),a[0]),o instanceof W&&f.setSelection(new W(f.doc.resolve(o.$anchorCell.pos),d?f.doc.resolve(d):void 0)),t(f)}return!0}}function mn(n,e){return function(t,r){if(!ve(t))return!1;const o=Kr(t);if(o.nodeAfter.attrs[n]===e)return!1;if(r){const s=t.tr;t.selection instanceof W?t.selection.forEachCell((i,l)=>{i.attrs[n]!==e&&s.setNodeMarkup(l,null,{...i.attrs,[n]:e})}):s.setNodeMarkup(o.pos,null,{...o.nodeAfter.attrs,[n]:e}),r(s)}return!0}}function jg(n){return function(e,t){if(!ve(e))return!1;if(t){const r=pe(e.schema),o=He(e),s=e.tr,i=o.map.cellsInRect(n=="column"?{left:o.left,top:0,right:o.right,bottom:o.map.height}:n=="row"?{left:0,top:o.top,right:o.map.width,bottom:o.bottom}:o),l=i.map(a=>o.table.nodeAt(a));for(let a=0;a<i.length;a++)l[a].type==r.header_cell&&s.setNodeMarkup(o.tableStart+i[a],r.cell,l[a].attrs);if(s.steps.length==0)for(let a=0;a<i.length;a++)s.setNodeMarkup(o.tableStart+i[a],r.header_cell,l[a].attrs);t(s)}return!0}}function Fc(n,e,t){const r=e.map.cellsInRect({left:0,top:0,right:n=="row"?e.map.width:1,bottom:n=="column"?e.map.height:1});for(let o=0;o<r.length;o++){const s=e.table.nodeAt(r[o]);if(s&&s.type!==t.header_cell)return!1}return!0}function Vs(n,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?jg(n):function(t,r){if(!ve(t))return!1;if(r){const o=pe(t.schema),s=He(t),i=t.tr,l=Fc("row",s,o),a=Fc("column",s,o),u=(n==="column"?l:n==="row"?a:!1)?1:0,f=n=="column"?{left:0,top:u,right:1,bottom:s.map.height}:n=="row"?{left:u,top:0,right:s.map.width,bottom:1}:s,d=n=="column"?a?o.cell:o.header_cell:n=="row"?l?o.cell:o.header_cell:o.cell;s.map.cellsInRect(f).forEach(p=>{const h=p+s.tableStart,b=i.doc.nodeAt(h);b&&i.setNodeMarkup(h,d,b.attrs)}),r(i)}return!0}}var Bg=Vs("row",{useDeprecatedLogic:!0}),Fg=Vs("column",{useDeprecatedLogic:!0}),Lg=Vs("cell",{useDeprecatedLogic:!0});function Wg(n,e){if(e<0){const t=n.nodeBefore;if(t)return n.pos-t.nodeSize;for(let r=n.index(-1)-1,o=n.before();r>=0;r--){const s=n.node(-1).child(r),i=s.lastChild;if(i)return o-1-i.nodeSize;o-=s.nodeSize}}else{if(n.index()<n.parent.childCount-1)return n.pos+n.nodeAfter.nodeSize;const t=n.node(-1);for(let r=n.indexAfter(-1),o=n.after();r<t.childCount;r++){const s=t.child(r);if(s.childCount)return o+1;o+=s.nodeSize}}return null}function Lc(n){return function(e,t){if(!ve(e))return!1;const r=Wg(Kr(e),n);if(r==null)return!1;if(t){const o=e.doc.resolve(r);t(e.tr.setSelection(V.between(o,gg(o))).scrollIntoView())}return!0}}function _g(n,e){const t=n.selection.$anchor;for(let r=t.depth;r>0;r--)if(t.node(r).type.spec.tableRole=="table")return e&&e(n.tr.delete(t.before(r),t.after(r)).scrollIntoView()),!0;return!1}function Jr(n,e){const t=n.selection;if(!(t instanceof W))return!1;if(e){const r=n.tr,o=pe(n.schema).cell.createAndFill().content;t.forEachCell((s,i)=>{s.content.eq(o)||r.replace(r.mapping.map(i+1),r.mapping.map(i+s.nodeSize-1),new E(o,0,0))}),r.docChanged&&e(r)}return!0}function qg(n){if(!n.size)return null;let{content:e,openStart:t,openEnd:r}=n;for(;e.childCount==1&&(t>0&&r>0||e.child(0).type.spec.tableRole=="table");)t--,r--,e=e.child(0).content;const o=e.child(0),s=o.type.spec.tableRole,i=o.type.schema,l=[];if(s=="row")for(let a=0;a<e.childCount;a++){let c=e.child(a).content;const u=a?0:Math.max(0,t-1),f=a<e.childCount-1?0:Math.max(0,r-1);(u||f)&&(c=Rs(pe(i).row,new E(c,u,f)).content),l.push(c)}else if(s=="cell"||s=="header_cell")l.push(t||r?Rs(pe(i).row,new E(e,t,r)).content:e);else return null;return Hg(i,l)}function Hg(n,e){const t=[];for(let o=0;o<e.length;o++){const s=e[o];for(let i=s.childCount-1;i>=0;i--){const{rowspan:l,colspan:a}=s.child(i).attrs;for(let c=o;c<o+l;c++)t[c]=(t[c]||0)+a}}let r=0;for(let o=0;o<t.length;o++)r=Math.max(r,t[o]);for(let o=0;o<t.length;o++)if(o>=e.length&&e.push(C.empty),t[o]<r){const s=pe(n).cell.createAndFill(),i=[];for(let l=t[o];l<r;l++)i.push(s);e[o]=e[o].append(C.from(i))}return{height:e.length,width:r,rows:e}}function Rs(n,e){const t=n.createAndFill();return new rl(t).replace(0,t.content.size,e).doc}function Kg({width:n,height:e,rows:t},r,o){if(n!=r){const s=[],i=[];for(let l=0;l<t.length;l++){const a=t[l],c=[];for(let u=s[l]||0,f=0;u<r;f++){let d=a.child(f%a.childCount);u+d.attrs.colspan>r&&(d=d.type.createChecked(qt(d.attrs,d.attrs.colspan,u+d.attrs.colspan-r),d.content)),c.push(d),u+=d.attrs.colspan;for(let p=1;p<d.attrs.rowspan;p++)s[l+p]=(s[l+p]||0)+d.attrs.colspan}i.push(C.from(c))}t=i,n=r}if(e!=o){const s=[];for(let i=0,l=0;i<o;i++,l++){const a=[],c=t[l%e];for(let u=0;u<c.childCount;u++){let f=c.child(u);i+f.attrs.rowspan>o&&(f=f.type.create({...f.attrs,rowspan:Math.max(1,o-f.attrs.rowspan)},f.content)),a.push(f)}s.push(C.from(a))}t=s,e=o}return{width:n,height:e,rows:t}}function Jg(n,e,t,r,o,s,i){const l=n.doc.type.schema,a=pe(l);let c,u;if(o>e.width)for(let f=0,d=0;f<e.height;f++){const p=t.child(f);d+=p.nodeSize;const h=[];let b;p.lastChild==null||p.lastChild.type==a.cell?b=c||(c=a.cell.createAndFill()):b=u||(u=a.header_cell.createAndFill());for(let g=e.width;g<o;g++)h.push(b);n.insert(n.mapping.slice(i).map(d-1+r),h)}if(s>e.height){const f=[];for(let h=0,b=(e.height-1)*e.width;h<Math.max(e.width,o);h++){const g=h>=e.width?!1:t.nodeAt(e.map[b+h]).type==a.header_cell;f.push(g?u||(u=a.header_cell.createAndFill()):c||(c=a.cell.createAndFill()))}const d=a.row.create(null,C.from(f)),p=[];for(let h=e.height;h<s;h++)p.push(d);n.insert(n.mapping.slice(i).map(r+t.nodeSize-2),p)}return!!(c||u)}function Wc(n,e,t,r,o,s,i,l){if(i==0||i==e.height)return!1;let a=!1;for(let c=o;c<s;c++){const u=i*e.width+c,f=e.map[u];if(e.map[u-e.width]==f){a=!0;const d=t.nodeAt(f),{top:p,left:h}=e.findCell(f);n.setNodeMarkup(n.mapping.slice(l).map(f+r),null,{...d.attrs,rowspan:i-p}),n.insert(n.mapping.slice(l).map(e.positionAt(i,h,t)),d.type.createAndFill({...d.attrs,rowspan:p+d.attrs.rowspan-i})),c+=d.attrs.colspan-1}}return a}function _c(n,e,t,r,o,s,i,l){if(i==0||i==e.width)return!1;let a=!1;for(let c=o;c<s;c++){const u=c*e.width+i,f=e.map[u];if(e.map[u-1]==f){a=!0;const d=t.nodeAt(f),p=e.colCount(f),h=n.mapping.slice(l).map(f+r);n.setNodeMarkup(h,null,qt(d.attrs,i-p,d.attrs.colspan-(i-p))),n.insert(h+d.nodeSize,d.type.createAndFill(qt(d.attrs,0,i-p))),c+=d.attrs.rowspan-1}}return a}function qc(n,e,t,r,o){let s=t?n.doc.nodeAt(t-1):n.doc;if(!s)throw new Error("No table found");let i=Q.get(s);const{top:l,left:a}=r,c=a+o.width,u=l+o.height,f=n.tr;let d=0;function p(){if(s=t?f.doc.nodeAt(t-1):f.doc,!s)throw new Error("No table found");i=Q.get(s),d=f.mapping.maps.length}Jg(f,i,s,t,c,u,d)&&p(),Wc(f,i,s,t,a,c,l,d)&&p(),Wc(f,i,s,t,a,c,u,d)&&p(),_c(f,i,s,t,l,u,a,d)&&p(),_c(f,i,s,t,l,u,c,d)&&p();for(let h=l;h<u;h++){const b=i.positionAt(h,a,s),g=i.positionAt(h,c,s);f.replace(f.mapping.slice(d).map(b+t),f.mapping.slice(d).map(g+t),new E(o.rows[h-l],0,0))}p(),f.setSelection(new W(f.doc.resolve(t+i.positionAt(l,a,s)),f.doc.resolve(t+i.positionAt(u-1,c-1,s)))),e(f)}var Yg=zo({ArrowLeft:Gr("horiz",-1),ArrowRight:Gr("horiz",1),ArrowUp:Gr("vert",-1),ArrowDown:Gr("vert",1),"Shift-ArrowLeft":Xr("horiz",-1),"Shift-ArrowRight":Xr("horiz",1),"Shift-ArrowUp":Xr("vert",-1),"Shift-ArrowDown":Xr("vert",1),Backspace:Jr,"Mod-Backspace":Jr,Delete:Jr,"Mod-Delete":Jr});function Yr(n,e,t){return t.eq(n.selection)?!1:(e&&e(n.tr.setSelection(t).scrollIntoView()),!0)}function Gr(n,e){return(t,r,o)=>{if(!o)return!1;const s=t.selection;if(s instanceof W)return Yr(t,r,R.near(s.$headCell,e));if(n!="horiz"&&!s.empty)return!1;const i=Hc(o,n,e);if(i==null)return!1;if(n=="horiz")return Yr(t,r,R.near(t.doc.resolve(s.head+e),e));{const l=t.doc.resolve(i),a=Vc(l,n,e);let c;return a?c=R.near(a,1):e<0?c=R.near(t.doc.resolve(l.before(-1)),-1):c=R.near(t.doc.resolve(l.after(-1)),1),Yr(t,r,c)}}}function Xr(n,e){return(t,r,o)=>{if(!o)return!1;const s=t.selection;let i;if(s instanceof W)i=s;else{const a=Hc(o,n,e);if(a==null)return!1;i=new W(t.doc.resolve(a))}const l=Vc(i.$headCell,n,e);return l?Yr(t,r,new W(i.$anchorCell,l)):!1}}function Gg(n,e){const t=n.state.doc,r=Gn(t.resolve(e));return r?(n.dispatch(n.state.tr.setSelection(new W(r))),!0):!1}function Xg(n,e,t){if(!ve(n.state))return!1;let r=qg(t);const o=n.state.selection;if(o instanceof W){r||(r={width:1,height:1,rows:[C.from(Rs(pe(n.state.schema).cell,t))]});const s=o.$anchorCell.node(-1),i=o.$anchorCell.start(-1),l=Q.get(s).rectBetween(o.$anchorCell.pos-i,o.$headCell.pos-i);return r=Kg(r,l.right-l.left,l.bottom-l.top),qc(n.state,n.dispatch,i,l,r),!0}else if(r){const s=Kr(n.state),i=s.start(-1);return qc(n.state,n.dispatch,i,Q.get(s.node(-1)).findCell(s.pos-i),r),!0}else return!1}function Ug(n,e){var t;if(e.ctrlKey||e.metaKey)return;const r=Kc(n,e.target);let o;if(e.shiftKey&&n.state.selection instanceof W)s(n.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&r&&(o=Gn(n.state.selection.$anchor))!=null&&((t=zs(n,e))==null?void 0:t.pos)!=o.pos)s(o,e),e.preventDefault();else if(!r)return;function s(a,c){let u=zs(n,c);const f=Ct.getState(n.state)==null;if(!u||!Ps(a,u))if(f)u=a;else return;const d=new W(a,u);if(f||!n.state.selection.eq(d)){const p=n.state.tr.setSelection(d);f&&p.setMeta(Ct,a.pos),n.dispatch(p)}}function i(){n.root.removeEventListener("mouseup",i),n.root.removeEventListener("dragstart",i),n.root.removeEventListener("mousemove",l),Ct.getState(n.state)!=null&&n.dispatch(n.state.tr.setMeta(Ct,-1))}function l(a){const c=a,u=Ct.getState(n.state);let f;if(u!=null)f=n.state.doc.resolve(u);else if(Kc(n,c.target)!=r&&(f=zs(n,e),!f))return i();f&&s(f,c)}n.root.addEventListener("mouseup",i),n.root.addEventListener("dragstart",i),n.root.addEventListener("mousemove",l)}function Hc(n,e,t){if(!(n.state.selection instanceof V))return null;const{$head:r}=n.state.selection;for(let o=r.depth-1;o>=0;o--){const s=r.node(o);if((t<0?r.index(o):r.indexAfter(o))!=(t<0?0:s.childCount))return null;if(s.type.spec.tableRole=="cell"||s.type.spec.tableRole=="header_cell"){const l=r.before(o),a=e=="vert"?t>0?"down":"up":t>0?"right":"left";return n.endOfTextblock(a)?l:null}}return null}function Kc(n,e){for(;e&&e!=n.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function zs(n,e){const t=n.posAtCoords({left:e.clientX,top:e.clientY});return t&&t?Gn(n.state.doc.resolve(t.pos)):null}new lt("tableColumnResizing");function Qg({allowTableNodeSelection:n=!1}={}){return new Be({key:Ct,state:{init(){return null},apply(e,t){const r=e.getMeta(Ct);if(r!=null)return r==-1?null:r;if(t==null||!e.docChanged)return t;const{deleted:o,pos:s}=e.mapping.mapResult(t);return o?null:s}},props:{decorations:xg,handleDOMEvents:{mousedown:Ug},createSelectionBetween(e){return Ct.getState(e.state)!=null?e.state.selection:null},handleTripleClick:Gg,handleKeyDown:Yg,handlePaste:Xg},appendTransaction(e,t,r){return Cg(r,Is(r,t),n)}})}const wt=m.createContext(null),Zg=m.createContext(null),Jc=m.createContext(null),Ur=new WeakMap;function ey(n){const e=Object.create(null);e.class="ProseMirror",e.contenteditable=String(n.editable),n.someProp("attributes",o=>{if(typeof o=="function"&&(o=o(n.state)),o)for(const s in o)s=="class"?e.class+=" "+o[s]:s=="style"?e.style=(e.style?e.style+";":"")+o[s]:!e[s]&&s!="contenteditable"&&s!="nodeName"&&(e[s]=String(o[s]))}),e.translate||(e.translate="no");const t=[Ve.node(0,n.state.doc.content.size,e)],r=Ur.get(n);return!r||r[0].to!==n.state.doc.content.size||!r[0].type.eq(t[0].type)?(Ur.set(n,t),t):r}const ty=[],ny={},$s=H.empty;let Yc=class Sn{constructor(e){j(this,"members");this.members=e}map(e,t){const r=this.members.map(o=>o.map(e,t,ny));return Sn.from(r)}forChild(e,t){if(t.isLeaf)return H.empty;let r=[];for(let o=0;o<this.members.length;o++){const s=this.members[o].forChild(e,t);s!=$s&&(s instanceof Sn?r=r.concat(s.members):r.push(s))}return Sn.from(r)}eq(e){if(!(e instanceof Sn)||e.members.length!=this.members.length)return!1;for(let t=0;t<this.members.length;t++)if(!this.members[t].eq(e.members[t]))return!1;return!0}locals(e){let t,r=!0;for(let o=0;o<this.members.length;o++){const s=this.members[o].localsInner(e);if(s.length)if(!t)t=s;else{r&&(t=t.slice(),r=!1);for(let i=0;i<s.length;i++)t.push(s[i])}}return t?ry(r?t:t.sort(Gc)):ty}static from(e){switch(e.length){case 0:return $s;case 1:return e[0];default:return new Sn(e.every(t=>t instanceof H)?e:e.reduce((t,r)=>t.concat(r instanceof H?r:r.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}};function Gc(n,e){return n.from-e.from||n.to-e.to}function ry(n){let e=n;for(let t=0;t<e.length-1;t++){const r=e[t];if(r.from!=r.to)for(let o=t+1;o<e.length;o++){const s=e[o];if(s.from==r.from){s.to!=r.to&&(e==n&&(e=n.slice()),e[o]=s.copy(s.from,r.to),Xc(e,o+1,s.copy(r.to,s.to)));continue}else{s.from<r.to&&(e==n&&(e=n.slice()),e[t]=r.copy(r.from,s.from),Xc(e,o,r.copy(s.from,r.to)));break}}}return e}function Xc(n,e,t){for(;e<n.length&&Gc(t,n[e])>0;)e++;n.splice(e,0,t)}const js=new WeakMap;function oy(n,e){const t=[];n.someProp("decorations",i=>{const l=i(n.state);l&&l!=$s&&t.push(l)}),e&&t.push(H.create(n.state.doc,[e]));const r=js.get(n);if(!r){const i=Yc.from(t);return js.set(n,i),i}let o=0,s=!0;if(r.forEachSet(i=>{t[o++]!==i&&(s=!1)}),o!==t.length&&(s=!1),!s){const i=Yc.from(t);return js.set(n,i),i}return r}const Bs=function(n){for(let e=0;;e++)if(n=n.previousSibling,!n)return e},Uc=function(n){const e=n.assignedSlot||n.parentNode;return e&&e.nodeType==11?e.host:e},sy=function(n,e,t,r){return t&&(Qc(n,e,t,r,-1)||Qc(n,e,t,r,1))},iy=/^(img|br|input|textarea|hr)$/i;function Qc(n,e,t,r,o){for(;;){if(n==t&&e==r)return!0;if(e==(o<0?0:Qr(n))){const s=n.parentNode;if(!s||s.nodeType!=1||ay(n)||iy.test(n.nodeName)||n.contentEditable=="false")return!1;e=Bs(n)+(o<0?0:1),n=s}else if(n.nodeType==1){if(n=n.childNodes[e+(o<0?-1:0)],n.contentEditable=="false")return!1;e=o<0?Qr(n):0}else return!1}}function Qr(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function ly(n,e,t){for(let r=e==0,o=e==Qr(n);r||o;){if(n==t)return!0;const s=Bs(n);if(n=n.parentNode,!n)return!1;r=r&&s==0,o=o&&s==Qr(n)}return!1}function ay(n){let e;for(let t=n;t&&!(e=t.pmViewDesc);t=t.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==n||e.contentDOM==n)}const Zc=function(n){return n.focusNode&&sy(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)},eu=m.createContext(null);function J(){for(var n=arguments.length,e=new Array(n),t=0;t<n;t++)e[t]=arguments[t];typeof document>"u"||m.useLayoutEffect(...e)}function cy(n,e){const t=m.useContext(eu);J(()=>t(n),e)}function Ke(n,e){const{view:t,flushSyncRef:r}=m.useContext(wt);cy(()=>{if(t!=null&&t.docView){r.current=!1;const o=n(t);return r.current=!0,o}},e&&[t,...e])}const uy=m.forwardRef(function(e,t){let{widget:r,getPos:o,...s}=e;const[i,l]=m.useState(!0),a=m.useRef(null);return m.useImperativeHandle(t,()=>a.current,[]),Ke(c=>{if(!c||!a.current)return;c.domObserver.disconnectSelection();const u=c.domSelection(),f=document.createRange(),d=a.current;d.nodeName=="IMG"&&d.parentNode?f.setEnd(d.parentNode,Bs(d)+1):f.setEnd(d,0),f.collapse(!1),u.removeAllRanges(),u.addRange(f),l(!1),c.domObserver.connectSelection()},[]),i?m.createElement("img",{ref:a,className:"ProseMirror-separator","mark-placeholder":"true",alt:"",...s}):null});function fy(n,e){if(n==e)return!0;for(const t in n)if(n[t]!==e[t])return!1;for(const t in e)if(!(t in n))return!1;return!0}const dy={side:0};class Xn{constructor(e,t){j(this,"Component");j(this,"side");j(this,"spec");this.Component=e,this.spec=t??dy,this.side=this.spec.side??0}map(e,t,r,o){const{pos:s,deleted:i}=e.mapResult(t.from+o,this.side<0?-1:1);return i?null:new Ve(s-r,s-r,this)}valid(){return!0}eq(e){return this==e||e instanceof Xn&&(this.spec.key&&this.spec.key==e.spec.key||this.Component==e.Component&&fy(this.spec,e.spec))}destroy(){}}function hy(n,e,t){return new Ve(n,n,new Xn(e,t))}function Fs(){return Math.floor(Math.random()*0xffffffffffff).toString(16)}const Un=new lt("@handlewithcare/react-prosemirror/reactKeys");function py(){let n=!1;return new Be({key:Un,state:{init(e,t){const r={posToKey:new Map,keyToPos:new Map};return t.doc.descendants((o,s)=>{const i=Fs();return r.posToKey.set(s,i),r.keyToPos.set(i,s),!0}),r},apply(e,t,r,o){if(!e.docChanged||n)return t;const s=e.getMeta(Un),i=(s==null?void 0:s.type)==="bustKey"&&s.payload.key,l={posToKey:new Map,keyToPos:new Map},a=Array.from(t.posToKey.entries()).sort((c,u)=>{let[f]=c,[d]=u;return f-d});for(const[c,u]of a){const{pos:f,deleted:d}=e.mapping.mapResult(c);if(d)continue;let p=u;i===u&&(p=Fs()),l.posToKey.set(f,p),l.keyToPos.set(p,f)}return o.doc.descendants((c,u)=>{if(l.posToKey.has(u))return!0;const f=Fs();return l.posToKey.set(u,f),l.keyToPos.set(f,u),!0}),l}},props:{handleDOMEvents:{compositionstart:()=>{n=!0},compositionend:()=>{n=!1}}}})}function Ls(n,e){var i;let t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(e===null)return!1;const r=t.from??n.state.selection.from,o=t.to??n.state.selection.to;if(n.someProp("handleTextInput",l=>l(n,r,o,e)))return!0;const{tr:s}=n.state;if(t.marks&&s.ensureMarks(t.marks),s.insertText(e,r,o),t.bust){const l=n.state.doc.resolve(r),a=l.sharedDepth(o),c=l.start(a),u=(i=Un.getState(n.state))==null?void 0:i.posToKey.get(c-1);s.setMeta(Un,{type:"bustKey",payload:{key:u}})}return n.dispatch(s),!0}function my(n){let e=null,t=null;return new Be({props:{handleDOMEvents:{compositionstart(r){var i;const{state:o}=r;r.dispatch(o.tr.deleteSelection());const s=o.selection.$from;return o.selection.empty&&(o.storedMarks||!s.textOffset&&s.parentOffset&&((i=s.nodeBefore)!=null&&i.marks.some(l=>l.type.spec.inclusive===!1)))&&n(hy(o.selection.from,uy,{key:"cursor-wrapper",marks:o.storedMarks??s.marks()})),t=o.storedMarks??s.marks(),r.input.composing=!0,!0},compositionupdate(){return!0},compositionend(r){if(r.input.composing=!1,e!==null)return Ls(r,e,{bust:!0,marks:t}),e=null,t=null,n(null),!0},beforeinput(r,o){var s,i;switch(o.preventDefault(),o.inputType){case"insertCompositionText":{if(o.data===null)break;e=o.data;break}case"insertReplacementText":{const l=o.getTargetRanges();(i=(s=o.dataTransfer)==null?void 0:s.items[0])==null||i.getAsString(a=>{for(const c of l){const u=r.posAtDOM(c.startContainer,c.startOffset,1),f=r.posAtDOM(c.endContainer,c.endOffset,1);Ls(r,a,{from:u,to:f})}});break}case"insertText":{Ls(r,o.data);break}case"deleteWordBackward":case"deleteContentBackward":case"deleteWordForward":case"deleteContentForward":case"deleteContent":{const l=o.getTargetRanges(),{tr:a}=r.state;for(const c of l){const u=r.posAtDOM(c.startContainer,c.startOffset),f=r.posAtDOM(c.endContainer,c.endOffset),{doc:d}=r.state,p=d.resolve(u).marksAcross(d.resolve(f));a.delete(u,f).setStoredMarks(p)}r.dispatch(a);break}}return!0}}}})}const Je=typeof navigator<"u"?navigator:null,tu=typeof document<"u"?document:null,Ht=Je&&Je.userAgent||"",Ws=/Edge\/(\d+)/.exec(Ht),nu=/MSIE \d/.exec(Ht),_s=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Ht),Zr=!!(nu||_s||Ws),gy=nu?document.documentMode:_s?+_s[1]:Ws?+Ws[1]:0,ru=!Zr&&/gecko\/(\d+)/i.test(Ht);ru&&+(/Firefox\/(\d+)/.exec(Ht)||[0,0])[1];const qs=!Zr&&/Chrome\/(\d+)/.exec(Ht),yy=!!qs,by=qs?+qs[1]:0,ou=!Zr&&!!Je&&/Apple Computer/.test(Je.vendor);ou&&(/Mobile\/\w+/.test(Ht)||!!Je&&Je.maxTouchPoints>2)||Je&&/Mac/.test(Je.platform),Je&&/Win/.test(Je.platform),!!tu&&"webkitFontSmoothing"in tu.documentElement.style&&+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1];const ae={ie:Zr,ie_version:gy,gecko:ru,chrome:yy,chrome_version:by,safari:ou};function su(n){return n.editable&&!n.hasFocus()?!1:xy(n)}function xy(n){var t,r;const e=n.domSelectionRange();if(!e.anchorNode)return!1;try{return n.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(n.editable||n.dom.contains(((t=e.focusNode)==null?void 0:t.nodeType)==3?(r=e.focusNode)==null?void 0:r.parentNode:e.focusNode))}catch{return!1}}function ky(n,e,t,r){return n.someProp("createSelectionBetween",o=>o(n,e,t))||V.between(e,t,r)}function iu(n){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null;const t=n.domSelectionRange(),r=n.state.doc;if(!t.focusNode)return null;let o=n.docView.nearestDesc(t.focusNode);const s=o&&o.size==0;let i=n.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(i<0)return null;let l=r.resolve(i),a,c;if(Zc(t)){for(a=i;o&&!o.node;)o=o.parent;const f=o.node;if(o&&f.isAtom&&v.isSelectable(f)&&o.parent&&!(f.isInline&&ly(t.focusNode,t.focusOffset,o.dom))){const d=o.posBefore;c=new v(i==d?l:r.resolve(d))}}else{if(t instanceof n.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let f=i,d=i;for(let p=0;p<t.rangeCount;p++){const h=t.getRangeAt(p);f=Math.min(f,n.docView.posFromDOM(h.startContainer,h.startOffset,1)),d=Math.max(d,n.docView.posFromDOM(h.endContainer,h.endOffset,-1))}if(f<0)return null;[a,i]=d==n.state.selection.anchor?[d,f]:[f,d],l=r.resolve(i)}else a=n.docView.posFromDOM(t.anchorNode,t.anchorOffset,1);if(a<0)return null}const u=r.resolve(a);if(!c){const f=e=="pointer"||n.state.selection.head<l.pos&&!s?1:-1;c=ky(n,u,l,f)}return c}const eo=function(n,e,t,r){return t&&(lu(n,e,t,r,-1)||lu(n,e,t,r,1))};function Sy(n){let e;for(let t=n;t&&!(e=t.pmViewDesc);t=t.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==n||e.contentDOM==n)}const Cy=/^(img|br|input|textarea|hr)$/i;function lu(n,e,t,r,o){for(;;){if(n==t&&e==r)return!0;if(e==(o<0?0:au(n))){const s=n.parentNode;if(!s||s.nodeType!=1||Sy(n)||Cy.test(n.nodeName)||n.contentEditable=="false")return!1;e=Mt(n)+(o<0?0:1),n=s}else if(n.nodeType==1){if(n=n.childNodes[e+(o<0?-1:0)],n.contentEditable=="false")return!1;e=o<0?au(n):0}else return!1}}const Mt=function(n){let e=n;for(let t=0;;t++)if(e=e.previousSibling,!e)return t};function au(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function wy(n,e){const t=n;if(e instanceof v){const r=t.docView.descAt(e.from);r!=t.lastSelectedViewDesc&&(cu(t),r&&r.selectNode(),t.lastSelectedViewDesc=r)}else cu(t)}function cu(n){const e=n;e.lastSelectedViewDesc&&(e.lastSelectedViewDesc.parent&&e.lastSelectedViewDesc.deselectNode(),e.lastSelectedViewDesc=void 0)}function My(n){const e=n,t=e.domSelectionRange();if(!t.anchorNode)return!1;try{return e.dom.contains(t.anchorNode.nodeType==3?t.anchorNode.parentNode:t.anchorNode)&&(e.editable||e.dom.contains(t.focusNode.nodeType==3?t.focusNode.parentNode:t.focusNode))}catch{return!1}}function uu(n){return n.editable?n.hasFocus():My(n)&&document.activeElement&&document.activeElement.contains(n.dom)}function Ny(n){const e=n,t=e.domSelection(),r=document.createRange();if(!t)return;const o=e.cursorWrapper.dom,s=o.nodeName=="IMG";s?r.setStart(o.parentNode,Mt(o)+1):r.setStart(o,0),r.collapse(!0),t.removeAllRanges(),t.addRange(r),!s&&!e.state.selection.visible&&ae.ie&&ae.ie_version<=11&&(o.disabled=!0,o.disabled=!1)}function fu(n,e){const t=n,{node:r,offset:o}=t.docView.domFromPos(e,0),s=o<r.childNodes.length?r.childNodes[o]:null,i=o?r.childNodes[o-1]:null;if(ae.safari&&s&&s.contentEditable=="false")return Hs(s);if((!s||s.contentEditable=="false")&&(!i||i.contentEditable=="false")){if(s)return Hs(s);if(i)return Hs(i)}}function Hs(n){return n.contentEditable="true",ae.safari&&n.draggable&&(n.draggable=!1,n.wasDraggable=!0),n}function du(n){n.contentEditable="false",n.wasDraggable&&(n.draggable=!0,n.wasDraggable=null)}function Ey(n){const e=n,t=e.dom.ownerDocument;t.removeEventListener("selectionchange",e.input.hideSelectionGuard);const r=e.domSelectionRange(),o=r.anchorNode,s=r.anchorOffset;t.addEventListener("selectionchange",e.input.hideSelectionGuard=()=>{(r.anchorNode!=o||r.anchorOffset!=s)&&(t.removeEventListener("selectionchange",e.input.hideSelectionGuard),setTimeout(()=>{(!uu(e)||e.state.selection.visible)&&e.dom.classList.remove("ProseMirror-hideselection")},20))})}const hu=ae.safari||ae.chrome&&ae.chrome_version<63;function to(n){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;const t=n,r=t.state.selection;if(wy(t,r),!!uu(t)){if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&ae.chrome){const o=t.domSelectionRange(),s=t.domObserver.currentSelection;if(o.anchorNode&&s.anchorNode&&eo(o.anchorNode,o.anchorOffset,s.anchorNode,s.anchorOffset)){t.input.mouseDown.delayedSelectionSync=!0,t.domObserver.setCurSelection();return}}if(t.domObserver.disconnectSelection(),t.cursorWrapper)Ny(t);else{const{anchor:o,head:s}=r;let i,l;hu&&!(r instanceof V)&&(r.$from.parent.inlineContent||(i=fu(t,r.from)),!r.empty&&!r.$from.parent.inlineContent&&(l=fu(t,r.to))),t.docView.setSelection(o,s,t,e),hu&&(i&&du(i),l&&du(l)),r.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&Ey(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}}let Dy=class{constructor(){j(this,"anchorNode",null);j(this,"anchorOffset",0);j(this,"focusNode",null);j(this,"focusOffset",0)}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}};class vy{constructor(e){j(this,"view");j(this,"flushingSoon");j(this,"currentSelection");j(this,"suppressingSelectionUpdates");this.view=e,this.flushingSoon=-1,this.currentSelection=new Dy,this.suppressingSelectionUpdates=!1,this.view=e,this.onSelectionChange=this.onSelectionChange.bind(this)}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}stop(){this.disconnectSelection()}start(){this.connectSelection()}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;const t=new Set;let r;for(let s=e.focusNode;s;s=Uc(s))t.add(s);for(let s=e.anchorNode;s;s=Uc(s))if(t.has(s)){r=s;break}const o=r&&this.view.docView.nearestDesc(r);if(o&&o.ignoreMutation({type:"selection",target:(r==null?void 0:r.nodeType)==3?r==null?void 0:r.parentNode:r}))return this.setCurSelection(),!0}registerMutation(){}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}updateSelection(){const{view:e}=this,t=e.input.compositionPendingChanges||(e.composing?e.input.compositionID:0);e.input.compositionPendingChanges=0;const r=e.input.lastSelectionTime>Date.now()-50?e.input.lastSelectionOrigin:null,o=iu(e,r);if(o&&!e.state.selection.eq(o)){const s=e.state.tr.setSelection(o);r=="pointer"?s.setMeta("pointer",!0):r=="key"&&s.scrollIntoView(),t&&s.setMeta("composition",t),e.dispatch(s)}}selectionToDOM(){const{view:e}=this;to(e);const t=e.domSelectionRange();this.currentSelection.set(t)}flush(){const{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;const t=e.domSelectionRange(),r=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(t)&&su(e)&&!this.ignoreSelectionChange(t);let o=null;r&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&Zc(t)&&(o=iu(e))&&o.eq(R.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,to(e),this.currentSelection.set(t),e.scrollToSelection()):r&&(this.updateSelection(),this.currentSelection.eq(t)||to(e),this.currentSelection.set(t))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}onSelectionChange(){if(su(this.view)&&!this.view.composing){if(this.suppressingSelectionUpdates)return to(this.view);if(ae.ie&&ae.ie_version<=11&&!this.view.state.selection.empty){const e=this.view.domSelectionRange();if(e.focusNode&&eo(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}}let Oy=class{add(){}remove(){}},pu=class co{constructor(){j(this,"nodeName","div");j(this,"style",{})}get parent(){return new co}get parentNode(){return new co}appendChild(){return new co}setAttribute(){}hasAttribute(){return!1}insertBefore(){}get classList(){return new Oy}get ownerDocument(){return new mu}addEventListener(){}removeEventListener(){}replaceChildren(){}},mu=class{createElement(){return new pu}addEventListener(){}removeEventListener(){}get documentElement(){return new pu}};function gu(){const n=globalThis.window;globalThis.window??(globalThis.window={visualViewport:null});const e=globalThis.document;return globalThis.document??(globalThis.document=new mu),function(){globalThis.window!==n&&(globalThis.window=n),globalThis.document!==e&&(globalThis.document=e)}}function Kt(n,e){return n instanceof er?1:e instanceof er?-1:n.getPos()-e.getPos()}const gn=0,yu=1,no=2,Qn=3;class Zn{constructor(e,t,r,o,s){j(this,"parent");j(this,"children");j(this,"getPos");j(this,"dom");j(this,"contentDOM");j(this,"dirty");j(this,"node");this.parent=e,this.children=t,this.getPos=r,this.dom=o,this.contentDOM=s,this.dirty=gn,o.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,r){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;t<this.children.length;t++)e+=this.children[t].size;return e}get border(){return 0}destroy(){}posBeforeChild(e){for(let t=0,r=this.posAtStart;;t++){const o=this.children[t];if(o==e)return r;r+=o.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,t,r){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(r<0){let s,i;if(e==this.contentDOM)s=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;s=e.previousSibling}for(;s&&!((i=s.pmViewDesc)&&i.parent==this);)s=s.previousSibling;return s?this.posBeforeChild(i)+i.size:this.posAtStart}else{let s,i;if(e==this.contentDOM)s=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;s=e.nextSibling}for(;s&&!((i=s.pmViewDesc)&&i.parent==this);)s=s.nextSibling;return s?this.posBeforeChild(i):this.posAtEnd}let o;if(e==this.dom&&this.contentDOM)o=t>Mt(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))o=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(t==0)for(let s=e;;s=s.parentNode){if(s==this.dom){o=!1;break}if(s.previousSibling)break}if(o==null&&t==e.childNodes.length)for(let s=e;;s=s.parentNode){if(s==this.dom){o=!0;break}if(s.nextSibling)break}}return o??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;for(let r=!0,o=e;o;o=o.parentNode){const s=this.getDesc(o);let i;if(s&&(!t||s.node))if(r&&(i=s.nodeDOM)&&!(i.nodeType==1?i.contains(e.nodeType==1?e:e.parentNode):i==e))r=!1;else return s}}getDesc(e){const t=e.pmViewDesc;for(let r=t;r;r=r.parent)if(r==this)return t}posFromDOM(e,t,r){for(let o=e;o;o=o.parentNode){const s=this.getDesc(o);if(s)return s.localPosFromDOM(e,t,r)}return-1}descAt(e){for(let t=0,r=0;t<this.children.length;t++){let o=this.children[t];const s=r+o.size;if(r==e&&s!=r){for(;!o.border&&o.children.length;)o=o.children[0];return o}if(e<s)return o.descAt(e-r-o.border);r=s}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let r=0,o=0;for(let s=0;r<this.children.length;r++){const i=this.children[r],l=s+i.size;if(l>e||i instanceof er){o=e-s;break}s=l}if(o)return this.children[r].domFromPos(o-this.children[r].border,t);for(let s;r&&!(s=this.children[r-1]).size&&s instanceof Ks&&s.side>=0;r--);if(t<=0){let s,i=!0;for(;s=r?this.children[r-1]:null,!(!s||s.dom.parentNode==this.contentDOM);r--,i=!1);return s&&t&&i&&!s.border&&!s.domAtom?s.domFromPos(s.size,t):{node:this.contentDOM,offset:s?Mt(s.dom)+1:0}}else{let s,i=!0;for(;s=r<this.children.length?this.children[r]:null,!(!s||s.dom.parentNode==this.contentDOM);r++,i=!1);return s&&i&&!s.border&&!s.domAtom?s.domFromPos(0,t):{node:this.contentDOM,offset:s?Mt(s.dom):this.contentDOM.childNodes.length}}}parseRange(e,t){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0;if(this.children.length==0)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let o=-1,s=-1;for(let i=r,l=0;;l++){const a=this.children[l],c=i+a.size;if(o==-1&&e<=c){const u=i+a.border;if(e>=u&&t<=c-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,t,u);e=i;for(let f=l;f>0;f--){const d=this.children[f-1];if(d.size&&d.dom.parentNode==this.contentDOM&&!d.emptyChildAt(1)){o=Mt(d.dom)+1;break}e-=d.size}o==-1&&(o=0)}if(o>-1&&(c>t||l==this.children.length-1)){t=c;for(let u=l+1;u<this.children.length;u++){const f=this.children[u];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(-1)){s=Mt(f.dom);break}t+=f.size}s==-1&&(s=this.contentDOM.childNodes.length);break}i=c}return{node:this.contentDOM,from:e,to:t,fromOffset:o,toOffset:s}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;const t=this.children[e<0?0:this.children.length-1];return t.size==0||t.emptyChildAt(e)}domAfterPos(e){const{node:t,offset:r}=this.domFromPos(e,0);if(t.nodeType!=1||r==t.childNodes.length)throw new RangeError("No node after pos "+e);return t.childNodes[r]}setSelection(e,t,r){var p;let o=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1;const s=Math.min(e,t),i=Math.max(e,t);for(let h=0,b=0;h<this.children.length;h++){const g=this.children[h],x=b+g.size;if(s>b&&i<x)return g.setSelection(e-b-g.border,t-b-g.border,r,o);b=x}let l=this.domFromPos(e,e?-1:1),a=t==e?l:this.domFromPos(t,t?-1:1);const c=r.root.getSelection(),u=r.domSelectionRange();let f=!1;if((ae.gecko||ae.safari)&&e==t){const{node:h,offset:b}=l;if(h.nodeType==3){if(f=!!(b&&((p=h.nodeValue)==null?void 0:p[b-1])==`
|
|
45
|
+
`),f&&b==h.nodeValue.length)for(let g=h,x;g;g=g.parentNode){if(x=g.nextSibling){x.nodeName=="BR"&&(l=a={node:x.parentNode,offset:Mt(x)+1});break}const S=g.pmViewDesc;if(S&&S.node&&S.node.isBlock)break}}else{const g=h.childNodes[b-1];f=g&&(g.nodeName=="BR"||g.contentEditable=="false")}}if(ae.gecko&&u.focusNode&&u.focusNode!=a.node&&u.focusNode.nodeType==1){const h=u.focusNode.childNodes[u.focusOffset];h&&h.contentEditable=="false"&&(o=!0)}if(!(o||f&&ae.safari)&&eo(l.node,l.offset,u.anchorNode,u.anchorOffset)&&eo(a.node,a.offset,u.focusNode,u.focusOffset))return;let d=!1;if((c.extend||e==t)&&!f){c.collapse(l.node,l.offset);try{e!=t&&c.extend(a.node,a.offset),d=!0}catch{}}if(!d){if(e>t){const b=l;l=a,a=b}const h=document.createRange();h.setEnd(a.node,a.offset),h.setStart(l.node,l.offset),c.removeAllRanges(),c.addRange(h)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let r=0,o=0;o<this.children.length;o++){const s=this.children[o],i=r+s.size;if(r==i?e<=i&&t>=r:e<i&&t>r){const l=r+s.border,a=i-s.border;if(e>=l&&t<=a){this.dirty=e==r||t==i?no:yu,e==l&&t==a&&(s.contentLost||s.dom.parentNode!=this.contentDOM)?s.dirty=Qn:s.markDirty(e-l,t-l);return}else s.dirty=s.dom==s.contentDOM&&s.dom.parentNode==this.contentDOM&&!s.children.length?no:Qn}r=i}this.dirty=no}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){const r=e==1?no:yu;t.dirty<r&&(t.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}}class Ks extends Zn{constructor(t,r,o,s){super(t,[],r,s,null);j(this,"widget");this.widget=o,this.widget=o}matchesWidget(t){return this.dirty==gn&&t.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(t){const r=this.widget.spec.stopEvent;return r?r(t):!1}ignoreMutation(t){return t.type!="selection"||this.widget.spec.ignoreSelection}get domAtom(){return!0}get side(){return this.widget.type.side}}class ro extends Zn{constructor(t,r,o,s,i){super(t,[],r,o,null);j(this,"textDOM");j(this,"text");this.textDOM=s,this.text=i}get size(){return this.text.length}localPosFromDOM(t,r){return t!=this.textDOM?this.posAtStart+(r?this.size:0):this.posAtStart+r}domFromPos(t){return{node:this.textDOM,offset:t}}ignoreMutation(t){return t.type==="characterData"&&t.target.nodeValue==t.oldValue}}class Ty extends Zn{constructor(t,r,o,s,i,l,a){super(t,r,o,i,l);j(this,"mark");j(this,"spec");this.mark=s,this.spec=a}parseRule(){return this.dirty&Qn||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(t){return this.dirty!=Qn&&this.mark.eq(t)}markDirty(t,r){if(super.markDirty(t,r),this.dirty!=gn){let o=this.parent;for(;!o.node;)o=o.parent;o.dirty<this.dirty&&(o.dirty=this.dirty),this.dirty=gn}}ignoreMutation(t){return this.spec.ignoreMutation?this.spec.ignoreMutation(t):super.ignoreMutation(t)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class Js extends Zn{constructor(t,r,o,s,i,l,a,c,u,f,d,p,h){super(t,r,o,a,c);j(this,"node");j(this,"outerDeco");j(this,"innerDeco");j(this,"nodeDOM");j(this,"stopEvent");j(this,"selectNode");j(this,"deselectNode");j(this,"ignoreMutation");this.node=s,this.outerDeco=i,this.innerDeco=l,this.nodeDOM=u,this.stopEvent=f,this.selectNode=d,this.deselectNode=p,this.ignoreMutation=h}updateOuterDeco(){}parseRule(){if(this.node.type.spec.reparseInView)return null;const t={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(t.preserveWhitespace="full"),!this.contentDOM)t.getContent=()=>this.node.content;else if(!this.contentLost)t.contentElement=this.contentDOM;else{for(let r=this.children.length-1;r>=0;r--){const o=this.children[r];if(this.dom.contains(o.dom.parentNode)){t.contentElement=o.dom.parentNode;break}}t.contentElement||(t.getContent=()=>C.empty)}return t}matchesNode(t,r,o){return this.dirty==gn&&t.eq(this.node)&&Py(r,this.outerDeco)&&o.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}update(t,r,o,s){return!0}get domAtom(){return this.node.isAtom}}class Ay extends Js{constructor(e,t,r,o,s,i,l,a){super(e,t,r,o,s,i,l,null,a,()=>!1,()=>{},()=>{},c=>c.type!="characterData"&&c.type!="selection")}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,r,o){return!0}inParent(){const e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,r){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,r)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=Qn)}get domAtom(){return!1}}class er extends Zn{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==gn&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}function Py(n,e){if(n.length!=e.length)return!1;for(let t=0;t<n.length;t++)if(!n[t].type.eq(e[t].type))return!1;return!0}function Iy(n){const e={};for(const[r,o]of n.entries()){let s=function(i,l){for(const a of o){let c=!1;if(Ye.unstable_batchedUpdates(()=>{c=!!a.call(this,i,l)}),c||l.defaultPrevented)return!0}return!1};e[r]=s}return new Be({key:new lt("@handlewithcare/react-prosemirror/componentEventListeners"),props:{handleDOMEvents:e}})}function Vy(){const[n,e]=m.useState(new Map),t=m.useCallback((s,i)=>{const l=n.get(s)??[];l.unshift(i),n.has(s)||(n.set(s,l),e(new Map(n)))},[n]),r=m.useCallback((s,i)=>{const l=n.get(s);l==null||l.splice(l.indexOf(i),1)},[n]),o=m.useMemo(()=>Iy(n),[n]);return{registerEventListener:t,unregisterEventListener:r,componentEventListenersPlugin:o}}function Ys(){const[,n]=m.useReducer(e=>e+1,0);return n}function Ry(n){const e=Object.create(null);function t(r){for(const o in r)Object.prototype.hasOwnProperty.call(e,o)||(e[o]=r[o])}return n.someProp("nodeViews",t),n.someProp("markViews",t),e}function zy(n,e){let t=0,r=0;for(const o in n){if(n[o]!=e[o])return!0;t++}for(const o in e)r++;return t!=r}function $y(n,e){for(const t of Object.keys(n))if(n[t]!==e[t])return!0;return!1}function bu(n){return!n.someProp("editable",e=>e(n.state)===!1)}class xu extends Op{constructor(t,r){const o=gu();super(t,{state:Ge.create({schema:r.state.schema,plugins:r.state.plugins}),plugins:r.plugins});j(this,"shouldUpdatePluginViews",!1);j(this,"oldProps");j(this,"_props");o(),this.shouldUpdatePluginViews=!0,this._props=r,this.oldProps={state:r.state},this.state=r.state,this.domObserver.stop(),this.domObserver=new vy(this),this.domObserver.start(),this.editable=bu(this),this.docView.dom.replaceChildren(),this.docView=r.docView}get needsRedraw(){if(this.oldProps.state.plugins===this._props.state.plugins&&this._props.plugins===this.oldProps.plugins)return!1;const t=Ry(this);return zy(this.nodeViews,t)}pureSetProps(t){this._props={...this._props,...t},this.state=this._props.state,this.editable=bu(this)}runPendingEffects(){if($y(this.props,this.oldProps)){const t=this.props;this._props=this.oldProps,this.state=this._props.state,this.update(t)}}update(t){super.update(t),this.oldProps=t}updatePluginViews(t){this.shouldUpdatePluginViews&&super.updatePluginViews(t)}destroy(){this.dom=document.createElement("div"),super.destroy()}}const jy=new xr({nodes:{doc:{content:"text*"},text:{inline:!0}}}),By=Ge.create({schema:jy});let ku=!1;function Fy(n,e){process.env.NODE_ENV!=="production"&&e.defaultState!==void 0&&e.state!==void 0&&!ku&&(console.error("A component contains a ProseMirror editor with both value and defaultValue props. ProseMirror editors must be either controlled or uncontrolled (specify either the state prop, or the defaultState prop, but not both). Decide between using a controlled or uncontrolled ProseMirror editor and remove one of these props. More info: https://reactjs.org/link/controlled-components"),ku=!0);const t=m.useRef(!0),[r,o]=m.useState(null),s=Ys(),i=e.defaultState??By,[l,a]=m.useState(i),c=e.state??l,{componentEventListenersPlugin:u,registerEventListener:f,unregisterEventListener:d}=Vy(),p=m.useCallback(I=>{Ye.flushSync(()=>{o(I)})},[]),h=m.useMemo(()=>[...e.plugins??[],u,my(p)],[e.plugins,u,p]),b=m.useCallback(function(z){t.current?Ye.flushSync(()=>{e.state||a(O=>O.apply(z)),e.dispatchTransaction&&e.dispatchTransaction.call(this,z)}):(e.state||a(O=>O.apply(z)),e.dispatchTransaction&&e.dispatchTransaction.call(this,z))},[e.dispatchTransaction,e.state]),g=gu(),x=document.createElement("div");g();const S=m.useRef(new Js(void 0,[],()=>-1,c.doc,[],H.empty,x,null,x,()=>!1,()=>{},()=>{},()=>!1)),w={...e,state:c,plugins:h,dispatchTransaction:b,docView:S.current},[D,T]=m.useState(()=>new xu(null,w));return J(()=>()=>{D==null||D.destroy()},[D]),J(()=>{if(!n){T(null);return}if(!D||D.dom!==n){const I=new xu({mount:n},w);T(I),I.dom.addEventListener("compositionend",s);return}if(D.needsRedraw){T(null);return}D==null||D.domObserver.selectionToDOM(),D==null||D.runPendingEffects()}),D==null||D.pureSetProps(w),{editor:m.useMemo(()=>({view:D,registerEventListener:f,unregisterEventListener:d,cursorWrapper:r,docViewDescRef:S,flushSyncRef:t}),[D,f,d,r]),state:c}}function Ly(n){let{children:e}=n;const t=m.useRef(new Set).current,r=m.useRef(new Set).current,o=m.useRef(!1),s=Ys(),i=m.useRef(!0),l=m.useCallback(()=>{i.current||(s(),i.current=!0)},[s]),a=m.useCallback(c=>{let u;const f=()=>{u=c()};return t.add(f),l(),()=>{t.delete(f),u&&(o.current?(r.add(u),l()):u())}},[t,r,l]);return J(()=>(i.current=!1,t.forEach(c=>c()),t.clear(),()=>{r.forEach(c=>c()),r.clear()})),J(()=>(o.current=!0,()=>{o.current=!1}),[]),m.createElement(eu.Provider,{value:a},e)}const Ce=m.createContext({parentRef:{current:void 0},siblingsRef:{current:[]}});function Gs(n,e,t,r,o,s,i,l){const{view:a}=m.useContext(wt),[c,u]=m.useState(!0),f=m.useRef(i),d=m.useRef(()=>!1),p=m.useCallback(M=>{d.current=M},[]),h=m.useRef(()=>!1),b=m.useCallback(M=>{h.current=M},[]),g=m.useRef(()=>{!r.current||!n||(r.current.nodeType==1&&r.current.classList.add("ProseMirror-selectednode"),(l!=null&&l.current||!n.type.spec.draggable)&&(((t==null?void 0:t.current)??r.current).draggable=!0))}),x=m.useRef(()=>{!r.current||!n||r.current.nodeType==1&&(r.current.classList.remove("ProseMirror-selectednode"),(l!=null&&l.current||!n.type.spec.draggable)&&((t==null?void 0:t.current)??r.current).removeAttribute("draggable"))}),S=m.useCallback((M,I)=>{g.current=M,x.current=I},[]),{siblingsRef:w,parentRef:D}=m.useContext(Ce),T=m.useRef([]);return J(()=>{const M=w.current;return()=>{if(f.current&&M.includes(f.current)){const I=M.indexOf(f.current);M.splice(I,1)}}},[w]),J(()=>{var I;if(!n||!r.current)return;const M=T.current[0];f.current?(f.current.parent=D.current,f.current.children=T.current,f.current.node=n,f.current.getPos=e,f.current.outerDeco=s,f.current.innerDeco=o,f.current.dom=(t==null?void 0:t.current)??r.current,f.current.dom.pmViewDesc=f.current,f.current.contentDOM=(l==null?void 0:l.current)??f.current.contentDOM??(M==null?void 0:M.dom.parentElement)??null,f.current.nodeDOM=r.current):f.current=new Js(D.current,T.current,e,n,s,o,(t==null?void 0:t.current)??r.current,(M==null?void 0:M.dom.parentElement)??null,r.current,z=>!!d.current(z),()=>g.current(),()=>x.current(),z=>h.current(z)),u(f.current.contentDOM!==null),w.current.includes(f.current)||w.current.push(f.current),w.current.sort(Kt);for(const z of T.current)if(z.parent=f.current,z instanceof ro){const O=(I=f.current.contentDOM)==null?void 0:I.firstChild;if(!O)throw new Error("Started a composition but couldn't find the text node it belongs to.");let L=O;for(;L.firstChild;)L=L.firstChild;if(!L||!(L instanceof Text))throw new Error("Started a composition but couldn't find the text node it belongs to.");z.dom=O,z.textDOM=L,z.text=L.data,z.textDOM.pmViewDesc=z,a==null||a.input.compositionNodes.push(z)}return()=>{var z,O,L,we;((z=f.current)==null?void 0:z.children[0])instanceof ro&&!(a!=null&&a.composing)&&((we=(O=f.current)==null?void 0:O.children[0].dom.parentNode)==null||we.removeChild((L=f.current)==null?void 0:L.children[0].dom))}}),{hasContentDOM:c,childDescriptors:T,nodeViewDescRef:f,setStopEvent:p,setSelectNode:S,setIgnoreMutation:b}}function Wy(n,e){return n.type.side-e.type.side}function _y(n,e,t,r){const o=e.locals(n);let s=0;if(o.length==0){for(let c=0;c<n.childCount;c++){const u=n.child(c);r(u,o,e.forChild(s,u),s,c),s+=u.nodeSize}return}let i=0;const l=[];let a=null;for(let c=0;;){if(i<o.length&&o[i].to==s){const h=o[i++];let b;for(;i<o.length&&o[i].to==s;)(b||(b=[h])).push(o[i++]);if(b){b.sort(Wy);for(let g=0;g<b.length;g++)t(b[g],!(b[g].type instanceof Xn),s,c+g,!!a)}else t(h,!(h.type instanceof Xn),s,c,!!a)}let u,f;if(a)f=-1,u=a,a=null;else if(c<n.childCount)f=c,u=n.child(c++);else break;for(let h=0;h<l.length;h++)l[h].to<=s&&l.splice(h--,1);for(;i<o.length&&o[i].from<=s&&o[i].to>s;)l.push(o[i++]);let d=s+u.nodeSize;if(u.isText){let h=d;i<o.length&&o[i].from<h&&(h=o[i].from);for(let b=0;b<l.length;b++)l[b].to<h&&(h=l[b].to);h<d&&(a=u.cut(h-s),u=u.cut(0,h-s),d=h,f=-1)}const p=u.isInline&&!u.isLeaf?l.filter(h=>!h.inline):l.slice();r(u,p,e.forChild(s,u),s,f),s=d}}function qy(){const{view:n}=m.useContext(wt);return n&&Un.getState(n.state)}var Su={exports:{}};/*!
|
|
46
46
|
Copyright (c) 2018 Jed Watson.
|
|
47
47
|
Licensed under the MIT License (MIT), see
|
|
48
48
|
http://jedwatson.github.io/classnames
|
|
49
|
-
*/(function(n){(function(){var e={}.hasOwnProperty;function t(){for(var s="",i=0;i<arguments.length;i++){var l=arguments[i];l&&(s=o(s,r(l)))}return s}function r(s){if(typeof s=="string"||typeof s=="number")return s;if(typeof s!="object")return"";if(Array.isArray(s))return t.apply(null,s);if(s.toString!==Object.prototype.toString&&!s.toString.toString().includes("[native code]"))return s.toString();var i="";for(var l in s)e.call(s,l)&&s[l]&&(i=o(i,l));return i}function o(s,i){return i?s?s+" "+i:s+i:s}n.exports?(t.default=t,n.exports=t):window.classNames=t})()})(Su);var Hy=Su.exports;const Ky=bf(Hy);let Cu=!1;function Jy(){if(Cu)return;const n=console.error;console.error=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];const[o,s,i]=t;typeof o=="string"&&o.includes("Invalid DOM property `%s`. Did you mean `%s`?")&&s==="STYLE"&&i==="style"||n(...t)},Cu=!0}function Yy(n,e){return"STYLE"in n?"STYLE"in e?`${n.STYLE.match(/;\s*$/)?n.STYLE:`${n.STYLE}`} ${e.STYLE}`:n.STYLE:"STYLE"in e?e.STYLE:void 0}function wu(n,e){return{...n,...e,className:Ky(n.className,e.className),STYLE:Yy(n,e),style:{...n.style,...e.style}}}function Mu(n){Jy();const e={};for(const[t,r]of Object.entries(n))switch(t.toLowerCase()){case"class":{e.className=r;break}case"style":{e.STYLE=r;break}case"autocapitalize":{e.autoCapitalize=r;break}case"contenteditable":{if(r===""||r==="true"){e.contentEditable=!0;break}if(r==="false"){e.contentEditable=!1;break}if(r==="plaintext-only"){e.contentEditable="plaintext-only";break}e.contentEditable=null;break}case"draggable":{e.draggable=r!=null;break}case"enterkeyhint":{e.enterKeyHint=r;break}case"for":{e.htmlFor=r;break}case"hidden":{e.hidden=r;break}case"inputmode":{e.inputMode=r;break}case"itemprop":{e.itemProp=r;break}case"spellcheck":{if(r===""||r==="true"){e.spellCheck=!0;break}if(r==="false"){e.spellCheck=!1;break}e.spellCheck=null;break}case"tabindex":{const o=parseInt(r,10);Number.isNaN(o)||(e.tabIndex=o);break}case"autocomplete":{e.autoComplete=r;break}case"autofocus":{e.autoFocus=r!=null;break}case"formaction":{e.formAction=r;break}case"formenctype":{e.formEnctype=r;break}case"formmethod":{e.formMethod=r;break}case"formnovalidate":{e.formNoValidate=r;break}case"formtarget":{e.formTarget=r;break}case"maxlength":{const o=parseInt(r,10);Number.isNaN(o)||(e.maxLength=r);break}case"minlength":{const o=parseInt(r,10);Number.isNaN(o)||(e.minLength=r);break}case"max":{const o=parseInt(r,10);Number.isNaN(o)||(e.max=r);break}case"min":{const o=parseInt(r,10);Number.isNaN(o)||(e.min=r);break}case"multiple":{e.multiple=r!=null;break}case"readonly":{e.readOnly=r!=null;break}case"required":{e.required=r!=null;break}case"size":{const o=parseInt(r,10);Number.isNaN(o)||(e.size=r);break}case"step":{if(r==="any"){e.step=r;break}const o=parseInt(r,10);!Number.isNaN(o)&&o>0&&(e.step=r);break}case"disabled":{e.disabled=r!=null;break}case"rows":{const o=parseInt(r,10);Number.isNaN(o)||(e.rows=r);break}default:{e[t]=r;break}}return e}function Nu(n){if(!Array.isArray(n))throw new Error("@handlewithcare/react-prosemirror only supports strings and arrays in toDOM");const e=n[1];let t=1;e&&typeof e=="object"&&e.nodeType==null&&!Array.isArray(e)&&(t=2);for(let r=t;r<n.length;r++){const o=n[r];if(o===0||Nu(o))return!0}return!1}const Xs=m.memo(m.forwardRef(function(e,t){let{outputSpec:r,isMark:o,children:s,...i}=e;if(typeof r=="string")return m.createElement(m.Fragment,null,r);if(!Array.isArray(r))throw new Error("@handlewithcare/react-prosemirror only supports strings and arrays in toDOM");const a=r[0].replace(" ",":"),c=r[1];let u={ref:t,...i},f=1;c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)&&(f=2,u=wu(Mu(c),u));const d=[];for(let p=f;p<r.length;p++){const h=r[p];if(h===0){if(p<r.length-1||p>f)throw new RangeError("Content hole must be the only child of its parent node");return m.createElement(a,u,s)}d.push(m.createElement(Xs,{outputSpec:h},s))}return o&&!Nu(r)&&d.push(s),m.createElement(a,u,...d)})),Eu=m.memo(m.forwardRef(function(e,t){let{mark:r,getPos:o,children:s}=e;const{siblingsRef:i,parentRef:l}=m.useContext(Ce),a=m.useRef(void 0),c=m.useRef([]),u=m.useRef(null);m.useImperativeHandle(t,()=>u.current,[]);const f=m.useMemo(()=>{var p,h;return(h=(p=r.type.spec).toDOM)==null?void 0:h.call(p,r,!0)},[r]);if(!f)throw new Error(`Mark spec for ${r.type.name} is missing toDOM`);J(()=>{const p=i.current;return()=>{if(a.current&&p.includes(a.current)){const h=p.indexOf(a.current);p.splice(h,1)}}},[i]),J(()=>{if(!u.current)return;const p=c.current[0];a.current?(a.current.parent=l.current,a.current.spec.dom=a.current.dom=u.current,a.current.children=c.current,a.current.spec.contentDOM=a.current.contentDOM=(p==null?void 0:p.dom.parentElement)??u.current,a.current.mark=r,a.current.getPos=()=>o.current()):a.current=new Ty(l.current,c.current,()=>o.current(),r,u.current,(p==null?void 0:p.dom.parentElement)??u.current,{dom:u.current,contentDOM:(p==null?void 0:p.dom.parentElement)??u.current}),i.current.includes(a.current)||i.current.push(a.current),i.current.sort(Kt);for(const h of c.current)h.parent=a.current});const d=m.useMemo(()=>({parentRef:a,siblingsRef:c}),[c,a]);return m.createElement(Xs,{ref:u,outputSpec:f,isMark:!0},m.createElement(Ce.Provider,{value:d},s))}));function Gy(n){let{widget:e,getPos:t}=n;const{siblingsRef:r,parentRef:o}=m.useContext(Ce),s=m.useRef(null),i=m.useRef(null);return J(()=>{const l=r.current;return()=>{if(s.current&&l.includes(s.current)){const a=l.indexOf(s.current);l.splice(a,1)}}},[r]),Ke(l=>{if(!i.current)return;const a=e.type.toDOM;let c=typeof a=="function"?a(l,()=>t.current()):a;if(!e.type.spec.raw){if(c.nodeType!=1){const u=document.createElement("span");u.appendChild(c),c=u}c.contentEditable="false",c.classList.add("ProseMirror-widget")}i.current.firstElementChild!==c&&i.current.replaceChildren(c)}),J(()=>{i.current&&(s.current?(s.current.parent=o.current,s.current.widget=e,s.current.getPos=()=>t.current(),s.current.dom=i.current):s.current=new Ks(o.current,()=>t.current(),e,i.current),r.current.includes(s.current)||r.current.push(s.current),r.current.sort(Kt))}),m.createElement("span",{ref:i})}function Xy(){}function Uy(){return Xy}function Qy(){return m.useSyncExternalStore(Uy,()=>!0,()=>!1)}const Zy=m.memo(function(e){var Et;let{customNodeView:t,node:r,getPos:o,innerDeco:s,outerDeco:i}=e;const{view:l}=m.useContext(wt),a=m.useRef(null),c=m.useRef(null),u=m.useRef(null),f=m.useRef(()=>o.current()).current,d=m.useRef(r);d.current=r;const p=m.useRef(i);p.current=i;const h=m.useRef(s);h.current=s;const b=m.useRef(null),g=m.useRef(null),x=Ys(),S=Qy();J(()=>{var Yt,yn,ar;if(g.current||(g.current=t(d.current,l,f,p.current,h.current),g.current.stopEvent&&T(g.current.stopEvent.bind(g.current)),g.current.selectNode&&M(g.current.selectNode.bind(g.current),((Yt=g.current.deselectNode)==null?void 0:Yt.bind(g.current))??(()=>{})),g.current.ignoreMutation&&I(g.current.ignoreMutation.bind(g.current)),x()),!b.current)return;const{dom:Ae}=g.current;if(b.current.firstChild===Ae)return;c.current=b.current,b.current.appendChild(Ae),(l==null?void 0:l.state.selection)instanceof O&&l.state.selection.node===d.current&&((ar=(yn=g.current).selectNode)==null||ar.call(yn));const ze=g.current;return()=>{var lo;(lo=ze.destroy)==null||lo.call(ze),g.current=null}},[t,f,l]),J(()=>{if(!t||!g.current)return;const{destroy:Ae,update:ze}=g.current;if(((ze==null?void 0:ze.call(g.current,r,i,s))??!0)||(Ae==null||Ae.call(g.current),!b.current))return;g.current=t(d.current,l,f,p.current,h.current);const{dom:yn}=g.current;c.current=b.current,b.current.appendChild(yn)},[t,l,s,r,i,o,f]);const{childDescriptors:w,nodeViewDescRef:D,setStopEvent:T,setSelectNode:M,setIgnoreMutation:I}=Gs(r,f,a,c,s,i,void 0,u),z=m.useMemo(()=>({parentRef:D,siblingsRef:w}),[w,D]);if(!S)return null;g.current||(g.current=t(d.current,l,()=>o.current(),p.current,h.current),g.current.stopEvent&&T(g.current.stopEvent.bind(g.current)),g.current.selectNode&&M(g.current.selectNode.bind(g.current),((Et=g.current.deselectNode)==null?void 0:Et.bind(g.current))??(()=>{})),g.current.ignoreMutation&&I(g.current.ignoreMutation.bind(g.current)));const{contentDOM:v}=g.current;u.current=v??null;const L=m.createElement(r.isInline?"span":"div",{ref:b,contentEditable:!!v,suppressContentEditableWarning:!0},v&&Ye.createPortal(m.createElement(tr,{getPos:o,node:r,innerDecorations:s}),v)),we=m.cloneElement(i.reduce(oo,L),i.some(Ae=>Ae.type.attrs.nodeName)?{ref:a}:void 0);return m.createElement(Ce.Provider,{value:z},we)}),eb=m.createContext(null),tb=m.createContext(null),Du=m.createContext(null),nb=m.memo(function(e){let{outerDeco:t,getPos:r,node:o,innerDeco:s,...i}=e;const l=m.useRef(null),a=m.useRef(null),c=m.useRef(null),u=m.useRef(()=>r.current()).current,{nodeViews:f}=m.useContext(Jc);let d=null;const p=f[o.type.name],h=m.useMemo(()=>{var v,L;return(L=(v=o.type.spec).toDOM)==null?void 0:L.call(v,o)},[o]),{hasContentDOM:b,childDescriptors:g,setStopEvent:x,setSelectNode:S,setIgnoreMutation:w,nodeViewDescRef:D}=Gs(o,()=>r.current(),l,a,s,t,void 0,c),T={...i,...!b&&{contentEditable:!1}},M=m.useMemo(()=>({node:o,getPos:u,decorations:t,innerDecorations:s}),[u,s,o,t]);if(p?d=m.createElement(p,{...T,ref:a,nodeProps:M},m.createElement(tr,{getPos:r,node:o,innerDecorations:s})):h&&(d=m.createElement(Xs,{...T,ref:a,outputSpec:h},m.createElement(tr,{getPos:r,node:o,innerDecorations:s}))),!d)throw new Error(`Node spec for ${o.type.name} is missing toDOM`);const I=m.cloneElement(t.reduce(oo,d),t.some(v=>v.type.attrs.nodeName)?{ref:l}:void 0),z=m.useMemo(()=>({parentRef:D,siblingsRef:g}),[g,D]);return m.createElement(tb.Provider,{value:S},m.createElement(Du.Provider,{value:x},m.createElement(eb.Provider,{value:w},m.createElement(Ce.Provider,{value:z},I))))}),Ou=m.memo(function(e){let{outerDeco:t,getPos:r,node:o,innerDeco:s,...i}=e;const{view:l}=m.useContext(wt),a=l==null?void 0:l.someProp("nodeViews",c=>c==null?void 0:c[o.type.name]);return a?m.createElement(Zy,{customNodeView:a,node:o,innerDeco:s,outerDeco:t,getPos:r}):m.createElement(nb,{node:o,innerDeco:s,outerDeco:t,getPos:r,...i})});function rb(n){let{getPos:e}=n;const{siblingsRef:t,parentRef:r}=m.useContext(Ce),o=m.useRef(null),s=m.useRef(null),[i,l]=m.useState(!1);return J(()=>{const a=t.current;return()=>{if(o.current&&a.includes(o.current)){const c=a.indexOf(o.current);a.splice(c,1)}}},[t]),J(()=>{var c;const a=t.current[t.current.length-1];if((ae.safari||ae.chrome)&&((c=a==null?void 0:a.dom)==null?void 0:c.contentEditable)=="false"){l(!0);return}s.current&&(o.current?(o.current.parent=r.current,o.current.dom=s.current,o.current.getPos=()=>e.current()):o.current=new er(r.current,[],()=>e.current(),s.current,null),t.current.includes(o.current)||t.current.push(o.current),t.current.sort(Kt))}),i?m.createElement("img",{ref:s,className:"ProseMirror-separator"}):null}var Us={exports:{}},ve={};/**
|
|
49
|
+
*/(function(n){(function(){var e={}.hasOwnProperty;function t(){for(var s="",i=0;i<arguments.length;i++){var l=arguments[i];l&&(s=o(s,r(l)))}return s}function r(s){if(typeof s=="string"||typeof s=="number")return s;if(typeof s!="object")return"";if(Array.isArray(s))return t.apply(null,s);if(s.toString!==Object.prototype.toString&&!s.toString.toString().includes("[native code]"))return s.toString();var i="";for(var l in s)e.call(s,l)&&s[l]&&(i=o(i,l));return i}function o(s,i){return i?s?s+" "+i:s+i:s}n.exports?(t.default=t,n.exports=t):window.classNames=t})()})(Su);var Hy=Su.exports;const Ky=bf(Hy);let Cu=!1;function Jy(){if(Cu)return;const n=console.error;console.error=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];const[o,s,i]=t;typeof o=="string"&&o.includes("Invalid DOM property `%s`. Did you mean `%s`?")&&s==="STYLE"&&i==="style"||n(...t)},Cu=!0}function Yy(n,e){return"STYLE"in n?"STYLE"in e?`${n.STYLE.match(/;\s*$/)?n.STYLE:`${n.STYLE}`} ${e.STYLE}`:n.STYLE:"STYLE"in e?e.STYLE:void 0}function wu(n,e){return{...n,...e,className:Ky(n.className,e.className),STYLE:Yy(n,e),style:{...n.style,...e.style}}}function Mu(n){Jy();const e={};for(const[t,r]of Object.entries(n))switch(t.toLowerCase()){case"class":{e.className=r;break}case"style":{e.STYLE=r;break}case"autocapitalize":{e.autoCapitalize=r;break}case"contenteditable":{if(r===""||r==="true"){e.contentEditable=!0;break}if(r==="false"){e.contentEditable=!1;break}if(r==="plaintext-only"){e.contentEditable="plaintext-only";break}e.contentEditable=null;break}case"draggable":{e.draggable=r!=null;break}case"enterkeyhint":{e.enterKeyHint=r;break}case"for":{e.htmlFor=r;break}case"hidden":{e.hidden=r;break}case"inputmode":{e.inputMode=r;break}case"itemprop":{e.itemProp=r;break}case"spellcheck":{if(r===""||r==="true"){e.spellCheck=!0;break}if(r==="false"){e.spellCheck=!1;break}e.spellCheck=null;break}case"tabindex":{const o=parseInt(r,10);Number.isNaN(o)||(e.tabIndex=o);break}case"autocomplete":{e.autoComplete=r;break}case"autofocus":{e.autoFocus=r!=null;break}case"formaction":{e.formAction=r;break}case"formenctype":{e.formEnctype=r;break}case"formmethod":{e.formMethod=r;break}case"formnovalidate":{e.formNoValidate=r;break}case"formtarget":{e.formTarget=r;break}case"maxlength":{const o=parseInt(r,10);Number.isNaN(o)||(e.maxLength=r);break}case"minlength":{const o=parseInt(r,10);Number.isNaN(o)||(e.minLength=r);break}case"max":{const o=parseInt(r,10);Number.isNaN(o)||(e.max=r);break}case"min":{const o=parseInt(r,10);Number.isNaN(o)||(e.min=r);break}case"multiple":{e.multiple=r!=null;break}case"readonly":{e.readOnly=r!=null;break}case"required":{e.required=r!=null;break}case"size":{const o=parseInt(r,10);Number.isNaN(o)||(e.size=r);break}case"step":{if(r==="any"){e.step=r;break}const o=parseInt(r,10);!Number.isNaN(o)&&o>0&&(e.step=r);break}case"disabled":{e.disabled=r!=null;break}case"rows":{const o=parseInt(r,10);Number.isNaN(o)||(e.rows=r);break}default:{e[t]=r;break}}return e}function Nu(n){if(!Array.isArray(n))throw new Error("@handlewithcare/react-prosemirror only supports strings and arrays in toDOM");const e=n[1];let t=1;e&&typeof e=="object"&&e.nodeType==null&&!Array.isArray(e)&&(t=2);for(let r=t;r<n.length;r++){const o=n[r];if(o===0||Nu(o))return!0}return!1}const Xs=m.memo(m.forwardRef(function(e,t){let{outputSpec:r,isMark:o,children:s,...i}=e;if(typeof r=="string")return m.createElement(m.Fragment,null,r);if(!Array.isArray(r))throw new Error("@handlewithcare/react-prosemirror only supports strings and arrays in toDOM");const a=r[0].replace(" ",":"),c=r[1];let u={ref:t,...i},f=1;c&&typeof c=="object"&&c.nodeType==null&&!Array.isArray(c)&&(f=2,u=wu(Mu(c),u));const d=[];for(let p=f;p<r.length;p++){const h=r[p];if(h===0){if(p<r.length-1||p>f)throw new RangeError("Content hole must be the only child of its parent node");return m.createElement(a,u,s)}d.push(m.createElement(Xs,{outputSpec:h},s))}return o&&!Nu(r)&&d.push(s),m.createElement(a,u,...d)})),Eu=m.memo(m.forwardRef(function(e,t){let{mark:r,getPos:o,children:s}=e;const{siblingsRef:i,parentRef:l}=m.useContext(Ce),a=m.useRef(void 0),c=m.useRef([]),u=m.useRef(null);m.useImperativeHandle(t,()=>u.current,[]);const f=m.useMemo(()=>{var p,h;return(h=(p=r.type.spec).toDOM)==null?void 0:h.call(p,r,!0)},[r]);if(!f)throw new Error(`Mark spec for ${r.type.name} is missing toDOM`);J(()=>{const p=i.current;return()=>{if(a.current&&p.includes(a.current)){const h=p.indexOf(a.current);p.splice(h,1)}}},[i]),J(()=>{if(!u.current)return;const p=c.current[0];a.current?(a.current.parent=l.current,a.current.spec.dom=a.current.dom=u.current,a.current.children=c.current,a.current.spec.contentDOM=a.current.contentDOM=(p==null?void 0:p.dom.parentElement)??u.current,a.current.mark=r,a.current.getPos=()=>o.current()):a.current=new Ty(l.current,c.current,()=>o.current(),r,u.current,(p==null?void 0:p.dom.parentElement)??u.current,{dom:u.current,contentDOM:(p==null?void 0:p.dom.parentElement)??u.current}),i.current.includes(a.current)||i.current.push(a.current),i.current.sort(Kt);for(const h of c.current)h.parent=a.current});const d=m.useMemo(()=>({parentRef:a,siblingsRef:c}),[c,a]);return m.createElement(Xs,{ref:u,outputSpec:f,isMark:!0},m.createElement(Ce.Provider,{value:d},s))}));function Gy(n){let{widget:e,getPos:t}=n;const{siblingsRef:r,parentRef:o}=m.useContext(Ce),s=m.useRef(null),i=m.useRef(null);return J(()=>{const l=r.current;return()=>{if(s.current&&l.includes(s.current)){const a=l.indexOf(s.current);l.splice(a,1)}}},[r]),Ke(l=>{if(!i.current)return;const a=e.type.toDOM;let c=typeof a=="function"?a(l,()=>t.current()):a;if(!e.type.spec.raw){if(c.nodeType!=1){const u=document.createElement("span");u.appendChild(c),c=u}c.contentEditable="false",c.classList.add("ProseMirror-widget")}i.current.firstElementChild!==c&&i.current.replaceChildren(c)}),J(()=>{i.current&&(s.current?(s.current.parent=o.current,s.current.widget=e,s.current.getPos=()=>t.current(),s.current.dom=i.current):s.current=new Ks(o.current,()=>t.current(),e,i.current),r.current.includes(s.current)||r.current.push(s.current),r.current.sort(Kt))}),m.createElement("span",{ref:i})}function Xy(){}function Uy(){return Xy}function Qy(){return m.useSyncExternalStore(Uy,()=>!0,()=>!1)}const Zy=m.memo(function(e){var Et;let{customNodeView:t,node:r,getPos:o,innerDeco:s,outerDeco:i}=e;const{view:l}=m.useContext(wt),a=m.useRef(null),c=m.useRef(null),u=m.useRef(null),f=m.useRef(()=>o.current()).current,d=m.useRef(r);d.current=r;const p=m.useRef(i);p.current=i;const h=m.useRef(s);h.current=s;const b=m.useRef(null),g=m.useRef(null),x=Ys(),S=Qy();J(()=>{var Yt,yn,ar;if(g.current||(g.current=t(d.current,l,f,p.current,h.current),g.current.stopEvent&&T(g.current.stopEvent.bind(g.current)),g.current.selectNode&&M(g.current.selectNode.bind(g.current),((Yt=g.current.deselectNode)==null?void 0:Yt.bind(g.current))??(()=>{})),g.current.ignoreMutation&&I(g.current.ignoreMutation.bind(g.current)),x()),!b.current)return;const{dom:Ae}=g.current;if(b.current.firstChild===Ae)return;c.current=b.current,b.current.appendChild(Ae),(l==null?void 0:l.state.selection)instanceof v&&l.state.selection.node===d.current&&((ar=(yn=g.current).selectNode)==null||ar.call(yn));const ze=g.current;return()=>{var lo;(lo=ze.destroy)==null||lo.call(ze),g.current=null}},[t,f,l]),J(()=>{if(!t||!g.current)return;const{destroy:Ae,update:ze}=g.current;if(((ze==null?void 0:ze.call(g.current,r,i,s))??!0)||(Ae==null||Ae.call(g.current),!b.current))return;g.current=t(d.current,l,f,p.current,h.current);const{dom:yn}=g.current;c.current=b.current,b.current.appendChild(yn)},[t,l,s,r,i,o,f]);const{childDescriptors:w,nodeViewDescRef:D,setStopEvent:T,setSelectNode:M,setIgnoreMutation:I}=Gs(r,f,a,c,s,i,void 0,u),z=m.useMemo(()=>({parentRef:D,siblingsRef:w}),[w,D]);if(!S)return null;g.current||(g.current=t(d.current,l,()=>o.current(),p.current,h.current),g.current.stopEvent&&T(g.current.stopEvent.bind(g.current)),g.current.selectNode&&M(g.current.selectNode.bind(g.current),((Et=g.current.deselectNode)==null?void 0:Et.bind(g.current))??(()=>{})),g.current.ignoreMutation&&I(g.current.ignoreMutation.bind(g.current)));const{contentDOM:O}=g.current;u.current=O??null;const L=m.createElement(r.isInline?"span":"div",{ref:b,contentEditable:!!O,suppressContentEditableWarning:!0},O&&Ye.createPortal(m.createElement(tr,{getPos:o,node:r,innerDecorations:s}),O)),we=m.cloneElement(i.reduce(oo,L),i.some(Ae=>Ae.type.attrs.nodeName)?{ref:a}:void 0);return m.createElement(Ce.Provider,{value:z},we)}),eb=m.createContext(null),tb=m.createContext(null),Du=m.createContext(null),nb=m.memo(function(e){let{outerDeco:t,getPos:r,node:o,innerDeco:s,...i}=e;const l=m.useRef(null),a=m.useRef(null),c=m.useRef(null),u=m.useRef(()=>r.current()).current,{nodeViews:f}=m.useContext(Jc);let d=null;const p=f[o.type.name],h=m.useMemo(()=>{var O,L;return(L=(O=o.type.spec).toDOM)==null?void 0:L.call(O,o)},[o]),{hasContentDOM:b,childDescriptors:g,setStopEvent:x,setSelectNode:S,setIgnoreMutation:w,nodeViewDescRef:D}=Gs(o,()=>r.current(),l,a,s,t,void 0,c),T={...i,...!b&&{contentEditable:!1}},M=m.useMemo(()=>({node:o,getPos:u,decorations:t,innerDecorations:s}),[u,s,o,t]);if(p?d=m.createElement(p,{...T,ref:a,nodeProps:M},m.createElement(tr,{getPos:r,node:o,innerDecorations:s})):h&&(d=m.createElement(Xs,{...T,ref:a,outputSpec:h},m.createElement(tr,{getPos:r,node:o,innerDecorations:s}))),!d)throw new Error(`Node spec for ${o.type.name} is missing toDOM`);const I=m.cloneElement(t.reduce(oo,d),t.some(O=>O.type.attrs.nodeName)?{ref:l}:void 0),z=m.useMemo(()=>({parentRef:D,siblingsRef:g}),[g,D]);return m.createElement(tb.Provider,{value:S},m.createElement(Du.Provider,{value:x},m.createElement(eb.Provider,{value:w},m.createElement(Ce.Provider,{value:z},I))))}),vu=m.memo(function(e){let{outerDeco:t,getPos:r,node:o,innerDeco:s,...i}=e;const{view:l}=m.useContext(wt),a=l==null?void 0:l.someProp("nodeViews",c=>c==null?void 0:c[o.type.name]);return a?m.createElement(Zy,{customNodeView:a,node:o,innerDeco:s,outerDeco:t,getPos:r}):m.createElement(nb,{node:o,innerDeco:s,outerDeco:t,getPos:r,...i})});function rb(n){let{getPos:e}=n;const{siblingsRef:t,parentRef:r}=m.useContext(Ce),o=m.useRef(null),s=m.useRef(null),[i,l]=m.useState(!1);return J(()=>{const a=t.current;return()=>{if(o.current&&a.includes(o.current)){const c=a.indexOf(o.current);a.splice(c,1)}}},[t]),J(()=>{var c;const a=t.current[t.current.length-1];if((ae.safari||ae.chrome)&&((c=a==null?void 0:a.dom)==null?void 0:c.contentEditable)=="false"){l(!0);return}s.current&&(o.current?(o.current.parent=r.current,o.current.dom=s.current,o.current.getPos=()=>e.current()):o.current=new er(r.current,[],()=>e.current(),s.current,null),t.current.includes(o.current)||t.current.push(o.current),t.current.sort(Kt))}),i?m.createElement("img",{ref:s,className:"ProseMirror-separator"}):null}var Us={exports:{}},Oe={};/**
|
|
50
50
|
* @license React
|
|
51
51
|
* react-reconciler-reflection.production.js
|
|
52
52
|
*
|
|
@@ -54,7 +54,7 @@ Check the top-level render call using <`+k+">."),A}var w=m,D=Symbol.for("react.t
|
|
|
54
54
|
*
|
|
55
55
|
* This source code is licensed under the MIT license found in the
|
|
56
56
|
* LICENSE file in the root directory of this source tree.
|
|
57
|
-
*/var
|
|
57
|
+
*/var Ou;function ob(){if(Ou)return Oe;Ou=1;function n(i){var l="https://react.dev/errors/"+i;if(1<arguments.length){l+="?args[]="+encodeURIComponent(arguments[1]);for(var a=2;a<arguments.length;a++)l+="&args[]="+encodeURIComponent(arguments[a])}return"Minified React error #"+i+"; visit "+l+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function e(i){var l=i,a=i;if(i.alternate)for(;l.return;)l=l.return;else{i=l;do l=i,l.flags&4098&&(a=l.return),i=l.return;while(i)}return l.tag===3?a:null}function t(i){if(e(i)!==i)throw Error(n(188))}function r(i){var l=i.alternate;if(!l){if(l=e(i),l===null)throw Error(n(188));return l!==i?null:i}for(var a=i,c=l;;){var u=a.return;if(u===null)break;var f=u.alternate;if(f===null){if(c=u.return,c!==null){a=c;continue}break}if(u.child===f.child){for(f=u.child;f;){if(f===a)return t(u),i;if(f===c)return t(u),l;f=f.sibling}throw Error(n(188))}if(a.return!==c.return)a=u,c=f;else{for(var d=!1,p=u.child;p;){if(p===a){d=!0,a=u,c=f;break}if(p===c){d=!0,c=u,a=f;break}p=p.sibling}if(!d){for(p=f.child;p;){if(p===a){d=!0,a=f,c=u;break}if(p===c){d=!0,c=f,a=u;break}p=p.sibling}if(!d)throw Error(n(189))}}if(a.alternate!==c)throw Error(n(190))}if(a.tag!==3)throw Error(n(188));return a.stateNode.current===a?i:l}function o(i){var l=i.tag;if(l===5||l===26||l===27||l===6)return i;for(i=i.child;i!==null;){if(l=o(i),l!==null)return l;i=i.sibling}return null}function s(i){var l=i.tag;if(l===5||l===26||l===27||l===6)return i;for(i=i.child;i!==null;){if(i.tag!==4&&(l=s(i),l!==null))return l;i=i.sibling}return null}return Oe.doesFiberContain=function(i,l){for(var a=i.alternate;l!==null;){if(l===i||l===a)return!0;l=l.return}return!1},Oe.findCurrentFiberUsingSlowPath=r,Oe.findCurrentHostFiber=function(i){return i=r(i),i!==null?o(i):null},Oe.findCurrentHostFiberWithNoPortals=function(i){return i=r(i),i!==null?s(i):null},Oe.getContainerFromFiber=function(i){return i.tag===3?i.stateNode.containerInfo:null},Oe.getNearestMountedFiber=e,Oe.getSuspenseInstanceFromFiber=function(i){if(i.tag===13){var l=i.memoizedState;if(l===null&&(i=i.alternate,i!==null&&(l=i.memoizedState)),l!==null)return l.dehydrated}return null},Oe.isFiberMounted=function(i){return e(i)===i},Oe.isFiberSuspenseAndTimedOut=function(i){var l=i.memoizedState;return i.tag===13&&l!==null&&l.dehydrated===null},Oe.isMounted=function(i){return(i=i._reactInternals)?e(i)===i:!1},Oe}var Te={};/**
|
|
58
58
|
* @license React
|
|
59
59
|
* react-reconciler-reflection.development.js
|
|
60
60
|
*
|
|
@@ -62,5 +62,5 @@ Check the top-level render call using <`+k+">."),A}var w=m,D=Symbol.for("react.t
|
|
|
62
62
|
*
|
|
63
63
|
* This source code is licensed under the MIT license found in the
|
|
64
64
|
* LICENSE file in the root directory of this source tree.
|
|
65
|
-
*/var Tu;function sb(){return Tu||(Tu=1,process.env.NODE_ENV!=="production"&&function(){function n(s){var i=s,l=s;if(s.alternate)for(;i.return;)i=i.return;else{s=i;do i=s,i.flags&4098&&(l=i.return),s=i.return;while(s)}return i.tag===3?l:null}function e(s){if(n(s)!==s)throw Error("Unable to find node on an unmounted component.")}function t(s){var i=s.alternate;if(!i){if(i=n(s),i===null)throw Error("Unable to find node on an unmounted component.");return i!==s?null:s}for(var l=s,a=i;;){var c=l.return;if(c===null)break;var u=c.alternate;if(u===null){if(a=c.return,a!==null){l=a;continue}break}if(c.child===u.child){for(u=c.child;u;){if(u===l)return e(c),s;if(u===a)return e(c),i;u=u.sibling}throw Error("Unable to find node on an unmounted component.")}if(l.return!==a.return)l=c,a=u;else{for(var f=!1,d=c.child;d;){if(d===l){f=!0,l=c,a=u;break}if(d===a){f=!0,a=c,l=u;break}d=d.sibling}if(!f){for(d=u.child;d;){if(d===l){f=!0,l=u,a=c;break}if(d===a){f=!0,a=u,l=c;break}d=d.sibling}if(!f)throw Error("Child was not found in either parent set. This indicates a bug in React related to the return pointer. Please file an issue.")}}if(l.alternate!==a)throw Error("Return fibers should always be each others' alternates. This error is likely caused by a bug in React. Please file an issue.")}if(l.tag!==3)throw Error("Unable to find node on an unmounted component.");return l.stateNode.current===l?s:i}function r(s){var i=s.tag;if(i===5||i===26||i===27||i===6)return s;for(s=s.child;s!==null;){if(i=r(s),i!==null)return i;s=s.sibling}return null}function o(s){var i=s.tag;if(i===5||i===26||i===27||i===6)return s;for(s=s.child;s!==null;){if(s.tag!==4&&(i=o(s),i!==null))return i;s=s.sibling}return null}Te.doesFiberContain=function(s,i){for(var l=s.alternate;i!==null;){if(i===s||i===l)return!0;i=i.return}return!1},Te.findCurrentFiberUsingSlowPath=t,Te.findCurrentHostFiber=function(s){return s=t(s),s!==null?r(s):null},Te.findCurrentHostFiberWithNoPortals=function(s){return s=t(s),s!==null?o(s):null},Te.getContainerFromFiber=function(s){return s.tag===3?s.stateNode.containerInfo:null},Te.getNearestMountedFiber=n,Te.getSuspenseInstanceFromFiber=function(s){if(s.tag===13){var i=s.memoizedState;if(i===null&&(s=s.alternate,s!==null&&(i=s.memoizedState)),i!==null)return i.dehydrated}return null},Te.isFiberMounted=function(s){return n(s)===s},Te.isFiberSuspenseAndTimedOut=function(s){var i=s.memoizedState;return s.tag===13&&i!==null&&i.dehydrated===null},Te.isMounted=function(s){return(s=s._reactInternals)?n(s)===s:!1}}()),Te}process.env.NODE_ENV==="production"?Us.exports=ob():Us.exports=sb();var ib=Us.exports;function lb(n){return n._reactInternals}function P0(n){return n}function ab(n){const e=lb(n);if(e===void 0){if(typeof n.render=="function")throw new Error("Unable to find node on an unmounted component.");{const r=Object.keys(n).join(",");throw new Error(`Argument appears to not be a ReactComponent. Keys: ${r}`)}}const t=ib.findCurrentHostFiber(e);return t===null?null:t.stateNode}function cb(n){return ab(n)}function ub(n,e){if(n===e)return!0;if(!n||!e)return!1;const t=Object.keys(n),r=Object.keys(e),o=t.length;if(r.length!==o)return!1;for(let s=0;s<o;s++){const i=t[s];if(n[i]!==e[i]||!Object.prototype.hasOwnProperty.call(e,i))return!1}return!0}class fb extends m.Component{constructor(){super(...arguments);j(this,"viewDescRef",null);j(this,"renderRef",null)}updateEffect(){const{view:t,decorations:r,siblingsRef:o,parentRef:s,getPos:i,node:l}=this.props,a=cb(this);if(!a){if(!(t!=null&&t.composing))return;this.viewDescRef=new ro(s.current,()=>i.current(),document.createElement("div"),document.createTextNode(l.text??""),l.text??"");return}let c=a;for(;c.firstChild;)c=c.firstChild;!this.viewDescRef||this.viewDescRef instanceof ro?this.viewDescRef=new Ay(void 0,[],()=>i.current(),l,r,H.empty,a,c):(this.viewDescRef.parent=s.current,this.viewDescRef.children=[],this.viewDescRef.node=l,this.viewDescRef.getPos=()=>i.current(),this.viewDescRef.outerDeco=r,this.viewDescRef.innerDeco=H.empty,this.viewDescRef.dom=a,this.viewDescRef.dom.pmViewDesc=this.viewDescRef,this.viewDescRef.nodeDOM=c),o.current.includes(this.viewDescRef)||o.current.push(this.viewDescRef),o.current.sort(Kt)}shouldComponentUpdate(t){return!ub(this.props,t)}componentDidMount(){this.updateEffect()}componentDidUpdate(){this.updateEffect()}componentWillUnmount(){const{siblingsRef:t}=this.props;if(this.viewDescRef&&t.current.includes(this.viewDescRef)){const r=t.current.indexOf(this.viewDescRef);t.current.splice(r,1)}}render(){const{view:t,getPos:r,node:o,decorations:s}=this.props;return t!=null&&t.composing&&t.state.selection.from>=r.current()&&t.state.selection.from<=r.current()+o.nodeSize?this.renderRef:(this.renderRef=s.reduce(oo,o.text),this.renderRef)}}function db(n){let{getPos:e}=n;const{siblingsRef:t,parentRef:r}=m.useContext(Ce),o=m.useRef(null),s=m.useRef(null);return J(()=>{const i=t.current;return()=>{if(o.current&&i.includes(o.current)){const l=i.indexOf(o.current);i.splice(l,1)}}},[t]),J(()=>{s.current&&(o.current?(o.current.parent=r.current,o.current.dom=s.current,o.current.getPos=()=>e.current()):o.current=new er(r.current,[],()=>e.current(),s.current,null),t.current.includes(o.current)||t.current.push(o.current),t.current.sort(Kt))}),m.createElement("br",{ref:s,className:"ProseMirror-trailingBreak"})}function hb(n){let{widget:e,getPos:t}=n;const{siblingsRef:r,parentRef:o}=m.useContext(Ce),s=m.useRef(null),i=m.useRef(()=>t.current()).current,l=m.useRef(null);J(()=>{const c=r.current;return()=>{if(s.current&&c.includes(s.current)){const u=c.indexOf(s.current);c.splice(u,1)}}},[r]),J(()=>{l.current&&(s.current?(s.current.parent=o.current,s.current.widget=e,s.current.getPos=()=>t.current(),s.current.dom=l.current):s.current=new Ks(o.current,()=>t.current(),e,l.current),r.current.includes(s.current)||r.current.push(s.current),r.current.sort(Kt))});const{Component:a}=e.type;return a&&m.createElement(a,{ref:l,widget:e,getPos:i,contentEditable:!1})}function oo(n,e){const{nodeName:t,...r}=e.type.attrs,o=Mu(r);return t||typeof n=="string"?m.createElement(t??"span",o,n):m.cloneElement(n,wu(n.props,o))}function Qs(n,e){var t,r,o;return n.type===e.type&&n.marks.every(s=>s.isInSet(e.marks))&&e.marks.every(s=>s.isInSet(n.marks))&&n.key===e.key&&(n.type==="node"?((t=n.outerDeco)==null?void 0:t.length)===((r=e.outerDeco)==null?void 0:r.length)&&((o=n.outerDeco)==null?void 0:o.every(s=>{var i;return(i=e.outerDeco)==null?void 0:i.some(l=>s.from===l.from&&s.to&&l.to&&s.type.eq(l.type))}))&&n.innerDeco.eq(e.innerDeco):!0)&&n.node===e.node&&n.widget===e.widget}const pb=m.memo(function(e){let{child:t,getInnerPos:r}=e;const{view:o}=m.useContext(wt),s=m.useRef(()=>r.current()+t.offset);return s.current=()=>r.current()+t.offset,t.type==="widget"?m.createElement(hb,{key:t.key,widget:t.widget,getPos:s}):t.type==="native-widget"?m.createElement(Gy,{key:t.key,widget:t.widget,getPos:s}):t.node.isText?m.createElement(Ce.Consumer,{key:t.key},i=>{let{siblingsRef:l,parentRef:a}=i;return m.createElement(fb,{view:o,node:t.node,getPos:s,siblingsRef:l,parentRef:a,decorations:t.outerDeco})}):m.createElement(Ou,{key:t.key,node:t.node,getPos:s,outerDeco:t.outerDeco,innerDeco:t.innerDeco})}),mb=m.memo(function(e){let{childViews:t,getInnerPos:r}=e;const o=t[0],s=m.useRef(()=>r.current()+o.offset);s.current=()=>r.current()+o.offset;const i=o.marks[0];return i?m.createElement(Eu,{getPos:s,key:o.key,mark:i},m.createElement(Zs,{key:o.key,getInnerPos:r,childViews:t.map(l=>({...l,marks:l.marks.slice(1)}))})):m.createElement(m.Fragment,null,t.map(l=>m.createElement(pb,{key:l.key,child:l,getInnerPos:r})))}),Zs=m.memo(function(e){let{getInnerPos:t,childViews:r}=e;const o=r.reduce((s,i)=>{var c;const l=s[s.length-1];if(!l)return[[i]];const a=l[l.length-1];return a?!i.marks.length&&!a.marks.length||i.marks.length&&a.marks.length&&((c=i.marks[0])!=null&&c.eq(a.marks[0]))?[...s.slice(0,s.length-1),[...l.slice(0,l.length),i]]:[...s,[i]]:[...s.slice(0,s.length),[i]]},[]);return m.createElement(m.Fragment,null,o.map(s=>{const i=s[0];return i?m.createElement(mb,{key:i.key,childViews:s,getInnerPos:t}):null}))});function ei(n,e,t,r,o,s){const i=n+e,l=r==null?void 0:r.get(i);if(t==="widget"||t==="native-widget")return o.type.spec.key?o.type.spec.key:(console.warn(`Widget at position ${i} doesn't have a key specified. This may cause issues.`),`${l}-${s}`);if(l)return l;const a=n-1,c=r==null?void 0:r.get(a);return c?`${c}-${e}`:i}function gb(n,e){if(!e||e.widget.type.side>=0||!n||!n.node.isInline)return;const t=n.marks;e.marks=e.marks.reduce((r,o)=>o.addToSet(r),t)}function yb(n,e){if(!e.node.isInline)return;const t=e.marks;for(let r=n.length-1;r>=0;r--){const o=n[r];o.widget.type.side<0||(o.marks=o.marks.reduce((s,i)=>i.addToSet(s),t))}}const bb=m.memo(function(e){let{child:t,getInnerPos:r}=e;const o=m.useRef(()=>r.current()+t.offset);return o.current=()=>r.current()+t.offset,t.type==="node"?t.marks.reduce((s,i)=>m.createElement(Eu,{getPos:o,mark:i},s),m.createElement(Ou,{key:t.key,outerDeco:t.outerDeco,node:t.node,innerDeco:t.innerDeco,getPos:o})):m.createElement(Zs,{key:t.key,childViews:[t],getInnerPos:r})});function xb(n,e){return n.length?n.every(t=>t.type!=="node"||t.node.isInline)?[m.createElement(Zs,{key:n[0].key,childViews:n,getInnerPos:e})]:n.map(t=>m.createElement(bb,{key:t.key,child:t,getInnerPos:e})):[]}const tr=m.memo(function(e){let{getPos:t,node:r,innerDecorations:o}=e;const s=qy(),i=m.useRef(()=>t.current()+1),l=m.useRef(new Map).current;if(!r)return null;const a=new Set;let c=[],u=null;_y(r,o,(h,b,g,x)=>{const S=h.type.spec.marks??[];let w;if(b){w=ei(i.current(),g,"native-widget",s==null?void 0:s.posToKey,h,x);const T={type:"native-widget",widget:h,marks:S,offset:g,index:x,key:w},M=l.get(w);M&&Qs(M,T)?M.offset=g:l.set(w,T),a.add(w)}else{w=ei(i.current(),g,"widget",s==null?void 0:s.posToKey,h,x);const T={type:"widget",widget:h,marks:S,offset:g,index:x,key:w},M=l.get(w);M&&Qs(M,T)?M.offset=g:l.set(w,T),a.add(w)}const D=l.get(w);c.push(D),gb(u,l.get(w))},(h,b,g,x)=>{const S=ei(i.current(),x,"node",s==null?void 0:s.posToKey),w={type:"node",node:h,marks:h.marks,innerDeco:g,outerDeco:b,offset:x,key:S},D=l.get(S);D&&Qs(D,w)?(D.offset=x,u=D):(l.set(S,w),u=w),a.add(S),yb(c,u),c=[]});for(const h of l.keys())a.has(h)||l.delete(h);const f=Array.from(l.values()).sort((h,b)=>h.offset-b.offset),d=xb(f,i),p=f[f.length-1];return(!p||p.type!=="node"||p.node.isInline&&!p.node.isText||/\n$/.test(p.node.text))&&d.push(m.createElement(rb,{getPos:i,key:"trailing-hack-img"}),m.createElement(db,{getPos:i,key:"trailing-hack-br"})),m.createElement(m.Fragment,null,d)}),ti={current(){return-1}},kb=m.memo(m.forwardRef(function(e,t){let{className:r,node:o,innerDeco:s,outerDeco:i,as:l,viewDesc:a,...c}=e;const u=m.useRef(null);m.useImperativeHandle(t,()=>u.current,[]);const{childDescriptors:f,nodeViewDescRef:d}=Gs(o,()=>ti.current(),u,u,s,i,a),p=m.useMemo(()=>({parentRef:d,siblingsRef:f}),[f,d]),h={...c,ref:u,className:r,suppressContentEditableWarning:!0},b=l?m.cloneElement(l,h,m.createElement(Ce.Provider,{value:p},m.createElement(tr,{getPos:ti,node:o,innerDecorations:s}))):m.createElement("div",h,m.createElement(Ce.Provider,{value:p},m.createElement(tr,{getPos:ti,node:o,innerDecorations:s})));if(!o)return b;const g=i.filter(S=>!S.inline);return g.length?g.reduce(oo,b):b})),Au=m.createContext(null);function Sb(n,e){let{as:t,...r}=n;const o=m.useRef([]),s=m.useRef(null),{setMount:i,...l}=m.useContext(Au),a=m.useRef(void 0);m.useImperativeHandle(e,()=>s.current,[]);const c=m.useMemo(()=>({parentRef:a,siblingsRef:o}),[o,a]);return m.createElement(Ce.Provider,{value:c},m.createElement(kb,{ref:u=>{s.current=u,i(u)},...r,...l,as:t}))}const Pu=m.forwardRef(Sb),Cb=[];function wb(n){var h;let{className:e,children:t,nodeViews:r,customNodeViews:o,...s}=n;const[i,l]=m.useState(null),{editor:a,state:c}=Fy(i,{...s,nodeViews:o}),u=a.view?oy(a.view,a.cursorWrapper):H.empty,f=a.view?ey(a.view):Cb,d=m.useMemo(()=>({nodeViews:r??{}}),[r]),p=m.useMemo(()=>{var b;return{className:e,setMount:l,node:(b=a.view)==null?void 0:b.state.doc,innerDeco:u,outerDeco:f,viewDesc:a.docViewDescRef.current}},[e,a.docViewDescRef,(h=a.view)==null?void 0:h.state.doc,u,f]);return m.createElement(wt.Provider,{value:a},m.createElement(Zg.Provider,{value:c},m.createElement(Jc.Provider,{value:d},m.createElement(Au.Provider,{value:p},t))))}function Iu(n){return m.createElement(Ly,null,m.createElement(wb,n))}function re(n){const e=m.useRef(n),{view:t}=m.useContext(wt);return Ke(()=>{e.current=n},[n]),m.useCallback(function(){for(var r=arguments.length,o=new Array(r),s=0;s<r;s++)o[s]=arguments[s];return e.current(t,...o)},[t])}function Vu(n){const e=m.useContext(Du),t=re(n);Ke(()=>{e(t)},[e,t])}const Ru=n=>[Qg(),Ro({Tab:Lc(1),"Shift-Tab":Lc(-1)}),gm(n.schema),Ro(um(n.schema)),Ro(Yd),Gd({color:"#F00",width:2}),Vp(),wd(),ym(n),py()],Mb=["p",0],Nb=["blockquote",0],Eb=["hr"],Db=["pre",["code",0]],Ob=["br"],vb={doc:{content:"block+"},paragraph:{content:"inline*",group:"block",parseDOM:[{tag:"p"}],toDOM(){return Mb}},blockquote:{content:"block+",group:"block",defining:!0,parseDOM:[{tag:"blockquote"}],toDOM(){return Nb}},horizontal_rule:{group:"block",parseDOM:[{tag:"hr"}],toDOM(){return Eb}},heading:{attrs:{level:{default:1,validate:"number"}},content:"inline*",group:"block",defining:!0,parseDOM:[{tag:"h1",attrs:{level:1}},{tag:"h2",attrs:{level:2}},{tag:"h3",attrs:{level:3}},{tag:"h4",attrs:{level:4}},{tag:"h5",attrs:{level:5}},{tag:"h6",attrs:{level:6}}],toDOM(n){return["h"+n.attrs.level,0]}},code_block:{content:"text*",marks:"",group:"block",code:!0,defining:!0,parseDOM:[{tag:"pre",preserveWhitespace:"full"}],toDOM(){return Db}},text:{group:"inline"},image:{inline:!0,attrs:{src:{validate:"string"},alt:{default:null,validate:"string|null"},title:{default:null,validate:"string|null"}},group:"inline",draggable:!0,parseDOM:[{tag:"img[src]",getAttrs(n){return{src:n.getAttribute("src"),title:n.getAttribute("title"),alt:n.getAttribute("alt")}}}],toDOM(n){let{src:e,alt:t,title:r}=n.attrs;return["img",{src:e,alt:t,title:r}]}},hard_break:{inline:!0,group:"inline",selectable:!1,parseDOM:[{tag:"br"}],toDOM(){return Ob}}},Tb=["em",0],Ab=["strong",0],Pb=["code",0],Ib={link:{attrs:{href:{validate:"string"},title:{default:null,validate:"string|null"}},inclusive:!1,parseDOM:[{tag:"a[href]",getAttrs(n){return{href:n.getAttribute("href"),title:n.getAttribute("title")}}}],toDOM(n){let{href:e,title:t}=n.attrs;return["a",{href:e,title:t},0]}},em:{parseDOM:[{tag:"i"},{tag:"em"},{style:"font-style=italic"},{style:"font-style=normal",clearMark:n=>n.type.name=="em"}],toDOM(){return Tb}},strong:{parseDOM:[{tag:"strong"},{tag:"b",getAttrs:n=>n.style.fontWeight!="normal"&&null},{style:"font-weight=400",clearMark:n=>n.type.name=="strong"},{style:"font-weight",getAttrs:n=>/^(bold(er)?|[5-9]\d{2,})$/.test(n)&&null}],toDOM(){return Ab}},code:{code:!0,parseDOM:[{tag:"code"}],toDOM(){return Pb}}},zu=new xr({nodes:vb,marks:Ib}),$u=zu.spec.marks.append({underline:{parseDOM:[{tag:"u"},{style:"font-style=underline"}],toDOM(){return["u",0]}},strikethrough:{parseDOM:[{tag:"s"},{style:"font-style=strike"},{style:"font-style=strikethrough"}],toDOM(){return["s",0]}}}),so="https://dailytelefrag.ru/api",ni="https://dailytelefrag.ru/error_image.png",ri="https://dailytelefrag.ru/error_embed.png",nr=(n,e)=>{try{const t=new URL(n);if(t.hostname!=="vkvideo.ru"&&t.hostname!=="vk.com")throw new Error;let r,o;if(t.pathname==="/video_ext.php")r=t.searchParams.get("id"),o=t.searchParams.get("oid");else if(t.pathname.startsWith("/video"))[o,r]=t.pathname.slice(6).split("_");else throw new Error;if(!r||!o)throw new Error;return e?`https://vkvideo.ru/video_ext.php?oid=${o}&id=${r}&hd=2`:!0}catch{return e?"":!1}},rr=(n,e)=>{try{const t=new URL(n);if(t.hostname!=="rutube.ru")throw new Error;let r;if(t.pathname.startsWith("/video/"))r=t.pathname.split("/")[2];else if(t.pathname.startsWith("/play/embed/"))r=t.pathname.split("/")[3];else throw new Error;if(!r)throw new Error;return e?`https://rutube.ru/play/embed/${r}`:!0}catch{return e?"":!1}},or=(n,e)=>{try{const t=new URL(n);if(t.hostname!=="youtube.com"&&t.hostname!=="www.youtube.com"&&t.hostname!=="youtu.be")throw new Error;if(t.hostname==="youtu.be")return e?`https://youtube.com/embed${t.pathname}`:!0;let r;if(t.pathname==="/watch")r=t.searchParams.get("v");else if(t.pathname.startsWith("/live/"))r=t.pathname.split("/")[2];else if(t.pathname.startsWith("/embed/"))r=t.pathname.split("/")[2];else throw new Error;if(!r)throw new Error;return e?`https://youtube.com/embed/${r}`:!0}catch{return e?"":!1}},oi=n=>{try{const e=new URL(n);switch(e.hostname){case"vkvideo.ru":case"vk.com":return nr(e,!0)+"";case"rutube.ru":return rr(e,!0)+"";case"youtube.com":case"www.youtube.com":case"youtu.be":return or(e,!0)+"";default:throw new Error}}catch{return""}},Vb={atom:!0,attrs:{fid:{default:null,validate:"string|null|number"},src:{default:null,validate:"string|null"},alt:{default:null,validate:"string|null"},title:{default:null,validate:"string|null"}},group:"block",parseDOM:[{tag:"img[src]",getAttrs(n){return{fid:n.getAttribute("fid"),src:n.getAttribute("src"),alt:n.getAttribute("alt"),title:n.getAttribute("title")}}}],toDOM(n){let{fid:e,src:t,alt:r,title:o}=n.attrs;return e&&(t=`${so}/files/${e}`),t||(t=ni),["div",{title:o,class:"image"},["img",{fid:e,src:t,alt:r,title:o}]]}},Rb={atom:!0,attrs:{title:{default:null,validate:"string|null"},src:{validate:n=>{if(typeof n!="string"){if(Array.isArray(n)){n.forEach(e=>{if(typeof e!="string")throw new Error("One of the video sources is not a string")});return}throw new Error("Video source must be a string or array of strings")}}}},group:"block",parseDOM:[{tag:"iframe[src]",getAttrs(n){return{src:n.getAttribute("src"),title:n.getAttribute("title")}}}],toDOM(n){const{src:e,title:t}=n.attrs,r="fullscreen; accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share",o=Array.isArray(e)?e[0]:e;return oi(o)?["div",{title:t,class:"video"},["iframe",{src:o,title:t,allow:r}]]:["div",{title:t,class:"image"},["img",{src:ri}]]}},zb={content:"inline*",group:"block",attrs:{align:{default:null,validate:"string|null"}},parseDOM:[{tag:"p",getAttrs(n){let e=n.getAttribute("align");return e!=="right"&&e!=="center"&&e!=="justify"&&(e=null),{align:e}}}],toDOM(n){const{align:e}=n.attrs;return["p",{align:e},0]}},$b={attrs:{level:{default:1,validate:"number"}},content:"inline*",marks:"underline strikethrough",group:"block",parseDOM:[{tag:"h1",attrs:{level:1}},{tag:"h2",attrs:{level:2}},{tag:"h3",attrs:{level:3}},{tag:"h4",attrs:{level:4}},{tag:"h5",attrs:{level:5}},{tag:"h6",attrs:{level:6}}],toDOM(n){return["h"+n.attrs.level,0]}},jb={atom:!0,content:"image*",group:"block",toDOM(){return["div",{class:"carousel"},0]}},ju=zu.spec.nodes.remove("image").append({image:Vb,video:Rb}),io=new xr({nodes:ju.remove("horizontal_rule").remove("heading"),marks:$u}),Bb=ju.remove("heading").remove("paragraph").prepend({paragraph:zb}).append({heading:$b}).append({carousel:jb}).append(hg({tableGroup:"block",cellContent:"(paragraph | ordered_list | bullet_list)+",cellAttributes:{halign:{default:null,getFromDOM(n){const e=n.getAttribute("align")||null;return e==="left"||e==="right"||e==="center"?e:null},setDOMAttr(n,e){n&&(e.style=(e.style||"")+`text-align: ${n};`)}},valign:{default:null,getFromDOM(n){const e=n.style.verticalAlign||null;return e==="top"||e==="bottom"||e==="middle"?e:null},setDOMAttr(n,e){n&&(e.style=(e.style||"")+`vertical-align: ${n};`)}}}})),Nt=new xr({nodes:Hp(Bb,"(paragraph | ordered_list | bullet_list)+","block"),marks:$u}),Fb=n=>{if(n)try{const e=be.fromJSON(Nt,JSON.parse(n)),t=$e.fromSchema(Nt).serializeFragment(e.content);return Pt.fromSchema(io).parse(t)}catch(e){console.error(`Can not convert content to simple schema: ${e}`)}},sr=({ref:n,item:e})=>{const[t,r]=m.useState(!0),[o,s]=m.useState(!1),[i,l]=m.useState(!1);Ke(c=>{c&&(r(e.isActive&&e.isActive(c.state)),l(e.isSelected&&!e.isSelected(c.state)),e.isDisabled?s(e.isDisabled(c.state)):s(!e.command(c.state)))});const a=re(c=>{c&&(o||e.command(c.state,c.dispatch,c),c.focus())});return i?null:y.jsx("div",{ref:n,className:`MenuItem ${t?"active":""} ${o?"disabled":""}`,onClick:c=>{c.stopPropagation(),c.preventDefault(),a()},children:e.icon})},Bu=({schema:n})=>{const[e,t]=m.useState(void 0),[r,o]=m.useState(void 0);return m.useEffect(()=>{if(t(void 0),o(void 0),n.nodes.paragraph){const s=n.nodes.paragraph;t({icon:y.jsx(N.Icons.Type,{}),command:on(s)})}if(n.nodes.code_block){const s=n.nodes.code_block;o({icon:y.jsx(N.Icons.CodeXml,{}),command:on(s)})}},[n]),y.jsxs(y.Fragment,{children:[e&&y.jsx(sr,{item:e}),r&&y.jsx(sr,{item:r})]})},ir=({items:n})=>y.jsx("div",{className:"MenuBlock",children:n.map((e,t)=>y.jsx(sr,{item:e},t))}),Lb=({schema:n,isOpen:e,onClose:t})=>{const r=re((o,s)=>{o&&(ke(n.marks.link,{href:s})(o.state,o.dispatch),t(),o.focus())});return y.jsx(N.Prompt,{title:"Введите URL для ссылки",isOpen:e,onCancel:t,onSubmit:r})},Fu=({schema:n})=>{const[e,t]=m.useState([]),[r,o]=m.useState(!1);return m.useEffect(()=>{const s=[];if(n.marks.strong){const i=n.marks.strong;s.push({icon:y.jsx(N.Icons.Bold,{}),command:ke(i),isActive:l=>Jt(l,i)})}if(n.marks.em){const i=n.marks.em;s.push({icon:y.jsx(N.Icons.Italic,{}),command:ke(i),isActive:l=>Jt(l,i)})}if(n.marks.underline){const i=n.marks.underline;s.push({icon:y.jsx(N.Icons.Underline,{}),command:ke(i),isActive:l=>Jt(l,i)})}if(n.marks.strikethrough){const i=n.marks.strikethrough;s.push({icon:y.jsx(N.Icons.Strikethrough,{}),command:ke(i),isActive:l=>Jt(l,i)})}if(n.marks.code){const i=n.marks.code;s.push({icon:y.jsx(N.Icons.Code,{}),command:ke(i),isActive:l=>Jt(l,i)})}if(n.marks.link){const i=n.marks.link;s.push({icon:y.jsx(N.Icons.Link,{}),isActive:l=>Jt(l,i),isDisabled:l=>l.selection.empty?!0:!ke(i)(l),command:(l,a,c)=>(Jt(l,i)?(ke(i)(l,a),c==null||c.focus()):o(!0),!0)})}t(s)},[n]),e.length<1?null:y.jsxs(y.Fragment,{children:[y.jsx(ir,{items:e}),y.jsx(Lb,{isOpen:r,schema:n,onClose:()=>o(!1)})]})};function Jt(n,e){let{from:t,$from:r,to:o,empty:s}=n.selection;return s?!!e.isInSet(n.storedMarks||r.marks()):n.doc.rangeHasMark(t,o,e)}const Lu=()=>y.jsxs("div",{className:"MenuBlock",children:[y.jsx(sr,{item:{icon:y.jsx(N.Icons.Undo,{}),command:Po}}),y.jsx(sr,{item:{icon:y.jsx(N.Icons.Redo,{}),command:Dr}})]}),Wu=({schema:n})=>{const[e,t]=m.useState([]);return m.useEffect(()=>{const r=[];if(n.nodes.bullet_list){const o=n.nodes.bullet_list;r.push({icon:y.jsx(N.Icons.List,{}),command:(s,i)=>jr(o)(s,i)})}if(n.nodes.ordered_list){const o=n.nodes.ordered_list;r.push({icon:y.jsx(N.Icons.ListOrdered,{}),command:(s,i)=>jr(o)(s,i)})}if(n.nodes.blockquote){const o=n.nodes.blockquote;r.push({icon:y.jsx(N.Icons.Quote,{}),command:(s,i)=>Nl(o)(s,i)})}t(r)},[n]),e.length<1?null:y.jsx(ir,{items:e})},_u=({pos:n,isOpen:e,onClose:t})=>{const[r,o]=m.useState(""),[s,i]=m.useState(),[l,a]=m.useState(""),[c,u]=m.useState(!1);m.useEffect(()=>{o(""),a(""),i(void 0)},[e]),Ke(d=>{if(!d||!e)return;const p=tt.getState(d.state);u(p.upload!==void 0)},[e]);const f=re(d=>{d&&(c?xm(d,s,l,n):km(d,r,l,n),d.focus(),t())});return y.jsxs(N.Modal,{isOpen:e,onClose:t,children:[y.jsx("h1",{children:"Вставка картинки"}),y.jsxs(N.Form,{submit:"Вставить",submitType:"Success",onSubmit:f,onCancel:t,children:[c?y.jsx(N.Image,{id:"image",value:s,onChange:i,text:y.jsxs("span",{children:[y.jsx(N.Icons.Image,{}),y.jsx("br",{}),"Выберите файл"]}),required:!0,label:"Картинка"}):y.jsx(N.Input,{id:"href",value:r,onChange:o,required:!0,label:"Ссылка на картинку"}),y.jsx(N.Input,{id:"value",value:l,onChange:a,label:"Подпись"})]})]})},Wb=({schema:n,isOpen:e,onClose:t})=>{const[r,o]=m.useState(""),[s,i]=m.useState(""),[l,a]=m.useState(""),[c,u]=m.useState(""),[f,d]=m.useState(""),[p,h]=m.useState(!0);m.useEffect(()=>{o(""),i(""),a(""),u(""),d(""),n.nodes.table?h(!1):h(!0)},[e]);const b=re(x=>{const S=n.nodes.video;if(!x||!S)return;let w=[];if(p){if(w=oi(r),!w)return}else{if(!s&&!l&&!c)return;const D=rr(l,!0)+"",T=or(c,!0)+"",M=nr(s,!0)+"";D&&w.push(D),T&&w.push(T),M&&w.push(M)}x.dispatch(x.state.tr.replaceSelectionWith(S.create({src:w,title:f}))),x.focus(),t()}),g=()=>p?!!oi(r):l&&!rr(l)||c&&!or(c)||s&&!nr(s)?!1:!!(l||c||s);return n.nodes.video?y.jsxs(N.Modal,{isOpen:e,onClose:t,children:[y.jsx("h1",{children:"Вставка видео"}),y.jsxs(N.Form,{submit:"Вставить",submitType:"Success",onSubmit:b,onCancel:t,children:[p?y.jsx(N.Input,{id:"url",value:r,onChange:o,label:"Ссылка на видео",bottom:"Поддерживаются VK Video, RuTube и YouTube",required:!g()}):y.jsxs(y.Fragment,{children:[y.jsx(N.Input,{id:"vkvideo",value:s,onChange:i,label:"Ссылка на VK Video",required:!g()}),y.jsx(N.Input,{id:"rutube",value:l,onChange:a,label:"Ссылка на RuTube",required:!g()}),y.jsx(N.Input,{id:"youtube",value:c,onChange:u,label:"Ссылка на YouTube",required:!g()})]}),y.jsx(N.Input,{id:"value",value:f,onChange:d,label:"Подпись"})]})]}):null},qu=({schema:n})=>{const[e,t]=m.useState([]),[r,o]=m.useState(!1),[s,i]=m.useState(!1);return m.useEffect(()=>{const l=[];if(n.nodes.image){const a=n.nodes.image;l.push({icon:y.jsx(N.Icons.Image,{}),isDisabled:c=>!si(c,a),command:()=>(o(!0),!0)})}if(n.nodes.video){const a=n.nodes.video;l.push({icon:y.jsx(N.Icons.Film,{}),isDisabled:c=>!si(c,a),command:()=>(i(!0),!0)})}if(n.nodes.horizontal_rule){const a=n.nodes.horizontal_rule;l.push({icon:y.jsx(N.Icons.FlipVertical,{}),isDisabled:c=>!si(c,a),command:(c,u)=>u?(u(c.tr.replaceSelectionWith(a.create())),!0):!1})}n.nodes.table&&l.push({icon:y.jsx(N.Icons.Table,{}),isDisabled:Oe,command:_b()}),t(l)},[n]),e.length<1?null:y.jsxs(y.Fragment,{children:[y.jsx(ir,{items:e}),y.jsx(_u,{isOpen:r,onClose:()=>o(!1)}),y.jsx(Wb,{isOpen:s,schema:n,onClose:()=>i(!1)})]})},si=(n,e)=>{let t=n.selection.$from;for(let r=t.depth;r>=0;r--){let o=t.index(r);if(t.node(r).canReplaceWith(o,o,e))return!0}return!1};function _b(){return(n,e)=>{const t=n.tr.selection.anchor+1,r=n.tr,o=n.schema.nodes.table_cell.createAndFill(),s=n.schema.nodes.table.create(null,C.fromArray([n.schema.nodes.table_row.create(null,C.fromArray([o,o,o])),n.schema.nodes.table_row.create(null,C.fromArray([o,o,o]))]));return e&&e(r.replaceSelectionWith(s).scrollIntoView().setSelection(V.near(r.doc.resolve(t)))),!0}}const Hu=({schema:n})=>n.nodes.carousel?y.jsx(ir,{items:[{icon:y.jsx(N.Icons.JoinUp,{}),command:Sl},{icon:y.jsx(N.Icons.IndentDecrease,{}),command:$o},{icon:y.jsx(N.Icons.SquareDashed,{}),command:Bo}]}):y.jsx(ir,{items:[{icon:y.jsx(N.Icons.IndentDecrease,{}),command:$o},{icon:y.jsx(N.Icons.SquareDashed,{}),command:Bo}]}),qb=({schema:n})=>y.jsxs("div",{className:"SimpleMenuBar",children:[y.jsx("div",{className:"MenuBlock",children:y.jsx(Bu,{schema:n})}),y.jsx(Fu,{schema:n}),y.jsx(qu,{schema:n}),y.jsx(Wu,{schema:n}),y.jsx(Hu,{schema:n}),y.jsx(Lu,{})]}),Ku=m.forwardRef(function({children:e,nodeProps:t,...r},o){const[s,i]=m.useState(t.node.attrs.alt??""),[l,a]=m.useState(t.node.attrs.title??""),[c,u]=m.useState(!1),[f,d]=m.useState("");Vu((x,S)=>x?!(S instanceof MouseEvent):!1),Ke(x=>{if(d(""),u(!1),!x||!x.state.schema.nodes.carousel)return;const S=t.getPos(),w=x.state.doc.resolve(S).parent;if(u(w.type.name!=="carousel"),w.type.name==="carousel"){let D=0;w.forEach((T,M)=>{T===t.node&&(D=M+1)}),d(D?`${D} / ${w.childCount}`:"")}});const p=re((x,S)=>{if(!x)return;i(S);const w=x.state.tr,D=t.getPos();x.dispatch(w.setNodeMarkup(D,null,{...t.node.attrs,alt:S})),x.focus()}),h=re((x,S)=>{if(!x)return;a(S);const w=x.state.tr,D=t.getPos();x.dispatch(w.setNodeMarkup(D,null,{...t.node.attrs,title:S})),x.focus()}),b=re(x=>{if(!x)return;const S=t.getPos(),w=t.node.nodeSize,D=t.node.attrs,T=x.state.schema,M=T.nodes.carousel.create(null,T.nodes.image.create(D));x.dispatch(x.state.tr.replaceWith(S,S+w,M))}),g=re(x=>{if(!x)return;const S=x.state.tr,w=t.getPos(),D=t.node.nodeSize;x.dispatch(S.delete(w,w+D))});return y.jsxs("div",{...r,ref:o,className:"image",title:t.node.attrs.title,children:[y.jsxs("div",{className:"image-buttons",children:[c&&y.jsx("div",{onClick:b,className:"text-button",children:"Сделать карусель"}),f&&y.jsx("div",{className:"text-button",children:f}),y.jsx("div",{onClick:g,children:y.jsx(N.Icons.Trash,{})})]}),y.jsx("div",{className:"image-title",children:y.jsx(N.Editable,{value:s,placeholder:"Alt: описание изображения (не обязательно)",onChange:p,empty:!0,style:{textAlign:"center",cursor:"text"}})}),y.jsx("img",{title:t.node.attrs.title,alt:t.node.attrs.alt,src:t.node.attrs.fid?`${so}/files/${t.node.attrs.fid}`:t.node.attrs.src}),y.jsx("div",{className:"image-title",children:y.jsx(N.Editable,{value:l,placeholder:"Title: подпись под изображением (не обязательно)",onChange:h,empty:!0,style:{textAlign:"center",cursor:"text"}})})]})}),Ju=m.forwardRef(function({children:e,nodeProps:t,...r},o){const[s,i]=m.useState(""),[l,a]=m.useState(""),[c,u]=m.useState(""),[f,d]=m.useState(""),[p,h]=m.useState(t.node.attrs.title??""),b="fullscreen; accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share";Vu(()=>!0),m.useEffect(()=>{let x=t.node.attrs.src;typeof x=="string"&&(x=[x]),x.forEach(S=>{rr(S)?(i(S),a(S)):or(S)?(i(S),u(S)):nr(S)&&(i(S),d(S))})},[t]);const g=re((x,S)=>{if(!x)return;h(S);const{$from:w,$to:D}=x.state.selection,T=w.blockRange(D);if(T){const M=x.state.doc;let I=x.state.tr;M.nodesBetween(T.start,T.end,(z,v)=>{z.type.name==="video"&&(I=I.setNodeMarkup(v,null,{...t.node.attrs,title:S}))}),x.dispatch(I)}x.focus()});return y.jsxs("div",{...r,ref:o,className:"video",title:t.node.attrs.title,children:[y.jsxs("div",{className:"video-switcher",children:[l&&y.jsx("div",{onClick:()=>i(l),className:s===l?"active":"",children:"RuTube"}),c&&y.jsx("div",{onClick:()=>i(c),className:s===c?"active":"",children:"YouTube"}),f&&y.jsx("div",{onClick:()=>i(f),className:s===f?"active":"",children:"VK Video"})]}),s?y.jsx("iframe",{src:s,allow:b}):y.jsx("img",{src:ri}),y.jsx("div",{className:"video-title",children:y.jsx(N.Editable,{value:p,placeholder:"Подпись под видео (не обязательно)",onChange:g,empty:!0,style:{textAlign:"center",cursor:"text"}})})]})}),Yu=({onSave:n,disabled:e=!1,notEmpty:t=!0})=>{const[r,o]=m.useState(!0),[s,i]=m.useState(!1);Ke(a=>{let c=!0;if(t){const u=a.state.doc;c=!!u.textBetween(0,u.content.size,void 0," ").length}o(c)});const l=re(async a=>{i(!0);try{let c;const u=Is(a.state);if(u){const d=a.state.apply(u.setMeta("addToHistory",!1));c=JSON.stringify(d.doc.toJSON())}else c=JSON.stringify(a.state.doc.toJSON());const f=await n({content:c,format:"prose"});if(f)throw new Error(f)}catch(c){console.error(`Can not save doc: ${c}`)}i(!1),a.focus()});return y.jsx(N.Button,{type:"Accent",disabled:e||!r||s,label:s?"Сохраняю":"Сохранить",size:"Small",onClick:l})},Hb=({title:n=!1,content:e,onSave:t,onCancel:r,onChange:o,onUpload:s})=>{const[i,l]=m.useState(""),[a,c]=m.useState();m.useEffect(()=>{const p=Ge.create({doc:Fb(e),schema:io,plugins:Ru({schema:io,upload:s})});c(p),n!==!1&&l(typeof n=="string"?n:"")},[n,e]);const u=()=>n!==!1?i.trim().length>0:!0,f=p=>{!t||!u()||t({...p,name:i})},d=()=>{r&&r()};return a?y.jsxs("div",{className:"ProseNotes",children:[n!==!1&&y.jsx("input",{className:"ProseNotesTitle",onChange:p=>l(p.currentTarget.value),value:i,placeholder:"Укажите заголовок"}),y.jsxs(Iu,{state:a,dispatchTransaction:p=>c(h=>{const b=h==null?void 0:h.apply(p);return b&&o&&o(!!Md(b)),b}),nodeViews:{image:Ku,video:Ju},children:[y.jsxs("div",{className:"ProseNotesContent",children:[y.jsx(qb,{schema:io}),y.jsx(Pu,{})]}),(t||r)&&y.jsxs("div",{className:"ProseNotesButtons",children:[r&&y.jsx("span",{className:"a small",onClick:d,children:"Отменить"}),t&&y.jsx(Yu,{onSave:f,disabled:!u()})]})]})]}):null},Kb=({schema:n})=>{const e=m.useRef(null),[t,r]=m.useState([]),[o,s]=m.useState([]),[i,l]=m.useState(!1);Ke(c=>{const u=n.nodes.heading;if(!c||!u||!i)return;const f=[],d=[];for(let p=2;p<7;p++){const b=on(u,{level:p});d[p]=b,f[p]={id:p,icon:y.jsx(Jb,{level:p}),text:`уровень ${p}`,disabled:!b(c.state)}}r(f),s(d)},[i]);const a=re((c,u)=>{!c||!u.id||(o[u.id](c.state,c.dispatch,c),l(!1),c.focus())});return n.nodes.heading?y.jsxs(y.Fragment,{children:[y.jsx("div",{ref:e,className:"MenuItem",onClick:()=>l(!0),children:y.jsx(N.Icons.Heading,{})}),e.current&&y.jsx(N.Menu,{parent:e.current,items:t,isOpen:i,onClose:()=>l(!1),onClick:a,horizontal:"inner-left"})]}):null},Jb=({level:n})=>{switch(n){case 2:return y.jsx(N.Icons.Heading2,{});case 3:return y.jsx(N.Icons.Heading3,{});case 4:return y.jsx(N.Icons.Heading4,{});case 5:return y.jsx(N.Icons.Heading5,{});case 6:return y.jsx(N.Icons.Heading6,{});default:return y.jsx(N.Icons.Heading,{})}},Yb=[{id:"left",icon:y.jsx(N.Icons.AlignLeft,{}),text:"Прижать влево"},{id:"right",icon:y.jsx(N.Icons.AlignRight,{}),text:"Прижать вправо"},{id:"center",icon:y.jsx(N.Icons.AlignCenter,{}),text:"Отцентровать"},{id:"justify",icon:y.jsx(N.Icons.AlignJustify,{}),text:"Выровнять по краям"}],Gb=({schema:n})=>{const e=m.useRef(null),[t,r]=m.useState(!1),o=re((s,i)=>{if(!s||!i.id)return;const l=i.id==="left"?null:i.id,{$from:a,$to:c}=s.state.selection,u=a.blockRange(c);if(u){const f=s.state.doc;let d=s.state.tr;f.nodesBetween(u.start,u.end,(p,h)=>{p.type.name==="paragraph"&&(d=d.setNodeMarkup(h,null,{align:l}))}),s.dispatch(d)}s.focus(),r(!1)});return n.nodes.paragraph?y.jsxs(y.Fragment,{children:[y.jsx("div",{ref:e,className:"MenuItem",onClick:()=>r(!0),children:y.jsx(N.Icons.AlignLeft,{})}),e.current&&y.jsx(N.Menu,{parent:e.current,items:Yb,isOpen:t,onClose:()=>r(!1),onClick:o,horizontal:"inner-left"})]}):null},Xb=({schema:n,onSave:e,onView:t})=>y.jsxs("div",{className:"MenuBar",children:[y.jsxs("div",{className:"MenuBlock",children:[y.jsx(Kb,{schema:n}),y.jsx(Bu,{schema:n})]}),y.jsx(Fu,{schema:n}),y.jsx(qu,{schema:n}),y.jsx(Wu,{schema:n}),y.jsx(Gb,{schema:n}),y.jsx(Hu,{schema:n}),y.jsx(Lu,{}),t&&y.jsx("div",{className:"MenuItem",onClick:()=>t(),children:y.jsx(N.Icons.Eye,{})}),y.jsx("div",{className:"MenuBlock",children:y.jsx(Yu,{onSave:e})})]}),Ub=7,Gu=1,lr=50,Qb=({width:n,onChange:e,onWidth:t})=>{const[r,o]=m.useState(!1),[s,i]=m.useState(0),[l,a]=m.useState(0),[c,u]=m.useState(n),f=h=>{const b=n[l],g=n[l+1],x=[...c];return b+h<lr&&(h=lr-b),g-h<lr&&(h=g-lr),x[l]=b+h,x[l+1]=g-h,x};m.useEffect(()=>{u(n)},[n]),m.useEffect(()=>{const h=g=>{if(!r)return;o(!1),g.preventDefault(),g.stopPropagation();const x=g.clientX-s,S=f(x);t(S)},b=g=>{if(!r)return;g.preventDefault(),g.stopPropagation();const x=g.clientX-s,S=f(x);u(S),e(S)};return document.addEventListener("mouseup",h),document.addEventListener("mousemove",b),()=>{document.removeEventListener("mouseup",h),document.removeEventListener("mousemove",b)}},[r,l]);const d=(h,b)=>{b!==n.length-1&&(h.preventDefault(),h.stopPropagation(),o(!0),i(h.clientX),a(b))},p=h=>c.slice(0,h+1).reduce((b,g)=>b+g,0)+h+Gu-Math.floor(Ub/2);return y.jsx("div",{className:"table-resizer",children:c.map((h,b)=>y.jsx("div",{style:{left:p(b)+"px"},onMouseDown:g=>d(g,b)},b))})},Zb=m.forwardRef(function({children:e,nodeProps:t,...r},o){var f;const s=m.useRef(null),i=m.useRef(null),[l,a]=m.useState([]),c=re((d,p)=>{if(!d)return;const h=t.node,b=t.getPos()+1,g=Q.get(h),x=d.state.tr;for(let S=0;S<g.height;S++)for(let w=0;w<g.width;){const D=S*g.width+w,T=g.map[D],M=h.nodeAt(T).attrs,I=p.slice(w,w+M.colspan);S&&g.map[D]==g.map[D-g.width]||x.setNodeMarkup(b+T,null,{...M,colwidth:I}),w+=M.colspan}x.docChanged&&d.dispatch(x)});m.useEffect(()=>{if(!s.current||!i.current)return;const p=t.node.firstChild;if(!p)return;let h=[];for(let M=0;M<p.childCount;M++){const I=p.child(M),{colspan:z,colwidth:v}=I.attrs;h=h.concat(Array.isArray(v)?v:Array(z).fill(0))}const b=h.filter(M=>!M).length,g=h.reduce((M,I)=>M+I,0),x=(h.length+1)*Gu,S=Math.max(b?(s.current.offsetWidth-g-x)/b:0,lr);h=h.map(M=>M||S);const w=h.reduce((M,I)=>M+I,0),D=i.current.offsetWidth-x-16,T=D/w;h=h.map(M=>Math.round(M*T)),h[h.length-1]+=D-h.reduce((M,I)=>M+I,0),a(h)},[t,s,i,(f=i.current)==null?void 0:f.offsetWidth]);const u=re(d=>{_g(d.state,d.dispatch)});return y.jsxs("div",{...r,className:"table-wrapper",ref:d=>{i.current=d,o&&(typeof o=="function"?o(d):o.current=d)},children:[y.jsx(Qb,{width:l,onChange:a,onWidth:c}),y.jsxs("table",{ref:s,children:[y.jsx("colgroup",{children:l.map((d,p)=>y.jsx("col",{width:d},p))}),y.jsx("caption",{onClick:u,children:y.jsx(N.Icons.Trash,{})}),y.jsx("tbody",{children:e})]})]})}),e0=[{id:"toggleHeaderRow",text:"Toggle header row",icon:y.jsx(N.Icons.Heading,{})},{id:"addRowBefore",text:"Insert row before",icon:y.jsx(N.Icons.RowInsertBefore,{})},{id:"addRowAfter",text:"Insert row after",icon:y.jsx(N.Icons.RowInsertAfter,{})},{id:"deleteRow",text:"Delete row",icon:y.jsx(N.Icons.Trash,{})}],t0=[{id:"toggleHeaderColumn",text:"Toggle header column",icon:y.jsx(N.Icons.Heading,{})},{id:"addColumnBefore",text:"Insert column before",icon:y.jsx(N.Icons.ColumnInsertBefore,{})},{id:"addColumnAfter",text:"Insert column after",icon:y.jsx(N.Icons.ColumnInsertAfter,{})},{id:"deleteColumn",text:"Delete column",icon:y.jsx(N.Icons.Trash,{})}],n0=[{id:"toggleHeaderCell",text:"Toggle header",icon:y.jsx(N.Icons.Heading,{})},{id:"alignLeft",text:"Horizontal align left",icon:y.jsx(N.Icons.AlignLeft,{})},{id:"alignCenter",text:"Horizontal align center",icon:y.jsx(N.Icons.AlignCenter,{})},{id:"alignRight",text:"Horizontal align Right",icon:y.jsx(N.Icons.AlignRight,{})},{id:"alignTop",text:"Vertical align top",icon:y.jsx(N.Icons.AlignTop,{})},{id:"alignMiddle",text:"Vertical align middle",icon:y.jsx(N.Icons.AlignMiddle,{})},{id:"alignBottom",text:"Vertical align bottom",icon:y.jsx(N.Icons.AlignBottom,{})},{id:"mergeCells",text:"Merge cells",icon:y.jsx(N.Icons.CellsMerge,{})},{id:"splitCell",text:"Split cell",icon:y.jsx(N.Icons.CellsSplit,{})}],Xu=({x:n,y:e,isRowMenuOpen:t,isCellMenuOpen:r,isColumnMenuOpen:o,onRowMenuClose:s,onCellMenuClose:i,onColumnMenuClose:l})=>{const a=re((c,u)=>{if(c){switch(u.id){case"toggleHeaderRow":Bg(c.state,c.dispatch);break;case"addRowBefore":Tg(c.state,c.dispatch);break;case"addRowAfter":Ag(c.state,c.dispatch);break;case"deleteRow":Ig(c.state,c.dispatch);break;case"toggleHeaderColumn":Fg(c.state,c.dispatch);break;case"addColumnBefore":Ng(c.state,c.dispatch);break;case"addColumnAfter":Eg(c.state,c.dispatch);break;case"deleteColumn":Og(c.state,c.dispatch);break;case"mergeCells":Rg(c.state,c.dispatch);break;case"splitCell":zg(c.state,c.dispatch);break;case"toggleHeaderCell":Lg(c.state,c.dispatch);break;case"alignLeft":mn("halign","left")(c.state,c.dispatch);break;case"alignCenter":mn("halign","center")(c.state,c.dispatch);break;case"alignRight":mn("halign","right")(c.state,c.dispatch);break;case"alignTop":mn("valign","top")(c.state,c.dispatch);break;case"alignMiddle":mn("valign","middle")(c.state,c.dispatch);break;case"alignBottom":mn("valign","bottom")(c.state,c.dispatch);break}s(),i(),l(),c.focus()}});return y.jsxs(y.Fragment,{children:[y.jsx(N.Menu,{x:n,y:e,items:e0,isOpen:t,onClose:s,onClick:a}),y.jsx(N.Menu,{x:n,y:e,items:n0,isOpen:r,onClose:i,onClick:a}),y.jsx(N.Menu,{x:n,y:e,items:t0,isOpen:o,onClose:l,onClick:a})]})},Uu=m.forwardRef(function({children:e,nodeProps:t,...r},o){const s=m.useRef(null),[i,l]=m.useState(0),[a,c]=m.useState(0),[u,f]=m.useState(!1),[d,p]=m.useState(!1),[h,b]=m.useState(!1);m.useEffect(()=>{const S=w=>{s.current!==w.target&&(f(!1),p(!1),b(!1))};return document.addEventListener("contextmenu",S,!0),()=>document.removeEventListener("contextmenu",S,!0)},[]);const g=S=>{S.preventDefault(),S.stopPropagation(),f(!1),p(!1),b(!1),l(S.clientX),c(S.clientY);const w=S.currentTarget.getBoundingClientRect();S.clientY<w.y?b(!0):S.clientX<w.x?f(!0):p(!0)},x=S=>{f(!1),p(!1),b(!1),l(S.clientX),c(S.clientY);const w=S.currentTarget.getBoundingClientRect();if(S.clientY<w.y)b(!0);else if(S.clientX<w.x)f(!0);else return;S.preventDefault(),S.stopPropagation()};return t.node.type.spec.tableRole==="header_cell"?y.jsxs("th",{...r,datatype:`width-${t.node.attrs.colwidth}`,colSpan:t.node.attrs.colspan,rowSpan:t.node.attrs.rowspan,style:{textAlign:t.node.attrs.halign,verticalAlign:t.node.attrs.valign},onClick:x,onContextMenu:g,ref:S=>{s.current=S,o&&(typeof o=="function"?o(S):o.current=S)},children:[e,y.jsx(Xu,{x:i,y:a,isRowMenuOpen:u,onRowMenuClose:()=>f(!1),isCellMenuOpen:d,onCellMenuClose:()=>p(!1),isColumnMenuOpen:h,onColumnMenuClose:()=>b(!1)})]}):y.jsxs("td",{...r,datatype:`width-${t.node.attrs.colwidth}`,colSpan:t.node.attrs.colspan,rowSpan:t.node.attrs.rowspan,style:{textAlign:t.node.attrs.halign,verticalAlign:t.node.attrs.valign},onClick:x,onContextMenu:g,ref:S=>{s.current=S,o&&(typeof o=="function"?o(S):o.current=S)},children:[e,y.jsx(Xu,{x:i,y:a,isRowMenuOpen:u,onRowMenuClose:()=>f(!1),isCellMenuOpen:d,onCellMenuClose:()=>p(!1),isColumnMenuOpen:h,onColumnMenuClose:()=>b(!1)})]})}),r0=m.forwardRef(function({children:e,nodeProps:t,...r},o){var T;const s=m.useRef(null),[i,l]=m.useState(!1),[a,c]=m.useState(!1),[u,f]=m.useState(!1),[d,p]=m.useState(),[h,b]=m.useState(),g=M=>{const I=M.scrollLeft,z=M.clientWidth,v=M.scrollWidth;c(I>0),f(I<v-z*1.5)};m.useEffect(()=>{s.current&&(h&&s.current.scrollWidth>h&&(s.current.scrollLeft=s.current.scrollWidth-s.current.clientWidth),b(s.current.scrollWidth))},[(T=s.current)==null?void 0:T.scrollWidth]),m.useEffect(()=>{p(t.getPos()+t.node.nodeSize-1),s.current&&t.node.childCount>1&&g(s.current)},[t,s]),Ke(M=>{if(!M||t.node.childCount>0)return;const I=M.state.tr,z=t.getPos(),v=t.node.nodeSize;M.dispatch(I.delete(z,z+v))},[t]);const x=re(M=>{if(!M)return;const I=t.getPos(),z=t.node.nodeSize;M.dispatch(M.state.tr.delete(I,I+z))}),S=()=>{l(!0)},w=M=>{g(M.currentTarget)},D=(M,I)=>{if(M.stopPropagation(),!s.current)return;const z=s.current.clientWidth;let v=s.current.scrollLeft+I*z;s.current.scrollLeft=v};return y.jsxs("div",{ref:o,...r,className:"carousel",children:[y.jsx("div",{className:"carousel-list",ref:s,onScroll:w,children:e}),y.jsxs("div",{className:"carousel-buttons",children:[y.jsx("div",{onClick:x,className:"text-button",children:"Удалить карусель"}),y.jsx("div",{onClick:S,children:y.jsx(N.Icons.Plus,{})})]}),a&&y.jsx("div",{className:"carousel-prev",onClick:M=>D(M,-1),children:y.jsx(N.Icons.ChevronLeft,{})}),u&&y.jsx("div",{className:"carousel-next",onClick:M=>D(M,1),children:y.jsx(N.Icons.ChevronRight,{})}),y.jsx(_u,{pos:d,isOpen:i,onClose:()=>l(!1)})]})}),o0=({content:n,onSave:e,onView:t,onChange:r,onUpload:o})=>{const[s,i]=m.useState();m.useEffect(()=>{let a;if(n)try{a=be.fromJSON(Nt,JSON.parse(n))}catch(f){console.error(`Can not parse Prose format: ${f}`)}let c=Ge.create({doc:a,schema:Nt,plugins:Ru({schema:Nt,upload:o})});const u=Is(c);u&&(c=c.apply(u.setMeta("addToHistory",!1))),i(c)},[n]);const l=async a=>{const c=await e(a);return r&&r(!1),c};return s?y.jsx("div",{className:"ProseEditor",children:y.jsxs(Iu,{state:s,dispatchTransaction:a=>i(c=>{const u=c==null?void 0:c.apply(a);return u&&r&&r(!0),u}),nodeViews:{image:Ku,video:Ju,table:Zb,table_header:Uu,table_cell:Uu,carousel:r0},children:[y.jsx(Xb,{schema:Nt,onSave:l,onView:t}),y.jsx(Pu,{})]})}):null},s0=({node:n})=>{const[e,t]=m.useState();return m.useEffect(()=>{var o;const r=(o=n.attrs)==null?void 0:o.align;t(r!=="right"&&r!=="center"&&r!=="justify"?void 0:{textAlign:r})},[n]),y.jsx("p",{style:e,children:Array.isArray(n.content)&&n.content.map((r,o)=>y.jsx(Y,{node:r},o))})},i0=({node:n})=>{if(!n.text)return null;const e=(t,r)=>{var i;if(!Array.isArray(n.marks))return y.jsx(y.Fragment,{children:r});if(!t.length)return y.jsx(y.Fragment,{children:r});const o=t[0].type,s=(i=t[0].attrs)==null?void 0:i.href;switch(o){case"em":return y.jsx("em",{children:e(t.slice(1),r)});case"code":return y.jsx("code",{children:e(t.slice(1),r)});case"strong":return y.jsx("strong",{children:e(t.slice(1),r)});case"underline":return y.jsx("u",{children:e(t.slice(1),r)});case"strikethrough":return y.jsx("s",{children:e(t.slice(1),r)});case"link":return s?y.jsx("a",{target:"_blank",href:s,children:e(t.slice(1),r)}):y.jsx(y.Fragment,{children:e(t.slice(1),r)});default:return y.jsx(y.Fragment,{children:e(t.slice(1),r)})}};return e(n.marks,n.text)},l0=({node:n,className:e})=>y.jsx("div",{className:e,children:Array.isArray(n.content)&&n.content.map((t,r)=>y.jsx(Y,{node:t},r))}),a0=({node:n})=>{const e=m.useRef(null),[t,r]=m.useState(""),[o,s]=m.useState(""),[i,l]=m.useState(""),[a,c]=m.useState(!1);m.useEffect(()=>{const f=()=>{c(!!document.fullscreenElement)};return document.addEventListener("fullscreenchange",f),()=>document.removeEventListener("fullscreenchange",f)},[]),m.useEffect(()=>{var p,h,b,g,x,S,w;let f=(p=n.attrs)==null?void 0:p.fid,d=(h=n.attrs)!=null&&h.src?`${(b=n.attrs)==null?void 0:b.src}`:"";f&&(d=`${so}/files/${f}`),d||(d=ni),r(d),s((g=n.attrs)!=null&&g.alt?`${(x=n.attrs)==null?void 0:x.alt}`:""),l((S=n.attrs)!=null&&S.title?`${(w=n.attrs)==null?void 0:w.title}`:"")},[n]);const u=f=>{var d;f.stopPropagation(),a?document.exitFullscreen():(d=e.current)==null||d.requestFullscreen()};return t?y.jsxs("div",{ref:e,className:"image",children:[y.jsx("img",{src:t,onClick:u,alt:o,title:i}),i&&y.jsx("div",{className:"image-title",children:i}),y.jsx("div",{className:"image-full",onClick:u,children:a?y.jsx(N.Icons.Minimize,{}):y.jsx(N.Icons.Maximize,{})})]}):null},c0=({node:n})=>y.jsx("blockquote",{children:Array.isArray(n.content)&&n.content.map((e,t)=>y.jsx(Y,{node:e},t))}),u0=50,f0=({node:n})=>{const[e,t]=m.useState([]);return m.useEffect(()=>{if(t([]),!Array.isArray(n.content))return;const r=n.content[0];if(!Array.isArray(r.content))return;let o=[];for(let i=0;i<r.content.length;i++){const l=r.content[i].attrs;if(!l)return;const{colspan:a,colwidth:c}=l;o=o.concat(Array.isArray(c)?c:Array(a).fill(u0))}const s=o.reduce((i,l)=>i+l,0);o=o.map(i=>Math.round(i*100/s)),o[o.length-1]+=100-o.reduce((i,l)=>i+l,0),t(o)},[n]),y.jsxs("table",{children:[e.length>0&&y.jsx("colgroup",{children:e.map((r,o)=>y.jsx("col",{width:`${r}%`},o))}),y.jsx("tbody",{children:Array.isArray(n.content)&&n.content.map((r,o)=>y.jsx(Y,{node:r},o))})]})},d0=({node:n})=>y.jsx("tr",{children:Array.isArray(n.content)&&n.content.map((e,t)=>y.jsx(Y,{node:e},t))}),h0=({node:n})=>{const[e,t]=m.useState(),[r,o]=m.useState(),[s,i]=m.useState(),[l,a]=m.useState();return m.useEffect(()=>{var c,u,f,d;t((c=n.attrs)==null?void 0:c.halign),o((u=n.attrs)==null?void 0:u.valign),i((f=n.attrs)!=null&&f.rowspan?parseInt(n.attrs.rowspan+""):1),a((d=n.attrs)!=null&&d.colspan?parseInt(n.attrs.colspan+""):1)},[n]),n.type==="table_header"?y.jsx("th",{colSpan:l,rowSpan:s,style:{textAlign:e,verticalAlign:r},children:Array.isArray(n.content)&&n.content.map((c,u)=>y.jsx(Y,{node:c},u))}):y.jsx("td",{colSpan:l,rowSpan:s,style:{textAlign:e,verticalAlign:r},children:Array.isArray(n.content)&&n.content.map((c,u)=>y.jsx(Y,{node:c},u))})},p0=({node:n})=>{var e;if(!Array.isArray(n.content))return null;switch((e=n.attrs)==null?void 0:e.level){case 1:return y.jsx("h1",{children:n.content.map((t,r)=>y.jsx(Y,{node:t},r))});case 2:return y.jsx("h2",{children:n.content.map((t,r)=>y.jsx(Y,{node:t},r))});case 3:return y.jsx("h3",{children:n.content.map((t,r)=>y.jsx(Y,{node:t},r))});case 4:return y.jsx("h4",{children:n.content.map((t,r)=>y.jsx(Y,{node:t},r))});case 5:return y.jsx("h5",{children:n.content.map((t,r)=>y.jsx(Y,{node:t},r))});case 6:return y.jsx("h6",{children:n.content.map((t,r)=>y.jsx(Y,{node:t},r))});default:return y.jsx("h2",{children:n.content.map((t,r)=>y.jsx(Y,{node:t},r))})}},m0=({node:n})=>Array.isArray(n.content)?n.type==="bullet_list"?y.jsx("ul",{children:n.content.map((e,t)=>y.jsx(Y,{node:e},t))}):y.jsx("ol",{children:n.content.map((e,t)=>y.jsx(Y,{node:e},t))}):null,g0=({node:n})=>y.jsx("li",{children:Array.isArray(n.content)&&n.content.map((e,t)=>y.jsx(Y,{node:e},t))}),y0=({node:n})=>y.jsx("pre",{children:Array.isArray(n.content)&&n.content.map((e,t)=>y.jsx(Y,{node:e},t))}),b0=()=>y.jsx("hr",{}),x0=({node:n})=>{const[e,t]=m.useState(""),[r,o]=m.useState(""),[s,i]=m.useState(""),[l,a]=m.useState(""),[c,u]=m.useState(""),[f,d]=m.useState(0),p="fullscreen; accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share";return m.useEffect(()=>{var b,g;u((b=n.attrs)!=null&&b.title?`${n.attrs.title}`:"");let h=(g=n.attrs)==null?void 0:g.src;typeof h=="string"&&(h=[h]),h.forEach(x=>{rr(x)?(t(x),o(x)):or(x)?(t(x),i(x)):nr(x)&&(t(x),a(x))})},[n]),m.useEffect(()=>{let h=0;r&&h++,s&&h++,l&&h++,d(h)},[r,s,l]),f?y.jsxs("div",{className:"video",children:[f>1&&y.jsxs("div",{className:"video-switcher",children:[r&&y.jsx("div",{onClick:()=>t(r),className:e===r?"active":"",children:"RuTube"}),s&&y.jsx("div",{onClick:()=>t(s),className:e===s?"active":"",children:"YouTube"}),l&&y.jsx("div",{onClick:()=>t(l),className:e===l?"active":"",children:"VK Video"})]}),y.jsx("iframe",{src:e,allow:p}),c&&y.jsx("div",{className:"video-title",children:c})]}):y.jsxs("div",{className:"image",children:[y.jsx("img",{src:ri}),c&&y.jsx("div",{className:"image-title",children:c})]})},k0=()=>y.jsx("br",{}),S0=({node:n})=>{const e=m.useRef(null),t=m.useRef(null),[r,o]=m.useState(!1),[s,i]=m.useState(!1),[l,a]=m.useState(!1),[c,u]=m.useState(1),[f,d]=m.useState(1),p=g=>{const x=g.scrollLeft,S=g.clientWidth,w=g.scrollWidth;i(x>S/2),a(x<w-S*1.5),u(Math.round(x/S+1))};m.useEffect(()=>{var g;a(Array.isArray(n.content)&&n.content.length>1),d(((g=n.content)==null?void 0:g.length)??1),u(1)},[n]),m.useEffect(()=>{const g=()=>{o(!!document.fullscreenElement)};return document.addEventListener("fullscreenchange",g),()=>document.removeEventListener("fullscreenchange",g)},[]),m.useEffect(()=>{if(!r)return;const g=x=>{x.key==="ArrowLeft"&&b(null,-1),x.key==="ArrowRight"&&b(null,1)};return document.body.addEventListener("keydown",g),()=>document.body.removeEventListener("keydown",g)},[r]);const h=g=>{var x;g.stopPropagation(),r?document.exitFullscreen():(x=t.current)==null||x.requestFullscreen()},b=(g,x)=>{if(g==null||g.stopPropagation(),!e.current)return;const S=e.current.clientWidth;let w=e.current.scrollLeft+x*S;e.current.scrollLeft=w};return Array.isArray(n.content)?y.jsxs("div",{className:"carousel",ref:t,children:[y.jsx("div",{className:"carousel-list",ref:e,onScroll:g=>p(g.currentTarget),children:n.content.map((g,x)=>y.jsx(C0,{node:g,onClick:h},x))}),y.jsxs("div",{className:"carousel-numb",children:[c," / ",f]}),y.jsx("div",{className:"carousel-full",onClick:h,children:r?y.jsx(N.Icons.Minimize,{}):y.jsx(N.Icons.Maximize,{})}),s&&y.jsx("div",{className:"carousel-prev",onClick:g=>b(g,-1),children:y.jsx(N.Icons.ChevronLeft,{})}),l&&y.jsx("div",{className:"carousel-next",onClick:g=>b(g,1),children:y.jsx(N.Icons.ChevronRight,{})})]}):null},C0=({node:n,onClick:e})=>{const[t,r]=m.useState(""),[o,s]=m.useState(""),[i,l]=m.useState("");return m.useEffect(()=>{var d,p,h,b;let a=(d=n.attrs)==null?void 0:d.fid,c=(p=n.attrs)!=null&&p.src?`${n.attrs.src}`:"",u=(h=n.attrs)!=null&&h.alt?`${n.attrs.alt}`:"",f=(b=n.attrs)!=null&&b.title?`${n.attrs.title}`:"";a&&(c=`${so}/files/${a}`),c||(c=ni),r(c),s(u),l(f)},[n]),n.type!=="image"?null:y.jsxs("div",{className:"image",children:[t&&y.jsx("img",{src:t,onClick:e,alt:o,title:i}),i&&y.jsx("div",{className:"image-title",children:i})]})},Y=({node:n,className:e})=>n?(r=>{switch(r.type){case"doc":return y.jsx(l0,{node:r,className:e});case"list_item":return y.jsx(g0,{node:r});case"bullet_list":case"ordered_list":return y.jsx(m0,{node:r});case"image":return y.jsx(a0,{node:r});case"video":return y.jsx(x0,{node:r});case"text":return y.jsx(i0,{node:r});case"table":return y.jsx(f0,{node:r});case"table_row":return y.jsx(d0,{node:r});case"table_cell":case"table_header":return y.jsx(h0,{node:r});case"heading":return y.jsx(p0,{node:r});case"code_block":return y.jsx(y0,{node:r});case"paragraph":return y.jsx(s0,{node:r});case"blockquote":return y.jsx(c0,{node:r});case"carousel":return y.jsx(S0,{node:r});case"horizontal_rule":return y.jsx(b0,{});case"hard_break":return y.jsx(k0,{});default:return y.jsx("span",{className:"unknown_node_type",children:r.type})}})(n):null,w0=({content:n})=>{const[e,t]=m.useState(),[r,o]=m.useState(!1);return m.useEffect(()=>{try{o(!1);const s=JSON.parse(n);t(s)}catch(s){o(!0),console.error(`Can not parse Prose format: ${s}`)}},[n]),r?y.jsx("div",{className:"error",children:"ОШИБКА"}):y.jsx(Y,{node:e,className:"ProseViewer"})},M0=({content:n})=>{const e=m.useRef(null),[t,r]=m.useState(!1);return m.useEffect(()=>{var o;try{r(!1);const s=be.fromJSON(Nt,JSON.parse(n)),i=$e.fromSchema(Nt).serializeFragment(s.content);(o=e.current)==null||o.appendChild(i)}catch(s){r(!0),console.error(`Can not parse Prose format: ${s}`)}},[e,n]),y.jsx("div",{ref:e,className:"ProseViewer",children:t&&y.jsx("div",{className:"error",children:"ОШИБКА"})})};G.DOM=M0,G.Editor=o0,G.Notes=Hb,G.Viewer=w0,Object.defineProperty(G,Symbol.toStringTag,{value:"Module"})});
|
|
65
|
+
*/var Tu;function sb(){return Tu||(Tu=1,process.env.NODE_ENV!=="production"&&function(){function n(s){var i=s,l=s;if(s.alternate)for(;i.return;)i=i.return;else{s=i;do i=s,i.flags&4098&&(l=i.return),s=i.return;while(s)}return i.tag===3?l:null}function e(s){if(n(s)!==s)throw Error("Unable to find node on an unmounted component.")}function t(s){var i=s.alternate;if(!i){if(i=n(s),i===null)throw Error("Unable to find node on an unmounted component.");return i!==s?null:s}for(var l=s,a=i;;){var c=l.return;if(c===null)break;var u=c.alternate;if(u===null){if(a=c.return,a!==null){l=a;continue}break}if(c.child===u.child){for(u=c.child;u;){if(u===l)return e(c),s;if(u===a)return e(c),i;u=u.sibling}throw Error("Unable to find node on an unmounted component.")}if(l.return!==a.return)l=c,a=u;else{for(var f=!1,d=c.child;d;){if(d===l){f=!0,l=c,a=u;break}if(d===a){f=!0,a=c,l=u;break}d=d.sibling}if(!f){for(d=u.child;d;){if(d===l){f=!0,l=u,a=c;break}if(d===a){f=!0,a=u,l=c;break}d=d.sibling}if(!f)throw Error("Child was not found in either parent set. This indicates a bug in React related to the return pointer. Please file an issue.")}}if(l.alternate!==a)throw Error("Return fibers should always be each others' alternates. This error is likely caused by a bug in React. Please file an issue.")}if(l.tag!==3)throw Error("Unable to find node on an unmounted component.");return l.stateNode.current===l?s:i}function r(s){var i=s.tag;if(i===5||i===26||i===27||i===6)return s;for(s=s.child;s!==null;){if(i=r(s),i!==null)return i;s=s.sibling}return null}function o(s){var i=s.tag;if(i===5||i===26||i===27||i===6)return s;for(s=s.child;s!==null;){if(s.tag!==4&&(i=o(s),i!==null))return i;s=s.sibling}return null}Te.doesFiberContain=function(s,i){for(var l=s.alternate;i!==null;){if(i===s||i===l)return!0;i=i.return}return!1},Te.findCurrentFiberUsingSlowPath=t,Te.findCurrentHostFiber=function(s){return s=t(s),s!==null?r(s):null},Te.findCurrentHostFiberWithNoPortals=function(s){return s=t(s),s!==null?o(s):null},Te.getContainerFromFiber=function(s){return s.tag===3?s.stateNode.containerInfo:null},Te.getNearestMountedFiber=n,Te.getSuspenseInstanceFromFiber=function(s){if(s.tag===13){var i=s.memoizedState;if(i===null&&(s=s.alternate,s!==null&&(i=s.memoizedState)),i!==null)return i.dehydrated}return null},Te.isFiberMounted=function(s){return n(s)===s},Te.isFiberSuspenseAndTimedOut=function(s){var i=s.memoizedState;return s.tag===13&&i!==null&&i.dehydrated===null},Te.isMounted=function(s){return(s=s._reactInternals)?n(s)===s:!1}}()),Te}process.env.NODE_ENV==="production"?Us.exports=ob():Us.exports=sb();var ib=Us.exports;function lb(n){return n._reactInternals}function P0(n){return n}function ab(n){const e=lb(n);if(e===void 0){if(typeof n.render=="function")throw new Error("Unable to find node on an unmounted component.");{const r=Object.keys(n).join(",");throw new Error(`Argument appears to not be a ReactComponent. Keys: ${r}`)}}const t=ib.findCurrentHostFiber(e);return t===null?null:t.stateNode}function cb(n){return ab(n)}function ub(n,e){if(n===e)return!0;if(!n||!e)return!1;const t=Object.keys(n),r=Object.keys(e),o=t.length;if(r.length!==o)return!1;for(let s=0;s<o;s++){const i=t[s];if(n[i]!==e[i]||!Object.prototype.hasOwnProperty.call(e,i))return!1}return!0}class fb extends m.Component{constructor(){super(...arguments);j(this,"viewDescRef",null);j(this,"renderRef",null)}updateEffect(){const{view:t,decorations:r,siblingsRef:o,parentRef:s,getPos:i,node:l}=this.props,a=cb(this);if(!a){if(!(t!=null&&t.composing))return;this.viewDescRef=new ro(s.current,()=>i.current(),document.createElement("div"),document.createTextNode(l.text??""),l.text??"");return}let c=a;for(;c.firstChild;)c=c.firstChild;!this.viewDescRef||this.viewDescRef instanceof ro?this.viewDescRef=new Ay(void 0,[],()=>i.current(),l,r,H.empty,a,c):(this.viewDescRef.parent=s.current,this.viewDescRef.children=[],this.viewDescRef.node=l,this.viewDescRef.getPos=()=>i.current(),this.viewDescRef.outerDeco=r,this.viewDescRef.innerDeco=H.empty,this.viewDescRef.dom=a,this.viewDescRef.dom.pmViewDesc=this.viewDescRef,this.viewDescRef.nodeDOM=c),o.current.includes(this.viewDescRef)||o.current.push(this.viewDescRef),o.current.sort(Kt)}shouldComponentUpdate(t){return!ub(this.props,t)}componentDidMount(){this.updateEffect()}componentDidUpdate(){this.updateEffect()}componentWillUnmount(){const{siblingsRef:t}=this.props;if(this.viewDescRef&&t.current.includes(this.viewDescRef)){const r=t.current.indexOf(this.viewDescRef);t.current.splice(r,1)}}render(){const{view:t,getPos:r,node:o,decorations:s}=this.props;return t!=null&&t.composing&&t.state.selection.from>=r.current()&&t.state.selection.from<=r.current()+o.nodeSize?this.renderRef:(this.renderRef=s.reduce(oo,o.text),this.renderRef)}}function db(n){let{getPos:e}=n;const{siblingsRef:t,parentRef:r}=m.useContext(Ce),o=m.useRef(null),s=m.useRef(null);return J(()=>{const i=t.current;return()=>{if(o.current&&i.includes(o.current)){const l=i.indexOf(o.current);i.splice(l,1)}}},[t]),J(()=>{s.current&&(o.current?(o.current.parent=r.current,o.current.dom=s.current,o.current.getPos=()=>e.current()):o.current=new er(r.current,[],()=>e.current(),s.current,null),t.current.includes(o.current)||t.current.push(o.current),t.current.sort(Kt))}),m.createElement("br",{ref:s,className:"ProseMirror-trailingBreak"})}function hb(n){let{widget:e,getPos:t}=n;const{siblingsRef:r,parentRef:o}=m.useContext(Ce),s=m.useRef(null),i=m.useRef(()=>t.current()).current,l=m.useRef(null);J(()=>{const c=r.current;return()=>{if(s.current&&c.includes(s.current)){const u=c.indexOf(s.current);c.splice(u,1)}}},[r]),J(()=>{l.current&&(s.current?(s.current.parent=o.current,s.current.widget=e,s.current.getPos=()=>t.current(),s.current.dom=l.current):s.current=new Ks(o.current,()=>t.current(),e,l.current),r.current.includes(s.current)||r.current.push(s.current),r.current.sort(Kt))});const{Component:a}=e.type;return a&&m.createElement(a,{ref:l,widget:e,getPos:i,contentEditable:!1})}function oo(n,e){const{nodeName:t,...r}=e.type.attrs,o=Mu(r);return t||typeof n=="string"?m.createElement(t??"span",o,n):m.cloneElement(n,wu(n.props,o))}function Qs(n,e){var t,r,o;return n.type===e.type&&n.marks.every(s=>s.isInSet(e.marks))&&e.marks.every(s=>s.isInSet(n.marks))&&n.key===e.key&&(n.type==="node"?((t=n.outerDeco)==null?void 0:t.length)===((r=e.outerDeco)==null?void 0:r.length)&&((o=n.outerDeco)==null?void 0:o.every(s=>{var i;return(i=e.outerDeco)==null?void 0:i.some(l=>s.from===l.from&&s.to&&l.to&&s.type.eq(l.type))}))&&n.innerDeco.eq(e.innerDeco):!0)&&n.node===e.node&&n.widget===e.widget}const pb=m.memo(function(e){let{child:t,getInnerPos:r}=e;const{view:o}=m.useContext(wt),s=m.useRef(()=>r.current()+t.offset);return s.current=()=>r.current()+t.offset,t.type==="widget"?m.createElement(hb,{key:t.key,widget:t.widget,getPos:s}):t.type==="native-widget"?m.createElement(Gy,{key:t.key,widget:t.widget,getPos:s}):t.node.isText?m.createElement(Ce.Consumer,{key:t.key},i=>{let{siblingsRef:l,parentRef:a}=i;return m.createElement(fb,{view:o,node:t.node,getPos:s,siblingsRef:l,parentRef:a,decorations:t.outerDeco})}):m.createElement(vu,{key:t.key,node:t.node,getPos:s,outerDeco:t.outerDeco,innerDeco:t.innerDeco})}),mb=m.memo(function(e){let{childViews:t,getInnerPos:r}=e;const o=t[0],s=m.useRef(()=>r.current()+o.offset);s.current=()=>r.current()+o.offset;const i=o.marks[0];return i?m.createElement(Eu,{getPos:s,key:o.key,mark:i},m.createElement(Zs,{key:o.key,getInnerPos:r,childViews:t.map(l=>({...l,marks:l.marks.slice(1)}))})):m.createElement(m.Fragment,null,t.map(l=>m.createElement(pb,{key:l.key,child:l,getInnerPos:r})))}),Zs=m.memo(function(e){let{getInnerPos:t,childViews:r}=e;const o=r.reduce((s,i)=>{var c;const l=s[s.length-1];if(!l)return[[i]];const a=l[l.length-1];return a?!i.marks.length&&!a.marks.length||i.marks.length&&a.marks.length&&((c=i.marks[0])!=null&&c.eq(a.marks[0]))?[...s.slice(0,s.length-1),[...l.slice(0,l.length),i]]:[...s,[i]]:[...s.slice(0,s.length),[i]]},[]);return m.createElement(m.Fragment,null,o.map(s=>{const i=s[0];return i?m.createElement(mb,{key:i.key,childViews:s,getInnerPos:t}):null}))});function ei(n,e,t,r,o,s){const i=n+e,l=r==null?void 0:r.get(i);if(t==="widget"||t==="native-widget")return o.type.spec.key?o.type.spec.key:(console.warn(`Widget at position ${i} doesn't have a key specified. This may cause issues.`),`${l}-${s}`);if(l)return l;const a=n-1,c=r==null?void 0:r.get(a);return c?`${c}-${e}`:i}function gb(n,e){if(!e||e.widget.type.side>=0||!n||!n.node.isInline)return;const t=n.marks;e.marks=e.marks.reduce((r,o)=>o.addToSet(r),t)}function yb(n,e){if(!e.node.isInline)return;const t=e.marks;for(let r=n.length-1;r>=0;r--){const o=n[r];o.widget.type.side<0||(o.marks=o.marks.reduce((s,i)=>i.addToSet(s),t))}}const bb=m.memo(function(e){let{child:t,getInnerPos:r}=e;const o=m.useRef(()=>r.current()+t.offset);return o.current=()=>r.current()+t.offset,t.type==="node"?t.marks.reduce((s,i)=>m.createElement(Eu,{getPos:o,mark:i},s),m.createElement(vu,{key:t.key,outerDeco:t.outerDeco,node:t.node,innerDeco:t.innerDeco,getPos:o})):m.createElement(Zs,{key:t.key,childViews:[t],getInnerPos:r})});function xb(n,e){return n.length?n.every(t=>t.type!=="node"||t.node.isInline)?[m.createElement(Zs,{key:n[0].key,childViews:n,getInnerPos:e})]:n.map(t=>m.createElement(bb,{key:t.key,child:t,getInnerPos:e})):[]}const tr=m.memo(function(e){let{getPos:t,node:r,innerDecorations:o}=e;const s=qy(),i=m.useRef(()=>t.current()+1),l=m.useRef(new Map).current;if(!r)return null;const a=new Set;let c=[],u=null;_y(r,o,(h,b,g,x)=>{const S=h.type.spec.marks??[];let w;if(b){w=ei(i.current(),g,"native-widget",s==null?void 0:s.posToKey,h,x);const T={type:"native-widget",widget:h,marks:S,offset:g,index:x,key:w},M=l.get(w);M&&Qs(M,T)?M.offset=g:l.set(w,T),a.add(w)}else{w=ei(i.current(),g,"widget",s==null?void 0:s.posToKey,h,x);const T={type:"widget",widget:h,marks:S,offset:g,index:x,key:w},M=l.get(w);M&&Qs(M,T)?M.offset=g:l.set(w,T),a.add(w)}const D=l.get(w);c.push(D),gb(u,l.get(w))},(h,b,g,x)=>{const S=ei(i.current(),x,"node",s==null?void 0:s.posToKey),w={type:"node",node:h,marks:h.marks,innerDeco:g,outerDeco:b,offset:x,key:S},D=l.get(S);D&&Qs(D,w)?(D.offset=x,u=D):(l.set(S,w),u=w),a.add(S),yb(c,u),c=[]});for(const h of l.keys())a.has(h)||l.delete(h);const f=Array.from(l.values()).sort((h,b)=>h.offset-b.offset),d=xb(f,i),p=f[f.length-1];return(!p||p.type!=="node"||p.node.isInline&&!p.node.isText||/\n$/.test(p.node.text))&&d.push(m.createElement(rb,{getPos:i,key:"trailing-hack-img"}),m.createElement(db,{getPos:i,key:"trailing-hack-br"})),m.createElement(m.Fragment,null,d)}),ti={current(){return-1}},kb=m.memo(m.forwardRef(function(e,t){let{className:r,node:o,innerDeco:s,outerDeco:i,as:l,viewDesc:a,...c}=e;const u=m.useRef(null);m.useImperativeHandle(t,()=>u.current,[]);const{childDescriptors:f,nodeViewDescRef:d}=Gs(o,()=>ti.current(),u,u,s,i,a),p=m.useMemo(()=>({parentRef:d,siblingsRef:f}),[f,d]),h={...c,ref:u,className:r,suppressContentEditableWarning:!0},b=l?m.cloneElement(l,h,m.createElement(Ce.Provider,{value:p},m.createElement(tr,{getPos:ti,node:o,innerDecorations:s}))):m.createElement("div",h,m.createElement(Ce.Provider,{value:p},m.createElement(tr,{getPos:ti,node:o,innerDecorations:s})));if(!o)return b;const g=i.filter(S=>!S.inline);return g.length?g.reduce(oo,b):b})),Au=m.createContext(null);function Sb(n,e){let{as:t,...r}=n;const o=m.useRef([]),s=m.useRef(null),{setMount:i,...l}=m.useContext(Au),a=m.useRef(void 0);m.useImperativeHandle(e,()=>s.current,[]);const c=m.useMemo(()=>({parentRef:a,siblingsRef:o}),[o,a]);return m.createElement(Ce.Provider,{value:c},m.createElement(kb,{ref:u=>{s.current=u,i(u)},...r,...l,as:t}))}const Pu=m.forwardRef(Sb),Cb=[];function wb(n){var h;let{className:e,children:t,nodeViews:r,customNodeViews:o,...s}=n;const[i,l]=m.useState(null),{editor:a,state:c}=Fy(i,{...s,nodeViews:o}),u=a.view?oy(a.view,a.cursorWrapper):H.empty,f=a.view?ey(a.view):Cb,d=m.useMemo(()=>({nodeViews:r??{}}),[r]),p=m.useMemo(()=>{var b;return{className:e,setMount:l,node:(b=a.view)==null?void 0:b.state.doc,innerDeco:u,outerDeco:f,viewDesc:a.docViewDescRef.current}},[e,a.docViewDescRef,(h=a.view)==null?void 0:h.state.doc,u,f]);return m.createElement(wt.Provider,{value:a},m.createElement(Zg.Provider,{value:c},m.createElement(Jc.Provider,{value:d},m.createElement(Au.Provider,{value:p},t))))}function Iu(n){return m.createElement(Ly,null,m.createElement(wb,n))}function re(n){const e=m.useRef(n),{view:t}=m.useContext(wt);return Ke(()=>{e.current=n},[n]),m.useCallback(function(){for(var r=arguments.length,o=new Array(r),s=0;s<r;s++)o[s]=arguments[s];return e.current(t,...o)},[t])}function Vu(n){const e=m.useContext(Du),t=re(n);Ke(()=>{e(t)},[e,t])}const Ru=n=>[Qg(),Ro({Tab:Lc(1),"Shift-Tab":Lc(-1)}),gm(n.schema),Ro(um(n.schema)),Ro(Yd),Gd({color:"#F00",width:2}),Vp(),wd(),ym(n),py()],Mb=["p",0],Nb=["blockquote",0],Eb=["hr"],Db=["pre",["code",0]],vb=["br"],Ob={doc:{content:"block+"},paragraph:{content:"inline*",group:"block",parseDOM:[{tag:"p"}],toDOM(){return Mb}},blockquote:{content:"block+",group:"block",defining:!0,parseDOM:[{tag:"blockquote"}],toDOM(){return Nb}},horizontal_rule:{group:"block",parseDOM:[{tag:"hr"}],toDOM(){return Eb}},heading:{attrs:{level:{default:1,validate:"number"}},content:"inline*",group:"block",defining:!0,parseDOM:[{tag:"h1",attrs:{level:1}},{tag:"h2",attrs:{level:2}},{tag:"h3",attrs:{level:3}},{tag:"h4",attrs:{level:4}},{tag:"h5",attrs:{level:5}},{tag:"h6",attrs:{level:6}}],toDOM(n){return["h"+n.attrs.level,0]}},code_block:{content:"text*",marks:"",group:"block",code:!0,defining:!0,parseDOM:[{tag:"pre",preserveWhitespace:"full"}],toDOM(){return Db}},text:{group:"inline"},image:{inline:!0,attrs:{src:{validate:"string"},alt:{default:null,validate:"string|null"},title:{default:null,validate:"string|null"}},group:"inline",draggable:!0,parseDOM:[{tag:"img[src]",getAttrs(n){return{src:n.getAttribute("src"),title:n.getAttribute("title"),alt:n.getAttribute("alt")}}}],toDOM(n){let{src:e,alt:t,title:r}=n.attrs;return["img",{src:e,alt:t,title:r}]}},hard_break:{inline:!0,group:"inline",selectable:!1,parseDOM:[{tag:"br"}],toDOM(){return vb}}},Tb=["em",0],Ab=["strong",0],Pb=["code",0],Ib={link:{attrs:{href:{validate:"string"},title:{default:null,validate:"string|null"}},inclusive:!1,parseDOM:[{tag:"a[href]",getAttrs(n){return{href:n.getAttribute("href"),title:n.getAttribute("title")}}}],toDOM(n){let{href:e,title:t}=n.attrs;return["a",{href:e,title:t},0]}},em:{parseDOM:[{tag:"i"},{tag:"em"},{style:"font-style=italic"},{style:"font-style=normal",clearMark:n=>n.type.name=="em"}],toDOM(){return Tb}},strong:{parseDOM:[{tag:"strong"},{tag:"b",getAttrs:n=>n.style.fontWeight!="normal"&&null},{style:"font-weight=400",clearMark:n=>n.type.name=="strong"},{style:"font-weight",getAttrs:n=>/^(bold(er)?|[5-9]\d{2,})$/.test(n)&&null}],toDOM(){return Ab}},code:{code:!0,parseDOM:[{tag:"code"}],toDOM(){return Pb}}},zu=new xr({nodes:Ob,marks:Ib}),$u=zu.spec.marks.append({underline:{parseDOM:[{tag:"u"},{style:"font-style=underline"}],toDOM(){return["u",0]}},strikethrough:{parseDOM:[{tag:"s"},{style:"font-style=strike"},{style:"font-style=strikethrough"}],toDOM(){return["s",0]}}}),so="https://dailytelefrag.ru/api",ni="https://dailytelefrag.ru/error_image.png",ri="https://dailytelefrag.ru/error_embed.png",nr=(n,e)=>{try{const t=new URL(n);if(t.hostname!=="vkvideo.ru"&&t.hostname!=="vk.com")throw new Error;let r,o;if(t.pathname==="/video_ext.php")r=t.searchParams.get("id"),o=t.searchParams.get("oid");else if(t.pathname.startsWith("/video"))[o,r]=t.pathname.slice(6).split("_");else throw new Error;if(!r||!o)throw new Error;return e?`https://vkvideo.ru/video_ext.php?oid=${o}&id=${r}&hd=2`:!0}catch{return e?"":!1}},rr=(n,e)=>{try{const t=new URL(n);if(t.hostname!=="rutube.ru")throw new Error;let r;if(t.pathname.startsWith("/video/"))r=t.pathname.split("/")[2];else if(t.pathname.startsWith("/play/embed/"))r=t.pathname.split("/")[3];else throw new Error;if(!r)throw new Error;return e?`https://rutube.ru/play/embed/${r}`:!0}catch{return e?"":!1}},or=(n,e)=>{try{const t=new URL(n);if(t.hostname!=="youtube.com"&&t.hostname!=="www.youtube.com"&&t.hostname!=="youtu.be")throw new Error;if(t.hostname==="youtu.be")return e?`https://youtube.com/embed${t.pathname}`:!0;let r;if(t.pathname==="/watch")r=t.searchParams.get("v");else if(t.pathname.startsWith("/live/"))r=t.pathname.split("/")[2];else if(t.pathname.startsWith("/embed/"))r=t.pathname.split("/")[2];else throw new Error;if(!r)throw new Error;return e?`https://youtube.com/embed/${r}`:!0}catch{return e?"":!1}},oi=n=>{try{const e=new URL(n);switch(e.hostname){case"vkvideo.ru":case"vk.com":return nr(e,!0)+"";case"rutube.ru":return rr(e,!0)+"";case"youtube.com":case"www.youtube.com":case"youtu.be":return or(e,!0)+"";default:throw new Error}}catch{return""}},Vb={atom:!0,attrs:{fid:{default:null,validate:"string|null|number"},src:{default:null,validate:"string|null"},alt:{default:null,validate:"string|null"},title:{default:null,validate:"string|null"}},group:"block",parseDOM:[{tag:"img[src]",getAttrs(n){return{fid:n.getAttribute("fid"),src:n.getAttribute("src"),alt:n.getAttribute("alt"),title:n.getAttribute("title")}}}],toDOM(n){let{fid:e,src:t,alt:r,title:o}=n.attrs;return e&&(t=`${so}/files/${e}`),t||(t=ni),["div",{title:o,class:"image"},["img",{fid:e,src:t,alt:r,title:o}]]}},Rb={atom:!0,attrs:{title:{default:null,validate:"string|null"},src:{validate:n=>{if(typeof n!="string"){if(Array.isArray(n)){n.forEach(e=>{if(typeof e!="string")throw new Error("One of the video sources is not a string")});return}throw new Error("Video source must be a string or array of strings")}}}},group:"block",parseDOM:[{tag:"iframe[src]",getAttrs(n){return{src:n.getAttribute("src"),title:n.getAttribute("title")}}}],toDOM(n){const{src:e,title:t}=n.attrs,r="fullscreen; accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share",o=Array.isArray(e)?e[0]:e;return oi(o)?["div",{title:t,class:"video"},["iframe",{src:o,title:t,allow:r}]]:["div",{title:t,class:"image"},["img",{src:ri}]]}},zb={content:"inline*",group:"block",attrs:{align:{default:null,validate:"string|null"}},parseDOM:[{tag:"p",getAttrs(n){let e=n.getAttribute("align");return e!=="right"&&e!=="center"&&e!=="justify"&&(e=null),{align:e}}}],toDOM(n){const{align:e}=n.attrs;return["p",{align:e},0]}},$b={attrs:{level:{default:1,validate:"number"}},content:"inline*",marks:"underline strikethrough",group:"block",parseDOM:[{tag:"h1",attrs:{level:1}},{tag:"h2",attrs:{level:2}},{tag:"h3",attrs:{level:3}},{tag:"h4",attrs:{level:4}},{tag:"h5",attrs:{level:5}},{tag:"h6",attrs:{level:6}}],toDOM(n){return["h"+n.attrs.level,0]}},jb={atom:!0,content:"image*",group:"block",toDOM(){return["div",{class:"carousel"},0]}},ju=zu.spec.nodes.remove("image").append({image:Vb,video:Rb}),io=new xr({nodes:ju.remove("horizontal_rule").remove("heading"),marks:$u}),Bb=ju.remove("heading").remove("paragraph").prepend({paragraph:zb}).append({heading:$b}).append({carousel:jb}).append(hg({tableGroup:"block",cellContent:"(paragraph | ordered_list | bullet_list)+",cellAttributes:{halign:{default:null,getFromDOM(n){const e=n.getAttribute("align")||null;return e==="left"||e==="right"||e==="center"?e:null},setDOMAttr(n,e){n&&(e.style=(e.style||"")+`text-align: ${n};`)}},valign:{default:null,getFromDOM(n){const e=n.style.verticalAlign||null;return e==="top"||e==="bottom"||e==="middle"?e:null},setDOMAttr(n,e){n&&(e.style=(e.style||"")+`vertical-align: ${n};`)}}}})),Nt=new xr({nodes:Hp(Bb,"(paragraph | ordered_list | bullet_list)+","block"),marks:$u}),Fb=n=>{if(n)try{const e=be.fromJSON(Nt,JSON.parse(n)),t=$e.fromSchema(Nt).serializeFragment(e.content);return Pt.fromSchema(io).parse(t)}catch(e){console.error(`Can not convert content to simple schema: ${e}`)}},sr=({ref:n,item:e})=>{const[t,r]=m.useState(!0),[o,s]=m.useState(!1),[i,l]=m.useState(!1);Ke(c=>{c&&(r(e.isActive&&e.isActive(c.state)),l(e.isSelected&&!e.isSelected(c.state)),e.isDisabled?s(e.isDisabled(c.state)):s(!e.command(c.state)))});const a=re(c=>{c&&(o||e.command(c.state,c.dispatch,c),c.focus())});return i?null:y.jsx("div",{ref:n,className:`MenuItem ${t?"active":""} ${o?"disabled":""}`,onClick:c=>{c.stopPropagation(),c.preventDefault(),a()},children:e.icon})},Bu=({schema:n})=>{const[e,t]=m.useState(void 0),[r,o]=m.useState(void 0);return m.useEffect(()=>{if(t(void 0),o(void 0),n.nodes.paragraph){const s=n.nodes.paragraph;t({icon:y.jsx(N.Icons.Type,{}),command:on(s)})}if(n.nodes.code_block){const s=n.nodes.code_block;o({icon:y.jsx(N.Icons.CodeXml,{}),command:on(s)})}},[n]),y.jsxs(y.Fragment,{children:[e&&y.jsx(sr,{item:e}),r&&y.jsx(sr,{item:r})]})},ir=({items:n})=>y.jsx("div",{className:"MenuBlock",children:n.map((e,t)=>y.jsx(sr,{item:e},t))}),Lb=({schema:n,isOpen:e,onClose:t})=>{const r=re((o,s)=>{o&&(ke(n.marks.link,{href:s})(o.state,o.dispatch),t(),o.focus())});return y.jsx(N.Prompt,{title:"Введите URL для ссылки",isOpen:e,onCancel:t,onSubmit:r})},Fu=({schema:n})=>{const[e,t]=m.useState([]),[r,o]=m.useState(!1);return m.useEffect(()=>{const s=[];if(n.marks.strong){const i=n.marks.strong;s.push({icon:y.jsx(N.Icons.Bold,{}),command:ke(i),isActive:l=>Jt(l,i)})}if(n.marks.em){const i=n.marks.em;s.push({icon:y.jsx(N.Icons.Italic,{}),command:ke(i),isActive:l=>Jt(l,i)})}if(n.marks.underline){const i=n.marks.underline;s.push({icon:y.jsx(N.Icons.Underline,{}),command:ke(i),isActive:l=>Jt(l,i)})}if(n.marks.strikethrough){const i=n.marks.strikethrough;s.push({icon:y.jsx(N.Icons.Strikethrough,{}),command:ke(i),isActive:l=>Jt(l,i)})}if(n.marks.code){const i=n.marks.code;s.push({icon:y.jsx(N.Icons.Code,{}),command:ke(i),isActive:l=>Jt(l,i)})}if(n.marks.link){const i=n.marks.link;s.push({icon:y.jsx(N.Icons.Link,{}),isActive:l=>Jt(l,i),isDisabled:l=>l.selection.empty?!0:!ke(i)(l),command:(l,a,c)=>(Jt(l,i)?(ke(i)(l,a),c==null||c.focus()):o(!0),!0)})}t(s)},[n]),e.length<1?null:y.jsxs(y.Fragment,{children:[y.jsx(ir,{items:e}),y.jsx(Lb,{isOpen:r,schema:n,onClose:()=>o(!1)})]})};function Jt(n,e){let{from:t,$from:r,to:o,empty:s}=n.selection;return s?!!e.isInSet(n.storedMarks||r.marks()):n.doc.rangeHasMark(t,o,e)}const Lu=()=>y.jsxs("div",{className:"MenuBlock",children:[y.jsx(sr,{item:{icon:y.jsx(N.Icons.Undo,{}),command:Po}}),y.jsx(sr,{item:{icon:y.jsx(N.Icons.Redo,{}),command:Dr}})]}),Wu=({schema:n})=>{const[e,t]=m.useState([]);return m.useEffect(()=>{const r=[];if(n.nodes.bullet_list){const o=n.nodes.bullet_list;r.push({icon:y.jsx(N.Icons.List,{}),command:(s,i)=>jr(o)(s,i)})}if(n.nodes.ordered_list){const o=n.nodes.ordered_list;r.push({icon:y.jsx(N.Icons.ListOrdered,{}),command:(s,i)=>jr(o)(s,i)})}if(n.nodes.blockquote){const o=n.nodes.blockquote;r.push({icon:y.jsx(N.Icons.Quote,{}),command:(s,i)=>Nl(o)(s,i)})}t(r)},[n]),e.length<1?null:y.jsx(ir,{items:e})},_u=({pos:n,isOpen:e,onClose:t})=>{const[r,o]=m.useState(""),[s,i]=m.useState(),[l,a]=m.useState(""),[c,u]=m.useState(!1);m.useEffect(()=>{o(""),a(""),i(void 0)},[e]),Ke(d=>{if(!d||!e)return;const p=tt.getState(d.state);u(p.upload!==void 0)},[e]);const f=re(d=>{d&&(c?xm(d,s,l,n):km(d,r,l,n),d.focus(),t())});return y.jsxs(N.Modal,{isOpen:e,onClose:t,children:[y.jsx("h1",{children:"Вставка картинки"}),y.jsxs(N.Form,{submit:"Вставить",submitType:"Success",onSubmit:f,onCancel:t,children:[c?y.jsx(N.Image,{id:"image",value:s,onChange:i,text:y.jsxs("span",{children:[y.jsx(N.Icons.Image,{}),y.jsx("br",{}),"Выберите файл"]}),required:!0,label:"Картинка"}):y.jsx(N.Input,{id:"href",value:r,onChange:o,required:!0,label:"Ссылка на картинку"}),y.jsx(N.Input,{id:"value",value:l,onChange:a,label:"Подпись"})]})]})},Wb=({schema:n,isOpen:e,onClose:t})=>{const[r,o]=m.useState(""),[s,i]=m.useState(""),[l,a]=m.useState(""),[c,u]=m.useState(""),[f,d]=m.useState(""),[p,h]=m.useState(!0);m.useEffect(()=>{o(""),i(""),a(""),u(""),d(""),n.nodes.table?h(!1):h(!0)},[e]);const b=re(x=>{const S=n.nodes.video;if(!x||!S)return;let w=[];if(p){if(w=oi(r),!w)return}else{if(!s&&!l&&!c)return;const D=rr(l,!0)+"",T=or(c,!0)+"",M=nr(s,!0)+"";D&&w.push(D),T&&w.push(T),M&&w.push(M)}x.dispatch(x.state.tr.replaceSelectionWith(S.create({src:w,title:f}))),x.focus(),t()}),g=()=>p?!!oi(r):l&&!rr(l)||c&&!or(c)||s&&!nr(s)?!1:!!(l||c||s);return n.nodes.video?y.jsxs(N.Modal,{isOpen:e,onClose:t,children:[y.jsx("h1",{children:"Вставка видео"}),y.jsxs(N.Form,{submit:"Вставить",submitType:"Success",onSubmit:b,onCancel:t,children:[p?y.jsx(N.Input,{id:"url",value:r,onChange:o,label:"Ссылка на видео",bottom:"Поддерживаются VK Video, RuTube и YouTube",required:!g()}):y.jsxs(y.Fragment,{children:[y.jsx(N.Input,{id:"vkvideo",value:s,onChange:i,label:"Ссылка на VK Video",required:!g()}),y.jsx(N.Input,{id:"rutube",value:l,onChange:a,label:"Ссылка на RuTube",required:!g()}),y.jsx(N.Input,{id:"youtube",value:c,onChange:u,label:"Ссылка на YouTube",required:!g()})]}),y.jsx(N.Input,{id:"value",value:f,onChange:d,label:"Подпись"})]})]}):null},qu=({schema:n})=>{const[e,t]=m.useState([]),[r,o]=m.useState(!1),[s,i]=m.useState(!1);return m.useEffect(()=>{const l=[];if(n.nodes.image){const a=n.nodes.image;l.push({icon:y.jsx(N.Icons.Image,{}),isDisabled:c=>!si(c,a),command:()=>(o(!0),!0)})}if(n.nodes.video){const a=n.nodes.video;l.push({icon:y.jsx(N.Icons.Film,{}),isDisabled:c=>!si(c,a),command:()=>(i(!0),!0)})}if(n.nodes.horizontal_rule){const a=n.nodes.horizontal_rule;l.push({icon:y.jsx(N.Icons.FlipVertical,{}),isDisabled:c=>!si(c,a),command:(c,u)=>u?(u(c.tr.replaceSelectionWith(a.create())),!0):!1})}n.nodes.table&&l.push({icon:y.jsx(N.Icons.Table,{}),isDisabled:ve,command:_b()}),t(l)},[n]),e.length<1?null:y.jsxs(y.Fragment,{children:[y.jsx(ir,{items:e}),y.jsx(_u,{isOpen:r,onClose:()=>o(!1)}),y.jsx(Wb,{isOpen:s,schema:n,onClose:()=>i(!1)})]})},si=(n,e)=>{let t=n.selection.$from;for(let r=t.depth;r>=0;r--){let o=t.index(r);if(t.node(r).canReplaceWith(o,o,e))return!0}return!1};function _b(){return(n,e)=>{const t=n.tr.selection.anchor+1,r=n.tr,o=n.schema.nodes.table_cell.createAndFill(),s=n.schema.nodes.table.create(null,C.fromArray([n.schema.nodes.table_row.create(null,C.fromArray([o,o,o])),n.schema.nodes.table_row.create(null,C.fromArray([o,o,o]))]));return e&&e(r.replaceSelectionWith(s).scrollIntoView().setSelection(V.near(r.doc.resolve(t)))),!0}}const Hu=({schema:n})=>n.nodes.carousel?y.jsx(ir,{items:[{icon:y.jsx(N.Icons.JoinUp,{}),command:Sl},{icon:y.jsx(N.Icons.IndentDecrease,{}),command:$o},{icon:y.jsx(N.Icons.SquareDashed,{}),command:Bo}]}):y.jsx(ir,{items:[{icon:y.jsx(N.Icons.IndentDecrease,{}),command:$o},{icon:y.jsx(N.Icons.SquareDashed,{}),command:Bo}]}),qb=({schema:n})=>y.jsxs("div",{className:"SimpleMenuBar",children:[y.jsx("div",{className:"MenuBlock",children:y.jsx(Bu,{schema:n})}),y.jsx(Fu,{schema:n}),y.jsx(qu,{schema:n}),y.jsx(Wu,{schema:n}),y.jsx(Hu,{schema:n}),y.jsx(Lu,{})]}),Ku=m.forwardRef(function({children:e,nodeProps:t,...r},o){const[s,i]=m.useState(t.node.attrs.alt??""),[l,a]=m.useState(t.node.attrs.title??""),[c,u]=m.useState(!1),[f,d]=m.useState("");Vu((x,S)=>x?!(S instanceof MouseEvent):!1),Ke(x=>{if(d(""),u(!1),!x||!x.state.schema.nodes.carousel)return;const S=t.getPos(),w=x.state.doc.resolve(S).parent;if(u(w.type.name!=="carousel"),w.type.name==="carousel"){let D=0;w.forEach((T,M)=>{T===t.node&&(D=M+1)}),d(D?`${D} / ${w.childCount}`:"")}});const p=re((x,S)=>{if(!x)return;i(S);const w=x.state.tr,D=t.getPos();x.dispatch(w.setNodeMarkup(D,null,{...t.node.attrs,alt:S})),x.focus()}),h=re((x,S)=>{if(!x)return;a(S);const w=x.state.tr,D=t.getPos();x.dispatch(w.setNodeMarkup(D,null,{...t.node.attrs,title:S})),x.focus()}),b=re(x=>{if(!x)return;const S=t.getPos(),w=t.node.nodeSize,D=t.node.attrs,T=x.state.schema,M=T.nodes.carousel.create(null,T.nodes.image.create(D));x.dispatch(x.state.tr.replaceWith(S,S+w,M))}),g=re(x=>{if(!x)return;const S=x.state.tr,w=t.getPos(),D=t.node.nodeSize;x.dispatch(S.delete(w,w+D))});return y.jsxs("div",{...r,ref:o,className:"image",title:t.node.attrs.title,children:[y.jsxs("div",{className:"image-buttons",children:[c&&y.jsx("div",{onClick:b,className:"text-button",children:"Сделать карусель"}),f&&y.jsx("div",{className:"text-button",children:f}),y.jsx("div",{onClick:g,children:y.jsx(N.Icons.Trash,{})})]}),y.jsx("div",{className:"image-title",children:y.jsx(N.Editable,{value:s,placeholder:"Alt: описание изображения (не обязательно)",onChange:p,empty:!0,style:{textAlign:"center",cursor:"text"}})}),y.jsx("img",{title:t.node.attrs.title,alt:t.node.attrs.alt,src:t.node.attrs.fid?`${so}/files/${t.node.attrs.fid}`:t.node.attrs.src}),y.jsx("div",{className:"image-title",children:y.jsx(N.Editable,{value:l,placeholder:"Title: подпись под изображением (не обязательно)",onChange:h,empty:!0,style:{textAlign:"center",cursor:"text"}})})]})}),Ju=m.forwardRef(function({children:e,nodeProps:t,...r},o){const[s,i]=m.useState(""),[l,a]=m.useState(""),[c,u]=m.useState(""),[f,d]=m.useState(""),[p,h]=m.useState(t.node.attrs.title??""),b="fullscreen; accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share";Vu(()=>!0),m.useEffect(()=>{let x=t.node.attrs.src;typeof x=="string"&&(x=[x]),x.forEach(S=>{rr(S)?(i(S),a(S)):or(S)?(i(S),u(S)):nr(S)&&(i(S),d(S))})},[t]);const g=re((x,S)=>{if(!x)return;h(S);const{$from:w,$to:D}=x.state.selection,T=w.blockRange(D);if(T){const M=x.state.doc;let I=x.state.tr;M.nodesBetween(T.start,T.end,(z,O)=>{z.type.name==="video"&&(I=I.setNodeMarkup(O,null,{...t.node.attrs,title:S}))}),x.dispatch(I)}x.focus()});return y.jsxs("div",{...r,ref:o,className:"video",title:t.node.attrs.title,children:[y.jsxs("div",{className:"video-switcher",children:[l&&y.jsx("div",{onClick:()=>i(l),className:s===l?"active":"",children:"RuTube"}),c&&y.jsx("div",{onClick:()=>i(c),className:s===c?"active":"",children:"YouTube"}),f&&y.jsx("div",{onClick:()=>i(f),className:s===f?"active":"",children:"VK Video"})]}),s?y.jsx("iframe",{src:s,allow:b}):y.jsx("img",{src:ri}),y.jsx("div",{className:"video-title",children:y.jsx(N.Editable,{value:p,placeholder:"Подпись под видео (не обязательно)",onChange:g,empty:!0,style:{textAlign:"center",cursor:"text"}})})]})}),Yu=({onSave:n,disabled:e=!1,notEmpty:t=!0})=>{const[r,o]=m.useState(!0),[s,i]=m.useState(!1);Ke(a=>{let c=!0;if(t){const u=a.state.doc;c=!!u.textBetween(0,u.content.size,void 0," ").length}o(c)});const l=re(async a=>{i(!0);try{let c;const u=Is(a.state);if(u){const d=a.state.apply(u.setMeta("addToHistory",!1));c=JSON.stringify(d.doc.toJSON())}else c=JSON.stringify(a.state.doc.toJSON());const f=await n({content:c,format:"prose"});if(f)throw new Error(f)}catch(c){console.error(`Can not save doc: ${c}`)}i(!1),a.focus()});return y.jsx(N.Button,{type:"Accent",disabled:e||!r||s,label:s?"Сохраняю":"Сохранить",size:"Small",onClick:l})},Hb=({title:n=!1,content:e,onSave:t,onCancel:r,onChange:o,onUpload:s})=>{const[i,l]=m.useState(""),[a,c]=m.useState();m.useEffect(()=>{const p=Ge.create({doc:Fb(e),schema:io,plugins:Ru({schema:io,upload:s})});c(p),n!==!1&&l(typeof n=="string"?n:"")},[n,e]);const u=()=>n!==!1?i.trim().length>0:!0,f=p=>{!t||!u()||t({...p,name:i})},d=()=>{r&&r()};return a?y.jsxs("div",{className:"ProseNotes",children:[n!==!1&&y.jsx("input",{className:"ProseNotesTitle",onChange:p=>l(p.currentTarget.value),value:i,placeholder:"Укажите заголовок"}),y.jsxs(Iu,{state:a,dispatchTransaction:p=>c(h=>{const b=h==null?void 0:h.apply(p);return b&&o&&o(!!Md(b)),b}),nodeViews:{image:Ku,video:Ju},children:[y.jsxs("div",{className:"ProseNotesContent",children:[y.jsx(qb,{schema:io}),y.jsx(Pu,{})]}),(t||r)&&y.jsxs("div",{className:"ProseNotesButtons",children:[r&&y.jsx("span",{className:"a small",onClick:d,children:"Отменить"}),t&&y.jsx(Yu,{onSave:f,disabled:!u()})]})]})]}):null},Kb=({schema:n})=>{const e=m.useRef(null),[t,r]=m.useState([]),[o,s]=m.useState([]),[i,l]=m.useState(!1);Ke(c=>{const u=n.nodes.heading;if(!c||!u||!i)return;const f=[],d=[];for(let p=2;p<7;p++){const b=on(u,{level:p});d[p]=b,f[p]={id:p,icon:y.jsx(Jb,{level:p}),text:`уровень ${p}`,disabled:!b(c.state)}}r(f),s(d)},[i]);const a=re((c,u)=>{!c||!u.id||(o[u.id](c.state,c.dispatch,c),l(!1),c.focus())});return n.nodes.heading?y.jsxs(y.Fragment,{children:[y.jsx("div",{ref:e,className:"MenuItem",onClick:()=>l(!0),children:y.jsx(N.Icons.Heading,{})}),e.current&&y.jsx(N.Menu,{parent:e.current,items:t,isOpen:i,onClose:()=>l(!1),onClick:a,horizontal:"inner-left"})]}):null},Jb=({level:n})=>{switch(n){case 2:return y.jsx(N.Icons.Heading2,{});case 3:return y.jsx(N.Icons.Heading3,{});case 4:return y.jsx(N.Icons.Heading4,{});case 5:return y.jsx(N.Icons.Heading5,{});case 6:return y.jsx(N.Icons.Heading6,{});default:return y.jsx(N.Icons.Heading,{})}},Yb=[{id:"left",icon:y.jsx(N.Icons.AlignLeft,{}),text:"Прижать влево"},{id:"right",icon:y.jsx(N.Icons.AlignRight,{}),text:"Прижать вправо"},{id:"center",icon:y.jsx(N.Icons.AlignCenter,{}),text:"Отцентровать"},{id:"justify",icon:y.jsx(N.Icons.AlignJustify,{}),text:"Выровнять по краям"}],Gb=({schema:n})=>{const e=m.useRef(null),[t,r]=m.useState(!1),o=re((s,i)=>{if(!s||!i.id)return;const l=i.id==="left"?null:i.id,{$from:a,$to:c}=s.state.selection,u=a.blockRange(c);if(u){const f=s.state.doc;let d=s.state.tr;f.nodesBetween(u.start,u.end,(p,h)=>{p.type.name==="paragraph"&&(d=d.setNodeMarkup(h,null,{align:l}))}),s.dispatch(d)}s.focus(),r(!1)});return n.nodes.paragraph?y.jsxs(y.Fragment,{children:[y.jsx("div",{ref:e,className:"MenuItem",onClick:()=>r(!0),children:y.jsx(N.Icons.AlignLeft,{})}),e.current&&y.jsx(N.Menu,{parent:e.current,items:Yb,isOpen:t,onClose:()=>r(!1),onClick:o,horizontal:"inner-left"})]}):null},Xb=({schema:n,onSave:e,onView:t})=>y.jsxs("div",{className:"MenuBar",children:[y.jsxs("div",{className:"MenuBlock",children:[y.jsx(Kb,{schema:n}),y.jsx(Bu,{schema:n})]}),y.jsx(Fu,{schema:n}),y.jsx(qu,{schema:n}),y.jsx(Wu,{schema:n}),y.jsx(Gb,{schema:n}),y.jsx(Hu,{schema:n}),y.jsx(Lu,{}),t&&y.jsx("div",{className:"MenuItem",onClick:()=>t(),children:y.jsx(N.Icons.Eye,{})}),y.jsx("div",{className:"MenuBlock",children:y.jsx(Yu,{onSave:e})})]}),Ub=7,Gu=1,lr=50,Qb=({width:n,onChange:e,onWidth:t})=>{const[r,o]=m.useState(!1),[s,i]=m.useState(0),[l,a]=m.useState(0),[c,u]=m.useState(n),f=h=>{const b=n[l],g=n[l+1],x=[...c];return b+h<lr&&(h=lr-b),g-h<lr&&(h=g-lr),x[l]=b+h,x[l+1]=g-h,x};m.useEffect(()=>{u(n)},[n]),m.useEffect(()=>{const h=g=>{if(!r)return;o(!1),g.preventDefault(),g.stopPropagation();const x=g.clientX-s,S=f(x);t(S)},b=g=>{if(!r)return;g.preventDefault(),g.stopPropagation();const x=g.clientX-s,S=f(x);u(S),e(S)};return document.addEventListener("mouseup",h),document.addEventListener("mousemove",b),()=>{document.removeEventListener("mouseup",h),document.removeEventListener("mousemove",b)}},[r,l]);const d=(h,b)=>{b!==n.length-1&&(h.preventDefault(),h.stopPropagation(),o(!0),i(h.clientX),a(b))},p=h=>c.slice(0,h+1).reduce((b,g)=>b+g,0)+h+Gu-Math.floor(Ub/2);return y.jsx("div",{className:"table-resizer",children:c.map((h,b)=>y.jsx("div",{style:{left:p(b)+"px"},onMouseDown:g=>d(g,b)},b))})},Zb=m.forwardRef(function({children:e,nodeProps:t,...r},o){var f;const s=m.useRef(null),i=m.useRef(null),[l,a]=m.useState([]),c=re((d,p)=>{if(!d)return;const h=t.node,b=t.getPos()+1,g=Q.get(h),x=d.state.tr;for(let S=0;S<g.height;S++)for(let w=0;w<g.width;){const D=S*g.width+w,T=g.map[D],M=h.nodeAt(T).attrs,I=p.slice(w,w+M.colspan);S&&g.map[D]==g.map[D-g.width]||x.setNodeMarkup(b+T,null,{...M,colwidth:I}),w+=M.colspan}x.docChanged&&d.dispatch(x)});m.useEffect(()=>{if(!s.current||!i.current)return;const p=t.node.firstChild;if(!p)return;let h=[];for(let M=0;M<p.childCount;M++){const I=p.child(M),{colspan:z,colwidth:O}=I.attrs;h=h.concat(Array.isArray(O)?O:Array(z).fill(0))}const b=h.filter(M=>!M).length,g=h.reduce((M,I)=>M+I,0),x=(h.length+1)*Gu,S=Math.max(b?(s.current.offsetWidth-g-x)/b:0,lr);h=h.map(M=>M||S);const w=h.reduce((M,I)=>M+I,0),D=i.current.offsetWidth-x-16,T=D/w;h=h.map(M=>Math.round(M*T)),h[h.length-1]+=D-h.reduce((M,I)=>M+I,0),a(h)},[t,s,i,(f=i.current)==null?void 0:f.offsetWidth]);const u=re(d=>{_g(d.state,d.dispatch)});return y.jsxs("div",{...r,className:"table-wrapper",ref:d=>{i.current=d,o&&(typeof o=="function"?o(d):o.current=d)},children:[y.jsx(Qb,{width:l,onChange:a,onWidth:c}),y.jsxs("table",{ref:s,children:[y.jsx("colgroup",{children:l.map((d,p)=>y.jsx("col",{width:d},p))}),y.jsx("caption",{onClick:u,children:y.jsx(N.Icons.Trash,{})}),y.jsx("tbody",{children:e})]})]})}),e0=[{id:"toggleHeaderRow",text:"Toggle header row",icon:y.jsx(N.Icons.Heading,{})},{id:"addRowBefore",text:"Insert row before",icon:y.jsx(N.Icons.RowInsertBefore,{})},{id:"addRowAfter",text:"Insert row after",icon:y.jsx(N.Icons.RowInsertAfter,{})},{id:"deleteRow",text:"Delete row",icon:y.jsx(N.Icons.Trash,{})}],t0=[{id:"toggleHeaderColumn",text:"Toggle header column",icon:y.jsx(N.Icons.Heading,{})},{id:"addColumnBefore",text:"Insert column before",icon:y.jsx(N.Icons.ColumnInsertBefore,{})},{id:"addColumnAfter",text:"Insert column after",icon:y.jsx(N.Icons.ColumnInsertAfter,{})},{id:"deleteColumn",text:"Delete column",icon:y.jsx(N.Icons.Trash,{})}],n0=[{id:"toggleHeaderCell",text:"Toggle header",icon:y.jsx(N.Icons.Heading,{})},{id:"alignLeft",text:"Horizontal align left",icon:y.jsx(N.Icons.AlignLeft,{})},{id:"alignCenter",text:"Horizontal align center",icon:y.jsx(N.Icons.AlignCenter,{})},{id:"alignRight",text:"Horizontal align Right",icon:y.jsx(N.Icons.AlignRight,{})},{id:"alignTop",text:"Vertical align top",icon:y.jsx(N.Icons.AlignTop,{})},{id:"alignMiddle",text:"Vertical align middle",icon:y.jsx(N.Icons.AlignMiddle,{})},{id:"alignBottom",text:"Vertical align bottom",icon:y.jsx(N.Icons.AlignBottom,{})},{id:"mergeCells",text:"Merge cells",icon:y.jsx(N.Icons.CellsMerge,{})},{id:"splitCell",text:"Split cell",icon:y.jsx(N.Icons.CellsSplit,{})}],Xu=({x:n,y:e,isRowMenuOpen:t,isCellMenuOpen:r,isColumnMenuOpen:o,onRowMenuClose:s,onCellMenuClose:i,onColumnMenuClose:l})=>{const a=re((c,u)=>{if(c){switch(u.id){case"toggleHeaderRow":Bg(c.state,c.dispatch);break;case"addRowBefore":Tg(c.state,c.dispatch);break;case"addRowAfter":Ag(c.state,c.dispatch);break;case"deleteRow":Ig(c.state,c.dispatch);break;case"toggleHeaderColumn":Fg(c.state,c.dispatch);break;case"addColumnBefore":Ng(c.state,c.dispatch);break;case"addColumnAfter":Eg(c.state,c.dispatch);break;case"deleteColumn":vg(c.state,c.dispatch);break;case"mergeCells":Rg(c.state,c.dispatch);break;case"splitCell":zg(c.state,c.dispatch);break;case"toggleHeaderCell":Lg(c.state,c.dispatch);break;case"alignLeft":mn("halign","left")(c.state,c.dispatch);break;case"alignCenter":mn("halign","center")(c.state,c.dispatch);break;case"alignRight":mn("halign","right")(c.state,c.dispatch);break;case"alignTop":mn("valign","top")(c.state,c.dispatch);break;case"alignMiddle":mn("valign","middle")(c.state,c.dispatch);break;case"alignBottom":mn("valign","bottom")(c.state,c.dispatch);break}s(),i(),l(),c.focus()}});return y.jsxs(y.Fragment,{children:[y.jsx(N.Menu,{x:n,y:e,items:e0,isOpen:t,onClose:s,onClick:a}),y.jsx(N.Menu,{x:n,y:e,items:n0,isOpen:r,onClose:i,onClick:a}),y.jsx(N.Menu,{x:n,y:e,items:t0,isOpen:o,onClose:l,onClick:a})]})},Uu=m.forwardRef(function({children:e,nodeProps:t,...r},o){const s=m.useRef(null),[i,l]=m.useState(0),[a,c]=m.useState(0),[u,f]=m.useState(!1),[d,p]=m.useState(!1),[h,b]=m.useState(!1);m.useEffect(()=>{const S=w=>{s.current!==w.target&&(f(!1),p(!1),b(!1))};return document.addEventListener("contextmenu",S,!0),()=>document.removeEventListener("contextmenu",S,!0)},[]);const g=S=>{S.preventDefault(),S.stopPropagation(),f(!1),p(!1),b(!1),l(S.clientX),c(S.clientY);const w=S.currentTarget.getBoundingClientRect();S.clientY<w.y?b(!0):S.clientX<w.x?f(!0):p(!0)},x=S=>{f(!1),p(!1),b(!1),l(S.clientX),c(S.clientY);const w=S.currentTarget.getBoundingClientRect();if(S.clientY<w.y)b(!0);else if(S.clientX<w.x)f(!0);else return;S.preventDefault(),S.stopPropagation()};return t.node.type.spec.tableRole==="header_cell"?y.jsxs("th",{...r,datatype:`width-${t.node.attrs.colwidth}`,colSpan:t.node.attrs.colspan,rowSpan:t.node.attrs.rowspan,style:{textAlign:t.node.attrs.halign,verticalAlign:t.node.attrs.valign},onClick:x,onContextMenu:g,ref:S=>{s.current=S,o&&(typeof o=="function"?o(S):o.current=S)},children:[e,y.jsx(Xu,{x:i,y:a,isRowMenuOpen:u,onRowMenuClose:()=>f(!1),isCellMenuOpen:d,onCellMenuClose:()=>p(!1),isColumnMenuOpen:h,onColumnMenuClose:()=>b(!1)})]}):y.jsxs("td",{...r,datatype:`width-${t.node.attrs.colwidth}`,colSpan:t.node.attrs.colspan,rowSpan:t.node.attrs.rowspan,style:{textAlign:t.node.attrs.halign,verticalAlign:t.node.attrs.valign},onClick:x,onContextMenu:g,ref:S=>{s.current=S,o&&(typeof o=="function"?o(S):o.current=S)},children:[e,y.jsx(Xu,{x:i,y:a,isRowMenuOpen:u,onRowMenuClose:()=>f(!1),isCellMenuOpen:d,onCellMenuClose:()=>p(!1),isColumnMenuOpen:h,onColumnMenuClose:()=>b(!1)})]})}),r0=m.forwardRef(function({children:e,nodeProps:t,...r},o){var T;const s=m.useRef(null),[i,l]=m.useState(!1),[a,c]=m.useState(!1),[u,f]=m.useState(!1),[d,p]=m.useState(),[h,b]=m.useState(),g=M=>{const I=M.scrollLeft,z=M.clientWidth,O=M.scrollWidth;c(I>0),f(I<O-z*1.5)};m.useEffect(()=>{s.current&&(h&&s.current.scrollWidth>h&&(s.current.scrollLeft=s.current.scrollWidth-s.current.clientWidth),b(s.current.scrollWidth))},[(T=s.current)==null?void 0:T.scrollWidth]),m.useEffect(()=>{p(t.getPos()+t.node.nodeSize-1),s.current&&t.node.childCount>1&&g(s.current)},[t,s]),Ke(M=>{if(!M||t.node.childCount>0)return;const I=M.state.tr,z=t.getPos(),O=t.node.nodeSize;M.dispatch(I.delete(z,z+O))},[t]);const x=re(M=>{if(!M)return;const I=t.getPos(),z=t.node.nodeSize;M.dispatch(M.state.tr.delete(I,I+z))}),S=()=>{l(!0)},w=M=>{g(M.currentTarget)},D=(M,I)=>{if(M.stopPropagation(),!s.current)return;const z=s.current.clientWidth;let O=s.current.scrollLeft+I*z;s.current.scrollLeft=O};return y.jsxs("div",{ref:o,...r,className:"carousel",children:[y.jsx("div",{className:"carousel-list",ref:s,onScroll:w,children:e}),y.jsxs("div",{className:"carousel-buttons",children:[y.jsx("div",{onClick:x,className:"text-button",children:"Удалить карусель"}),y.jsx("div",{onClick:S,children:y.jsx(N.Icons.Plus,{})})]}),a&&y.jsx("div",{className:"carousel-prev",onClick:M=>D(M,-1),children:y.jsx(N.Icons.ChevronLeft,{})}),u&&y.jsx("div",{className:"carousel-next",onClick:M=>D(M,1),children:y.jsx(N.Icons.ChevronRight,{})}),y.jsx(_u,{pos:d,isOpen:i,onClose:()=>l(!1)})]})}),o0=({content:n,onSave:e,onView:t,onChange:r,onUpload:o})=>{const[s,i]=m.useState();m.useEffect(()=>{let a;if(n)try{a=be.fromJSON(Nt,JSON.parse(n))}catch(f){console.error(`Can not parse Prose format: ${f}`)}let c=Ge.create({doc:a,schema:Nt,plugins:Ru({schema:Nt,upload:o})});const u=Is(c);u&&(c=c.apply(u.setMeta("addToHistory",!1))),i(c)},[n]);const l=async a=>{const c=await e(a);return r&&r(!1),c};return s?y.jsx("div",{className:"ProseEditor",children:y.jsxs(Iu,{state:s,dispatchTransaction:a=>i(c=>{const u=c==null?void 0:c.apply(a);return u&&r&&r(!0),u}),nodeViews:{image:Ku,video:Ju,table:Zb,table_header:Uu,table_cell:Uu,carousel:r0},children:[y.jsx(Xb,{schema:Nt,onSave:l,onView:t}),y.jsx(Pu,{})]})}):null},s0=({node:n})=>{const[e,t]=m.useState();return m.useEffect(()=>{var o;const r=(o=n.attrs)==null?void 0:o.align;t(r!=="right"&&r!=="center"&&r!=="justify"?void 0:{textAlign:r})},[n]),y.jsx("p",{style:e,children:Array.isArray(n.content)&&n.content.map((r,o)=>y.jsx(Y,{node:r},o))})},i0=({node:n})=>{if(!n.text)return null;const e=(t,r)=>{var i;if(!Array.isArray(n.marks))return y.jsx(y.Fragment,{children:r});if(!t.length)return y.jsx(y.Fragment,{children:r});const o=t[0].type,s=(i=t[0].attrs)==null?void 0:i.href;switch(o){case"em":return y.jsx("em",{children:e(t.slice(1),r)});case"code":return y.jsx("code",{children:e(t.slice(1),r)});case"strong":return y.jsx("strong",{children:e(t.slice(1),r)});case"underline":return y.jsx("u",{children:e(t.slice(1),r)});case"strikethrough":return y.jsx("s",{children:e(t.slice(1),r)});case"link":return s?y.jsx("a",{target:"_blank",href:s,children:e(t.slice(1),r)}):y.jsx(y.Fragment,{children:e(t.slice(1),r)});default:return y.jsx(y.Fragment,{children:e(t.slice(1),r)})}};return e(n.marks,n.text)},l0=({node:n,className:e})=>y.jsx("div",{className:e,children:Array.isArray(n.content)&&n.content.map((t,r)=>y.jsx(Y,{node:t},r))}),a0=({node:n})=>{const e=m.useRef(null),[t,r]=m.useState(""),[o,s]=m.useState(""),[i,l]=m.useState(""),[a,c]=m.useState(!1);m.useEffect(()=>{const f=()=>{c(!!document.fullscreenElement)};return document.addEventListener("fullscreenchange",f),()=>document.removeEventListener("fullscreenchange",f)},[]),m.useEffect(()=>{var p,h,b,g,x,S,w;let f=(p=n.attrs)==null?void 0:p.fid,d=(h=n.attrs)!=null&&h.src?`${(b=n.attrs)==null?void 0:b.src}`:"";f&&(d=`${so}/files/${f}`),d||(d=ni),r(d),s((g=n.attrs)!=null&&g.alt?`${(x=n.attrs)==null?void 0:x.alt}`:""),l((S=n.attrs)!=null&&S.title?`${(w=n.attrs)==null?void 0:w.title}`:"")},[n]);const u=f=>{var d;f.stopPropagation(),a?document.exitFullscreen():(d=e.current)==null||d.requestFullscreen()};return t?y.jsxs("div",{ref:e,className:"image",children:[y.jsx("img",{src:t,onClick:u,alt:o,title:i}),i&&y.jsx("div",{className:"image-title",children:i}),y.jsx("div",{className:"image-full",onClick:u,children:a?y.jsx(N.Icons.Minimize,{}):y.jsx(N.Icons.Maximize,{})})]}):null},c0=({node:n})=>y.jsx("blockquote",{children:Array.isArray(n.content)&&n.content.map((e,t)=>y.jsx(Y,{node:e},t))}),u0=50,f0=({node:n})=>{const[e,t]=m.useState([]);return m.useEffect(()=>{if(t([]),!Array.isArray(n.content))return;const r=n.content[0];if(!Array.isArray(r.content))return;let o=[];for(let i=0;i<r.content.length;i++){const l=r.content[i].attrs;if(!l)return;const{colspan:a,colwidth:c}=l;o=o.concat(Array.isArray(c)?c:Array(a).fill(u0))}const s=o.reduce((i,l)=>i+l,0);o=o.map(i=>Math.round(i*100/s)),o[o.length-1]+=100-o.reduce((i,l)=>i+l,0),t(o)},[n]),y.jsxs("table",{children:[e.length>0&&y.jsx("colgroup",{children:e.map((r,o)=>y.jsx("col",{width:`${r}%`},o))}),y.jsx("tbody",{children:Array.isArray(n.content)&&n.content.map((r,o)=>y.jsx(Y,{node:r},o))})]})},d0=({node:n})=>y.jsx("tr",{children:Array.isArray(n.content)&&n.content.map((e,t)=>y.jsx(Y,{node:e},t))}),h0=({node:n})=>{const[e,t]=m.useState(),[r,o]=m.useState(),[s,i]=m.useState(),[l,a]=m.useState();return m.useEffect(()=>{var c,u,f,d;t((c=n.attrs)==null?void 0:c.halign),o((u=n.attrs)==null?void 0:u.valign),i((f=n.attrs)!=null&&f.rowspan?parseInt(n.attrs.rowspan+""):1),a((d=n.attrs)!=null&&d.colspan?parseInt(n.attrs.colspan+""):1)},[n]),n.type==="table_header"?y.jsx("th",{colSpan:l,rowSpan:s,style:{textAlign:e,verticalAlign:r},children:Array.isArray(n.content)&&n.content.map((c,u)=>y.jsx(Y,{node:c},u))}):y.jsx("td",{colSpan:l,rowSpan:s,style:{textAlign:e,verticalAlign:r},children:Array.isArray(n.content)&&n.content.map((c,u)=>y.jsx(Y,{node:c},u))})},p0=({node:n})=>{var e;if(!Array.isArray(n.content))return null;switch((e=n.attrs)==null?void 0:e.level){case 1:return y.jsx("h1",{children:n.content.map((t,r)=>y.jsx(Y,{node:t},r))});case 2:return y.jsx("h2",{children:n.content.map((t,r)=>y.jsx(Y,{node:t},r))});case 3:return y.jsx("h3",{children:n.content.map((t,r)=>y.jsx(Y,{node:t},r))});case 4:return y.jsx("h4",{children:n.content.map((t,r)=>y.jsx(Y,{node:t},r))});case 5:return y.jsx("h5",{children:n.content.map((t,r)=>y.jsx(Y,{node:t},r))});case 6:return y.jsx("h6",{children:n.content.map((t,r)=>y.jsx(Y,{node:t},r))});default:return y.jsx("h2",{children:n.content.map((t,r)=>y.jsx(Y,{node:t},r))})}},m0=({node:n})=>Array.isArray(n.content)?n.type==="bullet_list"?y.jsx("ul",{children:n.content.map((e,t)=>y.jsx(Y,{node:e},t))}):y.jsx("ol",{children:n.content.map((e,t)=>y.jsx(Y,{node:e},t))}):null,g0=({node:n})=>y.jsx("li",{children:Array.isArray(n.content)&&n.content.map((e,t)=>y.jsx(Y,{node:e},t))}),y0=({node:n})=>y.jsx("pre",{children:Array.isArray(n.content)&&n.content.map((e,t)=>y.jsx(Y,{node:e},t))}),b0=()=>y.jsx("hr",{}),x0=({node:n})=>{const[e,t]=m.useState(""),[r,o]=m.useState(""),[s,i]=m.useState(""),[l,a]=m.useState(""),[c,u]=m.useState(""),[f,d]=m.useState(0),p="fullscreen; accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share";return m.useEffect(()=>{var b,g;u((b=n.attrs)!=null&&b.title?`${n.attrs.title}`:"");let h=(g=n.attrs)==null?void 0:g.src;typeof h=="string"&&(h=[h]),h.forEach(x=>{rr(x)?(t(x),o(x)):or(x)?(t(x),i(x)):nr(x)&&(t(x),a(x))})},[n]),m.useEffect(()=>{let h=0;r&&h++,s&&h++,l&&h++,d(h)},[r,s,l]),f?y.jsxs("div",{className:"video",children:[f>1&&y.jsxs("div",{className:"video-switcher",children:[r&&y.jsx("div",{onClick:()=>t(r),className:e===r?"active":"",children:"RuTube"}),s&&y.jsx("div",{onClick:()=>t(s),className:e===s?"active":"",children:"YouTube"}),l&&y.jsx("div",{onClick:()=>t(l),className:e===l?"active":"",children:"VK Video"})]}),y.jsx("iframe",{src:e,allow:p}),c&&y.jsx("div",{className:"video-title",children:c})]}):y.jsxs("div",{className:"image",children:[y.jsx("img",{src:ri}),c&&y.jsx("div",{className:"image-title",children:c})]})},k0=()=>y.jsx("br",{}),S0=({node:n})=>{const e=m.useRef(null),t=m.useRef(null),[r,o]=m.useState(!1),[s,i]=m.useState(!1),[l,a]=m.useState(!1),[c,u]=m.useState(1),[f,d]=m.useState(1),p=g=>{const x=g.scrollLeft,S=g.clientWidth,w=g.scrollWidth;i(x>S/2),a(x<w-S*1.5),u(Math.round(x/S+1))};m.useEffect(()=>{var g;a(Array.isArray(n.content)&&n.content.length>1),d(((g=n.content)==null?void 0:g.length)??1),u(1)},[n]),m.useEffect(()=>{const g=()=>{o(!!document.fullscreenElement)};return document.addEventListener("fullscreenchange",g),()=>document.removeEventListener("fullscreenchange",g)},[]),m.useEffect(()=>{if(!r)return;const g=x=>{x.key==="ArrowLeft"&&b(null,-1),x.key==="ArrowRight"&&b(null,1)};return document.body.addEventListener("keydown",g),()=>document.body.removeEventListener("keydown",g)},[r]);const h=g=>{var x;g.stopPropagation(),r?document.exitFullscreen():(x=t.current)==null||x.requestFullscreen()},b=(g,x)=>{if(g==null||g.stopPropagation(),!e.current)return;const S=e.current.clientWidth;let w=e.current.scrollLeft+x*S;e.current.scrollLeft=w};return Array.isArray(n.content)?y.jsxs("div",{className:"carousel",ref:t,children:[y.jsx("div",{className:"carousel-list",ref:e,onScroll:g=>p(g.currentTarget),children:n.content.map((g,x)=>y.jsx(C0,{node:g,onClick:h},x))}),y.jsxs("div",{className:"carousel-numb",children:[c," / ",f]}),y.jsx("div",{className:"carousel-full",onClick:h,children:r?y.jsx(N.Icons.Minimize,{}):y.jsx(N.Icons.Maximize,{})}),s&&y.jsx("div",{className:"carousel-prev",onClick:g=>b(g,-1),children:y.jsx(N.Icons.ChevronLeft,{})}),l&&y.jsx("div",{className:"carousel-next",onClick:g=>b(g,1),children:y.jsx(N.Icons.ChevronRight,{})})]}):null},C0=({node:n,onClick:e})=>{const[t,r]=m.useState(""),[o,s]=m.useState(""),[i,l]=m.useState("");return m.useEffect(()=>{var d,p,h,b;let a=(d=n.attrs)==null?void 0:d.fid,c=(p=n.attrs)!=null&&p.src?`${n.attrs.src}`:"",u=(h=n.attrs)!=null&&h.alt?`${n.attrs.alt}`:"",f=(b=n.attrs)!=null&&b.title?`${n.attrs.title}`:"";a&&(c=`${so}/files/${a}`),c||(c=ni),r(c),s(u),l(f)},[n]),n.type!=="image"?null:y.jsxs("div",{className:"image",children:[t&&y.jsx("img",{src:t,onClick:e,alt:o,title:i}),i&&y.jsx("div",{className:"image-title",children:i})]})},Y=({node:n,className:e})=>n?(r=>{switch(r.type){case"doc":return y.jsx(l0,{node:r,className:e});case"list_item":return y.jsx(g0,{node:r});case"bullet_list":case"ordered_list":return y.jsx(m0,{node:r});case"image":return y.jsx(a0,{node:r});case"video":return y.jsx(x0,{node:r});case"text":return y.jsx(i0,{node:r});case"table":return y.jsx(f0,{node:r});case"table_row":return y.jsx(d0,{node:r});case"table_cell":case"table_header":return y.jsx(h0,{node:r});case"heading":return y.jsx(p0,{node:r});case"code_block":return y.jsx(y0,{node:r});case"paragraph":return y.jsx(s0,{node:r});case"blockquote":return y.jsx(c0,{node:r});case"carousel":return y.jsx(S0,{node:r});case"horizontal_rule":return y.jsx(b0,{});case"hard_break":return y.jsx(k0,{});default:return y.jsx("span",{className:"unknown_node_type",children:r.type})}})(n):null,w0=({content:n})=>{const[e,t]=m.useState(),[r,o]=m.useState(!1);return m.useEffect(()=>{try{o(!1);const s=JSON.parse(n);t(s)}catch(s){o(!0),console.error(`Can not parse Prose format: ${s}`)}},[n]),r?y.jsx("div",{className:"error",children:"ОШИБКА"}):y.jsx(Y,{node:e,className:"ProseViewer"})},M0=({content:n})=>{const e=m.useRef(null),[t,r]=m.useState(!1);return m.useEffect(()=>{var o;try{r(!1);const s=be.fromJSON(Nt,JSON.parse(n)),i=$e.fromSchema(Nt).serializeFragment(s.content);(o=e.current)==null||o.appendChild(i)}catch(s){r(!0),console.error(`Can not parse Prose format: ${s}`)}},[e,n]),y.jsx("div",{ref:e,className:"ProseViewer",children:t&&y.jsx("div",{className:"error",children:"ОШИБКА"})})};G.DOM=M0,G.Editor=o0,G.Notes=Hb,G.Viewer=w0,Object.defineProperty(G,Symbol.toStringTag,{value:"Module"})});
|
|
66
66
|
//# sourceMappingURL=prose-editor.umd.js.map
|