diff --git a/app/assets/javascript/lexxy.js b/app/assets/javascript/lexxy.js index 51e6a565..3f61d09d 100644 --- a/app/assets/javascript/lexxy.js +++ b/app/assets/javascript/lexxy.js @@ -7856,26 +7856,19 @@ class Selection { this.#containEditorFocus(); } - clear() { - this.current = null; - } - set current(selection) { - if (xr(selection)) { - this.editor.getEditorState().read(() => { - this._current = Lr(); - this.#syncSelectedClasses(); - }); - } else { - this.editor.update(() => { - this.#syncSelectedClasses(); - this._current = null; - }); - } + this.editor.update(() => { + this.#syncSelectedClasses(); + }); } - get current() { - return this._current + get hasNodeSelection() { + let result = false; + this.editor.getEditorState().read(() => { + const selection = Lr(); + result = selection !== null && xr(selection); + }); + return result } get cursorPosition() { @@ -8068,18 +8061,18 @@ class Selection { } get #currentlySelectedKeys() { - if (this._currentlySelectedKeys) { return this._currentlySelectedKeys } + if (this.currentlySelectedKeys) { return this.currentlySelectedKeys } - this._currentlySelectedKeys = new Set(); + this.currentlySelectedKeys = new Set(); const selection = Lr(); if (selection && xr(selection)) { for (const node of selection.getNodes()) { - this._currentlySelectedKeys.add(node.getKey()); + this.currentlySelectedKeys.add(node.getKey()); } } - return this._currentlySelectedKeys + return this.currentlySelectedKeys } #processSelectionChangeCommands() { @@ -8209,7 +8202,7 @@ class Selection { this.#highlightNewItems(); this.previouslySelectedKeys = this.#currentlySelectedKeys; - this._currentlySelectedKeys = null; + this.currentlySelectedKeys = null; } #clearPreviouslyHighlightedItems() { @@ -8231,7 +8224,7 @@ class Selection { } async #selectPreviousNode() { - if (this.current) { + if (this.hasNodeSelection) { await this.#withCurrentNode((currentNode) => currentNode.selectPrevious()); } else { this.#selectInLexical(this.nodeBeforeCursor); @@ -8239,7 +8232,7 @@ class Selection { } async #selectNextNode() { - if (this.current) { + if (this.hasNodeSelection) { await this.#withCurrentNode((currentNode) => currentNode.selectNext(0, 0)); } else { this.#selectInLexical(this.nodeAfterCursor); @@ -8247,7 +8240,7 @@ class Selection { } async #selectPreviousTopLevelNode() { - if (this.current) { + if (this.hasNodeSelection) { await this.#withCurrentNode((currentNode) => currentNode.selectPrevious()); } else { this.#selectInLexical(this.topLevelNodeBeforeCursor); @@ -8255,7 +8248,7 @@ class Selection { } async #selectNextTopLevelNode() { - if (this.current) { + if (this.hasNodeSelection) { await this.#withCurrentNode((currentNode) => currentNode.selectNext(0, 0)); } else { this.#selectInLexical(this.topLevelNodeAfterCursor); @@ -8264,10 +8257,9 @@ class Selection { async #withCurrentNode(fn) { await nextFrame(); - if (this.current) { + if (this.hasNodeSelection) { this.editor.update(() => { - this.clear(); - fn(this.current.getNodes()[0]); + fn(Lr().getNodes()[0]); this.editor.focus(); }); } @@ -9171,8 +9163,8 @@ class Contents { let focusNode = null; this.editor.update(() => { - if (xr(this.#selection.current)) { - const nodesToRemove = this.#selection.current.getNodes(); + if (this.#selection.hasNodeSelection) { + const nodesToRemove = Lr().getNodes(); if (nodesToRemove.length === 0) return focusNode = this.#findAdjacentNodeTo(nodesToRemove); @@ -9184,7 +9176,6 @@ class Contents { this.editor.update(() => { this.#selectAfterDeletion(focusNode); - this.#selection.clear(); this.editor.focus(); }); } diff --git a/app/assets/javascript/lexxy.js.br b/app/assets/javascript/lexxy.js.br index 9967c8f7..d08d0dc2 100644 Binary files a/app/assets/javascript/lexxy.js.br and b/app/assets/javascript/lexxy.js.br differ diff --git a/app/assets/javascript/lexxy.js.gz b/app/assets/javascript/lexxy.js.gz index 56a62553..a78b3aa2 100644 Binary files a/app/assets/javascript/lexxy.js.gz and b/app/assets/javascript/lexxy.js.gz differ diff --git a/app/assets/javascript/lexxy.min.js b/app/assets/javascript/lexxy.min.js index a97d52a3..9b0e03fa 100644 --- a/app/assets/javascript/lexxy.min.js +++ b/app/assets/javascript/lexxy.min.js @@ -8,4 +8,4 @@ import{DirectUpload as e}from"@rails/activestorage";var t="undefined"!=typeof gl * @public */e.exports&&(e.exports=n),void 0!==t&&(t.Prism=n),n.languages.markup={comment:{pattern://,greedy:!0},prolog:{pattern:/<\?[\s\S]+?\?>/,greedy:!0},doctype:{pattern:/"'[\]]|"[^"]*"|'[^']*')+(?:\[(?:[^<"'\]]|"[^"]*"|'[^']*'|<(?!!--)|)*\]\s*)?>/i,greedy:!0,inside:{"internal-subset":{pattern:/(^[^\[]*\[)[\s\S]+(?=\]>$)/,lookbehind:!0,greedy:!0,inside:null},string:{pattern:/"[^"]*"|'[^']*'/,greedy:!0},punctuation:/^$|[[\]]/,"doctype-tag":/^DOCTYPE/i,name:/[^\s<>'"]+/}},cdata:{pattern://i,greedy:!0},tag:{pattern:/<\/?(?!\d)[^\s>\/=$<%]+(?:\s(?:\s*[^\s>\/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/,greedy:!0,inside:{tag:{pattern:/^<\/?[^\s>\/]+/,inside:{punctuation:/^<\/?/,namespace:/^[^\s>\/:]+:/}},"special-attr":[],"attr-value":{pattern:/=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+)/,inside:{punctuation:[{pattern:/^=/,alias:"attr-equals"},{pattern:/^(\s*)["']|["']$/,lookbehind:!0}]}},punctuation:/\/?>/,"attr-name":{pattern:/[^\s>\/]+/,inside:{namespace:/^[^\s>\/:]+:/}}}},entity:[{pattern:/&[\da-z]{1,8};/i,alias:"named-entity"},/&#x?[\da-f]{1,8};/i]},n.languages.markup.tag.inside["attr-value"].inside.entity=n.languages.markup.entity,n.languages.markup.doctype.inside["internal-subset"].inside=n.languages.markup,n.hooks.add("wrap",(function(e){"entity"===e.type&&(e.attributes.title=e.content.replace(/&/,"&"))})),Object.defineProperty(n.languages.markup.tag,"addInlined",{value:function(e,t){var r={};r["language-"+t]={pattern:/(^$)/i,lookbehind:!0,inside:n.languages[t]},r.cdata=/^$/i;var i={"included-cdata":{pattern://i,inside:r}};i["language-"+t]={pattern:/[\s\S]+/,inside:n.languages[t]};var o={};o[e]={pattern:RegExp(/(<__[^>]*>)(?:))*\]\]>|(?!)/.source.replace(/__/g,(function(){return e})),"i"),lookbehind:!0,greedy:!0,inside:i},n.languages.insertBefore("markup","cdata",o)}}),Object.defineProperty(n.languages.markup.tag,"addAttribute",{value:function(e,t){n.languages.markup.tag.inside["special-attr"].push({pattern:RegExp(/(^|["'\s])/.source+"(?:"+e+")"+/\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))/.source,"i"),lookbehind:!0,inside:{"attr-name":/^[^\s=]+/,"attr-value":{pattern:/=[\s\S]+/,inside:{value:{pattern:/(^=\s*(["']|(?!["'])))\S[\s\S]*(?=\2$)/,lookbehind:!0,alias:[t,"language-"+t],inside:n.languages[t]},punctuation:[{pattern:/^=/,alias:"attr-equals"},/"|'/]}}}})}}),n.languages.html=n.languages.markup,n.languages.mathml=n.languages.markup,n.languages.svg=n.languages.markup,n.languages.xml=n.languages.extend("markup",{}),n.languages.ssml=n.languages.xml,n.languages.atom=n.languages.xml,n.languages.rss=n.languages.xml,function(e){var t=/(?:"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"|'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n])*')/;e.languages.css={comment:/\/\*[\s\S]*?\*\//,atrule:{pattern:RegExp("@[\\w-](?:"+/[^;{\s"']|\s+(?!\s)/.source+"|"+t.source+")*?"+/(?:;|(?=\s*\{))/.source),inside:{rule:/^@[\w-]+/,"selector-function-argument":{pattern:/(\bselector\s*\(\s*(?![\s)]))(?:[^()\s]|\s+(?![\s)])|\((?:[^()]|\([^()]*\))*\))+(?=\s*\))/,lookbehind:!0,alias:"selector"},keyword:{pattern:/(^|[^\w-])(?:and|not|only|or)(?![\w-])/,lookbehind:!0}}},url:{pattern:RegExp("\\burl\\((?:"+t.source+"|"+/(?:[^\\\r\n()"']|\\[\s\S])*/.source+")\\)","i"),greedy:!0,inside:{function:/^url/i,punctuation:/^\(|\)$/,string:{pattern:RegExp("^"+t.source+"$"),alias:"url"}}},selector:{pattern:RegExp("(^|[{}\\s])[^{}\\s](?:[^{};\"'\\s]|\\s+(?![\\s{])|"+t.source+")*(?=\\s*\\{)"),lookbehind:!0},string:{pattern:t,greedy:!0},property:{pattern:/(^|[^-\w\xA0-\uFFFF])(?!\s)[-_a-z\xA0-\uFFFF](?:(?!\s)[-\w\xA0-\uFFFF])*(?=\s*:)/i,lookbehind:!0},important:/!important\b/i,function:{pattern:/(^|[^-a-z0-9])[-a-z0-9]+(?=\()/i,lookbehind:!0},punctuation:/[(){};:,]/},e.languages.css.atrule.inside.rest=e.languages.css;var n=e.languages.markup;n&&(n.tag.addInlined("style","css"),n.tag.addAttribute("style","css"))}(n),n.languages.clike={comment:[{pattern:/(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/,lookbehind:!0,greedy:!0},{pattern:/(^|[^\\:])\/\/.*/,lookbehind:!0,greedy:!0}],string:{pattern:/(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,greedy:!0},"class-name":{pattern:/(\b(?:class|extends|implements|instanceof|interface|new|trait)\s+|\bcatch\s+\()[\w.\\]+/i,lookbehind:!0,inside:{punctuation:/[.\\]/}},keyword:/\b(?:break|catch|continue|do|else|finally|for|function|if|in|instanceof|new|null|return|throw|try|while)\b/,boolean:/\b(?:false|true)\b/,function:/\b\w+(?=\()/,number:/\b0x[\da-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?/i,operator:/[<>]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,punctuation:/[{}[\];(),.:]/},n.languages.javascript=n.languages.extend("clike",{"class-name":[n.languages.clike["class-name"],{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$A-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\.(?:constructor|prototype))/,lookbehind:!0}],keyword:[{pattern:/((?:^|\})\s*)catch\b/,lookbehind:!0},{pattern:/(^|[^.]|\.\.\.\s*)\b(?:as|assert(?=\s*\{)|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally(?=\s*(?:\{|$))|for|from(?=\s*(?:['"]|$))|function|(?:get|set)(?=\s*(?:[#\[$\w\xA0-\uFFFF]|$))|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/,lookbehind:!0}],function:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,number:{pattern:RegExp(/(^|[^\w$])/.source+"(?:"+/NaN|Infinity/.source+"|"+/0[bB][01]+(?:_[01]+)*n?/.source+"|"+/0[oO][0-7]+(?:_[0-7]+)*n?/.source+"|"+/0[xX][\dA-Fa-f]+(?:_[\dA-Fa-f]+)*n?/.source+"|"+/\d+(?:_\d+)*n/.source+"|"+/(?:\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\.\d+(?:_\d+)*)(?:[Ee][+-]?\d+(?:_\d+)*)?/.source+")"+/(?![\w$])/.source),lookbehind:!0},operator:/--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/}),n.languages.javascript["class-name"][0].pattern=/(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/,n.languages.insertBefore("javascript","keyword",{regex:{pattern:RegExp(/((?:^|[^$\w\xA0-\uFFFF."'\])\s]|\b(?:return|yield))\s*)/.source+/\//.source+"(?:"+/(?:\[(?:[^\]\\\r\n]|\\.)*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}/.source+"|"+/(?:\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.)*\])*\])*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}v[dgimyus]{0,7}/.source+")"+/(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/.source),lookbehind:!0,greedy:!0,inside:{"regex-source":{pattern:/^(\/)[\s\S]+(?=\/[a-z]*$)/,lookbehind:!0,alias:"language-regex",inside:n.languages.regex},"regex-delimiter":/^\/|\/$/,"regex-flags":/^[a-z]+$/}},"function-variable":{pattern:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)\s*=>))/,alias:"function"},parameter:[{pattern:/(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/,lookbehind:!0,inside:n.languages.javascript},{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i,lookbehind:!0,inside:n.languages.javascript},{pattern:/(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/,lookbehind:!0,inside:n.languages.javascript},{pattern:/((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*)\(\s*|\]\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*\{)/,lookbehind:!0,inside:n.languages.javascript}],constant:/\b[A-Z](?:[A-Z_]|\dx?)*\b/}),n.languages.insertBefore("javascript","string",{hashbang:{pattern:/^#!.*/,greedy:!0,alias:"comment"},"template-string":{pattern:/`(?:\\[\s\S]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}|(?!\$\{)[^\\`])*`/,greedy:!0,inside:{"template-punctuation":{pattern:/^`|`$/,alias:"string"},interpolation:{pattern:/((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}/,lookbehind:!0,inside:{"interpolation-punctuation":{pattern:/^\$\{|\}$/,alias:"punctuation"},rest:n.languages.javascript}},string:/[\s\S]+/}},"string-property":{pattern:/((?:^|[,{])[ \t]*)(["'])(?:\\(?:\r\n|[\s\S])|(?!\2)[^\\\r\n])*\2(?=\s*:)/m,lookbehind:!0,greedy:!0,alias:"property"}}),n.languages.insertBefore("javascript","operator",{"literal-property":{pattern:/((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m,lookbehind:!0,alias:"property"}}),n.languages.markup&&(n.languages.markup.tag.addInlined("script","javascript"),n.languages.markup.tag.addAttribute(/on(?:abort|blur|change|click|composition(?:end|start|update)|dblclick|error|focus(?:in|out)?|key(?:down|up)|load|mouse(?:down|enter|leave|move|out|over|up)|reset|resize|scroll|select|slotchange|submit|unload|wheel)/.source,"javascript")),n.languages.js=n.languages.javascript,function(){if(void 0!==n&&"undefined"!=typeof document){Element.prototype.matches||(Element.prototype.matches=Element.prototype.msMatchesSelector||Element.prototype.webkitMatchesSelector);var e={js:"javascript",py:"python",rb:"ruby",ps1:"powershell",psm1:"powershell",sh:"bash",bat:"batch",h:"c",tex:"latex"},t="data-src-status",r="loading",i="loaded",o="pre[data-src]:not(["+t+'="'+i+'"]):not(['+t+'="'+r+'"])';n.hooks.add("before-highlightall",(function(e){e.selector+=", "+o})),n.hooks.add("before-sanity-check",(function(s){var l=s.element;if(l.matches(o)){s.code="",l.setAttribute(t,r);var a=l.appendChild(document.createElement("CODE"));a.textContent="Loading…";var c=l.getAttribute("data-src"),u=s.language;if("none"===u){var d=(/\.(\w+)$/.exec(c)||[,"none"])[1];u=e[d]||d}n.util.setLanguage(a,u),n.util.setLanguage(l,u);var h=n.plugins.autoloader;h&&h.loadLanguages(u),function(e,t,n){var r=new XMLHttpRequest;r.open("GET",e,!0),r.onreadystatechange=function(){4==r.readyState&&(r.status<400&&r.responseText?t(r.responseText):r.status>=400?n("✖ Error "+r.status+" while fetching file: "+r.statusText):n("✖ Error: File does not exist or is empty"))},r.send(null)}(c,(function(e){l.setAttribute(t,i);var r=function(e){var t=/^\s*(\d+)\s*(?:(,)\s*(?:(\d+)\s*)?)?$/.exec(e||"");if(t){var n=Number(t[1]),r=t[2],i=t[3];return r?i?[n,Number(i)]:[n,void 0]:[n,n]}}(l.getAttribute("data-range"));if(r){var o=e.split(/\r\n?|\n/g),s=r[0],c=null==r[1]?o.length:r[1];s<0&&(s+=o.length),s=Math.max(0,Math.min(s-1,o.length)),c<0&&(c+=o.length),c=Math.max(0,Math.min(c,o.length)),e=o.slice(s,c).join("\n"),l.hasAttribute("data-start")||l.setAttribute("data-start",String(s+1))}a.textContent=e,n.highlightElement(a)}),(function(e){l.setAttribute(t,"failed"),a.textContent=e}))}})),n.plugins.fileHighlight={highlight:function(e){for(var t,r=(e||document).querySelectorAll(o),i=0;t=r[i++];)n.highlightElement(t)}};var s=!1;n.fileHighlight=function(){s||(console.warn("Prism.fileHighlight is deprecated. Use `Prism.plugins.fileHighlight.highlight` instead."),s=!0),n.plugins.fileHighlight.highlight.apply(this,arguments)}}}()}(i)),i.exports),s=n(o);s.languages.clike={comment:[{pattern:/(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/,lookbehind:!0,greedy:!0},{pattern:/(^|[^\\:])\/\/.*/,lookbehind:!0,greedy:!0}],string:{pattern:/(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,greedy:!0},"class-name":{pattern:/(\b(?:class|extends|implements|instanceof|interface|new|trait)\s+|\bcatch\s+\()[\w.\\]+/i,lookbehind:!0,inside:{punctuation:/[.\\]/}},keyword:/\b(?:break|catch|continue|do|else|finally|for|function|if|in|instanceof|new|null|return|throw|try|while)\b/,boolean:/\b(?:false|true)\b/,function:/\b\w+(?=\()/,number:/\b0x[\da-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?/i,operator:/[<>]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/,punctuation:/[{}[\];(),.:]/},s.languages.markup={comment:{pattern://,greedy:!0},prolog:{pattern:/<\?[\s\S]+?\?>/,greedy:!0},doctype:{pattern:/"'[\]]|"[^"]*"|'[^']*')+(?:\[(?:[^<"'\]]|"[^"]*"|'[^']*'|<(?!!--)|)*\]\s*)?>/i,greedy:!0,inside:{"internal-subset":{pattern:/(^[^\[]*\[)[\s\S]+(?=\]>$)/,lookbehind:!0,greedy:!0,inside:null},string:{pattern:/"[^"]*"|'[^']*'/,greedy:!0},punctuation:/^$|[[\]]/,"doctype-tag":/^DOCTYPE/i,name:/[^\s<>'"]+/}},cdata:{pattern://i,greedy:!0},tag:{pattern:/<\/?(?!\d)[^\s>\/=$<%]+(?:\s(?:\s*[^\s>\/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/,greedy:!0,inside:{tag:{pattern:/^<\/?[^\s>\/]+/,inside:{punctuation:/^<\/?/,namespace:/^[^\s>\/:]+:/}},"special-attr":[],"attr-value":{pattern:/=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+)/,inside:{punctuation:[{pattern:/^=/,alias:"attr-equals"},{pattern:/^(\s*)["']|["']$/,lookbehind:!0}]}},punctuation:/\/?>/,"attr-name":{pattern:/[^\s>\/]+/,inside:{namespace:/^[^\s>\/:]+:/}}}},entity:[{pattern:/&[\da-z]{1,8};/i,alias:"named-entity"},/&#x?[\da-f]{1,8};/i]},s.languages.markup.tag.inside["attr-value"].inside.entity=s.languages.markup.entity,s.languages.markup.doctype.inside["internal-subset"].inside=s.languages.markup,s.hooks.add("wrap",(function(e){"entity"===e.type&&(e.attributes.title=e.content.replace(/&/,"&"))})),Object.defineProperty(s.languages.markup.tag,"addInlined",{value:function(e,t){var n={};n["language-"+t]={pattern:/(^$)/i,lookbehind:!0,inside:s.languages[t]},n.cdata=/^$/i;var r={"included-cdata":{pattern://i,inside:n}};r["language-"+t]={pattern:/[\s\S]+/,inside:s.languages[t]};var i={};i[e]={pattern:RegExp(/(<__[^>]*>)(?:))*\]\]>|(?!)/.source.replace(/__/g,(function(){return e})),"i"),lookbehind:!0,greedy:!0,inside:r},s.languages.insertBefore("markup","cdata",i)}}),Object.defineProperty(s.languages.markup.tag,"addAttribute",{value:function(e,t){s.languages.markup.tag.inside["special-attr"].push({pattern:RegExp(/(^|["'\s])/.source+"(?:"+e+")"+/\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))/.source,"i"),lookbehind:!0,inside:{"attr-name":/^[^\s=]+/,"attr-value":{pattern:/=[\s\S]+/,inside:{value:{pattern:/(^=\s*(["']|(?!["'])))\S[\s\S]*(?=\2$)/,lookbehind:!0,alias:[t,"language-"+t],inside:s.languages[t]},punctuation:[{pattern:/^=/,alias:"attr-equals"},/"|'/]}}}})}}),s.languages.html=s.languages.markup,s.languages.mathml=s.languages.markup,s.languages.svg=s.languages.markup,s.languages.xml=s.languages.extend("markup",{}),s.languages.ssml=s.languages.xml,s.languages.atom=s.languages.xml,s.languages.rss=s.languages.xml,function(e){function t(e,t){return"___"+e.toUpperCase()+t+"___"}Object.defineProperties(e.languages["markup-templating"]={},{buildPlaceholders:{value:function(n,r,i,o){if(n.language===r){var s=n.tokenStack=[];n.code=n.code.replace(i,(function(e){if("function"==typeof o&&!o(e))return e;for(var i,l=s.length;-1!==n.code.indexOf(i=t(r,l));)++l;return s[l]=e,i})),n.grammar=e.languages.markup}}},tokenizePlaceholders:{value:function(n,r){if(n.language===r&&n.tokenStack){n.grammar=e.languages[r];var i=0,o=Object.keys(n.tokenStack);!function s(l){for(var a=0;a=o.length);a++){var c=l[a];if("string"==typeof c||c.content&&"string"==typeof c.content){var u=o[i],d=n.tokenStack[u],h="string"==typeof c?c:c.content,g=t(r,u),p=h.indexOf(g);if(p>-1){++i;var f=h.substring(0,p),m=new e.Token(r,e.tokenize(d,n.grammar),"language-"+r,d),y=h.substring(p+g.length),b=[];f&&b.push.apply(b,s([f])),b.push(m),y&&b.push.apply(b,s([y])),"string"==typeof c?l.splice.apply(l,[a,1].concat(b)):c.content=b}}else c.content&&s(c.content)}return l}(n.tokens)}}}})}(s);var l;l||(l=1,function(e){e.languages.ruby=e.languages.extend("clike",{comment:{pattern:/#.*|^=begin\s[\s\S]*?^=end/m,greedy:!0},"class-name":{pattern:/(\b(?:class|module)\s+|\bcatch\s+\()[\w.\\]+|\b[A-Z_]\w*(?=\s*\.\s*new\b)/,lookbehind:!0,inside:{punctuation:/[.\\]/}},keyword:/\b(?:BEGIN|END|alias|and|begin|break|case|class|def|define_method|defined|do|each|else|elsif|end|ensure|extend|for|if|in|include|module|new|next|nil|not|or|prepend|private|protected|public|raise|redo|require|rescue|retry|return|self|super|then|throw|undef|unless|until|when|while|yield)\b/,operator:/\.{2,3}|&\.|===||[!=]?~|(?:&&|\|\||<<|>>|\*\*|[+\-*/%<>!^&|=])=?|[?:]/,punctuation:/[(){}[\].,;]/}),e.languages.insertBefore("ruby","operator",{"double-colon":{pattern:/::/,alias:"punctuation"}});var t={pattern:/((?:^|[^\\])(?:\\{2})*)#\{(?:[^{}]|\{[^{}]*\})*\}/,lookbehind:!0,inside:{content:{pattern:/^(#\{)[\s\S]+(?=\}$)/,lookbehind:!0,inside:e.languages.ruby},delimiter:{pattern:/^#\{|\}$/,alias:"punctuation"}}};delete e.languages.ruby.function;var n="(?:"+[/([^a-zA-Z0-9\s{(\[<=])(?:(?!\1)[^\\]|\\[\s\S])*\1/.source,/\((?:[^()\\]|\\[\s\S]|\((?:[^()\\]|\\[\s\S])*\))*\)/.source,/\{(?:[^{}\\]|\\[\s\S]|\{(?:[^{}\\]|\\[\s\S])*\})*\}/.source,/\[(?:[^\[\]\\]|\\[\s\S]|\[(?:[^\[\]\\]|\\[\s\S])*\])*\]/.source,/<(?:[^<>\\]|\\[\s\S]|<(?:[^<>\\]|\\[\s\S])*>)*>/.source].join("|")+")",r=/(?:"(?:\\.|[^"\\\r\n])*"|(?:\b[a-zA-Z_]\w*|[^\s\0-\x7F]+)[?!]?|\$.)/.source;e.languages.insertBefore("ruby","keyword",{"regex-literal":[{pattern:RegExp(/%r/.source+n+/[egimnosux]{0,6}/.source),greedy:!0,inside:{interpolation:t,regex:/[\s\S]+/}},{pattern:/(^|[^/])\/(?!\/)(?:\[[^\r\n\]]+\]|\\.|[^[/\\\r\n])+\/[egimnosux]{0,6}(?=\s*(?:$|[\r\n,.;})#]))/,lookbehind:!0,greedy:!0,inside:{interpolation:t,regex:/[\s\S]+/}}],variable:/[@$]+[a-zA-Z_]\w*(?:[?!]|\b)/,symbol:[{pattern:RegExp(/(^|[^:]):/.source+r),lookbehind:!0,greedy:!0},{pattern:RegExp(/([\r\n{(,][ \t]*)/.source+r+/(?=:(?!:))/.source),lookbehind:!0,greedy:!0}],"method-definition":{pattern:/(\bdef\s+)\w+(?:\s*\.\s*\w+)?/,lookbehind:!0,inside:{function:/\b\w+$/,keyword:/^self\b/,"class-name":/^\w+/,punctuation:/\./}}}),e.languages.insertBefore("ruby","string",{"string-literal":[{pattern:RegExp(/%[qQiIwWs]?/.source+n),greedy:!0,inside:{interpolation:t,string:/[\s\S]+/}},{pattern:/("|')(?:#\{[^}]+\}|#(?!\{)|\\(?:\r\n|[\s\S])|(?!\1)[^\\#\r\n])*\1/,greedy:!0,inside:{interpolation:t,string:/[\s\S]+/}},{pattern:/<<[-~]?([a-z_]\w*)[\r\n](?:.*[\r\n])*?[\t ]*\1/i,alias:"heredoc-string",greedy:!0,inside:{delimiter:{pattern:/^<<[-~]?[a-z_]\w*|\b[a-z_]\w*$/i,inside:{symbol:/\b\w+/,punctuation:/^<<[-~]?/}},interpolation:t,string:/[\s\S]+/}},{pattern:/<<[-~]?'([a-z_]\w*)'[\r\n](?:.*[\r\n])*?[\t ]*\1/i,alias:"heredoc-string",greedy:!0,inside:{delimiter:{pattern:/^<<[-~]?'[a-z_]\w*'|\b[a-z_]\w*$/i,inside:{symbol:/\b\w+/,punctuation:/^<<[-~]?'|'$/}},string:/[\s\S]+/}}],"command-literal":[{pattern:RegExp(/%x/.source+n),greedy:!0,inside:{interpolation:t,command:{pattern:/[\s\S]+/,alias:"string"}}},{pattern:/`(?:#\{[^}]+\}|#(?!\{)|\\(?:\r\n|[\s\S])|[^\\`#\r\n])*`/,greedy:!0,inside:{interpolation:t,command:{pattern:/[\s\S]+/,alias:"string"}}}]}),delete e.languages.ruby.string,e.languages.insertBefore("ruby","number",{builtin:/\b(?:Array|Bignum|Binding|Class|Continuation|Dir|Exception|FalseClass|File|Fixnum|Float|Hash|IO|Integer|MatchData|Method|Module|NilClass|Numeric|Object|Proc|Range|Regexp|Stat|String|Struct|Symbol|TMS|Thread|ThreadGroup|Time|TrueClass)\b/,constant:/\b[A-Z][A-Z0-9_]*(?:[?!]|\b)/}),e.languages.rb=e.languages.ruby}(s));var a;a||(a=1,function(e){var t=/\/\*[\s\S]*?\*\/|\/\/.*|#(?!\[).*/,n=[{pattern:/\b(?:false|true)\b/i,alias:"boolean"},{pattern:/(::\s*)\b[a-z_]\w*\b(?!\s*\()/i,greedy:!0,lookbehind:!0},{pattern:/(\b(?:case|const)\s+)\b[a-z_]\w*(?=\s*[;=])/i,greedy:!0,lookbehind:!0},/\b(?:null)\b/i,/\b[A-Z_][A-Z0-9_]*\b(?!\s*\()/],r=/\b0b[01]+(?:_[01]+)*\b|\b0o[0-7]+(?:_[0-7]+)*\b|\b0x[\da-f]+(?:_[\da-f]+)*\b|(?:\b\d+(?:_\d+)*\.?(?:\d+(?:_\d+)*)?|\B\.\d+)(?:e[+-]?\d+)?/i,i=/|\?\?=?|\.{3}|\??->|[!=]=?=?|::|\*\*=?|--|\+\+|&&|\|\||<<|>>|[?~]|[/^|%*&<>.+-]=?/,o=/[{}\[\](),:;]/;e.languages.php={delimiter:{pattern:/\?>$|^<\?(?:php(?=\s)|=)?/i,alias:"important"},comment:t,variable:/\$+(?:\w+\b|(?=\{))/,package:{pattern:/(namespace\s+|use\s+(?:function\s+)?)(?:\\?\b[a-z_]\w*)+\b(?!\\)/i,lookbehind:!0,inside:{punctuation:/\\/}},"class-name-definition":{pattern:/(\b(?:class|enum|interface|trait)\s+)\b[a-z_]\w*(?!\\)\b/i,lookbehind:!0,alias:"class-name"},"function-definition":{pattern:/(\bfunction\s+)[a-z_]\w*(?=\s*\()/i,lookbehind:!0,alias:"function"},keyword:[{pattern:/(\(\s*)\b(?:array|bool|boolean|float|int|integer|object|string)\b(?=\s*\))/i,alias:"type-casting",greedy:!0,lookbehind:!0},{pattern:/([(,?]\s*)\b(?:array(?!\s*\()|bool|callable|(?:false|null)(?=\s*\|)|float|int|iterable|mixed|object|self|static|string)\b(?=\s*\$)/i,alias:"type-hint",greedy:!0,lookbehind:!0},{pattern:/(\)\s*:\s*(?:\?\s*)?)\b(?:array(?!\s*\()|bool|callable|(?:false|null)(?=\s*\|)|float|int|iterable|mixed|never|object|self|static|string|void)\b/i,alias:"return-type",greedy:!0,lookbehind:!0},{pattern:/\b(?:array(?!\s*\()|bool|float|int|iterable|mixed|object|string|void)\b/i,alias:"type-declaration",greedy:!0},{pattern:/(\|\s*)(?:false|null)\b|\b(?:false|null)(?=\s*\|)/i,alias:"type-declaration",greedy:!0,lookbehind:!0},{pattern:/\b(?:parent|self|static)(?=\s*::)/i,alias:"static-context",greedy:!0},{pattern:/(\byield\s+)from\b/i,lookbehind:!0},/\bclass\b/i,{pattern:/((?:^|[^\s>:]|(?:^|[^-])>|(?:^|[^:]):)\s*)\b(?:abstract|and|array|as|break|callable|case|catch|clone|const|continue|declare|default|die|do|echo|else|elseif|empty|enddeclare|endfor|endforeach|endif|endswitch|endwhile|enum|eval|exit|extends|final|finally|fn|for|foreach|function|global|goto|if|implements|include|include_once|instanceof|insteadof|interface|isset|list|match|namespace|never|new|or|parent|print|private|protected|public|readonly|require|require_once|return|self|static|switch|throw|trait|try|unset|use|var|while|xor|yield|__halt_compiler)\b/i,lookbehind:!0}],"argument-name":{pattern:/([(,]\s*)\b[a-z_]\w*(?=\s*:(?!:))/i,lookbehind:!0},"class-name":[{pattern:/(\b(?:extends|implements|instanceof|new(?!\s+self|\s+static))\s+|\bcatch\s*\()\b[a-z_]\w*(?!\\)\b/i,greedy:!0,lookbehind:!0},{pattern:/(\|\s*)\b[a-z_]\w*(?!\\)\b/i,greedy:!0,lookbehind:!0},{pattern:/\b[a-z_]\w*(?!\\)\b(?=\s*\|)/i,greedy:!0},{pattern:/(\|\s*)(?:\\?\b[a-z_]\w*)+\b/i,alias:"class-name-fully-qualified",greedy:!0,lookbehind:!0,inside:{punctuation:/\\/}},{pattern:/(?:\\?\b[a-z_]\w*)+\b(?=\s*\|)/i,alias:"class-name-fully-qualified",greedy:!0,inside:{punctuation:/\\/}},{pattern:/(\b(?:extends|implements|instanceof|new(?!\s+self\b|\s+static\b))\s+|\bcatch\s*\()(?:\\?\b[a-z_]\w*)+\b(?!\\)/i,alias:"class-name-fully-qualified",greedy:!0,lookbehind:!0,inside:{punctuation:/\\/}},{pattern:/\b[a-z_]\w*(?=\s*\$)/i,alias:"type-declaration",greedy:!0},{pattern:/(?:\\?\b[a-z_]\w*)+(?=\s*\$)/i,alias:["class-name-fully-qualified","type-declaration"],greedy:!0,inside:{punctuation:/\\/}},{pattern:/\b[a-z_]\w*(?=\s*::)/i,alias:"static-context",greedy:!0},{pattern:/(?:\\?\b[a-z_]\w*)+(?=\s*::)/i,alias:["class-name-fully-qualified","static-context"],greedy:!0,inside:{punctuation:/\\/}},{pattern:/([(,?]\s*)[a-z_]\w*(?=\s*\$)/i,alias:"type-hint",greedy:!0,lookbehind:!0},{pattern:/([(,?]\s*)(?:\\?\b[a-z_]\w*)+(?=\s*\$)/i,alias:["class-name-fully-qualified","type-hint"],greedy:!0,lookbehind:!0,inside:{punctuation:/\\/}},{pattern:/(\)\s*:\s*(?:\?\s*)?)\b[a-z_]\w*(?!\\)\b/i,alias:"return-type",greedy:!0,lookbehind:!0},{pattern:/(\)\s*:\s*(?:\?\s*)?)(?:\\?\b[a-z_]\w*)+\b(?!\\)/i,alias:["class-name-fully-qualified","return-type"],greedy:!0,lookbehind:!0,inside:{punctuation:/\\/}}],constant:n,function:{pattern:/(^|[^\\\w])\\?[a-z_](?:[\w\\]*\w)?(?=\s*\()/i,lookbehind:!0,inside:{punctuation:/\\/}},property:{pattern:/(->\s*)\w+/,lookbehind:!0},number:r,operator:i,punctuation:o};var s={pattern:/\{\$(?:\{(?:\{[^{}]+\}|[^{}]+)\}|[^{}])+\}|(^|[^\\{])\$+(?:\w+(?:\[[^\r\n\[\]]+\]|->\w+)?)/,lookbehind:!0,inside:e.languages.php},l=[{pattern:/<<<'([^']+)'[\r\n](?:.*[\r\n])*?\1;/,alias:"nowdoc-string",greedy:!0,inside:{delimiter:{pattern:/^<<<'[^']+'|[a-z_]\w*;$/i,alias:"symbol",inside:{punctuation:/^<<<'?|[';]$/}}}},{pattern:/<<<(?:"([^"]+)"[\r\n](?:.*[\r\n])*?\1;|([a-z_]\w*)[\r\n](?:.*[\r\n])*?\2;)/i,alias:"heredoc-string",greedy:!0,inside:{delimiter:{pattern:/^<<<(?:"[^"]+"|[a-z_]\w*)|[a-z_]\w*;$/i,alias:"symbol",inside:{punctuation:/^<<<"?|[";]$/}},interpolation:s}},{pattern:/`(?:\\[\s\S]|[^\\`])*`/,alias:"backtick-quoted-string",greedy:!0},{pattern:/'(?:\\[\s\S]|[^\\'])*'/,alias:"single-quoted-string",greedy:!0},{pattern:/"(?:\\[\s\S]|[^\\"])*"/,alias:"double-quoted-string",greedy:!0,inside:{interpolation:s}}];e.languages.insertBefore("php","variable",{string:l,attribute:{pattern:/#\[(?:[^"'\/#]|\/(?![*/])|\/\/.*$|#(?!\[).*$|\/\*(?:[^*]|\*(?!\/))*\*\/|"(?:\\[\s\S]|[^\\"])*"|'(?:\\[\s\S]|[^\\'])*')+\](?=\s*[a-z$#])/im,greedy:!0,inside:{"attribute-content":{pattern:/^(#\[)[\s\S]+(?=\]$)/,lookbehind:!0,inside:{comment:t,string:l,"attribute-class-name":[{pattern:/([^:]|^)\b[a-z_]\w*(?!\\)\b/i,alias:"class-name",greedy:!0,lookbehind:!0},{pattern:/([^:]|^)(?:\\?\b[a-z_]\w*)+/i,alias:["class-name","class-name-fully-qualified"],greedy:!0,lookbehind:!0,inside:{punctuation:/\\/}}],constant:n,number:r,operator:i,punctuation:o}},delimiter:{pattern:/^#\[|\]$/,alias:"punctuation"}}}}),e.hooks.add("before-tokenize",(function(t){/<\?/.test(t.code)&&e.languages["markup-templating"].buildPlaceholders(t,"php",/<\?(?:[^"'/#]|\/(?![*/])|("|')(?:\\[\s\S]|(?!\1)[^\\])*\1|(?:\/\/|#(?!\[))(?:[^?\n\r]|\?(?!>))*(?=$|\?>|[\r\n])|#\[|\/\*(?:[^*]|\*(?!\/))*(?:\*\/|$))*?(?:\?>|$)/g)})),e.hooks.add("after-tokenize",(function(t){e.languages["markup-templating"].tokenizePlaceholders(t,"php")}))}(s)),s.languages.go=s.languages.extend("clike",{string:{pattern:/(^|[^\\])"(?:\\.|[^"\\\r\n])*"|`[^`]*`/,lookbehind:!0,greedy:!0},keyword:/\b(?:break|case|chan|const|continue|default|defer|else|fallthrough|for|func|go(?:to)?|if|import|interface|map|package|range|return|select|struct|switch|type|var)\b/,boolean:/\b(?:_|false|iota|nil|true)\b/,number:[/\b0(?:b[01_]+|o[0-7_]+)i?\b/i,/\b0x(?:[a-f\d_]+(?:\.[a-f\d_]*)?|\.[a-f\d_]+)(?:p[+-]?\d+(?:_\d+)*)?i?(?!\w)/i,/(?:\b\d[\d_]*(?:\.[\d_]*)?|\B\.\d[\d_]*)(?:e[+-]?[\d_]+)?i?(?!\w)/i],operator:/[*\/%^!=]=?|\+[=+]?|-[=-]?|\|[=|]?|&(?:=|&|\^=?)?|>(?:>=?|=)?|<(?:<=?|=|-)?|:=|\.\.\./,builtin:/\b(?:append|bool|byte|cap|close|complex|complex(?:64|128)|copy|delete|error|float(?:32|64)|u?int(?:8|16|32|64)?|imag|len|make|new|panic|print(?:ln)?|real|recover|rune|string|uintptr)\b/}),s.languages.insertBefore("go","string",{char:{pattern:/'(?:\\.|[^'\\\r\n]){0,10}'/,greedy:!0}}),delete s.languages.go["class-name"],function(e){var t="\\b(?:BASH|BASHOPTS|BASH_ALIASES|BASH_ARGC|BASH_ARGV|BASH_CMDS|BASH_COMPLETION_COMPAT_DIR|BASH_LINENO|BASH_REMATCH|BASH_SOURCE|BASH_VERSINFO|BASH_VERSION|COLORTERM|COLUMNS|COMP_WORDBREAKS|DBUS_SESSION_BUS_ADDRESS|DEFAULTS_PATH|DESKTOP_SESSION|DIRSTACK|DISPLAY|EUID|GDMSESSION|GDM_LANG|GNOME_KEYRING_CONTROL|GNOME_KEYRING_PID|GPG_AGENT_INFO|GROUPS|HISTCONTROL|HISTFILE|HISTFILESIZE|HISTSIZE|HOME|HOSTNAME|HOSTTYPE|IFS|INSTANCE|JOB|LANG|LANGUAGE|LC_ADDRESS|LC_ALL|LC_IDENTIFICATION|LC_MEASUREMENT|LC_MONETARY|LC_NAME|LC_NUMERIC|LC_PAPER|LC_TELEPHONE|LC_TIME|LESSCLOSE|LESSOPEN|LINES|LOGNAME|LS_COLORS|MACHTYPE|MAILCHECK|MANDATORY_PATH|NO_AT_BRIDGE|OLDPWD|OPTERR|OPTIND|ORBIT_SOCKETDIR|OSTYPE|PAPERSIZE|PATH|PIPESTATUS|PPID|PS1|PS2|PS3|PS4|PWD|RANDOM|REPLY|SECONDS|SELINUX_INIT|SESSION|SESSIONTYPE|SESSION_MANAGER|SHELL|SHELLOPTS|SHLVL|SSH_AUTH_SOCK|TERM|UID|UPSTART_EVENTS|UPSTART_INSTANCE|UPSTART_JOB|UPSTART_SESSION|USER|WINDOWID|XAUTHORITY|XDG_CONFIG_DIRS|XDG_CURRENT_DESKTOP|XDG_DATA_DIRS|XDG_GREETER_DATA_DIR|XDG_MENU_PREFIX|XDG_RUNTIME_DIR|XDG_SEAT|XDG_SEAT_PATH|XDG_SESSION_DESKTOP|XDG_SESSION_ID|XDG_SESSION_PATH|XDG_SESSION_TYPE|XDG_VTNR|XMODIFIERS)\\b",n={pattern:/(^(["']?)\w+\2)[ \t]+\S.*/,lookbehind:!0,alias:"punctuation",inside:null},r={bash:n,environment:{pattern:RegExp("\\$"+t),alias:"constant"},variable:[{pattern:/\$?\(\([\s\S]+?\)\)/,greedy:!0,inside:{variable:[{pattern:/(^\$\(\([\s\S]+)\)\)/,lookbehind:!0},/^\$\(\(/],number:/\b0x[\dA-Fa-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:[Ee]-?\d+)?/,operator:/--|\+\+|\*\*=?|<<=?|>>=?|&&|\|\||[=!+\-*/%<>^&|]=?|[?~:]/,punctuation:/\(\(?|\)\)?|,|;/}},{pattern:/\$\((?:\([^)]+\)|[^()])+\)|`[^`]+`/,greedy:!0,inside:{variable:/^\$\(|^`|\)$|`$/}},{pattern:/\$\{[^}]+\}/,greedy:!0,inside:{operator:/:[-=?+]?|[!\/]|##?|%%?|\^\^?|,,?/,punctuation:/[\[\]]/,environment:{pattern:RegExp("(\\{)"+t),lookbehind:!0,alias:"constant"}}},/\$(?:\w+|[#?*!@$])/],entity:/\\(?:[abceEfnrtv\\"]|O?[0-7]{1,3}|U[0-9a-fA-F]{8}|u[0-9a-fA-F]{4}|x[0-9a-fA-F]{1,2})/};e.languages.bash={shebang:{pattern:/^#!\s*\/.*/,alias:"important"},comment:{pattern:/(^|[^"{\\$])#.*/,lookbehind:!0},"function-name":[{pattern:/(\bfunction\s+)[\w-]+(?=(?:\s*\(?:\s*\))?\s*\{)/,lookbehind:!0,alias:"function"},{pattern:/\b[\w-]+(?=\s*\(\s*\)\s*\{)/,alias:"function"}],"for-or-select":{pattern:/(\b(?:for|select)\s+)\w+(?=\s+in\s)/,alias:"variable",lookbehind:!0},"assign-left":{pattern:/(^|[\s;|&]|[<>]\()\w+(?:\.\w+)*(?=\+?=)/,inside:{environment:{pattern:RegExp("(^|[\\s;|&]|[<>]\\()"+t),lookbehind:!0,alias:"constant"}},alias:"variable",lookbehind:!0},parameter:{pattern:/(^|\s)-{1,2}(?:\w+:[+-]?)?\w+(?:\.\w+)*(?=[=\s]|$)/,alias:"variable",lookbehind:!0},string:[{pattern:/((?:^|[^<])<<-?\s*)(\w+)\s[\s\S]*?(?:\r?\n|\r)\2/,lookbehind:!0,greedy:!0,inside:r},{pattern:/((?:^|[^<])<<-?\s*)(["'])(\w+)\2\s[\s\S]*?(?:\r?\n|\r)\3/,lookbehind:!0,greedy:!0,inside:{bash:n}},{pattern:/(^|[^\\](?:\\\\)*)"(?:\\[\s\S]|\$\([^)]+\)|\$(?!\()|`[^`]+`|[^"\\`$])*"/,lookbehind:!0,greedy:!0,inside:r},{pattern:/(^|[^$\\])'[^']*'/,lookbehind:!0,greedy:!0},{pattern:/\$'(?:[^'\\]|\\[\s\S])*'/,greedy:!0,inside:{entity:r.entity}}],environment:{pattern:RegExp("\\$?"+t),alias:"constant"},variable:r.variable,function:{pattern:/(^|[\s;|&]|[<>]\()(?:add|apropos|apt|apt-cache|apt-get|aptitude|aspell|automysqlbackup|awk|basename|bash|bc|bconsole|bg|bzip2|cal|cargo|cat|cfdisk|chgrp|chkconfig|chmod|chown|chroot|cksum|clear|cmp|column|comm|composer|cp|cron|crontab|csplit|curl|cut|date|dc|dd|ddrescue|debootstrap|df|diff|diff3|dig|dir|dircolors|dirname|dirs|dmesg|docker|docker-compose|du|egrep|eject|env|ethtool|expand|expect|expr|fdformat|fdisk|fg|fgrep|file|find|fmt|fold|format|free|fsck|ftp|fuser|gawk|git|gparted|grep|groupadd|groupdel|groupmod|groups|grub-mkconfig|gzip|halt|head|hg|history|host|hostname|htop|iconv|id|ifconfig|ifdown|ifup|import|install|ip|java|jobs|join|kill|killall|less|link|ln|locate|logname|logrotate|look|lpc|lpr|lprint|lprintd|lprintq|lprm|ls|lsof|lynx|make|man|mc|mdadm|mkconfig|mkdir|mke2fs|mkfifo|mkfs|mkisofs|mknod|mkswap|mmv|more|most|mount|mtools|mtr|mutt|mv|nano|nc|netstat|nice|nl|node|nohup|notify-send|npm|nslookup|op|open|parted|passwd|paste|pathchk|ping|pkill|pnpm|podman|podman-compose|popd|pr|printcap|printenv|ps|pushd|pv|quota|quotacheck|quotactl|ram|rar|rcp|reboot|remsync|rename|renice|rev|rm|rmdir|rpm|rsync|scp|screen|sdiff|sed|sendmail|seq|service|sftp|sh|shellcheck|shuf|shutdown|sleep|slocate|sort|split|ssh|stat|strace|su|sudo|sum|suspend|swapon|sync|sysctl|tac|tail|tar|tee|time|timeout|top|touch|tr|traceroute|tsort|tty|umount|uname|unexpand|uniq|units|unrar|unshar|unzip|update-grub|uptime|useradd|userdel|usermod|users|uudecode|uuencode|v|vcpkg|vdir|vi|vim|virsh|vmstat|wait|watch|wc|wget|whereis|which|who|whoami|write|xargs|xdg-open|yarn|yes|zenity|zip|zsh|zypper)(?=$|[)\s;|&])/,lookbehind:!0},keyword:{pattern:/(^|[\s;|&]|[<>]\()(?:case|do|done|elif|else|esac|fi|for|function|if|in|select|then|until|while)(?=$|[)\s;|&])/,lookbehind:!0},builtin:{pattern:/(^|[\s;|&]|[<>]\()(?:\.|:|alias|bind|break|builtin|caller|cd|command|continue|declare|echo|enable|eval|exec|exit|export|getopts|hash|help|let|local|logout|mapfile|printf|pwd|read|readarray|readonly|return|set|shift|shopt|source|test|times|trap|type|typeset|ulimit|umask|unalias|unset)(?=$|[)\s;|&])/,lookbehind:!0,alias:"class-name"},boolean:{pattern:/(^|[\s;|&]|[<>]\()(?:false|true)(?=$|[)\s;|&])/,lookbehind:!0},"file-descriptor":{pattern:/\B&\d\b/,alias:"important"},operator:{pattern:/\d?<>|>\||\+=|=[=~]?|!=?|<<[<-]?|[&\d]?>>|\d[<>]&?|[<>][&=]?|&[>&]?|\|[&|]?/,inside:{"file-descriptor":{pattern:/^\d/,alias:"important"}}},punctuation:/\$?\(\(?|\)\)?|\.\.|[{}[\];\\]/,number:{pattern:/(^|\s)(?:[1-9]\d*|0)(?:[.,]\d+)?\b/,lookbehind:!0}},n.inside=e.languages.bash;for(var i=["comment","function-name","for-or-select","assign-left","parameter","string","environment","function","keyword","builtin","boolean","file-descriptor","operator","punctuation","number"],o=r.variable[1].inside,s=0;s",unchanged:" ",diff:"!"};Object.keys(t).forEach((function(n){var r=t[n],i=[];/^\w+$/.test(n)||i.push(/\w+/.exec(n)[0]),"diff"===n&&i.push("bold"),e.languages.diff[n]={pattern:RegExp("^(?:["+r+"].*(?:\r\n?|\n|(?![\\s\\S])))+","m"),alias:i,inside:{line:{pattern:/(.)(?=[\s\S]).*(?:\r\n?|\n)?/,lookbehind:!0},prefix:{pattern:/[\s\S]/,alias:/\w+/.exec(n)[0]}}}})),Object.defineProperty(e.languages.diff,"PREFIXES",{value:t})}(s),window.Prism=window.Prism||{},window.Prism.manual=!0; /*! @license DOMPurify 3.3.0 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.3.0/LICENSE */ -const{entries:c,setPrototypeOf:u,isFrozen:d,getPrototypeOf:h,getOwnPropertyDescriptor:g}=Object;let{freeze:p,seal:f,create:m}=Object,{apply:y,construct:b}="undefined"!=typeof Reflect&&Reflect;p||(p=function(e){return e}),f||(f=function(e){return e}),y||(y=function(e,t){for(var n=arguments.length,r=new Array(n>2?n-2:0),i=2;i1?t-1:0),r=1;r1?n-1:0),i=1;i2&&void 0!==arguments[2]?arguments[2]:w;u&&u(e,null);let r=t.length;for(;r--;){let i=t[r];if("string"==typeof i){const e=n(i);e!==i&&(d(t)||(t[r]=e),i=e)}e[i]=!0}return e}function M(e){for(let t=0;t/gm),X=f(/\$\{[\w\W]*/gm),Q=f(/^data-[\-\w.\u00B7-\uFFFF]+$/),ee=f(/^aria-[\-\w]+$/),te=f(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),ne=f(/^(?:\w+script|data):/i),re=f(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),ie=f(/^html$/i),oe=f(/^[a-z][.\w]*(-[.\w]+)+$/i);var se=Object.freeze({__proto__:null,ARIA_ATTR:ee,ATTR_WHITESPACE:re,CUSTOM_ELEMENT:oe,DATA_ATTR:Q,DOCTYPE_NAME:ie,ERB_EXPR:Y,IS_ALLOWED_URI:te,IS_SCRIPT_OR_DATA:ne,MUSTACHE_EXPR:J,TMPLIT_EXPR:X});const le=1,ae=3,ce=7,ue=8,de=9,he=function(){return"undefined"==typeof window?null:window};var ge=function e(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:he();const n=t=>e(t);if(n.version="3.3.0",n.removed=[],!t||!t.document||t.document.nodeType!==de||!t.Element)return n.isSupported=!1,n;let{document:r}=t;const i=r,o=i.currentScript,{DocumentFragment:s,HTMLTemplateElement:l,Node:a,Element:u,NodeFilter:d,NamedNodeMap:h=t.NamedNodeMap||t.MozNamedAttrMap,HTMLFormElement:g,DOMParser:f,trustedTypes:y}=t,b=u.prototype,R=B(b,"cloneNode"),I=B(b,"remove"),M=B(b,"nextSibling"),J=B(b,"childNodes"),Y=B(b,"parentNode");if("function"==typeof l){const e=r.createElement("template");e.content&&e.content.ownerDocument&&(r=e.content.ownerDocument)}let X,Q="";const{implementation:ee,createNodeIterator:ne,createDocumentFragment:re,getElementsByTagName:oe}=r,{importNode:ge}=i;let pe={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]};n.isSupported="function"==typeof c&&"function"==typeof Y&&ee&&void 0!==ee.createHTMLDocument;const{MUSTACHE_EXPR:fe,ERB_EXPR:me,TMPLIT_EXPR:ye,DATA_ATTR:be,ARIA_ATTR:_e,IS_SCRIPT_OR_DATA:xe,ATTR_WHITESPACE:Se,CUSTOM_ELEMENT:Ce}=se;let{IS_ALLOWED_URI:ve}=se,we=null;const ke=P({},[...z,...$,...H,...U,...V]);let Te=null;const Ee=P({},[...q,...j,...Z,...G]);let Ne=Object.seal(m(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),Ae=null,Le=null;const Oe=Object.seal(m(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let Fe=!0,Re=!0,Ie=!1,Pe=!0,Me=!1,De=!0,Be=!1,ze=!1,$e=!1,He=!1,Ke=!1,Ue=!1,We=!0,Ve=!1,qe=!0,je=!1,Ze={},Ge=null;const Je=P({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let Ye=null;const Xe=P({},["audio","video","img","source","image","track"]);let Qe=null;const et=P({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),tt="http://www.w3.org/1998/Math/MathML",nt="http://www.w3.org/2000/svg",rt="http://www.w3.org/1999/xhtml";let it=rt,ot=!1,st=null;const lt=P({},[tt,nt,rt],k);let at=P({},["mi","mo","mn","ms","mtext"]),ct=P({},["annotation-xml"]);const ut=P({},["title","style","font","a","script"]);let dt=null;const ht=["application/xhtml+xml","text/html"];let gt=null,pt=null;const ft=r.createElement("form"),mt=function(e){return e instanceof RegExp||e instanceof Function},yt=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!pt||pt!==e){if(e&&"object"==typeof e||(e={}),e=D(e),dt=-1===ht.indexOf(e.PARSER_MEDIA_TYPE)?"text/html":e.PARSER_MEDIA_TYPE,gt="application/xhtml+xml"===dt?k:w,we=L(e,"ALLOWED_TAGS")?P({},e.ALLOWED_TAGS,gt):ke,Te=L(e,"ALLOWED_ATTR")?P({},e.ALLOWED_ATTR,gt):Ee,st=L(e,"ALLOWED_NAMESPACES")?P({},e.ALLOWED_NAMESPACES,k):lt,Qe=L(e,"ADD_URI_SAFE_ATTR")?P(D(et),e.ADD_URI_SAFE_ATTR,gt):et,Ye=L(e,"ADD_DATA_URI_TAGS")?P(D(Xe),e.ADD_DATA_URI_TAGS,gt):Xe,Ge=L(e,"FORBID_CONTENTS")?P({},e.FORBID_CONTENTS,gt):Je,Ae=L(e,"FORBID_TAGS")?P({},e.FORBID_TAGS,gt):D({}),Le=L(e,"FORBID_ATTR")?P({},e.FORBID_ATTR,gt):D({}),Ze=!!L(e,"USE_PROFILES")&&e.USE_PROFILES,Fe=!1!==e.ALLOW_ARIA_ATTR,Re=!1!==e.ALLOW_DATA_ATTR,Ie=e.ALLOW_UNKNOWN_PROTOCOLS||!1,Pe=!1!==e.ALLOW_SELF_CLOSE_IN_ATTR,Me=e.SAFE_FOR_TEMPLATES||!1,De=!1!==e.SAFE_FOR_XML,Be=e.WHOLE_DOCUMENT||!1,He=e.RETURN_DOM||!1,Ke=e.RETURN_DOM_FRAGMENT||!1,Ue=e.RETURN_TRUSTED_TYPE||!1,$e=e.FORCE_BODY||!1,We=!1!==e.SANITIZE_DOM,Ve=e.SANITIZE_NAMED_PROPS||!1,qe=!1!==e.KEEP_CONTENT,je=e.IN_PLACE||!1,ve=e.ALLOWED_URI_REGEXP||te,it=e.NAMESPACE||rt,at=e.MATHML_TEXT_INTEGRATION_POINTS||at,ct=e.HTML_INTEGRATION_POINTS||ct,Ne=e.CUSTOM_ELEMENT_HANDLING||{},e.CUSTOM_ELEMENT_HANDLING&&mt(e.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(Ne.tagNameCheck=e.CUSTOM_ELEMENT_HANDLING.tagNameCheck),e.CUSTOM_ELEMENT_HANDLING&&mt(e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(Ne.attributeNameCheck=e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),e.CUSTOM_ELEMENT_HANDLING&&"boolean"==typeof e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements&&(Ne.allowCustomizedBuiltInElements=e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),Me&&(Re=!1),Ke&&(He=!0),Ze&&(we=P({},V),Te=[],!0===Ze.html&&(P(we,z),P(Te,q)),!0===Ze.svg&&(P(we,$),P(Te,j),P(Te,G)),!0===Ze.svgFilters&&(P(we,H),P(Te,j),P(Te,G)),!0===Ze.mathMl&&(P(we,U),P(Te,Z),P(Te,G))),e.ADD_TAGS&&("function"==typeof e.ADD_TAGS?Oe.tagCheck=e.ADD_TAGS:(we===ke&&(we=D(we)),P(we,e.ADD_TAGS,gt))),e.ADD_ATTR&&("function"==typeof e.ADD_ATTR?Oe.attributeCheck=e.ADD_ATTR:(Te===Ee&&(Te=D(Te)),P(Te,e.ADD_ATTR,gt))),e.ADD_URI_SAFE_ATTR&&P(Qe,e.ADD_URI_SAFE_ATTR,gt),e.FORBID_CONTENTS&&(Ge===Je&&(Ge=D(Ge)),P(Ge,e.FORBID_CONTENTS,gt)),qe&&(we["#text"]=!0),Be&&P(we,["html","head","body"]),we.table&&(P(we,["tbody"]),delete Ae.tbody),e.TRUSTED_TYPES_POLICY){if("function"!=typeof e.TRUSTED_TYPES_POLICY.createHTML)throw F('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if("function"!=typeof e.TRUSTED_TYPES_POLICY.createScriptURL)throw F('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');X=e.TRUSTED_TYPES_POLICY,Q=X.createHTML("")}else void 0===X&&(X=function(e,t){if("object"!=typeof e||"function"!=typeof e.createPolicy)return null;let n=null;const r="data-tt-policy-suffix";t&&t.hasAttribute(r)&&(n=t.getAttribute(r));const i="dompurify"+(n?"#"+n:"");try{return e.createPolicy(i,{createHTML:e=>e,createScriptURL:e=>e})}catch(e){return console.warn("TrustedTypes policy "+i+" could not be created."),null}}(y,o)),null!==X&&"string"==typeof Q&&(Q=X.createHTML(""));p&&p(e),pt=e}},bt=P({},[...$,...H,...K]),_t=P({},[...U,...W]),xt=function(e){C(n.removed,{element:e});try{Y(e).removeChild(e)}catch(t){I(e)}},St=function(e,t){try{C(n.removed,{attribute:t.getAttributeNode(e),from:t})}catch(e){C(n.removed,{attribute:null,from:t})}if(t.removeAttribute(e),"is"===e)if(He||Ke)try{xt(t)}catch(e){}else try{t.setAttribute(e,"")}catch(e){}},Ct=function(e){let t=null,n=null;if($e)e=""+e;else{const t=T(e,/^[\r\n\t ]+/);n=t&&t[0]}"application/xhtml+xml"===dt&&it===rt&&(e=''+e+"");const i=X?X.createHTML(e):e;if(it===rt)try{t=(new f).parseFromString(i,dt)}catch(e){}if(!t||!t.documentElement){t=ee.createDocument(it,"template",null);try{t.documentElement.innerHTML=ot?Q:i}catch(e){}}const o=t.body||t.documentElement;return e&&n&&o.insertBefore(r.createTextNode(n),o.childNodes[0]||null),it===rt?oe.call(t,Be?"html":"body")[0]:Be?t.documentElement:o},vt=function(e){return ne.call(e.ownerDocument||e,e,d.SHOW_ELEMENT|d.SHOW_COMMENT|d.SHOW_TEXT|d.SHOW_PROCESSING_INSTRUCTION|d.SHOW_CDATA_SECTION,null)},wt=function(e){return e instanceof g&&("string"!=typeof e.nodeName||"string"!=typeof e.textContent||"function"!=typeof e.removeChild||!(e.attributes instanceof h)||"function"!=typeof e.removeAttribute||"function"!=typeof e.setAttribute||"string"!=typeof e.namespaceURI||"function"!=typeof e.insertBefore||"function"!=typeof e.hasChildNodes)},kt=function(e){return"function"==typeof a&&e instanceof a};function Tt(e,t,r){_(e,(e=>{e.call(n,t,r,pt)}))}const Et=function(e){let t=null;if(Tt(pe.beforeSanitizeElements,e,null),wt(e))return xt(e),!0;const r=gt(e.nodeName);if(Tt(pe.uponSanitizeElement,e,{tagName:r,allowedTags:we}),De&&e.hasChildNodes()&&!kt(e.firstElementChild)&&O(/<[/\w!]/g,e.innerHTML)&&O(/<[/\w!]/g,e.textContent))return xt(e),!0;if(e.nodeType===ce)return xt(e),!0;if(De&&e.nodeType===ue&&O(/<[/\w]/g,e.data))return xt(e),!0;if(!(Oe.tagCheck instanceof Function&&Oe.tagCheck(r))&&(!we[r]||Ae[r])){if(!Ae[r]&&At(r)){if(Ne.tagNameCheck instanceof RegExp&&O(Ne.tagNameCheck,r))return!1;if(Ne.tagNameCheck instanceof Function&&Ne.tagNameCheck(r))return!1}if(qe&&!Ge[r]){const t=Y(e)||e.parentNode,n=J(e)||e.childNodes;if(n&&t){for(let r=n.length-1;r>=0;--r){const i=R(n[r],!0);i.__removalCount=(e.__removalCount||0)+1,t.insertBefore(i,M(e))}}}return xt(e),!0}return e instanceof u&&!function(e){let t=Y(e);t&&t.tagName||(t={namespaceURI:it,tagName:"template"});const n=w(e.tagName),r=w(t.tagName);return!!st[e.namespaceURI]&&(e.namespaceURI===nt?t.namespaceURI===rt?"svg"===n:t.namespaceURI===tt?"svg"===n&&("annotation-xml"===r||at[r]):Boolean(bt[n]):e.namespaceURI===tt?t.namespaceURI===rt?"math"===n:t.namespaceURI===nt?"math"===n&&ct[r]:Boolean(_t[n]):e.namespaceURI===rt?!(t.namespaceURI===nt&&!ct[r])&&!(t.namespaceURI===tt&&!at[r])&&!_t[n]&&(ut[n]||!bt[n]):!("application/xhtml+xml"!==dt||!st[e.namespaceURI]))}(e)?(xt(e),!0):"noscript"!==r&&"noembed"!==r&&"noframes"!==r||!O(/<\/no(script|embed|frames)/i,e.innerHTML)?(Me&&e.nodeType===ae&&(t=e.textContent,_([fe,me,ye],(e=>{t=E(t,e," ")})),e.textContent!==t&&(C(n.removed,{element:e.cloneNode()}),e.textContent=t)),Tt(pe.afterSanitizeElements,e,null),!1):(xt(e),!0)},Nt=function(e,t,n){if(We&&("id"===t||"name"===t)&&(n in r||n in ft))return!1;if(Re&&!Le[t]&&O(be,t));else if(Fe&&O(_e,t));else if(Oe.attributeCheck instanceof Function&&Oe.attributeCheck(t,e));else if(!Te[t]||Le[t]){if(!(At(e)&&(Ne.tagNameCheck instanceof RegExp&&O(Ne.tagNameCheck,e)||Ne.tagNameCheck instanceof Function&&Ne.tagNameCheck(e))&&(Ne.attributeNameCheck instanceof RegExp&&O(Ne.attributeNameCheck,t)||Ne.attributeNameCheck instanceof Function&&Ne.attributeNameCheck(t,e))||"is"===t&&Ne.allowCustomizedBuiltInElements&&(Ne.tagNameCheck instanceof RegExp&&O(Ne.tagNameCheck,n)||Ne.tagNameCheck instanceof Function&&Ne.tagNameCheck(n))))return!1}else if(Qe[t]);else if(O(ve,E(n,Se,"")));else if("src"!==t&&"xlink:href"!==t&&"href"!==t||"script"===e||0!==N(n,"data:")||!Ye[e]){if(Ie&&!O(xe,E(n,Se,"")));else if(n)return!1}else;return!0},At=function(e){return"annotation-xml"!==e&&T(e,Ce)},Lt=function(e){Tt(pe.beforeSanitizeAttributes,e,null);const{attributes:t}=e;if(!t||wt(e))return;const r={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:Te,forceKeepAttr:void 0};let i=t.length;for(;i--;){const o=t[i],{name:s,namespaceURI:l,value:a}=o,c=gt(s),u=a;let d="value"===s?u:A(u);if(r.attrName=c,r.attrValue=d,r.keepAttr=!0,r.forceKeepAttr=void 0,Tt(pe.uponSanitizeAttribute,e,r),d=r.attrValue,!Ve||"id"!==c&&"name"!==c||(St(s,e),d="user-content-"+d),De&&O(/((--!?|])>)|<\/(style|title|textarea)/i,d)){St(s,e);continue}if("attributename"===c&&T(d,"href")){St(s,e);continue}if(r.forceKeepAttr)continue;if(!r.keepAttr){St(s,e);continue}if(!Pe&&O(/\/>/i,d)){St(s,e);continue}Me&&_([fe,me,ye],(e=>{d=E(d,e," ")}));const h=gt(e.nodeName);if(Nt(h,c,d)){if(X&&"object"==typeof y&&"function"==typeof y.getAttributeType)if(l);else switch(y.getAttributeType(h,c)){case"TrustedHTML":d=X.createHTML(d);break;case"TrustedScriptURL":d=X.createScriptURL(d)}if(d!==u)try{l?e.setAttributeNS(l,s,d):e.setAttribute(s,d),wt(e)?xt(e):S(n.removed)}catch(t){St(s,e)}}else St(s,e)}Tt(pe.afterSanitizeAttributes,e,null)},Ot=function e(t){let n=null;const r=vt(t);for(Tt(pe.beforeSanitizeShadowDOM,t,null);n=r.nextNode();)Tt(pe.uponSanitizeShadowNode,n,null),Et(n),Lt(n),n.content instanceof s&&e(n.content);Tt(pe.afterSanitizeShadowDOM,t,null)};return n.sanitize=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=null,o=null,l=null,c=null;if(ot=!e,ot&&(e="\x3c!--\x3e"),"string"!=typeof e&&!kt(e)){if("function"!=typeof e.toString)throw F("toString is not a function");if("string"!=typeof(e=e.toString()))throw F("dirty is not a string, aborting")}if(!n.isSupported)return e;if(ze||yt(t),n.removed=[],"string"==typeof e&&(je=!1),je){if(e.nodeName){const t=gt(e.nodeName);if(!we[t]||Ae[t])throw F("root node is forbidden and cannot be sanitized in-place")}}else if(e instanceof a)r=Ct("\x3c!----\x3e"),o=r.ownerDocument.importNode(e,!0),o.nodeType===le&&"BODY"===o.nodeName||"HTML"===o.nodeName?r=o:r.appendChild(o);else{if(!He&&!Me&&!Be&&-1===e.indexOf("<"))return X&&Ue?X.createHTML(e):e;if(r=Ct(e),!r)return He?null:Ue?Q:""}r&&$e&&xt(r.firstChild);const u=vt(je?e:r);for(;l=u.nextNode();)Et(l),Lt(l),l.content instanceof s&&Ot(l.content);if(je)return e;if(He){if(Ke)for(c=re.call(r.ownerDocument);r.firstChild;)c.appendChild(r.firstChild);else c=r;return(Te.shadowroot||Te.shadowrootmode)&&(c=ge.call(i,c,!0)),c}let d=Be?r.outerHTML:r.innerHTML;return Be&&we["!doctype"]&&r.ownerDocument&&r.ownerDocument.doctype&&r.ownerDocument.doctype.name&&O(ie,r.ownerDocument.doctype.name)&&(d="\n"+d),Me&&_([fe,me,ye],(e=>{d=E(d,e," ")})),X&&Ue?X.createHTML(d):d},n.setConfig=function(){yt(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),ze=!0},n.clearConfig=function(){pt=null,ze=!1},n.isValidAttribute=function(e,t,n){pt||yt({});const r=gt(e),i=gt(t);return Nt(r,i,n)},n.addHook=function(e,t){"function"==typeof t&&C(pe[e],t)},n.removeHook=function(e,t){if(void 0!==t){const n=x(pe[e],t);return-1===n?void 0:v(pe[e],n,1)[0]}return S(pe[e])},n.removeHooks=function(e){pe[e]=[]},n.removeAllHooks=function(){pe={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},n}();function pe(e,...t){const n=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",e);for(const e of t)r.append("v",e);throw n.search=r.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function fe(e,...t){const n=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",e);for(const e of t)r.append("v",e);n.search=r.toString(),console.warn(`Minified Lexical warning #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}const me="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,ye=me&&"documentMode"in document?document.documentMode:null,be=me&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),_e=me&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),xe=!(!me||!("InputEvent"in window)||ye)&&"getTargetRanges"in new window.InputEvent("input"),Se=me&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),Ce=me&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,ve=me&&/Android/.test(navigator.userAgent),we=me&&/^(?=.*Chrome).*/i.test(navigator.userAgent),ke=me&&ve&&we,Te=me&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&be&&!we;function Ee(...e){const t=[];for(const n of e)if(n&&"string"==typeof n)for(const[e]of n.matchAll(/\S+/g))t.push(e);return t}const Ne=0,Ae=1,Le=2,Oe=1,Fe=2,Re=3,Ie=4,Pe=5,Me=6,De=Se||Ce||Te?" ":"​",Be="\n\n",ze=_e?" ":De,$e="֑-߿יִ-﷽ﹰ-ﻼ",He="A-Za-zÀ-ÖØ-öø-ʸ̀-֐ࠀ-῿‎Ⰰ-﬜︀-﹯﻽-￿",Ke=new RegExp("^[^"+He+"]*["+$e+"]"),Ue=new RegExp("^[^"+$e+"]*["+He+"]"),We={bold:1,capitalize:1024,code:16,highlight:128,italic:2,lowercase:256,strikethrough:4,subscript:32,superscript:64,underline:8,uppercase:512},Ve={directionless:1,unmergeable:2},qe={center:2,end:6,justify:4,left:1,right:3,start:5},je={[Fe]:"center",[Me]:"end",[Ie]:"justify",[Oe]:"left",[Re]:"right",[Pe]:"start"},Ze={normal:0,segmented:2,token:1},Ge={[Ne]:"normal",[Le]:"segmented",[Ae]:"token"},Je="$config";function Ye(e,t,n,r,i,o){let s=e.getFirstChild();for(;null!==s;){const e=s.__key;s.__parent===t&&(po(s)&&Ye(s,e,n,r,i,o),n.has(e)||o.delete(e),i.push(e)),s=s.getNextSibling()}}let Xe=!1,Qe=0;function et(e){Qe=e.timeStamp}function tt(e,t,n){const r="BR"===e.nodeName,i=t.__lexicalLineBreak;return i&&(e===i||r&&e.previousSibling===i)||r&&void 0!==ss(e,n)}function nt(e,t,n){const r=Zs($s(n));let i=null,o=null;null!==r&&r.anchorNode===e&&(i=r.anchorOffset,o=r.focusOffset);const s=e.nodeValue;null!==s&&_s(t,s,i,o,!1)}function rt(e,t,n){if(gi(e)){const t=e.anchor.getNode();if(t.is(n)&&e.format!==t.getFormat())return!1}return Zo(t)&&n.isAttached()}function it(e,t,n,r){for(let i=e;i&&!al(i);i=Ps(i)){const e=ss(i,t);if(void 0!==e){const t=is(e,n);if(t)return yo(t)||!Js(i)?void 0:[i,t]}else if(i===r)return[r,ds(n)]}}function ot(e,t,n){Xe=!0;const r=performance.now()-Qe>100;try{co(e,(()=>{const i=Li()||function(e){return e.getEditorState().read((()=>{const e=Li();return null!==e?e.clone():null}))}(e),o=new Map,s=e.getRootElement(),l=e._editorState,a=e._blockCursorElement;let c=!1,u="";for(let n=0;n0){let t=0;for(let i=0;i0)for(const[t,n]of o)n.reconcileObservedMutation(t,e);const d=n.takeRecords();if(d.length>0){for(let t=0;t{ot(e,t,n)}))}let at=class{key;parse;unparse;isEqual;defaultValue;constructor(e,t){this.key=e,this.parse=t.parse.bind(t),this.unparse=(t.unparse||mt).bind(t),this.isEqual=(t.isEqual||Object.is).bind(t),this.defaultValue=this.parse(void 0)}};function ct(e,t,n="latest"){const r=("latest"===n?e.getLatest():e).__state;return r?r.getValue(t):t.defaultValue}function ut(e,t,n){let r;if(Zi(),"function"==typeof n){const i=e.getLatest(),o=ct(i,t);if(r=n(o),t.isEqual(o,r))return i}else r=n;const i=e.getWritable();return gt(i).updateFromKnown(t,r),i}function dt(e){const t=new Map,n=new Set;for(let r="function"==typeof e?e:e.replace;r.prototype&&void 0!==r.prototype.getType;r=Object.getPrototypeOf(r)){const{ownNodeConfig:e}=ul(r);if(e&&e.stateConfigs)for(const r of e.stateConfigs){let e;"stateConfig"in r?(e=r.stateConfig,r.flat&&n.add(e.key)):e=r,t.set(e.key,e)}}return{flatKeys:n,sharedConfigMap:t}}let ht=class e{node;knownState;unknownState;sharedNodeState;size;constructor(e,t,n=void 0,r=new Map,i=void 0){this.node=e,this.sharedNodeState=t,this.unknownState=n,this.knownState=r;const{sharedConfigMap:o}=this.sharedNodeState,s=void 0!==i?i:function(e,t,n){let r=n.size;if(t)for(const i in t){const t=e.get(i);t&&n.has(t)||r++}return r}(o,n,r);this.size=s}getValue(e){const t=this.knownState.get(e);if(void 0!==t)return t;this.sharedNodeState.sharedConfigMap.set(e.key,e);let n=e.defaultValue;if(this.unknownState&&e.key in this.unknownState){const t=this.unknownState[e.key];void 0!==t&&(n=e.parse(t)),this.updateFromKnown(e,n)}return n}getInternalState(){return[this.unknownState,this.knownState]}toJSON(){const e={...this.unknownState},t={};for(const[t,n]of this.knownState)t.isEqual(n,t.defaultValue)?delete e[t.key]:e[t.key]=t.unparse(n);for(const n of this.sharedNodeState.flatKeys)n in e&&(t[n]=e[n],delete e[n]);return ft(e)&&(t.$=e),t}getWritable(t){if(this.node===t)return this;const{sharedNodeState:n,unknownState:r}=this,i=new Map(this.knownState);return new e(t,n,function(e,t,n){let r;if(n)for(const[i,o]of Object.entries(n)){const n=e.get(i);n?t.has(n)||t.set(n,n.parse(o)):(r=r||{},r[i]=o)}return r}(n.sharedConfigMap,i,r),i,this.size)}updateFromKnown(e,t){const n=e.key;this.sharedNodeState.sharedConfigMap.set(n,e);const{knownState:r,unknownState:i}=this;r.has(e)||i&&n in i||(i&&(delete i[n],this.unknownState=ft(i)),this.size++),r.set(e,t)}updateFromUnknown(e,t){const n=this.sharedNodeState.sharedConfigMap.get(e);n?this.updateFromKnown(n,n.parse(t)):(this.unknownState=this.unknownState||{},e in this.unknownState||this.size++,this.unknownState[e]=t)}updateFromJSON(e){const{knownState:t}=this;for(const e of t.keys())t.set(e,e.defaultValue);if(this.size=t.size,this.unknownState=void 0,e)for(const[t,n]of Object.entries(e))this.updateFromUnknown(t,n)}};function gt(e){const t=e.getWritable(),n=t.__state?t.__state.getWritable(t):new ht(t,pt(t));return t.__state=n,n}function pt(e){return e.__state?e.__state.sharedNodeState:Mo(nl(),e.getType()).sharedNodeState}function ft(e){if(e)for(const t in e)return e}function mt(e){return e}function yt(e,t,n){for(const[r,i]of t.knownState){if(e.has(r.key))continue;e.add(r.key);const t=n?n.getValue(r):r.defaultValue;if(t!==i&&!r.isEqual(t,i))return!0}return!1}function bt(e,t,n){const{unknownState:r}=t,i=n?n.unknownState:void 0;if(r)for(const[t,n]of Object.entries(r))if(!e.has(t)&&(e.add(t),n!==(i?i[t]:void 0)))return!0;return!1}function _t(e,t){const n=e.__state;return n&&n.node===e?n.getWritable(t):n}function xt(e,t){const n=e.__mode,r=e.__format,i=e.__style,o=t.__mode,s=t.__format,l=t.__style,a=e.__state,c=t.__state;return(null===n||n===o)&&(null===r||r===s)&&(null===i||i===l)&&(null===e.__state||a===c||function(e,t){if(e===t)return!0;if(e&&t&&e.size!==t.size)return!1;const n=new Set;return!(e&&yt(n,e,t)||t&&yt(n,t,e)||e&&bt(n,e,t)||t&&bt(n,t,e))}(a,c))}function St(e,t){const n=e.mergeWithSibling(t),r=Yi()._normalizedNodes;return r.add(e.__key),r.add(t.__key),n}function Ct(e){let t,n,r=e;if(""!==r.__text||!r.isSimpleText()||r.isUnmergeable()){for(;null!==(t=r.getPreviousSibling())&&ri(t)&&t.isSimpleText()&&!t.isUnmergeable();){if(""!==t.__text){if(xt(t,r)){r=St(t,r);break}break}t.remove()}for(;null!==(n=r.getNextSibling())&&ri(n)&&n.isSimpleText()&&!n.isUnmergeable();){if(""!==n.__text){if(xt(r,n)){r=St(r,n);break}break}n.remove()}}else r.remove()}function vt(e){return wt(e.anchor),wt(e.focus),e}function wt(e){for(;"element"===e.type;){const t=e.getNode(),n=e.offset;let r,i;if(n===t.getChildrenSize()?(r=t.getChildAtIndex(n-1),i=!0):(r=t.getChildAtIndex(n),i=!1),ri(r)){e.set(r.__key,i?r.getTextContentSize():0,"text",!0);break}if(!po(r))break;e.set(r.__key,i?r.getChildrenSize():0,"element",!0)}}let kt,Tt,Et,Nt,At,Lt,Ot,Ft,Rt,It,Pt="",Mt=null,Dt="",Bt="",zt=!1,$t=!1;function Ht(e,t){const n=Ot.get(e);if(null!==t){const n=rn(e);n.parentNode===t&&t.removeChild(n)}if(Ft.has(e)||Tt._keyToDOMMap.delete(e),po(n)){const e=Qt(n,Ot);Kt(e,0,e.length-1,null)}void 0!==n&&Ns(It,Et,Nt,n,"destroyed")}function Kt(e,t,n,r){let i=t;for(;i<=n;++i){const t=e[i];void 0!==t&&Ht(t,r)}}function Ut(e,t){e.setProperty("text-align",t)}const Wt="40px";function Vt(e,t){const n=kt.theme.indent;if("string"==typeof n){const r=e.classList.contains(n);t>0&&!r?e.classList.add(n):t<1&&r&&e.classList.remove(n)}const r=getComputedStyle(e).getPropertyValue("--lexical-indent-base-value")||Wt;e.style.setProperty("padding-inline-start",0===t?"":`calc(${t} * ${r})`)}function qt(e,t){const n=e.style;0===t?Ut(n,""):1===t?Ut(n,"left"):2===t?Ut(n,"center"):3===t?Ut(n,"right"):4===t?Ut(n,"justify"):5===t?Ut(n,"start"):6===t&&Ut(n,"end")}function jt(e,t){const n=function(e){const t=e.__dir;if(null!==t)return t;if(_o(e))return null;const n=e.getParentOrThrow();return _o(n)&&null===n.__dir?"auto":null}(t);null!==n?e.dir=n:e.removeAttribute("dir")}function Zt(e,t){const n=Ft.get(e);void 0===n&&pe(60);const r=n.createDOM(kt,Tt);if(function(e,t,n){const r=n._keyToDOMMap;(function(e,t,n){e[`__lexicalKey_${t._key}`]=n})(t,n,e),r.set(e,t)}(e,r,Tt),ri(n)?r.setAttribute("data-lexical-text","true"):yo(n)&&r.setAttribute("data-lexical-decorator","true"),po(n)){const e=n.__indent,t=n.__size;if(jt(r,n),0!==e&&Vt(r,e),0!==t){const e=t-1;Gt(Qt(n,Ft),n,0,e,n.getDOMSlot(r))}const i=n.__format;0!==i&&qt(r,i),n.isInline()||Yt(null,n,r),Rs(n)&&(Pt+=Be,Bt+=Be)}else{const t=n.getTextContent();if(yo(n)){const t=n.decorate(Tt,kt);null!==t&&tn(e,t),r.contentEditable="false"}Pt+=t,Bt+=t}return null!==t&&t.insertChild(r),Ns(It,Et,Nt,n,"created"),r}function Gt(e,t,n,r,i){const o=Pt;Pt="";let s=n;for(;s<=r;++s){Zt(e[s],i);const t=Ft.get(e[s]);null!==t&&ri(t)&&(null===Mt&&(Mt=t.getFormat()),""===Dt&&(Dt=t.getStyle()))}Rs(t)&&(Pt+=Be),i.element.__lexicalTextContent=Pt,Pt=o+Pt}function Jt(e,t){if(e){const n=e.__last;if(n){const e=t.get(n);if(e)return zr(e)?"line-break":yo(e)&&e.isInline()?"decorator":null}return"empty"}return null}function Yt(e,t,n){const r=Jt(e,Ot),i=Jt(t,Ft);r!==i&&t.getDOMSlot(n).setManagedLineBreak(i)}function Xt(e,t,n){var r;Mt=null,Dt="",function(e,t,n){const r=Pt,i=e.__size,o=t.__size;Pt="";const s=n.element;if(1===i&&1===o){const n=e.__first,i=t.__first;if(n===i)en(n,s);else{const e=rn(n),t=Zt(i,null);try{s.replaceChild(t,e)}catch(r){if("object"==typeof r&&null!=r){const o=`${r.toString()} Parent: ${s.tagName}, new child: {tag: ${t.tagName} key: ${i}}, old child: {tag: ${e.tagName}, key: ${n}}.`;throw new Error(o)}throw r}Ht(n,null)}const o=Ft.get(i);ri(o)&&(null===Mt&&(Mt=o.getFormat()),""===Dt&&(Dt=o.getStyle()))}else{const r=Qt(e,Ot),l=Qt(t,Ft);if(r.length!==i&&pe(227),l.length!==o&&pe(228),0===i)0!==o&&Gt(l,t,0,o-1,n);else if(0===o){if(0!==i){const e=null==n.after&&null==n.before&&null==n.element.__lexicalLineBreak;Kt(r,0,i-1,e?null:s),e&&(s.textContent="")}}else!function(e,t,n,r,i,o){const s=r-1,l=i-1;let a,c,u=o.getFirstChild(),d=0,h=0;for(;d<=s&&h<=l;){const e=t[d],r=n[h];if(e===r)u=nn(en(r,o.element)),d++,h++;else{void 0===a&&(a=new Set(t)),void 0===c&&(c=new Set(n));const i=c.has(e),s=a.has(r);if(i)if(s){const e=Is(Tt,r);e===u?u=nn(en(r,o.element)):(o.withBefore(u).insertChild(e),en(r,o.element)),d++,h++}else Zt(r,o.withBefore(u)),h++;else u=nn(rn(e)),Ht(e,o.element),d++}const i=Ft.get(r);null!==i&&ri(i)&&(null===Mt&&(Mt=i.getFormat()),""===Dt&&(Dt=i.getStyle()))}const g=d>s,p=h>l;if(g&&!p){const t=n[l+1],r=void 0===t?null:Tt.getElementByKey(t);Gt(n,e,h,l,o.withBefore(r))}else p&&!g&&Kt(t,d,s,o.element)}(t,r,l,i,o,n)}Rs(t)&&(Pt+=Be),s.__lexicalTextContent=Pt,Pt=r+Pt}(e,t,t.getDOMSlot(n)),r=t,null==Mt||Mt===r.__textFormat||$t||r.setTextFormat(Mt),function(e){""===Dt||Dt===e.__textStyle||$t||e.setTextStyle(Dt)}(t)}function Qt(e,t){const n=[];let r=e.__first;for(;null!==r;){const e=t.get(r);void 0===e&&pe(101),n.push(r),r=e.__next}return n}function en(e,t){const n=Ot.get(e);let r=Ft.get(e);void 0!==n&&void 0!==r||pe(61);const i=zt||Lt.has(e)||At.has(e),o=Is(Tt,e);if(n===r&&!i){if(po(n)){const e=o.__lexicalTextContent;void 0!==e&&(Pt+=e,Bt+=e)}else{const e=n.getTextContent();Bt+=e,Pt+=e}return o}if(n!==r&&i&&Ns(It,Et,Nt,r,"updated"),r.updateDOM(n,o,kt)){const n=Zt(e,null);return null===t&&pe(62),t.replaceChild(n,o),Ht(e,null),n}if(po(n)&&po(r)){const e=r.__indent;(zt||e!==n.__indent)&&Vt(o,e);const t=r.__format;if((zt||t!==n.__format)&&qt(o,t),i&&(Xt(n,r,o),_o(r)||r.isInline()||Yt(n,r,o)),Rs(r)&&(Pt+=Be,Bt+=Be),(zt||r.__dir!==n.__dir)&&(jt(o,r),_o(r)&&!zt))for(const e of r.getChildren())po(e)&&jt(Is(Tt,e.getKey()),e)}else{const t=r.getTextContent();if(yo(r)){const t=r.decorate(Tt,kt);null!==t&&tn(e,t)}Pt+=t,Bt+=t}if(!$t&&_o(r)&&r.__cachedText!==Bt){const e=r.getWritable();e.__cachedText=Bt,r=e}return o}function tn(e,t){let n=Tt._pendingDecorators;const r=Tt._decorators;if(null===n){if(r[e]===t)return;n=as(Tt)}n[e]=t}function nn(e){let t=e.nextSibling;return null!==t&&t===Tt._blockCursorElement&&(t=t.nextSibling),t}function rn(e){const t=Rt.get(e);return void 0===t&&pe(75,e),t}function on(e){return{type:e}}const sn=on("SELECTION_CHANGE_COMMAND"),ln=on("SELECTION_INSERT_CLIPBOARD_NODES_COMMAND"),an=on("CLICK_COMMAND"),cn=on("DELETE_CHARACTER_COMMAND"),un=on("INSERT_LINE_BREAK_COMMAND"),dn=on("INSERT_PARAGRAPH_COMMAND"),hn=on("CONTROLLED_TEXT_INSERTION_COMMAND"),gn=on("PASTE_COMMAND"),pn=on("REMOVE_TEXT_COMMAND"),fn=on("DELETE_WORD_COMMAND"),mn=on("DELETE_LINE_COMMAND"),yn=on("FORMAT_TEXT_COMMAND"),bn=on("UNDO_COMMAND"),_n=on("REDO_COMMAND"),xn=on("KEYDOWN_COMMAND"),Sn=on("KEY_ARROW_RIGHT_COMMAND"),Cn=on("MOVE_TO_END"),vn=on("KEY_ARROW_LEFT_COMMAND"),wn=on("MOVE_TO_START"),kn=on("KEY_ARROW_UP_COMMAND"),Tn=on("KEY_ARROW_DOWN_COMMAND"),En=on("KEY_ENTER_COMMAND"),Nn=on("KEY_SPACE_COMMAND"),An=on("KEY_BACKSPACE_COMMAND"),Ln=on("KEY_ESCAPE_COMMAND"),On=on("KEY_DELETE_COMMAND"),Fn=on("KEY_TAB_COMMAND"),Rn=on("INSERT_TAB_COMMAND"),In=on("INDENT_CONTENT_COMMAND"),Pn=on("OUTDENT_CONTENT_COMMAND"),Mn=on("DROP_COMMAND"),Dn=on("FORMAT_ELEMENT_COMMAND"),Bn=on("DRAGSTART_COMMAND"),zn=on("DRAGOVER_COMMAND"),$n=on("DRAGEND_COMMAND"),Hn=on("COPY_COMMAND"),Kn=on("CUT_COMMAND"),Un=on("SELECT_ALL_COMMAND"),Wn=on("CLEAR_EDITOR_COMMAND"),Vn=on("CLEAR_HISTORY_COMMAND"),qn=on("CAN_REDO_COMMAND"),jn=on("CAN_UNDO_COMMAND"),Zn=on("FOCUS_COMMAND"),Gn=on("BLUR_COMMAND"),Jn=on("KEY_MODIFIER_COMMAND"),Yn=Object.freeze({}),Xn=[["keydown",function(e,t){if(!(Qn=e.timeStamp,er=e.key,t.isComposing()||Fs(t,xn,e)||null==e.key)){if(cr&&ks(e))return co(t,(()=>{_r(t,ur)})),cr=!1,void(ur="");if(function(e){return Cs(e,"ArrowRight",{shiftKey:"any"})}(e))Fs(t,Sn,e);else if(function(e){return Cs(e,"ArrowRight",vs)}(e))Fs(t,Cn,e);else if(function(e){return Cs(e,"ArrowLeft",{shiftKey:"any"})}(e))Fs(t,vn,e);else if(function(e){return Cs(e,"ArrowLeft",vs)}(e))Fs(t,wn,e);else if(function(e){return Cs(e,"ArrowUp",{altKey:"any",shiftKey:"any"})}(e))Fs(t,kn,e);else if(function(e){return Cs(e,"ArrowDown",{altKey:"any",shiftKey:"any"})}(e))Fs(t,Tn,e);else if(function(e){return Cs(e,"Enter",{altKey:"any",ctrlKey:"any",metaKey:"any",shiftKey:!0})}(e))lr=!0,Fs(t,En,e);else if(function(e){return" "===e.key}(e))Fs(t,Nn,e);else if(function(e){return be&&Cs(e,"o",{ctrlKey:!0})}(e))e.preventDefault(),lr=!0,Fs(t,un,!0);else if(function(e){return Cs(e,"Enter",{altKey:"any",ctrlKey:"any",metaKey:"any"})}(e))lr=!1,Fs(t,En,e);else if(function(e){return Cs(e,"Backspace",{shiftKey:"any"})||be&&Cs(e,"h",{ctrlKey:!0})}(e))ks(e)?Fs(t,An,e):(e.preventDefault(),Fs(t,cn,!0));else if(function(e){return"Escape"===e.key}(e))Fs(t,Ln,e);else if(function(e){return Cs(e,"Delete",{})||be&&Cs(e,"d",{ctrlKey:!0})}(e))!function(e){return"Delete"===e.key}(e)?(e.preventDefault(),Fs(t,cn,!1)):Fs(t,On,e);else if(function(e){return Cs(e,"Backspace",ws)}(e))e.preventDefault(),Fs(t,fn,!0);else if(function(e){return Cs(e,"Delete",ws)}(e))e.preventDefault(),Fs(t,fn,!1);else if(function(e){return be&&Cs(e,"Backspace",{metaKey:!0})}(e))e.preventDefault(),Fs(t,mn,!0);else if(function(e){return be&&(Cs(e,"Delete",{metaKey:!0})||Cs(e,"k",{ctrlKey:!0}))}(e))e.preventDefault(),Fs(t,mn,!1);else if(function(e){return Cs(e,"b",vs)}(e))e.preventDefault(),Fs(t,yn,"bold");else if(function(e){return Cs(e,"u",vs)}(e))e.preventDefault(),Fs(t,yn,"underline");else if(function(e){return Cs(e,"i",vs)}(e))e.preventDefault(),Fs(t,yn,"italic");else if(function(e){return Cs(e,"Tab",{shiftKey:"any"})}(e))Fs(t,Fn,e);else if(function(e){return Cs(e,"z",vs)}(e))e.preventDefault(),Fs(t,bn,void 0);else if(function(e){return be?Cs(e,"z",{metaKey:!0,shiftKey:!0}):Cs(e,"y",{ctrlKey:!0})||Cs(e,"z",{ctrlKey:!0,shiftKey:!0})}(e))e.preventDefault(),Fs(t,_n,void 0);else{const n=t._editorState._selection;null===n||gi(n)?Ts(e)&&(e.preventDefault(),Fs(t,Un,e)):function(e){return Cs(e,"c",vs)}(e)?(e.preventDefault(),Fs(t,Hn,e)):function(e){return Cs(e,"x",vs)}(e)?(e.preventDefault(),Fs(t,Kn,e)):Ts(e)&&(e.preventDefault(),Fs(t,Un,e))}(function(e){return e.ctrlKey||e.shiftKey||e.altKey||e.metaKey})(e)&&Fs(t,Jn,e)}}],["pointerdown",function(e,t){const n=e.target,r=e.pointerType;Ys(n)&&"touch"!==r&&"pen"!==r&&0===e.button&&co(t,(()=>{zo(n)||(sr=!0)}))}],["compositionstart",function(e,t){co(t,(()=>{const n=Li();if(gi(n)&&!t.isComposing()){const r=n.anchor,i=n.anchor.getNode();ns(r.key),(e.timeStamp{_r(t,e.data)})):(cr=!0,ur=e.data)}],["input",function(e,t){e.stopPropagation(),co(t,(()=>{if(Js(e.target)&&zo(e.target))return;const n=Li(),r=e.data,i=br(e);if(null!=r&&gi(n)&&gr(n,i,r,e.timeStamp,!1)){ar&&(_r(t,r),ar=!1);const i=n.anchor.getNode(),o=Zs($s(t));if(null===o)return;const s=n.isBackward(),l=s?n.anchor.offset:n.focus.offset,a=s?n.focus.offset:n.anchor.offset;xe&&!n.isCollapsed()&&ri(i)&&null!==o.anchorNode&&i.getTextContent().slice(0,l)+r+i.getTextContent().slice(l+a)===ys(o.anchorNode)||Fs(t,hn,r);const c=r.length;_e&&c>1&&"insertCompositionText"===e.inputType&&!t.isComposing()&&(n.anchor.offset-=c),Se||Ce||Te||!t.isComposing()||(Qn=0,ns(null))}else bs(!1,t,null!==r?r:void 0),ar&&(_r(t,r||void 0),ar=!1);!function(){Zi();st(Yi())}()}),{event:e}),nr=null}],["click",function(e,t){co(t,(()=>{const n=Li(),r=Zs($s(t)),i=Oi();if(r)if(gi(n)){const t=n.anchor,o=t.getNode();if("element"===t.type&&0===t.offset&&n.isCollapsed()&&!_o(o)&&1===us().getChildrenSize()&&o.getTopLevelElementOrThrow().isEmpty()&&null!==i&&n.is(i))r.removeAllRanges(),n.dirty=!0;else if(3===e.detail&&!n.isCollapsed()&&o!==n.focus.getNode()){const e=dl(o,(e=>po(e)&&!e.isInline()));po(e)&&e.select(0)}}else if("touch"===e.pointerType||"pen"===e.pointerType){const n=r.anchorNode;(Js(n)||Zo(n))&&hs(Ai(i,r,t,e))}Fs(t,an,e)}))}],["cut",Yn],["copy",Yn],["dragstart",Yn],["dragover",Yn],["dragend",Yn],["paste",Yn],["focus",Yn],["blur",Yn],["drop",Yn]];xe&&Xn.push(["beforeinput",(e,t)=>function(e,t){const n=e.inputType,r=br(e);"deleteCompositionText"===n||_e&&Os(t)||"insertCompositionText"!==n&&co(t,(()=>{const i=Li();if("deleteContentBackward"===n){if(null===i){const e=Oi();if(!gi(e))return;hs(e.clone())}if(gi(i)){const n=i.anchor.key===i.focus.key;if(o=e.timeStamp,"MediaLast"===er&&o{co(t,(()=>{ns(null)}))}),30),gi(i)){const e=i.anchor.getNode();e.markDirty(),ri(e)||pe(142),yr(i,e)}}else{ns(null),e.preventDefault();const r=i.anchor.getNode(),o=r.getTextContent(),s=r.canInsertTextAfter(),l=0===i.anchor.offset&&i.focus.offset===o.length;let a=ke&&n&&!l&&s;if(a&&i.isCollapsed()&&(a=!yo(Ls(i.anchor,!0))),!a){Fs(t,cn,!0);const e=Li();ke&&gi(e)&&e.isCollapsed()&&(dr=e,setTimeout((()=>dr=null)))}}return}}var o;if(!gi(i))return;const s=e.data;null!==nr&&bs(!1,t,nr),i.dirty&&null===nr||!i.isCollapsed()||_o(i.anchor.getNode())||null===r||i.applyDOMRange(r),nr=null;const l=i.anchor,a=i.focus,c=l.getNode(),u=a.getNode();if("insertText"!==n&&"insertTranspose"!==n)switch(e.preventDefault(),n){case"insertFromYank":case"insertFromDrop":case"insertReplacementText":Fs(t,hn,e);break;case"insertFromComposition":ns(null),Fs(t,hn,e);break;case"insertLineBreak":ns(null),Fs(t,un,!1);break;case"insertParagraph":ns(null),lr&&!Ce?(lr=!1,Fs(t,un,!1)):Fs(t,dn,void 0);break;case"insertFromPaste":case"insertFromPasteAsQuotation":Fs(t,gn,e);break;case"deleteByComposition":(function(e,t){return e!==t||po(e)||po(t)||!qo(e)||!qo(t)})(c,u)&&Fs(t,pn,e);break;case"deleteByDrag":case"deleteByCut":Fs(t,pn,e);break;case"deleteContent":Fs(t,cn,!1);break;case"deleteWordBackward":Fs(t,fn,!0);break;case"deleteWordForward":Fs(t,fn,!1);break;case"deleteHardLineBackward":case"deleteSoftLineBackward":Fs(t,mn,!0);break;case"deleteContentForward":case"deleteHardLineForward":case"deleteSoftLineForward":Fs(t,mn,!1);break;case"formatStrikeThrough":Fs(t,yn,"strikethrough");break;case"formatBold":Fs(t,yn,"bold");break;case"formatItalic":Fs(t,yn,"italic");break;case"formatUnderline":Fs(t,yn,"underline");break;case"historyUndo":Fs(t,bn,void 0);break;case"historyRedo":Fs(t,_n,void 0)}else{if("\n"===s)e.preventDefault(),Fs(t,un,!1);else if(s===Be)e.preventDefault(),Fs(t,dn,void 0);else if(null==s&&e.dataTransfer){const t=e.dataTransfer.getData("text/plain");e.preventDefault(),i.insertRawText(t)}else null!=s&&gr(i,r,s,e.timeStamp,!0)?(e.preventDefault(),Fs(t,hn,s)):nr=s;tr=e.timeStamp}}))}(e,t)]);let Qn=0,er=null,tr=0,nr=null;const rr=new WeakMap,ir=new WeakMap;let or=!1,sr=!1,lr=!1,ar=!1,cr=!1,ur="",dr=null,hr=[0,"",0,"root",0];function gr(e,t,n,r,i){const o=e.anchor,s=e.focus,l=o.getNode(),a=Yi(),c=Zs($s(a)),u=null!==c?c.anchorNode:null,d=o.key,h=a.getElementByKey(d),g=n.length;return d!==s.key||!ri(l)||(!i&&(!xe||tr1||(i||!xe)&&null!==h&&!l.isComposing()&&u!==Jo(h)||null!==c&&null!==t&&(!t.collapsed||t.startContainer!==c.anchorNode||t.startOffset!==c.anchorOffset)||l.getFormat()!==e.format||l.getStyle()!==e.style||function(e,t){if(t.isSegmented())return!0;if(!e.isCollapsed())return!1;const n=e.anchor.offset,r=t.getParentOrThrow(),i=qo(t);return 0===n?!t.canInsertTextBefore()||!r.canInsertTextBefore()&&!t.isComposing()||i||function(e){const t=e.getPreviousSibling();return(ri(t)||po(t)&&t.isInline())&&!t.canInsertTextAfter()}(t):n===t.getTextContentSize()&&(!t.canInsertTextAfter()||!r.canInsertTextAfter()&&!t.isComposing()||i)}(e,l)}function pr(e,t){return Zo(e)&&null!==e.nodeValue&&0!==t&&t!==e.nodeValue.length}function fr(e,t,n){const{anchorNode:r,anchorOffset:i,focusNode:o,focusOffset:s}=e;or&&(or=!1,pr(r,i)&&pr(o,s)&&!dr)||co(t,(()=>{if(!n)return void hs(null);if(!Ho(t,r,o))return;let l=Li();if(dr&&gi(l)&&l.isCollapsed()){const e=l.anchor,t=dr.anchor;(e.key===t.key&&e.offset===t.offset+1||1===e.offset&&t.getNode().is(e.getNode().getPreviousSibling()))&&(l=dr.clone(),hs(l))}if(dr=null,gi(l)){const n=l.anchor,r=n.getNode();if(l.isCollapsed()){"Range"===e.type&&e.anchorNode===e.focusNode&&(l.dirty=!0);const i=$s(t).event,o=i?i.timeStamp:performance.now(),[s,a,c,u,d]=hr,h=us(),g=!1===t.isComposing()&&""===h.getTextContent();if(o{const r=Oi(),i=t.anchorNode;(Js(i)||Zo(i))&&hs(Ai(r,t,n,e))})));const r=fs(n),i=r[r.length-1],o=i._key,s=Sr.get(o),l=s||i;l!==n&&fr(t,l,!1),fr(t,n,!0),n!==i?Sr.set(o,n):s&&Sr.delete(o)}function vr(e){e._lexicalHandled=!0}function wr(e){return!0===e._lexicalHandled}function kr(e){const t=rr.get(e);if(void 0===t)return;const n=ir.get(t);if(void 0===n)return;const r=n-1;r>=0||pe(164),rr.delete(e),ir.set(t,r),0===r&&t.removeEventListener("selectionchange",Cr);const i=Wo(e);Ko(i)?(function(e){if(null!==e._parentEditor){const t=fs(e),n=t[t.length-1]._key;Sr.get(n)===e&&Sr.delete(n)}else Sr.delete(e._key)}(i),e.__lexicalEditor=null):i&&pe(198);const o=xr(e);for(let e=0;ee.__key===this.__key));if(ri(this))return n;if(gi(t)&&"element"===t.anchor.type&&"element"===t.focus.type){if(t.isCollapsed())return!1;const e=this.getParent();if(yo(this)&&this.isInline()&&e){const n=t.isBackward()?t.focus:t.anchor;if(e.is(n.getNode())&&n.offset===e.getChildrenSize()&&this.is(e.getLastChild()))return!1}}return n}getKey(){return this.__key}getIndexWithinParent(){const e=this.getParent();if(null===e)return-1;let t=e.getFirstChild(),n=0;for(;null!==t;){if(this.is(t))return n;n++,t=t.getNextSibling()}return-1}getParent(){const e=this.getLatest().__parent;return null===e?null:is(e)}getParentOrThrow(){const e=this.getParent();return null===e&&pe(66,this.__key),e}getTopLevelElement(){let e=this;for(;null!==e;){const t=e.getParent();if(Ks(t))return po(e)||e===this&&yo(e)||pe(194),e;e=t}return null}getTopLevelElementOrThrow(){const e=this.getTopLevelElement();return null===e&&pe(67,this.__key),e}getParents(){const e=[];let t=this.getParent();for(;null!==t;)e.push(t),t=t.getParent();return e}getParentKeys(){const e=[];let t=this.getParent();for(;null!==t;)e.push(t.__key),t=t.getParent();return e}getPreviousSibling(){const e=this.getLatest().__prev;return null===e?null:is(e)}getPreviousSiblings(){const e=[],t=this.getParent();if(null===t)return e;let n=t.getFirstChild();for(;null!==n&&!n.is(this);)e.push(n),n=n.getNextSibling();return e}getNextSibling(){const e=this.getLatest().__next;return null===e?null:is(e)}getNextSiblings(){const e=[];let t=this.getNextSibling();for(;null!==t;)e.push(t),t=t.getNextSibling();return e}getCommonAncestor(e){const t=po(this)?this:this.getParent(),n=po(e)?e:e.getParent(),r=t&&n?Kl(t,n):null;return r?r.commonAncestor:null}is(e){return null!=e&&this.__key===e.__key}isBefore(e){const t=Kl(this,e);return null!==t&&("descendant"===t.type||("branch"===t.type?-1===zl(t):("same"!==t.type&&"ancestor"!==t.type&&pe(279),!1)))}isParentOf(e){const t=Kl(this,e);return null!==t&&"ancestor"===t.type}getNodesBetween(e){const t=this.isBefore(e),n=[],r=new Set;let i=this;for(;null!==i;){const o=i.__key;if(r.has(o)||(r.add(o),n.push(i)),i===e)break;const s=po(i)?t?i.getFirstChild():i.getLastChild():null;if(null!==s){i=s;continue}const l=t?i.getNextSibling():i.getPreviousSibling();if(null!==l){i=l;continue}const a=i.getParentOrThrow();if(r.has(a.__key)||n.push(a),a===e)break;let c=null,u=a;do{if(null===u&&pe(68),c=t?u.getNextSibling():u.getPreviousSibling(),u=u.getParent(),null===u)break;null!==c||r.has(u.__key)||n.push(u)}while(null===c);i=c}return t||n.reverse(),n}isDirty(){const e=Yi()._dirtyLeaves;return null!==e&&e.has(this.__key)}getLatest(){if(Nr(this))return this;const e=is(this.__key);return null===e&&pe(113),e}getWritable(){if(Nr(this))return this;Zi();const e=Ji(),t=Yi(),n=e._nodeMap,r=this.__key,i=this.getLatest(),o=t._cloneNotNeeded,s=Li();if(null!==s&&s.setCachedNodes(null),o.has(r))return ts(i),i;const l=sl(i);return o.add(r),ts(l),n.set(r,l),l}getTextContent(){return""}getTextContentSize(){return this.getTextContent().length}createDOM(e,t){pe(70)}updateDOM(e,t,n){pe(71)}exportDOM(e){return{element:this.createDOM(e._config,e)}}exportJSON(){const e=this.__state?this.__state.toJSON():void 0;return{type:this.__type,version:1,...e}}static importJSON(e){pe(18,this.name)}updateFromJSON(e){return function(e,t){const n=e.getWritable(),r=t.$;let i=r;for(const e of pt(n).flatKeys)e in t&&(void 0!==i&&i!==r||(i={...r}),i[e]=t[e]);return(n.__state||i)&>(e).updateFromJSON(i),n}(this,e)}static transform(){return null}remove(e){Tr(this,!0,e)}replace(e,t){Zi();let n=Li();null!==n&&(n=n.clone()),Vs(this,e);const r=this.getLatest(),i=this.__key,o=e.__key,s=e.getWritable(),l=this.getParentOrThrow().getWritable(),a=l.__size;es(s);const c=r.getPreviousSibling(),u=r.getNextSibling(),d=r.__prev,h=r.__next,g=r.__parent;if(Tr(r,!1,!0),null===c?l.__first=o:c.getWritable().__next=o,s.__prev=d,null===u?l.__last=o:u.getWritable().__prev=o,s.__next=h,s.__parent=g,l.__size=a,t&&(po(this)&&po(s)||pe(139),this.getChildren().forEach((e=>{s.append(e)}))),gi(n)){hs(n);const e=n.anchor,t=n.focus;e.key===i&&di(e,s),t.key===i&&di(t,s)}return rs()===i&&ns(o),s}insertAfter(e,t=!0){Zi(),Vs(this,e);const n=this.getWritable(),r=e.getWritable(),i=r.getParent(),o=Li();let s=!1,l=!1;if(null!==i){const t=e.getIndexWithinParent();if(es(r),gi(o)){const e=i.__key,n=o.anchor,r=o.focus;s="element"===n.type&&n.key===e&&n.offset===t+1,l="element"===r.type&&r.key===e&&r.offset===t+1}}const a=this.getNextSibling(),c=this.getParentOrThrow().getWritable(),u=r.__key,d=n.__next;if(null===a?c.__last=u:a.getWritable().__prev=u,c.__size++,n.__next=u,r.__next=d,r.__prev=n.__key,r.__parent=n.__parent,t&&gi(o)){const e=this.getIndexWithinParent();Fi(o,c,e+1);const t=c.__key;s&&o.anchor.set(t,e+2,"element"),l&&o.focus.set(t,e+2,"element")}return e}insertBefore(e,t=!0){Zi(),Vs(this,e);const n=this.getWritable(),r=e.getWritable(),i=r.__key;es(r);const o=this.getPreviousSibling(),s=this.getParentOrThrow().getWritable(),l=n.__prev,a=this.getIndexWithinParent();null===o?s.__first=i:o.getWritable().__next=i,s.__size++,n.__prev=i,r.__prev=l,r.__next=n.__key,r.__parent=n.__parent;const c=Li();return t&&gi(c)&&Fi(c,this.getParentOrThrow(),a),e}isParentRequired(){return!1}createParentElementNode(){return Eo()}selectStart(){return this.selectPrevious()}selectEnd(){return this.selectNext(0,0)}selectPrevious(e,t){Zi();const n=this.getPreviousSibling(),r=this.getParentOrThrow();if(null===n)return r.select(0,0);if(po(n))return n.select();if(!ri(n)){const e=n.getIndexWithinParent()+1;return r.select(e,e)}return n.select(e,t)}selectNext(e,t){Zi();const n=this.getNextSibling(),r=this.getParentOrThrow();if(null===n)return r.select();if(po(n))return n.select(0,0);if(!ri(n)){const e=n.getIndexWithinParent();return r.select(e,e)}return n.select(e,t)}markDirty(){this.getWritable()}reconcileObservedMutation(e,t){this.markDirty()}}const Lr="historic",Or="history-merge",Fr="collaboration",Rr="skip-scroll-into-view",Ir="skip-dom-selection",Pr="skip-selection-focus";class Mr extends Ar{static getType(){return"linebreak"}static clone(e){return new Mr(e.__key)}constructor(e){super(e)}getTextContent(){return"\n"}createDOM(){return document.createElement("br")}updateDOM(){return!1}isInline(){return!0}static importDOM(){return{br:e=>function(e){const t=e.parentElement;if(null!==t&&el(t)){const n=t.firstChild;if(n===e||n.nextSibling===e&&$r(n)){const n=t.lastChild;if(n===e||n.previousSibling===e&&$r(n))return!0}}return!1}(e)||function(e){const t=e.parentElement;if(null!==t&&el(t)){const n=t.firstChild;if(n===e||n.nextSibling===e&&$r(n))return!1;const r=t.lastChild;if(r===e||r.previousSibling===e&&$r(r))return!0}return!1}(e)?null:{conversion:Dr,priority:0}}}static importJSON(e){return Br().updateFromJSON(e)}}function Dr(e){return{node:Br()}}function Br(){return Ws(new Mr)}function zr(e){return e instanceof Mr}function $r(e){return Zo(e)&&/^( |\t|\r?\n)+$/.test(e.textContent||"")}function Hr(e,t){return 16&t?"code":128&t?"mark":32&t?"sub":64&t?"sup":null}function Kr(e,t){return 1&t?"strong":2&t?"em":"span"}function Ur(e,t,n,r,i){const o=r.classList;let s=Es(i,"base");void 0!==s&&o.add(...s),s=Es(i,"underlineStrikethrough");let l=!1;const a=8&t&&4&t;void 0!==s&&(8&n&&4&n?(l=!0,a||o.add(...s)):a&&o.remove(...s));for(const e in We){const r=We[e];if(s=Es(i,e),void 0!==s)if(n&r){if(l&&("underline"===e||"strikethrough"===e)){t&r&&o.remove(...s);continue}(0===(t&r)||a&&"underline"===e||"strikethrough"===e)&&o.add(...s)}else t&r&&o.remove(...s)}}function Wr(e,t,n){const r=t.firstChild,i=n.isComposing(),o=e+(i?De:"");if(null==r)t.textContent=o;else{const e=r.nodeValue;if(e!==o)if(i||_e){const[t,n,i]=function(e,t){const n=e.length,r=t.length;let i=0,o=0;for(;i({conversion:Xr,priority:0}),b:()=>({conversion:Gr,priority:0}),code:()=>({conversion:ti,priority:0}),em:()=>({conversion:ti,priority:0}),i:()=>({conversion:ti,priority:0}),mark:()=>({conversion:ti,priority:0}),s:()=>({conversion:ti,priority:0}),span:()=>({conversion:Zr,priority:0}),strong:()=>({conversion:ti,priority:0}),sub:()=>({conversion:ti,priority:0}),sup:()=>({conversion:ti,priority:0}),u:()=>({conversion:ti,priority:0})}}static importJSON(e){return ni().updateFromJSON(e)}updateFromJSON(e){return super.updateFromJSON(e).setTextContent(e.text).setFormat(e.format).setDetail(e.detail).setMode(e.mode).setStyle(e.style)}exportDOM(e){let{element:t}=super.exportDOM(e);return Js(t)||pe(132),t.style.whiteSpace="pre-wrap",this.hasFormat("lowercase")?t.style.textTransform="lowercase":this.hasFormat("uppercase")?t.style.textTransform="uppercase":this.hasFormat("capitalize")&&(t.style.textTransform="capitalize"),this.hasFormat("bold")&&(t=qr(t,"b")),this.hasFormat("italic")&&(t=qr(t,"i")),this.hasFormat("strikethrough")&&(t=qr(t,"s")),this.hasFormat("underline")&&(t=qr(t,"u")),{element:t}}exportJSON(){return{detail:this.getDetail(),format:this.getFormat(),mode:this.getMode(),style:this.getStyle(),text:this.getTextContent(),...super.exportJSON()}}selectionTransform(e,t){}setFormat(e){const t=this.getWritable();return t.__format="string"==typeof e?We[e]:e,t}setDetail(e){const t=this.getWritable();return t.__detail="string"==typeof e?Ve[e]:e,t}setStyle(e){const t=this.getWritable();return t.__style=e,t}toggleFormat(e){const t=Yo(this.getFormat(),e,null);return this.setFormat(t)}toggleDirectionless(){const e=this.getWritable();return e.__detail^=1,e}toggleUnmergeable(){const e=this.getWritable();return e.__detail^=2,e}setMode(e){const t=Ze[e];if(this.__mode===t)return this;const n=this.getWritable();return n.__mode=t,n}setTextContent(e){if(this.__text===e)return this;const t=this.getWritable();return t.__text=e,t}select(e,t){Zi();let n=e,r=t;const i=Li(),o=this.getTextContent(),s=this.__key;if("string"==typeof o){const e=o.length;void 0===n&&(n=e),void 0===r&&(r=e)}else n=0,r=0;if(!gi(i))return Ti(s,n,s,r,"text","text");{const e=rs();e!==i.anchor.key&&e!==i.focus.key||ns(s),i.setTextNodeRange(this,n,this,r)}return i}selectStart(){return this.select(0,0)}selectEnd(){const e=this.getTextContentSize();return this.select(e,e)}spliceText(e,t,n,r){const i=this.getWritable(),o=i.__text,s=n.length;let l=e;l<0&&(l=s+l,l<0&&(l=0));const a=Li();if(r&&gi(a)){const t=e+s;a.setTextNodeRange(i,t,i,t)}const c=o.slice(0,l)+n+o.slice(l+t);return i.__text=c,i}canInsertTextBefore(){return!0}canInsertTextAfter(){return!0}splitText(...e){Zi();const t=this.getLatest(),n=t.getTextContent();if(""===n)return[];const r=t.__key,i=rs(),o=n.length;e.sort(((e,t)=>e-t)),e.push(o);const s=[],l=e.length;for(let t=0,r=0;tt&&(s.push(n.slice(t,i)),t=i)}const a=s.length;if(1===a)return[t];const c=s[0],u=t.getParent();let d;const h=t.getFormat(),g=t.getStyle(),p=t.__detail;let f=!1,m=null,y=null;const b=Li();if(gi(b)){const[e,t]=b.isBackward()?[b.focus,b.anchor]:[b.anchor,b.focus];"text"===e.type&&e.key===r&&(m=e),"text"===t.type&&t.key===r&&(y=t)}t.isSegmented()?(d=ni(c),d.__format=h,d.__style=g,d.__detail=p,d.__state=_t(t,d),f=!0):d=t.setTextContent(c);const _=[d];for(let e=1;e=C&&(m.set(e.getKey(),x-C,"text"),x=C){y.set(e.getKey(),S-C,"text");break}C=t}if(null!==u){!function(e){const t=e.getPreviousSibling(),n=e.getNextSibling();null!==t&&ts(t),null!==n&&ts(n)}(this);const e=u.getWritable(),t=this.getIndexWithinParent();f?(e.splice(t,0,_),this.remove()):e.splice(t,1,_),gi(b)&&Fi(b,u,t,a-1)}return _}mergeWithSibling(e){const t=e===this.getPreviousSibling();t||e===this.getNextSibling()||pe(50);const n=this.__key,r=e.__key,i=this.__text,o=i.length;rs()===r&&ns(n);const s=Li();if(gi(s)){const i=s.anchor,l=s.focus;null!==i&&i.key===r&&Pi(i,t,n,e,o),null!==l&&l.key===r&&Pi(l,t,n,e,o)}const l=e.__text,a=t?l+i:i+l;this.setTextContent(a);const c=this.getWritable();return e.remove(),c}isTextEntity(){return!1}}function Zr(e){return{forChild:ii(e.style),node:null}}function Gr(e){const t=e,n="normal"===t.style.fontWeight;return{forChild:ii(t.style,n?void 0:"bold"),node:null}}const Jr=new WeakMap;function Yr(e){if(!Js(e))return!1;if("PRE"===e.nodeName)return!0;const t=e.style.whiteSpace;return"string"==typeof t&&t.startsWith("pre")}function Xr(e){const t=e;null===e.parentElement&&pe(129);let n=t.textContent||"";if(null!==function(e){let t,n=e.parentNode;const r=[e];for(;null!==n&&void 0===(t=Jr.get(n))&&!Yr(n);)r.push(n),n=n.parentNode;const i=void 0===t?n:t;for(let e=0;e0){/[ \t\n]$/.test(t)&&(n=n.slice(1)),r=!1;break}}r&&(n=n.slice(1))}if(" "===n[n.length-1]){let e=t,r=!0;for(;null!==e&&null!==(e=Qr(e,!0));)if((e.textContent||"").replace(/^( |\t|\r?\n)+/,"").length>0){r=!1;break}r&&(n=n.slice(0,n.length-1))}return""===n?{node:null}:{node:ni(n)}}function Qr(e,t){let n=e;for(;;){let e;for(;null===(e=t?n.nextSibling:n.previousSibling);){const e=n.parentElement;if(null===e)return null;n=e}if(n=e,Js(n)){const e=n.style.display;if(""===e&&!Qs(n)||""!==e&&!e.startsWith("inline"))return null}let r=n;for(;null!==(r=t?n.firstChild:n.lastChild);)n=r;if(Zo(n))return n;if("BR"===n.nodeName)return null}}const ei={code:"code",em:"italic",i:"italic",mark:"highlight",s:"strikethrough",strong:"bold",sub:"subscript",sup:"superscript",u:"underline"};function ti(e){const t=ei[e.nodeName.toLowerCase()];return void 0===t?{node:null}:{forChild:ii(e.style,t),node:null}}function ni(e=""){return Ws(new jr(e))}function ri(e){return e instanceof jr}function ii(e,t){const n=e.fontWeight,r=e.textDecoration.split(" "),i="700"===n||"bold"===n,o=r.includes("line-through"),s="italic"===e.fontStyle,l=r.includes("underline"),a=e.verticalAlign;return e=>ri(e)?(i&&!e.hasFormat("bold")&&e.toggleFormat("bold"),o&&!e.hasFormat("strikethrough")&&e.toggleFormat("strikethrough"),s&&!e.hasFormat("italic")&&e.toggleFormat("italic"),l&&!e.hasFormat("underline")&&e.toggleFormat("underline"),"sub"!==a||e.hasFormat("subscript")||e.toggleFormat("subscript"),"super"!==a||e.hasFormat("superscript")||e.toggleFormat("superscript"),t&&!e.hasFormat(t)&&e.toggleFormat(t),e):e}class oi extends jr{static getType(){return"tab"}static clone(e){return new oi(e.__key)}constructor(e){super("\t",e),this.__detail=2}static importDOM(){return null}createDOM(e){const t=super.createDOM(e),n=Es(e.theme,"tab");return void 0!==n&&t.classList.add(...n),t}static importJSON(e){return si().updateFromJSON(e)}setTextContent(e){return"\t"!==e&&""!==e&&fe(126),super.setTextContent("\t")}spliceText(e,t,n,r){return""===n&&0===t||"\t"===n&&1===t||pe(286),this}setDetail(e){return 2!==e&&pe(127),this}setMode(e){return"normal"!==e&&pe(128),this}canInsertTextBefore(){return!1}canInsertTextAfter(){return!1}}function si(){return Ws(new oi)}function li(e){return e instanceof oi}class ai{key;offset;type;_selection;constructor(e,t,n){this._selection=null,this.key=e,this.offset=t,this.type=n}is(e){return this.key===e.key&&this.offset===e.offset&&this.type===e.type}isBefore(e){return this.key===e.key?this.offsete&&(r=e)}else if(!po(t)){const e=t.getNextSibling();if(ri(e))n=e.__key,r=0,i="text";else{const e=t.getParent();e&&(n=e.__key,r=t.getIndexWithinParent()+1)}}e.set(n,r,i)}function di(e,t){if(po(t)){const n=t.getLastDescendant();po(n)||ri(n)?ui(e,n):ui(e,t)}else ui(e,t)}class hi{_nodes;_cachedNodes;dirty;constructor(e){this._cachedNodes=null,this._nodes=e,this.dirty=!1}getCachedNodes(){return this._cachedNodes}setCachedNodes(e){this._cachedNodes=e}is(e){if(!fi(e))return!1;const t=this._nodes,n=e._nodes;return t.size===n.size&&Array.from(t).every((e=>n.has(e)))}isCollapsed(){return!1}isBackward(){return!1}getStartEndPoints(){return null}add(e){this.dirty=!0,this._nodes.add(e),this._cachedNodes=null}delete(e){this.dirty=!0,this._nodes.delete(e),this._cachedNodes=null}clear(){this.dirty=!0,this._nodes.clear(),this._cachedNodes=null}has(e){return this._nodes.has(e)}clone(){return new hi(new Set(this._nodes))}extract(){return this.getNodes()}insertRawText(e){}insertText(){}insertNodes(e){const t=this.getNodes(),n=t.length,r=t[n-1];let i;if(ri(r))i=r.select();else{const e=r.getIndexWithinParent()+1;i=r.getParentOrThrow().select(e,e)}i.insertNodes(e);for(let e=0;e1;){const e=t[t.length-1];if(!po(e)||o.has(e)||e.isEmpty()||i.has(e))break;t.pop()}if(0===t.length&&e.isCollapsed()){const n=Xl(e.anchor),r=Xl(e.anchor.getFlipped()),i=e=>xl(e)?e.origin:e.getNodeAtCaret(),o=i(n)||i(r)||(e.anchor.getNodeAtCaret()?n.origin:r.origin);t.push(o)}return t}(ta(jl(this),"next"));return ji()||(this._cachedNodes=t),t}setTextNodeRange(e,t,n,r){this.anchor.set(e.__key,t,"text"),this.focus.set(n.__key,r,"text")}getTextContent(){const e=this.getNodes();if(0===e.length)return"";const t=e[0],n=e[e.length-1],r=this.anchor,i=this.focus,o=r.isBefore(i),[s,l]=yi(this);let a="",c=!0;for(let u=0;u=0;e--){const t=o[e];if(t.is(d)||po(t)&&t.isParentOf(d))break;t.isAttached()&&(!g.has(t)||t.is(i)?f||m.insertAfter(t,!1):t.remove())}if(!f){let e=r,n=null;for(;null!==e;){const r=e.getChildren(),i=r.length;(0===i||r[i-1].is(n))&&(t.delete(e.__key),n=e),e=e.getParent()}}if(qo(d))if(l===h)d.select();else{const t=ni(e);t.select(),d.replace(t)}else d=d.spliceText(l,h-l,e,!0),""===d.getTextContent()?d.remove():d.isComposing()&&"text"===this.anchor.type&&(this.anchor.offset-=e.length);for(let e=1;e{n.forEach((n=>{if(po(n)){const r=n.getFormatFlags(e,t);n.setTextFormat(r)}}))},o=r.length;if(0===o)return this.toggleFormat(e),ns(null),void i(t);const s=this.anchor,l=this.focus,a=this.isBackward(),c=a?l:s,u=a?s:l;let d=0,h=r[0],g="element"===c.type?0:c.offset;if("text"===c.type&&g===h.getTextContentSize()&&(d=1,h=r[1],g=0),null==h)return;const p=h.getFormatFlags(e,t);i(p);const f=o-1;let m=r[f];const y="text"===u.type?u.offset:m.getTextContentSize();if(h.is(m)){if(g===y)return;if(jo(h)||0===g&&y===h.getTextContentSize())h.setFormat(p);else{const e=h.splitText(g,y),t=0===g?e[0]:e[1];t.setFormat(p),"text"===c.type&&c.set(t.__key,0,"text"),"text"===u.type&&u.set(t.__key,y-g,"text")}return void(this.format=p)}0===g||jo(h)||([,h]=h.splitText(g),g=0),h.setFormat(p);const b=m.getFormatFlags(e,p);y>0&&(y===m.getTextContentSize()||jo(m)||([m]=m.splitText(y)),m.setFormat(b));for(let t=d+1;t(po(e)||yo(e))&&!e.isInline()))){po(n)||pe(211,t.constructor.name,t.getType());const i=Bi(this);return n.splice(i,0,e),void r.selectEnd()}const i=function(e){const t=Eo();let n=null;for(let r=0;r0){const e=o.getRangeAt(0),n=this.anchor.getNode(),i=_o(n)?n:function(e){let t=e.getParentOrThrow();for(;null!==t;){if(Ks(t))return t;t=t.getParentOrThrow()}return t}(n);if(this.applyDOMRange(e),this.dirty=!0,!r){const n=this.getNodes(),r=[];let s=!1;for(let e=0;e0)if(t){const e=r[0];po(e)?e.selectStart():e.getParentOrThrow().selectStart()}else{const e=r[r.length-1];po(e)?e.selectEnd():e.getParentOrThrow().selectEnd()}o.anchorNode===e.startContainer&&o.anchorOffset===e.startOffset||function(e){const t=e.focus,n=e.anchor,r=n.key,i=n.offset,o=n.type;n.set(t.key,t.offset,t.type,!0),t.set(r,i,o,!0)}(this)}}"lineboundary"===n&&$i(this,e,t,n,"decorators")}forwardDeletion(e,t,n){if(!n&&("element"===e.type&&po(t)&&e.offset===t.getChildrenSize()||"text"===e.type&&e.offset===t.getTextContentSize())){const e=t.getParent(),n=t.getNextSibling()||(null===e?null:e.getNextSibling());if(po(n)&&n.isShadowRoot())return!0}return!1}deleteCharacter(e){const t=this.isCollapsed();if(this.isCollapsed()){const t=this.anchor;let n=t.getNode();if(this.forwardDeletion(t,n,e))return;const r=Il(Ul(t,e?"previous":"next"));if(r.getTextSlices().every((e=>null===e||0===e.distance))){let e={type:"initial"};for(const t of r.iterNodeCarets("shadowRoot"))if(Cl(t))if(t.origin.isInline());else{if(t.origin.isShadowRoot()){if("merge-block"===e.type)break;if(po(r.anchor.origin)&&r.anchor.origin.isEmpty()){const e=Xl(t);ql(this,Ml(e,e)),r.anchor.origin.remove()}return}"merge-next-block"!==e.type&&"merge-block"!==e.type||(e={block:e.block,caret:t,type:"merge-block"})}else{if("merge-block"===e.type)break;if(Sl(t)){if(po(t.origin)){if(t.origin.isInline()){if(!t.origin.isParentOf(r.anchor.origin))break}else e={block:t.origin,type:"merge-next-block"};continue}if(yo(t.origin)){if(t.origin.isIsolated());else if("merge-next-block"===e.type&&(t.origin.isKeyboardSelectable()||!t.origin.isInline())&&po(r.anchor.origin)&&r.anchor.origin.isEmpty()){r.anchor.origin.remove();const e=Ni();e.add(t.origin.getKey()),hs(e)}else t.origin.remove();return}break}}if("merge-block"===e.type){const{caret:t,block:n}=e;return ql(this,Ml(!t.origin.isEmpty()&&n.isEmpty()?Zl(Tl(n,t.direction)):r.anchor,t)),this.removeText()}}const i=this.focus;if(this.modify("extend",e,"character"),this.isCollapsed()){if(e&&0===t.offset&&bi(this,t.getNode()))return}else{const r="text"===i.type?i.getNode():null;if(n="text"===t.type?t.getNode():null,null!==r&&r.isSegmented()){const t=i.offset,o=r.getTextContentSize();if(r.is(n)||e&&t!==o||!e&&0!==t)return void xi(r,e,t)}else if(null!==n&&n.isSegmented()){const i=t.offset,o=n.getTextContentSize();if(n.is(r)||e&&0!==i||!e&&i!==o)return void xi(n,e,i)}!function(e,t){const n=e.anchor,r=e.focus,i=n.getNode();if(i===r.getNode()&&"text"===n.type&&"text"===r.type){const e=n.offset,o=r.offset,s=e{try{const e=new RegExp("\\p{Emoji}","u"),t=e.test.bind(e);if(t("❤️")&&t("#️⃣")&&t("👍"))return t}catch(e){}return()=>!1})();function xi(e,t,n){const r=e,i=r.getTextContent().split(/(?=\s)/g),o=i.length;let s=0,l=0;for(let e=0;en||r){i.splice(e,1),r&&(l=void 0);break}}const a=i.join("").trim();""===a?r.remove():(r.setTextContent(a),r.select(l,l))}function Si(e,t,n,r){let i,o=t;if(Js(e)){let s=!1;const l=e.childNodes,a=l.length,c=r._blockCursorElement;o===a&&(s=!0,o=a-1);let u=l[o],d=!1;if(u===c)u=l[o+1],d=!0;else if(null!==c){const n=c.parentNode;e===n&&t>Array.prototype.indexOf.call(n.children,c)&&o--}if(i=gs(u),ri(i))o=Nl(i,s?"next":"previous");else{let l=gs(e);if(null===l)return null;if(po(l)){const a=r.getElementByKey(l.getKey());null===a&&pe(214);const c=l.getDOMSlot(a);[l,o]=c.resolveChildIndex(l,a,e,t),po(l)||pe(215),s&&o>=l.getChildrenSize()&&(o=Math.max(0,l.getChildrenSize()-1));let u=l.getChildAtIndex(o);if(po(u)&&function(e,t,n){const r=e.getParent();return null===n||null===r||!r.canBeEmpty()||r!==n.getNode()}(u,0,n)){const e=s?u.getLastDescendant():u.getFirstDescendant();null===e?l=u:(u=e,l=po(u)?u:u.getParentOrThrow()),o=0}ri(u)?(i=u,l=null,o=Nl(u,s?"next":"previous")):u!==l&&s&&!d&&(po(l)||pe(216),o=Math.min(l.getChildrenSize(),o+1))}else{const n=l.getIndexWithinParent();o=0===t&&yo(l)&&gs(e)===l?n:n+1,l=l.getParentOrThrow()}if(po(l))return ci(l.__key,o,"element")}}else i=gs(e);return ri(i)?ci(i.__key,Nl(i,o,"clamp"),"text"):null}function Ci(e,t,n){const r=e.offset,i=e.getNode();if(0===r){const r=i.getPreviousSibling(),o=i.getParent();if(t){if((n||!t)&&null===r&&po(o)&&o.isInline()){const t=o.getPreviousSibling();ri(t)&&e.set(t.__key,t.getTextContent().length,"text")}}else po(r)&&!n&&r.isInline()?e.set(r.__key,r.getChildrenSize(),"element"):ri(r)&&e.set(r.__key,r.getTextContent().length,"text")}else if(r===i.getTextContent().length){const r=i.getNextSibling(),o=i.getParent();if(t&&po(r)&&r.isInline())e.set(r.__key,0,"element");else if((n||t)&&null===r&&po(o)&&o.isInline()&&!o.canInsertTextAfter()){const t=o.getNextSibling();ri(t)&&e.set(t.__key,0,"text")}}}function vi(e,t,n){if("text"===e.type&&"text"===t.type){const r=e.isBefore(t),i=e.is(t);Ci(e,r,i),Ci(t,!r,i),i&&t.set(e.key,e.offset,e.type);const o=Yi();if(o.isComposing()&&o._compositionKey!==e.key&&gi(n)){const r=n.anchor,i=n.focus;e.set(r.key,r.offset,r.type,!0),t.set(i.key,i.offset,i.type,!0)}}}function wi(e,t,n,r,i,o){if(null===e||null===n||!Ho(i,e,n))return null;const s=Si(e,t,gi(o)?o.anchor:null,i);if(null===s)return null;const l=Si(n,r,gi(o)?o.focus:null,i);if(null===l)return null;if("element"===s.type&&"element"===l.type){const t=gs(e),r=gs(n);if(yo(t)&&yo(r))return null}return vi(s,l,o),[s,l]}function ki(e){return po(e)&&!e.isInline()}function Ti(e,t,n,r,i,o){const s=Ji(),l=new pi(ci(e,t,i),ci(n,r,o),0,"");return l.dirty=!0,s._selection=l,l}function Ei(){const e=ci("root",0,"element"),t=ci("root",0,"element");return new pi(e,t,0,"")}function Ni(){return new hi(new Set)}function Ai(e,t,n,r){const i=n._window;if(null===i)return null;const o=r||i.event,s=o?o.type:void 0,l="selectionchange"===s,a=!Xe&&(l||"beforeinput"===s||"compositionstart"===s||"compositionend"===s||"click"===s&&o&&3===o.detail||"drop"===s||void 0===s);let c,u,d,h;if(gi(e)&&!a)return e.clone();if(null===t)return null;if(c=t.anchorNode,u=t.focusNode,d=t.anchorOffset,h=t.focusOffset,(l||void 0===s)&&gi(e)&&!Ho(n,c,u))return e.clone();const g=wi(c,d,u,h,n,e);if(null===g)return null;const[p,f]=g;return new pi(p,f,gi(e)?e.format:0,gi(e)?e.style:"")}function Li(){return Ji()._selection}function Oi(){return Yi()._editorState._selection}function Fi(e,t,n,r=1){const i=e.anchor,o=e.focus,s=i.getNode(),l=o.getNode();if(!t.is(s)&&!t.is(l))return;const a=t.__key;if(e.isCollapsed()){const t=i.offset;if(n<=t&&r>0||n0||n0||n=e,s=i?o.getChildAtIndex(e-1):o.getChildAtIndex(n);if(ri(s)){let e=0;i&&(e=s.getTextContentSize()),t.set(s.__key,e,"text"),r.set(s.__key,e,"text")}}else{if(po(o)){const e=o.getChildrenSize(),r=n>=e,i=r?o.getChildAtIndex(e-1):o.getChildAtIndex(n);if(ri(i)){let e=0;r&&(e=i.getTextContentSize()),t.set(i.__key,e,"text")}}if(po(s)){const e=s.getChildrenSize(),t=i>=e,n=t?s.getChildAtIndex(e-1):s.getChildAtIndex(i);if(ri(n)){let e=0;t&&(e=n.getTextContentSize()),r.set(n.__key,e,"text")}}}}function Ii(e,t,n,r,i){let o=null,s=0,l=null;null!==r?(o=r.__key,ri(r)?(s=r.getTextContentSize(),l="text"):po(r)&&(s=r.getChildrenSize(),l="element")):null!==i&&(o=i.__key,ri(i)?l="text":po(i)&&(l="element")),null!==o&&null!==l?e.set(o,s,l):(s=t.getIndexWithinParent(),-1===s&&(s=n.getChildrenSize()),e.set(n.__key,s,"element"))}function Pi(e,t,n,r,i){"text"===e.type?e.set(n,e.offset+(t?0:i),"text"):e.offset>r.getIndexWithinParent()&&e.set(e.key,e.offset-1,"element")}function Mi(e,t,n,r,i){try{e.setBaseAndExtent(t,n,r,i)}catch(e){}}function Di(e){let t=Li()||Oi();null===t&&(t=us().selectEnd()),t.insertNodes(e)}function Bi(e){let t=e;e.isCollapsed()||t.removeText();const n=Li();gi(n)&&(t=n),gi(t)||pe(161);const r=t.anchor;let i=r.getNode(),o=r.offset;for(;!tl(i);){const e=i;if([i,o]=zi(i,o),e.is(i))break}return o}function zi(e,t){const n=e.getParent();if(!n){const e=Eo();return us().append(e),e.select(),[us(),0]}if(ri(e)){const r=e.splitText(t);if(0===r.length)return[n,e.getIndexWithinParent()];const i=0===t?0:1;return[n,r[0].getIndexWithinParent()+i]}if(!po(e)||0===t)return[n,e.getIndexWithinParent()];const r=e.getChildAtIndex(t);if(r){const n=new pi(ci(e.__key,t,"element"),ci(e.__key,t,"element"),0,""),i=e.insertNewAfter(n);i&&i.append(r,...r.getNextSiblings())}return[n,e.getIndexWithinParent()+1]}function $i(e,t,n,r,i="decorators-and-blocks"){if("move"===t&&"character"===r&&!e.isCollapsed()){const[t,r]=n===e.isBackward()?[e.focus,e.anchor]:[e.anchor,e.focus];return r.set(t.key,t.offset,t.type),!0}const o=Ul(e.focus,n?"previous":"next"),s="lineboundary"===r,l="move"===t;let a=o,c="decorators-and-blocks"===i;if(!Ql(a)){for(const e of a){c=!1;const{origin:t}=e;if(!yo(t)||t.isIsolated()||(a=e,!s||!t.isInline()))break}if(c)for(const e of Il(o).iterNodeCarets("extend"===t?"shadowRoot":"root")){if(Cl(e))e.origin.isInline()||(a=e);else{if(po(e.origin))continue;yo(e.origin)&&!e.origin.isInline()&&(a=e)}break}}if(a===o)return!1;if(l&&!s&&yo(a.origin)&&a.origin.isKeyboardSelectable()){const e=Ni();return e.add(a.origin.getKey()),hs(e),!0}return a=Xl(a),l&&Wl(e.anchor,a),Wl(e.focus,a),c||!s}let Hi=null,Ki=null,Ui=!1,Wi=!1,Vi=0;const qi={characterData:!0,childList:!0,subtree:!0};function ji(){return Ui||null!==Hi&&Hi._readOnly}function Zi(){Ui&&pe(13)}function Gi(){Vi>99&&pe(14)}function Ji(){return null===Hi&&pe(195,Xi()),Hi}function Yi(){return null===Ki&&pe(196,Xi()),Ki}function Xi(){let e=0;const t=new Set,n=Fo.version;if("undefined"!=typeof window)for(const r of document.querySelectorAll("[contenteditable]")){const i=Wo(r);if(Ko(i))e++;else if(i){let e=String(i.constructor.version||"<0.17.1");e===n&&(e+=" (separately built, likely a bundler configuration issue)"),t.add(e)}}let r=` Detected on the page: ${e} compatible editor(s) with version ${n}`;return t.size&&(r+=` and incompatible editors with versions ${Array.from(t).join(", ")}`),r}function Qi(e,t,n){const r=t.__type,i=Mo(e,r);let o=n.get(r);void 0===o&&(o=Array.from(i.transforms),n.set(r,o));const s=o.length;for(let e=0;e0?r.getRangeAt(0):null;if(null!==e){let t;if(e instanceof Text){const n=document.createRange();n.selectNode(e),t=n.getBoundingClientRect()}else t=e.getBoundingClientRect();!function(e,t,n){const r=Ms(n),i=zs(r);if(null===r||null===i)return;let{top:o,bottom:s}=t,l=0,a=0,c=n;for(;null!==c;){const t=c===r.body;if(t)l=0,a=$s(e).innerHeight;else{const e=c.getBoundingClientRect();l=e.top,a=e.bottom}let n=0;if(oa&&(n=s-a),0!==n)if(t)i.scrollBy(0,n);else{const e=c.scrollTop;c.scrollTop+=n;const t=c.scrollTop-e;o-=t,s-=t}if(t)break;c=Ps(c)}}(n,t,o)}}or=!0}}(s,l,e,x,b,r)}!function(e,t,n){let r=e._blockCursorElement;if(gi(n)&&n.isCollapsed()&&"element"===n.anchor.type&&t.contains(document.activeElement)){const i=n.anchor,o=i.getNode(),s=i.offset;let l=!1,a=null;if(s===o.getChildrenSize())qs(o.getChildAtIndex(s-1))&&(l=!0);else{const t=o.getChildAtIndex(s);if(null!==t&&qs(t)){const n=t.getPreviousSibling();(null===n||qs(n))&&(l=!0,a=e.getElementByKey(t.__key))}}if(l){const n=e.getElementByKey(o.__key);return null===r&&(e._blockCursorElement=r=function(e){const t=e.theme,n=document.createElement("div");n.contentEditable="false",n.setAttribute("data-lexical-cursor","true");let r=t.blockCursor;if(void 0!==r){if("string"==typeof r){const e=Ee(r);r=t.blockCursor=e}void 0!==r&&n.classList.add(...r)}return n}(e._config)),t.style.caretColor="transparent",void(null===a?n.appendChild(r):n.insertBefore(r,a))}}null!==r&&js(r,e,t)}(e,r,l)}finally{null!==g&&g.observe(r,qi),Ki=d,Hi=c}}null!==p&&function(e,t,n,r,i){const o=Array.from(e._listeners.mutation),s=o.length;for(let e=0;e0||u>0;){if(a>0){t._dirtyLeaves=new Set;for(const e of l){const r=i.get(e);ri(r)&&r.isAttached()&&r.isSimpleText()&&!r.isUnmergeable()&&Ct(r),void 0!==r&&eo(r,o)&&Qi(t,r,s),n.add(e)}if(l=t._dirtyLeaves,a=l.size,a>0){Vi++;continue}}t._dirtyLeaves=new Set,t._dirtyElements=new Map,c.delete("root")&&c.set("root",!0);for(const e of c){const n=e[0],l=e[1];if(r.set(n,l),!l)continue;const a=i.get(n);void 0!==a&&eo(a,o)&&Qi(t,a,s)}l=t._dirtyLeaves,a=l.size,c=t._dirtyElements,u=c.size,Vi++}t._dirtyLeaves=n,t._dirtyElements=r}(a,e),lo(e),function(e,t,n,r){const i=e._nodeMap,o=t._nodeMap,s=[];for(const[e]of r){const t=o.get(e);void 0!==t&&(t.isAttached()||(po(t)&&Ye(t,e,i,o,s,r),i.has(e)||r.delete(e),s.push(e)))}for(const e of s)o.delete(e);for(const e of n){const t=o.get(e);void 0===t||t.isAttached()||(i.has(e)||n.delete(e),o.delete(e))}}(l,a,e._dirtyLeaves,e._dirtyElements)),r!==e._compositionKey&&(a._flushSync=!0);const i=a._selection;if(gi(i)){const e=a._nodeMap,t=i.anchor.key,n=i.focus.key;void 0!==e.get(t)&&void 0!==e.get(n)||pe(19)}else fi(i)&&0===i._nodes.size&&(a._selection=null)}catch(t){return t instanceof Error&&e._onError(t),e._pendingEditorState=l,e._dirtyType=2,e._cloneNotNeeded.clear(),e._dirtyLeaves=new Set,e._dirtyElements.clear(),void oo(e)}finally{Hi=u,Ui=d,Ki=h,e._updating=g,Vi=0}const f=0!==e._dirtyType||e._deferred.length>0||function(e,t){const n=t.getEditorState()._selection,r=e._selection;if(null!==r){if(r.dirty||!r.is(n))return!0}else if(null!==n)return!0;return!1}(a,e);f?a._flushSync?(a._flushSync=!1,oo(e)):c&&Bo((()=>{oo(e)})):(a._flushSync=!1,c&&(r.clear(),e._deferred=[],e._pendingEditorState=null))}function co(e,t,n){Ki===e&&void 0===n?t():ao(e,t,n)}class uo{element;before;after;constructor(e,t,n){this.element=e,this.before=t||null,this.after=n||null}withBefore(e){return new uo(this.element,e,this.after)}withAfter(e){return new uo(this.element,this.before,e)}withElement(e){return this.element===e?this:new uo(e,this.before,this.after)}insertChild(e){const t=this.before||this.getManagedLineBreak();return null!==t&&t.parentElement!==this.element&&pe(222),this.element.insertBefore(e,t),this}removeChild(e){return e.parentElement!==this.element&&pe(223),this.element.removeChild(e),this}replaceChild(e,t){return t.parentElement!==this.element&&pe(224),this.element.replaceChild(e,t),this}getFirstChild(){const e=this.after?this.after.nextSibling:this.element.firstChild;return e===this.before||e===this.getManagedLineBreak()?null:e}getManagedLineBreak(){return this.element.__lexicalLineBreak||null}setManagedLineBreak(e){if(null===e)this.removeManagedLineBreak();else{const t="decorator"===e&&(Te||Ce||Se);this.insertManagedLineBreak(t)}}removeManagedLineBreak(){const e=this.getManagedLineBreak();if(e){const t=this.element,n="IMG"===e.nodeName?e.nextSibling:null;n&&t.removeChild(n),t.removeChild(e),t.__lexicalLineBreak=void 0}}insertManagedLineBreak(e){const t=this.getManagedLineBreak();if(t){if(e===("IMG"===t.nodeName))return;this.removeManagedLineBreak()}const n=this.element,r=this.before,i=document.createElement("br");if(n.insertBefore(i,r),e){const e=document.createElement("img");e.setAttribute("data-lexical-linebreak","true"),e.style.cssText="display: inline !important; border: 0px !important; margin: 0px !important;",e.alt="",n.insertBefore(e,i),n.__lexicalLineBreak=e}else n.__lexicalLineBreak=i}getFirstChildOffset(){let e=0;for(let t=this.after;null!==t;t=t.previousSibling)e++;return e}resolveChildIndex(e,t,n,r){if(n===this.element){const t=this.getFirstChildOffset();return[e,Math.min(t+e.getChildrenSize(),Math.max(t,r))]}const i=ho(t,n);i.push(r);const o=ho(t,this.element);let s=e.getIndexWithinParent();for(let e=0;en){s+=1;break}}return[e.getParentOrThrow(),s]}}function ho(e,t){const n=[];let r=t;for(;r!==e&&null!==r;r=r.parentNode){let e=0;for(let t=r.previousSibling;null!==t;t=t.previousSibling)e++;n.push(e)}return r!==e&&pe(225),n.reverse()}class go extends Ar{__first;__last;__size;__format;__style;__indent;__dir;__textFormat;__textStyle;constructor(e){super(e),this.__first=null,this.__last=null,this.__size=0,this.__format=0,this.__style="",this.__indent=0,this.__dir=null,this.__textFormat=0,this.__textStyle=""}afterCloneFrom(e){super.afterCloneFrom(e),this.__key===e.__key&&(this.__first=e.__first,this.__last=e.__last,this.__size=e.__size),this.__indent=e.__indent,this.__format=e.__format,this.__style=e.__style,this.__dir=e.__dir,this.__textFormat=e.__textFormat,this.__textStyle=e.__textStyle}getFormat(){return this.getLatest().__format}getFormatType(){const e=this.getFormat();return je[e]||""}getStyle(){return this.getLatest().__style}getIndent(){return this.getLatest().__indent}getChildren(){const e=[];let t=this.getFirstChild();for(;null!==t;)e.push(t),t=t.getNextSibling();return e}getChildrenKeys(){const e=[];let t=this.getFirstChild();for(;null!==t;)e.push(t.__key),t=t.getNextSibling();return e}getChildrenSize(){return this.getLatest().__size}isEmpty(){return 0===this.getChildrenSize()}isDirty(){const e=Yi()._dirtyElements;return null!==e&&e.has(this.__key)}isLastChild(){const e=this.getLatest(),t=this.getParentOrThrow().getLastChild();return null!==t&&t.is(e)}getAllTextNodes(){const e=[];let t=this.getFirstChild();for(;null!==t;){if(ri(t)&&e.push(t),po(t)){const n=t.getAllTextNodes();e.push(...n)}t=t.getNextSibling()}return e}getFirstDescendant(){let e=this.getFirstChild();for(;po(e);){const t=e.getFirstChild();if(null===t)break;e=t}return e}getLastDescendant(){let e=this.getLastChild();for(;po(e);){const t=e.getLastChild();if(null===t)break;e=t}return e}getDescendantByIndex(e){const t=this.getChildren(),n=t.length;if(e>=n){const e=t[n-1];return po(e)&&e.getLastDescendant()||e||null}const r=t[e];return po(r)&&r.getFirstDescendant()||r||null}getFirstChild(){const e=this.getLatest().__first;return null===e?null:is(e)}getFirstChildOrThrow(){const e=this.getFirstChild();return null===e&&pe(45,this.__key),e}getLastChild(){const e=this.getLatest().__last;return null===e?null:is(e)}getLastChildOrThrow(){const e=this.getLastChild();return null===e&&pe(96,this.__key),e}getChildAtIndex(e){const t=this.getChildrenSize();let n,r;if(e=e;){if(r===e)return n;n=n.getPreviousSibling(),r--}return null}getTextContent(){let e="";const t=this.getChildren(),n=t.length;for(let r=0;re.remove())),e}append(...e){return this.splice(this.getChildrenSize(),0,e)}setDirection(e){const t=this.getWritable();return t.__dir=e,t}setFormat(e){return this.getWritable().__format=""!==e?qe[e]:0,this}setStyle(e){return this.getWritable().__style=e||"",this}setTextFormat(e){const t=this.getWritable();return t.__textFormat=e,t}setTextStyle(e){const t=this.getWritable();return t.__textStyle=e,t}setIndent(e){return this.getWritable().__indent=e,this}splice(e,t,n){Nr(this)&&pe(324,this.__key,this.__type);const r=this.getChildrenSize(),i=this.getWritable();e+t<=r||pe(226,String(e),String(t),String(r));const o=i.__key,s=[],l=[],a=this.getChildAtIndex(e+t);let c=null,u=r-t+n.length;if(0!==e)if(e===r)c=this.getLastChild();else{const t=this.getChildAtIndex(e);null!==t&&(c=t.getPreviousSibling())}if(t>0){let e=null===c?this.getFirstChild():c.getNextSibling();for(let n=0;n0&&(t.style.paddingInlineStart=40*e+"px");const n=this.getDirection();n&&(t.dir=n)}return{element:t}}exportJSON(){const e={children:[],direction:this.getDirection(),format:this.getFormatType(),indent:this.getIndent(),...super.exportJSON()},t=this.getTextFormat(),n=this.getTextStyle();return 0!==t&&(e.textFormat=t),""!==n&&(e.textStyle=n),e}updateFromJSON(e){return super.updateFromJSON(e).setFormat(e.format).setIndent(e.indent).setDirection(e.direction).setTextFormat(e.textFormat||0).setTextStyle(e.textStyle||"")}insertNewAfter(e,t){return null}canIndent(){return!0}collapseAtStart(e){return!1}excludeFromCopy(e){return!1}canReplaceWith(e){return!0}canInsertAfter(e){return!0}canBeEmpty(){return!0}canInsertTextBefore(){return!0}canInsertTextAfter(){return!0}isInline(){return!1}isShadowRoot(){return!1}canMergeWith(e){return!1}extractWithChild(e,t,n){return!1}canMergeWhenEmpty(){return!1}reconcileObservedMutation(e,t){const n=this.getDOMSlot(e);let r=n.getFirstChild();for(let e=this.getFirstChild();e;e=e.getNextSibling()){const i=t.getElementByKey(e.getKey());null!==i&&(null==r?(n.insertChild(i),r=i):r!==i&&n.replaceChild(i,r),r=r.nextSibling)}}}function po(e){return e instanceof go}function fo(e,t,n){let r=e.getNode();for(;r;){const e=r.__key;if(t.has(e)&&!n.has(e))return!0;r=r.getParent()}return!1}class mo extends Ar{decorate(e,t){return null}isIsolated(){return!1}isInline(){return!0}isKeyboardSelectable(){return!0}}function yo(e){return e instanceof mo}class bo extends go{__cachedText;static getType(){return"root"}static clone(){return new bo}constructor(){super("root"),this.__cachedText=null}getTopLevelElementOrThrow(){pe(51)}getTextContent(){const e=this.__cachedText;return!ji()&&0!==Yi()._dirtyType||null===e?super.getTextContent():e}remove(){pe(52)}replace(e){pe(53)}insertBefore(e){pe(54)}insertAfter(e){pe(55)}updateDOM(e,t){return!1}splice(e,t,n){for(const e of n)po(e)||yo(e)||pe(282);return super.splice(e,t,n)}static importJSON(e){return us().updateFromJSON(e)}collapseAtStart(){return!0}}function _o(e){return e instanceof bo}function xo(e){return new vo(new Map(e._nodeMap))}function So(){return new vo(new Map([["root",new bo]]))}function Co(e){const t=e.exportJSON(),n=e.constructor;if(t.type!==n.getType()&&pe(130,n.name),po(e)){const r=t.children;Array.isArray(r)||pe(59,n.name);const i=e.getChildren();for(let e=0;e({root:Co(us())})))}}class wo extends go{static getType(){return"artificial"}createDOM(e){return document.createElement("div")}}class ko extends go{static getType(){return"paragraph"}static clone(e){return new ko(e.__key)}createDOM(e){const t=document.createElement("p"),n=Es(e.theme,"paragraph");return void 0!==n&&t.classList.add(...n),t}updateDOM(e,t,n){return!1}static importDOM(){return{p:e=>({conversion:To,priority:0})}}exportDOM(e){const{element:t}=super.exportDOM(e);if(Js(t)){this.isEmpty()&&t.append(document.createElement("br"));const e=this.getFormatType();e&&(t.style.textAlign=e)}return{element:t}}static importJSON(e){return Eo().updateFromJSON(e)}exportJSON(){return{...super.exportJSON(),textFormat:this.getTextFormat(),textStyle:this.getTextStyle()}}insertNewAfter(e,t){const n=Eo();n.setTextFormat(e.format),n.setTextStyle(e.style);const r=this.getDirection();return n.setDirection(r),n.setFormat(this.getFormatType()),n.setStyle(this.getStyle()),this.insertAfter(n,t),n}collapseAtStart(){const e=this.getChildren();if(0===e.length||ri(e[0])&&""===e[0].getTextContent().trim()){if(null!==this.getNextSibling())return this.selectNext(),this.remove(),!0;if(null!==this.getPreviousSibling())return this.selectPrevious(),this.remove(),!0}return!1}}function To(e){const t=Eo();return e.style&&(t.setFormat(e.style.textAlign),ll(e,t)),{node:t}}function Eo(){return Ws(new ko)}function No(e){return e instanceof ko}function Ao(e,t,n,r){const i=e._keyToDOMMap;i.clear(),e._editorState=So(),e._pendingEditorState=r,e._compositionKey=null,e._dirtyType=0,e._cloneNotNeeded.clear(),e._dirtyLeaves=new Set,e._dirtyElements.clear(),e._normalizedNodes=new Set,e._updateTags=new Set,e._updates=[],e._blockCursorElement=null;const o=e._observer;null!==o&&(o.disconnect(),e._observer=null),null!==t&&(t.textContent=""),null!==n&&(n.textContent="",i.set("root",n))}function Lo(e){const t=new Set,n=new Set;let r=e;for(;r;){const{ownNodeConfig:e}=ul(r),i=r.transform;if(!n.has(i)){n.add(i);const e=r.transform();e&&t.add(e)}if(e){const n=e.$transform;n&&t.add(n),r=e.extends}else{const e=Object.getPrototypeOf(r);r=e.prototype instanceof Ar&&e!==Ar?e:void 0}}return t}function Oo(e){const t=e||{},n=Ki,r=t.theme||{},i=void 0===e?n:t.parentEditor||null,o=t.disableEvents||!1,s=So(),l=t.namespace||(null!==i?i._config.namespace:ms()),a=t.editorState,c=[bo,jr,Mr,oi,ko,wo,...t.nodes||[]],{onError:u,html:d}=t,h=void 0===t.editable||t.editable;let g;if(void 0===e&&null!==n)g=n._nodes;else{g=new Map;for(let e=0;e{Object.keys(e).forEach((t=>{let r=n.get(t);void 0===r&&(r=[],n.set(t,r)),r.push(e[t])}))};return e.forEach((e=>{const t=e.klass.importDOM;if(null==t||r.has(t))return;r.add(t);const n=t.call(e.klass);null!==n&&i(n)})),t&&i(t),n}(g,d?d.import:void 0),h,e);return void 0!==a&&(p._pendingEditorState=a,p._dirtyType=2),p}class Fo{static version;_headless;_parentEditor;_rootElement;_editorState;_pendingEditorState;_compositionKey;_deferred;_keyToDOMMap;_updates;_updating;_listeners;_commands;_nodes;_decorators;_pendingDecorators;_config;_dirtyType;_cloneNotNeeded;_dirtyLeaves;_dirtyElements;_normalizedNodes;_updateTags;_observer;_key;_onError;_htmlConversions;_window;_editable;_blockCursorElement;_createEditorArgs;constructor(e,t,n,r,i,o,s,l){this._createEditorArgs=l,this._parentEditor=t,this._rootElement=null,this._editorState=e,this._pendingEditorState=null,this._compositionKey=null,this._deferred=[],this._keyToDOMMap=new Map,this._updates=[],this._updating=!1,this._listeners={decorator:new Set,editable:new Set,mutation:new Map,root:new Set,textcontent:new Set,update:new Set},this._commands=new Map,this._config=r,this._nodes=n,this._decorators={},this._pendingDecorators=null,this._dirtyType=0,this._cloneNotNeeded=new Set,this._dirtyLeaves=new Set,this._dirtyElements=new Map,this._normalizedNodes=new Set,this._updateTags=new Set,this._observer=null,this._key=ms(),this._onError=i,this._htmlConversions=o,this._editable=s,this._headless=null!==t&&t._headless,this._window=null,this._blockCursorElement=null}isComposing(){return null!=this._compositionKey}registerUpdateListener(e){const t=this._listeners.update;return t.add(e),()=>{t.delete(e)}}registerEditableListener(e){const t=this._listeners.editable;return t.add(e),()=>{t.delete(e)}}registerDecoratorListener(e){const t=this._listeners.decorator;return t.add(e),()=>{t.delete(e)}}registerTextContentListener(e){const t=this._listeners.textcontent;return t.add(e),()=>{t.delete(e)}}registerRootListener(e){const t=this._listeners.root;return e(this._rootElement,null),t.add(e),()=>{e(null,this._rootElement),t.delete(e)}}registerCommand(e,t,n){void 0===n&&pe(35);const r=this._commands;r.has(e)||r.set(e,[new Set,new Set,new Set,new Set,new Set]);const i=r.get(e);void 0===i&&pe(36,String(e));const o=i[n];return o.add(t),()=>{o.delete(t),i.every((e=>0===e.size))&&r.delete(e)}}registerMutationListener(e,t,n){const r=this.resolveRegisteredNodeAfterReplacements(this.getRegisteredNode(e)).klass,i=this._listeners.mutation;let o=i.get(t);void 0===o&&(o=new Set,i.set(t,o)),o.add(r);const s=n&&n.skipInitialization;return void 0!==s&&s||this.initializeMutationListener(t,r),()=>{o.delete(r),0===o.size&&i.delete(t)}}getRegisteredNode(e){const t=this._nodes.get(e.getType());return void 0===t&&pe(37,e.name),t}resolveRegisteredNodeAfterReplacements(e){for(;e.replaceWithKlass;)e=this.getRegisteredNode(e.replaceWithKlass);return e}initializeMutationListener(e,t){const n=this._editorState,r=ol(n).get(t.getType());if(!r)return;const i=new Map;for(const e of r.keys())i.set(e,"created");i.size>0&&e(i,{dirtyLeaves:new Set,prevEditorState:n,updateTags:new Set(["registerMutationListener"])})}registerNodeTransformToKlass(e,t){const n=this.getRegisteredNode(e);return n.transforms.add(t),n}registerNodeTransform(e,t){const n=this.registerNodeTransformToKlass(e,t),r=[n],i=n.replaceWithKlass;if(null!=i){const e=this.registerNodeTransformToKlass(i,t);r.push(e)}return function(e,t){const n=ol(e.getEditorState()),r=[];for(const e of t){const t=n.get(e);t&&r.push(t)}0!==r.length&&e.update((()=>{for(const e of r)for(const t of e.keys()){const e=is(t);e&&e.markDirty()}}),null===e._pendingEditorState?{tag:Or}:void 0)}(this,r.map((e=>e.klass.getType()))),()=>{r.forEach((e=>e.transforms.delete(t)))}}hasNode(e){return this._nodes.has(e.getType())}hasNodes(e){return e.every(this.hasNode.bind(this))}dispatchCommand(e,t){return Fs(this,e,t)}getDecorators(){return this._decorators}getRootElement(){return this._rootElement}getKey(){return this._key}setRootElement(e){const t=this._rootElement;if(e!==t){const n=Es(this._config.theme,"root"),r=this._pendingEditorState||this._editorState;if(this._rootElement=e,Ao(this,t,e,r),null!==t&&(this._config.disableEvents||kr(t),null!=n&&t.classList.remove(...n)),null!==e){const t=zs(e),r=e.style;r.userSelect="text",r.whiteSpace="pre-wrap",r.wordBreak="break-word",e.setAttribute("data-lexical-editor","true"),this._window=t,this._dirtyType=2,lt(this),this._updateTags.add(Or),oo(this),this._config.disableEvents||function(e,t){const n=e.ownerDocument;rr.set(e,n);const r=ir.get(n)??0;r<1&&n.addEventListener("selectionchange",Cr),ir.set(n,r+1),e.__lexicalEditor=t;const i=xr(e);for(let n=0;n{wr(e)||(vr(e),(t.isEditable()||"click"===r)&&o(e,t))}:e=>{if(wr(e))return;vr(e);const n=t.isEditable();switch(r){case"cut":return n&&Fs(t,Kn,e);case"copy":return Fs(t,Hn,e);case"paste":return n&&Fs(t,gn,e);case"dragstart":return n&&Fs(t,Bn,e);case"dragover":return n&&Fs(t,zn,e);case"dragend":return n&&Fs(t,$n,e);case"focus":return n&&Fs(t,Zn,e);case"blur":return n&&Fs(t,Gn,e);case"drop":return n&&Fs(t,Mn,e)}};e.addEventListener(r,s),i.push((()=>{e.removeEventListener(r,s)}))}}(e,this),null!=n&&e.classList.add(...n)}else this._window=null,this._updateTags.add(Or),oo(this);so("root",this,!1,e,t)}}getElementByKey(e){return this._keyToDOMMap.get(e)||null}getEditorState(){return this._editorState}setEditorState(e,t){e.isEmpty()&&pe(38);let n=e;n._readOnly&&(n=xo(e),n._selection=e._selection?e._selection.clone():null),st(this);const r=this._pendingEditorState,i=this._updateTags,o=void 0!==t?t.tag:null;null===r||r.isEmpty()||(null!=o&&i.add(o),oo(this)),this._pendingEditorState=n,this._dirtyType=2,this._dirtyElements.set("root",!1),this._compositionKey=null,null!=o&&i.add(o),this._updating||oo(this)}parseEditorState(e,t){return function(e,t,n){const r=So(),i=Hi,o=Ui,s=Ki,l=t._dirtyElements,a=t._dirtyLeaves,c=t._cloneNotNeeded,u=t._dirtyType;t._dirtyElements=new Map,t._dirtyLeaves=new Set,t._cloneNotNeeded=new Set,t._dirtyType=0,Hi=r,Ui=!1,Ki=t,Io(null);try{const i=t._nodes;ro(e.root,i),n&&n(),r._readOnly=!0}catch(e){e instanceof Error&&t._onError(e)}finally{t._dirtyElements=l,t._dirtyLeaves=a,t._cloneNotNeeded=c,t._dirtyType=u,Hi=i,Ui=o,Ki=s}return r}("string"==typeof e?JSON.parse(e):e,this,t)}read(e){return oo(this),this.getEditorState().read(e,{editor:this})}update(e,t){!function(e,t,n){e._updating?e._updates.push([t,n]):ao(e,t,n)}(this,e,t)}focus(e,t={}){const n=this._rootElement;null!==n&&(n.setAttribute("autocapitalize","off"),co(this,(()=>{const r=Li(),i=us();null!==r?r.dirty||hs(r.clone()):0!==i.getChildrenSize()&&("rootStart"===t.defaultSelection?i.selectStart():i.selectEnd()),Ds("focus"),function(e){Zi(),Yi()._deferred.push(e)}((()=>{n.removeAttribute("autocapitalize"),e&&e()}))})),null===this._pendingEditorState&&n.removeAttribute("autocapitalize"))}blur(){const e=this._rootElement;null!==e&&e.blur();const t=Zs(this._window);null!==t&&t.removeAllRanges()}isEditable(){return this._editable}setEditable(e){this._editable!==e&&(this._editable=e,so("editable",this,!0,e))}toJSON(){return{editorState:this._editorState.toJSON()}}}Fo.version="0.38.2+prod.esm";let Ro=null;function Io(e){Ro=e}let Po=1;function Mo(e,t){const n=Do(e,t);return void 0===n&&pe(30,t),n}function Do(e,t){return e._nodes.get(t)}const Bo="function"==typeof queueMicrotask?queueMicrotask:e=>{Promise.resolve().then(e)};function zo(e){return yo(ls(e))}function $o(e){const t=document.activeElement;if(!Js(t))return!1;const n=t.nodeName;return yo(ls(e))&&("INPUT"===n||"TEXTAREA"===n||"true"===t.contentEditable&&null==Wo(t))}function Ho(e,t,n){const r=e.getRootElement();try{return null!==r&&r.contains(t)&&r.contains(n)&&null!==t&&!$o(t)&&Uo(t)===e}catch(e){return!1}}function Ko(e){return e instanceof Fo}function Uo(e){let t=e;for(;null!=t;){const e=Wo(t);if(Ko(e))return e;t=Ps(t)}return null}function Wo(e){return e?e.__lexicalEditor:null}function Vo(e){return Ke.test(e)?"rtl":Ue.test(e)?"ltr":null}function qo(e){return li(e)||e.isToken()}function jo(e){return qo(e)||e.isSegmented()}function Zo(e){return Ys(e)&&3===e.nodeType}function Go(e){return Ys(e)&&9===e.nodeType}function Jo(e){let t=e;for(;null!=t;){if(Zo(t))return t;t=t.firstChild}return null}function Yo(e,t,n){const r=We[t];if(null!==n&&(e&r)===(n&r))return e;let i=e^r;return"subscript"===t?i&=-65:"superscript"===t?i&=-33:"lowercase"===t?(i&=-513,i&=-1025):"uppercase"===t?(i&=-257,i&=-1025):"capitalize"===t&&(i&=-257,i&=-513),i}function Xo(e){return ri(e)||zr(e)||yo(e)}function Qo(e,t){const n=function(){const e=Ro;return Ro=null,e}();if(null!=(t=t||n&&n.__key))return void(e.__key=t);Zi(),Gi();const r=Yi(),i=Ji(),o=""+Po++;i._nodeMap.set(o,e),po(e)?r._dirtyElements.set(o,!0):r._dirtyLeaves.add(o),r._cloneNotNeeded.add(o),r._dirtyType=1,e.__key=o}function es(e){const t=e.getParent();if(null!==t){const n=e.getWritable(),r=t.getWritable(),i=e.getPreviousSibling(),o=e.getNextSibling(),s=null!==o?o.__key:null,l=null!==i?i.__key:null,a=null!==i?i.getWritable():null,c=null!==o?o.getWritable():null;null===i&&(r.__first=s),null===o&&(r.__last=l),null!==a&&(a.__next=s),null!==c&&(c.__prev=l),n.__prev=null,n.__next=null,n.__parent=null,r.__size--}}function ts(e){Gi(),Nr(e)&&pe(323,e.__key,e.__type);const t=e.getLatest(),n=t.__parent,r=Ji(),i=Yi(),o=r._nodeMap,s=i._dirtyElements;null!==n&&function(e,t,n){let r=e;for(;null!==r;){if(n.has(r))return;const e=t.get(r);if(void 0===e)break;n.set(r,!1),r=e.__parent}}(n,o,s);const l=t.__key;i._dirtyType=1,po(e)?s.set(l,!0):i._dirtyLeaves.add(l)}function ns(e){Zi();const t=Yi(),n=t._compositionKey;if(e!==n){if(t._compositionKey=e,null!==n){const e=is(n);null!==e&&e.getWritable()}if(null!==e){const t=is(e);null!==t&&t.getWritable()}}}function rs(){return ji()?null:Yi()._compositionKey}function is(e,t){const n=(t||Ji())._nodeMap.get(e);return void 0===n?null:n}function os(e,t){const n=ss(e,Yi());return void 0!==n?is(n,t):null}function ss(e,t){return e[`__lexicalKey_${t._key}`]}function ls(e,t){let n=e;for(;null!=n;){const e=os(n,t);if(null!==e)return e;n=Ps(n)}return null}function as(e){const t=e._decorators,n=Object.assign({},t);return e._pendingDecorators=n,n}function cs(e){return e.read((()=>us().getTextContent()))}function us(){return ds(Ji())}function ds(e){return e._nodeMap.get("root")}function hs(e){Zi();const t=Ji();null!==e&&(e.dirty=!0,e.setCachedNodes(null)),t._selection=e}function gs(e){const t=Yi(),n=function(e,t){let n=e;for(;null!=n;){const e=ss(n,t);if(void 0!==e)return e;n=Ps(n)}return null}(e,t);return null===n?e===t.getRootElement()?is("root"):null:is(n)}function ps(e){return/[\uD800-\uDBFF][\uDC00-\uDFFF]/g.test(e)}function fs(e){const t=[];let n=e;for(;null!==n;)t.push(n),n=n._parentEditor;return t}function ms(){return Math.random().toString(36).replace(/[^a-z]+/g,"").substring(0,5)}function ys(e){return Zo(e)?e.nodeValue:null}function bs(e,t,n){const r=Zs($s(t));if(null===r)return;const i=r.anchorNode;let{anchorOffset:o,focusOffset:s}=r;if(null!==i){let t=ys(i);const r=ls(i);if(null!==t&&ri(r)){if(t===De&&n){const e=n.length;t=n,o=e,s=e}null!==t&&_s(r,t,o,s,e)}}}function _s(e,t,n,r,i){let o=e;if(o.isAttached()&&(i||!o.isDirty())){const s=o.isComposing();let l=t;(s||i)&&t[t.length-1]===De&&(l=t.slice(0,-1));const a=o.getTextContent();if(i||l!==a){if(""===l){if(ns(null),Se||Ce||Te)o.remove();else{const e=Yi();setTimeout((()=>{e.update((()=>{o.isAttached()&&o.remove()}))}),20)}return}const t=o.getParent(),i=Oi(),a=o.getTextContentSize(),c=rs(),u=o.getKey();if(o.isToken()||null!==c&&u===c&&!s||gi(i)&&(null!==t&&!t.canInsertTextBefore()&&0===i.anchor.offset||i.anchor.key===e.__key&&0===i.anchor.offset&&!o.canInsertTextBefore()&&!s||i.focus.key===e.__key&&i.focus.offset===a&&!o.canInsertTextAfter()&&!s))return void o.markDirty();const d=Li();if(!gi(d)||null===n||null===r)return void xs(o,l,d);if(d.setTextNodeRange(o,n,o,r),o.isSegmented()){const e=ni(o.getTextContent());o.replace(e),o=e}xs(o,l,d)}}}function xs(e,t,n){if(e.setTextContent(t),gi(n)){const t=e.getKey();for(const r of["anchor","focus"]){const i=n[r];"text"===i.type&&i.key===t&&(i.offset=Nl(e,i.offset,"clamp"))}}}function Ss(e,t,n){const r=t[n]||!1;return"any"===r||r===e[n]}function Cs(e,t,n){return function(e,t){return Ss(e,t,"altKey")&&Ss(e,t,"ctrlKey")&&Ss(e,t,"shiftKey")&&Ss(e,t,"metaKey")}(e,n)&&e.key.toLowerCase()===t.toLowerCase()}const vs={ctrlKey:!be,metaKey:be},ws={altKey:be,ctrlKey:!be};function ks(e){return"Backspace"===e.key}function Ts(e){return Cs(e,"a",vs)}function Es(e,t){void 0===e.__lexicalClassNameCache&&(e.__lexicalClassNameCache={});const n=e.__lexicalClassNameCache,r=n[t];if(void 0!==r)return r;const i=e[t];if("string"==typeof i){const e=Ee(i);return n[t]=e,e}return i}function Ns(e,t,n,r,i){if(0===n.size)return;const o=r.__type,s=r.__key,l=t.get(o);void 0===l&&pe(33,o);const a=l.klass;let c=e.get(a);void 0===c&&(c=new Map,e.set(a,c));const u=c.get(s),d="destroyed"===u&&"created"===i;(void 0===u||d)&&c.set(s,d?"updated":i)}function As(e,t,n){const r=e.getParent();let i=n,o=e;return null!==r&&(t&&0===n?(i=o.getIndexWithinParent(),o=r):t||n!==o.getChildrenSize()||(i=o.getIndexWithinParent()+1,o=r)),o.getChildAtIndex(t?i-1:i)}function Ls(e,t){const n=e.offset;if("element"===e.type)return As(e.getNode(),t,n);{const r=e.getNode();if(t&&0===n||!t&&n===r.getTextContentSize()){const e=t?r.getPreviousSibling():r.getNextSibling();return null===e?As(r.getParentOrThrow(),t,r.getIndexWithinParent()+(t?0:1)):e}}return null}function Os(e){const t=$s(e).event,n=t&&t.inputType;return"insertFromPaste"===n||"insertFromPasteAsQuotation"===n}function Fs(e,t,n){return function(e,t,n){const r=fs(e);for(let i=4;i>=0;i--)for(let o=0;o{for(let t=0;to),cl(e,"clone")||(e.clone=t=>(Io(t),new e)),cl(e,"importJSON")||(e.importJSON=i&&i.$importJSON||(t=>(new e).updateFromJSON(t))),!cl(e,"importDOM")&&i)){const{importDOM:t}=i;t&&(e.importDOM=()=>t)}return{ownNodeConfig:i,ownNodeType:o}}const dl=(e,t)=>{let n=e;for(;null!=n&&!_o(n);){if(t(n))return n;n=n.getParent()}return null},hl={next:"previous",previous:"next"};class gl{origin;constructor(e){this.origin=e}[Symbol.iterator](){return Dl({hasNext:Sl,initial:this.getAdjacentCaret(),map:e=>e,step:e=>e.getAdjacentCaret()})}getAdjacentCaret(){return Tl(this.getNodeAtCaret(),this.direction)}getSiblingCaret(){return Tl(this.origin,this.direction)}remove(){const e=this.getNodeAtCaret();return e&&e.remove(),this}replaceOrInsert(e,t){const n=this.getNodeAtCaret();return e.is(this.origin)||e.is(n)||(null===n?this.insert(e):n.replace(e,t)),this}splice(e,t,n="next"){const r=n===this.direction?t:Array.from(t).reverse();let i=this;const o=this.getParentAtCaret(),s=new Map;for(let t=i.getAdjacentCaret();null!==t&&s.size0){const t=i.getNodeAtCaret();if(t)if(s.delete(t.getKey()),s.delete(e.getKey()),t.is(e)||i.origin.is(e));else{const n=e.getParent();n&&n.is(o)&&e.remove(),t.replace(e)}else null===t&&pe(263,Array.from(s).join(" "))}else i.insert(e);i=Tl(e,this.direction)}for(const e of s.values())e.remove();return this}}class pl extends gl{type="child";getLatest(){const e=this.origin.getLatest();return e===this.origin?this:Ll(e,this.direction)}getParentCaret(e="root"){return Tl(yl(this.getParentAtCaret(),e),this.direction)}getFlipped(){const e=ml(this.direction);return Tl(this.getNodeAtCaret(),e)||Ll(this.origin,e)}getParentAtCaret(){return this.origin}getChildCaret(){return this}isSameNodeCaret(e){return e instanceof pl&&this.direction===e.direction&&this.origin.is(e.origin)}isSamePointCaret(e){return this.isSameNodeCaret(e)}}const fl={root:_o,shadowRoot:Ks};function ml(e){return hl[e]}function yl(e,t="root"){return fl[t](e)?null:e}class bl extends gl{type="sibling";getLatest(){const e=this.origin.getLatest();return e===this.origin?this:Tl(e,this.direction)}getSiblingCaret(){return this}getParentAtCaret(){return this.origin.getParent()}getChildCaret(){return po(this.origin)?Ll(this.origin,this.direction):null}getParentCaret(e="root"){return Tl(yl(this.getParentAtCaret(),e),this.direction)}getFlipped(){const e=ml(this.direction);return Tl(this.getNodeAtCaret(),e)||Ll(this.origin.getParentOrThrow(),e)}isSamePointCaret(e){return e instanceof bl&&this.direction===e.direction&&this.origin.is(e.origin)}isSameNodeCaret(e){return(e instanceof bl||e instanceof _l)&&this.direction===e.direction&&this.origin.is(e.origin)}}class _l extends gl{type="text";offset;constructor(e,t){super(e),this.offset=t}getLatest(){const e=this.origin.getLatest();return e===this.origin?this:El(e,this.direction,this.offset)}getParentAtCaret(){return this.origin.getParent()}getChildCaret(){return null}getParentCaret(e="root"){return Tl(yl(this.getParentAtCaret(),e),this.direction)}getFlipped(){return El(this.origin,ml(this.direction),this.offset)}isSamePointCaret(e){return e instanceof _l&&this.direction===e.direction&&this.origin.is(e.origin)&&this.offset===e.offset}isSameNodeCaret(e){return(e instanceof bl||e instanceof _l)&&this.direction===e.direction&&this.origin.is(e.origin)}getSiblingCaret(){return Tl(this.origin,this.direction)}}function xl(e){return e instanceof _l}function Sl(e){return e instanceof bl}function Cl(e){return e instanceof pl}const vl={next:class extends _l{direction="next";getNodeAtCaret(){return this.origin.getNextSibling()}insert(e){return this.origin.insertAfter(e),this}},previous:class extends _l{direction="previous";getNodeAtCaret(){return this.origin.getPreviousSibling()}insert(e){return this.origin.insertBefore(e),this}}},wl={next:class extends bl{direction="next";getNodeAtCaret(){return this.origin.getNextSibling()}insert(e){return this.origin.insertAfter(e),this}},previous:class extends bl{direction="previous";getNodeAtCaret(){return this.origin.getPreviousSibling()}insert(e){return this.origin.insertBefore(e),this}}},kl={next:class extends pl{direction="next";getNodeAtCaret(){return this.origin.getFirstChild()}insert(e){return this.origin.splice(0,0,[e]),this}},previous:class extends pl{direction="previous";getNodeAtCaret(){return this.origin.getLastChild()}insert(e){return this.origin.splice(this.origin.getChildrenSize(),0,[e]),this}}};function Tl(e,t){return e?new wl[t](e):null}function El(e,t,n){return e?new vl[t](e,Nl(e,n)):null}function Nl(e,t,n="error"){const r=e.getTextContentSize();let i="next"===t?r:"previous"===t?0:t;return(i<0||i>r)&&("clamp"!==n&&fe(284,String(t),String(r),e.getKey()),i=i<0?0:r),i}function Al(e,t){return new Rl(e,t)}function Ll(e,t){return po(e)?new kl[t](e):null}function Ol(e){return e&&function(e){return e&&e.getChildCaret()||e}(e.getAdjacentCaret())}class Fl{type="node-caret-range";direction;anchor;focus;constructor(e,t,n){this.anchor=e,this.focus=t,this.direction=n}getLatest(){const e=this.anchor.getLatest(),t=this.focus.getLatest();return e===this.anchor&&t===this.focus?this:new Fl(e,t,this.direction)}isCollapsed(){return this.anchor.isSamePointCaret(this.focus)}getTextSlices(){const e=e=>{const t=this[e].getLatest();return xl(t)?function(e,t){const{direction:n,origin:r}=e;return Al(e,Nl(r,"focus"===t?ml(n):n)-e.offset)}(t,e):null},t=e("anchor"),n=e("focus");if(t&&n){const{caret:e}=t,{caret:r}=n;if(e.isSameNodeCaret(r))return[Al(e,r.offset-e.offset),null]}return[t,n]}iterNodeCarets(e="root"){const t=xl(this.anchor)?this.anchor.getSiblingCaret():this.anchor.getLatest(),n=this.focus.getLatest(),r=xl(n),i=t=>t.isSameNodeCaret(n)?null:Ol(t)||t.getParentCaret(e);return Dl({hasNext:e=>null!==e&&!(r&&n.isSameNodeCaret(e)),initial:t.isSameNodeCaret(n)?null:i(t),map:e=>e,step:i})}[Symbol.iterator](){return this.iterNodeCarets("root")}}class Rl{type="slice";caret;distance;constructor(e,t){this.caret=e,this.distance=t}getSliceIndices(){const{distance:e,caret:{offset:t}}=this,n=t+e;return n{let n;for(let r=a;rn.has(e.getKey())&&tl(e)));return u&&d?[u,d]:null}(u,d,a);if(h){const[e,t]=h;Ll(e,"previous").splice(0,t.getChildren()),t.remove()}const g=[u,d,...s,...l].find(Jl);if(g)return Pl(ea(Xl(g),e.direction));pe(269,JSON.stringify(s.map((e=>e.origin.__key))))}function Xl(e){const t=function(e){let t=e;for(;Cl(t);){const e=Ol(t);if(!Cl(e))break;t=e}return t}(e.getLatest()),{direction:n}=t;if(ri(t.origin))return xl(t)?t:El(t.origin,n,n);const r=t.getAdjacentCaret();return Sl(r)&&ri(r.origin)?El(r.origin,n,ml(n)):t}function Ql(e){return xl(e)&&e.offset!==Nl(e.origin,e.direction)}function ea(e,t){return e.direction===t?e:e.getFlipped()}function ta(e,t){return e.direction===t?e:Ml(ea(e.focus,t),ea(e.anchor,t))}function na(e){const{origin:t,offset:n,direction:r}=e;if(n===Nl(t,r))return e.getSiblingCaret();if(n===Nl(t,ml(r)))return Zl(e.getSiblingCaret());const[i]=t.splitText(n);return ri(i)||pe(281),ea(Tl(i,"next"),r)}function ra(e,t){return!0}function ia(e,{$copyElementNode:t=Us,$splitTextPointCaretNext:n=na,rootMode:r="shadowRoot",$shouldSplit:i=ra}={}){if(xl(e))return n(e);const o=e.getParentCaret(r);if(o){const{origin:n}=o;if(Cl(e)&&(!n.canBeEmpty()||!i(n,"first")))return Zl(o);const r=function(e){const t=[];for(let n=e.getAdjacentCaret();n;n=n.getAdjacentCaret())t.push(n.origin);return t}(e);(r.length>0||n.canBeEmpty()&&i(n,"last"))&&o.insert(t(n).splice(0,0,r))}return o}const oa=new Map;function sa(e){const t={};if(!e)return t;const n=e.split(";");for(const e of n)if(""!==e){const[n,r]=e.split(/:([^]+)/);n&&r&&(t[n.trim()]=r.trim())}return t}function la(e){let t=oa.get(e);return void 0===t&&(t=sa(e),oa.set(e,t)),t}function aa(e){let t="";for(const n in e)n&&(t+=`${n}: ${e[n]};`);return t}function ca(e){const t=nl().getElementByKey(e.getKey());if(null===t)return null;const n=t.ownerDocument.defaultView;return null===n?null:n.getComputedStyle(t)}function ua(e){return ca(_o(e)?e:e.getParentOrThrow())}function da(e){const t=ua(e);return null!==t&&"rtl"===t.direction}function ha(e,t,n="self"){const r=e.getStartEndPoints();if(t.isSelected(e)&&!jo(t)&&null!==r){const[i,o]=r,s=e.isBackward(),l=i.getNode(),a=o.getNode(),c=t.is(l),u=t.is(a);if(c||u){const[r,i]=yi(e),o=l.is(a),c=t.is(s?a:l),u=t.is(s?l:a);let d,h=0;o?(h=r>i?i:r,d=r>i?r:i):c?(h=s?i:r,d=void 0):u&&(h=0,d=s?r:i);const g=t.__text.slice(h,d);g!==t.__text&&("clone"===n&&(t=function(e){return(t=sl(e))[Er]=!0,t;var t}(t)),t.__text=g)}}return t}function ga(e){const t=e.getStyle(),n=sa(t);oa.set(t,n)}function pa(e,t){(gi(e)?e.isCollapsed():ri(e)||po(e))||function(e,...t){const n=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",e);for(const e of t)r.append("v",e);throw n.search=r.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}(280);const n=la(gi(e)?e.style:ri(e)?e.getStyle():e.getTextStyle()),r=Object.entries(t).reduce(((t,[r,i])=>("function"==typeof i?t[r]=i(n[r],e):null===i?delete t[r]:t[r]=i,t)),{...n}),i=aa(r);gi(e)||ri(e)?e.setStyle(i):e.setTextStyle(i),oa.set(i,r)}function fa(e,t){if(gi(e)&&e.isCollapsed()){pa(e,t);const n=e.anchor.getNode();po(n)&&n.isEmpty()&&pa(n,t)}!function(e){const t=Li();if(!t)return;const n=new Map,r=e=>n.get(e.getKey())||[0,e.getTextContentSize()];if(gi(t))for(const e of jl(t).getTextSlices())e&&n.set(e.caret.origin.getKey(),e.getSliceIndices());const i=t.getNodes();for(const t of i){if(!ri(t)||!t.canHaveFormat())continue;const[n,i]=r(t);i!==n&&(jo(t)||0===n&&i===t.getTextContentSize()?e(t):e(t.splitText(n,i)[0===n?0:1]))}gi(t)&&"text"===t.anchor.type&&"text"===t.focus.type&&t.anchor.key===t.focus.key&&function(e){if(e.isBackward()){const{anchor:t,focus:n}=e,{key:r,offset:i,type:o}=t;t.set(n.key,n.offset,n.type),n.set(r,i,o)}}(t)}((e=>{pa(e,t)}))}function ma(e){const t=ya(e);return null!==t&&"vertical-rl"===t.writingMode}function ya(e){const t=e.anchor.getNode();return po(t)?ca(t):ua(t)}function ba(e,t){let n=ma(e)?!t:t;_a(e)&&(n=!n);const r=Ul(e.focus,n?"previous":"next");if(Ql(r))return!1;for(const e of Il(r)){if(Cl(e))return!e.origin.isInline();if(!po(e.origin)){if(yo(e.origin))return!0;break}}return!1}function _a(e){const t=ya(e);return null!==t&&"rtl"===t.direction}function xa(e,t,n){const r=_a(e);let i;i=ma(e)||r?!n:n,function(e,t,n,r){e.modify(t?"extend":"move",n,r)}(e,t,i,"character")}function Sa(e,t,n){const r=la(e.getStyle());return null!==r&&r[t]||n}function Ca(e,t,n=""){let r=null;const i=e.getNodes(),o=e.anchor,s=e.focus,l=e.isBackward(),a=l?s.offset:o.offset,c=l?s.getNode():o.getNode();if(gi(e)&&e.isCollapsed()&&""!==e.style){const n=la(e.style);if(null!==n&&t in n)return n[t]}for(let e=0;e{"strong"!==t.tagName&&"em"!==t.tagName||e.removeAttribute("class")})),ge.setConfig({ALLOWED_TAGS:["a","action-text-attachment","b","blockquote","br","code","em","figcaption","figure","h1","h2","h3","h4","h5","h6","hr","i","img","li","mark","ol","p","pre","q","s","strong","ul","table","tbody","tr","th","td"],ALLOWED_ATTR:["alt","caption","class","content","content-type","contenteditable","data-direct-upload-id","data-sgid","filename","filesize","height","href","presentation","previewable","sgid","src","style","title","url","width"],SAFE_FOR_XML:!1});const Ta="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,Ea=Ta&&"documentMode"in document?document.documentMode:null;function Na(...e){const t=[];for(const n of e)if(n&&"string"==typeof n)for(const[e]of n.matchAll(/\S+/g))t.push(e);return t}function Aa(...e){return()=>{for(let t=e.length-1;t>=0;t--)e[t]();e.length=0}}function La(e,...t){const n=Na(...t);n.length>0&&e.classList.add(...n)}function Oa(e,...t){const n=Na(...t);n.length>0&&e.classList.remove(...n)}function Fa(e){return e?e.getAdjacentCaret():null}function Ra(e,t){let n=e;for(;null!=n;){if(n instanceof t)return n;n=n.getParent()}return null}function Ia(e){const t=Li()||Oi();let n;if(gi(t))n=Ul(t.focus,"next");else{if(null!=t){const e=t.getNodes(),r=e[e.length-1];r&&(n=Tl(r,"next"))}n=n||Ll(us(),"previous").getFlipped().insert(Eo())}const r=function(e,t,n){let r=ea(t,"next");for(let e=r;e;e=ia(e,n))r=e;return xl(r)&&ka(283),r.insert(e.isInline()?Eo().append(e):e),ea(Tl(e.getLatest(),"next"),t.direction)}(e,n),i=Ol(r);return Vl(Pl(Cl(i)?Xl(i):r)),e.getLatest()}function Pa(e,t){return null!==e&&Object.getPrototypeOf(e).constructor.name===t.name}function Ma(e,t){return Da(e,t,null)}function Da(e,t,n){let r=!1;for(const i of za(e))t(i)?null!==n&&n(i):(r=!0,po(i)&&Da(i,t,n||(e=>i.insertAfter(e))),i.remove());return r}function Ba(e,t){const n=[],r=Array.from(e).reverse();for(let e=r.pop();void 0!==e;e=r.pop())if(t(e))n.push(e);else if(po(e))for(const t of za(e))r.push(t);return n}function za(e){return function(e){return Dl({hasNext:Sl,initial:e.getAdjacentCaret(),map:e=>e.origin.getLatest(),step:e=>e.getAdjacentCaret()})}(Ll(e,"previous"))}Ta&&"InputEvent"in window&&!Ea&&new window.InputEvent("input");const $a=Symbol.for("preact-signals");function Ha(){if(Va>1)return void Va--;let e,t=!1;for(;void 0!==Ua;){let n=Ua;for(Ua=void 0,qa++;void 0!==n;){const r=n.o;if(n.o=void 0,n.f&=-3,!(8&n.f)&&Ya(n))try{n.c()}catch(n){t||(e=n,t=!0)}n=r}}if(qa=0,Va--,t)throw e}let Ka,Ua;function Wa(e){const t=Ka;Ka=void 0;try{return e()}finally{Ka=t}}let Va=0,qa=0,ja=0;function Za(e){if(void 0===Ka)return;let t=e.n;return void 0===t||t.t!==Ka?(t={i:0,S:e,p:Ka.s,n:void 0,t:Ka,e:void 0,x:void 0,r:t},void 0!==Ka.s&&(Ka.s.n=t),Ka.s=t,e.n=t,32&Ka.f&&e.S(t),t):-1===t.i?(t.i=0,void 0!==t.n&&(t.n.p=t.p,void 0!==t.p&&(t.p.n=t.n),t.p=Ka.s,t.n=void 0,Ka.s.n=t,Ka.s=t),t):void 0}function Ga(e,t){this.v=e,this.i=0,this.n=void 0,this.t=void 0,this.W=null==t?void 0:t.watched,this.Z=null==t?void 0:t.unwatched,this.name=null==t?void 0:t.name}function Ja(e,t){return new Ga(e,t)}function Ya(e){for(let t=e.s;void 0!==t;t=t.n)if(t.S.i!==t.i||!t.S.h()||t.S.i!==t.i)return!0;return!1}function Xa(e){for(let t=e.s;void 0!==t;t=t.n){const n=t.S.n;if(void 0!==n&&(t.r=n),t.S.n=t,t.i=-1,void 0===t.n){e.s=t;break}}}function Qa(e){let t,n=e.s;for(;void 0!==n;){const e=n.p;-1===n.i?(n.S.U(n),void 0!==e&&(e.n=n.n),void 0!==n.n&&(n.n.p=e)):t=n,n.S.n=n.r,void 0!==n.r&&(n.r=void 0),n=e}e.s=t}function ec(e,t){Ga.call(this,void 0),this.x=e,this.s=void 0,this.g=ja-1,this.f=4,this.W=null==t?void 0:t.watched,this.Z=null==t?void 0:t.unwatched,this.name=null==t?void 0:t.name}function tc(e){const t=e.u;if(e.u=void 0,"function"==typeof t){Va++;const n=Ka;Ka=void 0;try{t()}catch(t){throw e.f&=-2,e.f|=8,nc(e),t}finally{Ka=n,Ha()}}}function nc(e){for(let t=e.s;void 0!==t;t=t.n)t.S.U(t);e.x=void 0,e.s=void 0,tc(e)}function rc(e){if(Ka!==this)throw new Error("Out-of-order effect");Qa(this),Ka=e,this.f&=-2,8&this.f&&nc(this),Ha()}function ic(e,t){this.x=e,this.u=void 0,this.s=void 0,this.o=void 0,this.f=32,this.name=null==t?void 0:t.name}function oc(e,t){const n=new ic(e,t);try{n.c()}catch(e){throw n.d(),e}const r=n.d.bind(n);return r[Symbol.dispose]=r,r}Ga.prototype.brand=$a,Ga.prototype.h=function(){return!0},Ga.prototype.S=function(e){const t=this.t;t!==e&&void 0===e.e&&(e.x=t,this.t=e,void 0!==t?t.e=e:Wa((()=>{var e;null==(e=this.W)||e.call(this)})))},Ga.prototype.U=function(e){if(void 0!==this.t){const t=e.e,n=e.x;void 0!==t&&(t.x=n,e.e=void 0),void 0!==n&&(n.e=t,e.x=void 0),e===this.t&&(this.t=n,void 0===n&&Wa((()=>{var e;null==(e=this.Z)||e.call(this)})))}},Ga.prototype.subscribe=function(e){return oc((()=>{const t=this.value,n=Ka;Ka=void 0;try{e(t)}finally{Ka=n}}),{name:"sub"})},Ga.prototype.valueOf=function(){return this.value},Ga.prototype.toString=function(){return this.value+""},Ga.prototype.toJSON=function(){return this.value},Ga.prototype.peek=function(){const e=Ka;Ka=void 0;try{return this.value}finally{Ka=e}},Object.defineProperty(Ga.prototype,"value",{get(){const e=Za(this);return void 0!==e&&(e.i=this.i),this.v},set(e){if(e!==this.v){if(qa>100)throw new Error("Cycle detected");this.v=e,this.i++,ja++,Va++;try{for(let e=this.t;void 0!==e;e=e.x)e.t.N()}finally{Ha()}}}}),ec.prototype=new Ga,ec.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if(32==(36&this.f))return!0;if(this.f&=-5,this.g===ja)return!0;if(this.g=ja,this.f|=1,this.i>0&&!Ya(this))return this.f&=-2,!0;const e=Ka;try{Xa(this),Ka=this;const e=this.x();(16&this.f||this.v!==e||0===this.i)&&(this.v=e,this.f&=-17,this.i++)}catch(e){this.v=e,this.f|=16,this.i++}return Ka=e,Qa(this),this.f&=-2,!0},ec.prototype.S=function(e){if(void 0===this.t){this.f|=36;for(let e=this.s;void 0!==e;e=e.n)e.S.S(e)}Ga.prototype.S.call(this,e)},ec.prototype.U=function(e){if(void 0!==this.t&&(Ga.prototype.U.call(this,e),void 0===this.t)){this.f&=-33;for(let e=this.s;void 0!==e;e=e.n)e.S.U(e)}},ec.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(let e=this.t;void 0!==e;e=e.x)e.t.N()}},Object.defineProperty(ec.prototype,"value",{get(){if(1&this.f)throw new Error("Cycle detected");const e=Za(this);if(this.h(),void 0!==e&&(e.i=this.i),16&this.f)throw this.v;return this.v}}),ic.prototype.c=function(){const e=this.S();try{if(8&this.f)return;if(void 0===this.x)return;const e=this.x();"function"==typeof e&&(this.u=e)}finally{e()}},ic.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,tc(this),Xa(this),Va++;const e=Ka;return Ka=this,rc.bind(this,e)},ic.prototype.N=function(){2&this.f||(this.f|=2,this.o=Ua,Ua=this)},ic.prototype.d=function(){this.f|=8,1&this.f||nc(this)},ic.prototype.dispose=function(){this.d()};new Set;Symbol.for("@lexical/extension/LexicalBuilder");function sc(e,...t){const n=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",e);for(const e of t)r.append("v",e);throw n.search=r.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function lc(e){let t=1,n=e.getParent();for(;null!=n;){if(kc(n)){const e=n.getParent();if(Fc(e)){t++,n=e.getParent();continue}sc(40)}return t}return t}function ac(e){let t=e.getParent();Fc(t)||sc(40);let n=t;for(;null!==n;)n=n.getParent(),Fc(n)&&(t=n);return t}function cc(e){let t=[];const n=e.getChildren().filter(kc);for(let e=0;e0&&e.append(...i),t.remove()}function yc(e){const t="check"!==e.getListType();let n=e.getStart();for(const r of e.getChildren())kc(r)&&(r.getValue()!==n&&r.setValue(n),t&&null!=r.getLatest().__checked&&r.setChecked(void 0),Fc(r.getFirstChild())||n++)}function bc(e){const t=new Set;if(uc(e)||t.has(e.getKey()))return;const n=e.getParent(),r=e.getNextSibling(),i=e.getPreviousSibling();if(uc(r)&&uc(i)){const n=i.getFirstChild();if(Fc(n)){n.append(e);const i=r.getFirstChild();Fc(i)&&(pc(n,i.getChildren()),r.remove(),t.add(r.getKey()))}}else if(uc(r)){const t=r.getFirstChild();if(Fc(t)){const n=t.getFirstChild();null!==n&&n.insertBefore(e)}}else if(uc(i)){const t=i.getFirstChild();Fc(t)&&t.append(e)}else if(Fc(n)){const t=wc().setTextFormat(e.getTextFormat()).setTextStyle(e.getTextStyle()),o=Oc(n.getListType()).setTextFormat(n.getTextFormat()).setTextStyle(n.getTextStyle());t.append(o),o.append(e),i?i.insertAfter(t):r?r.insertBefore(t):n.append(t)}}function _c(e){if(uc(e))return;const t=e.getParent(),n=t?t.getParent():void 0;if(Fc(n?n.getParent():void 0)&&kc(n)&&Fc(t)){const r=t?t.getFirstChild():void 0,i=t?t.getLastChild():void 0;if(e.is(r))n.insertBefore(e),t.isEmpty()&&n.remove();else if(e.is(i))n.insertAfter(e),t.isEmpty()&&n.remove();else{const r=t.getListType(),i=wc(),o=Oc(r);i.append(o),e.getPreviousSiblings().forEach((e=>o.append(e)));const s=wc(),l=Oc(r);s.append(l),pc(l,e.getNextSiblings()),n.insertBefore(i),n.insertAfter(s),n.replace(e)}}}function xc(...e){const t=[];for(const n of e)if(n&&"string"==typeof n)for(const[e]of n.matchAll(/\S+/g))t.push(e);return t}let Sc=class extends go{__value;__checked;$config(){return this.config("listitem",{$transform:e=>{if(null==e.__checked)return;const t=e.getParent();Fc(t)&&"check"!==t.getListType()&&null!=e.getChecked()&&e.setChecked(void 0)},extends:go,importDOM:{li:()=>({conversion:Cc,priority:0})}})}constructor(e=1,t=void 0,n){super(n),this.__value=void 0===e?1:e,this.__checked=t}afterCloneFrom(e){super.afterCloneFrom(e),this.__value=e.__value,this.__checked=e.__checked}createDOM(e){const t=document.createElement("li");return this.updateListItemDOM(null,t,e),t}updateListItemDOM(e,t,n){!function(e,t,n){const r=t.getParent();!Fc(r)||"check"!==r.getListType()||Fc(t.getFirstChild())?(e.removeAttribute("role"),e.removeAttribute("tabIndex"),e.removeAttribute("aria-checked")):(e.setAttribute("role","checkbox"),e.setAttribute("tabIndex","-1"),n&&t.__checked===n.__checked||e.setAttribute("aria-checked",t.getChecked()?"true":"false"))}(t,this,e),t.value=this.__value,function(e,t,n){const r=[],i=[],o=t.list,s=o?o.listitem:void 0;let l;if(o&&o.nested&&(l=o.nested.listitem),void 0!==s&&r.push(...xc(s)),o){const e=n.getParent(),t=Fc(e)&&"check"===e.getListType(),s=n.getChecked();t&&!s||i.push(o.listitemUnchecked),t&&s||i.push(o.listitemChecked),t&&r.push(s?o.listitemChecked:o.listitemUnchecked)}if(void 0!==l){const e=xc(l);n.getChildren().some((e=>Fc(e)))?r.push(...e):i.push(...e)}i.length>0&&Oa(e,...i),r.length>0&&La(e,...r)}(t,n.theme,this);const r=e?e.__style:"",i=this.__style;r!==i&&(""===i?t.removeAttribute("style"):t.style.cssText=i),function(e,t,n){const r=la(t.__textStyle);for(const t in r)e.style.setProperty(`--listitem-marker-${t}`,r[t]);if(n)for(const t in la(n.__textStyle))t in r||e.style.removeProperty(`--listitem-marker-${t}`)}(t,this,e)}updateDOM(e,t,n){const r=t;return this.updateListItemDOM(e,r,n),!1}updateFromJSON(e){return super.updateFromJSON(e).setValue(e.value).setChecked(e.checked)}exportDOM(e){const t=this.createDOM(e._config),n=this.getFormatType();n&&(t.style.textAlign=n);const r=this.getDirection();return r&&(t.dir=r),{element:t}}exportJSON(){return{...super.exportJSON(),checked:this.getChecked(),value:this.getValue()}}append(...e){for(let t=0;t{e.append(t)}))),this.remove(),0===n.getChildrenSize()&&n.remove(),e}insertAfter(e,t=!0){const n=this.getParentOrThrow();if(Fc(n)||sc(39),kc(e))return super.insertAfter(e,t);const r=this.getNextSiblings();if(n.insertAfter(e,t),0!==r.length){const i=Oc(n.getListType());r.forEach((e=>i.append(e))),e.insertAfter(i,t)}return e}remove(e){const t=this.getPreviousSibling(),n=this.getNextSibling();super.remove(e),t&&n&&uc(t)&&uc(n)&&(mc(t.getFirstChild(),n.getFirstChild()),n.remove())}insertNewAfter(e,t=!0){const n=wc().updateFromJSON(this.exportJSON()).setChecked(!this.getChecked()&&void 0);return this.insertAfter(n,t),n}collapseAtStart(e){const t=Eo();this.getChildren().forEach((e=>t.append(e)));const n=this.getParentOrThrow(),r=n.getParentOrThrow(),i=kc(r);if(1===n.getChildrenSize())if(i)n.remove(),r.select();else{n.insertBefore(t),n.remove();const r=e.anchor,i=e.focus,o=t.getKey();"element"===r.type&&r.getNode().is(this)&&r.set(o,r.offset,"element"),"element"===i.type&&i.getNode().is(this)&&i.set(o,i.offset,"element")}else n.insertBefore(t),this.remove();return!0}getValue(){return this.getLatest().__value}setValue(e){const t=this.getWritable();return t.__value=e,t}getChecked(){const e=this.getLatest();let t;const n=this.getParent();return Fc(n)&&(t=n.getListType()),"check"===t?Boolean(e.__checked):void 0}setChecked(e){const t=this.getWritable();return t.__checked=e,t}toggleChecked(){const e=this.getWritable();return e.setChecked(!e.__checked)}getIndent(){const e=this.getParent();if(null===e||!this.isAttached())return this.getLatest().__indent;let t=e.getParentOrThrow(),n=0;for(;kc(t);)t=t.getParentOrThrow().getParentOrThrow(),n++;return n}setIndent(e){"number"!=typeof e&&sc(117),(e=Math.floor(e))>=0||sc(199);let t=this.getIndent();for(;t!==e;)t0&&"INPUT"===t.children[0].tagName)return vc(t.children[0]);const t=e.getAttribute("aria-checked");return{node:wc("true"===t||"false"!==t&&void 0)}}function vc(e){return"checkbox"!==e.getAttribute("type")?{node:null}:{node:wc(e.hasAttribute("checked"))}}function wc(e){return Ws(new Sc(void 0,e))}function kc(e){return e instanceof Sc}let Tc=class extends go{__tag;__start;__listType;$config(){return this.config("list",{$transform:e=>{!function(e){const t=e.getNextSibling();Fc(t)&&e.getListType()===t.getListType()&&mc(e,t)}(e),yc(e)},extends:go,importDOM:{ol:()=>({conversion:Ac,priority:0}),ul:()=>({conversion:Ac,priority:0})}})}constructor(e="number",t=1,n){super(n);const r=Lc[e]||e;this.__listType=r,this.__tag="number"===r?"ol":"ul",this.__start=t}afterCloneFrom(e){super.afterCloneFrom(e),this.__listType=e.__listType,this.__tag=e.__tag,this.__start=e.__start}getTag(){return this.getLatest().__tag}setListType(e){const t=this.getWritable();return t.__listType=e,t.__tag="number"===e?"ol":"ul",t}getListType(){return this.getLatest().__listType}getStart(){return this.getLatest().__start}setStart(e){const t=this.getWritable();return t.__start=e,t}createDOM(e,t){const n=this.__tag,r=document.createElement(n);return 1!==this.__start&&r.setAttribute("start",String(this.__start)),r.__lexicalListType=this.__listType,Ec(r,e.theme,this),r}updateDOM(e,t,n){return e.__tag!==this.__tag||e.__listType!==this.__listType||(Ec(t,n.theme,this),!1)}updateFromJSON(e){return super.updateFromJSON(e).setListType(e.listType).setStart(e.start)}exportDOM(e){const t=this.createDOM(e._config,e);return Js(t)&&(1!==this.__start&&t.setAttribute("start",String(this.__start)),"check"===this.__listType&&t.setAttribute("__lexicalListType","check")),{element:t}}exportJSON(){return{...super.exportJSON(),listType:this.getListType(),start:this.getStart(),tag:this.getTag()}}canBeEmpty(){return!1}canIndent(){return!1}splice(e,t,n){let r=n;for(let e=0;e1?r.push(...e):i.push(...e)}}i.length>0&&Oa(e,...i),r.length>0&&La(e,...r)}function Nc(e){const t=[];for(let n=0;n1&&e.forEach((e=>{Fc(e)&&t.push(dc(e))}))}else t.push(dc(r))}return t}function Ac(e){const t=e.nodeName.toLowerCase();let n=null;return"ol"===t?n=Oc("number",e.start):"ul"===t&&(n=function(e){if("check"===e.getAttribute("__lexicallisttype")||e.classList.contains("contains-task-list")||"1"===e.getAttribute("data-is-checklist"))return!0;for(const t of e.childNodes)if(Js(t)&&t.hasAttribute("aria-checked"))return!0;return!1}(e)?Oc("check"):Oc("bullet")),{after:Nc,node:n}}const Lc={ol:"number",ul:"bullet"};function Oc(e="number",t=1){return Ws(new Tc(e,t))}function Fc(e){return e instanceof Tc}const Rc=on("UPDATE_LIST_START_COMMAND"),Ic=on("INSERT_UNORDERED_LIST_COMMAND"),Pc=on("INSERT_ORDERED_LIST_COMMAND"),Mc=on("REMOVE_LIST_COMMAND");function Dc(e){return Aa(e.registerCommand(Pc,(()=>(gc("number"),!0)),1),e.registerCommand(Rc,(e=>{const{listNodeKey:t,newStart:n}=e,r=is(t);return!!Fc(r)&&("number"===r.getListType()&&(r.setStart(n),yc(r)),!0)}),1),e.registerCommand(Ic,(()=>(gc("bullet"),!0)),1),e.registerCommand(Mc,(()=>(function(){const e=Li();if(gi(e)){const t=new Set,n=e.getNodes(),r=e.anchor.getNode();if(hc(r,n))t.add(ac(r));else for(let e=0;efunction(){const e=Li();if(!gi(e)||!e.isCollapsed())return!1;const t=e.anchor.getNode();if(!kc(t)||0!==t.getChildrenSize())return!1;const n=ac(t),r=t.getParent();Fc(r)||sc(40);const i=r.getParent();let o;if(Ks(i))o=Eo(),n.insertAfter(o);else{if(!kc(i))return!1;o=wc(),i.insertAfter(o)}o.setTextStyle(e.style).setTextFormat(e.format).select();const s=t.getNextSiblings();if(s.length>0){const e=Oc(r.getListType());if(kc(o)){const t=wc();t.append(e),o.insertAfter(t)}else o.insertAfter(e);e.append(...s)}return function(e){let t=e;for(;null==t.getNextSibling()&&null==t.getPreviousSibling();){const e=t.getParent();if(null==e||!kc(e)&&!Fc(e))break;t=e}t.remove()}(t),!0}()),1),e.registerNodeTransform(Sc,(e=>{const t=e.getFirstChild();if(t){if(ri(t)){const n=t.getStyle(),r=t.getFormat();e.getTextStyle()!==n&&e.setTextStyle(n),e.getTextFormat()!==r&&e.setTextFormat(r)}}else{const t=Li();gi(t)&&(t.style!==e.getTextStyle()||t.format!==e.getTextFormat())&&t.isCollapsed()&&e.is(t.anchor.getNode())&&e.setTextStyle(t.style).setTextFormat(t.format)}})),e.registerNodeTransform(jr,(e=>{const t=e.getParent();if(kc(t)&&e.is(t.getFirstChild())){const n=e.getStyle(),r=e.getFormat();n===t.getTextStyle()&&r===t.getTextFormat()||t.setTextStyle(n).setTextFormat(r)}})))}function Bc(e,t){const n=Go(t)?t.body.childNodes:t.childNodes;let r=[];const i=[];for(const t of n)if(!Hc.has(t.nodeName)){const n=Kc(t,e,i,!1);null!==n&&(r=r.concat(n))}return function(e){for(const t of e)t.getNextSibling()instanceof wo&&t.insertAfter(Br());for(const t of e){const e=t.getChildren();for(const n of e)t.insertBefore(n);t.remove()}}(i),r}function zc(e,t){if("undefined"==typeof document||"undefined"==typeof window&&void 0===global.window)throw new Error("To use $generateHtmlFromNodes in headless mode please initialize a headless browser implementation such as JSDom before calling this function.");const n=document.createElement("div"),r=us().getChildren();for(let i=0;i{const e=new wo;return n.push(e),e}:Eo)),null==l?h.length>0?s=s.concat(h):el(e)&&function(e){return null!=e.nextSibling&&null!=e.previousSibling&&(Qs(e.nextSibling)&&Qs(e.previousSibling))}(e)&&(s=s.concat(Br())):po(l)&&l.append(...h),s}function Uc(e,...t){const n=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",e);for(const e of t)r.append("v",e);throw n.search=r.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function Wc(e,t,n){const r=e.getData("application/x-lexical-editor");if(r)try{const e=JSON.parse(r);if(e.namespace===n._config.namespace&&Array.isArray(e.nodes))return Vc(n,function(e){const t=[];for(let n=0;ne}).createHTML(e):e}(i),"text/html")),t)}catch(e){console.error(e)}const s=o||e.getData("text/uri-list");if(null!=s)if(gi(t)){const e=s.split(/(\r?\n|\t)/);""===e[e.length-1]&&e.pop();for(let t=0;t{e.update((()=>{r(Gc(e,t,n))}))}));const r=e.getRootElement(),i=e._window||window,o=i.document,s=Zs(i);if(null===r||null===s)return!1;const l=o.createElement("span");l.style.cssText="position: fixed; top: -1000px;",l.append(o.createTextNode("#")),r.append(l);const a=new Range;return a.setStart(l,0),a.setEnd(l,1),s.removeAllRanges(),s.addRange(a),new Promise(((t,r)=>{const s=e.registerCommand(Hn,(r=>(Pa(r,ClipboardEvent)&&(s(),null!==jc&&(i.clearTimeout(jc),jc=null),t(Gc(e,r,n))),!0)),4);jc=i.setTimeout((()=>{s(),jc=null,t(!1)}),50),o.execCommand("copy"),l.remove()}))}function Gc(e,t,n){if(void 0===n){const t=Zs(e._window),r=Li();if(!r||r.isCollapsed())return!1;if(!t)return!1;const i=t.anchorNode,o=t.focusNode;if(null!==i&&null!==o&&!Ho(e,i,o))return!1;n=Yc(r)}t.preventDefault();const r=t.clipboardData;return null!==r&&(function(e,t){for(const[n]of Jc)void 0===t[n]&&e.setData(n,"");for(const n in t){const r=t[n];void 0!==r&&e.setData(n,r)}}(r,n),!0)}const Jc=[["text/html",function(e,t=Li()){return null==t&&Uc(166),gi(t)&&t.isCollapsed()||0===t.getNodes().length?"":zc(e,t)}],["application/x-lexical-editor",function(e,t=Li()){return null==t&&Uc(166),gi(t)&&t.isCollapsed()||0===t.getNodes().length?null:JSON.stringify(function(e,t){const n=[],r=us().getChildren();for(let i=0;i({conversion:pu,priority:0})}}exportDOM(e){const{element:t}=super.exportDOM(e);if(Js(t)){this.isEmpty()&&t.append(document.createElement("br"));const e=this.getFormatType();e&&(t.style.textAlign=e);const n=this.getDirection();n&&(t.dir=n)}return{element:t}}static importJSON(e){return cu().updateFromJSON(e)}insertNewAfter(e,t){const n=Eo(),r=this.getDirection();return n.setDirection(r),this.insertAfter(n,t),n}collapseAtStart(){const e=Eo();return this.getChildren().forEach((t=>e.append(t))),this.replace(e),!0}canMergeWhenEmpty(){return!0}};function cu(){return Ws(new au)}function uu(e){return e instanceof au}let du=class e extends go{__tag;static getType(){return"heading"}static clone(t){return new e(t.__tag,t.__key)}constructor(e,t){super(t),this.__tag=e}getTag(){return this.__tag}setTag(e){const t=this.getWritable();return this.__tag=e,t}createDOM(e){const t=this.__tag,n=document.createElement(t),r=e.theme.heading;if(void 0!==r){La(n,r[t])}return n}updateDOM(e,t,n){return e.__tag!==this.__tag}static importDOM(){return{h1:e=>({conversion:gu,priority:0}),h2:e=>({conversion:gu,priority:0}),h3:e=>({conversion:gu,priority:0}),h4:e=>({conversion:gu,priority:0}),h5:e=>({conversion:gu,priority:0}),h6:e=>({conversion:gu,priority:0}),p:e=>{const t=e.firstChild;return null!==t&&hu(t)?{conversion:()=>({node:null}),priority:3}:null},span:e=>hu(e)?{conversion:e=>({node:fu("h1")}),priority:3}:null}}exportDOM(e){const{element:t}=super.exportDOM(e);if(Js(t)){this.isEmpty()&&t.append(document.createElement("br"));const e=this.getFormatType();e&&(t.style.textAlign=e);const n=this.getDirection();n&&(t.dir=n)}return{element:t}}static importJSON(e){return fu(e.tag).updateFromJSON(e)}updateFromJSON(e){return super.updateFromJSON(e).setTag(e.tag)}exportJSON(){return{...super.exportJSON(),tag:this.getTag()}}insertNewAfter(e,t=!0){const n=e?e.anchor.offset:0,r=this.getLastDescendant(),i=!r||e&&e.anchor.key===r.getKey()&&n===r.getTextContentSize()||!e?Eo():fu(this.getTag()),o=this.getDirection();if(i.setDirection(o),this.insertAfter(i,t),0===n&&!this.isEmpty()&&e){const e=Eo();e.select(),this.replace(e,!0)}return i}collapseAtStart(){const e=this.isEmpty()?Eo():fu(this.getTag());return this.getChildren().forEach((t=>e.append(t))),this.replace(e),!0}extractWithChild(){return!0}};function hu(e){return"span"===e.nodeName.toLowerCase()&&"26pt"===e.style.fontSize}function gu(e){const t=e.nodeName.toLowerCase();let n=null;return"h1"!==t&&"h2"!==t&&"h3"!==t&&"h4"!==t&&"h5"!==t&&"h6"!==t||(n=fu(t),null!==e.style&&(ll(e,n),n.setFormat(e.style.textAlign))),{node:n}}function pu(e){const t=cu();return null!==e.style&&(t.setFormat(e.style.textAlign),ll(e,t)),{node:t}}function fu(e="h1"){return Ws(new du(e))}function mu(e){return e instanceof du}function yu(e){let t=null;if(Pa(e,DragEvent)?t=e.dataTransfer:Pa(e,ClipboardEvent)&&(t=e.clipboardData),null===t)return[!1,[],!1];const n=t.types,r=n.includes("Files"),i=n.includes("text/html")||n.includes("text/plain");return[r,Array.from(t.files),i]}function bu(e){const t=Li();if(!gi(t))return!1;const n=new Set,r=t.getNodes();for(let t=0;tpo(e)&&!e.isInline()));if(null===s)continue;const l=s.getKey();s.canIndent()&&!n.has(l)&&(n.add(l),e(s))}return n.size>0}function _u(e){return yo(ls(e))}function xu(e){for(const t of["lowercase","uppercase","capitalize"])e.hasFormat(t)&&e.toggleFormat(t)}function Su(e){return Aa(e.registerCommand(an,(e=>{const t=Li();return!!fi(t)&&(t.clear(),!0)}),0),e.registerCommand(cn,(e=>{const t=Li();return gi(t)?(t.deleteCharacter(e),!0):!!fi(t)&&(t.deleteNodes(),!0)}),0),e.registerCommand(fn,(e=>{const t=Li();return!!gi(t)&&(t.deleteWord(e),!0)}),0),e.registerCommand(mn,(e=>{const t=Li();return!!gi(t)&&(t.deleteLine(e),!0)}),0),e.registerCommand(hn,(t=>{const n=Li();if("string"==typeof t)null!==n&&n.insertText(t);else{if(null===n)return!1;const r=t.dataTransfer;if(null!=r)Wc(r,n,e);else if(gi(n)){const e=t.data;return e&&n.insertText(e),!0}}return!0}),0),e.registerCommand(pn,(()=>{const e=Li();return!!gi(e)&&(e.removeText(),!0)}),0),e.registerCommand(yn,(e=>{const t=Li();return!!gi(t)&&(t.formatText(e),!0)}),0),e.registerCommand(Dn,(e=>{const t=Li();if(!gi(t)&&!fi(t))return!1;const n=t.getNodes();for(const t of n){const n=dl(t,(e=>po(e)&&!e.isInline()));null!==n&&n.setFormat(e)}return!0}),0),e.registerCommand(un,(e=>{const t=Li();return!!gi(t)&&(t.insertLineBreak(e),!0)}),0),e.registerCommand(dn,(()=>{const e=Li();return!!gi(e)&&(e.insertParagraph(),!0)}),0),e.registerCommand(Rn,(()=>(Di([si()]),!0)),0),e.registerCommand(In,(()=>bu((e=>{const t=e.getIndent();e.setIndent(t+1)}))),0),e.registerCommand(Pn,(()=>bu((e=>{const t=e.getIndent();t>0&&e.setIndent(Math.max(0,t-1))}))),0),e.registerCommand(kn,(e=>{const t=Li();if(fi(t)){const n=t.getNodes();if(n.length>0)return e.preventDefault(),n[0].selectPrevious(),!0}else if(gi(t)){const n=Ls(t.focus,!0);if(!e.shiftKey&&yo(n)&&!n.isIsolated()&&!n.isInline())return n.selectPrevious(),e.preventDefault(),!0}return!1}),0),e.registerCommand(Tn,(e=>{const t=Li();if(fi(t)){const n=t.getNodes();if(n.length>0)return e.preventDefault(),n[0].selectNext(0,0),!0}else if(gi(t)){if(function(e){const t=e.focus;return"root"===t.key&&t.offset===us().getChildrenSize()}(t))return e.preventDefault(),!0;const n=Ls(t.focus,!1);if(!e.shiftKey&&yo(n)&&!n.isIsolated()&&!n.isInline())return n.selectNext(),e.preventDefault(),!0}return!1}),0),e.registerCommand(vn,(e=>{const t=Li();if(fi(t)){const n=t.getNodes();if(n.length>0)return e.preventDefault(),da(n[0])?n[0].selectNext(0,0):n[0].selectPrevious(),!0}if(!gi(t))return!1;if(ba(t,!0)){const n=e.shiftKey;return e.preventDefault(),xa(t,n,!0),!0}return!1}),0),e.registerCommand(Sn,(e=>{const t=Li();if(fi(t)){const n=t.getNodes();if(n.length>0)return e.preventDefault(),da(n[0])?n[0].selectPrevious():n[0].selectNext(0,0),!0}if(!gi(t))return!1;const n=e.shiftKey;return!!ba(t,!1)&&(e.preventDefault(),xa(t,n,!1),!0)}),0),e.registerCommand(An,(t=>{if(_u(t.target))return!1;const n=Li();if(gi(n)){if(function(e){if(!e.isCollapsed())return!1;const{anchor:t}=e;if(0!==t.offset)return!1;const n=t.getNode();if(_o(n))return!1;const r=function(e){const t=dl(e,(e=>po(e)&&!e.isInline()));return po(t)||ka(4,e.__key),t}(n);return r.getIndent()>0&&(r.is(n)||n.is(r.getFirstDescendant()))}(n))return t.preventDefault(),e.dispatchCommand(Pn,void 0);if(iu&&"ko-KR"===navigator.language)return!1}else if(!fi(n))return!1;return t.preventDefault(),e.dispatchCommand(cn,!0)}),0),e.registerCommand(On,(t=>{if(_u(t.target))return!1;const n=Li();return!(!gi(n)&&!fi(n))&&(t.preventDefault(),e.dispatchCommand(cn,!1))}),0),e.registerCommand(En,(t=>{const n=Li();if(!gi(n))return!1;if(xu(n),null!==t){if((iu||ru||su)&&nu)return!1;if(t.preventDefault(),t.shiftKey)return e.dispatchCommand(un,!1)}return e.dispatchCommand(dn,void 0)}),0),e.registerCommand(Ln,(()=>!!gi(Li())&&(e.blur(),!0)),0),e.registerCommand(Mn,(t=>{const[,n]=yu(t);if(n.length>0){const r=Xc(t.clientX,t.clientY);if(null!==r){const{offset:t,node:i}=r,o=ls(i);if(null!==o){const e=Ei();if(ri(o))e.anchor.set(o.getKey(),t,"text"),e.focus.set(o.getKey(),t,"text");else{const t=o.getParentOrThrow().getKey(),n=o.getIndexWithinParent()+1;e.anchor.set(t,n,"element"),e.focus.set(t,n,"element")}hs(vt(e))}e.dispatchCommand(lu,n)}return t.preventDefault(),!0}return!!gi(Li())}),0),e.registerCommand(Bn,(e=>{const[t]=yu(e),n=Li();return!(t&&!gi(n))}),0),e.registerCommand(zn,(e=>{const[t]=yu(e),n=Li();if(t&&!gi(n))return!1;const r=Xc(e.clientX,e.clientY);if(null!==r){yo(ls(r.node))&&e.preventDefault()}return!0}),0),e.registerCommand(Un,(()=>(function(e){const t=us();if(gi(e)){const t=e.anchor,n=e.focus,r=t.getNode().getTopLevelElementOrThrow().getParentOrThrow();return t.set(r.getKey(),0,"element"),n.set(r.getKey(),r.getChildrenSize(),"element"),vt(e),e}{const e=t.select(0,t.getChildrenSize());hs(vt(e))}}(),!0)),0),e.registerCommand(Hn,(t=>(Zc(e,Pa(t,ClipboardEvent)?t:null),!0)),0),e.registerCommand(Kn,(t=>(async function(e,t){await Zc(t,Pa(e,ClipboardEvent)?e:null),t.update((()=>{const e=Li();gi(e)?e.removeText():fi(e)&&e.getNodes().forEach((e=>e.remove()))}))}(t,e),!0)),0),e.registerCommand(gn,(t=>{const[,n,r]=yu(t);return n.length>0&&!r?(e.dispatchCommand(lu,n),!0):(!Ys(t.target)||!$o(t.target))&&(null!==Li()&&(function(e,t){e.preventDefault(),t.update((()=>{const n=Li(),r=Pa(e,InputEvent)||Pa(e,KeyboardEvent)?null:e.clipboardData;null!=r&&null!==n&&Wc(r,n,t)}),{tag:"paste"})}(t,e),!0))}),0),e.registerCommand(Nn,(e=>{const t=Li();return gi(t)&&xu(t),!1}),0),e.registerCommand(Fn,(e=>{const t=Li();return gi(t)&&xu(t),!1}),0))}var Cu;s.languages.javascript=s.languages.extend("clike",{"class-name":[s.languages.clike["class-name"],{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$A-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\.(?:constructor|prototype))/,lookbehind:!0}],keyword:[{pattern:/((?:^|\})\s*)catch\b/,lookbehind:!0},{pattern:/(^|[^.]|\.\.\.\s*)\b(?:as|assert(?=\s*\{)|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally(?=\s*(?:\{|$))|for|from(?=\s*(?:['"]|$))|function|(?:get|set)(?=\s*(?:[#\[$\w\xA0-\uFFFF]|$))|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/,lookbehind:!0}],function:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,number:{pattern:RegExp(/(^|[^\w$])/.source+"(?:"+/NaN|Infinity/.source+"|"+/0[bB][01]+(?:_[01]+)*n?/.source+"|"+/0[oO][0-7]+(?:_[0-7]+)*n?/.source+"|"+/0[xX][\dA-Fa-f]+(?:_[\dA-Fa-f]+)*n?/.source+"|"+/\d+(?:_\d+)*n/.source+"|"+/(?:\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\.\d+(?:_\d+)*)(?:[Ee][+-]?\d+(?:_\d+)*)?/.source+")"+/(?![\w$])/.source),lookbehind:!0},operator:/--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/}),s.languages.javascript["class-name"][0].pattern=/(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/,s.languages.insertBefore("javascript","keyword",{regex:{pattern:RegExp(/((?:^|[^$\w\xA0-\uFFFF."'\])\s]|\b(?:return|yield))\s*)/.source+/\//.source+"(?:"+/(?:\[(?:[^\]\\\r\n]|\\.)*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}/.source+"|"+/(?:\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.)*\])*\])*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}v[dgimyus]{0,7}/.source+")"+/(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/.source),lookbehind:!0,greedy:!0,inside:{"regex-source":{pattern:/^(\/)[\s\S]+(?=\/[a-z]*$)/,lookbehind:!0,alias:"language-regex",inside:s.languages.regex},"regex-delimiter":/^\/|\/$/,"regex-flags":/^[a-z]+$/}},"function-variable":{pattern:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)\s*=>))/,alias:"function"},parameter:[{pattern:/(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/,lookbehind:!0,inside:s.languages.javascript},{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i,lookbehind:!0,inside:s.languages.javascript},{pattern:/(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/,lookbehind:!0,inside:s.languages.javascript},{pattern:/((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*)\(\s*|\]\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*\{)/,lookbehind:!0,inside:s.languages.javascript}],constant:/\b[A-Z](?:[A-Z_]|\dx?)*\b/}),s.languages.insertBefore("javascript","string",{hashbang:{pattern:/^#!.*/,greedy:!0,alias:"comment"},"template-string":{pattern:/`(?:\\[\s\S]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}|(?!\$\{)[^\\`])*`/,greedy:!0,inside:{"template-punctuation":{pattern:/^`|`$/,alias:"string"},interpolation:{pattern:/((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}/,lookbehind:!0,inside:{"interpolation-punctuation":{pattern:/^\$\{|\}$/,alias:"punctuation"},rest:s.languages.javascript}},string:/[\s\S]+/}},"string-property":{pattern:/((?:^|[,{])[ \t]*)(["'])(?:\\(?:\r\n|[\s\S])|(?!\2)[^\\\r\n])*\2(?=\s*:)/m,lookbehind:!0,greedy:!0,alias:"property"}}),s.languages.insertBefore("javascript","operator",{"literal-property":{pattern:/((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m,lookbehind:!0,alias:"property"}}),s.languages.markup&&(s.languages.markup.tag.addInlined("script","javascript"),s.languages.markup.tag.addAttribute(/on(?:abort|blur|change|click|composition(?:end|start|update)|dblclick|error|focus(?:in|out)?|key(?:down|up)|load|mouse(?:down|enter|leave|move|out|over|up)|reset|resize|scroll|select|slotchange|submit|unload|wheel)/.source,"javascript")),s.languages.js=s.languages.javascript,function(e){var t=/(?:\\.|[^\\\n\r]|(?:\n|\r\n?)(?![\r\n]))/.source;function n(e){return e=e.replace(//g,(function(){return t})),RegExp(/((?:^|[^\\])(?:\\{2})*)/.source+"(?:"+e+")")}var r=/(?:\\.|``(?:[^`\r\n]|`(?!`))+``|`[^`\r\n]+`|[^\\|\r\n`])+/.source,i=/\|?__(?:\|__)+\|?(?:(?:\n|\r\n?)|(?![\s\S]))/.source.replace(/__/g,(function(){return r})),o=/\|?[ \t]*:?-{3,}:?[ \t]*(?:\|[ \t]*:?-{3,}:?[ \t]*)+\|?(?:\n|\r\n?)/.source;e.languages.markdown=e.languages.extend("markup",{}),e.languages.insertBefore("markdown","prolog",{"front-matter-block":{pattern:/(^(?:\s*[\r\n])?)---(?!.)[\s\S]*?[\r\n]---(?!.)/,lookbehind:!0,greedy:!0,inside:{punctuation:/^---|---$/,"front-matter":{pattern:/\S+(?:\s+\S+)*/,alias:["yaml","language-yaml"],inside:e.languages.yaml}}},blockquote:{pattern:/^>(?:[\t ]*>)*/m,alias:"punctuation"},table:{pattern:RegExp("^"+i+o+"(?:"+i+")*","m"),inside:{"table-data-rows":{pattern:RegExp("^("+i+o+")(?:"+i+")*$"),lookbehind:!0,inside:{"table-data":{pattern:RegExp(r),inside:e.languages.markdown},punctuation:/\|/}},"table-line":{pattern:RegExp("^("+i+")"+o+"$"),lookbehind:!0,inside:{punctuation:/\||:?-{3,}:?/}},"table-header-row":{pattern:RegExp("^"+i+"$"),inside:{"table-header":{pattern:RegExp(r),alias:"important",inside:e.languages.markdown},punctuation:/\|/}}}},code:[{pattern:/((?:^|\n)[ \t]*\n|(?:^|\r\n?)[ \t]*\r\n?)(?: {4}|\t).+(?:(?:\n|\r\n?)(?: {4}|\t).+)*/,lookbehind:!0,alias:"keyword"},{pattern:/^```[\s\S]*?^```$/m,greedy:!0,inside:{"code-block":{pattern:/^(```.*(?:\n|\r\n?))[\s\S]+?(?=(?:\n|\r\n?)^```$)/m,lookbehind:!0},"code-language":{pattern:/^(```).+/,lookbehind:!0},punctuation:/```/}}],title:[{pattern:/\S.*(?:\n|\r\n?)(?:==+|--+)(?=[ \t]*$)/m,alias:"important",inside:{punctuation:/==+$|--+$/}},{pattern:/(^\s*)#.+/m,lookbehind:!0,alias:"important",inside:{punctuation:/^#+|#+$/}}],hr:{pattern:/(^\s*)([*-])(?:[\t ]*\2){2,}(?=\s*$)/m,lookbehind:!0,alias:"punctuation"},list:{pattern:/(^\s*)(?:[*+-]|\d+\.)(?=[\t ].)/m,lookbehind:!0,alias:"punctuation"},"url-reference":{pattern:/!?\[[^\]]+\]:[\t ]+(?:\S+|<(?:\\.|[^>\\])+>)(?:[\t ]+(?:"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\((?:\\.|[^)\\])*\)))?/,inside:{variable:{pattern:/^(!?\[)[^\]]+/,lookbehind:!0},string:/(?:"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\((?:\\.|[^)\\])*\))$/,punctuation:/^[\[\]!:]|[<>]/},alias:"url"},bold:{pattern:n(/\b__(?:(?!_)|_(?:(?!_))+_)+__\b|\*\*(?:(?!\*)|\*(?:(?!\*))+\*)+\*\*/.source),lookbehind:!0,greedy:!0,inside:{content:{pattern:/(^..)[\s\S]+(?=..$)/,lookbehind:!0,inside:{}},punctuation:/\*\*|__/}},italic:{pattern:n(/\b_(?:(?!_)|__(?:(?!_))+__)+_\b|\*(?:(?!\*)|\*\*(?:(?!\*))+\*\*)+\*/.source),lookbehind:!0,greedy:!0,inside:{content:{pattern:/(^.)[\s\S]+(?=.$)/,lookbehind:!0,inside:{}},punctuation:/[*_]/}},strike:{pattern:n(/(~~?)(?:(?!~))+\2/.source),lookbehind:!0,greedy:!0,inside:{content:{pattern:/(^~~?)[\s\S]+(?=\1$)/,lookbehind:!0,inside:{}},punctuation:/~~?/}},"code-snippet":{pattern:/(^|[^\\`])(?:``[^`\r\n]+(?:`[^`\r\n]+)*``(?!`)|`[^`\r\n]+`(?!`))/,lookbehind:!0,greedy:!0,alias:["code","keyword"]},url:{pattern:n(/!?\[(?:(?!\]))+\](?:\([^\s)]+(?:[\t ]+"(?:\\.|[^"\\])*")?\)|[ \t]?\[(?:(?!\]))+\])/.source),lookbehind:!0,greedy:!0,inside:{operator:/^!/,content:{pattern:/(^\[)[^\]]+(?=\])/,lookbehind:!0,inside:{}},variable:{pattern:/(^\][ \t]?\[)[^\]]+(?=\]$)/,lookbehind:!0},url:{pattern:/(^\]\()[^\s)]+/,lookbehind:!0},string:{pattern:/(^[ \t]+)"(?:\\.|[^"\\])*"(?=\)$)/,lookbehind:!0}}}}),["url","bold","italic","strike"].forEach((function(t){["url","bold","italic","strike","code-snippet"].forEach((function(n){t!==n&&(e.languages.markdown[t].inside.content.inside[n]=e.languages.markdown[n])}))})),e.hooks.add("after-tokenize",(function(e){"markdown"!==e.language&&"md"!==e.language||function e(t){if(t&&"string"!=typeof t)for(var n=0,r=t.length;n",quot:'"'},a=String.fromCodePoint||String.fromCharCode;e.languages.md=e.languages.markdown}(s),s.languages.c=s.languages.extend("clike",{comment:{pattern:/\/\/(?:[^\r\n\\]|\\(?:\r\n?|\n|(?![\r\n])))*|\/\*[\s\S]*?(?:\*\/|$)/,greedy:!0},string:{pattern:/"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"/,greedy:!0},"class-name":{pattern:/(\b(?:enum|struct)\s+(?:__attribute__\s*\(\([\s\S]*?\)\)\s*)?)\w+|\b[a-z]\w*_t\b/,lookbehind:!0},keyword:/\b(?:_Alignas|_Alignof|_Atomic|_Bool|_Complex|_Generic|_Imaginary|_Noreturn|_Static_assert|_Thread_local|__attribute__|asm|auto|break|case|char|const|continue|default|do|double|else|enum|extern|float|for|goto|if|inline|int|long|register|return|short|signed|sizeof|static|struct|switch|typedef|typeof|union|unsigned|void|volatile|while)\b/,function:/\b[a-z_]\w*(?=\s*\()/i,number:/(?:\b0x(?:[\da-f]+(?:\.[\da-f]*)?|\.[\da-f]+)(?:p[+-]?\d+)?|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?)[ful]{0,4}/i,operator:/>>=?|<<=?|->|([-+&|:])\1|[?:~]|[-+*/%&|^!=<>]=?/}),s.languages.insertBefore("c","string",{char:{pattern:/'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n]){0,32}'/,greedy:!0}}),s.languages.insertBefore("c","string",{macro:{pattern:/(^[\t ]*)#\s*[a-z](?:[^\r\n\\/]|\/(?!\*)|\/\*(?:[^*]|\*(?!\/))*\*\/|\\(?:\r\n|[\s\S]))*/im,lookbehind:!0,greedy:!0,alias:"property",inside:{string:[{pattern:/^(#\s*include\s*)<[^>]+>/,lookbehind:!0},s.languages.c.string],char:s.languages.c.char,comment:s.languages.c.comment,"macro-name":[{pattern:/(^#\s*define\s+)\w+\b(?!\()/i,lookbehind:!0},{pattern:/(^#\s*define\s+)\w+\b(?=\()/i,lookbehind:!0,alias:"function"}],directive:{pattern:/^(#\s*)[a-z]+/,lookbehind:!0,alias:"keyword"},"directive-hash":/^#/,punctuation:/##|\\(?=[\r\n])/,expression:{pattern:/\S[\s\S]*/,inside:s.languages.c}}}}),s.languages.insertBefore("c","function",{constant:/\b(?:EOF|NULL|SEEK_CUR|SEEK_END|SEEK_SET|__DATE__|__FILE__|__LINE__|__TIMESTAMP__|__TIME__|__func__|stderr|stdin|stdout)\b/}),delete s.languages.c.boolean,function(e){var t=/(?:"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"|'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n])*')/;e.languages.css={comment:/\/\*[\s\S]*?\*\//,atrule:{pattern:RegExp("@[\\w-](?:"+/[^;{\s"']|\s+(?!\s)/.source+"|"+t.source+")*?"+/(?:;|(?=\s*\{))/.source),inside:{rule:/^@[\w-]+/,"selector-function-argument":{pattern:/(\bselector\s*\(\s*(?![\s)]))(?:[^()\s]|\s+(?![\s)])|\((?:[^()]|\([^()]*\))*\))+(?=\s*\))/,lookbehind:!0,alias:"selector"},keyword:{pattern:/(^|[^\w-])(?:and|not|only|or)(?![\w-])/,lookbehind:!0}}},url:{pattern:RegExp("\\burl\\((?:"+t.source+"|"+/(?:[^\\\r\n()"']|\\[\s\S])*/.source+")\\)","i"),greedy:!0,inside:{function:/^url/i,punctuation:/^\(|\)$/,string:{pattern:RegExp("^"+t.source+"$"),alias:"url"}}},selector:{pattern:RegExp("(^|[{}\\s])[^{}\\s](?:[^{};\"'\\s]|\\s+(?![\\s{])|"+t.source+")*(?=\\s*\\{)"),lookbehind:!0},string:{pattern:t,greedy:!0},property:{pattern:/(^|[^-\w\xA0-\uFFFF])(?!\s)[-_a-z\xA0-\uFFFF](?:(?!\s)[-\w\xA0-\uFFFF])*(?=\s*:)/i,lookbehind:!0},important:/!important\b/i,function:{pattern:/(^|[^-a-z0-9])[-a-z0-9]+(?=\()/i,lookbehind:!0},punctuation:/[(){};:,]/},e.languages.css.atrule.inside.rest=e.languages.css;var n=e.languages.markup;n&&(n.tag.addInlined("style","css"),n.tag.addAttribute("style","css"))}(s),s.languages.objectivec=s.languages.extend("c",{string:{pattern:/@?"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"/,greedy:!0},keyword:/\b(?:asm|auto|break|case|char|const|continue|default|do|double|else|enum|extern|float|for|goto|if|in|inline|int|long|register|return|self|short|signed|sizeof|static|struct|super|switch|typedef|typeof|union|unsigned|void|volatile|while)\b|(?:@interface|@end|@implementation|@protocol|@class|@public|@protected|@private|@property|@try|@catch|@finally|@throw|@synthesize|@dynamic|@selector)\b/,operator:/-[->]?|\+\+?|!=?|<>?=?|==?|&&?|\|\|?|[~^%?*\/@]/}),delete s.languages.objectivec["class-name"],s.languages.objc=s.languages.objectivec,s.languages.sql={comment:{pattern:/(^|[^\\])(?:\/\*[\s\S]*?\*\/|(?:--|\/\/|#).*)/,lookbehind:!0},variable:[{pattern:/@(["'`])(?:\\[\s\S]|(?!\1)[^\\])+\1/,greedy:!0},/@[\w.$]+/],string:{pattern:/(^|[^@\\])("|')(?:\\[\s\S]|(?!\2)[^\\]|\2\2)*\2/,greedy:!0,lookbehind:!0},identifier:{pattern:/(^|[^@\\])`(?:\\[\s\S]|[^`\\]|``)*`/,greedy:!0,lookbehind:!0,inside:{punctuation:/^`|`$/}},function:/\b(?:AVG|COUNT|FIRST|FORMAT|LAST|LCASE|LEN|MAX|MID|MIN|MOD|NOW|ROUND|SUM|UCASE)(?=\s*\()/i,keyword:/\b(?:ACTION|ADD|AFTER|ALGORITHM|ALL|ALTER|ANALYZE|ANY|APPLY|AS|ASC|AUTHORIZATION|AUTO_INCREMENT|BACKUP|BDB|BEGIN|BERKELEYDB|BIGINT|BINARY|BIT|BLOB|BOOL|BOOLEAN|BREAK|BROWSE|BTREE|BULK|BY|CALL|CASCADED?|CASE|CHAIN|CHAR(?:ACTER|SET)?|CHECK(?:POINT)?|CLOSE|CLUSTERED|COALESCE|COLLATE|COLUMNS?|COMMENT|COMMIT(?:TED)?|COMPUTE|CONNECT|CONSISTENT|CONSTRAINT|CONTAINS(?:TABLE)?|CONTINUE|CONVERT|CREATE|CROSS|CURRENT(?:_DATE|_TIME|_TIMESTAMP|_USER)?|CURSOR|CYCLE|DATA(?:BASES?)?|DATE(?:TIME)?|DAY|DBCC|DEALLOCATE|DEC|DECIMAL|DECLARE|DEFAULT|DEFINER|DELAYED|DELETE|DELIMITERS?|DENY|DESC|DESCRIBE|DETERMINISTIC|DISABLE|DISCARD|DISK|DISTINCT|DISTINCTROW|DISTRIBUTED|DO|DOUBLE|DROP|DUMMY|DUMP(?:FILE)?|DUPLICATE|ELSE(?:IF)?|ENABLE|ENCLOSED|END|ENGINE|ENUM|ERRLVL|ERRORS|ESCAPED?|EXCEPT|EXEC(?:UTE)?|EXISTS|EXIT|EXPLAIN|EXTENDED|FETCH|FIELDS|FILE|FILLFACTOR|FIRST|FIXED|FLOAT|FOLLOWING|FOR(?: EACH ROW)?|FORCE|FOREIGN|FREETEXT(?:TABLE)?|FROM|FULL|FUNCTION|GEOMETRY(?:COLLECTION)?|GLOBAL|GOTO|GRANT|GROUP|HANDLER|HASH|HAVING|HOLDLOCK|HOUR|IDENTITY(?:COL|_INSERT)?|IF|IGNORE|IMPORT|INDEX|INFILE|INNER|INNODB|INOUT|INSERT|INT|INTEGER|INTERSECT|INTERVAL|INTO|INVOKER|ISOLATION|ITERATE|JOIN|KEYS?|KILL|LANGUAGE|LAST|LEAVE|LEFT|LEVEL|LIMIT|LINENO|LINES|LINESTRING|LOAD|LOCAL|LOCK|LONG(?:BLOB|TEXT)|LOOP|MATCH(?:ED)?|MEDIUM(?:BLOB|INT|TEXT)|MERGE|MIDDLEINT|MINUTE|MODE|MODIFIES|MODIFY|MONTH|MULTI(?:LINESTRING|POINT|POLYGON)|NATIONAL|NATURAL|NCHAR|NEXT|NO|NONCLUSTERED|NULLIF|NUMERIC|OFF?|OFFSETS?|ON|OPEN(?:DATASOURCE|QUERY|ROWSET)?|OPTIMIZE|OPTION(?:ALLY)?|ORDER|OUT(?:ER|FILE)?|OVER|PARTIAL|PARTITION|PERCENT|PIVOT|PLAN|POINT|POLYGON|PRECEDING|PRECISION|PREPARE|PREV|PRIMARY|PRINT|PRIVILEGES|PROC(?:EDURE)?|PUBLIC|PURGE|QUICK|RAISERROR|READS?|REAL|RECONFIGURE|REFERENCES|RELEASE|RENAME|REPEAT(?:ABLE)?|REPLACE|REPLICATION|REQUIRE|RESIGNAL|RESTORE|RESTRICT|RETURN(?:ING|S)?|REVOKE|RIGHT|ROLLBACK|ROUTINE|ROW(?:COUNT|GUIDCOL|S)?|RTREE|RULE|SAVE(?:POINT)?|SCHEMA|SECOND|SELECT|SERIAL(?:IZABLE)?|SESSION(?:_USER)?|SET(?:USER)?|SHARE|SHOW|SHUTDOWN|SIMPLE|SMALLINT|SNAPSHOT|SOME|SONAME|SQL|START(?:ING)?|STATISTICS|STATUS|STRIPED|SYSTEM_USER|TABLES?|TABLESPACE|TEMP(?:ORARY|TABLE)?|TERMINATED|TEXT(?:SIZE)?|THEN|TIME(?:STAMP)?|TINY(?:BLOB|INT|TEXT)|TOP?|TRAN(?:SACTIONS?)?|TRIGGER|TRUNCATE|TSEQUAL|TYPES?|UNBOUNDED|UNCOMMITTED|UNDEFINED|UNION|UNIQUE|UNLOCK|UNPIVOT|UNSIGNED|UPDATE(?:TEXT)?|USAGE|USE|USER|USING|VALUES?|VAR(?:BINARY|CHAR|CHARACTER|YING)|VIEW|WAITFOR|WARNINGS|WHEN|WHERE|WHILE|WITH(?: ROLLUP|IN)?|WORK|WRITE(?:TEXT)?|YEAR)\b/i,boolean:/\b(?:FALSE|NULL|TRUE)\b/i,number:/\b0x[\da-f]+\b|\b\d+(?:\.\d*)?|\B\.\d+\b/i,operator:/[-+*\/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?|\b(?:AND|BETWEEN|DIV|ILIKE|IN|IS|LIKE|NOT|OR|REGEXP|RLIKE|SOUNDS LIKE|XOR)\b/i,punctuation:/[;[\]()`,.]/},(Cu=s.languages.powershell={comment:[{pattern:/(^|[^`])<#[\s\S]*?#>/,lookbehind:!0},{pattern:/(^|[^`])#.*/,lookbehind:!0}],string:[{pattern:/"(?:`[\s\S]|[^`"])*"/,greedy:!0,inside:null},{pattern:/'(?:[^']|'')*'/,greedy:!0}],namespace:/\[[a-z](?:\[(?:\[[^\]]*\]|[^\[\]])*\]|[^\[\]])*\]/i,boolean:/\$(?:false|true)\b/i,variable:/\$\w+\b/,function:[/\b(?:Add|Approve|Assert|Backup|Block|Checkpoint|Clear|Close|Compare|Complete|Compress|Confirm|Connect|Convert|ConvertFrom|ConvertTo|Copy|Debug|Deny|Disable|Disconnect|Dismount|Edit|Enable|Enter|Exit|Expand|Export|Find|ForEach|Format|Get|Grant|Group|Hide|Import|Initialize|Install|Invoke|Join|Limit|Lock|Measure|Merge|Move|New|Open|Optimize|Out|Ping|Pop|Protect|Publish|Push|Read|Receive|Redo|Register|Remove|Rename|Repair|Request|Reset|Resize|Resolve|Restart|Restore|Resume|Revoke|Save|Search|Select|Send|Set|Show|Skip|Sort|Split|Start|Step|Stop|Submit|Suspend|Switch|Sync|Tee|Test|Trace|Unblock|Undo|Uninstall|Unlock|Unprotect|Unpublish|Unregister|Update|Use|Wait|Watch|Where|Write)-[a-z]+\b/i,/\b(?:ac|cat|chdir|clc|cli|clp|clv|compare|copy|cp|cpi|cpp|cvpa|dbp|del|diff|dir|ebp|echo|epal|epcsv|epsn|erase|fc|fl|ft|fw|gal|gbp|gc|gci|gcs|gdr|gi|gl|gm|gp|gps|group|gsv|gu|gv|gwmi|iex|ii|ipal|ipcsv|ipsn|irm|iwmi|iwr|kill|lp|ls|measure|mi|mount|move|mp|mv|nal|ndr|ni|nv|ogv|popd|ps|pushd|pwd|rbp|rd|rdr|ren|ri|rm|rmdir|rni|rnp|rp|rv|rvpa|rwmi|sal|saps|sasv|sbp|sc|select|set|shcm|si|sl|sleep|sls|sort|sp|spps|spsv|start|sv|swmi|tee|trcm|type|write)\b/i],keyword:/\b(?:Begin|Break|Catch|Class|Continue|Data|Define|Do|DynamicParam|Else|ElseIf|End|Exit|Filter|Finally|For|ForEach|From|Function|If|InlineScript|Parallel|Param|Process|Return|Sequence|Switch|Throw|Trap|Try|Until|Using|Var|While|Workflow)\b/i,operator:{pattern:/(^|\W)(?:!|-(?:b?(?:and|x?or)|as|(?:Not)?(?:Contains|In|Like|Match)|eq|ge|gt|is(?:Not)?|Join|le|lt|ne|not|Replace|sh[lr])\b|-[-=]?|\+[+=]?|[*\/%]=?)/i,lookbehind:!0},punctuation:/[|{}[\];(),.]/}).string[0].inside={function:{pattern:/(^|[^`])\$\((?:\$\([^\r\n()]*\)|(?!\$\()[^\r\n)])*\)/,lookbehind:!0,inside:Cu},boolean:Cu.boolean,variable:Cu.variable};var vu;vu||(vu=1,s.languages.python={comment:{pattern:/(^|[^\\])#.*/,lookbehind:!0,greedy:!0},"string-interpolation":{pattern:/(?:f|fr|rf)(?:("""|''')[\s\S]*?\1|("|')(?:\\.|(?!\2)[^\\\r\n])*\2)/i,greedy:!0,inside:{interpolation:{pattern:/((?:^|[^{])(?:\{\{)*)\{(?!\{)(?:[^{}]|\{(?!\{)(?:[^{}]|\{(?!\{)(?:[^{}])+\})+\})+\}/,lookbehind:!0,inside:{"format-spec":{pattern:/(:)[^:(){}]+(?=\}$)/,lookbehind:!0},"conversion-option":{pattern:/![sra](?=[:}]$)/,alias:"punctuation"},rest:null}},string:/[\s\S]+/}},"triple-quoted-string":{pattern:/(?:[rub]|br|rb)?("""|''')[\s\S]*?\1/i,greedy:!0,alias:"string"},string:{pattern:/(?:[rub]|br|rb)?("|')(?:\\.|(?!\1)[^\\\r\n])*\1/i,greedy:!0},function:{pattern:/((?:^|\s)def[ \t]+)[a-zA-Z_]\w*(?=\s*\()/g,lookbehind:!0},"class-name":{pattern:/(\bclass\s+)\w+/i,lookbehind:!0},decorator:{pattern:/(^[\t ]*)@\w+(?:\.\w+)*/m,lookbehind:!0,alias:["annotation","punctuation"],inside:{punctuation:/\./}},keyword:/\b(?:_(?=\s*:)|and|as|assert|async|await|break|case|class|continue|def|del|elif|else|except|exec|finally|for|from|global|if|import|in|is|lambda|match|nonlocal|not|or|pass|print|raise|return|try|while|with|yield)\b/,builtin:/\b(?:__import__|abs|all|any|apply|ascii|basestring|bin|bool|buffer|bytearray|bytes|callable|chr|classmethod|cmp|coerce|compile|complex|delattr|dict|dir|divmod|enumerate|eval|execfile|file|filter|float|format|frozenset|getattr|globals|hasattr|hash|help|hex|id|input|int|intern|isinstance|issubclass|iter|len|list|locals|long|map|max|memoryview|min|next|object|oct|open|ord|pow|property|range|raw_input|reduce|reload|repr|reversed|round|set|setattr|slice|sorted|staticmethod|str|sum|super|tuple|type|unichr|unicode|vars|xrange|zip)\b/,boolean:/\b(?:False|None|True)\b/,number:/\b0(?:b(?:_?[01])+|o(?:_?[0-7])+|x(?:_?[a-f0-9])+)\b|(?:\b\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\B\.\d+(?:_\d+)*)(?:e[+-]?\d+(?:_\d+)*)?j?(?!\w)/i,operator:/[-+%=]=?|!=|:=|\*\*?=?|\/\/?=?|<[<=>]?|>[=>]?|[&|^~]/,punctuation:/[{}[\];(),.:]/},s.languages.python["string-interpolation"].inside.interpolation.inside.rest=s.languages.python,s.languages.py=s.languages.python);var wu;wu||(wu=1,function(e){for(var t=/\/\*(?:[^*/]|\*(?!\/)|\/(?!\*)|)*\*\//.source,n=0;n<2;n++)t=t.replace(//g,(function(){return t}));t=t.replace(//g,(function(){return/[^\s\S]/.source})),e.languages.rust={comment:[{pattern:RegExp(/(^|[^\\])/.source+t),lookbehind:!0,greedy:!0},{pattern:/(^|[^\\:])\/\/.*/,lookbehind:!0,greedy:!0}],string:{pattern:/b?"(?:\\[\s\S]|[^\\"])*"|b?r(#*)"(?:[^"]|"(?!\1))*"\1/,greedy:!0},char:{pattern:/b?'(?:\\(?:x[0-7][\da-fA-F]|u\{(?:[\da-fA-F]_*){1,6}\}|.)|[^\\\r\n\t'])'/,greedy:!0},attribute:{pattern:/#!?\[(?:[^\[\]"]|"(?:\\[\s\S]|[^\\"])*")*\]/,greedy:!0,alias:"attr-name",inside:{string:null}},"closure-params":{pattern:/([=(,:]\s*|\bmove\s*)\|[^|]*\||\|[^|]*\|(?=\s*(?:\{|->))/,lookbehind:!0,greedy:!0,inside:{"closure-punctuation":{pattern:/^\||\|$/,alias:"punctuation"},rest:null}},"lifetime-annotation":{pattern:/'\w+/,alias:"symbol"},"fragment-specifier":{pattern:/(\$\w+:)[a-z]+/,lookbehind:!0,alias:"punctuation"},variable:/\$\w+/,"function-definition":{pattern:/(\bfn\s+)\w+/,lookbehind:!0,alias:"function"},"type-definition":{pattern:/(\b(?:enum|struct|trait|type|union)\s+)\w+/,lookbehind:!0,alias:"class-name"},"module-declaration":[{pattern:/(\b(?:crate|mod)\s+)[a-z][a-z_\d]*/,lookbehind:!0,alias:"namespace"},{pattern:/(\b(?:crate|self|super)\s*)::\s*[a-z][a-z_\d]*\b(?:\s*::(?:\s*[a-z][a-z_\d]*\s*::)*)?/,lookbehind:!0,alias:"namespace",inside:{punctuation:/::/}}],keyword:[/\b(?:Self|abstract|as|async|await|become|box|break|const|continue|crate|do|dyn|else|enum|extern|final|fn|for|if|impl|in|let|loop|macro|match|mod|move|mut|override|priv|pub|ref|return|self|static|struct|super|trait|try|type|typeof|union|unsafe|unsized|use|virtual|where|while|yield)\b/,/\b(?:bool|char|f(?:32|64)|[ui](?:8|16|32|64|128|size)|str)\b/],function:/\b[a-z_]\w*(?=\s*(?:::\s*<|\())/,macro:{pattern:/\b\w+!/,alias:"property"},constant:/\b[A-Z_][A-Z_\d]+\b/,"class-name":/\b[A-Z]\w*\b/,namespace:{pattern:/(?:\b[a-z][a-z_\d]*\s*::\s*)*\b[a-z][a-z_\d]*\s*::(?!\s*<)/,inside:{punctuation:/::/}},number:/\b(?:0x[\dA-Fa-f](?:_?[\dA-Fa-f])*|0o[0-7](?:_?[0-7])*|0b[01](?:_?[01])*|(?:(?:\d(?:_?\d)*)?\.)?\d(?:_?\d)*(?:[Ee][+-]?\d+)?)(?:_?(?:f32|f64|[iu](?:8|16|32|64|size)?))?\b/,boolean:/\b(?:false|true)\b/,punctuation:/->|\.\.=|\.{1,3}|::|[{}[\];(),:]/,operator:/[-+*\/%!^]=?|=[=>]?|&[&=]?|\|[|=]?|<>?=?|[@?]/},e.languages.rust["closure-params"].inside.rest=e.languages.rust,e.languages.rust.attribute.inside.string=e.languages.rust.string}(s)),s.languages.swift={comment:{pattern:/(^|[^\\:])(?:\/\/.*|\/\*(?:[^/*]|\/(?!\*)|\*(?!\/)|\/\*(?:[^*]|\*(?!\/))*\*\/)*\*\/)/,lookbehind:!0,greedy:!0},"string-literal":[{pattern:RegExp(/(^|[^"#])/.source+"(?:"+/"(?:\\(?:\((?:[^()]|\([^()]*\))*\)|\r\n|[^(])|[^\\\r\n"])*"/.source+"|"+/"""(?:\\(?:\((?:[^()]|\([^()]*\))*\)|[^(])|[^\\"]|"(?!""))*"""/.source+")"+/(?!["#])/.source),lookbehind:!0,greedy:!0,inside:{interpolation:{pattern:/(\\\()(?:[^()]|\([^()]*\))*(?=\))/,lookbehind:!0,inside:null},"interpolation-punctuation":{pattern:/^\)|\\\($/,alias:"punctuation"},punctuation:/\\(?=[\r\n])/,string:/[\s\S]+/}},{pattern:RegExp(/(^|[^"#])(#+)/.source+"(?:"+/"(?:\\(?:#+\((?:[^()]|\([^()]*\))*\)|\r\n|[^#])|[^\\\r\n])*?"/.source+"|"+/"""(?:\\(?:#+\((?:[^()]|\([^()]*\))*\)|[^#])|[^\\])*?"""/.source+")\\2"),lookbehind:!0,greedy:!0,inside:{interpolation:{pattern:/(\\#+\()(?:[^()]|\([^()]*\))*(?=\))/,lookbehind:!0,inside:null},"interpolation-punctuation":{pattern:/^\)|\\#+\($/,alias:"punctuation"},string:/[\s\S]+/}}],directive:{pattern:RegExp(/#/.source+"(?:"+/(?:elseif|if)\b/.source+"(?:[ \t]*"+/(?:![ \t]*)?(?:\b\w+\b(?:[ \t]*\((?:[^()]|\([^()]*\))*\))?|\((?:[^()]|\([^()]*\))*\))(?:[ \t]*(?:&&|\|\|))?/.source+")+|"+/(?:else|endif)\b/.source+")"),alias:"property",inside:{"directive-name":/^#\w+/,boolean:/\b(?:false|true)\b/,number:/\b\d+(?:\.\d+)*\b/,operator:/!|&&|\|\||[<>]=?/,punctuation:/[(),]/}},literal:{pattern:/#(?:colorLiteral|column|dsohandle|file(?:ID|Literal|Path)?|function|imageLiteral|line)\b/,alias:"constant"},"other-directive":{pattern:/#\w+\b/,alias:"property"},attribute:{pattern:/@\w+/,alias:"atrule"},"function-definition":{pattern:/(\bfunc\s+)\w+/,lookbehind:!0,alias:"function"},label:{pattern:/\b(break|continue)\s+\w+|\b[a-zA-Z_]\w*(?=\s*:\s*(?:for|repeat|while)\b)/,lookbehind:!0,alias:"important"},keyword:/\b(?:Any|Protocol|Self|Type|actor|as|assignment|associatedtype|associativity|async|await|break|case|catch|class|continue|convenience|default|defer|deinit|didSet|do|dynamic|else|enum|extension|fallthrough|fileprivate|final|for|func|get|guard|higherThan|if|import|in|indirect|infix|init|inout|internal|is|isolated|lazy|left|let|lowerThan|mutating|none|nonisolated|nonmutating|open|operator|optional|override|postfix|precedencegroup|prefix|private|protocol|public|repeat|required|rethrows|return|right|safe|self|set|some|static|struct|subscript|super|switch|throw|throws|try|typealias|unowned|unsafe|var|weak|where|while|willSet)\b/,boolean:/\b(?:false|true)\b/,nil:{pattern:/\bnil\b/,alias:"constant"},"short-argument":/\$\d+\b/,omit:{pattern:/\b_\b/,alias:"keyword"},number:/\b(?:[\d_]+(?:\.[\de_]+)?|0x[a-f0-9_]+(?:\.[a-f0-9p_]+)?|0b[01_]+|0o[0-7_]+)\b/i,"class-name":/\b[A-Z](?:[A-Z_\d]*[a-z]\w*)?\b/,function:/\b[a-z_]\w*(?=\s*\()/i,constant:/\b(?:[A-Z_]{2,}|k[A-Z][A-Za-z_]+)\b/,operator:/[-+*/%=!<>&|^~?]+|\.[.\-+*/%=!<>&|^~?]+/,punctuation:/[{}[\]();,.:\\]/},s.languages.swift["string-literal"].forEach((function(e){e.inside.interpolation.inside=s.languages.swift}));var ku;ku||(ku=1,function(e){e.languages.typescript=e.languages.extend("javascript",{"class-name":{pattern:/(\b(?:class|extends|implements|instanceof|interface|new|type)\s+)(?!keyof\b)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?:\s*<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>)?/,lookbehind:!0,greedy:!0,inside:null},builtin:/\b(?:Array|Function|Promise|any|boolean|console|never|number|string|symbol|unknown)\b/}),e.languages.typescript.keyword.push(/\b(?:abstract|declare|is|keyof|readonly|require)\b/,/\b(?:asserts|infer|interface|module|namespace|type)\b(?=\s*(?:[{_$a-zA-Z\xA0-\uFFFF]|$))/,/\btype\b(?=\s*(?:[\{*]|$))/),delete e.languages.typescript.parameter,delete e.languages.typescript["literal-property"];var t=e.languages.extend("typescript",{});delete t["class-name"],e.languages.typescript["class-name"].inside=t,e.languages.insertBefore("typescript","function",{decorator:{pattern:/@[$\w\xA0-\uFFFF]+/,inside:{at:{pattern:/^@/,alias:"operator"},function:/^[\s\S]+/}},"generic-function":{pattern:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>(?=\s*\()/,greedy:!0,inside:{function:/^#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*/,generic:{pattern:/<[\s\S]+/,alias:"class-name",inside:t}}}}),e.languages.ts=e.languages.typescript}(s));var Tu;Tu||(Tu=1,function(e){var t=/\b(?:abstract|assert|boolean|break|byte|case|catch|char|class|const|continue|default|do|double|else|enum|exports|extends|final|finally|float|for|goto|if|implements|import|instanceof|int|interface|long|module|native|new|non-sealed|null|open|opens|package|permits|private|protected|provides|public|record(?!\s*[(){}[\]<>=%~.:,;?+\-*/&|^])|requires|return|sealed|short|static|strictfp|super|switch|synchronized|this|throw|throws|to|transient|transitive|try|uses|var|void|volatile|while|with|yield)\b/,n=/(?:[a-z]\w*\s*\.\s*)*(?:[A-Z]\w*\s*\.\s*)*/.source,r={pattern:RegExp(/(^|[^\w.])/.source+n+/[A-Z](?:[\d_A-Z]*[a-z]\w*)?\b/.source),lookbehind:!0,inside:{namespace:{pattern:/^[a-z]\w*(?:\s*\.\s*[a-z]\w*)*(?:\s*\.)?/,inside:{punctuation:/\./}},punctuation:/\./}};e.languages.java=e.languages.extend("clike",{string:{pattern:/(^|[^\\])"(?:\\.|[^"\\\r\n])*"/,lookbehind:!0,greedy:!0},"class-name":[r,{pattern:RegExp(/(^|[^\w.])/.source+n+/[A-Z]\w*(?=\s+\w+\s*[;,=()]|\s*(?:\[[\s,]*\]\s*)?::\s*new\b)/.source),lookbehind:!0,inside:r.inside},{pattern:RegExp(/(\b(?:class|enum|extends|implements|instanceof|interface|new|record|throws)\s+)/.source+n+/[A-Z]\w*\b/.source),lookbehind:!0,inside:r.inside}],keyword:t,function:[e.languages.clike.function,{pattern:/(::\s*)[a-z_]\w*/,lookbehind:!0}],number:/\b0b[01][01_]*L?\b|\b0x(?:\.[\da-f_p+-]+|[\da-f_]+(?:\.[\da-f_p+-]+)?)\b|(?:\b\d[\d_]*(?:\.[\d_]*)?|\B\.\d[\d_]*)(?:e[+-]?\d[\d_]*)?[dfl]?/i,operator:{pattern:/(^|[^.])(?:<<=?|>>>?=?|->|--|\+\+|&&|\|\||::|[?:~]|[-+*/%&|^!=<>]=?)/m,lookbehind:!0},constant:/\b[A-Z][A-Z_\d]+\b/}),e.languages.insertBefore("java","string",{"triple-quoted-string":{pattern:/"""[ \t]*[\r\n](?:(?:"|"")?(?:\\.|[^"\\]))*"""/,greedy:!0,alias:"string"},char:{pattern:/'(?:\\.|[^'\\\r\n]){1,6}'/,greedy:!0}}),e.languages.insertBefore("java","class-name",{annotation:{pattern:/(^|[^.])@\w+(?:\s*\.\s*\w+)*/,lookbehind:!0,alias:"punctuation"},generics:{pattern:/<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&))*>)*>)*>)*>/,inside:{"class-name":r,keyword:t,punctuation:/[<>(),.:]/,operator:/[?&|]/}},import:[{pattern:RegExp(/(\bimport\s+)/.source+n+/(?:[A-Z]\w*|\*)(?=\s*;)/.source),lookbehind:!0,inside:{namespace:r.inside.namespace,punctuation:/\./,operator:/\*/,"class-name":/\w+/}},{pattern:RegExp(/(\bimport\s+static\s+)/.source+n+/(?:\w+|\*)(?=\s*;)/.source),lookbehind:!0,alias:"static",inside:{namespace:r.inside.namespace,static:/\b\w+$/,punctuation:/\./,operator:/\*/,"class-name":/\w+/}}],namespace:{pattern:RegExp(/(\b(?:exports|import(?:\s+static)?|module|open|opens|package|provides|requires|to|transitive|uses|with)\s+)(?!)[a-z]\w*(?:\.[a-z]\w*)*\.?/.source.replace(//g,(function(){return t.source}))),lookbehind:!0,inside:{punctuation:/\./}}})}(s));var Eu;function Nu(e,...t){const n=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",e);for(const e of t)r.append("v",e);throw n.search=r.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}Eu||(Eu=1,function(e){var t=/\b(?:alignas|alignof|asm|auto|bool|break|case|catch|char|char16_t|char32_t|char8_t|class|co_await|co_return|co_yield|compl|concept|const|const_cast|consteval|constexpr|constinit|continue|decltype|default|delete|do|double|dynamic_cast|else|enum|explicit|export|extern|final|float|for|friend|goto|if|import|inline|int|int16_t|int32_t|int64_t|int8_t|long|module|mutable|namespace|new|noexcept|nullptr|operator|override|private|protected|public|register|reinterpret_cast|requires|return|short|signed|sizeof|static|static_assert|static_cast|struct|switch|template|this|thread_local|throw|try|typedef|typeid|typename|uint16_t|uint32_t|uint64_t|uint8_t|union|unsigned|using|virtual|void|volatile|wchar_t|while)\b/,n=/\b(?!)\w+(?:\s*\.\s*\w+)*\b/.source.replace(//g,(function(){return t.source}));e.languages.cpp=e.languages.extend("c",{"class-name":[{pattern:RegExp(/(\b(?:class|concept|enum|struct|typename)\s+)(?!)\w+/.source.replace(//g,(function(){return t.source}))),lookbehind:!0},/\b[A-Z]\w*(?=\s*::\s*\w+\s*\()/,/\b[A-Z_]\w*(?=\s*::\s*~\w+\s*\()/i,/\b\w+(?=\s*<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>\s*::\s*\w+\s*\()/],keyword:t,number:{pattern:/(?:\b0b[01']+|\b0x(?:[\da-f']+(?:\.[\da-f']*)?|\.[\da-f']+)(?:p[+-]?[\d']+)?|(?:\b[\d']+(?:\.[\d']*)?|\B\.[\d']+)(?:e[+-]?[\d']+)?)[ful]{0,4}/i,greedy:!0},operator:/>>=?|<<=?|->|--|\+\+|&&|\|\||[?:~]|<=>|[-+*/%&|^!=<>]=?|\b(?:and|and_eq|bitand|bitor|not|not_eq|or|or_eq|xor|xor_eq)\b/,boolean:/\b(?:false|true)\b/}),e.languages.insertBefore("cpp","string",{module:{pattern:RegExp(/(\b(?:import|module)\s+)/.source+"(?:"+/"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"|<[^<>\r\n]*>/.source+"|"+/(?:\s*:\s*)?|:\s*/.source.replace(//g,(function(){return n}))+")"),lookbehind:!0,greedy:!0,inside:{string:/^[<"][\s\S]+/,operator:/:/,punctuation:/\./}},"raw-string":{pattern:/R"([^()\\ ]{0,16})\([\s\S]*?\)\1"/,alias:"string",greedy:!0}}),e.languages.insertBefore("cpp","keyword",{"generic-function":{pattern:/\b(?!operator\b)[a-z_]\w*\s*<(?:[^<>]|<[^<>]*>)*>(?=\s*\()/i,inside:{function:/^\w+/,generic:{pattern:/<[\s\S]+/,alias:"class-name",inside:e.languages.cpp}}}}),e.languages.insertBefore("cpp","operator",{"double-colon":{pattern:/::/,alias:"punctuation"}}),e.languages.insertBefore("cpp","class-name",{"base-clause":{pattern:/(\b(?:class|struct)\s+\w+\s*:\s*)[^;{}"'\s]+(?:\s+[^;{}"'\s]+)*(?=\s*[;{])/,lookbehind:!0,greedy:!0,inside:e.languages.extend("cpp",{})}}),e.languages.insertBefore("inside","double-colon",{"class-name":/\b[a-z_]\w*\b(?!\s*::)/i},e.languages.cpp["base-clause"])}(s));function Au(e,t){for(const n of e.childNodes){if(Js(n)&&n.tagName===t)return!0;Au(n,t)}return!1}const Lu="data-language",Ou="data-highlight-language",Fu="data-theme";let Ru=class e extends go{__language;__theme;__isSyntaxHighlightSupported;static getType(){return"code"}static clone(t){return new e(t.__language,t.__key)}constructor(e,t){super(t),this.__language=e||void 0,this.__isSyntaxHighlightSupported=!1,this.__theme=void 0}afterCloneFrom(e){super.afterCloneFrom(e),this.__language=e.__language,this.__theme=e.__theme,this.__isSyntaxHighlightSupported=e.__isSyntaxHighlightSupported}createDOM(e){const t=document.createElement("code");La(t,e.theme.code),t.setAttribute("spellcheck","false");const n=this.getLanguage();n&&(t.setAttribute(Lu,n),this.getIsSyntaxHighlightSupported()&&t.setAttribute(Ou,n));const r=this.getTheme();r&&t.setAttribute(Fu,r);const i=this.getStyle();return i&&t.setAttribute("style",i),t}updateDOM(e,t,n){const r=this.__language,i=e.__language;r?r!==i&&t.setAttribute(Lu,r):i&&t.removeAttribute(Lu);const o=this.__isSyntaxHighlightSupported;e.__isSyntaxHighlightSupported&&i?o&&r?r!==i&&t.setAttribute(Ou,r):t.removeAttribute(Ou):o&&r&&t.setAttribute(Ou,r);const s=this.__theme,l=e.__theme;s?s!==l&&t.setAttribute(Fu,s):l&&t.removeAttribute(Fu);const a=this.__style,c=e.__style;return a?a!==c&&t.setAttribute("style",a):c&&t.removeAttribute("style"),!1}exportDOM(e){const t=document.createElement("pre");La(t,e._config.theme.code),t.setAttribute("spellcheck","false");const n=this.getLanguage();n&&(t.setAttribute(Lu,n),this.getIsSyntaxHighlightSupported()&&t.setAttribute(Ou,n));const r=this.getTheme();r&&t.setAttribute(Fu,r);const i=this.getStyle();return i&&t.setAttribute("style",i),{element:t}}static importDOM(){return{code:e=>null!=e.textContent&&(/\r?\n/.test(e.textContent)||Au(e,"BR"))?{conversion:Mu,priority:1}:null,div:()=>({conversion:Du,priority:1}),pre:()=>({conversion:Mu,priority:0}),table:e=>Hu(e)?{conversion:Bu,priority:3}:null,td:e=>{const t=e,n=t.closest("table");return t.classList.contains("js-file-line")||n&&Hu(n)?{conversion:zu,priority:3}:null},tr:e=>{const t=e.closest("table");return t&&Hu(t)?{conversion:zu,priority:3}:null}}}static importJSON(e){return Iu().updateFromJSON(e)}updateFromJSON(e){return super.updateFromJSON(e).setLanguage(e.language).setTheme(e.theme)}exportJSON(){return{...super.exportJSON(),language:this.getLanguage(),theme:this.getTheme()}}insertNewAfter(e,t=!0){const n=this.getChildren(),r=n.length;if(r>=2&&"\n"===n[r-1].getTextContent()&&"\n"===n[r-2].getTextContent()&&e.isCollapsed()&&e.anchor.key===this.__key&&e.anchor.offset===r){n[r-1].remove(),n[r-2].remove();const e=Eo();return this.insertAfter(e,t),e}const{anchor:i,focus:o}=e,s=(i.isBefore(o)?i:o).getNode();if(ri(s)){let e=ju(s);const t=[];for(;;)if(li(e))t.push(si()),e=e.getNextSibling();else{if(!Vu(e))break;{let n=0;const r=e.getTextContent(),i=e.getTextContentSize();for(;ne.append(t))),this.replace(e),!0}setLanguage(e){const t=this.getWritable();return t.__language=e||void 0,t}getLanguage(){return this.getLatest().__language}setIsSyntaxHighlightSupported(e){const t=this.getWritable();return t.__isSyntaxHighlightSupported=e,t}getIsSyntaxHighlightSupported(){return this.getLatest().__isSyntaxHighlightSupported}setTheme(e){const t=this.getWritable();return t.__theme=e||void 0,t}getTheme(){return this.getLatest().__theme}};function Iu(e,t){return function(e){const t=nl();return Zi(),new(t.resolveRegisteredNodeAfterReplacements(t.getRegisteredNode(e)).klass)}(Ru).setLanguage(e).setTheme(t)}function Pu(e){return e instanceof Ru}function Mu(e){return{node:Iu(e.getAttribute(Lu))}}function Du(e){const t=e,n=$u(t);return n||function(e){let t=e.parentElement;for(;null!==t;){if($u(t))return!0;t=t.parentElement}return!1}(t)?{node:n?Iu():null}:{node:null}}function Bu(){return{node:Iu()}}function zu(){return{node:null}}function $u(e){return null!==e.style.fontFamily.match("monospace")}function Hu(e){return e.classList.contains("js-file-line-container")}let Ku=class e extends jr{__highlightType;constructor(e="",t,n){super(e,n),this.__highlightType=t}static getType(){return"code-highlight"}static clone(t){return new e(t.__text,t.__highlightType||void 0,t.__key)}getHighlightType(){return this.getLatest().__highlightType}setHighlightType(e){const t=this.getWritable();return t.__highlightType=e||void 0,t}canHaveFormat(){return!1}createDOM(e){const t=super.createDOM(e);return La(t,Uu(e.theme,this.__highlightType)),t}updateDOM(e,t,n){const r=super.updateDOM(e,t,n),i=Uu(n.theme,e.__highlightType),o=Uu(n.theme,this.__highlightType);return i!==o&&(i&&Oa(t,i),o&&La(t,o)),r}static importJSON(e){return Wu().updateFromJSON(e)}updateFromJSON(e){return super.updateFromJSON(e).setHighlightType(e.highlightType)}exportJSON(){return{...super.exportJSON(),highlightType:this.getHighlightType()}}setFormat(e){return this}isParentRequired(){return!0}createParentElementNode(){return Iu()}};function Uu(e,t){return t&&e&&e.codeHighlight&&e.codeHighlight[t]}function Wu(e="",t){return Ws(new Ku(e,t))}function Vu(e){return e instanceof Ku}function qu(e,t){let n=e;for(let r=Tl(e,t);r&&(Vu(r.origin)||li(r.origin));r=Fa(r))n=r.origin;return n}function ju(e){return qu(e,"previous")}function Zu(e){return qu(e,"next")}!function(e){e.languages.diff={coord:[/^(?:\*{3}|-{3}|\+{3}).*$/m,/^@@.*@@$/m,/^\d.*$/m]};var t={"deleted-sign":"-","deleted-arrow":"<","inserted-sign":"+","inserted-arrow":">",unchanged:" ",diff:"!"};Object.keys(t).forEach((function(n){var r=t[n],i=[];/^\w+$/.test(n)||i.push(/\w+/.exec(n)[0]),"diff"===n&&i.push("bold"),e.languages.diff[n]={pattern:RegExp("^(?:["+r+"].*(?:\r\n?|\n|(?![\\s\\S])))+","m"),alias:i,inside:{line:{pattern:/(.)(?=[\s\S]).*(?:\r\n?|\n)?/,lookbehind:!0},prefix:{pattern:/[\s\S]/,alias:/\w+/.exec(n)[0]}}}})),Object.defineProperty(e.languages.diff,"PREFIXES",{value:t})}(Prism);const Gu=globalThis.Prism||window.Prism,Ju={c:"C",clike:"C-like",cpp:"C++",css:"CSS",html:"HTML",java:"Java",js:"JavaScript",markdown:"Markdown",objc:"Objective-C",plain:"Plain Text",powershell:"PowerShell",py:"Python",rust:"Rust",sql:"SQL",swift:"Swift",typescript:"TypeScript",xml:"XML"},Yu={cpp:"cpp",java:"java",javascript:"js",md:"markdown",plaintext:"plain",python:"py",text:"plain",ts:"typescript"};function Xu(e){return Yu[e]||e}function Qu(e){return"string"==typeof e?e:Array.isArray(e)?e.map(Qu).join(""):Qu(e.content)}function ed(e,t){const n=/^diff-([\w-]+)/i.exec(t),r=e.getTextContent();let i=Gu.tokenize(r,Gu.languages[n?"diff":t]);return n&&(i=function(e,t){const n=t,r=Gu.languages[n],i={tokens:e},o=Gu.languages.diff.PREFIXES;for(const e of i.tokens){if("string"==typeof e||!(e.type in o)||!Array.isArray(e.content))continue;const t=e.type;let n=0;const i=()=>(n++,new Gu.Token("prefix",o[t],t.replace(/^(\w+).*/,"$1"))),s=e.content.filter((e=>"string"==typeof e||"prefix"!==e.type)),l=e.content.length-s.length,a=Gu.tokenize(Qu(s),r);a.unshift(i());const c=/\r\n|\n/g,u=e=>{const t=[];c.lastIndex=0;let r,o=0;for(;n{for(let t=0;t0&&n.push(Wu(i,t))}}else{const{content:e,alias:t}=r;"string"==typeof e?n.push(...td([e],"prefix"===r.type&&"string"==typeof t?t:r.type)):Array.isArray(e)&&n.push(...td(e,"unchanged"===r.type?void 0:r.type))}return n}const nd={$tokenize(e,t){return ed(e,t||this.defaultLanguage)},defaultLanguage:"javascript",tokenize(e,t){return Gu.tokenize(e,Gu.languages[t||""]||Gu.languages[this.defaultLanguage])}};function rd(e,t,n){const r=e.getParent();Pu(r)?sd(r,t,n):Vu(e)&&e.replace(ni(e.__text))}function id(e,t){const n=t.getElementByKey(e.getKey());if(null===n)return;const r=e.getChildren(),i=r.length;if(i===n.__cachedChildrenLength)return;n.__cachedChildrenLength=i;let o="1",s=1;for(let e=0;e{!function(e,t){const n=is(e);if(!Pu(n)||!n.isAttached())return;const r=Li();if(!gi(r))return void t();const i=r.anchor,o=i.offset,s="element"===i.type&&zr(n.getChildAtIndex(i.offset-1));let l=0;if(!s){const e=i.getNode();l=o+e.getPreviousSiblings().reduce(((e,t)=>e+t.getTextContentSize()),0)}t()&&(s?i.getNode().select(o,o):n.getChildren().some((e=>{const t=ri(e);if(t||zr(e)){const n=e.getTextContentSize();if(t&&n>=l)return e.select(l,l),!0;l-=n}return!1})))}(r,(()=>{const t=is(r);if(!Pu(t)||!t.isAttached())return!1;const i=t.getLanguage()||n.defaultLanguage,o=n.$tokenize(t,i),s=function(e,t){let n=0;for(;n{od.delete(r)},skipTransforms:!0}))}function ld(e,t){return Vu(e)&&Vu(t)&&e.__text===t.__text&&e.__highlightType===t.__highlightType||li(e)&&li(t)||zr(e)&&zr(t)}function ad(e){if(!gi(e))return!1;const t=e.anchor.getNode(),n=Pu(t)?t:t.getParent(),r=e.focus.getNode(),i=Pu(r)?r:r.getParent();return Pu(n)&&n.is(i)}function cd(e){const t=e.getNodes(),n=[];if(1===t.length&&Pu(t[0]))return n;let r=[];for(let e=0;e0&&(n.push(r),r=[]):r.push(i)}if(r.length>0){const t=e.isBackward()?e.anchor:e.focus,i=ci(r[0].getKey(),0,"text");t.is(i)||n.push(r)}return n}function ud(e){const t=Li();if(!gi(t)||!ad(t))return!1;const n=cd(t),r=n.length;if(0===r&&t.isCollapsed())return e===In&&t.insertNodes([si()]),!0;if(0===r&&e===In&&"\n"===t.getTextContent()){const e=si(),n=Br(),r=t.isBackward()?"previous":"next";return t.insertNodes([e,n]),Vl(ta(Ml(El(e,"next",0),Xl(Tl(n,"next"))),r)),!0}for(let i=0;i0){let n=r[0];if(0===i&&(n=ju(n)),e===In){const e=si();if(n.insertBefore(e),0===i){const r=t.isBackward()?"focus":"anchor",i=ci(n.getKey(),0,"text");t[r].is(i)&&t[r].set(e.getKey(),0,"text")}}else li(n)&&n.remove()}}return!0}function dd(e,t){const n=Li();if(!gi(n))return!1;const{anchor:r,focus:i}=n,o=r.offset,s=i.offset,l=r.getNode(),a=i.getNode(),c=e===kn;if(!ad(n)||!Vu(l)&&!li(l)||!Vu(a)&&!li(a))return!1;if(!t.altKey){if(n.isCollapsed()){const e=l.getParentOrThrow();if(c&&0===o&&null===l.getPreviousSibling()){if(null===e.getPreviousSibling())return e.selectPrevious(),t.preventDefault(),!0}else if(!c&&o===l.getTextContentSize()&&null===l.getNextSibling()&&null===e.getNextSibling())return e.selectNext(),t.preventDefault(),!0}return!1}let u,d;if(l.isBefore(a)?(u=ju(l),d=Zu(a)):(u=ju(a),d=Zu(l)),null==u||null==d)return!1;const h=u.getNodesBetween(d);for(let e=0;ee.remove())),e===kn?(h.forEach((e=>m.insertBefore(e))),m.insertBefore(g)):(m.insertAfter(g),m=g,h.forEach((e=>{m.insertAfter(e),m=e}))),n.setTextNodeRange(l,o,a,s),!0}function hd(e,t){const n=Li();if(!gi(n))return!1;const{anchor:r,focus:i}=n,o=r.getNode(),s=i.getNode(),l=e===wn;if(!ad(n)||!Vu(o)&&!li(o)||!Vu(s)&&!li(s))return!1;const a=s;if("rtl"===function(e){const t=ju(e),n=Zu(e);let r=t;for(;null!==r;){if(Vu(r)){const e=Vo(r.getTextContent());if(null!==e)return e}if(r===n)break;r=r.getNextSibling()}const i=t.getParent();if(po(i)){const e=i.getDirection();if("ltr"===e||"rtl"===e)return e}return null}(a)?!l:l){const e=function(e,t){let n=null,r=null,i=e,o=t,s=e.getTextContent();for(;;){if(0===o){if(i=i.getPreviousSibling(),null===i)break;if(Vu(i)||li(i)||zr(i)||Nu(167),zr(i)){n={node:i,offset:1};break}o=Math.max(0,i.getTextContentSize()-1),s=i.getTextContent()}else o--;const e=s[o];Vu(i)&&" "!==e&&(r={node:i,offset:o})}if(null!==r)return r;let l=null;if(t({conversion:fd,priority:1})}}static importJSON(e){return md().updateFromJSON(e)}updateFromJSON(e){return super.updateFromJSON(e).setURL(e.url).setRel(e.rel||null).setTarget(e.target||null).setTitle(e.title||null)}sanitizeUrl(e){e=wd(e);try{const t=new URL(wd(e));if(!gd.has(t.protocol))return"about:blank"}catch(t){return e}return e}exportJSON(){return{...super.exportJSON(),rel:this.getRel(),target:this.getTarget(),title:this.getTitle(),url:this.getURL()}}getURL(){return this.getLatest().__url}setURL(e){const t=this.getWritable();return t.__url=e,t}getTarget(){return this.getLatest().__target}setTarget(e){const t=this.getWritable();return t.__target=e,t}getRel(){return this.getLatest().__rel}setRel(e){const t=this.getWritable();return t.__rel=e,t}getTitle(){return this.getLatest().__title}setTitle(e){const t=this.getWritable();return t.__title=e,t}insertNewAfter(e,t=!0){const n=md(this.__url,{rel:this.__rel,target:this.__target,title:this.__title});return this.insertAfter(n,t),n}canInsertTextBefore(){return!1}canInsertTextAfter(){return!1}canBeEmpty(){return!1}isInline(){return!0}extractWithChild(e,t,n){if(!gi(t))return!1;const r=t.anchor.getNode(),i=t.focus.getNode();return this.isParentOf(r)&&this.isParentOf(i)&&t.getTextContent().length>0}isEmailURI(){return this.__url.startsWith("mailto:")}isWebSiteURI(){return this.__url.startsWith("https://")||this.__url.startsWith("http://")}};function fd(e){let t=null;if(Gs(e)){const n=e.textContent;(null!==n&&""!==n||e.children.length>0)&&(t=md(e.getAttribute("href")||"",{rel:e.getAttribute("rel"),target:e.getAttribute("target"),title:e.getAttribute("title")}))}return{node:t}}function md(e="",t){return Ws(new pd(e,t))}function yd(e){return e instanceof pd}class bd extends pd{__isUnlinked;constructor(e="",t={},n){super(e,t,n),this.__isUnlinked=void 0!==t.isUnlinked&&null!==t.isUnlinked&&t.isUnlinked}static getType(){return"autolink"}static clone(e){return new bd(e.__url,{isUnlinked:e.__isUnlinked,rel:e.__rel,target:e.__target,title:e.__title},e.__key)}getIsUnlinked(){return this.__isUnlinked}setIsUnlinked(e){const t=this.getWritable();return t.__isUnlinked=e,t}createDOM(e){return this.__isUnlinked?document.createElement("span"):super.createDOM(e)}updateDOM(e,t,n){return super.updateDOM(e,t,n)||e.__isUnlinked!==this.__isUnlinked}static importJSON(e){return _d().updateFromJSON(e)}updateFromJSON(e){return super.updateFromJSON(e).setIsUnlinked(e.isUnlinked||!1)}static importDOM(){return null}exportJSON(){return{...super.exportJSON(),isUnlinked:this.__isUnlinked}}insertNewAfter(e,t=!0){const n=this.getParentOrThrow().insertNewAfter(e,t);if(po(n)){const e=_d(this.__url,{isUnlinked:this.__isUnlinked,rel:this.__rel,target:this.__target,title:this.__title});return n.append(e),e}return null}}function _d(e="",t){return Ws(new bd(e,t))}function xd(e){return e instanceof bd}function Sd(e,t){if("element"===e.type){const n=e.getNode();return po(n)||function(e,...t){const n=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",e);for(const e of t)r.append("v",e);throw n.search=r.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}(252),n.getChildren()[e.offset+t]||null}return null}function Cd(e,t={}){let n;if(e&&"object"==typeof e){const{url:r,...i}=e;n=r,t={...i,...t}}else n=e;const{target:r,title:i}=t,o=void 0===t.rel?"noreferrer":t.rel,s=Li();if(null===s||!gi(s)&&!fi(s))return;if(fi(s)){const e=s.getNodes();if(0===e.length)return;return void e.forEach((e=>{if(null===n){const t=dl(e,(e=>!xd(e)&&yd(e)));t&&(t.insertBefore(e),0===t.getChildren().length&&t.remove())}else{const t=dl(e,(e=>!xd(e)&&yd(e)));if(t)t.setURL(n),void 0!==r&&t.setTarget(r),void 0!==o&&t.setRel(o);else{const t=md(n,{rel:o,target:r});e.insertBefore(t),t.append(e)}}}))}const l=s.extract();if(null===n){const e=new Set;return void l.forEach((t=>{const n=t.getParent();if(yd(n)&&!xd(n)){const t=n.getKey();if(e.has(t))return;!function(e,t){const n=new Set(t.filter((t=>e.isParentOf(t))).map((e=>e.getKey()))),r=e.getChildren(),i=r.filter((e=>n.has(e.getKey())));if(i.length===r.length)return r.forEach((t=>e.insertBefore(t))),void e.remove();const o=r.findIndex((e=>n.has(e.getKey()))),s=r.findLastIndex((e=>n.has(e.getKey()))),l=0===o,a=s===r.length-1;if(l)i.forEach((t=>e.insertBefore(t)));else if(a)for(let t=i.length-1;t>=0;t--)e.insertAfter(i[t]);else{for(let t=i.length-1;t>=0;t--)e.insertAfter(i[t]);const t=r.slice(s+1);if(t.length>0){const n=md(e.getURL(),{rel:e.getRel(),target:e.getTarget(),title:e.getTitle()});i[i.length-1].insertAfter(n),t.forEach((e=>n.append(e)))}}}(n,l),e.add(t)}}))}const a=new Set,c=e=>{a.has(e.getKey())||(a.add(e.getKey()),e.setURL(n),void 0!==r&&e.setTarget(r),void 0!==o&&e.setRel(o),void 0!==i&&e.setTitle(i))};if(1===l.length){const e=l[0],t=dl(e,yd);if(null!==t)return c(t)}!function(e){const t=Li();if(!gi(t))return e();const n=vt(t),r=n.isBackward(),i=Sd(n.anchor,r?-1:0),o=Sd(n.focus,r?0:-1);if(e(),i||o){const e=Li();if(gi(e)){const t=e.clone();if(i){const e=i.getParent();e&&t.anchor.set(e.getKey(),i.getIndexWithinParent()+(r?1:0),"element")}if(o){const e=o.getParent();e&&t.focus.set(e.getKey(),o.getIndexWithinParent()+(r?0:1),"element")}hs(vt(t))}}}((()=>{let e=null;for(const t of l){if(!t.isAttached())continue;const s=dl(t,yd);if(s){c(s);continue}if(po(t)){if(!t.isInline())continue;if(yd(t)){if(!(xd(t)||null!==e&&e.getParentOrThrow().isParentOf(t))){c(t),e=t;continue}for(const e of t.getChildren())t.insertBefore(e);t.remove();continue}}const l=t.getPreviousSibling();yd(l)&&l.is(e)?l.append(t):(e=md(n,{rel:o,target:r,title:i}),t.insertAfter(e),e.append(t))}}))}const vd=/^\+?[0-9\s()-]{5,}$/;function wd(e){return e.match(/^[a-z][a-z0-9+.-]*:/i)||e.match(/^[/#.]/)?e:e.includes("@")?`mailto:${e}`:vd.test(e)?`tel:${e}`:`https://${e}`}const kd=/^(\d+(?:\.\d+)?)px$/,Td=3,Ed=2,Nd=0,Ad=1;class Ld extends go{__colSpan;__rowSpan;__headerState;__width;__backgroundColor;__verticalAlign;static getType(){return"tablecell"}static clone(e){return new Ld(e.__headerState,e.__colSpan,e.__width,e.__key)}afterCloneFrom(e){super.afterCloneFrom(e),this.__rowSpan=e.__rowSpan,this.__backgroundColor=e.__backgroundColor,this.__verticalAlign=e.__verticalAlign}static importDOM(){return{td:e=>({conversion:Fd,priority:0}),th:e=>({conversion:Fd,priority:0})}}static importJSON(e){return Rd().updateFromJSON(e)}updateFromJSON(e){return super.updateFromJSON(e).setHeaderStyles(e.headerState).setColSpan(e.colSpan||1).setRowSpan(e.rowSpan||1).setWidth(e.width||void 0).setBackgroundColor(e.backgroundColor||null).setVerticalAlign(e.verticalAlign||void 0)}constructor(e=Nd,t=1,n,r){super(r),this.__colSpan=t,this.__rowSpan=1,this.__headerState=e,this.__width=n,this.__backgroundColor=null,this.__verticalAlign=void 0}createDOM(e){const t=document.createElement(this.getTag());return this.__width&&(t.style.width=`${this.__width}px`),this.__colSpan>1&&(t.colSpan=this.__colSpan),this.__rowSpan>1&&(t.rowSpan=this.__rowSpan),null!==this.__backgroundColor&&(t.style.backgroundColor=this.__backgroundColor),Od(this.__verticalAlign)&&(t.style.verticalAlign=this.__verticalAlign),La(t,e.theme.tableCell,this.hasHeader()&&e.theme.tableCellHeader),t}exportDOM(e){const t=super.exportDOM(e);if(Js(t.element)){const e=t.element;e.setAttribute("data-temporary-table-cell-lexical-key",this.getKey()),e.style.border="1px solid black",this.__colSpan>1&&(e.colSpan=this.__colSpan),this.__rowSpan>1&&(e.rowSpan=this.__rowSpan),e.style.width=`${this.getWidth()||75}px`,e.style.verticalAlign=this.getVerticalAlign()||"top",e.style.textAlign="start",null===this.__backgroundColor&&this.hasHeader()&&(e.style.backgroundColor="#f2f3f5")}return t}exportJSON(){return{...super.exportJSON(),...Od(this.__verticalAlign)&&{verticalAlign:this.__verticalAlign},backgroundColor:this.getBackgroundColor(),colSpan:this.__colSpan,headerState:this.__headerState,rowSpan:this.__rowSpan,width:this.getWidth()}}getColSpan(){return this.getLatest().__colSpan}setColSpan(e){const t=this.getWritable();return t.__colSpan=e,t}getRowSpan(){return this.getLatest().__rowSpan}setRowSpan(e){const t=this.getWritable();return t.__rowSpan=e,t}getTag(){return this.hasHeader()?"th":"td"}setHeaderStyles(e,t=Td){const n=this.getWritable();return n.__headerState=e&t|n.__headerState&~t,n}getHeaderStyles(){return this.getLatest().__headerState}setWidth(e){const t=this.getWritable();return t.__width=e,t}getWidth(){return this.getLatest().__width}getBackgroundColor(){return this.getLatest().__backgroundColor}setBackgroundColor(e){const t=this.getWritable();return t.__backgroundColor=e,t}getVerticalAlign(){return this.getLatest().__verticalAlign}setVerticalAlign(e){const t=this.getWritable();return t.__verticalAlign=e||void 0,t}toggleHeaderStyle(e){const t=this.getWritable();return(t.__headerState&e)===e?t.__headerState-=e:t.__headerState+=e,t}hasHeaderState(e){return(this.getHeaderStyles()&e)===e}hasHeader(){return this.getLatest().__headerState!==Nd}updateDOM(e){return e.__headerState!==this.__headerState||e.__width!==this.__width||e.__colSpan!==this.__colSpan||e.__rowSpan!==this.__rowSpan||e.__backgroundColor!==this.__backgroundColor||e.__verticalAlign!==this.__verticalAlign}isShadowRoot(){return!0}collapseAtStart(){return!0}canBeEmpty(){return!1}canIndent(){return!1}}function Od(e){return"middle"===e||"bottom"===e}function Fd(e){const t=e,n=e.nodeName.toLowerCase();let r;kd.test(t.style.width)&&(r=parseFloat(t.style.width));const i=Rd("th"===n?Ad:Nd,t.colSpan,r);i.__rowSpan=t.rowSpan;const o=t.style.backgroundColor;""!==o&&(i.__backgroundColor=o);const s=t.style.verticalAlign;Od(s)&&(i.__verticalAlign=s);const l=t.style,a=(l&&l.textDecoration||"").split(" "),c="700"===l.fontWeight||"bold"===l.fontWeight,u=a.includes("line-through"),d="italic"===l.fontStyle,h=a.includes("underline");return{after:e=>{const t=[];let n=null;const r=()=>{if(n){const e=n.getFirstChild();zr(e)&&1===n.getChildrenSize()&&e.remove()}};for(const i of e)Hs(i)||ri(i)||zr(i)?(ri(i)&&(c&&i.toggleFormat("bold"),u&&i.toggleFormat("strikethrough"),d&&i.toggleFormat("italic"),h&&i.toggleFormat("underline")),n?n.append(i):(n=Eo().append(i),t.push(n))):(t.push(i),r(),n=null);return r(),0===t.length&&t.push(Eo()),t},node:i}}function Rd(e=Nd,t=1,n){return Ws(new Ld(e,t,n))}function Id(e){return e instanceof Ld}const Pd=on("INSERT_TABLE_COMMAND");function Md(e,...t){const n=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",e);for(const e of t)r.append("v",e);throw n.search=r.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}let Dd=class e extends go{__height;static getType(){return"tablerow"}static clone(t){return new e(t.__height,t.__key)}static importDOM(){return{tr:e=>({conversion:Bd,priority:0})}}static importJSON(e){return zd().updateFromJSON(e)}updateFromJSON(e){return super.updateFromJSON(e).setHeight(e.height)}constructor(e,t){super(t),this.__height=e}exportJSON(){const e=this.getHeight();return{...super.exportJSON(),...void 0===e?void 0:{height:e}}}createDOM(e){const t=document.createElement("tr");return this.__height&&(t.style.height=`${this.__height}px`),La(t,e.theme.tableRow),t}extractWithChild(e,t,n){return"html"===n}isShadowRoot(){return!0}setHeight(e){const t=this.getWritable();return t.__height=e,t}getHeight(){return this.getLatest().__height}updateDOM(e){return e.__height!==this.__height}canBeEmpty(){return!1}canIndent(){return!1}};function Bd(e){const t=e;let n;return kd.test(t.style.height)&&(n=parseFloat(t.style.height)),{after:e=>Ba(e,Id),node:zd(n)}}function zd(e){return Ws(new Dd(e))}function $d(e){return e instanceof Dd}const Hd="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,Kd=Hd&&"documentMode"in document?document.documentMode:null,Ud=Hd&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent);function Wd(e){const t=dl(e,(e=>Id(e)));return Id(t)?t:null}function Vd(e){const t=dl(e,(e=>$d(e)));if($d(t))return t;throw new Error("Expected table cell to be inside of table row.")}function qd(e){const t=dl(e,(e=>eg(e)));if(eg(t))return t;throw new Error("Expected table cell to be inside of table.")}Hd&&"InputEvent"in window&&!Kd&&new window.InputEvent("input");const jd=(e,t)=>e===Td||e===t?t:Nd;function Zd(e=!0){const t=Li();gi(t)||uh(t)||Md(188);const n=t.anchor.getNode(),r=t.focus.getNode(),[i]=oh(n),[o,,s]=oh(r),[,l,a]=rh(s,o,i),{startRow:c}=a,{startRow:u}=l;return e?Gd(c+i.__rowSpan>u+o.__rowSpan?i:o,!0):Gd(uu+o.__colSpan?i:o,!0):Yd(u1;){if(s-=o.__colSpan,!(s>=0)){h.append(d(r));continue e}{const{cell:e,startRow:r}=t[s];n=e,i=r}}n.insertAfter(d(r))}else o.setColSpan(o.__colSpan+1)}null!==u&&n&&Xd(u);const g=r.getColWidths();if(g){const e=[...g],t=a<0?0:a,n=e[t];e.splice(t,0,n),r.setColWidths(e)}return u}function Xd(e){const t=e.getFirstDescendant();null==t?e.selectStart():t.getParentOrThrow().selectStart()}function Qd(e,t){const n=e.getFirstChild();null!==n?n.insertBefore(t):e.append(t)}function eh(e){if(0===e.length)return null;const t=qd(e[0]),[n]=ih(t,null,null);let r=1/0,i=-1/0,o=1/0,s=-1/0;const l=new Set;for(const t of n)for(const n of t){if(!n||!n.cell)continue;const t=n.cell.getKey();if(!l.has(t)&&e.some((e=>e.is(n.cell)))){l.add(t);const e=n.startRow,a=n.startColumn,c=n.cell.__rowSpan||1,u=n.cell.__colSpan||1;r=Math.min(r,e),i=Math.max(i,e+c-1),o=Math.min(o,a),s=Math.max(s,a+u-1)}}if(r===1/0||o===1/0)return null;const a=i-r+1,c=s-o+1,u=n[r][o];if(!u.cell)return null;const d=u.cell;d.setColSpan(c),d.setRowSpan(a);const h=new Set([d.getKey()]);for(let e=r;e<=i;e++)for(let t=o;t<=s;t++){const r=n[e][t];if(!r.cell)continue;const i=r.cell,o=i.getKey();h.has(o)||(h.add(o),th(i)||d.append(...i.getChildren()),i.remove())}return 0===d.getChildrenSize()&&d.append(Eo()),d}function th(e){if(1!==e.getChildrenSize())return!1;const t=e.getFirstChildOrThrow();return!(!No(t)||!t.isEmpty())}function nh(e){const[t,n,r]=oh(e),i=t.__colSpan,o=t.__rowSpan;if(1===i&&1===o)return;const[s,l]=rh(r,t,t),{startColumn:a,startRow:c}=l,u=t.__headerState&Ed,d=Array.from({length:i},((e,t)=>{let n=u;for(let e=0;0!==n&&e{let n=h;for(let e=0;0!==n&&e1){for(let e=1;e1){let e;for(let t=1;t1&&(e+=n.__colSpan-1)}if(null===l)for(let n=i-1;n>=0;n--)Qd(e,Rd(d[n]|g[t]).append(Eo()));else for(let e=i-1;e>=0;e--)l.insertAfter(Rd(d[e]|g[t]).append(Eo()))}t.setRowSpan(1)}}function rh(e,t,n){const[r,i,o]=ih(e,t,n);return null===i&&Md(207),null===o&&Md(208),[r,i,o]}function ih(e,t,n){const r=[];let i=null,o=null;function s(e){let t=r[e];return void 0===t&&(r[e]=t=[]),t}const l=e.getChildren();for(let e=0;e=l.length);t++){const n=s(e+t);for(let e=0;e=i,h=a.startRow<=l&&u>=o;if(d&&h){const e=Math.min(i,a.startColumn),t=Math.max(s,c),n=Math.min(o,a.startRow),d=Math.max(l,u);e===i&&t===s&&n===o&&d===l||(i=e,s=t,o=n,l=d,r=!0)}}}while(r);return{maxColumn:s,maxRow:l,minColumn:i,minRow:o}}function lh(e){const[t,,n]=oh(e),r=n.getChildren(),i=r.length,o=r[0].getChildren().length,s=new Array(i);for(let e=0;e{const n=e[t].getNode(),r=dl(n,Id);Id(r)||Md(238,t,n.getKey(),n.getType());const i=r.getParent();$d(i)||Md(239,t);const o=i.getParent();return eg(o)||Md(240,t),[n,r,i,o]}));return i.is(a)||Md(241),{anchorCell:n,anchorNode:t,anchorRow:r,anchorTable:i,focusCell:s,focusNode:o,focusRow:l,focusTable:a}}let ch=class e{tableKey;anchor;focus;_cachedNodes;dirty;constructor(e,t,n){this.anchor=t,this.focus=n,t._selection=this,n._selection=this,this._cachedNodes=null,this.dirty=!1,this.tableKey=e}getStartEndPoints(){return[this.anchor,this.focus]}isValid(){if("root"===this.tableKey||"root"===this.anchor.key||"element"!==this.anchor.type||"root"===this.focus.key||"element"!==this.focus.type)return!1;const e=is(this.tableKey),t=is(this.anchor.key),n=is(this.focus.key);return null!==e&&null!==t&&null!==n}isBackward(){return this.focus.isBefore(this.anchor)}getCachedNodes(){return this._cachedNodes}setCachedNodes(e){this._cachedNodes=e}is(e){return uh(e)&&this.tableKey===e.tableKey&&this.anchor.is(e.anchor)&&this.focus.is(e.focus)}set(e,t,n){this.dirty=this.dirty||e!==this.tableKey||t!==this.anchor.key||n!==this.focus.key,this.tableKey=e,this.anchor.key=t,this.focus.key=n,this._cachedNodes=null}clone(){return new e(this.tableKey,ci(this.anchor.key,this.anchor.offset,this.anchor.type),ci(this.focus.key,this.focus.offset,this.focus.type))}isCollapsed(){return!1}extract(){return this.getNodes()}insertRawText(e){}insertText(){}hasFormat(e){let t=0;this.getNodes().filter(Id).forEach((e=>{const n=e.getFirstChild();No(n)&&(t|=n.getTextFormat())}));return 0!==(t&We[e])}insertNodes(e){const t=this.focus.getNode();po(t)||Md(151),vt(t.select(0,t.getChildrenSize())).insertNodes(e)}getShape(){const{anchorCell:e,focusCell:t}=ah(this),n=lh(e);null===n&&Md(153);const r=lh(t);null===r&&Md(155);const i=Math.min(n.columnIndex,r.columnIndex),o=Math.max(n.columnIndex+n.colSpan-1,r.columnIndex+r.colSpan-1),s=Math.min(n.rowIndex,r.rowIndex),l=Math.max(n.rowIndex+n.rowSpan-1,r.rowIndex+r.rowSpan-1);return{fromX:Math.min(i,o),fromY:Math.min(s,l),toX:Math.max(i,o),toY:Math.max(s,l)}}getNodes(){if(!this.isValid())return[];const e=this._cachedNodes;if(null!==e)return e;const{anchorTable:t,anchorCell:n,focusCell:r}=ah(this),i=r.getParents()[1];if(i!==t){if(t.isParentOf(r)){const e=i.getParent();null==e&&Md(159),this.set(this.tableKey,r.getKey(),e.getKey())}else{const e=t.getParent();null==e&&Md(158),this.set(this.tableKey,e.getKey(),r.getKey())}return this.getNodes()}const[o,s,l]=rh(t,n,r),{minColumn:a,maxColumn:c,minRow:u,maxRow:d}=sh(o,s,l),h=new Map([[t.getKey(),t]]);let g=null;for(let e=u;e<=d;e++)for(let t=a;t<=c;t++){const{cell:n}=o[e][t],r=n.getParent();$d(r)||Md(160),r!==g&&(h.set(r.getKey(),r),g=r),h.has(n.getKey())||hh(n,(e=>{h.set(e.getKey(),e)}))}const p=Array.from(h.values());return ji()||(this._cachedNodes=p),p}getTextContent(){const e=this.getNodes().filter((e=>Id(e)));let t="";for(let n=0;n0;e=n.at(-1)){const r=e.pop();void 0===r?n.pop():!1!==t(r)&&po(r)&&n.push(r.getChildren())}}function gh(e,t=nl()){const n=is(e);eg(n)||Md(231,e);const r=yh(n,t.getElementByKey(e));return null===r&&Md(232,e),{tableElement:r,tableNode:n}}let ph=class{focusX;focusY;listenersToRemove;table;isHighlightingCells;anchorX;anchorY;tableNodeKey;anchorCell;focusCell;anchorCellNodeKey;focusCellNodeKey;editor;tableSelection;hasHijackedSelectionStyles;isSelecting;pointerType;shouldCheckSelection;abortController;listenerOptions;nextFocus;constructor(e,t){this.isHighlightingCells=!1,this.anchorX=-1,this.anchorY=-1,this.focusX=-1,this.focusY=-1,this.listenersToRemove=new Set,this.tableNodeKey=t,this.editor=e,this.table={columns:0,domRows:[],rows:0},this.tableSelection=null,this.anchorCellNodeKey=null,this.focusCellNodeKey=null,this.anchorCell=null,this.focusCell=null,this.hasHijackedSelectionStyles=!1,this.isSelecting=!1,this.pointerType=null,this.shouldCheckSelection=!1,this.abortController=new AbortController,this.listenerOptions={signal:this.abortController.signal},this.nextFocus=null,this.trackTable()}getTable(){return this.table}removeListeners(){this.abortController.abort("removeListeners"),Array.from(this.listenersToRemove).forEach((e=>e())),this.listenersToRemove.clear()}$lookup(){return gh(this.tableNodeKey,this.editor)}trackTable(){const e=new MutationObserver((e=>{this.editor.getEditorState().read((()=>{let t=!1;for(let n=0;n{const{tableNode:t,tableElement:n}=this.$lookup();this.table=Eh(t,n),e.observe(n,{attributes:!0,childList:!0,subtree:!0})}),{editor:this.editor})}$clearHighlight(){const e=this.editor;this.isHighlightingCells=!1,this.anchorX=-1,this.anchorY=-1,this.focusX=-1,this.focusY=-1,this.tableSelection=null,this.anchorCellNodeKey=null,this.focusCellNodeKey=null,this.anchorCell=null,this.focusCell=null,this.hasHijackedSelectionStyles=!1,this.$enableHighlightStyle();const{tableNode:t,tableElement:n}=this.$lookup();Nh(e,Eh(t,n),null),null!==Li()&&(hs(null),e.dispatchCommand(sn,void 0))}$enableHighlightStyle(){const e=this.editor,{tableElement:t}=this.$lookup();Oa(t,e._config.theme.tableSelection),t.classList.remove("disable-selection"),this.hasHijackedSelectionStyles=!1}$disableHighlightStyle(){const{tableElement:e}=this.$lookup();La(e,this.editor._config.theme.tableSelection),this.hasHijackedSelectionStyles=!0}$updateTableTableSelection(e){if(null!==e){e.tableKey!==this.tableNodeKey&&Md(233,e.tableKey,this.tableNodeKey);const t=this.editor;this.tableSelection=e,this.isHighlightingCells=!0,this.$disableHighlightStyle(),this.updateDOMSelection(),Nh(t,this.table,this.tableSelection)}else this.$clearHighlight()}setShouldCheckSelection(){this.shouldCheckSelection=!0}getAndClearShouldCheckSelection(){return!!this.shouldCheckSelection&&(this.shouldCheckSelection=!1,!0)}setNextFocus(e){this.nextFocus=e}getAndClearNextFocus(){const{nextFocus:e}=this;return null!==e&&(this.nextFocus=null),e}updateDOMSelection(){if(null!==this.anchorCell&&null!==this.focusCell){const e=Zs(this.editor._window);e&&e.rangeCount>0&&e.removeAllRanges()}}$setFocusCellForSelection(e,t=!1){const n=this.editor,{tableNode:r}=this.$lookup(),i=e.x,o=e.y;if(this.focusCell=e,this.isHighlightingCells||this.anchorX===i&&this.anchorY===o&&!t){if(i===this.focusX&&o===this.focusY)return!1}else this.isHighlightingCells=!0,this.$disableHighlightStyle();if(this.focusX=i,this.focusY=o,this.isHighlightingCells){const t=qh(r,e.elem);if(null!=this.tableSelection&&null!=this.anchorCellNodeKey&&null!==t)return this.focusCellNodeKey=t.getKey(),this.tableSelection=function(e,t,n){e.getKey(),t.getKey(),n.getKey();const r=Li(),i=uh(r)?r.clone():dh();return i.set(e.getKey(),t.getKey(),n.getKey()),i}(r,this.$getAnchorTableCellOrThrow(),t),hs(this.tableSelection),n.dispatchCommand(sn,void 0),Nh(n,this.table,this.tableSelection),!0}return!1}$getAnchorTableCell(){return this.anchorCellNodeKey?is(this.anchorCellNodeKey):null}$getAnchorTableCellOrThrow(){const e=this.$getAnchorTableCell();return null===e&&Md(234),e}$getFocusTableCell(){return this.focusCellNodeKey?is(this.focusCellNodeKey):null}$getFocusTableCellOrThrow(){const e=this.$getFocusTableCell();return null===e&&Md(235),e}$setAnchorCellForSelection(e){this.isHighlightingCells=!1,this.anchorCell=e,this.anchorX=e.x,this.anchorY=e.y;const{tableNode:t}=this.$lookup(),n=qh(t,e.elem);if(null!==n){const e=n.getKey();this.tableSelection=null!=this.tableSelection?this.tableSelection.clone():dh(),this.anchorCellNodeKey=e}}$formatCells(e){const t=Li();uh(t)||Md(236);const n=Ei(),r=n.anchor,i=n.focus,o=t.getNodes().filter(Id);o.length>0||Md(237);const s=o[0].getFirstChild(),l=No(s)?s.getFormatFlags(e,null):null;o.forEach((t=>{r.set(t.getKey(),0,"element"),i.set(t.getKey(),t.getChildrenSize(),"element"),n.formatText(e,l)})),hs(t),this.editor.dispatchCommand(sn,void 0)}$clearText(){const{editor:e}=this,t=is(this.tableNodeKey);if(!eg(t))throw new Error("Expected TableNode.");const n=Li();uh(n)||Md(253);const r=n.getNodes().filter(Id),i=t.getFirstChild(),o=t.getLastChild();if(r.length>0&&null!==i&&null!==o&&$d(i)&&$d(o)&&r[0]===i.getFirstChild()&&r[r.length-1]===o.getLastChild()){t.selectPrevious();const n=t.getParent();return t.remove(),void(_o(n)&&n.isEmpty()&&e.dispatchCommand(dn,void 0))}r.forEach((e=>{if(po(e)){const t=Eo(),n=ni();t.append(n),e.append(t),e.getChildren().forEach((e=>{e!==t&&e.remove()}))}})),Nh(e,this.table,null),hs(null),e.dispatchCommand(sn,void 0)}};const fh="__lexicalTableSelection";function mh(e){return Js(e)&&"TABLE"===e.nodeName}function yh(e,t){if(!t)return t;const n=mh(t)?t:e.getDOMSlot(t).element;return"TABLE"!==n.nodeName&&Md(245,t.nodeName),n}function bh(e){return e._window}function _h(e,t){for(let n=t,r=null;null!==n;n=n.getParent()){if(e.is(n))return r;Id(n)&&(r=n)}return null}const xh=[[Tn,"down"],[kn,"up"],[vn,"backward"],[Sn,"forward"]],Sh=[fn,mn,cn],Ch=[An,On];function vh(e,t,n,r){const i=n.getRootElement(),o=bh(n);null!==i&&null!==o||Md(246);const s=new ph(n,e.getKey()),l=yh(e,t);!function(e,t){null!==wh(e)&&Md(205),e[fh]=t}(l,s),s.listenersToRemove.add((()=>function(e,t){wh(e)===t&&delete e[fh]}(l,s)));const a=t=>{if(s.pointerType=t.pointerType,0!==t.button||!Ys(t.target)||!o)return;const r=kh(t.target);null!==r&&n.update((()=>{const n=Oi();if(Ud&&t.shiftKey&&Ph(n,e)&&(gi(n)||uh(n))){const i=n.anchor.getNode(),o=_h(e,n.anchor.getNode());o?(s.$setAnchorCellForSelection(Vh(s,o)),s.$setFocusCellForSelection(r),Kh(t)):(e.isBefore(i)?e.selectStart():e.selectEnd()).anchor.set(n.anchor.key,n.anchor.offset,n.anchor.type)}else"touch"!==t.pointerType&&s.$setAnchorCellForSelection(r)})),(()=>{if(s.isSelecting)return;const e=()=>{s.isSelecting=!1,o.removeEventListener("pointerup",e),o.removeEventListener("pointermove",t)},t=r=>{if(1&~r.buttons&&s.isSelecting)return s.isSelecting=!1,o.removeEventListener("pointerup",e),void o.removeEventListener("pointermove",t);if(!Ys(r.target))return;let i=null;const a=!(Ud||l.contains(r.target));if(a)i=Th(l,r.target);else for(const e of document.elementsFromPoint(r.clientX,r.clientY))if(i=Th(l,e),i)break;!i||null!==s.focusCell&&i.elem===s.focusCell.elem||(s.setNextFocus({focusCell:i,override:a}),n.dispatchCommand(sn,void 0))};s.isSelecting=!0,o.addEventListener("pointerup",e,s.listenerOptions),o.addEventListener("pointermove",t,s.listenerOptions)})()};l.addEventListener("pointerdown",a,s.listenerOptions),s.listenersToRemove.add((()=>{l.removeEventListener("pointerdown",a)}));const c=e=>{e.detail>=3&&Ys(e.target)&&null!==kh(e.target)&&e.preventDefault()};l.addEventListener("mousedown",c,s.listenerOptions),s.listenersToRemove.add((()=>{l.removeEventListener("mousedown",c)}));const u=e=>{const t=e.target;0===e.button&&Ys(t)&&n.update((()=>{const e=Li();uh(e)&&e.tableKey===s.tableNodeKey&&i.contains(t)&&s.$clearHighlight()}))};o.addEventListener("pointerdown",u,s.listenerOptions),s.listenersToRemove.add((()=>{o.removeEventListener("pointerdown",u)}));for(const[t,r]of xh)s.listenersToRemove.add(n.registerCommand(t,(t=>Hh(n,t,r,e,s)),3));s.listenersToRemove.add(n.registerCommand(Ln,(t=>{const n=Li();if(uh(n)){const r=_h(e,n.focus.getNode());if(null!==r)return Kh(t),r.selectEnd(),!0}return!1}),3));const d=t=>()=>{const n=Li();if(!Ph(n,e))return!1;if(uh(n))return s.$clearText(),!0;if(gi(n)){if(!Id(_h(e,n.anchor.getNode())))return!1;const r=n.anchor.getNode(),i=n.focus.getNode(),o=e.isParentOf(r),l=e.isParentOf(i);if(o&&!l||l&&!o)return s.$clearText(),!0;const a=dl(n.anchor.getNode(),(e=>po(e))),c=a&&dl(a,(e=>po(e)&&Id(e.getParent())));if(!po(c)||!po(a))return!1;if(t===mn&&null===c.getPreviousSibling())return!0}return!1};for(const e of Sh)s.listenersToRemove.add(n.registerCommand(e,d(e),3));const h=t=>{const n=Li();if(!uh(n)&&!gi(n))return!1;const r=e.isParentOf(n.anchor.getNode());if(r!==e.isParentOf(n.focus.getNode())){const t=r?"anchor":"focus",i=r?"focus":"anchor",{key:o,offset:s,type:l}=n[i];return e[n[t].isBefore(n[i])?"selectPrevious":"selectNext"]()[i].set(o,s,l),!1}return!!Ph(n,e)&&!!uh(n)&&(t&&(t.preventDefault(),t.stopPropagation()),s.$clearText(),!0)};for(const e of Ch)s.listenersToRemove.add(n.registerCommand(e,h,3));return s.listenersToRemove.add(n.registerCommand(Kn,(e=>{const t=Li();if(t){if(!uh(t)&&!gi(t))return!1;Zc(n,Pa(e,ClipboardEvent)?e:null,Yc(t));const r=h(e);return gi(t)?(t.removeText(),!0):r}return!1}),3)),s.listenersToRemove.add(n.registerCommand(yn,(t=>{const n=Li();if(!Ph(n,e))return!1;if(uh(n))return s.$formatCells(t),!0;if(gi(n)){const e=dl(n.anchor.getNode(),(e=>Id(e)));if(!Id(e))return!1}return!1}),3)),s.listenersToRemove.add(n.registerCommand(Dn,(t=>{const n=Li();if(!uh(n)||!Ph(n,e))return!1;const r=n.anchor.getNode(),i=n.focus.getNode();if(!Id(r)||!Id(i))return!1;if(function(e,t){if(uh(e)){const n=e.anchor.getNode(),r=e.focus.getNode();if(t&&n&&r){const[e]=rh(t,n,r);return n.getKey()===e[0][0].cell.getKey()&&r.getKey()===e[e.length-1].at(-1).cell.getKey()}}return!1}(n,e))return e.setFormat(t),!0;const[o,s,l]=rh(e,r,i),a=Math.max(s.startRow+s.cell.__rowSpan-1,l.startRow+l.cell.__rowSpan-1),c=Math.max(s.startColumn+s.cell.__colSpan-1,l.startColumn+l.cell.__colSpan-1),u=Math.min(s.startRow,l.startRow),d=Math.min(s.startColumn,l.startColumn),h=new Set;for(let e=u;e<=a;e++)for(let n=d;n<=c;n++){const r=o[e][n].cell;if(h.has(r))continue;h.add(r),r.setFormat(t);const i=r.getChildren();for(let e=0;e{const r=Li();if(!Ph(r,e))return!1;if(uh(r))return s.$clearHighlight(),!1;if(gi(r)){const i=dl(r.anchor.getNode(),(e=>Id(e)));if(!Id(i))return!1;if("string"==typeof t){const i=Wh(n,r,e);if(i)return Uh(i,e,[ni(t)]),!0}}return!1}),3)),r&&s.listenersToRemove.add(n.registerCommand(Fn,(t=>{const n=Li();if(!gi(n)||!n.isCollapsed()||!Ph(n,e))return!1;const r=zh(n.anchor.getNode());return!(null===r||!e.is($h(r))||(Kh(t),function(e,t){const n="next"===t?"getNextSibling":"getPreviousSibling",r="next"===t?"getFirstChild":"getLastChild",i=e[n]();if(po(i))return i.selectEnd();const o=dl(e,$d);null===o&&Md(247);for(let e=o[n]();$d(e);e=e[n]()){const t=e[r]();if(po(t))return t.selectEnd()}const s=dl(o,eg);null===s&&Md(248),"next"===t?s.selectNext():s.selectPrevious()}(r,t.shiftKey?"previous":"next"),0))}),3)),s.listenersToRemove.add(n.registerCommand(Zn,(t=>e.isSelected()),3)),s.listenersToRemove.add(n.registerCommand(ln,((e,t)=>{if(n!==t)return!1;const{nodes:r,selection:i}=e,o=i.getStartEndPoints(),s=uh(i),l=gi(i)&&null!==dl(i.anchor.getNode(),(e=>Id(e)))&&null!==dl(i.focus.getNode(),(e=>Id(e)))||s;if(1!==r.length||!eg(r[0])||!l||null===o)return!1;const[a,c]=o,[u,d,h]=oh(a),g=dl(c.getNode(),(e=>Id(e)));if(!(Id(u)&&Id(g)&&$d(d)&&eg(h)))return!1;const p=r[0],[f,m,y]=rh(h,u,g),[b]=ih(p,null,null),_=f.length,x=_>0?f[0].length:0;let S=m.startRow,C=m.startColumn,v=b.length,w=v>0?b[0].length:0;if(s){const e=sh(f,m,y),t=e.maxRow-e.minRow+1,n=e.maxColumn-e.minColumn+1;S=e.minRow,C=e.minColumn,v=Math.min(v,t),w=Math.min(w,n)}let k=!1;const T=Math.min(_,S+v)-1,E=Math.min(x,C+w)-1,N=new Set;for(let e=S;e<=T;e++)for(let t=C;t<=E;t++){const n=f[e][t];N.has(n.cell.getKey())||1===n.cell.__rowSpan&&1===n.cell.__colSpan||(nh(n.cell),N.add(n.cell.getKey()),k=!0)}let[A]=ih(h.getWritable(),null,null);const L=v-_+S;for(let e=0;e{ri(e)?(Eo().append(e),s.append(e)):s.append(e)})),l.forEach((e=>e.remove()))}if(s&&k){const[e]=ih(h.getWritable(),null,null);e[m.startRow][m.startColumn].cell.selectEnd()}return!0}),3)),s.listenersToRemove.add(n.registerCommand(sn,(()=>{const t=Li(),r=Oi(),i=s.getAndClearNextFocus();if(null!==i){const{focusCell:n}=i;if(uh(t)&&t.tableKey===s.tableNodeKey)return(n.x!==s.focusX||n.y!==s.focusY)&&(s.$setFocusCellForSelection(n),!0);if(n!==s.anchorCell&&Ph(t,e))return s.$setFocusCellForSelection(n),!0}if(s.getAndClearShouldCheckSelection()&&gi(r)&&gi(t)&&t.isCollapsed()){const n=t.anchor.getNode(),r=e.getFirstChild(),i=zh(n);if(null!==i&&$d(r)){const t=r.getFirstChild();if(Id(t)&&e.is(dl(i,(n=>n.is(e)||n.is(t)))))return t.selectStart(),!0}}if(gi(t)){const{anchor:i,focus:o}=t,l=i.getNode(),a=o.getNode(),c=zh(l),u=zh(a),d=!(!c||!e.is($h(c))),h=!(!u||!e.is($h(u))),g=d!==h,p=d&&h,f=t.isBackward();if(g){const r=t.clone();if(h){const[t]=rh(e,u,u),n=t[0][0].cell,i=t[t.length-1].at(-1).cell;r.focus.set(f?n.getKey():i.getKey(),f?n.getChildrenSize():i.getChildrenSize(),"element")}else if(d){const[t]=rh(e,c,c),n=t[0][0].cell,i=t[t.length-1].at(-1).cell;r.anchor.set(f?i.getKey():n.getKey(),f?i.getChildrenSize():0,"element")}hs(r),Lh(n,s)}else if(p&&(c.is(u)||(s.$setAnchorCellForSelection(Vh(s,c)),s.$setFocusCellForSelection(Vh(s,u),!0)),"touch"===s.pointerType&&s.isSelecting&&t.isCollapsed()&&gi(r)&&r.isCollapsed())){const e=zh(r.anchor.getNode());e&&!e.is(u)&&(s.$setAnchorCellForSelection(Vh(s,e)),s.$setFocusCellForSelection(Vh(s,u),!0),s.pointerType=null)}}else if(t&&uh(t)&&t.is(r)&&t.tableKey===e.getKey()){const r=Zs(o);if(r&&r.anchorNode&&r.focusNode){const i=ls(r.focusNode),o=i&&!e.isParentOf(i),s=ls(r.anchorNode),l=s&&e.isParentOf(s);if(o&&l&&r.rangeCount>0){const i=function(e,t){return Ai(null,e,t,null)}(r,n);i&&(i.anchor.set(e.getKey(),t.isBackward()?e.getChildrenSize():0,"element"),r.removeAllRanges(),hs(i))}}}return t&&!t.is(r)&&(uh(t)||uh(r))&&s.tableSelection&&!s.tableSelection.is(r)?(uh(t)&&t.tableKey===s.tableNodeKey?s.$updateTableTableSelection(t):!uh(t)&&uh(r)&&r.tableKey===s.tableNodeKey&&s.$updateTableTableSelection(null),!1):(s.hasHijackedSelectionStyles&&!e.isSelected()?function(e,t){t.$enableHighlightStyle(),Ah(t.table,(t=>{const n=t.elem;t.highlighted=!1,Bh(e,t),n.getAttribute("style")||n.removeAttribute("style")}))}(n,s):!s.hasHijackedSelectionStyles&&e.isSelected()&&Lh(n,s),!1)}),3)),s.listenersToRemove.add(n.registerCommand(dn,(()=>{const t=Li();if(!gi(t)||!t.isCollapsed()||!Ph(t,e))return!1;const r=Wh(n,t,e);return!!r&&(Uh(r,e),!0)}),3)),s}function wh(e){return e[fh]||null}function kh(e){let t=e;for(;null!=t;){const e=t.nodeName;if("TD"===e||"TH"===e){const e=t._cell;return void 0===e?null:e}t=t.parentNode}return null}function Th(e,t){if(!e.contains(t))return null;let n=null;for(let r=t;null!=r;r=r.parentNode){if(r===e)return n;const t=r.nodeName;"TD"!==t&&"TH"!==t||(n=r._cell||null)}return null}function Eh(e,t){const n=[],r={columns:0,domRows:n,rows:0};let i=yh(e,t).querySelector("tr"),o=0,s=0;for(n.length=0;null!=i;){const e=i.nodeName;if("TD"===e||"TH"===e){const e={elem:i,hasBackgroundColor:""!==i.style.backgroundColor,highlighted:!1,x:o,y:s};i._cell=e;let t=n[s];void 0===t&&(t=n[s]=[]),t[o]=e}else{const e=i.firstChild;if(null!=e){i=e;continue}}const t=i.nextSibling;if(null!=t){o++,i=t;continue}const r=i.parentNode;if(null!=r){const e=r.nextSibling;if(null==e)break;s++,o=0,i=e}}return r.columns=o+1,r.rows=s+1,r}function Nh(e,t,n){const r=new Set(n?n.getNodes():[]);Ah(t,((t,n)=>{const i=t.elem;r.has(n)?(t.highlighted=!0,Dh(e,t)):(t.highlighted=!1,Bh(e,t),i.getAttribute("style")||i.removeAttribute("style"))}))}function Ah(e,t){const{domRows:n}=e;for(let e=0;e{t.highlighted=!0,Dh(e,t)}))}const Oh=(e,t,n,r,i)=>{const o="forward"===i;switch(i){case"backward":case"forward":return n!==(o?e.table.columns-1:0)?Mh(t.getCellNodeFromCordsOrThrow(n+(o?1:-1),r,e.table),o):r!==(o?e.table.rows-1:0)?Mh(t.getCellNodeFromCordsOrThrow(o?0:e.table.columns-1,r+(o?1:-1),e.table),o):o?t.selectNext():t.selectPrevious(),!0;case"up":return 0!==r?Mh(t.getCellNodeFromCordsOrThrow(n,r-1,e.table),!1):t.selectPrevious(),!0;case"down":return r!==e.table.rows-1?Mh(t.getCellNodeFromCordsOrThrow(n,r+1,e.table),!0):t.selectNext(),!0;default:return!1}};function Fh(e,t){let n,r;if(t.startColumn===e.minColumn)n="minColumn";else{if(t.startColumn+t.cell.__colSpan-1!==e.maxColumn)return null;n="maxColumn"}if(t.startRow===e.minRow)r="minRow";else{if(t.startRow+t.cell.__rowSpan-1!==e.maxRow)return null;r="maxRow"}return[n,r]}function Rh([e,t]){return["minColumn"===e?"maxColumn":"minColumn","minRow"===t?"maxRow":"minRow"]}function Ih(e,t,[n,r]){const i=t[r],o=e[i];void 0===o&&Md(250,r,String(i));const s=t[n],l=o[s];return void 0===l&&Md(250,n,String(s)),l}function Ph(e,t){if(gi(e)||uh(e)){const n=t.isParentOf(e.anchor.getNode()),r=t.isParentOf(e.focus.getNode());return n&&r}return!1}function Mh(e,t){t?e.selectStart():e.selectEnd()}function Dh(e,t){const n=t.elem,r=e._config.theme;Id(ls(n))||Md(131),La(n,r.tableCellSelected)}function Bh(e,t){const n=t.elem;Id(ls(n))||Md(131);Oa(n,e._config.theme.tableCellSelected)}function zh(e){const t=dl(e,Id);return Id(t)?t:null}function $h(e){const t=dl(e,eg);return eg(t)?t:null}function Hh(e,t,n,r,i){if(("up"===n||"down"===n)&&function(e){const t=e.getRootElement();return!!t&&(t.hasAttribute("aria-controls")&&"typeahead-menu"===t.getAttribute("aria-controls"))}(e))return!1;const o=Li();if(!Ph(o,r)){if(gi(o)){if("backward"===n){if(o.focus.offset>0)return!1;const e=function(e){for(let t=e,n=e;null!==n;t=n,n=n.getParent())if(po(n)){if(n!==t&&n.getFirstChild()!==t)return null;if(!n.isInline())return n}return null}(o.focus.getNode());if(!e)return!1;const n=e.getPreviousSibling();return!!eg(n)&&(Kh(t),t.shiftKey?o.focus.set(n.getParentOrThrow().getKey(),n.getIndexWithinParent(),"element"):n.selectEnd(),!0)}if(t.shiftKey&&("up"===n||"down"===n)){const e=o.focus.getNode();if(!o.isCollapsed()&&("up"===n&&!o.isBackward()||"down"===n&&o.isBackward())){let i=dl(e,(e=>eg(e)));if(Id(i)&&(i=dl(i,eg)),i!==r)return!1;if(!i)return!1;const s="down"===n?i.getNextSibling():i.getPreviousSibling();if(!s)return!1;let l=0;"up"===n&&po(s)&&(l=s.getChildrenSize());let a=s;if("up"===n&&po(s)){a=s.getLastChild()||s,l=ri(a)?a.getTextContentSize():0}const c=o.clone();return c.focus.set(a.getKey(),l,ri(a)?"text":"element"),hs(c),Kh(t),!0}if(Ks(e)){const e="up"===n?o.getNodes()[o.getNodes().length-1]:o.getNodes()[0];if(e&&null!==_h(r,e)){const e=r.getFirstDescendant(),t=r.getLastDescendant();if(!e||!t)return!1;const[n]=oh(e),[o]=oh(t),s=r.getCordsFromCellNode(n,i.table),l=r.getCordsFromCellNode(o,i.table),a=r.getDOMCellFromCordsOrThrow(s.x,s.y,i.table),c=r.getDOMCellFromCordsOrThrow(l.x,l.y,i.table);return i.$setAnchorCellForSelection(a),i.$setFocusCellForSelection(c,!0),!0}return!1}{let r=dl(e,(e=>po(e)&&!e.isInline()));if(Id(r)&&(r=dl(r,eg)),!r)return!1;const s="down"===n?r.getNextSibling():r.getPreviousSibling();if(eg(s)&&i.tableNodeKey===s.getKey()){const e=s.getFirstDescendant(),r=s.getLastDescendant();if(!e||!r)return!1;const[i]=oh(e),[l]=oh(r),a=o.clone();return a.focus.set(("up"===n?i:l).getKey(),"up"===n?0:l.getChildrenSize(),"element"),Kh(t),hs(a),!0}}}}return"down"===n&&Gh(e)&&i.setShouldCheckSelection(),!1}if(gi(o)){if("backward"===n||"forward"===n)return function(e,t,n,r,i,o,s){const l=Ul(n.focus,i?"previous":"next");if(Ql(l))return!1;let a=l;for(const e of Il(l).iterNodeCarets("shadowRoot")){if(!Sl(e)||!po(e.origin))return!1;a=e}const c=a.getParentAtCaret();if(!Id(c))return!1;const u=c,d=function(e){for(const t of Il(e).iterNodeCarets("root")){const{origin:n}=t;if(Id(n)){if(Cl(t))return Ll(n,e.direction)}else if(!$d(n))break}return null}(Tl(u,a.direction)),h=dl(u,eg);if(!h||!h.is(o))return!1;const g=e.getElementByKey(u.getKey()),p=kh(g);if(!g||!p)return!1;const f=Yh(e,h);if(s.table=f,d)if("extend"===r){const t=kh(e.getElementByKey(d.origin.getKey()));if(!t)return!1;s.$setAnchorCellForSelection(p),s.$setFocusCellForSelection(t,!0)}else{const e=Xl(d);Wl(n.anchor,e),Wl(n.focus,e)}else if("extend"===r)s.$setAnchorCellForSelection(p),s.$setFocusCellForSelection(p,!0);else{const e=function(e){const t=Ol(e);return Cl(t)?Xl(t):e}(Tl(h,l.direction));Wl(n.anchor,e),Wl(n.focus,e)}return Kh(t),!0}(e,t,o,t.shiftKey?"extend":"move","backward"===n,r,i);if(o.isCollapsed()){const{anchor:s,focus:l}=o,a=dl(s.getNode(),Id),c=dl(l.getNode(),Id);if(!Id(a)||!a.is(c))return!1;const u=$h(a);if(u!==r&&null!=u){const r=yh(u,e.getElementByKey(u.getKey()));if(null!=r)return i.table=Eh(u,r),Hh(e,t,n,u,i)}const d=e.getElementByKey(a.__key),h=e.getElementByKey(s.key);if(null==h||null==d)return!1;let g;if("element"===s.type)g=h.getBoundingClientRect();else{const t=Zs(bh(e));if(null===t||0===t.rangeCount)return!1;g=t.getRangeAt(0).getBoundingClientRect()}const p="up"===n?a.getFirstChild():a.getLastChild();if(null==p)return!1;const f=e.getElementByKey(p.__key);if(null==f)return!1;const m=f.getBoundingClientRect();if("up"===n?m.top>g.top-g.height:g.bottom+g.height>m.bottom){Kh(t);const e=r.getCordsFromCellNode(a,i.table);if(!t.shiftKey)return Oh(i,r,e.x,e.y,n);{const t=r.getDOMCellFromCordsOrThrow(e.x,e.y,i.table);i.$setAnchorCellForSelection(t),i.$setFocusCellForSelection(t,!0)}return!0}}}else if(uh(o)){const{anchor:s,focus:l}=o,a=dl(s.getNode(),Id),c=dl(l.getNode(),Id),[u]=o.getNodes();eg(u)||Md(251);const d=yh(u,e.getElementByKey(u.getKey()));if(!Id(a)||!Id(c)||!eg(u)||null==d)return!1;i.$updateTableTableSelection(o);const h=Eh(u,d),g=r.getCordsFromCellNode(a,h),p=r.getDOMCellFromCordsOrThrow(g.x,g.y,h);if(i.$setAnchorCellForSelection(p),Kh(t),t.shiftKey){const[e,t,o]=rh(r,a,c);return function(e,t,n,r,i){const o=sh(t,n,r),s=function(e,t){const{minColumn:n,maxColumn:r,minRow:i,maxRow:o}=t;let s=1,l=1,a=1,c=1;const u=e[i],d=e[o];for(let e=n;e<=r;e++)s=Math.max(s,u[e].cell.__rowSpan),c=Math.max(c,d[e].cell.__rowSpan);for(let t=i;t<=o;t++)l=Math.max(l,e[t][n].cell.__colSpan),a=Math.max(a,e[t][r].cell.__colSpan);return{bottomSpan:c,leftSpan:l,rightSpan:a,topSpan:s}}(t,o),{topSpan:l,leftSpan:a,bottomSpan:c,rightSpan:u}=s,d=function(e,t){const n=Fh(e,t);return null===n&&Md(249,t.cell.getKey()),n}(o,n),[h,g]=Rh(d);let p=o[h],f=o[g];"forward"===i?p+="maxColumn"===h?1:a:"backward"===i?p-="minColumn"===h?1:u:"down"===i?f+="maxRow"===g?1:l:"up"===i&&(f-="minRow"===g?1:c);const m=t[f];if(void 0===m)return!1;const y=m[p];if(void 0===y)return!1;const[b,_]=function(e,t,n){const r=sh(e,t,n),i=Fh(r,t);if(i)return[Ih(e,r,i),Ih(e,r,Rh(i))];const o=Fh(r,n);if(o)return[Ih(e,r,Rh(o)),Ih(e,r,o)];const s=["minColumn","minRow"];return[Ih(e,r,s),Ih(e,r,Rh(s))]}(t,n,y),x=Vh(e,b.cell),S=Vh(e,_.cell);return e.$setAnchorCellForSelection(x),e.$setFocusCellForSelection(S,!0),!0}(i,e,t,o,n)}return c.selectEnd(),!0}return!1}function Kh(e){e.preventDefault(),e.stopImmediatePropagation(),e.stopPropagation()}function Uh(e,t,n){const r=Eo();"first"===e?t.insertBefore(r):t.insertAfter(r),r.append(...n||[]),r.selectEnd()}function Wh(e,t,n){const r=n.getParent();if(!r)return;const i=Zs(bh(e));if(!i)return;const o=i.anchorNode,s=e.getElementByKey(r.getKey()),l=yh(n,e.getElementByKey(n.getKey()));if(!o||!s||!l||!s.contains(o)||l.contains(o))return;const a=dl(t.anchor.getNode(),(e=>Id(e)));if(!a)return;const c=dl(a,(e=>eg(e)));if(!eg(c)||!c.is(n))return;const[u,d]=rh(n,a,a),h=u[0][0],g=u[u.length-1][u[0].length-1],{startRow:p,startColumn:f}=d,m=p===h.startRow&&f===h.startColumn,y=p===g.startRow&&f===g.startColumn;return m?"first":y?"last":void 0}function Vh(e,t){const{tableNode:n}=e.$lookup(),r=n.getCordsFromCellNode(t,e.table);return n.getDOMCellFromCordsOrThrow(r.x,r.y,e.table)}function qh(e,t,n){return _h(e,ls(t,n))}function jh(e,t,n){if(!t.theme.tableAlignment)return;const r=[],i=[];for(const e of["center","right"]){const o=t.theme.tableAlignment[e];o&&(e===n?i:r).push(o)}Oa(e,...r),La(e,...i)}const Zh=new WeakSet;function Gh(e=nl()){return Zh.has(e)}class Jh extends go{__rowStriping;__frozenColumnCount;__frozenRowCount;__colWidths;static getType(){return"table"}getColWidths(){return this.getLatest().__colWidths}setColWidths(e){const t=this.getWritable();return t.__colWidths=e,t}static clone(e){return new Jh(e.__key)}afterCloneFrom(e){super.afterCloneFrom(e),this.__colWidths=e.__colWidths,this.__rowStriping=e.__rowStriping,this.__frozenColumnCount=e.__frozenColumnCount,this.__frozenRowCount=e.__frozenRowCount}static importDOM(){return{table:e=>({conversion:Xh,priority:1})}}static importJSON(e){return Qh().updateFromJSON(e)}updateFromJSON(e){return super.updateFromJSON(e).setRowStriping(e.rowStriping||!1).setFrozenColumns(e.frozenColumnCount||0).setFrozenRows(e.frozenRowCount||0).setColWidths(e.colWidths)}constructor(e){super(e),this.__rowStriping=!1,this.__frozenColumnCount=0,this.__frozenRowCount=0,this.__colWidths=void 0}exportJSON(){return{...super.exportJSON(),colWidths:this.getColWidths(),frozenColumnCount:this.__frozenColumnCount?this.__frozenColumnCount:void 0,frozenRowCount:this.__frozenRowCount?this.__frozenRowCount:void 0,rowStriping:this.__rowStriping?this.__rowStriping:void 0}}extractWithChild(e,t,n){return"html"===n}getDOMSlot(e){const t=mh(e)?e:e.querySelector("table");return mh(t)||Md(229),super.getDOMSlot(e).withElement(t).withAfter(t.querySelector("colgroup"))}createDOM(e,t){const n=document.createElement("table");this.__style&&(n.style.cssText=this.__style);const r=document.createElement("colgroup");if(n.appendChild(r),function(e){e.__lexicalUnmanaged=!0}(r),La(n,e.theme.table),this.updateTableElement(null,n,e),Gh(t)){const t=document.createElement("div"),r=e.theme.tableScrollableWrapper;return r?La(t,r):t.style.cssText="overflow-x: auto;",t.appendChild(n),this.updateTableWrapper(null,t,n,e),t}return n}updateTableWrapper(e,t,n,r){this.__frozenColumnCount!==(e?e.__frozenColumnCount:0)&&function(e,t,n,r){r>0?(La(e,n.theme.tableFrozenColumn),t.setAttribute("data-lexical-frozen-column","true")):(Oa(e,n.theme.tableFrozenColumn),t.removeAttribute("data-lexical-frozen-column"))}(t,n,r,this.__frozenColumnCount),this.__frozenRowCount!==(e?e.__frozenRowCount:0)&&function(e,t,n,r){r>0?(La(e,n.theme.tableFrozenRow),t.setAttribute("data-lexical-frozen-row","true")):(Oa(e,n.theme.tableFrozenRow),t.removeAttribute("data-lexical-frozen-row"))}(t,n,r,this.__frozenRowCount)}updateTableElement(e,t,n){this.__style!==(e?e.__style:"")&&(t.style.cssText=this.__style),this.__rowStriping!==(!!e&&e.__rowStriping)&&function(e,t,n){n?(La(e,t.theme.tableRowStriping),e.setAttribute("data-lexical-row-striping","true")):(Oa(e,t.theme.tableRowStriping),e.removeAttribute("data-lexical-row-striping"))}(t,n,this.__rowStriping),function(e,t,n,r){const i=e.querySelector("colgroup");if(!i)return;const o=[];for(let e=0;e{if(t.after&&(n=t.after(n)),!mh(n)&&Js(n)&&(n=n.querySelector("table")),!mh(n))return null;jh(n,e._config,this.getFormatType());const[r]=ih(this,null,null),i=new Map;for(const e of r)for(const t of e){const e=t.cell.getKey();i.has(e)||i.set(e,{colSpan:t.cell.getColSpan(),startColumn:t.startColumn})}const o=new Set;for(const e of n.querySelectorAll(":scope > tr > [data-temporary-table-cell-lexical-key]")){const t=e.getAttribute("data-temporary-table-cell-lexical-key");if(t){const n=i.get(t);if(e.removeAttribute("data-temporary-table-cell-lexical-key"),n){i.delete(t);for(let e=0;e colgroup");if(s){const e=Array.from(n.querySelectorAll(":scope > colgroup > col")).filter(((e,t)=>o.has(t)));s.replaceChildren(...e)}const l=n.querySelectorAll(":scope > tr");if(l.length>0){const e=document.createElement("tbody");for(const t of l)e.appendChild(t);n.append(e)}return n},element:!mh(n)&&Js(n)?n.querySelector("table"):n}}canBeEmpty(){return!1}isShadowRoot(){return!0}getCordsFromCellNode(e,t){const{rows:n,domRows:r}=t;for(let t=0;t{Id(e)&&(t+=e.getColSpan())})),t}}function Yh(e,t){const n=e.getElementByKey(t.getKey());return null===n&&Md(230),Eh(t,n)}function Xh(e){const t=Qh();e.hasAttribute("data-lexical-row-striping")&&t.setRowStriping(!0),e.hasAttribute("data-lexical-frozen-column")&&t.setFrozenColumns(1),e.hasAttribute("data-lexical-frozen-row")&&t.setFrozenRows(1);const n=e.querySelector(":scope > colgroup");if(n){let e=[];for(const t of n.querySelectorAll(":scope > col")){let n=t.style.width||"";if(!kd.test(n)&&(n=t.getAttribute("width")||"",!/^\d+$/.test(n))){e=void 0;break}e.push(parseFloat(n))}e&&t.setColWidths(e)}return{after:e=>Ba(e,$d),node:t}}function Qh(){return Ws(new Jh)}function eg(e){return e instanceof Jh}function tg({rows:e,columns:t,includeHeaders:n}){const r=Li()||Oi();if(!r||!gi(r))return!1;if($h(r.anchor.getNode()))return!1;const i=function(e,t,n=!0){const r=Qh();for(let i=0;iMath.max(e,t.length)),0),r=e.getChildren();for(let e=0;et?1+e:e),0);if(o!==n)for(let e=o;epo(e)&&!e.isInline()));return null!==n&&(!!Id(n.getParent())&&(n.select(0),!0))}function sg(e){let t=e;for(;null!==t;){if(kc(t))return t;t=t.getParent()}return null}function lg(e){let t=e;for(;t;){if(Fc(t))return t.getListType();t=t.getParent()}return null}function ag(e,t=e=>e){return cg(jr,e,((e,n)=>({...e,forChild:(r,i)=>{const o=e?.forChild??(e=>e);let s=o(r,i);return ri(s)&&(s=t(s,n)??s),s}})))}function cg(e,t,n=e=>e){return r=>{const i=e.importDOM()?.[t]?.(r);if(!i)return null;const o=i.conversion(r);return o?n(o,r)??o:o}}function ug(e){const t="string"==typeof e?la(e):e;return!(!t.color&&!t["background-color"])}function dg(e,t){const n=document.activeElement;if(e.includes(n)){new hg(e,t.key).selectNext(n)&&t.preventDefault()}}class hg{constructor(e,t){this.elements=e,this.key=t}selectNext(e){const t=this.#e(e);if(t){const e=this.elements.filter((e=>e!==t));return this.#t(e),this.#n(t),!0}return!1}#e(e){switch(this.key){case"ArrowRight":case"ArrowDown":return this.#r(e);case"ArrowLeft":case"ArrowUp":return this.#i(e);case"Home":return this.#o();case"End":return this.#s()}}#o(e=this.elements){return e.find(gg)}#s(e=this.elements){return e.findLast(gg)}#r(e){const t=this.elements.slice(this.#l(e)+1);return this.#o(t)}#i(e){const t=this.elements.slice(0,this.#l(e));return this.#s(t)}#l(e){return this.elements.indexOf(e)}#n(e){gg(e)&&(e.tabIndex=0,e.focus())}#t(e){e.forEach((e=>e.tabIndex=-1))}}function gg(e){return e&&!e.disabled&&e.checkVisibility()}class pg extends HTMLElement{static observedAttributes=["connected"];constructor(){super(),this.internals=this.attachInternals(),this.internals.role="toolbar"}connectedCallback(){requestAnimationFrame((()=>this.#a())),this.setAttribute("role","toolbar"),this.#c()}disconnectedCallback(){this.#u(),this.#d(),this.#h()}attributeChangedCallback(e,t,n){"connected"===e&&this.isConnected&&null!=t&&t!==n&&requestAnimationFrame((()=>this.#g()))}setEditor(e){this.editorElement=e,this.editor=e.editor,this.#p(),this.#f(),this.#m(),this.#y(),this.#b(),this.#_(),this.#a(),this.#x(),this.toggleAttribute("connected",!0)}#g(){this.disconnectedCallback(),this.connectedCallback()}#c(){this.resizeObserver=new ResizeObserver((()=>this.#a())),this.resizeObserver.observe(this)}#u(){this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null)}#p(){this.addEventListener("click",this.#S.bind(this))}#S(e){this.#C(e,"[data-command]",this.#v.bind(this))}#C(e,t,n){const r=e.target.closest(t);r&&n(e,r)}#v(e,{dataset:{command:t,payload:n}}){const r=e instanceof PointerEvent&&-1===e.pointerId;this.editor.update((()=>{this.editor.dispatchCommand(t,n)}),{tag:r?Ir:void 0})}#f(){this.editorElement.addEventListener("keydown",this.#w)}#d(){this.editorElement?.removeEventListener("keydown",this.#w)}#w=e=>{this.querySelectorAll("[data-hotkey]").forEach((t=>{t.dataset.hotkey.toLowerCase().split(/\s+/).includes(this.#k(e))&&(e.preventDefault(),e.stopPropagation(),t.click())}))};#k(e){const t=e.key.toLowerCase();return[...[e.ctrlKey?"ctrl":null,e.metaKey?"cmd":null,e.altKey?"alt":null,e.shiftKey?"shift":null].filter(Boolean),t].join("+")}#x(){this.editorElement.addEventListener("lexxy:focus",this.#T),this.editorElement.addEventListener("lexxy:blur",this.#E),this.addEventListener("focusout",this.#E),this.addEventListener("keydown",this.#N)}#h(){this.editorElement.removeEventListener("lexxy:focus",this.#T),this.editorElement.removeEventListener("lexxy:blur",this.#E),this.removeEventListener("focusout",this.#E),this.removeEventListener("keydown",this.#N)}#T=()=>{this.#m(),this.#A[0].tabIndex=0};#E=()=>{this.contains(document.activeElement)||this.#m()};#N=e=>{dg(this.#A,e)};#m(){this.#A.forEach((e=>{e.tabIndex=-1}))}#b(){this.editor.registerUpdateListener((()=>{this.editor.getEditorState().read((()=>{this.#L()}))}))}#_(){this.editor.registerUpdateListener((()=>{this.#O()}))}#O(){this.editor.getEditorState().read((()=>{const e=this.editorElement.historyState;e&&(this.#F("undo",0===e.undoStack.length),this.#F("redo",0===e.redoStack.length))}))}#L(){const e=Li();if(!gi(e))return;const t=e.anchor.getNode();if(!t.getParent())return;const n=t.getTopLevelElementOrThrow(),r=e.hasFormat("bold"),i=e.hasFormat("italic"),o=e.hasFormat("strikethrough"),s=function(e){return!!gi(e)&&(e.isCollapsed()?ug(e.style):e.hasFormat("highlight"))}(e),l=this.#R(t),a=uu(n),c=mu(n),u=Pu(n)||e.hasFormat("code"),d=this.#I(t),h=lg(t),g=null!==Wd(t);this.#P("bold",r),this.#P("italic",i),this.#P("strikethrough",o),this.#P("highlight",s),this.#P("link",l),this.#P("quote",a),this.#P("heading",c),this.#P("code",u),this.#P("unordered-list",d&&"bullet"===h),this.#P("ordered-list",d&&"number"===h),this.#P("table",g),this.#O()}#I(e){let t=e;for(;t;){if(Fc(t)||kc(t))return!0;t=t.getParent()}return!1}#R(e){let t=e;for(;t;){if(yd(t))return!0;t=t.getParent()}return!1}#P(e,t){const n=this.querySelector(`[name="${e}"]`);n&&n.setAttribute("aria-pressed",t.toString())}#F(e,t){const n=this.querySelector(`[name="${e}"]`);n&&(n.disabled=t,n.setAttribute("aria-disabled",t.toString()))}#M(){return this.scrollWidth>this.clientWidth}#a=()=>{this.#D(),this.#B(),this.#z.style.display=this.#$.children.length?"block":"none",this.#z.setAttribute("nonce",wa());const e=this.#$.children.length>0;this.toggleAttribute("overflowing",e),this.#$.toggleAttribute("disabled",!e)};#B(){const e=this.#H.reverse();let t=!1;for(const n of e){if(!this.#M()){t&&this.#$.prepend(n);break}this.#$.prepend(n),t=!0}}#D(){const e=Array.from(this.#$.children);e.sort(((e,t)=>this.#K(t)-this.#K(e))),e.forEach((e=>{const t=this.querySelector(`[data-position="${this.#K(e)+1}"]`)??this.#z;this.insertBefore(e,t)}))}#K(e){return parseInt(e.dataset.position??"999")}#y(){this.#U.forEach(((e,t)=>{void 0===e.dataset.position&&(e.dataset.position=t)}))}get#z(){return this.querySelector(".lexxy-editor__toolbar-overflow")}get#$(){return this.querySelector(".lexxy-editor__toolbar-overflow-menu")}get#H(){return Array.from(this.querySelectorAll(":scope > button"))}get#A(){return Array.from(this.querySelectorAll(":scope button, :scope > details > summary"))}get#U(){return Array.from(this.querySelectorAll(":scope > *:not(.lexxy-editor__toolbar-overflow)"))}static get defaultTemplate(){return'\n \n\n \n\n \n\n
\n \n \n \n \n
\n
\n \n
\n
\n\n
\n \n \n \n \n
\n \n
\n \n \n
\n
\n
\n
\n\n \n\n \n\n \n\n \n\n \n\n \n\n \n\n \n \n \n \n \n\n \n\n
\n •••\n
\n
\n '}}function fg(e,t){const n={};for(const r of e){const e=t(r);e&&(n[e]?n[e].push(r):n[e]=[r])}return n}customElements.define("lexxy-toolbar",pg);const mg=/[!-/:-@[-`{-~\s]/;function yg(e,...t){const n=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",e);for(const e of t)r.append("v",e);throw n.search=r.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}const bg=function(e,t){return new at(e,t)}("mdListMarker",{parse:e=>"string"==typeof e&&/^[-*+]$/.test(e)?e:"-"}),_g=e=>(t,n,r,i)=>{const o=e(r);o.append(...n),t.replace(o),i||o.select(0,0)},xg=e=>(t,n,r,i)=>{const o=t.getPreviousSibling(),s=t.getNextSibling(),l=wc("check"===e?"x"===r[3]:void 0),a=r[0].trim()[0],c="bullet"!==e&&"check"!==e||a!==bg.parse(a)?void 0:a;if(Fc(s)&&s.getListType()===e){c&&ut(s,bg,c);const e=s.getFirstChild();null!==e?e.insertBefore(l):s.append(l),t.remove()}else if(Fc(o)&&o.getListType()===e)c&&ut(o,bg,c),o.append(l),t.remove();else{const n=Oc(e,"number"===e?Number(r[2]):void 0);c&&ut(n,bg,c),n.append(l),t.replace(n)}l.append(...n),i||l.select(0,0);const u=function(e){const t=e.match(/\t/g),n=e.match(/ /g);let r=0;return t&&(r+=t.length),n&&(r+=Math.floor(n.length/4)),r}(r[1]);u&&l.setIndent(u)},Sg=(e,t,n)=>{const r=[],i=e.getChildren();let o=0;for(const s of i)if(kc(s)){if(1===s.getChildrenSize()){const e=s.getFirstChild();if(Fc(e)){r.push(Sg(e,t,n+1));continue}}const i=" ".repeat(4*n),l=e.getListType(),a=ct(e,bg),c="number"===l?`${e.getStart()+o}. `:"check"===l?`${a} [${s.getChecked()?"x":" "}] `:a+" ";r.push(i+c+t(s)),o++}return r.join("\n")},Cg={dependencies:[du],export:(e,t)=>{if(!mu(e))return null;const n=Number(e.getTag().slice(1));return"#".repeat(n)+" "+t(e)},regExp:/^(#{1,6})\s/,replace:_g((e=>fu("h"+e[1].length))),type:"element"},vg={dependencies:[au],export:(e,t)=>{if(!uu(e))return null;const n=t(e).split("\n"),r=[];for(const e of n)r.push("> "+e);return r.join("\n")},regExp:/^>\s/,replace:(e,t,n,r)=>{if(r){const n=e.getPreviousSibling();if(uu(n))return n.splice(n.getChildrenSize(),0,[Br(),...t]),void e.remove()}const i=cu();i.append(...t),e.replace(i),r||i.select(0,0)},type:"element"},wg={dependencies:[Ru],export:e=>{if(!Pu(e))return null;const t=e.getTextContent();return"```"+(e.getLanguage()||"")+(t?"\n"+t:"")+"\n```"},regExpEnd:{optional:!0,regExp:/[ \t]*```$/},regExpStart:/^[ \t]*```([\w-]+)?/,replace:(e,t,n,r,i,o)=>{let s,l;if(!t&&i){if(1===i.length)r?(s=Iu(),l=n[1]+i[0]):(s=Iu(n[1]),l=i[0].startsWith(" ")?i[0].slice(1):i[0]);else{if(s=Iu(n[1]),0===i[0].trim().length)for(;i.length>0&&!i[0].length;)i.shift();else i[0]=i[0].startsWith(" ")?i[0].slice(1):i[0];for(;i.length>0&&!i[i.length-1].length;)i.pop();l=i.join("\n")}const t=ni(l);s.append(t),e.append(s)}else t&&_g((e=>Iu(e?e[1]:void 0)))(e,t,n,o)},type:"multiline-element"},kg={dependencies:[Tc,Sc],export:(e,t)=>Fc(e)?Sg(e,t,0):null,regExp:/^(\s*)[-*+]\s/,replace:xg("bullet"),type:"element"},Tg={dependencies:[Tc,Sc],export:(e,t)=>Fc(e)?Sg(e,t,0):null,regExp:/^(\s*)(\d{1,})\.\s/,replace:xg("number"),type:"element"},Eg={dependencies:[pd],export:(e,t,n)=>{if(!yd(e)||xd(e))return null;const r=e.getTitle(),i=t(e);return r?`[${i}](${e.getURL()} "${r}")`:`[${i}](${e.getURL()})`},importRegExp:/(?:\[(.+?)\])(?:\((?:([^()\s]+)(?:\s"((?:[^"]*\\")*[^"]*)"\s*)?)\))/,regExp:/(?:\[(.+?)\])(?:\((?:([^()\s]+)(?:\s"((?:[^"]*\\")*[^"]*)"\s*)?)\))$/,replace:(e,t)=>{const[,n,r,i]=t,o=md(r,{title:i}),s=n.split("[").length-1,l=n.split("]").length-1;let a=n,c="";if(sl){const e=n.split("[");c="["+e[0],a=e.slice(1).join("[")}const u=ni(a);return u.setFormat(e.getFormat()),o.append(u),e.replace(o),c&&o.insertBefore(ni(c)),u},trigger:")",type:"text-match"},Ng=[...[Cg,vg,kg,Tg],...[wg],...[{format:["code"],tag:"`",type:"text-format"},{format:["bold","italic"],tag:"***",type:"text-format"},{format:["bold","italic"],intraword:!1,tag:"___",type:"text-format"},{format:["bold"],tag:"**",type:"text-format"},{format:["bold"],intraword:!1,tag:"__",type:"text-format"},{format:["highlight"],tag:"==",type:"text-format"},{format:["italic"],tag:"*",type:"text-format"},{format:["italic"],intraword:!1,tag:"_",type:"text-format"},{format:["strikethrough"],tag:"~~",type:"text-format"}],...[Eg]];function Ag(e,t,n){const r=n.length;for(let i=t;i>=r;i--){const t=i-r;if(Lg(e,t,n,0,r)&&" "!==e[t+r])return t}return-1}function Lg(e,t,n,r,i){for(let o=0;oe.type));return{element:t.element||[],multilineElement:t["multiline-element"]||[],textFormat:t["text-format"]||[],textMatch:t["text-match"]||[]}}(t),r=fg(n.textFormat,(({tag:e})=>e[e.length-1])),i=fg(n.textMatch,(({trigger:e})=>e));for(const n of t){const t=n.type;if("element"===t||"text-match"===t||"multiline-element"===t){const t=n.dependencies;for(const n of t)e.hasNode(n)||yg(173,n.getType())}}const o=(e,t,o)=>{(function(e,t,n,r){if(!Ks(e.getParent())||e.getFirstChild()!==t)return!1;const i=t.getTextContent();if(" "!==i[n-1])return!1;for(const{regExp:o,replace:s}of r){const r=i.match(o);if(r&&r[0].length===(r[0].endsWith(" ")?n:n-1)){const i=t.getNextSiblings(),[o,l]=t.splitText(n);if(!1!==s(e,l?[l,...i]:i,r,!1))return o.remove(),!0}}return!1})(e,t,o,n.element)||function(e,t,n,r){if(!Ks(e.getParent())||e.getFirstChild()!==t)return!1;const i=t.getTextContent();if(" "!==i[n-1])return!1;for(const{regExpStart:o,replace:s,regExpEnd:l}of r){if(l&&!("optional"in l)||l&&"optional"in l&&!l.optional)continue;const r=i.match(o);if(r&&r[0].length===(r[0].endsWith(" ")?n:n-1)){const i=t.getNextSiblings(),[o,l]=t.splitText(n);if(!1!==s(e,l?[l,...i]:i,r,null,null,!1))return o.remove(),!0}}return!1}(e,t,o,n.multilineElement)||function(e,t,n){let r=e.getTextContent();const i=n[r[t-1]];if(null==i)return!1;t1&&!Lg(r,l,n,0,s))continue;if(" "===r[l-1])continue;const a=r[i+1];if(!1===t.intraword&&a&&!mg.test(a))continue;const c=e;let u=c,d=Ag(r,l,n),h=u;for(;d<0&&(h=h.getPreviousSibling())&&!zr(h);)if(ri(h)){if(h.hasFormat("code"))continue;const e=h.getTextContent();u=h,d=Ag(e,e.length,n)}if(d<0)continue;if(u===c&&d+s===l)continue;const g=u.getTextContent();if(d>0&&g[d-1]===o)continue;const p=g[d-1];if(!1===t.intraword&&p&&!mg.test(p))continue;const f=c.getTextContent(),m=f.slice(0,l)+f.slice(i+1);c.setTextContent(m);const y=u===c?m:g;u.setTextContent(y.slice(0,d)+y.slice(d+s));const b=Li(),_=Ei();hs(_);const x=i-s*(u===c?2:1)+1;_.anchor.set(u.__key,d,"text"),_.focus.set(c.__key,x,"text");for(const e of t.format)_.hasFormat(e)||_.formatText(e);_.anchor.set(_.focus.key,_.focus.offset,_.focus.type);for(const e of t.format)_.hasFormat(e)&&_.toggleFormat(e);return gi(b)&&(_.format=b.format),!0}}(t,o,r)};return e.registerUpdateListener((({tags:t,dirtyLeaves:n,editorState:r,prevEditorState:i})=>{if(t.has(Fr)||t.has(Lr))return;if(e.isComposing())return;const s=r.read(Li),l=i.read(Li);if(!gi(l)||!gi(s)||!s.isCollapsed()||s.is(l))return;const a=s.anchor.key,c=s.anchor.offset,u=r._nodeMap.get(a);!ri(u)||!n.has(a)||1!==c&&c>l.anchor.offset+1||e.update((()=>{if(!function(e){return ri(e)&&!e.hasFormat("code")}(u))return;const e=u.getParent();null===e||Pu(e)||o(e,u,s.anchor.offset)}))}))}function Fg(e,t){let n=Date.now(),r=0;return(i,o,s,l,a,c)=>{const u=Date.now();if(c.has(Lr))return r=0,n=u,2;const d=function(e,t,n,r,i){if(null===e||0===n.size&&0===r.size&&!i)return 0;const o=t._selection,s=e._selection;if(i)return 1;if(!(gi(o)&&gi(s)&&s.isCollapsed()&&o.isCollapsed()))return 0;const l=function(e,t,n){const r=e._nodeMap,i=[];for(const e of t){const t=r.get(e);void 0!==t&&i.push(t)}for(const[e,t]of n){if(!t)continue;const n=r.get(e);void 0===n||_o(n)||i.push(n)}return i}(t,n,r);if(0===l.length)return 0;if(l.length>1){const n=t._nodeMap,r=n.get(o.anchor.key),i=n.get(s.anchor.key);return r&&i&&!e._nodeMap.has(r.__key)&&ri(r)&&1===r.__text.length&&1===o.anchor.offset?2:0}const a=l[0],c=e._nodeMap.get(a.__key);if(!ri(c)||!ri(a)||c.__mode!==a.__mode)return 0;const u=c.__text,d=a.__text;if(u===d)return 0;const h=o.anchor,g=s.anchor;if(h.key!==g.key||"text"!==h.type)return 0;const p=h.offset,f=g.offset,m=d.length-u.length;return 1===m&&f===p-1?2:-1===m&&f===p+1?3:-1===m&&f===p?4:0}(i,o,l,a,e.isComposing()),h=(()=>{const h=null===s||s.editor===e,g=c.has("history-push");if(!g&&h&&c.has(Or))return 0;if(null===i)return 1;const p=o._selection;if(!(l.size>0||a.size>0))return null!==p?0:2;const f="number"==typeof t?t:t.peek();return!1===g&&0!==d&&d===r&&ur.exportJSON())))===JSON.stringify(n.read((()=>i.exportJSON())))}(Array.from(l)[0],i,o)?0:1})();return n=u,r=d,h}}function Rg(e){e.undoStack=[],e.redoStack=[],e.current=null}function Ig(e,t,n){const r=Fg(e,n),i=Aa(e.registerCommand(bn,(()=>(function(e,t){const n=t.redoStack,r=t.undoStack;if(0!==r.length){const i=t.current,o=r.pop();null!==i&&(n.push(i),e.dispatchCommand(qn,!0)),0===r.length&&e.dispatchCommand(jn,!1),t.current=o||null,o&&o.editor.setEditorState(o.editorState,{tag:Lr})}}(e,t),!0)),0),e.registerCommand(_n,(()=>(function(e,t){const n=t.redoStack,r=t.undoStack;if(0!==n.length){const i=t.current;null!==i&&(r.push(i),e.dispatchCommand(jn,!0));const o=n.pop();0===n.length&&e.dispatchCommand(qn,!1),t.current=o||null,o&&o.editor.setEditorState(o.editorState,{tag:Lr})}}(e,t),!0)),0),e.registerCommand(Wn,(()=>(Rg(t),!1)),0),e.registerCommand(Vn,(()=>(Rg(t),e.dispatchCommand(qn,!1),e.dispatchCommand(jn,!1),!0)),0),e.registerUpdateListener((({editorState:n,prevEditorState:i,dirtyLeaves:o,dirtyElements:s,tags:l})=>{const a=t.current,c=t.redoStack,u=t.undoStack,d=null===a?null:a.editorState;if(null!==a&&n===d)return;const h=r(i,n,a,o,s,l);if(1===h)0!==c.length&&(t.redoStack=[],e.dispatchCommand(qn,!1)),null!==a&&(u.push({...a}),e.dispatchCommand(jn,!0));else if(2===h)return;t.current={editor:e,editorState:n}})));return i}function Pg(){return{current:null,redoStack:[],undoStack:[]}}var Mg={text:{bold:"lexxy-content__bold",italic:"lexxy-content__italic",strikethrough:"lexxy-content__strikethrough",underline:"lexxy-content__underline",highlight:"lexxy-content__highlight"},tableCellHeader:"lexxy-content__table-cell--header",tableCellSelected:"lexxy-content__table-cell--selected",tableSelection:"lexxy-content__table--selection",tableScrollableWrapper:"lexxy-content__table-wrapper",list:{nested:{listitem:"lexxy-nested-listitem"}},codeHighlight:{addition:"code-token__selector",atrule:"code-token__attr",attr:"code-token__attr","attr-name":"code-token__attr","attr-value":"code-token__selector",boolean:"code-token__property",bold:"code-token__variable",builtin:"code-token__selector",cdata:"code-token__comment",char:"code-token__selector",class:"code-token__function","class-name":"code-token__function",color:"code-token__property",comment:"code-token__comment",constant:"code-token__property",coord:"code-token__comment",decorator:"code-token__function",deleted:"code-token__operator",deletion:"code-token__operator",directive:"code-token__attr","directive-hash":"code-token__property",doctype:"code-token__comment",entity:"code-token__operator",function:"code-token__function",hexcode:"code-token__property",important:"code-token__function",inserted:"code-token__selector",italic:"code-token__comment",keyword:"code-token__attr",line:"code-token__selector",namespace:"code-token__variable",number:"code-token__property",macro:"code-token__function",operator:"code-token__operator",parameter:"code-token__variable",prolog:"code-token__comment",property:"code-token__property",punctuation:"code-token__punctuation","raw-string":"code-token__operator",regex:"code-token__variable",script:"code-token__function",selector:"code-token__selector",string:"code-token__selector",style:"code-token__function",symbol:"code-token__property",tag:"code-token__property",title:"code-token__function","type-definition":"code-token__function",url:"code-token__operator",variable:"code-token__variable"}};function Dg(e,t,n=""){const r=document.createElement(e);for(const[e,n]of Object.entries(t||{}))e in r?r[e]=n:null!=n&&r.setAttribute(e,n);return n&&(r.innerHTML=n),r}function Bg(e){return(new DOMParser).parseFromString(e,"text/html")}function zg(e,t,n){const r=new CustomEvent(t,{detail:n,bubbles:!0});e.dispatchEvent(r)}function $g(e,t,n=null,r=!1){return e.dispatchEvent(new CustomEvent(t,{bubbles:!0,detail:n,cancelable:r}))}function Hg(e){return`${e}-${Math.random().toString(36).slice(2,10)}`}function Kg(e){if(0===e)return"0 B";const t=Math.floor(Math.log(e)/Math.log(1024));return`${(e/Math.pow(1024,t)).toFixed(2)} ${["B","KB","MB","GB","TB","PB"][t]}`}class Ug extends mo{static getType(){return"action_text_attachment"}static clone(e){return new Ug({...e},e.__key)}static importJSON(e){return new Ug({...e})}static importDOM(){return{"action-text-attachment":e=>({conversion:()=>({node:new Ug({sgid:e.getAttribute("sgid"),src:e.getAttribute("url"),previewable:e.getAttribute("previewable"),altText:e.getAttribute("alt"),caption:e.getAttribute("caption"),contentType:e.getAttribute("content-type"),fileName:e.getAttribute("filename"),fileSize:e.getAttribute("filesize"),width:e.getAttribute("width"),height:e.getAttribute("height")})}),priority:1}),img:e=>({conversion:()=>({node:new Ug({src:e.getAttribute("src"),caption:e.getAttribute("alt")||"",contentType:"image/*",width:e.getAttribute("width"),height:e.getAttribute("height")})}),priority:1}),video:e=>{const t=e.getAttribute("src")||e.querySelector("source")?.src,n=t?.split("/")?.pop(),r=e.querySelector("source")?.getAttribute("content-type")||"video/*";return{conversion:()=>({node:new Ug({src:t,fileName:n,contentType:r})}),priority:1}}}}constructor({sgid:e,src:t,previewable:n,altText:r,caption:i,contentType:o,fileName:s,fileSize:l,width:a,height:c},u){super(u),this.sgid=e,this.src=t,this.previewable=n,this.altText=r||"",this.caption=i||"",this.contentType=o||"",this.fileName=s||"",this.fileSize=l,this.width=a,this.height=c}createDOM(){const e=this.createAttachmentFigure();return e.addEventListener("click",(t=>{this.#W(e)})),this.isPreviewableAttachment?(e.appendChild(this.#V()),e.appendChild(this.#q())):(e.appendChild(this.#j()),e.appendChild(this.#Z())),e}updateDOM(){return!0}getTextContent(){return`[${this.caption||this.fileName}]\n\n`}isInline(){return!1}exportDOM(){return{element:Dg("action-text-attachment",{sgid:this.sgid,previewable:this.previewable||null,url:this.src,alt:this.altText,caption:this.caption,"content-type":this.contentType,filename:this.fileName,filesize:this.fileSize,width:this.width,height:this.height,presentation:"gallery"})}}exportJSON(){return{type:"action_text_attachment",version:1,sgid:this.sgid,src:this.src,previewable:this.previewable,altText:this.altText,caption:this.caption,contentType:this.contentType,fileName:this.fileName,fileSize:this.fileSize,width:this.width,height:this.height}}decorate(){return null}createAttachmentFigure(){return e=this.contentType,t=this.isPreviewableAttachment,n=this.fileName,Dg("figure",{className:`attachment attachment--${t?"preview":"file"} attachment--${n?n.split(".").pop().toLowerCase():"unknown"}`,"data-content-type":e});var e,t,n}get#G(){return(e=this.contentType).startsWith("image/")&&!e.includes("svg");var e}get isPreviewableAttachment(){return this.#G||this.previewable}#V(){return Dg("img",{src:this.src,alt:this.altText,...this.#J})}get#J(){return this.width&&this.height?{width:this.width,height:this.height}:{}}#j(){return Dg("span",{className:"attachment__icon",textContent:`${this.fileName?this.fileName.split(".").pop().toLowerCase():"unknown"}`})}#Z(){const e=Dg("figcaption",{className:"attachment__caption"}),t=Dg("strong",{className:"attachment__name",textContent:this.caption||this.fileName});if(e.appendChild(t),this.fileSize){const t=Dg("span",{className:"attachment__size",textContent:Kg(this.fileSize)});e.appendChild(t)}return e}#W(e){zg(e,"lexxy:internal:select-node",{key:this.getKey()})}#q(){const e=Dg("figcaption",{className:"attachment__caption"}),t=Dg("textarea",{value:this.caption,placeholder:this.fileName,rows:"1"});return t.addEventListener("focusin",(()=>t.placeholder="Add caption...")),t.addEventListener("blur",this.#Y.bind(this)),t.addEventListener("keydown",this.#X.bind(this)),e.appendChild(t),e}#Y(e){const t=e.target;t.placeholder=this.fileName,this.#Q(t)}#Q(e){zg(e,"lexxy:internal:invalidate-node",{key:this.getKey(),values:{caption:e.value}})}#X(e){"Enter"===e.key&&(this.#Q(e.target),zg(e.target,"lexxy:internal:move-to-next-line"),e.preventDefault()),e.stopPropagation()}}class Wg extends Ug{static getType(){return"action_text_attachment_upload"}static clone(e){return new Wg({...e},e.__key)}static importJSON(e){return new Wg({...e})}static importDOM(){return null}constructor({file:e,uploadUrl:t,blobUrlTemplate:n,editor:r,progress:i},o){super({contentType:e.type},o),this.file=e,this.uploadUrl=t,this.blobUrlTemplate=n,this.src=null,this.editor=r,this.progress=i||0}createDOM(){const e=this.createAttachmentFigure();this.isPreviewableAttachment?e.appendChild(this.#V()):e.appendChild(this.#j()),e.appendChild(this.#ee());const t=Dg("progress",{value:this.progress,max:100});return e.appendChild(t),this.#te(e).then((()=>this.#ne(t,e))),e}exportDOM(){const e=document.createElement("img");return this.src&&(e.src=this.src),{element:e}}exportJSON(){return{type:"action_text_attachment_upload",version:1,progress:this.progress,uploadUrl:this.uploadUrl,blobUrlTemplate:this.blobUrlTemplate,...super.exportJSON()}}#V(){return Dg("img")}#j(){return Dg("span",{className:"attachment__icon",textContent:this.#re()})}#re(){return this.file.name.split(".").pop().toLowerCase()}#ee(){const e=Dg("figcaption",{className:"attachment__caption"}),t=Dg("span",{className:"attachment__name",textContent:this.file.name||""}),n=Dg("span",{className:"attachment__size",textContent:Kg(this.file.size)});return e.appendChild(t),e.appendChild(n),e}#te(e){const t=e.querySelector("img");return t?async function(e,t){return new Promise((n=>{const r=new FileReader;t.addEventListener("load",(()=>{n(t)})),r.onload=e=>{t.src=e.target.result||null},r.readAsDataURL(e)}))}(this.file,t):Promise.resolve()}#ne(t,n){const r=new e(this.file,this.uploadUrl,this);r.delegate={directUploadWillStoreFileWithXHR:e=>{e.upload.addEventListener("progress",(e=>{this.editor.update((()=>{t.value=Math.round(e.loaded/e.total*100)}))}))}},r.create(((e,t)=>{e?this.#ie(n):this.#oe(t,n).then((()=>{this.#se(n,t)}))}))}#ie(e){e.innerHTML="",e.classList.add("attachment--error"),e.appendChild(Dg("div",{innerText:`Error uploading ${this.file?.name??"image"}`}))}async#se(e,t){this.editor.update((()=>{const n=e.querySelector("img"),r=this.blobUrlTemplate.replace(":signed_id",t.signed_id).replace(":filename",encodeURIComponent(t.filename)),i=is(this.getKey());i&&i.replace(new Ug({sgid:t.attachable_sgid,src:t.previewable?t.url:r,altText:t.filename,contentType:t.content_type,fileName:t.filename,fileSize:t.byte_size,width:n?.naturalWidth,previewable:t.previewable,height:n?.naturalHeight}))}),{tag:Or})}async#oe(e,t){return e.previewable?new Promise((n=>{this.editor.update((()=>{const r=this.#V();r.addEventListener("load",(()=>{n()})),r.src=e.url,t.insertBefore(r,t.firstChild)}))})):Promise.resolve()}}class Vg extends mo{static getType(){return"horizontal_divider"}static clone(e){return new Vg(e.__key)}static importJSON(e){return new Vg}static importDOM(){return{hr:e=>({conversion:()=>({node:new Vg}),priority:1})}}constructor(e){super(e)}createDOM(){const e=Dg("figure",{className:"horizontal-divider"}),t=Dg("hr");return e.addEventListener("click",(t=>{zg(e,"lexxy:internal:select-node",{key:this.getKey()})})),e.appendChild(t),e}updateDOM(){return!0}getTextContent(){return"┄\n\n"}isInline(){return!1}exportDOM(){return{element:Dg("hr")}}exportJSON(){return{type:"horizontal_divider",version:1}}decorate(){return null}}const qg=["bold","italic","strikethrough","link","unlink","toggleHighlight","removeHighlight","rotateHeadingFormat","insertUnorderedList","insertOrderedList","insertQuoteBlock","insertCodeBlock","insertHorizontalDivider","uploadAttachments","insertTable","insertTableRowAbove","insertTableRowBelow","insertTableColumnAfter","insertTableColumnBefore","deleteTableRow","deleteTableColumn","deleteTable","undo","redo"];class jg{static configureFor(e){new jg(e)}constructor(e){this.editorElement=e,this.editor=e.editor,this.selection=e.selection,this.contents=e.contents,this.clipboard=e.clipboard,this.highlighter=e.highlighter,this.#le(),this.#ae(),this.#ce()}dispatchPaste(e){return this.clipboard.paste(e)}dispatchBold(){this.editor.dispatchCommand(yn,"bold")}dispatchItalic(){this.editor.dispatchCommand(yn,"italic")}dispatchStrikethrough(){this.editor.dispatchCommand(yn,"strikethrough")}dispatchToggleHighlight(e){this.highlighter.toggle(e)}dispatchRemoveHighlight(){this.highlighter.remove()}dispatchLink(e){this.editor.update((()=>{const t=Li();if(gi(t))if(t.isCollapsed()){const n=_d(e),r=ni(e);n.append(r),t.insertNodes([n])}else Cd(e)}))}dispatchUnlink(){this.#ue(null)}dispatchInsertUnorderedList(){const e=Li();if(!e)return;const t=e.anchor.getNode();this.selection.isInsideList&&t&&"bullet"===lg(t)?this.contents.unwrapSelectedListItems():this.editor.dispatchCommand(Ic,void 0)}dispatchInsertOrderedList(){const e=Li();if(!e)return;const t=e.anchor.getNode();this.selection.isInsideList&&t&&"number"===lg(t)?this.contents.unwrapSelectedListItems():this.editor.dispatchCommand(Pc,void 0)}dispatchInsertQuoteBlock(){this.contents.toggleNodeWrappingAllSelectedNodes((e=>uu(e)),(()=>cu()))}dispatchInsertCodeBlock(){this.editor.update((()=>{this.selection.hasSelectedWordsInSingleLine?this.editor.dispatchCommand(yn,"code"):this.contents.toggleNodeWrappingAllSelectedLines((e=>Pu(e)),(()=>new Ru("plain")))}))}dispatchInsertHorizontalDivider(){this.editor.update((()=>{this.contents.insertAtCursorEnsuringLineBelow(new Vg)})),this.editor.focus()}dispatchRotateHeadingFormat(){this.editor.update((()=>{const e=Li();if(!gi(e))return;const t=e.anchor.getNode().getTopLevelElementOrThrow();let n="h2";if(mu(t)){const e=t.getTag();n="h2"===e?"h3":"h3"===e?"h4":"h4"===e?null:"h2"}n?this.contents.insertNodeWrappingEachSelectedLine((()=>fu(n))):this.contents.removeFormattingFromSelectedLines()}))}dispatchUploadAttachments(){const e=Dg("input",{type:"file",multiple:!0,style:"display: none;",onchange:({target:e})=>{const t=Array.from(e.files);if(t.length)for(const e of t)this.contents.uploadFile(e)}});this.editorElement.appendChild(e),e.click(),setTimeout((()=>e.remove()),1e3)}dispatchInsertTable(){this.editor.dispatchCommand(Pd,{rows:3,columns:3,includeHeaders:!0})}dispatchInsertTableRowBelow(){Zd(!0)}dispatchInsertTableRowAbove(){Zd(!1)}dispatchInsertTableColumnAfter(){Jd(!0)}dispatchInsertTableColumnBefore(){Jd(!1)}dispatchDeleteTableRow(){!function(){const e=Li();gi(e)||uh(e)||Md(188);const[t,n]=e.isBackward()?[e.focus.getNode(),e.anchor.getNode()]:[e.anchor.getNode(),e.focus.getNode()],[r,,i]=oh(t),[o]=oh(n),[s,l,a]=rh(i,r,o),{startRow:c}=l,{startRow:u}=a,d=u+o.__rowSpan-1;if(s.length===d-c+1)return void i.remove();const h=s[0].length,g=s[d+1],p=i.getChildAtIndex(d+1);for(let e=d;e>=c;e--){for(let t=h-1;t>=0;t--){const{cell:n,startRow:r,startColumn:i}=s[e][t];if(i===t){if(rd){const e=Math.max(r,c),t=Math.min(n.__rowSpan+r-1,d),i=e<=t?t-e+1:0;n.setRowSpan(n.__rowSpan-i)}if(r>=c&&r+n.__rowSpan-1>d&&e===d){null===p&&Md(122);let r=null;for(let n=0;n1&&(n+=i.__colSpan-1)}null===r?Qd(p,n):r.insertAfter(n)}}}const t=i.getChildAtIndex(e);$d(t)||Md(206,String(e)),t.remove()}if(void 0!==g){const{cell:e}=g[0];Xd(e)}else{const e=s[c-1],{cell:t}=e[0];Xd(t)}}()}dispatchDeleteTableColumn(){!function(){const e=Li();gi(e)||uh(e)||Md(188);const t=e.anchor.getNode(),n=e.focus.getNode(),[r,,i]=oh(t),[o]=oh(n),[s,l,a]=rh(i,r,o),{startColumn:c}=l,{startRow:u,startColumn:d}=a,h=Math.min(c,d),g=Math.max(c+r.__colSpan-1,d+o.__colSpan-1),p=g-h+1;if(s[0].length===g-h+1)return i.selectPrevious(),void i.remove();const f=s.length;for(let e=0;eg){if(t===g){const e=g-r+1;n.setColSpan(n.__colSpan-e)}}else n.remove()}const m=s[u],y=c>d?m[c+r.__colSpan]:m[d+o.__colSpan];if(void 0!==y){const{cell:e}=y;Xd(e)}else{const e=d{const e=Li();if(!gi(e))return;$h(e.anchor.getNode()).remove()}))}dispatchUndo(){this.editor.dispatchCommand(bn,void 0)}dispatchRedo(){this.editor.dispatchCommand(_n,void 0)}#le(){for(const t of qg){const n=`dispatch${e=t,e.charAt(0).toUpperCase()+e.slice(1)}`;this.#de(t,0,this[n].bind(this))}var e;this.#de(gn,1,this.dispatchPaste.bind(this))}#de(e,t,n){this.editor.registerCommand(e,n,t)}#ae(){this.editor.registerCommand(Fn,this.#he.bind(this),2)}#ce(){this.editorElement.supportsAttachments&&(this.dragCounter=0,this.editor.getRootElement().addEventListener("dragover",this.#ge.bind(this)),this.editor.getRootElement().addEventListener("drop",this.#pe.bind(this)),this.editor.getRootElement().addEventListener("dragenter",this.#fe.bind(this)),this.editor.getRootElement().addEventListener("dragleave",this.#me.bind(this)))}#fe(e){this.dragCounter++,1===this.dragCounter&&this.editor.getRootElement().classList.add("lexxy-editor--drag-over")}#me(e){this.dragCounter--,0===this.dragCounter&&this.editor.getRootElement().classList.remove("lexxy-editor--drag-over")}#ge(e){e.preventDefault()}#pe(e){e.preventDefault(),this.dragCounter=0,this.editor.getRootElement().classList.remove("lexxy-editor--drag-over");const t=e.dataTransfer;if(!t)return;const n=Array.from(t.files);if(n.length){for(const e of n)this.contents.uploadFile(e);this.editor.focus()}}#he(e){return this.selection.isInsideList?this.#ye(e):!!this.selection.isInsideCodeBlock&&this.#be()}#ye(e){if(e.shiftKey&&!this.selection.isIndentedList)return!1;e.preventDefault();const t=e.shiftKey?Pn:In;return this.editor.dispatchCommand(t)}#be(){const e=Li();return gi(e)&&e.isCollapsed()}#ue(e){this.editor.update((()=>{Cd(null===e?null:e)}))}}function Zg(){return new Promise(requestAnimationFrame)}class Gg{constructor(e){this.editorElement=e,this.editorContentElement=e.editorContentElement,this.editor=this.editorElement.editor,this.previouslySelectedKeys=new Set,this.#_e(),this.#xe(),this.#Se(),this.#Ce()}clear(){this.current=null}set current(e){fi(e)?this.editor.getEditorState().read((()=>{this._current=Li(),this.#ve()})):this.editor.update((()=>{this.#ve(),this._current=null}))}get current(){return this._current}get cursorPosition(){let e={x:0,y:0};return this.editor.getEditorState().read((()=>{const t=this.#we();if(!t)return;const n=this.#ke(t);n&&(e=this.#Te(n,t))})),e}placeCursorAtTheEnd(){this.editor.update((()=>{us().selectEnd()}))}selectedNodeWithOffset(){const e=Li();if(!e)return{node:null,offset:0};if(gi(e))return{node:e.anchor.getNode(),offset:e.anchor.offset};if(fi(e)){const[t]=e.getNodes();return{node:t,offset:0}}return{node:null,offset:0}}preservingSelection(e){let t=null;this.editor.getEditorState().read((()=>{const e=Li();e&&gi(e)&&(t={anchor:{key:e.anchor.key,offset:e.anchor.offset},focus:{key:e.focus.key,offset:e.focus.offset}})})),e(),t&&this.editor.update((()=>{const e=Li();e&&gi(e)&&(e.anchor.set(t.anchor.key,t.anchor.offset,"text"),e.focus.set(t.focus.key,t.focus.offset,"text"))}))}get hasSelectedWordsInSingleLine(){const e=Li();if(!gi(e))return!1;if(e.isCollapsed())return!1;const t=e.anchor.getNode(),n=e.focus.getNode();if(t.getTopLevelElement()!==n.getTopLevelElement())return!1;if(!t.getTopLevelElement())return!1;const r=e.getNodes();for(const e of r)if(zr(e))return!1;return!0}get isInsideList(){const e=Li();if(!gi(e))return!1;return null!==sg(e.anchor.getNode())}get isIndentedList(){const e=Li();if(!gi(e))return!1;const t=e.getNodes();for(const e of t){const t=Ra(e,Tc);if(t&&lc(t)>1)return!0}return!1}get isInsideCodeBlock(){const e=Li();if(!gi(e))return!1;return null!==Ra(e.anchor.getNode(),Ru)}get nodeAfterCursor(){const{anchorNode:e,offset:t}=this.#Ee();return e?ri(e)?this.#Ne(e,t):po(e)?this.#Ae(e,t):this.#Le(e):null}get topLevelNodeAfterCursor(){const{anchorNode:e,offset:t}=this.#Ee();return e?ri(e)?this.#Oe(e):po(e)?this.#Ae(e,t):this.#Le(e):null}get nodeBeforeCursor(){const{anchorNode:e,offset:t}=this.#Ee();return e?ri(e)?this.#Fe(e,t):po(e)?this.#Re(e,t):this.#Ie(e):null}get topLevelNodeBeforeCursor(){const{anchorNode:e,offset:t}=this.#Ee();return e?ri(e)?this.#Pe(e):po(e)?this.#Re(e,t):this.#Ie(e):null}get#Me(){return this.editorElement.contents}get#De(){if(this._currentlySelectedKeys)return this._currentlySelectedKeys;this._currentlySelectedKeys=new Set;const e=Li();if(e&&fi(e))for(const t of e.getNodes())this._currentlySelectedKeys.add(t.getKey());return this._currentlySelectedKeys}#xe(){this.editor.registerCommand(vn,this.#Be.bind(this),1),this.editor.registerCommand(Sn,this.#ze.bind(this),1),this.editor.registerCommand(kn,this.#$e.bind(this),1),this.editor.registerCommand(Tn,this.#He.bind(this),1),this.editor.registerCommand(On,this.#Ke.bind(this),1),this.editor.registerCommand(An,this.#Ue.bind(this),1),this.editor.registerCommand(sn,(()=>{this.current=Li()}),1)}#_e(){this.editor.getRootElement().addEventListener("lexxy:internal:select-node",(async e=>{await Zg();const{key:t}=e.detail;this.editor.update((()=>{const e=is(t);if(e){const t=Ni();t.add(e.getKey()),hs(t)}this.editor.focus()}))})),this.editor.getRootElement().addEventListener("lexxy:internal:move-to-next-line",(e=>{this.#We()}))}#Se(){this.editor.getRootElement().addEventListener("keydown",(e=>{(function(e){return!(e.ctrlKey||e.metaKey||e.altKey||e.key.length>1&&"Enter"!==e.key&&"Space"!==e.key||1!==e.key.length)})(e)&&this.editor.update((()=>{const t=Li();if(gi(t)&&t.isCollapsed()){const n=t.anchor.getNode(),r=t.anchor.offset,i=this.#Ve(n,r),o=this.#qe(n,r);if(i instanceof mo&&!i.isInline())return e.preventDefault(),void this.#Me.createParagraphAfterNode(i,e.key);if(o instanceof mo&&!o.isInline())return e.preventDefault(),void this.#Me.createParagraphBeforeNode(o,e.key)}}))}),!0)}#Ve(e,t){return ri(e)&&0===t?e.getPreviousSibling():po(e)&&t>0?e.getChildAtIndex(t-1):null}#qe(e,t){return ri(e)&&t===e.getTextContentSize()?e.getNextSibling():po(e)?e.getChildAtIndex(t):null}#Ce(){this.editorContentElement.addEventListener("keydown",(e=>{if("ArrowUp"===e.key){const t=this.editor.getRootElement().querySelector("[data-lexical-cursor]");if(t){let n=t.previousElementSibling;for(;n&&n.hasAttribute("data-lexical-cursor");)n=n.previousElementSibling;n||e.preventDefault()}}if("ArrowDown"===e.key){const t=this.editor.getRootElement().querySelector("[data-lexical-cursor]");if(t){let n=t.nextElementSibling;for(;n&&n.hasAttribute("data-lexical-cursor");)n=n.nextElementSibling;n||e.preventDefault()}}}),!0)}#ve(){this.#je(),this.#Ze(),this.previouslySelectedKeys=this.#De,this._currentlySelectedKeys=null}#je(){for(const e of this.previouslySelectedKeys)if(!this.#De.has(e)){const t=this.editor.getElementByKey(e);t&&t.classList.remove("node--selected")}}#Ze(){for(const e of this.#De)if(!this.previouslySelectedKeys.has(e)){const t=this.editor.getElementByKey(e);t&&t.classList.add("node--selected")}}async#Be(){this.current?await this.#Ge((e=>e.selectPrevious())):this.#Je(this.nodeBeforeCursor)}async#ze(){this.current?await this.#Ge((e=>e.selectNext(0,0))):this.#Je(this.nodeAfterCursor)}async#$e(){this.current?await this.#Ge((e=>e.selectPrevious())):this.#Je(this.topLevelNodeBeforeCursor)}async#He(){this.current?await this.#Ge((e=>e.selectNext(0,0))):this.#Je(this.topLevelNodeAfterCursor)}async#Ge(e){await Zg(),this.current&&this.editor.update((()=>{this.clear(),e(this.current.getNodes()[0]),this.editor.focus()}))}async#We(){this.editor.update((()=>{const e=this.#Ye();e&&this.#Xe(e)}))}#Ye(){const e=Li();return e?fi(e)?this.#Qe(e):gi(e)?this.#et(e):null:null}#Qe(e){const t=e.getNodes();return t.length>0?t[0].getTopLevelElement():null}#et(e){return e.anchor.getNode().getTopLevelElement()}#Xe(e){const t=e.getNextSibling();t?t.selectStart():this.#tt()}#tt(){const e=us(),t=Eo();e.append(t),t.selectStart()}#Je(e){e&&e instanceof mo&&this.editor.update((()=>{const t=Ni();t.add(e.getKey()),hs(t)}))}#Ke(){const e=this.nodeAfterCursor;return e instanceof mo?(this.#Je(e),!0):(this.#Me.deleteSelectedNodes(),!1)}#Ue(){const e=this.nodeBeforeCursor;return e instanceof mo?(this.#Je(e),!0):(this.#Me.deleteSelectedNodes(),!1)}#we(){const e=Li();if(!e||!e.isCollapsed())return null;const t=window.getSelection();return t&&0!==t.rangeCount?t.getRangeAt(0):null}#ke(e){let t=e.getBoundingClientRect();if(this.#nt(t)){const n=this.#rt(e);t=n.getBoundingClientRect(),this.#it(n),n.remove()}return t}#nt(e){return 0===e.width&&0===e.height||0===e.top&&0===e.left}#rt(e){const t=this.#ot();return e.insertNode(t),t}#ot(){const e=document.createElement("span");return e.textContent="​",e.style.display="inline-block",e.style.width="1px",e.style.height="1em",e.style.lineHeight="normal",e.setAttribute("nonce",wa()),e}#it(e){const t=window.getSelection();t.removeAllRanges();const n=document.createRange();n.setStartAfter(e),n.collapse(!0),t.addRange(n)}#Te(e,t){const n=this.editor.getRootElement().getBoundingClientRect(),r=e.left-n.left;let i=e.top-n.top;const o=this.#st(t);return isNaN(o)||(i+=o),{x:r,y:i,fontSize:o}}#st(e){const t=window.getSelection().anchorNode,n=this.#lt(t);if(n instanceof HTMLElement){const e=window.getComputedStyle(n);return parseFloat(e.fontSize)}return 0}#lt(e){return e?.nodeType===Node.TEXT_NODE?e.parentElement:e}#Ee(){const e=Li();if(!gi(e)||!e.isCollapsed())return{anchorNode:null,offset:0};const{anchor:t}=e;return{anchorNode:t.getNode(),offset:t.offset}}#Ne(e,t){return t===e.getTextContentSize()?this.#Oe(e):null}#Oe(e){if(e.getNextSibling()instanceof mo)return e.getNextSibling();const t=e.getParent();return t?t.getNextSibling():null}#Ae(e,t){return t0?e.getChildAtIndex(t-1):this.#Ie(e)}#Le(e){let t=e;for(;t&&null==t.getNextSibling();)t=t.getParent();return t?t.getNextSibling():null}#Ie(e){let t=e;for(;t&&null==t.getPreviousSibling();)t=t.getParent();return t?t.getPreviousSibling():null}}class Jg extends mo{static getType(){return"custom_action_text_attachment"}static clone(e){return new Jg({...e},e.__key)}static importJSON(e){return new Jg({...e})}static importDOM(){return{"action-text-attachment":e=>{const t=e.getAttribute("content");return e.getAttribute("content")?{conversion:()=>{const n=[],r=e.previousSibling;return r&&r.nodeType===Node.TEXT_NODE&&/\s$/.test(r.textContent)&&n.push(ni(" ")),n.push(new Jg({sgid:e.getAttribute("sgid"),innerHtml:JSON.parse(t),contentType:e.getAttribute("content-type")})),n.push(ni(" ")),{node:n}},priority:2}:null}}}constructor({sgid:e,contentType:t,innerHtml:n},r){super(r),this.sgid=e,this.contentType=t||"application/vnd.actiontext.unknown",this.innerHtml=n}createDOM(){const e=Dg("action-text-attachment",{"content-type":this.contentType,"data-lexxy-decorator":!0});return e.addEventListener("click",(t=>{zg(e,"lexxy:internal:select-node",{key:this.getKey()})})),e.insertAdjacentHTML("beforeend",this.innerHtml),e}updateDOM(){return!0}getTextContent(){return this.createDOM().textContent.trim()||`[${this.contentType}]`}isInline(){return!0}exportDOM(){return{element:Dg("action-text-attachment",{sgid:this.sgid,content:JSON.stringify(this.innerHtml),"content-type":this.contentType})}}exportJSON(){return{type:"custom_action_text_attachment",version:1,sgid:this.sgid,contentType:this.contentType,innerHtml:this.innerHtml}}decorate(){return null}}class Yg{constructor(e){this.editorElement=e,this.editor=e.editor}monitor(){this.editor.registerCommand(En,(e=>this.#at(e)),3)}#at(e){const t=Li();if(!gi(t))return!1;const n=t.anchor.getNode();return!!this.#ct(n)&&(this.#ut(e,n)||this.#dt(e,n))}#ut(e,t){return!(!this.#ht(t)&&!this.#gt(t))&&(e.preventDefault(),this.#pt(t),!0)}#dt(e,t){return!!this.#ft(t)&&(e.preventDefault(),this.#mt(t),!0)}#ct(e){let t=e;for(;t;){if(uu(t))return!0;t=t.getParent()}return!1}#ht(e){const t=this.#yt(e);return!!t&&this.#bt(t)}#gt(e){const t=this.#_t(e);if(!t)return!1;if(!this.#bt(t))return!1;const n=t.getParent();return n&&kc(n)}#bt(e){if(""!==e.getTextContent().trim())return!1;const t=e.getChildren();return 0===t.length||t.every((e=>!!zr(e)||this.#bt(e)))}#yt(e){let t=e;for(;t;){if(kc(t))return t;t=t.getParent()}return null}#pt(e){const t=this.#yt(e);if(!t)return;const n=t.getParent();if(!n||!Fc(n))return;const r=n.getParent();if(r&&uu(r)){const e=this.#xt(t).filter((e=>!this.#bt(e)));if(e.length>0)return void this.#St(r,n,t,e)}const i=Eo();n.insertAfter(i),t.remove(),i.selectStart()}#ft(e){const t=this.#_t(e);if(!t)return!1;if(!this.#bt(t))return!1;const n=t.getParent();return n&&uu(n)}#_t(e){let t=e;for(;t;){if(No(t))return t;t=t.getParent()}return null}#mt(e){const t=this.#_t(e);if(!t)return;const n=t.getParent();if(!n||!uu(n))return;const r=this.#Ct(t).filter((e=>!this.#bt(e)));if(r.length>0)this.#vt(n,t,r);else{const e=Eo();n.insertAfter(e),t.remove(),e.selectStart()}}#Ct(e){const t=[];let n=e.getNextSibling();for(;n;)t.push(n),n=n.getNextSibling();return t}#xt(e){const t=[];let n=e.getNextSibling();for(;n;)kc(n)&&t.push(n),n=n.getNextSibling();return t}#St(e,t,n,r){const i=this.#Ct(t).filter((e=>!this.#bt(e))),o=Eo();e.insertAfter(o);const s=Oc(t.getListType()),l=cu();o.insertAfter(l),l.append(s),r.forEach((e=>{s.append(e)})),i.forEach((e=>{l.append(e)})),n.remove(),this.#wt(t),this.#kt(l),0===t.getChildrenSize()?(t.remove(),0===e.getChildrenSize()&&e.remove()):this.#kt(e),o.selectStart()}#wt(e){const t=e.getChildren();for(let e=t.length-1;e>=0;e--){const n=t[e];if(!kc(n)||!this.#bt(n))break;n.remove()}}#kt(e){const t=e.getChildren();for(let e=t.length-1;e>=0;e--){const n=t[e];if(!this.#bt(n))break;n.remove()}}#vt(e,t,n){const r=Eo();e.insertAfter(r);const i=cu();r.insertAfter(i),n.forEach((e=>{i.append(e)})),t.remove(),this.#kt(e),this.#kt(i),r.selectStart()}}class Xg{constructor(e){this.editorElement=e,this.editor=e.editor,new Yg(e).monitor()}insertHtml(e){this.editor.update((()=>{const t=Li();if(!gi(t))return;const n=Bc(this.editor,Bg(e));t.insertNodes(n)}))}insertAtCursor(e){this.editor.update((()=>{const t=Li(),n=t?.getNodes();if(gi(t))Di([e]);else if(fi(t)&&n&&n.length>0){n[n.length-1].insertAfter(e)}else{us().append(e)}}))}insertAtCursorEnsuringLineBelow(e){this.insertAtCursor(e),this.#Tt(e)}insertNodeWrappingEachSelectedLine(e){this.editor.update((()=>{const t=Li();if(!gi(t))return;t.extract().forEach((t=>{if(!t.getParent())return;const n=t.getTopLevelElementOrThrow(),r=e();r.append(...n.getChildren()),n.replace(r)}))}))}toggleNodeWrappingAllSelectedLines(e,t){this.editor.update((()=>{const n=Li();if(!gi(n))return;const r=n.anchor.getNode().getTopLevelElementOrThrow();e(r)?this.removeFormattingFromSelectedLines():this.#Et(t)}))}toggleNodeWrappingAllSelectedNodes(e,t){this.editor.update((()=>{const n=Li();if(!gi(n))return;const r=n.anchor.getNode().getTopLevelElement();r&&e(r)?this.#Nt(r):this.#At(t)}))}removeFormattingFromSelectedLines(){this.editor.update((()=>{const e=Li();if(!gi(e))return;const t=e.anchor.getNode().getTopLevelElementOrThrow(),n=Eo();n.append(...t.getChildren()),t.replace(n)}))}hasSelectedText(){let e=!1;return this.editor.read((()=>{const t=Li();e=gi(t)&&!t.isCollapsed()})),e}unwrapSelectedListItems(){this.editor.update((()=>{const e=Li();if(!gi(e))return;const{listItems:t,parentLists:n}=this.#Lt(e);if(t.size>0){const e=this.#Ot(t);this.#Ft(n),this.#Rt(e)}}))}createLink(e){let t=null;return this.editor.update((()=>{const n=ni(e),r=md(e);r.append(n);const i=Li();gi(i)&&(i.insertNodes([r]),t=r.getKey())})),t}createLinkWithSelectedText(e){this.hasSelectedText()&&this.editor.update((()=>{Cd(e)}))}textBackUntil(e){let t="";return this.editor.getEditorState().read((()=>{const n=Li();if(!n||!n.isCollapsed())return;const r=n.anchor,i=r.getNode();if(!ri(i))return;const o=i.getTextContent(),s=r.offset,l=o.slice(0,s),a=l.lastIndexOf(e);-1!==a&&(t=l.slice(a+e.length))})),t}containsTextBackUntil(e){let t=!1;return this.editor.getEditorState().read((()=>{const n=Li();if(!n||!n.isCollapsed())return;const r=n.anchor,i=r.getNode();if(!ri(i))return;const o=i.getTextContent(),s=r.offset,l=o.slice(0,s);t=l.includes(e)})),t}replaceTextBackUntil(e,t){t=Array.isArray(t)?t:[t],this.editor.update((()=>{const{anchorNode:n,offset:r}=this.#It();if(!n)return;const i=this.#Pt(n,r,e);-1!==i&&this.#Mt(n,r,i,t)}))}createParagraphAfterNode(e,t){const n=Eo();e.insertAfter(n),n.selectStart(),t&&(n.append(ni(t)),n.select(1,1))}createParagraphBeforeNode(e,t){const n=Eo();e.insertBefore(n),n.selectStart(),t&&(n.append(ni(t)),n.select(1,1))}uploadFile(e){if(!this.editorElement.supportsAttachments)return void console.warn("This editor does not supports attachments (it's configured with [attachments=false])");if(!this.#Dt(e))return;const t=this.editorElement.directUploadUrl,n=this.editorElement.blobUrlTemplate;this.editor.update((()=>{const r=new Wg({file:e,uploadUrl:t,blobUrlTemplate:n,editor:this.editor});this.insertAtCursor(r)}),{tag:Or})}async deleteSelectedNodes(){let e=null;this.editor.update((()=>{if(fi(this.#Bt.current)){const t=this.#Bt.current.getNodes();if(0===t.length)return;e=this.#zt(t),this.#$t(t)}})),await Zg(),this.editor.update((()=>{this.#Ht(e),this.#Bt.clear(),this.editor.focus()}))}replaceNodeWithHTML(e,t,n={}){this.editor.update((()=>{const r=is(e);if(!r)return;const i=Li();let o=!1;if(gi(i)){const e=i.getNodes();o=e.includes(r)||e.some((e=>e.getParent()===r)),o&&hs(null)}const s=n.attachment?this.#Kt(t,n.attachment):this.#Ut(t);r.replace(s),o&&s.selectEnd()}))}insertHTMLBelowNode(e,t,n={}){this.editor.update((()=>{const r=is(e);if(!r)return;const i=r.getTopLevelElement()||r,o=n.attachment?this.#Kt(t,n.attachment):this.#Ut(t);i.insertAfter(o)}))}get#Bt(){return this.editorElement.selection}#Tt(e){this.editor.update((()=>{if(!e.getNextSibling()){const t=Eo();e.insertAfter(t),t.selectStart()}}))}#Nt(e){e.getChildren().forEach((t=>{e.insertBefore(t)})),e.remove()}#At(e){this.editor.update((()=>{const t=Li();if(!gi(t))return;const n=t.extract();if(0===n.length)return;const r=new Set;n.forEach((e=>{const t=e.getTopLevelElementOrThrow();r.add(t)}));const i=this.#Wt(Array.from(r));if(0===i.length)return this.#Vt(),void this.insertAtCursor(e());const o=e();i[0].insertBefore(o),i.forEach((e=>{o.append(e)}))}))}#Wt(e){let t=e.length-1;for(;t>=0;){const n=e[t];if(!No(n)||!this.#qt(n))break;t--}return e.slice(0,t+1)}#qt(e){if(""!==e.getTextContent().trim())return!1;const t=e.getChildren();return 0===t.length||t.every((e=>zr(e)))}#Vt(){const e=us();if(1===e.getChildrenSize()){const t=e.getFirstChild();t&&No(t)&&this.#qt(t)&&t.remove()}}#Et(e){this.editor.update((()=>{const t=Li();gi(t)&&(t.isCollapsed()?this.#jt(t,e):this.#Zt(t,e))}))}#jt(e,t){const n=e.anchor.getNode().getTopLevelElementOrThrow();if(n.getTextContent()){const e=t();e.append(...n.getChildren()),n.replace(e)}else Di([t()])}#Zt(e,t){const n=this.#Gt(e);if(0===n.length)return;const{lineSet:r,nodesToDelete:i}=this.#Jt(n);if(0===r.size)return;const o=this.#Yt(t,r);this.#Xt(e,o),this.#Qt(i)}#Gt(e){const t=e.extract().map((e=>this.#en(e))).filter(Boolean);return hs(null),t}#en(e){return No(e)?e:ri(e)&&e.getParent()&&No(e.getParent())?e.getParent():null}#Jt(e){const t=new Set,n=new Set;return e.forEach((e=>{const r=e.getTextContent();r&&r.split("\n").forEach((e=>{e.trim()&&t.add(e)})),n.add(e)})),{lineSet:t,nodesToDelete:n}}#Yt(e,t){const n=e(),r=Array.from(t);return r.forEach(((e,t)=>{n.append(ni(e)),te.remove()))}#$t(e){e.forEach((e=>{const t=e.getParent();if(!po(t))return;const n=t.getChildren().indexOf(e);n>=0&&t.splice(n,1,[])}))}#zt(e){const t=e[0],n=e[e.length-1];return t?.getPreviousSibling()||n?.getNextSibling()}#Ht(e){const t=us();if(0===t.getChildrenSize()){const e=Eo();t.append(e),e.selectStart()}else e&&(ri(e)||No(e)?e.selectEnd():e.selectNext(0,0))}#Lt(e){const t=e.getNodes(),n=new Set,r=new Set;for(const e of t){const t=sg(e);if(t){n.add(t);const e=t.getParent();e&&Fc(e)&&r.add(e)}}return{listItems:n,parentLists:r}}#Ot(e){const t=[];for(const n of e){const e=this.#tn(n);e&&t.push(e)}return t}#tn(e){const t=e.getParent();if(!t||!Fc(t))return null;const n=Eo(),r=this.#nn(e,n);return e.insertAfter(n),this.#rn(n,r),e.remove(),n}#nn(e,t){const n=[];return e.getChildren().forEach((e=>{Fc(e)?n.push(e):t.append(e)})),n}#rn(e,t){t.forEach((t=>{e.insertAfter(t)}))}#Ft(e){for(const t of e)Fc(t)&&0===t.getChildrenSize()&&t.remove()}#Rt(e){if(0===e.length)return;const t=e[0],n=e[e.length-1];1===e.length?t.selectEnd():this.#in(t,n)}#in(e,t){e.selectStart();const n=Li();n&&gi(n)&&(n.anchor.set(e.getKey(),0,"element"),n.focus.set(t.getKey(),t.getChildrenSize(),"element"))}#It(){const e=Li();if(!e||!e.isCollapsed())return{anchorNode:null,offset:0};const t=e.anchor,n=t.getNode();return ri(n)?{anchorNode:n,offset:t.offset}:{anchorNode:null,offset:0}}#Pt(e,t,n){return e.getTextContent().slice(0,t).lastIndexOf(n)}#Mt(e,t,n,r){const i=e.getTextContent(),o=i.slice(0,n),s=i.slice(t),l=ni(o),a=ni(s||" ");e.replace(l);this.#on(l,r).insertAfter(a),this.#sn(a.getParentOrThrow());const c=s?0:1;a.select(c,c)}#on(e,t){let n=e;for(const e of t)n.insertAfter(e),n=e;return n}#sn(e){if(No(e)&&!this.editorElement.isSingleLineMode){const t=e.getChildren(),n=t[t.length-1],r=t[t.length-2];ri(n)&&""===n.getTextContent()&&r&&!ri(r)&&e.append(Br())}}#Kt(e,t={}){return new Jg({sgid:("object"==typeof t?t:{}).sgid||null,contentType:"text/html",innerHtml:e})}#Ut(e){return Bc(this.editor,Bg(e))[0]||Eo()}#Dt(e){return $g(this.editorElement,"lexxy:file-accept",{file:e},!0)}}function Qg(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var ep={async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null};function tp(e){ep=e}var np={exec:()=>null};function rp(e,t=""){let n="string"==typeof e?e:e.source,r={replace:(e,t)=>{let i="string"==typeof t?t:t.source;return i=i.replace(ip.caret,"$1"),n=n.replace(e,i),r},getRegex:()=>new RegExp(n,t)};return r}var ip={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceTabs:/^\t+/,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] /,listReplaceTask:/^\[[ xX]\] +/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,unescapeTest:/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/gi,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>new RegExp(`^( {0,3}${e})((?:[\t ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ \t][^\\n]*)?(?:\\n|$))`),hrRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}#`),htmlBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}<(?:[a-z].*>|!--)`,"i")},op=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,sp=/(?:[*+-]|\d{1,9}[.)])/,lp=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,ap=rp(lp).replace(/bull/g,sp).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),cp=rp(lp).replace(/bull/g,sp).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),up=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,dp=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,hp=rp(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",dp).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),gp=rp(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,sp).getRegex(),pp="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",fp=/|$))/,mp=rp("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|\\n*|$)|\\n*|$)|)[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)|(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$))","i").replace("comment",fp).replace("tag",pp).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),yp=rp(up).replace("hr",op).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html",")|<(?:script|pre|style|textarea|!--)").replace("tag",pp).getRegex(),bp={blockquote:rp(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",yp).getRegex(),code:/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,def:hp,fences:/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,heading:/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,hr:op,html:mp,lheading:ap,list:gp,newline:/^(?:[ \t]*(?:\n|$))+/,paragraph:yp,table:np,text:/^[^\n]+/},_p=rp("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",op).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3}\t)[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html",")|<(?:script|pre|style|textarea|!--)").replace("tag",pp).getRegex(),xp={...bp,lheading:cp,table:_p,paragraph:rp(up).replace("hr",op).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",_p).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html",")|<(?:script|pre|style|textarea|!--)").replace("tag",pp).getRegex()},Sp={...bp,html:rp("^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+? *(?:\\n{2,}|\\s*$)|\\s]*)*?/?> *(?:\\n{2,}|\\s*$))").replace("comment",fp).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:np,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:rp(up).replace("hr",op).replace("heading"," *#{1,6} *[^\n]").replace("lheading",ap).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},Cp=/^( {2,}|\\)\n(?!\s*$)/,vp=/[\p{P}\p{S}]/u,wp=/[\s\p{P}\p{S}]/u,kp=/[^\s\p{P}\p{S}]/u,Tp=rp(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,wp).getRegex(),Ep=/(?!~)[\p{P}\p{S}]/u,Np=rp(/link|code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?`+)[^`]+\k(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("code",/(?`+)[^`]+\k(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),Ap=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,Lp=rp(Ap,"u").replace(/punct/g,vp).getRegex(),Op=rp(Ap,"u").replace(/punct/g,Ep).getRegex(),Fp="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",Rp=rp(Fp,"gu").replace(/notPunctSpace/g,kp).replace(/punctSpace/g,wp).replace(/punct/g,vp).getRegex(),Ip=rp(Fp,"gu").replace(/notPunctSpace/g,/(?:[^\s\p{P}\p{S}]|~)/u).replace(/punctSpace/g,/(?!~)[\s\p{P}\p{S}]/u).replace(/punct/g,Ep).getRegex(),Pp=rp("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,kp).replace(/punctSpace/g,wp).replace(/punct/g,vp).getRegex(),Mp=rp(/\\(punct)/,"gu").replace(/punct/g,vp).getRegex(),Dp=rp(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),Bp=rp(fp).replace("(?:--\x3e|$)","--\x3e").getRegex(),zp=rp("^comment|^|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^|^").replace("comment",Bp).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),$p=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/,Hp=rp(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",$p).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Kp=rp(/^!?\[(label)\]\[(ref)\]/).replace("label",$p).replace("ref",dp).getRegex(),Up=rp(/^!?\[(ref)\](?:\[\])?/).replace("ref",dp).getRegex(),Wp=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Vp={_backpedal:np,anyPunctuation:Mp,autolink:Dp,blockSkip:Np,br:Cp,code:/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,del:np,emStrongLDelim:Lp,emStrongRDelimAst:Rp,emStrongRDelimUnd:Pp,escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,link:Hp,nolink:Up,punctuation:Tp,reflink:Kp,reflinkSearch:rp("reflink|nolink(?!\\()","g").replace("reflink",Kp).replace("nolink",Up).getRegex(),tag:zp,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\":">",'"':""","'":"'"},Xp=e=>Yp[e];function Qp(e,t){if(t){if(ip.escapeTest.test(e))return e.replace(ip.escapeReplace,Xp)}else if(ip.escapeTestNoEncode.test(e))return e.replace(ip.escapeReplaceNoEncode,Xp);return e}function ef(e){try{e=encodeURI(e).replace(ip.percentDecode,"%")}catch{return null}return e}function tf(e,t){let n=e.replace(ip.findPipe,((e,t,n)=>{let r=!1,i=t;for(;--i>=0&&"\\"===n[i];)r=!r;return r?"|":" |"})),r=n.split(ip.splitPipe),i=0;if(r[0].trim()||r.shift(),r.length>0&&!r.at(-1)?.trim()&&r.pop(),t)if(r.length>t)r.splice(t);else for(;r.length0)return{type:"space",raw:t[0]}}code(e){let t=this.rules.block.code.exec(e);if(t){let e=t[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:t[0],codeBlockStyle:"indented",text:this.options.pedantic?e:nf(e,"\n")}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let e=t[0],n=function(e,t,n){let r=e.match(n.other.indentCodeCompensation);if(null===r)return t;let i=r[1];return t.split("\n").map((e=>{let t=e.match(n.other.beginningSpace);if(null===t)return e;let[r]=t;return r.length>=i.length?e.slice(i.length):e})).join("\n")}(e,t[3]||"",this.rules);return{type:"code",raw:e,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):t[2],text:n}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let e=t[2].trim();if(this.rules.other.endingHash.test(e)){let t=nf(e,"#");(this.options.pedantic||!t||this.rules.other.endingSpaceChar.test(t))&&(e=t.trim())}return{type:"heading",raw:t[0],depth:t[1].length,text:e,tokens:this.lexer.inline(e)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:"hr",raw:nf(t[0],"\n")}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let e=nf(t[0],"\n").split("\n"),n="",r="",i=[];for(;e.length>0;){let t,o=!1,s=[];for(t=0;t1,i={type:"list",raw:"",ordered:r,start:r?+n.slice(0,-1):"",loose:!1,items:[]};n=r?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=r?n:"[*+-]");let o=this.rules.other.listItemRegex(n),s=!1;for(;e;){let n=!1,r="",l="";if(!(t=o.exec(e))||this.rules.block.hr.test(e))break;r=t[0],e=e.substring(r.length);let a=t[2].split("\n",1)[0].replace(this.rules.other.listReplaceTabs,(e=>" ".repeat(3*e.length))),c=e.split("\n",1)[0],u=!a.trim(),d=0;if(this.options.pedantic?(d=2,l=a.trimStart()):u?d=t[1].length+1:(d=t[2].search(this.rules.other.nonSpaceChar),d=d>4?1:d,l=a.slice(d),d+=t[1].length),u&&this.rules.other.blankLine.test(c)&&(r+=c+"\n",e=e.substring(c.length+1),n=!0),!n){let t=this.rules.other.nextBulletRegex(d),n=this.rules.other.hrRegex(d),i=this.rules.other.fencesBeginRegex(d),o=this.rules.other.headingBeginRegex(d),s=this.rules.other.htmlBeginRegex(d);for(;e;){let h,g=e.split("\n",1)[0];if(c=g,this.options.pedantic?(c=c.replace(this.rules.other.listReplaceNesting," "),h=c):h=c.replace(this.rules.other.tabCharGlobal," "),i.test(c)||o.test(c)||s.test(c)||t.test(c)||n.test(c))break;if(h.search(this.rules.other.nonSpaceChar)>=d||!c.trim())l+="\n"+h.slice(d);else{if(u||a.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||i.test(a)||o.test(a)||n.test(a))break;l+="\n"+c}!u&&!c.trim()&&(u=!0),r+=g+"\n",e=e.substring(g.length+1),a=h.slice(d)}}i.loose||(s?i.loose=!0:this.rules.other.doubleBlankLine.test(r)&&(s=!0));let h,g=null;this.options.gfm&&(g=this.rules.other.listIsTask.exec(l),g&&(h="[ ] "!==g[0],l=l.replace(this.rules.other.listReplaceTask,""))),i.items.push({type:"list_item",raw:r,task:!!g,checked:h,loose:!1,text:l,tokens:[]}),i.raw+=r}let l=i.items.at(-1);if(!l)return;l.raw=l.raw.trimEnd(),l.text=l.text.trimEnd(),i.raw=i.raw.trimEnd();for(let e=0;e"space"===e.type)),n=t.length>0&&t.some((e=>this.rules.other.anyLine.test(e.raw)));i.loose=n}if(i.loose)for(let e=0;e({text:e,tokens:this.lexer.inline(e),header:!1,align:o.align[t]}))));return o}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t)return{type:"heading",raw:t[0],depth:"="===t[2].charAt(0)?1:2,text:t[1],tokens:this.lexer.inline(t[1])}}paragraph(e){let t=this.rules.block.paragraph.exec(e);if(t){let e="\n"===t[1].charAt(t[1].length-1)?t[1].slice(0,-1):t[1];return{type:"paragraph",raw:t[0],text:e,tokens:this.lexer.inline(e)}}}text(e){let t=this.rules.block.text.exec(e);if(t)return{type:"text",raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return{type:"escape",raw:t[0],text:t[1]}}tag(e){let t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){let t=this.rules.inline.link.exec(e);if(t){let e=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(e)){if(!this.rules.other.endAngleBracket.test(e))return;let t=nf(e.slice(0,-1),"\\");if((e.length-t.length)%2==0)return}else{let e=function(e,t){if(-1===e.indexOf(t[1]))return-1;let n=0;for(let r=0;r0?-2:-1}(t[2],"()");if(-2===e)return;if(e>-1){let n=(0===t[0].indexOf("!")?5:4)+t[1].length+e;t[2]=t[2].substring(0,e),t[0]=t[0].substring(0,n).trim(),t[3]=""}}let n=t[2],r="";if(this.options.pedantic){let e=this.rules.other.pedanticHrefTitle.exec(n);e&&(n=e[1],r=e[3])}else r=t[3]?t[3].slice(1,-1):"";return n=n.trim(),this.rules.other.startAngleBracket.test(n)&&(n=this.options.pedantic&&!this.rules.other.endAngleBracket.test(e)?n.slice(1):n.slice(1,-1)),rf(t,{href:n&&n.replace(this.rules.inline.anyPunctuation,"$1"),title:r&&r.replace(this.rules.inline.anyPunctuation,"$1")},t[0],this.lexer,this.rules)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){let e=t[(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal," ").toLowerCase()];if(!e){let e=n[0].charAt(0);return{type:"text",raw:e,text:e}}return rf(n,e,n[0],this.lexer,this.rules)}}emStrong(e,t,n=""){let r=this.rules.inline.emStrongLDelim.exec(e);if(!(!r||r[3]&&n.match(this.rules.other.unicodeAlphaNumeric))&&(!r[1]&&!r[2]||!n||this.rules.inline.punctuation.exec(n))){let n,i,o=[...r[0]].length-1,s=o,l=0,a="*"===r[0][0]?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(a.lastIndex=0,t=t.slice(-1*e.length+o);null!=(r=a.exec(t));){if(n=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!n)continue;if(i=[...n].length,r[3]||r[4]){s+=i;continue}if((r[5]||r[6])&&o%3&&!((o+i)%3)){l+=i;continue}if(s-=i,s>0)continue;i=Math.min(i,i+s+l);let t=[...r[0]][0].length,a=e.slice(0,o+r.index+t+i);if(Math.min(o,i)%2){let e=a.slice(1,-1);return{type:"em",raw:a,text:e,tokens:this.lexer.inlineTokens(e)}}let c=a.slice(2,-2);return{type:"strong",raw:a,text:c,tokens:this.lexer.inlineTokens(c)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let e=t[2].replace(this.rules.other.newLineCharGlobal," "),n=this.rules.other.nonSpaceChar.test(e),r=this.rules.other.startingSpaceChar.test(e)&&this.rules.other.endingSpaceChar.test(e);return n&&r&&(e=e.substring(1,e.length-1)),{type:"codespan",raw:t[0],text:e}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return{type:"br",raw:t[0]}}del(e){let t=this.rules.inline.del.exec(e);if(t)return{type:"del",raw:t[0],text:t[2],tokens:this.lexer.inlineTokens(t[2])}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let e,n;return"@"===t[2]?(e=t[1],n="mailto:"+e):(e=t[1],n=e),{type:"link",raw:t[0],text:e,href:n,tokens:[{type:"text",raw:e,text:e}]}}}url(e){let t;if(t=this.rules.inline.url.exec(e)){let e,n;if("@"===t[2])e=t[0],n="mailto:"+e;else{let r;do{r=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])?.[0]??""}while(r!==t[0]);e=t[0],n="www."===t[1]?"http://"+t[0]:t[0]}return{type:"link",raw:t[0],text:e,href:n,tokens:[{type:"text",raw:e,text:e}]}}}inlineText(e){let t=this.rules.inline.text.exec(e);if(t){let e=this.lexer.state.inRawBlock;return{type:"text",raw:t[0],text:t[0],escaped:e}}}},sf=class e{tokens;options;state;tokenizer;inlineQueue;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||ep,this.options.tokenizer=this.options.tokenizer||new of,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let t={other:ip,block:Gp.normal,inline:Jp.normal};this.options.pedantic?(t.block=Gp.pedantic,t.inline=Jp.pedantic):this.options.gfm&&(t.block=Gp.gfm,this.options.breaks?t.inline=Jp.breaks:t.inline=Jp.gfm),this.tokenizer.rules=t}static get rules(){return{block:Gp,inline:Jp}}static lex(t,n){return new e(n).lex(t)}static lexInline(t,n){return new e(n).inlineTokens(t)}lex(e){e=e.replace(ip.carriageReturn,"\n"),this.blockTokens(e,this.tokens);for(let e=0;e!!(r=n.call({lexer:this},e,t))&&(e=e.substring(r.raw.length),t.push(r),!0))))continue;if(r=this.tokenizer.space(e)){e=e.substring(r.raw.length);let n=t.at(-1);1===r.raw.length&&void 0!==n?n.raw+="\n":t.push(r);continue}if(r=this.tokenizer.code(e)){e=e.substring(r.raw.length);let n=t.at(-1);"paragraph"===n?.type||"text"===n?.type?(n.raw+=(n.raw.endsWith("\n")?"":"\n")+r.raw,n.text+="\n"+r.text,this.inlineQueue.at(-1).src=n.text):t.push(r);continue}if(r=this.tokenizer.fences(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.heading(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.hr(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.blockquote(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.list(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.html(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.def(e)){e=e.substring(r.raw.length);let n=t.at(-1);"paragraph"===n?.type||"text"===n?.type?(n.raw+=(n.raw.endsWith("\n")?"":"\n")+r.raw,n.text+="\n"+r.raw,this.inlineQueue.at(-1).src=n.text):this.tokens.links[r.tag]||(this.tokens.links[r.tag]={href:r.href,title:r.title},t.push(r));continue}if(r=this.tokenizer.table(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.lheading(e)){e=e.substring(r.raw.length),t.push(r);continue}let i=e;if(this.options.extensions?.startBlock){let t,n=1/0,r=e.slice(1);this.options.extensions.startBlock.forEach((e=>{t=e.call({lexer:this},r),"number"==typeof t&&t>=0&&(n=Math.min(n,t))})),n<1/0&&n>=0&&(i=e.substring(0,n+1))}if(this.state.top&&(r=this.tokenizer.paragraph(i))){let o=t.at(-1);n&&"paragraph"===o?.type?(o.raw+=(o.raw.endsWith("\n")?"":"\n")+r.raw,o.text+="\n"+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=o.text):t.push(r),n=i.length!==e.length,e=e.substring(r.raw.length)}else if(r=this.tokenizer.text(e)){e=e.substring(r.raw.length);let n=t.at(-1);"text"===n?.type?(n.raw+=(n.raw.endsWith("\n")?"":"\n")+r.raw,n.text+="\n"+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=n.text):t.push(r)}else if(e){let t="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(t);break}throw new Error(t)}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){let n=e,r=null;if(this.tokens.links){let e=Object.keys(this.tokens.links);if(e.length>0)for(;null!=(r=this.tokenizer.rules.inline.reflinkSearch.exec(n));)e.includes(r[0].slice(r[0].lastIndexOf("[")+1,-1))&&(n=n.slice(0,r.index)+"["+"a".repeat(r[0].length-2)+"]"+n.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;null!=(r=this.tokenizer.rules.inline.anyPunctuation.exec(n));)n=n.slice(0,r.index)+"++"+n.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);for(;null!=(r=this.tokenizer.rules.inline.blockSkip.exec(n));)n=n.slice(0,r.index)+"["+"a".repeat(r[0].length-2)+"]"+n.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);n=this.options.hooks?.emStrongMask?.call({lexer:this},n)??n;let i=!1,o="";for(;e;){let r;if(i||(o=""),i=!1,this.options.extensions?.inline?.some((n=>!!(r=n.call({lexer:this},e,t))&&(e=e.substring(r.raw.length),t.push(r),!0))))continue;if(r=this.tokenizer.escape(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.tag(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.link(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(r.raw.length);let n=t.at(-1);"text"===r.type&&"text"===n?.type?(n.raw+=r.raw,n.text+=r.text):t.push(r);continue}if(r=this.tokenizer.emStrong(e,n,o)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.codespan(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.br(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.del(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.autolink(e)){e=e.substring(r.raw.length),t.push(r);continue}if(!this.state.inLink&&(r=this.tokenizer.url(e))){e=e.substring(r.raw.length),t.push(r);continue}let s=e;if(this.options.extensions?.startInline){let t,n=1/0,r=e.slice(1);this.options.extensions.startInline.forEach((e=>{t=e.call({lexer:this},r),"number"==typeof t&&t>=0&&(n=Math.min(n,t))})),n<1/0&&n>=0&&(s=e.substring(0,n+1))}if(r=this.tokenizer.inlineText(s)){e=e.substring(r.raw.length),"_"!==r.raw.slice(-1)&&(o=r.raw.slice(-1)),i=!0;let n=t.at(-1);"text"===n?.type?(n.raw+=r.raw,n.text+=r.text):t.push(r)}else if(e){let t="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(t);break}throw new Error(t)}}return t}},lf=class{options;parser;constructor(e){this.options=e||ep}space(e){return""}code({text:e,lang:t,escaped:n}){let r=(t||"").match(ip.notSpaceStart)?.[0],i=e.replace(ip.endingNewline,"")+"\n";return r?'
'+(n?i:Qp(i,!0))+"
\n":"
"+(n?i:Qp(i,!0))+"
\n"}blockquote({tokens:e}){return`
\n${this.parser.parse(e)}
\n`}html({text:e}){return e}def(e){return""}heading({tokens:e,depth:t}){return`${this.parser.parseInline(e)}\n`}hr(e){return"
\n"}list(e){let t=e.ordered,n=e.start,r="";for(let t=0;t\n"+r+"\n"}listitem(e){let t="";if(e.task){let n=this.checkbox({checked:!!e.checked});e.loose?"paragraph"===e.tokens[0]?.type?(e.tokens[0].text=n+" "+e.tokens[0].text,e.tokens[0].tokens&&e.tokens[0].tokens.length>0&&"text"===e.tokens[0].tokens[0].type&&(e.tokens[0].tokens[0].text=n+" "+Qp(e.tokens[0].tokens[0].text),e.tokens[0].tokens[0].escaped=!0)):e.tokens.unshift({type:"text",raw:n+" ",text:n+" ",escaped:!0}):t+=n+" "}return t+=this.parser.parse(e.tokens,!!e.loose),`
  • ${t}
  • \n`}checkbox({checked:e}){return"'}paragraph({tokens:e}){return`

    ${this.parser.parseInline(e)}

    \n`}table(e){let t="",n="";for(let t=0;t${r}`),"\n\n"+t+"\n"+r+"
    \n"}tablerow({text:e}){return`\n${e}\n`}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?"th":"td";return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`\n`}strong({tokens:e}){return`${this.parser.parseInline(e)}`}em({tokens:e}){return`${this.parser.parseInline(e)}`}codespan({text:e}){return`${Qp(e,!0)}`}br(e){return"
    "}del({tokens:e}){return`${this.parser.parseInline(e)}`}link({href:e,title:t,tokens:n}){let r=this.parser.parseInline(n),i=ef(e);if(null===i)return r;let o='
    ",o}image({href:e,title:t,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let i=ef(e);if(null===i)return Qp(n);let o=`${n}{let i=e[r].flat(1/0);n=n.concat(this.walkTokens(i,t))})):e.tokens&&(n=n.concat(this.walkTokens(e.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach((e=>{let n={...e};if(n.async=this.defaults.async||n.async||!1,e.extensions&&(e.extensions.forEach((e=>{if(!e.name)throw new Error("extension name required");if("renderer"in e){let n=t.renderers[e.name];t.renderers[e.name]=n?function(...t){let r=e.renderer.apply(this,t);return!1===r&&(r=n.apply(this,t)),r}:e.renderer}if("tokenizer"in e){if(!e.level||"block"!==e.level&&"inline"!==e.level)throw new Error("extension level must be 'block' or 'inline'");let n=t[e.level];n?n.unshift(e.tokenizer):t[e.level]=[e.tokenizer],e.start&&("block"===e.level?t.startBlock?t.startBlock.push(e.start):t.startBlock=[e.start]:"inline"===e.level&&(t.startInline?t.startInline.push(e.start):t.startInline=[e.start]))}"childTokens"in e&&e.childTokens&&(t.childTokens[e.name]=e.childTokens)})),n.extensions=t),e.renderer){let t=this.defaults.renderer||new lf(this.defaults);for(let n in e.renderer){if(!(n in t))throw new Error(`renderer '${n}' does not exist`);if(["options","parser"].includes(n))continue;let r=n,i=e.renderer[r],o=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return!1===n&&(n=o.apply(t,e)),n||""}}n.renderer=t}if(e.tokenizer){let t=this.defaults.tokenizer||new of(this.defaults);for(let n in e.tokenizer){if(!(n in t))throw new Error(`tokenizer '${n}' does not exist`);if(["options","rules","lexer"].includes(n))continue;let r=n,i=e.tokenizer[r],o=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return!1===n&&(n=o.apply(t,e)),n}}n.tokenizer=t}if(e.hooks){let t=this.defaults.hooks||new uf;for(let n in e.hooks){if(!(n in t))throw new Error(`hook '${n}' does not exist`);if(["options","block"].includes(n))continue;let r=n,i=e.hooks[r],o=t[r];uf.passThroughHooks.has(n)?t[r]=e=>{if(this.defaults.async&&uf.passThroughHooksRespectAsync.has(n))return(async()=>{let n=await i.call(t,e);return o.call(t,n)})();let r=i.call(t,e);return o.call(t,r)}:t[r]=(...e)=>{if(this.defaults.async)return(async()=>{let n=await i.apply(t,e);return!1===n&&(n=await o.apply(t,e)),n})();let n=i.apply(t,e);return!1===n&&(n=o.apply(t,e)),n}}n.hooks=t}if(e.walkTokens){let t=this.defaults.walkTokens,r=e.walkTokens;n.walkTokens=function(e){let n=[];return n.push(r.call(this,e)),t&&(n=n.concat(t.call(this,e))),n}}this.defaults={...this.defaults,...n}})),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return sf.lex(e,t??this.defaults)}parser(e,t){return cf.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let r={...n},i={...this.defaults,...r},o=this.onError(!!i.silent,!!i.async);if(!0===this.defaults.async&&!1===r.async)return o(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof t>"u"||null===t)return o(new Error("marked(): input parameter is undefined or null"));if("string"!=typeof t)return o(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(t)+", string expected"));if(i.hooks&&(i.hooks.options=i,i.hooks.block=e),i.async)return(async()=>{let n=i.hooks?await i.hooks.preprocess(t):t,r=await(i.hooks?await i.hooks.provideLexer():e?sf.lex:sf.lexInline)(n,i),o=i.hooks?await i.hooks.processAllTokens(r):r;i.walkTokens&&await Promise.all(this.walkTokens(o,i.walkTokens));let s=await(i.hooks?await i.hooks.provideParser():e?cf.parse:cf.parseInline)(o,i);return i.hooks?await i.hooks.postprocess(s):s})().catch(o);try{i.hooks&&(t=i.hooks.preprocess(t));let n=(i.hooks?i.hooks.provideLexer():e?sf.lex:sf.lexInline)(t,i);i.hooks&&(n=i.hooks.processAllTokens(n)),i.walkTokens&&this.walkTokens(n,i.walkTokens);let r=(i.hooks?i.hooks.provideParser():e?cf.parse:cf.parseInline)(n,i);return i.hooks&&(r=i.hooks.postprocess(r)),r}catch(e){return o(e)}}}onError(e,t){return n=>{if(n.message+="\nPlease report this to https://github.com/markedjs/marked.",e){let e="

    An error occurred:

    "+Qp(n.message+"",!0)+"
    ";return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}};function hf(e,t){return df.parse(e,t)}function gf(e){try{return new URL(e),!0}catch{return!1}}function pf(e){return e.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g,"")}hf.options=hf.setOptions=function(e){return df.setOptions(e),hf.defaults=df.defaults,tp(hf.defaults),hf},hf.getDefaults=Qg,hf.defaults=ep,hf.use=function(...e){return df.use(...e),hf.defaults=df.defaults,tp(hf.defaults),hf},hf.walkTokens=function(e,t){return df.walkTokens(e,t)},hf.parseInline=df.parseInline,hf.Parser=cf,hf.parser=cf.parse,hf.Renderer=lf,hf.TextRenderer=af,hf.Lexer=sf,hf.lexer=sf.lex,hf.Tokenizer=of,hf.Hooks=uf,hf.parse=hf,hf.options,hf.setOptions,hf.use,hf.walkTokens,hf.parseInline,cf.parse,sf.lex;class ff{constructor(e){this.editorElement=e,this.editor=e.editor,this.contents=e.contents}paste(e){const t=e.clipboardData;return!!t&&(this.#ln(t)&&!this.#an()?(this.#cn(t),e.preventDefault(),!0):void this.#un(t))}#ln(e){return this.#dn(e)||this.#hn(e)}#dn(e){const t=Array.from(e.types);return 1===t.length&&"text/plain"===t[0]}#hn(e){const t=Array.from(e.types);return 2===t.length&&t.includes("text/uri-list")&&t.includes("text/plain")}#an(){let e=!1;return this.editor.getEditorState().read((()=>{const t=Li();if(!gi(t))return;let n=t.anchor.getNode();for(;n;){if(Pu(n))return void(e=!0);n=n.getParent()}})),e}#cn(e){e.items[0].getAsString((e=>{if(gf(e)&&this.contents.hasSelectedText())this.contents.createLinkWithSelectedText(e);else if(gf(e)){const t=this.contents.createLink(e);this.#gn(t,{url:e})}else this.#pn(e)}))}#gn(e,t){const n={replaceLinkWith:(t,n)=>this.contents.replaceNodeWithHTML(e,t,n),insertBelowLink:(t,n)=>this.contents.insertHTMLBelowNode(e,t,n)};$g(this.editorElement,"lexxy:insert-link",{...t,...n})}#pn(e){const t=hf(e);this.contents.insertHtml(t)}#un(e){if(!this.editorElement.supportsAttachments)return;e.getData("text/html")||this.#fn((()=>{for(const t of e.items){const e=t.getAsFile();e&&this.contents.uploadFile(e)}}))}async#fn(e){const t=window.scrollY,n=window.scrollX;e(),await Zg(),window.scrollTo(n,t),this.editor.focus()}}class mf{constructor(e){this.editor=e.editor,this.#mn()}toggle(e){this.editor.update((()=>{this.#yn(e)}))}remove(){this.toggle({color:null,"background-color":null})}#mn(){return this.editor.registerNodeTransform(jr,(e=>{this.#bn(e)}))}#yn(e){const t=Li();if(!gi(t))return;const n={};for(const r in e){const i=Ca(t,r);n[r]=this.#_n(i,e[r])}fa(t,n)}#_n(e,t){return e===t?null:t}#bn(e){ug(e.getStyle())!==e.hasFormat("highlight")&&e.toggleFormat("highlight")}}class yf extends jr{$config(){return this.config("highlight",{extends:jr})}static importDOM(){return{mark:()=>({conversion:ag("mark",bf),priority:1})}}}function bf(e,t){const n=t.style?.color,r=t.style?.backgroundColor;let i="";if(n&&""!==n&&(i+=`color: ${n};`),r&&""!==r&&(i+=`background-color: ${r};`),i.length)return e.hasFormat("highlight")||e.toggleFormat("highlight"),e.setStyle(e.getStyle()+i)}const _f="language";class xf extends jr{$config(){return this.config("trix-text",{extends:jr})}static importDOM(){return{em:e=>Sf(e,{conversion:ag("i",bf),priority:1}),span:e=>Sf(e,{conversion:ag("mark",bf),priority:1}),strong:e=>Sf(e,{conversion:ag("b",bf),priority:1}),del:()=>({conversion:ag("s",Cf),priority:1}),pre:e=>function(e,t){return e.hasAttribute(_f)?t:null}(e,{conversion:cg(Ru,"pre",vf),priority:1})}}}function Sf(e,t){return""!==e.style.color||""!==e.style.backgroundColor?t:null}function Cf(e,t){return e.hasFormat("strikethrough")||e.toggleFormat("strikethrough"),bf(e,t)}function vf(e,t){const n=Xu(t.getAttribute(_f));e.node.setLanguage(n)}class wf extends HTMLElement{static formAssociated=!0;static debug=!1;static commands=["bold","italic","strikethrough"];static observedAttributes=["connected","required"];#xn="";#Sn=document.createElement("textarea");constructor(){super(),this.internals=this.attachInternals(),this.internals.role="presentation"}connectedCallback(){this.id??=Hg("lexxy-editor"),this.editor=this.#Cn(),this.contents=new Xg(this),this.selection=new Gg(this),this.clipboard=new ff(this),this.highlighter=new mf(this),jg.configureFor(this),this.#vn(),requestAnimationFrame((()=>$g(this,"lexxy:initialize"))),this.toggleAttribute("connected",!0),this.valueBeforeDisconnect=null}disconnectedCallback(){this.valueBeforeDisconnect=this.value,this.#wn()}attributeChangedCallback(e,t,n){"connected"===e&&this.isConnected&&null!=t&&t!==n&&requestAnimationFrame((()=>this.#g())),"required"===e&&this.isConnected&&(this.#Sn.required=this.hasAttribute("required"),this.#kn())}formResetCallback(){this.value=this.#xn,this.editor.dispatchCommand(Vn,void 0)}get form(){return this.internals.form}get name(){return this.getAttribute("name")}get toolbarElement(){return this.#Tn?(this.toolbar=this.toolbar||this.#En(),this.toolbar):null}get directUploadUrl(){return this.dataset.directUploadUrl}get blobUrlTemplate(){return this.dataset.blobUrlTemplate}get isEmpty(){return["


    ","

    ",""].includes(this.value.trim())}get isBlank(){return this.isEmpty||null!==this.toString().match(/^\s*$/g)}get hasOpenPrompt(){return null!==this.querySelector(".lexxy-prompt-menu.lexxy-prompt-menu--visible")}get isSingleLineMode(){return this.hasAttribute("single-line")}get supportsAttachments(){return"false"!==this.getAttribute("attachments")}get contentTabIndex(){return parseInt(this.editorContentElement?.getAttribute("tabindex")??"0")}focus(){this.editor.focus()}get value(){return this.cachedValue||this.editor?.getEditorState().read((()=>{this.cachedValue=function(e){return ge.sanitize(e)}(zc(this.editor,null))})),this.cachedValue}set value(e){this.editor.update((()=>{Ds(Ir);const t=us();t.clear(),""!==e&&t.append(...this.#Nn(e)),t.select(),this.#An(),requestAnimationFrame((()=>this.editor?.update((()=>{}))))}))}toString(){return this.cachedStringValue||this.editor?.getEditorState().read((()=>{this.cachedStringValue=us().getTextContent()})),this.cachedStringValue}#Nn(e){e||(e="

    ");return Bc(this.editor,Bg(`
    ${e}
    `)).map((e=>{if("paragraph"===e.getType()&&1===e.getChildrenSize()){const t=e.getFirstChild();if(t instanceof mo&&!t.isInline())return t}return e}))}#vn(){this.#Ln(),this.#On(),this.#Fn(),this.#Rn(),this.#T(),this.#In(),this.#Pn(),this.#Mn(),this.#Dn(),this.#Bn()}#Cn(){this.editorContentElement=this.editorContentElement||this.#zn();const e=Oo({namespace:"LexicalEditor",onError(e){throw e},theme:Mg,nodes:this.#$n});return e.setRootElement(this.editorContentElement),e}get#$n(){const e=[xf,yf,au,du,Tc,Sc,Ru,Ku,pd,bd,Vg,Jh,Ld,Dd,Jg];return this.supportsAttachments&&e.push(Ug,Wg),e}#zn(){const e=Dg("div",{classList:"lexxy-editor__content",contenteditable:!0,role:"textbox","aria-multiline":!0,"aria-label":this.#Hn,placeholder:this.getAttribute("placeholder")});return e.id=`${this.id}-content`,this.#Kn.forEach((t=>e.setAttribute(t.name,t.value))),this.appendChild(e),this.getAttribute("tabindex")?(e.setAttribute("tabindex",this.getAttribute("tabindex")),this.removeAttribute("tabindex")):e.setAttribute("tabindex",0),e}get#Hn(){return Array.from(this.internals.labels).map((e=>e.textContent)).join(" ")}get#Kn(){return Array.from(this.attributes).filter((e=>e.name.startsWith("aria-")))}set#Un(e){const t=void 0!==this.#Un&&this.#Un!==this.value;this.internals.setFormValue(e),this._internalFormValue=e,this.#Sn.value=this.isEmpty?"":e,t&&$g(this,"lexxy:change")}get#Un(){return this._internalFormValue}#Dn(){const e=this.valueBeforeDisconnect||this.getAttribute("value")||"

    ";this.value=this.#xn=e}#Bn(){document.addEventListener("turbo:before-cache",this.#Wn)}#Wn=e=>{this.#wn()};#Ln(){this.#Vn(this.editor.registerUpdateListener((({editorState:e})=>{this.#qn(),this.#Un=this.value,this.#An(),this.#kn()})))}#qn(){this.cachedValue=null,this.cachedStringValue=null}#Vn(e){this.unregisterHandlers=this.unregisterHandlers||[],this.unregisterHandlers.push(e)}#jn(){this.unregisterHandlers?.forEach((e=>{e()})),this.unregisterHandlers=null}#On(){Su(this.editor),this.historyState={current:null,redoStack:[],undoStack:[]},Ig(this.editor,this.historyState,20),Dc(this.editor),this.#Zn(),this.#Gn(),Og(this.editor,Ng)}#Zn(){!function(e){e.hasNodes([Jh])||Md(255),Aa(e.registerCommand(Pd,tg,0),e.registerCommand(ln,(({nodes:t,selection:n},r)=>!(e!==r||!gi(n))&&null!==$h(n.anchor.getNode())&&t.some(eg)),0),e.registerCommand(an,og,0),e.registerNodeTransform(Jh,ig),e.registerNodeTransform(Dd,rg),e.registerNodeTransform(Ld,ng))}(this.editor),this.tableHandler=Dg("lexxy-table-handler"),this.append(this.tableHandler),this.#Vn(this.editor.registerNodeTransform(Ld,(e=>{null===e.getBackgroundColor()&&e.setBackgroundColor("")})))}#Gn(){!function(e,t){if(!e.hasNodes([Ru,Ku]))throw new Error("CodeHighlightPlugin: CodeNode or CodeHighlightNode not registered on editor");null==t&&(t=nd);const n=[];!0!==e._headless&&n.push(e.registerMutationListener(Ru,(t=>{e.getEditorState().read((()=>{for(const[n,r]of t)if("destroyed"!==r){const t=is(n);null!==t&&id(t,e)}}))}),{skipInitialization:!1})),n.push(e.registerNodeTransform(Ru,(n=>sd(n,e,t))),e.registerNodeTransform(jr,(n=>rd(n,e,t))),e.registerNodeTransform(Ku,(n=>rd(n,e,t))),e.registerCommand(Fn,(t=>{const n=function(e){const t=Li();if(!gi(t)||!ad(t))return null;const n=e?Pn:In,r=e?Pn:Rn,i=t.anchor,o=t.focus;if(i.is(o))return r;const s=cd(t);if(1!==s.length)return n;const l=s[0];let a,c;0===l.length&&Nu(285),t.isBackward()?(a=o,c=i):(a=i,c=o);const u=ju(l[0]),d=Zu(l[0]),h=ci(u.getKey(),0,"text"),g=ci(d.getKey(),d.getTextContentSize(),"text");return a.isBefore(h)||g.isBefore(c)?n:h.isBefore(a)||c.isBefore(g)?r:n}(t.shiftKey);return null!==n&&(t.preventDefault(),e.dispatchCommand(n,void 0),!0)}),1),e.registerCommand(Rn,(()=>!!ad(Li())&&(Di([si()]),!0)),1),e.registerCommand(In,(e=>ud(In)),1),e.registerCommand(Pn,(e=>ud(Pn)),1),e.registerCommand(kn,(e=>{const t=Li();if(!gi(t))return!1;const{anchor:n}=t,r=n.getNode();return!!ad(t)&&(t.isCollapsed()&&0===n.offset&&null===r.getPreviousSibling()&&Pu(r.getParentOrThrow())?(e.preventDefault(),!0):dd(kn,e))}),1),e.registerCommand(Tn,(e=>{const t=Li();if(!gi(t))return!1;const{anchor:n}=t,r=n.getNode();return!!ad(t)&&(t.isCollapsed()&&n.offset===r.getTextContentSize()&&null===r.getNextSibling()&&Pu(r.getParentOrThrow())?(e.preventDefault(),!0):dd(Tn,e))}),1),e.registerCommand(wn,(e=>hd(wn,e)),1),e.registerCommand(Cn,(e=>hd(Cn,e)),1)),Aa(...n)}(this.editor),this.codeLanguagePicker=Dg("lexxy-code-language-picker"),this.append(this.codeLanguagePicker)}#Fn(){this.editor.getRootElement().addEventListener("lexxy:internal:invalidate-node",(e=>{const{key:t,values:n}=e.detail;this.editor.update((()=>{const e=is(t);if(e instanceof Ug){const t=e.getWritable();Object.assign(t,n)}}))}))}#Rn(){this.editor.registerCommand(En,(e=>(e.ctrlKey||e.metaKey||!!this.isSingleLineMode)&&(e.preventDefault(),!0)),2)}#T(){this.editor.registerCommand(Gn,(()=>{$g(this,"lexxy:blur")}),2),this.editor.registerCommand(Zn,(()=>{$g(this,"lexxy:focus")}),2)}#In(){this.removeTableSelectionObserver=function(e,t=!0){const n=new Map,r=(r,i,o)=>{const s=yh(r,o),l=vh(r,s,e,t);n.set(i,[l,s])},i=e.registerMutationListener(Jh,(t=>{e.getEditorState().read((()=>{for(const[e,i]of t){const t=n.get(e);if("created"===i||"updated"===i){const{tableNode:i,tableElement:o}=gh(e);void 0===t?r(i,e,o):o!==t[1]&&(t[0].removeListeners(),n.delete(e),r(i,e,o))}else"destroyed"===i&&void 0!==t&&(t[0].removeListeners(),n.delete(e))}}),{editor:e})}),{skipInitialization:!1});return()=>{i();for(const[,[e]]of n)e.removeListeners()}}(this.editor,!0),function(e){Zh.add(e)}(this.editor)}#Pn(){wf.debug&&this.#Vn(this.editor.registerUpdateListener((({editorState:e})=>{e.read((()=>{console.debug("HTML: ",this.value,"String:",this.toString()),console.debug("empty",this.isEmpty,"blank",this.isBlank)}))})))}#Mn(){this.#Tn&&this.toolbarElement.setEditor(this)}#En(){const e=this.getAttribute("toolbar");return e?document.getElementById(e):this.#Jn()}get#Tn(){return"false"!==this.getAttribute("toolbar")}#Jn(){const e=Dg("lexxy-toolbar");return e.innerHTML=pg.defaultTemplate,e.setAttribute("data-attachments",this.supportsAttachments),this.prepend(e),e}#An(){this.classList.toggle("lexxy-editor--empty",this.isEmpty)}#kn(){this.#Sn.validity.valid?this.internals.setValidity({}):this.internals.setValidity(this.#Sn.validity,this.#Sn.validationMessage,this.editorContentElement)}#wn(){this.#jn(),this.editorContentElement&&(this.editorContentElement.remove(),this.editorContentElement=null),this.contents=null,this.editor=null,this.toolbar&&(this.getAttribute("toolbar")||this.toolbar.remove(),this.toolbar=null),this.codeLanguagePicker&&(this.codeLanguagePicker.remove(),this.codeLanguagePicker=null),this.tableHandler&&(this.tableHandler.remove(),this.tableHandler=null),this.selection=null,document.removeEventListener("turbo:before-cache",this.#Wn)}#g(){this.disconnectedCallback(),this.valueBeforeDisconnect=null,this.connectedCallback()}}customElements.define("lexxy-editor",wf);class kf extends HTMLElement{connectedCallback(){this.container=this.closest("details"),this.container.addEventListener("toggle",this.#Yn.bind(this)),this.container.addEventListener("keydown",this.#Xn.bind(this))}disconnectedCallback(){this.#Qn(),this.container.removeEventListener("keydown",this.#Xn.bind(this))}get toolbar(){return this.closest("lexxy-toolbar")}get editor(){return this.toolbar.editor}close(){this.container.removeAttribute("open")}#Yn(e){this.container.open?this.#er(e.target):this.#tr()}#er(){this.#nr[0].focus(),this.#rr(),this.#m()}#tr(){this.#Qn(),this.editor.focus()}#rr(){this.clickOutsideHandler||(this.clickOutsideHandler=this.#ir.bind(this),document.addEventListener("click",this.clickOutsideHandler,!0))}#Qn(){this.clickOutsideHandler&&(document.removeEventListener("click",this.clickOutsideHandler,!0),this.clickOutsideHandler=null)}#ir({target:e}){this.container.open&&!this.container.contains(e)&&this.close()}#Xn(e){"Escape"===e.key&&(e.stopPropagation(),this.close())}async#m(){await Zg(),this.#H.forEach(((e,t)=>{e.setAttribute("tabindex",0===t?0:"-1")}))}get#nr(){return Array.from(this.querySelectorAll("button, input"))}get#H(){return Array.from(this.querySelectorAll("button"))}}customElements.define("lexxy-link-dropdown",class extends kf{connectedCallback(){super.connectedCallback(),this.input=this.querySelector("input"),this.#or()}#or(){this.container.addEventListener("toggle",this.#Yn.bind(this)),this.addEventListener("submit",this.#sr.bind(this)),this.querySelector("[value='unlink']").addEventListener("click",this.#lr.bind(this))}#Yn({newState:e}){this.input.value=this.#ar,this.input.required="open"===e}#sr(e){const t=e.submitter?.value;this.editor.dispatchCommand(t,this.input.value),this.close()}#lr(){this.editor.dispatchCommand("unlink"),this.close()}get#ar(){let e="";return this.editor.getEditorState().read((()=>{const t=Li();if(!gi(t))return;let n=t.getNodes()[0];for(;n&&n.getParent();){if(yd(n)){e=n.getURL();break}n=n.getParent()}})),e}});const Tf="button.lexxy-highlight-button",Ef="[data-command='removeHighlight']",Nf=Symbol("no_style");customElements.define("lexxy-highlight-dropdown",class extends kf{connectedCallback(){super.connectedCallback(),this.#cr(),this.#or()}#or(){this.container.addEventListener("toggle",this.#Yn.bind(this)),this.#ur.forEach((e=>e.addEventListener("click",this.#dr.bind(this)))),this.querySelector(Ef).addEventListener("click",this.#hr.bind(this))}#cr(){this.#gr.forEach((e=>{this.#pr(e)}))}#pr(e){const t=e.dataset.values?.split("; ")||[],n=e.dataset.buttonGroup;t.forEach(((t,r)=>{e.appendChild(this.#fr(n,t,r))}))}#fr(e,t,n){const r=document.createElement("button");return r.dataset.style=e,r.style.setProperty(e,t),r.dataset.value=t,r.classList.add("lexxy-highlight-button"),r.name=e+"-"+n,r}#Yn({newState:e}){"open"===e&&this.editor.getEditorState().read((()=>{this.#mr(Li())}))}#dr(e){e.preventDefault();const t=e.target.closest(Tf);if(!t)return;const n=t.dataset.style,r=t.dataset.value;this.editor.dispatchCommand("toggleHighlight",{[n]:r}),this.close()}#hr(e){e.preventDefault(),this.editor.dispatchCommand("removeHighlight"),this.close()}#mr(e){if(!gi(e))return;const t=Ca(e,"color",Nf),n=Ca(e,"background-color",Nf);this.#ur.forEach((e=>{const r=e.dataset.value===t||e.dataset.value===n;e.setAttribute("aria-pressed",r)}));const r=t!==Nf||n!==Nf;this.querySelector(Ef).disabled=!r}get#gr(){return this.querySelectorAll("[data-button-group]")}get#ur(){return Array.from(this.querySelectorAll(Tf))}});class Af extends HTMLElement{connectedCallback(){this.#cr(),this.#yr(),this.#br()}disconnectedCallback(){this.#_r()}get#xr(){return this.#Sr.editor}get#Sr(){return this.closest("lexxy-editor")}get#Cr(){const e=Li();if(!gi(e))return null;return Wd(e.anchor.getNode())}get#vr(){const e=this.#Cr;return e?function(e){const t=Vd(e);return qd(t).getChildren().findIndex((e=>e.is(t)))}(e):0}get#wr(){const e=this.#Cr;return e?function(e){return Vd(e).getChildren().findIndex((t=>t.is(e)))}(e):0}get#kr(){return Array.from(this.buttonsContainer.querySelectorAll("button, details > summary"))}#br(){this.unregisterKeyboardShortcuts=this.#xr.registerCommand(xn,this.#Xn,3)}#_r(){this.unregisterKeyboardShortcuts()}#Xn=e=>{if((e.ctrlKey||e.metaKey)&&e.shiftKey&&"F10"===e.key){const e=this.buttonsContainer?.querySelector("button, [tabindex]:not([tabindex='-1'])");this.#Tr(),e?.focus()}else"Escape"===e.key&&(this.#xr.getEditorState().read((()=>{const e=this.#Cr;e&&this.#xr.update((()=>{e.select()}))})),this.#Er())};#Nr=e=>{"Escape"===e.key?this.#xr.focus():dg(this.#kr,e)};#cr(){this.buttonsContainer=Dg("div",{className:"lexxy-table-handle-buttons"}),this.buttonsContainer.appendChild(this.#Ar()),this.buttonsContainer.appendChild(this.#Lr()),this.moreMenu=this.#Or(),this.buttonsContainer.appendChild(this.moreMenu),this.buttonsContainer.addEventListener("keydown",this.#Nr),this.#Sr.appendChild(this.buttonsContainer)}#Fr(){this.buttonsContainer.style.display="flex",this.#Er(),this.#Rr(),this.#Ir(!0)}#Pr(){this.buttonsContainer.style.display="none",this.#Er(),this.#Ir(!1),this.currentTableNode=null}#Mr(e){const t=this.#xr.getElementByKey(e.getKey());if(!t)return;const n=t.getBoundingClientRect(),r=this.#Sr.getBoundingClientRect(),i=n.top-r.top,o=(n.left+n.right)/2-r.left;this.buttonsContainer.style.top=`${i}px`,this.buttonsContainer.style.left=`${o}px`}#Rr(){if(!this.currentTableNode)return;const e=Yh(this.#xr,this.currentTableNode);if(!e)return;const t=e.rows,n=e.columns;this.rowCount.textContent=`${t} row${1===t?"":"s"}`,this.columnCount.textContent=`${n} column${1===n?"":"s"}`}#fr(e,t,n){const r=Dg("button",{className:"lexxy-table-control__button","aria-label":t,type:"button"});return r.tabIndex=-1,r.innerHTML=`${e} ${t}`,r.addEventListener("click",n.bind(this)),r}#Ar(){const e=Dg("div",{className:"lexxy-table-control"}),t=this.#fr("+","Add row",(()=>this.#Dr("end"))),n=this.#fr("−","Remove row",(()=>this.#Br("end")));return this.rowCount=Dg("span"),this.rowCount.textContent="_ rows",e.appendChild(n),e.appendChild(this.rowCount),e.appendChild(t),e}#Lr(){const e=Dg("div",{className:"lexxy-table-control"}),t=this.#fr("+","Add column",(()=>this.#zr("end"))),n=this.#fr("−","Remove column",(()=>this.#$r("end")));return this.columnCount=Dg("span"),this.columnCount.textContent="_ columns",e.appendChild(n),e.appendChild(this.columnCount),e.appendChild(t),e}#Or(){const e=Dg("details",{className:"lexxy-table-control lexxy-table-control__more-menu"});e.setAttribute("name","lexxy-dropdown"),e.tabIndex=-1;const t=Dg("summary",{},"•••");e.appendChild(t);const n=Dg("div",{className:"lexxy-table-control__more-menu-details"});return e.appendChild(n),n.appendChild(this.#Hr()),n.appendChild(this.#Kr()),n.appendChild(this.#Ur()),e.addEventListener("toggle",this.#Wr.bind(this)),e}#Kr(){const e=Dg("section",{className:"lexxy-table-control__more-menu-section"});return[{icon:this.#Vr("add-column-before"),label:"Add column before",onClick:()=>this.#zr("left")},{icon:this.#Vr("add-column-after"),label:"Add column after",onClick:()=>this.#zr("right")},{icon:this.#Vr("remove-column"),label:"Remove column",onClick:this.#$r},{icon:this.#Vr("toggle-column-style"),label:"Toggle column style",onClick:this.#qr}].forEach((t=>{const n=this.#fr(t.icon,t.label,t.onClick);e.appendChild(n)})),e}#Hr(){const e=Dg("section",{className:"lexxy-table-control__more-menu-section"});return[{icon:this.#Vr("add-row-above"),label:"Add row above",onClick:()=>this.#Dr("above")},{icon:this.#Vr("add-row-below"),label:"Add row below",onClick:()=>this.#Dr("below")},{icon:this.#Vr("remove-row"),label:"Remove row",onClick:this.#Br},{icon:this.#Vr("toggle-row-style"),label:"Toggle row style",onClick:this.#jr}].forEach((t=>{const n=this.#fr(t.icon,t.label,t.onClick);e.appendChild(n)})),e}#Ur(){const e=Dg("section",{className:"lexxy-table-control__more-menu-section"}),t={icon:this.#Vr("delete-table"),label:"Delete table",onClick:this.#Zr},n=this.#fr(t.icon,t.label,t.onClick);return e.appendChild(n),e}#Wr(){this.moreMenu.open?this.#Tr():this.#Gr()}#Er(){this.#Gr(),this.moreMenu.removeAttribute("open")}#yr(){this.#xr.registerUpdateListener((()=>{this.#xr.getEditorState().read((()=>{const e=Li();if(!gi(e))return;const t=$h(e.anchor.getNode());t?this.#Jr(t):this.#Pr()}))}))}#Ir(e){if(this.#Sr.querySelector("div.node--selected:has(table)")?.classList.remove("node--selected"),e&&this.currentTableNode){const e=this.#xr.getElementByKey(this.currentTableNode.getKey());if(!e)return;e.classList.add("node--selected")}}#Jr(e){this.currentTableNode=e,this.#Mr(e),this.#Fr()}#Tr(){this.#xr.getEditorState().read((()=>{const e=this.#Cr;if(!e)return;const t=this.#xr.getElementByKey(e.getKey());t&&t.classList.add("table-cell--selected")}))}#Gr(){this.#Sr.querySelector(".table-cell--selected")?.classList.remove("table-cell--selected")}#Yr(){if(!this.currentTableNode)return;const e=this.currentTableNode.getLastChild().getLastChild();Id(e)&&e.selectEnd()}#Zr(){this.#xr.dispatchCommand("deleteTable"),this.#Er(),this.#Rr()}#Dr(e){this.#Xr("insert","row",e)}#zr(e){this.#Xr("insert","column",e)}#Br(e){this.#Xr("delete","row",e)}#$r(e){this.#Xr("delete","column",e)}#Xr(e="insert",t="row",n){this.#xr.update((()=>{const r=this.#Cr;r&&("end"===n&&this.#Yr(),this.#Qr(e,t,n),r.isAttached()&&r.selectEnd())})),this.#Er(),this.#Rr()}#Qr(e,t,n){switch(e){case"insert":switch(t){case"row":"above"===n?this.#xr.dispatchCommand("insertTableRowAbove"):this.#xr.dispatchCommand("insertTableRowBelow");break;case"column":"left"===n?this.#xr.dispatchCommand("insertTableColumnBefore"):this.#xr.dispatchCommand("insertTableColumnAfter")}break;case"delete":switch(t){case"row":this.#xr.dispatchCommand("deleteTableRow");break;case"column":this.#xr.dispatchCommand("deleteTableColumn")}}}#jr(){this.#xr.update((()=>{const e=this.currentTableNode.getChildren()[this.#vr];if(!e)return;const t=e.getChildren(),n=Wd(t[0]);if(!n)return;const r=n.getHeaderStyles()^Ad;t.forEach((e=>{this.#ei(e,r,Ad)}))}))}#qr(){this.#xr.update((()=>{const e=this.currentTableNode.getChildren(),t=e[this.#vr];if(!t)return;const n=Wd(t.getChildren()[this.#wr]);if(!n)return;const r=n.getHeaderStyles()^Ed;e.forEach((e=>{const t=e.getChildren()[this.#wr];t&&this.#ei(t,r,Ed)}))}))}#ei(e,t,n){const r=Wd(e);r&&r.setHeaderStyles(t,n)}#Vr(e){return{"add-row-above":'\n \n ',"add-row-below":'\n \n ',"remove-row":'\n \n ',"toggle-row-style":'\n \n ',"add-column-before":'\n \n ',"add-column-after":'\n \n ',"remove-column":'\n \n ',"toggle-column-style":'\n \n ',"delete-table":'\n \n '}[e]}}customElements.define("lexxy-table-handler",Af);class Lf{async buildListItems(e=""){return Promise.resolve([])}promptItemFor(e){return null}buildListItemElementFor(e){const t=e.querySelector("template[type='menu']").content.cloneNode(!0),n=Dg("li",{role:"option",id:Hg("prompt-item"),tabindex:"0"});return n.classList.add("lexxy-prompt-menu__item"),n.appendChild(t),n}async loadPromptItemsFromUrl(e){try{const t=await fetch(e),n=Bg(await t.text()).querySelectorAll("lexxy-prompt-item");return Promise.resolve(Array.from(n))}catch(e){return Promise.reject(e)}}}class Of extends Lf{async buildListItems(e=""){const t=await this.fetchPromptItems();return this.#ti(t,e)}async fetchPromptItems(e){return Promise.resolve([])}promptItemFor(e){return this.promptItemByListItem.get(e)}#ti(e,t){const n=[];return this.promptItemByListItem=new WeakMap,e.forEach((e=>{const r=e.getAttribute("search");if(!t||function(e,t){return pf(e).includes(pf(t))}(r,t)){const t=this.buildListItemElementFor(e);this.promptItemByListItem.set(t,e),n.push(t)}})),n}}class Ff extends Of{constructor(e){super(),this.inlinePromptItemElements=Array.from(e)}async fetchPromptItems(){return Promise.resolve(this.inlinePromptItemElements)}}class Rf extends Of{constructor(e){super(),this.url=e,this.fetchPromptItems()}async fetchPromptItems(){return this.promptItems??=await this.loadPromptItemsFromUrl(this.url),Promise.resolve(this.promptItems)}}class If extends Lf{constructor(e){super(),this.baseURL=e,this.loadAndFilterListItems=function(e,t){let n;return(...r)=>(clearTimeout(n),new Promise(((i,o)=>{n=setTimeout((async()=>{try{const t=await e(...r);i(t)}catch(e){o(e)}}),t)})))}(this.fetchFilteredListItems.bind(this),200)}async buildListItems(e=""){return await this.loadAndFilterListItems(e)}promptItemFor(e){return this.promptItemByListItem.get(e)}async fetchFilteredListItems(e){const t=await this.loadPromptItemsFromUrl(this.#ni(e));return this.#ti(t)}#ni(e){const t=new URL(this.baseURL,window.location.origin);return t.searchParams.append("filter",e),t.toString()}#ti(e){const t=[];this.promptItemByListItem=new WeakMap;for(const n of e){const e=this.buildListItemElementFor(n);this.promptItemByListItem.set(e,n),t.push(e)}return t}}class Pf extends HTMLElement{constructor(){super(),this.keyListeners=[]}static observedAttributes=["connected"];connectedCallback(){this.source=this.#ri(),this.#ii(),this.toggleAttribute("connected",!0)}disconnectedCallback(){this.source=null,this.popoverElement=null}attributeChangedCallback(e,t,n){"connected"===e&&this.isConnected&&null!=t&&t!==n&&requestAnimationFrame((()=>this.#g()))}get name(){return this.getAttribute("name")}get trigger(){return this.getAttribute("trigger")}get supportsSpaceInSearches(){return this.hasAttribute("supports-space-in-searches")}get open(){return this.popoverElement?.classList?.contains("lexxy-prompt-menu--visible")}get closed(){return!this.open}get#oi(){return!this.supportsSpaceInSearches}#ri(){const e=this.getAttribute("src");return e?this.hasAttribute("remote-filtering")?new If(e):new Rf(e):new Ff(this.querySelectorAll("lexxy-prompt-item"))}#ii(){const e=this.#xr.registerUpdateListener((()=>{this.#xr.read((()=>{const{node:t,offset:n}=this.#Bt.selectedNodeWithOffset();if(t&&ri(t)&&n>0){const r=t.getTextContent();if(r[n-1]===this.trigger){const t=1===n,i=n>1?r[n-2]:null;(t||(" "===i||"\n"===i))&&(e(),this.#si())}}}))}))}#li(){this.cursorPositionListener=this.#xr.registerUpdateListener((()=>{this.closed||this.#xr.read((()=>{const{node:e,offset:t}=this.#Bt.selectedNodeWithOffset();if(e)if(ri(e)&&t>0){const n=e.getTextContent().slice(0,t).lastIndexOf(this.trigger);(-1===n||t<=n)&&this.#ai()}else this.#ai()}))}))}#ci(){this.cursorPositionListener&&(this.cursorPositionListener(),this.cursorPositionListener=null)}get#xr(){return this.#Sr.editor}get#Sr(){return this.closest("lexxy-editor")}get#Bt(){return this.#Sr.selection}async#si(){this.popoverElement??=await this.#ui(),this.#di(),await this.#hi(),this.popoverElement.classList.toggle("lexxy-prompt-menu--visible",!0),this.#gi(),this.#Sr.addEventListener("keydown",this.#pi),this.#Sr.addEventListener("lexxy:change",this.#hi),this.#fi(),this.#li()}#fi(){this.keyListeners.push(this.#xr.registerCommand(En,this.#mi.bind(this),3)),this.keyListeners.push(this.#xr.registerCommand(Fn,this.#mi.bind(this),3)),this.#oi&&this.keyListeners.push(this.#xr.registerCommand(Nn,this.#mi.bind(this),3)),this.keyListeners.push(this.#xr.registerCommand(kn,this.#yi.bind(this),3)),this.keyListeners.push(this.#xr.registerCommand(Tn,this.#bi.bind(this),3))}#yi(e){return this.#_i(),e.preventDefault(),!0}#bi(e){return this.#xi(),e.preventDefault(),!0}#gi(){const e=this.#Si[0];e&&this.#Ci(e)}get#Si(){return Array.from(this.popoverElement.querySelectorAll(".lexxy-prompt-menu__item"))}#Ci(e){this.#vi(),e.toggleAttribute("aria-selected",!0),e.scrollIntoView({block:"nearest",behavior:"smooth"}),e.focus(),this.#Bt.preservingSelection((()=>{this.#Sr.focus()})),this.#wi.setAttribute("aria-controls",this.popoverElement.id),this.#wi.setAttribute("aria-activedescendant",e.id),this.#wi.setAttribute("aria-haspopup","listbox")}#vi(){this.#Si.forEach((e=>{e.toggleAttribute("aria-selected",!1)})),this.#wi.removeAttribute("aria-controls"),this.#wi.removeAttribute("aria-activedescendant"),this.#wi.removeAttribute("aria-haspopup")}#ki(){const{x:e,y:t,fontSize:n}=this.#Bt.cursorPosition,r=this.#Sr.getBoundingClientRect(),i=this.#wi.getBoundingClientRect().top-r.top;this.popoverElement.hasAttribute("data-anchored")||(this.popoverElement.style.left=`${e}px`,this.popoverElement.toggleAttribute("data-anchored",!0)),this.popoverElement.style.top=`${t+i}px`,this.popoverElement.style.bottom="auto";const o=this.popoverElement.getBoundingClientRect();(o.bottom>window.innerHeight||this.popoverElement.hasAttribute("data-clipped-at-bottom"))&&(this.popoverElement.style.top=t+i-o.height-n+"px",this.popoverElement.style.bottom="auto",this.popoverElement.toggleAttribute("data-clipped-at-bottom",!0))}#di(){this.popoverElement.removeAttribute("data-clipped-at-bottom"),this.popoverElement.removeAttribute("data-anchored")}async#ai(){this.#vi(),this.popoverElement.classList.toggle("lexxy-prompt-menu--visible",!1),this.#Sr.removeEventListener("lexxy:change",this.#hi),this.#Sr.removeEventListener("keydown",this.#pi),this.#Ti(),this.#ci(),await Zg(),this.#ii()}#Ti(){this.keyListeners.forEach((e=>e())),this.keyListeners=[]}#hi=async()=>{this.initialPrompt?this.initialPrompt=!1:this.#Ei.containsTextBackUntil(this.trigger)?(await this.#Ni(),await Zg(),this.#ki()):this.#ai()};async#Ni(){const e=this.#Ei.textBackUntil(this.trigger),t=await this.source.buildListItems(e);this.popoverElement.innerHTML="",t.length>0?this.#Ai(t):this.#Li(),this.#gi()}#Ai(e){this.popoverElement.classList.remove("lexxy-prompt-menu--empty"),this.popoverElement.append(...e)}#Li(){this.popoverElement.classList.add("lexxy-prompt-menu--empty");const e=Dg("li",{innerHTML:this.#Oi});e.classList.add("lexxy-prompt-menu__item--empty"),this.popoverElement.append(e)}get#Oi(){return this.getAttribute("empty-results")||"Nothing found"}#pi=e=>{"Escape"===e.key&&(this.#ai(),this.#Sr.focus(),e.stopPropagation())};#xi(){const e=this.#Fi+1;e=0&&this.#Ci(this.#Si[e])}get#Fi(){return this.#Si.findIndex((e=>e.hasAttribute("aria-selected")))}get#Ri(){return this.#Si[this.#Fi]}#mi(e){return e.preventDefault(),e.stopPropagation(),this.#Ii(),!0}#Ii(){this.#Pi(),this.#ai(),this.#Sr.focus()}#Pi(){const e=this.source.promptItemFor(this.#Ri);if(!e)return;const t=e.querySelector("template[type='editor']"),n=`${this.trigger}${this.#Ei.textBackUntil(this.trigger)}`;this.hasAttribute("insert-editable-text")?this.#Mi(t,n):this.#Di(e,t,n)}#Mi(e,t){this.#xr.update((()=>{const n=Bc(this.#xr,Bg(`${e.innerHTML}`));this.#Ei.replaceTextBackUntil(t,n)}))}#Di(e,t,n){this.#xr.update((()=>{const r=new Jg({sgid:e.getAttribute("sgid"),contentType:`application/vnd.actiontext.${this.name}`,innerHtml:t.innerHTML});this.#Ei.replaceTextBackUntil(n,r)}))}get#Ei(){return this.#Sr.contents}get#wi(){return this.#Sr.editorContentElement}async#ui(){const e=Dg("ul",{role:"listbox",id:Hg("prompt-popover")});return e.classList.add("lexxy-prompt-menu"),e.style.position="absolute",e.setAttribute("nonce",wa()),e.append(...await this.source.buildListItems()),e.addEventListener("click",this.#Bi),this.#Sr.appendChild(e),e}#Bi=e=>{const t=e.target.closest(".lexxy-prompt-menu__item");t&&(this.#Ci(t),this.#Ii())};#g(){this.disconnectedCallback(),this.connectedCallback()}}customElements.define("lexxy-prompt",Pf);class Mf extends HTMLElement{connectedCallback(){this.editorElement=this.closest("lexxy-editor"),this.editor=this.editorElement.editor,this.#zi(),this.#$i()}#zi(){this.languagePickerElement=this.#Hi(),this.languagePickerElement.addEventListener("change",(()=>{this.#Ki(this.languagePickerElement.value)})),this.languagePickerElement.style.position="absolute",this.languagePickerElement.setAttribute("nonce",wa()),this.editorElement.appendChild(this.languagePickerElement)}#Hi(){const e=Dg("select",{hidden:!0,className:"lexxy-code-language-picker","aria-label":"Pick a language…",name:"lexxy-code-language"});for(const[t,n]of Object.entries(this.#Ui)){const r=document.createElement("option");r.value=t,r.textContent=n,e.appendChild(r)}return e}get#Ui(){const e={...Ju};e.ruby||(e.ruby="Ruby"),e.php||(e.php="PHP"),e.go||(e.go="Go"),e.bash||(e.bash="Bash"),e.json||(e.json="JSON"),e.diff||(e.diff="Diff");const t=Object.entries(e).sort((([,e],[,t])=>e.localeCompare(t))),n=t.findIndex((([e])=>"plain"===e)),r=t.splice(n,1)[0];return Object.fromEntries([r,...t])}#Ki(e){this.editor.update((()=>{const t=this.#Wi();t&&t.setLanguage(e)}))}#$i(){this.editor.registerUpdateListener((()=>{this.editor.getEditorState().read((()=>{const e=this.#Wi();e?this.#Vi(e):this.#qi()}))}))}#Wi(){const e=Li();if(!gi(e))return null;const t=e.anchor.getNode(),n=t.getParent();return Pu(t)?t:Pu(n)?n:null}#Vi(e){const t=e.getLanguage();this.#ji(t),this.#Zi(),this.#Gi(e)}#ji(e){if(this.languagePickerElement&&e){const t=Xu(e);this.languagePickerElement.value=t}}#Gi(e){const t=this.editor.getElementByKey(e.getKey());if(!t)return;const n=t.getBoundingClientRect(),r=this.editorElement.getBoundingClientRect(),i=n.top-r.top;this.languagePickerElement.style.top=`${i}px`}#Zi(){this.languagePickerElement.hidden=!1}#qi(){this.languagePickerElement.hidden=!0}}function Df(){document.querySelectorAll("pre[data-language]").forEach((e=>{!function(e){const t=e.getAttribute("data-language");let n=e.innerHTML.replace(//gi,"\n");const r=s.languages?.[t];if(!r)return;n=(new DOMParser).parseFromString(n,"text/html").body.textContent||"";const i=s.highlight(n,r,t),o=Dg("code",{"data-language":t,innerHTML:i});e.replaceWith(o)}(e)}))}customElements.define("lexxy-code-language-picker",Mf);export{Df as highlightAll}; +const{entries:c,setPrototypeOf:u,isFrozen:d,getPrototypeOf:h,getOwnPropertyDescriptor:g}=Object;let{freeze:p,seal:f,create:m}=Object,{apply:y,construct:b}="undefined"!=typeof Reflect&&Reflect;p||(p=function(e){return e}),f||(f=function(e){return e}),y||(y=function(e,t){for(var n=arguments.length,r=new Array(n>2?n-2:0),i=2;i1?t-1:0),r=1;r1?n-1:0),i=1;i2&&void 0!==arguments[2]?arguments[2]:w;u&&u(e,null);let r=t.length;for(;r--;){let i=t[r];if("string"==typeof i){const e=n(i);e!==i&&(d(t)||(t[r]=e),i=e)}e[i]=!0}return e}function M(e){for(let t=0;t/gm),X=f(/\$\{[\w\W]*/gm),Q=f(/^data-[\-\w.\u00B7-\uFFFF]+$/),ee=f(/^aria-[\-\w]+$/),te=f(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),ne=f(/^(?:\w+script|data):/i),re=f(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),ie=f(/^html$/i),oe=f(/^[a-z][.\w]*(-[.\w]+)+$/i);var se=Object.freeze({__proto__:null,ARIA_ATTR:ee,ATTR_WHITESPACE:re,CUSTOM_ELEMENT:oe,DATA_ATTR:Q,DOCTYPE_NAME:ie,ERB_EXPR:Y,IS_ALLOWED_URI:te,IS_SCRIPT_OR_DATA:ne,MUSTACHE_EXPR:J,TMPLIT_EXPR:X});const le=1,ae=3,ce=7,ue=8,de=9,he=function(){return"undefined"==typeof window?null:window};var ge=function e(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:he();const n=t=>e(t);if(n.version="3.3.0",n.removed=[],!t||!t.document||t.document.nodeType!==de||!t.Element)return n.isSupported=!1,n;let{document:r}=t;const i=r,o=i.currentScript,{DocumentFragment:s,HTMLTemplateElement:l,Node:a,Element:u,NodeFilter:d,NamedNodeMap:h=t.NamedNodeMap||t.MozNamedAttrMap,HTMLFormElement:g,DOMParser:f,trustedTypes:y}=t,b=u.prototype,R=B(b,"cloneNode"),I=B(b,"remove"),M=B(b,"nextSibling"),J=B(b,"childNodes"),Y=B(b,"parentNode");if("function"==typeof l){const e=r.createElement("template");e.content&&e.content.ownerDocument&&(r=e.content.ownerDocument)}let X,Q="";const{implementation:ee,createNodeIterator:ne,createDocumentFragment:re,getElementsByTagName:oe}=r,{importNode:ge}=i;let pe={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]};n.isSupported="function"==typeof c&&"function"==typeof Y&&ee&&void 0!==ee.createHTMLDocument;const{MUSTACHE_EXPR:fe,ERB_EXPR:me,TMPLIT_EXPR:ye,DATA_ATTR:be,ARIA_ATTR:_e,IS_SCRIPT_OR_DATA:xe,ATTR_WHITESPACE:Se,CUSTOM_ELEMENT:Ce}=se;let{IS_ALLOWED_URI:ve}=se,we=null;const ke=P({},[...z,...$,...H,...U,...V]);let Te=null;const Ee=P({},[...q,...j,...Z,...G]);let Ne=Object.seal(m(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),Ae=null,Le=null;const Oe=Object.seal(m(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let Fe=!0,Re=!0,Ie=!1,Pe=!0,Me=!1,De=!0,Be=!1,ze=!1,$e=!1,He=!1,Ke=!1,Ue=!1,We=!0,Ve=!1,qe=!0,je=!1,Ze={},Ge=null;const Je=P({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let Ye=null;const Xe=P({},["audio","video","img","source","image","track"]);let Qe=null;const et=P({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),tt="http://www.w3.org/1998/Math/MathML",nt="http://www.w3.org/2000/svg",rt="http://www.w3.org/1999/xhtml";let it=rt,ot=!1,st=null;const lt=P({},[tt,nt,rt],k);let at=P({},["mi","mo","mn","ms","mtext"]),ct=P({},["annotation-xml"]);const ut=P({},["title","style","font","a","script"]);let dt=null;const ht=["application/xhtml+xml","text/html"];let gt=null,pt=null;const ft=r.createElement("form"),mt=function(e){return e instanceof RegExp||e instanceof Function},yt=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!pt||pt!==e){if(e&&"object"==typeof e||(e={}),e=D(e),dt=-1===ht.indexOf(e.PARSER_MEDIA_TYPE)?"text/html":e.PARSER_MEDIA_TYPE,gt="application/xhtml+xml"===dt?k:w,we=L(e,"ALLOWED_TAGS")?P({},e.ALLOWED_TAGS,gt):ke,Te=L(e,"ALLOWED_ATTR")?P({},e.ALLOWED_ATTR,gt):Ee,st=L(e,"ALLOWED_NAMESPACES")?P({},e.ALLOWED_NAMESPACES,k):lt,Qe=L(e,"ADD_URI_SAFE_ATTR")?P(D(et),e.ADD_URI_SAFE_ATTR,gt):et,Ye=L(e,"ADD_DATA_URI_TAGS")?P(D(Xe),e.ADD_DATA_URI_TAGS,gt):Xe,Ge=L(e,"FORBID_CONTENTS")?P({},e.FORBID_CONTENTS,gt):Je,Ae=L(e,"FORBID_TAGS")?P({},e.FORBID_TAGS,gt):D({}),Le=L(e,"FORBID_ATTR")?P({},e.FORBID_ATTR,gt):D({}),Ze=!!L(e,"USE_PROFILES")&&e.USE_PROFILES,Fe=!1!==e.ALLOW_ARIA_ATTR,Re=!1!==e.ALLOW_DATA_ATTR,Ie=e.ALLOW_UNKNOWN_PROTOCOLS||!1,Pe=!1!==e.ALLOW_SELF_CLOSE_IN_ATTR,Me=e.SAFE_FOR_TEMPLATES||!1,De=!1!==e.SAFE_FOR_XML,Be=e.WHOLE_DOCUMENT||!1,He=e.RETURN_DOM||!1,Ke=e.RETURN_DOM_FRAGMENT||!1,Ue=e.RETURN_TRUSTED_TYPE||!1,$e=e.FORCE_BODY||!1,We=!1!==e.SANITIZE_DOM,Ve=e.SANITIZE_NAMED_PROPS||!1,qe=!1!==e.KEEP_CONTENT,je=e.IN_PLACE||!1,ve=e.ALLOWED_URI_REGEXP||te,it=e.NAMESPACE||rt,at=e.MATHML_TEXT_INTEGRATION_POINTS||at,ct=e.HTML_INTEGRATION_POINTS||ct,Ne=e.CUSTOM_ELEMENT_HANDLING||{},e.CUSTOM_ELEMENT_HANDLING&&mt(e.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(Ne.tagNameCheck=e.CUSTOM_ELEMENT_HANDLING.tagNameCheck),e.CUSTOM_ELEMENT_HANDLING&&mt(e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(Ne.attributeNameCheck=e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),e.CUSTOM_ELEMENT_HANDLING&&"boolean"==typeof e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements&&(Ne.allowCustomizedBuiltInElements=e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),Me&&(Re=!1),Ke&&(He=!0),Ze&&(we=P({},V),Te=[],!0===Ze.html&&(P(we,z),P(Te,q)),!0===Ze.svg&&(P(we,$),P(Te,j),P(Te,G)),!0===Ze.svgFilters&&(P(we,H),P(Te,j),P(Te,G)),!0===Ze.mathMl&&(P(we,U),P(Te,Z),P(Te,G))),e.ADD_TAGS&&("function"==typeof e.ADD_TAGS?Oe.tagCheck=e.ADD_TAGS:(we===ke&&(we=D(we)),P(we,e.ADD_TAGS,gt))),e.ADD_ATTR&&("function"==typeof e.ADD_ATTR?Oe.attributeCheck=e.ADD_ATTR:(Te===Ee&&(Te=D(Te)),P(Te,e.ADD_ATTR,gt))),e.ADD_URI_SAFE_ATTR&&P(Qe,e.ADD_URI_SAFE_ATTR,gt),e.FORBID_CONTENTS&&(Ge===Je&&(Ge=D(Ge)),P(Ge,e.FORBID_CONTENTS,gt)),qe&&(we["#text"]=!0),Be&&P(we,["html","head","body"]),we.table&&(P(we,["tbody"]),delete Ae.tbody),e.TRUSTED_TYPES_POLICY){if("function"!=typeof e.TRUSTED_TYPES_POLICY.createHTML)throw F('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if("function"!=typeof e.TRUSTED_TYPES_POLICY.createScriptURL)throw F('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');X=e.TRUSTED_TYPES_POLICY,Q=X.createHTML("")}else void 0===X&&(X=function(e,t){if("object"!=typeof e||"function"!=typeof e.createPolicy)return null;let n=null;const r="data-tt-policy-suffix";t&&t.hasAttribute(r)&&(n=t.getAttribute(r));const i="dompurify"+(n?"#"+n:"");try{return e.createPolicy(i,{createHTML:e=>e,createScriptURL:e=>e})}catch(e){return console.warn("TrustedTypes policy "+i+" could not be created."),null}}(y,o)),null!==X&&"string"==typeof Q&&(Q=X.createHTML(""));p&&p(e),pt=e}},bt=P({},[...$,...H,...K]),_t=P({},[...U,...W]),xt=function(e){C(n.removed,{element:e});try{Y(e).removeChild(e)}catch(t){I(e)}},St=function(e,t){try{C(n.removed,{attribute:t.getAttributeNode(e),from:t})}catch(e){C(n.removed,{attribute:null,from:t})}if(t.removeAttribute(e),"is"===e)if(He||Ke)try{xt(t)}catch(e){}else try{t.setAttribute(e,"")}catch(e){}},Ct=function(e){let t=null,n=null;if($e)e=""+e;else{const t=T(e,/^[\r\n\t ]+/);n=t&&t[0]}"application/xhtml+xml"===dt&&it===rt&&(e=''+e+"");const i=X?X.createHTML(e):e;if(it===rt)try{t=(new f).parseFromString(i,dt)}catch(e){}if(!t||!t.documentElement){t=ee.createDocument(it,"template",null);try{t.documentElement.innerHTML=ot?Q:i}catch(e){}}const o=t.body||t.documentElement;return e&&n&&o.insertBefore(r.createTextNode(n),o.childNodes[0]||null),it===rt?oe.call(t,Be?"html":"body")[0]:Be?t.documentElement:o},vt=function(e){return ne.call(e.ownerDocument||e,e,d.SHOW_ELEMENT|d.SHOW_COMMENT|d.SHOW_TEXT|d.SHOW_PROCESSING_INSTRUCTION|d.SHOW_CDATA_SECTION,null)},wt=function(e){return e instanceof g&&("string"!=typeof e.nodeName||"string"!=typeof e.textContent||"function"!=typeof e.removeChild||!(e.attributes instanceof h)||"function"!=typeof e.removeAttribute||"function"!=typeof e.setAttribute||"string"!=typeof e.namespaceURI||"function"!=typeof e.insertBefore||"function"!=typeof e.hasChildNodes)},kt=function(e){return"function"==typeof a&&e instanceof a};function Tt(e,t,r){_(e,(e=>{e.call(n,t,r,pt)}))}const Et=function(e){let t=null;if(Tt(pe.beforeSanitizeElements,e,null),wt(e))return xt(e),!0;const r=gt(e.nodeName);if(Tt(pe.uponSanitizeElement,e,{tagName:r,allowedTags:we}),De&&e.hasChildNodes()&&!kt(e.firstElementChild)&&O(/<[/\w!]/g,e.innerHTML)&&O(/<[/\w!]/g,e.textContent))return xt(e),!0;if(e.nodeType===ce)return xt(e),!0;if(De&&e.nodeType===ue&&O(/<[/\w]/g,e.data))return xt(e),!0;if(!(Oe.tagCheck instanceof Function&&Oe.tagCheck(r))&&(!we[r]||Ae[r])){if(!Ae[r]&&At(r)){if(Ne.tagNameCheck instanceof RegExp&&O(Ne.tagNameCheck,r))return!1;if(Ne.tagNameCheck instanceof Function&&Ne.tagNameCheck(r))return!1}if(qe&&!Ge[r]){const t=Y(e)||e.parentNode,n=J(e)||e.childNodes;if(n&&t){for(let r=n.length-1;r>=0;--r){const i=R(n[r],!0);i.__removalCount=(e.__removalCount||0)+1,t.insertBefore(i,M(e))}}}return xt(e),!0}return e instanceof u&&!function(e){let t=Y(e);t&&t.tagName||(t={namespaceURI:it,tagName:"template"});const n=w(e.tagName),r=w(t.tagName);return!!st[e.namespaceURI]&&(e.namespaceURI===nt?t.namespaceURI===rt?"svg"===n:t.namespaceURI===tt?"svg"===n&&("annotation-xml"===r||at[r]):Boolean(bt[n]):e.namespaceURI===tt?t.namespaceURI===rt?"math"===n:t.namespaceURI===nt?"math"===n&&ct[r]:Boolean(_t[n]):e.namespaceURI===rt?!(t.namespaceURI===nt&&!ct[r])&&!(t.namespaceURI===tt&&!at[r])&&!_t[n]&&(ut[n]||!bt[n]):!("application/xhtml+xml"!==dt||!st[e.namespaceURI]))}(e)?(xt(e),!0):"noscript"!==r&&"noembed"!==r&&"noframes"!==r||!O(/<\/no(script|embed|frames)/i,e.innerHTML)?(Me&&e.nodeType===ae&&(t=e.textContent,_([fe,me,ye],(e=>{t=E(t,e," ")})),e.textContent!==t&&(C(n.removed,{element:e.cloneNode()}),e.textContent=t)),Tt(pe.afterSanitizeElements,e,null),!1):(xt(e),!0)},Nt=function(e,t,n){if(We&&("id"===t||"name"===t)&&(n in r||n in ft))return!1;if(Re&&!Le[t]&&O(be,t));else if(Fe&&O(_e,t));else if(Oe.attributeCheck instanceof Function&&Oe.attributeCheck(t,e));else if(!Te[t]||Le[t]){if(!(At(e)&&(Ne.tagNameCheck instanceof RegExp&&O(Ne.tagNameCheck,e)||Ne.tagNameCheck instanceof Function&&Ne.tagNameCheck(e))&&(Ne.attributeNameCheck instanceof RegExp&&O(Ne.attributeNameCheck,t)||Ne.attributeNameCheck instanceof Function&&Ne.attributeNameCheck(t,e))||"is"===t&&Ne.allowCustomizedBuiltInElements&&(Ne.tagNameCheck instanceof RegExp&&O(Ne.tagNameCheck,n)||Ne.tagNameCheck instanceof Function&&Ne.tagNameCheck(n))))return!1}else if(Qe[t]);else if(O(ve,E(n,Se,"")));else if("src"!==t&&"xlink:href"!==t&&"href"!==t||"script"===e||0!==N(n,"data:")||!Ye[e]){if(Ie&&!O(xe,E(n,Se,"")));else if(n)return!1}else;return!0},At=function(e){return"annotation-xml"!==e&&T(e,Ce)},Lt=function(e){Tt(pe.beforeSanitizeAttributes,e,null);const{attributes:t}=e;if(!t||wt(e))return;const r={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:Te,forceKeepAttr:void 0};let i=t.length;for(;i--;){const o=t[i],{name:s,namespaceURI:l,value:a}=o,c=gt(s),u=a;let d="value"===s?u:A(u);if(r.attrName=c,r.attrValue=d,r.keepAttr=!0,r.forceKeepAttr=void 0,Tt(pe.uponSanitizeAttribute,e,r),d=r.attrValue,!Ve||"id"!==c&&"name"!==c||(St(s,e),d="user-content-"+d),De&&O(/((--!?|])>)|<\/(style|title|textarea)/i,d)){St(s,e);continue}if("attributename"===c&&T(d,"href")){St(s,e);continue}if(r.forceKeepAttr)continue;if(!r.keepAttr){St(s,e);continue}if(!Pe&&O(/\/>/i,d)){St(s,e);continue}Me&&_([fe,me,ye],(e=>{d=E(d,e," ")}));const h=gt(e.nodeName);if(Nt(h,c,d)){if(X&&"object"==typeof y&&"function"==typeof y.getAttributeType)if(l);else switch(y.getAttributeType(h,c)){case"TrustedHTML":d=X.createHTML(d);break;case"TrustedScriptURL":d=X.createScriptURL(d)}if(d!==u)try{l?e.setAttributeNS(l,s,d):e.setAttribute(s,d),wt(e)?xt(e):S(n.removed)}catch(t){St(s,e)}}else St(s,e)}Tt(pe.afterSanitizeAttributes,e,null)},Ot=function e(t){let n=null;const r=vt(t);for(Tt(pe.beforeSanitizeShadowDOM,t,null);n=r.nextNode();)Tt(pe.uponSanitizeShadowNode,n,null),Et(n),Lt(n),n.content instanceof s&&e(n.content);Tt(pe.afterSanitizeShadowDOM,t,null)};return n.sanitize=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=null,o=null,l=null,c=null;if(ot=!e,ot&&(e="\x3c!--\x3e"),"string"!=typeof e&&!kt(e)){if("function"!=typeof e.toString)throw F("toString is not a function");if("string"!=typeof(e=e.toString()))throw F("dirty is not a string, aborting")}if(!n.isSupported)return e;if(ze||yt(t),n.removed=[],"string"==typeof e&&(je=!1),je){if(e.nodeName){const t=gt(e.nodeName);if(!we[t]||Ae[t])throw F("root node is forbidden and cannot be sanitized in-place")}}else if(e instanceof a)r=Ct("\x3c!----\x3e"),o=r.ownerDocument.importNode(e,!0),o.nodeType===le&&"BODY"===o.nodeName||"HTML"===o.nodeName?r=o:r.appendChild(o);else{if(!He&&!Me&&!Be&&-1===e.indexOf("<"))return X&&Ue?X.createHTML(e):e;if(r=Ct(e),!r)return He?null:Ue?Q:""}r&&$e&&xt(r.firstChild);const u=vt(je?e:r);for(;l=u.nextNode();)Et(l),Lt(l),l.content instanceof s&&Ot(l.content);if(je)return e;if(He){if(Ke)for(c=re.call(r.ownerDocument);r.firstChild;)c.appendChild(r.firstChild);else c=r;return(Te.shadowroot||Te.shadowrootmode)&&(c=ge.call(i,c,!0)),c}let d=Be?r.outerHTML:r.innerHTML;return Be&&we["!doctype"]&&r.ownerDocument&&r.ownerDocument.doctype&&r.ownerDocument.doctype.name&&O(ie,r.ownerDocument.doctype.name)&&(d="\n"+d),Me&&_([fe,me,ye],(e=>{d=E(d,e," ")})),X&&Ue?X.createHTML(d):d},n.setConfig=function(){yt(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),ze=!0},n.clearConfig=function(){pt=null,ze=!1},n.isValidAttribute=function(e,t,n){pt||yt({});const r=gt(e),i=gt(t);return Nt(r,i,n)},n.addHook=function(e,t){"function"==typeof t&&C(pe[e],t)},n.removeHook=function(e,t){if(void 0!==t){const n=x(pe[e],t);return-1===n?void 0:v(pe[e],n,1)[0]}return S(pe[e])},n.removeHooks=function(e){pe[e]=[]},n.removeAllHooks=function(){pe={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},n}();function pe(e,...t){const n=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",e);for(const e of t)r.append("v",e);throw n.search=r.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function fe(e,...t){const n=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",e);for(const e of t)r.append("v",e);n.search=r.toString(),console.warn(`Minified Lexical warning #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}const me="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,ye=me&&"documentMode"in document?document.documentMode:null,be=me&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),_e=me&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),xe=!(!me||!("InputEvent"in window)||ye)&&"getTargetRanges"in new window.InputEvent("input"),Se=me&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),Ce=me&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,ve=me&&/Android/.test(navigator.userAgent),we=me&&/^(?=.*Chrome).*/i.test(navigator.userAgent),ke=me&&ve&&we,Te=me&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&be&&!we;function Ee(...e){const t=[];for(const n of e)if(n&&"string"==typeof n)for(const[e]of n.matchAll(/\S+/g))t.push(e);return t}const Ne=0,Ae=1,Le=2,Oe=1,Fe=2,Re=3,Ie=4,Pe=5,Me=6,De=Se||Ce||Te?" ":"​",Be="\n\n",ze=_e?" ":De,$e="֑-߿יִ-﷽ﹰ-ﻼ",He="A-Za-zÀ-ÖØ-öø-ʸ̀-֐ࠀ-῿‎Ⰰ-﬜︀-﹯﻽-￿",Ke=new RegExp("^[^"+He+"]*["+$e+"]"),Ue=new RegExp("^[^"+$e+"]*["+He+"]"),We={bold:1,capitalize:1024,code:16,highlight:128,italic:2,lowercase:256,strikethrough:4,subscript:32,superscript:64,underline:8,uppercase:512},Ve={directionless:1,unmergeable:2},qe={center:2,end:6,justify:4,left:1,right:3,start:5},je={[Fe]:"center",[Me]:"end",[Ie]:"justify",[Oe]:"left",[Re]:"right",[Pe]:"start"},Ze={normal:0,segmented:2,token:1},Ge={[Ne]:"normal",[Le]:"segmented",[Ae]:"token"},Je="$config";function Ye(e,t,n,r,i,o){let s=e.getFirstChild();for(;null!==s;){const e=s.__key;s.__parent===t&&(po(s)&&Ye(s,e,n,r,i,o),n.has(e)||o.delete(e),i.push(e)),s=s.getNextSibling()}}let Xe=!1,Qe=0;function et(e){Qe=e.timeStamp}function tt(e,t,n){const r="BR"===e.nodeName,i=t.__lexicalLineBreak;return i&&(e===i||r&&e.previousSibling===i)||r&&void 0!==ss(e,n)}function nt(e,t,n){const r=Zs($s(n));let i=null,o=null;null!==r&&r.anchorNode===e&&(i=r.anchorOffset,o=r.focusOffset);const s=e.nodeValue;null!==s&&_s(t,s,i,o,!1)}function rt(e,t,n){if(gi(e)){const t=e.anchor.getNode();if(t.is(n)&&e.format!==t.getFormat())return!1}return Zo(t)&&n.isAttached()}function it(e,t,n,r){for(let i=e;i&&!al(i);i=Ps(i)){const e=ss(i,t);if(void 0!==e){const t=is(e,n);if(t)return yo(t)||!Js(i)?void 0:[i,t]}else if(i===r)return[r,ds(n)]}}function ot(e,t,n){Xe=!0;const r=performance.now()-Qe>100;try{co(e,(()=>{const i=Li()||function(e){return e.getEditorState().read((()=>{const e=Li();return null!==e?e.clone():null}))}(e),o=new Map,s=e.getRootElement(),l=e._editorState,a=e._blockCursorElement;let c=!1,u="";for(let n=0;n0){let t=0;for(let i=0;i0)for(const[t,n]of o)n.reconcileObservedMutation(t,e);const d=n.takeRecords();if(d.length>0){for(let t=0;t{ot(e,t,n)}))}let at=class{key;parse;unparse;isEqual;defaultValue;constructor(e,t){this.key=e,this.parse=t.parse.bind(t),this.unparse=(t.unparse||mt).bind(t),this.isEqual=(t.isEqual||Object.is).bind(t),this.defaultValue=this.parse(void 0)}};function ct(e,t,n="latest"){const r=("latest"===n?e.getLatest():e).__state;return r?r.getValue(t):t.defaultValue}function ut(e,t,n){let r;if(Zi(),"function"==typeof n){const i=e.getLatest(),o=ct(i,t);if(r=n(o),t.isEqual(o,r))return i}else r=n;const i=e.getWritable();return gt(i).updateFromKnown(t,r),i}function dt(e){const t=new Map,n=new Set;for(let r="function"==typeof e?e:e.replace;r.prototype&&void 0!==r.prototype.getType;r=Object.getPrototypeOf(r)){const{ownNodeConfig:e}=ul(r);if(e&&e.stateConfigs)for(const r of e.stateConfigs){let e;"stateConfig"in r?(e=r.stateConfig,r.flat&&n.add(e.key)):e=r,t.set(e.key,e)}}return{flatKeys:n,sharedConfigMap:t}}let ht=class e{node;knownState;unknownState;sharedNodeState;size;constructor(e,t,n=void 0,r=new Map,i=void 0){this.node=e,this.sharedNodeState=t,this.unknownState=n,this.knownState=r;const{sharedConfigMap:o}=this.sharedNodeState,s=void 0!==i?i:function(e,t,n){let r=n.size;if(t)for(const i in t){const t=e.get(i);t&&n.has(t)||r++}return r}(o,n,r);this.size=s}getValue(e){const t=this.knownState.get(e);if(void 0!==t)return t;this.sharedNodeState.sharedConfigMap.set(e.key,e);let n=e.defaultValue;if(this.unknownState&&e.key in this.unknownState){const t=this.unknownState[e.key];void 0!==t&&(n=e.parse(t)),this.updateFromKnown(e,n)}return n}getInternalState(){return[this.unknownState,this.knownState]}toJSON(){const e={...this.unknownState},t={};for(const[t,n]of this.knownState)t.isEqual(n,t.defaultValue)?delete e[t.key]:e[t.key]=t.unparse(n);for(const n of this.sharedNodeState.flatKeys)n in e&&(t[n]=e[n],delete e[n]);return ft(e)&&(t.$=e),t}getWritable(t){if(this.node===t)return this;const{sharedNodeState:n,unknownState:r}=this,i=new Map(this.knownState);return new e(t,n,function(e,t,n){let r;if(n)for(const[i,o]of Object.entries(n)){const n=e.get(i);n?t.has(n)||t.set(n,n.parse(o)):(r=r||{},r[i]=o)}return r}(n.sharedConfigMap,i,r),i,this.size)}updateFromKnown(e,t){const n=e.key;this.sharedNodeState.sharedConfigMap.set(n,e);const{knownState:r,unknownState:i}=this;r.has(e)||i&&n in i||(i&&(delete i[n],this.unknownState=ft(i)),this.size++),r.set(e,t)}updateFromUnknown(e,t){const n=this.sharedNodeState.sharedConfigMap.get(e);n?this.updateFromKnown(n,n.parse(t)):(this.unknownState=this.unknownState||{},e in this.unknownState||this.size++,this.unknownState[e]=t)}updateFromJSON(e){const{knownState:t}=this;for(const e of t.keys())t.set(e,e.defaultValue);if(this.size=t.size,this.unknownState=void 0,e)for(const[t,n]of Object.entries(e))this.updateFromUnknown(t,n)}};function gt(e){const t=e.getWritable(),n=t.__state?t.__state.getWritable(t):new ht(t,pt(t));return t.__state=n,n}function pt(e){return e.__state?e.__state.sharedNodeState:Mo(nl(),e.getType()).sharedNodeState}function ft(e){if(e)for(const t in e)return e}function mt(e){return e}function yt(e,t,n){for(const[r,i]of t.knownState){if(e.has(r.key))continue;e.add(r.key);const t=n?n.getValue(r):r.defaultValue;if(t!==i&&!r.isEqual(t,i))return!0}return!1}function bt(e,t,n){const{unknownState:r}=t,i=n?n.unknownState:void 0;if(r)for(const[t,n]of Object.entries(r))if(!e.has(t)&&(e.add(t),n!==(i?i[t]:void 0)))return!0;return!1}function _t(e,t){const n=e.__state;return n&&n.node===e?n.getWritable(t):n}function xt(e,t){const n=e.__mode,r=e.__format,i=e.__style,o=t.__mode,s=t.__format,l=t.__style,a=e.__state,c=t.__state;return(null===n||n===o)&&(null===r||r===s)&&(null===i||i===l)&&(null===e.__state||a===c||function(e,t){if(e===t)return!0;if(e&&t&&e.size!==t.size)return!1;const n=new Set;return!(e&&yt(n,e,t)||t&&yt(n,t,e)||e&&bt(n,e,t)||t&&bt(n,t,e))}(a,c))}function St(e,t){const n=e.mergeWithSibling(t),r=Yi()._normalizedNodes;return r.add(e.__key),r.add(t.__key),n}function Ct(e){let t,n,r=e;if(""!==r.__text||!r.isSimpleText()||r.isUnmergeable()){for(;null!==(t=r.getPreviousSibling())&&ri(t)&&t.isSimpleText()&&!t.isUnmergeable();){if(""!==t.__text){if(xt(t,r)){r=St(t,r);break}break}t.remove()}for(;null!==(n=r.getNextSibling())&&ri(n)&&n.isSimpleText()&&!n.isUnmergeable();){if(""!==n.__text){if(xt(r,n)){r=St(r,n);break}break}n.remove()}}else r.remove()}function vt(e){return wt(e.anchor),wt(e.focus),e}function wt(e){for(;"element"===e.type;){const t=e.getNode(),n=e.offset;let r,i;if(n===t.getChildrenSize()?(r=t.getChildAtIndex(n-1),i=!0):(r=t.getChildAtIndex(n),i=!1),ri(r)){e.set(r.__key,i?r.getTextContentSize():0,"text",!0);break}if(!po(r))break;e.set(r.__key,i?r.getChildrenSize():0,"element",!0)}}let kt,Tt,Et,Nt,At,Lt,Ot,Ft,Rt,It,Pt="",Mt=null,Dt="",Bt="",zt=!1,$t=!1;function Ht(e,t){const n=Ot.get(e);if(null!==t){const n=rn(e);n.parentNode===t&&t.removeChild(n)}if(Ft.has(e)||Tt._keyToDOMMap.delete(e),po(n)){const e=Qt(n,Ot);Kt(e,0,e.length-1,null)}void 0!==n&&Ns(It,Et,Nt,n,"destroyed")}function Kt(e,t,n,r){let i=t;for(;i<=n;++i){const t=e[i];void 0!==t&&Ht(t,r)}}function Ut(e,t){e.setProperty("text-align",t)}const Wt="40px";function Vt(e,t){const n=kt.theme.indent;if("string"==typeof n){const r=e.classList.contains(n);t>0&&!r?e.classList.add(n):t<1&&r&&e.classList.remove(n)}const r=getComputedStyle(e).getPropertyValue("--lexical-indent-base-value")||Wt;e.style.setProperty("padding-inline-start",0===t?"":`calc(${t} * ${r})`)}function qt(e,t){const n=e.style;0===t?Ut(n,""):1===t?Ut(n,"left"):2===t?Ut(n,"center"):3===t?Ut(n,"right"):4===t?Ut(n,"justify"):5===t?Ut(n,"start"):6===t&&Ut(n,"end")}function jt(e,t){const n=function(e){const t=e.__dir;if(null!==t)return t;if(_o(e))return null;const n=e.getParentOrThrow();return _o(n)&&null===n.__dir?"auto":null}(t);null!==n?e.dir=n:e.removeAttribute("dir")}function Zt(e,t){const n=Ft.get(e);void 0===n&&pe(60);const r=n.createDOM(kt,Tt);if(function(e,t,n){const r=n._keyToDOMMap;(function(e,t,n){e[`__lexicalKey_${t._key}`]=n})(t,n,e),r.set(e,t)}(e,r,Tt),ri(n)?r.setAttribute("data-lexical-text","true"):yo(n)&&r.setAttribute("data-lexical-decorator","true"),po(n)){const e=n.__indent,t=n.__size;if(jt(r,n),0!==e&&Vt(r,e),0!==t){const e=t-1;Gt(Qt(n,Ft),n,0,e,n.getDOMSlot(r))}const i=n.__format;0!==i&&qt(r,i),n.isInline()||Yt(null,n,r),Rs(n)&&(Pt+=Be,Bt+=Be)}else{const t=n.getTextContent();if(yo(n)){const t=n.decorate(Tt,kt);null!==t&&tn(e,t),r.contentEditable="false"}Pt+=t,Bt+=t}return null!==t&&t.insertChild(r),Ns(It,Et,Nt,n,"created"),r}function Gt(e,t,n,r,i){const o=Pt;Pt="";let s=n;for(;s<=r;++s){Zt(e[s],i);const t=Ft.get(e[s]);null!==t&&ri(t)&&(null===Mt&&(Mt=t.getFormat()),""===Dt&&(Dt=t.getStyle()))}Rs(t)&&(Pt+=Be),i.element.__lexicalTextContent=Pt,Pt=o+Pt}function Jt(e,t){if(e){const n=e.__last;if(n){const e=t.get(n);if(e)return zr(e)?"line-break":yo(e)&&e.isInline()?"decorator":null}return"empty"}return null}function Yt(e,t,n){const r=Jt(e,Ot),i=Jt(t,Ft);r!==i&&t.getDOMSlot(n).setManagedLineBreak(i)}function Xt(e,t,n){var r;Mt=null,Dt="",function(e,t,n){const r=Pt,i=e.__size,o=t.__size;Pt="";const s=n.element;if(1===i&&1===o){const n=e.__first,i=t.__first;if(n===i)en(n,s);else{const e=rn(n),t=Zt(i,null);try{s.replaceChild(t,e)}catch(r){if("object"==typeof r&&null!=r){const o=`${r.toString()} Parent: ${s.tagName}, new child: {tag: ${t.tagName} key: ${i}}, old child: {tag: ${e.tagName}, key: ${n}}.`;throw new Error(o)}throw r}Ht(n,null)}const o=Ft.get(i);ri(o)&&(null===Mt&&(Mt=o.getFormat()),""===Dt&&(Dt=o.getStyle()))}else{const r=Qt(e,Ot),l=Qt(t,Ft);if(r.length!==i&&pe(227),l.length!==o&&pe(228),0===i)0!==o&&Gt(l,t,0,o-1,n);else if(0===o){if(0!==i){const e=null==n.after&&null==n.before&&null==n.element.__lexicalLineBreak;Kt(r,0,i-1,e?null:s),e&&(s.textContent="")}}else!function(e,t,n,r,i,o){const s=r-1,l=i-1;let a,c,u=o.getFirstChild(),d=0,h=0;for(;d<=s&&h<=l;){const e=t[d],r=n[h];if(e===r)u=nn(en(r,o.element)),d++,h++;else{void 0===a&&(a=new Set(t)),void 0===c&&(c=new Set(n));const i=c.has(e),s=a.has(r);if(i)if(s){const e=Is(Tt,r);e===u?u=nn(en(r,o.element)):(o.withBefore(u).insertChild(e),en(r,o.element)),d++,h++}else Zt(r,o.withBefore(u)),h++;else u=nn(rn(e)),Ht(e,o.element),d++}const i=Ft.get(r);null!==i&&ri(i)&&(null===Mt&&(Mt=i.getFormat()),""===Dt&&(Dt=i.getStyle()))}const g=d>s,p=h>l;if(g&&!p){const t=n[l+1],r=void 0===t?null:Tt.getElementByKey(t);Gt(n,e,h,l,o.withBefore(r))}else p&&!g&&Kt(t,d,s,o.element)}(t,r,l,i,o,n)}Rs(t)&&(Pt+=Be),s.__lexicalTextContent=Pt,Pt=r+Pt}(e,t,t.getDOMSlot(n)),r=t,null==Mt||Mt===r.__textFormat||$t||r.setTextFormat(Mt),function(e){""===Dt||Dt===e.__textStyle||$t||e.setTextStyle(Dt)}(t)}function Qt(e,t){const n=[];let r=e.__first;for(;null!==r;){const e=t.get(r);void 0===e&&pe(101),n.push(r),r=e.__next}return n}function en(e,t){const n=Ot.get(e);let r=Ft.get(e);void 0!==n&&void 0!==r||pe(61);const i=zt||Lt.has(e)||At.has(e),o=Is(Tt,e);if(n===r&&!i){if(po(n)){const e=o.__lexicalTextContent;void 0!==e&&(Pt+=e,Bt+=e)}else{const e=n.getTextContent();Bt+=e,Pt+=e}return o}if(n!==r&&i&&Ns(It,Et,Nt,r,"updated"),r.updateDOM(n,o,kt)){const n=Zt(e,null);return null===t&&pe(62),t.replaceChild(n,o),Ht(e,null),n}if(po(n)&&po(r)){const e=r.__indent;(zt||e!==n.__indent)&&Vt(o,e);const t=r.__format;if((zt||t!==n.__format)&&qt(o,t),i&&(Xt(n,r,o),_o(r)||r.isInline()||Yt(n,r,o)),Rs(r)&&(Pt+=Be,Bt+=Be),(zt||r.__dir!==n.__dir)&&(jt(o,r),_o(r)&&!zt))for(const e of r.getChildren())po(e)&&jt(Is(Tt,e.getKey()),e)}else{const t=r.getTextContent();if(yo(r)){const t=r.decorate(Tt,kt);null!==t&&tn(e,t)}Pt+=t,Bt+=t}if(!$t&&_o(r)&&r.__cachedText!==Bt){const e=r.getWritable();e.__cachedText=Bt,r=e}return o}function tn(e,t){let n=Tt._pendingDecorators;const r=Tt._decorators;if(null===n){if(r[e]===t)return;n=as(Tt)}n[e]=t}function nn(e){let t=e.nextSibling;return null!==t&&t===Tt._blockCursorElement&&(t=t.nextSibling),t}function rn(e){const t=Rt.get(e);return void 0===t&&pe(75,e),t}function on(e){return{type:e}}const sn=on("SELECTION_CHANGE_COMMAND"),ln=on("SELECTION_INSERT_CLIPBOARD_NODES_COMMAND"),an=on("CLICK_COMMAND"),cn=on("DELETE_CHARACTER_COMMAND"),un=on("INSERT_LINE_BREAK_COMMAND"),dn=on("INSERT_PARAGRAPH_COMMAND"),hn=on("CONTROLLED_TEXT_INSERTION_COMMAND"),gn=on("PASTE_COMMAND"),pn=on("REMOVE_TEXT_COMMAND"),fn=on("DELETE_WORD_COMMAND"),mn=on("DELETE_LINE_COMMAND"),yn=on("FORMAT_TEXT_COMMAND"),bn=on("UNDO_COMMAND"),_n=on("REDO_COMMAND"),xn=on("KEYDOWN_COMMAND"),Sn=on("KEY_ARROW_RIGHT_COMMAND"),Cn=on("MOVE_TO_END"),vn=on("KEY_ARROW_LEFT_COMMAND"),wn=on("MOVE_TO_START"),kn=on("KEY_ARROW_UP_COMMAND"),Tn=on("KEY_ARROW_DOWN_COMMAND"),En=on("KEY_ENTER_COMMAND"),Nn=on("KEY_SPACE_COMMAND"),An=on("KEY_BACKSPACE_COMMAND"),Ln=on("KEY_ESCAPE_COMMAND"),On=on("KEY_DELETE_COMMAND"),Fn=on("KEY_TAB_COMMAND"),Rn=on("INSERT_TAB_COMMAND"),In=on("INDENT_CONTENT_COMMAND"),Pn=on("OUTDENT_CONTENT_COMMAND"),Mn=on("DROP_COMMAND"),Dn=on("FORMAT_ELEMENT_COMMAND"),Bn=on("DRAGSTART_COMMAND"),zn=on("DRAGOVER_COMMAND"),$n=on("DRAGEND_COMMAND"),Hn=on("COPY_COMMAND"),Kn=on("CUT_COMMAND"),Un=on("SELECT_ALL_COMMAND"),Wn=on("CLEAR_EDITOR_COMMAND"),Vn=on("CLEAR_HISTORY_COMMAND"),qn=on("CAN_REDO_COMMAND"),jn=on("CAN_UNDO_COMMAND"),Zn=on("FOCUS_COMMAND"),Gn=on("BLUR_COMMAND"),Jn=on("KEY_MODIFIER_COMMAND"),Yn=Object.freeze({}),Xn=[["keydown",function(e,t){if(!(Qn=e.timeStamp,er=e.key,t.isComposing()||Fs(t,xn,e)||null==e.key)){if(cr&&ks(e))return co(t,(()=>{_r(t,ur)})),cr=!1,void(ur="");if(function(e){return Cs(e,"ArrowRight",{shiftKey:"any"})}(e))Fs(t,Sn,e);else if(function(e){return Cs(e,"ArrowRight",vs)}(e))Fs(t,Cn,e);else if(function(e){return Cs(e,"ArrowLeft",{shiftKey:"any"})}(e))Fs(t,vn,e);else if(function(e){return Cs(e,"ArrowLeft",vs)}(e))Fs(t,wn,e);else if(function(e){return Cs(e,"ArrowUp",{altKey:"any",shiftKey:"any"})}(e))Fs(t,kn,e);else if(function(e){return Cs(e,"ArrowDown",{altKey:"any",shiftKey:"any"})}(e))Fs(t,Tn,e);else if(function(e){return Cs(e,"Enter",{altKey:"any",ctrlKey:"any",metaKey:"any",shiftKey:!0})}(e))lr=!0,Fs(t,En,e);else if(function(e){return" "===e.key}(e))Fs(t,Nn,e);else if(function(e){return be&&Cs(e,"o",{ctrlKey:!0})}(e))e.preventDefault(),lr=!0,Fs(t,un,!0);else if(function(e){return Cs(e,"Enter",{altKey:"any",ctrlKey:"any",metaKey:"any"})}(e))lr=!1,Fs(t,En,e);else if(function(e){return Cs(e,"Backspace",{shiftKey:"any"})||be&&Cs(e,"h",{ctrlKey:!0})}(e))ks(e)?Fs(t,An,e):(e.preventDefault(),Fs(t,cn,!0));else if(function(e){return"Escape"===e.key}(e))Fs(t,Ln,e);else if(function(e){return Cs(e,"Delete",{})||be&&Cs(e,"d",{ctrlKey:!0})}(e))!function(e){return"Delete"===e.key}(e)?(e.preventDefault(),Fs(t,cn,!1)):Fs(t,On,e);else if(function(e){return Cs(e,"Backspace",ws)}(e))e.preventDefault(),Fs(t,fn,!0);else if(function(e){return Cs(e,"Delete",ws)}(e))e.preventDefault(),Fs(t,fn,!1);else if(function(e){return be&&Cs(e,"Backspace",{metaKey:!0})}(e))e.preventDefault(),Fs(t,mn,!0);else if(function(e){return be&&(Cs(e,"Delete",{metaKey:!0})||Cs(e,"k",{ctrlKey:!0}))}(e))e.preventDefault(),Fs(t,mn,!1);else if(function(e){return Cs(e,"b",vs)}(e))e.preventDefault(),Fs(t,yn,"bold");else if(function(e){return Cs(e,"u",vs)}(e))e.preventDefault(),Fs(t,yn,"underline");else if(function(e){return Cs(e,"i",vs)}(e))e.preventDefault(),Fs(t,yn,"italic");else if(function(e){return Cs(e,"Tab",{shiftKey:"any"})}(e))Fs(t,Fn,e);else if(function(e){return Cs(e,"z",vs)}(e))e.preventDefault(),Fs(t,bn,void 0);else if(function(e){return be?Cs(e,"z",{metaKey:!0,shiftKey:!0}):Cs(e,"y",{ctrlKey:!0})||Cs(e,"z",{ctrlKey:!0,shiftKey:!0})}(e))e.preventDefault(),Fs(t,_n,void 0);else{const n=t._editorState._selection;null===n||gi(n)?Ts(e)&&(e.preventDefault(),Fs(t,Un,e)):function(e){return Cs(e,"c",vs)}(e)?(e.preventDefault(),Fs(t,Hn,e)):function(e){return Cs(e,"x",vs)}(e)?(e.preventDefault(),Fs(t,Kn,e)):Ts(e)&&(e.preventDefault(),Fs(t,Un,e))}(function(e){return e.ctrlKey||e.shiftKey||e.altKey||e.metaKey})(e)&&Fs(t,Jn,e)}}],["pointerdown",function(e,t){const n=e.target,r=e.pointerType;Ys(n)&&"touch"!==r&&"pen"!==r&&0===e.button&&co(t,(()=>{zo(n)||(sr=!0)}))}],["compositionstart",function(e,t){co(t,(()=>{const n=Li();if(gi(n)&&!t.isComposing()){const r=n.anchor,i=n.anchor.getNode();ns(r.key),(e.timeStamp{_r(t,e.data)})):(cr=!0,ur=e.data)}],["input",function(e,t){e.stopPropagation(),co(t,(()=>{if(Js(e.target)&&zo(e.target))return;const n=Li(),r=e.data,i=br(e);if(null!=r&&gi(n)&&gr(n,i,r,e.timeStamp,!1)){ar&&(_r(t,r),ar=!1);const i=n.anchor.getNode(),o=Zs($s(t));if(null===o)return;const s=n.isBackward(),l=s?n.anchor.offset:n.focus.offset,a=s?n.focus.offset:n.anchor.offset;xe&&!n.isCollapsed()&&ri(i)&&null!==o.anchorNode&&i.getTextContent().slice(0,l)+r+i.getTextContent().slice(l+a)===ys(o.anchorNode)||Fs(t,hn,r);const c=r.length;_e&&c>1&&"insertCompositionText"===e.inputType&&!t.isComposing()&&(n.anchor.offset-=c),Se||Ce||Te||!t.isComposing()||(Qn=0,ns(null))}else bs(!1,t,null!==r?r:void 0),ar&&(_r(t,r||void 0),ar=!1);!function(){Zi();st(Yi())}()}),{event:e}),nr=null}],["click",function(e,t){co(t,(()=>{const n=Li(),r=Zs($s(t)),i=Oi();if(r)if(gi(n)){const t=n.anchor,o=t.getNode();if("element"===t.type&&0===t.offset&&n.isCollapsed()&&!_o(o)&&1===us().getChildrenSize()&&o.getTopLevelElementOrThrow().isEmpty()&&null!==i&&n.is(i))r.removeAllRanges(),n.dirty=!0;else if(3===e.detail&&!n.isCollapsed()&&o!==n.focus.getNode()){const e=dl(o,(e=>po(e)&&!e.isInline()));po(e)&&e.select(0)}}else if("touch"===e.pointerType||"pen"===e.pointerType){const n=r.anchorNode;(Js(n)||Zo(n))&&hs(Ai(i,r,t,e))}Fs(t,an,e)}))}],["cut",Yn],["copy",Yn],["dragstart",Yn],["dragover",Yn],["dragend",Yn],["paste",Yn],["focus",Yn],["blur",Yn],["drop",Yn]];xe&&Xn.push(["beforeinput",(e,t)=>function(e,t){const n=e.inputType,r=br(e);"deleteCompositionText"===n||_e&&Os(t)||"insertCompositionText"!==n&&co(t,(()=>{const i=Li();if("deleteContentBackward"===n){if(null===i){const e=Oi();if(!gi(e))return;hs(e.clone())}if(gi(i)){const n=i.anchor.key===i.focus.key;if(o=e.timeStamp,"MediaLast"===er&&o{co(t,(()=>{ns(null)}))}),30),gi(i)){const e=i.anchor.getNode();e.markDirty(),ri(e)||pe(142),yr(i,e)}}else{ns(null),e.preventDefault();const r=i.anchor.getNode(),o=r.getTextContent(),s=r.canInsertTextAfter(),l=0===i.anchor.offset&&i.focus.offset===o.length;let a=ke&&n&&!l&&s;if(a&&i.isCollapsed()&&(a=!yo(Ls(i.anchor,!0))),!a){Fs(t,cn,!0);const e=Li();ke&&gi(e)&&e.isCollapsed()&&(dr=e,setTimeout((()=>dr=null)))}}return}}var o;if(!gi(i))return;const s=e.data;null!==nr&&bs(!1,t,nr),i.dirty&&null===nr||!i.isCollapsed()||_o(i.anchor.getNode())||null===r||i.applyDOMRange(r),nr=null;const l=i.anchor,a=i.focus,c=l.getNode(),u=a.getNode();if("insertText"!==n&&"insertTranspose"!==n)switch(e.preventDefault(),n){case"insertFromYank":case"insertFromDrop":case"insertReplacementText":Fs(t,hn,e);break;case"insertFromComposition":ns(null),Fs(t,hn,e);break;case"insertLineBreak":ns(null),Fs(t,un,!1);break;case"insertParagraph":ns(null),lr&&!Ce?(lr=!1,Fs(t,un,!1)):Fs(t,dn,void 0);break;case"insertFromPaste":case"insertFromPasteAsQuotation":Fs(t,gn,e);break;case"deleteByComposition":(function(e,t){return e!==t||po(e)||po(t)||!qo(e)||!qo(t)})(c,u)&&Fs(t,pn,e);break;case"deleteByDrag":case"deleteByCut":Fs(t,pn,e);break;case"deleteContent":Fs(t,cn,!1);break;case"deleteWordBackward":Fs(t,fn,!0);break;case"deleteWordForward":Fs(t,fn,!1);break;case"deleteHardLineBackward":case"deleteSoftLineBackward":Fs(t,mn,!0);break;case"deleteContentForward":case"deleteHardLineForward":case"deleteSoftLineForward":Fs(t,mn,!1);break;case"formatStrikeThrough":Fs(t,yn,"strikethrough");break;case"formatBold":Fs(t,yn,"bold");break;case"formatItalic":Fs(t,yn,"italic");break;case"formatUnderline":Fs(t,yn,"underline");break;case"historyUndo":Fs(t,bn,void 0);break;case"historyRedo":Fs(t,_n,void 0)}else{if("\n"===s)e.preventDefault(),Fs(t,un,!1);else if(s===Be)e.preventDefault(),Fs(t,dn,void 0);else if(null==s&&e.dataTransfer){const t=e.dataTransfer.getData("text/plain");e.preventDefault(),i.insertRawText(t)}else null!=s&&gr(i,r,s,e.timeStamp,!0)?(e.preventDefault(),Fs(t,hn,s)):nr=s;tr=e.timeStamp}}))}(e,t)]);let Qn=0,er=null,tr=0,nr=null;const rr=new WeakMap,ir=new WeakMap;let or=!1,sr=!1,lr=!1,ar=!1,cr=!1,ur="",dr=null,hr=[0,"",0,"root",0];function gr(e,t,n,r,i){const o=e.anchor,s=e.focus,l=o.getNode(),a=Yi(),c=Zs($s(a)),u=null!==c?c.anchorNode:null,d=o.key,h=a.getElementByKey(d),g=n.length;return d!==s.key||!ri(l)||(!i&&(!xe||tr1||(i||!xe)&&null!==h&&!l.isComposing()&&u!==Jo(h)||null!==c&&null!==t&&(!t.collapsed||t.startContainer!==c.anchorNode||t.startOffset!==c.anchorOffset)||l.getFormat()!==e.format||l.getStyle()!==e.style||function(e,t){if(t.isSegmented())return!0;if(!e.isCollapsed())return!1;const n=e.anchor.offset,r=t.getParentOrThrow(),i=qo(t);return 0===n?!t.canInsertTextBefore()||!r.canInsertTextBefore()&&!t.isComposing()||i||function(e){const t=e.getPreviousSibling();return(ri(t)||po(t)&&t.isInline())&&!t.canInsertTextAfter()}(t):n===t.getTextContentSize()&&(!t.canInsertTextAfter()||!r.canInsertTextAfter()&&!t.isComposing()||i)}(e,l)}function pr(e,t){return Zo(e)&&null!==e.nodeValue&&0!==t&&t!==e.nodeValue.length}function fr(e,t,n){const{anchorNode:r,anchorOffset:i,focusNode:o,focusOffset:s}=e;or&&(or=!1,pr(r,i)&&pr(o,s)&&!dr)||co(t,(()=>{if(!n)return void hs(null);if(!Ho(t,r,o))return;let l=Li();if(dr&&gi(l)&&l.isCollapsed()){const e=l.anchor,t=dr.anchor;(e.key===t.key&&e.offset===t.offset+1||1===e.offset&&t.getNode().is(e.getNode().getPreviousSibling()))&&(l=dr.clone(),hs(l))}if(dr=null,gi(l)){const n=l.anchor,r=n.getNode();if(l.isCollapsed()){"Range"===e.type&&e.anchorNode===e.focusNode&&(l.dirty=!0);const i=$s(t).event,o=i?i.timeStamp:performance.now(),[s,a,c,u,d]=hr,h=us(),g=!1===t.isComposing()&&""===h.getTextContent();if(o{const r=Oi(),i=t.anchorNode;(Js(i)||Zo(i))&&hs(Ai(r,t,n,e))})));const r=fs(n),i=r[r.length-1],o=i._key,s=Sr.get(o),l=s||i;l!==n&&fr(t,l,!1),fr(t,n,!0),n!==i?Sr.set(o,n):s&&Sr.delete(o)}function vr(e){e._lexicalHandled=!0}function wr(e){return!0===e._lexicalHandled}function kr(e){const t=rr.get(e);if(void 0===t)return;const n=ir.get(t);if(void 0===n)return;const r=n-1;r>=0||pe(164),rr.delete(e),ir.set(t,r),0===r&&t.removeEventListener("selectionchange",Cr);const i=Wo(e);Ko(i)?(function(e){if(null!==e._parentEditor){const t=fs(e),n=t[t.length-1]._key;Sr.get(n)===e&&Sr.delete(n)}else Sr.delete(e._key)}(i),e.__lexicalEditor=null):i&&pe(198);const o=xr(e);for(let e=0;ee.__key===this.__key));if(ri(this))return n;if(gi(t)&&"element"===t.anchor.type&&"element"===t.focus.type){if(t.isCollapsed())return!1;const e=this.getParent();if(yo(this)&&this.isInline()&&e){const n=t.isBackward()?t.focus:t.anchor;if(e.is(n.getNode())&&n.offset===e.getChildrenSize()&&this.is(e.getLastChild()))return!1}}return n}getKey(){return this.__key}getIndexWithinParent(){const e=this.getParent();if(null===e)return-1;let t=e.getFirstChild(),n=0;for(;null!==t;){if(this.is(t))return n;n++,t=t.getNextSibling()}return-1}getParent(){const e=this.getLatest().__parent;return null===e?null:is(e)}getParentOrThrow(){const e=this.getParent();return null===e&&pe(66,this.__key),e}getTopLevelElement(){let e=this;for(;null!==e;){const t=e.getParent();if(Ks(t))return po(e)||e===this&&yo(e)||pe(194),e;e=t}return null}getTopLevelElementOrThrow(){const e=this.getTopLevelElement();return null===e&&pe(67,this.__key),e}getParents(){const e=[];let t=this.getParent();for(;null!==t;)e.push(t),t=t.getParent();return e}getParentKeys(){const e=[];let t=this.getParent();for(;null!==t;)e.push(t.__key),t=t.getParent();return e}getPreviousSibling(){const e=this.getLatest().__prev;return null===e?null:is(e)}getPreviousSiblings(){const e=[],t=this.getParent();if(null===t)return e;let n=t.getFirstChild();for(;null!==n&&!n.is(this);)e.push(n),n=n.getNextSibling();return e}getNextSibling(){const e=this.getLatest().__next;return null===e?null:is(e)}getNextSiblings(){const e=[];let t=this.getNextSibling();for(;null!==t;)e.push(t),t=t.getNextSibling();return e}getCommonAncestor(e){const t=po(this)?this:this.getParent(),n=po(e)?e:e.getParent(),r=t&&n?Kl(t,n):null;return r?r.commonAncestor:null}is(e){return null!=e&&this.__key===e.__key}isBefore(e){const t=Kl(this,e);return null!==t&&("descendant"===t.type||("branch"===t.type?-1===zl(t):("same"!==t.type&&"ancestor"!==t.type&&pe(279),!1)))}isParentOf(e){const t=Kl(this,e);return null!==t&&"ancestor"===t.type}getNodesBetween(e){const t=this.isBefore(e),n=[],r=new Set;let i=this;for(;null!==i;){const o=i.__key;if(r.has(o)||(r.add(o),n.push(i)),i===e)break;const s=po(i)?t?i.getFirstChild():i.getLastChild():null;if(null!==s){i=s;continue}const l=t?i.getNextSibling():i.getPreviousSibling();if(null!==l){i=l;continue}const a=i.getParentOrThrow();if(r.has(a.__key)||n.push(a),a===e)break;let c=null,u=a;do{if(null===u&&pe(68),c=t?u.getNextSibling():u.getPreviousSibling(),u=u.getParent(),null===u)break;null!==c||r.has(u.__key)||n.push(u)}while(null===c);i=c}return t||n.reverse(),n}isDirty(){const e=Yi()._dirtyLeaves;return null!==e&&e.has(this.__key)}getLatest(){if(Nr(this))return this;const e=is(this.__key);return null===e&&pe(113),e}getWritable(){if(Nr(this))return this;Zi();const e=Ji(),t=Yi(),n=e._nodeMap,r=this.__key,i=this.getLatest(),o=t._cloneNotNeeded,s=Li();if(null!==s&&s.setCachedNodes(null),o.has(r))return ts(i),i;const l=sl(i);return o.add(r),ts(l),n.set(r,l),l}getTextContent(){return""}getTextContentSize(){return this.getTextContent().length}createDOM(e,t){pe(70)}updateDOM(e,t,n){pe(71)}exportDOM(e){return{element:this.createDOM(e._config,e)}}exportJSON(){const e=this.__state?this.__state.toJSON():void 0;return{type:this.__type,version:1,...e}}static importJSON(e){pe(18,this.name)}updateFromJSON(e){return function(e,t){const n=e.getWritable(),r=t.$;let i=r;for(const e of pt(n).flatKeys)e in t&&(void 0!==i&&i!==r||(i={...r}),i[e]=t[e]);return(n.__state||i)&>(e).updateFromJSON(i),n}(this,e)}static transform(){return null}remove(e){Tr(this,!0,e)}replace(e,t){Zi();let n=Li();null!==n&&(n=n.clone()),Vs(this,e);const r=this.getLatest(),i=this.__key,o=e.__key,s=e.getWritable(),l=this.getParentOrThrow().getWritable(),a=l.__size;es(s);const c=r.getPreviousSibling(),u=r.getNextSibling(),d=r.__prev,h=r.__next,g=r.__parent;if(Tr(r,!1,!0),null===c?l.__first=o:c.getWritable().__next=o,s.__prev=d,null===u?l.__last=o:u.getWritable().__prev=o,s.__next=h,s.__parent=g,l.__size=a,t&&(po(this)&&po(s)||pe(139),this.getChildren().forEach((e=>{s.append(e)}))),gi(n)){hs(n);const e=n.anchor,t=n.focus;e.key===i&&di(e,s),t.key===i&&di(t,s)}return rs()===i&&ns(o),s}insertAfter(e,t=!0){Zi(),Vs(this,e);const n=this.getWritable(),r=e.getWritable(),i=r.getParent(),o=Li();let s=!1,l=!1;if(null!==i){const t=e.getIndexWithinParent();if(es(r),gi(o)){const e=i.__key,n=o.anchor,r=o.focus;s="element"===n.type&&n.key===e&&n.offset===t+1,l="element"===r.type&&r.key===e&&r.offset===t+1}}const a=this.getNextSibling(),c=this.getParentOrThrow().getWritable(),u=r.__key,d=n.__next;if(null===a?c.__last=u:a.getWritable().__prev=u,c.__size++,n.__next=u,r.__next=d,r.__prev=n.__key,r.__parent=n.__parent,t&&gi(o)){const e=this.getIndexWithinParent();Fi(o,c,e+1);const t=c.__key;s&&o.anchor.set(t,e+2,"element"),l&&o.focus.set(t,e+2,"element")}return e}insertBefore(e,t=!0){Zi(),Vs(this,e);const n=this.getWritable(),r=e.getWritable(),i=r.__key;es(r);const o=this.getPreviousSibling(),s=this.getParentOrThrow().getWritable(),l=n.__prev,a=this.getIndexWithinParent();null===o?s.__first=i:o.getWritable().__next=i,s.__size++,n.__prev=i,r.__prev=l,r.__next=n.__key,r.__parent=n.__parent;const c=Li();return t&&gi(c)&&Fi(c,this.getParentOrThrow(),a),e}isParentRequired(){return!1}createParentElementNode(){return Eo()}selectStart(){return this.selectPrevious()}selectEnd(){return this.selectNext(0,0)}selectPrevious(e,t){Zi();const n=this.getPreviousSibling(),r=this.getParentOrThrow();if(null===n)return r.select(0,0);if(po(n))return n.select();if(!ri(n)){const e=n.getIndexWithinParent()+1;return r.select(e,e)}return n.select(e,t)}selectNext(e,t){Zi();const n=this.getNextSibling(),r=this.getParentOrThrow();if(null===n)return r.select();if(po(n))return n.select(0,0);if(!ri(n)){const e=n.getIndexWithinParent();return r.select(e,e)}return n.select(e,t)}markDirty(){this.getWritable()}reconcileObservedMutation(e,t){this.markDirty()}}const Lr="historic",Or="history-merge",Fr="collaboration",Rr="skip-scroll-into-view",Ir="skip-dom-selection",Pr="skip-selection-focus";class Mr extends Ar{static getType(){return"linebreak"}static clone(e){return new Mr(e.__key)}constructor(e){super(e)}getTextContent(){return"\n"}createDOM(){return document.createElement("br")}updateDOM(){return!1}isInline(){return!0}static importDOM(){return{br:e=>function(e){const t=e.parentElement;if(null!==t&&el(t)){const n=t.firstChild;if(n===e||n.nextSibling===e&&$r(n)){const n=t.lastChild;if(n===e||n.previousSibling===e&&$r(n))return!0}}return!1}(e)||function(e){const t=e.parentElement;if(null!==t&&el(t)){const n=t.firstChild;if(n===e||n.nextSibling===e&&$r(n))return!1;const r=t.lastChild;if(r===e||r.previousSibling===e&&$r(r))return!0}return!1}(e)?null:{conversion:Dr,priority:0}}}static importJSON(e){return Br().updateFromJSON(e)}}function Dr(e){return{node:Br()}}function Br(){return Ws(new Mr)}function zr(e){return e instanceof Mr}function $r(e){return Zo(e)&&/^( |\t|\r?\n)+$/.test(e.textContent||"")}function Hr(e,t){return 16&t?"code":128&t?"mark":32&t?"sub":64&t?"sup":null}function Kr(e,t){return 1&t?"strong":2&t?"em":"span"}function Ur(e,t,n,r,i){const o=r.classList;let s=Es(i,"base");void 0!==s&&o.add(...s),s=Es(i,"underlineStrikethrough");let l=!1;const a=8&t&&4&t;void 0!==s&&(8&n&&4&n?(l=!0,a||o.add(...s)):a&&o.remove(...s));for(const e in We){const r=We[e];if(s=Es(i,e),void 0!==s)if(n&r){if(l&&("underline"===e||"strikethrough"===e)){t&r&&o.remove(...s);continue}(0===(t&r)||a&&"underline"===e||"strikethrough"===e)&&o.add(...s)}else t&r&&o.remove(...s)}}function Wr(e,t,n){const r=t.firstChild,i=n.isComposing(),o=e+(i?De:"");if(null==r)t.textContent=o;else{const e=r.nodeValue;if(e!==o)if(i||_e){const[t,n,i]=function(e,t){const n=e.length,r=t.length;let i=0,o=0;for(;i({conversion:Xr,priority:0}),b:()=>({conversion:Gr,priority:0}),code:()=>({conversion:ti,priority:0}),em:()=>({conversion:ti,priority:0}),i:()=>({conversion:ti,priority:0}),mark:()=>({conversion:ti,priority:0}),s:()=>({conversion:ti,priority:0}),span:()=>({conversion:Zr,priority:0}),strong:()=>({conversion:ti,priority:0}),sub:()=>({conversion:ti,priority:0}),sup:()=>({conversion:ti,priority:0}),u:()=>({conversion:ti,priority:0})}}static importJSON(e){return ni().updateFromJSON(e)}updateFromJSON(e){return super.updateFromJSON(e).setTextContent(e.text).setFormat(e.format).setDetail(e.detail).setMode(e.mode).setStyle(e.style)}exportDOM(e){let{element:t}=super.exportDOM(e);return Js(t)||pe(132),t.style.whiteSpace="pre-wrap",this.hasFormat("lowercase")?t.style.textTransform="lowercase":this.hasFormat("uppercase")?t.style.textTransform="uppercase":this.hasFormat("capitalize")&&(t.style.textTransform="capitalize"),this.hasFormat("bold")&&(t=qr(t,"b")),this.hasFormat("italic")&&(t=qr(t,"i")),this.hasFormat("strikethrough")&&(t=qr(t,"s")),this.hasFormat("underline")&&(t=qr(t,"u")),{element:t}}exportJSON(){return{detail:this.getDetail(),format:this.getFormat(),mode:this.getMode(),style:this.getStyle(),text:this.getTextContent(),...super.exportJSON()}}selectionTransform(e,t){}setFormat(e){const t=this.getWritable();return t.__format="string"==typeof e?We[e]:e,t}setDetail(e){const t=this.getWritable();return t.__detail="string"==typeof e?Ve[e]:e,t}setStyle(e){const t=this.getWritable();return t.__style=e,t}toggleFormat(e){const t=Yo(this.getFormat(),e,null);return this.setFormat(t)}toggleDirectionless(){const e=this.getWritable();return e.__detail^=1,e}toggleUnmergeable(){const e=this.getWritable();return e.__detail^=2,e}setMode(e){const t=Ze[e];if(this.__mode===t)return this;const n=this.getWritable();return n.__mode=t,n}setTextContent(e){if(this.__text===e)return this;const t=this.getWritable();return t.__text=e,t}select(e,t){Zi();let n=e,r=t;const i=Li(),o=this.getTextContent(),s=this.__key;if("string"==typeof o){const e=o.length;void 0===n&&(n=e),void 0===r&&(r=e)}else n=0,r=0;if(!gi(i))return Ti(s,n,s,r,"text","text");{const e=rs();e!==i.anchor.key&&e!==i.focus.key||ns(s),i.setTextNodeRange(this,n,this,r)}return i}selectStart(){return this.select(0,0)}selectEnd(){const e=this.getTextContentSize();return this.select(e,e)}spliceText(e,t,n,r){const i=this.getWritable(),o=i.__text,s=n.length;let l=e;l<0&&(l=s+l,l<0&&(l=0));const a=Li();if(r&&gi(a)){const t=e+s;a.setTextNodeRange(i,t,i,t)}const c=o.slice(0,l)+n+o.slice(l+t);return i.__text=c,i}canInsertTextBefore(){return!0}canInsertTextAfter(){return!0}splitText(...e){Zi();const t=this.getLatest(),n=t.getTextContent();if(""===n)return[];const r=t.__key,i=rs(),o=n.length;e.sort(((e,t)=>e-t)),e.push(o);const s=[],l=e.length;for(let t=0,r=0;tt&&(s.push(n.slice(t,i)),t=i)}const a=s.length;if(1===a)return[t];const c=s[0],u=t.getParent();let d;const h=t.getFormat(),g=t.getStyle(),p=t.__detail;let f=!1,m=null,y=null;const b=Li();if(gi(b)){const[e,t]=b.isBackward()?[b.focus,b.anchor]:[b.anchor,b.focus];"text"===e.type&&e.key===r&&(m=e),"text"===t.type&&t.key===r&&(y=t)}t.isSegmented()?(d=ni(c),d.__format=h,d.__style=g,d.__detail=p,d.__state=_t(t,d),f=!0):d=t.setTextContent(c);const _=[d];for(let e=1;e=C&&(m.set(e.getKey(),x-C,"text"),x=C){y.set(e.getKey(),S-C,"text");break}C=t}if(null!==u){!function(e){const t=e.getPreviousSibling(),n=e.getNextSibling();null!==t&&ts(t),null!==n&&ts(n)}(this);const e=u.getWritable(),t=this.getIndexWithinParent();f?(e.splice(t,0,_),this.remove()):e.splice(t,1,_),gi(b)&&Fi(b,u,t,a-1)}return _}mergeWithSibling(e){const t=e===this.getPreviousSibling();t||e===this.getNextSibling()||pe(50);const n=this.__key,r=e.__key,i=this.__text,o=i.length;rs()===r&&ns(n);const s=Li();if(gi(s)){const i=s.anchor,l=s.focus;null!==i&&i.key===r&&Pi(i,t,n,e,o),null!==l&&l.key===r&&Pi(l,t,n,e,o)}const l=e.__text,a=t?l+i:i+l;this.setTextContent(a);const c=this.getWritable();return e.remove(),c}isTextEntity(){return!1}}function Zr(e){return{forChild:ii(e.style),node:null}}function Gr(e){const t=e,n="normal"===t.style.fontWeight;return{forChild:ii(t.style,n?void 0:"bold"),node:null}}const Jr=new WeakMap;function Yr(e){if(!Js(e))return!1;if("PRE"===e.nodeName)return!0;const t=e.style.whiteSpace;return"string"==typeof t&&t.startsWith("pre")}function Xr(e){const t=e;null===e.parentElement&&pe(129);let n=t.textContent||"";if(null!==function(e){let t,n=e.parentNode;const r=[e];for(;null!==n&&void 0===(t=Jr.get(n))&&!Yr(n);)r.push(n),n=n.parentNode;const i=void 0===t?n:t;for(let e=0;e0){/[ \t\n]$/.test(t)&&(n=n.slice(1)),r=!1;break}}r&&(n=n.slice(1))}if(" "===n[n.length-1]){let e=t,r=!0;for(;null!==e&&null!==(e=Qr(e,!0));)if((e.textContent||"").replace(/^( |\t|\r?\n)+/,"").length>0){r=!1;break}r&&(n=n.slice(0,n.length-1))}return""===n?{node:null}:{node:ni(n)}}function Qr(e,t){let n=e;for(;;){let e;for(;null===(e=t?n.nextSibling:n.previousSibling);){const e=n.parentElement;if(null===e)return null;n=e}if(n=e,Js(n)){const e=n.style.display;if(""===e&&!Qs(n)||""!==e&&!e.startsWith("inline"))return null}let r=n;for(;null!==(r=t?n.firstChild:n.lastChild);)n=r;if(Zo(n))return n;if("BR"===n.nodeName)return null}}const ei={code:"code",em:"italic",i:"italic",mark:"highlight",s:"strikethrough",strong:"bold",sub:"subscript",sup:"superscript",u:"underline"};function ti(e){const t=ei[e.nodeName.toLowerCase()];return void 0===t?{node:null}:{forChild:ii(e.style,t),node:null}}function ni(e=""){return Ws(new jr(e))}function ri(e){return e instanceof jr}function ii(e,t){const n=e.fontWeight,r=e.textDecoration.split(" "),i="700"===n||"bold"===n,o=r.includes("line-through"),s="italic"===e.fontStyle,l=r.includes("underline"),a=e.verticalAlign;return e=>ri(e)?(i&&!e.hasFormat("bold")&&e.toggleFormat("bold"),o&&!e.hasFormat("strikethrough")&&e.toggleFormat("strikethrough"),s&&!e.hasFormat("italic")&&e.toggleFormat("italic"),l&&!e.hasFormat("underline")&&e.toggleFormat("underline"),"sub"!==a||e.hasFormat("subscript")||e.toggleFormat("subscript"),"super"!==a||e.hasFormat("superscript")||e.toggleFormat("superscript"),t&&!e.hasFormat(t)&&e.toggleFormat(t),e):e}class oi extends jr{static getType(){return"tab"}static clone(e){return new oi(e.__key)}constructor(e){super("\t",e),this.__detail=2}static importDOM(){return null}createDOM(e){const t=super.createDOM(e),n=Es(e.theme,"tab");return void 0!==n&&t.classList.add(...n),t}static importJSON(e){return si().updateFromJSON(e)}setTextContent(e){return"\t"!==e&&""!==e&&fe(126),super.setTextContent("\t")}spliceText(e,t,n,r){return""===n&&0===t||"\t"===n&&1===t||pe(286),this}setDetail(e){return 2!==e&&pe(127),this}setMode(e){return"normal"!==e&&pe(128),this}canInsertTextBefore(){return!1}canInsertTextAfter(){return!1}}function si(){return Ws(new oi)}function li(e){return e instanceof oi}class ai{key;offset;type;_selection;constructor(e,t,n){this._selection=null,this.key=e,this.offset=t,this.type=n}is(e){return this.key===e.key&&this.offset===e.offset&&this.type===e.type}isBefore(e){return this.key===e.key?this.offsete&&(r=e)}else if(!po(t)){const e=t.getNextSibling();if(ri(e))n=e.__key,r=0,i="text";else{const e=t.getParent();e&&(n=e.__key,r=t.getIndexWithinParent()+1)}}e.set(n,r,i)}function di(e,t){if(po(t)){const n=t.getLastDescendant();po(n)||ri(n)?ui(e,n):ui(e,t)}else ui(e,t)}class hi{_nodes;_cachedNodes;dirty;constructor(e){this._cachedNodes=null,this._nodes=e,this.dirty=!1}getCachedNodes(){return this._cachedNodes}setCachedNodes(e){this._cachedNodes=e}is(e){if(!fi(e))return!1;const t=this._nodes,n=e._nodes;return t.size===n.size&&Array.from(t).every((e=>n.has(e)))}isCollapsed(){return!1}isBackward(){return!1}getStartEndPoints(){return null}add(e){this.dirty=!0,this._nodes.add(e),this._cachedNodes=null}delete(e){this.dirty=!0,this._nodes.delete(e),this._cachedNodes=null}clear(){this.dirty=!0,this._nodes.clear(),this._cachedNodes=null}has(e){return this._nodes.has(e)}clone(){return new hi(new Set(this._nodes))}extract(){return this.getNodes()}insertRawText(e){}insertText(){}insertNodes(e){const t=this.getNodes(),n=t.length,r=t[n-1];let i;if(ri(r))i=r.select();else{const e=r.getIndexWithinParent()+1;i=r.getParentOrThrow().select(e,e)}i.insertNodes(e);for(let e=0;e1;){const e=t[t.length-1];if(!po(e)||o.has(e)||e.isEmpty()||i.has(e))break;t.pop()}if(0===t.length&&e.isCollapsed()){const n=Xl(e.anchor),r=Xl(e.anchor.getFlipped()),i=e=>xl(e)?e.origin:e.getNodeAtCaret(),o=i(n)||i(r)||(e.anchor.getNodeAtCaret()?n.origin:r.origin);t.push(o)}return t}(ta(jl(this),"next"));return ji()||(this._cachedNodes=t),t}setTextNodeRange(e,t,n,r){this.anchor.set(e.__key,t,"text"),this.focus.set(n.__key,r,"text")}getTextContent(){const e=this.getNodes();if(0===e.length)return"";const t=e[0],n=e[e.length-1],r=this.anchor,i=this.focus,o=r.isBefore(i),[s,l]=yi(this);let a="",c=!0;for(let u=0;u=0;e--){const t=o[e];if(t.is(d)||po(t)&&t.isParentOf(d))break;t.isAttached()&&(!g.has(t)||t.is(i)?f||m.insertAfter(t,!1):t.remove())}if(!f){let e=r,n=null;for(;null!==e;){const r=e.getChildren(),i=r.length;(0===i||r[i-1].is(n))&&(t.delete(e.__key),n=e),e=e.getParent()}}if(qo(d))if(l===h)d.select();else{const t=ni(e);t.select(),d.replace(t)}else d=d.spliceText(l,h-l,e,!0),""===d.getTextContent()?d.remove():d.isComposing()&&"text"===this.anchor.type&&(this.anchor.offset-=e.length);for(let e=1;e{n.forEach((n=>{if(po(n)){const r=n.getFormatFlags(e,t);n.setTextFormat(r)}}))},o=r.length;if(0===o)return this.toggleFormat(e),ns(null),void i(t);const s=this.anchor,l=this.focus,a=this.isBackward(),c=a?l:s,u=a?s:l;let d=0,h=r[0],g="element"===c.type?0:c.offset;if("text"===c.type&&g===h.getTextContentSize()&&(d=1,h=r[1],g=0),null==h)return;const p=h.getFormatFlags(e,t);i(p);const f=o-1;let m=r[f];const y="text"===u.type?u.offset:m.getTextContentSize();if(h.is(m)){if(g===y)return;if(jo(h)||0===g&&y===h.getTextContentSize())h.setFormat(p);else{const e=h.splitText(g,y),t=0===g?e[0]:e[1];t.setFormat(p),"text"===c.type&&c.set(t.__key,0,"text"),"text"===u.type&&u.set(t.__key,y-g,"text")}return void(this.format=p)}0===g||jo(h)||([,h]=h.splitText(g),g=0),h.setFormat(p);const b=m.getFormatFlags(e,p);y>0&&(y===m.getTextContentSize()||jo(m)||([m]=m.splitText(y)),m.setFormat(b));for(let t=d+1;t(po(e)||yo(e))&&!e.isInline()))){po(n)||pe(211,t.constructor.name,t.getType());const i=Bi(this);return n.splice(i,0,e),void r.selectEnd()}const i=function(e){const t=Eo();let n=null;for(let r=0;r0){const e=o.getRangeAt(0),n=this.anchor.getNode(),i=_o(n)?n:function(e){let t=e.getParentOrThrow();for(;null!==t;){if(Ks(t))return t;t=t.getParentOrThrow()}return t}(n);if(this.applyDOMRange(e),this.dirty=!0,!r){const n=this.getNodes(),r=[];let s=!1;for(let e=0;e0)if(t){const e=r[0];po(e)?e.selectStart():e.getParentOrThrow().selectStart()}else{const e=r[r.length-1];po(e)?e.selectEnd():e.getParentOrThrow().selectEnd()}o.anchorNode===e.startContainer&&o.anchorOffset===e.startOffset||function(e){const t=e.focus,n=e.anchor,r=n.key,i=n.offset,o=n.type;n.set(t.key,t.offset,t.type,!0),t.set(r,i,o,!0)}(this)}}"lineboundary"===n&&$i(this,e,t,n,"decorators")}forwardDeletion(e,t,n){if(!n&&("element"===e.type&&po(t)&&e.offset===t.getChildrenSize()||"text"===e.type&&e.offset===t.getTextContentSize())){const e=t.getParent(),n=t.getNextSibling()||(null===e?null:e.getNextSibling());if(po(n)&&n.isShadowRoot())return!0}return!1}deleteCharacter(e){const t=this.isCollapsed();if(this.isCollapsed()){const t=this.anchor;let n=t.getNode();if(this.forwardDeletion(t,n,e))return;const r=Il(Ul(t,e?"previous":"next"));if(r.getTextSlices().every((e=>null===e||0===e.distance))){let e={type:"initial"};for(const t of r.iterNodeCarets("shadowRoot"))if(Cl(t))if(t.origin.isInline());else{if(t.origin.isShadowRoot()){if("merge-block"===e.type)break;if(po(r.anchor.origin)&&r.anchor.origin.isEmpty()){const e=Xl(t);ql(this,Ml(e,e)),r.anchor.origin.remove()}return}"merge-next-block"!==e.type&&"merge-block"!==e.type||(e={block:e.block,caret:t,type:"merge-block"})}else{if("merge-block"===e.type)break;if(Sl(t)){if(po(t.origin)){if(t.origin.isInline()){if(!t.origin.isParentOf(r.anchor.origin))break}else e={block:t.origin,type:"merge-next-block"};continue}if(yo(t.origin)){if(t.origin.isIsolated());else if("merge-next-block"===e.type&&(t.origin.isKeyboardSelectable()||!t.origin.isInline())&&po(r.anchor.origin)&&r.anchor.origin.isEmpty()){r.anchor.origin.remove();const e=Ni();e.add(t.origin.getKey()),hs(e)}else t.origin.remove();return}break}}if("merge-block"===e.type){const{caret:t,block:n}=e;return ql(this,Ml(!t.origin.isEmpty()&&n.isEmpty()?Zl(Tl(n,t.direction)):r.anchor,t)),this.removeText()}}const i=this.focus;if(this.modify("extend",e,"character"),this.isCollapsed()){if(e&&0===t.offset&&bi(this,t.getNode()))return}else{const r="text"===i.type?i.getNode():null;if(n="text"===t.type?t.getNode():null,null!==r&&r.isSegmented()){const t=i.offset,o=r.getTextContentSize();if(r.is(n)||e&&t!==o||!e&&0!==t)return void xi(r,e,t)}else if(null!==n&&n.isSegmented()){const i=t.offset,o=n.getTextContentSize();if(n.is(r)||e&&0!==i||!e&&i!==o)return void xi(n,e,i)}!function(e,t){const n=e.anchor,r=e.focus,i=n.getNode();if(i===r.getNode()&&"text"===n.type&&"text"===r.type){const e=n.offset,o=r.offset,s=e{try{const e=new RegExp("\\p{Emoji}","u"),t=e.test.bind(e);if(t("❤️")&&t("#️⃣")&&t("👍"))return t}catch(e){}return()=>!1})();function xi(e,t,n){const r=e,i=r.getTextContent().split(/(?=\s)/g),o=i.length;let s=0,l=0;for(let e=0;en||r){i.splice(e,1),r&&(l=void 0);break}}const a=i.join("").trim();""===a?r.remove():(r.setTextContent(a),r.select(l,l))}function Si(e,t,n,r){let i,o=t;if(Js(e)){let s=!1;const l=e.childNodes,a=l.length,c=r._blockCursorElement;o===a&&(s=!0,o=a-1);let u=l[o],d=!1;if(u===c)u=l[o+1],d=!0;else if(null!==c){const n=c.parentNode;e===n&&t>Array.prototype.indexOf.call(n.children,c)&&o--}if(i=gs(u),ri(i))o=Nl(i,s?"next":"previous");else{let l=gs(e);if(null===l)return null;if(po(l)){const a=r.getElementByKey(l.getKey());null===a&&pe(214);const c=l.getDOMSlot(a);[l,o]=c.resolveChildIndex(l,a,e,t),po(l)||pe(215),s&&o>=l.getChildrenSize()&&(o=Math.max(0,l.getChildrenSize()-1));let u=l.getChildAtIndex(o);if(po(u)&&function(e,t,n){const r=e.getParent();return null===n||null===r||!r.canBeEmpty()||r!==n.getNode()}(u,0,n)){const e=s?u.getLastDescendant():u.getFirstDescendant();null===e?l=u:(u=e,l=po(u)?u:u.getParentOrThrow()),o=0}ri(u)?(i=u,l=null,o=Nl(u,s?"next":"previous")):u!==l&&s&&!d&&(po(l)||pe(216),o=Math.min(l.getChildrenSize(),o+1))}else{const n=l.getIndexWithinParent();o=0===t&&yo(l)&&gs(e)===l?n:n+1,l=l.getParentOrThrow()}if(po(l))return ci(l.__key,o,"element")}}else i=gs(e);return ri(i)?ci(i.__key,Nl(i,o,"clamp"),"text"):null}function Ci(e,t,n){const r=e.offset,i=e.getNode();if(0===r){const r=i.getPreviousSibling(),o=i.getParent();if(t){if((n||!t)&&null===r&&po(o)&&o.isInline()){const t=o.getPreviousSibling();ri(t)&&e.set(t.__key,t.getTextContent().length,"text")}}else po(r)&&!n&&r.isInline()?e.set(r.__key,r.getChildrenSize(),"element"):ri(r)&&e.set(r.__key,r.getTextContent().length,"text")}else if(r===i.getTextContent().length){const r=i.getNextSibling(),o=i.getParent();if(t&&po(r)&&r.isInline())e.set(r.__key,0,"element");else if((n||t)&&null===r&&po(o)&&o.isInline()&&!o.canInsertTextAfter()){const t=o.getNextSibling();ri(t)&&e.set(t.__key,0,"text")}}}function vi(e,t,n){if("text"===e.type&&"text"===t.type){const r=e.isBefore(t),i=e.is(t);Ci(e,r,i),Ci(t,!r,i),i&&t.set(e.key,e.offset,e.type);const o=Yi();if(o.isComposing()&&o._compositionKey!==e.key&&gi(n)){const r=n.anchor,i=n.focus;e.set(r.key,r.offset,r.type,!0),t.set(i.key,i.offset,i.type,!0)}}}function wi(e,t,n,r,i,o){if(null===e||null===n||!Ho(i,e,n))return null;const s=Si(e,t,gi(o)?o.anchor:null,i);if(null===s)return null;const l=Si(n,r,gi(o)?o.focus:null,i);if(null===l)return null;if("element"===s.type&&"element"===l.type){const t=gs(e),r=gs(n);if(yo(t)&&yo(r))return null}return vi(s,l,o),[s,l]}function ki(e){return po(e)&&!e.isInline()}function Ti(e,t,n,r,i,o){const s=Ji(),l=new pi(ci(e,t,i),ci(n,r,o),0,"");return l.dirty=!0,s._selection=l,l}function Ei(){const e=ci("root",0,"element"),t=ci("root",0,"element");return new pi(e,t,0,"")}function Ni(){return new hi(new Set)}function Ai(e,t,n,r){const i=n._window;if(null===i)return null;const o=r||i.event,s=o?o.type:void 0,l="selectionchange"===s,a=!Xe&&(l||"beforeinput"===s||"compositionstart"===s||"compositionend"===s||"click"===s&&o&&3===o.detail||"drop"===s||void 0===s);let c,u,d,h;if(gi(e)&&!a)return e.clone();if(null===t)return null;if(c=t.anchorNode,u=t.focusNode,d=t.anchorOffset,h=t.focusOffset,(l||void 0===s)&&gi(e)&&!Ho(n,c,u))return e.clone();const g=wi(c,d,u,h,n,e);if(null===g)return null;const[p,f]=g;return new pi(p,f,gi(e)?e.format:0,gi(e)?e.style:"")}function Li(){return Ji()._selection}function Oi(){return Yi()._editorState._selection}function Fi(e,t,n,r=1){const i=e.anchor,o=e.focus,s=i.getNode(),l=o.getNode();if(!t.is(s)&&!t.is(l))return;const a=t.__key;if(e.isCollapsed()){const t=i.offset;if(n<=t&&r>0||n0||n0||n=e,s=i?o.getChildAtIndex(e-1):o.getChildAtIndex(n);if(ri(s)){let e=0;i&&(e=s.getTextContentSize()),t.set(s.__key,e,"text"),r.set(s.__key,e,"text")}}else{if(po(o)){const e=o.getChildrenSize(),r=n>=e,i=r?o.getChildAtIndex(e-1):o.getChildAtIndex(n);if(ri(i)){let e=0;r&&(e=i.getTextContentSize()),t.set(i.__key,e,"text")}}if(po(s)){const e=s.getChildrenSize(),t=i>=e,n=t?s.getChildAtIndex(e-1):s.getChildAtIndex(i);if(ri(n)){let e=0;t&&(e=n.getTextContentSize()),r.set(n.__key,e,"text")}}}}function Ii(e,t,n,r,i){let o=null,s=0,l=null;null!==r?(o=r.__key,ri(r)?(s=r.getTextContentSize(),l="text"):po(r)&&(s=r.getChildrenSize(),l="element")):null!==i&&(o=i.__key,ri(i)?l="text":po(i)&&(l="element")),null!==o&&null!==l?e.set(o,s,l):(s=t.getIndexWithinParent(),-1===s&&(s=n.getChildrenSize()),e.set(n.__key,s,"element"))}function Pi(e,t,n,r,i){"text"===e.type?e.set(n,e.offset+(t?0:i),"text"):e.offset>r.getIndexWithinParent()&&e.set(e.key,e.offset-1,"element")}function Mi(e,t,n,r,i){try{e.setBaseAndExtent(t,n,r,i)}catch(e){}}function Di(e){let t=Li()||Oi();null===t&&(t=us().selectEnd()),t.insertNodes(e)}function Bi(e){let t=e;e.isCollapsed()||t.removeText();const n=Li();gi(n)&&(t=n),gi(t)||pe(161);const r=t.anchor;let i=r.getNode(),o=r.offset;for(;!tl(i);){const e=i;if([i,o]=zi(i,o),e.is(i))break}return o}function zi(e,t){const n=e.getParent();if(!n){const e=Eo();return us().append(e),e.select(),[us(),0]}if(ri(e)){const r=e.splitText(t);if(0===r.length)return[n,e.getIndexWithinParent()];const i=0===t?0:1;return[n,r[0].getIndexWithinParent()+i]}if(!po(e)||0===t)return[n,e.getIndexWithinParent()];const r=e.getChildAtIndex(t);if(r){const n=new pi(ci(e.__key,t,"element"),ci(e.__key,t,"element"),0,""),i=e.insertNewAfter(n);i&&i.append(r,...r.getNextSiblings())}return[n,e.getIndexWithinParent()+1]}function $i(e,t,n,r,i="decorators-and-blocks"){if("move"===t&&"character"===r&&!e.isCollapsed()){const[t,r]=n===e.isBackward()?[e.focus,e.anchor]:[e.anchor,e.focus];return r.set(t.key,t.offset,t.type),!0}const o=Ul(e.focus,n?"previous":"next"),s="lineboundary"===r,l="move"===t;let a=o,c="decorators-and-blocks"===i;if(!Ql(a)){for(const e of a){c=!1;const{origin:t}=e;if(!yo(t)||t.isIsolated()||(a=e,!s||!t.isInline()))break}if(c)for(const e of Il(o).iterNodeCarets("extend"===t?"shadowRoot":"root")){if(Cl(e))e.origin.isInline()||(a=e);else{if(po(e.origin))continue;yo(e.origin)&&!e.origin.isInline()&&(a=e)}break}}if(a===o)return!1;if(l&&!s&&yo(a.origin)&&a.origin.isKeyboardSelectable()){const e=Ni();return e.add(a.origin.getKey()),hs(e),!0}return a=Xl(a),l&&Wl(e.anchor,a),Wl(e.focus,a),c||!s}let Hi=null,Ki=null,Ui=!1,Wi=!1,Vi=0;const qi={characterData:!0,childList:!0,subtree:!0};function ji(){return Ui||null!==Hi&&Hi._readOnly}function Zi(){Ui&&pe(13)}function Gi(){Vi>99&&pe(14)}function Ji(){return null===Hi&&pe(195,Xi()),Hi}function Yi(){return null===Ki&&pe(196,Xi()),Ki}function Xi(){let e=0;const t=new Set,n=Fo.version;if("undefined"!=typeof window)for(const r of document.querySelectorAll("[contenteditable]")){const i=Wo(r);if(Ko(i))e++;else if(i){let e=String(i.constructor.version||"<0.17.1");e===n&&(e+=" (separately built, likely a bundler configuration issue)"),t.add(e)}}let r=` Detected on the page: ${e} compatible editor(s) with version ${n}`;return t.size&&(r+=` and incompatible editors with versions ${Array.from(t).join(", ")}`),r}function Qi(e,t,n){const r=t.__type,i=Mo(e,r);let o=n.get(r);void 0===o&&(o=Array.from(i.transforms),n.set(r,o));const s=o.length;for(let e=0;e0?r.getRangeAt(0):null;if(null!==e){let t;if(e instanceof Text){const n=document.createRange();n.selectNode(e),t=n.getBoundingClientRect()}else t=e.getBoundingClientRect();!function(e,t,n){const r=Ms(n),i=zs(r);if(null===r||null===i)return;let{top:o,bottom:s}=t,l=0,a=0,c=n;for(;null!==c;){const t=c===r.body;if(t)l=0,a=$s(e).innerHeight;else{const e=c.getBoundingClientRect();l=e.top,a=e.bottom}let n=0;if(oa&&(n=s-a),0!==n)if(t)i.scrollBy(0,n);else{const e=c.scrollTop;c.scrollTop+=n;const t=c.scrollTop-e;o-=t,s-=t}if(t)break;c=Ps(c)}}(n,t,o)}}or=!0}}(s,l,e,x,b,r)}!function(e,t,n){let r=e._blockCursorElement;if(gi(n)&&n.isCollapsed()&&"element"===n.anchor.type&&t.contains(document.activeElement)){const i=n.anchor,o=i.getNode(),s=i.offset;let l=!1,a=null;if(s===o.getChildrenSize())qs(o.getChildAtIndex(s-1))&&(l=!0);else{const t=o.getChildAtIndex(s);if(null!==t&&qs(t)){const n=t.getPreviousSibling();(null===n||qs(n))&&(l=!0,a=e.getElementByKey(t.__key))}}if(l){const n=e.getElementByKey(o.__key);return null===r&&(e._blockCursorElement=r=function(e){const t=e.theme,n=document.createElement("div");n.contentEditable="false",n.setAttribute("data-lexical-cursor","true");let r=t.blockCursor;if(void 0!==r){if("string"==typeof r){const e=Ee(r);r=t.blockCursor=e}void 0!==r&&n.classList.add(...r)}return n}(e._config)),t.style.caretColor="transparent",void(null===a?n.appendChild(r):n.insertBefore(r,a))}}null!==r&&js(r,e,t)}(e,r,l)}finally{null!==g&&g.observe(r,qi),Ki=d,Hi=c}}null!==p&&function(e,t,n,r,i){const o=Array.from(e._listeners.mutation),s=o.length;for(let e=0;e0||u>0;){if(a>0){t._dirtyLeaves=new Set;for(const e of l){const r=i.get(e);ri(r)&&r.isAttached()&&r.isSimpleText()&&!r.isUnmergeable()&&Ct(r),void 0!==r&&eo(r,o)&&Qi(t,r,s),n.add(e)}if(l=t._dirtyLeaves,a=l.size,a>0){Vi++;continue}}t._dirtyLeaves=new Set,t._dirtyElements=new Map,c.delete("root")&&c.set("root",!0);for(const e of c){const n=e[0],l=e[1];if(r.set(n,l),!l)continue;const a=i.get(n);void 0!==a&&eo(a,o)&&Qi(t,a,s)}l=t._dirtyLeaves,a=l.size,c=t._dirtyElements,u=c.size,Vi++}t._dirtyLeaves=n,t._dirtyElements=r}(a,e),lo(e),function(e,t,n,r){const i=e._nodeMap,o=t._nodeMap,s=[];for(const[e]of r){const t=o.get(e);void 0!==t&&(t.isAttached()||(po(t)&&Ye(t,e,i,o,s,r),i.has(e)||r.delete(e),s.push(e)))}for(const e of s)o.delete(e);for(const e of n){const t=o.get(e);void 0===t||t.isAttached()||(i.has(e)||n.delete(e),o.delete(e))}}(l,a,e._dirtyLeaves,e._dirtyElements)),r!==e._compositionKey&&(a._flushSync=!0);const i=a._selection;if(gi(i)){const e=a._nodeMap,t=i.anchor.key,n=i.focus.key;void 0!==e.get(t)&&void 0!==e.get(n)||pe(19)}else fi(i)&&0===i._nodes.size&&(a._selection=null)}catch(t){return t instanceof Error&&e._onError(t),e._pendingEditorState=l,e._dirtyType=2,e._cloneNotNeeded.clear(),e._dirtyLeaves=new Set,e._dirtyElements.clear(),void oo(e)}finally{Hi=u,Ui=d,Ki=h,e._updating=g,Vi=0}const f=0!==e._dirtyType||e._deferred.length>0||function(e,t){const n=t.getEditorState()._selection,r=e._selection;if(null!==r){if(r.dirty||!r.is(n))return!0}else if(null!==n)return!0;return!1}(a,e);f?a._flushSync?(a._flushSync=!1,oo(e)):c&&Bo((()=>{oo(e)})):(a._flushSync=!1,c&&(r.clear(),e._deferred=[],e._pendingEditorState=null))}function co(e,t,n){Ki===e&&void 0===n?t():ao(e,t,n)}class uo{element;before;after;constructor(e,t,n){this.element=e,this.before=t||null,this.after=n||null}withBefore(e){return new uo(this.element,e,this.after)}withAfter(e){return new uo(this.element,this.before,e)}withElement(e){return this.element===e?this:new uo(e,this.before,this.after)}insertChild(e){const t=this.before||this.getManagedLineBreak();return null!==t&&t.parentElement!==this.element&&pe(222),this.element.insertBefore(e,t),this}removeChild(e){return e.parentElement!==this.element&&pe(223),this.element.removeChild(e),this}replaceChild(e,t){return t.parentElement!==this.element&&pe(224),this.element.replaceChild(e,t),this}getFirstChild(){const e=this.after?this.after.nextSibling:this.element.firstChild;return e===this.before||e===this.getManagedLineBreak()?null:e}getManagedLineBreak(){return this.element.__lexicalLineBreak||null}setManagedLineBreak(e){if(null===e)this.removeManagedLineBreak();else{const t="decorator"===e&&(Te||Ce||Se);this.insertManagedLineBreak(t)}}removeManagedLineBreak(){const e=this.getManagedLineBreak();if(e){const t=this.element,n="IMG"===e.nodeName?e.nextSibling:null;n&&t.removeChild(n),t.removeChild(e),t.__lexicalLineBreak=void 0}}insertManagedLineBreak(e){const t=this.getManagedLineBreak();if(t){if(e===("IMG"===t.nodeName))return;this.removeManagedLineBreak()}const n=this.element,r=this.before,i=document.createElement("br");if(n.insertBefore(i,r),e){const e=document.createElement("img");e.setAttribute("data-lexical-linebreak","true"),e.style.cssText="display: inline !important; border: 0px !important; margin: 0px !important;",e.alt="",n.insertBefore(e,i),n.__lexicalLineBreak=e}else n.__lexicalLineBreak=i}getFirstChildOffset(){let e=0;for(let t=this.after;null!==t;t=t.previousSibling)e++;return e}resolveChildIndex(e,t,n,r){if(n===this.element){const t=this.getFirstChildOffset();return[e,Math.min(t+e.getChildrenSize(),Math.max(t,r))]}const i=ho(t,n);i.push(r);const o=ho(t,this.element);let s=e.getIndexWithinParent();for(let e=0;en){s+=1;break}}return[e.getParentOrThrow(),s]}}function ho(e,t){const n=[];let r=t;for(;r!==e&&null!==r;r=r.parentNode){let e=0;for(let t=r.previousSibling;null!==t;t=t.previousSibling)e++;n.push(e)}return r!==e&&pe(225),n.reverse()}class go extends Ar{__first;__last;__size;__format;__style;__indent;__dir;__textFormat;__textStyle;constructor(e){super(e),this.__first=null,this.__last=null,this.__size=0,this.__format=0,this.__style="",this.__indent=0,this.__dir=null,this.__textFormat=0,this.__textStyle=""}afterCloneFrom(e){super.afterCloneFrom(e),this.__key===e.__key&&(this.__first=e.__first,this.__last=e.__last,this.__size=e.__size),this.__indent=e.__indent,this.__format=e.__format,this.__style=e.__style,this.__dir=e.__dir,this.__textFormat=e.__textFormat,this.__textStyle=e.__textStyle}getFormat(){return this.getLatest().__format}getFormatType(){const e=this.getFormat();return je[e]||""}getStyle(){return this.getLatest().__style}getIndent(){return this.getLatest().__indent}getChildren(){const e=[];let t=this.getFirstChild();for(;null!==t;)e.push(t),t=t.getNextSibling();return e}getChildrenKeys(){const e=[];let t=this.getFirstChild();for(;null!==t;)e.push(t.__key),t=t.getNextSibling();return e}getChildrenSize(){return this.getLatest().__size}isEmpty(){return 0===this.getChildrenSize()}isDirty(){const e=Yi()._dirtyElements;return null!==e&&e.has(this.__key)}isLastChild(){const e=this.getLatest(),t=this.getParentOrThrow().getLastChild();return null!==t&&t.is(e)}getAllTextNodes(){const e=[];let t=this.getFirstChild();for(;null!==t;){if(ri(t)&&e.push(t),po(t)){const n=t.getAllTextNodes();e.push(...n)}t=t.getNextSibling()}return e}getFirstDescendant(){let e=this.getFirstChild();for(;po(e);){const t=e.getFirstChild();if(null===t)break;e=t}return e}getLastDescendant(){let e=this.getLastChild();for(;po(e);){const t=e.getLastChild();if(null===t)break;e=t}return e}getDescendantByIndex(e){const t=this.getChildren(),n=t.length;if(e>=n){const e=t[n-1];return po(e)&&e.getLastDescendant()||e||null}const r=t[e];return po(r)&&r.getFirstDescendant()||r||null}getFirstChild(){const e=this.getLatest().__first;return null===e?null:is(e)}getFirstChildOrThrow(){const e=this.getFirstChild();return null===e&&pe(45,this.__key),e}getLastChild(){const e=this.getLatest().__last;return null===e?null:is(e)}getLastChildOrThrow(){const e=this.getLastChild();return null===e&&pe(96,this.__key),e}getChildAtIndex(e){const t=this.getChildrenSize();let n,r;if(e=e;){if(r===e)return n;n=n.getPreviousSibling(),r--}return null}getTextContent(){let e="";const t=this.getChildren(),n=t.length;for(let r=0;re.remove())),e}append(...e){return this.splice(this.getChildrenSize(),0,e)}setDirection(e){const t=this.getWritable();return t.__dir=e,t}setFormat(e){return this.getWritable().__format=""!==e?qe[e]:0,this}setStyle(e){return this.getWritable().__style=e||"",this}setTextFormat(e){const t=this.getWritable();return t.__textFormat=e,t}setTextStyle(e){const t=this.getWritable();return t.__textStyle=e,t}setIndent(e){return this.getWritable().__indent=e,this}splice(e,t,n){Nr(this)&&pe(324,this.__key,this.__type);const r=this.getChildrenSize(),i=this.getWritable();e+t<=r||pe(226,String(e),String(t),String(r));const o=i.__key,s=[],l=[],a=this.getChildAtIndex(e+t);let c=null,u=r-t+n.length;if(0!==e)if(e===r)c=this.getLastChild();else{const t=this.getChildAtIndex(e);null!==t&&(c=t.getPreviousSibling())}if(t>0){let e=null===c?this.getFirstChild():c.getNextSibling();for(let n=0;n0&&(t.style.paddingInlineStart=40*e+"px");const n=this.getDirection();n&&(t.dir=n)}return{element:t}}exportJSON(){const e={children:[],direction:this.getDirection(),format:this.getFormatType(),indent:this.getIndent(),...super.exportJSON()},t=this.getTextFormat(),n=this.getTextStyle();return 0!==t&&(e.textFormat=t),""!==n&&(e.textStyle=n),e}updateFromJSON(e){return super.updateFromJSON(e).setFormat(e.format).setIndent(e.indent).setDirection(e.direction).setTextFormat(e.textFormat||0).setTextStyle(e.textStyle||"")}insertNewAfter(e,t){return null}canIndent(){return!0}collapseAtStart(e){return!1}excludeFromCopy(e){return!1}canReplaceWith(e){return!0}canInsertAfter(e){return!0}canBeEmpty(){return!0}canInsertTextBefore(){return!0}canInsertTextAfter(){return!0}isInline(){return!1}isShadowRoot(){return!1}canMergeWith(e){return!1}extractWithChild(e,t,n){return!1}canMergeWhenEmpty(){return!1}reconcileObservedMutation(e,t){const n=this.getDOMSlot(e);let r=n.getFirstChild();for(let e=this.getFirstChild();e;e=e.getNextSibling()){const i=t.getElementByKey(e.getKey());null!==i&&(null==r?(n.insertChild(i),r=i):r!==i&&n.replaceChild(i,r),r=r.nextSibling)}}}function po(e){return e instanceof go}function fo(e,t,n){let r=e.getNode();for(;r;){const e=r.__key;if(t.has(e)&&!n.has(e))return!0;r=r.getParent()}return!1}class mo extends Ar{decorate(e,t){return null}isIsolated(){return!1}isInline(){return!0}isKeyboardSelectable(){return!0}}function yo(e){return e instanceof mo}class bo extends go{__cachedText;static getType(){return"root"}static clone(){return new bo}constructor(){super("root"),this.__cachedText=null}getTopLevelElementOrThrow(){pe(51)}getTextContent(){const e=this.__cachedText;return!ji()&&0!==Yi()._dirtyType||null===e?super.getTextContent():e}remove(){pe(52)}replace(e){pe(53)}insertBefore(e){pe(54)}insertAfter(e){pe(55)}updateDOM(e,t){return!1}splice(e,t,n){for(const e of n)po(e)||yo(e)||pe(282);return super.splice(e,t,n)}static importJSON(e){return us().updateFromJSON(e)}collapseAtStart(){return!0}}function _o(e){return e instanceof bo}function xo(e){return new vo(new Map(e._nodeMap))}function So(){return new vo(new Map([["root",new bo]]))}function Co(e){const t=e.exportJSON(),n=e.constructor;if(t.type!==n.getType()&&pe(130,n.name),po(e)){const r=t.children;Array.isArray(r)||pe(59,n.name);const i=e.getChildren();for(let e=0;e({root:Co(us())})))}}class wo extends go{static getType(){return"artificial"}createDOM(e){return document.createElement("div")}}class ko extends go{static getType(){return"paragraph"}static clone(e){return new ko(e.__key)}createDOM(e){const t=document.createElement("p"),n=Es(e.theme,"paragraph");return void 0!==n&&t.classList.add(...n),t}updateDOM(e,t,n){return!1}static importDOM(){return{p:e=>({conversion:To,priority:0})}}exportDOM(e){const{element:t}=super.exportDOM(e);if(Js(t)){this.isEmpty()&&t.append(document.createElement("br"));const e=this.getFormatType();e&&(t.style.textAlign=e)}return{element:t}}static importJSON(e){return Eo().updateFromJSON(e)}exportJSON(){return{...super.exportJSON(),textFormat:this.getTextFormat(),textStyle:this.getTextStyle()}}insertNewAfter(e,t){const n=Eo();n.setTextFormat(e.format),n.setTextStyle(e.style);const r=this.getDirection();return n.setDirection(r),n.setFormat(this.getFormatType()),n.setStyle(this.getStyle()),this.insertAfter(n,t),n}collapseAtStart(){const e=this.getChildren();if(0===e.length||ri(e[0])&&""===e[0].getTextContent().trim()){if(null!==this.getNextSibling())return this.selectNext(),this.remove(),!0;if(null!==this.getPreviousSibling())return this.selectPrevious(),this.remove(),!0}return!1}}function To(e){const t=Eo();return e.style&&(t.setFormat(e.style.textAlign),ll(e,t)),{node:t}}function Eo(){return Ws(new ko)}function No(e){return e instanceof ko}function Ao(e,t,n,r){const i=e._keyToDOMMap;i.clear(),e._editorState=So(),e._pendingEditorState=r,e._compositionKey=null,e._dirtyType=0,e._cloneNotNeeded.clear(),e._dirtyLeaves=new Set,e._dirtyElements.clear(),e._normalizedNodes=new Set,e._updateTags=new Set,e._updates=[],e._blockCursorElement=null;const o=e._observer;null!==o&&(o.disconnect(),e._observer=null),null!==t&&(t.textContent=""),null!==n&&(n.textContent="",i.set("root",n))}function Lo(e){const t=new Set,n=new Set;let r=e;for(;r;){const{ownNodeConfig:e}=ul(r),i=r.transform;if(!n.has(i)){n.add(i);const e=r.transform();e&&t.add(e)}if(e){const n=e.$transform;n&&t.add(n),r=e.extends}else{const e=Object.getPrototypeOf(r);r=e.prototype instanceof Ar&&e!==Ar?e:void 0}}return t}function Oo(e){const t=e||{},n=Ki,r=t.theme||{},i=void 0===e?n:t.parentEditor||null,o=t.disableEvents||!1,s=So(),l=t.namespace||(null!==i?i._config.namespace:ms()),a=t.editorState,c=[bo,jr,Mr,oi,ko,wo,...t.nodes||[]],{onError:u,html:d}=t,h=void 0===t.editable||t.editable;let g;if(void 0===e&&null!==n)g=n._nodes;else{g=new Map;for(let e=0;e{Object.keys(e).forEach((t=>{let r=n.get(t);void 0===r&&(r=[],n.set(t,r)),r.push(e[t])}))};return e.forEach((e=>{const t=e.klass.importDOM;if(null==t||r.has(t))return;r.add(t);const n=t.call(e.klass);null!==n&&i(n)})),t&&i(t),n}(g,d?d.import:void 0),h,e);return void 0!==a&&(p._pendingEditorState=a,p._dirtyType=2),p}class Fo{static version;_headless;_parentEditor;_rootElement;_editorState;_pendingEditorState;_compositionKey;_deferred;_keyToDOMMap;_updates;_updating;_listeners;_commands;_nodes;_decorators;_pendingDecorators;_config;_dirtyType;_cloneNotNeeded;_dirtyLeaves;_dirtyElements;_normalizedNodes;_updateTags;_observer;_key;_onError;_htmlConversions;_window;_editable;_blockCursorElement;_createEditorArgs;constructor(e,t,n,r,i,o,s,l){this._createEditorArgs=l,this._parentEditor=t,this._rootElement=null,this._editorState=e,this._pendingEditorState=null,this._compositionKey=null,this._deferred=[],this._keyToDOMMap=new Map,this._updates=[],this._updating=!1,this._listeners={decorator:new Set,editable:new Set,mutation:new Map,root:new Set,textcontent:new Set,update:new Set},this._commands=new Map,this._config=r,this._nodes=n,this._decorators={},this._pendingDecorators=null,this._dirtyType=0,this._cloneNotNeeded=new Set,this._dirtyLeaves=new Set,this._dirtyElements=new Map,this._normalizedNodes=new Set,this._updateTags=new Set,this._observer=null,this._key=ms(),this._onError=i,this._htmlConversions=o,this._editable=s,this._headless=null!==t&&t._headless,this._window=null,this._blockCursorElement=null}isComposing(){return null!=this._compositionKey}registerUpdateListener(e){const t=this._listeners.update;return t.add(e),()=>{t.delete(e)}}registerEditableListener(e){const t=this._listeners.editable;return t.add(e),()=>{t.delete(e)}}registerDecoratorListener(e){const t=this._listeners.decorator;return t.add(e),()=>{t.delete(e)}}registerTextContentListener(e){const t=this._listeners.textcontent;return t.add(e),()=>{t.delete(e)}}registerRootListener(e){const t=this._listeners.root;return e(this._rootElement,null),t.add(e),()=>{e(null,this._rootElement),t.delete(e)}}registerCommand(e,t,n){void 0===n&&pe(35);const r=this._commands;r.has(e)||r.set(e,[new Set,new Set,new Set,new Set,new Set]);const i=r.get(e);void 0===i&&pe(36,String(e));const o=i[n];return o.add(t),()=>{o.delete(t),i.every((e=>0===e.size))&&r.delete(e)}}registerMutationListener(e,t,n){const r=this.resolveRegisteredNodeAfterReplacements(this.getRegisteredNode(e)).klass,i=this._listeners.mutation;let o=i.get(t);void 0===o&&(o=new Set,i.set(t,o)),o.add(r);const s=n&&n.skipInitialization;return void 0!==s&&s||this.initializeMutationListener(t,r),()=>{o.delete(r),0===o.size&&i.delete(t)}}getRegisteredNode(e){const t=this._nodes.get(e.getType());return void 0===t&&pe(37,e.name),t}resolveRegisteredNodeAfterReplacements(e){for(;e.replaceWithKlass;)e=this.getRegisteredNode(e.replaceWithKlass);return e}initializeMutationListener(e,t){const n=this._editorState,r=ol(n).get(t.getType());if(!r)return;const i=new Map;for(const e of r.keys())i.set(e,"created");i.size>0&&e(i,{dirtyLeaves:new Set,prevEditorState:n,updateTags:new Set(["registerMutationListener"])})}registerNodeTransformToKlass(e,t){const n=this.getRegisteredNode(e);return n.transforms.add(t),n}registerNodeTransform(e,t){const n=this.registerNodeTransformToKlass(e,t),r=[n],i=n.replaceWithKlass;if(null!=i){const e=this.registerNodeTransformToKlass(i,t);r.push(e)}return function(e,t){const n=ol(e.getEditorState()),r=[];for(const e of t){const t=n.get(e);t&&r.push(t)}0!==r.length&&e.update((()=>{for(const e of r)for(const t of e.keys()){const e=is(t);e&&e.markDirty()}}),null===e._pendingEditorState?{tag:Or}:void 0)}(this,r.map((e=>e.klass.getType()))),()=>{r.forEach((e=>e.transforms.delete(t)))}}hasNode(e){return this._nodes.has(e.getType())}hasNodes(e){return e.every(this.hasNode.bind(this))}dispatchCommand(e,t){return Fs(this,e,t)}getDecorators(){return this._decorators}getRootElement(){return this._rootElement}getKey(){return this._key}setRootElement(e){const t=this._rootElement;if(e!==t){const n=Es(this._config.theme,"root"),r=this._pendingEditorState||this._editorState;if(this._rootElement=e,Ao(this,t,e,r),null!==t&&(this._config.disableEvents||kr(t),null!=n&&t.classList.remove(...n)),null!==e){const t=zs(e),r=e.style;r.userSelect="text",r.whiteSpace="pre-wrap",r.wordBreak="break-word",e.setAttribute("data-lexical-editor","true"),this._window=t,this._dirtyType=2,lt(this),this._updateTags.add(Or),oo(this),this._config.disableEvents||function(e,t){const n=e.ownerDocument;rr.set(e,n);const r=ir.get(n)??0;r<1&&n.addEventListener("selectionchange",Cr),ir.set(n,r+1),e.__lexicalEditor=t;const i=xr(e);for(let n=0;n{wr(e)||(vr(e),(t.isEditable()||"click"===r)&&o(e,t))}:e=>{if(wr(e))return;vr(e);const n=t.isEditable();switch(r){case"cut":return n&&Fs(t,Kn,e);case"copy":return Fs(t,Hn,e);case"paste":return n&&Fs(t,gn,e);case"dragstart":return n&&Fs(t,Bn,e);case"dragover":return n&&Fs(t,zn,e);case"dragend":return n&&Fs(t,$n,e);case"focus":return n&&Fs(t,Zn,e);case"blur":return n&&Fs(t,Gn,e);case"drop":return n&&Fs(t,Mn,e)}};e.addEventListener(r,s),i.push((()=>{e.removeEventListener(r,s)}))}}(e,this),null!=n&&e.classList.add(...n)}else this._window=null,this._updateTags.add(Or),oo(this);so("root",this,!1,e,t)}}getElementByKey(e){return this._keyToDOMMap.get(e)||null}getEditorState(){return this._editorState}setEditorState(e,t){e.isEmpty()&&pe(38);let n=e;n._readOnly&&(n=xo(e),n._selection=e._selection?e._selection.clone():null),st(this);const r=this._pendingEditorState,i=this._updateTags,o=void 0!==t?t.tag:null;null===r||r.isEmpty()||(null!=o&&i.add(o),oo(this)),this._pendingEditorState=n,this._dirtyType=2,this._dirtyElements.set("root",!1),this._compositionKey=null,null!=o&&i.add(o),this._updating||oo(this)}parseEditorState(e,t){return function(e,t,n){const r=So(),i=Hi,o=Ui,s=Ki,l=t._dirtyElements,a=t._dirtyLeaves,c=t._cloneNotNeeded,u=t._dirtyType;t._dirtyElements=new Map,t._dirtyLeaves=new Set,t._cloneNotNeeded=new Set,t._dirtyType=0,Hi=r,Ui=!1,Ki=t,Io(null);try{const i=t._nodes;ro(e.root,i),n&&n(),r._readOnly=!0}catch(e){e instanceof Error&&t._onError(e)}finally{t._dirtyElements=l,t._dirtyLeaves=a,t._cloneNotNeeded=c,t._dirtyType=u,Hi=i,Ui=o,Ki=s}return r}("string"==typeof e?JSON.parse(e):e,this,t)}read(e){return oo(this),this.getEditorState().read(e,{editor:this})}update(e,t){!function(e,t,n){e._updating?e._updates.push([t,n]):ao(e,t,n)}(this,e,t)}focus(e,t={}){const n=this._rootElement;null!==n&&(n.setAttribute("autocapitalize","off"),co(this,(()=>{const r=Li(),i=us();null!==r?r.dirty||hs(r.clone()):0!==i.getChildrenSize()&&("rootStart"===t.defaultSelection?i.selectStart():i.selectEnd()),Ds("focus"),function(e){Zi(),Yi()._deferred.push(e)}((()=>{n.removeAttribute("autocapitalize"),e&&e()}))})),null===this._pendingEditorState&&n.removeAttribute("autocapitalize"))}blur(){const e=this._rootElement;null!==e&&e.blur();const t=Zs(this._window);null!==t&&t.removeAllRanges()}isEditable(){return this._editable}setEditable(e){this._editable!==e&&(this._editable=e,so("editable",this,!0,e))}toJSON(){return{editorState:this._editorState.toJSON()}}}Fo.version="0.38.2+prod.esm";let Ro=null;function Io(e){Ro=e}let Po=1;function Mo(e,t){const n=Do(e,t);return void 0===n&&pe(30,t),n}function Do(e,t){return e._nodes.get(t)}const Bo="function"==typeof queueMicrotask?queueMicrotask:e=>{Promise.resolve().then(e)};function zo(e){return yo(ls(e))}function $o(e){const t=document.activeElement;if(!Js(t))return!1;const n=t.nodeName;return yo(ls(e))&&("INPUT"===n||"TEXTAREA"===n||"true"===t.contentEditable&&null==Wo(t))}function Ho(e,t,n){const r=e.getRootElement();try{return null!==r&&r.contains(t)&&r.contains(n)&&null!==t&&!$o(t)&&Uo(t)===e}catch(e){return!1}}function Ko(e){return e instanceof Fo}function Uo(e){let t=e;for(;null!=t;){const e=Wo(t);if(Ko(e))return e;t=Ps(t)}return null}function Wo(e){return e?e.__lexicalEditor:null}function Vo(e){return Ke.test(e)?"rtl":Ue.test(e)?"ltr":null}function qo(e){return li(e)||e.isToken()}function jo(e){return qo(e)||e.isSegmented()}function Zo(e){return Ys(e)&&3===e.nodeType}function Go(e){return Ys(e)&&9===e.nodeType}function Jo(e){let t=e;for(;null!=t;){if(Zo(t))return t;t=t.firstChild}return null}function Yo(e,t,n){const r=We[t];if(null!==n&&(e&r)===(n&r))return e;let i=e^r;return"subscript"===t?i&=-65:"superscript"===t?i&=-33:"lowercase"===t?(i&=-513,i&=-1025):"uppercase"===t?(i&=-257,i&=-1025):"capitalize"===t&&(i&=-257,i&=-513),i}function Xo(e){return ri(e)||zr(e)||yo(e)}function Qo(e,t){const n=function(){const e=Ro;return Ro=null,e}();if(null!=(t=t||n&&n.__key))return void(e.__key=t);Zi(),Gi();const r=Yi(),i=Ji(),o=""+Po++;i._nodeMap.set(o,e),po(e)?r._dirtyElements.set(o,!0):r._dirtyLeaves.add(o),r._cloneNotNeeded.add(o),r._dirtyType=1,e.__key=o}function es(e){const t=e.getParent();if(null!==t){const n=e.getWritable(),r=t.getWritable(),i=e.getPreviousSibling(),o=e.getNextSibling(),s=null!==o?o.__key:null,l=null!==i?i.__key:null,a=null!==i?i.getWritable():null,c=null!==o?o.getWritable():null;null===i&&(r.__first=s),null===o&&(r.__last=l),null!==a&&(a.__next=s),null!==c&&(c.__prev=l),n.__prev=null,n.__next=null,n.__parent=null,r.__size--}}function ts(e){Gi(),Nr(e)&&pe(323,e.__key,e.__type);const t=e.getLatest(),n=t.__parent,r=Ji(),i=Yi(),o=r._nodeMap,s=i._dirtyElements;null!==n&&function(e,t,n){let r=e;for(;null!==r;){if(n.has(r))return;const e=t.get(r);if(void 0===e)break;n.set(r,!1),r=e.__parent}}(n,o,s);const l=t.__key;i._dirtyType=1,po(e)?s.set(l,!0):i._dirtyLeaves.add(l)}function ns(e){Zi();const t=Yi(),n=t._compositionKey;if(e!==n){if(t._compositionKey=e,null!==n){const e=is(n);null!==e&&e.getWritable()}if(null!==e){const t=is(e);null!==t&&t.getWritable()}}}function rs(){return ji()?null:Yi()._compositionKey}function is(e,t){const n=(t||Ji())._nodeMap.get(e);return void 0===n?null:n}function os(e,t){const n=ss(e,Yi());return void 0!==n?is(n,t):null}function ss(e,t){return e[`__lexicalKey_${t._key}`]}function ls(e,t){let n=e;for(;null!=n;){const e=os(n,t);if(null!==e)return e;n=Ps(n)}return null}function as(e){const t=e._decorators,n=Object.assign({},t);return e._pendingDecorators=n,n}function cs(e){return e.read((()=>us().getTextContent()))}function us(){return ds(Ji())}function ds(e){return e._nodeMap.get("root")}function hs(e){Zi();const t=Ji();null!==e&&(e.dirty=!0,e.setCachedNodes(null)),t._selection=e}function gs(e){const t=Yi(),n=function(e,t){let n=e;for(;null!=n;){const e=ss(n,t);if(void 0!==e)return e;n=Ps(n)}return null}(e,t);return null===n?e===t.getRootElement()?is("root"):null:is(n)}function ps(e){return/[\uD800-\uDBFF][\uDC00-\uDFFF]/g.test(e)}function fs(e){const t=[];let n=e;for(;null!==n;)t.push(n),n=n._parentEditor;return t}function ms(){return Math.random().toString(36).replace(/[^a-z]+/g,"").substring(0,5)}function ys(e){return Zo(e)?e.nodeValue:null}function bs(e,t,n){const r=Zs($s(t));if(null===r)return;const i=r.anchorNode;let{anchorOffset:o,focusOffset:s}=r;if(null!==i){let t=ys(i);const r=ls(i);if(null!==t&&ri(r)){if(t===De&&n){const e=n.length;t=n,o=e,s=e}null!==t&&_s(r,t,o,s,e)}}}function _s(e,t,n,r,i){let o=e;if(o.isAttached()&&(i||!o.isDirty())){const s=o.isComposing();let l=t;(s||i)&&t[t.length-1]===De&&(l=t.slice(0,-1));const a=o.getTextContent();if(i||l!==a){if(""===l){if(ns(null),Se||Ce||Te)o.remove();else{const e=Yi();setTimeout((()=>{e.update((()=>{o.isAttached()&&o.remove()}))}),20)}return}const t=o.getParent(),i=Oi(),a=o.getTextContentSize(),c=rs(),u=o.getKey();if(o.isToken()||null!==c&&u===c&&!s||gi(i)&&(null!==t&&!t.canInsertTextBefore()&&0===i.anchor.offset||i.anchor.key===e.__key&&0===i.anchor.offset&&!o.canInsertTextBefore()&&!s||i.focus.key===e.__key&&i.focus.offset===a&&!o.canInsertTextAfter()&&!s))return void o.markDirty();const d=Li();if(!gi(d)||null===n||null===r)return void xs(o,l,d);if(d.setTextNodeRange(o,n,o,r),o.isSegmented()){const e=ni(o.getTextContent());o.replace(e),o=e}xs(o,l,d)}}}function xs(e,t,n){if(e.setTextContent(t),gi(n)){const t=e.getKey();for(const r of["anchor","focus"]){const i=n[r];"text"===i.type&&i.key===t&&(i.offset=Nl(e,i.offset,"clamp"))}}}function Ss(e,t,n){const r=t[n]||!1;return"any"===r||r===e[n]}function Cs(e,t,n){return function(e,t){return Ss(e,t,"altKey")&&Ss(e,t,"ctrlKey")&&Ss(e,t,"shiftKey")&&Ss(e,t,"metaKey")}(e,n)&&e.key.toLowerCase()===t.toLowerCase()}const vs={ctrlKey:!be,metaKey:be},ws={altKey:be,ctrlKey:!be};function ks(e){return"Backspace"===e.key}function Ts(e){return Cs(e,"a",vs)}function Es(e,t){void 0===e.__lexicalClassNameCache&&(e.__lexicalClassNameCache={});const n=e.__lexicalClassNameCache,r=n[t];if(void 0!==r)return r;const i=e[t];if("string"==typeof i){const e=Ee(i);return n[t]=e,e}return i}function Ns(e,t,n,r,i){if(0===n.size)return;const o=r.__type,s=r.__key,l=t.get(o);void 0===l&&pe(33,o);const a=l.klass;let c=e.get(a);void 0===c&&(c=new Map,e.set(a,c));const u=c.get(s),d="destroyed"===u&&"created"===i;(void 0===u||d)&&c.set(s,d?"updated":i)}function As(e,t,n){const r=e.getParent();let i=n,o=e;return null!==r&&(t&&0===n?(i=o.getIndexWithinParent(),o=r):t||n!==o.getChildrenSize()||(i=o.getIndexWithinParent()+1,o=r)),o.getChildAtIndex(t?i-1:i)}function Ls(e,t){const n=e.offset;if("element"===e.type)return As(e.getNode(),t,n);{const r=e.getNode();if(t&&0===n||!t&&n===r.getTextContentSize()){const e=t?r.getPreviousSibling():r.getNextSibling();return null===e?As(r.getParentOrThrow(),t,r.getIndexWithinParent()+(t?0:1)):e}}return null}function Os(e){const t=$s(e).event,n=t&&t.inputType;return"insertFromPaste"===n||"insertFromPasteAsQuotation"===n}function Fs(e,t,n){return function(e,t,n){const r=fs(e);for(let i=4;i>=0;i--)for(let o=0;o{for(let t=0;to),cl(e,"clone")||(e.clone=t=>(Io(t),new e)),cl(e,"importJSON")||(e.importJSON=i&&i.$importJSON||(t=>(new e).updateFromJSON(t))),!cl(e,"importDOM")&&i)){const{importDOM:t}=i;t&&(e.importDOM=()=>t)}return{ownNodeConfig:i,ownNodeType:o}}const dl=(e,t)=>{let n=e;for(;null!=n&&!_o(n);){if(t(n))return n;n=n.getParent()}return null},hl={next:"previous",previous:"next"};class gl{origin;constructor(e){this.origin=e}[Symbol.iterator](){return Dl({hasNext:Sl,initial:this.getAdjacentCaret(),map:e=>e,step:e=>e.getAdjacentCaret()})}getAdjacentCaret(){return Tl(this.getNodeAtCaret(),this.direction)}getSiblingCaret(){return Tl(this.origin,this.direction)}remove(){const e=this.getNodeAtCaret();return e&&e.remove(),this}replaceOrInsert(e,t){const n=this.getNodeAtCaret();return e.is(this.origin)||e.is(n)||(null===n?this.insert(e):n.replace(e,t)),this}splice(e,t,n="next"){const r=n===this.direction?t:Array.from(t).reverse();let i=this;const o=this.getParentAtCaret(),s=new Map;for(let t=i.getAdjacentCaret();null!==t&&s.size0){const t=i.getNodeAtCaret();if(t)if(s.delete(t.getKey()),s.delete(e.getKey()),t.is(e)||i.origin.is(e));else{const n=e.getParent();n&&n.is(o)&&e.remove(),t.replace(e)}else null===t&&pe(263,Array.from(s).join(" "))}else i.insert(e);i=Tl(e,this.direction)}for(const e of s.values())e.remove();return this}}class pl extends gl{type="child";getLatest(){const e=this.origin.getLatest();return e===this.origin?this:Ll(e,this.direction)}getParentCaret(e="root"){return Tl(yl(this.getParentAtCaret(),e),this.direction)}getFlipped(){const e=ml(this.direction);return Tl(this.getNodeAtCaret(),e)||Ll(this.origin,e)}getParentAtCaret(){return this.origin}getChildCaret(){return this}isSameNodeCaret(e){return e instanceof pl&&this.direction===e.direction&&this.origin.is(e.origin)}isSamePointCaret(e){return this.isSameNodeCaret(e)}}const fl={root:_o,shadowRoot:Ks};function ml(e){return hl[e]}function yl(e,t="root"){return fl[t](e)?null:e}class bl extends gl{type="sibling";getLatest(){const e=this.origin.getLatest();return e===this.origin?this:Tl(e,this.direction)}getSiblingCaret(){return this}getParentAtCaret(){return this.origin.getParent()}getChildCaret(){return po(this.origin)?Ll(this.origin,this.direction):null}getParentCaret(e="root"){return Tl(yl(this.getParentAtCaret(),e),this.direction)}getFlipped(){const e=ml(this.direction);return Tl(this.getNodeAtCaret(),e)||Ll(this.origin.getParentOrThrow(),e)}isSamePointCaret(e){return e instanceof bl&&this.direction===e.direction&&this.origin.is(e.origin)}isSameNodeCaret(e){return(e instanceof bl||e instanceof _l)&&this.direction===e.direction&&this.origin.is(e.origin)}}class _l extends gl{type="text";offset;constructor(e,t){super(e),this.offset=t}getLatest(){const e=this.origin.getLatest();return e===this.origin?this:El(e,this.direction,this.offset)}getParentAtCaret(){return this.origin.getParent()}getChildCaret(){return null}getParentCaret(e="root"){return Tl(yl(this.getParentAtCaret(),e),this.direction)}getFlipped(){return El(this.origin,ml(this.direction),this.offset)}isSamePointCaret(e){return e instanceof _l&&this.direction===e.direction&&this.origin.is(e.origin)&&this.offset===e.offset}isSameNodeCaret(e){return(e instanceof bl||e instanceof _l)&&this.direction===e.direction&&this.origin.is(e.origin)}getSiblingCaret(){return Tl(this.origin,this.direction)}}function xl(e){return e instanceof _l}function Sl(e){return e instanceof bl}function Cl(e){return e instanceof pl}const vl={next:class extends _l{direction="next";getNodeAtCaret(){return this.origin.getNextSibling()}insert(e){return this.origin.insertAfter(e),this}},previous:class extends _l{direction="previous";getNodeAtCaret(){return this.origin.getPreviousSibling()}insert(e){return this.origin.insertBefore(e),this}}},wl={next:class extends bl{direction="next";getNodeAtCaret(){return this.origin.getNextSibling()}insert(e){return this.origin.insertAfter(e),this}},previous:class extends bl{direction="previous";getNodeAtCaret(){return this.origin.getPreviousSibling()}insert(e){return this.origin.insertBefore(e),this}}},kl={next:class extends pl{direction="next";getNodeAtCaret(){return this.origin.getFirstChild()}insert(e){return this.origin.splice(0,0,[e]),this}},previous:class extends pl{direction="previous";getNodeAtCaret(){return this.origin.getLastChild()}insert(e){return this.origin.splice(this.origin.getChildrenSize(),0,[e]),this}}};function Tl(e,t){return e?new wl[t](e):null}function El(e,t,n){return e?new vl[t](e,Nl(e,n)):null}function Nl(e,t,n="error"){const r=e.getTextContentSize();let i="next"===t?r:"previous"===t?0:t;return(i<0||i>r)&&("clamp"!==n&&fe(284,String(t),String(r),e.getKey()),i=i<0?0:r),i}function Al(e,t){return new Rl(e,t)}function Ll(e,t){return po(e)?new kl[t](e):null}function Ol(e){return e&&function(e){return e&&e.getChildCaret()||e}(e.getAdjacentCaret())}class Fl{type="node-caret-range";direction;anchor;focus;constructor(e,t,n){this.anchor=e,this.focus=t,this.direction=n}getLatest(){const e=this.anchor.getLatest(),t=this.focus.getLatest();return e===this.anchor&&t===this.focus?this:new Fl(e,t,this.direction)}isCollapsed(){return this.anchor.isSamePointCaret(this.focus)}getTextSlices(){const e=e=>{const t=this[e].getLatest();return xl(t)?function(e,t){const{direction:n,origin:r}=e;return Al(e,Nl(r,"focus"===t?ml(n):n)-e.offset)}(t,e):null},t=e("anchor"),n=e("focus");if(t&&n){const{caret:e}=t,{caret:r}=n;if(e.isSameNodeCaret(r))return[Al(e,r.offset-e.offset),null]}return[t,n]}iterNodeCarets(e="root"){const t=xl(this.anchor)?this.anchor.getSiblingCaret():this.anchor.getLatest(),n=this.focus.getLatest(),r=xl(n),i=t=>t.isSameNodeCaret(n)?null:Ol(t)||t.getParentCaret(e);return Dl({hasNext:e=>null!==e&&!(r&&n.isSameNodeCaret(e)),initial:t.isSameNodeCaret(n)?null:i(t),map:e=>e,step:i})}[Symbol.iterator](){return this.iterNodeCarets("root")}}class Rl{type="slice";caret;distance;constructor(e,t){this.caret=e,this.distance=t}getSliceIndices(){const{distance:e,caret:{offset:t}}=this,n=t+e;return n{let n;for(let r=a;rn.has(e.getKey())&&tl(e)));return u&&d?[u,d]:null}(u,d,a);if(h){const[e,t]=h;Ll(e,"previous").splice(0,t.getChildren()),t.remove()}const g=[u,d,...s,...l].find(Jl);if(g)return Pl(ea(Xl(g),e.direction));pe(269,JSON.stringify(s.map((e=>e.origin.__key))))}function Xl(e){const t=function(e){let t=e;for(;Cl(t);){const e=Ol(t);if(!Cl(e))break;t=e}return t}(e.getLatest()),{direction:n}=t;if(ri(t.origin))return xl(t)?t:El(t.origin,n,n);const r=t.getAdjacentCaret();return Sl(r)&&ri(r.origin)?El(r.origin,n,ml(n)):t}function Ql(e){return xl(e)&&e.offset!==Nl(e.origin,e.direction)}function ea(e,t){return e.direction===t?e:e.getFlipped()}function ta(e,t){return e.direction===t?e:Ml(ea(e.focus,t),ea(e.anchor,t))}function na(e){const{origin:t,offset:n,direction:r}=e;if(n===Nl(t,r))return e.getSiblingCaret();if(n===Nl(t,ml(r)))return Zl(e.getSiblingCaret());const[i]=t.splitText(n);return ri(i)||pe(281),ea(Tl(i,"next"),r)}function ra(e,t){return!0}function ia(e,{$copyElementNode:t=Us,$splitTextPointCaretNext:n=na,rootMode:r="shadowRoot",$shouldSplit:i=ra}={}){if(xl(e))return n(e);const o=e.getParentCaret(r);if(o){const{origin:n}=o;if(Cl(e)&&(!n.canBeEmpty()||!i(n,"first")))return Zl(o);const r=function(e){const t=[];for(let n=e.getAdjacentCaret();n;n=n.getAdjacentCaret())t.push(n.origin);return t}(e);(r.length>0||n.canBeEmpty()&&i(n,"last"))&&o.insert(t(n).splice(0,0,r))}return o}const oa=new Map;function sa(e){const t={};if(!e)return t;const n=e.split(";");for(const e of n)if(""!==e){const[n,r]=e.split(/:([^]+)/);n&&r&&(t[n.trim()]=r.trim())}return t}function la(e){let t=oa.get(e);return void 0===t&&(t=sa(e),oa.set(e,t)),t}function aa(e){let t="";for(const n in e)n&&(t+=`${n}: ${e[n]};`);return t}function ca(e){const t=nl().getElementByKey(e.getKey());if(null===t)return null;const n=t.ownerDocument.defaultView;return null===n?null:n.getComputedStyle(t)}function ua(e){return ca(_o(e)?e:e.getParentOrThrow())}function da(e){const t=ua(e);return null!==t&&"rtl"===t.direction}function ha(e,t,n="self"){const r=e.getStartEndPoints();if(t.isSelected(e)&&!jo(t)&&null!==r){const[i,o]=r,s=e.isBackward(),l=i.getNode(),a=o.getNode(),c=t.is(l),u=t.is(a);if(c||u){const[r,i]=yi(e),o=l.is(a),c=t.is(s?a:l),u=t.is(s?l:a);let d,h=0;o?(h=r>i?i:r,d=r>i?r:i):c?(h=s?i:r,d=void 0):u&&(h=0,d=s?r:i);const g=t.__text.slice(h,d);g!==t.__text&&("clone"===n&&(t=function(e){return(t=sl(e))[Er]=!0,t;var t}(t)),t.__text=g)}}return t}function ga(e){const t=e.getStyle(),n=sa(t);oa.set(t,n)}function pa(e,t){(gi(e)?e.isCollapsed():ri(e)||po(e))||function(e,...t){const n=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",e);for(const e of t)r.append("v",e);throw n.search=r.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}(280);const n=la(gi(e)?e.style:ri(e)?e.getStyle():e.getTextStyle()),r=Object.entries(t).reduce(((t,[r,i])=>("function"==typeof i?t[r]=i(n[r],e):null===i?delete t[r]:t[r]=i,t)),{...n}),i=aa(r);gi(e)||ri(e)?e.setStyle(i):e.setTextStyle(i),oa.set(i,r)}function fa(e,t){if(gi(e)&&e.isCollapsed()){pa(e,t);const n=e.anchor.getNode();po(n)&&n.isEmpty()&&pa(n,t)}!function(e){const t=Li();if(!t)return;const n=new Map,r=e=>n.get(e.getKey())||[0,e.getTextContentSize()];if(gi(t))for(const e of jl(t).getTextSlices())e&&n.set(e.caret.origin.getKey(),e.getSliceIndices());const i=t.getNodes();for(const t of i){if(!ri(t)||!t.canHaveFormat())continue;const[n,i]=r(t);i!==n&&(jo(t)||0===n&&i===t.getTextContentSize()?e(t):e(t.splitText(n,i)[0===n?0:1]))}gi(t)&&"text"===t.anchor.type&&"text"===t.focus.type&&t.anchor.key===t.focus.key&&function(e){if(e.isBackward()){const{anchor:t,focus:n}=e,{key:r,offset:i,type:o}=t;t.set(n.key,n.offset,n.type),n.set(r,i,o)}}(t)}((e=>{pa(e,t)}))}function ma(e){const t=ya(e);return null!==t&&"vertical-rl"===t.writingMode}function ya(e){const t=e.anchor.getNode();return po(t)?ca(t):ua(t)}function ba(e,t){let n=ma(e)?!t:t;_a(e)&&(n=!n);const r=Ul(e.focus,n?"previous":"next");if(Ql(r))return!1;for(const e of Il(r)){if(Cl(e))return!e.origin.isInline();if(!po(e.origin)){if(yo(e.origin))return!0;break}}return!1}function _a(e){const t=ya(e);return null!==t&&"rtl"===t.direction}function xa(e,t,n){const r=_a(e);let i;i=ma(e)||r?!n:n,function(e,t,n,r){e.modify(t?"extend":"move",n,r)}(e,t,i,"character")}function Sa(e,t,n){const r=la(e.getStyle());return null!==r&&r[t]||n}function Ca(e,t,n=""){let r=null;const i=e.getNodes(),o=e.anchor,s=e.focus,l=e.isBackward(),a=l?s.offset:o.offset,c=l?s.getNode():o.getNode();if(gi(e)&&e.isCollapsed()&&""!==e.style){const n=la(e.style);if(null!==n&&t in n)return n[t]}for(let e=0;e{"strong"!==t.tagName&&"em"!==t.tagName||e.removeAttribute("class")})),ge.setConfig({ALLOWED_TAGS:["a","action-text-attachment","b","blockquote","br","code","em","figcaption","figure","h1","h2","h3","h4","h5","h6","hr","i","img","li","mark","ol","p","pre","q","s","strong","ul","table","tbody","tr","th","td"],ALLOWED_ATTR:["alt","caption","class","content","content-type","contenteditable","data-direct-upload-id","data-sgid","filename","filesize","height","href","presentation","previewable","sgid","src","style","title","url","width"],SAFE_FOR_XML:!1});const Ta="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,Ea=Ta&&"documentMode"in document?document.documentMode:null;function Na(...e){const t=[];for(const n of e)if(n&&"string"==typeof n)for(const[e]of n.matchAll(/\S+/g))t.push(e);return t}function Aa(...e){return()=>{for(let t=e.length-1;t>=0;t--)e[t]();e.length=0}}function La(e,...t){const n=Na(...t);n.length>0&&e.classList.add(...n)}function Oa(e,...t){const n=Na(...t);n.length>0&&e.classList.remove(...n)}function Fa(e){return e?e.getAdjacentCaret():null}function Ra(e,t){let n=e;for(;null!=n;){if(n instanceof t)return n;n=n.getParent()}return null}function Ia(e){const t=Li()||Oi();let n;if(gi(t))n=Ul(t.focus,"next");else{if(null!=t){const e=t.getNodes(),r=e[e.length-1];r&&(n=Tl(r,"next"))}n=n||Ll(us(),"previous").getFlipped().insert(Eo())}const r=function(e,t,n){let r=ea(t,"next");for(let e=r;e;e=ia(e,n))r=e;return xl(r)&&ka(283),r.insert(e.isInline()?Eo().append(e):e),ea(Tl(e.getLatest(),"next"),t.direction)}(e,n),i=Ol(r);return Vl(Pl(Cl(i)?Xl(i):r)),e.getLatest()}function Pa(e,t){return null!==e&&Object.getPrototypeOf(e).constructor.name===t.name}function Ma(e,t){return Da(e,t,null)}function Da(e,t,n){let r=!1;for(const i of za(e))t(i)?null!==n&&n(i):(r=!0,po(i)&&Da(i,t,n||(e=>i.insertAfter(e))),i.remove());return r}function Ba(e,t){const n=[],r=Array.from(e).reverse();for(let e=r.pop();void 0!==e;e=r.pop())if(t(e))n.push(e);else if(po(e))for(const t of za(e))r.push(t);return n}function za(e){return function(e){return Dl({hasNext:Sl,initial:e.getAdjacentCaret(),map:e=>e.origin.getLatest(),step:e=>e.getAdjacentCaret()})}(Ll(e,"previous"))}Ta&&"InputEvent"in window&&!Ea&&new window.InputEvent("input");const $a=Symbol.for("preact-signals");function Ha(){if(Va>1)return void Va--;let e,t=!1;for(;void 0!==Ua;){let n=Ua;for(Ua=void 0,qa++;void 0!==n;){const r=n.o;if(n.o=void 0,n.f&=-3,!(8&n.f)&&Ya(n))try{n.c()}catch(n){t||(e=n,t=!0)}n=r}}if(qa=0,Va--,t)throw e}let Ka,Ua;function Wa(e){const t=Ka;Ka=void 0;try{return e()}finally{Ka=t}}let Va=0,qa=0,ja=0;function Za(e){if(void 0===Ka)return;let t=e.n;return void 0===t||t.t!==Ka?(t={i:0,S:e,p:Ka.s,n:void 0,t:Ka,e:void 0,x:void 0,r:t},void 0!==Ka.s&&(Ka.s.n=t),Ka.s=t,e.n=t,32&Ka.f&&e.S(t),t):-1===t.i?(t.i=0,void 0!==t.n&&(t.n.p=t.p,void 0!==t.p&&(t.p.n=t.n),t.p=Ka.s,t.n=void 0,Ka.s.n=t,Ka.s=t),t):void 0}function Ga(e,t){this.v=e,this.i=0,this.n=void 0,this.t=void 0,this.W=null==t?void 0:t.watched,this.Z=null==t?void 0:t.unwatched,this.name=null==t?void 0:t.name}function Ja(e,t){return new Ga(e,t)}function Ya(e){for(let t=e.s;void 0!==t;t=t.n)if(t.S.i!==t.i||!t.S.h()||t.S.i!==t.i)return!0;return!1}function Xa(e){for(let t=e.s;void 0!==t;t=t.n){const n=t.S.n;if(void 0!==n&&(t.r=n),t.S.n=t,t.i=-1,void 0===t.n){e.s=t;break}}}function Qa(e){let t,n=e.s;for(;void 0!==n;){const e=n.p;-1===n.i?(n.S.U(n),void 0!==e&&(e.n=n.n),void 0!==n.n&&(n.n.p=e)):t=n,n.S.n=n.r,void 0!==n.r&&(n.r=void 0),n=e}e.s=t}function ec(e,t){Ga.call(this,void 0),this.x=e,this.s=void 0,this.g=ja-1,this.f=4,this.W=null==t?void 0:t.watched,this.Z=null==t?void 0:t.unwatched,this.name=null==t?void 0:t.name}function tc(e){const t=e.u;if(e.u=void 0,"function"==typeof t){Va++;const n=Ka;Ka=void 0;try{t()}catch(t){throw e.f&=-2,e.f|=8,nc(e),t}finally{Ka=n,Ha()}}}function nc(e){for(let t=e.s;void 0!==t;t=t.n)t.S.U(t);e.x=void 0,e.s=void 0,tc(e)}function rc(e){if(Ka!==this)throw new Error("Out-of-order effect");Qa(this),Ka=e,this.f&=-2,8&this.f&&nc(this),Ha()}function ic(e,t){this.x=e,this.u=void 0,this.s=void 0,this.o=void 0,this.f=32,this.name=null==t?void 0:t.name}function oc(e,t){const n=new ic(e,t);try{n.c()}catch(e){throw n.d(),e}const r=n.d.bind(n);return r[Symbol.dispose]=r,r}Ga.prototype.brand=$a,Ga.prototype.h=function(){return!0},Ga.prototype.S=function(e){const t=this.t;t!==e&&void 0===e.e&&(e.x=t,this.t=e,void 0!==t?t.e=e:Wa((()=>{var e;null==(e=this.W)||e.call(this)})))},Ga.prototype.U=function(e){if(void 0!==this.t){const t=e.e,n=e.x;void 0!==t&&(t.x=n,e.e=void 0),void 0!==n&&(n.e=t,e.x=void 0),e===this.t&&(this.t=n,void 0===n&&Wa((()=>{var e;null==(e=this.Z)||e.call(this)})))}},Ga.prototype.subscribe=function(e){return oc((()=>{const t=this.value,n=Ka;Ka=void 0;try{e(t)}finally{Ka=n}}),{name:"sub"})},Ga.prototype.valueOf=function(){return this.value},Ga.prototype.toString=function(){return this.value+""},Ga.prototype.toJSON=function(){return this.value},Ga.prototype.peek=function(){const e=Ka;Ka=void 0;try{return this.value}finally{Ka=e}},Object.defineProperty(Ga.prototype,"value",{get(){const e=Za(this);return void 0!==e&&(e.i=this.i),this.v},set(e){if(e!==this.v){if(qa>100)throw new Error("Cycle detected");this.v=e,this.i++,ja++,Va++;try{for(let e=this.t;void 0!==e;e=e.x)e.t.N()}finally{Ha()}}}}),ec.prototype=new Ga,ec.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if(32==(36&this.f))return!0;if(this.f&=-5,this.g===ja)return!0;if(this.g=ja,this.f|=1,this.i>0&&!Ya(this))return this.f&=-2,!0;const e=Ka;try{Xa(this),Ka=this;const e=this.x();(16&this.f||this.v!==e||0===this.i)&&(this.v=e,this.f&=-17,this.i++)}catch(e){this.v=e,this.f|=16,this.i++}return Ka=e,Qa(this),this.f&=-2,!0},ec.prototype.S=function(e){if(void 0===this.t){this.f|=36;for(let e=this.s;void 0!==e;e=e.n)e.S.S(e)}Ga.prototype.S.call(this,e)},ec.prototype.U=function(e){if(void 0!==this.t&&(Ga.prototype.U.call(this,e),void 0===this.t)){this.f&=-33;for(let e=this.s;void 0!==e;e=e.n)e.S.U(e)}},ec.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(let e=this.t;void 0!==e;e=e.x)e.t.N()}},Object.defineProperty(ec.prototype,"value",{get(){if(1&this.f)throw new Error("Cycle detected");const e=Za(this);if(this.h(),void 0!==e&&(e.i=this.i),16&this.f)throw this.v;return this.v}}),ic.prototype.c=function(){const e=this.S();try{if(8&this.f)return;if(void 0===this.x)return;const e=this.x();"function"==typeof e&&(this.u=e)}finally{e()}},ic.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,tc(this),Xa(this),Va++;const e=Ka;return Ka=this,rc.bind(this,e)},ic.prototype.N=function(){2&this.f||(this.f|=2,this.o=Ua,Ua=this)},ic.prototype.d=function(){this.f|=8,1&this.f||nc(this)},ic.prototype.dispose=function(){this.d()};new Set;Symbol.for("@lexical/extension/LexicalBuilder");function sc(e,...t){const n=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",e);for(const e of t)r.append("v",e);throw n.search=r.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function lc(e){let t=1,n=e.getParent();for(;null!=n;){if(kc(n)){const e=n.getParent();if(Fc(e)){t++,n=e.getParent();continue}sc(40)}return t}return t}function ac(e){let t=e.getParent();Fc(t)||sc(40);let n=t;for(;null!==n;)n=n.getParent(),Fc(n)&&(t=n);return t}function cc(e){let t=[];const n=e.getChildren().filter(kc);for(let e=0;e0&&e.append(...i),t.remove()}function yc(e){const t="check"!==e.getListType();let n=e.getStart();for(const r of e.getChildren())kc(r)&&(r.getValue()!==n&&r.setValue(n),t&&null!=r.getLatest().__checked&&r.setChecked(void 0),Fc(r.getFirstChild())||n++)}function bc(e){const t=new Set;if(uc(e)||t.has(e.getKey()))return;const n=e.getParent(),r=e.getNextSibling(),i=e.getPreviousSibling();if(uc(r)&&uc(i)){const n=i.getFirstChild();if(Fc(n)){n.append(e);const i=r.getFirstChild();Fc(i)&&(pc(n,i.getChildren()),r.remove(),t.add(r.getKey()))}}else if(uc(r)){const t=r.getFirstChild();if(Fc(t)){const n=t.getFirstChild();null!==n&&n.insertBefore(e)}}else if(uc(i)){const t=i.getFirstChild();Fc(t)&&t.append(e)}else if(Fc(n)){const t=wc().setTextFormat(e.getTextFormat()).setTextStyle(e.getTextStyle()),o=Oc(n.getListType()).setTextFormat(n.getTextFormat()).setTextStyle(n.getTextStyle());t.append(o),o.append(e),i?i.insertAfter(t):r?r.insertBefore(t):n.append(t)}}function _c(e){if(uc(e))return;const t=e.getParent(),n=t?t.getParent():void 0;if(Fc(n?n.getParent():void 0)&&kc(n)&&Fc(t)){const r=t?t.getFirstChild():void 0,i=t?t.getLastChild():void 0;if(e.is(r))n.insertBefore(e),t.isEmpty()&&n.remove();else if(e.is(i))n.insertAfter(e),t.isEmpty()&&n.remove();else{const r=t.getListType(),i=wc(),o=Oc(r);i.append(o),e.getPreviousSiblings().forEach((e=>o.append(e)));const s=wc(),l=Oc(r);s.append(l),pc(l,e.getNextSiblings()),n.insertBefore(i),n.insertAfter(s),n.replace(e)}}}function xc(...e){const t=[];for(const n of e)if(n&&"string"==typeof n)for(const[e]of n.matchAll(/\S+/g))t.push(e);return t}let Sc=class extends go{__value;__checked;$config(){return this.config("listitem",{$transform:e=>{if(null==e.__checked)return;const t=e.getParent();Fc(t)&&"check"!==t.getListType()&&null!=e.getChecked()&&e.setChecked(void 0)},extends:go,importDOM:{li:()=>({conversion:Cc,priority:0})}})}constructor(e=1,t=void 0,n){super(n),this.__value=void 0===e?1:e,this.__checked=t}afterCloneFrom(e){super.afterCloneFrom(e),this.__value=e.__value,this.__checked=e.__checked}createDOM(e){const t=document.createElement("li");return this.updateListItemDOM(null,t,e),t}updateListItemDOM(e,t,n){!function(e,t,n){const r=t.getParent();!Fc(r)||"check"!==r.getListType()||Fc(t.getFirstChild())?(e.removeAttribute("role"),e.removeAttribute("tabIndex"),e.removeAttribute("aria-checked")):(e.setAttribute("role","checkbox"),e.setAttribute("tabIndex","-1"),n&&t.__checked===n.__checked||e.setAttribute("aria-checked",t.getChecked()?"true":"false"))}(t,this,e),t.value=this.__value,function(e,t,n){const r=[],i=[],o=t.list,s=o?o.listitem:void 0;let l;if(o&&o.nested&&(l=o.nested.listitem),void 0!==s&&r.push(...xc(s)),o){const e=n.getParent(),t=Fc(e)&&"check"===e.getListType(),s=n.getChecked();t&&!s||i.push(o.listitemUnchecked),t&&s||i.push(o.listitemChecked),t&&r.push(s?o.listitemChecked:o.listitemUnchecked)}if(void 0!==l){const e=xc(l);n.getChildren().some((e=>Fc(e)))?r.push(...e):i.push(...e)}i.length>0&&Oa(e,...i),r.length>0&&La(e,...r)}(t,n.theme,this);const r=e?e.__style:"",i=this.__style;r!==i&&(""===i?t.removeAttribute("style"):t.style.cssText=i),function(e,t,n){const r=la(t.__textStyle);for(const t in r)e.style.setProperty(`--listitem-marker-${t}`,r[t]);if(n)for(const t in la(n.__textStyle))t in r||e.style.removeProperty(`--listitem-marker-${t}`)}(t,this,e)}updateDOM(e,t,n){const r=t;return this.updateListItemDOM(e,r,n),!1}updateFromJSON(e){return super.updateFromJSON(e).setValue(e.value).setChecked(e.checked)}exportDOM(e){const t=this.createDOM(e._config),n=this.getFormatType();n&&(t.style.textAlign=n);const r=this.getDirection();return r&&(t.dir=r),{element:t}}exportJSON(){return{...super.exportJSON(),checked:this.getChecked(),value:this.getValue()}}append(...e){for(let t=0;t{e.append(t)}))),this.remove(),0===n.getChildrenSize()&&n.remove(),e}insertAfter(e,t=!0){const n=this.getParentOrThrow();if(Fc(n)||sc(39),kc(e))return super.insertAfter(e,t);const r=this.getNextSiblings();if(n.insertAfter(e,t),0!==r.length){const i=Oc(n.getListType());r.forEach((e=>i.append(e))),e.insertAfter(i,t)}return e}remove(e){const t=this.getPreviousSibling(),n=this.getNextSibling();super.remove(e),t&&n&&uc(t)&&uc(n)&&(mc(t.getFirstChild(),n.getFirstChild()),n.remove())}insertNewAfter(e,t=!0){const n=wc().updateFromJSON(this.exportJSON()).setChecked(!this.getChecked()&&void 0);return this.insertAfter(n,t),n}collapseAtStart(e){const t=Eo();this.getChildren().forEach((e=>t.append(e)));const n=this.getParentOrThrow(),r=n.getParentOrThrow(),i=kc(r);if(1===n.getChildrenSize())if(i)n.remove(),r.select();else{n.insertBefore(t),n.remove();const r=e.anchor,i=e.focus,o=t.getKey();"element"===r.type&&r.getNode().is(this)&&r.set(o,r.offset,"element"),"element"===i.type&&i.getNode().is(this)&&i.set(o,i.offset,"element")}else n.insertBefore(t),this.remove();return!0}getValue(){return this.getLatest().__value}setValue(e){const t=this.getWritable();return t.__value=e,t}getChecked(){const e=this.getLatest();let t;const n=this.getParent();return Fc(n)&&(t=n.getListType()),"check"===t?Boolean(e.__checked):void 0}setChecked(e){const t=this.getWritable();return t.__checked=e,t}toggleChecked(){const e=this.getWritable();return e.setChecked(!e.__checked)}getIndent(){const e=this.getParent();if(null===e||!this.isAttached())return this.getLatest().__indent;let t=e.getParentOrThrow(),n=0;for(;kc(t);)t=t.getParentOrThrow().getParentOrThrow(),n++;return n}setIndent(e){"number"!=typeof e&&sc(117),(e=Math.floor(e))>=0||sc(199);let t=this.getIndent();for(;t!==e;)t0&&"INPUT"===t.children[0].tagName)return vc(t.children[0]);const t=e.getAttribute("aria-checked");return{node:wc("true"===t||"false"!==t&&void 0)}}function vc(e){return"checkbox"!==e.getAttribute("type")?{node:null}:{node:wc(e.hasAttribute("checked"))}}function wc(e){return Ws(new Sc(void 0,e))}function kc(e){return e instanceof Sc}let Tc=class extends go{__tag;__start;__listType;$config(){return this.config("list",{$transform:e=>{!function(e){const t=e.getNextSibling();Fc(t)&&e.getListType()===t.getListType()&&mc(e,t)}(e),yc(e)},extends:go,importDOM:{ol:()=>({conversion:Ac,priority:0}),ul:()=>({conversion:Ac,priority:0})}})}constructor(e="number",t=1,n){super(n);const r=Lc[e]||e;this.__listType=r,this.__tag="number"===r?"ol":"ul",this.__start=t}afterCloneFrom(e){super.afterCloneFrom(e),this.__listType=e.__listType,this.__tag=e.__tag,this.__start=e.__start}getTag(){return this.getLatest().__tag}setListType(e){const t=this.getWritable();return t.__listType=e,t.__tag="number"===e?"ol":"ul",t}getListType(){return this.getLatest().__listType}getStart(){return this.getLatest().__start}setStart(e){const t=this.getWritable();return t.__start=e,t}createDOM(e,t){const n=this.__tag,r=document.createElement(n);return 1!==this.__start&&r.setAttribute("start",String(this.__start)),r.__lexicalListType=this.__listType,Ec(r,e.theme,this),r}updateDOM(e,t,n){return e.__tag!==this.__tag||e.__listType!==this.__listType||(Ec(t,n.theme,this),!1)}updateFromJSON(e){return super.updateFromJSON(e).setListType(e.listType).setStart(e.start)}exportDOM(e){const t=this.createDOM(e._config,e);return Js(t)&&(1!==this.__start&&t.setAttribute("start",String(this.__start)),"check"===this.__listType&&t.setAttribute("__lexicalListType","check")),{element:t}}exportJSON(){return{...super.exportJSON(),listType:this.getListType(),start:this.getStart(),tag:this.getTag()}}canBeEmpty(){return!1}canIndent(){return!1}splice(e,t,n){let r=n;for(let e=0;e1?r.push(...e):i.push(...e)}}i.length>0&&Oa(e,...i),r.length>0&&La(e,...r)}function Nc(e){const t=[];for(let n=0;n1&&e.forEach((e=>{Fc(e)&&t.push(dc(e))}))}else t.push(dc(r))}return t}function Ac(e){const t=e.nodeName.toLowerCase();let n=null;return"ol"===t?n=Oc("number",e.start):"ul"===t&&(n=function(e){if("check"===e.getAttribute("__lexicallisttype")||e.classList.contains("contains-task-list")||"1"===e.getAttribute("data-is-checklist"))return!0;for(const t of e.childNodes)if(Js(t)&&t.hasAttribute("aria-checked"))return!0;return!1}(e)?Oc("check"):Oc("bullet")),{after:Nc,node:n}}const Lc={ol:"number",ul:"bullet"};function Oc(e="number",t=1){return Ws(new Tc(e,t))}function Fc(e){return e instanceof Tc}const Rc=on("UPDATE_LIST_START_COMMAND"),Ic=on("INSERT_UNORDERED_LIST_COMMAND"),Pc=on("INSERT_ORDERED_LIST_COMMAND"),Mc=on("REMOVE_LIST_COMMAND");function Dc(e){return Aa(e.registerCommand(Pc,(()=>(gc("number"),!0)),1),e.registerCommand(Rc,(e=>{const{listNodeKey:t,newStart:n}=e,r=is(t);return!!Fc(r)&&("number"===r.getListType()&&(r.setStart(n),yc(r)),!0)}),1),e.registerCommand(Ic,(()=>(gc("bullet"),!0)),1),e.registerCommand(Mc,(()=>(function(){const e=Li();if(gi(e)){const t=new Set,n=e.getNodes(),r=e.anchor.getNode();if(hc(r,n))t.add(ac(r));else for(let e=0;efunction(){const e=Li();if(!gi(e)||!e.isCollapsed())return!1;const t=e.anchor.getNode();if(!kc(t)||0!==t.getChildrenSize())return!1;const n=ac(t),r=t.getParent();Fc(r)||sc(40);const i=r.getParent();let o;if(Ks(i))o=Eo(),n.insertAfter(o);else{if(!kc(i))return!1;o=wc(),i.insertAfter(o)}o.setTextStyle(e.style).setTextFormat(e.format).select();const s=t.getNextSiblings();if(s.length>0){const e=Oc(r.getListType());if(kc(o)){const t=wc();t.append(e),o.insertAfter(t)}else o.insertAfter(e);e.append(...s)}return function(e){let t=e;for(;null==t.getNextSibling()&&null==t.getPreviousSibling();){const e=t.getParent();if(null==e||!kc(e)&&!Fc(e))break;t=e}t.remove()}(t),!0}()),1),e.registerNodeTransform(Sc,(e=>{const t=e.getFirstChild();if(t){if(ri(t)){const n=t.getStyle(),r=t.getFormat();e.getTextStyle()!==n&&e.setTextStyle(n),e.getTextFormat()!==r&&e.setTextFormat(r)}}else{const t=Li();gi(t)&&(t.style!==e.getTextStyle()||t.format!==e.getTextFormat())&&t.isCollapsed()&&e.is(t.anchor.getNode())&&e.setTextStyle(t.style).setTextFormat(t.format)}})),e.registerNodeTransform(jr,(e=>{const t=e.getParent();if(kc(t)&&e.is(t.getFirstChild())){const n=e.getStyle(),r=e.getFormat();n===t.getTextStyle()&&r===t.getTextFormat()||t.setTextStyle(n).setTextFormat(r)}})))}function Bc(e,t){const n=Go(t)?t.body.childNodes:t.childNodes;let r=[];const i=[];for(const t of n)if(!Hc.has(t.nodeName)){const n=Kc(t,e,i,!1);null!==n&&(r=r.concat(n))}return function(e){for(const t of e)t.getNextSibling()instanceof wo&&t.insertAfter(Br());for(const t of e){const e=t.getChildren();for(const n of e)t.insertBefore(n);t.remove()}}(i),r}function zc(e,t){if("undefined"==typeof document||"undefined"==typeof window&&void 0===global.window)throw new Error("To use $generateHtmlFromNodes in headless mode please initialize a headless browser implementation such as JSDom before calling this function.");const n=document.createElement("div"),r=us().getChildren();for(let i=0;i{const e=new wo;return n.push(e),e}:Eo)),null==l?h.length>0?s=s.concat(h):el(e)&&function(e){return null!=e.nextSibling&&null!=e.previousSibling&&(Qs(e.nextSibling)&&Qs(e.previousSibling))}(e)&&(s=s.concat(Br())):po(l)&&l.append(...h),s}function Uc(e,...t){const n=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",e);for(const e of t)r.append("v",e);throw n.search=r.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function Wc(e,t,n){const r=e.getData("application/x-lexical-editor");if(r)try{const e=JSON.parse(r);if(e.namespace===n._config.namespace&&Array.isArray(e.nodes))return Vc(n,function(e){const t=[];for(let n=0;ne}).createHTML(e):e}(i),"text/html")),t)}catch(e){console.error(e)}const s=o||e.getData("text/uri-list");if(null!=s)if(gi(t)){const e=s.split(/(\r?\n|\t)/);""===e[e.length-1]&&e.pop();for(let t=0;t{e.update((()=>{r(Gc(e,t,n))}))}));const r=e.getRootElement(),i=e._window||window,o=i.document,s=Zs(i);if(null===r||null===s)return!1;const l=o.createElement("span");l.style.cssText="position: fixed; top: -1000px;",l.append(o.createTextNode("#")),r.append(l);const a=new Range;return a.setStart(l,0),a.setEnd(l,1),s.removeAllRanges(),s.addRange(a),new Promise(((t,r)=>{const s=e.registerCommand(Hn,(r=>(Pa(r,ClipboardEvent)&&(s(),null!==jc&&(i.clearTimeout(jc),jc=null),t(Gc(e,r,n))),!0)),4);jc=i.setTimeout((()=>{s(),jc=null,t(!1)}),50),o.execCommand("copy"),l.remove()}))}function Gc(e,t,n){if(void 0===n){const t=Zs(e._window),r=Li();if(!r||r.isCollapsed())return!1;if(!t)return!1;const i=t.anchorNode,o=t.focusNode;if(null!==i&&null!==o&&!Ho(e,i,o))return!1;n=Yc(r)}t.preventDefault();const r=t.clipboardData;return null!==r&&(function(e,t){for(const[n]of Jc)void 0===t[n]&&e.setData(n,"");for(const n in t){const r=t[n];void 0!==r&&e.setData(n,r)}}(r,n),!0)}const Jc=[["text/html",function(e,t=Li()){return null==t&&Uc(166),gi(t)&&t.isCollapsed()||0===t.getNodes().length?"":zc(e,t)}],["application/x-lexical-editor",function(e,t=Li()){return null==t&&Uc(166),gi(t)&&t.isCollapsed()||0===t.getNodes().length?null:JSON.stringify(function(e,t){const n=[],r=us().getChildren();for(let i=0;i({conversion:pu,priority:0})}}exportDOM(e){const{element:t}=super.exportDOM(e);if(Js(t)){this.isEmpty()&&t.append(document.createElement("br"));const e=this.getFormatType();e&&(t.style.textAlign=e);const n=this.getDirection();n&&(t.dir=n)}return{element:t}}static importJSON(e){return cu().updateFromJSON(e)}insertNewAfter(e,t){const n=Eo(),r=this.getDirection();return n.setDirection(r),this.insertAfter(n,t),n}collapseAtStart(){const e=Eo();return this.getChildren().forEach((t=>e.append(t))),this.replace(e),!0}canMergeWhenEmpty(){return!0}};function cu(){return Ws(new au)}function uu(e){return e instanceof au}let du=class e extends go{__tag;static getType(){return"heading"}static clone(t){return new e(t.__tag,t.__key)}constructor(e,t){super(t),this.__tag=e}getTag(){return this.__tag}setTag(e){const t=this.getWritable();return this.__tag=e,t}createDOM(e){const t=this.__tag,n=document.createElement(t),r=e.theme.heading;if(void 0!==r){La(n,r[t])}return n}updateDOM(e,t,n){return e.__tag!==this.__tag}static importDOM(){return{h1:e=>({conversion:gu,priority:0}),h2:e=>({conversion:gu,priority:0}),h3:e=>({conversion:gu,priority:0}),h4:e=>({conversion:gu,priority:0}),h5:e=>({conversion:gu,priority:0}),h6:e=>({conversion:gu,priority:0}),p:e=>{const t=e.firstChild;return null!==t&&hu(t)?{conversion:()=>({node:null}),priority:3}:null},span:e=>hu(e)?{conversion:e=>({node:fu("h1")}),priority:3}:null}}exportDOM(e){const{element:t}=super.exportDOM(e);if(Js(t)){this.isEmpty()&&t.append(document.createElement("br"));const e=this.getFormatType();e&&(t.style.textAlign=e);const n=this.getDirection();n&&(t.dir=n)}return{element:t}}static importJSON(e){return fu(e.tag).updateFromJSON(e)}updateFromJSON(e){return super.updateFromJSON(e).setTag(e.tag)}exportJSON(){return{...super.exportJSON(),tag:this.getTag()}}insertNewAfter(e,t=!0){const n=e?e.anchor.offset:0,r=this.getLastDescendant(),i=!r||e&&e.anchor.key===r.getKey()&&n===r.getTextContentSize()||!e?Eo():fu(this.getTag()),o=this.getDirection();if(i.setDirection(o),this.insertAfter(i,t),0===n&&!this.isEmpty()&&e){const e=Eo();e.select(),this.replace(e,!0)}return i}collapseAtStart(){const e=this.isEmpty()?Eo():fu(this.getTag());return this.getChildren().forEach((t=>e.append(t))),this.replace(e),!0}extractWithChild(){return!0}};function hu(e){return"span"===e.nodeName.toLowerCase()&&"26pt"===e.style.fontSize}function gu(e){const t=e.nodeName.toLowerCase();let n=null;return"h1"!==t&&"h2"!==t&&"h3"!==t&&"h4"!==t&&"h5"!==t&&"h6"!==t||(n=fu(t),null!==e.style&&(ll(e,n),n.setFormat(e.style.textAlign))),{node:n}}function pu(e){const t=cu();return null!==e.style&&(t.setFormat(e.style.textAlign),ll(e,t)),{node:t}}function fu(e="h1"){return Ws(new du(e))}function mu(e){return e instanceof du}function yu(e){let t=null;if(Pa(e,DragEvent)?t=e.dataTransfer:Pa(e,ClipboardEvent)&&(t=e.clipboardData),null===t)return[!1,[],!1];const n=t.types,r=n.includes("Files"),i=n.includes("text/html")||n.includes("text/plain");return[r,Array.from(t.files),i]}function bu(e){const t=Li();if(!gi(t))return!1;const n=new Set,r=t.getNodes();for(let t=0;tpo(e)&&!e.isInline()));if(null===s)continue;const l=s.getKey();s.canIndent()&&!n.has(l)&&(n.add(l),e(s))}return n.size>0}function _u(e){return yo(ls(e))}function xu(e){for(const t of["lowercase","uppercase","capitalize"])e.hasFormat(t)&&e.toggleFormat(t)}function Su(e){return Aa(e.registerCommand(an,(e=>{const t=Li();return!!fi(t)&&(t.clear(),!0)}),0),e.registerCommand(cn,(e=>{const t=Li();return gi(t)?(t.deleteCharacter(e),!0):!!fi(t)&&(t.deleteNodes(),!0)}),0),e.registerCommand(fn,(e=>{const t=Li();return!!gi(t)&&(t.deleteWord(e),!0)}),0),e.registerCommand(mn,(e=>{const t=Li();return!!gi(t)&&(t.deleteLine(e),!0)}),0),e.registerCommand(hn,(t=>{const n=Li();if("string"==typeof t)null!==n&&n.insertText(t);else{if(null===n)return!1;const r=t.dataTransfer;if(null!=r)Wc(r,n,e);else if(gi(n)){const e=t.data;return e&&n.insertText(e),!0}}return!0}),0),e.registerCommand(pn,(()=>{const e=Li();return!!gi(e)&&(e.removeText(),!0)}),0),e.registerCommand(yn,(e=>{const t=Li();return!!gi(t)&&(t.formatText(e),!0)}),0),e.registerCommand(Dn,(e=>{const t=Li();if(!gi(t)&&!fi(t))return!1;const n=t.getNodes();for(const t of n){const n=dl(t,(e=>po(e)&&!e.isInline()));null!==n&&n.setFormat(e)}return!0}),0),e.registerCommand(un,(e=>{const t=Li();return!!gi(t)&&(t.insertLineBreak(e),!0)}),0),e.registerCommand(dn,(()=>{const e=Li();return!!gi(e)&&(e.insertParagraph(),!0)}),0),e.registerCommand(Rn,(()=>(Di([si()]),!0)),0),e.registerCommand(In,(()=>bu((e=>{const t=e.getIndent();e.setIndent(t+1)}))),0),e.registerCommand(Pn,(()=>bu((e=>{const t=e.getIndent();t>0&&e.setIndent(Math.max(0,t-1))}))),0),e.registerCommand(kn,(e=>{const t=Li();if(fi(t)){const n=t.getNodes();if(n.length>0)return e.preventDefault(),n[0].selectPrevious(),!0}else if(gi(t)){const n=Ls(t.focus,!0);if(!e.shiftKey&&yo(n)&&!n.isIsolated()&&!n.isInline())return n.selectPrevious(),e.preventDefault(),!0}return!1}),0),e.registerCommand(Tn,(e=>{const t=Li();if(fi(t)){const n=t.getNodes();if(n.length>0)return e.preventDefault(),n[0].selectNext(0,0),!0}else if(gi(t)){if(function(e){const t=e.focus;return"root"===t.key&&t.offset===us().getChildrenSize()}(t))return e.preventDefault(),!0;const n=Ls(t.focus,!1);if(!e.shiftKey&&yo(n)&&!n.isIsolated()&&!n.isInline())return n.selectNext(),e.preventDefault(),!0}return!1}),0),e.registerCommand(vn,(e=>{const t=Li();if(fi(t)){const n=t.getNodes();if(n.length>0)return e.preventDefault(),da(n[0])?n[0].selectNext(0,0):n[0].selectPrevious(),!0}if(!gi(t))return!1;if(ba(t,!0)){const n=e.shiftKey;return e.preventDefault(),xa(t,n,!0),!0}return!1}),0),e.registerCommand(Sn,(e=>{const t=Li();if(fi(t)){const n=t.getNodes();if(n.length>0)return e.preventDefault(),da(n[0])?n[0].selectPrevious():n[0].selectNext(0,0),!0}if(!gi(t))return!1;const n=e.shiftKey;return!!ba(t,!1)&&(e.preventDefault(),xa(t,n,!1),!0)}),0),e.registerCommand(An,(t=>{if(_u(t.target))return!1;const n=Li();if(gi(n)){if(function(e){if(!e.isCollapsed())return!1;const{anchor:t}=e;if(0!==t.offset)return!1;const n=t.getNode();if(_o(n))return!1;const r=function(e){const t=dl(e,(e=>po(e)&&!e.isInline()));return po(t)||ka(4,e.__key),t}(n);return r.getIndent()>0&&(r.is(n)||n.is(r.getFirstDescendant()))}(n))return t.preventDefault(),e.dispatchCommand(Pn,void 0);if(iu&&"ko-KR"===navigator.language)return!1}else if(!fi(n))return!1;return t.preventDefault(),e.dispatchCommand(cn,!0)}),0),e.registerCommand(On,(t=>{if(_u(t.target))return!1;const n=Li();return!(!gi(n)&&!fi(n))&&(t.preventDefault(),e.dispatchCommand(cn,!1))}),0),e.registerCommand(En,(t=>{const n=Li();if(!gi(n))return!1;if(xu(n),null!==t){if((iu||ru||su)&&nu)return!1;if(t.preventDefault(),t.shiftKey)return e.dispatchCommand(un,!1)}return e.dispatchCommand(dn,void 0)}),0),e.registerCommand(Ln,(()=>!!gi(Li())&&(e.blur(),!0)),0),e.registerCommand(Mn,(t=>{const[,n]=yu(t);if(n.length>0){const r=Xc(t.clientX,t.clientY);if(null!==r){const{offset:t,node:i}=r,o=ls(i);if(null!==o){const e=Ei();if(ri(o))e.anchor.set(o.getKey(),t,"text"),e.focus.set(o.getKey(),t,"text");else{const t=o.getParentOrThrow().getKey(),n=o.getIndexWithinParent()+1;e.anchor.set(t,n,"element"),e.focus.set(t,n,"element")}hs(vt(e))}e.dispatchCommand(lu,n)}return t.preventDefault(),!0}return!!gi(Li())}),0),e.registerCommand(Bn,(e=>{const[t]=yu(e),n=Li();return!(t&&!gi(n))}),0),e.registerCommand(zn,(e=>{const[t]=yu(e),n=Li();if(t&&!gi(n))return!1;const r=Xc(e.clientX,e.clientY);if(null!==r){yo(ls(r.node))&&e.preventDefault()}return!0}),0),e.registerCommand(Un,(()=>(function(e){const t=us();if(gi(e)){const t=e.anchor,n=e.focus,r=t.getNode().getTopLevelElementOrThrow().getParentOrThrow();return t.set(r.getKey(),0,"element"),n.set(r.getKey(),r.getChildrenSize(),"element"),vt(e),e}{const e=t.select(0,t.getChildrenSize());hs(vt(e))}}(),!0)),0),e.registerCommand(Hn,(t=>(Zc(e,Pa(t,ClipboardEvent)?t:null),!0)),0),e.registerCommand(Kn,(t=>(async function(e,t){await Zc(t,Pa(e,ClipboardEvent)?e:null),t.update((()=>{const e=Li();gi(e)?e.removeText():fi(e)&&e.getNodes().forEach((e=>e.remove()))}))}(t,e),!0)),0),e.registerCommand(gn,(t=>{const[,n,r]=yu(t);return n.length>0&&!r?(e.dispatchCommand(lu,n),!0):(!Ys(t.target)||!$o(t.target))&&(null!==Li()&&(function(e,t){e.preventDefault(),t.update((()=>{const n=Li(),r=Pa(e,InputEvent)||Pa(e,KeyboardEvent)?null:e.clipboardData;null!=r&&null!==n&&Wc(r,n,t)}),{tag:"paste"})}(t,e),!0))}),0),e.registerCommand(Nn,(e=>{const t=Li();return gi(t)&&xu(t),!1}),0),e.registerCommand(Fn,(e=>{const t=Li();return gi(t)&&xu(t),!1}),0))}var Cu;s.languages.javascript=s.languages.extend("clike",{"class-name":[s.languages.clike["class-name"],{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$A-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\.(?:constructor|prototype))/,lookbehind:!0}],keyword:[{pattern:/((?:^|\})\s*)catch\b/,lookbehind:!0},{pattern:/(^|[^.]|\.\.\.\s*)\b(?:as|assert(?=\s*\{)|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally(?=\s*(?:\{|$))|for|from(?=\s*(?:['"]|$))|function|(?:get|set)(?=\s*(?:[#\[$\w\xA0-\uFFFF]|$))|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)\b/,lookbehind:!0}],function:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/,number:{pattern:RegExp(/(^|[^\w$])/.source+"(?:"+/NaN|Infinity/.source+"|"+/0[bB][01]+(?:_[01]+)*n?/.source+"|"+/0[oO][0-7]+(?:_[0-7]+)*n?/.source+"|"+/0[xX][\dA-Fa-f]+(?:_[\dA-Fa-f]+)*n?/.source+"|"+/\d+(?:_\d+)*n/.source+"|"+/(?:\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\.\d+(?:_\d+)*)(?:[Ee][+-]?\d+(?:_\d+)*)?/.source+")"+/(?![\w$])/.source),lookbehind:!0},operator:/--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/}),s.languages.javascript["class-name"][0].pattern=/(\b(?:class|extends|implements|instanceof|interface|new)\s+)[\w.\\]+/,s.languages.insertBefore("javascript","keyword",{regex:{pattern:RegExp(/((?:^|[^$\w\xA0-\uFFFF."'\])\s]|\b(?:return|yield))\s*)/.source+/\//.source+"(?:"+/(?:\[(?:[^\]\\\r\n]|\\.)*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}/.source+"|"+/(?:\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.|\[(?:[^[\]\\\r\n]|\\.)*\])*\])*\]|\\.|[^/\\\[\r\n])+\/[dgimyus]{0,7}v[dgimyus]{0,7}/.source+")"+/(?=(?:\s|\/\*(?:[^*]|\*(?!\/))*\*\/)*(?:$|[\r\n,.;:})\]]|\/\/))/.source),lookbehind:!0,greedy:!0,inside:{"regex-source":{pattern:/^(\/)[\s\S]+(?=\/[a-z]*$)/,lookbehind:!0,alias:"language-regex",inside:s.languages.regex},"regex-delimiter":/^\/|\/$/,"regex-flags":/^[a-z]+$/}},"function-variable":{pattern:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)\s*=>))/,alias:"function"},parameter:[{pattern:/(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/,lookbehind:!0,inside:s.languages.javascript},{pattern:/(^|[^$\w\xA0-\uFFFF])(?!\s)[_$a-z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i,lookbehind:!0,inside:s.languages.javascript},{pattern:/(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/,lookbehind:!0,inside:s.languages.javascript},{pattern:/((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*)\(\s*|\]\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*\{)/,lookbehind:!0,inside:s.languages.javascript}],constant:/\b[A-Z](?:[A-Z_]|\dx?)*\b/}),s.languages.insertBefore("javascript","string",{hashbang:{pattern:/^#!.*/,greedy:!0,alias:"comment"},"template-string":{pattern:/`(?:\\[\s\S]|\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}|(?!\$\{)[^\\`])*`/,greedy:!0,inside:{"template-punctuation":{pattern:/^`|`$/,alias:"string"},interpolation:{pattern:/((?:^|[^\\])(?:\\{2})*)\$\{(?:[^{}]|\{(?:[^{}]|\{[^}]*\})*\})+\}/,lookbehind:!0,inside:{"interpolation-punctuation":{pattern:/^\$\{|\}$/,alias:"punctuation"},rest:s.languages.javascript}},string:/[\s\S]+/}},"string-property":{pattern:/((?:^|[,{])[ \t]*)(["'])(?:\\(?:\r\n|[\s\S])|(?!\2)[^\\\r\n])*\2(?=\s*:)/m,lookbehind:!0,greedy:!0,alias:"property"}}),s.languages.insertBefore("javascript","operator",{"literal-property":{pattern:/((?:^|[,{])[ \t]*)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*:)/m,lookbehind:!0,alias:"property"}}),s.languages.markup&&(s.languages.markup.tag.addInlined("script","javascript"),s.languages.markup.tag.addAttribute(/on(?:abort|blur|change|click|composition(?:end|start|update)|dblclick|error|focus(?:in|out)?|key(?:down|up)|load|mouse(?:down|enter|leave|move|out|over|up)|reset|resize|scroll|select|slotchange|submit|unload|wheel)/.source,"javascript")),s.languages.js=s.languages.javascript,function(e){var t=/(?:\\.|[^\\\n\r]|(?:\n|\r\n?)(?![\r\n]))/.source;function n(e){return e=e.replace(//g,(function(){return t})),RegExp(/((?:^|[^\\])(?:\\{2})*)/.source+"(?:"+e+")")}var r=/(?:\\.|``(?:[^`\r\n]|`(?!`))+``|`[^`\r\n]+`|[^\\|\r\n`])+/.source,i=/\|?__(?:\|__)+\|?(?:(?:\n|\r\n?)|(?![\s\S]))/.source.replace(/__/g,(function(){return r})),o=/\|?[ \t]*:?-{3,}:?[ \t]*(?:\|[ \t]*:?-{3,}:?[ \t]*)+\|?(?:\n|\r\n?)/.source;e.languages.markdown=e.languages.extend("markup",{}),e.languages.insertBefore("markdown","prolog",{"front-matter-block":{pattern:/(^(?:\s*[\r\n])?)---(?!.)[\s\S]*?[\r\n]---(?!.)/,lookbehind:!0,greedy:!0,inside:{punctuation:/^---|---$/,"front-matter":{pattern:/\S+(?:\s+\S+)*/,alias:["yaml","language-yaml"],inside:e.languages.yaml}}},blockquote:{pattern:/^>(?:[\t ]*>)*/m,alias:"punctuation"},table:{pattern:RegExp("^"+i+o+"(?:"+i+")*","m"),inside:{"table-data-rows":{pattern:RegExp("^("+i+o+")(?:"+i+")*$"),lookbehind:!0,inside:{"table-data":{pattern:RegExp(r),inside:e.languages.markdown},punctuation:/\|/}},"table-line":{pattern:RegExp("^("+i+")"+o+"$"),lookbehind:!0,inside:{punctuation:/\||:?-{3,}:?/}},"table-header-row":{pattern:RegExp("^"+i+"$"),inside:{"table-header":{pattern:RegExp(r),alias:"important",inside:e.languages.markdown},punctuation:/\|/}}}},code:[{pattern:/((?:^|\n)[ \t]*\n|(?:^|\r\n?)[ \t]*\r\n?)(?: {4}|\t).+(?:(?:\n|\r\n?)(?: {4}|\t).+)*/,lookbehind:!0,alias:"keyword"},{pattern:/^```[\s\S]*?^```$/m,greedy:!0,inside:{"code-block":{pattern:/^(```.*(?:\n|\r\n?))[\s\S]+?(?=(?:\n|\r\n?)^```$)/m,lookbehind:!0},"code-language":{pattern:/^(```).+/,lookbehind:!0},punctuation:/```/}}],title:[{pattern:/\S.*(?:\n|\r\n?)(?:==+|--+)(?=[ \t]*$)/m,alias:"important",inside:{punctuation:/==+$|--+$/}},{pattern:/(^\s*)#.+/m,lookbehind:!0,alias:"important",inside:{punctuation:/^#+|#+$/}}],hr:{pattern:/(^\s*)([*-])(?:[\t ]*\2){2,}(?=\s*$)/m,lookbehind:!0,alias:"punctuation"},list:{pattern:/(^\s*)(?:[*+-]|\d+\.)(?=[\t ].)/m,lookbehind:!0,alias:"punctuation"},"url-reference":{pattern:/!?\[[^\]]+\]:[\t ]+(?:\S+|<(?:\\.|[^>\\])+>)(?:[\t ]+(?:"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\((?:\\.|[^)\\])*\)))?/,inside:{variable:{pattern:/^(!?\[)[^\]]+/,lookbehind:!0},string:/(?:"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\((?:\\.|[^)\\])*\))$/,punctuation:/^[\[\]!:]|[<>]/},alias:"url"},bold:{pattern:n(/\b__(?:(?!_)|_(?:(?!_))+_)+__\b|\*\*(?:(?!\*)|\*(?:(?!\*))+\*)+\*\*/.source),lookbehind:!0,greedy:!0,inside:{content:{pattern:/(^..)[\s\S]+(?=..$)/,lookbehind:!0,inside:{}},punctuation:/\*\*|__/}},italic:{pattern:n(/\b_(?:(?!_)|__(?:(?!_))+__)+_\b|\*(?:(?!\*)|\*\*(?:(?!\*))+\*\*)+\*/.source),lookbehind:!0,greedy:!0,inside:{content:{pattern:/(^.)[\s\S]+(?=.$)/,lookbehind:!0,inside:{}},punctuation:/[*_]/}},strike:{pattern:n(/(~~?)(?:(?!~))+\2/.source),lookbehind:!0,greedy:!0,inside:{content:{pattern:/(^~~?)[\s\S]+(?=\1$)/,lookbehind:!0,inside:{}},punctuation:/~~?/}},"code-snippet":{pattern:/(^|[^\\`])(?:``[^`\r\n]+(?:`[^`\r\n]+)*``(?!`)|`[^`\r\n]+`(?!`))/,lookbehind:!0,greedy:!0,alias:["code","keyword"]},url:{pattern:n(/!?\[(?:(?!\]))+\](?:\([^\s)]+(?:[\t ]+"(?:\\.|[^"\\])*")?\)|[ \t]?\[(?:(?!\]))+\])/.source),lookbehind:!0,greedy:!0,inside:{operator:/^!/,content:{pattern:/(^\[)[^\]]+(?=\])/,lookbehind:!0,inside:{}},variable:{pattern:/(^\][ \t]?\[)[^\]]+(?=\]$)/,lookbehind:!0},url:{pattern:/(^\]\()[^\s)]+/,lookbehind:!0},string:{pattern:/(^[ \t]+)"(?:\\.|[^"\\])*"(?=\)$)/,lookbehind:!0}}}}),["url","bold","italic","strike"].forEach((function(t){["url","bold","italic","strike","code-snippet"].forEach((function(n){t!==n&&(e.languages.markdown[t].inside.content.inside[n]=e.languages.markdown[n])}))})),e.hooks.add("after-tokenize",(function(e){"markdown"!==e.language&&"md"!==e.language||function e(t){if(t&&"string"!=typeof t)for(var n=0,r=t.length;n",quot:'"'},a=String.fromCodePoint||String.fromCharCode;e.languages.md=e.languages.markdown}(s),s.languages.c=s.languages.extend("clike",{comment:{pattern:/\/\/(?:[^\r\n\\]|\\(?:\r\n?|\n|(?![\r\n])))*|\/\*[\s\S]*?(?:\*\/|$)/,greedy:!0},string:{pattern:/"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"/,greedy:!0},"class-name":{pattern:/(\b(?:enum|struct)\s+(?:__attribute__\s*\(\([\s\S]*?\)\)\s*)?)\w+|\b[a-z]\w*_t\b/,lookbehind:!0},keyword:/\b(?:_Alignas|_Alignof|_Atomic|_Bool|_Complex|_Generic|_Imaginary|_Noreturn|_Static_assert|_Thread_local|__attribute__|asm|auto|break|case|char|const|continue|default|do|double|else|enum|extern|float|for|goto|if|inline|int|long|register|return|short|signed|sizeof|static|struct|switch|typedef|typeof|union|unsigned|void|volatile|while)\b/,function:/\b[a-z_]\w*(?=\s*\()/i,number:/(?:\b0x(?:[\da-f]+(?:\.[\da-f]*)?|\.[\da-f]+)(?:p[+-]?\d+)?|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?)[ful]{0,4}/i,operator:/>>=?|<<=?|->|([-+&|:])\1|[?:~]|[-+*/%&|^!=<>]=?/}),s.languages.insertBefore("c","string",{char:{pattern:/'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n]){0,32}'/,greedy:!0}}),s.languages.insertBefore("c","string",{macro:{pattern:/(^[\t ]*)#\s*[a-z](?:[^\r\n\\/]|\/(?!\*)|\/\*(?:[^*]|\*(?!\/))*\*\/|\\(?:\r\n|[\s\S]))*/im,lookbehind:!0,greedy:!0,alias:"property",inside:{string:[{pattern:/^(#\s*include\s*)<[^>]+>/,lookbehind:!0},s.languages.c.string],char:s.languages.c.char,comment:s.languages.c.comment,"macro-name":[{pattern:/(^#\s*define\s+)\w+\b(?!\()/i,lookbehind:!0},{pattern:/(^#\s*define\s+)\w+\b(?=\()/i,lookbehind:!0,alias:"function"}],directive:{pattern:/^(#\s*)[a-z]+/,lookbehind:!0,alias:"keyword"},"directive-hash":/^#/,punctuation:/##|\\(?=[\r\n])/,expression:{pattern:/\S[\s\S]*/,inside:s.languages.c}}}}),s.languages.insertBefore("c","function",{constant:/\b(?:EOF|NULL|SEEK_CUR|SEEK_END|SEEK_SET|__DATE__|__FILE__|__LINE__|__TIMESTAMP__|__TIME__|__func__|stderr|stdin|stdout)\b/}),delete s.languages.c.boolean,function(e){var t=/(?:"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"|'(?:\\(?:\r\n|[\s\S])|[^'\\\r\n])*')/;e.languages.css={comment:/\/\*[\s\S]*?\*\//,atrule:{pattern:RegExp("@[\\w-](?:"+/[^;{\s"']|\s+(?!\s)/.source+"|"+t.source+")*?"+/(?:;|(?=\s*\{))/.source),inside:{rule:/^@[\w-]+/,"selector-function-argument":{pattern:/(\bselector\s*\(\s*(?![\s)]))(?:[^()\s]|\s+(?![\s)])|\((?:[^()]|\([^()]*\))*\))+(?=\s*\))/,lookbehind:!0,alias:"selector"},keyword:{pattern:/(^|[^\w-])(?:and|not|only|or)(?![\w-])/,lookbehind:!0}}},url:{pattern:RegExp("\\burl\\((?:"+t.source+"|"+/(?:[^\\\r\n()"']|\\[\s\S])*/.source+")\\)","i"),greedy:!0,inside:{function:/^url/i,punctuation:/^\(|\)$/,string:{pattern:RegExp("^"+t.source+"$"),alias:"url"}}},selector:{pattern:RegExp("(^|[{}\\s])[^{}\\s](?:[^{};\"'\\s]|\\s+(?![\\s{])|"+t.source+")*(?=\\s*\\{)"),lookbehind:!0},string:{pattern:t,greedy:!0},property:{pattern:/(^|[^-\w\xA0-\uFFFF])(?!\s)[-_a-z\xA0-\uFFFF](?:(?!\s)[-\w\xA0-\uFFFF])*(?=\s*:)/i,lookbehind:!0},important:/!important\b/i,function:{pattern:/(^|[^-a-z0-9])[-a-z0-9]+(?=\()/i,lookbehind:!0},punctuation:/[(){};:,]/},e.languages.css.atrule.inside.rest=e.languages.css;var n=e.languages.markup;n&&(n.tag.addInlined("style","css"),n.tag.addAttribute("style","css"))}(s),s.languages.objectivec=s.languages.extend("c",{string:{pattern:/@?"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"/,greedy:!0},keyword:/\b(?:asm|auto|break|case|char|const|continue|default|do|double|else|enum|extern|float|for|goto|if|in|inline|int|long|register|return|self|short|signed|sizeof|static|struct|super|switch|typedef|typeof|union|unsigned|void|volatile|while)\b|(?:@interface|@end|@implementation|@protocol|@class|@public|@protected|@private|@property|@try|@catch|@finally|@throw|@synthesize|@dynamic|@selector)\b/,operator:/-[->]?|\+\+?|!=?|<>?=?|==?|&&?|\|\|?|[~^%?*\/@]/}),delete s.languages.objectivec["class-name"],s.languages.objc=s.languages.objectivec,s.languages.sql={comment:{pattern:/(^|[^\\])(?:\/\*[\s\S]*?\*\/|(?:--|\/\/|#).*)/,lookbehind:!0},variable:[{pattern:/@(["'`])(?:\\[\s\S]|(?!\1)[^\\])+\1/,greedy:!0},/@[\w.$]+/],string:{pattern:/(^|[^@\\])("|')(?:\\[\s\S]|(?!\2)[^\\]|\2\2)*\2/,greedy:!0,lookbehind:!0},identifier:{pattern:/(^|[^@\\])`(?:\\[\s\S]|[^`\\]|``)*`/,greedy:!0,lookbehind:!0,inside:{punctuation:/^`|`$/}},function:/\b(?:AVG|COUNT|FIRST|FORMAT|LAST|LCASE|LEN|MAX|MID|MIN|MOD|NOW|ROUND|SUM|UCASE)(?=\s*\()/i,keyword:/\b(?:ACTION|ADD|AFTER|ALGORITHM|ALL|ALTER|ANALYZE|ANY|APPLY|AS|ASC|AUTHORIZATION|AUTO_INCREMENT|BACKUP|BDB|BEGIN|BERKELEYDB|BIGINT|BINARY|BIT|BLOB|BOOL|BOOLEAN|BREAK|BROWSE|BTREE|BULK|BY|CALL|CASCADED?|CASE|CHAIN|CHAR(?:ACTER|SET)?|CHECK(?:POINT)?|CLOSE|CLUSTERED|COALESCE|COLLATE|COLUMNS?|COMMENT|COMMIT(?:TED)?|COMPUTE|CONNECT|CONSISTENT|CONSTRAINT|CONTAINS(?:TABLE)?|CONTINUE|CONVERT|CREATE|CROSS|CURRENT(?:_DATE|_TIME|_TIMESTAMP|_USER)?|CURSOR|CYCLE|DATA(?:BASES?)?|DATE(?:TIME)?|DAY|DBCC|DEALLOCATE|DEC|DECIMAL|DECLARE|DEFAULT|DEFINER|DELAYED|DELETE|DELIMITERS?|DENY|DESC|DESCRIBE|DETERMINISTIC|DISABLE|DISCARD|DISK|DISTINCT|DISTINCTROW|DISTRIBUTED|DO|DOUBLE|DROP|DUMMY|DUMP(?:FILE)?|DUPLICATE|ELSE(?:IF)?|ENABLE|ENCLOSED|END|ENGINE|ENUM|ERRLVL|ERRORS|ESCAPED?|EXCEPT|EXEC(?:UTE)?|EXISTS|EXIT|EXPLAIN|EXTENDED|FETCH|FIELDS|FILE|FILLFACTOR|FIRST|FIXED|FLOAT|FOLLOWING|FOR(?: EACH ROW)?|FORCE|FOREIGN|FREETEXT(?:TABLE)?|FROM|FULL|FUNCTION|GEOMETRY(?:COLLECTION)?|GLOBAL|GOTO|GRANT|GROUP|HANDLER|HASH|HAVING|HOLDLOCK|HOUR|IDENTITY(?:COL|_INSERT)?|IF|IGNORE|IMPORT|INDEX|INFILE|INNER|INNODB|INOUT|INSERT|INT|INTEGER|INTERSECT|INTERVAL|INTO|INVOKER|ISOLATION|ITERATE|JOIN|KEYS?|KILL|LANGUAGE|LAST|LEAVE|LEFT|LEVEL|LIMIT|LINENO|LINES|LINESTRING|LOAD|LOCAL|LOCK|LONG(?:BLOB|TEXT)|LOOP|MATCH(?:ED)?|MEDIUM(?:BLOB|INT|TEXT)|MERGE|MIDDLEINT|MINUTE|MODE|MODIFIES|MODIFY|MONTH|MULTI(?:LINESTRING|POINT|POLYGON)|NATIONAL|NATURAL|NCHAR|NEXT|NO|NONCLUSTERED|NULLIF|NUMERIC|OFF?|OFFSETS?|ON|OPEN(?:DATASOURCE|QUERY|ROWSET)?|OPTIMIZE|OPTION(?:ALLY)?|ORDER|OUT(?:ER|FILE)?|OVER|PARTIAL|PARTITION|PERCENT|PIVOT|PLAN|POINT|POLYGON|PRECEDING|PRECISION|PREPARE|PREV|PRIMARY|PRINT|PRIVILEGES|PROC(?:EDURE)?|PUBLIC|PURGE|QUICK|RAISERROR|READS?|REAL|RECONFIGURE|REFERENCES|RELEASE|RENAME|REPEAT(?:ABLE)?|REPLACE|REPLICATION|REQUIRE|RESIGNAL|RESTORE|RESTRICT|RETURN(?:ING|S)?|REVOKE|RIGHT|ROLLBACK|ROUTINE|ROW(?:COUNT|GUIDCOL|S)?|RTREE|RULE|SAVE(?:POINT)?|SCHEMA|SECOND|SELECT|SERIAL(?:IZABLE)?|SESSION(?:_USER)?|SET(?:USER)?|SHARE|SHOW|SHUTDOWN|SIMPLE|SMALLINT|SNAPSHOT|SOME|SONAME|SQL|START(?:ING)?|STATISTICS|STATUS|STRIPED|SYSTEM_USER|TABLES?|TABLESPACE|TEMP(?:ORARY|TABLE)?|TERMINATED|TEXT(?:SIZE)?|THEN|TIME(?:STAMP)?|TINY(?:BLOB|INT|TEXT)|TOP?|TRAN(?:SACTIONS?)?|TRIGGER|TRUNCATE|TSEQUAL|TYPES?|UNBOUNDED|UNCOMMITTED|UNDEFINED|UNION|UNIQUE|UNLOCK|UNPIVOT|UNSIGNED|UPDATE(?:TEXT)?|USAGE|USE|USER|USING|VALUES?|VAR(?:BINARY|CHAR|CHARACTER|YING)|VIEW|WAITFOR|WARNINGS|WHEN|WHERE|WHILE|WITH(?: ROLLUP|IN)?|WORK|WRITE(?:TEXT)?|YEAR)\b/i,boolean:/\b(?:FALSE|NULL|TRUE)\b/i,number:/\b0x[\da-f]+\b|\b\d+(?:\.\d*)?|\B\.\d+\b/i,operator:/[-+*\/=%^~]|&&?|\|\|?|!=?|<(?:=>?|<|>)?|>[>=]?|\b(?:AND|BETWEEN|DIV|ILIKE|IN|IS|LIKE|NOT|OR|REGEXP|RLIKE|SOUNDS LIKE|XOR)\b/i,punctuation:/[;[\]()`,.]/},(Cu=s.languages.powershell={comment:[{pattern:/(^|[^`])<#[\s\S]*?#>/,lookbehind:!0},{pattern:/(^|[^`])#.*/,lookbehind:!0}],string:[{pattern:/"(?:`[\s\S]|[^`"])*"/,greedy:!0,inside:null},{pattern:/'(?:[^']|'')*'/,greedy:!0}],namespace:/\[[a-z](?:\[(?:\[[^\]]*\]|[^\[\]])*\]|[^\[\]])*\]/i,boolean:/\$(?:false|true)\b/i,variable:/\$\w+\b/,function:[/\b(?:Add|Approve|Assert|Backup|Block|Checkpoint|Clear|Close|Compare|Complete|Compress|Confirm|Connect|Convert|ConvertFrom|ConvertTo|Copy|Debug|Deny|Disable|Disconnect|Dismount|Edit|Enable|Enter|Exit|Expand|Export|Find|ForEach|Format|Get|Grant|Group|Hide|Import|Initialize|Install|Invoke|Join|Limit|Lock|Measure|Merge|Move|New|Open|Optimize|Out|Ping|Pop|Protect|Publish|Push|Read|Receive|Redo|Register|Remove|Rename|Repair|Request|Reset|Resize|Resolve|Restart|Restore|Resume|Revoke|Save|Search|Select|Send|Set|Show|Skip|Sort|Split|Start|Step|Stop|Submit|Suspend|Switch|Sync|Tee|Test|Trace|Unblock|Undo|Uninstall|Unlock|Unprotect|Unpublish|Unregister|Update|Use|Wait|Watch|Where|Write)-[a-z]+\b/i,/\b(?:ac|cat|chdir|clc|cli|clp|clv|compare|copy|cp|cpi|cpp|cvpa|dbp|del|diff|dir|ebp|echo|epal|epcsv|epsn|erase|fc|fl|ft|fw|gal|gbp|gc|gci|gcs|gdr|gi|gl|gm|gp|gps|group|gsv|gu|gv|gwmi|iex|ii|ipal|ipcsv|ipsn|irm|iwmi|iwr|kill|lp|ls|measure|mi|mount|move|mp|mv|nal|ndr|ni|nv|ogv|popd|ps|pushd|pwd|rbp|rd|rdr|ren|ri|rm|rmdir|rni|rnp|rp|rv|rvpa|rwmi|sal|saps|sasv|sbp|sc|select|set|shcm|si|sl|sleep|sls|sort|sp|spps|spsv|start|sv|swmi|tee|trcm|type|write)\b/i],keyword:/\b(?:Begin|Break|Catch|Class|Continue|Data|Define|Do|DynamicParam|Else|ElseIf|End|Exit|Filter|Finally|For|ForEach|From|Function|If|InlineScript|Parallel|Param|Process|Return|Sequence|Switch|Throw|Trap|Try|Until|Using|Var|While|Workflow)\b/i,operator:{pattern:/(^|\W)(?:!|-(?:b?(?:and|x?or)|as|(?:Not)?(?:Contains|In|Like|Match)|eq|ge|gt|is(?:Not)?|Join|le|lt|ne|not|Replace|sh[lr])\b|-[-=]?|\+[+=]?|[*\/%]=?)/i,lookbehind:!0},punctuation:/[|{}[\];(),.]/}).string[0].inside={function:{pattern:/(^|[^`])\$\((?:\$\([^\r\n()]*\)|(?!\$\()[^\r\n)])*\)/,lookbehind:!0,inside:Cu},boolean:Cu.boolean,variable:Cu.variable};var vu;vu||(vu=1,s.languages.python={comment:{pattern:/(^|[^\\])#.*/,lookbehind:!0,greedy:!0},"string-interpolation":{pattern:/(?:f|fr|rf)(?:("""|''')[\s\S]*?\1|("|')(?:\\.|(?!\2)[^\\\r\n])*\2)/i,greedy:!0,inside:{interpolation:{pattern:/((?:^|[^{])(?:\{\{)*)\{(?!\{)(?:[^{}]|\{(?!\{)(?:[^{}]|\{(?!\{)(?:[^{}])+\})+\})+\}/,lookbehind:!0,inside:{"format-spec":{pattern:/(:)[^:(){}]+(?=\}$)/,lookbehind:!0},"conversion-option":{pattern:/![sra](?=[:}]$)/,alias:"punctuation"},rest:null}},string:/[\s\S]+/}},"triple-quoted-string":{pattern:/(?:[rub]|br|rb)?("""|''')[\s\S]*?\1/i,greedy:!0,alias:"string"},string:{pattern:/(?:[rub]|br|rb)?("|')(?:\\.|(?!\1)[^\\\r\n])*\1/i,greedy:!0},function:{pattern:/((?:^|\s)def[ \t]+)[a-zA-Z_]\w*(?=\s*\()/g,lookbehind:!0},"class-name":{pattern:/(\bclass\s+)\w+/i,lookbehind:!0},decorator:{pattern:/(^[\t ]*)@\w+(?:\.\w+)*/m,lookbehind:!0,alias:["annotation","punctuation"],inside:{punctuation:/\./}},keyword:/\b(?:_(?=\s*:)|and|as|assert|async|await|break|case|class|continue|def|del|elif|else|except|exec|finally|for|from|global|if|import|in|is|lambda|match|nonlocal|not|or|pass|print|raise|return|try|while|with|yield)\b/,builtin:/\b(?:__import__|abs|all|any|apply|ascii|basestring|bin|bool|buffer|bytearray|bytes|callable|chr|classmethod|cmp|coerce|compile|complex|delattr|dict|dir|divmod|enumerate|eval|execfile|file|filter|float|format|frozenset|getattr|globals|hasattr|hash|help|hex|id|input|int|intern|isinstance|issubclass|iter|len|list|locals|long|map|max|memoryview|min|next|object|oct|open|ord|pow|property|range|raw_input|reduce|reload|repr|reversed|round|set|setattr|slice|sorted|staticmethod|str|sum|super|tuple|type|unichr|unicode|vars|xrange|zip)\b/,boolean:/\b(?:False|None|True)\b/,number:/\b0(?:b(?:_?[01])+|o(?:_?[0-7])+|x(?:_?[a-f0-9])+)\b|(?:\b\d+(?:_\d+)*(?:\.(?:\d+(?:_\d+)*)?)?|\B\.\d+(?:_\d+)*)(?:e[+-]?\d+(?:_\d+)*)?j?(?!\w)/i,operator:/[-+%=]=?|!=|:=|\*\*?=?|\/\/?=?|<[<=>]?|>[=>]?|[&|^~]/,punctuation:/[{}[\];(),.:]/},s.languages.python["string-interpolation"].inside.interpolation.inside.rest=s.languages.python,s.languages.py=s.languages.python);var wu;wu||(wu=1,function(e){for(var t=/\/\*(?:[^*/]|\*(?!\/)|\/(?!\*)|)*\*\//.source,n=0;n<2;n++)t=t.replace(//g,(function(){return t}));t=t.replace(//g,(function(){return/[^\s\S]/.source})),e.languages.rust={comment:[{pattern:RegExp(/(^|[^\\])/.source+t),lookbehind:!0,greedy:!0},{pattern:/(^|[^\\:])\/\/.*/,lookbehind:!0,greedy:!0}],string:{pattern:/b?"(?:\\[\s\S]|[^\\"])*"|b?r(#*)"(?:[^"]|"(?!\1))*"\1/,greedy:!0},char:{pattern:/b?'(?:\\(?:x[0-7][\da-fA-F]|u\{(?:[\da-fA-F]_*){1,6}\}|.)|[^\\\r\n\t'])'/,greedy:!0},attribute:{pattern:/#!?\[(?:[^\[\]"]|"(?:\\[\s\S]|[^\\"])*")*\]/,greedy:!0,alias:"attr-name",inside:{string:null}},"closure-params":{pattern:/([=(,:]\s*|\bmove\s*)\|[^|]*\||\|[^|]*\|(?=\s*(?:\{|->))/,lookbehind:!0,greedy:!0,inside:{"closure-punctuation":{pattern:/^\||\|$/,alias:"punctuation"},rest:null}},"lifetime-annotation":{pattern:/'\w+/,alias:"symbol"},"fragment-specifier":{pattern:/(\$\w+:)[a-z]+/,lookbehind:!0,alias:"punctuation"},variable:/\$\w+/,"function-definition":{pattern:/(\bfn\s+)\w+/,lookbehind:!0,alias:"function"},"type-definition":{pattern:/(\b(?:enum|struct|trait|type|union)\s+)\w+/,lookbehind:!0,alias:"class-name"},"module-declaration":[{pattern:/(\b(?:crate|mod)\s+)[a-z][a-z_\d]*/,lookbehind:!0,alias:"namespace"},{pattern:/(\b(?:crate|self|super)\s*)::\s*[a-z][a-z_\d]*\b(?:\s*::(?:\s*[a-z][a-z_\d]*\s*::)*)?/,lookbehind:!0,alias:"namespace",inside:{punctuation:/::/}}],keyword:[/\b(?:Self|abstract|as|async|await|become|box|break|const|continue|crate|do|dyn|else|enum|extern|final|fn|for|if|impl|in|let|loop|macro|match|mod|move|mut|override|priv|pub|ref|return|self|static|struct|super|trait|try|type|typeof|union|unsafe|unsized|use|virtual|where|while|yield)\b/,/\b(?:bool|char|f(?:32|64)|[ui](?:8|16|32|64|128|size)|str)\b/],function:/\b[a-z_]\w*(?=\s*(?:::\s*<|\())/,macro:{pattern:/\b\w+!/,alias:"property"},constant:/\b[A-Z_][A-Z_\d]+\b/,"class-name":/\b[A-Z]\w*\b/,namespace:{pattern:/(?:\b[a-z][a-z_\d]*\s*::\s*)*\b[a-z][a-z_\d]*\s*::(?!\s*<)/,inside:{punctuation:/::/}},number:/\b(?:0x[\dA-Fa-f](?:_?[\dA-Fa-f])*|0o[0-7](?:_?[0-7])*|0b[01](?:_?[01])*|(?:(?:\d(?:_?\d)*)?\.)?\d(?:_?\d)*(?:[Ee][+-]?\d+)?)(?:_?(?:f32|f64|[iu](?:8|16|32|64|size)?))?\b/,boolean:/\b(?:false|true)\b/,punctuation:/->|\.\.=|\.{1,3}|::|[{}[\];(),:]/,operator:/[-+*\/%!^]=?|=[=>]?|&[&=]?|\|[|=]?|<>?=?|[@?]/},e.languages.rust["closure-params"].inside.rest=e.languages.rust,e.languages.rust.attribute.inside.string=e.languages.rust.string}(s)),s.languages.swift={comment:{pattern:/(^|[^\\:])(?:\/\/.*|\/\*(?:[^/*]|\/(?!\*)|\*(?!\/)|\/\*(?:[^*]|\*(?!\/))*\*\/)*\*\/)/,lookbehind:!0,greedy:!0},"string-literal":[{pattern:RegExp(/(^|[^"#])/.source+"(?:"+/"(?:\\(?:\((?:[^()]|\([^()]*\))*\)|\r\n|[^(])|[^\\\r\n"])*"/.source+"|"+/"""(?:\\(?:\((?:[^()]|\([^()]*\))*\)|[^(])|[^\\"]|"(?!""))*"""/.source+")"+/(?!["#])/.source),lookbehind:!0,greedy:!0,inside:{interpolation:{pattern:/(\\\()(?:[^()]|\([^()]*\))*(?=\))/,lookbehind:!0,inside:null},"interpolation-punctuation":{pattern:/^\)|\\\($/,alias:"punctuation"},punctuation:/\\(?=[\r\n])/,string:/[\s\S]+/}},{pattern:RegExp(/(^|[^"#])(#+)/.source+"(?:"+/"(?:\\(?:#+\((?:[^()]|\([^()]*\))*\)|\r\n|[^#])|[^\\\r\n])*?"/.source+"|"+/"""(?:\\(?:#+\((?:[^()]|\([^()]*\))*\)|[^#])|[^\\])*?"""/.source+")\\2"),lookbehind:!0,greedy:!0,inside:{interpolation:{pattern:/(\\#+\()(?:[^()]|\([^()]*\))*(?=\))/,lookbehind:!0,inside:null},"interpolation-punctuation":{pattern:/^\)|\\#+\($/,alias:"punctuation"},string:/[\s\S]+/}}],directive:{pattern:RegExp(/#/.source+"(?:"+/(?:elseif|if)\b/.source+"(?:[ \t]*"+/(?:![ \t]*)?(?:\b\w+\b(?:[ \t]*\((?:[^()]|\([^()]*\))*\))?|\((?:[^()]|\([^()]*\))*\))(?:[ \t]*(?:&&|\|\|))?/.source+")+|"+/(?:else|endif)\b/.source+")"),alias:"property",inside:{"directive-name":/^#\w+/,boolean:/\b(?:false|true)\b/,number:/\b\d+(?:\.\d+)*\b/,operator:/!|&&|\|\||[<>]=?/,punctuation:/[(),]/}},literal:{pattern:/#(?:colorLiteral|column|dsohandle|file(?:ID|Literal|Path)?|function|imageLiteral|line)\b/,alias:"constant"},"other-directive":{pattern:/#\w+\b/,alias:"property"},attribute:{pattern:/@\w+/,alias:"atrule"},"function-definition":{pattern:/(\bfunc\s+)\w+/,lookbehind:!0,alias:"function"},label:{pattern:/\b(break|continue)\s+\w+|\b[a-zA-Z_]\w*(?=\s*:\s*(?:for|repeat|while)\b)/,lookbehind:!0,alias:"important"},keyword:/\b(?:Any|Protocol|Self|Type|actor|as|assignment|associatedtype|associativity|async|await|break|case|catch|class|continue|convenience|default|defer|deinit|didSet|do|dynamic|else|enum|extension|fallthrough|fileprivate|final|for|func|get|guard|higherThan|if|import|in|indirect|infix|init|inout|internal|is|isolated|lazy|left|let|lowerThan|mutating|none|nonisolated|nonmutating|open|operator|optional|override|postfix|precedencegroup|prefix|private|protocol|public|repeat|required|rethrows|return|right|safe|self|set|some|static|struct|subscript|super|switch|throw|throws|try|typealias|unowned|unsafe|var|weak|where|while|willSet)\b/,boolean:/\b(?:false|true)\b/,nil:{pattern:/\bnil\b/,alias:"constant"},"short-argument":/\$\d+\b/,omit:{pattern:/\b_\b/,alias:"keyword"},number:/\b(?:[\d_]+(?:\.[\de_]+)?|0x[a-f0-9_]+(?:\.[a-f0-9p_]+)?|0b[01_]+|0o[0-7_]+)\b/i,"class-name":/\b[A-Z](?:[A-Z_\d]*[a-z]\w*)?\b/,function:/\b[a-z_]\w*(?=\s*\()/i,constant:/\b(?:[A-Z_]{2,}|k[A-Z][A-Za-z_]+)\b/,operator:/[-+*/%=!<>&|^~?]+|\.[.\-+*/%=!<>&|^~?]+/,punctuation:/[{}[\]();,.:\\]/},s.languages.swift["string-literal"].forEach((function(e){e.inside.interpolation.inside=s.languages.swift}));var ku;ku||(ku=1,function(e){e.languages.typescript=e.languages.extend("javascript",{"class-name":{pattern:/(\b(?:class|extends|implements|instanceof|interface|new|type)\s+)(?!keyof\b)(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?:\s*<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>)?/,lookbehind:!0,greedy:!0,inside:null},builtin:/\b(?:Array|Function|Promise|any|boolean|console|never|number|string|symbol|unknown)\b/}),e.languages.typescript.keyword.push(/\b(?:abstract|declare|is|keyof|readonly|require)\b/,/\b(?:asserts|infer|interface|module|namespace|type)\b(?=\s*(?:[{_$a-zA-Z\xA0-\uFFFF]|$))/,/\btype\b(?=\s*(?:[\{*]|$))/),delete e.languages.typescript.parameter,delete e.languages.typescript["literal-property"];var t=e.languages.extend("typescript",{});delete t["class-name"],e.languages.typescript["class-name"].inside=t,e.languages.insertBefore("typescript","function",{decorator:{pattern:/@[$\w\xA0-\uFFFF]+/,inside:{at:{pattern:/^@/,alias:"operator"},function:/^[\s\S]+/}},"generic-function":{pattern:/#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>(?=\s*\()/,greedy:!0,inside:{function:/^#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*/,generic:{pattern:/<[\s\S]+/,alias:"class-name",inside:t}}}}),e.languages.ts=e.languages.typescript}(s));var Tu;Tu||(Tu=1,function(e){var t=/\b(?:abstract|assert|boolean|break|byte|case|catch|char|class|const|continue|default|do|double|else|enum|exports|extends|final|finally|float|for|goto|if|implements|import|instanceof|int|interface|long|module|native|new|non-sealed|null|open|opens|package|permits|private|protected|provides|public|record(?!\s*[(){}[\]<>=%~.:,;?+\-*/&|^])|requires|return|sealed|short|static|strictfp|super|switch|synchronized|this|throw|throws|to|transient|transitive|try|uses|var|void|volatile|while|with|yield)\b/,n=/(?:[a-z]\w*\s*\.\s*)*(?:[A-Z]\w*\s*\.\s*)*/.source,r={pattern:RegExp(/(^|[^\w.])/.source+n+/[A-Z](?:[\d_A-Z]*[a-z]\w*)?\b/.source),lookbehind:!0,inside:{namespace:{pattern:/^[a-z]\w*(?:\s*\.\s*[a-z]\w*)*(?:\s*\.)?/,inside:{punctuation:/\./}},punctuation:/\./}};e.languages.java=e.languages.extend("clike",{string:{pattern:/(^|[^\\])"(?:\\.|[^"\\\r\n])*"/,lookbehind:!0,greedy:!0},"class-name":[r,{pattern:RegExp(/(^|[^\w.])/.source+n+/[A-Z]\w*(?=\s+\w+\s*[;,=()]|\s*(?:\[[\s,]*\]\s*)?::\s*new\b)/.source),lookbehind:!0,inside:r.inside},{pattern:RegExp(/(\b(?:class|enum|extends|implements|instanceof|interface|new|record|throws)\s+)/.source+n+/[A-Z]\w*\b/.source),lookbehind:!0,inside:r.inside}],keyword:t,function:[e.languages.clike.function,{pattern:/(::\s*)[a-z_]\w*/,lookbehind:!0}],number:/\b0b[01][01_]*L?\b|\b0x(?:\.[\da-f_p+-]+|[\da-f_]+(?:\.[\da-f_p+-]+)?)\b|(?:\b\d[\d_]*(?:\.[\d_]*)?|\B\.\d[\d_]*)(?:e[+-]?\d[\d_]*)?[dfl]?/i,operator:{pattern:/(^|[^.])(?:<<=?|>>>?=?|->|--|\+\+|&&|\|\||::|[?:~]|[-+*/%&|^!=<>]=?)/m,lookbehind:!0},constant:/\b[A-Z][A-Z_\d]+\b/}),e.languages.insertBefore("java","string",{"triple-quoted-string":{pattern:/"""[ \t]*[\r\n](?:(?:"|"")?(?:\\.|[^"\\]))*"""/,greedy:!0,alias:"string"},char:{pattern:/'(?:\\.|[^'\\\r\n]){1,6}'/,greedy:!0}}),e.languages.insertBefore("java","class-name",{annotation:{pattern:/(^|[^.])@\w+(?:\s*\.\s*\w+)*/,lookbehind:!0,alias:"punctuation"},generics:{pattern:/<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&)|<(?:[\w\s,.?]|&(?!&))*>)*>)*>)*>/,inside:{"class-name":r,keyword:t,punctuation:/[<>(),.:]/,operator:/[?&|]/}},import:[{pattern:RegExp(/(\bimport\s+)/.source+n+/(?:[A-Z]\w*|\*)(?=\s*;)/.source),lookbehind:!0,inside:{namespace:r.inside.namespace,punctuation:/\./,operator:/\*/,"class-name":/\w+/}},{pattern:RegExp(/(\bimport\s+static\s+)/.source+n+/(?:\w+|\*)(?=\s*;)/.source),lookbehind:!0,alias:"static",inside:{namespace:r.inside.namespace,static:/\b\w+$/,punctuation:/\./,operator:/\*/,"class-name":/\w+/}}],namespace:{pattern:RegExp(/(\b(?:exports|import(?:\s+static)?|module|open|opens|package|provides|requires|to|transitive|uses|with)\s+)(?!)[a-z]\w*(?:\.[a-z]\w*)*\.?/.source.replace(//g,(function(){return t.source}))),lookbehind:!0,inside:{punctuation:/\./}}})}(s));var Eu;function Nu(e,...t){const n=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",e);for(const e of t)r.append("v",e);throw n.search=r.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}Eu||(Eu=1,function(e){var t=/\b(?:alignas|alignof|asm|auto|bool|break|case|catch|char|char16_t|char32_t|char8_t|class|co_await|co_return|co_yield|compl|concept|const|const_cast|consteval|constexpr|constinit|continue|decltype|default|delete|do|double|dynamic_cast|else|enum|explicit|export|extern|final|float|for|friend|goto|if|import|inline|int|int16_t|int32_t|int64_t|int8_t|long|module|mutable|namespace|new|noexcept|nullptr|operator|override|private|protected|public|register|reinterpret_cast|requires|return|short|signed|sizeof|static|static_assert|static_cast|struct|switch|template|this|thread_local|throw|try|typedef|typeid|typename|uint16_t|uint32_t|uint64_t|uint8_t|union|unsigned|using|virtual|void|volatile|wchar_t|while)\b/,n=/\b(?!)\w+(?:\s*\.\s*\w+)*\b/.source.replace(//g,(function(){return t.source}));e.languages.cpp=e.languages.extend("c",{"class-name":[{pattern:RegExp(/(\b(?:class|concept|enum|struct|typename)\s+)(?!)\w+/.source.replace(//g,(function(){return t.source}))),lookbehind:!0},/\b[A-Z]\w*(?=\s*::\s*\w+\s*\()/,/\b[A-Z_]\w*(?=\s*::\s*~\w+\s*\()/i,/\b\w+(?=\s*<(?:[^<>]|<(?:[^<>]|<[^<>]*>)*>)*>\s*::\s*\w+\s*\()/],keyword:t,number:{pattern:/(?:\b0b[01']+|\b0x(?:[\da-f']+(?:\.[\da-f']*)?|\.[\da-f']+)(?:p[+-]?[\d']+)?|(?:\b[\d']+(?:\.[\d']*)?|\B\.[\d']+)(?:e[+-]?[\d']+)?)[ful]{0,4}/i,greedy:!0},operator:/>>=?|<<=?|->|--|\+\+|&&|\|\||[?:~]|<=>|[-+*/%&|^!=<>]=?|\b(?:and|and_eq|bitand|bitor|not|not_eq|or|or_eq|xor|xor_eq)\b/,boolean:/\b(?:false|true)\b/}),e.languages.insertBefore("cpp","string",{module:{pattern:RegExp(/(\b(?:import|module)\s+)/.source+"(?:"+/"(?:\\(?:\r\n|[\s\S])|[^"\\\r\n])*"|<[^<>\r\n]*>/.source+"|"+/(?:\s*:\s*)?|:\s*/.source.replace(//g,(function(){return n}))+")"),lookbehind:!0,greedy:!0,inside:{string:/^[<"][\s\S]+/,operator:/:/,punctuation:/\./}},"raw-string":{pattern:/R"([^()\\ ]{0,16})\([\s\S]*?\)\1"/,alias:"string",greedy:!0}}),e.languages.insertBefore("cpp","keyword",{"generic-function":{pattern:/\b(?!operator\b)[a-z_]\w*\s*<(?:[^<>]|<[^<>]*>)*>(?=\s*\()/i,inside:{function:/^\w+/,generic:{pattern:/<[\s\S]+/,alias:"class-name",inside:e.languages.cpp}}}}),e.languages.insertBefore("cpp","operator",{"double-colon":{pattern:/::/,alias:"punctuation"}}),e.languages.insertBefore("cpp","class-name",{"base-clause":{pattern:/(\b(?:class|struct)\s+\w+\s*:\s*)[^;{}"'\s]+(?:\s+[^;{}"'\s]+)*(?=\s*[;{])/,lookbehind:!0,greedy:!0,inside:e.languages.extend("cpp",{})}}),e.languages.insertBefore("inside","double-colon",{"class-name":/\b[a-z_]\w*\b(?!\s*::)/i},e.languages.cpp["base-clause"])}(s));function Au(e,t){for(const n of e.childNodes){if(Js(n)&&n.tagName===t)return!0;Au(n,t)}return!1}const Lu="data-language",Ou="data-highlight-language",Fu="data-theme";let Ru=class e extends go{__language;__theme;__isSyntaxHighlightSupported;static getType(){return"code"}static clone(t){return new e(t.__language,t.__key)}constructor(e,t){super(t),this.__language=e||void 0,this.__isSyntaxHighlightSupported=!1,this.__theme=void 0}afterCloneFrom(e){super.afterCloneFrom(e),this.__language=e.__language,this.__theme=e.__theme,this.__isSyntaxHighlightSupported=e.__isSyntaxHighlightSupported}createDOM(e){const t=document.createElement("code");La(t,e.theme.code),t.setAttribute("spellcheck","false");const n=this.getLanguage();n&&(t.setAttribute(Lu,n),this.getIsSyntaxHighlightSupported()&&t.setAttribute(Ou,n));const r=this.getTheme();r&&t.setAttribute(Fu,r);const i=this.getStyle();return i&&t.setAttribute("style",i),t}updateDOM(e,t,n){const r=this.__language,i=e.__language;r?r!==i&&t.setAttribute(Lu,r):i&&t.removeAttribute(Lu);const o=this.__isSyntaxHighlightSupported;e.__isSyntaxHighlightSupported&&i?o&&r?r!==i&&t.setAttribute(Ou,r):t.removeAttribute(Ou):o&&r&&t.setAttribute(Ou,r);const s=this.__theme,l=e.__theme;s?s!==l&&t.setAttribute(Fu,s):l&&t.removeAttribute(Fu);const a=this.__style,c=e.__style;return a?a!==c&&t.setAttribute("style",a):c&&t.removeAttribute("style"),!1}exportDOM(e){const t=document.createElement("pre");La(t,e._config.theme.code),t.setAttribute("spellcheck","false");const n=this.getLanguage();n&&(t.setAttribute(Lu,n),this.getIsSyntaxHighlightSupported()&&t.setAttribute(Ou,n));const r=this.getTheme();r&&t.setAttribute(Fu,r);const i=this.getStyle();return i&&t.setAttribute("style",i),{element:t}}static importDOM(){return{code:e=>null!=e.textContent&&(/\r?\n/.test(e.textContent)||Au(e,"BR"))?{conversion:Mu,priority:1}:null,div:()=>({conversion:Du,priority:1}),pre:()=>({conversion:Mu,priority:0}),table:e=>Hu(e)?{conversion:Bu,priority:3}:null,td:e=>{const t=e,n=t.closest("table");return t.classList.contains("js-file-line")||n&&Hu(n)?{conversion:zu,priority:3}:null},tr:e=>{const t=e.closest("table");return t&&Hu(t)?{conversion:zu,priority:3}:null}}}static importJSON(e){return Iu().updateFromJSON(e)}updateFromJSON(e){return super.updateFromJSON(e).setLanguage(e.language).setTheme(e.theme)}exportJSON(){return{...super.exportJSON(),language:this.getLanguage(),theme:this.getTheme()}}insertNewAfter(e,t=!0){const n=this.getChildren(),r=n.length;if(r>=2&&"\n"===n[r-1].getTextContent()&&"\n"===n[r-2].getTextContent()&&e.isCollapsed()&&e.anchor.key===this.__key&&e.anchor.offset===r){n[r-1].remove(),n[r-2].remove();const e=Eo();return this.insertAfter(e,t),e}const{anchor:i,focus:o}=e,s=(i.isBefore(o)?i:o).getNode();if(ri(s)){let e=ju(s);const t=[];for(;;)if(li(e))t.push(si()),e=e.getNextSibling();else{if(!Vu(e))break;{let n=0;const r=e.getTextContent(),i=e.getTextContentSize();for(;ne.append(t))),this.replace(e),!0}setLanguage(e){const t=this.getWritable();return t.__language=e||void 0,t}getLanguage(){return this.getLatest().__language}setIsSyntaxHighlightSupported(e){const t=this.getWritable();return t.__isSyntaxHighlightSupported=e,t}getIsSyntaxHighlightSupported(){return this.getLatest().__isSyntaxHighlightSupported}setTheme(e){const t=this.getWritable();return t.__theme=e||void 0,t}getTheme(){return this.getLatest().__theme}};function Iu(e,t){return function(e){const t=nl();return Zi(),new(t.resolveRegisteredNodeAfterReplacements(t.getRegisteredNode(e)).klass)}(Ru).setLanguage(e).setTheme(t)}function Pu(e){return e instanceof Ru}function Mu(e){return{node:Iu(e.getAttribute(Lu))}}function Du(e){const t=e,n=$u(t);return n||function(e){let t=e.parentElement;for(;null!==t;){if($u(t))return!0;t=t.parentElement}return!1}(t)?{node:n?Iu():null}:{node:null}}function Bu(){return{node:Iu()}}function zu(){return{node:null}}function $u(e){return null!==e.style.fontFamily.match("monospace")}function Hu(e){return e.classList.contains("js-file-line-container")}let Ku=class e extends jr{__highlightType;constructor(e="",t,n){super(e,n),this.__highlightType=t}static getType(){return"code-highlight"}static clone(t){return new e(t.__text,t.__highlightType||void 0,t.__key)}getHighlightType(){return this.getLatest().__highlightType}setHighlightType(e){const t=this.getWritable();return t.__highlightType=e||void 0,t}canHaveFormat(){return!1}createDOM(e){const t=super.createDOM(e);return La(t,Uu(e.theme,this.__highlightType)),t}updateDOM(e,t,n){const r=super.updateDOM(e,t,n),i=Uu(n.theme,e.__highlightType),o=Uu(n.theme,this.__highlightType);return i!==o&&(i&&Oa(t,i),o&&La(t,o)),r}static importJSON(e){return Wu().updateFromJSON(e)}updateFromJSON(e){return super.updateFromJSON(e).setHighlightType(e.highlightType)}exportJSON(){return{...super.exportJSON(),highlightType:this.getHighlightType()}}setFormat(e){return this}isParentRequired(){return!0}createParentElementNode(){return Iu()}};function Uu(e,t){return t&&e&&e.codeHighlight&&e.codeHighlight[t]}function Wu(e="",t){return Ws(new Ku(e,t))}function Vu(e){return e instanceof Ku}function qu(e,t){let n=e;for(let r=Tl(e,t);r&&(Vu(r.origin)||li(r.origin));r=Fa(r))n=r.origin;return n}function ju(e){return qu(e,"previous")}function Zu(e){return qu(e,"next")}!function(e){e.languages.diff={coord:[/^(?:\*{3}|-{3}|\+{3}).*$/m,/^@@.*@@$/m,/^\d.*$/m]};var t={"deleted-sign":"-","deleted-arrow":"<","inserted-sign":"+","inserted-arrow":">",unchanged:" ",diff:"!"};Object.keys(t).forEach((function(n){var r=t[n],i=[];/^\w+$/.test(n)||i.push(/\w+/.exec(n)[0]),"diff"===n&&i.push("bold"),e.languages.diff[n]={pattern:RegExp("^(?:["+r+"].*(?:\r\n?|\n|(?![\\s\\S])))+","m"),alias:i,inside:{line:{pattern:/(.)(?=[\s\S]).*(?:\r\n?|\n)?/,lookbehind:!0},prefix:{pattern:/[\s\S]/,alias:/\w+/.exec(n)[0]}}}})),Object.defineProperty(e.languages.diff,"PREFIXES",{value:t})}(Prism);const Gu=globalThis.Prism||window.Prism,Ju={c:"C",clike:"C-like",cpp:"C++",css:"CSS",html:"HTML",java:"Java",js:"JavaScript",markdown:"Markdown",objc:"Objective-C",plain:"Plain Text",powershell:"PowerShell",py:"Python",rust:"Rust",sql:"SQL",swift:"Swift",typescript:"TypeScript",xml:"XML"},Yu={cpp:"cpp",java:"java",javascript:"js",md:"markdown",plaintext:"plain",python:"py",text:"plain",ts:"typescript"};function Xu(e){return Yu[e]||e}function Qu(e){return"string"==typeof e?e:Array.isArray(e)?e.map(Qu).join(""):Qu(e.content)}function ed(e,t){const n=/^diff-([\w-]+)/i.exec(t),r=e.getTextContent();let i=Gu.tokenize(r,Gu.languages[n?"diff":t]);return n&&(i=function(e,t){const n=t,r=Gu.languages[n],i={tokens:e},o=Gu.languages.diff.PREFIXES;for(const e of i.tokens){if("string"==typeof e||!(e.type in o)||!Array.isArray(e.content))continue;const t=e.type;let n=0;const i=()=>(n++,new Gu.Token("prefix",o[t],t.replace(/^(\w+).*/,"$1"))),s=e.content.filter((e=>"string"==typeof e||"prefix"!==e.type)),l=e.content.length-s.length,a=Gu.tokenize(Qu(s),r);a.unshift(i());const c=/\r\n|\n/g,u=e=>{const t=[];c.lastIndex=0;let r,o=0;for(;n{for(let t=0;t0&&n.push(Wu(i,t))}}else{const{content:e,alias:t}=r;"string"==typeof e?n.push(...td([e],"prefix"===r.type&&"string"==typeof t?t:r.type)):Array.isArray(e)&&n.push(...td(e,"unchanged"===r.type?void 0:r.type))}return n}const nd={$tokenize(e,t){return ed(e,t||this.defaultLanguage)},defaultLanguage:"javascript",tokenize(e,t){return Gu.tokenize(e,Gu.languages[t||""]||Gu.languages[this.defaultLanguage])}};function rd(e,t,n){const r=e.getParent();Pu(r)?sd(r,t,n):Vu(e)&&e.replace(ni(e.__text))}function id(e,t){const n=t.getElementByKey(e.getKey());if(null===n)return;const r=e.getChildren(),i=r.length;if(i===n.__cachedChildrenLength)return;n.__cachedChildrenLength=i;let o="1",s=1;for(let e=0;e{!function(e,t){const n=is(e);if(!Pu(n)||!n.isAttached())return;const r=Li();if(!gi(r))return void t();const i=r.anchor,o=i.offset,s="element"===i.type&&zr(n.getChildAtIndex(i.offset-1));let l=0;if(!s){const e=i.getNode();l=o+e.getPreviousSiblings().reduce(((e,t)=>e+t.getTextContentSize()),0)}t()&&(s?i.getNode().select(o,o):n.getChildren().some((e=>{const t=ri(e);if(t||zr(e)){const n=e.getTextContentSize();if(t&&n>=l)return e.select(l,l),!0;l-=n}return!1})))}(r,(()=>{const t=is(r);if(!Pu(t)||!t.isAttached())return!1;const i=t.getLanguage()||n.defaultLanguage,o=n.$tokenize(t,i),s=function(e,t){let n=0;for(;n{od.delete(r)},skipTransforms:!0}))}function ld(e,t){return Vu(e)&&Vu(t)&&e.__text===t.__text&&e.__highlightType===t.__highlightType||li(e)&&li(t)||zr(e)&&zr(t)}function ad(e){if(!gi(e))return!1;const t=e.anchor.getNode(),n=Pu(t)?t:t.getParent(),r=e.focus.getNode(),i=Pu(r)?r:r.getParent();return Pu(n)&&n.is(i)}function cd(e){const t=e.getNodes(),n=[];if(1===t.length&&Pu(t[0]))return n;let r=[];for(let e=0;e0&&(n.push(r),r=[]):r.push(i)}if(r.length>0){const t=e.isBackward()?e.anchor:e.focus,i=ci(r[0].getKey(),0,"text");t.is(i)||n.push(r)}return n}function ud(e){const t=Li();if(!gi(t)||!ad(t))return!1;const n=cd(t),r=n.length;if(0===r&&t.isCollapsed())return e===In&&t.insertNodes([si()]),!0;if(0===r&&e===In&&"\n"===t.getTextContent()){const e=si(),n=Br(),r=t.isBackward()?"previous":"next";return t.insertNodes([e,n]),Vl(ta(Ml(El(e,"next",0),Xl(Tl(n,"next"))),r)),!0}for(let i=0;i0){let n=r[0];if(0===i&&(n=ju(n)),e===In){const e=si();if(n.insertBefore(e),0===i){const r=t.isBackward()?"focus":"anchor",i=ci(n.getKey(),0,"text");t[r].is(i)&&t[r].set(e.getKey(),0,"text")}}else li(n)&&n.remove()}}return!0}function dd(e,t){const n=Li();if(!gi(n))return!1;const{anchor:r,focus:i}=n,o=r.offset,s=i.offset,l=r.getNode(),a=i.getNode(),c=e===kn;if(!ad(n)||!Vu(l)&&!li(l)||!Vu(a)&&!li(a))return!1;if(!t.altKey){if(n.isCollapsed()){const e=l.getParentOrThrow();if(c&&0===o&&null===l.getPreviousSibling()){if(null===e.getPreviousSibling())return e.selectPrevious(),t.preventDefault(),!0}else if(!c&&o===l.getTextContentSize()&&null===l.getNextSibling()&&null===e.getNextSibling())return e.selectNext(),t.preventDefault(),!0}return!1}let u,d;if(l.isBefore(a)?(u=ju(l),d=Zu(a)):(u=ju(a),d=Zu(l)),null==u||null==d)return!1;const h=u.getNodesBetween(d);for(let e=0;ee.remove())),e===kn?(h.forEach((e=>m.insertBefore(e))),m.insertBefore(g)):(m.insertAfter(g),m=g,h.forEach((e=>{m.insertAfter(e),m=e}))),n.setTextNodeRange(l,o,a,s),!0}function hd(e,t){const n=Li();if(!gi(n))return!1;const{anchor:r,focus:i}=n,o=r.getNode(),s=i.getNode(),l=e===wn;if(!ad(n)||!Vu(o)&&!li(o)||!Vu(s)&&!li(s))return!1;const a=s;if("rtl"===function(e){const t=ju(e),n=Zu(e);let r=t;for(;null!==r;){if(Vu(r)){const e=Vo(r.getTextContent());if(null!==e)return e}if(r===n)break;r=r.getNextSibling()}const i=t.getParent();if(po(i)){const e=i.getDirection();if("ltr"===e||"rtl"===e)return e}return null}(a)?!l:l){const e=function(e,t){let n=null,r=null,i=e,o=t,s=e.getTextContent();for(;;){if(0===o){if(i=i.getPreviousSibling(),null===i)break;if(Vu(i)||li(i)||zr(i)||Nu(167),zr(i)){n={node:i,offset:1};break}o=Math.max(0,i.getTextContentSize()-1),s=i.getTextContent()}else o--;const e=s[o];Vu(i)&&" "!==e&&(r={node:i,offset:o})}if(null!==r)return r;let l=null;if(t({conversion:fd,priority:1})}}static importJSON(e){return md().updateFromJSON(e)}updateFromJSON(e){return super.updateFromJSON(e).setURL(e.url).setRel(e.rel||null).setTarget(e.target||null).setTitle(e.title||null)}sanitizeUrl(e){e=wd(e);try{const t=new URL(wd(e));if(!gd.has(t.protocol))return"about:blank"}catch(t){return e}return e}exportJSON(){return{...super.exportJSON(),rel:this.getRel(),target:this.getTarget(),title:this.getTitle(),url:this.getURL()}}getURL(){return this.getLatest().__url}setURL(e){const t=this.getWritable();return t.__url=e,t}getTarget(){return this.getLatest().__target}setTarget(e){const t=this.getWritable();return t.__target=e,t}getRel(){return this.getLatest().__rel}setRel(e){const t=this.getWritable();return t.__rel=e,t}getTitle(){return this.getLatest().__title}setTitle(e){const t=this.getWritable();return t.__title=e,t}insertNewAfter(e,t=!0){const n=md(this.__url,{rel:this.__rel,target:this.__target,title:this.__title});return this.insertAfter(n,t),n}canInsertTextBefore(){return!1}canInsertTextAfter(){return!1}canBeEmpty(){return!1}isInline(){return!0}extractWithChild(e,t,n){if(!gi(t))return!1;const r=t.anchor.getNode(),i=t.focus.getNode();return this.isParentOf(r)&&this.isParentOf(i)&&t.getTextContent().length>0}isEmailURI(){return this.__url.startsWith("mailto:")}isWebSiteURI(){return this.__url.startsWith("https://")||this.__url.startsWith("http://")}};function fd(e){let t=null;if(Gs(e)){const n=e.textContent;(null!==n&&""!==n||e.children.length>0)&&(t=md(e.getAttribute("href")||"",{rel:e.getAttribute("rel"),target:e.getAttribute("target"),title:e.getAttribute("title")}))}return{node:t}}function md(e="",t){return Ws(new pd(e,t))}function yd(e){return e instanceof pd}class bd extends pd{__isUnlinked;constructor(e="",t={},n){super(e,t,n),this.__isUnlinked=void 0!==t.isUnlinked&&null!==t.isUnlinked&&t.isUnlinked}static getType(){return"autolink"}static clone(e){return new bd(e.__url,{isUnlinked:e.__isUnlinked,rel:e.__rel,target:e.__target,title:e.__title},e.__key)}getIsUnlinked(){return this.__isUnlinked}setIsUnlinked(e){const t=this.getWritable();return t.__isUnlinked=e,t}createDOM(e){return this.__isUnlinked?document.createElement("span"):super.createDOM(e)}updateDOM(e,t,n){return super.updateDOM(e,t,n)||e.__isUnlinked!==this.__isUnlinked}static importJSON(e){return _d().updateFromJSON(e)}updateFromJSON(e){return super.updateFromJSON(e).setIsUnlinked(e.isUnlinked||!1)}static importDOM(){return null}exportJSON(){return{...super.exportJSON(),isUnlinked:this.__isUnlinked}}insertNewAfter(e,t=!0){const n=this.getParentOrThrow().insertNewAfter(e,t);if(po(n)){const e=_d(this.__url,{isUnlinked:this.__isUnlinked,rel:this.__rel,target:this.__target,title:this.__title});return n.append(e),e}return null}}function _d(e="",t){return Ws(new bd(e,t))}function xd(e){return e instanceof bd}function Sd(e,t){if("element"===e.type){const n=e.getNode();return po(n)||function(e,...t){const n=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",e);for(const e of t)r.append("v",e);throw n.search=r.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}(252),n.getChildren()[e.offset+t]||null}return null}function Cd(e,t={}){let n;if(e&&"object"==typeof e){const{url:r,...i}=e;n=r,t={...i,...t}}else n=e;const{target:r,title:i}=t,o=void 0===t.rel?"noreferrer":t.rel,s=Li();if(null===s||!gi(s)&&!fi(s))return;if(fi(s)){const e=s.getNodes();if(0===e.length)return;return void e.forEach((e=>{if(null===n){const t=dl(e,(e=>!xd(e)&&yd(e)));t&&(t.insertBefore(e),0===t.getChildren().length&&t.remove())}else{const t=dl(e,(e=>!xd(e)&&yd(e)));if(t)t.setURL(n),void 0!==r&&t.setTarget(r),void 0!==o&&t.setRel(o);else{const t=md(n,{rel:o,target:r});e.insertBefore(t),t.append(e)}}}))}const l=s.extract();if(null===n){const e=new Set;return void l.forEach((t=>{const n=t.getParent();if(yd(n)&&!xd(n)){const t=n.getKey();if(e.has(t))return;!function(e,t){const n=new Set(t.filter((t=>e.isParentOf(t))).map((e=>e.getKey()))),r=e.getChildren(),i=r.filter((e=>n.has(e.getKey())));if(i.length===r.length)return r.forEach((t=>e.insertBefore(t))),void e.remove();const o=r.findIndex((e=>n.has(e.getKey()))),s=r.findLastIndex((e=>n.has(e.getKey()))),l=0===o,a=s===r.length-1;if(l)i.forEach((t=>e.insertBefore(t)));else if(a)for(let t=i.length-1;t>=0;t--)e.insertAfter(i[t]);else{for(let t=i.length-1;t>=0;t--)e.insertAfter(i[t]);const t=r.slice(s+1);if(t.length>0){const n=md(e.getURL(),{rel:e.getRel(),target:e.getTarget(),title:e.getTitle()});i[i.length-1].insertAfter(n),t.forEach((e=>n.append(e)))}}}(n,l),e.add(t)}}))}const a=new Set,c=e=>{a.has(e.getKey())||(a.add(e.getKey()),e.setURL(n),void 0!==r&&e.setTarget(r),void 0!==o&&e.setRel(o),void 0!==i&&e.setTitle(i))};if(1===l.length){const e=l[0],t=dl(e,yd);if(null!==t)return c(t)}!function(e){const t=Li();if(!gi(t))return e();const n=vt(t),r=n.isBackward(),i=Sd(n.anchor,r?-1:0),o=Sd(n.focus,r?0:-1);if(e(),i||o){const e=Li();if(gi(e)){const t=e.clone();if(i){const e=i.getParent();e&&t.anchor.set(e.getKey(),i.getIndexWithinParent()+(r?1:0),"element")}if(o){const e=o.getParent();e&&t.focus.set(e.getKey(),o.getIndexWithinParent()+(r?0:1),"element")}hs(vt(t))}}}((()=>{let e=null;for(const t of l){if(!t.isAttached())continue;const s=dl(t,yd);if(s){c(s);continue}if(po(t)){if(!t.isInline())continue;if(yd(t)){if(!(xd(t)||null!==e&&e.getParentOrThrow().isParentOf(t))){c(t),e=t;continue}for(const e of t.getChildren())t.insertBefore(e);t.remove();continue}}const l=t.getPreviousSibling();yd(l)&&l.is(e)?l.append(t):(e=md(n,{rel:o,target:r,title:i}),t.insertAfter(e),e.append(t))}}))}const vd=/^\+?[0-9\s()-]{5,}$/;function wd(e){return e.match(/^[a-z][a-z0-9+.-]*:/i)||e.match(/^[/#.]/)?e:e.includes("@")?`mailto:${e}`:vd.test(e)?`tel:${e}`:`https://${e}`}const kd=/^(\d+(?:\.\d+)?)px$/,Td=3,Ed=2,Nd=0,Ad=1;class Ld extends go{__colSpan;__rowSpan;__headerState;__width;__backgroundColor;__verticalAlign;static getType(){return"tablecell"}static clone(e){return new Ld(e.__headerState,e.__colSpan,e.__width,e.__key)}afterCloneFrom(e){super.afterCloneFrom(e),this.__rowSpan=e.__rowSpan,this.__backgroundColor=e.__backgroundColor,this.__verticalAlign=e.__verticalAlign}static importDOM(){return{td:e=>({conversion:Fd,priority:0}),th:e=>({conversion:Fd,priority:0})}}static importJSON(e){return Rd().updateFromJSON(e)}updateFromJSON(e){return super.updateFromJSON(e).setHeaderStyles(e.headerState).setColSpan(e.colSpan||1).setRowSpan(e.rowSpan||1).setWidth(e.width||void 0).setBackgroundColor(e.backgroundColor||null).setVerticalAlign(e.verticalAlign||void 0)}constructor(e=Nd,t=1,n,r){super(r),this.__colSpan=t,this.__rowSpan=1,this.__headerState=e,this.__width=n,this.__backgroundColor=null,this.__verticalAlign=void 0}createDOM(e){const t=document.createElement(this.getTag());return this.__width&&(t.style.width=`${this.__width}px`),this.__colSpan>1&&(t.colSpan=this.__colSpan),this.__rowSpan>1&&(t.rowSpan=this.__rowSpan),null!==this.__backgroundColor&&(t.style.backgroundColor=this.__backgroundColor),Od(this.__verticalAlign)&&(t.style.verticalAlign=this.__verticalAlign),La(t,e.theme.tableCell,this.hasHeader()&&e.theme.tableCellHeader),t}exportDOM(e){const t=super.exportDOM(e);if(Js(t.element)){const e=t.element;e.setAttribute("data-temporary-table-cell-lexical-key",this.getKey()),e.style.border="1px solid black",this.__colSpan>1&&(e.colSpan=this.__colSpan),this.__rowSpan>1&&(e.rowSpan=this.__rowSpan),e.style.width=`${this.getWidth()||75}px`,e.style.verticalAlign=this.getVerticalAlign()||"top",e.style.textAlign="start",null===this.__backgroundColor&&this.hasHeader()&&(e.style.backgroundColor="#f2f3f5")}return t}exportJSON(){return{...super.exportJSON(),...Od(this.__verticalAlign)&&{verticalAlign:this.__verticalAlign},backgroundColor:this.getBackgroundColor(),colSpan:this.__colSpan,headerState:this.__headerState,rowSpan:this.__rowSpan,width:this.getWidth()}}getColSpan(){return this.getLatest().__colSpan}setColSpan(e){const t=this.getWritable();return t.__colSpan=e,t}getRowSpan(){return this.getLatest().__rowSpan}setRowSpan(e){const t=this.getWritable();return t.__rowSpan=e,t}getTag(){return this.hasHeader()?"th":"td"}setHeaderStyles(e,t=Td){const n=this.getWritable();return n.__headerState=e&t|n.__headerState&~t,n}getHeaderStyles(){return this.getLatest().__headerState}setWidth(e){const t=this.getWritable();return t.__width=e,t}getWidth(){return this.getLatest().__width}getBackgroundColor(){return this.getLatest().__backgroundColor}setBackgroundColor(e){const t=this.getWritable();return t.__backgroundColor=e,t}getVerticalAlign(){return this.getLatest().__verticalAlign}setVerticalAlign(e){const t=this.getWritable();return t.__verticalAlign=e||void 0,t}toggleHeaderStyle(e){const t=this.getWritable();return(t.__headerState&e)===e?t.__headerState-=e:t.__headerState+=e,t}hasHeaderState(e){return(this.getHeaderStyles()&e)===e}hasHeader(){return this.getLatest().__headerState!==Nd}updateDOM(e){return e.__headerState!==this.__headerState||e.__width!==this.__width||e.__colSpan!==this.__colSpan||e.__rowSpan!==this.__rowSpan||e.__backgroundColor!==this.__backgroundColor||e.__verticalAlign!==this.__verticalAlign}isShadowRoot(){return!0}collapseAtStart(){return!0}canBeEmpty(){return!1}canIndent(){return!1}}function Od(e){return"middle"===e||"bottom"===e}function Fd(e){const t=e,n=e.nodeName.toLowerCase();let r;kd.test(t.style.width)&&(r=parseFloat(t.style.width));const i=Rd("th"===n?Ad:Nd,t.colSpan,r);i.__rowSpan=t.rowSpan;const o=t.style.backgroundColor;""!==o&&(i.__backgroundColor=o);const s=t.style.verticalAlign;Od(s)&&(i.__verticalAlign=s);const l=t.style,a=(l&&l.textDecoration||"").split(" "),c="700"===l.fontWeight||"bold"===l.fontWeight,u=a.includes("line-through"),d="italic"===l.fontStyle,h=a.includes("underline");return{after:e=>{const t=[];let n=null;const r=()=>{if(n){const e=n.getFirstChild();zr(e)&&1===n.getChildrenSize()&&e.remove()}};for(const i of e)Hs(i)||ri(i)||zr(i)?(ri(i)&&(c&&i.toggleFormat("bold"),u&&i.toggleFormat("strikethrough"),d&&i.toggleFormat("italic"),h&&i.toggleFormat("underline")),n?n.append(i):(n=Eo().append(i),t.push(n))):(t.push(i),r(),n=null);return r(),0===t.length&&t.push(Eo()),t},node:i}}function Rd(e=Nd,t=1,n){return Ws(new Ld(e,t,n))}function Id(e){return e instanceof Ld}const Pd=on("INSERT_TABLE_COMMAND");function Md(e,...t){const n=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",e);for(const e of t)r.append("v",e);throw n.search=r.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}let Dd=class e extends go{__height;static getType(){return"tablerow"}static clone(t){return new e(t.__height,t.__key)}static importDOM(){return{tr:e=>({conversion:Bd,priority:0})}}static importJSON(e){return zd().updateFromJSON(e)}updateFromJSON(e){return super.updateFromJSON(e).setHeight(e.height)}constructor(e,t){super(t),this.__height=e}exportJSON(){const e=this.getHeight();return{...super.exportJSON(),...void 0===e?void 0:{height:e}}}createDOM(e){const t=document.createElement("tr");return this.__height&&(t.style.height=`${this.__height}px`),La(t,e.theme.tableRow),t}extractWithChild(e,t,n){return"html"===n}isShadowRoot(){return!0}setHeight(e){const t=this.getWritable();return t.__height=e,t}getHeight(){return this.getLatest().__height}updateDOM(e){return e.__height!==this.__height}canBeEmpty(){return!1}canIndent(){return!1}};function Bd(e){const t=e;let n;return kd.test(t.style.height)&&(n=parseFloat(t.style.height)),{after:e=>Ba(e,Id),node:zd(n)}}function zd(e){return Ws(new Dd(e))}function $d(e){return e instanceof Dd}const Hd="undefined"!=typeof window&&void 0!==window.document&&void 0!==window.document.createElement,Kd=Hd&&"documentMode"in document?document.documentMode:null,Ud=Hd&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent);function Wd(e){const t=dl(e,(e=>Id(e)));return Id(t)?t:null}function Vd(e){const t=dl(e,(e=>$d(e)));if($d(t))return t;throw new Error("Expected table cell to be inside of table row.")}function qd(e){const t=dl(e,(e=>eg(e)));if(eg(t))return t;throw new Error("Expected table cell to be inside of table.")}Hd&&"InputEvent"in window&&!Kd&&new window.InputEvent("input");const jd=(e,t)=>e===Td||e===t?t:Nd;function Zd(e=!0){const t=Li();gi(t)||uh(t)||Md(188);const n=t.anchor.getNode(),r=t.focus.getNode(),[i]=oh(n),[o,,s]=oh(r),[,l,a]=rh(s,o,i),{startRow:c}=a,{startRow:u}=l;return e?Gd(c+i.__rowSpan>u+o.__rowSpan?i:o,!0):Gd(uu+o.__colSpan?i:o,!0):Yd(u1;){if(s-=o.__colSpan,!(s>=0)){h.append(d(r));continue e}{const{cell:e,startRow:r}=t[s];n=e,i=r}}n.insertAfter(d(r))}else o.setColSpan(o.__colSpan+1)}null!==u&&n&&Xd(u);const g=r.getColWidths();if(g){const e=[...g],t=a<0?0:a,n=e[t];e.splice(t,0,n),r.setColWidths(e)}return u}function Xd(e){const t=e.getFirstDescendant();null==t?e.selectStart():t.getParentOrThrow().selectStart()}function Qd(e,t){const n=e.getFirstChild();null!==n?n.insertBefore(t):e.append(t)}function eh(e){if(0===e.length)return null;const t=qd(e[0]),[n]=ih(t,null,null);let r=1/0,i=-1/0,o=1/0,s=-1/0;const l=new Set;for(const t of n)for(const n of t){if(!n||!n.cell)continue;const t=n.cell.getKey();if(!l.has(t)&&e.some((e=>e.is(n.cell)))){l.add(t);const e=n.startRow,a=n.startColumn,c=n.cell.__rowSpan||1,u=n.cell.__colSpan||1;r=Math.min(r,e),i=Math.max(i,e+c-1),o=Math.min(o,a),s=Math.max(s,a+u-1)}}if(r===1/0||o===1/0)return null;const a=i-r+1,c=s-o+1,u=n[r][o];if(!u.cell)return null;const d=u.cell;d.setColSpan(c),d.setRowSpan(a);const h=new Set([d.getKey()]);for(let e=r;e<=i;e++)for(let t=o;t<=s;t++){const r=n[e][t];if(!r.cell)continue;const i=r.cell,o=i.getKey();h.has(o)||(h.add(o),th(i)||d.append(...i.getChildren()),i.remove())}return 0===d.getChildrenSize()&&d.append(Eo()),d}function th(e){if(1!==e.getChildrenSize())return!1;const t=e.getFirstChildOrThrow();return!(!No(t)||!t.isEmpty())}function nh(e){const[t,n,r]=oh(e),i=t.__colSpan,o=t.__rowSpan;if(1===i&&1===o)return;const[s,l]=rh(r,t,t),{startColumn:a,startRow:c}=l,u=t.__headerState&Ed,d=Array.from({length:i},((e,t)=>{let n=u;for(let e=0;0!==n&&e{let n=h;for(let e=0;0!==n&&e1){for(let e=1;e1){let e;for(let t=1;t1&&(e+=n.__colSpan-1)}if(null===l)for(let n=i-1;n>=0;n--)Qd(e,Rd(d[n]|g[t]).append(Eo()));else for(let e=i-1;e>=0;e--)l.insertAfter(Rd(d[e]|g[t]).append(Eo()))}t.setRowSpan(1)}}function rh(e,t,n){const[r,i,o]=ih(e,t,n);return null===i&&Md(207),null===o&&Md(208),[r,i,o]}function ih(e,t,n){const r=[];let i=null,o=null;function s(e){let t=r[e];return void 0===t&&(r[e]=t=[]),t}const l=e.getChildren();for(let e=0;e=l.length);t++){const n=s(e+t);for(let e=0;e=i,h=a.startRow<=l&&u>=o;if(d&&h){const e=Math.min(i,a.startColumn),t=Math.max(s,c),n=Math.min(o,a.startRow),d=Math.max(l,u);e===i&&t===s&&n===o&&d===l||(i=e,s=t,o=n,l=d,r=!0)}}}while(r);return{maxColumn:s,maxRow:l,minColumn:i,minRow:o}}function lh(e){const[t,,n]=oh(e),r=n.getChildren(),i=r.length,o=r[0].getChildren().length,s=new Array(i);for(let e=0;e{const n=e[t].getNode(),r=dl(n,Id);Id(r)||Md(238,t,n.getKey(),n.getType());const i=r.getParent();$d(i)||Md(239,t);const o=i.getParent();return eg(o)||Md(240,t),[n,r,i,o]}));return i.is(a)||Md(241),{anchorCell:n,anchorNode:t,anchorRow:r,anchorTable:i,focusCell:s,focusNode:o,focusRow:l,focusTable:a}}let ch=class e{tableKey;anchor;focus;_cachedNodes;dirty;constructor(e,t,n){this.anchor=t,this.focus=n,t._selection=this,n._selection=this,this._cachedNodes=null,this.dirty=!1,this.tableKey=e}getStartEndPoints(){return[this.anchor,this.focus]}isValid(){if("root"===this.tableKey||"root"===this.anchor.key||"element"!==this.anchor.type||"root"===this.focus.key||"element"!==this.focus.type)return!1;const e=is(this.tableKey),t=is(this.anchor.key),n=is(this.focus.key);return null!==e&&null!==t&&null!==n}isBackward(){return this.focus.isBefore(this.anchor)}getCachedNodes(){return this._cachedNodes}setCachedNodes(e){this._cachedNodes=e}is(e){return uh(e)&&this.tableKey===e.tableKey&&this.anchor.is(e.anchor)&&this.focus.is(e.focus)}set(e,t,n){this.dirty=this.dirty||e!==this.tableKey||t!==this.anchor.key||n!==this.focus.key,this.tableKey=e,this.anchor.key=t,this.focus.key=n,this._cachedNodes=null}clone(){return new e(this.tableKey,ci(this.anchor.key,this.anchor.offset,this.anchor.type),ci(this.focus.key,this.focus.offset,this.focus.type))}isCollapsed(){return!1}extract(){return this.getNodes()}insertRawText(e){}insertText(){}hasFormat(e){let t=0;this.getNodes().filter(Id).forEach((e=>{const n=e.getFirstChild();No(n)&&(t|=n.getTextFormat())}));return 0!==(t&We[e])}insertNodes(e){const t=this.focus.getNode();po(t)||Md(151),vt(t.select(0,t.getChildrenSize())).insertNodes(e)}getShape(){const{anchorCell:e,focusCell:t}=ah(this),n=lh(e);null===n&&Md(153);const r=lh(t);null===r&&Md(155);const i=Math.min(n.columnIndex,r.columnIndex),o=Math.max(n.columnIndex+n.colSpan-1,r.columnIndex+r.colSpan-1),s=Math.min(n.rowIndex,r.rowIndex),l=Math.max(n.rowIndex+n.rowSpan-1,r.rowIndex+r.rowSpan-1);return{fromX:Math.min(i,o),fromY:Math.min(s,l),toX:Math.max(i,o),toY:Math.max(s,l)}}getNodes(){if(!this.isValid())return[];const e=this._cachedNodes;if(null!==e)return e;const{anchorTable:t,anchorCell:n,focusCell:r}=ah(this),i=r.getParents()[1];if(i!==t){if(t.isParentOf(r)){const e=i.getParent();null==e&&Md(159),this.set(this.tableKey,r.getKey(),e.getKey())}else{const e=t.getParent();null==e&&Md(158),this.set(this.tableKey,e.getKey(),r.getKey())}return this.getNodes()}const[o,s,l]=rh(t,n,r),{minColumn:a,maxColumn:c,minRow:u,maxRow:d}=sh(o,s,l),h=new Map([[t.getKey(),t]]);let g=null;for(let e=u;e<=d;e++)for(let t=a;t<=c;t++){const{cell:n}=o[e][t],r=n.getParent();$d(r)||Md(160),r!==g&&(h.set(r.getKey(),r),g=r),h.has(n.getKey())||hh(n,(e=>{h.set(e.getKey(),e)}))}const p=Array.from(h.values());return ji()||(this._cachedNodes=p),p}getTextContent(){const e=this.getNodes().filter((e=>Id(e)));let t="";for(let n=0;n0;e=n.at(-1)){const r=e.pop();void 0===r?n.pop():!1!==t(r)&&po(r)&&n.push(r.getChildren())}}function gh(e,t=nl()){const n=is(e);eg(n)||Md(231,e);const r=yh(n,t.getElementByKey(e));return null===r&&Md(232,e),{tableElement:r,tableNode:n}}let ph=class{focusX;focusY;listenersToRemove;table;isHighlightingCells;anchorX;anchorY;tableNodeKey;anchorCell;focusCell;anchorCellNodeKey;focusCellNodeKey;editor;tableSelection;hasHijackedSelectionStyles;isSelecting;pointerType;shouldCheckSelection;abortController;listenerOptions;nextFocus;constructor(e,t){this.isHighlightingCells=!1,this.anchorX=-1,this.anchorY=-1,this.focusX=-1,this.focusY=-1,this.listenersToRemove=new Set,this.tableNodeKey=t,this.editor=e,this.table={columns:0,domRows:[],rows:0},this.tableSelection=null,this.anchorCellNodeKey=null,this.focusCellNodeKey=null,this.anchorCell=null,this.focusCell=null,this.hasHijackedSelectionStyles=!1,this.isSelecting=!1,this.pointerType=null,this.shouldCheckSelection=!1,this.abortController=new AbortController,this.listenerOptions={signal:this.abortController.signal},this.nextFocus=null,this.trackTable()}getTable(){return this.table}removeListeners(){this.abortController.abort("removeListeners"),Array.from(this.listenersToRemove).forEach((e=>e())),this.listenersToRemove.clear()}$lookup(){return gh(this.tableNodeKey,this.editor)}trackTable(){const e=new MutationObserver((e=>{this.editor.getEditorState().read((()=>{let t=!1;for(let n=0;n{const{tableNode:t,tableElement:n}=this.$lookup();this.table=Eh(t,n),e.observe(n,{attributes:!0,childList:!0,subtree:!0})}),{editor:this.editor})}$clearHighlight(){const e=this.editor;this.isHighlightingCells=!1,this.anchorX=-1,this.anchorY=-1,this.focusX=-1,this.focusY=-1,this.tableSelection=null,this.anchorCellNodeKey=null,this.focusCellNodeKey=null,this.anchorCell=null,this.focusCell=null,this.hasHijackedSelectionStyles=!1,this.$enableHighlightStyle();const{tableNode:t,tableElement:n}=this.$lookup();Nh(e,Eh(t,n),null),null!==Li()&&(hs(null),e.dispatchCommand(sn,void 0))}$enableHighlightStyle(){const e=this.editor,{tableElement:t}=this.$lookup();Oa(t,e._config.theme.tableSelection),t.classList.remove("disable-selection"),this.hasHijackedSelectionStyles=!1}$disableHighlightStyle(){const{tableElement:e}=this.$lookup();La(e,this.editor._config.theme.tableSelection),this.hasHijackedSelectionStyles=!0}$updateTableTableSelection(e){if(null!==e){e.tableKey!==this.tableNodeKey&&Md(233,e.tableKey,this.tableNodeKey);const t=this.editor;this.tableSelection=e,this.isHighlightingCells=!0,this.$disableHighlightStyle(),this.updateDOMSelection(),Nh(t,this.table,this.tableSelection)}else this.$clearHighlight()}setShouldCheckSelection(){this.shouldCheckSelection=!0}getAndClearShouldCheckSelection(){return!!this.shouldCheckSelection&&(this.shouldCheckSelection=!1,!0)}setNextFocus(e){this.nextFocus=e}getAndClearNextFocus(){const{nextFocus:e}=this;return null!==e&&(this.nextFocus=null),e}updateDOMSelection(){if(null!==this.anchorCell&&null!==this.focusCell){const e=Zs(this.editor._window);e&&e.rangeCount>0&&e.removeAllRanges()}}$setFocusCellForSelection(e,t=!1){const n=this.editor,{tableNode:r}=this.$lookup(),i=e.x,o=e.y;if(this.focusCell=e,this.isHighlightingCells||this.anchorX===i&&this.anchorY===o&&!t){if(i===this.focusX&&o===this.focusY)return!1}else this.isHighlightingCells=!0,this.$disableHighlightStyle();if(this.focusX=i,this.focusY=o,this.isHighlightingCells){const t=qh(r,e.elem);if(null!=this.tableSelection&&null!=this.anchorCellNodeKey&&null!==t)return this.focusCellNodeKey=t.getKey(),this.tableSelection=function(e,t,n){e.getKey(),t.getKey(),n.getKey();const r=Li(),i=uh(r)?r.clone():dh();return i.set(e.getKey(),t.getKey(),n.getKey()),i}(r,this.$getAnchorTableCellOrThrow(),t),hs(this.tableSelection),n.dispatchCommand(sn,void 0),Nh(n,this.table,this.tableSelection),!0}return!1}$getAnchorTableCell(){return this.anchorCellNodeKey?is(this.anchorCellNodeKey):null}$getAnchorTableCellOrThrow(){const e=this.$getAnchorTableCell();return null===e&&Md(234),e}$getFocusTableCell(){return this.focusCellNodeKey?is(this.focusCellNodeKey):null}$getFocusTableCellOrThrow(){const e=this.$getFocusTableCell();return null===e&&Md(235),e}$setAnchorCellForSelection(e){this.isHighlightingCells=!1,this.anchorCell=e,this.anchorX=e.x,this.anchorY=e.y;const{tableNode:t}=this.$lookup(),n=qh(t,e.elem);if(null!==n){const e=n.getKey();this.tableSelection=null!=this.tableSelection?this.tableSelection.clone():dh(),this.anchorCellNodeKey=e}}$formatCells(e){const t=Li();uh(t)||Md(236);const n=Ei(),r=n.anchor,i=n.focus,o=t.getNodes().filter(Id);o.length>0||Md(237);const s=o[0].getFirstChild(),l=No(s)?s.getFormatFlags(e,null):null;o.forEach((t=>{r.set(t.getKey(),0,"element"),i.set(t.getKey(),t.getChildrenSize(),"element"),n.formatText(e,l)})),hs(t),this.editor.dispatchCommand(sn,void 0)}$clearText(){const{editor:e}=this,t=is(this.tableNodeKey);if(!eg(t))throw new Error("Expected TableNode.");const n=Li();uh(n)||Md(253);const r=n.getNodes().filter(Id),i=t.getFirstChild(),o=t.getLastChild();if(r.length>0&&null!==i&&null!==o&&$d(i)&&$d(o)&&r[0]===i.getFirstChild()&&r[r.length-1]===o.getLastChild()){t.selectPrevious();const n=t.getParent();return t.remove(),void(_o(n)&&n.isEmpty()&&e.dispatchCommand(dn,void 0))}r.forEach((e=>{if(po(e)){const t=Eo(),n=ni();t.append(n),e.append(t),e.getChildren().forEach((e=>{e!==t&&e.remove()}))}})),Nh(e,this.table,null),hs(null),e.dispatchCommand(sn,void 0)}};const fh="__lexicalTableSelection";function mh(e){return Js(e)&&"TABLE"===e.nodeName}function yh(e,t){if(!t)return t;const n=mh(t)?t:e.getDOMSlot(t).element;return"TABLE"!==n.nodeName&&Md(245,t.nodeName),n}function bh(e){return e._window}function _h(e,t){for(let n=t,r=null;null!==n;n=n.getParent()){if(e.is(n))return r;Id(n)&&(r=n)}return null}const xh=[[Tn,"down"],[kn,"up"],[vn,"backward"],[Sn,"forward"]],Sh=[fn,mn,cn],Ch=[An,On];function vh(e,t,n,r){const i=n.getRootElement(),o=bh(n);null!==i&&null!==o||Md(246);const s=new ph(n,e.getKey()),l=yh(e,t);!function(e,t){null!==wh(e)&&Md(205),e[fh]=t}(l,s),s.listenersToRemove.add((()=>function(e,t){wh(e)===t&&delete e[fh]}(l,s)));const a=t=>{if(s.pointerType=t.pointerType,0!==t.button||!Ys(t.target)||!o)return;const r=kh(t.target);null!==r&&n.update((()=>{const n=Oi();if(Ud&&t.shiftKey&&Ph(n,e)&&(gi(n)||uh(n))){const i=n.anchor.getNode(),o=_h(e,n.anchor.getNode());o?(s.$setAnchorCellForSelection(Vh(s,o)),s.$setFocusCellForSelection(r),Kh(t)):(e.isBefore(i)?e.selectStart():e.selectEnd()).anchor.set(n.anchor.key,n.anchor.offset,n.anchor.type)}else"touch"!==t.pointerType&&s.$setAnchorCellForSelection(r)})),(()=>{if(s.isSelecting)return;const e=()=>{s.isSelecting=!1,o.removeEventListener("pointerup",e),o.removeEventListener("pointermove",t)},t=r=>{if(1&~r.buttons&&s.isSelecting)return s.isSelecting=!1,o.removeEventListener("pointerup",e),void o.removeEventListener("pointermove",t);if(!Ys(r.target))return;let i=null;const a=!(Ud||l.contains(r.target));if(a)i=Th(l,r.target);else for(const e of document.elementsFromPoint(r.clientX,r.clientY))if(i=Th(l,e),i)break;!i||null!==s.focusCell&&i.elem===s.focusCell.elem||(s.setNextFocus({focusCell:i,override:a}),n.dispatchCommand(sn,void 0))};s.isSelecting=!0,o.addEventListener("pointerup",e,s.listenerOptions),o.addEventListener("pointermove",t,s.listenerOptions)})()};l.addEventListener("pointerdown",a,s.listenerOptions),s.listenersToRemove.add((()=>{l.removeEventListener("pointerdown",a)}));const c=e=>{e.detail>=3&&Ys(e.target)&&null!==kh(e.target)&&e.preventDefault()};l.addEventListener("mousedown",c,s.listenerOptions),s.listenersToRemove.add((()=>{l.removeEventListener("mousedown",c)}));const u=e=>{const t=e.target;0===e.button&&Ys(t)&&n.update((()=>{const e=Li();uh(e)&&e.tableKey===s.tableNodeKey&&i.contains(t)&&s.$clearHighlight()}))};o.addEventListener("pointerdown",u,s.listenerOptions),s.listenersToRemove.add((()=>{o.removeEventListener("pointerdown",u)}));for(const[t,r]of xh)s.listenersToRemove.add(n.registerCommand(t,(t=>Hh(n,t,r,e,s)),3));s.listenersToRemove.add(n.registerCommand(Ln,(t=>{const n=Li();if(uh(n)){const r=_h(e,n.focus.getNode());if(null!==r)return Kh(t),r.selectEnd(),!0}return!1}),3));const d=t=>()=>{const n=Li();if(!Ph(n,e))return!1;if(uh(n))return s.$clearText(),!0;if(gi(n)){if(!Id(_h(e,n.anchor.getNode())))return!1;const r=n.anchor.getNode(),i=n.focus.getNode(),o=e.isParentOf(r),l=e.isParentOf(i);if(o&&!l||l&&!o)return s.$clearText(),!0;const a=dl(n.anchor.getNode(),(e=>po(e))),c=a&&dl(a,(e=>po(e)&&Id(e.getParent())));if(!po(c)||!po(a))return!1;if(t===mn&&null===c.getPreviousSibling())return!0}return!1};for(const e of Sh)s.listenersToRemove.add(n.registerCommand(e,d(e),3));const h=t=>{const n=Li();if(!uh(n)&&!gi(n))return!1;const r=e.isParentOf(n.anchor.getNode());if(r!==e.isParentOf(n.focus.getNode())){const t=r?"anchor":"focus",i=r?"focus":"anchor",{key:o,offset:s,type:l}=n[i];return e[n[t].isBefore(n[i])?"selectPrevious":"selectNext"]()[i].set(o,s,l),!1}return!!Ph(n,e)&&!!uh(n)&&(t&&(t.preventDefault(),t.stopPropagation()),s.$clearText(),!0)};for(const e of Ch)s.listenersToRemove.add(n.registerCommand(e,h,3));return s.listenersToRemove.add(n.registerCommand(Kn,(e=>{const t=Li();if(t){if(!uh(t)&&!gi(t))return!1;Zc(n,Pa(e,ClipboardEvent)?e:null,Yc(t));const r=h(e);return gi(t)?(t.removeText(),!0):r}return!1}),3)),s.listenersToRemove.add(n.registerCommand(yn,(t=>{const n=Li();if(!Ph(n,e))return!1;if(uh(n))return s.$formatCells(t),!0;if(gi(n)){const e=dl(n.anchor.getNode(),(e=>Id(e)));if(!Id(e))return!1}return!1}),3)),s.listenersToRemove.add(n.registerCommand(Dn,(t=>{const n=Li();if(!uh(n)||!Ph(n,e))return!1;const r=n.anchor.getNode(),i=n.focus.getNode();if(!Id(r)||!Id(i))return!1;if(function(e,t){if(uh(e)){const n=e.anchor.getNode(),r=e.focus.getNode();if(t&&n&&r){const[e]=rh(t,n,r);return n.getKey()===e[0][0].cell.getKey()&&r.getKey()===e[e.length-1].at(-1).cell.getKey()}}return!1}(n,e))return e.setFormat(t),!0;const[o,s,l]=rh(e,r,i),a=Math.max(s.startRow+s.cell.__rowSpan-1,l.startRow+l.cell.__rowSpan-1),c=Math.max(s.startColumn+s.cell.__colSpan-1,l.startColumn+l.cell.__colSpan-1),u=Math.min(s.startRow,l.startRow),d=Math.min(s.startColumn,l.startColumn),h=new Set;for(let e=u;e<=a;e++)for(let n=d;n<=c;n++){const r=o[e][n].cell;if(h.has(r))continue;h.add(r),r.setFormat(t);const i=r.getChildren();for(let e=0;e{const r=Li();if(!Ph(r,e))return!1;if(uh(r))return s.$clearHighlight(),!1;if(gi(r)){const i=dl(r.anchor.getNode(),(e=>Id(e)));if(!Id(i))return!1;if("string"==typeof t){const i=Wh(n,r,e);if(i)return Uh(i,e,[ni(t)]),!0}}return!1}),3)),r&&s.listenersToRemove.add(n.registerCommand(Fn,(t=>{const n=Li();if(!gi(n)||!n.isCollapsed()||!Ph(n,e))return!1;const r=zh(n.anchor.getNode());return!(null===r||!e.is($h(r))||(Kh(t),function(e,t){const n="next"===t?"getNextSibling":"getPreviousSibling",r="next"===t?"getFirstChild":"getLastChild",i=e[n]();if(po(i))return i.selectEnd();const o=dl(e,$d);null===o&&Md(247);for(let e=o[n]();$d(e);e=e[n]()){const t=e[r]();if(po(t))return t.selectEnd()}const s=dl(o,eg);null===s&&Md(248),"next"===t?s.selectNext():s.selectPrevious()}(r,t.shiftKey?"previous":"next"),0))}),3)),s.listenersToRemove.add(n.registerCommand(Zn,(t=>e.isSelected()),3)),s.listenersToRemove.add(n.registerCommand(ln,((e,t)=>{if(n!==t)return!1;const{nodes:r,selection:i}=e,o=i.getStartEndPoints(),s=uh(i),l=gi(i)&&null!==dl(i.anchor.getNode(),(e=>Id(e)))&&null!==dl(i.focus.getNode(),(e=>Id(e)))||s;if(1!==r.length||!eg(r[0])||!l||null===o)return!1;const[a,c]=o,[u,d,h]=oh(a),g=dl(c.getNode(),(e=>Id(e)));if(!(Id(u)&&Id(g)&&$d(d)&&eg(h)))return!1;const p=r[0],[f,m,y]=rh(h,u,g),[b]=ih(p,null,null),_=f.length,x=_>0?f[0].length:0;let S=m.startRow,C=m.startColumn,v=b.length,w=v>0?b[0].length:0;if(s){const e=sh(f,m,y),t=e.maxRow-e.minRow+1,n=e.maxColumn-e.minColumn+1;S=e.minRow,C=e.minColumn,v=Math.min(v,t),w=Math.min(w,n)}let k=!1;const T=Math.min(_,S+v)-1,E=Math.min(x,C+w)-1,N=new Set;for(let e=S;e<=T;e++)for(let t=C;t<=E;t++){const n=f[e][t];N.has(n.cell.getKey())||1===n.cell.__rowSpan&&1===n.cell.__colSpan||(nh(n.cell),N.add(n.cell.getKey()),k=!0)}let[A]=ih(h.getWritable(),null,null);const L=v-_+S;for(let e=0;e{ri(e)?(Eo().append(e),s.append(e)):s.append(e)})),l.forEach((e=>e.remove()))}if(s&&k){const[e]=ih(h.getWritable(),null,null);e[m.startRow][m.startColumn].cell.selectEnd()}return!0}),3)),s.listenersToRemove.add(n.registerCommand(sn,(()=>{const t=Li(),r=Oi(),i=s.getAndClearNextFocus();if(null!==i){const{focusCell:n}=i;if(uh(t)&&t.tableKey===s.tableNodeKey)return(n.x!==s.focusX||n.y!==s.focusY)&&(s.$setFocusCellForSelection(n),!0);if(n!==s.anchorCell&&Ph(t,e))return s.$setFocusCellForSelection(n),!0}if(s.getAndClearShouldCheckSelection()&&gi(r)&&gi(t)&&t.isCollapsed()){const n=t.anchor.getNode(),r=e.getFirstChild(),i=zh(n);if(null!==i&&$d(r)){const t=r.getFirstChild();if(Id(t)&&e.is(dl(i,(n=>n.is(e)||n.is(t)))))return t.selectStart(),!0}}if(gi(t)){const{anchor:i,focus:o}=t,l=i.getNode(),a=o.getNode(),c=zh(l),u=zh(a),d=!(!c||!e.is($h(c))),h=!(!u||!e.is($h(u))),g=d!==h,p=d&&h,f=t.isBackward();if(g){const r=t.clone();if(h){const[t]=rh(e,u,u),n=t[0][0].cell,i=t[t.length-1].at(-1).cell;r.focus.set(f?n.getKey():i.getKey(),f?n.getChildrenSize():i.getChildrenSize(),"element")}else if(d){const[t]=rh(e,c,c),n=t[0][0].cell,i=t[t.length-1].at(-1).cell;r.anchor.set(f?i.getKey():n.getKey(),f?i.getChildrenSize():0,"element")}hs(r),Lh(n,s)}else if(p&&(c.is(u)||(s.$setAnchorCellForSelection(Vh(s,c)),s.$setFocusCellForSelection(Vh(s,u),!0)),"touch"===s.pointerType&&s.isSelecting&&t.isCollapsed()&&gi(r)&&r.isCollapsed())){const e=zh(r.anchor.getNode());e&&!e.is(u)&&(s.$setAnchorCellForSelection(Vh(s,e)),s.$setFocusCellForSelection(Vh(s,u),!0),s.pointerType=null)}}else if(t&&uh(t)&&t.is(r)&&t.tableKey===e.getKey()){const r=Zs(o);if(r&&r.anchorNode&&r.focusNode){const i=ls(r.focusNode),o=i&&!e.isParentOf(i),s=ls(r.anchorNode),l=s&&e.isParentOf(s);if(o&&l&&r.rangeCount>0){const i=function(e,t){return Ai(null,e,t,null)}(r,n);i&&(i.anchor.set(e.getKey(),t.isBackward()?e.getChildrenSize():0,"element"),r.removeAllRanges(),hs(i))}}}return t&&!t.is(r)&&(uh(t)||uh(r))&&s.tableSelection&&!s.tableSelection.is(r)?(uh(t)&&t.tableKey===s.tableNodeKey?s.$updateTableTableSelection(t):!uh(t)&&uh(r)&&r.tableKey===s.tableNodeKey&&s.$updateTableTableSelection(null),!1):(s.hasHijackedSelectionStyles&&!e.isSelected()?function(e,t){t.$enableHighlightStyle(),Ah(t.table,(t=>{const n=t.elem;t.highlighted=!1,Bh(e,t),n.getAttribute("style")||n.removeAttribute("style")}))}(n,s):!s.hasHijackedSelectionStyles&&e.isSelected()&&Lh(n,s),!1)}),3)),s.listenersToRemove.add(n.registerCommand(dn,(()=>{const t=Li();if(!gi(t)||!t.isCollapsed()||!Ph(t,e))return!1;const r=Wh(n,t,e);return!!r&&(Uh(r,e),!0)}),3)),s}function wh(e){return e[fh]||null}function kh(e){let t=e;for(;null!=t;){const e=t.nodeName;if("TD"===e||"TH"===e){const e=t._cell;return void 0===e?null:e}t=t.parentNode}return null}function Th(e,t){if(!e.contains(t))return null;let n=null;for(let r=t;null!=r;r=r.parentNode){if(r===e)return n;const t=r.nodeName;"TD"!==t&&"TH"!==t||(n=r._cell||null)}return null}function Eh(e,t){const n=[],r={columns:0,domRows:n,rows:0};let i=yh(e,t).querySelector("tr"),o=0,s=0;for(n.length=0;null!=i;){const e=i.nodeName;if("TD"===e||"TH"===e){const e={elem:i,hasBackgroundColor:""!==i.style.backgroundColor,highlighted:!1,x:o,y:s};i._cell=e;let t=n[s];void 0===t&&(t=n[s]=[]),t[o]=e}else{const e=i.firstChild;if(null!=e){i=e;continue}}const t=i.nextSibling;if(null!=t){o++,i=t;continue}const r=i.parentNode;if(null!=r){const e=r.nextSibling;if(null==e)break;s++,o=0,i=e}}return r.columns=o+1,r.rows=s+1,r}function Nh(e,t,n){const r=new Set(n?n.getNodes():[]);Ah(t,((t,n)=>{const i=t.elem;r.has(n)?(t.highlighted=!0,Dh(e,t)):(t.highlighted=!1,Bh(e,t),i.getAttribute("style")||i.removeAttribute("style"))}))}function Ah(e,t){const{domRows:n}=e;for(let e=0;e{t.highlighted=!0,Dh(e,t)}))}const Oh=(e,t,n,r,i)=>{const o="forward"===i;switch(i){case"backward":case"forward":return n!==(o?e.table.columns-1:0)?Mh(t.getCellNodeFromCordsOrThrow(n+(o?1:-1),r,e.table),o):r!==(o?e.table.rows-1:0)?Mh(t.getCellNodeFromCordsOrThrow(o?0:e.table.columns-1,r+(o?1:-1),e.table),o):o?t.selectNext():t.selectPrevious(),!0;case"up":return 0!==r?Mh(t.getCellNodeFromCordsOrThrow(n,r-1,e.table),!1):t.selectPrevious(),!0;case"down":return r!==e.table.rows-1?Mh(t.getCellNodeFromCordsOrThrow(n,r+1,e.table),!0):t.selectNext(),!0;default:return!1}};function Fh(e,t){let n,r;if(t.startColumn===e.minColumn)n="minColumn";else{if(t.startColumn+t.cell.__colSpan-1!==e.maxColumn)return null;n="maxColumn"}if(t.startRow===e.minRow)r="minRow";else{if(t.startRow+t.cell.__rowSpan-1!==e.maxRow)return null;r="maxRow"}return[n,r]}function Rh([e,t]){return["minColumn"===e?"maxColumn":"minColumn","minRow"===t?"maxRow":"minRow"]}function Ih(e,t,[n,r]){const i=t[r],o=e[i];void 0===o&&Md(250,r,String(i));const s=t[n],l=o[s];return void 0===l&&Md(250,n,String(s)),l}function Ph(e,t){if(gi(e)||uh(e)){const n=t.isParentOf(e.anchor.getNode()),r=t.isParentOf(e.focus.getNode());return n&&r}return!1}function Mh(e,t){t?e.selectStart():e.selectEnd()}function Dh(e,t){const n=t.elem,r=e._config.theme;Id(ls(n))||Md(131),La(n,r.tableCellSelected)}function Bh(e,t){const n=t.elem;Id(ls(n))||Md(131);Oa(n,e._config.theme.tableCellSelected)}function zh(e){const t=dl(e,Id);return Id(t)?t:null}function $h(e){const t=dl(e,eg);return eg(t)?t:null}function Hh(e,t,n,r,i){if(("up"===n||"down"===n)&&function(e){const t=e.getRootElement();return!!t&&(t.hasAttribute("aria-controls")&&"typeahead-menu"===t.getAttribute("aria-controls"))}(e))return!1;const o=Li();if(!Ph(o,r)){if(gi(o)){if("backward"===n){if(o.focus.offset>0)return!1;const e=function(e){for(let t=e,n=e;null!==n;t=n,n=n.getParent())if(po(n)){if(n!==t&&n.getFirstChild()!==t)return null;if(!n.isInline())return n}return null}(o.focus.getNode());if(!e)return!1;const n=e.getPreviousSibling();return!!eg(n)&&(Kh(t),t.shiftKey?o.focus.set(n.getParentOrThrow().getKey(),n.getIndexWithinParent(),"element"):n.selectEnd(),!0)}if(t.shiftKey&&("up"===n||"down"===n)){const e=o.focus.getNode();if(!o.isCollapsed()&&("up"===n&&!o.isBackward()||"down"===n&&o.isBackward())){let i=dl(e,(e=>eg(e)));if(Id(i)&&(i=dl(i,eg)),i!==r)return!1;if(!i)return!1;const s="down"===n?i.getNextSibling():i.getPreviousSibling();if(!s)return!1;let l=0;"up"===n&&po(s)&&(l=s.getChildrenSize());let a=s;if("up"===n&&po(s)){a=s.getLastChild()||s,l=ri(a)?a.getTextContentSize():0}const c=o.clone();return c.focus.set(a.getKey(),l,ri(a)?"text":"element"),hs(c),Kh(t),!0}if(Ks(e)){const e="up"===n?o.getNodes()[o.getNodes().length-1]:o.getNodes()[0];if(e&&null!==_h(r,e)){const e=r.getFirstDescendant(),t=r.getLastDescendant();if(!e||!t)return!1;const[n]=oh(e),[o]=oh(t),s=r.getCordsFromCellNode(n,i.table),l=r.getCordsFromCellNode(o,i.table),a=r.getDOMCellFromCordsOrThrow(s.x,s.y,i.table),c=r.getDOMCellFromCordsOrThrow(l.x,l.y,i.table);return i.$setAnchorCellForSelection(a),i.$setFocusCellForSelection(c,!0),!0}return!1}{let r=dl(e,(e=>po(e)&&!e.isInline()));if(Id(r)&&(r=dl(r,eg)),!r)return!1;const s="down"===n?r.getNextSibling():r.getPreviousSibling();if(eg(s)&&i.tableNodeKey===s.getKey()){const e=s.getFirstDescendant(),r=s.getLastDescendant();if(!e||!r)return!1;const[i]=oh(e),[l]=oh(r),a=o.clone();return a.focus.set(("up"===n?i:l).getKey(),"up"===n?0:l.getChildrenSize(),"element"),Kh(t),hs(a),!0}}}}return"down"===n&&Gh(e)&&i.setShouldCheckSelection(),!1}if(gi(o)){if("backward"===n||"forward"===n)return function(e,t,n,r,i,o,s){const l=Ul(n.focus,i?"previous":"next");if(Ql(l))return!1;let a=l;for(const e of Il(l).iterNodeCarets("shadowRoot")){if(!Sl(e)||!po(e.origin))return!1;a=e}const c=a.getParentAtCaret();if(!Id(c))return!1;const u=c,d=function(e){for(const t of Il(e).iterNodeCarets("root")){const{origin:n}=t;if(Id(n)){if(Cl(t))return Ll(n,e.direction)}else if(!$d(n))break}return null}(Tl(u,a.direction)),h=dl(u,eg);if(!h||!h.is(o))return!1;const g=e.getElementByKey(u.getKey()),p=kh(g);if(!g||!p)return!1;const f=Yh(e,h);if(s.table=f,d)if("extend"===r){const t=kh(e.getElementByKey(d.origin.getKey()));if(!t)return!1;s.$setAnchorCellForSelection(p),s.$setFocusCellForSelection(t,!0)}else{const e=Xl(d);Wl(n.anchor,e),Wl(n.focus,e)}else if("extend"===r)s.$setAnchorCellForSelection(p),s.$setFocusCellForSelection(p,!0);else{const e=function(e){const t=Ol(e);return Cl(t)?Xl(t):e}(Tl(h,l.direction));Wl(n.anchor,e),Wl(n.focus,e)}return Kh(t),!0}(e,t,o,t.shiftKey?"extend":"move","backward"===n,r,i);if(o.isCollapsed()){const{anchor:s,focus:l}=o,a=dl(s.getNode(),Id),c=dl(l.getNode(),Id);if(!Id(a)||!a.is(c))return!1;const u=$h(a);if(u!==r&&null!=u){const r=yh(u,e.getElementByKey(u.getKey()));if(null!=r)return i.table=Eh(u,r),Hh(e,t,n,u,i)}const d=e.getElementByKey(a.__key),h=e.getElementByKey(s.key);if(null==h||null==d)return!1;let g;if("element"===s.type)g=h.getBoundingClientRect();else{const t=Zs(bh(e));if(null===t||0===t.rangeCount)return!1;g=t.getRangeAt(0).getBoundingClientRect()}const p="up"===n?a.getFirstChild():a.getLastChild();if(null==p)return!1;const f=e.getElementByKey(p.__key);if(null==f)return!1;const m=f.getBoundingClientRect();if("up"===n?m.top>g.top-g.height:g.bottom+g.height>m.bottom){Kh(t);const e=r.getCordsFromCellNode(a,i.table);if(!t.shiftKey)return Oh(i,r,e.x,e.y,n);{const t=r.getDOMCellFromCordsOrThrow(e.x,e.y,i.table);i.$setAnchorCellForSelection(t),i.$setFocusCellForSelection(t,!0)}return!0}}}else if(uh(o)){const{anchor:s,focus:l}=o,a=dl(s.getNode(),Id),c=dl(l.getNode(),Id),[u]=o.getNodes();eg(u)||Md(251);const d=yh(u,e.getElementByKey(u.getKey()));if(!Id(a)||!Id(c)||!eg(u)||null==d)return!1;i.$updateTableTableSelection(o);const h=Eh(u,d),g=r.getCordsFromCellNode(a,h),p=r.getDOMCellFromCordsOrThrow(g.x,g.y,h);if(i.$setAnchorCellForSelection(p),Kh(t),t.shiftKey){const[e,t,o]=rh(r,a,c);return function(e,t,n,r,i){const o=sh(t,n,r),s=function(e,t){const{minColumn:n,maxColumn:r,minRow:i,maxRow:o}=t;let s=1,l=1,a=1,c=1;const u=e[i],d=e[o];for(let e=n;e<=r;e++)s=Math.max(s,u[e].cell.__rowSpan),c=Math.max(c,d[e].cell.__rowSpan);for(let t=i;t<=o;t++)l=Math.max(l,e[t][n].cell.__colSpan),a=Math.max(a,e[t][r].cell.__colSpan);return{bottomSpan:c,leftSpan:l,rightSpan:a,topSpan:s}}(t,o),{topSpan:l,leftSpan:a,bottomSpan:c,rightSpan:u}=s,d=function(e,t){const n=Fh(e,t);return null===n&&Md(249,t.cell.getKey()),n}(o,n),[h,g]=Rh(d);let p=o[h],f=o[g];"forward"===i?p+="maxColumn"===h?1:a:"backward"===i?p-="minColumn"===h?1:u:"down"===i?f+="maxRow"===g?1:l:"up"===i&&(f-="minRow"===g?1:c);const m=t[f];if(void 0===m)return!1;const y=m[p];if(void 0===y)return!1;const[b,_]=function(e,t,n){const r=sh(e,t,n),i=Fh(r,t);if(i)return[Ih(e,r,i),Ih(e,r,Rh(i))];const o=Fh(r,n);if(o)return[Ih(e,r,Rh(o)),Ih(e,r,o)];const s=["minColumn","minRow"];return[Ih(e,r,s),Ih(e,r,Rh(s))]}(t,n,y),x=Vh(e,b.cell),S=Vh(e,_.cell);return e.$setAnchorCellForSelection(x),e.$setFocusCellForSelection(S,!0),!0}(i,e,t,o,n)}return c.selectEnd(),!0}return!1}function Kh(e){e.preventDefault(),e.stopImmediatePropagation(),e.stopPropagation()}function Uh(e,t,n){const r=Eo();"first"===e?t.insertBefore(r):t.insertAfter(r),r.append(...n||[]),r.selectEnd()}function Wh(e,t,n){const r=n.getParent();if(!r)return;const i=Zs(bh(e));if(!i)return;const o=i.anchorNode,s=e.getElementByKey(r.getKey()),l=yh(n,e.getElementByKey(n.getKey()));if(!o||!s||!l||!s.contains(o)||l.contains(o))return;const a=dl(t.anchor.getNode(),(e=>Id(e)));if(!a)return;const c=dl(a,(e=>eg(e)));if(!eg(c)||!c.is(n))return;const[u,d]=rh(n,a,a),h=u[0][0],g=u[u.length-1][u[0].length-1],{startRow:p,startColumn:f}=d,m=p===h.startRow&&f===h.startColumn,y=p===g.startRow&&f===g.startColumn;return m?"first":y?"last":void 0}function Vh(e,t){const{tableNode:n}=e.$lookup(),r=n.getCordsFromCellNode(t,e.table);return n.getDOMCellFromCordsOrThrow(r.x,r.y,e.table)}function qh(e,t,n){return _h(e,ls(t,n))}function jh(e,t,n){if(!t.theme.tableAlignment)return;const r=[],i=[];for(const e of["center","right"]){const o=t.theme.tableAlignment[e];o&&(e===n?i:r).push(o)}Oa(e,...r),La(e,...i)}const Zh=new WeakSet;function Gh(e=nl()){return Zh.has(e)}class Jh extends go{__rowStriping;__frozenColumnCount;__frozenRowCount;__colWidths;static getType(){return"table"}getColWidths(){return this.getLatest().__colWidths}setColWidths(e){const t=this.getWritable();return t.__colWidths=e,t}static clone(e){return new Jh(e.__key)}afterCloneFrom(e){super.afterCloneFrom(e),this.__colWidths=e.__colWidths,this.__rowStriping=e.__rowStriping,this.__frozenColumnCount=e.__frozenColumnCount,this.__frozenRowCount=e.__frozenRowCount}static importDOM(){return{table:e=>({conversion:Xh,priority:1})}}static importJSON(e){return Qh().updateFromJSON(e)}updateFromJSON(e){return super.updateFromJSON(e).setRowStriping(e.rowStriping||!1).setFrozenColumns(e.frozenColumnCount||0).setFrozenRows(e.frozenRowCount||0).setColWidths(e.colWidths)}constructor(e){super(e),this.__rowStriping=!1,this.__frozenColumnCount=0,this.__frozenRowCount=0,this.__colWidths=void 0}exportJSON(){return{...super.exportJSON(),colWidths:this.getColWidths(),frozenColumnCount:this.__frozenColumnCount?this.__frozenColumnCount:void 0,frozenRowCount:this.__frozenRowCount?this.__frozenRowCount:void 0,rowStriping:this.__rowStriping?this.__rowStriping:void 0}}extractWithChild(e,t,n){return"html"===n}getDOMSlot(e){const t=mh(e)?e:e.querySelector("table");return mh(t)||Md(229),super.getDOMSlot(e).withElement(t).withAfter(t.querySelector("colgroup"))}createDOM(e,t){const n=document.createElement("table");this.__style&&(n.style.cssText=this.__style);const r=document.createElement("colgroup");if(n.appendChild(r),function(e){e.__lexicalUnmanaged=!0}(r),La(n,e.theme.table),this.updateTableElement(null,n,e),Gh(t)){const t=document.createElement("div"),r=e.theme.tableScrollableWrapper;return r?La(t,r):t.style.cssText="overflow-x: auto;",t.appendChild(n),this.updateTableWrapper(null,t,n,e),t}return n}updateTableWrapper(e,t,n,r){this.__frozenColumnCount!==(e?e.__frozenColumnCount:0)&&function(e,t,n,r){r>0?(La(e,n.theme.tableFrozenColumn),t.setAttribute("data-lexical-frozen-column","true")):(Oa(e,n.theme.tableFrozenColumn),t.removeAttribute("data-lexical-frozen-column"))}(t,n,r,this.__frozenColumnCount),this.__frozenRowCount!==(e?e.__frozenRowCount:0)&&function(e,t,n,r){r>0?(La(e,n.theme.tableFrozenRow),t.setAttribute("data-lexical-frozen-row","true")):(Oa(e,n.theme.tableFrozenRow),t.removeAttribute("data-lexical-frozen-row"))}(t,n,r,this.__frozenRowCount)}updateTableElement(e,t,n){this.__style!==(e?e.__style:"")&&(t.style.cssText=this.__style),this.__rowStriping!==(!!e&&e.__rowStriping)&&function(e,t,n){n?(La(e,t.theme.tableRowStriping),e.setAttribute("data-lexical-row-striping","true")):(Oa(e,t.theme.tableRowStriping),e.removeAttribute("data-lexical-row-striping"))}(t,n,this.__rowStriping),function(e,t,n,r){const i=e.querySelector("colgroup");if(!i)return;const o=[];for(let e=0;e{if(t.after&&(n=t.after(n)),!mh(n)&&Js(n)&&(n=n.querySelector("table")),!mh(n))return null;jh(n,e._config,this.getFormatType());const[r]=ih(this,null,null),i=new Map;for(const e of r)for(const t of e){const e=t.cell.getKey();i.has(e)||i.set(e,{colSpan:t.cell.getColSpan(),startColumn:t.startColumn})}const o=new Set;for(const e of n.querySelectorAll(":scope > tr > [data-temporary-table-cell-lexical-key]")){const t=e.getAttribute("data-temporary-table-cell-lexical-key");if(t){const n=i.get(t);if(e.removeAttribute("data-temporary-table-cell-lexical-key"),n){i.delete(t);for(let e=0;e colgroup");if(s){const e=Array.from(n.querySelectorAll(":scope > colgroup > col")).filter(((e,t)=>o.has(t)));s.replaceChildren(...e)}const l=n.querySelectorAll(":scope > tr");if(l.length>0){const e=document.createElement("tbody");for(const t of l)e.appendChild(t);n.append(e)}return n},element:!mh(n)&&Js(n)?n.querySelector("table"):n}}canBeEmpty(){return!1}isShadowRoot(){return!0}getCordsFromCellNode(e,t){const{rows:n,domRows:r}=t;for(let t=0;t{Id(e)&&(t+=e.getColSpan())})),t}}function Yh(e,t){const n=e.getElementByKey(t.getKey());return null===n&&Md(230),Eh(t,n)}function Xh(e){const t=Qh();e.hasAttribute("data-lexical-row-striping")&&t.setRowStriping(!0),e.hasAttribute("data-lexical-frozen-column")&&t.setFrozenColumns(1),e.hasAttribute("data-lexical-frozen-row")&&t.setFrozenRows(1);const n=e.querySelector(":scope > colgroup");if(n){let e=[];for(const t of n.querySelectorAll(":scope > col")){let n=t.style.width||"";if(!kd.test(n)&&(n=t.getAttribute("width")||"",!/^\d+$/.test(n))){e=void 0;break}e.push(parseFloat(n))}e&&t.setColWidths(e)}return{after:e=>Ba(e,$d),node:t}}function Qh(){return Ws(new Jh)}function eg(e){return e instanceof Jh}function tg({rows:e,columns:t,includeHeaders:n}){const r=Li()||Oi();if(!r||!gi(r))return!1;if($h(r.anchor.getNode()))return!1;const i=function(e,t,n=!0){const r=Qh();for(let i=0;iMath.max(e,t.length)),0),r=e.getChildren();for(let e=0;et?1+e:e),0);if(o!==n)for(let e=o;epo(e)&&!e.isInline()));return null!==n&&(!!Id(n.getParent())&&(n.select(0),!0))}function sg(e){let t=e;for(;null!==t;){if(kc(t))return t;t=t.getParent()}return null}function lg(e){let t=e;for(;t;){if(Fc(t))return t.getListType();t=t.getParent()}return null}function ag(e,t=e=>e){return cg(jr,e,((e,n)=>({...e,forChild:(r,i)=>{const o=e?.forChild??(e=>e);let s=o(r,i);return ri(s)&&(s=t(s,n)??s),s}})))}function cg(e,t,n=e=>e){return r=>{const i=e.importDOM()?.[t]?.(r);if(!i)return null;const o=i.conversion(r);return o?n(o,r)??o:o}}function ug(e){const t="string"==typeof e?la(e):e;return!(!t.color&&!t["background-color"])}function dg(e,t){const n=document.activeElement;if(e.includes(n)){new hg(e,t.key).selectNext(n)&&t.preventDefault()}}class hg{constructor(e,t){this.elements=e,this.key=t}selectNext(e){const t=this.#e(e);if(t){const e=this.elements.filter((e=>e!==t));return this.#t(e),this.#n(t),!0}return!1}#e(e){switch(this.key){case"ArrowRight":case"ArrowDown":return this.#r(e);case"ArrowLeft":case"ArrowUp":return this.#i(e);case"Home":return this.#o();case"End":return this.#s()}}#o(e=this.elements){return e.find(gg)}#s(e=this.elements){return e.findLast(gg)}#r(e){const t=this.elements.slice(this.#l(e)+1);return this.#o(t)}#i(e){const t=this.elements.slice(0,this.#l(e));return this.#s(t)}#l(e){return this.elements.indexOf(e)}#n(e){gg(e)&&(e.tabIndex=0,e.focus())}#t(e){e.forEach((e=>e.tabIndex=-1))}}function gg(e){return e&&!e.disabled&&e.checkVisibility()}class pg extends HTMLElement{static observedAttributes=["connected"];constructor(){super(),this.internals=this.attachInternals(),this.internals.role="toolbar"}connectedCallback(){requestAnimationFrame((()=>this.#a())),this.setAttribute("role","toolbar"),this.#c()}disconnectedCallback(){this.#u(),this.#d(),this.#h()}attributeChangedCallback(e,t,n){"connected"===e&&this.isConnected&&null!=t&&t!==n&&requestAnimationFrame((()=>this.#g()))}setEditor(e){this.editorElement=e,this.editor=e.editor,this.#p(),this.#f(),this.#m(),this.#y(),this.#b(),this.#_(),this.#a(),this.#x(),this.toggleAttribute("connected",!0)}#g(){this.disconnectedCallback(),this.connectedCallback()}#c(){this.resizeObserver=new ResizeObserver((()=>this.#a())),this.resizeObserver.observe(this)}#u(){this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null)}#p(){this.addEventListener("click",this.#S.bind(this))}#S(e){this.#C(e,"[data-command]",this.#v.bind(this))}#C(e,t,n){const r=e.target.closest(t);r&&n(e,r)}#v(e,{dataset:{command:t,payload:n}}){const r=e instanceof PointerEvent&&-1===e.pointerId;this.editor.update((()=>{this.editor.dispatchCommand(t,n)}),{tag:r?Ir:void 0})}#f(){this.editorElement.addEventListener("keydown",this.#w)}#d(){this.editorElement?.removeEventListener("keydown",this.#w)}#w=e=>{this.querySelectorAll("[data-hotkey]").forEach((t=>{t.dataset.hotkey.toLowerCase().split(/\s+/).includes(this.#k(e))&&(e.preventDefault(),e.stopPropagation(),t.click())}))};#k(e){const t=e.key.toLowerCase();return[...[e.ctrlKey?"ctrl":null,e.metaKey?"cmd":null,e.altKey?"alt":null,e.shiftKey?"shift":null].filter(Boolean),t].join("+")}#x(){this.editorElement.addEventListener("lexxy:focus",this.#T),this.editorElement.addEventListener("lexxy:blur",this.#E),this.addEventListener("focusout",this.#E),this.addEventListener("keydown",this.#N)}#h(){this.editorElement.removeEventListener("lexxy:focus",this.#T),this.editorElement.removeEventListener("lexxy:blur",this.#E),this.removeEventListener("focusout",this.#E),this.removeEventListener("keydown",this.#N)}#T=()=>{this.#m(),this.#A[0].tabIndex=0};#E=()=>{this.contains(document.activeElement)||this.#m()};#N=e=>{dg(this.#A,e)};#m(){this.#A.forEach((e=>{e.tabIndex=-1}))}#b(){this.editor.registerUpdateListener((()=>{this.editor.getEditorState().read((()=>{this.#L()}))}))}#_(){this.editor.registerUpdateListener((()=>{this.#O()}))}#O(){this.editor.getEditorState().read((()=>{const e=this.editorElement.historyState;e&&(this.#F("undo",0===e.undoStack.length),this.#F("redo",0===e.redoStack.length))}))}#L(){const e=Li();if(!gi(e))return;const t=e.anchor.getNode();if(!t.getParent())return;const n=t.getTopLevelElementOrThrow(),r=e.hasFormat("bold"),i=e.hasFormat("italic"),o=e.hasFormat("strikethrough"),s=function(e){return!!gi(e)&&(e.isCollapsed()?ug(e.style):e.hasFormat("highlight"))}(e),l=this.#R(t),a=uu(n),c=mu(n),u=Pu(n)||e.hasFormat("code"),d=this.#I(t),h=lg(t),g=null!==Wd(t);this.#P("bold",r),this.#P("italic",i),this.#P("strikethrough",o),this.#P("highlight",s),this.#P("link",l),this.#P("quote",a),this.#P("heading",c),this.#P("code",u),this.#P("unordered-list",d&&"bullet"===h),this.#P("ordered-list",d&&"number"===h),this.#P("table",g),this.#O()}#I(e){let t=e;for(;t;){if(Fc(t)||kc(t))return!0;t=t.getParent()}return!1}#R(e){let t=e;for(;t;){if(yd(t))return!0;t=t.getParent()}return!1}#P(e,t){const n=this.querySelector(`[name="${e}"]`);n&&n.setAttribute("aria-pressed",t.toString())}#F(e,t){const n=this.querySelector(`[name="${e}"]`);n&&(n.disabled=t,n.setAttribute("aria-disabled",t.toString()))}#M(){return this.scrollWidth>this.clientWidth}#a=()=>{this.#D(),this.#B(),this.#z.style.display=this.#$.children.length?"block":"none",this.#z.setAttribute("nonce",wa());const e=this.#$.children.length>0;this.toggleAttribute("overflowing",e),this.#$.toggleAttribute("disabled",!e)};#B(){const e=this.#H.reverse();let t=!1;for(const n of e){if(!this.#M()){t&&this.#$.prepend(n);break}this.#$.prepend(n),t=!0}}#D(){const e=Array.from(this.#$.children);e.sort(((e,t)=>this.#K(t)-this.#K(e))),e.forEach((e=>{const t=this.querySelector(`[data-position="${this.#K(e)+1}"]`)??this.#z;this.insertBefore(e,t)}))}#K(e){return parseInt(e.dataset.position??"999")}#y(){this.#U.forEach(((e,t)=>{void 0===e.dataset.position&&(e.dataset.position=t)}))}get#z(){return this.querySelector(".lexxy-editor__toolbar-overflow")}get#$(){return this.querySelector(".lexxy-editor__toolbar-overflow-menu")}get#H(){return Array.from(this.querySelectorAll(":scope > button"))}get#A(){return Array.from(this.querySelectorAll(":scope button, :scope > details > summary"))}get#U(){return Array.from(this.querySelectorAll(":scope > *:not(.lexxy-editor__toolbar-overflow)"))}static get defaultTemplate(){return'\n \n\n \n\n \n\n
    \n \n \n \n \n
    \n
    \n \n
    \n
    \n\n
    \n \n \n \n \n
    \n \n
    \n \n \n
    \n
    \n
    \n
    \n\n \n\n \n\n \n\n \n\n \n\n \n\n \n\n \n \n \n \n \n\n \n\n
    \n •••\n
    \n
    \n '}}function fg(e,t){const n={};for(const r of e){const e=t(r);e&&(n[e]?n[e].push(r):n[e]=[r])}return n}customElements.define("lexxy-toolbar",pg);const mg=/[!-/:-@[-`{-~\s]/;function yg(e,...t){const n=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",e);for(const e of t)r.append("v",e);throw n.search=r.toString(),Error(`Minified Lexical error #${e}; visit ${n.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}const bg=function(e,t){return new at(e,t)}("mdListMarker",{parse:e=>"string"==typeof e&&/^[-*+]$/.test(e)?e:"-"}),_g=e=>(t,n,r,i)=>{const o=e(r);o.append(...n),t.replace(o),i||o.select(0,0)},xg=e=>(t,n,r,i)=>{const o=t.getPreviousSibling(),s=t.getNextSibling(),l=wc("check"===e?"x"===r[3]:void 0),a=r[0].trim()[0],c="bullet"!==e&&"check"!==e||a!==bg.parse(a)?void 0:a;if(Fc(s)&&s.getListType()===e){c&&ut(s,bg,c);const e=s.getFirstChild();null!==e?e.insertBefore(l):s.append(l),t.remove()}else if(Fc(o)&&o.getListType()===e)c&&ut(o,bg,c),o.append(l),t.remove();else{const n=Oc(e,"number"===e?Number(r[2]):void 0);c&&ut(n,bg,c),n.append(l),t.replace(n)}l.append(...n),i||l.select(0,0);const u=function(e){const t=e.match(/\t/g),n=e.match(/ /g);let r=0;return t&&(r+=t.length),n&&(r+=Math.floor(n.length/4)),r}(r[1]);u&&l.setIndent(u)},Sg=(e,t,n)=>{const r=[],i=e.getChildren();let o=0;for(const s of i)if(kc(s)){if(1===s.getChildrenSize()){const e=s.getFirstChild();if(Fc(e)){r.push(Sg(e,t,n+1));continue}}const i=" ".repeat(4*n),l=e.getListType(),a=ct(e,bg),c="number"===l?`${e.getStart()+o}. `:"check"===l?`${a} [${s.getChecked()?"x":" "}] `:a+" ";r.push(i+c+t(s)),o++}return r.join("\n")},Cg={dependencies:[du],export:(e,t)=>{if(!mu(e))return null;const n=Number(e.getTag().slice(1));return"#".repeat(n)+" "+t(e)},regExp:/^(#{1,6})\s/,replace:_g((e=>fu("h"+e[1].length))),type:"element"},vg={dependencies:[au],export:(e,t)=>{if(!uu(e))return null;const n=t(e).split("\n"),r=[];for(const e of n)r.push("> "+e);return r.join("\n")},regExp:/^>\s/,replace:(e,t,n,r)=>{if(r){const n=e.getPreviousSibling();if(uu(n))return n.splice(n.getChildrenSize(),0,[Br(),...t]),void e.remove()}const i=cu();i.append(...t),e.replace(i),r||i.select(0,0)},type:"element"},wg={dependencies:[Ru],export:e=>{if(!Pu(e))return null;const t=e.getTextContent();return"```"+(e.getLanguage()||"")+(t?"\n"+t:"")+"\n```"},regExpEnd:{optional:!0,regExp:/[ \t]*```$/},regExpStart:/^[ \t]*```([\w-]+)?/,replace:(e,t,n,r,i,o)=>{let s,l;if(!t&&i){if(1===i.length)r?(s=Iu(),l=n[1]+i[0]):(s=Iu(n[1]),l=i[0].startsWith(" ")?i[0].slice(1):i[0]);else{if(s=Iu(n[1]),0===i[0].trim().length)for(;i.length>0&&!i[0].length;)i.shift();else i[0]=i[0].startsWith(" ")?i[0].slice(1):i[0];for(;i.length>0&&!i[i.length-1].length;)i.pop();l=i.join("\n")}const t=ni(l);s.append(t),e.append(s)}else t&&_g((e=>Iu(e?e[1]:void 0)))(e,t,n,o)},type:"multiline-element"},kg={dependencies:[Tc,Sc],export:(e,t)=>Fc(e)?Sg(e,t,0):null,regExp:/^(\s*)[-*+]\s/,replace:xg("bullet"),type:"element"},Tg={dependencies:[Tc,Sc],export:(e,t)=>Fc(e)?Sg(e,t,0):null,regExp:/^(\s*)(\d{1,})\.\s/,replace:xg("number"),type:"element"},Eg={dependencies:[pd],export:(e,t,n)=>{if(!yd(e)||xd(e))return null;const r=e.getTitle(),i=t(e);return r?`[${i}](${e.getURL()} "${r}")`:`[${i}](${e.getURL()})`},importRegExp:/(?:\[(.+?)\])(?:\((?:([^()\s]+)(?:\s"((?:[^"]*\\")*[^"]*)"\s*)?)\))/,regExp:/(?:\[(.+?)\])(?:\((?:([^()\s]+)(?:\s"((?:[^"]*\\")*[^"]*)"\s*)?)\))$/,replace:(e,t)=>{const[,n,r,i]=t,o=md(r,{title:i}),s=n.split("[").length-1,l=n.split("]").length-1;let a=n,c="";if(sl){const e=n.split("[");c="["+e[0],a=e.slice(1).join("[")}const u=ni(a);return u.setFormat(e.getFormat()),o.append(u),e.replace(o),c&&o.insertBefore(ni(c)),u},trigger:")",type:"text-match"},Ng=[...[Cg,vg,kg,Tg],...[wg],...[{format:["code"],tag:"`",type:"text-format"},{format:["bold","italic"],tag:"***",type:"text-format"},{format:["bold","italic"],intraword:!1,tag:"___",type:"text-format"},{format:["bold"],tag:"**",type:"text-format"},{format:["bold"],intraword:!1,tag:"__",type:"text-format"},{format:["highlight"],tag:"==",type:"text-format"},{format:["italic"],tag:"*",type:"text-format"},{format:["italic"],intraword:!1,tag:"_",type:"text-format"},{format:["strikethrough"],tag:"~~",type:"text-format"}],...[Eg]];function Ag(e,t,n){const r=n.length;for(let i=t;i>=r;i--){const t=i-r;if(Lg(e,t,n,0,r)&&" "!==e[t+r])return t}return-1}function Lg(e,t,n,r,i){for(let o=0;oe.type));return{element:t.element||[],multilineElement:t["multiline-element"]||[],textFormat:t["text-format"]||[],textMatch:t["text-match"]||[]}}(t),r=fg(n.textFormat,(({tag:e})=>e[e.length-1])),i=fg(n.textMatch,(({trigger:e})=>e));for(const n of t){const t=n.type;if("element"===t||"text-match"===t||"multiline-element"===t){const t=n.dependencies;for(const n of t)e.hasNode(n)||yg(173,n.getType())}}const o=(e,t,o)=>{(function(e,t,n,r){if(!Ks(e.getParent())||e.getFirstChild()!==t)return!1;const i=t.getTextContent();if(" "!==i[n-1])return!1;for(const{regExp:o,replace:s}of r){const r=i.match(o);if(r&&r[0].length===(r[0].endsWith(" ")?n:n-1)){const i=t.getNextSiblings(),[o,l]=t.splitText(n);if(!1!==s(e,l?[l,...i]:i,r,!1))return o.remove(),!0}}return!1})(e,t,o,n.element)||function(e,t,n,r){if(!Ks(e.getParent())||e.getFirstChild()!==t)return!1;const i=t.getTextContent();if(" "!==i[n-1])return!1;for(const{regExpStart:o,replace:s,regExpEnd:l}of r){if(l&&!("optional"in l)||l&&"optional"in l&&!l.optional)continue;const r=i.match(o);if(r&&r[0].length===(r[0].endsWith(" ")?n:n-1)){const i=t.getNextSiblings(),[o,l]=t.splitText(n);if(!1!==s(e,l?[l,...i]:i,r,null,null,!1))return o.remove(),!0}}return!1}(e,t,o,n.multilineElement)||function(e,t,n){let r=e.getTextContent();const i=n[r[t-1]];if(null==i)return!1;t1&&!Lg(r,l,n,0,s))continue;if(" "===r[l-1])continue;const a=r[i+1];if(!1===t.intraword&&a&&!mg.test(a))continue;const c=e;let u=c,d=Ag(r,l,n),h=u;for(;d<0&&(h=h.getPreviousSibling())&&!zr(h);)if(ri(h)){if(h.hasFormat("code"))continue;const e=h.getTextContent();u=h,d=Ag(e,e.length,n)}if(d<0)continue;if(u===c&&d+s===l)continue;const g=u.getTextContent();if(d>0&&g[d-1]===o)continue;const p=g[d-1];if(!1===t.intraword&&p&&!mg.test(p))continue;const f=c.getTextContent(),m=f.slice(0,l)+f.slice(i+1);c.setTextContent(m);const y=u===c?m:g;u.setTextContent(y.slice(0,d)+y.slice(d+s));const b=Li(),_=Ei();hs(_);const x=i-s*(u===c?2:1)+1;_.anchor.set(u.__key,d,"text"),_.focus.set(c.__key,x,"text");for(const e of t.format)_.hasFormat(e)||_.formatText(e);_.anchor.set(_.focus.key,_.focus.offset,_.focus.type);for(const e of t.format)_.hasFormat(e)&&_.toggleFormat(e);return gi(b)&&(_.format=b.format),!0}}(t,o,r)};return e.registerUpdateListener((({tags:t,dirtyLeaves:n,editorState:r,prevEditorState:i})=>{if(t.has(Fr)||t.has(Lr))return;if(e.isComposing())return;const s=r.read(Li),l=i.read(Li);if(!gi(l)||!gi(s)||!s.isCollapsed()||s.is(l))return;const a=s.anchor.key,c=s.anchor.offset,u=r._nodeMap.get(a);!ri(u)||!n.has(a)||1!==c&&c>l.anchor.offset+1||e.update((()=>{if(!function(e){return ri(e)&&!e.hasFormat("code")}(u))return;const e=u.getParent();null===e||Pu(e)||o(e,u,s.anchor.offset)}))}))}function Fg(e,t){let n=Date.now(),r=0;return(i,o,s,l,a,c)=>{const u=Date.now();if(c.has(Lr))return r=0,n=u,2;const d=function(e,t,n,r,i){if(null===e||0===n.size&&0===r.size&&!i)return 0;const o=t._selection,s=e._selection;if(i)return 1;if(!(gi(o)&&gi(s)&&s.isCollapsed()&&o.isCollapsed()))return 0;const l=function(e,t,n){const r=e._nodeMap,i=[];for(const e of t){const t=r.get(e);void 0!==t&&i.push(t)}for(const[e,t]of n){if(!t)continue;const n=r.get(e);void 0===n||_o(n)||i.push(n)}return i}(t,n,r);if(0===l.length)return 0;if(l.length>1){const n=t._nodeMap,r=n.get(o.anchor.key),i=n.get(s.anchor.key);return r&&i&&!e._nodeMap.has(r.__key)&&ri(r)&&1===r.__text.length&&1===o.anchor.offset?2:0}const a=l[0],c=e._nodeMap.get(a.__key);if(!ri(c)||!ri(a)||c.__mode!==a.__mode)return 0;const u=c.__text,d=a.__text;if(u===d)return 0;const h=o.anchor,g=s.anchor;if(h.key!==g.key||"text"!==h.type)return 0;const p=h.offset,f=g.offset,m=d.length-u.length;return 1===m&&f===p-1?2:-1===m&&f===p+1?3:-1===m&&f===p?4:0}(i,o,l,a,e.isComposing()),h=(()=>{const h=null===s||s.editor===e,g=c.has("history-push");if(!g&&h&&c.has(Or))return 0;if(null===i)return 1;const p=o._selection;if(!(l.size>0||a.size>0))return null!==p?0:2;const f="number"==typeof t?t:t.peek();return!1===g&&0!==d&&d===r&&ur.exportJSON())))===JSON.stringify(n.read((()=>i.exportJSON())))}(Array.from(l)[0],i,o)?0:1})();return n=u,r=d,h}}function Rg(e){e.undoStack=[],e.redoStack=[],e.current=null}function Ig(e,t,n){const r=Fg(e,n),i=Aa(e.registerCommand(bn,(()=>(function(e,t){const n=t.redoStack,r=t.undoStack;if(0!==r.length){const i=t.current,o=r.pop();null!==i&&(n.push(i),e.dispatchCommand(qn,!0)),0===r.length&&e.dispatchCommand(jn,!1),t.current=o||null,o&&o.editor.setEditorState(o.editorState,{tag:Lr})}}(e,t),!0)),0),e.registerCommand(_n,(()=>(function(e,t){const n=t.redoStack,r=t.undoStack;if(0!==n.length){const i=t.current;null!==i&&(r.push(i),e.dispatchCommand(jn,!0));const o=n.pop();0===n.length&&e.dispatchCommand(qn,!1),t.current=o||null,o&&o.editor.setEditorState(o.editorState,{tag:Lr})}}(e,t),!0)),0),e.registerCommand(Wn,(()=>(Rg(t),!1)),0),e.registerCommand(Vn,(()=>(Rg(t),e.dispatchCommand(qn,!1),e.dispatchCommand(jn,!1),!0)),0),e.registerUpdateListener((({editorState:n,prevEditorState:i,dirtyLeaves:o,dirtyElements:s,tags:l})=>{const a=t.current,c=t.redoStack,u=t.undoStack,d=null===a?null:a.editorState;if(null!==a&&n===d)return;const h=r(i,n,a,o,s,l);if(1===h)0!==c.length&&(t.redoStack=[],e.dispatchCommand(qn,!1)),null!==a&&(u.push({...a}),e.dispatchCommand(jn,!0));else if(2===h)return;t.current={editor:e,editorState:n}})));return i}function Pg(){return{current:null,redoStack:[],undoStack:[]}}var Mg={text:{bold:"lexxy-content__bold",italic:"lexxy-content__italic",strikethrough:"lexxy-content__strikethrough",underline:"lexxy-content__underline",highlight:"lexxy-content__highlight"},tableCellHeader:"lexxy-content__table-cell--header",tableCellSelected:"lexxy-content__table-cell--selected",tableSelection:"lexxy-content__table--selection",tableScrollableWrapper:"lexxy-content__table-wrapper",list:{nested:{listitem:"lexxy-nested-listitem"}},codeHighlight:{addition:"code-token__selector",atrule:"code-token__attr",attr:"code-token__attr","attr-name":"code-token__attr","attr-value":"code-token__selector",boolean:"code-token__property",bold:"code-token__variable",builtin:"code-token__selector",cdata:"code-token__comment",char:"code-token__selector",class:"code-token__function","class-name":"code-token__function",color:"code-token__property",comment:"code-token__comment",constant:"code-token__property",coord:"code-token__comment",decorator:"code-token__function",deleted:"code-token__operator",deletion:"code-token__operator",directive:"code-token__attr","directive-hash":"code-token__property",doctype:"code-token__comment",entity:"code-token__operator",function:"code-token__function",hexcode:"code-token__property",important:"code-token__function",inserted:"code-token__selector",italic:"code-token__comment",keyword:"code-token__attr",line:"code-token__selector",namespace:"code-token__variable",number:"code-token__property",macro:"code-token__function",operator:"code-token__operator",parameter:"code-token__variable",prolog:"code-token__comment",property:"code-token__property",punctuation:"code-token__punctuation","raw-string":"code-token__operator",regex:"code-token__variable",script:"code-token__function",selector:"code-token__selector",string:"code-token__selector",style:"code-token__function",symbol:"code-token__property",tag:"code-token__property",title:"code-token__function","type-definition":"code-token__function",url:"code-token__operator",variable:"code-token__variable"}};function Dg(e,t,n=""){const r=document.createElement(e);for(const[e,n]of Object.entries(t||{}))e in r?r[e]=n:null!=n&&r.setAttribute(e,n);return n&&(r.innerHTML=n),r}function Bg(e){return(new DOMParser).parseFromString(e,"text/html")}function zg(e,t,n){const r=new CustomEvent(t,{detail:n,bubbles:!0});e.dispatchEvent(r)}function $g(e,t,n=null,r=!1){return e.dispatchEvent(new CustomEvent(t,{bubbles:!0,detail:n,cancelable:r}))}function Hg(e){return`${e}-${Math.random().toString(36).slice(2,10)}`}function Kg(e){if(0===e)return"0 B";const t=Math.floor(Math.log(e)/Math.log(1024));return`${(e/Math.pow(1024,t)).toFixed(2)} ${["B","KB","MB","GB","TB","PB"][t]}`}class Ug extends mo{static getType(){return"action_text_attachment"}static clone(e){return new Ug({...e},e.__key)}static importJSON(e){return new Ug({...e})}static importDOM(){return{"action-text-attachment":e=>({conversion:()=>({node:new Ug({sgid:e.getAttribute("sgid"),src:e.getAttribute("url"),previewable:e.getAttribute("previewable"),altText:e.getAttribute("alt"),caption:e.getAttribute("caption"),contentType:e.getAttribute("content-type"),fileName:e.getAttribute("filename"),fileSize:e.getAttribute("filesize"),width:e.getAttribute("width"),height:e.getAttribute("height")})}),priority:1}),img:e=>({conversion:()=>({node:new Ug({src:e.getAttribute("src"),caption:e.getAttribute("alt")||"",contentType:"image/*",width:e.getAttribute("width"),height:e.getAttribute("height")})}),priority:1}),video:e=>{const t=e.getAttribute("src")||e.querySelector("source")?.src,n=t?.split("/")?.pop(),r=e.querySelector("source")?.getAttribute("content-type")||"video/*";return{conversion:()=>({node:new Ug({src:t,fileName:n,contentType:r})}),priority:1}}}}constructor({sgid:e,src:t,previewable:n,altText:r,caption:i,contentType:o,fileName:s,fileSize:l,width:a,height:c},u){super(u),this.sgid=e,this.src=t,this.previewable=n,this.altText=r||"",this.caption=i||"",this.contentType=o||"",this.fileName=s||"",this.fileSize=l,this.width=a,this.height=c}createDOM(){const e=this.createAttachmentFigure();return e.addEventListener("click",(t=>{this.#W(e)})),this.isPreviewableAttachment?(e.appendChild(this.#V()),e.appendChild(this.#q())):(e.appendChild(this.#j()),e.appendChild(this.#Z())),e}updateDOM(){return!0}getTextContent(){return`[${this.caption||this.fileName}]\n\n`}isInline(){return!1}exportDOM(){return{element:Dg("action-text-attachment",{sgid:this.sgid,previewable:this.previewable||null,url:this.src,alt:this.altText,caption:this.caption,"content-type":this.contentType,filename:this.fileName,filesize:this.fileSize,width:this.width,height:this.height,presentation:"gallery"})}}exportJSON(){return{type:"action_text_attachment",version:1,sgid:this.sgid,src:this.src,previewable:this.previewable,altText:this.altText,caption:this.caption,contentType:this.contentType,fileName:this.fileName,fileSize:this.fileSize,width:this.width,height:this.height}}decorate(){return null}createAttachmentFigure(){return e=this.contentType,t=this.isPreviewableAttachment,n=this.fileName,Dg("figure",{className:`attachment attachment--${t?"preview":"file"} attachment--${n?n.split(".").pop().toLowerCase():"unknown"}`,"data-content-type":e});var e,t,n}get#G(){return(e=this.contentType).startsWith("image/")&&!e.includes("svg");var e}get isPreviewableAttachment(){return this.#G||this.previewable}#V(){return Dg("img",{src:this.src,alt:this.altText,...this.#J})}get#J(){return this.width&&this.height?{width:this.width,height:this.height}:{}}#j(){return Dg("span",{className:"attachment__icon",textContent:`${this.fileName?this.fileName.split(".").pop().toLowerCase():"unknown"}`})}#Z(){const e=Dg("figcaption",{className:"attachment__caption"}),t=Dg("strong",{className:"attachment__name",textContent:this.caption||this.fileName});if(e.appendChild(t),this.fileSize){const t=Dg("span",{className:"attachment__size",textContent:Kg(this.fileSize)});e.appendChild(t)}return e}#W(e){zg(e,"lexxy:internal:select-node",{key:this.getKey()})}#q(){const e=Dg("figcaption",{className:"attachment__caption"}),t=Dg("textarea",{value:this.caption,placeholder:this.fileName,rows:"1"});return t.addEventListener("focusin",(()=>t.placeholder="Add caption...")),t.addEventListener("blur",this.#Y.bind(this)),t.addEventListener("keydown",this.#X.bind(this)),e.appendChild(t),e}#Y(e){const t=e.target;t.placeholder=this.fileName,this.#Q(t)}#Q(e){zg(e,"lexxy:internal:invalidate-node",{key:this.getKey(),values:{caption:e.value}})}#X(e){"Enter"===e.key&&(this.#Q(e.target),zg(e.target,"lexxy:internal:move-to-next-line"),e.preventDefault()),e.stopPropagation()}}class Wg extends Ug{static getType(){return"action_text_attachment_upload"}static clone(e){return new Wg({...e},e.__key)}static importJSON(e){return new Wg({...e})}static importDOM(){return null}constructor({file:e,uploadUrl:t,blobUrlTemplate:n,editor:r,progress:i},o){super({contentType:e.type},o),this.file=e,this.uploadUrl=t,this.blobUrlTemplate=n,this.src=null,this.editor=r,this.progress=i||0}createDOM(){const e=this.createAttachmentFigure();this.isPreviewableAttachment?e.appendChild(this.#V()):e.appendChild(this.#j()),e.appendChild(this.#ee());const t=Dg("progress",{value:this.progress,max:100});return e.appendChild(t),this.#te(e).then((()=>this.#ne(t,e))),e}exportDOM(){const e=document.createElement("img");return this.src&&(e.src=this.src),{element:e}}exportJSON(){return{type:"action_text_attachment_upload",version:1,progress:this.progress,uploadUrl:this.uploadUrl,blobUrlTemplate:this.blobUrlTemplate,...super.exportJSON()}}#V(){return Dg("img")}#j(){return Dg("span",{className:"attachment__icon",textContent:this.#re()})}#re(){return this.file.name.split(".").pop().toLowerCase()}#ee(){const e=Dg("figcaption",{className:"attachment__caption"}),t=Dg("span",{className:"attachment__name",textContent:this.file.name||""}),n=Dg("span",{className:"attachment__size",textContent:Kg(this.file.size)});return e.appendChild(t),e.appendChild(n),e}#te(e){const t=e.querySelector("img");return t?async function(e,t){return new Promise((n=>{const r=new FileReader;t.addEventListener("load",(()=>{n(t)})),r.onload=e=>{t.src=e.target.result||null},r.readAsDataURL(e)}))}(this.file,t):Promise.resolve()}#ne(t,n){const r=new e(this.file,this.uploadUrl,this);r.delegate={directUploadWillStoreFileWithXHR:e=>{e.upload.addEventListener("progress",(e=>{this.editor.update((()=>{t.value=Math.round(e.loaded/e.total*100)}))}))}},r.create(((e,t)=>{e?this.#ie(n):this.#oe(t,n).then((()=>{this.#se(n,t)}))}))}#ie(e){e.innerHTML="",e.classList.add("attachment--error"),e.appendChild(Dg("div",{innerText:`Error uploading ${this.file?.name??"image"}`}))}async#se(e,t){this.editor.update((()=>{const n=e.querySelector("img"),r=this.blobUrlTemplate.replace(":signed_id",t.signed_id).replace(":filename",encodeURIComponent(t.filename)),i=is(this.getKey());i&&i.replace(new Ug({sgid:t.attachable_sgid,src:t.previewable?t.url:r,altText:t.filename,contentType:t.content_type,fileName:t.filename,fileSize:t.byte_size,width:n?.naturalWidth,previewable:t.previewable,height:n?.naturalHeight}))}),{tag:Or})}async#oe(e,t){return e.previewable?new Promise((n=>{this.editor.update((()=>{const r=this.#V();r.addEventListener("load",(()=>{n()})),r.src=e.url,t.insertBefore(r,t.firstChild)}))})):Promise.resolve()}}class Vg extends mo{static getType(){return"horizontal_divider"}static clone(e){return new Vg(e.__key)}static importJSON(e){return new Vg}static importDOM(){return{hr:e=>({conversion:()=>({node:new Vg}),priority:1})}}constructor(e){super(e)}createDOM(){const e=Dg("figure",{className:"horizontal-divider"}),t=Dg("hr");return e.addEventListener("click",(t=>{zg(e,"lexxy:internal:select-node",{key:this.getKey()})})),e.appendChild(t),e}updateDOM(){return!0}getTextContent(){return"┄\n\n"}isInline(){return!1}exportDOM(){return{element:Dg("hr")}}exportJSON(){return{type:"horizontal_divider",version:1}}decorate(){return null}}const qg=["bold","italic","strikethrough","link","unlink","toggleHighlight","removeHighlight","rotateHeadingFormat","insertUnorderedList","insertOrderedList","insertQuoteBlock","insertCodeBlock","insertHorizontalDivider","uploadAttachments","insertTable","insertTableRowAbove","insertTableRowBelow","insertTableColumnAfter","insertTableColumnBefore","deleteTableRow","deleteTableColumn","deleteTable","undo","redo"];class jg{static configureFor(e){new jg(e)}constructor(e){this.editorElement=e,this.editor=e.editor,this.selection=e.selection,this.contents=e.contents,this.clipboard=e.clipboard,this.highlighter=e.highlighter,this.#le(),this.#ae(),this.#ce()}dispatchPaste(e){return this.clipboard.paste(e)}dispatchBold(){this.editor.dispatchCommand(yn,"bold")}dispatchItalic(){this.editor.dispatchCommand(yn,"italic")}dispatchStrikethrough(){this.editor.dispatchCommand(yn,"strikethrough")}dispatchToggleHighlight(e){this.highlighter.toggle(e)}dispatchRemoveHighlight(){this.highlighter.remove()}dispatchLink(e){this.editor.update((()=>{const t=Li();if(gi(t))if(t.isCollapsed()){const n=_d(e),r=ni(e);n.append(r),t.insertNodes([n])}else Cd(e)}))}dispatchUnlink(){this.#ue(null)}dispatchInsertUnorderedList(){const e=Li();if(!e)return;const t=e.anchor.getNode();this.selection.isInsideList&&t&&"bullet"===lg(t)?this.contents.unwrapSelectedListItems():this.editor.dispatchCommand(Ic,void 0)}dispatchInsertOrderedList(){const e=Li();if(!e)return;const t=e.anchor.getNode();this.selection.isInsideList&&t&&"number"===lg(t)?this.contents.unwrapSelectedListItems():this.editor.dispatchCommand(Pc,void 0)}dispatchInsertQuoteBlock(){this.contents.toggleNodeWrappingAllSelectedNodes((e=>uu(e)),(()=>cu()))}dispatchInsertCodeBlock(){this.editor.update((()=>{this.selection.hasSelectedWordsInSingleLine?this.editor.dispatchCommand(yn,"code"):this.contents.toggleNodeWrappingAllSelectedLines((e=>Pu(e)),(()=>new Ru("plain")))}))}dispatchInsertHorizontalDivider(){this.editor.update((()=>{this.contents.insertAtCursorEnsuringLineBelow(new Vg)})),this.editor.focus()}dispatchRotateHeadingFormat(){this.editor.update((()=>{const e=Li();if(!gi(e))return;const t=e.anchor.getNode().getTopLevelElementOrThrow();let n="h2";if(mu(t)){const e=t.getTag();n="h2"===e?"h3":"h3"===e?"h4":"h4"===e?null:"h2"}n?this.contents.insertNodeWrappingEachSelectedLine((()=>fu(n))):this.contents.removeFormattingFromSelectedLines()}))}dispatchUploadAttachments(){const e=Dg("input",{type:"file",multiple:!0,style:"display: none;",onchange:({target:e})=>{const t=Array.from(e.files);if(t.length)for(const e of t)this.contents.uploadFile(e)}});this.editorElement.appendChild(e),e.click(),setTimeout((()=>e.remove()),1e3)}dispatchInsertTable(){this.editor.dispatchCommand(Pd,{rows:3,columns:3,includeHeaders:!0})}dispatchInsertTableRowBelow(){Zd(!0)}dispatchInsertTableRowAbove(){Zd(!1)}dispatchInsertTableColumnAfter(){Jd(!0)}dispatchInsertTableColumnBefore(){Jd(!1)}dispatchDeleteTableRow(){!function(){const e=Li();gi(e)||uh(e)||Md(188);const[t,n]=e.isBackward()?[e.focus.getNode(),e.anchor.getNode()]:[e.anchor.getNode(),e.focus.getNode()],[r,,i]=oh(t),[o]=oh(n),[s,l,a]=rh(i,r,o),{startRow:c}=l,{startRow:u}=a,d=u+o.__rowSpan-1;if(s.length===d-c+1)return void i.remove();const h=s[0].length,g=s[d+1],p=i.getChildAtIndex(d+1);for(let e=d;e>=c;e--){for(let t=h-1;t>=0;t--){const{cell:n,startRow:r,startColumn:i}=s[e][t];if(i===t){if(rd){const e=Math.max(r,c),t=Math.min(n.__rowSpan+r-1,d),i=e<=t?t-e+1:0;n.setRowSpan(n.__rowSpan-i)}if(r>=c&&r+n.__rowSpan-1>d&&e===d){null===p&&Md(122);let r=null;for(let n=0;n1&&(n+=i.__colSpan-1)}null===r?Qd(p,n):r.insertAfter(n)}}}const t=i.getChildAtIndex(e);$d(t)||Md(206,String(e)),t.remove()}if(void 0!==g){const{cell:e}=g[0];Xd(e)}else{const e=s[c-1],{cell:t}=e[0];Xd(t)}}()}dispatchDeleteTableColumn(){!function(){const e=Li();gi(e)||uh(e)||Md(188);const t=e.anchor.getNode(),n=e.focus.getNode(),[r,,i]=oh(t),[o]=oh(n),[s,l,a]=rh(i,r,o),{startColumn:c}=l,{startRow:u,startColumn:d}=a,h=Math.min(c,d),g=Math.max(c+r.__colSpan-1,d+o.__colSpan-1),p=g-h+1;if(s[0].length===g-h+1)return i.selectPrevious(),void i.remove();const f=s.length;for(let e=0;eg){if(t===g){const e=g-r+1;n.setColSpan(n.__colSpan-e)}}else n.remove()}const m=s[u],y=c>d?m[c+r.__colSpan]:m[d+o.__colSpan];if(void 0!==y){const{cell:e}=y;Xd(e)}else{const e=d{const e=Li();if(!gi(e))return;$h(e.anchor.getNode()).remove()}))}dispatchUndo(){this.editor.dispatchCommand(bn,void 0)}dispatchRedo(){this.editor.dispatchCommand(_n,void 0)}#le(){for(const t of qg){const n=`dispatch${e=t,e.charAt(0).toUpperCase()+e.slice(1)}`;this.#de(t,0,this[n].bind(this))}var e;this.#de(gn,1,this.dispatchPaste.bind(this))}#de(e,t,n){this.editor.registerCommand(e,n,t)}#ae(){this.editor.registerCommand(Fn,this.#he.bind(this),2)}#ce(){this.editorElement.supportsAttachments&&(this.dragCounter=0,this.editor.getRootElement().addEventListener("dragover",this.#ge.bind(this)),this.editor.getRootElement().addEventListener("drop",this.#pe.bind(this)),this.editor.getRootElement().addEventListener("dragenter",this.#fe.bind(this)),this.editor.getRootElement().addEventListener("dragleave",this.#me.bind(this)))}#fe(e){this.dragCounter++,1===this.dragCounter&&this.editor.getRootElement().classList.add("lexxy-editor--drag-over")}#me(e){this.dragCounter--,0===this.dragCounter&&this.editor.getRootElement().classList.remove("lexxy-editor--drag-over")}#ge(e){e.preventDefault()}#pe(e){e.preventDefault(),this.dragCounter=0,this.editor.getRootElement().classList.remove("lexxy-editor--drag-over");const t=e.dataTransfer;if(!t)return;const n=Array.from(t.files);if(n.length){for(const e of n)this.contents.uploadFile(e);this.editor.focus()}}#he(e){return this.selection.isInsideList?this.#ye(e):!!this.selection.isInsideCodeBlock&&this.#be()}#ye(e){if(e.shiftKey&&!this.selection.isIndentedList)return!1;e.preventDefault();const t=e.shiftKey?Pn:In;return this.editor.dispatchCommand(t)}#be(){const e=Li();return gi(e)&&e.isCollapsed()}#ue(e){this.editor.update((()=>{Cd(null===e?null:e)}))}}function Zg(){return new Promise(requestAnimationFrame)}class Gg{constructor(e){this.editorElement=e,this.editorContentElement=e.editorContentElement,this.editor=this.editorElement.editor,this.previouslySelectedKeys=new Set,this.#_e(),this.#xe(),this.#Se(),this.#Ce()}set current(e){this.editor.update((()=>{this.#ve()}))}get hasNodeSelection(){let e=!1;return this.editor.getEditorState().read((()=>{const t=Li();e=null!==t&&fi(t)})),e}get cursorPosition(){let e={x:0,y:0};return this.editor.getEditorState().read((()=>{const t=this.#we();if(!t)return;const n=this.#ke(t);n&&(e=this.#Te(n,t))})),e}placeCursorAtTheEnd(){this.editor.update((()=>{us().selectEnd()}))}selectedNodeWithOffset(){const e=Li();if(!e)return{node:null,offset:0};if(gi(e))return{node:e.anchor.getNode(),offset:e.anchor.offset};if(fi(e)){const[t]=e.getNodes();return{node:t,offset:0}}return{node:null,offset:0}}preservingSelection(e){let t=null;this.editor.getEditorState().read((()=>{const e=Li();e&&gi(e)&&(t={anchor:{key:e.anchor.key,offset:e.anchor.offset},focus:{key:e.focus.key,offset:e.focus.offset}})})),e(),t&&this.editor.update((()=>{const e=Li();e&&gi(e)&&(e.anchor.set(t.anchor.key,t.anchor.offset,"text"),e.focus.set(t.focus.key,t.focus.offset,"text"))}))}get hasSelectedWordsInSingleLine(){const e=Li();if(!gi(e))return!1;if(e.isCollapsed())return!1;const t=e.anchor.getNode(),n=e.focus.getNode();if(t.getTopLevelElement()!==n.getTopLevelElement())return!1;if(!t.getTopLevelElement())return!1;const r=e.getNodes();for(const e of r)if(zr(e))return!1;return!0}get isInsideList(){const e=Li();if(!gi(e))return!1;return null!==sg(e.anchor.getNode())}get isIndentedList(){const e=Li();if(!gi(e))return!1;const t=e.getNodes();for(const e of t){const t=Ra(e,Tc);if(t&&lc(t)>1)return!0}return!1}get isInsideCodeBlock(){const e=Li();if(!gi(e))return!1;return null!==Ra(e.anchor.getNode(),Ru)}get nodeAfterCursor(){const{anchorNode:e,offset:t}=this.#Ee();return e?ri(e)?this.#Ne(e,t):po(e)?this.#Ae(e,t):this.#Le(e):null}get topLevelNodeAfterCursor(){const{anchorNode:e,offset:t}=this.#Ee();return e?ri(e)?this.#Oe(e):po(e)?this.#Ae(e,t):this.#Le(e):null}get nodeBeforeCursor(){const{anchorNode:e,offset:t}=this.#Ee();return e?ri(e)?this.#Fe(e,t):po(e)?this.#Re(e,t):this.#Ie(e):null}get topLevelNodeBeforeCursor(){const{anchorNode:e,offset:t}=this.#Ee();return e?ri(e)?this.#Pe(e):po(e)?this.#Re(e,t):this.#Ie(e):null}get#Me(){return this.editorElement.contents}get#De(){if(this.currentlySelectedKeys)return this.currentlySelectedKeys;this.currentlySelectedKeys=new Set;const e=Li();if(e&&fi(e))for(const t of e.getNodes())this.currentlySelectedKeys.add(t.getKey());return this.currentlySelectedKeys}#xe(){this.editor.registerCommand(vn,this.#Be.bind(this),1),this.editor.registerCommand(Sn,this.#ze.bind(this),1),this.editor.registerCommand(kn,this.#$e.bind(this),1),this.editor.registerCommand(Tn,this.#He.bind(this),1),this.editor.registerCommand(On,this.#Ke.bind(this),1),this.editor.registerCommand(An,this.#Ue.bind(this),1),this.editor.registerCommand(sn,(()=>{this.current=Li()}),1)}#_e(){this.editor.getRootElement().addEventListener("lexxy:internal:select-node",(async e=>{await Zg();const{key:t}=e.detail;this.editor.update((()=>{const e=is(t);if(e){const t=Ni();t.add(e.getKey()),hs(t)}this.editor.focus()}))})),this.editor.getRootElement().addEventListener("lexxy:internal:move-to-next-line",(e=>{this.#We()}))}#Se(){this.editor.getRootElement().addEventListener("keydown",(e=>{(function(e){return!(e.ctrlKey||e.metaKey||e.altKey||e.key.length>1&&"Enter"!==e.key&&"Space"!==e.key||1!==e.key.length)})(e)&&this.editor.update((()=>{const t=Li();if(gi(t)&&t.isCollapsed()){const n=t.anchor.getNode(),r=t.anchor.offset,i=this.#Ve(n,r),o=this.#qe(n,r);if(i instanceof mo&&!i.isInline())return e.preventDefault(),void this.#Me.createParagraphAfterNode(i,e.key);if(o instanceof mo&&!o.isInline())return e.preventDefault(),void this.#Me.createParagraphBeforeNode(o,e.key)}}))}),!0)}#Ve(e,t){return ri(e)&&0===t?e.getPreviousSibling():po(e)&&t>0?e.getChildAtIndex(t-1):null}#qe(e,t){return ri(e)&&t===e.getTextContentSize()?e.getNextSibling():po(e)?e.getChildAtIndex(t):null}#Ce(){this.editorContentElement.addEventListener("keydown",(e=>{if("ArrowUp"===e.key){const t=this.editor.getRootElement().querySelector("[data-lexical-cursor]");if(t){let n=t.previousElementSibling;for(;n&&n.hasAttribute("data-lexical-cursor");)n=n.previousElementSibling;n||e.preventDefault()}}if("ArrowDown"===e.key){const t=this.editor.getRootElement().querySelector("[data-lexical-cursor]");if(t){let n=t.nextElementSibling;for(;n&&n.hasAttribute("data-lexical-cursor");)n=n.nextElementSibling;n||e.preventDefault()}}}),!0)}#ve(){this.#je(),this.#Ze(),this.previouslySelectedKeys=this.#De,this.currentlySelectedKeys=null}#je(){for(const e of this.previouslySelectedKeys)if(!this.#De.has(e)){const t=this.editor.getElementByKey(e);t&&t.classList.remove("node--selected")}}#Ze(){for(const e of this.#De)if(!this.previouslySelectedKeys.has(e)){const t=this.editor.getElementByKey(e);t&&t.classList.add("node--selected")}}async#Be(){this.hasNodeSelection?await this.#Ge((e=>e.selectPrevious())):this.#Je(this.nodeBeforeCursor)}async#ze(){this.hasNodeSelection?await this.#Ge((e=>e.selectNext(0,0))):this.#Je(this.nodeAfterCursor)}async#$e(){this.hasNodeSelection?await this.#Ge((e=>e.selectPrevious())):this.#Je(this.topLevelNodeBeforeCursor)}async#He(){this.hasNodeSelection?await this.#Ge((e=>e.selectNext(0,0))):this.#Je(this.topLevelNodeAfterCursor)}async#Ge(e){await Zg(),this.hasNodeSelection&&this.editor.update((()=>{e(Li().getNodes()[0]),this.editor.focus()}))}async#We(){this.editor.update((()=>{const e=this.#Ye();e&&this.#Xe(e)}))}#Ye(){const e=Li();return e?fi(e)?this.#Qe(e):gi(e)?this.#et(e):null:null}#Qe(e){const t=e.getNodes();return t.length>0?t[0].getTopLevelElement():null}#et(e){return e.anchor.getNode().getTopLevelElement()}#Xe(e){const t=e.getNextSibling();t?t.selectStart():this.#tt()}#tt(){const e=us(),t=Eo();e.append(t),t.selectStart()}#Je(e){e&&e instanceof mo&&this.editor.update((()=>{const t=Ni();t.add(e.getKey()),hs(t)}))}#Ke(){const e=this.nodeAfterCursor;return e instanceof mo?(this.#Je(e),!0):(this.#Me.deleteSelectedNodes(),!1)}#Ue(){const e=this.nodeBeforeCursor;return e instanceof mo?(this.#Je(e),!0):(this.#Me.deleteSelectedNodes(),!1)}#we(){const e=Li();if(!e||!e.isCollapsed())return null;const t=window.getSelection();return t&&0!==t.rangeCount?t.getRangeAt(0):null}#ke(e){let t=e.getBoundingClientRect();if(this.#nt(t)){const n=this.#rt(e);t=n.getBoundingClientRect(),this.#it(n),n.remove()}return t}#nt(e){return 0===e.width&&0===e.height||0===e.top&&0===e.left}#rt(e){const t=this.#ot();return e.insertNode(t),t}#ot(){const e=document.createElement("span");return e.textContent="​",e.style.display="inline-block",e.style.width="1px",e.style.height="1em",e.style.lineHeight="normal",e.setAttribute("nonce",wa()),e}#it(e){const t=window.getSelection();t.removeAllRanges();const n=document.createRange();n.setStartAfter(e),n.collapse(!0),t.addRange(n)}#Te(e,t){const n=this.editor.getRootElement().getBoundingClientRect(),r=e.left-n.left;let i=e.top-n.top;const o=this.#st(t);return isNaN(o)||(i+=o),{x:r,y:i,fontSize:o}}#st(e){const t=window.getSelection().anchorNode,n=this.#lt(t);if(n instanceof HTMLElement){const e=window.getComputedStyle(n);return parseFloat(e.fontSize)}return 0}#lt(e){return e?.nodeType===Node.TEXT_NODE?e.parentElement:e}#Ee(){const e=Li();if(!gi(e)||!e.isCollapsed())return{anchorNode:null,offset:0};const{anchor:t}=e;return{anchorNode:t.getNode(),offset:t.offset}}#Ne(e,t){return t===e.getTextContentSize()?this.#Oe(e):null}#Oe(e){if(e.getNextSibling()instanceof mo)return e.getNextSibling();const t=e.getParent();return t?t.getNextSibling():null}#Ae(e,t){return t0?e.getChildAtIndex(t-1):this.#Ie(e)}#Le(e){let t=e;for(;t&&null==t.getNextSibling();)t=t.getParent();return t?t.getNextSibling():null}#Ie(e){let t=e;for(;t&&null==t.getPreviousSibling();)t=t.getParent();return t?t.getPreviousSibling():null}}class Jg extends mo{static getType(){return"custom_action_text_attachment"}static clone(e){return new Jg({...e},e.__key)}static importJSON(e){return new Jg({...e})}static importDOM(){return{"action-text-attachment":e=>{const t=e.getAttribute("content");return e.getAttribute("content")?{conversion:()=>{const n=[],r=e.previousSibling;return r&&r.nodeType===Node.TEXT_NODE&&/\s$/.test(r.textContent)&&n.push(ni(" ")),n.push(new Jg({sgid:e.getAttribute("sgid"),innerHtml:JSON.parse(t),contentType:e.getAttribute("content-type")})),n.push(ni(" ")),{node:n}},priority:2}:null}}}constructor({sgid:e,contentType:t,innerHtml:n},r){super(r),this.sgid=e,this.contentType=t||"application/vnd.actiontext.unknown",this.innerHtml=n}createDOM(){const e=Dg("action-text-attachment",{"content-type":this.contentType,"data-lexxy-decorator":!0});return e.addEventListener("click",(t=>{zg(e,"lexxy:internal:select-node",{key:this.getKey()})})),e.insertAdjacentHTML("beforeend",this.innerHtml),e}updateDOM(){return!0}getTextContent(){return this.createDOM().textContent.trim()||`[${this.contentType}]`}isInline(){return!0}exportDOM(){return{element:Dg("action-text-attachment",{sgid:this.sgid,content:JSON.stringify(this.innerHtml),"content-type":this.contentType})}}exportJSON(){return{type:"custom_action_text_attachment",version:1,sgid:this.sgid,contentType:this.contentType,innerHtml:this.innerHtml}}decorate(){return null}}class Yg{constructor(e){this.editorElement=e,this.editor=e.editor}monitor(){this.editor.registerCommand(En,(e=>this.#at(e)),3)}#at(e){const t=Li();if(!gi(t))return!1;const n=t.anchor.getNode();return!!this.#ct(n)&&(this.#ut(e,n)||this.#dt(e,n))}#ut(e,t){return!(!this.#ht(t)&&!this.#gt(t))&&(e.preventDefault(),this.#pt(t),!0)}#dt(e,t){return!!this.#ft(t)&&(e.preventDefault(),this.#mt(t),!0)}#ct(e){let t=e;for(;t;){if(uu(t))return!0;t=t.getParent()}return!1}#ht(e){const t=this.#yt(e);return!!t&&this.#bt(t)}#gt(e){const t=this.#_t(e);if(!t)return!1;if(!this.#bt(t))return!1;const n=t.getParent();return n&&kc(n)}#bt(e){if(""!==e.getTextContent().trim())return!1;const t=e.getChildren();return 0===t.length||t.every((e=>!!zr(e)||this.#bt(e)))}#yt(e){let t=e;for(;t;){if(kc(t))return t;t=t.getParent()}return null}#pt(e){const t=this.#yt(e);if(!t)return;const n=t.getParent();if(!n||!Fc(n))return;const r=n.getParent();if(r&&uu(r)){const e=this.#xt(t).filter((e=>!this.#bt(e)));if(e.length>0)return void this.#St(r,n,t,e)}const i=Eo();n.insertAfter(i),t.remove(),i.selectStart()}#ft(e){const t=this.#_t(e);if(!t)return!1;if(!this.#bt(t))return!1;const n=t.getParent();return n&&uu(n)}#_t(e){let t=e;for(;t;){if(No(t))return t;t=t.getParent()}return null}#mt(e){const t=this.#_t(e);if(!t)return;const n=t.getParent();if(!n||!uu(n))return;const r=this.#Ct(t).filter((e=>!this.#bt(e)));if(r.length>0)this.#vt(n,t,r);else{const e=Eo();n.insertAfter(e),t.remove(),e.selectStart()}}#Ct(e){const t=[];let n=e.getNextSibling();for(;n;)t.push(n),n=n.getNextSibling();return t}#xt(e){const t=[];let n=e.getNextSibling();for(;n;)kc(n)&&t.push(n),n=n.getNextSibling();return t}#St(e,t,n,r){const i=this.#Ct(t).filter((e=>!this.#bt(e))),o=Eo();e.insertAfter(o);const s=Oc(t.getListType()),l=cu();o.insertAfter(l),l.append(s),r.forEach((e=>{s.append(e)})),i.forEach((e=>{l.append(e)})),n.remove(),this.#wt(t),this.#kt(l),0===t.getChildrenSize()?(t.remove(),0===e.getChildrenSize()&&e.remove()):this.#kt(e),o.selectStart()}#wt(e){const t=e.getChildren();for(let e=t.length-1;e>=0;e--){const n=t[e];if(!kc(n)||!this.#bt(n))break;n.remove()}}#kt(e){const t=e.getChildren();for(let e=t.length-1;e>=0;e--){const n=t[e];if(!this.#bt(n))break;n.remove()}}#vt(e,t,n){const r=Eo();e.insertAfter(r);const i=cu();r.insertAfter(i),n.forEach((e=>{i.append(e)})),t.remove(),this.#kt(e),this.#kt(i),r.selectStart()}}class Xg{constructor(e){this.editorElement=e,this.editor=e.editor,new Yg(e).monitor()}insertHtml(e){this.editor.update((()=>{const t=Li();if(!gi(t))return;const n=Bc(this.editor,Bg(e));t.insertNodes(n)}))}insertAtCursor(e){this.editor.update((()=>{const t=Li(),n=t?.getNodes();if(gi(t))Di([e]);else if(fi(t)&&n&&n.length>0){n[n.length-1].insertAfter(e)}else{us().append(e)}}))}insertAtCursorEnsuringLineBelow(e){this.insertAtCursor(e),this.#Tt(e)}insertNodeWrappingEachSelectedLine(e){this.editor.update((()=>{const t=Li();if(!gi(t))return;t.extract().forEach((t=>{if(!t.getParent())return;const n=t.getTopLevelElementOrThrow(),r=e();r.append(...n.getChildren()),n.replace(r)}))}))}toggleNodeWrappingAllSelectedLines(e,t){this.editor.update((()=>{const n=Li();if(!gi(n))return;const r=n.anchor.getNode().getTopLevelElementOrThrow();e(r)?this.removeFormattingFromSelectedLines():this.#Et(t)}))}toggleNodeWrappingAllSelectedNodes(e,t){this.editor.update((()=>{const n=Li();if(!gi(n))return;const r=n.anchor.getNode().getTopLevelElement();r&&e(r)?this.#Nt(r):this.#At(t)}))}removeFormattingFromSelectedLines(){this.editor.update((()=>{const e=Li();if(!gi(e))return;const t=e.anchor.getNode().getTopLevelElementOrThrow(),n=Eo();n.append(...t.getChildren()),t.replace(n)}))}hasSelectedText(){let e=!1;return this.editor.read((()=>{const t=Li();e=gi(t)&&!t.isCollapsed()})),e}unwrapSelectedListItems(){this.editor.update((()=>{const e=Li();if(!gi(e))return;const{listItems:t,parentLists:n}=this.#Lt(e);if(t.size>0){const e=this.#Ot(t);this.#Ft(n),this.#Rt(e)}}))}createLink(e){let t=null;return this.editor.update((()=>{const n=ni(e),r=md(e);r.append(n);const i=Li();gi(i)&&(i.insertNodes([r]),t=r.getKey())})),t}createLinkWithSelectedText(e){this.hasSelectedText()&&this.editor.update((()=>{Cd(e)}))}textBackUntil(e){let t="";return this.editor.getEditorState().read((()=>{const n=Li();if(!n||!n.isCollapsed())return;const r=n.anchor,i=r.getNode();if(!ri(i))return;const o=i.getTextContent(),s=r.offset,l=o.slice(0,s),a=l.lastIndexOf(e);-1!==a&&(t=l.slice(a+e.length))})),t}containsTextBackUntil(e){let t=!1;return this.editor.getEditorState().read((()=>{const n=Li();if(!n||!n.isCollapsed())return;const r=n.anchor,i=r.getNode();if(!ri(i))return;const o=i.getTextContent(),s=r.offset,l=o.slice(0,s);t=l.includes(e)})),t}replaceTextBackUntil(e,t){t=Array.isArray(t)?t:[t],this.editor.update((()=>{const{anchorNode:n,offset:r}=this.#It();if(!n)return;const i=this.#Pt(n,r,e);-1!==i&&this.#Mt(n,r,i,t)}))}createParagraphAfterNode(e,t){const n=Eo();e.insertAfter(n),n.selectStart(),t&&(n.append(ni(t)),n.select(1,1))}createParagraphBeforeNode(e,t){const n=Eo();e.insertBefore(n),n.selectStart(),t&&(n.append(ni(t)),n.select(1,1))}uploadFile(e){if(!this.editorElement.supportsAttachments)return void console.warn("This editor does not supports attachments (it's configured with [attachments=false])");if(!this.#Dt(e))return;const t=this.editorElement.directUploadUrl,n=this.editorElement.blobUrlTemplate;this.editor.update((()=>{const r=new Wg({file:e,uploadUrl:t,blobUrlTemplate:n,editor:this.editor});this.insertAtCursor(r)}),{tag:Or})}async deleteSelectedNodes(){let e=null;this.editor.update((()=>{if(this.#Bt.hasNodeSelection){const t=Li().getNodes();if(0===t.length)return;e=this.#zt(t),this.#$t(t)}})),await Zg(),this.editor.update((()=>{this.#Ht(e),this.editor.focus()}))}replaceNodeWithHTML(e,t,n={}){this.editor.update((()=>{const r=is(e);if(!r)return;const i=Li();let o=!1;if(gi(i)){const e=i.getNodes();o=e.includes(r)||e.some((e=>e.getParent()===r)),o&&hs(null)}const s=n.attachment?this.#Kt(t,n.attachment):this.#Ut(t);r.replace(s),o&&s.selectEnd()}))}insertHTMLBelowNode(e,t,n={}){this.editor.update((()=>{const r=is(e);if(!r)return;const i=r.getTopLevelElement()||r,o=n.attachment?this.#Kt(t,n.attachment):this.#Ut(t);i.insertAfter(o)}))}get#Bt(){return this.editorElement.selection}#Tt(e){this.editor.update((()=>{if(!e.getNextSibling()){const t=Eo();e.insertAfter(t),t.selectStart()}}))}#Nt(e){e.getChildren().forEach((t=>{e.insertBefore(t)})),e.remove()}#At(e){this.editor.update((()=>{const t=Li();if(!gi(t))return;const n=t.extract();if(0===n.length)return;const r=new Set;n.forEach((e=>{const t=e.getTopLevelElementOrThrow();r.add(t)}));const i=this.#Wt(Array.from(r));if(0===i.length)return this.#Vt(),void this.insertAtCursor(e());const o=e();i[0].insertBefore(o),i.forEach((e=>{o.append(e)}))}))}#Wt(e){let t=e.length-1;for(;t>=0;){const n=e[t];if(!No(n)||!this.#qt(n))break;t--}return e.slice(0,t+1)}#qt(e){if(""!==e.getTextContent().trim())return!1;const t=e.getChildren();return 0===t.length||t.every((e=>zr(e)))}#Vt(){const e=us();if(1===e.getChildrenSize()){const t=e.getFirstChild();t&&No(t)&&this.#qt(t)&&t.remove()}}#Et(e){this.editor.update((()=>{const t=Li();gi(t)&&(t.isCollapsed()?this.#jt(t,e):this.#Zt(t,e))}))}#jt(e,t){const n=e.anchor.getNode().getTopLevelElementOrThrow();if(n.getTextContent()){const e=t();e.append(...n.getChildren()),n.replace(e)}else Di([t()])}#Zt(e,t){const n=this.#Gt(e);if(0===n.length)return;const{lineSet:r,nodesToDelete:i}=this.#Jt(n);if(0===r.size)return;const o=this.#Yt(t,r);this.#Xt(e,o),this.#Qt(i)}#Gt(e){const t=e.extract().map((e=>this.#en(e))).filter(Boolean);return hs(null),t}#en(e){return No(e)?e:ri(e)&&e.getParent()&&No(e.getParent())?e.getParent():null}#Jt(e){const t=new Set,n=new Set;return e.forEach((e=>{const r=e.getTextContent();r&&r.split("\n").forEach((e=>{e.trim()&&t.add(e)})),n.add(e)})),{lineSet:t,nodesToDelete:n}}#Yt(e,t){const n=e(),r=Array.from(t);return r.forEach(((e,t)=>{n.append(ni(e)),te.remove()))}#$t(e){e.forEach((e=>{const t=e.getParent();if(!po(t))return;const n=t.getChildren().indexOf(e);n>=0&&t.splice(n,1,[])}))}#zt(e){const t=e[0],n=e[e.length-1];return t?.getPreviousSibling()||n?.getNextSibling()}#Ht(e){const t=us();if(0===t.getChildrenSize()){const e=Eo();t.append(e),e.selectStart()}else e&&(ri(e)||No(e)?e.selectEnd():e.selectNext(0,0))}#Lt(e){const t=e.getNodes(),n=new Set,r=new Set;for(const e of t){const t=sg(e);if(t){n.add(t);const e=t.getParent();e&&Fc(e)&&r.add(e)}}return{listItems:n,parentLists:r}}#Ot(e){const t=[];for(const n of e){const e=this.#tn(n);e&&t.push(e)}return t}#tn(e){const t=e.getParent();if(!t||!Fc(t))return null;const n=Eo(),r=this.#nn(e,n);return e.insertAfter(n),this.#rn(n,r),e.remove(),n}#nn(e,t){const n=[];return e.getChildren().forEach((e=>{Fc(e)?n.push(e):t.append(e)})),n}#rn(e,t){t.forEach((t=>{e.insertAfter(t)}))}#Ft(e){for(const t of e)Fc(t)&&0===t.getChildrenSize()&&t.remove()}#Rt(e){if(0===e.length)return;const t=e[0],n=e[e.length-1];1===e.length?t.selectEnd():this.#in(t,n)}#in(e,t){e.selectStart();const n=Li();n&&gi(n)&&(n.anchor.set(e.getKey(),0,"element"),n.focus.set(t.getKey(),t.getChildrenSize(),"element"))}#It(){const e=Li();if(!e||!e.isCollapsed())return{anchorNode:null,offset:0};const t=e.anchor,n=t.getNode();return ri(n)?{anchorNode:n,offset:t.offset}:{anchorNode:null,offset:0}}#Pt(e,t,n){return e.getTextContent().slice(0,t).lastIndexOf(n)}#Mt(e,t,n,r){const i=e.getTextContent(),o=i.slice(0,n),s=i.slice(t),l=ni(o),a=ni(s||" ");e.replace(l);this.#on(l,r).insertAfter(a),this.#sn(a.getParentOrThrow());const c=s?0:1;a.select(c,c)}#on(e,t){let n=e;for(const e of t)n.insertAfter(e),n=e;return n}#sn(e){if(No(e)&&!this.editorElement.isSingleLineMode){const t=e.getChildren(),n=t[t.length-1],r=t[t.length-2];ri(n)&&""===n.getTextContent()&&r&&!ri(r)&&e.append(Br())}}#Kt(e,t={}){return new Jg({sgid:("object"==typeof t?t:{}).sgid||null,contentType:"text/html",innerHtml:e})}#Ut(e){return Bc(this.editor,Bg(e))[0]||Eo()}#Dt(e){return $g(this.editorElement,"lexxy:file-accept",{file:e},!0)}}function Qg(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var ep={async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null};function tp(e){ep=e}var np={exec:()=>null};function rp(e,t=""){let n="string"==typeof e?e:e.source,r={replace:(e,t)=>{let i="string"==typeof t?t:t.source;return i=i.replace(ip.caret,"$1"),n=n.replace(e,i),r},getRegex:()=>new RegExp(n,t)};return r}var ip={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceTabs:/^\t+/,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] /,listReplaceTask:/^\[[ xX]\] +/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^
    /i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,unescapeTest:/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/gi,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>new RegExp(`^( {0,3}${e})((?:[\t ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ \t][^\\n]*)?(?:\\n|$))`),hrRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}#`),htmlBeginRegex:e=>new RegExp(`^ {0,${Math.min(3,e-1)}}<(?:[a-z].*>|!--)`,"i")},op=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,sp=/(?:[*+-]|\d{1,9}[.)])/,lp=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,ap=rp(lp).replace(/bull/g,sp).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),cp=rp(lp).replace(/bull/g,sp).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),up=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,dp=/(?!\s*\])(?:\\[\s\S]|[^\[\]\\])+/,hp=rp(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",dp).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),gp=rp(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,sp).getRegex(),pp="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",fp=/|$))/,mp=rp("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|\\n*|$)|\\n*|$)|)[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$)|(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ \t]*)+\\n|$))","i").replace("comment",fp).replace("tag",pp).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),yp=rp(up).replace("hr",op).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html",")|<(?:script|pre|style|textarea|!--)").replace("tag",pp).getRegex(),bp={blockquote:rp(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",yp).getRegex(),code:/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,def:hp,fences:/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,heading:/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,hr:op,html:mp,lheading:ap,list:gp,newline:/^(?:[ \t]*(?:\n|$))+/,paragraph:yp,table:np,text:/^[^\n]+/},_p=rp("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",op).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3}\t)[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html",")|<(?:script|pre|style|textarea|!--)").replace("tag",pp).getRegex(),xp={...bp,lheading:cp,table:_p,paragraph:rp(up).replace("hr",op).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",_p).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html",")|<(?:script|pre|style|textarea|!--)").replace("tag",pp).getRegex()},Sp={...bp,html:rp("^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+? *(?:\\n{2,}|\\s*$)|\\s]*)*?/?> *(?:\\n{2,}|\\s*$))").replace("comment",fp).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:np,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:rp(up).replace("hr",op).replace("heading"," *#{1,6} *[^\n]").replace("lheading",ap).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},Cp=/^( {2,}|\\)\n(?!\s*$)/,vp=/[\p{P}\p{S}]/u,wp=/[\s\p{P}\p{S}]/u,kp=/[^\s\p{P}\p{S}]/u,Tp=rp(/^((?![*_])punctSpace)/,"u").replace(/punctSpace/g,wp).getRegex(),Ep=/(?!~)[\p{P}\p{S}]/u,Np=rp(/link|code|html/,"g").replace("link",/\[(?:[^\[\]`]|(?`+)[^`]+\k(?!`))*?\]\((?:\\[\s\S]|[^\\\(\)]|\((?:\\[\s\S]|[^\\\(\)])*\))*\)/).replace("code",/(?`+)[^`]+\k(?!`)/).replace("html",/<(?! )[^<>]*?>/).getRegex(),Ap=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,Lp=rp(Ap,"u").replace(/punct/g,vp).getRegex(),Op=rp(Ap,"u").replace(/punct/g,Ep).getRegex(),Fp="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",Rp=rp(Fp,"gu").replace(/notPunctSpace/g,kp).replace(/punctSpace/g,wp).replace(/punct/g,vp).getRegex(),Ip=rp(Fp,"gu").replace(/notPunctSpace/g,/(?:[^\s\p{P}\p{S}]|~)/u).replace(/punctSpace/g,/(?!~)[\s\p{P}\p{S}]/u).replace(/punct/g,Ep).getRegex(),Pp=rp("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,kp).replace(/punctSpace/g,wp).replace(/punct/g,vp).getRegex(),Mp=rp(/\\(punct)/,"gu").replace(/punct/g,vp).getRegex(),Dp=rp(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),Bp=rp(fp).replace("(?:--\x3e|$)","--\x3e").getRegex(),zp=rp("^comment|^|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^|^").replace("comment",Bp).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),$p=/(?:\[(?:\\[\s\S]|[^\[\]\\])*\]|\\[\s\S]|`+[^`]*?`+(?!`)|[^\[\]\\`])*?/,Hp=rp(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",$p).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),Kp=rp(/^!?\[(label)\]\[(ref)\]/).replace("label",$p).replace("ref",dp).getRegex(),Up=rp(/^!?\[(ref)\](?:\[\])?/).replace("ref",dp).getRegex(),Wp=/[hH][tT][tT][pP][sS]?|[fF][tT][pP]/,Vp={_backpedal:np,anyPunctuation:Mp,autolink:Dp,blockSkip:Np,br:Cp,code:/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,del:np,emStrongLDelim:Lp,emStrongRDelimAst:Rp,emStrongRDelimUnd:Pp,escape:/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,link:Hp,nolink:Up,punctuation:Tp,reflink:Kp,reflinkSearch:rp("reflink|nolink(?!\\()","g").replace("reflink",Kp).replace("nolink",Up).getRegex(),tag:zp,text:/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\":">",'"':""","'":"'"},Xp=e=>Yp[e];function Qp(e,t){if(t){if(ip.escapeTest.test(e))return e.replace(ip.escapeReplace,Xp)}else if(ip.escapeTestNoEncode.test(e))return e.replace(ip.escapeReplaceNoEncode,Xp);return e}function ef(e){try{e=encodeURI(e).replace(ip.percentDecode,"%")}catch{return null}return e}function tf(e,t){let n=e.replace(ip.findPipe,((e,t,n)=>{let r=!1,i=t;for(;--i>=0&&"\\"===n[i];)r=!r;return r?"|":" |"})),r=n.split(ip.splitPipe),i=0;if(r[0].trim()||r.shift(),r.length>0&&!r.at(-1)?.trim()&&r.pop(),t)if(r.length>t)r.splice(t);else for(;r.length0)return{type:"space",raw:t[0]}}code(e){let t=this.rules.block.code.exec(e);if(t){let e=t[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:t[0],codeBlockStyle:"indented",text:this.options.pedantic?e:nf(e,"\n")}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let e=t[0],n=function(e,t,n){let r=e.match(n.other.indentCodeCompensation);if(null===r)return t;let i=r[1];return t.split("\n").map((e=>{let t=e.match(n.other.beginningSpace);if(null===t)return e;let[r]=t;return r.length>=i.length?e.slice(i.length):e})).join("\n")}(e,t[3]||"",this.rules);return{type:"code",raw:e,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):t[2],text:n}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let e=t[2].trim();if(this.rules.other.endingHash.test(e)){let t=nf(e,"#");(this.options.pedantic||!t||this.rules.other.endingSpaceChar.test(t))&&(e=t.trim())}return{type:"heading",raw:t[0],depth:t[1].length,text:e,tokens:this.lexer.inline(e)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:"hr",raw:nf(t[0],"\n")}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let e=nf(t[0],"\n").split("\n"),n="",r="",i=[];for(;e.length>0;){let t,o=!1,s=[];for(t=0;t1,i={type:"list",raw:"",ordered:r,start:r?+n.slice(0,-1):"",loose:!1,items:[]};n=r?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=r?n:"[*+-]");let o=this.rules.other.listItemRegex(n),s=!1;for(;e;){let n=!1,r="",l="";if(!(t=o.exec(e))||this.rules.block.hr.test(e))break;r=t[0],e=e.substring(r.length);let a=t[2].split("\n",1)[0].replace(this.rules.other.listReplaceTabs,(e=>" ".repeat(3*e.length))),c=e.split("\n",1)[0],u=!a.trim(),d=0;if(this.options.pedantic?(d=2,l=a.trimStart()):u?d=t[1].length+1:(d=t[2].search(this.rules.other.nonSpaceChar),d=d>4?1:d,l=a.slice(d),d+=t[1].length),u&&this.rules.other.blankLine.test(c)&&(r+=c+"\n",e=e.substring(c.length+1),n=!0),!n){let t=this.rules.other.nextBulletRegex(d),n=this.rules.other.hrRegex(d),i=this.rules.other.fencesBeginRegex(d),o=this.rules.other.headingBeginRegex(d),s=this.rules.other.htmlBeginRegex(d);for(;e;){let h,g=e.split("\n",1)[0];if(c=g,this.options.pedantic?(c=c.replace(this.rules.other.listReplaceNesting," "),h=c):h=c.replace(this.rules.other.tabCharGlobal," "),i.test(c)||o.test(c)||s.test(c)||t.test(c)||n.test(c))break;if(h.search(this.rules.other.nonSpaceChar)>=d||!c.trim())l+="\n"+h.slice(d);else{if(u||a.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||i.test(a)||o.test(a)||n.test(a))break;l+="\n"+c}!u&&!c.trim()&&(u=!0),r+=g+"\n",e=e.substring(g.length+1),a=h.slice(d)}}i.loose||(s?i.loose=!0:this.rules.other.doubleBlankLine.test(r)&&(s=!0));let h,g=null;this.options.gfm&&(g=this.rules.other.listIsTask.exec(l),g&&(h="[ ] "!==g[0],l=l.replace(this.rules.other.listReplaceTask,""))),i.items.push({type:"list_item",raw:r,task:!!g,checked:h,loose:!1,text:l,tokens:[]}),i.raw+=r}let l=i.items.at(-1);if(!l)return;l.raw=l.raw.trimEnd(),l.text=l.text.trimEnd(),i.raw=i.raw.trimEnd();for(let e=0;e"space"===e.type)),n=t.length>0&&t.some((e=>this.rules.other.anyLine.test(e.raw)));i.loose=n}if(i.loose)for(let e=0;e({text:e,tokens:this.lexer.inline(e),header:!1,align:o.align[t]}))));return o}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t)return{type:"heading",raw:t[0],depth:"="===t[2].charAt(0)?1:2,text:t[1],tokens:this.lexer.inline(t[1])}}paragraph(e){let t=this.rules.block.paragraph.exec(e);if(t){let e="\n"===t[1].charAt(t[1].length-1)?t[1].slice(0,-1):t[1];return{type:"paragraph",raw:t[0],text:e,tokens:this.lexer.inline(e)}}}text(e){let t=this.rules.block.text.exec(e);if(t)return{type:"text",raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return{type:"escape",raw:t[0],text:t[1]}}tag(e){let t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){let t=this.rules.inline.link.exec(e);if(t){let e=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(e)){if(!this.rules.other.endAngleBracket.test(e))return;let t=nf(e.slice(0,-1),"\\");if((e.length-t.length)%2==0)return}else{let e=function(e,t){if(-1===e.indexOf(t[1]))return-1;let n=0;for(let r=0;r0?-2:-1}(t[2],"()");if(-2===e)return;if(e>-1){let n=(0===t[0].indexOf("!")?5:4)+t[1].length+e;t[2]=t[2].substring(0,e),t[0]=t[0].substring(0,n).trim(),t[3]=""}}let n=t[2],r="";if(this.options.pedantic){let e=this.rules.other.pedanticHrefTitle.exec(n);e&&(n=e[1],r=e[3])}else r=t[3]?t[3].slice(1,-1):"";return n=n.trim(),this.rules.other.startAngleBracket.test(n)&&(n=this.options.pedantic&&!this.rules.other.endAngleBracket.test(e)?n.slice(1):n.slice(1,-1)),rf(t,{href:n&&n.replace(this.rules.inline.anyPunctuation,"$1"),title:r&&r.replace(this.rules.inline.anyPunctuation,"$1")},t[0],this.lexer,this.rules)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){let e=t[(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal," ").toLowerCase()];if(!e){let e=n[0].charAt(0);return{type:"text",raw:e,text:e}}return rf(n,e,n[0],this.lexer,this.rules)}}emStrong(e,t,n=""){let r=this.rules.inline.emStrongLDelim.exec(e);if(!(!r||r[3]&&n.match(this.rules.other.unicodeAlphaNumeric))&&(!r[1]&&!r[2]||!n||this.rules.inline.punctuation.exec(n))){let n,i,o=[...r[0]].length-1,s=o,l=0,a="*"===r[0][0]?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(a.lastIndex=0,t=t.slice(-1*e.length+o);null!=(r=a.exec(t));){if(n=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!n)continue;if(i=[...n].length,r[3]||r[4]){s+=i;continue}if((r[5]||r[6])&&o%3&&!((o+i)%3)){l+=i;continue}if(s-=i,s>0)continue;i=Math.min(i,i+s+l);let t=[...r[0]][0].length,a=e.slice(0,o+r.index+t+i);if(Math.min(o,i)%2){let e=a.slice(1,-1);return{type:"em",raw:a,text:e,tokens:this.lexer.inlineTokens(e)}}let c=a.slice(2,-2);return{type:"strong",raw:a,text:c,tokens:this.lexer.inlineTokens(c)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let e=t[2].replace(this.rules.other.newLineCharGlobal," "),n=this.rules.other.nonSpaceChar.test(e),r=this.rules.other.startingSpaceChar.test(e)&&this.rules.other.endingSpaceChar.test(e);return n&&r&&(e=e.substring(1,e.length-1)),{type:"codespan",raw:t[0],text:e}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return{type:"br",raw:t[0]}}del(e){let t=this.rules.inline.del.exec(e);if(t)return{type:"del",raw:t[0],text:t[2],tokens:this.lexer.inlineTokens(t[2])}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let e,n;return"@"===t[2]?(e=t[1],n="mailto:"+e):(e=t[1],n=e),{type:"link",raw:t[0],text:e,href:n,tokens:[{type:"text",raw:e,text:e}]}}}url(e){let t;if(t=this.rules.inline.url.exec(e)){let e,n;if("@"===t[2])e=t[0],n="mailto:"+e;else{let r;do{r=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])?.[0]??""}while(r!==t[0]);e=t[0],n="www."===t[1]?"http://"+t[0]:t[0]}return{type:"link",raw:t[0],text:e,href:n,tokens:[{type:"text",raw:e,text:e}]}}}inlineText(e){let t=this.rules.inline.text.exec(e);if(t){let e=this.lexer.state.inRawBlock;return{type:"text",raw:t[0],text:t[0],escaped:e}}}},sf=class e{tokens;options;state;tokenizer;inlineQueue;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||ep,this.options.tokenizer=this.options.tokenizer||new of,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let t={other:ip,block:Gp.normal,inline:Jp.normal};this.options.pedantic?(t.block=Gp.pedantic,t.inline=Jp.pedantic):this.options.gfm&&(t.block=Gp.gfm,this.options.breaks?t.inline=Jp.breaks:t.inline=Jp.gfm),this.tokenizer.rules=t}static get rules(){return{block:Gp,inline:Jp}}static lex(t,n){return new e(n).lex(t)}static lexInline(t,n){return new e(n).inlineTokens(t)}lex(e){e=e.replace(ip.carriageReturn,"\n"),this.blockTokens(e,this.tokens);for(let e=0;e!!(r=n.call({lexer:this},e,t))&&(e=e.substring(r.raw.length),t.push(r),!0))))continue;if(r=this.tokenizer.space(e)){e=e.substring(r.raw.length);let n=t.at(-1);1===r.raw.length&&void 0!==n?n.raw+="\n":t.push(r);continue}if(r=this.tokenizer.code(e)){e=e.substring(r.raw.length);let n=t.at(-1);"paragraph"===n?.type||"text"===n?.type?(n.raw+=(n.raw.endsWith("\n")?"":"\n")+r.raw,n.text+="\n"+r.text,this.inlineQueue.at(-1).src=n.text):t.push(r);continue}if(r=this.tokenizer.fences(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.heading(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.hr(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.blockquote(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.list(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.html(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.def(e)){e=e.substring(r.raw.length);let n=t.at(-1);"paragraph"===n?.type||"text"===n?.type?(n.raw+=(n.raw.endsWith("\n")?"":"\n")+r.raw,n.text+="\n"+r.raw,this.inlineQueue.at(-1).src=n.text):this.tokens.links[r.tag]||(this.tokens.links[r.tag]={href:r.href,title:r.title},t.push(r));continue}if(r=this.tokenizer.table(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.lheading(e)){e=e.substring(r.raw.length),t.push(r);continue}let i=e;if(this.options.extensions?.startBlock){let t,n=1/0,r=e.slice(1);this.options.extensions.startBlock.forEach((e=>{t=e.call({lexer:this},r),"number"==typeof t&&t>=0&&(n=Math.min(n,t))})),n<1/0&&n>=0&&(i=e.substring(0,n+1))}if(this.state.top&&(r=this.tokenizer.paragraph(i))){let o=t.at(-1);n&&"paragraph"===o?.type?(o.raw+=(o.raw.endsWith("\n")?"":"\n")+r.raw,o.text+="\n"+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=o.text):t.push(r),n=i.length!==e.length,e=e.substring(r.raw.length)}else if(r=this.tokenizer.text(e)){e=e.substring(r.raw.length);let n=t.at(-1);"text"===n?.type?(n.raw+=(n.raw.endsWith("\n")?"":"\n")+r.raw,n.text+="\n"+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=n.text):t.push(r)}else if(e){let t="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(t);break}throw new Error(t)}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){let n=e,r=null;if(this.tokens.links){let e=Object.keys(this.tokens.links);if(e.length>0)for(;null!=(r=this.tokenizer.rules.inline.reflinkSearch.exec(n));)e.includes(r[0].slice(r[0].lastIndexOf("[")+1,-1))&&(n=n.slice(0,r.index)+"["+"a".repeat(r[0].length-2)+"]"+n.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;null!=(r=this.tokenizer.rules.inline.anyPunctuation.exec(n));)n=n.slice(0,r.index)+"++"+n.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);for(;null!=(r=this.tokenizer.rules.inline.blockSkip.exec(n));)n=n.slice(0,r.index)+"["+"a".repeat(r[0].length-2)+"]"+n.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);n=this.options.hooks?.emStrongMask?.call({lexer:this},n)??n;let i=!1,o="";for(;e;){let r;if(i||(o=""),i=!1,this.options.extensions?.inline?.some((n=>!!(r=n.call({lexer:this},e,t))&&(e=e.substring(r.raw.length),t.push(r),!0))))continue;if(r=this.tokenizer.escape(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.tag(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.link(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(r.raw.length);let n=t.at(-1);"text"===r.type&&"text"===n?.type?(n.raw+=r.raw,n.text+=r.text):t.push(r);continue}if(r=this.tokenizer.emStrong(e,n,o)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.codespan(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.br(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.del(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.autolink(e)){e=e.substring(r.raw.length),t.push(r);continue}if(!this.state.inLink&&(r=this.tokenizer.url(e))){e=e.substring(r.raw.length),t.push(r);continue}let s=e;if(this.options.extensions?.startInline){let t,n=1/0,r=e.slice(1);this.options.extensions.startInline.forEach((e=>{t=e.call({lexer:this},r),"number"==typeof t&&t>=0&&(n=Math.min(n,t))})),n<1/0&&n>=0&&(s=e.substring(0,n+1))}if(r=this.tokenizer.inlineText(s)){e=e.substring(r.raw.length),"_"!==r.raw.slice(-1)&&(o=r.raw.slice(-1)),i=!0;let n=t.at(-1);"text"===n?.type?(n.raw+=r.raw,n.text+=r.text):t.push(r)}else if(e){let t="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(t);break}throw new Error(t)}}return t}},lf=class{options;parser;constructor(e){this.options=e||ep}space(e){return""}code({text:e,lang:t,escaped:n}){let r=(t||"").match(ip.notSpaceStart)?.[0],i=e.replace(ip.endingNewline,"")+"\n";return r?'
    '+(n?i:Qp(i,!0))+"
    \n":"
    "+(n?i:Qp(i,!0))+"
    \n"}blockquote({tokens:e}){return`
    \n${this.parser.parse(e)}
    \n`}html({text:e}){return e}def(e){return""}heading({tokens:e,depth:t}){return`${this.parser.parseInline(e)}\n`}hr(e){return"
    \n"}list(e){let t=e.ordered,n=e.start,r="";for(let t=0;t\n"+r+"\n"}listitem(e){let t="";if(e.task){let n=this.checkbox({checked:!!e.checked});e.loose?"paragraph"===e.tokens[0]?.type?(e.tokens[0].text=n+" "+e.tokens[0].text,e.tokens[0].tokens&&e.tokens[0].tokens.length>0&&"text"===e.tokens[0].tokens[0].type&&(e.tokens[0].tokens[0].text=n+" "+Qp(e.tokens[0].tokens[0].text),e.tokens[0].tokens[0].escaped=!0)):e.tokens.unshift({type:"text",raw:n+" ",text:n+" ",escaped:!0}):t+=n+" "}return t+=this.parser.parse(e.tokens,!!e.loose),`
  • ${t}
  • \n`}checkbox({checked:e}){return"'}paragraph({tokens:e}){return`

    ${this.parser.parseInline(e)}

    \n`}table(e){let t="",n="";for(let t=0;t${r}`),"\n\n"+t+"\n"+r+"
    \n"}tablerow({text:e}){return`\n${e}\n`}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?"th":"td";return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`\n`}strong({tokens:e}){return`${this.parser.parseInline(e)}`}em({tokens:e}){return`${this.parser.parseInline(e)}`}codespan({text:e}){return`${Qp(e,!0)}`}br(e){return"
    "}del({tokens:e}){return`${this.parser.parseInline(e)}`}link({href:e,title:t,tokens:n}){let r=this.parser.parseInline(n),i=ef(e);if(null===i)return r;let o='
    ",o}image({href:e,title:t,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let i=ef(e);if(null===i)return Qp(n);let o=`${n}{let i=e[r].flat(1/0);n=n.concat(this.walkTokens(i,t))})):e.tokens&&(n=n.concat(this.walkTokens(e.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach((e=>{let n={...e};if(n.async=this.defaults.async||n.async||!1,e.extensions&&(e.extensions.forEach((e=>{if(!e.name)throw new Error("extension name required");if("renderer"in e){let n=t.renderers[e.name];t.renderers[e.name]=n?function(...t){let r=e.renderer.apply(this,t);return!1===r&&(r=n.apply(this,t)),r}:e.renderer}if("tokenizer"in e){if(!e.level||"block"!==e.level&&"inline"!==e.level)throw new Error("extension level must be 'block' or 'inline'");let n=t[e.level];n?n.unshift(e.tokenizer):t[e.level]=[e.tokenizer],e.start&&("block"===e.level?t.startBlock?t.startBlock.push(e.start):t.startBlock=[e.start]:"inline"===e.level&&(t.startInline?t.startInline.push(e.start):t.startInline=[e.start]))}"childTokens"in e&&e.childTokens&&(t.childTokens[e.name]=e.childTokens)})),n.extensions=t),e.renderer){let t=this.defaults.renderer||new lf(this.defaults);for(let n in e.renderer){if(!(n in t))throw new Error(`renderer '${n}' does not exist`);if(["options","parser"].includes(n))continue;let r=n,i=e.renderer[r],o=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return!1===n&&(n=o.apply(t,e)),n||""}}n.renderer=t}if(e.tokenizer){let t=this.defaults.tokenizer||new of(this.defaults);for(let n in e.tokenizer){if(!(n in t))throw new Error(`tokenizer '${n}' does not exist`);if(["options","rules","lexer"].includes(n))continue;let r=n,i=e.tokenizer[r],o=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return!1===n&&(n=o.apply(t,e)),n}}n.tokenizer=t}if(e.hooks){let t=this.defaults.hooks||new uf;for(let n in e.hooks){if(!(n in t))throw new Error(`hook '${n}' does not exist`);if(["options","block"].includes(n))continue;let r=n,i=e.hooks[r],o=t[r];uf.passThroughHooks.has(n)?t[r]=e=>{if(this.defaults.async&&uf.passThroughHooksRespectAsync.has(n))return(async()=>{let n=await i.call(t,e);return o.call(t,n)})();let r=i.call(t,e);return o.call(t,r)}:t[r]=(...e)=>{if(this.defaults.async)return(async()=>{let n=await i.apply(t,e);return!1===n&&(n=await o.apply(t,e)),n})();let n=i.apply(t,e);return!1===n&&(n=o.apply(t,e)),n}}n.hooks=t}if(e.walkTokens){let t=this.defaults.walkTokens,r=e.walkTokens;n.walkTokens=function(e){let n=[];return n.push(r.call(this,e)),t&&(n=n.concat(t.call(this,e))),n}}this.defaults={...this.defaults,...n}})),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return sf.lex(e,t??this.defaults)}parser(e,t){return cf.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let r={...n},i={...this.defaults,...r},o=this.onError(!!i.silent,!!i.async);if(!0===this.defaults.async&&!1===r.async)return o(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof t>"u"||null===t)return o(new Error("marked(): input parameter is undefined or null"));if("string"!=typeof t)return o(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(t)+", string expected"));if(i.hooks&&(i.hooks.options=i,i.hooks.block=e),i.async)return(async()=>{let n=i.hooks?await i.hooks.preprocess(t):t,r=await(i.hooks?await i.hooks.provideLexer():e?sf.lex:sf.lexInline)(n,i),o=i.hooks?await i.hooks.processAllTokens(r):r;i.walkTokens&&await Promise.all(this.walkTokens(o,i.walkTokens));let s=await(i.hooks?await i.hooks.provideParser():e?cf.parse:cf.parseInline)(o,i);return i.hooks?await i.hooks.postprocess(s):s})().catch(o);try{i.hooks&&(t=i.hooks.preprocess(t));let n=(i.hooks?i.hooks.provideLexer():e?sf.lex:sf.lexInline)(t,i);i.hooks&&(n=i.hooks.processAllTokens(n)),i.walkTokens&&this.walkTokens(n,i.walkTokens);let r=(i.hooks?i.hooks.provideParser():e?cf.parse:cf.parseInline)(n,i);return i.hooks&&(r=i.hooks.postprocess(r)),r}catch(e){return o(e)}}}onError(e,t){return n=>{if(n.message+="\nPlease report this to https://github.com/markedjs/marked.",e){let e="

    An error occurred:

    "+Qp(n.message+"",!0)+"
    ";return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}};function hf(e,t){return df.parse(e,t)}function gf(e){try{return new URL(e),!0}catch{return!1}}function pf(e){return e.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g,"")}hf.options=hf.setOptions=function(e){return df.setOptions(e),hf.defaults=df.defaults,tp(hf.defaults),hf},hf.getDefaults=Qg,hf.defaults=ep,hf.use=function(...e){return df.use(...e),hf.defaults=df.defaults,tp(hf.defaults),hf},hf.walkTokens=function(e,t){return df.walkTokens(e,t)},hf.parseInline=df.parseInline,hf.Parser=cf,hf.parser=cf.parse,hf.Renderer=lf,hf.TextRenderer=af,hf.Lexer=sf,hf.lexer=sf.lex,hf.Tokenizer=of,hf.Hooks=uf,hf.parse=hf,hf.options,hf.setOptions,hf.use,hf.walkTokens,hf.parseInline,cf.parse,sf.lex;class ff{constructor(e){this.editorElement=e,this.editor=e.editor,this.contents=e.contents}paste(e){const t=e.clipboardData;return!!t&&(this.#ln(t)&&!this.#an()?(this.#cn(t),e.preventDefault(),!0):void this.#un(t))}#ln(e){return this.#dn(e)||this.#hn(e)}#dn(e){const t=Array.from(e.types);return 1===t.length&&"text/plain"===t[0]}#hn(e){const t=Array.from(e.types);return 2===t.length&&t.includes("text/uri-list")&&t.includes("text/plain")}#an(){let e=!1;return this.editor.getEditorState().read((()=>{const t=Li();if(!gi(t))return;let n=t.anchor.getNode();for(;n;){if(Pu(n))return void(e=!0);n=n.getParent()}})),e}#cn(e){e.items[0].getAsString((e=>{if(gf(e)&&this.contents.hasSelectedText())this.contents.createLinkWithSelectedText(e);else if(gf(e)){const t=this.contents.createLink(e);this.#gn(t,{url:e})}else this.#pn(e)}))}#gn(e,t){const n={replaceLinkWith:(t,n)=>this.contents.replaceNodeWithHTML(e,t,n),insertBelowLink:(t,n)=>this.contents.insertHTMLBelowNode(e,t,n)};$g(this.editorElement,"lexxy:insert-link",{...t,...n})}#pn(e){const t=hf(e);this.contents.insertHtml(t)}#un(e){if(!this.editorElement.supportsAttachments)return;e.getData("text/html")||this.#fn((()=>{for(const t of e.items){const e=t.getAsFile();e&&this.contents.uploadFile(e)}}))}async#fn(e){const t=window.scrollY,n=window.scrollX;e(),await Zg(),window.scrollTo(n,t),this.editor.focus()}}class mf{constructor(e){this.editor=e.editor,this.#mn()}toggle(e){this.editor.update((()=>{this.#yn(e)}))}remove(){this.toggle({color:null,"background-color":null})}#mn(){return this.editor.registerNodeTransform(jr,(e=>{this.#bn(e)}))}#yn(e){const t=Li();if(!gi(t))return;const n={};for(const r in e){const i=Ca(t,r);n[r]=this.#_n(i,e[r])}fa(t,n)}#_n(e,t){return e===t?null:t}#bn(e){ug(e.getStyle())!==e.hasFormat("highlight")&&e.toggleFormat("highlight")}}class yf extends jr{$config(){return this.config("highlight",{extends:jr})}static importDOM(){return{mark:()=>({conversion:ag("mark",bf),priority:1})}}}function bf(e,t){const n=t.style?.color,r=t.style?.backgroundColor;let i="";if(n&&""!==n&&(i+=`color: ${n};`),r&&""!==r&&(i+=`background-color: ${r};`),i.length)return e.hasFormat("highlight")||e.toggleFormat("highlight"),e.setStyle(e.getStyle()+i)}const _f="language";class xf extends jr{$config(){return this.config("trix-text",{extends:jr})}static importDOM(){return{em:e=>Sf(e,{conversion:ag("i",bf),priority:1}),span:e=>Sf(e,{conversion:ag("mark",bf),priority:1}),strong:e=>Sf(e,{conversion:ag("b",bf),priority:1}),del:()=>({conversion:ag("s",Cf),priority:1}),pre:e=>function(e,t){return e.hasAttribute(_f)?t:null}(e,{conversion:cg(Ru,"pre",vf),priority:1})}}}function Sf(e,t){return""!==e.style.color||""!==e.style.backgroundColor?t:null}function Cf(e,t){return e.hasFormat("strikethrough")||e.toggleFormat("strikethrough"),bf(e,t)}function vf(e,t){const n=Xu(t.getAttribute(_f));e.node.setLanguage(n)}class wf extends HTMLElement{static formAssociated=!0;static debug=!1;static commands=["bold","italic","strikethrough"];static observedAttributes=["connected","required"];#xn="";#Sn=document.createElement("textarea");constructor(){super(),this.internals=this.attachInternals(),this.internals.role="presentation"}connectedCallback(){this.id??=Hg("lexxy-editor"),this.editor=this.#Cn(),this.contents=new Xg(this),this.selection=new Gg(this),this.clipboard=new ff(this),this.highlighter=new mf(this),jg.configureFor(this),this.#vn(),requestAnimationFrame((()=>$g(this,"lexxy:initialize"))),this.toggleAttribute("connected",!0),this.valueBeforeDisconnect=null}disconnectedCallback(){this.valueBeforeDisconnect=this.value,this.#wn()}attributeChangedCallback(e,t,n){"connected"===e&&this.isConnected&&null!=t&&t!==n&&requestAnimationFrame((()=>this.#g())),"required"===e&&this.isConnected&&(this.#Sn.required=this.hasAttribute("required"),this.#kn())}formResetCallback(){this.value=this.#xn,this.editor.dispatchCommand(Vn,void 0)}get form(){return this.internals.form}get name(){return this.getAttribute("name")}get toolbarElement(){return this.#Tn?(this.toolbar=this.toolbar||this.#En(),this.toolbar):null}get directUploadUrl(){return this.dataset.directUploadUrl}get blobUrlTemplate(){return this.dataset.blobUrlTemplate}get isEmpty(){return["


    ","

    ",""].includes(this.value.trim())}get isBlank(){return this.isEmpty||null!==this.toString().match(/^\s*$/g)}get hasOpenPrompt(){return null!==this.querySelector(".lexxy-prompt-menu.lexxy-prompt-menu--visible")}get isSingleLineMode(){return this.hasAttribute("single-line")}get supportsAttachments(){return"false"!==this.getAttribute("attachments")}get contentTabIndex(){return parseInt(this.editorContentElement?.getAttribute("tabindex")??"0")}focus(){this.editor.focus()}get value(){return this.cachedValue||this.editor?.getEditorState().read((()=>{this.cachedValue=function(e){return ge.sanitize(e)}(zc(this.editor,null))})),this.cachedValue}set value(e){this.editor.update((()=>{Ds(Ir);const t=us();t.clear(),""!==e&&t.append(...this.#Nn(e)),t.select(),this.#An(),requestAnimationFrame((()=>this.editor?.update((()=>{}))))}))}toString(){return this.cachedStringValue||this.editor?.getEditorState().read((()=>{this.cachedStringValue=us().getTextContent()})),this.cachedStringValue}#Nn(e){e||(e="

    ");return Bc(this.editor,Bg(`
    ${e}
    `)).map((e=>{if("paragraph"===e.getType()&&1===e.getChildrenSize()){const t=e.getFirstChild();if(t instanceof mo&&!t.isInline())return t}return e}))}#vn(){this.#Ln(),this.#On(),this.#Fn(),this.#Rn(),this.#T(),this.#In(),this.#Pn(),this.#Mn(),this.#Dn(),this.#Bn()}#Cn(){this.editorContentElement=this.editorContentElement||this.#zn();const e=Oo({namespace:"LexicalEditor",onError(e){throw e},theme:Mg,nodes:this.#$n});return e.setRootElement(this.editorContentElement),e}get#$n(){const e=[xf,yf,au,du,Tc,Sc,Ru,Ku,pd,bd,Vg,Jh,Ld,Dd,Jg];return this.supportsAttachments&&e.push(Ug,Wg),e}#zn(){const e=Dg("div",{classList:"lexxy-editor__content",contenteditable:!0,role:"textbox","aria-multiline":!0,"aria-label":this.#Hn,placeholder:this.getAttribute("placeholder")});return e.id=`${this.id}-content`,this.#Kn.forEach((t=>e.setAttribute(t.name,t.value))),this.appendChild(e),this.getAttribute("tabindex")?(e.setAttribute("tabindex",this.getAttribute("tabindex")),this.removeAttribute("tabindex")):e.setAttribute("tabindex",0),e}get#Hn(){return Array.from(this.internals.labels).map((e=>e.textContent)).join(" ")}get#Kn(){return Array.from(this.attributes).filter((e=>e.name.startsWith("aria-")))}set#Un(e){const t=void 0!==this.#Un&&this.#Un!==this.value;this.internals.setFormValue(e),this._internalFormValue=e,this.#Sn.value=this.isEmpty?"":e,t&&$g(this,"lexxy:change")}get#Un(){return this._internalFormValue}#Dn(){const e=this.valueBeforeDisconnect||this.getAttribute("value")||"

    ";this.value=this.#xn=e}#Bn(){document.addEventListener("turbo:before-cache",this.#Wn)}#Wn=e=>{this.#wn()};#Ln(){this.#Vn(this.editor.registerUpdateListener((({editorState:e})=>{this.#qn(),this.#Un=this.value,this.#An(),this.#kn()})))}#qn(){this.cachedValue=null,this.cachedStringValue=null}#Vn(e){this.unregisterHandlers=this.unregisterHandlers||[],this.unregisterHandlers.push(e)}#jn(){this.unregisterHandlers?.forEach((e=>{e()})),this.unregisterHandlers=null}#On(){Su(this.editor),this.historyState={current:null,redoStack:[],undoStack:[]},Ig(this.editor,this.historyState,20),Dc(this.editor),this.#Zn(),this.#Gn(),Og(this.editor,Ng)}#Zn(){!function(e){e.hasNodes([Jh])||Md(255),Aa(e.registerCommand(Pd,tg,0),e.registerCommand(ln,(({nodes:t,selection:n},r)=>!(e!==r||!gi(n))&&null!==$h(n.anchor.getNode())&&t.some(eg)),0),e.registerCommand(an,og,0),e.registerNodeTransform(Jh,ig),e.registerNodeTransform(Dd,rg),e.registerNodeTransform(Ld,ng))}(this.editor),this.tableHandler=Dg("lexxy-table-handler"),this.append(this.tableHandler),this.#Vn(this.editor.registerNodeTransform(Ld,(e=>{null===e.getBackgroundColor()&&e.setBackgroundColor("")})))}#Gn(){!function(e,t){if(!e.hasNodes([Ru,Ku]))throw new Error("CodeHighlightPlugin: CodeNode or CodeHighlightNode not registered on editor");null==t&&(t=nd);const n=[];!0!==e._headless&&n.push(e.registerMutationListener(Ru,(t=>{e.getEditorState().read((()=>{for(const[n,r]of t)if("destroyed"!==r){const t=is(n);null!==t&&id(t,e)}}))}),{skipInitialization:!1})),n.push(e.registerNodeTransform(Ru,(n=>sd(n,e,t))),e.registerNodeTransform(jr,(n=>rd(n,e,t))),e.registerNodeTransform(Ku,(n=>rd(n,e,t))),e.registerCommand(Fn,(t=>{const n=function(e){const t=Li();if(!gi(t)||!ad(t))return null;const n=e?Pn:In,r=e?Pn:Rn,i=t.anchor,o=t.focus;if(i.is(o))return r;const s=cd(t);if(1!==s.length)return n;const l=s[0];let a,c;0===l.length&&Nu(285),t.isBackward()?(a=o,c=i):(a=i,c=o);const u=ju(l[0]),d=Zu(l[0]),h=ci(u.getKey(),0,"text"),g=ci(d.getKey(),d.getTextContentSize(),"text");return a.isBefore(h)||g.isBefore(c)?n:h.isBefore(a)||c.isBefore(g)?r:n}(t.shiftKey);return null!==n&&(t.preventDefault(),e.dispatchCommand(n,void 0),!0)}),1),e.registerCommand(Rn,(()=>!!ad(Li())&&(Di([si()]),!0)),1),e.registerCommand(In,(e=>ud(In)),1),e.registerCommand(Pn,(e=>ud(Pn)),1),e.registerCommand(kn,(e=>{const t=Li();if(!gi(t))return!1;const{anchor:n}=t,r=n.getNode();return!!ad(t)&&(t.isCollapsed()&&0===n.offset&&null===r.getPreviousSibling()&&Pu(r.getParentOrThrow())?(e.preventDefault(),!0):dd(kn,e))}),1),e.registerCommand(Tn,(e=>{const t=Li();if(!gi(t))return!1;const{anchor:n}=t,r=n.getNode();return!!ad(t)&&(t.isCollapsed()&&n.offset===r.getTextContentSize()&&null===r.getNextSibling()&&Pu(r.getParentOrThrow())?(e.preventDefault(),!0):dd(Tn,e))}),1),e.registerCommand(wn,(e=>hd(wn,e)),1),e.registerCommand(Cn,(e=>hd(Cn,e)),1)),Aa(...n)}(this.editor),this.codeLanguagePicker=Dg("lexxy-code-language-picker"),this.append(this.codeLanguagePicker)}#Fn(){this.editor.getRootElement().addEventListener("lexxy:internal:invalidate-node",(e=>{const{key:t,values:n}=e.detail;this.editor.update((()=>{const e=is(t);if(e instanceof Ug){const t=e.getWritable();Object.assign(t,n)}}))}))}#Rn(){this.editor.registerCommand(En,(e=>(e.ctrlKey||e.metaKey||!!this.isSingleLineMode)&&(e.preventDefault(),!0)),2)}#T(){this.editor.registerCommand(Gn,(()=>{$g(this,"lexxy:blur")}),2),this.editor.registerCommand(Zn,(()=>{$g(this,"lexxy:focus")}),2)}#In(){this.removeTableSelectionObserver=function(e,t=!0){const n=new Map,r=(r,i,o)=>{const s=yh(r,o),l=vh(r,s,e,t);n.set(i,[l,s])},i=e.registerMutationListener(Jh,(t=>{e.getEditorState().read((()=>{for(const[e,i]of t){const t=n.get(e);if("created"===i||"updated"===i){const{tableNode:i,tableElement:o}=gh(e);void 0===t?r(i,e,o):o!==t[1]&&(t[0].removeListeners(),n.delete(e),r(i,e,o))}else"destroyed"===i&&void 0!==t&&(t[0].removeListeners(),n.delete(e))}}),{editor:e})}),{skipInitialization:!1});return()=>{i();for(const[,[e]]of n)e.removeListeners()}}(this.editor,!0),function(e){Zh.add(e)}(this.editor)}#Pn(){wf.debug&&this.#Vn(this.editor.registerUpdateListener((({editorState:e})=>{e.read((()=>{console.debug("HTML: ",this.value,"String:",this.toString()),console.debug("empty",this.isEmpty,"blank",this.isBlank)}))})))}#Mn(){this.#Tn&&this.toolbarElement.setEditor(this)}#En(){const e=this.getAttribute("toolbar");return e?document.getElementById(e):this.#Jn()}get#Tn(){return"false"!==this.getAttribute("toolbar")}#Jn(){const e=Dg("lexxy-toolbar");return e.innerHTML=pg.defaultTemplate,e.setAttribute("data-attachments",this.supportsAttachments),this.prepend(e),e}#An(){this.classList.toggle("lexxy-editor--empty",this.isEmpty)}#kn(){this.#Sn.validity.valid?this.internals.setValidity({}):this.internals.setValidity(this.#Sn.validity,this.#Sn.validationMessage,this.editorContentElement)}#wn(){this.#jn(),this.editorContentElement&&(this.editorContentElement.remove(),this.editorContentElement=null),this.contents=null,this.editor=null,this.toolbar&&(this.getAttribute("toolbar")||this.toolbar.remove(),this.toolbar=null),this.codeLanguagePicker&&(this.codeLanguagePicker.remove(),this.codeLanguagePicker=null),this.tableHandler&&(this.tableHandler.remove(),this.tableHandler=null),this.selection=null,document.removeEventListener("turbo:before-cache",this.#Wn)}#g(){this.disconnectedCallback(),this.valueBeforeDisconnect=null,this.connectedCallback()}}customElements.define("lexxy-editor",wf);class kf extends HTMLElement{connectedCallback(){this.container=this.closest("details"),this.container.addEventListener("toggle",this.#Yn.bind(this)),this.container.addEventListener("keydown",this.#Xn.bind(this))}disconnectedCallback(){this.#Qn(),this.container.removeEventListener("keydown",this.#Xn.bind(this))}get toolbar(){return this.closest("lexxy-toolbar")}get editor(){return this.toolbar.editor}close(){this.container.removeAttribute("open")}#Yn(e){this.container.open?this.#er(e.target):this.#tr()}#er(){this.#nr[0].focus(),this.#rr(),this.#m()}#tr(){this.#Qn(),this.editor.focus()}#rr(){this.clickOutsideHandler||(this.clickOutsideHandler=this.#ir.bind(this),document.addEventListener("click",this.clickOutsideHandler,!0))}#Qn(){this.clickOutsideHandler&&(document.removeEventListener("click",this.clickOutsideHandler,!0),this.clickOutsideHandler=null)}#ir({target:e}){this.container.open&&!this.container.contains(e)&&this.close()}#Xn(e){"Escape"===e.key&&(e.stopPropagation(),this.close())}async#m(){await Zg(),this.#H.forEach(((e,t)=>{e.setAttribute("tabindex",0===t?0:"-1")}))}get#nr(){return Array.from(this.querySelectorAll("button, input"))}get#H(){return Array.from(this.querySelectorAll("button"))}}customElements.define("lexxy-link-dropdown",class extends kf{connectedCallback(){super.connectedCallback(),this.input=this.querySelector("input"),this.#or()}#or(){this.container.addEventListener("toggle",this.#Yn.bind(this)),this.addEventListener("submit",this.#sr.bind(this)),this.querySelector("[value='unlink']").addEventListener("click",this.#lr.bind(this))}#Yn({newState:e}){this.input.value=this.#ar,this.input.required="open"===e}#sr(e){const t=e.submitter?.value;this.editor.dispatchCommand(t,this.input.value),this.close()}#lr(){this.editor.dispatchCommand("unlink"),this.close()}get#ar(){let e="";return this.editor.getEditorState().read((()=>{const t=Li();if(!gi(t))return;let n=t.getNodes()[0];for(;n&&n.getParent();){if(yd(n)){e=n.getURL();break}n=n.getParent()}})),e}});const Tf="button.lexxy-highlight-button",Ef="[data-command='removeHighlight']",Nf=Symbol("no_style");customElements.define("lexxy-highlight-dropdown",class extends kf{connectedCallback(){super.connectedCallback(),this.#cr(),this.#or()}#or(){this.container.addEventListener("toggle",this.#Yn.bind(this)),this.#ur.forEach((e=>e.addEventListener("click",this.#dr.bind(this)))),this.querySelector(Ef).addEventListener("click",this.#hr.bind(this))}#cr(){this.#gr.forEach((e=>{this.#pr(e)}))}#pr(e){const t=e.dataset.values?.split("; ")||[],n=e.dataset.buttonGroup;t.forEach(((t,r)=>{e.appendChild(this.#fr(n,t,r))}))}#fr(e,t,n){const r=document.createElement("button");return r.dataset.style=e,r.style.setProperty(e,t),r.dataset.value=t,r.classList.add("lexxy-highlight-button"),r.name=e+"-"+n,r}#Yn({newState:e}){"open"===e&&this.editor.getEditorState().read((()=>{this.#mr(Li())}))}#dr(e){e.preventDefault();const t=e.target.closest(Tf);if(!t)return;const n=t.dataset.style,r=t.dataset.value;this.editor.dispatchCommand("toggleHighlight",{[n]:r}),this.close()}#hr(e){e.preventDefault(),this.editor.dispatchCommand("removeHighlight"),this.close()}#mr(e){if(!gi(e))return;const t=Ca(e,"color",Nf),n=Ca(e,"background-color",Nf);this.#ur.forEach((e=>{const r=e.dataset.value===t||e.dataset.value===n;e.setAttribute("aria-pressed",r)}));const r=t!==Nf||n!==Nf;this.querySelector(Ef).disabled=!r}get#gr(){return this.querySelectorAll("[data-button-group]")}get#ur(){return Array.from(this.querySelectorAll(Tf))}});class Af extends HTMLElement{connectedCallback(){this.#cr(),this.#yr(),this.#br()}disconnectedCallback(){this.#_r()}get#xr(){return this.#Sr.editor}get#Sr(){return this.closest("lexxy-editor")}get#Cr(){const e=Li();if(!gi(e))return null;return Wd(e.anchor.getNode())}get#vr(){const e=this.#Cr;return e?function(e){const t=Vd(e);return qd(t).getChildren().findIndex((e=>e.is(t)))}(e):0}get#wr(){const e=this.#Cr;return e?function(e){return Vd(e).getChildren().findIndex((t=>t.is(e)))}(e):0}get#kr(){return Array.from(this.buttonsContainer.querySelectorAll("button, details > summary"))}#br(){this.unregisterKeyboardShortcuts=this.#xr.registerCommand(xn,this.#Xn,3)}#_r(){this.unregisterKeyboardShortcuts()}#Xn=e=>{if((e.ctrlKey||e.metaKey)&&e.shiftKey&&"F10"===e.key){const e=this.buttonsContainer?.querySelector("button, [tabindex]:not([tabindex='-1'])");this.#Tr(),e?.focus()}else"Escape"===e.key&&(this.#xr.getEditorState().read((()=>{const e=this.#Cr;e&&this.#xr.update((()=>{e.select()}))})),this.#Er())};#Nr=e=>{"Escape"===e.key?this.#xr.focus():dg(this.#kr,e)};#cr(){this.buttonsContainer=Dg("div",{className:"lexxy-table-handle-buttons"}),this.buttonsContainer.appendChild(this.#Ar()),this.buttonsContainer.appendChild(this.#Lr()),this.moreMenu=this.#Or(),this.buttonsContainer.appendChild(this.moreMenu),this.buttonsContainer.addEventListener("keydown",this.#Nr),this.#Sr.appendChild(this.buttonsContainer)}#Fr(){this.buttonsContainer.style.display="flex",this.#Er(),this.#Rr(),this.#Ir(!0)}#Pr(){this.buttonsContainer.style.display="none",this.#Er(),this.#Ir(!1),this.currentTableNode=null}#Mr(e){const t=this.#xr.getElementByKey(e.getKey());if(!t)return;const n=t.getBoundingClientRect(),r=this.#Sr.getBoundingClientRect(),i=n.top-r.top,o=(n.left+n.right)/2-r.left;this.buttonsContainer.style.top=`${i}px`,this.buttonsContainer.style.left=`${o}px`}#Rr(){if(!this.currentTableNode)return;const e=Yh(this.#xr,this.currentTableNode);if(!e)return;const t=e.rows,n=e.columns;this.rowCount.textContent=`${t} row${1===t?"":"s"}`,this.columnCount.textContent=`${n} column${1===n?"":"s"}`}#fr(e,t,n){const r=Dg("button",{className:"lexxy-table-control__button","aria-label":t,type:"button"});return r.tabIndex=-1,r.innerHTML=`${e} ${t}`,r.addEventListener("click",n.bind(this)),r}#Ar(){const e=Dg("div",{className:"lexxy-table-control"}),t=this.#fr("+","Add row",(()=>this.#Dr("end"))),n=this.#fr("−","Remove row",(()=>this.#Br("end")));return this.rowCount=Dg("span"),this.rowCount.textContent="_ rows",e.appendChild(n),e.appendChild(this.rowCount),e.appendChild(t),e}#Lr(){const e=Dg("div",{className:"lexxy-table-control"}),t=this.#fr("+","Add column",(()=>this.#zr("end"))),n=this.#fr("−","Remove column",(()=>this.#$r("end")));return this.columnCount=Dg("span"),this.columnCount.textContent="_ columns",e.appendChild(n),e.appendChild(this.columnCount),e.appendChild(t),e}#Or(){const e=Dg("details",{className:"lexxy-table-control lexxy-table-control__more-menu"});e.setAttribute("name","lexxy-dropdown"),e.tabIndex=-1;const t=Dg("summary",{},"•••");e.appendChild(t);const n=Dg("div",{className:"lexxy-table-control__more-menu-details"});return e.appendChild(n),n.appendChild(this.#Hr()),n.appendChild(this.#Kr()),n.appendChild(this.#Ur()),e.addEventListener("toggle",this.#Wr.bind(this)),e}#Kr(){const e=Dg("section",{className:"lexxy-table-control__more-menu-section"});return[{icon:this.#Vr("add-column-before"),label:"Add column before",onClick:()=>this.#zr("left")},{icon:this.#Vr("add-column-after"),label:"Add column after",onClick:()=>this.#zr("right")},{icon:this.#Vr("remove-column"),label:"Remove column",onClick:this.#$r},{icon:this.#Vr("toggle-column-style"),label:"Toggle column style",onClick:this.#qr}].forEach((t=>{const n=this.#fr(t.icon,t.label,t.onClick);e.appendChild(n)})),e}#Hr(){const e=Dg("section",{className:"lexxy-table-control__more-menu-section"});return[{icon:this.#Vr("add-row-above"),label:"Add row above",onClick:()=>this.#Dr("above")},{icon:this.#Vr("add-row-below"),label:"Add row below",onClick:()=>this.#Dr("below")},{icon:this.#Vr("remove-row"),label:"Remove row",onClick:this.#Br},{icon:this.#Vr("toggle-row-style"),label:"Toggle row style",onClick:this.#jr}].forEach((t=>{const n=this.#fr(t.icon,t.label,t.onClick);e.appendChild(n)})),e}#Ur(){const e=Dg("section",{className:"lexxy-table-control__more-menu-section"}),t={icon:this.#Vr("delete-table"),label:"Delete table",onClick:this.#Zr},n=this.#fr(t.icon,t.label,t.onClick);return e.appendChild(n),e}#Wr(){this.moreMenu.open?this.#Tr():this.#Gr()}#Er(){this.#Gr(),this.moreMenu.removeAttribute("open")}#yr(){this.#xr.registerUpdateListener((()=>{this.#xr.getEditorState().read((()=>{const e=Li();if(!gi(e))return;const t=$h(e.anchor.getNode());t?this.#Jr(t):this.#Pr()}))}))}#Ir(e){if(this.#Sr.querySelector("div.node--selected:has(table)")?.classList.remove("node--selected"),e&&this.currentTableNode){const e=this.#xr.getElementByKey(this.currentTableNode.getKey());if(!e)return;e.classList.add("node--selected")}}#Jr(e){this.currentTableNode=e,this.#Mr(e),this.#Fr()}#Tr(){this.#xr.getEditorState().read((()=>{const e=this.#Cr;if(!e)return;const t=this.#xr.getElementByKey(e.getKey());t&&t.classList.add("table-cell--selected")}))}#Gr(){this.#Sr.querySelector(".table-cell--selected")?.classList.remove("table-cell--selected")}#Yr(){if(!this.currentTableNode)return;const e=this.currentTableNode.getLastChild().getLastChild();Id(e)&&e.selectEnd()}#Zr(){this.#xr.dispatchCommand("deleteTable"),this.#Er(),this.#Rr()}#Dr(e){this.#Xr("insert","row",e)}#zr(e){this.#Xr("insert","column",e)}#Br(e){this.#Xr("delete","row",e)}#$r(e){this.#Xr("delete","column",e)}#Xr(e="insert",t="row",n){this.#xr.update((()=>{const r=this.#Cr;r&&("end"===n&&this.#Yr(),this.#Qr(e,t,n),r.isAttached()&&r.selectEnd())})),this.#Er(),this.#Rr()}#Qr(e,t,n){switch(e){case"insert":switch(t){case"row":"above"===n?this.#xr.dispatchCommand("insertTableRowAbove"):this.#xr.dispatchCommand("insertTableRowBelow");break;case"column":"left"===n?this.#xr.dispatchCommand("insertTableColumnBefore"):this.#xr.dispatchCommand("insertTableColumnAfter")}break;case"delete":switch(t){case"row":this.#xr.dispatchCommand("deleteTableRow");break;case"column":this.#xr.dispatchCommand("deleteTableColumn")}}}#jr(){this.#xr.update((()=>{const e=this.currentTableNode.getChildren()[this.#vr];if(!e)return;const t=e.getChildren(),n=Wd(t[0]);if(!n)return;const r=n.getHeaderStyles()^Ad;t.forEach((e=>{this.#ei(e,r,Ad)}))}))}#qr(){this.#xr.update((()=>{const e=this.currentTableNode.getChildren(),t=e[this.#vr];if(!t)return;const n=Wd(t.getChildren()[this.#wr]);if(!n)return;const r=n.getHeaderStyles()^Ed;e.forEach((e=>{const t=e.getChildren()[this.#wr];t&&this.#ei(t,r,Ed)}))}))}#ei(e,t,n){const r=Wd(e);r&&r.setHeaderStyles(t,n)}#Vr(e){return{"add-row-above":'\n \n ',"add-row-below":'\n \n ',"remove-row":'\n \n ',"toggle-row-style":'\n \n ',"add-column-before":'\n \n ',"add-column-after":'\n \n ',"remove-column":'\n \n ',"toggle-column-style":'\n \n ',"delete-table":'\n \n '}[e]}}customElements.define("lexxy-table-handler",Af);class Lf{async buildListItems(e=""){return Promise.resolve([])}promptItemFor(e){return null}buildListItemElementFor(e){const t=e.querySelector("template[type='menu']").content.cloneNode(!0),n=Dg("li",{role:"option",id:Hg("prompt-item"),tabindex:"0"});return n.classList.add("lexxy-prompt-menu__item"),n.appendChild(t),n}async loadPromptItemsFromUrl(e){try{const t=await fetch(e),n=Bg(await t.text()).querySelectorAll("lexxy-prompt-item");return Promise.resolve(Array.from(n))}catch(e){return Promise.reject(e)}}}class Of extends Lf{async buildListItems(e=""){const t=await this.fetchPromptItems();return this.#ti(t,e)}async fetchPromptItems(e){return Promise.resolve([])}promptItemFor(e){return this.promptItemByListItem.get(e)}#ti(e,t){const n=[];return this.promptItemByListItem=new WeakMap,e.forEach((e=>{const r=e.getAttribute("search");if(!t||function(e,t){return pf(e).includes(pf(t))}(r,t)){const t=this.buildListItemElementFor(e);this.promptItemByListItem.set(t,e),n.push(t)}})),n}}class Ff extends Of{constructor(e){super(),this.inlinePromptItemElements=Array.from(e)}async fetchPromptItems(){return Promise.resolve(this.inlinePromptItemElements)}}class Rf extends Of{constructor(e){super(),this.url=e,this.fetchPromptItems()}async fetchPromptItems(){return this.promptItems??=await this.loadPromptItemsFromUrl(this.url),Promise.resolve(this.promptItems)}}class If extends Lf{constructor(e){super(),this.baseURL=e,this.loadAndFilterListItems=function(e,t){let n;return(...r)=>(clearTimeout(n),new Promise(((i,o)=>{n=setTimeout((async()=>{try{const t=await e(...r);i(t)}catch(e){o(e)}}),t)})))}(this.fetchFilteredListItems.bind(this),200)}async buildListItems(e=""){return await this.loadAndFilterListItems(e)}promptItemFor(e){return this.promptItemByListItem.get(e)}async fetchFilteredListItems(e){const t=await this.loadPromptItemsFromUrl(this.#ni(e));return this.#ti(t)}#ni(e){const t=new URL(this.baseURL,window.location.origin);return t.searchParams.append("filter",e),t.toString()}#ti(e){const t=[];this.promptItemByListItem=new WeakMap;for(const n of e){const e=this.buildListItemElementFor(n);this.promptItemByListItem.set(e,n),t.push(e)}return t}}class Pf extends HTMLElement{constructor(){super(),this.keyListeners=[]}static observedAttributes=["connected"];connectedCallback(){this.source=this.#ri(),this.#ii(),this.toggleAttribute("connected",!0)}disconnectedCallback(){this.source=null,this.popoverElement=null}attributeChangedCallback(e,t,n){"connected"===e&&this.isConnected&&null!=t&&t!==n&&requestAnimationFrame((()=>this.#g()))}get name(){return this.getAttribute("name")}get trigger(){return this.getAttribute("trigger")}get supportsSpaceInSearches(){return this.hasAttribute("supports-space-in-searches")}get open(){return this.popoverElement?.classList?.contains("lexxy-prompt-menu--visible")}get closed(){return!this.open}get#oi(){return!this.supportsSpaceInSearches}#ri(){const e=this.getAttribute("src");return e?this.hasAttribute("remote-filtering")?new If(e):new Rf(e):new Ff(this.querySelectorAll("lexxy-prompt-item"))}#ii(){const e=this.#xr.registerUpdateListener((()=>{this.#xr.read((()=>{const{node:t,offset:n}=this.#Bt.selectedNodeWithOffset();if(t&&ri(t)&&n>0){const r=t.getTextContent();if(r[n-1]===this.trigger){const t=1===n,i=n>1?r[n-2]:null;(t||(" "===i||"\n"===i))&&(e(),this.#si())}}}))}))}#li(){this.cursorPositionListener=this.#xr.registerUpdateListener((()=>{this.closed||this.#xr.read((()=>{const{node:e,offset:t}=this.#Bt.selectedNodeWithOffset();if(e)if(ri(e)&&t>0){const n=e.getTextContent().slice(0,t).lastIndexOf(this.trigger);(-1===n||t<=n)&&this.#ai()}else this.#ai()}))}))}#ci(){this.cursorPositionListener&&(this.cursorPositionListener(),this.cursorPositionListener=null)}get#xr(){return this.#Sr.editor}get#Sr(){return this.closest("lexxy-editor")}get#Bt(){return this.#Sr.selection}async#si(){this.popoverElement??=await this.#ui(),this.#di(),await this.#hi(),this.popoverElement.classList.toggle("lexxy-prompt-menu--visible",!0),this.#gi(),this.#Sr.addEventListener("keydown",this.#pi),this.#Sr.addEventListener("lexxy:change",this.#hi),this.#fi(),this.#li()}#fi(){this.keyListeners.push(this.#xr.registerCommand(En,this.#mi.bind(this),3)),this.keyListeners.push(this.#xr.registerCommand(Fn,this.#mi.bind(this),3)),this.#oi&&this.keyListeners.push(this.#xr.registerCommand(Nn,this.#mi.bind(this),3)),this.keyListeners.push(this.#xr.registerCommand(kn,this.#yi.bind(this),3)),this.keyListeners.push(this.#xr.registerCommand(Tn,this.#bi.bind(this),3))}#yi(e){return this.#_i(),e.preventDefault(),!0}#bi(e){return this.#xi(),e.preventDefault(),!0}#gi(){const e=this.#Si[0];e&&this.#Ci(e)}get#Si(){return Array.from(this.popoverElement.querySelectorAll(".lexxy-prompt-menu__item"))}#Ci(e){this.#vi(),e.toggleAttribute("aria-selected",!0),e.scrollIntoView({block:"nearest",behavior:"smooth"}),e.focus(),this.#Bt.preservingSelection((()=>{this.#Sr.focus()})),this.#wi.setAttribute("aria-controls",this.popoverElement.id),this.#wi.setAttribute("aria-activedescendant",e.id),this.#wi.setAttribute("aria-haspopup","listbox")}#vi(){this.#Si.forEach((e=>{e.toggleAttribute("aria-selected",!1)})),this.#wi.removeAttribute("aria-controls"),this.#wi.removeAttribute("aria-activedescendant"),this.#wi.removeAttribute("aria-haspopup")}#ki(){const{x:e,y:t,fontSize:n}=this.#Bt.cursorPosition,r=this.#Sr.getBoundingClientRect(),i=this.#wi.getBoundingClientRect().top-r.top;this.popoverElement.hasAttribute("data-anchored")||(this.popoverElement.style.left=`${e}px`,this.popoverElement.toggleAttribute("data-anchored",!0)),this.popoverElement.style.top=`${t+i}px`,this.popoverElement.style.bottom="auto";const o=this.popoverElement.getBoundingClientRect();(o.bottom>window.innerHeight||this.popoverElement.hasAttribute("data-clipped-at-bottom"))&&(this.popoverElement.style.top=t+i-o.height-n+"px",this.popoverElement.style.bottom="auto",this.popoverElement.toggleAttribute("data-clipped-at-bottom",!0))}#di(){this.popoverElement.removeAttribute("data-clipped-at-bottom"),this.popoverElement.removeAttribute("data-anchored")}async#ai(){this.#vi(),this.popoverElement.classList.toggle("lexxy-prompt-menu--visible",!1),this.#Sr.removeEventListener("lexxy:change",this.#hi),this.#Sr.removeEventListener("keydown",this.#pi),this.#Ti(),this.#ci(),await Zg(),this.#ii()}#Ti(){this.keyListeners.forEach((e=>e())),this.keyListeners=[]}#hi=async()=>{this.initialPrompt?this.initialPrompt=!1:this.#Ei.containsTextBackUntil(this.trigger)?(await this.#Ni(),await Zg(),this.#ki()):this.#ai()};async#Ni(){const e=this.#Ei.textBackUntil(this.trigger),t=await this.source.buildListItems(e);this.popoverElement.innerHTML="",t.length>0?this.#Ai(t):this.#Li(),this.#gi()}#Ai(e){this.popoverElement.classList.remove("lexxy-prompt-menu--empty"),this.popoverElement.append(...e)}#Li(){this.popoverElement.classList.add("lexxy-prompt-menu--empty");const e=Dg("li",{innerHTML:this.#Oi});e.classList.add("lexxy-prompt-menu__item--empty"),this.popoverElement.append(e)}get#Oi(){return this.getAttribute("empty-results")||"Nothing found"}#pi=e=>{"Escape"===e.key&&(this.#ai(),this.#Sr.focus(),e.stopPropagation())};#xi(){const e=this.#Fi+1;e=0&&this.#Ci(this.#Si[e])}get#Fi(){return this.#Si.findIndex((e=>e.hasAttribute("aria-selected")))}get#Ri(){return this.#Si[this.#Fi]}#mi(e){return e.preventDefault(),e.stopPropagation(),this.#Ii(),!0}#Ii(){this.#Pi(),this.#ai(),this.#Sr.focus()}#Pi(){const e=this.source.promptItemFor(this.#Ri);if(!e)return;const t=e.querySelector("template[type='editor']"),n=`${this.trigger}${this.#Ei.textBackUntil(this.trigger)}`;this.hasAttribute("insert-editable-text")?this.#Mi(t,n):this.#Di(e,t,n)}#Mi(e,t){this.#xr.update((()=>{const n=Bc(this.#xr,Bg(`${e.innerHTML}`));this.#Ei.replaceTextBackUntil(t,n)}))}#Di(e,t,n){this.#xr.update((()=>{const r=new Jg({sgid:e.getAttribute("sgid"),contentType:`application/vnd.actiontext.${this.name}`,innerHtml:t.innerHTML});this.#Ei.replaceTextBackUntil(n,r)}))}get#Ei(){return this.#Sr.contents}get#wi(){return this.#Sr.editorContentElement}async#ui(){const e=Dg("ul",{role:"listbox",id:Hg("prompt-popover")});return e.classList.add("lexxy-prompt-menu"),e.style.position="absolute",e.setAttribute("nonce",wa()),e.append(...await this.source.buildListItems()),e.addEventListener("click",this.#Bi),this.#Sr.appendChild(e),e}#Bi=e=>{const t=e.target.closest(".lexxy-prompt-menu__item");t&&(this.#Ci(t),this.#Ii())};#g(){this.disconnectedCallback(),this.connectedCallback()}}customElements.define("lexxy-prompt",Pf);class Mf extends HTMLElement{connectedCallback(){this.editorElement=this.closest("lexxy-editor"),this.editor=this.editorElement.editor,this.#zi(),this.#$i()}#zi(){this.languagePickerElement=this.#Hi(),this.languagePickerElement.addEventListener("change",(()=>{this.#Ki(this.languagePickerElement.value)})),this.languagePickerElement.style.position="absolute",this.languagePickerElement.setAttribute("nonce",wa()),this.editorElement.appendChild(this.languagePickerElement)}#Hi(){const e=Dg("select",{hidden:!0,className:"lexxy-code-language-picker","aria-label":"Pick a language…",name:"lexxy-code-language"});for(const[t,n]of Object.entries(this.#Ui)){const r=document.createElement("option");r.value=t,r.textContent=n,e.appendChild(r)}return e}get#Ui(){const e={...Ju};e.ruby||(e.ruby="Ruby"),e.php||(e.php="PHP"),e.go||(e.go="Go"),e.bash||(e.bash="Bash"),e.json||(e.json="JSON"),e.diff||(e.diff="Diff");const t=Object.entries(e).sort((([,e],[,t])=>e.localeCompare(t))),n=t.findIndex((([e])=>"plain"===e)),r=t.splice(n,1)[0];return Object.fromEntries([r,...t])}#Ki(e){this.editor.update((()=>{const t=this.#Wi();t&&t.setLanguage(e)}))}#$i(){this.editor.registerUpdateListener((()=>{this.editor.getEditorState().read((()=>{const e=this.#Wi();e?this.#Vi(e):this.#qi()}))}))}#Wi(){const e=Li();if(!gi(e))return null;const t=e.anchor.getNode(),n=t.getParent();return Pu(t)?t:Pu(n)?n:null}#Vi(e){const t=e.getLanguage();this.#ji(t),this.#Zi(),this.#Gi(e)}#ji(e){if(this.languagePickerElement&&e){const t=Xu(e);this.languagePickerElement.value=t}}#Gi(e){const t=this.editor.getElementByKey(e.getKey());if(!t)return;const n=t.getBoundingClientRect(),r=this.editorElement.getBoundingClientRect(),i=n.top-r.top;this.languagePickerElement.style.top=`${i}px`}#Zi(){this.languagePickerElement.hidden=!1}#qi(){this.languagePickerElement.hidden=!0}}function Df(){document.querySelectorAll("pre[data-language]").forEach((e=>{!function(e){const t=e.getAttribute("data-language");let n=e.innerHTML.replace(//gi,"\n");const r=s.languages?.[t];if(!r)return;n=(new DOMParser).parseFromString(n,"text/html").body.textContent||"";const i=s.highlight(n,r,t),o=Dg("code",{"data-language":t,innerHTML:i});e.replaceWith(o)}(e)}))}customElements.define("lexxy-code-language-picker",Mf);export{Df as highlightAll}; diff --git a/app/assets/javascript/lexxy.min.js.br b/app/assets/javascript/lexxy.min.js.br index e8262b7c..13de3d03 100644 Binary files a/app/assets/javascript/lexxy.min.js.br and b/app/assets/javascript/lexxy.min.js.br differ diff --git a/app/assets/javascript/lexxy.min.js.gz b/app/assets/javascript/lexxy.min.js.gz index eb2a567e..6c1cebcc 100644 Binary files a/app/assets/javascript/lexxy.min.js.gz and b/app/assets/javascript/lexxy.min.js.gz differ diff --git a/src/editor/contents.js b/src/editor/contents.js index 9cc2b04e..12e18163 100644 --- a/src/editor/contents.js +++ b/src/editor/contents.js @@ -278,8 +278,8 @@ export default class Contents { let focusNode = null this.editor.update(() => { - if ($isNodeSelection(this.#selection.current)) { - const nodesToRemove = this.#selection.current.getNodes() + if (this.#selection.hasNodeSelection) { + const nodesToRemove = $getSelection().getNodes() if (nodesToRemove.length === 0) return focusNode = this.#findAdjacentNodeTo(nodesToRemove) @@ -291,7 +291,6 @@ export default class Contents { this.editor.update(() => { this.#selectAfterDeletion(focusNode) - this.#selection.clear() this.editor.focus() }) } diff --git a/src/editor/selection.js b/src/editor/selection.js index 5e719147..39a95aff 100644 --- a/src/editor/selection.js +++ b/src/editor/selection.js @@ -24,26 +24,19 @@ export default class Selection { this.#containEditorFocus() } - clear() { - this.current = null - } - set current(selection) { - if ($isNodeSelection(selection)) { - this.editor.getEditorState().read(() => { - this._current = $getSelection() - this.#syncSelectedClasses() - }) - } else { - this.editor.update(() => { - this.#syncSelectedClasses() - this._current = null - }) - } + this.editor.update(() => { + this.#syncSelectedClasses() + }) } - get current() { - return this._current + get hasNodeSelection() { + let result = false + this.editor.getEditorState().read(() => { + const selection = $getSelection() + result = selection !== null && $isNodeSelection(selection) + }) + return result } get cursorPosition() { @@ -236,18 +229,18 @@ export default class Selection { } get #currentlySelectedKeys() { - if (this._currentlySelectedKeys) { return this._currentlySelectedKeys } + if (this.currentlySelectedKeys) { return this.currentlySelectedKeys } - this._currentlySelectedKeys = new Set() + this.currentlySelectedKeys = new Set() const selection = $getSelection() if (selection && $isNodeSelection(selection)) { for (const node of selection.getNodes()) { - this._currentlySelectedKeys.add(node.getKey()) + this.currentlySelectedKeys.add(node.getKey()) } } - return this._currentlySelectedKeys + return this.currentlySelectedKeys } #processSelectionChangeCommands() { @@ -377,7 +370,7 @@ export default class Selection { this.#highlightNewItems() this.previouslySelectedKeys = this.#currentlySelectedKeys - this._currentlySelectedKeys = null + this.currentlySelectedKeys = null } #clearPreviouslyHighlightedItems() { @@ -399,7 +392,7 @@ export default class Selection { } async #selectPreviousNode() { - if (this.current) { + if (this.hasNodeSelection) { await this.#withCurrentNode((currentNode) => currentNode.selectPrevious()) } else { this.#selectInLexical(this.nodeBeforeCursor) @@ -407,7 +400,7 @@ export default class Selection { } async #selectNextNode() { - if (this.current) { + if (this.hasNodeSelection) { await this.#withCurrentNode((currentNode) => currentNode.selectNext(0, 0)) } else { this.#selectInLexical(this.nodeAfterCursor) @@ -415,7 +408,7 @@ export default class Selection { } async #selectPreviousTopLevelNode() { - if (this.current) { + if (this.hasNodeSelection) { await this.#withCurrentNode((currentNode) => currentNode.selectPrevious()) } else { this.#selectInLexical(this.topLevelNodeBeforeCursor) @@ -423,7 +416,7 @@ export default class Selection { } async #selectNextTopLevelNode() { - if (this.current) { + if (this.hasNodeSelection) { await this.#withCurrentNode((currentNode) => currentNode.selectNext(0, 0)) } else { this.#selectInLexical(this.topLevelNodeAfterCursor) @@ -432,10 +425,9 @@ export default class Selection { async #withCurrentNode(fn) { await nextFrame() - if (this.current) { + if (this.hasNodeSelection) { this.editor.update(() => { - this.clear() - fn(this.current.getNodes()[0]) + fn($getSelection().getNodes()[0]) this.editor.focus() }) }