@alxgrn/prose-editor 0.0.6 → 0.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,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,Je,N){"use strict";var k0=Object.defineProperty;var S0=(G,m,Je)=>m in G?k0(G,m,{enumerable:!0,configurable:!0,writable:!0,value:Je}):G[m]=Je;var z=(G,m,Je)=>S0(G,typeof m!="symbol"?m+"":m,Je);var si=document.createElement("style");si.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)}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;border-bottom:1px solid var(--alxgrn-border);padding:var(--alxgrn-unit-small);padding-bottom:var(--alxgrn-unit-half)}.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-small)}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-small)}.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: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,.ProseNotes ul p,.ProseEditor ul p,.ProseViewer ul p,.ProseNotes ol p,.ProseEditor ol p,.ProseViewer ol p{margin: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}.ProseNotes div.image img,.ProseEditor div.image img,.ProseViewer div.image img{display:block;border-radius:var(--alxgrn-unit-small);max-width:100%;max-height:75vh;margin:0 auto;background-color:var(--alxgrn-border)}.ProseViewer div.image:after{content:attr(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:after{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-half);top:0;right:0;width:auto;margin:var(--alxgrn-unit-half);display:flex;align-items:stretch;justify-content:stretch}.ProseEditor div.carousel div.carousel-buttons{z-index:10;position:absolute;gap:var(--alxgrn-unit-half);top:0;left:0;width:auto;margin:var(--alxgrn-unit-half);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:#fff;background-color:var(--alxgrn-color-light);border-radius:var(--alxgrn-unit-small);cursor:pointer;height:var(--alxgrn-unit-double);width:var(--alxgrn-unit-double);padding:0}.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{background-color:var(--alxgrn-color-accent)}.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-half);font-style:normal;font-weight:600;font-size:var(--alxgrn-font-size-small)}.ProseEditor div.image div.image-buttons div:hover,.ProseEditor div.carousel div.carousel-buttons div:hover{background-color:var(--alxgrn-color-accent)}.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-small);width:100%;aspect-ratio:16 / 9;border:none;margin:0 auto;background-color:var(--alxgrn-border)}.ProseViewer div.video:after{content:attr(title);font-style:italic;display:block;width:80%;margin:0 auto}.ProseNotes div.image>div,.ProseEditor div.image>div,.ProseNotes div.video>div,.ProseEditor div.video>div{font-style:italic;width:80%;margin:0 auto}.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{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:#8fbc8f}.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-small);flex-direction:column;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)}.ProseNotesButtons{display:flex;gap:var(--alxgrn-unit);align-items:center;justify-content:flex-end;border-top:1px solid var(--alxgrn-border);padding:var(--alxgrn-unit-small);padding-top:var(--alxgrn-unit-half)}.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}.ProseMirror .tableWrapper{overflow-x:auto;margin:1em 0}.ProseMirror table{border-collapse:collapse;table-layout:fixed;width:100%;margin:var(--alxgrn-unit-double) 0 var(--alxgrn-unit) 0}.ProseMirror td,.ProseMirror th{text-align:left;vertical-align:top;box-sizing:border-box;position:relative;min-width:1em;border:1px solid #ddd;padding:var(--alxgrn-unit-small) var(--alxgrn-unit-half)}.ProseMirror th{font-weight:700;text-align:center;vertical-align:middle;background-color:#8fbc8f}.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{position:relative;width:calc(100% - var(--alxgrn-unit));margin-left:var(--alxgrn-unit)}.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)}.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)}.ProseMirror table tbody tr:first-child th:last-child:before,.ProseMirror table tbody tr:first-child td:last-child:before{right:-1px}.ProseMirror-cell-resizer{display:block;position:absolute;top:0;left:calc(100% - var(--alxgrn-unit-small));bottom:0;width:var(--alxgrn-unit-half)}.ProseMirror-cell-resizer:hover{cursor:ew-resize;cursor:col-resize;background-color:#8cf}.ProseMirror-cell-resizer.dragging{background-color:#7fffd4}div.carousel{width:100%;position:relative;text-align:center;margin:var(--alxgrn-unit) 0;background-color:var(--alxgrn-bg-main);border-radius:var(--alxgrn-unit-small);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}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-half);height:var(--alxgrn-unit-double);width:var(--alxgrn-unit-double);color:#fff;background-color:var(--alxgrn-color-light);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-half)}div.carousel div.carousel-numb{top:var(--alxgrn-unit-half);font-size:var(--alxgrn-font-size-small);font-weight:600;font-style:normal;padding:0 var(--alxgrn-unit-half);width:unset}div.carousel div.carousel-full{top:var(--alxgrn-unit-half);left:unset;right:var(--alxgrn-unit-half)}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{background-color:var(--alxgrn-color-accent)}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:after{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}
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,Je,N){"use strict";var k0=Object.defineProperty;var S0=(G,m,Je)=>m in G?k0(G,m,{enumerable:!0,configurable:!0,writable:!0,value:Je}):G[m]=Je;var z=(G,m,Je)=>S0(G,typeof m!="symbol"?m+"":m,Je);var si=document.createElement("style");si.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;border-bottom:1px solid var(--alxgrn-border);padding:var(--alxgrn-unit-small);padding-bottom:var(--alxgrn-unit-half)}.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-small)}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-small)}.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: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,.ProseNotes ul p,.ProseEditor ul p,.ProseViewer ul p,.ProseNotes ol p,.ProseEditor ol p,.ProseViewer ol p{margin: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}.ProseNotes div.image img,.ProseEditor div.image img,.ProseViewer div.image img{display:block;border-radius:var(--alxgrn-unit-small);max-width:100%;max-height:75vh;margin:0 auto}.ProseViewer div.image:after{content:attr(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:after{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-half);top:0;right:0;width:auto;margin:var(--alxgrn-unit-half);display:flex;align-items:stretch;justify-content:stretch}.ProseEditor div.carousel div.carousel-buttons{z-index:10;position:absolute;gap:var(--alxgrn-unit-half);top:0;left:0;width:auto;margin:var(--alxgrn-unit-half);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:#fff;background-color:var(--alxgrn-color-light);border-radius:var(--alxgrn-unit-small);cursor:pointer;height:var(--alxgrn-unit-double);width:var(--alxgrn-unit-double);padding:0}.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{background-color:var(--alxgrn-color-accent)}.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-half);font-style:normal;font-weight:600;font-size:var(--alxgrn-font-size-small)}.ProseEditor div.image div.image-buttons div:hover,.ProseEditor div.carousel div.carousel-buttons div:hover{background-color:var(--alxgrn-color-accent)}.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-small);width:100%;aspect-ratio:16 / 9;border:none;margin:0 auto;background-color:var(--alxgrn-border)}.ProseViewer div.video:after{content:attr(title);font-style:italic;display:block;width:80%;margin:0 auto}.ProseNotes div.image>div,.ProseEditor div.image>div,.ProseNotes div.video>div,.ProseEditor div.video>div{font-style:italic;width:80%;margin:0 auto}.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:#8fbc8f}.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-small);flex-direction:column;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)}.ProseNotesButtons{display:flex;gap:var(--alxgrn-unit);align-items:center;justify-content:flex-end;border-top:1px solid var(--alxgrn-border);padding:var(--alxgrn-unit-small);padding-top:var(--alxgrn-unit-half)}.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}.ProseMirror .tableWrapper{overflow-x:auto;margin:1em 0}.ProseMirror table{border-collapse:collapse;table-layout:fixed;width:100%;margin:var(--alxgrn-unit-double) 0 var(--alxgrn-unit) 0}.ProseMirror td,.ProseMirror th{text-align:left;vertical-align:top;box-sizing:border-box;position:relative;min-width:1em;border:1px solid #ddd;padding:var(--alxgrn-unit-small) var(--alxgrn-unit-half)}.ProseMirror th{font-weight:700;text-align:center;vertical-align:middle;background-color:#8fbc8f}.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{position:relative;width:calc(100% - var(--alxgrn-unit));margin-left:var(--alxgrn-unit)}.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)}.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)}.ProseMirror table tbody tr:first-child th:last-child:before,.ProseMirror table tbody tr:first-child td:last-child:before{right:-1px}.ProseMirror-cell-resizer{display:block;position:absolute;top:0;left:calc(100% - var(--alxgrn-unit-small));bottom:0;width:var(--alxgrn-unit-half)}.ProseMirror-cell-resizer:hover{cursor:ew-resize;cursor:col-resize;background-color:#8cf}.ProseMirror-cell-resizer.dragging{background-color:#7fffd4}div.carousel{width:100%;position:relative;text-align:center;margin:var(--alxgrn-unit) 0;border-radius:var(--alxgrn-unit-small);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}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-half);height:var(--alxgrn-unit-double);width:var(--alxgrn-unit-double);color:#fff;background-color:var(--alxgrn-color-light);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-half)}div.carousel div.carousel-numb{top:var(--alxgrn-unit-half);font-size:var(--alxgrn-font-size-small);font-weight:600;font-style:normal;padding:0 var(--alxgrn-unit-half);width:unset}div.carousel div.carousel-full{top:var(--alxgrn-unit-half);left:unset;right:var(--alxgrn-unit-half)}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{background-color:var(--alxgrn-color-accent)}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:after{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}
2
2
  /*$vite$:1*/`,document.head.appendChild(si);function pf(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var lo={exports:{}},Cn={};/**
3
3
  * @license React
4
4
  * react-jsx-runtime.production.js
@@ -38,7 +38,7 @@ Check the top-level render call using <`+x+">."),T}var w=m,D=Symbol.for("react.t
38
38
  `),f&&p==h.nodeValue.length)for(let b=h,y;b;b=b.parentNode){if(y=b.nextSibling){y.nodeName=="BR"&&(l=a={node:y.parentNode,offset:te(y)+1});break}let k=b.pmViewDesc;if(k&&k.node&&k.node.isBlock)break}}else{let b=h.childNodes[p-1];f=b&&(b.nodeName=="BR"||b.contentEditable=="false")}}if(Ie&&u.focusNode&&u.focusNode!=a.node&&u.focusNode.nodeType==1){let h=u.focusNode.childNodes[u.focusOffset];h&&h.contentEditable=="false"&&(o=!0)}if(!(o||f&&ue)&&Vt(l.node,l.offset,u.anchorNode,u.anchorOffset)&&Vt(a.node,a.offset,u.focusNode,u.focusOffset))return;let d=!1;if((c.extend||e==t)&&!f){c.collapse(l.node,l.offset);try{e!=t&&c.extend(a.node,a.offset),d=!0}catch{}}if(!d){if(e>t){let p=l;l=a,a=p}let h=document.createRange();h.setEnd(a.node,a.offset),h.setStart(l.node,l.offset),c.removeAllRanges(),c.addRange(h)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let r=0,o=0;o<this.children.length;o++){let s=this.children[o],i=r+s.size;if(r==i?e<=i&&t>=r:e<i&&t>r){let l=r+s.border,a=i-s.border;if(e>=l&&t<=a){this.dirty=e==r||t==i?zt:Fl,e==l&&t==a&&(s.contentLost||s.dom.parentNode!=this.contentDOM)?s.dirty=Le:s.markDirty(e-l,t-l);return}else s.dirty=s.dom==s.contentDOM&&s.dom.parentNode==this.contentDOM&&!s.children.length?zt:Le}r=i}this.dirty=zt}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let r=e==1?zt:Fl;t.dirty<r&&(t.dirty=r)}}get domAtom(){return!1}get ignoreForCoords(){return!1}isText(e){return!1}},Bl=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}},gh=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}},Nr=class ri 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 ri(e,t,i.dom,i.contentDOM||i.dom,i)}parseRule(){return this.dirty&Le||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=Le&&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=ri.create(this.parent,this.mark,!0,r),s=this.children,i=this.size;t<i&&(s=_o(s,t,i,r)),e>0&&(s=_o(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 cf extends $n{constructor(e,t,r,o,s,i,l,a,c){super(e,[],s,i),this.node=t,this.outerDeco=r,this.innerDeco=o,this.nodeDOM=l}static create(e,t,r,o,s,i){let l=s.nodeViews[t.type.name],a,c=l&&l(t,s,()=>{if(!a)return i;if(a.parent)return a.parent.posBeforeChild(a)},r,o),u=c&&c.dom,f=c&&c.contentDOM;if(t.isText){if(!u)u=document.createTextNode(t.text);else if(u.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else u||({dom:u,contentDOM:f}=$e.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs));!f&&!t.isText&&u.nodeName!="BR"&&(u.hasAttribute("contenteditable")||(u.contentEditable="false"),t.type.spec.draggable&&(u.draggable=!0));let d=u;return u=Jl(u,r,t),c?a=new yh(e,t,r,o,u,f||null,d,c,s,i+1):t.isText?new Wl(e,t,r,o,u,d,s):new cf(e,t,r,o,u,f||null,d,s,i+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(e.preserveWhitespace="full"),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let t=this.children.length-1;t>=0;t--){let r=this.children[t];if(this.dom.contains(r.dom.parentNode)){e.contentElement=r.dom.parentNode;break}}e.contentElement||(e.getContent=()=>S.empty)}return e}matchesNode(e,t,r){return this.dirty==Ee&&e.eq(this.node)&&Er(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 xh(this,i&&i.node,e);Ch(this.node,this.innerDeco,(c,u,f)=>{c.spec.marks?a.syncToMarks(c.spec.marks,r,e):c.type.side>=0&&!f&&a.syncToMarks(u==this.node.childCount?F.none:this.node.child(u).marks,r,e),a.placeWidget(c,e,o)},(c,u,f,d)=>{a.syncToMarks(c.marks,r,e);let h;a.findNodeMatch(c,u,f,d)||l&&e.state.selection.from>o&&e.state.selection.to<o+c.nodeSize&&(h=a.findIndexWithChild(s.node))>-1&&a.updateNodeAt(c,u,f,h,e)||a.updateNextNode(c,u,f,e,d,o)||a.addNode(c,u,f,e,o),o+=c.nodeSize}),a.syncToMarks([],r,e),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==zt)&&(i&&this.protectLocalComposition(e,i),ql(this.contentDOM,this.children,e),sn&&wh(this.dom))}localCompositionInfo(e,t){let{from:r,to:o}=e.state.selection;if(!(e.state.selection instanceof P)||r<t||o>t+this.node.content.size)return null;let s=e.input.compositionNode;if(!s||!this.dom.contains(s.parentNode))return null;if(this.node.inlineContent){let i=s.nodeValue,l=Mh(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 gh(this,s,t,o);e.input.compositionNodes.push(i),this.children=_o(this.children,r,r+o.length,e,i)}update(e,t,r,o){return this.dirty==Le||!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(Er(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,r=this.dom;this.dom=Hl(this.dom,this.nodeDOM,Wo(this.outerDeco,this.node,t),Wo(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 Ll(n,e,t,r,o){Jl(r,e,n);let s=new an(void 0,n,e,t,r,r,r,o,0);return s.contentDOM&&s.updateChildren(o,0),s}let Wl=class uf 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==Le||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 uf(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=Le)}get domAtom(){return!1}isText(e){return this.node.text==e}},_l=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 yh 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==Le)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 ql(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=Kl(r),o=!0;r=r.nextSibling}else o=!0,n.insertBefore(l,r);if(i instanceof Nr){let a=r?r.previousSibling:n.lastChild;ql(i.contentDOM,i.children,t),r=a?a.nextSibling:n.firstChild}}for(;r;)r=Kl(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 Wo(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 Hl(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}bh(o,l||$t[0],i)}return o}function bh(n,e,t){for(let r in e)r!="class"&&r!="style"&&r!="nodeName"&&!(r in t)&&n.removeAttribute(r);for(let r in t)r!="class"&&r!="style"&&r!="nodeName"&&t[r]!=e[r]&&n.setAttribute(r,t[r]);if(e.class!=t.class){let r=e.class?e.class.split(" ").filter(Boolean):[],o=t.class?t.class.split(" ").filter(Boolean):[];for(let s=0;s<r.length;s++)o.indexOf(r[s])==-1&&n.classList.remove(r[s]);for(let s=0;s<o.length;s++)r.indexOf(o[s])==-1&&n.classList.add(o[s]);n.classList.length==0&&n.removeAttribute("class")}if(e.style!=t.style){if(e.style){let r=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,o;for(;o=r.exec(e.style);)n.style.removeProperty(o[1])}t.style&&(n.style.cssText+=t.style)}}function Jl(n,e,t){return Hl(n,n,$t,Wo(e,t,n.nodeType!=1))}function Er(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 Kl(n){let e=n.nextSibling;return n.parentNode.removeChild(n),e}class xh{constructor(e,t,r){this.lock=t,this.view=r,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=kh(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=Nr.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==Le&&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!=Le&&Er(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)||!Er(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 Bl(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 Nr;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof Wl)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((ue||se)&&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 _l(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 kh(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 Nr)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 Sh(n,e){return n.type.side-e.type.side}function Ch(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 y=o[i++];y.widget&&(u?(f||(f=[u])).push(y):u=y)}if(u)if(f){f.sort(Sh);for(let y=0;y<f.length;y++)t(f[y],c,!!a)}else t(u,c,!!a);let d,h;if(a)h=-1,d=a,a=null;else if(c<n.childCount)h=c,d=n.child(c++);else break;for(let y=0;y<l.length;y++)l[y].to<=s&&l.splice(y--,1);for(;i<o.length&&o[i].from<=s&&o[i].to>s;)l.push(o[i++]);let p=s+d.nodeSize;if(d.isText){let y=p;i<o.length&&o[i].from<y&&(y=o[i].from);for(let k=0;k<l.length;k++)l[k].to<y&&(y=l[k].to);y<p&&(a=d.cut(y-s),d=d.cut(0,y-s),p=y,h=-1)}else for(;i<o.length&&o[i].to<p;)i++;let b=d.isInline&&!d.isLeaf?l.filter(y=>!y.inline):l.slice();r(d,b,e.forChild(s,d),h),s=p}}function wh(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 Mh(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 _o(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 qo(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(Mr(t)){for(a=i;o&&!o.node;)o=o.parent;let f=o.node;if(o&&f.isAtom&&E.isSelectable(f)&&o.parent&&!(f.isInline&&Ud(t.focusNode,t.focusOffset,o.dom))){let d=o.posBefore;c=new E(i==d?l:r.resolve(d))}}else{if(t instanceof n.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let f=i,d=i;for(let h=0;h<t.rangeCount;h++){let p=t.getRangeAt(h);f=Math.min(f,n.docView.posFromDOM(p.startContainer,p.startOffset,1)),d=Math.max(d,n.docView.posFromDOM(p.endContainer,p.endOffset,-1))}if(f<0)return null;[a,i]=d==n.state.selection.anchor?[d,f]:[f,d],l=r.resolve(i)}else a=n.docView.posFromDOM(t.anchorNode,t.anchorOffset,1);if(a<0)return null}let u=r.resolve(a);if(!c){let f=e=="pointer"||n.state.selection.head<l.pos&&!s?1:-1;c=Jo(n,u,l,f)}return c}function Yl(n){return n.editable?n.hasFocus():ta(n)&&document.activeElement&&document.activeElement.contains(n.dom)}function Ze(n,e=!1){let t=n.state.selection;if(Ql(n,t),!!Yl(n)){if(!e&&n.input.mouseDown&&n.input.mouseDown.allowDefault&&se){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)Eh(n);else{let{anchor:r,head:o}=t,s,i;Gl&&!(t instanceof P)&&(t.$from.parent.inlineContent||(s=Ul(n,t.from)),!t.empty&&!t.$from.parent.inlineContent&&(i=Ul(n,t.to))),n.docView.setSelection(r,o,n,e),Gl&&(s&&Xl(s),i&&Xl(i)),t.visible?n.dom.classList.remove("ProseMirror-hideselection"):(n.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&Nh(n))}n.domObserver.setCurSelection(),n.domObserver.connectSelection()}}const Gl=ue||se&&Dl<63;function Ul(n,e){let{node:t,offset:r}=n.docView.domFromPos(e,0),o=r<t.childNodes.length?t.childNodes[r]:null,s=r?t.childNodes[r-1]:null;if(ue&&o&&o.contentEditable=="false")return Ho(o);if((!o||o.contentEditable=="false")&&(!s||s.contentEditable=="false")){if(o)return Ho(o);if(s)return Ho(s)}}function Ho(n){return n.contentEditable="true",ue&&n.draggable&&(n.draggable=!1,n.wasDraggable=!0),n}function Xl(n){n.contentEditable="false",n.wasDraggable&&(n.draggable=!0,n.wasDraggable=null)}function Nh(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(()=>{(!Yl(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function Eh(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,te(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 Ql(n,e){if(e instanceof E){let t=n.docView.descAt(e.from);t!=n.lastSelectedViewDesc&&(Zl(n),t&&t.selectNode(),n.lastSelectedViewDesc=t)}else Zl(n)}function Zl(n){n.lastSelectedViewDesc&&(n.lastSelectedViewDesc.parent&&n.lastSelectedViewDesc.deselectNode(),n.lastSelectedViewDesc=void 0)}function Jo(n,e,t,r){return n.someProp("createSelectionBetween",o=>o(n,e,t))||P.between(e,t,r)}function ea(n){return n.editable&&!n.hasFocus()?!1:ta(n)}function ta(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 Dh(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 Ko(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&&I.findFrom(s,e)}function pt(n,e){return n.dispatch(n.state.tr.setSelection(e).scrollIntoView()),!0}function na(n,e,t){let r=n.state.selection;if(r instanceof P)if(t.indexOf("s")>-1){let{$head:o}=r,s=o.textOffset?null:e<0?o.nodeBefore:o.nodeAfter;if(!s||s.isText||!s.isLeaf)return!1;let i=n.state.doc.resolve(o.pos+s.nodeSize*(e<0?-1:1));return pt(n,new P(r.$anchor,i))}else if(r.empty){if(n.endOfTextblock(e>0?"forward":"backward")){let o=Ko(n.state,e);return o&&o instanceof E?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?E.isSelectable(s)?pt(n,new E(e<0?n.state.doc.resolve(o.pos-s.nodeSize):o)):Rn?pt(n,new P(n.state.doc.resolve(e<0?l:l+s.nodeSize))):!1:!1}}else return!1;else{if(r instanceof E&&r.node.isInline)return pt(n,new P(e>0?r.$to:r.$from));{let o=Ko(n.state,e);return o?pt(n,o):!1}}}function Dr(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Fn(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?Oh(n):Th(n)}function Oh(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<Dr(t)&&Fn(t.childNodes[r],-1)&&(i=!0);;)if(r>0){if(t.nodeType!=1)break;{let l=t.childNodes[r-1];if(Fn(l,-1))o=t,s=--r;else if(l.nodeType==3)t=l,r=t.nodeValue.length;else break}}else{if(ra(t))break;{let l=t.previousSibling;for(;l&&Fn(l,-1);)o=t.parentNode,s=te(l),l=l.previousSibling;if(l)t=l,r=Dr(t);else{if(t=t.parentNode,t==n.dom)break;r=0}}}i?Yo(n,t,r):o&&Yo(n,o,s)}function Th(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let o=Dr(t),s,i;for(;;)if(r<o){if(t.nodeType!=1)break;let l=t.childNodes[r];if(Fn(l,1))s=t,i=++r;else break}else{if(ra(t))break;{let l=t.nextSibling;for(;l&&Fn(l,1);)s=l.parentNode,i=te(l)+1,l=l.nextSibling;if(l)t=l,r=0,o=Dr(t);else{if(t=t.parentNode,t==n.dom)break;r=o=0}}}s&&Yo(n,s,i)}function ra(n){let e=n.pmViewDesc;return e&&e.node&&e.node.isBlock}function vh(n,e){for(;n&&e==n.childNodes.length&&!Vn(n);)e=te(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 Ah(n,e){for(;n&&!e&&!Vn(n);)e=te(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 Yo(n,e,t){if(e.nodeType!=3){let s,i;(i=vh(e,t))?(e=i,t=0):(s=Ah(e,t))&&(e=s,t=s.nodeValue.length)}let r=n.domSelection();if(!r)return;if(Mr(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&&Ze(n)},50)}function oa(n,e){let t=n.state.doc.resolve(e);if(!(se||Zd)&&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 sa(n,e,t){let r=n.state.selection;if(r instanceof P&&!r.empty||t.indexOf("s")>-1||Ne&&t.indexOf("m")>-1)return!1;let{$from:o,$to:s}=r;if(!o.parent.inlineContent||n.endOfTextblock(e<0?"up":"down")){let i=Ko(n.state,e);if(i&&i instanceof E)return pt(n,i)}if(!o.parent.inlineContent){let i=e<0?o:s,l=r instanceof ge?I.near(i,e):I.findFrom(i,e);return l?pt(n,l):!1}return!1}function ia(n,e){if(!(n.state.selection instanceof P))return!0;let{$head:t,$anchor:r,empty:o}=n.state.selection;if(!t.sameParent(r))return!0;if(!o)return!1;if(n.endOfTextblock(e>0?"forward":"backward"))return!0;let s=!t.textOffset&&(e<0?t.nodeBefore:t.nodeAfter);if(s&&!s.isText){let i=n.state.tr;return e<0?i.delete(t.pos-s.nodeSize,t.pos):i.delete(t.pos,t.pos+s.nodeSize),n.dispatch(i),!0}return!1}function la(n,e,t){n.domObserver.stop(),e.contentEditable=t,n.domObserver.start()}function Ph(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;la(n,r,"true"),setTimeout(()=>la(n,r,"false"),20)}return!1}function Ih(n){let e="";return n.ctrlKey&&(e+="c"),n.metaKey&&(e+="m"),n.altKey&&(e+="a"),n.shiftKey&&(e+="s"),e}function Vh(n,e){let t=e.keyCode,r=Ih(e);if(t==8||Ne&&t==72&&r=="c")return ia(n,-1)||cn(n,-1);if(t==46&&!e.shiftKey||Ne&&t==68&&r=="c")return ia(n,1)||cn(n,1);if(t==13||t==27)return!0;if(t==37||Ne&&t==66&&r=="c"){let o=t==37?oa(n,n.state.selection.from)=="ltr"?-1:1:-1;return na(n,o,r)||cn(n,o)}else if(t==39||Ne&&t==70&&r=="c"){let o=t==39?oa(n,n.state.selection.from)=="ltr"?1:-1:1;return na(n,o,r)||cn(n,o)}else{if(t==38||Ne&&t==80&&r=="c")return sa(n,-1,r)||cn(n,-1);if(t==40||Ne&&t==78&&r=="c")return Ph(n)||sa(n,1,r)||cn(n,1);if(r==(Ne?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function aa(n,e){n.someProp("transformCopied",h=>{e=h(e,n)});let t=[],{content:r,openStart:o,openEnd:s}=e;for(;o>1&&s>1&&r.childCount==1&&r.firstChild.childCount==1;){o--,s--;let h=r.firstChild;t.push(h.type.name,h.attrs!=h.type.defaultAttrs?h.attrs:null),r=h.content}let i=n.someProp("clipboardSerializer")||$e.fromSchema(n.state.schema),l=ga(),a=l.createElement("div");a.appendChild(i.serializeFragment(r,{document:l}));let c=a.firstChild,u,f=0;for(;c&&c.nodeType==1&&(u=pa[c.nodeName.toLowerCase()]);){for(let h=u.length-1;h>=0;h--){let p=l.createElement(u[h]);for(;a.firstChild;)p.appendChild(a.firstChild);a.appendChild(p),f++}c=a.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${o} ${s}${f?` -${f}`:""} ${JSON.stringify(t)}`);let d=n.someProp("clipboardTextSerializer",h=>h(e,n))||e.content.textBetween(0,e.content.size,`
39
39
 
40
40
  `);return{dom:a,text:d,slice:e}}function ca(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 M(S.from(n.state.schema.text(e.replace(/\r\n?/g,`
41
- `))),0,0):M.empty;let f=n.someProp("clipboardTextParser",d=>d(e,o,r,n));if(f)l=f;else{let d=o.marks(),{schema:h}=n.state,p=$e.fromSchema(h);i=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(b=>{let y=i.appendChild(document.createElement("p"));b&&y.appendChild(p.serializeNode(h.text(b,d)))})}}else n.someProp("transformPastedHTML",f=>{t=f(t,n)}),i=jh(t),Rn&&Fh(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&&!Rh.test(d.parentNode.nodeName)?{ignore:!0}:null}})),u)l=Bh(ha(l,+u[1],+u[2]),u[4]);else if(l=M.maxOpen(zh(l.content,o),!0),l.openStart||l.openEnd){let f=0,d=0;for(let h=l.content.firstChild;f<l.openStart&&!h.type.spec.isolating;f++,h=h.firstChild);for(let h=l.content.lastChild;d<l.openEnd&&!h.type.spec.isolating;d++,h=h.lastChild);l=ha(l,f,d)}return n.someProp("transformPasted",f=>{l=f(l,n)}),l}const Rh=/^(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 zh(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&&fa(a,s,l,i[i.length-1],0))i[i.length-1]=c;else{i.length&&(i[i.length-1]=da(i[i.length-1],s.length));let u=ua(l,a);i.push(u),o=o.matchType(u.type),s=a}}),i)return S.from(i)}return n}function ua(n,e,t=0){for(let r=e.length-1;r>=t;r--)n=e[r].create(null,S.from(n));return n}function fa(n,e,t,r,o){if(o<n.length&&o<e.length&&n[o]==e[o]){let s=fa(n,e,t,r.lastChild,o+1);if(s)return r.copy(r.content.replaceChild(r.childCount-1,s));if(r.contentMatchAt(r.childCount).matchType(o==n.length-1?t.type:n[o+1]))return r.copy(r.content.append(S.from(ua(t,n,o+1))))}}function da(n,e){if(e==0)return n;let t=n.content.replaceChild(n.childCount-1,da(n.lastChild,e-1)),r=n.contentMatchAt(n.childCount).fillBefore(S.empty,!0);return n.copy(t.append(r))}function Go(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=Go(l,e,t,r,o+1,s)),o>=t&&(l=e<0?i.contentMatchAt(0).fillBefore(l,s<=o).append(l):l.append(i.contentMatchAt(i.childCount).fillBefore(S.empty,!0))),n.replaceChild(e<0?0:n.childCount-1,i.copy(l))}function ha(n,e,t){return e<n.openStart&&(n=new M(Go(n.content,-1,e,n.openStart,0,n.openEnd),e,n.openEnd)),t<n.openEnd&&(n=new M(Go(n.content,1,t,n.openEnd,0,0),n.openStart,t)),n}const pa={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 ma=null;function ga(){return ma||(ma=document.implementation.createHTMLDocument("title"))}let Uo=null;function $h(n){let e=window.trustedTypes;return e?(Uo||(Uo=e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})),Uo.createHTML(n)):n}function jh(n){let e=/^(\s*<meta [^>]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=ga().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(n),o;if((o=r&&pa[r[1].toLowerCase()])&&(n=o.map(s=>"<"+s+">").join("")+n+o.map(s=>"</"+s+">").reverse().join("")),t.innerHTML=$h(n),o)for(let s=0;s<o.length;s++)t=t.querySelector(o[s])||t;return t}function Fh(n){let e=n.querySelectorAll(se?"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 Bh(n,e){if(!n.size)return n;let t=n.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return n}let{content:o,openStart:s,openEnd:i}=n;for(let l=r.length-2;l>=0;l-=2){let a=t.nodes[r[l]];if(!a||a.hasRequiredAttrs())break;o=S.from(a.create(r[l+1],o)),s++,i++}return new M(o,s,i)}const fe={},de={},Lh={touchstart:!0,touchmove:!0};class Wh{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 _h(n){for(let e in fe){let t=fe[e];n.dom.addEventListener(e,n.input.eventHandlers[e]=r=>{Hh(n,r)&&!Qo(n,r)&&(n.editable||!(r.type in de))&&t(n,r)},Lh[e]?{passive:!0}:void 0)}ue&&n.dom.addEventListener("input",()=>null),Xo(n)}function mt(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}function qh(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 Xo(n){n.someProp("handleDOMEvents",e=>{for(let t in e)n.input.eventHandlers[t]||n.dom.addEventListener(t,n.input.eventHandlers[t]=r=>Qo(n,r))})}function Qo(n,e){return n.someProp("handleDOMEvents",t=>{let r=t[e.type];return r?r(n,e)||e.defaultPrevented:!1})}function Hh(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 Jh(n,e){!Qo(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,!ba(n,t)&&(n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),!(Xe&&se&&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))||Vh(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(ba(n,t)||!t.charCode||t.ctrlKey&&!t.altKey||Ne&&t.metaKey)return;if(n.someProp("handleKeyPress",o=>o(n,t))){t.preventDefault();return}let r=n.state.selection;if(!(r instanceof P)||!r.$from.sameParent(r.$to)){let o=String.fromCharCode(t.charCode);!/[\r\n]/.test(o)&&!n.someProp("handleTextInput",s=>s(n,r.$from.pos,r.$to.pos,o))&&n.dispatch(n.state.tr.insertText(o).scrollIntoView()),t.preventDefault()}};function Or(n){return{left:n.clientX,top:n.clientY}}function Kh(n,e){let t=e.x-n.clientX,r=e.y-n.clientY;return t*t+r*r<100}function Zo(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 Yh(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),r=t.nodeAfter;return r&&r.isAtom&&E.isSelectable(r)?(un(n,new E(t)),!0):!1}function Gh(n,e){if(e==-1)return!1;let t=n.state.selection,r,o;t instanceof E&&(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(E.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,E.create(n.state.doc,o)),!0):!1}function Uh(n,e,t,r,o){return Zo(n,"handleClickOn",e,t,r)||n.someProp("handleClick",s=>s(n,e,r))||(o?Gh(n,t):Yh(n,t))}function Xh(n,e,t,r){return Zo(n,"handleDoubleClickOn",e,t,r)||n.someProp("handleDoubleClick",o=>o(n,e,r))}function Qh(n,e,t,r){return Zo(n,"handleTripleClickOn",e,t,r)||n.someProp("handleTripleClick",o=>o(n,e,r))||Zh(n,t,r)}function Zh(n,e,t){if(t.button!=0)return!1;let r=n.state.doc;if(e==-1)return r.inlineContent?(un(n,P.create(r,0,r.content.size)),!0):!1;let o=r.resolve(e);for(let s=o.depth+1;s>0;s--){let i=s>o.depth?o.nodeAfter:o.node(s),l=o.before(s);if(i.inlineContent)un(n,P.create(r,l+1,l+1+i.content.size));else if(E.isSelectable(i))un(n,E.create(r,l));else continue;return!0}}function es(n){return Tr(n)}const ya=Ne?"metaKey":"ctrlKey";fe.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&&Kh(t,n.input.lastClick)&&!t[ya]&&(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(Or(t));i&&(s=="singleClick"?(n.input.mouseDown&&n.input.mouseDown.done(),n.input.mouseDown=new ep(n,i,t,!!r)):(s=="doubleClick"?Xh:Qh)(n,i.pos,i.inside,t)?t.preventDefault():mt(n,"pointer"))};let ep=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[ya],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 E&&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(()=>Ze(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(Or(e))),this.updateAllowDefault(e),this.allowDefault||!t?mt(this.view,"pointer"):Uh(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||ue&&this.mightDrag&&!this.mightDrag.node.isAtom||se&&!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,I.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(),es(n),mt(n,"pointer")},fe.touchmove=n=>{n.input.lastTouch=Date.now(),mt(n,"pointer")},fe.contextmenu=n=>es(n);function ba(n,e){return n.composing?!0:ue&&Math.abs(e.timeStamp-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}const tp=Xe?5e3:-1;de.compositionstart=de.compositionupdate=n=>{if(!n.composing){n.domObserver.flush();let{state:e}=n,t=e.selection.$to;if(e.selection instanceof P&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)))n.markCursor=n.state.storedMarks||t.marks(),Tr(n,!0),n.markCursor=null;else if(Tr(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}xa(n,tp)},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++,xa(n,20))};function xa(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>Tr(n),e))}function ka(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=rp());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function np(n){let e=n.domSelectionRange();if(!e.focusNode)return null;let t=Yd(e.focusNode,e.focusOffset),r=Gd(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 rp(){let n=document.createEvent("Event");return n.initEvent("event",!0,!0),n.timeStamp}function Tr(n,e=!1){if(!(Xe&&n.domObserver.flushingSoon>=0)){if(n.domObserver.forceFlush(),ka(n),e||n.docView&&n.docView.dirty){let t=qo(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 op(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 Bn=ye&&dt<15||sn&&eh<604;fe.copy=de.cut=(n,e)=>{let t=e,r=n.state.selection,o=t.type=="cut";if(r.empty)return;let s=Bn?null:t.clipboardData,i=r.content(),{dom:l,text:a}=aa(n,i);s?(t.preventDefault(),s.clearData(),s.setData("text/html",l.innerHTML),s.setData("text/plain",a)):op(n,l),o&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function sp(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function ip(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=ca(n,e,t,r,n.state.selection.$from);if(n.someProp("handlePaste",a=>a(n,o,s||M.empty)))return!0;if(!s)return!1;let i=sp(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 Sa(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&&!Xe)return;let r=Bn?null:t.clipboardData,o=n.input.shiftKey&&n.input.lastKeyCode!=45;r&&Ln(n,Sa(r),r.getData("text/html"),o,t)?t.preventDefault():ip(n,t)};let Ca=class{constructor(e,t,r){this.slice=e,this.move=t,this.node=r}};const wa=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(Or(t)),i;if(!(s&&s.pos>=o.from&&s.pos<=(o instanceof E?o.to-1:o.to))){if(r&&r.mightDrag)i=E.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=E.create(n.state.doc,f.posBefore))}}let l=(i||n.state.selection).content(),{dom:a,text:c,slice:u}=aa(n,l);(!t.dataTransfer.files.length||!se||Dl>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(Bn?"Text":"text/html",a.innerHTML),t.dataTransfer.effectAllowed="copyMove",Bn||t.dataTransfer.setData("text/plain",c),n.dragging=new Ca(u,!t[wa],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(Or(t));if(!o)return;let s=n.state.doc.resolve(o.pos),i=r&&r.slice;i?n.someProp("transformPasted",p=>{i=p(i,n)}):i=ca(n,Sa(t.dataTransfer),Bn?null:t.dataTransfer.getData("text/html"),!1,s);let l=!!(r&&!t[wa]);if(n.someProp("handleDrop",p=>p(n,t,i||M.empty,l))){t.preventDefault();return}if(!i)return;t.preventDefault();let a=i?xo(n.state.doc,s.pos,i):s.pos;a==null&&(a=s.pos);let c=n.state.tr;if(l){let{node:p}=r;p?p.replace(c):c.deleteSelection()}let u=c.mapping.map(a),f=i.openStart==0&&i.openEnd==0&&i.content.childCount==1,d=c.doc;if(f?c.replaceRangeWith(u,u,i.content.firstChild):c.replaceRange(u,u,i),c.doc.eq(d))return;let h=c.doc.resolve(u);if(f&&E.isSelectable(i.content.firstChild)&&h.nodeAfter&&h.nodeAfter.sameMarkup(i.content.firstChild))c.setSelection(new E(h));else{let p=c.mapping.map(a);c.mapping.maps[c.mapping.maps.length-1].forEach((b,y,k,C)=>p=C),c.setSelection(Jo(n,h,c.doc.resolve(p)))}n.focus(),n.dispatch(c.setMeta("uiEvent","drop"))},fe.focus=n=>{n.input.lastFocus=Date.now(),n.focused||(n.domObserver.stop(),n.dom.classList.add("ProseMirror-focused"),n.domObserver.start(),n.focused=!0,setTimeout(()=>{n.docView&&n.hasFocus()&&!n.domObserver.currentSelection.eq(n.domSelectionRange())&&Ze(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(se&&Xe&&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 Ma=class ff{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 ff&&(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 oi{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 oi&&Wn(this.attrs,e.attrs)&&Wn(this.spec,e.spec)}static is(e){return e.type instanceof oi}destroy(){}},lp=class df{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 df&&Wn(this.attrs,e.attrs)&&Wn(this.spec,e.spec)}destroy(){}},Ve=class sr{constructor(e,t,r){this.from=e,this.to=t,this.type=r}copy(e,t){return new sr(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 sr(e,e,new Ma(t,r))}static inline(e,t,r,o){return new sr(e,t,new _n(r,o))}static node(e,t,r,o){return new sr(e,t,new lp(r,o))}get spec(){return this.type.spec}get inline(){return this.type instanceof _n}get widget(){return this.type instanceof Ma}};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?vr(t,e,0,jt):ie}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==ie||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?ap(this.children,i||[],e,t,r,o,s):i?new Ot(i.sort(Ft),fn):ie}add(e,t){return t.length?this==ie?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=Da(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,vr(u,l,c+1,jt)),s+=3}});let i=Ea(s?Oa(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(Ft):this.local,o||this.children)}remove(e){return e.length==0||this==ie?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!=ie?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):ie}forChild(e,t){if(this==ie)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(Ft),fn);return r?new Na([l,r]):l}return r||ie}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 ts(this.localsInner(e))}localsInner(e){if(this==ie)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=ts;const ie=H.empty;let Na=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!=ie&&(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?ts(r?t:t.sort(Ft)):fn}static from(e){switch(e.length){case 0:return ie;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 ap(n,e,t,r,o,s,i){let l=n.slice();for(let c=0,u=s;c<t.maps.length;c++){let f=0;t.maps[c].forEach((d,h,p,b)=>{let y=b-p-(h-d);for(let k=0;k<l.length;k+=3){let C=l[k+1];if(C<0||d>C+u-f)continue;let w=l[k]+u-f;h>=w?l[k+1]=d<=w?-2:-1:d>=u&&y&&(l[k]+=y,l[k+1]+=y)}f+=y}),u=t.maps[c].map(u,-1)}let a=!1;for(let c=0;c<l.length;c+=3)if(l[c+1]<0){if(l[c+1]==-2){a=!0,l[c+1]=-1;continue}let u=t.map(n[c]+s),f=u-o;if(f<0||f>=r.content.size){a=!0;continue}let d=t.map(n[c+1]+s,-1),h=d-o,{index:p,offset:b}=r.content.findIndex(f),y=r.maybeChild(p);if(y&&b==f&&b+y.nodeSize==h){let k=l[c+2].mapInner(t,y,u+1,n[c]+s+1,i);k!=ie?(l[c]=f,l[c+1]=h,l[c+2]=k):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=cp(l,n,e,t,o,s,i),u=vr(c,r,0,i);e=u.local;for(let f=0;f<l.length;f+=3)l[f+1]<0&&(l.splice(f,3),f-=3);for(let f=0,d=0;f<u.children.length;f+=3){let h=u.children[f];for(;d<l.length&&l[d]<h;)d+=3;l.splice(d,0,u.children[f],u.children[f+1],u.children[f+2])}}return new H(e.sort(Ft),l)}function Ea(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 cp(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 Da(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 Oa(n){let e=[];for(let t=0;t<n.length;t++)n[t]!=null&&e.push(n[t]);return e}function vr(n,e,t,r){let o=[],s=!1;e.forEach((l,a)=>{let c=Da(n,l,a+t);if(c){s=!0;let u=vr(c,l,t+a+1,r);u!=ie&&o.push(a,a+l.nodeSize,u)}});let i=Ea(s?Oa(n):n,-t).sort(Ft);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):ie}function Ft(n,e){return n.from-e.from||n.to-e.to}function ts(n){let e=n;for(let t=0;t<e.length-1;t++){let r=e[t];if(r.from!=r.to)for(let o=t+1;o<e.length;o++){let s=e[o];if(s.from==r.from){s.to!=r.to&&(e==n&&(e=n.slice()),e[o]=s.copy(s.from,r.to),Ta(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),Ta(e,o,r.copy(s.from,r.to)));break}}}return e}function Ta(n,e,t){for(;e<n.length&&Ft(t,n[e])>0;)e++;n.splice(e,0,t)}function ns(n){let e=[];return n.someProp("decorations",t=>{let r=t(n.state);r&&r!=ie&&e.push(r)}),n.cursorWrapper&&e.push(H.create(n.state.doc,[n.cursorWrapper.deco])),Na.from(e)}const up={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},fp=ye&&dt<=11;let dp=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 hp{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new dp,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()}),fp&&(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,up)),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(ea(this.view)){if(this.suppressingSelectionUpdates)return Ze(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)&&ea(e)&&!this.ignoreSelectionChange(r),s=-1,i=-1,l=!1,a=[];if(e.editable)for(let u=0;u<t.length;u++){let f=this.registerMutation(t[u],a);f&&(s=s<0?f.from:Math.min(f.from,s),i=i<0?f.to:Math.max(f.to,i),f.typeOver&&(l=!0))}if(Ie&&a.length){let u=a.filter(f=>f.nodeName=="BR");if(u.length==2){let[f,d]=u;f.parentNode&&f.parentNode.parentNode==d.parentNode?d.remove():f.remove()}else{let{focusNode:f}=this.currentSelection;for(let d of u){let h=d.parentNode;h&&h.nodeName=="LI"&&(!f||gp(e,f)!=h)&&d.remove()}}}let c=null;s<0&&o&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&Mr(r)&&(c=qo(e))&&c.eq(I.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,Ze(e),this.currentSelection.set(r),e.scrollToSelection()):(s>-1||o)&&(s>-1&&(e.docView.markDirty(s,i),pp(e)),this.handleDOMChange(s,i,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||Ze(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?te(o)+1:0,l=r.localPosFromDOM(e.target,i,-1),a=s&&s.parentNode==e.target?te(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,Aa=!1;function pp(n){if(!va.has(n)&&(va.set(n,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(n.dom).whiteSpace)!==-1)){if(n.requiresGeckoHackNode=Ie,Aa)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."),Aa=!0}}function Pa(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 mp(n,e){if(e.getComposedRanges){let o=e.getComposedRanges(n.root)[0];if(o)return Pa(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?Pa(n,t):null}function gp(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 yp(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}],Mr(a)||c.push({node:a.focusNode,offset:a.focusOffset})),se&&n.input.lastKeyCode===8)for(let y=s;y>o;y--){let k=r.childNodes[y-1],C=k.pmViewDesc;if(k.nodeName=="BR"&&!C){s=y;break}if(!C||C.size)break}let f=n.state.doc,d=n.someProp("domParser")||Pt.fromSchema(n.state.schema),h=f.resolve(i),p=null,b=d.parse(r,{topNode:h.parent,topMatch:h.parent.contentMatchAt(h.index()),topOpen:!0,from:o,to:s,preserveWhitespace:h.parent.type.whitespace=="pre"?"full":!0,findPositions:c,ruleFromNode:bp,context:h});if(c&&c[0].pos!=null){let y=c[0].pos,k=c[1]&&c[1].pos;k==null&&(k=y),p={anchor:y+i,head:k+i}}return{doc:b,sel:p,from:i,to:l}}function bp(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 xp=/^(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 kp(n,e,t,r,o){let s=n.input.compositionPendingChanges||(n.composing?n.input.compositionID:0);if(n.input.compositionPendingChanges=0,e<0){let A=n.input.lastSelectionTime>Date.now()-50?n.input.lastSelectionOrigin:null,L=qo(n,A);if(L&&!n.state.selection.eq(L)){if(se&&Xe&&n.input.lastKeyCode===13&&Date.now()-100<n.input.lastKeyCodeTime&&n.someProp("handleKeyDown",Et=>Et(n,Rt(13,"Enter"))))return;let Ce=n.state.tr.setSelection(L);A=="pointer"?Ce.setMeta("pointer",!0):A=="key"&&Ce.scrollIntoView(),s&&Ce.setMeta("composition",s),n.dispatch(Ce)}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=yp(n,e,t),u=n.state.doc,f=u.slice(c.from,c.to),d,h;n.input.lastKeyCode===8&&Date.now()-100<n.input.lastKeyCodeTime?(d=n.state.selection.to,h="end"):(d=n.state.selection.from,h="start"),n.input.lastKeyCode=null;let p=wp(f.content,c.doc.content,c.from,d,h);if(p&&n.input.domChangeCount++,(sn&&n.input.lastIOSEnter>Date.now()-225||Xe)&&o.some(A=>A.nodeType==1&&!xp.test(A.nodeName))&&(!p||p.endA>=p.endB)&&n.someProp("handleKeyDown",A=>A(n,Rt(13,"Enter")))){n.input.lastIOSEnter=0;return}if(!p)if(r&&a instanceof P&&!a.empty&&a.$head.sameParent(a.$anchor)&&!n.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))p={start:a.from,endA:a.to,endB:a.to};else{if(c.sel){let A=Ia(n,n.state.doc,c.sel);if(A&&!A.eq(n.state.selection)){let L=n.state.tr.setSelection(A);s&&L.setMeta("composition",s),n.dispatch(L)}}return}n.state.selection.from<n.state.selection.to&&p.start==p.endB&&n.state.selection instanceof P&&(p.start>n.state.selection.from&&p.start<=n.state.selection.from+2&&n.state.selection.from>=c.from?p.start=n.state.selection.from:p.endA<n.state.selection.to&&p.endA>=n.state.selection.to-2&&n.state.selection.to<=c.to&&(p.endB+=n.state.selection.to-p.endA,p.endA=n.state.selection.to)),ye&&dt<=11&&p.endB==p.start+1&&p.endA==p.start&&p.start>c.from&&c.doc.textBetween(p.start-c.from-1,p.start-c.from+1)=="  "&&(p.start--,p.endA--,p.endB--);let b=c.doc.resolveNoCache(p.start-c.from),y=c.doc.resolveNoCache(p.endB-c.from),k=u.resolve(p.start),C=b.sameParent(y)&&b.parent.inlineContent&&k.end()>=p.endA,w;if((sn&&n.input.lastIOSEnter>Date.now()-225&&(!C||o.some(A=>A.nodeName=="DIV"||A.nodeName=="P"))||!C&&b.pos<c.doc.content.size&&!b.sameParent(y)&&(w=I.findFrom(c.doc.resolve(b.pos+1),1,!0))&&w.head==y.pos)&&n.someProp("handleKeyDown",A=>A(n,Rt(13,"Enter")))){n.input.lastIOSEnter=0;return}if(n.state.selection.anchor>p.start&&Cp(u,p.start,p.endA,b,y)&&n.someProp("handleKeyDown",A=>A(n,Rt(8,"Backspace")))){Xe&&se&&n.domObserver.suppressSelectionUpdates();return}se&&p.endB==p.start&&(n.input.lastChromeDelete=Date.now()),Xe&&!C&&b.start()!=y.start()&&y.parentOffset==0&&b.depth==y.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==p.endA&&(p.endB-=2,y=c.doc.resolveNoCache(p.endB-c.from),setTimeout(()=>{n.someProp("handleKeyDown",function(A){return A(n,Rt(13,"Enter"))})},20));let D=p.start,V=p.endA,O,B,$;if(C){if(b.pos==y.pos)ye&&dt<=11&&b.parentOffset==0&&(n.domObserver.suppressSelectionUpdates(),setTimeout(()=>Ze(n),20)),O=n.state.tr.delete(D,V),B=u.resolve(p.start).marksAcross(u.resolve(p.endA));else if(p.endA==p.endB&&($=Sp(b.parent.content.cut(b.parentOffset,y.parentOffset),k.parent.content.cut(k.parentOffset,p.endA-k.start()))))O=n.state.tr,$.type=="add"?O.addMark(D,V,$.mark):O.removeMark(D,V,$.mark);else if(b.parent.child(b.index()).isText&&b.index()==y.index()-(y.textOffset?0:1)){let A=b.parent.textBetween(b.parentOffset,y.parentOffset);if(n.someProp("handleTextInput",L=>L(n,D,V,A)))return;O=n.state.tr.insertText(A,D,V)}}if(O||(O=n.state.tr.replace(D,V,c.doc.slice(p.start-c.from,p.endB-c.from))),c.sel){let A=Ia(n,O.doc,c.sel);A&&!(se&&n.composing&&A.empty&&(p.start!=p.endB||n.input.lastChromeDelete<Date.now()-100)&&(A.head==D||A.head==O.mapping.map(V)-1)||ye&&A.empty&&A.head==D)&&O.setSelection(A)}B&&O.ensureMarks(B),s&&O.setMeta("composition",s),n.dispatch(O.scrollIntoView())}function Ia(n,e,t){return Math.max(t.anchor,t.head)>e.content.size?null:Jo(n,e.resolve(t.anchor),e.resolve(t.head))}function Sp(n,e){let t=n.firstChild.marks,r=e.firstChild.marks,o=t,s=r,i,l,a;for(let u=0;u<r.length;u++)o=r[u].removeFromSet(o);for(let u=0;u<t.length;u++)s=t[u].removeFromSet(s);if(o.length==1&&s.length==0)l=o[0],i="add",a=u=>u.mark(l.addToSet(u.marks));else if(o.length==0&&s.length==1)l=s[0],i="remove",a=u=>u.mark(l.removeFromSet(u.marks));else return null;let c=[];for(let u=0;u<e.childCount;u++)c.push(a(e.child(u)));if(S.from(c).eq(n))return{mark:l,type:i}}function Cp(n,e,t,r,o){if(t-e<=o.pos-r.pos||rs(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(rs(s,!0,!0));return!i.parent.isTextblock||i.pos>t||rs(i,!0,!1)<t?!1:r.parent.content.cut(r.parentOffset).eq(i.parent.content)}function rs(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 wp(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&&Va(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&&Va(n.textBetween(s-1,s+1))&&(s+=a?1:-1),i=s+(i-l),l=s}return{start:s,endA:i,endB:l}}function Va(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 Mp{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 Wh,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(Fa),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):typeof e=="function"?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=$a(this),za(this),this.nodeViews=ja(this),this.docView=Ll(this.state.doc,Ra(this),ns(this),this.dom,this),this.domObserver=new hp(this,(r,o,s,i)=>kp(this,r,o,s,i)),this.domObserver.start(),_h(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&&Xo(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Fa),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let r in this._props)t[r]=this._props[r];t.state=this.state;for(let r in e)t[r]=e[r];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var r;let o=this.state,s=!1,i=!1;e.storedMarks&&this.composing&&(ka(this),i=!0),this.state=e;let l=o.plugins!=e.plugins||this._props.plugins!=t.plugins;if(l||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let h=ja(this);Ep(h,this.nodeViews)&&(this.nodeViews=h,s=!0)}(l||t.handleDOMEvents!=this._props.handleDOMEvents)&&Xo(this),this.editable=$a(this),za(this);let a=ns(this),c=Ra(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&&rh(this);if(i){this.domObserver.stop();let h=f&&(ye||se)&&!this.composing&&!o.selection.empty&&!e.selection.empty&&Np(o.selection,e.selection);if(f){let p=se?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=np(this)),(s||!this.docView.update(e.doc,c,a,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=Ll(e.doc,c,a,this.dom,this)),p&&!this.trackWrites&&(h=!0)}h||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&Dh(this))?Ze(this,h):(Ql(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&&oh(d)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof E){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&Ol(this,t.getBoundingClientRect(),e)}else Ol(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 Ca(e.slice,e.move,o<0?void 0:E.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&&sh(this.dom),Ze(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 uh(this,e)}coordsAtPos(e,t=1){return Vl(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 mh(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&&(qh(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],ns(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Jd())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return Jh(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&&Xd(this.dom.ownerDocument)==this.dom&&mp(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}function Ra(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 za(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 $a(n){return!n.someProp("editable",e=>e(n.state)===!1)}function Np(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 ja(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 Ep(n,e){let t=0,r=0;for(let o in n){if(n[o]!=e[o])return!0;t++}for(let o in e)r++;return t!=r}function Fa(n){if(n.spec.state||n.spec.filterTransaction||n.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}class q extends I{constructor(e){super(e,e)}map(e,t){let r=e.resolve(t.map(this.head));return q.valid(r)?new q(r):I.near(r)}content(){return M.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 ss(this.anchor)}static valid(e){let t=e.parent;if(t.isTextblock||!Dp(e)||!Op(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&&!E.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,I.jsonID("gapcursor",q);class ss{constructor(e){this.pos=e}map(e){return new ss(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return q.valid(t)?new q(t):I.near(t)}}function Dp(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 Op(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 Tp(){return new Ye({props:{decorations:Ip,createSelectionBetween(n,e,t){return e.pos==t.pos&&q.valid(t)?new q(t):null},handleClick:Ap,handleKeyDown:vp,handleDOMEvents:{beforeinput:Pp}}})}const vp=vo({ArrowLeft:Ar("horiz",-1),ArrowRight:Ar("horiz",1),ArrowUp:Ar("vert",-1),ArrowDown:Ar("vert",1)});function Ar(n,e){const t=n=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,o,s){let i=r.selection,l=e>0?i.$to:i.$from,a=i.empty;if(i instanceof P){if(!s.endOfTextblock(t)||l.depth==0)return!1;a=!1,l=r.doc.resolve(e>0?l.after():l.before())}let c=q.findGapCursorFrom(l,e,a);return c?(o&&o(r.tr.setSelection(new q(c))),!0):!1}}function Ap(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&&E.isSelectable(n.state.doc.nodeAt(o.inside))?!1:(n.dispatch(n.state.tr.setSelection(new q(r))),!0)}function Pp(n,e){if(e.inputType!="insertCompositionText"||!(n.state.selection instanceof q))return!1;let{$from:t}=n.state.selection,r=t.parent.contentMatchAt(t.index()).findWrapping(n.state.schema.nodes.text);if(!r)return!1;let o=S.empty;for(let i=r.length-1;i>=0;i--)o=S.from(r[i].createAndFill(null,o));let s=n.state.tr.replace(t.pos,t.pos,new M(o,0,0));return s.setSelection(P.near(s.doc.resolve(t.pos+1))),n.dispatch(s),!1}function Ip(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 Vp=["ol",0],Rp=["ul",0],zp=["li",0],$p={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?Vp:["ol",{start:n.attrs.order},0]}},jp={parseDOM:[{tag:"ul"}],toDOM(){return Rp}},Fp={parseDOM:[{tag:"li"}],toDOM(){return zp},defining:!0};function is(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 Bp(n,e,t){return n.append({ordered_list:is($p,{content:"list_item+",group:t}),bullet_list:is(jp,{content:"list_item+",group:t}),list_item:is(Fp,{content:e})})}function Pr(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 Lp(l,i,n,e)?(r&&r(l.scrollIntoView()),!0):!1}}function Lp(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 ur(a,a,e.depth),e.endIndex<e.parent.childCount&&(e=new ur(e.$from,i.resolve(e.$to.end(e.depth)),e.depth)),o=!0}let l=bo(s,t,r,e);return l?(n&&Wp(n,e,l,o,t),!0):!1}function Wp(n,e,t,r,o){let s=S.empty;for(let u=t.length-1;u>=0;u--)s=S.from(t[u].type.create(t[u].attrs,s));n.step(new Z(e.start-(r?2:0),e.end,e.start,e.end,new M(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 _p(n,e){return function(t,r){let{$from:o,$to:s,node:i}=t.selection;if(i&&i.isBlock||o.depth<2||!o.sameParent(s))return!1;let l=o.node(-1);if(l.type!=n)return!1;if(o.parent.content.size==0&&o.node(-1).childCount==o.indexAfter(-1)){if(o.depth==3||o.node(-3).type!=n||o.index(-2)!=o.node(-2).childCount-1)return!1;if(r){let f=S.empty,d=o.index(-1)?1:o.index(-2)?2:3;for(let k=o.depth-d;k>=o.depth-3;k--)f=S.from(o.node(k).copy(f));let h=o.indexAfter(-1)<o.node(-2).childCount?1:o.indexAfter(-2)<o.node(-3).childCount?2:3;f=f.append(S.from(n.createAndFill()));let p=o.before(o.depth-(d-1)),b=t.tr.replace(p,o.after(-h),new M(f,4-d,0)),y=-1;b.doc.nodesBetween(p,b.doc.content.size,(k,C)=>{if(y>-1)return!1;k.isTextblock&&k.content.size==0&&(y=C+1)}),y>-1&&b.setSelection(I.near(b.doc.resolve(y))),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 qp(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?Hp(e,t,n,s):Jp(e,t,s):!0:!1}}function Hp(n,e,t,r){let o=n.tr,s=r.end,i=r.$to.end(r.depth);s<i&&(o.step(new Z(s-1,i,s,i,new M(S.from(t.create(null,r.parent.copy())),1,0),1,!0)),r=new ur(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 Jp(n,e,t){let r=n.tr,o=t.parent;for(let h=t.end,p=t.endIndex-1,b=t.startIndex;p>b;p--)h-=o.child(p).nodeSize,r.delete(h-1,h+1);let s=r.doc.resolve(t.start),i=s.nodeAfter;if(r.mapping.map(t.end)!=t.start+s.nodeAfter.nodeSize)return!1;let l=t.startIndex==0,a=t.endIndex==o.childCount,c=s.node(-1),u=s.index(-1);if(!c.canReplace(u+(l?0:1),u+1,i.content.append(a?S.empty:S.from(o))))return!1;let f=s.pos,d=f+i.nodeSize;return r.step(new Z(f-(l?1:0),d+(a?1:0),f+1,d-1,new M((l?S.empty:S.from(o.copy(S.empty))).append(a?S.empty:S.from(o.copy(S.empty))),l?0:1,a?0:1),l?0:1)),e(r.scrollIntoView()),!0}function Kp(n){return function(e,t){let{$from:r,$to:o}=e.selection,s=r.blockRange(o,c=>c.childCount>0&&c.firstChild.type==n);if(!s)return!1;let i=s.startIndex;if(i==0)return!1;let l=s.parent,a=l.child(i-1);if(a.type!=n)return!1;if(t){let c=a.lastChild&&a.lastChild.type==l.type,u=S.from(c?n.create():null),f=new M(S.from(n.create(null,S.from(l.type.create(null,u)))),c?3:1,0),d=s.start,h=s.end;t(e.tr.step(new Z(d-(c?3:1),h,d,h,f,1,!0)).scrollIntoView())}return!0}}class gt{constructor(e,t,r={}){this.match=e,this.match=e,this.handler=typeof t=="string"?Yp(t):t,this.undoable=r.undoable!==!1,this.inCode=r.inCode||!1,this.inCodeMark=r.inCodeMark!==!1}}function Yp(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 Gp=500;function Up({rules:n}){let e=new Ye({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 Ba(t,r,o,s,n,e)},handleDOMEvents:{compositionend:t=>{setTimeout(()=>{let{$cursor:r}=t.state.selection;r&&Ba(t,r.pos,r.pos,"",n,e)})}}},isInputRules:!0});return e}function Ba(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-Gp),l.parentOffset,null,"")+r;for(let c=0;c<o.length;c++){let u=o[c];if(!u.inCodeMark&&l.marks().some(h=>h.type.spec.code))continue;if(l.parent.type.spec.code){if(!u.inCode)continue}else if(u.inCode==="only")continue;let f=u.match.exec(a),d=f&&f[0].length>=r.length&&u.handler(i,f,e-(f[0].length-r.length),t);if(d)return u.undoable&&d.setMeta(s,{transform:d,from:e,to:t,text:r}),n.dispatch(d),!0}return!1}const Xp=(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},Qp=new gt(/--$/,"—",{inCodeMark:!1}),Zp=new gt(/\.\.\.$/,"…",{inCodeMark:!1}),em=new gt(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,"“",{inCodeMark:!1}),tm=new gt(/"$/,"”",{inCodeMark:!1}),nm=new gt(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,"‘",{inCodeMark:!1}),rm=new gt(/'$/,"’",{inCodeMark:!1}),om=[em,tm,nm,rm];function ls(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&&bo(f,e,a);if(!d)return null;c.wrap(f,d);let h=c.doc.resolve(i-1).nodeBefore;return h&&h.type==e&&Zt(c.doc,i-1)&&(!r||r(s,h))&&c.join(i-1),c})}function La(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 Wa=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):!1;function sm(n,e){let t={},r;function o(s,i){t[s]=i}if(o("Mod-z",Io),o("Shift-Mod-z",Cr),o("Backspace",Xp),Wa||o("Mod-y",Cr),o("Alt-ArrowUp",ml),o("Alt-ArrowDown",Pd),o("Mod-BracketLeft",gl),o("Escape",bl),(r=n.marks.strong)&&(o("Mod-b",we(r)),o("Mod-B",we(r))),(r=n.marks.em)&&(o("Mod-i",we(r)),o("Mod-I",we(r))),(r=n.marks.code)&&o("Mod-`",we(r)),(r=n.nodes.bullet_list)&&o("Shift-Ctrl-8",Pr(r)),(r=n.nodes.ordered_list)&&o("Shift-Ctrl-9",Pr(r)),(r=n.nodes.blockquote)&&o("Ctrl->",Sl(r)),r=n.nodes.hard_break){let s=r,i=wr(yl,(l,a)=>(a&&a(l.tr.replaceSelectionWith(s.create()).scrollIntoView()),!0));o("Mod-Enter",i),o("Shift-Enter",i),Wa&&o("Ctrl-Enter",i)}if((r=n.nodes.list_item)&&(o("Enter",_p(r)),o("Mod-[",qp(r)),o("Mod-]",Kp(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 im(n){return ls(/^\s*>\s$/,n)}function lm(n){return ls(/^(\d+)\.\s$/,n,e=>({order:+e[1]}),(e,t)=>t.childCount+t.attrs.order==+e[1])}function am(n){return ls(/^\s*([-+*])\s$/,n)}function cm(n){return La(/^```$/,n)}function um(n,e){return La(new RegExp("^(#{1,"+e+"})\\s$"),n,t=>({level:t[1].length}))}function fm(n){let e=om.concat(Zp,Qp),t;return(t=n.nodes.blockquote)&&e.push(im(t)),(t=n.nodes.ordered_list)&&e.push(lm(t)),(t=n.nodes.bullet_list)&&e.push(am(t)),(t=n.nodes.code_block)&&e.push(cm(t)),(t=n.nodes.heading)&&e.push(um(t,6)),Up({rules:e})}const et=new lt("ImagePluginKey"),dm=n=>new Ye({key:et,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(et);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}}}),hm=(n,e)=>{const t=et.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},pm=async(n,e,t)=>{if(!e)return;const r=Date.now(),o=n.state.tr;o.selection.empty||o.deleteSelection(),o.setMeta(et,{add:{id:r,pos:o.selection.from}}),n.dispatch(o);try{const s=et.getState(n.state),i=s.schema,l=s.upload;if(!l)throw new Error("startImageUpload: Image upload function not defined");const a=await l(e);if(typeof a=="string")throw new Error(a);const c=hm(n.state,r);if(c===null){console.warn("startImageUpload: The image was removed from the document during upload");return}n.dispatch(n.state.tr.replaceWith(c,c,i.nodes.image.create({fid:a,title:t})).setMeta(et,{remove:{id:r}}))}catch(s){n.dispatch(n.state.tr.setMeta(et,{remove:{id:r}})),console.error(`startImageUpload: ${s}`)}},mm=(n,e,t)=>{if(!e)return;const r=n.state.tr;r.selection.empty||r.deleteSelection();const o=r.selection.from,s=et.getState(n.state).schema;n.dispatch(n.state.tr.replaceWith(o,o,s.nodes.image.create({src:e,title:t})))},Bt=function(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e},_a=function(n,e,t,r){return t&&(qa(n,e,t,r,-1)||qa(n,e,t,r,1))},gm=/^(img|br|input|textarea|hr)$/i;function qa(n,e,t,r,o){for(;;){if(n==t&&e==r)return!0;if(e==(o<0?0:Ir(n))){let s=n.parentNode;if(!s||s.nodeType!=1||as(n)||gm.test(n.nodeName)||n.contentEditable=="false")return!1;e=Bt(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?Ir(n):0}else return!1}}function Ir(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function ym(n,e,t){for(let r=e==0,o=e==Ir(n);r||o;){if(n==t)return!0;let s=Bt(n);if(n=n.parentNode,!n)return!1;r=r&&s==0,o=o&&s==Ir(n)}}function as(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 Ha=function(n){return n.focusNode&&_a(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)};function Ja(n,e){let t=document.createEvent("Event");return t.initEvent("keydown",!0,!0),t.keyCode=n,t.key=t.code=e,t}const We=typeof navigator<"u"?navigator:null,Ka=typeof document<"u"?document:null,yt=We&&We.userAgent||"",cs=/Edge\/(\d+)/.exec(yt),Ya=/MSIE \d/.exec(yt),us=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(yt),qn=!!(Ya||us||cs),Ga=Ya?document.documentMode:us?+us[1]:cs?+cs[1]:0,Vr=!qn&&/gecko\/(\d+)/i.test(yt);Vr&&+(/Firefox\/(\d+)/.exec(yt)||[0,0])[1];const fs=!qn&&/Chrome\/(\d+)/.exec(yt),bt=!!fs,Ua=fs?+fs[1]:0,Lt=!qn&&!!We&&/Apple Computer/.test(We.vendor),ds=Lt&&(/Mobile\/\w+/.test(yt)||!!We&&We.maxTouchPoints>2),De=ds||(We?/Mac/.test(We.platform):!1),bm=We?/Win/.test(We.platform):!1,Hn=/Android \d/.test(yt),hs=!!Ka&&"webkitFontSmoothing"in Ka.documentElement.style,xm=hs?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function km(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(Ha(t)){for(a=i;o&&!o.node;)o=o.parent;let f=o.node;if(o&&f.isAtom&&E.isSelectable(f)&&o.parent&&!(f.isInline&&ym(t.focusNode,t.focusOffset,o.dom))){let d=o.posBefore;c=new E(i==d?l:r.resolve(d))}}else{if(t instanceof n.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let f=i,d=i;for(let h=0;h<t.rangeCount;h++){let p=t.getRangeAt(h);f=Math.min(f,n.docView.posFromDOM(p.startContainer,p.startOffset,1)),d=Math.max(d,n.docView.posFromDOM(p.endContainer,p.endOffset,-1))}if(f<0)return null;[a,i]=d==n.state.selection.anchor?[d,f]:[f,d],l=r.resolve(i)}else a=n.docView.posFromDOM(t.anchorNode,t.anchorOffset,1);if(a<0)return null}let u=r.resolve(a);if(!c){let f=e=="pointer"||n.state.selection.head<l.pos&&!s?1:-1;c=nc(n,u,l,f)}return c}function Xa(n){return n.editable?n.hasFocus():Mm(n)&&document.activeElement&&document.activeElement.contains(n.dom)}function ps(n,e=!1){let t=n.state.selection;if(wm(n,t),!!Xa(n)){if(!e&&n.input.mouseDown&&n.input.mouseDown.allowDefault&&bt){let r=n.domSelectionRange(),o=n.domObserver.currentSelection;if(r.anchorNode&&o.anchorNode&&_a(r.anchorNode,r.anchorOffset,o.anchorNode,o.anchorOffset)){n.input.mouseDown.delayedSelectionSync=!0,n.domObserver.setCurSelection();return}}if(n.domObserver.disconnectSelection(),n.cursorWrapper)Cm(n);else{let{anchor:r,head:o}=t,s,i;Qa&&!(t instanceof P)&&(t.$from.parent.inlineContent||(s=Za(n,t.from)),!t.empty&&!t.$from.parent.inlineContent&&(i=Za(n,t.to))),n.docView.setSelection(r,o,n,e),Qa&&(s&&ec(s),i&&ec(i)),t.visible?n.dom.classList.remove("ProseMirror-hideselection"):(n.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&Sm(n))}n.domObserver.setCurSelection(),n.domObserver.connectSelection()}}const Qa=Lt||bt&&Ua<63;function Za(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 ms(o);if((!o||o.contentEditable=="false")&&(!s||s.contentEditable=="false")){if(o)return ms(o);if(s)return ms(s)}}function ms(n){return n.contentEditable="true",Lt&&n.draggable&&(n.draggable=!1,n.wasDraggable=!0),n}function ec(n){n.contentEditable="false",n.wasDraggable&&(n.draggable=!0,n.wasDraggable=null)}function Sm(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(()=>{(!Xa(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function Cm(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,Bt(r)+1):t.setStart(r,0),t.collapse(!0),e.removeAllRanges(),e.addRange(t),!o&&!n.state.selection.visible&&qn&&Ga<=11&&(r.disabled=!0,r.disabled=!1)}function wm(n,e){if(e instanceof E){let t=n.docView.descAt(e.from);t!=n.lastSelectedViewDesc&&(tc(n),t&&t.selectNode(),n.lastSelectedViewDesc=t)}else tc(n)}function tc(n){n.lastSelectedViewDesc&&(n.lastSelectedViewDesc.parent&&n.lastSelectedViewDesc.deselectNode(),n.lastSelectedViewDesc=void 0)}function nc(n,e,t,r){return n.someProp("createSelectionBetween",o=>o(n,e,t))||P.between(e,t,r)}function Mm(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 gs(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&&I.findFrom(s,e)}function xt(n,e){return n.dispatch(n.state.tr.setSelection(e).scrollIntoView()),!0}function rc(n,e,t){let r=n.state.selection;if(r instanceof P)if(t.indexOf("s")>-1){let{$head:o}=r,s=o.textOffset?null:e<0?o.nodeBefore:o.nodeAfter;if(!s||s.isText||!s.isLeaf)return!1;let i=n.state.doc.resolve(o.pos+s.nodeSize*(e<0?-1:1));return xt(n,new P(r.$anchor,i))}else if(r.empty){if(n.endOfTextblock(e>0?"forward":"backward")){let o=gs(n.state,e);return o&&o instanceof E?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?E.isSelectable(s)?xt(n,new E(e<0?n.state.doc.resolve(o.pos-s.nodeSize):o)):hs?xt(n,new P(n.state.doc.resolve(e<0?l:l+s.nodeSize))):!1:!1}}else return!1;else{if(r instanceof E&&r.node.isInline)return xt(n,new P(e>0?r.$to:r.$from));{let o=gs(n.state,e);return o?xt(n,o):!1}}}function Rr(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Jn(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?Nm(n):Em(n)}function Nm(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let o,s,i=!1;for(Vr&&t.nodeType==1&&r<Rr(t)&&Jn(t.childNodes[r],-1)&&(i=!0);;)if(r>0){if(t.nodeType!=1)break;{let l=t.childNodes[r-1];if(Jn(l,-1))o=t,s=--r;else if(l.nodeType==3)t=l,r=t.nodeValue.length;else break}}else{if(oc(t))break;{let l=t.previousSibling;for(;l&&Jn(l,-1);)o=t.parentNode,s=Bt(l),l=l.previousSibling;if(l)t=l,r=Rr(t);else{if(t=t.parentNode,t==n.dom)break;r=0}}}i?ys(n,t,r):o&&ys(n,o,s)}function Em(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let o=Rr(t),s,i;for(;;)if(r<o){if(t.nodeType!=1)break;let l=t.childNodes[r];if(Jn(l,1))s=t,i=++r;else break}else{if(oc(t))break;{let l=t.nextSibling;for(;l&&Jn(l,1);)s=l.parentNode,i=Bt(l)+1,l=l.nextSibling;if(l)t=l,r=0,o=Rr(t);else{if(t=t.parentNode,t==n.dom)break;r=o=0}}}s&&ys(n,s,i)}function oc(n){let e=n.pmViewDesc;return e&&e.node&&e.node.isBlock}function Dm(n,e){for(;n&&e==n.childNodes.length&&!as(n);)e=Bt(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 Om(n,e){for(;n&&!e&&!as(n);)e=Bt(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 ys(n,e,t){if(e.nodeType!=3){let s,i;(i=Dm(e,t))?(e=i,t=0):(s=Om(e,t))&&(e=s,t=s.nodeValue.length)}let r=n.domSelection();if(!r)return;if(Ha(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&&ps(n)},50)}function sc(n,e){let t=n.state.doc.resolve(e);if(!(bt||bm)&&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 ic(n,e,t){let r=n.state.selection;if(r instanceof P&&!r.empty||t.indexOf("s")>-1||De&&t.indexOf("m")>-1)return!1;let{$from:o,$to:s}=r;if(!o.parent.inlineContent||n.endOfTextblock(e<0?"up":"down")){let i=gs(n.state,e);if(i&&i instanceof E)return xt(n,i)}if(!o.parent.inlineContent){let i=e<0?o:s,l=r instanceof ge?I.near(i,e):I.findFrom(i,e);return l?xt(n,l):!1}return!1}function lc(n,e){if(!(n.state.selection instanceof P))return!0;let{$head:t,$anchor:r,empty:o}=n.state.selection;if(!t.sameParent(r))return!0;if(!o)return!1;if(n.endOfTextblock(e>0?"forward":"backward"))return!0;let s=!t.textOffset&&(e<0?t.nodeBefore:t.nodeAfter);if(s&&!s.isText){let i=n.state.tr;return e<0?i.delete(t.pos-s.nodeSize,t.pos):i.delete(t.pos,t.pos+s.nodeSize),n.dispatch(i),!0}return!1}function ac(n,e,t){n.domObserver.stop(),e.contentEditable=t,n.domObserver.start()}function Tm(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;ac(n,r,"true"),setTimeout(()=>ac(n,r,"false"),20)}return!1}function vm(n){let e="";return n.ctrlKey&&(e+="c"),n.metaKey&&(e+="m"),n.altKey&&(e+="a"),n.shiftKey&&(e+="s"),e}function Am(n,e){let t=e.keyCode,r=vm(e);if(t==8||De&&t==72&&r=="c")return lc(n,-1)||dn(n,-1);if(t==46&&!e.shiftKey||De&&t==68&&r=="c")return lc(n,1)||dn(n,1);if(t==13||t==27)return!0;if(t==37||De&&t==66&&r=="c"){let o=t==37?sc(n,n.state.selection.from)=="ltr"?-1:1:-1;return rc(n,o,r)||dn(n,o)}else if(t==39||De&&t==70&&r=="c"){let o=t==39?sc(n,n.state.selection.from)=="ltr"?1:-1:1;return rc(n,o,r)||dn(n,o)}else{if(t==38||De&&t==80&&r=="c")return ic(n,-1,r)||dn(n,-1);if(t==40||De&&t==78&&r=="c")return Tm(n)||ic(n,1,r)||dn(n,1);if(r==(De?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function cc(n,e){n.someProp("transformCopied",h=>{e=h(e,n)});let t=[],{content:r,openStart:o,openEnd:s}=e;for(;o>1&&s>1&&r.childCount==1&&r.firstChild.childCount==1;){o--,s--;let h=r.firstChild;t.push(h.type.name,h.attrs!=h.type.defaultAttrs?h.attrs:null),r=h.content}let i=n.someProp("clipboardSerializer")||$e.fromSchema(n.state.schema),l=yc(),a=l.createElement("div");a.appendChild(i.serializeFragment(r,{document:l}));let c=a.firstChild,u,f=0;for(;c&&c.nodeType==1&&(u=mc[c.nodeName.toLowerCase()]);){for(let h=u.length-1;h>=0;h--){let p=l.createElement(u[h]);for(;a.firstChild;)p.appendChild(a.firstChild);a.appendChild(p),f++}c=a.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${o} ${s}${f?` -${f}`:""} ${JSON.stringify(t)}`);let d=n.someProp("clipboardTextSerializer",h=>h(e,n))||e.content.textBetween(0,e.content.size,`
41
+ `))),0,0):M.empty;let f=n.someProp("clipboardTextParser",d=>d(e,o,r,n));if(f)l=f;else{let d=o.marks(),{schema:h}=n.state,p=$e.fromSchema(h);i=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(b=>{let y=i.appendChild(document.createElement("p"));b&&y.appendChild(p.serializeNode(h.text(b,d)))})}}else n.someProp("transformPastedHTML",f=>{t=f(t,n)}),i=jh(t),Rn&&Fh(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&&!Rh.test(d.parentNode.nodeName)?{ignore:!0}:null}})),u)l=Bh(ha(l,+u[1],+u[2]),u[4]);else if(l=M.maxOpen(zh(l.content,o),!0),l.openStart||l.openEnd){let f=0,d=0;for(let h=l.content.firstChild;f<l.openStart&&!h.type.spec.isolating;f++,h=h.firstChild);for(let h=l.content.lastChild;d<l.openEnd&&!h.type.spec.isolating;d++,h=h.lastChild);l=ha(l,f,d)}return n.someProp("transformPasted",f=>{l=f(l,n)}),l}const Rh=/^(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 zh(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&&fa(a,s,l,i[i.length-1],0))i[i.length-1]=c;else{i.length&&(i[i.length-1]=da(i[i.length-1],s.length));let u=ua(l,a);i.push(u),o=o.matchType(u.type),s=a}}),i)return S.from(i)}return n}function ua(n,e,t=0){for(let r=e.length-1;r>=t;r--)n=e[r].create(null,S.from(n));return n}function fa(n,e,t,r,o){if(o<n.length&&o<e.length&&n[o]==e[o]){let s=fa(n,e,t,r.lastChild,o+1);if(s)return r.copy(r.content.replaceChild(r.childCount-1,s));if(r.contentMatchAt(r.childCount).matchType(o==n.length-1?t.type:n[o+1]))return r.copy(r.content.append(S.from(ua(t,n,o+1))))}}function da(n,e){if(e==0)return n;let t=n.content.replaceChild(n.childCount-1,da(n.lastChild,e-1)),r=n.contentMatchAt(n.childCount).fillBefore(S.empty,!0);return n.copy(t.append(r))}function Go(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=Go(l,e,t,r,o+1,s)),o>=t&&(l=e<0?i.contentMatchAt(0).fillBefore(l,s<=o).append(l):l.append(i.contentMatchAt(i.childCount).fillBefore(S.empty,!0))),n.replaceChild(e<0?0:n.childCount-1,i.copy(l))}function ha(n,e,t){return e<n.openStart&&(n=new M(Go(n.content,-1,e,n.openStart,0,n.openEnd),e,n.openEnd)),t<n.openEnd&&(n=new M(Go(n.content,1,t,n.openEnd,0,0),n.openStart,t)),n}const pa={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 ma=null;function ga(){return ma||(ma=document.implementation.createHTMLDocument("title"))}let Uo=null;function $h(n){let e=window.trustedTypes;return e?(Uo||(Uo=e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})),Uo.createHTML(n)):n}function jh(n){let e=/^(\s*<meta [^>]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=ga().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(n),o;if((o=r&&pa[r[1].toLowerCase()])&&(n=o.map(s=>"<"+s+">").join("")+n+o.map(s=>"</"+s+">").reverse().join("")),t.innerHTML=$h(n),o)for(let s=0;s<o.length;s++)t=t.querySelector(o[s])||t;return t}function Fh(n){let e=n.querySelectorAll(se?"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 Bh(n,e){if(!n.size)return n;let t=n.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return n}let{content:o,openStart:s,openEnd:i}=n;for(let l=r.length-2;l>=0;l-=2){let a=t.nodes[r[l]];if(!a||a.hasRequiredAttrs())break;o=S.from(a.create(r[l+1],o)),s++,i++}return new M(o,s,i)}const fe={},de={},Lh={touchstart:!0,touchmove:!0};class Wh{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 _h(n){for(let e in fe){let t=fe[e];n.dom.addEventListener(e,n.input.eventHandlers[e]=r=>{Hh(n,r)&&!Qo(n,r)&&(n.editable||!(r.type in de))&&t(n,r)},Lh[e]?{passive:!0}:void 0)}ue&&n.dom.addEventListener("input",()=>null),Xo(n)}function mt(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}function qh(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 Xo(n){n.someProp("handleDOMEvents",e=>{for(let t in e)n.input.eventHandlers[t]||n.dom.addEventListener(t,n.input.eventHandlers[t]=r=>Qo(n,r))})}function Qo(n,e){return n.someProp("handleDOMEvents",t=>{let r=t[e.type];return r?r(n,e)||e.defaultPrevented:!1})}function Hh(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 Jh(n,e){!Qo(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,!ba(n,t)&&(n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),!(Xe&&se&&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))||Vh(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(ba(n,t)||!t.charCode||t.ctrlKey&&!t.altKey||Ne&&t.metaKey)return;if(n.someProp("handleKeyPress",o=>o(n,t))){t.preventDefault();return}let r=n.state.selection;if(!(r instanceof P)||!r.$from.sameParent(r.$to)){let o=String.fromCharCode(t.charCode);!/[\r\n]/.test(o)&&!n.someProp("handleTextInput",s=>s(n,r.$from.pos,r.$to.pos,o))&&n.dispatch(n.state.tr.insertText(o).scrollIntoView()),t.preventDefault()}};function Or(n){return{left:n.clientX,top:n.clientY}}function Kh(n,e){let t=e.x-n.clientX,r=e.y-n.clientY;return t*t+r*r<100}function Zo(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 Yh(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),r=t.nodeAfter;return r&&r.isAtom&&E.isSelectable(r)?(un(n,new E(t)),!0):!1}function Gh(n,e){if(e==-1)return!1;let t=n.state.selection,r,o;t instanceof E&&(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(E.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,E.create(n.state.doc,o)),!0):!1}function Uh(n,e,t,r,o){return Zo(n,"handleClickOn",e,t,r)||n.someProp("handleClick",s=>s(n,e,r))||(o?Gh(n,t):Yh(n,t))}function Xh(n,e,t,r){return Zo(n,"handleDoubleClickOn",e,t,r)||n.someProp("handleDoubleClick",o=>o(n,e,r))}function Qh(n,e,t,r){return Zo(n,"handleTripleClickOn",e,t,r)||n.someProp("handleTripleClick",o=>o(n,e,r))||Zh(n,t,r)}function Zh(n,e,t){if(t.button!=0)return!1;let r=n.state.doc;if(e==-1)return r.inlineContent?(un(n,P.create(r,0,r.content.size)),!0):!1;let o=r.resolve(e);for(let s=o.depth+1;s>0;s--){let i=s>o.depth?o.nodeAfter:o.node(s),l=o.before(s);if(i.inlineContent)un(n,P.create(r,l+1,l+1+i.content.size));else if(E.isSelectable(i))un(n,E.create(r,l));else continue;return!0}}function es(n){return Tr(n)}const ya=Ne?"metaKey":"ctrlKey";fe.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&&Kh(t,n.input.lastClick)&&!t[ya]&&(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(Or(t));i&&(s=="singleClick"?(n.input.mouseDown&&n.input.mouseDown.done(),n.input.mouseDown=new ep(n,i,t,!!r)):(s=="doubleClick"?Xh:Qh)(n,i.pos,i.inside,t)?t.preventDefault():mt(n,"pointer"))};let ep=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[ya],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 E&&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(()=>Ze(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(Or(e))),this.updateAllowDefault(e),this.allowDefault||!t?mt(this.view,"pointer"):Uh(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||ue&&this.mightDrag&&!this.mightDrag.node.isAtom||se&&!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,I.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(),es(n),mt(n,"pointer")},fe.touchmove=n=>{n.input.lastTouch=Date.now(),mt(n,"pointer")},fe.contextmenu=n=>es(n);function ba(n,e){return n.composing?!0:ue&&Math.abs(e.timeStamp-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}const tp=Xe?5e3:-1;de.compositionstart=de.compositionupdate=n=>{if(!n.composing){n.domObserver.flush();let{state:e}=n,t=e.selection.$to;if(e.selection instanceof P&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)))n.markCursor=n.state.storedMarks||t.marks(),Tr(n,!0),n.markCursor=null;else if(Tr(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}xa(n,tp)},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++,xa(n,20))};function xa(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>Tr(n),e))}function ka(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=rp());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function np(n){let e=n.domSelectionRange();if(!e.focusNode)return null;let t=Yd(e.focusNode,e.focusOffset),r=Gd(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 rp(){let n=document.createEvent("Event");return n.initEvent("event",!0,!0),n.timeStamp}function Tr(n,e=!1){if(!(Xe&&n.domObserver.flushingSoon>=0)){if(n.domObserver.forceFlush(),ka(n),e||n.docView&&n.docView.dirty){let t=qo(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 op(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 Bn=ye&&dt<15||sn&&eh<604;fe.copy=de.cut=(n,e)=>{let t=e,r=n.state.selection,o=t.type=="cut";if(r.empty)return;let s=Bn?null:t.clipboardData,i=r.content(),{dom:l,text:a}=aa(n,i);s?(t.preventDefault(),s.clearData(),s.setData("text/html",l.innerHTML),s.setData("text/plain",a)):op(n,l),o&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function sp(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function ip(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=ca(n,e,t,r,n.state.selection.$from);if(n.someProp("handlePaste",a=>a(n,o,s||M.empty)))return!0;if(!s)return!1;let i=sp(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 Sa(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&&!Xe)return;let r=Bn?null:t.clipboardData,o=n.input.shiftKey&&n.input.lastKeyCode!=45;r&&Ln(n,Sa(r),r.getData("text/html"),o,t)?t.preventDefault():ip(n,t)};let Ca=class{constructor(e,t,r){this.slice=e,this.move=t,this.node=r}};const wa=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(Or(t)),i;if(!(s&&s.pos>=o.from&&s.pos<=(o instanceof E?o.to-1:o.to))){if(r&&r.mightDrag)i=E.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=E.create(n.state.doc,f.posBefore))}}let l=(i||n.state.selection).content(),{dom:a,text:c,slice:u}=aa(n,l);(!t.dataTransfer.files.length||!se||Dl>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(Bn?"Text":"text/html",a.innerHTML),t.dataTransfer.effectAllowed="copyMove",Bn||t.dataTransfer.setData("text/plain",c),n.dragging=new Ca(u,!t[wa],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(Or(t));if(!o)return;let s=n.state.doc.resolve(o.pos),i=r&&r.slice;i?n.someProp("transformPasted",p=>{i=p(i,n)}):i=ca(n,Sa(t.dataTransfer),Bn?null:t.dataTransfer.getData("text/html"),!1,s);let l=!!(r&&!t[wa]);if(n.someProp("handleDrop",p=>p(n,t,i||M.empty,l))){t.preventDefault();return}if(!i)return;t.preventDefault();let a=i?xo(n.state.doc,s.pos,i):s.pos;a==null&&(a=s.pos);let c=n.state.tr;if(l){let{node:p}=r;p?p.replace(c):c.deleteSelection()}let u=c.mapping.map(a),f=i.openStart==0&&i.openEnd==0&&i.content.childCount==1,d=c.doc;if(f?c.replaceRangeWith(u,u,i.content.firstChild):c.replaceRange(u,u,i),c.doc.eq(d))return;let h=c.doc.resolve(u);if(f&&E.isSelectable(i.content.firstChild)&&h.nodeAfter&&h.nodeAfter.sameMarkup(i.content.firstChild))c.setSelection(new E(h));else{let p=c.mapping.map(a);c.mapping.maps[c.mapping.maps.length-1].forEach((b,y,k,C)=>p=C),c.setSelection(Jo(n,h,c.doc.resolve(p)))}n.focus(),n.dispatch(c.setMeta("uiEvent","drop"))},fe.focus=n=>{n.input.lastFocus=Date.now(),n.focused||(n.domObserver.stop(),n.dom.classList.add("ProseMirror-focused"),n.domObserver.start(),n.focused=!0,setTimeout(()=>{n.docView&&n.hasFocus()&&!n.domObserver.currentSelection.eq(n.domSelectionRange())&&Ze(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(se&&Xe&&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 Ma=class ff{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 ff&&(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 oi{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 oi&&Wn(this.attrs,e.attrs)&&Wn(this.spec,e.spec)}static is(e){return e.type instanceof oi}destroy(){}},lp=class df{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 df&&Wn(this.attrs,e.attrs)&&Wn(this.spec,e.spec)}destroy(){}},Ve=class sr{constructor(e,t,r){this.from=e,this.to=t,this.type=r}copy(e,t){return new sr(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 sr(e,e,new Ma(t,r))}static inline(e,t,r,o){return new sr(e,t,new _n(r,o))}static node(e,t,r,o){return new sr(e,t,new lp(r,o))}get spec(){return this.type.spec}get inline(){return this.type instanceof _n}get widget(){return this.type instanceof Ma}};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?vr(t,e,0,jt):ie}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==ie||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?ap(this.children,i||[],e,t,r,o,s):i?new Ot(i.sort(Ft),fn):ie}add(e,t){return t.length?this==ie?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=Da(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,vr(u,l,c+1,jt)),s+=3}});let i=Ea(s?Oa(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(Ft):this.local,o||this.children)}remove(e){return e.length==0||this==ie?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!=ie?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):ie}forChild(e,t){if(this==ie)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(Ft),fn);return r?new Na([l,r]):l}return r||ie}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 ts(this.localsInner(e))}localsInner(e){if(this==ie)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=ts;const ie=H.empty;let Na=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!=ie&&(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?ts(r?t:t.sort(Ft)):fn}static from(e){switch(e.length){case 0:return ie;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 ap(n,e,t,r,o,s,i){let l=n.slice();for(let c=0,u=s;c<t.maps.length;c++){let f=0;t.maps[c].forEach((d,h,p,b)=>{let y=b-p-(h-d);for(let k=0;k<l.length;k+=3){let C=l[k+1];if(C<0||d>C+u-f)continue;let w=l[k]+u-f;h>=w?l[k+1]=d<=w?-2:-1:d>=u&&y&&(l[k]+=y,l[k+1]+=y)}f+=y}),u=t.maps[c].map(u,-1)}let a=!1;for(let c=0;c<l.length;c+=3)if(l[c+1]<0){if(l[c+1]==-2){a=!0,l[c+1]=-1;continue}let u=t.map(n[c]+s),f=u-o;if(f<0||f>=r.content.size){a=!0;continue}let d=t.map(n[c+1]+s,-1),h=d-o,{index:p,offset:b}=r.content.findIndex(f),y=r.maybeChild(p);if(y&&b==f&&b+y.nodeSize==h){let k=l[c+2].mapInner(t,y,u+1,n[c]+s+1,i);k!=ie?(l[c]=f,l[c+1]=h,l[c+2]=k):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=cp(l,n,e,t,o,s,i),u=vr(c,r,0,i);e=u.local;for(let f=0;f<l.length;f+=3)l[f+1]<0&&(l.splice(f,3),f-=3);for(let f=0,d=0;f<u.children.length;f+=3){let h=u.children[f];for(;d<l.length&&l[d]<h;)d+=3;l.splice(d,0,u.children[f],u.children[f+1],u.children[f+2])}}return new H(e.sort(Ft),l)}function Ea(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 cp(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 Da(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 Oa(n){let e=[];for(let t=0;t<n.length;t++)n[t]!=null&&e.push(n[t]);return e}function vr(n,e,t,r){let o=[],s=!1;e.forEach((l,a)=>{let c=Da(n,l,a+t);if(c){s=!0;let u=vr(c,l,t+a+1,r);u!=ie&&o.push(a,a+l.nodeSize,u)}});let i=Ea(s?Oa(n):n,-t).sort(Ft);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):ie}function Ft(n,e){return n.from-e.from||n.to-e.to}function ts(n){let e=n;for(let t=0;t<e.length-1;t++){let r=e[t];if(r.from!=r.to)for(let o=t+1;o<e.length;o++){let s=e[o];if(s.from==r.from){s.to!=r.to&&(e==n&&(e=n.slice()),e[o]=s.copy(s.from,r.to),Ta(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),Ta(e,o,r.copy(s.from,r.to)));break}}}return e}function Ta(n,e,t){for(;e<n.length&&Ft(t,n[e])>0;)e++;n.splice(e,0,t)}function ns(n){let e=[];return n.someProp("decorations",t=>{let r=t(n.state);r&&r!=ie&&e.push(r)}),n.cursorWrapper&&e.push(H.create(n.state.doc,[n.cursorWrapper.deco])),Na.from(e)}const up={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},fp=ye&&dt<=11;let dp=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 hp{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new dp,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()}),fp&&(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,up)),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(ea(this.view)){if(this.suppressingSelectionUpdates)return Ze(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)&&ea(e)&&!this.ignoreSelectionChange(r),s=-1,i=-1,l=!1,a=[];if(e.editable)for(let u=0;u<t.length;u++){let f=this.registerMutation(t[u],a);f&&(s=s<0?f.from:Math.min(f.from,s),i=i<0?f.to:Math.max(f.to,i),f.typeOver&&(l=!0))}if(Ie&&a.length){let u=a.filter(f=>f.nodeName=="BR");if(u.length==2){let[f,d]=u;f.parentNode&&f.parentNode.parentNode==d.parentNode?d.remove():f.remove()}else{let{focusNode:f}=this.currentSelection;for(let d of u){let h=d.parentNode;h&&h.nodeName=="LI"&&(!f||gp(e,f)!=h)&&d.remove()}}}let c=null;s<0&&o&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&Mr(r)&&(c=qo(e))&&c.eq(I.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,Ze(e),this.currentSelection.set(r),e.scrollToSelection()):(s>-1||o)&&(s>-1&&(e.docView.markDirty(s,i),pp(e)),this.handleDOMChange(s,i,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(r)||Ze(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?te(o)+1:0,l=r.localPosFromDOM(e.target,i,-1),a=s&&s.parentNode==e.target?te(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,Aa=!1;function pp(n){if(!va.has(n)&&(va.set(n,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(n.dom).whiteSpace)!==-1)){if(n.requiresGeckoHackNode=Ie,Aa)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."),Aa=!0}}function Pa(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 mp(n,e){if(e.getComposedRanges){let o=e.getComposedRanges(n.root)[0];if(o)return Pa(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?Pa(n,t):null}function gp(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 yp(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}],Mr(a)||c.push({node:a.focusNode,offset:a.focusOffset})),se&&n.input.lastKeyCode===8)for(let y=s;y>o;y--){let k=r.childNodes[y-1],C=k.pmViewDesc;if(k.nodeName=="BR"&&!C){s=y;break}if(!C||C.size)break}let f=n.state.doc,d=n.someProp("domParser")||Pt.fromSchema(n.state.schema),h=f.resolve(i),p=null,b=d.parse(r,{topNode:h.parent,topMatch:h.parent.contentMatchAt(h.index()),topOpen:!0,from:o,to:s,preserveWhitespace:h.parent.type.whitespace=="pre"?"full":!0,findPositions:c,ruleFromNode:bp,context:h});if(c&&c[0].pos!=null){let y=c[0].pos,k=c[1]&&c[1].pos;k==null&&(k=y),p={anchor:y+i,head:k+i}}return{doc:b,sel:p,from:i,to:l}}function bp(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 xp=/^(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 kp(n,e,t,r,o){let s=n.input.compositionPendingChanges||(n.composing?n.input.compositionID:0);if(n.input.compositionPendingChanges=0,e<0){let A=n.input.lastSelectionTime>Date.now()-50?n.input.lastSelectionOrigin:null,L=qo(n,A);if(L&&!n.state.selection.eq(L)){if(se&&Xe&&n.input.lastKeyCode===13&&Date.now()-100<n.input.lastKeyCodeTime&&n.someProp("handleKeyDown",Et=>Et(n,Rt(13,"Enter"))))return;let Ce=n.state.tr.setSelection(L);A=="pointer"?Ce.setMeta("pointer",!0):A=="key"&&Ce.scrollIntoView(),s&&Ce.setMeta("composition",s),n.dispatch(Ce)}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=yp(n,e,t),u=n.state.doc,f=u.slice(c.from,c.to),d,h;n.input.lastKeyCode===8&&Date.now()-100<n.input.lastKeyCodeTime?(d=n.state.selection.to,h="end"):(d=n.state.selection.from,h="start"),n.input.lastKeyCode=null;let p=wp(f.content,c.doc.content,c.from,d,h);if(p&&n.input.domChangeCount++,(sn&&n.input.lastIOSEnter>Date.now()-225||Xe)&&o.some(A=>A.nodeType==1&&!xp.test(A.nodeName))&&(!p||p.endA>=p.endB)&&n.someProp("handleKeyDown",A=>A(n,Rt(13,"Enter")))){n.input.lastIOSEnter=0;return}if(!p)if(r&&a instanceof P&&!a.empty&&a.$head.sameParent(a.$anchor)&&!n.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))p={start:a.from,endA:a.to,endB:a.to};else{if(c.sel){let A=Ia(n,n.state.doc,c.sel);if(A&&!A.eq(n.state.selection)){let L=n.state.tr.setSelection(A);s&&L.setMeta("composition",s),n.dispatch(L)}}return}n.state.selection.from<n.state.selection.to&&p.start==p.endB&&n.state.selection instanceof P&&(p.start>n.state.selection.from&&p.start<=n.state.selection.from+2&&n.state.selection.from>=c.from?p.start=n.state.selection.from:p.endA<n.state.selection.to&&p.endA>=n.state.selection.to-2&&n.state.selection.to<=c.to&&(p.endB+=n.state.selection.to-p.endA,p.endA=n.state.selection.to)),ye&&dt<=11&&p.endB==p.start+1&&p.endA==p.start&&p.start>c.from&&c.doc.textBetween(p.start-c.from-1,p.start-c.from+1)=="  "&&(p.start--,p.endA--,p.endB--);let b=c.doc.resolveNoCache(p.start-c.from),y=c.doc.resolveNoCache(p.endB-c.from),k=u.resolve(p.start),C=b.sameParent(y)&&b.parent.inlineContent&&k.end()>=p.endA,w;if((sn&&n.input.lastIOSEnter>Date.now()-225&&(!C||o.some(A=>A.nodeName=="DIV"||A.nodeName=="P"))||!C&&b.pos<c.doc.content.size&&!b.sameParent(y)&&(w=I.findFrom(c.doc.resolve(b.pos+1),1,!0))&&w.head==y.pos)&&n.someProp("handleKeyDown",A=>A(n,Rt(13,"Enter")))){n.input.lastIOSEnter=0;return}if(n.state.selection.anchor>p.start&&Cp(u,p.start,p.endA,b,y)&&n.someProp("handleKeyDown",A=>A(n,Rt(8,"Backspace")))){Xe&&se&&n.domObserver.suppressSelectionUpdates();return}se&&p.endB==p.start&&(n.input.lastChromeDelete=Date.now()),Xe&&!C&&b.start()!=y.start()&&y.parentOffset==0&&b.depth==y.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==p.endA&&(p.endB-=2,y=c.doc.resolveNoCache(p.endB-c.from),setTimeout(()=>{n.someProp("handleKeyDown",function(A){return A(n,Rt(13,"Enter"))})},20));let D=p.start,V=p.endA,O,B,$;if(C){if(b.pos==y.pos)ye&&dt<=11&&b.parentOffset==0&&(n.domObserver.suppressSelectionUpdates(),setTimeout(()=>Ze(n),20)),O=n.state.tr.delete(D,V),B=u.resolve(p.start).marksAcross(u.resolve(p.endA));else if(p.endA==p.endB&&($=Sp(b.parent.content.cut(b.parentOffset,y.parentOffset),k.parent.content.cut(k.parentOffset,p.endA-k.start()))))O=n.state.tr,$.type=="add"?O.addMark(D,V,$.mark):O.removeMark(D,V,$.mark);else if(b.parent.child(b.index()).isText&&b.index()==y.index()-(y.textOffset?0:1)){let A=b.parent.textBetween(b.parentOffset,y.parentOffset);if(n.someProp("handleTextInput",L=>L(n,D,V,A)))return;O=n.state.tr.insertText(A,D,V)}}if(O||(O=n.state.tr.replace(D,V,c.doc.slice(p.start-c.from,p.endB-c.from))),c.sel){let A=Ia(n,O.doc,c.sel);A&&!(se&&n.composing&&A.empty&&(p.start!=p.endB||n.input.lastChromeDelete<Date.now()-100)&&(A.head==D||A.head==O.mapping.map(V)-1)||ye&&A.empty&&A.head==D)&&O.setSelection(A)}B&&O.ensureMarks(B),s&&O.setMeta("composition",s),n.dispatch(O.scrollIntoView())}function Ia(n,e,t){return Math.max(t.anchor,t.head)>e.content.size?null:Jo(n,e.resolve(t.anchor),e.resolve(t.head))}function Sp(n,e){let t=n.firstChild.marks,r=e.firstChild.marks,o=t,s=r,i,l,a;for(let u=0;u<r.length;u++)o=r[u].removeFromSet(o);for(let u=0;u<t.length;u++)s=t[u].removeFromSet(s);if(o.length==1&&s.length==0)l=o[0],i="add",a=u=>u.mark(l.addToSet(u.marks));else if(o.length==0&&s.length==1)l=s[0],i="remove",a=u=>u.mark(l.removeFromSet(u.marks));else return null;let c=[];for(let u=0;u<e.childCount;u++)c.push(a(e.child(u)));if(S.from(c).eq(n))return{mark:l,type:i}}function Cp(n,e,t,r,o){if(t-e<=o.pos-r.pos||rs(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(rs(s,!0,!0));return!i.parent.isTextblock||i.pos>t||rs(i,!0,!1)<t?!1:r.parent.content.cut(r.parentOffset).eq(i.parent.content)}function rs(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 wp(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&&Va(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&&Va(n.textBetween(s-1,s+1))&&(s+=a?1:-1),i=s+(i-l),l=s}return{start:s,endA:i,endB:l}}function Va(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 Mp{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 Wh,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(Fa),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):typeof e=="function"?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=$a(this),za(this),this.nodeViews=ja(this),this.docView=Ll(this.state.doc,Ra(this),ns(this),this.dom,this),this.domObserver=new hp(this,(r,o,s,i)=>kp(this,r,o,s,i)),this.domObserver.start(),_h(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&&Xo(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Fa),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let r in this._props)t[r]=this._props[r];t.state=this.state;for(let r in e)t[r]=e[r];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var r;let o=this.state,s=!1,i=!1;e.storedMarks&&this.composing&&(ka(this),i=!0),this.state=e;let l=o.plugins!=e.plugins||this._props.plugins!=t.plugins;if(l||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let h=ja(this);Ep(h,this.nodeViews)&&(this.nodeViews=h,s=!0)}(l||t.handleDOMEvents!=this._props.handleDOMEvents)&&Xo(this),this.editable=$a(this),za(this);let a=ns(this),c=Ra(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&&rh(this);if(i){this.domObserver.stop();let h=f&&(ye||se)&&!this.composing&&!o.selection.empty&&!e.selection.empty&&Np(o.selection,e.selection);if(f){let p=se?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=np(this)),(s||!this.docView.update(e.doc,c,a,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=Ll(e.doc,c,a,this.dom,this)),p&&!this.trackWrites&&(h=!0)}h||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&Dh(this))?Ze(this,h):(Ql(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&&oh(d)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof E){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&Ol(this,t.getBoundingClientRect(),e)}else Ol(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 Ca(e.slice,e.move,o<0?void 0:E.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&&sh(this.dom),Ze(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 uh(this,e)}coordsAtPos(e,t=1){return Vl(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 mh(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&&(qh(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],ns(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Jd())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return Jh(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&&Xd(this.dom.ownerDocument)==this.dom&&mp(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}function Ra(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 za(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 $a(n){return!n.someProp("editable",e=>e(n.state)===!1)}function Np(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 ja(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 Ep(n,e){let t=0,r=0;for(let o in n){if(n[o]!=e[o])return!0;t++}for(let o in e)r++;return t!=r}function Fa(n){if(n.spec.state||n.spec.filterTransaction||n.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}class q extends I{constructor(e){super(e,e)}map(e,t){let r=e.resolve(t.map(this.head));return q.valid(r)?new q(r):I.near(r)}content(){return M.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 ss(this.anchor)}static valid(e){let t=e.parent;if(t.isTextblock||!Dp(e)||!Op(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&&!E.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,I.jsonID("gapcursor",q);class ss{constructor(e){this.pos=e}map(e){return new ss(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return q.valid(t)?new q(t):I.near(t)}}function Dp(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 Op(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 Tp(){return new Ye({props:{decorations:Ip,createSelectionBetween(n,e,t){return e.pos==t.pos&&q.valid(t)?new q(t):null},handleClick:Ap,handleKeyDown:vp,handleDOMEvents:{beforeinput:Pp}}})}const vp=vo({ArrowLeft:Ar("horiz",-1),ArrowRight:Ar("horiz",1),ArrowUp:Ar("vert",-1),ArrowDown:Ar("vert",1)});function Ar(n,e){const t=n=="vert"?e>0?"down":"up":e>0?"right":"left";return function(r,o,s){let i=r.selection,l=e>0?i.$to:i.$from,a=i.empty;if(i instanceof P){if(!s.endOfTextblock(t)||l.depth==0)return!1;a=!1,l=r.doc.resolve(e>0?l.after():l.before())}let c=q.findGapCursorFrom(l,e,a);return c?(o&&o(r.tr.setSelection(new q(c))),!0):!1}}function Ap(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&&E.isSelectable(n.state.doc.nodeAt(o.inside))?!1:(n.dispatch(n.state.tr.setSelection(new q(r))),!0)}function Pp(n,e){if(e.inputType!="insertCompositionText"||!(n.state.selection instanceof q))return!1;let{$from:t}=n.state.selection,r=t.parent.contentMatchAt(t.index()).findWrapping(n.state.schema.nodes.text);if(!r)return!1;let o=S.empty;for(let i=r.length-1;i>=0;i--)o=S.from(r[i].createAndFill(null,o));let s=n.state.tr.replace(t.pos,t.pos,new M(o,0,0));return s.setSelection(P.near(s.doc.resolve(t.pos+1))),n.dispatch(s),!1}function Ip(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 Vp=["ol",0],Rp=["ul",0],zp=["li",0],$p={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?Vp:["ol",{start:n.attrs.order},0]}},jp={parseDOM:[{tag:"ul"}],toDOM(){return Rp}},Fp={parseDOM:[{tag:"li"}],toDOM(){return zp},defining:!0};function is(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 Bp(n,e,t){return n.append({ordered_list:is($p,{content:"list_item+",group:t}),bullet_list:is(jp,{content:"list_item+",group:t}),list_item:is(Fp,{content:e})})}function Pr(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 Lp(l,i,n,e)?(r&&r(l.scrollIntoView()),!0):!1}}function Lp(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 ur(a,a,e.depth),e.endIndex<e.parent.childCount&&(e=new ur(e.$from,i.resolve(e.$to.end(e.depth)),e.depth)),o=!0}let l=bo(s,t,r,e);return l?(n&&Wp(n,e,l,o,t),!0):!1}function Wp(n,e,t,r,o){let s=S.empty;for(let u=t.length-1;u>=0;u--)s=S.from(t[u].type.create(t[u].attrs,s));n.step(new Z(e.start-(r?2:0),e.end,e.start,e.end,new M(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 _p(n,e){return function(t,r){let{$from:o,$to:s,node:i}=t.selection;if(i&&i.isBlock||o.depth<2||!o.sameParent(s))return!1;let l=o.node(-1);if(l.type!=n)return!1;if(o.parent.content.size==0&&o.node(-1).childCount==o.indexAfter(-1)){if(o.depth==3||o.node(-3).type!=n||o.index(-2)!=o.node(-2).childCount-1)return!1;if(r){let f=S.empty,d=o.index(-1)?1:o.index(-2)?2:3;for(let k=o.depth-d;k>=o.depth-3;k--)f=S.from(o.node(k).copy(f));let h=o.indexAfter(-1)<o.node(-2).childCount?1:o.indexAfter(-2)<o.node(-3).childCount?2:3;f=f.append(S.from(n.createAndFill()));let p=o.before(o.depth-(d-1)),b=t.tr.replace(p,o.after(-h),new M(f,4-d,0)),y=-1;b.doc.nodesBetween(p,b.doc.content.size,(k,C)=>{if(y>-1)return!1;k.isTextblock&&k.content.size==0&&(y=C+1)}),y>-1&&b.setSelection(I.near(b.doc.resolve(y))),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 qp(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?Hp(e,t,n,s):Jp(e,t,s):!0:!1}}function Hp(n,e,t,r){let o=n.tr,s=r.end,i=r.$to.end(r.depth);s<i&&(o.step(new Z(s-1,i,s,i,new M(S.from(t.create(null,r.parent.copy())),1,0),1,!0)),r=new ur(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 Jp(n,e,t){let r=n.tr,o=t.parent;for(let h=t.end,p=t.endIndex-1,b=t.startIndex;p>b;p--)h-=o.child(p).nodeSize,r.delete(h-1,h+1);let s=r.doc.resolve(t.start),i=s.nodeAfter;if(r.mapping.map(t.end)!=t.start+s.nodeAfter.nodeSize)return!1;let l=t.startIndex==0,a=t.endIndex==o.childCount,c=s.node(-1),u=s.index(-1);if(!c.canReplace(u+(l?0:1),u+1,i.content.append(a?S.empty:S.from(o))))return!1;let f=s.pos,d=f+i.nodeSize;return r.step(new Z(f-(l?1:0),d+(a?1:0),f+1,d-1,new M((l?S.empty:S.from(o.copy(S.empty))).append(a?S.empty:S.from(o.copy(S.empty))),l?0:1,a?0:1),l?0:1)),e(r.scrollIntoView()),!0}function Kp(n){return function(e,t){let{$from:r,$to:o}=e.selection,s=r.blockRange(o,c=>c.childCount>0&&c.firstChild.type==n);if(!s)return!1;let i=s.startIndex;if(i==0)return!1;let l=s.parent,a=l.child(i-1);if(a.type!=n)return!1;if(t){let c=a.lastChild&&a.lastChild.type==l.type,u=S.from(c?n.create():null),f=new M(S.from(n.create(null,S.from(l.type.create(null,u)))),c?3:1,0),d=s.start,h=s.end;t(e.tr.step(new Z(d-(c?3:1),h,d,h,f,1,!0)).scrollIntoView())}return!0}}class gt{constructor(e,t,r={}){this.match=e,this.match=e,this.handler=typeof t=="string"?Yp(t):t,this.undoable=r.undoable!==!1,this.inCode=r.inCode||!1,this.inCodeMark=r.inCodeMark!==!1}}function Yp(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 Gp=500;function Up({rules:n}){let e=new Ye({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 Ba(t,r,o,s,n,e)},handleDOMEvents:{compositionend:t=>{setTimeout(()=>{let{$cursor:r}=t.state.selection;r&&Ba(t,r.pos,r.pos,"",n,e)})}}},isInputRules:!0});return e}function Ba(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-Gp),l.parentOffset,null,"")+r;for(let c=0;c<o.length;c++){let u=o[c];if(!u.inCodeMark&&l.marks().some(h=>h.type.spec.code))continue;if(l.parent.type.spec.code){if(!u.inCode)continue}else if(u.inCode==="only")continue;let f=u.match.exec(a),d=f&&f[0].length>=r.length&&u.handler(i,f,e-(f[0].length-r.length),t);if(d)return u.undoable&&d.setMeta(s,{transform:d,from:e,to:t,text:r}),n.dispatch(d),!0}return!1}const Xp=(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},Qp=new gt(/--$/,"—",{inCodeMark:!1}),Zp=new gt(/\.\.\.$/,"…",{inCodeMark:!1}),em=new gt(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,"“",{inCodeMark:!1}),tm=new gt(/"$/,"”",{inCodeMark:!1}),nm=new gt(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,"‘",{inCodeMark:!1}),rm=new gt(/'$/,"’",{inCodeMark:!1}),om=[em,tm,nm,rm];function ls(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&&bo(f,e,a);if(!d)return null;c.wrap(f,d);let h=c.doc.resolve(i-1).nodeBefore;return h&&h.type==e&&Zt(c.doc,i-1)&&(!r||r(s,h))&&c.join(i-1),c})}function La(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 Wa=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):!1;function sm(n,e){let t={},r;function o(s,i){t[s]=i}if(o("Mod-z",Io),o("Shift-Mod-z",Cr),o("Backspace",Xp),Wa||o("Mod-y",Cr),o("Alt-ArrowUp",ml),o("Alt-ArrowDown",Pd),o("Mod-BracketLeft",gl),o("Escape",bl),(r=n.marks.strong)&&(o("Mod-b",we(r)),o("Mod-B",we(r))),(r=n.marks.em)&&(o("Mod-i",we(r)),o("Mod-I",we(r))),(r=n.marks.code)&&o("Mod-`",we(r)),(r=n.nodes.bullet_list)&&o("Shift-Ctrl-8",Pr(r)),(r=n.nodes.ordered_list)&&o("Shift-Ctrl-9",Pr(r)),(r=n.nodes.blockquote)&&o("Ctrl->",Sl(r)),r=n.nodes.hard_break){let s=r,i=wr(yl,(l,a)=>(a&&a(l.tr.replaceSelectionWith(s.create()).scrollIntoView()),!0));o("Mod-Enter",i),o("Shift-Enter",i),Wa&&o("Ctrl-Enter",i)}if((r=n.nodes.list_item)&&(o("Enter",_p(r)),o("Mod-[",qp(r)),o("Mod-]",Kp(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 im(n){return ls(/^\s*>\s$/,n)}function lm(n){return ls(/^(\d+)\.\s$/,n,e=>({order:+e[1]}),(e,t)=>t.childCount+t.attrs.order==+e[1])}function am(n){return ls(/^\s*([-+*])\s$/,n)}function cm(n){return La(/^```$/,n)}function um(n,e){return La(new RegExp("^(#{1,"+e+"})\\s$"),n,t=>({level:t[1].length}))}function fm(n){let e=om.concat(Zp,Qp),t;return(t=n.nodes.blockquote)&&e.push(im(t)),(t=n.nodes.ordered_list)&&e.push(lm(t)),(t=n.nodes.bullet_list)&&e.push(am(t)),(t=n.nodes.code_block)&&e.push(cm(t)),(t=n.nodes.heading)&&e.push(um(t,6)),Up({rules:e})}const et=new lt("ImagePluginKey"),dm=n=>new Ye({key:et,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(et);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}}}),hm=(n,e)=>{const t=et.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},pm=async(n,e,t)=>{if(!e)return;const r=Date.now(),o=n.state.tr;o.selection.empty||o.deleteSelection(),o.setMeta(et,{add:{id:r,pos:o.selection.from}}),n.dispatch(o);try{const s=et.getState(n.state),i=s.schema,l=s.upload;if(!l)throw new Error("uploadImage: Image upload function not defined");const a=await l(e);if(typeof a=="string")throw new Error(a);const c=hm(n.state,r);if(c===null){console.warn("uploadImage: The image was removed from the document during upload");return}n.dispatch(n.state.tr.replaceWith(c,c,i.nodes.image.create({fid:a,title:t})).setMeta(et,{remove:{id:r}}))}catch(s){n.dispatch(n.state.tr.setMeta(et,{remove:{id:r}})),console.error(`uploadImage: ${s}`)}},mm=(n,e,t)=>{if(!e)return;const r=n.state.tr;r.selection.empty||r.deleteSelection();const o=r.selection.from,s=et.getState(n.state).schema;n.dispatch(n.state.tr.replaceWith(o,o,s.nodes.image.create({src:e,title:t})))},Bt=function(n){for(var e=0;;e++)if(n=n.previousSibling,!n)return e},_a=function(n,e,t,r){return t&&(qa(n,e,t,r,-1)||qa(n,e,t,r,1))},gm=/^(img|br|input|textarea|hr)$/i;function qa(n,e,t,r,o){for(;;){if(n==t&&e==r)return!0;if(e==(o<0?0:Ir(n))){let s=n.parentNode;if(!s||s.nodeType!=1||as(n)||gm.test(n.nodeName)||n.contentEditable=="false")return!1;e=Bt(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?Ir(n):0}else return!1}}function Ir(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function ym(n,e,t){for(let r=e==0,o=e==Ir(n);r||o;){if(n==t)return!0;let s=Bt(n);if(n=n.parentNode,!n)return!1;r=r&&s==0,o=o&&s==Ir(n)}}function as(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 Ha=function(n){return n.focusNode&&_a(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)};function Ja(n,e){let t=document.createEvent("Event");return t.initEvent("keydown",!0,!0),t.keyCode=n,t.key=t.code=e,t}const We=typeof navigator<"u"?navigator:null,Ka=typeof document<"u"?document:null,yt=We&&We.userAgent||"",cs=/Edge\/(\d+)/.exec(yt),Ya=/MSIE \d/.exec(yt),us=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(yt),qn=!!(Ya||us||cs),Ga=Ya?document.documentMode:us?+us[1]:cs?+cs[1]:0,Vr=!qn&&/gecko\/(\d+)/i.test(yt);Vr&&+(/Firefox\/(\d+)/.exec(yt)||[0,0])[1];const fs=!qn&&/Chrome\/(\d+)/.exec(yt),bt=!!fs,Ua=fs?+fs[1]:0,Lt=!qn&&!!We&&/Apple Computer/.test(We.vendor),ds=Lt&&(/Mobile\/\w+/.test(yt)||!!We&&We.maxTouchPoints>2),De=ds||(We?/Mac/.test(We.platform):!1),bm=We?/Win/.test(We.platform):!1,Hn=/Android \d/.test(yt),hs=!!Ka&&"webkitFontSmoothing"in Ka.documentElement.style,xm=hs?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function km(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(Ha(t)){for(a=i;o&&!o.node;)o=o.parent;let f=o.node;if(o&&f.isAtom&&E.isSelectable(f)&&o.parent&&!(f.isInline&&ym(t.focusNode,t.focusOffset,o.dom))){let d=o.posBefore;c=new E(i==d?l:r.resolve(d))}}else{if(t instanceof n.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let f=i,d=i;for(let h=0;h<t.rangeCount;h++){let p=t.getRangeAt(h);f=Math.min(f,n.docView.posFromDOM(p.startContainer,p.startOffset,1)),d=Math.max(d,n.docView.posFromDOM(p.endContainer,p.endOffset,-1))}if(f<0)return null;[a,i]=d==n.state.selection.anchor?[d,f]:[f,d],l=r.resolve(i)}else a=n.docView.posFromDOM(t.anchorNode,t.anchorOffset,1);if(a<0)return null}let u=r.resolve(a);if(!c){let f=e=="pointer"||n.state.selection.head<l.pos&&!s?1:-1;c=nc(n,u,l,f)}return c}function Xa(n){return n.editable?n.hasFocus():Mm(n)&&document.activeElement&&document.activeElement.contains(n.dom)}function ps(n,e=!1){let t=n.state.selection;if(wm(n,t),!!Xa(n)){if(!e&&n.input.mouseDown&&n.input.mouseDown.allowDefault&&bt){let r=n.domSelectionRange(),o=n.domObserver.currentSelection;if(r.anchorNode&&o.anchorNode&&_a(r.anchorNode,r.anchorOffset,o.anchorNode,o.anchorOffset)){n.input.mouseDown.delayedSelectionSync=!0,n.domObserver.setCurSelection();return}}if(n.domObserver.disconnectSelection(),n.cursorWrapper)Cm(n);else{let{anchor:r,head:o}=t,s,i;Qa&&!(t instanceof P)&&(t.$from.parent.inlineContent||(s=Za(n,t.from)),!t.empty&&!t.$from.parent.inlineContent&&(i=Za(n,t.to))),n.docView.setSelection(r,o,n,e),Qa&&(s&&ec(s),i&&ec(i)),t.visible?n.dom.classList.remove("ProseMirror-hideselection"):(n.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&Sm(n))}n.domObserver.setCurSelection(),n.domObserver.connectSelection()}}const Qa=Lt||bt&&Ua<63;function Za(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 ms(o);if((!o||o.contentEditable=="false")&&(!s||s.contentEditable=="false")){if(o)return ms(o);if(s)return ms(s)}}function ms(n){return n.contentEditable="true",Lt&&n.draggable&&(n.draggable=!1,n.wasDraggable=!0),n}function ec(n){n.contentEditable="false",n.wasDraggable&&(n.draggable=!0,n.wasDraggable=null)}function Sm(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(()=>{(!Xa(n)||n.state.selection.visible)&&n.dom.classList.remove("ProseMirror-hideselection")},20))})}function Cm(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,Bt(r)+1):t.setStart(r,0),t.collapse(!0),e.removeAllRanges(),e.addRange(t),!o&&!n.state.selection.visible&&qn&&Ga<=11&&(r.disabled=!0,r.disabled=!1)}function wm(n,e){if(e instanceof E){let t=n.docView.descAt(e.from);t!=n.lastSelectedViewDesc&&(tc(n),t&&t.selectNode(),n.lastSelectedViewDesc=t)}else tc(n)}function tc(n){n.lastSelectedViewDesc&&(n.lastSelectedViewDesc.parent&&n.lastSelectedViewDesc.deselectNode(),n.lastSelectedViewDesc=void 0)}function nc(n,e,t,r){return n.someProp("createSelectionBetween",o=>o(n,e,t))||P.between(e,t,r)}function Mm(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 gs(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&&I.findFrom(s,e)}function xt(n,e){return n.dispatch(n.state.tr.setSelection(e).scrollIntoView()),!0}function rc(n,e,t){let r=n.state.selection;if(r instanceof P)if(t.indexOf("s")>-1){let{$head:o}=r,s=o.textOffset?null:e<0?o.nodeBefore:o.nodeAfter;if(!s||s.isText||!s.isLeaf)return!1;let i=n.state.doc.resolve(o.pos+s.nodeSize*(e<0?-1:1));return xt(n,new P(r.$anchor,i))}else if(r.empty){if(n.endOfTextblock(e>0?"forward":"backward")){let o=gs(n.state,e);return o&&o instanceof E?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?E.isSelectable(s)?xt(n,new E(e<0?n.state.doc.resolve(o.pos-s.nodeSize):o)):hs?xt(n,new P(n.state.doc.resolve(e<0?l:l+s.nodeSize))):!1:!1}}else return!1;else{if(r instanceof E&&r.node.isInline)return xt(n,new P(e>0?r.$to:r.$from));{let o=gs(n.state,e);return o?xt(n,o):!1}}}function Rr(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function Jn(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?Nm(n):Em(n)}function Nm(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let o,s,i=!1;for(Vr&&t.nodeType==1&&r<Rr(t)&&Jn(t.childNodes[r],-1)&&(i=!0);;)if(r>0){if(t.nodeType!=1)break;{let l=t.childNodes[r-1];if(Jn(l,-1))o=t,s=--r;else if(l.nodeType==3)t=l,r=t.nodeValue.length;else break}}else{if(oc(t))break;{let l=t.previousSibling;for(;l&&Jn(l,-1);)o=t.parentNode,s=Bt(l),l=l.previousSibling;if(l)t=l,r=Rr(t);else{if(t=t.parentNode,t==n.dom)break;r=0}}}i?ys(n,t,r):o&&ys(n,o,s)}function Em(n){let e=n.domSelectionRange(),t=e.focusNode,r=e.focusOffset;if(!t)return;let o=Rr(t),s,i;for(;;)if(r<o){if(t.nodeType!=1)break;let l=t.childNodes[r];if(Jn(l,1))s=t,i=++r;else break}else{if(oc(t))break;{let l=t.nextSibling;for(;l&&Jn(l,1);)s=l.parentNode,i=Bt(l)+1,l=l.nextSibling;if(l)t=l,r=0,o=Rr(t);else{if(t=t.parentNode,t==n.dom)break;r=o=0}}}s&&ys(n,s,i)}function oc(n){let e=n.pmViewDesc;return e&&e.node&&e.node.isBlock}function Dm(n,e){for(;n&&e==n.childNodes.length&&!as(n);)e=Bt(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 Om(n,e){for(;n&&!e&&!as(n);)e=Bt(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 ys(n,e,t){if(e.nodeType!=3){let s,i;(i=Dm(e,t))?(e=i,t=0):(s=Om(e,t))&&(e=s,t=s.nodeValue.length)}let r=n.domSelection();if(!r)return;if(Ha(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&&ps(n)},50)}function sc(n,e){let t=n.state.doc.resolve(e);if(!(bt||bm)&&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 ic(n,e,t){let r=n.state.selection;if(r instanceof P&&!r.empty||t.indexOf("s")>-1||De&&t.indexOf("m")>-1)return!1;let{$from:o,$to:s}=r;if(!o.parent.inlineContent||n.endOfTextblock(e<0?"up":"down")){let i=gs(n.state,e);if(i&&i instanceof E)return xt(n,i)}if(!o.parent.inlineContent){let i=e<0?o:s,l=r instanceof ge?I.near(i,e):I.findFrom(i,e);return l?xt(n,l):!1}return!1}function lc(n,e){if(!(n.state.selection instanceof P))return!0;let{$head:t,$anchor:r,empty:o}=n.state.selection;if(!t.sameParent(r))return!0;if(!o)return!1;if(n.endOfTextblock(e>0?"forward":"backward"))return!0;let s=!t.textOffset&&(e<0?t.nodeBefore:t.nodeAfter);if(s&&!s.isText){let i=n.state.tr;return e<0?i.delete(t.pos-s.nodeSize,t.pos):i.delete(t.pos,t.pos+s.nodeSize),n.dispatch(i),!0}return!1}function ac(n,e,t){n.domObserver.stop(),e.contentEditable=t,n.domObserver.start()}function Tm(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;ac(n,r,"true"),setTimeout(()=>ac(n,r,"false"),20)}return!1}function vm(n){let e="";return n.ctrlKey&&(e+="c"),n.metaKey&&(e+="m"),n.altKey&&(e+="a"),n.shiftKey&&(e+="s"),e}function Am(n,e){let t=e.keyCode,r=vm(e);if(t==8||De&&t==72&&r=="c")return lc(n,-1)||dn(n,-1);if(t==46&&!e.shiftKey||De&&t==68&&r=="c")return lc(n,1)||dn(n,1);if(t==13||t==27)return!0;if(t==37||De&&t==66&&r=="c"){let o=t==37?sc(n,n.state.selection.from)=="ltr"?-1:1:-1;return rc(n,o,r)||dn(n,o)}else if(t==39||De&&t==70&&r=="c"){let o=t==39?sc(n,n.state.selection.from)=="ltr"?1:-1:1;return rc(n,o,r)||dn(n,o)}else{if(t==38||De&&t==80&&r=="c")return ic(n,-1,r)||dn(n,-1);if(t==40||De&&t==78&&r=="c")return Tm(n)||ic(n,1,r)||dn(n,1);if(r==(De?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function cc(n,e){n.someProp("transformCopied",h=>{e=h(e,n)});let t=[],{content:r,openStart:o,openEnd:s}=e;for(;o>1&&s>1&&r.childCount==1&&r.firstChild.childCount==1;){o--,s--;let h=r.firstChild;t.push(h.type.name,h.attrs!=h.type.defaultAttrs?h.attrs:null),r=h.content}let i=n.someProp("clipboardSerializer")||$e.fromSchema(n.state.schema),l=yc(),a=l.createElement("div");a.appendChild(i.serializeFragment(r,{document:l}));let c=a.firstChild,u,f=0;for(;c&&c.nodeType==1&&(u=mc[c.nodeName.toLowerCase()]);){for(let h=u.length-1;h>=0;h--){let p=l.createElement(u[h]);for(;a.firstChild;)p.appendChild(a.firstChild);a.appendChild(p),f++}c=a.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${o} ${s}${f?` -${f}`:""} ${JSON.stringify(t)}`);let d=n.someProp("clipboardTextSerializer",h=>h(e,n))||e.content.textBetween(0,e.content.size,`
42
42
 
43
43
  `);return{dom:a,text:d,slice:e}}function uc(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 M(S.from(n.state.schema.text(e.replace(/\r\n?/g,`
44
44
  `))),0,0):M.empty;let f=n.someProp("clipboardTextParser",d=>d(e,o,r,n));if(f)l=f;else{let d=o.marks(),{schema:h}=n.state,p=$e.fromSchema(h);i=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(b=>{let y=i.appendChild(document.createElement("p"));b&&y.appendChild(p.serializeNode(h.text(b,d)))})}}else n.someProp("transformPastedHTML",f=>{t=f(t,n)}),i=Rm(t),hs&&zm(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&&!Pm.test(d.parentNode.nodeName)?{ignore:!0}:null}})),u)l=$m(pc(l,+u[1],+u[2]),u[4]);else if(l=M.maxOpen(Im(l.content,o),!0),l.openStart||l.openEnd){let f=0,d=0;for(let h=l.content.firstChild;f<l.openStart&&!h.type.spec.isolating;f++,h=h.firstChild);for(let h=l.content.lastChild;d<l.openEnd&&!h.type.spec.isolating;d++,h=h.lastChild);l=pc(l,f,d)}return n.someProp("transformPasted",f=>{l=f(l,n)}),l}const Pm=/^(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 Im(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&&dc(a,s,l,i[i.length-1],0))i[i.length-1]=c;else{i.length&&(i[i.length-1]=hc(i[i.length-1],s.length));let u=fc(l,a);i.push(u),o=o.matchType(u.type),s=a}}),i)return S.from(i)}return n}function fc(n,e,t=0){for(let r=e.length-1;r>=t;r--)n=e[r].create(null,S.from(n));return n}function dc(n,e,t,r,o){if(o<n.length&&o<e.length&&n[o]==e[o]){let s=dc(n,e,t,r.lastChild,o+1);if(s)return r.copy(r.content.replaceChild(r.childCount-1,s));if(r.contentMatchAt(r.childCount).matchType(o==n.length-1?t.type:n[o+1]))return r.copy(r.content.append(S.from(fc(t,n,o+1))))}}function hc(n,e){if(e==0)return n;let t=n.content.replaceChild(n.childCount-1,hc(n.lastChild,e-1)),r=n.contentMatchAt(n.childCount).fillBefore(S.empty,!0);return n.copy(t.append(r))}function bs(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=bs(l,e,t,r,o+1,s)),o>=t&&(l=e<0?i.contentMatchAt(0).fillBefore(l,s<=o).append(l):l.append(i.contentMatchAt(i.childCount).fillBefore(S.empty,!0))),n.replaceChild(e<0?0:n.childCount-1,i.copy(l))}function pc(n,e,t){return e<n.openStart&&(n=new M(bs(n.content,-1,e,n.openStart,0,n.openEnd),e,n.openEnd)),t<n.openEnd&&(n=new M(bs(n.content,1,t,n.openEnd,0,0),n.openStart,t)),n}const mc={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 gc=null;function yc(){return gc||(gc=document.implementation.createHTMLDocument("title"))}let xs=null;function Vm(n){let e=window.trustedTypes;return e?(xs||(xs=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})),xs.createHTML(n)):n}function Rm(n){let e=/^(\s*<meta [^>]*>)*/.exec(n);e&&(n=n.slice(e[0].length));let t=yc().createElement("div"),r=/<([a-z][^>\s]+)/i.exec(n),o;if((o=r&&mc[r[1].toLowerCase()])&&(n=o.map(s=>"<"+s+">").join("")+n+o.map(s=>"</"+s+">").reverse().join("")),t.innerHTML=Vm(n),o)for(let s=0;s<o.length;s++)t=t.querySelector(o[s])||t;return t}function zm(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 $m(n,e){if(!n.size)return n;let t=n.content.firstChild.type.schema,r;try{r=JSON.parse(e)}catch{return n}let{content:o,openStart:s,openEnd:i}=n;for(let l=r.length-2;l>=0;l-=2){let a=t.nodes[r[l]];if(!a||a.hasRequiredAttrs())break;o=S.from(a.create(r[l+1],o)),s++,i++}return new M(o,s,i)}const Re={},ke={};function kt(n,e){n.input.lastSelectionOrigin=e,n.input.lastSelectionTime=Date.now()}ke.keydown=(n,e)=>{let t=e;if(n.input.shiftKey=t.keyCode==16||t.shiftKey,!xc(n,t)&&(n.input.lastKeyCode=t.keyCode,n.input.lastKeyCodeTime=Date.now(),!(Hn&&bt&&t.keyCode==13)))if(t.keyCode!=229&&n.domObserver.forceFlush(),ds&&t.keyCode==13&&!t.ctrlKey&&!t.altKey&&!t.metaKey){let r=Date.now();n.input.lastIOSEnter=r,n.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{n.input.lastIOSEnter==r&&(n.someProp("handleKeyDown",o=>o(n,Ja(13,"Enter"))),n.input.lastIOSEnter=0)},200)}else n.someProp("handleKeyDown",r=>r(n,t))||Am(n,t)?t.preventDefault():kt(n,"key")},ke.keyup=(n,e)=>{e.keyCode==16&&(n.input.shiftKey=!1)},ke.keypress=(n,e)=>{let t=e;if(xc(n,t)||!t.charCode||t.ctrlKey&&!t.altKey||De&&t.metaKey)return;if(n.someProp("handleKeyPress",o=>o(n,t))){t.preventDefault();return}let r=n.state.selection;if(!(r instanceof P)||!r.$from.sameParent(r.$to)){let o=String.fromCharCode(t.charCode);!/[\r\n]/.test(o)&&!n.someProp("handleTextInput",s=>s(n,r.$from.pos,r.$to.pos,o))&&n.dispatch(n.state.tr.insertText(o).scrollIntoView()),t.preventDefault()}};function zr(n){return{left:n.clientX,top:n.clientY}}function jm(n,e){let t=e.x-n.clientX,r=e.y-n.clientY;return t*t+r*r<100}function ks(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 Fm(n,e){if(e==-1)return!1;let t=n.state.doc.resolve(e),r=t.nodeAfter;return r&&r.isAtom&&E.isSelectable(r)?(hn(n,new E(t)),!0):!1}function Bm(n,e){if(e==-1)return!1;let t=n.state.selection,r,o;t instanceof E&&(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(E.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,E.create(n.state.doc,o)),!0):!1}function Lm(n,e,t,r,o){return ks(n,"handleClickOn",e,t,r)||n.someProp("handleClick",s=>s(n,e,r))||(o?Bm(n,t):Fm(n,t))}function Wm(n,e,t,r){return ks(n,"handleDoubleClickOn",e,t,r)||n.someProp("handleDoubleClick",o=>o(n,e,r))}function _m(n,e,t,r){return ks(n,"handleTripleClickOn",e,t,r)||n.someProp("handleTripleClick",o=>o(n,e,r))||qm(n,t,r)}function qm(n,e,t){if(t.button!=0)return!1;let r=n.state.doc;if(e==-1)return r.inlineContent?(hn(n,P.create(r,0,r.content.size)),!0):!1;let o=r.resolve(e);for(let s=o.depth+1;s>0;s--){let i=s>o.depth?o.nodeAfter:o.node(s),l=o.before(s);if(i.inlineContent)hn(n,P.create(r,l+1,l+1+i.content.size));else if(E.isSelectable(i))hn(n,E.create(r,l));else continue;return!0}}function Ss(n){return $r(n)}const bc=De?"metaKey":"ctrlKey";Re.mousedown=(n,e)=>{let t=e;n.input.shiftKey=t.shiftKey;let r=Ss(n),o=Date.now(),s="singleClick";o-n.input.lastClick.time<500&&jm(t,n.input.lastClick)&&!t[bc]&&(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(zr(t));i&&(s=="singleClick"?(n.input.mouseDown&&n.input.mouseDown.done(),n.input.mouseDown=new Hm(n,i,t,!!r)):(s=="doubleClick"?Wm:_m)(n,i.pos,i.inside,t)?t.preventDefault():kt(n,"pointer"))};class Hm{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[bc],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 E&&c.from<=i&&c.to>i)&&(this.mightDrag={node:s,pos:i,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&Vr&&!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(()=>ps(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(zr(e))),this.updateAllowDefault(e),this.allowDefault||!t?kt(this.view,"pointer"):Lm(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,I.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(),Ss(n),kt(n,"pointer")},Re.touchmove=n=>{n.input.lastTouch=Date.now(),kt(n,"pointer")},Re.contextmenu=n=>Ss(n);function xc(n,e){return n.composing?!0:Lt&&Math.abs(e.timeStamp-n.input.compositionEndedAt)<500?(n.input.compositionEndedAt=-2e8,!0):!1}const Jm=Hn?5e3:-1;ke.compositionstart=ke.compositionupdate=n=>{if(!n.composing){n.domObserver.flush();let{state:e}=n,t=e.selection.$to;if(e.selection instanceof P&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(r=>r.type.spec.inclusive===!1)))n.markCursor=n.state.storedMarks||t.marks(),$r(n,!0),n.markCursor=null;else if($r(n,!e.selection.empty),Vr&&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}kc(n,Jm)},ke.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++,kc(n,20))};function kc(n,e){clearTimeout(n.input.composingTimeout),e>-1&&(n.input.composingTimeout=setTimeout(()=>$r(n),e))}function Km(n){for(n.composing&&(n.input.composing=!1,n.input.compositionEndedAt=Ym());n.input.compositionNodes.length>0;)n.input.compositionNodes.pop().markParentsDirty()}function Ym(){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(),Km(n),e||n.docView&&n.docView.dirty){let t=km(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 Gm(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 Kn=qn&&Ga<15||ds&&xm<604;Re.copy=ke.cut=(n,e)=>{let t=e,r=n.state.selection,o=t.type=="cut";if(r.empty)return;let s=Kn?null:t.clipboardData,i=r.content(),{dom:l,text:a}=cc(n,i);s?(t.preventDefault(),s.clearData(),s.setData("text/html",l.innerHTML),s.setData("text/plain",a)):Gm(n,l),o&&n.dispatch(n.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function Um(n){return n.openStart==0&&n.openEnd==0&&n.content.childCount==1?n.content.firstChild:null}function Xm(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?Cs(n,r.value,null,o,e):Cs(n,r.textContent,r.innerHTML,o,e)},50)}function Cs(n,e,t,r,o){let s=uc(n,e,t,r,n.state.selection.$from);if(n.someProp("handlePaste",a=>a(n,o,s||M.empty)))return!0;if(!s)return!1;let i=Um(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 Sc(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," "):""}ke.paste=(n,e)=>{let t=e;if(n.composing&&!Hn)return;let r=Kn?null:t.clipboardData,o=n.input.shiftKey&&n.input.lastKeyCode!=45;r&&Cs(n,Sc(r),r.getData("text/html"),o,t)?t.preventDefault():Xm(n,t)};class Qm{constructor(e,t,r){this.slice=e,this.move=t,this.node=r}}const Zm=De?"altKey":"ctrlKey";function Cc(n,e){let t=n.someProp("dragCopies",r=>!r(e));return t??!e[Zm]}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(zr(t)),i;if(!(s&&s.pos>=o.from&&s.pos<=(o instanceof E?o.to-1:o.to))){if(r&&r.mightDrag)i=E.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=E.create(n.state.doc,f.posBefore))}}let l=(i||n.state.selection).content(),{dom:a,text:c,slice:u}=cc(n,l);(!t.dataTransfer.files.length||!bt||Ua>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(Kn?"Text":"text/html",a.innerHTML),t.dataTransfer.effectAllowed="copyMove",Kn||t.dataTransfer.setData("text/plain",c),n.dragging=new Qm(u,Cc(n,t),i)},Re.dragend=n=>{let e=n.dragging;window.setTimeout(()=>{n.dragging==e&&(n.dragging=null)},50)},ke.dragover=ke.dragenter=(n,e)=>e.preventDefault(),ke.drop=(n,e)=>{let t=e,r=n.dragging;if(n.dragging=null,!t.dataTransfer)return;let o=n.posAtCoords(zr(t));if(!o)return;let s=n.state.doc.resolve(o.pos),i=r&&r.slice;i?n.someProp("transformPasted",p=>{i=p(i,n)}):i=uc(n,Sc(t.dataTransfer),Kn?null:t.dataTransfer.getData("text/html"),!1,s);let l=!!(r&&Cc(n,t));if(n.someProp("handleDrop",p=>p(n,t,i||M.empty,l))){t.preventDefault();return}if(!i)return;t.preventDefault();let a=i?xo(n.state.doc,s.pos,i):s.pos;a==null&&(a=s.pos);let c=n.state.tr;if(l){let{node:p}=r;p?p.replace(c):c.deleteSelection()}let u=c.mapping.map(a),f=i.openStart==0&&i.openEnd==0&&i.content.childCount==1,d=c.doc;if(f?c.replaceRangeWith(u,u,i.content.firstChild):c.replaceRange(u,u,i),c.doc.eq(d))return;let h=c.doc.resolve(u);if(f&&E.isSelectable(i.content.firstChild)&&h.nodeAfter&&h.nodeAfter.sameMarkup(i.content.firstChild))c.setSelection(new E(h));else{let p=c.mapping.map(a);c.mapping.maps[c.mapping.maps.length-1].forEach((b,y,k,C)=>p=C),c.setSelection(nc(n,h,c.doc.resolve(p)))}n.focus(),n.dispatch(c.setMeta("uiEvent","drop"))},Re.focus=n=>{n.input.lastFocus=Date.now(),n.focused||(n.domObserver.stop(),n.dom.classList.add("ProseMirror-focused"),n.domObserver.start(),n.focused=!0,setTimeout(()=>{n.docView&&n.hasFocus()&&!n.domObserver.currentSelection.eq(n.domSelectionRange())&&ps(n)},20))},Re.blur=(n,e)=>{let t=e;n.focused&&(n.domObserver.stop(),n.dom.classList.remove("ProseMirror-focused"),n.domObserver.start(),t.relatedTarget&&n.dom.contains(t.relatedTarget)&&n.domObserver.currentSelection.clear(),n.focused=!1)},Re.beforeinput=(n,e)=>{if(bt&&Hn&&e.inputType=="deleteContentBackward"){n.domObserver.flushSoon();let{domChangeCount:r}=n.input;setTimeout(()=>{if(n.input.domChangeCount!=r||(n.dom.blur(),n.focus(),n.someProp("handleKeyDown",s=>s(n,Ja(8,"Backspace")))))return;let{$cursor:o}=n.state.selection;o&&o.pos>0&&n.dispatch(n.state.tr.delete(o.pos-1,o.pos).scrollIntoView())},50)}};for(let n in ke)Re[n]=ke[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 jr{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 _e(s-r,s-r,this)}valid(){return!0}eq(e){return this==e||e instanceof jr&&(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 _e(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 ws{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 _e(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 ws&&Yn(this.attrs,e.attrs)&&Yn(this.spec,e.spec)}destroy(){}}class _e{constructor(e,t,r){this.from=e,this.to=t,this.type=r}copy(e,t){return new _e(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 _e(e,e,new jr(t,r))}static inline(e,t,r,o){return new _e(e,t,new St(r,o))}static node(e,t,r,o){return new _e(e,t,new ws(r,o))}get spec(){return this.type.spec}get inline(){return this.type instanceof St}get widget(){return this.type instanceof jr}}const pn=[],Wt={};class X{constructor(e,t){this.local=e.length?e:pn,this.children=t.length?t:pn}static create(e,t){return t.length?Fr(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?tg(this.children,i||[],e,t,r,o,s):i?new X(i.sort(_t),pn):he}add(e,t){return t.length?this==he?X.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=Mc(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,Fr(u,l,c+1,Wt)),s+=3}});let i=wc(s?Nc(t):t,-r);for(let l=0;l<i.length;l++)i[l].type.valid(e,i[l])||i.splice(l--,1);return new X(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 X(o,r):he}forChild(e,t){if(this==he)return this;if(t.isLeaf)return X.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 X(o.sort(_t),pn);return r?new eg([l,r]):l}return r||he}eq(e){if(this==e)return!0;if(!(e instanceof X)||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 Ms(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)}}X.empty=new X([],[]),X.removeOverlap=Ms;const he=X.empty;let eg=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 X.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?Ms(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 X)?e:e.reduce((t,r)=>t.concat(r instanceof X?r:r.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}};function tg(n,e,t,r,o,s,i){let l=n.slice();for(let c=0,u=s;c<t.maps.length;c++){let f=0;t.maps[c].forEach((d,h,p,b)=>{let y=b-p-(h-d);for(let k=0;k<l.length;k+=3){let C=l[k+1];if(C<0||d>C+u-f)continue;let w=l[k]+u-f;h>=w?l[k+1]=d<=w?-2:-1:d>=u&&y&&(l[k]+=y,l[k+1]+=y)}f+=y}),u=t.maps[c].map(u,-1)}let a=!1;for(let c=0;c<l.length;c+=3)if(l[c+1]<0){if(l[c+1]==-2){a=!0,l[c+1]=-1;continue}let u=t.map(n[c]+s),f=u-o;if(f<0||f>=r.content.size){a=!0;continue}let d=t.map(n[c+1]+s,-1),h=d-o,{index:p,offset:b}=r.content.findIndex(f),y=r.maybeChild(p);if(y&&b==f&&b+y.nodeSize==h){let k=l[c+2].mapInner(t,y,u+1,n[c]+s+1,i);k!=he?(l[c]=f,l[c+1]=h,l[c+2]=k):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=ng(l,n,e,t,o,s,i),u=Fr(c,r,0,i);e=u.local;for(let f=0;f<l.length;f+=3)l[f+1]<0&&(l.splice(f,3),f-=3);for(let f=0,d=0;f<u.children.length;f+=3){let h=u.children[f];for(;d<l.length&&l[d]<h;)d+=3;l.splice(d,0,u.children[f],u.children[f+1],u.children[f+2])}}return new X(e.sort(_t),l)}function wc(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 _e(o.from+e,o.to+e,o.type))}return t}function ng(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 Mc(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 Nc(n){let e=[];for(let t=0;t<n.length;t++)n[t]!=null&&e.push(n[t]);return e}function Fr(n,e,t,r){let o=[],s=!1;e.forEach((l,a)=>{let c=Mc(n,l,a+t);if(c){s=!0;let u=Fr(c,l,t+a+1,r);u!=he&&o.push(a,a+l.nodeSize,u)}});let i=wc(s?Nc(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 X(i,o):he}function _t(n,e){return n.from-e.from||n.to-e.to}function Ms(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),Ec(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),Ec(e,o,r.copy(s.from,r.to)));break}}}return e}function Ec(n,e,t){for(;e<n.length&&_t(t,n[e])>0;)e++;n.splice(e,0,t)}var Ns,Es;if(typeof WeakMap<"u"){let n=new WeakMap;Ns=e=>n.get(e),Es=(e,t)=>(n.set(e,t),t)}else{const n=[];let t=0;Ns=r=>{for(let o=0;o<n.length;o+=2)if(n[o]==r)return n[o+1]},Es=(r,o)=>(t==10&&(t=0),n[t++]=r,n[t++]=o)}var ne=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 Ns(n)||Es(n,rg(n))}};function rg(n){if(n.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+n.type.name);const e=og(n),t=n.childCount,r=[];let o=0,s=null;const i=[];for(let c=0,u=e*t;c<u;c++)r[c]=0;for(let c=0,u=0;c<t;c++){const f=n.child(c);u++;for(let p=0;;p++){for(;o<r.length&&r[o]!=0;)o++;if(p==f.childCount)break;const b=f.child(p),{colspan:y,rowspan:k,colwidth:C}=b.attrs;for(let w=0;w<k;w++){if(w+c>=t){(s||(s=[])).push({type:"overlong_rowspan",pos:u,n:k-w});break}const D=o+w*e;for(let V=0;V<y;V++){r[D+V]==0?r[D+V]=u:(s||(s=[])).push({type:"collision",row:c,pos:u,n:y-V});const O=C&&C[V];if(O){const B=(D+V)%e*2,$=i[B];$==null||$!=O&&i[B+1]==1?(i[B]=O,i[B+1]=1):$==O&&i[B+1]++}}}o+=y,u+=b.nodeSize}const d=(c+1)*e;let h=0;for(;o<d;)r[o++]==0&&h++;h&&(s||(s=[])).push({type:"missing",row:c,n:h}),u++}(e===0||t===0)&&(s||(s=[])).push({type:"zero_sized"});const l=new ne(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&&sg(l,i,n),l}function og(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 sg(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=ig(a)))[c]=f)}l&&n.problems.unshift({type:"colwidth mismatch",pos:s,colwidth:l})}}function ig(n){if(n.colwidth)return n.colwidth.slice();const e=[];for(let t=0;t<n.colspan;t++)e.push(0);return e}function Dc(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 Oc(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 lg(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 ag(n){const e=n.cellAttributes||{},t={colspan:{default:1,validate:"number"},rowspan:{default:1,validate:"number"},colwidth:{default:null,validate:lg}};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=>Dc(r,e)}],toDOM(r){return["td",Oc(r,e),0]}},table_header:{content:n.cellContent,attrs:t,tableRole:"header_cell",isolating:!0,parseDOM:[{tag:"th",getAttrs:r=>Dc(r,e)}],toDOM(r){return["th",Oc(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 cg(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 Br(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)||ug(e.$head);if(t)return t;throw new RangeError(`No cell found around position ${e.head}`)}function ug(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 Tc(n){return n.parent.type.spec.tableRole=="row"&&!!n.nodeAfter}function fg(n){return n.node(0).resolve(n.pos+n.nodeAfter.nodeSize)}function Ds(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=ne.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 Ac(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 dg(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 I{constructor(e,t=e){const r=e.node(-1),o=ne.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 Xi(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(Tc(r)&&Tc(o)&&Ds(r,o)){const s=this.$anchorCell.node(-1)!=r.node(-1);return s&&this.isRowSelection()?ot.rowSelection(r,o):s&&this.isColSelection()?ot.colSelection(r,o):new ot(r,o)}return P.between(r,o)}content(){const e=this.$anchorCell.node(-1),t=ne.get(e),r=this.$anchorCell.start(-1),o=t.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),s={},i=[];for(let a=o.top;a<o.bottom;a++){const c=[];for(let u=a*t.width+o.left,f=o.left;f<o.right;f++,u++){const d=t.map[u];if(s[d])continue;s[d]=!0;const h=t.findCell(d);let p=e.nodeAt(d);if(!p)throw RangeError(`No cell with offset ${d} found`);const b=o.left-h.left,y=h.right-o.right;if(b>0||y>0){let k=p.attrs;if(b>0&&(k=qt(k,0,b)),y>0&&(k=qt(k,k.colspan-y,y)),h.left<o.left){if(p=p.type.createAndFill(k),!p)throw RangeError(`Could not create cell with attrs ${JSON.stringify(k)}`)}else p=p.type.create(k,p.content)}if(h.top<o.top||h.bottom>o.bottom){const k={...p.attrs,rowspan:Math.min(h.bottom,o.bottom)-Math.max(h.top,o.top)};h.top<o.top?p=p.type.createAndFill(k):p=p.type.create(k,p.content)}c.push(p)}i.push(e.child(a).copy(S.from(c)))}const l=this.isColSelection()&&this.isRowSelection()?e:i;return new M(S.from(l),1,1)}replace(e,t=M.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?M.empty:t)}const s=I.findFrom(e.doc.resolve(e.mapping.slice(r).map(this.to)),-1);s&&e.setSelection(s)}replaceWith(e,t){this.replace(e,new M(S.from(t),0,0))}forEachCell(e){const t=this.$anchorCell.node(-1),r=ne.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=ne.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=ne.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=ne.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 hg(this.$anchorCell.pos,this.$headCell.pos)}};W.prototype.visible=!1,I.jsonID("cell",W);var hg=class hf{constructor(e,t){this.anchor=e,this.head=t}map(e){return new hf(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&&Ds(t,r)?new W(t,r):I.near(r,1)}};function pg(n){if(!(n.selection instanceof W))return null;const e=[];return n.selection.forEachCell((t,r)=>{e.push(_e.node(r,r+t.nodeSize,{class:"selectedCell"}))}),X.create(n.doc,e)}function mg({$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 gg({$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 yg(n,e,t){const r=(e||n).selection,o=(e||n).doc;let s,i;if(r instanceof E&&(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=ne.get(r.node),a=r.from+1,c=a+l.map[l.width*l.height-1];s=W.create(o,a+1,c)}}else r instanceof P&&mg(r)?s=P.create(o,r.from):r instanceof P&&gg(r)&&(s=P.create(o,r.$from.start(),r.$from.end()));return s&&(e||(e=n.tr)).setSelection(s),e}var bg=new lt("fix-tables");function Pc(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)?Pc(n.child(l),a,t+1,r):a.nodesBetween(0,a.content.size,r,t+1),t+=a.nodeSize}}function Os(n,e){let t;const r=(o,s)=>{o.type.spec.tableRole=="table"&&(t=xg(n,o,s,t))};return e?e.doc!=n.doc&&Pc(e.doc,n.doc,0,r):n.doc.descendants(r),t}function xg(n,e,t,r){const o=ne.get(e);if(!o.problems)return r;r||(r=n.tr);const s=[];for(let a=0;a<o.height;a++)s.push(0);for(let a=0;a<o.problems.length;a++){const c=o.problems[a];if(c.type=="collision"){const u=e.nodeAt(c.pos);if(!u)continue;const f=u.attrs;for(let d=0;d<f.rowspan;d++)s[c.row+d]+=c.n;r.setNodeMarkup(r.mapping.map(t+1+c.pos),null,qt(f,f.colspan-c.n,c.n))}else if(c.type=="missing")s[c.row]+=c.n;else if(c.type=="overlong_rowspan"){const u=e.nodeAt(c.pos);if(!u)continue;r.setNodeMarkup(r.mapping.map(t+1+c.pos),null,{...u.attrs,rowspan:u.attrs.rowspan-c.n})}else if(c.type=="colwidth mismatch"){const u=e.nodeAt(c.pos);if(!u)continue;r.setNodeMarkup(r.mapping.map(t+1+c.pos),null,{...u.attrs,colwidth:c.colwidth})}else if(c.type=="zero_sized"){const u=r.mapping.map(t);r.delete(u,u+e.nodeSize)}}let i,l;for(let a=0;a<s.length;a++)s[a]&&(i==null&&(i=a),l=a);for(let a=0,c=t+1;a<o.height;a++){const u=e.child(a),f=c+u.nodeSize,d=s[a];if(d>0){let h="cell";u.firstChild&&(h=u.firstChild.type.spec.tableRole);const p=[];for(let y=0;y<d;y++){const k=pe(n.schema)[h].createAndFill();k&&p.push(k)}const b=(a==0||i==a-1)&&l==a?c+1:f-1;r.insert(r.mapping.map(b),p)}c=f}return r.setMeta(bg,{fixTables:!0})}function qe(n){const e=n.selection,t=Br(n),r=t.node(-1),o=t.start(-1),s=ne.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 Ic(n,{map:e,tableStart:t,table:r},o){let s=o>0?-1:0;dg(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,Ac(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 kg(n,e){if(!Oe(n))return!1;if(e){const t=qe(n);e(Ic(n.tr,t,t.left))}return!0}function Sg(n,e){if(!Oe(n))return!1;if(e){const t=qe(n);e(Ic(n.tr,t,t.right))}return!0}function Cg(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 wg(n,e){if(!Oe(n))return!1;if(e){const t=qe(n),r=n.tr;if(t.left==0&&t.right==t.map.width)return!1;for(let o=t.right-1;Cg(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=ne.get(s)}e(r)}return!0}function Mg(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 Vc(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;Mg(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 Ng(n,e){if(!Oe(n))return!1;if(e){const t=qe(n);e(Vc(n.tr,t,t.top))}return!0}function Eg(n,e){if(!Oe(n))return!1;if(e){const t=qe(n);e(Vc(n.tr,t,t.bottom))}return!0}function Dg(n,{map:e,table:t,tableStart:r},o){let s=0;for(let c=0;c<o;c++)s+=t.child(c).nodeSize;const i=s+t.child(o).nodeSize,l=n.mapping.maps.length;n.delete(s+r,i+r);const a=new Set;for(let c=0,u=o*e.width;c<e.width;c++,u++){const f=e.map[u];if(!a.has(f)){if(a.add(f),o>0&&f==e.map[u-e.width]){const d=t.nodeAt(f).attrs;n.setNodeMarkup(n.mapping.slice(l).map(f+r),null,{...d,rowspan:d.rowspan-1}),c+=d.colspan-1}else if(o<e.height&&f==e.map[u+e.width]){const d=t.nodeAt(f),h=d.attrs,p=d.type.create({...h,rowspan:d.attrs.rowspan-1},d.content),b=e.positionAt(o+1,c,t);n.insert(n.mapping.slice(l).map(r+b),p),c+=h.colspan-1}}}}function Og(n,e){if(!Oe(n))return!1;if(e){const t=qe(n),r=n.tr;if(t.top==0&&t.bottom==t.map.height)return!1;for(let o=t.bottom-1;Dg(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=ne.get(t.table)}e(r)}return!0}function Rc(n){const e=n.content;return e.childCount==1&&e.child(0).isTextblock&&e.child(0).childCount==0}function Tg({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 vg(n,e){const t=n.selection;if(!(t instanceof W)||t.$anchorCell.pos==t.$headCell.pos)return!1;const r=qe(n),{map:o}=r;if(Tg(o,r))return!1;if(e){const s=n.tr,i={};let l=S.empty,a,c;for(let u=r.top;u<r.bottom;u++)for(let f=r.left;f<r.right;f++){const d=o.map[u*o.width+f],h=r.table.nodeAt(d);if(!(i[d]||!h))if(i[d]=!0,a==null)a=d,c=h;else{Rc(h)||(l=l.append(h.content));const p=s.mapping.map(d+r.tableStart);s.delete(p,p+h.nodeSize)}}if(a==null||c==null)return!0;if(s.setNodeMarkup(a+r.tableStart,null,{...Ac(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=Rc(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 Ag(n,e){const t=pe(n.schema);return Pg(({node:r})=>t[r.type.spec.tableRole])(n,e)}function Pg(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=cg(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=qe(e),f=e.tr;for(let h=0;h<u.right-u.left;h++)a.push(c?{...l,colwidth:c&&c[h]?[c[h]]:null}:l);let d;for(let h=u.top;h<u.bottom;h++){let p=u.map.positionAt(h,u.left,u.table);h==u.top&&(p+=s.nodeSize);for(let b=u.left,y=0;b<u.right;b++,y++)b==u.left&&h==u.top||f.insert(d=f.mapping.map(p+u.tableStart,1),n({node:s,row:h,col:b}).createAndFill(a[y]))}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=Br(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 Ig(n){return function(e,t){if(!Oe(e))return!1;if(t){const r=pe(e.schema),o=qe(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 zc(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 Ts(n,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?Ig(n):function(t,r){if(!Oe(t))return!1;if(r){const o=pe(t.schema),s=qe(t),i=t.tr,l=zc("row",s,o),a=zc("column",s,o),u=(n==="column"?l:n==="row"?a:!1)?1:0,f=n=="column"?{left:0,top:u,right:1,bottom:s.map.height}:n=="row"?{left:u,top:0,right:s.map.width,bottom:1}:s,d=n=="column"?a?o.cell:o.header_cell:n=="row"?l?o.cell:o.header_cell:o.cell;s.map.cellsInRect(f).forEach(h=>{const p=h+s.tableStart,b=i.doc.nodeAt(p);b&&i.setNodeMarkup(p,d,b.attrs)}),r(i)}return!0}}var Vg=Ts("row",{useDeprecatedLogic:!0}),Rg=Ts("column",{useDeprecatedLogic:!0}),zg=Ts("cell",{useDeprecatedLogic:!0});function $g(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 $c(n){return function(e,t){if(!Oe(e))return!1;const r=$g(Br(e),n);if(r==null)return!1;if(t){const o=e.doc.resolve(r);t(e.tr.setSelection(P.between(o,fg(o))).scrollIntoView())}return!0}}function jg(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 Lr(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 M(o,0,0))}),r.docChanged&&e(r)}return!0}function Fg(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=vs(pe(i).row,new M(c,u,f)).content),l.push(c)}else if(s=="cell"||s=="header_cell")l.push(t||r?vs(pe(i).row,new M(e,t,r)).content:e);else return null;return Bg(i,l)}function Bg(n,e){const t=[];for(let o=0;o<e.length;o++){const s=e[o];for(let i=s.childCount-1;i>=0;i--){const{rowspan:l,colspan:a}=s.child(i).attrs;for(let c=o;c<o+l;c++)t[c]=(t[c]||0)+a}}let r=0;for(let o=0;o<t.length;o++)r=Math.max(r,t[o]);for(let o=0;o<t.length;o++)if(o>=e.length&&e.push(S.empty),t[o]<r){const s=pe(n).cell.createAndFill(),i=[];for(let l=t[o];l<r;l++)i.push(s);e[o]=e[o].append(S.from(i))}return{height:e.length,width:r,rows:e}}function vs(n,e){const t=n.createAndFill();return new Ui(t).replace(0,t.content.size,e).doc}function Lg({width:n,height:e,rows:t},r,o){if(n!=r){const s=[],i=[];for(let l=0;l<t.length;l++){const a=t[l],c=[];for(let u=s[l]||0,f=0;u<r;f++){let d=a.child(f%a.childCount);u+d.attrs.colspan>r&&(d=d.type.createChecked(qt(d.attrs,d.attrs.colspan,u+d.attrs.colspan-r),d.content)),c.push(d),u+=d.attrs.colspan;for(let h=1;h<d.attrs.rowspan;h++)s[l+h]=(s[l+h]||0)+d.attrs.colspan}i.push(S.from(c))}t=i,n=r}if(e!=o){const s=[];for(let i=0,l=0;i<o;i++,l++){const a=[],c=t[l%e];for(let u=0;u<c.childCount;u++){let f=c.child(u);i+f.attrs.rowspan>o&&(f=f.type.create({...f.attrs,rowspan:Math.max(1,o-f.attrs.rowspan)},f.content)),a.push(f)}s.push(S.from(a))}t=s,e=o}return{width:n,height:e,rows:t}}function Wg(n,e,t,r,o,s,i){const l=n.doc.type.schema,a=pe(l);let c,u;if(o>e.width)for(let f=0,d=0;f<e.height;f++){const h=t.child(f);d+=h.nodeSize;const p=[];let b;h.lastChild==null||h.lastChild.type==a.cell?b=c||(c=a.cell.createAndFill()):b=u||(u=a.header_cell.createAndFill());for(let y=e.width;y<o;y++)p.push(b);n.insert(n.mapping.slice(i).map(d-1+r),p)}if(s>e.height){const f=[];for(let p=0,b=(e.height-1)*e.width;p<Math.max(e.width,o);p++){const y=p>=e.width?!1:t.nodeAt(e.map[b+p]).type==a.header_cell;f.push(y?u||(u=a.header_cell.createAndFill()):c||(c=a.cell.createAndFill()))}const d=a.row.create(null,S.from(f)),h=[];for(let p=e.height;p<s;p++)h.push(d);n.insert(n.mapping.slice(i).map(r+t.nodeSize-2),h)}return!!(c||u)}function jc(n,e,t,r,o,s,i,l){if(i==0||i==e.height)return!1;let a=!1;for(let c=o;c<s;c++){const u=i*e.width+c,f=e.map[u];if(e.map[u-e.width]==f){a=!0;const d=t.nodeAt(f),{top:h,left:p}=e.findCell(f);n.setNodeMarkup(n.mapping.slice(l).map(f+r),null,{...d.attrs,rowspan:i-h}),n.insert(n.mapping.slice(l).map(e.positionAt(i,p,t)),d.type.createAndFill({...d.attrs,rowspan:h+d.attrs.rowspan-i})),c+=d.attrs.colspan-1}}return a}function Fc(n,e,t,r,o,s,i,l){if(i==0||i==e.width)return!1;let a=!1;for(let c=o;c<s;c++){const u=c*e.width+i,f=e.map[u];if(e.map[u-1]==f){a=!0;const d=t.nodeAt(f),h=e.colCount(f),p=n.mapping.slice(l).map(f+r);n.setNodeMarkup(p,null,qt(d.attrs,i-h,d.attrs.colspan-(i-h))),n.insert(p+d.nodeSize,d.type.createAndFill(qt(d.attrs,0,i-h))),c+=d.attrs.rowspan-1}}return a}function Bc(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=ne.get(s);const{top:l,left:a}=r,c=a+o.width,u=l+o.height,f=n.tr;let d=0;function h(){if(s=t?f.doc.nodeAt(t-1):f.doc,!s)throw new Error("No table found");i=ne.get(s),d=f.mapping.maps.length}Wg(f,i,s,t,c,u,d)&&h(),jc(f,i,s,t,a,c,l,d)&&h(),jc(f,i,s,t,a,c,u,d)&&h(),Fc(f,i,s,t,l,u,a,d)&&h(),Fc(f,i,s,t,l,u,c,d)&&h();for(let p=l;p<u;p++){const b=i.positionAt(p,a,s),y=i.positionAt(p,c,s);f.replace(f.mapping.slice(d).map(b+t),f.mapping.slice(d).map(y+t),new M(o.rows[p-l],0,0))}h(),f.setSelection(new W(f.doc.resolve(t+i.positionAt(l,a,s)),f.doc.resolve(t+i.positionAt(u-1,c-1,s)))),e(f)}var _g=vo({ArrowLeft:_r("horiz",-1),ArrowRight:_r("horiz",1),ArrowUp:_r("vert",-1),ArrowDown:_r("vert",1),"Shift-ArrowLeft":qr("horiz",-1),"Shift-ArrowRight":qr("horiz",1),"Shift-ArrowUp":qr("vert",-1),"Shift-ArrowDown":qr("vert",1),Backspace:Lr,"Mod-Backspace":Lr,Delete:Lr,"Mod-Delete":Lr});function Wr(n,e,t){return t.eq(n.selection)?!1:(e&&e(n.tr.setSelection(t).scrollIntoView()),!0)}function _r(n,e){return(t,r,o)=>{if(!o)return!1;const s=t.selection;if(s instanceof W)return Wr(t,r,I.near(s.$headCell,e));if(n!="horiz"&&!s.empty)return!1;const i=Lc(o,n,e);if(i==null)return!1;if(n=="horiz")return Wr(t,r,I.near(t.doc.resolve(s.head+e),e));{const l=t.doc.resolve(i),a=vc(l,n,e);let c;return a?c=I.near(a,1):e<0?c=I.near(t.doc.resolve(l.before(-1)),-1):c=I.near(t.doc.resolve(l.after(-1)),1),Wr(t,r,c)}}}function qr(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=Lc(o,n,e);if(a==null)return!1;i=new W(t.doc.resolve(a))}const l=vc(i.$headCell,n,e);return l?Wr(t,r,new W(i.$anchorCell,l)):!1}}function qg(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 Hg(n,e,t){if(!Oe(n.state))return!1;let r=Fg(t);const o=n.state.selection;if(o instanceof W){r||(r={width:1,height:1,rows:[S.from(vs(pe(n.state.schema).cell,t))]});const s=o.$anchorCell.node(-1),i=o.$anchorCell.start(-1),l=ne.get(s).rectBetween(o.$anchorCell.pos-i,o.$headCell.pos-i);return r=Lg(r,l.right-l.left,l.bottom-l.top),Bc(n.state,n.dispatch,i,l,r),!0}else if(r){const s=Br(n.state),i=s.start(-1);return Bc(n.state,n.dispatch,i,ne.get(s.node(-1)).findCell(s.pos-i),r),!0}else return!1}function Jg(n,e){var t;if(e.ctrlKey||e.metaKey)return;const r=Wc(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=As(n,e))==null?void 0:t.pos)!=o.pos)s(o,e),e.preventDefault();else if(!r)return;function s(a,c){let u=As(n,c);const f=Ct.getState(n.state)==null;if(!u||!Ds(a,u))if(f)u=a;else return;const d=new W(a,u);if(f||!n.state.selection.eq(d)){const h=n.state.tr.setSelection(d);f&&h.setMeta(Ct,a.pos),n.dispatch(h)}}function i(){n.root.removeEventListener("mouseup",i),n.root.removeEventListener("dragstart",i),n.root.removeEventListener("mousemove",l),Ct.getState(n.state)!=null&&n.dispatch(n.state.tr.setMeta(Ct,-1))}function l(a){const c=a,u=Ct.getState(n.state);let f;if(u!=null)f=n.state.doc.resolve(u);else if(Wc(n,c.target)!=r&&(f=As(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 Lc(n,e,t){if(!(n.state.selection instanceof P))return null;const{$head:r}=n.state.selection;for(let o=r.depth-1;o>=0;o--){const s=r.node(o);if((t<0?r.index(o):r.indexAfter(o))!=(t<0?0:s.childCount))return null;if(s.type.spec.tableRole=="cell"||s.type.spec.tableRole=="header_cell"){const l=r.before(o),a=e=="vert"?t>0?"down":"up":t>0?"right":"left";return n.endOfTextblock(a)?l:null}}return null}function Wc(n,e){for(;e&&e!=n.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e;return null}function As(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 Kg({allowTableNodeSelection:n=!1}={}){return new Ye({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:pg,handleDOMEvents:{mousedown:Jg},createSelectionBetween(e){return Ct.getState(e.state)!=null?e.state.selection:null},handleTripleClick:qg,handleKeyDown:_g,handlePaste:Hg},appendTransaction(e,t,r){return yg(r,Os(r,t),n)}})}const _c=n=>[Kg(),To({Tab:$c(1),"Shift-Tab":$c(-1)}),fm(n.schema),To(sm(n.schema)),To(_d),qd({color:"#F00",width:2}),Tp(),Nd(),dm(n)],wt=m.createContext(null),Yg=m.createContext(null),qc=m.createContext(null),Hr=new WeakMap;function Gg(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=Hr.get(n);return!r||r[0].to!==n.state.doc.content.size||!r[0].type.eq(t[0].type)?(Hr.set(n,t),t):r}const Ug=[],Xg={},Ps=H.empty;let Hc=class Sn{constructor(e){z(this,"members");this.members=e}map(e,t){const r=this.members.map(o=>o.map(e,t,Xg));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!=Ps&&(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?Qg(r?t:t.sort(Jc)):Ug}static from(e){switch(e.length){case 0:return Ps;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 Jc(n,e){return n.from-e.from||n.to-e.to}function Qg(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),Kc(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),Kc(e,o,r.copy(s.from,r.to)));break}}}return e}function Kc(n,e,t){for(;e<n.length&&Jc(t,n[e])>0;)e++;n.splice(e,0,t)}const Is=new WeakMap;function Zg(n,e){const t=[];n.someProp("decorations",i=>{const l=i(n.state);l&&l!=Ps&&t.push(l)}),e&&t.push(H.create(n.state.doc,[e]));const r=Is.get(n);if(!r){const i=Hc.from(t);return Is.set(n,i),i}let o=0,s=!0;if(r.forEachSet(i=>{t[o++]!==i&&(s=!1)}),o!==t.length&&(s=!1),!s){const i=Hc.from(t);return Is.set(n,i),i}return r}const Vs=function(n){for(let e=0;;e++)if(n=n.previousSibling,!n)return e},Yc=function(n){const e=n.assignedSlot||n.parentNode;return e&&e.nodeType==11?e.host:e},ey=function(n,e,t,r){return t&&(Gc(n,e,t,r,-1)||Gc(n,e,t,r,1))},ty=/^(img|br|input|textarea|hr)$/i;function Gc(n,e,t,r,o){for(;;){if(n==t&&e==r)return!0;if(e==(o<0?0:Jr(n))){const s=n.parentNode;if(!s||s.nodeType!=1||ry(n)||ty.test(n.nodeName)||n.contentEditable=="false")return!1;e=Vs(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?Jr(n):0}else return!1}}function Jr(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function ny(n,e,t){for(let r=e==0,o=e==Jr(n);r||o;){if(n==t)return!0;const s=Vs(n);if(n=n.parentNode,!n)return!1;r=r&&s==0,o=o&&s==Jr(n)}return!1}function ry(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 Uc=function(n){return n.focusNode&&ey(n.focusNode,n.focusOffset,n.anchorNode,n.anchorOffset)},Xc=m.createContext(null);function K(){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 oy(n,e){const t=m.useContext(Xc);K(()=>t(n),e)}function tt(n,e){const{view:t,flushSyncRef:r}=m.useContext(wt);oy(()=>{if(t!=null&&t.docView){r.current=!1;const o=n(t);return r.current=!0,o}},e&&[t,...e])}const sy=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,[]),tt(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,Vs(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 iy(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 ly={side:0};class Un{constructor(e,t){z(this,"Component");z(this,"side");z(this,"spec");this.Component=e,this.spec=t??ly,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 Un&&(this.spec.key&&this.spec.key==e.spec.key||this.Component==e.Component&&iy(this.spec,e.spec))}destroy(){}}function ay(n,e,t){return new Ve(n,n,new Un(e,t))}const Rs=new lt("@handlewithcare/react-prosemirror/reactKeys");function zs(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=Rs.getState(n.state))==null?void 0:i.posToKey.get(c-1);s.setMeta(Rs,{type:"bustKey",payload:{key:u}})}return n.dispatch(s),!0}function cy(n){let e=null,t=null;return new Ye({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(ay(o.selection.from,sy,{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 zs(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);zs(r,a,{from:u,to:f})}});break}case"insertText":{zs(r,o.data);break}case"deleteWordBackward":case"deleteContentBackward":case"deleteWordForward":case"deleteContentForward":case"deleteContent":{const l=o.getTargetRanges(),{tr:a}=r.state;for(const c of l){const u=r.posAtDOM(c.startContainer,c.startOffset),f=r.posAtDOM(c.endContainer,c.endOffset),{doc:d}=r.state,h=d.resolve(u).marksAcross(d.resolve(f));a.delete(u,f).setStoredMarks(h)}r.dispatch(a);break}}return!0}}}})}const He=typeof navigator<"u"?navigator:null,Qc=typeof document<"u"?document:null,Ht=He&&He.userAgent||"",$s=/Edge\/(\d+)/.exec(Ht),Zc=/MSIE \d/.exec(Ht),js=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Ht),Kr=!!(Zc||js||$s),uy=Zc?document.documentMode:js?+js[1]:$s?+$s[1]:0,eu=!Kr&&/gecko\/(\d+)/i.test(Ht);eu&&+(/Firefox\/(\d+)/.exec(Ht)||[0,0])[1];const Fs=!Kr&&/Chrome\/(\d+)/.exec(Ht),fy=!!Fs,dy=Fs?+Fs[1]:0,tu=!Kr&&!!He&&/Apple Computer/.test(He.vendor);tu&&(/Mobile\/\w+/.test(Ht)||!!He&&He.maxTouchPoints>2)||He&&/Mac/.test(He.platform),He&&/Win/.test(He.platform),!!Qc&&"webkitFontSmoothing"in Qc.documentElement.style&&+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1];const le={ie:Kr,ie_version:uy,gecko:eu,chrome:fy,chrome_version:dy,safari:tu};function nu(n){return n.editable&&!n.hasFocus()?!1:hy(n)}function hy(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 py(n,e,t,r){return n.someProp("createSelectionBetween",o=>o(n,e,t))||P.between(e,t,r)}function ru(n){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null;const t=n.domSelectionRange(),r=n.state.doc;if(!t.focusNode)return null;let o=n.docView.nearestDesc(t.focusNode);const s=o&&o.size==0;let i=n.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(i<0)return null;let l=r.resolve(i),a,c;if(Uc(t)){for(a=i;o&&!o.node;)o=o.parent;const f=o.node;if(o&&f.isAtom&&E.isSelectable(f)&&o.parent&&!(f.isInline&&ny(t.focusNode,t.focusOffset,o.dom))){const d=o.posBefore;c=new E(i==d?l:r.resolve(d))}}else{if(t instanceof n.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let f=i,d=i;for(let h=0;h<t.rangeCount;h++){const p=t.getRangeAt(h);f=Math.min(f,n.docView.posFromDOM(p.startContainer,p.startOffset,1)),d=Math.max(d,n.docView.posFromDOM(p.endContainer,p.endOffset,-1))}if(f<0)return null;[a,i]=d==n.state.selection.anchor?[d,f]:[f,d],l=r.resolve(i)}else a=n.docView.posFromDOM(t.anchorNode,t.anchorOffset,1);if(a<0)return null}const u=r.resolve(a);if(!c){const f=e=="pointer"||n.state.selection.head<l.pos&&!s?1:-1;c=py(n,u,l,f)}return c}const Yr=function(n,e,t,r){return t&&(ou(n,e,t,r,-1)||ou(n,e,t,r,1))};function my(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 gy=/^(img|br|input|textarea|hr)$/i;function ou(n,e,t,r,o){for(;;){if(n==t&&e==r)return!0;if(e==(o<0?0:su(n))){const s=n.parentNode;if(!s||s.nodeType!=1||my(n)||gy.test(n.nodeName)||n.contentEditable=="false")return!1;e=Mt(n)+(o<0?0:1),n=s}else if(n.nodeType==1){if(n=n.childNodes[e+(o<0?-1:0)],n.contentEditable=="false")return!1;e=o<0?su(n):0}else return!1}}const Mt=function(n){let e=n;for(let t=0;;t++)if(e=e.previousSibling,!e)return t};function su(n){return n.nodeType==3?n.nodeValue.length:n.childNodes.length}function yy(n,e){const t=n;if(e instanceof E){const r=t.docView.descAt(e.from);r!=t.lastSelectedViewDesc&&(iu(t),r&&r.selectNode(),t.lastSelectedViewDesc=r)}else iu(t)}function iu(n){const e=n;e.lastSelectedViewDesc&&(e.lastSelectedViewDesc.parent&&e.lastSelectedViewDesc.deselectNode(),e.lastSelectedViewDesc=void 0)}function by(n){const e=n,t=e.domSelectionRange();if(!t.anchorNode)return!1;try{return e.dom.contains(t.anchorNode.nodeType==3?t.anchorNode.parentNode:t.anchorNode)&&(e.editable||e.dom.contains(t.focusNode.nodeType==3?t.focusNode.parentNode:t.focusNode))}catch{return!1}}function lu(n){return n.editable?n.hasFocus():by(n)&&document.activeElement&&document.activeElement.contains(n.dom)}function xy(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&&le.ie&&le.ie_version<=11&&(o.disabled=!0,o.disabled=!1)}function au(n,e){const t=n,{node:r,offset:o}=t.docView.domFromPos(e,0),s=o<r.childNodes.length?r.childNodes[o]:null,i=o?r.childNodes[o-1]:null;if(le.safari&&s&&s.contentEditable=="false")return Bs(s);if((!s||s.contentEditable=="false")&&(!i||i.contentEditable=="false")){if(s)return Bs(s);if(i)return Bs(i)}}function Bs(n){return n.contentEditable="true",le.safari&&n.draggable&&(n.draggable=!1,n.wasDraggable=!0),n}function cu(n){n.contentEditable="false",n.wasDraggable&&(n.draggable=!0,n.wasDraggable=null)}function ky(n){const e=n,t=e.dom.ownerDocument;t.removeEventListener("selectionchange",e.input.hideSelectionGuard);const r=e.domSelectionRange(),o=r.anchorNode,s=r.anchorOffset;t.addEventListener("selectionchange",e.input.hideSelectionGuard=()=>{(r.anchorNode!=o||r.anchorOffset!=s)&&(t.removeEventListener("selectionchange",e.input.hideSelectionGuard),setTimeout(()=>{(!lu(e)||e.state.selection.visible)&&e.dom.classList.remove("ProseMirror-hideselection")},20))})}const uu=le.safari||le.chrome&&le.chrome_version<63;function Gr(n){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;const t=n,r=t.state.selection;if(yy(t,r),!!lu(t)){if(!e&&t.input.mouseDown&&t.input.mouseDown.allowDefault&&le.chrome){const o=t.domSelectionRange(),s=t.domObserver.currentSelection;if(o.anchorNode&&s.anchorNode&&Yr(o.anchorNode,o.anchorOffset,s.anchorNode,s.anchorOffset)){t.input.mouseDown.delayedSelectionSync=!0,t.domObserver.setCurSelection();return}}if(t.domObserver.disconnectSelection(),t.cursorWrapper)xy(t);else{const{anchor:o,head:s}=r;let i,l;uu&&!(r instanceof P)&&(r.$from.parent.inlineContent||(i=au(t,r.from)),!r.empty&&!r.$from.parent.inlineContent&&(l=au(t,r.to))),t.docView.setSelection(o,s,t,e),uu&&(i&&cu(i),l&&cu(l)),r.visible?t.dom.classList.remove("ProseMirror-hideselection"):(t.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&ky(t))}t.domObserver.setCurSelection(),t.domObserver.connectSelection()}}let Sy=class{constructor(){z(this,"anchorNode",null);z(this,"anchorOffset",0);z(this,"focusNode",null);z(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 Cy{constructor(e){z(this,"view");z(this,"flushingSoon");z(this,"currentSelection");z(this,"suppressingSelectionUpdates");this.view=e,this.flushingSoon=-1,this.currentSelection=new Sy,this.suppressingSelectionUpdates=!1,this.view=e,this.onSelectionChange=this.onSelectionChange.bind(this)}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}stop(){this.disconnectSelection()}start(){this.connectSelection()}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;const t=new Set;let r;for(let s=e.focusNode;s;s=Yc(s))t.add(s);for(let s=e.anchorNode;s;s=Yc(s))if(t.has(s)){r=s;break}const o=r&&this.view.docView.nearestDesc(r);if(o&&o.ignoreMutation({type:"selection",target:(r==null?void 0:r.nodeType)==3?r==null?void 0:r.parentNode:r}))return this.setCurSelection(),!0}registerMutation(){}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}updateSelection(){const{view:e}=this,t=e.input.compositionPendingChanges||(e.composing?e.input.compositionID:0);e.input.compositionPendingChanges=0;const r=e.input.lastSelectionTime>Date.now()-50?e.input.lastSelectionOrigin:null,o=ru(e,r);if(o&&!e.state.selection.eq(o)){const s=e.state.tr.setSelection(o);r=="pointer"?s.setMeta("pointer",!0):r=="key"&&s.scrollIntoView(),t&&s.setMeta("composition",t),e.dispatch(s)}}selectionToDOM(){const{view:e}=this;Gr(e);const t=e.domSelectionRange();this.currentSelection.set(t)}flush(){const{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;const t=e.domSelectionRange(),r=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(t)&&nu(e)&&!this.ignoreSelectionChange(t);let o=null;r&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&Uc(t)&&(o=ru(e))&&o.eq(I.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,Gr(e),this.currentSelection.set(t),e.scrollToSelection()):r&&(this.updateSelection(),this.currentSelection.eq(t)||Gr(e),this.currentSelection.set(t))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}onSelectionChange(){if(nu(this.view)&&!this.view.composing){if(this.suppressingSelectionUpdates)return Gr(this.view);if(le.ie&&le.ie_version<=11&&!this.view.state.selection.empty){const e=this.view.domSelectionRange();if(e.focusNode&&Yr(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}}let wy=class{add(){}remove(){}},fu=class io{constructor(){z(this,"nodeName","div");z(this,"style",{})}get parent(){return new io}get parentNode(){return new io}appendChild(){return new io}setAttribute(){}hasAttribute(){return!1}insertBefore(){}get classList(){return new wy}get ownerDocument(){return new du}addEventListener(){}removeEventListener(){}replaceChildren(){}},du=class{createElement(){return new fu}addEventListener(){}removeEventListener(){}get documentElement(){return new fu}};function hu(){const n=globalThis.window;globalThis.window??(globalThis.window={visualViewport:null});const e=globalThis.document;return globalThis.document??(globalThis.document=new du),function(){globalThis.window!==n&&(globalThis.window=n),globalThis.document!==e&&(globalThis.document=e)}}function Jt(n,e){return n instanceof Zn?1:e instanceof Zn?-1:n.getPos()-e.getPos()}const gn=0,pu=1,Ur=2,Xn=3;class Qn{constructor(e,t,r,o,s){z(this,"parent");z(this,"children");z(this,"getPos");z(this,"dom");z(this,"contentDOM");z(this,"dirty");z(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 Zn){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 Ls&&s.side>=0;r--);if(t<=0){let s,i=!0;for(;s=r?this.children[r-1]:null,!(!s||s.dom.parentNode==this.contentDOM);r--,i=!1);return s&&t&&i&&!s.border&&!s.domAtom?s.domFromPos(s.size,t):{node:this.contentDOM,offset:s?Mt(s.dom)+1:0}}else{let s,i=!0;for(;s=r<this.children.length?this.children[r]:null,!(!s||s.dom.parentNode==this.contentDOM);r++,i=!1);return s&&i&&!s.border&&!s.domAtom?s.domFromPos(0,t):{node:this.contentDOM,offset:s?Mt(s.dom):this.contentDOM.childNodes.length}}}parseRange(e,t){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0;if(this.children.length==0)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let o=-1,s=-1;for(let i=r,l=0;;l++){const a=this.children[l],c=i+a.size;if(o==-1&&e<=c){const u=i+a.border;if(e>=u&&t<=c-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,t,u);e=i;for(let f=l;f>0;f--){const d=this.children[f-1];if(d.size&&d.dom.parentNode==this.contentDOM&&!d.emptyChildAt(1)){o=Mt(d.dom)+1;break}e-=d.size}o==-1&&(o=0)}if(o>-1&&(c>t||l==this.children.length-1)){t=c;for(let u=l+1;u<this.children.length;u++){const f=this.children[u];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(-1)){s=Mt(f.dom);break}t+=f.size}s==-1&&(s=this.contentDOM.childNodes.length);break}i=c}return{node:this.contentDOM,from:e,to:t,fromOffset:o,toOffset:s}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;const t=this.children[e<0?0:this.children.length-1];return t.size==0||t.emptyChildAt(e)}domAfterPos(e){const{node:t,offset:r}=this.domFromPos(e,0);if(t.nodeType!=1||r==t.childNodes.length)throw new RangeError("No node after pos "+e);return t.childNodes[r]}setSelection(e,t,r){var h;let o=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1;const s=Math.min(e,t),i=Math.max(e,t);for(let p=0,b=0;p<this.children.length;p++){const y=this.children[p],k=b+y.size;if(s>b&&i<k)return y.setSelection(e-b-y.border,t-b-y.border,r,o);b=k}let l=this.domFromPos(e,e?-1:1),a=t==e?l:this.domFromPos(t,t?-1:1);const c=r.root.getSelection(),u=r.domSelectionRange();let f=!1;if((le.gecko||le.safari)&&e==t){const{node:p,offset:b}=l;if(p.nodeType==3){if(f=!!(b&&((h=p.nodeValue)==null?void 0:h[b-1])==`