@oix1987/yjd 1.0.3 → 2.1.0

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.
Files changed (73) hide show
  1. package/LICENSE +15 -0
  2. package/README.md +223 -142
  3. package/core.js +82 -0
  4. package/dist/core.esm.js +2 -0
  5. package/dist/core.esm.js.map +1 -0
  6. package/dist/rich-editor.esm.js +1 -1
  7. package/dist/rich-editor.esm.js.map +1 -1
  8. package/dist/rich-editor.min.js +1 -1
  9. package/dist/rich-editor.min.js.map +1 -1
  10. package/index.d.ts +230 -103
  11. package/index.js +297 -0
  12. package/lib/core/editor.js +1885 -0
  13. package/lib/core/format.js +540 -0
  14. package/lib/core/module.js +81 -0
  15. package/lib/core/registry.js +158 -0
  16. package/lib/formats/background.js +213 -0
  17. package/lib/formats/bold.js +49 -0
  18. package/lib/formats/capitalization.js +579 -0
  19. package/lib/formats/color.js +183 -0
  20. package/lib/formats/emoji.js +282 -0
  21. package/lib/formats/font-family.js +548 -0
  22. package/lib/formats/heading.js +502 -0
  23. package/lib/formats/image.js +341 -0
  24. package/lib/formats/import.js +385 -0
  25. package/lib/formats/indent.js +297 -0
  26. package/lib/formats/italic.js +27 -0
  27. package/lib/formats/line-height.js +562 -0
  28. package/lib/formats/link.js +251 -0
  29. package/lib/formats/list.js +635 -0
  30. package/lib/formats/strike.js +31 -0
  31. package/lib/formats/subscript.js +40 -0
  32. package/lib/formats/superscript.js +39 -0
  33. package/lib/formats/table.js +293 -0
  34. package/lib/formats/tag.js +304 -0
  35. package/lib/formats/text-align.js +422 -0
  36. package/lib/formats/text-size.js +498 -0
  37. package/lib/formats/underline.js +30 -0
  38. package/lib/formats/video.js +381 -0
  39. package/lib/modules/block-toolbar.js +639 -0
  40. package/lib/modules/code-view.js +447 -0
  41. package/lib/modules/find-replace.js +273 -0
  42. package/lib/modules/history.js +425 -0
  43. package/lib/modules/mention.js +200 -0
  44. package/lib/modules/resize-handles.js +701 -0
  45. package/lib/modules/slash-menu.js +183 -0
  46. package/lib/modules/table-toolbar.js +635 -0
  47. package/lib/modules/toolbar.js +607 -0
  48. package/lib/serialize.js +241 -0
  49. package/lib/static.js +28 -0
  50. package/lib/styles-loader.js +142 -0
  51. package/{dist → lib}/styles.css +1392 -35
  52. package/lib/styles.css.js +2 -0
  53. package/lib/styles.min.css +1 -0
  54. package/lib/ui/color-picker.js +296 -0
  55. package/lib/ui/customselect.js +351 -0
  56. package/lib/ui/emoji-picker.js +196 -0
  57. package/lib/ui/icons.js +145 -0
  58. package/lib/ui/image-popup.js +435 -0
  59. package/lib/ui/import-popup.js +288 -0
  60. package/lib/ui/link-popup.js +139 -0
  61. package/lib/ui/list-picker.js +307 -0
  62. package/lib/ui/select-button.js +68 -0
  63. package/lib/ui/table-popup.js +171 -0
  64. package/lib/ui/tag-popup.js +249 -0
  65. package/lib/ui/text-align-picker.js +278 -0
  66. package/lib/ui/video-popup.js +413 -0
  67. package/lib/utils/exec-command.js +72 -0
  68. package/lib/utils/history-helper.js +50 -0
  69. package/lib/utils/popup-helper.js +219 -0
  70. package/lib/utils/popup-positioning.js +234 -0
  71. package/lib/utils/sanitize.js +164 -0
  72. package/package.json +51 -32
  73. package/umd-entry.js +19 -0
@@ -1,2 +1,2 @@
1
- const t=new class{constructor(){this.modules=new Map,this.formats=new Map,this.themes=new Map,this.ui=new Map}register(t,e,n=!1){if("object"==typeof t)return void Object.entries(t).forEach(([t,e])=>{this.register(t,e,n)});const[i,s]=t.split("/");switch(!n&&this.get(t),i){case"modules":this.modules.set(s,e);break;case"formats":this.formats.set(s,e);break;case"themes":this.themes.set(s,e);break;case"ui":this.ui.set(s,e)}}get(t){const[e,n]=t.split("/");switch(e){case"modules":return this.modules.get(n);case"formats":return this.formats.get(n);case"themes":return this.themes.get(n);case"ui":return this.ui.get(n);default:return null}}has(t){return null!==this.get(t)&&void 0!==this.get(t)}getAll(t){switch(t){case"modules":return new Map(this.modules);case"formats":return new Map(this.formats);case"themes":return new Map(this.themes);case"ui":return new Map(this.ui);default:return new Map}}unregister(t){const[e,n]=t.split("/");switch(e){case"modules":this.modules.delete(n);break;case"formats":this.formats.delete(n);break;case"themes":this.themes.delete(n);break;case"ui":this.ui.delete(n)}}clear(){this.modules.clear(),this.formats.clear(),this.themes.clear(),this.ui.clear()}getAllItems(){const t={};return t.modules=Array.from(this.modules.keys()),t.formats=Array.from(this.formats.keys()),t.themes=Array.from(this.themes.keys()),t.ui=Array.from(this.ui.keys()),t}};class e{static DEFAULTS={};constructor(t,e={}){this.editor=t,this.options={...this.constructor.DEFAULTS,...e},this.events=new Map}on(t,e){this.events.has(t)||this.events.set(t,[]),this.events.get(t).push(e)}off(t,e){if(this.events.has(t)){const n=this.events.get(t),i=n.indexOf(e);i>-1&&n.splice(i,1)}}emit(t,e){this.events.has(t)&&this.events.get(t).forEach(t=>{try{t(e)}catch(t){}})}destroy(){this.events.clear()}onContentChange(){}onSelectionChange(t){}}class n{static DEFAULTS={placeholder:"Start typing...",theme:"light",height:400,width:800,maxWidth:1200,maxHeight:800,content:null,features:{emoji:!0,image:!0,table:!0,wordCount:!0,breadcrumb:!0}};static currentInstance=null;static instances=new Map;constructor(e,i={}){this.options={...n.DEFAULTS,...i},this.root="string"==typeof e?document.querySelector(e):e,this.modules=new Map,this.formats=new Map,this.registry=t,this.events=new Map,this.toolbarBtns={},this.statusbarEls={},this.dropdownMenus={},this.popupInstances=new Map,n.currentInstance=this;const s=this.generateInstanceId();this.instanceId=s,n.instances.set(s,this),this.init()}generateInstanceId(){return"editor_"+Date.now()+"_"+Math.random().toString(36).substr(2,9)}init(){this.createStructure(),this.loadModules(),this.loadFormats(),this.setupEventListeners(),this.updateStatusbar()}createStructure(){this.wrapper=document.createElement("div"),this.wrapper.className="yjd-rich-editor",this.wrapper.style.width=this.options.width+"px",this.wrapper.style.maxWidth=this.options.maxWidth+"px",this.wrapper.style.minHeight=this.options.height+"px",this.wrapper.style.maxHeight=this.options.maxHeight+"px",this.wrapper.style.position="relative",this.editor=document.createElement("div"),this.editor.className="rich-editor-area",this.editor.contentEditable=!0,this.editor.setAttribute("data-placeholder",this.options.placeholder);try{document.execCommand("defaultParagraphSeparator",!1,"p")}catch(t){}this.editor.innerHTML=this.getDefaultContent(),this.wrapper.appendChild(this.editor),this.popupContainer=document.createElement("div"),this.popupContainer.className="rich-editor-popup-container",this.popupContainer.style.position="absolute",this.popupContainer.style.top="0",this.popupContainer.style.left="0",this.popupContainer.style.width="100%",this.popupContainer.style.height="100%",this.popupContainer.style.pointerEvents="none",this.popupContainer.style.zIndex="1000",this.wrapper.appendChild(this.popupContainer),(this.options.features.wordCount||this.options.features.breadcrumb)&&this.createStatusbar(),this.root.appendChild(this.wrapper),this.updatePlaceholderVisibility()}isHtmlContent(t){if(!t||"string"!=typeof t)return!1;const e=t.trim();return[/<[^>]+>/,/&[a-zA-Z]+;/,/&#\d+;/].some(t=>t.test(e))}wrapTextInParagraph(t){if(!t||"string"!=typeof t)return"<p><br></p>";const e=t.trim();return this.isHtmlContent(e)?e:""===e?"<p><br></p>":`<p>${e}</p>`}getDefaultContent(){return this.options.content?this.wrapTextInParagraph(this.options.content):""}createStatusbar(){this.statusbar=document.createElement("div"),this.statusbar.className="rich-editor-statusbar",this.statusbarEls.breadcrumb=document.createElement("span"),this.statusbarEls.breadcrumb.className="rich-editor-breadcrumb",this.statusbarEls.wordcount=document.createElement("span"),this.statusbarEls.wordcount.className="wordcount",this.statusbar.appendChild(this.statusbarEls.breadcrumb),this.statusbar.appendChild(this.statusbarEls.wordcount),this.wrapper.appendChild(this.statusbar)}loadModules(){let t;t=this.options.toolbar||this.options.toolbar1||this.options.toolbar2?this.options.modules||["toolbar","history"]:this.options.modules||["toolbar","history","block-toolbar","table-toolbar","code-view","theme-switcher","resize-handles"],t.forEach(t=>{const e=this.registry.get(`modules/${t}`);if(e){const n=new e(this,"toolbar"===t?this.options:this.options[t]||this.options);if(this.modules.set(t,n),"toolbar"===t&&n.getContainer){const t=n.getContainer();this.wrapper.insertBefore(t,this.editor),n.on("toolbar-click",t=>{this.handleToolbarClick(t)})}}})}loadFormats(){let t;t=this.options.toolbar||this.options.toolbar1||this.options.toolbar2?this.options.formats||["bold","italic","underline","strike"]:this.options.formats||["bold","italic","underline","strike","subscript","superscript","color","background","text-align","text-size","link","code","h1","h2","h3","h4","h5","h6","paragraph","pre"],t.forEach(t=>{const e=this.registry.get(`formats/${t}`);e&&this.formats.set(t,e)})}setupEventListeners(){this.editor.addEventListener("input",()=>{this.ensureEditorHasContent(),this.updatePlaceholderVisibility(),this.updateStatusbar(),this.onContentChange()}),document.addEventListener("selectionchange",()=>{(document.activeElement===this.editor||this.editor.contains(document.activeElement))&&this.onSelectionChange()}),this.editor.addEventListener("mouseup",()=>{setTimeout(()=>{this.onSelectionChange()},10)}),this.editor.addEventListener("click",t=>{setTimeout(()=>{this.ensureEditorHasContent()},0)}),this.editor.addEventListener("contextmenu",t=>{}),this.editor.addEventListener("keydown",t=>{"Delete"!==t.key&&"Backspace"!==t.key||setTimeout(()=>{this.ensureEditorHasContent(),this.updatePlaceholderVisibility()},0)}),this.editor.addEventListener("paste",()=>{setTimeout(()=>{this.ensureEditorHasContent(),this.updatePlaceholderVisibility()},0)}),this.editor.addEventListener("drop",()=>{setTimeout(()=>{this.ensureEditorHasContent(),this.updatePlaceholderVisibility()},0)}),this.editor.addEventListener("cut",()=>{setTimeout(()=>{this.ensureEditorHasContent(),this.updatePlaceholderVisibility()},0)}),setTimeout(()=>{this.ensureEditorHasContent(),this.updatePlaceholderVisibility(),this.focus()},100),this.editor.addEventListener("focus",()=>{setTimeout(()=>{this.ensureEditorHasContent(),this.updatePlaceholderVisibility()},0)})}onContentChange(){this.ensureEditorHasContent(),this.modules.forEach(t=>{"function"==typeof t.onContentChange&&t.onContentChange()});const t=this.getContent();this.options.onChange&&"function"==typeof this.options.onChange&&this.options.onChange(t),this.emit("text-change",t)}ensureEditorHasContent(){if(this.isEditorEmpty()){const t=document.createElement("p");t.innerHTML="<br>",this.editor.innerHTML="",this.editor.appendChild(t),this.setCursorToElement(t),this.editor.focus()}}ensureParagraphForEditing(){const t=this.editor.children;if(0===t.length){const t=document.createElement("p");return t.innerHTML="<br>",this.editor.appendChild(t),void this.setCursorToElement(t)}const e=t[t.length-1];if(!["P","DIV","H1","H2","H3","H4","H5","H6","BLOCKQUOTE","PRE","ARTICLE","SECTION","MAIN","ASIDE"].includes(e.tagName)){const t=document.createElement("p");t.innerHTML="<br>",this.editor.appendChild(t)}}isEditorEmpty(){const t=this.editor.innerHTML.trim();if(""===t)return!0;if(["<br>","<div><br></div>","<p><br></p>","<p></p>","<div></div>","<p>&nbsp;</p>","<div>&nbsp;</div>"].includes(t))return!0;const e=this.editor.children;if(0===e.length)return!0;for(let t=0;t<e.length;t++){const n=e[t].innerHTML.trim();if(""!==n&&"<br>"!==n&&"&nbsp;"!==n&&"<br>&nbsp;"!==n&&"&nbsp;<br>"!==n)return!1}return!0}setCursorToElement(t){const e=document.createRange(),n=window.getSelection();t.firstChild&&t.firstChild.nodeType===Node.TEXT_NODE?e.setStart(t.firstChild,0):e.setStart(t,0),e.collapse(!0),n.removeAllRanges(),n.addRange(e)}onSelectionChange(){const t=window.getSelection(),e=t.rangeCount>0?t.getRangeAt(0):null,n=this.isSelectionInEditableArea(t);this.modules.forEach(t=>{"function"==typeof t.onSelectionChange&&t.onSelectionChange(e,n)}),this.updateToolbarButtonStates(),this.updateToolbarAccessibility(n),this.updateStatusbar()}isSelectionInEditableArea(t){if(!t||0===t.rangeCount)return!1;const e=t.getRangeAt(0),n=e.startContainer,i=e.endContainer,s=this.isNodeInEditableArea(n),o=this.isNodeInEditableArea(i);return s&&o}isNodeInEditableArea(t){if(!t)return!1;let e=t.nodeType===Node.TEXT_NODE?t.parentNode:t;for(;e&&e!==document.body;){if(e===this.editor||e.classList&&e.classList.contains("rich-editor-area"))return!0;e=e.parentNode}return!1}updateToolbarAccessibility(t){const e=this.getModule("toolbar");if(!e)return;["bold","italic","underline","strike","subscript","superscript","color","background","link","table","heading","font-family","line-height","capitalization","text-align","list","indent-increase","indent-decrease","text-size"].forEach(n=>{e.setButtonDisabled(n,!t)});["more","undo","redo","code-view","theme"].forEach(t=>{e.setButtonDisabled(t,!1)})}updateStatusbar(){if(!this.statusbar)return;const t=window.getSelection();if(t){if(this.statusbarEls.breadcrumb&&this.options.features.breadcrumb){const e=t.anchorNode,n=[];let i=3===e?.nodeType?e.parentElement:e;for(;i&&i!==this.editor&&i!==document.body;){if(i.tagName){let t=i.tagName.toLowerCase();if(i.className&&"string"==typeof i.className){const e=i.className.trim();e&&(t+="."+e.split(" ").join("."))}i.id&&(t+="#"+i.id),n.unshift(t)}i=i.parentElement}this.statusbarEls.breadcrumb.textContent=n.length>0?n.join(" > "):"editor"}if(this.statusbarEls.wordcount&&this.options.features.wordCount){const t=this.editor.textContent||"",e=t.trim()?t.trim().split(/\s+/).length:0,n=t.length,i=t.replace(/\s/g,"").length;this.statusbarEls.wordcount.textContent=`${e} words, ${n} chars (${i} no spaces)`}}}focus(){this.editor&&this.editor.focus()}getContent(){return this.editor.innerHTML}setContent(t){const e=this.wrapTextInParagraph(t);this.editor.innerHTML=e,this.onContentChange()}getModule(t){return this.modules.get(t)}getFormat(t){return this.formats.get(t)}register(t,e,n=!1){this.registry.register(t,e,n)}handleToolbarClick(t){const{command:e,button:i,value:s}=t;n.currentInstance,n.currentInstance=this,this.emit("toolbar-click",t);if(["more","undo","redo","code-view","theme"].includes(e))switch(e){case"more":case"code-view":return;case"undo":return void this.undo();case"redo":return void this.redo()}const o=window.getSelection();if(this.isSelectionInEditableArea(o))switch(e){case"bold":case"italic":case"underline":case"strike":case"subscript":case"superscript":case"color":case"background":case"link":case"table":case"heading":case"font-family":case"line-height":case"capitalization":case"text-align":case"text-size":case"list":case"indent-increase":case"indent-decrease":case"emoji":case"image":case"video":case"tag":case"import":this.toggleFormat(e)}}toggleFormat(t){const e=this.getModule("history");e&&"function"==typeof e.saveBeforeFormat&&e.saveBeforeFormat();const n={bold:"bold",italic:"italic",underline:"underline",strike:"strike",subscript:"subscript",superscript:"superscript",color:"color",background:"background",link:"link",table:"table",heading:"heading","font-family":"font-family","line-height":"line-height",capitalization:"capitalization","text-align":"text-align","text-size":"text-size",list:"list","indent-increase":"indent-increase","indent-decrease":"indent-decrease",emoji:"emoji",image:"image",video:"video",tag:"tag",import:"import"}[t];if(!n)return;const i=this.registry.get(`formats/${n}`);if(!i)return;(new i).toggle(),this.updateToolbarButtonStates();["bold","italic","underline","strike","subscript","superscript"].includes(t)&&setTimeout(()=>{this.onContentChange()},0)}updateToolbarButtonStates(){const t=this.getModule("toolbar");if(!t)return;const e=window.getSelection();if(!e||!e.rangeCount)return;const i=this.isSelectionInEditableArea(e);if(["heading","font-family","line-height","capitalization","text-align","list","indent-increase","indent-decrease","bold","italic","underline","strike","subscript","superscript","color","background","link","table","text-size"].forEach(e=>{if(i){const i=this.registry.get(`formats/${e}`);if(i){let s;if(i.createForEditor)s=i.createForEditor(this.instanceId);else{const t=n.currentInstance;n.currentInstance=this,s=new i,n.currentInstance=t}if(s){const n=s.isActive();t.setButtonActive(e,n),"line-height"===e&&"function"==typeof s.updateButtonText&&s.updateButtonText()}}}else t.setButtonActive(e,!1)}),i){const t=this.registry.get("formats/text-size");t&&"function"==typeof t.updateButtonTextStatic&&t.updateButtonTextStatic(this.instanceId)}}undo(){const t=this.getModule("history");t&&"function"==typeof t.undo?t.undo():document.execCommand("undo")}redo(){const t=this.getModule("history");t&&"function"==typeof t.redo?t.redo():document.execCommand("redo")}on(t,e){this.events.has(t)||this.events.set(t,[]),this.events.get(t).push(e)}off(t,e){if(this.events.has(t)){const n=this.events.get(t),i=n.indexOf(e);i>-1&&n.splice(i,1)}}emit(t,e){this.events.has(t)&&this.events.get(t).forEach(t=>{try{t(e)}catch(t){}})}preventFocusLoss(t,e="button, input, select, textarea, [contenteditable]"){t&&t.addEventListener("mousedown",t=>{t.target.closest(e)||(t.preventDefault(),setTimeout(()=>{this.focus()},0))})}static getCurrentInstance(){return n.currentInstance}static maintainFocus(t,e=null){"function"==typeof t&&t();const i=e||n.getCurrentInstance();i&&setTimeout(()=>i.focus(),0)}getPopupContainer(){return this.popupContainer}static getPopupContainer(){const t=n.getCurrentInstance();return t?t.getPopupContainer():null}getPopupInstance(t){return this.popupInstances.get(t)}setPopupInstance(t,e){this.popupInstances.set(t,e)}static getPopupInstanceById(t,e){const i=n.instances.get(t);return i?i.getPopupInstance(e):null}static getInstanceById(t){return n.instances.get(t)}static getAllInstances(){return n.instances}destroyPopupInstances(){this.popupInstances.forEach((t,e)=>{t&&"function"==typeof t.destroy&&t.destroy()}),this.popupInstances.clear()}updatePlaceholderVisibility(){this.editor.textContent.trim().length>0?this.editor.classList.remove("placeholder-visible"):this.editor.classList.add("placeholder-visible")}destroy(){this.modules.forEach(t=>{"function"==typeof t.destroy&&t.destroy()}),this.destroyPopupInstances(),this.wrapper&&this.wrapper.parentNode&&this.wrapper.parentNode.removeChild(this.wrapper),this.modules.clear(),this.formats.clear(),this.events.clear(),n.instances.delete(this.instanceId),n.currentInstance===this&&(n.currentInstance=null)}}class i{static formatName="";static tagName="";static className="";constructor(t){this.domNode=t}static create(t){const e=document.createElement(this.tagName);return this.className&&(e.className=this.className),e}getOffsetWithin(t,e){let n=0;const i=document.createTreeWalker(t,NodeFilter.SHOW_TEXT,null);let s;for(;s=i.nextNode();){if(s===e.startContainer)return n+e.startOffset;n+=s.textContent.length}return n}}class s extends i{static create(t){return super.create(t)}apply(t){const e=window.getSelection();if(!e||!e.rangeCount)return;const n=e.getRangeAt(0);if(n.collapsed){const i=this.constructor.create(t);i.appendChild(document.createTextNode("​")),n.insertNode(i);const s=document.createRange();s.setStart(i.firstChild,1),s.collapse(!0),e.removeAllRanges(),e.addRange(s)}else{const i=n.extractContents(),s=this.constructor.create(t);s.appendChild(i),n.insertNode(s);const o=document.createRange();o.selectNodeContents(s),e.removeAllRanges(),e.addRange(o)}}remove(){const t=window.getSelection();if(!t||!t.rangeCount)return;const e=t.getRangeAt(0);e.collapsed?this.removeAtCursor(e,t):this.removeFromSelection(e,t)}removeAtCursor(t,e){const n=t.startContainer,i=this.findFormatNode(n);if(!i||!i.parentNode)return;const s=i.textContent,o=this.getOffsetWithin(i,t),r=s.slice(0,o),l=s.slice(o),a=document.createDocumentFragment();if(r){const t=i.cloneNode(!1);t.textContent=r,a.appendChild(t)}const c=document.createTextNode("​");if(a.appendChild(c),l){const t=i.cloneNode(!1);t.textContent=l,a.appendChild(t)}i.replaceWith(a);const d=document.createRange();d.setStartAfter(c),d.collapse(!0),e.removeAllRanges(),e.addRange(d)}removeFromSelection(t,e){const n=this.constructor.formatName;document.execCommand(n),"strike"===n&&document.execCommand("strikeThrough")}findFormatNode(t){for(;t&&t!==document.body;){if(t.nodeType===Node.ELEMENT_NODE&&t.tagName===this.constructor.tagName)return t;t=t.parentNode}return null}findFormatNodesInRange(t){const e=[],n=document.createTreeWalker(t.commonAncestorContainer,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>e.tagName===this.constructor.tagName&&t.intersectsNode(e)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP});let i;for(;i=n.nextNode();)e.push(i);return e}isActive(){const t=window.getSelection();if(!t||!t.rangeCount)return!1;let e=t.getRangeAt(0).startContainer;const n=this.constructor.tagName,i=this.constructor.alternativeTagNames||[],s=this.constructor.formatName;if(["bold","italic","underline"].includes(s?.toLowerCase()))try{return document.queryCommandState(s)}catch(t){}for(;e&&e!==document.body;){if(e.nodeType===Node.ELEMENT_NODE&&(e.tagName===n||i.includes(e.tagName)))return!0;e=e.parentNode}return!1}}class o extends i{static create(t){return super.create(t)}apply(t){const e=window.getSelection();if(!e||!e.rangeCount)return;const n=e.getRangeAt(0),i=this.getBlockElements(n);0===i.length?this.createBlockAtCursor(n,t):i.forEach(e=>{this.convertBlock(e,t)})}remove(){const t=window.getSelection();if(!t||!t.rangeCount)return;const e=t.getRangeAt(0);this.getBlockElements(e).forEach(t=>{this.removeBlockFormat(t)})}createBlockAtCursor(t,e){const n=this.constructor.create(e),i=this.getBlockElement(t.startContainer);if(i&&i.style&&i.style.cssText&&(n.style.cssText=i.style.cssText),t.collapsed){n.appendChild(document.createTextNode("")),t.insertNode(n);const e=document.createRange();e.setStart(n,0),e.collapse(!0);const i=window.getSelection();i.removeAllRanges(),i.addRange(e)}else{const e=t.extractContents();n.appendChild(e),t.insertNode(n);const i=document.createRange();i.selectNodeContents(n);const s=window.getSelection();s.removeAllRanges(),s.addRange(i)}}convertBlock(t,e){const n=this.constructor.create(e);for(;t.firstChild;)n.appendChild(t.firstChild);t.className&&this.shouldPreserveClass(t.className)&&(n.className=t.className),t.style&&t.style.cssText&&(n.style.cssText=t.style.cssText),t.parentNode.replaceChild(n,t)}removeBlockFormat(t){const e=document.createElement("P");for(;t.firstChild;)e.appendChild(t.firstChild);t.style&&t.style.cssText&&(e.style.cssText=t.style.cssText),t.parentNode.replaceChild(e,t)}getBlockElements(t){const e=[];let n=this.getBlockElement(t.startContainer),i=this.getBlockElement(t.endContainer);if(n&&i&&n.nextElementSibling===i){t.endContainer===i&&0===t.endOffset&&(i=n)}if(n===i)n&&e.push(n);else{let t=n;for(;t&&t!==i;)this.isBlockElement(t)&&e.push(t),t=this.getNextBlockElement(t);i&&this.isBlockElement(i)&&e.push(i)}return e.filter((t,e,n)=>n.indexOf(t)===e)}getBlockElement(t){for(;t&&t.nodeType!==Node.ELEMENT_NODE;)t=t.parentNode;for(;t&&t!==document.body;){if(this.isBlockElement(t))return t;t=t.parentNode}return null}isBlockElement(t){if(!t||t.nodeType!==Node.ELEMENT_NODE)return!1;return["P","DIV","H1","H2","H3","H4","H5","H6","BLOCKQUOTE","PRE","UL","OL","LI","SECTION","ARTICLE"].includes(t.tagName.toUpperCase())}getNextBlockElement(t){let e=t.nextElementSibling;for(;e;){if(this.isBlockElement(e))return e;e=e.nextElementSibling}return null}isActive(t=null){const e=window.getSelection();if(!e||!e.rangeCount)return!1;const n=e.getRangeAt(0),i=this.getBlockElement(n.startContainer);return!!i&&(i.tagName===this.constructor.tagName&&(!t||this.hasValue(i,t)))}hasValue(t,e){return!0}shouldPreserveClass(t){return!1}}function r(){const t=n.getCurrentInstance();if(t){const e=t.getModule("history");e&&"function"==typeof e.saveBeforeFormat&&e.saveBeforeFormat()}}class l extends s{static formatName="bold";static tagName="B";static alternativeTagNames=["STRONG"];apply(){r();try{document.execCommand("bold",!1,null)}catch(t){}}remove(){try{document.execCommand("bold",!1,null)}catch(t){}}toggle(){r();try{document.execCommand("bold",!1,null)}catch(t){}}isActive(){try{return document.queryCommandState("bold")}catch(t){return!1}}}class a extends s{static formatName="italic";static tagName="I";static alternativeTagNames=["EM"];toggle(){r(),this.isActive()?this.remove():this.apply()}}class c extends s{static formatName="underline";static tagName="U";static alternativeTagNames=["SPAN"];toggle(){r(),this.isActive()?this.remove():this.apply()}}class d extends s{static formatName="strike";static tagName="S";static alternativeTagNames=["STRIKE","DEL"];toggle(){r(),this.isActive()?this.remove():this.apply()}}class h extends s{static formatName="superscript";static tagName="SUP";removeSubscriptBeforeApply(){const t=new u;t.isActive()&&t.remove()}toggle(){r(),this.isActive()?this.remove():(this.removeSubscriptBeforeApply(),this.apply())}}class u extends s{static formatName="subscript";static tagName="SUB";removeSuperscriptBeforeApply(){const t=new h;t.isActive()&&t.remove()}toggle(){r(),this.isActive()?this.remove():(this.removeSuperscriptBeforeApply(),this.apply())}}const p={bold:'<svg xmlns="http://www.w3.org/2000/svg" width="11" height="14" viewBox="0 0 11 14" fill="none">\n<path d="M0 1.72875C0 1.24281 0.407135 0.85022 0.911072 0.85022H2.27768H2.73322H6.3775C8.3904 0.85022 10.0218 2.42334 10.0218 4.36435C10.0218 5.22367 9.70007 6.01435 9.16766 6.62383C10.2239 7.23881 10.9329 8.35619 10.9329 9.63556C10.9329 11.5766 9.30147 13.1497 7.28857 13.1497H2.73322H2.27768H0.911072C0.407135 13.1497 0 12.7571 0 12.2712C0 11.7852 0.407135 11.3926 0.911072 11.3926H1.36661V6.99995V2.60729H0.911072C0.407135 2.60729 0 2.21469 0 1.72875ZM6.3775 6.12142C7.38253 6.12142 8.19965 5.33349 8.19965 4.36435C8.19965 3.39522 7.38253 2.60729 6.3775 2.60729H3.18875V6.12142H6.3775ZM3.18875 7.87849V11.3926H7.28857C8.2936 11.3926 9.11072 10.6047 9.11072 9.63556C9.11072 8.66642 8.2936 7.87849 7.28857 7.87849H6.3775H3.18875Z" fill="#454545"/>\n</svg>',italic:'<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 12 12" fill="none">\n <path d="M4.31684 1.02168C4.31684 0.562739 4.6949 0.191956 5.16284 0.191956H10.2388C10.7067 0.191956 11.0848 0.562739 11.0848 1.02168C11.0848 1.48062 10.7067 1.85141 10.2388 1.85141H8.68694L5.16284 10.1487H6.85483C7.32277 10.1487 7.70082 10.5195 7.70082 10.9784C7.70082 11.4373 7.32277 11.8081 6.85483 11.8081H1.77886C1.31092 11.8081 0.932861 11.4373 0.932861 10.9784C0.932861 10.5195 1.31092 10.1487 1.77886 10.1487H3.33073L6.85483 1.85141H5.16284C4.6949 1.85141 4.31684 1.48062 4.31684 1.02168Z" fill="#454545"/>\n</svg>',underline:'\x3c!-- Underline icon SVG - to be filled by user --\x3e \n<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 12 12" fill="none">\n <path d="M0.475176 1.02168C0.475176 0.562739 0.824149 0.191956 1.25609 0.191956H3.59885C4.0308 0.191956 4.37977 0.562739 4.37977 1.02168C4.37977 1.48062 4.0308 1.85141 3.59885 1.85141H3.20839V5.17031C3.20839 6.54455 4.25775 7.65949 5.55115 7.65949C6.84454 7.65949 7.8939 6.54455 7.8939 5.17031V1.85141H7.50344C7.0715 1.85141 6.72253 1.48062 6.72253 1.02168C6.72253 0.562739 7.0715 0.191956 7.50344 0.191956H9.8462C10.2781 0.191956 10.6271 0.562739 10.6271 1.02168C10.6271 1.48062 10.2781 1.85141 9.8462 1.85141H9.45574V5.17031C9.45574 7.46243 7.70844 9.31894 5.55115 9.31894C3.39386 9.31894 1.64655 7.46243 1.64655 5.17031V1.85141H1.25609C0.824149 1.85141 0.475176 1.48062 0.475176 1.02168ZM0.0847168 10.9784C0.0847168 10.5195 0.43369 10.1487 0.865636 10.1487H10.2367C10.6686 10.1487 11.0176 10.5195 11.0176 10.9784C11.0176 11.4373 10.6686 11.8081 10.2367 11.8081H0.865636C0.43369 11.8081 0.0847168 11.4373 0.0847168 10.9784Z" fill="#454545"/>\n</svg>',strike:'\x3c!-- Strike icon SVG - to be filled by user --\x3e \n<svg xmlns="http://www.w3.org/2000/svg" width="15" height="16" viewBox="0 0 15 16" fill="none">\n <g clip-path="url(#clip0_3_45)">\n <path d="M5.28358 4.92512C5.37144 4.4529 5.66794 4.09874 6.20879 3.86538C6.78807 3.6183 7.63091 3.5277 8.64123 3.68693C8.96793 3.73909 9.98099 3.93676 10.2912 4.01638C10.7607 4.13993 11.2411 3.86264 11.3674 3.39317C11.4937 2.92371 11.2137 2.44326 10.7442 2.31697C10.3516 2.21264 9.27267 2.00399 8.91577 1.94908C7.68857 1.7569 6.49157 1.83378 5.51969 2.24833C4.51761 2.67662 3.75164 3.47828 3.54848 4.64508C3.54573 4.66156 3.54299 4.67528 3.54299 4.69175C3.46612 5.34791 3.55672 5.94367 3.82028 6.46529C3.94382 6.71238 4.10031 6.92927 4.27876 7.12145H1.73376C1.24782 7.12145 0.855225 7.51404 0.855225 7.99998C0.855225 8.48592 1.24782 8.87852 1.73376 8.87852H14.0332C14.5192 8.87852 14.9118 8.48592 14.9118 7.99998C14.9118 7.51404 14.5192 7.12145 14.0332 7.12145H8.2706L8.25962 7.1187L8.22942 7.11047C7.24107 6.81396 6.4394 6.57237 5.89032 6.20173C5.635 6.02877 5.47851 5.85581 5.39065 5.67736C5.30555 5.50989 5.24789 5.27653 5.28633 4.92512H5.28358ZM10.434 10.2293C10.5081 10.4077 10.5548 10.663 10.4861 11.0556C10.4038 11.5388 10.1073 11.9012 9.55545 12.1373C8.97617 12.3844 8.13607 12.475 7.12576 12.3158C6.63158 12.2362 5.77776 11.9451 5.08317 11.709C4.92942 11.6569 4.78117 11.6075 4.64665 11.5608C4.18542 11.407 3.6885 11.6569 3.53475 12.1181C3.38101 12.5793 3.63084 13.0763 4.09207 13.23C4.19091 13.2629 4.30896 13.3041 4.44074 13.3481C5.12435 13.5814 6.18682 13.9438 6.84573 14.0509H6.85122C8.07842 14.2431 9.27542 14.1662 10.2473 13.7516C11.2494 13.3233 12.0153 12.5217 12.2185 11.3549C12.3173 10.7783 12.2926 10.2457 12.1334 9.75979H10.0551C10.2473 9.91354 10.3681 10.0673 10.4367 10.232L10.434 10.2293Z" fill="#454545"/>\n </g>\n <defs>\n <clipPath id="clip0_3_45">\n <rect width="14.0565" height="14.0565" fill="white" transform="translate(0.855225 0.971741)"/>\n </clipPath>\n </defs>\n</svg>',subscript:'\x3c!-- Subscript icon SVG - to be filled by user --\x3e \n<svg xmlns="http://www.w3.org/2000/svg" width="15" height="14" viewBox="0 0 15 14" fill="none">\n <g clip-path="url(#clip0_26_737)">\n <path d="M1.50049 1.75C1.0165 1.75 0.625488 2.14102 0.625488 2.625C0.625488 3.10898 1.0165 3.5 1.50049 3.5H1.91885L4.36885 7L1.91885 10.5H1.50049C1.0165 10.5 0.625488 10.891 0.625488 11.375C0.625488 11.859 1.0165 12.25 1.50049 12.25H2.37549C2.65986 12.25 2.92783 12.1105 3.09189 11.8781L5.43799 8.52578L7.78408 11.8781C7.94814 12.1133 8.21611 12.25 8.50049 12.25H9.37549C9.85947 12.25 10.2505 11.859 10.2505 11.375C10.2505 10.891 9.85947 10.5 9.37549 10.5H8.95713L6.50713 7L8.95713 3.5H9.37549C9.85947 3.5 10.2505 3.10898 10.2505 2.625C10.2505 2.14102 9.85947 1.75 9.37549 1.75H8.50049C8.21611 1.75 7.94814 1.88945 7.78408 2.12187L5.43799 5.47422L3.09189 2.12187C2.92783 1.88945 2.65986 1.75 2.37549 1.75H1.50049ZM13.7505 8.75C13.7505 8.44648 13.5946 8.16484 13.3349 8.00625C13.0751 7.84766 12.7552 7.83125 12.4845 7.96797L11.6095 8.40547C11.1774 8.62148 11.0024 9.14648 11.2185 9.57852C11.3716 9.88477 11.6806 10.0625 12.0005 10.0625V12.25C11.5165 12.25 11.1255 12.641 11.1255 13.125C11.1255 13.609 11.5165 14 12.0005 14H12.8755H13.7505C14.2345 14 14.6255 13.609 14.6255 13.125C14.6255 12.641 14.2345 12.25 13.7505 12.25V8.75Z" fill="#454545"/>\n </g>\n <defs>\n <clipPath id="clip0_26_737">\n <rect width="14" height="14" fill="white" transform="translate(0.625488)"/>\n </clipPath>\n </defs>\n</svg>',superscript:'\x3c!-- Superscript icon SVG - to be filled by user --\x3e \n<svg xmlns="http://www.w3.org/2000/svg" width="15" height="14" viewBox="0 0 15 14" fill="none">\n <g clip-path="url(#clip0_26_735)">\n <path d="M13.7505 0.874642C13.7505 0.571127 13.5946 0.289486 13.3349 0.130892C13.0751 -0.0277016 12.7552 -0.0441078 12.4845 0.092611L11.6095 0.530111C11.1774 0.746127 11.0024 1.27113 11.2185 1.70316C11.3716 2.00941 11.6806 2.18714 12.0005 2.18714V4.37464C11.5165 4.37464 11.1255 4.76566 11.1255 5.24964C11.1255 5.73363 11.5165 6.12464 12.0005 6.12464H12.8755H13.7505C14.2345 6.12464 14.6255 5.73363 14.6255 5.24964C14.6255 4.76566 14.2345 4.37464 13.7505 4.37464V0.874642ZM1.50049 1.74964C1.0165 1.74964 0.625488 2.14066 0.625488 2.62464C0.625488 3.10863 1.0165 3.49964 1.50049 3.49964H1.91885L4.36885 6.99964L1.91885 10.4996H1.50049C1.0165 10.4996 0.625488 10.8907 0.625488 11.3746C0.625488 11.8586 1.0165 12.2496 1.50049 12.2496H2.37549C2.65986 12.2496 2.92783 12.1102 3.09189 11.8778L5.43799 8.52542L7.78408 11.8778C7.94814 12.1129 8.21611 12.2496 8.50049 12.2496H9.37549C9.85947 12.2496 10.2505 11.8586 10.2505 11.3746C10.2505 10.8907 9.85947 10.4996 9.37549 10.4996H8.95713L6.50713 6.99964L8.95713 3.49964H9.37549C9.85947 3.49964 10.2505 3.10863 10.2505 2.62464C10.2505 2.14066 9.85947 1.74964 9.37549 1.74964H8.50049C8.21611 1.74964 7.94814 1.8891 7.78408 2.12152L5.43799 5.47386L3.09189 2.12152C2.92783 1.8891 2.65986 1.74964 2.37549 1.74964H1.50049Z" fill="#454545"/>\n </g>\n <defs>\n <clipPath id="clip0_26_735">\n <rect width="14" height="14" fill="white" transform="translate(0.625488)"/>\n </clipPath>\n </defs>\n</svg>',"align-left":'<svg xmlns="http://www.w3.org/2000/svg" width="13" height="16" viewBox="0 0 13 16" fill="none">\n <path d="M8.35714 2C8.35714 2.55313 7.94219 3 7.42857 3H0.928571C0.414955 3 0 2.55313 0 2C0 1.44687 0.414955 1 0.928571 1H7.42857C7.94219 1 8.35714 1.44687 8.35714 2ZM8.35714 10C8.35714 10.5531 7.94219 11 7.42857 11H0.928571C0.414955 11 0 10.5531 0 10C0 9.44687 0.414955 9 0.928571 9H7.42857C7.94219 9 8.35714 9.44687 8.35714 10ZM0 6C0 5.44688 0.414955 5 0.928571 5H12.0714C12.585 5 13 5.44688 13 6C13 6.55312 12.585 7 12.0714 7H0.928571C0.414955 7 0 6.55312 0 6ZM13 14C13 14.5531 12.585 15 12.0714 15H0.928571C0.414955 15 0 14.5531 0 14C0 13.4469 0.414955 13 0.928571 13H12.0714C12.585 13 13 13.4469 13 14Z" fill="#454545"/>\n</svg>',"align-center":'<svg xmlns="http://www.w3.org/2000/svg" width="14" height="15" viewBox="0 0 14 15" fill="none">\n <g clip-path="url(#clip0_12_238)">\n <path d="M11 1.875C11 1.35645 10.5531 0.9375 10 0.9375H4C3.44688 0.9375 3 1.35645 3 1.875C3 2.39355 3.44688 2.8125 4 2.8125H10C10.5531 2.8125 11 2.39355 11 1.875ZM14 5.625C14 5.10645 13.5531 4.6875 13 4.6875H1C0.446875 4.6875 0 5.10645 0 5.625C0 6.14355 0.446875 6.5625 1 6.5625H13C13.5531 6.5625 14 6.14355 14 5.625ZM0 13.125C0 13.6436 0.446875 14.0625 1 14.0625H13C13.5531 14.0625 14 13.6436 14 13.125C14 12.6064 13.5531 12.1875 13 12.1875H1C0.446875 12.1875 0 12.6064 0 13.125ZM11 9.375C11 8.85645 10.5531 8.4375 10 8.4375H4C3.44688 8.4375 3 8.85645 3 9.375C3 9.89355 3.44688 10.3125 4 10.3125H10C10.5531 10.3125 11 9.89355 11 9.375Z" fill="#454545"/>\n </g>\n <defs>\n <clipPath id="clip0_12_238">\n <rect width="14" height="15" fill="white"/>\n </clipPath>\n </defs>\n</svg>',"align-right":'<svg xmlns="http://www.w3.org/2000/svg" width="14" height="15" viewBox="0 0 14 15" fill="none">\n <g clip-path="url(#clip0_12_244)">\n <path d="M14 1.875C14 2.39355 13.5531 2.8125 13 2.8125H6C5.44688 2.8125 5 2.39355 5 1.875C5 1.35645 5.44688 0.9375 6 0.9375H13C13.5531 0.9375 14 1.35645 14 1.875ZM14 9.375C14 9.89355 13.5531 10.3125 13 10.3125H6C5.44688 10.3125 5 9.89355 5 9.375C5 8.85645 5.44688 8.4375 6 8.4375H13C13.5531 8.4375 14 8.85645 14 9.375ZM0 5.625C0 5.10645 0.446875 4.6875 1 4.6875H13C13.5531 4.6875 14 5.10645 14 5.625C14 6.14355 13.5531 6.5625 13 6.5625H1C0.446875 6.5625 0 6.14355 0 5.625ZM14 13.125C14 13.6436 13.5531 14.0625 13 14.0625H1C0.446875 14.0625 0 13.6436 0 13.125C0 12.6064 0.446875 12.1875 1 12.1875H13C13.5531 12.1875 14 12.6064 14 13.125Z" fill="#454545"/>\n </g>\n <defs>\n <clipPath id="clip0_12_244">\n <rect width="14" height="15" fill="white"/>\n </clipPath>\n </defs>\n</svg>',"align-justify":'<svg xmlns="http://www.w3.org/2000/svg" width="14" height="15" viewBox="0 0 14 15" fill="none">\n <g clip-path="url(#clip0_12_240)">\n <path d="M14 1.875C14 1.35645 13.5531 0.9375 13 0.9375H1C0.446875 0.9375 0 1.35645 0 1.875C0 2.39355 0.446875 2.8125 1 2.8125H13C13.5531 2.8125 14 2.39355 14 1.875ZM14 9.375C14 8.85645 13.5531 8.4375 13 8.4375H1C0.446875 8.4375 0 8.85645 0 9.375C0 9.89355 0.446875 10.3125 1 10.3125H13C13.5531 10.3125 14 9.89355 14 9.375ZM0 5.625C0 6.14355 0.446875 6.5625 1 6.5625H13C13.5531 6.5625 14 6.14355 14 5.625C14 5.10645 13.5531 4.6875 13 4.6875H1C0.446875 4.6875 0 5.10645 0 5.625ZM14 13.125C14 12.6064 13.5531 12.1875 13 12.1875H1C0.446875 12.1875 0 12.6064 0 13.125C0 13.6436 0.446875 14.0625 1 14.0625H13C13.5531 14.0625 14 13.6436 14 13.125Z" fill="#454545"/>\n </g>\n <defs>\n <clipPath id="clip0_12_240">\n <rect width="14" height="15" fill="white"/>\n </clipPath>\n </defs>\n</svg>',"list-bullet":'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">\x3c!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--\x3e<path d="M64 144a48 48 0 1 0 0-96 48 48 0 1 0 0 96zM192 64c-17.7 0-32 14.3-32 32s14.3 32 32 32l288 0c17.7 0 32-14.3 32-32s-14.3-32-32-32L192 64zm0 160c-17.7 0-32 14.3-32 32s14.3 32 32 32l288 0c17.7 0 32-14.3 32-32s-14.3-32-32-32l-288 0zm0 160c-17.7 0-32 14.3-32 32s14.3 32 32 32l288 0c17.7 0 32-14.3 32-32s-14.3-32-32-32l-288 0zM64 464a48 48 0 1 0 0-96 48 48 0 1 0 0 96zm48-208a48 48 0 1 0 -96 0 48 48 0 1 0 96 0z"/></svg>',"list-ordered":'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">\x3c!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--\x3e<path d="M24 56c0-13.3 10.7-24 24-24l32 0c13.3 0 24 10.7 24 24l0 120 16 0c13.3 0 24 10.7 24 24s-10.7 24-24 24l-80 0c-13.3 0-24-10.7-24-24s10.7-24 24-24l16 0 0-96-8 0C34.7 80 24 69.3 24 56zM86.7 341.2c-6.5-7.4-18.3-6.9-24 1.2L51.5 357.9c-7.7 10.8-22.7 13.3-33.5 5.6s-13.3-22.7-5.6-33.5l11.1-15.6c23.7-33.2 72.3-35.6 99.2-4.9c21.3 24.4 20.8 60.9-1.1 84.7L86.8 432l33.2 0c13.3 0 24 10.7 24 24s-10.7 24-24 24l-88 0c-9.5 0-18.2-5.6-22-14.4s-2.1-18.9 4.3-25.9l72-78c5.3-5.8 5.4-14.6 .3-20.5zM224 64l256 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-256 0c-17.7 0-32-14.3-32-32s14.3-32 32-32zm0 160l256 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-256 0c-17.7 0-32-14.3-32-32s14.3-32 32-32zm0 160l256 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-256 0c-17.7 0-32-14.3-32-32s14.3-32 32-32z"/></svg>',"list-check":'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">\x3c!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--\x3e<path d="M152.1 38.2c9.9 8.9 10.7 24 1.8 33.9l-72 80c-4.4 4.9-10.6 7.8-17.2 7.9s-12.9-2.4-17.6-7L7 113C-2.3 103.6-2.3 88.4 7 79s24.6-9.4 33.9 0l22.1 22.1 55.1-61.2c8.9-9.9 24-10.7 33.9-1.8zm0 160c9.9 8.9 10.7 24 1.8 33.9l-72 80c-4.4 4.9-10.6 7.8-17.2 7.9s-12.9-2.4-17.6-7L7 273c-9.4-9.4-9.4-24.6 0-33.9s24.6-9.4 33.9 0l22.1 22.1 55.1-61.2c8.9-9.9 24-10.7 33.9-1.8zM224 96c0-17.7 14.3-32 32-32l224 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-224 0c-17.7 0-32-14.3-32-32zm0 160c0-17.7 14.3-32 32-32l224 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-224 0c-17.7 0-32-14.3-32-32zM160 416c0-17.7 14.3-32 32-32l288 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-288 0c-17.7 0-32-14.3-32-32zM48 368a48 48 0 1 1 0 96 48 48 0 1 1 0-96z"/></svg>',"list-alpha":'<svg xmlns="http://www.w3.org/2000/svg" width="20" height="14" viewBox="0 0 20 14" fill="none">\n <g clip-path="url(#clip0_28_112)">\n <path d="M9.6648 0.278534H18.8487C19.4853 0.278534 20.0001 0.78256 20.0001 1.40596C20.0001 2.02936 19.4853 2.53339 18.8487 2.53339H9.6648C9.02816 2.53339 8.51343 2.02936 8.51343 1.40596C8.51343 0.78256 9.02816 0.278534 9.6648 0.278534ZM9.6648 5.90241H18.8487C19.4853 5.90241 20.0001 6.40644 20.0001 7.02984C20.0001 7.65324 19.4853 8.15726 18.8487 8.15726H9.6648C9.02816 8.15726 8.51343 7.65324 8.51343 7.02984C8.51343 6.40644 9.02816 5.90241 9.6648 5.90241ZM9.6648 11.5197H18.8487C19.4853 11.5197 20.0001 12.0237 20.0001 12.6471C20.0001 13.2705 19.4853 13.7745 18.8487 13.7745H9.6648C9.02816 13.7745 8.51343 13.2705 8.51343 12.6471C8.51343 12.0237 9.02816 11.5197 9.6648 11.5197Z" fill="#010101"/>\n <path d="M1.80823 9.37091C2.07914 9.04595 2.60742 8.88678 3.18988 8.88678C4.6257 8.88678 5.51294 9.99431 5.51294 11.4401C5.51294 12.8858 4.61216 13.9934 3.18988 13.9934C2.56001 13.9934 1.97078 13.7215 1.76759 13.4164C1.67278 13.7811 1.46959 13.9536 1.1445 13.9536C0.663632 13.9536 0.460449 13.7016 0.460449 13.2307V7.30175C0.460449 6.81762 0.683951 6.59213 1.13095 6.59213C1.57796 6.59213 1.80823 6.82425 1.80823 7.30175V9.36428V9.37091ZM1.80823 11.4467C1.80823 12.1364 2.30264 12.6802 2.98669 12.6802C3.67074 12.6802 4.16516 12.1364 4.16516 11.4467C4.16516 10.757 3.67074 10.2132 2.98669 10.2132C2.30264 10.2132 1.80823 10.7769 1.80823 11.4467Z" fill="#231F20"/>\n <path d="M3.77237 0.58361C3.84687 0.258645 4.04328 0.092847 4.38192 0.092847C4.82215 0.092847 5.04565 0.311701 5.04565 0.762672V4.34391C5.04565 4.82804 4.82215 5.06679 4.3616 5.06679C4.04328 5.06679 3.8401 4.88773 3.73851 4.52961C3.53532 4.83468 2.94609 5.10658 2.31623 5.10658C0.893943 5.10658 -0.00683594 3.97252 -0.00683594 2.55329C-0.00683594 1.13406 0.88717 0 2.323 0C2.96641 0 3.52855 0.179062 3.77914 0.58361H3.77237ZM1.34772 2.55329C1.34772 3.25628 1.84213 3.78683 2.52618 3.78683C3.21023 3.78683 3.70464 3.24964 3.70464 2.55329C3.70464 1.85694 3.21023 1.31975 2.52618 1.31975C1.84213 1.31975 1.34772 1.88347 1.34772 2.55329Z" fill="#231F20"/>\n </g>\n <defs>\n <clipPath id="clip0_28_112">\n <rect width="20" height="14" fill="white"/>\n </clipPath>\n </defs>\n</svg>',"list-roman":'<svg xmlns="http://www.w3.org/2000/svg" width="19" height="13" viewBox="0 0 19 13" fill="none">\n <g clip-path="url(#clip0_28_165)">\n <path d="M9.89384 0.533844H17.9855C18.5465 0.533844 19 0.979692 19 1.53114C19 2.08258 18.5465 2.52843 17.9855 2.52843H9.89384C9.33291 2.52843 8.87939 2.08258 8.87939 1.53114C8.87939 0.979692 9.33291 0.533844 9.89384 0.533844ZM9.89384 5.50271H17.9855C18.5465 5.50271 19 5.94856 19 6.5C19 7.05144 18.5465 7.49729 17.9855 7.49729H9.89384C9.33291 7.49729 8.87939 7.05144 8.87939 6.5C8.87939 5.94856 9.33291 5.50271 9.89384 5.50271ZM9.89384 10.4774H17.9855C18.5465 10.4774 19 10.9233 19 11.4747C19 12.0262 18.5465 12.472 17.9855 12.472H9.89384C9.33291 12.472 8.87939 12.0262 8.87939 11.4747C8.87939 10.9233 9.33291 10.4774 9.89384 10.4774Z" fill="#010101"/>\n <path d="M2.6495 7.15703C3.06124 7.15703 3.27607 7.35062 3.27607 7.7202C3.27607 8.08979 3.06124 8.28338 2.6495 8.28338H2.23178V11.8678H2.6495C3.06124 11.8678 3.27607 12.0614 3.27607 12.4309C3.27607 12.8005 3.06124 12.9941 2.6495 12.9941H0.62657C0.208857 12.9941 0 12.8064 0 12.4192C0 12.032 0.202889 11.8619 0.62657 11.8619H1.07412V8.27751H0.62657C0.208857 8.27751 0 8.08979 0 7.7026C0 7.31542 0.202889 7.14529 0.62657 7.14529H2.6495V7.15703Z" fill="#231F20"/>\n <path d="M6.33724 7.15703C6.74899 7.15703 6.96381 7.35062 6.96381 7.7202C6.96381 8.08979 6.74899 8.28338 6.33724 8.28338H5.91953V11.8678H6.33724C6.74899 11.8678 6.96381 12.0614 6.96381 12.4309C6.96381 12.8005 6.74899 12.9941 6.33724 12.9941H4.31431C3.8966 12.9941 3.68774 12.8064 3.68774 12.4192C3.68774 12.032 3.89063 11.8619 4.31431 11.8619H4.76186V8.27751H4.31431C3.8966 8.27751 3.68774 8.08979 3.68774 7.7026C3.68774 7.31542 3.89063 7.14529 4.31431 7.14529H6.33724V7.15703Z" fill="#231F20"/>\n <path d="M4.49349 0C4.90524 0 5.12006 0.193592 5.12006 0.563177C5.12006 0.932762 4.90524 1.12635 4.49349 1.12635H4.07578V4.71074H4.49349C4.90524 4.71074 5.12006 4.90433 5.12006 5.27392C5.12006 5.6435 4.90524 5.83709 4.49349 5.83709H2.47056C2.05285 5.83709 1.84399 5.64937 1.84399 5.26218C1.84399 4.875 2.04688 4.70487 2.47056 4.70487H2.91811V1.13222H2.47056C2.05285 1.13222 1.84399 0.944495 1.84399 0.55731C1.84399 0.170126 2.04688 0 2.47056 0H4.49349Z" fill="#231F20"/>\n </g>\n <defs>\n <clipPath id="clip0_28_165">\n <rect width="19" height="13" fill="white"/>\n </clipPath>\n </defs>\n</svg>',list:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">\x3c!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--\x3e<path d="M40 48C26.7 48 16 58.7 16 72l0 48c0 13.3 10.7 24 24 24l48 0c13.3 0 24-10.7 24-24l0-48c0-13.3-10.7-24-24-24L40 48zM192 64c-17.7 0-32 14.3-32 32s14.3 32 32 32l288 0c17.7 0 32-14.3 32-32s-14.3-32-32-32L192 64zm0 160c-17.7 0-32 14.3-32 32s14.3 32 32 32l288 0c17.7 0 32-14.3 32-32s-14.3-32-32-32l-288 0zm0 160c-17.7 0-32 14.3-32 32s14.3 32 32 32l288 0c17.7 0 32-14.3 32-32s-14.3-32-32-32l-288 0zM16 232l0 48c0 13.3 10.7 24 24 24l48 0c13.3 0 24-10.7 24-24l0-48c0-13.3-10.7-24-24-24l-48 0c-13.3 0-24 10.7-24 24zM40 368c-13.3 0-24 10.7-24 24l0 48c0 13.3 10.7 24 24 24l48 0c13.3 0 24-10.7 24-24l0-48c0-13.3-10.7-24-24-24l-48 0z"/></svg>',"indent-increase":'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512">\x3c!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--\x3e<path d="M0 64C0 46.3 14.3 32 32 32l384 0c17.7 0 32 14.3 32 32s-14.3 32-32 32L32 96C14.3 96 0 81.7 0 64zM192 192c0-17.7 14.3-32 32-32l192 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-192 0c-17.7 0-32-14.3-32-32zm32 96l192 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-192 0c-17.7 0-32-14.3-32-32s14.3-32 32-32zM0 448c0-17.7 14.3-32 32-32l384 0c17.7 0 32 14.3 32 32s-14.3 32-32 32L32 480c-17.7 0-32-14.3-32-32zM127.8 268.6L25.8 347.9C15.3 356.1 0 348.6 0 335.3L0 176.7c0-13.3 15.3-20.8 25.8-12.6l101.9 79.3c8.2 6.4 8.2 18.9 0 25.3z"/></svg>',"indent-decrease":'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512">\x3c!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--\x3e<path d="M0 64C0 46.3 14.3 32 32 32l384 0c17.7 0 32 14.3 32 32s-14.3 32-32 32L32 96C14.3 96 0 81.7 0 64zM192 192c0-17.7 14.3-32 32-32l192 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-192 0c-17.7 0-32-14.3-32-32zm32 96l192 0c17.7 0 32 14.3 32 32s-14.3 32-32 32l-192 0c-17.7 0-32-14.3-32-32s14.3-32 32-32zM0 448c0-17.7 14.3-32 32-32l384 0c17.7 0 32 14.3 32 32s-14.3 32-32 32L32 480c-17.7 0-32-14.3-32-32zM.2 268.6c-8.2-6.4-8.2-18.9 0-25.3l101.9-79.3c10.5-8.2 25.8-.7 25.8 12.6l0 158.6c0 13.3-15.3 20.8-25.8 12.6L.2 268.6z"/></svg>',image:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">\x3c!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--\x3e<path d="M448 80c8.8 0 16 7.2 16 16l0 319.8-5-6.5-136-176c-4.5-5.9-11.6-9.3-19-9.3s-14.4 3.4-19 9.3L202 340.7l-30.5-42.7C167 291.7 159.8 288 152 288s-15 3.7-19.5 10.1l-80 112L48 416.3l0-.3L48 96c0-8.8 7.2-16 16-16l384 0zM64 32C28.7 32 0 60.7 0 96L0 416c0 35.3 28.7 64 64 64l384 0c35.3 0 64-28.7 64-64l0-320c0-35.3-28.7-64-64-64L64 32zm80 192a48 48 0 1 0 0-96 48 48 0 1 0 0 96z"/></svg>',video:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">\x3c!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--\x3e<path d="M0 96C0 60.7 28.7 32 64 32l384 0c35.3 0 64 28.7 64 64l0 320c0 35.3-28.7 64-64 64L64 480c-35.3 0-64-28.7-64-64L0 96zM48 368l0 32c0 8.8 7.2 16 16 16l32 0c8.8 0 16-7.2 16-16l0-32c0-8.8-7.2-16-16-16l-32 0c-8.8 0-16 7.2-16 16zm368-16c-8.8 0-16 7.2-16 16l0 32c0 8.8 7.2 16 16 16l32 0c8.8 0 16-7.2 16-16l0-32c0-8.8-7.2-16-16-16l-32 0zM48 240l0 32c0 8.8 7.2 16 16 16l32 0c8.8 0 16-7.2 16-16l0-32c0-8.8-7.2-16-16-16l-32 0c-8.8 0-16 7.2-16 16zm368-16c-8.8 0-16 7.2-16 16l0 32c0 8.8 7.2 16 16 16l32 0c8.8 0 16-7.2 16-16l0-32c0-8.8-7.2-16-16-16l-32 0zM48 112l0 32c0 8.8 7.2 16 16 16l32 0c8.8 0 16-7.2 16-16l0-32c0-8.8-7.2-16-16-16L64 96c-8.8 0-16 7.2-16 16zM416 96c-8.8 0-16 7.2-16 16l0 32c0 8.8 7.2 16 16 16l32 0c8.8 0 16-7.2 16-16l0-32c0-8.8-7.2-16-16-16l-32 0zM160 128l0 64c0 17.7 14.3 32 32 32l128 0c17.7 0 32-14.3 32-32l0-64c0-17.7-14.3-32-32-32L192 96c-17.7 0-32 14.3-32 32zm32 160c-17.7 0-32 14.3-32 32l0 64c0 17.7 14.3 32 32 32l128 0c17.7 0 32-14.3 32-32l0-64c0-17.7-14.3-32-32-32l-128 0z"/></svg>',table:'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" fill="none">\n <g clip-path="url(#clip0_26_744)">\n <path d="M2.50049 8V5.1875H7.18799V8H2.50049ZM2.50049 9.875H7.18799V12.6875H2.50049V9.875ZM9.06299 12.6875V9.875H13.7505V12.6875H9.06299ZM13.7505 8H9.06299V5.1875H13.7505V8ZM2.50049 1.4375C1.46631 1.4375 0.625488 2.27832 0.625488 3.3125V12.6875C0.625488 13.7217 1.46631 14.5625 2.50049 14.5625H13.7505C14.7847 14.5625 15.6255 13.7217 15.6255 12.6875V3.3125C15.6255 2.27832 14.7847 1.4375 13.7505 1.4375H2.50049Z" fill="#454545"/>\n </g>\n <defs>\n <clipPath id="clip0_26_744">\n <rect width="15" height="15" fill="white" transform="translate(0.625488 0.5)"/>\n </clipPath>\n </defs>\n</svg>',"table-profile":'<svg xmlns="http://www.w3.org/2000/svg" width="18" height="14" viewBox="0 0 18 14" fill="none">\n <g clip-path="url(#clip0_23_620)">\n <path d="M17.2744 10.9348V2.16365C17.2744 0.994844 16.3413 0.0475311 15.1901 0.0475311H2.35536C1.20413 0.0475311 0.274414 0.991437 0.274414 2.16024V10.9382C0.274414 12.1036 1.20413 13.0509 2.35536 13.0509H15.1935C16.3447 13.0509 17.2744 12.1036 17.2744 10.9382V10.9348ZM2.31844 7.60218H7.66178V10.8803H2.31844V7.60218ZM15.0827 10.8803H9.74273V7.60218H15.0827V10.8803ZM15.0827 5.48947H9.74273V2.21477H15.0827V5.48947ZM2.31844 2.21477H7.66178V5.48947H2.31844V2.21477Z" fill="#454545"/>\n </g>\n <defs>\n <clipPath id="clip0_23_620">\n <rect width="17" height="13" fill="white" transform="translate(0.274414 0.0475311)"/>\n </clipPath>\n </defs>\n</svg>',"add-row-above":'<svg xmlns="http://www.w3.org/2000/svg" width="18" height="16" viewBox="0 0 18 16" fill="none">\n <path d="M15.6134 2.02472H13.216C13.3691 2.47353 13.4541 2.9566 13.4541 3.4568C13.4541 3.71033 13.4337 3.96043 13.3895 4.20368H15.6508V7.49953H10.7847C10.2678 7.71537 9.70328 7.83528 9.10819 7.83528C8.5131 7.83528 7.94861 7.71537 7.43173 7.49953H2.71859V4.20368H4.82692C4.78271 3.96043 4.76231 3.71033 4.76231 3.4568C4.76231 2.9566 4.84732 2.47353 5.00035 2.02472H2.60637C1.43999 2.02472 0.498047 2.97716 0.498047 4.15229V12.9709C0.498047 14.146 1.43999 15.0951 2.60637 15.0951H15.6134C16.7764 15.0951 17.7217 14.146 17.7217 12.9743V4.14886C17.7217 2.97716 16.7764 2.02472 15.6134 2.02472ZM8.12884 12.9161H2.71859V9.62367H8.12884V12.9161ZM15.6508 12.9161H10.2372V9.62367H15.6508V12.9161Z" fill="#454545"/>\n <path d="M12.2335 2.02479C11.6962 0.832527 10.4992 0 9.1118 0C7.72438 0 6.52739 0.832527 5.99011 2.02479C5.78948 2.4599 5.68066 2.94639 5.68066 3.45687C5.68066 3.71383 5.70787 3.96393 5.76228 4.20375C6.02752 5.4337 6.94566 6.41697 8.13245 6.77328C8.44189 6.86578 8.77174 6.91717 9.1118 6.91717C9.50626 6.91717 9.88712 6.84865 10.2408 6.72531C11.3527 6.33474 12.2063 5.38231 12.4613 4.20375C12.5157 3.96393 12.5429 3.71383 12.5429 3.45687C12.5429 2.94639 12.4341 2.4599 12.2335 2.02479ZM10.8393 3.77549H9.42465V5.1973C9.42465 5.37203 9.28522 5.5125 9.1118 5.5125C8.93837 5.5125 8.79895 5.37203 8.79895 5.1973V3.77549H7.38433C7.2109 3.77549 7.07148 3.6316 7.07148 3.45687C7.07148 3.28214 7.2109 3.14168 7.38433 3.14168H8.79895V1.71987C8.79895 1.54514 8.93837 1.40125 9.1118 1.40125C9.28522 1.40125 9.42465 1.54514 9.42465 1.71987V3.14168H10.8393C11.0127 3.14168 11.1521 3.28214 11.1521 3.45687C11.1521 3.6316 11.0127 3.77549 10.8393 3.77549Z" fill="#454545"/>\n</svg>',"add-row-below":'<svg xmlns="http://www.w3.org/2000/svg" width="18" height="16" viewBox="0 0 18 16" fill="none">\n <path d="M2.83001 13.0703H5.22738C5.07436 12.6215 4.98935 12.1385 4.98935 11.6383C4.98935 11.3847 5.00975 11.1346 5.05396 10.8914H2.79261V7.59554H7.65876C8.17564 7.3797 8.74013 7.25979 9.33522 7.25979C9.93032 7.25979 10.4948 7.3797 11.0117 7.59554H15.7248V10.8914H13.6165C13.6607 11.1346 13.6811 11.3847 13.6811 11.6383C13.6811 12.1385 13.5961 12.6215 13.4431 13.0703H15.837C17.0034 13.0703 17.9454 12.1179 17.9454 10.9428V2.12416C17.9454 0.949028 17.0034 1.52588e-05 15.837 1.52588e-05H2.83001C1.66703 1.52588e-05 0.72168 0.949028 0.72168 2.12073V10.9462C0.72168 12.1179 1.66703 13.0703 2.83001 13.0703ZM10.3146 2.17898H15.7248V5.4714H10.3146V2.17898ZM2.79261 2.17898H8.20625V5.4714H2.79261V2.17898Z" fill="#454545"/>\n <path d="M6.2135 13.0703C6.75079 14.2625 7.94777 15.095 9.33519 15.095C10.7226 15.095 11.9196 14.2625 12.4569 13.0703C12.6575 12.6351 12.7663 12.1486 12.7663 11.6382C12.7663 11.3812 12.7391 11.1311 12.6847 10.8913C12.4195 9.66135 11.5013 8.67807 10.3145 8.32177C10.0051 8.22926 9.67524 8.17787 9.33519 8.17787C8.94072 8.17787 8.55987 8.24639 8.20621 8.36973C7.09424 8.7603 6.24071 9.71274 5.98567 10.8913C5.93126 11.1311 5.90405 11.3812 5.90405 11.6382C5.90405 12.1486 6.01287 12.6351 6.2135 13.0703ZM7.60772 11.3195H9.02234V9.89774C9.02234 9.72302 9.16176 9.58255 9.33519 9.58255C9.50861 9.58255 9.64803 9.72302 9.64803 9.89774V11.3195H11.0627C11.2361 11.3195 11.3755 11.4634 11.3755 11.6382C11.3755 11.8129 11.2361 11.9534 11.0627 11.9534H9.64803V13.3752C9.64803 13.5499 9.50861 13.6938 9.33519 13.6938C9.16176 13.6938 9.02234 13.5499 9.02234 13.3752V11.9534H7.60772C7.43429 11.9534 7.29487 11.8129 7.29487 11.6382C7.29487 11.4634 7.43429 11.3195 7.60772 11.3195Z" fill="#454545"/>\n</svg>',"add-col-left":'<svg xmlns="http://www.w3.org/2000/svg" width="19" height="14" viewBox="0 0 19 14" fill="none">\n <path d="M16.4982 0.0123596H3.49115C2.32476 0.0123596 1.38281 0.964798 1.38281 2.1365V2.78402C2.03231 2.39346 2.79063 2.17076 3.60336 2.17076C3.73938 2.17076 3.872 2.17762 4.00462 2.19132H9.0136V5.48717H7.82001C7.90503 5.82977 7.94924 6.18265 7.94924 6.54924C7.94924 6.91583 7.90503 7.27213 7.82001 7.61131H9.0136V10.9037H4.04883C3.9026 10.9209 3.75298 10.9277 3.60336 10.9277C2.79063 10.9277 2.03231 10.705 1.38281 10.3145V10.9586C1.38281 12.1303 2.32476 13.0827 3.49115 13.0827H16.4982C17.6612 13.0827 18.6065 12.1337 18.6065 10.962V2.1365C18.6065 0.964798 17.6612 0.0123596 16.4982 0.0123596ZM16.5356 10.9037H11.1219V7.61131H16.5356V10.9037ZM16.5356 5.48717H11.1219V2.19132H16.5356V5.48717Z" fill="#454545"/>\n <path d="M6.87164 5.48725C6.42617 4.09627 5.13057 3.08902 3.60373 3.08902C2.75699 3.08902 1.98167 3.39736 1.38318 3.91469C0.638465 4.54509 0.169189 5.49067 0.169189 6.54932C0.169189 7.60796 0.638465 8.55012 1.38318 9.18052C1.98167 9.69785 2.75699 10.0062 3.60373 10.0062C5.13057 10.0062 6.42617 8.99894 6.87164 7.61139C6.97706 7.27906 7.03486 6.91933 7.03486 6.54932C7.03486 6.17931 6.97706 5.81957 6.87164 5.48725ZM5.3278 6.86451H3.91658V8.28632C3.91658 8.46105 3.77715 8.60494 3.60373 8.60494C3.4303 8.60494 3.28748 8.46105 3.28748 8.28632V6.86451H1.87626C1.70284 6.86451 1.56341 6.72405 1.56341 6.54932C1.56341 6.37459 1.70284 6.2307 1.87626 6.2307H3.28748V4.80889C3.28748 4.63416 3.4303 4.4937 3.60373 4.4937C3.77715 4.4937 3.91658 4.63416 3.91658 4.80889V6.2307H5.3278C5.50123 6.2307 5.64405 6.37459 5.64405 6.54932C5.64405 6.72405 5.50123 6.86451 5.3278 6.86451Z" fill="#454545"/>\n</svg>',"add-col-right":'<svg xmlns="http://www.w3.org/2000/svg" width="20" height="14" viewBox="0 0 20 14" fill="none">\n <path d="M2.71478 13.0827H15.7218C16.8882 13.0827 17.8301 12.1303 17.8301 10.9586V10.311C17.1806 10.7016 16.4223 10.9243 15.6096 10.9243C15.4736 10.9243 15.3409 10.9174 15.2083 10.9037H10.1993V7.60789H11.3929C11.3079 7.26528 11.2637 6.9124 11.2637 6.54581C11.2637 6.17923 11.3079 5.82292 11.3929 5.48374H10.1993V2.19132H15.1641C15.3103 2.17419 15.46 2.16734 15.6096 2.16734C16.4223 2.16734 17.1806 2.39003 17.8301 2.7806V2.1365C17.8301 0.964798 16.8882 0.0123596 15.7218 0.0123596H2.71478C1.5518 0.0123596 0.606445 0.961372 0.606445 2.13308V10.9586C0.606445 12.1303 1.5518 13.0827 2.71478 13.0827ZM2.67737 2.19132H8.09102V5.48374H2.67737V2.19132ZM2.67737 7.60789H8.09102V10.9037H2.67737V7.60789Z" fill="#454545"/>\n <path d="M12.3419 7.60796C12.7874 8.99894 14.083 10.0062 15.6098 10.0062C16.4566 10.0062 17.2319 9.69785 17.8304 9.18052C18.5751 8.55012 19.0444 7.60454 19.0444 6.54589C19.0444 5.48725 18.5751 4.54509 17.8304 3.91469C17.2319 3.39736 16.4566 3.08902 15.6098 3.08902C14.083 3.08902 12.7874 4.09627 12.3419 5.48382C12.2365 5.81615 12.1787 6.17588 12.1787 6.54589C12.1787 6.9159 12.2365 7.27564 12.3419 7.60796ZM13.8858 6.2307H15.297V4.80889C15.297 4.63416 15.4364 4.49027 15.6098 4.49027C15.7833 4.49027 15.9261 4.63416 15.9261 4.80889V6.2307H17.3373C17.5107 6.2307 17.6502 6.37116 17.6502 6.54589C17.6502 6.72062 17.5107 6.86451 17.3373 6.86451H15.9261V8.28632C15.9261 8.46105 15.7833 8.60152 15.6098 8.60152C15.4364 8.60152 15.297 8.46105 15.297 8.28632V6.86451H13.8858C13.7124 6.86451 13.5695 6.72062 13.5695 6.54589C13.5695 6.37116 13.7124 6.2307 13.8858 6.2307Z" fill="#454545"/>\n</svg>',"delete-row":'<svg xmlns="http://www.w3.org/2000/svg" width="19" height="14" viewBox="0 0 19 14" fill="none">\n <path d="M18.169 2.13993V10.9586C18.169 12.1337 17.2271 13.0827 16.0607 13.0827H3.05365C1.89066 13.0827 0.945312 12.1337 0.945312 10.962V2.1365C0.945312 0.964798 1.89066 0.0123596 3.05365 0.0123596H7.45053C7.10367 0.204218 6.77723 0.450893 6.48478 0.745532C6.06311 1.17036 5.74346 1.66371 5.53263 2.19132H3.01624V5.48374H5.53263C5.74346 6.01135 6.05971 6.50813 6.48478 6.93638C6.74662 7.20019 7.03226 7.42288 7.33831 7.60789H3.01624V10.9037H8.42988V8.0704C9.12019 8.25541 9.8445 8.26911 10.5382 8.10466V10.9037H15.9485V7.60789H11.7794C12.0855 7.42288 12.3711 7.20019 12.6329 6.93638C13.058 6.50813 13.3743 6.01135 13.5851 5.48374H15.9485V2.19132H13.5851C13.3743 1.66371 13.0546 1.17036 12.6329 0.745532C12.3405 0.450893 12.014 0.204218 11.6672 0.0123596H16.0607C17.2271 0.0123596 18.169 0.964798 18.169 2.13993Z" fill="#454545"/>\n <path d="M12.5751 2.19137C12.4221 1.90701 12.2249 1.63635 11.9869 1.39653C10.6436 0.04324 8.4707 0.04324 7.1309 1.39653C6.89286 1.63635 6.69563 1.90701 6.5426 2.19137C5.98832 3.21575 5.98832 4.4594 6.53921 5.48379C6.69223 5.77158 6.88946 6.04223 7.1309 6.28548C8.4707 7.63534 10.6436 7.63534 11.9869 6.28548C12.2283 6.04223 12.4255 5.77158 12.5785 5.48379C13.1294 4.4594 13.1294 3.21575 12.5751 2.19137ZM10.5382 4.3806L11.0007 4.84655C11.1231 4.96988 11.1231 5.16859 11.0007 5.29536C10.8783 5.41869 10.681 5.41869 10.5586 5.29536L9.55887 4.2881L8.55912 5.29536C8.52171 5.33304 8.47751 5.36045 8.4299 5.37073C8.32108 5.40842 8.20207 5.38101 8.11705 5.29536C7.99463 5.16859 7.99463 4.96988 8.11705 4.84655L8.4299 4.53135L9.1134 3.83929L8.11705 2.83546C7.99463 2.71212 7.99463 2.50999 8.11705 2.38665C8.20207 2.301 8.32108 2.27359 8.4299 2.31128C8.47751 2.32156 8.52171 2.34896 8.55912 2.38665L9.55887 3.39391L10.5586 2.38665C10.681 2.26331 10.8783 2.26331 11.0007 2.38665C11.1231 2.50999 11.1231 2.71212 11.0007 2.83546L10.5382 3.3014L10.0009 3.83929L10.5382 4.3806Z" fill="#454545"/>\n</svg>',"delete-col":'<svg xmlns="http://www.w3.org/2000/svg" width="19" height="14" viewBox="0 0 19 14" fill="none">\n <path d="M16.5185 0.0123596H3.51142C2.34844 0.0123596 1.40649 0.964798 1.40649 2.1365V2.69495C2.18522 2.27012 3.06596 2.10224 3.92289 2.19132H8.89106V5.48374H7.69069C7.86412 6.17923 7.86412 6.9124 7.69069 7.60789H8.89106V10.9037H3.89228C3.04215 10.986 2.17501 10.8181 1.40649 10.3967V10.962C1.40649 12.1337 2.34844 13.0827 3.51142 13.0827H16.5185C17.6848 13.0827 18.6302 12.1303 18.6302 10.9586V2.13993C18.6302 0.964798 17.6848 0.0123596 16.5185 0.0123596ZM16.4096 10.9037H10.9994V7.60789H16.4096V10.9037ZM16.4096 5.48374H10.9994V2.19132H16.4096V5.48374Z" fill="#454545"/>\n <path d="M6.74518 5.48377C6.58195 4.97671 6.30312 4.50049 5.90185 4.09965C5.23195 3.42472 4.35801 3.08554 3.47727 3.08554C2.74616 3.08554 2.01504 3.31851 1.40634 3.78788C1.28052 3.88038 1.16151 3.98659 1.04929 4.09965C-0.290519 5.44951 -0.290519 7.64217 1.04929 8.99203C1.16151 9.10509 1.28052 9.2113 1.40634 9.3038C2.01504 9.77317 2.74616 10.0061 3.47727 10.0061C4.35801 10.0061 5.23195 9.66696 5.90185 8.99203C6.30312 8.59119 6.58195 8.11496 6.74518 7.60791C6.96281 6.91928 6.96281 6.1724 6.74518 5.48377ZM4.9191 7.55309C4.9191 7.55309 4.9497 7.58736 4.9633 7.60791C5.03812 7.72782 5.02451 7.89227 4.9191 7.99848C4.79668 8.12182 4.59605 8.12182 4.47363 7.99848L4.08596 7.60791L3.47727 6.99465L2.47752 7.99848C2.3551 8.12182 2.15787 8.12182 2.03205 7.99848C1.90963 7.87514 1.90963 7.67643 2.03205 7.55309L3.0318 6.54584L2.03205 5.53858C1.90963 5.41525 1.90963 5.21654 2.03205 5.0932C2.15787 4.96986 2.3551 4.96986 2.47752 5.0932L3.47727 6.09703L4.47363 5.0932C4.59605 4.96986 4.79668 4.96986 4.9191 5.0932C5.02451 5.19941 5.03812 5.36386 4.9633 5.48377C4.9497 5.50432 4.9361 5.52145 4.9191 5.53858L3.91934 6.54584L4.9191 7.55309Z" fill="#454545"/>\n</svg>',"delete-table":'<svg xmlns="http://www.w3.org/2000/svg" width="18" height="14" viewBox="0 0 18 14" fill="none">\n <path d="M15.3864 0.0123596H2.37934C1.21636 0.0123596 0.274414 0.964798 0.274414 2.1365V10.962C0.274414 12.1337 1.21636 13.0827 2.37934 13.0827H15.3864C16.5528 13.0827 17.4981 12.1337 17.4981 10.9586V2.13993C17.4981 0.964798 16.5528 0.0123596 15.3864 0.0123596ZM15.2776 5.48374H13.2542C13.4209 6.18265 13.4209 6.9124 13.2542 7.60789H15.2776V10.9037H10.1257C9.31642 11.1367 8.45609 11.1367 7.64676 10.9037H2.34534V7.60789H4.51488C4.34825 6.9124 4.34825 6.18265 4.51488 5.48374H2.34534V2.19132H7.66037C8.46289 1.96178 9.31302 1.96178 10.1155 2.19132H15.2776V5.48374Z" fill="#454545"/>\n <path d="M12.2715 5.48376C12.1083 4.9493 11.8158 4.44567 11.3942 4.02084C10.9521 3.57546 10.4284 3.27396 9.86732 3.11294C9.18041 2.9108 8.4425 2.92793 7.75899 3.15748C7.25231 3.32535 6.77624 3.61657 6.37497 4.02084C5.95331 4.44567 5.66086 4.9493 5.49764 5.48376C5.28 6.17239 5.28 6.91927 5.49424 7.6079C5.65746 8.14579 5.95331 8.65284 6.37497 9.07767C6.79664 9.5025 7.25231 9.77316 7.75899 9.94103C8.4425 10.1706 9.18041 10.1877 9.86732 9.98557C10.4284 9.82455 10.9521 9.52306 11.3942 9.07767C11.8362 8.63229 12.1117 8.14579 12.2749 7.6079C12.4891 6.91927 12.4891 6.17239 12.2715 5.48376ZM10.3774 7.59077C10.3774 7.59077 10.3876 7.60105 10.391 7.6079C10.5032 7.73467 10.4964 7.92995 10.3774 8.05329C10.2516 8.18005 10.0441 8.18005 9.91833 8.05329L9.86732 8.0019L8.88457 7.01177L7.8508 8.05329C7.8236 8.0807 7.793 8.10468 7.75899 8.11838C7.63997 8.1732 7.49375 8.15264 7.39173 8.05329C7.27271 7.92995 7.26591 7.73467 7.37813 7.6079C7.38153 7.60105 7.38493 7.59762 7.39173 7.59077L8.42549 6.54926L7.39173 5.50774C7.39173 5.50774 7.37813 5.49404 7.37133 5.48376C7.26591 5.357 7.27271 5.16514 7.39173 5.04523C7.49375 4.94587 7.63997 4.92531 7.75899 4.98013C7.793 4.99384 7.8236 5.01782 7.8508 5.04523L8.88457 6.08674L9.86732 5.09662L9.91833 5.04523C10.0441 4.91846 10.2516 4.91846 10.3774 5.04523C10.4964 5.16514 10.5032 5.357 10.3978 5.48376C10.391 5.49404 10.3842 5.50089 10.3774 5.50774L9.34364 6.54926L10.3774 7.59077Z" fill="#454545"/>\n</svg>',color:'<svg xmlns="http://www.w3.org/2000/svg" width="13" height="14" viewBox="0 0 13 14" fill="none">\n <g clip-path="url(#clip0_26_733)">\n <path d="M7.55292 1.73122C7.43003 1.4071 7.11626 1.19189 6.76851 1.19189C6.42076 1.19189 6.107 1.4071 5.98411 1.73122L2.42291 11.1486H1.74832C1.28552 11.1486 0.911621 11.5194 0.911621 11.9783C0.911621 12.4373 1.28552 12.8081 1.74832 12.8081H4.25842C4.72121 12.8081 5.09511 12.4373 5.09511 11.9783C5.09511 11.5194 4.72121 11.1486 4.25842 11.1486H4.21135L4.68199 9.90402H8.85503L9.32567 11.1486H9.27861C8.81581 11.1486 8.44191 11.5194 8.44191 11.9783C8.44191 12.4373 8.81581 12.8081 9.27861 12.8081H11.7887C12.2515 12.8081 12.6254 12.4373 12.6254 11.9783C12.6254 11.5194 12.2515 11.1486 11.7887 11.1486H11.1141L7.55292 1.73122ZM8.2275 8.24457H5.30952L6.76851 4.38375L8.2275 8.24457Z" fill="#454545"/>\n </g>\n <defs>\n <clipPath id="clip0_26_733">\n <rect width="11.7138" height="13.2756" fill="white" transform="translate(0.911621 0.362183)"/>\n </clipPath>\n </defs>\n</svg>',background:'<svg xmlns="http://www.w3.org/2000/svg" width="15" height="14" viewBox="0 0 15 14" fill="none">\n <g clip-path="url(#clip0_3_40)">\n <path d="M1.08399 0.605877C1.40598 0.281765 1.92632 0.281765 2.24831 0.605877L4.34514 2.7139L5.71296 1.33707C6.4368 0.60847 7.61144 0.60847 8.33528 1.33707L12.2353 5.26531C12.9591 5.99391 12.9591 7.17627 12.2353 7.90487L7.33066 12.8443C6.36468 13.8167 4.7985 13.8167 3.83252 12.8443L0.805784 9.79769C-0.160196 8.82535 -0.160196 7.24887 0.805784 6.27654L3.17823 3.88848L1.08399 1.77786C0.761993 1.45375 0.761993 0.927396 1.08399 0.603284V0.605877ZM5.61765 6.34395L4.34514 5.06306L1.97269 7.45112C1.8645 7.56002 1.79237 7.69226 1.75631 7.82968H9.97873L11.0684 6.73289C11.1482 6.65251 11.1482 6.52027 11.0684 6.43989L7.17095 2.51165C7.09109 2.43127 6.95972 2.43127 6.87987 2.51165L5.51204 3.88848L6.78456 5.16937C7.10655 5.49348 7.10655 6.01984 6.78456 6.34395C6.46256 6.66806 5.93965 6.66806 5.61765 6.34395ZM13.2064 13.6378C12.2971 13.6378 11.5578 12.8936 11.5578 11.9783C11.5578 11.3249 12.3975 9.91437 12.8767 9.15983C13.0312 8.9161 13.379 8.9161 13.5335 9.15983C14.0152 9.91437 14.855 11.3249 14.855 11.9783C14.855 12.8936 14.1157 13.6378 13.2064 13.6378Z" fill="#454545"/>\n </g>\n <defs>\n <clipPath id="clip0_3_40">\n <rect width="14.8375" height="13.2756" fill="white" transform="translate(0.0175781 0.362183)"/>\n </clipPath>\n </defs>\n</svg>',"no-color":'<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">\n <line x1="1.24715" y1="6.41398" x2="21.5343" y2="18.1268" stroke="#EA6666" stroke-width="0.842105"/>\n <circle cx="11.7127" cy="11.7128" r="11.2918" transform="rotate(90 11.7127 11.7128)" stroke="#D7D7D7" stroke-width="0.842105"/>\n</svg> ',"custom-color":'<svg xmlns="http://www.w3.org/2000/svg" width="17" height="16" viewBox="0 0 17 16" fill="none">\n <g clip-path="url(#clip0_6_132)">\n <path d="M16.07 7.7128C16.07 7.73944 16.07 7.76609 16.07 7.79273C16.0582 8.87332 15.0753 9.60753 13.9947 9.60753H11.0963C10.3118 9.60753 9.67527 10.244 9.67527 11.0286C9.67527 11.1292 9.68711 11.2269 9.70487 11.3217C9.76704 11.6237 9.89731 11.9138 10.0246 12.2069C10.2052 12.6154 10.3828 13.021 10.3828 13.4503C10.3828 14.3917 9.74336 15.2473 8.80191 15.2858C8.69829 15.2888 8.59468 15.2917 8.4881 15.2917C4.30487 15.2917 0.912109 11.899 0.912109 7.7128C0.912109 3.52661 4.30487 0.13385 8.49106 0.13385C12.6772 0.13385 16.07 3.52661 16.07 7.7128ZM4.70158 8.66017C4.70158 8.40891 4.60177 8.16794 4.42411 7.99028C4.24644 7.81261 4.00547 7.7128 3.75421 7.7128C3.50296 7.7128 3.26199 7.81261 3.08432 7.99028C2.90666 8.16794 2.80685 8.40891 2.80685 8.66017C2.80685 8.91142 2.90666 9.15239 3.08432 9.33006C3.26199 9.50772 3.50296 9.60753 3.75421 9.60753C4.00547 9.60753 4.24644 9.50772 4.42411 9.33006C4.60177 9.15239 4.70158 8.91142 4.70158 8.66017ZM4.70158 5.81806C4.95284 5.81806 5.19381 5.71825 5.37147 5.54058C5.54914 5.36292 5.64895 5.12195 5.64895 4.87069C5.64895 4.61943 5.54914 4.37847 5.37147 4.2008C5.19381 4.02314 4.95284 3.92332 4.70158 3.92332C4.45033 3.92332 4.20936 4.02314 4.03169 4.2008C3.85403 4.37847 3.75421 4.61943 3.75421 4.87069C3.75421 5.12195 3.85403 5.36292 4.03169 5.54058C4.20936 5.71825 4.45033 5.81806 4.70158 5.81806ZM9.43843 2.97596C9.43843 2.7247 9.33861 2.48373 9.16095 2.30606C8.98328 2.1284 8.74231 2.02859 8.49106 2.02859C8.2398 2.02859 7.99883 2.1284 7.82117 2.30606C7.6435 2.48373 7.54369 2.7247 7.54369 2.97596C7.54369 3.22721 7.6435 3.46818 7.82117 3.64585C7.99883 3.82351 8.2398 3.92332 8.49106 3.92332C8.74231 3.92332 8.98328 3.82351 9.16095 3.64585C9.33861 3.46818 9.43843 3.22721 9.43843 2.97596ZM12.2805 5.81806C12.5318 5.81806 12.7728 5.71825 12.9504 5.54058C13.1281 5.36292 13.2279 5.12195 13.2279 4.87069C13.2279 4.61943 13.1281 4.37847 12.9504 4.2008C12.7728 4.02314 12.5318 3.92332 12.2805 3.92332C12.0293 3.92332 11.7883 4.02314 11.6106 4.2008C11.433 4.37847 11.3332 4.61943 11.3332 4.87069C11.3332 5.12195 11.433 5.36292 11.6106 5.54058C11.7883 5.71825 12.0293 5.81806 12.2805 5.81806Z" fill="#454545"/>\n </g>\n <defs>\n <clipPath id="clip0_6_132">\n <rect width="15.1579" height="15.1579" fill="white" transform="translate(0.912109 0.13385)"/>\n </clipPath>\n </defs>\n</svg>',undo:'\x3c!-- Undo icon SVG - to be filled by user --\x3e \n<svg xmlns="http://www.w3.org/2000/svg" width="15" height="14" viewBox="0 0 15 14" fill="none">\n <path d="M1.95166 6.12501H1.71924C1.35557 6.12501 1.06299 5.83243 1.06299 5.46876V1.96876C1.06299 1.70353 1.22158 1.4629 1.46768 1.36173C1.71377 1.26056 1.99541 1.31525 2.18408 1.50392L3.32158 2.64142C5.7169 0.276185 9.5751 0.284388 11.9567 2.66876C14.3493 5.06134 14.3493 8.93869 11.9567 11.3313C9.56416 13.7238 5.68682 13.7238 3.29424 11.3313C2.95244 10.9895 2.95244 10.4344 3.29424 10.0926C3.63604 9.7508 4.19111 9.7508 4.53291 10.0926C6.2419 11.8016 9.01182 11.8016 10.7208 10.0926C12.4298 8.38361 12.4298 5.61369 10.7208 3.9047C9.02002 2.20392 6.27197 2.19572 4.56025 3.87736L5.68408 5.00392C5.87275 5.19259 5.92744 5.47423 5.82627 5.72033C5.7251 5.96642 5.48447 6.12501 5.21924 6.12501H1.95166Z" fill="#454545"/>\n</svg>',redo:'\x3c!-- Redo icon SVG - to be filled by user --\x3e \n<svg xmlns="http://www.w3.org/2000/svg" width="15" height="14" viewBox="0 0 15 14" fill="none">\n <g clip-path="url(#clip0_26_755)">\n <path d="M11.1883 4.37501H9.81294C9.32896 4.37501 8.93794 4.76603 8.93794 5.25001C8.93794 5.734 9.32896 6.12501 9.81294 6.12501H13.3129C13.7969 6.12501 14.1879 5.734 14.1879 5.25001V1.75001C14.1879 1.26603 13.7969 0.875012 13.3129 0.875012C12.829 0.875012 12.4379 1.26603 12.4379 1.75001V3.15001L11.9567 2.66876C9.56411 0.276184 5.68677 0.276184 3.29419 2.66876C0.901611 5.06134 0.901611 8.93868 3.29419 11.3313C5.68677 13.7238 9.56411 13.7238 11.9567 11.3313C12.2985 10.9895 12.2985 10.4344 11.9567 10.0926C11.6149 9.75079 11.0598 9.75079 10.718 10.0926C9.00903 11.8016 6.23911 11.8016 4.53013 10.0926C2.82114 8.38361 2.82114 5.61368 4.53013 3.9047C6.23911 2.19572 9.00903 2.19572 10.718 3.9047L11.1883 4.37501Z" fill="#454545"/>\n </g>\n <defs>\n <clipPath id="clip0_26_755">\n <rect width="14" height="14" fill="white" transform="translate(0.625488)"/>\n </clipPath>\n </defs>\n</svg>',link:'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="12" viewBox="0 0 16 12" fill="none">\n <path d="M14.5737 6.29853C15.9761 4.85693 15.9761 2.5223 14.5737 1.0807C13.3327 -0.195058 11.3769 -0.360906 9.94976 0.687763L9.91005 0.71583C9.55264 0.978635 9.47074 1.48894 9.72638 1.8538C9.98203 2.21867 10.4784 2.30542 10.8334 2.04261L10.8731 2.01455C11.6698 1.43025 12.7594 1.52211 13.4494 2.23398C14.2312 3.0377 14.2312 4.33897 13.4494 5.14269L10.6646 8.01059C9.88275 8.81431 8.61693 8.81431 7.83509 8.01059C7.14261 7.29872 7.05326 6.17861 7.62164 5.36212L7.64894 5.3213C7.90459 4.95388 7.8202 4.44358 7.46527 4.18333C7.11035 3.92307 6.61147 4.00727 6.3583 4.37214L6.331 4.41296C5.30841 5.87753 5.46974 7.88811 6.71075 9.16387C8.11308 10.6055 10.3841 10.6055 11.7864 9.16387L14.5737 6.29853ZM1.67724 5.70147C0.274905 7.14307 0.274905 9.4777 1.67724 10.9193C2.91824 12.1951 4.87406 12.3609 6.30121 11.3122L6.34093 11.2842C6.69834 11.0214 6.78024 10.5111 6.5246 10.1462C6.26895 9.78133 5.77255 9.69458 5.41762 9.95739L5.37791 9.98545C4.58118 10.5697 3.49158 10.4779 2.80159 9.76602C2.01976 8.95975 2.01976 7.65848 2.80159 6.85475L5.5864 3.98941C6.36823 3.18569 7.63405 3.18569 8.41588 3.98941C9.10836 4.70128 9.19771 5.82139 8.62934 6.64043L8.60203 6.68125C8.34639 7.04867 8.43078 7.55897 8.7857 7.81922C9.14063 8.07948 9.63951 7.99528 9.89268 7.63041L9.91998 7.58959C10.9426 6.12247 10.7812 4.11189 9.54023 2.83613C8.1379 1.39453 5.86686 1.39453 4.46453 2.83613L1.67724 5.70147Z" fill="#454545"/>\n</svg>',emoji:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">\x3c!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--\x3e<path d="M464 256A208 208 0 1 0 48 256a208 208 0 1 0 416 0zM0 256a256 256 0 1 1 512 0A256 256 0 1 1 0 256zm177.6 62.1C192.8 334.5 218.8 352 256 352s63.2-17.5 78.4-33.9c9-9.7 24.2-10.4 33.9-1.4s10.4 24.2 1.4 33.9c-22 23.8-60 49.4-113.6 49.4s-91.7-25.5-113.6-49.4c-9-9.7-8.4-24.9 1.4-33.9s24.9-8.4 33.9 1.4zM144.4 208a32 32 0 1 1 64 0 32 32 0 1 1 -64 0zm192-32a32 32 0 1 1 0 64 32 32 0 1 1 0-64z"/></svg>',tag:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512">\x3c!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--\x3e<path d="M0 80L0 229.5c0 17 6.7 33.3 18.7 45.3l176 176c25 25 65.5 25 90.5 0L418.7 317.3c25-25 25-65.5 0-90.5l-176-176c-12-12-28.3-18.7-45.3-18.7L48 32C21.5 32 0 53.5 0 80zm112 32a32 32 0 1 1 0 64 32 32 0 1 1 0-64z"/></svg>',import:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">\x3c!--!Font Awesome Free 6.7.2 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free Copyright 2025 Fonticons, Inc.--\x3e<path d="M128 64c0-35.3 28.7-64 64-64L352 0l0 128c0 17.7 14.3 32 32 32l128 0 0 288c0 35.3-28.7 64-64 64l-256 0c-35.3 0-64-28.7-64-64l0-112 174.1 0-39 39c-9.4 9.4-9.4 24.6 0 33.9s24.6 9.4 33.9 0l80-80c9.4-9.4 9.4-24.6 0-33.9l-80-80c-9.4-9.4-24.6-9.4-33.9 0s-9.4 24.6 0 33.9l39 39L128 288l0-224zm0 224l0 48L24 336c-13.3 0-24-10.7-24-24s10.7-24 24-24l104 0zM512 128l-128 0L384 0 512 128z"/></svg>',code:'<svg xmlns="http://www.w3.org/2000/svg" width="18" height="14" viewBox="0 0 18 14" fill="none">\n <g clip-path="url(#clip0_131_130)">\n <path d="M10.6186 0.421434C10.1623 0.294382 9.68715 0.551079 9.55561 0.991871L6.11957 12.608C5.98803 13.0488 6.25379 13.5078 6.71014 13.6348C7.16649 13.7619 7.64163 13.5052 7.77316 13.0644L11.2092 1.44822C11.3407 1.00743 11.075 0.548486 10.6186 0.421434ZM12.7823 3.5355C12.4467 3.85961 12.4467 4.38597 12.7823 4.71008L15.1794 7.02813L12.7796 9.34618C12.444 9.67029 12.444 10.1966 12.7796 10.5208C13.1151 10.8449 13.6601 10.8449 13.9956 10.5208L17.0022 7.61672C17.3377 7.2926 17.3377 6.76625 17.0022 6.44213L13.9956 3.53809C13.6601 3.21398 13.1151 3.21398 12.7796 3.53809L12.7823 3.5355ZM4.54919 3.5355C4.21364 3.21139 3.6687 3.21139 3.33315 3.5355L0.326614 6.43954C-0.00893658 6.76365 -0.00893658 7.29001 0.326614 7.61412L3.33315 10.5182C3.6687 10.8423 4.21364 10.8423 4.54919 10.5182C4.88474 10.1941 4.88474 9.66769 4.54919 9.34358L2.14933 7.02813L4.54919 4.71008C4.88474 4.38597 4.88474 3.85961 4.54919 3.5355Z" fill="#454545"/>\n </g>\n <defs>\n <clipPath id="clip0_131_130">\n <rect width="17.1802" height="13.2756" fill="white" transform="translate(0.0742188 0.390442)"/>\n </clipPath>\n </defs>\n</svg>',"code-view":'<svg xmlns="http://www.w3.org/2000/svg" width="18" height="14" viewBox="0 0 18 14" fill="none">\n <g clip-path="url(#clip0_131_130)">\n <path d="M10.6186 0.421434C10.1623 0.294382 9.68715 0.551079 9.55561 0.991871L6.11957 12.608C5.98803 13.0488 6.25379 13.5078 6.71014 13.6348C7.16649 13.7619 7.64163 13.5052 7.77316 13.0644L11.2092 1.44822C11.3407 1.00743 11.075 0.548486 10.6186 0.421434ZM12.7823 3.5355C12.4467 3.85961 12.4467 4.38597 12.7823 4.71008L15.1794 7.02813L12.7796 9.34618C12.444 9.67029 12.444 10.1966 12.7796 10.5208C13.1151 10.8449 13.6601 10.8449 13.9956 10.5208L17.0022 7.61672C17.3377 7.2926 17.3377 6.76625 17.0022 6.44213L13.9956 3.53809C13.6601 3.21398 13.1151 3.21398 12.7796 3.53809L12.7823 3.5355ZM4.54919 3.5355C4.21364 3.21139 3.6687 3.21139 3.33315 3.5355L0.326614 6.43954C-0.00893658 6.76365 -0.00893658 7.29001 0.326614 7.61412L3.33315 10.5182C3.6687 10.8423 4.21364 10.8423 4.54919 10.5182C4.88474 10.1941 4.88474 9.66769 4.54919 9.34358L2.14933 7.02813L4.54919 4.71008C4.88474 4.38597 4.88474 3.85961 4.54919 3.5355Z" fill="#454545"/>\n </g>\n <defs>\n <clipPath id="clip0_131_130">\n <rect width="17.1802" height="13.2756" fill="white" transform="translate(0.0742188 0.390442)"/>\n </clipPath>\n </defs>\n</svg>',check:'<svg xmlns="http://www.w3.org/2000/svg" width="10" height="11" viewBox="0 0 10 11" fill="none">\n <g clip-path="url(#clip0_4_79)">\n <path d="M9.68012 2.27338C9.93724 2.52649 9.93724 2.93753 9.68012 3.19063L4.41429 8.37417C4.15717 8.62728 3.73961 8.62728 3.48249 8.37417L0.849578 5.7824C0.592458 5.5293 0.592458 5.11826 0.849578 4.86516C1.1067 4.61205 1.52426 4.61205 1.78138 4.86516L3.94942 6.99729L8.75037 2.27338C9.00749 2.02028 9.42505 2.02028 9.68217 2.27338H9.68012Z" fill="currentColor"/>\n </g>\n <defs>\n <clipPath id="clip0_4_79">\n <rect width="9.21519" height="10.3671" fill="white" transform="translate(0.658203 0.139252)"/>\n </clipPath>\n </defs>\n</svg> ',dropdown:'<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 8 7" fill="none">\n <g clip-path="url(#clip0_4_66)">\n <path d="M3.81655 5.55897C3.98745 5.72987 4.26499 5.72987 4.43589 5.55897L7.06089 2.93397C7.23179 2.76307 7.23179 2.48553 7.06089 2.31464C6.88999 2.14374 6.61245 2.14374 6.44155 2.31464L4.12554 4.63065L1.80952 2.316C1.63862 2.1451 1.36108 2.1451 1.19019 2.316C1.01929 2.4869 1.01929 2.76444 1.19019 2.93534L3.81519 5.56034L3.81655 5.55897Z" fill="#CCCCCC"/>\n </g>\n <defs>\n <clipPath id="clip0_4_66">\n <rect width="12" height="12" fill="white" transform="translate(0.625488)"/>\n </clipPath>\n </defs>\n</svg> ',more:'\x3c!-- More options icon SVG - to be filled by user --\x3e \n<svg xmlns="http://www.w3.org/2000/svg" width="15" height="16" viewBox="0 0 15 16" fill="none">\n <g clip-path="url(#clip0_26_758)">\n <path d="M0.875488 8C0.875488 7.53587 1.05986 7.09075 1.38805 6.76256C1.71624 6.43437 2.16136 6.25 2.62549 6.25C3.08962 6.25 3.53474 6.43437 3.86293 6.76256C4.19111 7.09075 4.37549 7.53587 4.37549 8C4.37549 8.46413 4.19111 8.90925 3.86293 9.23744C3.53474 9.56563 3.08962 9.75 2.62549 9.75C2.16136 9.75 1.71624 9.56563 1.38805 9.23744C1.05986 8.90925 0.875488 8.46413 0.875488 8ZM5.87549 8C5.87549 7.53587 6.05986 7.09075 6.38805 6.76256C6.71624 6.43437 7.16136 6.25 7.62549 6.25C8.08962 6.25 8.53474 6.43437 8.86293 6.76256C9.19111 7.09075 9.37549 7.53587 9.37549 8C9.37549 8.46413 9.19111 8.90925 8.86293 9.23744C8.53474 9.56563 8.08962 9.75 7.62549 9.75C7.16136 9.75 6.71624 9.56563 6.38805 9.23744C6.05986 8.90925 5.87549 8.46413 5.87549 8ZM12.6255 6.25C13.0896 6.25 13.5347 6.43437 13.8629 6.76256C14.1911 7.09075 14.3755 7.53587 14.3755 8C14.3755 8.46413 14.1911 8.90925 13.8629 9.23744C13.5347 9.56563 13.0896 9.75 12.6255 9.75C12.1614 9.75 11.7162 9.56563 11.3881 9.23744C11.0599 8.90925 10.8755 8.46413 10.8755 8C10.8755 7.53587 11.0599 7.09075 11.3881 6.76256C11.7162 6.43437 12.1614 6.25 12.6255 6.25Z" fill="#454545"/>\n </g>\n <defs>\n <clipPath id="clip0_26_758">\n <rect width="14" height="16" fill="white" transform="translate(0.625488)"/>\n </clipPath>\n </defs>\n</svg>',theme:'<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" fill="none">\n <circle cx="8" cy="8" r="3" stroke="#454545" stroke-width="1.5" fill="none"/>\n <path d="M8 1V2M8 14V15M15 8H14M2 8H1M12.5 3.5L11.8 4.2M4.2 11.8L3.5 12.5M12.5 12.5L11.8 11.8M4.2 4.2L3.5 3.5" stroke="#454545" stroke-width="1.5" stroke-linecap="round"/>\n</svg> ',heading:'<svg xmlns="http://www.w3.org/2000/svg" width="12" height="14" viewBox="0 0 12 14" fill="none">\n <g clip-path="url(#clip0_17_399)">\n <path d="M6.89569 1.75949C6.7728 1.43538 6.45904 1.22017 6.11129 1.22017C5.76353 1.22017 5.44977 1.43538 5.32688 1.75949L1.76568 11.1769H1.09109C0.628294 11.1769 0.254395 11.5477 0.254395 12.0066C0.254395 12.4656 0.628294 12.8363 1.09109 12.8363H3.60119C4.06399 12.8363 4.43789 12.4656 4.43789 12.0066C4.43789 11.5477 4.06399 11.1769 3.60119 11.1769H3.55412L4.02477 9.93229H8.1978L8.66844 11.1769H8.62138C8.15858 11.1769 7.78468 11.5477 7.78468 12.0066C7.78468 12.4656 8.15858 12.8363 8.62138 12.8363H11.1315C11.5943 12.8363 11.9682 12.4656 11.9682 12.0066C11.9682 11.5477 11.5943 11.1769 11.1315 11.1769H10.4569L6.89569 1.75949ZM7.57028 8.27284H4.65229L6.11129 4.41202L7.57028 8.27284Z" fill="#454545"/>\n </g>\n <defs>\n <clipPath id="clip0_17_399">\n <rect width="11.7138" height="13.2756" fill="white" transform="translate(0.254395 0.390457)"/>\n </clipPath>\n </defs>\n</svg>',"font-family":'<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">\n <path d="M2 2h12v2H2V2zm0 4h8v2H2V6zm0 4h10v2H2v-2zm0 4h6v2H2v-2z" fill="currentColor"/>\n <path d="M4 4h8v1H4V4zm0 2h6v1H4V6zm0 2h8v1H4V8z" fill="currentColor"/>\n </svg>',"line-height":'<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">\n <path d="M2 2h12v2H2V2zm0 4h12v2H2V6zm0 4h12v2H2v-2zm0 4h12v2H2v-2z" fill="currentColor"/>\n <path d="M4 3h8v1H4V3zm0 2h8v1H4V5zm0 2h8v1H4V7zm0 2h8v1H4V9z" fill="currentColor"/>\n </svg>',capitalization:'<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">\n <path d="M2 2h12v2H2V2zm0 4h8v2H2V6zm0 4h10v2H2v-2zm0 4h6v2H2v-2z" fill="currentColor"/>\n <path d="M4 4h8v1H4V4zm0 2h6v1H4V6zm0 2h8v1H4V8z" fill="currentColor"/>\n </svg>',"text-size":'<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">\n <path d="M2 2h12v2H2V2zm0 4h8v2H2V6zm0 4h10v2H2v-2zm0 4h6v2H2v-2z" fill="currentColor"/>\n <path d="M4 4h8v1H4V4zm0 2h6v1H4V6zm0 2h8v1H4V8z" fill="currentColor"/>\n </svg>'};class m{static getIcon(t){return p[t]||""}static createIconElement(t,e={}){const n=document.createElement("span");return n.className=`icon icon-${t}`,n.style.display="inline-block",n.style.width=e.width||"16px",n.style.height=e.height||"16px",n.style.verticalAlign="middle",n.innerHTML=this.getIcon(t),n}static hasIcon(t){return t in p}static getIconNames(){return Object.keys(p)}}function g(t=null){let e;return e=t?n.getInstanceById(t):n.getCurrentInstance(),e?e.getPopupContainer():document.body}function C(t,e=null){const n=g(e);t.parentNode&&t.parentNode.removeChild(t),n.appendChild(t)}function f(t){if(!t)return{width:300,height:200};const e=t.getBoundingClientRect();if(e.width>0&&e.height>0)return{width:e.width,height:e.height};if(t.offsetWidth>0&&t.offsetHeight>0)return{width:t.offsetWidth,height:t.offsetHeight};const n=window.getComputedStyle(t);if("none"===n.display||"hidden"===n.visibility){const e=t.style.display,n=t.style.visibility,i=t.style.position,s=t.style.top,o=t.style.left,r=t.style.zIndex;t.style.display="block",t.style.visibility="visible",t.style.position="absolute",t.style.top="-9999px",t.style.left="-9999px",t.style.zIndex="-1",t.offsetHeight;const l=t.getBoundingClientRect(),a=l.width>0?l.width:300,c=l.height>0?l.height:200;return t.style.display=e,t.style.visibility=n,t.style.position=i,t.style.top=s,t.style.left=o,t.style.zIndex=r,{width:a,height:c}}const i=parseInt(n.width),s=parseInt(n.height);return{width:i>0?i:300,height:s>0?s:200}}function b(t,e,n={}){const{offsetX:i=0,offsetY:s=5,preferTop:o=!1,preferLeft:r=!1}=n,l=t.getBoundingClientRect(),a=g();let c,d;if(a.classList.contains("rich-editor-popup-container")){const t=a.getBoundingClientRect();c=l.top-t.top+l.height+s,d=l.left-t.left+i;const{width:n,height:h}=f(e);if(c+h>t.height&&!o){const e=l.top-t.top-h-s;c=e>=0?e:Math.max(s,(t.height-h)/2)}d+n+5>t.width&&!r&&(d=t.width-n-i-15),d<0&&(d=i),c<0&&(c=s)}else{c=l.bottom+window.scrollY+s,d=l.left+window.scrollX+i;const{width:t,height:n}=f(e);if(d+t>window.innerWidth&&!r&&(d=window.innerWidth-t-i),c+n>window.innerHeight+window.scrollY&&!o){const t=l.top+window.scrollY-n-s;c=t>=window.scrollY?t:Math.max(window.scrollY+s,window.scrollY+(window.innerHeight-n)/2)}d<0&&(d=i),c<0&&(c=s)}return{top:c,left:d}}function y(t,e){t.style.position="absolute",t.style.top=`${e.top}px`,t.style.left=`${e.left}px`,t.style.zIndex="1000"}class v{constructor(t={}){this.options={colors:["#000000","#333333","#666666","#999999","#cccccc","#eeeeee","#ff0000","#ff6600","#ffcc00","#ffff00","#99ff00","#00ff00","#00ffcc","#00ccff","#0066ff","#0000ff","#6600ff","#cc00ff","#ff00cc","#ff0066","#800000","#ff8000","#808000","#008000","#008080","#0080ff","#004080","#800080","#804080","#ff0080"],customColorEnabled:!0,onColorSelect:null,editor:null,...t},this.popup=null,this.isVisible=!1,this.currentColor="#000000",this.clickOutsideHandler=null,this.createColorPicker()}createColorPicker(){this.popup=document.createElement("div"),this.popup.className="color-picker-popup",this.createColorGrid(),this.options.customColorEnabled&&this.createCustomColorInput(),C(this.popup),this.options.editor&&"function"==typeof this.options.editor.preventFocusLoss&&this.options.editor.preventFocusLoss(this.popup)}createColorGrid(){const t=document.createElement("div");t.className="color-grid",this.options.colors.forEach(e=>{const n=document.createElement("button");n.type="button",n.className="color-button",n.style.backgroundColor=e,n.dataset.color=e,n.title=e,n.addEventListener("click",t=>{t.preventDefault(),t.stopPropagation(),this.selectColor(e),this.options.editor&&setTimeout(()=>this.options.editor.focus(),0)}),t.appendChild(n)}),this.popup.appendChild(t)}createCustomColorInput(){const t=document.createElement("div");t.className="custom-color-container";const e=document.createElement("button");e.type="button",e.className="color-button no-color-button",e.title="No Color",e.style.backgroundColor="transparent";const n=m.createIconElement("no-color",{width:"24",height:"24"});e.appendChild(n),e.addEventListener("click",t=>{t.preventDefault(),t.stopPropagation(),this.selectColor("transparent"),this.options.editor&&setTimeout(()=>this.options.editor.focus(),0)});const i=document.createElement("button");i.type="button",i.className="color-button white-button",i.style.backgroundColor="#ffffff",i.style.border="1px solid #ccc",i.title="White",i.addEventListener("click",t=>{t.preventDefault(),t.stopPropagation(),this.selectColor("#ffffff"),this.options.editor&&setTimeout(()=>this.options.editor.focus(),0)});const s=document.createElement("button");s.type="button",s.className="color-button black-button",s.style.backgroundColor="#000000",s.title="Black",s.addEventListener("click",t=>{t.preventDefault(),t.stopPropagation(),this.selectColor("#000000"),this.options.editor&&setTimeout(()=>this.options.editor.focus(),0)});const o=document.createElement("button");o.type="button",o.className="color-button custom-color-button",o.title="Custom Color",o.style.backgroundColor="transparent",o.style.border="1px solid #ccc",o.style.font="none !important";const r=m.createIconElement("custom-color",{width:"16px",height:"16px"});o.appendChild(r);const l=document.createElement("input");l.type="color",l.className="custom-color-input",l.value=this.currentColor,l.style.visibility="hidden",l.style.pointerEvents="none",l.style.opacity="0",o.addEventListener("click",t=>{l.style.visibility="visible",l.style.pointerEvents="auto",l.style.opacity="1",t.preventDefault(),t.stopPropagation(),l.click()}),l.addEventListener("change",t=>{l.style.visibility="hidden",l.style.pointerEvents="none",l.style.opacity="0",this.selectColor(t.target.value),this.options.editor&&setTimeout(()=>this.options.editor.focus(),0)}),t.appendChild(e),t.appendChild(i),t.appendChild(s),t.appendChild(o),t.appendChild(l),this.popup.appendChild(t)}setupClickOutside(){this.clickOutsideHandler&&document.removeEventListener("click",this.clickOutsideHandler),this.clickOutsideHandler=t=>{this.popup.contains(t.target)||this.hide()},setTimeout(()=>{document.addEventListener("click",this.clickOutsideHandler)},100)}removeClickOutside(){this.clickOutsideHandler&&(document.removeEventListener("click",this.clickOutsideHandler),this.clickOutsideHandler=null)}show(t){if(!t)return;document.body.contains(this.popup)||C(this.popup);const e=b(t,this.popup,{offsetY:5,offsetX:0});y(this.popup,e),this.popup.classList.add("visible"),this.isVisible=!0,this.setupClickOutside()}hide(){this.popup.classList.remove("visible"),this.isVisible=!1,this.removeClickOutside()}selectColor(t){this.currentColor=t,this.options.onColorSelect&&this.options.onColorSelect(t),this.hide()}destroy(){this.removeClickOutside(),this.popup&&this.popup.parentNode&&this.popup.parentNode.removeChild(this.popup)}}class w extends s{static formatName="color";static tagName="SPAN";static attribute="color";constructor(){super();const t=n.getCurrentInstance();if(!t)return;this.editorId=t.instanceId;let e=t.getPopupInstance("color");e||(e=new v({onColorSelect:t=>{w.applyColorToCurrentSelection(t)},editor:n.getCurrentInstance()}),t.setPopupInstance("color",e)),this.colorPicker=e}static applyColorToCurrentSelection(t){const e=window.getSelection();if(!e||!e.rangeCount||e.isCollapsed)return;r();const i=document.querySelector(".rich-editor-toolbar-btn.color-btn");try{document.execCommand("styleWithCSS",!1,!0),"transparent"===t?(document.execCommand("foreColor",!1,"#2c3e50"),i.classList.remove("active")):(document.execCommand("foreColor",!1,t),i.classList.add("active"))}catch(t){}setTimeout(()=>{const t=n.getCurrentInstance();t&&"function"==typeof t.onContentChange&&t.onContentChange()},0)}toggle(){this.colorPicker.isVisible?this.colorPicker.hide():this.showColorPicker()}showColorPicker(){const t=n.getInstanceById(this.editorId);if(!t)return;const e=t.getModule("toolbar");let i=null;if(e&&(i=e.getButton("color")),!i){const t=e?.getContainer();t&&(i=t.querySelector(".rich-editor-toolbar-btn.color-btn"))}i||(i=t.wrapper.querySelector(".rich-editor-toolbar-btn.color-btn")),i&&this.colorPicker.show(i)}isActive(){const t=window.getSelection();if(!t||!t.rangeCount)return!1;let e=t.getRangeAt(0).startContainer;for(e.nodeType===Node.TEXT_NODE&&(e=e.parentNode);e&&e!==document.body;){if(e.nodeType===Node.ELEMENT_NODE){const t=window.getComputedStyle(e).color;if("rgb(44, 62, 80)"===t)return!1;if(t&&"rgba(0, 0, 0, 0)"!==t)return!0}e=e.parentNode}return!1}}class E extends s{static formatName="background";static tagName="SPAN";static attribute="background-color";constructor(){super();const t=n.getCurrentInstance();if(!t)return;this.editorId=t.instanceId;let e=t.getPopupInstance("background");e||(e=new v({onColorSelect:t=>{E.applyBackgroundToCurrentSelection(t,this.editorId)},editor:t,editorId:this.editorId}),t.setPopupInstance("background",e)),this.colorPicker=e}static createForEditor(t){const e=n.getInstanceById(t);if(!e)return null;const i=n.currentInstance;n.currentInstance=e;const s=new E;return n.currentInstance=i,s}static applyBackgroundToCurrentSelection(t,e=null){let i=null;if(i=e?n.getInstanceById(e):n.getCurrentInstance(),!i)return;const s=window.getSelection();if(!s||!s.rangeCount||s.isCollapsed)return;r();const o=i.getModule("toolbar");let l=null;if(o&&(l=o.getButton("background")),!l){const t=o?.getContainer();t&&(l=t.querySelector(".rich-editor-toolbar-btn.background-btn"))}l||(l=i.wrapper.querySelector(".rich-editor-toolbar-btn.background-btn"));try{document.execCommand("styleWithCSS",!1,!0),document.execCommand("backColor",!1,t),l&&l.classList.add("active")}catch(t){}setTimeout(()=>{i&&"function"==typeof i.onContentChange&&i.onContentChange()},0)}toggle(){this.colorPicker.isVisible?this.colorPicker.hide():this.showColorPicker()}showColorPicker(){const t=n.getInstanceById(this.editorId);if(!t)return;const e=t.getModule("toolbar");let i=null;if(e&&(i=e.getButton("background")),!i){const t=e?.getContainer();t&&(i=t.querySelector(".rich-editor-toolbar-btn.background-btn"))}i||(i=t.wrapper.querySelector(".rich-editor-toolbar-btn.background-btn")),i&&this.colorPicker.show(i)}isActive(){const t=window.getSelection();if(!t||!t.rangeCount)return!1;let e=t.getRangeAt(0).startContainer;for(e.nodeType===Node.TEXT_NODE&&(e=e.parentNode);e&&e!==document.body;){if(e.nodeType===Node.ELEMENT_NODE){const t=window.getComputedStyle(e).backgroundColor;if(t&&"rgba(0, 0, 0, 0)"!=t&&"transparent"!==t&&t&&"rgb(255, 255, 255)"!=t&&"transparent"!==t)return!0}e=e.parentNode}return!1}}class T{constructor(t={}){this.options={onLinkSelect:null,editor:null,...t},this.popup=null,this.isVisible=!1,this.urlInput=null,this.textInput=null,this.createPopup()}createPopup(){this.popup=document.createElement("div"),this.popup.className="link-popup";const t=document.createElement("div");t.className="link-popup-content";const e=document.createElement("h2");e.textContent="Upload link",e.className="yjd-input-title";const n=document.createElement("div");n.className="yjd-input-group";const i=document.createElement("p");i.textContent="Your URL",i.className="yjd-input-label",this.urlInput=document.createElement("input"),this.urlInput.type="url",this.urlInput.className="yjd-input",this.urlInput.placeholder="Please enter your URL",n.appendChild(i),n.appendChild(this.urlInput);const s=document.createElement("div");s.className="yjd-input-group";const o=document.createElement("p");o.textContent="Your display text",o.className="yjd-input-label",this.textInput=document.createElement("input"),this.textInput.type="text",this.textInput.className="yjd-input",this.textInput.placeholder="Please enter display text",s.appendChild(o),s.appendChild(this.textInput);const r=document.createElement("div");r.className="yjd-button-container";const l=document.createElement("button");l.type="button",l.className="yjd-button-confirm",l.textContent="Add link",l.onclick=()=>{this.handleOk(),this.options.editor&&setTimeout(()=>this.options.editor.focus(),0)};const a=document.createElement("button");a.type="button",a.className="yjd-button-cancel",a.textContent="Cancel",a.onclick=()=>{this.hide(),this.options.editor&&setTimeout(()=>this.options.editor.focus(),0)},this.urlInput.onkeydown=t=>{"Enter"===t.key&&this.handleOk(),"Escape"===t.key&&this.hide()},this.textInput.onkeydown=t=>{"Enter"===t.key&&this.handleOk(),"Escape"===t.key&&this.hide()},r.appendChild(a),r.appendChild(l),t.appendChild(e),t.appendChild(n),t.appendChild(s),t.appendChild(r),this.popup.appendChild(t),C(this.popup),this.options.editor&&"function"==typeof this.options.editor.preventFocusLoss&&this.options.editor.preventFocusLoss(this.popup)}handleOk(){const t=this.urlInput.value.trim();if(!t)return alert("Please enter a URL"),void this.urlInput.focus();try{new URL(t)}catch(t){return alert("Please enter a valid URL"),void this.urlInput.focus()}const e=this.textInput.value.trim();this.options.onLinkSelect&&this.options.onLinkSelect({url:t,text:e}),this.hide()}show(t,e=null,n=""){if(!t)return;this.urlInput.value=e?e.url:"",this.textInput.value=n||(e?e.text:"");const i=b(t,this.popup,{offsetY:5,offsetX:0});y(this.popup,i),this.popup.classList.add("visible"),this.isVisible=!0,setTimeout(()=>this.urlInput.focus(),100),setTimeout(()=>{document.addEventListener("click",this.closeOnClickOutside)},100)}hide(){this.popup.classList.remove("visible"),this.isVisible=!1,document.removeEventListener("click",this.closeOnClickOutside)}closeOnClickOutside=t=>{this.popup.contains(t.target)||this.hide()};destroy(){document.removeEventListener("click",this.closeOnClickOutside),this.popup&&this.popup.parentNode&&this.popup.parentNode.removeChild(this.popup)}}class I extends s{static formatName="link";static tagName="A";static savedRanges=new Map;constructor(){super();const t=n.getCurrentInstance();if(!t)return;this.editorId=t.instanceId;let e=t.getPopupInstance("link");e||(e=new T({onLinkSelect:t=>{I.insertLink(t,this.editorId)},editor:t,editorId:this.editorId}),t.setPopupInstance("link",e)),this.linkPopup=e}static createForEditor(t){const e=n.getInstanceById(t);if(!e)return null;const i=n.currentInstance;n.currentInstance=e;const s=new I;return n.currentInstance=i,s}static insertLink(t,e=null){let i=null;if(i=e?n.getInstanceById(e):n.getCurrentInstance(),!i)return;const s=I.savedRanges.get(e);if(!s)return;const o=window.getSelection();o.removeAllRanges(),o.addRange(s);const r=o.getRangeAt(0);if(r.collapsed){const e=document.createElement("A");e.href=t.url,e.target="_blank",e.rel="noopener noreferrer",e.textContent=t.text||t.url,r.insertNode(e)}else{const e=r.extractContents(),n=document.createElement("A");for(n.href=t.url,n.target="_blank",n.rel="noopener noreferrer";e.firstChild;)n.appendChild(e.firstChild);r.insertNode(n)}const l=document.createRange();l.setStartAfter(r.endContainer),l.collapse(!0),o.removeAllRanges(),o.addRange(l),setTimeout(()=>{i&&"function"==typeof i.onContentChange&&i.onContentChange()},0),I.savedRanges.delete(e),i&&"function"==typeof i.onContentChange&&i.onContentChange()}toggle(){this.linkPopup.isVisible?this.linkPopup.hide():this.showPopup()}showPopup(){const t=window.getSelection();if(t&&t.rangeCount>0){const e=t.getRangeAt(0).cloneRange();I.savedRanges.set(this.editorId,e)}const e=n.getInstanceById(this.editorId);if(!e)return;const i=e.getModule("toolbar");if(!i)return;let s=i.getButton("link");if(!s){const t=i.getContainer();t&&(s=t.querySelector('.rich-editor-toolbar-btn[data-command="link"]'))}if(s||(s=e.wrapper.querySelector('.rich-editor-toolbar-btn[data-command="link"]')),!s)return;const o=this.getCurrentLink();let r="";t&&!t.isCollapsed&&(r=t.toString().trim()),this.linkPopup.show(s,o,r)}getCurrentLink(){const t=window.getSelection();if(!t||!t.rangeCount)return null;let e=t.getRangeAt(0).startContainer;for(;e&&e!==document.body;){if(e.nodeType===Node.ELEMENT_NODE&&"A"===e.tagName)return{url:e.href||"",text:e.textContent||""};e=e.parentNode}return null}isActive(){return null!==this.getCurrentLink()}}class x{constructor(t={}){this.options={maxRows:8,maxCols:8,onTableSelect:null,...t},this.popup=null,this.isVisible=!1,this.selectedRows=1,this.selectedCols=1,this.grid=null,this.sizeDisplay=null,this.createPopup()}createPopup(){this.popup=document.createElement("div"),this.popup.className="table-popup";const t=document.createElement("div");t.className="table-popup-content",this.createSizeDisplay(),this.createGridSelector(),t.appendChild(this.grid),t.appendChild(this.sizeDisplay),this.popup.appendChild(t),C(this.popup)}createSizeDisplay(){this.sizeDisplay=document.createElement("div"),this.sizeDisplay.className="table-size-display"}createGridSelector(){this.grid=document.createElement("div"),this.grid.className="table-grid-selector";for(let t=1;t<=this.options.maxRows;t++)for(let e=1;e<=this.options.maxCols;e++){const n=document.createElement("div");n.className="table-grid-cell",n.dataset.row=t,n.dataset.col=e,n.addEventListener("mouseenter",()=>{this.highlightGrid(t,e)}),n.addEventListener("click",()=>{this.selectSize(t,e),this.handleInsert()}),this.grid.appendChild(n)}this.grid.addEventListener("mouseleave",()=>{this.highlightGrid(1,1)})}highlightGrid(t,e){this.selectedRows=t,this.selectedCols=e,this.updateSizeDisplay(t,e);this.grid.querySelectorAll(".table-grid-cell").forEach(n=>{const i=parseInt(n.dataset.row),s=parseInt(n.dataset.col);i<=t&&s<=e?n.classList.add("highlighted"):n.classList.remove("highlighted")})}updateSizeDisplay(t,e){this.sizeDisplay&&(this.sizeDisplay.textContent=`${t}x${e}`)}selectSize(t,e){this.selectedRows=t,this.selectedCols=e,this.updateSizeDisplay(t,e)}handleInsert(){this.options.onTableSelect&&this.options.onTableSelect({rows:this.selectedRows,cols:this.selectedCols}),this.hide()}show(t){if(!t)return;this.selectedRows=1,this.selectedCols=1,this.highlightGrid(1,1);const e=b(t,this.popup,{offsetY:5,offsetX:0});y(this.popup,e),this.popup.classList.add("visible"),this.isVisible=!0,setTimeout(()=>{document.addEventListener("click",this.closeOnClickOutside)},100)}hide(){this.popup.classList.remove("visible"),this.isVisible=!1,document.removeEventListener("click",this.closeOnClickOutside)}closeOnClickOutside=t=>{this.popup.contains(t.target)||this.hide()};destroy(){document.removeEventListener("click",this.closeOnClickOutside),this.popup&&this.popup.parentNode&&this.popup.parentNode.removeChild(this.popup)}}class L extends o{static formatName="table";static tagName="TABLE";static savedRanges=new Map;constructor(){super();const t=n.getCurrentInstance();if(!t)return;this.editorId=t.instanceId;let e=t.getPopupInstance("table");e||(e=new x({onTableSelect:t=>{L.insertTable(t,this.editorId)},editor:t,editorId:this.editorId}),t.setPopupInstance("table",e)),this.tablePopup=e}static createForEditor(t){const e=n.getInstanceById(t);if(!e)return null;const i=n.currentInstance;n.currentInstance=e;const s=new L;return n.currentInstance=i,s}static insertTable(t,e=null){let i=null;if(i=e?n.getInstanceById(e):n.getCurrentInstance(),!i)return;const s=L.savedRanges.get(e);if(!s)return;const o=window.getSelection();o.removeAllRanges(),o.addRange(s);const r=o.getRangeAt(0),l=L.createTableElement(t.rows,t.cols);r.collapsed||r.deleteContents(),r.insertNode(l);const a=l.querySelector("td");if(a){const t=document.createRange();t.setStart(a,0),t.collapse(!0),o.removeAllRanges(),o.addRange(t)}L.savedRanges.delete(e),i&&"function"==typeof i.onContentChange&&i.onContentChange()}static createTableElement(t,e){const n=document.createElement("table");n.className="rich-editor-table",n.cellSpacing="0",n.cellPadding="0",n.border="1";const i=document.createElement("tbody");for(let n=0;n<t;n++){const t=document.createElement("tr");for(let n=0;n<e;n++){const e=document.createElement("td");e.innerHTML="&nbsp;",e.style.minWidth="50px",e.style.minHeight="24px",e.style.padding="4px 8px",e.style.border="1px solid #ddd",e.style.verticalAlign="top",e.contentEditable="true",t.appendChild(e)}i.appendChild(t)}return n.appendChild(i),n.style.borderCollapse="collapse",n.style.width="100%",n.style.margin="10px 0",n}toggle(){this.tablePopup.isVisible?this.tablePopup.hide():this.showPopup()}showPopup(){const t=window.getSelection();t&&t.rangeCount>0&&L.savedRanges.set(this.editorId,t.getRangeAt(0).cloneRange());const e=n.getInstanceById(this.editorId);if(!e)return;const i=e.getModule("toolbar");let s=null;if(i&&(s=i.getButton("table")),!s){const t=i?.getContainer();t&&(s=t.querySelector(".rich-editor-toolbar-btn.table-btn"))}s||(s=e.wrapper.querySelector(".rich-editor-toolbar-btn.table-btn")),s&&this.tablePopup.show(s)}isActive(){const t=window.getSelection();if(!t||!t.rangeCount)return!1;let e=t.getRangeAt(0).startContainer;for(;e&&e!==document.body;){if(e.nodeType===Node.ELEMENT_NODE&&"TABLE"===e.tagName)return!0;e=e.parentNode}return!1}getCurrentTable(){const t=window.getSelection();if(!t||!t.rangeCount)return null;let e=t.getRangeAt(0).startContainer;for(;e&&e!==document.body;){if(e.nodeType===Node.ELEMENT_NODE&&"TABLE"===e.tagName)return e;e=e.parentNode}return null}apply(){this.showPopup()}remove(){const t=this.getCurrentTable();t&&(window.richEditor&&window.richEditor.resizeHandles&&window.richEditor.resizeHandles.hideHandles(),t.parentNode.removeChild(t))}}class S{constructor(t={}){this.options={items:[],onItemSelect:null,displayProperty:"label",valueProperty:"value",className:"custom-select",width:200,height:280,...t},this.popup=null,this.isVisible=!1,this.currentValue=null,this.clickOutsideHandler=null,this.initialized=!1,this.createSelect()}createSelect(){this.popup=document.createElement("div"),this.popup.className=`${this.options.className}-popup`,C(this.popup),this.init()}async init(){await this.createItemList(),this.initialized=!0}async createItemList(){const t=document.createElement("div");t.className="item-list";const e=m.getIcon("check");this.options.items.forEach(n=>{const i=document.createElement("button");i.type="button",i.className="custom-select-item-button",i.dataset.value=this.getItemValue(n);const s=document.createElement("div");s.className="item-text",s.innerHTML=this.getItemDisplay(n);const o=document.createElement("span");o.className="item-checkmark",o.innerHTML=e||"",i.appendChild(s),i.appendChild(o),i.addEventListener("click",t=>{t.preventDefault(),t.stopPropagation(),this.selectItem(n)}),t.appendChild(i)}),this.popup.appendChild(t)}getItemDisplay(t){return t[this.options.displayProperty]||t.toString()}getItemValue(t){return t[this.options.valueProperty]||t[this.options.displayProperty]||t}async updateItems(t){this.options.items=t;const e=this.popup.querySelector(".item-list");e&&e.remove(),await this.createItemList()}setupClickOutside(){this.clickOutsideHandler&&document.removeEventListener("click",this.clickOutsideHandler),this.clickOutsideHandler=t=>{t.target.closest(".block-toolbar")||this.popup.contains(t.target)||this.hide()},setTimeout(()=>{document.addEventListener("click",this.clickOutsideHandler)},100)}removeClickOutside(){this.clickOutsideHandler&&(document.removeEventListener("click",this.clickOutsideHandler),this.clickOutsideHandler=null)}setupScrollHandler(){this.scrollHandler&&window.removeEventListener("scroll",this.scrollHandler),this.scrollHandler=()=>{this.isVisible&&this.updatePosition()},window.addEventListener("scroll",this.scrollHandler)}removeScrollHandler(){this.scrollHandler&&(window.removeEventListener("scroll",this.scrollHandler),this.scrollHandler=null)}async show(t){if(!t)return;this.initialized||await new Promise(t=>{const e=()=>{this.initialized?t():setTimeout(e,10)};e()}),document.body.contains(this.popup)||C(this.popup),this.highlightCurrentItem(this.currentValue);const e=b(t,this.popup,{offsetY:5,offsetX:0});y(this.popup,e),this.popup.classList.add("visible"),this.isVisible=!0,this.setupClickOutside(),this.setupScrollHandler(),this.currentAnchor=t}hide(){this.popup.classList.remove("visible"),this.isVisible=!1,this.removeClickOutside(),this.currentAnchor=null}updatePosition(){if(this.isVisible&&this.currentAnchor){const t=b(this.currentAnchor,this.popup,{offsetY:5,offsetX:0});y(this.popup,t)}}setCurrentValue(t){this.currentValue=t,this.highlightCurrentItem(t)}highlightCurrentItem(t){if(this.popup.querySelectorAll(".custom-select-item-button.current").forEach(t=>{t.classList.remove("current")}),null!=t){const e=this.popup.querySelectorAll(".custom-select-item-button");for(const n of e)if(n.dataset.value===t.toString()){n.classList.add("current");break}}}selectItem(t){const e=this.getItemValue(t);this.currentValue=e,this.options.onItemSelect&&this.options.onItemSelect(e,t),this.hide()}getCurrentValue(){return this.currentValue}destroy(){this.removeClickOutside(),this.popup&&this.popup.parentNode&&this.popup.parentNode.removeChild(this.popup)}}class N extends o{static formatName="heading";static tagName="H1";constructor(){super();const t=n.getCurrentInstance();if(!t)return;this.editorId=t.instanceId;let e=t.getPopupInstance("heading");if(!e){const n=N.getTagMap(),i=Object.values(n).map(t=>({value:t.tag,label:t.element,title:t.title}));e=new S({items:i,displayProperty:"label",valueProperty:"value",className:"heading-select",onItemSelect:(t,e)=>{N.applyTagToCurrentSelection(t,this.editorId)},editor:t,editorId:this.editorId}),t.setPopupInstance("heading",e)}this.customSelect=e}static createForEditor(t){const e=n.getInstanceById(t);if(!e)return null;const i=n.currentInstance;n.currentInstance=e;const s=new N;return n.currentInstance=i,s}static getTagMap(){return{H1:{tag:"H1",element:'<h1 style="margin:0">Heading 1</h1>',title:"Heading 1"},H2:{tag:"H2",element:'<h2 style="margin:0">Heading 2</h2>',title:"Heading 2"},H3:{tag:"H3",element:'<h3 style="margin:0">Heading 3</h3>',title:"Heading 3"},H4:{tag:"H4",element:'<h4 style="margin:0">Heading 4</h4>',title:"Heading 4"},H5:{tag:"H5",element:'<h5 style="margin:0">Heading 5</h5>',title:"Heading 5"},H6:{tag:"H6",element:'<h6 style="margin:0">Heading 6</h6>',title:"Heading 6"},P:{tag:"P",element:'<p style="margin:0">Paragraph</p>',title:"Paragraph"},PRE:{tag:"PRE",element:'<pre style="margin:0">Code</pre>',title:"Preformatted"},BLOCKQUOTE:{tag:"BLOCKQUOTE",element:'<blockquote style="margin:0">Quote</blockquote>',title:"Quote"}}}static getTagDisplayName(t){const e=this.getTagMap();return e[t]?.title||"Paragraph"}updateButtonText(){const t=this.getCurrentTag(),e=N.getTagDisplayName(t||"P"),i=n.getInstanceById(this.editorId);if(!i)return;const s=i.getModule("toolbar");let o=null;if(s&&(o=s.getButton("heading")),!o){const t=s?.getContainer();t&&(o=t.querySelector(".rich-editor-toolbar-btn.heading-btn"))}o||(o=i.wrapper.querySelector(".rich-editor-toolbar-btn.heading-btn")),o&&o.updateText?o.updateText(e):o&&(o.textContent=e)}static create(t="P"){return document.createElement(t.toUpperCase())}static applyTagToCurrentSelection(t,e=null){let i=null;if(i=e?n.getInstanceById(e):n.getCurrentInstance(),!i)return;const s=window.getSelection();if(!s||!s.rangeCount)return;r(),s.getRangeAt(0);const o=N.createForEditor(e);o&&(o.apply(t),o.updateButtonText()),setTimeout(()=>{i&&"function"==typeof i.onContentChange&&i.onContentChange()},0)}apply(t="P"){const e=window.getSelection();if(!e||!e.rangeCount)return;const n=e.getRangeAt(0);n.collapsed;const i=this.getBlockElements(n);if(0===i.length){const s=this.createBlockAtCursor(n,t),o=document.createRange();o.setStart(s,0),o.collapse(!0),e.removeAllRanges(),e.addRange(o)}else{const r=window.getSelection();if(!r.rangeCount)return;const l=r.getRangeAt(0),a=l.collapsed,c=Array.from(i);function d(t,e){for(;t&&9!==t.nodeType;){const n=e.indexOf(t);if(-1!==n)return n;t=t.parentNode}return-1}function h(t,e,n){const i=document.createRange();return i.setStart(t,0),i.setEnd(e,n),i.toString().length}const u=d(l.startContainer,c),p=d(l.endContainer,c);let m=0,g=0;-1!==u&&(m=h(c[u],l.startContainer,l.startOffset)),a||-1===p||(g=h(c[p],l.endContainer,l.endOffset));const C=c.map(e=>this.convertBlock(e,t)||e);function f(t,e){const n=document.createTreeWalker(t,NodeFilter.SHOW_TEXT,null,!1);let i,s=e;for(;i=n.nextNode();){const t=i.nodeValue.length;if(s<=t)return{node:i,offset:s};s-=t}return{node:t,offset:t.childNodes.length}}const b=document.createRange();if(a){const y=f(C[-1!==u?u:0],m);y.node.nodeType===Node.TEXT_NODE?b.setStart(y.node,y.offset):b.setStart(y.node,Math.max(0,y.offset)),b.collapse(!0)}else{if(-1===u||-1===p)return r.removeAllRanges(),void r.addRange(l);const v=f(C[u],m),w=f(C[p],g);v.node.nodeType===Node.TEXT_NODE?b.setStart(v.node,v.offset):b.setStart(v.node,Math.min(v.offset,v.node.childNodes.length)),w.node.nodeType===Node.TEXT_NODE?b.setEnd(w.node,w.offset):b.setEnd(w.node,Math.min(w.offset,w.node.childNodes.length))}r.removeAllRanges(),r.addRange(b)}}createBlockAtCursor(t,e){const n=this.constructor.create(e),i=this.getBlockElement(t.startContainer);if(i&&i.style&&i.style.cssText&&(n.style.cssText=i.style.cssText),t.collapsed){n.appendChild(document.createTextNode("")),t.insertNode(n);const e=document.createRange();e.setStart(n,0),e.collapse(!0);const i=window.getSelection();i.removeAllRanges(),i.addRange(e)}else{const e=t.extractContents();n.appendChild(e),t.insertNode(n);const i=document.createRange();i.selectNodeContents(n);const s=window.getSelection();s.removeAllRanges(),s.addRange(i)}}convertBlock(t,e){const n=this.constructor.create(e);for(;t.firstChild;)n.appendChild(t.firstChild);return t.className&&this.shouldPreserveClass(t.className)&&(n.className=t.className),t.style&&t.style.cssText&&(n.style.cssText=t.style.cssText),t.parentNode.replaceChild(n,t),n}setCursorAtStartOfBlock(t){const e=window.getSelection(),n=document.createRange(),i=document.createTreeWalker(t,NodeFilter.SHOW_TEXT,null,!1).nextNode();i?(n.setStart(i,0),n.collapse(!0)):(n.setStart(t,0),n.collapse(!0)),e.removeAllRanges(),e.addRange(n)}async toggle(){this.customSelect.isVisible?this.customSelect.hide():await this.showTagPicker()}async showTagPicker(){const t=n.getInstanceById(this.editorId);if(!t)return;const e=t.getModule("toolbar");let i=null;if(e&&(i=e.getButton("heading")),!i){const t=e?.getContainer();t&&(i=t.querySelector(".rich-editor-toolbar-btn.heading-btn"))}if(i||(i=t.wrapper.querySelector(".rich-editor-toolbar-btn.heading-btn")),!i)return;const s=this.getCurrentTag();s&&this.customSelect.setCurrentValue(s),await this.customSelect.show(i)}isActive(t=null){return this.updateButtonText(),!1}getCurrentTag(){const t=window.getSelection();if(!t||!t.rangeCount)return null;const e=t.getRangeAt(0),n=this.getBlockElement(e.startContainer);if(!n)return null;return["H1","H2","H3","H4","H5","H6","P","PRE","BLOCKQUOTE"].includes(n.tagName)?n.tagName:null}}class H extends s{static formatName="fontFamily";static tagName="SPAN";constructor(){super();const t=n.getCurrentInstance();if(!t)return;this.editorId=t.instanceId;let e=t.getPopupInstance("font-family");if(!e){const n=H.getFontMap(),i=Object.values(n).map(t=>({value:t.font,label:t.element,title:t.title}));e=new S({items:i,displayProperty:"label",valueProperty:"value",className:"font-family-select",onItemSelect:(t,e)=>{H.applyFontFamilyToCurrentSelection(t,this.editorId)},editor:t,editorId:this.editorId}),t.setPopupInstance("font-family",e)}this.customSelect=e,this.setupSelectionListener()}static createForEditor(t){const e=n.getInstanceById(t);if(!e)return null;const i=n.currentInstance;n.currentInstance=e;const s=new H;return n.currentInstance=i,s}setupSelectionListener(){let t;const e=()=>{clearTimeout(t),t=setTimeout(()=>{const t=window.getSelection();if(t&&t.rangeCount>0){const e=t.getRangeAt(0),i=n.getInstanceById(this.editorId);i&&(i.editor.contains(e.startContainer)||i.editor.isSameNode(e.startContainer))&&this.updateButtonText()}},50)};document.addEventListener("selectionchange",e),document.addEventListener("mouseup",e),document.addEventListener("keyup",e),this.selectionListener=e}static getFontMap(){return{Arial:{font:"Arial, sans-serif",element:'<span style="font-family: Arial, sans-serif">Arial</span>',title:"Arial"},Helvetica:{font:"Helvetica, Arial, sans-serif",element:'<span style="font-family: Helvetica, Arial, sans-serif">Helvetica</span>',title:"Helvetica"},"Times New Roman":{font:'"Times New Roman", Times, serif',element:"<span style=\"font-family: 'Times New Roman', Times, serif\">Times New Roman</span>",title:"Times New Roman"},Georgia:{font:"Georgia, serif",element:'<span style="font-family: Georgia, serif">Georgia</span>',title:"Georgia"},Verdana:{font:"Verdana, Geneva, sans-serif",element:'<span style="font-family: Verdana, Geneva, sans-serif">Verdana</span>',title:"Verdana"},"Courier New":{font:'"Courier New", Courier, monospace',element:"<span style=\"font-family: 'Courier New', Courier, monospace\">Courier New</span>",title:"Courier New"},"Trebuchet MS":{font:'"Trebuchet MS", Helvetica, sans-serif',element:"<span style=\"font-family: 'Trebuchet MS', Helvetica, sans-serif\">Trebuchet MS</span>",title:"Trebuchet MS"},"Comic Sans MS":{font:'"Comic Sans MS", cursive',element:"<span style=\"font-family: 'Comic Sans MS', cursive\">Comic Sans MS</span>",title:"Comic Sans MS"},Impact:{font:"Impact, Charcoal, sans-serif",element:'<span style="font-family: Impact, Charcoal, sans-serif">Impact</span>',title:"Impact"},"Lucida Console":{font:'"Lucida Console", Monaco, monospace',element:"<span style=\"font-family: 'Lucida Console', Monaco, monospace\">Lucida Console</span>",title:"Lucida Console"}}}static getFontDisplayName(t){const e=this.getFontMap();for(const[n,i]of Object.entries(e))if(i.font===t||n===t)return i.title;return"Arial"}updateButtonText(){const t=this.getCurrentFont(),e=H.getFontDisplayName(t||"Arial, sans-serif"),i=n.getInstanceById(this.editorId);if(!i)return;const s=i.getModule("toolbar");let o=null;if(s&&(o=s.getButton("font-family")),!o){const t=s?.getContainer();t&&(o=t.querySelector(".rich-editor-toolbar-btn.font-family-btn"))}o||(o=i.wrapper.querySelector(".rich-editor-toolbar-btn.font-family-btn")),o&&o.updateText?o.updateText(e):o&&(o.textContent=e)}static create(t="Arial, sans-serif"){const e=document.createElement("span");return e.style.fontFamily=t,e}static applyFontFamilyToCurrentSelection(t,e=null){let i=null;if(i=e?n.getInstanceById(e):n.getCurrentInstance(),!i)return;const s=window.getSelection();if(!s||!s.rangeCount)return;r(),s.getRangeAt(0);const o=H.createForEditor(e);o&&(o.apply(t),o.updateButtonText()),setTimeout(()=>{i&&"function"==typeof i.onContentChange&&i.onContentChange()},0)}apply(t="Arial, sans-serif"){const e=window.getSelection();if(!e||!e.rangeCount)return;const n=e.getRangeAt(0);function i(t){const e=window.getSelection(),n=document.createRange(),i=t.firstChild;n.setStart(i,i.length),n.collapse(!0),e.removeAllRanges(),e.addRange(n)}if(n.collapsed){if(function(t,e){if(!t.rangeCount)return!1;let n=t.getRangeAt(0).startContainer;n.nodeType===Node.TEXT_NODE&&(n=n.parentNode);const i=e.split(",")[0].trim().toLowerCase();for(;n&&n.nodeType===Node.ELEMENT_NODE;){if("SPAN"===n.tagName){const t=n.style.fontFamily;if(t&&t.split(",")[0].trim().toLowerCase()===i)return 1===n.childNodes.length&&n.firstChild.nodeType===Node.TEXT_NODE&&n.firstChild.textContent,!0}n=n.parentNode}return!1}(e,t))return;let s=n.startContainer;n.startOffset,s.nodeType===Node.TEXT_NODE&&(s=s.parentNode);const o=s.closest&&s.closest("span");if(o&&"​"===o.textContent)return void(o.style.fontFamily=t);if(o&&o.firstChild&&o.firstChild.nodeType===Node.TEXT_NODE){const e=o.firstChild,s=n.startOffset,r=e.data.slice(0,s),l=e.data.slice(s),a=o.parentNode;if(0===s){const e=document.createElement("span");e.style.fontFamily=t,e.appendChild(document.createTextNode("​")),a.insertBefore(e,o),i(e)}else if(s===e.data.length){const e=document.createElement("span");e.style.fontFamily=t,e.appendChild(document.createTextNode("​")),a.insertBefore(e,o.nextSibling),i(e)}else{const e=document.createElement("span");e.style.fontFamily=o.style.fontFamily,e.appendChild(document.createTextNode(r));const n=document.createElement("span");n.style.fontFamily=t,n.appendChild(document.createTextNode("​"));const s=document.createElement("span");s.style.fontFamily=o.style.fontFamily,s.appendChild(document.createTextNode(l)),a.insertBefore(e,o),a.insertBefore(n,o),a.insertBefore(s,o),a.removeChild(o),i(n)}return}const r=document.createElement("span");r.style.fontFamily=t,r.appendChild(document.createTextNode("​")),n.insertNode(r),i(r)}else document.execCommand("fontName",!1,t)}async toggle(t=null){this.customSelect.isVisible?this.customSelect.hide():await this.showFontPicker(t)}async showFontPicker(t=null){let e=t;if(!e){const t=n.getInstanceById(this.editorId);if(!t)return;const i=t.getModule("toolbar");if(i&&(e=i.getButton("font-family")),!e){const t=i?.getContainer();t&&(e=t.querySelector(".rich-editor-toolbar-btn.font-family-btn"))}e||(e=t.wrapper.querySelector(".rich-editor-toolbar-btn.font-family-btn"))}if(!e)return;const i=this.getCurrentFont();i&&this.customSelect.setCurrentValue(i),await this.customSelect.show(e)}isActive(t=null){return this.updateButtonText(),!1}getCurrentFont(){const t=window.getSelection();if(!t||!t.rangeCount)return null;let e=t.getRangeAt(0).startContainer;e.nodeType===Node.TEXT_NODE&&(e=e.parentElement);const i=n.getInstanceById(this.editorId);if(!i)return"Arial, sans-serif";if(!i.editor.contains(e)&&!i.editor.isSameNode(e))return"Arial, sans-serif";for(;e&&e!==document.body;){if(e.nodeType===Node.ELEMENT_NODE){const t=e;if(t.style.fontFamily)return t.style.fontFamily;const n=window.getComputedStyle(t).fontFamily;if(n&&"initial"!==n&&"inherit"!==n)return n}e=e.parentElement}return"Arial, sans-serif"}setCurrentFont(t){this.currentFont=t}}class k extends s{static formatName="lineHeight";static tagName="SPAN";constructor(){super();const t=n.getCurrentInstance();if(!t)return;this.editorId=t.instanceId;let e=t.getPopupInstance("line-height");if(!e){const n=k.getHeightMap(),i=Object.values(n).map(t=>({value:t.height,label:t.element,title:t.title}));e=new S({items:i,displayProperty:"label",valueProperty:"value",className:"line-height-select",onItemSelect:(t,e)=>{k.applyLineHeightToCurrentSelection(t,this.editorId)},editor:t,editorId:this.editorId}),t.setPopupInstance("line-height",e)}this.customSelect=e,this.setupSelectionListener()}static createForEditor(t){const e=n.getInstanceById(t);if(!e)return null;const i=n.currentInstance;n.currentInstance=e;const s=new k;return n.currentInstance=i,s}setupSelectionListener(){let t;const e=()=>{clearTimeout(t),t=setTimeout(()=>{const t=window.getSelection();if(t&&t.rangeCount>0){const e=t.getRangeAt(0),i=n.getInstanceById(this.editorId);i&&(i.editor.contains(e.startContainer)||i.editor.isSameNode(e.startContainer))&&this.updateButtonText()}},50)};document.addEventListener("selectionchange",e),document.addEventListener("mouseup",e),document.addEventListener("keyup",e),this.selectionListener=e}static getHeightMap(){return{"1.0":{height:"1",element:"<span>1.0</span>",title:"1.0"},1.2:{height:"1.2",element:"<span>1.2</span>",title:"1.2"},1.5:{height:"1.5",element:"<span>1.5</span>",title:"1.5"},1.8:{height:"1.8",element:"<span>1.8</span>",title:"1.8"},"2.0":{height:"2",element:"<span>2.0</span>",title:"2.0"},2.5:{height:"2.5",element:"<span>2.5</span>",title:"2.5"},"3.0":{height:"3",element:"<span>3.0</span>",title:"3.0"}}}static getHeightDisplayName(t){const e=this.getHeightMap();return e[t]?.title||"line height"}updateButtonText(){const t=this.getCurrentHeight(),e=k.getHeightDisplayName(t||"1.15"),i=n.getInstanceById(this.editorId);if(!i)return;const s=i.getModule("toolbar");let o=null;if(s&&(o=s.getButton("line-height")),!o){const t=s?.getContainer();t&&(o=t.querySelector(".rich-editor-toolbar-btn.line-height-btn"))}o||(o=i.wrapper.querySelector(".rich-editor-toolbar-btn.line-height-btn")),o&&o.updateText?o.updateText(e):o&&(o.textContent=e)}static create(t="1.15"){const e=document.createElement("span");return e.style.lineHeight=t,e}static applyLineHeightToCurrentSelection(t,e=null){let i=null;if(i=e?n.getInstanceById(e):n.getCurrentInstance(),!i)return;const s=window.getSelection();if(!s||!s.rangeCount)return;r(),s.getRangeAt(0);const o=k.createForEditor(e);o&&(o.apply(t),o.updateButtonText()),setTimeout(()=>{i&&"function"==typeof i.onContentChange&&i.onContentChange()},0)}apply(t="1.15"){const e=window.getSelection();if(!e||!e.rangeCount)return;r();const n=e.getRangeAt(0);if(n.collapsed){let e=n.startContainer;e.nodeType===Node.TEXT_NODE&&(e=e.parentNode);const i=e.closest("div, p, li, section, article")||e;return i.style.lineHeight=t,void function(t){const e=window.getSelection(),n=document.createRange(),i=t.firstChild;n.setStart(i,i.length),n.collapse(!0),e.removeAllRanges(),e.addRange(n)}(i)}const i=this.getBlockElementsInRange(n);if(i.length>0)i.forEach(e=>{e.style.lineHeight=t});else{const i=this.constructor.create(t);try{const t=n.extractContents();i.appendChild(t),n.insertNode(i);const s=document.createRange();s.selectNodeContents(i),e.removeAllRanges(),e.addRange(s)}catch(t){}}}getBlockElementsInRange(t){const e=[],n=["P","DIV","H1","H2","H3","H4","H5","H6","BLOCKQUOTE","PRE","UL","OL","LI"],i=t.cloneContents(),s=document.createTreeWalker(i,NodeFilter.SHOW_ELEMENT,{acceptNode:t=>n.includes(t.tagName)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP});let o=s.nextNode();for(;o;){const n=t.commonAncestorContainer.querySelector(`${o.tagName.toLowerCase()}:not([data-processed])`);n&&t.intersectsNode(n)&&(e.push(n),n.setAttribute("data-processed","true")),o=s.nextNode()}if(e.forEach(t=>t.removeAttribute("data-processed")),0===e.length){let i=t.startContainer;for(i.nodeType===Node.TEXT_NODE&&(i=i.parentElement);i&&i!==document.body;){if(i.nodeType===Node.ELEMENT_NODE&&n.includes(i.tagName)){e.push(i);break}i=i.parentElement}}return e}async toggle(){this.customSelect.isVisible?this.customSelect.hide():await this.showHeightPicker()}async showHeightPicker(){const t=n.getInstanceById(this.editorId);if(!t)return;const e=t.getModule("toolbar");let i=null;if(e&&(i=e.getButton("line-height")),!i){const t=e?.getContainer();t&&(i=t.querySelector(".rich-editor-toolbar-btn.line-height-btn"))}if(i||(i=t.wrapper.querySelector(".rich-editor-toolbar-btn.line-height-btn")),!i)return;const s=this.getCurrentHeight();s&&this.customSelect.setCurrentValue(s),await this.customSelect.show(i)}isActive(t=null){return this.updateButtonText(),!1}getCurrentHeight(){const t=window.getSelection();if(!t||!t.rangeCount)return null;let e=t.getRangeAt(0).startContainer;e.nodeType===Node.TEXT_NODE&&(e=e.parentElement);const i=n.getInstanceById(this.editorId);if(!i)return"1.15";if(!i.editor.contains(e)&&!i.editor.isSameNode(e))return"1.15";for(;e&&e!==document.body;){if(e.nodeType===Node.ELEMENT_NODE){const t=e;if(t.style.lineHeight){const e=t.style.lineHeight;return this.normalizeHeightValue(e)}const n=window.getComputedStyle(t),i=n.lineHeight;if(i&&"normal"!==i&&"initial"!==i&&"inherit"!==i){if(i.endsWith("px")){const t=parseFloat(n.fontSize),e=parseFloat(i);if(t>0){const n=(e/t).toFixed(2);return this.normalizeHeightValue(n)}}return this.normalizeHeightValue(i)}}e=e.parentElement}return"1.15"}normalizeHeightValue(t){if(!t)return"1.15";const e=parseFloat(t);if(isNaN(e))return"1.15";const n=e.toFixed(1);return this.constructor.getHeightMap()[n]?n:t}destroy(){this.selectionListener&&(document.removeEventListener("selectionchange",this.selectionListener),document.removeEventListener("mouseup",this.selectionListener),document.removeEventListener("keyup",this.selectionListener),this.selectionListener=null)}}class A extends s{static formatName="capitalization";static tagName="SPAN";constructor(){super();const t=n.getCurrentInstance();if(!t)return;this.editorId=t.instanceId;let e=t.getPopupInstance("capitalization");if(!e){const n=A.getCapitalizationMap(),i=Object.values(n).map(t=>({value:t.style,label:t.element,title:t.title}));e=new S({items:i,displayProperty:"label",valueProperty:"value",className:"capitalization-select",onItemSelect:(t,e)=>{A.applyCapitalizationToCurrentSelection(t,this.editorId)},editor:t,editorId:this.editorId}),t.setPopupInstance("capitalization",e)}this.customSelect=e}static createForEditor(t){const e=n.getInstanceById(t);if(!e)return null;const i=n.currentInstance;n.currentInstance=e;const s=new A;return n.currentInstance=i,s}static getCapitalizationMap(){return{capitalize:{style:"capitalize",element:"<span>Capitalize</span>",title:"Capitalize"},uppercase:{style:"uppercase",element:"<span>UPPERCASE</span>",title:"UPPERCASE"},lowercase:{style:"lowercase",element:"<span>lowercase</span>",title:"lowercase"},"small-caps":{style:"small-caps",element:"<span>Small Caps</span>",title:"Small Caps"}}}static getCapitalizationDisplayName(t){const e=this.getCapitalizationMap();return e[t]?.title||"Capitalization"}updateButtonText(){const t=this.getCurrentCapitalization(),e=A.getCapitalizationDisplayName(t||"none"),i=n.getInstanceById(this.editorId);if(!i)return;const s=i.getModule("toolbar");let o=null;if(s&&(o=s.getButton("capitalization")),!o){const t=s?.getContainer();t&&(o=t.querySelector(".rich-editor-toolbar-btn.capitalization-btn"))}o||(o=i.wrapper.querySelector(".rich-editor-toolbar-btn.capitalization-btn")),o&&o.updateText?o.updateText(e):o&&(o.textContent=e)}static create(t="none"){const e=document.createElement("span");return"small-caps"===t?e.style.fontVariant="small-caps":e.style.textTransform=t,e}static applyCapitalizationToCurrentSelection(t,e=null){let i=null;if(i=e?n.getInstanceById(e):n.getCurrentInstance(),!i)return;const s=window.getSelection();if(!s||!s.rangeCount)return;r(),s.getRangeAt(0);const o=A.createForEditor(e);o&&(o.apply(t),o.updateButtonText()),setTimeout(()=>{i&&"function"==typeof i.onContentChange&&i.onContentChange()},0)}hasCapitalizationStyling(t){if(!t||t.nodeType!==Node.ELEMENT_NODE)return!1;if("small-caps"===t.style.fontVariant)return!0;if(t.style.textTransform&&"none"!==t.style.textTransform)return!0;const e=window.getComputedStyle(t);return"small-caps"===e.fontVariant||!(!e.textTransform||"none"===e.textTransform)}isCapitalizationElement(t){return!(!t||t.nodeType!==Node.ELEMENT_NODE)&&("small-caps"===t.style.fontVariant||!(!t.style.textTransform||"none"===t.style.textTransform))}findAncestorCapitalizationElement(t){let e=t;if(!e)return null;for(e.nodeType===Node.TEXT_NODE&&(e=e.parentElement);e&&e!==document.body;){if(this.isCapitalizationElement(e))return e;e=e.parentElement}return null}setElementCapitalizationStyle(t,e){t&&("small-caps"===e?(t.style.fontVariant="small-caps",t.style.textTransform=""):"none"===e?(t.style.fontVariant="",t.style.textTransform=""):(t.style.fontVariant="",t.style.textTransform=e))}apply(t="none"){const e=window.getSelection();if(!e||!e.rangeCount)return;r();const n=e.getRangeAt(0);function i(t,e){switch(e){case"uppercase":return t.toUpperCase();case"lowercase":return t.toLowerCase();case"capitalize":return(t=t.toLowerCase()).replace(/\b\w/g,t=>t.toUpperCase());default:return t}}const s=n.extractContents(),o=document.createTreeWalker(s,NodeFilter.SHOW_TEXT,null);for(;o.nextNode();){const e=o.currentNode;e.textContent=i(e.textContent,t)}n.deleteContents(),n.insertNode(s),function(t){if(!t)return;const e=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,null),n=[];for(;e.nextNode();){const t=e.currentNode;t.textContent.trim()||0!==t.childElementCount||n.push(t)}n.forEach(t=>t.remove())}(n.commonAncestorContainer),e.removeAllRanges(),e.addRange(n)}removeExistingCapitalization(t){const e=t.commonAncestorContainer,n=new Set,i=e=>{e&&e.nodeType===Node.ELEMENT_NODE&&this.hasCapitalizationStyling(e)&&t.intersectsNode(e)&&n.add(e)};e&&e.nodeType===Node.ELEMENT_NODE&&i(e);const s=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>t.intersectsNode(e)&&this.hasCapitalizationStyling(e)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP});let o;for(;o=s.nextNode();)n.add(o);const r=t=>{let e=t.nodeType===Node.TEXT_NODE?t.parentElement:t;for(;e&&e!==document.body;)i(e),e=e.parentElement};r(t.startContainer),r(t.endContainer),Array.from(n).forEach(t=>{t.style.textTransform="",t.style.fontVariant="",t.style.cssText.trim()||t.className||this.unwrapElement(t)})}unwrapElement(t){const e=t.parentNode;if(e){for(;t.firstChild;)e.insertBefore(t.firstChild,t);e.removeChild(t)}}async toggle(){this.customSelect.isVisible?this.customSelect.hide():await this.showCapitalizationPicker()}async showCapitalizationPicker(){const t=n.getInstanceById(this.editorId);if(!t)return;const e=t.getModule("toolbar");let i=null;if(e&&(i=e.getButton("capitalization")),!i){const t=e?.getContainer();t&&(i=t.querySelector(".rich-editor-toolbar-btn.capitalization-btn"))}if(i||(i=t.wrapper.querySelector(".rich-editor-toolbar-btn.capitalization-btn")),!i)return;const s=this.getCurrentCapitalization();s&&this.customSelect.setCurrentValue(s),await this.customSelect.show(i)}isActive(t=null){return this.updateButtonText(),!1}getCurrentCapitalization(){const t=window.getSelection();if(!t||!t.rangeCount)return null;let e=t.getRangeAt(0).startContainer;for(e.nodeType===Node.TEXT_NODE&&(e=e.parentElement);e&&e!==document.body;){if(e.nodeType===Node.ELEMENT_NODE){const t=e;if("small-caps"===t.style.fontVariant)return"small-caps";if(t.style.textTransform&&"none"!==t.style.textTransform)return t.style.textTransform;const n=window.getComputedStyle(t);if("small-caps"===n.fontVariant)return"small-caps";if(n.textTransform&&"none"!==n.textTransform)return n.textTransform}e=e.parentElement}return"none"}setCurrentCapitalization(t){this.currentCapitalization=t}static toggleUppercase(){const t="uppercase"===(new A).getCurrentCapitalization()?"none":"uppercase";A.applyCapitalizationToCurrentSelection(t)}static toggleLowercase(){const t="lowercase"===(new A).getCurrentCapitalization()?"none":"lowercase";A.applyCapitalizationToCurrentSelection(t)}static toggleCapitalize(){const t="capitalize"===(new A).getCurrentCapitalization()?"none":"capitalize";A.applyCapitalizationToCurrentSelection(t)}static toggleSmallCaps(){const t="small-caps"===(new A).getCurrentCapitalization()?"none":"small-caps";A.applyCapitalizationToCurrentSelection(t)}}class B{constructor(t={}){this.options={alignments:[{value:"left",label:"Align Left",icon:"align-left"},{value:"center",label:"Align Center",icon:"align-center"},{value:"right",label:"Align Right",icon:"align-right"},{value:"justify",label:"Justify",icon:"align-justify"}],onAlignSelect:null,...t},this.popup=null,this.isVisible=!1,this.currentAlignment="left",this.clickOutsideHandler=null,this.createAlignPicker()}createAlignPicker(){this.popup=document.createElement("div"),this.popup.className="text-align-picker-popup",this.createAlignmentButtons(),C(this.popup)}async createAlignmentButtons(){const t=document.createElement("div");t.className="align-button-container";for(const e of this.options.alignments){const n=document.createElement("button");n.type="button",n.className="align-button",n.dataset.alignment=e.value,n.title=e.label;const i=m.getIcon(e.icon);i?n.innerHTML=`\n <span class="icon-wrapper">${i}</span>\n <span class="label-text">${e.label}</span>\n `:n.textContent=e.label.charAt(0),n.addEventListener("click",t=>{t.preventDefault(),t.stopPropagation(),this.selectAlignment(e.value)}),t.appendChild(n)}this.popup.appendChild(t)}setupClickOutside(){this.clickOutsideHandler&&document.removeEventListener("click",this.clickOutsideHandler),this.clickOutsideHandler=t=>{this.popup.contains(t.target)||this.hide()},setTimeout(()=>{document.addEventListener("click",this.clickOutsideHandler)},100)}removeClickOutside(){this.clickOutsideHandler&&(document.removeEventListener("click",this.clickOutsideHandler),this.clickOutsideHandler=null)}show(t){if(!t)return;document.body.contains(this.popup)||C(this.popup),this.updateCurrentAlignment();const e=b(t,this.popup,{offsetY:5,offsetX:0});y(this.popup,e),this.popup.classList.add("visible"),this.isVisible=!0,this.setupClickOutside()}hide(){this.popup.classList.remove("visible"),this.isVisible=!1,this.removeClickOutside()}selectAlignment(t){this.currentAlignment=t,this.options.onAlignSelect&&this.options.onAlignSelect(t),this.hide()}updateCurrentAlignment(){const t=window.getSelection();if(t&&t.rangeCount)try{const e=t.getRangeAt(0),n=this.getSelectedBlockElements(e),i=n.length>0?n[0]:this.getBlockElement(e.commonAncestorContainer);if(i){const t=window.getComputedStyle(i).textAlign;this.currentAlignment="left"!==t&&"start"!==t&&t?t:"left"}else this.currentAlignment="left";this.popup.querySelectorAll(".align-button").forEach(t=>{t.dataset.alignment===this.currentAlignment?t.classList.add("active"):t.classList.remove("active")}),this.updateToolbarButtonIcon(this.currentAlignment)}catch(t){}}getSelectedBlockElements(t){const e=[],n=this.getBlockElement(t.startContainer),i=this.getBlockElement(t.endContainer);if(n&&e.push(n),n&&i&&n!==i){let t=n;for(;t&&t!==i;)t=t.nextElementSibling,t&&this.getBlockElement(t)&&!e.includes(t)&&e.push(t);i&&!e.includes(i)&&e.push(i)}return e}updateToolbarButtonIcon(t){Promise.resolve().then(function(){return M}).then(e=>{e.default.updateToolbarButtonIcon(t)}).catch(t=>{})}getBlockElement(t){if(!t)return null;let e=t;for(;e&&e!==document.body;){if(e.nodeType===Node.ELEMENT_NODE){const t=e.tagName;if(["P","DIV","H1","H2","H3","H4","H5","H6","BLOCKQUOTE","LI"].includes(t))return e}e=e.parentNode}return null}destroy(){this.removeClickOutside(),this.popup&&this.popup.parentNode&&this.popup.parentNode.removeChild(this.popup)}}class P extends o{static formatName="text-align";static tagName="P";static attribute="style";constructor(){super();const t=n.getCurrentInstance();if(!t)return;this.editorId=t.instanceId;let e=t.getPopupInstance("text-align");e||(e=new B({onAlignSelect:t=>{P.applyAlignToCurrentSelection(t,this.editorId)},editor:t,editorId:this.editorId}),t.setPopupInstance("text-align",e)),this.alignPicker=e}static createForEditor(t){const e=n.getInstanceById(t);if(!e)return null;const i=n.currentInstance;n.currentInstance=e;const s=new P;return n.currentInstance=i,s}static create(t){const e=document.createElement(this.tagName);return t&&"left"!==t&&(e.style.textAlign=t),e}static applyAlignToCurrentSelection(t,e=null){let i=null;if(i=e?n.getInstanceById(e):n.getCurrentInstance(),!i)return;const s=window.getSelection();if(!s||!s.rangeCount)return;r();const o=s.getRangeAt(0),l=o.endContainer,a=o.endOffset;try{const n=s.getRangeAt(0),i=P.getSelectedBlockElements(n);if(0===i.length){document.execCommand("formatBlock",!1,"p");const e=s.getRangeAt(0);P.getSelectedBlockElements(e).forEach(e=>{P.applyAlignmentToBlock(e,t)})}else i.forEach(e=>{P.applyAlignmentToBlock(e,t)});P.updateToolbarButtonIcon(t,e),s.removeAllRanges();const o=document.createRange();o.setStart(l,a),o.collapse(!0),s.addRange(o)}catch(t){}setTimeout(()=>{i&&"function"==typeof i.onContentChange&&i.onContentChange()},0)}static applyAlignmentToBlock(t,e){t.style.textAlign="left"===e?"":e}static getIconNameForAlignment(t){return{left:"align-left",center:"align-center",right:"align-right",justify:"align-justify"}[t]||"align-center"}static updateToolbarButtonIcon(t,e=null){let i=null;if(i=e?n.getInstanceById(e):n.getCurrentInstance(),!i)return;const s=i.getModule("toolbar");let o=null;if(s&&(o=s.getButton("text-align")),!o){const t=s?.getContainer();t&&(o=t.querySelector(".rich-editor-toolbar-btn.text-align-btn"))}if(o||(o=i.wrapper.querySelector(".rich-editor-toolbar-btn.text-align-btn")),!o)return;const r=P.getIconNameForAlignment(t);o.title={left:"Align Left",center:"Align Center",right:"Align Right",justify:"Justify"}[t]||"Text Alignment";const l=m.getIcon(r);if(l){const t=o.querySelector(".icon");t?t.innerHTML=l:o.innerHTML=`<span class="icon">${l}</span>`}}static getSelectedBlockElements(t){const e=[],n=P.getBlockElement(t.startContainer),i=P.getBlockElement(t.endContainer);if(!n||!i)return e;if(n===i)return e.push(n),e;let s=n;for(;s;){const n=document.createRange();if(n.selectNodeContents(s),t.compareBoundaryPoints(Range.END_TO_START,n)<0&&t.compareBoundaryPoints(Range.START_TO_END,n)>0&&e.push(s),s===i)break;s=P.getNextBlockElement(s)}return e}static getBlockElement(t){if(!t)return null;let e=t;for(;e&&e!==document.body;){if(e.nodeType===Node.ELEMENT_NODE){const t=e.tagName;if(["P","DIV","H1","H2","H3","H4","H5","H6","BLOCKQUOTE","LI"].includes(t))return e}e=e.parentNode}return null}static getNextBlockElement(t){let e=t.nextSibling;for(;e;){if(e.nodeType===Node.ELEMENT_NODE){const t=e.tagName;if(["P","DIV","H1","H2","H3","H4","H5","H6","BLOCKQUOTE","LI"].includes(t))return e}e=e.nextSibling}return null}apply(t="left"){P.applyAlignToCurrentSelection(t,this.editorId)}remove(){P.applyAlignToCurrentSelection("left",this.editorId)}toggle(){this.alignPicker.isVisible?this.alignPicker.hide():this.showAlignPicker()}showAlignPicker(){const t=n.getInstanceById(this.editorId);if(!t)return;const e=t.getModule("toolbar");let i=null;if(e&&(i=e.getButton("text-align")),!i){const t=e?.getContainer();t&&(i=t.querySelector(".rich-editor-toolbar-btn.text-align-btn"))}i||(i=t.wrapper.querySelector(".rich-editor-toolbar-btn.text-align-btn")),i&&this.alignPicker.show(i)}isActive(t=null){const e=P.getCurrentAlignment();return P.updateToolbarButtonIcon(e,this.editorId),!1}static getCurrentAlignment(){const t=window.getSelection();if(!t||!t.rangeCount)return"left";try{const e=t.getRangeAt(0),n=P.getSelectedBlockElements(e),i=n.length>0?n[0]:P.getBlockElement(e.commonAncestorContainer);if(!i)return"left";const s=window.getComputedStyle(i).textAlign;return"left"!==s&&"start"!==s&&s?s:"left"}catch(t){return"left"}}}var M=Object.freeze({__proto__:null,default:P});class V{constructor(t={}){this.options={listTypes:[{value:"bullet",label:"Bullet List",icon:"list-bullet"},{value:"ordered",label:"Numbered List",icon:"list-ordered"},{value:"roman",label:"Roman Numerals List",icon:"list-roman"},{value:"alpha",label:"Alphabetical List",icon:"list-alpha"}],onListSelect:null,...t},this.popup=null,this.isVisible=!1,this.currentListType=null,this.clickOutsideHandler=null,this.createListPicker()}createListPicker(){this.popup=document.createElement("div"),this.popup.className="list-picker-popup",this.createListTypeButtons(),C(this.popup)}async createListTypeButtons(){const t=document.createElement("div");t.className="list-button-container";for(const e of this.options.listTypes){const n=document.createElement("button");n.type="button",n.className="list-button",n.dataset.listType=e.value,n.title=e.label;const i=m.getIcon(e.icon);i?n.innerHTML=i:n.textContent=e.label.charAt(0),n.addEventListener("click",t=>{t.preventDefault(),t.stopPropagation(),this.selectListType(e.value)}),t.appendChild(n)}this.popup.appendChild(t)}setupClickOutside(){this.clickOutsideHandler&&document.removeEventListener("click",this.clickOutsideHandler),this.clickOutsideHandler=t=>{this.popup.contains(t.target)||this.hide()},setTimeout(()=>{document.addEventListener("click",this.clickOutsideHandler)},100)}removeClickOutside(){this.clickOutsideHandler&&(document.removeEventListener("click",this.clickOutsideHandler),this.clickOutsideHandler=null)}show(t){if(!t)return;document.body.contains(this.popup)||C(this.popup),this.updateCurrentListType();const e=b(t,this.popup,{offsetY:5,offsetX:0});y(this.popup,e),this.popup.classList.add("visible"),this.isVisible=!0,this.setupClickOutside()}hide(){this.popup.classList.remove("visible"),this.isVisible=!1,this.removeClickOutside()}selectListType(t){this.currentListType=t,this.options.onListSelect&&this.options.onListSelect(t),this.hide()}updateCurrentListType(){try{const t=this.getCurrentListType();this.currentListType=t,this.updateButtonStates(t)}catch(t){}}updateButtonStates(t){this.popup.querySelectorAll(".list-button").forEach(e=>{e.classList.remove("active"),t&&e.dataset.listType===t&&e.classList.add("active")})}updateToolbarButtonIcon(t){const e=document.querySelector(".rich-editor-toolbar-btn.list-btn");if(!e)return;const n={bullet:"list-bullet",ordered:"list-ordered",roman:"list-roman",alpha:"list-alpha"}[t]||"list-bullet";e.title={bullet:"Bullet List",ordered:"Numbered List",roman:"Roman Numerals List",alpha:"Alphabetical List"}[t]||"List";const i=m.getIcon(n);if(i){const t=e.querySelector(".icon");t?t.innerHTML=i:e.innerHTML=`<span class="icon">${i}</span>`}}getParentList(t){let e=t;for(;e&&e!==document.body;){if("UL"===e.tagName||"OL"===e.tagName)return e;e=e.parentElement}return null}getListType(t){if("OL"===t.tagName){const e=t.style.listStyleType;return"upper-roman"===e?"roman":"lower-alpha"===e?"alpha":"ordered"}return"bullet"}getBlockElement(t){if(!t)return null;let e=t;for(;e&&e!==document.body;){if(e.nodeType===Node.ELEMENT_NODE){const t=e.tagName;if(["P","DIV","H1","H2","H3","H4","H5","H6","BLOCKQUOTE","LI","UL","OL"].includes(t))return e}e=e.parentNode}return null}getCurrentListType(){const t=window.getSelection();if(!t||!t.rangeCount)return null;const e=t.getRangeAt(0),n=this.getParentList(e.commonAncestorContainer);return n?this.getListType(n):null}destroy(){this.removeClickOutside(),this.popup&&this.popup.parentNode&&this.popup.parentNode.removeChild(this.popup),this.popup=null,this.isVisible=!1,this.currentListType=null}}class R extends o{static formatName="list";static tagName="UL";static attribute="class";constructor(){super();const t=n.getCurrentInstance();if(!t)return;this.editorId=t.instanceId;let e=t.getPopupInstance("list");e||(e=new V({onListSelect:t=>{R.applyListToCurrentSelection(t,this.editorId)},editor:t,editorId:this.editorId}),t.setPopupInstance("list",e)),this.listPicker=e}static createForEditor(t){const e=n.getInstanceById(t);if(!e)return null;const i=n.currentInstance;n.currentInstance=e;const s=new R;return n.currentInstance=i,s}static create(t){let e;switch(t){case"ordered":e=document.createElement("OL"),e.style.listStyleType="decimal";break;case"roman":e=document.createElement("OL"),e.style.listStyleType="upper-roman";break;case"alpha":e=document.createElement("OL"),e.style.listStyleType="lower-alpha";break;default:e=document.createElement("UL"),e.style.listStyleType="disc"}return e}static applyListToCurrentSelection(t,e=null){let i=null;if(i=e?n.getInstanceById(e):n.getCurrentInstance(),!i)return;const s=window.getSelection();if(s&&s.rangeCount){r();try{const n=s.getRangeAt(0),i=R.getSelectedBlockElements(n);0===i.length?R.createListFromSelection(t):R.convertBlocksToList(i,t),R.updateToolbarButtonIcon(t,e)}catch(t){}setTimeout(()=>{i&&"function"==typeof i.onContentChange&&i.onContentChange()},0)}}static createListFromSelection(t){const e=window.getSelection();if(!e||!e.rangeCount)return;const n=e.getRangeAt(0),i=n.toString()||"List item",s=R.create(t),o=document.createElement("LI");if(n.toString()===n.cloneContents().textContent)o.textContent=i;else{const t=n.cloneContents();o.appendChild(t)}const r=R.getBlockElement(n.startContainer);r&&r.style&&r.style.cssText&&(o.style.cssText=r.style.cssText),s.appendChild(o),n.deleteContents(),n.insertNode(s);const l=document.createRange();l.selectNodeContents(o),l.collapse(!1),e.removeAllRanges(),e.addRange(l)}static convertBlocksToList(t,e){if(0===t.length)return;const n=R.getParentList(t[0]);if(n)return void R.toggleOrChangeListType(n,e);const i=R.create(e),s=t[0];s.parentNode.insertBefore(i,s);let o=null;if(t.forEach((t,e)=>{const n=document.createElement("LI");n.innerHTML=t.innerHTML||t.textContent||"",t.style&&t.style.cssText&&(n.style.cssText=t.style.cssText),i.appendChild(n),t.remove(),0===e&&(o=n)}),o){const t=document.createRange(),e=window.getSelection();t.selectNodeContents(o),t.collapse(!1),e.removeAllRanges(),e.addRange(t)}}static toggleOrChangeListType(t,e){R.getListType(t)===e?R.removeListFormatting(t):R.changeListType(t,e)}static getListType(t){if("OL"===t.tagName){const e=t.style.listStyleType;return"upper-roman"===e?"roman":"lower-alpha"===e?"alpha":"ordered"}return"bullet"}static changeListType(t,e){const n=R.create(e);if(Array.from(t.children).forEach(t=>{const e=document.createElement("LI");e.innerHTML=t.innerHTML||t.textContent||"",t.style&&t.style.cssText&&(e.style.cssText=t.style.cssText),n.appendChild(e)}),t.parentNode.replaceChild(n,t),n.firstElementChild){const t=document.createRange(),e=window.getSelection();t.selectNodeContents(n.firstElementChild),t.collapse(!1),e.removeAllRanges(),e.addRange(t)}}static removeListFormatting(t){const e=t.parentNode;let n=null;if(Array.from(t.children).forEach((i,s)=>{const o=document.createElement("P");o.innerHTML=i.innerHTML||i.textContent||"",i.style&&i.style.cssText&&(o.style.cssText=i.style.cssText),e.insertBefore(o,t),0===s&&(n=o)}),t.remove(),n){const t=document.createRange(),e=window.getSelection();t.selectNodeContents(n),t.collapse(!1),e.removeAllRanges(),e.addRange(t)}}static getParentList(t){let e=t;for(;e&&e!==document.body;){if("UL"===e.tagName||"OL"===e.tagName)return e;e=e.parentElement}return null}static getIconNameForListType(t){return{bullet:"list-bullet",ordered:"list-ordered",roman:"list-roman",alpha:"list-alpha"}[t]||"list-bullet"}static updateToolbarButtonIcon(t,e=null){let i=null;if(i=e?n.getInstanceById(e):n.getCurrentInstance(),!i)return;const s=i.getModule("toolbar");let o=null;if(s&&(o=s.getButton("list")),!o){const t=s?.getContainer();t&&(o=t.querySelector(".rich-editor-toolbar-btn.list-btn"))}if(o||(o=i.wrapper.querySelector(".rich-editor-toolbar-btn.list-btn")),!o)return;const r=R.getIconNameForListType(t);o.title={bullet:"Bullet List",ordered:"Numbered List",roman:"Roman Numerals List",alpha:"Alphabetical List"}[t]||"List";const l=m.getIcon(r);if(l){const t=o.querySelector(".icon");t?t.innerHTML=l:o.innerHTML=`<span class="icon">${l}</span>`}}static getSelectedBlockElements(t){const e=[],n=t.startContainer,i=t.endContainer,s=R.getBlockElement(n);if(s&&e.push(s),n!==i){let t=s;for(;t&&t!==i;){const n=R.getNextBlockElement(t);if(!n||e.includes(n))break;e.push(n),t=n}const n=R.getBlockElement(i);n&&!e.includes(n)&&e.push(n)}return e}static getBlockElement(t){if(!t)return null;let e=t;for(;e&&e!==document.body;){if(e.nodeType===Node.ELEMENT_NODE){const t=e.tagName;if(["P","DIV","H1","H2","H3","H4","H5","H6","BLOCKQUOTE","LI"].includes(t))return e}e=e.parentNode}return null}static getNextBlockElement(t){let e=t.nextSibling;for(;e;){if(e.nodeType===Node.ELEMENT_NODE){const t=e.tagName;if(["P","DIV","H1","H2","H3","H4","H5","H6","BLOCKQUOTE","LI"].includes(t))return e}e=e.nextSibling}return null}apply(t="bullet"){R.applyListToCurrentSelection(t,this.editorId)}remove(){const t=window.getSelection();if(!t||!t.rangeCount)return;const e=t.getRangeAt(0),n=R.getParentList(e.commonAncestorContainer);n&&R.removeListFormatting(n)}toggle(){this.listPicker.isVisible?this.listPicker.hide():this.showListPicker()}showListPicker(){const t=n.getInstanceById(this.editorId);if(!t)return;const e=t.getModule("toolbar");let i=null;if(e&&(i=e.getButton("list")),!i){const t=e?.getContainer();t&&(i=t.querySelector(".rich-editor-toolbar-btn.list-btn"))}i||(i=t.wrapper.querySelector(".rich-editor-toolbar-btn.list-btn")),i&&this.listPicker.show(i)}isActive(t=null){const e=R.getCurrentListType();return e?R.updateToolbarButtonIcon(e,this.editorId):R.updateToolbarButtonIcon("bullet",this.editorId),!1}static getCurrentListType(){const t=window.getSelection();if(!t||!t.rangeCount)return null;const e=t.getRangeAt(0),n=R.getParentList(e.commonAncestorContainer);return n?R.getListType(n):null}getCurrentListType(){return R.getCurrentListType()}}class O extends o{static formatName="indent";static tagName="DIV";static attribute="style";constructor(){super()}static create(t){const e=document.createElement("DIV");return t&&(e.style.paddingLeft=t),e}static applyIndentToCurrentSelection(t){const e=window.getSelection();if(e&&e.rangeCount){r();try{const n=e.getRangeAt(0),i=O.getSelectedBlockElements(n);if(0===i.length){const i=document.createElement("DIV");i.style.paddingLeft="increase"===t?"20px":"0px";const s=n.toString()||"";s?(i.textContent=s,n.deleteContents(),n.insertNode(i)):(n.insertNode(i),i.innerHTML="<br>");const o=document.createRange();o.selectNodeContents(i),o.collapse(!1),e.removeAllRanges(),e.addRange(o)}else i.forEach(e=>{O.applyIndentToBlock(e,t)})}catch(t){}setTimeout(()=>{const t=n.getCurrentInstance();t&&"function"==typeof t.onContentChange&&t.onContentChange()},0)}}static applyIndentToBlock(t,e){if(!t||!t.style)return;const n=parseInt(t.style.paddingLeft)||0;let i;i="increase"===e?n+20:Math.max(0,n-20),t.style.paddingLeft=0===i?"":i+"px"}static getSelectedBlockElements(t){const e=[],n=t.startContainer,i=t.endContainer,s=O.getBlockElement(n);if(s&&e.push(s),n!==i){let t=s;for(;t&&t!==i;){const n=O.getNextBlockElement(t);if(!n||e.includes(n))break;e.push(n),t=n}const n=O.getBlockElement(i);n&&!e.includes(n)&&e.push(n)}return e}static getBlockElement(t){if(!t)return null;let e=t;for(;e&&e!==document.body;){if(e.nodeType===Node.ELEMENT_NODE){const t=e.tagName;if(["P","DIV","H1","H2","H3","H4","H5","H6","BLOCKQUOTE","LI"].includes(t))return e}e=e.parentNode}return null}static getNextBlockElement(t){let e=t.nextSibling;for(;e;){if(e.nodeType===Node.ELEMENT_NODE){const t=e.tagName;if(["P","DIV","H1","H2","H3","H4","H5","H6","BLOCKQUOTE","LI"].includes(t))return e}e=e.nextSibling}return null}apply(t="increase"){O.applyIndentToCurrentSelection(t)}remove(){O.applyIndentToCurrentSelection("remove")}isActive(){const t=window.getSelection();if(!t||!t.rangeCount)return!1;const e=t.getRangeAt(0),n=O.getBlockElement(e.commonAncestorContainer);if(!n)return!1;return(parseInt(n.style.paddingLeft)||0)>0}static getCurrentIndentLevel(){const t=window.getSelection();if(!t||!t.rangeCount)return 0;const e=t.getRangeAt(0),n=O.getBlockElement(e.commonAncestorContainer);return n&&parseInt(n.style.paddingLeft)||0}getCurrentIndentLevel(){return O.getCurrentIndentLevel()}}class z extends O{static formatName="indent-increase";apply(){O.applyIndentToCurrentSelection("increase")}toggle(){this.apply()}isActive(){return!1}}class F extends O{static formatName="indent-decrease";apply(){O.applyIndentToCurrentSelection("decrease")}toggle(){this.apply()}isActive(){return!1}}class _{constructor(t={}){this.options={emojis:["😀","😁","😂","🤣","😃","😄","😅","😆","😉","😊","😋","😎","😍","🥰","😘","😗","😙","😚","🙂","🤗","😳","🥺","😦","😧","😨","😰","😥","😢","😭","😱","🤬","😈","👿","💀","☠️","💩","🤡","👹","👺","👻"],onEmojiSelect:null,...t},this.popup=null,this.isVisible=!1,this.clickOutsideHandler=null,this.createEmojiPicker()}detectOS(){const t=navigator.platform.toLowerCase();return t.includes("mac")?"mac":(t.includes("win"),"windows")}getEmojiShortcutMessage(){return"mac"===this.detectOS()?'<div style="color: rgb(113, 120, 124); font-style: normal; font-weight: 400; line-height: normal; text-align: center;">Get more emojis with <span style="border-radius: 2.2px; background: #EEE; padding: 2px 4px;">⌘</span> <span style="color: #000;">+</span> <span style="border-radius: 2.2px; background: #EEE; padding: 2px 4px;">CTRL</span> <span style="color: #000;">+</span> <span style="border-radius: 2.2px; background: #EEE; padding: 2px 4px;">SPACE</span></div>':'<div style="color: rgb(113, 120, 124); font-style: normal; font-weight: 400; line-height: normal; text-align: center;">Get more emojis with <span style="border-radius: 2.2px; background: #EEE; padding: 2px 4px;">WIN</span> <span style="color: #000;">+</span> <span style="border-radius: 2.2px; background: #EEE; padding: 2px 4px;">.</span></div>'}createEmojiPicker(){this.popup=document.createElement("div"),this.popup.className="emoji-picker-popup",this.createEmojiGrid();const t=document.createElement("div");t.className="emoji-text-message",t.innerHTML=this.getEmojiShortcutMessage(),this.popup.appendChild(t),C(this.popup)}createEmojiGrid(){const t=document.createElement("div");t.className="emoji-grid",this.options.emojis.forEach(e=>{const n=document.createElement("button");n.type="button",n.className="emoji-button",n.textContent=e,n.title=e,n.addEventListener("click",t=>{t.preventDefault(),t.stopPropagation(),this.selectEmoji(e)}),t.appendChild(n)}),this.popup.appendChild(t)}setupClickOutside(){this.clickOutsideHandler&&document.removeEventListener("click",this.clickOutsideHandler),this.clickOutsideHandler=t=>{this.popup.contains(t.target)||this.hide()},setTimeout(()=>{document.addEventListener("click",this.clickOutsideHandler)},100)}removeClickOutside(){this.clickOutsideHandler&&(document.removeEventListener("click",this.clickOutsideHandler),this.clickOutsideHandler=null)}show(t){if(!t)return;document.body.contains(this.popup)||C(this.popup);const e=b(t,this.popup,{offsetY:5,offsetX:0});y(this.popup,e),this.popup.classList.add("visible"),this.isVisible=!0,this.setupClickOutside()}hide(){this.popup.classList.remove("visible"),this.isVisible=!1,this.removeClickOutside()}selectEmoji(t){this.options.onEmojiSelect&&this.options.onEmojiSelect(t),this.hide()}destroy(){this.removeClickOutside(),this.popup&&this.popup.parentNode&&this.popup.parentNode.removeChild(this.popup),this.popup=null,this.isVisible=!1}}class D extends s{static formatName="emoji";static tagName="SPAN";static className="emoji";constructor(){super();const t=n.getCurrentInstance();if(!t)return;this.editorId=t.instanceId;let e=t.getPopupInstance("emoji");e||(e=new _({onEmojiSelect:t=>{D.insertEmojiAtCurrentPosition(t,this.editorId)},editor:t,editorId:this.editorId}),t.setPopupInstance("emoji",e)),this.emojiPicker=e}static createForEditor(t){const e=n.getInstanceById(t);if(!e)return null;const i=n.currentInstance;n.currentInstance=e;const s=new D;return n.currentInstance=i,s}static create(t){const e=document.createElement("SPAN");return e.className="emoji",e.textContent=t,e.setAttribute("data-emoji",t),e}static insertEmojiAtCurrentPosition(t,e=null){let i=null;if(i=e?n.getInstanceById(e):n.getCurrentInstance(),!i)return;const s=window.getSelection();if(s&&s.rangeCount)try{const e=s.getRangeAt(0);let n=e.startContainer,o=null;for(n.nodeType===Node.TEXT_NODE&&(n=n.parentNode);n&&n!==i.element;){if(n.classList&&n.classList.contains("emoji")){o=n;break}n=n.parentNode}o&&(e.setStartAfter(o),e.collapse(!0),s.removeAllRanges(),s.addRange(e));const r=D.create(t);e.deleteContents(),e.insertNode(r);const l=document.createTextNode("​");e.setStartAfter(r),e.insertNode(l),e.setStartAfter(l),e.collapse(!0),s.removeAllRanges(),s.addRange(e),i&&"function"==typeof i.onContentChange&&i.onContentChange()}catch(t){}}apply(t){t?D.insertEmojiAtCurrentPosition(t,this.editorId):this.showEmojiPicker()}remove(){const t=window.getSelection();if(!t||!t.rangeCount)return;const e=t.getRangeAt(0),n=this.getEmojiElement(e);if(n){const t=document.createTextNode(n.textContent);n.parentNode.replaceChild(t,n)}}toggle(){this.emojiPicker.isVisible?this.emojiPicker.hide():this.showEmojiPicker()}showEmojiPicker(){const t=n.getInstanceById(this.editorId);if(!t)return;const e=t.getModule("toolbar");let i=null;if(e&&(i=e.getButton("emoji")),!i){const t=e?.getContainer();t&&(i=t.querySelector(".rich-editor-toolbar-btn.emoji-btn"))}i||(i=t.wrapper.querySelector(".rich-editor-toolbar-btn.emoji-btn")),i&&this.emojiPicker.show(i)}isActive(){const t=window.getSelection();if(!t||!t.rangeCount)return!1;const e=t.getRangeAt(0);return null!==this.getEmojiElement(e)}getEmojiElement(t){let e=t.commonAncestorContainer;if(e.nodeType===Node.TEXT_NODE&&(e=e.parentNode),e.classList&&e.classList.contains("emoji"))return e;const n=t.cloneContents().querySelector(".emoji");return n||null}}class j{constructor(t={}){this.options={onImageInsert:null,editor:null,...t},this.popup=null,this.isVisible=!1,this.clickOutsideHandler=null,this.selectedImageSrc=null,this.savedSelection=null,this.resizeHandler=null,this.createImagePopup()}createImagePopup(){this.popup=document.createElement("div"),this.popup.className="image-popup";const t=document.createElement("div");t.className="image-popup-content";const e=document.createElement("h3");e.textContent="Upload image",e.className="yjd-input-title",t.appendChild(e);const n=document.createElement("div");n.className="image-input-container";const i=document.createElement("p");i.textContent="Your image url",i.className="yjd-input-label";const s=document.createElement("div");s.className="yjd-input-upload-group",this.inputGroup=s,this.urlInput=document.createElement("input"),this.urlInput.type="url",this.urlInput.className="yjd-input",this.urlInput.placeholder="Please enter your image URL",this.fileInput=document.createElement("input"),this.fileInput.type="file",this.fileInput.accept="image/*",this.fileInput.className="image-input-hidden",this.fileInput.addEventListener("change",t=>this.handleFileSelect(t));const o=document.createElement("button");o.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" width="17" height="17" viewBox="0 0 17 17" fill="none">\n <g clip-path="url(#clip0_243_650)">\n <path d="M9.45721 4.06101V11.4287C9.45721 11.966 9.02311 12.4001 8.48578 12.4001C7.94846 12.4001 7.51436 11.966 7.51436 11.4287V4.06101L5.28614 6.28923C4.90668 6.66869 4.29043 6.66869 3.91096 6.28923C3.5315 5.90976 3.5315 5.29351 3.91096 4.91405L7.79668 1.02833C8.17614 0.64887 8.79239 0.64887 9.17186 1.02833L13.0576 4.91405C13.437 5.29351 13.437 5.90976 13.0576 6.28923C12.6781 6.66869 12.0619 6.66869 11.6824 6.28923L9.45721 4.06101ZM2.65721 11.4287H6.54293C6.54293 12.5003 7.41418 13.3715 8.48578 13.3715C9.55739 13.3715 10.4286 12.5003 10.4286 11.4287H14.3144C15.386 11.4287 16.2572 12.2999 16.2572 13.3715V14.343C16.2572 15.4146 15.386 16.2858 14.3144 16.2858H2.65721C1.58561 16.2858 0.714355 15.4146 0.714355 14.343V13.3715C0.714355 12.2999 1.58561 11.4287 2.65721 11.4287ZM13.8286 14.5858C14.0219 14.5858 14.2072 14.5091 14.3438 14.3724C14.4805 14.2358 14.5572 14.0505 14.5572 13.8573C14.5572 13.664 14.4805 13.4787 14.3438 13.3421C14.2072 13.2055 14.0219 13.1287 13.8286 13.1287C13.6354 13.1287 13.4501 13.2055 13.3135 13.3421C13.1768 13.4787 13.1001 13.664 13.1001 13.8573C13.1001 14.0505 13.1768 14.2358 13.3135 14.3724C13.4501 14.5091 13.6354 14.5858 13.8286 14.5858Z" fill="#252424"/>\n </g>\n <defs>\n <clipPath id="clip0_243_650">\n <rect width="15.5429" height="15.5429" fill="white" transform="translate(0.714355 0.742859)"/>\n </clipPath>\n </defs>\n </svg>',o.className="yjd-custom-upload-button",this.customButton=o,o.addEventListener("click",()=>this.fileInput.click()),this.createPreviewContainer(),s.appendChild(this.urlInput),s.appendChild(this.fileInput),s.appendChild(o),n.appendChild(i),n.appendChild(s),n.appendChild(this.previewContainer),t.appendChild(n),this.urlInput.addEventListener("input",()=>{this.updateInsertButton();const t=this.urlInput.value.trim();t&&this.isValidImageUrl(t)?this.showPreview(t):this.removePreview(),this.urlInput.value.trim()?this.customButton.style.display="none":this.customButton.style.display="flex"});const r=document.createElement("div");r.className="yjd-button-container";const l=document.createElement("button");l.type="button",l.className="image-button yjd-button-cancel",l.textContent="Cancel",l.addEventListener("click",()=>{this.hide(),this.options.editor&&setTimeout(()=>this.options.editor.focus(),0)}),this.insertButton=document.createElement("button"),this.insertButton.type="button",this.insertButton.className="image-button yjd-button-confirm button-disable",this.insertButton.textContent="Add image",this.insertButton.disabled=!0,this.insertButton.addEventListener("click",()=>{this.insertImage(),this.options.editor&&setTimeout(()=>this.options.editor.focus(),0)}),r.appendChild(l),r.appendChild(this.insertButton),t.appendChild(r),this.popup.appendChild(t),C(this.popup),this.options.editor&&"function"==typeof this.options.editor.preventFocusLoss&&this.options.editor.preventFocusLoss(this.popup)}async handleFileSelect(t){const e=t.target.files[0];if(e)try{const{default:t}=await Promise.resolve().then(function(){return U});this.selectedImageSrc=await t.handleFileUpload(e),this.urlInput.value="",this.showPreview(this.selectedImageSrc),this.updateInsertButton()}catch(t){alert(t.message)}}updateInsertButton(){const t=this.selectedImageSrc||this.urlInput.value.trim();this.insertButton.disabled=!t,this.insertButton.classList.toggle("button-disable",!t)}showPreview(t){t&&(this.imagePreview.src=t,this.previewContainer.style.display="block",this.selectedImageSrc=t,this.toggleInputGroup(!1),this.recalculatePosition())}removePreview(){this.selectedImageSrc=null,this.previewContainer.style.display="none",this.imagePreview.src="",this.toggleInputGroup(!0),this.fileInput&&(this.fileInput.value=""),this.updateInsertButton(),this.recalculatePosition()}toggleInputGroup(t){this.inputGroup&&(t?(this.inputGroup.style.display="flex",this.inputGroup.style.visibility="visible",this.customButton&&(this.customButton.style.pointerEvents="auto")):(this.inputGroup.style.display="none",this.inputGroup.style.visibility="hidden"))}createPreviewContainer(){this.previewContainer=document.createElement("div"),this.previewContainer.className="image-preview-container",this.previewContainer.style.cssText="display: none; position: relative;",this.imagePreview=document.createElement("img"),this.imagePreview.className="image-preview",this.imagePreview.style.cssText="max-width: 100%; max-height: 200px; border-radius: 8px; object-fit: contain;",this.removeButton=document.createElement("button"),this.removeButton.className="image-remove-button",this.removeButton.innerHTML="×",this.removeButton.style.cssText="\n position: absolute; top: 5px; right: 5px; background: rgba(0,0,0,0.7);\n color: white; border: none; border-radius: 50%; width: 24px; height: 24px;\n cursor: pointer; font-size: 16px; font-weight: bold;\n ",this.removeButton.addEventListener("click",()=>this.removePreview()),this.previewContainer.appendChild(this.imagePreview),this.previewContainer.appendChild(this.removeButton)}isValidImageUrl(t){try{const e=new URL(t),n=[".jpg",".jpeg",".png",".gif",".webp",".svg",".bmp"],i=["imgur.com","images.unsplash.com","picsum.photos","via.placeholder.com"],s=e.pathname.toLowerCase(),o=n.some(t=>s.endsWith(t)),r=i.some(t=>e.hostname.includes(t));return o||r}catch{return!1}}async insertImage(){let t=this.selectedImageSrc||this.urlInput.value.trim();if(t){try{const{default:e}=await Promise.resolve().then(function(){return U});if(!await e.validateImageUrl(t))return void alert("Invalid image URL. Please check the URL and try again.")}catch(t){return void alert("Error validating image URL.")}this.restoreSelection(),this.options.onImageInsert&&this.options.onImageInsert(t,""),this.hide(),this.reset()}}reset(){this.fileInput.value="",this.urlInput.value="",this.selectedImageSrc=null,this.previewContainer.style.display="none",this.imagePreview.src="",this.toggleInputGroup(!0),this.updateInsertButton(),this.customButton.style.display="block"}saveSelection(){const t=window.getSelection();t&&t.rangeCount>0&&(this.savedSelection=t.getRangeAt(0).cloneRange())}restoreSelection(){if(this.savedSelection){const t=window.getSelection();t.removeAllRanges(),t.addRange(this.savedSelection)}}setupClickOutside(){this.clickOutsideHandler&&document.removeEventListener("click",this.clickOutsideHandler),this.clickOutsideHandler=t=>{this.popup.contains(t.target)||this.hide()},setTimeout(()=>{document.addEventListener("click",this.clickOutsideHandler)},100)}setupResizeHandler(){this.resizeHandler&&window.removeEventListener("resize",this.resizeHandler),this.resizeHandler=()=>{this.isVisible&&this.recalculatePosition()},window.addEventListener("resize",this.resizeHandler)}removeResizeHandler(){this.resizeHandler&&(window.removeEventListener("resize",this.resizeHandler),this.resizeHandler=null)}removeClickOutside(){this.clickOutsideHandler&&(document.removeEventListener("click",this.clickOutsideHandler),this.clickOutsideHandler=null)}show(t){if(!t)return;this.saveSelection(),this.reset(),this.currentAnchor=t;const e=b(t,this.popup,{offsetY:5,offsetX:0});y(this.popup,e),this.popup.classList.add("visible"),this.isVisible=!0,this.setupClickOutside()}recalculatePosition(){this.currentAnchor&&this.isVisible&&setTimeout(()=>{const t=b(this.currentAnchor,this.popup,{offsetY:5,offsetX:0});y(this.popup,t)},10)}hide(){this.popup.classList.remove("visible"),this.isVisible=!1,this.removeClickOutside(),this.savedSelection=null}destroy(){this.removeClickOutside(),this.popup&&this.popup.parentNode&&this.popup.parentNode.removeChild(this.popup),this.popup=null,this.isVisible=!1}}class Z extends s{static formatName="image";static tagName="IMG";static className="inserted-image";constructor(){super();const t=n.getCurrentInstance();if(!t)return;this.editorId=t.instanceId;let e=t.getPopupInstance("image");e||(e=new j({onImageInsert:(t,e)=>{Z.insertImageAtCurrentPosition(t,e,this.editorId)},editor:t,editorId:this.editorId}),t.setPopupInstance("image",e)),this.imagePopup=e}static createForEditor(t){const e=n.getInstanceById(t);if(!e)return null;const i=n.currentInstance;n.currentInstance=e;const s=new Z;return n.currentInstance=i,s}static create(t,e=""){const n=document.createElement("IMG");return n.src=t,n.alt=e||"Inserted image",n.className="inserted-image",n.style.maxWidth="100%",n.style.height="auto",n.setAttribute("contenteditable","false"),n}static insertImageAtCurrentPosition(t,e="",i=null){let s=null;if(s=i?n.getInstanceById(i):n.getCurrentInstance(),!s)return;const o=window.getSelection();if(o&&o.rangeCount){try{const n=o.getRangeAt(0),i=Z.create(t,e);n.deleteContents(),n.insertNode(i);const r=document.createTextNode(" ");n.setStartAfter(i),n.insertNode(r),n.setStartAfter(r),n.collapse(!0),o.removeAllRanges(),o.addRange(n),s&&"function"==typeof s.onContentChange&&s.onContentChange()}catch(t){}setTimeout(()=>{const t=n.getCurrentInstance();t&&"function"==typeof t.onContentChange&&t.onContentChange()},0)}}apply(t,e){t?Z.insertImageAtCurrentPosition(t,e,this.editorId):this.showImagePopup()}remove(){const t=window.getSelection();if(!t||!t.rangeCount)return;const e=t.getRangeAt(0),n=this.getImageElement(e);n&&n.remove()}toggle(){this.imagePopup.isVisible?this.imagePopup.hide():this.showImagePopup()}showImagePopup(){const t=n.getInstanceById(this.editorId);if(!t)return;const e=t.getModule("toolbar");let i=null;if(e&&(i=e.getButton("image")),!i){const t=e?.getContainer();t&&(i=t.querySelector(".rich-editor-toolbar-btn.image-btn"))}i||(i=t.wrapper.querySelector(".rich-editor-toolbar-btn.image-btn")),i&&this.imagePopup.show(i)}isActive(){const t=window.getSelection();if(!t||!t.rangeCount)return!1;const e=t.getRangeAt(0);return null!==this.getImageElement(e)}getImageElement(t){let e=t.commonAncestorContainer;if(e.nodeType===Node.TEXT_NODE&&(e=e.parentNode),"IMG"===e.tagName&&e.classList&&e.classList.contains("inserted-image"))return e;const n=t.cloneContents().querySelector(".inserted-image");return n||null}static async handleFileUpload(t){return new Promise((e,n)=>{if(!t||!t.type.startsWith("image/"))return void n(new Error("Please select a valid image file"));const i=new FileReader;i.onload=t=>{e(t.target.result)},i.onerror=()=>{n(new Error("Failed to read file"))},i.readAsDataURL(t)})}static validateImageUrl(t){return new Promise(e=>{const n=["jpg","jpeg","png","gif","bmp","webp","svg"].some(e=>t.toLowerCase().includes(`.${e}`));if(t.startsWith("data:image/"))return void e(!0);if(!/^https?:\/\//.test(t))return void e(!1);if(n)return void e(!0);const i=new Z;i.onload=()=>{e(!0)},i.onerror=()=>{t.includes("imgur.com")||t.includes("drive.google.com")||n?e(!0):e(!1)},setTimeout(()=>{n||t.includes("imgur.com")||t.includes("drive.google.com")?e(!0):e(!1)},5e3),i.src=t})}}var U=Object.freeze({__proto__:null,default:Z});class q{constructor(t={}){this.options={onVideoInsert:null,editor:null,...t},this.popup=null,this.isVisible=!1,this.clickOutsideHandler=null,this.selectedVideoSrc=null,this.savedSelection=null,this.createVideoPopup()}createVideoPopup(){this.popup=document.createElement("div"),this.popup.className="video-popup";const t=document.createElement("div");t.className="video-popup-content";const e=document.createElement("h3");e.textContent="Upload video",e.className="yjd-input-title",t.appendChild(e);const n=document.createElement("div");n.className="video-input-container";const i=document.createElement("p");i.textContent="Your video url",i.className="yjd-input-label";const s=document.createElement("div");s.className="yjd-input-upload-group",this.inputGroup=s,this.urlInput=document.createElement("input"),this.urlInput.type="url",this.urlInput.className="yjd-input",this.urlInput.placeholder="Please enter your video URL",this.urlInput.addEventListener("input",()=>{this.updateInsertButton();const t=this.urlInput.value.trim();t&&this.isValidVideoUrl(t)?this.showPreview(t):this.removePreview(),this.urlInput.value.trim()?this.customButton.style.display="none":this.customButton.style.display="block"}),this.fileInput=document.createElement("input"),this.fileInput.type="file",this.fileInput.accept="video/*",this.fileInput.className="image-input-hidden",this.fileInput.addEventListener("change",t=>this.handleFileSelect(t));const o=document.createElement("button");o.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" width="17" height="17" viewBox="0 0 17 17" fill="none">\n <g clip-path="url(#clip0_243_650)">\n <path d="M9.45721 4.06101V11.4287C9.45721 11.966 9.02311 12.4001 8.48578 12.4001C7.94846 12.4001 7.51436 11.966 7.51436 11.4287V4.06101L5.28614 6.28923C4.90668 6.66869 4.29043 6.66869 3.91096 6.28923C3.5315 5.90976 3.5315 5.29351 3.91096 4.91405L7.79668 1.02833C8.17614 0.64887 8.79239 0.64887 9.17186 1.02833L13.0576 4.91405C13.437 5.29351 13.437 5.90976 13.0576 6.28923C12.6781 6.66869 12.0619 6.66869 11.6824 6.28923L9.45721 4.06101ZM2.65721 11.4287H6.54293C6.54293 12.5003 7.41418 13.3715 8.48578 13.3715C9.55739 13.3715 10.4286 12.5003 10.4286 11.4287H14.3144C15.386 11.4287 16.2572 12.2999 16.2572 13.3715V14.343C16.2572 15.4146 15.386 16.2858 14.3144 16.2858H2.65721C1.58561 16.2858 0.714355 15.4146 0.714355 14.343V13.3715C0.714355 12.2999 1.58561 11.4287 2.65721 11.4287ZM13.8286 14.5858C14.0219 14.5858 14.2072 14.5091 14.3438 14.3724C14.4805 14.2358 14.5572 14.0505 14.5572 13.8573C14.5572 13.664 14.4805 13.4787 14.3438 13.3421C14.2072 13.2055 14.0219 13.1287 13.8286 13.1287C13.6354 13.1287 13.4501 13.2055 13.3135 13.3421C13.1768 13.4787 13.1001 13.664 13.1001 13.8573C13.1001 14.0505 13.1768 14.2358 13.3135 14.3724C13.4501 14.5091 13.6354 14.5858 13.8286 14.5858Z" fill="#252424"/>\n </g>\n <defs>\n <clipPath id="clip0_243_650">\n <rect width="15.5429" height="15.5429" fill="white" transform="translate(0.714355 0.742859)"/>\n </clipPath>\n </defs>\n </svg>',o.className="yjd-custom-upload-button",this.customButton=o,o.addEventListener("click",()=>this.fileInput.click()),this.createPreviewContainer(),s.appendChild(this.urlInput),s.appendChild(this.fileInput),s.appendChild(o),n.appendChild(i),n.appendChild(s),n.appendChild(this.previewContainer),t.appendChild(n);const r=document.createElement("div");r.className="yjd-button-container";const l=document.createElement("button");l.type="button",l.className="image-button yjd-button-cancel",l.textContent="Cancel",l.addEventListener("click",()=>{this.hide(),this.options.editor&&setTimeout(()=>this.options.editor.focus(),0)}),this.insertButton=document.createElement("button"),this.insertButton.type="button",this.insertButton.className="image-button yjd-button-confirm button-disable",this.insertButton.textContent="Add video",this.insertButton.disabled=!0,this.insertButton.addEventListener("click",()=>{this.insertVideo(),this.options.editor&&setTimeout(()=>this.options.editor.focus(),0)}),r.appendChild(l),r.appendChild(this.insertButton),t.appendChild(r),this.popup.appendChild(t),C(this.popup),this.options.editor&&"function"==typeof this.options.editor.preventFocusLoss&&this.options.editor.preventFocusLoss(this.popup)}async handleFileSelect(t){const e=t.target.files[0];if(e)try{const{default:t}=await Promise.resolve().then(function(){return X});this.selectedVideoSrc=await t.handleFileUpload(e),this.urlInput.value="",this.showPreview(this.selectedVideoSrc),this.updateInsertButton()}catch(t){alert(t.message)}}updateInsertButton(){const t=this.selectedVideoSrc||this.urlInput.value.trim();this.insertButton.disabled=!t,this.insertButton.classList.toggle("button-disable",!t)}showPreview(t){t&&(this.videoPreview.src=t,this.previewContainer.style.display="block",this.selectedVideoSrc=t,this.toggleInputGroup(!1),this.recalculatePosition())}removePreview(){this.selectedVideoSrc=null,this.previewContainer.style.display="none",this.videoPreview.src="",this.toggleInputGroup(!0),this.fileInput&&(this.fileInput.value=""),this.updateInsertButton(),this.recalculatePosition()}toggleInputGroup(t){this.inputGroup&&(t?(this.inputGroup.style.display="flex",this.inputGroup.style.visibility="visible",this.customButton&&(this.customButton.style.pointerEvents="auto")):(this.inputGroup.style.display="none",this.inputGroup.style.visibility="hidden"))}createPreviewContainer(){this.previewContainer=document.createElement("div"),this.previewContainer.className="video-preview-container",this.previewContainer.style.cssText="display: none; position: relative;",this.videoPreview=document.createElement("video"),this.videoPreview.className="video-preview",this.videoPreview.style.cssText="max-width: 100%; max-height: 200px; border-radius: 8px; object-fit: contain;",this.videoPreview.controls=!0,this.videoPreview.muted=!0,this.removeButton=document.createElement("button"),this.removeButton.className="video-remove-button",this.removeButton.innerHTML="×",this.removeButton.style.cssText="\n position: absolute; top: 5px; right: 5px; background: rgba(0,0,0,0.7);\n color: white; border: none; border-radius: 50%; width: 24px; height: 24px;\n cursor: pointer; font-size: 16px; font-weight: bold;\n ",this.removeButton.addEventListener("click",()=>this.removePreview()),this.previewContainer.appendChild(this.videoPreview),this.previewContainer.appendChild(this.removeButton)}isValidVideoUrl(t){try{const e=new URL(t),n=[".mp4",".webm",".ogg",".mov",".avi",".mkv"],i=["youtube.com","youtu.be","vimeo.com","dailymotion.com"],s=e.pathname.toLowerCase(),o=n.some(t=>s.endsWith(t)),r=i.some(t=>e.hostname.includes(t));return o||r}catch{return!1}}async insertVideo(){let t=this.selectedVideoSrc||this.urlInput.value.trim();if(t){try{const{default:e}=await Promise.resolve().then(function(){return X});if(!await e.validateVideoUrl(t))return void alert("Invalid video URL. Please check the URL and try again.")}catch(t){return void alert("Error validating video URL.")}this.restoreSelection(),this.options.onVideoInsert&&this.options.onVideoInsert(t),this.hide(),this.reset()}}reset(){this.fileInput.value="",this.urlInput.value="",this.selectedVideoSrc=null,this.previewContainer.style.display="none",this.videoPreview.src="",this.toggleInputGroup(!0),this.updateInsertButton(),this.customButton.style.display="block"}saveSelection(){const t=window.getSelection();t&&t.rangeCount>0&&(this.savedSelection=t.getRangeAt(0).cloneRange())}restoreSelection(){if(this.savedSelection){const t=window.getSelection();t.removeAllRanges(),t.addRange(this.savedSelection)}}setupClickOutside(){this.clickOutsideHandler&&document.removeEventListener("click",this.clickOutsideHandler),this.clickOutsideHandler=t=>{this.popup.contains(t.target)||this.hide()},setTimeout(()=>{document.addEventListener("click",this.clickOutsideHandler)},100)}removeClickOutside(){this.clickOutsideHandler&&(document.removeEventListener("click",this.clickOutsideHandler),this.clickOutsideHandler=null)}show(t){if(!t)return;this.saveSelection(),this.reset(),this.currentAnchor=t;const e=b(t,this.popup,{offsetY:5,offsetX:0});y(this.popup,e),this.popup.classList.add("visible"),this.isVisible=!0,this.setupClickOutside()}recalculatePosition(){this.currentAnchor&&this.isVisible&&setTimeout(()=>{const t=b(this.currentAnchor,this.popup,{offsetY:5,offsetX:0});y(this.popup,t)},10)}hide(){this.popup.classList.remove("visible"),this.isVisible=!1,this.removeClickOutside(),this.savedSelection=null}destroy(){this.removeClickOutside(),this.popup&&this.popup.parentNode&&this.popup.parentNode.removeChild(this.popup),this.popup=null,this.isVisible=!1}}class W extends s{static formatName="video";static tagName="VIDEO";static className="inserted-video";constructor(){super();const t=n.getCurrentInstance();if(!t)return;this.editorId=t.instanceId;let e=t.getPopupInstance("video");e||(e=new q({onVideoInsert:t=>{W.insertVideoAtCurrentPosition(t,this.editorId)},editor:t,editorId:this.editorId}),t.setPopupInstance("video",e)),this.videoPopup=e}static createForEditor(t){const e=n.getInstanceById(t);if(!e)return null;const i=n.currentInstance;n.currentInstance=e;const s=new W;return n.currentInstance=i,s}static create(t){if(W.isYouTubeUrl(t))return W.createYouTubeEmbed(t);const e=document.createElement("VIDEO");return e.src=t,e.className="inserted-video",e.controls=!0,e.style.maxWidth="100%",e.style.height="auto",e.setAttribute("contenteditable","false"),e}static createYouTubeEmbed(t){const e=W.getYouTubeVideoId(t);if(!e)throw new Error("Invalid YouTube URL");const n=document.createElement("IFRAME");return n.src=`https://www.youtube.com/embed/${e}`,n.className="inserted-video youtube-video",n.width="560",n.height="315",n.style.maxWidth="100%",n.style.width="560px",n.style.height="315px",n.style.position="relative",n.style.display="block",n.setAttribute("frameborder","0"),n.setAttribute("allowfullscreen",""),n.setAttribute("contenteditable","false"),n}static insertVideoAtCurrentPosition(t,e=null){let i=null;if(i=e?n.getInstanceById(e):n.getCurrentInstance(),!i)return;const s=window.getSelection();if(s&&s.rangeCount)try{const e=s.getRangeAt(0),n=W.create(t);e.deleteContents(),e.insertNode(n);const o=document.createTextNode(" ");e.setStartAfter(n),e.insertNode(o),e.setStartAfter(o),e.collapse(!0),s.removeAllRanges(),s.addRange(e),i&&"function"==typeof i.onContentChange&&i.onContentChange()}catch(t){}}apply(t){t?W.insertVideoAtCurrentPosition(t,this.editorId):this.showVideoPopup()}remove(){const t=window.getSelection();if(!t||!t.rangeCount)return;const e=t.getRangeAt(0),n=this.getVideoElement(e);n&&n.remove()}toggle(){this.videoPopup.isVisible?this.videoPopup.hide():this.showVideoPopup()}showVideoPopup(){const t=n.getInstanceById(this.editorId);if(!t)return;const e=t.getModule("toolbar");let i=null;if(e&&(i=e.getButton("video")),!i){const t=e?.getContainer();t&&(i=t.querySelector(".rich-editor-toolbar-btn.video-btn"))}i||(i=t.wrapper.querySelector(".rich-editor-toolbar-btn.video-btn")),i&&this.videoPopup.show(i)}isActive(){const t=window.getSelection();if(!t||!t.rangeCount)return!1;const e=t.getRangeAt(0);return null!==this.getVideoElement(e)}getVideoElement(t){let e=t.commonAncestorContainer;if(e.nodeType===Node.TEXT_NODE&&(e=e.parentNode),("VIDEO"===e.tagName||"IFRAME"===e.tagName)&&e.classList&&e.classList.contains("inserted-video"))return e;const n=t.cloneContents().querySelector(".inserted-video");return n||null}static async handleFileUpload(t){return new Promise((e,n)=>{if(!t||!t.type.startsWith("video/"))return void n(new Error("Please select a valid video file"));const i=new FileReader;i.onload=t=>{e(t.target.result)},i.onerror=()=>{n(new Error("Failed to read file"))},i.readAsDataURL(t)})}static validateVideoUrl(t){return new Promise(e=>{if(W.isYouTubeUrl(t))return void e(!0);if(["mp4","webm","ogg","mov","avi","mkv"].some(e=>t.toLowerCase().includes(`.${e}`)))return void e(!0);const n=document.createElement("video");n.onloadedmetadata=()=>{e(!0)},n.onerror=()=>{e(!1)},setTimeout(()=>{e(!1)},5e3),n.src=t})}static isYouTubeUrl(t){return/(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/watch\?v=|youtu\.be\/|youtube\.com\/embed\/)([a-zA-Z0-9_-]{11})/.test(t)}static getYouTubeVideoId(t){const e=t.match(/(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/watch\?v=|youtu\.be\/|youtube\.com\/embed\/)([a-zA-Z0-9_-]{11})/);return e?e[1]:null}}var X=Object.freeze({__proto__:null,default:W});class G{constructor(t={}){this.options={onTagInsert:null,editor:null,...t},this.popup=null,this.isVisible=!1,this.clickOutsideHandler=null,this.selectedTagType="mention",this.createTagPopup()}createTagPopup(){this.popup=document.createElement("div"),this.popup.className="tag-popup";const t=document.createElement("div");t.className="tag-popup-content";const e=document.createElement("h3");e.textContent="Insert tags",e.className="yjd-input-title",t.appendChild(e);const n=document.createElement("div");n.className="yjd-input-group";const i=document.createElement("label");i.textContent="Type",i.className="yjd-input-label",this.typeSelect=document.createElement("select"),this.typeSelect.className="yjd-select-input",this.typeSelect.innerHTML='\n <option value="mention">Mention</option>\n <option value="hashtag">Hashtag</option>\n <option value="custom">Custom</option>\n ',this.typeSelect.addEventListener("change",()=>this.updateSuggestions()),n.appendChild(i),n.appendChild(this.typeSelect),t.appendChild(n);const s=document.createElement("div");s.className="yjd-input-group";const o=document.createElement("label");o.textContent="Content",o.className="yjd-input-label",this.contentInput=document.createElement("input"),this.contentInput.type="text",this.contentInput.className="yjd-input",this.contentInput.placeholder="Please enter tag content",this.contentInput.addEventListener("input",()=>this.updateInsertButton()),this.contentInput.addEventListener("keydown",t=>{"Enter"===t.key&&(t.preventDefault(),this.insertTag())}),s.appendChild(o),s.appendChild(this.contentInput),t.appendChild(s);const r=document.createElement("div");r.className="yjd-input-group",this.suggestionsContainer=document.createElement("div"),this.suggestionsContainer.className="tag-suggestions-container";const l=document.createElement("label");l.textContent="Suggestions",l.className="yjd-input-label",this.suggestionsList=document.createElement("div"),this.suggestionsList.className="yjd-suggestions-list",this.suggestionsContainer.appendChild(this.suggestionsList),r.appendChild(l),r.appendChild(this.suggestionsContainer),t.appendChild(r);const a=document.createElement("div");a.className="yjd-button-container";const c=document.createElement("button");c.type="button",c.className="yjd-button-cancel",c.textContent="Cancel",c.addEventListener("click",()=>this.hide()),this.insertButton=document.createElement("button"),this.insertButton.type="button",this.insertButton.className="yjd-button-confirm",this.insertButton.textContent="Insert Tag",this.insertButton.disabled=!0,this.insertButton.addEventListener("click",()=>this.insertTag()),a.appendChild(c),a.appendChild(this.insertButton),t.appendChild(a),this.popup.appendChild(t),C(this.popup),this.options.editor&&"function"==typeof this.options.editor.preventFocusLoss&&this.options.editor.preventFocusLoss(this.popup),this.updateSuggestions()}updateSuggestions(){this.selectedTagType=this.typeSelect.value,this.suggestionsList.innerHTML="";this.getSuggestions(this.selectedTagType).forEach(t=>{const e=document.createElement("button");e.type="button",e.className="yjd-suggestion-button",e.textContent=t,e.addEventListener("click",()=>{this.contentInput.value=t,this.updateInsertButton(),this.contentInput.focus()}),this.suggestionsList.appendChild(e)})}getSuggestions(t){return{mention:["john","admin","team","support"],hashtag:["urgent","done","important"],custom:["warning","info","success"]}[t]||[]}updateInsertButton(){const t=this.contentInput.value.trim();this.insertButton.disabled=!t}insertTag(){const t=this.contentInput.value.trim();t&&(this.options.onTagInsert&&this.options.onTagInsert(this.selectedTagType,t),this.hide(),this.reset())}reset(){this.contentInput.value="",this.typeSelect.value="mention",this.selectedTagType="mention",this.updateInsertButton(),this.updateSuggestions()}setupClickOutside(){this.clickOutsideHandler&&document.removeEventListener("click",this.clickOutsideHandler),this.clickOutsideHandler=t=>{this.popup.contains(t.target)||this.hide()},setTimeout(()=>{document.addEventListener("click",this.clickOutsideHandler)},100)}removeClickOutside(){this.clickOutsideHandler&&(document.removeEventListener("click",this.clickOutsideHandler),this.clickOutsideHandler=null)}show(t){if(!t)return;const e=b(t,this.popup,{offsetY:5,offsetX:0});y(this.popup,e),this.popup.classList.add("visible"),this.isVisible=!0,this.setupClickOutside(),setTimeout(()=>{this.contentInput.focus()},100)}hide(){this.popup.classList.remove("visible"),this.isVisible=!1,this.removeClickOutside()}destroy(){this.removeClickOutside(),this.popup&&this.popup.parentNode&&this.popup.parentNode.removeChild(this.popup),this.popup=null,this.isVisible=!1}}class Y extends s{static formatName="tag";static tagName="SPAN";static className="custom-tag";static savedRanges=new Map;constructor(){super();const t=n.getCurrentInstance();if(!t)return;this.editorId=t.instanceId;let e=t.getPopupInstance("tag");e||(e=new G({onTagInsert:(t,e)=>{Y.insertTagAtCurrentPosition(t,e,this.editorId)},editor:t,editorId:this.editorId}),t.setPopupInstance("tag",e)),this.tagPopup=e}static createForEditor(t){const e=n.getInstanceById(t);if(!e)return null;const i=n.currentInstance;n.currentInstance=e;const s=new Y;return n.currentInstance=i,s}static create(t,e){const n=document.createElement("SPAN");n.className=`custom-tag tag-${t}`;let i=e;return"mention"===t?i=`@${e}`:"hashtag"===t?i=`#${e}`:"custom"===t&&(i=`<${e}>`),n.textContent=i,n.setAttribute("data-tag-type",t),n.setAttribute("data-tag-content",e),n.setAttribute("contenteditable","false"),n}static insertTagAtCurrentPosition(t,e,i=null){let s=null;if(s=i?n.getInstanceById(i):n.getCurrentInstance(),!s)return;const o=window.getSelection();if(o)try{const n=Y.savedRanges.get(i);if(n)o.removeAllRanges(),o.addRange(n),Y.savedRanges.delete(i);else if(!o.rangeCount)return;const r=o.getRangeAt(0),l=Y.create(t,e);r.deleteContents(),r.insertNode(l);const a=document.createTextNode(" ");r.setStartAfter(l),r.insertNode(a),r.setStartAfter(a),r.collapse(!0),o.removeAllRanges(),o.addRange(r),s&&s.element&&s.element.focus(),s&&"function"==typeof s.onContentChange&&s.onContentChange()}catch(t){}}apply(t,e){if(t&&e)Y.insertTagAtCurrentPosition(t,e,this.editorId);else{const t=window.getSelection();t&&t.rangeCount>0&&Y.savedRanges.set(this.editorId,t.getRangeAt(0).cloneRange()),this.showTagPopup()}}remove(){const t=window.getSelection();if(!t||!t.rangeCount)return;const e=t.getRangeAt(0),n=this.getTagElement(e);if(n){const t=document.createTextNode(n.textContent);n.parentNode.replaceChild(t,n)}}toggle(){if(this.tagPopup.isVisible)this.tagPopup.hide();else{const t=window.getSelection();t&&t.rangeCount>0&&Y.savedRanges.set(this.editorId,t.getRangeAt(0).cloneRange()),this.showTagPopup()}}showTagPopup(){const t=n.getInstanceById(this.editorId);if(!t)return;const e=t.getModule("toolbar");let i=null;if(e&&(i=e.getButton("tag")),!i){const t=e?.getContainer();t&&(i=t.querySelector(".rich-editor-toolbar-btn.tag-btn"))}i||(i=t.wrapper.querySelector(".rich-editor-toolbar-btn.tag-btn")),i&&this.tagPopup.show(i)}isActive(){const t=window.getSelection();if(!t||!t.rangeCount)return!1;const e=t.getRangeAt(0);return null!==this.getTagElement(e)}getTagElement(t){let e=t.commonAncestorContainer;if(e.nodeType===Node.TEXT_NODE&&(e=e.parentNode),e.classList&&e.classList.contains("custom-tag"))return e;return t.cloneContents().querySelector(".custom-tag")||null}static getSuggestions(t){return{mention:["john","sarah","admin","team","support"],hashtag:["urgent","todo","done","review","important"],custom:["note","warning","tip","info","success"]}[t]||[]}}class $ extends s{static formatName="textSize";static tagName="SPAN";constructor(){super();const t=n.getCurrentInstance();if(!t)return;this.editorId=t.instanceId;let e=t.getPopupInstance("text-size");if(!e){const n=$.getSizeMap(),i=Object.values(n).map(t=>({value:t.size,label:t.element,title:t.title}));e=new S({items:i,displayProperty:"label",valueProperty:"value",className:"text-size-select",onItemSelect:t=>{$.applyTextSizeToCurrentSelection(t,this.editorId)},editor:t,editorId:this.editorId}),t.setPopupInstance("text-size",e)}this.customSelect=e}static createForEditor(t){const e=n.getInstanceById(t);if(!e)return null;const i=n.currentInstance;n.currentInstance=e;const s=new $;return n.currentInstance=i,s}static getSizeMap(){return{1:{size:"1",element:"<span >XX-Small</span>",title:"XX-Small"},2:{size:"2",element:"<span >X-Small</span>",title:"X-Small"},3:{size:"3",element:"<span >Small</span>",title:"Small"},4:{size:"4",element:"<span >Medium</span>",title:"Medium"},5:{size:"5",element:"<span >Large</span>",title:"Large"},6:{size:"6",element:"<span >X-Large</span>",title:"X-Large"},7:{size:"7",element:"<span >XX-Large</span>",title:"XX-Large"}}}static getSizeDisplayName(t){const e=this.getSizeMap();return e[t]?.title||"Medium"}updateButtonText(){const t=this.getCurrentSize(),e=$.getSizeDisplayName(t||"4"),i=n.getInstanceById(this.editorId);if(!i)return;const s=i.getModule("toolbar");let o=null;if(s&&(o=s.getButton("text-size")),!o){const t=s?.getContainer();t&&(o=t.querySelector(".rich-editor-toolbar-btn.text-size-btn"))}o||(o=i.wrapper.querySelector(".rich-editor-toolbar-btn.text-size-btn")),o&&o.updateText?o.updateText(e):o&&(o.textContent=e)}static updateButtonTextStatic(t=null){let e=null;if(e=t?n.getInstanceById(t):n.getCurrentInstance(),!e)return;const i=$.getCurrentSizeStatic(),s=$.getSizeDisplayName(i||"4"),o=e.getModule("toolbar");let r=null;if(o&&(r=o.getButton("text-size")),!r){const t=o?.getContainer();t&&(r=t.querySelector(".rich-editor-toolbar-btn.text-size-btn"))}r||(r=e.wrapper.querySelector(".rich-editor-toolbar-btn.text-size-btn")),r&&r.updateText?r.updateText(s):r&&(r.textContent=s)}static create(t="4"){const e=document.createElement("span");return e.style.fontSize=$.sizeToCss(t),e}static applyTextSizeToCurrentSelection(t,e=null){let i=null;if(i=e?n.getInstanceById(e):n.getCurrentInstance(),!i)return;const s=window.getSelection();if(!s||!s.rangeCount)return;r();const o=$.createForEditor(e);o&&(o.apply(t),o.updateButtonText()),setTimeout(()=>{i&&"function"==typeof i.onContentChange&&i.onContentChange()},0)}static sizeToCss(t){return{1:"10px",2:"12px",3:"14px",4:"16px",5:"20px",6:"28px",7:"36px"}[String(t)]||"16px"}apply(t="4"){const e=window.getSelection();if(!e||!e.rangeCount)return;r();const n=e.getRangeAt(0);if(!n.collapsed){document.execCommand("fontSize",!1,String(t));const e=window.getSelection();if(e.rangeCount>0){const t=e.getRangeAt(0).commonAncestorContainer;t.nodeType===Node.TEXT_NODE?t.parentNode.normalize():t.normalize()}return}let i=n.startContainer;n.startOffset,i.nodeType===Node.TEXT_NODE&&(i=i.parentNode);const s=i.closest&&i.closest("font");if(s&&"​"===s.textContent)return void s.setAttribute("size",String(t));if(s&&s.firstChild&&s.firstChild.nodeType===Node.TEXT_NODE){const e=s.firstChild,i=n.startOffset,o=e.data.slice(0,i),r=e.data.slice(i),l=s.parentNode;if(0===i){const e=document.createElement("font");e.setAttribute("size",String(t)),e.appendChild(document.createTextNode("​")),l.insertBefore(e,s),a(e)}else if(i===e.data.length){const e=document.createElement("font");e.setAttribute("size",String(t)),e.appendChild(document.createTextNode("​")),l.insertBefore(e,s.nextSibling),a(e)}else{const e=document.createElement("font");e.setAttribute("size",s.getAttribute("size")),e.appendChild(document.createTextNode(o));const n=document.createElement("font");n.setAttribute("size",String(t)),n.appendChild(document.createTextNode("​"));const i=document.createElement("font");i.setAttribute("size",s.getAttribute("size")),i.appendChild(document.createTextNode(r)),l.insertBefore(e,s),l.insertBefore(n,s),l.insertBefore(i,s),l.removeChild(s),a(n)}return}const o=document.createElement("font");o.setAttribute("size",String(t));const l=document.createTextNode("​");function a(t){const e=window.getSelection(),n=document.createRange(),i=t.firstChild;n.setStart(i,i.length),n.collapse(!0),e.removeAllRanges(),e.addRange(n)}o.appendChild(l),n.insertNode(o),a(o)}async toggle(){this.customSelect.isVisible?this.customSelect.hide():await this.showSizePicker()}async showSizePicker(){const t=n.getInstanceById(this.editorId);if(!t)return;const e=t.getModule("toolbar");let i=null;if(e&&(i=e.getButton("text-size")),!i){const t=e?.getContainer();t&&(i=t.querySelector(".rich-editor-toolbar-btn.text-size-btn"))}if(i||(i=t.wrapper.querySelector(".rich-editor-toolbar-btn.text-size-btn")),!i)return;const s=this.getCurrentSize();s&&this.customSelect.setCurrentValue(s),await this.customSelect.show(i)}isActive(t=null){return this.updateButtonText(),!1}getCurrentSize(){return $.getCurrentSizeStatic()}static getCurrentSizeStatic(){const t=window.getSelection();if(!t||!t.rangeCount)return"4";try{const t=document.queryCommandValue("fontSize"),e=parseInt(t,10);if(!isNaN(e)&&e>=1&&e<=7)return String(e)}catch(t){}let e=t.getRangeAt(0).startContainer;for(e.nodeType===Node.TEXT_NODE&&(e=e.parentElement);e&&e!==document.body;){if(e.nodeType===Node.ELEMENT_NODE){const t=e,n=t.style?.fontSize;if(n)return this.normalizeCssSizeToExecSize(n);const i=window.getComputedStyle(t).fontSize;if(i)return this.normalizeCssSizeToExecSize(i)}e=e.parentElement}return"4"}normalizeCssSizeToExecSize(t){const e=parseFloat(t);if(isNaN(e))return"4";const n=[10,12,14,16,20,28,36];let i=3,s=1/0;for(let t=0;t<n.length;t++){const o=Math.abs(e-n[t]);o<s&&(s=o,i=t)}return String(i+1)}}class K{constructor(t={}){this.options={onImport:null,...t},this.popup=null,this.isVisible=!1,this.clickOutsideHandler=null,this.selectedFile=null,this.fileType=null,this.createImportPopup()}createImportPopup(){this.popup=document.createElement("div"),this.popup.className="import-popup";const t=document.createElement("div");t.className="import-popup-content";const e=document.createElement("h3");e.textContent="Import File",e.className="import-popup-title",t.appendChild(e);const n=document.createElement("div");n.className="import-type-container";const i=document.createElement("label");i.textContent="File Type:",i.className="import-input-label",this.typeSelect=document.createElement("select"),this.typeSelect.className="import-type-select",this.typeSelect.innerHTML='\n <option value="">Select file type...</option>\n <option value="html">HTML (.html, .htm)</option>\n <option value="excel">Excel/CSV (.csv, .xlsx, .xls)</option>\n <option value="pdf">PDF (.pdf)</option>\n <option value="word">Word (.doc, .docx)</option>\n ',this.typeSelect.addEventListener("change",()=>this.updateFileInput()),n.appendChild(i),n.appendChild(this.typeSelect),t.appendChild(n),this.fileInput=document.createElement("input"),this.fileInput.type="file",this.fileInput.className="import-file-input",this.fileInput.disabled=!0,this.fileInput.addEventListener("change",t=>this.handleFileSelect(t)),t.appendChild(this.fileInput),this.fileInfo=document.createElement("div"),this.fileInfo.className="import-file-info",this.fileInfo.style.display="none",t.appendChild(this.fileInfo);const s=document.createElement("div");s.className="import-button-container";const o=document.createElement("button");o.type="button",o.className="import-button cancel-button",o.textContent="Cancel",o.addEventListener("click",()=>this.hide()),this.importButton=document.createElement("button"),this.importButton.type="button",this.importButton.className="import-button import-button-main",this.importButton.textContent="Import",this.importButton.disabled=!0,this.importButton.addEventListener("click",()=>this.processImport()),s.appendChild(o),s.appendChild(this.importButton),t.appendChild(s),this.popup.appendChild(t),C(this.popup)}updateFileInput(){const t=this.typeSelect.value;if(t){this.fileType=t,this.fileInput.disabled=!1;const e=this.getAcceptTypes(t);this.fileInput.accept=e}else this.fileType=null,this.fileInput.disabled=!0,this.fileInput.accept="";this.updateImportButton()}getAcceptTypes(t){return{html:".html,.htm,text/html",excel:".csv,.xlsx,.xls,text/csv",pdf:".pdf,application/pdf",word:".doc,.docx"}[t]||""}handleFileSelect(t){const e=t.target.files[0];e&&this.setSelectedFile(e)}setSelectedFile(t){this.selectedFile=t,this.fileInfo.style.display="block",this.fileInfo.innerHTML=`\n <div><strong>Name:</strong> ${t.name}</div>\n <div><strong>Size:</strong> ${this.formatFileSize(t.size)}</div>\n <div><strong>Type:</strong> ${t.type||"Unknown"}</div>\n `,this.updateImportButton()}formatFileSize(t){if(0===t)return"0 Bytes";const e=Math.floor(Math.log(t)/Math.log(1024));return parseFloat((t/Math.pow(1024,e)).toFixed(2))+" "+["Bytes","KB","MB","GB"][e]}updateImportButton(){this.importButton.disabled=!this.selectedFile||!this.fileType}async processImport(){if(this.selectedFile&&this.fileType)try{let t;if("html"===this.fileType)t=await this.readAsText(this.selectedFile);else if("excel"===this.fileType){if(!this.selectedFile.name.toLowerCase().endsWith(".csv"))return void alert("Excel files (.xlsx/.xls) require additional libraries. Please use CSV format.");{const e=await this.readAsText(this.selectedFile);t=this.parseCSV(e)}}else{if("pdf"===this.fileType)return void alert("PDF import requires additional libraries. Feature coming soon.");if("word"===this.fileType)return void alert("Word document import requires additional libraries. Feature coming soon.")}this.options.onImport&&this.options.onImport(t,this.fileType),this.hide(),this.reset()}catch(t){alert("Error importing file: "+t.message)}}parseCSV(t){const e=t.split("\n"),n=[];return e.forEach(t=>{if(t.trim()){const e=t.split(",").map(t=>t.trim().replace(/^["']|["']$/g,""));n.push(e)}}),n}readAsText(t){return new Promise((e,n)=>{const i=new FileReader;i.onload=t=>e(t.target.result),i.onerror=()=>n(new Error("Failed to read file")),i.readAsText(t)})}reset(){this.selectedFile=null,this.fileType=null,this.typeSelect.value="",this.fileInput.value="",this.fileInput.disabled=!0,this.fileInfo.style.display="none",this.updateImportButton()}setupClickOutside(){this.clickOutsideHandler&&document.removeEventListener("click",this.clickOutsideHandler),this.clickOutsideHandler=t=>{this.popup.contains(t.target)||this.hide()},setTimeout(()=>{document.addEventListener("click",this.clickOutsideHandler)},100)}removeClickOutside(){this.clickOutsideHandler&&(document.removeEventListener("click",this.clickOutsideHandler),this.clickOutsideHandler=null)}show(t){if(!t)return;const e=b(t,this.popup,{offsetY:5,offsetX:0});y(this.popup,e),this.popup.classList.add("visible"),this.isVisible=!0,this.setupClickOutside()}hide(){this.popup.classList.remove("visible"),this.isVisible=!1,this.removeClickOutside()}destroy(){this.removeClickOutside(),this.popup&&this.popup.parentNode&&this.popup.parentNode.removeChild(this.popup),this.popup=null,this.isVisible=!1}}class Q extends s{static formatName="import";static tagName="DIV";static className="imported-content";constructor(){super();const t=n.getCurrentInstance();if(!t)return;this.editorId=t.instanceId;let e=t.getPopupInstance("import");e||(e=new K({onImport:(t,e)=>{Q.insertImportedContent(t,e,this.editorId)},editor:t,editorId:this.editorId}),t.setPopupInstance("import",e)),this.importPopup=e}static createForEditor(t){const e=n.getInstanceById(t);if(!e)return null;const i=n.currentInstance;n.currentInstance=e;const s=new Q;return n.currentInstance=i,s}static insertImportedContent(t,e,i=null){let s=null;if(s=i?n.getInstanceById(i):n.getCurrentInstance(),!s)return;const o=window.getSelection();if(o&&o.rangeCount)try{const n=o.getRangeAt(0);let i;i="html"===e?Q.processHtmlContent(t):"excel"===e?Q.processExcelContent(t):Q.processTextContent(t),n.deleteContents(),n.insertNode(i),n.setStartAfter(i),n.collapse(!0),o.removeAllRanges(),o.addRange(n),s&&"function"==typeof s.onContentChange&&s.onContentChange()}catch(t){}}static processHtmlContent(t){const e=document.createElement("div");e.className="imported-content html-content";const n=document.createElement("div");return n.innerHTML=t,Q.cleanHtmlContent(n),e.appendChild(n),e}static processExcelContent(t){const e=document.createElement("div");if(e.className="imported-content excel-content",!Array.isArray(t)||0===t.length)return e.textContent="No data to import",e;const n=document.createElement("table");if(n.className="imported-table",t.length>0){const e=document.createElement("thead"),i=document.createElement("tr");t[0].forEach(t=>{const e=document.createElement("th");e.textContent=t||"",i.appendChild(e)}),e.appendChild(i),n.appendChild(e)}if(t.length>1){const e=document.createElement("tbody");for(let n=1;n<t.length;n++){const i=document.createElement("tr");t[n].forEach(t=>{const e=document.createElement("td");e.textContent=t||"",i.appendChild(e)}),e.appendChild(i)}n.appendChild(e)}return e.appendChild(n),e}static processTextContent(t){const e=document.createElement("div");e.className="imported-content text-content";return t.split(/\n\s*\n/).forEach(t=>{if(t.trim()){const n=document.createElement("p");n.textContent=t.trim(),e.appendChild(n)}}),e}static cleanHtmlContent(t){const e=["p","div","span","h1","h2","h3","h4","h5","h6","strong","b","em","i","u","ul","ol","li","br","table","thead","tbody","tr","th","td"],n=["class","style"],i=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,null,!1),s=[];for(;i.nextNode();){const t=i.currentNode;if(!e.includes(t.tagName.toLowerCase())){s.push(t);continue}Array.from(t.attributes).forEach(e=>{n.includes(e.name.toLowerCase())||t.removeAttribute(e.name)})}s.forEach(t=>{t.parentNode&&t.parentNode.removeChild(t)})}static parseCSV(t){const e=t.split("\n"),n=[];return e.forEach(t=>{if(t.trim()){const e=t.split(",").map(t=>t.trim().replace(/^["']|["']$/g,""));n.push(e)}}),n}apply(){this.showImportPopup()}toggle(){this.importPopup.isVisible?this.importPopup.hide():this.showImportPopup()}showImportPopup(){const t=n.getInstanceById(this.editorId);if(!t)return;const e=t.getModule("toolbar");let i=null;if(e&&(i=e.getButton("import")),!i){const t=e?.getContainer();t&&(i=t.querySelector(".rich-editor-toolbar-btn.import-btn"))}i||(i=t.wrapper.querySelector(".rich-editor-toolbar-btn.import-btn")),i&&this.importPopup.show(i)}isActive(){return!1}static getSupportedTypes(){return{html:{extensions:[".html",".htm"],mimeTypes:["text/html"],name:"HTML Files"},excel:{extensions:[".csv",".xlsx",".xls"],mimeTypes:["text/csv","application/vnd.ms-excel","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"],name:"Excel Files"},pdf:{extensions:[".pdf"],mimeTypes:["application/pdf"],name:"PDF Files"},word:{extensions:[".doc",".docx"],mimeTypes:["application/msword","application/vnd.openxmlformats-officedocument.wordprocessingml.document"],name:"Word Documents"}}}}function J(t="Button",e={}){const{width:n="auto"}=e,i=document.createElement("button");i.type="button",i.className="custom-select-button";const s=document.createElement("span");s.textContent=t,s.className="button-text";const o=m.createIconElement("dropdown");return o.className="dropdown-icon",i.appendChild(s),i.appendChild(o),i.style.width=n,i.style.padding="0px 5px 0px 8px",i.style.setProperty("height","32px","important"),i.style.setProperty("borderRadius","6px","important"),i.style.setProperty("alignItems","center","important"),i.style.fontSize="14px",i.style.fontWeight="400",i.style.color="#374151",i.style.background="#FFFFFF",i.style.cursor="pointer",i.style.border="1px solid #d1d5db",i.style.display="flex",i.style.justifyContent="space-between",i.style.alignItems="center",s.style.flex="1",s.style.textAlign="left",i.updateText=function(t){s.textContent=t},i}class tt extends e{static DEFAULTS={container:null,toolbar1:[{group:"text-format",items:["bold","italic","underline","strike"]},{group:"script",items:["subscript","superscript"]},{group:"colors",items:["color","background"]},{group:"link",items:["link"]},{group:"structure",items:["heading","text-size"]},{group:"table",items:["table"]},{group:"alignment",items:["text-align"]},{group:"actions",items:["undo","redo"]},{group:"more",items:["more"]}],toolbar2:[{group:"structure",items:["list"]},{group:"indent",items:["indent-increase","indent-decrease"]},{group:"font-family",items:["font-family"]},{group:"line-height",items:["line-height"]},{group:"capitalization",items:["capitalization"]},{group:"media",items:["emoji","image","video"]},{group:"content",items:["tag"]},{group:"view",items:["code-view"]}]};constructor(t,e={}){super(t,e),this.buttons=new Map,this.toolbar2Visible=!1,this.events=new Map,Array.isArray(e.toolbar)?this.options={container:null,toolbar1:[{group:"text-format",items:e.toolbar}],toolbar2:[]}:e.toolbar1||e.toolbar2?this.options={container:null,toolbar1:e.toolbar1||[],toolbar2:e.toolbar2||[]}:this.options={...tt.DEFAULTS,...e},this.init(),this.preloadIcons()}init(){this.container=this.createToolbarContainer()}async preloadIcons(){}createToolbarContainer(){const t=document.createElement("div");return t.className="rich-editor-toolbar-container",this.editor.preventFocusLoss(t),this.toolbar1=this.createToolbar("rich-editor-toolbar-1",this.options.toolbar1),t.appendChild(this.toolbar1),this.toolbar2=this.createToolbar("rich-editor-toolbar-2",this.options.toolbar2),this.toolbar2.style.display="none",t.appendChild(this.toolbar2),t}createToolbar(t,e){const n=document.createElement("div");return n.className=t,Array.isArray(e)&&e.forEach(t=>{if(t&&t.group&&Array.isArray(t.items)){const e=document.createElement("div");e.className=`toolbar-group toolbar-group-${t.group}`,t.items.forEach(t=>{"string"==typeof t&&this.addButton(e,t)}),n.appendChild(e)}}),n}addButton(t,e){if("more"===e)return this.addMoreButton(t);const n={heading:{text:"Paragraph",width:"110px",title:"Format (Headings & Paragraphs)"},"font-family":{text:"Font Family",width:"150px",title:"Font Family"},"line-height":{text:"Line Height",width:"110px",title:"Line Height"},capitalization:{text:"Capitalization",width:"130px",title:"Text Capitalization"},"text-size":{text:"Text Size",width:"100px",title:"Text Size"}};if(n[e]){const i=n[e],s=J(i.text,{width:i.width});return s.dataset.command=e,s.classList.add("rich-editor-toolbar-btn",`${e}-btn`),s.title=i.title,s.addEventListener("click",t=>{t.preventDefault(),this.emit("toolbar-click",{command:e,button:s}),setTimeout(()=>{this.editor.focus()},0)}),this.buttons.set(e,s),t.appendChild(s),s}const i={"text-align":{icon:"align-left",title:"Align Left"},list:{icon:"list",title:"List"}};if(i[e]){const n=i[e],s=document.createElement("button");s.type="button",s.className=`rich-editor-toolbar-btn ${e}-btn`,s.dataset.command=e,s.title=n.title;const o=m.getIcon(n.icon);return o?s.innerHTML=`<span class="icon">${o}</span>`:s.textContent="text-align"===e?"≡":"•",s.addEventListener("click",t=>{t.preventDefault(),this.emit("toolbar-click",{command:e,button:s}),setTimeout(()=>{this.editor.focus()},0)}),this.buttons.set(e,s),t.appendChild(s),s}const s=document.createElement("button");s.type="button",s.className=`rich-editor-toolbar-btn ${e}-btn`,s.dataset.command=e;const o=m.createIconElement(e,{width:"16px",height:"16px"});s.appendChild(o);return s.title={bold:"Bold (Ctrl+B)",italic:"Italic (Ctrl+I)",underline:"Underline (Ctrl+U)",strike:"Strikethrough",subscript:"Subscript",superscript:"Superscript",color:"Text Color",background:"Background Color",link:"Insert/Edit Link",table:"Insert Table",undo:"Undo (Ctrl+Z)",redo:"Redo (Ctrl+Y)","indent-increase":"Increase Indent","indent-decrease":"Decrease Indent",emoji:"Insert Emoji",image:"Insert Image",video:"Insert Video",tag:"Insert Tag",import:"Import Files","code-view":"Switch to HTML Editor"}[e]||e,"code-view"===e&&setTimeout(()=>{o.innerHTML.trim()||(o.innerHTML="&lt;/&gt;",o.style.fontSize="12px",o.style.fontWeight="bold")},1e3),s.addEventListener("click",t=>{t.preventDefault(),this.emit("toolbar-click",{command:e,button:s}),setTimeout(()=>{this.editor.focus()},0)}),this.buttons.set(e,s),t.appendChild(s),s}addMoreButton(t){const e=document.createElement("button");e.type="button",e.className="rich-editor-toolbar-btn more-btn",e.dataset.command="more";const n=m.createIconElement("more",{width:"16px",height:"16px"});return e.appendChild(n),e.title="More Options",e.addEventListener("click",t=>{t.preventDefault(),this.toggleToolbar2(),setTimeout(()=>{this.editor.focus()},0)}),this.buttons.set("more",e),t.appendChild(e),e}toggleToolbar2(){this.toolbar2Visible=!this.toolbar2Visible,this.toolbar2Visible?(this.toolbar2.style.display="flex",this.toolbar2.style.borderTop="1px solid #d1d5db"):this.toolbar2.style.display="none";const t=this.buttons.get("more");t&&(this.toolbar2Visible?(t.classList.add("active"),t.title="Hide More Options"):(t.classList.remove("active"),t.title="More Options"))}getContainer(){return this.container}getButton(t){return this.buttons.get(t)}setButtonActive(t,e){const n=this.buttons.get(t);n&&n.classList&&(e?n.classList.add("active"):n.classList.remove("active"))}setButtonDisabled(t,e){const n=this.buttons.get(t);n&&(n.disabled=e,n.style.opacity=e?"0.5":"1",n.style.cursor=e?"not-allowed":"pointer")}setButtonTitle(t,e){const n=this.buttons.get(t);n&&(n.title=e)}isToolbar2Visible(){return this.toolbar2Visible}on(t,e){this.events.has(t)||this.events.set(t,[]),this.events.get(t).push(e)}emit(t,e){const n=this.events.get(t);n&&n.forEach(t=>{try{t(e)}catch(t){}})}destroy(){this.container&&this.container.parentNode&&this.container.parentNode.removeChild(this.container),this.buttons.clear(),this.events.clear()}}class et extends e{static DEFAULTS={delay:1e3,maxStack:100,userOnly:!1};constructor(t,e={}){super(t,e),this.stack=[],this.index=-1,this.lastSave=0,this.savedSelection=null,this.init()}init(){this.setupEventListeners(),this.saveState()}setupEventListeners(){this.editor.editor.addEventListener("input",()=>{this.handleInput()}),this.editor.editor.addEventListener("keydown",t=>{"Enter"!==t.key&&"Backspace"!==t.key&&"Delete"!==t.key||this.saveState()}),this.setupMutationObserver(),this.editor.wrapper.addEventListener("click",t=>{t.target.closest(".rich-editor-toolbar-btn")&&setTimeout(()=>{this.saveState()},0)}),this.editor.editor.addEventListener("keydown",t=>{!t.ctrlKey&&!t.metaKey||t.shiftKey||"z"!==t.key?((t.ctrlKey||t.metaKey)&&t.shiftKey&&"z"===t.key||(t.ctrlKey||t.metaKey)&&"y"===t.key)&&(t.preventDefault(),this.redo()):(t.preventDefault(),this.undo())})}setupMutationObserver(){this.mutationObserver=new MutationObserver(t=>{let e=!1;for(const n of t)if("childList"===n.type||"attributes"===n.type&&(n.target.nodeType===Node.TEXT_NODE||["P","DIV","H1","H2","H3","H4","H5","H6","BLOCKQUOTE","PRE","UL","OL","LI","SPAN","STRONG","EM","U","S","SUB","SUP","A","IMG","VIDEO","TABLE","TR","TD","TH"].includes(n.target.tagName))){e=!0;break}e&&(clearTimeout(this.mutationTimeout),this.mutationTimeout=setTimeout(()=>{this.saveState()},100))}),this.mutationObserver.observe(this.editor.editor,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["style","class","href","src","alt","title"]})}handleInput(){const t=Date.now();t-this.lastSave>this.options.delay&&(this.saveState(),this.lastSave=t)}saveState(){const t=this.editor.getContent(),e=this.saveSelection();if(this.stack.length>0&&this.stack[this.index]?.content===t)return;const n=Date.now();this.lastSave&&n-this.lastSave<50||(this.index<this.stack.length-1&&this.stack.splice(this.index+1),this.stack.push({content:t,selection:e,timestamp:n}),this.stack.length>this.options.maxStack?this.stack.shift():this.index++,this.lastSave=n)}undo(){if(!this.canUndo())return!1;this.index--;const t=this.stack[this.index];return this.restoreState(t),this.onHistoryChange("undo"),!0}redo(){if(!this.canRedo())return!1;this.index++;const t=this.stack[this.index];return this.restoreState(t),this.onHistoryChange("redo"),!0}canUndo(){return this.index>0}canRedo(){return this.index<this.stack.length-1}restoreState(t){t&&(this.editor.setContent(t.content),t.selection&&setTimeout(()=>{this.restoreSelection(t.selection)},10))}saveSelection(){const t=window.getSelection();if(!t||!t.rangeCount)return null;const e=t.getRangeAt(0),n=this.editor.editor;return{startOffset:this.getOffsetInEditor(e.startContainer,e.startOffset,n),endOffset:this.getOffsetInEditor(e.endContainer,e.endOffset,n),collapsed:e.collapsed}}restoreSelection(t){if(!t)return;const e=this.editor.editor,n=document.createRange(),i=window.getSelection();try{const s=this.getNodeAtOffset(e,t.startOffset),o=this.getNodeAtOffset(e,t.endOffset);s&&o&&(n.setStart(s.node,s.offset),n.setEnd(o.node,o.offset),i.removeAllRanges(),i.addRange(n))}catch(t){this.editor.focus()}}getOffsetInEditor(t,e,n){let i=0;const s=document.createTreeWalker(n,NodeFilter.SHOW_TEXT,null,!1);let o;for(;o=s.nextNode();){if(o===t)return i+e;i+=o.textContent.length}return i}getNodeAtOffset(t,e){let n=0;const i=document.createTreeWalker(t,NodeFilter.SHOW_TEXT,null,!1);let s;for(;s=i.nextNode();){const t=s.textContent.length;if(n+t>=e)return{node:s,offset:e-n};n+=t}return{node:t.lastChild||t,offset:0}}clear(){this.stack=[],this.index=-1,this.saveState()}getState(){return{canUndo:this.canUndo(),canRedo:this.canRedo(),stackLength:this.stack.length,currentIndex:this.index}}onHistoryChange(t){this.editor.modules.forEach(e=>{e!==this&&"function"==typeof e.onHistoryChange&&e.onHistoryChange(t,this.getState())});const e=new CustomEvent("historychange",{detail:{action:t,state:this.getState()}});this.editor.editor.dispatchEvent(e)}forceSave(){const t=this.lastSave;this.lastSave=0,this.saveState(),this.lastSave=t}saveBeforeFormat(){this.forceSave()}destroy(){this.mutationObserver&&(this.mutationObserver.disconnect(),this.mutationObserver=null),this.mutationTimeout&&(clearTimeout(this.mutationTimeout),this.mutationTimeout=null),this.stack=[],this.index=-1,this.savedSelection=null}}class nt extends e{static DEFAULTS={showOnSelection:!0,showOnEnter:!0,buttons:["bold","italic","underline","strike","code"]};constructor(t,e={}){super(t,e),this.blockToolbar=null,this.isVisible=!1,this.currentSelection=null,this.currentCursorPosition=null,this.originalTags=new Map,this.init()}init(){this.preloadIcons(),this.createBlockToolbar(),this.setupEventListeners()}async preloadIcons(){}createBlockToolbar(){this.blockToolbar=document.createElement("div"),this.blockToolbar.className="block-toolbar";const t=document.createElement("div");t.className="block-toolbar-container";[{cmd:"bold",icon:"bold",title:"Bold (Ctrl+B)"},{cmd:"italic",icon:"italic",title:"Italic (Ctrl+I)"},{cmd:"underline",icon:"underline",title:"Underline (Ctrl+U)"},{cmd:"strike",icon:"strike",title:"Strikethrough"},{cmd:"code",icon:"code",title:"Code"},{cmd:"font-family",icon:"heading",title:"Font Family"}].forEach(({cmd:e,icon:n,title:i})=>{const s=document.createElement("button");s.className="block-toolbar-btn",s.title=i,s.dataset.command=e;const o=m.createIconElement(n,{width:"16px",height:"16px"});s.appendChild(o),s.addEventListener("click",t=>{t.preventDefault(),t.stopPropagation(),this.handleCommand(e,s)}),t.appendChild(s)});const e=document.createElement("div");e.className="block-toolbar-arrow",this.blockToolbar.appendChild(t),this.blockToolbar.appendChild(e),this.editor.wrapper.appendChild(this.blockToolbar)}setupEventListeners(){this.options.showOnSelection&&this.editor.editor.addEventListener("mouseup",()=>{setTimeout(()=>this.handleSelectionChange(),0)}),this.options.showOnEnter&&this.editor.editor.addEventListener("keydown",t=>{"Enter"!==t.key||t.shiftKey?this.hide():requestAnimationFrame(()=>{setTimeout(()=>this.showAtCursorAfterEnter(),10)})}),document.addEventListener("mousedown",t=>{t.target.closest(".font-family-select-popup")||t.target.closest(".custom-select-popup")||t.target.closest(".block-toolbar")||t.target.closest(".rich-editor-area")||this.hide()}),window.addEventListener("scroll",()=>{this.isVisible&&this.updateToolbarPosition()}),this.editor.editor.addEventListener("scroll",()=>{this.isVisible&&this.updateToolbarPosition()}),this.editor.editor.addEventListener("keyup",t=>{"Enter"===t.key&&t.shiftKey?this.hide():this.isVisible?this.updateButtonStates():this.handleSelectionChange()})}handleSelectionChange(){const t=window.getSelection();if(!t||0===t.rangeCount)return this.hide();const e=t.getRangeAt(0);if(!(this.editor.isSelectionInEditableArea?this.editor.isSelectionInEditableArea(t):this.editor.editor.contains(e.commonAncestorContainer)))return this.hide();!e.collapsed&&t.toString().trim().length>0?this.showAtSelection(t):this.hide()}showAtSelection(t){if(!t||0===t.rangeCount)return;this.currentSelection=t,this.currentCursorPosition=null;const e=t.getRangeAt(0).getBoundingClientRect(),n=this.editor.wrapper.getBoundingClientRect(),i=window.pageYOffset||document.documentElement.scrollTop,s=window.pageXOffset||document.documentElement.scrollLeft;this.showAt(e.left+e.width/2-n.left+s,e.top-n.top+i-10)}showAtCursorAfterEnter(){this.editor.focus();const t=window.getSelection();if(!t||0===t.rangeCount)return;const e=t.getRangeAt(0);if(!(this.editor.isSelectionInEditableArea?this.editor.isSelectionInEditableArea(t):this.editor.editor.contains(e.commonAncestorContainer)))return;this.ensureCursorAtEndOfLine(e),this.currentSelection=t,this.currentCursorPosition=this.getCursorPositionAfterEnter();const n=this.currentCursorPosition;if(!n)return;const i=this.editor.wrapper.getBoundingClientRect(),s=window.pageYOffset||document.documentElement.scrollTop,o=window.pageXOffset||document.documentElement.scrollLeft;this.showAt(n.left-i.left+o,n.top-i.top+s-10)}ensureCursorAtEndOfLine(t){if(!t.collapsed)return;const e=window.getSelection(),n=t.startContainer;if(n.nodeType===Node.TEXT_NODE){const i=n.textContent.length;t.startOffset<i&&(t.setStart(n,i),t.setEnd(n,i),e.removeAllRanges(),e.addRange(t))}else if(n.nodeType===Node.ELEMENT_NODE){const i=document.createTreeWalker(n,NodeFilter.SHOW_TEXT,null,!1);let s,o=null;for(;s=i.nextNode();)o=s;if(o){const n=o.textContent.length;t.setStart(o,n),t.setEnd(o,n),e.removeAllRanges(),e.addRange(t)}}}getCursorPositionAfterEnter(){const t=window.getSelection();if(!t||0===t.rangeCount)return null;const e=t.getRangeAt(0),n=document.createElement("span");n.innerHTML="&#8203;",n.style.position="absolute",n.style.visibility="hidden",n.style.pointerEvents="none",e.insertNode(n);const i=n.getBoundingClientRect();n.parentNode&&n.parentNode.removeChild(n);const s=document.createRange();return s.setStart(e.startContainer,e.startOffset),s.collapse(!0),t.removeAllRanges(),t.addRange(s),i}showAtCursor(){const t=window.getSelection();if(!t||0===t.rangeCount)return;const e=t.getRangeAt(0);if(!(this.editor.isSelectionInEditableArea?this.editor.isSelectionInEditableArea(t):this.editor.editor.contains(e.commonAncestorContainer)))return;let n;if(e.collapsed){const i=document.createElement("span");i.innerHTML="&#8203;",i.style.position="absolute",i.style.visibility="hidden",i.style.pointerEvents="none",e.insertNode(i),n=i.getBoundingClientRect(),i.parentNode&&i.parentNode.removeChild(i);const s=document.createRange();s.setStart(e.startContainer,e.startOffset),s.collapse(!0),t.removeAllRanges(),t.addRange(s)}else n=e.getBoundingClientRect();const i=this.editor.wrapper.getBoundingClientRect(),s=window.pageYOffset||document.documentElement.scrollTop,o=window.pageXOffset||document.documentElement.scrollLeft;this.showAt(n.left-i.left+o,n.top-i.top+s-10)}showAt(t,e){this.blockToolbar&&(this.blockToolbar.classList.add("visible"),this.isVisible=!0,this.ensureToolbarInViewport(t,e),this.updateButtonStates())}ensureToolbarInViewport(t,e){if(!this.blockToolbar)return;const n=this.editor.editor,i=n.getBoundingClientRect();this.blockToolbar.getBoundingClientRect();const s=this.editor.wrapper.querySelector(".rich-editor-toolbar-container"),o=s?s.getBoundingClientRect():null;let r=t-this.blockToolbar.offsetWidth/2,l=i.y+e-o.height-n.scrollTop-(i.y+window.scrollY)+s.offsetHeight-49,a="50%",c="down";if(r<0&&(r=t-.1*this.blockToolbar.offsetWidth,r<0&&(r=0),a="10%"),r+this.blockToolbar.offsetWidth>this.editor.wrapper.offsetWidth-2&&(r=t-.9*this.blockToolbar.offsetWidth,a="90%"),l<o.height&&(l=i.y+e-o.height-n.scrollTop+100-(i.y+window.scrollY)+s.offsetHeight-49,c="up",l<o.height))return void this.hide();if(l>i.height)return void this.hide();const d=this.blockToolbar.querySelector(".block-toolbar-arrow");d&&(d.style.left=a,"up"===c?(d.style.bottom="auto",d.style.top="-8px",d.style.borderTop="none",d.style.borderBottom="8px solid #fff",d.style.borderLeft="6px solid transparent",d.style.borderRight="6px solid transparent"):(d.style.top="auto",d.style.bottom="-8px",d.style.borderBottom="none",d.style.borderTop="8px solid #fff",d.style.borderLeft="6px solid transparent",d.style.borderRight="6px solid transparent")),this.blockToolbar.style.left=r+"px",this.blockToolbar.style.top=l+"px"}updateToolbarPosition(){if(!this.isVisible)return;const t=window.getSelection();if(!t||0===t.rangeCount)return void this.hide();const e=t.getRangeAt(0);if(!(this.editor.isSelectionInEditableArea?this.editor.isSelectionInEditableArea(t):this.editor.editor.contains(e.commonAncestorContainer)))return void this.hide();let n;if(e.collapsed){const i=document.createElement("span");i.innerHTML="&#8203;",i.style.position="absolute",i.style.visibility="hidden",i.style.pointerEvents="none";try{e.insertNode(i),n=i.getBoundingClientRect(),i.parentNode&&i.parentNode.removeChild(i);const s=document.createRange();s.setStart(e.startContainer,e.startOffset),s.collapse(!0),t.removeAllRanges(),t.addRange(s)}catch(t){return void this.hide()}}else n=e.getBoundingClientRect();const i=this.editor.wrapper.getBoundingClientRect(),s=window.pageYOffset||document.documentElement.scrollTop,o=window.pageXOffset||document.documentElement.scrollLeft;let r,l;e.collapsed?(r=n.left-i.left+o,l=n.top-i.top+s-10):(r=n.left+n.width/2-i.left+o,l=n.top-i.top+s-10),this.updateToolbarAt(r,l);const a=this.editor.registry.get("formats/font-family");a&&a.selectInstance&&a.selectInstance.isVisible&&a.selectInstance.updatePosition()}updateToolbarAt(t,e){this.blockToolbar&&(this.ensureToolbarInViewport(t,e),this.updateButtonStates())}hide(){if(!this.blockToolbar||!this.isVisible)return;this.blockToolbar.classList.remove("visible"),this.isVisible=!1,this.currentSelection=null,this.currentCursorPosition=null;const t=this.editor.registry.get("formats/font-family");t&&t.selectInstance&&t.selectInstance.hide()}handleCommand(t,e){const n=window.getSelection();if(!(!this.editor.isSelectionInEditableArea||this.editor.isSelectionInEditableArea(n)))return void this.hide();if("font-family"===t){const n=this.editor.registry.get("formats/font-family");if(n){return(new n).toggle(e),this.updateButtonState(t,e),void this.editor.focus()}}if("code"===t){const n=this.editor.registry.get("formats/heading");if(n){const i=new n,s=i.getCurrentTag();if("PRE"===s){const t=window.getSelection();if(t&&t.rangeCount){const e=t.getRangeAt(0),n=this.getBlockElement(e.startContainer);if(n){const t=this.originalTags.get(n)||"P";i.apply(t),this.originalTags.delete(n)}else i.apply("P")}else i.apply("P")}else{const t=window.getSelection();if(t&&t.rangeCount){const e=t.getRangeAt(0),n=this.getBlockElement(e.startContainer);n&&this.originalTags.set(n,s||"P")}i.apply("PRE")}return this.updateButtonState(t,e),void this.editor.focus()}}const i=this.editor.registry.get(`formats/${t}`);if(i){const t=new i;"function"==typeof t.toggle?t.toggle():"function"==typeof t.apply&&t.apply()}else document.execCommand(t,!1,null);this.updateButtonState(t,e),this.editor.focus()}updateButtonStates(){if(!this.blockToolbar)return;this.blockToolbar.querySelectorAll(".block-toolbar-btn").forEach(t=>{const e=t.dataset.command;this.updateButtonState(e,t)})}updateButtonState(t,e){if(!e)return;let n=!1;if("font-family"===t){const t=this.editor.registry.get("formats/font-family");if(t){n=(new t).isActive()}}else if("code"===t){const t=this.editor.registry.get("formats/heading");if(t){n="PRE"===(new t).getCurrentTag()}}else if("strike"===t){const e=this.editor.registry.get(`formats/${t}`);if(e){n=(new e).isActive()}}else try{n=document.queryCommandState(t)}catch(t){n=!1}n?e.classList.add("active"):e.classList.remove("active")}getBlockElement(t){if(!t)return null;if(t.nodeType===Node.ELEMENT_NODE){if(["H1","H2","H3","H4","H5","H6","P","PRE","BLOCKQUOTE","DIV"].includes(t.tagName))return t}let e=t;for(;e&&e!==this.editor.editor;){if(e.nodeType===Node.ELEMENT_NODE){if(["H1","H2","H3","H4","H5","H6","P","PRE","BLOCKQUOTE","DIV"].includes(e.tagName))return e}e=e.parentNode}return null}destroy(){this.blockToolbar&&this.blockToolbar.parentNode&&this.blockToolbar.parentNode.removeChild(this.blockToolbar),this.blockToolbar=null,this.isVisible=!1,this.originalTags.clear()}}class it extends e{static DEFAULTS={fadeDelay:3e3,buttons:["tableProfile","deleteTable","insertRowAbove","insertRowBelow","deleteRow","insertColRight","insertColLeft","deleteCol"]};constructor(t,e={}){super(t,e),this.tableToolbar=null,this.currentTable=null,this.currentCell=null,this.hideTimeout=null,this.isVisible=!1,this.init()}async init(){await this.createTableToolbar(),this.setupEventListeners()}async createTableToolbar(){this.tableToolbar=document.createElement("div"),this.tableToolbar.className="table-toolbar";const t=document.createElement("div");t.className="table-toolbar-container";const e=[{name:"table-actions",buttons:[{cmd:"tableProfile",icon:"icon-table-profile",title:"Table Profile"},{cmd:"deleteTable",icon:"icon-delete-table",title:"Delete Table"}]},{name:"row-actions",buttons:[{cmd:"insertRowAbove",icon:"icon-add-row-above",title:"Add Row Above"},{cmd:"insertRowBelow",icon:"icon-add-row-below",title:"Add Row Below"},{cmd:"deleteRow",icon:"icon-delete-row",title:"Delete Selected Row"}]},{name:"col-actions",buttons:[{cmd:"insertColRight",icon:"icon-add-col-right",title:"Add Column Right"},{cmd:"insertColLeft",icon:"icon-add-col-left",title:"Add Column Left"},{cmd:"deleteCol",icon:"icon-delete-col",title:"Delete Selected Column"}]}];for(const n of e){const e=document.createElement("div");e.className=`table-toolbar-group ${n.name}`;for(const{cmd:t,icon:i,title:s}of n.buttons){const n=document.createElement("button");n.className="table-toolbar-btn",n.title=s,n.dataset.command=t;const o=m.getIcon(i.replace("icon-",""));o&&(n.innerHTML=o),n.addEventListener("click",e=>{e.preventDefault(),e.stopPropagation(),this.handleCommand(t,n)}),e.appendChild(n)}t.appendChild(e)}const n=document.createElement("div");n.className="table-toolbar-arrow",this.tableToolbar.appendChild(t),this.tableToolbar.appendChild(n),this.editor.wrapper.appendChild(this.tableToolbar)}setupEventListeners(){this.editor.editor.addEventListener("click",t=>{const e=t.target.closest("td, th"),n=t.target.closest("table");if(n&&e){if(!(!this.editor.isNodeInEditableArea||this.editor.isNodeInEditableArea(n)))return void this.hide();this.currentTable=n,this.currentCell=e,this.showAtTable(n)}else this.hide()}),document.addEventListener("mousedown",t=>{t.target.closest(".table-toolbar")||t.target.closest("table")||this.hide()}),window.addEventListener("scroll",()=>{this.isVisible&&this.currentTable&&this.updateToolbarPosition()}),this.editor.editor.addEventListener("scroll",()=>{this.isVisible&&this.currentTable&&this.updateToolbarPosition()}),this.editor.editor.addEventListener("keyup",()=>{if(this.isVisible&&this.currentTable){const t=window.getSelection();if(t&&t.rangeCount>0){const e=t.getRangeAt(0).startContainer,n=e.nodeType===Node.TEXT_NODE?e.parentElement.closest("td, th"):e.closest("td, th");if(n&&n!==this.currentCell){if(!(!this.editor.isNodeInEditableArea||this.editor.isNodeInEditableArea(n)))return void this.hide();this.currentCell=n}}}})}updateToolbarPosition(){if(!this.isVisible||!this.currentTable)return;if(!document.body.contains(this.currentTable))return void this.hide();if(!(!this.editor.isNodeInEditableArea||this.editor.isNodeInEditableArea(this.currentTable)))return void this.hide();const t=this.currentTable.getBoundingClientRect(),e=this.editor.wrapper.getBoundingClientRect(),n=window.pageYOffset||document.documentElement.scrollTop,i=window.pageXOffset||document.documentElement.scrollLeft;this.updateToolbarAt(t.left-e.left+i,t.top-e.top+n,t.width,t.height)}updateToolbarAt(t,e,n,i){this.tableToolbar&&this.ensureToolbarInViewport(t,e,n,i)}showAtTable(t){if(!t||!this.tableToolbar)return;const e=t.getBoundingClientRect(),n=this.editor.wrapper.getBoundingClientRect(),i=window.pageYOffset||document.documentElement.scrollTop,s=window.pageXOffset||document.documentElement.scrollLeft;this.showAt(e.left-n.left+s,e.top-n.top+i,e.width,e.height)}showAt(t,e,n,i){this.tableToolbar&&(this.tableToolbar.classList.add("visible"),this.isVisible=!0,this.ensureToolbarInViewport(t,e,n,i),this.clearHideTimeout())}ensureToolbarInViewport(t,e,n,i){if(!this.tableToolbar)return;const s=this.editor.editor.getBoundingClientRect();this.tableToolbar.getBoundingClientRect();const o=this.editor.wrapper.querySelector(".rich-editor-toolbar-container"),r=o?o.getBoundingClientRect():null;let l=t+n/2-this.tableToolbar.offsetWidth/2,a=e-60-document.documentElement.scrollTop,c="50%",d="down";if(l<0&&(l=t-.1*this.tableToolbar.offsetWidth,l<0&&(l=0),c="10%"),l+this.tableToolbar.offsetWidth>this.editor.wrapper.offsetWidth-2&&(l=t-.9*this.tableToolbar.offsetWidth,c="90%"),a<(r?r.height:48)&&(a=e+i+10-document.documentElement.scrollTop,d="up",a<(r?r.height:48)))return void this.hide();if(a>s.height)return void this.hide();const h=this.tableToolbar.querySelector(".table-toolbar-arrow");h&&(h.style.left=c,"up"===d?(h.style.bottom="auto",h.style.top="-8px",h.style.borderTop="none",h.style.borderBottom="8px solid #fff",h.style.borderLeft="6px solid transparent",h.style.borderRight="6px solid transparent"):(h.style.top="auto",h.style.bottom="-8px",h.style.borderBottom="none",h.style.borderTop="8px solid #fff",h.style.borderLeft="6px solid transparent",h.style.borderRight="6px solid transparent")),this.tableToolbar.style.left=l+"px",this.tableToolbar.style.top=a+"px"}hide(){this.tableToolbar&&this.isVisible&&(this.tableToolbar.classList.remove("visible"),this.isVisible=!1,this.currentTable=null,this.currentCell=null,this.clearHideTimeout())}clearHideTimeout(){this.hideTimeout&&(clearTimeout(this.hideTimeout),this.hideTimeout=null)}handleCommand(t,e){if(!this.currentTable||!this.currentCell)return;if(!this.editor.isNodeInEditableArea||this.editor.isNodeInEditableArea(this.currentTable)){switch(t){case"tableProfile":this.showTableProfile();break;case"deleteTable":this.deleteTable();break;case"insertRowAbove":this.insertRowAbove();break;case"insertRowBelow":this.insertRowBelow();break;case"deleteRow":this.deleteRow();break;case"insertColRight":this.insertColumnRight();break;case"insertColLeft":this.insertColumnLeft();break;case"deleteCol":this.deleteColumn()}this.editor.focus()}else this.hide()}insertRowAbove(){const t=this.currentCell.parentElement,e=this.createNewRow(t.cells.length);t.parentElement.insertBefore(e,t),this.editor.resizeHandles&&this.editor.resizeHandles.checkAndUpdateHandles()}insertRowBelow(){const t=this.currentCell.parentElement,e=this.createNewRow(t.cells.length);t.nextElementSibling?t.parentElement.insertBefore(e,t.nextElementSibling):t.parentElement.appendChild(e),this.editor.resizeHandles&&this.editor.resizeHandles.checkAndUpdateHandles()}insertColumnLeft(){const t=Array.from(this.currentCell.parentElement.children).indexOf(this.currentCell);(this.currentTable.querySelector("tbody")||this.currentTable).querySelectorAll("tr").forEach(e=>{const n=this.createNewCell(),i=e.children[t];i?e.insertBefore(n,i):e.appendChild(n)}),this.editor.resizeHandles&&this.editor.resizeHandles.checkAndUpdateHandles()}insertColumnRight(){const t=Array.from(this.currentCell.parentElement.children).indexOf(this.currentCell);(this.currentTable.querySelector("tbody")||this.currentTable).querySelectorAll("tr").forEach(e=>{const n=this.createNewCell(),i=e.children[t+1];i?e.insertBefore(n,i):e.appendChild(n)}),this.editor.resizeHandles&&this.editor.resizeHandles.checkAndUpdateHandles()}deleteRow(){const t=this.currentCell.parentElement;t.parentElement.children.length<=1||(t.remove(),this.editor.resizeHandles&&this.editor.resizeHandles.checkAndUpdateHandles(),this.hide())}deleteColumn(){const t=Array.from(this.currentCell.parentElement.children).indexOf(this.currentCell),e=(this.currentTable.querySelector("tbody")||this.currentTable).querySelectorAll("tr");this.currentCell.parentElement.children.length<=1||(e.forEach(e=>{e.children[t]&&e.children[t].remove()}),this.editor.resizeHandles&&this.editor.resizeHandles.checkAndUpdateHandles(),this.hide())}showTableProfile(){if(!this.currentTable)return;const t=this.currentTable.querySelectorAll("tr").length,e=this.currentTable.querySelector("tr")?this.currentTable.querySelector("tr").querySelectorAll("td, th").length:0,n=t,i=e,s=t*e,o=this.currentTable.offsetWidth,r=this.currentTable.offsetHeight;alert(`Table Profile:\nRows: ${n}\nColumns: ${i}\nTotal Cells: ${s}\nWidth: ${o}px\nHeight: ${r}px`)}deleteTable(){this.editor.resizeHandles&&this.editor.resizeHandles.hideHandles(),this.currentTable.remove(),this.hide()}createNewRow(t){const e=document.createElement("tr");for(let n=0;n<t;n++)e.appendChild(this.createNewCell());return e}createNewCell(){const t=document.createElement("td");return t.innerHTML="&nbsp;",t.style.minWidth="50px",t.style.minHeight="24px",t.style.padding="4px 8px",t.style.border="1px solid #ddd",t.style.verticalAlign="top",t.contentEditable="true",t}destroy(){this.tableToolbar&&this.tableToolbar.parentNode&&this.tableToolbar.parentNode.removeChild(this.tableToolbar),this.clearHideTimeout(),this.tableToolbar=null,this.currentTable=null,this.currentCell=null,this.isVisible=!1}}class st extends e{constructor(t,e={}){super(t,e),this.isCodeView=!1,this.originalContent="",this.codeTextarea=null,this.disabledModules=new Set,this.init()}init(){this.editor.on("toolbar-click",t=>{"code-view"===t.command&&this.toggleCodeView()})}toggleCodeView(){this.isCodeView?this.showNormalView():this.showCodeView(),this.updateToolbarButton()}showCodeView(){const t=this.editor.editor;if(!t)return;this.originalContent=t.innerHTML,this.codeTextarea=document.createElement("textarea"),this.codeTextarea.className="code-view-textarea",this.codeTextarea.value=this.formatHTML(this.originalContent),t.style.display="none",t.parentNode.insertBefore(this.codeTextarea,t);const e=this.editor.wrapper;e&&e.classList.add("code-view-active"),this.codeTextarea.focus(),this.isCodeView=!0,this.disableOtherFeatures(),this.codeTextarea.addEventListener("input",()=>{this.updateOriginalContent()})}showNormalView(){const t=this.editor.editor;if(!t||!this.codeTextarea)return;const e=this.codeTextarea.value;this.codeTextarea.parentNode.removeChild(this.codeTextarea),this.codeTextarea=null;const n=this.editor.wrapper;n&&n.classList.remove("code-view-active"),t.style.display="",t.innerHTML=e,t.focus(),this.isCodeView=!1,this.enableOtherFeatures(),this.editor.onContentChange()}disableOtherFeatures(){const t=this.editor.getModule("toolbar");if(t){["bold","italic","underline","strike","subscript","superscript","color","background","link","table","heading","font-family","line-height","capitalization","text-align","list","indent-increase","indent-decrease","text-size","emoji","image","video","tag","import","undo","redo"].forEach(e=>{t.setButtonDisabled(e,!0)}),t.setButtonDisabled("code-view",!1),t.setButtonDisabled("theme",!1)}this.disableEditorEvents(),this.disableOtherModules(),this.hideAllPopups()}enableOtherFeatures(){const t=this.editor.getModule("toolbar");if(t){["bold","italic","underline","strike","subscript","superscript","color","background","link","table","heading","font-family","line-height","capitalization","text-align","list","indent-increase","indent-decrease","text-size","emoji","image","video","tag","import","undo","redo"].forEach(e=>{t.setButtonDisabled(e,!1)})}this.enableEditorEvents(),this.enableOtherModules()}disableEditorEvents(){const t=this.editor.editor;t&&(t.contentEditable=!1,t.style.opacity="0.5",t.style.pointerEvents="none",t.style.cursor="not-allowed",t.title='Editor is disabled in code view mode. Click "Switch to Visual Editor" to return to normal editing.')}enableEditorEvents(){const t=this.editor.editor;t&&(t.contentEditable=!0,t.style.opacity="",t.style.pointerEvents="",t.style.cursor="",t.title="")}disableOtherModules(){["history","block-toolbar","table-toolbar","resize-handles"].forEach(t=>{const e=this.editor.getModule(t);if(e)if("function"==typeof e.disable)e.disable(),this.disabledModules.add(t);else if(e.getContainer&&"function"==typeof e.getContainer){const n=e.getContainer();n&&(n.style.display="none",this.disabledModules.add(t))}})}enableOtherModules(){this.disabledModules.forEach(t=>{const e=this.editor.getModule(t);if(e)if("function"==typeof e.enable)e.enable();else if(e.getContainer&&"function"==typeof e.getContainer){const t=e.getContainer();t&&(t.style.display="")}}),this.disabledModules.clear()}updateOriginalContent(){if(this.codeTextarea){this.originalContent=this.codeTextarea.value;const t=this.codeTextarea.value;this.editor.options.onChange&&"function"==typeof this.editor.options.onChange&&this.editor.options.onChange(t),this.editor.emit("text-change",t)}}formatHTML(t){let e=t;e=e.replace(/></g,">\n<"),e=e.replace(/>([^<>\s][^<]*)</g,">\n$1\n<");const n=e.split("\n"),i=[],s=[];for(let t of n){const e=t.trim();if(!e)continue;if(/^<\/(\w+)/.test(e)){const t=e.match(/^<\/(\w+)/);if(t){const e=t[1];for(let t=s.length-1;t>=0;t--)if(s[t]===e){s.splice(t,1);break}}}let n=s.length;e.startsWith("<")||(n=s.length),i.push(" ".repeat(4*n)+e);const o=e.match(/^<(\w+)/);if(o&&!e.startsWith("</")&&!e.endsWith("/>")&&!["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"].includes(o[1].toLowerCase())){const t=o[1];s.push(t)}}return i.join("\n")}updateToolbarButton(){const t=this.editor.getModule("toolbar");if(t){t.setButtonActive("code-view",this.isCodeView);const e=this.isCodeView?"Switch to Visual Editor":"Switch to HTML Editor";t.setButtonTitle("code-view",e)}}isInCodeView(){return this.isCodeView}getCurrentContent(){return this.isCodeView&&this.codeTextarea?this.codeTextarea.value:this.editor.editor.innerHTML}setContent(t){this.isCodeView&&this.codeTextarea?(this.codeTextarea.value=this.formatHTML(t),this.updateOriginalContent()):this.editor.editor.innerHTML=t}hideAllPopups(){document.querySelectorAll(".rich-editor-popup, .color-picker-popup, .emoji-picker-popup, .link-popup, .image-popup, .video-popup, .table-popup, .tag-popup, .import-popup").forEach(t=>{t.parentNode&&t.parentNode.removeChild(t)}),this.editor.popupInstances&&this.editor.popupInstances.clear()}destroy(){this.isCodeView&&this.showNormalView(),this.codeTextarea&&this.codeTextarea.parentNode&&this.codeTextarea.parentNode.removeChild(this.codeTextarea),this.codeTextarea=null,this.originalContent="",this.isCodeView=!1,this.disabledModules.clear()}}class ot extends e{static DEFAULTS={minWidth:50,minHeight:50,maxWidth:800,maxHeight:600,maintainAspectRatio:!0,snapToGrid:!1,gridSize:10};constructor(t,e={}){super(t,e),this.activeElement=null,this.handles=[],this.isResizing=!1,this.startX=0,this.startY=0,this.startWidth=0,this.startHeight=0,this.currentHandle=null,this.aspectRatio=1,this.init()}init(){this.createHandles(),this.setupEventListeners()}createHandles(){this.handlesContainer=document.createElement("div"),this.handlesContainer.className="resize-handles-container",this.handlesContainer.style.position="absolute",this.handlesContainer.style.pointerEvents="none",this.handlesContainer.style.zIndex="997",this.handlesContainer.style.display="none";[{name:"nw",cursor:"nw-resize",position:{top:-4,left:-4}},{name:"ne",cursor:"ne-resize",position:{top:-4,right:-4}},{name:"sw",cursor:"sw-resize",position:{bottom:-4,left:-4}},{name:"se",cursor:"se-resize",position:{bottom:-4,right:-4}}].forEach(t=>{const e=this.createHandle(t);this.handles.push(e),this.handlesContainer.appendChild(e)}),this.editor.wrapper.appendChild(this.handlesContainer)}createHandle(t){const e=document.createElement("div");return e.className=`resize-handle resize-handle-${t.name}`,e.style.position="absolute",e.style.width="8px",e.style.height="8px",e.style.backgroundColor="#3b82f6",e.style.border="1px solid #fff",e.style.borderRadius="50%",e.style.cursor=t.cursor,e.style.pointerEvents="auto",e.style.boxShadow="0 2px 4px rgba(0,0,0,0.2)",e.style.zIndex="999",e.dataset.handle=t.name,Object.entries(t.position).forEach(([t,n])=>{e.style[t]=n+"px"}),e.addEventListener("mousedown",e=>this.handleMouseDown(e,t.name)),e}setupEventListeners(){this.editor.editor.addEventListener("click",t=>{this.handleElementClick(t)}),document.addEventListener("click",t=>{this.isClickOnResizableElement(t)||this.isClickOnHandle(t)||this.hideHandles()}),document.addEventListener("mousemove",t=>this.handleMouseMove(t)),document.addEventListener("mouseup",t=>this.handleMouseUp(t)),window.addEventListener("scroll",()=>{this.activeElement&&this.updateHandlePosition()}),this.editor.editor.addEventListener("scroll",()=>{this.activeElement&&this.updateHandlePosition()}),this.setupMutationObserver()}handleElementClick(t){const e=t.target;let n=this.findResizableElement(e);n&&(t.preventDefault(),t.stopPropagation(),this.showHandles(n))}findResizableElement(t){if(this.isResizableElement(t))return t;if("TD"===t.tagName||"TH"===t.tagName||"TR"===t.tagName||"TBODY"===t.tagName){let e=t.parentElement;for(;e&&"TABLE"!==e.tagName;)e=e.parentElement;if(e&&this.isResizableElement(e))return e}let e=t.parentElement;for(;e&&e!==this.editor.wrapper;){if(this.isResizableElement(e))return e;e=e.parentElement}return null}isResizableElement(t){const e=t.classList.contains("inserted-image"),n=t.classList.contains("inserted-video"),i=t.classList.contains("rich-editor-table");return e||n||i}isClickOnResizableElement(t){return this.isResizableElement(t.target)}isClickOnHandle(t){return t.target.classList.contains("resize-handle")}showHandles(t){this.activeElement=t,this.updateHandlePosition(),this.handlesContainer.style.display="block",(t.classList.contains("inserted-image")||t.classList.contains("inserted-video"))&&(this.aspectRatio=t.offsetWidth/t.offsetHeight),t.classList.contains("rich-editor-table")&&(t.style.position="relative",t.style.display="table",this.lastTableWidth=t.offsetWidth,this.lastTableHeight=t.offsetHeight,this.setupTableSizeMonitoring(t))}hideHandles(){this.tableSizeInterval&&(clearInterval(this.tableSizeInterval),this.tableSizeInterval=null),this.activeElement=null,this.handlesContainer.style.display="none"}updateHandlePosition(){if(!this.activeElement)return;if(!document.body.contains(this.activeElement))return void this.hideHandles();const t=this.activeElement.getBoundingClientRect(),e=this.editor.wrapper.getBoundingClientRect(),n=this.editor.wrapper.scrollTop||0,i=this.editor.wrapper.scrollLeft||0,s=t.top-e.top+n,o=t.left-e.left+i,r=t.width,l=t.height,a=s+l;this.handlesContainer.style.top=s+"px",this.handlesContainer.style.left=o+"px",this.handlesContainer.style.width=r+"px",this.handlesContainer.style.height=l+"px",(a<0||s>e.height)&&this.hideHandles()}handleMouseDown(t,e){t.preventDefault(),t.stopPropagation(),this.isResizing=!0,this.currentHandle=e,this.startX=t.clientX,this.startY=t.clientY,this.startWidth=this.activeElement.offsetWidth,this.startHeight=this.activeElement.offsetHeight;const n=this.activeElement.getBoundingClientRect();this.startLeft=n.left,this.startTop=n.top,this.activeElement.classList.add("resizing"),document.body.style.cursor=t.target.style.cursor,document.body.style.userSelect="none"}handleMouseMove(t){if(!this.isResizing||!this.activeElement)return;const e=t.clientX-this.startX,n=t.clientY-this.startY;let i=this.startWidth,s=this.startHeight;switch(this.currentHandle){case"nw":i=this.startWidth-e,s=this.startHeight-n;break;case"ne":i=this.startWidth+e,s=this.startHeight-n;break;case"sw":i=this.startWidth-e,s=this.startHeight+n;break;case"se":i=this.startWidth+e,s=this.startHeight+n}if(i=Math.max(this.options.minWidth,Math.min(this.options.maxWidth,i)),s=Math.max(this.options.minHeight,Math.min(this.options.maxHeight,s)),(this.activeElement.classList.contains("inserted-image")||this.activeElement.classList.contains("inserted-video"))&&this.options.maintainAspectRatio){const t=i/this.aspectRatio,e=s*this.aspectRatio;Math.abs(i-e)<Math.abs(s-t)?i=e:s=t}this.options.snapToGrid&&(i=Math.round(i/this.options.gridSize)*this.options.gridSize,s=Math.round(s/this.options.gridSize)*this.options.gridSize),this.applyDimensions(i,s),this.updateHandlePosition(),this.emit("element-resize",{element:this.activeElement,width:i,height:s,handle:this.currentHandle})}handleMouseUp(t){this.isResizing&&(this.isResizing=!1,this.currentHandle=null,this.activeElement&&this.activeElement.classList.remove("resizing"),document.body.style.cursor="",document.body.style.userSelect="",this.emit("element-resize-complete",{element:this.activeElement,width:this.activeElement.offsetWidth,height:this.activeElement.offsetHeight}))}applyDimensions(t,e){if(this.activeElement)if(this.activeElement.classList.contains("rich-editor-table")){this.activeElement.style.width=t+"px",this.activeElement.style.minWidth=t+"px",this.activeElement.style.height=e+"px",this.activeElement.style.minHeight=e+"px";const n=this.activeElement.querySelectorAll("tr"),i=n.length>0?n[0].querySelectorAll("td, th").length:0;if(n.length>0&&i>0){const s=Math.floor(t/i),o=Math.floor(e/n.length);this.activeElement.querySelectorAll("td, th").forEach(t=>{t.style.minWidth=s+"px",t.style.minHeight=o+"px",t.style.height=o+"px"})}}else this.activeElement.style.width=t+"px",this.activeElement.style.height=e+"px","IFRAME"===this.activeElement.tagName&&(this.activeElement.width=t,this.activeElement.height=e)}getActiveElement(){return this.activeElement}setActiveElement(t){this.isResizableElement(t)&&this.showHandles(t)}checkAndUpdateHandles(){if(this.activeElement){if(!document.body.contains(this.activeElement)||!this.isResizableElement(this.activeElement))return void this.hideHandles();this.updateHandlePosition(),this.activeElement.classList.contains("rich-editor-table")&&this.checkTableSizeChange()}}refreshHandles(){this.activeElement&&document.body.contains(this.activeElement)&&this.updateHandlePosition()}setupTableSizeMonitoring(t){this.tableSizeInterval&&clearInterval(this.tableSizeInterval),this.tableSizeInterval=setInterval(()=>{this.activeElement&&this.activeElement.classList.contains("rich-editor-table")?this.checkTableSizeChange():(clearInterval(this.tableSizeInterval),this.tableSizeInterval=null)},100)}checkTableSizeChange(){if(!this.activeElement||!this.activeElement.classList.contains("rich-editor-table"))return;const t=this.activeElement.offsetWidth,e=this.activeElement.offsetHeight;(Math.abs(t-this.lastTableWidth)>1||Math.abs(e-this.lastTableHeight)>1)&&(this.lastTableWidth=t,this.lastTableHeight=e,this.updateHandlePosition(),this.emit("table-size-changed",{element:this.activeElement,width:t,height:e,previousWidth:this.lastTableWidth,previousHeight:this.lastTableHeight}))}setupMutationObserver(){"undefined"!=typeof MutationObserver&&(this.mutationObserver=new MutationObserver(t=>{let e=!1;t.forEach(t=>{if(this.activeElement){if("childList"===t.type){if(t.removedNodes)for(let n of t.removedNodes)if(n===this.activeElement||n.contains(this.activeElement)){e=!0;break}(t.target===this.activeElement||t.target.nodeType===Node.ELEMENT_NODE&&this.activeElement.contains(t.target))&&(e=!0)}if("characterData"===t.type&&this.activeElement.classList.contains("rich-editor-table")){let n=t.target;for(;n&&n!==this.activeElement;)n=n.parentNode;n===this.activeElement&&(e=!0)}if("attributes"===t.type&&this.activeElement.classList.contains("rich-editor-table")){const n=t.attributeName;"style"!==n&&"class"!==n||(e=!0)}}}),e&&setTimeout(()=>{this.checkAndUpdateHandles()},0)}),this.mutationObserver.observe(this.editor.editor,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["style","class"],characterData:!0,characterDataOldValue:!0}))}setMaintainAspectRatio(t){this.options.maintainAspectRatio=t}setConstraints(t,e,n,i){this.options.minWidth=t||this.options.minWidth,this.options.minHeight=e||this.options.minHeight,this.options.maxWidth=n||this.options.maxWidth,this.options.maxHeight=i||this.options.maxHeight}destroy(){this.hideHandles(),this.handlesContainer&&this.handlesContainer.remove(),this.tableSizeInterval&&(clearInterval(this.tableSizeInterval),this.tableSizeInterval=null),this.mutationObserver&&(this.mutationObserver.disconnect(),this.mutationObserver=null),super.destroy()}}t.register("formats/bold",l,!0),t.register("formats/italic",a,!0),t.register("formats/underline",c,!0),t.register("formats/strike",d,!0),t.register("formats/subscript",u,!0),t.register("formats/superscript",h,!0),t.register("formats/color",w,!0),t.register("formats/background",E,!0),t.register("formats/link",I,!0),t.register("formats/table",L,!0),t.register("formats/heading",N,!0),t.register("formats/font-family",H,!0),t.register("formats/line-height",k,!0),t.register("formats/capitalization",A,!0),t.register("formats/text-align",P,!0),t.register("formats/list",R,!0),t.register("formats/indent",O,!0),t.register("formats/indent-increase",z,!0),t.register("formats/indent-decrease",F,!0),t.register("formats/emoji",D,!0),t.register("formats/image",Z,!0),t.register("formats/video",W,!0),t.register("formats/tag",Y,!0),t.register("formats/text-size",$,!0),t.register("formats/import",Q,!0),t.register("modules/toolbar",tt,!0),t.register("modules/history",et,!0),t.register("modules/block-toolbar",nt,!0),t.register("modules/table-toolbar",it,!0),t.register("modules/code-view",st,!0),t.register("modules/resize-handles",ot,!0),t.register("ui/color-picker",v,!0),t.register("ui/text-align-picker",B,!0),t.register("ui/list-picker",V,!0),t.register("ui/emoji-picker",_,!0),t.register("ui/image-popup",j,!0),t.register("ui/video-popup",q,!0),t.register("ui/tag-popup",G,!0),t.register("ui/custom-button",J,!0),class{static loaded=!1;static styleElement=null;static async loadStyles(){if(!this.loaded)try{this.styleElement=document.createElement("style"),this.styleElement.id="rich-editor-styles";const t=await fetch(new URL("./styles.css",import.meta.url)),e=await t.text();this.styleElement.textContent=e,document.head.appendChild(this.styleElement),this.loaded=!0}catch(t){this.loadFallbackStyles()}}static loadFallbackStyles(){this.styleElement=document.createElement("style"),this.styleElement.id="rich-editor-styles-fallback",this.styleElement.textContent="\n .yjd-rich-editor { \n position: relative; \n background: #fff; \n border: 1px solid #ddd; \n border-radius: 4px; \n display: flex; \n flex-direction: column; \n font-family: system-ui, sans-serif; \n }\n .yjd-rich-editor .rich-editor-area { \n flex: 1; \n padding: 20px; \n outline: none; \n min-height: 100px; \n }\n .yjd-rich-editor .rich-editor-toolbar { \n display: flex; \n gap: 4px; \n padding: 8px; \n border-bottom: 1px solid #ddd; \n background: #f9f9f9; \n }\n .yjd-rich-editor .rich-editor-toolbar-btn { \n padding: 4px 8px; \n border: 1px solid #ccc; \n border-radius: 3px; \n background: #fff; \n cursor: pointer; \n }\n .yjd-rich-editor .table-grid-selector { \n position: absolute; \n background: white; \n border: 1px solid #ccc; \n border-radius: 4px; \n padding: 10px; \n box-shadow: 0 2px 8px rgba(0,0,0,0.15); \n z-index: 1000; \n display: none; \n }\n .yjd-rich-editor .table-grid-cell { \n width: 20px; \n height: 20px; \n border: 1px solid #ddd; \n cursor: pointer; \n background: white; \n }\n ",document.head.appendChild(this.styleElement),this.loaded=!0}static unloadStyles(){this.styleElement&&this.styleElement.parentNode&&(this.styleElement.parentNode.removeChild(this.styleElement),this.styleElement=null,this.loaded=!1)}static isLoaded(){return this.loaded}static async reloadStyles(){this.unloadStyles(),await this.loadStyles()}static addCustomCSS(t,e="rich-editor-custom"){const n=document.getElementById(e);n&&n.remove();const i=document.createElement("style");i.id=e,i.textContent=t,document.head.appendChild(i)}}.loadStyles().catch(t=>{});class rt extends n{static register(e,n,i=!1){t.register(e,n,i)}static get(e){return t.get(e)}static create(t,e={}){return new rt(t,e)}}function lt(t,e={}){return new rt(t,e)}export{E as Background,o as BlockFormat,nt as BlockToolbar,l as Bold,A as Capitalization,st as CodeView,w as Color,v as ColorPicker,n as Editor,D as Emoji,_ as EmojiPicker,H as FontFamily,i as Format,N as Heading,et as History,m as IconUtils,Z as Image,j as ImagePopup,Q as Import,O as Indent,F as IndentDecrease,z as IndentIncrease,s as InlineFormat,a as Italic,k as LineHeight,I as Link,T as LinkPopup,R as List,V as ListPicker,e as Module,ot as ResizeHandles,d as Strike,u as Subscript,h as Superscript,L as Table,x as TablePopup,it as TableToolbar,Y as Tag,G as TagPopup,P as TextAlign,B as TextAlignPicker,$ as TextSize,tt as Toolbar,c as Underline,W as Video,q as VideoPopup,J as createCustomButton,lt as createEditor,rt as default,t as registry};
1
+ const t=new class{constructor(){this.modules=new Map,this.formats=new Map,this.themes=new Map,this.ui=new Map}register(t,e,i=!1){if("object"==typeof t)return void Object.entries(t).forEach(([t,e])=>{this.register(t,e,i)});const[o,n]=t.split("/");if(!i){this.get(t)}switch(o){case"modules":this.modules.set(n,e);break;case"formats":this.formats.set(n,e);break;case"themes":this.themes.set(n,e);break;case"ui":this.ui.set(n,e)}}get(t){const[e,i]=t.split("/");switch(e){case"modules":return this.modules.get(i);case"formats":return this.formats.get(i);case"themes":return this.themes.get(i);case"ui":return this.ui.get(i);default:return null}}has(t){return null!==this.get(t)&&void 0!==this.get(t)}getAll(t){switch(t){case"modules":return new Map(this.modules);case"formats":return new Map(this.formats);case"themes":return new Map(this.themes);case"ui":return new Map(this.ui);default:return new Map}}unregister(t){const[e,i]=t.split("/");switch(e){case"modules":this.modules.delete(i);break;case"formats":this.formats.delete(i);break;case"themes":this.themes.delete(i);break;case"ui":this.ui.delete(i)}}clear(){this.modules.clear(),this.formats.clear(),this.themes.clear(),this.ui.clear()}getAllItems(){const t={};return t.modules=Array.from(this.modules.keys()),t.formats=Array.from(this.formats.keys()),t.themes=Array.from(this.themes.keys()),t.ui=Array.from(this.ui.keys()),t}};class e{static DEFAULTS={};constructor(t,e={}){this.editor=t,this.options={...this.constructor.DEFAULTS,...e},this.events=new Map}on(t,e){this.events.has(t)||this.events.set(t,[]),this.events.get(t).push(e)}off(t,e){if(this.events.has(t)){const i=this.events.get(t),o=i.indexOf(e);o>-1&&i.splice(o,1)}}emit(t,e){this.events.has(t)&&this.events.get(t).forEach(t=>{try{t(e)}catch(t){}})}destroy(){this.events.clear()}onContentChange(){}onSelectionChange(t){}}function i(t,e=null){try{return null==e?document.execCommand(t,!1):document.execCommand(t,!1,e)}catch(t){return!1}}function o(t=!0){return i("styleWithCSS",t)}function n(t){try{return document.queryCommandState(t)}catch(t){return!1}}const r=["http:","https:","mailto:","tel:","ftp:"],s=["https://www.youtube.com/embed/","https://www.youtube-nocookie.com/embed/","https://player.vimeo.com/video/"];function a(t,{allowDataImage:e=!1}={}){if("string"!=typeof t)return!1;const i=t.trim();if(""===i)return!1;const o=i.replace(/[\u0000-\u0020\u007F-\u009F]/g,""),n=o.match(/^([a-z][a-z0-9+.-]*):/i);if(!n)return!0;const s=n[1].toLowerCase()+":";return"data:"===s?!!e&&(/^data:image\//i.test(o)&&!/^data:image\/svg/i.test(o)):r.includes(s)}const l=new Set(["SCRIPT","STYLE","OBJECT","EMBED","LINK","META","BASE","FORM","INPUT","BUTTON","TEXTAREA","SELECT","OPTION","NOSCRIPT"]);function c(t){const e=Array.from(t.attributes);for(const i of e){const e=i.name.toLowerCase(),o=i.value;if(e.startsWith("on"))t.removeAttribute(i.name);else{if("href"===e||"src"===e||"xlink:href"===e){a(o,{allowDataImage:"IMG"===t.tagName})||t.removeAttribute(i.name);continue}"style"===e&&/expression\s*\(|javascript:/i.test(o)&&t.removeAttribute(i.name)}}}function d(t){if("string"!=typeof t||""===t)return"";const e=(new DOMParser).parseFromString(t,"text/html"),i=Array.from(e.body.querySelectorAll("*"));for(const t of i){const e=t.tagName;if(l.has(e))t.remove();else{if("IFRAME"===e){const e=t.getAttribute("src")||"";if(!s.some(t=>e.startsWith(t))){t.remove();continue}}c(t)}}return e.body.innerHTML}function h(t){const e=document.createElement("div");return e.innerHTML=t||"",p(e,0).replace(/\n{3,}/g,"\n\n").trim()+"\n"}function p(t,e){let i="";return t.childNodes.forEach(t=>{i+=function(t,e){if(3===t.nodeType){const e=t.textContent.replace(/\s+/g," ");return e.trim()?e+"\n\n":""}if(1!==t.nodeType)return"";const i=t.tagName;switch(i){case"H1":case"H2":case"H3":case"H4":case"H5":case"H6":return"#".repeat(+i[1])+" "+g(t)+"\n\n";case"P":case"DIV":{const e=g(t);return e.trim()?e+"\n\n":""}case"BLOCKQUOTE":return g(t).split("\n").map(t=>"> "+t).join("\n")+"\n\n";case"PRE":return"```\n"+t.textContent.replace(/\n$/,"")+"\n```\n\n";case"UL":return u(t,e,!1)+"\n";case"OL":return u(t,e,!0)+"\n";case"HR":return"---\n\n";case"TABLE":return function(t){const e=[...t.querySelectorAll("tr")];if(!e.length)return"";const i=t=>[...t.children].map(t=>g(t).replace(/\|/g,"\\|").trim()),o=i(e[0]);let n="| "+o.join(" | ")+" |\n| "+o.map(()=>"---").join(" | ")+" |\n";return e.slice(1).forEach(t=>{n+="| "+i(t).join(" | ")+" |\n"}),n}(t)+"\n";case"FIGURE":return p(t,e);case"IMG":return m(t)+"\n\n";case"BR":return"\n";default:return g(t)+"\n\n"}}(t,e)}),i}function u(t,e,i){let o="",n=1;return t.childNodes.forEach(t=>{if(1!==t.nodeType||"LI"!==t.tagName)return;const r=i?n+++". ":"- ",s=" ".repeat(e);let a="",l="";t.childNodes.forEach(t=>{1!==t.nodeType||"UL"!==t.tagName&&"OL"!==t.tagName?a+=f(t):l+=u(t,e+1,"OL"===t.tagName)}),o+=s+r+a.trim()+"\n"+l}),o}function m(t){return`![${t.getAttribute("alt")||""}](${t.getAttribute("src")||""})`}function g(t){let e="";return t.childNodes.forEach(t=>{e+=f(t)}),e}function f(t){if(3===t.nodeType)return t.textContent;if(1!==t.nodeType)return"";const e=t.tagName;if(t.classList&&t.classList.contains("mention")){const e=t.getAttribute("data-id")||"",i=(t.textContent||"").replace(/^[@#]/,"");return`${(t.textContent||"@")[0]}[${i}](${e})`}switch(e){case"B":case"STRONG":return"**"+g(t)+"**";case"I":case"EM":return"*"+g(t)+"*";case"S":case"STRIKE":case"DEL":return"~~"+g(t)+"~~";case"U":return"<u>"+g(t)+"</u>";case"CODE":return"`"+t.textContent+"`";case"A":return"["+g(t)+"]("+(t.getAttribute("href")||"")+")";case"IMG":return m(t);case"BR":return" \n";default:return g(t)}}function y(t){const e=(t||"").replace(/\r\n/g,"\n").split("\n");let i="",o=0;const n=t=>/^\s*([-*+]|\d+\.)\s+/.test(t);for(;o<e.length;){const t=e[o];if(/^\s*$/.test(t)){o++;continue}if(/^---+$/.test(t.trim())){i+="<hr>",o++;continue}const r=t.match(/^(#{1,6})\s+(.*)$/);if(r){i+=`<h${r[1].length}>${C(r[2])}</h${r[1].length}>`,o++;continue}if(/^```/.test(t)){o++;let t="";for(;o<e.length&&!/^```/.test(e[o]);)t+=e[o]+"\n",o++;o++,i+="<pre>"+w(t.replace(/\n$/,""))+"</pre>";continue}if(/^>\s?/.test(t)){const t=[];for(;o<e.length&&/^>\s?/.test(e[o]);)t.push(e[o].replace(/^>\s?/,"")),o++;i+="<blockquote>"+C(t.join(" "))+"</blockquote>";continue}if(/^\|.*\|\s*$/.test(t)&&o+1<e.length&&/^\|[\s:|-]+\|\s*$/.test(e[o+1])){const t=x(e,o);i+=t.html,o=t.next;continue}if(n(t)){const t=v(e,o,0);i+=t.html,o=t.next;continue}const s=[t];for(o++;o<e.length&&!/^\s*$/.test(e[o])&&!/^(#{1,6}\s|>|```)/.test(e[o])&&!/^---+$/.test(e[o].trim())&&!n(e[o]);)s.push(e[o]),o++;i+="<p>"+C(s.join("\n").trim())+"</p>"}return i}function b(t){return(t.match(/^(\s*)/)[1]||"").length}function v(t,e,i){const o=/^\s*\d+\./.test(t[e]);let n=e,r="<"+(o?"ol":"ul")+">";for(;n<t.length;){const e=t[n];if(/^\s*$/.test(e)){n++;continue}const o=b(e),s=e.match(/^\s*([-*+]|\d+\.)\s+(.*)$/);if(!s||o<i)break;if(o>i){const e=v(t,n,o);r=r.replace(/<\/li>$/,e.html+"</li>"),n=e.next;continue}r+="<li>"+C(s[2])+"</li>",n++}return{html:r+"</"+(o?"ol":"ul")+">",next:n}}function x(t,e){const i=t=>t.trim().replace(/^\||\|$/g,"").split("|").map(t=>t.trim()),o=i(t[e]);let n=e+2,r="";for(;n<t.length&&/^\|.*\|\s*$/.test(t[n]);)r+="<tr>"+i(t[n]).map(t=>`<td>${C(t)}</td>`).join("")+"</tr>",n++;return{html:`<table class="rich-editor-table"><tbody>${"<tr>"+o.map(t=>`<td><b>${C(t)}</b></td>`).join("")+"</tr>"}${r}</tbody></table>`,next:n}}function C(t){return t.replace(/!\[([^\]]*)\]\(([^)]+)\)/g,(t,e,i)=>`<img class="inserted-image" src="${E(i)}" alt="${E(e)}" style="max-width:100%;height:auto">`).replace(/([@#])\[([^\]]+)\]\(([^)]+)\)/g,(t,e,i,o)=>`<span class="mention" data-id="${E(o)}">${e}${w(i)}</span>`).replace(/\[([^\]]+)\]\(([^)]+)\)/g,(t,e,i)=>`<a href="${E(i)}" target="_blank" rel="noopener noreferrer">${w(e)}</a>`).replace(/\*\*([^*]+)\*\*/g,"<b>$1</b>").replace(/(^|[^*])\*([^*]+)\*/g,"$1<i>$2</i>").replace(/~~([^~]+)~~/g,"<s>$1</s>").replace(/`([^`]+)`/g,(t,e)=>"<code>"+w(e)+"</code>").replace(/\n/g,"<br>")}function w(t){return String(t).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function E(t){return String(t).replace(/"/g,"&quot;").replace(/</g,"&lt;")}function k(t){const e=document.createElement("div");return e.innerHTML=t||"",{type:"doc",content:[...e.childNodes].map(j).filter(Boolean)}}function j(t){if(3===t.nodeType){const e=t.textContent;return e?{text:e}:null}if(1!==t.nodeType)return null;const e={tag:t.tagName.toLowerCase()};if(t.attributes.length){e.attrs={};for(const i of t.attributes)e.attrs[i.name]=i.value}const i=[...t.childNodes].map(j).filter(Boolean);return i.length&&(e.content=i),e}function T(t){return(t&&t.content?t.content:Array.isArray(t)?t:[]).map(I).join("")}function I(t){if(null==t)return"";if(null!=t.text)return w(t.text);if(!t.tag)return"";const e=t.attrs?Object.entries(t.attrs).map(([t,e])=>` ${t}="${E(e)}"`).join(""):"",i=(t.content||[]).map(I).join("");return new Set(["img","hr","br","input"]).has(t.tag)?`<${t.tag}${e}>`:`<${t.tag}${e}>${i}</${t.tag}>`}class S{static DEFAULTS={placeholder:"Start typing...",theme:"light",height:400,width:800,maxWidth:1200,maxHeight:800,content:null,features:{emoji:!0,image:!0,table:!0,wordCount:!0,breadcrumb:!0}};static currentInstance=null;static instances=new Map;constructor(e,i={}){this.options={...S.DEFAULTS,...i,features:{...S.DEFAULTS.features,...i.features||{}}},this.root="string"==typeof e?document.querySelector(e):e,this.modules=new Map,this.formats=new Map,this.registry=t,this.events=new Map,this.toolbarBtns={},this.statusbarEls={},this.dropdownMenus={},this.popupInstances=new Map,S.currentInstance=this;const o=this.generateInstanceId();this.instanceId=o,S.instances.set(o,this),this.init()}generateInstanceId(){return"editor_"+Date.now()+"_"+Math.random().toString(36).substr(2,9)}init(){this.createStructure(),this.loadModules(),this.loadFormats(),this.setupEventListeners(),this.updateStatusbar()}createStructure(){this.wrapper=document.createElement("div"),this.wrapper.className="yjd-rich-editor";const t=t=>"number"==typeof t?t+"px":t;this.wrapper.style.width=t(this.options.width),this.wrapper.style.maxWidth=t(this.options.maxWidth),this.wrapper.style.minHeight=t(this.options.height),this.wrapper.style.maxHeight=t(this.options.maxHeight),this.wrapper.style.position="relative",this.editor=document.createElement("div"),this.editor.className="rich-editor-area",this.editor.contentEditable=!0,this.editor.setAttribute("data-placeholder",this.options.placeholder),this.editor.setAttribute("role","textbox"),this.editor.setAttribute("aria-multiline","true"),this.editor.setAttribute("aria-label",this.options.ariaLabel||this.options.placeholder||"Rich text editor"),this.options.direction&&this.editor.setAttribute("dir","rtl"===this.options.direction?"rtl":"ltr"),i("defaultParagraphSeparator","p"),this.editor.innerHTML=this.getDefaultContent(),this.wrapper.appendChild(this.editor),this.popupContainer=document.createElement("div"),this.popupContainer.className="rich-editor-popup-container",this.popupContainer.style.position="absolute",this.popupContainer.style.top="0",this.popupContainer.style.left="0",this.popupContainer.style.width="100%",this.popupContainer.style.height="100%",this.popupContainer.style.pointerEvents="none",this.popupContainer.style.zIndex="1000",this.wrapper.appendChild(this.popupContainer),(this.options.features.wordCount||this.options.features.breadcrumb)&&this.createStatusbar(),this.root.appendChild(this.wrapper),this.updatePlaceholderVisibility()}isHtmlContent(t){if(!t||"string"!=typeof t)return!1;const e=t.trim();return[/<[^>]+>/,/&[a-zA-Z]+;/,/&#\d+;/].some(t=>t.test(e))}wrapTextInParagraph(t){if(!t||"string"!=typeof t)return"<p><br></p>";const e=t.trim();return this.isHtmlContent(e)?e:""===e?"<p><br></p>":`<p>${e}</p>`}getDefaultContent(){if(this.options.content)return this.wrapTextInParagraph(this.options.content);const t=this._getAutosaved();return null!=t&&""!==t?t:""}createStatusbar(){this.statusbar=document.createElement("div"),this.statusbar.className="rich-editor-statusbar",this.statusbarEls.breadcrumb=document.createElement("span"),this.statusbarEls.breadcrumb.className="rich-editor-breadcrumb",this.statusbarEls.wordcount=document.createElement("span"),this.statusbarEls.wordcount.className="wordcount",this.statusbar.appendChild(this.statusbarEls.breadcrumb),this.statusbar.appendChild(this.statusbarEls.wordcount),this.wrapper.appendChild(this.statusbar)}loadModules(){let t;t=this.options.toolbar||this.options.toolbar1||this.options.toolbar2?this.options.modules||["toolbar","history"]:this.options.modules||["toolbar","history","block-toolbar","table-toolbar","code-view","theme-switcher","resize-handles","find-replace","slash-menu","mention"],this.options.mention&&!t.includes("mention")&&t.push("mention"),t.forEach(t=>{const e=this.registry.get(`modules/${t}`);if(e){const i=new e(this,"toolbar"===t?this.options:this.options[t]||this.options);if(this.modules.set(t,i),"toolbar"===t&&i.getContainer){const t=i.getContainer();this.wrapper.insertBefore(t,this.editor),i.on("toolbar-click",t=>{this.handleToolbarClick(t)})}}})}loadFormats(){let t;t=this.options.toolbar||this.options.toolbar1||this.options.toolbar2?this.options.formats||["bold","italic","underline","strike"]:this.options.formats||["bold","italic","underline","strike","subscript","superscript","color","background","text-align","text-size","link","code","h1","h2","h3","h4","h5","h6","paragraph","pre"],t.forEach(t=>{const e=this.registry.get(`formats/${t}`);e&&this.formats.set(t,e)})}setupEventListeners(){this._markActive=()=>{S.currentInstance=this},this.wrapper.addEventListener("pointerdown",this._markActive,!0),this.wrapper.addEventListener("focusin",this._markActive,!0),this.editor.addEventListener("input",()=>{this.updatePlaceholderVisibility(),this.onContentChange()}),this._onDocSelectionChange=()=>{(document.activeElement===this.editor||this.editor.contains(document.activeElement))&&this._scheduleSelectionUpdate()},document.addEventListener("selectionchange",this._onDocSelectionChange),this.editor.addEventListener("mouseup",()=>this._scheduleSelectionUpdate()),this.editor.addEventListener("click",()=>{this.ensureEditorHasContent()}),this.editor.addEventListener("contextmenu",t=>{}),this.editor.addEventListener("keydown",t=>{if(!t.ctrlKey&&!t.metaKey||t.altKey)return;const e={b:"bold",i:"italic",u:"underline",k:"link"}[t.key.toLowerCase()];e&&(t.shiftKey||(t.preventDefault(),this.toggleFormat(e)))}),this.editor.addEventListener("keydown",t=>{"Delete"!==t.key&&"Backspace"!==t.key||setTimeout(()=>{this.ensureEditorHasContent(),this.updatePlaceholderVisibility()},0)}),this.editor.addEventListener("paste",t=>{this.handlePaste(t)}),this.editor.addEventListener("dragover",t=>{t.dataTransfer&&Array.from(t.dataTransfer.types||[]).includes("Files")&&t.preventDefault()}),this.editor.addEventListener("drop",t=>{const e=t.dataTransfer,i=(e&&e.files?Array.from(e.files):[]).find(t=>t.type&&t.type.startsWith("image/"));if(i)return t.preventDefault(),this.placeCaretAtPoint(t.clientX,t.clientY),void this.insertImageFile(i);setTimeout(()=>{this.ensureEditorHasContent(),this.updatePlaceholderVisibility()},0)}),this.options.maxLength&&this.editor.addEventListener("beforeinput",t=>{if(!t.inputType||!t.inputType.startsWith("insert"))return;if("insertFromPaste"===t.inputType)return;const e=t.data?t.data.length:1;this._remainingChars()<e&&t.preventDefault()}),!1!==this.options.markdown&&this.editor.addEventListener("keydown",t=>{" "!==t.key||t.ctrlKey||t.metaKey||t.altKey||this.handleMarkdownShortcut(t)}),this.editor.addEventListener("cut",()=>{setTimeout(()=>{this.ensureEditorHasContent(),this.updatePlaceholderVisibility()},0)}),setTimeout(()=>{this.ensureEditorHasContent(),this.updatePlaceholderVisibility(),this.updateHistoryButtons(),this.focus()},100),this.editor.addEventListener("focus",()=>{setTimeout(()=>{this.ensureEditorHasContent(),this.updatePlaceholderVisibility()},0)})}onContentChange(){this.ensureEditorHasContent(),this._emitChange()}_emitChange(){this.modules.forEach(t=>{"function"==typeof t.onContentChange&&t.onContentChange()}),this.updateStatusbar();const t=this.getContent();this.options.onChange&&"function"==typeof this.options.onChange&&this.options.onChange(t),this._scheduleAutosave(t),this.emit("change",t),this.emit("text-change",t)}ensureEditorHasContent(){if(!this.isEditorEmpty())return;const t=this.isSelectionInEditableArea(window.getSelection());if("<p><br></p>"!==this.editor.innerHTML){const t=document.createElement("p");t.innerHTML="<br>",this.editor.innerHTML="",this.editor.appendChild(t),this.setCursorToElement(t),this.editor.focus()}(t||document.activeElement===this.editor)&&this._clearStickyInlineFormats(),this.updateToolbarButtonStates(),this.updateStatusbar()}_clearStickyInlineFormats(){["bold","italic","underline","strikeThrough"].forEach(t=>{n(t)&&i(t)})}ensureParagraphForEditing(){const t=this.editor.children;if(0===t.length){const t=document.createElement("p");return t.innerHTML="<br>",this.editor.appendChild(t),void this.setCursorToElement(t)}const e=t[t.length-1];if(!["P","DIV","H1","H2","H3","H4","H5","H6","BLOCKQUOTE","PRE","ARTICLE","SECTION","MAIN","ASIDE"].includes(e.tagName)){const t=document.createElement("p");t.innerHTML="<br>",this.editor.appendChild(t)}}isEditorEmpty(){const t=this.editor.textContent;return(!t||""===t.replace(/\u200B/g,"").trim())&&!this.editor.querySelector("img, table, hr, video, iframe, audio, figure")}setCursorToElement(t){const e=document.createRange(),i=window.getSelection();t.firstChild&&t.firstChild.nodeType===Node.TEXT_NODE?e.setStart(t.firstChild,0):e.setStart(t,0),e.collapse(!0),i.removeAllRanges(),i.addRange(e)}_scheduleSelectionUpdate(){this._selUpdateQueued||(this._selUpdateQueued=!0,requestAnimationFrame(()=>{this._selUpdateQueued=!1,this.onSelectionChange()}))}onSelectionChange(){const t=window.getSelection(),e=t.rangeCount>0?t.getRangeAt(0):null,i=this.isSelectionInEditableArea(t);i&&(S.currentInstance=this,e&&!e.collapsed&&(this._lastRange=e.cloneRange())),this.modules.forEach(t=>{"function"==typeof t.onSelectionChange&&t.onSelectionChange(e,i)}),this.updateToolbarButtonStates(),this.updateToolbarAccessibility(i),this.updateStatusbar()}isSelectionInEditableArea(t){if(!t||0===t.rangeCount)return!1;const e=t.getRangeAt(0),i=e.startContainer,o=e.endContainer,n=this.isNodeInEditableArea(i),r=this.isNodeInEditableArea(o);return n&&r}isNodeInEditableArea(t){if(!t)return!1;let e=t.nodeType===Node.TEXT_NODE?t.parentNode:t;for(;e&&e!==document.body;){if(e===this.editor||e.classList&&e.classList.contains("rich-editor-area"))return!0;e=e.parentNode}return!1}updateToolbarAccessibility(t){const e=this.getModule("toolbar");if(!e)return;["bold","italic","underline","strike","subscript","superscript","color","background","link","table","heading","font-family","line-height","capitalization","text-align","list","indent-increase","indent-decrease","text-size"].forEach(i=>{e.setButtonDisabled(i,!t)});["more","undo","redo","code-view","theme"].forEach(t=>{e.setButtonDisabled(t,!1)})}updateStatusbar(){if(!this.statusbar)return;const t=window.getSelection();if(t){if(this.statusbarEls.breadcrumb&&this.options.features.breadcrumb){const e=t.anchorNode;if(e&&this.editor.contains(e)){const t=[];let i=3===e?.nodeType?e.parentElement:e;for(;i&&i!==this.editor&&i!==document.body;){if(i.tagName){let e=i.tagName.toLowerCase();if(i.className&&"string"==typeof i.className){const t=i.className.trim();t&&(e+="."+t.split(" ").join("."))}i.id&&(e+="#"+i.id),t.unshift(e)}i=i.parentElement}this.statusbarEls.breadcrumb.textContent=t.length>0?t.join(" > "):"editor"}else this.statusbarEls.breadcrumb.textContent="editor"}if(this.statusbarEls.wordcount&&this.options.features.wordCount){let t;const e=this.getModule("code-view");if(e&&"function"==typeof e.isInCodeView&&e.isInCodeView()){const i=document.createElement("div");i.innerHTML=e.getCurrentContent?e.getCurrentContent():"",t=i.textContent||""}else t=this.editor.textContent||"";const i=t.trim()?t.trim().split(/\s+/).length:0,o=t.length;let n=`${i} words, ${o} chars (${t.replace(/\s/g,"").length} no spaces)`;this.options.maxLength&&(n+=` • ${Math.max(0,this.options.maxLength-o)} left`),this.statusbarEls.wordcount.textContent=n}}}focus(){this.editor&&this.editor.focus()}getContent(){return this.editor.innerHTML}setContent(t){const e=this.wrapTextInParagraph(t);this.editor.innerHTML=e,this.onContentChange()}getHTML(){return this.getContent()}setHTML(t){this.setContent(d(t||""))}getJSON(){return k(this.getContent())}setJSON(t){this.setContent(d(T(t)))}getMarkdown(){return h(this.getContent())}setMarkdown(t){this.setContent(d(y(t||"")))}getText(){return this.editor.textContent||""}isEmpty(){return this.isEditorEmpty()}clear(){this.editor.innerHTML="<p><br></p>",this.onContentChange(),this.updatePlaceholderVisibility()}insertText(t){"string"==typeof t&&(this.focus(),i("insertText",t),this.onContentChange())}insertHTML(t){"string"==typeof t&&(this.focus(),i("insertHTML",d(t)),this.onContentChange())}handlePaste(t){const e=t.clipboardData||window.clipboardData;if(!e)return;const o=(e.items?Array.from(e.items):[]).find(t=>"file"===t.kind&&t.type&&t.type.startsWith("image/"));if(o){const e=o.getAsFile();if(e)return t.preventDefault(),void this.insertImageFile(e)}let n=e.getData("text/html"),r=e.getData("text/plain");if(n||r){if(t.preventDefault(),this.options.maxLength){const t=this._remainingChars();if(t<=0)return;i("insertText",(r||"").slice(0,t))}else!this.options.pasteAsPlainText&&n?i("insertHTML",d(n)):r&&i("insertText",r);setTimeout(()=>{this.ensureEditorHasContent(),this.updatePlaceholderVisibility(),this.onContentChange()},0)}}_remainingChars(){if(!this.options.maxLength)return 1/0;const t=window.getSelection(),e=t&&!t.isCollapsed?t.toString().length:0;return this.options.maxLength-(this.getText().length-e)}insertImageFile(t){if(!t||!t.type||!t.type.startsWith("image/"))return;const e=this.options.image||{};if(e.accept&&"image/*"!==e.accept){if(!e.accept.split(",").some(e=>(e=e.trim()).endsWith("/*")?t.type.startsWith(e.slice(0,-1)):t.type===e))return void this.emit("image:error",{file:t,reason:"type"})}if(e.maxSize&&t.size>e.maxSize)return void this.emit("image:error",{file:t,reason:"size"});const o=(t,e="")=>{const i=this.registry.get("formats/image");if(i&&"function"==typeof i.create){const o=i.create(t);return o?(e&&o.setAttribute("data-state",e),o):null}return null};if("function"!=typeof e.upload){const e=new FileReader;return e.onload=t=>{const e=(o(t.target.result)||{}).outerHTML||`<img src="${t.target.result}" class="inserted-image" style="max-width:100%" contenteditable="false">`;this.focus(),i("insertHTML",e),this.onContentChange()},void e.readAsDataURL(t)}const n="rte-up-"+Math.round(performance.now())+"-"+(this._upCounter=(this._upCounter||0)+1),r=o("data:image/svg+xml,%3Csvg xmlns=%27http://www.w3.org/2000/svg%27 width=%27120%27 height=%2790%27%3E%3Crect width=%27100%25%27 height=%27100%25%27 fill=%27%23efedff%27/%3E%3C/svg%3E","uploading");r&&(r.id=n,r.style.opacity="0.6",this.focus(),i("insertHTML",r.outerHTML),this.emit("image:upload",{file:t}),Promise.resolve(e.upload(t)).then(e=>{const i=this.editor.querySelector("#"+n);i&&(e?(i.src=e,i.style.opacity="",i.removeAttribute("data-state"),i.removeAttribute("id"),this.emit("image:uploaded",{file:t,url:e})):i.remove(),this.onContentChange())}).catch(e=>{const i=this.editor.querySelector("#"+n);i&&i.remove(),this.emit("image:error",{file:t,reason:"upload",error:e}),this.onContentChange()}))}placeCaretAtPoint(t,e){let i=null;if(document.caretRangeFromPoint)i=document.caretRangeFromPoint(t,e);else if(document.caretPositionFromPoint){const o=document.caretPositionFromPoint(t,e);o&&(i=document.createRange(),i.setStart(o.offsetNode,o.offset))}if(i){i.collapse(!0);const t=window.getSelection();t.removeAllRanges(),t.addRange(i)}}handleMarkdownShortcut(t){const e=window.getSelection();if(!e||!e.isCollapsed||!e.rangeCount)return;const o=e.getRangeAt(0);let n=o.startContainer;for(n=n.nodeType===Node.TEXT_NODE?n.parentElement:n;n&&n!==this.editor&&"P"!==n.tagName&&"DIV"!==n.tagName;)n=n.parentElement;if(!n||n===this.editor)return;const r=document.createRange();r.selectNodeContents(n),r.setEnd(o.startContainer,o.startOffset);const s=r.toString(),a={"#":"h1","##":"h2","###":"h3","####":"h4","#####":"h5","######":"h6",">":"blockquote"}[s],l="-"===s||"*"===s?"ul":/^\d+\.$/.test(s)?"ol":null;if(!a&&!l)return;t.preventDefault();const c=this.getModule("history");if(c&&"function"==typeof c.saveBeforeFormat&&c.saveBeforeFormat(),r.deleteContents(),a){const t=document.createElement(a);for(;n.firstChild;)t.appendChild(n.firstChild);""!==t.textContent||t.querySelector("*")||(t.innerHTML="<br>"),n.replaceWith(t);const i=document.createRange();i.selectNodeContents(t),i.collapse(!0),e.removeAllRanges(),e.addRange(i)}else{const t=document.createRange();t.selectNodeContents(n),t.collapse(!0),e.removeAllRanges(),e.addRange(t),i("ul"===l?"insertUnorderedList":"insertOrderedList")}this._emitChange(),this.updatePlaceholderVisibility()}setDirection(t){const e="rtl"===t?"rtl":"ltr";this.editor.setAttribute("dir",e);const i=this.getModule("toolbar");i&&i.setButtonActive("text-direction","rtl"===e)}getDirection(){return"rtl"===this.editor.getAttribute("dir")?"rtl":"ltr"}toggleDirection(){this.setDirection("rtl"===this.getDirection()?"ltr":"rtl")}_autosaveCfg(){if(void 0!==this._autosaveMemo)return this._autosaveMemo;const t=this.options.autosave;return t?(this._autosaveMemo={key:"object"==typeof t&&t.key?t.key:"yjd-autosave",debounce:"object"==typeof t&&t.debounce?t.debounce:1e3},this._autosaveMemo):(this._autosaveMemo=null,null)}_getAutosaved(){const t=this._autosaveCfg();if(!t)return null;try{return localStorage.getItem(t.key)}catch(t){return null}}_scheduleAutosave(t){const e=this._autosaveCfg();e&&(clearTimeout(this._autosaveTimer),this._autosaveTimer=setTimeout(()=>{try{localStorage.setItem(e.key,t)}catch(t){}},e.debounce))}clearAutosave(){const t=this._autosaveCfg();if(t)try{localStorage.removeItem(t.key)}catch(t){}}clearFormatting(){const t=this.getModule("history");t&&"function"==typeof t.saveBeforeFormat&&t.saveBeforeFormat(),this.focus(),i("removeFormat"),i("unlink"),this.onContentChange(),this.updateToolbarButtonStates()}setBlockType(t){const e=window.getSelection();if(!e||!e.rangeCount)return;let o=e.getRangeAt(0).startContainer;o=o.nodeType===Node.TEXT_NODE?o.parentElement:o;const n=/^(P|DIV|H[1-6]|BLOCKQUOTE|PRE|LI)$/;for(;o&&o!==this.editor&&!n.test(o.tagName);)o=o.parentElement;if(!o||o===this.editor)return;const r=this.getModule("history");if(r&&"function"==typeof r.saveBeforeFormat&&r.saveBeforeFormat(),"ul"===t||"ol"===t){const n=document.createRange();n.selectNodeContents(o),n.collapse(!0),e.removeAllRanges(),e.addRange(n),i("ul"===t?"insertUnorderedList":"insertOrderedList")}else{const i=document.createElement(t);for(;o.firstChild;)i.appendChild(o.firstChild);""!==i.textContent||i.querySelector("*")||(i.innerHTML="<br>"),o.replaceWith(i);const n=document.createRange();n.selectNodeContents(i),n.collapse(!1),e.removeAllRanges(),e.addRange(n)}this._emitChange(),this.updatePlaceholderVisibility()}insertHorizontalRule(){const t=this.getModule("history");t&&"function"==typeof t.saveBeforeFormat&&t.saveBeforeFormat(),this.focus(),i("insertHorizontalRule"),this.onContentChange()}_isBlockEmpty(t){return!t||(!t.querySelector||!t.querySelector("img, table, hr, video, iframe, audio, figure"))&&""===(t.textContent||"").replace(/\u200B/g,"").trim()}insertBlock(t){const e=window.getSelection();let i=null;if(e&&e.rangeCount){const t=e.getRangeAt(0);t.collapsed||t.deleteContents();let o=t.startContainer;for(o=o.nodeType===Node.TEXT_NODE?o.parentNode:o;o&&o!==this.editor&&o.parentNode!==this.editor;)o=o.parentNode;o&&o.parentNode===this.editor&&(i=o)}if(i){const e=this._isBlockEmpty(i);i.nextSibling?this.editor.insertBefore(t,i.nextSibling):this.editor.appendChild(t),e&&i.remove()}else this.editor.appendChild(t);if(!t.nextSibling){const t=document.createElement("p");t.innerHTML="<br>",this.editor.appendChild(t)}}setReadOnly(t){this._readOnly=!!t,this.editor.contentEditable=this._readOnly?"false":"true",this.editor.setAttribute("aria-readonly",this._readOnly?"true":"false"),this.wrapper.classList.toggle("read-only",this._readOnly);const e=this.getModule("toolbar");e&&e.buttons&&e.buttons.forEach((t,i)=>{e.setButtonDisabled(i,this._readOnly)})}isReadOnly(){return!!this._readOnly}getModule(t){return this.modules.get(t)}getFormat(t){return this.formats.get(t)}register(t,e,i=!1){this.registry.register(t,e,i)}handleToolbarClick(t){const{command:e,button:i,value:o}=t;S.currentInstance,S.currentInstance=this,this.emit("toolbar-click",t);if(["more","undo","redo","code-view","theme","text-direction","find"].includes(e))switch(e){case"more":case"code-view":case"find":return;case"undo":return void this.undo();case"redo":return void this.redo();case"text-direction":return void this.toggleDirection()}const n=window.getSelection();if(this.isSelectionInEditableArea(n))switch(e){case"bold":case"italic":case"underline":case"strike":case"subscript":case"superscript":case"color":case"background":case"link":case"table":case"heading":case"font-family":case"line-height":case"capitalization":case"text-align":case"text-size":case"list":case"indent-increase":case"indent-decrease":case"emoji":case"image":case"video":case"tag":case"import":this.toggleFormat(e);break;case"clear-format":this.clearFormatting();break;case"horizontal-rule":this.insertHorizontalRule()}}toggleFormat(t){const e=this.getModule("history");e&&"function"==typeof e.saveBeforeFormat&&e.saveBeforeFormat();const i={bold:"bold",italic:"italic",underline:"underline",strike:"strike",subscript:"subscript",superscript:"superscript",color:"color",background:"background",link:"link",table:"table",heading:"heading","font-family":"font-family","line-height":"line-height",capitalization:"capitalization","text-align":"text-align","text-size":"text-size",list:"list","indent-increase":"indent-increase","indent-decrease":"indent-decrease",emoji:"emoji",image:"image",video:"video",tag:"tag",import:"import"}[t];if(!i)return;const o=this.registry.get(`formats/${i}`);if(!o)return;(new o).toggle(),this.updateToolbarButtonStates();["bold","italic","underline","strike","subscript","superscript"].includes(t)&&setTimeout(()=>{this.onContentChange()},0)}_getFormatInstance(t){if(this._fmtCache||(this._fmtCache=new Map),this._fmtCache.has(t))return this._fmtCache.get(t);const e=this.registry.get(`formats/${t}`);if(!e)return null;let i;if(e.createForEditor)i=e.createForEditor(this.instanceId);else{const t=S.currentInstance;S.currentInstance=this,i=new e,S.currentInstance=t}return this._fmtCache.set(t,i),i}updateToolbarButtonStates(){const t=this.getModule("toolbar");if(!t)return;const e=window.getSelection();if(!e||!e.rangeCount)return;const i=this.isSelectionInEditableArea(e);if(["heading","font-family","line-height","capitalization","text-align","list","indent-increase","indent-decrease","bold","italic","underline","strike","subscript","superscript","color","background","link","table","text-size"].forEach(e=>{if(i){const i=this._getFormatInstance(e);i&&(t.setButtonActive(e,i.isActive()),"line-height"===e&&"function"==typeof i.updateButtonText&&i.updateButtonText())}else t.setButtonActive(e,!1)}),i){const t=this.registry.get("formats/text-size");t&&"function"==typeof t.updateButtonTextStatic&&t.updateButtonTextStatic(this.instanceId)}this.updateColorSwatches(),this.updateHistoryButtons()}updateHistoryButtons(){const t=this.getModule("toolbar");if(!t||"function"!=typeof t.getButton)return;const e=this.getModule("history"),i=!(!e||"function"!=typeof e.canUndo||!e.canUndo()),o=!(!e||"function"!=typeof e.canRedo||!e.canRedo()),n=(t,e)=>{t&&(t.classList.remove("rte-hidden"),t.disabled=!e,t.classList.toggle("is-disabled",!e))};n(t.getButton("undo"),i),n(t.getButton("redo"),o)}updateColorSwatches(){const t=this.getModule("toolbar");if(!t||"function"!=typeof t.getButton)return;const e=(e,i)=>{const o=t.getButton(e);if(!o)return;const n=o.querySelector(".rte-swatch");n&&(i?(n.style.background=i,o.classList.add("has-color")):(n.style.removeProperty("background"),o.classList.remove("has-color")))},i=this.registry.get("formats/color");i&&"function"==typeof i.getCurrentColor&&e("color",i.getCurrentColor());const o=this.registry.get("formats/background");o&&"function"==typeof o.getCurrentColor&&e("background",o.getCurrentColor())}undo(){const t=this.getModule("history");t&&"function"==typeof t.undo?t.undo():i("undo")}redo(){const t=this.getModule("history");t&&"function"==typeof t.redo?t.redo():i("redo")}on(t,e){this.events.has(t)||this.events.set(t,[]),this.events.get(t).push(e)}off(t,e){if(this.events.has(t)){const i=this.events.get(t),o=i.indexOf(e);o>-1&&i.splice(o,1)}}emit(t,e){this.events.has(t)&&this.events.get(t).forEach(t=>{try{t(e)}catch(t){}})}preventFocusLoss(t,e="button, input, select, textarea, [contenteditable]"){t&&t.addEventListener("mousedown",t=>{t.target.closest(e)||(t.preventDefault(),setTimeout(()=>{this.focus()},0))})}static getCurrentInstance(){return S.currentInstance}static maintainFocus(t,e=null){"function"==typeof t&&t();const i=e||S.getCurrentInstance();i&&setTimeout(()=>i.focus(),0)}getPopupContainer(){return this.popupContainer}static getPopupContainer(){const t=S.getCurrentInstance();return t?t.getPopupContainer():null}getPopupInstance(t){return this.popupInstances.get(t)}setPopupInstance(t,e){this.popupInstances.set(t,e)}static getPopupInstanceById(t,e){const i=S.instances.get(t);return i?i.getPopupInstance(e):null}static getInstanceById(t){return S.instances.get(t)}static getAllInstances(){return S.instances}destroyPopupInstances(){this.popupInstances.forEach((t,e)=>{t&&"function"==typeof t.destroy&&t.destroy()}),this.popupInstances.clear()}updatePlaceholderVisibility(){this.isEditorEmpty()?this.editor.classList.add("placeholder-visible"):this.editor.classList.remove("placeholder-visible")}destroy(){this._markActive&&(this.wrapper.removeEventListener("pointerdown",this._markActive,!0),this.wrapper.removeEventListener("focusin",this._markActive,!0),this._markActive=null),this._onDocSelectionChange&&(document.removeEventListener("selectionchange",this._onDocSelectionChange),this._onDocSelectionChange=null),this._fmtCache&&this._fmtCache.clear(),clearTimeout(this._autosaveTimer),this.modules.forEach(t=>{"function"==typeof t.destroy&&t.destroy()}),this.destroyPopupInstances(),this.wrapper&&this.wrapper.parentNode&&this.wrapper.parentNode.removeChild(this.wrapper),this.modules.clear(),this.formats.clear(),this.events.clear(),S.instances.delete(this.instanceId),S.currentInstance===this&&(S.currentInstance=null)}}class N{static formatName="";static tagName="";static className="";constructor(t){this.domNode=t}static create(t){const e=document.createElement(this.tagName);return this.className&&(e.className=this.className),e}getOffsetWithin(t,e){let i=0;const o=document.createTreeWalker(t,NodeFilter.SHOW_TEXT,null);let n;for(;n=o.nextNode();){if(n===e.startContainer)return i+e.startOffset;i+=n.textContent.length}return i}}class L extends N{static create(t){return super.create(t)}apply(t){const e=window.getSelection();if(!e||!e.rangeCount)return;const i=e.getRangeAt(0);if(i.collapsed){const o=this.constructor.create(t);o.appendChild(document.createTextNode("​")),i.insertNode(o);const n=document.createRange();n.setStart(o.firstChild,1),n.collapse(!0),e.removeAllRanges(),e.addRange(n)}else{const o=i.extractContents(),n=this.constructor.create(t);n.appendChild(o),i.insertNode(n);const r=document.createRange();r.selectNodeContents(n),e.removeAllRanges(),e.addRange(r)}}remove(){const t=window.getSelection();if(!t||!t.rangeCount)return;const e=t.getRangeAt(0);e.collapsed?this.removeAtCursor(e,t):this.removeFromSelection(e,t)}removeAtCursor(t,e){const i=t.startContainer,o=this.findFormatNode(i);if(!o||!o.parentNode)return;const n=o.textContent,r=this.getOffsetWithin(o,t),s=n.slice(0,r),a=n.slice(r),l=document.createDocumentFragment();if(s){const t=o.cloneNode(!1);t.textContent=s,l.appendChild(t)}const c=document.createTextNode("​");if(l.appendChild(c),a){const t=o.cloneNode(!1);t.textContent=a,l.appendChild(t)}o.replaceWith(l);const d=document.createRange();d.setStartAfter(c),d.collapse(!0),e.removeAllRanges(),e.addRange(d)}removeFromSelection(t,e){const o=this.constructor.formatName;i(o),"strike"===o&&i("strikeThrough")}findFormatNode(t){for(;t&&t!==document.body;){if(t.nodeType===Node.ELEMENT_NODE&&t.tagName===this.constructor.tagName)return t;t=t.parentNode}return null}findFormatNodesInRange(t){const e=[],i=document.createTreeWalker(t.commonAncestorContainer,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>e.tagName===this.constructor.tagName&&t.intersectsNode(e)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP});let o;for(;o=i.nextNode();)e.push(o);return e}isActive(){const t=window.getSelection();if(!t||!t.rangeCount)return!1;let e=t.getRangeAt(0).startContainer;const i=this.constructor.tagName,o=this.constructor.alternativeTagNames||[],r=this.constructor.formatName;if(["bold","italic","underline"].includes(r?.toLowerCase()))return n(r);for(;e&&e!==document.body;){if(e.nodeType===Node.ELEMENT_NODE&&(e.tagName===i||o.includes(e.tagName)))return!0;e=e.parentNode}return!1}}class A extends N{static create(t){return super.create(t)}apply(t){const e=window.getSelection();if(!e||!e.rangeCount)return;const i=e.getRangeAt(0),o=this.getBlockElements(i);0===o.length?this.createBlockAtCursor(i,t):o.forEach(e=>{this.convertBlock(e,t)})}remove(){const t=window.getSelection();if(!t||!t.rangeCount)return;const e=t.getRangeAt(0);this.getBlockElements(e).forEach(t=>{this.removeBlockFormat(t)})}createBlockAtCursor(t,e){const i=this.constructor.create(e),o=this.getBlockElement(t.startContainer);if(o&&o.style&&o.style.cssText&&(i.style.cssText=o.style.cssText),t.collapsed){i.appendChild(document.createTextNode("")),t.insertNode(i);const e=document.createRange();e.setStart(i,0),e.collapse(!0);const o=window.getSelection();o.removeAllRanges(),o.addRange(e)}else{const e=t.extractContents();i.appendChild(e),t.insertNode(i);const o=document.createRange();o.selectNodeContents(i);const n=window.getSelection();n.removeAllRanges(),n.addRange(o)}}convertBlock(t,e){const i=this.constructor.create(e);for(;t.firstChild;)i.appendChild(t.firstChild);t.className&&this.shouldPreserveClass(t.className)&&(i.className=t.className),t.style&&t.style.cssText&&(i.style.cssText=t.style.cssText),t.parentNode.replaceChild(i,t)}removeBlockFormat(t){const e=document.createElement("P");for(;t.firstChild;)e.appendChild(t.firstChild);t.style&&t.style.cssText&&(e.style.cssText=t.style.cssText),t.parentNode.replaceChild(e,t)}getBlockElements(t){const e=[];let i=this.getBlockElement(t.startContainer),o=this.getBlockElement(t.endContainer);if(i&&o&&i.nextElementSibling===o){t.endContainer===o&&0===t.endOffset&&(o=i)}if(i===o)i&&e.push(i);else{let t=i;for(;t&&t!==o;)this.isBlockElement(t)&&e.push(t),t=this.getNextBlockElement(t);o&&this.isBlockElement(o)&&e.push(o)}return e.filter((t,e,i)=>i.indexOf(t)===e)}getBlockElement(t){for(;t&&t.nodeType!==Node.ELEMENT_NODE;)t=t.parentNode;for(;t&&t!==document.body;){if(this.isBlockElement(t))return t;t=t.parentNode}return null}isBlockElement(t){if(!t||t.nodeType!==Node.ELEMENT_NODE)return!1;return["P","DIV","H1","H2","H3","H4","H5","H6","BLOCKQUOTE","PRE","UL","OL","LI","SECTION","ARTICLE"].includes(t.tagName.toUpperCase())}getNextBlockElement(t){let e=t.nextElementSibling;for(;e;){if(this.isBlockElement(e))return e;e=e.nextElementSibling}return null}isActive(t=null){const e=window.getSelection();if(!e||!e.rangeCount)return!1;const i=e.getRangeAt(0),o=this.getBlockElement(i.startContainer);return!!o&&(o.tagName===this.constructor.tagName&&(!t||this.hasValue(o,t)))}hasValue(t,e){return!0}shouldPreserveClass(t){return!1}}function B(t,e){const i=d(t||""),o=e||document.createElement("div");return o.classList.add("yjd-content"),o.innerHTML=i,o}function R(){const t=S.getCurrentInstance();if(t){const e=t.getModule("history");e&&"function"==typeof e.saveBeforeFormat&&e.saveBeforeFormat()}}class H extends L{static formatName="bold";static tagName="B";static alternativeTagNames=["STRONG"];apply(){R(),i("bold")}remove(){i("bold")}toggle(){R(),i("bold")}isActive(){return n("bold")}}class z extends L{static formatName="italic";static tagName="I";static alternativeTagNames=["EM"];toggle(){R(),this.isActive()?this.remove():this.apply()}}class O extends L{static formatName="underline";static tagName="U";static alternativeTagNames=["SPAN"];toggle(){R(),this.isActive()?this.remove():this.apply()}}class M extends L{static formatName="strike";static tagName="S";static alternativeTagNames=["STRIKE","DEL"];toggle(){R(),this.isActive()?this.remove():this.apply()}}class P extends L{static formatName="subscript";static tagName="SUB";removeSuperscriptBeforeApply(){const e=t.get("formats/superscript");if(!e)return;const i=new e;i.isActive()&&i.remove()}toggle(){R(),this.isActive()?this.remove():(this.removeSuperscriptBeforeApply(),this.apply())}}class _ extends L{static formatName="superscript";static tagName="SUP";removeSubscriptBeforeApply(){const e=t.get("formats/subscript");if(!e)return;const i=new e;i.isActive()&&i.remove()}toggle(){R(),this.isActive()?this.remove():(this.removeSubscriptBeforeApply(),this.apply())}}const D=t=>`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">${t}</svg>`,F={bold:D('<path d="M6 4h8a4 4 0 0 1 4 4 4 4 0 0 1-4 4H6z"/><path d="M6 12h9a4 4 0 0 1 4 4 4 4 0 0 1-4 4H6z"/>'),italic:D('<line x1="19" x2="10" y1="4" y2="4"/><line x1="14" x2="5" y1="20" y2="20"/><line x1="15" x2="9" y1="4" y2="20"/>'),underline:D('<path d="M6 4v6a6 6 0 0 0 12 0V4"/><line x1="4" x2="20" y1="20" y2="20"/>'),strike:D('<path d="M16 4H9a3 3 0 0 0-2.83 4"/><path d="M14 12a4 4 0 0 1 0 8H6"/><line x1="4" x2="20" y1="12" y2="12"/>'),subscript:D('<path d="m4 5 8 8"/><path d="m12 5-8 8"/><path d="M20 19h-4c0-1.5.44-2 1.5-2.5S20 15.33 20 14c0-.47-.17-.93-.48-1.29a2.11 2.11 0 0 0-2.62-.44c-.42.24-.74.62-.9 1.07"/>'),superscript:D('<path d="m4 19 8-8"/><path d="m12 19-8-8"/><path d="M20 12h-4c0-1.5.44-2 1.5-2.5S20 8.33 20 7c0-.47-.17-.93-.48-1.29a2.11 2.11 0 0 0-2.62-.44c-.42.24-.74.62-.9 1.07"/>'),"align-left":D('<line x1="21" x2="3" y1="6" y2="6"/><line x1="15" x2="3" y1="12" y2="12"/><line x1="17" x2="3" y1="18" y2="18"/>'),"align-center":D('<line x1="21" x2="3" y1="6" y2="6"/><line x1="17" x2="7" y1="12" y2="12"/><line x1="19" x2="5" y1="18" y2="18"/>'),"align-right":D('<line x1="21" x2="3" y1="6" y2="6"/><line x1="21" x2="9" y1="12" y2="12"/><line x1="21" x2="7" y1="18" y2="18"/>'),"align-justify":D('<line x1="3" x2="21" y1="6" y2="6"/><line x1="3" x2="21" y1="12" y2="12"/><line x1="3" x2="21" y1="18" y2="18"/>'),"list-bullet":D('<line x1="8" x2="21" y1="6" y2="6"/><line x1="8" x2="21" y1="12" y2="12"/><line x1="8" x2="21" y1="18" y2="18"/><circle cx="3.5" cy="6" r="1" fill="currentColor" stroke="none"/><circle cx="3.5" cy="12" r="1" fill="currentColor" stroke="none"/><circle cx="3.5" cy="18" r="1" fill="currentColor" stroke="none"/>'),"list-ordered":D('<line x1="10" x2="21" y1="6" y2="6"/><line x1="10" x2="21" y1="12" y2="12"/><line x1="10" x2="21" y1="18" y2="18"/><path d="M4 6h1v4"/><path d="M4 10h2"/><path d="M6 18H4c0-1 2-2 2-3s-1-1.5-2-1"/>'),"list-alpha":D('<line x1="10" x2="21" y1="6" y2="6"/><line x1="10" x2="21" y1="12" y2="12"/><line x1="10" x2="21" y1="18" y2="18"/><path d="M4 10V8a1 1 0 0 1 2 0v2"/><path d="M4 9h2"/><path d="M4 14h1.5a1 1 0 0 1 0 2H4l2-2"/>'),"list-roman":D('<line x1="10" x2="21" y1="6" y2="6"/><line x1="10" x2="21" y1="12" y2="12"/><line x1="10" x2="21" y1="18" y2="18"/><path d="M5 7v3"/><path d="M4 14h2l-1 4"/>'),list:D('<line x1="8" x2="21" y1="6" y2="6"/><line x1="8" x2="21" y1="12" y2="12"/><line x1="8" x2="21" y1="18" y2="18"/><circle cx="3.5" cy="6" r="1" fill="currentColor" stroke="none"/><circle cx="3.5" cy="12" r="1" fill="currentColor" stroke="none"/><circle cx="3.5" cy="18" r="1" fill="currentColor" stroke="none"/>'),"indent-increase":D('<polyline points="3 8 7 12 3 16"/><line x1="21" x2="11" y1="6" y2="6"/><line x1="21" x2="11" y1="12" y2="12"/><line x1="21" x2="11" y1="18" y2="18"/>'),"indent-decrease":D('<polyline points="7 8 3 12 7 16"/><line x1="21" x2="11" y1="6" y2="6"/><line x1="21" x2="11" y1="12" y2="12"/><line x1="21" x2="11" y1="18" y2="18"/>'),image:D('<rect width="18" height="18" x="3" y="3" rx="2" ry="2"/><circle cx="9" cy="9" r="2"/><path d="m21 15-3.1-3.1a2 2 0 0 0-2.8 0L6 21"/>'),video:D('<path d="m22 8-6 4 6 4V8Z"/><rect width="14" height="12" x="2" y="6" rx="2" ry="2"/>'),table:D('<path d="M12 3v18"/><rect width="18" height="18" x="3" y="3" rx="2"/><path d="M3 9h18"/><path d="M3 15h18"/>'),"table-profile":D('<path d="M15 3v18"/><rect width="18" height="18" x="3" y="3" rx="2"/><path d="M21 9H3"/><path d="M21 15H3"/>'),"add-row-above":D('<rect x="3" y="13" width="18" height="8" rx="2"/><line x1="12" x2="12" y1="3" y2="9"/><line x1="9" x2="15" y1="6" y2="6"/>'),"add-row-below":D('<rect x="3" y="3" width="18" height="8" rx="2"/><line x1="12" x2="12" y1="15" y2="21"/><line x1="9" x2="15" y1="18" y2="18"/>'),"add-col-left":D('<rect x="13" y="3" width="8" height="18" rx="2"/><line x1="3" x2="9" y1="12" y2="12"/><line x1="6" x2="6" y1="9" y2="15"/>'),"add-col-right":D('<rect x="3" y="3" width="8" height="18" rx="2"/><line x1="15" x2="21" y1="12" y2="12"/><line x1="18" x2="18" y1="9" y2="15"/>'),"delete-row":D('<rect x="3" y="9" width="18" height="6" rx="2"/><line x1="9" x2="15" y1="12" y2="12"/>'),"delete-col":D('<rect x="9" y="3" width="6" height="18" rx="2"/><line x1="12" x2="12" y1="9" y2="15"/>'),"delete-table":D('<path d="M3 6h18"/><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6"/><path d="M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/><line x1="10" x2="10" y1="11" y2="17"/><line x1="14" x2="14" y1="11" y2="17"/>'),color:D('<path d="M5.5 19 12 5l6.5 14"/><path d="M8 14h8"/>'),background:D('<path d="m9 11-6 6v3h9l3-3"/><path d="m22 12-4.6 4.6a2 2 0 0 1-2.8 0l-5.2-5.2a2 2 0 0 1 0-2.8L14 4"/>'),"no-color":D('<circle cx="12" cy="12" r="9"/><line x1="5.6" x2="18.4" y1="5.6" y2="18.4"/>'),"custom-color":D('<path d="M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10c.93 0 1.65-.75 1.65-1.69 0-.43-.18-.83-.44-1.12-.29-.29-.44-.65-.44-1.13a1.64 1.64 0 0 1 1.67-1.67h2c3.05 0 5.55-2.5 5.55-5.55C22 6 17.5 2 12 2z"/><circle cx="8.5" cy="7.5" r="1" fill="currentColor" stroke="none"/><circle cx="6.5" cy="12.5" r="1" fill="currentColor" stroke="none"/><circle cx="13.5" cy="6.5" r="1" fill="currentColor" stroke="none"/><circle cx="17.5" cy="10.5" r="1" fill="currentColor" stroke="none"/>'),undo:D('<path d="M9 14 4 9l5-5"/><path d="M4 9h10.5a5.5 5.5 0 0 1 0 11H11"/>'),redo:D('<path d="m15 14 5-5-5-5"/><path d="M20 9H9.5a5.5 5.5 0 0 0 0 11H13"/>'),link:D('<path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"/><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"/>'),emoji:D('<circle cx="12" cy="12" r="10"/><path d="M8 14s1.5 2 4 2 4-2 4-2"/><line x1="9" x2="9.01" y1="9" y2="9"/><line x1="15" x2="15.01" y1="9" y2="9"/>'),tag:D('<path d="M12.6 2.6A2 2 0 0 0 11.2 2H4a2 2 0 0 0-2 2v7.2a2 2 0 0 0 .6 1.4l8.7 8.7a2.4 2.4 0 0 0 3.4 0l6.6-6.6a2.4 2.4 0 0 0 0-3.4z"/><circle cx="7.5" cy="7.5" r="1" fill="currentColor" stroke="none"/>'),import:D('<path d="M12 3v12"/><path d="m8 11 4 4 4-4"/><path d="M8 5H4a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2h-4"/>'),code:D('<polyline points="16 18 22 12 16 6"/><polyline points="8 6 2 12 8 18"/>'),"code-view":D('<path d="m18 16 4-4-4-4"/><path d="m6 8-4 4 4 4"/><path d="m14.5 4-5 16"/>'),"clear-format":D('<path d="M4 7V4h16v3"/><path d="M5 20h6"/><path d="M13 4 8 20"/><path d="m15 15 5 5"/><path d="m20 15-5 5"/>'),"horizontal-rule":D('<path d="M5 12h14"/>'),find:D('<circle cx="11" cy="11" r="8"/><path d="m21 21-4.3-4.3"/>'),"chevron-up":D('<path d="m18 15-6-6-6 6"/>'),"chevron-down":D('<path d="m6 9 6 6 6-6"/>'),close:D('<path d="M18 6 6 18"/><path d="m6 6 12 12"/>'),"text-direction":D('<path d="M8 3 4 7l4 4"/><path d="M4 7h16"/><path d="m16 21 4-4-4-4"/><path d="M20 17H4"/>'),check:D('<polyline points="20 6 9 17 4 12"/>'),dropdown:D('<path d="m6 9 6 6 6-6"/>'),more:D('<circle cx="12" cy="12" r="1.4" fill="currentColor" stroke="none"/><circle cx="19" cy="12" r="1.4" fill="currentColor" stroke="none"/><circle cx="5" cy="12" r="1.4" fill="currentColor" stroke="none"/>'),theme:D('<circle cx="12" cy="12" r="4"/><path d="M12 2v2"/><path d="M12 20v2"/><path d="m4.9 4.9 1.4 1.4"/><path d="m17.7 17.7 1.4 1.4"/><path d="M2 12h2"/><path d="M20 12h2"/><path d="m6.3 17.7-1.4 1.4"/><path d="m19.1 4.9-1.4 1.4"/>'),heading:D('<path d="M4 12h8"/><path d="M4 18V6"/><path d="M12 18V6"/><path d="m17 12 3-2v8"/>'),"font-family":D('<polyline points="4 7 4 4 20 4 20 7"/><line x1="9" x2="15" y1="20" y2="20"/><line x1="12" x2="12" y1="4" y2="20"/>'),"line-height":D('<path d="M3 5h12"/><path d="M3 12h12"/><path d="M3 19h12"/><path d="M19 5v14"/><path d="m16.5 7.5 2.5-2.5 2.5 2.5"/><path d="m16.5 16.5 2.5 2.5 2.5-2.5"/>'),capitalization:D('<path d="M4 18 8 8l4 10"/><path d="M5.5 14h5"/><path d="M16 18a3 3 0 1 0 0-6 3 3 0 0 0-3 3v3"/><path d="M19 12v6"/>'),"text-size":D('<path d="M21 14h-5"/><path d="M16 16v-3.5a2.5 2.5 0 0 1 5 0V16"/><path d="M4.5 13h6"/><path d="m3 16 4.5-9 4.5 9"/>')};class V{static getIcon(t){return F[t]||""}static createIconElement(t,e={}){const i=document.createElement("span");return i.className=`icon icon-${t}`,i.style.display="inline-flex",i.style.alignItems="center",i.style.justifyContent="center",i.style.width=e.width||"16px",i.style.height=e.height||"16px",i.style.verticalAlign="middle",i.innerHTML=this.getIcon(t),i}static hasIcon(t){return t in F}static getIconNames(){return Object.keys(F)}}function U(t=null){let e;return e=t?S.getInstanceById(t):S.getCurrentInstance(),e?e.getPopupContainer():document.body}function q(t,e=null){const i=U(e);t.parentNode&&t.parentNode.removeChild(t),i.appendChild(t)}function W(t){if(!t)return{width:300,height:200};const e=t.getBoundingClientRect();if(e.width>0&&e.height>0)return{width:e.width,height:e.height};if(t.offsetWidth>0&&t.offsetHeight>0)return{width:t.offsetWidth,height:t.offsetHeight};const i=window.getComputedStyle(t);if("none"===i.display||"hidden"===i.visibility){const e=t.style.display,i=t.style.visibility,o=t.style.position,n=t.style.top,r=t.style.left,s=t.style.zIndex;t.style.display="block",t.style.visibility="visible",t.style.position="absolute",t.style.top="-9999px",t.style.left="-9999px",t.style.zIndex="-1",t.offsetHeight;const a=t.getBoundingClientRect(),l=a.width>0?a.width:300,c=a.height>0?a.height:200;return t.style.display=e,t.style.visibility=i,t.style.position=o,t.style.top=n,t.style.left=r,t.style.zIndex=s,{width:l,height:c}}const o=parseInt(i.width),n=parseInt(i.height);return{width:o>0?o:300,height:n>0?n:200}}function $(t,e,i={}){const{offsetX:o=0,offsetY:n=5,preferTop:r=!1,preferLeft:s=!1}=i,a=t.getBoundingClientRect(),l=U();let c,d;if(l.classList.contains("rich-editor-popup-container")){const t=l.getBoundingClientRect();c=a.top-t.top+a.height+n,d=a.left-t.left+o;const{width:i,height:h}=W(e);if(c+h>t.height&&!r){const e=a.top-t.top-h-n;c=e>=0?e:Math.max(n,(t.height-h)/2)}d+i+5>t.width&&!s&&(d=t.width-i-o-15),d<0&&(d=o),c<0&&(c=n)}else{c=a.bottom+window.scrollY+n,d=a.left+window.scrollX+o;const{width:t,height:i}=W(e);if(d+t>window.innerWidth&&!s&&(d=window.innerWidth-t-o),c+i>window.innerHeight+window.scrollY&&!r){const t=a.top+window.scrollY-i-n;c=t>=window.scrollY?t:Math.max(window.scrollY+n,window.scrollY+(window.innerHeight-i)/2)}d<0&&(d=o),c<0&&(c=n)}return{top:c,left:d}}function X(t,e){t.style.position="absolute",t.style.top=`${e.top}px`,t.style.left=`${e.left}px`,t.style.zIndex="1000"}class K{constructor(t={}){this.options={colors:["#000000","#333333","#666666","#999999","#cccccc","#eeeeee","#ff0000","#ff6600","#ffcc00","#ffff00","#99ff00","#00ff00","#00ffcc","#00ccff","#0066ff","#0000ff","#6600ff","#cc00ff","#ff00cc","#ff0066","#800000","#ff8000","#808000","#008000","#008080","#0080ff","#004080","#800080","#804080","#ff0080"],customColorEnabled:!0,onColorSelect:null,editor:null,...t},this.popup=null,this.isVisible=!1,this.currentColor="#000000",this.clickOutsideHandler=null,this.createColorPicker()}createColorPicker(){this.popup=document.createElement("div"),this.popup.className="color-picker-popup",this.createColorGrid(),this.options.customColorEnabled&&this.createCustomColorInput(),q(this.popup),this.options.editor&&"function"==typeof this.options.editor.preventFocusLoss&&this.options.editor.preventFocusLoss(this.popup)}createColorGrid(){const t=document.createElement("div");t.className="color-grid",this.options.colors.forEach(e=>{const i=document.createElement("button");i.type="button",i.className="color-button",i.style.backgroundColor=e,i.dataset.color=e,i.title=e,i.addEventListener("click",t=>{t.preventDefault(),t.stopPropagation(),this.selectColor(e),this.options.editor&&setTimeout(()=>this.options.editor.focus(),0)}),t.appendChild(i)}),this.popup.appendChild(t)}createCustomColorInput(){const t=document.createElement("div");t.className="custom-color-container";const e=document.createElement("button");e.type="button",e.className="color-button no-color-button",e.title="No Color",e.style.backgroundColor="transparent";const i=V.createIconElement("no-color",{width:"24",height:"24"});e.appendChild(i),e.addEventListener("click",t=>{t.preventDefault(),t.stopPropagation(),this.selectColor("transparent"),this.options.editor&&setTimeout(()=>this.options.editor.focus(),0)});const o=document.createElement("button");o.type="button",o.className="color-button white-button",o.style.backgroundColor="#ffffff",o.style.border="1px solid #ccc",o.title="White",o.addEventListener("click",t=>{t.preventDefault(),t.stopPropagation(),this.selectColor("#ffffff"),this.options.editor&&setTimeout(()=>this.options.editor.focus(),0)});const n=document.createElement("button");n.type="button",n.className="color-button black-button",n.style.backgroundColor="#000000",n.title="Black",n.addEventListener("click",t=>{t.preventDefault(),t.stopPropagation(),this.selectColor("#000000"),this.options.editor&&setTimeout(()=>this.options.editor.focus(),0)});const r=document.createElement("button");r.type="button",r.className="color-button custom-color-button",r.title="Custom Color",r.style.backgroundColor="transparent",r.style.border="1px solid #ccc",r.style.font="none !important";const s=V.createIconElement("custom-color",{width:"16px",height:"16px"});r.appendChild(s);const a=document.createElement("input");a.type="color",a.className="custom-color-input",a.value=this.currentColor,a.style.visibility="hidden",a.style.pointerEvents="none",a.style.opacity="0",r.addEventListener("click",t=>{a.style.visibility="visible",a.style.pointerEvents="auto",a.style.opacity="1",t.preventDefault(),t.stopPropagation(),a.click()}),a.addEventListener("change",t=>{a.style.visibility="hidden",a.style.pointerEvents="none",a.style.opacity="0",this.selectColor(t.target.value),this.options.editor&&setTimeout(()=>this.options.editor.focus(),0)}),t.appendChild(e),t.appendChild(o),t.appendChild(n),t.appendChild(r),t.appendChild(a),this.popup.appendChild(t)}setupClickOutside(){this.clickOutsideHandler&&document.removeEventListener("click",this.clickOutsideHandler),this.clickOutsideHandler=t=>{this.popup.contains(t.target)||this.hide()},setTimeout(()=>{document.addEventListener("click",this.clickOutsideHandler)},100)}removeClickOutside(){this.clickOutsideHandler&&(document.removeEventListener("click",this.clickOutsideHandler),this.clickOutsideHandler=null)}show(t){if(!t)return;document.body.contains(this.popup)||q(this.popup);const e=$(t,this.popup,{offsetY:5,offsetX:0});X(this.popup,e),this.popup.classList.add("visible"),this.isVisible=!0,this.setupClickOutside()}hide(){this.popup.classList.remove("visible"),this.isVisible=!1,this.removeClickOutside()}selectColor(t){this.currentColor=t,this.options.onColorSelect&&this.options.onColorSelect(t),this.hide()}destroy(){this.removeClickOutside(),this.popup&&this.popup.parentNode&&this.popup.parentNode.removeChild(this.popup)}}class G extends L{static formatName="color";static tagName="SPAN";static attribute="color";static savedRanges=new Map;constructor(){super();const t=S.getCurrentInstance();if(!t)return;this.editorId=t.instanceId;let e=t.getPopupInstance("color");if(!e){const i=this.editorId;e=new K({onColorSelect:t=>{G.applyColorToCurrentSelection(t,i)},editor:S.getCurrentInstance()}),t.setPopupInstance("color",e)}this.colorPicker=e}static applyColorToCurrentSelection(t,e=null){const n=window.getSelection(),r=null!=e?G.savedRanges.get(e):null;r&&(n.removeAllRanges(),n.addRange(r)),null!=e&&G.savedRanges.delete(e),n&&n.rangeCount&&!n.isCollapsed&&(R(),o(!0),i("foreColor","transparent"===t?"inherit":t),setTimeout(()=>{const t=S.getCurrentInstance();t&&("function"==typeof t.updateToolbarButtonStates&&t.updateToolbarButtonStates(),"function"==typeof t.onContentChange&&t.onContentChange())},0))}toggle(){this.colorPicker.isVisible?this.colorPicker.hide():this.showColorPicker()}showColorPicker(){const t=S.getInstanceById(this.editorId);if(!t)return;const e=window.getSelection();e&&e.rangeCount&&!e.isCollapsed?G.savedRanges.set(this.editorId,e.getRangeAt(0).cloneRange()):t._lastRange&&G.savedRanges.set(this.editorId,t._lastRange.cloneRange());const i=t.getModule("toolbar");let o=null;if(i&&(o=i.getButton("color")),!o){const t=i?.getContainer();t&&(o=t.querySelector(".rich-editor-toolbar-btn.color-btn"))}o||(o=t.wrapper.querySelector(".rich-editor-toolbar-btn.color-btn")),o&&this.colorPicker.show(o)}isActive(){return!!G.getCurrentColor()}static getCurrentColor(){const t=window.getSelection();if(!t||!t.rangeCount)return null;let e=t.getRangeAt(0).startContainer;for(e.nodeType===Node.TEXT_NODE&&(e=e.parentNode);e&&e.nodeType===Node.ELEMENT_NODE&&(!e.classList||!e.classList.contains("rich-editor-area"));){if(e.style&&e.style.color&&"inherit"!==e.style.color)return e.style.color;if("FONT"===e.tagName&&e.getAttribute("color"))return e.getAttribute("color");e=e.parentNode}return null}}class Y extends L{static formatName="background";static tagName="SPAN";static attribute="background-color";static savedRanges=new Map;constructor(){super();const t=S.getCurrentInstance();if(!t)return;this.editorId=t.instanceId;let e=t.getPopupInstance("background");e||(e=new K({onColorSelect:t=>{Y.applyBackgroundToCurrentSelection(t,this.editorId)},editor:t,editorId:this.editorId}),t.setPopupInstance("background",e)),this.colorPicker=e}static createForEditor(t){const e=S.getInstanceById(t);if(!e)return null;const i=S.currentInstance;S.currentInstance=e;const o=new Y;return S.currentInstance=i,o}static applyBackgroundToCurrentSelection(t,e=null){let n=null;if(n=e?S.getInstanceById(e):S.getCurrentInstance(),!n)return;const r=window.getSelection(),s=null!=e?Y.savedRanges.get(e):null;s&&(r.removeAllRanges(),r.addRange(s)),null!=e&&Y.savedRanges.delete(e),r&&r.rangeCount&&!r.isCollapsed&&(R(),o(!0),i("backColor","transparent"===t?"inherit":t),setTimeout(()=>{n&&("function"==typeof n.updateToolbarButtonStates&&n.updateToolbarButtonStates(),"function"==typeof n.onContentChange&&n.onContentChange())},0))}toggle(){this.colorPicker.isVisible?this.colorPicker.hide():this.showColorPicker()}showColorPicker(){const t=S.getInstanceById(this.editorId);if(!t)return;const e=window.getSelection();e&&e.rangeCount&&!e.isCollapsed?Y.savedRanges.set(this.editorId,e.getRangeAt(0).cloneRange()):t._lastRange&&Y.savedRanges.set(this.editorId,t._lastRange.cloneRange());const i=t.getModule("toolbar");let o=null;if(i&&(o=i.getButton("background")),!o){const t=i?.getContainer();t&&(o=t.querySelector(".rich-editor-toolbar-btn.background-btn"))}o||(o=t.wrapper.querySelector(".rich-editor-toolbar-btn.background-btn")),o&&this.colorPicker.show(o)}isActive(){return!!Y.getCurrentColor()}static getCurrentColor(){const t=window.getSelection();if(!t||!t.rangeCount)return null;let e=t.getRangeAt(0).startContainer;for(e.nodeType===Node.TEXT_NODE&&(e=e.parentNode);e&&e.nodeType===Node.ELEMENT_NODE&&(!e.classList||!e.classList.contains("rich-editor-area"));){if(e.style&&e.style.backgroundColor&&"inherit"!==e.style.backgroundColor)return e.style.backgroundColor;e=e.parentNode}return null}}class Q{constructor(t={}){this.options={onLinkSelect:null,editor:null,...t},this.popup=null,this.isVisible=!1,this.urlInput=null,this.textInput=null,this.createPopup()}createPopup(){this.popup=document.createElement("div"),this.popup.className="link-popup link-popup--inline";const t=document.createElement("div");t.className="link-popup-content",this.textGroup=document.createElement("div"),this.textGroup.className="link-popup-row",this.textInput=document.createElement("input"),this.textInput.type="text",this.textInput.className="yjd-input",this.textInput.placeholder="Text to display",this.textGroup.appendChild(this.textInput);const e=document.createElement("div");e.className="link-popup-row",this.urlInput=document.createElement("input"),this.urlInput.type="text",this.urlInput.className="yjd-input",this.urlInput.placeholder="Paste or type a link…",this.applyBtn=document.createElement("button"),this.applyBtn.type="button",this.applyBtn.className="yjd-button-confirm link-popup-apply",this.applyBtn.textContent="Apply",this.applyBtn.onclick=()=>{this.handleOk(),this._refocusEditor()},e.appendChild(this.urlInput),e.appendChild(this.applyBtn),t.appendChild(this.textGroup),t.appendChild(e),this.popup.appendChild(t);const i=t=>{"Enter"===t.key&&(t.preventDefault(),this.handleOk(),this._refocusEditor()),"Escape"===t.key&&(this.hide(),this._refocusEditor())};this.urlInput.onkeydown=i,this.textInput.onkeydown=i,q(this.popup),this.options.editor&&"function"==typeof this.options.editor.preventFocusLoss&&this.options.editor.preventFocusLoss(this.popup)}_refocusEditor(){this.options.editor&&setTimeout(()=>this.options.editor.focus(),0)}handleOk(){const t=this.urlInput.value.trim();if(!t)return void this.urlInput.focus();let e=t;/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(e)||e.startsWith("/")||e.startsWith("#")||(e="https://"+e);const i=this.textInput.value.trim();this.options.onLinkSelect&&this.options.onLinkSelect({url:e,text:i}),this.hide()}show(t,e=null,i=""){if(!t)return;const o=!!i;this.urlInput.value=e?e.url:"",this.textInput.value=i||(e?e.text:""),this.textGroup.style.display=o?"none":"";const n=$(t,this.popup,{offsetY:8,offsetX:0});X(this.popup,n),this.popup.classList.add("visible"),this.isVisible=!0,setTimeout(()=>this.urlInput.focus(),60),setTimeout(()=>{document.addEventListener("click",this.closeOnClickOutside)},100)}hide(){this.popup.classList.remove("visible"),this.isVisible=!1,document.removeEventListener("click",this.closeOnClickOutside)}closeOnClickOutside=t=>{this.popup.contains(t.target)||this.hide()};destroy(){document.removeEventListener("click",this.closeOnClickOutside),this.popup&&this.popup.parentNode&&this.popup.parentNode.removeChild(this.popup)}}class Z extends L{static formatName="link";static tagName="A";static savedRanges=new Map;constructor(){super();const t=S.getCurrentInstance();if(!t)return;this.editorId=t.instanceId;let e=t.getPopupInstance("link");e||(e=new Q({onLinkSelect:t=>{Z.insertLink(t,this.editorId)},editor:t,editorId:this.editorId}),t.setPopupInstance("link",e)),this.linkPopup=e}static createForEditor(t){const e=S.getInstanceById(t);if(!e)return null;const i=S.currentInstance;S.currentInstance=e;const o=new Z;return S.currentInstance=i,o}static insertLink(t,e=null){let i=null;if(i=e?S.getInstanceById(e):S.getCurrentInstance(),!i)return;if(!a(t.url))return;const o=Z.savedRanges.get(e);if(!o)return;const n=window.getSelection();n.removeAllRanges(),n.addRange(o);const r=n.getRangeAt(0);if(r.collapsed){const e=document.createElement("A");e.href=t.url,e.target="_blank",e.rel="noopener noreferrer",e.textContent=t.text||t.url,r.insertNode(e)}else{const e=r.extractContents(),i=document.createElement("A");for(i.href=t.url,i.target="_blank",i.rel="noopener noreferrer";e.firstChild;)i.appendChild(e.firstChild);r.insertNode(i)}const s=document.createRange();s.setStartAfter(r.endContainer),s.collapse(!0),n.removeAllRanges(),n.addRange(s),setTimeout(()=>{i&&"function"==typeof i.onContentChange&&i.onContentChange()},0),Z.savedRanges.delete(e),i&&"function"==typeof i.onContentChange&&i.onContentChange()}toggle(){this.linkPopup.isVisible?this.linkPopup.hide():this.showPopup()}showPopup(){const t=S.getInstanceById(this.editorId);if(!t)return;const e=window.getSelection();let i=null;if(e&&e.rangeCount>0){const t=e.getRangeAt(0).cloneRange();if(Z.savedRanges.set(this.editorId,t),i=t.getBoundingClientRect(),!i||0===i.width&&0===i.height){const e=t.startContainer.nodeType===Node.TEXT_NODE?t.startContainer.parentElement:t.startContainer;e&&e.getBoundingClientRect&&(i=e.getBoundingClientRect())}}const o=this.getCurrentLink();let n="";e&&!e.isCollapsed&&(n=e.toString().trim());let r=null;if(i&&(i.width||i.height))r={getBoundingClientRect:()=>i};else{const e=t.getModule("toolbar");r=e&&(e.getButton("link")||t.wrapper.querySelector('.rich-editor-toolbar-btn[data-command="link"]'))}r&&this.linkPopup.show(r,o,n)}getCurrentLink(){const t=window.getSelection();if(!t||!t.rangeCount)return null;let e=t.getRangeAt(0).startContainer;for(;e&&e!==document.body;){if(e.nodeType===Node.ELEMENT_NODE&&"A"===e.tagName)return{url:e.href||"",text:e.textContent||""};e=e.parentNode}return null}isActive(){return null!==this.getCurrentLink()}}class J{constructor(t={}){this.options={maxRows:8,maxCols:8,onTableSelect:null,...t},this.popup=null,this.isVisible=!1,this.selectedRows=1,this.selectedCols=1,this.grid=null,this.sizeDisplay=null,this.createPopup()}createPopup(){this.popup=document.createElement("div"),this.popup.className="table-popup";const t=document.createElement("div");t.className="table-popup-content",this.createSizeDisplay(),this.createGridSelector(),t.appendChild(this.grid),t.appendChild(this.sizeDisplay),this.popup.appendChild(t),q(this.popup)}createSizeDisplay(){this.sizeDisplay=document.createElement("div"),this.sizeDisplay.className="table-size-display"}createGridSelector(){this.grid=document.createElement("div"),this.grid.className="table-grid-selector";for(let t=1;t<=this.options.maxRows;t++)for(let e=1;e<=this.options.maxCols;e++){const i=document.createElement("div");i.className="table-grid-cell",i.dataset.row=t,i.dataset.col=e,i.addEventListener("mouseenter",()=>{this.highlightGrid(t,e)}),i.addEventListener("click",()=>{this.selectSize(t,e),this.handleInsert()}),this.grid.appendChild(i)}this.grid.addEventListener("mouseleave",()=>{this.highlightGrid(1,1)})}highlightGrid(t,e){this.selectedRows=t,this.selectedCols=e,this.updateSizeDisplay(t,e);this.grid.querySelectorAll(".table-grid-cell").forEach(i=>{const o=parseInt(i.dataset.row),n=parseInt(i.dataset.col);o<=t&&n<=e?i.classList.add("highlighted"):i.classList.remove("highlighted")})}updateSizeDisplay(t,e){this.sizeDisplay&&(this.sizeDisplay.textContent=`${t}x${e}`)}selectSize(t,e){this.selectedRows=t,this.selectedCols=e,this.updateSizeDisplay(t,e)}handleInsert(){this.options.onTableSelect&&this.options.onTableSelect({rows:this.selectedRows,cols:this.selectedCols}),this.hide()}show(t){if(!t)return;this.selectedRows=1,this.selectedCols=1,this.highlightGrid(1,1);const e=$(t,this.popup,{offsetY:5,offsetX:0});X(this.popup,e),this.popup.classList.add("visible"),this.isVisible=!0,setTimeout(()=>{document.addEventListener("click",this.closeOnClickOutside)},100)}hide(){this.popup.classList.remove("visible"),this.isVisible=!1,document.removeEventListener("click",this.closeOnClickOutside)}closeOnClickOutside=t=>{this.popup.contains(t.target)||this.hide()};destroy(){document.removeEventListener("click",this.closeOnClickOutside),this.popup&&this.popup.parentNode&&this.popup.parentNode.removeChild(this.popup)}}class tt extends A{static formatName="table";static tagName="TABLE";static savedRanges=new Map;constructor(){super();const t=S.getCurrentInstance();if(!t)return;this.editorId=t.instanceId;let e=t.getPopupInstance("table");e||(e=new J({onTableSelect:t=>{tt.insertTable(t,this.editorId)},editor:t,editorId:this.editorId}),t.setPopupInstance("table",e)),this.tablePopup=e}static createForEditor(t){const e=S.getInstanceById(t);if(!e)return null;const i=S.currentInstance;S.currentInstance=e;const o=new tt;return S.currentInstance=i,o}static insertTable(t,e=null){let i=null;if(i=e?S.getInstanceById(e):S.getCurrentInstance(),!i)return;const o=tt.savedRanges.get(e);if(!o)return;const n=window.getSelection();n.removeAllRanges(),n.addRange(o);const r=n.getRangeAt(0),s=tt.createTableElement(t.rows,t.cols);r.collapsed||r.deleteContents(),"function"==typeof i.insertBlock?i.insertBlock(s):r.insertNode(s);const a=s.querySelector("td");if(a){const t=document.createRange();t.setStart(a,0),t.collapse(!0),n.removeAllRanges(),n.addRange(t)}tt.savedRanges.delete(e),i&&"function"==typeof i.onContentChange&&i.onContentChange()}static createTableElement(t,e){const i=document.createElement("table");i.className="rich-editor-table",i.cellSpacing="0",i.cellPadding="0",i.border="1";const o=document.createElement("tbody");for(let i=0;i<t;i++){const t=document.createElement("tr");for(let i=0;i<e;i++){const e=document.createElement("td");e.innerHTML="<br>",e.style.minWidth="50px",e.style.minHeight="24px",e.style.padding="4px 8px",e.style.border="1px solid #ddd",e.style.verticalAlign="top",e.contentEditable="true",t.appendChild(e)}o.appendChild(t)}return i.appendChild(o),i.style.borderCollapse="collapse",i.style.width="100%",i.style.margin="10px 0",i}toggle(){this.tablePopup.isVisible?this.tablePopup.hide():this.showPopup()}showPopup(){const t=window.getSelection();t&&t.rangeCount>0&&tt.savedRanges.set(this.editorId,t.getRangeAt(0).cloneRange());const e=S.getInstanceById(this.editorId);if(!e)return;const i=e.getModule("toolbar");let o=null;if(i&&(o=i.getButton("table")),!o){const t=i?.getContainer();t&&(o=t.querySelector(".rich-editor-toolbar-btn.table-btn"))}o||(o=e.wrapper.querySelector(".rich-editor-toolbar-btn.table-btn")),o&&this.tablePopup.show(o)}isActive(){const t=window.getSelection();if(!t||!t.rangeCount)return!1;let e=t.getRangeAt(0).startContainer;for(;e&&e!==document.body;){if(e.nodeType===Node.ELEMENT_NODE&&"TABLE"===e.tagName)return!0;e=e.parentNode}return!1}getCurrentTable(){const t=window.getSelection();if(!t||!t.rangeCount)return null;let e=t.getRangeAt(0).startContainer;for(;e&&e!==document.body;){if(e.nodeType===Node.ELEMENT_NODE&&"TABLE"===e.tagName)return e;e=e.parentNode}return null}apply(){this.showPopup()}remove(){const t=this.getCurrentTable();t&&(window.richEditor&&window.richEditor.resizeHandles&&window.richEditor.resizeHandles.hideHandles(),t.parentNode.removeChild(t))}}class et{constructor(t={}){this.options={items:[],onItemSelect:null,displayProperty:"label",valueProperty:"value",className:"custom-select",title:"",width:200,height:280,...t},this.popup=null,this.isVisible=!1,this.currentValue=null,this.clickOutsideHandler=null,this.initialized=!1,this.createSelect()}createSelect(){if(this.popup=document.createElement("div"),this.popup.className=`${this.options.className}-popup`,this.options.title){const t=document.createElement("div");t.className="custom-select-header",t.textContent=this.options.title,this.popup.appendChild(t)}q(this.popup),this.init()}async init(){await this.createItemList(),this.initialized=!0}async createItemList(){const t=document.createElement("div");t.className="item-list";const e=V.getIcon("check");this.options.items.forEach(i=>{const o=document.createElement("button");o.type="button",o.className="custom-select-item-button",o.dataset.value=this.getItemValue(i);const n=document.createElement("div");n.className="item-text",n.innerHTML=this.getItemDisplay(i);const r=document.createElement("span");r.className="item-checkmark",r.innerHTML=e||"",o.appendChild(n),o.appendChild(r),o.addEventListener("click",t=>{t.preventDefault(),t.stopPropagation(),this.selectItem(i)}),t.appendChild(o)}),this.popup.appendChild(t)}getItemDisplay(t){return t[this.options.displayProperty]||t.toString()}getItemValue(t){return t[this.options.valueProperty]||t[this.options.displayProperty]||t}async updateItems(t){this.options.items=t;const e=this.popup.querySelector(".item-list");e&&e.remove(),await this.createItemList()}setupClickOutside(){this.clickOutsideHandler&&document.removeEventListener("click",this.clickOutsideHandler),this.clickOutsideHandler=t=>{t.target.closest(".block-toolbar")||this.popup.contains(t.target)||this.hide()},setTimeout(()=>{document.addEventListener("click",this.clickOutsideHandler)},100)}removeClickOutside(){this.clickOutsideHandler&&(document.removeEventListener("click",this.clickOutsideHandler),this.clickOutsideHandler=null)}setupScrollHandler(){this.scrollHandler&&window.removeEventListener("scroll",this.scrollHandler),this.scrollHandler=()=>{this.isVisible&&this.updatePosition()},window.addEventListener("scroll",this.scrollHandler)}removeScrollHandler(){this.scrollHandler&&(window.removeEventListener("scroll",this.scrollHandler),this.scrollHandler=null)}async show(t){if(!t)return;const e=window.getSelection(),i=S.getCurrentInstance&&S.getCurrentInstance(),o=i&&i.editor;e&&e.rangeCount&&o&&o.contains(e.anchorNode)?this._savedRange=e.getRangeAt(0).cloneRange():this._savedRange=i&&i._lastRange?i._lastRange.cloneRange():null,this.initialized||await new Promise(t=>{const e=()=>{this.initialized?t():setTimeout(e,10)};e()}),document.body.contains(this.popup)||q(this.popup),this.highlightCurrentItem(this.currentValue);const n=$(t,this.popup,{offsetY:5,offsetX:0});X(this.popup,n),this.popup.classList.add("visible"),this.isVisible=!0,this.setupClickOutside(),this.setupScrollHandler(),this.currentAnchor=t}hide(){this.popup.classList.remove("visible"),this.isVisible=!1,this.removeClickOutside(),this.currentAnchor=null}updatePosition(){if(this.isVisible&&this.currentAnchor){const t=$(this.currentAnchor,this.popup,{offsetY:5,offsetX:0});X(this.popup,t)}}setCurrentValue(t){this.currentValue=t,this.highlightCurrentItem(t)}highlightCurrentItem(t){if(this.popup.querySelectorAll(".custom-select-item-button.current").forEach(t=>{t.classList.remove("current")}),null!=t){const e=this.popup.querySelectorAll(".custom-select-item-button");for(const i of e)if(i.dataset.value===t.toString()){i.classList.add("current");break}}}selectItem(t){const e=this.getItemValue(t);if(this.currentValue=e,this._savedRange){const t=window.getSelection();t.removeAllRanges(),t.addRange(this._savedRange)}this.options.onItemSelect&&this.options.onItemSelect(e,t),this.hide()}getCurrentValue(){return this.currentValue}destroy(){this.removeClickOutside(),this.popup&&this.popup.parentNode&&this.popup.parentNode.removeChild(this.popup)}}class it extends A{static formatName="heading";static tagName="H1";constructor(){super();const t=S.getCurrentInstance();if(!t)return;this.editorId=t.instanceId;let e=t.getPopupInstance("heading");if(!e){const i=it.getTagMap(),o=Object.values(i).map(t=>({value:t.tag,label:t.element,title:t.title}));e=new et({items:o,displayProperty:"label",valueProperty:"value",className:"heading-select",onItemSelect:(t,e)=>{it.applyTagToCurrentSelection(t,this.editorId)},editor:t,editorId:this.editorId}),t.setPopupInstance("heading",e)}this.customSelect=e}static createForEditor(t){const e=S.getInstanceById(t);if(!e)return null;const i=S.currentInstance;S.currentInstance=e;const o=new it;return S.currentInstance=i,o}static getTagMap(){return{H1:{tag:"H1",element:'<h1 style="margin:0">Heading 1</h1>',title:"Heading 1"},H2:{tag:"H2",element:'<h2 style="margin:0">Heading 2</h2>',title:"Heading 2"},H3:{tag:"H3",element:'<h3 style="margin:0">Heading 3</h3>',title:"Heading 3"},H4:{tag:"H4",element:'<h4 style="margin:0">Heading 4</h4>',title:"Heading 4"},H5:{tag:"H5",element:'<h5 style="margin:0">Heading 5</h5>',title:"Heading 5"},H6:{tag:"H6",element:'<h6 style="margin:0">Heading 6</h6>',title:"Heading 6"},P:{tag:"P",element:'<p style="margin:0">Paragraph</p>',title:"Paragraph"},PRE:{tag:"PRE",element:'<pre style="margin:0">Code</pre>',title:"Preformatted"},BLOCKQUOTE:{tag:"BLOCKQUOTE",element:'<blockquote style="margin:0">Quote</blockquote>',title:"Quote"}}}static getTagDisplayName(t){const e=this.getTagMap();return e[t]?.title||"Paragraph"}updateButtonText(){const t=this.getCurrentTag(),e=it.getTagDisplayName(t||"P"),i=S.getInstanceById(this.editorId);if(!i)return;const o=i.getModule("toolbar");let n=null;if(o&&(n=o.getButton("heading")),!n){const t=o?.getContainer();t&&(n=t.querySelector(".rich-editor-toolbar-btn.heading-btn"))}n||(n=i.wrapper.querySelector(".rich-editor-toolbar-btn.heading-btn")),n&&n.updateText?n.updateText(e):n&&(n.textContent=e)}static create(t="P"){return document.createElement(t.toUpperCase())}static applyTagToCurrentSelection(t,e=null){let i=null;if(i=e?S.getInstanceById(e):S.getCurrentInstance(),!i)return;const o=window.getSelection();if(!o||!o.rangeCount)return;R(),o.getRangeAt(0);const n=it.createForEditor(e);n&&(n.apply(t),n.updateButtonText()),setTimeout(()=>{i&&"function"==typeof i.onContentChange&&i.onContentChange()},0)}apply(t="P"){const e=window.getSelection();if(!e||!e.rangeCount)return;const i=e.getRangeAt(0);i.collapsed;const o=this.getBlockElements(i);if(0===o.length){const n=this.createBlockAtCursor(i,t),r=document.createRange();r.setStart(n,0),r.collapse(!0),e.removeAllRanges(),e.addRange(r)}else{const s=window.getSelection();if(!s.rangeCount)return;const a=s.getRangeAt(0),l=a.collapsed,c=Array.from(o);function d(t,e){for(;t&&9!==t.nodeType;){const i=e.indexOf(t);if(-1!==i)return i;t=t.parentNode}return-1}function h(t,e,i){const o=document.createRange();return o.setStart(t,0),o.setEnd(e,i),o.toString().length}const p=d(a.startContainer,c),u=d(a.endContainer,c);let m=0,g=0;-1!==p&&(m=h(c[p],a.startContainer,a.startOffset)),l||-1===u||(g=h(c[u],a.endContainer,a.endOffset));const f=c.map(e=>this.convertBlock(e,t)||e);function y(t,e){const i=document.createTreeWalker(t,NodeFilter.SHOW_TEXT,null,!1);let o,n=e;for(;o=i.nextNode();){const t=o.nodeValue.length;if(n<=t)return{node:o,offset:n};n-=t}return{node:t,offset:t.childNodes.length}}const b=document.createRange();if(l){const v=y(f[-1!==p?p:0],m);v.node.nodeType===Node.TEXT_NODE?b.setStart(v.node,v.offset):b.setStart(v.node,Math.max(0,v.offset)),b.collapse(!0)}else{if(-1===p||-1===u)return s.removeAllRanges(),void s.addRange(a);const x=y(f[p],m),C=y(f[u],g);x.node.nodeType===Node.TEXT_NODE?b.setStart(x.node,x.offset):b.setStart(x.node,Math.min(x.offset,x.node.childNodes.length)),C.node.nodeType===Node.TEXT_NODE?b.setEnd(C.node,C.offset):b.setEnd(C.node,Math.min(C.offset,C.node.childNodes.length))}s.removeAllRanges(),s.addRange(b)}}createBlockAtCursor(t,e){const i=this.constructor.create(e),o=this.getBlockElement(t.startContainer);if(o&&o.style&&o.style.cssText&&(i.style.cssText=o.style.cssText),t.collapsed){i.appendChild(document.createTextNode("")),t.insertNode(i);const e=document.createRange();e.setStart(i,0),e.collapse(!0);const o=window.getSelection();o.removeAllRanges(),o.addRange(e)}else{const e=t.extractContents();i.appendChild(e),t.insertNode(i);const o=document.createRange();o.selectNodeContents(i);const n=window.getSelection();n.removeAllRanges(),n.addRange(o)}}convertBlock(t,e){const i=this.constructor.create(e);for(;t.firstChild;)i.appendChild(t.firstChild);return t.className&&this.shouldPreserveClass(t.className)&&(i.className=t.className),t.style&&t.style.cssText&&(i.style.cssText=t.style.cssText),t.parentNode.replaceChild(i,t),i}setCursorAtStartOfBlock(t){const e=window.getSelection(),i=document.createRange(),o=document.createTreeWalker(t,NodeFilter.SHOW_TEXT,null,!1).nextNode();o?(i.setStart(o,0),i.collapse(!0)):(i.setStart(t,0),i.collapse(!0)),e.removeAllRanges(),e.addRange(i)}async toggle(){this.customSelect.isVisible?this.customSelect.hide():await this.showTagPicker()}async showTagPicker(){const t=S.getInstanceById(this.editorId);if(!t)return;const e=t.getModule("toolbar");let i=null;if(e&&(i=e.getButton("heading")),!i){const t=e?.getContainer();t&&(i=t.querySelector(".rich-editor-toolbar-btn.heading-btn"))}if(i||(i=t.wrapper.querySelector(".rich-editor-toolbar-btn.heading-btn")),!i)return;const o=this.getCurrentTag();o&&this.customSelect.setCurrentValue(o),await this.customSelect.show(i)}isActive(t=null){return this.updateButtonText(),!1}getCurrentTag(){const t=window.getSelection();if(!t||!t.rangeCount)return null;const e=t.getRangeAt(0),i=this.getBlockElement(e.startContainer);if(!i)return null;return["H1","H2","H3","H4","H5","H6","P","PRE","BLOCKQUOTE"].includes(i.tagName)?i.tagName:null}}class ot extends L{static formatName="fontFamily";static tagName="SPAN";constructor(){super();const t=S.getCurrentInstance();if(!t)return;this.editorId=t.instanceId;let e=t.getPopupInstance("font-family");if(!e){const i=ot.getFontMap(),o=Object.values(i).map(t=>({value:t.font,label:t.element,title:t.title}));e=new et({items:o,displayProperty:"label",valueProperty:"value",className:"font-family-select",onItemSelect:(t,e)=>{ot.applyFontFamilyToCurrentSelection(t,this.editorId)},editor:t,editorId:this.editorId}),t.setPopupInstance("font-family",e)}this.customSelect=e,this.setupSelectionListener()}static createForEditor(t){const e=S.getInstanceById(t);if(!e)return null;const i=S.currentInstance;S.currentInstance=e;const o=new ot;return S.currentInstance=i,o}setupSelectionListener(){let t;const e=()=>{clearTimeout(t),t=setTimeout(()=>{const t=window.getSelection();if(t&&t.rangeCount>0){const e=t.getRangeAt(0),i=S.getInstanceById(this.editorId);i&&(i.editor.contains(e.startContainer)||i.editor.isSameNode(e.startContainer))&&this.updateButtonText()}},50)};document.addEventListener("selectionchange",e),document.addEventListener("mouseup",e),document.addEventListener("keyup",e),this.selectionListener=e}static getFontMap(){return{Arial:{font:"Arial, sans-serif",element:'<span style="font-family: Arial, sans-serif">Arial</span>',title:"Arial"},Helvetica:{font:"Helvetica, Arial, sans-serif",element:'<span style="font-family: Helvetica, Arial, sans-serif">Helvetica</span>',title:"Helvetica"},"Times New Roman":{font:'"Times New Roman", Times, serif',element:"<span style=\"font-family: 'Times New Roman', Times, serif\">Times New Roman</span>",title:"Times New Roman"},Georgia:{font:"Georgia, serif",element:'<span style="font-family: Georgia, serif">Georgia</span>',title:"Georgia"},Verdana:{font:"Verdana, Geneva, sans-serif",element:'<span style="font-family: Verdana, Geneva, sans-serif">Verdana</span>',title:"Verdana"},"Courier New":{font:'"Courier New", Courier, monospace',element:"<span style=\"font-family: 'Courier New', Courier, monospace\">Courier New</span>",title:"Courier New"},"Trebuchet MS":{font:'"Trebuchet MS", Helvetica, sans-serif',element:"<span style=\"font-family: 'Trebuchet MS', Helvetica, sans-serif\">Trebuchet MS</span>",title:"Trebuchet MS"},"Comic Sans MS":{font:'"Comic Sans MS", cursive',element:"<span style=\"font-family: 'Comic Sans MS', cursive\">Comic Sans MS</span>",title:"Comic Sans MS"},Impact:{font:"Impact, Charcoal, sans-serif",element:'<span style="font-family: Impact, Charcoal, sans-serif">Impact</span>',title:"Impact"},"Lucida Console":{font:'"Lucida Console", Monaco, monospace',element:"<span style=\"font-family: 'Lucida Console', Monaco, monospace\">Lucida Console</span>",title:"Lucida Console"}}}static getFontDisplayName(t){const e=this.getFontMap();for(const[i,o]of Object.entries(e))if(o.font===t||i===t)return o.title;return"Arial"}updateButtonText(){const t=this.getCurrentFont(),e=ot.getFontDisplayName(t||"Arial, sans-serif"),i=S.getInstanceById(this.editorId);if(!i)return;const o=i.getModule("toolbar");let n=null;if(o&&(n=o.getButton("font-family")),!n){const t=o?.getContainer();t&&(n=t.querySelector(".rich-editor-toolbar-btn.font-family-btn"))}n||(n=i.wrapper.querySelector(".rich-editor-toolbar-btn.font-family-btn")),n&&n.updateText?n.updateText(e):n&&(n.textContent=e)}static create(t="Arial, sans-serif"){const e=document.createElement("span");return e.style.fontFamily=t,e}static applyFontFamilyToCurrentSelection(t,e=null){let i=null;if(i=e?S.getInstanceById(e):S.getCurrentInstance(),!i)return;const o=window.getSelection();if(!o||!o.rangeCount)return;R(),o.getRangeAt(0);const n=ot.createForEditor(e);n&&(n.apply(t),n.updateButtonText()),setTimeout(()=>{i&&"function"==typeof i.onContentChange&&i.onContentChange()},0)}apply(t="Arial, sans-serif"){const e=window.getSelection();if(!e||!e.rangeCount)return;const o=e.getRangeAt(0);function n(t){const e=window.getSelection(),i=document.createRange(),o=t.firstChild;i.setStart(o,o.length),i.collapse(!0),e.removeAllRanges(),e.addRange(i)}if(o.collapsed){if(function(t,e){if(!t.rangeCount)return!1;let i=t.getRangeAt(0).startContainer;i.nodeType===Node.TEXT_NODE&&(i=i.parentNode);const o=e.split(",")[0].trim().toLowerCase();for(;i&&i.nodeType===Node.ELEMENT_NODE;){if("SPAN"===i.tagName){const t=i.style.fontFamily;if(t&&t.split(",")[0].trim().toLowerCase()===o)return 1===i.childNodes.length&&i.firstChild.nodeType===Node.TEXT_NODE&&i.firstChild.textContent,!0}i=i.parentNode}return!1}(e,t))return;let i=o.startContainer;o.startOffset,i.nodeType===Node.TEXT_NODE&&(i=i.parentNode);const r=i.closest&&i.closest("span");if(r&&"​"===r.textContent)return void(r.style.fontFamily=t);if(r&&r.firstChild&&r.firstChild.nodeType===Node.TEXT_NODE){const e=r.firstChild,i=o.startOffset,s=e.data.slice(0,i),a=e.data.slice(i),l=r.parentNode;if(0===i){const e=document.createElement("span");e.style.fontFamily=t,e.appendChild(document.createTextNode("​")),l.insertBefore(e,r),n(e)}else if(i===e.data.length){const e=document.createElement("span");e.style.fontFamily=t,e.appendChild(document.createTextNode("​")),l.insertBefore(e,r.nextSibling),n(e)}else{const e=document.createElement("span");e.style.fontFamily=r.style.fontFamily,e.appendChild(document.createTextNode(s));const i=document.createElement("span");i.style.fontFamily=t,i.appendChild(document.createTextNode("​"));const o=document.createElement("span");o.style.fontFamily=r.style.fontFamily,o.appendChild(document.createTextNode(a)),l.insertBefore(e,r),l.insertBefore(i,r),l.insertBefore(o,r),l.removeChild(r),n(i)}return}const s=document.createElement("span");s.style.fontFamily=t,s.appendChild(document.createTextNode("​")),o.insertNode(s),n(s)}else i("fontName",t)}async toggle(t=null){this.customSelect.isVisible?this.customSelect.hide():await this.showFontPicker(t)}async showFontPicker(t=null){let e=t;if(!e){const t=S.getInstanceById(this.editorId);if(!t)return;const i=t.getModule("toolbar");if(i&&(e=i.getButton("font-family")),!e){const t=i?.getContainer();t&&(e=t.querySelector(".rich-editor-toolbar-btn.font-family-btn"))}e||(e=t.wrapper.querySelector(".rich-editor-toolbar-btn.font-family-btn"))}if(!e)return;const i=this.getCurrentFont();i&&this.customSelect.setCurrentValue(i),await this.customSelect.show(e)}isActive(t=null){return this.updateButtonText(),!1}getCurrentFont(){const t=window.getSelection();if(!t||!t.rangeCount)return null;let e=t.getRangeAt(0).startContainer;e.nodeType===Node.TEXT_NODE&&(e=e.parentElement);const i=S.getInstanceById(this.editorId);if(!i)return"Arial, sans-serif";if(!i.editor.contains(e)&&!i.editor.isSameNode(e))return"Arial, sans-serif";for(;e&&e!==document.body;){if(e.nodeType===Node.ELEMENT_NODE){const t=e;if(t.style.fontFamily)return t.style.fontFamily;const i=window.getComputedStyle(t).fontFamily;if(i&&"initial"!==i&&"inherit"!==i)return i}e=e.parentElement}return"Arial, sans-serif"}setCurrentFont(t){this.currentFont=t}}class nt extends L{static formatName="lineHeight";static tagName="SPAN";constructor(){super();const t=S.getCurrentInstance();if(!t)return;this.editorId=t.instanceId;let e=t.getPopupInstance("line-height");if(!e){const i=nt.getHeightMap(),o=Object.values(i).map(t=>({value:t.height,label:t.element,title:t.title}));e=new et({items:o,displayProperty:"label",valueProperty:"value",className:"line-height-select",onItemSelect:(t,e)=>{nt.applyLineHeightToCurrentSelection(t,this.editorId)},editor:t,editorId:this.editorId}),t.setPopupInstance("line-height",e)}this.customSelect=e,this.setupSelectionListener()}static createForEditor(t){const e=S.getInstanceById(t);if(!e)return null;const i=S.currentInstance;S.currentInstance=e;const o=new nt;return S.currentInstance=i,o}setupSelectionListener(){let t;const e=()=>{clearTimeout(t),t=setTimeout(()=>{const t=window.getSelection();if(t&&t.rangeCount>0){const e=t.getRangeAt(0),i=S.getInstanceById(this.editorId);i&&(i.editor.contains(e.startContainer)||i.editor.isSameNode(e.startContainer))&&this.updateButtonText()}},50)};document.addEventListener("selectionchange",e),document.addEventListener("mouseup",e),document.addEventListener("keyup",e),this.selectionListener=e}static getHeightMap(){return{"1.0":{height:"1",element:"<span>1.0</span>",title:"1.0"},1.2:{height:"1.2",element:"<span>1.2</span>",title:"1.2"},1.5:{height:"1.5",element:"<span>1.5</span>",title:"1.5"},1.8:{height:"1.8",element:"<span>1.8</span>",title:"1.8"},"2.0":{height:"2",element:"<span>2.0</span>",title:"2.0"},2.5:{height:"2.5",element:"<span>2.5</span>",title:"2.5"},"3.0":{height:"3",element:"<span>3.0</span>",title:"3.0"}}}static getHeightDisplayName(t){const e=this.getHeightMap();if(e[t]?.title)return e[t].title;const i=parseFloat(t);return isNaN(i)?"Normal":String(i)}updateButtonText(){const t=this.getCurrentHeight(),e=nt.getHeightDisplayName(t||"1.15"),i=S.getInstanceById(this.editorId);if(!i)return;const o=i.getModule("toolbar");let n=null;if(o&&(n=o.getButton("line-height")),!n){const t=o?.getContainer();t&&(n=t.querySelector(".rich-editor-toolbar-btn.line-height-btn"))}n||(n=i.wrapper.querySelector(".rich-editor-toolbar-btn.line-height-btn")),n&&n.updateText?n.updateText(e):n&&(n.textContent=e)}static create(t="1.15"){const e=document.createElement("span");return e.style.lineHeight=t,e}static applyLineHeightToCurrentSelection(t,e=null){let i=null;if(i=e?S.getInstanceById(e):S.getCurrentInstance(),!i)return;const o=window.getSelection();if(!o||!o.rangeCount)return;R(),o.getRangeAt(0);const n=nt.createForEditor(e);n&&(n.apply(t),n.updateButtonText()),setTimeout(()=>{i&&"function"==typeof i.onContentChange&&i.onContentChange()},0)}apply(t="1.15"){const e=window.getSelection();if(!e||!e.rangeCount)return;R();const i=e.getRangeAt(0);if(i.collapsed){let e=i.startContainer;e.nodeType===Node.TEXT_NODE&&(e=e.parentNode);const o=e.closest("div, p, li, section, article")||e;return o.style.lineHeight=t,void function(t){const e=window.getSelection(),i=document.createRange(),o=t.firstChild;i.setStart(o,o.length),i.collapse(!0),e.removeAllRanges(),e.addRange(i)}(o)}const o=this.getBlockElementsInRange(i);if(o.length>0)o.forEach(e=>{e.style.lineHeight=t});else{const o=this.constructor.create(t);try{const t=i.extractContents();o.appendChild(t),i.insertNode(o);const n=document.createRange();n.selectNodeContents(o),e.removeAllRanges(),e.addRange(n)}catch(t){}}}getBlockElementsInRange(t){const e=[],i=["P","DIV","H1","H2","H3","H4","H5","H6","BLOCKQUOTE","PRE","UL","OL","LI"],o=t.cloneContents(),n=document.createTreeWalker(o,NodeFilter.SHOW_ELEMENT,{acceptNode:t=>i.includes(t.tagName)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP});let r=n.nextNode();for(;r;){const i=t.commonAncestorContainer.querySelector(`${r.tagName.toLowerCase()}:not([data-processed])`);i&&t.intersectsNode(i)&&(e.push(i),i.setAttribute("data-processed","true")),r=n.nextNode()}if(e.forEach(t=>t.removeAttribute("data-processed")),0===e.length){let o=t.startContainer;for(o.nodeType===Node.TEXT_NODE&&(o=o.parentElement);o&&o!==document.body;){if(o.nodeType===Node.ELEMENT_NODE&&i.includes(o.tagName)){e.push(o);break}o=o.parentElement}}return e}async toggle(){this.customSelect.isVisible?this.customSelect.hide():await this.showHeightPicker()}async showHeightPicker(){const t=S.getInstanceById(this.editorId);if(!t)return;const e=t.getModule("toolbar");let i=null;if(e&&(i=e.getButton("line-height")),!i){const t=e?.getContainer();t&&(i=t.querySelector(".rich-editor-toolbar-btn.line-height-btn"))}if(i||(i=t.wrapper.querySelector(".rich-editor-toolbar-btn.line-height-btn")),!i)return;const o=this.getCurrentHeight();o&&this.customSelect.setCurrentValue(o),await this.customSelect.show(i)}isActive(t=null){return this.updateButtonText(),!1}getCurrentHeight(){const t=window.getSelection();if(!t||!t.rangeCount)return null;let e=t.getRangeAt(0).startContainer;e.nodeType===Node.TEXT_NODE&&(e=e.parentElement);const i=S.getInstanceById(this.editorId);if(!i)return"1.15";if(!i.editor.contains(e)&&!i.editor.isSameNode(e))return"1.15";for(;e&&e!==document.body;){if(e.nodeType===Node.ELEMENT_NODE){const t=e;if(t.style.lineHeight){const e=t.style.lineHeight;return this.normalizeHeightValue(e)}const i=window.getComputedStyle(t),o=i.lineHeight;if(o&&"normal"!==o&&"initial"!==o&&"inherit"!==o){if(o.endsWith("px")){const t=parseFloat(i.fontSize),e=parseFloat(o);if(t>0){const i=(e/t).toFixed(2);return this.normalizeHeightValue(i)}}return this.normalizeHeightValue(o)}}e=e.parentElement}return"1.15"}normalizeHeightValue(t){if(!t)return"1.15";const e=parseFloat(t);if(isNaN(e))return"1.15";const i=e.toFixed(1);return this.constructor.getHeightMap()[i]?i:t}destroy(){this.selectionListener&&(document.removeEventListener("selectionchange",this.selectionListener),document.removeEventListener("mouseup",this.selectionListener),document.removeEventListener("keyup",this.selectionListener),this.selectionListener=null)}}class rt extends L{static formatName="capitalization";static tagName="SPAN";constructor(){super();const t=S.getCurrentInstance();if(!t)return;this.editorId=t.instanceId;let e=t.getPopupInstance("capitalization");if(!e){const i=rt.getCapitalizationMap(),o=Object.values(i).map(t=>({value:t.style,label:t.element,title:t.title}));e=new et({items:o,displayProperty:"label",valueProperty:"value",className:"capitalization-select",onItemSelect:(t,e)=>{rt.applyCapitalizationToCurrentSelection(t,this.editorId)},editor:t,editorId:this.editorId}),t.setPopupInstance("capitalization",e)}this.customSelect=e}static createForEditor(t){const e=S.getInstanceById(t);if(!e)return null;const i=S.currentInstance;S.currentInstance=e;const o=new rt;return S.currentInstance=i,o}static getCapitalizationMap(){return{capitalize:{style:"capitalize",element:"<span>Capitalize</span>",title:"Capitalize"},uppercase:{style:"uppercase",element:"<span>UPPERCASE</span>",title:"UPPERCASE"},lowercase:{style:"lowercase",element:"<span>lowercase</span>",title:"lowercase"},"small-caps":{style:"small-caps",element:"<span>Small Caps</span>",title:"Small Caps"}}}static getCapitalizationDisplayName(t){const e=this.getCapitalizationMap();return e[t]?.title||"Capitalization"}updateButtonText(){const t=this.getCurrentCapitalization(),e=rt.getCapitalizationDisplayName(t||"none"),i=S.getInstanceById(this.editorId);if(!i)return;const o=i.getModule("toolbar");let n=null;if(o&&(n=o.getButton("capitalization")),!n){const t=o?.getContainer();t&&(n=t.querySelector(".rich-editor-toolbar-btn.capitalization-btn"))}n||(n=i.wrapper.querySelector(".rich-editor-toolbar-btn.capitalization-btn")),n&&n.updateText?n.updateText(e):n&&(n.textContent=e)}static create(t="none"){const e=document.createElement("span");return"small-caps"===t?e.style.fontVariant="small-caps":e.style.textTransform=t,e}static applyCapitalizationToCurrentSelection(t,e=null){let i=null;if(i=e?S.getInstanceById(e):S.getCurrentInstance(),!i)return;const o=window.getSelection();if(!o||!o.rangeCount)return;R(),o.getRangeAt(0);const n=rt.createForEditor(e);n&&(n.apply(t),n.updateButtonText()),setTimeout(()=>{i&&"function"==typeof i.onContentChange&&i.onContentChange()},0)}hasCapitalizationStyling(t){if(!t||t.nodeType!==Node.ELEMENT_NODE)return!1;if("small-caps"===t.style.fontVariant)return!0;if(t.style.textTransform&&"none"!==t.style.textTransform)return!0;const e=window.getComputedStyle(t);return"small-caps"===e.fontVariant||!(!e.textTransform||"none"===e.textTransform)}isCapitalizationElement(t){return!(!t||t.nodeType!==Node.ELEMENT_NODE)&&("small-caps"===t.style.fontVariant||!(!t.style.textTransform||"none"===t.style.textTransform))}findAncestorCapitalizationElement(t){let e=t;if(!e)return null;for(e.nodeType===Node.TEXT_NODE&&(e=e.parentElement);e&&e!==document.body;){if(this.isCapitalizationElement(e))return e;e=e.parentElement}return null}setElementCapitalizationStyle(t,e){t&&("small-caps"===e?(t.style.fontVariant="small-caps",t.style.textTransform=""):"none"===e?(t.style.fontVariant="",t.style.textTransform=""):(t.style.fontVariant="",t.style.textTransform=e))}apply(t="none"){const e=window.getSelection();if(!e||!e.rangeCount)return;R();const i=e.getRangeAt(0);if(i.collapsed)return;if("small-caps"===t){const t=i.extractContents(),o=document.createElement("span");o.style.fontVariant="small-caps",o.appendChild(t),i.insertNode(o);const n=document.createRange();return n.selectNodeContents(o),e.removeAllRanges(),void e.addRange(n)}function o(t,e){switch(e){case"uppercase":return t.toUpperCase();case"lowercase":return t.toLowerCase();case"capitalize":return(t=t.toLowerCase()).replace(/\b\w/g,t=>t.toUpperCase());default:return t}}const n=i.extractContents(),r=document.createTreeWalker(n,NodeFilter.SHOW_TEXT,null);for(;r.nextNode();){const e=r.currentNode;e.textContent=o(e.textContent,t)}i.deleteContents(),i.insertNode(n),function(t){if(!t)return;const e=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,null),i=[];for(;e.nextNode();){const t=e.currentNode;t.textContent.trim()||0!==t.childElementCount||i.push(t)}i.forEach(t=>t.remove())}(i.commonAncestorContainer),e.removeAllRanges(),e.addRange(i)}removeExistingCapitalization(t){const e=t.commonAncestorContainer,i=new Set,o=e=>{e&&e.nodeType===Node.ELEMENT_NODE&&this.hasCapitalizationStyling(e)&&t.intersectsNode(e)&&i.add(e)};e&&e.nodeType===Node.ELEMENT_NODE&&o(e);const n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>t.intersectsNode(e)&&this.hasCapitalizationStyling(e)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP});let r;for(;r=n.nextNode();)i.add(r);const s=t=>{let e=t.nodeType===Node.TEXT_NODE?t.parentElement:t;for(;e&&e!==document.body;)o(e),e=e.parentElement};s(t.startContainer),s(t.endContainer),Array.from(i).forEach(t=>{t.style.textTransform="",t.style.fontVariant="",t.style.cssText.trim()||t.className||this.unwrapElement(t)})}unwrapElement(t){const e=t.parentNode;if(e){for(;t.firstChild;)e.insertBefore(t.firstChild,t);e.removeChild(t)}}async toggle(){this.customSelect.isVisible?this.customSelect.hide():await this.showCapitalizationPicker()}async showCapitalizationPicker(){const t=S.getInstanceById(this.editorId);if(!t)return;const e=t.getModule("toolbar");let i=null;if(e&&(i=e.getButton("capitalization")),!i){const t=e?.getContainer();t&&(i=t.querySelector(".rich-editor-toolbar-btn.capitalization-btn"))}if(i||(i=t.wrapper.querySelector(".rich-editor-toolbar-btn.capitalization-btn")),!i)return;const o=this.getCurrentCapitalization();o&&this.customSelect.setCurrentValue(o),await this.customSelect.show(i)}isActive(t=null){return this.updateButtonText(),!1}getCurrentCapitalization(){const t=window.getSelection();if(!t||!t.rangeCount)return null;let e=t.getRangeAt(0).startContainer;for(e.nodeType===Node.TEXT_NODE&&(e=e.parentElement);e&&e!==document.body;){if(e.nodeType===Node.ELEMENT_NODE){const t=e;if("small-caps"===t.style.fontVariant)return"small-caps";if(t.style.textTransform&&"none"!==t.style.textTransform)return t.style.textTransform;const i=window.getComputedStyle(t);if("small-caps"===i.fontVariant)return"small-caps";if(i.textTransform&&"none"!==i.textTransform)return i.textTransform}e=e.parentElement}return"none"}setCurrentCapitalization(t){this.currentCapitalization=t}static toggleUppercase(){const t="uppercase"===(new rt).getCurrentCapitalization()?"none":"uppercase";rt.applyCapitalizationToCurrentSelection(t)}static toggleLowercase(){const t="lowercase"===(new rt).getCurrentCapitalization()?"none":"lowercase";rt.applyCapitalizationToCurrentSelection(t)}static toggleCapitalize(){const t="capitalize"===(new rt).getCurrentCapitalization()?"none":"capitalize";rt.applyCapitalizationToCurrentSelection(t)}static toggleSmallCaps(){const t="small-caps"===(new rt).getCurrentCapitalization()?"none":"small-caps";rt.applyCapitalizationToCurrentSelection(t)}}class st{constructor(t={}){this.options={alignments:[{value:"left",label:"Align Left",icon:"align-left"},{value:"center",label:"Align Center",icon:"align-center"},{value:"right",label:"Align Right",icon:"align-right"},{value:"justify",label:"Justify",icon:"align-justify"}],onAlignSelect:null,...t},this.popup=null,this.isVisible=!1,this.currentAlignment="left",this.clickOutsideHandler=null,this.createAlignPicker()}createAlignPicker(){this.popup=document.createElement("div"),this.popup.className="text-align-picker-popup",this.createAlignmentButtons(),q(this.popup)}async createAlignmentButtons(){const t=document.createElement("div");t.className="align-button-container";for(const e of this.options.alignments){const i=document.createElement("button");i.type="button",i.className="align-button",i.dataset.alignment=e.value,i.title=e.label;const o=V.getIcon(e.icon);o?i.innerHTML=`<span class="icon-wrapper">${o}</span>`:i.textContent=e.label.charAt(0),i.addEventListener("click",t=>{t.preventDefault(),t.stopPropagation(),this.selectAlignment(e.value)}),t.appendChild(i)}this.popup.appendChild(t)}setupClickOutside(){this.clickOutsideHandler&&document.removeEventListener("click",this.clickOutsideHandler),this.clickOutsideHandler=t=>{this.popup.contains(t.target)||this.hide()},setTimeout(()=>{document.addEventListener("click",this.clickOutsideHandler)},100)}removeClickOutside(){this.clickOutsideHandler&&(document.removeEventListener("click",this.clickOutsideHandler),this.clickOutsideHandler=null)}show(t){if(!t)return;document.body.contains(this.popup)||q(this.popup),this.updateCurrentAlignment();const e=$(t,this.popup,{offsetY:5,offsetX:0});X(this.popup,e),this.popup.classList.add("visible"),this.isVisible=!0,this.setupClickOutside()}hide(){this.popup.classList.remove("visible"),this.isVisible=!1,this.removeClickOutside()}selectAlignment(t){this.currentAlignment=t,this.options.onAlignSelect&&this.options.onAlignSelect(t),this.hide()}updateCurrentAlignment(){const t=window.getSelection();if(t&&t.rangeCount)try{const e=t.getRangeAt(0),i=this.getSelectedBlockElements(e),o=i.length>0?i[0]:this.getBlockElement(e.commonAncestorContainer);if(o){const t=window.getComputedStyle(o).textAlign;this.currentAlignment="left"!==t&&"start"!==t&&t?t:"left"}else this.currentAlignment="left";this.popup.querySelectorAll(".align-button").forEach(t=>{t.dataset.alignment===this.currentAlignment?t.classList.add("active"):t.classList.remove("active")}),this.updateToolbarButtonIcon(this.currentAlignment)}catch(t){}}getSelectedBlockElements(t){const e=[],i=this.getBlockElement(t.startContainer),o=this.getBlockElement(t.endContainer);if(i&&e.push(i),i&&o&&i!==o){let t=i;for(;t&&t!==o;)t=t.nextElementSibling,t&&this.getBlockElement(t)&&!e.includes(t)&&e.push(t);o&&!e.includes(o)&&e.push(o)}return e}updateToolbarButtonIcon(t){Promise.resolve().then(function(){return lt}).then(e=>{e.default.updateToolbarButtonIcon(t)}).catch(t=>{})}getBlockElement(t){if(!t)return null;let e=t;for(;e&&e!==document.body;){if(e.nodeType===Node.ELEMENT_NODE){const t=e.tagName;if(["P","DIV","H1","H2","H3","H4","H5","H6","BLOCKQUOTE","LI"].includes(t))return e}e=e.parentNode}return null}destroy(){this.removeClickOutside(),this.popup&&this.popup.parentNode&&this.popup.parentNode.removeChild(this.popup)}}class at extends A{static formatName="text-align";static tagName="P";static attribute="style";constructor(){super();const t=S.getCurrentInstance();if(!t)return;this.editorId=t.instanceId;let e=t.getPopupInstance("text-align");e||(e=new st({onAlignSelect:t=>{at.applyAlignToCurrentSelection(t,this.editorId)},editor:t,editorId:this.editorId}),t.setPopupInstance("text-align",e)),this.alignPicker=e}static createForEditor(t){const e=S.getInstanceById(t);if(!e)return null;const i=S.currentInstance;S.currentInstance=e;const o=new at;return S.currentInstance=i,o}static create(t){const e=document.createElement(this.tagName);return t&&"left"!==t&&(e.style.textAlign=t),e}static applyAlignToCurrentSelection(t,e=null){let o=null;if(o=e?S.getInstanceById(e):S.getCurrentInstance(),!o)return;const n=window.getSelection();if(!n||!n.rangeCount)return;R();const r=n.getRangeAt(0),s=r.endContainer,a=r.endOffset;try{const o=n.getRangeAt(0),r=at.getSelectedBlockElements(o);if(0===r.length){i("formatBlock","p");const e=n.getRangeAt(0);at.getSelectedBlockElements(e).forEach(e=>{at.applyAlignmentToBlock(e,t)})}else r.forEach(e=>{at.applyAlignmentToBlock(e,t)});at.updateToolbarButtonIcon(t,e),n.removeAllRanges();const l=document.createRange();l.setStart(s,a),l.collapse(!0),n.addRange(l)}catch(t){}setTimeout(()=>{o&&"function"==typeof o.onContentChange&&o.onContentChange()},0)}static applyAlignmentToBlock(t,e){t.style.textAlign="left"===e?"":e}static getIconNameForAlignment(t){return{left:"align-left",center:"align-center",right:"align-right",justify:"align-justify"}[t]||"align-center"}static updateToolbarButtonIcon(t,e=null){let i=null;if(i=e?S.getInstanceById(e):S.getCurrentInstance(),!i)return;const o=i.getModule("toolbar");let n=null;if(o&&(n=o.getButton("text-align")),!n){const t=o?.getContainer();t&&(n=t.querySelector(".rich-editor-toolbar-btn.text-align-btn"))}if(n||(n=i.wrapper.querySelector(".rich-editor-toolbar-btn.text-align-btn")),!n)return;const r=at.getIconNameForAlignment(t);n.title={left:"Align Left",center:"Align Center",right:"Align Right",justify:"Justify"}[t]||"Text Alignment";const s=V.getIcon(r);if(s){const t=n.querySelector(".icon");t?t.innerHTML=s:n.innerHTML=`<span class="icon">${s}</span>`}}static getSelectedBlockElements(t){const e=[],i=at.getBlockElement(t.startContainer),o=at.getBlockElement(t.endContainer);if(!i||!o)return e;if(i===o)return e.push(i),e;let n=i;for(;n;){const i=document.createRange();if(i.selectNodeContents(n),t.compareBoundaryPoints(Range.END_TO_START,i)<0&&t.compareBoundaryPoints(Range.START_TO_END,i)>0&&e.push(n),n===o)break;n=at.getNextBlockElement(n)}return e}static getBlockElement(t){if(!t)return null;let e=t;for(;e&&e!==document.body;){if(e.nodeType===Node.ELEMENT_NODE){const t=e.tagName;if(["P","DIV","H1","H2","H3","H4","H5","H6","BLOCKQUOTE","LI"].includes(t))return e}e=e.parentNode}return null}static getNextBlockElement(t){let e=t.nextSibling;for(;e;){if(e.nodeType===Node.ELEMENT_NODE){const t=e.tagName;if(["P","DIV","H1","H2","H3","H4","H5","H6","BLOCKQUOTE","LI"].includes(t))return e}e=e.nextSibling}return null}apply(t="left"){at.applyAlignToCurrentSelection(t,this.editorId)}remove(){at.applyAlignToCurrentSelection("left",this.editorId)}toggle(){this.alignPicker.isVisible?this.alignPicker.hide():this.showAlignPicker()}showAlignPicker(){const t=S.getInstanceById(this.editorId);if(!t)return;const e=t.getModule("toolbar");let i=null;if(e&&(i=e.getButton("text-align")),!i){const t=e?.getContainer();t&&(i=t.querySelector(".rich-editor-toolbar-btn.text-align-btn"))}i||(i=t.wrapper.querySelector(".rich-editor-toolbar-btn.text-align-btn")),i&&this.alignPicker.show(i)}isActive(t=null){const e=at.getCurrentAlignment();return at.updateToolbarButtonIcon(e,this.editorId),!!e&&"left"!==e&&"start"!==e}static getCurrentAlignment(){const t=window.getSelection();if(!t||!t.rangeCount)return"left";try{const e=t.getRangeAt(0),i=at.getSelectedBlockElements(e),o=i.length>0?i[0]:at.getBlockElement(e.commonAncestorContainer);if(!o)return"left";const n=window.getComputedStyle(o).textAlign;return"left"!==n&&"start"!==n&&n?n:"left"}catch(t){return"left"}}}var lt=Object.freeze({__proto__:null,default:at});class ct{constructor(t={}){this.options={listTypes:[{value:"bullet",label:"Bullet List",icon:"list-bullet"},{value:"ordered",label:"Numbered List",icon:"list-ordered"},{value:"roman",label:"Roman Numerals List",icon:"list-roman"},{value:"alpha",label:"Alphabetical List",icon:"list-alpha"}],onListSelect:null,...t},this.popup=null,this.isVisible=!1,this.currentListType=null,this.clickOutsideHandler=null,this.createListPicker()}createListPicker(){this.popup=document.createElement("div"),this.popup.className="list-picker-popup",this.createListTypeButtons(),q(this.popup)}async createListTypeButtons(){const t=document.createElement("div");t.className="list-button-container";for(const e of this.options.listTypes){const i=document.createElement("button");i.type="button",i.className="list-button",i.dataset.listType=e.value,i.title=e.label;const o=V.getIcon(e.icon);o?i.innerHTML=o:i.textContent=e.label.charAt(0),i.addEventListener("click",t=>{t.preventDefault(),t.stopPropagation(),this.selectListType(e.value)}),t.appendChild(i)}this.popup.appendChild(t)}setupClickOutside(){this.clickOutsideHandler&&document.removeEventListener("click",this.clickOutsideHandler),this.clickOutsideHandler=t=>{this.popup.contains(t.target)||this.hide()},setTimeout(()=>{document.addEventListener("click",this.clickOutsideHandler)},100)}removeClickOutside(){this.clickOutsideHandler&&(document.removeEventListener("click",this.clickOutsideHandler),this.clickOutsideHandler=null)}show(t){if(!t)return;document.body.contains(this.popup)||q(this.popup),this.updateCurrentListType();const e=$(t,this.popup,{offsetY:5,offsetX:0});X(this.popup,e),this.popup.classList.add("visible"),this.isVisible=!0,this.setupClickOutside()}hide(){this.popup.classList.remove("visible"),this.isVisible=!1,this.removeClickOutside()}selectListType(t){this.currentListType=t,this.options.onListSelect&&this.options.onListSelect(t),this.hide()}updateCurrentListType(){try{const t=this.getCurrentListType();this.currentListType=t,this.updateButtonStates(t)}catch(t){}}updateButtonStates(t){this.popup.querySelectorAll(".list-button").forEach(e=>{e.classList.remove("active"),t&&e.dataset.listType===t&&e.classList.add("active")})}updateToolbarButtonIcon(t){const e=document.querySelector(".rich-editor-toolbar-btn.list-btn");if(!e)return;const i={bullet:"list-bullet",ordered:"list-ordered",roman:"list-roman",alpha:"list-alpha"}[t]||"list-bullet";e.title={bullet:"Bullet List",ordered:"Numbered List",roman:"Roman Numerals List",alpha:"Alphabetical List"}[t]||"List";const o=V.getIcon(i);if(o){const t=e.querySelector(".icon");t?t.innerHTML=o:e.innerHTML=`<span class="icon">${o}</span>`}}getParentList(t){let e=t;for(;e&&e!==document.body;){if("UL"===e.tagName||"OL"===e.tagName)return e;e=e.parentElement}return null}getListType(t){if("OL"===t.tagName){const e=t.style.listStyleType;return"upper-roman"===e?"roman":"lower-alpha"===e?"alpha":"ordered"}return"bullet"}getBlockElement(t){if(!t)return null;let e=t;for(;e&&e!==document.body;){if(e.nodeType===Node.ELEMENT_NODE){const t=e.tagName;if(["P","DIV","H1","H2","H3","H4","H5","H6","BLOCKQUOTE","LI","UL","OL"].includes(t))return e}e=e.parentNode}return null}getCurrentListType(){const t=window.getSelection();if(!t||!t.rangeCount)return null;const e=t.getRangeAt(0),i=this.getParentList(e.commonAncestorContainer);return i?this.getListType(i):null}destroy(){this.removeClickOutside(),this.popup&&this.popup.parentNode&&this.popup.parentNode.removeChild(this.popup),this.popup=null,this.isVisible=!1,this.currentListType=null}}class dt extends A{static formatName="list";static tagName="UL";static attribute="class";constructor(){super();const t=S.getCurrentInstance();if(!t)return;this.editorId=t.instanceId;let e=t.getPopupInstance("list");e||(e=new ct({onListSelect:t=>{dt.applyListToCurrentSelection(t,this.editorId)},editor:t,editorId:this.editorId}),t.setPopupInstance("list",e)),this.listPicker=e}static createForEditor(t){const e=S.getInstanceById(t);if(!e)return null;const i=S.currentInstance;S.currentInstance=e;const o=new dt;return S.currentInstance=i,o}static create(t){let e;switch(t){case"ordered":e=document.createElement("OL"),e.style.listStyleType="decimal";break;case"roman":e=document.createElement("OL"),e.style.listStyleType="upper-roman";break;case"alpha":e=document.createElement("OL"),e.style.listStyleType="lower-alpha";break;default:e=document.createElement("UL"),e.style.listStyleType="disc"}return e}static applyListToCurrentSelection(t,e=null){let i=null;if(i=e?S.getInstanceById(e):S.getCurrentInstance(),!i)return;const o=window.getSelection();if(o&&o.rangeCount){R();try{const i=o.getRangeAt(0),n=dt.getSelectedBlockElements(i);0===n.length?dt.createListFromSelection(t):dt.convertBlocksToList(n,t),dt.updateToolbarButtonIcon(t,e)}catch(t){}setTimeout(()=>{i&&"function"==typeof i.onContentChange&&i.onContentChange()},0)}}static createListFromSelection(t){const e=window.getSelection();if(!e||!e.rangeCount)return;const i=e.getRangeAt(0),o=i.toString()||"List item",n=dt.create(t),r=document.createElement("LI");if(i.toString()===i.cloneContents().textContent)r.textContent=o;else{const t=i.cloneContents();r.appendChild(t)}const s=dt.getBlockElement(i.startContainer);s&&s.style&&s.style.cssText&&(r.style.cssText=s.style.cssText),n.appendChild(r),i.deleteContents(),i.insertNode(n);const a=document.createRange();a.selectNodeContents(r),a.collapse(!1),e.removeAllRanges(),e.addRange(a)}static convertBlocksToList(t,e){if(0===t.length)return;const i=dt.getParentList(t[0]);if(i)return void dt.toggleOrChangeListType(i,e);const o=dt.create(e),n=t[0];n.parentNode.insertBefore(o,n);let r=null;if(t.forEach((t,e)=>{const i=document.createElement("LI");i.innerHTML=t.innerHTML||t.textContent||"",t.style&&t.style.cssText&&(i.style.cssText=t.style.cssText),o.appendChild(i),t.remove(),0===e&&(r=i)}),r){const t=document.createRange(),e=window.getSelection();t.selectNodeContents(r),t.collapse(!1),e.removeAllRanges(),e.addRange(t)}}static toggleOrChangeListType(t,e){dt.getListType(t)===e?dt.removeListFormatting(t):dt.changeListType(t,e)}static getListType(t){if("OL"===t.tagName){const e=t.style.listStyleType;return"upper-roman"===e?"roman":"lower-alpha"===e?"alpha":"ordered"}return"bullet"}static changeListType(t,e){const i=dt.create(e);if(Array.from(t.children).forEach(t=>{const e=document.createElement("LI");e.innerHTML=t.innerHTML||t.textContent||"",t.style&&t.style.cssText&&(e.style.cssText=t.style.cssText),i.appendChild(e)}),t.parentNode.replaceChild(i,t),i.firstElementChild){const t=document.createRange(),e=window.getSelection();t.selectNodeContents(i.firstElementChild),t.collapse(!1),e.removeAllRanges(),e.addRange(t)}}static removeListFormatting(t){const e=t.parentNode;let i=null;if(Array.from(t.children).forEach((o,n)=>{const r=document.createElement("P");r.innerHTML=o.innerHTML||o.textContent||"",o.style&&o.style.cssText&&(r.style.cssText=o.style.cssText),e.insertBefore(r,t),0===n&&(i=r)}),t.remove(),i){const t=document.createRange(),e=window.getSelection();t.selectNodeContents(i),t.collapse(!1),e.removeAllRanges(),e.addRange(t)}}static getParentList(t){let e=t;for(;e&&e!==document.body;){if("UL"===e.tagName||"OL"===e.tagName)return e;e=e.parentElement}return null}static getIconNameForListType(t){return{bullet:"list-bullet",ordered:"list-ordered",roman:"list-roman",alpha:"list-alpha"}[t]||"list-bullet"}static updateToolbarButtonIcon(t,e=null){let i=null;if(i=e?S.getInstanceById(e):S.getCurrentInstance(),!i)return;const o=i.getModule("toolbar");let n=null;if(o&&(n=o.getButton("list")),!n){const t=o?.getContainer();t&&(n=t.querySelector(".rich-editor-toolbar-btn.list-btn"))}if(n||(n=i.wrapper.querySelector(".rich-editor-toolbar-btn.list-btn")),!n)return;const r=dt.getIconNameForListType(t);n.title={bullet:"Bullet List",ordered:"Numbered List",roman:"Roman Numerals List",alpha:"Alphabetical List"}[t]||"List";const s=V.getIcon(r);if(s){const t=n.querySelector(".icon");t?t.innerHTML=s:n.innerHTML=`<span class="icon">${s}</span>`}}static getSelectedBlockElements(t){const e=[],i=t.startContainer,o=t.endContainer,n=dt.getBlockElement(i);if(n&&e.push(n),i!==o){let t=n;for(;t&&t!==o;){const i=dt.getNextBlockElement(t);if(!i||e.includes(i))break;e.push(i),t=i}const i=dt.getBlockElement(o);i&&!e.includes(i)&&e.push(i)}return e}static getBlockElement(t){if(!t)return null;let e=t;for(;e&&e!==document.body;){if(e.nodeType===Node.ELEMENT_NODE){const t=e.tagName;if(["P","DIV","H1","H2","H3","H4","H5","H6","BLOCKQUOTE","LI"].includes(t))return e}e=e.parentNode}return null}static getNextBlockElement(t){let e=t.nextSibling;for(;e;){if(e.nodeType===Node.ELEMENT_NODE){const t=e.tagName;if(["P","DIV","H1","H2","H3","H4","H5","H6","BLOCKQUOTE","LI"].includes(t))return e}e=e.nextSibling}return null}apply(t="bullet"){dt.applyListToCurrentSelection(t,this.editorId)}remove(){const t=window.getSelection();if(!t||!t.rangeCount)return;const e=t.getRangeAt(0),i=dt.getParentList(e.commonAncestorContainer);i&&dt.removeListFormatting(i)}toggle(){this.listPicker.isVisible?this.listPicker.hide():this.showListPicker()}showListPicker(){const t=S.getInstanceById(this.editorId);if(!t)return;const e=t.getModule("toolbar");let i=null;if(e&&(i=e.getButton("list")),!i){const t=e?.getContainer();t&&(i=t.querySelector(".rich-editor-toolbar-btn.list-btn"))}i||(i=t.wrapper.querySelector(".rich-editor-toolbar-btn.list-btn")),i&&this.listPicker.show(i)}isActive(t=null){const e=dt.getCurrentListType();return e?dt.updateToolbarButtonIcon(e,this.editorId):dt.updateToolbarButtonIcon("bullet",this.editorId),!!e}static getCurrentListType(){const t=window.getSelection();if(!t||!t.rangeCount)return null;const e=t.getRangeAt(0),i=dt.getParentList(e.commonAncestorContainer);return i?dt.getListType(i):null}getCurrentListType(){return dt.getCurrentListType()}}class ht extends A{static formatName="indent";static tagName="DIV";static attribute="style";constructor(){super()}static create(t){const e=document.createElement("DIV");return t&&(e.style.paddingLeft=t),e}static applyIndentToCurrentSelection(t){const e=window.getSelection();if(e&&e.rangeCount){R();try{const i=e.getRangeAt(0),o=ht.getSelectedBlockElements(i);if(0===o.length){const o=document.createElement("DIV");o.style.paddingLeft="increase"===t?"20px":"0px";const n=i.toString()||"";n?(o.textContent=n,i.deleteContents(),i.insertNode(o)):(i.insertNode(o),o.innerHTML="<br>");const r=document.createRange();r.selectNodeContents(o),r.collapse(!1),e.removeAllRanges(),e.addRange(r)}else o.forEach(e=>{ht.applyIndentToBlock(e,t)})}catch(t){}setTimeout(()=>{const t=S.getCurrentInstance();t&&"function"==typeof t.onContentChange&&t.onContentChange()},0)}}static applyIndentToBlock(t,e){if(!t||!t.style)return;const i=parseInt(t.style.paddingLeft)||0;let o;o="increase"===e?i+20:Math.max(0,i-20),t.style.paddingLeft=0===o?"":o+"px"}static getSelectedBlockElements(t){const e=[],i=t.startContainer,o=t.endContainer,n=ht.getBlockElement(i);if(n&&e.push(n),i!==o){let t=n;for(;t&&t!==o;){const i=ht.getNextBlockElement(t);if(!i||e.includes(i))break;e.push(i),t=i}const i=ht.getBlockElement(o);i&&!e.includes(i)&&e.push(i)}return e}static getBlockElement(t){if(!t)return null;let e=t;for(;e&&e!==document.body;){if(e.nodeType===Node.ELEMENT_NODE){const t=e.tagName;if(["P","DIV","H1","H2","H3","H4","H5","H6","BLOCKQUOTE","LI"].includes(t))return e}e=e.parentNode}return null}static getNextBlockElement(t){let e=t.nextSibling;for(;e;){if(e.nodeType===Node.ELEMENT_NODE){const t=e.tagName;if(["P","DIV","H1","H2","H3","H4","H5","H6","BLOCKQUOTE","LI"].includes(t))return e}e=e.nextSibling}return null}apply(t="increase"){ht.applyIndentToCurrentSelection(t)}remove(){ht.applyIndentToCurrentSelection("remove")}isActive(){const t=window.getSelection();if(!t||!t.rangeCount)return!1;const e=t.getRangeAt(0),i=ht.getBlockElement(e.commonAncestorContainer);if(!i)return!1;return(parseInt(i.style.paddingLeft)||0)>0}static getCurrentIndentLevel(){const t=window.getSelection();if(!t||!t.rangeCount)return 0;const e=t.getRangeAt(0),i=ht.getBlockElement(e.commonAncestorContainer);return i&&parseInt(i.style.paddingLeft)||0}getCurrentIndentLevel(){return ht.getCurrentIndentLevel()}}class pt extends ht{static formatName="indent-increase";apply(){ht.applyIndentToCurrentSelection("increase")}toggle(){this.apply()}isActive(){return!1}}class ut extends ht{static formatName="indent-decrease";apply(){ht.applyIndentToCurrentSelection("decrease")}toggle(){this.apply()}isActive(){return!1}}class mt{constructor(t={}){this.options={emojis:["😀","😁","😂","🤣","😃","😄","😅","😆","😉","😊","😋","😎","😍","🥰","😘","😗","😙","😚","🙂","🤗","😳","🥺","😦","😧","😨","😰","😥","😢","😭","😱","🤬","😈","👿","💀","☠️","💩","🤡","👹","👺","👻"],onEmojiSelect:null,...t},this.popup=null,this.isVisible=!1,this.clickOutsideHandler=null,this.createEmojiPicker()}detectOS(){const t=navigator.platform.toLowerCase();return t.includes("mac")?"mac":(t.includes("win"),"windows")}getEmojiShortcutMessage(){return"mac"===this.detectOS()?'<div style="color: rgb(113, 120, 124); font-style: normal; font-weight: 400; line-height: normal; text-align: center;">Get more emojis with <span style="border-radius: 2.2px; background: #EEE; padding: 2px 4px;">⌘</span> <span style="color: #000;">+</span> <span style="border-radius: 2.2px; background: #EEE; padding: 2px 4px;">CTRL</span> <span style="color: #000;">+</span> <span style="border-radius: 2.2px; background: #EEE; padding: 2px 4px;">SPACE</span></div>':'<div style="color: rgb(113, 120, 124); font-style: normal; font-weight: 400; line-height: normal; text-align: center;">Get more emojis with <span style="border-radius: 2.2px; background: #EEE; padding: 2px 4px;">WIN</span> <span style="color: #000;">+</span> <span style="border-radius: 2.2px; background: #EEE; padding: 2px 4px;">.</span></div>'}createEmojiPicker(){this.popup=document.createElement("div"),this.popup.className="emoji-picker-popup",this.createEmojiGrid();const t=document.createElement("div");t.className="emoji-text-message",t.innerHTML=this.getEmojiShortcutMessage(),this.popup.appendChild(t),q(this.popup)}createEmojiGrid(){const t=document.createElement("div");t.className="emoji-grid",this.options.emojis.forEach(e=>{const i=document.createElement("button");i.type="button",i.className="emoji-button",i.textContent=e,i.title=e,i.addEventListener("click",t=>{t.preventDefault(),t.stopPropagation(),this.selectEmoji(e)}),t.appendChild(i)}),this.popup.appendChild(t)}setupClickOutside(){this.clickOutsideHandler&&document.removeEventListener("click",this.clickOutsideHandler),this.clickOutsideHandler=t=>{this.popup.contains(t.target)||this.hide()},setTimeout(()=>{document.addEventListener("click",this.clickOutsideHandler)},100)}removeClickOutside(){this.clickOutsideHandler&&(document.removeEventListener("click",this.clickOutsideHandler),this.clickOutsideHandler=null)}show(t){if(!t)return;document.body.contains(this.popup)||q(this.popup);const e=$(t,this.popup,{offsetY:5,offsetX:0});X(this.popup,e),this.popup.classList.add("visible"),this.isVisible=!0,this.setupClickOutside()}hide(){this.popup.classList.remove("visible"),this.isVisible=!1,this.removeClickOutside()}selectEmoji(t){this.options.onEmojiSelect&&this.options.onEmojiSelect(t),this.hide()}destroy(){this.removeClickOutside(),this.popup&&this.popup.parentNode&&this.popup.parentNode.removeChild(this.popup),this.popup=null,this.isVisible=!1}}class gt extends L{static formatName="emoji";static tagName="SPAN";static className="emoji";constructor(){super();const t=S.getCurrentInstance();if(!t)return;this.editorId=t.instanceId;let e=t.getPopupInstance("emoji");e||(e=new mt({onEmojiSelect:t=>{gt.insertEmojiAtCurrentPosition(t,this.editorId)},editor:t,editorId:this.editorId}),t.setPopupInstance("emoji",e)),this.emojiPicker=e}static createForEditor(t){const e=S.getInstanceById(t);if(!e)return null;const i=S.currentInstance;S.currentInstance=e;const o=new gt;return S.currentInstance=i,o}static create(t){const e=document.createElement("SPAN");return e.className="emoji",e.textContent=t,e.setAttribute("data-emoji",t),e}static insertEmojiAtCurrentPosition(t,e=null){let i=null;if(i=e?S.getInstanceById(e):S.getCurrentInstance(),!i)return;const o=window.getSelection();if(o&&o.rangeCount)try{const e=o.getRangeAt(0);let n=e.startContainer,r=null;for(n.nodeType===Node.TEXT_NODE&&(n=n.parentNode);n&&n!==i.element;){if(n.classList&&n.classList.contains("emoji")){r=n;break}n=n.parentNode}r&&(e.setStartAfter(r),e.collapse(!0),o.removeAllRanges(),o.addRange(e));const s=gt.create(t);e.deleteContents(),e.insertNode(s);const a=document.createTextNode("​");e.setStartAfter(s),e.insertNode(a),e.setStartAfter(a),e.collapse(!0),o.removeAllRanges(),o.addRange(e),i&&"function"==typeof i.onContentChange&&i.onContentChange()}catch(t){}}apply(t){t?gt.insertEmojiAtCurrentPosition(t,this.editorId):this.showEmojiPicker()}remove(){const t=window.getSelection();if(!t||!t.rangeCount)return;const e=t.getRangeAt(0),i=this.getEmojiElement(e);if(i){const t=document.createTextNode(i.textContent);i.parentNode.replaceChild(t,i)}}toggle(){this.emojiPicker.isVisible?this.emojiPicker.hide():this.showEmojiPicker()}showEmojiPicker(){const t=S.getInstanceById(this.editorId);if(!t)return;const e=t.getModule("toolbar");let i=null;if(e&&(i=e.getButton("emoji")),!i){const t=e?.getContainer();t&&(i=t.querySelector(".rich-editor-toolbar-btn.emoji-btn"))}i||(i=t.wrapper.querySelector(".rich-editor-toolbar-btn.emoji-btn")),i&&this.emojiPicker.show(i)}isActive(){const t=window.getSelection();if(!t||!t.rangeCount)return!1;const e=t.getRangeAt(0);return null!==this.getEmojiElement(e)}getEmojiElement(t){let e=t.commonAncestorContainer;if(e.nodeType===Node.TEXT_NODE&&(e=e.parentNode),e.classList&&e.classList.contains("emoji"))return e;const i=t.cloneContents().querySelector(".emoji");return i||null}}class ft extends L{static formatName="image";static tagName="IMG";static className="inserted-image";constructor(){super();const t=S.getCurrentInstance();t&&(this.editorId=t.instanceId)}static createForEditor(t){const e=S.getInstanceById(t);if(!e)return null;const i=S.currentInstance;S.currentInstance=e;const o=new ft;return S.currentInstance=i,o}static create(t,e=""){if(!a(t,{allowDataImage:!0}))return null;const i=document.createElement("IMG");return i.src=t,i.alt=e||"Inserted image",i.className="inserted-image",i.style.maxWidth="100%",i.style.height="auto",i.setAttribute("contenteditable","false"),i}static insertImageAtCurrentPosition(t,e="",i=null){let o=null;if(o=i?S.getInstanceById(i):S.getCurrentInstance(),!o)return;const n=window.getSelection();if(n){if(!n.rangeCount||!o.editor.contains(n.anchorNode)){const t=document.createRange();t.selectNodeContents(o.editor),t.collapse(!1),n.removeAllRanges(),n.addRange(t)}try{const i=n.getRangeAt(0),r=ft.create(t,e);if(!r)return;i.deleteContents(),i.insertNode(r);const s=document.createTextNode(" ");i.setStartAfter(r),i.insertNode(s),i.setStartAfter(s),i.collapse(!0),n.removeAllRanges(),n.addRange(i),o&&"function"==typeof o.onContentChange&&o.onContentChange()}catch(t){}setTimeout(()=>{const t=S.getCurrentInstance();t&&"function"==typeof t.onContentChange&&t.onContentChange()},0)}}apply(t,e){t?ft.insertImageAtCurrentPosition(t,e,this.editorId):this.openFilePicker()}openFilePicker(){const t=S.getInstanceById(this.editorId);if(!t)return;const e=window.getSelection(),i=e&&e.rangeCount?e.getRangeAt(0).cloneRange():null,o=document.createElement("input");o.type="file",o.accept=t.options.image&&t.options.image.accept||"image/*",o.style.display="none",o.addEventListener("change",()=>{const e=o.files&&o.files[0];if(e){t.focus();const o=window.getSelection();if(i)o.removeAllRanges(),o.addRange(i);else if(!o.rangeCount||!t.editor.contains(o.anchorNode)){const e=document.createRange();e.selectNodeContents(t.editor),e.collapse(!1),o.removeAllRanges(),o.addRange(e)}t.insertImageFile(e)}o.remove()}),document.body.appendChild(o),o.click()}remove(){const t=window.getSelection();if(!t||!t.rangeCount)return;const e=t.getRangeAt(0),i=this.getImageElement(e);i&&i.remove()}toggle(){this.openFilePicker()}isActive(){const t=window.getSelection();if(!t||!t.rangeCount)return!1;const e=t.getRangeAt(0);return null!==this.getImageElement(e)}getImageElement(t){let e=t.commonAncestorContainer;if(e.nodeType===Node.TEXT_NODE&&(e=e.parentNode),"IMG"===e.tagName&&e.classList&&e.classList.contains("inserted-image"))return e;const i=t.cloneContents().querySelector(".inserted-image");return i||null}static async handleFileUpload(t){return new Promise((e,i)=>{if(!t||!t.type.startsWith("image/"))return void i(new Error("Please select a valid image file"));const o=new FileReader;o.onload=t=>{e(t.target.result)},o.onerror=()=>{i(new Error("Failed to read file"))},o.readAsDataURL(t)})}static validateImageUrl(t){return new Promise(e=>{const i=["jpg","jpeg","png","gif","bmp","webp","svg"].some(e=>t.toLowerCase().includes(`.${e}`));if(t.startsWith("data:image/"))return void e(!0);if(!/^https?:\/\//.test(t))return void e(!1);if(i)return void e(!0);const o=new ft;o.onload=()=>{e(!0)},o.onerror=()=>{t.includes("imgur.com")||t.includes("drive.google.com")||i?e(!0):e(!1)},setTimeout(()=>{i||t.includes("imgur.com")||t.includes("drive.google.com")?e(!0):e(!1)},5e3),o.src=t})}}var yt=Object.freeze({__proto__:null,default:ft});class bt{constructor(t={}){this.options={onVideoInsert:null,editor:null,...t},this.popup=null,this.isVisible=!1,this.clickOutsideHandler=null,this.selectedVideoSrc=null,this.savedSelection=null,this.createVideoPopup()}createVideoPopup(){this.popup=document.createElement("div"),this.popup.className="video-popup";const t=document.createElement("div");t.className="video-popup-content";const e=document.createElement("h3");e.textContent="Insert video",e.className="yjd-input-title",t.appendChild(e);const i=document.createElement("div");i.className="video-input-container";const o=document.createElement("p");o.textContent="Your video url",o.className="yjd-input-label";const n=document.createElement("div");n.className="yjd-input-upload-group",this.inputGroup=n,this.urlInput=document.createElement("input"),this.urlInput.type="url",this.urlInput.className="yjd-input",this.urlInput.placeholder="Please enter your video URL",this.urlInput.addEventListener("input",()=>{this.updateInsertButton();const t=this.urlInput.value.trim();t&&this.isValidVideoUrl(t)?this.showPreview(t):this.removePreview(),this.urlInput.value.trim()?this.customButton.style.display="none":this.customButton.style.display="block"}),this.fileInput=document.createElement("input"),this.fileInput.type="file",this.fileInput.accept="video/*",this.fileInput.className="image-input-hidden",this.fileInput.addEventListener("change",t=>this.handleFileSelect(t));const r=document.createElement("button");r.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="17 8 12 3 7 8"/><line x1="12" x2="12" y1="3" y2="15"/></svg>',r.className="yjd-custom-upload-button",this.customButton=r,r.addEventListener("click",()=>this.fileInput.click()),this.createPreviewContainer(),n.appendChild(this.urlInput),n.appendChild(this.fileInput),n.appendChild(r),i.appendChild(o),i.appendChild(n),i.appendChild(this.previewContainer),t.appendChild(i);const s=document.createElement("div");s.className="yjd-button-container";const a=document.createElement("button");a.type="button",a.className="image-button yjd-button-cancel",a.textContent="Cancel",a.addEventListener("click",()=>{this.hide(),this.options.editor&&setTimeout(()=>this.options.editor.focus(),0)}),this.insertButton=document.createElement("button"),this.insertButton.type="button",this.insertButton.className="image-button yjd-button-confirm button-disable",this.insertButton.textContent="Add video",this.insertButton.disabled=!0,this.insertButton.addEventListener("click",()=>{this.insertVideo(),this.options.editor&&setTimeout(()=>this.options.editor.focus(),0)}),s.appendChild(a),s.appendChild(this.insertButton),t.appendChild(s),this.popup.appendChild(t),q(this.popup),this.options.editor&&"function"==typeof this.options.editor.preventFocusLoss&&this.options.editor.preventFocusLoss(this.popup)}async handleFileSelect(t){const e=t.target.files[0];if(e)try{const{default:t}=await Promise.resolve().then(function(){return xt});this.selectedVideoSrc=await t.handleFileUpload(e),this.urlInput.value="",this.showPreview(this.selectedVideoSrc),this.updateInsertButton()}catch(t){alert(t.message)}}updateInsertButton(){const t=this.selectedVideoSrc||this.urlInput.value.trim();this.insertButton.disabled=!t,this.insertButton.classList.toggle("button-disable",!t)}showPreview(t){t&&(this.videoPreview.src=t,this.previewContainer.style.display="block",this.selectedVideoSrc=t,this.toggleInputGroup(!1),this.recalculatePosition())}removePreview(){this.selectedVideoSrc=null,this.previewContainer.style.display="none",this.videoPreview.src="",this.toggleInputGroup(!0),this.fileInput&&(this.fileInput.value=""),this.updateInsertButton(),this.recalculatePosition()}toggleInputGroup(t){this.inputGroup&&(t?(this.inputGroup.style.display="flex",this.inputGroup.style.visibility="visible",this.customButton&&(this.customButton.style.pointerEvents="auto")):(this.inputGroup.style.display="none",this.inputGroup.style.visibility="hidden"))}createPreviewContainer(){this.previewContainer=document.createElement("div"),this.previewContainer.className="video-preview-container",this.previewContainer.style.cssText="display: none; position: relative;",this.videoPreview=document.createElement("video"),this.videoPreview.className="video-preview",this.videoPreview.style.cssText="max-width: 100%; max-height: 200px; border-radius: 8px; object-fit: contain;",this.videoPreview.controls=!0,this.videoPreview.muted=!0,this.removeButton=document.createElement("button"),this.removeButton.className="video-remove-button",this.removeButton.innerHTML="×",this.removeButton.style.cssText="\n position: absolute; top: 5px; right: 5px; background: rgba(0,0,0,0.7);\n color: white; border: none; border-radius: 50%; width: 24px; height: 24px;\n cursor: pointer; font-size: 16px; font-weight: bold;\n ",this.removeButton.addEventListener("click",()=>this.removePreview()),this.previewContainer.appendChild(this.videoPreview),this.previewContainer.appendChild(this.removeButton)}isValidVideoUrl(t){try{const e=new URL(t),i=[".mp4",".webm",".ogg",".mov",".avi",".mkv"],o=["youtube.com","youtu.be","vimeo.com","dailymotion.com"],n=e.pathname.toLowerCase(),r=i.some(t=>n.endsWith(t)),s=o.some(t=>e.hostname.includes(t));return r||s}catch{return!1}}async insertVideo(){let t=this.selectedVideoSrc||this.urlInput.value.trim();if(t){try{const{default:e}=await Promise.resolve().then(function(){return xt});if(!await e.validateVideoUrl(t))return void alert("Invalid video URL. Please check the URL and try again.")}catch(t){return void alert("Error validating video URL.")}this.restoreSelection(),this.options.onVideoInsert&&this.options.onVideoInsert(t),this.hide(),this.reset()}}reset(){this.fileInput.value="",this.urlInput.value="",this.selectedVideoSrc=null,this.previewContainer.style.display="none",this.videoPreview.src="",this.toggleInputGroup(!0),this.updateInsertButton(),this.customButton.style.display="block"}saveSelection(){const t=window.getSelection();t&&t.rangeCount>0&&(this.savedSelection=t.getRangeAt(0).cloneRange())}restoreSelection(){if(this.savedSelection){const t=window.getSelection();t.removeAllRanges(),t.addRange(this.savedSelection)}}setupClickOutside(){this.clickOutsideHandler&&document.removeEventListener("click",this.clickOutsideHandler),this.clickOutsideHandler=t=>{this.popup.contains(t.target)||this.hide()},setTimeout(()=>{document.addEventListener("click",this.clickOutsideHandler)},100)}removeClickOutside(){this.clickOutsideHandler&&(document.removeEventListener("click",this.clickOutsideHandler),this.clickOutsideHandler=null)}show(t){if(!t)return;this.saveSelection(),this.reset(),this.currentAnchor=t;const e=$(t,this.popup,{offsetY:5,offsetX:0});X(this.popup,e),this.popup.classList.add("visible"),this.isVisible=!0,this.setupClickOutside()}recalculatePosition(){this.currentAnchor&&this.isVisible&&setTimeout(()=>{const t=$(this.currentAnchor,this.popup,{offsetY:5,offsetX:0});X(this.popup,t)},10)}hide(){this.popup.classList.remove("visible"),this.isVisible=!1,this.removeClickOutside(),this.savedSelection=null}destroy(){this.removeClickOutside(),this.popup&&this.popup.parentNode&&this.popup.parentNode.removeChild(this.popup),this.popup=null,this.isVisible=!1}}class vt extends L{static formatName="video";static tagName="VIDEO";static className="inserted-video";constructor(){super();const t=S.getCurrentInstance();if(!t)return;this.editorId=t.instanceId;let e=t.getPopupInstance("video");e||(e=new bt({onVideoInsert:t=>{vt.insertVideoAtCurrentPosition(t,this.editorId)},editor:t,editorId:this.editorId}),t.setPopupInstance("video",e)),this.videoPopup=e}static createForEditor(t){const e=S.getInstanceById(t);if(!e)return null;const i=S.currentInstance;S.currentInstance=e;const o=new vt;return S.currentInstance=i,o}static create(t){if(vt.isYouTubeUrl(t))return vt.createYouTubeEmbed(t);if(!a(t))return null;const e=document.createElement("VIDEO");return e.src=t,e.className="inserted-video",e.controls=!0,e.style.maxWidth="100%",e.style.height="auto",e.setAttribute("contenteditable","false"),e}static createYouTubeEmbed(t){const e=vt.getYouTubeVideoId(t);if(!e)throw new Error("Invalid YouTube URL");const i=document.createElement("IFRAME");return i.src=`https://www.youtube.com/embed/${e}`,i.className="inserted-video youtube-video",i.width="560",i.height="315",i.style.maxWidth="100%",i.style.width="560px",i.style.height="315px",i.style.position="relative",i.style.display="block",i.setAttribute("frameborder","0"),i.setAttribute("allowfullscreen",""),i.setAttribute("contenteditable","false"),i}static insertVideoAtCurrentPosition(t,e=null){let i=null;if(i=e?S.getInstanceById(e):S.getCurrentInstance(),!i)return;const o=window.getSelection();if(o&&o.rangeCount)try{const e=o.getRangeAt(0),n=vt.create(t);if(!n)return;e.deleteContents(),e.insertNode(n);const r=document.createTextNode(" ");e.setStartAfter(n),e.insertNode(r),e.setStartAfter(r),e.collapse(!0),o.removeAllRanges(),o.addRange(e),i&&"function"==typeof i.onContentChange&&i.onContentChange()}catch(t){}}apply(t){t?vt.insertVideoAtCurrentPosition(t,this.editorId):this.showVideoPopup()}remove(){const t=window.getSelection();if(!t||!t.rangeCount)return;const e=t.getRangeAt(0),i=this.getVideoElement(e);i&&i.remove()}toggle(){this.videoPopup.isVisible?this.videoPopup.hide():this.showVideoPopup()}showVideoPopup(){const t=S.getInstanceById(this.editorId);if(!t)return;const e=t.getModule("toolbar");let i=null;if(e&&(i=e.getButton("video")),!i){const t=e?.getContainer();t&&(i=t.querySelector(".rich-editor-toolbar-btn.video-btn"))}i||(i=t.wrapper.querySelector(".rich-editor-toolbar-btn.video-btn")),i&&this.videoPopup.show(i)}isActive(){const t=window.getSelection();if(!t||!t.rangeCount)return!1;const e=t.getRangeAt(0);return null!==this.getVideoElement(e)}getVideoElement(t){let e=t.commonAncestorContainer;if(e.nodeType===Node.TEXT_NODE&&(e=e.parentNode),("VIDEO"===e.tagName||"IFRAME"===e.tagName)&&e.classList&&e.classList.contains("inserted-video"))return e;const i=t.cloneContents().querySelector(".inserted-video");return i||null}static async handleFileUpload(t){return new Promise((e,i)=>{if(!t||!t.type.startsWith("video/"))return void i(new Error("Please select a valid video file"));const o=new FileReader;o.onload=t=>{e(t.target.result)},o.onerror=()=>{i(new Error("Failed to read file"))},o.readAsDataURL(t)})}static validateVideoUrl(t){return new Promise(e=>{if(vt.isYouTubeUrl(t))return void e(!0);if(["mp4","webm","ogg","mov","avi","mkv"].some(e=>t.toLowerCase().includes(`.${e}`)))return void e(!0);const i=document.createElement("video");i.onloadedmetadata=()=>{e(!0)},i.onerror=()=>{e(!1)},setTimeout(()=>{e(!1)},5e3),i.src=t})}static isYouTubeUrl(t){return/(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/watch\?v=|youtu\.be\/|youtube\.com\/embed\/)([a-zA-Z0-9_-]{11})/.test(t)}static getYouTubeVideoId(t){const e=t.match(/(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/watch\?v=|youtu\.be\/|youtube\.com\/embed\/)([a-zA-Z0-9_-]{11})/);return e?e[1]:null}}var xt=Object.freeze({__proto__:null,default:vt});class Ct{constructor(t={}){this.options={onTagInsert:null,editor:null,...t},this.popup=null,this.isVisible=!1,this.clickOutsideHandler=null,this.selectedTagType="mention",this.createTagPopup()}createTagPopup(){this.popup=document.createElement("div"),this.popup.className="tag-popup";const t=document.createElement("div");t.className="tag-popup-content";const e=document.createElement("h3");e.textContent="Insert tags",e.className="yjd-input-title",t.appendChild(e);const i=document.createElement("div");i.className="yjd-input-group";const o=document.createElement("label");o.textContent="Type",o.className="yjd-input-label",this.typeSelect=document.createElement("select"),this.typeSelect.className="yjd-select-input",this.typeSelect.innerHTML='\n <option value="mention">Mention</option>\n <option value="hashtag">Hashtag</option>\n <option value="custom">Custom</option>\n ',this.typeSelect.addEventListener("change",()=>this.updateSuggestions()),i.appendChild(o),i.appendChild(this.typeSelect),t.appendChild(i);const n=document.createElement("div");n.className="yjd-input-group";const r=document.createElement("label");r.textContent="Content",r.className="yjd-input-label",this.contentInput=document.createElement("input"),this.contentInput.type="text",this.contentInput.className="yjd-input",this.contentInput.placeholder="Please enter tag content",this.contentInput.addEventListener("input",()=>this.updateInsertButton()),this.contentInput.addEventListener("keydown",t=>{"Enter"===t.key&&(t.preventDefault(),this.insertTag())}),n.appendChild(r),n.appendChild(this.contentInput),t.appendChild(n);const s=document.createElement("div");s.className="yjd-input-group",this.suggestionsContainer=document.createElement("div"),this.suggestionsContainer.className="tag-suggestions-container";const a=document.createElement("label");a.textContent="Suggestions",a.className="yjd-input-label",this.suggestionsList=document.createElement("div"),this.suggestionsList.className="yjd-suggestions-list",this.suggestionsContainer.appendChild(this.suggestionsList),s.appendChild(a),s.appendChild(this.suggestionsContainer),t.appendChild(s);const l=document.createElement("div");l.className="yjd-button-container";const c=document.createElement("button");c.type="button",c.className="yjd-button-cancel",c.textContent="Cancel",c.addEventListener("click",()=>this.hide()),this.insertButton=document.createElement("button"),this.insertButton.type="button",this.insertButton.className="yjd-button-confirm",this.insertButton.textContent="Insert Tag",this.insertButton.disabled=!0,this.insertButton.addEventListener("click",()=>this.insertTag()),l.appendChild(c),l.appendChild(this.insertButton),t.appendChild(l),this.popup.appendChild(t),q(this.popup),this.options.editor&&"function"==typeof this.options.editor.preventFocusLoss&&this.options.editor.preventFocusLoss(this.popup),this.updateSuggestions()}updateSuggestions(){this.selectedTagType=this.typeSelect.value,this.suggestionsList.innerHTML="";this.getSuggestions(this.selectedTagType).forEach(t=>{const e=document.createElement("button");e.type="button",e.className="yjd-suggestion-button",e.textContent=t,e.addEventListener("click",()=>{this.contentInput.value=t,this.updateInsertButton(),this.contentInput.focus()}),this.suggestionsList.appendChild(e)})}getSuggestions(t){return{mention:["john","admin","team","support"],hashtag:["urgent","done","important"],custom:["warning","info","success"]}[t]||[]}updateInsertButton(){const t=this.contentInput.value.trim();this.insertButton.disabled=!t}insertTag(){const t=this.contentInput.value.trim();t&&(this.options.onTagInsert&&this.options.onTagInsert(this.selectedTagType,t),this.hide(),this.reset())}reset(){this.contentInput.value="",this.typeSelect.value="mention",this.selectedTagType="mention",this.updateInsertButton(),this.updateSuggestions()}setupClickOutside(){this.clickOutsideHandler&&document.removeEventListener("click",this.clickOutsideHandler),this.clickOutsideHandler=t=>{this.popup.contains(t.target)||this.hide()},setTimeout(()=>{document.addEventListener("click",this.clickOutsideHandler)},100)}removeClickOutside(){this.clickOutsideHandler&&(document.removeEventListener("click",this.clickOutsideHandler),this.clickOutsideHandler=null)}show(t){if(!t)return;const e=$(t,this.popup,{offsetY:5,offsetX:0});X(this.popup,e),this.popup.classList.add("visible"),this.isVisible=!0,this.setupClickOutside(),setTimeout(()=>{this.contentInput.focus()},100)}hide(){this.popup.classList.remove("visible"),this.isVisible=!1,this.removeClickOutside()}destroy(){this.removeClickOutside(),this.popup&&this.popup.parentNode&&this.popup.parentNode.removeChild(this.popup),this.popup=null,this.isVisible=!1}}class wt extends L{static formatName="tag";static tagName="SPAN";static className="custom-tag";static savedRanges=new Map;constructor(){super();const t=S.getCurrentInstance();if(!t)return;this.editorId=t.instanceId;let e=t.getPopupInstance("tag");e||(e=new Ct({onTagInsert:(t,e)=>{wt.insertTagAtCurrentPosition(t,e,this.editorId)},editor:t,editorId:this.editorId}),t.setPopupInstance("tag",e)),this.tagPopup=e}static createForEditor(t){const e=S.getInstanceById(t);if(!e)return null;const i=S.currentInstance;S.currentInstance=e;const o=new wt;return S.currentInstance=i,o}static create(t,e){const i=document.createElement("SPAN");i.className=`custom-tag tag-${t}`;let o=e;return"mention"===t?o=`@${e}`:"hashtag"===t?o=`#${e}`:"custom"===t&&(o=`<${e}>`),i.textContent=o,i.setAttribute("data-tag-type",t),i.setAttribute("data-tag-content",e),i.setAttribute("contenteditable","false"),i}static insertTagAtCurrentPosition(t,e,i=null){let o=null;if(o=i?S.getInstanceById(i):S.getCurrentInstance(),!o)return;const n=window.getSelection();if(n)try{const r=wt.savedRanges.get(i);if(r)n.removeAllRanges(),n.addRange(r),wt.savedRanges.delete(i);else if(!n.rangeCount)return;const s=n.getRangeAt(0),a=wt.create(t,e);s.deleteContents(),s.insertNode(a);const l=document.createTextNode(" ");s.setStartAfter(a),s.insertNode(l),s.setStartAfter(l),s.collapse(!0),n.removeAllRanges(),n.addRange(s),o&&o.element&&o.element.focus(),o&&"function"==typeof o.onContentChange&&o.onContentChange()}catch(t){}}apply(t,e){if(t&&e)wt.insertTagAtCurrentPosition(t,e,this.editorId);else{const t=window.getSelection();t&&t.rangeCount>0&&wt.savedRanges.set(this.editorId,t.getRangeAt(0).cloneRange()),this.showTagPopup()}}remove(){const t=window.getSelection();if(!t||!t.rangeCount)return;const e=t.getRangeAt(0),i=this.getTagElement(e);if(i){const t=document.createTextNode(i.textContent);i.parentNode.replaceChild(t,i)}}toggle(){if(this.tagPopup.isVisible)this.tagPopup.hide();else{const t=window.getSelection();t&&t.rangeCount>0&&wt.savedRanges.set(this.editorId,t.getRangeAt(0).cloneRange()),this.showTagPopup()}}showTagPopup(){const t=S.getInstanceById(this.editorId);if(!t)return;const e=t.getModule("toolbar");let i=null;if(e&&(i=e.getButton("tag")),!i){const t=e?.getContainer();t&&(i=t.querySelector(".rich-editor-toolbar-btn.tag-btn"))}i||(i=t.wrapper.querySelector(".rich-editor-toolbar-btn.tag-btn")),i&&this.tagPopup.show(i)}isActive(){const t=window.getSelection();if(!t||!t.rangeCount)return!1;const e=t.getRangeAt(0);return null!==this.getTagElement(e)}getTagElement(t){let e=t.commonAncestorContainer;if(e.nodeType===Node.TEXT_NODE&&(e=e.parentNode),e.classList&&e.classList.contains("custom-tag"))return e;return t.cloneContents().querySelector(".custom-tag")||null}static getSuggestions(t){return{mention:["john","sarah","admin","team","support"],hashtag:["urgent","todo","done","review","important"],custom:["note","warning","tip","info","success"]}[t]||[]}}class Et extends L{static formatName="textSize";static tagName="SPAN";constructor(){super();const t=S.getCurrentInstance();if(!t)return;this.editorId=t.instanceId;let e=t.getPopupInstance("text-size");if(!e){const i=Et.getSizeMap(),o=Object.values(i).map(t=>({value:t.size,label:t.element,title:t.title}));e=new et({items:o,displayProperty:"label",valueProperty:"value",className:"text-size-select",onItemSelect:t=>{Et.applyTextSizeToCurrentSelection(t,this.editorId)},editor:t,editorId:this.editorId}),t.setPopupInstance("text-size",e)}this.customSelect=e}static createForEditor(t){const e=S.getInstanceById(t);if(!e)return null;const i=S.currentInstance;S.currentInstance=e;const o=new Et;return S.currentInstance=i,o}static getSizeMap(){return{1:{size:"1",element:"<span >XX-Small</span>",title:"XX-Small"},2:{size:"2",element:"<span >X-Small</span>",title:"X-Small"},3:{size:"3",element:"<span >Small</span>",title:"Small"},4:{size:"4",element:"<span >Medium</span>",title:"Medium"},5:{size:"5",element:"<span >Large</span>",title:"Large"},6:{size:"6",element:"<span >X-Large</span>",title:"X-Large"},7:{size:"7",element:"<span >XX-Large</span>",title:"XX-Large"}}}static getSizeDisplayName(t){const e=this.getSizeMap();return e[t]?.title||"Medium"}updateButtonText(){const t=this.getCurrentSize(),e=Et.getSizeDisplayName(t||"4"),i=S.getInstanceById(this.editorId);if(!i)return;const o=i.getModule("toolbar");let n=null;if(o&&(n=o.getButton("text-size")),!n){const t=o?.getContainer();t&&(n=t.querySelector(".rich-editor-toolbar-btn.text-size-btn"))}n||(n=i.wrapper.querySelector(".rich-editor-toolbar-btn.text-size-btn")),n&&n.updateText?n.updateText(e):n&&(n.textContent=e)}static updateButtonTextStatic(t=null){let e=null;if(e=t?S.getInstanceById(t):S.getCurrentInstance(),!e)return;const i=Et.getCurrentSizeStatic(),o=Et.getSizeDisplayName(i||"4"),n=e.getModule("toolbar");let r=null;if(n&&(r=n.getButton("text-size")),!r){const t=n?.getContainer();t&&(r=t.querySelector(".rich-editor-toolbar-btn.text-size-btn"))}r||(r=e.wrapper.querySelector(".rich-editor-toolbar-btn.text-size-btn")),r&&r.updateText?r.updateText(o):r&&(r.textContent=o)}static create(t="4"){const e=document.createElement("span");return e.style.fontSize=Et.sizeToCss(t),e}static applyTextSizeToCurrentSelection(t,e=null){let i=null;if(i=e?S.getInstanceById(e):S.getCurrentInstance(),!i)return;const o=window.getSelection();if(!o||!o.rangeCount)return;R();const n=Et.createForEditor(e);n&&(n.apply(t),n.updateButtonText()),setTimeout(()=>{i&&"function"==typeof i.onContentChange&&i.onContentChange()},0)}static sizeToCss(t){return{1:"10px",2:"12px",3:"14px",4:"16px",5:"20px",6:"28px",7:"36px"}[String(t)]||"16px"}apply(t="4"){const e=window.getSelection();if(!e||!e.rangeCount)return;R();const o=e.getRangeAt(0);if(!o.collapsed){i("fontSize",String(t));const e=window.getSelection();if(e.rangeCount>0){const t=e.getRangeAt(0).commonAncestorContainer;t.nodeType===Node.TEXT_NODE?t.parentNode.normalize():t.normalize()}return}let n=o.startContainer;o.startOffset,n.nodeType===Node.TEXT_NODE&&(n=n.parentNode);const r=n.closest&&n.closest("font");if(r&&"​"===r.textContent)return void r.setAttribute("size",String(t));if(r&&r.firstChild&&r.firstChild.nodeType===Node.TEXT_NODE){const e=r.firstChild,i=o.startOffset,n=e.data.slice(0,i),s=e.data.slice(i),a=r.parentNode;if(0===i){const e=document.createElement("font");e.setAttribute("size",String(t)),e.appendChild(document.createTextNode("​")),a.insertBefore(e,r),l(e)}else if(i===e.data.length){const e=document.createElement("font");e.setAttribute("size",String(t)),e.appendChild(document.createTextNode("​")),a.insertBefore(e,r.nextSibling),l(e)}else{const e=document.createElement("font");e.setAttribute("size",r.getAttribute("size")),e.appendChild(document.createTextNode(n));const i=document.createElement("font");i.setAttribute("size",String(t)),i.appendChild(document.createTextNode("​"));const o=document.createElement("font");o.setAttribute("size",r.getAttribute("size")),o.appendChild(document.createTextNode(s)),a.insertBefore(e,r),a.insertBefore(i,r),a.insertBefore(o,r),a.removeChild(r),l(i)}return}const s=document.createElement("font");s.setAttribute("size",String(t));const a=document.createTextNode("​");function l(t){const e=window.getSelection(),i=document.createRange(),o=t.firstChild;i.setStart(o,o.length),i.collapse(!0),e.removeAllRanges(),e.addRange(i)}s.appendChild(a),o.insertNode(s),l(s)}async toggle(){this.customSelect.isVisible?this.customSelect.hide():await this.showSizePicker()}async showSizePicker(){const t=S.getInstanceById(this.editorId);if(!t)return;const e=t.getModule("toolbar");let i=null;if(e&&(i=e.getButton("text-size")),!i){const t=e?.getContainer();t&&(i=t.querySelector(".rich-editor-toolbar-btn.text-size-btn"))}if(i||(i=t.wrapper.querySelector(".rich-editor-toolbar-btn.text-size-btn")),!i)return;const o=this.getCurrentSize();o&&this.customSelect.setCurrentValue(o),await this.customSelect.show(i)}isActive(t=null){return this.updateButtonText(),!1}getCurrentSize(){return Et.getCurrentSizeStatic()}static getCurrentSizeStatic(){const t=window.getSelection();if(!t||!t.rangeCount)return"4";try{const t=function(t){try{return document.queryCommandValue(t)||""}catch(t){return""}}("fontSize"),e=parseInt(t,10);if(!isNaN(e)&&e>=1&&e<=7)return String(e)}catch(t){}let e=t.getRangeAt(0).startContainer;for(e.nodeType===Node.TEXT_NODE&&(e=e.parentElement);e&&e!==document.body;){if(e.nodeType===Node.ELEMENT_NODE){const t=e,i=t.style?.fontSize;if(i)return this.normalizeCssSizeToExecSize(i);const o=window.getComputedStyle(t).fontSize;if(o)return this.normalizeCssSizeToExecSize(o)}e=e.parentElement}return"4"}normalizeCssSizeToExecSize(t){const e=parseFloat(t);if(isNaN(e))return"4";const i=[10,12,14,16,20,28,36];let o=3,n=1/0;for(let t=0;t<i.length;t++){const r=Math.abs(e-i[t]);r<n&&(n=r,o=t)}return String(o+1)}}class kt{constructor(t={}){this.options={onImport:null,...t},this.popup=null,this.isVisible=!1,this.clickOutsideHandler=null,this.selectedFile=null,this.fileType=null,this.createImportPopup()}createImportPopup(){this.popup=document.createElement("div"),this.popup.className="import-popup";const t=document.createElement("div");t.className="import-popup-content";const e=document.createElement("h3");e.textContent="Import File",e.className="import-popup-title",t.appendChild(e);const i=document.createElement("div");i.className="import-type-container";const o=document.createElement("label");o.textContent="File Type:",o.className="import-input-label",this.typeSelect=document.createElement("select"),this.typeSelect.className="import-type-select",this.typeSelect.innerHTML='\n <option value="">Select file type...</option>\n <option value="html">HTML (.html, .htm)</option>\n <option value="excel">Excel/CSV (.csv, .xlsx, .xls)</option>\n <option value="pdf">PDF (.pdf)</option>\n <option value="word">Word (.doc, .docx)</option>\n ',this.typeSelect.addEventListener("change",()=>this.updateFileInput()),i.appendChild(o),i.appendChild(this.typeSelect),t.appendChild(i),this.fileInput=document.createElement("input"),this.fileInput.type="file",this.fileInput.className="import-file-input",this.fileInput.disabled=!0,this.fileInput.addEventListener("change",t=>this.handleFileSelect(t)),t.appendChild(this.fileInput),this.fileInfo=document.createElement("div"),this.fileInfo.className="import-file-info",this.fileInfo.style.display="none",t.appendChild(this.fileInfo);const n=document.createElement("div");n.className="import-button-container";const r=document.createElement("button");r.type="button",r.className="import-button cancel-button",r.textContent="Cancel",r.addEventListener("click",()=>this.hide()),this.importButton=document.createElement("button"),this.importButton.type="button",this.importButton.className="import-button import-button-main",this.importButton.textContent="Import",this.importButton.disabled=!0,this.importButton.addEventListener("click",()=>this.processImport()),n.appendChild(r),n.appendChild(this.importButton),t.appendChild(n),this.popup.appendChild(t),q(this.popup)}updateFileInput(){const t=this.typeSelect.value;if(t){this.fileType=t,this.fileInput.disabled=!1;const e=this.getAcceptTypes(t);this.fileInput.accept=e}else this.fileType=null,this.fileInput.disabled=!0,this.fileInput.accept="";this.updateImportButton()}getAcceptTypes(t){return{html:".html,.htm,text/html",excel:".csv,.xlsx,.xls,text/csv",pdf:".pdf,application/pdf",word:".doc,.docx"}[t]||""}handleFileSelect(t){const e=t.target.files[0];e&&this.setSelectedFile(e)}setSelectedFile(t){this.selectedFile=t,this.fileInfo.style.display="block",this.fileInfo.innerHTML=`\n <div><strong>Name:</strong> ${t.name}</div>\n <div><strong>Size:</strong> ${this.formatFileSize(t.size)}</div>\n <div><strong>Type:</strong> ${t.type||"Unknown"}</div>\n `,this.updateImportButton()}formatFileSize(t){if(0===t)return"0 Bytes";const e=Math.floor(Math.log(t)/Math.log(1024));return parseFloat((t/Math.pow(1024,e)).toFixed(2))+" "+["Bytes","KB","MB","GB"][e]}updateImportButton(){this.importButton.disabled=!this.selectedFile||!this.fileType}async processImport(){if(this.selectedFile&&this.fileType)try{let t;if("html"===this.fileType)t=await this.readAsText(this.selectedFile);else if("excel"===this.fileType){if(!this.selectedFile.name.toLowerCase().endsWith(".csv"))return void alert("Excel files (.xlsx/.xls) require additional libraries. Please use CSV format.");{const e=await this.readAsText(this.selectedFile);t=this.parseCSV(e)}}else{if("pdf"===this.fileType)return void alert("PDF import requires additional libraries. Feature coming soon.");if("word"===this.fileType)return void alert("Word document import requires additional libraries. Feature coming soon.")}this.options.onImport&&this.options.onImport(t,this.fileType),this.hide(),this.reset()}catch(t){alert("Error importing file: "+t.message)}}parseCSV(t){const e=t.split("\n"),i=[];return e.forEach(t=>{if(t.trim()){const e=t.split(",").map(t=>t.trim().replace(/^["']|["']$/g,""));i.push(e)}}),i}readAsText(t){return new Promise((e,i)=>{const o=new FileReader;o.onload=t=>e(t.target.result),o.onerror=()=>i(new Error("Failed to read file")),o.readAsText(t)})}reset(){this.selectedFile=null,this.fileType=null,this.typeSelect.value="",this.fileInput.value="",this.fileInput.disabled=!0,this.fileInfo.style.display="none",this.updateImportButton()}setupClickOutside(){this.clickOutsideHandler&&document.removeEventListener("click",this.clickOutsideHandler),this.clickOutsideHandler=t=>{this.popup.contains(t.target)||this.hide()},setTimeout(()=>{document.addEventListener("click",this.clickOutsideHandler)},100)}removeClickOutside(){this.clickOutsideHandler&&(document.removeEventListener("click",this.clickOutsideHandler),this.clickOutsideHandler=null)}show(t){if(!t)return;const e=$(t,this.popup,{offsetY:5,offsetX:0});X(this.popup,e),this.popup.classList.add("visible"),this.isVisible=!0,this.setupClickOutside()}hide(){this.popup.classList.remove("visible"),this.isVisible=!1,this.removeClickOutside()}destroy(){this.removeClickOutside(),this.popup&&this.popup.parentNode&&this.popup.parentNode.removeChild(this.popup),this.popup=null,this.isVisible=!1}}class jt extends L{static formatName="import";static tagName="DIV";static className="imported-content";constructor(){super();const t=S.getCurrentInstance();if(!t)return;this.editorId=t.instanceId;let e=t.getPopupInstance("import");e||(e=new kt({onImport:(t,e)=>{jt.insertImportedContent(t,e,this.editorId)},editor:t,editorId:this.editorId}),t.setPopupInstance("import",e)),this.importPopup=e}static createForEditor(t){const e=S.getInstanceById(t);if(!e)return null;const i=S.currentInstance;S.currentInstance=e;const o=new jt;return S.currentInstance=i,o}static insertImportedContent(t,e,i=null){let o=null;if(o=i?S.getInstanceById(i):S.getCurrentInstance(),!o)return;const n=window.getSelection();if(n&&n.rangeCount)try{const i=n.getRangeAt(0);let r;r="html"===e?jt.processHtmlContent(t):"excel"===e?jt.processExcelContent(t):jt.processTextContent(t),i.deleteContents(),i.insertNode(r),i.setStartAfter(r),i.collapse(!0),n.removeAllRanges(),n.addRange(i),o&&"function"==typeof o.onContentChange&&o.onContentChange()}catch(t){}}static processHtmlContent(t){const e=document.createElement("div");return e.className="imported-content html-content",e.innerHTML=d(t),jt.cleanHtmlContent(e),e}static processExcelContent(t){const e=document.createElement("div");if(e.className="imported-content excel-content",!Array.isArray(t)||0===t.length)return e.textContent="No data to import",e;const i=document.createElement("table");if(i.className="imported-table",t.length>0){const e=document.createElement("thead"),o=document.createElement("tr");t[0].forEach(t=>{const e=document.createElement("th");e.textContent=t||"",o.appendChild(e)}),e.appendChild(o),i.appendChild(e)}if(t.length>1){const e=document.createElement("tbody");for(let i=1;i<t.length;i++){const o=document.createElement("tr");t[i].forEach(t=>{const e=document.createElement("td");e.textContent=t||"",o.appendChild(e)}),e.appendChild(o)}i.appendChild(e)}return e.appendChild(i),e}static processTextContent(t){const e=document.createElement("div");e.className="imported-content text-content";return t.split(/\n\s*\n/).forEach(t=>{if(t.trim()){const i=document.createElement("p");i.textContent=t.trim(),e.appendChild(i)}}),e}static cleanHtmlContent(t){const e=["p","div","span","h1","h2","h3","h4","h5","h6","strong","b","em","i","u","ul","ol","li","br","table","thead","tbody","tr","th","td"],i=["class","style"],o=document.createTreeWalker(t,NodeFilter.SHOW_ELEMENT,null,!1),n=[];for(;o.nextNode();){const t=o.currentNode;if(!e.includes(t.tagName.toLowerCase())){n.push(t);continue}Array.from(t.attributes).forEach(e=>{i.includes(e.name.toLowerCase())||t.removeAttribute(e.name)})}n.forEach(t=>{t.parentNode&&t.parentNode.removeChild(t)})}static parseCSV(t){const e=t.split("\n"),i=[];return e.forEach(t=>{if(t.trim()){const e=t.split(",").map(t=>t.trim().replace(/^["']|["']$/g,""));i.push(e)}}),i}apply(){this.showImportPopup()}toggle(){this.importPopup.isVisible?this.importPopup.hide():this.showImportPopup()}showImportPopup(){const t=S.getInstanceById(this.editorId);if(!t)return;const e=t.getModule("toolbar");let i=null;if(e&&(i=e.getButton("import")),!i){const t=e?.getContainer();t&&(i=t.querySelector(".rich-editor-toolbar-btn.import-btn"))}i||(i=t.wrapper.querySelector(".rich-editor-toolbar-btn.import-btn")),i&&this.importPopup.show(i)}isActive(){return!1}static getSupportedTypes(){return{html:{extensions:[".html",".htm"],mimeTypes:["text/html"],name:"HTML Files"},excel:{extensions:[".csv",".xlsx",".xls"],mimeTypes:["text/csv","application/vnd.ms-excel","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"],name:"Excel Files"},pdf:{extensions:[".pdf"],mimeTypes:["application/pdf"],name:"PDF Files"},word:{extensions:[".doc",".docx"],mimeTypes:["application/msword","application/vnd.openxmlformats-officedocument.wordprocessingml.document"],name:"Word Documents"}}}}function Tt(t="Button",e={}){const{width:i="auto",icon:o=null}=e,n=document.createElement("button");if(n.type="button",n.className="custom-select-button",o){const t=V.createIconElement(o);t.className="select-lead-icon",n.appendChild(t)}const r=document.createElement("span");r.textContent=t,r.className="button-text";const s=V.createIconElement("dropdown");return s.className="dropdown-icon",n.appendChild(r),n.appendChild(s),n.style.width=i,n.style.padding="0px 5px 0px 8px",n.style.setProperty("height","32px","important"),n.style.setProperty("borderRadius","6px","important"),n.style.setProperty("alignItems","center","important"),n.style.fontSize="14px",n.style.fontWeight="400",n.style.color="#374151",n.style.background="#FFFFFF",n.style.cursor="pointer",n.style.border="1px solid #d1d5db",n.style.display="flex",n.style.justifyContent="space-between",n.style.alignItems="center",r.style.flex="1",r.style.textAlign="left",n.updateText=function(t){r.textContent=t},n}class It extends e{static DEFAULTS={container:null,toolbar1:[{group:"text-format",items:["bold","italic","underline","strike"]},{group:"paragraph",items:["heading"]},{group:"colors",items:["color","background"]},{group:"link",items:["link"]},{group:"paragraph-ops",items:["list","indent-increase","indent-decrease","text-align"]},{group:"insert",items:["image","table"]},{group:"history",items:["undo","redo"]},{group:"more",items:["more"]}],toolbar2:[{group:"font",items:["font-family","text-size","line-height"]},{group:"script",items:["subscript","superscript","capitalization"]},{group:"media",items:["emoji","video","tag","horizontal-rule"]},{group:"tools",items:["clear-format","text-direction","find","code-view"]}]};constructor(t,e={}){super(t,e),this.buttons=new Map,this.toolbar2Visible=!1,this.events=new Map,Array.isArray(e.toolbar)?this.options={container:null,toolbar1:[{group:"text-format",items:e.toolbar}],toolbar2:[]}:e.toolbar1||e.toolbar2?this.options={container:null,toolbar1:e.toolbar1||[],toolbar2:e.toolbar2||[]}:this.options={...It.DEFAULTS,...e},this.init(),this.preloadIcons()}init(){this.container=this.createToolbarContainer()}async preloadIcons(){}createToolbarContainer(){const t=document.createElement("div");t.className="rich-editor-toolbar-container",t.setAttribute("role","toolbar"),t.setAttribute("aria-label","Text formatting"),this.editor.preventFocusLoss(t),t.addEventListener("pointerdown",t=>{t.target.closest("button")&&t.preventDefault()}),this.toolbar1=document.createElement("div"),this.toolbar1.className="rich-editor-toolbar-1",this.toolbar2=document.createElement("div"),this.toolbar2.className="rich-editor-toolbar-2",this.toolbar2.style.display="none",this.flowGroups=[];return[...this.options.toolbar1||[],...this.options.toolbar2||[]].forEach(t=>{if(!t||!t.group||!Array.isArray(t.items))return;if(1===t.items.length&&"more"===t.items[0])return;const e=document.createElement("div");e.className=`toolbar-group toolbar-group-${t.group}`,t.items.forEach(t=>{"string"==typeof t&&this.addButton(e,t)}),this.toolbar1.appendChild(e),this.flowGroups.push(e)}),this.addMoreButton(this.toolbar1),this.moreBtn=this.buttons.get("more"),this.moreBtn&&this.moreBtn.classList.add("more-btn"),t.appendChild(this.toolbar1),t.appendChild(this.toolbar2),"undefined"!=typeof ResizeObserver&&(this._ro=new ResizeObserver(()=>this._scheduleReflow()),this._ro.observe(t)),requestAnimationFrame(()=>this.reflow()),this._setupKeyboardNav(t),t}_focusableButtons(){return Array.from(this.container.querySelectorAll(".rich-editor-toolbar-btn, .custom-select-button")).filter(t=>!t.disabled&&null!==t.offsetParent)}_updateRoving(){this._focusableButtons().forEach((t,e)=>{t.tabIndex=0===e?0:-1})}_setupKeyboardNav(t){t.addEventListener("keydown",t=>{if(!["ArrowLeft","ArrowRight","Home","End"].includes(t.key))return;const e=this._focusableButtons();if(!e.length)return;const i=e.indexOf(document.activeElement);let o;o="Home"===t.key?0:"End"===t.key?e.length-1:-1===i?0:"ArrowRight"===t.key?(i+1)%e.length:(i-1+e.length)%e.length,t.preventDefault(),e.forEach(t=>{t.tabIndex=-1}),e[o].tabIndex=0,e[o].focus()})}_scheduleReflow(){this._reflowQueued||(this._reflowQueued=!0,requestAnimationFrame(()=>{this._reflowQueued=!1,this.reflow()}))}reflow(){if(!this.toolbar1||!this.flowGroups||!this.moreBtn)return;if(this.flowGroups.forEach(t=>this.toolbar1.insertBefore(t,this.moreBtn)),"undefined"!=typeof window&&window.matchMedia&&window.matchMedia("(max-width: 640px)").matches)return this.moreBtn.style.display="none",this.toolbar2.style.display="none",this.toolbar2Visible=!1,this._syncMoreButton(),void this._updateRoving();const t=getComputedStyle(this.toolbar1),e=this.toolbar1.clientWidth-(parseFloat(t.paddingLeft)||0)-(parseFloat(t.paddingRight)||0);if(e<=0)return;let i=0;if(this.flowGroups.forEach((t,e)=>{i+=t.offsetWidth+(e>0?12:0)}),i<=e)return this.moreBtn.style.display="none",this.toolbar2.style.display="none",this.toolbar2Visible=!1,this._syncMoreButton(),void this._updateRoving();const o=e-((this.moreBtn.offsetWidth||32)+12);let n=0,r=this.flowGroups.length;for(let t=0;t<this.flowGroups.length;t++){const e=this.flowGroups[t].offsetWidth+(t>0?12:0);if(n+e>o){r=t;break}n+=e}r<1&&(r=1);for(let t=r;t<this.flowGroups.length;t++)this.toolbar2.appendChild(this.flowGroups[t]);this.moreBtn.style.display="",this.toolbar2.style.display=this.toolbar2Visible?"flex":"none",this._syncMoreButton(),this._updateRoving()}_syncMoreButton(){const t=this.moreBtn;t&&(t.setAttribute("aria-expanded",this.toolbar2Visible?"true":"false"),this.toolbar2Visible?(t.classList.add("active"),t.title="Hide more options"):(t.classList.remove("active"),t.title="More options"))}createToolbar(t,e){const i=document.createElement("div");return i.className=t,Array.isArray(e)&&e.forEach(t=>{if(t&&t.group&&Array.isArray(t.items)){const e=document.createElement("div");e.className=`toolbar-group toolbar-group-${t.group}`,t.items.forEach(t=>{"string"==typeof t&&this.addButton(e,t)}),i.appendChild(e)}}),i}addButton(t,e){if("more"===e)return this.addMoreButton(t);const i={heading:{text:"Paragraph",width:"124px",title:"Paragraph style",icon:"heading"},"font-family":{text:"Font Family",width:"156px",title:"Font",icon:"font-family"},"line-height":{text:"Line Height",width:"116px",title:"Line spacing",icon:"line-height"},capitalization:{text:"Capitalization",width:"146px",title:"Letter case",icon:"capitalization"},"text-size":{text:"Text Size",width:"116px",title:"Font size",icon:"text-size"}};if(i[e]){const o=i[e],n=Tt(o.text,{width:o.width,icon:o.icon});return n.dataset.command=e,n.classList.add("rich-editor-toolbar-btn",`${e}-btn`),n.title=o.title,n.setAttribute("aria-label",o.title),n.setAttribute("aria-haspopup","true"),n.addEventListener("click",t=>{t.preventDefault(),this.emit("toolbar-click",{command:e,button:n}),setTimeout(()=>{this.editor.focus()},0)}),this.buttons.set(e,n),t.appendChild(n),n}const o={"text-align":{icon:"align-left",title:"Align Left"},list:{icon:"list",title:"List"}};if(o[e]){const i=o[e],n=document.createElement("button");n.type="button",n.className=`rich-editor-toolbar-btn ${e}-btn`,n.dataset.command=e,n.title=i.title,n.setAttribute("aria-label",i.title);const r=V.getIcon(i.icon);return r?n.innerHTML=`<span class="icon">${r}</span>`:n.textContent="text-align"===e?"≡":"•",n.addEventListener("click",t=>{t.preventDefault(),this.emit("toolbar-click",{command:e,button:n}),setTimeout(()=>{this.editor.focus()},0)}),this.buttons.set(e,n),t.appendChild(n),n}const n=document.createElement("button");n.type="button",n.className=`rich-editor-toolbar-btn ${e}-btn`,n.dataset.command=e;const r=V.createIconElement(e,{width:"16px",height:"16px"});n.appendChild(r);if(n.title={bold:"Bold (Ctrl+B)",italic:"Italic (Ctrl+I)",underline:"Underline (Ctrl+U)",strike:"Strikethrough",subscript:"Subscript",superscript:"Superscript",color:"Text Color",background:"Background Color",link:"Insert/Edit Link",table:"Insert Table",undo:"Undo (Ctrl+Z)",redo:"Redo (Ctrl+Y)","indent-increase":"Increase Indent","indent-decrease":"Decrease Indent",emoji:"Insert Emoji",image:"Insert Image",video:"Insert Video",tag:"Insert Tag","horizontal-rule":"Insert Horizontal Rule","clear-format":"Clear Formatting","text-direction":"Toggle Text Direction (LTR/RTL)",find:"Find & Replace (Ctrl+F)",import:"Import Files","code-view":"Switch to HTML Editor"}[e]||e,n.setAttribute("aria-label",n.title),"color"===e||"background"===e){const t=document.createElement("span");t.className="rte-swatch",n.appendChild(t)}return"code-view"===e&&setTimeout(()=>{r.innerHTML.trim()||(r.innerHTML="&lt;/&gt;",r.style.fontSize="12px",r.style.fontWeight="bold")},1e3),n.addEventListener("click",t=>{t.preventDefault(),this.emit("toolbar-click",{command:e,button:n}),setTimeout(()=>{this.editor.focus()},0)}),this.buttons.set(e,n),t.appendChild(n),n}addMoreButton(t){const e=document.createElement("button");e.type="button",e.className="rich-editor-toolbar-btn more-btn",e.dataset.command="more";const i=V.createIconElement("more",{width:"16px",height:"16px"});return e.appendChild(i),e.title="More Options",e.setAttribute("aria-label","More Options"),e.setAttribute("aria-expanded","false"),e.addEventListener("click",t=>{t.preventDefault(),this.toggleToolbar2(),setTimeout(()=>{this.editor.focus()},0)}),this.buttons.set("more",e),t.appendChild(e),e}toggleToolbar2(){this.moreBtn&&"none"===this.moreBtn.style.display||(this.toolbar2Visible=!this.toolbar2Visible,this.toolbar2.style.display=this.toolbar2Visible?"flex":"none",this._syncMoreButton(),this._updateRoving())}getContainer(){return this.container}getButton(t){return this.buttons.get(t)}setButtonActive(t,e){const i=this.buttons.get(t);i&&i.classList&&(e?i.classList.add("active"):i.classList.remove("active"),i.setAttribute("aria-pressed",e?"true":"false"))}setButtonDisabled(t,e){const i=this.buttons.get(t);i&&(i.disabled=e,i.style.opacity=e?"0.5":"1",i.style.cursor=e?"not-allowed":"pointer")}setButtonTitle(t,e){const i=this.buttons.get(t);i&&(i.title=e)}isToolbar2Visible(){return this.toolbar2Visible}on(t,e){this.events.has(t)||this.events.set(t,[]),this.events.get(t).push(e)}emit(t,e){const i=this.events.get(t);i&&i.forEach(t=>{try{t(e)}catch(t){}})}destroy(){this._ro&&(this._ro.disconnect(),this._ro=null),this.container&&this.container.parentNode&&this.container.parentNode.removeChild(this.container),this.buttons.clear(),this.events.clear()}}class St extends e{static DEFAULTS={delay:1e3,maxStack:100,userOnly:!1};constructor(t,e={}){super(t,e),this.stack=[],this.index=-1,this.lastSave=0,this.savedSelection=null,this.init()}init(){this.setupEventListeners(),this.saveState()}setupEventListeners(){this._onInput=()=>{this.handleInput()},this._onKeydownSave=t=>{"Enter"!==t.key&&"Backspace"!==t.key&&"Delete"!==t.key||this.saveState()},this._onToolbarClick=t=>{t.target.closest(".rich-editor-toolbar-btn")&&setTimeout(()=>{this.saveState()},0)},this._onUndoRedo=t=>{!t.ctrlKey&&!t.metaKey||t.shiftKey||"z"!==t.key?((t.ctrlKey||t.metaKey)&&t.shiftKey&&"z"===t.key||(t.ctrlKey||t.metaKey)&&"y"===t.key)&&(t.preventDefault(),this.redo()):(t.preventDefault(),this.undo())},this.editor.editor.addEventListener("input",this._onInput),this.editor.editor.addEventListener("keydown",this._onKeydownSave),this.editor.wrapper.addEventListener("click",this._onToolbarClick),this.editor.editor.addEventListener("keydown",this._onUndoRedo),this.setupMutationObserver()}setupMutationObserver(){this.mutationObserver=new MutationObserver(t=>{let e=!1;for(const i of t)if("childList"===i.type||"attributes"===i.type&&(i.target.nodeType===Node.TEXT_NODE||["P","DIV","H1","H2","H3","H4","H5","H6","BLOCKQUOTE","PRE","UL","OL","LI","SPAN","STRONG","EM","U","S","SUB","SUP","A","IMG","VIDEO","TABLE","TR","TD","TH"].includes(i.target.tagName))){e=!0;break}e&&(clearTimeout(this.mutationTimeout),this.mutationTimeout=setTimeout(()=>{this.saveState()},100))}),this.mutationObserver.observe(this.editor.editor,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["style","class","href","src","alt","title"]})}handleInput(){const t=Date.now();t-this.lastSave>this.options.delay&&(this.saveState(),this.lastSave=t)}saveState(){const t=this.editor.getContent(),e=this.saveSelection();if(this.stack.length>0&&this.stack[this.index]?.content===t)return;const i=Date.now();this.lastSave&&i-this.lastSave<50||(this.index<this.stack.length-1&&this.stack.splice(this.index+1),this.stack.push({content:t,selection:e,timestamp:i}),this.stack.length>this.options.maxStack?this.stack.shift():this.index++,this.lastSave=i)}undo(){if(!this.canUndo())return!1;this.index--;const t=this.stack[this.index];return this.restoreState(t),this.onHistoryChange("undo"),!0}redo(){if(!this.canRedo())return!1;this.index++;const t=this.stack[this.index];return this.restoreState(t),this.onHistoryChange("redo"),!0}canUndo(){return this.index>0}canRedo(){return this.index<this.stack.length-1}restoreState(t){t&&(this.editor.setContent(t.content),t.selection&&setTimeout(()=>{this.restoreSelection(t.selection)},10))}saveSelection(){const t=window.getSelection();if(!t||!t.rangeCount)return null;const e=t.getRangeAt(0),i=this.editor.editor;return{startOffset:this.getOffsetInEditor(e.startContainer,e.startOffset,i),endOffset:this.getOffsetInEditor(e.endContainer,e.endOffset,i),collapsed:e.collapsed}}restoreSelection(t){if(!t)return;const e=this.editor.editor,i=document.createRange(),o=window.getSelection();try{const n=this.getNodeAtOffset(e,t.startOffset),r=this.getNodeAtOffset(e,t.endOffset);n&&r&&(i.setStart(n.node,n.offset),i.setEnd(r.node,r.offset),o.removeAllRanges(),o.addRange(i))}catch(t){this.editor.focus()}}getOffsetInEditor(t,e,i){let o=0;const n=document.createTreeWalker(i,NodeFilter.SHOW_TEXT,null,!1);let r;for(;r=n.nextNode();){if(r===t)return o+e;o+=r.textContent.length}return o}getNodeAtOffset(t,e){let i=0;const o=document.createTreeWalker(t,NodeFilter.SHOW_TEXT,null,!1);let n;for(;n=o.nextNode();){const t=n.textContent.length;if(i+t>=e)return{node:n,offset:e-i};i+=t}return{node:t.lastChild||t,offset:0}}clear(){this.stack=[],this.index=-1,this.saveState()}getState(){return{canUndo:this.canUndo(),canRedo:this.canRedo(),stackLength:this.stack.length,currentIndex:this.index}}onHistoryChange(t){this.editor.modules.forEach(e=>{e!==this&&"function"==typeof e.onHistoryChange&&e.onHistoryChange(t,this.getState())});const e=new CustomEvent("historychange",{detail:{action:t,state:this.getState()}});this.editor.editor.dispatchEvent(e)}forceSave(){const t=this.lastSave;this.lastSave=0,this.saveState(),this.lastSave=t}saveBeforeFormat(){this.forceSave()}destroy(){this._onInput&&(this.editor.editor.removeEventListener("input",this._onInput),this.editor.editor.removeEventListener("keydown",this._onKeydownSave),this.editor.editor.removeEventListener("keydown",this._onUndoRedo),this.editor.wrapper.removeEventListener("click",this._onToolbarClick),this._onInput=this._onKeydownSave=this._onUndoRedo=this._onToolbarClick=null),this.mutationObserver&&(this.mutationObserver.disconnect(),this.mutationObserver=null),this.mutationTimeout&&(clearTimeout(this.mutationTimeout),this.mutationTimeout=null),this.stack=[],this.index=-1,this.savedSelection=null}}class Nt extends e{static DEFAULTS={showOnSelection:!0,showOnEnter:!0,buttons:["bold","italic","underline","strike","code"]};constructor(t,e={}){super(t,e),this.blockToolbar=null,this.isVisible=!1,this.currentSelection=null,this.currentCursorPosition=null,this.originalTags=new Map,this.init()}init(){this.preloadIcons(),this.createBlockToolbar(),this.setupEventListeners()}async preloadIcons(){}createBlockToolbar(){this.blockToolbar=document.createElement("div"),this.blockToolbar.className="block-toolbar";const t=document.createElement("div");t.className="block-toolbar-container";const e={bold:{icon:"bold",title:"Bold (Ctrl+B)"},italic:{icon:"italic",title:"Italic (Ctrl+I)"},underline:{icon:"underline",title:"Underline (Ctrl+U)"},strike:{icon:"strike",title:"Strikethrough"},code:{icon:"code",title:"Code"},"font-family":{icon:"font-family",title:"Font Family"},link:{icon:"link",title:"Insert link"},color:{icon:"color",title:"Text color"},background:{icon:"background",title:"Background color"}};(Array.isArray(this.options.buttons)&&this.options.buttons.length?this.options.buttons:["bold","italic","underline","strike","code","font-family"]).map(t=>({cmd:t,icon:e[t]&&e[t].icon||t,title:e[t]&&e[t].title||t})).forEach(({cmd:e,icon:i,title:o})=>{const n=document.createElement("button");n.className="block-toolbar-btn",n.title=o,n.dataset.command=e;const r=V.createIconElement(i,{width:"16px",height:"16px"});n.appendChild(r),n.addEventListener("click",t=>{t.preventDefault(),t.stopPropagation(),this.handleCommand(e,n)}),t.appendChild(n)});const i=document.createElement("div");i.className="block-toolbar-arrow",this.blockToolbar.appendChild(t),this.blockToolbar.appendChild(i),this.editor.wrapper.appendChild(this.blockToolbar)}setupEventListeners(){this._onEditorMouseup=()=>{setTimeout(()=>this.handleSelectionChange(),0)},this._onEditorKeydown=t=>{"Enter"!==t.key||t.shiftKey||requestAnimationFrame(()=>{setTimeout(()=>this.showAtCursorAfterEnter(),10)})},this._onDocMousedown=t=>{t.target.closest(".font-family-select-popup")||t.target.closest(".custom-select-popup")||t.target.closest(".block-toolbar")||t.target.closest(".rich-editor-area")||this.hide()},this._onWindowScroll=()=>{this.isVisible&&this.updateToolbarPosition()},this._onEditorScroll=()=>{this.isVisible&&this.updateToolbarPosition()},this._onEditorKeyup=t=>{"Enter"===t.key&&t.shiftKey?this.hide():this.isVisible?this.updateButtonStates():this.handleSelectionChange()},this.options.showOnSelection&&this.editor.editor.addEventListener("mouseup",this._onEditorMouseup),this.options.showOnEnter&&this.editor.editor.addEventListener("keydown",this._onEditorKeydown),document.addEventListener("mousedown",this._onDocMousedown),window.addEventListener("scroll",this._onWindowScroll),this.editor.editor.addEventListener("scroll",this._onEditorScroll),this.editor.editor.addEventListener("keyup",this._onEditorKeyup)}handleSelectionChange(){const t=window.getSelection();if(!t||0===t.rangeCount)return this.hide();const e=t.getRangeAt(0);if(!(this.editor.isSelectionInEditableArea?this.editor.isSelectionInEditableArea(t):this.editor.editor.contains(e.commonAncestorContainer)))return this.hide();!e.collapsed&&t.toString().trim().length>0?this.showAtSelection(t):this.hide()}showAtSelection(t){if(!t||0===t.rangeCount)return;this.currentSelection=t,this.currentCursorPosition=null;const e=t.getRangeAt(0).getBoundingClientRect(),i=this.editor.wrapper.getBoundingClientRect(),o=window.pageYOffset||document.documentElement.scrollTop,n=window.pageXOffset||document.documentElement.scrollLeft;this.showAt(e.left+e.width/2-i.left+n,e.top-i.top+o-10)}showAtCursorAfterEnter(){this.editor.focus();const t=window.getSelection();if(!t||0===t.rangeCount)return;const e=t.getRangeAt(0);if(!(this.editor.isSelectionInEditableArea?this.editor.isSelectionInEditableArea(t):this.editor.editor.contains(e.commonAncestorContainer)))return;this.ensureCursorAtEndOfLine(e),this.currentSelection=t,this.currentCursorPosition=this.getCursorPositionAfterEnter();const i=this.currentCursorPosition;if(!i)return;const o=this.editor.wrapper.getBoundingClientRect(),n=window.pageYOffset||document.documentElement.scrollTop,r=window.pageXOffset||document.documentElement.scrollLeft;this.showAt(i.left-o.left+r,i.top-o.top+n-10)}ensureCursorAtEndOfLine(t){if(!t.collapsed)return;const e=window.getSelection(),i=t.startContainer;if(i.nodeType===Node.TEXT_NODE){const o=i.textContent.length;t.startOffset<o&&(t.setStart(i,o),t.setEnd(i,o),e.removeAllRanges(),e.addRange(t))}else if(i.nodeType===Node.ELEMENT_NODE){const o=document.createTreeWalker(i,NodeFilter.SHOW_TEXT,null,!1);let n,r=null;for(;n=o.nextNode();)r=n;if(r){const i=r.textContent.length;t.setStart(r,i),t.setEnd(r,i),e.removeAllRanges(),e.addRange(t)}}}getCursorPositionAfterEnter(){const t=window.getSelection();if(!t||0===t.rangeCount)return null;const e=t.getRangeAt(0),i=document.createElement("span");i.innerHTML="&#8203;",i.style.position="absolute",i.style.visibility="hidden",i.style.pointerEvents="none",e.insertNode(i);const o=i.getBoundingClientRect();i.parentNode&&i.parentNode.removeChild(i);const n=document.createRange();return n.setStart(e.startContainer,e.startOffset),n.collapse(!0),t.removeAllRanges(),t.addRange(n),o}showAtCursor(){const t=window.getSelection();if(!t||0===t.rangeCount)return;const e=t.getRangeAt(0);if(!(this.editor.isSelectionInEditableArea?this.editor.isSelectionInEditableArea(t):this.editor.editor.contains(e.commonAncestorContainer)))return;let i;if(e.collapsed){const o=document.createElement("span");o.innerHTML="&#8203;",o.style.position="absolute",o.style.visibility="hidden",o.style.pointerEvents="none",e.insertNode(o),i=o.getBoundingClientRect(),o.parentNode&&o.parentNode.removeChild(o);const n=document.createRange();n.setStart(e.startContainer,e.startOffset),n.collapse(!0),t.removeAllRanges(),t.addRange(n)}else i=e.getBoundingClientRect();const o=this.editor.wrapper.getBoundingClientRect(),n=window.pageYOffset||document.documentElement.scrollTop,r=window.pageXOffset||document.documentElement.scrollLeft;this.showAt(i.left-o.left+r,i.top-o.top+n-10)}showAt(t,e){this.blockToolbar&&(this.blockToolbar.classList.add("visible"),this.isVisible=!0,this.ensureToolbarInViewport(t,e),this.updateButtonStates())}ensureToolbarInViewport(t,e){if(!this.blockToolbar)return;const i=this.editor.editor,o=i.getBoundingClientRect();this.blockToolbar.getBoundingClientRect();const n=this.editor.wrapper.querySelector(".rich-editor-toolbar-container"),r=n?n.getBoundingClientRect():null;let s=t-this.blockToolbar.offsetWidth/2,a=o.y+e-r.height-i.scrollTop-(o.y+window.scrollY)+n.offsetHeight-49,l="50%",c="down";if(s<0&&(s=t-.1*this.blockToolbar.offsetWidth,s<0&&(s=0),l="10%"),s+this.blockToolbar.offsetWidth>this.editor.wrapper.offsetWidth-2&&(s=t-.9*this.blockToolbar.offsetWidth,l="90%"),a<r.height&&(a=o.y+e-r.height-i.scrollTop+100-(o.y+window.scrollY)+n.offsetHeight-49,c="up",a<r.height))return void this.hide();if(a>o.height)return void this.hide();const d=this.blockToolbar.querySelector(".block-toolbar-arrow");d&&(d.style.left=l,"up"===c?(d.style.bottom="auto",d.style.top="-8px",d.style.borderTop="none",d.style.borderBottom="8px solid #fff",d.style.borderLeft="6px solid transparent",d.style.borderRight="6px solid transparent"):(d.style.top="auto",d.style.bottom="-8px",d.style.borderBottom="none",d.style.borderTop="8px solid #fff",d.style.borderLeft="6px solid transparent",d.style.borderRight="6px solid transparent")),this.blockToolbar.style.left=s+"px",this.blockToolbar.style.top=a+"px"}updateToolbarPosition(){if(!this.isVisible)return;const t=window.getSelection();if(!t||0===t.rangeCount)return void this.hide();const e=t.getRangeAt(0);if(!(this.editor.isSelectionInEditableArea?this.editor.isSelectionInEditableArea(t):this.editor.editor.contains(e.commonAncestorContainer)))return void this.hide();let i;if(e.collapsed){const o=document.createElement("span");o.innerHTML="&#8203;",o.style.position="absolute",o.style.visibility="hidden",o.style.pointerEvents="none";try{e.insertNode(o),i=o.getBoundingClientRect(),o.parentNode&&o.parentNode.removeChild(o);const n=document.createRange();n.setStart(e.startContainer,e.startOffset),n.collapse(!0),t.removeAllRanges(),t.addRange(n)}catch(t){return void this.hide()}}else i=e.getBoundingClientRect();const o=this.editor.wrapper.getBoundingClientRect(),n=window.pageYOffset||document.documentElement.scrollTop,r=window.pageXOffset||document.documentElement.scrollLeft;let s,a;e.collapsed?(s=i.left-o.left+r,a=i.top-o.top+n-10):(s=i.left+i.width/2-o.left+r,a=i.top-o.top+n-10),this.updateToolbarAt(s,a);const l=this.editor.registry.get("formats/font-family");l&&l.selectInstance&&l.selectInstance.isVisible&&l.selectInstance.updatePosition()}updateToolbarAt(t,e){this.blockToolbar&&(this.ensureToolbarInViewport(t,e),this.updateButtonStates())}hide(){if(!this.blockToolbar||!this.isVisible)return;this.blockToolbar.classList.remove("visible"),this.isVisible=!1,this.currentSelection=null,this.currentCursorPosition=null;const t=this.editor.registry.get("formats/font-family");t&&t.selectInstance&&t.selectInstance.hide()}handleCommand(t,e){const o=window.getSelection();if(!(!this.editor.isSelectionInEditableArea||this.editor.isSelectionInEditableArea(o)))return void this.hide();if("font-family"===t){const i=this.editor.registry.get("formats/font-family");if(i){return(new i).toggle(e),this.updateButtonState(t,e),void this.editor.focus()}}if("code"===t){const i=this.editor.registry.get("formats/heading");if(i){const o=new i,n=o.getCurrentTag();if("PRE"===n){const t=window.getSelection();if(t&&t.rangeCount){const e=t.getRangeAt(0),i=this.getBlockElement(e.startContainer);if(i){const t=this.originalTags.get(i)||"P";o.apply(t),this.originalTags.delete(i)}else o.apply("P")}else o.apply("P")}else{const t=window.getSelection();if(t&&t.rangeCount){const e=t.getRangeAt(0),i=this.getBlockElement(e.startContainer);i&&this.originalTags.set(i,n||"P")}o.apply("PRE")}return this.updateButtonState(t,e),void this.editor.focus()}}const n=this.editor.registry.get(`formats/${t}`);if(n){const t=new n;"function"==typeof t.toggle?t.toggle():"function"==typeof t.apply&&t.apply()}else i(t);this.updateButtonState(t,e),this.editor.focus()}updateButtonStates(){if(!this.blockToolbar)return;this.blockToolbar.querySelectorAll(".block-toolbar-btn").forEach(t=>{const e=t.dataset.command;this.updateButtonState(e,t)})}updateButtonState(t,e){if(!e)return;let i=!1;if("font-family"===t){const t=this.editor.registry.get("formats/font-family");if(t){i=(new t).isActive()}}else if("code"===t){const t=this.editor.registry.get("formats/heading");if(t){i="PRE"===(new t).getCurrentTag()}}else if("strike"===t){const e=this.editor.registry.get(`formats/${t}`);if(e){i=(new e).isActive()}}else i=n(t);i?e.classList.add("active"):e.classList.remove("active")}getBlockElement(t){if(!t)return null;if(t.nodeType===Node.ELEMENT_NODE){if(["H1","H2","H3","H4","H5","H6","P","PRE","BLOCKQUOTE","DIV"].includes(t.tagName))return t}let e=t;for(;e&&e!==this.editor.editor;){if(e.nodeType===Node.ELEMENT_NODE){if(["H1","H2","H3","H4","H5","H6","P","PRE","BLOCKQUOTE","DIV"].includes(e.tagName))return e}e=e.parentNode}return null}destroy(){this._onDocMousedown&&(document.removeEventListener("mousedown",this._onDocMousedown),window.removeEventListener("scroll",this._onWindowScroll),this.editor.editor.removeEventListener("mouseup",this._onEditorMouseup),this.editor.editor.removeEventListener("keydown",this._onEditorKeydown),this.editor.editor.removeEventListener("scroll",this._onEditorScroll),this.editor.editor.removeEventListener("keyup",this._onEditorKeyup),this._onDocMousedown=this._onWindowScroll=this._onEditorMouseup=null,this._onEditorKeydown=this._onEditorScroll=this._onEditorKeyup=null),this.blockToolbar&&this.blockToolbar.parentNode&&this.blockToolbar.parentNode.removeChild(this.blockToolbar),this.blockToolbar=null,this.isVisible=!1,this.originalTags.clear()}}class Lt extends e{static DEFAULTS={fadeDelay:3e3,buttons:["tableProfile","deleteTable","insertRowAbove","insertRowBelow","deleteRow","insertColRight","insertColLeft","deleteCol"]};constructor(t,e={}){super(t,e),this.tableToolbar=null,this.currentTable=null,this.currentCell=null,this.hideTimeout=null,this.isVisible=!1,this.init()}async init(){await this.createTableToolbar(),this.setupEventListeners()}async createTableToolbar(){this.tableToolbar=document.createElement("div"),this.tableToolbar.className="table-toolbar";const t=document.createElement("div");t.className="table-toolbar-container";const e=[{name:"table-actions",buttons:[{cmd:"tableProfile",icon:"icon-table-profile",title:"Table Profile"},{cmd:"deleteTable",icon:"icon-delete-table",title:"Delete Table"}]},{name:"row-actions",buttons:[{cmd:"insertRowAbove",icon:"icon-add-row-above",title:"Add Row Above"},{cmd:"insertRowBelow",icon:"icon-add-row-below",title:"Add Row Below"},{cmd:"deleteRow",icon:"icon-delete-row",title:"Delete Selected Row"}]},{name:"col-actions",buttons:[{cmd:"insertColRight",icon:"icon-add-col-right",title:"Add Column Right"},{cmd:"insertColLeft",icon:"icon-add-col-left",title:"Add Column Left"},{cmd:"deleteCol",icon:"icon-delete-col",title:"Delete Selected Column"}]}];for(const i of e){const e=document.createElement("div");e.className=`table-toolbar-group ${i.name}`;for(const{cmd:t,icon:o,title:n}of i.buttons){const i=document.createElement("button");i.className="table-toolbar-btn",i.title=n,i.dataset.command=t;const r=V.getIcon(o.replace("icon-",""));r&&(i.innerHTML=r),i.addEventListener("click",e=>{e.preventDefault(),e.stopPropagation(),this.handleCommand(t,i)}),e.appendChild(i)}t.appendChild(e)}const i=document.createElement("div");i.className="table-toolbar-arrow",this.tableToolbar.appendChild(t),this.tableToolbar.appendChild(i),this.editor.wrapper.appendChild(this.tableToolbar)}setupEventListeners(){this._onEditorClick=t=>{const e=t.target.closest("td, th"),i=t.target.closest("table");if(i&&e){if(!(!this.editor.isNodeInEditableArea||this.editor.isNodeInEditableArea(i)))return void this.hide();this.currentTable=i,this.currentCell=e,this.showAtTable(i)}else this.hide()},this._onDocMousedown=t=>{t.target.closest(".table-toolbar")||t.target.closest("table")||this.hide()},this._onWindowScroll=()=>{this.isVisible&&this.currentTable&&this.updateToolbarPosition()},this._onEditorScroll=()=>{this.isVisible&&this.currentTable&&this.updateToolbarPosition()},this.editor.editor.addEventListener("click",this._onEditorClick),document.addEventListener("mousedown",this._onDocMousedown),window.addEventListener("scroll",this._onWindowScroll),this.editor.editor.addEventListener("scroll",this._onEditorScroll),this._onEditorKeyup=t=>{if(this.isVisible&&this.currentTable){const t=window.getSelection();if(t&&t.rangeCount>0){const e=t.getRangeAt(0).startContainer,i=e.nodeType===Node.TEXT_NODE?e.parentElement.closest("td, th"):e.closest("td, th");if(i&&i!==this.currentCell){if(!(!this.editor.isNodeInEditableArea||this.editor.isNodeInEditableArea(i)))return void this.hide();this.currentCell=i}}}},this.editor.editor.addEventListener("keyup",this._onEditorKeyup)}updateToolbarPosition(){if(!this.isVisible||!this.currentTable)return;if(!document.body.contains(this.currentTable))return void this.hide();if(!(!this.editor.isNodeInEditableArea||this.editor.isNodeInEditableArea(this.currentTable)))return void this.hide();const t=this.currentTable.getBoundingClientRect(),e=this.editor.wrapper.getBoundingClientRect(),i=window.pageYOffset||document.documentElement.scrollTop,o=window.pageXOffset||document.documentElement.scrollLeft;this.updateToolbarAt(t.left-e.left+o,t.top-e.top+i,t.width,t.height)}updateToolbarAt(t,e,i,o){this.tableToolbar&&this.ensureToolbarInViewport(t,e,i,o)}showAtTable(t){if(!t||!this.tableToolbar)return;const e=t.getBoundingClientRect(),i=this.editor.wrapper.getBoundingClientRect(),o=window.pageYOffset||document.documentElement.scrollTop,n=window.pageXOffset||document.documentElement.scrollLeft;this.showAt(e.left-i.left+n,e.top-i.top+o,e.width,e.height)}showAt(t,e,i,o){this.tableToolbar&&(this.tableToolbar.classList.add("visible"),this.isVisible=!0,this.ensureToolbarInViewport(t,e,i,o),this.clearHideTimeout())}ensureToolbarInViewport(t,e,i,o){if(!this.tableToolbar)return;const n=this.editor.editor.getBoundingClientRect();this.tableToolbar.getBoundingClientRect();const r=this.editor.wrapper.querySelector(".rich-editor-toolbar-container"),s=r?r.getBoundingClientRect():null;let a=t+i/2-this.tableToolbar.offsetWidth/2,l=e-60-document.documentElement.scrollTop,c="50%",d="down";if(a<0&&(a=t-.1*this.tableToolbar.offsetWidth,a<0&&(a=0),c="10%"),a+this.tableToolbar.offsetWidth>this.editor.wrapper.offsetWidth-2&&(a=t-.9*this.tableToolbar.offsetWidth,c="90%"),l<(s?s.height:48)&&(l=e+o+10-document.documentElement.scrollTop,d="up",l<(s?s.height:48)))return void this.hide();if(l>n.height)return void this.hide();const h=this.tableToolbar.querySelector(".table-toolbar-arrow");h&&(h.style.left=c,"up"===d?(h.style.bottom="auto",h.style.top="-8px",h.style.borderTop="none",h.style.borderBottom="8px solid #fff",h.style.borderLeft="6px solid transparent",h.style.borderRight="6px solid transparent"):(h.style.top="auto",h.style.bottom="-8px",h.style.borderBottom="none",h.style.borderTop="8px solid #fff",h.style.borderLeft="6px solid transparent",h.style.borderRight="6px solid transparent")),this.tableToolbar.style.left=a+"px",this.tableToolbar.style.top=l+"px"}hide(){this.tableToolbar&&this.isVisible&&(this.tableToolbar.classList.remove("visible"),this.isVisible=!1,this.currentTable=null,this.currentCell=null,this.clearHideTimeout())}clearHideTimeout(){this.hideTimeout&&(clearTimeout(this.hideTimeout),this.hideTimeout=null)}handleCommand(t,e){if(!this.currentTable||!this.currentCell)return;if(!this.editor.isNodeInEditableArea||this.editor.isNodeInEditableArea(this.currentTable)){switch(t){case"tableProfile":this.showTableProfile();break;case"deleteTable":this.deleteTable();break;case"insertRowAbove":this.insertRowAbove();break;case"insertRowBelow":this.insertRowBelow();break;case"deleteRow":this.deleteRow();break;case"insertColRight":this.insertColumnRight();break;case"insertColLeft":this.insertColumnLeft();break;case"deleteCol":this.deleteColumn()}this.editor.focus()}else this.hide()}insertRowAbove(){const t=this.currentCell.parentElement,e=this.createNewRow(t.cells.length);t.parentElement.insertBefore(e,t),this.editor.resizeHandles&&this.editor.resizeHandles.checkAndUpdateHandles()}insertRowBelow(){const t=this.currentCell.parentElement,e=this.createNewRow(t.cells.length);t.nextElementSibling?t.parentElement.insertBefore(e,t.nextElementSibling):t.parentElement.appendChild(e),this.editor.resizeHandles&&this.editor.resizeHandles.checkAndUpdateHandles()}insertColumnLeft(){const t=Array.from(this.currentCell.parentElement.children).indexOf(this.currentCell);(this.currentTable.querySelector("tbody")||this.currentTable).querySelectorAll("tr").forEach(e=>{const i=this.createNewCell(),o=e.children[t];o?e.insertBefore(i,o):e.appendChild(i)}),this.editor.resizeHandles&&this.editor.resizeHandles.checkAndUpdateHandles()}insertColumnRight(){const t=Array.from(this.currentCell.parentElement.children).indexOf(this.currentCell);(this.currentTable.querySelector("tbody")||this.currentTable).querySelectorAll("tr").forEach(e=>{const i=this.createNewCell(),o=e.children[t+1];o?e.insertBefore(i,o):e.appendChild(i)}),this.editor.resizeHandles&&this.editor.resizeHandles.checkAndUpdateHandles()}deleteRow(){const t=this.currentCell.parentElement;t.parentElement.children.length<=1||(t.remove(),this.editor.resizeHandles&&this.editor.resizeHandles.checkAndUpdateHandles(),this.hide())}deleteColumn(){const t=Array.from(this.currentCell.parentElement.children).indexOf(this.currentCell),e=(this.currentTable.querySelector("tbody")||this.currentTable).querySelectorAll("tr");this.currentCell.parentElement.children.length<=1||(e.forEach(e=>{e.children[t]&&e.children[t].remove()}),this.editor.resizeHandles&&this.editor.resizeHandles.checkAndUpdateHandles(),this.hide())}showTableProfile(){if(!this.currentTable)return;const t=this.currentTable.querySelectorAll("tr").length,e=this.currentTable.querySelector("tr")?this.currentTable.querySelector("tr").querySelectorAll("td, th").length:0,i=t,o=e,n=t*e,r=this.currentTable.offsetWidth,s=this.currentTable.offsetHeight;alert(`Table Profile:\nRows: ${i}\nColumns: ${o}\nTotal Cells: ${n}\nWidth: ${r}px\nHeight: ${s}px`)}deleteTable(){this.editor.resizeHandles&&this.editor.resizeHandles.hideHandles(),this.currentTable.remove(),this.hide()}createNewRow(t){const e=document.createElement("tr");for(let i=0;i<t;i++)e.appendChild(this.createNewCell());return e}createNewCell(){const t=document.createElement("td");return t.innerHTML="&nbsp;",t.style.minWidth="50px",t.style.minHeight="24px",t.style.padding="4px 8px",t.style.border="1px solid #ddd",t.style.verticalAlign="top",t.contentEditable="true",t}destroy(){this._onDocMousedown&&(document.removeEventListener("mousedown",this._onDocMousedown),window.removeEventListener("scroll",this._onWindowScroll),this.editor.editor.removeEventListener("click",this._onEditorClick),this.editor.editor.removeEventListener("scroll",this._onEditorScroll),this.editor.editor.removeEventListener("keyup",this._onEditorKeyup),this._onDocMousedown=this._onWindowScroll=this._onEditorClick=null,this._onEditorScroll=this._onEditorKeyup=null),this.tableToolbar&&this.tableToolbar.parentNode&&this.tableToolbar.parentNode.removeChild(this.tableToolbar),this.clearHideTimeout(),this.tableToolbar=null,this.currentTable=null,this.currentCell=null,this.isVisible=!1}}class At extends e{constructor(t,e={}){super(t,e),this.isCodeView=!1,this.originalContent="",this.codeTextarea=null,this.disabledModules=new Set,this.init()}init(){this.editor.on("toolbar-click",t=>{"code-view"===t.command&&this.toggleCodeView()})}toggleCodeView(){this.isCodeView?this.showNormalView():this.showCodeView(),this.updateToolbarButton()}showCodeView(){const t=this.editor.editor;if(!t)return;this.originalContent=t.innerHTML,this.codeTextarea=document.createElement("textarea"),this.codeTextarea.className="code-view-textarea",this.codeTextarea.value=this.formatHTML(this.originalContent),t.style.display="none",t.parentNode.insertBefore(this.codeTextarea,t);const e=this.editor.wrapper;e&&e.classList.add("code-view-active"),this.codeTextarea.focus(),this.isCodeView=!0,"function"==typeof this.editor.updateStatusbar&&this.editor.updateStatusbar(),this.disableOtherFeatures(),this.codeTextarea.addEventListener("input",()=>{this.updateOriginalContent()})}showNormalView(){const t=this.editor.editor;if(!t||!this.codeTextarea)return;const e=this.codeTextarea.value;this.codeTextarea.parentNode.removeChild(this.codeTextarea),this.codeTextarea=null;const i=this.editor.wrapper;i&&i.classList.remove("code-view-active"),t.style.display="",t.innerHTML=d(e),t.focus(),this.isCodeView=!1,this.enableOtherFeatures(),this.editor.onContentChange()}disableOtherFeatures(){const t=this.editor.getModule("toolbar");if(t){["bold","italic","underline","strike","subscript","superscript","color","background","link","table","heading","font-family","line-height","capitalization","text-align","list","indent-increase","indent-decrease","text-size","emoji","image","video","tag","import","undo","redo","clear-format","horizontal-rule","text-direction","find","more"].forEach(e=>{t.setButtonDisabled(e,!0)}),t.setButtonDisabled("code-view",!1),t.setButtonDisabled("theme",!1)}this.disableEditorEvents(),this.disableOtherModules(),this.hideAllPopups()}enableOtherFeatures(){const t=this.editor.getModule("toolbar");if(t){["bold","italic","underline","strike","subscript","superscript","color","background","link","table","heading","font-family","line-height","capitalization","text-align","list","indent-increase","indent-decrease","text-size","emoji","image","video","tag","import","undo","redo","clear-format","horizontal-rule","text-direction","find","more"].forEach(e=>{t.setButtonDisabled(e,!1)})}this.enableEditorEvents(),this.enableOtherModules()}disableEditorEvents(){const t=this.editor.editor;t&&(t.contentEditable=!1,t.style.opacity="0.5",t.style.pointerEvents="none",t.style.cursor="not-allowed",t.title='Editor is disabled in code view mode. Click "Switch to Visual Editor" to return to normal editing.')}enableEditorEvents(){const t=this.editor.editor;t&&(t.contentEditable=!0,t.style.opacity="",t.style.pointerEvents="",t.style.cursor="",t.title="")}disableOtherModules(){["history","block-toolbar","table-toolbar","resize-handles"].forEach(t=>{const e=this.editor.getModule(t);if(e)if("function"==typeof e.disable)e.disable(),this.disabledModules.add(t);else if(e.getContainer&&"function"==typeof e.getContainer){const i=e.getContainer();i&&(i.style.display="none",this.disabledModules.add(t))}})}enableOtherModules(){this.disabledModules.forEach(t=>{const e=this.editor.getModule(t);if(e)if("function"==typeof e.enable)e.enable();else if(e.getContainer&&"function"==typeof e.getContainer){const t=e.getContainer();t&&(t.style.display="")}}),this.disabledModules.clear()}updateOriginalContent(){if(this.codeTextarea){this.originalContent=this.codeTextarea.value;const t=this.codeTextarea.value;this.editor.options.onChange&&"function"==typeof this.editor.options.onChange&&this.editor.options.onChange(t),this.editor.emit("text-change",t),"function"==typeof this.editor.updateStatusbar&&this.editor.updateStatusbar()}}formatHTML(t){let e=t;e=e.replace(/></g,">\n<"),e=e.replace(/>([^<>\s][^<]*)</g,">\n$1\n<");const i=e.split("\n"),o=[],n=[];for(let t of i){const e=t.trim();if(!e)continue;if(/^<\/(\w+)/.test(e)){const t=e.match(/^<\/(\w+)/);if(t){const e=t[1];for(let t=n.length-1;t>=0;t--)if(n[t]===e){n.splice(t,1);break}}}let i=n.length;e.startsWith("<")||(i=n.length),o.push(" ".repeat(4*i)+e);const r=e.match(/^<(\w+)/);if(r&&!e.startsWith("</")&&!e.endsWith("/>")&&!["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"].includes(r[1].toLowerCase())){const t=r[1];n.push(t)}}return o.join("\n")}updateToolbarButton(){const t=this.editor.getModule("toolbar");if(t){t.setButtonActive("code-view",this.isCodeView);const e=this.isCodeView?"Switch to Visual Editor":"Switch to HTML Editor";t.setButtonTitle("code-view",e)}}isInCodeView(){return this.isCodeView}getCurrentContent(){return this.isCodeView&&this.codeTextarea?this.codeTextarea.value:this.editor.editor.innerHTML}setContent(t){this.isCodeView&&this.codeTextarea?(this.codeTextarea.value=this.formatHTML(t),this.updateOriginalContent()):this.editor.editor.innerHTML=t}hideAllPopups(){document.querySelectorAll(".rich-editor-popup, .color-picker-popup, .emoji-picker-popup, .link-popup, .image-popup, .video-popup, .table-popup, .tag-popup, .import-popup").forEach(t=>{t.parentNode&&t.parentNode.removeChild(t)}),this.editor.popupInstances&&this.editor.popupInstances.clear()}destroy(){this.isCodeView&&this.showNormalView(),this.codeTextarea&&this.codeTextarea.parentNode&&this.codeTextarea.parentNode.removeChild(this.codeTextarea),this.codeTextarea=null,this.originalContent="",this.isCodeView=!1,this.disabledModules.clear()}}class Bt extends e{constructor(t,e={}){super(t,e),this.hits=[],this.activeIndex=-1,this.caseSensitive=!1,this.isOpen=!1,this.buildPanel(),this.bindEvents()}buildPanel(){const t=document.createElement("div");t.className="yjd-find-replace";const e=(t,e)=>{const i=document.createElement("input");return i.type="text",i.placeholder=t,i.className=`yjd-find-input ${e}`,i.setAttribute("aria-label",t),i},i=(t,e,i="",o=null)=>{const n=document.createElement("button");if(n.type="button",o){const e=V.getIcon(o);n.innerHTML=e?`<span class="icon">${e}</span>`:t}else n.textContent=t;return n.title=e,n.setAttribute("aria-label",e),n.className=`yjd-find-btn ${i}`.trim(),n},o=document.createElement("div");o.className="yjd-find-row";const n=document.createElement("div");n.className="yjd-find-row",this.findInput=e("Find","yjd-find-field"),this.replaceInput=e("Replace with","yjd-find-field"),this.countEl=document.createElement("span"),this.countEl.className="yjd-find-count",this.countEl.textContent="0/0",this.prevBtn=i("","Previous match","yjd-find-icon","chevron-up"),this.nextBtn=i("","Next match","yjd-find-icon","chevron-down"),this.caseBtn=i("Aa","Match case","yjd-find-icon yjd-find-toggle"),this.closeBtn=i("","Close (Esc)","yjd-find-icon yjd-find-close","close"),this.replaceBtn=i("Replace","Replace current"),this.replaceAllBtn=i("Replace all","Replace all matches"),o.append(this.findInput,this.countEl,this.prevBtn,this.nextBtn,this.caseBtn,this.closeBtn),n.append(this.replaceInput,this.replaceBtn,this.replaceAllBtn),t.append(o,n),this.panel=t,this.editor.wrapper.appendChild(t)}bindEvents(){this._onKeydown=t=>{!t.ctrlKey&&!t.metaKey||t.shiftKey||t.altKey||"f"!==t.key.toLowerCase()||(t.preventDefault(),this.open())},this.editor.editor.addEventListener("keydown",this._onKeydown),this._onToolbarClick=t=>{t&&"find"===t.command&&this.open()},this.editor.on("toolbar-click",this._onToolbarClick),this.findInput.addEventListener("input",()=>this.runSearch()),this.findInput.addEventListener("keydown",t=>{"Enter"===t.key?(t.preventDefault(),this.navigate(t.shiftKey?-1:1)):"Escape"===t.key&&(t.preventDefault(),this.close())}),this.replaceInput.addEventListener("keydown",t=>{"Enter"===t.key?(t.preventDefault(),this.replaceCurrent()):"Escape"===t.key&&(t.preventDefault(),this.close())}),this.prevBtn.addEventListener("click",()=>this.navigate(-1)),this.nextBtn.addEventListener("click",()=>this.navigate(1)),this.replaceBtn.addEventListener("click",()=>this.replaceCurrent()),this.replaceAllBtn.addEventListener("click",()=>this.replaceAll()),this.caseBtn.addEventListener("click",()=>{this.caseSensitive=!this.caseSensitive,this.caseBtn.classList.toggle("active",this.caseSensitive),this.caseBtn.setAttribute("aria-pressed",this.caseSensitive?"true":"false"),this.runSearch()}),this.closeBtn.addEventListener("click",()=>this.close())}open(){this.isOpen=!0,this.panel.classList.add("open");const t=this.editor.wrapper.querySelector(".rich-editor-toolbar-container");t&&(this.panel.style.top=t.offsetHeight+6+"px");const e=window.getSelection(),i=e&&!e.isCollapsed?e.toString():"";i&&!i.includes("\n")&&(this.findInput.value=i),this.findInput.focus(),this.findInput.select(),this.runSearch()}close(){this.isOpen=!1,this.panel.classList.remove("open"),this.clearHighlights(),this.hits=[],this.activeIndex=-1,this.editor.focus()}escapeRegex(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}clearHighlights(){this.editor.editor.querySelectorAll("mark.yjd-find-hit").forEach(t=>{const e=t.parentNode;if(e){for(;t.firstChild;)e.insertBefore(t.firstChild,t);e.removeChild(t),e.normalize()}})}runSearch(){this.clearHighlights(),this.hits=[],this.activeIndex=-1;const t=this.findInput.value;if(!t)return void this.updateCount();let e;try{e=new RegExp(this.escapeRegex(t),this.caseSensitive?"g":"gi")}catch(t){return void this.updateCount()}const i=this.editor.editor,o=document.createTreeWalker(i,NodeFilter.SHOW_TEXT,null),n=[];let r;for(;r=o.nextNode();)r.nodeValue&&r.nodeValue.length&&n.push(r);n.forEach(t=>{const i=t.nodeValue,o=[];let n;for(e.lastIndex=0;null!==(n=e.exec(i));)0!==n[0].length?o.push([n.index,n.index+n[0].length]):e.lastIndex++;for(let e=o.length-1;e>=0;e--){const i=document.createRange();i.setStart(t,o[e][0]),i.setEnd(t,o[e][1]);const n=document.createElement("mark");n.className="yjd-find-hit";try{i.surroundContents(n)}catch(t){}}}),this.hits=Array.from(i.querySelectorAll("mark.yjd-find-hit")),this.hits.length&&(this.activeIndex=0,this.highlightActive(!0)),this.updateCount()}highlightActive(t){this.hits.forEach((t,e)=>{t.classList.toggle("active",e===this.activeIndex)}),t&&this.activeIndex>=0&&this.hits[this.activeIndex]&&this.hits[this.activeIndex].scrollIntoView({block:"nearest",inline:"nearest"})}navigate(t){this.hits.length&&(this.activeIndex=(this.activeIndex+t+this.hits.length)%this.hits.length,this.highlightActive(!0),this.updateCount())}updateCount(){const t=this.hits.length,e=t?this.activeIndex+1:0;this.countEl.textContent=`${e}/${t}`}replaceCurrent(){if(this.activeIndex<0||!this.hits[this.activeIndex])return;const t=this.editor.getModule("history");t&&"function"==typeof t.saveBeforeFormat&&t.saveBeforeFormat();const e=this.hits[this.activeIndex],i=this.activeIndex,o=e.parentNode;o.replaceChild(document.createTextNode(this.replaceInput.value),e),o.normalize(),this.editor.onContentChange(),this.runSearch(),this.hits.length&&(this.activeIndex=Math.min(i,this.hits.length-1),this.highlightActive(!0),this.updateCount())}replaceAll(){if(!this.hits.length)return;const t=this.editor.getModule("history");t&&"function"==typeof t.saveBeforeFormat&&t.saveBeforeFormat();const e=this.replaceInput.value;this.hits.forEach(t=>{const i=t.parentNode;i&&i.replaceChild(document.createTextNode(e),t)}),this.editor.editor.normalize(),this.editor.onContentChange(),this.runSearch()}destroy(){this.editor.editor.removeEventListener("keydown",this._onKeydown),this.editor.off("toolbar-click",this._onToolbarClick),this.clearHighlights(),this.panel&&this.panel.parentNode&&this.panel.parentNode.removeChild(this.panel),super.destroy()}}class Rt extends e{constructor(t,e={}){super(t,e),this.isOpen=!1,this.activeIndex=0,this.query="",this.filtered=[],this.commands=this.buildCommands(),this.buildMenu(),this.bindEvents()}buildCommands(){const t=this.editor;return[{id:"h1",label:"Heading 1",hint:"Big section heading",icon:"heading",run:()=>t.setBlockType("h1")},{id:"h2",label:"Heading 2",hint:"Medium heading",icon:"heading",run:()=>t.setBlockType("h2")},{id:"h3",label:"Heading 3",hint:"Small heading",icon:"heading",run:()=>t.setBlockType("h3")},{id:"ul",label:"Bullet list",hint:"Unordered list",icon:"list-bullet",run:()=>t.setBlockType("ul")},{id:"ol",label:"Numbered list",hint:"Ordered list",icon:"list-ordered",run:()=>t.setBlockType("ol")},{id:"quote",label:"Quote",hint:"Blockquote",icon:"code",run:()=>t.setBlockType("blockquote")},{id:"code",label:"Code block",hint:"Preformatted code",icon:"code-view",run:()=>t.setBlockType("pre")},{id:"hr",label:"Divider",hint:"Horizontal rule",icon:"horizontal-rule",run:()=>t.insertHorizontalRule()},{id:"table",label:"Table",hint:"3×3 table",icon:"table",run:()=>this.insertTable()},{id:"p",label:"Text",hint:"Plain paragraph",icon:"font-family",run:()=>t.setBlockType("p")}]}insertTable(){const t=this.editor.registry.get("formats/table");t&&"function"==typeof t.createTableElement&&"function"==typeof this.editor.insertBlock&&this.editor.insertBlock(t.createTableElement(3,3))}buildMenu(){const t=document.createElement("div");t.className="yjd-slash-menu",t.setAttribute("role","listbox"),t.style.display="none",this.menu=t,document.body.appendChild(t)}bindEvents(){this._onInput=()=>this.handleInput(),this.editor.editor.addEventListener("input",this._onInput),this._onKeydown=t=>{this.isOpen&&("ArrowDown"===t.key?(t.preventDefault(),this.move(1)):"ArrowUp"===t.key?(t.preventDefault(),this.move(-1)):"Enter"===t.key?(t.preventDefault(),this.choose(this.activeIndex)):"Escape"===t.key&&(t.preventDefault(),this.close()))},this.editor.editor.addEventListener("keydown",this._onKeydown,!0),this._onDocPointer=t=>{this.isOpen&&!this.menu.contains(t.target)&&this.close()},document.addEventListener("pointerdown",this._onDocPointer,!0)}handleInput(){const t=window.getSelection();if(!t||!t.isCollapsed||!t.rangeCount)return this.close();const e=t.getRangeAt(0),i=e.startContainer;if(i.nodeType!==Node.TEXT_NODE)return this.close();const o=i.textContent.slice(0,e.startOffset).match(/(?:^|\s)\/([^\s/]*)$/);if(!o)return this.close();this.query=o[1],this.slashNode=i,this.slashStart=e.startOffset-this.query.length-1;const n=this.query.toLowerCase();if(this.filtered=this.commands.filter(t=>t.label.toLowerCase().includes(n)||t.id.toLowerCase().includes(n)||(t.hint||"").toLowerCase().includes(n)),!this.filtered.length)return this.close();this.activeIndex=0,this.render(),this.open(e)}open(t){this.isOpen=!0,this.menu.style.display="block";const e=t.getBoundingClientRect(),i=e.left||(t.startContainer.parentElement||this.editor.editor).getBoundingClientRect().left,o=e.bottom||e.top;this.menu.style.left=`${Math.round(i+window.scrollX)}px`,this.menu.style.top=`${Math.round(o+window.scrollY+6)}px`;const n=this.menu.offsetHeight;e.bottom+n+8>window.innerHeight&&(this.menu.style.top=`${Math.round(e.top+window.scrollY-n-6)}px`)}close(){this.isOpen&&(this.isOpen=!1,this.menu.style.display="none")}move(t){this.activeIndex=(this.activeIndex+t+this.filtered.length)%this.filtered.length,this.render()}render(){this.menu.innerHTML="",this.filtered.forEach((t,e)=>{const i=document.createElement("button");i.type="button",i.className="yjd-slash-item"+(e===this.activeIndex?" active":""),i.setAttribute("role","option"),i.setAttribute("aria-selected",e===this.activeIndex?"true":"false");const o=document.createElement("span");o.className="yjd-slash-icon",o.innerHTML=V.getIcon(t.icon)||"";const n=document.createElement("span");n.className="yjd-slash-text",n.innerHTML=`<span class="yjd-slash-label">${t.label}</span><span class="yjd-slash-hint">${t.hint}</span>`,i.append(o,n),i.addEventListener("pointerdown",t=>{t.preventDefault(),this.choose(e)}),this.menu.appendChild(i)})}choose(t){const e=this.filtered[t];if(!e)return this.close();try{const t=this.slashNode,e=window.getSelection(),i=document.createRange();i.setStart(t,this.slashStart),i.setEnd(t,this.slashStart+this.query.length+1),i.deleteContents();const o=document.createRange();o.setStart(t,this.slashStart),o.collapse(!0),e.removeAllRanges(),e.addRange(o)}catch(t){}this.close(),this.editor.focus(),e.run(this.editor)}destroy(){this.editor.editor.removeEventListener("input",this._onInput),this.editor.editor.removeEventListener("keydown",this._onKeydown,!0),document.removeEventListener("pointerdown",this._onDocPointer,!0),this.menu&&this.menu.parentNode&&this.menu.parentNode.removeChild(this.menu),super.destroy()}}class Ht extends e{constructor(t,e={}){super(t,e),this.isOpen=!1,this.activeIndex=0,this.items=[],this.sources=this._buildSources(),this.buildMenu(),this.bindEvents()}_buildSources(){const t=this.editor.options.mention||this.options||{},e={},i=t.renderItem;return"function"==typeof t.source&&(e[t.trigger||"@"]={source:t.source,renderItem:t.renderItem||i}),(t.triggers||[]).forEach(t=>{t&&t.char&&"function"==typeof t.source&&(e[t.char]={source:t.source,renderItem:t.renderItem||i})}),e}get enabled(){return Object.keys(this.sources).length>0}buildMenu(){const t=document.createElement("div");t.className="yjd-mention-menu",t.setAttribute("role","listbox"),t.style.display="none",this.menu=t,document.body.appendChild(t)}bindEvents(){this.enabled&&(this._onInput=()=>this.handleInput(),this.editor.editor.addEventListener("input",this._onInput),this._onKeydown=t=>{this.isOpen&&("ArrowDown"===t.key?(t.preventDefault(),this.move(1)):"ArrowUp"===t.key?(t.preventDefault(),this.move(-1)):"Enter"===t.key||"Tab"===t.key?(t.preventDefault(),this.choose(this.activeIndex)):"Escape"===t.key&&(t.preventDefault(),this.close()))},this.editor.editor.addEventListener("keydown",this._onKeydown,!0),this._onDocPointer=t=>{this.isOpen&&!this.menu.contains(t.target)&&this.close()},document.addEventListener("pointerdown",this._onDocPointer,!0))}handleInput(){const t=window.getSelection();if(!t||!t.isCollapsed||!t.rangeCount)return this.close();const e=t.getRangeAt(0),i=e.startContainer;if(i.nodeType!==Node.TEXT_NODE)return this.close();const o=Object.keys(this.sources).map(t=>t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join(""),n=i.textContent.slice(0,e.startOffset).match(new RegExp(`(?:^|\\s)([${o}])([^\\s${o}]*)$`));if(!n)return this.close();this.char=n[1],this.query=n[2],this.node=i,this.start=e.startOffset-this.query.length-1,this._loadFor(e)}_loadFor(t){const e=this.sources[this.char];if(!e)return this.close();clearTimeout(this._t);const i=this.query,o=this.char;this._t=setTimeout(()=>{Promise.resolve(e.source(i)).then(n=>{if(this.char===o&&this.query===i){if(this.items=Array.isArray(n)?n:[],!this.items.length)return this.close();this.activeIndex=0,this.render(e.renderItem),this.open(t)}}).catch(()=>this.close())},120)}open(t){this.isOpen=!0,this.menu.style.display="block";const e=t.getBoundingClientRect(),i=e.left||(t.startContainer.parentElement||this.editor.editor).getBoundingClientRect().left,o=e.bottom||e.top;this.menu.style.left=`${Math.round(i+window.scrollX)}px`,this.menu.style.top=`${Math.round(o+window.scrollY+6)}px`;const n=this.menu.offsetHeight;e.bottom+n+8>window.innerHeight&&(this.menu.style.top=`${Math.round(e.top+window.scrollY-n-6)}px`)}close(){this.isOpen&&(this.isOpen=!1,this.menu.style.display="none")}move(t){this.activeIndex=(this.activeIndex+t+this.items.length)%this.items.length,[...this.menu.children].forEach((t,e)=>{t.classList.toggle("active",e===this.activeIndex),t.setAttribute("aria-selected",e===this.activeIndex?"true":"false")})}render(t){this.menu.innerHTML="",this.items.forEach((e,i)=>{const o=document.createElement("button");o.type="button",o.className="yjd-mention-item"+(i===this.activeIndex?" active":""),o.setAttribute("role","option"),o.setAttribute("aria-selected",i===this.activeIndex?"true":"false");const n=e.name||e.label||e.id||"";o.innerHTML="function"==typeof t?t(e):`${e.avatar_url?`<img class="yjd-mention-avatar" src="${e.avatar_url}" alt="">`:""}<span class="yjd-mention-name">${this.char}${n}</span>`,o.addEventListener("pointerdown",t=>{t.preventDefault(),this.choose(i)}),this.menu.appendChild(o)})}choose(t){const e=this.items[t];if(!e)return this.close();const i=e.name||e.label||e.id||"";try{const t=this.node,o=window.getSelection(),n=document.createRange();n.setStart(t,this.start),n.setEnd(t,this.start+this.query.length+1),n.deleteContents();const r=document.createElement("span");r.className="mention",r.setAttribute("data-id",String(null!=e.id?e.id:"")),r.setAttribute("data-trigger",this.char),r.setAttribute("contenteditable","false"),r.textContent=this.char+i,n.insertNode(r);const s=document.createTextNode(" ");r.after(s);const a=document.createRange();a.setStart(s,1),a.collapse(!0),o.removeAllRanges(),o.addRange(a)}catch(t){}this.close(),this.editor.focus(),"function"==typeof this.editor.onContentChange&&this.editor.onContentChange(),this.editor.emit("mention:select",e)}destroy(){this._onInput&&this.editor.editor.removeEventListener("input",this._onInput),this._onKeydown&&this.editor.editor.removeEventListener("keydown",this._onKeydown,!0),this._onDocPointer&&document.removeEventListener("pointerdown",this._onDocPointer,!0),this.menu&&this.menu.parentNode&&this.menu.parentNode.removeChild(this.menu),super.destroy()}}class zt extends e{static DEFAULTS={minWidth:50,minHeight:50,maxWidth:800,maxHeight:600,maintainAspectRatio:!0,snapToGrid:!1,gridSize:10};constructor(t,e={}){super(t,e),this.activeElement=null,this.handles=[],this.isResizing=!1,this.startX=0,this.startY=0,this.startWidth=0,this.startHeight=0,this.currentHandle=null,this.aspectRatio=1,this.init()}init(){this.createHandles(),this.setupEventListeners()}createHandles(){this.handlesContainer=document.createElement("div"),this.handlesContainer.className="resize-handles-container",this.handlesContainer.style.position="absolute",this.handlesContainer.style.pointerEvents="none",this.handlesContainer.style.zIndex="997",this.handlesContainer.style.display="none";[{name:"nw",cursor:"nw-resize",position:{top:-4,left:-4}},{name:"ne",cursor:"ne-resize",position:{top:-4,right:-4}},{name:"sw",cursor:"sw-resize",position:{bottom:-4,left:-4}},{name:"se",cursor:"se-resize",position:{bottom:-4,right:-4}}].forEach(t=>{const e=this.createHandle(t);this.handles.push(e),this.handlesContainer.appendChild(e)}),this.editor.wrapper.appendChild(this.handlesContainer)}createHandle(t){const e=document.createElement("div");return e.className=`resize-handle resize-handle-${t.name}`,e.style.position="absolute",e.style.width="8px",e.style.height="8px",e.style.backgroundColor="#3b82f6",e.style.border="1px solid #fff",e.style.borderRadius="50%",e.style.cursor=t.cursor,e.style.pointerEvents="auto",e.style.boxShadow="0 2px 4px rgba(0,0,0,0.2)",e.style.zIndex="999",e.dataset.handle=t.name,Object.entries(t.position).forEach(([t,i])=>{e.style[t]=i+"px"}),e.addEventListener("mousedown",e=>this.handleMouseDown(e,t.name)),e}setupEventListeners(){this._onEditorClick=t=>this.handleElementClick(t),this._onDocClick=t=>{this.isClickOnResizableElement(t)||this.isClickOnHandle(t)||this.hideHandles()},this._onDocMousemove=t=>this.handleMouseMove(t),this._onDocMouseup=t=>this.handleMouseUp(t),this._onWindowScroll=()=>{this.activeElement&&this.updateHandlePosition()},this._onEditorScroll=()=>{this.activeElement&&this.updateHandlePosition()},this.editor.editor.addEventListener("click",this._onEditorClick),document.addEventListener("click",this._onDocClick),document.addEventListener("mousemove",this._onDocMousemove),document.addEventListener("mouseup",this._onDocMouseup),window.addEventListener("scroll",this._onWindowScroll),this.editor.editor.addEventListener("scroll",this._onEditorScroll),this.setupMutationObserver()}handleElementClick(t){const e=t.target;let i=this.findResizableElement(e);i&&(t.preventDefault(),t.stopPropagation(),this.showHandles(i))}findResizableElement(t){if(this.isResizableElement(t))return t;if("TD"===t.tagName||"TH"===t.tagName||"TR"===t.tagName||"TBODY"===t.tagName){let e=t.parentElement;for(;e&&"TABLE"!==e.tagName;)e=e.parentElement;if(e&&this.isResizableElement(e))return e}let e=t.parentElement;for(;e&&e!==this.editor.wrapper;){if(this.isResizableElement(e))return e;e=e.parentElement}return null}isResizableElement(t){const e=t.classList.contains("inserted-image"),i=t.classList.contains("inserted-video"),o=t.classList.contains("rich-editor-table");return e||i||o}isClickOnResizableElement(t){return this.isResizableElement(t.target)}isClickOnHandle(t){return t.target.classList.contains("resize-handle")}showHandles(t){this.activeElement=t,this.updateHandlePosition(),this.handlesContainer.style.display="block",(t.classList.contains("inserted-image")||t.classList.contains("inserted-video"))&&(this.aspectRatio=t.offsetWidth/t.offsetHeight),t.classList.contains("rich-editor-table")&&(t.style.position="relative",t.style.display="table",this.lastTableWidth=t.offsetWidth,this.lastTableHeight=t.offsetHeight,this.setupTableSizeMonitoring(t))}hideHandles(){this.tableSizeInterval&&(clearInterval(this.tableSizeInterval),this.tableSizeInterval=null),this.activeElement=null,this.handlesContainer.style.display="none"}updateHandlePosition(){if(!this.activeElement)return;if(!document.body.contains(this.activeElement))return void this.hideHandles();const t=this.activeElement.getBoundingClientRect(),e=this.editor.wrapper.getBoundingClientRect(),i=this.editor.wrapper.scrollTop||0,o=this.editor.wrapper.scrollLeft||0,n=t.top-e.top+i,r=t.left-e.left+o,s=t.width,a=t.height,l=n+a;this.handlesContainer.style.top=n+"px",this.handlesContainer.style.left=r+"px",this.handlesContainer.style.width=s+"px",this.handlesContainer.style.height=a+"px",(l<0||n>e.height)&&this.hideHandles()}handleMouseDown(t,e){t.preventDefault(),t.stopPropagation(),this.isResizing=!0,this.currentHandle=e,this.startX=t.clientX,this.startY=t.clientY,this.startWidth=this.activeElement.offsetWidth,this.startHeight=this.activeElement.offsetHeight;const i=this.activeElement.getBoundingClientRect();this.startLeft=i.left,this.startTop=i.top,this.activeElement.classList.add("resizing"),document.body.style.cursor=t.target.style.cursor,document.body.style.userSelect="none"}handleMouseMove(t){if(!this.isResizing||!this.activeElement)return;const e=t.clientX-this.startX,i=t.clientY-this.startY;let o=this.startWidth,n=this.startHeight;switch(this.currentHandle){case"nw":o=this.startWidth-e,n=this.startHeight-i;break;case"ne":o=this.startWidth+e,n=this.startHeight-i;break;case"sw":o=this.startWidth-e,n=this.startHeight+i;break;case"se":o=this.startWidth+e,n=this.startHeight+i}let r=this.options.maxWidth;const s=this.editor&&this.editor.editor;if(s){const t=getComputedStyle(s),e=s.clientWidth-(parseFloat(t.paddingLeft)||0)-(parseFloat(t.paddingRight)||0);e>0&&(r=Math.min(r,e))}if(o=Math.max(this.options.minWidth,Math.min(r,o)),n=Math.max(this.options.minHeight,Math.min(this.options.maxHeight,n)),(this.activeElement.classList.contains("inserted-image")||this.activeElement.classList.contains("inserted-video"))&&this.options.maintainAspectRatio){const t=o/this.aspectRatio,e=n*this.aspectRatio;Math.abs(o-e)<Math.abs(n-t)?o=e:n=t,o>r&&(o=r,n=o/this.aspectRatio)}this.options.snapToGrid&&(o=Math.round(o/this.options.gridSize)*this.options.gridSize,n=Math.round(n/this.options.gridSize)*this.options.gridSize),this.applyDimensions(o,n),this.updateHandlePosition(),this.emit("element-resize",{element:this.activeElement,width:o,height:n,handle:this.currentHandle})}handleMouseUp(t){this.isResizing&&(this.isResizing=!1,this.currentHandle=null,this.activeElement&&this.activeElement.classList.remove("resizing"),document.body.style.cursor="",document.body.style.userSelect="",this.emit("element-resize-complete",{element:this.activeElement,width:this.activeElement.offsetWidth,height:this.activeElement.offsetHeight}))}applyDimensions(t,e){if(this.activeElement)if(this.activeElement.classList.contains("rich-editor-table")){this.activeElement.style.width=t+"px",this.activeElement.style.minWidth=t+"px",this.activeElement.style.height=e+"px",this.activeElement.style.minHeight=e+"px";const i=this.activeElement.querySelectorAll("tr"),o=i.length>0?i[0].querySelectorAll("td, th").length:0;if(i.length>0&&o>0){const n=Math.floor(t/o),r=Math.floor(e/i.length);this.activeElement.querySelectorAll("td, th").forEach(t=>{t.style.minWidth=n+"px",t.style.minHeight=r+"px",t.style.height=r+"px"})}}else this.activeElement.style.width=t+"px",this.activeElement.style.height=e+"px","IFRAME"===this.activeElement.tagName&&(this.activeElement.width=t,this.activeElement.height=e)}getActiveElement(){return this.activeElement}setActiveElement(t){this.isResizableElement(t)&&this.showHandles(t)}checkAndUpdateHandles(){if(this.activeElement){if(!document.body.contains(this.activeElement)||!this.isResizableElement(this.activeElement))return void this.hideHandles();this.updateHandlePosition(),this.activeElement.classList.contains("rich-editor-table")&&this.checkTableSizeChange()}}refreshHandles(){this.activeElement&&document.body.contains(this.activeElement)&&this.updateHandlePosition()}setupTableSizeMonitoring(t){this.tableSizeInterval&&clearInterval(this.tableSizeInterval),this.tableSizeInterval=setInterval(()=>{this.activeElement&&this.activeElement.classList.contains("rich-editor-table")?this.checkTableSizeChange():(clearInterval(this.tableSizeInterval),this.tableSizeInterval=null)},100)}checkTableSizeChange(){if(!this.activeElement||!this.activeElement.classList.contains("rich-editor-table"))return;const t=this.activeElement.offsetWidth,e=this.activeElement.offsetHeight;(Math.abs(t-this.lastTableWidth)>1||Math.abs(e-this.lastTableHeight)>1)&&(this.lastTableWidth=t,this.lastTableHeight=e,this.updateHandlePosition(),this.emit("table-size-changed",{element:this.activeElement,width:t,height:e,previousWidth:this.lastTableWidth,previousHeight:this.lastTableHeight}))}setupMutationObserver(){"undefined"!=typeof MutationObserver&&(this.mutationObserver=new MutationObserver(t=>{let e=!1;t.forEach(t=>{if(this.activeElement){if("childList"===t.type){if(t.removedNodes)for(let i of t.removedNodes)if(i===this.activeElement||i.contains(this.activeElement)){e=!0;break}(t.target===this.activeElement||t.target.nodeType===Node.ELEMENT_NODE&&this.activeElement.contains(t.target))&&(e=!0)}if("characterData"===t.type&&this.activeElement.classList.contains("rich-editor-table")){let i=t.target;for(;i&&i!==this.activeElement;)i=i.parentNode;i===this.activeElement&&(e=!0)}if("attributes"===t.type&&this.activeElement.classList.contains("rich-editor-table")){const i=t.attributeName;"style"!==i&&"class"!==i||(e=!0)}}}),e&&setTimeout(()=>{this.checkAndUpdateHandles()},0)}),this.mutationObserver.observe(this.editor.editor,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["style","class"],characterData:!0,characterDataOldValue:!0}))}setMaintainAspectRatio(t){this.options.maintainAspectRatio=t}setConstraints(t,e,i,o){this.options.minWidth=t||this.options.minWidth,this.options.minHeight=e||this.options.minHeight,this.options.maxWidth=i||this.options.maxWidth,this.options.maxHeight=o||this.options.maxHeight}destroy(){this.hideHandles(),this._onDocClick&&(this.editor.editor.removeEventListener("click",this._onEditorClick),document.removeEventListener("click",this._onDocClick),document.removeEventListener("mousemove",this._onDocMousemove),document.removeEventListener("mouseup",this._onDocMouseup),window.removeEventListener("scroll",this._onWindowScroll),this.editor.editor.removeEventListener("scroll",this._onEditorScroll),this._onEditorClick=this._onDocClick=this._onDocMousemove=null,this._onDocMouseup=this._onWindowScroll=this._onEditorScroll=null),this.handlesContainer&&this.handlesContainer.remove(),this.tableSizeInterval&&(clearInterval(this.tableSizeInterval),this.tableSizeInterval=null),this.mutationObserver&&(this.mutationObserver.disconnect(),this.mutationObserver=null),super.destroy()}}class Ot{constructor(t={}){this.options={onImageInsert:null,editor:null,...t},this.popup=null,this.isVisible=!1,this.clickOutsideHandler=null,this.selectedImageSrc=null,this.savedSelection=null,this.resizeHandler=null,this.createImagePopup()}createImagePopup(){this.popup=document.createElement("div"),this.popup.className="image-popup";const t=document.createElement("div");t.className="image-popup-content";const e=document.createElement("h3");e.textContent="Insert image",e.className="yjd-input-title",t.appendChild(e);const i=document.createElement("div");i.className="image-input-container";const o=document.createElement("p");o.textContent="Your image url",o.className="yjd-input-label";const n=document.createElement("div");n.className="yjd-input-upload-group",this.inputGroup=n,this.urlInput=document.createElement("input"),this.urlInput.type="url",this.urlInput.className="yjd-input",this.urlInput.placeholder="Please enter your image URL",this.fileInput=document.createElement("input"),this.fileInput.type="file",this.fileInput.accept="image/*",this.fileInput.className="image-input-hidden",this.fileInput.addEventListener("change",t=>this.handleFileSelect(t));const r=document.createElement("button");r.innerHTML='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="17 8 12 3 7 8"/><line x1="12" x2="12" y1="3" y2="15"/></svg>',r.className="yjd-custom-upload-button",this.customButton=r,r.addEventListener("click",()=>this.fileInput.click()),this.createPreviewContainer(),n.appendChild(this.urlInput),n.appendChild(this.fileInput),n.appendChild(r),i.appendChild(o),i.appendChild(n),i.appendChild(this.previewContainer),t.appendChild(i),this.urlInput.addEventListener("input",()=>{this.updateInsertButton();const t=this.urlInput.value.trim();t&&this.isValidImageUrl(t)?this.showPreview(t):this.removePreview(),this.urlInput.value.trim()?this.customButton.style.display="none":this.customButton.style.display="flex"});const s=document.createElement("div");s.className="yjd-button-container";const a=document.createElement("button");a.type="button",a.className="image-button yjd-button-cancel",a.textContent="Cancel",a.addEventListener("click",()=>{this.hide(),this.options.editor&&setTimeout(()=>this.options.editor.focus(),0)}),this.insertButton=document.createElement("button"),this.insertButton.type="button",this.insertButton.className="image-button yjd-button-confirm button-disable",this.insertButton.textContent="Add image",this.insertButton.disabled=!0,this.insertButton.addEventListener("click",()=>{this.insertImage(),this.options.editor&&setTimeout(()=>this.options.editor.focus(),0)}),s.appendChild(a),s.appendChild(this.insertButton),t.appendChild(s),this.popup.appendChild(t),q(this.popup),this.options.editor&&"function"==typeof this.options.editor.preventFocusLoss&&this.options.editor.preventFocusLoss(this.popup)}async handleFileSelect(t){const e=t.target.files[0];if(e)try{const{default:t}=await Promise.resolve().then(function(){return yt});this.selectedImageSrc=await t.handleFileUpload(e),this.urlInput.value="",this.showPreview(this.selectedImageSrc),this.updateInsertButton()}catch(t){alert(t.message)}}updateInsertButton(){const t=this.selectedImageSrc||this.urlInput.value.trim();this.insertButton.disabled=!t,this.insertButton.classList.toggle("button-disable",!t)}showPreview(t){t&&(this.imagePreview.src=t,this.previewContainer.style.display="block",this.selectedImageSrc=t,this.toggleInputGroup(!1),this.recalculatePosition())}removePreview(){this.selectedImageSrc=null,this.previewContainer.style.display="none",this.imagePreview.src="",this.toggleInputGroup(!0),this.fileInput&&(this.fileInput.value=""),this.updateInsertButton(),this.recalculatePosition()}toggleInputGroup(t){this.inputGroup&&(t?(this.inputGroup.style.display="flex",this.inputGroup.style.visibility="visible",this.customButton&&(this.customButton.style.pointerEvents="auto")):(this.inputGroup.style.display="none",this.inputGroup.style.visibility="hidden"))}createPreviewContainer(){this.previewContainer=document.createElement("div"),this.previewContainer.className="image-preview-container",this.previewContainer.style.cssText="display: none; position: relative;",this.imagePreview=document.createElement("img"),this.imagePreview.className="image-preview",this.imagePreview.style.cssText="max-width: 100%; max-height: 200px; border-radius: 8px; object-fit: contain;",this.removeButton=document.createElement("button"),this.removeButton.className="image-remove-button",this.removeButton.innerHTML="×",this.removeButton.style.cssText="\n position: absolute; top: 5px; right: 5px; background: rgba(0,0,0,0.7);\n color: white; border: none; border-radius: 50%; width: 24px; height: 24px;\n cursor: pointer; font-size: 16px; font-weight: bold;\n ",this.removeButton.addEventListener("click",()=>this.removePreview()),this.previewContainer.appendChild(this.imagePreview),this.previewContainer.appendChild(this.removeButton)}isValidImageUrl(t){try{const e=new URL(t),i=[".jpg",".jpeg",".png",".gif",".webp",".svg",".bmp"],o=["imgur.com","images.unsplash.com","picsum.photos","via.placeholder.com"],n=e.pathname.toLowerCase(),r=i.some(t=>n.endsWith(t)),s=o.some(t=>e.hostname.includes(t));return r||s}catch{return!1}}async insertImage(){let t=this.selectedImageSrc||this.urlInput.value.trim();if(t){try{const{default:e}=await Promise.resolve().then(function(){return yt});if(!await e.validateImageUrl(t))return void alert("Invalid image URL. Please check the URL and try again.")}catch(t){return void alert("Error validating image URL.")}this.restoreSelection(),this.options.onImageInsert&&this.options.onImageInsert(t,""),this.hide(),this.reset()}}reset(){this.fileInput.value="",this.urlInput.value="",this.selectedImageSrc=null,this.previewContainer.style.display="none",this.imagePreview.src="",this.toggleInputGroup(!0),this.updateInsertButton(),this.customButton.style.display="block"}saveSelection(){const t=window.getSelection();t&&t.rangeCount>0&&(this.savedSelection=t.getRangeAt(0).cloneRange())}restoreSelection(){if(this.savedSelection){const t=window.getSelection();t.removeAllRanges(),t.addRange(this.savedSelection)}}setupClickOutside(){this.clickOutsideHandler&&document.removeEventListener("click",this.clickOutsideHandler),this.clickOutsideHandler=t=>{this.popup.contains(t.target)||this.hide()},setTimeout(()=>{document.addEventListener("click",this.clickOutsideHandler)},100)}setupResizeHandler(){this.resizeHandler&&window.removeEventListener("resize",this.resizeHandler),this.resizeHandler=()=>{this.isVisible&&this.recalculatePosition()},window.addEventListener("resize",this.resizeHandler)}removeResizeHandler(){this.resizeHandler&&(window.removeEventListener("resize",this.resizeHandler),this.resizeHandler=null)}removeClickOutside(){this.clickOutsideHandler&&(document.removeEventListener("click",this.clickOutsideHandler),this.clickOutsideHandler=null)}show(t){if(!t)return;this.saveSelection(),this.reset(),this.currentAnchor=t;const e=$(t,this.popup,{offsetY:5,offsetX:0});X(this.popup,e),this.popup.classList.add("visible"),this.isVisible=!0,this.setupClickOutside()}recalculatePosition(){this.currentAnchor&&this.isVisible&&setTimeout(()=>{const t=$(this.currentAnchor,this.popup,{offsetY:5,offsetX:0});X(this.popup,t)},10)}hide(){this.popup.classList.remove("visible"),this.isVisible=!1,this.removeClickOutside(),this.savedSelection=null}destroy(){this.removeClickOutside(),this.popup&&this.popup.parentNode&&this.popup.parentNode.removeChild(this.popup),this.popup=null,this.isVisible=!1}}t.register("formats/bold",H,!0),t.register("formats/italic",z,!0),t.register("formats/underline",O,!0),t.register("formats/strike",M,!0),t.register("formats/subscript",P,!0),t.register("formats/superscript",_,!0),t.register("formats/color",G,!0),t.register("formats/background",Y,!0),t.register("formats/link",Z,!0),t.register("formats/table",tt,!0),t.register("formats/heading",it,!0),t.register("formats/font-family",ot,!0),t.register("formats/line-height",nt,!0),t.register("formats/capitalization",rt,!0),t.register("formats/text-align",at,!0),t.register("formats/list",dt,!0),t.register("formats/indent",ht,!0),t.register("formats/indent-increase",pt,!0),t.register("formats/indent-decrease",ut,!0),t.register("formats/emoji",gt,!0),t.register("formats/image",ft,!0),t.register("formats/video",vt,!0),t.register("formats/tag",wt,!0),t.register("formats/text-size",Et,!0),t.register("formats/import",jt,!0),t.register("modules/toolbar",It,!0),t.register("modules/history",St,!0),t.register("modules/block-toolbar",Nt,!0),t.register("modules/table-toolbar",Lt,!0),t.register("modules/code-view",At,!0),t.register("modules/find-replace",Bt,!0),t.register("modules/slash-menu",Rt,!0),t.register("modules/mention",Ht,!0),t.register("modules/resize-handles",zt,!0),t.register("ui/color-picker",K,!0),t.register("ui/text-align-picker",st,!0),t.register("ui/list-picker",ct,!0),t.register("ui/emoji-picker",mt,!0),t.register("ui/image-popup",Ot,!0),t.register("ui/video-popup",bt,!0),t.register("ui/tag-popup",Ct,!0),t.register("ui/custom-button",Tt,!0),class{static loaded=!1;static styleElement=null;static loadStyles(){if(this.loaded)return Promise.resolve();try{this.styleElement=document.createElement("style"),this.styleElement.id="rich-editor-styles",this.styleElement.textContent='@keyframes rte-pop-in{0%{opacity:0;transform:translateY(-2px)}to{opacity:1;transform:none}}@keyframes yjd-slash-in{0%{opacity:0;transform:translateY(-2px)}to{opacity:1;transform:none}}.yjd-rich-editor,.yjd-rich-editor .rich-editor-area{background:#fff;position:relative;box-sizing:border-box}.yjd-rich-editor{border:1px solid #d1d5db;border-radius:8px;overflow:hidden;margin:0 auto;display:flex;flex-direction:column}@layer base{.yjd-rich-editor .toolbar-container ::file-selector-button,.yjd-rich-editor .toolbar-container button,.yjd-rich-editor .toolbar-container input,.yjd-rich-editor .toolbar-container optgroup,.yjd-rich-editor .toolbar-container select,.yjd-rich-editor .toolbar-container textarea{font:500 14px/1.4"Inter",Arial,sans-serif!important;letter-spacing:normal!important;font-feature-settings:normal!important;font-variation-settings:normal!important}.yjd-rich-editor .emoji-picker-popup .emoji-button,.yjd-rich-editor .emoji-picker-popup button.emoji-button{font-size:20px!important}}@layer base{.yjd-rich-editor .rich-editor-popup-container ::file-selector-button,.yjd-rich-editor .rich-editor-popup-container button,.yjd-rich-editor .rich-editor-popup-container input,.yjd-rich-editor .rich-editor-popup-container optgroup,.yjd-rich-editor .rich-editor-popup-container select,.yjd-rich-editor .rich-editor-popup-container textarea{font:500 14px/1.4"Inter",Arial,sans-serif!important;letter-spacing:normal!important;font-feature-settings:normal!important;font-variation-settings:normal!important}.yjd-rich-editor .emoji-picker-popup .emoji-button,.yjd-rich-editor .emoji-picker-popup button.emoji-button{font-size:20px!important}}.yjd-rich-editor .rich-editor-area{flex:1 1 auto;min-height:40px;outline:0;overflow-y:auto;border:0;text-align:left;font-family:inherit;color:#2c3e50}.yjd-rich-editor .rich-editor-area[data-placeholder]:before{content:attr(data-placeholder);color:#9ca3af;pointer-events:none;position:absolute;top:0;left:0;right:0;padding:inherit;box-sizing:border-box;font:inherit;font-style:italic;line-height:inherit;display:none;z-index:1}.yjd-rich-editor .custom-select-item-button.current .item-checkmark,.yjd-rich-editor .rich-editor-area div,.yjd-rich-editor .rich-editor-area[data-placeholder].placeholder-visible:before{display:block}.yjd-rich-editor .rich-editor-area b,.yjd-rich-editor .rich-editor-area strong{font-weight:700}.yjd-rich-editor .rich-editor-area em,.yjd-rich-editor .rich-editor-area i{font-style:italic}.yjd-rich-editor .rich-editor-area u{text-decoration:underline}.yjd-rich-editor .rich-editor-area a{color:#2563eb;text-decoration:underline;cursor:pointer;color:var(--rte-accent-ink);text-decoration-color:var(--rte-accent-ring);text-underline-offset:2px}.yjd-content p,.yjd-rich-editor .rich-editor-area p{margin:0 0 1em}.yjd-content h1,.yjd-rich-editor .rich-editor-area h1{font-size:2em;font-weight:700;margin:.67em 0}.yjd-content h2,.yjd-rich-editor .rich-editor-area h2{font-size:1.5em;font-weight:700;margin:.75em 0}.yjd-content h3,.yjd-rich-editor .rich-editor-area h3{font-size:1.25em;font-weight:700;margin:.83em 0}.yjd-content h4,.yjd-rich-editor .rich-editor-area h4{font-size:1.1em;font-weight:700;margin:1em 0}.yjd-content h5,.yjd-rich-editor .rich-editor-area h5{font-size:1em;font-weight:700;margin:1.25em 0}.yjd-content h6,.yjd-rich-editor .rich-editor-area h6{font-size:.875em;font-weight:700;margin:1.5em 0;color:#555}.yjd-content ol,.yjd-content ul{margin:0 0 1em 2em;padding:0}.yjd-rich-editor .rich-editor-area ol,.yjd-rich-editor .rich-editor-area ul{padding:0}.yjd-rich-editor .rich-editor-area li{margin:.25em 0 4px;line-height:1.6}.yjd-rich-editor .rich-editor-area code,.yjd-rich-editor .rich-editor-area pre{font-family:Consolas,Menlo,Monaco,"Courier New",monospace;background:#f1f2f3;overflow-x:auto}.yjd-rich-editor .rich-editor-area pre{border-radius:4px;display:block;margin:1em 0;background-color:#f1f2f3;width:96%;white-space:pre;word-wrap:normal;background:#20242f;color:#ececf5;border-radius:var(--rte-radius-md);padding:14px 16px;border:0}.yjd-rich-editor .rich-editor-area code{display:inline;background:var(--rte-chrome-2);border-radius:6px;padding:2px 6px;font-size:.9em}.yjd-content blockquote{margin:1em 0;padding:4px 12px}.yjd-content blockquote,.yjd-rich-editor .rich-editor-area blockquote{border-left:4px solid #d1d5db;color:#555;font-style:italic;background:#f9fafb}.yjd-rich-editor .rich-editor-area sub{font-size:.75em;vertical-align:sub;line-height:1}.yjd-rich-editor .rich-editor-area sup{font-size:.75em;vertical-align:super;line-height:1}.yjd-rich-editor .rich-editor-area:empty::before{content:"";display:block}.yjd-rich-editor .rich-editor-statusbar{position:relative;z-index:1000;border-top:1px solid #d1d5db;background:#f9fafb;font-size:13px;color:#6b7280;font-family:inherit;min-height:32px;box-sizing:border-box}.yjd-rich-editor .rich-editor-toolbar-container{border-bottom:1px solid #d1d5db;position:relative;z-index:1000}.yjd-rich-editor .rich-editor-toolbar-1,.yjd-rich-editor .rich-editor-toolbar-2{gap:20px;background:#fcfcfc;min-height:48px;box-sizing:border-box;width:100%;z-index:1000;position:relative}.yjd-rich-editor .rich-editor-toolbar-2{display:none;overflow:hidden}.yjd-rich-editor .rich-editor-toolbar-2.visible{display:flex}.yjd-rich-editor .rich-editor-toolbar-btn{width:22px;border-radius:4px;font-size:14px;font-weight:500}.yjd-rich-editor .custom-select-button span{justify-content:left!important}.yjd-rich-editor .custom-select-button:focus{outline:0;border-color:#3b82f6;box-shadow:0 0 0 1px rgba(59,130,246,.1)}.yjd-rich-editor .rich-editor-toolbar-btn span{display:flex!important;align-items:center;justify-content:center}.yjd-rich-editor .rich-editor-toolbar-btn:hover{background:#eee!important;cursor:pointer}.yjd-rich-editor .block-toolbar-btn{border-radius:4px;padding:4px;cursor:pointer;font-size:14px;font-weight:500;align-items:center;justify-content:center;display:inline-flex}.yjd-rich-editor .block-toolbar-btn:hover{background:#eee}.yjd-rich-editor .block-toolbar-btn.active{background:#ccc;color:#136fdf!important}.yjd-rich-editor .block-toolbar-btn.active svg,.yjd-rich-editor .block-toolbar-btn.active svg path{fill:#136fdf!important}.yjd-rich-editor .block-toolbar-container{display:flex;align-items:center;background:#fff;border-radius:6.9px;box-shadow:0 4px 24px rgba(0,0,0,.13)}.yjd-rich-editor .block-toolbar-arrow{position:absolute;bottom:-6px;left:50%;transform:translateX(-50%);width:0;height:0;border-left:6px solid transparent;border-right:6px solid transparent;border-top:6px solid #fff;filter:drop-shadow(0 2px 4px rgba(0,0,0,.1))}.yjd-rich-editor .table-toolbar-container{display:flex;align-items:center;background:#fff;border-radius:6px;box-shadow:0 4px 24px rgba(0,0,0,.13)}.yjd-rich-editor .table-toolbar-arrow{position:absolute;bottom:-6px;left:50%;transform:translateX(-50%);width:0;height:0;border-left:6px solid transparent;border-right:6px solid transparent;border-top:6px solid #fff;filter:drop-shadow(0 2px 4px rgba(0,0,0,.1))}.yjd-rich-editor .block-toolbar{display:none;position:absolute;z-index:1001;background:0 0;border:0;border-radius:6.9px;box-sizing:border-box;padding:0;gap:0;flex-direction:column;align-items:center}.yjd-rich-editor .block-toolbar.visible{display:flex}.yjd-rich-editor .color-picker-popup{position:absolute;background:#fff;display:none;border-radius:6.9px;padding:8px;z-index:1000;pointer-events:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.yjd-rich-editor .capitalization-select-popup.visible,.yjd-rich-editor .color-picker-popup.visible,.yjd-rich-editor .custom-select-popup.visible,.yjd-rich-editor .font-family-select-popup.visible,.yjd-rich-editor .heading-select-popup.visible,.yjd-rich-editor .line-height-select-popup.visible,.yjd-rich-editor .text-size-select-popup.visible{display:block!important}.yjd-rich-editor .capitalization-select-popup,.yjd-rich-editor .custom-select-popup,.yjd-rich-editor .font-family-select-popup,.yjd-rich-editor .heading-select-popup,.yjd-rich-editor .line-height-select-popup,.yjd-rich-editor .text-size-select-popup{position:absolute;background:#fff;display:none;border:1px solid #d1d5db;border-radius:6.9px;z-index:1002;max-height:200px;overflow-y:auto;pointer-events:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.yjd-rich-editor .image-popup,.yjd-rich-editor .link-popup,.yjd-rich-editor .tag-popup,.yjd-rich-editor .video-popup{width:299px}.yjd-rich-editor .item-list{display:flex;flex-direction:column;gap:2px}.yjd-rich-editor .heading-select-popup{width:190px;max-width:100vw}.yjd-rich-editor .capitalization-select-popup{width:150px;max-width:100vw}.yjd-rich-editor .font-family-select-popup{width:190px;max-width:100vw}.yjd-rich-editor .line-height-select-popup{width:80px;max-width:100vw}.yjd-rich-editor .text-size-select-popup{width:150px;max-width:100vw}.yjd-rich-editor .custom-select-item-button{width:100%;border:0;background:0 0;border-radius:6px;cursor:pointer;text-align:left;transition:all .2s ease;font-size:14px;line-height:1.4;color:#111827;display:flex;align-items:center;justify-content:space-between;pointer-events:auto}.yjd-rich-editor .custom-select-item-button:hover{background:#eee}.yjd-rich-editor .custom-select-item-button.current{background:#eee!important}.yjd-rich-editor .custom-select-item-button .item-checkmark{display:none}.yjd-rich-editor .item-text{flex:1}.yjd-rich-editor .dropdown-icon{display:inline-flex!important;align-items:center;justify-content:center;width:16px;height:16px;flex:0 0 auto}.yjd-rich-editor .dropdown-icon svg{width:16px;height:16px;display:block;stroke:currentColor;fill:none}.yjd-rich-editor .color-grid{display:grid;grid-template-columns:repeat(6,1fr);gap:6px 4px;margin-bottom:12px}.yjd-rich-editor .color-button{width:24px;height:24px;border:0;border-radius:50%;cursor:pointer;transition:all .2s ease;padding:0;margin:0;pointer-events:auto}.yjd-rich-editor .color-button:hover{transform:scale(1.1);border-color:#374151;box-shadow:0 2px 4px rgba(0,0,0,.1)}.yjd-rich-editor .custom-color-container{position:relative;padding-top:8px;display:flex;align-items:center;gap:8px;z-index:0}.yjd-rich-editor .custom-color-container::before{content:"";position:absolute;top:0;left:-8px;width:calc(100% + 16px);height:0;border-top:1px solid #e5e7eb;z-index:-1}.yjd-rich-editor .custom-color-label{font-size:12px;color:#6b7280;margin:0}.yjd-rich-editor .yjd-input-label,.yjd-rich-editor .yjd-input-title{margin:0;color:#252424;font-size:16px;font-style:normal;line-height:normal}.yjd-rich-editor .yjd-input-label{font-size:14px;font-weight:700}.yjd-rich-editor .yjd-input-group{display:flex;flex-direction:column;gap:8px}.yjd-rich-editor .yjd-input{flex:1 1 auto;min-width:0;max-width:100%;max-height:37px;border-radius:10px;border:1px solid #e1e1e1;color:#252424!important}.yjd-rich-editor .yjd-input:focus{border-color:#3b82f6;box-shadow:0 0 0 1px rgba(59,130,246,.1)}.yjd-rich-editor .yjd-button-container{display:flex;justify-content:flex-end;gap:4px}.yjd-rich-editor .yjd-button-cancel,.yjd-rich-editor .yjd-button-confirm{border-radius:6px;align-items:center;box-shadow:0 1px 3.3px 0 rgba(0,0,0,.04);font-style:normal;line-height:normal;cursor:pointer}.yjd-rich-editor .yjd-button-confirm{background:#181616}.yjd-rich-editor .yjd-button-cancel{border:1px solid #e0e0e0;background:#fff;color:#2a2727}.yjd-rich-editor .button-disable{cursor:not-allowed}.yjd-rich-editor .link-popup{position:absolute;background:#fff;font-family:"Lato",sans-serif;display:none;border:0;border-radius:10px;z-index:1000;margin:0;pointer-events:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.yjd-rich-editor .link-popup.visible{display:block!important}.yjd-rich-editor .link-popup-content{display:flex;flex-direction:column;gap:16px;padding:16px}.yjd-rich-editor .yjd-input-upload-group{display:flex;align-items:center;gap:4px}.yjd-rich-editor .yjd-custom-upload-button{display:flex!important;align-items:center;justify-content:center;padding:0;border:1px solid #e1e1e1;background:#fff;width:34px;height:34px;border-radius:10px;cursor:pointer}.yjd-rich-editor .yjd-suggestions-list{display:flex;flex-wrap:wrap;gap:8px;flex:1 1 auto;min-width:0;max-width:100%}.yjd-rich-editor .yjd-suggestion-button{border:0;display:flex;padding:4px 10px;justify-content:center;align-items:center;border-radius:30px;background:#f5f5f5;cursor:pointer;font-size:14px;color:#252424!important}.yjd-rich-editor .yjd-select-input{border-radius:10px;border:1px solid #e1e1e1;max-height:37px;align-items:center;color:#252424!important}.yjd-rich-editor .yjd-select-input:focus{border-color:#3b82f6;box-shadow:0 0 0 1px rgba(59,130,246,.1)}.yjd-rich-editor .table-popup{position:absolute;background:#fff;font-family:"Lato",sans-serif;display:none;border:1px solid #d1d5db;border-radius:6.9px;z-index:1000;pointer-events:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.yjd-rich-editor .table-popup.visible{display:block!important}.yjd-rich-editor .table-popup-content{padding:8px;display:flex;flex-direction:column;align-items:center;gap:12px;position:relative}.yjd-rich-editor .table-popup-content>*{position:relative;width:100%}.yjd-rich-editor .table-popup-content>:not(:last-child)::after{content:"";position:absolute;bottom:-8px;left:-8px;right:-8px;height:1px;background-color:#e5e7eb}.yjd-rich-editor .table-grid-selector{display:grid;grid-template-columns:repeat(8,1fr);gap:1px;border-bottom:1px solid #eee}.yjd-rich-editor .table-size-display{display:flex;align-items:center;justify-content:center;font-family:"Lato",sans-serif;color:#252424!important;font-size:12px;font-style:normal;font-weight:400;line-height:normal}.yjd-rich-editor .table-grid-cell{width:20px;height:20px;background:#fff;border:1px solid #eee;cursor:pointer;transition:background-color .1s ease;border-radius:2px}.yjd-rich-editor .table-grid-cell.highlighted,.yjd-rich-editor .table-grid-cell:hover{background:#eee}.yjd-rich-editor .rich-editor-table{border-collapse:collapse;width:100%;max-width:100%;box-sizing:border-box;margin:16px 0;font-size:14px;line-height:1.5;position:relative;display:table;table-layout:fixed}.yjd-rich-editor .rich-editor-table td{box-sizing:border-box;border:1px solid #d1d5db;padding:8px 12px;min-height:28px;vertical-align:top;background:#fff;overflow-wrap:break-word}.yjd-rich-editor .rich-editor-table td:focus{outline-offset:-2px;background:#fefefe}.yjd-rich-editor .table-toolbar{position:absolute;display:none;z-index:1002;background:0 0;border:0;border-radius:6.9px;opacity:0;pointer-events:none}.yjd-rich-editor .table-toolbar-group{display:flex;gap:8px;align-items:center}.yjd-rich-editor .table-toolbar.visible{display:block;opacity:1;pointer-events:auto;transform:translateY(0)}.yjd-rich-editor .table-toolbar-btn{padding:4px;display:inline-flex;align-items:center;justify-content:center;border-radius:4px;font-size:12px;font-weight:500;cursor:pointer;transition:all .15s ease;white-space:nowrap}.yjd-rich-editor .table-toolbar-btn:hover{background:#f3f4f6;color:#111827}.yjd-rich-editor .table-toolbar-btn:active{background:#e5e7eb;border-color:#9ca3af;color:#136fdf!important}@media (max-width:768px){.yjd-rich-editor .table-toolbar-container{flex-wrap:wrap;max-width:200px;gap:2px}.yjd-rich-editor .table-toolbar-btn{height:24px;min-width:24px;font-size:10px;padding:2px 4px}}.yjd-rich-editor .text-align-picker-popup{position:absolute;background:#fff;display:none;border:1px solid #d1d5db;border-radius:6.9px;z-index:1000;pointer-events:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.yjd-rich-editor .text-align-picker-popup.visible{display:block!important}.yjd-rich-editor .align-button-container{display:flex}.yjd-rich-editor .align-button .icon-wrapper{display:flex;margin-left:8px;align-items:center;justify-content:center}.yjd-rich-editor .align-button .label-text{color:#252424;font-size:12px;font-style:normal;font-weight:400;line-height:normal}.yjd-rich-editor .align-button{border-radius:3.456px;background:#fff;border:0;align-items:center;display:flex;cursor:pointer;pointer-events:auto}.yjd-rich-editor .align-button:hover{background:#f3f4f6}.yjd-rich-editor .align-button.active{background:#e5e7eb}.yjd-rich-editor .align-button.active svg{color:#1f2937}.yjd-rich-editor .list-picker-popup{position:absolute;background:#fff;display:none;border-radius:6.9px;box-shadow:0 4px 16px rgba(0,0,0,.1);z-index:1000;pointer-events:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.yjd-rich-editor .list-picker-popup.visible{display:block!important}.yjd-rich-editor .list-button-container{display:grid;grid-template-columns:repeat(3,1fr)}.yjd-rich-editor .list-button{border-radius:3.46px;display:flex}.yjd-rich-editor .list-button:hover{background:#f3f4f6}.yjd-rich-editor .list-button.active{background:#eee}.yjd-rich-editor .list-button svg{color:#374151}.yjd-rich-editor .list-button.active svg{color:#fff}.yjd-rich-editor .rich-editor-area ul.checklist{list-style:none;padding-left:0}.yjd-rich-editor .rich-editor-area ul.checklist li{position:relative;padding-left:25px;margin-bottom:4px}.yjd-rich-editor .rich-editor-area ul.checklist li input[type=checkbox]{position:absolute;left:0;top:2px;margin:0;cursor:pointer}.yjd-rich-editor .rich-editor-area ol,.yjd-rich-editor .rich-editor-area ul{margin:12px 0;padding-left:20px}.yjd-rich-editor .rich-editor-area .indented,.yjd-rich-editor .rich-editor-area [style*=padding-left]{transition:padding-left .2s ease}.yjd-rich-editor .indent-decrease-btn svg,.yjd-rich-editor .indent-increase-btn svg{width:16px;height:16px;fill:#454545}.yjd-rich-editor .indent-decrease-btn:hover svg,.yjd-rich-editor .indent-increase-btn:hover svg{fill:#454545}.yjd-rich-editor .indent-decrease-btn:disabled,.yjd-rich-editor .indent-increase-btn:disabled{opacity:.5;cursor:not-allowed}.yjd-rich-editor .indent-decrease-btn:disabled svg,.yjd-rich-editor .indent-increase-btn:disabled svg{fill:#9ca3af}.yjd-rich-editor .emoji-picker-popup{position:absolute;z-index:10000;background:#fff;border-radius:8px;padding:8px;display:none;overflow-y:auto;pointer-events:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.yjd-rich-editor .emoji-picker-popup.visible{display:block}.yjd-rich-editor .emoji-grid{display:grid;grid-template-columns:repeat(10,1fr);gap:4px;max-height:240px;overflow-y:auto}.yjd-rich-editor .emoji-text-message{margin-top:4px;color:#71787c;text-align:center;font-family:"Segoe UI",Arial,sans-serif;font-size:12px;font-style:normal;font-weight:400;line-height:normal}.yjd-rich-editor .emoji-button{width:28px;height:28px;border:0;background:0 0;padding:0;border-radius:4px;cursor:pointer;font-size:20px!important;display:flex;align-items:center;justify-content:center;transition:background-color .2s ease;pointer-events:auto}.yjd-rich-editor .emoji-button:hover{background-color:#f3f4f6}.yjd-rich-editor .emoji{font-size:1.1em;line-height:1}.yjd-rich-editor .image-popup{position:absolute;z-index:10000;background:#fff;font-family:"Lato",sans-serif;border-radius:10px;display:none;margin:0;pointer-events:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.yjd-rich-editor .image-popup.visible,.yjd-rich-editor .tag-popup.visible,.yjd-rich-editor .video-popup.visible{display:block}.yjd-rich-editor .image-popup-content{display:flex;flex-direction:column;gap:16px;padding:16px}.yjd-rich-editor .image-input-container{gap:8px;display:flex;flex-direction:column}.yjd-rich-editor .image-input-hidden{display:none}.yjd-rich-editor .video-popup{position:absolute;z-index:10000;background:#fff;font-family:"Lato",sans-serif;border-radius:10px;display:none;margin:0;pointer-events:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.yjd-rich-editor .video-popup-content{display:flex;flex-direction:column;gap:16px;padding:16px}.yjd-rich-editor .video-input-container{gap:8px;display:flex;flex-direction:column}.yjd-rich-editor .inserted-image,.yjd-rich-editor .inserted-video{max-width:100%;height:auto;margin:4px 0;border-radius:4px;display:block}.yjd-rich-editor .inserted-video{background:#000}.yjd-rich-editor .tag-popup{position:absolute;z-index:10000;background:#fff;font-family:"Lato",sans-serif;border-radius:10px;display:none;margin:0;pointer-events:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.tag-popup{max-height:80vh;overflow-y:auto}.tag-suggestions-container{max-height:200px;overflow-y:auto}.yjd-rich-editor .tag-popup-content{display:flex;flex-direction:column;gap:16px;padding:16px}.yjd-rich-editor .tag-type-container{gap:8px;display:flex;flex-direction:column}.yjd-rich-editor .custom-tag{display:inline-block;padding:2px 6px;border-radius:12px;font-size:.85em;font-weight:500;cursor:pointer;margin:0 2px}.yjd-rich-editor .custom-tag.tag-mention{background:#dbeafe;color:#1d4ed8}.yjd-rich-editor .custom-tag.tag-hashtag{background:#dcfce7;color:#166534}.yjd-rich-editor .custom-tag.tag-custom{background:#fef3c7;color:#92400e}.yjd-rich-editor .custom-tag:hover{opacity:.8}.yjd-rich-editor .import-popup{position:absolute;z-index:10000;background:#fff;border:1px solid #d1d5db;border-radius:8px;display:none;width:400px;max-width:90vw;pointer-events:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.yjd-rich-editor .import-popup.visible{display:block}.yjd-rich-editor .import-popup-content{padding:20px}.yjd-rich-editor .import-popup-title{margin:0 0 20px;font-size:18px;font-weight:600;color:#1f2937}.yjd-rich-editor .import-type-container{margin-bottom:20px}.yjd-rich-editor .import-input-label{display:block;margin-bottom:8px;font-size:14px;font-weight:500;color:#374151}.yjd-rich-editor .import-type-select{border:1px solid #d1d5db;border-radius:6px;font-size:14px;background:#fff;color:#374151}.yjd-rich-editor .import-type-select:focus{border-color:#3b82f6;box-shadow:0 0 0 1px rgba(59,130,246,.1)}.yjd-rich-editor .import-file-input{width:100%;padding:10px 12px;border:1px solid #d1d5db;border-radius:6px;font-size:14px;background:#fff;color:#374151;margin-bottom:16px;cursor:pointer;box-sizing:border-box}.yjd-rich-editor .import-file-input:disabled{background-color:#f3f4f6;cursor:not-allowed;opacity:.5}.yjd-rich-editor .import-file-input:focus{outline:0;border-color:#3b82f6;box-shadow:0 0 0 1px rgba(59,130,246,.1)}.yjd-rich-editor .import-file-info{padding:12px;background-color:#f9fafb;border:1px solid #e5e7eb;border-radius:6px;margin-bottom:16px;font-size:14px;color:#374151}.yjd-rich-editor .import-file-info div{margin-bottom:4px}.yjd-rich-editor .import-file-info div:last-child{margin-bottom:0}.yjd-rich-editor .import-button-container{display:flex;justify-content:flex-end;gap:10px;margin-top:20px}.yjd-rich-editor .import-button{padding:10px 20px;border:1px solid #d1d5db;border-radius:6px;font-size:14px;font-weight:500;cursor:pointer;transition:all .2s}.yjd-rich-editor .import-button:hover{background-color:#f3f4f6}.yjd-rich-editor .import-button.import-button-main{background-color:#3b82f6;color:#fff;border-color:#3b82f6}.yjd-rich-editor .import-button.import-button-main:hover{background-color:#2563eb}.yjd-rich-editor .import-button.import-button-main:disabled{background-color:#9ca3af;border-color:#9ca3af;cursor:not-allowed}.yjd-rich-editor .import-button.cancel-button{background-color:#fff;color:#6b7280}.yjd-rich-editor .import-button.cancel-button:hover,.yjd-rich-editor .imported-table tr:hover{background-color:#f9fafb}.yjd-rich-editor .imported-content{margin:16px 0;padding:16px;border:1px dashed #d1d5db;border-radius:6px;background-color:#f9fafb}.yjd-rich-editor .imported-content.html-content{border-color:#3b82f6;background-color:#eff6ff}.yjd-rich-editor .imported-content.excel-content{border-color:#10b981;background-color:#f0fdf4}.yjd-rich-editor .imported-content.text-content{border-color:#f59e0b;background-color:#fffbeb}.yjd-rich-editor .imported-table{width:100%;border-collapse:collapse;font-size:14px;background:#fff;border-radius:4px;overflow:hidden;box-shadow:0 1px 3px rgba(0,0,0,.1)}.yjd-rich-editor .imported-table td,.yjd-rich-editor .imported-table th{padding:12px;text-align:left;border-bottom:1px solid #e5e7eb}.yjd-rich-editor .imported-table th{background-color:#f3f4f6;font-weight:600;color:#374151}.yjd-rich-editor .imported-content p{margin:8px 0;line-height:1.6;color:#374151}.yjd-rich-editor .imported-content p:first-child{margin-top:0}.yjd-rich-editor .imported-content p:last-child{margin-bottom:0}.yjd-rich-editor .code-view-textarea{width:100%;height:500px;font-family:"Consolas","Monaco","Courier New",monospace;font-size:14px;line-height:1.5;padding:16px;background-color:#f8fafc;color:#374151;resize:vertical;border:0;outline:0;white-space:pre;word-wrap:break-word;tab-size:2;box-sizing:border-box}@media (max-width:768px){.yjd-rich-editor .code-view-textarea{font-size:13px;padding:12px}.yjd-rich-editor.code-view-active::after{top:5px;right:5px;font-size:11px;padding:3px 6px}}.yjd-rich-editor .resize-handles-container{position:absolute;pointer-events:none;z-index:997;display:none}.yjd-rich-editor .resize-handles-container.active{display:block}.yjd-rich-editor .resize-handle{position:absolute;width:8px;height:8px;background-color:#3b82f6;pointer-events:auto;box-shadow:0 2px 4px rgba(0,0,0,.2);transition:all .2s ease;z-index:999}.yjd-rich-editor .resize-handle:hover{background-color:#2563eb;transform:scale(1.2);box-shadow:0 2px 6px rgba(0,0,0,.3)}.yjd-rich-editor .resize-handle-nw{top:-4px;left:-4px;cursor:nw-resize}.yjd-rich-editor .resize-handle-ne{top:-4px;right:-4px;cursor:ne-resize}.yjd-rich-editor .resize-handle-sw{bottom:-4px;left:-4px;cursor:sw-resize}.yjd-rich-editor .resize-handle-se{bottom:-4px;right:-4px;cursor:se-resize}.yjd-rich-editor .inserted-image.resizing,.yjd-rich-editor .inserted-video.resizing,.yjd-rich-editor .rich-editor-table.resizing{outline:2px solid #3b82f6;outline-offset:2px;opacity:.8}.yjd-rich-editor .inserted-image.resizing,.yjd-rich-editor .inserted-video.resizing{-webkit-user-select:none;user-select:none;pointer-events:none}.yjd-rich-editor .rich-editor-table.resizing{-webkit-user-select:none;user-select:none}.yjd-rich-editor .rich-editor-table.resizing td{pointer-events:none}.yjd-rich-editor .inserted-image:hover,.yjd-rich-editor .inserted-video:hover,.yjd-rich-editor .rich-editor-table:hover{outline:1px solid #3b82f6;outline-offset:1px;cursor:pointer}@media (max-width:768px){.yjd-rich-editor .resize-handle{width:12px;height:12px}.yjd-rich-editor .resize-handle-nw{top:-6px;left:-6px}.yjd-rich-editor .resize-handle-ne{top:-6px;right:-6px}.yjd-rich-editor .resize-handle-sw{bottom:-6px;left:-6px}.yjd-rich-editor .resize-handle-se{bottom:-6px;right:-6px}}@media (max-width:849px){.yjd-rich-editor{margin:0;width:100%!important;max-width:100%!important}.yjd-rich-editor .rich-editor-area{padding:12px;min-height:150px;font-size:14px;line-height:1.4}.yjd-rich-editor .rich-editor-statusbar{padding:6px 8px;font-size:11px;flex-wrap:wrap;gap:8px}.yjd-rich-editor .editor-dropdown,.yjd-rich-editor .editor-popup{position:fixed!important;top:50%!important;left:50%!important;transform:translate(-50%,-50%)!important;width:90%!important;max-width:320px!important;max-height:80vh!important;overflow-y:auto;z-index:10000}.yjd-rich-editor .editor-popup::before{content:"";position:fixed;top:0;left:0;width:100%;height:100%;background:rgba(0,0,0,.5);z-index:-1}.yjd-rich-editor .color-picker{width:100%!important;max-width:280px!important}.yjd-rich-editor .color-picker-grid{grid-template-columns:repeat(6,1fr)!important;gap:8px!important}.yjd-rich-editor .color-picker-item{width:32px!important;height:32px!important}.yjd-rich-editor .table-popup{max-width:300px!important}.yjd-rich-editor .table-size-grid{grid-template-columns:repeat(8,1fr)!important;gap:2px!important}.yjd-rich-editor .table-size-cell{width:24px!important;height:24px!important}.yjd-rich-editor .list-picker{width:100%!important;max-width:250px!important}.yjd-rich-editor .list-picker-btn{padding:12px!important;font-size:14px!important}.yjd-rich-editor .text-align-picker{width:100%!important;max-width:200px!important}.yjd-rich-editor .image-popup,.yjd-rich-editor .import-popup,.yjd-rich-editor .link-popup,.yjd-rich-editor .video-popup{width:90%!important;max-width:350px!important}.yjd-rich-editor .media-upload-area{min-height:100px!important;padding:20px!important}.yjd-rich-editor .tag-popup{width:90%!important;max-width:320px!important}.yjd-rich-editor .emoji-picker{width:100%!important;max-width:300px!important;max-height:350px!important}.yjd-rich-editor .emoji-grid{grid-template-columns:repeat(8,1fr)!important;gap:4px!important}.yjd-rich-editor .emoji-item{width:32px!important;height:32px!important;font-size:18px!important}.yjd-rich-editor .code-view-textarea{font-size:12px!important;padding:8px!important;line-height:1.3!important}.yjd-rich-editor .rich-editor-area h1{font-size:1.5em!important;margin:.5em 0!important}.yjd-rich-editor .rich-editor-area h2{font-size:1.3em!important;margin:.5em 0!important}.yjd-rich-editor .rich-editor-area h3{font-size:1.1em!important;margin:.5em 0!important}.yjd-rich-editor .rich-editor-area p{margin:.8em 0!important}.yjd-rich-editor .rich-editor-area ol,.yjd-rich-editor .rich-editor-area ul{padding-left:20px!important;margin:.8em 0!important}.yjd-rich-editor .rich-editor-area blockquote{padding-left:12px!important;margin:.8em 0!important;font-size:14px!important}.yjd-rich-editor .rich-editor-area table{font-size:13px!important;overflow-x:auto!important;display:block!important;white-space:nowrap!important}.yjd-rich-editor .rich-editor-area td,.yjd-rich-editor .rich-editor-area th{padding:6px 8px!important;min-width:60px!important}}@media (max-width:290px){.yjd-rich-editor .emoji-picker{max-width:calc(100vw - 20px)!important}.yjd-rich-editor .emoji-grid{grid-template-columns:repeat(auto-fit,minmax(30px,1fr))!important}}@media print{.yjd-rich-editor .rich-editor-statusbar,.yjd-rich-editor .rich-editor-toolbar-1,.yjd-rich-editor .rich-editor-toolbar-2{display:none!important}.yjd-rich-editor{border:0!important;box-shadow:none!important}.yjd-rich-editor .rich-editor-area{padding:0!important;background:#fff!important;color:#000!important}}.yjd-rich-editor .rich-editor-popup-container{position:absolute;top:0;left:0;width:100%;height:100%;pointer-events:none;z-index:1005;overflow:visible;max-height:90%;overflow-y:auto}.yjd-rich-editor .capitalization-select-popup button,.yjd-rich-editor .color-picker-popup button,.yjd-rich-editor .custom-color-input,.yjd-rich-editor .custom-select-popup button,.yjd-rich-editor .custom-tag,.yjd-rich-editor .emoji-picker-popup button,.yjd-rich-editor .font-family-select-popup button,.yjd-rich-editor .heading-select-popup button,.yjd-rich-editor .image-input-hidden,.yjd-rich-editor .image-popup button,.yjd-rich-editor .image-popup input,.yjd-rich-editor .image-popup select,.yjd-rich-editor .import-csv-input,.yjd-rich-editor .import-file-input,.yjd-rich-editor .import-html-input,.yjd-rich-editor .import-input,.yjd-rich-editor .import-json-input,.yjd-rich-editor .import-markdown-input,.yjd-rich-editor .import-popup button,.yjd-rich-editor .import-popup input,.yjd-rich-editor .import-popup select,.yjd-rich-editor .import-text-input,.yjd-rich-editor .import-toml-input,.yjd-rich-editor .import-type-select,.yjd-rich-editor .import-url-input,.yjd-rich-editor .import-xml-input,.yjd-rich-editor .import-yaml-input,.yjd-rich-editor .line-height-select-popup button,.yjd-rich-editor .link-popup button,.yjd-rich-editor .link-popup input,.yjd-rich-editor .link-popup select,.yjd-rich-editor .list-button,.yjd-rich-editor .list-picker-popup button,.yjd-rich-editor .table-popup button,.yjd-rich-editor .table-popup input,.yjd-rich-editor .table-toolbar-btn,.yjd-rich-editor .tag-popup button,.yjd-rich-editor .tag-popup input,.yjd-rich-editor .tag-popup select,.yjd-rich-editor .tag-type-select,.yjd-rich-editor .tag-value-input,.yjd-rich-editor .text-align-picker-popup button,.yjd-rich-editor .text-size-select-popup button,.yjd-rich-editor .video-input-hidden,.yjd-rich-editor .video-popup button,.yjd-rich-editor .video-popup input,.yjd-rich-editor .video-popup select,.yjd-rich-editor .yjd-button-cancel,.yjd-rich-editor .yjd-button-confirm,.yjd-rich-editor .yjd-custom-upload-button,.yjd-rich-editor .yjd-input,.yjd-rich-editor .yjd-select-input,.yjd-rich-editor .yjd-suggestion-button{pointer-events:auto!important}.yjd-rich-editor .rich-editor-popup-container>*{pointer-events:auto}.yjd-rich-editor .rich-editor-popup-container .color-picker-popup,.yjd-rich-editor .rich-editor-popup-container .custom-select-popup,.yjd-rich-editor .rich-editor-popup-container .emoji-picker-popup,.yjd-rich-editor .rich-editor-popup-container .image-popup,.yjd-rich-editor .rich-editor-popup-container .import-popup,.yjd-rich-editor .rich-editor-popup-container .link-popup,.yjd-rich-editor .rich-editor-popup-container .list-picker-popup,.yjd-rich-editor .rich-editor-popup-container .table-popup,.yjd-rich-editor .rich-editor-popup-container .tag-popup,.yjd-rich-editor .rich-editor-popup-container .text-align-picker-popup,.yjd-rich-editor .rich-editor-popup-container .video-popup{position:absolute!important;z-index:1001!important}.yjd-rich-editor{--rte-bg:#ffffff;--rte-chrome:#fbfbfd;--rte-chrome-2:#f2f2f7;--rte-border:#e9e9f1;--rte-border-strong:#dadae6;--rte-ink:#20242f;--rte-muted:#767c8e;--rte-accent:#6d5efc;--rte-accent-ink:#5a48ee;--rte-accent-weak:#efedff;--rte-accent-ring:rgba(109, 94, 252, 0.28);--rte-danger:#e5484d;--rte-radius:14px;--rte-radius-md:11px;--rte-radius-sm:8px;--rte-shadow-sm:0 1px 2px rgba(20, 24, 46, 0.06);--rte-shadow:0 12px 32px -8px rgba(20, 24, 46, 0.20), 0 4px 10px -4px rgba(20, 24, 46, 0.10);--rte-t:140ms cubic-bezier(0.4, 0, 0.2, 1);border:1px solid var(--rte-border)!important;border-radius:var(--rte-radius)!important;background:var(--rte-bg);color:var(--rte-ink);box-shadow:var(--rte-shadow-sm);font-family:system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,sans-serif}.yjd-rich-editor .rich-editor-popup-container button,.yjd-rich-editor .rich-editor-popup-container input,.yjd-rich-editor .rich-editor-popup-container select,.yjd-rich-editor .rich-editor-popup-container textarea,.yjd-rich-editor .toolbar-container button,.yjd-rich-editor .toolbar-container input,.yjd-rich-editor .toolbar-container select,.yjd-rich-editor .toolbar-container textarea{font-family:system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,sans-serif!important}.yjd-rich-editor .rich-editor-toolbar-container{background:var(--rte-chrome);border-bottom:1px solid var(--rte-border)}.yjd-rich-editor .rich-editor-toolbar-1,.yjd-rich-editor .rich-editor-toolbar-2{display:flex;align-items:center;column-gap:0;row-gap:4px;padding:8px 12px}.yjd-rich-editor .rich-editor-toolbar-2{justify-content:flex-start}.yjd-rich-editor .rich-editor-toolbar-2.visible{border-top:1px solid var(--rte-border)}.yjd-rich-editor .toolbar-group{display:flex;align-items:center;gap:2px;border-right:none;margin:0;padding:0}.yjd-rich-editor .toolbar-group+.toolbar-group{margin-left:12px}.yjd-rich-editor .rich-editor-toolbar-btn{color:var(--rte-ink)}.yjd-rich-editor .custom-select-button,.yjd-rich-editor .rich-editor-toolbar-btn{display:inline-flex;align-items:center;justify-content:center;gap:6px;min-width:32px;height:32px;padding:0 8px;border:1px solid transparent;border-radius:var(--rte-radius-sm);background:0 0;cursor:pointer;transition:background var(--rte-t),color var(--rte-t),box-shadow var(--rte-t),border-color var(--rte-t)}.yjd-rich-editor .rich-editor-toolbar-btn:hover{background:var(--rte-chrome-2)}.yjd-rich-editor .custom-select-button:hover{background:var(--rte-chrome-2);color:var(--rte-ink)}.yjd-rich-editor .rich-editor-toolbar-btn.active{background:var(--rte-accent-weak);border-color:transparent}.yjd-rich-editor .rich-editor-toolbar-btn:disabled,.yjd-rich-editor .rich-editor-toolbar-btn[disabled]{opacity:.38!important;cursor:not-allowed!important}.yjd-rich-editor .custom-select-button:focus-visible,.yjd-rich-editor .rich-editor-toolbar-btn:focus-visible{outline:0;border-color:var(--rte-accent);box-shadow:0 0 0 3px var(--rte-accent-ring)}.yjd-rich-editor .rich-editor-statusbar{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:7px 14px;background:var(--rte-chrome);border-top:1px solid var(--rte-border)}.yjd-rich-editor .rich-editor-breadcrumb,.yjd-rich-editor .wordcount{color:var(--rte-muted);font-size:12px;letter-spacing:.01em}.yjd-rich-editor .rich-editor-area{color:var(--rte-ink);font-size:16px;line-height:1.75;padding:22px 24px}.yjd-rich-editor .rich-editor-area[data-placeholder].placeholder-visible:before{color:var(--rte-muted);opacity:.55}.yjd-rich-editor .rich-editor-area blockquote{border-left:3px solid var(--rte-accent);background:var(--rte-accent-weak);border-radius:0 var(--rte-radius-sm) var(--rte-radius-sm)0;padding:8px 16px;color:var(--rte-ink);margin:12px 0}.yjd-rich-editor .rich-editor-area pre code{background:0 0;color:inherit;padding:0}.yjd-rich-editor .capitalization-select-popup,.yjd-rich-editor .color-picker-popup,.yjd-rich-editor .custom-select-popup,.yjd-rich-editor .emoji-picker-popup,.yjd-rich-editor .font-family-select-popup,.yjd-rich-editor .heading-select-popup,.yjd-rich-editor .image-popup,.yjd-rich-editor .import-popup,.yjd-rich-editor .line-height-select-popup,.yjd-rich-editor .link-popup,.yjd-rich-editor .table-popup,.yjd-rich-editor .tag-popup,.yjd-rich-editor .text-align-picker-popup,.yjd-rich-editor .text-size-select-popup,.yjd-rich-editor .video-popup{background:var(--rte-bg);border:1px solid var(--rte-border);box-shadow:var(--rte-shadow)}.yjd-rich-editor .custom-select-item-button{color:var(--rte-ink);transition:background var(--rte-t),color var(--rte-t)}.yjd-rich-editor .custom-select-item-button:hover{background:var(--rte-chrome-2)}.yjd-rich-editor .custom-select-item-button.current .item-checkmark{color:var(--rte-accent-ink)}.yjd-rich-editor .yjd-input{transition:border-color var(--rte-t),box-shadow var(--rte-t)}.yjd-rich-editor .yjd-input:focus{outline:0}.yjd-rich-editor .yjd-input-title{color:var(--rte-ink);font-weight:600}.yjd-rich-editor .yjd-input-label{color:var(--rte-muted)}.yjd-rich-editor .yjd-button-confirm{border:0}.yjd-rich-editor .yjd-button-cancel{background:var(--rte-chrome-2)}.yjd-rich-editor .yjd-button-cancel:hover{background:#e9e9f2}.yjd-rich-editor .yjd-custom-upload-button{border-radius:var(--rte-radius-sm);border:1px dashed var(--rte-border-strong);color:var(--rte-accent-ink);background:var(--rte-accent-weak);transition:background var(--rte-t),border-color var(--rte-t)}.yjd-rich-editor .yjd-custom-upload-button:hover{border-color:var(--rte-accent)}.yjd-rich-editor .block-toolbar-container,.yjd-rich-editor .table-toolbar-container{background:var(--rte-bg);border:1px solid var(--rte-border);border-radius:var(--rte-radius-md);box-shadow:var(--rte-shadow);padding:4px;gap:2px}.yjd-rich-editor .block-toolbar-btn,.yjd-rich-editor .table-toolbar-btn{border:1px solid transparent;border-radius:var(--rte-radius-sm);background:0 0;color:var(--rte-ink);transition:background var(--rte-t),color var(--rte-t)}.yjd-rich-editor .block-toolbar-btn:hover,.yjd-rich-editor .table-toolbar-btn:hover{background:var(--rte-chrome-2)}.yjd-rich-editor .block-toolbar-btn.active{background:var(--rte-accent-weak);color:var(--rte-accent-ink)}.yjd-rich-editor .block-toolbar-btn.active .icon svg,.yjd-rich-editor .block-toolbar-btn.active .icon svg path{fill:var(--rte-accent-ink)}.yjd-rich-editor .rich-editor-table td{border:1px solid var(--rte-border-strong)!important}.yjd-rich-editor .rich-editor-table td:focus{outline:0;box-shadow:inset 0 0 0 2px var(--rte-accent);background:var(--rte-accent-weak)}.yjd-rich-editor .table-grid-cell.highlighted{background:var(--rte-accent);border-color:var(--rte-accent)}.yjd-rich-editor .resize-handle{background:var(--rte-accent)!important;border:2px solid #fff!important;border-radius:50%!important;box-shadow:var(--rte-shadow-sm)!important}.yjd-rich-editor .yjd-find-replace{position:absolute;top:10px;right:10px;z-index:1100;display:none;flex-direction:column;gap:8px;padding:10px;background:var(--rte-bg);border:1px solid var(--rte-border);border-radius:var(--rte-radius-md);box-shadow:var(--rte-shadow);font:13px/1.4 system-ui,-apple-system,sans-serif;max-width:calc(100% - 20px)}.yjd-rich-editor .yjd-find-replace.open{display:flex}.yjd-rich-editor .yjd-find-row{display:flex;align-items:center;gap:6px}.yjd-rich-editor .yjd-find-input{flex:1 1 auto;min-width:150px;transition:border-color var(--rte-t),box-shadow var(--rte-t)}.yjd-rich-editor .yjd-find-input:focus{outline:0}.yjd-rich-editor .yjd-find-count{min-width:46px;text-align:center;color:var(--rte-muted);font-variant-numeric:tabular-nums}.yjd-rich-editor .yjd-find-btn{border:1px solid var(--rte-border);background:var(--rte-chrome);color:var(--rte-ink);cursor:pointer}.yjd-rich-editor .yjd-find-btn:hover{background:var(--rte-chrome-2)}.yjd-rich-editor .yjd-find-btn:focus-visible{outline:0;border-color:var(--rte-accent);box-shadow:0 0 0 3px var(--rte-accent-ring)}.yjd-rich-editor .yjd-find-icon{width:30px;padding:0;font-size:15px;line-height:1}.yjd-rich-editor .yjd-find-toggle.active{background:var(--rte-accent-weak);color:var(--rte-accent-ink);border-color:transparent}.yjd-rich-editor .yjd-find-replace .yjd-find-btn.yjd-find-close:hover{background:#fdecec;color:var(--rte-danger);border-color:#f6caca}.yjd-rich-editor .yjd-find-replace-input{flex:1 1 auto}.yjd-rich-editor .yjd-find-row .yjd-find-btn:not(.yjd-find-icon){flex:0 0 auto}.yjd-rich-editor mark.yjd-find-hit{background:#fff1b8;color:inherit;border-radius:3px}.yjd-rich-editor mark.yjd-find-hit.active{background:var(--rte-accent);color:#fff}@media (prefers-reduced-motion:reduce){.yjd-rich-editor *{transition-duration:.01ms!important;animation-duration:.01ms!important}}.yjd-rich-editor .block-toolbar-btn svg [fill="#454545"],.yjd-rich-editor .icon svg [fill="#010101"],.yjd-rich-editor .icon svg [fill="#231F20"],.yjd-rich-editor .icon svg [fill="#454545"],.yjd-rich-editor .icon svg[fill="#454545"],.yjd-rich-editor .table-toolbar-btn svg [fill="#454545"]{fill:currentColor}.yjd-rich-editor .block-toolbar-btn .icon,.yjd-rich-editor .rich-editor-toolbar-btn .icon,.yjd-rich-editor .table-toolbar-btn .icon{display:inline-flex;align-items:center;justify-content:center;width:18px;height:18px;color:inherit}.yjd-rich-editor .block-toolbar-btn .icon svg,.yjd-rich-editor .rich-editor-toolbar-btn .icon svg,.yjd-rich-editor .table-toolbar-btn .icon svg{width:auto!important;height:16px!important;max-width:18px;display:block}.yjd-rich-editor .rich-editor-toolbar-btn .icon svg,.yjd-rich-editor .rich-editor-toolbar-btn .icon svg path{fill:currentColor}.yjd-rich-editor .rich-editor-toolbar-btn{color:#4b5060}.yjd-rich-editor .rich-editor-toolbar-btn:hover{color:var(--rte-ink)}.yjd-rich-editor .rich-editor-toolbar-btn.active,.yjd-rich-editor .rich-editor-toolbar-btn.active .icon svg [fill]{color:var(--rte-accent-ink)!important;fill:var(--rte-accent-ink)!important}.yjd-rich-editor .rich-editor-toolbar-btn.active .icon svg,.yjd-rich-editor .rich-editor-toolbar-btn.active .icon svg path{fill:var(--rte-accent-ink)!important}.yjd-rich-editor .custom-select-button,.yjd-rich-editor .rich-editor-toolbar-btn{box-shadow:none}.yjd-rich-editor .custom-select-button{border-color:var(--rte-border);background:var(--rte-bg);color:var(--rte-ink);font-weight:500}.yjd-rich-editor .custom-select-button:hover{border-color:var(--rte-border-strong);background:var(--rte-bg)}.yjd-rich-editor .dropdown-icon{color:var(--rte-muted)}.yjd-rich-editor .capitalization-select-popup,.yjd-rich-editor .color-picker-popup,.yjd-rich-editor .custom-select-popup,.yjd-rich-editor .font-family-select-popup,.yjd-rich-editor .heading-select-popup,.yjd-rich-editor .image-popup,.yjd-rich-editor .import-popup,.yjd-rich-editor .line-height-select-popup,.yjd-rich-editor .link-popup,.yjd-rich-editor .table-popup,.yjd-rich-editor .tag-popup,.yjd-rich-editor .text-size-select-popup,.yjd-rich-editor .video-popup{border-color:var(--rte-border);border-radius:var(--rte-radius-md);box-shadow:0 10px 30px -10px rgba(20,24,46,.18),0 2px 6px -2px rgba(20,24,46,.08)}.yjd-rich-editor .emoji-picker-popup,.yjd-rich-editor .text-align-picker-popup{border-color:var(--rte-border);box-shadow:0 10px 30px -10px rgba(20,24,46,.18),0 2px 6px -2px rgba(20,24,46,.08)}.yjd-rich-editor .emoji-picker-popup{border-radius:var(--rte-radius-md)}.yjd-rich-editor .capitalization-select-popup,.yjd-rich-editor .custom-select-popup,.yjd-rich-editor .font-family-select-popup,.yjd-rich-editor .heading-select-popup,.yjd-rich-editor .line-height-select-popup,.yjd-rich-editor .text-size-select-popup{padding:6px}.yjd-rich-editor .capitalization-select-popup.visible,.yjd-rich-editor .color-picker-popup.visible,.yjd-rich-editor .custom-select-popup.visible,.yjd-rich-editor .font-family-select-popup.visible,.yjd-rich-editor .heading-select-popup.visible,.yjd-rich-editor .image-popup.visible,.yjd-rich-editor .line-height-select-popup.visible,.yjd-rich-editor .link-popup.visible,.yjd-rich-editor .table-popup.visible,.yjd-rich-editor .tag-popup.visible,.yjd-rich-editor .text-align-picker-popup.visible,.yjd-rich-editor .text-size-select-popup.visible,.yjd-rich-editor .video-popup.visible,.yjd-rich-editor .yjd-find-replace.open{animation:rte-pop-in 90ms ease-out}.yjd-rich-editor .yjd-input{height:36px;border:1px solid var(--rte-border);border-radius:var(--rte-radius-sm);background:var(--rte-bg);color:var(--rte-ink)}.yjd-rich-editor .yjd-select-input{height:36px;background:var(--rte-bg);font-size:14px}.yjd-rich-editor .yjd-find-input{height:36px;border:1px solid var(--rte-border);border-radius:var(--rte-radius-sm);background:var(--rte-bg);color:var(--rte-ink)}.yjd-rich-editor .yjd-find-input::placeholder,.yjd-rich-editor .yjd-input::placeholder,.yjd-rich-editor .yjd-select-input::placeholder{color:var(--rte-muted);opacity:.7}.yjd-rich-editor .yjd-find-input:focus,.yjd-rich-editor .yjd-input:focus{border-color:var(--rte-accent);box-shadow:0 0 0 3px var(--rte-accent-ring)}.yjd-rich-editor .yjd-button-cancel,.yjd-rich-editor .yjd-button-confirm,.yjd-rich-editor .yjd-find-btn{height:36px;padding:0 16px;font-size:14px;font-weight:500;border-radius:var(--rte-radius-sm);box-shadow:none;transition:background var(--rte-t),color var(--rte-t),border-color var(--rte-t)}.yjd-rich-editor .yjd-button-confirm{background:var(--rte-accent);border:1px solid var(--rte-accent);color:#fff}.yjd-rich-editor .yjd-button-confirm:hover{background:var(--rte-accent-ink);border-color:var(--rte-accent-ink)}.yjd-rich-editor .yjd-button-cancel{background:0 0;border:1px solid var(--rte-border);color:var(--rte-muted)}.yjd-rich-editor .yjd-button-cancel:hover{background:var(--rte-chrome-2);color:var(--rte-ink)}.yjd-rich-editor .yjd-find-btn:not(.yjd-find-icon){background:0 0;border:1px solid var(--rte-border);color:var(--rte-ink)}.yjd-rich-editor .yjd-find-btn:not(.yjd-find-icon):hover{background:var(--rte-chrome-2)}.yjd-rich-editor .yjd-find-btn.yjd-find-icon{height:32px;width:32px;color:var(--rte-muted);background:0 0;border:1px solid transparent}.yjd-rich-editor .yjd-find-btn.yjd-find-icon:hover{background:var(--rte-chrome-2);color:var(--rte-ink)}@media (prefers-reduced-motion:reduce){.yjd-rich-editor .color-picker-popup.visible,.yjd-rich-editor .yjd-find-replace.open,.yjd-rich-editor [class$=-popup].visible,.yjd-rich-editor [class*=select-popup].visible{animation:none!important}}.yjd-rich-editor .icon svg{display:block;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;overflow:visible}.yjd-rich-editor .icon svg line,.yjd-rich-editor .icon svg path,.yjd-rich-editor .icon svg polyline,.yjd-rich-editor .icon svg rect{fill:none!important;stroke:currentColor}.yjd-rich-editor .icon svg [fill=currentColor],.yjd-rich-editor .list-button svg [fill=currentColor],.yjd-rich-editor .table-toolbar-btn svg [fill=currentColor]{fill:currentColor!important;stroke:none!important}.yjd-rich-editor .rich-editor-toolbar-btn .icon svg{color:#565b6b}.yjd-rich-editor .rich-editor-toolbar-btn:hover .icon svg{color:var(--rte-ink)}.yjd-rich-editor .rich-editor-toolbar-btn.active .icon svg,.yjd-rich-editor .rich-editor-toolbar-btn.active .icon svg line,.yjd-rich-editor .rich-editor-toolbar-btn.active .icon svg path,.yjd-rich-editor .rich-editor-toolbar-btn.active .icon svg polyline,.yjd-rich-editor .rich-editor-toolbar-btn.active .icon svg rect{color:var(--rte-accent-ink)!important;stroke:var(--rte-accent-ink)!important;fill:none!important}.yjd-rich-editor .rich-editor-toolbar-btn.active .icon svg [fill=currentColor]{fill:var(--rte-accent-ink)!important;stroke:none!important}.yjd-rich-editor .block-toolbar-btn.active .icon svg,.yjd-rich-editor .block-toolbar-btn.active .icon svg path{stroke:var(--rte-accent-ink)!important;fill:none!important}.yjd-rich-editor .list-picker-popup{background:var(--rte-bg);border:1px solid var(--rte-border);border-radius:var(--rte-radius-md);box-shadow:var(--rte-shadow);padding:6px}.yjd-rich-editor .list-picker-popup.visible{animation:rte-pop-in 90ms ease-out}.yjd-rich-editor .list-button-container{display:flex;align-items:center;gap:2px}.yjd-rich-editor .list-button{display:inline-flex;align-items:center;justify-content:center;width:34px;height:32px;padding:0;border:1px solid transparent;border-radius:var(--rte-radius-sm);background:0 0;color:#565b6b;cursor:pointer;transition:background var(--rte-t),color var(--rte-t)}.yjd-rich-editor .list-button:hover{background:var(--rte-chrome-2);color:var(--rte-ink)}.yjd-rich-editor .list-button.active{background:var(--rte-accent-weak);color:var(--rte-accent-ink)}.yjd-rich-editor .icon svg,.yjd-rich-editor .list-button svg,.yjd-rich-editor .table-toolbar-btn svg{width:auto!important;height:16px!important;max-width:20px;fill:none!important}.yjd-rich-editor .list-button svg{stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}.yjd-rich-editor .table-toolbar-btn svg{display:block}.yjd-rich-editor .table-toolbar-btn{color:#565b6b}.yjd-rich-editor .table-toolbar-btn:hover{color:var(--rte-ink)}.yjd-rich-editor .align-button{border-radius:var(--rte-radius-sm);background:0 0;color:var(--rte-ink);transition:background var(--rte-t),color var(--rte-t)}.yjd-rich-editor .align-button:hover{background:var(--rte-chrome-2);border-color:transparent}.yjd-rich-editor .align-button.active{background:var(--rte-accent-weak);color:var(--rte-accent-ink);border-color:transparent}.yjd-rich-editor .align-button svg,.yjd-rich-editor .table-toolbar-btn svg,.yjd-slash-icon svg{stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}.yjd-rich-editor .align-button svg{width:auto!important;height:16px!important;color:inherit;fill:none!important}.yjd-rich-editor .align-button.active svg{color:var(--rte-accent-ink)}.yjd-rich-editor .yjd-custom-upload-button svg{width:17px;height:17px;fill:none;stroke:var(--rte-accent-ink)}.yjd-rich-editor .text-align-picker-popup{min-width:168px}.yjd-rich-editor .align-button,.yjd-rich-editor .align-button .label-text{white-space:nowrap}.yjd-rich-editor .rich-editor-toolbar-1{flex-wrap:nowrap!important;overflow:hidden}.yjd-rich-editor .rich-editor-toolbar-2{border-top:1px solid var(--rte-border)}.yjd-rich-editor .custom-select-button,.yjd-rich-editor .rich-editor-toolbar-btn,.yjd-rich-editor .toolbar-group{flex:0 0 auto}.yjd-rich-editor .block-toolbar-arrow,.yjd-rich-editor .table-toolbar-arrow{display:none!important}.yjd-slash-menu{position:absolute;z-index:2000;min-width:264px;max-width:320px;max-height:320px;overflow-y:auto;padding:6px;background:#fff;border:1px solid #e9e9f1;border-radius:12px;box-shadow:0 12px 32px -8px rgba(20,24,46,.2),0 4px 10px -4px rgba(20,24,46,.1);font:14px/1.4 system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,sans-serif;animation:yjd-slash-in 90ms ease-out}.yjd-slash-item{display:flex;align-items:center;gap:10px;width:100%;padding:8px 10px;border:0;background:0 0;border-radius:8px;cursor:pointer;text-align:left;color:#20242f}.yjd-slash-item.active,.yjd-slash-item:hover{background:#efedff;color:#5a48ee}.yjd-slash-icon{display:inline-flex;align-items:center;justify-content:center;width:28px;height:28px;flex:0 0 auto;border-radius:7px;background:#f2f2f7;color:inherit}.yjd-slash-item.active .yjd-slash-icon{background:#fff}.yjd-slash-icon svg{width:auto;height:16px;fill:none}.yjd-slash-icon svg [fill=currentColor]{fill:currentColor;stroke:none}.yjd-slash-text{display:flex;flex-direction:column;line-height:1.25;min-width:0}.yjd-slash-label{font-weight:500}.yjd-slash-hint{font-size:12px;color:#767c8e}.yjd-slash-item.active .yjd-slash-hint{color:#8b7ff0}@media (prefers-reduced-motion:reduce){.yjd-slash-menu{animation:none}}.yjd-rich-editor .rich-editor-toolbar-btn.background-btn,.yjd-rich-editor .rich-editor-toolbar-btn.color-btn{position:relative}.yjd-rich-editor .rich-editor-toolbar-btn .rte-swatch{position:absolute;left:50%;bottom:5px;transform:translateX(-50%);width:16px;height:3px;border-radius:2px;background:var(--rte-ink, #20242f);pointer-events:none;box-shadow:0 0 0 1px rgba(0,0,0,.06)}.yjd-rich-editor .rich-editor-toolbar-btn.background-btn .rte-swatch{background:0 0;box-shadow:inset 0 0 0 1px var(--rte-border, #e9e9f1)}.yjd-rich-editor .rich-editor-toolbar-btn.background-btn.has-color .rte-swatch{box-shadow:0 0 0 1px rgba(0,0,0,.06)}.yjd-rich-editor .rich-editor-toolbar-btn.background-btn .icon,.yjd-rich-editor .rich-editor-toolbar-btn.color-btn .icon{transform:translateY(-1px)}.yjd-rich-editor .link-popup.link-popup--inline{width:auto;min-width:320px;max-width:min(92vw,420px);padding:10px}.yjd-rich-editor .link-popup--inline .link-popup-content{display:flex;flex-direction:column;gap:8px}.yjd-rich-editor .link-popup--inline .link-popup-row{display:flex;align-items:center;gap:8px}.yjd-rich-editor .link-popup--inline .link-popup-row .yjd-input{flex:1;min-width:0;margin:0}.yjd-rich-editor .link-popup--inline .link-popup-apply{flex:0 0 auto;white-space:nowrap;padding:8px 16px;margin:0}.yjd-rich-editor .custom-select-item-button{min-height:34px;padding:6px 10px!important;gap:10px;border-radius:var(--rte-radius-sm)!important}.yjd-rich-editor .custom-select-item-button.current,.yjd-rich-editor .custom-select-item-button:hover{background:var(--rte-accent-weak)!important;color:var(--rte-accent-ink)!important}.yjd-rich-editor .custom-select-item-button.current{font-weight:600}.yjd-rich-editor .font-family-select-popup .custom-select-item-button,.yjd-rich-editor .heading-select-popup .custom-select-item-button,.yjd-rich-editor .text-size-select-popup .custom-select-item-button{line-height:1.15}.yjd-rich-editor .import-type-select,.yjd-rich-editor .tag-type-select,.yjd-rich-editor .yjd-select-input,.yjd-rich-editor select{-webkit-appearance:none;-moz-appearance:none;appearance:none;width:100%;box-sizing:border-box;padding:10px 36px 10px 12px;font:500 14px/1.4 system-ui,-apple-system,"Segoe UI",Roboto,sans-serif;color:var(--rte-ink);background-color:var(--rte-bg);background-image:url("data:image/svg+xml,%3Csvg%20xmlns=\'http://www.w3.org/2000/svg\'%20width=\'16\'%20height=\'16\'%20viewBox=\'0%200%2024%2024\'%20fill=\'none\'%20stroke=\'%23767c8e\'%20stroke-width=\'2\'%20stroke-linecap=\'round\'%20stroke-linejoin=\'round\'%3E%3Cpath%20d=\'m6%209%206%206%206-6\'/%3E%3C/svg%3E");background-repeat:no-repeat;background-position:right 12px center;background-size:16px;border:1px solid var(--rte-border-strong);border-radius:var(--rte-radius-sm);cursor:pointer;transition:border-color var(--rte-t),box-shadow var(--rte-t)}.yjd-rich-editor .import-type-select:hover,.yjd-rich-editor .tag-type-select:hover,.yjd-rich-editor .yjd-select-input:hover,.yjd-rich-editor select:hover{border-color:var(--rte-accent)}.yjd-rich-editor .import-type-select:focus,.yjd-rich-editor .tag-type-select:focus,.yjd-rich-editor .yjd-select-input:focus,.yjd-rich-editor select:focus{outline:0;border-color:var(--rte-accent);box-shadow:0 0 0 3px var(--rte-accent-ring)}.yjd-rich-editor .yjd-find-input,.yjd-rich-editor .yjd-input{box-sizing:border-box;padding:10px 12px;font-size:14px;line-height:1.4}.yjd-rich-editor .table-grid-cell:hover{background:var(--rte-accent-weak)!important;border-color:var(--rte-accent)!important}.yjd-rich-editor .rich-editor-toolbar-1{justify-content:flex-start!important}.yjd-rich-editor .rich-editor-toolbar-1 .more-btn{margin-left:auto!important}@media (max-width:640px){.yjd-rich-editor .rich-editor-toolbar-1{flex-wrap:nowrap!important;overflow-x:auto!important;overflow-y:hidden;-webkit-overflow-scrolling:touch;scrollbar-width:none;justify-content:flex-start!important;padding:6px 8px;scroll-padding:8px}.yjd-rich-editor .rich-editor-toolbar-1::-webkit-scrollbar{display:none}.yjd-rich-editor .rich-editor-toolbar-1 .more-btn,.yjd-rich-editor .rich-editor-toolbar-2{display:none!important}.yjd-rich-editor .toolbar-group{flex:0 0 auto}.yjd-rich-editor .toolbar-group+.toolbar-group{margin-left:8px}.yjd-rich-editor .custom-select-button,.yjd-rich-editor .rich-editor-toolbar-btn{min-width:32px;height:32px;padding:0 8px;flex:0 0 auto}.yjd-rich-editor .custom-select-button{max-width:none}}.yjd-rich-editor .rich-editor-toolbar-btn.rte-hidden{display:none!important}.yjd-rich-editor .rich-editor-area>:first-child{margin-top:0!important}.yjd-rich-editor .rich-editor-area>:last-child{margin-bottom:0!important}.yjd-rich-editor .align-button-container{flex-direction:row!important;width:auto!important;height:auto!important;gap:4px}.yjd-rich-editor .align-button{width:34px!important;min-height:34px!important;height:34px!important;padding:0!important;gap:0!important;justify-content:center!important}.yjd-rich-editor .text-align-picker-popup{width:auto!important}.yjd-rich-editor .rich-editor-toolbar-2{flex-wrap:nowrap!important;overflow-x:auto;overflow-y:hidden;-webkit-overflow-scrolling:touch;scrollbar-width:none}.yjd-rich-editor .rich-editor-toolbar-2::-webkit-scrollbar{display:none}.yjd-rich-editor .rich-editor-toolbar-2 .toolbar-group{flex:0 0 auto}.yjd-rich-editor .custom-select-header{padding:8px 12px 6px;font-size:11px;font-weight:600;letter-spacing:.05em;text-transform:uppercase;color:var(--rte-muted);border-bottom:1px solid var(--rte-border);margin-bottom:4px;white-space:nowrap}.yjd-rich-editor .custom-select-button .select-lead-icon{width:16px;height:16px;display:inline-flex;align-items:center;justify-content:center;color:var(--rte-muted);margin-right:4px}.yjd-rich-editor .custom-select-button .select-lead-icon svg{width:16px;height:16px;display:block;stroke:currentColor;fill:none}.yjd-rich-editor .custom-select-button{white-space:nowrap;overflow:hidden}.yjd-rich-editor .custom-select-button .button-text{flex:1 1 auto;min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.yjd-rich-editor .custom-select-button .dropdown-icon,.yjd-rich-editor .custom-select-button .select-lead-icon{flex:0 0 auto}.yjd-rich-editor .text-align-picker-popup{padding:6px!important;border-radius:var(--rte-radius-md)!important}.yjd-rich-editor .align-button-container{padding:0!important}.yjd-rich-editor .rich-editor-breadcrumb,.yjd-rich-editor .wordcount{color:#5b6373}.yjd-rich-editor .yjd-find-btn{display:inline-flex;align-items:center;justify-content:center}.yjd-rich-editor .yjd-find-icon .icon,.yjd-rich-editor .yjd-find-icon .icon svg{width:16px;height:16px;display:block}.yjd-rich-editor .yjd-find-icon .icon svg{stroke:currentColor;fill:none}.mention{display:inline;padding:0 2px;border-radius:4px;background:#efedff;color:#5a48ee;font-weight:500;text-decoration:none;white-space:nowrap}.mention[data-trigger="#"]{background:#e8f3ff;color:#1f6feb}.yjd-mention-menu{position:absolute;z-index:2000;min-width:220px;max-width:320px;max-height:280px;overflow-y:auto;padding:6px;background:#fff;border:1px solid #e9e9f1;border-radius:12px;box-shadow:0 12px 32px -8px rgba(20,24,46,.2),0 4px 10px -4px rgba(20,24,46,.1);font:14px/1.4 system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,sans-serif;animation:yjd-slash-in 90ms ease-out}.yjd-mention-item{display:flex;align-items:center;gap:10px;width:100%;padding:7px 10px;border:0;background:0 0;border-radius:8px;cursor:pointer;text-align:left;color:#20242f}.yjd-mention-item.active,.yjd-mention-item:hover{background:#efedff;color:#5a48ee}.yjd-mention-avatar{width:26px;height:26px;border-radius:50%;object-fit:cover;flex:0 0 auto;background:#f2f2f7}.yjd-mention-name{font-weight:500;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}@media (prefers-reduced-motion:reduce){.yjd-mention-menu{animation:none}}.yjd-content{font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif;font-size:16px;line-height:1.6;color:#20242f;word-wrap:break-word}.yjd-content>:first-child{margin-top:0}.yjd-content>:last-child{margin-bottom:0}.yjd-content li{margin:.25em 0}.yjd-content a{color:#2563eb;text-decoration:underline}.yjd-content code,.yjd-content pre{font-family:Consolas,Menlo,Monaco,"Courier New",monospace;background:#f1f2f3;padding:2px 6px;border-radius:4px}.yjd-content pre{padding:12px 14px;border-radius:6px;margin:1em 0;overflow-x:auto;white-space:pre}.yjd-content pre code{background:0 0;padding:0}.yjd-content img{max-width:100%;height:auto;border-radius:4px}.yjd-content hr{border:0;border-top:1px solid #d1d5db;margin:1.5em 0}.yjd-content table{border-collapse:collapse;width:100%;margin:1em 0}.yjd-content table td,.yjd-content table th{border:1px solid #d1d5db;padding:8px 10px;text-align:left}',document.head.appendChild(this.styleElement),this.loaded=!0}catch(t){this.loadFallbackStyles()}return Promise.resolve()}static loadFallbackStyles(){this.styleElement=document.createElement("style"),this.styleElement.id="rich-editor-styles-fallback",this.styleElement.textContent="\n .yjd-rich-editor { \n position: relative; \n background: #fff; \n border: 1px solid #ddd; \n border-radius: 4px; \n display: flex; \n flex-direction: column; \n font-family: system-ui, sans-serif; \n }\n .yjd-rich-editor .rich-editor-area { \n flex: 1; \n padding: 20px; \n outline: none; \n min-height: 100px; \n }\n .yjd-rich-editor .rich-editor-toolbar { \n display: flex; \n gap: 4px; \n padding: 8px; \n border-bottom: 1px solid #ddd; \n background: #f9f9f9; \n }\n .yjd-rich-editor .rich-editor-toolbar-btn { \n padding: 4px 8px; \n border: 1px solid #ccc; \n border-radius: 3px; \n background: #fff; \n cursor: pointer; \n }\n .yjd-rich-editor .table-grid-selector { \n position: absolute; \n background: white; \n border: 1px solid #ccc; \n border-radius: 4px; \n padding: 10px; \n box-shadow: 0 2px 8px rgba(0,0,0,0.15); \n z-index: 1000; \n display: none; \n }\n .yjd-rich-editor .table-grid-cell { \n width: 20px; \n height: 20px; \n border: 1px solid #ddd; \n cursor: pointer; \n background: white; \n }\n ",document.head.appendChild(this.styleElement),this.loaded=!0}static unloadStyles(){this.styleElement&&this.styleElement.parentNode&&(this.styleElement.parentNode.removeChild(this.styleElement),this.styleElement=null,this.loaded=!1)}static isLoaded(){return this.loaded}static async reloadStyles(){this.unloadStyles(),await this.loadStyles()}static addCustomCSS(t,e="rich-editor-custom"){const i=document.getElementById(e);i&&i.remove();const o=document.createElement("style");o.id=e,o.textContent=t,document.head.appendChild(o)}}.loadStyles().catch(t=>{});class Mt extends S{static register(e,i,o=!1){t.register(e,i,o)}static get(e){return t.get(e)}static create(t,e={}){return new Mt(t,e)}static fromTextarea(t,e={}){const i="string"==typeof t?document.querySelector(t):t;if(!i)throw new Error("RichEditor.fromTextarea: textarea not found");const o="markdown"===e.format?"markdown":"html",n=document.createElement("div");i.after(n),i.style.display="none",i.setAttribute("aria-hidden","true");const r=i.value||"",s=new Mt(n,{width:"100%",...e,content:null!=e.content?e.content:"markdown"===o?y(r):r}),a=()=>{const t=(e=s,"markdown"===o?e.getMarkdown():e.getContent());var e;i.value!==t&&(i.value=t,i.dispatchEvent(new Event("input",{bubbles:!0})),i.dispatchEvent(new Event("change",{bubbles:!0})))};return s.on("change",a),a(),s.textarea=i,s}}function Pt(t,e={}){return new Mt(t,e)}export{Y as Background,A as BlockFormat,Nt as BlockToolbar,H as Bold,rt as Capitalization,At as CodeView,G as Color,K as ColorPicker,S as Editor,gt as Emoji,mt as EmojiPicker,Bt as FindReplace,ot as FontFamily,N as Format,it as Heading,St as History,V as IconUtils,ft as Image,Ot as ImagePopup,jt as Import,ht as Indent,ut as IndentDecrease,pt as IndentIncrease,L as InlineFormat,z as Italic,nt as LineHeight,Z as Link,Q as LinkPopup,dt as List,ct as ListPicker,Ht as Mention,e as Module,zt as ResizeHandles,Mt as RichEditor,Rt as SlashMenu,M as Strike,P as Subscript,_ as Superscript,tt as Table,J as TablePopup,Lt as TableToolbar,wt as Tag,Ct as TagPopup,at as TextAlign,st as TextAlignPicker,Et as TextSize,It as Toolbar,O as Underline,vt as Video,bt as VideoPopup,Tt as createCustomButton,Pt as createEditor,Mt as default,k as domToJson,h as htmlToMarkdown,T as jsonToHtml,y as markdownToHtml,t as registry,B as renderStatic,Mt as yjd};
2
2
  //# sourceMappingURL=rich-editor.esm.js.map