rt-native 1.0.116 → 1.0.118
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +131 -54
- package/package.json +1 -1
- package/rt-native.js +1 -1
package/rt-native.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
class t{constructor(t,e,o,i,n){this.id=t,this.shadow_id=e,this.toolbar_id=o,this.styles=i,this.dotNetObjectReference=n,this.init()}init=()=>{this.hydrateShadowTree(),this.Utilities=new r(this.shadowRoot,this.content),this.NodeManager=new o(this.shadowRoot,this.content,this.Utilities),this.ActionOptions=new n(this.shadowRoot,this.content,this.Utilities),this.ListProvider=new i(this.shadowRoot,this.content,this.Utilities,this.NodeManager),this.ColorPickers={};const t="rich-text-box-text-color-modal",m="rich-text-box-text-bg-color-modal";this.ColorPickers[t]=new g(this.shadowRoot,this.content,t,this.NodeManager,this.Utilities),this.ColorPickers[m]=new g(this.shadowRoot,this.content,m,this.NodeManager,this.Utilities),this.LinkDialog=new u(this.shadowRoot,this.content,this.Utilities),this.ImageDialog=new b(this.shadowRoot,this.content,this.Utilities),this.UploadImageDialog=new h(this.shadowRoot,this.content,this.Utilities),this.BlockQuoteDialog=new d(this.shadowRoot,this.content,this.Utilities),this.CodeBlockDialog=new c(this.shadowRoot,this.content,this.Utilities),this.MediaDialog=new l(this.shadowRoot,this.content,this.Utilities),this.VideoDialog=new a(this.shadowRoot,this.content,this.Utilities),this.TableDialog=new s(this.shadowRoot,this.content,this.Utilities),this.StateManager=new e(this.content,this.source,this.Utilities,this.dotNetObjectReference,this.contentContainer),this.addEventListeners()};hydrateShadowTree=()=>{const t=document.getElementById(this.shadow_id);this.shadowRoot=t.attachShadow({mode:"open"});const e=document.createElement("style");e.textContent=this.styles,this.shadowRoot.appendChild(e),this.contentContainer=document.createElement("div"),this.contentContainer.classList.add("rich-text-box-content-container","rich-text-box-scroll"),this.container=document.createElement("div"),this.container.classList.add("rich-text-box-container","rich-text-box-scroll"),this.content=document.createElement("div"),this.content.setAttribute("id",this.id),this.content.setAttribute("class","rich-text-box-content"),this.content.setAttribute("contenteditable","true"),this.content.setAttribute("role","textbox"),this.content.setAttribute("aria-multiline","true"),this.content.setAttribute("aria-label","Rich text editor"),this.content.setAttribute("aria-readonly","false"),this.content.style.display="block",this.source=document.createElement("textarea"),this.source.setAttribute("id","rich-text-box-source"),this.source.setAttribute("aria-label","HTML source"),this.source.classList.add("rich-text-box-source","rich-text-box-scroll"),this.source.style.display="none",this.source.spellcheck=!1;const o=document.createElement("div");o.setAttribute("class","rich-text-box-message-bar rich-text-box-message-hidden"),o.setAttribute("id","rich-text-box-message-bar");const i=document.createElement("span");i.setAttribute("class","rich-text-box-message");const n=document.createElement("button");n.setAttribute("class","rich-text-box-message-close-button"),n.textContent="×",n.onclick=()=>{this.Utilities.closeFadingBar()},o.appendChild(i),o.appendChild(n),this.statusBar=document.createElement("div"),this.statusBar.className="rtb-status-bar",this.statusBar.setAttribute("role","status"),this.statusBar.setAttribute("aria-live","polite"),this.statusBar.setAttribute("aria-atomic","true"),this.statusBar.id="rich-text-box-status-bar",this.statusBar.textContent="0 words · 0 characters";const r=document.getElementById(this.toolbar_id);this.container.appendChild(r),this.contentContainer.appendChild(this.content),this.contentContainer.appendChild(this.source),this.container.appendChild(o),this.container.appendChild(this.contentContainer),this.container.appendChild(this.statusBar),this.shadowRoot.appendChild(this.container)};addEventListeners=()=>{document.addEventListener("selectionchange",t=>{const e=this.Utilities.getSelection();null!==e&&this.clearSettings(e.anchorNode)}),this.content.addEventListener("click",t=>{"A"===t.target.tagName&&(t.preventDefault(),t.stopPropagation())}),this.content.addEventListener("click",t=>{const e=t.target.tagName;if("VIDEO"===e||"SOURCE"===e){t.preventDefault();const o="SOURCE"===e?t.target.closest("video"):t.target;if(o&&o.parentNode===this.content){if(!o.nextSibling){const t=document.createElement("p");t.appendChild(document.createElement("br")),this.content.insertBefore(t,null)}const t=o.nextSibling,e=window.getSelection();if(e&&t){const o=document.createRange(),i=t.firstChild??t;o.setStart(i,0),o.collapse(!0),e.removeAllRanges(),e.addRange(o)}}}},!0),this.content.addEventListener("dblclick",t=>{const e=t.target.tagName;"VIDEO"!==e&&"SOURCE"!==e||t.preventDefault()},!0),this.content.addEventListener("dblclick",t=>{switch(t.target.tagName){case"A":t.preventDefault(),this.openLinkDialog();break;case"IMG":t.preventDefault();const e=this.Utilities.getSelection(),o=document.createRange();o.selectNodeContents(t.target),e.removeAllRanges(),e.addRange(o),t.target.src.startsWith("data")?this.uploadImageDialog():this.openImageDialog();break;case"VIDEO":case"SOURCE":{t.preventDefault();const e="SOURCE"===t.target.tagName?t.target.closest("video"):t.target;if(e){const t=this.Utilities.getSelection(),o=document.createRange();o.selectNode(e),t.removeAllRanges(),t.addRange(o),this.openVideoDialogForElement(e)}else this.openVideoDialog();break}case"BLOCKQUOTE":t.preventDefault(),this.openBlockQuoteDialogForElement(t.target);break;case"PRE":t.preventDefault(),this.openCodeBlockDialogForElement(t.target);break;case"CODE":{const e=t.target.closest("pre");e&&this.content.contains(e)&&(t.preventDefault(),this.openCodeBlockDialogForElement(e));break}default:{const e=t.target.closest("pre");if(e&&this.content.contains(e)){t.preventDefault(),this.openCodeBlockDialogForElement(e);break}const o=t.target.closest("blockquote");o&&this.content.contains(o)&&(t.preventDefault(),this.openBlockQuoteDialogForElement(o));break}}}),this.content.addEventListener("input",t=>{this.updateWordCount();const e=this.Utilities.getSelection(),o=e.getRangeAt(0).startContainer;if(o.nodeType===Node.TEXT_NODE&&"SPAN"===o.parentNode.tagName){const t=o.parentNode,i=t.parentNode;if(this.NodeManager.isFormatElement(i)){for(;t.firstChild;)i.insertBefore(t.firstChild,t);i.removeChild(t);const o=document.createRange();o.setStart(i.firstChild,0),o.collapse(!0),e.removeAllRanges(),e.addRange(o)}}}),this.content.addEventListener("keydown",t=>{this.keyEvents(t)}),this.source.addEventListener("keydown",t=>{t.ctrlKey&&t.shiftKey&&"A"===t.key&&(t.preventDefault(),!0===this.EditMode?this.getHtml():this.getCode()),t.ctrlKey&&t.shiftKey&&"P"===t.key&&(t.preventDefault(),this.openPreview()),t.ctrlKey&&t.shiftKey&&"S"===t.key&&(t.preventDefault(),this.saveHtml()),t.ctrlKey&&!t.shiftKey&&"\\"===t.key&&(t.preventDefault(),this.toggleStatusBar())});this.shadowRoot.querySelectorAll(".rich-text-box-dropdown-content").forEach(t=>{t.addEventListener("mousedown",t=>{t.preventDefault()})})};goBack=()=>{this.StateManager.goBack(),this.NodeManager.refreshUI(),this.updateWordCount()};goForward=()=>{this.StateManager.goForward(),this.NodeManager.refreshUI(),this.updateWordCount()};clearSettings=t=>{this.fontSize=void 0,this.NodeManager.selectButtons(t)};keyEvents=t=>{if(this.NodeManager.createDefaultElement(),!1===this.EditMode)return t.ctrlKey&&"z"===t.key&&t.preventDefault(),void(t.ctrlKey&&"y"===t.key&&t.preventDefault());if("Enter"===t.key&&!t.ctrlKey&&!t.altKey&&!t.metaKey){if(this.TableDialog.addRowFromLastCell())return void t.preventDefault();if(this.insertParagraphAfterStructuredBlock())return void t.preventDefault()}if(t.ctrlKey&&"b"===t.key&&(t.preventDefault(),this.bold()),t.ctrlKey&&"i"===t.key&&(t.preventDefault(),this.italic()),t.ctrlKey&&"u"===t.key&&(t.preventDefault(),this.underline()),t.ctrlKey&&"d"===t.key&&(t.preventDefault(),this.strikethrough()),t.ctrlKey&&"c"===t.key&&(t.preventDefault(),this.copy()),t.ctrlKey&&"x"===t.key&&(t.preventDefault(),this.cut()),t.ctrlKey&&"v"===t.key&&(t.preventDefault(),this.paste()),"Delete"===t.key||46===t.keyCode){const e=this.Utilities.getSelection();null!==e&&e.toString().length>0&&(t.preventDefault(),this.delete())}if(t.ctrlKey&&"="===t.key&&(t.preventDefault(),this.subscript()),t.ctrlKey&&t.shiftKey&&"+"===t.key&&(t.preventDefault(),this.superscript()),t.ctrlKey&&"l"===t.key&&(t.preventDefault(),this.alignleft()),t.ctrlKey&&"e"===t.key&&(t.preventDefault(),this.aligncenter()),t.ctrlKey&&"r"===t.key&&(t.preventDefault(),this.alignright()),t.ctrlKey&&"j"===t.key&&(t.preventDefault(),this.alignjustify()),t.ctrlKey&&"a"===t.key&&(t.preventDefault(),this.selectall()),t.ctrlKey&&"z"===t.key&&(t.preventDefault(),this.goBack()),t.ctrlKey&&"y"===t.key&&(t.preventDefault(),this.goForward()),t.ctrlKey&&t.shiftKey&&"A"===t.key&&(t.preventDefault(),this.toggleView()),t.ctrlKey&&t.shiftKey&&"S"===t.key&&(t.preventDefault(),this.saveHtml()),t.ctrlKey&&t.shiftKey&&"&"===t.key&&(t.preventDefault(),this.uploadImageDialog()),t.ctrlKey&&t.shiftKey&&"U"===t.key&&(t.preventDefault(),this.unorderedlist()),t.ctrlKey&&t.shiftKey&&"O"===t.key&&(t.preventDefault(),this.orderedlist()),t.ctrlKey&&t.shiftKey&&">"===t.key&&(t.preventDefault(),this.changeFontSize(!0)),t.ctrlKey&&t.shiftKey&&"<"===t.key&&(t.preventDefault(),this.changeFontSize(!1)),t.ctrlKey&&t.shiftKey&&"C"===t.key&&(t.preventDefault(),this.openTextColorDialog()),t.ctrlKey&&t.shiftKey&&"B"===t.key&&(t.preventDefault(),this.openTextBackgroundColorDialog()),t.ctrlKey&&t.shiftKey&&"K"===t.key&&(t.preventDefault(),this.openLinkDialog()),t.ctrlKey&&t.shiftKey&&"*"===t.key&&(t.preventDefault(),this.openCodeBlockDialog()),t.ctrlKey&&t.shiftKey&&"Q"===t.key&&(t.preventDefault(),this.openBlockQuoteDialog()),t.ctrlKey&&t.shiftKey&&"I"===t.key&&(t.preventDefault(),this.openImageDialog()),t.ctrlKey&&t.shiftKey&&"M"===t.key&&(t.preventDefault(),this.openMediaDialog()),t.ctrlKey&&t.shiftKey&&"L"===t.key&&(t.preventDefault(),this.openTableDialog()),t.ctrlKey&&t.shiftKey&&"D"===t.key&&(t.preventDefault(),this.format("none")),t.ctrlKey&&t.shiftKey&&"P"===t.key&&(t.preventDefault(),this.openPreview()),t.ctrlKey&&t.shiftKey&&"!"===t.key&&(t.preventDefault(),this.format("h1")),t.ctrlKey&&t.shiftKey&&"@"===t.key&&(t.preventDefault(),this.format("h2")),t.ctrlKey&&t.shiftKey&&"#"===t.key&&(t.preventDefault(),this.format("h3")),t.ctrlKey&&t.shiftKey&&"$"===t.key&&(t.preventDefault(),this.format("h4")),t.ctrlKey&&t.shiftKey&&"%"===t.key&&(t.preventDefault(),this.format("h5")),t.ctrlKey&&t.shiftKey&&"^"===t.key&&(t.preventDefault(),this.format("h6")),t.ctrlKey&&t.shiftKey&&"V"===t.key&&(t.preventDefault(),this.openVideoDialog()),t.ctrlKey&&t.shiftKey&&"H"===t.key&&(t.preventDefault(),this.insertHorizontalRule()),t.ctrlKey&&!t.shiftKey&&"\\"===t.key&&(t.preventDefault(),this.toggleStatusBar()),"Backspace"===t.key){const e=this.Utilities.getSelection();if(e&&e.isCollapsed){const o=e.getRangeAt(0),i=["P","DIV","H1","H2","H3","H4","H5","H6","OL","UL","SECTION","ARTICLE","HEADER","FOOTER"];let n=e.anchorNode;for(;n&&n!==this.content&&(n.nodeType!==Node.ELEMENT_NODE||!i.includes(n.nodeName));)n=n.parentNode;if(n&&n!==this.content){if((parseFloat(window.getComputedStyle(n).marginLeft)||0)>0){const e=document.createRange();e.setStart(n,0),e.setEnd(o.startContainer,o.startOffset),0===e.toString().length&&(t.preventDefault(),this.decreaseIndent())}}}}if(t.shiftKey&&"Tab"===t.key)t.preventDefault(),this.decreaseIndent();else if("Tab"===t.key){const e=this.Utilities.getSelection();if(null!==e&&null!=e.anchorNode&&e.anchorNode!==this.content&&null!=e.anchorNode.parentNode&&e.anchorNode.parentNode!=this.content)if("TD"===e.anchorNode.parentNode.nodeName)t.preventDefault(),this.TableDialog.tableTab();else t.preventDefault(),this.increaseIndent()}};isBreakable=t=>{let e=!1;switch(t){case"BLOCKQUOTE":case"CODE":case"P":case"SPAN":e=!0}return e};getStructuredBlockFromNode=t=>{if(!t||t===this.content)return null;const e=t.nodeType===Node.ELEMENT_NODE?t:t.parentElement;if(!e||!this.content.contains(e))return null;const o=e.closest("pre");if(o&&this.content.contains(o))return o;const i=e.closest("blockquote");return i&&this.content.contains(i)?i:null};insertParagraphAfterStructuredBlock=()=>{const t=this.Utilities.getSelection();if(!t||0===t.rangeCount)return!1;const e=this.getStructuredBlockFromNode(t.anchorNode);if(!e)return!1;const o=document.createElement("p");o.appendChild(document.createElement("br")),e.nextSibling?e.parentNode.insertBefore(o,e.nextSibling):e.parentNode.appendChild(o);const i=document.createRange();return i.setStart(o,0),i.collapse(!0),t.removeAllRanges(),t.addRange(i),this.content.focus(),!0};changeFontSize=t=>{if(void 0===this.fontSize){const t=this.Utilities.getSelection();if(null!==t&&t&&t.rangeCount>0){const e=t.getRangeAt(0),o=window.getComputedStyle(e.commonAncestorContainer.parentElement);this.fontSize=parseFloat(o.fontSize)}}t?this.fontSize+=1:this.fontSize-=1,this.NodeManager.updateNode("size",`${this.fontSize}px`)};openPreview=()=>{this.preview=this.shadowRoot.getElementById(`${this.id}_Preview`);const t=this.shadowRoot.getElementById("rich-text-box-preview");this.preview&&t&&(this.loadPreviewWindow(t),this.addPreviewEventListeners(this.preview),this.preview.showModal(),t.scrollTop=0,t.scrollLeft=0)};addPreviewEventListeners=t=>{t.addEventListener("keydown",t=>{"Enter"===t.key&&(t.preventDefault(),this.closePreview()),"Escape"===t.key&&(t.preventDefault(),this.closePreview())})};loadPreviewWindow=t=>{const e="block"===this.content.style.display?this.html()||"":this.source.value||"",o=t.shadowRoot||t.attachShadow({mode:"open"});for(;o.firstChild;)o.removeChild(o.firstChild);const i=document.createElement("style");i.textContent=":host{display:block;position:relative;}iframe{position:absolute;top:0;left:0;width:100%;height:100%;border:none;}",o.appendChild(i);const n=(this._previewCssUrls||[]).filter(t=>t).map(t=>`<link rel="stylesheet" href="${t.replace(/"/g,"%22")}">`).join(""),r=this._previewCssText?`<style>${this._previewCssText}</style>`:"",s=this._rtbHostElement,l=s?getComputedStyle(s):null,getVar=(t,e)=>(l?l.getPropertyValue(t).trim():"")||e,a=["<style>","html,body{margin:0;}","body{"," padding:20px 24px;",` color:${getVar("--rtb-content-text","#242424")};`,` font-size:${getVar("--rtb-content-size","16px")};`,` font-family:${getVar("--rtb-content-font","Arial, Helvetica, Verdana, sans-serif")};`,` line-height:${getVar("--rtb-content-line-height","1.55")};`,` background-color:${getVar("--rtb-content-bg","#FFF")};`,"}",`blockquote{background:${getVar("--rtb-quote-bg","#f9f9f9")};border-left:${getVar("--rtb-quote-border-width","5px")} solid ${getVar("--rtb-quote-border-color","#ccc")};color:${getVar("--rtb-quote-text",getVar("--rtb-content-text","#242424"))};margin:1.5em 10px;padding:0.5em 10px;}`,`pre{background:${getVar("--rtb-code-bg","#f9f9f9")};border-radius:${getVar("--rtb-code-border-radius","10px")};overflow-x:auto;white-space:pre-wrap;margin:1.5em 10px;padding:0.5em 10px;}`,"table{border-collapse:collapse;}","td,th{border:1px solid #ccc;padding:4px 6px;height:25px;min-width:100px;}","</style>"].join(""),c=document.createElement("iframe");c.srcdoc=["<!DOCTYPE html><html><head>",'<meta charset="UTF-8">',a,n,r,"</head><body>",e,"</body></html>"].join(""),o.appendChild(c),this.NodeManager.clearButtons(),this.enablePreview()};closePreview=()=>{this.disablePreview(),this._resetPreviewMaximize(),this.preview.close(),this.source.focus(),this.content.focus()};togglePreviewMaximize=()=>{const t=this.shadowRoot.getElementById(`${this.id}_Preview`),e=this.shadowRoot.getElementById(`${this.id}_PreviewMaxBtn`);if(!t||!e)return;const o=!t.hasAttribute("data-maximized"),i=[["width","100vw"],["height","100vh"],["max-width","100vw"],["max-height","100vh"],["top","0"],["left","0"],["transform","none"],["border-radius","0"],["resize","none"]];o?(t.setAttribute("data-maximized",""),i.forEach(([e,o])=>t.style.setProperty(e,o))):(t.removeAttribute("data-maximized"),i.forEach(([e])=>t.style.removeProperty(e))),e.setAttribute("aria-label",o?"Restore preview":"Maximize preview"),e.querySelector("svg").innerHTML=o?'<path d="M4.5 1.5V4.5H1.5M7.5 10.5V7.5H10.5M4.5 4.5L1.5 1.5M7.5 7.5L10.5 10.5" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" fill="none"/>':'<path d="M1.5 4.5V1.5H4.5M10.5 7.5V10.5H7.5M1.5 1.5L4.5 4.5M10.5 10.5L7.5 7.5" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" fill="none"/>'};_resetPreviewMaximize=()=>{const t=this.shadowRoot.getElementById(`${this.id}_Preview`),e=this.shadowRoot.getElementById(`${this.id}_PreviewMaxBtn`);t&&e&&(t.removeAttribute("data-maximized"),["width","height","max-width","max-height","top","left","transform","border-radius","resize"].forEach(e=>t.style.removeProperty(e)),e.setAttribute("aria-label","Maximize preview"),e.querySelector("svg").innerHTML='<path d="M1.5 4.5V1.5H4.5M10.5 7.5V10.5H7.5M1.5 1.5L4.5 4.5M10.5 10.5L7.5 7.5" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" fill="none"/>')};insertHorizontalRule=()=>{const t=this.Utilities.getSelection();if(!t||!t.rangeCount)return;const e=t.getRangeAt(0);e.deleteContents();let o=e.startContainer;if(o===this.content){const t=this.content.childNodes[e.startOffset]??null,o=document.createElement("hr");return this.content.insertBefore(o,t),this.NodeManager.refreshUI(),void this.content.dispatchEvent(new Event("input",{bubbles:!0}))}for(;o.parentNode&&o.parentNode!==this.content;)if(o=o.parentNode,!this.content.contains(o))return this.content.appendChild(document.createElement("hr")),this.NodeManager.refreshUI(),void this.content.dispatchEvent(new Event("input",{bubbles:!0}));const i=document.createElement("hr");o&&o!==this.content&&this.content.contains(o)?this.content.insertBefore(i,o.nextSibling):this.content.appendChild(i),this.NodeManager.refreshUI(),this.content.dispatchEvent(new Event("input",{bubbles:!0}))};toggleStatusBar=()=>{if(!this.statusBar)return;const t="none"===this.statusBar.style.display,e=this.shadowRoot.getElementById("blazing-rich-text-statusbar-button");t?(this.statusBar.style.display="",e&&(e.classList.add("selected"),e.setAttribute("aria-pressed","true")),this.updateWordCount()):(this.statusBar.style.display="none",e&&(e.classList.remove("selected"),e.setAttribute("aria-pressed","false")))};updateWordCount=()=>{if(!this.statusBar||"none"===this.statusBar.style.display)return;const t=this.content.innerText||"",e=t.trim(),o=e?e.split(/\s+/).length:0,i=t.replace(/\n/g,"").length;this.statusBar.textContent=`${o} word${1!==o?"s":""} · ${i} character${1!==i?"s":""}`};_syncWordCountVisibility=()=>{const t=!1!==this._rtbHostElement?._visibility?.wordCount;this.statusBar&&(this.statusBar.style.display=t?"":"none")};setReadOnly=t=>{this.content.contentEditable=t?"false":"true",this.content.setAttribute("aria-readonly",t?"true":"false");const e=this.shadowRoot.querySelector(`#${CSS.escape(this.toolbar_id)}`);e&&(e.style.display=t?"none":"")};saveHtml=()=>{const t="block"===this.content.style.display?this.html()||"":this.source.value||"",e=new Blob([t],{type:"text/html"}),o=URL.createObjectURL(e),i=document.createElement("a");i.href=o,i.download=this.createTimestampedHtmlFileName(),i.click(),URL.revokeObjectURL(o)};createTimestampedHtmlFileName=()=>{const t=new Date,pad=t=>String(t).padStart(2,"0");return`html-${[t.getFullYear(),pad(t.getMonth()+1),pad(t.getDate())].join("-")+"_"+[pad(t.getHours()),pad(t.getMinutes()),pad(t.getSeconds())].join("-")}.html`};enablePreview=()=>{this.shadowRoot.getElementById("blazing-rich-text-source").disabled=!0,this.disableButtons()};disablePreview=()=>{this.shadowRoot.getElementById("blazing-rich-text-source").disabled=!1,"block"===this.content.style.display&&this.enableButtons()};format=t=>{this.NodeManager.formatNode(t),this.closeDropdown("blazing-rich-text-format-button-dropdown")};dropdown=t=>{const e=this.shadowRoot.getElementById(t);null!=e&&e.classList.contains("rich-text-box-show")?e.classList.remove("rich-text-box-show"):(this.NodeManager.closeDropdowns(),e.classList.add("rich-text-box-show"))};increaseIndent=()=>{this.content.focus();const t=this.Utilities.getSelection(),e=this.ListProvider.getList(t.anchorNode);e?this.ListProvider.increaseIndent(t,e):this.NodeManager.indentBlock(t,!0)};decreaseIndent=()=>{this.content.focus();const t=this.Utilities.getSelection(),e=this.ListProvider.getList(t.anchorNode);e?this.ListProvider.decreaseIndent(t,e):this.NodeManager.indentBlock(t,!1)};openTextColorDialog=()=>{this.lockToolbar=!0,this.content.focus();const t=this.Utilities.getSelection();if(this.savedSelection=this.Utilities.saveSelection(t),t){const e=this.ColorPickers["rich-text-box-text-color-modal"];this.selection=e.openColorPicker(t,this.content)}else this.Utilities.showFadingBar("No content selected.")};selectTextColor=t=>{this.ColorPickers["rich-text-box-text-color-modal"].selectColor(t)};insertTextColor=()=>{this.ColorPickers["rich-text-box-text-color-modal"].insertColor()};removeTextColor=()=>{this.currentColor=null,this.NodeManager.updateNode("textcolor","None"),this.NodeManager.updateNode("textbgcolor","None")};openTextBackgroundColorDialog=()=>{this.lockToolbar=!0,this.content.focus();const t=this.Utilities.getSelection();if(this.savedSelection=this.Utilities.saveSelection(t),null!==t){const e=this.ColorPickers["rich-text-box-text-bg-color-modal"];this.selection=e.openColorPicker(t,this.content)}else this.Utilities.showFadingBar("No content selected.")};selectTextBackgroundColor=t=>{this.ColorPickers["rich-text-box-text-bg-color-modal"].selectColor(t)};insertTextBackgroundColor=()=>{this.ColorPickers["rich-text-box-text-bg-color-modal"].insertColor()};openTableDialog=()=>{this.lockToolbar=!0,this.content.focus();const t=this.Utilities.getSelection();this.savedSelection=this.Utilities.saveSelection(t),null!==t?this.TableDialog.openTableDialog(t):this.Utilities.showFadingBar("No content selected.")};insertTable=()=>{this.TableDialog.insertTable()};font=t=>{this.NodeManager.updateNode("font",t),this.closeDropdown("blazing-rich-text-font-button-dropdown")};size=t=>{this.clearSettings(),this.NodeManager.updateNode("size",t),this.closeDropdown("blazing-rich-text-size-button-dropdown")};bold=()=>{this.NodeManager.updateNode("bold")};italic=()=>{this.NodeManager.updateNode("italic")};underline=()=>{this.NodeManager.updateNode("underline")};strikethrough=()=>{this.NodeManager.updateNode("line-through")};subscript=()=>{this.NodeManager.updateNode("subscript")};superscript=()=>{this.NodeManager.updateNode("superscript")};alignleft=()=>{this.NodeManager.updateNode("alignleft")};aligncenter=()=>{this.NodeManager.updateNode("aligncenter")};alignright=()=>{this.NodeManager.updateNode("alignright")};alignjustify=()=>{this.NodeManager.updateNode("alignjustify")};copy=()=>{this.ActionOptions.copy(),this.NodeManager.refreshUI()};cut=()=>{this.ActionOptions.cut(),this.NodeManager.refreshUI()};paste=()=>{this.NodeManager.allSelected&&this.delete(),this.ActionOptions.paste(),this.NodeManager.refreshUI()};closeDropdown=t=>{this.shadowRoot.getElementById(t).classList.remove("rich-text-box-show"),this.lockToolbar=!1,this.content.focus()};delete=()=>{const t=this.Utilities.getSelection();null!==t&&(t.deleteFromDocument(),this.NodeManager.refreshUI())};selectall=()=>{const t=document.createRange();t.selectNodeContents(this.content),this.content.focus();const e=this.Utilities.getSelection();null!==e&&(e.removeAllRanges(),e.addRange(t),this.content.focus())};orderedlist=()=>{this.ListProvider.addlist("OL"),this.NodeManager.refreshUI()};unorderedlist=()=>{this.ListProvider.addlist("UL"),this.NodeManager.refreshUI()};openLinkDialog=()=>{this.lockToolbar=!0,this.content.focus();const t=this.Utilities.getSelection();this.savedSelection=this.Utilities.saveSelection(t),null!==t?this.LinkDialog.openLinkDialog(t):this.Utilities.showFadingBar("No content selected.")};insertLink=()=>{this.LinkDialog.insertLink(),this.NodeManager.refreshUI()};removeLink=()=>{this.LinkDialog.removeLink()};openBlockQuoteDialog=()=>{this.lockToolbar=!0,this.content.focus();const t=this.Utilities.getSelection();this.savedSelection=this.Utilities.saveSelection(t),null!==t?this.BlockQuoteDialog.openBlockQuoteDialog(t):this.Utilities.showFadingBar("No content selected.")};openBlockQuoteDialogForElement=t=>{if(!t||"BLOCKQUOTE"!==t.nodeName||!this.content.contains(t))return;this.lockToolbar=!0;const e=this.Utilities.getSelection()||window.getSelection(),o=document.createRange();o.selectNodeContents(t),e.removeAllRanges(),e.addRange(o),this.savedSelection=this.Utilities.saveSelection(e),this.BlockQuoteDialog.openBlockQuoteDialogForElement(t,o)};insertBlockQuote=()=>{this.BlockQuoteDialog.insertBlockQuote(),this.NodeManager.refreshUI()};openCodeBlockDialog=()=>{this.lockToolbar=!0,this.content.focus();const t=this.Utilities.getSelection();this.savedSelection=this.Utilities.saveSelection(t),null!==t?this.CodeBlockDialog.openCodeBlockDialog(t):this.Utilities.showFadingBar("No content selected.")};openCodeBlockDialogForElement=t=>{if(!t||"PRE"!==t.nodeName||!this.content.contains(t))return;const e=t.querySelector("code")||t;this.lockToolbar=!0;const o=this.Utilities.getSelection()||window.getSelection(),i=document.createRange();i.selectNodeContents(e),o.removeAllRanges(),o.addRange(i),this.savedSelection=this.Utilities.saveSelection(o),this.CodeBlockDialog.openCodeBlockDialogForElement(t,i)};insertCodeBlock=()=>{this.CodeBlockDialog.insertCodeBlock(),this.NodeManager.refreshUI()};openMediaDialog=()=>{this.lockToolbar=!0;const t=this.Utilities.getSelection();this.savedSelection=this.Utilities.saveSelection(t),null!==t?this.MediaDialog.openMediaDialog(t):this.Utilities.showFadingBar("No content selected.")};insertMedia=()=>{this.MediaDialog.insertMedia(),this.NodeManager.refreshUI()};openVideoDialog=()=>{this.lockToolbar=!0;const t=this.Utilities.getSelection();this.savedSelection=this.Utilities.saveSelection(t),null!==t?this.VideoDialog.openVideoDialog(t):this.Utilities.showFadingBar("No content selected.")};openVideoDialogForElement=t=>{this.lockToolbar=!0;const e=this.Utilities.getSelection(),o=this.Utilities.saveSelection(e);this.savedSelection=o,this.VideoDialog.openVideoDialogForElement(t,o)};insertVideo=()=>{this.VideoDialog.insertVideo(),this.NodeManager.refreshUI()};uploadImageDialog=()=>{this.lockToolbar=!0,this.content.focus();const t=this.Utilities.getSelection();this.savedSelection=this.Utilities.saveSelection(t),null!==t?this.UploadImageDialog.openUploadImageDialog(t):this.Utilities.showFadingBar("No content selected.")};uploadImage=()=>{this.UploadImageDialog.insertUploadedImage()};openImageDialog=()=>{this.lockToolbar=!0,this.content.focus();const t=this.Utilities.getSelection();this.savedSelection=this.Utilities.saveSelection(t),null!==t?this.ImageDialog.openImageDialog(t):this.Utilities.showFadingBar("No content selected.")};insertImage=()=>{this.ImageDialog.insertImage(),this.NodeManager.refreshUI()};closeDialog=t=>{this.lockToolbar=!1,this.Utilities.closeDialog(t,this.savedSelection)};enableButtons=()=>{this.shadowRoot.querySelectorAll(".rich-text-box-dropdown-btn").forEach(t=>t.disabled=!1);this.shadowRoot.querySelectorAll(".rich-text-box-menu-item").forEach(t=>t.disabled=!1)};disableButtons=()=>{this.shadowRoot.querySelectorAll(".rich-text-box-dropdown-btn").forEach(t=>t.disabled=!0);this.shadowRoot.querySelectorAll(".rich-text-box-menu-item").forEach(t=>t.disabled=!0)};toggleView=()=>{!0===this.EditMode?this.getHtml():this.getCode()};getHtml=async()=>{this.htmlSelection=this.StateManager.saveSelection(),this.contentScroll=this.Utilities.saveScroll(this.contentContainer),this.statusBar&&(this._statusBarWasVisible="none"!==this.statusBar.style.display,this.statusBar.style.display="none");const t=this.html();this.loadInnerText(t),this.content.style.display="none",this.source.style.display="block",this.source.focus(),this.Utilities.restoreScroll(this.source,this.sourceScroll),this.disableButtons()};getCode=async()=>{this.sourceScroll=this.Utilities.saveScroll(this.source);const t=this.source.value;this.loadHtml(t),this.content.style.display="block",this.source.style.display="none",this.content.focus(),this.StateManager.restoreSelection(this.htmlSelection),this.Utilities.restoreScroll(this.contentContainer,this.contentScroll),this.enableButtons(),this.statusBar&&this._statusBarWasVisible&&(this.statusBar.style.display="",this.updateWordCount())};html=()=>(this.NodeManager.removeEmptyNodes(),this.content.innerHTML);loadView=t=>{!0===this.EditMode?this.loadHtml(t):this.loadInnerText(t)};loadHtml=t=>{this.EditMode=!0;const e=this.shadowRoot.getElementById("blazing-rich-text-source");e&&(e.classList.remove("selected"),e.setAttribute("aria-pressed","false")),this.content.innerHTML=null!=t?t:"",this.NodeManager.clearButtons(),this.updateWordCount()};loadInnerText=t=>{this.EditMode=!1;const e=this.shadowRoot.getElementById("blazing-rich-text-source");e&&(e.classList.add("selected"),e.setAttribute("aria-pressed","true")),this.source.value=null!=t?t:"",this.NodeManager.clearButtons()};plaintext=()=>this.content.textContent}class e{constructor(t,e,o,i,n){this.content=t,this.source=e,this.Utilities=o,this.dotNetObjectReference=i,this.contentContainer=n,this.history=[],this.currentIndex=-1,this.currentIndex=-1,this.isNavigating=!1,this.mutationObserver()}mutationObserver=()=>{new MutationObserver((t,e)=>{if("block"!==this.content.style.display||this.isNavigating)this.isNavigating=!1,this.updateBinding();else for(let e of t)switch(e.type){case"attributes":case"characterData":case"subtree":case"childList":this.saveState()}}).observe(this.content,{attributes:!0,childList:!0,subtree:!0,characterData:!0})};updateBinding=()=>{"block"===this.content.style.display?this.dotNetObjectReference&&this.dotNetObjectReference.invokeMethodAsync("UpdateValue",this.content.innerHTML):this.dotNetObjectReference&&this.dotNetObjectReference.invokeMethodAsync("UpdateValue",this.source.value)};saveState=()=>{if(this.PreviousHtml===this.content.innerHTML)return;const t={html:this.content.innerHTML,selection:this.saveSelection(),scroll:this.Utilities.saveScroll(this.contentContainer)};this.PreviousHtml=this.content.innerHTML,-1!==this.currentIndex&&t===this.history[this.currentIndex]||(this.history=this.history.slice(0,this.currentIndex+1),this.history.push(t),this.currentIndex++,this.history.length>60&&(this.history.shift(),this.currentIndex--),this.updateBinding())};restoreLastState=()=>{this.currentIndex>0&&(this.isNavigating=!0,this.restoreState(this.history[this.currentIndex]))};goBack=()=>{this.currentIndex>0&&(this.isNavigating=!0,this.currentIndex--,this.restoreState(this.history[this.currentIndex]))};goForward=()=>{this.currentIndex<this.history.length-1&&(this.isNavigating=!0,this.currentIndex++,this.restoreState(this.history[this.currentIndex]))};saveSelection=()=>{const t=this.Utilities.getSelection();if(t&&t.rangeCount>0){const e=t.getRangeAt(0),o=e.cloneRange();o.selectNodeContents(this.content),o.setEnd(e.startContainer,e.startOffset);const i=o.toString().length;return{start:i,end:i+e.toString().length}}return null};restoreSelection=t=>{if(t)try{const charIndex=(t,e)=>{let o=0;if(t.nodeType===Node.TEXT_NODE)return e<=t.length?[t,e]:[null,e-t.length];for(let i=0;i<t.childNodes.length;i++){const n=t.childNodes[i],[r,s]=charIndex(n,e-o);if(r)return[r,s];o+=n.textContent.length}return[null,e-o]},e=document.createRange();let[o,i]=charIndex(this.content,t.start),[n,r]=charIndex(this.content,t.end);if(o&&n){e.setStart(o,i),e.setEnd(n,r);const t=window.getSelection();t.removeAllRanges(),t.addRange(e)}}catch(t){}};restoreState=t=>{this.content.innerHTML=t.html,this.restoreSelection(t.selection),this.Utilities.restoreScroll(this.contentContainer,t.scroll),this.content.focus()}}class o{constructor(t,e,o){this.shadowRoot=t,this.content=e,this.Utilities=o}_press=(t,e=!0)=>{t&&(t.classList.toggle("selected",e),t.setAttribute("aria-pressed",e?"true":"false"))};formatNode=t=>{let e,o;if(e=this.Utilities.getSelection(),null!==e){let i;if(0==e.toString().length)null!=e.anchorNode&&e.anchorNode!=this.content&&null!=e.anchorNode.parentNode&&this.content.contains(e.anchorNode.parentNode)&&(i=this.getElementByType(e.anchorNode.parentNode,"Format"));else if(1==this.hasCommonAncestor(e)){i=e.getRangeAt(0).commonAncestorContainer,this.isCommonAncestor=!0}else i=this.getElementByContent(e.anchorNode,t,e);if(null!=i&&i!=this.content&&null!=i.parentNode&&this.content.contains(i.parentNode)){if("none"==t){let t=this.Utilities.saveCaretPosition();const e=document.createElement("div");for(let t=0;t<i.style.length;t++){const o=i.style[t];e.style[o]=i.style[o]}for(;i.firstChild;)e.appendChild(i.firstChild);i.parentNode.replaceChild(e,i),this.Utilities.restoreCaretPosition(e,t)}else{let e=this.Utilities.saveCaretPosition();const o=document.createElement(t);o.innerHTML=i.innerHTML;const n=window.getComputedStyle(i);for(let t=0;t<n.length;t++){let e=n[t],r=i.style.getPropertyValue(e);""!==r&&(o.style[e]=r)}i.parentNode.replaceChild(o,i),this.Utilities.restoreCaretPosition(o,e)}return}if(e.toString().length>0){let i;switch(t){case"p":i=document.createElement("p");break;case"h1":i=document.createElement("h1");break;case"h2":i=document.createElement("h2");break;case"h3":i=document.createElement("h3");break;case"h4":i=document.createElement("h4");break;case"h5":i=document.createElement("h5")}null!=i&&e.rangeCount>0&&(o=e.getRangeAt(0),this.hasInvalidElementsInSelection(e)||(i.appendChild(o.cloneContents()),o.deleteContents(),o.insertNode(i),o.selectNodeContents(i),e.removeAllRanges(),e.addRange(o)))}}};updateNode=(t,e,o)=>{let i,n;if(i=this.Utilities.getSelection(),i||o){let r;if(i&&o?(i.removeAllRanges(),i.addRange(o)):o&&(i=window.getSelection(),i.removeAllRanges(),i.addRange(o)),this.isCommonAncestor=!1,0==i.toString().length){if(r=this.getElementByStyle(i.anchorNode,t),null==r&&null!=i.anchorNode&&i.anchorNode!=this.content&&this.content.contains(i.anchorNode)&&i.anchorNode.querySelector){null!=i.anchorNode.querySelector("img")&&(r=i.anchorNode);null!=i.anchorNode.querySelector("embed")&&(r=i.anchorNode);null!=i.anchorNode.querySelector("object")&&(r=i.anchorNode);const t=i.anchorNode.querySelector("table");null!=t&&(r=t)}null==r&&null!=i.anchorNode&&i.anchorNode!=this.content&&null!=i.anchorNode.parentNode&&i.anchorNode.parentNode!=this.content&&this.content.contains(i.anchorNode.parentNode)&&(r=i.anchorNode.parentNode)}else if(1==this.hasCommonAncestor(i)){r=i.getRangeAt(0).commonAncestorContainer,this.isCommonAncestor=!0}else r=this.getElementByContent(i.anchorNode,t,i);if(null!=r){let o;switch(t){case"textcolor":"None"==e?(o=this.getElementByStyle(r,t),null!=o&&this.removeProperty(o,"color",o.style.getPropertyValue("color"))):r.style.setProperty("color",e);break;case"textbgcolor":"None"==e?(o=this.getElementByStyle(r,t),null!=o&&this.removeProperty(o,"background-color",o.style.getPropertyValue("background-color"))):r.style.setProperty("background-color",e);break;case"font":"None"==e?this.removeProperty(r,"font-family",e):r.style.setProperty("font-family",e);break;case"size":"None"==e?this.removeProperty(r,"font-size"):r.style.setProperty("font-size",e);break;case"bold":"bold"==r.style.fontWeight?this.removeProperty(r,"font-weight","bold"):r.style.setProperty("font-weight","bold");break;case"italic":"italic"==r.style.fontStyle?this.removeProperty(r,"font-style","italic"):r.style.setProperty("font-style","italic");break;case"underline":r.style.textDecoration.includes("underline")?this.removeTextDecoration(r,"underline"):this.addTextDecoration(r,"underline");break;case"line-through":r.style.textDecoration.includes("line-through")?this.removeTextDecoration(r,"line-through"):this.addTextDecoration(r,"line-through");break;case"subscript":"sub"==r.style.verticalAlign?this.removeProperty(r,"vertical-align","sub"):r.style.setProperty("vertical-align","sub");break;case"superscript":"super"==r.style.verticalAlign?this.removeProperty(r,"vertical-align","super"):r.style.setProperty("vertical-align","super");break;case"alignleft":"TABLE"===r.nodeName?this.alignTable(r,"alignleft"):"left"==r.style.textAlign?this.removeProperty(r,"text-align","left"):r.style.setProperty("text-align","left");break;case"aligncenter":"TABLE"===r.nodeName?this.alignTable(r,"aligncenter"):"center"==r.style.textAlign?this.removeProperty(r,"text-align","center"):r.style.setProperty("text-align","center");break;case"alignright":"TABLE"===r.nodeName?this.alignTable(r,"alignright"):"right"==r.style.textAlign?this.removeProperty(r,"text-align","right"):r.style.setProperty("text-align","right");break;case"alignjustify":"TABLE"===r.nodeName?this.alignTable(r,"alignjustify"):"justify"==r.style.textAlign?this.removeProperty(r,"text-align","justify"):r.style.setProperty("text-align","justify")}return this.selection=null,void this.refreshUI()}if(i.toString().length>0&&"None"!=e&&!this.isExcluded(i)){let o;switch(t){case"textcolor":o=this.createElement(i),o.style.color=e;break;case"textbgcolor":o=this.createElement(i),o.style.backgroundColor=e;break;case"font":o=this.createElement(i),o.style.fontFamily=e;break;case"size":o=this.createElement(i),o.style.fontSize=e;break;case"bold":o=this.createElement(i),o.style.fontWeight="bold";break;case"italic":o=this.createElement(i),o.style.fontStyle="italic";break;case"underline":o=this.createElement(i),this.addTextDecoration(o,"underline");break;case"line-through":o=this.createElement(i),this.addTextDecoration(o,"line-through");break;case"subscript":o=this.createElement(i),o.style.verticalAlign="sub";break;case"superscript":o=this.createElement(i),o.style.verticalAlign="super";break;case"alignleft":o=document.createElement("div"),o.style.textAlign="left";break;case"aligncenter":o=document.createElement("div"),o.style.textAlign="center";break;case"alignright":o=document.createElement("div"),o.style.textAlign="right";break;case"alignjustify":o=document.createElement("div"),o.style.textAlign="justify"}null!=o&&0!=i.rangeCount&&(n=i.getRangeAt(0),o.appendChild(n.cloneContents()),n.deleteContents(),n.insertNode(o),n.selectNodeContents(o),i.removeAllRanges(),i.addRange(n),this.selection=null,this.refreshUI())}}};alignTable=(t,e)=>{"alignleft"!==e&&"alignjustify"!==e||("auto"==t.style.margin&&this.removeProperty(t,"margin","auto"),"auto"==t.style.marginLeft&&this.removeProperty(t,"margin-left","auto")),"aligncenter"===e&&(t.style.margin&&"auto"===t.style.margin?this.removeProperty(t,"margin","auto"):t.style.setProperty("margin","auto")),"alignright"===e&&("auto"==t.style.margin&&this.removeProperty(t,"margin","auto"),"auto"==t.style.marginLeft?this.removeProperty(t,"margin-left","auto"):t.style.setProperty("margin-left","auto"))};isExcluded=t=>{if(t.anchorNode&&t.anchorNode.querySelector){const e=t.anchorNode.querySelector("table");if(null!=e&&t.toString().trim()!==e.innerText.trim())return!0}if(t.anchorNode.parentNode!==this.content)switch(t.anchorNode.parentNode.nodeName){case"TD":case"CODE":case"PRE":return!0}return!1};indentBlock=(t,e)=>{let o=t.anchorNode;for(;o&&!this.applyMargin(o,e);)o=o.parentNode};applyMargin=(t,e)=>{if(t.nodeType===Node.ELEMENT_NODE&&["P","DIV","H1","H2","H3","H4","H5","H6","OL","UL","SECTION","ARTICLE","HEADER","FOOTER"].includes(t.nodeName)){const o=window.getComputedStyle(t).marginLeft,i=parseFloat(o)||0,n=40;return e?t.style.marginLeft=`${i+n}px`:i<=n?(t.style.marginLeft="",t.hasAttribute("style")&&(t.getAttribute("style")||t.removeAttribute("style"))):t.style.marginLeft=i-n+"px",!0}return!1};selectButtons=t=>{if(null==t||t==this.content||!this.content.contains(t)||1==this.lockToolbar)return;this.clearButtons();const e=this.getButton("blazing-rich-text-bold-button"),o=this.getButton("blazing-rich-text-italic-button"),i=this.getButton("blazing-rich-text-underline-button"),n=this.getButton("blazing-rich-text-strike-button"),r=this.getButton("blazing-rich-text-sub-button"),s=this.getButton("blazing-rich-text-super-button"),l=this.getButton("blazing-rich-text-alignleft-button"),a=this.getButton("blazing-rich-text-aligncenter-button"),c=this.getButton("blazing-rich-text-alignright-button"),d=this.getButton("blazing-rich-text-alignjustify-button");this.textAlign=!1;const h=this.getButton("blazing-rich-text-orderedlist-button"),b=this.getButton("blazing-rich-text-unorderedlist-button"),u=this.getButton("blazing-rich-text-link-button"),g=this.getButton("blazing-rich-text-remove-link-button"),m=this.getButton("blazing-rich-text-textcolor-button"),x=this.getButton("blazing-rich-text-text-bg-color-button"),p=this.getButton("blazing-rich-text-textcolor-remove-button"),v=this.getButton("blazing-rich-text-quote-button"),f=this.getButton("blazing-rich-text-code-block-button"),y=this.getButton("blazing-rich-text-table-button"),w=this.getButton("blazing-rich-text-image-button"),C=this.getButton("blazing-rich-text-image-upload-button"),N=this.getButton("blazing-rich-text-embed-button"),k=this.getButton("blazing-rich-text-video-button"),S=this.shadowRoot.getElementById("blazing-rich-text-format-button");null!=S&&(S.innerText="Format",this.formatSelected=!1);const E=this.shadowRoot.getElementById("blazing-rich-text-font-button");null!=E&&(E.innerText="Font",this.fontSelected=!1);const R=this.shadowRoot.getElementById("blazing-rich-text-size-button");for(null!=R&&(R.innerText="Size",this.fontSizeSelected=!1);t!==this.content&&null!==t.parentNode&&this.content.contains(t.parentNode)&&"#text"!=t.parentNode.nodeName&&"#document"!=t.parentNode.nodeName;){let T=window.getComputedStyle(t.parentNode);if(null!=t.parentNode.style&&"bold"==t.parentNode.style.fontWeight&&this._press(e),null!=t.parentNode.style&&t.parentNode.style.color&&this._press(m),null!=t.parentNode.style&&t.parentNode.style.backgroundColor&&this._press(x),(null!=t.parentNode.style&&t.parentNode.style.color||t.parentNode.style.backgroundColor)&&this._press(p),"italic"==T.getPropertyValue("font-style")&&this._press(o),T.getPropertyValue("text-decoration").includes("underline")&&"A"!=t.parentNode.nodeName&&this._press(i),T.getPropertyValue("text-decoration").includes("line-through")&&this._press(n),"sub"==T.getPropertyValue("vertical-align")&&this._press(r),"super"==T.getPropertyValue("vertical-align")&&this._press(s),"left"!=T.getPropertyValue("text-align")||this.textAlign||(this._press(l),this.textAlign=!0),"center"!=T.getPropertyValue("text-align")||this.textAlign||(this._press(a),this.textAlign=!0),"right"!=T.getPropertyValue("text-align")||this.textAlign||(this._press(c),this.textAlign=!0),"justify"!=T.getPropertyValue("text-align")||this.textAlign||(this._press(d),this.textAlign=!0),null!=t&&null!=t.style&&t.style.fontFamily&&!this.fontSelected&&(E.innerText=t.style.fontFamily.replace(/^"(.*)"$/,"$1"),this.fontSelected=!0),null!=t&&null!=t.style&&t.style.fontSize&&!this.fontSizeSelected&&(R.innerText=t.style.fontSize,this.fontSizeSelected=!0),"P"!=t.parentNode.nodeName||this.formatSelected||(S.innerText="Paragraph",this.formatSelected=!0),"H1"!=t.parentNode.nodeName||this.formatSelected||(S.innerText="Header 1",this.formatSelected=!0),"H2"!=t.parentNode.nodeName||this.formatSelected||(S.innerText="Header 2",this.formatSelected=!0),"H3"!=t.parentNode.nodeName||this.formatSelected||(S.innerText="Header 3",this.formatSelected=!0),"H4"!=t.parentNode.nodeName||this.formatSelected||(S.innerText="Header 4",this.formatSelected=!0),"H5"!=t.parentNode.nodeName||this.formatSelected||(S.innerText="Header 5",this.formatSelected=!0),"A"==t.parentNode.nodeName&&(this._press(u),this._press(g)),"BLOCKQUOTE"==t.parentNode.nodeName&&this._press(v),"CODE"==t.parentNode.nodeName&&this._press(f),"TD"==t.parentNode.nodeName&&this._press(y),"OL"==t.parentNode.nodeName&&this._press(h),"UL"==t.parentNode.nodeName&&this._press(b),"VIDEO"!==t.nodeName&&"SOURCE"!==t.nodeName||k&&this._press(k),t.querySelector){const e=t.querySelector("img");e&&(e.src.startsWith("data")?this._press(C):this._press(w));t.querySelector("object")&&this._press(N);t.querySelector("video")&&k&&this._press(k)}t=t.parentNode}this.closeDropdowns()};closeDropdowns=()=>{this.shadowRoot.querySelectorAll(".rich-text-box-dropdown-content").forEach(function(t){t.classList.contains("rich-text-box-show")&&t.classList.remove("rich-text-box-show")})};getButton=t=>this.shadowRoot.getElementById(t);refreshUI=()=>{const t=this.Utilities.getSelection();null!==t&&this.selectButtons(t.anchorNode),this.removeEmptyNodes(),this.content.focus()};removeEmptyNodes=()=>{const t=this.content;if(t){t.querySelectorAll("*").forEach(t=>{t.hasChildNodes()&&(1!==t.childNodes.length||3!==t.childNodes[0].nodeType||/\S/.test(t.textContent))||t.parentElement&&!this.isNotRemovable(t.nodeName)&&t.parentElement.removeChild(t)})}};createDefaultElement=()=>{if(""===this.content.innerHTML.trim()){const t=document.createElement("div"),e=document.createElement("br");t.appendChild(e),this.content.appendChild(t)}};allSelected=()=>{const t=this.Utilities.getSelection();if(null!==t){if(0===t.rangeCount)return!1;const e=t.getRangeAt(0),o=document.createRange();return o.selectNodeContents(this.content),e.startContainer===o.startContainer&&e.startOffset===o.startOffset&&e.endContainer===o.endContainer&&e.endOffset===o.endOffset}return!1};clearButtons=()=>{this.closeDropdowns();this.shadowRoot.querySelectorAll(".rich-text-box-menu-item, .rich-text-box-menu-item-special").forEach(function(t){t.classList.remove("selected"),t.setAttribute("aria-pressed","false")});const t=this.shadowRoot.getElementById("blazing-rich-text-format-button");null!=t&&(t.innerText="Format",this.formatSelected=!1);const e=this.shadowRoot.getElementById("blazing-rich-text-font-button");null!=e&&(e.innerText="Font",this.fontSelected=!1);const o=this.shadowRoot.getElementById("blazing-rich-text-size-button");null!=o&&(o.innerText="Size",this.fontSizeSelected=!1)};isNotRemovable=t=>{switch(t.toLowerCase()){case"td":case"img":case"i":case"br":case"area":case"base":case"col":case"embed":case"object":case"video":case"source":case"hr":case"input":case"link":case"meta":case"param":case"source":case"track":case"wbr":case"keygen":return!0}return!1};hasCommonAncestor(t){if(!t.rangeCount)return!1;const e=t.getRangeAt(0),o=e.cloneContents(),i=document.createElement("div");i.appendChild(o);const n=e.commonAncestorContainer;return n!==this.content&&this.content.contains(n)&&i.innerHTML==e.commonAncestorContainer.innerHTML&&n.nodeType!==Node.TEXT_NODE?(i.remove(),!0):(i.remove(),!1)}createElement=t=>this.hasInvalidElementsInSelection(t)?document.createElement("div"):document.createElement("span");hasInvalidElementsInSelection=t=>{if(t){const e=["address","article","aside","blockquote","details","dialog","div","dl","fieldset","figcaption","figure","footer","form","header","hgroup","hr","main","menu","nav","ol","p","pre","section","table","ul","button","input","textarea","select","form","h1","h2","h3","h4","h5","h6"],o=t.getRangeAt(0).cloneContents().querySelectorAll("*");for(let t=0;t<o.length;t++){const i=o[t];if(e.includes(i.tagName.toLowerCase()))return!0}}return!1};removeProperty=(t,e,o)=>{null!=t&&t!=this.content&&this.content.contains(t)&&(this.getUserDefinedStyleCount(t)>1?t.style.removeProperty(e,o):"SPAN"==t.nodeName?0==t.childElementCount?t.replaceWith(t.textContent):(t.insertAdjacentHTML("afterend",t.innerHTML),t.remove()):"DIV"==t.nodeName&&!0===this.isCommonAncestor?(t.insertAdjacentHTML("afterend",t.innerHTML),t.remove()):t.hasAttribute("style")&&t.removeAttribute("style"))};addTextDecoration=(t,e)=>{if(null==t||t==this.content||t==this.content.parentNode)return;const o=t.style.textDecoration;if(null!=o&&!o.includes(e)){const i=o?o+" "+e:e;t.style.textDecoration=i}};removeTextDecoration=(t,e)=>{if(null!=t&&t!=this.content&&this.content.contains(t))if(this.getUserDefinedStyleCount(t)>1){const o=t.style.textDecoration.split(" ").filter(t=>t!==e);t.style.textDecoration=o.join(" ")}else"SPAN"==t.nodeName&0==t.childElementCount?t.replaceWith(t.textContent):"SPAN"==t.nodeName?(t.insertAdjacentHTML("afterend",t.innerHTML),t.remove()):t.hasAttribute("style")&&t.removeAttribute("style")};getUserDefinedStyles=t=>{if(null==t||t==this.content||!this.content.contains(t))return;let e={};for(let o=0;o<t.style.length;o++){let i=t.style[o],n=t.style.getPropertyValue(i);e[i]=n}return e};getUserDefinedStyleCount=t=>{if(null==t||t==this.content||!this.content.contains(t))return;let e=0;for(let o=0;o<t.style.length;o++){let i=t.style[o],n=t.style.getPropertyValue(i);if(this.isFormatElement(t)){if("initial"!=n){let t=n.split(" ");if(!this.isMultiValueProperty(i)&&t.length>1)for(let o=0;o<t.length;o++)e++;else e++}}else e++}return e};isMultiValueProperty=t=>{switch(t){case"background-color":case"color":case"font-family":return!0}return!1};getElementByType=(t,e)=>{if(null!=t&&t!=this.content&&this.content.contains(t)){for(;t;){if(t===this.content||!this.content.contains(t))return;if("#text"!=t.nodeName&&"#document"!=t.nodeName)switch(e){case"Format":if(this.isFormatElement(t))return t;break;case"UL":case"OL":case"Element":if(t.nodeName===e)return t}t=t.parentNode}return null}};getElementByContent=(t,e,o)=>{if(null!=t&&t!=this.content&&this.content.contains(t))for(;t;){if(t===this.content||!this.content.contains(t))return;if("#text"!=t.nodeName&&"#document"!=t.nodeName){const i=this.getElementByStyle(t,e);if(null!=i&&this.selectionContainsNode(o,i))return i;if("LI"===t.nodeName)return t.parentNode;if(null!==o&&o.toString().trim()==t.textContent.trim())return t}t=t.parentNode}};selectionContainsNode(t,e){if(null==e||e==this.content||!this.content.contains(e))return!1;if(t.rangeCount>0)for(let o=0;o<t.rangeCount;o++){let i=t.getRangeAt(o);if(this.isNodeInRange(e,i))return!0}return!1}isNodeInRange(t,e){if(null==t||t==this.content||!this.content.contains(t))return!1;let o=t.ownerDocument.createRange();return o.selectNode(t),e.compareBoundaryPoints(Range.START_TO_END,o)<=0&&e.compareBoundaryPoints(Range.END_TO_START,o)>=0}getElementByStyle=(t,e)=>{if(null!=t&&t!=this.content&&this.content.contains(t)){for(;t;){if(t===this.content||!this.content.contains(t))return;if(null!=t.style){let o=null;switch(e){case"textcolor":if(o=t.getAttribute("style"),null!=o&&o.includes("color:"))return t;break;case"textbgcolor":if(o=t.getAttribute("style"),null!=o&&o.includes("background-color:"))return t;break;case"font":if(o=t.getAttribute("style"),null!=o&&o.includes("font-family:"))return t;break;case"size":if(o=t.getAttribute("style"),null!=o&&o.includes("font-size:"))return t;break;case"bold":if(o=t.getAttribute("style"),null!=o&&o.includes("font-weight:")&&"bold"==t.style.fontWeight)return t;break;case"italic":if(o=t.getAttribute("style"),null!=o&&o.includes("font-style:")&&"italic"==t.style.fontStyle)return t;break;case"underline":if(o=t.getAttribute("style"),null!=o&&o.includes("text-decoration:")&&t.style.textDecoration.includes("underline"))return t;break;case"line-through":if(o=t.getAttribute("style"),null!=o&&o.includes("text-decoration:")&&t.style.textDecoration.includes("line-through"))return t;break;case"subscript":if(o=t.getAttribute("style"),null!=o&&o.includes("vertical-align:")&&"sub"==t.style.verticalAlign)return t;break;case"superscript":if(o=t.getAttribute("style"),null!=o&&o.includes("vertical-align:")&&"superscript"==t.style.verticalAlign)return t;break;case"alignleft":if(o=t.getAttribute("style"),null!=o&&o.includes("text-align:")&&"left"==t.style.textAlign)return t;break;case"aligncenter":if(o=t.getAttribute("style"),null!=o&&o.includes("text-align:")&&"center"==t.style.textAlign)return t;break;case"alignright":if(o=t.getAttribute("style"),null!=o&&o.includes("text-align:")&&"right"==t.style.textAlign)return t;break;case"alignjustify":if(o=t.getAttribute("style"),null!=o&&o.includes("text-align:")&&"justify"==t.style.textAlign)return t}}t=t.parentNode}return null}};isFormatElement=t=>!(null==t||t==this.content||!this.content.contains(t))&&("P"==t.nodeName||"H1"==t.nodeName||"H2"==t.nodeName||"H3"==t.nodeName||"H4"==t.nodeName||"H5"==t.nodeName||(null!=t.style&&null!=t.style.textDecoration||void 0));insertLineBreak=t=>{const e=document.createElement("div"),o=document.createElement("br");if(e.appendChild(o),"CODE"==t.nodeName){const o=t.parentNode.parentNode;o.nextSibling?o.parentNode.insertBefore(e,o.nextSibling):o.parentNode.appendChild(e)}else t.parentNode.insertBefore(e,t.nextSibling);const i=document.createRange();i.setStartBefore(o),i.collapse(!0);const n=this.Utilities.getSelection();null!==n&&(n.removeAllRanges(),n.addRange(i))}}class i{constructor(t,e,o,i){this.shadowRoot=t,this.content=e,this.Utilities=o,this.NodeManager=i}addlist=t=>{const e=this.Utilities.getSelection();if(null!==e){if("UL"==t){const t=this.NodeManager.getElementByType(e.anchorNode,"OL");if(null!=t)return void this.replaceList(t,"UL")}else{const t=this.NodeManager.getElementByType(e.anchorNode,"UL");if(null!=t)return void this.replaceList(t,"OL")}const o=this.NodeManager.getElementByType(e.anchorNode,t);if(null!=o)this.removelist(o);else{if(0===e.toString().trim().length){const o=e.getRangeAt(0);let i;const n=document.createElement(t);if(e.anchorNode.parentNode!==this.content&&(i=e.anchorNode.parentNode),e.anchorNode!==this.content&&(i=e.anchorNode),i.nodeType===Node.ELEMENT_NODE||i.nodeType===Node.TEXT_NODE){let t=document.createElement("li"),e=i.cloneNode(!0);this.appendListItemContent(t,e),n.appendChild(t),i.remove()}o.deleteContents(),o.insertNode(n);const r=document.createRange();r.selectNodeContents(n),r.collapse(!1);const s=window.getSelection();s.removeAllRanges(),s.addRange(r)}else{const o=document.createElement(t);if(e.rangeCount>0){const t=e.getRangeAt(0),i=t.cloneContents().childNodes;Array.from(i).forEach(t=>{if(t.nodeType===Node.ELEMENT_NODE||t.nodeType===Node.TEXT_NODE){let e=document.createElement("li"),i=t.cloneNode(!0);this.appendListItemContent(e,i),o.appendChild(e),t.remove()}}),t.deleteContents(),t.insertNode(o),t.selectNodeContents(o),e.removeAllRanges(),e.addRange(t)}}}}};appendListItemContent=(t,e)=>{if(t&&e)if(this.isParagraphChild(e))for(;e.firstChild;)t.appendChild(e.firstChild);else t.appendChild(e)};replaceList=(t,e)=>{if(null===t||t===this.content||!this.content.contains(t))return;const o=this.Utilities.getSelection();let i,n,r,s,l;null!==o&&o.rangeCount>0&&(i=o.getRangeAt(0),n=i.startContainer,r=i.startOffset,s=i.endContainer,l=i.endOffset);const a=document.createElement(e);for(;t.firstChild;)a.appendChild(t.firstChild);if(t.parentNode.replaceChild(a,t),i){const e=document.createRange();t.contains(n)?e.setStart(a,r):e.setStart(n,r),t.contains(s)?e.setEnd(a,l):e.setEnd(s,l),o.removeAllRanges(),o.addRange(e)}};removelist=t=>{if(null==t||t==this.content||!this.content.contains(t))return;if("OL"===t.nodeName||"UL"===t.nodeName)return void this.removeListAsParagraphs(t);let e=null;for(;t.firstChild;){const o=t.firstChild;if("UL"===o.nodeName||"OL"===o.nodeName)e||(e=o),t.parentNode.insertBefore(o,t);else{for(;o.firstChild;){const i=o.firstChild;e||(e=i),t.parentNode.insertBefore(i,t)}t.removeChild(o)}}if(t.parentNode.removeChild(t),e){const t=this.Utilities.getSelection();if(null!==t){const o=document.createRange();o.setStart(e,0),o.collapse(!0),t.removeAllRanges(),t.addRange(o)}}};removeListAsParagraphs=t=>{let e=null;for(;t.firstChild;){const o=t.firstChild;if("LI"!==o.nodeName){e||(e=o),t.parentNode.insertBefore(o,t);continue}const i=document.createElement("p");for(;o.firstChild;){const t=o.firstChild;if("UL"===t.nodeName||"OL"===t.nodeName)break;if(this.isParagraphChild(t)){for(;t.firstChild;)i.appendChild(t.firstChild);o.removeChild(t)}else i.appendChild(t)}for(i.hasChildNodes()||i.appendChild(document.createElement("br")),e||(e=i),t.parentNode.insertBefore(i,t);o.firstChild;)t.parentNode.insertBefore(o.firstChild,t);t.removeChild(o)}if(t.parentNode.removeChild(t),e){const t=this.Utilities.getSelection();if(null!==t){const o=document.createRange();o.setStart(e,0),o.collapse(!0),t.removeAllRanges(),t.addRange(o)}}};isParagraphChild=t=>!(!t||t.nodeType!==Node.ELEMENT_NODE)&&["P","DIV"].includes(t.nodeName);increaseIndent=(t,e)=>{if(!t||!e||"UL"!==e.nodeName&&"OL"!==e.nodeName)return;let o=this.getSelectedNodes(t,e);if(!o||0===o.length)return;let i=o[0].previousElementSibling;if(!i||"LI"!==i.nodeName)return;let n=Array.from(i.children).find(t=>t.nodeName===e.nodeName);n||(n=document.createElement(e.nodeName),i.appendChild(n)),o.forEach(t=>{"LI"===t.nodeName&&n.appendChild(t)}),this.selectListItemStart(t,o[0])};decreaseIndent=(t,e)=>{if(!t||!e||"UL"!==e.nodeName&&"OL"!==e.nodeName)return;const o=this.getSelectedNodes(t,e);if(!o||0===o.length)return;const i=e.parentElement,n=i?i.parentElement:null;if(!i||"LI"!==i.nodeName||!n||"UL"!==n.nodeName&&"OL"!==n.nodeName)return;const r=o[o.length-1],s=document.createElement(e.nodeName);for(;r.nextElementSibling;)s.appendChild(r.nextElementSibling);const l=document.createDocumentFragment();o.forEach(t=>{"LI"===t.nodeName&&l.appendChild(t)}),n.insertBefore(l,i.nextSibling),s.children.length>0&&r.appendChild(s),0===e.children.length&&e.remove(),this.selectListItemStart(t,o[0])};getSelectedNodes=(t,e)=>{const o=[];if(!t.rangeCount)return null;const i=t.getRangeAt(0);if(null!==e){const t=e.children;for(let e=0;e<t.length;e++){const n=t[e];i.intersectsNode(n)&&o.push(n)}return o}return null};saveListSelection=t=>t&&0!==t.rangeCount?t.getRangeAt(0).cloneRange():null;restoreListSelection=(t,e,o)=>{if(t&&e&&this.content.contains(e.startContainer)&&this.content.contains(e.endContainer))return t.removeAllRanges(),void t.addRange(e);this.selectListItem(t,o)};selectListItemStart=(t,e)=>{if(!t||!e)return;const o=document.createRange();o.setStart(e,0),o.collapse(!0),t.removeAllRanges(),t.addRange(o)};selectListItem=(t,e)=>{if(!t||!e)return;const o=document.createRange(),i=this.getFirstTextNode(e);i?o.setStart(i,i.textContent.length):(o.selectNodeContents(e),o.collapse(!1)),o.collapse(!0),t.removeAllRanges(),t.addRange(o)};getFirstTextNode=t=>{if(!t)return null;if(t.nodeType===Node.TEXT_NODE)return t;for(let e=0;e<t.childNodes.length;e++){const o=t.childNodes[e];if("UL"===o.nodeName||"OL"===o.nodeName)continue;const i=this.getFirstTextNode(o);if(i)return i}return null};getList=t=>{for(;t;){if(t===this.content||!this.content.contains(t))return;if("#text"!=t.nodeName&&"#document"!=t.nodeName)switch(t.nodeName){case"OL":case"UL":return t}t=t.parentNode}return null}}class n{constructor(t,e,o){this.shadowRoot=t,this.content=e,this.Utilities=o}copy=()=>{const t=this.Utilities.getSelection();null!==t&&null!==t&&navigator&&navigator.clipboard&&navigator.clipboard.writeText&&navigator.clipboard.writeText(t)};cut=()=>{const t=this.Utilities.getSelection();null!==t&&null!==t&&navigator&&navigator.clipboard&&navigator.clipboard.writeText&&(navigator.clipboard.writeText(t),t.deleteFromDocument())};paste=()=>{navigator.clipboard.readText().then(t=>{this.checkParagraphs(t.trim())||this.checkTables(t.trim())||this.checkLines(t.trim())||this.checkText(t.trim())}).catch(t=>{console.error("Failed to read clipboard contents: ",t)})};checkParagraphs=t=>{let e=t.split(/\n\s*\n/);if(e.length>1){const t=this.Utilities.getSelection();if(null!==t){if(!t.rangeCount)return!1;const o=t.getRangeAt(0);o.deleteContents();let i=document.createDocumentFragment();return e.forEach(t=>{let e=this.checkParagraphTable(t,i);if(e||(e=this.checkParagraphLines(t,i)),!e){let e=document.createElement("p");e.textContent=t.trim(),i.appendChild(e)}}),o.insertNode(i),o.collapse(!0),t.removeAllRanges(),t.addRange(o),!0}}return!1};checkParagraphLines=(t,e)=>{let o=0,i=t.trim().split(/\n+/);return i.length>1&&(i.forEach(t=>{if(o++,o===i.length){let o=document.createElement("p");o.textContent=t.trim(),e.appendChild(o)}else{let o=document.createElement("div");o.textContent=t.trim(),e.appendChild(o)}}),!0)};checkParagraphTable=(t,e)=>{if(this.isTable(t)){let o=this.buildTable(t);return e.appendChild(o),!0}return!1};checkLines=t=>{let e=t.trim().split(/\n+/);if(e.length>1){const t=this.Utilities.getSelection();if(null!==t){if(!t.rangeCount)return!1;const o=t.getRangeAt(0);o.deleteContents();let i=document.createDocumentFragment();return e.forEach(t=>{let e=document.createElement("div");e.textContent=t.trim(),i.appendChild(e)}),o.insertNode(i),o.collapse(!0),t.removeAllRanges(),t.addRange(o),!0}}};checkTables=t=>{if(this.isTable(t)){const e=this.Utilities.getSelection();if(null!==e){if(!e.rangeCount)return!1;const o=e.getRangeAt(0);o.deleteContents();let i=document.createDocumentFragment(),n=this.buildTable(t);return i.appendChild(n),o.insertNode(i),o.collapse(!0),e.removeAllRanges(),e.addRange(o),!0}}};buildTable=t=>{let e=document.createElement("table"),o=t.split("\n"),i=document.createElement("tbody");return o.forEach((t,e)=>{if(t.trim().length>0){let e=t.split("\t"),o=document.createElement("tr");e.forEach(t=>{let e=document.createElement("td");t.trim().length>0&&(e.textContent=t),o.appendChild(e)}),i.appendChild(o)}}),e.appendChild(i),e};isTable=t=>{if(t.includes("\t")){let e=t.split("\n");if(e.length>1&&e[1].trim().length>0){let t=(e[1].match(/\t/g)||[]).length;if(0===t)return!1;for(let o=1;o<e.length;o++){let i=e[o];if(i.trim().length>0){if((i.match(/\t/g)||[]).length!==t)return!1}}return!0}}return!1};checkText=t=>{const e=this.Utilities.getSelection();if(null!==e){if(!e.rangeCount)return!1;const o=e.getRangeAt(0);if(o.deleteContents(),""===this.content.innerHTML.trim()){const e=document.createElement("div"),i=document.createTextNode(t);e.appendChild(i),o.insertNode(e),o.setStartAfter(e),o.setEndAfter(e)}else{const e=document.createTextNode(t);o.insertNode(e),o.setStartAfter(e),o.setEndAfter(e)}e.removeAllRanges(),e.addRange(o)}}}class r{constructor(t,e){this.shadowRoot=t,this.content=e}closeDialog=(t,e)=>{const o=this.shadowRoot.getElementById(t);null!=o&&o.close(),e&&this.restoreSelection(window.getSelection(),e),this.content.focus()};addClasses=(t,e)=>{if(null!=t&&null!=e)if(e.classList.remove(...e.classList),t.length>0){t.split(" ").map(t=>t.trim()).forEach(t=>{t&&e.classList.add(t)})}else e.hasAttribute("class")&&e.removeAttribute("class")};getSelection=()=>{const t=this.shadowRoot.getSelection();return this.content.contains(t.anchorNode)&&this.content.contains(t.focusNode)?t:null};showFadingBar=t=>{const e=this.shadowRoot.getElementById("rich-text-box-message-bar"),o=e.querySelector(".rich-text-box-message");e&&o&&(o.textContent=t,e.classList.remove("rich-text-box-message-hidden"),setTimeout(()=>{this.closeFadingBar()},2e3))};closeFadingBar=()=>{this.shadowRoot.getElementById("rich-text-box-message-bar").classList.add("rich-text-box-message-hidden")};saveSelection=t=>t&&t.rangeCount>0?t.getRangeAt(0).cloneRange():null;restoreSelection=(t,e)=>{t&&e&&(t.removeAllRanges(),t.addRange(e)),this.content.focus()};reselectNode=t=>{const e=document.createRange(),o=window.getSelection();t.childNodes.length>0?e.setStartAfter(t.childNodes[t.childNodes.length-1]):e.setStartAfter(t),e.collapse(!0),o.removeAllRanges(),o.addRange(e)};saveCaretPosition=()=>{const t=this.getSelection();if(null!==t){return{startOffset:t.getRangeAt(0).startOffset,endOffset:t.getRangeAt(0).endOffset}}return null};restoreCaretPosition=(t,e)=>{const o=this.getSelection();if(null!==o&&null!==e){let i=document.createRange();i.setStart(t.firstChild,e.startOffset),i.setEnd(t.firstChild,e.endOffset),o.removeAllRanges(),o.addRange(i)}};saveScroll=t=>t.scrollTop;restoreScroll=(t,e)=>{t.scrollTop=e}}class s{constructor(t,e,o){this.shadowRoot=t,this.content=e,this.Utilities=o,this.addEventListeners()}addEventListeners=()=>{this.dialog=this.shadowRoot.getElementById("rich-text-box-table-modal"),this.dialog.addEventListener("keydown",t=>{"Enter"===t.key&&(t.preventDefault(),this.insertTable()),"Escape"===t.key&&(t.preventDefault(),this.closeDialog())})};openTableDialog=t=>{if(this.resetTableDialog(),this.savedSelection=this.Utilities.saveSelection(t),null!=t.anchorNode&&t.anchorNode!=this.content&&null!=t.anchorNode.parentNode&&t.anchorNode.parentNode!=this.content&&"TD"===t.anchorNode.parentNode.nodeName){const e=this.getTable(t);if(e){const t=this.shadowRoot.getElementById("rich-text-box-table-rows");t.value=e.rows.length,t.disabled=!0;const o=this.shadowRoot.getElementById("rich-text-box-table-columns");o.value=this.getColumns(e),o.disabled=!0;this.shadowRoot.getElementById("rich-text-box-table-width").value=e.style.width;const i=this.shadowRoot.getElementById("rich-text-box-table-classes");if(null!=i){const t=e.classList;i.value=Array.from(t).join(" ")}this.table=e}}else null!==t&&t.rangeCount>0&&(this.tableSelection=t.getRangeAt(0).cloneRange());this.shadowRoot.getElementById("rich-text-box-table-modal").show();const e=this.shadowRoot.getElementById("rich-text-box-table-columns");e&&e.focus()};getTable=t=>"TABLE"===t.anchorNode.parentNode.parentNode.parentNode.nodeName?t.anchorNode.parentNode.parentNode.parentNode:"TABLE"===t.anchorNode.parentNode.parentNode.parentNode.parentNode.nodeName?t.anchorNode.parentNode.parentNode.parentNode.parentNode:void 0;getColumns(t){let e=0;for(let o=0;o<t.rows.length;o++){let i=t.rows[o].cells.length;i>e&&(e=i)}return e}resetTableDialog=()=>{this.table=null,this.tableSelection=null;const t=this.shadowRoot.getElementById("rich-text-box-table-rows");t.value=null,t.disabled=!1;const e=this.shadowRoot.getElementById("rich-text-box-table-columns");e.value=null,e.disabled=!1;this.shadowRoot.getElementById("rich-text-box-table-width").value=null;const o=this.shadowRoot.getElementById("rich-text-box-table-classes");null!=o&&(o.value=null)};insertTable=()=>{const t=this.shadowRoot.getElementById("rich-text-box-table-rows"),e=this.shadowRoot.getElementById("rich-text-box-table-columns"),o=this.shadowRoot.getElementById("rich-text-box-table-width"),i=this.shadowRoot.getElementById("rich-text-box-table-classes");if(0!=t.value.length&&0!=e.value.length){if(null!==this.table)o.value.trim().length>0?this.table.style.width=o.value:(this.table.style.removeProperty("width"),0===this.table.style.cssText.trim().length&&this.table.hasAttribute("style")&&this.table.removeAttribute("style")),null!==i&&this.Utilities.addClasses(i.value,this.table),this.Utilities.reselectNode(this.table);else if(null!=this.tableSelection){const n=this.tableSelection,r=this.createTable(t.value,e.value,o.value);null!==i&&this.Utilities.addClasses(i.value,r),n.deleteContents(),n.insertNode(r);let s=r.querySelector("td, th"),l=document.createRange();l.setStart(s,0),l.setEnd(s,0),this.savedSelection=l}this.closeDialog()}else this.closeDialog()};closeDialog=()=>{this.Utilities.closeDialog("rich-text-box-table-modal",this.savedSelection)};createTable=(t,e,o)=>{const i=parseInt(t,10),n=parseInt(e,10),r=document.createElement("table");o&&(r.style.width=o);const s=document.createElement("tbody");for(let t=0;t<i;t++){const t=document.createElement("tr");for(let e=0;e<n;e++){const e=document.createElement("td");e.innerHTML="​",t.appendChild(e)}s.appendChild(t)}return r.appendChild(s),r};tableTab=()=>{const t=this.Utilities.getSelection();if(null!==t){if(!t.rangeCount)return;const e=this.getCurrentCell(t);if(!e)return;const o=this.getNextElement(e);if(o){o.focus();const e=document.createRange();e.selectNodeContents(o),""===o.innerText&&e.collapse(),t.removeAllRanges(),t.addRange(e)}this.content.focus()}};addRowFromLastCell=()=>{const t=this.Utilities.getSelection();if(null===t||!t.rangeCount)return!1;const e=this.getCurrentCell(t);if(!e)return!1;const o=e.parentElement,i=o?o.parentElement:null,n=i?i.closest("table"):null;if(!o||!i||!n)return!1;if(o.nextElementSibling)return!1;if(e.nextElementSibling)return!1;const r=Math.max(this.getColumns(n),o.cells.length,1),s=document.createElement("tr");for(let t=0;t<r;t++){const t=document.createElement("td");t.innerHTML="​",s.appendChild(t)}i.appendChild(s);const l=s.querySelector("td, th");return l&&this.selectCell(l),!0};getCurrentCell=t=>{if(!t||!t.anchorNode)return null;const e=t.anchorNode.nodeType===Node.ELEMENT_NODE?t.anchorNode:t.anchorNode.parentElement;if(!e||!this.content.contains(e))return null;const o=e.closest("td, th");return o&&this.content.contains(o)?o:null};selectCell=t=>{if(!t)return;this.content.focus();const e=this.Utilities.getSelection()||window.getSelection(),o=document.createRange();o.selectNodeContents(t),o.collapse(!0),e.removeAllRanges(),e.addRange(o)};getNextElement=t=>{let e=t.nextElementSibling;if(!e){let o=t.parentElement.nextElementSibling;o&&(e=o.querySelector("td"))}return e}}class l{constructor(t,e,o){this.shadowRoot=t,this.content=e,this.Utilities=o,this.addEventListeners()}addEventListeners=()=>{this.dialog=this.shadowRoot.getElementById("rich-text-box-embed-modal"),this.dialog.addEventListener("keydown",t=>{"Enter"===t.key&&(t.preventDefault(),this.insertMedia()),"Escape"===t.key&&(t.preventDefault(),this.closeDialog())})};openMediaDialog=t=>{if(null!==t){if(this.resetMediaDialog(),this.savedSelection=this.Utilities.saveSelection(t),t.anchorNode&&t.anchorNode.querySelector&&(this.embed=t.anchorNode.querySelector("object"),null!==this.embed)){this.shadowRoot.getElementById("rich-text-box-embed-source").value=this.embed.data;this.shadowRoot.getElementById("rich-text-box-embed-width").value=this.embed.width;this.shadowRoot.getElementById("rich-text-box-embed-height").value=this.embed.height;this.shadowRoot.getElementById("rich-text-box-embed-type").value=this.embed.type;this.shadowRoot.getElementById("rich-text-box-embed-css-classes").value=Array.from(this.embed.classList).join(" ")}t.rangeCount>0&&(this.embedSelection=t.getRangeAt(0).cloneRange()),this.shadowRoot.getElementById("rich-text-box-embed-modal").show();const e=this.shadowRoot.getElementById("rich-text-box-embed-source");e&&e.focus()}};resetMediaDialog=()=>{this.embed=null,this.embedSelection=null;this.shadowRoot.getElementById("rich-text-box-embed-source").value=null;this.shadowRoot.getElementById("rich-text-box-embed-width").value=null;this.shadowRoot.getElementById("rich-text-box-embed-height").value=null;this.shadowRoot.getElementById("rich-text-box-embed-type").value=null;const t=this.shadowRoot.getElementById("rich-text-box-embed-css-classes");null!=t&&(t.value=null)};insertMedia=()=>{const t=this.shadowRoot.getElementById("rich-text-box-embed-source"),e=this.shadowRoot.getElementById("rich-text-box-embed-width"),o=this.shadowRoot.getElementById("rich-text-box-embed-height"),i=this.shadowRoot.getElementById("rich-text-box-embed-type"),n=this.shadowRoot.getElementById("rich-text-box-embed-css-classes");if(null!==this.embed)this.embed.data=t.value,i.value.trim().length>0?this.embed.type=i.value:this.embed.hasAttribute("type")&&this.embed.removeAttribute("type"),e.value.trim().length>0?this.embed.width=e.value:this.embed.hasAttribute("width")&&this.embed.removeAttribute("width"),o.value.trim().length>0?this.embed.height=o.value:this.embed.hasAttribute("height")&&this.embed.removeAttribute("height"),null!==n&&this.Utilities.addClasses(n.value,this.embed);else if(null!=this.embedSelection&&t.value.length>0){const r=this.embedSelection.cloneRange(),s=document.createElement("object");s.data=t.value,i.value.trim().length>0?s.type=i.value:s.hasAttribute("type")&&s.removeAttribute("type"),e.value.trim().length>0?s.width=e.value:s.hasAttribute("width")&&s.removeAttribute("width"),o.value.trim().length>0?s.height=o.value:s.hasAttribute("height")&&s.removeAttribute("height"),null!==n&&this.Utilities.addClasses(n.value,s),r.deleteContents(),r.insertNode(s),this.Utilities.reselectNode(s),this.embedSelection=r.cloneRange()}this.closeDialog()};closeDialog=()=>{this.Utilities.closeDialog("rich-text-box-embed-modal",this.savedSelection)}}class a{constructor(t,e,o){this.shadowRoot=t,this.content=e,this.Utilities=o,this.video=null,this.videoSelection=null,this.savedSelection=null,this.addEventListeners()}addEventListeners=()=>{this.dialog=this.shadowRoot.getElementById("rich-text-box-video-modal"),this.dialog.addEventListener("keydown",t=>{"Enter"===t.key&&(t.preventDefault(),this.insertVideo()),"Escape"===t.key&&(t.preventDefault(),this.closeDialog())})};_populateFromVideo=t=>{const ge=t=>this.shadowRoot.getElementById(t),e=t.querySelector("source");ge("rich-text-box-video-source").value=e?e.getAttribute("src")||"":t.getAttribute("src")||"",ge("rich-text-box-video-source-type").value=e&&e.getAttribute("type")||"",ge("rich-text-box-video-poster").value=t.getAttribute("poster")||"",ge("rich-text-box-video-width").value=t.getAttribute("width")||"",ge("rich-text-box-video-height").value=t.getAttribute("height")||"",ge("rich-text-box-video-controls").checked=t.hasAttribute("controls"),ge("rich-text-box-video-autoplay").checked=t.hasAttribute("autoplay"),ge("rich-text-box-video-loop").checked=t.hasAttribute("loop"),ge("rich-text-box-video-muted").checked=t.hasAttribute("muted"),ge("rich-text-box-video-css-classes").value=Array.from(t.classList).join(" ")};_showDialog=()=>{this.shadowRoot.getElementById("rich-text-box-video-modal").show(),this.shadowRoot.getElementById("rich-text-box-video-source").focus()};openVideoDialog=t=>{if(null!==t){this.resetVideoDialog(),this.savedSelection=this.Utilities.saveSelection(t);const e=t.anchorNode;e&&("VIDEO"===e.nodeName?this.video=e:"SOURCE"===e.nodeName&&"VIDEO"===e.parentElement?.nodeName?this.video=e.parentElement:e.querySelector&&(this.video=e.querySelector("video")),!this.video&&e.closest&&(this.video=e.closest("video"))),null!==this.video&&this._populateFromVideo(this.video),t.rangeCount>0&&(this.videoSelection=t.getRangeAt(0).cloneRange()),this._showDialog()}};openVideoDialogForElement=(t,e)=>{this.resetVideoDialog(),this.savedSelection=e,this.video=t,this._populateFromVideo(t);const o=this.Utilities.getSelection();o&&o.rangeCount>0&&(this.videoSelection=o.getRangeAt(0).cloneRange()),this._showDialog()};resetVideoDialog=()=>{this.video=null,this.videoSelection=null;const ge=t=>this.shadowRoot.getElementById(t);ge("rich-text-box-video-source").value="",ge("rich-text-box-video-source-type").value="",ge("rich-text-box-video-poster").value="",ge("rich-text-box-video-width").value="",ge("rich-text-box-video-height").value="",ge("rich-text-box-video-controls").checked=!0,ge("rich-text-box-video-autoplay").checked=!1,ge("rich-text-box-video-loop").checked=!1,ge("rich-text-box-video-muted").checked=!1,ge("rich-text-box-video-css-classes").value=""};insertVideo=()=>{const ge=t=>this.shadowRoot.getElementById(t),t=ge("rich-text-box-video-source").value.trim(),e=ge("rich-text-box-video-source-type").value.trim(),o=ge("rich-text-box-video-poster").value.trim(),i=ge("rich-text-box-video-width").value.trim(),n=ge("rich-text-box-video-height").value.trim(),r=ge("rich-text-box-video-controls").checked,s=ge("rich-text-box-video-autoplay").checked,l=ge("rich-text-box-video-loop").checked,a=ge("rich-text-box-video-muted").checked,c=ge("rich-text-box-video-css-classes").value.trim(),applyAttrs=d=>{let h=d.querySelector("source");h||(h=document.createElement("source"),d.appendChild(h)),h.setAttribute("src",t),e?h.setAttribute("type",e):h.removeAttribute("type"),o?d.setAttribute("poster",o):d.removeAttribute("poster"),i?d.setAttribute("width",i):d.removeAttribute("width"),n?d.setAttribute("height",n):d.removeAttribute("height"),r?d.setAttribute("controls",""):d.removeAttribute("controls"),s?d.setAttribute("autoplay",""):d.removeAttribute("autoplay"),l?d.setAttribute("loop",""):d.removeAttribute("loop"),a?d.setAttribute("muted",""):d.removeAttribute("muted"),this.Utilities.addClasses(c,d)};if(null!==this.video)applyAttrs(this.video);else if(null!==this.videoSelection&&t.length>0){const t=this.videoSelection.cloneRange();if(!this.content.contains(t.startContainer))return void this.closeDialog();const e=document.createElement("video");applyAttrs(e),t.deleteContents();let o=t.startContainer;if(o===this.content){const o=this.content.childNodes[t.startOffset]??null;this.content.insertBefore(e,o)}else{for(;o.parentNode&&o.parentNode!==this.content;)if(o=o.parentNode,!this.content.contains(o))return this.content.appendChild(e),this._placeCursorAfterVideo(e),this.videoSelection=null,void this.closeDialog();this.content.insertBefore(e,o.nextSibling)}this._placeCursorAfterVideo(e),this.videoSelection=null}this.closeDialog()};_placeCursorAfterVideo=t=>{if(!t.nextSibling){const e=document.createElement("p");e.appendChild(document.createElement("br")),this.content.insertBefore(e,t.nextSibling)}this._insertedVideo=t};closeDialog=()=>{const t=this._insertedVideo;if(this._insertedVideo=null,this.Utilities.closeDialog("rich-text-box-video-modal",this.savedSelection),t){const e=t.nextSibling;if(e){const t=document.createRange(),o=e.firstChild??e;t.setStart(o,0),t.collapse(!0);const i=window.getSelection();i&&(i.removeAllRanges(),i.addRange(t))}}}}class c{constructor(t,e,o){this.shadowRoot=t,this.content=e,this.Utilities=o,this.addEventListeners()}addEventListeners=()=>{const t=this.shadowRoot.getElementById("rich-text-box-code");this.dialog=this.shadowRoot.getElementById("rich-text-box-code-block-modal"),this.dialog.addEventListener("keydown",e=>{"Enter"===e.key&&e.target!==t&&(e.preventDefault(),e.stopPropagation(),this.insertCodeBlock()),"Escape"===e.key&&(e.preventDefault(),this.closeDialog())})};openCodeBlockDialog=t=>{if(null!==t){this.resetCodeBlockDialog(),this.savedSelection=this.Utilities.saveSelection(t);const e=this.shadowRoot.getElementById("rich-text-box-code"),o=this.shadowRoot.getElementById("rich-text-box-code-css-classes");if(null!=t.anchorNode&&t.anchorNode!=this.content&&null!=t.anchorNode.parentNode&&t.anchorNode.parentNode!=this.content&&this.content.contains(t.anchorNode.parentNode)&&"CODE"===t.anchorNode.parentNode.nodeName){const i=t.anchorNode.parentNode.cloneNode(!0);if(e.value=i.textContent,null!=o){const e=t.anchorNode.parentNode.classList;o.value=Array.from(e).join(" ")}this.codeSelection=t.getRangeAt(0).cloneRange(),this.code=t.anchorNode.parentNode}else t.rangeCount>0&&(this.codeSelection=t.getRangeAt(0).cloneRange());this.shadowRoot.getElementById("rich-text-box-code-block-modal").show(),e&&(e.focus(),e.scrollTop=0,e.scrollLeft=0)}};openCodeBlockDialogForElement=(t,e)=>{if(!t||!this.content.contains(t))return;this.resetCodeBlockDialog(),this.savedSelection=e?e.cloneRange():null;const o=t.querySelector("code")||t,i=this.shadowRoot.getElementById("rich-text-box-code"),n=this.shadowRoot.getElementById("rich-text-box-code-css-classes");i.value=o.textContent,null!=n&&(n.value=Array.from(o.classList).join(" ")),this.codeSelection=e?e.cloneRange():null,this.code=o,this.shadowRoot.getElementById("rich-text-box-code-block-modal").show(),i.focus(),i.scrollTop=0,i.scrollLeft=0};resetCodeBlockDialog=()=>{this.code=null,this.codeSelection=null;this.shadowRoot.getElementById("rich-text-box-code").value=null;const t=this.shadowRoot.getElementById("rich-text-box-code-css-classes");null!=t&&(t.value=null)};insertCodeBlock=()=>{const t=this.shadowRoot.getElementById("rich-text-box-code"),e=this.shadowRoot.getElementById("rich-text-box-code-css-classes");if(null!=this.code){const o=this.code;o.textContent=t.value,null!==e&&this.Utilities.addClasses(e.value,o);const i=o.closest("pre")||o,n=document.createRange();n.setStartAfter(i),n.collapse(!0),this.savedSelection=n}else if(null!=this.codeSelection&&t.value.length>0){const o=this.codeSelection.cloneRange(),i=document.createElement("pre"),n=document.createElement("code");null!==e&&this.Utilities.addClasses(e.value,n),n.textContent=t.value,i.appendChild(n),o.deleteContents(),o.insertNode(i),o.setStartAfter(i),o.setEndAfter(i),this.savedSelection=o}this.closeDialog()};closeDialog=()=>{this.Utilities.closeDialog("rich-text-box-code-block-modal",this.savedSelection)}}class d{constructor(t,e,o){this.shadowRoot=t,this.content=e,this.Utilities=o,this.addEventListeners()}addEventListeners=()=>{const t=this.shadowRoot.getElementById("rich-text-box-quote");this.dialog=this.shadowRoot.getElementById("rich-text-box-block-quote-modal"),this.dialog.addEventListener("keydown",e=>{"Enter"===e.key&&e.target!==t&&(e.preventDefault(),e.stopPropagation(),this.insertBlockQuote()),"Escape"===e.key&&(e.preventDefault(),this.closeDialog())})};openBlockQuoteDialog=t=>{if(null!==t){this.resetBlockQuoteDialog(),this.savedSelection=this.Utilities.saveSelection(t);const e=this.shadowRoot.getElementById("rich-text-box-quote"),o=this.shadowRoot.getElementById("rich-text-box-cite"),i=this.shadowRoot.getElementById("rich-text-box-quote-css-classes");if(null!=t.anchorNode&&t.anchorNode!=this.content&&null!=t.anchorNode.parentNode&&t.anchorNode.parentNode!=this.content&&this.content.contains(t.anchorNode.parentNode)&&"BLOCKQUOTE"==t.anchorNode.parentNode.nodeName){if(e.value=t.anchorNode.parentNode.textContent,null!=t.anchorNode.parentNode.cite&&(o.value=t.anchorNode.parentNode.cite),null!=i){const e=t.anchorNode.parentNode.classList;i.value=Array.from(e).join(" ")}this.quoteSelection=t.getRangeAt(0).cloneRange(),this.quote=t.anchorNode.parentNode}else t.rangeCount>0&&(this.quoteSelection=t.getRangeAt(0).cloneRange());this.shadowRoot.getElementById("rich-text-box-block-quote-modal").show(),e&&(e.focus(),e.scrollTop=0,e.scrollLeft=0)}};openBlockQuoteDialogForElement=(t,e)=>{if(!t||!this.content.contains(t))return;this.resetBlockQuoteDialog(),this.savedSelection=e?e.cloneRange():null;const o=this.shadowRoot.getElementById("rich-text-box-quote"),i=this.shadowRoot.getElementById("rich-text-box-cite"),n=this.shadowRoot.getElementById("rich-text-box-quote-css-classes");o.value=t.textContent,null!=t.cite&&(i.value=t.cite),null!=n&&(n.value=Array.from(t.classList).join(" ")),this.quoteSelection=e?e.cloneRange():null,this.quote=t,this.shadowRoot.getElementById("rich-text-box-block-quote-modal").show(),o.focus(),o.scrollTop=0,o.scrollLeft=0};resetBlockQuoteDialog=()=>{this.quote=null,this.quoteSelection=null;this.shadowRoot.getElementById("rich-text-box-quote").value=null;this.shadowRoot.getElementById("rich-text-box-cite").value=null;const t=this.shadowRoot.getElementById("rich-text-box-quote-css-classes");null!=t&&(t.value=null)};insertBlockQuote=()=>{const t=this.shadowRoot.getElementById("rich-text-box-quote"),e=this.shadowRoot.getElementById("rich-text-box-cite"),o=this.shadowRoot.getElementById("rich-text-box-quote-css-classes");if(null!=this.quote){const i=this.quote;i.textContent=t.value,e.value.trim().length>0?i.setAttribute("cite",e.value):i.hasAttribute("cite")&&i.removeAttribute("cite"),null!==o&&this.Utilities.addClasses(o.value,i);const n=document.createRange();n.setStartAfter(i),n.collapse(!0),this.savedSelection=n}else if(null!=this.quoteSelection&&t.value.length>0){const i=this.quoteSelection.cloneRange(),n=document.createElement("blockquote");n.textContent=t.value,e.value.trim().length>0?n.cite=e.value:n.hasAttribute("cite")&&n.removeAttribute("cite"),null!==o&&this.Utilities.addClasses(o.value,n),i.deleteContents(),i.insertNode(n),i.setStartAfter(n),i.setEndAfter(n),this.savedSelection=i}this.closeDialog()};closeDialog=()=>{this.Utilities.closeDialog("rich-text-box-block-quote-modal",this.savedSelection)}}class h{constructor(t,e,o){this.shadowRoot=t,this.content=e,this.Utilities=o,this.addEventListeners()}addEventListeners=()=>{this.dialog=this.shadowRoot.getElementById("rich-text-box-upload-image-modal"),this.dialog&&this.dialog.addEventListener("keydown",t=>{"Enter"===t.key&&(t.preventDefault(),this.insertUploadedImage()),"Escape"===t.key&&(t.preventDefault(),this.closeDialog())});this.shadowRoot.getElementById("rich-text-box-upload-image-file").addEventListener("change",this.handleFileSelect)};handleFileSelect=t=>{const e=t.target.files[0];this.shadowRoot.getElementById("rich-text-box-upload-image-file-chosen").textContent=e.name;const o=document.createElement("img");if(e){const t=new FileReader;t.onloadend=function(){this.base64String=t.result.split(",")[1],o.src=`data:image/jpg;base64,${this.base64String}`},t.readAsDataURL(e),this.image=o}};openUploadImageDialog=t=>{if(null!==t){if(this.resetUploadImageDialog(),this.savedSelection=this.Utilities.saveSelection(t),t.anchorNode&&t.anchorNode.querySelector&&(this.currentImage=t.anchorNode.querySelector("img"),null!==this.currentImage)){this.shadowRoot.getElementById("rich-text-box-upload-image-width").value=this.currentImage.width;this.shadowRoot.getElementById("rich-text-box-upload-image-height").value=this.currentImage.height;this.shadowRoot.getElementById("rich-text-box-upload-image-alt-text").value=this.currentImage.alt;this.shadowRoot.getElementById("rich-text-box-upload-image-css-classes").value=Array.from(this.currentImage.classList).join(" ")}this.range=t.getRangeAt(0).cloneRange(),this.shadowRoot.getElementById("rich-text-box-upload-image-modal").show();const e=this.shadowRoot.getElementById("rich-text-box-upload-btn");e&&e.focus()}};resetUploadImageDialog=()=>{this.currentImage=null,this.image=null,this.range=null;this.shadowRoot.getElementById("rich-text-box-upload-image-file-chosen").textContent=null;this.shadowRoot.getElementById("rich-text-box-upload-image-file").value=null;this.shadowRoot.getElementById("rich-text-box-upload-image-width").value=null;this.shadowRoot.getElementById("rich-text-box-upload-image-height").value=null;this.shadowRoot.getElementById("rich-text-box-upload-image-alt-text").value=null;const t=this.shadowRoot.getElementById("rich-text-box-upload-image-css-classes");null!=t&&(t.value=null)};insertUploadedImage=()=>{const t=this.shadowRoot.getElementById("rich-text-box-upload-image-width"),e=this.shadowRoot.getElementById("rich-text-box-upload-image-height"),o=this.shadowRoot.getElementById("rich-text-box-upload-image-alt-text"),i=this.shadowRoot.getElementById("rich-text-box-upload-image-css-classes");this.currentImage?(this.image&&this.image.src.length>0&&(this.currentImage.src=this.image.src),t.value.trim().length>0?this.currentImage.width=t.value:this.currentImage.hasAttribute("width")&&this.currentImage.removeAttribute("width"),e.value.trim().length>0?this.currentImage.height=e.value:this.currentImage.hasAttribute("height")&&this.currentImage.removeAttribute("height"),o.value.trim().length>0?this.currentImage.alt=o.value:this.currentImage.hasAttribute("alt")&&this.currentImage.removeAttribute("alt"),null!==i&&this.Utilities.addClasses(i.value,this.currentImage),this.Utilities.reselectNode(this.currentImage)):this.image&&(t.value.length>0?this.image.width=t.value:this.image.hasAttribute("width")&&this.image.removeAttribute("width"),e.value.length>0?this.image.height=e.value:this.image.hasAttribute("height")&&this.image.removeAttribute("height"),o.value.length>0?this.image.alt=o.value:this.image.hasAttribute("alt")&&this.image.removeAttribute("alt"),null!==i&&this.Utilities.addClasses(i.value,this.image),this.range.deleteContents(),this.range.insertNode(this.image),this.Utilities.reselectNode(this.image)),this.closeDialog()};closeDialog=()=>{this.Utilities.closeDialog("rich-text-box-upload-image-modal",this.savedSelection)}}class b{constructor(t,e,o){this.shadowRoot=t,this.content=e,this.Utilities=o,this.addEventListeners()}addEventListeners=()=>{this.dialog=this.shadowRoot.getElementById("rich-text-box-image-modal"),this.dialog.addEventListener("keydown",t=>{"Enter"===t.key&&(t.preventDefault(),this.insertImage()),"Escape"===t.key&&(t.preventDefault(),this.closeDialog())})};openImageDialog=t=>{if(null!==t){if(this.resetImageDialog(),this.savedSelection=this.Utilities.saveSelection(t),t.anchorNode&&t.anchorNode.querySelector&&(this.image=t.anchorNode.querySelector("img"),null!==this.image)){this.shadowRoot.getElementById("rich-text-box-image-webaddress").value=this.image.src;this.shadowRoot.getElementById("rich-text-box-image-width").value=this.image.width;this.shadowRoot.getElementById("rich-text-box-image-height").value=this.image.height;this.shadowRoot.getElementById("rich-text-box-image-alt-text").value=this.image.alt;this.shadowRoot.getElementById("rich-text-box-image-css-classes").value=Array.from(this.image.classList).join(" ")}t&&t.rangeCount>0&&(this.imageSelection=t.getRangeAt(0).cloneRange()),this.shadowRoot.getElementById("rich-text-box-image-modal").show();const e=this.shadowRoot.getElementById("rich-text-box-image-webaddress");e&&e.focus()}};resetImageDialog=()=>{this.image=null,this.imageSelection=null;this.shadowRoot.getElementById("rich-text-box-image-webaddress").value=null;this.shadowRoot.getElementById("rich-text-box-image-width").value=null;this.shadowRoot.getElementById("rich-text-box-image-height").value=null;this.shadowRoot.getElementById("rich-text-box-image-alt-text").value=null;const t=this.shadowRoot.getElementById("rich-text-box-image-css-classes");null!=t&&(t.value=null)};insertImage=()=>{const t=this.shadowRoot.getElementById("rich-text-box-image-webaddress"),e=this.shadowRoot.getElementById("rich-text-box-image-width"),o=this.shadowRoot.getElementById("rich-text-box-image-height"),i=this.shadowRoot.getElementById("rich-text-box-image-alt-text"),n=this.shadowRoot.getElementById("rich-text-box-image-css-classes");if(null!==this.imageSelection){const r=this.imageSelection.cloneRange();if(null!==this.image)t.value.trim().length>0&&(this.image.src=t.value),i.value.trim().length>0?this.image.alt=i.value:this.image.hasAttribute("alt")&&this.image.removeAttribute("alt"),e.value.trim().length>0?this.image.width=e.value:this.image.hasAttribute("width")&&this.image.removeAttribute("width"),o.value.trim().length>0?this.image.height=o.value:this.image.hasAttribute("height")&&this.image.removeAttribute("height"),null!==n&&this.Utilities.addClasses(n.value,this.image),this.Utilities.reselectNode(this.image);else if(t.value.length>0){const s=document.createElement("img");s.src=t.value,e.value.trim().length>0&&(s.width=e.value),o.value.trim().length>0&&(s.height=o.value),i.value.trim().length>0&&(s.alt=i.value),null!==n&&this.Utilities.addClasses(n.value,s),r.deleteContents(),r.insertNode(s),this.Utilities.reselectNode(s)}this.imageSelection=r.cloneRange()}this.closeDialog()};closeDialog=()=>{this.Utilities.closeDialog("rich-text-box-image-modal",this.savedSelection)}}class u{constructor(t,e,o){this.shadowRoot=t,this.content=e,this.Utilities=o,this.addEventListeners()}addEventListeners=()=>{this.dialog=this.shadowRoot.getElementById("rich-text-box-link-modal"),this.dialog.addEventListener("keydown",t=>{"Enter"===t.key&&(t.preventDefault(),this.insertLink()),"Escape"===t.key&&(t.preventDefault(),this.closeDialog())})};openLinkDialog=t=>{if(null!==t){if(this.savedSelection=this.Utilities.saveSelection(t),this.resetLinkDialog(),null!=t.anchorNode&&t.anchorNode!=this.content&&null!=t.anchorNode.parentNode&&t.anchorNode.parentNode!=this.content&&this.content.contains(t.anchorNode.parentNode)&&"A"===t.anchorNode.parentNode.nodeName){this.shadowRoot.getElementById("rich-text-box-linktext").value=t.anchorNode.parentNode.textContent;this.shadowRoot.getElementById("rich-text-box-link-webaddress").value=t.anchorNode.parentNode.getAttribute("href");const e=this.shadowRoot.getElementById("rich-text-box-link-css-classes");if(null!=e){const o=t.anchorNode.parentNode.classList;e.value=Array.from(o).join(" ")}if("_blank"===t.anchorNode.parentNode.getAttribute("target")){this.shadowRoot.getElementById("rich-text-box-link-modal-newtab").checked=!0}this.linkNode=t.anchorNode.parentNode}else{const e=this.shadowRoot.getElementById("rich-text-box-linktext");t.toString().length>0&&(this.linkSelection=t.getRangeAt(0).cloneRange(),e.value=this.linkSelection.toString())}this.shadowRoot.getElementById("rich-text-box-link-modal").show();const e=this.shadowRoot.getElementById("rich-text-box-link-webaddress");e&&e.focus()}};resetLinkDialog=()=>{this.linkNode=null,this.linkSelection=null;this.shadowRoot.getElementById("rich-text-box-linktext").value=null;this.shadowRoot.getElementById("rich-text-box-link-webaddress").value=null;this.shadowRoot.getElementById("rich-text-box-link-modal-newtab").checked=!1;const t=this.shadowRoot.getElementById("rich-text-box-link-css-classes");null!=t&&(t.value=null)};insertLink=()=>{const t=this.shadowRoot.getElementById("rich-text-box-linktext"),e=this.shadowRoot.getElementById("rich-text-box-link-webaddress"),o=this.shadowRoot.getElementById("rich-text-box-link-modal-newtab"),i=this.shadowRoot.getElementById("rich-text-box-link-css-classes");if(0!=e.value.length&&0!=t.value.length){if(null!=this.linkNode){const n=this.linkNode;n.href=e.value,n.textContent=t.value,null!==i&&this.Utilities.addClasses(i.value,n),o.checked?n.target="_blank":n.hasAttribute("target")&&n.removeAttribute("target"),this.Utilities.reselectNode(n)}else if(null!=this.linkSelection){const n=this.linkSelection,r=document.createElement("a");r.href=e.value,r.textContent=t.value,null!==i&&this.Utilities.addClasses(i.value,r),o.checked&&(r.target="_blank"),n.deleteContents(),n.insertNode(r),n.setStartBefore(r.firstChild),n.setEndAfter(r.lastChild),this.savedSelection=n}this.closeDialog()}else this.closeDialog()};closeDialog=()=>{this.Utilities.closeDialog("rich-text-box-link-modal",this.savedSelection)};removeLink=()=>{const t=this.Utilities.getSelection();if(null!==t){const e=this.Utilities.saveSelection(t);if(null!=t.anchorNode&&t.anchorNode!=this.content&&null!=t.anchorNode.parentNode&&this.content.contains(t.anchorNode.parentNode)&&"A"===t.anchorNode.parentNode.nodeName){const e=t.anchorNode.parentNode,o=document.createDocumentFragment();for(;e.firstChild;)o.appendChild(e.firstChild);e.parentNode.insertBefore(o,e),e.parentNode.removeChild(e)}this.Utilities.restoreSelection(t,e)}}}class g{constructor(t,e,o,i,n){this.shadowRoot=t,this.content=e,this.id=o,this.NodeManager=i,this.Utilities=n,this.init()}init=()=>{this.colorPickerDialog=this.shadowRoot.getElementById(this.id),this.colorPickerDialog.addEventListener("keydown",t=>{"Enter"===t.key&&(t.preventDefault(),this.insertColor()),"Escape"===t.key&&(t.preventDefault(),this.closeDialog())}),this.colorPicker=this.colorPickerDialog.querySelector(".rich-text-box-color-picker"),this.redSlider=this.colorPicker.querySelector(".rich-text-box-red-slider"),this.addSliderEventListener(this.redSlider),this.greenSlider=this.colorPicker.querySelector(".rich-text-box-green-slider"),this.addSliderEventListener(this.greenSlider),this.blueSlider=this.colorPicker.querySelector(".rich-text-box-blue-slider"),this.addSliderEventListener(this.blueSlider),this.redValue=this.colorPicker.querySelector(".rich-text-box-red-value"),this.addValueEventListener(this.redValue),this.greenValue=this.colorPicker.querySelector(".rich-text-box-green-value"),this.addValueEventListener(this.greenValue),this.blueValue=this.colorPicker.querySelector(".rich-text-box-blue-value"),this.addValueEventListener(this.blueValue),this.hexInput=this.colorPicker.querySelector(".rich-text-box-hex-input"),this.addHexEventListener(this.hexInput),this.colorDisplay=this.colorPicker.querySelector(".rich-text-box-color-display")};addSliderEventListener=async t=>{t.addEventListener("input",()=>this.updateColor())};addValueEventListener=async t=>{t.addEventListener("input",t=>{let e=Array.from(t.target.classList).find(t=>t.includes("value"));this.colorPicker.querySelector(`.${e.replace("value","slider")}`).value=t.target.value,this.updateColor()}),t.addEventListener("focus",t=>{t.target.select()})};addHexEventListener=async t=>{t.addEventListener("keyup",t=>{/^#?[0-9A-Fa-f]{6}$/.test(t.target.value)&&this.updateFromHex()}),t.addEventListener("change",()=>this.updateFromHex()),t.addEventListener("paste",()=>setTimeout(this.updateFromHex,0)),t.addEventListener("focus",e=>{t.select()})};openColorPicker=(t,e)=>{if(this.resetColorDialog(),this.savedSelection=this.Utilities.saveSelection(t),null!==t&&null!=t.anchorNode&&t.anchorNode!=e&&null!=t.anchorNode.parentNode&&t.anchorNode.parentNode!=e&&e.contains(t.anchorNode.parentNode)&&null!=t.anchorNode.parentNode.style){switch(this.selection=t.getRangeAt(0).cloneRange(),this.id){case"rich-text-box-text-color-modal":t.anchorNode.parentNode.style.color.toString().length>0&&(this.hexInput.value=this.colorToHex(t.anchorNode.parentNode.style.color));break;case"rich-text-box-text-bg-color-modal":t.anchorNode.parentNode.style.backgroundColor.toString().length>0&&(this.hexInput.value=this.colorToHex(t.anchorNode.parentNode.style.backgroundColor))}this.updateFromHex(),this.selection=t.getRangeAt(0).cloneRange()}else null!==t&&t.rangeCount>0&&(this.selection=t.getRangeAt(0).cloneRange());return this.colorPickerDialog.show(),this.selection};insertColor=()=>{let t;switch(this.currentColor=this.getCurrentColor(),this.id){case"rich-text-box-text-color-modal":t="textcolor";break;case"rich-text-box-text-bg-color-modal":t="textbgcolor"}null!==this.selection&&(this.savedSelection=this.Utilities.saveSelection(this.selection),null===this.currentColor?this.NodeManager.updateNode(t,"None",this.selection):this.NodeManager.updateNode(t,this.currentColor,this.selection)),this.closeDialog()};closeDialog=()=>{this.Utilities.closeDialog(this.id,this.savedSelection)};resetColorDialog=()=>{this.selection=null,this.hexInput.value="#000000",this.updateFromHex()};selectColor=t=>{this.hexInput.value=t,this.updateFromHex()};updateColor=()=>{let t=parseInt(this.redSlider.value),e=parseInt(this.greenSlider.value),o=parseInt(this.blueSlider.value),i=`rgb(${t}, ${e}, ${o})`;this.currentColor=i,this.colorDisplay.style.backgroundColor=i,this.redValue.value=t,this.greenValue.value=e,this.blueValue.value=o,this.hexInput.value=this.rgbToHex(t,e,o)};getCurrentColor=()=>this.currentColor;updateFromHex=()=>{let t=this.hexInput.value.trim();if("#"!==t.charAt(0)&&(t="#"+t),/^#[0-9A-Fa-f]{6}$/.test(t)){let e=this.hexToRgb(t);e&&(this.redSlider.value=this.redValue.value=e.r,this.greenSlider.value=this.greenValue.value=e.g,this.blueSlider.value=this.blueValue.value=e.b)}this.updateColor()};rgbToHex=(t,e,o)=>"#"+((1<<24)+(t<<16)+(e<<8)+o).toString(16).slice(1);hexToRgb=t=>{const e=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t);return e?{r:parseInt(e[1],16),g:parseInt(e[2],16),b:parseInt(e[3],16)}:null};colorToHex=t=>{const e=document.createElement("canvas").getContext("2d");return e.fillStyle=t,e.fillStyle}}window.RTNative_Instances={},window.RTNative_Initialize=(e,o,i,n,r,s)=>{try{null==RTNative_Instances[e]&&(RTNative_Instances[e]=new t(e,o,i,n,s),RTNative_Instances[e].loadHtml(r))}catch(t){console.log(t)}},window.RTNative_Method=(t,e,o)=>{try{const i=RTNative_Instances[e];if(null!=i&&"function"==typeof i[t])return null!=o?i[t](o):i[t]()}catch(t){console.log(t)}};const m={Bold:"M272-200v-560h221q65 0 120 40t55 111q0 51-23 78.5T602-491q25 11 55.5 41t30.5 90q0 89-65 124.5T501-200H272Zm121-112h104q48 0 58.5-24.5T566-372q0-11-10.5-35.5T494-432H393v120Zm0-228h93q33 0 48-17t15-38q0-24-17-39t-44-15h-95v109Z",Italic:"M200-200v-100h160l120-360H320v-100h400v100H580L460-300h140v100H200Z",Underline:"M200-120v-80h560v80H200Zm280-160q-101 0-157-63t-56-167v-330h103v336q0 56 28 91t82 35q54 0 82-35t28-91v-336h103v330q0 104-56 167t-157 63Z",Strikethrough:"M486-160q-76 0-135-45t-85-123l88-38q14 48 48.5 79t85.5 31q42 0 76-20t34-64q0-18-7-33t-19-27h112q5 14 7.5 28.5T694-340q0 86-61.5 133T486-160ZM80-480v-80h800v80H80Zm402-326q66 0 115.5 32.5T674-674l-88 39q-9-29-33.5-52T484-710q-41 0-68 18.5T386-640h-96q2-69 54.5-117.5T482-806Z",Subscript:"M760-160v-80q0-17 11.5-28.5T800-280h80v-40H760v-40h120q17 0 28.5 11.5T920-320v40q0 17-11.5 28.5T880-240h-80v40h120v40H760Zm-525-80 185-291-172-269h106l124 200h4l123-200h107L539-531l186 291H618L482-457h-4L342-240H235Z",Superscript:"M760-600v-80q0-17 11.5-28.5T800-720h80v-40H760v-40h120q17 0 28.5 11.5T920-760v40q0 17-11.5 28.5T880-680h-80v40h120v40H760ZM235-160l185-291-172-269h106l124 200h4l123-200h107L539-451l186 291H618L482-377h-4L342-160H235Z",Alignleft:"M120-120v-80h720v80H120Zm0-160v-80h480v80H120Zm0-160v-80h720v80H120Zm0-160v-80h480v80H120Zm0-160v-80h720v80H120Z",Aligncenter:"M120-120v-80h720v80H120Zm160-160v-80h400v80H280ZM120-440v-80h720v80H120Zm160-160v-80h400v80H280ZM120-760v-80h720v80H120Z",Alignright:"M120-760v-80h720v80H120Zm240 160v-80h480v80H360ZM120-440v-80h720v80H120Zm240 160v-80h480v80H360ZM120-120v-80h720v80H120Z",Alignjustify:"M120-120v-80h720v80H120Zm0-160v-80h720v80H120Zm0-160v-80h720v80H120Zm0-160v-80h720v80H120Zm0-160v-80h720v80H120Z",Copy:"M360-240q-33 0-56.5-23.5T280-320v-480q0-33 23.5-56.5T360-880h360q33 0 56.5 23.5T800-800v480q0 33-23.5 56.5T720-240H360Zm0-80h360v-480H360v480ZM200-80q-33 0-56.5-23.5T120-160v-560h80v560h440v80H200Zm160-240v-480 480Z",Cut:"M760-120 480-400l-94 94q8 15 11 32t3 34q0 66-47 113T240-80q-66 0-113-47T80-240q0-66 47-113t113-47q17 0 34 3t32 11l94-94-94-94q-15 8-32 11t-34 3q-66 0-113-47T80-720q0-66 47-113t113-47q66 0 113 47t47 113q0 17-3 34t-11 32l494 494v40H760ZM600-520l-80-80 240-240h120v40L600-520ZM240-640q33 0 56.5-23.5T320-720q0-33-23.5-56.5T240-800q-33 0-56.5 23.5T160-720q0 33 23.5 56.5T240-640Zm240 180q8 0 14-6t6-14q0-8-6-14t-14-6q-8 0-14 6t-6 14q0 8 6 14t14 6ZM240-160q33 0 56.5-23.5T320-240q0-33-23.5-56.5T240-320q-33 0-56.5 23.5T160-240q0 33 23.5 56.5T240-160Z",Paste:"M200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h167q11-35 43-57.5t70-22.5q40 0 71.5 22.5T594-840h166q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Zm0-80h560v-560h-80v120H280v-120h-80v560Zm280-560q17 0 28.5-11.5T520-800q0-17-11.5-28.5T480-840q-17 0-28.5 11.5T440-800q0 17 11.5 28.5T480-760Z",Delete:"M280-120q-33 0-56.5-23.5T200-200v-520h-40v-80h200v-40h240v40h200v80h-40v520q0 33-23.5 56.5T680-120H280Zm400-600H280v520h400v-520ZM360-280h80v-360h-80v360Zm160 0h80v-360h-80v360ZM280-720v520-520Z",Selectall:"M280-280v-400h400v400H280Zm80-80h240v-240H360v240ZM200-200v80q-33 0-56.5-23.5T120-200h80Zm-80-80v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm80-160h-80q0-33 23.5-56.5T200-840v80Zm80 640v-80h80v80h-80Zm0-640v-80h80v80h-80Zm160 640v-80h80v80h-80Zm0-640v-80h80v80h-80Zm160 640v-80h80v80h-80Zm0-640v-80h80v80h-80Zm160 640v-80h80q0 33-23.5 56.5T760-120Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80q33 0 56.5 23.5T840-760h-80Z",OrderedList:"M120-80v-60h100v-30h-60v-60h60v-30H120v-60h120q17 0 28.5 11.5T280-280v40q0 17-11.5 28.5T240-200q17 0 28.5 11.5T280-160v40q0 17-11.5 28.5T240-80H120Zm0-280v-110q0-17 11.5-28.5T160-510h60v-30H120v-60h120q17 0 28.5 11.5T280-560v70q0 17-11.5 28.5T240-450h-60v30h100v60H120Zm60-280v-180h-60v-60h120v240h-60Zm180 440v-80h480v80H360Zm0-240v-80h480v80H360Zm0-240v-80h480v80H360Z",UnorderedList:"M360-200v-80h480v80H360Zm0-240v-80h480v80H360Zm0-240v-80h480v80H360ZM200-160q-33 0-56.5-23.5T120-240q0-33 23.5-56.5T200-320q33 0 56.5 23.5T280-240q0 33-23.5 56.5T200-160Zm0-240q-33 0-56.5-23.5T120-480q0-33 23.5-56.5T200-560q33 0 56.5 23.5T280-480q0 33-23.5 56.5T200-400Zm-56.5-263.5Q120-687 120-720t23.5-56.5Q167-800 200-800t56.5 23.5Q280-753 280-720t-23.5 56.5Q233-640 200-640t-56.5-23.5Z",CreateLink:"M680-160v-120H560v-80h120v-120h80v120h120v80H760v120h-80ZM440-280H280q-83 0-141.5-58.5T80-480q0-83 58.5-141.5T280-680h160v80H280q-50 0-85 35t-35 85q0 50 35 85t85 35h160v80ZM320-440v-80h320v80H320Zm560-40h-80q0-50-35-85t-85-35H520v-80h160q83 0 141.5 58.5T880-480Z",RemoveLink:"m770-302-60-62q40-11 65-42.5t25-73.5q0-50-35-85t-85-35H520v-80h160q83 0 141.5 58.5T880-480q0 57-29.5 105T770-302ZM634-440l-80-80h86v80h-6ZM792-56 56-792l56-56 736 736-56 56ZM440-280H280q-83 0-141.5-58.5T80-480q0-69 42-123t108-71l74 74h-24q-50 0-85 35t-35 85q0 50 35 85t85 35h160v80ZM320-440v-80h65l79 80H320Z",Image:"M200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Zm0-80h560v-560H200v560Zm40-80h480L570-480 450-320l-90-120-120 160Zm-40 80v-560 560Z",Undo:"M280-200v-80h284q63 0 109.5-40T720-420q0-60-46.5-100T564-560H312l104 104-56 56-200-200 200-200 56 56-104 104h252q97 0 166.5 63T800-420q0 94-69.5 157T564-200H280Z",Redo:"M396-200q-97 0-166.5-63T160-420q0-94 69.5-157T396-640h252L544-744l56-56 200 200-200 200-56-56 104-104H396q-63 0-109.5 40T240-420q0 60 46.5 100T396-280h284v80H396Z",CodeBlocks:"m384-336 56-57-87-87 87-87-56-57-144 144 144 144Zm192 0 144-144-144-144-56 57 87 87-87 87 56 57ZM200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Zm0-80h560v-560H200v560Zm0-560v560-560Z",Code:"M320-240 80-480l240-240 57 57-184 184 183 183-56 56Zm320 0-57-57 184-184-183-183 56-56 240 240-240 240Z",Preview:"M607.5-372.5Q660-425 660-500t-52.5-127.5Q555-680 480-680t-127.5 52.5Q300-575 300-500t52.5 127.5Q405-320 480-320t127.5-52.5Zm-204-51Q372-455 372-500t31.5-76.5Q435-608 480-608t76.5 31.5Q588-545 588-500t-31.5 76.5Q525-392 480-392t-76.5-31.5ZM214-281.5Q94-363 40-500q54-137 174-218.5T480-800q146 0 266 81.5T920-500q-54 137-174 218.5T480-200q-146 0-266-81.5ZM480-500Zm207.5 160.5Q782-399 832-500q-50-101-144.5-160.5T480-720q-113 0-207.5 59.5T128-500q50 101 144.5 160.5T480-280q113 0 207.5-59.5Z",PermMedia:"M360-440h400L622-620l-92 120-62-80-108 140ZM120-120q-33 0-56.5-23.5T40-200v-520h80v520h680v80H120Zm160-160q-33 0-56.5-23.5T200-360v-440q0-33 23.5-56.5T280-880h200l80 80h280q33 0 56.5 23.5T920-720v360q0 33-23.5 56.5T840-280H280Zm0-80h560v-360H527l-80-80H280v440Zm0 0v-440 440Z",TextColor:"M80 0v-160h800V0H80Zm140-280 210-560h100l210 560h-96l-50-144H368l-52 144h-96Zm176-224h168l-82-232h-4l-82 232Z",TextBackgroundColor:"M80 0v-160h800V0H80Zm504-480L480-584 320-424l103 104 161-160Zm-47-160 103 103 160-159-104-104-159 160Zm-84-29 216 216-189 190q-24 24-56.5 24T367-263l-27 23H140l126-125q-24-24-25-57.5t23-57.5l189-189Zm0 0 187-187q24-24 56.5-24t56.5 24l104 103q24 24 24 56.5T857-640L669-453 453-669Z",RemoveTextFormat:"m528-546-93-93-121-121h486v120H568l-40 94ZM792-56 460-388l-80 188H249l119-280L56-792l56-56 736 736-56 56Z",Quote:"m228-240 92-160q-66 0-113-47t-47-113q0-66 47-113t113-47q66 0 113 47t47 113q0 23-5.5 42.5T458-480L320-240h-92Zm360 0 92-160q-66 0-113-47t-47-113q0-66 47-113t113-47q66 0 113 47t47 113q0 23-5.5 42.5T818-480L680-240h-92ZM320-500q25 0 42.5-17.5T380-560q0-25-17.5-42.5T320-620q-25 0-42.5 17.5T260-560q0 25 17.5 42.5T320-500Zm360 0q25 0 42.5-17.5T740-560q0-25-17.5-42.5T680-620q-25 0-42.5 17.5T620-560q0 25 17.5 42.5T680-500Zm0-60Zm-360 0Z",VideoFile:"M360-240h160q17 0 28.5-11.5T560-280v-40l80 42v-164l-80 42v-40q0-17-11.5-28.5T520-480H360q-17 0-28.5 11.5T320-440v160q0 17 11.5 28.5T360-240ZM240-80q-33 0-56.5-23.5T160-160v-640q0-33 23.5-56.5T240-880h320l240 240v480q0 33-23.5 56.5T720-80H240Zm280-520v-200H240v640h480v-440H520ZM240-800v200-200 640-640Z",Table:"M120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200q-33 0-56.5-23.5T120-200Zm80-400h560v-160H200v160Zm213 200h134v-120H413v120Zm0 200h134v-120H413v120ZM200-400h133v-120H200v120Zm427 0h133v-120H627v120ZM200-200h133v-120H200v120Zm427 0h133v-120H627v120Z",IncreaseIndent:"M120-120v-80h720v80H120Zm320-160v-80h400v80H440Zm0-160v-80h400v80H440Zm0-160v-80h400v80H440ZM120-760v-80h720v80H120Zm0 440v-320l160 160-160 160Z",DecreaseIndent:"M120-120v-80h720v80H120Zm320-160v-80h400v80H440Zm0-160v-80h400v80H440Zm0-160v-80h400v80H440ZM120-760v-80h720v80H120Zm160 440L120-480l160-160v320Z",UploadImage:"M440-200h80v-167l64 64 56-57-160-160-160 160 57 56 63-63v167ZM240-80q-33 0-56.5-23.5T160-160v-640q0-33 23.5-56.5T240-880h320l240 240v480q0 33-23.5 56.5T720-80H240Zm280-520v-200H240v640h480v-440H520ZM240-800v200-200 640-640Z",SaveHtml:"m720-120 160-160-56-56-64 64v-167h-80v167l-64-64-56 56 160 160ZM560 0v-80h320V0H560ZM240-160q-33 0-56.5-23.5T160-240v-560q0-33 23.5-56.5T240-880h280l240 240v121h-80v-81H480v-200H240v560h240v80H240Zm0-80v-560 560Z",HorizontalRule:"M160-440v-80h640v80H160Z",StatusBar:"M200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Zm0-200v120h560v-120H568q-17 18-39.5 29T480-280q-26 0-48.5-11T392-320H200Zm308.5-51.5Q520-383 520-400t-11.5-28.5Q497-440 480-440t-28.5 11.5Q440-417 440-400t11.5 28.5Q463-360 480-360t28.5-11.5ZM200-400h160q0-50 35-85t85-35q50 0 85 35t35 85h160v-360H200v360Zm0 200h560-560Z"};class x extends HTMLElement{constructor(){super(),this._uid="rtb-"+Math.random().toString(36).substring(2,11),this._initialized=!1,this._value=null,this._visibility=x._defaultVisibility(!0),this._previewCssUrls=[],this._previewCssText=""}static _defaultVisibility(t=!0){return{font:t,size:t,format:t,textStylesDivider:t,bold:t,italic:t,underline:t,strikethrough:t,subscript:t,superscript:t,formatDivider:t,textColor:t,textColorDivider:t,alignLeft:t,alignCenter:t,alignRight:t,alignJustify:t,alignDivider:t,copy:t,cut:t,paste:t,delete:t,selectAll:t,actionDivider:t,orderedList:t,unorderedList:t,indent:t,listDivider:t,link:t,image:t,imageUpload:t,quote:t,codeBlock:t,embedMedia:t,video:t,table:t,horizontalRule:t,mediaDivider:t,undo:t,redo:t,historyDivider:t,saveHtml:t,htmlView:t,preview:t,statusBarToggle:t,wordCount:!1}}static _injectGlobalStyles(){if(document.getElementById("_rtb-global-styles"))return;const t=document.createElement("style");t.id="_rtb-global-styles",t.textContent="\n/* ── rt-native host defaults ──────────────────────────────────────────────\n Override any --rtb-* variable on rt-native (or a higher-specificity rule\n such as .my-wrapper rt-native or rt-native.my-class) to theme the editor.\n ──────────────────────────────────────────────────────────────────────── */\nrt-native {\n display: block;\n\n /* Toolbar — Fluent 2 colorNeutralBackground1 + colorNeutralStroke1 separator */\n --rtb-toolbar-bg: #ffffff;\n --rtb-toolbar-border-style: solid;\n --rtb-toolbar-border-width: 1px;\n --rtb-toolbar-border-color: #d1d1d1;\n --rtb-toolbar-border-radius: 0px;\n\n /* Toolbar dropdowns */\n --rtb-dropdown-bg: #ffffff;\n --rtb-dropdown-text: #242424;\n --rtb-dropdown-bg-hover: #f5f5f5;\n --rtb-dropdown-text-hover: #242424;\n\n /* Buttons — transparent at rest, no border */\n --rtb-btn-text: #242424;\n --rtb-btn-size: 16px;\n --rtb-btn-font: Arial, Helvetica, Verdana, sans-serif;\n --rtb-btn-bg: transparent;\n --rtb-btn-bg-hover: #e8e8e8;\n --rtb-btn-bg-selected: #dcdcdc;\n --rtb-btn-border-style: none;\n --rtb-btn-border-width: 0px;\n --rtb-btn-border-color: #d1d1d1;\n --rtb-btn-border-hover: inherit;\n --rtb-btn-border-selected: inherit;\n --rtb-btn-border-radius: 4px;\n\n /* Editor content area */\n --rtb-content-text: #242424;\n --rtb-content-size: 1rem;\n --rtb-content-font: Arial, Helvetica, Verdana, sans-serif;\n --rtb-content-bg: #ffffff;\n --rtb-content-shadow: none;\n --rtb-content-line-height: 1.55;\n --rtb-content-padding: 20px 24px;\n --rtb-heading-text: #242424;\n --rtb-heading-muted-text: #6b7280;\n --rtb-heading-font: Arial, Helvetica, Verdana, sans-serif;\n --rtb-heading-weight: 600;\n --rtb-heading-line-height: 1.2;\n --rtb-heading-margin: 0 0 0.55em;\n --rtb-h1-size: 2.15em;\n --rtb-h2-size: 1.65em;\n --rtb-h3-size: 1.35em;\n --rtb-h4-size: 1.15em;\n --rtb-h5-size: 1em;\n --rtb-h6-size: 0.92em;\n --rtb-paragraph-margin: 0 0 0.9em;\n --rtb-list-margin: 0.35em 0 0.9em 1.35em;\n --rtb-list-padding-left: 1.35em;\n --rtb-list-item-margin: 0.18em 0;\n --rtb-link-text: #0969da;\n --rtb-link-decoration: underline;\n --rtb-inline-code-bg: rgba(175, 184, 193, 0.2);\n --rtb-inline-code-border-radius: 4px;\n --rtb-code-font: Consolas, Monaco, 'Courier New', monospace;\n --rtb-inline-code-size: 0.92em;\n --rtb-inline-code-padding: 0.15em 0.35em;\n --rtb-hr-border: 1px solid #d1d1d1;\n --rtb-hr-margin: 1.25em 0;\n\n /* Blockquote — brand-blue left accent on a tinted surface */\n --rtb-quote-bg: #f9f9f9;\n --rtb-quote-border-color: #ccc;\n --rtb-quote-border-width: 5px;\n --rtb-quote-text: #242424;\n --rtb-quote-margin: 1.5em 10px;\n --rtb-quote-padding: 0.5em 10px;\n\n /* Code / pre — neutral surface, Fluent medium corner radius */\n --rtb-code-bg: #f5f5f5;\n --rtb-code-border-radius: 4px;\n --rtb-code-margin: 1.2em 0;\n --rtb-code-padding: 0.85em 1em;\n --rtb-table-margin: 1.2em 0;\n --rtb-table-width: auto;\n --rtb-table-border: 1px solid #d1d1d1;\n --rtb-table-cell-min-width: 100px;\n --rtb-table-cell-padding: 6px 10px;\n --rtb-table-header-bg: #f5f5f5;\n --rtb-table-header-text: #242424;\n --rtb-table-header-weight: 600;\n\n /* Editor container — hairline border + featherweight shadow */\n --rtb-editor-width: 100%;\n --rtb-editor-height: 300px;\n --rtb-editor-border-radius: 4px;\n --rtb-editor-border-style: solid;\n --rtb-editor-border-width: 1px;\n --rtb-editor-border-color: #d1d1d1;\n --rtb-editor-shadow: 0 2px 4px rgba(0, 0, 0, 0.06);\n --rtb-editor-resize: auto;\n\n /* Scrollbars — thin pill-shaped Fluent style */\n --rtb-scroll-width: 6px;\n --rtb-scroll-opacity: 1;\n --rtb-scroll-bg: transparent;\n --rtb-scroll-thumb-bg: #c2c2c2;\n --rtb-scroll-thumb-bg-hover: #8a8a8a;\n --rtb-scroll-thumb-radius: 3px;\n\n /* Placeholder */\n --rtb-placeholder-color: #9ca3af;\n\n /* Stacking context — raise the entire editor above surrounding content */\n --rtb-z-index: 1;\n\n /* Modals / dialogs */\n --rtb-modal-bg: #ffffff;\n --rtb-modal-text: #242424;\n --rtb-modal-text-size: 1rem;\n --rtb-modal-text-font: Arial, Helvetica, Verdana, sans-serif;\n --rtb-modal-input-bg: #ffffff;\n --rtb-modal-input-text: #242424;\n --rtb-modal-input-border: #d1d1d1;\n --rtb-modal-checkbox: #0078d4;\n}\n\nrt-native.light,\nrt-native.fluent {\n --rtb-toolbar-bg: #ffffff;\n --rtb-toolbar-border-color: #d1d1d1;\n --rtb-dropdown-bg: #ffffff;\n --rtb-dropdown-text: #242424;\n --rtb-dropdown-bg-hover: #f5f5f5;\n --rtb-dropdown-text-hover: #242424;\n --rtb-btn-text: #242424;\n --rtb-btn-bg: transparent;\n --rtb-btn-bg-hover: #e8e8e8;\n --rtb-btn-bg-selected: #dcdcdc;\n --rtb-btn-border-color: #d1d1d1;\n\n --rtb-content-text: #242424;\n --rtb-content-bg: #ffffff;\n --rtb-heading-text: #242424;\n --rtb-heading-muted-text: #6b7280;\n --rtb-link-text: #0969da;\n --rtb-inline-code-bg: rgba(175, 184, 193, 0.2);\n --rtb-hr-border: 1px solid #d1d1d1;\n\n --rtb-quote-bg: #f9f9f9;\n --rtb-quote-border-color: #ccc;\n --rtb-quote-text: #242424;\n\n --rtb-code-bg: #f5f5f5;\n --rtb-table-border: 1px solid #d1d1d1;\n --rtb-table-header-bg: #f5f5f5;\n --rtb-table-header-text: #242424;\n\n --rtb-editor-border-color: #d1d1d1;\n --rtb-editor-shadow: 0 2px 4px rgba(0, 0, 0, 0.06);\n --rtb-scroll-thumb-bg: #c2c2c2;\n --rtb-scroll-thumb-bg-hover: #8a8a8a;\n --rtb-placeholder-color: #9ca3af;\n\n --rtb-modal-bg: #ffffff;\n --rtb-modal-text: #242424;\n --rtb-modal-input-bg: #ffffff;\n --rtb-modal-input-text: #242424;\n --rtb-modal-input-border: #d1d1d1;\n}\n\nrt-native.dark,\nrt-native.fluent-dark {\n --rtb-toolbar-bg: #1f1f1f;\n --rtb-toolbar-border-color: #3f3f46;\n --rtb-dropdown-bg: #242424;\n --rtb-dropdown-text: #f5f5f5;\n --rtb-dropdown-bg-hover: #323238;\n --rtb-dropdown-text-hover: #ffffff;\n --rtb-btn-text: #f5f5f5;\n --rtb-btn-bg: transparent;\n --rtb-btn-bg-hover: #323238;\n --rtb-btn-bg-selected: #3f3f46;\n --rtb-btn-border-color: #3f3f46;\n\n --rtb-content-text: #f5f5f5;\n --rtb-content-bg: #1f1f1f;\n --rtb-heading-text: #ffffff;\n --rtb-heading-muted-text: #a1a1aa;\n --rtb-link-text: #7ab7ff;\n --rtb-inline-code-bg: rgba(255, 255, 255, 0.12);\n --rtb-hr-border: 1px solid #3f3f46;\n\n --rtb-quote-bg: #10243a;\n --rtb-quote-border-color: #479ef5;\n --rtb-quote-text: #eef6ff;\n\n --rtb-code-bg: #141414;\n --rtb-table-border: 1px solid #52525b;\n --rtb-table-header-bg: #2b2b2b;\n --rtb-table-header-text: #ffffff;\n\n --rtb-editor-border-color: #3f3f46;\n --rtb-editor-shadow: none;\n --rtb-scroll-thumb-bg: #5c5c5c;\n --rtb-scroll-thumb-bg-hover: #7a7a7a;\n --rtb-placeholder-color: #a1a1aa;\n\n --rtb-modal-bg: #242424;\n --rtb-modal-text: #f5f5f5;\n --rtb-modal-input-bg: #1f1f1f;\n --rtb-modal-input-text: #f5f5f5;\n --rtb-modal-input-border: #52525b;\n}\n\n",document.head.appendChild(t)}static get observedAttributes(){return["value","width","height","config","placeholder","readonly","aria-label","label"]}attributeChangedCallback(t,e,o){if(e!==o){if("value"===t&&this._initialized&&(this._value=o||"",RTNative_Method("loadView",this._uid,o)),"width"===t&&this.style.setProperty("--rtb-editor-width",o||"100%"),"height"===t&&this.style.setProperty("--rtb-editor-height",o||"300px"),"config"===t)try{this.configure(JSON.parse(o))}catch(t){}if("placeholder"===t){const t=RTNative_Instances?.[this._uid];t?.content&&(o?t.content.setAttribute("data-placeholder",o):t.content.removeAttribute("data-placeholder"))}if("readonly"===t){const t=RTNative_Instances?.[this._uid];t&&t.setReadOnly(null!==o)}if("aria-label"===t||"label"===t){const t=RTNative_Instances?.[this._uid];t?.content&&o&&t.content.setAttribute("aria-label",o)}}}connectedCallback(){x._injectGlobalStyles(),this.style.setProperty("--rtb-editor-width",this.getAttribute("width")||"100%"),this.style.setProperty("--rtb-editor-height",this.getAttribute("height")||"300px"),this._render(),requestAnimationFrame(()=>this._initialize())}get readOnly(){return this.hasAttribute("readonly")}setReadOnly(t){t?this.setAttribute("readonly",""):this.removeAttribute("readonly")}disconnectedCallback(){window.RTNative_Instances?.[this._uid]&&delete RTNative_Instances[this._uid]}getValue(){return this._initialized?RTNative_Method("html",this._uid)||this._value||"":this._value||""}getPlainText(){return this._initialized&&RTNative_Method("plaintext",this._uid)||""}setValue(t){const e=(t||"").trim().replace(/>\s+</g,"><");this._value=e,this._initialized&&RTNative_Method("loadView",this._uid,e)}setPreviewCssFiles(...t){this._previewCssUrls=t.filter(t=>t&&"string"==typeof t),this._syncToInstance(),this._applyContentStyles()}setPreviewCssFile(t){this.setPreviewCssFiles(...t?[t]:[])}setPreviewCss(t){this._previewCssText=t||"",this._syncToInstance(),this._applyContentStyles()}_syncToInstance(){if(!this._initialized)return;const t=RTNative_Instances[this._uid];t&&(t._previewCssUrls=this._previewCssUrls,t._previewCssText=this._previewCssText)}_scopeCssText(t,e){t=t.replace(/\/\*[\s\S]*?\*\//g,"");let o="",i=0;for(;i<t.length;){for(;i<t.length&&/\s/.test(t[i]);)i++;if(i>=t.length)break;const n=t.indexOf("{",i);if(-1===n)break;const r=t.slice(i,n).trim();let s=1,l=n+1;for(;l<t.length&&s>0;)"{"===t[l]?s++:"}"===t[l]&&s--,l++;const a=t.slice(n+1,l-1);if(i=l,r)if(r.startsWith("@")){const t=(r.match(/^@[\w-]+/)||[""])[0].toLowerCase();["@media","@supports","@layer","@container"].includes(t)?o+=r+" {\n"+this._scopeCssText(a,e)+"}\n":o+=r+" {"+a+"}\n"}else{o+=r.split(",").map(t=>t.trim()).filter(t=>t).map(t=>":root"===t?e:e+" "+t).join(",\n")+" {"+a+"}\n"}}return o}async _applyContentStyles(){if(!this._initialized)return;const t=RTNative_Instances[this._uid];if(!t||!t.shadowRoot)return;const e=t.shadowRoot.getElementById("_rtb-content-preview-styles");e&&e.remove();const o=".rich-text-box-content";let i="";for(const t of this._previewCssUrls)try{const e=await fetch(t);e.ok?i+=this._scopeCssText(await e.text(),o)+"\n":console.warn(`rt-native: failed to load preview CSS (${e.status}): ${t}`)}catch(e){console.warn(`rt-native: could not load preview CSS: ${t}`,e)}if(this._previewCssText&&(i+=this._scopeCssText(this._previewCssText,o)+"\n"),i.trim()){const e=document.createElement("style");e.id="_rtb-content-preview-styles",e.textContent=i,t.shadowRoot.appendChild(e)}}configure(t={}){const{visibility:e,...o}=t;e&&(e.clearAll&&(this._visibility=x._defaultVisibility(!1)),Object.assign(this._visibility,e)),this._applyCSSVars(o),this._syncPreviewTheme(),this._initialized&&e&&this._reinitialize()}_syncPreviewTheme(){}_applyCSSVars(t){const set=(t,e)=>{null!=e&&this.style.setProperty(t,e)},e=t.toolbar||{};set("--rtb-toolbar-bg",e.backgroundColor),set("--rtb-toolbar-border-style",e.borderStyle),set("--rtb-toolbar-border-width",e.borderWidth),set("--rtb-toolbar-border-color",e.borderColor),set("--rtb-toolbar-border-radius",e.borderRadius),set("--rtb-dropdown-bg",e.dropdownBackgroundColor),set("--rtb-dropdown-text",e.dropdownTextColor),set("--rtb-dropdown-bg-hover",e.dropdownBackgroundColorHover),set("--rtb-dropdown-text-hover",e.dropdownTextColorHover);const o=t.button||{};set("--rtb-btn-text",o.textColor),set("--rtb-btn-size",o.textSize),set("--rtb-btn-font",o.textFont),set("--rtb-btn-bg",o.backgroundColor),set("--rtb-btn-bg-hover",o.backgroundColorHover),set("--rtb-btn-bg-selected",o.backgroundColorSelected),set("--rtb-btn-border-style",o.borderStyle),set("--rtb-btn-border-width",o.borderWidth),set("--rtb-btn-border-color",o.borderColor),set("--rtb-btn-border-hover",o.borderColorHover),set("--rtb-btn-border-selected",o.borderColorSelected),set("--rtb-btn-border-radius",o.borderRadius);const i=t.content||{};set("--rtb-content-text",i.textColor),set("--rtb-content-size",i.textSize),set("--rtb-content-font",i.textFont),set("--rtb-content-bg",i.backgroundColor),set("--rtb-content-shadow",i.boxShadow);const n=t.editor||{};set("--rtb-editor-width",n.width),set("--rtb-editor-height",n.height),set("--rtb-editor-border-radius",n.borderRadius),set("--rtb-editor-border-style",n.borderStyle),set("--rtb-editor-border-width",n.borderWidth),set("--rtb-editor-border-color",n.borderColor),set("--rtb-editor-shadow",n.boxShadow),null!=n.removeResizeHandle&&set("--rtb-editor-resize",n.removeResizeHandle?"visible":"auto");const r=t.scroll||{};set("--rtb-scroll-width",r.width),set("--rtb-scroll-opacity",r.opacity),set("--rtb-scroll-bg",r.backgroundColor),set("--rtb-scroll-thumb-bg",r.thumbBackground),set("--rtb-scroll-thumb-bg-hover",r.thumbBackgroundHover),set("--rtb-scroll-thumb-radius",r.thumbBorderRadius);const s=t.modal||{};set("--rtb-modal-bg",s.backgroundColor),set("--rtb-modal-text",s.textColor),set("--rtb-modal-text-size",s.textSize),set("--rtb-modal-text-font",s.textFont),set("--rtb-modal-input-bg",s.textboxBackgroundColor),set("--rtb-modal-input-text",s.textboxTextColor),set("--rtb-modal-input-border",s.textboxBorderColor),set("--rtb-modal-checkbox",s.checkboxAccentColor);const l=t.quote||{};set("--rtb-quote-bg",l.backgroundColor),set("--rtb-quote-border-color",l.borderColor),set("--rtb-quote-border-width",l.borderWidth);const a=t.code||{};set("--rtb-code-bg",a.backgroundColor),set("--rtb-code-border-radius",a.borderRadius)}_render(){this.innerHTML=this._buildToolbarHTML()+`<div id="${this._uid}_Shadow"></div>`}_initialize(){const e=this.getAttribute("value")||"",o=null!==this._value?this._value:e;this._value=o;const onValueChange=t=>{this._value=t,this.dispatchEvent(new CustomEvent("change",{detail:{value:t},bubbles:!0,composed:!0}))};window.RTNative_Instances||(window.RTNative_Instances={}),RTNative_Instances[this._uid]=new t(this._uid,`${this._uid}_Shadow`,`${this._uid}_Toolbar`,'\n.rich-text-box-tool-bar {\n background-color: var(--rtb-toolbar-bg, #FFF);\n border-bottom-style: var(--rtb-toolbar-border-style, solid);\n border-bottom-width: var(--rtb-toolbar-border-width, 1px);\n border-bottom-color: var(--rtb-toolbar-border-color, #EEE);\n border-radius: var(--rtb-toolbar-border-radius, 0px);\n padding-left: 3px;\n display: flex;\n flex-wrap: wrap;\n justify-content: flex-start;\n}\n.rich-text-box-tool-bar button {\n background-color: var(--rtb-btn-bg, inherit);\n border-style: var(--rtb-btn-border-style, none);\n border-width: var(--rtb-btn-border-width, 0px);\n border-color: var(--rtb-btn-border-color, #AAA);\n border-radius: var(--rtb-btn-border-radius, 5px);\n color: var(--rtb-btn-text, #000);\n outline: none;\n cursor: pointer;\n transition: 0.3s;\n min-height: calc(var(--rtb-btn-size, 16px) + 14px);\n font-family: var(--rtb-btn-font, Arial, sans-serif);\n margin: 4px 1px;\n}\n.rich-text-box-tool-bar button:hover {\n background-color: var(--rtb-btn-bg-hover, #e8e8e8);\n border-color: var(--rtb-btn-border-hover, inherit);\n}\n.rich-text-box-tool-bar button.selected {\n background-color: var(--rtb-btn-bg-selected, #dcdcdc);\n border-color: var(--rtb-btn-border-selected, inherit);\n}\n.rich-text-box-tool-bar button:disabled {\n background-color: transparent;\n color: #999;\n cursor: default;\n}\n.rich-text-box-tool-bar button svg {\n fill: var(--rtb-btn-text, #000);\n width: var(--rtb-btn-size, 16px);\n height: var(--rtb-btn-size, 16px);\n}\n.rich-text-box-tool-bar button:hover svg {\n fill: var(--rtb-btn-text, #000);\n}\n.rich-text-box-tool-bar button:disabled svg {\n fill: #999;\n}\n.rich-text-box-menu-item {}\n.rich-text-box-menu-item-special {}\n.rich-text-box-menu-item svg,\n.rich-text-box-menu-item-special svg {\n display: block;\n height: auto;\n width: auto;\n max-height: 100%;\n max-width: 100%;\n}\n.rich-text-box-menu-item:disabled { color: #999; }\n\n.rich-text-box-container {\n resize: both;\n overflow: var(--rtb-editor-resize, auto);\n border-style: var(--rtb-editor-border-style, solid);\n border-width: var(--rtb-editor-border-width, 1px);\n border-color: var(--rtb-editor-border-color, #EEE);\n border-radius: var(--rtb-editor-border-radius, 0px);\n box-shadow: var(--rtb-editor-shadow, none);\n max-width: var(--rtb-editor-width, 100%);\n height: var(--rtb-editor-height, 300px);\n display: flex;\n flex-direction: column;\n z-index: var(--rtb-z-index, 1);\n}\n.rich-text-box-content-container {\n width: 100%;\n height: 100%;\n overflow: auto;\n display: flex;\n flex-direction: row;\n background-color: var(--rtb-content-bg, #FFF);\n box-shadow: var(--rtb-content-shadow, none);\n}\n.rtb-status-bar {\n /* Mirror the toolbar\'s background and typography so every theme is\n automatically reflected without adding status-bar-specific CSS vars. */\n background-color: var(--rtb-toolbar-bg, #ffffff);\n color: var(--rtb-btn-text, #242424);\n font-family: var(--rtb-btn-font, Arial, Helvetica, Verdana, sans-serif);\n font-size: calc(var(--rtb-btn-size, 16px) * 0.9);\n border-top: 1px solid var(--rtb-toolbar-border-color, #d1d1d1);\n padding: 5px 24px 5px 10px;\n text-align: right;\n user-select: none;\n flex-shrink: 0;\n letter-spacing: 0.2px;\n}\n.rich-text-box-content[data-placeholder]:empty::before {\n content: attr(data-placeholder);\n color: var(--rtb-placeholder-color, #9ca3af);\n pointer-events: none;\n font-style: italic;\n}\n.rich-text-box-content[contenteditable="false"] {\n cursor: default;\n opacity: 0.85;\n}\n.rich-text-box-content {\n color: var(--rtb-content-text, #000);\n font-size: var(--rtb-content-size, 16px);\n font-family: var(--rtb-content-font, Arial, sans-serif);\n line-height: var(--rtb-content-line-height, 1.55);\n padding: var(--rtb-content-padding, 20px 24px);\n width: 100%;\n min-height: 25px;\n white-space: pre-wrap;\n word-wrap: break-word;\n outline: 0px solid transparent;\n}\n.rich-text-box-content h1,\n.rich-text-box-content h2,\n.rich-text-box-content h3,\n.rich-text-box-content h4,\n.rich-text-box-content h5,\n.rich-text-box-content h6 {\n color: var(--rtb-heading-text, var(--rtb-content-text, #242424));\n font-family: var(--rtb-heading-font, var(--rtb-content-font, Arial, sans-serif));\n font-weight: var(--rtb-heading-weight, 600);\n line-height: var(--rtb-heading-line-height, 1.2);\n margin: var(--rtb-heading-margin, 0 0 0.55em);\n padding: 0;\n border: 0;\n border-bottom: 0;\n text-decoration: none !important;\n}\n.rich-text-box-content h1 { font-size: var(--rtb-h1-size, 2.15em); }\n.rich-text-box-content h2 { font-size: var(--rtb-h2-size, 1.65em); }\n.rich-text-box-content h3 { font-size: var(--rtb-h3-size, 1.35em); }\n.rich-text-box-content h4 { font-size: var(--rtb-h4-size, 1.15em); }\n.rich-text-box-content h5 { font-size: var(--rtb-h5-size, 1em); }\n.rich-text-box-content h6 {\n color: var(--rtb-heading-muted-text, #6b7280);\n font-size: var(--rtb-h6-size, 0.92em);\n}\n.rich-text-box-content p { margin: var(--rtb-paragraph-margin, 0 0 0.9em); }\n.rich-text-box-content ul,\n.rich-text-box-content ol {\n margin: var(--rtb-list-margin, 0.35em 0 0.9em 1.35em);\n padding-left: var(--rtb-list-padding-left, 1.35em);\n}\n.rich-text-box-content li { margin: var(--rtb-list-item-margin, 0.18em 0); }\n.rich-text-box-content a {\n color: var(--rtb-link-text, #0969da);\n text-decoration: var(--rtb-link-decoration, underline);\n}\n.rich-text-box-content blockquote {\n background: var(--rtb-quote-bg, #f9f9f9);\n border-left: var(--rtb-quote-border-width, 5px) solid var(--rtb-quote-border-color, #ccc);\n color: var(--rtb-quote-text, var(--rtb-content-text, #242424));\n margin: var(--rtb-quote-margin, 1.5em 10px);\n padding: var(--rtb-quote-padding, 0.5em 10px);\n}\n.rich-text-box-content blockquote > :first-child {\n margin-top: 0;\n}\n.rich-text-box-content blockquote > :last-child {\n margin-bottom: 0;\n}\n.rich-text-box-content code {\n background: var(--rtb-inline-code-bg, rgba(175, 184, 193, 0.2));\n border-radius: var(--rtb-inline-code-border-radius, 4px);\n font-family: var(--rtb-code-font, Consolas, Monaco, \'Courier New\', monospace);\n font-size: var(--rtb-inline-code-size, 0.92em);\n padding: var(--rtb-inline-code-padding, 0.15em 0.35em);\n}\n.rich-text-box-content pre {\n background: var(--rtb-code-bg, #f5f5f5);\n border-radius: var(--rtb-code-border-radius, 4px);\n margin: var(--rtb-code-margin, 1.2em 0);\n overflow-x: auto;\n padding: var(--rtb-code-padding, 0.85em 1em);\n white-space: pre-wrap;\n}\n.rich-text-box-content pre code {\n background: transparent;\n border-radius: 0;\n display: block;\n padding: 0;\n}\n.rich-text-box-content hr {\n border: 0;\n border-top: var(--rtb-hr-border, 1px solid #d1d1d1);\n margin: var(--rtb-hr-margin, 1.25em 0);\n}\n.rich-text-box-content table {\n border-collapse: collapse;\n margin: var(--rtb-table-margin, 1.2em 0);\n width: var(--rtb-table-width, auto);\n}\n.rich-text-box-content th,\n.rich-text-box-content td {\n border: var(--rtb-table-border, 1px solid #d1d1d1);\n min-width: var(--rtb-table-cell-min-width, 100px);\n padding: var(--rtb-table-cell-padding, 6px 10px);\n}\n.rich-text-box-content th {\n background: var(--rtb-table-header-bg, #f5f5f5);\n color: var(--rtb-table-header-text, var(--rtb-content-text, #242424));\n font-weight: var(--rtb-table-header-weight, 600);\n}\n.rich-text-box-content img { cursor: pointer; }\n.rich-text-box-source {\n padding: 10px;\n width: 100%;\n min-height: 25px;\n color: var(--rtb-content-text, #000) !important;\n font-size: var(--rtb-content-size, 16px) !important;\n white-space: pre-wrap;\n background-color: var(--rtb-content-bg, #FFF);\n box-shadow: var(--rtb-content-shadow, none);\n border-style: none;\n display: none;\n resize: none;\n margin: 0;\n line-height: 1.6;\n outline: 0px solid transparent;\n}\n.rich-text-box-divider-btn {\n background-color: inherit;\n align-items: center;\n justify-content: center;\n text-align: center;\n border: none !important;\n outline: none;\n cursor: pointer;\n padding: 3px 4px;\n transition: 0.3s;\n margin: 4px 1px;\n}\n.rich-text-box-divider-btn[disabled],\n.rich-text-box-divider-btn[disabled]:hover,\n.rich-text-box-divider-btn[disabled]:focus,\n.rich-text-box-divider-btn[disabled]:active {\n background: unset;\n color: unset;\n cursor: default;\n}\n.rich-text-box-divider {\n min-height: 25px;\n height: var(--rtb-btn-size, 16px);\n background-color: var(--rtb-btn-text, #000);\n display: block;\n border-left: 0.5px solid rgba(255, 255, 255, 0.6);\n opacity: 0.5;\n}\n.rich-text-box-scroll::-webkit-scrollbar {\n height: var(--rtb-scroll-width, 10px);\n width: var(--rtb-scroll-width, 10px);\n opacity: var(--rtb-scroll-opacity, 1);\n}\n.rich-text-box-scroll::-webkit-scrollbar-track {\n background-color: var(--rtb-scroll-bg, transparent);\n}\n.rich-text-box-scroll::-webkit-scrollbar-thumb {\n background: var(--rtb-scroll-thumb-bg, #AAA);\n border-radius: var(--rtb-scroll-thumb-radius, 0);\n}\n.rich-text-box-scroll::-webkit-scrollbar-thumb:hover {\n background: var(--rtb-scroll-thumb-bg-hover, #DDD);\n cursor: default;\n}\n.rich-text-box-dropdown { position: relative; display: inline-block; }\n.rich-text-box-dropdown-content {\n display: none;\n position: absolute;\n background-color: var(--rtb-dropdown-bg, #FFF);\n border-style: var(--rtb-btn-border-style, none);\n border-width: var(--rtb-btn-border-width, 0px);\n border-color: var(--rtb-btn-border-color, #AAA);\n border-radius: 5px;\n max-height: 200px;\n overflow: auto;\n box-shadow: 0px 4px 8px 0px rgba(0, 0, 0, 0.2);\n font-family: Arial, sans-serif !important;\n z-index: 2;\n}\n.rich-text-box-dropdown-btn {\n font-size: var(--rtb-btn-size, 16px);\n min-height: calc(var(--rtb-btn-size, 16px) + 14px);\n padding: 0 10px;\n}\n.rich-text-box-font-button,\n.rich-text-box-size-button,\n.rich-text-box-format-button {\n font-family: var(--rtb-btn-font, Arial, sans-serif);\n font-size: calc(var(--rtb-btn-size, 16px) * 0.9);\n font-weight: 400;\n line-height: normal;\n}\n.rich-text-box-format-content { min-width: 185px; }\n.rich-text-box-font-content { min-width: 180px; }\n.rich-text-box-size-content { min-width: 80px; }\n.rich-text-box-dropdown-content a {\n color: var(--rtb-dropdown-text, #000);\n font-size: 18px;\n padding: 10px 14px;\n text-decoration: none;\n display: block;\n}\n.rich-text-box-dropdown a:hover,\n.rich-text-box-menu-item.active {\n background-color: var(--rtb-dropdown-bg-hover, #e5e5e5);\n color: var(--rtb-dropdown-text-hover, #000);\n}\n.rich-text-box-show { display: block; }\n\n.rich-text-box-modal {\n background-color: var(--rtb-modal-bg, #fefefe);\n color: var(--rtb-modal-text, #000);\n font-size: var(--rtb-modal-text-size, 16px);\n font-family: var(--rtb-modal-text-font, Arial, sans-serif);\n margin: auto;\n padding: 6px 16px 14px;\n border: 1px solid #888;\n width: 800px;\n box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);\n border-radius: 5px;\n user-select: none;\n z-index: 2;\n}\n.rich-text-box-modal-title {\n font-weight: bold;\n font-size: calc(var(--rtb-modal-text-size, 16px) + 2px);\n}\n.rtb-modal-header {\n display: flex;\n flex-direction: row;\n justify-content: space-between;\n align-items: center;\n flex-shrink: 0;\n padding-bottom: 10px;\n}\n.rich-text-box-form-left { float: left; width: 380px; }\n.rich-text-box-form-right { float: right; width: 380px; }\n@media screen and (max-width: 850px) {\n .rich-text-box-form-left,\n .rich-text-box-form-right { float: none; }\n .rich-text-box-modal { width: 400px; }\n}\n@media screen and (max-width: 500px) {\n .rich-text-box-modal { width: 100%; }\n}\n.clearfix { overflow: auto; }\n.clearfix::after { content: ""; clear: both; display: table; }\n.rich-text-box-modal-close {\n appearance: none;\n background: none;\n border: none;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n flex-shrink: 0;\n align-self: center;\n width: 32px;\n height: 32px;\n min-width: 32px;\n min-height: 32px;\n max-width: 32px;\n max-height: 32px;\n border-radius: 50%;\n padding: 0;\n color: var(--rtb-modal-text, #000);\n cursor: pointer;\n opacity: 0.75;\n}\n/* SVG icon inside the close button — block display eliminates inline\n baseline offset so the flex centering acts on the icon bounds only.\n Width/height are set via CSS (not just SVG attributes) so the size is\n reliably enforced regardless of browser presentation-attribute handling. */\n.rich-text-box-modal-close svg { display: block; width: 11px; height: 11px; }\n.rich-text-box-modal-close:hover {\n opacity: 1;\n background: rgba(128, 128, 128, 0.18);\n}\n.rich-text-box-modal-close:focus-visible {\n outline: 2px solid currentColor;\n outline-offset: 1px;\n}\n.rich-text-box-modal-body { padding: 2px 8px; }\n.rtb-preview-window {\n flex: 1;\n min-height: 0;\n width: 100%;\n overflow: auto;\n border: 1px solid var(--rtb-editor-border-color, #eee);\n border-radius: 4px;\n box-sizing: border-box;\n display: block;\n}\n.rtb-preview-window::-webkit-scrollbar {\n height: var(--rtb-scroll-width, 10px);\n width: var(--rtb-scroll-width, 10px);\n}\n.rtb-preview-window::-webkit-scrollbar-track { background: transparent; }\n.rtb-preview-window::-webkit-scrollbar-thumb {\n background: var(--rtb-scroll-thumb-bg, #AAA);\n border-radius: var(--rtb-scroll-thumb-radius, 0);\n}\n.rtb-preview-window::-webkit-scrollbar-thumb:hover {\n background: var(--rtb-scroll-thumb-bg-hover, #DDD);\n}\n/* Preview dialog — flex column layout so the dialog itself is resizable and\n the html viewer automatically fills the remaining space.\n display is intentionally NOT set here so the browser UA rule\n dialog:not([open]){display:none} still applies when the dialog is closed.\n display:flex is only added when the dialog is open (has the [open] attr). */\n.rtb-preview-dialog {\n padding: 6px 12px 10px;\n flex-direction: column;\n height: 520px;\n min-width: 400px;\n min-height: 300px;\n max-width: 95vw;\n max-height: 95vh;\n resize: both;\n overflow: hidden;\n box-sizing: border-box;\n position: fixed;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n margin: 0;\n z-index: 9999;\n}\n.rtb-preview-dialog[open] {\n display: flex;\n}\n.rtb-preview-dialog::backdrop {\n background: transparent;\n}\n.rtb-preview-dialog-body {\n display: flex;\n flex-direction: column;\n flex: 1;\n min-height: 0;\n overflow: hidden;\n gap: 6px;\n}\n.rich-text-box-form-element {\n width: 100%;\n padding: 10px;\n font-size: var(--rtb-modal-text-size, 16px);\n font-family: var(--rtb-modal-text-font, Arial, sans-serif);\n background-color: var(--rtb-modal-input-bg, #fff);\n color: var(--rtb-modal-input-text, #000);\n border-width: 1px;\n border-style: solid;\n border-color: var(--rtb-modal-input-border, #CCC);\n outline: 0;\n border-radius: 0px;\n box-sizing: border-box;\n margin-top: 0px;\n margin-bottom: 16px;\n resize: vertical;\n}\n.rich-text-box-form-element:disabled {\n color: #999;\n border-color: #DDD;\n cursor: default;\n}\n.rich-text-box-form-checkbox {\n outline: none;\n width: 20px;\n height: 20px;\n margin-right: 8px;\n accent-color: var(--rtb-modal-checkbox, #007bff);\n}\n.rich-text-box-form-checkbox:focus {\n border-style: solid;\n border-color: var(--rtb-modal-input-border, #CCC);\n border-width: 1px;\n box-shadow: 0 0 5px 2px rgba(169, 169, 169, 0.8);\n}\n.rich-text-box-upload-btn {\n padding: 10px 20px !important;\n font-size: var(--rtb-modal-text-size, 16px);\n font-family: var(--rtb-modal-text-font, Arial, sans-serif);\n transition: 0.3s;\n background-color: var(--rtb-btn-bg, inherit);\n border: 1px solid var(--rtb-btn-border-color, #AAA);\n border-radius: var(--rtb-btn-border-radius, 5px);\n color: var(--rtb-btn-text, #000);\n outline: none;\n cursor: pointer;\n min-width: 100% !important;\n min-height: calc(var(--rtb-btn-size, 16px) + 14px);\n font-family: var(--rtb-btn-font, Arial, sans-serif);\n margin: 4px 1px;\n}\n.rich-text-box-upload-btn:hover {\n background-color: var(--rtb-btn-bg-hover, #e8e8e8);\n border-color: var(--rtb-btn-border-hover, inherit);\n}\n.rich-text-box-form-button {\n padding: 10px 20px !important;\n font-size: var(--rtb-modal-text-size, 16px);\n font-family: var(--rtb-modal-text-font, Arial, sans-serif);\n transition: 0.3s;\n}\n.rich-text-box-form-button:focus {\n background-color: var(--rtb-btn-bg-hover, #e8e8e8);\n border-color: var(--rtb-btn-border-hover, inherit);\n}\n.blazing-rich-text-color-picker-container { position: relative; }\n.blazing-rich-text-color-picker-button { min-height: calc(var(--rtb-btn-size, 16px) + 14px); }\n.blazing-rich-text-color-picker-dropdown { width: 80px; padding: 10px 10px 6px 10px; }\n.blazing-rich-text-color-option {\n width: 15px; height: 15px; margin: 2px; cursor: pointer;\n display: inline-block; border: 1px solid #999;\n}\n.blazing-rich-text-color-option:hover { border-color: #000; }\n.blazing-rich-text-color-selection {\n width: 100%; border-style: solid; border-width: 1px; border-color: #999;\n height: 40px; cursor: pointer; display: inline-block;\n}\n.rich-text-box-quote { font-family: var(--rtb-modal-text-font, Arial, sans-serif); }\n.rich-text-box-code { overflow: auto !important; white-space: pre; }\n.rich-text-box-message-bar {\n font-size: var(--rtb-content-size, 16px);\n background-color: rgba(0, 0, 0, 0.6);\n color: white;\n display: flex;\n justify-content: space-between;\n align-items: center;\n padding: 5px 10px;\n opacity: 1;\n transform: translateY(0);\n transition: opacity 0.2s ease-in-out, transform 0.2s ease-in-out;\n pointer-events: auto;\n}\n.rich-text-box-message-bar.rich-text-box-message-hidden {\n opacity: 0; height: 0; padding: 0; color: transparent; pointer-events: none;\n}\n.rich-text-box-message {}\n.rich-text-box-message-close-button {\n background: none; border: none; color: white; font-size: 18px; cursor: pointer;\n}\n.rich-text-box-color-picker { width: 100%; }\n.rich-text-box-color-display { width: 100%; height: 50px; border: 1px solid #ccc; margin: 20px 0; }\n.rich-text-box-slider-container { display: flex; align-items: center; margin-bottom: 10px; }\n.rich-text-box-slider-container label {\n width: 20px; margin-right: 10px;\n color: var(--rtb-modal-text, #000);\n}\n.rich-text-box-range { width: 100%; -webkit-appearance: none; cursor: pointer; }\n.rich-text-box-range:focus { outline: none; }\n.rich-text-box-range::-webkit-slider-runnable-track {\n background: var(--rtb-modal-text, #000); height: 5px;\n}\n.rich-text-box-red-slider::-webkit-slider-runnable-track {\n background: linear-gradient(to right, rgb(0,0,0) 0%, rgb(255,0,0) 100%) !important;\n}\n.rich-text-box-green-slider::-webkit-slider-runnable-track {\n background: linear-gradient(to right, rgb(0,0,0) 0%, rgb(0,255,0) 100%) !important;\n}\n.rich-text-box-blue-slider::-webkit-slider-runnable-track {\n background: linear-gradient(to right, rgb(0,0,0) 0%, rgb(0,0,255) 100%) !important;\n}\n.rich-text-box-range::-moz-range-track {\n background: var(--rtb-modal-text, #000); height: 5px;\n}\n.rich-text-box-range::-webkit-slider-thumb {\n -webkit-appearance: none; height: 15px; width: 15px;\n background: var(--rtb-modal-bg, #fefefe);\n margin-top: -5px; border-style: solid; border-width: 3px;\n border-color: var(--rtb-modal-text, #000); border-radius: 50%;\n}\n.rich-text-box-range::-moz-range-thumb {\n -webkit-appearance: none; height: 15px; width: 15px;\n background: var(--rtb-modal-bg, #fefefe);\n margin-top: -5px; border-style: solid; border-width: 3px;\n border-color: var(--rtb-modal-text, #000); border-radius: 50%;\n}\n.rich-text-box-number {\n width: 100px; margin-left: 10px; padding: 5px; font-size: 14px;\n background-color: var(--rtb-modal-input-bg, #fff);\n color: var(--rtb-modal-input-text, #000);\n border-width: 1px; border-style: solid;\n border-color: var(--rtb-modal-input-border, #CCC);\n outline: 0; border-radius: 0px; box-sizing: border-box;\n}\n.rich-text-box-hex-container { display: flex; align-items: center; margin-top: 20px; }\n.rich-text-box-hex-input { width: 100px !important; margin-left: 10px; }\nblockquote {\n background: var(--rtb-quote-bg, #f9f9f9);\n border-left: var(--rtb-quote-border-width, 5px) solid var(--rtb-quote-border-color, #ccc);\n color: var(--rtb-quote-text, var(--rtb-content-text, #242424));\n margin: var(--rtb-quote-margin, 1.5em 10px);\n padding: var(--rtb-quote-padding, 0.5em 10px);\n}\npre {\n background: var(--rtb-code-bg, #f9f9f9);\n border-radius: var(--rtb-code-border-radius, 10px);\n overflow-x: auto; white-space: pre-wrap; margin: 1.5em 10px; padding: 0.5em 10px;\n}\ntable { border-collapse: collapse; }\ntd, th { border: 1px solid #ccc; padding: 4px 6px; height: 25px; min-width: 100px; }\n',{invokeMethodAsync:(t,e)=>onValueChange(e)}),RTNative_Instances[this._uid]._rtbHostElement=this;const i=this.getAttribute("aria-label")||this.getAttribute("label");i&&RTNative_Instances[this._uid].content.setAttribute("aria-label",i);const n=this.getAttribute("placeholder");n&&RTNative_Instances[this._uid].content.setAttribute("data-placeholder",n),this.hasAttribute("readonly")&&RTNative_Instances[this._uid].setReadOnly(!0),RTNative_Instances[this._uid]._syncWordCountVisibility(),RTNative_Instances[this._uid].loadHtml(o),this._initialized=!0,this._syncToInstance(),this._applyContentStyles()}_reinitialize(){const t=this.getValue();delete RTNative_Instances[this._uid],this._initialized=!1,this._uid="rtb-"+Math.random().toString(36).substring(2,11),this._render(),requestAnimationFrame(()=>{this._initialize(),t&&this.setValue(t)})}_svg(t){return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path d="${m[t]}"/></svg>`}_btn(t,e,o,i,n){return`<button id="${t}" title="${o}" aria-label="${o}" aria-pressed="false" class="rich-text-box-menu-item" onclick="${void 0!==n?`RTNative_Method('${i}','${this._uid}','${n}')`:`RTNative_Method('${i}','${this._uid}')`}">${this._svg(e)}</button>`}_specialBtn(t,e,o,i){return`<button id="${t}" title="${o}" aria-label="${o}" aria-pressed="false" class="rich-text-box-menu-item-special" onclick="RTNative_Method('${i}','${this._uid}')">${this._svg(e)}</button>`}_divider(){return'<button class="rich-text-box-divider-btn" disabled><div class="rich-text-box-divider"></div></button>'}_fontDropdown(){const t=this._uid,e=["None","Arial","Arial Narrow","Baskerville","Brush Script","Calibri","Cambria","Candara","Century Gothic","Claude Garamond","Comic Sans MS","Copperplate","Courier","Didot","Georgia","Gill Sans","Helvetica","Impact","Lucida Bright","Monospace","Optima","Palatino","Segoe UI","Tahoma","Times New Roman","Trebuchet MS","Verdana"].map(e=>`<a class="rich-text-box-menu-item" style="font-family:${e};cursor:pointer" onclick="RTNative_Method('font','${t}','${e}')">${e}</a>`).join("");return`\n<div class="rich-text-box-dropdown">\n <button id="blazing-rich-text-font-button" title="Font" class="rich-text-box-font-button rich-text-box-dropdown-btn"\n onclick="RTNative_Method('dropdown','${t}','blazing-rich-text-font-button-dropdown')">Font</button>\n <div id="blazing-rich-text-font-button-dropdown" class="rich-text-box-dropdown-content rich-text-box-font-content rich-text-box-scroll">\n ${e}\n </div>\n</div>`}_sizeDropdown(){const t=this._uid,e=["None","8","9","10","11","12","14","16","18","20","22","24","26","28","36","48","64"].map(e=>`<a class="rich-text-box-menu-item" style="${"None"===e?"":`font-size:${e}px !important;`}cursor:pointer" onclick="RTNative_Method('size','${t}','${"None"===e?"None":`${e}px`}')">${"None"===e?"None":e}</a>`).join("");return`\n<div class="rich-text-box-dropdown">\n <button id="blazing-rich-text-size-button" title="Size (Ctrl+Shift+[<,>])" class="rich-text-box-size-button rich-text-box-dropdown-btn"\n onclick="RTNative_Method('dropdown','${t}','blazing-rich-text-size-button-dropdown')">Size</button>\n <div id="blazing-rich-text-size-button-dropdown" class="rich-text-box-dropdown-content rich-text-box-size-content rich-text-box-scroll">\n ${e}\n </div>\n</div>`}_formatDropdown(){const t=this._uid;return`\n<div class="rich-text-box-dropdown">\n <button id="blazing-rich-text-format-button" title="Format (Ctrl+Shift+[D,P,1,2...])" class="rich-text-box-format-button rich-text-box-dropdown-btn"\n onclick="RTNative_Method('dropdown','${t}','blazing-rich-text-format-button-dropdown')">Format</button>\n <div id="blazing-rich-text-format-button-dropdown" class="rich-text-box-dropdown-content rich-text-box-format-content rich-text-box-scroll">\n <a class="rich-text-box-menu-item" style="cursor:pointer" onclick="RTNative_Method('format','${t}','none')">None</a>\n <a class="rich-text-box-menu-item" style="cursor:pointer" onclick="RTNative_Method('format','${t}','p')">Paragraph</a>\n <a class="rich-text-box-menu-item" style="font-size:34px;cursor:pointer" onclick="RTNative_Method('format','${t}','h1')">Header 1</a>\n <a class="rich-text-box-menu-item" style="font-size:30px;cursor:pointer" onclick="RTNative_Method('format','${t}','h2')">Header 2</a>\n <a class="rich-text-box-menu-item" style="font-size:24px;cursor:pointer" onclick="RTNative_Method('format','${t}','h3')">Header 3</a>\n <a class="rich-text-box-menu-item" style="font-size:20px;cursor:pointer" onclick="RTNative_Method('format','${t}','h4')">Header 4</a>\n <a class="rich-text-box-menu-item" style="font-size:18px;cursor:pointer" onclick="RTNative_Method('format','${t}','h5')">Header 5</a>\n <a class="rich-text-box-menu-item" style="font-size:16px;cursor:pointer" onclick="RTNative_Method('format','${t}','h6')">Header 6</a>\n </div>\n</div>`}_colorSwatches(t){return["#FFFFFF","#DCDCDC","#A9A9A9","#696969","#303030","#000000","#FFCCCC","#FF6666","#FF3333","#FF0000","#CC0000","#990000","#800000","#CCFFCC","#99FF99","#66FF66","#33CC33","#009900","#CCCCFF","#9999FF","#6666FF","#3333CC","#000099","#002060","#FFFFCC","#FFFF99","#FFFF66","#CCCC33","#999900","#CCFFFF","#99FFFF","#66FFFF","#33CCCC","#009999","#FFCCFF","#FF99FF","#FF66FF","#CC33CC","#990099","#FFDDCC","#FFBB99","#FF9966","#FF7733","#CC4400","#E0CCFF","#C199FF","#A366FF","#8533FF","#6600CC"].map(e=>`<div class="blazing-rich-text-color-option" onclick="RTNative_Method('${t}','${this._uid}','${e}')" style="background-color:${e};"></div>`).join("")}_colorDialog(t,e,o,i){const n=this._uid;return`\n<dialog id="${t}" class="rich-text-box-modal rich-text-box-scroll" aria-modal="true" aria-labelledby="${t}-title">\n <div class="rtb-modal-header">\n <div id="${t}-title" class="rich-text-box-modal-title">${e}</div>\n <button class="rich-text-box-modal-close" aria-label="Close dialog" onclick="RTNative_Method('closeDialog','${n}','${t}')"><svg viewBox="0 0 12 12" aria-hidden="true" focusable="false" width="8" height="8" style="display:block"><path d="M2 2L10 10M10 2L2 10" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" fill="none"/></svg></button>\n </div>\n <div class="rich-text-box-color-picker">\n <div class="clearfix">\n <div class="rich-text-box-form-left">\n ${this._colorSwatches(o)}\n <div class="rich-text-box-color-display"></div>\n </div>\n <div class="rich-text-box-form-right">\n <div class="rich-text-box-slider-container">\n <label>R</label>\n <input type="range" class="rich-text-box-range rich-text-box-red-slider" min="0" max="255" value="0">\n <input type="number" class="rich-text-box-number rich-text-box-form-element rich-text-box-red-value" min="0" max="255" value="0">\n </div>\n <div class="rich-text-box-slider-container">\n <label>G</label>\n <input type="range" class="rich-text-box-range rich-text-box-green-slider" min="0" max="255" value="0">\n <input type="number" class="rich-text-box-number rich-text-box-form-element rich-text-box-green-value" min="0" max="255" value="0">\n </div>\n <div class="rich-text-box-slider-container">\n <label>B</label>\n <input type="range" class="rich-text-box-range rich-text-box-blue-slider" min="0" max="255" value="0">\n <input type="number" class="rich-text-box-number rich-text-box-form-element rich-text-box-blue-value" min="0" max="255" value="0">\n </div>\n <div class="rich-text-box-hex-container">\n <label>Hex:</label>\n <input type="text" class="rich-text-box-form-element rich-text-box-hex-input" value="#000000" autocomplete="off">\n </div>\n </div>\n </div>\n <div style="text-align:right;">\n <button class="rich-text-box-form-button" onclick="RTNative_Method('closeDialog','${n}','${t}')">Close</button>\n <button id="rich-text-box-ok-button" class="rich-text-box-form-button" onclick="RTNative_Method('${i}','${n}')">OK</button>\n </div>\n </div>\n</dialog>`}_genericDialog(t,e,o,i){const n=this._uid;return`\n<dialog id="${t}" class="rich-text-box-modal rich-text-box-scroll" aria-modal="true" aria-labelledby="${t}-title">\n <div class="rtb-modal-header">\n <div id="${t}-title" class="rich-text-box-modal-title">${e}</div>\n <button class="rich-text-box-modal-close" aria-label="Close dialog" onclick="RTNative_Method('closeDialog','${n}','${t}')"><svg viewBox="0 0 12 12" aria-hidden="true" focusable="false" width="8" height="8" style="display:block"><path d="M2 2L10 10M10 2L2 10" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" fill="none"/></svg></button>\n </div>\n <div>\n ${i}\n <div style="margin-top:5px;text-align:right;">\n <button class="rich-text-box-form-button" onclick="RTNative_Method('closeDialog','${n}','${t}')">Close</button>\n <button id="rich-text-box-ok-button" class="rich-text-box-form-button" onclick="RTNative_Method('${o}','${n}')">OK</button>\n </div>\n </div>\n</dialog>`}_buildToolbarHTML(){const t=this._uid,e=this._visibility,o=(e.font||e.size||e.format)&&e.textStylesDivider,i=(e.bold||e.italic||e.underline||e.strikethrough||e.subscript||e.superscript)&&e.formatDivider,n=e.textColor&&e.textColorDivider,r=(e.alignLeft||e.alignCenter||e.alignRight||e.alignJustify)&&e.alignDivider,s=(e.copy||e.cut||e.paste||e.delete||e.selectAll)&&e.actionDivider,l=(e.orderedList||e.unorderedList||e.indent)&&e.listDivider,a=(e.link||e.image||e.imageUpload||e.quote||e.codeBlock||e.embedMedia||e.video||e.table||e.horizontalRule)&&e.mediaDivider,c=(e.undo||e.redo)&&e.historyDivider;return`\n<div id="${t}_Toolbar" class="rich-text-box-tool-bar" role="toolbar" aria-label="Formatting toolbar">\n\n ${e.font?this._fontDropdown():""}\n ${e.size?this._sizeDropdown():""}\n ${e.format?this._formatDropdown():""}\n ${o?this._divider():""}\n\n ${e.bold?this._btn("blazing-rich-text-bold-button","Bold","Bold (Ctrl+B)","bold"):""}\n ${e.italic?this._btn("blazing-rich-text-italic-button","Italic","Italic (Ctrl+I)","italic"):""}\n ${e.underline?this._btn("blazing-rich-text-underline-button","Underline","Underline (Ctrl+U)","underline"):""}\n ${e.strikethrough?this._btn("blazing-rich-text-strike-button","Strikethrough","Strikethrough (Ctrl+D)","strikethrough"):""}\n ${e.subscript?this._btn("blazing-rich-text-sub-button","Subscript","Subscript (Ctrl+=)","subscript"):""}\n ${e.superscript?this._btn("blazing-rich-text-super-button","Superscript","Superscript (Ctrl+Shift++)","superscript"):""}\n ${i?this._divider():""}\n\n ${e.textColor?this._btn("blazing-rich-text-textcolor-button","TextColor","Text Color (Ctrl+Shift+C)","openTextColorDialog"):""}\n ${e.textColor?this._btn("blazing-rich-text-text-bg-color-button","TextBackgroundColor","Text Background Color (Ctrl+Shift+B)","openTextBackgroundColorDialog"):""}\n ${e.textColor?this._btn("blazing-rich-text-textcolor-remove-button","RemoveTextFormat","Remove Color","removeTextColor"):""}\n ${n?this._divider():""}\n\n ${e.alignLeft?this._btn("blazing-rich-text-alignleft-button","Alignleft","Align Left (Ctrl+L)","alignleft"):""}\n ${e.alignCenter?this._btn("blazing-rich-text-aligncenter-button","Aligncenter","Align Center (Ctrl+E)","aligncenter"):""}\n ${e.alignRight?this._btn("blazing-rich-text-alignright-button","Alignright","Align Right (Ctrl+R)","alignright"):""}\n ${e.alignJustify?this._btn("blazing-rich-text-alignjustify-button","Alignjustify","Align Justify (Ctrl+J)","alignjustify"):""}\n ${r?this._divider():""}\n\n ${e.cut?this._btn("blazing-rich-text-cut-button","Cut","Cut (Ctrl+X)","cut"):""}\n ${e.copy?this._btn("blazing-rich-text-copy-button","Copy","Copy (Ctrl+C)","copy"):""}\n ${e.paste?this._btn("blazing-rich-text-paste-button","Paste","Paste (Ctrl+V)","paste"):""}\n ${e.delete?this._btn("blazing-rich-text-delete-button","Delete","Delete","delete"):""}\n ${e.selectAll?this._btn("blazing-rich-text-selectall-button","Selectall","Select All (Ctrl+A)","selectall"):""}\n ${s?this._divider():""}\n\n ${e.orderedList?this._btn("blazing-rich-text-orderedlist-button","OrderedList","Ordered List (Ctrl+Shift+O)","orderedlist"):""}\n ${e.unorderedList?this._btn("blazing-rich-text-unorderedlist-button","UnorderedList","Unordered List (Ctrl+Shift+U)","unorderedlist"):""}\n ${e.indent?this._btn("blazing-rich-text-increase-indent-button","IncreaseIndent","Increase Indent (Tab)","increaseIndent"):""}\n ${e.indent?this._btn("blazing-rich-text-decrease-indent-button","DecreaseIndent","Decrease Indent (Shift+Tab)","decreaseIndent"):""}\n ${l?this._divider():""}\n\n ${e.link?this._btn("blazing-rich-text-link-button","CreateLink","Insert Link (Ctrl+Shift+K)","openLinkDialog"):""}\n ${e.link?this._btn("blazing-rich-text-remove-link-button","RemoveLink","Remove Link","removeLink"):""}\n ${e.image?this._btn("blazing-rich-text-image-button","Image","Insert Image (Ctrl+Shift+I)","openImageDialog"):""}\n ${e.imageUpload?this._btn("blazing-rich-text-image-upload-button","UploadImage","Upload Image (Ctrl+Shift+&)","uploadImageDialog"):""}\n ${e.quote?this._btn("blazing-rich-text-quote-button","Quote","Block Quote (Ctrl+Shift+Q)","openBlockQuoteDialog"):""}\n ${e.embedMedia?this._btn("blazing-rich-text-embed-button","PermMedia","Insert Media (Ctrl+Shift+M)","openMediaDialog"):""}\n ${e.video?this._btn("blazing-rich-text-video-button","VideoFile","Insert Video (Ctrl+Shift+V)","openVideoDialog"):""}\n ${e.table?this._btn("blazing-rich-text-table-button","Table","Table (Ctrl+Shift+L)","openTableDialog"):""}\n ${e.codeBlock?this._btn("blazing-rich-text-code-block-button","CodeBlocks","Code Block (Ctrl+Shift+*)","openCodeBlockDialog"):""}\n ${e.horizontalRule?this._btn("blazing-rich-text-hr-button","HorizontalRule","Horizontal Rule (Ctrl+Shift+H)","insertHorizontalRule"):""}\n ${a?this._divider():""}\n\n ${e.undo?this._btn("blazing-rich-text-undo-button","Undo","Undo (Ctrl+Z)","goBack"):""}\n ${e.redo?this._btn("blazing-rich-text-redo-button","Redo","Redo (Ctrl+Y)","goForward"):""}\n ${c?this._divider():""}\n\n ${e.statusBarToggle?this._btn("blazing-rich-text-statusbar-button","StatusBar","Toggle Status Bar (Ctrl+\\)","toggleStatusBar"):""}\n ${e.saveHtml?this._specialBtn("blazing-rich-text-save-button","SaveHtml","Save HTML (Ctrl+Shift+S)","saveHtml"):""}\n ${e.htmlView?this._specialBtn("blazing-rich-text-source","Code","HTML Source (Ctrl+Shift+A)","toggleView"):""}\n ${e.preview?this._specialBtn("blazing-rich-text-preview-button","Preview","Preview (Ctrl+Shift+P)","openPreview"):""}\n\n ${this._colorDialog("rich-text-box-text-color-modal","Text Color","selectTextColor","insertTextColor")}\n ${this._colorDialog("rich-text-box-text-bg-color-modal","Text Background Color","selectTextBackgroundColor","insertTextBackgroundColor")}\n\n ${this._genericDialog("rich-text-box-table-modal","Table","insertTable",'\n <div class="clearfix">\n <div class="rich-text-box-form-left">\n <label>Columns</label>\n <input type="number" id="rich-text-box-table-columns" class="rich-text-box-form-element" min="0" max="10000" value="0" autocomplete="off">\n </div>\n <div class="rich-text-box-form-right">\n <label>Rows</label>\n <input type="number" id="rich-text-box-table-rows" class="rich-text-box-form-element" min="0" max="10000" value="0" autocomplete="off">\n <label>Width</label>\n <input type="text" id="rich-text-box-table-width" class="rich-text-box-form-element" placeholder="500px">\n </div>\n <div class="rich-text-box-form-left">\n <label>CSS Classes</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-table-classes" placeholder="class1 class2 class3">\n </div>\n </div>\n ')}\n\n ${this._genericDialog("rich-text-box-embed-modal","Media","insertMedia",'\n <div class="clearfix">\n <div class="rich-text-box-form-left">\n <label>Source</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-embed-source" placeholder="e.g., /documents/file.pdf" autocomplete="off">\n <label>Type</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-embed-type" placeholder="e.g., audio/mp3, application/pdf" autocomplete="off">\n </div>\n <div class="rich-text-box-form-right">\n <label>Width</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-embed-width" placeholder="450" autocomplete="off">\n <label>Height</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-embed-height" placeholder="250" autocomplete="off">\n </div>\n <div class="rich-text-box-form-left">\n <label>CSS Classes</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-embed-css-classes" placeholder="class1 class2 class3">\n </div>\n </div>\n ')}\n\n ${this._genericDialog("rich-text-box-video-modal","Video","insertVideo",'\n <div class="clearfix">\n <div class="rich-text-box-form-left">\n <label>Source</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-video-source" placeholder="e.g., /videos/movie.mp4" autocomplete="off">\n <label>Source Type</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-video-source-type" placeholder="e.g., video/mp4" autocomplete="off">\n <label>Poster Image URL</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-video-poster" placeholder="e.g., /images/poster.jpg" autocomplete="off">\n </div>\n <div class="rich-text-box-form-right">\n <label>Width</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-video-width" placeholder="640" autocomplete="off">\n <label>Height</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-video-height" placeholder="360" autocomplete="off">\n <label>CSS Classes</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-video-css-classes" placeholder="class1 class2 class3">\n </div>\n <div style="clear:both;display:grid;grid-template-columns:1fr 1fr;gap:2px 20px;margin-top:10px;">\n <label style="display:flex;align-items:center;gap:6px;margin-bottom:6px;">\n <input class="rich-text-box-form-checkbox" type="checkbox" id="rich-text-box-video-controls">\n Controls\n </label>\n <label style="display:flex;align-items:center;gap:6px;margin-bottom:6px;">\n <input class="rich-text-box-form-checkbox" type="checkbox" id="rich-text-box-video-autoplay">\n Autoplay\n </label>\n <label style="display:flex;align-items:center;gap:6px;margin-bottom:6px;">\n <input class="rich-text-box-form-checkbox" type="checkbox" id="rich-text-box-video-loop">\n Loop\n </label>\n <label style="display:flex;align-items:center;gap:6px;margin-bottom:6px;">\n <input class="rich-text-box-form-checkbox" type="checkbox" id="rich-text-box-video-muted">\n Muted\n </label>\n </div>\n </div>\n ')}\n\n ${this._genericDialog("rich-text-box-code-block-modal","Code Block","insertCodeBlock",'\n <div class="clearfix">\n <label>Code Block</label>\n <textarea rows="6" cols="50" class="rich-text-box-form-element rich-text-box-code rich-text-box-scroll" id="rich-text-box-code" spellcheck="false"></textarea>\n <div class="rich-text-box-form-left">\n <label>CSS Classes</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-code-css-classes" placeholder="class1 class2 class3">\n </div>\n </div>\n ')}\n\n ${this._genericDialog("rich-text-box-block-quote-modal","Block Quote","insertBlockQuote",'\n <div class="clearfix">\n <div class="rich-text-box-form-left">\n <label>Quote</label>\n <textarea rows="6" cols="50" class="rich-text-box-form-element rich-text-box-quote rich-text-box-scroll" id="rich-text-box-quote"></textarea>\n </div>\n <div class="rich-text-box-form-right">\n <label>Cite</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-cite" placeholder="https://www..." autocomplete="off">\n <label>CSS Classes</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-quote-css-classes" placeholder="class1 class2 class3">\n </div>\n </div>\n ')}\n\n ${this._genericDialog("rich-text-box-image-modal","Image","insertImage",'\n <div class="clearfix">\n <div class="rich-text-box-form-left">\n <label>Web Address</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-image-webaddress" placeholder="https://www..." autocomplete="off">\n <label>Alternative Text</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-image-alt-text" autocomplete="off">\n </div>\n <div class="rich-text-box-form-right">\n <label>Width</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-image-width" placeholder="400" autocomplete="off">\n <label>Height</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-image-height" autocomplete="off">\n </div>\n <div class="rich-text-box-form-left">\n <label>CSS Classes</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-image-css-classes" placeholder="class1 class2 class3">\n </div>\n </div>\n ')}\n\n ${this._genericDialog("rich-text-box-upload-image-modal","Upload / Embed Image","uploadImage",'\n <div class="clearfix">\n <div class="rich-text-box-form-left">\n <div style="height:40px;padding:20px 0 10px 0;">\n <input type="file" id="rich-text-box-upload-image-file" hidden>\n <label for="rich-text-box-upload-image-file" class="rich-text-box-upload-btn">Choose File</label>\n <span id="rich-text-box-upload-image-file-chosen">No file chosen</span>\n </div>\n <label>Alternative Text</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-upload-image-alt-text" autocomplete="off">\n </div>\n <div class="rich-text-box-form-right">\n <label>Width</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-upload-image-width" placeholder="400" autocomplete="off">\n <label>Height</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-upload-image-height" autocomplete="off">\n </div>\n <div class="rich-text-box-form-left">\n <label>CSS Classes</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-upload-image-css-classes" placeholder="class1 class2 class3">\n </div>\n </div>\n ')}\n\n ${this._genericDialog("rich-text-box-link-modal","Link","insertLink",'\n <div class="clearfix">\n <div class="rich-text-box-form-left">\n <label>Web Address</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-link-webaddress" placeholder="https://www..." autocomplete="off">\n </div>\n <div class="rich-text-box-form-right">\n <label>Link Text</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-linktext" autocomplete="off">\n <label style="display:flex;align-items:center;margin-bottom:12px;">\n <input class="rich-text-box-form-checkbox" id="rich-text-box-link-modal-newtab" type="checkbox">\n Open in New Tab\n </label>\n </div>\n <div class="rich-text-box-form-left">\n <label>CSS Classes</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-link-css-classes" placeholder="class1 class2 class3">\n </div>\n </div>\n ')}\n\n\n ${this._buildPreviewDialogHTML()}\n\n</div>`}_buildPreviewDialogHTML(){const t=this._uid;return`\n<dialog id="${t}_Preview" class="rich-text-box-modal rich-text-box-scroll rtb-preview-dialog" aria-modal="true" aria-labelledby="${t}_Preview-title">\n <div class="rtb-modal-header">\n <div id="${t}_Preview-title" class="rich-text-box-modal-title">Preview</div>\n <div style="display:flex;gap:2px;align-items:center;">\n <button id="${t}_PreviewMaxBtn" class="rich-text-box-modal-close" aria-label="Maximize preview" onclick="RTNative_Method('togglePreviewMaximize','${t}')"><svg viewBox="0 0 12 12" aria-hidden="true" focusable="false" width="11" height="11" style="display:block"><path d="M1.5 4.5V1.5H4.5M10.5 7.5V10.5H7.5M1.5 1.5L4.5 4.5M10.5 10.5L7.5 7.5" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" fill="none"/></svg></button>\n <button class="rich-text-box-modal-close" aria-label="Close preview" onclick="RTNative_Method('closePreview','${t}')"><svg viewBox="0 0 12 12" aria-hidden="true" focusable="false" width="8" height="8" style="display:block"><path d="M2 2L10 10M10 2L2 10" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" fill="none"/></svg></button>\n </div>\n </div>\n <div class="rtb-preview-dialog-body">\n <div id="rich-text-box-preview" class="rtb-preview-window"></div>\n <div style="text-align:right;flex-shrink:0;">\n <button class="rich-text-box-form-button" onclick="RTNative_Method('closePreview','${t}')">Close</button>\n </div>\n </div>\n</dialog>`}}customElements.define("rt-native",x);
|
|
1
|
+
class t{constructor(t,e,n,o,i){this.id=t,this.shadow_id=e,this.toolbar_id=n,this.styles=o,this.dotNetObjectReference=i,this.init()}init=()=>{this.hydrateShadowTree(),this.Utilities=new r(this.shadowRoot,this.content),this.NodeManager=new n(this.shadowRoot,this.content,this.Utilities),this.ActionOptions=new i(this.shadowRoot,this.content,this.Utilities),this.ListProvider=new o(this.shadowRoot,this.content,this.Utilities,this.NodeManager),this.ColorPickers={};const t="rich-text-box-text-color-modal",p="rich-text-box-text-bg-color-modal";this.ColorPickers[t]=new g(this.shadowRoot,this.content,t,this.NodeManager,this.Utilities),this.ColorPickers[p]=new g(this.shadowRoot,this.content,p,this.NodeManager,this.Utilities),this.LinkDialog=new u(this.shadowRoot,this.content,this.Utilities),this.ImageDialog=new b(this.shadowRoot,this.content,this.Utilities),this.UploadImageDialog=new h(this.shadowRoot,this.content,this.Utilities),this.BlockQuoteDialog=new c(this.shadowRoot,this.content,this.Utilities),this.CodeBlockDialog=new d(this.shadowRoot,this.content,this.Utilities),this.MediaDialog=new s(this.shadowRoot,this.content,this.Utilities),this.VideoDialog=new a(this.shadowRoot,this.content,this.Utilities),this.TableDialog=new l(this.shadowRoot,this.content,this.Utilities),this.StateManager=new e(this.content,this.source,this.Utilities,this.dotNetObjectReference,this.contentContainer),this.addEventListeners()};hydrateShadowTree=()=>{const t=document.getElementById(this.shadow_id);this.shadowRoot=t.attachShadow({mode:"open"});const e=document.createElement("style");e.textContent=this.styles,this.shadowRoot.appendChild(e),this.contentContainer=document.createElement("div"),this.contentContainer.classList.add("rich-text-box-content-container","rich-text-box-scroll"),this.container=document.createElement("div"),this.container.classList.add("rich-text-box-container","rich-text-box-scroll"),this.content=document.createElement("div"),this.content.setAttribute("id",this.id),this.content.setAttribute("class","rich-text-box-content"),this.content.setAttribute("contenteditable","true"),this.content.setAttribute("role","textbox"),this.content.setAttribute("aria-multiline","true"),this.content.setAttribute("aria-label","Rich text editor"),this.content.setAttribute("aria-readonly","false"),this.content.style.display="block",this.source=document.createElement("textarea"),this.source.setAttribute("id","rich-text-box-source"),this.source.setAttribute("aria-label","HTML source"),this.source.classList.add("rich-text-box-source","rich-text-box-scroll"),this.source.style.display="none",this.source.spellcheck=!1;const n=document.createElement("div");n.setAttribute("class","rich-text-box-message-bar rich-text-box-message-hidden"),n.setAttribute("id","rich-text-box-message-bar");const o=document.createElement("span");o.setAttribute("class","rich-text-box-message");const i=document.createElement("button");i.setAttribute("class","rich-text-box-message-close-button"),i.textContent="×",i.onclick=()=>{this.Utilities.closeFadingBar()},n.appendChild(o),n.appendChild(i),this.statusBar=document.createElement("div"),this.statusBar.className="rtb-status-bar",this.statusBar.setAttribute("role","status"),this.statusBar.setAttribute("aria-live","polite"),this.statusBar.setAttribute("aria-atomic","true"),this.statusBar.id="rich-text-box-status-bar",this.statusBar.textContent="0 words · 0 characters",this.findBar=document.createElement("div"),this.findBar.className="rtb-find-bar",this.findBar.setAttribute("role","search"),this.findBar.setAttribute("aria-label","Find in editor"),this.findBar.style.display="none",this.findBar.innerHTML='\n <input type="text" class="rtb-find-input" placeholder="Find..." aria-label="Find text" autocomplete="off" spellcheck="false">\n <span class="rtb-find-count" aria-live="polite"></span>\n <button class="rtb-find-nav-btn" title="Previous match (Shift+Enter)" aria-label="Previous match"><svg viewBox="0 -960 960 960"><path d="M480-528 296-344l-56-56 240-240 240 240-56 56-184-184Z"/></svg></button>\n <button class="rtb-find-nav-btn" title="Next match (Enter)" aria-label="Next match"><svg viewBox="0 -960 960 960"><path d="M480-344 240-584l56-56 184 184 184-184 56 56-240 240Z"/></svg></button>\n <button class="rtb-find-close-btn" title="Close (Escape)" aria-label="Close find bar"><svg viewBox="0 -960 960 960"><path d="m256-200-56-56 224-224-224-224 56-56 224 224 224-224 56 56-224 224 224 224-56 56-224-224-224 224Z"/></svg></button>\n ',this._findMatches=[],this._findIndex=-1;const r=document.getElementById(this.toolbar_id);this.container.appendChild(r),this.contentContainer.appendChild(this.content),this.contentContainer.appendChild(this.source),this.contextMenu=document.createElement("div"),this.contextMenu.className="rtb-context-menu",this.contextMenu.setAttribute("role","menu"),this.contextMenu.setAttribute("aria-hidden","true"),this.container.appendChild(n),this.container.appendChild(this.findBar),this.container.appendChild(this.contentContainer),this.container.appendChild(this.statusBar),this.container.appendChild(this.contextMenu),this.shadowRoot.appendChild(this.container)};addEventListeners=()=>{document.addEventListener("selectionchange",t=>{const e=this.Utilities.getSelection();null!==e&&this.clearSettings(e.anchorNode)}),this.content.addEventListener("click",t=>{"A"===t.target.tagName&&(t.preventDefault(),t.stopPropagation())}),this.content.addEventListener("click",t=>{const e=t.target.tagName;if("VIDEO"===e||"SOURCE"===e){t.preventDefault();const n="SOURCE"===e?t.target.closest("video"):t.target;if(n&&n.parentNode===this.content){if(!n.nextSibling){const t=document.createElement("p");t.appendChild(document.createElement("br")),this.content.insertBefore(t,null)}const t=n.nextSibling,e=window.getSelection();if(e&&t){const n=document.createRange(),o=t.firstChild??t;n.setStart(o,0),n.collapse(!0),e.removeAllRanges(),e.addRange(n)}}}},!0),this.content.addEventListener("dblclick",t=>{const e=t.target.tagName;"VIDEO"!==e&&"SOURCE"!==e||t.preventDefault()},!0),this.content.addEventListener("dblclick",t=>{switch(t.target.tagName){case"A":t.preventDefault(),this.openLinkDialog();break;case"IMG":t.preventDefault();const e=this.Utilities.getSelection(),n=document.createRange();n.selectNodeContents(t.target),e.removeAllRanges(),e.addRange(n),t.target.src.startsWith("data")?this.uploadImageDialog():this.openImageDialog();break;case"VIDEO":case"SOURCE":{t.preventDefault();const e="SOURCE"===t.target.tagName?t.target.closest("video"):t.target;if(e){const t=this.Utilities.getSelection(),n=document.createRange();n.selectNode(e),t.removeAllRanges(),t.addRange(n),this.openVideoDialogForElement(e)}else this.openVideoDialog();break}case"BLOCKQUOTE":t.preventDefault(),this.openBlockQuoteDialogForElement(t.target);break;case"PRE":t.preventDefault(),this.openCodeBlockDialogForElement(t.target);break;case"CODE":{const e=t.target.closest("pre");e&&this.content.contains(e)&&(t.preventDefault(),this.openCodeBlockDialogForElement(e));break}default:{const e=t.target.closest("pre");if(e&&this.content.contains(e)){t.preventDefault(),this.openCodeBlockDialogForElement(e);break}const n=t.target.closest("blockquote");n&&this.content.contains(n)&&(t.preventDefault(),this.openBlockQuoteDialogForElement(n));break}}}),this.content.addEventListener("input",t=>{this.updateWordCount();const e=this.Utilities.getSelection(),n=e.getRangeAt(0).startContainer;if(n.nodeType===Node.TEXT_NODE&&"SPAN"===n.parentNode.tagName){const t=n.parentNode,o=t.parentNode;if(this.NodeManager.isFormatElement(o)){for(;t.firstChild;)o.insertBefore(t.firstChild,t);o.removeChild(t);const n=document.createRange();n.setStart(o.firstChild,0),n.collapse(!0),e.removeAllRanges(),e.addRange(n)}}}),this.content.addEventListener("keydown",t=>{this.keyEvents(t)}),this.source.addEventListener("keydown",t=>{t.ctrlKey&&!t.shiftKey&&"f"===t.key&&(t.preventDefault(),this.openFindBar()),t.ctrlKey&&!t.shiftKey&&"/"===t.key&&(t.preventDefault(),this.openHelpDialog()),t.altKey&&!t.ctrlKey&&"l"===t.key&&(t.preventDefault(),this.dropdown("blazing-rich-text-file-button-dropdown")),t.altKey&&!t.ctrlKey&&"f"===t.key&&(t.preventDefault(),this.dropdown("blazing-rich-text-font-button-dropdown")),t.altKey&&!t.ctrlKey&&"s"===t.key&&(t.preventDefault(),this.dropdown("blazing-rich-text-size-button-dropdown")),t.altKey&&!t.ctrlKey&&"t"===t.key&&(t.preventDefault(),this.dropdown("blazing-rich-text-format-button-dropdown")),t.ctrlKey&&t.shiftKey&&"A"===t.key&&(t.preventDefault(),!0===this.EditMode?this.getHtml():this.getCode()),t.ctrlKey&&t.shiftKey&&"P"===t.key&&(t.preventDefault(),this.openPreview()),t.ctrlKey&&t.shiftKey&&"S"===t.key&&(t.preventDefault(),this.saveHtml()),t.ctrlKey&&!t.shiftKey&&"\\"===t.key&&(t.preventDefault(),this.toggleStatusBar())});this.shadowRoot.querySelectorAll(".rich-text-box-dropdown-content").forEach(t=>{t.addEventListener("mousedown",t=>{t.preventDefault()})});const t=this.findBar.querySelector(".rtb-find-input"),e=this.findBar.querySelector(".rtb-find-count"),[n,o]=this.findBar.querySelectorAll(".rtb-find-nav-btn"),i=this.findBar.querySelector(".rtb-find-close-btn");t.addEventListener("input",()=>{this._findMatches=[],this._findIndex=-1,e.textContent=""}),t.addEventListener("keydown",t=>{"Enter"===t.key&&(t.preventDefault(),t.shiftKey?this.findPrev():this.findNext()),"Escape"===t.key&&(t.preventDefault(),this.closeFindBar())}),n.addEventListener("mousedown",t=>t.preventDefault()),o.addEventListener("mousedown",t=>t.preventDefault()),i.addEventListener("mousedown",t=>t.preventDefault()),n.addEventListener("click",()=>this.findPrev()),o.addEventListener("click",()=>this.findNext()),i.addEventListener("click",()=>this.closeFindBar()),this.content.addEventListener("contextmenu",t=>this.openEditorContextMenu(t)),document.addEventListener("click",()=>this.hideContextMenu())};goBack=()=>{this.StateManager.goBack(),this.NodeManager.refreshUI(),this.updateWordCount()};goForward=()=>{this.StateManager.goForward(),this.NodeManager.refreshUI(),this.updateWordCount()};clearSettings=t=>{this.fontSize=void 0,this.NodeManager.selectButtons(t)};keyEvents=t=>{if(this.NodeManager.createDefaultElement(),!1===this.EditMode)return t.ctrlKey&&"z"===t.key&&t.preventDefault(),void(t.ctrlKey&&"y"===t.key&&t.preventDefault());if("Enter"===t.key&&!t.ctrlKey&&!t.altKey&&!t.metaKey){if(this.TableDialog.addRowFromLastCell())return void t.preventDefault();if(this.insertParagraphAfterStructuredBlock())return void t.preventDefault()}if(t.ctrlKey&&"b"===t.key&&(t.preventDefault(),this.bold()),t.ctrlKey&&"i"===t.key&&(t.preventDefault(),this.italic()),t.ctrlKey&&"u"===t.key&&(t.preventDefault(),this.underline()),t.ctrlKey&&"d"===t.key&&(t.preventDefault(),this.strikethrough()),t.ctrlKey&&"c"===t.key&&(t.preventDefault(),this.copy()),t.ctrlKey&&"x"===t.key&&(t.preventDefault(),this.cut()),t.ctrlKey&&"v"===t.key&&(t.preventDefault(),this.paste()),"Delete"===t.key||46===t.keyCode){const e=this.Utilities.getSelection();null!==e&&e.toString().length>0&&(t.preventDefault(),this.delete())}if(t.ctrlKey&&"="===t.key&&(t.preventDefault(),this.subscript()),t.ctrlKey&&t.shiftKey&&"+"===t.key&&(t.preventDefault(),this.superscript()),t.ctrlKey&&t.shiftKey&&"E"===t.key&&(t.preventDefault(),this.inlinecode()),t.ctrlKey&&"l"===t.key&&(t.preventDefault(),this.alignleft()),t.ctrlKey&&"e"===t.key&&(t.preventDefault(),this.aligncenter()),t.ctrlKey&&"r"===t.key&&(t.preventDefault(),this.alignright()),t.ctrlKey&&"j"===t.key&&(t.preventDefault(),this.alignjustify()),t.ctrlKey&&"a"===t.key&&(t.preventDefault(),this.selectall()),t.ctrlKey&&"z"===t.key&&(t.preventDefault(),this.goBack()),t.ctrlKey&&"y"===t.key&&(t.preventDefault(),this.goForward()),t.ctrlKey&&t.shiftKey&&"A"===t.key&&(t.preventDefault(),this.toggleView()),t.ctrlKey&&t.shiftKey&&"S"===t.key&&(t.preventDefault(),this.saveHtml()),t.ctrlKey&&t.shiftKey&&"&"===t.key&&(t.preventDefault(),this.uploadImageDialog()),t.ctrlKey&&t.shiftKey&&"U"===t.key&&(t.preventDefault(),this.unorderedlist()),t.ctrlKey&&t.shiftKey&&"O"===t.key&&(t.preventDefault(),this.orderedlist()),t.ctrlKey&&t.shiftKey&&">"===t.key&&(t.preventDefault(),this.changeFontSize(!0)),t.ctrlKey&&t.shiftKey&&"<"===t.key&&(t.preventDefault(),this.changeFontSize(!1)),t.ctrlKey&&t.shiftKey&&"C"===t.key&&(t.preventDefault(),this.openTextColorDialog()),t.ctrlKey&&t.shiftKey&&"B"===t.key&&(t.preventDefault(),this.openTextBackgroundColorDialog()),t.ctrlKey&&t.shiftKey&&"K"===t.key&&(t.preventDefault(),this.openLinkDialog()),t.ctrlKey&&t.shiftKey&&"*"===t.key&&(t.preventDefault(),this.openCodeBlockDialog()),t.ctrlKey&&t.shiftKey&&"Q"===t.key&&(t.preventDefault(),this.openBlockQuoteDialog()),t.ctrlKey&&t.shiftKey&&"I"===t.key&&(t.preventDefault(),this.openImageDialog()),t.ctrlKey&&t.shiftKey&&"M"===t.key&&(t.preventDefault(),this.openMediaDialog()),t.ctrlKey&&t.shiftKey&&"L"===t.key&&(t.preventDefault(),this.openTableDialog()),t.ctrlKey&&t.shiftKey&&"D"===t.key&&(t.preventDefault(),this.format("none")),t.ctrlKey&&t.shiftKey&&"P"===t.key&&(t.preventDefault(),this.openPreview()),t.ctrlKey&&t.shiftKey&&"!"===t.key&&(t.preventDefault(),this.format("h1")),t.ctrlKey&&t.shiftKey&&"@"===t.key&&(t.preventDefault(),this.format("h2")),t.ctrlKey&&t.shiftKey&&"#"===t.key&&(t.preventDefault(),this.format("h3")),t.ctrlKey&&t.shiftKey&&"$"===t.key&&(t.preventDefault(),this.format("h4")),t.ctrlKey&&t.shiftKey&&"%"===t.key&&(t.preventDefault(),this.format("h5")),t.ctrlKey&&t.shiftKey&&"^"===t.key&&(t.preventDefault(),this.format("h6")),t.ctrlKey&&t.shiftKey&&"V"===t.key&&(t.preventDefault(),this.openVideoDialog()),t.ctrlKey&&t.shiftKey&&"H"===t.key&&(t.preventDefault(),this.insertHorizontalRule()),t.ctrlKey&&!t.shiftKey&&"\\"===t.key&&(t.preventDefault(),this.toggleStatusBar()),t.ctrlKey&&!t.shiftKey&&"f"===t.key&&(t.preventDefault(),this.openFindBar()),t.ctrlKey&&!t.shiftKey&&"/"===t.key&&(t.preventDefault(),this.openHelpDialog()),t.altKey&&!t.ctrlKey&&"l"===t.key&&(t.preventDefault(),this.dropdown("blazing-rich-text-file-button-dropdown")),t.altKey&&!t.ctrlKey&&"f"===t.key&&(t.preventDefault(),this.dropdown("blazing-rich-text-font-button-dropdown")),t.altKey&&!t.ctrlKey&&"s"===t.key&&(t.preventDefault(),this.dropdown("blazing-rich-text-size-button-dropdown")),t.altKey&&!t.ctrlKey&&"t"===t.key&&(t.preventDefault(),this.dropdown("blazing-rich-text-format-button-dropdown")),"Backspace"===t.key){const e=this.Utilities.getSelection();if(e&&e.isCollapsed){const n=e.getRangeAt(0),o=["P","DIV","H1","H2","H3","H4","H5","H6","OL","UL","SECTION","ARTICLE","HEADER","FOOTER"];let i=e.anchorNode;for(;i&&i!==this.content&&(i.nodeType!==Node.ELEMENT_NODE||!o.includes(i.nodeName));)i=i.parentNode;if(i&&i!==this.content){if((parseFloat(window.getComputedStyle(i).marginLeft)||0)>0){const e=document.createRange();e.setStart(i,0),e.setEnd(n.startContainer,n.startOffset),0===e.toString().length&&(t.preventDefault(),this.decreaseIndent())}}}}if(t.shiftKey&&"Tab"===t.key)t.preventDefault(),this.decreaseIndent();else if("Tab"===t.key){const e=this.Utilities.getSelection();if(null!==e&&null!=e.anchorNode&&e.anchorNode!==this.content&&null!=e.anchorNode.parentNode&&e.anchorNode.parentNode!=this.content)if("TD"===e.anchorNode.parentNode.nodeName)t.preventDefault(),this.TableDialog.tableTab();else t.preventDefault(),this.increaseIndent()}};isBreakable=t=>{let e=!1;switch(t){case"BLOCKQUOTE":case"CODE":case"P":case"SPAN":e=!0}return e};getStructuredBlockFromNode=t=>{if(!t||t===this.content)return null;const e=t.nodeType===Node.ELEMENT_NODE?t:t.parentElement;if(!e||!this.content.contains(e))return null;const n=e.closest("pre");if(n&&this.content.contains(n))return n;const o=e.closest("blockquote");return o&&this.content.contains(o)?o:null};insertParagraphAfterStructuredBlock=()=>{const t=this.Utilities.getSelection();if(!t||0===t.rangeCount)return!1;const e=this.getStructuredBlockFromNode(t.anchorNode);if(!e)return!1;const n=document.createElement("p");n.appendChild(document.createElement("br")),e.nextSibling?e.parentNode.insertBefore(n,e.nextSibling):e.parentNode.appendChild(n);const o=document.createRange();return o.setStart(n,0),o.collapse(!0),t.removeAllRanges(),t.addRange(o),this.content.focus(),!0};changeFontSize=t=>{if(void 0===this.fontSize){const t=this.Utilities.getSelection();if(null!==t&&t&&t.rangeCount>0){const e=t.getRangeAt(0),n=window.getComputedStyle(e.commonAncestorContainer.parentElement);this.fontSize=parseFloat(n.fontSize)}}t?this.fontSize+=1:this.fontSize-=1,this.NodeManager.updateNode("size",`${this.fontSize}px`)};openPreview=()=>{this.preview=this.shadowRoot.getElementById(`${this.id}_Preview`);const t=this.shadowRoot.getElementById("rich-text-box-preview");this.preview&&t&&(this.loadPreviewWindow(t),this.addPreviewEventListeners(this.preview),this.preview.showModal(),t.scrollTop=0,t.scrollLeft=0)};addPreviewEventListeners=t=>{t.addEventListener("keydown",t=>{"Enter"===t.key&&(t.preventDefault(),this.closePreview()),"Escape"===t.key&&(t.preventDefault(),this.closePreview())})};loadPreviewWindow=t=>{const e="block"===this.content.style.display?this.html()||"":this.source.value||"",n=t.shadowRoot||t.attachShadow({mode:"open"});for(;n.firstChild;)n.removeChild(n.firstChild);const o=document.createElement("style");o.textContent=":host{display:block;position:relative;}iframe{position:absolute;top:0;left:0;width:100%;height:100%;border:none;}",n.appendChild(o);const i=(this._previewCssUrls||[]).filter(t=>t).map(t=>`<link rel="stylesheet" href="${t.replace(/"/g,"%22")}">`).join(""),r=this._previewCssText?`<style>${this._previewCssText}</style>`:"",l=this._rtbHostElement,s=l?getComputedStyle(l):null,getVar=(t,e)=>(s?s.getPropertyValue(t).trim():"")||e,a=["<style>","html,body{margin:0;}","body{"," padding:20px 24px;",` color:${getVar("--rtb-content-text","#242424")};`,` font-size:${getVar("--rtb-content-size","16px")};`,` font-family:${getVar("--rtb-content-font","Arial, Helvetica, Verdana, sans-serif")};`,` line-height:${getVar("--rtb-content-line-height","1.55")};`,` background-color:${getVar("--rtb-content-bg","#FFF")};`,"}",`blockquote{background:${getVar("--rtb-quote-bg","#f9f9f9")};border-left:${getVar("--rtb-quote-border-width","5px")} solid ${getVar("--rtb-quote-border-color","#ccc")};color:${getVar("--rtb-quote-text",getVar("--rtb-content-text","#242424"))};margin:1.5em 10px;padding:0.5em 10px;}`,`pre{background:${getVar("--rtb-code-bg","#f9f9f9")};border-radius:${getVar("--rtb-code-border-radius","10px")};overflow-x:auto;white-space:pre-wrap;margin:1.5em 10px;padding:0.5em 10px;}`,"table{border-collapse:collapse;}","td,th{border:1px solid #ccc;padding:4px 6px;height:25px;min-width:100px;}","</style>"].join(""),d=document.createElement("iframe");d.srcdoc=["<!DOCTYPE html><html><head>",'<meta charset="UTF-8">',a,i,r,"</head><body>",e,"</body></html>"].join(""),n.appendChild(d),this.NodeManager.clearButtons(),this.enablePreview()};closePreview=()=>{this.disablePreview(),this._resetPreviewMaximize(),this.preview.close(),this.source.focus(),this.content.focus()};togglePreviewMaximize=()=>{const t=this.shadowRoot.getElementById(`${this.id}_Preview`),e=this.shadowRoot.getElementById(`${this.id}_PreviewMaxBtn`);if(!t||!e)return;const n=!t.hasAttribute("data-maximized"),o=[["width","100vw"],["height","100vh"],["max-width","100vw"],["max-height","100vh"],["top","0"],["left","0"],["transform","none"],["border-radius","0"],["resize","none"]];n?(t.setAttribute("data-maximized",""),o.forEach(([e,n])=>t.style.setProperty(e,n))):(t.removeAttribute("data-maximized"),o.forEach(([e])=>t.style.removeProperty(e))),e.setAttribute("aria-label",n?"Restore preview":"Maximize preview"),e.querySelector("svg").innerHTML=n?'<path d="M4.5 1.5V4.5H1.5M7.5 10.5V7.5H10.5M4.5 4.5L1.5 1.5M7.5 7.5L10.5 10.5" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" fill="none"/>':'<path d="M1.5 4.5V1.5H4.5M10.5 7.5V10.5H7.5M1.5 1.5L4.5 4.5M10.5 10.5L7.5 7.5" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" fill="none"/>'};_resetPreviewMaximize=()=>{const t=this.shadowRoot.getElementById(`${this.id}_Preview`),e=this.shadowRoot.getElementById(`${this.id}_PreviewMaxBtn`);t&&e&&(t.removeAttribute("data-maximized"),["width","height","max-width","max-height","top","left","transform","border-radius","resize"].forEach(e=>t.style.removeProperty(e)),e.setAttribute("aria-label","Maximize preview"),e.querySelector("svg").innerHTML='<path d="M1.5 4.5V1.5H4.5M10.5 7.5V10.5H7.5M1.5 1.5L4.5 4.5M10.5 10.5L7.5 7.5" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" fill="none"/>')};insertHorizontalRule=()=>{const t=this.Utilities.getSelection();if(!t||!t.rangeCount)return;const e=t.getRangeAt(0);e.deleteContents();let n=e.startContainer;if(n===this.content){const t=this.content.childNodes[e.startOffset]??null,n=document.createElement("hr");return this.content.insertBefore(n,t),this.NodeManager.refreshUI(),void this.content.dispatchEvent(new Event("input",{bubbles:!0}))}for(;n.parentNode&&n.parentNode!==this.content;)if(n=n.parentNode,!this.content.contains(n))return this.content.appendChild(document.createElement("hr")),this.NodeManager.refreshUI(),void this.content.dispatchEvent(new Event("input",{bubbles:!0}));const o=document.createElement("hr");n&&n!==this.content&&this.content.contains(n)?this.content.insertBefore(o,n.nextSibling):this.content.appendChild(o),this.NodeManager.refreshUI(),this.content.dispatchEvent(new Event("input",{bubbles:!0}))};toggleStatusBar=()=>{if(!this.statusBar)return;const t="none"===this.statusBar.style.display;t?(this.statusBar.style.display="",this.updateWordCount()):this.statusBar.style.display="none";const e=this.shadowRoot.getElementById("blazing-rich-text-file-statusbar-label");e&&(e.textContent=t?"Hide Status Bar":"Show Status Bar")};openFindBar=()=>{this.findBar.style.display="flex";const t=this.findBar.querySelector(".rtb-find-input");requestAnimationFrame(()=>{t.focus(),t.select()})};closeFindBar=()=>{this.findBar.style.display="none",this._findMatches=[],this._findIndex=-1,this.findBar.querySelector(".rtb-find-count").textContent="",this.EditMode?this.content.focus():this.source.focus()};openHelpDialog=()=>{this.shadowRoot.getElementById("rich-text-box-help-modal").showModal()};fileMenuAction=t=>{switch(this.closeDropdown("blazing-rich-text-file-button-dropdown"),t){case"save":this.saveHtml();break;case"find":this.openFindBar();break;case"toggleStatusBar":this.toggleStatusBar();break;case"shortcuts":this.openHelpDialog()}};closeHelpDialog=()=>{this.shadowRoot.getElementById("rich-text-box-help-modal").close()};openEditorContextMenu=t=>{if(!this.EditMode)return;const e=t.target instanceof Element?t.target:t.target?.parentElement;if(!(e instanceof Element&&this.content.contains(e)))return;const n=e.closest("a"),o=e.closest("img"),i=(e.tagName,e.closest("video")),r=e.closest("pre"),l=e.closest("blockquote"),s=e.closest("object"),a=e.closest("table"),d=e.closest("ul"),c=e.closest("ol"),h=e.closest("hr")||(()=>{for(const e of this.content.querySelectorAll("hr")){const n=e.getBoundingClientRect();if(t.clientX>=n.left&&t.clientX<=n.right&&t.clientY>=n.top-10&&t.clientY<=n.bottom+10)return e}return null})();let b;b=n&&this.content.contains(n)?this._buildLinkContextItems(n):o&&this.content.contains(o)?this._buildImageContextItems(o):i&&this.content.contains(i)?this._buildVideoContextItems(i):r&&this.content.contains(r)?this._buildCodeBlockContextItems(r):l&&this.content.contains(l)?this._buildBlockQuoteContextItems(l):s&&this.content.contains(s)?this._buildMediaContextItems(s):a&&this.content.contains(a)?this._buildTableContextItems(a):h&&this.content.contains(h)?this._buildHrContextItems(h):d&&this.content.contains(d)?this._buildBulletListContextItems(d,e):c&&this.content.contains(c)?this._buildNumberListContextItems(c,e):this._buildTextContextItems(e),b&&0!==b.length&&(t.preventDefault(),t.stopPropagation(),this._showContextMenu(t,b))};_buildTextContextItems=t=>{const e=[],n=this._getInlineFormatAtNode(t,"bold"),o=this._getInlineFormatAtNode(t,"italic"),i=this._getInlineFormatAtNode(t,"underline"),r=this._getInlineFormatAtNode(t,"line-through"),l=this._getInlineFormatAtNode(t,"subscript"),s=this._getInlineFormatAtNode(t,"superscript"),a=this._getInlineFormatAtNode(t,"code");return n&&e.push({label:"Remove Bold",icon:"Delete",action:()=>{this.content.focus(),this.bold()}}),o&&e.push({label:"Remove Italic",icon:"Delete",action:()=>{this.content.focus(),this.italic()}}),i&&e.push({label:"Remove Underline",icon:"Delete",action:()=>{this.content.focus(),this.underline()}}),r&&e.push({label:"Remove Strikethrough",icon:"Delete",action:()=>{this.content.focus(),this.strikethrough()}}),l&&e.push({label:"Remove Subscript",icon:"Delete",action:()=>{this.content.focus(),this.subscript()}}),s&&e.push({label:"Remove Superscript",icon:"Delete",action:()=>{this.content.focus(),this.superscript()}}),a&&e.push({label:"Remove Inline Code",icon:"Delete",action:()=>{this.content.focus(),this.inlinecode()}}),e.length>0&&e.push({divider:!0}),[["None","none"],["Paragraph","p"],["Heading 1","h1"],["Heading 2","h2"],["Heading 3","h3"],["Heading 4","h4"],["Heading 5","h5"],["Heading 6","h6"]].forEach(([t,n])=>{e.push({label:t,icon:"Format",action:()=>{this.content.focus(),this.format(n)}})}),e.push({divider:!0}),e.push({label:"Text Color",icon:"TextColor",action:()=>this.openTextColorDialog()}),e.push({label:"Background Color",icon:"TextBackgroundColor",action:()=>this.openTextBackgroundColorDialog()}),e.push({label:"Remove Color",icon:"RemoveTextFormat",action:()=>this.removeTextColor()}),e};_buildLinkContextItems=t=>[{label:"Edit Link",icon:"CreateLink",action:()=>this._selectNodeForDialog(t,!0,()=>this.openLinkDialog())},{label:"Remove Link",icon:"RemoveLink",action:()=>this._selectNodeForDialog(t,!0,()=>this.removeLink())}];_buildImageContextItems=t=>[{label:"Edit Image",icon:"Image",action:()=>{const e=this.Utilities.getSelection()||window.getSelection(),n=document.createRange();n.selectNode(t),e.removeAllRanges(),e.addRange(n),t.src?.startsWith("data")?this.uploadImageDialog():this.openImageDialog()}},{label:"Remove Image",icon:"Delete",action:()=>this._removeContentElement(t)}];_buildVideoContextItems=t=>[{label:"Edit Video",icon:"VideoFile",action:()=>this.openVideoDialogForElement(t)},{label:"Remove Video",icon:"Delete",action:()=>this._removeContentElement(t)}];_buildBlockQuoteContextItems=t=>[{label:"Edit Block Quote",icon:"Quote",action:()=>this.openBlockQuoteDialogForElement(t)},{label:"Remove Block Quote",icon:"Delete",action:()=>this._removeContentElement(t)}];_buildCodeBlockContextItems=t=>[{label:"Edit Code Block",icon:"CodeBlocks",action:()=>this.openCodeBlockDialogForElement(t)},{label:"Remove Code Block",icon:"Delete",action:()=>this._removeContentElement(t)}];_buildMediaContextItems=t=>[{label:"Edit Media",icon:"PermMedia",action:()=>this._selectNodeForDialog(t,!1,()=>this.openMediaDialog())},{label:"Remove Media",icon:"Delete",action:()=>this._removeContentElement(t)}];_buildTableContextItems=t=>[{label:"Edit Table",icon:"Table",action:()=>{const e=t.querySelector("td, th");if(e){const t=this.Utilities.getSelection()||window.getSelection(),n=document.createRange();n.setStart(e,0),n.collapse(!0),t.removeAllRanges(),t.addRange(n)}this.openTableDialog()}},{label:"Remove Table",icon:"Delete",action:()=>this._removeContentElement(t)}];_buildHrContextItems=t=>[{label:"Remove Horizontal Rule",icon:"Delete",action:()=>this._removeContentElement(t)}];_buildBulletListContextItems=(t,e)=>{const n=[],o=this._getInlineFormatAtNode(e,"bold"),i=this._getInlineFormatAtNode(e,"italic"),r=this._getInlineFormatAtNode(e,"underline"),l=this._getInlineFormatAtNode(e,"line-through"),s=this._getInlineFormatAtNode(e,"code");return o&&n.push({label:"Remove Bold",icon:"Delete",action:()=>{this.content.focus(),this.bold()}}),i&&n.push({label:"Remove Italic",icon:"Delete",action:()=>{this.content.focus(),this.italic()}}),r&&n.push({label:"Remove Underline",icon:"Delete",action:()=>{this.content.focus(),this.underline()}}),l&&n.push({label:"Remove Strikethrough",icon:"Delete",action:()=>{this.content.focus(),this.strikethrough()}}),s&&n.push({label:"Remove Inline Code",icon:"Delete",action:()=>{this.content.focus(),this.inlinecode()}}),n.length>0&&n.push({divider:!0}),n.push({label:"Remove Bullet List",icon:"Delete",action:()=>{this.content.focus();const e=this.Utilities.getSelection()||window.getSelection(),n=document.createRange(),o=t.querySelector("li");o?n.setStart(o,0):n.setStart(t,0),n.collapse(!0),e.removeAllRanges(),e.addRange(n),this.unorderedlist()}}),n};_buildNumberListContextItems=(t,e)=>{const n=[],o=this._getInlineFormatAtNode(e,"bold"),i=this._getInlineFormatAtNode(e,"italic"),r=this._getInlineFormatAtNode(e,"underline"),l=this._getInlineFormatAtNode(e,"line-through"),s=this._getInlineFormatAtNode(e,"code");return o&&n.push({label:"Remove Bold",icon:"Delete",action:()=>{this.content.focus(),this.bold()}}),i&&n.push({label:"Remove Italic",icon:"Delete",action:()=>{this.content.focus(),this.italic()}}),r&&n.push({label:"Remove Underline",icon:"Delete",action:()=>{this.content.focus(),this.underline()}}),l&&n.push({label:"Remove Strikethrough",icon:"Delete",action:()=>{this.content.focus(),this.strikethrough()}}),s&&n.push({label:"Remove Inline Code",icon:"Delete",action:()=>{this.content.focus(),this.inlinecode()}}),n.length>0&&n.push({divider:!0}),n.push({label:"Remove Number List",icon:"Delete",action:()=>{this.content.focus();const e=this.Utilities.getSelection()||window.getSelection(),n=document.createRange(),o=t.querySelector("li");o?n.setStart(o,0):n.setStart(t,0),n.collapse(!0),e.removeAllRanges(),e.addRange(n),this.orderedlist()}}),n};_selectNodeForDialog=(t,e,n)=>{if(!t||!this.content.contains(t))return;const o=this.Utilities.getSelection()||window.getSelection(),i=document.createRange();e?i.selectNodeContents(t):i.selectNode(t),o.removeAllRanges(),o.addRange(i),n()};_removeContentElement=t=>{t&&this.content.contains(t)&&(t.remove(),this.NodeManager.refreshUI(),this.content.dispatchEvent(new Event("input",{bubbles:!0})))};_showContextMenu=(t,e)=>{if(!this.contextMenu)return;this.contextMenu.replaceChildren(...e.map(t=>{if(t.divider){const t=document.createElement("div");return t.className="rtb-context-menu-divider",t}return this._createContextMenuItem(t)})),this.contextMenu.style.display="block",this.contextMenu.setAttribute("aria-hidden","false"),this.contextMenu.style.left="0px",this.contextMenu.style.top="0px";const n=this.contextMenu.getBoundingClientRect(),o=window.visualViewport,i=o?.width||window.innerWidth||document.documentElement.clientWidth,r=o?.height||window.innerHeight||document.documentElement.clientHeight,l=o?.offsetLeft||0,s=o?.offsetTop||0,a=Math.min(Math.max(l+4,t.clientX),l+i-n.width-4),d=Math.min(Math.max(s+4,t.clientY),s+r-n.height-4);this.contextMenu.style.left=a-n.left+"px",this.contextMenu.style.top=d-n.top+"px"};_createContextMenuItem=t=>{const e=document.createElement("button");return e.type="button",e.setAttribute("role","menuitem"),e.innerHTML=`${this._contextMenuIcon(t.icon)}<span>${t.label}</span>`,e.addEventListener("click",e=>{e.stopPropagation(),this.hideContextMenu(),t.action()}),e};_contextMenuIcon=t=>{const e=p[t]||{Format:"M280-160v-80h400v80H280Zm0-160v-80h400v80H280Zm-80-160v-320h560v320H200Zm80-80h400v-160H280v160Z"}[t]||"";return e?`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960" aria-hidden="true" focusable="false"><path d="${e}"/></svg>`:""};hideContextMenu=()=>{this.contextMenu&&(this.contextMenu.style.display="none",this.contextMenu.setAttribute("aria-hidden","true"))};_getInlineFormatAtNode=(t,e)=>{let n=t instanceof Element?t:t?.parentElement;for(;n&&n!==this.content&&this.content.contains(n);){switch(e){case"bold":if("bold"===n.style.fontWeight)return n;break;case"italic":if("italic"===n.style.fontStyle)return n;break;case"underline":if(n.style.textDecoration?.includes("underline"))return n;break;case"line-through":if(n.style.textDecoration?.includes("line-through"))return n;break;case"subscript":if("sub"===n.style.verticalAlign)return n;break;case"superscript":if("super"===n.style.verticalAlign)return n;break;case"code":if("CODE"===n.nodeName&&"PRE"!==n.parentElement?.nodeName)return n}n=n.parentElement}return null};findNext=()=>{const t=this.findBar.querySelector(".rtb-find-input").value;t&&(this._findMatches.length||this._runSearch(t),this._findMatches.length&&(this._findIndex=(this._findIndex+1)%this._findMatches.length,this._applyFindMatch()))};findPrev=()=>{const t=this.findBar.querySelector(".rtb-find-input").value;t&&(this._findMatches.length||this._runSearch(t),this._findMatches.length&&(this._findIndex=(this._findIndex<=0?this._findMatches.length:this._findIndex)-1,this._applyFindMatch()))};_runSearch=t=>{this._findMatches=[],this._findIndex=-1;const e=this.findBar.querySelector(".rtb-find-count");if(!t)return void(e.textContent="");const n=t.toLowerCase();if(this.EditMode){const e=document.createTreeWalker(this.content,NodeFilter.SHOW_TEXT);let o;for(;o=e.nextNode();){const e=o.textContent.toLowerCase();let i=0;for(;-1!==(i=e.indexOf(n,i));)this._findMatches.push({node:o,start:i,end:i+t.length}),i++}}else{const e=this.source.value.toLowerCase();let o=0;for(;-1!==(o=e.indexOf(n,o));)this._findMatches.push({start:o,end:o+t.length}),o++}this._findMatches.length||(e.textContent="No results")};_applyFindMatch=()=>{const t=this._findMatches[this._findIndex];if(this.findBar.querySelector(".rtb-find-count").textContent=`${this._findIndex+1} / ${this._findMatches.length}`,this.EditMode){const e=document.createRange();e.setStart(t.node,t.start),e.setEnd(t.node,t.end);const n=this.Utilities.getSelection()||window.getSelection();n.removeAllRanges(),n.addRange(e),t.node.parentElement?.scrollIntoView({block:"center"})}else{const e=this.source.value;this.source.value=e.substring(0,t.start);const n=this.source.scrollHeight;this.source.value=e,this.source.focus({preventScroll:!0}),this.source.setSelectionRange(t.start,t.end),this.source.scrollTop=n<=this.source.clientHeight?0:Math.max(0,n-this.source.clientHeight/2)}};updateWordCount=()=>{if(!this.statusBar||"none"===this.statusBar.style.display)return;const t=this.content.innerText||"",e=t.trim(),n=e?e.split(/\s+/).length:0,o=t.replace(/\n/g,"").length,fmt=t=>t.toLocaleString();this.statusBar.textContent=`${fmt(n)} word${1!==n?"s":""} · ${fmt(o)} character${1!==o?"s":""}`};_syncWordCountVisibility=()=>{const t=!1!==this._rtbHostElement?._visibility?.wordCount;this.statusBar&&(this.statusBar.style.display=t?"":"none");const e=this.shadowRoot.getElementById("blazing-rich-text-file-statusbar-label");e&&(e.textContent=t?"Hide Status Bar":"Show Status Bar")};setReadOnly=t=>{this.content.contentEditable=t?"false":"true",this.content.setAttribute("aria-readonly",t?"true":"false");const e=this.shadowRoot.querySelector(`#${CSS.escape(this.toolbar_id)}`);e&&(e.style.display=t?"none":"")};saveHtml=()=>{const t="block"===this.content.style.display?this.html()||"":this.source.value||"",e=new Blob([t],{type:"text/html"}),n=URL.createObjectURL(e),o=document.createElement("a");o.href=n,o.download=this.createTimestampedHtmlFileName(),o.click(),URL.revokeObjectURL(n)};createTimestampedHtmlFileName=()=>{const t=new Date,pad=t=>String(t).padStart(2,"0");return`html-${[t.getFullYear(),pad(t.getMonth()+1),pad(t.getDate())].join("-")+"_"+[pad(t.getHours()),pad(t.getMinutes()),pad(t.getSeconds())].join("-")}.html`};enablePreview=()=>{this.shadowRoot.getElementById("blazing-rich-text-source").disabled=!0,this.disableButtons()};disablePreview=()=>{this.shadowRoot.getElementById("blazing-rich-text-source").disabled=!1,"block"===this.content.style.display&&this.enableButtons()};format=t=>{this.NodeManager.formatNode(t),this.closeDropdown("blazing-rich-text-format-button-dropdown")};dropdown=t=>{const e=this.shadowRoot.getElementById(t);null!=e&&e.classList.contains("rich-text-box-show")?e.classList.remove("rich-text-box-show"):(this.NodeManager.closeDropdowns(),e.classList.add("rich-text-box-show"))};increaseIndent=()=>{this.content.focus();const t=this.Utilities.getSelection(),e=this.ListProvider.getList(t.anchorNode);e?this.ListProvider.increaseIndent(t,e):this.NodeManager.indentBlock(t,!0)};decreaseIndent=()=>{this.content.focus();const t=this.Utilities.getSelection(),e=this.ListProvider.getList(t.anchorNode);e?this.ListProvider.decreaseIndent(t,e):this.NodeManager.indentBlock(t,!1)};openTextColorDialog=()=>{this.lockToolbar=!0,this.content.focus();const t=this.Utilities.getSelection();if(this.savedSelection=this.Utilities.saveSelection(t),t){const e=this.ColorPickers["rich-text-box-text-color-modal"];this.selection=e.openColorPicker(t,this.content)}else this.Utilities.showFadingBar("No content selected.")};selectTextColor=t=>{this.ColorPickers["rich-text-box-text-color-modal"].selectColor(t)};insertTextColor=()=>{this.ColorPickers["rich-text-box-text-color-modal"].insertColor()};removeTextColor=()=>{this.currentColor=null,this.NodeManager.updateNode("textcolor","None"),this.NodeManager.updateNode("textbgcolor","None")};openTextBackgroundColorDialog=()=>{this.lockToolbar=!0,this.content.focus();const t=this.Utilities.getSelection();if(this.savedSelection=this.Utilities.saveSelection(t),null!==t){const e=this.ColorPickers["rich-text-box-text-bg-color-modal"];this.selection=e.openColorPicker(t,this.content)}else this.Utilities.showFadingBar("No content selected.")};selectTextBackgroundColor=t=>{this.ColorPickers["rich-text-box-text-bg-color-modal"].selectColor(t)};insertTextBackgroundColor=()=>{this.ColorPickers["rich-text-box-text-bg-color-modal"].insertColor()};openTableDialog=()=>{this.lockToolbar=!0,this.content.focus();const t=this.Utilities.getSelection();this.savedSelection=this.Utilities.saveSelection(t),null!==t?this.TableDialog.openTableDialog(t):this.Utilities.showFadingBar("No content selected.")};insertTable=()=>{this.TableDialog.insertTable()};font=t=>{this.NodeManager.updateNode("font",t),this.closeDropdown("blazing-rich-text-font-button-dropdown")};size=t=>{this.clearSettings(),this.NodeManager.updateNode("size",t),this.closeDropdown("blazing-rich-text-size-button-dropdown")};bold=()=>{this.NodeManager.updateNode("bold")};italic=()=>{this.NodeManager.updateNode("italic")};underline=()=>{this.NodeManager.updateNode("underline")};strikethrough=()=>{this.NodeManager.updateNode("line-through")};subscript=()=>{this.NodeManager.updateNode("subscript")};superscript=()=>{this.NodeManager.updateNode("superscript")};inlinecode=()=>{const t=this.Utilities.getSelection();if(!t)return;let e=t.anchorNode instanceof Element?t.anchorNode:t.anchorNode?.parentElement;for(;e&&e!==this.content&&this.content.contains(e);){if("CODE"===e.nodeName&&"PRE"!==e.parentElement?.nodeName)return e.replaceWith(...e.childNodes),void this.NodeManager.refreshUI();e=e.parentElement}if(t.toString().length>0&&t.rangeCount>0){const e=t.getRangeAt(0),n=document.createElement("code");n.appendChild(e.cloneContents()),e.deleteContents(),e.insertNode(n),e.selectNodeContents(n),t.removeAllRanges(),t.addRange(e),this.NodeManager.refreshUI()}};alignleft=()=>{this.NodeManager.updateNode("alignleft")};aligncenter=()=>{this.NodeManager.updateNode("aligncenter")};alignright=()=>{this.NodeManager.updateNode("alignright")};alignjustify=()=>{this.NodeManager.updateNode("alignjustify")};copy=()=>{this.ActionOptions.copy(),this.NodeManager.refreshUI()};cut=()=>{this.ActionOptions.cut(),this.NodeManager.refreshUI()};paste=()=>{this.NodeManager.allSelected&&this.delete(),this.ActionOptions.paste(),this.NodeManager.refreshUI()};closeDropdown=t=>{this.shadowRoot.getElementById(t).classList.remove("rich-text-box-show"),this.lockToolbar=!1,this.content.focus()};delete=()=>{const t=this.Utilities.getSelection();null!==t&&(t.deleteFromDocument(),this.NodeManager.refreshUI())};selectall=()=>{const t=document.createRange();t.selectNodeContents(this.content),this.content.focus();const e=this.Utilities.getSelection();null!==e&&(e.removeAllRanges(),e.addRange(t),this.content.focus())};orderedlist=()=>{this.ListProvider.addlist("OL"),this.NodeManager.refreshUI()};unorderedlist=()=>{this.ListProvider.addlist("UL"),this.NodeManager.refreshUI()};openLinkDialog=()=>{this.lockToolbar=!0,this.content.focus();const t=this.Utilities.getSelection();this.savedSelection=this.Utilities.saveSelection(t),null!==t?this.LinkDialog.openLinkDialog(t):this.Utilities.showFadingBar("No content selected.")};insertLink=()=>{this.LinkDialog.insertLink(),this.NodeManager.refreshUI()};removeLink=()=>{this.LinkDialog.removeLink()};openBlockQuoteDialog=()=>{this.lockToolbar=!0,this.content.focus();const t=this.Utilities.getSelection();this.savedSelection=this.Utilities.saveSelection(t),null!==t?this.BlockQuoteDialog.openBlockQuoteDialog(t):this.Utilities.showFadingBar("No content selected.")};openBlockQuoteDialogForElement=t=>{if(!t||"BLOCKQUOTE"!==t.nodeName||!this.content.contains(t))return;this.lockToolbar=!0;const e=this.Utilities.getSelection()||window.getSelection(),n=document.createRange();n.selectNodeContents(t),e.removeAllRanges(),e.addRange(n),this.savedSelection=this.Utilities.saveSelection(e),this.BlockQuoteDialog.openBlockQuoteDialogForElement(t,n)};insertBlockQuote=()=>{this.BlockQuoteDialog.insertBlockQuote(),this.NodeManager.refreshUI()};openCodeBlockDialog=()=>{this.lockToolbar=!0,this.content.focus();const t=this.Utilities.getSelection();this.savedSelection=this.Utilities.saveSelection(t),null!==t?this.CodeBlockDialog.openCodeBlockDialog(t):this.Utilities.showFadingBar("No content selected.")};openCodeBlockDialogForElement=t=>{if(!t||"PRE"!==t.nodeName||!this.content.contains(t))return;const e=t.querySelector("code")||t;this.lockToolbar=!0;const n=this.Utilities.getSelection()||window.getSelection(),o=document.createRange();o.selectNodeContents(e),n.removeAllRanges(),n.addRange(o),this.savedSelection=this.Utilities.saveSelection(n),this.CodeBlockDialog.openCodeBlockDialogForElement(t,o)};insertCodeBlock=()=>{this.CodeBlockDialog.insertCodeBlock(),this.NodeManager.refreshUI()};openMediaDialog=()=>{this.lockToolbar=!0;const t=this.Utilities.getSelection();this.savedSelection=this.Utilities.saveSelection(t),null!==t?this.MediaDialog.openMediaDialog(t):this.Utilities.showFadingBar("No content selected.")};insertMedia=()=>{this.MediaDialog.insertMedia(),this.NodeManager.refreshUI()};openVideoDialog=()=>{this.lockToolbar=!0;const t=this.Utilities.getSelection();this.savedSelection=this.Utilities.saveSelection(t),null!==t?this.VideoDialog.openVideoDialog(t):this.Utilities.showFadingBar("No content selected.")};openVideoDialogForElement=t=>{this.lockToolbar=!0;const e=this.Utilities.getSelection(),n=this.Utilities.saveSelection(e);this.savedSelection=n,this.VideoDialog.openVideoDialogForElement(t,n)};insertVideo=()=>{this.VideoDialog.insertVideo(),this.NodeManager.refreshUI()};uploadImageDialog=()=>{this.lockToolbar=!0,this.content.focus();const t=this.Utilities.getSelection();this.savedSelection=this.Utilities.saveSelection(t),null!==t?this.UploadImageDialog.openUploadImageDialog(t):this.Utilities.showFadingBar("No content selected.")};uploadImage=()=>{this.UploadImageDialog.insertUploadedImage()};openImageDialog=()=>{this.lockToolbar=!0,this.content.focus();const t=this.Utilities.getSelection();this.savedSelection=this.Utilities.saveSelection(t),null!==t?this.ImageDialog.openImageDialog(t):this.Utilities.showFadingBar("No content selected.")};insertImage=()=>{this.ImageDialog.insertImage(),this.NodeManager.refreshUI()};closeDialog=t=>{this.lockToolbar=!1,this.Utilities.closeDialog(t,this.savedSelection)};enableButtons=()=>{this.shadowRoot.querySelectorAll(".rich-text-box-dropdown-btn").forEach(t=>t.disabled=!1);this.shadowRoot.querySelectorAll(".rich-text-box-menu-item").forEach(t=>t.disabled=!1)};disableButtons=()=>{this.shadowRoot.querySelectorAll(".rich-text-box-dropdown-btn").forEach(t=>t.disabled=!0);this.shadowRoot.querySelectorAll(".rich-text-box-menu-item").forEach(t=>t.disabled=!0)};toggleView=()=>{!0===this.EditMode?this.getHtml():this.getCode()};getHtml=async()=>{this.htmlSelection=this.StateManager.saveSelection(),this.contentScroll=this.Utilities.saveScroll(this.contentContainer),this.statusBar&&(this._statusBarWasVisible="none"!==this.statusBar.style.display,this.statusBar.style.display="none");const t=this.html();this.loadInnerText(t),this.content.style.display="none",this.source.style.display="block",this.source.focus(),this.Utilities.restoreScroll(this.source,this.sourceScroll),this.disableButtons(),"none"!==this.findBar.style.display&&this._runSearch(this.findBar.querySelector(".rtb-find-input").value)};getCode=async()=>{this.sourceScroll=this.Utilities.saveScroll(this.source);const t=this.source.value;this.loadHtml(t),this.content.style.display="block",this.source.style.display="none",this.content.focus(),this.StateManager.restoreSelection(this.htmlSelection),this.Utilities.restoreScroll(this.contentContainer,this.contentScroll),this.enableButtons(),this.statusBar&&this._statusBarWasVisible&&(this.statusBar.style.display="",this.updateWordCount()),"none"!==this.findBar.style.display&&this._runSearch(this.findBar.querySelector(".rtb-find-input").value)};html=()=>(this.NodeManager.removeEmptyNodes(),this.content.innerHTML);loadView=t=>{!0===this.EditMode?this.loadHtml(t):this.loadInnerText(t)};loadHtml=t=>{this.EditMode=!0;const e=this.shadowRoot.getElementById("blazing-rich-text-source");e&&(e.classList.remove("selected"),e.setAttribute("aria-pressed","false")),this.content.innerHTML=null!=t?t:"",this.NodeManager.clearButtons(),this.updateWordCount()};loadInnerText=t=>{this.EditMode=!1;const e=this.shadowRoot.getElementById("blazing-rich-text-source");e&&(e.classList.add("selected"),e.setAttribute("aria-pressed","true")),this.source.value=null!=t?t:"",this.NodeManager.clearButtons()};plaintext=()=>this.content.textContent}class e{constructor(t,e,n,o,i){this.content=t,this.source=e,this.Utilities=n,this.dotNetObjectReference=o,this.contentContainer=i,this.history=[],this.currentIndex=-1,this.currentIndex=-1,this.isNavigating=!1,this.mutationObserver()}mutationObserver=()=>{new MutationObserver((t,e)=>{if("block"!==this.content.style.display||this.isNavigating)this.isNavigating=!1,this.updateBinding();else for(let e of t)switch(e.type){case"attributes":case"characterData":case"subtree":case"childList":this.saveState()}}).observe(this.content,{attributes:!0,childList:!0,subtree:!0,characterData:!0})};updateBinding=()=>{"block"===this.content.style.display?this.dotNetObjectReference&&this.dotNetObjectReference.invokeMethodAsync("UpdateValue",this.content.innerHTML):this.dotNetObjectReference&&this.dotNetObjectReference.invokeMethodAsync("UpdateValue",this.source.value)};saveState=()=>{if(this.PreviousHtml===this.content.innerHTML)return;const t={html:this.content.innerHTML,selection:this.saveSelection(),scroll:this.Utilities.saveScroll(this.contentContainer)};this.PreviousHtml=this.content.innerHTML,-1!==this.currentIndex&&t===this.history[this.currentIndex]||(this.history=this.history.slice(0,this.currentIndex+1),this.history.push(t),this.currentIndex++,this.history.length>60&&(this.history.shift(),this.currentIndex--),this.updateBinding())};restoreLastState=()=>{this.currentIndex>0&&(this.isNavigating=!0,this.restoreState(this.history[this.currentIndex]))};goBack=()=>{this.currentIndex>0&&(this.isNavigating=!0,this.currentIndex--,this.restoreState(this.history[this.currentIndex]))};goForward=()=>{this.currentIndex<this.history.length-1&&(this.isNavigating=!0,this.currentIndex++,this.restoreState(this.history[this.currentIndex]))};saveSelection=()=>{const t=this.Utilities.getSelection();if(t&&t.rangeCount>0){const e=t.getRangeAt(0),n=e.cloneRange();n.selectNodeContents(this.content),n.setEnd(e.startContainer,e.startOffset);const o=n.toString().length;return{start:o,end:o+e.toString().length}}return null};restoreSelection=t=>{if(t)try{const charIndex=(t,e)=>{let n=0;if(t.nodeType===Node.TEXT_NODE)return e<=t.length?[t,e]:[null,e-t.length];for(let o=0;o<t.childNodes.length;o++){const i=t.childNodes[o],[r,l]=charIndex(i,e-n);if(r)return[r,l];n+=i.textContent.length}return[null,e-n]},e=document.createRange();let[n,o]=charIndex(this.content,t.start),[i,r]=charIndex(this.content,t.end);if(n&&i){e.setStart(n,o),e.setEnd(i,r);const t=window.getSelection();t.removeAllRanges(),t.addRange(e)}}catch(t){}};restoreState=t=>{this.content.innerHTML=t.html,this.restoreSelection(t.selection),this.Utilities.restoreScroll(this.contentContainer,t.scroll),this.content.focus()}}class n{constructor(t,e,n){this.shadowRoot=t,this.content=e,this.Utilities=n}_press=(t,e=!0)=>{t&&(t.classList.toggle("selected",e),t.setAttribute("aria-pressed",e?"true":"false"))};formatNode=t=>{let e,n;if(e=this.Utilities.getSelection(),null!==e){let o;if(0==e.toString().length)null!=e.anchorNode&&e.anchorNode!=this.content&&null!=e.anchorNode.parentNode&&this.content.contains(e.anchorNode.parentNode)&&(o=this.getElementByType(e.anchorNode.parentNode,"Format"));else if(1==this.hasCommonAncestor(e)){o=e.getRangeAt(0).commonAncestorContainer,this.isCommonAncestor=!0}else o=this.getElementByContent(e.anchorNode,t,e);if(null!=o&&o!=this.content&&null!=o.parentNode&&this.content.contains(o.parentNode)){if("none"==t){let t=this.Utilities.saveCaretPosition();const e=document.createElement("div");for(let t=0;t<o.style.length;t++){const n=o.style[t];e.style[n]=o.style[n]}for(;o.firstChild;)e.appendChild(o.firstChild);o.parentNode.replaceChild(e,o),this.Utilities.restoreCaretPosition(e,t)}else{let e=this.Utilities.saveCaretPosition();const n=document.createElement(t);n.innerHTML=o.innerHTML;const i=window.getComputedStyle(o);for(let t=0;t<i.length;t++){let e=i[t],r=o.style.getPropertyValue(e);""!==r&&(n.style[e]=r)}o.parentNode.replaceChild(n,o),this.Utilities.restoreCaretPosition(n,e)}return}if(e.toString().length>0){let o;switch(t){case"p":o=document.createElement("p");break;case"h1":o=document.createElement("h1");break;case"h2":o=document.createElement("h2");break;case"h3":o=document.createElement("h3");break;case"h4":o=document.createElement("h4");break;case"h5":o=document.createElement("h5")}null!=o&&e.rangeCount>0&&(n=e.getRangeAt(0),this.hasInvalidElementsInSelection(e)||(o.appendChild(n.cloneContents()),n.deleteContents(),n.insertNode(o),n.selectNodeContents(o),e.removeAllRanges(),e.addRange(n)))}}};updateNode=(t,e,n)=>{let o,i;if(o=this.Utilities.getSelection(),o||n){let r;if(o&&n?(o.removeAllRanges(),o.addRange(n)):n&&(o=window.getSelection(),o.removeAllRanges(),o.addRange(n)),this.isCommonAncestor=!1,0==o.toString().length){if(r=this.getElementByStyle(o.anchorNode,t),null==r&&null!=o.anchorNode&&o.anchorNode!=this.content&&this.content.contains(o.anchorNode)&&o.anchorNode.querySelector){null!=o.anchorNode.querySelector("img")&&(r=o.anchorNode);null!=o.anchorNode.querySelector("embed")&&(r=o.anchorNode);null!=o.anchorNode.querySelector("object")&&(r=o.anchorNode);const t=o.anchorNode.querySelector("table");null!=t&&(r=t)}null==r&&null!=o.anchorNode&&o.anchorNode!=this.content&&null!=o.anchorNode.parentNode&&o.anchorNode.parentNode!=this.content&&this.content.contains(o.anchorNode.parentNode)&&(r=o.anchorNode.parentNode)}else if(1==this.hasCommonAncestor(o)){r=o.getRangeAt(0).commonAncestorContainer,this.isCommonAncestor=!0}else r=this.getElementByContent(o.anchorNode,t,o);if(null!=r){let n;switch(t){case"textcolor":"None"==e?(n=this.getElementByStyle(r,t),null!=n&&this.removeProperty(n,"color",n.style.getPropertyValue("color"))):r.style.setProperty("color",e);break;case"textbgcolor":"None"==e?(n=this.getElementByStyle(r,t),null!=n&&this.removeProperty(n,"background-color",n.style.getPropertyValue("background-color"))):r.style.setProperty("background-color",e);break;case"font":"None"==e?this.removeProperty(r,"font-family",e):r.style.setProperty("font-family",e);break;case"size":"None"==e?this.removeProperty(r,"font-size"):r.style.setProperty("font-size",e);break;case"bold":"bold"==r.style.fontWeight?this.removeProperty(r,"font-weight","bold"):r.style.setProperty("font-weight","bold");break;case"italic":"italic"==r.style.fontStyle?this.removeProperty(r,"font-style","italic"):r.style.setProperty("font-style","italic");break;case"underline":r.style.textDecoration.includes("underline")?this.removeTextDecoration(r,"underline"):this.addTextDecoration(r,"underline");break;case"line-through":r.style.textDecoration.includes("line-through")?this.removeTextDecoration(r,"line-through"):this.addTextDecoration(r,"line-through");break;case"subscript":"sub"==r.style.verticalAlign?this.removeProperty(r,"vertical-align","sub"):r.style.setProperty("vertical-align","sub");break;case"superscript":"super"==r.style.verticalAlign?this.removeProperty(r,"vertical-align","super"):r.style.setProperty("vertical-align","super");break;case"alignleft":"TABLE"===r.nodeName?this.alignTable(r,"alignleft"):"left"==r.style.textAlign?this.removeProperty(r,"text-align","left"):r.style.setProperty("text-align","left");break;case"aligncenter":"TABLE"===r.nodeName?this.alignTable(r,"aligncenter"):"center"==r.style.textAlign?this.removeProperty(r,"text-align","center"):r.style.setProperty("text-align","center");break;case"alignright":"TABLE"===r.nodeName?this.alignTable(r,"alignright"):"right"==r.style.textAlign?this.removeProperty(r,"text-align","right"):r.style.setProperty("text-align","right");break;case"alignjustify":"TABLE"===r.nodeName?this.alignTable(r,"alignjustify"):"justify"==r.style.textAlign?this.removeProperty(r,"text-align","justify"):r.style.setProperty("text-align","justify")}return this.selection=null,void this.refreshUI()}if(o.toString().length>0&&"None"!=e&&!this.isExcluded(o)){let n;switch(t){case"textcolor":n=this.createElement(o),n.style.color=e;break;case"textbgcolor":n=this.createElement(o),n.style.backgroundColor=e;break;case"font":n=this.createElement(o),n.style.fontFamily=e;break;case"size":n=this.createElement(o),n.style.fontSize=e;break;case"bold":n=this.createElement(o),n.style.fontWeight="bold";break;case"italic":n=this.createElement(o),n.style.fontStyle="italic";break;case"underline":n=this.createElement(o),this.addTextDecoration(n,"underline");break;case"line-through":n=this.createElement(o),this.addTextDecoration(n,"line-through");break;case"subscript":n=this.createElement(o),n.style.verticalAlign="sub";break;case"superscript":n=this.createElement(o),n.style.verticalAlign="super";break;case"alignleft":n=document.createElement("div"),n.style.textAlign="left";break;case"aligncenter":n=document.createElement("div"),n.style.textAlign="center";break;case"alignright":n=document.createElement("div"),n.style.textAlign="right";break;case"alignjustify":n=document.createElement("div"),n.style.textAlign="justify"}null!=n&&0!=o.rangeCount&&(i=o.getRangeAt(0),n.appendChild(i.cloneContents()),i.deleteContents(),i.insertNode(n),i.selectNodeContents(n),o.removeAllRanges(),o.addRange(i),this.selection=null,this.refreshUI())}}};alignTable=(t,e)=>{"alignleft"!==e&&"alignjustify"!==e||("auto"==t.style.margin&&this.removeProperty(t,"margin","auto"),"auto"==t.style.marginLeft&&this.removeProperty(t,"margin-left","auto")),"aligncenter"===e&&(t.style.margin&&"auto"===t.style.margin?this.removeProperty(t,"margin","auto"):t.style.setProperty("margin","auto")),"alignright"===e&&("auto"==t.style.margin&&this.removeProperty(t,"margin","auto"),"auto"==t.style.marginLeft?this.removeProperty(t,"margin-left","auto"):t.style.setProperty("margin-left","auto"))};isExcluded=t=>{if(t.anchorNode&&t.anchorNode.querySelector){const e=t.anchorNode.querySelector("table");if(null!=e&&t.toString().trim()!==e.innerText.trim())return!0}if(t.anchorNode.parentNode!==this.content)switch(t.anchorNode.parentNode.nodeName){case"TD":case"CODE":case"PRE":return!0}return!1};indentBlock=(t,e)=>{let n=t.anchorNode;for(;n&&!this.applyMargin(n,e);)n=n.parentNode};applyMargin=(t,e)=>{if(t.nodeType===Node.ELEMENT_NODE&&["P","DIV","H1","H2","H3","H4","H5","H6","OL","UL","SECTION","ARTICLE","HEADER","FOOTER"].includes(t.nodeName)){const n=window.getComputedStyle(t).marginLeft,o=parseFloat(n)||0,i=40;return e?t.style.marginLeft=`${o+i}px`:o<=i?(t.style.marginLeft="",t.hasAttribute("style")&&(t.getAttribute("style")||t.removeAttribute("style"))):t.style.marginLeft=o-i+"px",!0}return!1};selectButtons=t=>{if(null==t||t==this.content||!this.content.contains(t)||1==this.lockToolbar)return;this.clearButtons();const e=this.getButton("blazing-rich-text-bold-button"),n=this.getButton("blazing-rich-text-italic-button"),o=this.getButton("blazing-rich-text-underline-button"),i=this.getButton("blazing-rich-text-strike-button"),r=this.getButton("blazing-rich-text-sub-button"),l=this.getButton("blazing-rich-text-super-button"),s=this.getButton("blazing-rich-text-alignleft-button"),a=this.getButton("blazing-rich-text-aligncenter-button"),d=this.getButton("blazing-rich-text-alignright-button"),c=this.getButton("blazing-rich-text-alignjustify-button");this.textAlign=!1;const h=this.getButton("blazing-rich-text-orderedlist-button"),b=this.getButton("blazing-rich-text-unorderedlist-button"),u=this.getButton("blazing-rich-text-link-button"),g=this.getButton("blazing-rich-text-remove-link-button"),p=this.getButton("blazing-rich-text-textcolor-button"),m=this.getButton("blazing-rich-text-text-bg-color-button"),x=this.getButton("blazing-rich-text-textcolor-remove-button"),v=this.getButton("blazing-rich-text-quote-button"),f=this.getButton("blazing-rich-text-code-block-button"),y=this.getButton("blazing-rich-text-inline-code-button"),w=this.getButton("blazing-rich-text-table-button"),C=this.getButton("blazing-rich-text-image-button"),N=this.getButton("blazing-rich-text-image-upload-button"),S=this.getButton("blazing-rich-text-embed-button"),E=this.getButton("blazing-rich-text-video-button"),R=this.shadowRoot.getElementById("blazing-rich-text-format-button");null!=R&&(R.innerText="Format",this.formatSelected=!1);const T=this.shadowRoot.getElementById("blazing-rich-text-font-button");null!=T&&(T.innerText="Font",this.fontSelected=!1);const B=this.shadowRoot.getElementById("blazing-rich-text-size-button");for(null!=B&&(B.innerText="Size",this.fontSizeSelected=!1);t!==this.content&&null!==t.parentNode&&this.content.contains(t.parentNode)&&"#text"!=t.parentNode.nodeName&&"#document"!=t.parentNode.nodeName;){let D=window.getComputedStyle(t.parentNode);if(null!=t.parentNode.style&&"bold"==t.parentNode.style.fontWeight&&this._press(e),null!=t.parentNode.style&&t.parentNode.style.color&&this._press(p),null!=t.parentNode.style&&t.parentNode.style.backgroundColor&&this._press(m),(null!=t.parentNode.style&&t.parentNode.style.color||t.parentNode.style.backgroundColor)&&this._press(x),"italic"==D.getPropertyValue("font-style")&&this._press(n),D.getPropertyValue("text-decoration").includes("underline")&&"A"!=t.parentNode.nodeName&&this._press(o),D.getPropertyValue("text-decoration").includes("line-through")&&this._press(i),"sub"==D.getPropertyValue("vertical-align")&&this._press(r),"super"==D.getPropertyValue("vertical-align")&&this._press(l),"left"!=D.getPropertyValue("text-align")||this.textAlign||(this._press(s),this.textAlign=!0),"center"!=D.getPropertyValue("text-align")||this.textAlign||(this._press(a),this.textAlign=!0),"right"!=D.getPropertyValue("text-align")||this.textAlign||(this._press(d),this.textAlign=!0),"justify"!=D.getPropertyValue("text-align")||this.textAlign||(this._press(c),this.textAlign=!0),null!=t&&null!=t.style&&t.style.fontFamily&&!this.fontSelected&&(T.innerText=t.style.fontFamily.replace(/^"(.*)"$/,"$1"),this.fontSelected=!0),null!=t&&null!=t.style&&t.style.fontSize&&!this.fontSizeSelected&&(B.innerText=t.style.fontSize,this.fontSizeSelected=!0),"P"!=t.parentNode.nodeName||this.formatSelected||(R.innerText="Paragraph",this.formatSelected=!0),"H1"!=t.parentNode.nodeName||this.formatSelected||(R.innerText="Header 1",this.formatSelected=!0),"H2"!=t.parentNode.nodeName||this.formatSelected||(R.innerText="Header 2",this.formatSelected=!0),"H3"!=t.parentNode.nodeName||this.formatSelected||(R.innerText="Header 3",this.formatSelected=!0),"H4"!=t.parentNode.nodeName||this.formatSelected||(R.innerText="Header 4",this.formatSelected=!0),"H5"!=t.parentNode.nodeName||this.formatSelected||(R.innerText="Header 5",this.formatSelected=!0),"A"==t.parentNode.nodeName&&(this._press(u),this._press(g)),"BLOCKQUOTE"==t.parentNode.nodeName&&this._press(v),"CODE"==t.parentNode.nodeName&&("PRE"!==t.parentNode.parentElement?.nodeName?this._press(y):this._press(f)),"TD"==t.parentNode.nodeName&&this._press(w),"OL"==t.parentNode.nodeName&&this._press(h),"UL"==t.parentNode.nodeName&&this._press(b),"VIDEO"!==t.nodeName&&"SOURCE"!==t.nodeName||E&&this._press(E),t.querySelector){const e=t.querySelector("img");e&&(e.src.startsWith("data")?this._press(N):this._press(C));t.querySelector("object")&&this._press(S);t.querySelector("video")&&E&&this._press(E)}t=t.parentNode}this.closeDropdowns()};closeDropdowns=()=>{this.shadowRoot.querySelectorAll(".rich-text-box-dropdown-content").forEach(function(t){t.classList.contains("rich-text-box-show")&&t.classList.remove("rich-text-box-show")})};getButton=t=>this.shadowRoot.getElementById(t);refreshUI=()=>{const t=this.Utilities.getSelection();null!==t&&this.selectButtons(t.anchorNode),this.removeEmptyNodes(),this.content.focus()};removeEmptyNodes=()=>{const t=this.content;if(t){t.querySelectorAll("*").forEach(t=>{t.hasChildNodes()&&(1!==t.childNodes.length||3!==t.childNodes[0].nodeType||/\S/.test(t.textContent))||t.parentElement&&!this.isNotRemovable(t.nodeName)&&t.parentElement.removeChild(t)})}};createDefaultElement=()=>{if(""===this.content.innerHTML.trim()){const t=document.createElement("div"),e=document.createElement("br");t.appendChild(e),this.content.appendChild(t)}};allSelected=()=>{const t=this.Utilities.getSelection();if(null!==t){if(0===t.rangeCount)return!1;const e=t.getRangeAt(0),n=document.createRange();return n.selectNodeContents(this.content),e.startContainer===n.startContainer&&e.startOffset===n.startOffset&&e.endContainer===n.endContainer&&e.endOffset===n.endOffset}return!1};clearButtons=()=>{this.closeDropdowns();this.shadowRoot.querySelectorAll(".rich-text-box-menu-item, .rich-text-box-menu-item-special").forEach(function(t){t.classList.remove("selected"),t.setAttribute("aria-pressed","false")});const t=this.shadowRoot.getElementById("blazing-rich-text-format-button");null!=t&&(t.innerText="Format",this.formatSelected=!1);const e=this.shadowRoot.getElementById("blazing-rich-text-font-button");null!=e&&(e.innerText="Font",this.fontSelected=!1);const n=this.shadowRoot.getElementById("blazing-rich-text-size-button");null!=n&&(n.innerText="Size",this.fontSizeSelected=!1)};isNotRemovable=t=>{switch(t.toLowerCase()){case"td":case"img":case"i":case"br":case"area":case"base":case"col":case"embed":case"object":case"video":case"source":case"hr":case"input":case"link":case"meta":case"param":case"source":case"track":case"wbr":case"keygen":return!0}return!1};hasCommonAncestor(t){if(!t.rangeCount)return!1;const e=t.getRangeAt(0),n=e.cloneContents(),o=document.createElement("div");o.appendChild(n);const i=e.commonAncestorContainer;return i!==this.content&&this.content.contains(i)&&o.innerHTML==e.commonAncestorContainer.innerHTML&&i.nodeType!==Node.TEXT_NODE?(o.remove(),!0):(o.remove(),!1)}createElement=t=>this.hasInvalidElementsInSelection(t)?document.createElement("div"):document.createElement("span");hasInvalidElementsInSelection=t=>{if(t){const e=["address","article","aside","blockquote","details","dialog","div","dl","fieldset","figcaption","figure","footer","form","header","hgroup","hr","main","menu","nav","ol","p","pre","section","table","ul","button","input","textarea","select","form","h1","h2","h3","h4","h5","h6"],n=t.getRangeAt(0).cloneContents().querySelectorAll("*");for(let t=0;t<n.length;t++){const o=n[t];if(e.includes(o.tagName.toLowerCase()))return!0}}return!1};removeProperty=(t,e,n)=>{null!=t&&t!=this.content&&this.content.contains(t)&&(this.getUserDefinedStyleCount(t)>1?t.style.removeProperty(e,n):"SPAN"==t.nodeName?0==t.childElementCount?t.replaceWith(t.textContent):(t.insertAdjacentHTML("afterend",t.innerHTML),t.remove()):"DIV"==t.nodeName&&!0===this.isCommonAncestor?(t.insertAdjacentHTML("afterend",t.innerHTML),t.remove()):t.hasAttribute("style")&&t.removeAttribute("style"))};addTextDecoration=(t,e)=>{if(null==t||t==this.content||t==this.content.parentNode)return;const n=t.style.textDecoration;if(null!=n&&!n.includes(e)){const o=n?n+" "+e:e;t.style.textDecoration=o}};removeTextDecoration=(t,e)=>{if(null!=t&&t!=this.content&&this.content.contains(t))if(this.getUserDefinedStyleCount(t)>1){const n=t.style.textDecoration.split(" ").filter(t=>t!==e);t.style.textDecoration=n.join(" ")}else"SPAN"==t.nodeName&0==t.childElementCount?t.replaceWith(t.textContent):"SPAN"==t.nodeName?(t.insertAdjacentHTML("afterend",t.innerHTML),t.remove()):t.hasAttribute("style")&&t.removeAttribute("style")};getUserDefinedStyles=t=>{if(null==t||t==this.content||!this.content.contains(t))return;let e={};for(let n=0;n<t.style.length;n++){let o=t.style[n],i=t.style.getPropertyValue(o);e[o]=i}return e};getUserDefinedStyleCount=t=>{if(null==t||t==this.content||!this.content.contains(t))return;let e=0;for(let n=0;n<t.style.length;n++){let o=t.style[n],i=t.style.getPropertyValue(o);if(this.isFormatElement(t)){if("initial"!=i){let t=i.split(" ");if(!this.isMultiValueProperty(o)&&t.length>1)for(let n=0;n<t.length;n++)e++;else e++}}else e++}return e};isMultiValueProperty=t=>{switch(t){case"background-color":case"color":case"font-family":return!0}return!1};getElementByType=(t,e)=>{if(null!=t&&t!=this.content&&this.content.contains(t)){for(;t;){if(t===this.content||!this.content.contains(t))return;if("#text"!=t.nodeName&&"#document"!=t.nodeName)switch(e){case"Format":if(this.isFormatElement(t))return t;break;case"UL":case"OL":case"Element":if(t.nodeName===e)return t}t=t.parentNode}return null}};getElementByContent=(t,e,n)=>{if(null!=t&&t!=this.content&&this.content.contains(t))for(;t;){if(t===this.content||!this.content.contains(t))return;if("#text"!=t.nodeName&&"#document"!=t.nodeName){const o=this.getElementByStyle(t,e);if(null!=o&&this.selectionContainsNode(n,o))return o;if(null!==n&&n.toString().trim()==t.textContent.trim())return t}t=t.parentNode}};selectionContainsNode(t,e){if(null==e||e==this.content||!this.content.contains(e))return!1;if(t.rangeCount>0)for(let n=0;n<t.rangeCount;n++){let o=t.getRangeAt(n);if(this.isNodeInRange(e,o))return!0}return!1}isNodeInRange(t,e){if(null==t||t==this.content||!this.content.contains(t))return!1;let n=t.ownerDocument.createRange();return n.selectNode(t),e.compareBoundaryPoints(Range.START_TO_END,n)<=0&&e.compareBoundaryPoints(Range.END_TO_START,n)>=0}getElementByStyle=(t,e)=>{if(null!=t&&t!=this.content&&this.content.contains(t)){for(;t;){if(t===this.content||!this.content.contains(t))return;if(null!=t.style){let n=null;switch(e){case"textcolor":if(n=t.getAttribute("style"),null!=n&&n.includes("color:"))return t;break;case"textbgcolor":if(n=t.getAttribute("style"),null!=n&&n.includes("background-color:"))return t;break;case"font":if(n=t.getAttribute("style"),null!=n&&n.includes("font-family:"))return t;break;case"size":if(n=t.getAttribute("style"),null!=n&&n.includes("font-size:"))return t;break;case"bold":if(n=t.getAttribute("style"),null!=n&&n.includes("font-weight:")&&"bold"==t.style.fontWeight)return t;break;case"italic":if(n=t.getAttribute("style"),null!=n&&n.includes("font-style:")&&"italic"==t.style.fontStyle)return t;break;case"underline":if(n=t.getAttribute("style"),null!=n&&n.includes("text-decoration:")&&t.style.textDecoration.includes("underline"))return t;break;case"line-through":if(n=t.getAttribute("style"),null!=n&&n.includes("text-decoration:")&&t.style.textDecoration.includes("line-through"))return t;break;case"subscript":if(n=t.getAttribute("style"),null!=n&&n.includes("vertical-align:")&&"sub"==t.style.verticalAlign)return t;break;case"superscript":if(n=t.getAttribute("style"),null!=n&&n.includes("vertical-align:")&&"superscript"==t.style.verticalAlign)return t;break;case"alignleft":if(n=t.getAttribute("style"),null!=n&&n.includes("text-align:")&&"left"==t.style.textAlign)return t;break;case"aligncenter":if(n=t.getAttribute("style"),null!=n&&n.includes("text-align:")&&"center"==t.style.textAlign)return t;break;case"alignright":if(n=t.getAttribute("style"),null!=n&&n.includes("text-align:")&&"right"==t.style.textAlign)return t;break;case"alignjustify":if(n=t.getAttribute("style"),null!=n&&n.includes("text-align:")&&"justify"==t.style.textAlign)return t}}t=t.parentNode}return null}};isFormatElement=t=>!(null==t||t==this.content||!this.content.contains(t))&&("P"==t.nodeName||"H1"==t.nodeName||"H2"==t.nodeName||"H3"==t.nodeName||"H4"==t.nodeName||"H5"==t.nodeName||(null!=t.style&&null!=t.style.textDecoration||void 0));insertLineBreak=t=>{const e=document.createElement("div"),n=document.createElement("br");if(e.appendChild(n),"CODE"==t.nodeName){const n=t.parentNode.parentNode;n.nextSibling?n.parentNode.insertBefore(e,n.nextSibling):n.parentNode.appendChild(e)}else t.parentNode.insertBefore(e,t.nextSibling);const o=document.createRange();o.setStartBefore(n),o.collapse(!0);const i=this.Utilities.getSelection();null!==i&&(i.removeAllRanges(),i.addRange(o))}}class o{constructor(t,e,n,o){this.shadowRoot=t,this.content=e,this.Utilities=n,this.NodeManager=o}addlist=t=>{const e=this.Utilities.getSelection();if(null!==e){if("UL"==t){const t=this.NodeManager.getElementByType(e.anchorNode,"OL");if(null!=t)return void this.replaceList(t,"UL")}else{const t=this.NodeManager.getElementByType(e.anchorNode,"UL");if(null!=t)return void this.replaceList(t,"OL")}const n=this.NodeManager.getElementByType(e.anchorNode,t);if(null!=n)this.removelist(n);else{if(0===e.toString().trim().length){const n=e.getRangeAt(0);let o;const i=document.createElement(t);if(e.anchorNode.parentNode!==this.content&&(o=e.anchorNode.parentNode),e.anchorNode!==this.content&&(o=e.anchorNode),o.nodeType===Node.ELEMENT_NODE||o.nodeType===Node.TEXT_NODE){let t=document.createElement("li"),e=o.cloneNode(!0);this.appendListItemContent(t,e),i.appendChild(t),o.remove()}n.deleteContents(),n.insertNode(i);const r=document.createRange();r.selectNodeContents(i),r.collapse(!1);const l=window.getSelection();l.removeAllRanges(),l.addRange(r)}else{const n=document.createElement(t);if(e.rangeCount>0){const t=e.getRangeAt(0),o=t.cloneContents().childNodes;Array.from(o).forEach(t=>{if(t.nodeType===Node.ELEMENT_NODE||t.nodeType===Node.TEXT_NODE){let e=document.createElement("li"),o=t.cloneNode(!0);this.appendListItemContent(e,o),n.appendChild(e),t.remove()}}),t.deleteContents(),t.insertNode(n),t.selectNodeContents(n),e.removeAllRanges(),e.addRange(t)}}}}};appendListItemContent=(t,e)=>{if(t&&e)if(this.isParagraphChild(e))for(;e.firstChild;)t.appendChild(e.firstChild);else t.appendChild(e)};replaceList=(t,e)=>{if(null===t||t===this.content||!this.content.contains(t))return;const n=this.Utilities.getSelection();let o,i,r,l,s;null!==n&&n.rangeCount>0&&(o=n.getRangeAt(0),i=o.startContainer,r=o.startOffset,l=o.endContainer,s=o.endOffset);const a=document.createElement(e);for(;t.firstChild;)a.appendChild(t.firstChild);if(t.parentNode.replaceChild(a,t),o){const e=document.createRange();t.contains(i)?e.setStart(a,r):e.setStart(i,r),t.contains(l)?e.setEnd(a,s):e.setEnd(l,s),n.removeAllRanges(),n.addRange(e)}};removelist=t=>{if(null==t||t==this.content||!this.content.contains(t))return;if("OL"===t.nodeName||"UL"===t.nodeName)return void this.removeListAsParagraphs(t);let e=null;for(;t.firstChild;){const n=t.firstChild;if("UL"===n.nodeName||"OL"===n.nodeName)e||(e=n),t.parentNode.insertBefore(n,t);else{for(;n.firstChild;){const o=n.firstChild;e||(e=o),t.parentNode.insertBefore(o,t)}t.removeChild(n)}}if(t.parentNode.removeChild(t),e){const t=this.Utilities.getSelection();if(null!==t){const n=document.createRange();n.setStart(e,0),n.collapse(!0),t.removeAllRanges(),t.addRange(n)}}};removeListAsParagraphs=t=>{let e=null;for(;t.firstChild;){const n=t.firstChild;if("LI"!==n.nodeName){e||(e=n),t.parentNode.insertBefore(n,t);continue}const o=document.createElement("p");for(;n.firstChild;){const t=n.firstChild;if("UL"===t.nodeName||"OL"===t.nodeName)break;if(this.isParagraphChild(t)){for(;t.firstChild;)o.appendChild(t.firstChild);n.removeChild(t)}else o.appendChild(t)}for(o.hasChildNodes()||o.appendChild(document.createElement("br")),e||(e=o),t.parentNode.insertBefore(o,t);n.firstChild;)t.parentNode.insertBefore(n.firstChild,t);t.removeChild(n)}if(t.parentNode.removeChild(t),e){const t=this.Utilities.getSelection();if(null!==t){const n=document.createRange();n.setStart(e,0),n.collapse(!0),t.removeAllRanges(),t.addRange(n)}}};isParagraphChild=t=>!(!t||t.nodeType!==Node.ELEMENT_NODE)&&["P","DIV"].includes(t.nodeName);increaseIndent=(t,e)=>{if(!t||!e||"UL"!==e.nodeName&&"OL"!==e.nodeName)return;let n=this.getSelectedNodes(t,e);if(!n||0===n.length)return;let o=n[0].previousElementSibling;if(!o||"LI"!==o.nodeName)return;let i=Array.from(o.children).find(t=>t.nodeName===e.nodeName);i||(i=document.createElement(e.nodeName),o.appendChild(i)),n.forEach(t=>{"LI"===t.nodeName&&i.appendChild(t)}),this.selectListItemStart(t,n[0])};decreaseIndent=(t,e)=>{if(!t||!e||"UL"!==e.nodeName&&"OL"!==e.nodeName)return;const n=this.getSelectedNodes(t,e);if(!n||0===n.length)return;const o=e.parentElement,i=o?o.parentElement:null;if(!o||"LI"!==o.nodeName||!i||"UL"!==i.nodeName&&"OL"!==i.nodeName)return;const r=n[n.length-1],l=document.createElement(e.nodeName);for(;r.nextElementSibling;)l.appendChild(r.nextElementSibling);const s=document.createDocumentFragment();n.forEach(t=>{"LI"===t.nodeName&&s.appendChild(t)}),i.insertBefore(s,o.nextSibling),l.children.length>0&&r.appendChild(l),0===e.children.length&&e.remove(),this.selectListItemStart(t,n[0])};getSelectedNodes=(t,e)=>{const n=[];if(!t.rangeCount)return null;const o=t.getRangeAt(0);if(null!==e){const t=e.children;for(let e=0;e<t.length;e++){const i=t[e];o.intersectsNode(i)&&n.push(i)}return n}return null};saveListSelection=t=>t&&0!==t.rangeCount?t.getRangeAt(0).cloneRange():null;restoreListSelection=(t,e,n)=>{if(t&&e&&this.content.contains(e.startContainer)&&this.content.contains(e.endContainer))return t.removeAllRanges(),void t.addRange(e);this.selectListItem(t,n)};selectListItemStart=(t,e)=>{if(!t||!e)return;const n=document.createRange();n.setStart(e,0),n.collapse(!0),t.removeAllRanges(),t.addRange(n)};selectListItem=(t,e)=>{if(!t||!e)return;const n=document.createRange(),o=this.getFirstTextNode(e);o?n.setStart(o,o.textContent.length):(n.selectNodeContents(e),n.collapse(!1)),n.collapse(!0),t.removeAllRanges(),t.addRange(n)};getFirstTextNode=t=>{if(!t)return null;if(t.nodeType===Node.TEXT_NODE)return t;for(let e=0;e<t.childNodes.length;e++){const n=t.childNodes[e];if("UL"===n.nodeName||"OL"===n.nodeName)continue;const o=this.getFirstTextNode(n);if(o)return o}return null};getList=t=>{for(;t;){if(t===this.content||!this.content.contains(t))return;if("#text"!=t.nodeName&&"#document"!=t.nodeName)switch(t.nodeName){case"OL":case"UL":return t}t=t.parentNode}return null}}class i{constructor(t,e,n){this.shadowRoot=t,this.content=e,this.Utilities=n}copy=()=>{const t=this.Utilities.getSelection();null!==t&&null!==t&&navigator&&navigator.clipboard&&navigator.clipboard.writeText&&navigator.clipboard.writeText(t)};cut=()=>{const t=this.Utilities.getSelection();null!==t&&null!==t&&navigator&&navigator.clipboard&&navigator.clipboard.writeText&&(navigator.clipboard.writeText(t),t.deleteFromDocument())};paste=()=>{navigator.clipboard.readText().then(t=>{this.checkParagraphs(t.trim())||this.checkTables(t.trim())||this.checkLines(t.trim())||this.checkText(t.trim())}).catch(t=>{console.error("Failed to read clipboard contents: ",t)})};checkParagraphs=t=>{let e=t.split(/\n\s*\n/);if(e.length>1){const t=this.Utilities.getSelection();if(null!==t){if(!t.rangeCount)return!1;const n=t.getRangeAt(0);n.deleteContents();let o=document.createDocumentFragment();return e.forEach(t=>{let e=this.checkParagraphTable(t,o);if(e||(e=this.checkParagraphLines(t,o)),!e){let e=document.createElement("p");e.textContent=t.trim(),o.appendChild(e)}}),n.insertNode(o),n.collapse(!0),t.removeAllRanges(),t.addRange(n),!0}}return!1};checkParagraphLines=(t,e)=>{let n=0,o=t.trim().split(/\n+/);return o.length>1&&(o.forEach(t=>{if(n++,n===o.length){let n=document.createElement("p");n.textContent=t.trim(),e.appendChild(n)}else{let n=document.createElement("div");n.textContent=t.trim(),e.appendChild(n)}}),!0)};checkParagraphTable=(t,e)=>{if(this.isTable(t)){let n=this.buildTable(t);return e.appendChild(n),!0}return!1};checkLines=t=>{let e=t.trim().split(/\n+/);if(e.length>1){const t=this.Utilities.getSelection();if(null!==t){if(!t.rangeCount)return!1;const n=t.getRangeAt(0);n.deleteContents();let o=document.createDocumentFragment();return e.forEach(t=>{let e=document.createElement("div");e.textContent=t.trim(),o.appendChild(e)}),n.insertNode(o),n.collapse(!0),t.removeAllRanges(),t.addRange(n),!0}}};checkTables=t=>{if(this.isTable(t)){const e=this.Utilities.getSelection();if(null!==e){if(!e.rangeCount)return!1;const n=e.getRangeAt(0);n.deleteContents();let o=document.createDocumentFragment(),i=this.buildTable(t);return o.appendChild(i),n.insertNode(o),n.collapse(!0),e.removeAllRanges(),e.addRange(n),!0}}};buildTable=t=>{let e=document.createElement("table"),n=t.split("\n"),o=document.createElement("tbody");return n.forEach((t,e)=>{if(t.trim().length>0){let e=t.split("\t"),n=document.createElement("tr");e.forEach(t=>{let e=document.createElement("td");t.trim().length>0&&(e.textContent=t),n.appendChild(e)}),o.appendChild(n)}}),e.appendChild(o),e};isTable=t=>{if(t.includes("\t")){let e=t.split("\n");if(e.length>1&&e[1].trim().length>0){let t=(e[1].match(/\t/g)||[]).length;if(0===t)return!1;for(let n=1;n<e.length;n++){let o=e[n];if(o.trim().length>0){if((o.match(/\t/g)||[]).length!==t)return!1}}return!0}}return!1};checkText=t=>{const e=this.Utilities.getSelection();if(null!==e){if(!e.rangeCount)return!1;const n=e.getRangeAt(0);if(n.deleteContents(),""===this.content.innerHTML.trim()){const e=document.createElement("div"),o=document.createTextNode(t);e.appendChild(o),n.insertNode(e),n.setStartAfter(e),n.setEndAfter(e)}else{const e=document.createTextNode(t);n.insertNode(e),n.setStartAfter(e),n.setEndAfter(e)}e.removeAllRanges(),e.addRange(n)}}}class r{constructor(t,e){this.shadowRoot=t,this.content=e}closeDialog=(t,e)=>{const n=this.shadowRoot.getElementById(t);null!=n&&n.close(),e&&this.restoreSelection(window.getSelection(),e),this.content.focus()};addClasses=(t,e)=>{if(null!=t&&null!=e)if(e.classList.remove(...e.classList),t.length>0){t.split(" ").map(t=>t.trim()).forEach(t=>{t&&e.classList.add(t)})}else e.hasAttribute("class")&&e.removeAttribute("class")};getSelection=()=>{const t=this.shadowRoot.getSelection();return this.content.contains(t.anchorNode)&&this.content.contains(t.focusNode)?t:null};showFadingBar=t=>{const e=this.shadowRoot.getElementById("rich-text-box-message-bar"),n=e.querySelector(".rich-text-box-message");e&&n&&(n.textContent=t,e.classList.remove("rich-text-box-message-hidden"),setTimeout(()=>{this.closeFadingBar()},2e3))};closeFadingBar=()=>{this.shadowRoot.getElementById("rich-text-box-message-bar").classList.add("rich-text-box-message-hidden")};saveSelection=t=>t&&t.rangeCount>0?t.getRangeAt(0).cloneRange():null;restoreSelection=(t,e)=>{t&&e&&(t.removeAllRanges(),t.addRange(e)),this.content.focus()};reselectNode=t=>{const e=document.createRange(),n=window.getSelection();t.childNodes.length>0?e.setStartAfter(t.childNodes[t.childNodes.length-1]):e.setStartAfter(t),e.collapse(!0),n.removeAllRanges(),n.addRange(e)};saveCaretPosition=()=>{const t=this.getSelection();if(null!==t){return{startOffset:t.getRangeAt(0).startOffset,endOffset:t.getRangeAt(0).endOffset}}return null};restoreCaretPosition=(t,e)=>{const n=this.getSelection();if(null!==n&&null!==e){let o=document.createRange();o.setStart(t.firstChild,e.startOffset),o.setEnd(t.firstChild,e.endOffset),n.removeAllRanges(),n.addRange(o)}};saveScroll=t=>t.scrollTop;restoreScroll=(t,e)=>{t.scrollTop=e}}class l{constructor(t,e,n){this.shadowRoot=t,this.content=e,this.Utilities=n,this.addEventListeners()}addEventListeners=()=>{this.dialog=this.shadowRoot.getElementById("rich-text-box-table-modal"),this.dialog.addEventListener("keydown",t=>{"Enter"===t.key&&(t.preventDefault(),this.insertTable()),"Escape"===t.key&&(t.preventDefault(),this.closeDialog())})};openTableDialog=t=>{if(this.resetTableDialog(),this.savedSelection=this.Utilities.saveSelection(t),null!=t.anchorNode&&t.anchorNode!=this.content&&null!=t.anchorNode.parentNode&&t.anchorNode.parentNode!=this.content&&"TD"===t.anchorNode.parentNode.nodeName){const e=this.getTable(t);if(e){const t=this.shadowRoot.getElementById("rich-text-box-table-rows");t.value=e.rows.length,t.disabled=!0;const n=this.shadowRoot.getElementById("rich-text-box-table-columns");n.value=this.getColumns(e),n.disabled=!0;this.shadowRoot.getElementById("rich-text-box-table-width").value=e.style.width;const o=this.shadowRoot.getElementById("rich-text-box-table-classes");if(null!=o){const t=e.classList;o.value=Array.from(t).join(" ")}this.table=e}}else null!==t&&t.rangeCount>0&&(this.tableSelection=t.getRangeAt(0).cloneRange());this.shadowRoot.getElementById("rich-text-box-table-modal").show();const e=this.shadowRoot.getElementById("rich-text-box-table-columns");e&&e.focus()};getTable=t=>"TABLE"===t.anchorNode.parentNode.parentNode.parentNode.nodeName?t.anchorNode.parentNode.parentNode.parentNode:"TABLE"===t.anchorNode.parentNode.parentNode.parentNode.parentNode.nodeName?t.anchorNode.parentNode.parentNode.parentNode.parentNode:void 0;getColumns(t){let e=0;for(let n=0;n<t.rows.length;n++){let o=t.rows[n].cells.length;o>e&&(e=o)}return e}resetTableDialog=()=>{this.table=null,this.tableSelection=null;const t=this.shadowRoot.getElementById("rich-text-box-table-rows");t.value=null,t.disabled=!1;const e=this.shadowRoot.getElementById("rich-text-box-table-columns");e.value=null,e.disabled=!1;this.shadowRoot.getElementById("rich-text-box-table-width").value=null;const n=this.shadowRoot.getElementById("rich-text-box-table-classes");null!=n&&(n.value=null)};insertTable=()=>{const t=this.shadowRoot.getElementById("rich-text-box-table-rows"),e=this.shadowRoot.getElementById("rich-text-box-table-columns"),n=this.shadowRoot.getElementById("rich-text-box-table-width"),o=this.shadowRoot.getElementById("rich-text-box-table-classes");if(0!=t.value.length&&0!=e.value.length){if(null!==this.table)n.value.trim().length>0?this.table.style.width=n.value:(this.table.style.removeProperty("width"),0===this.table.style.cssText.trim().length&&this.table.hasAttribute("style")&&this.table.removeAttribute("style")),null!==o&&this.Utilities.addClasses(o.value,this.table),this.Utilities.reselectNode(this.table);else if(null!=this.tableSelection){const i=this.tableSelection,r=this.createTable(t.value,e.value,n.value);null!==o&&this.Utilities.addClasses(o.value,r),i.deleteContents(),i.insertNode(r);let l=r.querySelector("td, th"),s=document.createRange();s.setStart(l,0),s.setEnd(l,0),this.savedSelection=s}this.closeDialog()}else this.closeDialog()};closeDialog=()=>{this.Utilities.closeDialog("rich-text-box-table-modal",this.savedSelection)};createTable=(t,e,n)=>{const o=parseInt(t,10),i=parseInt(e,10),r=document.createElement("table");n&&(r.style.width=n);const l=document.createElement("tbody");for(let t=0;t<o;t++){const t=document.createElement("tr");for(let e=0;e<i;e++){const e=document.createElement("td");e.innerHTML="​",t.appendChild(e)}l.appendChild(t)}return r.appendChild(l),r};tableTab=()=>{const t=this.Utilities.getSelection();if(null!==t){if(!t.rangeCount)return;const e=this.getCurrentCell(t);if(!e)return;const n=this.getNextElement(e);if(n){n.focus();const e=document.createRange();e.selectNodeContents(n),""===n.innerText&&e.collapse(),t.removeAllRanges(),t.addRange(e)}this.content.focus()}};addRowFromLastCell=()=>{const t=this.Utilities.getSelection();if(null===t||!t.rangeCount)return!1;const e=this.getCurrentCell(t);if(!e)return!1;const n=e.parentElement,o=n?n.parentElement:null,i=o?o.closest("table"):null;if(!n||!o||!i)return!1;if(n.nextElementSibling)return!1;if(e.nextElementSibling)return!1;const r=Math.max(this.getColumns(i),n.cells.length,1),l=document.createElement("tr");for(let t=0;t<r;t++){const t=document.createElement("td");t.innerHTML="​",l.appendChild(t)}o.appendChild(l);const s=l.querySelector("td, th");return s&&this.selectCell(s),!0};getCurrentCell=t=>{if(!t||!t.anchorNode)return null;const e=t.anchorNode.nodeType===Node.ELEMENT_NODE?t.anchorNode:t.anchorNode.parentElement;if(!e||!this.content.contains(e))return null;const n=e.closest("td, th");return n&&this.content.contains(n)?n:null};selectCell=t=>{if(!t)return;this.content.focus();const e=this.Utilities.getSelection()||window.getSelection(),n=document.createRange();n.selectNodeContents(t),n.collapse(!0),e.removeAllRanges(),e.addRange(n)};getNextElement=t=>{let e=t.nextElementSibling;if(!e){let n=t.parentElement.nextElementSibling;n&&(e=n.querySelector("td"))}return e}}class s{constructor(t,e,n){this.shadowRoot=t,this.content=e,this.Utilities=n,this.addEventListeners()}addEventListeners=()=>{this.dialog=this.shadowRoot.getElementById("rich-text-box-embed-modal"),this.dialog.addEventListener("keydown",t=>{"Enter"===t.key&&(t.preventDefault(),this.insertMedia()),"Escape"===t.key&&(t.preventDefault(),this.closeDialog())})};openMediaDialog=t=>{if(null!==t){if(this.resetMediaDialog(),this.savedSelection=this.Utilities.saveSelection(t),t.anchorNode&&t.anchorNode.querySelector&&(this.embed=t.anchorNode.querySelector("object"),null!==this.embed)){this.shadowRoot.getElementById("rich-text-box-embed-source").value=this.embed.data;this.shadowRoot.getElementById("rich-text-box-embed-width").value=this.embed.width;this.shadowRoot.getElementById("rich-text-box-embed-height").value=this.embed.height;this.shadowRoot.getElementById("rich-text-box-embed-type").value=this.embed.type;this.shadowRoot.getElementById("rich-text-box-embed-css-classes").value=Array.from(this.embed.classList).join(" ")}t.rangeCount>0&&(this.embedSelection=t.getRangeAt(0).cloneRange()),this.shadowRoot.getElementById("rich-text-box-embed-modal").show();const e=this.shadowRoot.getElementById("rich-text-box-embed-source");e&&e.focus()}};resetMediaDialog=()=>{this.embed=null,this.embedSelection=null;this.shadowRoot.getElementById("rich-text-box-embed-source").value=null;this.shadowRoot.getElementById("rich-text-box-embed-width").value=null;this.shadowRoot.getElementById("rich-text-box-embed-height").value=null;this.shadowRoot.getElementById("rich-text-box-embed-type").value=null;const t=this.shadowRoot.getElementById("rich-text-box-embed-css-classes");null!=t&&(t.value=null)};insertMedia=()=>{const t=this.shadowRoot.getElementById("rich-text-box-embed-source"),e=this.shadowRoot.getElementById("rich-text-box-embed-width"),n=this.shadowRoot.getElementById("rich-text-box-embed-height"),o=this.shadowRoot.getElementById("rich-text-box-embed-type"),i=this.shadowRoot.getElementById("rich-text-box-embed-css-classes");if(null!==this.embed)this.embed.data=t.value,o.value.trim().length>0?this.embed.type=o.value:this.embed.hasAttribute("type")&&this.embed.removeAttribute("type"),e.value.trim().length>0?this.embed.width=e.value:this.embed.hasAttribute("width")&&this.embed.removeAttribute("width"),n.value.trim().length>0?this.embed.height=n.value:this.embed.hasAttribute("height")&&this.embed.removeAttribute("height"),null!==i&&this.Utilities.addClasses(i.value,this.embed);else if(null!=this.embedSelection&&t.value.length>0){const r=this.embedSelection.cloneRange(),l=document.createElement("object");l.data=t.value,o.value.trim().length>0?l.type=o.value:l.hasAttribute("type")&&l.removeAttribute("type"),e.value.trim().length>0?l.width=e.value:l.hasAttribute("width")&&l.removeAttribute("width"),n.value.trim().length>0?l.height=n.value:l.hasAttribute("height")&&l.removeAttribute("height"),null!==i&&this.Utilities.addClasses(i.value,l),r.deleteContents(),r.insertNode(l),this.Utilities.reselectNode(l),this.embedSelection=r.cloneRange()}this.closeDialog()};closeDialog=()=>{this.Utilities.closeDialog("rich-text-box-embed-modal",this.savedSelection)}}class a{constructor(t,e,n){this.shadowRoot=t,this.content=e,this.Utilities=n,this.video=null,this.videoSelection=null,this.savedSelection=null,this.addEventListeners()}addEventListeners=()=>{this.dialog=this.shadowRoot.getElementById("rich-text-box-video-modal"),this.dialog.addEventListener("keydown",t=>{"Enter"===t.key&&(t.preventDefault(),this.insertVideo()),"Escape"===t.key&&(t.preventDefault(),this.closeDialog())})};_populateFromVideo=t=>{const ge=t=>this.shadowRoot.getElementById(t),e=t.querySelector("source");ge("rich-text-box-video-source").value=e?e.getAttribute("src")||"":t.getAttribute("src")||"",ge("rich-text-box-video-source-type").value=e&&e.getAttribute("type")||"",ge("rich-text-box-video-poster").value=t.getAttribute("poster")||"",ge("rich-text-box-video-width").value=t.getAttribute("width")||"",ge("rich-text-box-video-height").value=t.getAttribute("height")||"",ge("rich-text-box-video-controls").checked=t.hasAttribute("controls"),ge("rich-text-box-video-autoplay").checked=t.hasAttribute("autoplay"),ge("rich-text-box-video-loop").checked=t.hasAttribute("loop"),ge("rich-text-box-video-muted").checked=t.hasAttribute("muted"),ge("rich-text-box-video-css-classes").value=Array.from(t.classList).join(" ")};_showDialog=()=>{this.shadowRoot.getElementById("rich-text-box-video-modal").show(),this.shadowRoot.getElementById("rich-text-box-video-source").focus()};openVideoDialog=t=>{if(null!==t){this.resetVideoDialog(),this.savedSelection=this.Utilities.saveSelection(t);const e=t.anchorNode;e&&("VIDEO"===e.nodeName?this.video=e:"SOURCE"===e.nodeName&&"VIDEO"===e.parentElement?.nodeName?this.video=e.parentElement:e.querySelector&&(this.video=e.querySelector("video")),!this.video&&e.closest&&(this.video=e.closest("video"))),null!==this.video&&this._populateFromVideo(this.video),t.rangeCount>0&&(this.videoSelection=t.getRangeAt(0).cloneRange()),this._showDialog()}};openVideoDialogForElement=(t,e)=>{this.resetVideoDialog(),this.savedSelection=e,this.video=t,this._populateFromVideo(t);const n=this.Utilities.getSelection();n&&n.rangeCount>0&&(this.videoSelection=n.getRangeAt(0).cloneRange()),this._showDialog()};resetVideoDialog=()=>{this.video=null,this.videoSelection=null;const ge=t=>this.shadowRoot.getElementById(t);ge("rich-text-box-video-source").value="",ge("rich-text-box-video-source-type").value="",ge("rich-text-box-video-poster").value="",ge("rich-text-box-video-width").value="",ge("rich-text-box-video-height").value="",ge("rich-text-box-video-controls").checked=!0,ge("rich-text-box-video-autoplay").checked=!1,ge("rich-text-box-video-loop").checked=!1,ge("rich-text-box-video-muted").checked=!1,ge("rich-text-box-video-css-classes").value=""};insertVideo=()=>{const ge=t=>this.shadowRoot.getElementById(t),t=ge("rich-text-box-video-source").value.trim(),e=ge("rich-text-box-video-source-type").value.trim(),n=ge("rich-text-box-video-poster").value.trim(),o=ge("rich-text-box-video-width").value.trim(),i=ge("rich-text-box-video-height").value.trim(),r=ge("rich-text-box-video-controls").checked,l=ge("rich-text-box-video-autoplay").checked,s=ge("rich-text-box-video-loop").checked,a=ge("rich-text-box-video-muted").checked,d=ge("rich-text-box-video-css-classes").value.trim(),applyAttrs=c=>{let h=c.querySelector("source");h||(h=document.createElement("source"),c.appendChild(h)),h.setAttribute("src",t),e?h.setAttribute("type",e):h.removeAttribute("type"),n?c.setAttribute("poster",n):c.removeAttribute("poster"),o?c.setAttribute("width",o):c.removeAttribute("width"),i?c.setAttribute("height",i):c.removeAttribute("height"),r?c.setAttribute("controls",""):c.removeAttribute("controls"),l?c.setAttribute("autoplay",""):c.removeAttribute("autoplay"),s?c.setAttribute("loop",""):c.removeAttribute("loop"),a?c.setAttribute("muted",""):c.removeAttribute("muted"),this.Utilities.addClasses(d,c)};if(null!==this.video)applyAttrs(this.video);else if(null!==this.videoSelection&&t.length>0){const t=this.videoSelection.cloneRange();if(!this.content.contains(t.startContainer))return void this.closeDialog();const e=document.createElement("video");applyAttrs(e),t.deleteContents();let n=t.startContainer;if(n===this.content){const n=this.content.childNodes[t.startOffset]??null;this.content.insertBefore(e,n)}else{for(;n.parentNode&&n.parentNode!==this.content;)if(n=n.parentNode,!this.content.contains(n))return this.content.appendChild(e),this._placeCursorAfterVideo(e),this.videoSelection=null,void this.closeDialog();this.content.insertBefore(e,n.nextSibling)}this._placeCursorAfterVideo(e),this.videoSelection=null}this.closeDialog()};_placeCursorAfterVideo=t=>{if(!t.nextSibling){const e=document.createElement("p");e.appendChild(document.createElement("br")),this.content.insertBefore(e,t.nextSibling)}this._insertedVideo=t};closeDialog=()=>{const t=this._insertedVideo;if(this._insertedVideo=null,this.Utilities.closeDialog("rich-text-box-video-modal",this.savedSelection),t){const e=t.nextSibling;if(e){const t=document.createRange(),n=e.firstChild??e;t.setStart(n,0),t.collapse(!0);const o=window.getSelection();o&&(o.removeAllRanges(),o.addRange(t))}}}}class d{constructor(t,e,n){this.shadowRoot=t,this.content=e,this.Utilities=n,this.addEventListeners()}addEventListeners=()=>{const t=this.shadowRoot.getElementById("rich-text-box-code");this.dialog=this.shadowRoot.getElementById("rich-text-box-code-block-modal"),this.dialog.addEventListener("keydown",e=>{"Enter"===e.key&&e.target!==t&&(e.preventDefault(),e.stopPropagation(),this.insertCodeBlock()),"Escape"===e.key&&(e.preventDefault(),this.closeDialog())})};openCodeBlockDialog=t=>{if(null!==t){this.resetCodeBlockDialog(),this.savedSelection=this.Utilities.saveSelection(t);const e=this.shadowRoot.getElementById("rich-text-box-code"),n=this.shadowRoot.getElementById("rich-text-box-code-css-classes");if(null!=t.anchorNode&&t.anchorNode!=this.content&&null!=t.anchorNode.parentNode&&t.anchorNode.parentNode!=this.content&&this.content.contains(t.anchorNode.parentNode)&&"CODE"===t.anchorNode.parentNode.nodeName){const o=t.anchorNode.parentNode.cloneNode(!0);if(e.value=o.textContent,null!=n){const e=t.anchorNode.parentNode.classList;n.value=Array.from(e).join(" ")}this.codeSelection=t.getRangeAt(0).cloneRange(),this.code=t.anchorNode.parentNode}else t.rangeCount>0&&(this.codeSelection=t.getRangeAt(0).cloneRange());this.shadowRoot.getElementById("rich-text-box-code-block-modal").show(),e&&(e.focus(),e.scrollTop=0,e.scrollLeft=0)}};openCodeBlockDialogForElement=(t,e)=>{if(!t||!this.content.contains(t))return;this.resetCodeBlockDialog(),this.savedSelection=e?e.cloneRange():null;const n=t.querySelector("code")||t,o=this.shadowRoot.getElementById("rich-text-box-code"),i=this.shadowRoot.getElementById("rich-text-box-code-css-classes");o.value=n.textContent,null!=i&&(i.value=Array.from(n.classList).join(" ")),this.codeSelection=e?e.cloneRange():null,this.code=n,this.shadowRoot.getElementById("rich-text-box-code-block-modal").show(),o.focus(),o.scrollTop=0,o.scrollLeft=0};resetCodeBlockDialog=()=>{this.code=null,this.codeSelection=null;this.shadowRoot.getElementById("rich-text-box-code").value=null;const t=this.shadowRoot.getElementById("rich-text-box-code-css-classes");null!=t&&(t.value=null)};insertCodeBlock=()=>{const t=this.shadowRoot.getElementById("rich-text-box-code"),e=this.shadowRoot.getElementById("rich-text-box-code-css-classes");if(null!=this.code){const n=this.code;n.textContent=t.value,null!==e&&this.Utilities.addClasses(e.value,n);const o=n.closest("pre")||n,i=document.createRange();i.setStartAfter(o),i.collapse(!0),this.savedSelection=i}else if(null!=this.codeSelection&&t.value.length>0){const n=this.codeSelection.cloneRange(),o=document.createElement("pre"),i=document.createElement("code");null!==e&&this.Utilities.addClasses(e.value,i),i.textContent=t.value,o.appendChild(i),n.deleteContents(),n.insertNode(o),n.setStartAfter(o),n.setEndAfter(o),this.savedSelection=n}this.closeDialog()};closeDialog=()=>{this.Utilities.closeDialog("rich-text-box-code-block-modal",this.savedSelection)}}class c{constructor(t,e,n){this.shadowRoot=t,this.content=e,this.Utilities=n,this.addEventListeners()}addEventListeners=()=>{const t=this.shadowRoot.getElementById("rich-text-box-quote");this.dialog=this.shadowRoot.getElementById("rich-text-box-block-quote-modal"),this.dialog.addEventListener("keydown",e=>{"Enter"===e.key&&e.target!==t&&(e.preventDefault(),e.stopPropagation(),this.insertBlockQuote()),"Escape"===e.key&&(e.preventDefault(),this.closeDialog())})};openBlockQuoteDialog=t=>{if(null!==t){this.resetBlockQuoteDialog(),this.savedSelection=this.Utilities.saveSelection(t);const e=this.shadowRoot.getElementById("rich-text-box-quote"),n=this.shadowRoot.getElementById("rich-text-box-cite"),o=this.shadowRoot.getElementById("rich-text-box-quote-css-classes");if(null!=t.anchorNode&&t.anchorNode!=this.content&&null!=t.anchorNode.parentNode&&t.anchorNode.parentNode!=this.content&&this.content.contains(t.anchorNode.parentNode)&&"BLOCKQUOTE"==t.anchorNode.parentNode.nodeName){if(e.value=t.anchorNode.parentNode.textContent,null!=t.anchorNode.parentNode.cite&&(n.value=t.anchorNode.parentNode.cite),null!=o){const e=t.anchorNode.parentNode.classList;o.value=Array.from(e).join(" ")}this.quoteSelection=t.getRangeAt(0).cloneRange(),this.quote=t.anchorNode.parentNode}else t.rangeCount>0&&(this.quoteSelection=t.getRangeAt(0).cloneRange());this.shadowRoot.getElementById("rich-text-box-block-quote-modal").show(),e&&(e.focus(),e.scrollTop=0,e.scrollLeft=0)}};openBlockQuoteDialogForElement=(t,e)=>{if(!t||!this.content.contains(t))return;this.resetBlockQuoteDialog(),this.savedSelection=e?e.cloneRange():null;const n=this.shadowRoot.getElementById("rich-text-box-quote"),o=this.shadowRoot.getElementById("rich-text-box-cite"),i=this.shadowRoot.getElementById("rich-text-box-quote-css-classes");n.value=t.textContent,null!=t.cite&&(o.value=t.cite),null!=i&&(i.value=Array.from(t.classList).join(" ")),this.quoteSelection=e?e.cloneRange():null,this.quote=t,this.shadowRoot.getElementById("rich-text-box-block-quote-modal").show(),n.focus(),n.scrollTop=0,n.scrollLeft=0};resetBlockQuoteDialog=()=>{this.quote=null,this.quoteSelection=null;this.shadowRoot.getElementById("rich-text-box-quote").value=null;this.shadowRoot.getElementById("rich-text-box-cite").value=null;const t=this.shadowRoot.getElementById("rich-text-box-quote-css-classes");null!=t&&(t.value=null)};insertBlockQuote=()=>{const t=this.shadowRoot.getElementById("rich-text-box-quote"),e=this.shadowRoot.getElementById("rich-text-box-cite"),n=this.shadowRoot.getElementById("rich-text-box-quote-css-classes");if(null!=this.quote){const o=this.quote;o.textContent=t.value,e.value.trim().length>0?o.setAttribute("cite",e.value):o.hasAttribute("cite")&&o.removeAttribute("cite"),null!==n&&this.Utilities.addClasses(n.value,o);const i=document.createRange();i.setStartAfter(o),i.collapse(!0),this.savedSelection=i}else if(null!=this.quoteSelection&&t.value.length>0){const o=this.quoteSelection.cloneRange(),i=document.createElement("blockquote");i.textContent=t.value,e.value.trim().length>0?i.cite=e.value:i.hasAttribute("cite")&&i.removeAttribute("cite"),null!==n&&this.Utilities.addClasses(n.value,i),o.deleteContents(),o.insertNode(i),o.setStartAfter(i),o.setEndAfter(i),this.savedSelection=o}this.closeDialog()};closeDialog=()=>{this.Utilities.closeDialog("rich-text-box-block-quote-modal",this.savedSelection)}}class h{constructor(t,e,n){this.shadowRoot=t,this.content=e,this.Utilities=n,this.addEventListeners()}addEventListeners=()=>{this.dialog=this.shadowRoot.getElementById("rich-text-box-upload-image-modal"),this.dialog&&this.dialog.addEventListener("keydown",t=>{"Enter"===t.key&&(t.preventDefault(),this.insertUploadedImage()),"Escape"===t.key&&(t.preventDefault(),this.closeDialog())});this.shadowRoot.getElementById("rich-text-box-upload-image-file").addEventListener("change",this.handleFileSelect)};handleFileSelect=t=>{const e=t.target.files[0];this.shadowRoot.getElementById("rich-text-box-upload-image-file-chosen").textContent=e.name;const n=document.createElement("img");if(e){const t=new FileReader;t.onloadend=function(){this.base64String=t.result.split(",")[1],n.src=`data:image/jpg;base64,${this.base64String}`},t.readAsDataURL(e),this.image=n}};openUploadImageDialog=t=>{if(null!==t){if(this.resetUploadImageDialog(),this.savedSelection=this.Utilities.saveSelection(t),t.anchorNode&&t.anchorNode.querySelector&&(this.currentImage=t.anchorNode.querySelector("img"),null!==this.currentImage)){this.shadowRoot.getElementById("rich-text-box-upload-image-width").value=this.currentImage.width;this.shadowRoot.getElementById("rich-text-box-upload-image-height").value=this.currentImage.height;this.shadowRoot.getElementById("rich-text-box-upload-image-alt-text").value=this.currentImage.alt;this.shadowRoot.getElementById("rich-text-box-upload-image-css-classes").value=Array.from(this.currentImage.classList).join(" ")}this.range=t.getRangeAt(0).cloneRange(),this.shadowRoot.getElementById("rich-text-box-upload-image-modal").show();const e=this.shadowRoot.getElementById("rich-text-box-upload-btn");e&&e.focus()}};resetUploadImageDialog=()=>{this.currentImage=null,this.image=null,this.range=null;this.shadowRoot.getElementById("rich-text-box-upload-image-file-chosen").textContent=null;this.shadowRoot.getElementById("rich-text-box-upload-image-file").value=null;this.shadowRoot.getElementById("rich-text-box-upload-image-width").value=null;this.shadowRoot.getElementById("rich-text-box-upload-image-height").value=null;this.shadowRoot.getElementById("rich-text-box-upload-image-alt-text").value=null;const t=this.shadowRoot.getElementById("rich-text-box-upload-image-css-classes");null!=t&&(t.value=null)};insertUploadedImage=()=>{const t=this.shadowRoot.getElementById("rich-text-box-upload-image-width"),e=this.shadowRoot.getElementById("rich-text-box-upload-image-height"),n=this.shadowRoot.getElementById("rich-text-box-upload-image-alt-text"),o=this.shadowRoot.getElementById("rich-text-box-upload-image-css-classes");this.currentImage?(this.image&&this.image.src.length>0&&(this.currentImage.src=this.image.src),t.value.trim().length>0?this.currentImage.width=t.value:this.currentImage.hasAttribute("width")&&this.currentImage.removeAttribute("width"),e.value.trim().length>0?this.currentImage.height=e.value:this.currentImage.hasAttribute("height")&&this.currentImage.removeAttribute("height"),n.value.trim().length>0?this.currentImage.alt=n.value:this.currentImage.hasAttribute("alt")&&this.currentImage.removeAttribute("alt"),null!==o&&this.Utilities.addClasses(o.value,this.currentImage),this.Utilities.reselectNode(this.currentImage)):this.image&&(t.value.length>0?this.image.width=t.value:this.image.hasAttribute("width")&&this.image.removeAttribute("width"),e.value.length>0?this.image.height=e.value:this.image.hasAttribute("height")&&this.image.removeAttribute("height"),n.value.length>0?this.image.alt=n.value:this.image.hasAttribute("alt")&&this.image.removeAttribute("alt"),null!==o&&this.Utilities.addClasses(o.value,this.image),this.range.deleteContents(),this.range.insertNode(this.image),this.Utilities.reselectNode(this.image)),this.closeDialog()};closeDialog=()=>{this.Utilities.closeDialog("rich-text-box-upload-image-modal",this.savedSelection)}}class b{constructor(t,e,n){this.shadowRoot=t,this.content=e,this.Utilities=n,this.addEventListeners()}addEventListeners=()=>{this.dialog=this.shadowRoot.getElementById("rich-text-box-image-modal"),this.dialog.addEventListener("keydown",t=>{"Enter"===t.key&&(t.preventDefault(),this.insertImage()),"Escape"===t.key&&(t.preventDefault(),this.closeDialog())})};openImageDialog=t=>{if(null!==t){if(this.resetImageDialog(),this.savedSelection=this.Utilities.saveSelection(t),t.anchorNode&&t.anchorNode.querySelector&&(this.image=t.anchorNode.querySelector("img"),null!==this.image)){this.shadowRoot.getElementById("rich-text-box-image-webaddress").value=this.image.src;this.shadowRoot.getElementById("rich-text-box-image-width").value=this.image.width;this.shadowRoot.getElementById("rich-text-box-image-height").value=this.image.height;this.shadowRoot.getElementById("rich-text-box-image-alt-text").value=this.image.alt;this.shadowRoot.getElementById("rich-text-box-image-css-classes").value=Array.from(this.image.classList).join(" ")}t&&t.rangeCount>0&&(this.imageSelection=t.getRangeAt(0).cloneRange()),this.shadowRoot.getElementById("rich-text-box-image-modal").show();const e=this.shadowRoot.getElementById("rich-text-box-image-webaddress");e&&e.focus()}};resetImageDialog=()=>{this.image=null,this.imageSelection=null;this.shadowRoot.getElementById("rich-text-box-image-webaddress").value=null;this.shadowRoot.getElementById("rich-text-box-image-width").value=null;this.shadowRoot.getElementById("rich-text-box-image-height").value=null;this.shadowRoot.getElementById("rich-text-box-image-alt-text").value=null;const t=this.shadowRoot.getElementById("rich-text-box-image-css-classes");null!=t&&(t.value=null)};insertImage=()=>{const t=this.shadowRoot.getElementById("rich-text-box-image-webaddress"),e=this.shadowRoot.getElementById("rich-text-box-image-width"),n=this.shadowRoot.getElementById("rich-text-box-image-height"),o=this.shadowRoot.getElementById("rich-text-box-image-alt-text"),i=this.shadowRoot.getElementById("rich-text-box-image-css-classes");if(null!==this.imageSelection){const r=this.imageSelection.cloneRange();if(null!==this.image)t.value.trim().length>0&&(this.image.src=t.value),o.value.trim().length>0?this.image.alt=o.value:this.image.hasAttribute("alt")&&this.image.removeAttribute("alt"),e.value.trim().length>0?this.image.width=e.value:this.image.hasAttribute("width")&&this.image.removeAttribute("width"),n.value.trim().length>0?this.image.height=n.value:this.image.hasAttribute("height")&&this.image.removeAttribute("height"),null!==i&&this.Utilities.addClasses(i.value,this.image),this.Utilities.reselectNode(this.image);else if(t.value.length>0){const l=document.createElement("img");l.src=t.value,e.value.trim().length>0&&(l.width=e.value),n.value.trim().length>0&&(l.height=n.value),o.value.trim().length>0&&(l.alt=o.value),null!==i&&this.Utilities.addClasses(i.value,l),r.deleteContents(),r.insertNode(l),this.Utilities.reselectNode(l)}this.imageSelection=r.cloneRange()}this.closeDialog()};closeDialog=()=>{this.Utilities.closeDialog("rich-text-box-image-modal",this.savedSelection)}}class u{constructor(t,e,n){this.shadowRoot=t,this.content=e,this.Utilities=n,this.addEventListeners()}addEventListeners=()=>{this.dialog=this.shadowRoot.getElementById("rich-text-box-link-modal"),this.dialog.addEventListener("keydown",t=>{"Enter"===t.key&&(t.preventDefault(),this.insertLink()),"Escape"===t.key&&(t.preventDefault(),this.closeDialog())})};openLinkDialog=t=>{if(null!==t){if(this.savedSelection=this.Utilities.saveSelection(t),this.resetLinkDialog(),null!=t.anchorNode&&t.anchorNode!=this.content&&null!=t.anchorNode.parentNode&&t.anchorNode.parentNode!=this.content&&this.content.contains(t.anchorNode.parentNode)&&"A"===t.anchorNode.parentNode.nodeName){this.shadowRoot.getElementById("rich-text-box-linktext").value=t.anchorNode.parentNode.textContent;this.shadowRoot.getElementById("rich-text-box-link-webaddress").value=t.anchorNode.parentNode.getAttribute("href");const e=this.shadowRoot.getElementById("rich-text-box-link-css-classes");if(null!=e){const n=t.anchorNode.parentNode.classList;e.value=Array.from(n).join(" ")}if("_blank"===t.anchorNode.parentNode.getAttribute("target")){this.shadowRoot.getElementById("rich-text-box-link-modal-newtab").checked=!0}this.linkNode=t.anchorNode.parentNode}else{const e=this.shadowRoot.getElementById("rich-text-box-linktext");t.toString().length>0&&(this.linkSelection=t.getRangeAt(0).cloneRange(),e.value=this.linkSelection.toString())}this.shadowRoot.getElementById("rich-text-box-link-modal").show();const e=this.shadowRoot.getElementById("rich-text-box-link-webaddress");e&&e.focus()}};resetLinkDialog=()=>{this.linkNode=null,this.linkSelection=null;this.shadowRoot.getElementById("rich-text-box-linktext").value=null;this.shadowRoot.getElementById("rich-text-box-link-webaddress").value=null;this.shadowRoot.getElementById("rich-text-box-link-modal-newtab").checked=!1;const t=this.shadowRoot.getElementById("rich-text-box-link-css-classes");null!=t&&(t.value=null)};insertLink=()=>{const t=this.shadowRoot.getElementById("rich-text-box-linktext"),e=this.shadowRoot.getElementById("rich-text-box-link-webaddress"),n=this.shadowRoot.getElementById("rich-text-box-link-modal-newtab"),o=this.shadowRoot.getElementById("rich-text-box-link-css-classes");if(0!=e.value.length&&0!=t.value.length){if(null!=this.linkNode){const i=this.linkNode;i.href=e.value,i.textContent=t.value,null!==o&&this.Utilities.addClasses(o.value,i),n.checked?i.target="_blank":i.hasAttribute("target")&&i.removeAttribute("target"),this.Utilities.reselectNode(i)}else if(null!=this.linkSelection){const i=this.linkSelection,r=document.createElement("a");r.href=e.value,r.textContent=t.value,null!==o&&this.Utilities.addClasses(o.value,r),n.checked&&(r.target="_blank"),i.deleteContents(),i.insertNode(r),i.setStartBefore(r.firstChild),i.setEndAfter(r.lastChild),this.savedSelection=i}this.closeDialog()}else this.closeDialog()};closeDialog=()=>{this.Utilities.closeDialog("rich-text-box-link-modal",this.savedSelection)};removeLink=()=>{const t=this.Utilities.getSelection();if(null!==t){const e=this.Utilities.saveSelection(t);if(null!=t.anchorNode&&t.anchorNode!=this.content&&null!=t.anchorNode.parentNode&&this.content.contains(t.anchorNode.parentNode)&&"A"===t.anchorNode.parentNode.nodeName){const e=t.anchorNode.parentNode,n=document.createDocumentFragment();for(;e.firstChild;)n.appendChild(e.firstChild);e.parentNode.insertBefore(n,e),e.parentNode.removeChild(e)}this.Utilities.restoreSelection(t,e)}}}class g{constructor(t,e,n,o,i){this.shadowRoot=t,this.content=e,this.id=n,this.NodeManager=o,this.Utilities=i,this.init()}init=()=>{this.colorPickerDialog=this.shadowRoot.getElementById(this.id),this.colorPickerDialog.addEventListener("keydown",t=>{"Enter"===t.key&&(t.preventDefault(),this.insertColor()),"Escape"===t.key&&(t.preventDefault(),this.closeDialog())}),this.colorPicker=this.colorPickerDialog.querySelector(".rich-text-box-color-picker"),this.redSlider=this.colorPicker.querySelector(".rich-text-box-red-slider"),this.addSliderEventListener(this.redSlider),this.greenSlider=this.colorPicker.querySelector(".rich-text-box-green-slider"),this.addSliderEventListener(this.greenSlider),this.blueSlider=this.colorPicker.querySelector(".rich-text-box-blue-slider"),this.addSliderEventListener(this.blueSlider),this.redValue=this.colorPicker.querySelector(".rich-text-box-red-value"),this.addValueEventListener(this.redValue),this.greenValue=this.colorPicker.querySelector(".rich-text-box-green-value"),this.addValueEventListener(this.greenValue),this.blueValue=this.colorPicker.querySelector(".rich-text-box-blue-value"),this.addValueEventListener(this.blueValue),this.hexInput=this.colorPicker.querySelector(".rich-text-box-hex-input"),this.addHexEventListener(this.hexInput),this.colorDisplay=this.colorPicker.querySelector(".rich-text-box-color-display")};addSliderEventListener=async t=>{t.addEventListener("input",()=>this.updateColor())};addValueEventListener=async t=>{t.addEventListener("input",t=>{let e=Array.from(t.target.classList).find(t=>t.includes("value"));this.colorPicker.querySelector(`.${e.replace("value","slider")}`).value=t.target.value,this.updateColor()}),t.addEventListener("focus",t=>{t.target.select()})};addHexEventListener=async t=>{t.addEventListener("keyup",t=>{/^#?[0-9A-Fa-f]{6}$/.test(t.target.value)&&this.updateFromHex()}),t.addEventListener("change",()=>this.updateFromHex()),t.addEventListener("paste",()=>setTimeout(this.updateFromHex,0)),t.addEventListener("focus",e=>{t.select()})};openColorPicker=(t,e)=>{if(this.resetColorDialog(),this.savedSelection=this.Utilities.saveSelection(t),null!==t&&null!=t.anchorNode&&t.anchorNode!=e&&null!=t.anchorNode.parentNode&&t.anchorNode.parentNode!=e&&e.contains(t.anchorNode.parentNode)&&null!=t.anchorNode.parentNode.style){switch(this.selection=t.getRangeAt(0).cloneRange(),this.id){case"rich-text-box-text-color-modal":t.anchorNode.parentNode.style.color.toString().length>0&&(this.hexInput.value=this.colorToHex(t.anchorNode.parentNode.style.color));break;case"rich-text-box-text-bg-color-modal":t.anchorNode.parentNode.style.backgroundColor.toString().length>0&&(this.hexInput.value=this.colorToHex(t.anchorNode.parentNode.style.backgroundColor))}this.updateFromHex(),this.selection=t.getRangeAt(0).cloneRange()}else null!==t&&t.rangeCount>0&&(this.selection=t.getRangeAt(0).cloneRange());return this.colorPickerDialog.show(),this.selection};insertColor=()=>{let t;switch(this.currentColor=this.getCurrentColor(),this.id){case"rich-text-box-text-color-modal":t="textcolor";break;case"rich-text-box-text-bg-color-modal":t="textbgcolor"}null!==this.selection&&(this.savedSelection=this.Utilities.saveSelection(this.selection),null===this.currentColor?this.NodeManager.updateNode(t,"None",this.selection):this.NodeManager.updateNode(t,this.currentColor,this.selection)),this.closeDialog()};closeDialog=()=>{this.Utilities.closeDialog(this.id,this.savedSelection)};resetColorDialog=()=>{this.selection=null,this.hexInput.value="#000000",this.updateFromHex()};selectColor=t=>{this.hexInput.value=t,this.updateFromHex()};updateColor=()=>{let t=parseInt(this.redSlider.value),e=parseInt(this.greenSlider.value),n=parseInt(this.blueSlider.value),o=`rgb(${t}, ${e}, ${n})`;this.currentColor=o,this.colorDisplay.style.backgroundColor=o,this.redValue.value=t,this.greenValue.value=e,this.blueValue.value=n,this.hexInput.value=this.rgbToHex(t,e,n)};getCurrentColor=()=>this.currentColor;updateFromHex=()=>{let t=this.hexInput.value.trim();if("#"!==t.charAt(0)&&(t="#"+t),/^#[0-9A-Fa-f]{6}$/.test(t)){let e=this.hexToRgb(t);e&&(this.redSlider.value=this.redValue.value=e.r,this.greenSlider.value=this.greenValue.value=e.g,this.blueSlider.value=this.blueValue.value=e.b)}this.updateColor()};rgbToHex=(t,e,n)=>"#"+((1<<24)+(t<<16)+(e<<8)+n).toString(16).slice(1);hexToRgb=t=>{const e=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(t);return e?{r:parseInt(e[1],16),g:parseInt(e[2],16),b:parseInt(e[3],16)}:null};colorToHex=t=>{const e=document.createElement("canvas").getContext("2d");return e.fillStyle=t,e.fillStyle}}window.RTNative_Instances={},window.RTNative_Initialize=(e,n,o,i,r,l)=>{try{null==RTNative_Instances[e]&&(RTNative_Instances[e]=new t(e,n,o,i,l),RTNative_Instances[e].loadHtml(r))}catch(t){console.log(t)}},window.RTNative_Method=(t,e,n)=>{try{const o=RTNative_Instances[e];if(null!=o&&"function"==typeof o[t])return null!=n?o[t](n):o[t]()}catch(t){console.log(t)}};const p={Bold:"M272-200v-560h221q65 0 120 40t55 111q0 51-23 78.5T602-491q25 11 55.5 41t30.5 90q0 89-65 124.5T501-200H272Zm121-112h104q48 0 58.5-24.5T566-372q0-11-10.5-35.5T494-432H393v120Zm0-228h93q33 0 48-17t15-38q0-24-17-39t-44-15h-95v109Z",Italic:"M200-200v-100h160l120-360H320v-100h400v100H580L460-300h140v100H200Z",Underline:"M200-120v-80h560v80H200Zm280-160q-101 0-157-63t-56-167v-330h103v336q0 56 28 91t82 35q54 0 82-35t28-91v-336h103v330q0 104-56 167t-157 63Z",Strikethrough:"M486-160q-76 0-135-45t-85-123l88-38q14 48 48.5 79t85.5 31q42 0 76-20t34-64q0-18-7-33t-19-27h112q5 14 7.5 28.5T694-340q0 86-61.5 133T486-160ZM80-480v-80h800v80H80Zm402-326q66 0 115.5 32.5T674-674l-88 39q-9-29-33.5-52T484-710q-41 0-68 18.5T386-640h-96q2-69 54.5-117.5T482-806Z",Subscript:"M760-160v-80q0-17 11.5-28.5T800-280h80v-40H760v-40h120q17 0 28.5 11.5T920-320v40q0 17-11.5 28.5T880-240h-80v40h120v40H760Zm-525-80 185-291-172-269h106l124 200h4l123-200h107L539-531l186 291H618L482-457h-4L342-240H235Z",Superscript:"M760-600v-80q0-17 11.5-28.5T800-720h80v-40H760v-40h120q17 0 28.5 11.5T920-760v40q0 17-11.5 28.5T880-680h-80v40h120v40H760ZM235-160l185-291-172-269h106l124 200h4l123-200h107L539-451l186 291H618L482-377h-4L342-160H235Z",Alignleft:"M120-120v-80h720v80H120Zm0-160v-80h480v80H120Zm0-160v-80h720v80H120Zm0-160v-80h480v80H120Zm0-160v-80h720v80H120Z",Aligncenter:"M120-120v-80h720v80H120Zm160-160v-80h400v80H280ZM120-440v-80h720v80H120Zm160-160v-80h400v80H280ZM120-760v-80h720v80H120Z",Alignright:"M120-760v-80h720v80H120Zm240 160v-80h480v80H360ZM120-440v-80h720v80H120Zm240 160v-80h480v80H360ZM120-120v-80h720v80H120Z",Alignjustify:"M120-120v-80h720v80H120Zm0-160v-80h720v80H120Zm0-160v-80h720v80H120Zm0-160v-80h720v80H120Zm0-160v-80h720v80H120Z",Copy:"M360-240q-33 0-56.5-23.5T280-320v-480q0-33 23.5-56.5T360-880h360q33 0 56.5 23.5T800-800v480q0 33-23.5 56.5T720-240H360Zm0-80h360v-480H360v480ZM200-80q-33 0-56.5-23.5T120-160v-560h80v560h440v80H200Zm160-240v-480 480Z",Cut:"M760-120 480-400l-94 94q8 15 11 32t3 34q0 66-47 113T240-80q-66 0-113-47T80-240q0-66 47-113t113-47q17 0 34 3t32 11l94-94-94-94q-15 8-32 11t-34 3q-66 0-113-47T80-720q0-66 47-113t113-47q66 0 113 47t47 113q0 17-3 34t-11 32l494 494v40H760ZM600-520l-80-80 240-240h120v40L600-520ZM240-640q33 0 56.5-23.5T320-720q0-33-23.5-56.5T240-800q-33 0-56.5 23.5T160-720q0 33 23.5 56.5T240-640Zm240 180q8 0 14-6t6-14q0-8-6-14t-14-6q-8 0-14 6t-6 14q0 8 6 14t14 6ZM240-160q33 0 56.5-23.5T320-240q0-33-23.5-56.5T240-320q-33 0-56.5 23.5T160-240q0 33 23.5 56.5T240-160Z",Paste:"M200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h167q11-35 43-57.5t70-22.5q40 0 71.5 22.5T594-840h166q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Zm0-80h560v-560h-80v120H280v-120h-80v560Zm280-560q17 0 28.5-11.5T520-800q0-17-11.5-28.5T480-840q-17 0-28.5 11.5T440-800q0 17 11.5 28.5T480-760Z",Delete:"M280-120q-33 0-56.5-23.5T200-200v-520h-40v-80h200v-40h240v40h200v80h-40v520q0 33-23.5 56.5T680-120H280Zm400-600H280v520h400v-520ZM360-280h80v-360h-80v360Zm160 0h80v-360h-80v360ZM280-720v520-520Z",Selectall:"M280-280v-400h400v400H280Zm80-80h240v-240H360v240ZM200-200v80q-33 0-56.5-23.5T120-200h80Zm-80-80v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm80-160h-80q0-33 23.5-56.5T200-840v80Zm80 640v-80h80v80h-80Zm0-640v-80h80v80h-80Zm160 640v-80h80v80h-80Zm0-640v-80h80v80h-80Zm160 640v-80h80v80h-80Zm0-640v-80h80v80h-80Zm160 640v-80h80q0 33-23.5 56.5T760-120Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80h80v80h-80Zm0-160v-80q33 0 56.5 23.5T840-760h-80Z",OrderedList:"M120-80v-60h100v-30h-60v-60h60v-30H120v-60h120q17 0 28.5 11.5T280-280v40q0 17-11.5 28.5T240-200q17 0 28.5 11.5T280-160v40q0 17-11.5 28.5T240-80H120Zm0-280v-110q0-17 11.5-28.5T160-510h60v-30H120v-60h120q17 0 28.5 11.5T280-560v70q0 17-11.5 28.5T240-450h-60v30h100v60H120Zm60-280v-180h-60v-60h120v240h-60Zm180 440v-80h480v80H360Zm0-240v-80h480v80H360Zm0-240v-80h480v80H360Z",UnorderedList:"M360-200v-80h480v80H360Zm0-240v-80h480v80H360Zm0-240v-80h480v80H360ZM200-160q-33 0-56.5-23.5T120-240q0-33 23.5-56.5T200-320q33 0 56.5 23.5T280-240q0 33-23.5 56.5T200-160Zm0-240q-33 0-56.5-23.5T120-480q0-33 23.5-56.5T200-560q33 0 56.5 23.5T280-480q0 33-23.5 56.5T200-400Zm-56.5-263.5Q120-687 120-720t23.5-56.5Q167-800 200-800t56.5 23.5Q280-753 280-720t-23.5 56.5Q233-640 200-640t-56.5-23.5Z",CreateLink:"M680-160v-120H560v-80h120v-120h80v120h120v80H760v120h-80ZM440-280H280q-83 0-141.5-58.5T80-480q0-83 58.5-141.5T280-680h160v80H280q-50 0-85 35t-35 85q0 50 35 85t85 35h160v80ZM320-440v-80h320v80H320Zm560-40h-80q0-50-35-85t-85-35H520v-80h160q83 0 141.5 58.5T880-480Z",RemoveLink:"m770-302-60-62q40-11 65-42.5t25-73.5q0-50-35-85t-85-35H520v-80h160q83 0 141.5 58.5T880-480q0 57-29.5 105T770-302ZM634-440l-80-80h86v80h-6ZM792-56 56-792l56-56 736 736-56 56ZM440-280H280q-83 0-141.5-58.5T80-480q0-69 42-123t108-71l74 74h-24q-50 0-85 35t-35 85q0 50 35 85t85 35h160v80ZM320-440v-80h65l79 80H320Z",Image:"M200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Zm0-80h560v-560H200v560Zm40-80h480L570-480 450-320l-90-120-120 160Zm-40 80v-560 560Z",Undo:"M280-200v-80h284q63 0 109.5-40T720-420q0-60-46.5-100T564-560H312l104 104-56 56-200-200 200-200 56 56-104 104h252q97 0 166.5 63T800-420q0 94-69.5 157T564-200H280Z",Redo:"M396-200q-97 0-166.5-63T160-420q0-94 69.5-157T396-640h252L544-744l56-56 200 200-200 200-56-56 104-104H396q-63 0-109.5 40T240-420q0 60 46.5 100T396-280h284v80H396Z",CodeBlocks:"m384-336 56-57-87-87 87-87-56-57-144 144 144 144Zm192 0 144-144-144-144-56 57 87 87-87 87 56 57ZM200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Zm0-80h560v-560H200v560Zm0-560v560-560Z",Code:"M320-240 80-480l240-240 57 57-184 184 183 183-56 56Zm320 0-57-57 184-184-183-183 56-56 240 240-240 240Z",InlineCode:"M544-400 440-504 240-304l104 104 200-200Zm-47-161 104 104 199-199-104-104-199 199Zm-84-28 216 216-229 229q-24 24-56 24t-56-24l-2-2-26 26H60l126-126-2-2q-24-24-24-56t24-56l229-229Zm0 0 227-227q24-24 56-24t56 24l104 104q24 24 24 56t-24 56L629-373 413-589Z",Preview:"M607.5-372.5Q660-425 660-500t-52.5-127.5Q555-680 480-680t-127.5 52.5Q300-575 300-500t52.5 127.5Q405-320 480-320t127.5-52.5Zm-204-51Q372-455 372-500t31.5-76.5Q435-608 480-608t76.5 31.5Q588-545 588-500t-31.5 76.5Q525-392 480-392t-76.5-31.5ZM214-281.5Q94-363 40-500q54-137 174-218.5T480-800q146 0 266 81.5T920-500q-54 137-174 218.5T480-200q-146 0-266-81.5ZM480-500Zm207.5 160.5Q782-399 832-500q-50-101-144.5-160.5T480-720q-113 0-207.5 59.5T128-500q50 101 144.5 160.5T480-280q113 0 207.5-59.5Z",PermMedia:"M360-440h400L622-620l-92 120-62-80-108 140ZM120-120q-33 0-56.5-23.5T40-200v-520h80v520h680v80H120Zm160-160q-33 0-56.5-23.5T200-360v-440q0-33 23.5-56.5T280-880h200l80 80h280q33 0 56.5 23.5T920-720v360q0 33-23.5 56.5T840-280H280Zm0-80h560v-360H527l-80-80H280v440Zm0 0v-440 440Z",TextColor:"M80 0v-160h800V0H80Zm140-280 210-560h100l210 560h-96l-50-144H368l-52 144h-96Zm176-224h168l-82-232h-4l-82 232Z",TextBackgroundColor:"M80 0v-160h800V0H80Zm504-480L480-584 320-424l103 104 161-160Zm-47-160 103 103 160-159-104-104-159 160Zm-84-29 216 216-189 190q-24 24-56.5 24T367-263l-27 23H140l126-125q-24-24-25-57.5t23-57.5l189-189Zm0 0 187-187q24-24 56.5-24t56.5 24l104 103q24 24 24 56.5T857-640L669-453 453-669Z",RemoveTextFormat:"m528-546-93-93-121-121h486v120H568l-40 94ZM792-56 460-388l-80 188H249l119-280L56-792l56-56 736 736-56 56Z",Quote:"m228-240 92-160q-66 0-113-47t-47-113q0-66 47-113t113-47q66 0 113 47t47 113q0 23-5.5 42.5T458-480L320-240h-92Zm360 0 92-160q-66 0-113-47t-47-113q0-66 47-113t113-47q66 0 113 47t47 113q0 23-5.5 42.5T818-480L680-240h-92ZM320-500q25 0 42.5-17.5T380-560q0-25-17.5-42.5T320-620q-25 0-42.5 17.5T260-560q0 25 17.5 42.5T320-500Zm360 0q25 0 42.5-17.5T740-560q0-25-17.5-42.5T680-620q-25 0-42.5 17.5T620-560q0 25 17.5 42.5T680-500Zm0-60Zm-360 0Z",VideoFile:"M360-240h160q17 0 28.5-11.5T560-280v-40l80 42v-164l-80 42v-40q0-17-11.5-28.5T520-480H360q-17 0-28.5 11.5T320-440v160q0 17 11.5 28.5T360-240ZM240-80q-33 0-56.5-23.5T160-160v-640q0-33 23.5-56.5T240-880h320l240 240v480q0 33-23.5 56.5T720-80H240Zm280-520v-200H240v640h480v-440H520ZM240-800v200-200 640-640Z",Table:"M120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200q-33 0-56.5-23.5T120-200Zm80-400h560v-160H200v160Zm213 200h134v-120H413v120Zm0 200h134v-120H413v120ZM200-400h133v-120H200v120Zm427 0h133v-120H627v120ZM200-200h133v-120H200v120Zm427 0h133v-120H627v120Z",IncreaseIndent:"M120-120v-80h720v80H120Zm320-160v-80h400v80H440Zm0-160v-80h400v80H440Zm0-160v-80h400v80H440ZM120-760v-80h720v80H120Zm0 440v-320l160 160-160 160Z",DecreaseIndent:"M120-120v-80h720v80H120Zm320-160v-80h400v80H440Zm0-160v-80h400v80H440Zm0-160v-80h400v80H440ZM120-760v-80h720v80H120Zm160 440L120-480l160-160v320Z",UploadImage:"M440-200h80v-167l64 64 56-57-160-160-160 160 57 56 63-63v167ZM240-80q-33 0-56.5-23.5T160-160v-640q0-33 23.5-56.5T240-880h320l240 240v480q0 33-23.5 56.5T720-80H240Zm280-520v-200H240v640h480v-440H520ZM240-800v200-200 640-640Z",SaveHtml:"m720-120 160-160-56-56-64 64v-167h-80v167l-64-64-56 56 160 160ZM560 0v-80h320V0H560ZM240-160q-33 0-56.5-23.5T160-240v-560q0-33 23.5-56.5T240-880h280l240 240v121h-80v-81H480v-200H240v560h240v80H240Zm0-80v-560 560Z",HorizontalRule:"M160-440v-80h640v80H160Z",StatusBar:"M200-120q-33 0-56.5-23.5T120-200v-560q0-33 23.5-56.5T200-840h560q33 0 56.5 23.5T840-760v560q0 33-23.5 56.5T760-120H200Zm0-200v120h560v-120H568q-17 18-39.5 29T480-280q-26 0-48.5-11T392-320H200Zm308.5-51.5Q520-383 520-400t-11.5-28.5Q497-440 480-440t-28.5 11.5Q440-417 440-400t11.5 28.5Q463-360 480-360t28.5-11.5ZM200-400h160q0-50 35-85t85-35q50 0 85 35t35 85h160v-360H200v360Zm0 200h560-560Z",Search:"M784-120 532-372q-30 24-69 38t-83 14q-109 0-184.5-75.5T120-580q0-109 75.5-184.5T380-840q109 0 184.5 75.5T640-580q0 44-14 83t-38 69l252 252-56 56ZM380-400q75 0 127.5-52.5T560-580q0-75-52.5-127.5T380-760q-75 0-127.5 52.5T200-580q0 75 52.5 127.5T380-400Z",Help:"M513.5-254.5Q528-269 528-290t-14.5-35.5Q499-340 478-340t-35.5 14.5Q428-311 428-290t14.5 35.5Q457-240 478-240t35.5-14.5ZM442-394h74q0-33 7.5-52t42.5-52q26-26 41-49.5t15-56.5q0-56-41-86t-97-30q-57 0-92.5 30T342-618l66 26q5-18 22.5-39t53.5-21q32 0 48 17.5t16 38.5q0 20-12 37.5T506-526q-44 39-54 59t-10 73Zm38 314q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm0-80q134 0 227-93t93-227q0-134-93-227t-227-93q-134 0-227 93t-93 227q0 134 93 227t227 93Zm0-320Z"};class m extends HTMLElement{constructor(){super(),this._uid="rtb-"+Math.random().toString(36).substring(2,11),this._initialized=!1,this._value=null,this._visibility=m._defaultVisibility(!0),this._previewCssUrls=[],this._previewCssText="",this._customButtons=[]}static _defaultVisibility(t=!0){return{font:t,size:t,format:t,textStylesDivider:t,bold:t,italic:t,underline:t,strikethrough:t,subscript:t,superscript:t,inlineCode:t,formatDivider:t,textColor:t,textColorDivider:t,alignLeft:t,alignCenter:t,alignRight:t,alignJustify:t,alignDivider:t,copy:t,cut:t,paste:t,delete:t,selectAll:t,actionDivider:t,orderedList:t,unorderedList:t,indent:t,listDivider:t,link:t,image:t,imageUpload:t,quote:t,codeBlock:t,embedMedia:t,video:t,table:t,horizontalRule:t,mediaDivider:t,undo:t,redo:t,historyDivider:t,fileMenu:t,saveHtml:t,htmlView:t,preview:t,statusBarToggle:t,search:t,help:t,viewUtilDivider:t,wordCount:!1}}static _injectGlobalStyles(){if(document.getElementById("_rtb-global-styles"))return;const t=document.createElement("style");t.id="_rtb-global-styles",t.textContent="\n/* ── rt-native host defaults ──────────────────────────────────────────────\n Override any --rtb-* variable on rt-native (or a higher-specificity rule\n such as .my-wrapper rt-native or rt-native.my-class) to theme the editor.\n ──────────────────────────────────────────────────────────────────────── */\nrt-native {\n display: block;\n\n /* Toolbar — Fluent 2 colorNeutralBackground1 + colorNeutralStroke1 separator */\n --rtb-toolbar-bg: #ffffff;\n --rtb-toolbar-border-style: solid;\n --rtb-toolbar-border-width: 1px;\n --rtb-toolbar-border-color: #d1d1d1;\n --rtb-toolbar-border-radius: 0px;\n\n /* Toolbar dropdowns */\n --rtb-dropdown-bg: #ffffff;\n --rtb-dropdown-text: #242424;\n --rtb-dropdown-bg-hover: #f5f5f5;\n --rtb-dropdown-text-hover: #242424;\n\n /* Buttons — transparent at rest, no border */\n --rtb-btn-text: #242424;\n --rtb-btn-size: 16px;\n --rtb-btn-font: \"Segoe UI\", Arial, Helvetica, sans-serif;\n --rtb-btn-bg: transparent;\n --rtb-btn-bg-hover: #e8e8e8;\n --rtb-btn-bg-selected: #dcdcdc;\n --rtb-btn-border-style: none;\n --rtb-btn-border-width: 0px;\n --rtb-btn-border-color: #d1d1d1;\n --rtb-btn-border-hover: inherit;\n --rtb-btn-border-selected: inherit;\n --rtb-btn-border-radius: 4px;\n\n /* Editor content area */\n --rtb-content-text: #242424;\n --rtb-content-size: 1rem;\n --rtb-content-font: Arial, Helvetica, Verdana, sans-serif;\n --rtb-content-bg: #ffffff;\n --rtb-content-shadow: none;\n --rtb-content-line-height: 1.55;\n --rtb-content-padding: 20px 24px;\n --rtb-heading-text: #242424;\n --rtb-heading-muted-text: #6b7280;\n --rtb-heading-font: Arial, Helvetica, Verdana, sans-serif;\n --rtb-heading-weight: 600;\n --rtb-heading-line-height: 1.2;\n --rtb-heading-margin: 0 0 0.55em;\n --rtb-h1-size: 2.15em;\n --rtb-h2-size: 1.65em;\n --rtb-h3-size: 1.35em;\n --rtb-h4-size: 1.15em;\n --rtb-h5-size: 1em;\n --rtb-h6-size: 0.92em;\n --rtb-paragraph-margin: 0 0 0.9em;\n --rtb-list-margin: 0.35em 0 0.9em 1.35em;\n --rtb-list-padding-left: 1.35em;\n --rtb-list-item-margin: 0.18em 0;\n --rtb-link-text: #0969da;\n --rtb-link-decoration: underline;\n --rtb-inline-code-bg: rgba(175, 184, 193, 0.2);\n --rtb-inline-code-border-radius: 4px;\n --rtb-code-font: Consolas, Monaco, 'Courier New', monospace;\n --rtb-inline-code-size: 0.92em;\n --rtb-inline-code-padding: 0.15em 0.35em;\n --rtb-hr-border: 1px solid #d1d1d1;\n --rtb-hr-margin: 1.25em 0;\n\n /* Blockquote — brand-blue left accent on a tinted surface */\n --rtb-quote-bg: #f9f9f9;\n --rtb-quote-border-color: #ccc;\n --rtb-quote-border-width: 5px;\n --rtb-quote-text: #242424;\n --rtb-quote-margin: 1.5em 10px;\n --rtb-quote-padding: 0.5em 10px;\n\n /* Code / pre — neutral surface, Fluent medium corner radius */\n --rtb-code-bg: #f5f5f5;\n --rtb-code-border-radius: 4px;\n --rtb-code-margin: 1.2em 0;\n --rtb-code-padding: 0.85em 1em;\n --rtb-table-margin: 1.2em 0;\n --rtb-table-width: auto;\n --rtb-table-border: 1px solid #d1d1d1;\n --rtb-table-cell-min-width: 100px;\n --rtb-table-cell-padding: 6px 10px;\n --rtb-table-header-bg: #f5f5f5;\n --rtb-table-header-text: #242424;\n --rtb-table-header-weight: 600;\n\n /* Editor container — hairline border + featherweight shadow */\n --rtb-editor-width: 100%;\n --rtb-editor-height: 300px;\n --rtb-editor-border-radius: 4px;\n --rtb-editor-border-style: solid;\n --rtb-editor-border-width: 1px;\n --rtb-editor-border-color: #d1d1d1;\n --rtb-editor-shadow: 0 2px 4px rgba(0, 0, 0, 0.06);\n --rtb-editor-resize: auto;\n\n /* Scrollbars — thin pill-shaped Fluent style */\n --rtb-scroll-width: 6px;\n --rtb-scroll-opacity: 1;\n --rtb-scroll-bg: transparent;\n --rtb-scroll-thumb-bg: #c2c2c2;\n --rtb-scroll-thumb-bg-hover: #8a8a8a;\n --rtb-scroll-thumb-radius: 3px;\n\n /* Placeholder */\n --rtb-placeholder-color: #9ca3af;\n\n /* Stacking context — raise the entire editor above surrounding content */\n --rtb-z-index: 1;\n\n /* Modals / dialogs */\n --rtb-modal-bg: #ffffff;\n --rtb-modal-text: #242424;\n --rtb-modal-text-size: 1rem;\n --rtb-modal-text-font: Arial, Helvetica, Verdana, sans-serif;\n --rtb-modal-input-bg: #ffffff;\n --rtb-modal-input-text: #242424;\n --rtb-modal-input-border: #d1d1d1;\n --rtb-modal-checkbox: #0078d4;\n}\n\nrt-native.light,\nrt-native.fluent {\n --rtb-toolbar-bg: #ffffff;\n --rtb-toolbar-border-color: #d1d1d1;\n --rtb-dropdown-bg: #ffffff;\n --rtb-dropdown-text: #242424;\n --rtb-dropdown-bg-hover: #f5f5f5;\n --rtb-dropdown-text-hover: #242424;\n --rtb-btn-text: #242424;\n --rtb-btn-bg: transparent;\n --rtb-btn-bg-hover: #e8e8e8;\n --rtb-btn-bg-selected: #dcdcdc;\n --rtb-btn-border-color: #d1d1d1;\n\n --rtb-content-text: #242424;\n --rtb-content-bg: #ffffff;\n --rtb-heading-text: #242424;\n --rtb-heading-muted-text: #6b7280;\n --rtb-link-text: #0969da;\n --rtb-inline-code-bg: rgba(175, 184, 193, 0.2);\n --rtb-hr-border: 1px solid #d1d1d1;\n\n --rtb-quote-bg: #f9f9f9;\n --rtb-quote-border-color: #ccc;\n --rtb-quote-text: #242424;\n\n --rtb-code-bg: #f5f5f5;\n --rtb-table-border: 1px solid #d1d1d1;\n --rtb-table-header-bg: #f5f5f5;\n --rtb-table-header-text: #242424;\n\n --rtb-editor-border-color: #d1d1d1;\n --rtb-editor-shadow: 0 2px 4px rgba(0, 0, 0, 0.06);\n --rtb-scroll-thumb-bg: #c2c2c2;\n --rtb-scroll-thumb-bg-hover: #8a8a8a;\n --rtb-placeholder-color: #9ca3af;\n\n --rtb-modal-bg: #ffffff;\n --rtb-modal-text: #242424;\n --rtb-modal-input-bg: #ffffff;\n --rtb-modal-input-text: #242424;\n --rtb-modal-input-border: #d1d1d1;\n}\n\nrt-native.dark,\nrt-native.fluent-dark {\n --rtb-toolbar-bg: #1f1f1f;\n --rtb-toolbar-border-color: #3f3f46;\n --rtb-dropdown-bg: #242424;\n --rtb-dropdown-text: #f5f5f5;\n --rtb-dropdown-bg-hover: #323238;\n --rtb-dropdown-text-hover: #ffffff;\n --rtb-btn-text: #f5f5f5;\n --rtb-btn-bg: transparent;\n --rtb-btn-bg-hover: #323238;\n --rtb-btn-bg-selected: #3f3f46;\n --rtb-btn-border-color: #3f3f46;\n\n --rtb-content-text: #f5f5f5;\n --rtb-content-bg: #1f1f1f;\n --rtb-heading-text: #ffffff;\n --rtb-heading-muted-text: #a1a1aa;\n --rtb-link-text: #7ab7ff;\n --rtb-inline-code-bg: rgba(255, 255, 255, 0.12);\n --rtb-hr-border: 1px solid #3f3f46;\n\n --rtb-quote-bg: #10243a;\n --rtb-quote-border-color: #479ef5;\n --rtb-quote-text: #eef6ff;\n\n --rtb-code-bg: #141414;\n --rtb-table-border: 1px solid #52525b;\n --rtb-table-header-bg: #2b2b2b;\n --rtb-table-header-text: #ffffff;\n\n --rtb-editor-border-color: #3f3f46;\n --rtb-editor-shadow: none;\n --rtb-scroll-thumb-bg: #5c5c5c;\n --rtb-scroll-thumb-bg-hover: #7a7a7a;\n --rtb-placeholder-color: #a1a1aa;\n\n --rtb-modal-bg: #242424;\n --rtb-modal-text: #f5f5f5;\n --rtb-modal-input-bg: #1f1f1f;\n --rtb-modal-input-text: #f5f5f5;\n --rtb-modal-input-border: #52525b;\n}\n\n",document.head.appendChild(t)}static get observedAttributes(){return["value","width","height","config","placeholder","readonly","aria-label","label"]}attributeChangedCallback(t,e,n){if(e!==n){if("value"===t&&this._initialized&&(this._value=n||"",RTNative_Method("loadView",this._uid,n)),"width"===t&&this.style.setProperty("--rtb-editor-width",n||"100%"),"height"===t&&this.style.setProperty("--rtb-editor-height",n||"300px"),"config"===t)try{this.configure(JSON.parse(n))}catch(t){}if("placeholder"===t){const t=RTNative_Instances?.[this._uid];t?.content&&(n?t.content.setAttribute("data-placeholder",n):t.content.removeAttribute("data-placeholder"))}if("readonly"===t){const t=RTNative_Instances?.[this._uid];t&&t.setReadOnly(null!==n)}if("aria-label"===t||"label"===t){const t=RTNative_Instances?.[this._uid];t?.content&&n&&t.content.setAttribute("aria-label",n)}}}connectedCallback(){m._injectGlobalStyles(),this.style.setProperty("--rtb-editor-width",this.getAttribute("width")||"100%"),this.style.setProperty("--rtb-editor-height",this.getAttribute("height")||"300px"),this._render(),requestAnimationFrame(()=>this._initialize())}get readOnly(){return this.hasAttribute("readonly")}setReadOnly(t){t?this.setAttribute("readonly",""):this.removeAttribute("readonly")}disconnectedCallback(){window.RTNative_Instances?.[this._uid]&&delete RTNative_Instances[this._uid]}getValue(){return this._initialized?RTNative_Method("html",this._uid)||this._value||"":this._value||""}getPlainText(){return this._initialized&&RTNative_Method("plaintext",this._uid)||""}setValue(t){const e=(t||"").trim().replace(/>\s+</g,"><");this._value=e,this._initialized&&RTNative_Method("loadView",this._uid,e)}setPreviewCssFiles(...t){this._previewCssUrls=t.filter(t=>t&&"string"==typeof t),this._syncToInstance(),this._applyContentStyles()}setPreviewCssFile(t){this.setPreviewCssFiles(...t?[t]:[])}setPreviewCss(t){this._previewCssText=t||"",this._syncToInstance(),this._applyContentStyles()}addCustomButton(t){t&&t.id&&(this._customButtons=[...this._customButtons.filter(e=>e.id!==t.id),t],this._refreshToolbar())}setCustomButtons(t=[]){this._customButtons=Array.isArray(t)?t.filter(t=>t&&t.id):[],this._refreshToolbar()}removeCustomButton(t){this._customButtons=this._customButtons.filter(e=>e.id!==t),this._refreshToolbar()}clearCustomButtons(){this._customButtons=[],this._refreshToolbar()}_syncToInstance(){if(!this._initialized)return;const t=RTNative_Instances[this._uid];t&&(t._previewCssUrls=this._previewCssUrls,t._previewCssText=this._previewCssText)}_scopeCssText(t,e){t=t.replace(/\/\*[\s\S]*?\*\//g,"");let n="",o=0;for(;o<t.length;){for(;o<t.length&&/\s/.test(t[o]);)o++;if(o>=t.length)break;const i=t.indexOf("{",o);if(-1===i)break;const r=t.slice(o,i).trim();let l=1,s=i+1;for(;s<t.length&&l>0;)"{"===t[s]?l++:"}"===t[s]&&l--,s++;const a=t.slice(i+1,s-1);if(o=s,r)if(r.startsWith("@")){const t=(r.match(/^@[\w-]+/)||[""])[0].toLowerCase();["@media","@supports","@layer","@container"].includes(t)?n+=r+" {\n"+this._scopeCssText(a,e)+"}\n":n+=r+" {"+a+"}\n"}else{n+=r.split(",").map(t=>t.trim()).filter(t=>t).map(t=>":root"===t?e:e+" "+t).join(",\n")+" {"+a+"}\n"}}return n}async _applyContentStyles(){if(!this._initialized)return;const t=RTNative_Instances[this._uid];if(!t||!t.shadowRoot)return;const e=t.shadowRoot.getElementById("_rtb-content-preview-styles");e&&e.remove();const n=".rich-text-box-content";let o="";for(const t of this._previewCssUrls)try{const e=await fetch(t);e.ok?o+=this._scopeCssText(await e.text(),n)+"\n":console.warn(`rt-native: failed to load preview CSS (${e.status}): ${t}`)}catch(e){console.warn(`rt-native: could not load preview CSS: ${t}`,e)}if(this._previewCssText&&(o+=this._scopeCssText(this._previewCssText,n)+"\n"),o.trim()){const e=document.createElement("style");e.id="_rtb-content-preview-styles",e.textContent=o,t.shadowRoot.appendChild(e)}}configure(t={}){const{visibility:e,customButtons:n,...o}=t;e&&(e.clearAll&&(this._visibility=m._defaultVisibility(!1)),Object.assign(this._visibility,e)),n&&(this._customButtons=Array.isArray(n)?n.filter(t=>t&&t.id):[]),this._applyCSSVars(o),this._syncPreviewTheme(),this._initialized&&(e||n)&&this._reinitialize()}_syncPreviewTheme(){}_applyCSSVars(t){const set=(t,e)=>{null!=e&&this.style.setProperty(t,e)},e=t.toolbar||{};set("--rtb-toolbar-bg",e.backgroundColor),set("--rtb-toolbar-border-style",e.borderStyle),set("--rtb-toolbar-border-width",e.borderWidth),set("--rtb-toolbar-border-color",e.borderColor),set("--rtb-toolbar-border-radius",e.borderRadius),set("--rtb-dropdown-bg",e.dropdownBackgroundColor),set("--rtb-dropdown-text",e.dropdownTextColor),set("--rtb-dropdown-bg-hover",e.dropdownBackgroundColorHover),set("--rtb-dropdown-text-hover",e.dropdownTextColorHover);const n=t.button||{};set("--rtb-btn-text",n.textColor),set("--rtb-btn-size",n.textSize),set("--rtb-btn-font",n.textFont),set("--rtb-btn-bg",n.backgroundColor),set("--rtb-btn-bg-hover",n.backgroundColorHover),set("--rtb-btn-bg-selected",n.backgroundColorSelected),set("--rtb-btn-border-style",n.borderStyle),set("--rtb-btn-border-width",n.borderWidth),set("--rtb-btn-border-color",n.borderColor),set("--rtb-btn-border-hover",n.borderColorHover),set("--rtb-btn-border-selected",n.borderColorSelected),set("--rtb-btn-border-radius",n.borderRadius);const o=t.content||{};set("--rtb-content-text",o.textColor),set("--rtb-content-size",o.textSize),set("--rtb-content-font",o.textFont),set("--rtb-content-bg",o.backgroundColor),set("--rtb-content-shadow",o.boxShadow);const i=t.editor||{};set("--rtb-editor-width",i.width),set("--rtb-editor-height",i.height),set("--rtb-editor-border-radius",i.borderRadius),set("--rtb-editor-border-style",i.borderStyle),set("--rtb-editor-border-width",i.borderWidth),set("--rtb-editor-border-color",i.borderColor),set("--rtb-editor-shadow",i.boxShadow),null!=i.removeResizeHandle&&set("--rtb-editor-resize",i.removeResizeHandle?"visible":"auto");const r=t.scroll||{};set("--rtb-scroll-width",r.width),set("--rtb-scroll-opacity",r.opacity),set("--rtb-scroll-bg",r.backgroundColor),set("--rtb-scroll-thumb-bg",r.thumbBackground),set("--rtb-scroll-thumb-bg-hover",r.thumbBackgroundHover),set("--rtb-scroll-thumb-radius",r.thumbBorderRadius);const l=t.modal||{};set("--rtb-modal-bg",l.backgroundColor),set("--rtb-modal-text",l.textColor),set("--rtb-modal-text-size",l.textSize),set("--rtb-modal-text-font",l.textFont),set("--rtb-modal-input-bg",l.textboxBackgroundColor),set("--rtb-modal-input-text",l.textboxTextColor),set("--rtb-modal-input-border",l.textboxBorderColor),set("--rtb-modal-checkbox",l.checkboxAccentColor);const s=t.quote||{};set("--rtb-quote-bg",s.backgroundColor),set("--rtb-quote-border-color",s.borderColor),set("--rtb-quote-border-width",s.borderWidth);const a=t.code||{};set("--rtb-code-bg",a.backgroundColor),set("--rtb-code-border-radius",a.borderRadius)}_render(){this.innerHTML=this._buildToolbarHTML()+`<div id="${this._uid}_Shadow"></div>`}_initialize(){const e=this.getAttribute("value")||"",n=null!==this._value?this._value:e;this._value=n;const onValueChange=t=>{this._value=t,this.dispatchEvent(new CustomEvent("change",{detail:{value:t},bubbles:!0,composed:!0}))};window.RTNative_Instances||(window.RTNative_Instances={}),RTNative_Instances[this._uid]=new t(this._uid,`${this._uid}_Shadow`,`${this._uid}_Toolbar`,'\n.rich-text-box-tool-bar {\n background-color: var(--rtb-toolbar-bg, #FFF);\n border-bottom-style: var(--rtb-toolbar-border-style, solid);\n border-bottom-width: var(--rtb-toolbar-border-width, 1px);\n border-bottom-color: var(--rtb-toolbar-border-color, #EEE);\n border-radius: var(--rtb-toolbar-border-radius, 0px);\n padding-left: 3px;\n display: flex;\n flex-wrap: wrap;\n justify-content: flex-start;\n}\n.rich-text-box-tool-bar button {\n background-color: var(--rtb-btn-bg, inherit);\n border-style: var(--rtb-btn-border-style, none);\n border-width: var(--rtb-btn-border-width, 0px);\n border-color: var(--rtb-btn-border-color, #AAA);\n border-radius: var(--rtb-btn-border-radius, 5px);\n color: var(--rtb-btn-text, #000);\n outline: none;\n cursor: pointer;\n transition: 0.3s;\n min-height: calc(var(--rtb-btn-size, 16px) + 14px);\n font-family: var(--rtb-btn-font, Arial, sans-serif);\n margin: 4px 1px;\n}\n.rich-text-box-tool-bar button:hover {\n background-color: var(--rtb-btn-bg-hover, #e8e8e8);\n border-color: var(--rtb-btn-border-hover, inherit);\n}\n.rich-text-box-tool-bar button.selected {\n background-color: var(--rtb-btn-bg-selected, #dcdcdc);\n border-color: var(--rtb-btn-border-selected, inherit);\n}\n.rich-text-box-tool-bar button:disabled {\n background-color: transparent;\n color: #999;\n cursor: default;\n}\n.rich-text-box-tool-bar button svg {\n fill: var(--rtb-btn-text, #000);\n width: var(--rtb-btn-size, 16px);\n height: var(--rtb-btn-size, 16px);\n}\n.rich-text-box-tool-bar button:hover svg {\n fill: var(--rtb-btn-text, #000);\n}\n.rich-text-box-tool-bar button:disabled svg {\n fill: #999;\n}\n.rich-text-box-menu-item {}\n.rich-text-box-menu-item-special {}\n.rich-text-box-menu-item svg,\n.rich-text-box-menu-item-special svg {\n display: block;\n height: auto;\n width: auto;\n max-height: 100%;\n max-width: 100%;\n}\n.rich-text-box-menu-item:disabled { color: #999; }\n\n.rich-text-box-container {\n resize: both;\n overflow: var(--rtb-editor-resize, auto);\n border-style: var(--rtb-editor-border-style, solid);\n border-width: var(--rtb-editor-border-width, 1px);\n border-color: var(--rtb-editor-border-color, #EEE);\n border-radius: var(--rtb-editor-border-radius, 0px);\n box-shadow: var(--rtb-editor-shadow, none);\n max-width: var(--rtb-editor-width, 100%);\n height: var(--rtb-editor-height, 300px);\n display: flex;\n flex-direction: column;\n z-index: var(--rtb-z-index, 1);\n}\n.rich-text-box-content-container {\n width: 100%;\n height: 100%;\n overflow: auto;\n background-color: var(--rtb-content-bg, #FFF);\n box-shadow: var(--rtb-content-shadow, none);\n}\n.rtb-status-bar {\n /* Mirror the toolbar\'s background and typography so every theme is\n automatically reflected without adding status-bar-specific CSS vars. */\n background-color: var(--rtb-toolbar-bg, #ffffff);\n color: var(--rtb-btn-text, #242424);\n font-family: var(--rtb-btn-font, Arial, Helvetica, Verdana, sans-serif);\n font-size: calc(var(--rtb-btn-size, 16px) * 0.9);\n border-top: 1px solid var(--rtb-toolbar-border-color, #d1d1d1);\n padding: 5px 24px 5px 10px;\n text-align: right;\n user-select: none;\n flex-shrink: 0;\n letter-spacing: 0.2px;\n}\n.rtb-find-bar {\n display: flex;\n flex-shrink: 0;\n align-items: center;\n justify-content: flex-end;\n gap: 4px;\n width: 100%;\n background-color: var(--rtb-toolbar-bg, #fff);\n border-bottom: 1px solid var(--rtb-toolbar-border-color, #d1d1d1);\n padding: 4px 8px;\n box-sizing: border-box;\n}\n.rtb-find-input {\n border: 1px solid var(--rtb-toolbar-border-color, #d1d1d1);\n border-radius: 4px;\n padding: 3px 7px;\n font-size: calc(var(--rtb-btn-size, 16px) * 0.875);\n color: var(--rtb-btn-text, #242424);\n background-color: var(--rtb-content-bg, #fff);\n outline: none;\n width: 180px;\n}\n.rtb-find-input:focus {\n border-color: var(--rtb-btn-bg-selected, #a0a0a0);\n}\n.rtb-find-count {\n font-size: calc(var(--rtb-btn-size, 16px) * 0.8);\n color: var(--rtb-btn-text, #666);\n min-width: 54px;\n text-align: center;\n white-space: nowrap;\n user-select: none;\n}\n.rtb-find-nav-btn, .rtb-find-close-btn {\n background: none;\n border: none;\n border-radius: 4px;\n cursor: pointer;\n padding: 2px 4px;\n display: flex;\n align-items: center;\n justify-content: center;\n color: var(--rtb-btn-text, #242424);\n}\n.rtb-find-nav-btn svg, .rtb-find-close-btn svg {\n width: 18px;\n height: 18px;\n fill: currentColor;\n}\n.rtb-find-nav-btn:hover, .rtb-find-close-btn:hover {\n background-color: var(--rtb-btn-bg-hover, #e8e8e8);\n}\n.rtb-context-menu {\n background-color: var(--rtb-dropdown-bg, #fff);\n border: 1px solid rgba(0,0,0,0.12);\n border-radius: 4px;\n box-shadow: 0 8px 16px rgba(0,0,0,0.14), 0 0 2px rgba(0,0,0,0.12);\n box-sizing: border-box;\n display: none;\n min-width: 168px;\n padding: 4px;\n position: fixed;\n z-index: 9000;\n}\n.rtb-context-menu button {\n align-items: center;\n appearance: none;\n background: transparent;\n border: 0;\n border-radius: 4px;\n box-sizing: border-box;\n color: var(--rtb-dropdown-text, #242424);\n cursor: pointer;\n display: flex;\n font-family: var(--rtb-btn-font, Arial, Helvetica, sans-serif);\n font-size: 14px;\n gap: 10px;\n justify-content: flex-start;\n line-height: 20px;\n min-height: 32px;\n padding: 6px 8px;\n text-align: left;\n width: 100%;\n}\n.rtb-context-menu button:hover {\n background-color: var(--rtb-dropdown-bg-hover, #e5e5e5);\n color: var(--rtb-dropdown-text-hover, #000);\n}\n.rtb-context-menu svg {\n fill: currentColor;\n flex: 0 0 auto;\n height: 18px;\n width: 18px;\n}\n.rtb-context-menu-divider {\n border-top: 1px solid rgba(128,128,128,0.18);\n margin: 4px 0;\n}\n.rich-text-box-content[data-placeholder]:empty::before {\n content: attr(data-placeholder);\n color: var(--rtb-placeholder-color, #9ca3af);\n pointer-events: none;\n font-style: italic;\n}\n.rich-text-box-content[contenteditable="false"] {\n cursor: default;\n opacity: 0.85;\n}\n.rich-text-box-content {\n color: var(--rtb-content-text, #000);\n font-size: var(--rtb-content-size, 16px);\n font-family: var(--rtb-content-font, Arial, sans-serif);\n line-height: var(--rtb-content-line-height, 1.55);\n padding: var(--rtb-content-padding, 20px 24px);\n padding-bottom: 10px;\n width: 100%;\n min-height: 100%;\n box-sizing: border-box;\n white-space: pre-wrap;\n word-wrap: break-word;\n outline: 0px solid transparent;\n}\n.rich-text-box-content h1,\n.rich-text-box-content h2,\n.rich-text-box-content h3,\n.rich-text-box-content h4,\n.rich-text-box-content h5,\n.rich-text-box-content h6 {\n color: var(--rtb-heading-text, var(--rtb-content-text, #242424));\n font-family: var(--rtb-heading-font, var(--rtb-content-font, Arial, sans-serif));\n font-weight: var(--rtb-heading-weight, 600);\n line-height: var(--rtb-heading-line-height, 1.2);\n margin: var(--rtb-heading-margin, 0 0 0.55em);\n padding: 0;\n border: 0;\n border-bottom: 0;\n text-decoration: none !important;\n}\n.rich-text-box-content h1 { font-size: var(--rtb-h1-size, 2.15em); }\n.rich-text-box-content h2 { font-size: var(--rtb-h2-size, 1.65em); }\n.rich-text-box-content h3 { font-size: var(--rtb-h3-size, 1.35em); }\n.rich-text-box-content h4 { font-size: var(--rtb-h4-size, 1.15em); }\n.rich-text-box-content h5 { font-size: var(--rtb-h5-size, 1em); }\n.rich-text-box-content h6 {\n color: var(--rtb-heading-muted-text, #6b7280);\n font-size: var(--rtb-h6-size, 0.92em);\n}\n.rich-text-box-content p { margin: var(--rtb-paragraph-margin, 0 0 0.9em); }\n.rich-text-box-content ul,\n.rich-text-box-content ol {\n margin: var(--rtb-list-margin, 0.35em 0 0.9em 1.35em);\n padding-left: var(--rtb-list-padding-left, 1.35em);\n}\n.rich-text-box-content li { margin: var(--rtb-list-item-margin, 0.18em 0); }\n.rich-text-box-content a {\n color: var(--rtb-link-text, #0969da);\n text-decoration: var(--rtb-link-decoration, underline);\n}\n.rich-text-box-content blockquote {\n background: var(--rtb-quote-bg, #f9f9f9);\n border-left: var(--rtb-quote-border-width, 5px) solid var(--rtb-quote-border-color, #ccc);\n color: var(--rtb-quote-text, var(--rtb-content-text, #242424));\n margin: var(--rtb-quote-margin, 1.5em 10px);\n padding: var(--rtb-quote-padding, 0.5em 10px);\n}\n.rich-text-box-content blockquote > :first-child {\n margin-top: 0;\n}\n.rich-text-box-content blockquote > :last-child {\n margin-bottom: 0;\n}\n.rich-text-box-content code {\n background: var(--rtb-inline-code-bg, rgba(175, 184, 193, 0.2));\n border-radius: var(--rtb-inline-code-border-radius, 4px);\n font-family: var(--rtb-code-font, Consolas, Monaco, \'Courier New\', monospace);\n font-size: var(--rtb-inline-code-size, 0.92em);\n padding: var(--rtb-inline-code-padding, 0.15em 0.35em);\n}\n.rich-text-box-content pre {\n background: var(--rtb-code-bg, #f5f5f5);\n border-radius: var(--rtb-code-border-radius, 4px);\n margin: var(--rtb-code-margin, 1.2em 0);\n overflow-x: auto;\n padding: var(--rtb-code-padding, 0.85em 1em);\n white-space: pre-wrap;\n}\n.rich-text-box-content pre code {\n background: transparent;\n border-radius: 0;\n display: block;\n padding: 0;\n}\n.rich-text-box-content hr {\n border: 0;\n border-top: var(--rtb-hr-border, 1px solid #d1d1d1);\n margin: var(--rtb-hr-margin, 1.25em 0);\n padding: 8px 0;\n cursor: pointer;\n box-sizing: content-box;\n}\n.rich-text-box-content table {\n border-collapse: collapse;\n margin: var(--rtb-table-margin, 1.2em 0);\n width: var(--rtb-table-width, auto);\n}\n.rich-text-box-content th,\n.rich-text-box-content td {\n border: var(--rtb-table-border, 1px solid #d1d1d1);\n min-width: var(--rtb-table-cell-min-width, 100px);\n padding: var(--rtb-table-cell-padding, 6px 10px);\n}\n.rich-text-box-content th {\n background: var(--rtb-table-header-bg, #f5f5f5);\n color: var(--rtb-table-header-text, var(--rtb-content-text, #242424));\n font-weight: var(--rtb-table-header-weight, 600);\n}\n.rich-text-box-content img { cursor: pointer; }\n.rich-text-box-source {\n padding: 10px;\n width: 100%;\n height: 100%;\n box-sizing: border-box;\n min-height: 25px;\n color: var(--rtb-content-text, #000) !important;\n font-size: var(--rtb-content-size, 16px) !important;\n white-space: pre-wrap;\n background-color: var(--rtb-content-bg, #FFF);\n box-shadow: var(--rtb-content-shadow, none);\n border-style: none;\n display: none;\n resize: none;\n margin: 0;\n line-height: 1.6;\n letter-spacing: 0.04em;\n outline: 0px solid transparent;\n}\n.rich-text-box-divider-btn {\n background-color: inherit;\n align-items: center;\n justify-content: center;\n text-align: center;\n border: none !important;\n outline: none;\n cursor: pointer;\n padding: 3px 4px;\n transition: 0.3s;\n margin: 4px 1px;\n}\n.rich-text-box-divider-btn[disabled],\n.rich-text-box-divider-btn[disabled]:hover,\n.rich-text-box-divider-btn[disabled]:focus,\n.rich-text-box-divider-btn[disabled]:active {\n background: unset;\n color: unset;\n cursor: default;\n}\n.rich-text-box-divider {\n min-height: 25px;\n height: var(--rtb-btn-size, 16px);\n background-color: var(--rtb-btn-text, #000);\n display: block;\n border-left: 0.5px solid rgba(255, 255, 255, 0.6);\n opacity: 0.5;\n}\n.rich-text-box-scroll::-webkit-scrollbar {\n height: var(--rtb-scroll-width, 10px);\n width: var(--rtb-scroll-width, 10px);\n opacity: var(--rtb-scroll-opacity, 1);\n}\n.rich-text-box-scroll::-webkit-scrollbar-track {\n background-color: var(--rtb-scroll-bg, transparent);\n}\n.rich-text-box-scroll::-webkit-scrollbar-thumb {\n background: var(--rtb-scroll-thumb-bg, #AAA);\n border-radius: var(--rtb-scroll-thumb-radius, 0);\n}\n.rich-text-box-scroll::-webkit-scrollbar-thumb:hover {\n background: var(--rtb-scroll-thumb-bg-hover, #DDD);\n cursor: default;\n}\n.rich-text-box-dropdown { position: relative; display: inline-block; }\n.rich-text-box-dropdown-content {\n display: none;\n position: absolute;\n background-color: var(--rtb-dropdown-bg, #FFF);\n border-style: var(--rtb-btn-border-style, none);\n border-width: var(--rtb-btn-border-width, 0px);\n border-color: var(--rtb-btn-border-color, #AAA);\n border-radius: 5px;\n max-height: 200px;\n overflow: auto;\n box-shadow: 0px 4px 8px 0px rgba(0, 0, 0, 0.2);\n font-family: Arial, sans-serif !important;\n z-index: 2;\n}\n.rich-text-box-dropdown-btn {\n font-size: var(--rtb-btn-size, 16px);\n min-height: calc(var(--rtb-btn-size, 16px) + 14px);\n padding: 0 10px;\n}\n.rich-text-box-file-button,\n.rich-text-box-font-button,\n.rich-text-box-size-button,\n.rich-text-box-format-button {\n font-family: var(--rtb-btn-font, "Segoe UI", Arial, Helvetica, sans-serif);\n font-size: 0.82rem;\n font-weight: 600;\n letter-spacing: 0;\n}\n.rich-text-box-file-content {\n min-width: 220px;\n max-width: 320px;\n padding: 4px;\n background-color: var(--rtb-dropdown-bg, #fff);\n border: 1px solid var(--rtb-toolbar-border-color, #e0e0e0);\n border-radius: 8px;\n box-shadow: var(--rtb-file-menu-shadow, 0 8px 16px rgba(0, 0, 0, 0.14), 0 0 2px rgba(0, 0, 0, 0.12));\n font-family: var(--rtb-btn-font, "Segoe UI", Arial, Helvetica, sans-serif) !important;\n letter-spacing: 0.04em;\n line-height: 1.45;\n}\n.rich-text-box-format-content { min-width: 185px; }\n.rich-text-box-font-content { min-width: 180px; }\n.rich-text-box-size-content { min-width: 80px; }\n.rich-text-box-dropdown-content a {\n color: var(--rtb-dropdown-text, #000);\n font-size: 18px;\n padding: 10px 14px;\n text-decoration: none;\n display: block;\n}\n.rich-text-box-dropdown a:hover,\n.rich-text-box-menu-item.active {\n background-color: var(--rtb-dropdown-bg-hover, #e5e5e5);\n color: var(--rtb-dropdown-text-hover, #000);\n}\n.rich-text-box-show { display: block; }\n.rich-text-box-file-content a {\n align-items: center;\n border-radius: 4px;\n box-sizing: border-box;\n color: var(--rtb-dropdown-text, #242424);\n display: flex;\n font-size: 0.88rem;\n gap: 24px;\n justify-content: space-between;\n line-height: inherit;\n min-height: 32px;\n padding: 6px 8px;\n text-decoration: none;\n}\n.rich-text-box-file-content a:hover {\n background-color: var(--rtb-dropdown-bg-hover, #f5f5f5);\n color: var(--rtb-dropdown-text-hover, #242424);\n}\n.rich-text-box-file-content a:active {\n background-color: var(--rtb-btn-bg-selected, #ebebeb);\n}\n.rich-text-box-menu-shortcut {\n color: var(--rtb-dropdown-text, #707070);\n font-size: 12px;\n font-weight: 400;\n line-height: inherit;\n margin-left: 6px;\n opacity: 0.6;\n}\n.rich-text-box-dropdown-divider {\n height: 0;\n margin: 2px 0;\n border: 0;\n border-top: 1px solid var(--rtb-file-menu-divider, var(--rtb-toolbar-border-color, #e0e0e0));\n}\n\n.rich-text-box-modal {\n background-color: var(--rtb-modal-bg, #fefefe);\n color: var(--rtb-modal-text, #000);\n font-size: var(--rtb-modal-text-size, 16px);\n font-family: var(--rtb-modal-text-font, Arial, sans-serif);\n letter-spacing: 0.03em;\n margin: auto;\n padding: 6px 16px 14px;\n border: 1px solid #888;\n width: 800px;\n box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);\n border-radius: 5px;\n user-select: none;\n z-index: 2;\n}\n.rich-text-box-modal-title {\n font-weight: bold;\n font-size: calc(var(--rtb-modal-text-size, 16px) + 2px);\n}\n.rtb-modal-header {\n display: flex;\n flex-direction: row;\n justify-content: space-between;\n align-items: center;\n flex-shrink: 0;\n padding-bottom: 10px;\n}\n.rich-text-box-form-left { float: left; width: 380px; }\n.rich-text-box-form-right { float: right; width: 380px; }\n@media screen and (max-width: 850px) {\n .rich-text-box-form-left,\n .rich-text-box-form-right { float: none; }\n .rich-text-box-modal { width: 400px; }\n}\n@media screen and (max-width: 500px) {\n .rich-text-box-modal { width: 100%; }\n}\n.clearfix { overflow: auto; }\n.clearfix::after { content: ""; clear: both; display: table; }\n.rich-text-box-modal-close {\n appearance: none;\n background: none;\n border: none;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n flex-shrink: 0;\n align-self: center;\n width: 32px;\n height: 32px;\n min-width: 32px;\n min-height: 32px;\n max-width: 32px;\n max-height: 32px;\n border-radius: 50%;\n padding: 0;\n color: var(--rtb-modal-text, #000);\n cursor: pointer;\n opacity: 0.75;\n}\n/* SVG icon inside the close button — block display eliminates inline\n baseline offset so the flex centering acts on the icon bounds only.\n Width/height are set via CSS (not just SVG attributes) so the size is\n reliably enforced regardless of browser presentation-attribute handling. */\n.rich-text-box-modal-close svg { display: block; width: 11px; height: 11px; }\n.rich-text-box-modal-close:hover {\n opacity: 1;\n background: rgba(128, 128, 128, 0.18);\n}\n.rich-text-box-modal-close:focus-visible {\n outline: 2px solid currentColor;\n outline-offset: 1px;\n}\n.rich-text-box-modal-body { padding: 2px 8px; }\n.rtb-preview-window {\n flex: 1;\n min-height: 0;\n width: 100%;\n overflow: auto;\n border: 1px solid var(--rtb-editor-border-color, #eee);\n border-radius: 4px;\n box-sizing: border-box;\n display: block;\n}\n.rtb-preview-window::-webkit-scrollbar {\n height: var(--rtb-scroll-width, 10px);\n width: var(--rtb-scroll-width, 10px);\n}\n.rtb-preview-window::-webkit-scrollbar-track { background: transparent; }\n.rtb-preview-window::-webkit-scrollbar-thumb {\n background: var(--rtb-scroll-thumb-bg, #AAA);\n border-radius: var(--rtb-scroll-thumb-radius, 0);\n}\n.rtb-preview-window::-webkit-scrollbar-thumb:hover {\n background: var(--rtb-scroll-thumb-bg-hover, #DDD);\n}\n/* Preview dialog — flex column layout so the dialog itself is resizable and\n the html viewer automatically fills the remaining space.\n display is intentionally NOT set here so the browser UA rule\n dialog:not([open]){display:none} still applies when the dialog is closed.\n display:flex is only added when the dialog is open (has the [open] attr). */\n.rtb-preview-dialog {\n padding: 6px 12px 10px;\n flex-direction: column;\n height: 520px;\n min-width: 400px;\n min-height: 300px;\n max-width: 95vw;\n max-height: 95vh;\n resize: both;\n overflow: hidden;\n box-sizing: border-box;\n position: fixed;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n margin: 0;\n z-index: 9999;\n}\n.rtb-preview-dialog[open] {\n display: flex;\n}\n.rtb-preview-dialog::backdrop {\n background: transparent;\n}\n.rtb-preview-dialog-body {\n display: flex;\n flex-direction: column;\n flex: 1;\n min-height: 0;\n overflow: hidden;\n gap: 6px;\n}\n.rtb-help-dialog {\n position: fixed;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n margin: 0;\n z-index: 9999;\n width: min(95vw, 750px);\n padding: 0;\n box-sizing: border-box;\n max-height: 88vh;\n overflow-x: hidden;\n overflow-y: auto;\n border: none;\n scrollbar-color: var(--rtb-scroll-thumb-bg, #AAA) var(--rtb-scroll-bg, transparent);\n scrollbar-width: thin;\n}\n.rtb-help-dialog::-webkit-scrollbar {\n width: var(--rtb-scroll-width, 10px);\n}\n.rtb-help-dialog::-webkit-scrollbar-track {\n background-color: var(--rtb-scroll-bg, transparent);\n}\n.rtb-help-dialog::-webkit-scrollbar-thumb {\n background: var(--rtb-scroll-thumb-bg, #AAA);\n border-radius: var(--rtb-scroll-thumb-radius, 0);\n}\n.rtb-help-dialog::-webkit-scrollbar-thumb:hover {\n background: var(--rtb-scroll-thumb-bg-hover, #DDD);\n}\n.rtb-help-dialog[open] { display: block; }\n.rtb-help-dialog::backdrop { background: transparent; }\n.rtb-help-sticky-header {\n position: sticky;\n top: 0;\n z-index: 10;\n display: flex;\n flex-direction: row;\n justify-content: space-between;\n align-items: center;\n background: var(--rtb-modal-bg, #fefefe);\n padding: 10px 20px 11px;\n border-radius: 5px 5px 0 0;\n}\n.rtb-help-sticky-header .rich-text-box-modal-title {\n font-weight: bold;\n font-size: calc(var(--rtb-modal-text-size, 16px) + 2px);\n}\n.rtb-help-columns {\n display: flex;\n align-items: flex-start;\n padding: 14px 20px 22px;\n}\n.rtb-help-col {\n flex: 1;\n min-width: 0;\n}\n.rtb-help-col:first-child {\n padding-right: 30px;\n border-right: 1px solid rgba(128,128,128,0.16);\n}\n.rtb-help-col:last-child {\n padding-left: 30px;\n}\n@media (max-width: 680px) {\n .rtb-help-dialog { width: min(95vw, 360px); }\n .rtb-help-columns { flex-direction: column; align-items: stretch; padding: 10px 16px 18px; }\n .rtb-help-col:first-child { padding-right: 0; border-right: none; }\n .rtb-help-col:last-child { padding-left: 0; margin-top: 18px; }\n .rtb-help-col { width: 100%; }\n}\n.rtb-help-table {\n width: 100%;\n border-collapse: collapse;\n border: none;\n font-size: 0.84rem;\n}\n.rtb-help-table td {\n padding: 4px 8px;\n border: none;\n border-bottom: 1px solid rgba(128,128,128,0.07);\n vertical-align: middle;\n}\n.rtb-help-table td:first-child { padding-left: 2px; }\n.rtb-help-table td:last-child { padding-right: 2px; white-space: nowrap; text-align: right; }\n.rtb-help-table tr:not(.rtb-help-section):hover > td {\n background: rgba(128,128,128,0.06);\n}\n.rtb-help-section > td {\n text-align: left !important;\n font-weight: 700;\n font-size: 0.68rem;\n letter-spacing: 0.09em;\n text-transform: uppercase;\n opacity: 0.55;\n padding: 16px 2px 5px;\n border-top: none;\n border-bottom: 1px solid rgba(128,128,128,0.22);\n}\n.rtb-help-table > tbody > tr.rtb-help-section:first-child > td { padding-top: 4px; }\n.rtb-help-table kbd {\n font-family: "Consolas", "SF Mono", "Menlo", monospace;\n font-size: 0.74rem;\n background: rgba(128,128,128,0.11);\n border: 1px solid rgba(128,128,128,0.28);\n border-bottom-width: 2px;\n border-radius: 4px;\n padding: 1px 6px;\n white-space: nowrap;\n display: inline-block;\n line-height: 1.5;\n}\n.rich-text-box-form-element {\n width: 100%;\n padding: 10px;\n font-size: var(--rtb-modal-text-size, 16px);\n font-family: var(--rtb-modal-text-font, Arial, sans-serif);\n letter-spacing: 0.03em;\n background-color: var(--rtb-modal-input-bg, #fff);\n color: var(--rtb-modal-input-text, #000);\n border-width: 1px;\n border-style: solid;\n border-color: var(--rtb-modal-input-border, #CCC);\n outline: 0;\n border-radius: 0px;\n box-sizing: border-box;\n margin-top: 0px;\n margin-bottom: 16px;\n resize: vertical;\n}\n.rich-text-box-form-element:disabled {\n color: #999;\n border-color: #DDD;\n cursor: default;\n}\n:host(.dark) .rich-text-box-form-element,\n:host(.fluent-dark) .rich-text-box-form-element {\n color-scheme: dark;\n}\n.rich-text-box-form-checkbox {\n outline: none;\n width: 20px;\n height: 20px;\n margin-right: 8px;\n accent-color: var(--rtb-modal-checkbox, #007bff);\n}\n.rich-text-box-form-checkbox:focus {\n border-style: solid;\n border-color: var(--rtb-modal-input-border, #CCC);\n border-width: 1px;\n box-shadow: 0 0 5px 2px rgba(169, 169, 169, 0.8);\n}\n.rich-text-box-upload-btn {\n padding: 10px 20px !important;\n font-size: var(--rtb-modal-text-size, 16px);\n font-family: var(--rtb-modal-text-font, Arial, sans-serif);\n letter-spacing: 0.05em;\n transition: 0.3s;\n background-color: var(--rtb-btn-bg, inherit);\n border: 1px solid var(--rtb-btn-border-color, #AAA);\n border-radius: var(--rtb-btn-border-radius, 5px);\n color: var(--rtb-btn-text, #000);\n outline: none;\n cursor: pointer;\n min-width: 100% !important;\n min-height: calc(var(--rtb-btn-size, 16px) + 14px);\n font-family: var(--rtb-btn-font, Arial, sans-serif);\n margin: 4px 1px;\n}\n.rich-text-box-upload-btn:hover {\n background-color: var(--rtb-btn-bg-hover, #e8e8e8);\n border-color: var(--rtb-btn-border-hover, inherit);\n}\n.rich-text-box-form-button {\n padding: 10px 20px !important;\n font-size: var(--rtb-modal-text-size, 16px);\n font-family: var(--rtb-modal-text-font, Arial, sans-serif);\n letter-spacing: 0.05em;\n transition: 0.3s;\n}\n.rich-text-box-form-button:focus {\n background-color: var(--rtb-btn-bg-hover, #e8e8e8);\n border-color: var(--rtb-btn-border-hover, inherit);\n}\n.blazing-rich-text-color-picker-container { position: relative; }\n.blazing-rich-text-color-picker-button { min-height: calc(var(--rtb-btn-size, 16px) + 14px); }\n.blazing-rich-text-color-picker-dropdown { width: 80px; padding: 10px 10px 6px 10px; }\n.blazing-rich-text-color-option {\n width: 15px; height: 15px; margin: 2px; cursor: pointer;\n display: inline-block; border: 1px solid #999;\n}\n.blazing-rich-text-color-option:hover { border-color: #000; }\n.blazing-rich-text-color-selection {\n width: 100%; border-style: solid; border-width: 1px; border-color: #999;\n height: 40px; cursor: pointer; display: inline-block;\n}\n.rich-text-box-quote { font-family: var(--rtb-modal-text-font, Arial, sans-serif); }\n.rich-text-box-code { overflow: auto !important; white-space: pre; }\n.rich-text-box-message-bar {\n font-size: var(--rtb-content-size, 16px);\n background-color: rgba(0, 0, 0, 0.6);\n color: white;\n display: flex;\n justify-content: space-between;\n align-items: center;\n padding: 5px 10px;\n opacity: 1;\n transform: translateY(0);\n transition: opacity 0.2s ease-in-out, transform 0.2s ease-in-out;\n pointer-events: auto;\n}\n.rich-text-box-message-bar.rich-text-box-message-hidden {\n opacity: 0; height: 0; padding: 0; color: transparent; pointer-events: none;\n}\n.rich-text-box-message {}\n.rich-text-box-message-close-button {\n background: none; border: none; color: white; font-size: 18px; cursor: pointer;\n}\n.rich-text-box-color-picker { width: 100%; }\n.rich-text-box-color-display { width: 100%; height: 50px; border: 1px solid #ccc; margin: 20px 0; }\n.rich-text-box-slider-container { display: flex; align-items: center; margin-bottom: 10px; }\n.rich-text-box-slider-container label {\n width: 20px; margin-right: 10px;\n color: var(--rtb-modal-text, #000);\n}\n.rich-text-box-range { width: 100%; -webkit-appearance: none; cursor: pointer; }\n.rich-text-box-range:focus { outline: none; }\n.rich-text-box-range::-webkit-slider-runnable-track {\n background: var(--rtb-modal-text, #000); height: 5px;\n}\n.rich-text-box-red-slider::-webkit-slider-runnable-track {\n background: linear-gradient(to right, rgb(0,0,0) 0%, rgb(255,0,0) 100%) !important;\n}\n.rich-text-box-green-slider::-webkit-slider-runnable-track {\n background: linear-gradient(to right, rgb(0,0,0) 0%, rgb(0,255,0) 100%) !important;\n}\n.rich-text-box-blue-slider::-webkit-slider-runnable-track {\n background: linear-gradient(to right, rgb(0,0,0) 0%, rgb(0,0,255) 100%) !important;\n}\n.rich-text-box-range::-moz-range-track {\n background: var(--rtb-modal-text, #000); height: 5px;\n}\n.rich-text-box-range::-webkit-slider-thumb {\n -webkit-appearance: none; height: 15px; width: 15px;\n background: var(--rtb-modal-bg, #fefefe);\n margin-top: -5px; border-style: solid; border-width: 3px;\n border-color: var(--rtb-modal-text, #000); border-radius: 50%;\n}\n.rich-text-box-range::-moz-range-thumb {\n -webkit-appearance: none; height: 15px; width: 15px;\n background: var(--rtb-modal-bg, #fefefe);\n margin-top: -5px; border-style: solid; border-width: 3px;\n border-color: var(--rtb-modal-text, #000); border-radius: 50%;\n}\n.rich-text-box-number {\n width: 100px; margin-left: 10px; padding: 5px; font-size: 14px;\n background-color: var(--rtb-modal-input-bg, #fff);\n color: var(--rtb-modal-input-text, #000);\n border-width: 1px; border-style: solid;\n border-color: var(--rtb-modal-input-border, #CCC);\n outline: 0; border-radius: 0px; box-sizing: border-box;\n}\n.rich-text-box-hex-container { display: flex; align-items: center; margin-top: 20px; }\n.rich-text-box-hex-input { width: 100px !important; margin-left: 10px; }\nblockquote {\n background: var(--rtb-quote-bg, #f9f9f9);\n border-left: var(--rtb-quote-border-width, 5px) solid var(--rtb-quote-border-color, #ccc);\n color: var(--rtb-quote-text, var(--rtb-content-text, #242424));\n margin: var(--rtb-quote-margin, 1.5em 10px);\n padding: var(--rtb-quote-padding, 0.5em 10px);\n}\npre {\n background: var(--rtb-code-bg, #f9f9f9);\n border-radius: var(--rtb-code-border-radius, 10px);\n overflow-x: auto; white-space: pre-wrap; margin: 1.5em 10px; padding: 0.5em 10px;\n}\ntable { border-collapse: collapse; }\ntd, th { border: 1px solid #ccc; padding: 4px 6px; height: 25px; min-width: 100px; }\n',{invokeMethodAsync:(t,e)=>onValueChange(e)}),RTNative_Instances[this._uid]._rtbHostElement=this;const o=this.getAttribute("aria-label")||this.getAttribute("label");o&&RTNative_Instances[this._uid].content.setAttribute("aria-label",o);const i=this.getAttribute("placeholder");i&&RTNative_Instances[this._uid].content.setAttribute("data-placeholder",i),this.hasAttribute("readonly")&&RTNative_Instances[this._uid].setReadOnly(!0),RTNative_Instances[this._uid]._syncWordCountVisibility(),RTNative_Instances[this._uid].loadHtml(n),this._initialized=!0,this._syncToInstance(),this._applyContentStyles(),this._attachCustomButtonHandlers()}_reinitialize(){const t=this.getValue();delete RTNative_Instances[this._uid],this._initialized=!1,this._uid="rtb-"+Math.random().toString(36).substring(2,11),this._render(),requestAnimationFrame(()=>{this._initialize(),t&&this.setValue(t)})}_refreshToolbar(){this._initialized?this._reinitialize():this.isConnected&&this._render()}_svg(t){return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 -960 960 960"><path d="${p[t]}"/></svg>`}_btn(t,e,n,o,i){return`<button id="${t}" title="${n}" aria-label="${n}" aria-pressed="false" class="rich-text-box-menu-item" onclick="${void 0!==i?`RTNative_Method('${o}','${this._uid}','${i}')`:`RTNative_Method('${o}','${this._uid}')`}">${this._svg(e)}</button>`}_specialBtn(t,e,n,o){return`<button id="${t}" title="${n}" aria-label="${n}" aria-pressed="false" class="rich-text-box-menu-item-special" onclick="RTNative_Method('${o}','${this._uid}')">${this._svg(e)}</button>`}_divider(){return'<button class="rich-text-box-divider-btn" disabled><div class="rich-text-box-divider"></div></button>'}_escapeAttr(t){return String(t??"").replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}_customButton(t){const e=this._escapeAttr(t.id),n=this._escapeAttr(t.title||t.label||t.id),o=t.svg||"";return`<button id="${e}" title="${n}" aria-label="${n}" aria-pressed="false" class="rich-text-box-menu-item rich-text-box-custom-button" data-rtb-custom-button="${e}"${t.disabled?" disabled":""}>${o}</button>`}_customButtonsHTML(){return this._customButtons.length?this._customButtons.map(t=>this._customButton(t)).join("\n"):""}_resolveCustomButtonHandler(t){return"function"==typeof t?t:"string"==typeof t&&t.trim()?t.split(".").reduce((t,e)=>t?.[e],window):null}_attachCustomButtonHandlers(){const t=RTNative_Instances[this._uid];t?.shadowRoot&&this._customButtons.forEach(e=>{const n=t.shadowRoot.querySelector(`[data-rtb-custom-button="${CSS.escape(e.id)}"]`);n&&n.addEventListener("click",n=>{if(e.disabled)return;const o=this._resolveCustomButtonHandler(e.onClick||e.method);"function"==typeof o&&o.call(this,n,this,t),this.dispatchEvent(new CustomEvent("custom-button-click",{detail:{id:e.id,button:e,editor:this},bubbles:!0,composed:!0}))})})}_fontDropdown(){const t=this._uid,e=["None","Arial","Arial Narrow","Baskerville","Brush Script","Calibri","Cambria","Candara","Century Gothic","Claude Garamond","Comic Sans MS","Copperplate","Courier","Didot","Georgia","Gill Sans","Helvetica","Impact","Lucida Bright","Monospace","Optima","Palatino","Segoe UI","Tahoma","Times New Roman","Trebuchet MS","Verdana"].map(e=>`<a class="rich-text-box-menu-item" style="font-family:${e};cursor:pointer" onclick="RTNative_Method('font','${t}','${e}')">${e}</a>`).join("");return`\n<div class="rich-text-box-dropdown">\n <button id="blazing-rich-text-font-button" title="Font (Alt+F)" class="rich-text-box-font-button rich-text-box-dropdown-btn"\n onclick="RTNative_Method('dropdown','${t}','blazing-rich-text-font-button-dropdown')">Font</button>\n <div id="blazing-rich-text-font-button-dropdown" class="rich-text-box-dropdown-content rich-text-box-font-content rich-text-box-scroll">\n ${e}\n </div>\n</div>`}_sizeDropdown(){const t=this._uid,e=["None","8","9","10","11","12","14","16","18","20","22","24","26","28","36","48","64"].map(e=>`<a class="rich-text-box-menu-item" style="${"None"===e?"":`font-size:${e}px !important;`}cursor:pointer" onclick="RTNative_Method('size','${t}','${"None"===e?"None":`${e}px`}')">${"None"===e?"None":e}</a>`).join("");return`\n<div class="rich-text-box-dropdown">\n <button id="blazing-rich-text-size-button" title="Size (Alt+S)" class="rich-text-box-size-button rich-text-box-dropdown-btn"\n onclick="RTNative_Method('dropdown','${t}','blazing-rich-text-size-button-dropdown')">Size</button>\n <div id="blazing-rich-text-size-button-dropdown" class="rich-text-box-dropdown-content rich-text-box-size-content rich-text-box-scroll">\n ${e}\n </div>\n</div>`}_formatDropdown(){const t=this._uid;return`\n<div class="rich-text-box-dropdown">\n <button id="blazing-rich-text-format-button" title="Format (Alt+T)" class="rich-text-box-format-button rich-text-box-dropdown-btn"\n onclick="RTNative_Method('dropdown','${t}','blazing-rich-text-format-button-dropdown')">Format</button>\n <div id="blazing-rich-text-format-button-dropdown" class="rich-text-box-dropdown-content rich-text-box-format-content rich-text-box-scroll">\n <a class="rich-text-box-menu-item" style="cursor:pointer" onclick="RTNative_Method('format','${t}','none')">None</a>\n <a class="rich-text-box-menu-item" style="cursor:pointer" onclick="RTNative_Method('format','${t}','p')">Paragraph</a>\n <a class="rich-text-box-menu-item" style="font-size:34px;cursor:pointer" onclick="RTNative_Method('format','${t}','h1')">Header 1</a>\n <a class="rich-text-box-menu-item" style="font-size:30px;cursor:pointer" onclick="RTNative_Method('format','${t}','h2')">Header 2</a>\n <a class="rich-text-box-menu-item" style="font-size:24px;cursor:pointer" onclick="RTNative_Method('format','${t}','h3')">Header 3</a>\n <a class="rich-text-box-menu-item" style="font-size:20px;cursor:pointer" onclick="RTNative_Method('format','${t}','h4')">Header 4</a>\n <a class="rich-text-box-menu-item" style="font-size:18px;cursor:pointer" onclick="RTNative_Method('format','${t}','h5')">Header 5</a>\n <a class="rich-text-box-menu-item" style="font-size:16px;cursor:pointer" onclick="RTNative_Method('format','${t}','h6')">Header 6</a>\n </div>\n</div>`}_fileDropdown(){const t=this._uid,e=this._visibility;return`\n<div class="rich-text-box-dropdown">\n <button id="blazing-rich-text-file-button" title="File (Alt+L)" class="rich-text-box-file-button rich-text-box-dropdown-btn"\n onclick="RTNative_Method('dropdown','${t}','blazing-rich-text-file-button-dropdown')">File</button>\n <div id="blazing-rich-text-file-button-dropdown" class="rich-text-box-dropdown-content rich-text-box-file-content rich-text-box-scroll">\n ${e.search?`<a class="rich-text-box-menu-item" style="cursor:pointer" onclick="RTNative_Method('fileMenuAction','${t}','find')">Find<span class="rich-text-box-menu-shortcut">Ctrl+F</span></a>`:""}${e.saveHtml?`<a class="rich-text-box-menu-item" style="cursor:pointer" onclick="RTNative_Method('fileMenuAction','${t}','save')">Download<span class="rich-text-box-menu-shortcut">Ctrl+Shift+S</span></a>`:""}${(e.search||e.saveHtml)&&e.statusBarToggle?'<hr class="rich-text-box-dropdown-divider">':""}${e.statusBarToggle?`<a class="rich-text-box-menu-item" style="cursor:pointer" onclick="RTNative_Method('fileMenuAction','${t}','toggleStatusBar')"><span id="blazing-rich-text-file-statusbar-label">Show Status Bar</span><span class="rich-text-box-menu-shortcut">Ctrl+\\</span></a>`:""}${(e.search||e.saveHtml||e.statusBarToggle)&&e.help?'<hr class="rich-text-box-dropdown-divider">':""}${e.help?`<a class="rich-text-box-menu-item" style="cursor:pointer" onclick="RTNative_Method('fileMenuAction','${t}','shortcuts')">Keyboard Shortcuts<span class="rich-text-box-menu-shortcut">Ctrl+/</span></a>`:""}\n </div>\n</div>`}_colorSwatches(t){return["#FFFFFF","#DCDCDC","#A9A9A9","#696969","#303030","#000000","#FFCCCC","#FF6666","#FF3333","#FF0000","#CC0000","#990000","#800000","#CCFFCC","#99FF99","#66FF66","#33CC33","#009900","#CCCCFF","#9999FF","#6666FF","#3333CC","#000099","#002060","#FFFFCC","#FFFF99","#FFFF66","#CCCC33","#999900","#CCFFFF","#99FFFF","#66FFFF","#33CCCC","#009999","#FFCCFF","#FF99FF","#FF66FF","#CC33CC","#990099","#FFDDCC","#FFBB99","#FF9966","#FF7733","#CC4400","#E0CCFF","#C199FF","#A366FF","#8533FF","#6600CC"].map(e=>`<div class="blazing-rich-text-color-option" onclick="RTNative_Method('${t}','${this._uid}','${e}')" style="background-color:${e};"></div>`).join("")}_colorDialog(t,e,n,o){const i=this._uid;return`\n<dialog id="${t}" class="rich-text-box-modal rich-text-box-scroll" aria-modal="true" aria-labelledby="${t}-title">\n <div class="rtb-modal-header">\n <div id="${t}-title" class="rich-text-box-modal-title">${e}</div>\n <button class="rich-text-box-modal-close" aria-label="Close dialog" onclick="RTNative_Method('closeDialog','${i}','${t}')"><svg viewBox="0 0 12 12" aria-hidden="true" focusable="false" width="8" height="8" style="display:block"><path d="M2 2L10 10M10 2L2 10" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" fill="none"/></svg></button>\n </div>\n <div class="rich-text-box-color-picker">\n <div class="clearfix">\n <div class="rich-text-box-form-left">\n ${this._colorSwatches(n)}\n <div class="rich-text-box-color-display"></div>\n </div>\n <div class="rich-text-box-form-right">\n <div class="rich-text-box-slider-container">\n <label>R</label>\n <input type="range" class="rich-text-box-range rich-text-box-red-slider" min="0" max="255" value="0">\n <input type="number" class="rich-text-box-number rich-text-box-form-element rich-text-box-red-value" min="0" max="255" value="0">\n </div>\n <div class="rich-text-box-slider-container">\n <label>G</label>\n <input type="range" class="rich-text-box-range rich-text-box-green-slider" min="0" max="255" value="0">\n <input type="number" class="rich-text-box-number rich-text-box-form-element rich-text-box-green-value" min="0" max="255" value="0">\n </div>\n <div class="rich-text-box-slider-container">\n <label>B</label>\n <input type="range" class="rich-text-box-range rich-text-box-blue-slider" min="0" max="255" value="0">\n <input type="number" class="rich-text-box-number rich-text-box-form-element rich-text-box-blue-value" min="0" max="255" value="0">\n </div>\n <div class="rich-text-box-hex-container">\n <label>Hex:</label>\n <input type="text" class="rich-text-box-form-element rich-text-box-hex-input" value="#000000" autocomplete="off">\n </div>\n </div>\n </div>\n <div style="text-align:right;">\n <button class="rich-text-box-form-button" onclick="RTNative_Method('closeDialog','${i}','${t}')">Close</button>\n <button id="rich-text-box-ok-button" class="rich-text-box-form-button" onclick="RTNative_Method('${o}','${i}')">OK</button>\n </div>\n </div>\n</dialog>`}_genericDialog(t,e,n,o){const i=this._uid;return`\n<dialog id="${t}" class="rich-text-box-modal rich-text-box-scroll" aria-modal="true" aria-labelledby="${t}-title">\n <div class="rtb-modal-header">\n <div id="${t}-title" class="rich-text-box-modal-title">${e}</div>\n <button class="rich-text-box-modal-close" aria-label="Close dialog" onclick="RTNative_Method('closeDialog','${i}','${t}')"><svg viewBox="0 0 12 12" aria-hidden="true" focusable="false" width="8" height="8" style="display:block"><path d="M2 2L10 10M10 2L2 10" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" fill="none"/></svg></button>\n </div>\n <div>\n ${o}\n <div style="margin-top:5px;text-align:right;">\n <button class="rich-text-box-form-button" onclick="RTNative_Method('closeDialog','${i}','${t}')">Close</button>\n <button id="rich-text-box-ok-button" class="rich-text-box-form-button" onclick="RTNative_Method('${n}','${i}')">OK</button>\n </div>\n </div>\n</dialog>`}_buildToolbarHTML(){const t=this._uid,e=this._visibility,n=(e.font||e.size||e.format)&&e.textStylesDivider,o=(e.bold||e.italic||e.underline||e.strikethrough||e.subscript||e.superscript||e.inlineCode)&&e.formatDivider,i=e.textColor&&e.textColorDivider,r=(e.alignLeft||e.alignCenter||e.alignRight||e.alignJustify)&&e.alignDivider,l=(e.copy||e.cut||e.paste||e.delete||e.selectAll)&&e.actionDivider,s=(e.orderedList||e.unorderedList||e.indent)&&e.listDivider,a=(e.link||e.image||e.imageUpload||e.quote||e.codeBlock||e.embedMedia||e.video||e.table||e.horizontalRule)&&e.mediaDivider,d=(e.undo||e.redo)&&e.historyDivider,c=this._customButtons.length>0;return`\n<div id="${t}_Toolbar" class="rich-text-box-tool-bar" role="toolbar" aria-label="Formatting toolbar">\n\n ${e.fileMenu?this._fileDropdown():""}\n ${e.font?this._fontDropdown():""}\n ${e.size?this._sizeDropdown():""}\n ${e.format?this._formatDropdown():""}\n ${n?this._divider():""}\n\n ${e.bold?this._btn("blazing-rich-text-bold-button","Bold","Bold (Ctrl+B)","bold"):""}\n ${e.italic?this._btn("blazing-rich-text-italic-button","Italic","Italic (Ctrl+I)","italic"):""}\n ${e.underline?this._btn("blazing-rich-text-underline-button","Underline","Underline (Ctrl+U)","underline"):""}\n ${e.strikethrough?this._btn("blazing-rich-text-strike-button","Strikethrough","Strikethrough (Ctrl+D)","strikethrough"):""}\n ${e.subscript?this._btn("blazing-rich-text-sub-button","Subscript","Subscript (Ctrl+=)","subscript"):""}\n ${e.superscript?this._btn("blazing-rich-text-super-button","Superscript","Superscript (Ctrl+Shift++)","superscript"):""}\n ${e.inlineCode?this._btn("blazing-rich-text-inline-code-button","InlineCode","Inline Code (Ctrl+Shift+E)","inlinecode"):""}\n ${o?this._divider():""}\n\n ${e.textColor?this._btn("blazing-rich-text-textcolor-button","TextColor","Text Color (Ctrl+Shift+C)","openTextColorDialog"):""}\n ${e.textColor?this._btn("blazing-rich-text-text-bg-color-button","TextBackgroundColor","Text Background Color (Ctrl+Shift+B)","openTextBackgroundColorDialog"):""}\n ${e.textColor?this._btn("blazing-rich-text-textcolor-remove-button","RemoveTextFormat","Remove Color","removeTextColor"):""}\n ${i?this._divider():""}\n\n ${e.alignLeft?this._btn("blazing-rich-text-alignleft-button","Alignleft","Align Left (Ctrl+L)","alignleft"):""}\n ${e.alignCenter?this._btn("blazing-rich-text-aligncenter-button","Aligncenter","Align Center (Ctrl+E)","aligncenter"):""}\n ${e.alignRight?this._btn("blazing-rich-text-alignright-button","Alignright","Align Right (Ctrl+R)","alignright"):""}\n ${e.alignJustify?this._btn("blazing-rich-text-alignjustify-button","Alignjustify","Align Justify (Ctrl+J)","alignjustify"):""}\n ${r?this._divider():""}\n\n ${e.cut?this._btn("blazing-rich-text-cut-button","Cut","Cut (Ctrl+X)","cut"):""}\n ${e.copy?this._btn("blazing-rich-text-copy-button","Copy","Copy (Ctrl+C)","copy"):""}\n ${e.paste?this._btn("blazing-rich-text-paste-button","Paste","Paste (Ctrl+V)","paste"):""}\n ${e.delete?this._btn("blazing-rich-text-delete-button","Delete","Delete","delete"):""}\n ${e.selectAll?this._btn("blazing-rich-text-selectall-button","Selectall","Select All (Ctrl+A)","selectall"):""}\n ${l?this._divider():""}\n\n ${e.orderedList?this._btn("blazing-rich-text-orderedlist-button","OrderedList","Ordered List (Ctrl+Shift+O)","orderedlist"):""}\n ${e.unorderedList?this._btn("blazing-rich-text-unorderedlist-button","UnorderedList","Unordered List (Ctrl+Shift+U)","unorderedlist"):""}\n ${e.indent?this._btn("blazing-rich-text-increase-indent-button","IncreaseIndent","Increase Indent (Tab)","increaseIndent"):""}\n ${e.indent?this._btn("blazing-rich-text-decrease-indent-button","DecreaseIndent","Decrease Indent (Shift+Tab)","decreaseIndent"):""}\n ${s?this._divider():""}\n\n ${e.link?this._btn("blazing-rich-text-link-button","CreateLink","Insert Link (Ctrl+Shift+K)","openLinkDialog"):""}\n ${e.link?this._btn("blazing-rich-text-remove-link-button","RemoveLink","Remove Link","removeLink"):""}\n ${e.image?this._btn("blazing-rich-text-image-button","Image","Insert Image (Ctrl+Shift+I)","openImageDialog"):""}\n ${e.imageUpload?this._btn("blazing-rich-text-image-upload-button","UploadImage","Upload Image (Ctrl+Shift+&)","uploadImageDialog"):""}\n ${e.quote?this._btn("blazing-rich-text-quote-button","Quote","Block Quote (Ctrl+Shift+Q)","openBlockQuoteDialog"):""}\n ${e.embedMedia?this._btn("blazing-rich-text-embed-button","PermMedia","Insert Media (Ctrl+Shift+M)","openMediaDialog"):""}\n ${e.video?this._btn("blazing-rich-text-video-button","VideoFile","Insert Video (Ctrl+Shift+V)","openVideoDialog"):""}\n ${e.table?this._btn("blazing-rich-text-table-button","Table","Table (Ctrl+Shift+L)","openTableDialog"):""}\n ${e.codeBlock?this._btn("blazing-rich-text-code-block-button","CodeBlocks","Code Block (Ctrl+Shift+*)","openCodeBlockDialog"):""}\n ${e.horizontalRule?this._btn("blazing-rich-text-hr-button","HorizontalRule","Horizontal Rule (Ctrl+Shift+H)","insertHorizontalRule"):""}\n ${a?this._divider():""}\n\n ${e.undo?this._btn("blazing-rich-text-undo-button","Undo","Undo (Ctrl+Z)","goBack"):""}\n ${e.redo?this._btn("blazing-rich-text-redo-button","Redo","Redo (Ctrl+Y)","goForward"):""}\n ${d?this._divider():""}\n\n ${e.htmlView?this._specialBtn("blazing-rich-text-source","Code","HTML Source (Ctrl+Shift+A)","toggleView"):""}\n ${e.preview?this._specialBtn("blazing-rich-text-preview-button","Preview","Preview (Ctrl+Shift+P)","openPreview"):""}\n ${c?this._divider():""}\n ${this._customButtonsHTML()}\n\n ${this._colorDialog("rich-text-box-text-color-modal","Text Color","selectTextColor","insertTextColor")}\n ${this._colorDialog("rich-text-box-text-bg-color-modal","Text Background Color","selectTextBackgroundColor","insertTextBackgroundColor")}\n\n ${this._genericDialog("rich-text-box-table-modal","Table","insertTable",'\n <div class="clearfix">\n <div class="rich-text-box-form-left">\n <label>Columns</label>\n <input type="number" id="rich-text-box-table-columns" class="rich-text-box-form-element" min="0" max="10000" value="0" autocomplete="off">\n </div>\n <div class="rich-text-box-form-right">\n <label>Rows</label>\n <input type="number" id="rich-text-box-table-rows" class="rich-text-box-form-element" min="0" max="10000" value="0" autocomplete="off">\n <label>Width</label>\n <input type="text" id="rich-text-box-table-width" class="rich-text-box-form-element" placeholder="500px">\n </div>\n <div class="rich-text-box-form-left">\n <label>CSS Classes</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-table-classes" placeholder="class1 class2 class3">\n </div>\n </div>\n ')}\n\n ${this._genericDialog("rich-text-box-embed-modal","Media","insertMedia",'\n <div class="clearfix">\n <div class="rich-text-box-form-left">\n <label>Source</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-embed-source" placeholder="e.g., /documents/file.pdf" autocomplete="off">\n <label>Type</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-embed-type" placeholder="e.g., audio/mp3, application/pdf" autocomplete="off">\n </div>\n <div class="rich-text-box-form-right">\n <label>Width</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-embed-width" placeholder="450" autocomplete="off">\n <label>Height</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-embed-height" placeholder="250" autocomplete="off">\n </div>\n <div class="rich-text-box-form-left">\n <label>CSS Classes</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-embed-css-classes" placeholder="class1 class2 class3">\n </div>\n </div>\n ')}\n\n ${this._genericDialog("rich-text-box-video-modal","Video","insertVideo",'\n <div class="clearfix">\n <div class="rich-text-box-form-left">\n <label>Source</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-video-source" placeholder="e.g., /videos/movie.mp4" autocomplete="off">\n <label>Source Type</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-video-source-type" placeholder="e.g., video/mp4" autocomplete="off">\n <label>Poster Image URL</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-video-poster" placeholder="e.g., /images/poster.jpg" autocomplete="off">\n </div>\n <div class="rich-text-box-form-right">\n <label>Width</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-video-width" placeholder="640" autocomplete="off">\n <label>Height</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-video-height" placeholder="360" autocomplete="off">\n <label>CSS Classes</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-video-css-classes" placeholder="class1 class2 class3">\n </div>\n <div style="clear:both;display:grid;grid-template-columns:1fr 1fr;gap:2px 20px;margin-top:10px;">\n <label style="display:flex;align-items:center;gap:6px;margin-bottom:6px;">\n <input class="rich-text-box-form-checkbox" type="checkbox" id="rich-text-box-video-controls">\n Controls\n </label>\n <label style="display:flex;align-items:center;gap:6px;margin-bottom:6px;">\n <input class="rich-text-box-form-checkbox" type="checkbox" id="rich-text-box-video-autoplay">\n Autoplay\n </label>\n <label style="display:flex;align-items:center;gap:6px;margin-bottom:6px;">\n <input class="rich-text-box-form-checkbox" type="checkbox" id="rich-text-box-video-loop">\n Loop\n </label>\n <label style="display:flex;align-items:center;gap:6px;margin-bottom:6px;">\n <input class="rich-text-box-form-checkbox" type="checkbox" id="rich-text-box-video-muted">\n Muted\n </label>\n </div>\n </div>\n ')}\n\n ${this._genericDialog("rich-text-box-code-block-modal","Code Block","insertCodeBlock",'\n <div class="clearfix">\n <label>Code Block</label>\n <textarea rows="6" cols="50" class="rich-text-box-form-element rich-text-box-code rich-text-box-scroll" id="rich-text-box-code" spellcheck="false"></textarea>\n <div class="rich-text-box-form-left">\n <label>CSS Classes</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-code-css-classes" placeholder="class1 class2 class3">\n </div>\n </div>\n ')}\n\n ${this._genericDialog("rich-text-box-block-quote-modal","Block Quote","insertBlockQuote",'\n <div class="clearfix">\n <div class="rich-text-box-form-left">\n <label>Quote</label>\n <textarea rows="6" cols="50" class="rich-text-box-form-element rich-text-box-quote rich-text-box-scroll" id="rich-text-box-quote"></textarea>\n </div>\n <div class="rich-text-box-form-right">\n <label>Cite</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-cite" placeholder="https://www..." autocomplete="off">\n <label>CSS Classes</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-quote-css-classes" placeholder="class1 class2 class3">\n </div>\n </div>\n ')}\n\n ${this._genericDialog("rich-text-box-image-modal","Image","insertImage",'\n <div class="clearfix">\n <div class="rich-text-box-form-left">\n <label>Web Address</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-image-webaddress" placeholder="https://www..." autocomplete="off">\n <label>Alternative Text</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-image-alt-text" autocomplete="off">\n </div>\n <div class="rich-text-box-form-right">\n <label>Width</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-image-width" placeholder="400" autocomplete="off">\n <label>Height</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-image-height" autocomplete="off">\n </div>\n <div class="rich-text-box-form-left">\n <label>CSS Classes</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-image-css-classes" placeholder="class1 class2 class3">\n </div>\n </div>\n ')}\n\n ${this._genericDialog("rich-text-box-upload-image-modal","Upload / Embed Image","uploadImage",'\n <div class="clearfix">\n <div class="rich-text-box-form-left">\n <div style="height:40px;padding:20px 0 10px 0;">\n <input type="file" id="rich-text-box-upload-image-file" hidden>\n <label for="rich-text-box-upload-image-file" class="rich-text-box-upload-btn">Choose File</label>\n <span id="rich-text-box-upload-image-file-chosen">No file chosen</span>\n </div>\n <label>Alternative Text</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-upload-image-alt-text" autocomplete="off">\n </div>\n <div class="rich-text-box-form-right">\n <label>Width</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-upload-image-width" placeholder="400" autocomplete="off">\n <label>Height</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-upload-image-height" autocomplete="off">\n </div>\n <div class="rich-text-box-form-left">\n <label>CSS Classes</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-upload-image-css-classes" placeholder="class1 class2 class3">\n </div>\n </div>\n ')}\n\n ${this._genericDialog("rich-text-box-link-modal","Link","insertLink",'\n <div class="clearfix">\n <div class="rich-text-box-form-left">\n <label>Web Address</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-link-webaddress" placeholder="https://www..." autocomplete="off">\n </div>\n <div class="rich-text-box-form-right">\n <label>Link Text</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-linktext" autocomplete="off">\n <label style="display:flex;align-items:center;margin-bottom:12px;">\n <input class="rich-text-box-form-checkbox" id="rich-text-box-link-modal-newtab" type="checkbox">\n Open in New Tab\n </label>\n </div>\n <div class="rich-text-box-form-left">\n <label>CSS Classes</label>\n <input class="rich-text-box-form-element" type="text" id="rich-text-box-link-css-classes" placeholder="class1 class2 class3">\n </div>\n </div>\n ')}\n\n\n ${this._buildPreviewDialogHTML()}\n ${this._buildHelpDialogHTML()}\n\n</div>`}_buildPreviewDialogHTML(){const t=this._uid;return`\n<dialog id="${t}_Preview" class="rich-text-box-modal rich-text-box-scroll rtb-preview-dialog" aria-modal="true" aria-labelledby="${t}_Preview-title">\n <div class="rtb-modal-header">\n <div id="${t}_Preview-title" class="rich-text-box-modal-title">Preview</div>\n <div style="display:flex;gap:2px;align-items:center;">\n <button id="${t}_PreviewMaxBtn" class="rich-text-box-modal-close" aria-label="Maximize preview" onclick="RTNative_Method('togglePreviewMaximize','${t}')"><svg viewBox="0 0 12 12" aria-hidden="true" focusable="false" width="11" height="11" style="display:block"><path d="M1.5 4.5V1.5H4.5M10.5 7.5V10.5H7.5M1.5 1.5L4.5 4.5M10.5 10.5L7.5 7.5" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" fill="none"/></svg></button>\n <button class="rich-text-box-modal-close" aria-label="Close preview" onclick="RTNative_Method('closePreview','${t}')"><svg viewBox="0 0 12 12" aria-hidden="true" focusable="false" width="8" height="8" style="display:block"><path d="M2 2L10 10M10 2L2 10" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" fill="none"/></svg></button>\n </div>\n </div>\n <div class="rtb-preview-dialog-body">\n <div id="rich-text-box-preview" class="rtb-preview-window"></div>\n <div style="text-align:right;flex-shrink:0;">\n <button class="rich-text-box-form-button" onclick="RTNative_Method('closePreview','${t}')">Close</button>\n </div>\n </div>\n</dialog>`}_buildHelpDialogHTML(){const k=(...t)=>t.map(t=>`<kbd>${t}</kbd>`).join("+");return`\n<dialog id="rich-text-box-help-modal" class="rich-text-box-modal rtb-help-dialog" aria-labelledby="rich-text-box-help-modal-title">\n <div class="rtb-help-sticky-header">\n <div id="rich-text-box-help-modal-title" class="rich-text-box-modal-title">Keyboard Shortcuts</div>\n <button class="rich-text-box-modal-close" aria-label="Close" onclick="RTNative_Method('closeHelpDialog','${this._uid}')"><svg viewBox="0 0 12 12" aria-hidden="true" focusable="false" width="8" height="8" style="display:block"><path d="M2 2L10 10M10 2L2 10" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" fill="none"/></svg></button>\n </div>\n <div class="rtb-help-columns">\n <div class="rtb-help-col">\n <table class="rtb-help-table">\n <tbody>\n <tr class="rtb-help-section"><td colspan="2">Text Formatting</td></tr>\n <tr><td>Bold</td><td>${k("Ctrl","B")}</td></tr>\n <tr><td>Italic</td><td>${k("Ctrl","I")}</td></tr>\n <tr><td>Underline</td><td>${k("Ctrl","U")}</td></tr>\n <tr><td>Strikethrough</td><td>${k("Ctrl","D")}</td></tr>\n <tr><td>Subscript</td><td>${k("Ctrl","=")}</td></tr>\n <tr><td>Superscript</td><td>${k("Ctrl","Shift","+")}</td></tr>\n <tr class="rtb-help-section"><td colspan="2">Dropdowns</td></tr>\n <tr><td>File</td><td>${k("Alt","L")}</td></tr>\n <tr><td>Font</td><td>${k("Alt","F")}</td></tr>\n <tr><td>Size</td><td>${k("Alt","S")}</td></tr>\n <tr><td>Format</td><td>${k("Alt","T")}</td></tr>\n <tr><td>Increase font size</td><td>${k("Ctrl","Shift",">")}</td></tr>\n <tr><td>Decrease font size</td><td>${k("Ctrl","Shift","<")}</td></tr>\n <tr class="rtb-help-section"><td colspan="2">Paragraph Format</td></tr>\n <tr><td>Clear format</td><td>${k("Ctrl","Shift","D")}</td></tr>\n <tr><td>Heading 1</td><td>${k("Ctrl","Shift","1")}</td></tr>\n <tr><td>Heading 2</td><td>${k("Ctrl","Shift","2")}</td></tr>\n <tr><td>Heading 3</td><td>${k("Ctrl","Shift","3")}</td></tr>\n <tr><td>Heading 4</td><td>${k("Ctrl","Shift","4")}</td></tr>\n <tr><td>Heading 5</td><td>${k("Ctrl","Shift","5")}</td></tr>\n <tr><td>Heading 6</td><td>${k("Ctrl","Shift","6")}</td></tr>\n <tr class="rtb-help-section"><td colspan="2">Edit</td></tr>\n <tr><td>Copy</td><td>${k("Ctrl","C")}</td></tr>\n <tr><td>Cut</td><td>${k("Ctrl","X")}</td></tr>\n <tr><td>Paste</td><td>${k("Ctrl","V")}</td></tr>\n <tr><td>Select all</td><td>${k("Ctrl","A")}</td></tr>\n <tr><td>Undo</td><td>${k("Ctrl","Z")}</td></tr>\n <tr><td>Redo</td><td>${k("Ctrl","Y")}</td></tr>\n </tbody>\n </table>\n </div>\n <div class="rtb-help-col">\n <table class="rtb-help-table">\n <tbody>\n <tr class="rtb-help-section"><td colspan="2">Alignment</td></tr>\n <tr><td>Align left</td><td>${k("Ctrl","L")}</td></tr>\n <tr><td>Align center</td><td>${k("Ctrl","E")}</td></tr>\n <tr><td>Align right</td><td>${k("Ctrl","R")}</td></tr>\n <tr><td>Justify</td><td>${k("Ctrl","J")}</td></tr>\n <tr class="rtb-help-section"><td colspan="2">Color</td></tr>\n <tr><td>Text color</td><td>${k("Ctrl","Shift","C")}</td></tr>\n <tr><td>Background color</td><td>${k("Ctrl","Shift","B")}</td></tr>\n <tr class="rtb-help-section"><td colspan="2">Lists</td></tr>\n <tr><td>Unordered list</td><td>${k("Ctrl","Shift","U")}</td></tr>\n <tr><td>Ordered list</td><td>${k("Ctrl","Shift","O")}</td></tr>\n <tr class="rtb-help-section"><td colspan="2">Insert</td></tr>\n <tr><td>Link</td><td>${k("Ctrl","Shift","K")}</td></tr>\n <tr><td>Image</td><td>${k("Ctrl","Shift","I")}</td></tr>\n <tr><td>Upload / embed image</td><td>${k("Ctrl","Shift","7")}</td></tr>\n <tr><td>Media</td><td>${k("Ctrl","Shift","M")}</td></tr>\n <tr><td>Video</td><td>${k("Ctrl","Shift","V")}</td></tr>\n <tr><td>Table</td><td>${k("Ctrl","Shift","L")}</td></tr>\n <tr><td>Code block</td><td>${k("Ctrl","Shift","8")}</td></tr>\n <tr><td>Block quote</td><td>${k("Ctrl","Shift","Q")}</td></tr>\n <tr><td>Horizontal rule</td><td>${k("Ctrl","Shift","H")}</td></tr>\n <tr class="rtb-help-section"><td colspan="2">View</td></tr>\n <tr><td>Toggle HTML source</td><td>${k("Ctrl","Shift","A")}</td></tr>\n <tr><td>Preview</td><td>${k("Ctrl","Shift","P")}</td></tr>\n <tr><td>Save HTML</td><td>${k("Ctrl","Shift","S")}</td></tr>\n <tr><td>Toggle status bar</td><td>${k("Ctrl","\\")}</td></tr>\n <tr><td>Find</td><td>${k("Ctrl","F")}</td></tr>\n <tr><td>Keyboard Shortcuts</td><td>${k("Ctrl","/")}</td></tr>\n </tbody>\n </table>\n </div>\n </div>\n</dialog>`}}customElements.define("rt-native",m);
|
|
2
2
|
//# sourceMappingURL=rt-native.js.map
|